[pve-devel] [PATCH xtermjs 1/3] upgrade xterm.js to version 4.3.0

Dominik Csapak d.csapak at proxmox.com
Tue Jan 21 15:38:27 CET 2020


adapt version of xterm.js
also download and unpack xterm-addon-fit
replace addon/fit/fit.js[.map] with xterm-addon-fit.js[.map]

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 Makefile                       |    12 +-
 src/www/addons/fit/fit.js      |    51 -
 src/www/addons/fit/fit.js.map  |     1 -
 src/www/xterm-addon-fit.js     |     2 +
 src/www/xterm-addon-fit.js.map |     1 +
 src/www/xterm.css              |     6 +-
 src/www/xterm.js               | 10219 +------------------------------
 src/www/xterm.js.map           |     2 +-
 8 files changed, 18 insertions(+), 10276 deletions(-)
 delete mode 100644 src/www/addons/fit/fit.js
 delete mode 100644 src/www/addons/fit/fit.js.map
 create mode 100644 src/www/xterm-addon-fit.js
 create mode 100644 src/www/xterm-addon-fit.js.map

diff --git a/Makefile b/Makefile
index 6c98ddb..836c171 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,12 @@ PACKAGE=pve-xtermjs
 
 export VERSION=${DEB_VERSION_UPSTREAM_REVISION}
 
-XTERMJSVER=3.13.2
+XTERMJSVER=4.3.0
 XTERMJSTGZ=xterm-${XTERMJSVER}.tgz
 
+FITADDONVER=0.3.0
+FITADDONTGZ=xterm-addon-fit-${FITADDONVER}.tgz
+
 SRCDIR=src
 BUILDDIR ?= ${PACKAGE}-${DEB_VERSION_UPSTREAM}
 GITVERSION:=$(shell git rev-parse HEAD)
@@ -40,9 +43,12 @@ X_EXCLUSIONS=--exclude=addons/attach --exclude=addons/fullscreen --exclude=addon
 .PHONY: download
 download:
 	wget https://registry.npmjs.org/xterm/-/${XTERMJSTGZ} -O ${XTERMJSTGZ}.tmp
+	wget https://registry.npmjs.org/xterm-addon-fit/-/${FITADDONTGZ} -O ${FITADDONTGZ}.tmp
 	mv ${XTERMJSTGZ}.tmp ${XTERMJSTGZ}
-	tar -C $(SRCDIR)/www -xf ${XTERMJSTGZ} package/dist --strip-components=2 ${X_EXCLUSIONS}
-	rm ${XTERMJSTGZ}
+	mv ${FITADDONTGZ}.tmp ${FITADDONTGZ}
+	tar -C $(SRCDIR)/www -xf ${XTERMJSTGZ} package/lib package/css --strip-components=2 ${X_EXCLUSIONS}
+	tar -C $(SRCDIR)/www -xf ${FITADDONTGZ} package/lib --strip-components=2 ${X_EXCLUSIONS}
+	rm ${XTERMJSTGZ} ${FITADDONTGZ}
 
 .PHONY: upload
 upload: ${DEB}
diff --git a/src/www/addons/fit/fit.js b/src/www/addons/fit/fit.js
deleted file mode 100644
index b137d99..0000000
--- a/src/www/addons/fit/fit.js
+++ /dev/null
@@ -1,51 +0,0 @@
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fit = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function proposeGeometry(term) {
-    if (!term.element.parentElement) {
-        return null;
-    }
-    var parentElementStyle = window.getComputedStyle(term.element.parentElement);
-    var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
-    var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
-    var elementStyle = window.getComputedStyle(term.element);
-    var elementPadding = {
-        top: parseInt(elementStyle.getPropertyValue('padding-top')),
-        bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
-        right: parseInt(elementStyle.getPropertyValue('padding-right')),
-        left: parseInt(elementStyle.getPropertyValue('padding-left'))
-    };
-    var elementPaddingVer = elementPadding.top + elementPadding.bottom;
-    var elementPaddingHor = elementPadding.right + elementPadding.left;
-    var availableHeight = parentElementHeight - elementPaddingVer;
-    var availableWidth = parentElementWidth - elementPaddingHor - term._core.viewport.scrollBarWidth;
-    var geometry = {
-        cols: Math.floor(availableWidth / term._core.renderer.dimensions.actualCellWidth),
-        rows: Math.floor(availableHeight / term._core.renderer.dimensions.actualCellHeight)
-    };
-    return geometry;
-}
-exports.proposeGeometry = proposeGeometry;
-function fit(term) {
-    var geometry = proposeGeometry(term);
-    if (geometry) {
-        if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
-            term._core.renderer.clear();
-            term.resize(geometry.cols, geometry.rows);
-        }
-    }
-}
-exports.fit = fit;
-function apply(terminalConstructor) {
-    terminalConstructor.prototype.proposeGeometry = function () {
-        return proposeGeometry(this);
-    };
-    terminalConstructor.prototype.fit = function () {
-        fit(this);
-    };
-}
-exports.apply = apply;
-
-},{}]},{},[1])(1)
-});
-//# sourceMappingURL=fit.js.map
diff --git a/src/www/addons/fit/fit.js.map b/src/www/addons/fit/fit.js.map
deleted file mode 100644
index 5f1042e..0000000
--- a/src/www/addons/fit/fit.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"fit.js","sources":["../../../src/addons/fit/fit.ts","../../../node_modules/browser-pack/_prelude.js"],"sourcesContent":["/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * Fit terminal columns and rows to the dimensions of its DOM element.\n *\n * ## Approach\n *\n *    Rows: Truncate the division of the terminal parent element height by the\n *          terminal row height.\n * Columns: Truncate the division of the terminal parent element width by the\n *          terminal character width (apply display: inline at the terminal\n *          row and truncate its width with the current number of columns).\n */\n\nimport { Terminal } from 'xterm';\n\nexport interface IGeometry {\n  rows: number;\n  cols: number;\n}\n\nexport function proposeGeometry(term: Terminal): IGeometry {\n  if (!term.element.parentElement) {\n    return null;\n  }\n  const parentElementStyle = window.getComputedStyle(term.element.parentElement);\n  const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\n  const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));\n  const elementStyle = window.getComputedStyle(term.element);\n  const elementPadding = {\n    top: parseInt(elementStyle.getPropertyValue('padding-top')),\n    bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),\n    right: parseInt(elementStyle.getPropertyValue('padding-right')),\n    left: parseInt(elementStyle.getPropertyValue('padding-left'))\n  };\n  const elementPaddingVer = elementPadding.top + elementPadding.bottom;\n  const elementPaddingHor = elementPadding.right + elementPadding.left;\n  const availableHeight = parentElementHeight - elementPaddingVer;\n  const availableWidth = parentElementWidth - elementPaddingHor - (<any>term)._core.viewport.scrollBarWidth;\n  const geometry = {\n    cols: Math.floor(availableWidth / (<any>term)._core.renderer.dimensions.actualCellWidth),\n    rows: Math.floor(availableHeight / (<any>term)._core.renderer.dimensions.actualCellHeight)\n  };\n  return geometry;\n}\n\nexport function fit(term: Terminal): void {\n  const geometry = proposeGeometry(term);\n  if (geometry) {\n    // Force a full render\n    if (term.rows !== geometry.rows || term.cols !== geometry.cols) {\n      (<any>term)._core.renderer.clear();\n      term.resize(geometry.cols, geometry.rows);\n    }\n  }\n}\n\nexport function apply(terminalConstructor: typeof Terminal): void {\n  (<any>terminalConstructor.prototype).proposeGeometry = function (): IGeometry {\n    return proposeGeometry(this);\n  };\n\n  (<any>terminalConstructor.prototype).fit = function (): void {\n    fit(this);\n  };\n}\n",null],"names":[],"mappings":"ACAA;;;ADsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAvBA;AAyBA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AATA;AAWA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AARA;"}
\ No newline at end of file
diff --git a/src/www/xterm-addon-fit.js b/src/www/xterm-addon-fit.js
new file mode 100644
index 0000000..709e60a
--- /dev/null
+++ b/src/www/xterm-addon-fit.js
@@ -0,0 +1,2 @@
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.prototype.activate=function(e){this._terminal=e},e.prototype.dispose=function(){},e.prototype.fit=function(){var e=this.proposeDimensions();if(e&&this._terminal){var t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}},e.prototype.proposeDimensions=function(){if(this._terminal&&this._terminal.element&&this._terminal.element.parentElement){var e=this._terminal._core,t=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(t.getPropertyValue("height")),n=Math.max(0,parseInt(t.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),i=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),a=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-e.viewport.scrollBarWidth;return{cols:Math.max(2,Math.floor(a/e._renderService.dimensions.actualCellWidth)),rows:Math.max(1,Math.floor(i/e._renderService.dimensions.actualCellHeight))}}},e}();t.FitAddon=n}])});
+//# sourceMappingURL=xterm-addon-fit.js.map
\ No newline at end of file
diff --git a/src/www/xterm-addon-fit.js.map b/src/www/xterm-addon-fit.js.map
new file mode 100644
index 0000000..b080faa
--- /dev/null
+++ b/src/www/xterm-addon-fit.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["webpack://FitAddon/webpack/universalModuleDefinition","webpack://FitAddon/webpack/bootstrap","webpack://FitAddon/./src/FitAddon.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","activate","terminal","this","_terminal","dispose","fit","dims","proposeDimensions","core","_core","rows","cols","_renderService","clear","resize","element","parentElement","parentElementStyle","getComputedStyle","parentElementHeight","parseInt","getPropertyValue","parentElementWidth","Math","max","elementStyle","availableHeight","availableWidth","viewport","scrollBarWidth","floor","dimensions","actualCellWidth","actualCellHeight","FitAddon"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAkB,SAAID,IAEtBD,EAAe,SAAIC,IARrB,CASGK,OAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,G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":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FitAddon\"] = factory();\n\telse\n\t\troot[\"FitAddon\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Terminal, ITerminalAddon } from 'xterm';\n\ninterface ITerminalDimensions {\n  /**\n   * The number of rows in the terminal.\n   */\n  rows: number;\n\n  /**\n   * The number of columns in the terminal.\n   */\n  cols: number;\n}\n\nconst MINIMUM_COLS = 2;\nconst MINIMUM_ROWS = 1;\n\nexport class FitAddon implements ITerminalAddon {\n  private _terminal: Terminal | undefined;\n\n  constructor() {}\n\n  public activate(terminal: Terminal): void {\n    this._terminal = terminal;\n  }\n\n  public dispose(): void {}\n\n  public fit(): void {\n    const dims = this.proposeDimensions();\n    if (!dims || !this._terminal) {\n      return;\n    }\n\n    // TODO: Remove reliance on private API\n    const core = (<any>this._terminal)._core;\n\n    // Force a full render\n    if (this._terminal.rows !== dims.rows || this._terminal.cols !== dims.cols) {\n      core._renderService.clear();\n      this._terminal.resize(dims.cols, dims.rows);\n    }\n  }\n\n  public proposeDimensions(): ITerminalDimensions | undefined {\n    if (!this._terminal) {\n      return undefined;\n    }\n\n    if (!this._terminal.element || !this._terminal.element.parentElement) {\n      return undefined;\n    }\n\n    // TODO: Remove reliance on private API\n    const core = (<any>this._terminal)._core;\n\n    const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);\n    const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\n    const parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));\n    const elementStyle = window.getComputedStyle(this._terminal.element);\n    const elementPadding = {\n      top: parseInt(elementStyle.getPropertyValue('padding-top')),\n      bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),\n      right: parseInt(elementStyle.getPropertyValue('padding-right')),\n      left: parseInt(elementStyle.getPropertyValue('padding-left'))\n    };\n    const elementPaddingVer = elementPadding.top + elementPadding.bottom;\n    const elementPaddingHor = elementPadding.right + elementPadding.left;\n    const availableHeight = parentElementHeight - elementPaddingVer;\n    const availableWidth = parentElementWidth - elementPaddingHor - core.viewport.scrollBarWidth;\n    const geometry = {\n      cols: Math.max(MINIMUM_COLS, Math.floor(availableWidth / core._renderService.dimensions.actualCellWidth)),\n      rows: Math.max(MINIMUM_ROWS, Math.floor(availableHeight / core._renderService.dimensions.actualCellHeight))\n    };\n    return geometry;\n  }\n}\n"],"sourceRoot":""}
\ No newline at end of file
diff --git a/src/www/xterm.css b/src/www/xterm.css
index 5448b5a..b3d8d4f 100644
--- a/src/www/xterm.css
+++ b/src/www/xterm.css
@@ -55,7 +55,7 @@
      * The z-index of the helpers must be higher than the canvases in order for
      * IMEs to appear on top.
      */
-    z-index: 10;
+    z-index: 5;
 }
 
 .xterm .xterm-helper-textarea {
@@ -69,7 +69,7 @@
     top: 0;
     width: 0;
     height: 0;
-    z-index: -10;
+    z-index: -5;
     /** Prevent wrapping so the IME appears against the textarea at the correct position */
     white-space: nowrap;
     overflow: hidden;
@@ -150,7 +150,7 @@
     top: 0;
     bottom: 0;
     right: 0;
-    z-index: 100;
+    z-index: 10;
     color: transparent;
 }
 
diff --git a/src/www/xterm.js b/src/www/xterm.js
index cf27b6a..aebe9e9 100644
--- a/src/www/xterm.js
+++ b/src/www/xterm.js
@@ -1,10217 +1,2 @@
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Terminal = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Strings = require("./Strings");
-var Platform_1 = require("./common/Platform");
-var RenderDebouncer_1 = require("./ui/RenderDebouncer");
-var Lifecycle_1 = require("./ui/Lifecycle");
-var Lifecycle_2 = require("./common/Lifecycle");
-var MAX_ROWS_TO_READ = 20;
-var AccessibilityManager = (function (_super) {
-    __extends(AccessibilityManager, _super);
-    function AccessibilityManager(_terminal) {
-        var _this = _super.call(this) || this;
-        _this._terminal = _terminal;
-        _this._liveRegionLineCount = 0;
-        _this._charsToConsume = [];
-        _this._accessibilityTreeRoot = document.createElement('div');
-        _this._accessibilityTreeRoot.classList.add('xterm-accessibility');
-        _this._rowContainer = document.createElement('div');
-        _this._rowContainer.classList.add('xterm-accessibility-tree');
-        _this._rowElements = [];
-        for (var i = 0; i < _this._terminal.rows; i++) {
-            _this._rowElements[i] = _this._createAccessibilityTreeNode();
-            _this._rowContainer.appendChild(_this._rowElements[i]);
-        }
-        _this._topBoundaryFocusListener = function (e) { return _this._onBoundaryFocus(e, 0); };
-        _this._bottomBoundaryFocusListener = function (e) { return _this._onBoundaryFocus(e, 1); };
-        _this._rowElements[0].addEventListener('focus', _this._topBoundaryFocusListener);
-        _this._rowElements[_this._rowElements.length - 1].addEventListener('focus', _this._bottomBoundaryFocusListener);
-        _this._refreshRowsDimensions();
-        _this._accessibilityTreeRoot.appendChild(_this._rowContainer);
-        _this._renderRowsDebouncer = new RenderDebouncer_1.RenderDebouncer(_this._renderRows.bind(_this));
-        _this._refreshRows();
-        _this._liveRegion = document.createElement('div');
-        _this._liveRegion.classList.add('live-region');
-        _this._liveRegion.setAttribute('aria-live', 'assertive');
-        _this._accessibilityTreeRoot.appendChild(_this._liveRegion);
-        _this._terminal.element.insertAdjacentElement('afterbegin', _this._accessibilityTreeRoot);
-        _this.register(_this._renderRowsDebouncer);
-        _this.register(_this._terminal.onResize(function (e) { return _this._onResize(e.rows); }));
-        _this.register(_this._terminal.onRender(function (e) { return _this._refreshRows(e.start, e.end); }));
-        _this.register(_this._terminal.onScroll(function () { return _this._refreshRows(); }));
-        _this.register(_this._terminal.addDisposableListener('a11y.char', function (char) { return _this._onChar(char); }));
-        _this.register(_this._terminal.onLineFeed(function () { return _this._onChar('\n'); }));
-        _this.register(_this._terminal.addDisposableListener('a11y.tab', function (spaceCount) { return _this._onTab(spaceCount); }));
-        _this.register(_this._terminal.onKey(function (e) { return _this._onKey(e.key); }));
-        _this.register(_this._terminal.addDisposableListener('blur', function () { return _this._clearLiveRegion(); }));
-        _this.register(_this._terminal.addDisposableListener('dprchange', function () { return _this._refreshRowsDimensions(); }));
-        _this.register(_this._terminal.renderer.onCanvasResize(function () { return _this._refreshRowsDimensions(); }));
-        _this.register(Lifecycle_1.addDisposableDomListener(window, 'resize', function () { return _this._refreshRowsDimensions(); }));
-        return _this;
-    }
-    AccessibilityManager.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        this._terminal.element.removeChild(this._accessibilityTreeRoot);
-        this._rowElements.length = 0;
-    };
-    AccessibilityManager.prototype._onBoundaryFocus = function (e, position) {
-        var boundaryElement = e.target;
-        var beforeBoundaryElement = this._rowElements[position === 0 ? 1 : this._rowElements.length - 2];
-        var posInSet = boundaryElement.getAttribute('aria-posinset');
-        var lastRowPos = position === 0 ? '1' : "" + this._terminal.buffer.lines.length;
-        if (posInSet === lastRowPos) {
-            return;
-        }
-        if (e.relatedTarget !== beforeBoundaryElement) {
-            return;
-        }
-        var topBoundaryElement;
-        var bottomBoundaryElement;
-        if (position === 0) {
-            topBoundaryElement = boundaryElement;
-            bottomBoundaryElement = this._rowElements.pop();
-            this._rowContainer.removeChild(bottomBoundaryElement);
-        }
-        else {
-            topBoundaryElement = this._rowElements.shift();
-            bottomBoundaryElement = boundaryElement;
-            this._rowContainer.removeChild(topBoundaryElement);
-        }
-        topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);
-        bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);
-        if (position === 0) {
-            var newElement = this._createAccessibilityTreeNode();
-            this._rowElements.unshift(newElement);
-            this._rowContainer.insertAdjacentElement('afterbegin', newElement);
-        }
-        else {
-            var newElement = this._createAccessibilityTreeNode();
-            this._rowElements.push(newElement);
-            this._rowContainer.appendChild(newElement);
-        }
-        this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);
-        this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
-        this._terminal.scrollLines(position === 0 ? -1 : 1);
-        this._rowElements[position === 0 ? 1 : this._rowElements.length - 2].focus();
-        e.preventDefault();
-        e.stopImmediatePropagation();
-    };
-    AccessibilityManager.prototype._onResize = function (rows) {
-        this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);
-        for (var i = this._rowContainer.children.length; i < this._terminal.rows; i++) {
-            this._rowElements[i] = this._createAccessibilityTreeNode();
-            this._rowContainer.appendChild(this._rowElements[i]);
-        }
-        while (this._rowElements.length > rows) {
-            this._rowContainer.removeChild(this._rowElements.pop());
-        }
-        this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);
-        this._refreshRowsDimensions();
-    };
-    AccessibilityManager.prototype._createAccessibilityTreeNode = function () {
-        var element = document.createElement('div');
-        element.setAttribute('role', 'listitem');
-        element.tabIndex = -1;
-        this._refreshRowDimensions(element);
-        return element;
-    };
-    AccessibilityManager.prototype._onTab = function (spaceCount) {
-        for (var i = 0; i < spaceCount; i++) {
-            this._onChar(' ');
-        }
-    };
-    AccessibilityManager.prototype._onChar = function (char) {
-        var _this = this;
-        if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {
-            if (this._charsToConsume.length > 0) {
-                var shiftedChar = this._charsToConsume.shift();
-                if (shiftedChar !== char) {
-                    this._announceCharacter(char);
-                }
-            }
-            else {
-                this._announceCharacter(char);
-            }
-            if (char === '\n') {
-                this._liveRegionLineCount++;
-                if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) {
-                    this._liveRegion.textContent += Strings.tooMuchOutput;
-                }
-            }
-            if (Platform_1.isMac) {
-                if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {
-                    setTimeout(function () {
-                        _this._accessibilityTreeRoot.appendChild(_this._liveRegion);
-                    }, 0);
-                }
-            }
-        }
-    };
-    AccessibilityManager.prototype._clearLiveRegion = function () {
-        this._liveRegion.textContent = '';
-        this._liveRegionLineCount = 0;
-        if (Platform_1.isMac) {
-            if (this._liveRegion.parentNode) {
-                this._accessibilityTreeRoot.removeChild(this._liveRegion);
-            }
-        }
-    };
-    AccessibilityManager.prototype._onKey = function (keyChar) {
-        this._clearLiveRegion();
-        this._charsToConsume.push(keyChar);
-    };
-    AccessibilityManager.prototype._refreshRows = function (start, end) {
-        this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);
-    };
-    AccessibilityManager.prototype._renderRows = function (start, end) {
-        var buffer = this._terminal.buffer;
-        var setSize = buffer.lines.length.toString();
-        for (var i = start; i <= end; i++) {
-            var lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);
-            var posInSet = (buffer.ydisp + i + 1).toString();
-            var element = this._rowElements[i];
-            if (element) {
-                element.textContent = lineData.length === 0 ? Strings.blankLine : lineData;
-                element.setAttribute('aria-posinset', posInSet);
-                element.setAttribute('aria-setsize', setSize);
-            }
-        }
-    };
-    AccessibilityManager.prototype._refreshRowsDimensions = function () {
-        if (!this._terminal.renderer.dimensions.actualCellHeight) {
-            return;
-        }
-        if (this._rowElements.length !== this._terminal.rows) {
-            this._onResize(this._terminal.rows);
-        }
-        for (var i = 0; i < this._terminal.rows; i++) {
-            this._refreshRowDimensions(this._rowElements[i]);
-        }
-    };
-    AccessibilityManager.prototype._refreshRowDimensions = function (element) {
-        element.style.height = this._terminal.renderer.dimensions.actualCellHeight + "px";
-    };
-    AccessibilityManager.prototype._announceCharacter = function (char) {
-        if (char === ' ') {
-            this._liveRegion.innerHTML += ' ';
-        }
-        else {
-            this._liveRegion.textContent += char;
-        }
-    };
-    return AccessibilityManager;
-}(Lifecycle_2.Disposable));
-exports.AccessibilityManager = AccessibilityManager;
-
-},{"./Strings":18,"./common/Lifecycle":26,"./common/Platform":27,"./ui/Lifecycle":55,"./ui/RenderDebouncer":56}],2:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var CircularList_1 = require("./common/CircularList");
-var BufferLine_1 = require("./BufferLine");
-var BufferReflow_1 = require("./BufferReflow");
-var Types_1 = require("./renderer/atlas/Types");
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var Lifecycle_1 = require("../lib/common/Lifecycle");
-exports.DEFAULT_ATTR = (0 << 18) | (Types_1.DEFAULT_COLOR << 9) | (256 << 0);
-exports.DEFAULT_ATTR_DATA = new BufferLine_1.AttributeData();
-exports.CHAR_DATA_ATTR_INDEX = 0;
-exports.CHAR_DATA_CHAR_INDEX = 1;
-exports.CHAR_DATA_WIDTH_INDEX = 2;
-exports.CHAR_DATA_CODE_INDEX = 3;
-exports.MAX_BUFFER_SIZE = 4294967295;
-exports.NULL_CELL_CHAR = '';
-exports.NULL_CELL_WIDTH = 1;
-exports.NULL_CELL_CODE = 0;
-exports.WHITESPACE_CELL_CHAR = ' ';
-exports.WHITESPACE_CELL_WIDTH = 1;
-exports.WHITESPACE_CELL_CODE = 32;
-var Buffer = (function () {
-    function Buffer(_terminal, _hasScrollback) {
-        this._terminal = _terminal;
-        this._hasScrollback = _hasScrollback;
-        this.savedCurAttrData = exports.DEFAULT_ATTR_DATA.clone();
-        this.markers = [];
-        this._nullCell = BufferLine_1.CellData.fromCharData([0, exports.NULL_CELL_CHAR, exports.NULL_CELL_WIDTH, exports.NULL_CELL_CODE]);
-        this._whitespaceCell = BufferLine_1.CellData.fromCharData([0, exports.WHITESPACE_CELL_CHAR, exports.WHITESPACE_CELL_WIDTH, exports.WHITESPACE_CELL_CODE]);
-        this._cols = this._terminal.cols;
-        this._rows = this._terminal.rows;
-        this.clear();
-    }
-    Buffer.prototype.getNullCell = function (attr) {
-        if (attr) {
-            this._nullCell.fg = attr.fg;
-            this._nullCell.bg = attr.bg;
-        }
-        else {
-            this._nullCell.fg = 0;
-            this._nullCell.bg = 0;
-        }
-        return this._nullCell;
-    };
-    Buffer.prototype.getWhitespaceCell = function (attr) {
-        if (attr) {
-            this._whitespaceCell.fg = attr.fg;
-            this._whitespaceCell.bg = attr.bg;
-        }
-        else {
-            this._whitespaceCell.fg = 0;
-            this._whitespaceCell.bg = 0;
-        }
-        return this._whitespaceCell;
-    };
-    Buffer.prototype.getBlankLine = function (attr, isWrapped) {
-        return new BufferLine_1.BufferLine(this._terminal.cols, this.getNullCell(attr), isWrapped);
-    };
-    Object.defineProperty(Buffer.prototype, "hasScrollback", {
-        get: function () {
-            return this._hasScrollback && this.lines.maxLength > this._rows;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Buffer.prototype, "isCursorInViewport", {
-        get: function () {
-            var absoluteY = this.ybase + this.y;
-            var relativeY = absoluteY - this.ydisp;
-            return (relativeY >= 0 && relativeY < this._rows);
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Buffer.prototype._getCorrectBufferLength = function (rows) {
-        if (!this._hasScrollback) {
-            return rows;
-        }
-        var correctBufferLength = rows + this._terminal.options.scrollback;
-        return correctBufferLength > exports.MAX_BUFFER_SIZE ? exports.MAX_BUFFER_SIZE : correctBufferLength;
-    };
-    Buffer.prototype.fillViewportRows = function (fillAttr) {
-        if (this.lines.length === 0) {
-            if (fillAttr === undefined) {
-                fillAttr = exports.DEFAULT_ATTR_DATA;
-            }
-            var i = this._rows;
-            while (i--) {
-                this.lines.push(this.getBlankLine(fillAttr));
-            }
-        }
-    };
-    Buffer.prototype.clear = function () {
-        this.ydisp = 0;
-        this.ybase = 0;
-        this.y = 0;
-        this.x = 0;
-        this.lines = new CircularList_1.CircularList(this._getCorrectBufferLength(this._rows));
-        this.scrollTop = 0;
-        this.scrollBottom = this._rows - 1;
-        this.setupTabStops();
-    };
-    Buffer.prototype.resize = function (newCols, newRows) {
-        var nullCell = this.getNullCell(exports.DEFAULT_ATTR_DATA);
-        var newMaxLength = this._getCorrectBufferLength(newRows);
-        if (newMaxLength > this.lines.maxLength) {
-            this.lines.maxLength = newMaxLength;
-        }
-        if (this.lines.length > 0) {
-            if (this._cols < newCols) {
-                for (var i = 0; i < this.lines.length; i++) {
-                    this.lines.get(i).resize(newCols, nullCell);
-                }
-            }
-            var addToY = 0;
-            if (this._rows < newRows) {
-                for (var y = this._rows; y < newRows; y++) {
-                    if (this.lines.length < newRows + this.ybase) {
-                        if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {
-                            this.ybase--;
-                            addToY++;
-                            if (this.ydisp > 0) {
-                                this.ydisp--;
-                            }
-                        }
-                        else {
-                            this.lines.push(new BufferLine_1.BufferLine(newCols, nullCell));
-                        }
-                    }
-                }
-            }
-            else {
-                for (var y = this._rows; y > newRows; y--) {
-                    if (this.lines.length > newRows + this.ybase) {
-                        if (this.lines.length > this.ybase + this.y + 1) {
-                            this.lines.pop();
-                        }
-                        else {
-                            this.ybase++;
-                            this.ydisp++;
-                        }
-                    }
-                }
-            }
-            if (newMaxLength < this.lines.maxLength) {
-                var amountToTrim = this.lines.length - newMaxLength;
-                if (amountToTrim > 0) {
-                    this.lines.trimStart(amountToTrim);
-                    this.ybase = Math.max(this.ybase - amountToTrim, 0);
-                    this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
-                }
-                this.lines.maxLength = newMaxLength;
-            }
-            this.x = Math.min(this.x, newCols - 1);
-            this.y = Math.min(this.y, newRows - 1);
-            if (addToY) {
-                this.y += addToY;
-            }
-            this.savedY = Math.min(this.savedY, newRows - 1);
-            this.savedX = Math.min(this.savedX, newCols - 1);
-            this.scrollTop = 0;
-        }
-        this.scrollBottom = newRows - 1;
-        if (this._isReflowEnabled) {
-            this._reflow(newCols, newRows);
-            if (this._cols > newCols) {
-                for (var i = 0; i < this.lines.length; i++) {
-                    this.lines.get(i).resize(newCols, nullCell);
-                }
-            }
-        }
-        this._cols = newCols;
-        this._rows = newRows;
-    };
-    Object.defineProperty(Buffer.prototype, "_isReflowEnabled", {
-        get: function () {
-            return this._hasScrollback && !this._terminal.options.windowsMode;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Buffer.prototype._reflow = function (newCols, newRows) {
-        if (this._cols === newCols) {
-            return;
-        }
-        if (newCols > this._cols) {
-            this._reflowLarger(newCols, newRows);
-        }
-        else {
-            this._reflowSmaller(newCols, newRows);
-        }
-    };
-    Buffer.prototype._reflowLarger = function (newCols, newRows) {
-        var toRemove = BufferReflow_1.reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(exports.DEFAULT_ATTR_DATA));
-        if (toRemove.length > 0) {
-            var newLayoutResult = BufferReflow_1.reflowLargerCreateNewLayout(this.lines, toRemove);
-            BufferReflow_1.reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
-            this._reflowLargerAdjustViewport(newCols, newRows, newLayoutResult.countRemoved);
-        }
-    };
-    Buffer.prototype._reflowLargerAdjustViewport = function (newCols, newRows, countRemoved) {
-        var nullCell = this.getNullCell(exports.DEFAULT_ATTR_DATA);
-        var viewportAdjustments = countRemoved;
-        while (viewportAdjustments-- > 0) {
-            if (this.ybase === 0) {
-                if (this.y > 0) {
-                    this.y--;
-                }
-                if (this.lines.length < newRows) {
-                    this.lines.push(new BufferLine_1.BufferLine(newCols, nullCell));
-                }
-            }
-            else {
-                if (this.ydisp === this.ybase) {
-                    this.ydisp--;
-                }
-                this.ybase--;
-            }
-        }
-    };
-    Buffer.prototype._reflowSmaller = function (newCols, newRows) {
-        var nullCell = this.getNullCell(exports.DEFAULT_ATTR_DATA);
-        var toInsert = [];
-        var countToInsert = 0;
-        for (var y = this.lines.length - 1; y >= 0; y--) {
-            var nextLine = this.lines.get(y);
-            if (!nextLine.isWrapped && nextLine.getTrimmedLength() <= newCols) {
-                continue;
-            }
-            var wrappedLines = [nextLine];
-            while (nextLine.isWrapped && y > 0) {
-                nextLine = this.lines.get(--y);
-                wrappedLines.unshift(nextLine);
-            }
-            var absoluteY = this.ybase + this.y;
-            if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
-                continue;
-            }
-            var lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
-            var destLineLengths = BufferReflow_1.reflowSmallerGetNewLineLengths(wrappedLines, this._cols, newCols);
-            var linesToAdd = destLineLengths.length - wrappedLines.length;
-            var trimmedLines = void 0;
-            if (this.ybase === 0 && this.y !== this.lines.length - 1) {
-                trimmedLines = Math.max(0, this.y - this.lines.maxLength + linesToAdd);
-            }
-            else {
-                trimmedLines = Math.max(0, this.lines.length - this.lines.maxLength + linesToAdd);
-            }
-            var newLines = [];
-            for (var i = 0; i < linesToAdd; i++) {
-                var newLine = this.getBlankLine(exports.DEFAULT_ATTR_DATA, true);
-                newLines.push(newLine);
-            }
-            if (newLines.length > 0) {
-                toInsert.push({
-                    start: y + wrappedLines.length + countToInsert,
-                    newLines: newLines
-                });
-                countToInsert += newLines.length;
-            }
-            wrappedLines.push.apply(wrappedLines, newLines);
-            var destLineIndex = destLineLengths.length - 1;
-            var destCol = destLineLengths[destLineIndex];
-            if (destCol === 0) {
-                destLineIndex--;
-                destCol = destLineLengths[destLineIndex];
-            }
-            var srcLineIndex = wrappedLines.length - linesToAdd - 1;
-            var srcCol = lastLineLength;
-            while (srcLineIndex >= 0) {
-                var cellsToCopy = Math.min(srcCol, destCol);
-                wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true);
-                destCol -= cellsToCopy;
-                if (destCol === 0) {
-                    destLineIndex--;
-                    destCol = destLineLengths[destLineIndex];
-                }
-                srcCol -= cellsToCopy;
-                if (srcCol === 0) {
-                    srcLineIndex--;
-                    var wrappedLinesIndex = Math.max(srcLineIndex, 0);
-                    srcCol = BufferReflow_1.getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols);
-                }
-            }
-            for (var i = 0; i < wrappedLines.length; i++) {
-                if (destLineLengths[i] < newCols) {
-                    wrappedLines[i].setCell(destLineLengths[i], nullCell);
-                }
-            }
-            var viewportAdjustments = linesToAdd - trimmedLines;
-            while (viewportAdjustments-- > 0) {
-                if (this.ybase === 0) {
-                    if (this.y < newRows - 1) {
-                        this.y++;
-                        this.lines.pop();
-                    }
-                    else {
-                        this.ybase++;
-                        this.ydisp++;
-                    }
-                }
-                else {
-                    if (this.ybase < Math.min(this.lines.maxLength, this.lines.length + countToInsert) - newRows) {
-                        if (this.ybase === this.ydisp) {
-                            this.ydisp++;
-                        }
-                        this.ybase++;
-                    }
-                }
-            }
-        }
-        if (toInsert.length > 0) {
-            var insertEvents = [];
-            var originalLines = [];
-            for (var i = 0; i < this.lines.length; i++) {
-                originalLines.push(this.lines.get(i));
-            }
-            var originalLinesLength = this.lines.length;
-            var originalLineIndex = originalLinesLength - 1;
-            var nextToInsertIndex = 0;
-            var nextToInsert = toInsert[nextToInsertIndex];
-            this.lines.length = Math.min(this.lines.maxLength, this.lines.length + countToInsert);
-            var countInsertedSoFar = 0;
-            for (var i = Math.min(this.lines.maxLength - 1, originalLinesLength + countToInsert - 1); i >= 0; i--) {
-                if (nextToInsert && nextToInsert.start > originalLineIndex + countInsertedSoFar) {
-                    for (var nextI = nextToInsert.newLines.length - 1; nextI >= 0; nextI--) {
-                        this.lines.set(i--, nextToInsert.newLines[nextI]);
-                    }
-                    i++;
-                    insertEvents.push({
-                        index: originalLineIndex + 1,
-                        amount: nextToInsert.newLines.length
-                    });
-                    countInsertedSoFar += nextToInsert.newLines.length;
-                    nextToInsert = toInsert[++nextToInsertIndex];
-                }
-                else {
-                    this.lines.set(i, originalLines[originalLineIndex--]);
-                }
-            }
-            var insertCountEmitted = 0;
-            for (var i = insertEvents.length - 1; i >= 0; i--) {
-                insertEvents[i].index += insertCountEmitted;
-                this.lines.onInsertEmitter.fire(insertEvents[i]);
-                insertCountEmitted += insertEvents[i].amount;
-            }
-            var amountToTrim = Math.max(0, originalLinesLength + countToInsert - this.lines.maxLength);
-            if (amountToTrim > 0) {
-                this.lines.onTrimEmitter.fire(amountToTrim);
-            }
-        }
-    };
-    Buffer.prototype.stringIndexToBufferIndex = function (lineIndex, stringIndex, trimRight) {
-        if (trimRight === void 0) { trimRight = false; }
-        while (stringIndex) {
-            var line = this.lines.get(lineIndex);
-            if (!line) {
-                return [-1, -1];
-            }
-            var length_1 = (trimRight) ? line.getTrimmedLength() : line.length;
-            for (var i = 0; i < length_1; ++i) {
-                if (line.get(i)[exports.CHAR_DATA_WIDTH_INDEX]) {
-                    stringIndex -= line.get(i)[exports.CHAR_DATA_CHAR_INDEX].length || 1;
-                }
-                if (stringIndex < 0) {
-                    return [lineIndex, i];
-                }
-            }
-            lineIndex++;
-        }
-        return [lineIndex, 0];
-    };
-    Buffer.prototype.translateBufferLineToString = function (lineIndex, trimRight, startCol, endCol) {
-        if (startCol === void 0) { startCol = 0; }
-        var line = this.lines.get(lineIndex);
-        if (!line) {
-            return '';
-        }
-        return line.translateToString(trimRight, startCol, endCol);
-    };
-    Buffer.prototype.getWrappedRangeForLine = function (y) {
-        var first = y;
-        var last = y;
-        while (first > 0 && this.lines.get(first).isWrapped) {
-            first--;
-        }
-        while (last + 1 < this.lines.length && this.lines.get(last + 1).isWrapped) {
-            last++;
-        }
-        return { first: first, last: last };
-    };
-    Buffer.prototype.setupTabStops = function (i) {
-        if (i !== null && i !== undefined) {
-            if (!this.tabs[i]) {
-                i = this.prevStop(i);
-            }
-        }
-        else {
-            this.tabs = {};
-            i = 0;
-        }
-        for (; i < this._cols; i += this._terminal.options.tabStopWidth) {
-            this.tabs[i] = true;
-        }
-    };
-    Buffer.prototype.prevStop = function (x) {
-        if (x === null || x === undefined) {
-            x = this.x;
-        }
-        while (!this.tabs[--x] && x > 0)
-            ;
-        return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
-    };
-    Buffer.prototype.nextStop = function (x) {
-        if (x === null || x === undefined) {
-            x = this.x;
-        }
-        while (!this.tabs[++x] && x < this._cols)
-            ;
-        return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;
-    };
-    Buffer.prototype.addMarker = function (y) {
-        var _this = this;
-        var marker = new Marker(y);
-        this.markers.push(marker);
-        marker.register(this.lines.onTrim(function (amount) {
-            marker.line -= amount;
-            if (marker.line < 0) {
-                marker.dispose();
-            }
-        }));
-        marker.register(this.lines.onInsert(function (event) {
-            if (marker.line >= event.index) {
-                marker.line += event.amount;
-            }
-        }));
-        marker.register(this.lines.onDelete(function (event) {
-            if (marker.line >= event.index && marker.line < event.index + event.amount) {
-                marker.dispose();
-            }
-            if (marker.line > event.index) {
-                marker.line -= event.amount;
-            }
-        }));
-        marker.register(marker.onDispose(function () { return _this._removeMarker(marker); }));
-        return marker;
-    };
-    Buffer.prototype._removeMarker = function (marker) {
-        this.markers.splice(this.markers.indexOf(marker), 1);
-    };
-    Buffer.prototype.iterator = function (trimRight, startIndex, endIndex, startOverscan, endOverscan) {
-        return new BufferStringIterator(this, trimRight, startIndex, endIndex, startOverscan, endOverscan);
-    };
-    return Buffer;
-}());
-exports.Buffer = Buffer;
-var Marker = (function (_super) {
-    __extends(Marker, _super);
-    function Marker(line) {
-        var _this = _super.call(this) || this;
-        _this.line = line;
-        _this._id = Marker._nextId++;
-        _this.isDisposed = false;
-        _this._onDispose = new EventEmitter2_1.EventEmitter2();
-        return _this;
-    }
-    Object.defineProperty(Marker.prototype, "id", {
-        get: function () { return this._id; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Marker.prototype, "onDispose", {
-        get: function () { return this._onDispose.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Marker.prototype.dispose = function () {
-        if (this.isDisposed) {
-            return;
-        }
-        this.isDisposed = true;
-        this._onDispose.fire();
-    };
-    Marker._nextId = 1;
-    return Marker;
-}(Lifecycle_1.Disposable));
-exports.Marker = Marker;
-var BufferStringIterator = (function () {
-    function BufferStringIterator(_buffer, _trimRight, _startIndex, _endIndex, _startOverscan, _endOverscan) {
-        if (_startIndex === void 0) { _startIndex = 0; }
-        if (_endIndex === void 0) { _endIndex = _buffer.lines.length; }
-        if (_startOverscan === void 0) { _startOverscan = 0; }
-        if (_endOverscan === void 0) { _endOverscan = 0; }
-        this._buffer = _buffer;
-        this._trimRight = _trimRight;
-        this._startIndex = _startIndex;
-        this._endIndex = _endIndex;
-        this._startOverscan = _startOverscan;
-        this._endOverscan = _endOverscan;
-        if (this._startIndex < 0) {
-            this._startIndex = 0;
-        }
-        if (this._endIndex > this._buffer.lines.length) {
-            this._endIndex = this._buffer.lines.length;
-        }
-        this._current = this._startIndex;
-    }
-    BufferStringIterator.prototype.hasNext = function () {
-        return this._current < this._endIndex;
-    };
-    BufferStringIterator.prototype.next = function () {
-        var range = this._buffer.getWrappedRangeForLine(this._current);
-        if (range.first < this._startIndex - this._startOverscan) {
-            range.first = this._startIndex - this._startOverscan;
-        }
-        if (range.last > this._endIndex + this._endOverscan) {
-            range.last = this._endIndex + this._endOverscan;
-        }
-        range.first = Math.max(range.first, 0);
-        range.last = Math.min(range.last, this._buffer.lines.length);
-        var result = '';
-        for (var i = range.first; i <= range.last; ++i) {
-            result += this._buffer.translateBufferLineToString(i, this._trimRight);
-        }
-        this._current = range.last + 1;
-        return { range: range, content: result };
-    };
-    return BufferStringIterator;
-}());
-exports.BufferStringIterator = BufferStringIterator;
-
-},{"../lib/common/Lifecycle":26,"./BufferLine":3,"./BufferReflow":4,"./common/CircularList":22,"./common/EventEmitter2":25,"./renderer/atlas/Types":52}],3:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Buffer_1 = require("./Buffer");
-var TextDecoder_1 = require("./core/input/TextDecoder");
-var CELL_SIZE = 3;
-var AttributeData = (function () {
-    function AttributeData() {
-        this.fg = 0;
-        this.bg = 0;
-    }
-    AttributeData.toColorRGB = function (value) {
-        return [
-            value >>> 16 & 255,
-            value >>> 8 & 255,
-            value & 255
-        ];
-    };
-    AttributeData.fromColorRGB = function (value) {
-        return (value[0] & 255) << 16 | (value[1] & 255) << 8 | value[2] & 255;
-    };
-    AttributeData.prototype.clone = function () {
-        var newObj = new AttributeData();
-        newObj.fg = this.fg;
-        newObj.bg = this.bg;
-        return newObj;
-    };
-    AttributeData.prototype.isInverse = function () { return this.fg & 67108864; };
-    AttributeData.prototype.isBold = function () { return this.fg & 134217728; };
-    AttributeData.prototype.isUnderline = function () { return this.fg & 268435456; };
-    AttributeData.prototype.isBlink = function () { return this.fg & 536870912; };
-    AttributeData.prototype.isInvisible = function () { return this.fg & 1073741824; };
-    AttributeData.prototype.isItalic = function () { return this.bg & 67108864; };
-    AttributeData.prototype.isDim = function () { return this.bg & 134217728; };
-    AttributeData.prototype.getFgColorMode = function () { return this.fg & 50331648; };
-    AttributeData.prototype.getBgColorMode = function () { return this.bg & 50331648; };
-    AttributeData.prototype.isFgRGB = function () { return (this.fg & 50331648) === 50331648; };
-    AttributeData.prototype.isBgRGB = function () { return (this.bg & 50331648) === 50331648; };
-    AttributeData.prototype.isFgPalette = function () { return (this.fg & 50331648) === 16777216 || (this.fg & 50331648) === 33554432; };
-    AttributeData.prototype.isBgPalette = function () { return (this.bg & 50331648) === 16777216 || (this.bg & 50331648) === 33554432; };
-    AttributeData.prototype.isFgDefault = function () { return (this.fg & 50331648) === 0; };
-    AttributeData.prototype.isBgDefault = function () { return (this.bg & 50331648) === 0; };
-    AttributeData.prototype.getFgColor = function () {
-        switch (this.fg & 50331648) {
-            case 16777216:
-            case 33554432: return this.fg & 255;
-            case 50331648: return this.fg & 16777215;
-            default: return -1;
-        }
-    };
-    AttributeData.prototype.getBgColor = function () {
-        switch (this.bg & 50331648) {
-            case 16777216:
-            case 33554432: return this.bg & 255;
-            case 50331648: return this.bg & 16777215;
-            default: return -1;
-        }
-    };
-    return AttributeData;
-}());
-exports.AttributeData = AttributeData;
-var CellData = (function (_super) {
-    __extends(CellData, _super);
-    function CellData() {
-        var _this = _super !== null && _super.apply(this, arguments) || this;
-        _this.content = 0;
-        _this.fg = 0;
-        _this.bg = 0;
-        _this.combinedData = '';
-        return _this;
-    }
-    CellData.fromCharData = function (value) {
-        var obj = new CellData();
-        obj.setFromCharData(value);
-        return obj;
-    };
-    CellData.prototype.isCombined = function () {
-        return this.content & 2097152;
-    };
-    CellData.prototype.getWidth = function () {
-        return this.content >> 22;
-    };
-    CellData.prototype.getChars = function () {
-        if (this.content & 2097152) {
-            return this.combinedData;
-        }
-        if (this.content & 2097151) {
-            return TextDecoder_1.stringFromCodePoint(this.content & 2097151);
-        }
-        return '';
-    };
-    CellData.prototype.getCode = function () {
-        return (this.isCombined())
-            ? this.combinedData.charCodeAt(this.combinedData.length - 1)
-            : this.content & 2097151;
-    };
-    CellData.prototype.setFromCharData = function (value) {
-        this.fg = value[Buffer_1.CHAR_DATA_ATTR_INDEX];
-        this.bg = 0;
-        var combined = false;
-        if (value[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 2) {
-            combined = true;
-        }
-        else if (value[Buffer_1.CHAR_DATA_CHAR_INDEX].length === 2) {
-            var code = value[Buffer_1.CHAR_DATA_CHAR_INDEX].charCodeAt(0);
-            if (0xD800 <= code && code <= 0xDBFF) {
-                var second = value[Buffer_1.CHAR_DATA_CHAR_INDEX].charCodeAt(1);
-                if (0xDC00 <= second && second <= 0xDFFF) {
-                    this.content = ((code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000) | (value[Buffer_1.CHAR_DATA_WIDTH_INDEX] << 22);
-                }
-                else {
-                    combined = true;
-                }
-            }
-            else {
-                combined = true;
-            }
-        }
-        else {
-            this.content = value[Buffer_1.CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[Buffer_1.CHAR_DATA_WIDTH_INDEX] << 22);
-        }
-        if (combined) {
-            this.combinedData = value[Buffer_1.CHAR_DATA_CHAR_INDEX];
-            this.content = 2097152 | (value[Buffer_1.CHAR_DATA_WIDTH_INDEX] << 22);
-        }
-    };
-    CellData.prototype.getAsCharData = function () {
-        return [this.fg, this.getChars(), this.getWidth(), this.getCode()];
-    };
-    return CellData;
-}(AttributeData));
-exports.CellData = CellData;
-var BufferLine = (function () {
-    function BufferLine(cols, fillCellData, isWrapped) {
-        if (isWrapped === void 0) { isWrapped = false; }
-        this.isWrapped = isWrapped;
-        this._data = null;
-        this._combined = {};
-        if (cols) {
-            this._data = new Uint32Array(cols * CELL_SIZE);
-            var cell = fillCellData || CellData.fromCharData([0, Buffer_1.NULL_CELL_CHAR, Buffer_1.NULL_CELL_WIDTH, Buffer_1.NULL_CELL_CODE]);
-            for (var i = 0; i < cols; ++i) {
-                this.setCell(i, cell);
-            }
-        }
-        this.length = cols;
-    }
-    BufferLine.prototype.get = function (index) {
-        var content = this._data[index * CELL_SIZE + 0];
-        var cp = content & 2097151;
-        return [
-            this._data[index * CELL_SIZE + 1],
-            (content & 2097152)
-                ? this._combined[index]
-                : (cp) ? TextDecoder_1.stringFromCodePoint(cp) : '',
-            content >> 22,
-            (content & 2097152)
-                ? this._combined[index].charCodeAt(this._combined[index].length - 1)
-                : cp
-        ];
-    };
-    BufferLine.prototype.set = function (index, value) {
-        this._data[index * CELL_SIZE + 1] = value[Buffer_1.CHAR_DATA_ATTR_INDEX];
-        if (value[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
-            this._combined[index] = value[1];
-            this._data[index * CELL_SIZE + 0] = index | 2097152 | (value[Buffer_1.CHAR_DATA_WIDTH_INDEX] << 22);
-        }
-        else {
-            this._data[index * CELL_SIZE + 0] = value[Buffer_1.CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[Buffer_1.CHAR_DATA_WIDTH_INDEX] << 22);
-        }
-    };
-    BufferLine.prototype.getWidth = function (index) {
-        return this._data[index * CELL_SIZE + 0] >> 22;
-    };
-    BufferLine.prototype.hasWidth = function (index) {
-        return this._data[index * CELL_SIZE + 0] & 12582912;
-    };
-    BufferLine.prototype.getFg = function (index) {
-        return this._data[index * CELL_SIZE + 1];
-    };
-    BufferLine.prototype.getBg = function (index) {
-        return this._data[index * CELL_SIZE + 2];
-    };
-    BufferLine.prototype.hasContent = function (index) {
-        return this._data[index * CELL_SIZE + 0] & 4194303;
-    };
-    BufferLine.prototype.getCodePoint = function (index) {
-        var content = this._data[index * CELL_SIZE + 0];
-        if (content & 2097152) {
-            return this._combined[index].charCodeAt(this._combined[index].length - 1);
-        }
-        return content & 2097151;
-    };
-    BufferLine.prototype.isCombined = function (index) {
-        return this._data[index * CELL_SIZE + 0] & 2097152;
-    };
-    BufferLine.prototype.getString = function (index) {
-        var content = this._data[index * CELL_SIZE + 0];
-        if (content & 2097152) {
-            return this._combined[index];
-        }
-        if (content & 2097151) {
-            return TextDecoder_1.stringFromCodePoint(content & 2097151);
-        }
-        return '';
-    };
-    BufferLine.prototype.loadCell = function (index, cell) {
-        var startIndex = index * CELL_SIZE;
-        cell.content = this._data[startIndex + 0];
-        cell.fg = this._data[startIndex + 1];
-        cell.bg = this._data[startIndex + 2];
-        if (cell.content & 2097152) {
-            cell.combinedData = this._combined[index];
-        }
-        return cell;
-    };
-    BufferLine.prototype.setCell = function (index, cell) {
-        if (cell.content & 2097152) {
-            this._combined[index] = cell.combinedData;
-        }
-        this._data[index * CELL_SIZE + 0] = cell.content;
-        this._data[index * CELL_SIZE + 1] = cell.fg;
-        this._data[index * CELL_SIZE + 2] = cell.bg;
-    };
-    BufferLine.prototype.setCellFromCodePoint = function (index, codePoint, width, fg, bg) {
-        this._data[index * CELL_SIZE + 0] = codePoint | (width << 22);
-        this._data[index * CELL_SIZE + 1] = fg;
-        this._data[index * CELL_SIZE + 2] = bg;
-    };
-    BufferLine.prototype.addCodepointToCell = function (index, codePoint) {
-        var content = this._data[index * CELL_SIZE + 0];
-        if (content & 2097152) {
-            this._combined[index] += TextDecoder_1.stringFromCodePoint(codePoint);
-        }
-        else {
-            if (content & 2097151) {
-                this._combined[index] = TextDecoder_1.stringFromCodePoint(content & 2097151) + TextDecoder_1.stringFromCodePoint(codePoint);
-                content &= ~2097151;
-                content |= 2097152;
-            }
-            else {
-                content = codePoint | (1 << 22);
-            }
-            this._data[index * CELL_SIZE + 0] = content;
-        }
-    };
-    BufferLine.prototype.insertCells = function (pos, n, fillCellData) {
-        pos %= this.length;
-        if (n < this.length - pos) {
-            var cell = new CellData();
-            for (var i = this.length - pos - n - 1; i >= 0; --i) {
-                this.setCell(pos + n + i, this.loadCell(pos + i, cell));
-            }
-            for (var i = 0; i < n; ++i) {
-                this.setCell(pos + i, fillCellData);
-            }
-        }
-        else {
-            for (var i = pos; i < this.length; ++i) {
-                this.setCell(i, fillCellData);
-            }
-        }
-    };
-    BufferLine.prototype.deleteCells = function (pos, n, fillCellData) {
-        pos %= this.length;
-        if (n < this.length - pos) {
-            var cell = new CellData();
-            for (var i = 0; i < this.length - pos - n; ++i) {
-                this.setCell(pos + i, this.loadCell(pos + n + i, cell));
-            }
-            for (var i = this.length - n; i < this.length; ++i) {
-                this.setCell(i, fillCellData);
-            }
-        }
-        else {
-            for (var i = pos; i < this.length; ++i) {
-                this.setCell(i, fillCellData);
-            }
-        }
-    };
-    BufferLine.prototype.replaceCells = function (start, end, fillCellData) {
-        while (start < end && start < this.length) {
-            this.setCell(start++, fillCellData);
-        }
-    };
-    BufferLine.prototype.resize = function (cols, fillCellData) {
-        if (cols === this.length) {
-            return;
-        }
-        if (cols > this.length) {
-            var data = new Uint32Array(cols * CELL_SIZE);
-            if (this.length) {
-                if (cols * CELL_SIZE < this._data.length) {
-                    data.set(this._data.subarray(0, cols * CELL_SIZE));
-                }
-                else {
-                    data.set(this._data);
-                }
-            }
-            this._data = data;
-            for (var i = this.length; i < cols; ++i) {
-                this.setCell(i, fillCellData);
-            }
-        }
-        else {
-            if (cols) {
-                var data = new Uint32Array(cols * CELL_SIZE);
-                data.set(this._data.subarray(0, cols * CELL_SIZE));
-                this._data = data;
-                var keys = Object.keys(this._combined);
-                for (var i = 0; i < keys.length; i++) {
-                    var key = parseInt(keys[i], 10);
-                    if (key >= cols) {
-                        delete this._combined[key];
-                    }
-                }
-            }
-            else {
-                this._data = null;
-                this._combined = {};
-            }
-        }
-        this.length = cols;
-    };
-    BufferLine.prototype.fill = function (fillCellData) {
-        this._combined = {};
-        for (var i = 0; i < this.length; ++i) {
-            this.setCell(i, fillCellData);
-        }
-    };
-    BufferLine.prototype.copyFrom = function (line) {
-        if (this.length !== line.length) {
-            this._data = new Uint32Array(line._data);
-        }
-        else {
-            this._data.set(line._data);
-        }
-        this.length = line.length;
-        this._combined = {};
-        for (var el in line._combined) {
-            this._combined[el] = line._combined[el];
-        }
-        this.isWrapped = line.isWrapped;
-    };
-    BufferLine.prototype.clone = function () {
-        var newLine = new BufferLine(0);
-        newLine._data = new Uint32Array(this._data);
-        newLine.length = this.length;
-        for (var el in this._combined) {
-            newLine._combined[el] = this._combined[el];
-        }
-        newLine.isWrapped = this.isWrapped;
-        return newLine;
-    };
-    BufferLine.prototype.getTrimmedLength = function () {
-        for (var i = this.length - 1; i >= 0; --i) {
-            if ((this._data[i * CELL_SIZE + 0] & 4194303)) {
-                return i + (this._data[i * CELL_SIZE + 0] >> 22);
-            }
-        }
-        return 0;
-    };
-    BufferLine.prototype.copyCellsFrom = function (src, srcCol, destCol, length, applyInReverse) {
-        var srcData = src._data;
-        if (applyInReverse) {
-            for (var cell = length - 1; cell >= 0; cell--) {
-                for (var i = 0; i < CELL_SIZE; i++) {
-                    this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];
-                }
-            }
-        }
-        else {
-            for (var cell = 0; cell < length; cell++) {
-                for (var i = 0; i < CELL_SIZE; i++) {
-                    this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];
-                }
-            }
-        }
-        var srcCombinedKeys = Object.keys(src._combined);
-        for (var i = 0; i < srcCombinedKeys.length; i++) {
-            var key = parseInt(srcCombinedKeys[i], 10);
-            if (key >= srcCol) {
-                this._combined[key - srcCol + destCol] = src._combined[key];
-            }
-        }
-    };
-    BufferLine.prototype.translateToString = function (trimRight, startCol, endCol) {
-        if (trimRight === void 0) { trimRight = false; }
-        if (startCol === void 0) { startCol = 0; }
-        if (endCol === void 0) { endCol = this.length; }
-        if (trimRight) {
-            endCol = Math.min(endCol, this.getTrimmedLength());
-        }
-        var result = '';
-        while (startCol < endCol) {
-            var content = this._data[startCol * CELL_SIZE + 0];
-            var cp = content & 2097151;
-            result += (content & 2097152) ? this._combined[startCol] : (cp) ? TextDecoder_1.stringFromCodePoint(cp) : Buffer_1.WHITESPACE_CELL_CHAR;
-            startCol += (content >> 22) || 1;
-        }
-        return result;
-    };
-    return BufferLine;
-}());
-exports.BufferLine = BufferLine;
-
-},{"./Buffer":2,"./core/input/TextDecoder":32}],4:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function reflowLargerGetLinesToRemove(lines, oldCols, newCols, bufferAbsoluteY, nullCell) {
-    var toRemove = [];
-    for (var y = 0; y < lines.length - 1; y++) {
-        var i = y;
-        var nextLine = lines.get(++i);
-        if (!nextLine.isWrapped) {
-            continue;
-        }
-        var wrappedLines = [lines.get(y)];
-        while (i < lines.length && nextLine.isWrapped) {
-            wrappedLines.push(nextLine);
-            nextLine = lines.get(++i);
-        }
-        if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
-            y += wrappedLines.length - 1;
-            continue;
-        }
-        var destLineIndex = 0;
-        var destCol = getWrappedLineTrimmedLength(wrappedLines, destLineIndex, oldCols);
-        var srcLineIndex = 1;
-        var srcCol = 0;
-        while (srcLineIndex < wrappedLines.length) {
-            var srcTrimmedTineLength = getWrappedLineTrimmedLength(wrappedLines, srcLineIndex, oldCols);
-            var srcRemainingCells = srcTrimmedTineLength - srcCol;
-            var destRemainingCells = newCols - destCol;
-            var cellsToCopy = Math.min(srcRemainingCells, destRemainingCells);
-            wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol, destCol, cellsToCopy, false);
-            destCol += cellsToCopy;
-            if (destCol === newCols) {
-                destLineIndex++;
-                destCol = 0;
-            }
-            srcCol += cellsToCopy;
-            if (srcCol === srcTrimmedTineLength) {
-                srcLineIndex++;
-                srcCol = 0;
-            }
-            if (destCol === 0 && destLineIndex !== 0) {
-                if (wrappedLines[destLineIndex - 1].getWidth(newCols - 1) === 2) {
-                    wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[destLineIndex - 1], newCols - 1, destCol++, 1, false);
-                    wrappedLines[destLineIndex - 1].setCell(newCols - 1, nullCell);
-                }
-            }
-        }
-        wrappedLines[destLineIndex].replaceCells(destCol, newCols, nullCell);
-        var countToRemove = 0;
-        for (var i_1 = wrappedLines.length - 1; i_1 > 0; i_1--) {
-            if (i_1 > destLineIndex || wrappedLines[i_1].getTrimmedLength() === 0) {
-                countToRemove++;
-            }
-            else {
-                break;
-            }
-        }
-        if (countToRemove > 0) {
-            toRemove.push(y + wrappedLines.length - countToRemove);
-            toRemove.push(countToRemove);
-        }
-        y += wrappedLines.length - 1;
-    }
-    return toRemove;
-}
-exports.reflowLargerGetLinesToRemove = reflowLargerGetLinesToRemove;
-function reflowLargerCreateNewLayout(lines, toRemove) {
-    var layout = [];
-    var nextToRemoveIndex = 0;
-    var nextToRemoveStart = toRemove[nextToRemoveIndex];
-    var countRemovedSoFar = 0;
-    for (var i = 0; i < lines.length; i++) {
-        if (nextToRemoveStart === i) {
-            var countToRemove = toRemove[++nextToRemoveIndex];
-            lines.onDeleteEmitter.fire({
-                index: i - countRemovedSoFar,
-                amount: countToRemove
-            });
-            i += countToRemove - 1;
-            countRemovedSoFar += countToRemove;
-            nextToRemoveStart = toRemove[++nextToRemoveIndex];
-        }
-        else {
-            layout.push(i);
-        }
-    }
-    return {
-        layout: layout,
-        countRemoved: countRemovedSoFar
-    };
-}
-exports.reflowLargerCreateNewLayout = reflowLargerCreateNewLayout;
-function reflowLargerApplyNewLayout(lines, newLayout) {
-    var newLayoutLines = [];
-    for (var i = 0; i < newLayout.length; i++) {
-        newLayoutLines.push(lines.get(newLayout[i]));
-    }
-    for (var i = 0; i < newLayoutLines.length; i++) {
-        lines.set(i, newLayoutLines[i]);
-    }
-    lines.length = newLayout.length;
-}
-exports.reflowLargerApplyNewLayout = reflowLargerApplyNewLayout;
-function reflowSmallerGetNewLineLengths(wrappedLines, oldCols, newCols) {
-    var newLineLengths = [];
-    var cellsNeeded = wrappedLines.map(function (l, i) { return getWrappedLineTrimmedLength(wrappedLines, i, oldCols); }).reduce(function (p, c) { return p + c; });
-    var srcCol = 0;
-    var srcLine = 0;
-    var cellsAvailable = 0;
-    while (cellsAvailable < cellsNeeded) {
-        if (cellsNeeded - cellsAvailable < newCols) {
-            newLineLengths.push(cellsNeeded - cellsAvailable);
-            break;
-        }
-        srcCol += newCols;
-        var oldTrimmedLength = getWrappedLineTrimmedLength(wrappedLines, srcLine, oldCols);
-        if (srcCol > oldTrimmedLength) {
-            srcCol -= oldTrimmedLength;
-            srcLine++;
-        }
-        var endsWithWide = wrappedLines[srcLine].getWidth(srcCol - 1) === 2;
-        if (endsWithWide) {
-            srcCol--;
-        }
-        var lineLength = endsWithWide ? newCols - 1 : newCols;
-        newLineLengths.push(lineLength);
-        cellsAvailable += lineLength;
-    }
-    return newLineLengths;
-}
-exports.reflowSmallerGetNewLineLengths = reflowSmallerGetNewLineLengths;
-function getWrappedLineTrimmedLength(lines, i, cols) {
-    if (i === lines.length - 1) {
-        return lines[i].getTrimmedLength();
-    }
-    var endsInNull = !(lines[i].hasContent(cols - 1)) && lines[i].getWidth(cols - 1) === 1;
-    var followingLineStartsWithWide = lines[i + 1].getWidth(0) === 2;
-    if (endsInNull && followingLineStartsWithWide) {
-        return cols - 1;
-    }
-    return cols;
-}
-exports.getWrappedLineTrimmedLength = getWrappedLineTrimmedLength;
-
-},{}],5:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Buffer_1 = require("./Buffer");
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var BufferSet = (function () {
-    function BufferSet(_terminal) {
-        this._terminal = _terminal;
-        this._onBufferActivate = new EventEmitter2_1.EventEmitter2();
-        this._normal = new Buffer_1.Buffer(this._terminal, true);
-        this._normal.fillViewportRows();
-        this._alt = new Buffer_1.Buffer(this._terminal, false);
-        this._activeBuffer = this._normal;
-        this.setupTabStops();
-    }
-    Object.defineProperty(BufferSet.prototype, "onBufferActivate", {
-        get: function () { return this._onBufferActivate.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(BufferSet.prototype, "alt", {
-        get: function () {
-            return this._alt;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(BufferSet.prototype, "active", {
-        get: function () {
-            return this._activeBuffer;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(BufferSet.prototype, "normal", {
-        get: function () {
-            return this._normal;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    BufferSet.prototype.activateNormalBuffer = function () {
-        if (this._activeBuffer === this._normal) {
-            return;
-        }
-        this._normal.x = this._alt.x;
-        this._normal.y = this._alt.y;
-        this._alt.clear();
-        this._activeBuffer = this._normal;
-        this._onBufferActivate.fire({
-            activeBuffer: this._normal,
-            inactiveBuffer: this._alt
-        });
-    };
-    BufferSet.prototype.activateAltBuffer = function (fillAttr) {
-        if (this._activeBuffer === this._alt) {
-            return;
-        }
-        this._alt.fillViewportRows(fillAttr);
-        this._alt.x = this._normal.x;
-        this._alt.y = this._normal.y;
-        this._activeBuffer = this._alt;
-        this._onBufferActivate.fire({
-            activeBuffer: this._alt,
-            inactiveBuffer: this._normal
-        });
-    };
-    BufferSet.prototype.resize = function (newCols, newRows) {
-        this._normal.resize(newCols, newRows);
-        this._alt.resize(newCols, newRows);
-    };
-    BufferSet.prototype.setupTabStops = function (i) {
-        this._normal.setupTabStops(i);
-        this._alt.setupTabStops(i);
-    };
-    return BufferSet;
-}());
-exports.BufferSet = BufferSet;
-
-},{"./Buffer":2,"./common/EventEmitter2":25}],6:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var CharMeasure = (function () {
-    function CharMeasure(document, parentElement) {
-        this._onCharSizeChanged = new EventEmitter2_1.EventEmitter2();
-        this._document = document;
-        this._parentElement = parentElement;
-        this._measureElement = this._document.createElement('span');
-        this._measureElement.classList.add('xterm-char-measure-element');
-        this._measureElement.textContent = 'W';
-        this._measureElement.setAttribute('aria-hidden', 'true');
-        this._parentElement.appendChild(this._measureElement);
-    }
-    Object.defineProperty(CharMeasure.prototype, "onCharSizeChanged", {
-        get: function () { return this._onCharSizeChanged.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(CharMeasure.prototype, "width", {
-        get: function () {
-            return this._width;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(CharMeasure.prototype, "height", {
-        get: function () {
-            return this._height;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    CharMeasure.prototype.measure = function (options) {
-        this._measureElement.style.fontFamily = options.fontFamily;
-        this._measureElement.style.fontSize = options.fontSize + "px";
-        var geometry = this._measureElement.getBoundingClientRect();
-        if (geometry.width === 0 || geometry.height === 0) {
-            return;
-        }
-        var adjustedHeight = Math.ceil(geometry.height);
-        if (this._width !== geometry.width || this._height !== adjustedHeight) {
-            this._width = geometry.width;
-            this._height = adjustedHeight;
-            this._onCharSizeChanged.fire();
-        }
-    };
-    return CharMeasure;
-}());
-exports.CharMeasure = CharMeasure;
-
-},{"./common/EventEmitter2":25}],7:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var TypedArrayUtils_1 = require("./common/TypedArrayUtils");
-exports.wcwidth = (function (opts) {
-    var COMBINING_BMP = [
-        [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
-        [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],
-        [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],
-        [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],
-        [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],
-        [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],
-        [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],
-        [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],
-        [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],
-        [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],
-        [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],
-        [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],
-        [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],
-        [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],
-        [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],
-        [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],
-        [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],
-        [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],
-        [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],
-        [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],
-        [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],
-        [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],
-        [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],
-        [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],
-        [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],
-        [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],
-        [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],
-        [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],
-        [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],
-        [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],
-        [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],
-        [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],
-        [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],
-        [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],
-        [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],
-        [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],
-        [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],
-        [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],
-        [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],
-        [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],
-        [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],
-        [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],
-        [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]
-    ];
-    var COMBINING_HIGH = [
-        [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],
-        [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],
-        [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],
-        [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],
-        [0xE0100, 0xE01EF]
-    ];
-    function bisearch(ucs, data) {
-        var min = 0;
-        var max = data.length - 1;
-        var mid;
-        if (ucs < data[0][0] || ucs > data[max][1]) {
-            return false;
-        }
-        while (max >= min) {
-            mid = (min + max) >> 1;
-            if (ucs > data[mid][1]) {
-                min = mid + 1;
-            }
-            else if (ucs < data[mid][0]) {
-                max = mid - 1;
-            }
-            else {
-                return true;
-            }
-        }
-        return false;
-    }
-    function wcwidthHigh(ucs) {
-        if (bisearch(ucs, COMBINING_HIGH)) {
-            return 0;
-        }
-        if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {
-            return 2;
-        }
-        return 1;
-    }
-    var control = opts.control | 0;
-    var table = new Uint8Array(65536);
-    TypedArrayUtils_1.fill(table, 1);
-    table[0] = opts.nul;
-    TypedArrayUtils_1.fill(table, opts.control, 1, 32);
-    TypedArrayUtils_1.fill(table, opts.control, 0x7f, 0xa0);
-    TypedArrayUtils_1.fill(table, 2, 0x1100, 0x1160);
-    table[0x2329] = 2;
-    table[0x232a] = 2;
-    TypedArrayUtils_1.fill(table, 2, 0x2e80, 0xa4d0);
-    table[0x303f] = 1;
-    TypedArrayUtils_1.fill(table, 2, 0xac00, 0xd7a4);
-    TypedArrayUtils_1.fill(table, 2, 0xf900, 0xfb00);
-    TypedArrayUtils_1.fill(table, 2, 0xfe10, 0xfe1a);
-    TypedArrayUtils_1.fill(table, 2, 0xfe30, 0xfe70);
-    TypedArrayUtils_1.fill(table, 2, 0xff00, 0xff61);
-    TypedArrayUtils_1.fill(table, 2, 0xffe0, 0xffe7);
-    for (var r = 0; r < COMBINING_BMP.length; ++r) {
-        TypedArrayUtils_1.fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);
-    }
-    return function (num) {
-        if (num < 32) {
-            return control | 0;
-        }
-        if (num < 127) {
-            return 1;
-        }
-        if (num < 65536) {
-            return table[num];
-        }
-        return wcwidthHigh(num);
-    };
-})({ nul: 0, control: 0 });
-function getStringCellWidth(s) {
-    var result = 0;
-    var length = s.length;
-    for (var i = 0; i < length; ++i) {
-        var code = s.charCodeAt(i);
-        if (0xD800 <= code && code <= 0xDBFF) {
-            if (++i >= length) {
-                return result + exports.wcwidth(code);
-            }
-            var second = s.charCodeAt(i);
-            if (0xDC00 <= second && second <= 0xDFFF) {
-                code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
-            }
-            else {
-                result += exports.wcwidth(second);
-            }
-        }
-        result += exports.wcwidth(code);
-    }
-    return result;
-}
-exports.getStringCellWidth = getStringCellWidth;
-
-},{"./common/TypedArrayUtils":28}],8:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function prepareTextForTerminal(text) {
-    return text.replace(/\r?\n/g, '\r');
-}
-exports.prepareTextForTerminal = prepareTextForTerminal;
-function bracketTextForPaste(text, bracketedPasteMode) {
-    if (bracketedPasteMode) {
-        return '\x1b[200~' + text + '\x1b[201~';
-    }
-    return text;
-}
-exports.bracketTextForPaste = bracketTextForPaste;
-function copyHandler(ev, term, selectionManager) {
-    if (term.browser.isMSIE) {
-        window.clipboardData.setData('Text', selectionManager.selectionText);
-    }
-    else {
-        ev.clipboardData.setData('text/plain', selectionManager.selectionText);
-    }
-    ev.preventDefault();
-}
-exports.copyHandler = copyHandler;
-function pasteHandler(ev, term) {
-    ev.stopPropagation();
-    var text;
-    var dispatchPaste = function (text) {
-        text = prepareTextForTerminal(text);
-        text = bracketTextForPaste(text, term.bracketedPasteMode);
-        term.handler(text);
-        term.textarea.value = '';
-        term.emit('paste', text);
-        term.cancel(ev);
-    };
-    if (term.browser.isMSIE) {
-        if (window.clipboardData) {
-            text = window.clipboardData.getData('Text');
-            dispatchPaste(text);
-        }
-    }
-    else {
-        if (ev.clipboardData) {
-            text = ev.clipboardData.getData('text/plain');
-            dispatchPaste(text);
-        }
-    }
-}
-exports.pasteHandler = pasteHandler;
-function moveTextAreaUnderMouseCursor(ev, term) {
-    var pos = term.screenElement.getBoundingClientRect();
-    var left = ev.clientX - pos.left - 10;
-    var top = ev.clientY - pos.top - 10;
-    term.textarea.style.position = 'absolute';
-    term.textarea.style.width = '20px';
-    term.textarea.style.height = '20px';
-    term.textarea.style.left = left + "px";
-    term.textarea.style.top = top + "px";
-    term.textarea.style.zIndex = '1000';
-    term.textarea.focus();
-    setTimeout(function () {
-        term.textarea.style.position = null;
-        term.textarea.style.width = null;
-        term.textarea.style.height = null;
-        term.textarea.style.left = null;
-        term.textarea.style.top = null;
-        term.textarea.style.zIndex = null;
-    }, 200);
-}
-exports.moveTextAreaUnderMouseCursor = moveTextAreaUnderMouseCursor;
-function rightClickHandler(ev, term, selectionManager, shouldSelectWord) {
-    moveTextAreaUnderMouseCursor(ev, term);
-    if (shouldSelectWord && !selectionManager.isClickInSelection(ev)) {
-        selectionManager.selectWordAtCursor(ev);
-    }
-    term.textarea.value = selectionManager.selectionText;
-    term.textarea.select();
-}
-exports.rightClickHandler = rightClickHandler;
-
-},{}],9:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var CompositionHelper = (function () {
-    function CompositionHelper(_textarea, _compositionView, _terminal) {
-        this._textarea = _textarea;
-        this._compositionView = _compositionView;
-        this._terminal = _terminal;
-        this._isComposing = false;
-        this._isSendingComposition = false;
-        this._compositionPosition = { start: null, end: null };
-    }
-    CompositionHelper.prototype.compositionstart = function () {
-        this._isComposing = true;
-        this._compositionPosition.start = this._textarea.value.length;
-        this._compositionView.textContent = '';
-        this._compositionView.classList.add('active');
-    };
-    CompositionHelper.prototype.compositionupdate = function (ev) {
-        var _this = this;
-        this._compositionView.textContent = ev.data;
-        this.updateCompositionElements();
-        setTimeout(function () {
-            _this._compositionPosition.end = _this._textarea.value.length;
-        }, 0);
-    };
-    CompositionHelper.prototype.compositionend = function () {
-        this._finalizeComposition(true);
-    };
-    CompositionHelper.prototype.keydown = function (ev) {
-        if (this._isComposing || this._isSendingComposition) {
-            if (ev.keyCode === 229) {
-                return false;
-            }
-            else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {
-                return false;
-            }
-            this._finalizeComposition(false);
-        }
-        if (ev.keyCode === 229) {
-            this._handleAnyTextareaChanges();
-            return false;
-        }
-        return true;
-    };
-    CompositionHelper.prototype._finalizeComposition = function (waitForPropagation) {
-        var _this = this;
-        this._compositionView.classList.remove('active');
-        this._isComposing = false;
-        this._clearTextareaPosition();
-        if (!waitForPropagation) {
-            this._isSendingComposition = false;
-            var input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);
-            this._terminal.handler(input);
-        }
-        else {
-            var currentCompositionPosition_1 = {
-                start: this._compositionPosition.start,
-                end: this._compositionPosition.end
-            };
-            this._isSendingComposition = true;
-            setTimeout(function () {
-                if (_this._isSendingComposition) {
-                    _this._isSendingComposition = false;
-                    var input = void 0;
-                    if (_this._isComposing) {
-                        input = _this._textarea.value.substring(currentCompositionPosition_1.start, currentCompositionPosition_1.end);
-                    }
-                    else {
-                        input = _this._textarea.value.substring(currentCompositionPosition_1.start);
-                    }
-                    _this._terminal.handler(input);
-                }
-            }, 0);
-        }
-    };
-    CompositionHelper.prototype._handleAnyTextareaChanges = function () {
-        var _this = this;
-        var oldValue = this._textarea.value;
-        setTimeout(function () {
-            if (!_this._isComposing) {
-                var newValue = _this._textarea.value;
-                var diff = newValue.replace(oldValue, '');
-                if (diff.length > 0) {
-                    _this._terminal.handler(diff);
-                }
-            }
-        }, 0);
-    };
-    CompositionHelper.prototype.updateCompositionElements = function (dontRecurse) {
-        var _this = this;
-        if (!this._isComposing) {
-            return;
-        }
-        if (this._terminal.buffer.isCursorInViewport) {
-            var cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight);
-            var cursorTop = this._terminal.buffer.y * cellHeight;
-            var cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width;
-            this._compositionView.style.left = cursorLeft + 'px';
-            this._compositionView.style.top = cursorTop + 'px';
-            this._compositionView.style.height = cellHeight + 'px';
-            this._compositionView.style.lineHeight = cellHeight + 'px';
-            this._compositionView.style.fontFamily = this._terminal.options.fontFamily;
-            this._compositionView.style.fontSize = this._terminal.options.fontSize + 'px';
-            var compositionViewBounds = this._compositionView.getBoundingClientRect();
-            this._textarea.style.left = cursorLeft + 'px';
-            this._textarea.style.top = cursorTop + 'px';
-            this._textarea.style.width = compositionViewBounds.width + 'px';
-            this._textarea.style.height = compositionViewBounds.height + 'px';
-            this._textarea.style.lineHeight = compositionViewBounds.height + 'px';
-        }
-        if (!dontRecurse) {
-            setTimeout(function () { return _this.updateCompositionElements(true); }, 0);
-        }
-    };
-    CompositionHelper.prototype._clearTextareaPosition = function () {
-        this._textarea.style.left = '';
-        this._textarea.style.top = '';
-    };
-    return CompositionHelper;
-}());
-exports.CompositionHelper = CompositionHelper;
-
-},{}],10:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Lifecycle_1 = require("./common/Lifecycle");
-var TextDecoder_1 = require("./core/input/TextDecoder");
-function r(low, high) {
-    var c = high - low;
-    var arr = new Array(c);
-    while (c--) {
-        arr[c] = --high;
-    }
-    return arr;
-}
-var TransitionTable = (function () {
-    function TransitionTable(length) {
-        this.table = (typeof Uint8Array === 'undefined')
-            ? new Array(length)
-            : new Uint8Array(length);
-    }
-    TransitionTable.prototype.add = function (code, state, action, next) {
-        this.table[state << 8 | code] = ((action | 0) << 4) | ((next === undefined) ? state : next);
-    };
-    TransitionTable.prototype.addMany = function (codes, state, action, next) {
-        for (var i = 0; i < codes.length; i++) {
-            this.add(codes[i], state, action, next);
-        }
-    };
-    return TransitionTable;
-}());
-exports.TransitionTable = TransitionTable;
-var PRINTABLES = r(0x20, 0x7f);
-var EXECUTABLES = r(0x00, 0x18);
-EXECUTABLES.push(0x19);
-EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));
-var NON_ASCII_PRINTABLE = 0xA0;
-exports.VT500_TRANSITION_TABLE = (function () {
-    var table = new TransitionTable(4095);
-    var states = r(0, 13 + 1);
-    var state;
-    for (state in states) {
-        for (var code = 0; code <= NON_ASCII_PRINTABLE; ++code) {
-            table.add(code, state, 1, 0);
-        }
-    }
-    table.addMany(PRINTABLES, 0, 2, 0);
-    for (state in states) {
-        table.addMany([0x18, 0x1a, 0x99, 0x9a], state, 3, 0);
-        table.addMany(r(0x80, 0x90), state, 3, 0);
-        table.addMany(r(0x90, 0x98), state, 3, 0);
-        table.add(0x9c, state, 0, 0);
-        table.add(0x1b, state, 11, 1);
-        table.add(0x9d, state, 4, 8);
-        table.addMany([0x98, 0x9e, 0x9f], state, 0, 7);
-        table.add(0x9b, state, 11, 3);
-        table.add(0x90, state, 11, 9);
-    }
-    table.addMany(EXECUTABLES, 0, 3, 0);
-    table.addMany(EXECUTABLES, 1, 3, 1);
-    table.add(0x7f, 1, 0, 1);
-    table.addMany(EXECUTABLES, 8, 0, 8);
-    table.addMany(EXECUTABLES, 3, 3, 3);
-    table.add(0x7f, 3, 0, 3);
-    table.addMany(EXECUTABLES, 4, 3, 4);
-    table.add(0x7f, 4, 0, 4);
-    table.addMany(EXECUTABLES, 6, 3, 6);
-    table.addMany(EXECUTABLES, 5, 3, 5);
-    table.add(0x7f, 5, 0, 5);
-    table.addMany(EXECUTABLES, 2, 3, 2);
-    table.add(0x7f, 2, 0, 2);
-    table.add(0x5d, 1, 4, 8);
-    table.addMany(PRINTABLES, 8, 5, 8);
-    table.add(0x7f, 8, 5, 8);
-    table.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], 8, 6, 0);
-    table.addMany(r(0x1c, 0x20), 8, 0, 8);
-    table.addMany([0x58, 0x5e, 0x5f], 1, 0, 7);
-    table.addMany(PRINTABLES, 7, 0, 7);
-    table.addMany(EXECUTABLES, 7, 0, 7);
-    table.add(0x9c, 7, 0, 0);
-    table.add(0x7f, 7, 0, 7);
-    table.add(0x5b, 1, 11, 3);
-    table.addMany(r(0x40, 0x7f), 3, 7, 0);
-    table.addMany(r(0x30, 0x3a), 3, 8, 4);
-    table.add(0x3b, 3, 8, 4);
-    table.addMany([0x3c, 0x3d, 0x3e, 0x3f], 3, 9, 4);
-    table.addMany(r(0x30, 0x3a), 4, 8, 4);
-    table.add(0x3b, 4, 8, 4);
-    table.addMany(r(0x40, 0x7f), 4, 7, 0);
-    table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 4, 0, 6);
-    table.addMany(r(0x20, 0x40), 6, 0, 6);
-    table.add(0x7f, 6, 0, 6);
-    table.addMany(r(0x40, 0x7f), 6, 0, 0);
-    table.add(0x3a, 3, 0, 6);
-    table.addMany(r(0x20, 0x30), 3, 9, 5);
-    table.addMany(r(0x20, 0x30), 5, 9, 5);
-    table.addMany(r(0x30, 0x40), 5, 0, 6);
-    table.addMany(r(0x40, 0x7f), 5, 7, 0);
-    table.addMany(r(0x20, 0x30), 4, 9, 5);
-    table.addMany(r(0x20, 0x30), 1, 9, 2);
-    table.addMany(r(0x20, 0x30), 2, 9, 2);
-    table.addMany(r(0x30, 0x7f), 2, 10, 0);
-    table.addMany(r(0x30, 0x50), 1, 10, 0);
-    table.addMany(r(0x51, 0x58), 1, 10, 0);
-    table.addMany([0x59, 0x5a, 0x5c], 1, 10, 0);
-    table.addMany(r(0x60, 0x7f), 1, 10, 0);
-    table.add(0x50, 1, 11, 9);
-    table.addMany(EXECUTABLES, 9, 0, 9);
-    table.add(0x7f, 9, 0, 9);
-    table.addMany(r(0x1c, 0x20), 9, 0, 9);
-    table.addMany(r(0x20, 0x30), 9, 9, 12);
-    table.add(0x3a, 9, 0, 11);
-    table.addMany(r(0x30, 0x3a), 9, 8, 10);
-    table.add(0x3b, 9, 8, 10);
-    table.addMany([0x3c, 0x3d, 0x3e, 0x3f], 9, 9, 10);
-    table.addMany(EXECUTABLES, 11, 0, 11);
-    table.addMany(r(0x20, 0x80), 11, 0, 11);
-    table.addMany(r(0x1c, 0x20), 11, 0, 11);
-    table.addMany(EXECUTABLES, 10, 0, 10);
-    table.add(0x7f, 10, 0, 10);
-    table.addMany(r(0x1c, 0x20), 10, 0, 10);
-    table.addMany(r(0x30, 0x3a), 10, 8, 10);
-    table.add(0x3b, 10, 8, 10);
-    table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], 10, 0, 11);
-    table.addMany(r(0x20, 0x30), 10, 9, 12);
-    table.addMany(EXECUTABLES, 12, 0, 12);
-    table.add(0x7f, 12, 0, 12);
-    table.addMany(r(0x1c, 0x20), 12, 0, 12);
-    table.addMany(r(0x20, 0x30), 12, 9, 12);
-    table.addMany(r(0x30, 0x40), 12, 0, 11);
-    table.addMany(r(0x40, 0x7f), 12, 12, 13);
-    table.addMany(r(0x40, 0x7f), 10, 12, 13);
-    table.addMany(r(0x40, 0x7f), 9, 12, 13);
-    table.addMany(EXECUTABLES, 13, 13, 13);
-    table.addMany(PRINTABLES, 13, 13, 13);
-    table.add(0x7f, 13, 0, 13);
-    table.addMany([0x1b, 0x9c], 13, 14, 0);
-    table.add(NON_ASCII_PRINTABLE, 8, 5, 8);
-    return table;
-})();
-var DcsDummy = (function () {
-    function DcsDummy() {
-    }
-    DcsDummy.prototype.hook = function (collect, params, flag) { };
-    DcsDummy.prototype.put = function (data, start, end) { };
-    DcsDummy.prototype.unhook = function () { };
-    return DcsDummy;
-}());
-var EscapeSequenceParser = (function (_super) {
-    __extends(EscapeSequenceParser, _super);
-    function EscapeSequenceParser(TRANSITIONS) {
-        if (TRANSITIONS === void 0) { TRANSITIONS = exports.VT500_TRANSITION_TABLE; }
-        var _this = _super.call(this) || this;
-        _this.TRANSITIONS = TRANSITIONS;
-        _this.initialState = 0;
-        _this.currentState = _this.initialState;
-        _this._osc = '';
-        _this._params = [0];
-        _this._collect = '';
-        _this._printHandlerFb = function (data, start, end) { };
-        _this._executeHandlerFb = function (code) { };
-        _this._csiHandlerFb = function (collect, params, flag) { };
-        _this._escHandlerFb = function (collect, flag) { };
-        _this._oscHandlerFb = function (identifier, data) { };
-        _this._dcsHandlerFb = new DcsDummy();
-        _this._errorHandlerFb = function (state) { return state; };
-        _this._printHandler = _this._printHandlerFb;
-        _this._executeHandlers = Object.create(null);
-        _this._csiHandlers = Object.create(null);
-        _this._escHandlers = Object.create(null);
-        _this._oscHandlers = Object.create(null);
-        _this._dcsHandlers = Object.create(null);
-        _this._activeDcsHandler = null;
-        _this._errorHandler = _this._errorHandlerFb;
-        _this.setEscHandler('\\', function () { });
-        return _this;
-    }
-    EscapeSequenceParser.prototype.dispose = function () {
-        this._printHandlerFb = null;
-        this._executeHandlerFb = null;
-        this._csiHandlerFb = null;
-        this._escHandlerFb = null;
-        this._oscHandlerFb = null;
-        this._dcsHandlerFb = null;
-        this._errorHandlerFb = null;
-        this._printHandler = null;
-        this._executeHandlers = null;
-        this._escHandlers = null;
-        this._csiHandlers = null;
-        this._oscHandlers = null;
-        this._dcsHandlers = null;
-        this._activeDcsHandler = null;
-        this._errorHandler = null;
-    };
-    EscapeSequenceParser.prototype.setPrintHandler = function (callback) {
-        this._printHandler = callback;
-    };
-    EscapeSequenceParser.prototype.clearPrintHandler = function () {
-        this._printHandler = this._printHandlerFb;
-    };
-    EscapeSequenceParser.prototype.setExecuteHandler = function (flag, callback) {
-        this._executeHandlers[flag.charCodeAt(0)] = callback;
-    };
-    EscapeSequenceParser.prototype.clearExecuteHandler = function (flag) {
-        if (this._executeHandlers[flag.charCodeAt(0)])
-            delete this._executeHandlers[flag.charCodeAt(0)];
-    };
-    EscapeSequenceParser.prototype.setExecuteHandlerFallback = function (callback) {
-        this._executeHandlerFb = callback;
-    };
-    EscapeSequenceParser.prototype.addCsiHandler = function (flag, callback) {
-        var index = flag.charCodeAt(0);
-        if (this._csiHandlers[index] === undefined) {
-            this._csiHandlers[index] = [];
-        }
-        var handlerList = this._csiHandlers[index];
-        handlerList.push(callback);
-        return {
-            dispose: function () {
-                var handlerIndex = handlerList.indexOf(callback);
-                if (handlerIndex !== -1) {
-                    handlerList.splice(handlerIndex, 1);
-                }
-            }
-        };
-    };
-    EscapeSequenceParser.prototype.setCsiHandler = function (flag, callback) {
-        this._csiHandlers[flag.charCodeAt(0)] = [callback];
-    };
-    EscapeSequenceParser.prototype.clearCsiHandler = function (flag) {
-        if (this._csiHandlers[flag.charCodeAt(0)])
-            delete this._csiHandlers[flag.charCodeAt(0)];
-    };
-    EscapeSequenceParser.prototype.setCsiHandlerFallback = function (callback) {
-        this._csiHandlerFb = callback;
-    };
-    EscapeSequenceParser.prototype.setEscHandler = function (collectAndFlag, callback) {
-        this._escHandlers[collectAndFlag] = callback;
-    };
-    EscapeSequenceParser.prototype.clearEscHandler = function (collectAndFlag) {
-        if (this._escHandlers[collectAndFlag])
-            delete this._escHandlers[collectAndFlag];
-    };
-    EscapeSequenceParser.prototype.setEscHandlerFallback = function (callback) {
-        this._escHandlerFb = callback;
-    };
-    EscapeSequenceParser.prototype.addOscHandler = function (ident, callback) {
-        if (this._oscHandlers[ident] === undefined) {
-            this._oscHandlers[ident] = [];
-        }
-        var handlerList = this._oscHandlers[ident];
-        handlerList.push(callback);
-        return {
-            dispose: function () {
-                var handlerIndex = handlerList.indexOf(callback);
-                if (handlerIndex !== -1) {
-                    handlerList.splice(handlerIndex, 1);
-                }
-            }
-        };
-    };
-    EscapeSequenceParser.prototype.setOscHandler = function (ident, callback) {
-        this._oscHandlers[ident] = [callback];
-    };
-    EscapeSequenceParser.prototype.clearOscHandler = function (ident) {
-        if (this._oscHandlers[ident])
-            delete this._oscHandlers[ident];
-    };
-    EscapeSequenceParser.prototype.setOscHandlerFallback = function (callback) {
-        this._oscHandlerFb = callback;
-    };
-    EscapeSequenceParser.prototype.setDcsHandler = function (collectAndFlag, handler) {
-        this._dcsHandlers[collectAndFlag] = handler;
-    };
-    EscapeSequenceParser.prototype.clearDcsHandler = function (collectAndFlag) {
-        if (this._dcsHandlers[collectAndFlag])
-            delete this._dcsHandlers[collectAndFlag];
-    };
-    EscapeSequenceParser.prototype.setDcsHandlerFallback = function (handler) {
-        this._dcsHandlerFb = handler;
-    };
-    EscapeSequenceParser.prototype.setErrorHandler = function (callback) {
-        this._errorHandler = callback;
-    };
-    EscapeSequenceParser.prototype.clearErrorHandler = function () {
-        this._errorHandler = this._errorHandlerFb;
-    };
-    EscapeSequenceParser.prototype.reset = function () {
-        this.currentState = this.initialState;
-        this._osc = '';
-        this._params = [0];
-        this._collect = '';
-        this._activeDcsHandler = null;
-    };
-    EscapeSequenceParser.prototype.parse = function (data, length) {
-        var code = 0;
-        var transition = 0;
-        var error = false;
-        var currentState = this.currentState;
-        var print = -1;
-        var dcs = -1;
-        var osc = this._osc;
-        var collect = this._collect;
-        var params = this._params;
-        var table = this.TRANSITIONS.table;
-        var dcsHandler = this._activeDcsHandler;
-        var callback = null;
-        for (var i = 0; i < length; ++i) {
-            code = data[i];
-            if (currentState === 0 && code > 0x1f && code < 0x80) {
-                print = (~print) ? print : i;
-                do
-                    i++;
-                while (i < length && data[i] > 0x1f && data[i] < 0x80);
-                i--;
-                continue;
-            }
-            if (currentState === 4 && (code > 0x2f && code < 0x39)) {
-                params[params.length - 1] = params[params.length - 1] * 10 + code - 48;
-                continue;
-            }
-            transition = table[currentState << 8 | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)];
-            switch (transition >> 4) {
-                case 2:
-                    print = (~print) ? print : i;
-                    break;
-                case 3:
-                    if (~print) {
-                        this._printHandler(data, print, i);
-                        print = -1;
-                    }
-                    callback = this._executeHandlers[code];
-                    if (callback)
-                        callback();
-                    else
-                        this._executeHandlerFb(code);
-                    break;
-                case 0:
-                    if (~print) {
-                        this._printHandler(data, print, i);
-                        print = -1;
-                    }
-                    else if (~dcs) {
-                        dcsHandler.put(data, dcs, i);
-                        dcs = -1;
-                    }
-                    break;
-                case 1:
-                    if (code > 0x9f) {
-                        switch (currentState) {
-                            case 0:
-                                print = (~print) ? print : i;
-                                break;
-                            case 6:
-                                transition |= 6;
-                                break;
-                            case 11:
-                                transition |= 11;
-                                break;
-                            case 13:
-                                dcs = (~dcs) ? dcs : i;
-                                transition |= 13;
-                                break;
-                            default:
-                                error = true;
-                        }
-                    }
-                    else {
-                        error = true;
-                    }
-                    if (error) {
-                        var inject = this._errorHandler({
-                            position: i,
-                            code: code,
-                            currentState: currentState,
-                            print: print,
-                            dcs: dcs,
-                            osc: osc,
-                            collect: collect,
-                            params: params,
-                            abort: false
-                        });
-                        if (inject.abort)
-                            return;
-                        error = false;
-                    }
-                    break;
-                case 7:
-                    var handlers = this._csiHandlers[code];
-                    var j = handlers ? handlers.length - 1 : -1;
-                    for (; j >= 0; j--) {
-                        if (handlers[j](params, collect) !== false) {
-                            break;
-                        }
-                    }
-                    if (j < 0) {
-                        this._csiHandlerFb(collect, params, code);
-                    }
-                    break;
-                case 8:
-                    if (code === 0x3b)
-                        params.push(0);
-                    else
-                        params[params.length - 1] = params[params.length - 1] * 10 + code - 48;
-                    break;
-                case 9:
-                    collect += String.fromCharCode(code);
-                    break;
-                case 10:
-                    callback = this._escHandlers[collect + String.fromCharCode(code)];
-                    if (callback)
-                        callback(collect, code);
-                    else
-                        this._escHandlerFb(collect, code);
-                    break;
-                case 11:
-                    if (~print) {
-                        this._printHandler(data, print, i);
-                        print = -1;
-                    }
-                    osc = '';
-                    params = [0];
-                    collect = '';
-                    dcs = -1;
-                    break;
-                case 12:
-                    dcsHandler = this._dcsHandlers[collect + String.fromCharCode(code)];
-                    if (!dcsHandler)
-                        dcsHandler = this._dcsHandlerFb;
-                    dcsHandler.hook(collect, params, code);
-                    break;
-                case 13:
-                    dcs = (~dcs) ? dcs : i;
-                    break;
-                case 14:
-                    if (dcsHandler) {
-                        if (~dcs)
-                            dcsHandler.put(data, dcs, i);
-                        dcsHandler.unhook();
-                        dcsHandler = null;
-                    }
-                    if (code === 0x1b)
-                        transition |= 1;
-                    osc = '';
-                    params = [0];
-                    collect = '';
-                    dcs = -1;
-                    break;
-                case 4:
-                    if (~print) {
-                        this._printHandler(data, print, i);
-                        print = -1;
-                    }
-                    osc = '';
-                    break;
-                case 5:
-                    for (var j_1 = i + 1;; j_1++) {
-                        if (j_1 >= length
-                            || (code = data[j_1]) < 0x20
-                            || (code > 0x7f && code <= 0x9f)) {
-                            osc += TextDecoder_1.utf32ToString(data, i, j_1);
-                            i = j_1 - 1;
-                            break;
-                        }
-                    }
-                    break;
-                case 6:
-                    if (osc && code !== 0x18 && code !== 0x1a) {
-                        var idx = osc.indexOf(';');
-                        if (idx === -1) {
-                            this._oscHandlerFb(-1, osc);
-                        }
-                        else {
-                            var identifier = parseInt(osc.substring(0, idx));
-                            var content = osc.substring(idx + 1);
-                            var handlers_1 = this._oscHandlers[identifier];
-                            var j_2 = handlers_1 ? handlers_1.length - 1 : -1;
-                            for (; j_2 >= 0; j_2--) {
-                                if (handlers_1[j_2](content) !== false) {
-                                    break;
-                                }
-                            }
-                            if (j_2 < 0) {
-                                this._oscHandlerFb(identifier, content);
-                            }
-                        }
-                    }
-                    if (code === 0x1b)
-                        transition |= 1;
-                    osc = '';
-                    params = [0];
-                    collect = '';
-                    dcs = -1;
-                    break;
-            }
-            currentState = transition & 15;
-        }
-        if (currentState === 0 && ~print) {
-            this._printHandler(data, print, length);
-        }
-        else if (currentState === 13 && ~dcs && dcsHandler) {
-            dcsHandler.put(data, dcs, length);
-        }
-        this._osc = osc;
-        this._collect = collect;
-        this._params = params;
-        this._activeDcsHandler = dcsHandler;
-        this.currentState = currentState;
-    };
-    return EscapeSequenceParser;
-}(Lifecycle_1.Disposable));
-exports.EscapeSequenceParser = EscapeSequenceParser;
-
-},{"./common/Lifecycle":26,"./core/input/TextDecoder":32}],11:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var EscapeSequences_1 = require("./common/data/EscapeSequences");
-var Charsets_1 = require("./core/data/Charsets");
-var Buffer_1 = require("./Buffer");
-var CharWidth_1 = require("./CharWidth");
-var EscapeSequenceParser_1 = require("./EscapeSequenceParser");
-var Lifecycle_1 = require("./common/Lifecycle");
-var TypedArrayUtils_1 = require("./common/TypedArrayUtils");
-var TextDecoder_1 = require("./core/input/TextDecoder");
-var BufferLine_1 = require("./BufferLine");
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var GLEVEL = { '(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2 };
-var DECRQSS = (function () {
-    function DECRQSS(_terminal) {
-        this._terminal = _terminal;
-        this._data = new Uint32Array(0);
-    }
-    DECRQSS.prototype.hook = function (collect, params, flag) {
-        this._data = new Uint32Array(0);
-    };
-    DECRQSS.prototype.put = function (data, start, end) {
-        this._data = TypedArrayUtils_1.concat(this._data, data.subarray(start, end));
-    };
-    DECRQSS.prototype.unhook = function () {
-        var data = TextDecoder_1.utf32ToString(this._data);
-        this._data = new Uint32Array(0);
-        switch (data) {
-            case '"q':
-                return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r0\"q" + EscapeSequences_1.C0.ESC + "\\");
-            case '"p':
-                return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r61\"p" + EscapeSequences_1.C0.ESC + "\\");
-            case 'r':
-                var pt = '' + (this._terminal.buffer.scrollTop + 1) +
-                    ';' + (this._terminal.buffer.scrollBottom + 1) + 'r';
-                return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r" + pt + EscapeSequences_1.C0.ESC + "\\");
-            case 'm':
-                return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r0m" + EscapeSequences_1.C0.ESC + "\\");
-            case ' q':
-                var STYLES = { 'block': 2, 'underline': 4, 'bar': 6 };
-                var style = STYLES[this._terminal.getOption('cursorStyle')];
-                style -= this._terminal.getOption('cursorBlink');
-                return this._terminal.handler(EscapeSequences_1.C0.ESC + "P1$r" + style + " q" + EscapeSequences_1.C0.ESC + "\\");
-            default:
-                this._terminal.error('Unknown DCS $q %s', data);
-                this._terminal.handler(EscapeSequences_1.C0.ESC + "P0$r" + EscapeSequences_1.C0.ESC + "\\");
-        }
-    };
-    return DECRQSS;
-}());
-var InputHandler = (function (_super) {
-    __extends(InputHandler, _super);
-    function InputHandler(_terminal, _parser) {
-        if (_parser === void 0) { _parser = new EscapeSequenceParser_1.EscapeSequenceParser(); }
-        var _this = _super.call(this) || this;
-        _this._terminal = _terminal;
-        _this._parser = _parser;
-        _this._parseBuffer = new Uint32Array(4096);
-        _this._stringDecoder = new TextDecoder_1.StringToUtf32();
-        _this._workCell = new BufferLine_1.CellData();
-        _this._onCursorMove = new EventEmitter2_1.EventEmitter2();
-        _this._onData = new EventEmitter2_1.EventEmitter2();
-        _this._onLineFeed = new EventEmitter2_1.EventEmitter2();
-        _this._onScroll = new EventEmitter2_1.EventEmitter2();
-        _this.register(_this._parser);
-        _this._parser.setCsiHandlerFallback(function (collect, params, flag) {
-            _this._terminal.error('Unknown CSI code: ', { collect: collect, params: params, flag: String.fromCharCode(flag) });
-        });
-        _this._parser.setEscHandlerFallback(function (collect, flag) {
-            _this._terminal.error('Unknown ESC code: ', { collect: collect, flag: String.fromCharCode(flag) });
-        });
-        _this._parser.setExecuteHandlerFallback(function (code) {
-            _this._terminal.error('Unknown EXECUTE code: ', { code: code });
-        });
-        _this._parser.setOscHandlerFallback(function (identifier, data) {
-            _this._terminal.error('Unknown OSC code: ', { identifier: identifier, data: data });
-        });
-        _this._parser.setPrintHandler(function (data, start, end) { return _this.print(data, start, end); });
-        _this._parser.setCsiHandler('@', function (params, collect) { return _this.insertChars(params); });
-        _this._parser.setCsiHandler('A', function (params, collect) { return _this.cursorUp(params); });
-        _this._parser.setCsiHandler('B', function (params, collect) { return _this.cursorDown(params); });
-        _this._parser.setCsiHandler('C', function (params, collect) { return _this.cursorForward(params); });
-        _this._parser.setCsiHandler('D', function (params, collect) { return _this.cursorBackward(params); });
-        _this._parser.setCsiHandler('E', function (params, collect) { return _this.cursorNextLine(params); });
-        _this._parser.setCsiHandler('F', function (params, collect) { return _this.cursorPrecedingLine(params); });
-        _this._parser.setCsiHandler('G', function (params, collect) { return _this.cursorCharAbsolute(params); });
-        _this._parser.setCsiHandler('H', function (params, collect) { return _this.cursorPosition(params); });
-        _this._parser.setCsiHandler('I', function (params, collect) { return _this.cursorForwardTab(params); });
-        _this._parser.setCsiHandler('J', function (params, collect) { return _this.eraseInDisplay(params); });
-        _this._parser.setCsiHandler('K', function (params, collect) { return _this.eraseInLine(params); });
-        _this._parser.setCsiHandler('L', function (params, collect) { return _this.insertLines(params); });
-        _this._parser.setCsiHandler('M', function (params, collect) { return _this.deleteLines(params); });
-        _this._parser.setCsiHandler('P', function (params, collect) { return _this.deleteChars(params); });
-        _this._parser.setCsiHandler('S', function (params, collect) { return _this.scrollUp(params); });
-        _this._parser.setCsiHandler('T', function (params, collect) { return _this.scrollDown(params, collect); });
-        _this._parser.setCsiHandler('X', function (params, collect) { return _this.eraseChars(params); });
-        _this._parser.setCsiHandler('Z', function (params, collect) { return _this.cursorBackwardTab(params); });
-        _this._parser.setCsiHandler('`', function (params, collect) { return _this.charPosAbsolute(params); });
-        _this._parser.setCsiHandler('a', function (params, collect) { return _this.hPositionRelative(params); });
-        _this._parser.setCsiHandler('b', function (params, collect) { return _this.repeatPrecedingCharacter(params); });
-        _this._parser.setCsiHandler('c', function (params, collect) { return _this.sendDeviceAttributes(params, collect); });
-        _this._parser.setCsiHandler('d', function (params, collect) { return _this.linePosAbsolute(params); });
-        _this._parser.setCsiHandler('e', function (params, collect) { return _this.vPositionRelative(params); });
-        _this._parser.setCsiHandler('f', function (params, collect) { return _this.hVPosition(params); });
-        _this._parser.setCsiHandler('g', function (params, collect) { return _this.tabClear(params); });
-        _this._parser.setCsiHandler('h', function (params, collect) { return _this.setMode(params, collect); });
-        _this._parser.setCsiHandler('l', function (params, collect) { return _this.resetMode(params, collect); });
-        _this._parser.setCsiHandler('m', function (params, collect) { return _this.charAttributes(params); });
-        _this._parser.setCsiHandler('n', function (params, collect) { return _this.deviceStatus(params, collect); });
-        _this._parser.setCsiHandler('p', function (params, collect) { return _this.softReset(params, collect); });
-        _this._parser.setCsiHandler('q', function (params, collect) { return _this.setCursorStyle(params, collect); });
-        _this._parser.setCsiHandler('r', function (params, collect) { return _this.setScrollRegion(params, collect); });
-        _this._parser.setCsiHandler('s', function (params, collect) { return _this.saveCursor(params); });
-        _this._parser.setCsiHandler('u', function (params, collect) { return _this.restoreCursor(params); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.BEL, function () { return _this.bell(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.LF, function () { return _this.lineFeed(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.VT, function () { return _this.lineFeed(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.FF, function () { return _this.lineFeed(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.CR, function () { return _this.carriageReturn(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.BS, function () { return _this.backspace(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.HT, function () { return _this.tab(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.SO, function () { return _this.shiftOut(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C0.SI, function () { return _this.shiftIn(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C1.IND, function () { return _this.index(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C1.NEL, function () { return _this.nextLine(); });
-        _this._parser.setExecuteHandler(EscapeSequences_1.C1.HTS, function () { return _this.tabSet(); });
-        _this._parser.setOscHandler(0, function (data) { return _this.setTitle(data); });
-        _this._parser.setOscHandler(2, function (data) { return _this.setTitle(data); });
-        _this._parser.setEscHandler('7', function () { return _this.saveCursor([]); });
-        _this._parser.setEscHandler('8', function () { return _this.restoreCursor([]); });
-        _this._parser.setEscHandler('D', function () { return _this.index(); });
-        _this._parser.setEscHandler('E', function () { return _this.nextLine(); });
-        _this._parser.setEscHandler('H', function () { return _this.tabSet(); });
-        _this._parser.setEscHandler('M', function () { return _this.reverseIndex(); });
-        _this._parser.setEscHandler('=', function () { return _this.keypadApplicationMode(); });
-        _this._parser.setEscHandler('>', function () { return _this.keypadNumericMode(); });
-        _this._parser.setEscHandler('c', function () { return _this.reset(); });
-        _this._parser.setEscHandler('n', function () { return _this.setgLevel(2); });
-        _this._parser.setEscHandler('o', function () { return _this.setgLevel(3); });
-        _this._parser.setEscHandler('|', function () { return _this.setgLevel(3); });
-        _this._parser.setEscHandler('}', function () { return _this.setgLevel(2); });
-        _this._parser.setEscHandler('~', function () { return _this.setgLevel(1); });
-        _this._parser.setEscHandler('%@', function () { return _this.selectDefaultCharset(); });
-        _this._parser.setEscHandler('%G', function () { return _this.selectDefaultCharset(); });
-        var _loop_1 = function (flag) {
-            this_1._parser.setEscHandler('(' + flag, function () { return _this.selectCharset('(' + flag); });
-            this_1._parser.setEscHandler(')' + flag, function () { return _this.selectCharset(')' + flag); });
-            this_1._parser.setEscHandler('*' + flag, function () { return _this.selectCharset('*' + flag); });
-            this_1._parser.setEscHandler('+' + flag, function () { return _this.selectCharset('+' + flag); });
-            this_1._parser.setEscHandler('-' + flag, function () { return _this.selectCharset('-' + flag); });
-            this_1._parser.setEscHandler('.' + flag, function () { return _this.selectCharset('.' + flag); });
-            this_1._parser.setEscHandler('/' + flag, function () { return _this.selectCharset('/' + flag); });
-        };
-        var this_1 = this;
-        for (var flag in Charsets_1.CHARSETS) {
-            _loop_1(flag);
-        }
-        _this._parser.setErrorHandler(function (state) {
-            _this._terminal.error('Parsing error: ', state);
-            return state;
-        });
-        _this._parser.setDcsHandler('$q', new DECRQSS(_this._terminal));
-        return _this;
-    }
-    Object.defineProperty(InputHandler.prototype, "onCursorMove", {
-        get: function () { return this._onCursorMove.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(InputHandler.prototype, "onData", {
-        get: function () { return this._onData.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(InputHandler.prototype, "onLineFeed", {
-        get: function () { return this._onLineFeed.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(InputHandler.prototype, "onScroll", {
-        get: function () { return this._onScroll.event; },
-        enumerable: true,
-        configurable: true
-    });
-    InputHandler.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        this._terminal = null;
-    };
-    InputHandler.prototype.parse = function (data) {
-        if (!this._terminal) {
-            return;
-        }
-        var buffer = this._terminal.buffer;
-        var cursorStartX = buffer.x;
-        var cursorStartY = buffer.y;
-        if (this._terminal.debug) {
-            this._terminal.log('data: ' + data);
-        }
-        if (this._parseBuffer.length < data.length) {
-            this._parseBuffer = new Uint32Array(data.length);
-        }
-        this._parser.parse(this._parseBuffer, this._stringDecoder.decode(data, this._parseBuffer));
-        buffer = this._terminal.buffer;
-        if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) {
-            this._onCursorMove.fire();
-        }
-    };
-    InputHandler.prototype.print = function (data, start, end) {
-        var code;
-        var chWidth;
-        var buffer = this._terminal.buffer;
-        var charset = this._terminal.charset;
-        var screenReaderMode = this._terminal.options.screenReaderMode;
-        var cols = this._terminal.cols;
-        var wraparoundMode = this._terminal.wraparoundMode;
-        var insertMode = this._terminal.insertMode;
-        var curAttr = this._terminal.curAttrData;
-        var bufferRow = buffer.lines.get(buffer.y + buffer.ybase);
-        this._terminal.updateRange(buffer.y);
-        for (var pos = start; pos < end; ++pos) {
-            code = data[pos];
-            chWidth = CharWidth_1.wcwidth(code);
-            if (code < 127 && charset) {
-                var ch = charset[String.fromCharCode(code)];
-                if (ch) {
-                    code = ch.charCodeAt(0);
-                }
-            }
-            if (screenReaderMode) {
-                this._terminal.emit('a11y.char', TextDecoder_1.stringFromCodePoint(code));
-            }
-            if (!chWidth && buffer.x) {
-                if (!bufferRow.getWidth(buffer.x - 1)) {
-                    bufferRow.addCodepointToCell(buffer.x - 2, code);
-                }
-                else {
-                    bufferRow.addCodepointToCell(buffer.x - 1, code);
-                }
-                continue;
-            }
-            if (buffer.x + chWidth - 1 >= cols) {
-                if (wraparoundMode) {
-                    buffer.x = 0;
-                    buffer.y++;
-                    if (buffer.y > buffer.scrollBottom) {
-                        buffer.y--;
-                        this._terminal.scroll(true);
-                    }
-                    else {
-                        buffer.lines.get(buffer.y).isWrapped = true;
-                    }
-                    bufferRow = buffer.lines.get(buffer.y + buffer.ybase);
-                }
-                else {
-                    if (chWidth === 2) {
-                        continue;
-                    }
-                }
-            }
-            if (insertMode) {
-                bufferRow.insertCells(buffer.x, chWidth, buffer.getNullCell(curAttr));
-                if (bufferRow.getWidth(cols - 1) === 2) {
-                    bufferRow.setCellFromCodePoint(cols - 1, Buffer_1.NULL_CELL_CODE, Buffer_1.NULL_CELL_WIDTH, curAttr.fg, curAttr.bg);
-                }
-            }
-            bufferRow.setCellFromCodePoint(buffer.x++, code, chWidth, curAttr.fg, curAttr.bg);
-            if (chWidth > 0) {
-                while (--chWidth) {
-                    bufferRow.setCellFromCodePoint(buffer.x++, 0, 0, curAttr.fg, curAttr.bg);
-                }
-            }
-        }
-        this._terminal.updateRange(buffer.y);
-    };
-    InputHandler.prototype.addCsiHandler = function (flag, callback) {
-        return this._parser.addCsiHandler(flag, callback);
-    };
-    InputHandler.prototype.addOscHandler = function (ident, callback) {
-        return this._parser.addOscHandler(ident, callback);
-    };
-    InputHandler.prototype.bell = function () {
-        this._terminal.bell();
-    };
-    InputHandler.prototype.lineFeed = function () {
-        var buffer = this._terminal.buffer;
-        if (this._terminal.options.convertEol) {
-            buffer.x = 0;
-        }
-        buffer.y++;
-        if (buffer.y > buffer.scrollBottom) {
-            buffer.y--;
-            this._terminal.scroll();
-        }
-        if (buffer.x >= this._terminal.cols) {
-            buffer.x--;
-        }
-        this._onLineFeed.fire();
-    };
-    InputHandler.prototype.carriageReturn = function () {
-        this._terminal.buffer.x = 0;
-    };
-    InputHandler.prototype.backspace = function () {
-        if (this._terminal.buffer.x > 0) {
-            this._terminal.buffer.x--;
-        }
-    };
-    InputHandler.prototype.tab = function () {
-        var originalX = this._terminal.buffer.x;
-        this._terminal.buffer.x = this._terminal.buffer.nextStop();
-        if (this._terminal.options.screenReaderMode) {
-            this._terminal.emit('a11y.tab', this._terminal.buffer.x - originalX);
-        }
-    };
-    InputHandler.prototype.shiftOut = function () {
-        this._terminal.setgLevel(1);
-    };
-    InputHandler.prototype.shiftIn = function () {
-        this._terminal.setgLevel(0);
-    };
-    InputHandler.prototype.insertChars = function (params) {
-        this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).insertCells(this._terminal.buffer.x, params[0] || 1, this._terminal.buffer.getNullCell(this._terminal.eraseAttrData()));
-        this._terminal.updateRange(this._terminal.buffer.y);
-    };
-    InputHandler.prototype.cursorUp = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.y -= param;
-        if (this._terminal.buffer.y < 0) {
-            this._terminal.buffer.y = 0;
-        }
-    };
-    InputHandler.prototype.cursorDown = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.y += param;
-        if (this._terminal.buffer.y >= this._terminal.rows) {
-            this._terminal.buffer.y = this._terminal.rows - 1;
-        }
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x--;
-        }
-    };
-    InputHandler.prototype.cursorForward = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.x += param;
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x = this._terminal.cols - 1;
-        }
-    };
-    InputHandler.prototype.cursorBackward = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x--;
-        }
-        this._terminal.buffer.x -= param;
-        if (this._terminal.buffer.x < 0) {
-            this._terminal.buffer.x = 0;
-        }
-    };
-    InputHandler.prototype.cursorNextLine = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.y += param;
-        if (this._terminal.buffer.y >= this._terminal.rows) {
-            this._terminal.buffer.y = this._terminal.rows - 1;
-        }
-        this._terminal.buffer.x = 0;
-    };
-    InputHandler.prototype.cursorPrecedingLine = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.y -= param;
-        if (this._terminal.buffer.y < 0) {
-            this._terminal.buffer.y = 0;
-        }
-        this._terminal.buffer.x = 0;
-    };
-    InputHandler.prototype.cursorCharAbsolute = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.x = param - 1;
-    };
-    InputHandler.prototype.cursorPosition = function (params) {
-        var col;
-        var row = params[0] - 1;
-        if (params.length >= 2) {
-            col = params[1] - 1;
-        }
-        else {
-            col = 0;
-        }
-        if (row < 0) {
-            row = 0;
-        }
-        else if (row >= this._terminal.rows) {
-            row = this._terminal.rows - 1;
-        }
-        if (col < 0) {
-            col = 0;
-        }
-        else if (col >= this._terminal.cols) {
-            col = this._terminal.cols - 1;
-        }
-        this._terminal.buffer.x = col;
-        this._terminal.buffer.y = row;
-    };
-    InputHandler.prototype.cursorForwardTab = function (params) {
-        var param = params[0] || 1;
-        while (param--) {
-            this._terminal.buffer.x = this._terminal.buffer.nextStop();
-        }
-    };
-    InputHandler.prototype._eraseInBufferLine = function (y, start, end, clearWrap) {
-        if (clearWrap === void 0) { clearWrap = false; }
-        var line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y);
-        line.replaceCells(start, end, this._terminal.buffer.getNullCell(this._terminal.eraseAttrData()));
-        if (clearWrap) {
-            line.isWrapped = false;
-        }
-    };
-    InputHandler.prototype._resetBufferLine = function (y) {
-        this._eraseInBufferLine(y, 0, this._terminal.cols, true);
-    };
-    InputHandler.prototype.eraseInDisplay = function (params) {
-        var j;
-        switch (params[0]) {
-            case 0:
-                j = this._terminal.buffer.y;
-                this._terminal.updateRange(j);
-                this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols, this._terminal.buffer.x === 0);
-                for (; j < this._terminal.rows; j++) {
-                    this._resetBufferLine(j);
-                }
-                this._terminal.updateRange(j);
-                break;
-            case 1:
-                j = this._terminal.buffer.y;
-                this._terminal.updateRange(j);
-                this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1, true);
-                if (this._terminal.buffer.x + 1 >= this._terminal.cols) {
-                    this._terminal.buffer.lines.get(j + 1).isWrapped = false;
-                }
-                while (j--) {
-                    this._resetBufferLine(j);
-                }
-                this._terminal.updateRange(0);
-                break;
-            case 2:
-                j = this._terminal.rows;
-                this._terminal.updateRange(j - 1);
-                while (j--) {
-                    this._resetBufferLine(j);
-                }
-                this._terminal.updateRange(0);
-                break;
-            case 3:
-                var scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows;
-                if (scrollBackSize > 0) {
-                    this._terminal.buffer.lines.trimStart(scrollBackSize);
-                    this._terminal.buffer.ybase = Math.max(this._terminal.buffer.ybase - scrollBackSize, 0);
-                    this._terminal.buffer.ydisp = Math.max(this._terminal.buffer.ydisp - scrollBackSize, 0);
-                    this._onScroll.fire(0);
-                }
-                break;
-        }
-    };
-    InputHandler.prototype.eraseInLine = function (params) {
-        switch (params[0]) {
-            case 0:
-                this._eraseInBufferLine(this._terminal.buffer.y, this._terminal.buffer.x, this._terminal.cols);
-                break;
-            case 1:
-                this._eraseInBufferLine(this._terminal.buffer.y, 0, this._terminal.buffer.x + 1);
-                break;
-            case 2:
-                this._eraseInBufferLine(this._terminal.buffer.y, 0, this._terminal.cols);
-                break;
-        }
-        this._terminal.updateRange(this._terminal.buffer.y);
-    };
-    InputHandler.prototype.insertLines = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        var buffer = this._terminal.buffer;
-        var row = buffer.y + buffer.ybase;
-        var scrollBottomRowsOffset = this._terminal.rows - 1 - buffer.scrollBottom;
-        var scrollBottomAbsolute = this._terminal.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1;
-        while (param--) {
-            buffer.lines.splice(scrollBottomAbsolute - 1, 1);
-            buffer.lines.splice(row, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));
-        }
-        this._terminal.updateRange(buffer.y);
-        this._terminal.updateRange(buffer.scrollBottom);
-    };
-    InputHandler.prototype.deleteLines = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        var buffer = this._terminal.buffer;
-        var row = buffer.y + buffer.ybase;
-        var j;
-        j = this._terminal.rows - 1 - buffer.scrollBottom;
-        j = this._terminal.rows - 1 + buffer.ybase - j;
-        while (param--) {
-            buffer.lines.splice(row, 1);
-            buffer.lines.splice(j, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));
-        }
-        this._terminal.updateRange(buffer.y);
-        this._terminal.updateRange(buffer.scrollBottom);
-    };
-    InputHandler.prototype.deleteChars = function (params) {
-        this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).deleteCells(this._terminal.buffer.x, params[0] || 1, this._terminal.buffer.getNullCell(this._terminal.eraseAttrData()));
-        this._terminal.updateRange(this._terminal.buffer.y);
-    };
-    InputHandler.prototype.scrollUp = function (params) {
-        var param = params[0] || 1;
-        var buffer = this._terminal.buffer;
-        while (param--) {
-            buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1);
-            buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(Buffer_1.DEFAULT_ATTR_DATA));
-        }
-        this._terminal.updateRange(buffer.scrollTop);
-        this._terminal.updateRange(buffer.scrollBottom);
-    };
-    InputHandler.prototype.scrollDown = function (params, collect) {
-        if (params.length < 2 && !collect) {
-            var param = params[0] || 1;
-            var buffer = this._terminal.buffer;
-            while (param--) {
-                buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1);
-                buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(Buffer_1.DEFAULT_ATTR_DATA));
-            }
-            this._terminal.updateRange(buffer.scrollTop);
-            this._terminal.updateRange(buffer.scrollBottom);
-        }
-    };
-    InputHandler.prototype.eraseChars = function (params) {
-        this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).replaceCells(this._terminal.buffer.x, this._terminal.buffer.x + (params[0] || 1), this._terminal.buffer.getNullCell(this._terminal.eraseAttrData()));
-    };
-    InputHandler.prototype.cursorBackwardTab = function (params) {
-        var param = params[0] || 1;
-        var buffer = this._terminal.buffer;
-        while (param--) {
-            buffer.x = buffer.prevStop();
-        }
-    };
-    InputHandler.prototype.charPosAbsolute = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.x = param - 1;
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x = this._terminal.cols - 1;
-        }
-    };
-    InputHandler.prototype.hPositionRelative = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.x += param;
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x = this._terminal.cols - 1;
-        }
-    };
-    InputHandler.prototype.repeatPrecedingCharacter = function (params) {
-        var buffer = this._terminal.buffer;
-        var line = buffer.lines.get(buffer.ybase + buffer.y);
-        line.loadCell(buffer.x - 1, this._workCell);
-        line.replaceCells(buffer.x, buffer.x + (params[0] || 1), (this._workCell.content !== undefined) ? this._workCell : buffer.getNullCell(Buffer_1.DEFAULT_ATTR_DATA));
-    };
-    InputHandler.prototype.sendDeviceAttributes = function (params, collect) {
-        if (params[0] > 0) {
-            return;
-        }
-        if (!collect) {
-            if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {
-                this._terminal.handler(EscapeSequences_1.C0.ESC + '[?1;2c');
-            }
-            else if (this._terminal.is('linux')) {
-                this._terminal.handler(EscapeSequences_1.C0.ESC + '[?6c');
-            }
-        }
-        else if (collect === '>') {
-            if (this._terminal.is('xterm')) {
-                this._terminal.handler(EscapeSequences_1.C0.ESC + '[>0;276;0c');
-            }
-            else if (this._terminal.is('rxvt-unicode')) {
-                this._terminal.handler(EscapeSequences_1.C0.ESC + '[>85;95;0c');
-            }
-            else if (this._terminal.is('linux')) {
-                this._terminal.handler(params[0] + 'c');
-            }
-            else if (this._terminal.is('screen')) {
-                this._terminal.handler(EscapeSequences_1.C0.ESC + '[>83;40003;0c');
-            }
-        }
-    };
-    InputHandler.prototype.linePosAbsolute = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.y = param - 1;
-        if (this._terminal.buffer.y >= this._terminal.rows) {
-            this._terminal.buffer.y = this._terminal.rows - 1;
-        }
-    };
-    InputHandler.prototype.vPositionRelative = function (params) {
-        var param = params[0];
-        if (param < 1) {
-            param = 1;
-        }
-        this._terminal.buffer.y += param;
-        if (this._terminal.buffer.y >= this._terminal.rows) {
-            this._terminal.buffer.y = this._terminal.rows - 1;
-        }
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x--;
-        }
-    };
-    InputHandler.prototype.hVPosition = function (params) {
-        if (params[0] < 1)
-            params[0] = 1;
-        if (params[1] < 1)
-            params[1] = 1;
-        this._terminal.buffer.y = params[0] - 1;
-        if (this._terminal.buffer.y >= this._terminal.rows) {
-            this._terminal.buffer.y = this._terminal.rows - 1;
-        }
-        this._terminal.buffer.x = params[1] - 1;
-        if (this._terminal.buffer.x >= this._terminal.cols) {
-            this._terminal.buffer.x = this._terminal.cols - 1;
-        }
-    };
-    InputHandler.prototype.tabClear = function (params) {
-        var param = params[0];
-        if (param <= 0) {
-            delete this._terminal.buffer.tabs[this._terminal.buffer.x];
-        }
-        else if (param === 3) {
-            this._terminal.buffer.tabs = {};
-        }
-    };
-    InputHandler.prototype.setMode = function (params, collect) {
-        if (params.length > 1) {
-            for (var i = 0; i < params.length; i++) {
-                this.setMode([params[i]]);
-            }
-            return;
-        }
-        if (!collect) {
-            switch (params[0]) {
-                case 4:
-                    this._terminal.insertMode = true;
-                    break;
-                case 20:
-                    break;
-            }
-        }
-        else if (collect === '?') {
-            switch (params[0]) {
-                case 1:
-                    this._terminal.applicationCursor = true;
-                    break;
-                case 2:
-                    this._terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);
-                    this._terminal.setgCharset(1, Charsets_1.DEFAULT_CHARSET);
-                    this._terminal.setgCharset(2, Charsets_1.DEFAULT_CHARSET);
-                    this._terminal.setgCharset(3, Charsets_1.DEFAULT_CHARSET);
-                    break;
-                case 3:
-                    this._terminal.savedCols = this._terminal.cols;
-                    this._terminal.resize(132, this._terminal.rows);
-                    break;
-                case 6:
-                    this._terminal.originMode = true;
-                    break;
-                case 7:
-                    this._terminal.wraparoundMode = true;
-                    break;
-                case 12:
-                    break;
-                case 66:
-                    this._terminal.log('Serial port requested application keypad.');
-                    this._terminal.applicationKeypad = true;
-                    if (this._terminal.viewport) {
-                        this._terminal.viewport.syncScrollArea();
-                    }
-                    break;
-                case 9:
-                case 1000:
-                case 1002:
-                case 1003:
-                    this._terminal.x10Mouse = params[0] === 9;
-                    this._terminal.vt200Mouse = params[0] === 1000;
-                    this._terminal.normalMouse = params[0] > 1000;
-                    this._terminal.mouseEvents = true;
-                    if (this._terminal.element) {
-                        this._terminal.element.classList.add('enable-mouse-events');
-                    }
-                    if (this._terminal.selectionManager) {
-                        this._terminal.selectionManager.disable();
-                    }
-                    this._terminal.log('Binding to mouse events.');
-                    break;
-                case 1004:
-                    this._terminal.sendFocus = true;
-                    break;
-                case 1005:
-                    this._terminal.utfMouse = true;
-                    break;
-                case 1006:
-                    this._terminal.sgrMouse = true;
-                    break;
-                case 1015:
-                    this._terminal.urxvtMouse = true;
-                    break;
-                case 25:
-                    this._terminal.cursorHidden = false;
-                    break;
-                case 1048:
-                    this.saveCursor(params);
-                    break;
-                case 1049:
-                    this.saveCursor(params);
-                case 47:
-                case 1047:
-                    this._terminal.buffers.activateAltBuffer(this._terminal.eraseAttrData());
-                    this._terminal.refresh(0, this._terminal.rows - 1);
-                    if (this._terminal.viewport) {
-                        this._terminal.viewport.syncScrollArea();
-                    }
-                    this._terminal.showCursor();
-                    break;
-                case 2004:
-                    this._terminal.bracketedPasteMode = true;
-                    break;
-            }
-        }
-    };
-    InputHandler.prototype.resetMode = function (params, collect) {
-        if (params.length > 1) {
-            for (var i = 0; i < params.length; i++) {
-                this.resetMode([params[i]]);
-            }
-            return;
-        }
-        if (!collect) {
-            switch (params[0]) {
-                case 4:
-                    this._terminal.insertMode = false;
-                    break;
-                case 20:
-                    break;
-            }
-        }
-        else if (collect === '?') {
-            switch (params[0]) {
-                case 1:
-                    this._terminal.applicationCursor = false;
-                    break;
-                case 3:
-                    if (this._terminal.cols === 132 && this._terminal.savedCols) {
-                        this._terminal.resize(this._terminal.savedCols, this._terminal.rows);
-                    }
-                    delete this._terminal.savedCols;
-                    break;
-                case 6:
-                    this._terminal.originMode = false;
-                    break;
-                case 7:
-                    this._terminal.wraparoundMode = false;
-                    break;
-                case 12:
-                    break;
-                case 66:
-                    this._terminal.log('Switching back to normal keypad.');
-                    this._terminal.applicationKeypad = false;
-                    if (this._terminal.viewport) {
-                        this._terminal.viewport.syncScrollArea();
-                    }
-                    break;
-                case 9:
-                case 1000:
-                case 1002:
-                case 1003:
-                    this._terminal.x10Mouse = false;
-                    this._terminal.vt200Mouse = false;
-                    this._terminal.normalMouse = false;
-                    this._terminal.mouseEvents = false;
-                    if (this._terminal.element) {
-                        this._terminal.element.classList.remove('enable-mouse-events');
-                    }
-                    if (this._terminal.selectionManager) {
-                        this._terminal.selectionManager.enable();
-                    }
-                    break;
-                case 1004:
-                    this._terminal.sendFocus = false;
-                    break;
-                case 1005:
-                    this._terminal.utfMouse = false;
-                    break;
-                case 1006:
-                    this._terminal.sgrMouse = false;
-                    break;
-                case 1015:
-                    this._terminal.urxvtMouse = false;
-                    break;
-                case 25:
-                    this._terminal.cursorHidden = true;
-                    break;
-                case 1048:
-                    this.restoreCursor(params);
-                    break;
-                case 1049:
-                case 47:
-                case 1047:
-                    this._terminal.buffers.activateNormalBuffer();
-                    if (params[0] === 1049) {
-                        this.restoreCursor(params);
-                    }
-                    this._terminal.refresh(0, this._terminal.rows - 1);
-                    if (this._terminal.viewport) {
-                        this._terminal.viewport.syncScrollArea();
-                    }
-                    this._terminal.showCursor();
-                    break;
-                case 2004:
-                    this._terminal.bracketedPasteMode = false;
-                    break;
-            }
-        }
-    };
-    InputHandler.prototype.charAttributes = function (params) {
-        if (params.length === 1 && params[0] === 0) {
-            this._terminal.curAttrData.fg = Buffer_1.DEFAULT_ATTR_DATA.fg;
-            this._terminal.curAttrData.bg = Buffer_1.DEFAULT_ATTR_DATA.bg;
-            return;
-        }
-        var l = params.length;
-        var p;
-        var attr = this._terminal.curAttrData;
-        for (var i = 0; i < l; i++) {
-            p = params[i];
-            if (p >= 30 && p <= 37) {
-                attr.fg &= ~(50331648 | 255);
-                attr.fg |= 16777216 | (p - 30);
-            }
-            else if (p >= 40 && p <= 47) {
-                attr.bg &= ~(50331648 | 255);
-                attr.bg |= 16777216 | (p - 40);
-            }
-            else if (p >= 90 && p <= 97) {
-                attr.fg &= ~(50331648 | 255);
-                attr.fg |= 16777216 | (p - 90) | 8;
-            }
-            else if (p >= 100 && p <= 107) {
-                attr.bg &= ~(50331648 | 255);
-                attr.bg |= 16777216 | (p - 100) | 8;
-            }
-            else if (p === 0) {
-                attr.fg = Buffer_1.DEFAULT_ATTR_DATA.fg;
-                attr.bg = Buffer_1.DEFAULT_ATTR_DATA.bg;
-            }
-            else if (p === 1) {
-                attr.fg |= 134217728;
-            }
-            else if (p === 3) {
-                attr.bg |= 67108864;
-            }
-            else if (p === 4) {
-                attr.fg |= 268435456;
-            }
-            else if (p === 5) {
-                attr.fg |= 536870912;
-            }
-            else if (p === 7) {
-                attr.fg |= 67108864;
-            }
-            else if (p === 8) {
-                attr.fg |= 1073741824;
-            }
-            else if (p === 2) {
-                attr.bg |= 134217728;
-            }
-            else if (p === 22) {
-                attr.fg &= ~134217728;
-                attr.bg &= ~134217728;
-            }
-            else if (p === 23) {
-                attr.bg &= ~67108864;
-            }
-            else if (p === 24) {
-                attr.fg &= ~268435456;
-            }
-            else if (p === 25) {
-                attr.fg &= ~536870912;
-            }
-            else if (p === 27) {
-                attr.fg &= ~67108864;
-            }
-            else if (p === 28) {
-                attr.fg &= ~1073741824;
-            }
-            else if (p === 39) {
-                attr.fg &= ~(50331648 | 16777215);
-                attr.fg |= Buffer_1.DEFAULT_ATTR_DATA.fg & (255 | 16777215);
-            }
-            else if (p === 49) {
-                attr.bg &= ~(50331648 | 16777215);
-                attr.bg |= Buffer_1.DEFAULT_ATTR_DATA.bg & (255 | 16777215);
-            }
-            else if (p === 38) {
-                if (params[i + 1] === 2) {
-                    i += 2;
-                    attr.fg |= 50331648;
-                    attr.fg &= ~16777215;
-                    attr.fg |= BufferLine_1.AttributeData.fromColorRGB([params[i], params[i + 1], params[i + 2]]);
-                    i += 2;
-                }
-                else if (params[i + 1] === 5) {
-                    i += 2;
-                    p = params[i] & 0xff;
-                    attr.fg &= ~255;
-                    attr.fg |= 33554432 | p;
-                }
-            }
-            else if (p === 48) {
-                if (params[i + 1] === 2) {
-                    i += 2;
-                    attr.bg |= 50331648;
-                    attr.bg &= ~16777215;
-                    attr.bg |= BufferLine_1.AttributeData.fromColorRGB([params[i], params[i + 1], params[i + 2]]);
-                    i += 2;
-                }
-                else if (params[i + 1] === 5) {
-                    i += 2;
-                    p = params[i] & 0xff;
-                    attr.bg &= ~255;
-                    attr.bg |= 33554432 | p;
-                }
-            }
-            else if (p === 100) {
-                attr.fg &= ~(50331648 | 16777215);
-                attr.fg |= Buffer_1.DEFAULT_ATTR_DATA.fg & (255 | 16777215);
-                attr.bg &= ~(50331648 | 16777215);
-                attr.bg |= Buffer_1.DEFAULT_ATTR_DATA.bg & (255 | 16777215);
-            }
-            else {
-                this._terminal.error('Unknown SGR attribute: %d.', p);
-            }
-        }
-    };
-    InputHandler.prototype.deviceStatus = function (params, collect) {
-        if (!collect) {
-            switch (params[0]) {
-                case 5:
-                    this._onData.fire(EscapeSequences_1.C0.ESC + "[0n");
-                    break;
-                case 6:
-                    var y = this._terminal.buffer.y + 1;
-                    var x = this._terminal.buffer.x + 1;
-                    this._onData.fire(EscapeSequences_1.C0.ESC + "[" + y + ";" + x + "R");
-                    break;
-            }
-        }
-        else if (collect === '?') {
-            switch (params[0]) {
-                case 6:
-                    var y = this._terminal.buffer.y + 1;
-                    var x = this._terminal.buffer.x + 1;
-                    this._onData.fire(EscapeSequences_1.C0.ESC + "[?" + y + ";" + x + "R");
-                    break;
-                case 15:
-                    break;
-                case 25:
-                    break;
-                case 26:
-                    break;
-                case 53:
-                    break;
-            }
-        }
-    };
-    InputHandler.prototype.softReset = function (params, collect) {
-        if (collect === '!') {
-            this._terminal.cursorHidden = false;
-            this._terminal.insertMode = false;
-            this._terminal.originMode = false;
-            this._terminal.wraparoundMode = true;
-            this._terminal.applicationKeypad = false;
-            if (this._terminal.viewport) {
-                this._terminal.viewport.syncScrollArea();
-            }
-            this._terminal.applicationCursor = false;
-            this._terminal.buffer.scrollTop = 0;
-            this._terminal.buffer.scrollBottom = this._terminal.rows - 1;
-            this._terminal.curAttrData = Buffer_1.DEFAULT_ATTR_DATA;
-            this._terminal.buffer.x = this._terminal.buffer.y = 0;
-            this._terminal.charset = null;
-            this._terminal.glevel = 0;
-            this._terminal.charsets = [null];
-        }
-    };
-    InputHandler.prototype.setCursorStyle = function (params, collect) {
-        if (collect === ' ') {
-            var param = params[0] < 1 ? 1 : params[0];
-            switch (param) {
-                case 1:
-                case 2:
-                    this._terminal.setOption('cursorStyle', 'block');
-                    break;
-                case 3:
-                case 4:
-                    this._terminal.setOption('cursorStyle', 'underline');
-                    break;
-                case 5:
-                case 6:
-                    this._terminal.setOption('cursorStyle', 'bar');
-                    break;
-            }
-            var isBlinking = param % 2 === 1;
-            this._terminal.setOption('cursorBlink', isBlinking);
-        }
-    };
-    InputHandler.prototype.setScrollRegion = function (params, collect) {
-        if (collect) {
-            return;
-        }
-        this._terminal.buffer.scrollTop = (params[0] || 1) - 1;
-        this._terminal.buffer.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;
-        this._terminal.buffer.x = 0;
-        this._terminal.buffer.y = 0;
-    };
-    InputHandler.prototype.saveCursor = function (params) {
-        this._terminal.buffer.savedX = this._terminal.buffer.x;
-        this._terminal.buffer.savedY = this._terminal.buffer.y;
-        this._terminal.buffer.savedCurAttrData.fg = this._terminal.curAttrData.fg;
-        this._terminal.buffer.savedCurAttrData.bg = this._terminal.curAttrData.bg;
-    };
-    InputHandler.prototype.restoreCursor = function (params) {
-        this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
-        this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
-        this._terminal.curAttrData.fg = this._terminal.buffer.savedCurAttrData.fg;
-        this._terminal.curAttrData.bg = this._terminal.buffer.savedCurAttrData.bg;
-    };
-    InputHandler.prototype.setTitle = function (data) {
-        this._terminal.handleTitle(data);
-    };
-    InputHandler.prototype.nextLine = function () {
-        this._terminal.buffer.x = 0;
-        this.index();
-    };
-    InputHandler.prototype.keypadApplicationMode = function () {
-        this._terminal.log('Serial port requested application keypad.');
-        this._terminal.applicationKeypad = true;
-        if (this._terminal.viewport) {
-            this._terminal.viewport.syncScrollArea();
-        }
-    };
-    InputHandler.prototype.keypadNumericMode = function () {
-        this._terminal.log('Switching back to normal keypad.');
-        this._terminal.applicationKeypad = false;
-        if (this._terminal.viewport) {
-            this._terminal.viewport.syncScrollArea();
-        }
-    };
-    InputHandler.prototype.selectDefaultCharset = function () {
-        this._terminal.setgLevel(0);
-        this._terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);
-    };
-    InputHandler.prototype.selectCharset = function (collectAndFlag) {
-        if (collectAndFlag.length !== 2) {
-            this.selectDefaultCharset();
-            return;
-        }
-        if (collectAndFlag[0] === '/') {
-            return;
-        }
-        this._terminal.setgCharset(GLEVEL[collectAndFlag[0]], Charsets_1.CHARSETS[collectAndFlag[1]] || Charsets_1.DEFAULT_CHARSET);
-        return;
-    };
-    InputHandler.prototype.index = function () {
-        this._terminal.index();
-    };
-    InputHandler.prototype.tabSet = function () {
-        this._terminal.tabSet();
-    };
-    InputHandler.prototype.reverseIndex = function () {
-        this._terminal.reverseIndex();
-    };
-    InputHandler.prototype.reset = function () {
-        this._parser.reset();
-        this._terminal.reset();
-    };
-    InputHandler.prototype.setgLevel = function (level) {
-        this._terminal.setgLevel(level);
-    };
-    return InputHandler;
-}(Lifecycle_1.Disposable));
-exports.InputHandler = InputHandler;
-
-},{"./Buffer":2,"./BufferLine":3,"./CharWidth":7,"./EscapeSequenceParser":10,"./common/EventEmitter2":25,"./common/Lifecycle":26,"./common/TypedArrayUtils":28,"./common/data/EscapeSequences":29,"./core/data/Charsets":30,"./core/input/TextDecoder":32}],12:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var MouseZoneManager_1 = require("./MouseZoneManager");
-var CharWidth_1 = require("./CharWidth");
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var Linkifier = (function () {
-    function Linkifier(_terminal) {
-        this._terminal = _terminal;
-        this._linkMatchers = [];
-        this._nextLinkMatcherId = 0;
-        this._onLinkHover = new EventEmitter2_1.EventEmitter2();
-        this._onLinkLeave = new EventEmitter2_1.EventEmitter2();
-        this._onLinkTooltip = new EventEmitter2_1.EventEmitter2();
-        this._rowsToLinkify = {
-            start: null,
-            end: null
-        };
-    }
-    Object.defineProperty(Linkifier.prototype, "onLinkHover", {
-        get: function () { return this._onLinkHover.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Linkifier.prototype, "onLinkLeave", {
-        get: function () { return this._onLinkLeave.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Linkifier.prototype, "onLinkTooltip", {
-        get: function () { return this._onLinkTooltip.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Linkifier.prototype.attachToDom = function (mouseZoneManager) {
-        this._mouseZoneManager = mouseZoneManager;
-    };
-    Linkifier.prototype.linkifyRows = function (start, end) {
-        var _this = this;
-        if (!this._mouseZoneManager) {
-            return;
-        }
-        if (this._rowsToLinkify.start === null) {
-            this._rowsToLinkify.start = start;
-            this._rowsToLinkify.end = end;
-        }
-        else {
-            this._rowsToLinkify.start = Math.min(this._rowsToLinkify.start, start);
-            this._rowsToLinkify.end = Math.max(this._rowsToLinkify.end, end);
-        }
-        this._mouseZoneManager.clearAll(start, end);
-        if (this._rowsTimeoutId) {
-            clearTimeout(this._rowsTimeoutId);
-        }
-        this._rowsTimeoutId = setTimeout(function () { return _this._linkifyRows(); }, Linkifier.TIME_BEFORE_LINKIFY);
-    };
-    Linkifier.prototype._linkifyRows = function () {
-        this._rowsTimeoutId = null;
-        var buffer = this._terminal.buffer;
-        var absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;
-        if (absoluteRowIndexStart >= buffer.lines.length) {
-            return;
-        }
-        var absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._terminal.rows) + 1;
-        var overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols);
-        var iterator = this._terminal.buffer.iterator(false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
-        while (iterator.hasNext()) {
-            var lineData = iterator.next();
-            for (var i = 0; i < this._linkMatchers.length; i++) {
-                this._doLinkifyRow(lineData.range.first, lineData.content, this._linkMatchers[i]);
-            }
-        }
-        this._rowsToLinkify.start = null;
-        this._rowsToLinkify.end = null;
-    };
-    Linkifier.prototype.registerLinkMatcher = function (regex, handler, options) {
-        if (options === void 0) { options = {}; }
-        if (!handler) {
-            throw new Error('handler must be defined');
-        }
-        var matcher = {
-            id: this._nextLinkMatcherId++,
-            regex: regex,
-            handler: handler,
-            matchIndex: options.matchIndex,
-            validationCallback: options.validationCallback,
-            hoverTooltipCallback: options.tooltipCallback,
-            hoverLeaveCallback: options.leaveCallback,
-            willLinkActivate: options.willLinkActivate,
-            priority: options.priority || 0
-        };
-        this._addLinkMatcherToList(matcher);
-        return matcher.id;
-    };
-    Linkifier.prototype._addLinkMatcherToList = function (matcher) {
-        if (this._linkMatchers.length === 0) {
-            this._linkMatchers.push(matcher);
-            return;
-        }
-        for (var i = this._linkMatchers.length - 1; i >= 0; i--) {
-            if (matcher.priority <= this._linkMatchers[i].priority) {
-                this._linkMatchers.splice(i + 1, 0, matcher);
-                return;
-            }
-        }
-        this._linkMatchers.splice(0, 0, matcher);
-    };
-    Linkifier.prototype.deregisterLinkMatcher = function (matcherId) {
-        for (var i = 0; i < this._linkMatchers.length; i++) {
-            if (this._linkMatchers[i].id === matcherId) {
-                this._linkMatchers.splice(i, 1);
-                return true;
-            }
-        }
-        return false;
-    };
-    Linkifier.prototype._doLinkifyRow = function (rowIndex, text, matcher) {
-        var _this = this;
-        var rex = new RegExp(matcher.regex.source, matcher.regex.flags + 'g');
-        var match;
-        var stringIndex = -1;
-        var _loop_1 = function () {
-            var uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
-            if (!uri) {
-                if (this_1._terminal.debug) {
-                    console.log({ match: match, matcher: matcher });
-                    throw new Error('match found without corresponding matchIndex');
-                }
-                return "break";
-            }
-            stringIndex = text.indexOf(uri, stringIndex + 1);
-            rex.lastIndex = stringIndex + uri.length;
-            if (stringIndex < 0) {
-                return "break";
-            }
-            var bufferIndex = this_1._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex);
-            if (bufferIndex[0] < 0) {
-                return "break";
-            }
-            var line = this_1._terminal.buffer.lines.get(bufferIndex[0]);
-            var attr = line.getFg(bufferIndex[1]);
-            var fg;
-            if (attr) {
-                fg = (attr >> 9) & 0x1ff;
-            }
-            if (matcher.validationCallback) {
-                matcher.validationCallback(uri, function (isValid) {
-                    if (_this._rowsTimeoutId) {
-                        return;
-                    }
-                    if (isValid) {
-                        _this._addLink(bufferIndex[1], bufferIndex[0] - _this._terminal.buffer.ydisp, uri, matcher, fg);
-                    }
-                });
-            }
-            else {
-                this_1._addLink(bufferIndex[1], bufferIndex[0] - this_1._terminal.buffer.ydisp, uri, matcher, fg);
-            }
-        };
-        var this_1 = this;
-        while ((match = rex.exec(text)) !== null) {
-            var state_1 = _loop_1();
-            if (state_1 === "break")
-                break;
-        }
-    };
-    Linkifier.prototype._addLink = function (x, y, uri, matcher, fg) {
-        var _this = this;
-        var width = CharWidth_1.getStringCellWidth(uri);
-        var x1 = x % this._terminal.cols;
-        var y1 = y + Math.floor(x / this._terminal.cols);
-        var x2 = (x1 + width) % this._terminal.cols;
-        var y2 = y1 + Math.floor((x1 + width) / this._terminal.cols);
-        if (x2 === 0) {
-            x2 = this._terminal.cols;
-            y2--;
-        }
-        this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x1 + 1, y1 + 1, x2 + 1, y2 + 1, function (e) {
-            if (matcher.handler) {
-                return matcher.handler(e, uri);
-            }
-            window.open(uri, '_blank');
-        }, function () {
-            _this._onLinkHover.fire(_this._createLinkHoverEvent(x1, y1, x2, y2, fg));
-            _this._terminal.element.classList.add('xterm-cursor-pointer');
-        }, function (e) {
-            _this._onLinkTooltip.fire(_this._createLinkHoverEvent(x1, y1, x2, y2, fg));
-            if (matcher.hoverTooltipCallback) {
-                matcher.hoverTooltipCallback(e, uri);
-            }
-        }, function () {
-            _this._onLinkLeave.fire(_this._createLinkHoverEvent(x1, y1, x2, y2, fg));
-            _this._terminal.element.classList.remove('xterm-cursor-pointer');
-            if (matcher.hoverLeaveCallback) {
-                matcher.hoverLeaveCallback();
-            }
-        }, function (e) {
-            if (matcher.willLinkActivate) {
-                return matcher.willLinkActivate(e, uri);
-            }
-            return true;
-        }));
-    };
-    Linkifier.prototype._createLinkHoverEvent = function (x1, y1, x2, y2, fg) {
-        return { x1: x1, y1: y1, x2: x2, y2: y2, cols: this._terminal.cols, fg: fg };
-    };
-    Linkifier.TIME_BEFORE_LINKIFY = 200;
-    Linkifier.OVERSCAN_CHAR_LIMIT = 2000;
-    return Linkifier;
-}());
-exports.Linkifier = Linkifier;
-
-},{"./CharWidth":7,"./MouseZoneManager":14,"./common/EventEmitter2":25}],13:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var MouseHelper = (function () {
-    function MouseHelper(_renderer) {
-        this._renderer = _renderer;
-    }
-    MouseHelper.prototype.setRenderer = function (renderer) {
-        this._renderer = renderer;
-    };
-    MouseHelper.getCoordsRelativeToElement = function (event, element) {
-        var rect = element.getBoundingClientRect();
-        return [event.clientX - rect.left, event.clientY - rect.top];
-    };
-    MouseHelper.prototype.getCoords = function (event, element, charMeasure, colCount, rowCount, isSelection) {
-        if (!charMeasure.width || !charMeasure.height) {
-            return null;
-        }
-        var coords = MouseHelper.getCoordsRelativeToElement(event, element);
-        if (!coords) {
-            return null;
-        }
-        coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);
-        coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);
-        coords[0] = Math.min(Math.max(coords[0], 1), colCount + (isSelection ? 1 : 0));
-        coords[1] = Math.min(Math.max(coords[1], 1), rowCount);
-        return coords;
-    };
-    MouseHelper.prototype.getRawByteCoords = function (event, element, charMeasure, colCount, rowCount) {
-        var coords = this.getCoords(event, element, charMeasure, colCount, rowCount);
-        var x = coords[0];
-        var y = coords[1];
-        x += 32;
-        y += 32;
-        return { x: x, y: y };
-    };
-    return MouseHelper;
-}());
-exports.MouseHelper = MouseHelper;
-
-},{}],14:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Lifecycle_1 = require("./common/Lifecycle");
-var Lifecycle_2 = require("./ui/Lifecycle");
-var HOVER_DURATION = 500;
-var MouseZoneManager = (function (_super) {
-    __extends(MouseZoneManager, _super);
-    function MouseZoneManager(_terminal) {
-        var _this = _super.call(this) || this;
-        _this._terminal = _terminal;
-        _this._zones = [];
-        _this._areZonesActive = false;
-        _this._tooltipTimeout = null;
-        _this._currentZone = null;
-        _this._lastHoverCoords = [null, null];
-        _this.register(Lifecycle_2.addDisposableDomListener(_this._terminal.element, 'mousedown', function (e) { return _this._onMouseDown(e); }));
-        _this._mouseMoveListener = function (e) { return _this._onMouseMove(e); };
-        _this._mouseLeaveListener = function (e) { return _this._onMouseLeave(e); };
-        _this._clickListener = function (e) { return _this._onClick(e); };
-        return _this;
-    }
-    MouseZoneManager.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        this._deactivate();
-    };
-    MouseZoneManager.prototype.add = function (zone) {
-        this._zones.push(zone);
-        if (this._zones.length === 1) {
-            this._activate();
-        }
-    };
-    MouseZoneManager.prototype.clearAll = function (start, end) {
-        if (this._zones.length === 0) {
-            return;
-        }
-        if (!end) {
-            start = 0;
-            end = this._terminal.rows - 1;
-        }
-        for (var i = 0; i < this._zones.length; i++) {
-            var zone = this._zones[i];
-            if ((zone.y1 > start && zone.y1 <= end + 1) ||
-                (zone.y2 > start && zone.y2 <= end + 1) ||
-                (zone.y1 < start && zone.y2 > end + 1)) {
-                if (this._currentZone && this._currentZone === zone) {
-                    this._currentZone.leaveCallback();
-                    this._currentZone = null;
-                }
-                this._zones.splice(i--, 1);
-            }
-        }
-        if (this._zones.length === 0) {
-            this._deactivate();
-        }
-    };
-    MouseZoneManager.prototype._activate = function () {
-        if (!this._areZonesActive) {
-            this._areZonesActive = true;
-            this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);
-            this._terminal.element.addEventListener('mouseleave', this._mouseLeaveListener);
-            this._terminal.element.addEventListener('click', this._clickListener);
-        }
-    };
-    MouseZoneManager.prototype._deactivate = function () {
-        if (this._areZonesActive) {
-            this._areZonesActive = false;
-            this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);
-            this._terminal.element.removeEventListener('mouseleave', this._mouseLeaveListener);
-            this._terminal.element.removeEventListener('click', this._clickListener);
-        }
-    };
-    MouseZoneManager.prototype._onMouseMove = function (e) {
-        if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {
-            this._onHover(e);
-            this._lastHoverCoords = [e.pageX, e.pageY];
-        }
-    };
-    MouseZoneManager.prototype._onHover = function (e) {
-        var _this = this;
-        var zone = this._findZoneEventAt(e);
-        if (zone === this._currentZone) {
-            return;
-        }
-        if (this._currentZone) {
-            this._currentZone.leaveCallback();
-            this._currentZone = null;
-            if (this._tooltipTimeout) {
-                clearTimeout(this._tooltipTimeout);
-            }
-        }
-        if (!zone) {
-            return;
-        }
-        this._currentZone = zone;
-        if (zone.hoverCallback) {
-            zone.hoverCallback(e);
-        }
-        this._tooltipTimeout = setTimeout(function () { return _this._onTooltip(e); }, HOVER_DURATION);
-    };
-    MouseZoneManager.prototype._onTooltip = function (e) {
-        this._tooltipTimeout = null;
-        var zone = this._findZoneEventAt(e);
-        if (zone && zone.tooltipCallback) {
-            zone.tooltipCallback(e);
-        }
-    };
-    MouseZoneManager.prototype._onMouseDown = function (e) {
-        this._initialSelectionLength = this._terminal.getSelection().length;
-        if (!this._areZonesActive) {
-            return;
-        }
-        var zone = this._findZoneEventAt(e);
-        if (zone) {
-            if (zone.willLinkActivate(e)) {
-                e.preventDefault();
-                e.stopImmediatePropagation();
-            }
-        }
-    };
-    MouseZoneManager.prototype._onMouseLeave = function (e) {
-        if (this._currentZone) {
-            this._currentZone.leaveCallback();
-            this._currentZone = null;
-            if (this._tooltipTimeout) {
-                clearTimeout(this._tooltipTimeout);
-            }
-        }
-    };
-    MouseZoneManager.prototype._onClick = function (e) {
-        var zone = this._findZoneEventAt(e);
-        var currentSelectionLength = this._terminal.getSelection().length;
-        if (zone && currentSelectionLength === this._initialSelectionLength) {
-            zone.clickCallback(e);
-            e.preventDefault();
-            e.stopImmediatePropagation();
-        }
-    };
-    MouseZoneManager.prototype._findZoneEventAt = function (e) {
-        var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows);
-        if (!coords) {
-            return null;
-        }
-        var x = coords[0];
-        var y = coords[1];
-        for (var i = 0; i < this._zones.length; i++) {
-            var zone = this._zones[i];
-            if (zone.y1 === zone.y2) {
-                if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {
-                    return zone;
-                }
-            }
-            else {
-                if ((y === zone.y1 && x >= zone.x1) ||
-                    (y === zone.y2 && x < zone.x2) ||
-                    (y > zone.y1 && y < zone.y2)) {
-                    return zone;
-                }
-            }
-        }
-        return null;
-    };
-    return MouseZoneManager;
-}(Lifecycle_1.Disposable));
-exports.MouseZoneManager = MouseZoneManager;
-var MouseZone = (function () {
-    function MouseZone(x1, y1, x2, y2, clickCallback, hoverCallback, tooltipCallback, leaveCallback, willLinkActivate) {
-        this.x1 = x1;
-        this.y1 = y1;
-        this.x2 = x2;
-        this.y2 = y2;
-        this.clickCallback = clickCallback;
-        this.hoverCallback = hoverCallback;
-        this.tooltipCallback = tooltipCallback;
-        this.leaveCallback = leaveCallback;
-        this.willLinkActivate = willLinkActivate;
-    }
-    return MouseZone;
-}());
-exports.MouseZone = MouseZone;
-
-},{"./common/Lifecycle":26,"./ui/Lifecycle":55}],15:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var MouseHelper_1 = require("./MouseHelper");
-var Browser = require("./common/Platform");
-var SelectionModel_1 = require("./SelectionModel");
-var AltClickHandler_1 = require("./handlers/AltClickHandler");
-var BufferLine_1 = require("./BufferLine");
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var DRAG_SCROLL_MAX_THRESHOLD = 50;
-var DRAG_SCROLL_MAX_SPEED = 15;
-var DRAG_SCROLL_INTERVAL = 50;
-var ALT_CLICK_MOVE_CURSOR_TIME = 500;
-var WORD_SEPARATORS = ' ()[]{}\'"';
-var NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);
-var ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');
-var SelectionManager = (function () {
-    function SelectionManager(_terminal, _charMeasure) {
-        this._terminal = _terminal;
-        this._charMeasure = _charMeasure;
-        this._enabled = true;
-        this._workCell = new BufferLine_1.CellData();
-        this._onLinuxMouseSelection = new EventEmitter2_1.EventEmitter2();
-        this._onRedrawRequest = new EventEmitter2_1.EventEmitter2();
-        this._onSelectionChange = new EventEmitter2_1.EventEmitter2();
-        this._initListeners();
-        this.enable();
-        this._model = new SelectionModel_1.SelectionModel(_terminal);
-        this._activeSelectionMode = 0;
-    }
-    Object.defineProperty(SelectionManager.prototype, "onLinuxMouseSelection", {
-        get: function () { return this._onLinuxMouseSelection.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(SelectionManager.prototype, "onRedrawRequest", {
-        get: function () { return this._onRedrawRequest.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(SelectionManager.prototype, "onSelectionChange", {
-        get: function () { return this._onSelectionChange.event; },
-        enumerable: true,
-        configurable: true
-    });
-    SelectionManager.prototype.dispose = function () {
-        this._removeMouseDownListeners();
-    };
-    Object.defineProperty(SelectionManager.prototype, "_buffer", {
-        get: function () {
-            return this._terminal.buffers.active;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    SelectionManager.prototype._initListeners = function () {
-        var _this = this;
-        this._mouseMoveListener = function (event) { return _this._onMouseMove(event); };
-        this._mouseUpListener = function (event) { return _this._onMouseUp(event); };
-        this.initBuffersListeners();
-    };
-    SelectionManager.prototype.initBuffersListeners = function () {
-        var _this = this;
-        this._trimListener = this._terminal.buffer.lines.onTrim(function (amount) { return _this._onTrim(amount); });
-        this._terminal.buffers.onBufferActivate(function (e) { return _this._onBufferActivate(e); });
-    };
-    SelectionManager.prototype.disable = function () {
-        this.clearSelection();
-        this._enabled = false;
-    };
-    SelectionManager.prototype.enable = function () {
-        this._enabled = true;
-    };
-    Object.defineProperty(SelectionManager.prototype, "selectionStart", {
-        get: function () { return this._model.finalSelectionStart; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(SelectionManager.prototype, "selectionEnd", {
-        get: function () { return this._model.finalSelectionEnd; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(SelectionManager.prototype, "hasSelection", {
-        get: function () {
-            var start = this._model.finalSelectionStart;
-            var end = this._model.finalSelectionEnd;
-            if (!start || !end) {
-                return false;
-            }
-            return start[0] !== end[0] || start[1] !== end[1];
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(SelectionManager.prototype, "selectionText", {
-        get: function () {
-            var start = this._model.finalSelectionStart;
-            var end = this._model.finalSelectionEnd;
-            if (!start || !end) {
-                return '';
-            }
-            var result = [];
-            if (this._activeSelectionMode === 3) {
-                if (start[0] === end[0]) {
-                    return '';
-                }
-                for (var i = start[1]; i <= end[1]; i++) {
-                    var lineText = this._buffer.translateBufferLineToString(i, true, start[0], end[0]);
-                    result.push(lineText);
-                }
-            }
-            else {
-                var startRowEndCol = start[1] === end[1] ? end[0] : undefined;
-                result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));
-                for (var i = start[1] + 1; i <= end[1] - 1; i++) {
-                    var bufferLine = this._buffer.lines.get(i);
-                    var lineText = this._buffer.translateBufferLineToString(i, true);
-                    if (bufferLine.isWrapped) {
-                        result[result.length - 1] += lineText;
-                    }
-                    else {
-                        result.push(lineText);
-                    }
-                }
-                if (start[1] !== end[1]) {
-                    var bufferLine = this._buffer.lines.get(end[1]);
-                    var lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);
-                    if (bufferLine.isWrapped) {
-                        result[result.length - 1] += lineText;
-                    }
-                    else {
-                        result.push(lineText);
-                    }
-                }
-            }
-            var formattedResult = result.map(function (line) {
-                return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');
-            }).join(Browser.isMSWindows ? '\r\n' : '\n');
-            return formattedResult;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    SelectionManager.prototype.clearSelection = function () {
-        this._model.clearSelection();
-        this._removeMouseDownListeners();
-        this.refresh();
-    };
-    SelectionManager.prototype.refresh = function (isLinuxMouseSelection) {
-        var _this = this;
-        if (!this._refreshAnimationFrame) {
-            this._refreshAnimationFrame = window.requestAnimationFrame(function () { return _this._refresh(); });
-        }
-        if (Browser.isLinux && isLinuxMouseSelection) {
-            var selectionText = this.selectionText;
-            if (selectionText.length) {
-                this._onLinuxMouseSelection.fire(this.selectionText);
-            }
-        }
-    };
-    SelectionManager.prototype._refresh = function () {
-        this._refreshAnimationFrame = null;
-        this._onRedrawRequest.fire({
-            start: this._model.finalSelectionStart,
-            end: this._model.finalSelectionEnd,
-            columnSelectMode: this._activeSelectionMode === 3
-        });
-    };
-    SelectionManager.prototype.isClickInSelection = function (event) {
-        var coords = this._getMouseBufferCoords(event);
-        var start = this._model.finalSelectionStart;
-        var end = this._model.finalSelectionEnd;
-        if (!start || !end) {
-            return false;
-        }
-        return this._areCoordsInSelection(coords, start, end);
-    };
-    SelectionManager.prototype._areCoordsInSelection = function (coords, start, end) {
-        return (coords[1] > start[1] && coords[1] < end[1]) ||
-            (start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||
-            (start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||
-            (start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);
-    };
-    SelectionManager.prototype.selectWordAtCursor = function (event) {
-        var coords = this._getMouseBufferCoords(event);
-        if (coords) {
-            this._selectWordAt(coords, false);
-            this._model.selectionEnd = null;
-            this.refresh(true);
-        }
-    };
-    SelectionManager.prototype.selectAll = function () {
-        this._model.isSelectAllActive = true;
-        this.refresh();
-        this._onSelectionChange.fire();
-    };
-    SelectionManager.prototype.selectLines = function (start, end) {
-        this._model.clearSelection();
-        start = Math.max(start, 0);
-        end = Math.min(end, this._terminal.buffer.lines.length - 1);
-        this._model.selectionStart = [0, start];
-        this._model.selectionEnd = [this._terminal.cols, end];
-        this.refresh();
-        this._onSelectionChange.fire();
-    };
-    SelectionManager.prototype._onTrim = function (amount) {
-        var needsRefresh = this._model.onTrim(amount);
-        if (needsRefresh) {
-            this.refresh();
-        }
-    };
-    SelectionManager.prototype._getMouseBufferCoords = function (event) {
-        var coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.cols, this._terminal.rows, true);
-        if (!coords) {
-            return null;
-        }
-        coords[0]--;
-        coords[1]--;
-        coords[1] += this._terminal.buffer.ydisp;
-        return coords;
-    };
-    SelectionManager.prototype._getMouseEventScrollAmount = function (event) {
-        var offset = MouseHelper_1.MouseHelper.getCoordsRelativeToElement(event, this._terminal.screenElement)[1];
-        var terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);
-        if (offset >= 0 && offset <= terminalHeight) {
-            return 0;
-        }
-        if (offset > terminalHeight) {
-            offset -= terminalHeight;
-        }
-        offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);
-        offset /= DRAG_SCROLL_MAX_THRESHOLD;
-        return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));
-    };
-    SelectionManager.prototype.shouldForceSelection = function (event) {
-        if (Browser.isMac) {
-            return event.altKey && this._terminal.options.macOptionClickForcesSelection;
-        }
-        return event.shiftKey;
-    };
-    SelectionManager.prototype.onMouseDown = function (event) {
-        this._mouseDownTimeStamp = event.timeStamp;
-        if (event.button === 2 && this.hasSelection) {
-            return;
-        }
-        if (event.button !== 0) {
-            return;
-        }
-        if (!this._enabled) {
-            if (!this.shouldForceSelection(event)) {
-                return;
-            }
-            event.stopPropagation();
-        }
-        event.preventDefault();
-        this._dragScrollAmount = 0;
-        if (this._enabled && event.shiftKey) {
-            this._onIncrementalClick(event);
-        }
-        else {
-            if (event.detail === 1) {
-                this._onSingleClick(event);
-            }
-            else if (event.detail === 2) {
-                this._onDoubleClick(event);
-            }
-            else if (event.detail === 3) {
-                this._onTripleClick(event);
-            }
-        }
-        this._addMouseDownListeners();
-        this.refresh(true);
-    };
-    SelectionManager.prototype._addMouseDownListeners = function () {
-        var _this = this;
-        this._terminal.element.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);
-        this._terminal.element.ownerDocument.addEventListener('mouseup', this._mouseUpListener);
-        this._dragScrollIntervalTimer = setInterval(function () { return _this._dragScroll(); }, DRAG_SCROLL_INTERVAL);
-    };
-    SelectionManager.prototype._removeMouseDownListeners = function () {
-        if (this._terminal.element.ownerDocument) {
-            this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);
-            this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);
-        }
-        clearInterval(this._dragScrollIntervalTimer);
-        this._dragScrollIntervalTimer = null;
-    };
-    SelectionManager.prototype._onIncrementalClick = function (event) {
-        if (this._model.selectionStart) {
-            this._model.selectionEnd = this._getMouseBufferCoords(event);
-        }
-    };
-    SelectionManager.prototype._onSingleClick = function (event) {
-        this._model.selectionStartLength = 0;
-        this._model.isSelectAllActive = false;
-        this._activeSelectionMode = this.shouldColumnSelect(event) ? 3 : 0;
-        this._model.selectionStart = this._getMouseBufferCoords(event);
-        if (!this._model.selectionStart) {
-            return;
-        }
-        this._model.selectionEnd = null;
-        var line = this._buffer.lines.get(this._model.selectionStart[1]);
-        if (!line) {
-            return;
-        }
-        if (line.length >= this._model.selectionStart[0]) {
-            return;
-        }
-        if (line.hasWidth(this._model.selectionStart[0]) === 0) {
-            this._model.selectionStart[0]++;
-        }
-    };
-    SelectionManager.prototype._onDoubleClick = function (event) {
-        var coords = this._getMouseBufferCoords(event);
-        if (coords) {
-            this._activeSelectionMode = 1;
-            this._selectWordAt(coords, true);
-        }
-    };
-    SelectionManager.prototype._onTripleClick = function (event) {
-        var coords = this._getMouseBufferCoords(event);
-        if (coords) {
-            this._activeSelectionMode = 2;
-            this._selectLineAt(coords[1]);
-        }
-    };
-    SelectionManager.prototype.shouldColumnSelect = function (event) {
-        return event.altKey && !(Browser.isMac && this._terminal.options.macOptionClickForcesSelection);
-    };
-    SelectionManager.prototype._onMouseMove = function (event) {
-        event.stopImmediatePropagation();
-        var previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;
-        this._model.selectionEnd = this._getMouseBufferCoords(event);
-        if (!this._model.selectionEnd) {
-            this.refresh(true);
-            return;
-        }
-        if (this._activeSelectionMode === 2) {
-            if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {
-                this._model.selectionEnd[0] = 0;
-            }
-            else {
-                this._model.selectionEnd[0] = this._terminal.cols;
-            }
-        }
-        else if (this._activeSelectionMode === 1) {
-            this._selectToWordAt(this._model.selectionEnd);
-        }
-        this._dragScrollAmount = this._getMouseEventScrollAmount(event);
-        if (this._activeSelectionMode !== 3) {
-            if (this._dragScrollAmount > 0) {
-                this._model.selectionEnd[0] = this._terminal.cols;
-            }
-            else if (this._dragScrollAmount < 0) {
-                this._model.selectionEnd[0] = 0;
-            }
-        }
-        if (this._model.selectionEnd[1] < this._buffer.lines.length) {
-            if (this._buffer.lines.get(this._model.selectionEnd[1]).hasWidth(this._model.selectionEnd[0]) === 0) {
-                this._model.selectionEnd[0]++;
-            }
-        }
-        if (!previousSelectionEnd ||
-            previousSelectionEnd[0] !== this._model.selectionEnd[0] ||
-            previousSelectionEnd[1] !== this._model.selectionEnd[1]) {
-            this.refresh(true);
-        }
-    };
-    SelectionManager.prototype._dragScroll = function () {
-        if (this._dragScrollAmount) {
-            this._terminal.scrollLines(this._dragScrollAmount, false);
-            if (this._dragScrollAmount > 0) {
-                if (this._activeSelectionMode !== 3) {
-                    this._model.selectionEnd[0] = this._terminal.cols;
-                }
-                this._model.selectionEnd[1] = Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1);
-            }
-            else {
-                if (this._activeSelectionMode !== 3) {
-                    this._model.selectionEnd[0] = 0;
-                }
-                this._model.selectionEnd[1] = this._terminal.buffer.ydisp;
-            }
-            this.refresh();
-        }
-    };
-    SelectionManager.prototype._onMouseUp = function (event) {
-        var timeElapsed = event.timeStamp - this._mouseDownTimeStamp;
-        this._removeMouseDownListeners();
-        if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME) {
-            (new AltClickHandler_1.AltClickHandler(event, this._terminal)).move();
-        }
-        else if (this.hasSelection) {
-            this._onSelectionChange.fire();
-        }
-    };
-    SelectionManager.prototype._onBufferActivate = function (e) {
-        var _this = this;
-        this.clearSelection();
-        if (this._trimListener) {
-            this._trimListener.dispose();
-        }
-        this._trimListener = e.activeBuffer.lines.onTrim(function (amount) { return _this._onTrim(amount); });
-    };
-    SelectionManager.prototype._convertViewportColToCharacterIndex = function (bufferLine, coords) {
-        var charIndex = coords[0];
-        for (var i = 0; coords[0] >= i; i++) {
-            var length_1 = bufferLine.loadCell(i, this._workCell).getChars().length;
-            if (this._workCell.getWidth() === 0) {
-                charIndex--;
-            }
-            else if (length_1 > 1 && coords[0] !== i) {
-                charIndex += length_1 - 1;
-            }
-        }
-        return charIndex;
-    };
-    SelectionManager.prototype.setSelection = function (col, row, length) {
-        this._model.clearSelection();
-        this._removeMouseDownListeners();
-        this._model.selectionStart = [col, row];
-        this._model.selectionStartLength = length;
-        this.refresh();
-    };
-    SelectionManager.prototype._getWordAt = function (coords, allowWhitespaceOnlySelection, followWrappedLinesAbove, followWrappedLinesBelow) {
-        if (followWrappedLinesAbove === void 0) { followWrappedLinesAbove = true; }
-        if (followWrappedLinesBelow === void 0) { followWrappedLinesBelow = true; }
-        if (coords[0] >= this._terminal.cols) {
-            return null;
-        }
-        var bufferLine = this._buffer.lines.get(coords[1]);
-        if (!bufferLine) {
-            return null;
-        }
-        var line = this._buffer.translateBufferLineToString(coords[1], false);
-        var startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);
-        var endIndex = startIndex;
-        var charOffset = coords[0] - startIndex;
-        var leftWideCharCount = 0;
-        var rightWideCharCount = 0;
-        var leftLongCharOffset = 0;
-        var rightLongCharOffset = 0;
-        if (line.charAt(startIndex) === ' ') {
-            while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {
-                startIndex--;
-            }
-            while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {
-                endIndex++;
-            }
-        }
-        else {
-            var startCol = coords[0];
-            var endCol = coords[0];
-            if (bufferLine.getWidth(startCol) === 0) {
-                leftWideCharCount++;
-                startCol--;
-            }
-            if (bufferLine.getWidth(endCol) === 2) {
-                rightWideCharCount++;
-                endCol++;
-            }
-            var length_2 = bufferLine.getString(endCol).length;
-            if (length_2 > 1) {
-                rightLongCharOffset += length_2 - 1;
-                endIndex += length_2 - 1;
-            }
-            while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine.loadCell(startCol - 1, this._workCell))) {
-                bufferLine.loadCell(startCol - 1, this._workCell);
-                var length_3 = this._workCell.getChars().length;
-                if (this._workCell.getWidth() === 0) {
-                    leftWideCharCount++;
-                    startCol--;
-                }
-                else if (length_3 > 1) {
-                    leftLongCharOffset += length_3 - 1;
-                    startIndex -= length_3 - 1;
-                }
-                startIndex--;
-                startCol--;
-            }
-            while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine.loadCell(endCol + 1, this._workCell))) {
-                bufferLine.loadCell(endCol + 1, this._workCell);
-                var length_4 = this._workCell.getChars().length;
-                if (this._workCell.getWidth() === 2) {
-                    rightWideCharCount++;
-                    endCol++;
-                }
-                else if (length_4 > 1) {
-                    rightLongCharOffset += length_4 - 1;
-                    endIndex += length_4 - 1;
-                }
-                endIndex++;
-                endCol++;
-            }
-        }
-        endIndex++;
-        var start = startIndex
-            + charOffset
-            - leftWideCharCount
-            + leftLongCharOffset;
-        var length = Math.min(this._terminal.cols, endIndex
-            - startIndex
-            + leftWideCharCount
-            + rightWideCharCount
-            - leftLongCharOffset
-            - rightLongCharOffset);
-        if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {
-            return null;
-        }
-        if (followWrappedLinesAbove) {
-            if (start === 0 && bufferLine.getCodePoint(0) !== 32) {
-                var previousBufferLine = this._buffer.lines.get(coords[1] - 1);
-                if (previousBufferLine && bufferLine.isWrapped && previousBufferLine.getCodePoint(this._terminal.cols - 1) !== 32) {
-                    var previousLineWordPosition = this._getWordAt([this._terminal.cols - 1, coords[1] - 1], false, true, false);
-                    if (previousLineWordPosition) {
-                        var offset = this._terminal.cols - previousLineWordPosition.start;
-                        start -= offset;
-                        length += offset;
-                    }
-                }
-            }
-        }
-        if (followWrappedLinesBelow) {
-            if (start + length === this._terminal.cols && bufferLine.getCodePoint(this._terminal.cols - 1) !== 32) {
-                var nextBufferLine = this._buffer.lines.get(coords[1] + 1);
-                if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32) {
-                    var nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);
-                    if (nextLineWordPosition) {
-                        length += nextLineWordPosition.length;
-                    }
-                }
-            }
-        }
-        return { start: start, length: length };
-    };
-    SelectionManager.prototype._selectWordAt = function (coords, allowWhitespaceOnlySelection) {
-        var wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);
-        if (wordPosition) {
-            while (wordPosition.start < 0) {
-                wordPosition.start += this._terminal.cols;
-                coords[1]--;
-            }
-            this._model.selectionStart = [wordPosition.start, coords[1]];
-            this._model.selectionStartLength = wordPosition.length;
-        }
-    };
-    SelectionManager.prototype._selectToWordAt = function (coords) {
-        var wordPosition = this._getWordAt(coords, true);
-        if (wordPosition) {
-            var endRow = coords[1];
-            while (wordPosition.start < 0) {
-                wordPosition.start += this._terminal.cols;
-                endRow--;
-            }
-            if (!this._model.areSelectionValuesReversed()) {
-                while (wordPosition.start + wordPosition.length > this._terminal.cols) {
-                    wordPosition.length -= this._terminal.cols;
-                    endRow++;
-                }
-            }
-            this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : wordPosition.start + wordPosition.length, endRow];
-        }
-    };
-    SelectionManager.prototype._isCharWordSeparator = function (cell) {
-        if (cell.getWidth() === 0) {
-            return false;
-        }
-        return WORD_SEPARATORS.indexOf(cell.getChars()) >= 0;
-    };
-    SelectionManager.prototype._selectLineAt = function (line) {
-        var wrappedRange = this._buffer.getWrappedRangeForLine(line);
-        this._model.selectionStart = [0, wrappedRange.first];
-        this._model.selectionEnd = [this._terminal.cols, wrappedRange.last];
-        this._model.selectionStartLength = 0;
-    };
-    return SelectionManager;
-}());
-exports.SelectionManager = SelectionManager;
-
-},{"./BufferLine":3,"./MouseHelper":13,"./SelectionModel":16,"./common/EventEmitter2":25,"./common/Platform":27,"./handlers/AltClickHandler":33}],16:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var SelectionModel = (function () {
-    function SelectionModel(_terminal) {
-        this._terminal = _terminal;
-        this.clearSelection();
-    }
-    SelectionModel.prototype.clearSelection = function () {
-        this.selectionStart = null;
-        this.selectionEnd = null;
-        this.isSelectAllActive = false;
-        this.selectionStartLength = 0;
-    };
-    Object.defineProperty(SelectionModel.prototype, "finalSelectionStart", {
-        get: function () {
-            if (this.isSelectAllActive) {
-                return [0, 0];
-            }
-            if (!this.selectionEnd || !this.selectionStart) {
-                return this.selectionStart;
-            }
-            return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(SelectionModel.prototype, "finalSelectionEnd", {
-        get: function () {
-            if (this.isSelectAllActive) {
-                return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];
-            }
-            if (!this.selectionStart) {
-                return null;
-            }
-            if (!this.selectionEnd || this.areSelectionValuesReversed()) {
-                var startPlusLength = this.selectionStart[0] + this.selectionStartLength;
-                if (startPlusLength > this._terminal.cols) {
-                    return [startPlusLength % this._terminal.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._terminal.cols)];
-                }
-                return [startPlusLength, this.selectionStart[1]];
-            }
-            if (this.selectionStartLength) {
-                if (this.selectionEnd[1] === this.selectionStart[1]) {
-                    return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];
-                }
-            }
-            return this.selectionEnd;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    SelectionModel.prototype.areSelectionValuesReversed = function () {
-        var start = this.selectionStart;
-        var end = this.selectionEnd;
-        if (!start || !end) {
-            return false;
-        }
-        return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);
-    };
-    SelectionModel.prototype.onTrim = function (amount) {
-        if (this.selectionStart) {
-            this.selectionStart[1] -= amount;
-        }
-        if (this.selectionEnd) {
-            this.selectionEnd[1] -= amount;
-        }
-        if (this.selectionEnd && this.selectionEnd[1] < 0) {
-            this.clearSelection();
-            return true;
-        }
-        if (this.selectionStart && this.selectionStart[1] < 0) {
-            this.selectionStart[1] = 0;
-        }
-        return false;
-    };
-    return SelectionModel;
-}());
-exports.SelectionModel = SelectionModel;
-
-},{}],17:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.DEFAULT_BELL_SOUND = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';
-var SoundManager = (function () {
-    function SoundManager(_terminal) {
-        this._terminal = _terminal;
-    }
-    Object.defineProperty(SoundManager, "audioContext", {
-        get: function () {
-            if (!SoundManager._audioContext) {
-                var audioContextCtor = window.AudioContext || window.webkitAudioContext;
-                if (!audioContextCtor) {
-                    console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');
-                    return null;
-                }
-                SoundManager._audioContext = new audioContextCtor();
-            }
-            return SoundManager._audioContext;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    SoundManager.prototype.playBellSound = function () {
-        var ctx = SoundManager.audioContext;
-        if (!ctx) {
-            return;
-        }
-        var bellAudioSource = ctx.createBufferSource();
-        ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), function (buffer) {
-            bellAudioSource.buffer = buffer;
-            bellAudioSource.connect(ctx.destination);
-            bellAudioSource.start(0);
-        });
-    };
-    SoundManager.prototype._base64ToArrayBuffer = function (base64) {
-        var binaryString = window.atob(base64);
-        var len = binaryString.length;
-        var bytes = new Uint8Array(len);
-        for (var i = 0; i < len; i++) {
-            bytes[i] = binaryString.charCodeAt(i);
-        }
-        return bytes.buffer;
-    };
-    SoundManager.prototype._removeMimeType = function (dataURI) {
-        var splitUri = dataURI.split(',');
-        return splitUri[1];
-    };
-    return SoundManager;
-}());
-exports.SoundManager = SoundManager;
-
-},{}],18:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.blankLine = 'Blank line';
-exports.promptLabel = 'Terminal input';
-exports.tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';
-
-},{}],19:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var BufferSet_1 = require("./BufferSet");
-var Buffer_1 = require("./Buffer");
-var CompositionHelper_1 = require("./CompositionHelper");
-var EventEmitter_1 = require("./common/EventEmitter");
-var Viewport_1 = require("./Viewport");
-var Clipboard_1 = require("./Clipboard");
-var EscapeSequences_1 = require("./common/data/EscapeSequences");
-var InputHandler_1 = require("./InputHandler");
-var Renderer_1 = require("./renderer/Renderer");
-var Linkifier_1 = require("./Linkifier");
-var SelectionManager_1 = require("./SelectionManager");
-var CharMeasure_1 = require("./CharMeasure");
-var Browser = require("./common/Platform");
-var Lifecycle_1 = require("./ui/Lifecycle");
-var Strings = require("./Strings");
-var MouseHelper_1 = require("./MouseHelper");
-var SoundManager_1 = require("./SoundManager");
-var MouseZoneManager_1 = require("./MouseZoneManager");
-var AccessibilityManager_1 = require("./AccessibilityManager");
-var ScreenDprMonitor_1 = require("./ui/ScreenDprMonitor");
-var CharAtlasCache_1 = require("./renderer/atlas/CharAtlasCache");
-var DomRenderer_1 = require("./renderer/dom/DomRenderer");
-var Keyboard_1 = require("./core/input/Keyboard");
-var Clone_1 = require("./common/Clone");
-var EventEmitter2_1 = require("./common/EventEmitter2");
-var WindowsMode_1 = require("./WindowsMode");
-var document = (typeof window !== 'undefined') ? window.document : null;
-var WRITE_BUFFER_PAUSE_THRESHOLD = 5;
-var WRITE_TIMEOUT_MS = 12;
-var MINIMUM_COLS = 2;
-var MINIMUM_ROWS = 1;
-var CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows'];
-var DEFAULT_OPTIONS = {
-    cols: 80,
-    rows: 24,
-    convertEol: false,
-    termName: 'xterm',
-    cursorBlink: false,
-    cursorStyle: 'block',
-    bellSound: SoundManager_1.DEFAULT_BELL_SOUND,
-    bellStyle: 'none',
-    drawBoldTextInBrightColors: true,
-    enableBold: true,
-    experimentalCharAtlas: 'static',
-    fontFamily: 'courier-new, courier, monospace',
-    fontSize: 15,
-    fontWeight: 'normal',
-    fontWeightBold: 'bold',
-    lineHeight: 1.0,
-    letterSpacing: 0,
-    scrollback: 1000,
-    screenKeys: false,
-    screenReaderMode: false,
-    debug: false,
-    macOptionIsMeta: false,
-    macOptionClickForcesSelection: false,
-    cancelEvents: false,
-    disableStdin: false,
-    useFlowControl: false,
-    allowTransparency: false,
-    tabStopWidth: 8,
-    theme: null,
-    rightClickSelectsWord: Browser.isMac,
-    rendererType: 'canvas',
-    windowsMode: false
-};
-var Terminal = (function (_super) {
-    __extends(Terminal, _super);
-    function Terminal(options) {
-        if (options === void 0) { options = {}; }
-        var _this = _super.call(this) || this;
-        _this.browser = Browser;
-        _this._blankLine = null;
-        _this._onCursorMove = new EventEmitter2_1.EventEmitter2();
-        _this._onData = new EventEmitter2_1.EventEmitter2();
-        _this._onKey = new EventEmitter2_1.EventEmitter2();
-        _this._onLineFeed = new EventEmitter2_1.EventEmitter2();
-        _this._onRender = new EventEmitter2_1.EventEmitter2();
-        _this._onResize = new EventEmitter2_1.EventEmitter2();
-        _this._onScroll = new EventEmitter2_1.EventEmitter2();
-        _this._onSelectionChange = new EventEmitter2_1.EventEmitter2();
-        _this._onTitleChange = new EventEmitter2_1.EventEmitter2();
-        _this.options = Clone_1.clone(options);
-        _this._setup();
-        _this.onCursorMove(function () { return _this.emit('cursormove'); });
-        _this.onData(function (e) { return _this.emit('data', e); });
-        _this.onKey(function (e) { return _this.emit('key', e.key, e.domEvent); });
-        _this.onLineFeed(function () { return _this.emit('linefeed'); });
-        _this.onRender(function (e) { return _this.emit('refresh', e); });
-        _this.onResize(function (e) { return _this.emit('resize', e); });
-        _this.onSelectionChange(function () { return _this.emit('selection'); });
-        _this.onScroll(function (e) { return _this.emit('scroll', e); });
-        _this.onTitleChange(function (e) { return _this.emit('title', e); });
-        return _this;
-    }
-    Object.defineProperty(Terminal.prototype, "onCursorMove", {
-        get: function () { return this._onCursorMove.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onData", {
-        get: function () { return this._onData.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onKey", {
-        get: function () { return this._onKey.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onLineFeed", {
-        get: function () { return this._onLineFeed.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onRender", {
-        get: function () { return this._onRender.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onResize", {
-        get: function () { return this._onResize.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onScroll", {
-        get: function () { return this._onScroll.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onSelectionChange", {
-        get: function () { return this._onSelectionChange.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onTitleChange", {
-        get: function () { return this._onTitleChange.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Terminal.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        if (this._windowsMode) {
-            this._windowsMode.dispose();
-            this._windowsMode = undefined;
-        }
-        this._customKeyEventHandler = null;
-        CharAtlasCache_1.removeTerminalFromCache(this);
-        this.handler = function () { };
-        this.write = function () { };
-        if (this.element && this.element.parentNode) {
-            this.element.parentNode.removeChild(this.element);
-        }
-    };
-    Terminal.prototype.destroy = function () {
-        this.dispose();
-    };
-    Terminal.prototype._setup = function () {
-        var _this = this;
-        Object.keys(DEFAULT_OPTIONS).forEach(function (key) {
-            if (_this.options[key] === null || _this.options[key] === undefined) {
-                _this.options[key] = DEFAULT_OPTIONS[key];
-            }
-        });
-        this._parent = document ? document.body : null;
-        this.cols = Math.max(this.options.cols, MINIMUM_COLS);
-        this.rows = Math.max(this.options.rows, MINIMUM_ROWS);
-        if (this.options.handler) {
-            this.onData(this.options.handler);
-        }
-        this.cursorState = 0;
-        this.cursorHidden = false;
-        this._customKeyEventHandler = null;
-        this.applicationKeypad = false;
-        this.applicationCursor = false;
-        this.originMode = false;
-        this.insertMode = false;
-        this.wraparoundMode = true;
-        this.bracketedPasteMode = false;
-        this.charset = null;
-        this.gcharset = null;
-        this.glevel = 0;
-        this.charsets = [null];
-        this.curAttrData = Buffer_1.DEFAULT_ATTR_DATA.clone();
-        this._eraseAttrData = Buffer_1.DEFAULT_ATTR_DATA.clone();
-        this.params = [];
-        this.currentParam = 0;
-        this.writeBuffer = [];
-        this._writeInProgress = false;
-        this._xoffSentToCatchUp = false;
-        this._userScrolling = false;
-        this._inputHandler = new InputHandler_1.InputHandler(this);
-        this._inputHandler.onCursorMove(function () { return _this._onCursorMove.fire(); });
-        this._inputHandler.onLineFeed(function () { return _this._onLineFeed.fire(); });
-        this._inputHandler.onData(function (e) { return _this._onData.fire(e); });
-        this.register(this._inputHandler);
-        this.renderer = this.renderer || null;
-        this.selectionManager = this.selectionManager || null;
-        this.linkifier = this.linkifier || new Linkifier_1.Linkifier(this);
-        this._mouseZoneManager = this._mouseZoneManager || null;
-        this.soundManager = this.soundManager || new SoundManager_1.SoundManager(this);
-        this.buffers = new BufferSet_1.BufferSet(this);
-        if (this.selectionManager) {
-            this.selectionManager.clearSelection();
-            this.selectionManager.initBuffersListeners();
-        }
-        if (this.options.windowsMode) {
-            this._windowsMode = WindowsMode_1.applyWindowsMode(this);
-        }
-    };
-    Object.defineProperty(Terminal.prototype, "buffer", {
-        get: function () {
-            return this.buffers.active;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Terminal.prototype.eraseAttrData = function () {
-        this._eraseAttrData.bg &= ~(50331648 | 0xFFFFFF);
-        this._eraseAttrData.bg |= this.curAttrData.bg & ~0xFC000000;
-        return this._eraseAttrData;
-    };
-    Terminal.prototype.focus = function () {
-        if (this.textarea) {
-            this.textarea.focus({ preventScroll: true });
-        }
-    };
-    Object.defineProperty(Terminal.prototype, "isFocused", {
-        get: function () {
-            return document.activeElement === this.textarea && document.hasFocus();
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Terminal.prototype.getOption = function (key) {
-        if (!(key in DEFAULT_OPTIONS)) {
-            throw new Error('No option with key "' + key + '"');
-        }
-        return this.options[key];
-    };
-    Terminal.prototype.setOption = function (key, value) {
-        if (!(key in DEFAULT_OPTIONS)) {
-            throw new Error('No option with key "' + key + '"');
-        }
-        if (CONSTRUCTOR_ONLY_OPTIONS.indexOf(key) !== -1) {
-            console.error("Option \"" + key + "\" can only be set in the constructor");
-        }
-        if (this.options[key] === value) {
-            return;
-        }
-        switch (key) {
-            case 'bellStyle':
-                if (!value) {
-                    value = 'none';
-                }
-                break;
-            case 'cursorStyle':
-                if (!value) {
-                    value = 'block';
-                }
-                break;
-            case 'fontWeight':
-                if (!value) {
-                    value = 'normal';
-                }
-                break;
-            case 'fontWeightBold':
-                if (!value) {
-                    value = 'bold';
-                }
-                break;
-            case 'lineHeight':
-                if (value < 1) {
-                    console.warn(key + " cannot be less than 1, value: " + value);
-                    return;
-                }
-            case 'rendererType':
-                if (!value) {
-                    value = 'canvas';
-                }
-                break;
-            case 'tabStopWidth':
-                if (value < 1) {
-                    console.warn(key + " cannot be less than 1, value: " + value);
-                    return;
-                }
-                break;
-            case 'theme':
-                if (this.renderer) {
-                    this._setTheme(value);
-                    return;
-                }
-                break;
-            case 'scrollback':
-                value = Math.min(value, Buffer_1.MAX_BUFFER_SIZE);
-                if (value < 0) {
-                    console.warn(key + " cannot be less than 0, value: " + value);
-                    return;
-                }
-                if (this.options[key] !== value) {
-                    var newBufferLength = this.rows + value;
-                    if (this.buffer.lines.length > newBufferLength) {
-                        var amountToTrim = this.buffer.lines.length - newBufferLength;
-                        var needsRefresh = (this.buffer.ydisp - amountToTrim < 0);
-                        this.buffer.lines.trimStart(amountToTrim);
-                        this.buffer.ybase = Math.max(this.buffer.ybase - amountToTrim, 0);
-                        this.buffer.ydisp = Math.max(this.buffer.ydisp - amountToTrim, 0);
-                        if (needsRefresh) {
-                            this.refresh(0, this.rows - 1);
-                        }
-                    }
-                }
-                break;
-        }
-        this.options[key] = value;
-        switch (key) {
-            case 'fontFamily':
-            case 'fontSize':
-                if (this.renderer) {
-                    this.renderer.clear();
-                    this.charMeasure.measure(this.options);
-                }
-                break;
-            case 'drawBoldTextInBrightColors':
-            case 'experimentalCharAtlas':
-            case 'enableBold':
-            case 'letterSpacing':
-            case 'lineHeight':
-            case 'fontWeight':
-            case 'fontWeightBold':
-                if (this.renderer) {
-                    this.renderer.clear();
-                    this.renderer.onResize(this.cols, this.rows);
-                    this.refresh(0, this.rows - 1);
-                }
-                break;
-            case 'rendererType':
-                if (this.renderer) {
-                    this.unregister(this.renderer);
-                    this.renderer.dispose();
-                    this.renderer = null;
-                }
-                this._setupRenderer();
-                this.renderer.onCharSizeChanged();
-                if (this._theme) {
-                    this.renderer.setTheme(this._theme);
-                }
-                this.mouseHelper.setRenderer(this.renderer);
-                break;
-            case 'scrollback':
-                this.buffers.resize(this.cols, this.rows);
-                if (this.viewport) {
-                    this.viewport.syncScrollArea();
-                }
-                break;
-            case 'screenReaderMode':
-                if (value) {
-                    if (!this._accessibilityManager) {
-                        this._accessibilityManager = new AccessibilityManager_1.AccessibilityManager(this);
-                    }
-                }
-                else {
-                    if (this._accessibilityManager) {
-                        this._accessibilityManager.dispose();
-                        this._accessibilityManager = null;
-                    }
-                }
-                break;
-            case 'tabStopWidth':
-                this.buffers.setupTabStops();
-                break;
-            case 'windowsMode':
-                if (value) {
-                    if (!this._windowsMode) {
-                        this._windowsMode = WindowsMode_1.applyWindowsMode(this);
-                    }
-                }
-                else {
-                    if (this._windowsMode) {
-                        this._windowsMode.dispose();
-                        this._windowsMode = undefined;
-                    }
-                }
-                break;
-        }
-        if (this.renderer) {
-            this.renderer.onOptionsChanged();
-        }
-    };
-    Terminal.prototype._onTextAreaFocus = function (ev) {
-        if (this.sendFocus) {
-            this.handler(EscapeSequences_1.C0.ESC + '[I');
-        }
-        this.updateCursorStyle(ev);
-        this.element.classList.add('focus');
-        this.showCursor();
-        this.emit('focus');
-    };
-    Terminal.prototype.blur = function () {
-        return this.textarea.blur();
-    };
-    Terminal.prototype._onTextAreaBlur = function () {
-        this.textarea.value = '';
-        this.refresh(this.buffer.y, this.buffer.y);
-        if (this.sendFocus) {
-            this.handler(EscapeSequences_1.C0.ESC + '[O');
-        }
-        this.element.classList.remove('focus');
-        this.emit('blur');
-    };
-    Terminal.prototype._initGlobal = function () {
-        var _this = this;
-        this._bindKeys();
-        this.register(Lifecycle_1.addDisposableDomListener(this.element, 'copy', function (event) {
-            if (!_this.hasSelection()) {
-                return;
-            }
-            Clipboard_1.copyHandler(event, _this, _this.selectionManager);
-        }));
-        var pasteHandlerWrapper = function (event) { return Clipboard_1.pasteHandler(event, _this); };
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'paste', pasteHandlerWrapper));
-        this.register(Lifecycle_1.addDisposableDomListener(this.element, 'paste', pasteHandlerWrapper));
-        if (Browser.isFirefox) {
-            this.register(Lifecycle_1.addDisposableDomListener(this.element, 'mousedown', function (event) {
-                if (event.button === 2) {
-                    Clipboard_1.rightClickHandler(event, _this, _this.selectionManager, _this.options.rightClickSelectsWord);
-                }
-            }));
-        }
-        else {
-            this.register(Lifecycle_1.addDisposableDomListener(this.element, 'contextmenu', function (event) {
-                Clipboard_1.rightClickHandler(event, _this, _this.selectionManager, _this.options.rightClickSelectsWord);
-            }));
-        }
-        if (Browser.isLinux) {
-            this.register(Lifecycle_1.addDisposableDomListener(this.element, 'auxclick', function (event) {
-                if (event.button === 1) {
-                    Clipboard_1.moveTextAreaUnderMouseCursor(event, _this);
-                }
-            }));
-        }
-    };
-    Terminal.prototype._bindKeys = function () {
-        var _this = this;
-        var self = this;
-        this.register(Lifecycle_1.addDisposableDomListener(this.element, 'keydown', function (ev) {
-            if (document.activeElement !== this) {
-                return;
-            }
-            self._keyDown(ev);
-        }, true));
-        this.register(Lifecycle_1.addDisposableDomListener(this.element, 'keypress', function (ev) {
-            if (document.activeElement !== this) {
-                return;
-            }
-            self._keyPress(ev);
-        }, true));
-        this.register(Lifecycle_1.addDisposableDomListener(this.element, 'keyup', function (ev) {
-            if (!wasModifierKeyOnlyEvent(ev)) {
-                _this.focus();
-            }
-            self._keyUp(ev);
-        }, true));
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'keydown', function (ev) { return _this._keyDown(ev); }, true));
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'keypress', function (ev) { return _this._keyPress(ev); }, true));
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'compositionstart', function () { return _this._compositionHelper.compositionstart(); }));
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'compositionupdate', function (e) { return _this._compositionHelper.compositionupdate(e); }));
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'compositionend', function () { return _this._compositionHelper.compositionend(); }));
-        this.register(this.onRender(function () { return _this._compositionHelper.updateCompositionElements(); }));
-        this.register(this.onRender(function (e) { return _this._queueLinkification(e.start, e.end); }));
-    };
-    Terminal.prototype.open = function (parent) {
-        var _this = this;
-        this._parent = parent || this._parent;
-        if (!this._parent) {
-            throw new Error('Terminal requires a parent element.');
-        }
-        this._context = this._parent.ownerDocument.defaultView;
-        this._document = this._parent.ownerDocument;
-        this._screenDprMonitor = new ScreenDprMonitor_1.ScreenDprMonitor();
-        this._screenDprMonitor.setListener(function () { return _this.emit('dprchange', window.devicePixelRatio); });
-        this.register(this._screenDprMonitor);
-        this.element = this._document.createElement('div');
-        this.element.dir = 'ltr';
-        this.element.classList.add('terminal');
-        this.element.classList.add('xterm');
-        this.element.setAttribute('tabindex', '0');
-        this._parent.appendChild(this.element);
-        var fragment = document.createDocumentFragment();
-        this._viewportElement = document.createElement('div');
-        this._viewportElement.classList.add('xterm-viewport');
-        fragment.appendChild(this._viewportElement);
-        this._viewportScrollArea = document.createElement('div');
-        this._viewportScrollArea.classList.add('xterm-scroll-area');
-        this._viewportElement.appendChild(this._viewportScrollArea);
-        this.screenElement = document.createElement('div');
-        this.screenElement.classList.add('xterm-screen');
-        this._helperContainer = document.createElement('div');
-        this._helperContainer.classList.add('xterm-helpers');
-        this.screenElement.appendChild(this._helperContainer);
-        fragment.appendChild(this.screenElement);
-        this._mouseZoneManager = new MouseZoneManager_1.MouseZoneManager(this);
-        this.register(this._mouseZoneManager);
-        this.register(this.onScroll(function () { return _this._mouseZoneManager.clearAll(); }));
-        this.linkifier.attachToDom(this._mouseZoneManager);
-        this.textarea = document.createElement('textarea');
-        this.textarea.classList.add('xterm-helper-textarea');
-        this.textarea.setAttribute('aria-label', Strings.promptLabel);
-        this.textarea.setAttribute('aria-multiline', 'false');
-        this.textarea.setAttribute('autocorrect', 'off');
-        this.textarea.setAttribute('autocapitalize', 'off');
-        this.textarea.setAttribute('spellcheck', 'false');
-        this.textarea.tabIndex = 0;
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'focus', function (ev) { return _this._onTextAreaFocus(ev); }));
-        this.register(Lifecycle_1.addDisposableDomListener(this.textarea, 'blur', function () { return _this._onTextAreaBlur(); }));
-        this._helperContainer.appendChild(this.textarea);
-        this._compositionView = document.createElement('div');
-        this._compositionView.classList.add('composition-view');
-        this._compositionHelper = new CompositionHelper_1.CompositionHelper(this.textarea, this._compositionView, this);
-        this._helperContainer.appendChild(this._compositionView);
-        this.charMeasure = new CharMeasure_1.CharMeasure(document, this._helperContainer);
-        this.element.appendChild(fragment);
-        this._setupRenderer();
-        this._theme = this.options.theme;
-        this.options.theme = null;
-        this.viewport = new Viewport_1.Viewport(this, this._viewportElement, this._viewportScrollArea, this.charMeasure);
-        this.viewport.onThemeChanged(this.renderer.colorManager.colors);
-        this.register(this.viewport);
-        this.register(this.onCursorMove(function () { return _this.renderer.onCursorMove(); }));
-        this.register(this.onResize(function () { return _this.renderer.onResize(_this.cols, _this.rows); }));
-        this.register(this.addDisposableListener('blur', function () { return _this.renderer.onBlur(); }));
-        this.register(this.addDisposableListener('focus', function () { return _this.renderer.onFocus(); }));
-        this.register(this.addDisposableListener('dprchange', function () { return _this.renderer.onWindowResize(window.devicePixelRatio); }));
-        this.register(Lifecycle_1.addDisposableDomListener(window, 'resize', function () { return _this.renderer.onWindowResize(window.devicePixelRatio); }));
-        this.register(this.charMeasure.onCharSizeChanged(function () { return _this.renderer.onCharSizeChanged(); }));
-        this.register(this.renderer.onCanvasResize(function () { return _this.viewport.syncScrollArea(); }));
-        this.selectionManager = new SelectionManager_1.SelectionManager(this, this.charMeasure);
-        this.register(this.selectionManager.onSelectionChange(function () { return _this._onSelectionChange.fire(); }));
-        this.register(Lifecycle_1.addDisposableDomListener(this.element, 'mousedown', function (e) { return _this.selectionManager.onMouseDown(e); }));
-        this.register(this.selectionManager.onRedrawRequest(function (e) { return _this.renderer.onSelectionChanged(e.start, e.end, e.columnSelectMode); }));
-        this.register(this.selectionManager.onLinuxMouseSelection(function (text) {
-            _this.textarea.value = text;
-            _this.textarea.focus();
-            _this.textarea.select();
-        }));
-        this.register(this.onScroll(function () {
-            _this.viewport.syncScrollArea();
-            _this.selectionManager.refresh();
-        }));
-        this.register(Lifecycle_1.addDisposableDomListener(this._viewportElement, 'scroll', function () { return _this.selectionManager.refresh(); }));
-        this.mouseHelper = new MouseHelper_1.MouseHelper(this.renderer);
-        this.element.classList.toggle('enable-mouse-events', this.mouseEvents);
-        if (this.mouseEvents) {
-            this.selectionManager.disable();
-        }
-        else {
-            this.selectionManager.enable();
-        }
-        if (this.options.screenReaderMode) {
-            this._accessibilityManager = new AccessibilityManager_1.AccessibilityManager(this);
-        }
-        this.charMeasure.measure(this.options);
-        this.refresh(0, this.rows - 1);
-        this._initGlobal();
-        this.bindMouse();
-    };
-    Terminal.prototype._setupRenderer = function () {
-        var _this = this;
-        switch (this.options.rendererType) {
-            case 'canvas':
-                this.renderer = new Renderer_1.Renderer(this, this.options.theme);
-                break;
-            case 'dom':
-                this.renderer = new DomRenderer_1.DomRenderer(this, this.options.theme);
-                break;
-            default: throw new Error("Unrecognized rendererType \"" + this.options.rendererType + "\"");
-        }
-        this.renderer.onRender(function (e) { return _this._onRender.fire(e); });
-        this.register(this.renderer);
-    };
-    Terminal.prototype._setTheme = function (theme) {
-        this._theme = theme;
-        var colors = this.renderer.setTheme(theme);
-        if (this.viewport) {
-            this.viewport.onThemeChanged(colors);
-        }
-    };
-    Terminal.prototype.bindMouse = function () {
-        var _this = this;
-        var el = this.element;
-        var self = this;
-        var pressed = 32;
-        function sendButton(ev) {
-            var button;
-            var pos;
-            button = getButton(ev);
-            pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);
-            if (!pos)
-                return;
-            sendEvent(button, pos);
-            switch (ev.overrideType || ev.type) {
-                case 'mousedown':
-                    pressed = button;
-                    break;
-                case 'mouseup':
-                    pressed = 32;
-                    break;
-                case 'wheel':
-                    break;
-            }
-        }
-        function sendMove(ev) {
-            var button = pressed;
-            var pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);
-            if (!pos)
-                return;
-            button += 32;
-            sendEvent(button, pos);
-        }
-        function encode(data, ch) {
-            if (!self.utfMouse) {
-                if (ch === 255) {
-                    data.push(0);
-                    return;
-                }
-                if (ch > 127)
-                    ch = 127;
-                data.push(ch);
-            }
-            else {
-                if (ch > 2047) {
-                    data.push(2047);
-                    return;
-                }
-                data.push(ch);
-            }
-        }
-        function sendEvent(button, pos) {
-            if (self._vt300Mouse) {
-                button &= 3;
-                pos.x -= 32;
-                pos.y -= 32;
-                var data_1 = EscapeSequences_1.C0.ESC + '[24';
-                if (button === 0)
-                    data_1 += '1';
-                else if (button === 1)
-                    data_1 += '3';
-                else if (button === 2)
-                    data_1 += '5';
-                else if (button === 3)
-                    return;
-                else
-                    data_1 += '0';
-                data_1 += '~[' + pos.x + ',' + pos.y + ']\r';
-                self.handler(data_1);
-                return;
-            }
-            if (self._decLocator) {
-                button &= 3;
-                pos.x -= 32;
-                pos.y -= 32;
-                if (button === 0)
-                    button = 2;
-                else if (button === 1)
-                    button = 4;
-                else if (button === 2)
-                    button = 6;
-                else if (button === 3)
-                    button = 3;
-                self.handler(EscapeSequences_1.C0.ESC + '['
-                    + button
-                    + ';'
-                    + (button === 3 ? 4 : 0)
-                    + ';'
-                    + pos.y
-                    + ';'
-                    + pos.x
-                    + ';'
-                    + pos.page || 0
-                    + '&w');
-                return;
-            }
-            if (self.urxvtMouse) {
-                pos.x -= 32;
-                pos.y -= 32;
-                pos.x++;
-                pos.y++;
-                self.handler(EscapeSequences_1.C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');
-                return;
-            }
-            if (self.sgrMouse) {
-                pos.x -= 32;
-                pos.y -= 32;
-                self.handler(EscapeSequences_1.C0.ESC + '[<'
-                    + (((button & 3) === 3 ? button & ~3 : button) - 32)
-                    + ';'
-                    + pos.x
-                    + ';'
-                    + pos.y
-                    + ((button & 3) === 3 ? 'm' : 'M'));
-                return;
-            }
-            var data = [];
-            encode(data, button);
-            encode(data, pos.x);
-            encode(data, pos.y);
-            self.handler(EscapeSequences_1.C0.ESC + '[M' + String.fromCharCode.apply(String, data));
-        }
-        function getButton(ev) {
-            var button;
-            var shift;
-            var meta;
-            var ctrl;
-            var mod;
-            switch (ev.overrideType || ev.type) {
-                case 'mousedown':
-                    button = ev.button !== null && ev.button !== undefined
-                        ? +ev.button
-                        : ev.which !== null && ev.which !== undefined
-                            ? ev.which - 1
-                            : null;
-                    if (Browser.isMSIE) {
-                        button = button === 1 ? 0 : button === 4 ? 1 : button;
-                    }
-                    break;
-                case 'mouseup':
-                    button = 3;
-                    break;
-                case 'DOMMouseScroll':
-                    button = ev.detail < 0
-                        ? 64
-                        : 65;
-                    break;
-                case 'wheel':
-                    button = ev.deltaY < 0
-                        ? 64
-                        : 65;
-                    break;
-            }
-            shift = ev.shiftKey ? 4 : 0;
-            meta = ev.metaKey ? 8 : 0;
-            ctrl = ev.ctrlKey ? 16 : 0;
-            mod = shift | meta | ctrl;
-            if (self.vt200Mouse) {
-                mod &= ctrl;
-            }
-            else if (!self.normalMouse) {
-                mod = 0;
-            }
-            button = (32 + (mod << 2)) + button;
-            return button;
-        }
-        this.register(Lifecycle_1.addDisposableDomListener(el, 'mousedown', function (ev) {
-            ev.preventDefault();
-            _this.focus();
-            if (!_this.mouseEvents || _this.selectionManager.shouldForceSelection(ev)) {
-                return;
-            }
-            sendButton(ev);
-            if (_this.vt200Mouse) {
-                ev.overrideType = 'mouseup';
-                sendButton(ev);
-                return _this.cancel(ev);
-            }
-            var moveHandler;
-            if (_this.normalMouse) {
-                moveHandler = function (event) {
-                    if (!_this.normalMouse) {
-                        return;
-                    }
-                    sendMove(event);
-                };
-                _this._document.addEventListener('mousemove', moveHandler);
-            }
-            var handler = function (ev) {
-                if (_this.normalMouse && !_this.x10Mouse) {
-                    sendButton(ev);
-                }
-                if (moveHandler) {
-                    _this._document.removeEventListener('mousemove', moveHandler);
-                    moveHandler = null;
-                }
-                _this._document.removeEventListener('mouseup', handler);
-                return _this.cancel(ev);
-            };
-            _this._document.addEventListener('mouseup', handler);
-            return _this.cancel(ev);
-        }));
-        this.register(Lifecycle_1.addDisposableDomListener(el, 'wheel', function (ev) {
-            if (!_this.mouseEvents) {
-                if (!_this.buffer.hasScrollback) {
-                    var amount = _this.viewport.getLinesScrolled(ev);
-                    if (amount === 0) {
-                        return;
-                    }
-                    var sequence = EscapeSequences_1.C0.ESC + (_this.applicationCursor ? 'O' : '[') + (ev.deltaY < 0 ? 'A' : 'B');
-                    var data = '';
-                    for (var i = 0; i < Math.abs(amount); i++) {
-                        data += sequence;
-                    }
-                    _this.handler(data);
-                }
-                return;
-            }
-            if (_this.x10Mouse || _this._vt300Mouse || _this._decLocator)
-                return;
-            sendButton(ev);
-            ev.preventDefault();
-        }));
-        this.register(Lifecycle_1.addDisposableDomListener(el, 'wheel', function (ev) {
-            if (_this.mouseEvents)
-                return;
-            _this.viewport.onWheel(ev);
-            return _this.cancel(ev);
-        }));
-        this.register(Lifecycle_1.addDisposableDomListener(el, 'touchstart', function (ev) {
-            if (_this.mouseEvents)
-                return;
-            _this.viewport.onTouchStart(ev);
-            return _this.cancel(ev);
-        }));
-        this.register(Lifecycle_1.addDisposableDomListener(el, 'touchmove', function (ev) {
-            if (_this.mouseEvents)
-                return;
-            _this.viewport.onTouchMove(ev);
-            return _this.cancel(ev);
-        }));
-    };
-    Terminal.prototype.refresh = function (start, end) {
-        if (this.renderer) {
-            this.renderer.refreshRows(start, end);
-        }
-    };
-    Terminal.prototype._queueLinkification = function (start, end) {
-        if (this.linkifier) {
-            this.linkifier.linkifyRows(start, end);
-        }
-    };
-    Terminal.prototype.updateCursorStyle = function (ev) {
-        if (this.selectionManager && this.selectionManager.shouldColumnSelect(ev)) {
-            this.element.classList.add('column-select');
-        }
-        else {
-            this.element.classList.remove('column-select');
-        }
-    };
-    Terminal.prototype.showCursor = function () {
-        if (!this.cursorState) {
-            this.cursorState = 1;
-            this.refresh(this.buffer.y, this.buffer.y);
-        }
-    };
-    Terminal.prototype.scroll = function (isWrapped) {
-        if (isWrapped === void 0) { isWrapped = false; }
-        var newLine;
-        newLine = this._blankLine;
-        var eraseAttr = this.eraseAttrData();
-        if (!newLine || newLine.length !== this.cols || newLine.getFg(0) !== eraseAttr.fg || newLine.getBg(0) !== eraseAttr.bg) {
-            newLine = this.buffer.getBlankLine(eraseAttr, isWrapped);
-            this._blankLine = newLine;
-        }
-        newLine.isWrapped = isWrapped;
-        var topRow = this.buffer.ybase + this.buffer.scrollTop;
-        var bottomRow = this.buffer.ybase + this.buffer.scrollBottom;
-        if (this.buffer.scrollTop === 0) {
-            var willBufferBeTrimmed = this.buffer.lines.isFull;
-            if (bottomRow === this.buffer.lines.length - 1) {
-                if (willBufferBeTrimmed) {
-                    this.buffer.lines.recycle().copyFrom(newLine);
-                }
-                else {
-                    this.buffer.lines.push(newLine.clone());
-                }
-            }
-            else {
-                this.buffer.lines.splice(bottomRow + 1, 0, newLine.clone());
-            }
-            if (!willBufferBeTrimmed) {
-                this.buffer.ybase++;
-                if (!this._userScrolling) {
-                    this.buffer.ydisp++;
-                }
-            }
-            else {
-                if (this._userScrolling) {
-                    this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);
-                }
-            }
-        }
-        else {
-            var scrollRegionHeight = bottomRow - topRow + 1;
-            this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);
-            this.buffer.lines.set(bottomRow, newLine.clone());
-        }
-        if (!this._userScrolling) {
-            this.buffer.ydisp = this.buffer.ybase;
-        }
-        this.updateRange(this.buffer.scrollTop);
-        this.updateRange(this.buffer.scrollBottom);
-        this._onScroll.fire(this.buffer.ydisp);
-    };
-    Terminal.prototype.scrollLines = function (disp, suppressScrollEvent) {
-        if (disp < 0) {
-            if (this.buffer.ydisp === 0) {
-                return;
-            }
-            this._userScrolling = true;
-        }
-        else if (disp + this.buffer.ydisp >= this.buffer.ybase) {
-            this._userScrolling = false;
-        }
-        var oldYdisp = this.buffer.ydisp;
-        this.buffer.ydisp = Math.max(Math.min(this.buffer.ydisp + disp, this.buffer.ybase), 0);
-        if (oldYdisp === this.buffer.ydisp) {
-            return;
-        }
-        if (!suppressScrollEvent) {
-            this._onScroll.fire(this.buffer.ydisp);
-        }
-        this.refresh(0, this.rows - 1);
-    };
-    Terminal.prototype.scrollPages = function (pageCount) {
-        this.scrollLines(pageCount * (this.rows - 1));
-    };
-    Terminal.prototype.scrollToTop = function () {
-        this.scrollLines(-this.buffer.ydisp);
-    };
-    Terminal.prototype.scrollToBottom = function () {
-        this.scrollLines(this.buffer.ybase - this.buffer.ydisp);
-    };
-    Terminal.prototype.scrollToLine = function (line) {
-        var scrollAmount = line - this.buffer.ydisp;
-        if (scrollAmount !== 0) {
-            this.scrollLines(scrollAmount);
-        }
-    };
-    Terminal.prototype.write = function (data) {
-        var _this = this;
-        if (this._isDisposed) {
-            return;
-        }
-        if (!data) {
-            return;
-        }
-        this.writeBuffer.push(data);
-        if (this.options.useFlowControl && !this._xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
-            this.handler(EscapeSequences_1.C0.DC3);
-            this._xoffSentToCatchUp = true;
-        }
-        if (!this._writeInProgress && this.writeBuffer.length > 0) {
-            this._writeInProgress = true;
-            setTimeout(function () {
-                _this._innerWrite();
-            });
-        }
-    };
-    Terminal.prototype._innerWrite = function (bufferOffset) {
-        var _this = this;
-        if (bufferOffset === void 0) { bufferOffset = 0; }
-        if (this._isDisposed) {
-            this.writeBuffer = [];
-        }
-        var startTime = Date.now();
-        while (this.writeBuffer.length > bufferOffset) {
-            var data = this.writeBuffer[bufferOffset];
-            bufferOffset++;
-            if (this._xoffSentToCatchUp && this.writeBuffer.length === bufferOffset) {
-                this.handler(EscapeSequences_1.C0.DC1);
-                this._xoffSentToCatchUp = false;
-            }
-            this._refreshStart = this.buffer.y;
-            this._refreshEnd = this.buffer.y;
-            this._inputHandler.parse(data);
-            this.updateRange(this.buffer.y);
-            this.refresh(this._refreshStart, this._refreshEnd);
-            if (Date.now() - startTime >= WRITE_TIMEOUT_MS) {
-                break;
-            }
-        }
-        if (this.writeBuffer.length > bufferOffset) {
-            setTimeout(function () { return _this._innerWrite(bufferOffset); }, 0);
-        }
-        else {
-            this._writeInProgress = false;
-            this.writeBuffer = [];
-        }
-    };
-    Terminal.prototype.writeln = function (data) {
-        this.write(data + '\r\n');
-    };
-    Terminal.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler) {
-        this._customKeyEventHandler = customKeyEventHandler;
-    };
-    Terminal.prototype.addCsiHandler = function (flag, callback) {
-        return this._inputHandler.addCsiHandler(flag, callback);
-    };
-    Terminal.prototype.addOscHandler = function (ident, callback) {
-        return this._inputHandler.addOscHandler(ident, callback);
-    };
-    Terminal.prototype.registerLinkMatcher = function (regex, handler, options) {
-        var matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);
-        this.refresh(0, this.rows - 1);
-        return matcherId;
-    };
-    Terminal.prototype.deregisterLinkMatcher = function (matcherId) {
-        if (this.linkifier.deregisterLinkMatcher(matcherId)) {
-            this.refresh(0, this.rows - 1);
-        }
-    };
-    Terminal.prototype.registerCharacterJoiner = function (handler) {
-        var joinerId = this.renderer.registerCharacterJoiner(handler);
-        this.refresh(0, this.rows - 1);
-        return joinerId;
-    };
-    Terminal.prototype.deregisterCharacterJoiner = function (joinerId) {
-        if (this.renderer.deregisterCharacterJoiner(joinerId)) {
-            this.refresh(0, this.rows - 1);
-        }
-    };
-    Object.defineProperty(Terminal.prototype, "markers", {
-        get: function () {
-            return this.buffer.markers;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Terminal.prototype.addMarker = function (cursorYOffset) {
-        if (this.buffer !== this.buffers.normal) {
-            return;
-        }
-        return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);
-    };
-    Terminal.prototype.hasSelection = function () {
-        return this.selectionManager ? this.selectionManager.hasSelection : false;
-    };
-    Terminal.prototype.getSelection = function () {
-        return this.selectionManager ? this.selectionManager.selectionText : '';
-    };
-    Terminal.prototype.clearSelection = function () {
-        if (this.selectionManager) {
-            this.selectionManager.clearSelection();
-        }
-    };
-    Terminal.prototype.selectAll = function () {
-        if (this.selectionManager) {
-            this.selectionManager.selectAll();
-        }
-    };
-    Terminal.prototype.selectLines = function (start, end) {
-        if (this.selectionManager) {
-            this.selectionManager.selectLines(start, end);
-        }
-    };
-    Terminal.prototype._keyDown = function (event) {
-        if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {
-            return false;
-        }
-        if (!this._compositionHelper.keydown(event)) {
-            if (this.buffer.ybase !== this.buffer.ydisp) {
-                this.scrollToBottom();
-            }
-            return false;
-        }
-        var result = Keyboard_1.evaluateKeyboardEvent(event, this.applicationCursor, this.browser.isMac, this.options.macOptionIsMeta);
-        this.updateCursorStyle(event);
-        if (result.type === 3 || result.type === 2) {
-            var scrollCount = this.rows - 1;
-            this.scrollLines(result.type === 2 ? -scrollCount : scrollCount);
-            return this.cancel(event, true);
-        }
-        if (result.type === 1) {
-            this.selectAll();
-        }
-        if (this._isThirdLevelShift(this.browser, event)) {
-            return true;
-        }
-        if (result.cancel) {
-            this.cancel(event, true);
-        }
-        if (!result.key) {
-            return true;
-        }
-        this.emit('keydown', event);
-        this._onKey.fire({ key: result.key, domEvent: event });
-        this.showCursor();
-        this.handler(result.key);
-        return this.cancel(event, true);
-    };
-    Terminal.prototype._isThirdLevelShift = function (browser, ev) {
-        var thirdLevelKey = (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||
-            (browser.isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);
-        if (ev.type === 'keypress') {
-            return thirdLevelKey;
-        }
-        return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);
-    };
-    Terminal.prototype.setgLevel = function (g) {
-        this.glevel = g;
-        this.charset = this.charsets[g];
-    };
-    Terminal.prototype.setgCharset = function (g, charset) {
-        this.charsets[g] = charset;
-        if (this.glevel === g) {
-            this.charset = charset;
-        }
-    };
-    Terminal.prototype._keyUp = function (ev) {
-        this.updateCursorStyle(ev);
-    };
-    Terminal.prototype._keyPress = function (ev) {
-        var key;
-        if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
-            return false;
-        }
-        this.cancel(ev);
-        if (ev.charCode) {
-            key = ev.charCode;
-        }
-        else if (ev.which === null || ev.which === undefined) {
-            key = ev.keyCode;
-        }
-        else if (ev.which !== 0 && ev.charCode !== 0) {
-            key = ev.which;
-        }
-        else {
-            return false;
-        }
-        if (!key || ((ev.altKey || ev.ctrlKey || ev.metaKey) && !this._isThirdLevelShift(this.browser, ev))) {
-            return false;
-        }
-        key = String.fromCharCode(key);
-        this.emit('keypress', key, ev);
-        this._onKey.fire({ key: key, domEvent: ev });
-        this.showCursor();
-        this.handler(key);
-        return true;
-    };
-    Terminal.prototype.bell = function () {
-        var _this = this;
-        this.emit('bell');
-        if (this._soundBell()) {
-            this.soundManager.playBellSound();
-        }
-        if (this._visualBell()) {
-            this.element.classList.add('visual-bell-active');
-            clearTimeout(this._visualBellTimer);
-            this._visualBellTimer = window.setTimeout(function () {
-                _this.element.classList.remove('visual-bell-active');
-            }, 200);
-        }
-    };
-    Terminal.prototype.log = function (text, data) {
-        if (!this.options.debug)
-            return;
-        if (!this._context.console || !this._context.console.log)
-            return;
-        this._context.console.log(text, data);
-    };
-    Terminal.prototype.error = function (text, data) {
-        if (!this.options.debug)
-            return;
-        if (!this._context.console || !this._context.console.error)
-            return;
-        this._context.console.error(text, data);
-    };
-    Terminal.prototype.resize = function (x, y) {
-        if (isNaN(x) || isNaN(y)) {
-            return;
-        }
-        if (x === this.cols && y === this.rows) {
-            if (this.charMeasure && (!this.charMeasure.width || !this.charMeasure.height)) {
-                this.charMeasure.measure(this.options);
-            }
-            return;
-        }
-        if (x < MINIMUM_COLS)
-            x = MINIMUM_COLS;
-        if (y < MINIMUM_ROWS)
-            y = MINIMUM_ROWS;
-        this.buffers.resize(x, y);
-        this.cols = x;
-        this.rows = y;
-        this.buffers.setupTabStops(this.cols);
-        if (this.charMeasure) {
-            this.charMeasure.measure(this.options);
-        }
-        this.refresh(0, this.rows - 1);
-        this._onResize.fire({ cols: x, rows: y });
-    };
-    Terminal.prototype.updateRange = function (y) {
-        if (y < this._refreshStart)
-            this._refreshStart = y;
-        if (y > this._refreshEnd)
-            this._refreshEnd = y;
-    };
-    Terminal.prototype.maxRange = function () {
-        this._refreshStart = 0;
-        this._refreshEnd = this.rows - 1;
-    };
-    Terminal.prototype.clear = function () {
-        if (this.buffer.ybase === 0 && this.buffer.y === 0) {
-            return;
-        }
-        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 (var i = 1; i < this.rows; i++) {
-            this.buffer.lines.push(this.buffer.getBlankLine(Buffer_1.DEFAULT_ATTR_DATA));
-        }
-        this.refresh(0, this.rows - 1);
-        this._onScroll.fire(this.buffer.ydisp);
-    };
-    Terminal.prototype.is = function (term) {
-        return (this.options.termName + '').indexOf(term) === 0;
-    };
-    Terminal.prototype.handler = function (data) {
-        if (this.options.disableStdin) {
-            return;
-        }
-        if (this.selectionManager && this.selectionManager.hasSelection) {
-            this.selectionManager.clearSelection();
-        }
-        if (this.buffer.ybase !== this.buffer.ydisp) {
-            this.scrollToBottom();
-        }
-        this._onData.fire(data);
-    };
-    Terminal.prototype.handleTitle = function (title) {
-        this._onTitleChange.fire(title);
-    };
-    Terminal.prototype.index = function () {
-        this.buffer.y++;
-        if (this.buffer.y > this.buffer.scrollBottom) {
-            this.buffer.y--;
-            this.scroll();
-        }
-        if (this.buffer.x >= this.cols) {
-            this.buffer.x--;
-        }
-    };
-    Terminal.prototype.reverseIndex = function () {
-        if (this.buffer.y === this.buffer.scrollTop) {
-            var scrollRegionHeight = this.buffer.scrollBottom - this.buffer.scrollTop;
-            this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);
-            this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.buffer.getBlankLine(this.eraseAttrData()));
-            this.updateRange(this.buffer.scrollTop);
-            this.updateRange(this.buffer.scrollBottom);
-        }
-        else {
-            this.buffer.y--;
-        }
-    };
-    Terminal.prototype.reset = function () {
-        this.options.rows = this.rows;
-        this.options.cols = this.cols;
-        var customKeyEventHandler = this._customKeyEventHandler;
-        var inputHandler = this._inputHandler;
-        var cursorState = this.cursorState;
-        this._setup();
-        this._customKeyEventHandler = customKeyEventHandler;
-        this._inputHandler = inputHandler;
-        this.cursorState = cursorState;
-        this.refresh(0, this.rows - 1);
-        if (this.viewport) {
-            this.viewport.syncScrollArea();
-        }
-    };
-    Terminal.prototype.tabSet = function () {
-        this.buffer.tabs[this.buffer.x] = true;
-    };
-    Terminal.prototype.cancel = function (ev, force) {
-        if (!this.options.cancelEvents && !force) {
-            return;
-        }
-        ev.preventDefault();
-        ev.stopPropagation();
-        return false;
-    };
-    Terminal.prototype._visualBell = function () {
-        return false;
-    };
-    Terminal.prototype._soundBell = function () {
-        return this.options.bellStyle === 'sound';
-    };
-    return Terminal;
-}(EventEmitter_1.EventEmitter));
-exports.Terminal = Terminal;
-function wasModifierKeyOnlyEvent(ev) {
-    return ev.keyCode === 16 ||
-        ev.keyCode === 17 ||
-        ev.keyCode === 18;
-}
-
-},{"./AccessibilityManager":1,"./Buffer":2,"./BufferSet":5,"./CharMeasure":6,"./Clipboard":8,"./CompositionHelper":9,"./InputHandler":11,"./Linkifier":12,"./MouseHelper":13,"./MouseZoneManager":14,"./SelectionManager":15,"./SoundManager":17,"./Strings":18,"./Viewport":20,"./WindowsMode":21,"./common/Clone":23,"./common/EventEmitter":24,"./common/EventEmitter2":25,"./common/Platform":27,"./common/data/EscapeSequences":29,"./core/input/Keyboard":31,"./renderer/Renderer":41,"./renderer/atlas/CharAtlasCache":45,"./renderer/dom/DomRenderer":53,"./ui/Lifecycle":55,"./ui/ScreenDprMonitor":57}],20:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Lifecycle_1 = require("./common/Lifecycle");
-var Lifecycle_2 = require("./ui/Lifecycle");
-var FALLBACK_SCROLL_BAR_WIDTH = 15;
-var Viewport = (function (_super) {
-    __extends(Viewport, _super);
-    function Viewport(_terminal, _viewportElement, _scrollArea, _charMeasure) {
-        var _this = _super.call(this) || this;
-        _this._terminal = _terminal;
-        _this._viewportElement = _viewportElement;
-        _this._scrollArea = _scrollArea;
-        _this._charMeasure = _charMeasure;
-        _this.scrollBarWidth = 0;
-        _this._currentRowHeight = 0;
-        _this._lastRecordedBufferLength = 0;
-        _this._lastRecordedViewportHeight = 0;
-        _this._lastRecordedBufferHeight = 0;
-        _this._lastScrollTop = 0;
-        _this._wheelPartialScroll = 0;
-        _this._refreshAnimationFrame = null;
-        _this._ignoreNextScrollEvent = false;
-        _this.scrollBarWidth = (_this._viewportElement.offsetWidth - _this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
-        _this.register(Lifecycle_2.addDisposableDomListener(_this._viewportElement, 'scroll', _this._onScroll.bind(_this)));
-        setTimeout(function () { return _this.syncScrollArea(); }, 0);
-        return _this;
-    }
-    Viewport.prototype.onThemeChanged = function (colors) {
-        this._viewportElement.style.backgroundColor = colors.background.css;
-    };
-    Viewport.prototype._refresh = function () {
-        var _this = this;
-        if (this._refreshAnimationFrame === null) {
-            this._refreshAnimationFrame = requestAnimationFrame(function () { return _this._innerRefresh(); });
-        }
-    };
-    Viewport.prototype._innerRefresh = function () {
-        if (this._charMeasure.height > 0) {
-            this._currentRowHeight = this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
-            this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;
-            var newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._terminal.renderer.dimensions.canvasHeight);
-            if (this._lastRecordedBufferHeight !== newBufferHeight) {
-                this._lastRecordedBufferHeight = newBufferHeight;
-                this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';
-            }
-        }
-        var scrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
-        if (this._viewportElement.scrollTop !== scrollTop) {
-            this._ignoreNextScrollEvent = true;
-            this._viewportElement.scrollTop = scrollTop;
-        }
-        this._refreshAnimationFrame = null;
-    };
-    Viewport.prototype.syncScrollArea = function () {
-        if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) {
-            this._lastRecordedBufferLength = this._terminal.buffer.lines.length;
-            this._refresh();
-            return;
-        }
-        if (this._lastRecordedViewportHeight !== this._terminal.renderer.dimensions.canvasHeight) {
-            this._refresh();
-            return;
-        }
-        var newScrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;
-        if (this._lastScrollTop !== newScrollTop) {
-            this._refresh();
-            return;
-        }
-        if (this._lastScrollTop !== this._viewportElement.scrollTop) {
-            this._refresh();
-            return;
-        }
-        if (this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {
-            this._refresh();
-            return;
-        }
-    };
-    Viewport.prototype._onScroll = function (ev) {
-        this._lastScrollTop = this._viewportElement.scrollTop;
-        if (!this._viewportElement.offsetParent) {
-            return;
-        }
-        if (this._ignoreNextScrollEvent) {
-            this._ignoreNextScrollEvent = false;
-            return;
-        }
-        var newRow = Math.round(this._lastScrollTop / this._currentRowHeight);
-        var diff = newRow - this._terminal.buffer.ydisp;
-        this._terminal.scrollLines(diff, true);
-    };
-    Viewport.prototype.onWheel = function (ev) {
-        var amount = this._getPixelsScrolled(ev);
-        if (amount === 0) {
-            return;
-        }
-        this._viewportElement.scrollTop += amount;
-        ev.preventDefault();
-    };
-    Viewport.prototype._getPixelsScrolled = function (ev) {
-        if (ev.deltaY === 0) {
-            return 0;
-        }
-        var amount = ev.deltaY;
-        if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
-            amount *= this._currentRowHeight;
-        }
-        else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
-            amount *= this._currentRowHeight * this._terminal.rows;
-        }
-        return amount;
-    };
-    Viewport.prototype.getLinesScrolled = function (ev) {
-        if (ev.deltaY === 0) {
-            return 0;
-        }
-        var amount = ev.deltaY;
-        if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
-            amount /= this._currentRowHeight + 0.0;
-            this._wheelPartialScroll += amount;
-            amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
-            this._wheelPartialScroll %= 1;
-        }
-        else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
-            amount *= this._terminal.rows;
-        }
-        return amount;
-    };
-    Viewport.prototype.onTouchStart = function (ev) {
-        this._lastTouchY = ev.touches[0].pageY;
-    };
-    Viewport.prototype.onTouchMove = function (ev) {
-        var deltaY = this._lastTouchY - ev.touches[0].pageY;
-        this._lastTouchY = ev.touches[0].pageY;
-        if (deltaY === 0) {
-            return;
-        }
-        this._viewportElement.scrollTop += deltaY;
-        ev.preventDefault();
-    };
-    return Viewport;
-}(Lifecycle_1.Disposable));
-exports.Viewport = Viewport;
-
-},{"./common/Lifecycle":26,"./ui/Lifecycle":55}],21:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Buffer_1 = require("./Buffer");
-function applyWindowsMode(terminal) {
-    return terminal.onLineFeed(function () {
-        var line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
-        var lastChar = line.get(terminal.cols - 1);
-        if (lastChar[Buffer_1.CHAR_DATA_CODE_INDEX] !== Buffer_1.NULL_CELL_CODE && lastChar[Buffer_1.CHAR_DATA_CODE_INDEX] !== Buffer_1.WHITESPACE_CELL_CODE) {
-            var nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
-            nextLine.isWrapped = true;
-        }
-    });
-}
-exports.applyWindowsMode = applyWindowsMode;
-
-},{"./Buffer":2}],22:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var EventEmitter2_1 = require("./EventEmitter2");
-var CircularList = (function () {
-    function CircularList(_maxLength) {
-        this._maxLength = _maxLength;
-        this.onDeleteEmitter = new EventEmitter2_1.EventEmitter2();
-        this.onInsertEmitter = new EventEmitter2_1.EventEmitter2();
-        this.onTrimEmitter = new EventEmitter2_1.EventEmitter2();
-        this._array = new Array(this._maxLength);
-        this._startIndex = 0;
-        this._length = 0;
-    }
-    Object.defineProperty(CircularList.prototype, "onDelete", {
-        get: function () { return this.onDeleteEmitter.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(CircularList.prototype, "onInsert", {
-        get: function () { return this.onInsertEmitter.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(CircularList.prototype, "onTrim", {
-        get: function () { return this.onTrimEmitter.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(CircularList.prototype, "maxLength", {
-        get: function () {
-            return this._maxLength;
-        },
-        set: function (newMaxLength) {
-            if (this._maxLength === newMaxLength) {
-                return;
-            }
-            var newArray = new Array(newMaxLength);
-            for (var i = 0; i < Math.min(newMaxLength, this.length); i++) {
-                newArray[i] = this._array[this._getCyclicIndex(i)];
-            }
-            this._array = newArray;
-            this._maxLength = newMaxLength;
-            this._startIndex = 0;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(CircularList.prototype, "length", {
-        get: function () {
-            return this._length;
-        },
-        set: function (newLength) {
-            if (newLength > this._length) {
-                for (var i = this._length; i < newLength; i++) {
-                    this._array[i] = undefined;
-                }
-            }
-            this._length = newLength;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    CircularList.prototype.get = function (index) {
-        return this._array[this._getCyclicIndex(index)];
-    };
-    CircularList.prototype.set = function (index, value) {
-        this._array[this._getCyclicIndex(index)] = value;
-    };
-    CircularList.prototype.push = function (value) {
-        this._array[this._getCyclicIndex(this._length)] = value;
-        if (this._length === this._maxLength) {
-            this._startIndex = ++this._startIndex % this._maxLength;
-            this.onTrimEmitter.fire(1);
-        }
-        else {
-            this._length++;
-        }
-    };
-    CircularList.prototype.recycle = function () {
-        if (this._length !== this._maxLength) {
-            throw new Error('Can only recycle when the buffer is full');
-        }
-        this._startIndex = ++this._startIndex % this._maxLength;
-        this.onTrimEmitter.fire(1);
-        return this._array[this._getCyclicIndex(this._length - 1)];
-    };
-    Object.defineProperty(CircularList.prototype, "isFull", {
-        get: function () {
-            return this._length === this._maxLength;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    CircularList.prototype.pop = function () {
-        return this._array[this._getCyclicIndex(this._length-- - 1)];
-    };
-    CircularList.prototype.splice = function (start, deleteCount) {
-        var items = [];
-        for (var _i = 2; _i < arguments.length; _i++) {
-            items[_i - 2] = arguments[_i];
-        }
-        if (deleteCount) {
-            for (var i = start; i < this._length - deleteCount; i++) {
-                this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];
-            }
-            this._length -= deleteCount;
-        }
-        for (var i = this._length - 1; i >= start; i--) {
-            this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
-        }
-        for (var i = 0; i < items.length; i++) {
-            this._array[this._getCyclicIndex(start + i)] = items[i];
-        }
-        if (this._length + items.length > this._maxLength) {
-            var countToTrim = (this._length + items.length) - this._maxLength;
-            this._startIndex += countToTrim;
-            this._length = this._maxLength;
-            this.onTrimEmitter.fire(countToTrim);
-        }
-        else {
-            this._length += items.length;
-        }
-    };
-    CircularList.prototype.trimStart = function (count) {
-        if (count > this._length) {
-            count = this._length;
-        }
-        this._startIndex += count;
-        this._length -= count;
-        this.onTrimEmitter.fire(count);
-    };
-    CircularList.prototype.shiftElements = function (start, count, offset) {
-        if (count <= 0) {
-            return;
-        }
-        if (start < 0 || start >= this._length) {
-            throw new Error('start argument out of range');
-        }
-        if (start + offset < 0) {
-            throw new Error('Cannot shift elements in list beyond index 0');
-        }
-        if (offset > 0) {
-            for (var i = count - 1; i >= 0; i--) {
-                this.set(start + i + offset, this.get(start + i));
-            }
-            var expandListBy = (start + count + offset) - this._length;
-            if (expandListBy > 0) {
-                this._length += expandListBy;
-                while (this._length > this._maxLength) {
-                    this._length--;
-                    this._startIndex++;
-                    this.onTrimEmitter.fire(1);
-                }
-            }
-        }
-        else {
-            for (var i = 0; i < count; i++) {
-                this.set(start + i + offset, this.get(start + i));
-            }
-        }
-    };
-    CircularList.prototype._getCyclicIndex = function (index) {
-        return (this._startIndex + index) % this._maxLength;
-    };
-    return CircularList;
-}());
-exports.CircularList = CircularList;
-
-},{"./EventEmitter2":25}],23:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function clone(val, depth) {
-    if (depth === void 0) { depth = 5; }
-    if (typeof val !== 'object') {
-        return val;
-    }
-    if (val === null) {
-        return null;
-    }
-    var clonedObject = Array.isArray(val) ? [] : {};
-    for (var key in val) {
-        clonedObject[key] = depth <= 1 ? val[key] : clone(val[key], depth - 1);
-    }
-    return clonedObject;
-}
-exports.clone = clone;
-
-},{}],24:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Lifecycle_1 = require("./Lifecycle");
-var EventEmitter = (function (_super) {
-    __extends(EventEmitter, _super);
-    function EventEmitter() {
-        var _this = _super.call(this) || this;
-        _this._events = _this._events || {};
-        return _this;
-    }
-    EventEmitter.prototype.on = function (type, listener) {
-        this._events[type] = this._events[type] || [];
-        this._events[type].push(listener);
-    };
-    EventEmitter.prototype.addDisposableListener = function (type, handler) {
-        var _this = this;
-        this.on(type, handler);
-        var disposed = false;
-        return {
-            dispose: function () {
-                if (disposed) {
-                    return;
-                }
-                _this.off(type, handler);
-                disposed = true;
-            }
-        };
-    };
-    EventEmitter.prototype.off = function (type, listener) {
-        if (!this._events[type]) {
-            return;
-        }
-        var obj = this._events[type];
-        var i = obj.length;
-        while (i--) {
-            if (obj[i] === listener) {
-                obj.splice(i, 1);
-                return;
-            }
-        }
-    };
-    EventEmitter.prototype.removeAllListeners = function (type) {
-        if (this._events[type]) {
-            delete this._events[type];
-        }
-    };
-    EventEmitter.prototype.emit = function (type) {
-        var args = [];
-        for (var _i = 1; _i < arguments.length; _i++) {
-            args[_i - 1] = arguments[_i];
-        }
-        if (!this._events[type]) {
-            return;
-        }
-        var obj = this._events[type];
-        for (var i = 0; i < obj.length; i++) {
-            obj[i].apply(this, args);
-        }
-    };
-    EventEmitter.prototype.emitMayRemoveListeners = function (type) {
-        var args = [];
-        for (var _i = 1; _i < arguments.length; _i++) {
-            args[_i - 1] = arguments[_i];
-        }
-        if (!this._events[type]) {
-            return;
-        }
-        var obj = this._events[type];
-        var length = obj.length;
-        for (var i = 0; i < obj.length; i++) {
-            obj[i].apply(this, args);
-            i -= length - obj.length;
-            length = obj.length;
-        }
-    };
-    EventEmitter.prototype.listeners = function (type) {
-        return this._events[type] || [];
-    };
-    EventEmitter.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        this._events = {};
-    };
-    return EventEmitter;
-}(Lifecycle_1.Disposable));
-exports.EventEmitter = EventEmitter;
-
-},{"./Lifecycle":26}],25:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var EventEmitter2 = (function () {
-    function EventEmitter2() {
-        this._listeners = [];
-    }
-    Object.defineProperty(EventEmitter2.prototype, "event", {
-        get: function () {
-            var _this = this;
-            if (!this._event) {
-                this._event = function (listener) {
-                    _this._listeners.push(listener);
-                    var disposable = {
-                        dispose: function () {
-                            for (var i = 0; i < _this._listeners.length; i++) {
-                                if (_this._listeners[i] === listener) {
-                                    _this._listeners.splice(i, 1);
-                                    return;
-                                }
-                            }
-                        }
-                    };
-                    return disposable;
-                };
-            }
-            return this._event;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    EventEmitter2.prototype.fire = function (data) {
-        var queue = [];
-        for (var i = 0; i < this._listeners.length; i++) {
-            queue.push(this._listeners[i]);
-        }
-        for (var i = 0; i < queue.length; i++) {
-            queue[i].call(undefined, data);
-        }
-    };
-    return EventEmitter2;
-}());
-exports.EventEmitter2 = EventEmitter2;
-
-},{}],26:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Disposable = (function () {
-    function Disposable() {
-        this._disposables = [];
-        this._isDisposed = false;
-    }
-    Disposable.prototype.dispose = function () {
-        this._isDisposed = true;
-        this._disposables.forEach(function (d) { return d.dispose(); });
-        this._disposables.length = 0;
-    };
-    Disposable.prototype.register = function (d) {
-        this._disposables.push(d);
-    };
-    Disposable.prototype.unregister = function (d) {
-        var index = this._disposables.indexOf(d);
-        if (index !== -1) {
-            this._disposables.splice(index, 1);
-        }
-    };
-    return Disposable;
-}());
-exports.Disposable = Disposable;
-
-},{}],27:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var isNode = (typeof navigator === 'undefined') ? true : false;
-var userAgent = (isNode) ? 'node' : navigator.userAgent;
-var platform = (isNode) ? 'node' : navigator.platform;
-exports.isFirefox = !!~userAgent.indexOf('Firefox');
-exports.isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
-exports.isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');
-exports.isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
-exports.isIpad = platform === 'iPad';
-exports.isIphone = platform === 'iPhone';
-exports.isMSWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
-exports.isLinux = platform.indexOf('Linux') >= 0;
-function contains(arr, el) {
-    return arr.indexOf(el) >= 0;
-}
-
-},{}],28:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function fill(array, value, start, end) {
-    if (array.fill) {
-        return array.fill(value, start, end);
-    }
-    return fillFallback(array, value, start, end);
-}
-exports.fill = fill;
-function fillFallback(array, value, start, end) {
-    if (start === void 0) { start = 0; }
-    if (end === void 0) { end = array.length; }
-    if (start >= array.length) {
-        return array;
-    }
-    start = (array.length + start) % array.length;
-    if (end >= array.length) {
-        end = array.length;
-    }
-    else {
-        end = (array.length + end) % array.length;
-    }
-    for (var i = start; i < end; ++i) {
-        array[i] = value;
-    }
-    return array;
-}
-exports.fillFallback = fillFallback;
-function concat(a, b) {
-    var result = new a.constructor(a.length + b.length);
-    result.set(a);
-    result.set(b, a.length);
-    return result;
-}
-exports.concat = concat;
-
-},{}],29:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var C0;
-(function (C0) {
-    C0.NUL = '\x00';
-    C0.SOH = '\x01';
-    C0.STX = '\x02';
-    C0.ETX = '\x03';
-    C0.EOT = '\x04';
-    C0.ENQ = '\x05';
-    C0.ACK = '\x06';
-    C0.BEL = '\x07';
-    C0.BS = '\x08';
-    C0.HT = '\x09';
-    C0.LF = '\x0a';
-    C0.VT = '\x0b';
-    C0.FF = '\x0c';
-    C0.CR = '\x0d';
-    C0.SO = '\x0e';
-    C0.SI = '\x0f';
-    C0.DLE = '\x10';
-    C0.DC1 = '\x11';
-    C0.DC2 = '\x12';
-    C0.DC3 = '\x13';
-    C0.DC4 = '\x14';
-    C0.NAK = '\x15';
-    C0.SYN = '\x16';
-    C0.ETB = '\x17';
-    C0.CAN = '\x18';
-    C0.EM = '\x19';
-    C0.SUB = '\x1a';
-    C0.ESC = '\x1b';
-    C0.FS = '\x1c';
-    C0.GS = '\x1d';
-    C0.RS = '\x1e';
-    C0.US = '\x1f';
-    C0.SP = '\x20';
-    C0.DEL = '\x7f';
-})(C0 = exports.C0 || (exports.C0 = {}));
-var C1;
-(function (C1) {
-    C1.PAD = '\x80';
-    C1.HOP = '\x81';
-    C1.BPH = '\x82';
-    C1.NBH = '\x83';
-    C1.IND = '\x84';
-    C1.NEL = '\x85';
-    C1.SSA = '\x86';
-    C1.ESA = '\x87';
-    C1.HTS = '\x88';
-    C1.HTJ = '\x89';
-    C1.VTS = '\x8a';
-    C1.PLD = '\x8b';
-    C1.PLU = '\x8c';
-    C1.RI = '\x8d';
-    C1.SS2 = '\x8e';
-    C1.SS3 = '\x8f';
-    C1.DCS = '\x90';
-    C1.PU1 = '\x91';
-    C1.PU2 = '\x92';
-    C1.STS = '\x93';
-    C1.CCH = '\x94';
-    C1.MW = '\x95';
-    C1.SPA = '\x96';
-    C1.EPA = '\x97';
-    C1.SOS = '\x98';
-    C1.SGCI = '\x99';
-    C1.SCI = '\x9a';
-    C1.CSI = '\x9b';
-    C1.ST = '\x9c';
-    C1.OSC = '\x9d';
-    C1.PM = '\x9e';
-    C1.APC = '\x9f';
-})(C1 = exports.C1 || (exports.C1 = {}));
-
-},{}],30:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.CHARSETS = {};
-exports.DEFAULT_CHARSET = exports.CHARSETS['B'];
-exports.CHARSETS['0'] = {
-    '`': '\u25c6',
-    'a': '\u2592',
-    'b': '\u0009',
-    'c': '\u000c',
-    'd': '\u000d',
-    'e': '\u000a',
-    'f': '\u00b0',
-    'g': '\u00b1',
-    'h': '\u2424',
-    'i': '\u000b',
-    'j': '\u2518',
-    'k': '\u2510',
-    'l': '\u250c',
-    'm': '\u2514',
-    'n': '\u253c',
-    'o': '\u23ba',
-    'p': '\u23bb',
-    'q': '\u2500',
-    'r': '\u23bc',
-    's': '\u23bd',
-    't': '\u251c',
-    'u': '\u2524',
-    'v': '\u2534',
-    'w': '\u252c',
-    'x': '\u2502',
-    'y': '\u2264',
-    'z': '\u2265',
-    '{': '\u03c0',
-    '|': '\u2260',
-    '}': '\u00a3',
-    '~': '\u00b7'
-};
-exports.CHARSETS['A'] = {
-    '#': '£'
-};
-exports.CHARSETS['B'] = null;
-exports.CHARSETS['4'] = {
-    '#': '£',
-    '@': '¾',
-    '[': 'ij',
-    '\\': '½',
-    ']': '|',
-    '{': '¨',
-    '|': 'f',
-    '}': '¼',
-    '~': '´'
-};
-exports.CHARSETS['C'] =
-    exports.CHARSETS['5'] = {
-        '[': 'Ä',
-        '\\': 'Ö',
-        ']': 'Å',
-        '^': 'Ü',
-        '`': 'é',
-        '{': 'ä',
-        '|': 'ö',
-        '}': 'å',
-        '~': 'ü'
-    };
-exports.CHARSETS['R'] = {
-    '#': '£',
-    '@': 'à',
-    '[': '°',
-    '\\': 'ç',
-    ']': '§',
-    '{': 'é',
-    '|': 'ù',
-    '}': 'è',
-    '~': '¨'
-};
-exports.CHARSETS['Q'] = {
-    '@': 'à',
-    '[': 'â',
-    '\\': 'ç',
-    ']': 'ê',
-    '^': 'î',
-    '`': 'ô',
-    '{': 'é',
-    '|': 'ù',
-    '}': 'è',
-    '~': 'û'
-};
-exports.CHARSETS['K'] = {
-    '@': '§',
-    '[': 'Ä',
-    '\\': 'Ö',
-    ']': 'Ü',
-    '{': 'ä',
-    '|': 'ö',
-    '}': 'ü',
-    '~': 'ß'
-};
-exports.CHARSETS['Y'] = {
-    '#': '£',
-    '@': '§',
-    '[': '°',
-    '\\': 'ç',
-    ']': 'é',
-    '`': 'ù',
-    '{': 'à',
-    '|': 'ò',
-    '}': 'è',
-    '~': 'ì'
-};
-exports.CHARSETS['E'] =
-    exports.CHARSETS['6'] = {
-        '@': 'Ä',
-        '[': 'Æ',
-        '\\': 'Ø',
-        ']': 'Å',
-        '^': 'Ü',
-        '`': 'ä',
-        '{': 'æ',
-        '|': 'ø',
-        '}': 'å',
-        '~': 'ü'
-    };
-exports.CHARSETS['Z'] = {
-    '#': '£',
-    '@': '§',
-    '[': '¡',
-    '\\': 'Ñ',
-    ']': '¿',
-    '{': '°',
-    '|': 'ñ',
-    '}': 'ç'
-};
-exports.CHARSETS['H'] =
-    exports.CHARSETS['7'] = {
-        '@': 'É',
-        '[': 'Ä',
-        '\\': 'Ö',
-        ']': 'Å',
-        '^': 'Ü',
-        '`': 'é',
-        '{': 'ä',
-        '|': 'ö',
-        '}': 'å',
-        '~': 'ü'
-    };
-exports.CHARSETS['='] = {
-    '#': 'ù',
-    '@': 'à',
-    '[': 'é',
-    '\\': 'ç',
-    ']': 'ê',
-    '^': 'î',
-    '_': 'è',
-    '`': 'ô',
-    '{': 'ä',
-    '|': 'ö',
-    '}': 'ü',
-    '~': 'û'
-};
-
-},{}],31:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var EscapeSequences_1 = require("../../common/data/EscapeSequences");
-var KEYCODE_KEY_MAPPINGS = {
-    48: ['0', ')'],
-    49: ['1', '!'],
-    50: ['2', '@'],
-    51: ['3', '#'],
-    52: ['4', '$'],
-    53: ['5', '%'],
-    54: ['6', '^'],
-    55: ['7', '&'],
-    56: ['8', '*'],
-    57: ['9', '('],
-    186: [';', ':'],
-    187: ['=', '+'],
-    188: [',', '<'],
-    189: ['-', '_'],
-    190: ['.', '>'],
-    191: ['/', '?'],
-    192: ['`', '~'],
-    219: ['[', '{'],
-    220: ['\\', '|'],
-    221: [']', '}'],
-    222: ['\'', '"']
-};
-function evaluateKeyboardEvent(ev, applicationCursorMode, isMac, macOptionIsMeta) {
-    var result = {
-        type: 0,
-        cancel: false,
-        key: undefined
-    };
-    var modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);
-    switch (ev.keyCode) {
-        case 0:
-            if (ev.key === 'UIKeyInputUpArrow') {
-                if (applicationCursorMode) {
-                    result.key = EscapeSequences_1.C0.ESC + 'OA';
-                }
-                else {
-                    result.key = EscapeSequences_1.C0.ESC + '[A';
-                }
-            }
-            else if (ev.key === 'UIKeyInputLeftArrow') {
-                if (applicationCursorMode) {
-                    result.key = EscapeSequences_1.C0.ESC + 'OD';
-                }
-                else {
-                    result.key = EscapeSequences_1.C0.ESC + '[D';
-                }
-            }
-            else if (ev.key === 'UIKeyInputRightArrow') {
-                if (applicationCursorMode) {
-                    result.key = EscapeSequences_1.C0.ESC + 'OC';
-                }
-                else {
-                    result.key = EscapeSequences_1.C0.ESC + '[C';
-                }
-            }
-            else if (ev.key === 'UIKeyInputDownArrow') {
-                if (applicationCursorMode) {
-                    result.key = EscapeSequences_1.C0.ESC + 'OB';
-                }
-                else {
-                    result.key = EscapeSequences_1.C0.ESC + '[B';
-                }
-            }
-            break;
-        case 8:
-            if (ev.shiftKey) {
-                result.key = EscapeSequences_1.C0.BS;
-                break;
-            }
-            else if (ev.altKey) {
-                result.key = EscapeSequences_1.C0.ESC + EscapeSequences_1.C0.DEL;
-                break;
-            }
-            result.key = EscapeSequences_1.C0.DEL;
-            break;
-        case 9:
-            if (ev.shiftKey) {
-                result.key = EscapeSequences_1.C0.ESC + '[Z';
-                break;
-            }
-            result.key = EscapeSequences_1.C0.HT;
-            result.cancel = true;
-            break;
-        case 13:
-            result.key = EscapeSequences_1.C0.CR;
-            result.cancel = true;
-            break;
-        case 27:
-            result.key = EscapeSequences_1.C0.ESC;
-            result.cancel = true;
-            break;
-        case 37:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'D';
-                if (result.key === EscapeSequences_1.C0.ESC + '[1;3D') {
-                    result.key = isMac ? EscapeSequences_1.C0.ESC + 'b' : EscapeSequences_1.C0.ESC + '[1;5D';
-                }
-            }
-            else if (applicationCursorMode) {
-                result.key = EscapeSequences_1.C0.ESC + 'OD';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[D';
-            }
-            break;
-        case 39:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'C';
-                if (result.key === EscapeSequences_1.C0.ESC + '[1;3C') {
-                    result.key = isMac ? EscapeSequences_1.C0.ESC + 'f' : EscapeSequences_1.C0.ESC + '[1;5C';
-                }
-            }
-            else if (applicationCursorMode) {
-                result.key = EscapeSequences_1.C0.ESC + 'OC';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[C';
-            }
-            break;
-        case 38:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'A';
-                if (result.key === EscapeSequences_1.C0.ESC + '[1;3A') {
-                    result.key = EscapeSequences_1.C0.ESC + '[1;5A';
-                }
-            }
-            else if (applicationCursorMode) {
-                result.key = EscapeSequences_1.C0.ESC + 'OA';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[A';
-            }
-            break;
-        case 40:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'B';
-                if (result.key === EscapeSequences_1.C0.ESC + '[1;3B') {
-                    result.key = EscapeSequences_1.C0.ESC + '[1;5B';
-                }
-            }
-            else if (applicationCursorMode) {
-                result.key = EscapeSequences_1.C0.ESC + 'OB';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[B';
-            }
-            break;
-        case 45:
-            if (!ev.shiftKey && !ev.ctrlKey) {
-                result.key = EscapeSequences_1.C0.ESC + '[2~';
-            }
-            break;
-        case 46:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[3;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[3~';
-            }
-            break;
-        case 36:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'H';
-            }
-            else if (applicationCursorMode) {
-                result.key = EscapeSequences_1.C0.ESC + 'OH';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[H';
-            }
-            break;
-        case 35:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'F';
-            }
-            else if (applicationCursorMode) {
-                result.key = EscapeSequences_1.C0.ESC + 'OF';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[F';
-            }
-            break;
-        case 33:
-            if (ev.shiftKey) {
-                result.type = 2;
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[5~';
-            }
-            break;
-        case 34:
-            if (ev.shiftKey) {
-                result.type = 3;
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[6~';
-            }
-            break;
-        case 112:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'P';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + 'OP';
-            }
-            break;
-        case 113:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'Q';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + 'OQ';
-            }
-            break;
-        case 114:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'R';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + 'OR';
-            }
-            break;
-        case 115:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[1;' + (modifiers + 1) + 'S';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + 'OS';
-            }
-            break;
-        case 116:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[15;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[15~';
-            }
-            break;
-        case 117:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[17;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[17~';
-            }
-            break;
-        case 118:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[18;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[18~';
-            }
-            break;
-        case 119:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[19;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[19~';
-            }
-            break;
-        case 120:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[20;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[20~';
-            }
-            break;
-        case 121:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[21;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[21~';
-            }
-            break;
-        case 122:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[23;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[23~';
-            }
-            break;
-        case 123:
-            if (modifiers) {
-                result.key = EscapeSequences_1.C0.ESC + '[24;' + (modifiers + 1) + '~';
-            }
-            else {
-                result.key = EscapeSequences_1.C0.ESC + '[24~';
-            }
-            break;
-        default:
-            if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
-                if (ev.keyCode >= 65 && ev.keyCode <= 90) {
-                    result.key = String.fromCharCode(ev.keyCode - 64);
-                }
-                else if (ev.keyCode === 32) {
-                    result.key = String.fromCharCode(0);
-                }
-                else if (ev.keyCode >= 51 && ev.keyCode <= 55) {
-                    result.key = String.fromCharCode(ev.keyCode - 51 + 27);
-                }
-                else if (ev.keyCode === 56) {
-                    result.key = String.fromCharCode(127);
-                }
-                else if (ev.keyCode === 219) {
-                    result.key = String.fromCharCode(27);
-                }
-                else if (ev.keyCode === 220) {
-                    result.key = String.fromCharCode(28);
-                }
-                else if (ev.keyCode === 221) {
-                    result.key = String.fromCharCode(29);
-                }
-            }
-            else if ((!isMac || macOptionIsMeta) && ev.altKey && !ev.metaKey) {
-                var keyMapping = KEYCODE_KEY_MAPPINGS[ev.keyCode];
-                var key = keyMapping && keyMapping[!ev.shiftKey ? 0 : 1];
-                if (key) {
-                    result.key = EscapeSequences_1.C0.ESC + key;
-                }
-                else if (ev.keyCode >= 65 && ev.keyCode <= 90) {
-                    var keyCode = ev.ctrlKey ? ev.keyCode - 64 : ev.keyCode + 32;
-                    result.key = EscapeSequences_1.C0.ESC + String.fromCharCode(keyCode);
-                }
-            }
-            else if (isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {
-                if (ev.keyCode === 65) {
-                    result.type = 1;
-                }
-            }
-            else if (ev.key && !ev.ctrlKey && !ev.altKey && !ev.metaKey && ev.keyCode >= 48 && ev.key.length === 1) {
-                result.key = ev.key;
-            }
-            else if (ev.key && ev.ctrlKey) {
-                if (ev.key === '_') {
-                    result.key = EscapeSequences_1.C0.US;
-                }
-            }
-            break;
-    }
-    return result;
-}
-exports.evaluateKeyboardEvent = evaluateKeyboardEvent;
-
-},{"../../common/data/EscapeSequences":29}],32:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var StringToUtf32 = (function () {
-    function StringToUtf32() {
-        this._interim = 0;
-    }
-    StringToUtf32.prototype.clear = function () {
-        this._interim = 0;
-    };
-    StringToUtf32.prototype.decode = function (input, target) {
-        var length = input.length;
-        if (!length) {
-            return 0;
-        }
-        var size = 0;
-        var startPos = 0;
-        if (this._interim) {
-            var second = input.charCodeAt(startPos++);
-            if (0xDC00 <= second && second <= 0xDFFF) {
-                target[size++] = (this._interim - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
-            }
-            else {
-                target[size++] = this._interim;
-                target[size++] = second;
-            }
-            this._interim = 0;
-        }
-        for (var i = startPos; i < length; ++i) {
-            var code = input.charCodeAt(i);
-            if (0xD800 <= code && code <= 0xDBFF) {
-                if (++i >= length) {
-                    this._interim = code;
-                    return size;
-                }
-                var second = input.charCodeAt(i);
-                if (0xDC00 <= second && second <= 0xDFFF) {
-                    target[size++] = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
-                }
-                else {
-                    target[size++] = code;
-                    target[size++] = second;
-                }
-                continue;
-            }
-            target[size++] = code;
-        }
-        return size;
-    };
-    return StringToUtf32;
-}());
-exports.StringToUtf32 = StringToUtf32;
-function stringFromCodePoint(codePoint) {
-    if (codePoint > 0xFFFF) {
-        codePoint -= 0x10000;
-        return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);
-    }
-    return String.fromCharCode(codePoint);
-}
-exports.stringFromCodePoint = stringFromCodePoint;
-function utf32ToString(data, start, end) {
-    if (start === void 0) { start = 0; }
-    if (end === void 0) { end = data.length; }
-    var result = '';
-    for (var i = start; i < end; ++i) {
-        var codepoint = data[i];
-        if (codepoint > 0xFFFF) {
-            codepoint -= 0x10000;
-            result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);
-        }
-        else {
-            result += String.fromCharCode(codepoint);
-        }
-    }
-    return result;
-}
-exports.utf32ToString = utf32ToString;
-
-},{}],33:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var EscapeSequences_1 = require("../common/data/EscapeSequences");
-var AltClickHandler = (function () {
-    function AltClickHandler(_mouseEvent, _terminal) {
-        var _a;
-        this._mouseEvent = _mouseEvent;
-        this._terminal = _terminal;
-        this._lines = this._terminal.buffer.lines;
-        this._startCol = this._terminal.buffer.x;
-        this._startRow = this._terminal.buffer.y;
-        var coordinates = this._terminal.mouseHelper.getCoords(this._mouseEvent, this._terminal.element, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows, false);
-        if (coordinates) {
-            _a = coordinates.map(function (coordinate) {
-                return coordinate - 1;
-            }), this._endCol = _a[0], this._endRow = _a[1];
-        }
-    }
-    AltClickHandler.prototype.move = function () {
-        if (this._mouseEvent.altKey && this._endCol !== undefined && this._endRow !== undefined) {
-            this._terminal.handler(this._arrowSequences());
-        }
-    };
-    AltClickHandler.prototype._arrowSequences = function () {
-        if (!this._terminal.buffer.hasScrollback) {
-            return this._resetStartingRow() + this._moveToRequestedRow() + this._moveToRequestedCol();
-        }
-        return this._moveHorizontallyOnly();
-    };
-    AltClickHandler.prototype._resetStartingRow = function () {
-        if (this._moveToRequestedRow().length === 0) {
-            return '';
-        }
-        return repeat(this._bufferLine(this._startCol, this._startRow, this._startCol, this._startRow - this._wrappedRowsForRow(this._startRow), false).length, this._sequence("D"));
-    };
-    AltClickHandler.prototype._moveToRequestedRow = function () {
-        var startRow = this._startRow - this._wrappedRowsForRow(this._startRow);
-        var endRow = this._endRow - this._wrappedRowsForRow(this._endRow);
-        var rowsToMove = Math.abs(startRow - endRow) - this._wrappedRowsCount();
-        return repeat(rowsToMove, this._sequence(this._verticalDirection()));
-    };
-    AltClickHandler.prototype._moveToRequestedCol = function () {
-        var startRow;
-        if (this._moveToRequestedRow().length > 0) {
-            startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
-        }
-        else {
-            startRow = this._startRow;
-        }
-        var endRow = this._endRow;
-        var direction = this._horizontalDirection();
-        return repeat(this._bufferLine(this._startCol, startRow, this._endCol, endRow, direction === "C").length, this._sequence(direction));
-    };
-    AltClickHandler.prototype._moveHorizontallyOnly = function () {
-        var direction = this._horizontalDirection();
-        return repeat(Math.abs(this._startCol - this._endCol), this._sequence(direction));
-    };
-    AltClickHandler.prototype._wrappedRowsCount = function () {
-        var wrappedRows = 0;
-        var startRow = this._startRow - this._wrappedRowsForRow(this._startRow);
-        var endRow = this._endRow - this._wrappedRowsForRow(this._endRow);
-        for (var i = 0; i < Math.abs(startRow - endRow); i++) {
-            var direction = this._verticalDirection() === "A" ? -1 : 1;
-            if (this._lines.get(startRow + (direction * i)).isWrapped) {
-                wrappedRows++;
-            }
-        }
-        return wrappedRows;
-    };
-    AltClickHandler.prototype._wrappedRowsForRow = function (currentRow) {
-        var rowCount = 0;
-        var lineWraps = this._lines.get(currentRow).isWrapped;
-        while (lineWraps && currentRow >= 0 && currentRow < this._terminal.rows) {
-            rowCount++;
-            currentRow--;
-            lineWraps = this._lines.get(currentRow).isWrapped;
-        }
-        return rowCount;
-    };
-    AltClickHandler.prototype._horizontalDirection = function () {
-        var startRow;
-        if (this._moveToRequestedRow().length > 0) {
-            startRow = this._endRow - this._wrappedRowsForRow(this._endRow);
-        }
-        else {
-            startRow = this._startRow;
-        }
-        if ((this._startCol < this._endCol &&
-            startRow <= this._endRow) ||
-            (this._startCol >= this._endCol &&
-                startRow < this._endRow)) {
-            return "C";
-        }
-        return "D";
-    };
-    AltClickHandler.prototype._verticalDirection = function () {
-        if (this._startRow > this._endRow) {
-            return "A";
-        }
-        return "B";
-    };
-    AltClickHandler.prototype._bufferLine = function (startCol, startRow, endCol, endRow, forward) {
-        var currentCol = startCol;
-        var currentRow = startRow;
-        var bufferStr = '';
-        while (currentCol !== endCol || currentRow !== endRow) {
-            currentCol += forward ? 1 : -1;
-            if (forward && currentCol > this._terminal.cols - 1) {
-                bufferStr += this._terminal.buffer.translateBufferLineToString(currentRow, false, startCol, currentCol);
-                currentCol = 0;
-                startCol = 0;
-                currentRow++;
-            }
-            else if (!forward && currentCol < 0) {
-                bufferStr += this._terminal.buffer.translateBufferLineToString(currentRow, false, 0, startCol + 1);
-                currentCol = this._terminal.cols - 1;
-                startCol = currentCol;
-                currentRow--;
-            }
-        }
-        return bufferStr + this._terminal.buffer.translateBufferLineToString(currentRow, false, startCol, currentCol);
-    };
-    AltClickHandler.prototype._sequence = function (direction) {
-        var mod = this._terminal.applicationCursor ? 'O' : '[';
-        return EscapeSequences_1.C0.ESC + mod + direction;
-    };
-    return AltClickHandler;
-}());
-exports.AltClickHandler = AltClickHandler;
-function repeat(count, str) {
-    count = Math.floor(count);
-    var rpt = '';
-    for (var i = 0; i < count; i++) {
-        rpt += str;
-    }
-    return rpt;
-}
-
-},{"../common/data/EscapeSequences":29}],34:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Terminal_1 = require("../Terminal");
-var Strings = require("../Strings");
-var Terminal = (function () {
-    function Terminal(options) {
-        this._core = new Terminal_1.Terminal(options);
-    }
-    Object.defineProperty(Terminal.prototype, "onCursorMove", {
-        get: function () { return this._core.onCursorMove; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onLineFeed", {
-        get: function () { return this._core.onLineFeed; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onSelectionChange", {
-        get: function () { return this._core.onSelectionChange; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onData", {
-        get: function () { return this._core.onData; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onTitleChange", {
-        get: function () { return this._core.onTitleChange; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onScroll", {
-        get: function () { return this._core.onScroll; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onKey", {
-        get: function () { return this._core.onKey; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onRender", {
-        get: function () { return this._core.onRender; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "onResize", {
-        get: function () { return this._core.onResize; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "element", {
-        get: function () { return this._core.element; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "textarea", {
-        get: function () { return this._core.textarea; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "rows", {
-        get: function () { return this._core.rows; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "cols", {
-        get: function () { return this._core.cols; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Terminal.prototype, "markers", {
-        get: function () { return this._core.markers; },
-        enumerable: true,
-        configurable: true
-    });
-    Terminal.prototype.blur = function () {
-        this._core.blur();
-    };
-    Terminal.prototype.focus = function () {
-        this._core.focus();
-    };
-    Terminal.prototype.on = function (type, listener) {
-        this._core.on(type, listener);
-    };
-    Terminal.prototype.off = function (type, listener) {
-        this._core.off(type, listener);
-    };
-    Terminal.prototype.emit = function (type, data) {
-        this._core.emit(type, data);
-    };
-    Terminal.prototype.addDisposableListener = function (type, handler) {
-        return this._core.addDisposableListener(type, handler);
-    };
-    Terminal.prototype.resize = function (columns, rows) {
-        this._core.resize(columns, rows);
-    };
-    Terminal.prototype.writeln = function (data) {
-        this._core.writeln(data);
-    };
-    Terminal.prototype.open = function (parent) {
-        this._core.open(parent);
-    };
-    Terminal.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler) {
-        this._core.attachCustomKeyEventHandler(customKeyEventHandler);
-    };
-    Terminal.prototype.addCsiHandler = function (flag, callback) {
-        return this._core.addCsiHandler(flag, callback);
-    };
-    Terminal.prototype.addOscHandler = function (ident, callback) {
-        return this._core.addOscHandler(ident, callback);
-    };
-    Terminal.prototype.registerLinkMatcher = function (regex, handler, options) {
-        return this._core.registerLinkMatcher(regex, handler, options);
-    };
-    Terminal.prototype.deregisterLinkMatcher = function (matcherId) {
-        this._core.deregisterLinkMatcher(matcherId);
-    };
-    Terminal.prototype.registerCharacterJoiner = function (handler) {
-        return this._core.registerCharacterJoiner(handler);
-    };
-    Terminal.prototype.deregisterCharacterJoiner = function (joinerId) {
-        this._core.deregisterCharacterJoiner(joinerId);
-    };
-    Terminal.prototype.addMarker = function (cursorYOffset) {
-        return this._core.addMarker(cursorYOffset);
-    };
-    Terminal.prototype.hasSelection = function () {
-        return this._core.hasSelection();
-    };
-    Terminal.prototype.getSelection = function () {
-        return this._core.getSelection();
-    };
-    Terminal.prototype.clearSelection = function () {
-        this._core.clearSelection();
-    };
-    Terminal.prototype.selectAll = function () {
-        this._core.selectAll();
-    };
-    Terminal.prototype.selectLines = function (start, end) {
-        this._core.selectLines(start, end);
-    };
-    Terminal.prototype.dispose = function () {
-        this._core.dispose();
-    };
-    Terminal.prototype.destroy = function () {
-        this._core.destroy();
-    };
-    Terminal.prototype.scrollLines = function (amount) {
-        this._core.scrollLines(amount);
-    };
-    Terminal.prototype.scrollPages = function (pageCount) {
-        this._core.scrollPages(pageCount);
-    };
-    Terminal.prototype.scrollToTop = function () {
-        this._core.scrollToTop();
-    };
-    Terminal.prototype.scrollToBottom = function () {
-        this._core.scrollToBottom();
-    };
-    Terminal.prototype.scrollToLine = function (line) {
-        this._core.scrollToLine(line);
-    };
-    Terminal.prototype.clear = function () {
-        this._core.clear();
-    };
-    Terminal.prototype.write = function (data) {
-        this._core.write(data);
-    };
-    Terminal.prototype.getOption = function (key) {
-        return this._core.getOption(key);
-    };
-    Terminal.prototype.setOption = function (key, value) {
-        this._core.setOption(key, value);
-    };
-    Terminal.prototype.refresh = function (start, end) {
-        this._core.refresh(start, end);
-    };
-    Terminal.prototype.reset = function () {
-        this._core.reset();
-    };
-    Terminal.applyAddon = function (addon) {
-        addon.apply(Terminal);
-    };
-    Object.defineProperty(Terminal, "strings", {
-        get: function () {
-            return Strings;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    return Terminal;
-}());
-exports.Terminal = Terminal;
-
-},{"../Strings":18,"../Terminal":19}],35:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Types_1 = require("./atlas/Types");
-var CharAtlasCache_1 = require("./atlas/CharAtlasCache");
-var BufferLine_1 = require("../BufferLine");
-var Buffer_1 = require("../Buffer");
-var CharacterJoinerRegistry_1 = require("./CharacterJoinerRegistry");
-var BaseRenderLayer = (function () {
-    function BaseRenderLayer(_container, id, zIndex, _alpha, _colors) {
-        this._container = _container;
-        this._alpha = _alpha;
-        this._colors = _colors;
-        this._scaledCharWidth = 0;
-        this._scaledCharHeight = 0;
-        this._scaledCellWidth = 0;
-        this._scaledCellHeight = 0;
-        this._scaledCharLeft = 0;
-        this._scaledCharTop = 0;
-        this._currentGlyphIdentifier = {
-            chars: '',
-            code: 0,
-            bg: 0,
-            fg: 0,
-            bold: false,
-            dim: false,
-            italic: false
-        };
-        this._canvas = document.createElement('canvas');
-        this._canvas.classList.add("xterm-" + id + "-layer");
-        this._canvas.style.zIndex = zIndex.toString();
-        this._initCanvas();
-        this._container.appendChild(this._canvas);
-    }
-    BaseRenderLayer.prototype.dispose = function () {
-        this._container.removeChild(this._canvas);
-        if (this._charAtlas) {
-            this._charAtlas.dispose();
-        }
-    };
-    BaseRenderLayer.prototype._initCanvas = function () {
-        this._ctx = this._canvas.getContext('2d', { alpha: this._alpha });
-        if (!this._alpha) {
-            this.clearAll();
-        }
-    };
-    BaseRenderLayer.prototype.onOptionsChanged = function (terminal) { };
-    BaseRenderLayer.prototype.onBlur = function (terminal) { };
-    BaseRenderLayer.prototype.onFocus = function (terminal) { };
-    BaseRenderLayer.prototype.onCursorMove = function (terminal) { };
-    BaseRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) { };
-    BaseRenderLayer.prototype.onSelectionChanged = function (terminal, start, end, columnSelectMode) {
-        if (columnSelectMode === void 0) { columnSelectMode = false; }
-    };
-    BaseRenderLayer.prototype.onThemeChanged = function (terminal, colorSet) {
-        this._refreshCharAtlas(terminal, colorSet);
-    };
-    BaseRenderLayer.prototype.setTransparency = function (terminal, alpha) {
-        if (alpha === this._alpha) {
-            return;
-        }
-        var oldCanvas = this._canvas;
-        this._alpha = alpha;
-        this._canvas = this._canvas.cloneNode();
-        this._initCanvas();
-        this._container.replaceChild(this._canvas, oldCanvas);
-        this._refreshCharAtlas(terminal, this._colors);
-        this.onGridChanged(terminal, 0, terminal.rows - 1);
-    };
-    BaseRenderLayer.prototype._refreshCharAtlas = function (terminal, colorSet) {
-        if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {
-            return;
-        }
-        this._charAtlas = CharAtlasCache_1.acquireCharAtlas(terminal, colorSet, this._scaledCharWidth, this._scaledCharHeight);
-        this._charAtlas.warmUp();
-    };
-    BaseRenderLayer.prototype.resize = function (terminal, dim) {
-        this._scaledCellWidth = dim.scaledCellWidth;
-        this._scaledCellHeight = dim.scaledCellHeight;
-        this._scaledCharWidth = dim.scaledCharWidth;
-        this._scaledCharHeight = dim.scaledCharHeight;
-        this._scaledCharLeft = dim.scaledCharLeft;
-        this._scaledCharTop = dim.scaledCharTop;
-        this._canvas.width = dim.scaledCanvasWidth;
-        this._canvas.height = dim.scaledCanvasHeight;
-        this._canvas.style.width = dim.canvasWidth + "px";
-        this._canvas.style.height = dim.canvasHeight + "px";
-        if (!this._alpha) {
-            this.clearAll();
-        }
-        this._refreshCharAtlas(terminal, this._colors);
-    };
-    BaseRenderLayer.prototype.fillCells = function (x, y, width, height) {
-        this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
-    };
-    BaseRenderLayer.prototype.fillBottomLineAtCells = function (x, y, width) {
-        if (width === void 0) { width = 1; }
-        this._ctx.fillRect(x * this._scaledCellWidth, (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1, width * this._scaledCellWidth, window.devicePixelRatio);
-    };
-    BaseRenderLayer.prototype.fillLeftLineAtCell = function (x, y) {
-        this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, window.devicePixelRatio, this._scaledCellHeight);
-    };
-    BaseRenderLayer.prototype.strokeRectAtCell = function (x, y, width, height) {
-        this._ctx.lineWidth = window.devicePixelRatio;
-        this._ctx.strokeRect(x * this._scaledCellWidth + window.devicePixelRatio / 2, y * this._scaledCellHeight + (window.devicePixelRatio / 2), width * this._scaledCellWidth - window.devicePixelRatio, (height * this._scaledCellHeight) - window.devicePixelRatio);
-    };
-    BaseRenderLayer.prototype.clearAll = function () {
-        if (this._alpha) {
-            this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
-        }
-        else {
-            this._ctx.fillStyle = this._colors.background.css;
-            this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);
-        }
-    };
-    BaseRenderLayer.prototype.clearCells = function (x, y, width, height) {
-        if (this._alpha) {
-            this._ctx.clearRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
-        }
-        else {
-            this._ctx.fillStyle = this._colors.background.css;
-            this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
-        }
-    };
-    BaseRenderLayer.prototype.fillCharTrueColor = function (terminal, cell, x, y) {
-        this._ctx.font = this._getFont(terminal, false, false);
-        this._ctx.textBaseline = 'middle';
-        this._clipRow(terminal, y);
-        this._ctx.fillText(cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2);
-    };
-    BaseRenderLayer.prototype.drawChars = function (terminal, cell, x, y) {
-        if (cell.isFgRGB() || cell.isBgRGB() || cell instanceof CharacterJoinerRegistry_1.JoinedCellData) {
-            this._drawUncachedChars(terminal, cell, x, y);
-            return;
-        }
-        var fg;
-        var bg;
-        if (cell.isInverse()) {
-            fg = (cell.isBgDefault()) ? Types_1.INVERTED_DEFAULT_COLOR : cell.getBgColor();
-            bg = (cell.isFgDefault()) ? Types_1.INVERTED_DEFAULT_COLOR : cell.getFgColor();
-        }
-        else {
-            bg = (cell.isBgDefault()) ? Types_1.DEFAULT_COLOR : cell.getBgColor();
-            fg = (cell.isFgDefault()) ? Types_1.DEFAULT_COLOR : cell.getFgColor();
-        }
-        var drawInBrightColor = terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8 && fg !== Types_1.INVERTED_DEFAULT_COLOR;
-        fg += drawInBrightColor ? 8 : 0;
-        this._currentGlyphIdentifier.chars = cell.getChars() || Buffer_1.WHITESPACE_CELL_CHAR;
-        this._currentGlyphIdentifier.code = cell.getCode() || Buffer_1.WHITESPACE_CELL_CODE;
-        this._currentGlyphIdentifier.bg = bg;
-        this._currentGlyphIdentifier.fg = fg;
-        this._currentGlyphIdentifier.bold = cell.isBold() && terminal.options.enableBold;
-        this._currentGlyphIdentifier.dim = !!cell.isDim();
-        this._currentGlyphIdentifier.italic = !!cell.isItalic();
-        var atlasDidDraw = this._charAtlas && this._charAtlas.draw(this._ctx, this._currentGlyphIdentifier, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);
-        if (!atlasDidDraw) {
-            this._drawUncachedChars(terminal, cell, x, y);
-        }
-    };
-    BaseRenderLayer.prototype._drawUncachedChars = function (terminal, cell, x, y) {
-        this._ctx.save();
-        this._ctx.font = this._getFont(terminal, cell.isBold() && terminal.options.enableBold, !!cell.isItalic());
-        this._ctx.textBaseline = 'middle';
-        if (cell.isInverse()) {
-            if (cell.isBgDefault()) {
-                this._ctx.fillStyle = this._colors.background.css;
-            }
-            else if (cell.isBgRGB()) {
-                this._ctx.fillStyle = "rgb(" + BufferLine_1.AttributeData.toColorRGB(cell.getBgColor()).join(',') + ")";
-            }
-            else {
-                this._ctx.fillStyle = this._colors.ansi[cell.getBgColor()].css;
-            }
-        }
-        else {
-            if (cell.isFgDefault()) {
-                this._ctx.fillStyle = this._colors.foreground.css;
-            }
-            else if (cell.isFgRGB()) {
-                this._ctx.fillStyle = "rgb(" + BufferLine_1.AttributeData.toColorRGB(cell.getFgColor()).join(',') + ")";
-            }
-            else {
-                var fg = cell.getFgColor();
-                if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
-                    fg += 8;
-                }
-                this._ctx.fillStyle = this._colors.ansi[fg].css;
-            }
-        }
-        this._clipRow(terminal, y);
-        if (cell.isDim()) {
-            this._ctx.globalAlpha = Types_1.DIM_OPACITY;
-        }
-        this._ctx.fillText(cell.getChars(), x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2);
-        this._ctx.restore();
-    };
-    BaseRenderLayer.prototype._clipRow = function (terminal, y) {
-        this._ctx.beginPath();
-        this._ctx.rect(0, y * this._scaledCellHeight, terminal.cols * this._scaledCellWidth, this._scaledCellHeight);
-        this._ctx.clip();
-    };
-    BaseRenderLayer.prototype._getFont = function (terminal, isBold, isItalic) {
-        var fontWeight = isBold ? terminal.options.fontWeightBold : terminal.options.fontWeight;
-        var fontStyle = isItalic ? 'italic' : '';
-        return fontStyle + " " + fontWeight + " " + terminal.options.fontSize * window.devicePixelRatio + "px " + terminal.options.fontFamily;
-    };
-    return BaseRenderLayer;
-}());
-exports.BaseRenderLayer = BaseRenderLayer;
-
-},{"../Buffer":2,"../BufferLine":3,"./CharacterJoinerRegistry":36,"./atlas/CharAtlasCache":45,"./atlas/Types":52}],36:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var BufferLine_1 = require("../BufferLine");
-var Buffer_1 = require("../Buffer");
-var JoinedCellData = (function (_super) {
-    __extends(JoinedCellData, _super);
-    function JoinedCellData(firstCell, chars, width) {
-        var _this = _super.call(this) || this;
-        _this.content = 0;
-        _this.combinedData = '';
-        _this.fg = firstCell.fg;
-        _this.bg = firstCell.bg;
-        _this.combinedData = chars;
-        _this._width = width;
-        return _this;
-    }
-    JoinedCellData.prototype.isCombined = function () {
-        return 2097152;
-    };
-    JoinedCellData.prototype.getWidth = function () {
-        return this._width;
-    };
-    JoinedCellData.prototype.getChars = function () {
-        return this.combinedData;
-    };
-    JoinedCellData.prototype.getCode = function () {
-        return 0x1FFFFF;
-    };
-    JoinedCellData.prototype.setFromCharData = function (value) {
-        throw new Error('not implemented');
-    };
-    JoinedCellData.prototype.getAsCharData = function () {
-        return [this.fg, this.getChars(), this.getWidth(), this.getCode()];
-    };
-    return JoinedCellData;
-}(BufferLine_1.AttributeData));
-exports.JoinedCellData = JoinedCellData;
-var CharacterJoinerRegistry = (function () {
-    function CharacterJoinerRegistry(_terminal) {
-        this._terminal = _terminal;
-        this._characterJoiners = [];
-        this._nextCharacterJoinerId = 0;
-        this._workCell = new BufferLine_1.CellData();
-    }
-    CharacterJoinerRegistry.prototype.registerCharacterJoiner = function (handler) {
-        var joiner = {
-            id: this._nextCharacterJoinerId++,
-            handler: handler
-        };
-        this._characterJoiners.push(joiner);
-        return joiner.id;
-    };
-    CharacterJoinerRegistry.prototype.deregisterCharacterJoiner = function (joinerId) {
-        for (var i = 0; i < this._characterJoiners.length; i++) {
-            if (this._characterJoiners[i].id === joinerId) {
-                this._characterJoiners.splice(i, 1);
-                return true;
-            }
-        }
-        return false;
-    };
-    CharacterJoinerRegistry.prototype.getJoinedCharacters = function (row) {
-        if (this._characterJoiners.length === 0) {
-            return [];
-        }
-        var line = this._terminal.buffer.lines.get(row);
-        if (line.length === 0) {
-            return [];
-        }
-        var ranges = [];
-        var lineStr = line.translateToString(true);
-        var rangeStartColumn = 0;
-        var currentStringIndex = 0;
-        var rangeStartStringIndex = 0;
-        var rangeAttrFG = line.getFg(0);
-        var rangeAttrBG = line.getBg(0);
-        for (var x = 0; x < line.getTrimmedLength(); x++) {
-            line.loadCell(x, this._workCell);
-            if (this._workCell.getWidth() === 0) {
-                continue;
-            }
-            if (this._workCell.fg !== rangeAttrFG || this._workCell.bg !== rangeAttrBG) {
-                if (x - rangeStartColumn > 1) {
-                    var joinedRanges = this._getJoinedRanges(lineStr, rangeStartStringIndex, currentStringIndex, line, rangeStartColumn);
-                    for (var i = 0; i < joinedRanges.length; i++) {
-                        ranges.push(joinedRanges[i]);
-                    }
-                }
-                rangeStartColumn = x;
-                rangeStartStringIndex = currentStringIndex;
-                rangeAttrFG = this._workCell.fg;
-                rangeAttrBG = this._workCell.bg;
-            }
-            currentStringIndex += this._workCell.getChars().length || Buffer_1.WHITESPACE_CELL_CHAR.length;
-        }
-        if (this._terminal.cols - rangeStartColumn > 1) {
-            var joinedRanges = this._getJoinedRanges(lineStr, rangeStartStringIndex, currentStringIndex, line, rangeStartColumn);
-            for (var i = 0; i < joinedRanges.length; i++) {
-                ranges.push(joinedRanges[i]);
-            }
-        }
-        return ranges;
-    };
-    CharacterJoinerRegistry.prototype._getJoinedRanges = function (line, startIndex, endIndex, lineData, startCol) {
-        var text = line.substring(startIndex, endIndex);
-        var joinedRanges = this._characterJoiners[0].handler(text);
-        for (var i = 1; i < this._characterJoiners.length; i++) {
-            var joinerRanges = this._characterJoiners[i].handler(text);
-            for (var j = 0; j < joinerRanges.length; j++) {
-                CharacterJoinerRegistry._mergeRanges(joinedRanges, joinerRanges[j]);
-            }
-        }
-        this._stringRangesToCellRanges(joinedRanges, lineData, startCol);
-        return joinedRanges;
-    };
-    CharacterJoinerRegistry.prototype._stringRangesToCellRanges = function (ranges, line, startCol) {
-        var currentRangeIndex = 0;
-        var currentRangeStarted = false;
-        var currentStringIndex = 0;
-        var currentRange = ranges[currentRangeIndex];
-        if (!currentRange) {
-            return;
-        }
-        for (var x = startCol; x < this._terminal.cols; x++) {
-            var width = line.getWidth(x);
-            var length_1 = line.getString(x).length || Buffer_1.WHITESPACE_CELL_CHAR.length;
-            if (width === 0) {
-                continue;
-            }
-            if (!currentRangeStarted && currentRange[0] <= currentStringIndex) {
-                currentRange[0] = x;
-                currentRangeStarted = true;
-            }
-            if (currentRange[1] <= currentStringIndex) {
-                currentRange[1] = x;
-                currentRange = ranges[++currentRangeIndex];
-                if (!currentRange) {
-                    break;
-                }
-                if (currentRange[0] <= currentStringIndex) {
-                    currentRange[0] = x;
-                    currentRangeStarted = true;
-                }
-                else {
-                    currentRangeStarted = false;
-                }
-            }
-            currentStringIndex += length_1;
-        }
-        if (currentRange) {
-            currentRange[1] = this._terminal.cols;
-        }
-    };
-    CharacterJoinerRegistry._mergeRanges = function (ranges, newRange) {
-        var inRange = false;
-        for (var i = 0; i < ranges.length; i++) {
-            var range = ranges[i];
-            if (!inRange) {
-                if (newRange[1] <= range[0]) {
-                    ranges.splice(i, 0, newRange);
-                    return ranges;
-                }
-                if (newRange[1] <= range[1]) {
-                    range[0] = Math.min(newRange[0], range[0]);
-                    return ranges;
-                }
-                if (newRange[0] < range[1]) {
-                    range[0] = Math.min(newRange[0], range[0]);
-                    inRange = true;
-                }
-                continue;
-            }
-            else {
-                if (newRange[1] <= range[0]) {
-                    ranges[i - 1][1] = newRange[1];
-                    return ranges;
-                }
-                if (newRange[1] <= range[1]) {
-                    ranges[i - 1][1] = Math.max(newRange[1], range[1]);
-                    ranges.splice(i, 1);
-                    inRange = false;
-                    return ranges;
-                }
-                ranges.splice(i, 1);
-                i--;
-            }
-        }
-        if (inRange) {
-            ranges[ranges.length - 1][1] = newRange[1];
-        }
-        else {
-            ranges.push(newRange);
-        }
-        return ranges;
-    };
-    return CharacterJoinerRegistry;
-}());
-exports.CharacterJoinerRegistry = CharacterJoinerRegistry;
-
-},{"../Buffer":2,"../BufferLine":3}],37:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var DEFAULT_FOREGROUND = fromHex('#ffffff');
-var DEFAULT_BACKGROUND = fromHex('#000000');
-var DEFAULT_CURSOR = fromHex('#ffffff');
-var DEFAULT_CURSOR_ACCENT = fromHex('#000000');
-var DEFAULT_SELECTION = {
-    css: 'rgba(255, 255, 255, 0.3)',
-    rgba: 0xFFFFFF77
-};
-exports.DEFAULT_ANSI_COLORS = (function () {
-    var colors = [
-        fromHex('#2e3436'),
-        fromHex('#cc0000'),
-        fromHex('#4e9a06'),
-        fromHex('#c4a000'),
-        fromHex('#3465a4'),
-        fromHex('#75507b'),
-        fromHex('#06989a'),
-        fromHex('#d3d7cf'),
-        fromHex('#555753'),
-        fromHex('#ef2929'),
-        fromHex('#8ae234'),
-        fromHex('#fce94f'),
-        fromHex('#729fcf'),
-        fromHex('#ad7fa8'),
-        fromHex('#34e2e2'),
-        fromHex('#eeeeec')
-    ];
-    var v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
-    for (var i = 0; i < 216; i++) {
-        var r = v[(i / 36) % 6 | 0];
-        var g = v[(i / 6) % 6 | 0];
-        var b = v[i % 6];
-        colors.push({
-            css: "#" + toPaddedHex(r) + toPaddedHex(g) + toPaddedHex(b),
-            rgba: ((r << 24) | (g << 16) | (b << 8) | 0xFF) >>> 0
-        });
-    }
-    for (var i = 0; i < 24; i++) {
-        var c = 8 + i * 10;
-        var ch = toPaddedHex(c);
-        colors.push({
-            css: "#" + ch + ch + ch,
-            rgba: ((c << 24) | (c << 16) | (c << 8) | 0xFF) >>> 0
-        });
-    }
-    return colors;
-})();
-function fromHex(css) {
-    return {
-        css: css,
-        rgba: parseInt(css.slice(1), 16) << 8 | 0xFF
-    };
-}
-function toPaddedHex(c) {
-    var s = c.toString(16);
-    return s.length < 2 ? '0' + s : s;
-}
-var ColorManager = (function () {
-    function ColorManager(document, allowTransparency) {
-        this.allowTransparency = allowTransparency;
-        var canvas = document.createElement('canvas');
-        canvas.width = 1;
-        canvas.height = 1;
-        this._ctx = canvas.getContext('2d');
-        this._ctx.globalCompositeOperation = 'copy';
-        this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1);
-        this.colors = {
-            foreground: DEFAULT_FOREGROUND,
-            background: DEFAULT_BACKGROUND,
-            cursor: DEFAULT_CURSOR,
-            cursorAccent: DEFAULT_CURSOR_ACCENT,
-            selection: DEFAULT_SELECTION,
-            ansi: exports.DEFAULT_ANSI_COLORS.slice()
-        };
-    }
-    ColorManager.prototype.setTheme = function (theme) {
-        this.colors.foreground = this._parseColor(theme.foreground, DEFAULT_FOREGROUND);
-        this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);
-        this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);
-        this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);
-        this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);
-        this.colors.ansi[0] = this._parseColor(theme.black, exports.DEFAULT_ANSI_COLORS[0]);
-        this.colors.ansi[1] = this._parseColor(theme.red, exports.DEFAULT_ANSI_COLORS[1]);
-        this.colors.ansi[2] = this._parseColor(theme.green, exports.DEFAULT_ANSI_COLORS[2]);
-        this.colors.ansi[3] = this._parseColor(theme.yellow, exports.DEFAULT_ANSI_COLORS[3]);
-        this.colors.ansi[4] = this._parseColor(theme.blue, exports.DEFAULT_ANSI_COLORS[4]);
-        this.colors.ansi[5] = this._parseColor(theme.magenta, exports.DEFAULT_ANSI_COLORS[5]);
-        this.colors.ansi[6] = this._parseColor(theme.cyan, exports.DEFAULT_ANSI_COLORS[6]);
-        this.colors.ansi[7] = this._parseColor(theme.white, exports.DEFAULT_ANSI_COLORS[7]);
-        this.colors.ansi[8] = this._parseColor(theme.brightBlack, exports.DEFAULT_ANSI_COLORS[8]);
-        this.colors.ansi[9] = this._parseColor(theme.brightRed, exports.DEFAULT_ANSI_COLORS[9]);
-        this.colors.ansi[10] = this._parseColor(theme.brightGreen, exports.DEFAULT_ANSI_COLORS[10]);
-        this.colors.ansi[11] = this._parseColor(theme.brightYellow, exports.DEFAULT_ANSI_COLORS[11]);
-        this.colors.ansi[12] = this._parseColor(theme.brightBlue, exports.DEFAULT_ANSI_COLORS[12]);
-        this.colors.ansi[13] = this._parseColor(theme.brightMagenta, exports.DEFAULT_ANSI_COLORS[13]);
-        this.colors.ansi[14] = this._parseColor(theme.brightCyan, exports.DEFAULT_ANSI_COLORS[14]);
-        this.colors.ansi[15] = this._parseColor(theme.brightWhite, exports.DEFAULT_ANSI_COLORS[15]);
-    };
-    ColorManager.prototype._parseColor = function (css, fallback, allowTransparency) {
-        if (allowTransparency === void 0) { allowTransparency = this.allowTransparency; }
-        if (!css) {
-            return fallback;
-        }
-        this._ctx.fillStyle = this._litmusColor;
-        this._ctx.fillStyle = css;
-        if (typeof this._ctx.fillStyle !== 'string') {
-            console.warn("Color: " + css + " is invalid using fallback " + fallback.css);
-            return fallback;
-        }
-        this._ctx.fillRect(0, 0, 1, 1);
-        var data = this._ctx.getImageData(0, 0, 1, 1).data;
-        if (!allowTransparency && data[3] !== 0xFF) {
-            console.warn("Color: " + css + " is using transparency, but allowTransparency is false. " +
-                ("Using fallback " + fallback.css + "."));
-            return fallback;
-        }
-        return {
-            css: css,
-            rgba: (data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]) >>> 0
-        };
-    };
-    return ColorManager;
-}());
-exports.ColorManager = ColorManager;
-
-},{}],38:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var BaseRenderLayer_1 = require("./BaseRenderLayer");
-var BufferLine_1 = require("../BufferLine");
-var BLINK_INTERVAL = 600;
-var CursorRenderLayer = (function (_super) {
-    __extends(CursorRenderLayer, _super);
-    function CursorRenderLayer(container, zIndex, colors) {
-        var _this = _super.call(this, container, 'cursor', zIndex, true, colors) || this;
-        _this._cell = new BufferLine_1.CellData();
-        _this._state = {
-            x: null,
-            y: null,
-            isFocused: null,
-            style: null,
-            width: null
-        };
-        _this._cursorRenderers = {
-            'bar': _this._renderBarCursor.bind(_this),
-            'block': _this._renderBlockCursor.bind(_this),
-            'underline': _this._renderUnderlineCursor.bind(_this)
-        };
-        return _this;
-    }
-    CursorRenderLayer.prototype.resize = function (terminal, dim) {
-        _super.prototype.resize.call(this, terminal, dim);
-        this._state = {
-            x: null,
-            y: null,
-            isFocused: null,
-            style: null,
-            width: null
-        };
-    };
-    CursorRenderLayer.prototype.reset = function (terminal) {
-        this._clearCursor();
-        if (this._cursorBlinkStateManager) {
-            this._cursorBlinkStateManager.dispose();
-            this._cursorBlinkStateManager = null;
-            this.onOptionsChanged(terminal);
-        }
-    };
-    CursorRenderLayer.prototype.onBlur = function (terminal) {
-        if (this._cursorBlinkStateManager) {
-            this._cursorBlinkStateManager.pause();
-        }
-        terminal.refresh(terminal.buffer.y, terminal.buffer.y);
-    };
-    CursorRenderLayer.prototype.onFocus = function (terminal) {
-        if (this._cursorBlinkStateManager) {
-            this._cursorBlinkStateManager.resume(terminal);
-        }
-        else {
-            terminal.refresh(terminal.buffer.y, terminal.buffer.y);
-        }
-    };
-    CursorRenderLayer.prototype.onOptionsChanged = function (terminal) {
-        var _this = this;
-        if (terminal.options.cursorBlink) {
-            if (!this._cursorBlinkStateManager) {
-                this._cursorBlinkStateManager = new CursorBlinkStateManager(terminal, function () {
-                    _this._render(terminal, true);
-                });
-            }
-        }
-        else {
-            if (this._cursorBlinkStateManager) {
-                this._cursorBlinkStateManager.dispose();
-                this._cursorBlinkStateManager = null;
-            }
-            terminal.refresh(terminal.buffer.y, terminal.buffer.y);
-        }
-    };
-    CursorRenderLayer.prototype.onCursorMove = function (terminal) {
-        if (this._cursorBlinkStateManager) {
-            this._cursorBlinkStateManager.restartBlinkAnimation(terminal);
-        }
-    };
-    CursorRenderLayer.prototype.onGridChanged = function (terminal, startRow, endRow) {
-        if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {
-            this._render(terminal, false);
-        }
-        else {
-            this._cursorBlinkStateManager.restartBlinkAnimation(terminal);
-        }
-    };
-    CursorRenderLayer.prototype._render = function (terminal, triggeredByAnimationFrame) {
-        if (!terminal.cursorState || terminal.cursorHidden) {
-            this._clearCursor();
-            return;
-        }
-        var cursorY = terminal.buffer.ybase + terminal.buffer.y;
-        var viewportRelativeCursorY = cursorY - terminal.buffer.ydisp;
-        if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) {
-            this._clearCursor();
-            return;
-        }
-        terminal.buffer.lines.get(cursorY).loadCell(terminal.buffer.x, this._cell);
-        if (this._cell.content === undefined) {
-            return;
-        }
-        if (!terminal.isFocused) {
-            this._clearCursor();
-            this._ctx.save();
-            this._ctx.fillStyle = this._colors.cursor.css;
-            this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, this._cell);
-            this._ctx.restore();
-            this._state.x = terminal.buffer.x;
-            this._state.y = viewportRelativeCursorY;
-            this._state.isFocused = false;
-            this._state.style = terminal.options.cursorStyle;
-            this._state.width = this._cell.getWidth();
-            return;
-        }
-        if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {
-            this._clearCursor();
-            return;
-        }
-        if (this._state) {
-            if (this._state.x === terminal.buffer.x &&
-                this._state.y === viewportRelativeCursorY &&
-                this._state.isFocused === terminal.isFocused &&
-                this._state.style === terminal.options.cursorStyle &&
-                this._state.width === this._cell.getWidth()) {
-                return;
-            }
-            this._clearCursor();
-        }
-        this._ctx.save();
-        this._cursorRenderers[terminal.options.cursorStyle || 'block'](terminal, terminal.buffer.x, viewportRelativeCursorY, this._cell);
-        this._ctx.restore();
-        this._state.x = terminal.buffer.x;
-        this._state.y = viewportRelativeCursorY;
-        this._state.isFocused = false;
-        this._state.style = terminal.options.cursorStyle;
-        this._state.width = this._cell.getWidth();
-    };
-    CursorRenderLayer.prototype._clearCursor = function () {
-        if (this._state) {
-            this.clearCells(this._state.x, this._state.y, this._state.width, 1);
-            this._state = {
-                x: null,
-                y: null,
-                isFocused: null,
-                style: null,
-                width: null
-            };
-        }
-    };
-    CursorRenderLayer.prototype._renderBarCursor = function (terminal, x, y, cell) {
-        this._ctx.save();
-        this._ctx.fillStyle = this._colors.cursor.css;
-        this.fillLeftLineAtCell(x, y);
-        this._ctx.restore();
-    };
-    CursorRenderLayer.prototype._renderBlockCursor = function (terminal, x, y, cell) {
-        this._ctx.save();
-        this._ctx.fillStyle = this._colors.cursor.css;
-        this.fillCells(x, y, cell.getWidth(), 1);
-        this._ctx.fillStyle = this._colors.cursorAccent.css;
-        this.fillCharTrueColor(terminal, cell, x, y);
-        this._ctx.restore();
-    };
-    CursorRenderLayer.prototype._renderUnderlineCursor = function (terminal, x, y, cell) {
-        this._ctx.save();
-        this._ctx.fillStyle = this._colors.cursor.css;
-        this.fillBottomLineAtCells(x, y);
-        this._ctx.restore();
-    };
-    CursorRenderLayer.prototype._renderBlurCursor = function (terminal, x, y, cell) {
-        this._ctx.save();
-        this._ctx.strokeStyle = this._colors.cursor.css;
-        this.strokeRectAtCell(x, y, cell.getWidth(), 1);
-        this._ctx.restore();
-    };
-    return CursorRenderLayer;
-}(BaseRenderLayer_1.BaseRenderLayer));
-exports.CursorRenderLayer = CursorRenderLayer;
-var CursorBlinkStateManager = (function () {
-    function CursorBlinkStateManager(terminal, _renderCallback) {
-        this._renderCallback = _renderCallback;
-        this.isCursorVisible = true;
-        if (terminal.isFocused) {
-            this._restartInterval();
-        }
-    }
-    Object.defineProperty(CursorBlinkStateManager.prototype, "isPaused", {
-        get: function () { return !(this._blinkStartTimeout || this._blinkInterval); },
-        enumerable: true,
-        configurable: true
-    });
-    CursorBlinkStateManager.prototype.dispose = function () {
-        if (this._blinkInterval) {
-            window.clearInterval(this._blinkInterval);
-            this._blinkInterval = null;
-        }
-        if (this._blinkStartTimeout) {
-            window.clearTimeout(this._blinkStartTimeout);
-            this._blinkStartTimeout = null;
-        }
-        if (this._animationFrame) {
-            window.cancelAnimationFrame(this._animationFrame);
-            this._animationFrame = null;
-        }
-    };
-    CursorBlinkStateManager.prototype.restartBlinkAnimation = function (terminal) {
-        var _this = this;
-        if (this.isPaused) {
-            return;
-        }
-        this._animationTimeRestarted = Date.now();
-        this.isCursorVisible = true;
-        if (!this._animationFrame) {
-            this._animationFrame = window.requestAnimationFrame(function () {
-                _this._renderCallback();
-                _this._animationFrame = null;
-            });
-        }
-    };
-    CursorBlinkStateManager.prototype._restartInterval = function (timeToStart) {
-        var _this = this;
-        if (timeToStart === void 0) { timeToStart = BLINK_INTERVAL; }
-        if (this._blinkInterval) {
-            window.clearInterval(this._blinkInterval);
-        }
-        this._blinkStartTimeout = setTimeout(function () {
-            if (_this._animationTimeRestarted) {
-                var time = BLINK_INTERVAL - (Date.now() - _this._animationTimeRestarted);
-                _this._animationTimeRestarted = null;
-                if (time > 0) {
-                    _this._restartInterval(time);
-                    return;
-                }
-            }
-            _this.isCursorVisible = false;
-            _this._animationFrame = window.requestAnimationFrame(function () {
-                _this._renderCallback();
-                _this._animationFrame = null;
-            });
-            _this._blinkInterval = setInterval(function () {
-                if (_this._animationTimeRestarted) {
-                    var time = BLINK_INTERVAL - (Date.now() - _this._animationTimeRestarted);
-                    _this._animationTimeRestarted = null;
-                    _this._restartInterval(time);
-                    return;
-                }
-                _this.isCursorVisible = !_this.isCursorVisible;
-                _this._animationFrame = window.requestAnimationFrame(function () {
-                    _this._renderCallback();
-                    _this._animationFrame = null;
-                });
-            }, BLINK_INTERVAL);
-        }, timeToStart);
-    };
-    CursorBlinkStateManager.prototype.pause = function () {
-        this.isCursorVisible = true;
-        if (this._blinkInterval) {
-            window.clearInterval(this._blinkInterval);
-            this._blinkInterval = null;
-        }
-        if (this._blinkStartTimeout) {
-            window.clearTimeout(this._blinkStartTimeout);
-            this._blinkStartTimeout = null;
-        }
-        if (this._animationFrame) {
-            window.cancelAnimationFrame(this._animationFrame);
-            this._animationFrame = null;
-        }
-    };
-    CursorBlinkStateManager.prototype.resume = function (terminal) {
-        this._animationTimeRestarted = null;
-        this._restartInterval();
-        this.restartBlinkAnimation(terminal);
-    };
-    return CursorBlinkStateManager;
-}());
-
-},{"../BufferLine":3,"./BaseRenderLayer":35}],39:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var GridCache = (function () {
-    function GridCache() {
-        this.cache = [];
-    }
-    GridCache.prototype.resize = function (width, height) {
-        for (var x = 0; x < width; x++) {
-            if (this.cache.length <= x) {
-                this.cache.push([]);
-            }
-            for (var y = this.cache[x].length; y < height; y++) {
-                this.cache[x].push(null);
-            }
-            this.cache[x].length = height;
-        }
-        this.cache.length = width;
-    };
-    GridCache.prototype.clear = function () {
-        for (var x = 0; x < this.cache.length; x++) {
-            for (var y = 0; y < this.cache[x].length; y++) {
-                this.cache[x][y] = null;
-            }
-        }
-    };
-    return GridCache;
-}());
-exports.GridCache = GridCache;
-
-},{}],40:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var BaseRenderLayer_1 = require("./BaseRenderLayer");
-var Types_1 = require("./atlas/Types");
-var CharAtlasUtils_1 = require("./atlas/CharAtlasUtils");
-var LinkRenderLayer = (function (_super) {
-    __extends(LinkRenderLayer, _super);
-    function LinkRenderLayer(container, zIndex, colors, terminal) {
-        var _this = _super.call(this, container, 'link', zIndex, true, colors) || this;
-        _this._state = null;
-        terminal.linkifier.onLinkHover(function (e) { return _this._onLinkHover(e); });
-        terminal.linkifier.onLinkLeave(function (e) { return _this._onLinkLeave(e); });
-        return _this;
-    }
-    LinkRenderLayer.prototype.resize = function (terminal, dim) {
-        _super.prototype.resize.call(this, terminal, dim);
-        this._state = null;
-    };
-    LinkRenderLayer.prototype.reset = function (terminal) {
-        this._clearCurrentLink();
-    };
-    LinkRenderLayer.prototype._clearCurrentLink = function () {
-        if (this._state) {
-            this.clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
-            var middleRowCount = this._state.y2 - this._state.y1 - 1;
-            if (middleRowCount > 0) {
-                this.clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
-            }
-            this.clearCells(0, this._state.y2, this._state.x2, 1);
-            this._state = null;
-        }
-    };
-    LinkRenderLayer.prototype._onLinkHover = function (e) {
-        if (e.fg === Types_1.INVERTED_DEFAULT_COLOR) {
-            this._ctx.fillStyle = this._colors.background.css;
-        }
-        else if (CharAtlasUtils_1.is256Color(e.fg)) {
-            this._ctx.fillStyle = this._colors.ansi[e.fg].css;
-        }
-        else {
-            this._ctx.fillStyle = this._colors.foreground.css;
-        }
-        if (e.y1 === e.y2) {
-            this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
-        }
-        else {
-            this.fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
-            for (var y = e.y1 + 1; y < e.y2; y++) {
-                this.fillBottomLineAtCells(0, y, e.cols);
-            }
-            this.fillBottomLineAtCells(0, e.y2, e.x2);
-        }
-        this._state = e;
-    };
-    LinkRenderLayer.prototype._onLinkLeave = function (e) {
-        this._clearCurrentLink();
-    };
-    return LinkRenderLayer;
-}(BaseRenderLayer_1.BaseRenderLayer));
-exports.LinkRenderLayer = LinkRenderLayer;
-
-},{"./BaseRenderLayer":35,"./atlas/CharAtlasUtils":47,"./atlas/Types":52}],41:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var TextRenderLayer_1 = require("./TextRenderLayer");
-var SelectionRenderLayer_1 = require("./SelectionRenderLayer");
-var CursorRenderLayer_1 = require("./CursorRenderLayer");
-var ColorManager_1 = require("./ColorManager");
-var LinkRenderLayer_1 = require("./LinkRenderLayer");
-var RenderDebouncer_1 = require("../ui/RenderDebouncer");
-var ScreenDprMonitor_1 = require("../ui/ScreenDprMonitor");
-var CharacterJoinerRegistry_1 = require("../renderer/CharacterJoinerRegistry");
-var EventEmitter2_1 = require("../common/EventEmitter2");
-var Lifecycle_1 = require("../common/Lifecycle");
-var Renderer = (function (_super) {
-    __extends(Renderer, _super);
-    function Renderer(_terminal, theme) {
-        var _this = _super.call(this) || this;
-        _this._terminal = _terminal;
-        _this._isPaused = false;
-        _this._needsFullRefresh = false;
-        _this._onCanvasResize = new EventEmitter2_1.EventEmitter2();
-        _this._onRender = new EventEmitter2_1.EventEmitter2();
-        var allowTransparency = _this._terminal.options.allowTransparency;
-        _this.colorManager = new ColorManager_1.ColorManager(document, allowTransparency);
-        _this._characterJoinerRegistry = new CharacterJoinerRegistry_1.CharacterJoinerRegistry(_terminal);
-        if (theme) {
-            _this.colorManager.setTheme(theme);
-        }
-        _this._renderLayers = [
-            new TextRenderLayer_1.TextRenderLayer(_this._terminal.screenElement, 0, _this.colorManager.colors, _this._characterJoinerRegistry, allowTransparency),
-            new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.screenElement, 1, _this.colorManager.colors),
-            new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.screenElement, 2, _this.colorManager.colors, _this._terminal),
-            new CursorRenderLayer_1.CursorRenderLayer(_this._terminal.screenElement, 3, _this.colorManager.colors)
-        ];
-        _this.dimensions = {
-            scaledCharWidth: null,
-            scaledCharHeight: null,
-            scaledCellWidth: null,
-            scaledCellHeight: null,
-            scaledCharLeft: null,
-            scaledCharTop: null,
-            scaledCanvasWidth: null,
-            scaledCanvasHeight: null,
-            canvasWidth: null,
-            canvasHeight: null,
-            actualCellWidth: null,
-            actualCellHeight: null
-        };
-        _this._devicePixelRatio = window.devicePixelRatio;
-        _this._updateDimensions();
-        _this.onOptionsChanged();
-        _this._renderDebouncer = new RenderDebouncer_1.RenderDebouncer(_this._renderRows.bind(_this));
-        _this._screenDprMonitor = new ScreenDprMonitor_1.ScreenDprMonitor();
-        _this._screenDprMonitor.setListener(function () { return _this.onWindowResize(window.devicePixelRatio); });
-        _this.register(_this._screenDprMonitor);
-        if ('IntersectionObserver' in window) {
-            var observer_1 = new IntersectionObserver(function (e) { return _this.onIntersectionChange(e[e.length - 1]); }, { threshold: 0 });
-            observer_1.observe(_this._terminal.element);
-            _this.register({ dispose: function () { return observer_1.disconnect(); } });
-        }
-        return _this;
-    }
-    Object.defineProperty(Renderer.prototype, "onCanvasResize", {
-        get: function () { return this._onCanvasResize.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(Renderer.prototype, "onRender", {
-        get: function () { return this._onRender.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Renderer.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        this._renderLayers.forEach(function (l) { return l.dispose(); });
-    };
-    Renderer.prototype.onIntersectionChange = function (entry) {
-        this._isPaused = entry.intersectionRatio === 0;
-        if (!this._isPaused && this._needsFullRefresh) {
-            this._terminal.refresh(0, this._terminal.rows - 1);
-            this._needsFullRefresh = false;
-        }
-    };
-    Renderer.prototype.onWindowResize = function (devicePixelRatio) {
-        if (this._devicePixelRatio !== devicePixelRatio) {
-            this._devicePixelRatio = devicePixelRatio;
-            this.onResize(this._terminal.cols, this._terminal.rows);
-        }
-    };
-    Renderer.prototype.setTheme = function (theme) {
-        var _this = this;
-        this.colorManager.setTheme(theme);
-        this._renderLayers.forEach(function (l) {
-            l.onThemeChanged(_this._terminal, _this.colorManager.colors);
-            l.reset(_this._terminal);
-        });
-        if (this._isPaused) {
-            this._needsFullRefresh = true;
-        }
-        else {
-            this._terminal.refresh(0, this._terminal.rows - 1);
-        }
-        return this.colorManager.colors;
-    };
-    Renderer.prototype.onResize = function (cols, rows) {
-        var _this = this;
-        this._updateDimensions();
-        this._renderLayers.forEach(function (l) { return l.resize(_this._terminal, _this.dimensions); });
-        if (this._isPaused) {
-            this._needsFullRefresh = true;
-        }
-        else {
-            this._terminal.refresh(0, this._terminal.rows - 1);
-        }
-        this._terminal.screenElement.style.width = this.dimensions.canvasWidth + "px";
-        this._terminal.screenElement.style.height = this.dimensions.canvasHeight + "px";
-        this._onCanvasResize.fire({
-            width: this.dimensions.canvasWidth,
-            height: this.dimensions.canvasHeight
-        });
-    };
-    Renderer.prototype.onCharSizeChanged = function () {
-        this.onResize(this._terminal.cols, this._terminal.rows);
-    };
-    Renderer.prototype.onBlur = function () {
-        var _this = this;
-        this._runOperation(function (l) { return l.onBlur(_this._terminal); });
-    };
-    Renderer.prototype.onFocus = function () {
-        var _this = this;
-        this._runOperation(function (l) { return l.onFocus(_this._terminal); });
-    };
-    Renderer.prototype.onSelectionChanged = function (start, end, columnSelectMode) {
-        var _this = this;
-        if (columnSelectMode === void 0) { columnSelectMode = false; }
-        this._runOperation(function (l) { return l.onSelectionChanged(_this._terminal, start, end, columnSelectMode); });
-    };
-    Renderer.prototype.onCursorMove = function () {
-        var _this = this;
-        this._runOperation(function (l) { return l.onCursorMove(_this._terminal); });
-    };
-    Renderer.prototype.onOptionsChanged = function () {
-        var _this = this;
-        this.colorManager.allowTransparency = this._terminal.options.allowTransparency;
-        this._runOperation(function (l) { return l.onOptionsChanged(_this._terminal); });
-    };
-    Renderer.prototype.clear = function () {
-        var _this = this;
-        this._runOperation(function (l) { return l.reset(_this._terminal); });
-    };
-    Renderer.prototype._runOperation = function (operation) {
-        if (this._isPaused) {
-            this._needsFullRefresh = true;
-        }
-        else {
-            this._renderLayers.forEach(function (l) { return operation(l); });
-        }
-    };
-    Renderer.prototype.refreshRows = function (start, end) {
-        if (this._isPaused) {
-            this._needsFullRefresh = true;
-            return;
-        }
-        this._renderDebouncer.refresh(start, end, this._terminal.rows);
-    };
-    Renderer.prototype._renderRows = function (start, end) {
-        var _this = this;
-        this._renderLayers.forEach(function (l) { return l.onGridChanged(_this._terminal, start, end); });
-        this._onRender.fire({ start: start, end: end });
-    };
-    Renderer.prototype._updateDimensions = function () {
-        if (!this._terminal.charMeasure.width || !this._terminal.charMeasure.height) {
-            return;
-        }
-        this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
-        this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);
-        this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);
-        this.dimensions.scaledCharTop = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);
-        this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);
-        this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2);
-        this.dimensions.scaledCanvasHeight = this._terminal.rows * this.dimensions.scaledCellHeight;
-        this.dimensions.scaledCanvasWidth = this._terminal.cols * this.dimensions.scaledCellWidth;
-        this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
-        this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
-        this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;
-        this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;
-    };
-    Renderer.prototype.registerCharacterJoiner = function (handler) {
-        return this._characterJoinerRegistry.registerCharacterJoiner(handler);
-    };
-    Renderer.prototype.deregisterCharacterJoiner = function (joinerId) {
-        return this._characterJoinerRegistry.deregisterCharacterJoiner(joinerId);
-    };
-    return Renderer;
-}(Lifecycle_1.Disposable));
-exports.Renderer = Renderer;
-
-},{"../common/EventEmitter2":25,"../common/Lifecycle":26,"../renderer/CharacterJoinerRegistry":36,"../ui/RenderDebouncer":56,"../ui/ScreenDprMonitor":57,"./ColorManager":37,"./CursorRenderLayer":38,"./LinkRenderLayer":40,"./SelectionRenderLayer":42,"./TextRenderLayer":43}],42:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var BaseRenderLayer_1 = require("./BaseRenderLayer");
-var SelectionRenderLayer = (function (_super) {
-    __extends(SelectionRenderLayer, _super);
-    function SelectionRenderLayer(container, zIndex, colors) {
-        var _this = _super.call(this, container, 'selection', zIndex, true, colors) || this;
-        _this._clearState();
-        return _this;
-    }
-    SelectionRenderLayer.prototype._clearState = function () {
-        this._state = {
-            start: null,
-            end: null,
-            columnSelectMode: null,
-            ydisp: null
-        };
-    };
-    SelectionRenderLayer.prototype.resize = function (terminal, dim) {
-        _super.prototype.resize.call(this, terminal, dim);
-        this._clearState();
-    };
-    SelectionRenderLayer.prototype.reset = function (terminal) {
-        if (this._state.start && this._state.end) {
-            this._clearState();
-            this.clearAll();
-        }
-    };
-    SelectionRenderLayer.prototype.onSelectionChanged = function (terminal, start, end, columnSelectMode) {
-        if (!this._didStateChange(start, end, columnSelectMode, terminal.buffer.ydisp)) {
-            return;
-        }
-        this.clearAll();
-        if (!start || !end) {
-            this._clearState();
-            return;
-        }
-        var viewportStartRow = start[1] - terminal.buffer.ydisp;
-        var viewportEndRow = end[1] - terminal.buffer.ydisp;
-        var viewportCappedStartRow = Math.max(viewportStartRow, 0);
-        var viewportCappedEndRow = Math.min(viewportEndRow, terminal.rows - 1);
-        if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) {
-            return;
-        }
-        this._ctx.fillStyle = this._colors.selection.css;
-        if (columnSelectMode) {
-            var startCol = start[0];
-            var width = end[0] - startCol;
-            var height = viewportCappedEndRow - viewportCappedStartRow + 1;
-            this.fillCells(startCol, viewportCappedStartRow, width, height);
-        }
-        else {
-            var startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
-            var startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;
-            this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);
-            var middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);
-            this.fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);
-            if (viewportCappedStartRow !== viewportCappedEndRow) {
-                var endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols;
-                this.fillCells(0, viewportCappedEndRow, endCol, 1);
-            }
-        }
-        this._state.start = [start[0], start[1]];
-        this._state.end = [end[0], end[1]];
-        this._state.columnSelectMode = columnSelectMode;
-        this._state.ydisp = terminal.buffer.ydisp;
-    };
-    SelectionRenderLayer.prototype._didStateChange = function (start, end, columnSelectMode, ydisp) {
-        return !this._areCoordinatesEqual(start, this._state.start) ||
-            !this._areCoordinatesEqual(end, this._state.end) ||
-            columnSelectMode !== this._state.columnSelectMode ||
-            ydisp !== this._state.ydisp;
-    };
-    SelectionRenderLayer.prototype._areCoordinatesEqual = function (coord1, coord2) {
-        if (!coord1 || !coord2) {
-            return false;
-        }
-        return coord1[0] === coord2[0] && coord1[1] === coord2[1];
-    };
-    return SelectionRenderLayer;
-}(BaseRenderLayer_1.BaseRenderLayer));
-exports.SelectionRenderLayer = SelectionRenderLayer;
-
-},{"./BaseRenderLayer":35}],43:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Buffer_1 = require("../Buffer");
-var GridCache_1 = require("./GridCache");
-var BaseRenderLayer_1 = require("./BaseRenderLayer");
-var BufferLine_1 = require("../BufferLine");
-var CharacterJoinerRegistry_1 = require("./CharacterJoinerRegistry");
-var TextRenderLayer = (function (_super) {
-    __extends(TextRenderLayer, _super);
-    function TextRenderLayer(container, zIndex, colors, characterJoinerRegistry, alpha) {
-        var _this = _super.call(this, container, 'text', zIndex, alpha, colors) || this;
-        _this._characterOverlapCache = {};
-        _this._workCell = new BufferLine_1.CellData();
-        _this._state = new GridCache_1.GridCache();
-        _this._characterJoinerRegistry = characterJoinerRegistry;
-        return _this;
-    }
-    TextRenderLayer.prototype.resize = function (terminal, dim) {
-        _super.prototype.resize.call(this, terminal, dim);
-        var terminalFont = this._getFont(terminal, false, false);
-        if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {
-            this._characterWidth = dim.scaledCharWidth;
-            this._characterFont = terminalFont;
-            this._characterOverlapCache = {};
-        }
-        this._state.clear();
-        this._state.resize(terminal.cols, terminal.rows);
-    };
-    TextRenderLayer.prototype.reset = function (terminal) {
-        this._state.clear();
-        this.clearAll();
-    };
-    TextRenderLayer.prototype._forEachCell = function (terminal, firstRow, lastRow, joinerRegistry, callback) {
-        for (var y = firstRow; y <= lastRow; y++) {
-            var row = y + terminal.buffer.ydisp;
-            var line = terminal.buffer.lines.get(row);
-            var joinedRanges = joinerRegistry ? joinerRegistry.getJoinedCharacters(row) : [];
-            for (var x = 0; x < terminal.cols; x++) {
-                line.loadCell(x, this._workCell);
-                var cell = this._workCell;
-                var isJoined = false;
-                var lastCharX = x;
-                if (cell.getWidth() === 0) {
-                    continue;
-                }
-                if (joinedRanges.length > 0 && x === joinedRanges[0][0]) {
-                    isJoined = true;
-                    var range = joinedRanges.shift();
-                    cell = new CharacterJoinerRegistry_1.JoinedCellData(this._workCell, line.translateToString(true, range[0], range[1]), range[1] - range[0]);
-                    lastCharX = range[1] - 1;
-                }
-                if (!isJoined && this._isOverlapping(cell)) {
-                    if (lastCharX < line.length - 1 && line.getCodePoint(lastCharX + 1) === Buffer_1.NULL_CELL_CODE) {
-                        cell.content &= ~12582912;
-                        cell.content |= 2 << 22;
-                    }
-                }
-                callback(cell, x, y);
-                x = lastCharX;
-            }
-        }
-    };
-    TextRenderLayer.prototype._drawBackground = function (terminal, firstRow, lastRow) {
-        var _this = this;
-        var ctx = this._ctx;
-        var cols = terminal.cols;
-        var startX = 0;
-        var startY = 0;
-        var prevFillStyle = null;
-        ctx.save();
-        this._forEachCell(terminal, firstRow, lastRow, null, function (cell, x, y) {
-            var nextFillStyle = null;
-            if (cell.isInverse()) {
-                if (cell.isFgDefault()) {
-                    nextFillStyle = _this._colors.foreground.css;
-                }
-                else if (cell.isFgRGB()) {
-                    nextFillStyle = "rgb(" + BufferLine_1.AttributeData.toColorRGB(cell.getFgColor()).join(',') + ")";
-                }
-                else {
-                    nextFillStyle = _this._colors.ansi[cell.getFgColor()].css;
-                }
-            }
-            else if (cell.isBgRGB()) {
-                nextFillStyle = "rgb(" + BufferLine_1.AttributeData.toColorRGB(cell.getBgColor()).join(',') + ")";
-            }
-            else if (cell.isBgPalette()) {
-                nextFillStyle = _this._colors.ansi[cell.getBgColor()].css;
-            }
-            if (prevFillStyle === null) {
-                startX = x;
-                startY = y;
-            }
-            if (y !== startY) {
-                ctx.fillStyle = prevFillStyle;
-                _this.fillCells(startX, startY, cols - startX, 1);
-                startX = x;
-                startY = y;
-            }
-            else if (prevFillStyle !== nextFillStyle) {
-                ctx.fillStyle = prevFillStyle;
-                _this.fillCells(startX, startY, x - startX, 1);
-                startX = x;
-                startY = y;
-            }
-            prevFillStyle = nextFillStyle;
-        });
-        if (prevFillStyle !== null) {
-            ctx.fillStyle = prevFillStyle;
-            this.fillCells(startX, startY, cols - startX, 1);
-        }
-        ctx.restore();
-    };
-    TextRenderLayer.prototype._drawForeground = function (terminal, firstRow, lastRow) {
-        var _this = this;
-        this._forEachCell(terminal, firstRow, lastRow, this._characterJoinerRegistry, function (cell, x, y) {
-            if (cell.isInvisible()) {
-                return;
-            }
-            if (cell.isUnderline()) {
-                _this._ctx.save();
-                if (cell.isInverse()) {
-                    if (cell.isBgDefault()) {
-                        _this._ctx.fillStyle = _this._colors.background.css;
-                    }
-                    else if (cell.isBgRGB()) {
-                        _this._ctx.fillStyle = "rgb(" + BufferLine_1.AttributeData.toColorRGB(cell.getBgColor()).join(',') + ")";
-                    }
-                    else {
-                        _this._ctx.fillStyle = _this._colors.ansi[cell.getBgColor()].css;
-                    }
-                }
-                else {
-                    if (cell.isFgDefault()) {
-                        _this._ctx.fillStyle = _this._colors.foreground.css;
-                    }
-                    else if (cell.isFgRGB()) {
-                        _this._ctx.fillStyle = "rgb(" + BufferLine_1.AttributeData.toColorRGB(cell.getFgColor()).join(',') + ")";
-                    }
-                    else {
-                        var fg = cell.getFgColor();
-                        if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
-                            fg += 8;
-                        }
-                        _this._ctx.fillStyle = _this._colors.ansi[fg].css;
-                    }
-                }
-                _this.fillBottomLineAtCells(x, y, cell.getWidth());
-                _this._ctx.restore();
-            }
-            _this.drawChars(terminal, cell, x, y);
-        });
-    };
-    TextRenderLayer.prototype.onGridChanged = function (terminal, firstRow, lastRow) {
-        if (this._state.cache.length === 0) {
-            return;
-        }
-        if (this._charAtlas) {
-            this._charAtlas.beginFrame();
-        }
-        this.clearCells(0, firstRow, terminal.cols, lastRow - firstRow + 1);
-        this._drawBackground(terminal, firstRow, lastRow);
-        this._drawForeground(terminal, firstRow, lastRow);
-    };
-    TextRenderLayer.prototype.onOptionsChanged = function (terminal) {
-        this.setTransparency(terminal, terminal.options.allowTransparency);
-    };
-    TextRenderLayer.prototype._isOverlapping = function (cell) {
-        if (cell.getWidth() !== 1) {
-            return false;
-        }
-        if (cell.getCode() < 256) {
-            return false;
-        }
-        var chars = cell.getChars();
-        if (this._characterOverlapCache.hasOwnProperty(chars)) {
-            return this._characterOverlapCache[chars];
-        }
-        this._ctx.save();
-        this._ctx.font = this._characterFont;
-        var overlaps = Math.floor(this._ctx.measureText(chars).width) > this._characterWidth;
-        this._ctx.restore();
-        this._characterOverlapCache[chars] = overlaps;
-        return overlaps;
-    };
-    return TextRenderLayer;
-}(BaseRenderLayer_1.BaseRenderLayer));
-exports.TextRenderLayer = TextRenderLayer;
-
-},{"../Buffer":2,"../BufferLine":3,"./BaseRenderLayer":35,"./CharacterJoinerRegistry":36,"./GridCache":39}],44:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var BaseCharAtlas = (function () {
-    function BaseCharAtlas() {
-        this._didWarmUp = false;
-    }
-    BaseCharAtlas.prototype.dispose = function () { };
-    BaseCharAtlas.prototype.warmUp = function () {
-        if (!this._didWarmUp) {
-            this._doWarmUp();
-            this._didWarmUp = true;
-        }
-    };
-    BaseCharAtlas.prototype._doWarmUp = function () { };
-    BaseCharAtlas.prototype.beginFrame = function () { };
-    return BaseCharAtlas;
-}());
-exports.default = BaseCharAtlas;
-
-},{}],45:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var CharAtlasUtils_1 = require("./CharAtlasUtils");
-var DynamicCharAtlas_1 = require("./DynamicCharAtlas");
-var NoneCharAtlas_1 = require("./NoneCharAtlas");
-var StaticCharAtlas_1 = require("./StaticCharAtlas");
-var charAtlasImplementations = {
-    'none': NoneCharAtlas_1.default,
-    'static': StaticCharAtlas_1.default,
-    'dynamic': DynamicCharAtlas_1.default
-};
-var charAtlasCache = [];
-function acquireCharAtlas(terminal, colors, scaledCharWidth, scaledCharHeight) {
-    var newConfig = CharAtlasUtils_1.generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);
-    for (var i = 0; i < charAtlasCache.length; i++) {
-        var entry = charAtlasCache[i];
-        var ownedByIndex = entry.ownedBy.indexOf(terminal);
-        if (ownedByIndex >= 0) {
-            if (CharAtlasUtils_1.configEquals(entry.config, newConfig)) {
-                return entry.atlas;
-            }
-            if (entry.ownedBy.length === 1) {
-                entry.atlas.dispose();
-                charAtlasCache.splice(i, 1);
-            }
-            else {
-                entry.ownedBy.splice(ownedByIndex, 1);
-            }
-            break;
-        }
-    }
-    for (var i = 0; i < charAtlasCache.length; i++) {
-        var entry = charAtlasCache[i];
-        if (CharAtlasUtils_1.configEquals(entry.config, newConfig)) {
-            entry.ownedBy.push(terminal);
-            return entry.atlas;
-        }
-    }
-    var newEntry = {
-        atlas: new charAtlasImplementations[terminal.options.experimentalCharAtlas](document, newConfig),
-        config: newConfig,
-        ownedBy: [terminal]
-    };
-    charAtlasCache.push(newEntry);
-    return newEntry.atlas;
-}
-exports.acquireCharAtlas = acquireCharAtlas;
-function removeTerminalFromCache(terminal) {
-    for (var i = 0; i < charAtlasCache.length; i++) {
-        var index = charAtlasCache[i].ownedBy.indexOf(terminal);
-        if (index !== -1) {
-            if (charAtlasCache[i].ownedBy.length === 1) {
-                charAtlasCache[i].atlas.dispose();
-                charAtlasCache.splice(i, 1);
-            }
-            else {
-                charAtlasCache[i].ownedBy.splice(index, 1);
-            }
-            break;
-        }
-    }
-}
-exports.removeTerminalFromCache = removeTerminalFromCache;
-
-},{"./CharAtlasUtils":47,"./DynamicCharAtlas":48,"./NoneCharAtlas":50,"./StaticCharAtlas":51}],46:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Platform_1 = require("../../common/Platform");
-var Types_1 = require("./Types");
-function generateStaticCharAtlasTexture(context, canvasFactory, config) {
-    var cellWidth = config.scaledCharWidth + Types_1.CHAR_ATLAS_CELL_SPACING;
-    var cellHeight = config.scaledCharHeight + Types_1.CHAR_ATLAS_CELL_SPACING;
-    var canvas = canvasFactory(255 * cellWidth, (2 + 16 + 16) * cellHeight);
-    var ctx = canvas.getContext('2d', { alpha: config.allowTransparency });
-    ctx.fillStyle = config.colors.background.css;
-    ctx.fillRect(0, 0, canvas.width, canvas.height);
-    ctx.save();
-    ctx.fillStyle = config.colors.foreground.css;
-    ctx.font = getFont(config.fontWeight, config);
-    ctx.textBaseline = 'middle';
-    for (var i = 0; i < 256; i++) {
-        ctx.save();
-        ctx.beginPath();
-        ctx.rect(i * cellWidth, 0, cellWidth, cellHeight);
-        ctx.clip();
-        ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight / 2);
-        ctx.restore();
-    }
-    ctx.save();
-    ctx.font = getFont(config.fontWeightBold, config);
-    for (var i = 0; i < 256; i++) {
-        ctx.save();
-        ctx.beginPath();
-        ctx.rect(i * cellWidth, cellHeight, cellWidth, cellHeight);
-        ctx.clip();
-        ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight * 1.5);
-        ctx.restore();
-    }
-    ctx.restore();
-    ctx.font = getFont(config.fontWeight, config);
-    for (var colorIndex = 0; colorIndex < 16; colorIndex++) {
-        var y = (colorIndex + 2) * cellHeight;
-        for (var i = 0; i < 256; i++) {
-            ctx.save();
-            ctx.beginPath();
-            ctx.rect(i * cellWidth, y, cellWidth, cellHeight);
-            ctx.clip();
-            ctx.fillStyle = config.colors.ansi[colorIndex].css;
-            ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2);
-            ctx.restore();
-        }
-    }
-    ctx.font = getFont(config.fontWeightBold, config);
-    for (var colorIndex = 0; colorIndex < 16; colorIndex++) {
-        var y = (colorIndex + 2 + 16) * cellHeight;
-        for (var i = 0; i < 256; i++) {
-            ctx.save();
-            ctx.beginPath();
-            ctx.rect(i * cellWidth, y, cellWidth, cellHeight);
-            ctx.clip();
-            ctx.fillStyle = config.colors.ansi[colorIndex].css;
-            ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2);
-            ctx.restore();
-        }
-    }
-    ctx.restore();
-    if (!('createImageBitmap' in context) || Platform_1.isFirefox || Platform_1.isSafari) {
-        return canvas;
-    }
-    var charAtlasImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
-    clearColor(charAtlasImageData, config.colors.background);
-    return context.createImageBitmap(charAtlasImageData);
-}
-exports.generateStaticCharAtlasTexture = generateStaticCharAtlasTexture;
-function clearColor(imageData, color) {
-    var isEmpty = true;
-    var r = color.rgba >>> 24;
-    var g = color.rgba >>> 16 & 0xFF;
-    var b = color.rgba >>> 8 & 0xFF;
-    for (var offset = 0; offset < imageData.data.length; offset += 4) {
-        if (imageData.data[offset] === r &&
-            imageData.data[offset + 1] === g &&
-            imageData.data[offset + 2] === b) {
-            imageData.data[offset + 3] = 0;
-        }
-        else {
-            isEmpty = false;
-        }
-    }
-    return isEmpty;
-}
-exports.clearColor = clearColor;
-function getFont(fontWeight, config) {
-    return fontWeight + " " + config.fontSize * config.devicePixelRatio + "px " + config.fontFamily;
-}
-
-},{"../../common/Platform":27,"./Types":52}],47:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Types_1 = require("./Types");
-function generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors) {
-    var clonedColors = {
-        foreground: colors.foreground,
-        background: colors.background,
-        cursor: null,
-        cursorAccent: null,
-        selection: null,
-        ansi: colors.ansi.slice(0, 16)
-    };
-    return {
-        type: terminal.options.experimentalCharAtlas,
-        devicePixelRatio: window.devicePixelRatio,
-        scaledCharWidth: scaledCharWidth,
-        scaledCharHeight: scaledCharHeight,
-        fontFamily: terminal.options.fontFamily,
-        fontSize: terminal.options.fontSize,
-        fontWeight: terminal.options.fontWeight,
-        fontWeightBold: terminal.options.fontWeightBold,
-        allowTransparency: terminal.options.allowTransparency,
-        colors: clonedColors
-    };
-}
-exports.generateConfig = generateConfig;
-function configEquals(a, b) {
-    for (var i = 0; i < a.colors.ansi.length; i++) {
-        if (a.colors.ansi[i].rgba !== b.colors.ansi[i].rgba) {
-            return false;
-        }
-    }
-    return a.type === b.type &&
-        a.devicePixelRatio === b.devicePixelRatio &&
-        a.fontFamily === b.fontFamily &&
-        a.fontSize === b.fontSize &&
-        a.fontWeight === b.fontWeight &&
-        a.fontWeightBold === b.fontWeightBold &&
-        a.allowTransparency === b.allowTransparency &&
-        a.scaledCharWidth === b.scaledCharWidth &&
-        a.scaledCharHeight === b.scaledCharHeight &&
-        a.colors.foreground === b.colors.foreground &&
-        a.colors.background === b.colors.background;
-}
-exports.configEquals = configEquals;
-function is256Color(colorCode) {
-    return colorCode < Types_1.DEFAULT_COLOR;
-}
-exports.is256Color = is256Color;
-
-},{"./Types":52}],48:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Types_1 = require("./Types");
-var BaseCharAtlas_1 = require("./BaseCharAtlas");
-var ColorManager_1 = require("../ColorManager");
-var CharAtlasGenerator_1 = require("./CharAtlasGenerator");
-var LRUMap_1 = require("./LRUMap");
-var Platform_1 = require("../../common/Platform");
-var TEXTURE_WIDTH = 1024;
-var TEXTURE_HEIGHT = 1024;
-var TRANSPARENT_COLOR = {
-    css: 'rgba(0, 0, 0, 0)',
-    rgba: 0
-};
-var FRAME_CACHE_DRAW_LIMIT = 100;
-var GLYPH_BITMAP_COMMIT_DELAY = 100;
-function getGlyphCacheKey(glyph) {
-    return glyph.code << 21 | glyph.bg << 12 | glyph.fg << 3 | (glyph.bold ? 0 : 4) + (glyph.dim ? 0 : 2) + (glyph.italic ? 0 : 1);
-}
-exports.getGlyphCacheKey = getGlyphCacheKey;
-var DynamicCharAtlas = (function (_super) {
-    __extends(DynamicCharAtlas, _super);
-    function DynamicCharAtlas(document, _config) {
-        var _this = _super.call(this) || this;
-        _this._config = _config;
-        _this._drawToCacheCount = 0;
-        _this._glyphsWaitingOnBitmap = [];
-        _this._bitmapCommitTimeout = null;
-        _this._bitmap = null;
-        _this._cacheCanvas = document.createElement('canvas');
-        _this._cacheCanvas.width = TEXTURE_WIDTH;
-        _this._cacheCanvas.height = TEXTURE_HEIGHT;
-        _this._cacheCtx = _this._cacheCanvas.getContext('2d', { alpha: true });
-        var tmpCanvas = document.createElement('canvas');
-        tmpCanvas.width = _this._config.scaledCharWidth;
-        tmpCanvas.height = _this._config.scaledCharHeight;
-        _this._tmpCtx = tmpCanvas.getContext('2d', { alpha: _this._config.allowTransparency });
-        _this._width = Math.floor(TEXTURE_WIDTH / _this._config.scaledCharWidth);
-        _this._height = Math.floor(TEXTURE_HEIGHT / _this._config.scaledCharHeight);
-        var capacity = _this._width * _this._height;
-        _this._cacheMap = new LRUMap_1.default(capacity);
-        _this._cacheMap.prealloc(capacity);
-        return _this;
-    }
-    DynamicCharAtlas.prototype.dispose = function () {
-        if (this._bitmapCommitTimeout !== null) {
-            window.clearTimeout(this._bitmapCommitTimeout);
-            this._bitmapCommitTimeout = null;
-        }
-    };
-    DynamicCharAtlas.prototype.beginFrame = function () {
-        this._drawToCacheCount = 0;
-    };
-    DynamicCharAtlas.prototype.draw = function (ctx, glyph, x, y) {
-        if (glyph.code === 32) {
-            return true;
-        }
-        if (!this._canCache(glyph)) {
-            return false;
-        }
-        var glyphKey = getGlyphCacheKey(glyph);
-        var cacheValue = this._cacheMap.get(glyphKey);
-        if (cacheValue !== null && cacheValue !== undefined) {
-            this._drawFromCache(ctx, cacheValue, x, y);
-            return true;
-        }
-        else if (this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {
-            var index = void 0;
-            if (this._cacheMap.size < this._cacheMap.capacity) {
-                index = this._cacheMap.size;
-            }
-            else {
-                index = this._cacheMap.peek().index;
-            }
-            var cacheValue_1 = this._drawToCache(glyph, index);
-            this._cacheMap.set(glyphKey, cacheValue_1);
-            this._drawFromCache(ctx, cacheValue_1, x, y);
-            return true;
-        }
-        return false;
-    };
-    DynamicCharAtlas.prototype._canCache = function (glyph) {
-        return glyph.code < 256;
-    };
-    DynamicCharAtlas.prototype._toCoordinateX = function (index) {
-        return (index % this._width) * this._config.scaledCharWidth;
-    };
-    DynamicCharAtlas.prototype._toCoordinateY = function (index) {
-        return Math.floor(index / this._width) * this._config.scaledCharHeight;
-    };
-    DynamicCharAtlas.prototype._drawFromCache = function (ctx, cacheValue, x, y) {
-        if (cacheValue.isEmpty) {
-            return;
-        }
-        var cacheX = this._toCoordinateX(cacheValue.index);
-        var cacheY = this._toCoordinateY(cacheValue.index);
-        ctx.drawImage(cacheValue.inBitmap ? this._bitmap : this._cacheCanvas, cacheX, cacheY, this._config.scaledCharWidth, this._config.scaledCharHeight, x, y, this._config.scaledCharWidth, this._config.scaledCharHeight);
-    };
-    DynamicCharAtlas.prototype._getColorFromAnsiIndex = function (idx) {
-        if (idx < this._config.colors.ansi.length) {
-            return this._config.colors.ansi[idx];
-        }
-        return ColorManager_1.DEFAULT_ANSI_COLORS[idx];
-    };
-    DynamicCharAtlas.prototype._getBackgroundColor = function (glyph) {
-        if (this._config.allowTransparency) {
-            return TRANSPARENT_COLOR;
-        }
-        else if (glyph.bg === Types_1.INVERTED_DEFAULT_COLOR) {
-            return this._config.colors.foreground;
-        }
-        else if (glyph.bg < 256) {
-            return this._getColorFromAnsiIndex(glyph.bg);
-        }
-        return this._config.colors.background;
-    };
-    DynamicCharAtlas.prototype._getForegroundColor = function (glyph) {
-        if (glyph.fg === Types_1.INVERTED_DEFAULT_COLOR) {
-            return this._config.colors.background;
-        }
-        else if (glyph.fg < 256) {
-            return this._getColorFromAnsiIndex(glyph.fg);
-        }
-        return this._config.colors.foreground;
-    };
-    DynamicCharAtlas.prototype._drawToCache = function (glyph, index) {
-        this._drawToCacheCount++;
-        this._tmpCtx.save();
-        var backgroundColor = this._getBackgroundColor(glyph);
-        this._tmpCtx.globalCompositeOperation = 'copy';
-        this._tmpCtx.fillStyle = backgroundColor.css;
-        this._tmpCtx.fillRect(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight);
-        this._tmpCtx.globalCompositeOperation = 'source-over';
-        var fontWeight = glyph.bold ? this._config.fontWeightBold : this._config.fontWeight;
-        var fontStyle = glyph.italic ? 'italic' : '';
-        this._tmpCtx.font =
-            fontStyle + " " + fontWeight + " " + this._config.fontSize * this._config.devicePixelRatio + "px " + this._config.fontFamily;
-        this._tmpCtx.textBaseline = 'middle';
-        this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css;
-        if (glyph.dim) {
-            this._tmpCtx.globalAlpha = Types_1.DIM_OPACITY;
-        }
-        this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2);
-        this._tmpCtx.restore();
-        var imageData = this._tmpCtx.getImageData(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight);
-        var isEmpty = false;
-        if (!this._config.allowTransparency) {
-            isEmpty = CharAtlasGenerator_1.clearColor(imageData, backgroundColor);
-        }
-        var x = this._toCoordinateX(index);
-        var y = this._toCoordinateY(index);
-        this._cacheCtx.putImageData(imageData, x, y);
-        var cacheValue = {
-            index: index,
-            isEmpty: isEmpty,
-            inBitmap: false
-        };
-        this._addGlyphToBitmap(cacheValue);
-        return cacheValue;
-    };
-    DynamicCharAtlas.prototype._addGlyphToBitmap = function (cacheValue) {
-        var _this = this;
-        if (!('createImageBitmap' in window) || Platform_1.isFirefox || Platform_1.isSafari) {
-            return;
-        }
-        this._glyphsWaitingOnBitmap.push(cacheValue);
-        if (this._bitmapCommitTimeout !== null) {
-            return;
-        }
-        this._bitmapCommitTimeout = window.setTimeout(function () { return _this._generateBitmap(); }, GLYPH_BITMAP_COMMIT_DELAY);
-    };
-    DynamicCharAtlas.prototype._generateBitmap = function () {
-        var _this = this;
-        var glyphsMovingToBitmap = this._glyphsWaitingOnBitmap;
-        this._glyphsWaitingOnBitmap = [];
-        window.createImageBitmap(this._cacheCanvas).then(function (bitmap) {
-            _this._bitmap = bitmap;
-            for (var i = 0; i < glyphsMovingToBitmap.length; i++) {
-                var value = glyphsMovingToBitmap[i];
-                value.inBitmap = true;
-            }
-        });
-        this._bitmapCommitTimeout = null;
-    };
-    return DynamicCharAtlas;
-}(BaseCharAtlas_1.default));
-exports.default = DynamicCharAtlas;
-
-},{"../../common/Platform":27,"../ColorManager":37,"./BaseCharAtlas":44,"./CharAtlasGenerator":46,"./LRUMap":49,"./Types":52}],49:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var LRUMap = (function () {
-    function LRUMap(capacity) {
-        this.capacity = capacity;
-        this._map = {};
-        this._head = null;
-        this._tail = null;
-        this._nodePool = [];
-        this.size = 0;
-    }
-    LRUMap.prototype._unlinkNode = function (node) {
-        var prev = node.prev;
-        var next = node.next;
-        if (node === this._head) {
-            this._head = next;
-        }
-        if (node === this._tail) {
-            this._tail = prev;
-        }
-        if (prev !== null) {
-            prev.next = next;
-        }
-        if (next !== null) {
-            next.prev = prev;
-        }
-    };
-    LRUMap.prototype._appendNode = function (node) {
-        var tail = this._tail;
-        if (tail !== null) {
-            tail.next = node;
-        }
-        node.prev = tail;
-        node.next = null;
-        this._tail = node;
-        if (this._head === null) {
-            this._head = node;
-        }
-    };
-    LRUMap.prototype.prealloc = function (count) {
-        var nodePool = this._nodePool;
-        for (var i = 0; i < count; i++) {
-            nodePool.push({
-                prev: null,
-                next: null,
-                key: null,
-                value: null
-            });
-        }
-    };
-    LRUMap.prototype.get = function (key) {
-        var node = this._map[key];
-        if (node !== undefined) {
-            this._unlinkNode(node);
-            this._appendNode(node);
-            return node.value;
-        }
-        return null;
-    };
-    LRUMap.prototype.peekValue = function (key) {
-        var node = this._map[key];
-        if (node !== undefined) {
-            return node.value;
-        }
-        return null;
-    };
-    LRUMap.prototype.peek = function () {
-        var head = this._head;
-        return head === null ? null : head.value;
-    };
-    LRUMap.prototype.set = function (key, value) {
-        var node = this._map[key];
-        if (node !== undefined) {
-            node = this._map[key];
-            this._unlinkNode(node);
-            node.value = value;
-        }
-        else if (this.size >= this.capacity) {
-            node = this._head;
-            this._unlinkNode(node);
-            delete this._map[node.key];
-            node.key = key;
-            node.value = value;
-            this._map[key] = node;
-        }
-        else {
-            var nodePool = this._nodePool;
-            if (nodePool.length > 0) {
-                node = nodePool.pop();
-                node.key = key;
-                node.value = value;
-            }
-            else {
-                node = {
-                    prev: null,
-                    next: null,
-                    key: key,
-                    value: value
-                };
-            }
-            this._map[key] = node;
-            this.size++;
-        }
-        this._appendNode(node);
-    };
-    return LRUMap;
-}());
-exports.default = LRUMap;
-
-},{}],50:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var BaseCharAtlas_1 = require("./BaseCharAtlas");
-var NoneCharAtlas = (function (_super) {
-    __extends(NoneCharAtlas, _super);
-    function NoneCharAtlas(document, config) {
-        return _super.call(this) || this;
-    }
-    NoneCharAtlas.prototype.draw = function (ctx, glyph, x, y) {
-        return false;
-    };
-    return NoneCharAtlas;
-}(BaseCharAtlas_1.default));
-exports.default = NoneCharAtlas;
-
-},{"./BaseCharAtlas":44}],51:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Types_1 = require("./Types");
-var CharAtlasGenerator_1 = require("./CharAtlasGenerator");
-var BaseCharAtlas_1 = require("./BaseCharAtlas");
-var CharAtlasUtils_1 = require("./CharAtlasUtils");
-var StaticCharAtlas = (function (_super) {
-    __extends(StaticCharAtlas, _super);
-    function StaticCharAtlas(_document, _config) {
-        var _this = _super.call(this) || this;
-        _this._document = _document;
-        _this._config = _config;
-        _this._canvasFactory = function (width, height) {
-            var canvas = _this._document.createElement('canvas');
-            canvas.width = width;
-            canvas.height = height;
-            return canvas;
-        };
-        return _this;
-    }
-    StaticCharAtlas.prototype._doWarmUp = function () {
-        var _this = this;
-        var result = CharAtlasGenerator_1.generateStaticCharAtlasTexture(window, this._canvasFactory, this._config);
-        if (result instanceof HTMLCanvasElement) {
-            this._texture = result;
-        }
-        else {
-            result.then(function (texture) {
-                _this._texture = texture;
-            });
-        }
-    };
-    StaticCharAtlas.prototype._isCached = function (glyph, colorIndex) {
-        var isAscii = glyph.code < 256;
-        var isBasicColor = glyph.fg < 16;
-        var isDefaultColor = glyph.fg === Types_1.DEFAULT_COLOR;
-        var isDefaultBackground = glyph.bg === Types_1.DEFAULT_COLOR;
-        return isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !glyph.italic;
-    };
-    StaticCharAtlas.prototype.draw = function (ctx, glyph, x, y) {
-        if (this._texture === null || this._texture === undefined) {
-            return false;
-        }
-        var colorIndex = 0;
-        if (CharAtlasUtils_1.is256Color(glyph.fg)) {
-            colorIndex = 2 + glyph.fg + (glyph.bold ? 16 : 0);
-        }
-        else if (glyph.fg === Types_1.DEFAULT_COLOR) {
-            if (glyph.bold) {
-                colorIndex = 1;
-            }
-        }
-        if (!this._isCached(glyph, colorIndex)) {
-            return false;
-        }
-        ctx.save();
-        var charAtlasCellWidth = this._config.scaledCharWidth + Types_1.CHAR_ATLAS_CELL_SPACING;
-        var charAtlasCellHeight = this._config.scaledCharHeight + Types_1.CHAR_ATLAS_CELL_SPACING;
-        if (glyph.dim) {
-            ctx.globalAlpha = Types_1.DIM_OPACITY;
-        }
-        ctx.drawImage(this._texture, glyph.code * charAtlasCellWidth, colorIndex * charAtlasCellHeight, charAtlasCellWidth, this._config.scaledCharHeight, x, y, charAtlasCellWidth, this._config.scaledCharHeight);
-        ctx.restore();
-        return true;
-    };
-    return StaticCharAtlas;
-}(BaseCharAtlas_1.default));
-exports.default = StaticCharAtlas;
-
-},{"./BaseCharAtlas":44,"./CharAtlasGenerator":46,"./CharAtlasUtils":47,"./Types":52}],52:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.DEFAULT_COLOR = 256;
-exports.INVERTED_DEFAULT_COLOR = 257;
-exports.DIM_OPACITY = 0.5;
-exports.CHAR_ATLAS_CELL_SPACING = 1;
-
-},{}],53:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var ColorManager_1 = require("../ColorManager");
-var RenderDebouncer_1 = require("../../ui/RenderDebouncer");
-var DomRendererRowFactory_1 = require("./DomRendererRowFactory");
-var Types_1 = require("../atlas/Types");
-var EventEmitter2_1 = require("../../common/EventEmitter2");
-var Lifecycle_1 = require("../../common/Lifecycle");
-var TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';
-var ROW_CONTAINER_CLASS = 'xterm-rows';
-var FG_CLASS_PREFIX = 'xterm-fg-';
-var BG_CLASS_PREFIX = 'xterm-bg-';
-var FOCUS_CLASS = 'xterm-focus';
-var SELECTION_CLASS = 'xterm-selection';
-var nextTerminalId = 1;
-var DomRenderer = (function (_super) {
-    __extends(DomRenderer, _super);
-    function DomRenderer(_terminal, theme) {
-        var _this = _super.call(this) || this;
-        _this._terminal = _terminal;
-        _this._terminalClass = nextTerminalId++;
-        _this._rowElements = [];
-        _this._onCanvasResize = new EventEmitter2_1.EventEmitter2();
-        _this._onRender = new EventEmitter2_1.EventEmitter2();
-        var allowTransparency = _this._terminal.options.allowTransparency;
-        _this.colorManager = new ColorManager_1.ColorManager(document, allowTransparency);
-        _this.setTheme(theme);
-        _this._rowContainer = document.createElement('div');
-        _this._rowContainer.classList.add(ROW_CONTAINER_CLASS);
-        _this._rowContainer.style.lineHeight = 'normal';
-        _this._rowContainer.setAttribute('aria-hidden', 'true');
-        _this._refreshRowElements(_this._terminal.cols, _this._terminal.rows);
-        _this._selectionContainer = document.createElement('div');
-        _this._selectionContainer.classList.add(SELECTION_CLASS);
-        _this._selectionContainer.setAttribute('aria-hidden', 'true');
-        _this.dimensions = {
-            scaledCharWidth: null,
-            scaledCharHeight: null,
-            scaledCellWidth: null,
-            scaledCellHeight: null,
-            scaledCharLeft: null,
-            scaledCharTop: null,
-            scaledCanvasWidth: null,
-            scaledCanvasHeight: null,
-            canvasWidth: null,
-            canvasHeight: null,
-            actualCellWidth: null,
-            actualCellHeight: null
-        };
-        _this._updateDimensions();
-        _this._renderDebouncer = new RenderDebouncer_1.RenderDebouncer(_this._renderRows.bind(_this));
-        _this._rowFactory = new DomRendererRowFactory_1.DomRendererRowFactory(_terminal.options, document);
-        _this._terminal.element.classList.add(TERMINAL_CLASS_PREFIX + _this._terminalClass);
-        _this._terminal.screenElement.appendChild(_this._rowContainer);
-        _this._terminal.screenElement.appendChild(_this._selectionContainer);
-        _this._terminal.linkifier.onLinkHover(function (e) { return _this._onLinkHover(e); });
-        _this._terminal.linkifier.onLinkLeave(function (e) { return _this._onLinkLeave(e); });
-        return _this;
-    }
-    Object.defineProperty(DomRenderer.prototype, "onCanvasResize", {
-        get: function () { return this._onCanvasResize.event; },
-        enumerable: true,
-        configurable: true
-    });
-    Object.defineProperty(DomRenderer.prototype, "onRender", {
-        get: function () { return this._onRender.event; },
-        enumerable: true,
-        configurable: true
-    });
-    DomRenderer.prototype.dispose = function () {
-        this._terminal.element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);
-        this._terminal.screenElement.removeChild(this._rowContainer);
-        this._terminal.screenElement.removeChild(this._selectionContainer);
-        this._terminal.screenElement.removeChild(this._themeStyleElement);
-        this._terminal.screenElement.removeChild(this._dimensionsStyleElement);
-        _super.prototype.dispose.call(this);
-    };
-    DomRenderer.prototype._updateDimensions = function () {
-        var _this = this;
-        this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
-        this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);
-        this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);
-        this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);
-        this.dimensions.scaledCharLeft = 0;
-        this.dimensions.scaledCharTop = 0;
-        this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._terminal.cols;
-        this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._terminal.rows;
-        this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
-        this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
-        this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;
-        this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;
-        this._rowElements.forEach(function (element) {
-            element.style.width = _this.dimensions.canvasWidth + "px";
-            element.style.height = _this.dimensions.actualCellHeight + "px";
-            element.style.lineHeight = _this.dimensions.actualCellHeight + "px";
-            element.style.overflow = 'hidden';
-        });
-        if (!this._dimensionsStyleElement) {
-            this._dimensionsStyleElement = document.createElement('style');
-            this._terminal.screenElement.appendChild(this._dimensionsStyleElement);
-        }
-        var styles = this._terminalSelector + " ." + ROW_CONTAINER_CLASS + " span {" +
-            " display: inline-block;" +
-            " height: 100%;" +
-            " vertical-align: top;" +
-            (" width: " + this.dimensions.actualCellWidth + "px") +
-            "}";
-        this._dimensionsStyleElement.innerHTML = styles;
-        this._selectionContainer.style.height = this._terminal._viewportElement.style.height;
-        this._terminal.screenElement.style.width = this.dimensions.canvasWidth + "px";
-        this._terminal.screenElement.style.height = this.dimensions.canvasHeight + "px";
-    };
-    DomRenderer.prototype.setTheme = function (theme) {
-        var _this = this;
-        if (theme) {
-            this.colorManager.setTheme(theme);
-        }
-        if (!this._themeStyleElement) {
-            this._themeStyleElement = document.createElement('style');
-            this._terminal.screenElement.appendChild(this._themeStyleElement);
-        }
-        var styles = this._terminalSelector + " ." + ROW_CONTAINER_CLASS + " {" +
-            (" color: " + this.colorManager.colors.foreground.css + ";") +
-            (" background-color: " + this.colorManager.colors.background.css + ";") +
-            (" font-family: " + this._terminal.getOption('fontFamily') + ";") +
-            (" font-size: " + this._terminal.getOption('fontSize') + "px;") +
-            "}";
-        styles +=
-            this._terminalSelector + " span:not(." + DomRendererRowFactory_1.BOLD_CLASS + ") {" +
-                (" font-weight: " + this._terminal.options.fontWeight + ";") +
-                "}" +
-                (this._terminalSelector + " span." + DomRendererRowFactory_1.BOLD_CLASS + " {") +
-                (" font-weight: " + this._terminal.options.fontWeightBold + ";") +
-                "}" +
-                (this._terminalSelector + " span." + DomRendererRowFactory_1.ITALIC_CLASS + " {") +
-                " font-style: italic;" +
-                "}";
-        styles +=
-            "@keyframes blink {" +
-                " 0% { opacity: 1.0; }" +
-                " 50% { opacity: 0.0; }" +
-                " 100% { opacity: 1.0; }" +
-                "}";
-        styles +=
-            this._terminalSelector + " ." + ROW_CONTAINER_CLASS + ":not(." + FOCUS_CLASS + ") ." + DomRendererRowFactory_1.CURSOR_CLASS + " {" +
-                (" outline: 1px solid " + this.colorManager.colors.cursor.css + ";") +
-                " outline-offset: -1px;" +
-                "}" +
-                (this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_BLINK_CLASS + " {") +
-                " animation: blink 1s step-end infinite;" +
-                "}" +
-                (this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_STYLE_BLOCK_CLASS + " {") +
-                (" background-color: " + this.colorManager.colors.cursor.css + ";") +
-                (" color: " + this.colorManager.colors.cursorAccent.css + ";") +
-                "}" +
-                (this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_STYLE_BAR_CLASS + " {") +
-                (" box-shadow: 1px 0 0 " + this.colorManager.colors.cursor.css + " inset;") +
-                "}" +
-                (this._terminalSelector + " ." + ROW_CONTAINER_CLASS + "." + FOCUS_CLASS + " ." + DomRendererRowFactory_1.CURSOR_CLASS + "." + DomRendererRowFactory_1.CURSOR_STYLE_UNDERLINE_CLASS + " {") +
-                (" box-shadow: 0 -1px 0 " + this.colorManager.colors.cursor.css + " inset;") +
-                "}";
-        styles +=
-            this._terminalSelector + " ." + SELECTION_CLASS + " {" +
-                " position: absolute;" +
-                " top: 0;" +
-                " left: 0;" +
-                " z-index: 1;" +
-                " pointer-events: none;" +
-                "}" +
-                (this._terminalSelector + " ." + SELECTION_CLASS + " div {") +
-                " position: absolute;" +
-                (" background-color: " + this.colorManager.colors.selection.css + ";") +
-                "}";
-        this.colorManager.colors.ansi.forEach(function (c, i) {
-            styles +=
-                _this._terminalSelector + " ." + FG_CLASS_PREFIX + i + " { color: " + c.css + "; }" +
-                    (_this._terminalSelector + " ." + BG_CLASS_PREFIX + i + " { background-color: " + c.css + "; }");
-        });
-        styles +=
-            this._terminalSelector + " ." + FG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { color: " + this.colorManager.colors.background.css + "; }" +
-                (this._terminalSelector + " ." + BG_CLASS_PREFIX + Types_1.INVERTED_DEFAULT_COLOR + " { background-color: " + this.colorManager.colors.foreground.css + "; }");
-        this._themeStyleElement.innerHTML = styles;
-        return this.colorManager.colors;
-    };
-    DomRenderer.prototype.onWindowResize = function (devicePixelRatio) {
-        this._updateDimensions();
-    };
-    DomRenderer.prototype._refreshRowElements = function (cols, rows) {
-        for (var i = this._rowElements.length; i <= rows; i++) {
-            var row = document.createElement('div');
-            this._rowContainer.appendChild(row);
-            this._rowElements.push(row);
-        }
-        while (this._rowElements.length > rows) {
-            this._rowContainer.removeChild(this._rowElements.pop());
-        }
-    };
-    DomRenderer.prototype.onResize = function (cols, rows) {
-        this._refreshRowElements(cols, rows);
-        this._updateDimensions();
-        this._onCanvasResize.fire({
-            width: this.dimensions.canvasWidth,
-            height: this.dimensions.canvasHeight
-        });
-    };
-    DomRenderer.prototype.onCharSizeChanged = function () {
-        this._updateDimensions();
-    };
-    DomRenderer.prototype.onBlur = function () {
-        this._rowContainer.classList.remove(FOCUS_CLASS);
-    };
-    DomRenderer.prototype.onFocus = function () {
-        this._rowContainer.classList.add(FOCUS_CLASS);
-    };
-    DomRenderer.prototype.onSelectionChanged = function (start, end, columnSelectMode) {
-        while (this._selectionContainer.children.length) {
-            this._selectionContainer.removeChild(this._selectionContainer.children[0]);
-        }
-        if (!start || !end) {
-            return;
-        }
-        var viewportStartRow = start[1] - this._terminal.buffer.ydisp;
-        var viewportEndRow = end[1] - this._terminal.buffer.ydisp;
-        var viewportCappedStartRow = Math.max(viewportStartRow, 0);
-        var viewportCappedEndRow = Math.min(viewportEndRow, this._terminal.rows - 1);
-        if (viewportCappedStartRow >= this._terminal.rows || viewportCappedEndRow < 0) {
-            return;
-        }
-        var documentFragment = document.createDocumentFragment();
-        if (columnSelectMode) {
-            documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, start[0], end[0], viewportCappedEndRow - viewportCappedStartRow + 1));
-        }
-        else {
-            var startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
-            var endCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : this._terminal.cols;
-            documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));
-            var middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;
-            documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._terminal.cols, middleRowsCount));
-            if (viewportCappedStartRow !== viewportCappedEndRow) {
-                var endCol_1 = viewportEndRow === viewportCappedEndRow ? end[0] : this._terminal.cols;
-                documentFragment.appendChild(this._createSelectionElement(viewportCappedEndRow, 0, endCol_1));
-            }
-        }
-        this._selectionContainer.appendChild(documentFragment);
-    };
-    DomRenderer.prototype._createSelectionElement = function (row, colStart, colEnd, rowCount) {
-        if (rowCount === void 0) { rowCount = 1; }
-        var element = document.createElement('div');
-        element.style.height = rowCount * this.dimensions.actualCellHeight + "px";
-        element.style.top = row * this.dimensions.actualCellHeight + "px";
-        element.style.left = colStart * this.dimensions.actualCellWidth + "px";
-        element.style.width = this.dimensions.actualCellWidth * (colEnd - colStart) + "px";
-        return element;
-    };
-    DomRenderer.prototype.onCursorMove = function () {
-    };
-    DomRenderer.prototype.onOptionsChanged = function () {
-        this._updateDimensions();
-        this.setTheme(undefined);
-        this._terminal.refresh(0, this._terminal.rows - 1);
-    };
-    DomRenderer.prototype.clear = function () {
-        this._rowElements.forEach(function (e) { return e.innerHTML = ''; });
-    };
-    DomRenderer.prototype.refreshRows = function (start, end) {
-        this._renderDebouncer.refresh(start, end, this._terminal.rows);
-    };
-    DomRenderer.prototype._renderRows = function (start, end) {
-        var terminal = this._terminal;
-        var cursorAbsoluteY = terminal.buffer.ybase + terminal.buffer.y;
-        var cursorX = this._terminal.buffer.x;
-        var cursorBlink = this._terminal.options.cursorBlink;
-        for (var y = start; y <= end; y++) {
-            var rowElement = this._rowElements[y];
-            rowElement.innerHTML = '';
-            var row = y + terminal.buffer.ydisp;
-            var lineData = terminal.buffer.lines.get(row);
-            var cursorStyle = terminal.options.cursorStyle;
-            rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, terminal.cols));
-        }
-        this._onRender.fire({ start: start, end: end });
-    };
-    Object.defineProperty(DomRenderer.prototype, "_terminalSelector", {
-        get: function () {
-            return "." + TERMINAL_CLASS_PREFIX + this._terminalClass;
-        },
-        enumerable: true,
-        configurable: true
-    });
-    DomRenderer.prototype.registerCharacterJoiner = function (handler) { return -1; };
-    DomRenderer.prototype.deregisterCharacterJoiner = function (joinerId) { return false; };
-    DomRenderer.prototype._onLinkHover = function (e) {
-        this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, true);
-    };
-    DomRenderer.prototype._onLinkLeave = function (e) {
-        this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, false);
-    };
-    DomRenderer.prototype._setCellUnderline = function (x, x2, y, y2, cols, enabled) {
-        while (x !== x2 || y !== y2) {
-            var row = this._rowElements[y];
-            if (!row) {
-                return;
-            }
-            var span = row.children[x];
-            if (span) {
-                span.style.textDecoration = enabled ? 'underline' : 'none';
-            }
-            if (++x >= cols) {
-                x = 0;
-                y++;
-            }
-        }
-    };
-    return DomRenderer;
-}(Lifecycle_1.Disposable));
-exports.DomRenderer = DomRenderer;
-
-},{"../../common/EventEmitter2":25,"../../common/Lifecycle":26,"../../ui/RenderDebouncer":56,"../ColorManager":37,"../atlas/Types":52,"./DomRendererRowFactory":54}],54:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Buffer_1 = require("../../Buffer");
-var Types_1 = require("../atlas/Types");
-var BufferLine_1 = require("../../BufferLine");
-exports.BOLD_CLASS = 'xterm-bold';
-exports.DIM_CLASS = 'xterm-dim';
-exports.ITALIC_CLASS = 'xterm-italic';
-exports.UNDERLINE_CLASS = 'xterm-underline';
-exports.CURSOR_CLASS = 'xterm-cursor';
-exports.CURSOR_BLINK_CLASS = 'xterm-cursor-blink';
-exports.CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block';
-exports.CURSOR_STYLE_BAR_CLASS = 'xterm-cursor-bar';
-exports.CURSOR_STYLE_UNDERLINE_CLASS = 'xterm-cursor-underline';
-var DomRendererRowFactory = (function () {
-    function DomRendererRowFactory(_terminalOptions, _document) {
-        this._terminalOptions = _terminalOptions;
-        this._document = _document;
-        this._workCell = new BufferLine_1.CellData();
-    }
-    DomRendererRowFactory.prototype.createRow = function (lineData, isCursorRow, cursorStyle, cursorX, cursorBlink, cellWidth, cols) {
-        var fragment = this._document.createDocumentFragment();
-        var lineLength = 0;
-        for (var x = Math.min(lineData.length, cols) - 1; x >= 0; x--) {
-            if (lineData.loadCell(x, this._workCell).getCode() !== Buffer_1.NULL_CELL_CODE || (isCursorRow && x === cursorX)) {
-                lineLength = x + 1;
-                break;
-            }
-        }
-        for (var x = 0; x < lineLength; x++) {
-            lineData.loadCell(x, this._workCell);
-            var width = this._workCell.getWidth();
-            if (width === 0) {
-                continue;
-            }
-            var charElement = this._document.createElement('span');
-            if (width > 1) {
-                charElement.style.width = cellWidth * width + "px";
-            }
-            if (isCursorRow && x === cursorX) {
-                charElement.classList.add(exports.CURSOR_CLASS);
-                if (cursorBlink) {
-                    charElement.classList.add(exports.CURSOR_BLINK_CLASS);
-                }
-                switch (cursorStyle) {
-                    case 'bar':
-                        charElement.classList.add(exports.CURSOR_STYLE_BAR_CLASS);
-                        break;
-                    case 'underline':
-                        charElement.classList.add(exports.CURSOR_STYLE_UNDERLINE_CLASS);
-                        break;
-                    default:
-                        charElement.classList.add(exports.CURSOR_STYLE_BLOCK_CLASS);
-                        break;
-                }
-            }
-            if (this._workCell.isBold() && this._terminalOptions.enableBold) {
-                charElement.classList.add(exports.BOLD_CLASS);
-            }
-            if (this._workCell.isItalic()) {
-                charElement.classList.add(exports.ITALIC_CLASS);
-            }
-            if (this._workCell.isDim()) {
-                charElement.classList.add(exports.DIM_CLASS);
-            }
-            if (this._workCell.isUnderline()) {
-                charElement.classList.add(exports.UNDERLINE_CLASS);
-            }
-            charElement.textContent = this._workCell.getChars() || Buffer_1.WHITESPACE_CELL_CHAR;
-            var swapColor = this._workCell.isInverse();
-            if (this._workCell.isFgRGB()) {
-                var style = charElement.getAttribute('style') || '';
-                style += (swapColor ? 'background-' : '') + "color:rgb(" + (BufferLine_1.AttributeData.toColorRGB(this._workCell.getFgColor())).join(',') + ");";
-                charElement.setAttribute('style', style);
-            }
-            else if (this._workCell.isFgPalette()) {
-                var fg = this._workCell.getFgColor();
-                if (this._workCell.isBold() && fg < 8 && !swapColor &&
-                    this._terminalOptions.enableBold && this._terminalOptions.drawBoldTextInBrightColors) {
-                    fg += 8;
-                }
-                charElement.classList.add("xterm-" + (swapColor ? 'b' : 'f') + "g-" + fg);
-            }
-            else if (swapColor) {
-                charElement.classList.add("xterm-bg-" + Types_1.INVERTED_DEFAULT_COLOR);
-            }
-            if (this._workCell.isBgRGB()) {
-                var style = charElement.getAttribute('style') || '';
-                style += (swapColor ? '' : 'background-') + "color:rgb(" + (BufferLine_1.AttributeData.toColorRGB(this._workCell.getBgColor())).join(',') + ");";
-                charElement.setAttribute('style', style);
-            }
-            else if (this._workCell.isBgPalette()) {
-                charElement.classList.add("xterm-" + (swapColor ? 'f' : 'b') + "g-" + this._workCell.getBgColor());
-            }
-            else if (swapColor) {
-                charElement.classList.add("xterm-fg-" + Types_1.INVERTED_DEFAULT_COLOR);
-            }
-            fragment.appendChild(charElement);
-        }
-        return fragment;
-    };
-    return DomRendererRowFactory;
-}());
-exports.DomRendererRowFactory = DomRendererRowFactory;
-
-},{"../../Buffer":2,"../../BufferLine":3,"../atlas/Types":52}],55:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-function addDisposableDomListener(node, type, handler, useCapture) {
-    node.addEventListener(type, handler, useCapture);
-    return {
-        dispose: function () {
-            if (!handler) {
-                return;
-            }
-            node.removeEventListener(type, handler, useCapture);
-        }
-    };
-}
-exports.addDisposableDomListener = addDisposableDomListener;
-
-},{}],56:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var RenderDebouncer = (function () {
-    function RenderDebouncer(_renderCallback) {
-        this._renderCallback = _renderCallback;
-    }
-    RenderDebouncer.prototype.dispose = function () {
-        if (this._animationFrame) {
-            window.cancelAnimationFrame(this._animationFrame);
-            this._animationFrame = undefined;
-        }
-    };
-    RenderDebouncer.prototype.refresh = function (rowStart, rowEnd, rowCount) {
-        var _this = this;
-        this._rowCount = rowCount;
-        rowStart = rowStart !== undefined ? rowStart : 0;
-        rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;
-        this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;
-        this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;
-        if (this._animationFrame) {
-            return;
-        }
-        this._animationFrame = window.requestAnimationFrame(function () { return _this._innerRefresh(); });
-    };
-    RenderDebouncer.prototype._innerRefresh = function () {
-        if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) {
-            return;
-        }
-        this._rowStart = Math.max(this._rowStart, 0);
-        this._rowEnd = Math.min(this._rowEnd, this._rowCount - 1);
-        this._renderCallback(this._rowStart, this._rowEnd);
-        this._rowStart = undefined;
-        this._rowEnd = undefined;
-        this._animationFrame = undefined;
-    };
-    return RenderDebouncer;
-}());
-exports.RenderDebouncer = RenderDebouncer;
-
-},{}],57:[function(require,module,exports){
-"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-var Lifecycle_1 = require("../common/Lifecycle");
-var ScreenDprMonitor = (function (_super) {
-    __extends(ScreenDprMonitor, _super);
-    function ScreenDprMonitor() {
-        var _this = _super !== null && _super.apply(this, arguments) || this;
-        _this._currentDevicePixelRatio = window.devicePixelRatio;
-        return _this;
-    }
-    ScreenDprMonitor.prototype.setListener = function (listener) {
-        var _this = this;
-        if (this._listener) {
-            this.clearListener();
-        }
-        this._listener = listener;
-        this._outerListener = function () {
-            if (!_this._listener) {
-                return;
-            }
-            _this._listener(window.devicePixelRatio, _this._currentDevicePixelRatio);
-            _this._updateDpr();
-        };
-        this._updateDpr();
-    };
-    ScreenDprMonitor.prototype.dispose = function () {
-        _super.prototype.dispose.call(this);
-        this.clearListener();
-    };
-    ScreenDprMonitor.prototype._updateDpr = function () {
-        if (!this._resolutionMediaMatchList || !this._outerListener) {
-            return;
-        }
-        this._resolutionMediaMatchList.removeListener(this._outerListener);
-        this._currentDevicePixelRatio = window.devicePixelRatio;
-        this._resolutionMediaMatchList = window.matchMedia("screen and (resolution: " + window.devicePixelRatio + "dppx)");
-        this._resolutionMediaMatchList.addListener(this._outerListener);
-    };
-    ScreenDprMonitor.prototype.clearListener = function () {
-        if (!this._resolutionMediaMatchList || !this._listener || !this._outerListener) {
-            return;
-        }
-        this._resolutionMediaMatchList.removeListener(this._outerListener);
-        this._resolutionMediaMatchList = undefined;
-        this._listener = undefined;
-        this._outerListener = undefined;
-    };
-    return ScreenDprMonitor;
-}(Lifecycle_1.Disposable));
-exports.ScreenDprMonitor = ScreenDprMonitor;
-
-},{"../common/Lifecycle":26}],58:[function(require,module,exports){
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-var Terminal_1 = require("./public/Terminal");
-module.exports = Terminal_1.Terminal;
-
-},{"./public/Terminal":34}]},{},[58])(58)
-});
-//# sourceMappingURL=xterm.js.map
+!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(window,function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=33)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(14);t.IBufferService=i.createDecorator("BufferService"),t.ICoreMouseService=i.createDecorator("CoreMouseService"),t.ICoreService=i.createDecorator("CoreService"),t.IDirtyRowService=i.createDecorator("DirtyRowService"),t.IInstantiationService=i.createDecorator("InstantiationService"),t.ILogService=i.createDecorator("LogService"),t.IOptionsService=i.createDecorator("OptionsService")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._listeners=[],this._disposed=!1}return Object.defineProperty(e.prototype,"event",{get:function(){var e=this;return this._event||(this._event=function(t){return e._listeners.push(t),{dispose:function(){if(!e._disposed)for(var r=0;r<e._listeners.length;r++)if(e._listeners[r]===t)return void e._listeners.splice(r,1)}}}),this._event},enumerable:!0,configurable:!0}),e.prototype.fire=function(e){for(var t=[],r=0;r<this._listeners.length;r++)t.push(this._listeners[r]);for(r=0;r<t.length;r++)t[r].call(void 0,e)},e.prototype.dispose=function(){this._listeners&&(this._listeners.length=0),this._disposed=!0},e}();t.EventEmitter=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._disposables=[],this._isDisposed=!1}return e.prototype.dispose=function(){this._isDisposed=!0,this._disposables.forEach(function(e){return e.dispose()}),this._disposables.length=0},e.prototype.register=function(e){this._disposables.push(e)},e.prototype.unregister=function(e){var t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)},e}();t.Disposable=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_COLOR=256,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(14);t.ICharSizeService=i.createDecorator("CharSizeService"),t.ICoreBrowserService=i.createDecorator("CoreBrowserService"),t.IMouseService=i.createDecorator("MouseService"),t.IRenderService=i.createDecorator("RenderService"),t.ISelectionService=i.createDecorator("SelectionService"),t.ISoundService=i.createDecorator("SoundService")},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(8),s=r(3),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.content=0,t.fg=0,t.bg=0,t.combinedData="",t}return n(t,e),t.fromCharData=function(e){var r=new t;return r.setFromCharData(e),r},t.prototype.isCombined=function(){return 2097152&this.content},t.prototype.getWidth=function(){return this.content>>22},t.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?o.stringFromCodePoint(2097151&this.content):""},t.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},t.prototype.setFromCharData=function(e){this.fg=e[s.CHAR_DATA_ATTR_INDEX],this.bg=0;var t=!1;if(e[s.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(2===e[s.CHAR_DATA_CHAR_INDEX].length){var r=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=r&&r<=56319){var i=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(r-55296)+i-56320+65536|e[s.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[s.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[s.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[s.CHAR_DATA_WIDTH_INDEX]<<22)},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(r(6).AttributeData);t.CellData=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.fg=0,this.bg=0}return e.toColorRGB=function(e){return[e>>>16&255,e>>>8&255,255&e]},e.fromColorRGB=function(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},e.prototype.clone=function(){var t=new e;return t.fg=this.fg,t.bg=this.bg,t},e.prototype.isInverse=function(){return 67108864&this.fg},e.prototype.isBold=function(){return 134217728&this.fg},e.prototype.isUnderline=function(){return 268435456&this.fg},e.prototype.isBlink=function(){return 536870912&this.fg},e.prototype.isInvisible=function(){return 1073741824&this.fg},e.prototype.isItalic=function(){return 67108864&this.bg},e.prototype.isDim=function(){return 134217728&this.bg},e.prototype.getFgColorMode=function(){return 50331648&this.fg},e.prototype.getBgColorMode=function(){return 50331648&this.bg},e.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},e.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},e.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},e.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},e.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},e.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},e.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},e.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},e}();t.AttributeData=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=function(e,t,r,i){return e.addEventListener(t,r,i),{dispose:function(){r&&e.removeEventListener(t,r,i)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=e.length);for(var i="",n=t;n<r;++n){var o=e[n];o>65535?(o-=65536,i+=String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i};var i=function(){function e(){this._interim=0}return e.prototype.clear=function(){this._interim=0},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i=0,n=0;this._interim&&(56320<=(a=e.charCodeAt(n++))&&a<=57343?t[i++]=1024*(this._interim-55296)+a-56320+65536:(t[i++]=this._interim,t[i++]=a),this._interim=0);for(var o=n;o<r;++o){var s=e.charCodeAt(o);if(55296<=s&&s<=56319){if(++o>=r)return this._interim=s,i;var a;56320<=(a=e.charCodeAt(o))&&a<=57343?t[i++]=1024*(s-55296)+a-56320+65536:(t[i++]=s,t[i++]=a)}else t[i++]=s}return i},e}();t.StringToUtf32=i;var n=function(){function e(){this.interim=new Uint8Array(3)}return e.prototype.clear=function(){this.interim.fill(0)},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i,n,o,s,a=0,c=0,l=0;if(this.interim[0]){var h=!1,u=this.interim[0];u&=192==(224&u)?31:224==(240&u)?15:7;for(var f=0,_=void 0;(_=63&this.interim[++f])&&f<4;)u<<=6,u|=_;for(var d=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,p=d-f;l<p;){if(l>=r)return 0;if(128!=(192&(_=e[l++]))){l--,h=!0;break}this.interim[f++]=_,u<<=6,u|=63&_}h||(2===d?u<128?l--:t[a++]=u:3===d?u<2048||u>=55296&&u<=57343||(t[a++]=u):u<65536||u>1114111||(t[a++]=u)),this.interim.fill(0)}for(var v=r-4,g=l;g<r;){for(;!(!(g<v)||128&(i=e[g])||128&(n=e[g+1])||128&(o=e[g+2])||128&(s=e[g+3]));)t[a++]=i,t[a++]=n,t[a++]=o,t[a++]=s,g+=4;if((i=e[g++])<128)t[a++]=i;else if(192==(224&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if((c=(31&i)<<6|63&n)<128){g--;continue}t[a++]=c}else if(224==(240&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(o=e[g++]))){g--;continue}if((c=(15&i)<<12|(63&n)<<6|63&o)<2048||c>=55296&&c<=57343)continue;t[a++]=c}else if(240==(248&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(o=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,this.interim[2]=o,a;if(128!=(192&(s=e[g++]))){g--;continue}if((c=(7&i)<<18|(63&n)<<12|(63&o)<<6|63&s)<65536||c>1114111)continue;t[a++]=c}}return a},e}();t.Utf8ToUtf32=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.CHAR_ATLAS_CELL_SPACING=1},function(e,t,r){"use strict";function i(e){var t=e.toString(16);return t.length<2?"0"+t:t}function n(e,t,r,n){return void 0!==n?"#"+i(e)+i(t)+i(r)+i(n):"#"+i(e)+i(t)+i(r)}function o(e,t,r,i){return void 0===i&&(i=255),(e<<24|t<<16|r<<8|i)>>>0}function s(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}function a(e){return c(e>>16&255,e>>8&255,255&e)}function c(e,t,r){var i=e/255,n=t/255,o=r/255;return.2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}function l(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function h(e,t,r){return{css:n(e,t,r),rgba:o(e,t,r)}}function u(e,t,r){var i=a(e>>8),n=a(t>>8);if(l(i,n)<r)return n<i?f(e,t,r):_(e,t,r)}function f(e,t,r){for(var i=e>>24&255,n=e>>16&255,o=e>>8&255,s=t>>24&255,a=t>>16&255,h=t>>8&255,u=l(c(s,h,a),c(i,n,o));u<r&&(s>0||a>0||h>0);)s-=Math.max(0,Math.ceil(.1*s)),a-=Math.max(0,Math.ceil(.1*a)),u=l(c(s,h-=Math.max(0,Math.ceil(.1*h)),a),c(i,n,o));return(s<<24|a<<16|h<<8|255)>>>0}function _(e,t,r){for(var i=e>>24&255,n=e>>16&255,o=e>>8&255,s=t>>24&255,a=t>>16&255,h=t>>8&255,u=l(c(s,h,a),c(i,n,o));u<r&&(s<255||a<255||h<255);)s=Math.min(255,s+Math.ceil(.1*(255-s))),a=Math.min(255,a+Math.ceil(.1*(255-a))),u=l(c(s,h=Math.min(255,h+Math.ceil(.1*(255-h))),a),c(i,n,o));return(s<<24|a<<16|h<<8|255)>>>0}Object.defineProperty(t,"__esModule",{value:!0}),t.blend=function(e,t){var r=(255&t.rgba)/255;if(1===r)return{css:t.css,rgba:t.rgba};var i=t.rgba>>24&255,s=t.rgba>>16&255,a=t.rgba>>8&255,c=e.rgba>>24&255,l=e.rgba>>16&255,h=e.rgba>>8&255,u=c+Math.round((i-c)*r),f=l+Math.round((s-l)*r),_=h+Math.round((a-h)*r);return{css:n(u,f,_),rgba:o(u,f,_)}},t.fromCss=function(e){return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0}},t.toPaddedHex=i,t.toCss=n,t.toRgba=o,t.fromRgba=s,t.opaque=function(e){var t=(255|e.rgba)>>>0,r=s(t);return{css:n(r[0],r[1],r[2]),rgba:t}},t.rgbRelativeLuminance=a,t.rgbRelativeLuminance2=c,t.contrastRatio=l,t.rgbaToColor=h,t.ensureContrastRatioRgba=u,t.ensureContrastRatio=function(e,t,r){var i=u(e.rgba,t.rgba,r);if(i)return h(i>>24&255,i>>16&255,i>>8&255)},t.reduceLuminance=f,t.increaseLuminance=_},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="undefined"==typeof navigator,n=i?"node":navigator.userAgent,o=i?"node":navigator.platform;function s(e,t){return e.indexOf(t)>=0}t.isFirefox=!!~n.indexOf("Firefox"),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.isMac=s(["Macintosh","MacIntel","MacPPC","Mac68K"],o),t.isIpad="iPad"===o,t.isIphone="iPhone"===o,t.isWindows=s(["Windows","Win16","Win32","WinCE"],o),t.isLinux=o.indexOf("Linux")>=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="",e.BS="\b",e.HT="\t",e.LF="\n",e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="",e.FS="
",e.GS="
",e.RS="
",e.US="",e.SP=" ",e.DEL=""}(t.C0||(t.C0={})),function(e){e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="
",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"}(t.C1||(t.C1={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3),n=r(9),o=r(24),s=r(6),a=r(27),c=r(10),l=function(){function e(e,t,r,i,n,o,s,a){this._container=e,this._alpha=i,this._colors=n,this._rendererId=o,this._bufferService=s,this._optionsService=a,this._scaledCharWidth=0,this._scaledCharHeight=0,this._scaledCellWidth=0,this._scaledCellHeight=0,this._scaledCharLeft=0,this._scaledCharTop=0,this._currentGlyphIdentifier={chars:"",code:0,bg:0,fg:0,bold:!1,dim:!1,italic:!1},this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-"+t+"-layer"),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return e.prototype.dispose=function(){var e;this._container.removeChild(this._canvas),null===(e=this._charAtlas)||void 0===e||e.dispose()},e.prototype._initCanvas=function(){this._ctx=a.throwIfFalsy(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()},e.prototype.onOptionsChanged=function(){},e.prototype.onBlur=function(){},e.prototype.onFocus=function(){},e.prototype.onCursorMove=function(){},e.prototype.onGridChanged=function(e,t){},e.prototype.onSelectionChanged=function(e,t,r){void 0===r&&(r=!1)},e.prototype.setColors=function(e){this._refreshCharAtlas(e)},e.prototype._setTransparency=function(e){if(e!==this._alpha){var t=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,t),this._refreshCharAtlas(this._colors),this.onGridChanged(0,this._bufferService.rows-1)}},e.prototype._refreshCharAtlas=function(e){this._scaledCharWidth<=0&&this._scaledCharHeight<=0||(this._charAtlas=o.acquireCharAtlas(this._optionsService.options,this._rendererId,e,this._scaledCharWidth,this._scaledCharHeight),this._charAtlas.warmUp())},e.prototype.resize=function(e){this._scaledCellWidth=e.scaledCellWidth,this._scaledCellHeight=e.scaledCellHeight,this._scaledCharWidth=e.scaledCharWidth,this._scaledCharHeight=e.scaledCharHeight,this._scaledCharLeft=e.scaledCharLeft,this._scaledCharTop=e.scaledCharTop,this._canvas.width=e.scaledCanvasWidth,this._canvas.height=e.scaledCanvasHeight,this._canvas.style.width=e.canvasWidth+"px",this._canvas.style.height=e.canvasHeight+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(this._colors)},e.prototype._fillCells=function(e,t,r,i){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight)},e.prototype._fillBottomLineAtCells=function(e,t,r){void 0===r&&(r=1),this._ctx.fillRect(e*this._scaledCellWidth,(t+1)*this._scaledCellHeight-window.devicePixelRatio-1,r*this._scaledCellWidth,window.devicePixelRatio)},e.prototype._fillLeftLineAtCell=function(e,t){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,window.devicePixelRatio,this._scaledCellHeight)},e.prototype._strokeRectAtCell=function(e,t,r,i){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(e*this._scaledCellWidth+window.devicePixelRatio/2,t*this._scaledCellHeight+window.devicePixelRatio/2,r*this._scaledCellWidth-window.devicePixelRatio,i*this._scaledCellHeight-window.devicePixelRatio)},e.prototype._clearAll=function(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))},e.prototype._clearCells=function(e,t,r,i){this._alpha?this._ctx.clearRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight))},e.prototype._fillCharTrueColor=function(e,t,r){this._ctx.font=this._getFont(!1,!1),this._ctx.textBaseline="middle",this._clipRow(r),this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2)},e.prototype._drawChars=function(e,t,r){var o,s,a=this._getContrastColor(e);a||e.isFgRGB()||e.isBgRGB()?this._drawUncachedChars(e,t,r,a):(e.isInverse()?(o=e.isBgDefault()?n.INVERTED_DEFAULT_COLOR:e.getBgColor(),s=e.isFgDefault()?n.INVERTED_DEFAULT_COLOR:e.getFgColor()):(s=e.isBgDefault()?i.DEFAULT_COLOR:e.getBgColor(),o=e.isFgDefault()?i.DEFAULT_COLOR:e.getFgColor()),o+=this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8?8:0,this._currentGlyphIdentifier.chars=e.getChars()||i.WHITESPACE_CELL_CHAR,this._currentGlyphIdentifier.code=e.getCode()||i.WHITESPACE_CELL_CODE,this._currentGlyphIdentifier.bg=s,this._currentGlyphIdentifier.fg=o,this._currentGlyphIdentifier.bold=!!e.isBold(),this._currentGlyphIdentifier.dim=!!e.isDim(),this._currentGlyphIdentifier.italic=!!e.isItalic(),this._charAtlas&&this._charAtlas.draw(this._ctx,this._currentGlyphIdentifier,t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop)||this._drawUncachedChars(e,t,r))},e.prototype._drawUncachedChars=function(e,t,r,i){if(this._ctx.save(),this._ctx.font=this._getFont(!!e.isBold(),!!e.isItalic()),this._ctx.textBaseline="middle",e.isInverse())if(i)this._ctx.fillStyle=i.css;else if(e.isBgDefault())this._ctx.fillStyle=c.opaque(this._colors.background).css;else if(e.isBgRGB())this._ctx.fillStyle="rgb("+s.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var o=e.getBgColor();this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8&&(o+=8),this._ctx.fillStyle=this._colors.ansi[o].css}else if(i)this._ctx.fillStyle=i.css;else if(e.isFgDefault())this._ctx.fillStyle=this._colors.foreground.css;else if(e.isFgRGB())this._ctx.fillStyle="rgb("+s.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var a=e.getFgColor();this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&a<8&&(a+=8),this._ctx.fillStyle=this._colors.ansi[a].css}this._clipRow(r),e.isDim()&&(this._ctx.globalAlpha=n.DIM_OPACITY),this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2),this._ctx.restore()},e.prototype._clipRow=function(e){this._ctx.beginPath(),this._ctx.rect(0,e*this._scaledCellHeight,this._bufferService.cols*this._scaledCellWidth,this._scaledCellHeight),this._ctx.clip()},e.prototype._getFont=function(e,t){return(t?"italic":"")+" "+(e?this._optionsService.options.fontWeightBold:this._optionsService.options.fontWeight)+" "+this._optionsService.options.fontSize*window.devicePixelRatio+"px "+this._optionsService.options.fontFamily},e.prototype._getContrastColor=function(e){if(1!==this._optionsService.options.minimumContrastRatio){var t=this._colors.contrastCache.getColor(e.bg,e.fg);if(void 0!==t)return t||void 0;var r=e.getFgColor(),i=e.getFgColorMode(),n=e.getBgColor(),o=e.getBgColorMode(),s=!!e.isInverse(),a=!!e.isInverse();if(s){var l=r;r=n,n=l;var h=i;i=o,o=h}var u=this._resolveBackgroundRgba(o,n,s),f=this._resolveForegroundRgba(i,r,s,a),_=c.ensureContrastRatioRgba(u,f,this._optionsService.options.minimumContrastRatio);if(_){var d={css:c.toCss(_>>24&255,_>>16&255,_>>8&255),rgba:_};return this._colors.contrastCache.setColor(e.bg,e.fg,d),d}this._colors.contrastCache.setColor(e.bg,e.fg,null)}},e.prototype._resolveBackgroundRgba=function(e,t,r){switch(e){case 16777216:case 33554432:return this._colors.ansi[t].rgba;case 50331648:return t<<8;case 0:default:return r?this._colors.foreground.rgba:this._colors.background.rgba}},e.prototype._resolveForegroundRgba=function(e,t,r,i){switch(e){case 16777216:case 33554432:return this._optionsService.options.drawBoldTextInBrightColors&&i&&t<8&&(t+=8),this._colors.ansi[t].rgba;case 50331648:return t<<8;case 0:default:return r?this._colors.background.rgba:this._colors.foreground.rgba}},e}();t.BaseRenderLayer=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="di$target",n="di$dependencies";function o(e,t,r){t[i]===t?t[n].push({id:e,index:r}):(t[n]=[{id:e,index:r}],t[i]=t)}t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e[n]||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);var r=function(e,t,i){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");o(r,e,i)};return r.toString=function(){return e},t.serviceRegistry.set(e,r),r}},function(e,t,r){"use strict";function i(e,t,r,i){if(void 0===r&&(r=0),void 0===i&&(i=e.length),r>=e.length)return e;r=(e.length+r)%e.length,i=i>=e.length?e.length:(e.length+i)%e.length;for(var n=r;n<i;++n)e[n]=t;return e}Object.defineProperty(t,"__esModule",{value:!0}),t.fill=function(e,t,r,n){return e.fill?e.fill(t,r,n):i(e,t,r,n)},t.fillFallback=i,t.concat=function(e,t){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(8),n=r(3),o=r(5),s=r(6),a=3;t.DEFAULT_ATTR_DATA=Object.freeze(new s.AttributeData);var c=function(){function e(e,t,r){void 0===r&&(r=!1),this.isWrapped=r,this._combined={},this._data=new Uint32Array(e*a);for(var i=t||o.CellData.fromCharData([0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]),s=0;s<e;++s)this.setCell(s,i);this.length=e}return e.prototype.get=function(e){var t=this._data[e*a+0],r=2097151&t;return[this._data[e*a+1],2097152&t?this._combined[e]:r?i.stringFromCodePoint(r):"",t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):r]},e.prototype.set=function(e,t){this._data[e*a+1]=t[n.CHAR_DATA_ATTR_INDEX],t[n.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[e*a+0]=2097152|e|t[n.CHAR_DATA_WIDTH_INDEX]<<22):this._data[e*a+0]=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.CHAR_DATA_WIDTH_INDEX]<<22},e.prototype.getWidth=function(e){return this._data[e*a+0]>>22},e.prototype.hasWidth=function(e){return 12582912&this._data[e*a+0]},e.prototype.getFg=function(e){return this._data[e*a+1]},e.prototype.getBg=function(e){return this._data[e*a+2]},e.prototype.hasContent=function(e){return 4194303&this._data[e*a+0]},e.prototype.getCodePoint=function(e){var t=this._data[e*a+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t},e.prototype.isCombined=function(e){return 2097152&this._data[e*a+0]},e.prototype.getString=function(e){var t=this._data[e*a+0];return 2097152&t?this._combined[e]:2097151&t?i.stringFromCodePoint(2097151&t):""},e.prototype.loadCell=function(e,t){var r=e*a;return t.content=this._data[r+0],t.fg=this._data[r+1],t.bg=this._data[r+2],2097152&t.content&&(t.combinedData=this._combined[e]),t},e.prototype.setCell=function(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),this._data[e*a+0]=t.content,this._data[e*a+1]=t.fg,this._data[e*a+2]=t.bg},e.prototype.setCellFromCodePoint=function(e,t,r,i,n){this._data[e*a+0]=t|r<<22,this._data[e*a+1]=i,this._data[e*a+2]=n},e.prototype.addCodepointToCell=function(e,t){var r=this._data[e*a+0];2097152&r?this._combined[e]+=i.stringFromCodePoint(t):(2097151&r?(this._combined[e]=i.stringFromCodePoint(2097151&r)+i.stringFromCodePoint(t),r&=-2097152,r|=2097152):r=t|1<<22,this._data[e*a+0]=r)},e.prototype.insertCells=function(e,t,r){if(e%=this.length,t<this.length-e){for(var i=new o.CellData,n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,i));for(n=0;n<t;++n)this.setCell(e+n,r)}else for(n=e;n<this.length;++n)this.setCell(n,r)},e.prototype.deleteCells=function(e,t,r){if(e%=this.length,t<this.length-e){for(var i=new o.CellData,n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,i));for(n=this.length-t;n<this.length;++n)this.setCell(n,r)}else for(n=e;n<this.length;++n)this.setCell(n,r)},e.prototype.replaceCells=function(e,t,r){for(;e<t&&e<this.length;)this.setCell(e++,r)},e.prototype.resize=function(e,t){if(e!==this.length){if(e>this.length){var r=new Uint32Array(e*a);this.length&&(e*a<this._data.length?r.set(this._data.subarray(0,e*a)):r.set(this._data)),this._data=r;for(var i=this.length;i<e;++i)this.setCell(i,t)}else if(e){(r=new Uint32Array(e*a)).set(this._data.subarray(0,e*a)),this._data=r;var n=Object.keys(this._combined);for(i=0;i<n.length;i++){var o=parseInt(n[i],10);o>=e&&delete this._combined[o]}}else this._data=new Uint32Array(0),this._combined={};this.length=e}},e.prototype.fill=function(e){this._combined={};for(var t=0;t<this.length;++t)this.setCell(t,e)},e.prototype.copyFrom=function(e){for(var t in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[t]=e._combined[t];this.isWrapped=e.isWrapped},e.prototype.clone=function(){var t=new e(0);for(var r in t._data=new Uint32Array(this._data),t.length=this.length,this._combined)t._combined[r]=this._combined[r];return t.isWrapped=this.isWrapped,t},e.prototype.getTrimmedLength=function(){for(var e=this.length-1;e>=0;--e)if(4194303&this._data[e*a+0])return e+(this._data[e*a+0]>>22);return 0},e.prototype.copyCellsFrom=function(e,t,r,i,n){var o=e._data;if(n)for(var s=i-1;s>=0;s--)for(var c=0;c<a;c++)this._data[(r+s)*a+c]=o[(t+s)*a+c];else for(s=0;s<i;s++)for(c=0;c<a;c++)this._data[(r+s)*a+c]=o[(t+s)*a+c];var l=Object.keys(e._combined);for(c=0;c<l.length;c++){var h=parseInt(l[c],10);h>=t&&(this._combined[h-t+r]=e._combined[h])}},e.prototype.translateToString=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=0),void 0===r&&(r=this.length),e&&(r=Math.min(r,this.getTrimmedLength()));for(var o="";t<r;){var s=this._data[t*a+0],c=2097151&s;o+=2097152&s?this._combined[t]:c?i.stringFromCodePoint(c):n.WHITESPACE_CELL_CHAR,t+=s>>22||1}return o},e}();t.BufferLine=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.promptLabel="Terminal input",t.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"◆",a:"▒",b:"\t",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"␤",i:"\v",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},t.CHARSETS.A={"#":"£"},t.CHARSETS.B=null,t.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},t.CHARSETS.C=t.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},t.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},t.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},t.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},t.CHARSETS.E=t.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},t.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},t.CHARSETS.H=t.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(15);t.wcwidth=function(e){var t=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],r=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];var n=0|e.control,o=new Uint8Array(65536);i.fill(o,1),o[0]=e.nul,i.fill(o,e.control,1,32),i.fill(o,e.control,127,160),i.fill(o,2,4352,4448),o[9001]=2,o[9002]=2,i.fill(o,2,11904,42192),o[12351]=1,i.fill(o,2,44032,55204),i.fill(o,2,63744,64256),i.fill(o,2,65040,65050),i.fill(o,2,65072,65136),i.fill(o,2,65280,65377),i.fill(o,2,65504,65511);for(var s=0;s<t.length;++s)i.fill(o,0,t[s][0],t[s][1]+1);return function(e){return e<32?0|n:e<127?1:e<65536?o[e]:function(e,t){var r,i=0,n=t.length-1;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=i;)if(e>t[r=i+n>>1][1])i=r+1;else{if(!(e<t[r][0]))return!0;n=r-1}return!1}(t=e,r)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1;var t}}({nul:0,control:0}),t.getStringCellWidth=function(e){for(var r=0,i=e.length,n=0;n<i;++n){var o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return r+t.wcwidth(o);var s=e.charCodeAt(n);56320<=s&&s<=57343?o=1024*(o-55296)+s-56320+65536:r+=t.wcwidth(s)}r+=t.wcwidth(o)}return r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=256,n=function(){function e(e,t){if(void 0===e&&(e=32),void 0===t&&(t=32),this.maxLength=e,this.maxSubParamsLength=t,t>i)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}return e.fromArray=function(t){var r=new e;if(!t.length)return r;for(var i=t[0]instanceof Array?1:0;i<t.length;++i){var n=t[i];if(n instanceof Array)for(var o=0;o<n.length;++o)r.addSubParam(n[o]);else r.addParam(n)}return r},e.prototype.clone=function(){var t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t},e.prototype.toArray=function(){for(var e=[],t=0;t<this.length;++t){e.push(this.params[t]);var r=this._subParamsIdx[t]>>8,i=255&this._subParamsIdx[t];i-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,i))}return e},e.prototype.reset=function(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1},e.prototype.addParam=function(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>2147483647?2147483647:e}},e.prototype.addSubParam=function(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>2147483647?2147483647:e,this._subParamsIdx[this.length-1]++}},e.prototype.hasSubParams=function(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0},e.prototype.getSubParams=function(e){var t=this._subParamsIdx[e]>>8,r=255&this._subParamsIdx[e];return r-t>0?this._subParams.subarray(t,r):null},e.prototype.getSubParamsAll=function(){for(var e={},t=0;t<this.length;++t){var r=this._subParamsIdx[t]>>8,i=255&this._subParamsIdx[t];i-r>0&&(e[t]=this._subParams.slice(r,i))}return e},e.prototype.addDigit=function(e){var t;if(!(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)){var r=this._digitIsSub?this._subParams:this.params,i=r[t-1];r[t-1]=~i?Math.min(10*i+e,2147483647):e}},e}();t.Params=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(22),n=r(8),o=function(){function e(){this._state=0,this._id=-1,this._handlers=Object.create(null),this._handlerFb=function(){}}return e.prototype.addHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.setHandler=function(e,t){this._handlers[e]=[t]},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){}},e.prototype.reset=function(){2===this._state&&this.end(!1),this._id=-1,this._state=0},e.prototype._start=function(){var e=this._handlers[this._id];if(e)for(var t=e.length-1;t>=0;t--)e[t].start();else this._handlerFb(this._id,"START")},e.prototype._put=function(e,t,r){var i=this._handlers[this._id];if(i)for(var o=i.length-1;o>=0;o--)i[o].put(e,t,r);else this._handlerFb(this._id,"PUT",n.utf32ToString(e,t,r))},e.prototype._end=function(e){var t=this._handlers[this._id];if(t){for(var r=t.length-1;r>=0&&!1===t[r].end(e);r--);for(r--;r>=0;r--)t[r].end(!1)}else this._handlerFb(this._id,"END",e)},e.prototype.start=function(){this.reset(),this._id=-1,this._state=1},e.prototype.put=function(e,t,r){if(3!==this._state){if(1===this._state)for(;t<r;){var i=e[t++];if(59===i){this._state=2,this._start();break}if(i<48||57<i)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+i-48}2===this._state&&r-t>0&&this._put(e,t,r)}},e.prototype.end=function(e){0!==this._state&&(3!==this._state&&(1===this._state&&this._start(),this._end(e)),this._id=-1,this._state=0)},e}();t.OscParser=o;var s=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.start=function(){this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=n.utf32ToString(e,t,r),this._data.length>i.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.end=function(e){var t;return this._hitLimit?t=!1:e&&(t=this._handler(this._data)),this._data="",this._hitLimit=!1,t},e}();t.OscHandler=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=1e7},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(8),n=r(20),o=r(22),s=[],a=function(){function e(){this._handlers=Object.create(null),this._active=s,this._ident=0,this._handlerFb=function(){}}return e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){}},e.prototype.addHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.setHandler=function(e,t){this._handlers[e]=[t]},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.reset=function(){this._active.length&&this.unhook(!1),this._active=s,this._ident=0},e.prototype.hook=function(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||s,this._active.length)for(var r=this._active.length-1;r>=0;r--)this._active[r].hook(t);else this._handlerFb(this._ident,"HOOK",t)},e.prototype.put=function(e,t,r){if(this._active.length)for(var n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r);else this._handlerFb(this._ident,"PUT",i.utf32ToString(e,t,r))},e.prototype.unhook=function(e){if(this._active.length){for(var t=this._active.length-1;t>=0&&!1===this._active[t].unhook(e);t--);for(t--;t>=0;t--)this._active[t].unhook(!1)}else this._handlerFb(this._ident,"UNHOOK",e);this._active=s,this._ident=0},e}();t.DcsParser=a;var c=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.hook=function(e){this._params=e.clone(),this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=i.utf32ToString(e,t,r),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.unhook=function(e){var t;return this._hitLimit?t=!1:e&&(t=this._handler(this._data,this._params?this._params:new n.Params)),this._params=void 0,this._data="",this._hitLimit=!1,t},e}();t.DcsHandler=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(25),n=r(43),o=[];t.acquireCharAtlas=function(e,t,r,s,a){for(var c=i.generateConfig(s,a,e,r),l=0;l<o.length;l++){var h=(u=o[l]).ownedBy.indexOf(t);if(h>=0){if(i.configEquals(u.config,c))return u.atlas;1===u.ownedBy.length?(u.atlas.dispose(),o.splice(l,1)):u.ownedBy.splice(h,1);break}}for(l=0;l<o.length;l++){var u=o[l];if(i.configEquals(u.config,c))return u.ownedBy.push(t),u.atlas}var f={atlas:new n.DynamicCharAtlas(document,c),config:c,ownedBy:[t]};return o.push(f),f.atlas},t.removeTerminalFromCache=function(e){for(var t=0;t<o.length;t++){var r=o[t].ownedBy.indexOf(e);if(-1!==r){1===o[t].ownedBy.length?(o[t].atlas.dispose(),o.splice(t,1)):o[t].ownedBy.splice(r,1);break}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3);t.generateConfig=function(e,t,r,i){var n={foreground:i.foreground,background:i.background,cursor:void 0,cursorAccent:void 0,selection:void 0,ansi:i.ansi.slice(0,16)};return{devicePixelRatio:window.devicePixelRatio,scaledCharWidth:e,scaledCharHeight:t,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,colors:n}},t.configEquals=function(e,t){for(var r=0;r<e.colors.ansi.length;r++)if(e.colors.ansi[r].rgba!==t.colors.ansi[r].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.scaledCharWidth===t.scaledCharWidth&&e.scaledCharHeight===t.scaledCharHeight&&e.colors.foreground===t.colors.foreground&&e.colors.background===t.colors.background},t.is256Color=function(e){return e<i.DEFAULT_COLOR}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(10),n=r(45),o=i.fromCss("#ffffff"),s=i.fromCss("#000000"),a=i.fromCss("#ffffff"),c=i.fromCss("#000000"),l={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};t.DEFAULT_ANSI_COLORS=function(){for(var e=[i.fromCss("#2e3436"),i.fromCss("#cc0000"),i.fromCss("#4e9a06"),i.fromCss("#c4a000"),i.fromCss("#3465a4"),i.fromCss("#75507b"),i.fromCss("#06989a"),i.fromCss("#d3d7cf"),i.fromCss("#555753"),i.fromCss("#ef2929"),i.fromCss("#8ae234"),i.fromCss("#fce94f"),i.fromCss("#729fcf"),i.fromCss("#ad7fa8"),i.fromCss("#34e2e2"),i.fromCss("#eeeeec")],t=[0,95,135,175,215,255],r=0;r<216;r++){var n=t[r/36%6|0],o=t[r/6%6|0],s=t[r%6];e.push({css:i.toCss(n,o,s),rgba:i.toRgba(n,o,s)})}for(r=0;r<24;r++){var a=8+10*r;e.push({css:i.toCss(a,a,a),rgba:i.toRgba(a,a,a)})}return e}();var h=function(){function e(e,r){this.allowTransparency=r;var h=e.createElement("canvas");h.width=1,h.height=1;var u=h.getContext("2d");if(!u)throw new Error("Could not get rendering context");this._ctx=u,this._ctx.globalCompositeOperation="copy",this._litmusColor=this._ctx.createLinearGradient(0,0,1,1),this._contrastCache=new n.ColorContrastCache,this.colors={foreground:o,background:s,cursor:a,cursorAccent:c,selection:l,selectionOpaque:i.blend(s,l),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache}}return e.prototype.onOptionsChange=function(e){"minimumContrastRatio"===e&&this._contrastCache.clear()},e.prototype.setTheme=function(e){void 0===e&&(e={}),this.colors.foreground=this._parseColor(e.foreground,o),this.colors.background=this._parseColor(e.background,s),this.colors.cursor=this._parseColor(e.cursor,a,!0),this.colors.cursorAccent=this._parseColor(e.cursorAccent,c,!0),this.colors.selection=this._parseColor(e.selection,l,!0),this.colors.selectionOpaque=i.blend(this.colors.background,this.colors.selection),this.colors.ansi[0]=this._parseColor(e.black,t.DEFAULT_ANSI_COLORS[0]),this.colors.ansi[1]=this._parseColor(e.red,t.DEFAULT_ANSI_COLORS[1]),this.colors.ansi[2]=this._parseColor(e.green,t.DEFAULT_ANSI_COLORS[2]),this.colors.ansi[3]=this._parseColor(e.yellow,t.DEFAULT_ANSI_COLORS[3]),this.colors.ansi[4]=this._parseColor(e.blue,t.DEFAULT_ANSI_COLORS[4]),this.colors.ansi[5]=this._parseColor(e.magenta,t.DEFAULT_ANSI_COLORS[5]),this.colors.ansi[6]=this._parseColor(e.cyan,t.DEFAULT_ANSI_COLORS[6]),this.colors.ansi[7]=this._parseColor(e.white,t.DEFAULT_ANSI_COLORS[7]),this.colors.ansi[8]=this._parseColor(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),this.colors.ansi[9]=this._parseColor(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),this.colors.ansi[10]=this._parseColor(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),this.colors.ansi[11]=this._parseColor(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),this.colors.ansi[12]=this._parseColor(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),this.colors.ansi[13]=this._parseColor(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),this.colors.ansi[14]=this._parseColor(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),this.colors.ansi[15]=this._parseColor(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),this._contrastCache.clear()},e.prototype._parseColor=function(e,t,r){if(void 0===r&&(r=this.allowTransparency),void 0===e)return t;if(this._ctx.fillStyle=this._litmusColor,this._ctx.fillStyle=e,"string"!=typeof this._ctx.fillStyle)return console.warn("Color: "+e+" is invalid using fallback "+t.css),t;this._ctx.fillRect(0,0,1,1);var n=this._ctx.getImageData(0,0,1,1).data;if(255!==n[3]){if(!r)return console.warn("Color: "+e+" is using transparency, but allowTransparency is false. Using fallback "+t.css+"."),t;var o=void 0,s=void 0,a=void 0,c=void 0,l=void 0;if(5===e.length){var h=parseInt(e.substr(1),16);o=16*(h>>12&15),s=16*(h>>8&15),a=16*(h>>4&15),c=16*(15&h),l=i.toRgba(o,s,a,c)}else o=(l=parseInt(e.substr(1),16))>>24&255,s=l>>16&255,a=l>>8&255,c=255&l;return{rgba:l,css:i.toCss(o,s,a,c)}}return{css:e,rgba:i.toRgba(n[0],n[1],n[2],n[3])}},e}();t.ColorManager=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.throwIfFalsy=function(e){if(!e)throw new Error("value must not be falsy");return e}},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(6),s=r(3),a=r(5),c=function(e){function t(t,r,i){var n=e.call(this)||this;return n.content=0,n.combinedData="",n.fg=t.fg,n.bg=t.bg,n.combinedData=r,n._width=i,n}return n(t,e),t.prototype.isCombined=function(){return 2097152},t.prototype.getWidth=function(){return this._width},t.prototype.getChars=function(){return this.combinedData},t.prototype.getCode=function(){return 2097151},t.prototype.setFromCharData=function(e){throw new Error("not implemented")},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(o.AttributeData);t.JoinedCellData=c;var l=function(){function e(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new a.CellData}return e.prototype.registerCharacterJoiner=function(e){var t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id},e.prototype.deregisterCharacterJoiner=function(e){for(var t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1},e.prototype.getJoinedCharacters=function(e){if(0===this._characterJoiners.length)return[];var t=this._bufferService.buffer.lines.get(e);if(!t||0===t.length)return[];for(var r=[],i=t.translateToString(!0),n=0,o=0,a=0,c=t.getFg(0),l=t.getBg(0),h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==c||this._workCell.bg!==l){if(h-n>1)for(var u=this._getJoinedRanges(i,a,o,t,n),f=0;f<u.length;f++)r.push(u[f]);n=h,a=o,c=this._workCell.fg,l=this._workCell.bg}o+=this._workCell.getChars().length||s.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-n>1)for(u=this._getJoinedRanges(i,a,o,t,n),f=0;f<u.length;f++)r.push(u[f]);return r},e.prototype._getJoinedRanges=function(t,r,i,n,o){for(var s=t.substring(r,i),a=this._characterJoiners[0].handler(s),c=1;c<this._characterJoiners.length;c++)for(var l=this._characterJoiners[c].handler(s),h=0;h<l.length;h++)e._mergeRanges(a,l[h]);return this._stringRangesToCellRanges(a,n,o),a},e.prototype._stringRangesToCellRanges=function(e,t,r){var i=0,n=!1,o=0,a=e[i];if(a){for(var c=r;c<this._bufferService.cols;c++){var l=t.getWidth(c),h=t.getString(c).length||s.WHITESPACE_CELL_CHAR.length;if(0!==l){if(!n&&a[0]<=o&&(a[0]=c,n=!0),a[1]<=o){if(a[1]=c,!(a=e[++i]))break;a[0]<=o?(a[0]=c,n=!0):n=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}},e._mergeRanges=function(e,t){for(var r=!1,i=0;i<e.length;i++){var n=e[i];if(r){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),r=!0)}}return r?e[e.length-1][1]=t[1]:e.push(t),e},e}();t.CharacterJoinerRegistry=l},function(e,t,r){"use strict";function i(e,t){var r=t.getBoundingClientRect();return[e.clientX-r.left,e.clientY-r.top]}Object.defineProperty(t,"__esModule",{value:!0}),t.getCoordsRelativeToElement=i,t.getCoords=function(e,t,r,n,o,s,a,c){if(o){var l=i(e,t);if(l)return l[0]=Math.ceil((l[0]+(c?s/2:0))/s),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),r+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),n),l}},t.getRawByteCoords=function(e){if(e)return{x:e[0]+32,y:e[1]+32}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._renderCallback=e}return e.prototype.dispose=function(){this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.refresh=function(e,t,r){var i=this;this._rowCount=r,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){return i._innerRefresh()}))},e.prototype._innerRefresh=function(){void 0!==this._rowStart&&void 0!==this._rowEnd&&void 0!==this._rowCount&&(this._rowStart=Math.max(this._rowStart,0),this._rowEnd=Math.min(this._rowEnd,this._rowCount-1),this._renderCallback(this._rowStart,this._rowEnd),this._rowStart=void 0,this._rowEnd=void 0,this._animationFrame=void 0)},e}();t.RenderDebouncer=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._currentDevicePixelRatio=window.devicePixelRatio,t}return n(t,e),t.prototype.setListener=function(e){var t=this;this._listener&&this.clearListener(),this._listener=e,this._outerListener=function(){t._listener&&(t._listener(window.devicePixelRatio,t._currentDevicePixelRatio),t._updateDpr())},this._updateDpr()},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.clearListener()},t.prototype._updateDpr=function(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._currentDevicePixelRatio=window.devicePixelRatio,this._resolutionMediaMatchList=window.matchMedia("screen and (resolution: "+window.devicePixelRatio+"dppx)"),this._resolutionMediaMatchList.addListener(this._outerListener))},t.prototype.clearListener=function(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)},t}(r(2).Disposable);t.ScreenDprMonitor=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clone=function e(t,r){if(void 0===r&&(r=5),"object"!=typeof t)return t;var i=Array.isArray(t)?[]:{};for(var n in t)i[n]=r<=1?t[n]:t[n]?e(t[n],r-1):t[n];return i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(34),n=r(17),o=r(78),s=function(){function e(e){this._core=new i.Terminal(e),this._addonManager=new o.AddonManager}return Object.defineProperty(e.prototype,"onCursorMove",{get:function(){return this._core.onCursorMove},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLineFeed",{get:function(){return this._core.onLineFeed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSelectionChange",{get:function(){return this._core.onSelectionChange},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onData",{get:function(){return this._core.onData},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBinary",{get:function(){return this._core.onBinary},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTitleChange",{get:function(){return this._core.onTitleChange},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onScroll",{get:function(){return this._core.onScroll},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onKey",{get:function(){return this._core.onKey},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onRender",{get:function(){return this._core.onRender},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onResize",{get:function(){return this._core.onResize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this._core.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parser",{get:function(){return this._parser||(this._parser=new h(this._core)),this._parser},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textarea",{get:function(){return this._core.textarea},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._core.rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cols",{get:function(){return this._core.cols},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return new a(this._core.buffer)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"markers",{get:function(){return this._core.markers},enumerable:!0,configurable:!0}),e.prototype.blur=function(){this._core.blur()},e.prototype.focus=function(){this._core.focus()},e.prototype.resize=function(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)},e.prototype.open=function(e){this._core.open(e)},e.prototype.attachCustomKeyEventHandler=function(e){this._core.attachCustomKeyEventHandler(e)},e.prototype.registerLinkMatcher=function(e,t,r){return this._core.registerLinkMatcher(e,t,r)},e.prototype.deregisterLinkMatcher=function(e){this._core.deregisterLinkMatcher(e)},e.prototype.registerCharacterJoiner=function(e){return this._core.registerCharacterJoiner(e)},e.prototype.deregisterCharacterJoiner=function(e){this._core.deregisterCharacterJoiner(e)},e.prototype.addMarker=function(e){return this._verifyIntegers(e),this._core.addMarker(e)},e.prototype.hasSelection=function(){return this._core.hasSelection()},e.prototype.select=function(e,t,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)},e.prototype.getSelection=function(){return this._core.getSelection()},e.prototype.getSelectionPosition=function(){return this._core.getSelectionPosition()},e.prototype.clearSelection=function(){this._core.clearSelection()},e.prototype.selectAll=function(){this._core.selectAll()},e.prototype.selectLines=function(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)},e.prototype.dispose=function(){this._addonManager.dispose(),this._core.dispose()},e.prototype.scrollLines=function(e){this._verifyIntegers(e),this._core.scrollLines(e)},e.prototype.scrollPages=function(e){this._verifyIntegers(e),this._core.scrollPages(e)},e.prototype.scrollToTop=function(){this._core.scrollToTop()},e.prototype.scrollToBottom=function(){this._core.scrollToBottom()},e.prototype.scrollToLine=function(e){this._verifyIntegers(e),this._core.scrollToLine(e)},e.prototype.clear=function(){this._core.clear()},e.prototype.write=function(e,t){this._core.write(e,t)},e.prototype.writeUtf8=function(e,t){this._core.write(e,t)},e.prototype.writeln=function(e,t){this._core.write(e),this._core.write("\r\n",t)},e.prototype.paste=function(e){this._core.paste(e)},e.prototype.getOption=function(e){return this._core.optionsService.getOption(e)},e.prototype.setOption=function(e,t){this._core.optionsService.setOption(e,t)},e.prototype.refresh=function(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)},e.prototype.reset=function(){this._core.reset()},e.prototype.loadAddon=function(e){return this._addonManager.loadAddon(this,e)},Object.defineProperty(e,"strings",{get:function(){return n},enumerable:!0,configurable:!0}),e.prototype._verifyIntegers=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];e.forEach(function(e){if(e===1/0||isNaN(e)||e%1!=0)throw new Error("This API only accepts integers")})},e}();t.Terminal=s;var a=function(){function e(e){this._buffer=e}return Object.defineProperty(e.prototype,"cursorY",{get:function(){return this._buffer.y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cursorX",{get:function(){return this._buffer.x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportY",{get:function(){return this._buffer.ydisp},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baseY",{get:function(){return this._buffer.ybase},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._buffer.lines.length},enumerable:!0,configurable:!0}),e.prototype.getLine=function(e){var t=this._buffer.lines.get(e);if(t)return new c(t)},e}(),c=function(){function e(e){this._line=e}return Object.defineProperty(e.prototype,"isWrapped",{get:function(){return this._line.isWrapped},enumerable:!0,configurable:!0}),e.prototype.getCell=function(e){if(!(e<0||e>=this._line.length))return new l(this._line,e)},e.prototype.translateToString=function(e,t,r){return this._line.translateToString(e,t,r)},e}(),l=function(){function e(e,t){this._line=e,this._x=t}return Object.defineProperty(e.prototype,"char",{get:function(){return this._line.getString(this._x)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._line.getWidth(this._x)},enumerable:!0,configurable:!0}),e}(),h=function(){function e(e){this._core=e}return e.prototype.addCsiHandler=function(e,t){return this._core.addCsiHandler(e,function(e){return t(e.toArray())})},e.prototype.addDcsHandler=function(e,t){return this._core.addDcsHandler(e,function(e,r){return t(e,r.toArray())})},e.prototype.addEscHandler=function(e,t){return this._core.addEscHandler(e,t)},e.prototype.addOscHandler=function(e,t){return this._core.addOscHandler(e,t)},e}()},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(35),s=r(36),a=r(37),c=r(12),l=r(38),h=r(40),u=r(50),f=r(51),_=r(11),d=r(7),p=r(17),v=r(54),g=r(55),y=r(56),b=r(57),m=r(59),C=r(1),S=r(16),w=r(60),E=r(26),L=r(61),A=r(0),R=r(62),x=r(4),k=r(63),D=r(64),T=r(2),M=r(70),O=r(71),P=r(72),H=r(73),I=r(74),B=r(75),F=r(76),j=r(77),q="undefined"!=typeof window?window.document:null,W=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.browser=_,r.mouseEvents=0,r._keyDownHandled=!1,r._blankLine=null,r._onCursorMove=new C.EventEmitter,r._onData=new C.EventEmitter,r._onBinary=new C.EventEmitter,r._onKey=new C.EventEmitter,r._onLineFeed=new C.EventEmitter,r._onRender=new C.EventEmitter,r._onResize=new C.EventEmitter,r._onScroll=new C.EventEmitter,r._onSelectionChange=new C.EventEmitter,r._onTitleChange=new C.EventEmitter,r._onFocus=new C.EventEmitter,r._onBlur=new C.EventEmitter,r.onA11yCharEmitter=new C.EventEmitter,r.onA11yTabEmitter=new C.EventEmitter,r._instantiationService=new I.InstantiationService,r.optionsService=new R.OptionsService(t),r._instantiationService.setService(A.IOptionsService,r.optionsService),r._bufferService=r._instantiationService.createInstance(D.BufferService),r._instantiationService.setService(A.IBufferService,r._bufferService),r._logService=r._instantiationService.createInstance(P.LogService),r._instantiationService.setService(A.ILogService,r._logService),r._coreService=r._instantiationService.createInstance(O.CoreService,function(){return r.scrollToBottom()}),r._instantiationService.setService(A.ICoreService,r._coreService),r._coreService.onData(function(e){return r._onData.fire(e)}),r._coreService.onBinary(function(e){return r._onBinary.fire(e)}),r._coreMouseService=r._instantiationService.createInstance(B.CoreMouseService),r._instantiationService.setService(A.ICoreMouseService,r._coreMouseService),r._dirtyRowService=r._instantiationService.createInstance(H.DirtyRowService),r._instantiationService.setService(A.IDirtyRowService,r._dirtyRowService),r._setupOptionsListeners(),r._setup(),r._writeBuffer=new F.WriteBuffer(function(e){return r._inputHandler.parse(e)}),r}return n(t,e),Object.defineProperty(t.prototype,"options",{get:function(){return this.optionsService.options},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cols",{get:function(){return this._bufferService.cols},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._bufferService.rows},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onData",{get:function(){return this._onData.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onKey",{get:function(){return this._onKey.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRender",{get:function(){return this._onRender.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSelectionChange",{get:function(){return this._onSelectionChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onTitleChange",{get:function(){return this._onTitleChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onFocus",{get:function(){return this._onFocus.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBlur",{get:function(){return this._onBlur.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onA11yChar",{get:function(){return this.onA11yCharEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onA11yTab",{get:function(){return this.onA11yTabEmitter.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var t,r,i,n;this._isDisposed||(e.prototype.dispose.call(this),null===(t=this._windowsMode)||void 0===t||t.dispose(),this._windowsMode=void 0,null===(r=this._renderService)||void 0===r||r.dispose(),this._customKeyEventHandler=null,this.write=function(){},null===(n=null===(i=this.element)||void 0===i?void 0:i.parentNode)||void 0===n||n.removeChild(this.element))},t.prototype._setup=function(){var e=this;this._parent=q?q.body:null,this._customKeyEventHandler=null,this.applicationKeypad=!1,this.originMode=!1,this.insertMode=!1,this.wraparoundMode=!0,this.bracketedPasteMode=!1,this.charset=null,this.gcharset=null,this.glevel=0,this.charsets=[null],this.curAttrData=S.DEFAULT_ATTR_DATA.clone(),this._eraseAttrData=S.DEFAULT_ATTR_DATA.clone(),this.params=[],this.currentParam=0,this._userScrolling=!1,this._inputHandler=new l.InputHandler(this,this._bufferService,this._coreService,this._dirtyRowService,this._logService,this.optionsService,this._coreMouseService),this._inputHandler.onCursorMove(function(){return e._onCursorMove.fire()}),this._inputHandler.onLineFeed(function(){return e._onLineFeed.fire()}),this.register(this._inputHandler),this.linkifier=this.linkifier||new u.Linkifier(this._bufferService,this._logService),this.options.windowsMode&&this._enableWindowsMode()},t.prototype._enableWindowsMode=function(){this._windowsMode||(this._windowsMode=this.onLineFeed(w.handleWindowsModeLineFeed.bind(null,this._bufferService)))},Object.defineProperty(t.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buffers",{get:function(){return this._bufferService.buffers},enumerable:!0,configurable:!0}),t.prototype.eraseAttrData=function(){return this._eraseAttrData.bg&=-67108864,this._eraseAttrData.bg|=67108863&this.curAttrData.bg,this._eraseAttrData},t.prototype.focus=function(){this.textarea&&this.textarea.focus({preventScroll:!0})},t.prototype._setupOptionsListeners=function(){var e=this;this.optionsService.onOptionChange(function(t){var r,i,n,o,s;switch(t){case"fontFamily":case"fontSize":null===(r=e._renderService)||void 0===r||r.clear(),null===(i=e._charSizeService)||void 0===i||i.measure();break;case"drawBoldTextInBrightColors":case"letterSpacing":case"lineHeight":case"fontWeight":case"fontWeightBold":case"minimumContrastRatio":e._renderService&&(e._renderService.clear(),e._renderService.onResize(e.cols,e.rows),e.refresh(0,e.rows-1));break;case"rendererType":e._renderService&&(e._renderService.setRenderer(e._createRenderer()),e._renderService.onResize(e.cols,e.rows));break;case"scrollback":e.buffers.resize(e.cols,e.rows),null===(n=e.viewport)||void 0===n||n.syncScrollArea();break;case"screenReaderMode":e.optionsService.options.screenReaderMode?!e._accessibilityManager&&e._renderService&&(e._accessibilityManager=new y.AccessibilityManager(e,e._renderService)):(null===(o=e._accessibilityManager)||void 0===o||o.dispose(),e._accessibilityManager=null);break;case"tabStopWidth":e.buffers.setupTabStops();break;case"theme":e._setTheme(e.optionsService.options.theme);break;case"windowsMode":e.optionsService.options.windowsMode?e._enableWindowsMode():(null===(s=e._windowsMode)||void 0===s||s.dispose(),e._windowsMode=void 0)}})},t.prototype._onTextAreaFocus=function(e){this.sendFocus&&this._coreService.triggerDataEvent(c.C0.ESC+"[I"),this.updateCursorStyle(e),this.element.classList.add("focus"),this.showCursor(),this._onFocus.fire()},t.prototype.blur=function(){return this.textarea.blur()},t.prototype._onTextAreaBlur=function(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.sendFocus&&this._coreService.triggerDataEvent(c.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()},t.prototype._initGlobal=function(){var e=this;this._bindKeys(),this.register(d.addDisposableDomListener(this.element,"copy",function(t){e.hasSelection()&&a.copyHandler(t,e._selectionService)}));var t=function(t){return a.handlePasteEvent(t,e.textarea,e.bracketedPasteMode,e._coreService)};this.register(d.addDisposableDomListener(this.textarea,"paste",t)),this.register(d.addDisposableDomListener(this.element,"paste",t)),_.isFirefox?this.register(d.addDisposableDomListener(this.element,"mousedown",function(t){2===t.button&&a.rightClickHandler(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)})):this.register(d.addDisposableDomListener(this.element,"contextmenu",function(t){a.rightClickHandler(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)})),_.isLinux&&this.register(d.addDisposableDomListener(this.element,"auxclick",function(t){1===t.button&&a.moveTextAreaUnderMouseCursor(t,e.textarea,e.screenElement)}))},t.prototype._bindKeys=function(){var e=this;this.register(d.addDisposableDomListener(this.textarea,"keyup",function(t){return e._keyUp(t)},!0)),this.register(d.addDisposableDomListener(this.textarea,"keydown",function(t){return e._keyDown(t)},!0)),this.register(d.addDisposableDomListener(this.textarea,"keypress",function(t){return e._keyPress(t)},!0)),this.register(d.addDisposableDomListener(this.textarea,"compositionstart",function(){return e._compositionHelper.compositionstart()})),this.register(d.addDisposableDomListener(this.textarea,"compositionupdate",function(t){return e._compositionHelper.compositionupdate(t)})),this.register(d.addDisposableDomListener(this.textarea,"compositionend",function(){return e._compositionHelper.compositionend()})),this.register(this.onRender(function(){return e._compositionHelper.updateCompositionElements()})),this.register(this.onRender(function(t){return e._queueLinkification(t.start,t.end)}))},t.prototype.open=function(e){var t=this;if(this._parent=e||this._parent,!this._parent)throw new Error("Terminal requires a parent element.");q.body.contains(e)||this._logService.warn("Terminal.open was called on an element that was not attached to the DOM"),this._document=this._parent.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),this.element.setAttribute("tabindex","0"),this._parent.appendChild(this.element);var r=q.createDocumentFragment();this._viewportElement=q.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this._viewportScrollArea=q.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=q.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=q.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement),this.textarea=q.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this.register(d.addDisposableDomListener(this.textarea,"focus",function(e){return t._onTextAreaFocus(e)})),this.register(d.addDisposableDomListener(this.textarea,"blur",function(){return t._onTextAreaBlur()})),this._helperContainer.appendChild(this.textarea);var i=this._instantiationService.createInstance(j.CoreBrowserService,this.textarea);this._instantiationService.setService(x.ICoreBrowserService,i),this._charSizeService=this._instantiationService.createInstance(k.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._compositionView=q.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(o.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(r),this._theme=this.options.theme||this._theme,this.options.theme=void 0,this._colorManager=new E.ColorManager(q,this.options.allowTransparency),this.optionsService.onOptionChange(function(e){return t._colorManager.onOptionsChange(e)}),this._colorManager.setTheme(this._theme);var n=this._createRenderer();this._renderService=this._instantiationService.createInstance(L.RenderService,n,this.rows,this.screenElement),this._instantiationService.setService(x.IRenderService,this._renderService),this._renderService.onRender(function(e){return t._onRender.fire(e)}),this.onResize(function(e){return t._renderService.resize(e.cols,e.rows)}),this._soundService=this._instantiationService.createInstance(v.SoundService),this._instantiationService.setService(x.ISoundService,this._soundService),this._mouseService=this._instantiationService.createInstance(M.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(s.Viewport,function(e,r){return t.scrollLines(e,r)},this._viewportElement,this._viewportScrollArea),this.viewport.onThemeChange(this._colorManager.colors),this.register(this.viewport),this.register(this.onCursorMove(function(){return t._renderService.onCursorMove()})),this.register(this.onResize(function(){return t._renderService.onResize(t.cols,t.rows)})),this.register(this.onBlur(function(){return t._renderService.onBlur()})),this.register(this.onFocus(function(){return t._renderService.onFocus()})),this.register(this._renderService.onDimensionsChange(function(){return t.viewport.syncScrollArea()})),this._selectionService=this._instantiationService.createInstance(f.SelectionService,function(e,r){return t.scrollLines(e,r)},this.element,this.screenElement),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onSelectionChange(function(){return t._onSelectionChange.fire()})),this.register(this._selectionService.onRedrawRequest(function(e){return t._renderService.onSelectionChanged(e.start,e.end,e.columnSelectMode)})),this.register(this._selectionService.onLinuxMouseSelection(function(e){t.textarea.value=e,t.textarea.focus(),t.textarea.select()})),this.register(this.onScroll(function(){t.viewport.syncScrollArea(),t._selectionService.refresh()})),this.register(d.addDisposableDomListener(this._viewportElement,"scroll",function(){return t._selectionService.refresh()})),this._mouseZoneManager=this._instantiationService.createInstance(g.MouseZoneManager,this.element,this.screenElement),this.register(this._mouseZoneManager),this.register(this.onScroll(function(){return t._mouseZoneManager.clearAll()})),this.linkifier.attachToDom(this.element,this._mouseZoneManager),this.register(d.addDisposableDomListener(this.element,"mousedown",function(e){return t._selectionService.onMouseDown(e)})),this.mouseEvents?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager=new y.AccessibilityManager(this,this._renderService)),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()},t.prototype._createRenderer=function(){switch(this.options.rendererType){case"canvas":return this._instantiationService.createInstance(h.Renderer,this._colorManager.colors,this.screenElement,this.linkifier);case"dom":return this._instantiationService.createInstance(b.DomRenderer,this._colorManager.colors,this.element,this.screenElement,this._viewportElement,this.linkifier);default:throw new Error('Unrecognized rendererType "'+this.options.rendererType+'"')}},t.prototype._setTheme=function(e){var t,r,i;this._theme=e,null===(t=this._colorManager)||void 0===t||t.setTheme(e),null===(r=this._renderService)||void 0===r||r.setColors(this._colorManager.colors),null===(i=this.viewport)||void 0===i||i.onThemeChange(this._colorManager.colors)},t.prototype.bindMouse=function(){var e=this,t=this,r=this.element;function i(e){var r,i,n;if(!(r=t._mouseService.getRawByteCoords(e,t.screenElement,t.cols,t.rows)))return!1;switch(e.overrideType||e.type){case"mousemove":n=32,void 0===e.buttons?(i=3,void 0!==e.button&&(i=e.button<3?e.button:3)):i=1&e.buttons?0:4&e.buttons?1:2&e.buttons?2:3;break;case"mouseup":n=0,i=e.button<3?e.button:3;break;case"mousedown":n=1,i=e.button<3?e.button:3;break;case"wheel":0!==e.deltaY&&(n=e.deltaY<0?0:1),i=4;break;default:return!1}return!(void 0===n||void 0===i||i>4)&&t._coreMouseService.triggerMouseEvent({col:r.x-33,row:r.y-33,button:i,action:n,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})}var n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o=function(t){return i(t),t.buttons||(e._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&e._document.removeEventListener("mousemove",n.mousedrag)),e.cancel(t)},s=function(t){return i(t),t.preventDefault(),e.cancel(t)},a=function(e){e.buttons&&i(e)},l=function(e){e.buttons||i(e)};this._coreMouseService.onProtocolChange(function(t){e.mouseEvents=t,t?("debug"===e.optionsService.options.logLevel&&e._logService.debug("Binding to mouse events:",e._coreMouseService.explainEvents(t)),e.element.classList.add("enable-mouse-events"),e._selectionService.disable()):(e._logService.debug("Unbinding from mouse events."),e.element.classList.remove("enable-mouse-events"),e._selectionService.enable()),8&t?n.mousemove||(r.addEventListener("mousemove",l),n.mousemove=l):(r.removeEventListener("mousemove",n.mousemove),n.mousemove=null),16&t?n.wheel||(r.addEventListener("wheel",s),n.wheel=s):(r.removeEventListener("wheel",n.wheel),n.wheel=null),2&t?n.mouseup||(n.mouseup=o):(e._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),4&t?n.mousedrag||(n.mousedrag=a):(e._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)}),this._coreMouseService.activeProtocol=this._coreMouseService.activeProtocol,this.register(d.addDisposableDomListener(r,"mousedown",function(t){if(t.preventDefault(),e.focus(),e.mouseEvents&&!e._selectionService.shouldForceSelection(t))return i(t),n.mouseup&&e._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&e._document.addEventListener("mousemove",n.mousedrag),e.cancel(t)})),this.register(d.addDisposableDomListener(r,"wheel",function(t){if(n.wheel);else if(!e.buffer.hasScrollback){var r=e.viewport.getLinesScrolled(t);if(0===r)return;for(var i=c.C0.ESC+(e._coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B"),o="",s=0;s<Math.abs(r);s++)o+=i;e._coreService.triggerDataEvent(o,!0)}})),this.register(d.addDisposableDomListener(r,"wheel",function(t){if(!n.wheel)return e.viewport.onWheel(t)?void 0:e.cancel(t)})),this.register(d.addDisposableDomListener(r,"touchstart",function(t){if(!e.mouseEvents)return e.viewport.onTouchStart(t),e.cancel(t)})),this.register(d.addDisposableDomListener(r,"touchmove",function(t){if(!e.mouseEvents)return e.viewport.onTouchMove(t)?void 0:e.cancel(t)}))},t.prototype.refresh=function(e,t){var r;null===(r=this._renderService)||void 0===r||r.refreshRows(e,t)},t.prototype._queueLinkification=function(e,t){var r;null===(r=this.linkifier)||void 0===r||r.linkifyRows(e,t)},t.prototype.updateCursorStyle=function(e){this._selectionService&&this._selectionService.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")},t.prototype.showCursor=function(){this._coreService.isCursorInitialized||(this._coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))},t.prototype.scroll=function(e){var t;void 0===e&&(e=!1),t=this._blankLine;var r=this.eraseAttrData();t&&t.length===this.cols&&t.getFg(0)===r.fg&&t.getBg(0)===r.bg||(t=this.buffer.getBlankLine(r,e),this._blankLine=t),t.isWrapped=e;var i=this.buffer.ybase+this.buffer.scrollTop,n=this.buffer.ybase+this.buffer.scrollBottom;if(0===this.buffer.scrollTop){var o=this.buffer.lines.isFull;n===this.buffer.lines.length-1?o?this.buffer.lines.recycle().copyFrom(t):this.buffer.lines.push(t.clone()):this.buffer.lines.splice(n+1,0,t.clone()),o?this._userScrolling&&(this.buffer.ydisp=Math.max(this.buffer.ydisp-1,0)):(this.buffer.ybase++,this._userScrolling||this.buffer.ydisp++)}else{var s=n-i+1;this.buffer.lines.shiftElements(i+1,s-1,-1),this.buffer.lines.set(n,t.clone())}this._userScrolling||(this.buffer.ydisp=this.buffer.ybase),this._dirtyRowService.markRangeDirty(this.buffer.scrollTop,this.buffer.scrollBottom),this._onScroll.fire(this.buffer.ydisp)},t.prototype.scrollLines=function(e,t){if(e<0){if(0===this.buffer.ydisp)return;this._userScrolling=!0}else e+this.buffer.ydisp>=this.buffer.ybase&&(this._userScrolling=!1);var r=this.buffer.ydisp;this.buffer.ydisp=Math.max(Math.min(this.buffer.ydisp+e,this.buffer.ybase),0),r!==this.buffer.ydisp&&(t||this._onScroll.fire(this.buffer.ydisp),this.refresh(0,this.rows-1))},t.prototype.scrollPages=function(e){this.scrollLines(e*(this.rows-1))},t.prototype.scrollToTop=function(){this.scrollLines(-this.buffer.ydisp)},t.prototype.scrollToBottom=function(){this.scrollLines(this.buffer.ybase-this.buffer.ydisp)},t.prototype.scrollToLine=function(e){var t=e-this.buffer.ydisp;0!==t&&this.scrollLines(t)},t.prototype.paste=function(e){a.paste(e,this.textarea,this.bracketedPasteMode,this._coreService)},t.prototype.attachCustomKeyEventHandler=function(e){this._customKeyEventHandler=e},t.prototype.addEscHandler=function(e,t){return this._inputHandler.addEscHandler(e,t)},t.prototype.addDcsHandler=function(e,t){return this._inputHandler.addDcsHandler(e,t)},t.prototype.addCsiHandler=function(e,t){return this._inputHandler.addCsiHandler(e,t)},t.prototype.addOscHandler=function(e,t){return this._inputHandler.addOscHandler(e,t)},t.prototype.registerLinkMatcher=function(e,t,r){var i=this.linkifier.registerLinkMatcher(e,t,r);return this.refresh(0,this.rows-1),i},t.prototype.deregisterLinkMatcher=function(e){this.linkifier.deregisterLinkMatcher(e)&&this.refresh(0,this.rows-1)},t.prototype.registerCharacterJoiner=function(e){var t=this._renderService.registerCharacterJoiner(e);return this.refresh(0,this.rows-1),t},t.prototype.deregisterCharacterJoiner=function(e){this._renderService.deregisterCharacterJoiner(e)&&this.refresh(0,this.rows-1)},Object.defineProperty(t.prototype,"markers",{get:function(){return this.buffer.markers},enumerable:!0,configurable:!0}),t.prototype.addMarker=function(e){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)},t.prototype.hasSelection=function(){return!!this._selectionService&&this._selectionService.hasSelection},t.prototype.select=function(e,t,r){this._selectionService.setSelection(e,t,r)},t.prototype.getSelection=function(){return this._selectionService?this._selectionService.selectionText:""},t.prototype.getSelectionPosition=function(){if(this._selectionService.hasSelection)return{startColumn:this._selectionService.selectionStart[0],startRow:this._selectionService.selectionStart[1],endColumn:this._selectionService.selectionEnd[0],endRow:this._selectionService.selectionEnd[1]}},t.prototype.clearSelection=function(){var e;null===(e=this._selectionService)||void 0===e||e.clearSelection()},t.prototype.selectAll=function(){var e;null===(e=this._selectionService)||void 0===e||e.selectAll()},t.prototype.selectLines=function(e,t){var r;null===(r=this._selectionService)||void 0===r||r.selectLines(e,t)},t.prototype._keyDown=function(e){if(this._keyDownHandled=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(!this._compositionHelper.keydown(e))return this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;var t=m.evaluateKeyboardEvent(e,this._coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===t.type||2===t.type){var r=this.rows-1;return this.scrollLines(2===t.type?-r:r),this.cancel(e,!0)}return 1===t.type&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(t.cancel&&this.cancel(e,!0),!t.key||(t.key!==c.C0.ETX&&t.key!==c.C0.CR||(this.textarea.value=""),this._onKey.fire({key:t.key,domEvent:e}),this.showCursor(),this._coreService.triggerDataEvent(t.key,!0),this.optionsService.options.screenReaderMode?void(this._keyDownHandled=!0):this.cancel(e,!0)))},t.prototype._isThirdLevelShift=function(e,t){var r=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey;return"keypress"===t.type?r:r&&(!t.keyCode||t.keyCode>47)},t.prototype.setgLevel=function(e){this.glevel=e,this.charset=this.charsets[e]},t.prototype.setgCharset=function(e,t){this.charsets[e]=t,this.glevel===e&&(this.charset=t)},t.prototype._keyUp=function(e){this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return 16===e.keyCode||17===e.keyCode||18===e.keyCode}(e)||this.focus(),this.updateCursorStyle(e))},t.prototype._keyPress=function(e){var t;if(this._keyDownHandled)return!1;if(this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null===e.which||void 0===e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e))&&(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this.showCursor(),this._coreService.triggerDataEvent(t,!0),!0)},t.prototype.bell=function(){var e=this;this._soundBell()&&this._soundService.playBellSound(),this._visualBell()&&(this.element.classList.add("visual-bell-active"),clearTimeout(this._visualBellTimer),this._visualBellTimer=window.setTimeout(function(){e.element.classList.remove("visual-bell-active")},200))},t.prototype.resize=function(e,t){var r;isNaN(e)||isNaN(t)||(e!==this.cols||t!==this.rows?(e<D.MINIMUM_COLS&&(e=D.MINIMUM_COLS),t<D.MINIMUM_ROWS&&(t=D.MINIMUM_ROWS),this.buffers.resize(e,t),this._bufferService.resize(e,t),this.buffers.setupTabStops(this.cols),null===(r=this._charSizeService)||void 0===r||r.measure(),this.viewport.syncScrollArea(!0),this.refresh(0,this.rows-1),this._onResize.fire({cols:e,rows:t})):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure())},t.prototype.clear=function(){if(0!==this.buffer.ybase||0!==this.buffer.y){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(var e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(S.DEFAULT_ATTR_DATA));this.refresh(0,this.rows-1),this._onScroll.fire(this.buffer.ydisp)}},t.prototype.is=function(e){return 0===(this.options.termName+"").indexOf(e)},t.prototype.handleTitle=function(e){this._onTitleChange.fire(e)},t.prototype.reset=function(){var e,t;this.options.rows=this.rows,this.options.cols=this.cols;var r=this._customKeyEventHandler,i=this._inputHandler,n=this._userScrolling;this._setup(),this._bufferService.reset(),this._coreService.reset(),this._coreMouseService.reset(),null===(e=this._selectionService)||void 0===e||e.reset(),this._customKeyEventHandler=r,this._inputHandler=i,this._userScrolling=n,this.refresh(0,this.rows-1),null===(t=this.viewport)||void 0===t||t.syncScrollArea()},t.prototype.cancel=function(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1},t.prototype._visualBell=function(){return!1},t.prototype._soundBell=function(){return"sound"===this.options.bellStyle},t.prototype.write=function(e,t){this._writeBuffer.write(e,t)},t.prototype.writeSync=function(e){this._writeBuffer.writeSync(e)},t}(T.Disposable);t.Terminal=W},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=r(0),a=function(){function e(e,t,r,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=i,this._charSizeService=n,this._coreService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0}}return e.prototype.compositionstart=function(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._compositionView.classList.add("active")},e.prototype.compositionupdate=function(e){var t=this;this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(function(){t._compositionPosition.end=t._textarea.value.length},0)},e.prototype.compositionend=function(){this._finalizeComposition(!0)},e.prototype.keydown=function(e){if(this._isComposing||this._isSendingComposition){if(229===e.keyCode)return!1;if(16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)},e.prototype._finalizeComposition=function(e){var t=this;if(this._compositionView.classList.remove("active"),this._isComposing=!1,this._clearTextareaPosition(),e){var r={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(function(){if(t._isSendingComposition){t._isSendingComposition=!1;var e=void 0;e=t._isComposing?t._textarea.value.substring(r.start,r.end):t._textarea.value.substring(r.start),t._coreService.triggerDataEvent(e,!0)}},0)}else{this._isSendingComposition=!1;var i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}},e.prototype._handleAnyTextareaChanges=function(){var e=this,t=this._textarea.value;setTimeout(function(){if(!e._isComposing){var r=e._textarea.value.replace(t,"");r.length>0&&e._coreService.triggerDataEvent(r,!0)}},0)},e.prototype.updateCompositionElements=function(e){var t=this;if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){var r=Math.ceil(this._charSizeService.height*this._optionsService.options.lineHeight),i=this._bufferService.buffer.y*r,n=this._bufferService.buffer.x*this._charSizeService.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.options.fontFamily,this._compositionView.style.fontSize=this._optionsService.options.fontSize+"px";var o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=o.width+"px",this._textarea.style.height=o.height+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(function(){return t.updateCompositionElements(!0)},0)}},e.prototype._clearTextareaPosition=function(){this._textarea.style.left="",this._textarea.style.top=""},e=i([n(2,s.IBufferService),n(3,s.IOptionsService),n(4,o.ICharSizeService),n(5,s.ICoreService)],e)}();t.CompositionHelper=a},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),c=r(7),l=r(4),h=r(0),u=15,f=function(e){function t(t,r,i,n,o,s,a){var l=e.call(this)||this;return l._scrollLines=t,l._viewportElement=r,l._scrollArea=i,l._bufferService=n,l._optionsService=o,l._charSizeService=s,l._renderService=a,l.scrollBarWidth=0,l._currentRowHeight=0,l._lastRecordedBufferLength=0,l._lastRecordedViewportHeight=0,l._lastRecordedBufferHeight=0,l._lastTouchY=0,l._lastScrollTop=0,l._wheelPartialScroll=0,l._refreshAnimationFrame=null,l._ignoreNextScrollEvent=!1,l.scrollBarWidth=l._viewportElement.offsetWidth-l._scrollArea.offsetWidth||u,l.register(c.addDisposableDomListener(l._viewportElement,"scroll",l._onScroll.bind(l))),setTimeout(function(){return l.syncScrollArea()},0),l}return n(t,e),t.prototype.onThemeChange=function(e){this._viewportElement.style.backgroundColor=e.background.css},t.prototype._refresh=function(e){var t=this;if(e)return this._innerRefresh(),void(null!==this._refreshAnimationFrame&&cancelAnimationFrame(this._refreshAnimationFrame));null===this._refreshAnimationFrame&&(this._refreshAnimationFrame=requestAnimationFrame(function(){return t._innerRefresh()}))},t.prototype._innerRefresh=function(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.scaledCellHeight/window.devicePixelRatio,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;var e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.canvasHeight);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}var t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==t&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=t),this._refreshAnimationFrame=null},t.prototype.syncScrollArea=function(e){if(void 0===e&&(e=!1),this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);if(this._lastRecordedViewportHeight===this._renderService.dimensions.canvasHeight){var t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._lastScrollTop===t&&this._lastScrollTop===this._viewportElement.scrollTop&&this._renderService.dimensions.scaledCellHeight/window.devicePixelRatio===this._currentRowHeight||this._refresh(e)}else this._refresh(e)},t.prototype._onScroll=function(e){if(this._lastScrollTop=this._viewportElement.scrollTop,this._viewportElement.offsetParent)if(this._ignoreNextScrollEvent)this._ignoreNextScrollEvent=!1;else{var t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._scrollLines(t,!0)}},t.prototype._bubbleScroll=function(e,t){var r=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&0!==this._viewportElement.scrollTop||t>0&&r<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)},t.prototype.onWheel=function(e){var t=this._getPixelsScrolled(e);return 0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))},t.prototype._getPixelsScrolled=function(e){if(0===e.deltaY)return 0;var t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t},t.prototype.getLinesScrolled=function(e){if(0===e.deltaY)return 0;var t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t},t.prototype._applyScrollModifier=function(e,t){var r=this._optionsService.options.fastScrollModifier;return"alt"===r&&t.altKey||"ctrl"===r&&t.ctrlKey||"shift"===r&&t.shiftKey?e*this._optionsService.options.fastScrollSensitivity*this._optionsService.options.scrollSensitivity:e*this._optionsService.options.scrollSensitivity},t.prototype.onTouchStart=function(e){this._lastTouchY=e.touches[0].pageY},t.prototype.onTouchMove=function(e){var t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))},t=o([s(3,h.IBufferService),s(4,h.IOptionsService),s(5,l.ICharSizeService),s(6,l.IRenderService)],t)}(a.Disposable);t.Viewport=f},function(e,t,r){"use strict";function i(e){return e.replace(/\r?\n/g,"\r")}function n(e,t){return t?"[200~"+e+"[201~":e}function o(e,t,r,o){e=n(e=i(e),r),o.triggerDataEvent(e,!0),t.value=""}function s(e,t,r){var i=r.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.position="absolute",t.style.width="20px",t.style.height="20px",t.style.left=n+"px",t.style.top=o+"px",t.style.zIndex="1000",t.focus(),setTimeout(function(){t.style.position="",t.style.width="",t.style.height="",t.style.left="",t.style.top="",t.style.zIndex=""},200)}Object.defineProperty(t,"__esModule",{value:!0}),t.prepareTextForTerminal=i,t.bracketTextForPaste=n,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,r,i){e.stopPropagation(),e.clipboardData&&o(e.clipboardData.getData("text/plain"),t,r,i)},t.paste=o,t.moveTextAreaUnderMouseCursor=s,t.rightClickHandler=function(e,t,r,i,n){s(e,t,r),n&&!i.isClickInSelection(e)&&i.selectWordAtCursor(e),t.value=i.selectionText,t.select()}},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(12),s=r(18),a=r(19),c=r(39),l=r(2),h=r(15),u=r(8),f=r(16),_=r(1),d=r(3),p=r(5),v=r(6),g=r(21),y=r(23),b={"(":0,")":1,"*":2,"+":3,"-":1,".":2},m=function(){function e(e,t,r,i){this._bufferService=e,this._coreService=t,this._logService=r,this._optionsService=i,this._data=new Uint32Array(0)}return e.prototype.hook=function(e){this._data=new Uint32Array(0)},e.prototype.put=function(e,t,r){this._data=h.concat(this._data,e.subarray(t,r))},e.prototype.unhook=function(e){if(e){var t=u.utf32ToString(this._data);switch(this._data=new Uint32Array(0),t){case'"q':return this._coreService.triggerDataEvent(o.C0.ESC+'P1$r0"q'+o.C0.ESC+"\\");case'"p':return this._coreService.triggerDataEvent(o.C0.ESC+'P1$r61"p'+o.C0.ESC+"\\");case"r":var r=this._bufferService.buffer.scrollTop+1+";"+(this._bufferService.buffer.scrollBottom+1)+"r";return this._coreService.triggerDataEvent(o.C0.ESC+"P1$r"+r+o.C0.ESC+"\\");case"m":return this._coreService.triggerDataEvent(o.C0.ESC+"P1$r0m"+o.C0.ESC+"\\");case" q":var i={block:2,underline:4,bar:6}[this._optionsService.options.cursorStyle];return i-=this._optionsService.options.cursorBlink?1:0,this._coreService.triggerDataEvent(o.C0.ESC+"P1$r"+i+" q"+o.C0.ESC+"\\");default:this._logService.debug("Unknown DCS $q %s",t),this._coreService.triggerDataEvent(o.C0.ESC+"P0$r"+o.C0.ESC+"\\")}}else this._data=new Uint32Array(0)},e}(),C=function(e){function t(t,r,i,n,a,l,h,f){void 0===f&&(f=new c.EscapeSequenceParser);var d=e.call(this)||this;d._terminal=t,d._bufferService=r,d._coreService=i,d._dirtyRowService=n,d._logService=a,d._optionsService=l,d._coreMouseService=h,d._parser=f,d._parseBuffer=new Uint32Array(4096),d._stringDecoder=new u.StringToUtf32,d._utf8Decoder=new u.Utf8ToUtf32,d._workCell=new p.CellData,d._onCursorMove=new _.EventEmitter,d._onLineFeed=new _.EventEmitter,d._onScroll=new _.EventEmitter,d.register(d._parser),d._parser.setCsiHandlerFallback(function(e,t){d._logService.debug("Unknown CSI code: ",{identifier:d._parser.identToString(e),params:t.toArray()})}),d._parser.setEscHandlerFallback(function(e){d._logService.debug("Unknown ESC code: ",{identifier:d._parser.identToString(e)})}),d._parser.setExecuteHandlerFallback(function(e){d._logService.debug("Unknown EXECUTE code: ",{code:e})}),d._parser.setOscHandlerFallback(function(e,t,r){d._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:r})}),d._parser.setDcsHandlerFallback(function(e,t,r){"HOOK"===t&&(r=r.toArray()),d._logService.debug("Unknown DCS code: ",{identifier:d._parser.identToString(e),action:t,payload:r})}),d._parser.setPrintHandler(function(e,t,r){return d.print(e,t,r)}),d._parser.setCsiHandler({final:"@"},function(e){return d.insertChars(e)}),d._parser.setCsiHandler({intermediates:" ",final:"@"},function(e){return d.scrollLeft(e)}),d._parser.setCsiHandler({final:"A"},function(e){return d.cursorUp(e)}),d._parser.setCsiHandler({intermediates:" ",final:"A"},function(e){return d.scrollRight(e)}),d._parser.setCsiHandler({final:"B"},function(e){return d.cursorDown(e)}),d._parser.setCsiHandler({final:"C"},function(e){return d.cursorForward(e)}),d._parser.setCsiHandler({final:"D"},function(e){return d.cursorBackward(e)}),d._parser.setCsiHandler({final:"E"},function(e){return d.cursorNextLine(e)}),d._parser.setCsiHandler({final:"F"},function(e){return d.cursorPrecedingLine(e)}),d._parser.setCsiHandler({final:"G"},function(e){return d.cursorCharAbsolute(e)}),d._parser.setCsiHandler({final:"H"},function(e){return d.cursorPosition(e)}),d._parser.setCsiHandler({final:"I"},function(e){return d.cursorForwardTab(e)}),d._parser.setCsiHandler({final:"J"},function(e){return d.eraseInDisplay(e)}),d._parser.setCsiHandler({prefix:"?",final:"J"},function(e){return d.eraseInDisplay(e)}),d._parser.setCsiHandler({final:"K"},function(e){return d.eraseInLine(e)}),d._parser.setCsiHandler({prefix:"?",final:"K"},function(e){return d.eraseInLine(e)}),d._parser.setCsiHandler({final:"L"},function(e){return d.insertLines(e)}),d._parser.setCsiHandler({final:"M"},function(e){return d.deleteLines(e)}),d._parser.setCsiHandler({final:"P"},function(e){return d.deleteChars(e)}),d._parser.setCsiHandler({final:"S"},function(e){return d.scrollUp(e)}),d._parser.setCsiHandler({final:"T"},function(e){return d.scrollDown(e)}),d._parser.setCsiHandler({final:"X"},function(e){return d.eraseChars(e)}),d._parser.setCsiHandler({final:"Z"},function(e){return d.cursorBackwardTab(e)}),d._parser.setCsiHandler({final:"`"},function(e){return d.charPosAbsolute(e)}),d._parser.setCsiHandler({final:"a"},function(e){return d.hPositionRelative(e)}),d._parser.setCsiHandler({final:"b"},function(e){return d.repeatPrecedingCharacter(e)}),d._parser.setCsiHandler({final:"c"},function(e){return d.sendDeviceAttributesPrimary(e)}),d._parser.setCsiHandler({prefix:">",final:"c"},function(e){return d.sendDeviceAttributesSecondary(e)}),d._parser.setCsiHandler({final:"d"},function(e){return d.linePosAbsolute(e)}),d._parser.setCsiHandler({final:"e"},function(e){return d.vPositionRelative(e)}),d._parser.setCsiHandler({final:"f"},function(e){return d.hVPosition(e)}),d._parser.setCsiHandler({final:"g"},function(e){return d.tabClear(e)}),d._parser.setCsiHandler({final:"h"},function(e){return d.setMode(e)}),d._parser.setCsiHandler({prefix:"?",final:"h"},function(e){return d.setModePrivate(e)}),d._parser.setCsiHandler({final:"l"},function(e){return d.resetMode(e)}),d._parser.setCsiHandler({prefix:"?",final:"l"},function(e){return d.resetModePrivate(e)}),d._parser.setCsiHandler({final:"m"},function(e){return d.charAttributes(e)}),d._parser.setCsiHandler({final:"n"},function(e){return d.deviceStatus(e)}),d._parser.setCsiHandler({prefix:"?",final:"n"},function(e){return d.deviceStatusPrivate(e)}),d._parser.setCsiHandler({intermediates:"!",final:"p"},function(e){return d.softReset(e)}),d._parser.setCsiHandler({intermediates:" ",final:"q"},function(e){return d.setCursorStyle(e)}),d._parser.setCsiHandler({final:"r"},function(e){return d.setScrollRegion(e)}),d._parser.setCsiHandler({final:"s"},function(e){return d.saveCursor(e)}),d._parser.setCsiHandler({final:"u"},function(e){return d.restoreCursor(e)}),d._parser.setCsiHandler({intermediates:"'",final:"}"},function(e){return d.insertColumns(e)}),d._parser.setCsiHandler({intermediates:"'",final:"~"},function(e){return d.deleteColumns(e)}),d._parser.setExecuteHandler(o.C0.BEL,function(){return d.bell()}),d._parser.setExecuteHandler(o.C0.LF,function(){return d.lineFeed()}),d._parser.setExecuteHandler(o.C0.VT,function(){return d.lineFeed()}),d._parser.setExecuteHandler(o.C0.FF,function(){return d.lineFeed()}),d._parser.setExecuteHandler(o.C0.CR,function(){return d.carriageReturn()}),d._parser.setExecuteHandler(o.C0.BS,function(){return d.backspace()}),d._parser.setExecuteHandler(o.C0.HT,function(){return d.tab()}),d._parser.setExecuteHandler(o.C0.SO,function(){return d.shiftOut()}),d._parser.setExecuteHandler(o.C0.SI,function(){return d.shiftIn()}),d._parser.setExecuteHandler(o.C1.IND,function(){return d.index()}),d._parser.setExecuteHandler(o.C1.NEL,function(){return d.nextLine()}),d._parser.setExecuteHandler(o.C1.HTS,function(){return d.tabSet()}),d._parser.setOscHandler(0,new g.OscHandler(function(e){return d.setTitle(e)})),d._parser.setOscHandler(2,new g.OscHandler(function(e){return d.setTitle(e)})),d._parser.setEscHandler({final:"7"},function(){return d.saveCursor()}),d._parser.setEscHandler({final:"8"},function(){return d.restoreCursor()}),d._parser.setEscHandler({final:"D"},function(){return d.index()}),d._parser.setEscHandler({final:"E"},function(){return d.nextLine()}),d._parser.setEscHandler({final:"H"},function(){return d.tabSet()}),d._parser.setEscHandler({final:"M"},function(){return d.reverseIndex()}),d._parser.setEscHandler({final:"="},function(){return d.keypadApplicationMode()}),d._parser.setEscHandler({final:">"},function(){return d.keypadNumericMode()}),d._parser.setEscHandler({final:"c"},function(){return d.reset()}),d._parser.setEscHandler({final:"n"},function(){return d.setgLevel(2)}),d._parser.setEscHandler({final:"o"},function(){return d.setgLevel(3)}),d._parser.setEscHandler({final:"|"},function(){return d.setgLevel(3)}),d._parser.setEscHandler({final:"}"},function(){return d.setgLevel(2)}),d._parser.setEscHandler({final:"~"},function(){return d.setgLevel(1)}),d._parser.setEscHandler({intermediates:"%",final:"@"},function(){return d.selectDefaultCharset()}),d._parser.setEscHandler({intermediates:"%",final:"G"},function(){return d.selectDefaultCharset()});var v=function(e){y._parser.setEscHandler({intermediates:"(",final:e},function(){return d.selectCharset("("+e)}),y._parser.setEscHandler({intermediates:")",final:e},function(){return d.selectCharset(")"+e)}),y._parser.setEscHandler({intermediates:"*",final:e},function(){return d.selectCharset("*"+e)}),y._parser.setEscHandler({intermediates:"+",final:e},function(){return d.selectCharset("+"+e)}),y._parser.setEscHandler({intermediates:"-",final:e},function(){return d.selectCharset("-"+e)}),y._parser.setEscHandler({intermediates:".",final:e},function(){return d.selectCharset("."+e)}),y._parser.setEscHandler({intermediates:"/",final:e},function(){return d.selectCharset("/"+e)})},y=this;for(var b in s.CHARSETS)v(b);return d._parser.setEscHandler({intermediates:"#",final:"8"},function(){return d.screenAlignmentPattern()}),d._parser.setErrorHandler(function(e){return d._logService.error("Parsing error: ",e),e}),d._parser.setDcsHandler({intermediates:"$",final:"q"},new m(d._bufferService,d._coreService,d._logService,d._optionsService)),d}return n(t,e),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype.parse=function(e){var t=this._bufferService.buffer,r=t.x,i=t.y;if(this._logService.debug("parsing data",e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),this._dirtyRowService.clearRange(),e.length>131072)for(var n=0;n<e.length;n+=131072){var o=n+131072<e.length?n+131072:e.length,s="string"==typeof e?this._stringDecoder.decode(e.substring(n,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(n,o),this._parseBuffer);this._parser.parse(this._parseBuffer,s)}else{s="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);this._parser.parse(this._parseBuffer,s)}(t=this._bufferService.buffer).x===r&&t.y===i||this._onCursorMove.fire(),this._terminal.refresh(this._dirtyRowService.start,this._dirtyRowService.end)},t.prototype.print=function(e,t,r){var i,n,o=this._bufferService.buffer,s=this._terminal.charset,c=this._optionsService.options.screenReaderMode,l=this._bufferService.cols,h=this._terminal.wraparoundMode,f=this._terminal.insertMode,_=this._terminal.curAttrData,p=o.lines.get(o.y+o.ybase);this._dirtyRowService.markDirty(o.y);for(var v=t;v<r;++v){if(i=e[v],n=a.wcwidth(i),i<127&&s){var g=s[String.fromCharCode(i)];g&&(i=g.charCodeAt(0))}if(c&&this._terminal.onA11yCharEmitter.fire(u.stringFromCodePoint(i)),n||!o.x){if(o.x+n-1>=l)if(h)o.x=0,o.y++,o.y===o.scrollBottom+1?(o.y--,this._terminal.scroll(!0)):(o.y>=this._bufferService.rows&&(o.y=this._bufferService.rows-1),o.lines.get(o.y).isWrapped=!0),p=o.lines.get(o.y+o.ybase);else if(o.x=l-1,2===n)continue;if(f&&(p.insertCells(o.x,n,o.getNullCell(_)),2===p.getWidth(l-1)&&p.setCellFromCodePoint(l-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,_.fg,_.bg)),p.setCellFromCodePoint(o.x++,i,n,_.fg,_.bg),n>0)for(;--n;)p.setCellFromCodePoint(o.x++,0,0,_.fg,_.bg)}else p.getWidth(o.x-1)?p.addCodepointToCell(o.x-1,i):p.addCodepointToCell(o.x-2,i)}r&&(p.loadCell(o.x-1,this._workCell),2===this._workCell.getWidth()||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._dirtyRowService.markDirty(o.y)},t.prototype.addCsiHandler=function(e,t){return this._parser.addCsiHandler(e,t)},t.prototype.addDcsHandler=function(e,t){return this._parser.addDcsHandler(e,new y.DcsHandler(t))},t.prototype.addEscHandler=function(e,t){return this._parser.addEscHandler(e,t)},t.prototype.addOscHandler=function(e,t){return this._parser.addOscHandler(e,new g.OscHandler(t))},t.prototype.bell=function(){this._terminal.bell()},t.prototype.lineFeed=function(){var e=this._bufferService.buffer;this._dirtyRowService.markDirty(e.y),this._optionsService.options.convertEol&&(e.x=0),e.y++,e.y===e.scrollBottom+1?(e.y--,this._terminal.scroll()):e.y>=this._bufferService.rows&&(e.y=this._bufferService.rows-1),e.x>=this._bufferService.cols&&e.x--,this._dirtyRowService.markDirty(e.y),this._onLineFeed.fire()},t.prototype.carriageReturn=function(){this._bufferService.buffer.x=0},t.prototype.backspace=function(){this._restrictCursor(),this._bufferService.buffer.x>0&&this._bufferService.buffer.x--},t.prototype.tab=function(){if(!(this._bufferService.buffer.x>=this._bufferService.cols)){var e=this._bufferService.buffer.x;this._bufferService.buffer.x=this._bufferService.buffer.nextStop(),this._optionsService.options.screenReaderMode&&this._terminal.onA11yTabEmitter.fire(this._bufferService.buffer.x-e)}},t.prototype.shiftOut=function(){this._terminal.setgLevel(1)},t.prototype.shiftIn=function(){this._terminal.setgLevel(0)},t.prototype._restrictCursor=function(){this._bufferService.buffer.x=Math.min(this._bufferService.cols-1,Math.max(0,this._bufferService.buffer.x)),this._bufferService.buffer.y=this._terminal.originMode?Math.min(this._bufferService.buffer.scrollBottom,Math.max(this._bufferService.buffer.scrollTop,this._bufferService.buffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._bufferService.buffer.y)),this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype._setCursor=function(e,t){this._dirtyRowService.markDirty(this._bufferService.buffer.y),this._terminal.originMode?(this._bufferService.buffer.x=e,this._bufferService.buffer.y=this._bufferService.buffer.scrollTop+t):(this._bufferService.buffer.x=e,this._bufferService.buffer.y=t),this._restrictCursor(),this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype._moveCursor=function(e,t){this._restrictCursor(),this._setCursor(this._bufferService.buffer.x+e,this._bufferService.buffer.y+t)},t.prototype.cursorUp=function(e){var t=this._bufferService.buffer.y-this._bufferService.buffer.scrollTop;t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1))},t.prototype.cursorDown=function(e){var t=this._bufferService.buffer.scrollBottom-this._bufferService.buffer.y;t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1)},t.prototype.cursorForward=function(e){this._moveCursor(e.params[0]||1,0)},t.prototype.cursorBackward=function(e){this._moveCursor(-(e.params[0]||1),0)},t.prototype.cursorNextLine=function(e){this.cursorDown(e),this._bufferService.buffer.x=0},t.prototype.cursorPrecedingLine=function(e){this.cursorUp(e),this._bufferService.buffer.x=0},t.prototype.cursorCharAbsolute=function(e){this._setCursor((e.params[0]||1)-1,this._bufferService.buffer.y)},t.prototype.cursorPosition=function(e){this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1)},t.prototype.charPosAbsolute=function(e){this._setCursor((e.params[0]||1)-1,this._bufferService.buffer.y)},t.prototype.hPositionRelative=function(e){this._moveCursor(e.params[0]||1,0)},t.prototype.linePosAbsolute=function(e){this._setCursor(this._bufferService.buffer.x,(e.params[0]||1)-1)},t.prototype.vPositionRelative=function(e){this._moveCursor(0,e.params[0]||1)},t.prototype.hVPosition=function(e){this.cursorPosition(e)},t.prototype.tabClear=function(e){var t=e.params[0];0===t?delete this._bufferService.buffer.tabs[this._bufferService.buffer.x]:3===t&&(this._bufferService.buffer.tabs={})},t.prototype.cursorForwardTab=function(e){if(!(this._bufferService.buffer.x>=this._bufferService.cols))for(var t=e.params[0]||1;t--;)this._bufferService.buffer.x=this._bufferService.buffer.nextStop()},t.prototype.cursorBackwardTab=function(e){if(!(this._bufferService.buffer.x>=this._bufferService.cols))for(var t=e.params[0]||1,r=this._bufferService.buffer;t--;)r.x=r.prevStop()},t.prototype._eraseInBufferLine=function(e,t,r,i){void 0===i&&(i=!1);var n=this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase+e);n.replaceCells(t,r,this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())),i&&(n.isWrapped=!1)},t.prototype._resetBufferLine=function(e){var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase+e);t.fill(this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())),t.isWrapped=!1},t.prototype.eraseInDisplay=function(e){var t;switch(this._restrictCursor(),e.params[0]){case 0:for(t=this._bufferService.buffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t++,this._bufferService.buffer.x,this._bufferService.cols,0===this._bufferService.buffer.x);t<this._bufferService.rows;t++)this._resetBufferLine(t);this._dirtyRowService.markDirty(t);break;case 1:for(t=this._bufferService.buffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t,0,this._bufferService.buffer.x+1,!0),this._bufferService.buffer.x+1>=this._bufferService.cols&&(this._bufferService.buffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 2:for(t=this._bufferService.rows,this._dirtyRowService.markDirty(t-1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 3:var r=this._bufferService.buffer.lines.length-this._bufferService.rows;r>0&&(this._bufferService.buffer.lines.trimStart(r),this._bufferService.buffer.ybase=Math.max(this._bufferService.buffer.ybase-r,0),this._bufferService.buffer.ydisp=Math.max(this._bufferService.buffer.ydisp-r,0),this._onScroll.fire(0))}},t.prototype.eraseInLine=function(e){switch(this._restrictCursor(),e.params[0]){case 0:this._eraseInBufferLine(this._bufferService.buffer.y,this._bufferService.buffer.x,this._bufferService.cols);break;case 1:this._eraseInBufferLine(this._bufferService.buffer.y,0,this._bufferService.buffer.x+1);break;case 2:this._eraseInBufferLine(this._bufferService.buffer.y,0,this._bufferService.cols)}this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype.insertLines=function(e){this._restrictCursor();var t=e.params[0]||1,r=this._bufferService.buffer;if(!(r.y>r.scrollBottom||r.y<r.scrollTop)){for(var i=r.y+r.ybase,n=this._bufferService.rows-1-r.scrollBottom,o=this._bufferService.rows-1+r.ybase-n+1;t--;)r.lines.splice(o-1,1),r.lines.splice(i,0,r.getBlankLine(this._terminal.eraseAttrData()));this._dirtyRowService.markRangeDirty(r.y,r.scrollBottom),r.x=0}},t.prototype.deleteLines=function(e){this._restrictCursor();var t=e.params[0]||1,r=this._bufferService.buffer;if(!(r.y>r.scrollBottom||r.y<r.scrollTop)){var i,n=r.y+r.ybase;for(i=this._bufferService.rows-1-r.scrollBottom,i=this._bufferService.rows-1+r.ybase-i;t--;)r.lines.splice(n,1),r.lines.splice(i,0,r.getBlankLine(this._terminal.eraseAttrData()));this._dirtyRowService.markRangeDirty(r.y,r.scrollBottom),r.x=0}},t.prototype.insertChars=function(e){this._restrictCursor();var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.y+this._bufferService.buffer.ybase);t&&(t.insertCells(this._bufferService.buffer.x,e.params[0]||1,this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())),this._dirtyRowService.markDirty(this._bufferService.buffer.y))},t.prototype.deleteChars=function(e){this._restrictCursor();var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.y+this._bufferService.buffer.ybase);t&&(t.deleteCells(this._bufferService.buffer.x,e.params[0]||1,this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())),this._dirtyRowService.markDirty(this._bufferService.buffer.y))},t.prototype.scrollUp=function(e){for(var t=e.params[0]||1,r=this._bufferService.buffer;t--;)r.lines.splice(r.ybase+r.scrollTop,1),r.lines.splice(r.ybase+r.scrollBottom,0,r.getBlankLine(this._terminal.eraseAttrData()));this._dirtyRowService.markRangeDirty(r.scrollTop,r.scrollBottom)},t.prototype.scrollDown=function(e){for(var t=e.params[0]||1,r=this._bufferService.buffer;t--;)r.lines.splice(r.ybase+r.scrollBottom,1),r.lines.splice(r.ybase+r.scrollTop,0,r.getBlankLine(f.DEFAULT_ATTR_DATA));this._dirtyRowService.markRangeDirty(r.scrollTop,r.scrollBottom)},t.prototype.scrollLeft=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=t.lines.get(t.ybase+i);n.deleteCells(0,r,t.getNullCell(this._terminal.eraseAttrData())),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.scrollRight=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=t.lines.get(t.ybase+i);n.insertCells(0,r,t.getNullCell(this._terminal.eraseAttrData())),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.insertColumns=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=this._bufferService.buffer.lines.get(t.ybase+i);n.insertCells(t.x,r,t.getNullCell(this._terminal.eraseAttrData())),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.deleteColumns=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=t.lines.get(t.ybase+i);n.deleteCells(t.x,r,t.getNullCell(this._terminal.eraseAttrData())),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.eraseChars=function(e){this._restrictCursor();var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.y+this._bufferService.buffer.ybase);t&&(t.replaceCells(this._bufferService.buffer.x,this._bufferService.buffer.x+(e.params[0]||1),this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())),this._dirtyRowService.markDirty(this._bufferService.buffer.y))},t.prototype.repeatPrecedingCharacter=function(e){if(this._parser.precedingCodepoint){for(var t=e.params[0]||1,r=new Uint32Array(t),i=0;i<t;++i)r[i]=this._parser.precedingCodepoint;this.print(r,0,r.length)}},t.prototype.sendDeviceAttributesPrimary=function(e){e.params[0]>0||(this._terminal.is("xterm")||this._terminal.is("rxvt-unicode")||this._terminal.is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._terminal.is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c"))},t.prototype.sendDeviceAttributesSecondary=function(e){e.params[0]>0||(this._terminal.is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._terminal.is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._terminal.is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._terminal.is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c"))},t.prototype.setMode=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 4:this._terminal.insertMode=!0}},t.prototype.setModePrivate=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._terminal.setgCharset(0,s.DEFAULT_CHARSET),this._terminal.setgCharset(1,s.DEFAULT_CHARSET),this._terminal.setgCharset(2,s.DEFAULT_CHARSET),this._terminal.setgCharset(3,s.DEFAULT_CHARSET);break;case 3:this._terminal.savedCols=this._bufferService.cols,this._terminal.resize(132,this._bufferService.rows),this._terminal.reset();break;case 6:this._terminal.originMode=!0,this._setCursor(0,0);break;case 7:this._terminal.wraparoundMode=!0;break;case 12:break;case 66:this._logService.debug("Serial port requested application keypad."),this._terminal.applicationKeypad=!0,this._terminal.viewport&&this._terminal.viewport.syncScrollArea();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._terminal.sendFocus=!0;break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._terminal.eraseAttrData()),this._terminal.refresh(0,this._bufferService.rows-1),this._terminal.viewport&&this._terminal.viewport.syncScrollArea(),this._terminal.showCursor();break;case 2004:this._terminal.bracketedPasteMode=!0}},t.prototype.resetMode=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 4:this._terminal.insertMode=!1}},t.prototype.resetModePrivate=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:132===this._bufferService.cols&&this._terminal.savedCols&&this._terminal.resize(this._terminal.savedCols,this._bufferService.rows),delete this._terminal.savedCols,this._terminal.reset();break;case 6:this._terminal.originMode=!1,this._setCursor(0,0);break;case 7:this._terminal.wraparoundMode=!1;break;case 12:break;case 66:this._logService.debug("Switching back to normal keypad."),this._terminal.applicationKeypad=!1,this._terminal.viewport&&this._terminal.viewport.syncScrollArea();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._terminal.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[t]&&this.restoreCursor(),this._terminal.refresh(0,this._bufferService.rows-1),this._terminal.viewport&&this._terminal.viewport.syncScrollArea(),this._terminal.showCursor();break;case 2004:this._terminal.bracketedPasteMode=!1}},t.prototype._extractColor=function(e,t,r){var i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){var s=e.getSubParams(t+o),a=0;do{5===i[1]&&(n=1),i[o+a+1+n]=s[a]}while(++a<s.length&&a+o+1+n<i.length);break}if(5===i[1]&&o+n>=2||2===i[1]&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(a=2;a<i.length;++a)-1===i[a]&&(i[a]=0);return 38===i[0]?2===i[1]?(r.fg|=50331648,r.fg&=-16777216,r.fg|=v.AttributeData.fromColorRGB([i[3],i[4],i[5]])):5===i[1]&&(r.fg&=-50331904,r.fg|=33554432|255&i[3]):48===i[0]&&(2===i[1]?(r.bg|=50331648,r.bg&=-16777216,r.bg|=v.AttributeData.fromColorRGB([i[3],i[4],i[5]])):5===i[1]&&(r.bg&=-50331904,r.bg|=33554432|255&i[3])),o},t.prototype.charAttributes=function(e){if(1===e.length&&0===e.params[0])return this._terminal.curAttrData.fg=f.DEFAULT_ATTR_DATA.fg,void(this._terminal.curAttrData.bg=f.DEFAULT_ATTR_DATA.bg);for(var t,r=e.length,i=this._terminal.curAttrData,n=0;n<r;n++)(t=e.params[n])>=30&&t<=37?(i.fg&=-50331904,i.fg|=16777216|t-30):t>=40&&t<=47?(i.bg&=-50331904,i.bg|=16777216|t-40):t>=90&&t<=97?(i.fg&=-50331904,i.fg|=16777224|t-90):t>=100&&t<=107?(i.bg&=-50331904,i.bg|=16777224|t-100):0===t?(i.fg=f.DEFAULT_ATTR_DATA.fg,i.bg=f.DEFAULT_ATTR_DATA.bg):1===t?i.fg|=134217728:3===t?i.bg|=67108864:4===t?i.fg|=268435456:5===t?i.fg|=536870912:7===t?i.fg|=67108864:8===t?i.fg|=1073741824:2===t?i.bg|=134217728:22===t?(i.fg&=-134217729,i.bg&=-134217729):23===t?i.bg&=-67108865:24===t?i.fg&=-268435457:25===t?i.fg&=-536870913:27===t?i.fg&=-67108865:28===t?i.fg&=-1073741825:39===t?(i.fg&=-67108864,i.fg|=16777215&f.DEFAULT_ATTR_DATA.fg):49===t?(i.bg&=-67108864,i.bg|=16777215&f.DEFAULT_ATTR_DATA.bg):38===t||48===t?n+=this._extractColor(e,n,i):100===t?(i.fg&=-67108864,i.fg|=16777215&f.DEFAULT_ATTR_DATA.fg,i.bg&=-67108864,i.bg|=16777215&f.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",t)},t.prototype.deviceStatus=function(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(o.C0.ESC+"[0n");break;case 6:var t=this._bufferService.buffer.y+1,r=this._bufferService.buffer.x+1;this._coreService.triggerDataEvent(o.C0.ESC+"["+t+";"+r+"R")}},t.prototype.deviceStatusPrivate=function(e){switch(e.params[0]){case 6:var t=this._bufferService.buffer.y+1,r=this._bufferService.buffer.x+1;this._coreService.triggerDataEvent(o.C0.ESC+"[?"+t+";"+r+"R")}},t.prototype.softReset=function(e){this._coreService.isCursorHidden=!1,this._terminal.insertMode=!1,this._terminal.originMode=!1,this._terminal.wraparoundMode=!0,this._terminal.applicationKeypad=!1,this._terminal.viewport&&this._terminal.viewport.syncScrollArea(),this._coreService.decPrivateModes.applicationCursorKeys=!1,this._bufferService.buffer.scrollTop=0,this._bufferService.buffer.scrollBottom=this._bufferService.rows-1,this._terminal.curAttrData=f.DEFAULT_ATTR_DATA.clone(),this._bufferService.buffer.x=this._bufferService.buffer.y=0,this._terminal.charset=null,this._terminal.glevel=0,this._terminal.charsets=[null]},t.prototype.setCursorStyle=function(e){var t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}var r=t%2==1;this._optionsService.options.cursorBlink=r},t.prototype.setScrollRegion=function(e){var t,r=e.params[0]||1;(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>r&&(this._bufferService.buffer.scrollTop=r-1,this._bufferService.buffer.scrollBottom=t-1,this._setCursor(0,0))},t.prototype.saveCursor=function(e){this._bufferService.buffer.savedX=this._bufferService.buffer.x,this._bufferService.buffer.savedY=this._bufferService.buffer.ybase+this._bufferService.buffer.y,this._bufferService.buffer.savedCurAttrData.fg=this._terminal.curAttrData.fg,this._bufferService.buffer.savedCurAttrData.bg=this._terminal.curAttrData.bg,this._bufferService.buffer.savedCharset=this._terminal.charset},t.prototype.restoreCursor=function(e){this._bufferService.buffer.x=this._bufferService.buffer.savedX||0,this._bufferService.buffer.y=Math.max(this._bufferService.buffer.savedY-this._bufferService.buffer.ybase,0),this._terminal.curAttrData.fg=this._bufferService.buffer.savedCurAttrData.fg,this._terminal.curAttrData.bg=this._bufferService.buffer.savedCurAttrData.bg,this._terminal.charset=this._savedCharset,this._bufferService.buffer.savedCharset&&(this._terminal.charset=this._bufferService.buffer.savedCharset),this._restrictCursor()},t.prototype.setTitle=function(e){this._terminal.handleTitle(e)},t.prototype.nextLine=function(){this._bufferService.buffer.x=0,this.index()},t.prototype.keypadApplicationMode=function(){this._logService.debug("Serial port requested application keypad."),this._terminal.applicationKeypad=!0,this._terminal.viewport&&this._terminal.viewport.syncScrollArea()},t.prototype.keypadNumericMode=function(){this._logService.debug("Switching back to normal keypad."),this._terminal.applicationKeypad=!1,this._terminal.viewport&&this._terminal.viewport.syncScrollArea()},t.prototype.selectDefaultCharset=function(){this._terminal.setgLevel(0),this._terminal.setgCharset(0,s.DEFAULT_CHARSET)},t.prototype.selectCharset=function(e){2===e.length?"/"!==e[0]&&this._terminal.setgCharset(b[e[0]],s.CHARSETS[e[1]]||s.DEFAULT_CHARSET):this.selectDefaultCharset()},t.prototype.index=function(){this._restrictCursor();var e=this._bufferService.buffer;this._bufferService.buffer.y++,e.y===e.scrollBottom+1?(e.y--,this._terminal.scroll()):e.y>=this._bufferService.rows&&(e.y=this._bufferService.rows-1),this._restrictCursor()},t.prototype.tabSet=function(){this._bufferService.buffer.tabs[this._bufferService.buffer.x]=!0},t.prototype.reverseIndex=function(){this._restrictCursor();var e=this._bufferService.buffer;if(e.y===e.scrollTop){var t=e.scrollBottom-e.scrollTop;e.lines.shiftElements(e.y+e.ybase,t,1),e.lines.set(e.y+e.ybase,e.getBlankLine(this._terminal.eraseAttrData())),this._dirtyRowService.markRangeDirty(e.scrollTop,e.scrollBottom)}else e.y--,this._restrictCursor()},t.prototype.reset=function(){this._parser.reset(),this._terminal.reset()},t.prototype.setgLevel=function(e){this._terminal.setgLevel(e)},t.prototype.screenAlignmentPattern=function(){var e=new p.CellData;e.content=1<<22|"E".charCodeAt(0),e.fg=this._terminal.curAttrData.fg,e.bg=this._terminal.curAttrData.bg;var t=this._bufferService.buffer;this._setCursor(0,0);for(var r=0;r<this._bufferService.rows;++r){var i=t.y+t.ybase+r;t.lines.get(i).fill(e),t.lines.get(i).isWrapped=!1}this._dirtyRowService.markAllDirty(),this._setCursor(0,0)},t}(l.Disposable);t.InputHandler=C},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),s=r(15),a=r(20),c=r(21),l=r(23),h=function(){function e(e){this.table=new Uint8Array(e)}return e.prototype.setDefault=function(e,t){s.fill(this.table,e<<4|t)},e.prototype.add=function(e,t,r,i){this.table[t<<8|e]=r<<4|i},e.prototype.addMany=function(e,t,r,i){for(var n=0;n<e.length;n++)this.table[t<<8|e[n]]=r<<4|i},e}();t.TransitionTable=h;t.VT500_TRANSITION_TABLE=function(){var e=new h(4095),t=Array.apply(null,Array(256)).map(function(e,t){return t}),r=function(e,r){return t.slice(e,r)},i=r(32,127),n=r(0,24);n.push(25),n.push.apply(n,r(28,32));var o,s=r(0,14);for(o in e.setDefault(1,0),e.addMany(i,0,2,0),s)e.addMany([24,26,153,154],o,3,0),e.addMany(r(128,144),o,3,0),e.addMany(r(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}();var u=function(e){function r(r){void 0===r&&(r=t.VT500_TRANSITION_TABLE);var i=e.call(this)||this;return i.TRANSITIONS=r,i.initialState=0,i.currentState=i.initialState,i._params=new a.Params,i._params.addParam(0),i._collect=0,i.precedingCodepoint=0,i._printHandlerFb=function(e,t,r){},i._executeHandlerFb=function(e){},i._csiHandlerFb=function(e,t){},i._escHandlerFb=function(e){},i._errorHandlerFb=function(e){return e},i._printHandler=i._printHandlerFb,i._executeHandlers=Object.create(null),i._csiHandlers=Object.create(null),i._escHandlers=Object.create(null),i._oscParser=new c.OscParser,i._dcsParser=new l.DcsParser,i._errorHandler=i._errorHandlerFb,i.setEscHandler({final:"\\"},function(){}),i}return n(r,e),r.prototype._identifier=function(e,t){void 0===t&&(t=[64,126]);var r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if((r=e.prefix.charCodeAt(0))&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(var i=0;i<e.intermediates.length;++i){var n=e.intermediates.charCodeAt(i);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=n}}if(1!==e.final.length)throw new Error("final must be a single byte");var o=e.final.charCodeAt(0);if(t[0]>o||o>t[1])throw new Error("final must be in range "+t[0]+" .. "+t[1]);return r<<=8,r|=o},r.prototype.identToString=function(e){for(var t=[];e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")},r.prototype.dispose=function(){this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null),this._oscParser.dispose(),this._dcsParser.dispose()},r.prototype.setPrintHandler=function(e){this._printHandler=e},r.prototype.clearPrintHandler=function(){this._printHandler=this._printHandlerFb},r.prototype.addEscHandler=function(e,t){var r=this._identifier(e,[48,126]);void 0===this._escHandlers[r]&&(this._escHandlers[r]=[]);var i=this._escHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.setEscHandler=function(e,t){this._escHandlers[this._identifier(e,[48,126])]=[t]},r.prototype.clearEscHandler=function(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]},r.prototype.setEscHandlerFallback=function(e){this._escHandlerFb=e},r.prototype.setExecuteHandler=function(e,t){this._executeHandlers[e.charCodeAt(0)]=t},r.prototype.clearExecuteHandler=function(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]},r.prototype.setExecuteHandlerFallback=function(e){this._executeHandlerFb=e},r.prototype.addCsiHandler=function(e,t){var r=this._identifier(e);void 0===this._csiHandlers[r]&&(this._csiHandlers[r]=[]);var i=this._csiHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.setCsiHandler=function(e,t){this._csiHandlers[this._identifier(e)]=[t]},r.prototype.clearCsiHandler=function(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]},r.prototype.setCsiHandlerFallback=function(e){this._csiHandlerFb=e},r.prototype.addDcsHandler=function(e,t){return this._dcsParser.addHandler(this._identifier(e),t)},r.prototype.setDcsHandler=function(e,t){this._dcsParser.setHandler(this._identifier(e),t)},r.prototype.clearDcsHandler=function(e){this._dcsParser.clearHandler(this._identifier(e))},r.prototype.setDcsHandlerFallback=function(e){this._dcsParser.setHandlerFallback(e)},r.prototype.addOscHandler=function(e,t){return this._oscParser.addHandler(e,t)},r.prototype.setOscHandler=function(e,t){this._oscParser.setHandler(e,t)},r.prototype.clearOscHandler=function(e){this._oscParser.clearHandler(e)},r.prototype.setOscHandlerFallback=function(e){this._oscParser.setHandlerFallback(e)},r.prototype.setErrorHandler=function(e){this._errorHandler=e},r.prototype.clearErrorHandler=function(){this._errorHandler=this._errorHandlerFb},r.prototype.reset=function(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0},r.prototype.parse=function(e,t){for(var r=0,i=0,n=this.currentState,o=this._oscParser,s=this._dcsParser,a=this._collect,c=this._params,l=this.TRANSITIONS.table,h=0;h<t;++h){switch((i=l[n<<8|((r=e[h])<160?r:160)])>>4){case 2:for(var u=h+1;;++u){if(u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}if(++u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}if(++u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}if(++u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:r,currentState:n,collect:a,params:c,abort:!1}).abort)return;break;case 7:for(var f=this._csiHandlers[a<<8|r],_=f?f.length-1:-1;_>=0&&!1===f[_](c);_--);_<0&&this._csiHandlerFb(a<<8|r,c),this.precedingCodepoint=0;break;case 8:do{switch(r){case 59:c.addParam(0);break;case 58:c.addSubParam(-1);break;default:c.addDigit(r-48)}}while(++h<t&&(r=e[h])>47&&r<60);h--;break;case 9:a<<=8,a|=r;break;case 10:for(var d=this._escHandlers[a<<8|r],p=d?d.length-1:-1;p>=0&&!1===d[p]();p--);p<0&&this._escHandlerFb(a<<8|r),this.precedingCodepoint=0;break;case 11:c.reset(),c.addParam(0),a=0;break;case 12:s.hook(a<<8|r,c);break;case 13:for(var v=h+1;;++v)if(v>=t||24===(r=e[v])||26===r||27===r||r>127&&r<160){s.put(e,h,v),h=v-1;break}break;case 14:s.unhook(24!==r&&26!==r),27===r&&(i|=1),c.reset(),c.addParam(0),a=0,this.precedingCodepoint=0;break;case 4:o.start();break;case 5:for(var g=h+1;;g++)if(g>=t||(r=e[g])<32||r>127&&r<=159){o.put(e,h,g),h=g-1;break}break;case 6:o.end(24!==r&&26!==r),27===r&&(i|=1),c.reset(),c.addParam(0),a=0,this.precedingCodepoint=0}n=15&i}this._collect=a,this.currentState=n},r}(o.Disposable);t.EscapeSequenceParser=u},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(41),c=r(47),l=r(48),h=r(49),u=r(28),f=r(2),_=r(4),d=r(0),p=r(24),v=r(1),g=1,y=function(e){function t(t,r,i,n,o,s,f,_){var d=e.call(this)||this;d._colors=t,d._screenElement=r,d._linkifier=i,d._bufferService=n,d._charSizeService=o,d._optionsService=s,d.coreService=f,d.coreBrowserService=_,d._id=g++,d._onRequestRefreshRows=new v.EventEmitter;var p=d._optionsService.options.allowTransparency;return d._characterJoinerRegistry=new u.CharacterJoinerRegistry(d._bufferService),d._renderLayers=[new a.TextRenderLayer(d._screenElement,0,d._colors,d._characterJoinerRegistry,p,d._id,d._bufferService,s),new c.SelectionRenderLayer(d._screenElement,1,d._colors,d._id,d._bufferService,s),new h.LinkRenderLayer(d._screenElement,2,d._colors,d._id,d._linkifier,d._bufferService,s),new l.CursorRenderLayer(d._screenElement,3,d._colors,d._id,d._onRequestRefreshRows,d._bufferService,s,f,_)],d.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},d._devicePixelRatio=window.devicePixelRatio,d._updateDimensions(),d.onOptionsChanged(),d}return n(t,e),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._renderLayers.forEach(function(e){return e.dispose()}),p.removeTerminalFromCache(this._id)},t.prototype.onDevicePixelRatioChange=function(){this._devicePixelRatio!==window.devicePixelRatio&&(this._devicePixelRatio=window.devicePixelRatio,this.onResize(this._bufferService.cols,this._bufferService.rows))},t.prototype.setColors=function(e){var t=this;this._colors=e,this._renderLayers.forEach(function(e){e.setColors(t._colors),e.reset()})},t.prototype.onResize=function(e,t){var r=this;this._updateDimensions(),this._renderLayers.forEach(function(e){return e.resize(r.dimensions)}),this._screenElement.style.width=this.dimensions.canvasWidth+"px",this._screenElement.style.height=this.dimensions.canvasHeight+"px"},t.prototype.onCharSizeChanged=function(){this.onResize(this._bufferService.cols,this._bufferService.rows)},t.prototype.onBlur=function(){this._runOperation(function(e){return e.onBlur()})},t.prototype.onFocus=function(){this._runOperation(function(e){return e.onFocus()})},t.prototype.onSelectionChanged=function(e,t,r){void 0===r&&(r=!1),this._runOperation(function(i){return i.onSelectionChanged(e,t,r)})},t.prototype.onCursorMove=function(){this._runOperation(function(e){return e.onCursorMove()})},t.prototype.onOptionsChanged=function(){this._runOperation(function(e){return e.onOptionsChanged()})},t.prototype.clear=function(){this._runOperation(function(e){return e.reset()})},t.prototype._runOperation=function(e){this._renderLayers.forEach(function(t){return e(t)})},t.prototype.renderRows=function(e,t){this._renderLayers.forEach(function(r){return r.onGridChanged(e,t)})},t.prototype._updateDimensions=function(){this._charSizeService.hasValidSize&&(this.dimensions.scaledCharWidth=Math.floor(this._charSizeService.width*window.devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._charSizeService.height*window.devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.options.lineHeight),this.dimensions.scaledCharTop=1===this._optionsService.options.lineHeight?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._optionsService.options.letterSpacing),this.dimensions.scaledCharLeft=Math.floor(this._optionsService.options.letterSpacing/2),this.dimensions.scaledCanvasHeight=this._bufferService.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._bufferService.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._bufferService.rows,this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._bufferService.cols)},t.prototype.registerCharacterJoiner=function(e){return this._characterJoinerRegistry.registerCharacterJoiner(e)},t.prototype.deregisterCharacterJoiner=function(e){return this._characterJoinerRegistry.deregisterCharacterJoiner(e)},t=o([s(3,d.IBufferService),s(4,_.ICharSizeService),s(5,d.IOptionsService),s(6,d.ICoreService),s(7,_.ICoreBrowserService)],t)}(f.Disposable);t.Renderer=y},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(42),s=r(13),a=r(6),c=r(3),l=r(28),h=r(5),u=function(e){function t(t,r,i,n,s,a,c,l){var u=e.call(this,t,"text",r,s,i,a,c,l)||this;return u.bufferService=c,u.optionsService=l,u._characterWidth=0,u._characterFont="",u._characterOverlapCache={},u._workCell=new h.CellData,u._state=new o.GridCache,u._characterJoinerRegistry=n,u}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t);var r=this._getFont(!1,!1);this._characterWidth===t.scaledCharWidth&&this._characterFont===r||(this._characterWidth=t.scaledCharWidth,this._characterFont=r,this._characterOverlapCache={}),this._state.clear(),this._state.resize(this._bufferService.cols,this._bufferService.rows)},t.prototype.reset=function(){this._state.clear(),this._clearAll()},t.prototype._forEachCell=function(e,t,r,i){for(var n=e;n<=t;n++)for(var o=n+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.lines.get(o),a=r?r.getJoinedCharacters(o):[],h=0;h<this._bufferService.cols;h++){s.loadCell(h,this._workCell);var u=this._workCell,f=!1,_=h;if(0!==u.getWidth()){if(a.length>0&&h===a[0][0]){f=!0;var d=a.shift();u=new l.JoinedCellData(this._workCell,s.translateToString(!0,d[0],d[1]),d[1]-d[0]),_=d[1]-1}!f&&this._isOverlapping(u)&&_<s.length-1&&s.getCodePoint(_+1)===c.NULL_CELL_CODE&&(u.content&=-12582913,u.content|=2<<22),i(u,h,n),h=_}}},t.prototype._drawBackground=function(e,t){var r=this,i=this._ctx,n=this._bufferService.cols,o=0,s=0,c=null;i.save(),this._forEachCell(e,t,null,function(e,t,l){var h=null;e.isInverse()?h=e.isFgDefault()?r._colors.foreground.css:e.isFgRGB()?"rgb("+a.AttributeData.toColorRGB(e.getFgColor()).join(",")+")":r._colors.ansi[e.getFgColor()].css:e.isBgRGB()?h="rgb("+a.AttributeData.toColorRGB(e.getBgColor()).join(",")+")":e.isBgPalette()&&(h=r._colors.ansi[e.getBgColor()].css),null===c&&(o=t,s=l),l!==s?(i.fillStyle=c||"",r._fillCells(o,s,n-o,1),o=t,s=l):c!==h&&(i.fillStyle=c||"",r._fillCells(o,s,t-o,1),o=t,s=l),c=h}),null!==c&&(i.fillStyle=c,this._fillCells(o,s,n-o,1)),i.restore()},t.prototype._drawForeground=function(e,t){var r=this;this._forEachCell(e,t,this._characterJoinerRegistry,function(e,t,i){if(!e.isInvisible()&&(r._drawChars(e,t,i),e.isUnderline())){if(r._ctx.save(),e.isInverse())if(e.isBgDefault())r._ctx.fillStyle=r._colors.background.css;else if(e.isBgRGB())r._ctx.fillStyle="rgb("+a.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var n=e.getBgColor();r._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&n<8&&(n+=8),r._ctx.fillStyle=r._colors.ansi[n].css}else if(e.isFgDefault())r._ctx.fillStyle=r._colors.foreground.css;else if(e.isFgRGB())r._ctx.fillStyle="rgb("+a.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var o=e.getFgColor();r._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8&&(o+=8),r._ctx.fillStyle=r._colors.ansi[o].css}r._fillBottomLineAtCells(t,i,e.getWidth()),r._ctx.restore()}})},t.prototype.onGridChanged=function(e,t){0!==this._state.cache.length&&(this._charAtlas&&this._charAtlas.beginFrame(),this._clearCells(0,e,this._bufferService.cols,t-e+1),this._drawBackground(e,t),this._drawForeground(e,t))},t.prototype.onOptionsChanged=function(){this._setTransparency(this._optionsService.options.allowTransparency)},t.prototype._isOverlapping=function(e){if(1!==e.getWidth())return!1;if(e.getCode()<256)return!1;var t=e.getChars();if(this._characterOverlapCache.hasOwnProperty(t))return this._characterOverlapCache[t];this._ctx.save(),this._ctx.font=this._characterFont;var r=Math.floor(this._ctx.measureText(t).width)>this._characterWidth;return this._ctx.restore(),this._characterOverlapCache[t]=r,r},t}(s.BaseRenderLayer);t.TextRenderLayer=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.cache=[]}return e.prototype.resize=function(e,t){for(var r=0;r<e;r++){this.cache.length<=r&&this.cache.push([]);for(var i=this.cache[r].length;i<t;i++)this.cache[r].push(void 0);this.cache[r].length=t}this.cache.length=e},e.prototype.clear=function(){for(var e=0;e<this.cache.length;e++)for(var t=0;t<this.cache[e].length;t++)this.cache[e][t]=void 0},e}();t.GridCache=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(9),s=r(44),a=r(26),c=r(46),l=r(11),h=r(27),u=r(10),f=1024,_=1024,d={css:"rgba(0, 0, 0, 0)",rgba:0};function p(e){return e.code<<21|e.bg<<12|e.fg<<3|(e.bold?0:4)+(e.dim?0:2)+(e.italic?0:1)}t.getGlyphCacheKey=p;var v=function(e){function t(t,r){var i=e.call(this)||this;i._config=r,i._drawToCacheCount=0,i._glyphsWaitingOnBitmap=[],i._bitmapCommitTimeout=null,i._bitmap=null,i._cacheCanvas=t.createElement("canvas"),i._cacheCanvas.width=f,i._cacheCanvas.height=_,i._cacheCtx=h.throwIfFalsy(i._cacheCanvas.getContext("2d",{alpha:!0}));var n=t.createElement("canvas");n.width=i._config.scaledCharWidth,n.height=i._config.scaledCharHeight,i._tmpCtx=h.throwIfFalsy(n.getContext("2d",{alpha:i._config.allowTransparency})),i._width=Math.floor(f/i._config.scaledCharWidth),i._height=Math.floor(_/i._config.scaledCharHeight);var o=i._width*i._height;return i._cacheMap=new c.LRUMap(o),i._cacheMap.prealloc(o),i}return n(t,e),t.prototype.dispose=function(){null!==this._bitmapCommitTimeout&&(window.clearTimeout(this._bitmapCommitTimeout),this._bitmapCommitTimeout=null)},t.prototype.beginFrame=function(){this._drawToCacheCount=0},t.prototype.draw=function(e,t,r,i){if(32===t.code)return!0;if(!this._canCache(t))return!1;var n=p(t),o=this._cacheMap.get(n);if(null!=o)return this._drawFromCache(e,o,r,i),!0;if(this._drawToCacheCount<100){var s=void 0;s=this._cacheMap.size<this._cacheMap.capacity?this._cacheMap.size:this._cacheMap.peek().index;var a=this._drawToCache(t,s);return this._cacheMap.set(n,a),this._drawFromCache(e,a,r,i),!0}return!1},t.prototype._canCache=function(e){return e.code<256},t.prototype._toCoordinateX=function(e){return e%this._width*this._config.scaledCharWidth},t.prototype._toCoordinateY=function(e){return Math.floor(e/this._width)*this._config.scaledCharHeight},t.prototype._drawFromCache=function(e,t,r,i){if(!t.isEmpty){var n=this._toCoordinateX(t.index),o=this._toCoordinateY(t.index);e.drawImage(t.inBitmap?this._bitmap:this._cacheCanvas,n,o,this._config.scaledCharWidth,this._config.scaledCharHeight,r,i,this._config.scaledCharWidth,this._config.scaledCharHeight)}},t.prototype._getColorFromAnsiIndex=function(e){return e<this._config.colors.ansi.length?this._config.colors.ansi[e]:a.DEFAULT_ANSI_COLORS[e]},t.prototype._getBackgroundColor=function(e){return this._config.allowTransparency?d:e.bg===o.INVERTED_DEFAULT_COLOR?this._config.colors.foreground:e.bg<256?this._getColorFromAnsiIndex(e.bg):this._config.colors.background},t.prototype._getForegroundColor=function(e){return e.fg===o.INVERTED_DEFAULT_COLOR?u.opaque(this._config.colors.background):e.fg<256?this._getColorFromAnsiIndex(e.fg):this._config.colors.foreground},t.prototype._drawToCache=function(e,t){this._drawToCacheCount++,this._tmpCtx.save();var r=this._getBackgroundColor(e);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=r.css,this._tmpCtx.fillRect(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),this._tmpCtx.globalCompositeOperation="source-over";var i=e.bold?this._config.fontWeightBold:this._config.fontWeight,n=e.italic?"italic":"";this._tmpCtx.font=n+" "+i+" "+this._config.fontSize*this._config.devicePixelRatio+"px "+this._config.fontFamily,this._tmpCtx.textBaseline="middle",this._tmpCtx.fillStyle=this._getForegroundColor(e).css,e.dim&&(this._tmpCtx.globalAlpha=o.DIM_OPACITY),this._tmpCtx.fillText(e.chars,0,this._config.scaledCharHeight/2),this._tmpCtx.restore();var s=this._tmpCtx.getImageData(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),a=!1;this._config.allowTransparency||(a=function(e,t){for(var r=!0,i=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,s=0;s<e.data.length;s+=4)e.data[s]===i&&e.data[s+1]===n&&e.data[s+2]===o?e.data[s+3]=0:r=!1;return r}(s,r));var c=this._toCoordinateX(t),l=this._toCoordinateY(t);this._cacheCtx.putImageData(s,c,l);var h={index:t,isEmpty:a,inBitmap:!1};return this._addGlyphToBitmap(h),h},t.prototype._addGlyphToBitmap=function(e){var t=this;"createImageBitmap"in window&&!l.isFirefox&&!l.isSafari&&(this._glyphsWaitingOnBitmap.push(e),null===this._bitmapCommitTimeout&&(this._bitmapCommitTimeout=window.setTimeout(function(){return t._generateBitmap()},100)))},t.prototype._generateBitmap=function(){var e=this,t=this._glyphsWaitingOnBitmap;this._glyphsWaitingOnBitmap=[],window.createImageBitmap(this._cacheCanvas).then(function(r){e._bitmap=r;for(var i=0;i<t.length;i++){t[i].inBitmap=!0}}),this._bitmapCommitTimeout=null},t}(s.BaseCharAtlas);t.DynamicCharAtlas=v;var g=function(e){function t(t,r){return e.call(this)||this}return n(t,e),t.prototype.draw=function(e,t,r,i){return!1},t}(s.BaseCharAtlas);t.NoneCharAtlas=g},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._didWarmUp=!1}return e.prototype.dispose=function(){},e.prototype.warmUp=function(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)},e.prototype._doWarmUp=function(){},e.prototype.beginFrame=function(){},e}();t.BaseCharAtlas=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._color={},this._rgba={}}return e.prototype.clear=function(){this._color={},this._rgba={}},e.prototype.setCss=function(e,t,r){this._rgba[e]||(this._rgba[e]={}),this._rgba[e][t]=r},e.prototype.getCss=function(e,t){return this._rgba[e]?this._rgba[e][t]:void 0},e.prototype.setColor=function(e,t,r){this._color[e]||(this._color[e]={}),this._color[e][t]=r},e.prototype.getColor=function(e,t){return this._color[e]?this._color[e][t]:void 0},e}();t.ColorContrastCache=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.capacity=e,this._map={},this._head=null,this._tail=null,this._nodePool=[],this.size=0}return e.prototype._unlinkNode=function(e){var t=e.prev,r=e.next;e===this._head&&(this._head=r),e===this._tail&&(this._tail=t),null!==t&&(t.next=r),null!==r&&(r.prev=t)},e.prototype._appendNode=function(e){var t=this._tail;null!==t&&(t.next=e),e.prev=t,e.next=null,this._tail=e,null===this._head&&(this._head=e)},e.prototype.prealloc=function(e){for(var t=this._nodePool,r=0;r<e;r++)t.push({prev:null,next:null,key:null,value:null})},e.prototype.get=function(e){var t=this._map[e];return void 0!==t?(this._unlinkNode(t),this._appendNode(t),t.value):null},e.prototype.peekValue=function(e){var t=this._map[e];return void 0!==t?t.value:null},e.prototype.peek=function(){var e=this._head;return null===e?null:e.value},e.prototype.set=function(e,t){var r=this._map[e];if(void 0!==r)r=this._map[e],this._unlinkNode(r),r.value=t;else if(this.size>=this.capacity)r=this._head,this._unlinkNode(r),delete this._map[r.key],r.key=e,r.value=t,this._map[e]=r;else{var i=this._nodePool;i.length>0?((r=i.pop()).key=e,r.value=t):r={prev:null,next:null,key:e,value:t},this._map[e]=r,this.size++}this._appendNode(r)},e}();t.LRUMap=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,r,i,n,o,s){var a=e.call(this,t,"selection",r,!0,i,n,o,s)||this;return a.bufferService=o,a.optionsService=s,a._clearState(),a}return n(t,e),t.prototype._clearState=function(){this._state={start:void 0,end:void 0,columnSelectMode:void 0,ydisp:void 0}},t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._clearState()},t.prototype.reset=function(){this._state.start&&this._state.end&&(this._clearState(),this._clearAll())},t.prototype.onSelectionChanged=function(e,t,r){if(this._didStateChange(e,t,r,this._bufferService.buffer.ydisp))if(this._clearAll(),e&&t){var i=e[1]-this._bufferService.buffer.ydisp,n=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),s=Math.min(n,this._bufferService.rows-1);if(!(o>=this._bufferService.rows||s<0)){if(this._ctx.fillStyle=this._colors.selection.css,r){var a=e[0],c=t[0]-a,l=s-o+1;this._fillCells(a,o,c,l)}else{a=i===o?e[0]:0;var h=o===s?t[0]:this._bufferService.cols;this._fillCells(a,o,h-a,1);var u=Math.max(s-o-1,0);if(this._fillCells(0,o+1,this._bufferService.cols,u),o!==s){var f=n===s?t[0]:this._bufferService.cols;this._fillCells(0,s,f,1)}}this._state.start=[e[0],e[1]],this._state.end=[t[0],t[1]],this._state.columnSelectMode=r,this._state.ydisp=this._bufferService.buffer.ydisp}}else this._clearState()},t.prototype._didStateChange=function(e,t,r,i){return!this._areCoordinatesEqual(e,this._state.start)||!this._areCoordinatesEqual(t,this._state.end)||r!==this._state.columnSelectMode||i!==this._state.ydisp},t.prototype._areCoordinatesEqual=function(e,t){return!(!e||!t)&&(e[0]===t[0]&&e[1]===t[1])},t}(r(13).BaseRenderLayer);t.SelectionRenderLayer=o},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(13),s=r(5),a=function(e){function t(t,r,i,n,o,a,c,l,h){var u=e.call(this,t,"cursor",r,!0,i,n,a,c)||this;return u._onRequestRefreshRowsEvent=o,u.bufferService=a,u.optionsService=c,u._coreService=l,u._coreBrowserService=h,u._cell=new s.CellData,u._state={x:0,y:0,isFocused:!1,style:"",width:0},u._cursorRenderers={bar:u._renderBarCursor.bind(u),block:u._renderBlockCursor.bind(u),underline:u._renderUnderlineCursor.bind(u)},u}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._state={x:0,y:0,isFocused:!1,style:"",width:0}},t.prototype.reset=function(){this._clearCursor(),this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=void 0,this.onOptionsChanged())},t.prototype.onBlur=function(){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause(),this._onRequestRefreshRowsEvent.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onFocus=function(){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume():this._onRequestRefreshRowsEvent.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onOptionsChanged=function(){var e,t=this;this._optionsService.options.cursorBlink?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new c(this._coreBrowserService.isFocused,function(){t._render(!0)})):(null===(e=this._cursorBlinkStateManager)||void 0===e||e.dispose(),this._cursorBlinkStateManager=void 0),this._onRequestRefreshRowsEvent.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onCursorMove=function(){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation()},t.prototype.onGridChanged=function(e,t){!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isPaused?this._render(!1):this._cursorBlinkStateManager.restartBlinkAnimation()},t.prototype._render=function(e){if(this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden){var t=this._bufferService.buffer.ybase+this._bufferService.buffer.y,r=t-this._bufferService.buffer.ydisp;if(r<0||r>=this._bufferService.rows)this._clearCursor();else if(this._bufferService.buffer.lines.get(t).loadCell(this._bufferService.buffer.x,this._cell),void 0!==this._cell.content){if(!this._coreBrowserService.isFocused){this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css;var i=this._optionsService.options.cursorStyle;return i&&"block"!==i?this._cursorRenderers[i](this._bufferService.buffer.x,r,this._cell):this._renderBlurCursor(this._bufferService.buffer.x,r,this._cell),this._ctx.restore(),this._state.x=this._bufferService.buffer.x,this._state.y=r,this._state.isFocused=!1,this._state.style=i,void(this._state.width=this._cell.getWidth())}if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===this._bufferService.buffer.x&&this._state.y===r&&this._state.isFocused===this._coreBrowserService.isFocused&&this._state.style===this._optionsService.options.cursorStyle&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[this._optionsService.options.cursorStyle||"block"](this._bufferService.buffer.x,r,this._cell),this._ctx.restore(),this._state.x=this._bufferService.buffer.x,this._state.y=r,this._state.isFocused=!1,this._state.style=this._optionsService.options.cursorStyle,this._state.width=this._cell.getWidth()}else this._clearCursor()}}else this._clearCursor()},t.prototype._clearCursor=function(){this._state&&(this._clearCells(this._state.x,this._state.y,this._state.width,1),this._state={x:0,y:0,isFocused:!1,style:"",width:0})},t.prototype._renderBarCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,t),this._ctx.restore()},t.prototype._renderBlockCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,t,r.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(r,e,t),this._ctx.restore()},t.prototype._renderUnderlineCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,t),this._ctx.restore()},t.prototype._renderBlurCursor=function(e,t,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,t,r.getWidth(),1),this._ctx.restore()},t}(o.BaseRenderLayer);t.CursorRenderLayer=a;var c=function(){function e(e,t){this._renderCallback=t,this.isCursorVisible=!0,e&&this._restartInterval()}return Object.defineProperty(e.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.restartBlinkAnimation=function(){var e=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){e._renderCallback(),e._animationFrame=void 0})))},e.prototype._restartInterval=function(e){var t=this;void 0===e&&(e=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=setTimeout(function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);if(t._animationTimeRestarted=void 0,e>0)return void t._restartInterval(e)}t.isCursorVisible=!1,t._animationFrame=window.requestAnimationFrame(function(){t._renderCallback(),t._animationFrame=void 0}),t._blinkInterval=setInterval(function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);return t._animationTimeRestarted=void 0,void t._restartInterval(e)}t.isCursorVisible=!t.isCursorVisible,t._animationFrame=window.requestAnimationFrame(function(){t._renderCallback(),t._animationFrame=void 0})},600)},e)},e.prototype.pause=function(){this.isCursorVisible=!0,this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.resume=function(){this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()},e}()},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(13),s=r(9),a=r(25),c=function(e){function t(t,r,i,n,o,s,a){var c=e.call(this,t,"link",r,!0,i,n,s,a)||this;return c.bufferService=s,c.optionsService=a,o.onLinkHover(function(e){return c._onLinkHover(e)}),o.onLinkLeave(function(e){return c._onLinkLeave(e)}),c}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._state=void 0},t.prototype.reset=function(){this._clearCurrentLink()},t.prototype._clearCurrentLink=function(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);var e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}},t.prototype._onLinkHover=function(e){if(e.fg===s.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._colors.background.css:e.fg&&a.is256Color(e.fg)?this._ctx.fillStyle=this._colors.ansi[e.fg].css:this._ctx.fillStyle=this._colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(var t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e},t.prototype._onLinkLeave=function(e){this._clearCurrentLink()},t}(o.BaseRenderLayer);t.LinkRenderLayer=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(19),n=r(1),o=function(){function e(e,t){this._bufferService=e,this._logService=t,this._linkMatchers=[],this._nextLinkMatcherId=0,this._onLinkHover=new n.EventEmitter,this._onLinkLeave=new n.EventEmitter,this._onLinkTooltip=new n.EventEmitter,this._rowsToLinkify={start:void 0,end:void 0}}return Object.defineProperty(e.prototype,"onLinkHover",{get:function(){return this._onLinkHover.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLinkLeave",{get:function(){return this._onLinkLeave.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLinkTooltip",{get:function(){return this._onLinkTooltip.event},enumerable:!0,configurable:!0}),e.prototype.attachToDom=function(e,t){this._element=e,this._mouseZoneManager=t},e.prototype.linkifyRows=function(t,r){var i=this;this._mouseZoneManager&&(void 0===this._rowsToLinkify.start||void 0===this._rowsToLinkify.end?(this._rowsToLinkify.start=t,this._rowsToLinkify.end=r):(this._rowsToLinkify.start=Math.min(this._rowsToLinkify.start,t),this._rowsToLinkify.end=Math.max(this._rowsToLinkify.end,r)),this._mouseZoneManager.clearAll(t,r),this._rowsTimeoutId&&clearTimeout(this._rowsTimeoutId),this._rowsTimeoutId=setTimeout(function(){return i._linkifyRows()},e._timeBeforeLatency))},e.prototype._linkifyRows=function(){this._rowsTimeoutId=void 0;var e=this._bufferService.buffer;if(void 0!==this._rowsToLinkify.start&&void 0!==this._rowsToLinkify.end){var t=e.ydisp+this._rowsToLinkify.start;if(!(t>=e.lines.length)){for(var r=e.ydisp+Math.min(this._rowsToLinkify.end,this._bufferService.rows)+1,i=Math.ceil(2e3/this._bufferService.cols),n=this._bufferService.buffer.iterator(!1,t,r,i,i);n.hasNext();)for(var o=n.next(),s=0;s<this._linkMatchers.length;s++)this._doLinkifyRow(o.range.first,o.content,this._linkMatchers[s]);this._rowsToLinkify.start=void 0,this._rowsToLinkify.end=void 0}}else this._logService.debug("_rowToLinkify was unset before _linkifyRows was called")},e.prototype.registerLinkMatcher=function(e,t,r){if(void 0===r&&(r={}),!t)throw new Error("handler must be defined");var i={id:this._nextLinkMatcherId++,regex:e,handler:t,matchIndex:r.matchIndex,validationCallback:r.validationCallback,hoverTooltipCallback:r.tooltipCallback,hoverLeaveCallback:r.leaveCallback,willLinkActivate:r.willLinkActivate,priority:r.priority||0};return this._addLinkMatcherToList(i),i.id},e.prototype._addLinkMatcherToList=function(e){if(0!==this._linkMatchers.length){for(var t=this._linkMatchers.length-1;t>=0;t--)if(e.priority<=this._linkMatchers[t].priority)return void this._linkMatchers.splice(t+1,0,e);this._linkMatchers.splice(0,0,e)}else this._linkMatchers.push(e)},e.prototype.deregisterLinkMatcher=function(e){for(var t=0;t<this._linkMatchers.length;t++)if(this._linkMatchers[t].id===e)return this._linkMatchers.splice(t,1),!0;return!1},e.prototype._doLinkifyRow=function(e,t,r){for(var i,n=this,o=new RegExp(r.regex.source,(r.regex.flags||"")+"g"),s=-1,a=function(){var a=i["number"!=typeof r.matchIndex?0:r.matchIndex];if(!a)return c._logService.debug("match found without corresponding matchIndex",i,r),"break";if(s=t.indexOf(a,s+1),o.lastIndex=s+a.length,s<0)return"break";var l=c._bufferService.buffer.stringIndexToBufferIndex(e,s);if(l[0]<0)return"break";var h=c._bufferService.buffer.lines.get(l[0]);if(!h)return"break";var u=h.getFg(l[1]),f=u?u>>9&511:void 0;r.validationCallback?r.validationCallback(a,function(e){n._rowsTimeoutId||e&&n._addLink(l[1],l[0]-n._bufferService.buffer.ydisp,a,r,f)}):c._addLink(l[1],l[0]-c._bufferService.buffer.ydisp,a,r,f)},c=this;null!==(i=o.exec(t));){if("break"===a())break}},e.prototype._addLink=function(e,t,r,n,o){var a=this;if(this._mouseZoneManager&&this._element){var c=i.getStringCellWidth(r),l=e%this._bufferService.cols,h=t+Math.floor(e/this._bufferService.cols),u=(l+c)%this._bufferService.cols,f=h+Math.floor((l+c)/this._bufferService.cols);0===u&&(u=this._bufferService.cols,f--),this._mouseZoneManager.add(new s(l+1,h+1,u+1,f+1,function(e){if(n.handler)return n.handler(e,r);window.open(r,"_blank")},function(){a._onLinkHover.fire(a._createLinkHoverEvent(l,h,u,f,o)),a._element.classList.add("xterm-cursor-pointer")},function(e){a._onLinkTooltip.fire(a._createLinkHoverEvent(l,h,u,f,o)),n.hoverTooltipCallback&&n.hoverTooltipCallback(e,r,{start:{x:l,y:h},end:{x:u,y:f}})},function(){a._onLinkLeave.fire(a._createLinkHoverEvent(l,h,u,f,o)),a._element.classList.remove("xterm-cursor-pointer"),n.hoverLeaveCallback&&n.hoverLeaveCallback()},function(e){return!n.willLinkActivate||n.willLinkActivate(e,r)}))}},e.prototype._createLinkHoverEvent=function(e,t,r,i,n){return{x1:e,y1:t,x2:r,y2:i,cols:this._bufferService.cols,fg:n}},e._timeBeforeLatency=200,e}();t.Linkifier=o;var s=function(e,t,r,i,n,o,s,a,c){this.x1=e,this.y1=t,this.x2=r,this.y2=i,this.clickCallback=n,this.hoverCallback=o,this.tooltipCallback=s,this.leaveCallback=a,this.willLinkActivate=c};t.MouseZone=s},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(11),s=r(52),a=r(5),c=r(1),l=r(4),h=r(0),u=r(29),f=r(53),_=String.fromCharCode(160),d=new RegExp(_,"g"),p=function(){function e(e,t,r,i,n,o,l,h){var u=this;this._scrollLines=e,this._element=t,this._screenElement=r,this._charSizeService=i,this._bufferService=n,this._coreService=o,this._mouseService=l,this._optionsService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new a.CellData,this._mouseDownTimeStamp=0,this._onLinuxMouseSelection=new c.EventEmitter,this._onRedrawRequest=new c.EventEmitter,this._onSelectionChange=new c.EventEmitter,this._mouseMoveListener=function(e){return u._onMouseMove(e)},this._mouseUpListener=function(e){return u._onMouseUp(e)},this._coreService.onUserInput(function(){u.hasSelection&&u.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(function(e){return u._onTrim(e)}),this._bufferService.buffers.onBufferActivate(function(e){return u._onBufferActivate(e)}),this.enable(),this._model=new s.SelectionModel(this._bufferService),this._activeSelectionMode=0}return Object.defineProperty(e.prototype,"onLinuxMouseSelection",{get:function(){return this._onLinuxMouseSelection.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onRedrawRequest",{get:function(){return this._onRedrawRequest.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSelectionChange",{get:function(){return this._onSelectionChange.event},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._removeMouseDownListeners()},e.prototype.reset=function(){this.clearSelection()},e.prototype.disable=function(){this.clearSelection(),this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},Object.defineProperty(e.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSelection",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t)&&(e[0]!==t[0]||e[1]!==t[1])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectionText",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";var r=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";for(var n=e[1];n<=t[1];n++){var s=r.translateBufferLineToString(n,!0,e[0],t[0]);i.push(s)}}else{var a=e[1]===t[1]?t[0]:void 0;i.push(r.translateBufferLineToString(e[1],!0,e[0],a));for(n=e[1]+1;n<=t[1]-1;n++){var c=r.lines.get(n);s=r.translateBufferLineToString(n,!0);c&&c.isWrapped?i[i.length-1]+=s:i.push(s)}if(e[1]!==t[1]){c=r.lines.get(t[1]),s=r.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?i[i.length-1]+=s:i.push(s)}}return i.map(function(e){return e.replace(d," ")}).join(o.isWindows?"\r\n":"\n")},enumerable:!0,configurable:!0}),e.prototype.clearSelection=function(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()},e.prototype.refresh=function(e){var t=this;(this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(function(){return t._refresh()})),o.isLinux&&e)&&(this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText))},e.prototype._refresh=function(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})},e.prototype.isClickInSelection=function(e){var t=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!(r&&i&&t)&&this._areCoordsInSelection(t,r,i)},e.prototype._areCoordsInSelection=function(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]},e.prototype.selectWordAtCursor=function(e){var t=this._getMouseBufferCoords(e);t&&(this._selectWordAt(t,!1),this._model.selectionEnd=void 0,this.refresh(!0))},e.prototype.selectAll=function(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()},e.prototype.selectLines=function(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()},e.prototype._onTrim=function(e){this._model.onTrim(e)&&this.refresh()},e.prototype._getMouseBufferCoords=function(e){var t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t},e.prototype._getMouseEventScrollAmount=function(e){var t=u.getCoordsRelativeToElement(e,this._screenElement)[1],r=this._bufferService.rows*Math.ceil(this._charSizeService.height*this._optionsService.options.lineHeight);return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-50),50),(t/=50)/Math.abs(t)+Math.round(14*t))},e.prototype.shouldForceSelection=function(e){return o.isMac?e.altKey&&this._optionsService.options.macOptionClickForcesSelection:e.shiftKey},e.prototype.onMouseDown=function(e){if(this._mouseDownTimeStamp=e.timeStamp,(2!==e.button||!this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._onIncrementalClick(e):1===e.detail?this._onSingleClick(e):2===e.detail?this._onDoubleClick(e):3===e.detail&&this._onTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}},e.prototype._addMouseDownListeners=function(){var e=this;this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=window.setInterval(function(){return e._dragScroll()},50)},e.prototype._removeMouseDownListeners=function(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0},e.prototype._onIncrementalClick=function(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))},e.prototype._onSingleClick=function(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),this._model.selectionStart){this._model.selectionEnd=void 0;var t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&0===t.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}},e.prototype._onDoubleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=1,this._selectWordAt(t,!0))},e.prototype._onTripleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))},e.prototype.shouldColumnSelect=function(e){return e.altKey&&!(o.isMac&&this._optionsService.options.macOptionClickForcesSelection)},e.prototype._onMouseMove=function(e){if(e.stopImmediatePropagation(),this._model.selectionStart){var t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),this._model.selectionEnd){2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));var r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){var i=r.lines.get(this._model.selectionEnd[1]);i&&0===i.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}else this.refresh(!0)}},e.prototype._dragScroll=function(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._scrollLines(this._dragScrollAmount,!1);var e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}},e.prototype._onMouseUp=function(e){var t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500){if(e.altKey&&this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){var r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){var i=f.moveToCellSequence(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this.hasSelection&&this._onSelectionChange.fire()},e.prototype._onBufferActivate=function(e){var t=this;this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(function(e){return t._onTrim(e)})},e.prototype._convertViewportColToCharacterIndex=function(e,t){for(var r=t[0],i=0;t[0]>=i;i++){var n=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?r--:n>1&&t[0]!==i&&(r+=n-1)}return r},e.prototype.setSelection=function(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh()},e.prototype._getWordAt=function(e,t,r,i){if(void 0===r&&(r=!0),void 0===i&&(i=!0),!(e[0]>=this._bufferService.cols)){var n=this._bufferService.buffer,o=n.lines.get(e[1]);if(o){var s=n.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e),c=a,l=e[0]-a,h=0,u=0,f=0,_=0;if(" "===s.charAt(a)){for(;a>0&&" "===s.charAt(a-1);)a--;for(;c<s.length&&" "===s.charAt(c+1);)c++}else{var d=e[0],p=e[0];0===o.getWidth(d)&&(h++,d--),2===o.getWidth(p)&&(u++,p++);var v=o.getString(p).length;for(v>1&&(_+=v-1,c+=v-1);d>0&&a>0&&!this._isCharWordSeparator(o.loadCell(d-1,this._workCell));){o.loadCell(d-1,this._workCell);var g=this._workCell.getChars().length;0===this._workCell.getWidth()?(h++,d--):g>1&&(f+=g-1,a-=g-1),a--,d--}for(;p<o.length&&c+1<s.length&&!this._isCharWordSeparator(o.loadCell(p+1,this._workCell));){o.loadCell(p+1,this._workCell);var y=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,p++):y>1&&(_+=y-1,c+=y-1),c++,p++}}c++;var b=a+l-h+f,m=Math.min(this._bufferService.cols,c-a+h+u-f-_);if(t||""!==s.slice(a,c).trim()){if(r&&0===b&&32!==o.getCodePoint(0)){var C=n.lines.get(e[1]-1);if(C&&o.isWrapped&&32!==C.getCodePoint(this._bufferService.cols-1)){var S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){var w=this._bufferService.cols-S.start;b-=w,m+=w}}}if(i&&b+m===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){var E=n.lines.get(e[1]+1);if(E&&E.isWrapped&&32!==E.getCodePoint(0)){var L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(m+=L.length)}}return{start:b,length:m}}}}},e.prototype._selectWordAt=function(e,t){var r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}},e.prototype._selectToWordAt=function(e){var t=this._getWordAt(e,!0);if(t){for(var r=e[1];t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}},e.prototype._isCharWordSeparator=function(e){return 0!==e.getWidth()&&this._optionsService.options.wordSeparator.indexOf(e.getChars())>=0},e.prototype._selectLineAt=function(e){var t=this._bufferService.buffer.getWrappedRangeForLine(e);this._model.selectionStart=[0,t.first],this._model.selectionEnd=[this._bufferService.cols,t.last],this._model.selectionStartLength=0},e=i([n(3,l.ICharSizeService),n(4,h.IBufferService),n(5,h.ICoreService),n(6,l.IMouseService),n(7,h.IOptionsService)],e)}();t.SelectionService=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}return e.prototype.clearSelection=function(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0},Object.defineProperty(e.prototype,"finalSelectionStart",{get:function(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"finalSelectionEnd",{get:function(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){var e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}return this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]?[Math.max(this.selectionStart[0]+this.selectionStartLength,this.selectionEnd[0]),this.selectionEnd[1]]:this.selectionEnd}},enumerable:!0,configurable:!0}),e.prototype.areSelectionValuesReversed=function(){var e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])},e.prototype.onTrim=function(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)},e}();t.SelectionModel=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(12);function n(e,t,r,i){var n=e-o(r,e),s=t-o(r,t);return h(Math.abs(n-s)-function(e,t,r){for(var i=0,n=e-o(r,e),s=t-o(r,t),c=0;c<Math.abs(n-s);c++){var l="A"===a(e,t)?-1:1,h=r.buffer.lines.get(n+l*c);h&&h.isWrapped&&i++}return i}(e,t,r),l(a(e,t),i))}function o(e,t){for(var r=0,i=e.buffer.lines.get(t),n=i&&i.isWrapped;n&&t>=0&&t<e.rows;)r++,n=(i=e.buffer.lines.get(--t))&&i.isWrapped;return r}function s(e,t,r,i,s,a){var c;return c=n(r,i,s,a).length>0?i-o(s,i):t,e<r&&c<=i||e>=r&&c<i?"C":"D"}function a(e,t){return e>t?"A":"B"}function c(e,t,r,i,n,o){for(var s=e,a=t,c="";s!==r||a!==i;)s+=n?1:-1,n&&s>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,s),s=0,e=0,a++):!n&&s<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),e=s=o.cols-1,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,s)}function l(e,t){var r=t?"O":"[";return i.C0.ESC+r+e}function h(e,t){e=Math.floor(e);for(var r="",i=0;i<e;i++)r+=t;return r}t.moveToCellSequence=function(e,t,r,i){var a=r.buffer.x,u=r.buffer.y;return r.buffer.hasScrollback?function(e,t,r,i,n,o){var a=s(e,t,r,i,n,o);return h(Math.abs(e-r),l(a,o))}(a,u,e,t,r,i):function(e,t,r,i,s,a){if(0===n(t,i,s,a).length)return"";return h(c(e,t,e,t-o(s,t),!1,s).length,l("D",a))}(a,u,0,t,r,i)+n(u,t,r,i)+function(e,t,r,i,a,u){var f;f=n(t,i,a,u).length>0?i-o(a,i):t;var _=i,d=s(e,t,r,i,a,u);return h(c(e,f,r,_,"C"===d,a).length,l(d,u))}(a,u,e,t,r,i)}},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=function(){function e(e){this._optionsService=e}return Object.defineProperty(e,"audioContext",{get:function(){if(!e._audioContext){var t=window.AudioContext||window.webkitAudioContext;if(!t)return console.warn("Web Audio API is not supported by this browser. Consider upgrading to the latest version"),null;e._audioContext=new t}return e._audioContext},enumerable:!0,configurable:!0}),e.prototype.playBellSound=function(){var t=e.audioContext;if(t){var r=t.createBufferSource();t.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.options.bellSound)),function(e){r.buffer=e,r.connect(t.destination),r.start(0)})}},e.prototype._base64ToArrayBuffer=function(e){for(var t=window.atob(e),r=t.length,i=new Uint8Array(r),n=0;n<r;n++)i[n]=t.charCodeAt(n);return i.buffer},e.prototype._removeMimeType=function(e){return e.split(",")[1]},e=i([n(0,o.IOptionsService)],e)}();t.SoundService=s},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),c=r(7),l=r(4),h=r(0),u=function(e){function t(t,r,i,n,o){var s=e.call(this)||this;return s._element=t,s._screenElement=r,s._bufferService=i,s._mouseService=n,s._selectionService=o,s._zones=[],s._areZonesActive=!1,s._lastHoverCoords=[void 0,void 0],s._initialSelectionLength=0,s.register(c.addDisposableDomListener(s._element,"mousedown",function(e){return s._onMouseDown(e)})),s._mouseMoveListener=function(e){return s._onMouseMove(e)},s._mouseLeaveListener=function(e){return s._onMouseLeave(e)},s._clickListener=function(e){return s._onClick(e)},s}return n(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._deactivate()},t.prototype.add=function(e){this._zones.push(e),1===this._zones.length&&this._activate()},t.prototype.clearAll=function(e,t){if(0!==this._zones.length){e&&t||(e=0,t=this._bufferService.rows-1);for(var r=0;r<this._zones.length;r++){var i=this._zones[r];(i.y1>e&&i.y1<=t+1||i.y2>e&&i.y2<=t+1||i.y1<e&&i.y2>t+1)&&(this._currentZone&&this._currentZone===i&&(this._currentZone.leaveCallback(),this._currentZone=void 0),this._zones.splice(r--,1))}0===this._zones.length&&this._deactivate()}},t.prototype._activate=function(){this._areZonesActive||(this._areZonesActive=!0,this._element.addEventListener("mousemove",this._mouseMoveListener),this._element.addEventListener("mouseleave",this._mouseLeaveListener),this._element.addEventListener("click",this._clickListener))},t.prototype._deactivate=function(){this._areZonesActive&&(this._areZonesActive=!1,this._element.removeEventListener("mousemove",this._mouseMoveListener),this._element.removeEventListener("mouseleave",this._mouseLeaveListener),this._element.removeEventListener("click",this._clickListener))},t.prototype._onMouseMove=function(e){this._lastHoverCoords[0]===e.pageX&&this._lastHoverCoords[1]===e.pageY||(this._onHover(e),this._lastHoverCoords=[e.pageX,e.pageY])},t.prototype._onHover=function(e){var t=this,r=this._findZoneEventAt(e);r!==this._currentZone&&(this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout)),r&&(this._currentZone=r,r.hoverCallback&&r.hoverCallback(e),this._tooltipTimeout=setTimeout(function(){return t._onTooltip(e)},500)))},t.prototype._onTooltip=function(e){this._tooltipTimeout=void 0;var t=this._findZoneEventAt(e);t&&t.tooltipCallback&&t.tooltipCallback(e)},t.prototype._onMouseDown=function(e){var t;(this._initialSelectionLength=this._getSelectionLength(),this._areZonesActive)&&((null===(t=this._findZoneEventAt(e))||void 0===t?void 0:t.willLinkActivate(e))&&(e.preventDefault(),e.stopImmediatePropagation()))},t.prototype._onMouseLeave=function(e){this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout))},t.prototype._onClick=function(e){var t=this._findZoneEventAt(e),r=this._getSelectionLength();t&&r===this._initialSelectionLength&&(t.clickCallback(e),e.preventDefault(),e.stopImmediatePropagation())},t.prototype._getSelectionLength=function(){var e=this._selectionService.selectionText;return e?e.length:0},t.prototype._findZoneEventAt=function(e){var t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows);if(t)for(var r=t[0],i=t[1],n=0;n<this._zones.length;n++){var o=this._zones[n];if(o.y1===o.y2){if(i===o.y1&&r>=o.x1&&r<o.x2)return o}else if(i===o.y1&&r>=o.x1||i===o.y2&&r<o.x2||i>o.y1&&i<o.y2)return o}},t=o([s(2,h.IBufferService),s(3,l.IMouseService),s(4,l.ISelectionService)],t)}(a.Disposable);t.MouseZoneManager=u},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(17),s=r(11),a=r(30),c=r(7),l=r(2),h=r(31),u=function(e){function t(t,r){var i=e.call(this)||this;i._terminal=t,i._renderService=r,i._liveRegionLineCount=0,i._charsToConsume=[],i._charsToAnnounce="",i._accessibilityTreeRoot=document.createElement("div"),i._accessibilityTreeRoot.classList.add("xterm-accessibility"),i._rowContainer=document.createElement("div"),i._rowContainer.classList.add("xterm-accessibility-tree"),i._rowElements=[];for(var n=0;n<i._terminal.rows;n++)i._rowElements[n]=i._createAccessibilityTreeNode(),i._rowContainer.appendChild(i._rowElements[n]);return i._topBoundaryFocusListener=function(e){return i._onBoundaryFocus(e,0)},i._bottomBoundaryFocusListener=function(e){return i._onBoundaryFocus(e,1)},i._rowElements[0].addEventListener("focus",i._topBoundaryFocusListener),i._rowElements[i._rowElements.length-1].addEventListener("focus",i._bottomBoundaryFocusListener),i._refreshRowsDimensions(),i._accessibilityTreeRoot.appendChild(i._rowContainer),i._renderRowsDebouncer=new a.RenderDebouncer(i._renderRows.bind(i)),i._refreshRows(),i._liveRegion=document.createElement("div"),i._liveRegion.classList.add("live-region"),i._liveRegion.setAttribute("aria-live","assertive"),i._accessibilityTreeRoot.appendChild(i._liveRegion),i._terminal.element.insertAdjacentElement("afterbegin",i._accessibilityTreeRoot),i.register(i._renderRowsDebouncer),i.register(i._terminal.onResize(function(e){return i._onResize(e.rows)})),i.register(i._terminal.onRender(function(e){return i._refreshRows(e.start,e.end)})),i.register(i._terminal.onScroll(function(){return i._refreshRows()})),i.register(i._terminal.onA11yChar(function(e){return i._onChar(e)})),i.register(i._terminal.onLineFeed(function(){return i._onChar("\n")})),i.register(i._terminal.onA11yTab(function(e){return i._onTab(e)})),i.register(i._terminal.onKey(function(e){return i._onKey(e.key)})),i.register(i._terminal.onBlur(function(){return i._clearLiveRegion()})),i.register(i._renderService.onDimensionsChange(function(){return i._refreshRowsDimensions()})),i._screenDprMonitor=new h.ScreenDprMonitor,i.register(i._screenDprMonitor),i._screenDprMonitor.setListener(function(){return i._refreshRowsDimensions()}),i.register(c.addDisposableDomListener(window,"resize",function(){return i._refreshRowsDimensions()})),i}return n(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._terminal.element.removeChild(this._accessibilityTreeRoot),this._rowElements.length=0},t.prototype._onBoundaryFocus=function(e,t){var r=e.target,i=this._rowElements[0===t?1:this._rowElements.length-2];if(r.getAttribute("aria-posinset")!==(0===t?"1":""+this._terminal.buffer.lines.length)&&e.relatedTarget===i){var n,o;if(0===t?(n=r,o=this._rowElements.pop(),this._rowContainer.removeChild(o)):(n=this._rowElements.shift(),o=r,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),o.removeEventListener("focus",this._bottomBoundaryFocusListener),0===t){var s=this._createAccessibilityTreeNode();this._rowElements.unshift(s),this._rowContainer.insertAdjacentElement("afterbegin",s)}else{s=this._createAccessibilityTreeNode();this._rowElements.push(s),this._rowContainer.appendChild(s)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===t?-1:1),this._rowElements[0===t?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}},t.prototype._onResize=function(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(var t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()},t.prototype._createAccessibilityTreeNode=function(){var e=document.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e},t.prototype._onTab=function(e){for(var t=0;t<e;t++)this._onChar(" ")},t.prototype._onChar=function(e){var t=this;if(this._liveRegionLineCount<21){if(this._charsToConsume.length>0)this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e);else this._charsToAnnounce+=e;"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=o.tooMuchOutput)),s.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout(function(){t._accessibilityTreeRoot.appendChild(t._liveRegion)},0)}},t.prototype._clearLiveRegion=function(){this._liveRegion.textContent="",this._liveRegionLineCount=0,s.isMac&&this._liveRegion.parentNode&&this._accessibilityTreeRoot.removeChild(this._liveRegion)},t.prototype._onKey=function(e){this._clearLiveRegion(),this._charsToConsume.push(e)},t.prototype._refreshRows=function(e,t){this._renderRowsDebouncer.refresh(e,t,this._terminal.rows)},t.prototype._renderRows=function(e,t){for(var r=this._terminal.buffer,i=r.lines.length.toString(),n=e;n<=t;n++){var o=r.translateBufferLineToString(r.ydisp+n,!0),s=(r.ydisp+n+1).toString(),a=this._rowElements[n];a&&(0===o.length?a.innerHTML=" ":a.textContent=o,a.setAttribute("aria-posinset",s),a.setAttribute("aria-setsize",i))}this._announceCharacters()},t.prototype._refreshRowsDimensions=function(){if(this._renderService.dimensions.actualCellHeight){this._rowElements.length!==this._terminal.rows&&this._onResize(this._terminal.rows);for(var e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}},t.prototype._refreshRowDimensions=function(e){e.style.height=this._renderService.dimensions.actualCellHeight+"px"},t.prototype._announceCharacters=function(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")},t}(l.Disposable);t.AccessibilityManager=u},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(58),c=r(9),l=r(2),h=r(4),u=r(0),f=r(1),_=r(10),d="xterm-dom-renderer-owner-",p="xterm-rows",v="xterm-selection",g=1,y=function(e){function t(t,r,i,n,o,s,c,l){var h=e.call(this)||this;return h._colors=t,h._element=r,h._screenElement=i,h._viewportElement=n,h._linkifier=o,h._charSizeService=s,h._optionsService=c,h._bufferService=l,h._terminalClass=g++,h._rowElements=[],h._onRequestRefreshRows=new f.EventEmitter,h._rowContainer=document.createElement("div"),h._rowContainer.classList.add(p),h._rowContainer.style.lineHeight="normal",h._rowContainer.setAttribute("aria-hidden","true"),h._refreshRowElements(h._bufferService.cols,h._bufferService.rows),h._selectionContainer=document.createElement("div"),h._selectionContainer.classList.add(v),h._selectionContainer.setAttribute("aria-hidden","true"),h.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},h._updateDimensions(),h._injectCss(),h._rowFactory=new a.DomRendererRowFactory(document,h._optionsService,h._colors),h._element.classList.add(d+h._terminalClass),h._screenElement.appendChild(h._rowContainer),h._screenElement.appendChild(h._selectionContainer),h._linkifier.onLinkHover(function(e){return h._onLinkHover(e)}),h._linkifier.onLinkLeave(function(e){return h._onLinkLeave(e)}),h}return n(t,e),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._element.classList.remove(d+this._terminalClass),this._screenElement.removeChild(this._rowContainer),this._screenElement.removeChild(this._selectionContainer),this._screenElement.removeChild(this._themeStyleElement),this._screenElement.removeChild(this._dimensionsStyleElement),e.prototype.dispose.call(this)},t.prototype._updateDimensions=function(){var e=this;this.dimensions.scaledCharWidth=this._charSizeService.width*window.devicePixelRatio,this.dimensions.scaledCharHeight=Math.ceil(this._charSizeService.height*window.devicePixelRatio),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._optionsService.options.letterSpacing),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.options.lineHeight),this.dimensions.scaledCharLeft=0,this.dimensions.scaledCharTop=0,this.dimensions.scaledCanvasWidth=this.dimensions.scaledCellWidth*this._bufferService.cols,this.dimensions.scaledCanvasHeight=this.dimensions.scaledCellHeight*this._bufferService.rows,this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._bufferService.cols,this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._bufferService.rows,this._rowElements.forEach(function(t){t.style.width=e.dimensions.canvasWidth+"px",t.style.height=e.dimensions.actualCellHeight+"px",t.style.lineHeight=e.dimensions.actualCellHeight+"px",t.style.overflow="hidden"}),this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));var t=this._terminalSelector+" ."+p+" span { display: inline-block; height: 100%; vertical-align: top; width: "+this.dimensions.actualCellWidth+"px}";this._dimensionsStyleElement.innerHTML=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=this.dimensions.canvasWidth+"px",this._screenElement.style.height=this.dimensions.canvasHeight+"px"},t.prototype.setColors=function(e){this._colors=e,this._injectCss()},t.prototype._injectCss=function(){var e=this;this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));var t=this._terminalSelector+" ."+p+" { color: "+this._colors.foreground.css+"; background-color: "+this._colors.background.css+"; font-family: "+this._optionsService.options.fontFamily+"; font-size: "+this._optionsService.options.fontSize+"px;}";t+=this._terminalSelector+" span:not(."+a.BOLD_CLASS+") { font-weight: "+this._optionsService.options.fontWeight+";}"+this._terminalSelector+" span."+a.BOLD_CLASS+" { font-weight: "+this._optionsService.options.fontWeightBold+";}"+this._terminalSelector+" span."+a.ITALIC_CLASS+" { font-style: italic;}",t+="@keyframes blink_box_shadow { 50% {  box-shadow: none; }}",t+="@keyframes blink_block { 0% {  background-color: "+this._colors.cursor.css+";  color: "+this._colors.cursorAccent.css+"; } 50% {  background-color: "+this._colors.cursorAccent.css+";  color: "+this._colors.cursor.css+"; }}",t+=this._terminalSelector+" ."+p+":not(.xterm-focus) ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { outline: 1px solid "+this._colors.cursor.css+"; outline-offset: -1px;}"+this._terminalSelector+" ."+p+".xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_BLINK_CLASS+":not(."+a.CURSOR_STYLE_BLOCK_CLASS+") { animation: blink_box_shadow 1s step-end infinite;}"+this._terminalSelector+" ."+p+".xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_BLINK_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { animation: blink_block 1s step-end infinite;}"+this._terminalSelector+" ."+p+".xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { background-color: "+this._colors.cursor.css+"; color: "+this._colors.cursorAccent.css+";}"+this._terminalSelector+" ."+p+" ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BAR_CLASS+" { box-shadow: 1px 0 0 "+this._colors.cursor.css+" inset;}"+this._terminalSelector+" ."+p+" ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_UNDERLINE_CLASS+" { box-shadow: 0 -1px 0 "+this._colors.cursor.css+" inset;}",t+=this._terminalSelector+" ."+v+" { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}"+this._terminalSelector+" ."+v+" div { position: absolute; background-color: "+this._colors.selection.css+";}",this._colors.ansi.forEach(function(r,i){t+=e._terminalSelector+" .xterm-fg-"+i+" { color: "+r.css+"; }"+e._terminalSelector+" .xterm-bg-"+i+" { background-color: "+r.css+"; }"}),t+=this._terminalSelector+" .xterm-fg-"+c.INVERTED_DEFAULT_COLOR+" { color: "+_.opaque(this._colors.background).css+"; }"+this._terminalSelector+" .xterm-bg-"+c.INVERTED_DEFAULT_COLOR+" { background-color: "+this._colors.foreground.css+"; }",this._themeStyleElement.innerHTML=t},t.prototype.onDevicePixelRatioChange=function(){this._updateDimensions()},t.prototype._refreshRowElements=function(e,t){for(var r=this._rowElements.length;r<=t;r++){var i=document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())},t.prototype.onResize=function(e,t){this._refreshRowElements(e,t),this._updateDimensions()},t.prototype.onCharSizeChanged=function(){this._updateDimensions()},t.prototype.onBlur=function(){this._rowContainer.classList.remove("xterm-focus")},t.prototype.onFocus=function(){this._rowContainer.classList.add("xterm-focus")},t.prototype.onSelectionChanged=function(e,t,r){for(;this._selectionContainer.children.length;)this._selectionContainer.removeChild(this._selectionContainer.children[0]);if(e&&t){var i=e[1]-this._bufferService.buffer.ydisp,n=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),s=Math.min(n,this._bufferService.rows-1);if(!(o>=this._bufferService.rows||s<0)){var a=document.createDocumentFragment();if(r)a.appendChild(this._createSelectionElement(o,e[0],t[0],s-o+1));else{var c=i===o?e[0]:0,l=o===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));var h=s-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==s){var u=n===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,0,u))}}this._selectionContainer.appendChild(a)}}},t.prototype._createSelectionElement=function(e,t,r,i){void 0===i&&(i=1);var n=document.createElement("div");return n.style.height=i*this.dimensions.actualCellHeight+"px",n.style.top=e*this.dimensions.actualCellHeight+"px",n.style.left=t*this.dimensions.actualCellWidth+"px",n.style.width=this.dimensions.actualCellWidth*(r-t)+"px",n},t.prototype.onCursorMove=function(){},t.prototype.onOptionsChanged=function(){this._updateDimensions(),this._injectCss()},t.prototype.clear=function(){this._rowElements.forEach(function(e){return e.innerHTML=""})},t.prototype.renderRows=function(e,t){for(var r=this._bufferService.buffer.ybase+this._bufferService.buffer.y,i=this._bufferService.buffer.x,n=this._optionsService.options.cursorBlink,o=e;o<=t;o++){var s=this._rowElements[o];s.innerHTML="";var a=o+this._bufferService.buffer.ydisp,c=this._bufferService.buffer.lines.get(a),l=this._optionsService.options.cursorStyle;s.appendChild(this._rowFactory.createRow(c,a===r,l,i,n,this.dimensions.actualCellWidth,this._bufferService.cols))}},Object.defineProperty(t.prototype,"_terminalSelector",{get:function(){return"."+d+this._terminalClass},enumerable:!0,configurable:!0}),t.prototype.registerCharacterJoiner=function(e){return-1},t.prototype.deregisterCharacterJoiner=function(e){return!1},t.prototype._onLinkHover=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)},t.prototype._onLinkLeave=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)},t.prototype._setCellUnderline=function(e,t,r,i,n,o){for(;e!==t||r!==i;){var s=this._rowElements[r];if(!s)return;var a=s.children[e];a&&(a.style.textDecoration=o?"underline":"none"),++e>=n&&(e=0,r++)}},t=o([s(5,h.ICharSizeService),s(6,u.IOptionsService),s(7,u.IBufferService)],t)}(l.Disposable);t.DomRenderer=y},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(9),n=r(3),o=r(5),s=r(10);t.BOLD_CLASS="xterm-bold",t.DIM_CLASS="xterm-dim",t.ITALIC_CLASS="xterm-italic",t.UNDERLINE_CLASS="xterm-underline",t.CURSOR_CLASS="xterm-cursor",t.CURSOR_BLINK_CLASS="xterm-cursor-blink",t.CURSOR_STYLE_BLOCK_CLASS="xterm-cursor-block",t.CURSOR_STYLE_BAR_CLASS="xterm-cursor-bar",t.CURSOR_STYLE_UNDERLINE_CLASS="xterm-cursor-underline";var a=function(){function e(e,t,r){this._document=e,this._optionsService=t,this._colors=r,this._workCell=new o.CellData}return e.prototype.setColors=function(e){this._colors=e},e.prototype.createRow=function(e,r,o,a,l,h,u){for(var f=this._document.createDocumentFragment(),_=0,d=Math.min(e.length,u)-1;d>=0;d--)if(e.loadCell(d,this._workCell).getCode()!==n.NULL_CELL_CODE||r&&d===a){_=d+1;break}for(d=0;d<_;d++){e.loadCell(d,this._workCell);var p=this._workCell.getWidth();if(0!==p){var v=this._document.createElement("span");if(p>1&&(v.style.width=h*p+"px"),r&&d===a)switch(v.classList.add(t.CURSOR_CLASS),l&&v.classList.add(t.CURSOR_BLINK_CLASS),o){case"bar":v.classList.add(t.CURSOR_STYLE_BAR_CLASS);break;case"underline":v.classList.add(t.CURSOR_STYLE_UNDERLINE_CLASS);break;default:v.classList.add(t.CURSOR_STYLE_BLOCK_CLASS)}this._workCell.isBold()&&v.classList.add(t.BOLD_CLASS),this._workCell.isItalic()&&v.classList.add(t.ITALIC_CLASS),this._workCell.isDim()&&v.classList.add(t.DIM_CLASS),this._workCell.isUnderline()&&v.classList.add(t.UNDERLINE_CLASS),v.textContent=this._workCell.getChars()||n.WHITESPACE_CELL_CHAR;var g=this._workCell.getFgColor(),y=this._workCell.getFgColorMode(),b=this._workCell.getBgColor(),m=this._workCell.getBgColorMode(),C=!!this._workCell.isInverse();if(C){var S=g;g=b,b=S;var w=y;y=m,m=w}switch(y){case 16777216:case 33554432:this._workCell.isBold()&&g<8&&this._optionsService.options.drawBoldTextInBrightColors&&(g+=8),this._applyMinimumContrast(v,this._colors.background,this._colors.ansi[g])||v.classList.add("xterm-fg-"+g);break;case 50331648:var E=s.rgbaToColor(g>>16&255,g>>8&255,255&g);this._applyMinimumContrast(v,this._colors.background,E)||this._addStyle(v,"color:#"+c(g.toString(16),"0",6));break;case 0:default:this._applyMinimumContrast(v,this._colors.background,this._colors.foreground)||C&&v.classList.add("xterm-fg-"+i.INVERTED_DEFAULT_COLOR)}switch(m){case 16777216:case 33554432:v.classList.add("xterm-bg-"+b);break;case 50331648:this._addStyle(v,"background-color:#"+c(b.toString(16),"0",6));break;case 0:default:C&&v.classList.add("xterm-bg-"+i.INVERTED_DEFAULT_COLOR)}f.appendChild(v)}}return f},e.prototype._applyMinimumContrast=function(e,t,r){if(1===this._optionsService.options.minimumContrastRatio)return!1;var i=this._colors.contrastCache.getColor(this._workCell.bg,this._workCell.fg);return void 0===i&&(i=s.ensureContrastRatio(t,r,this._optionsService.options.minimumContrastRatio),this._colors.contrastCache.setColor(this._workCell.bg,this._workCell.fg,null!=i?i:null)),!!i&&(this._addStyle(e,"color:"+i.css),!0)},e.prototype._addStyle=function(e,t){e.setAttribute("style",""+(e.getAttribute("style")||"")+t+";")},e}();function c(e,t,r){for(;e.length<r;)e=t+e;return e}t.DomRendererRowFactory=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(12),n={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};t.evaluateKeyboardEvent=function(e,t,r,o){var s={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?s.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A":"UIKeyInputLeftArrow"===e.key?s.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D":"UIKeyInputRightArrow"===e.key?s.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(s.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B");break;case 8:if(e.shiftKey){s.key=i.C0.BS;break}if(e.altKey){s.key=i.C0.ESC+i.C0.DEL;break}s.key=i.C0.DEL;break;case 9:if(e.shiftKey){s.key=i.C0.ESC+"[Z";break}s.key=i.C0.HT,s.cancel=!0;break;case 13:s.key=i.C0.CR,s.cancel=!0;break;case 27:s.key=i.C0.ESC,s.cancel=!0;break;case 37:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"D",s.key===i.C0.ESC+"[1;3D"&&(s.key=i.C0.ESC+(r?"b":"[1;5D"))):s.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D";break;case 39:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"C",s.key===i.C0.ESC+"[1;3C"&&(s.key=i.C0.ESC+(r?"f":"[1;5C"))):s.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C";break;case 38:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"A",r||s.key!==i.C0.ESC+"[1;3A"||(s.key=i.C0.ESC+"[1;5A")):s.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A";break;case 40:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"B",r||s.key!==i.C0.ESC+"[1;3B"||(s.key=i.C0.ESC+"[1;5B")):s.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(s.key=i.C0.ESC+"[2~");break;case 46:s.key=a?i.C0.ESC+"[3;"+(a+1)+"~":i.C0.ESC+"[3~";break;case 36:s.key=a?i.C0.ESC+"[1;"+(a+1)+"H":t?i.C0.ESC+"OH":i.C0.ESC+"[H";break;case 35:s.key=a?i.C0.ESC+"[1;"+(a+1)+"F":t?i.C0.ESC+"OF":i.C0.ESC+"[F";break;case 33:e.shiftKey?s.type=2:s.key=i.C0.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:s.key=i.C0.ESC+"[6~";break;case 112:s.key=a?i.C0.ESC+"[1;"+(a+1)+"P":i.C0.ESC+"OP";break;case 113:s.key=a?i.C0.ESC+"[1;"+(a+1)+"Q":i.C0.ESC+"OQ";break;case 114:s.key=a?i.C0.ESC+"[1;"+(a+1)+"R":i.C0.ESC+"OR";break;case 115:s.key=a?i.C0.ESC+"[1;"+(a+1)+"S":i.C0.ESC+"OS";break;case 116:s.key=a?i.C0.ESC+"[15;"+(a+1)+"~":i.C0.ESC+"[15~";break;case 117:s.key=a?i.C0.ESC+"[17;"+(a+1)+"~":i.C0.ESC+"[17~";break;case 118:s.key=a?i.C0.ESC+"[18;"+(a+1)+"~":i.C0.ESC+"[18~";break;case 119:s.key=a?i.C0.ESC+"[19;"+(a+1)+"~":i.C0.ESC+"[19~";break;case 120:s.key=a?i.C0.ESC+"[20;"+(a+1)+"~":i.C0.ESC+"[20~";break;case 121:s.key=a?i.C0.ESC+"[21;"+(a+1)+"~":i.C0.ESC+"[21~";break;case 122:s.key=a?i.C0.ESC+"[23;"+(a+1)+"~":i.C0.ESC+"[23~";break;case 123:s.key=a?i.C0.ESC+"[24;"+(a+1)+"~":i.C0.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(r&&!o||!e.altKey||e.metaKey)r&&!e.altKey&&!e.ctrlKey&&e.metaKey?65===e.keyCode&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?s.key=e.key:e.key&&e.ctrlKey&&"_"===e.key&&(s.key=i.C0.US);else{var c=n[e.keyCode],l=c&&c[e.shiftKey?1:0];if(l)s.key=i.C0.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){var h=e.ctrlKey?e.keyCode-64:e.keyCode+32;s.key=i.C0.ESC+String.fromCharCode(h)}}else e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?s.key=i.C0.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?s.key=i.C0.DEL:219===e.keyCode?s.key=i.C0.ESC:220===e.keyCode?s.key=i.C0.FS:221===e.keyCode&&(s.key=i.C0.GS)}return s}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3);t.handleWindowsModeLineFeed=function(e){var t,r=null===(t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))||void 0===t?void 0:t.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&r&&(n.isWrapped=r[i.CHAR_DATA_CODE_INDEX]!==i.NULL_CELL_CODE&&r[i.CHAR_DATA_CODE_INDEX]!==i.WHITESPACE_CELL_CODE)}},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(30),c=r(1),l=r(2),h=r(31),u=r(7),f=r(0),_=r(4),d=function(e){function t(t,r,i,n,o){var s=e.call(this)||this;if(s._renderer=t,s._rowCount=r,s.screenElement=i,s.optionsService=n,s.charSizeService=o,s._isPaused=!1,s._needsFullRefresh=!1,s._canvasWidth=0,s._canvasHeight=0,s._onDimensionsChange=new c.EventEmitter,s._onRender=new c.EventEmitter,s._onRefreshRequest=new c.EventEmitter,s._renderDebouncer=new a.RenderDebouncer(function(e,t){return s._renderRows(e,t)}),s.register(s._renderDebouncer),s._screenDprMonitor=new h.ScreenDprMonitor,s._screenDprMonitor.setListener(function(){return s.onDevicePixelRatioChange()}),s.register(s._screenDprMonitor),s.register(n.onOptionChange(function(){return s._renderer.onOptionsChanged()})),s.register(o.onCharSizeChange(function(){return s.onCharSizeChanged()})),s._renderer.onRequestRefreshRows(function(e){return s.refreshRows(e.start,e.end)}),s.register(u.addDisposableDomListener(window,"resize",function(){return s.onDevicePixelRatioChange()})),"IntersectionObserver"in window){var l=new IntersectionObserver(function(e){return s._onIntersectionChange(e[e.length-1])},{threshold:0});l.observe(i),s.register({dispose:function(){return l.disconnect()}})}return s}return n(t,e),Object.defineProperty(t.prototype,"onDimensionsChange",{get:function(){return this._onDimensionsChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRender",{get:function(){return this._onRender.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRefreshRequest",{get:function(){return this._onRefreshRequest.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dimensions",{get:function(){return this._renderer.dimensions},enumerable:!0,configurable:!0}),t.prototype._onIntersectionChange=function(e){this._isPaused=0===e.intersectionRatio,!this._isPaused&&this._needsFullRefresh&&(this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)},t.prototype.refreshRows=function(e,t){this._isPaused?this._needsFullRefresh=!0:this._renderDebouncer.refresh(e,t,this._rowCount)},t.prototype._renderRows=function(e,t){this._renderer.renderRows(e,t),this._onRender.fire({start:e,end:t})},t.prototype.resize=function(e,t){this._rowCount=t,this._fireOnCanvasResize()},t.prototype.changeOptions=function(){this._renderer.onOptionsChanged(),this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize()},t.prototype._fireOnCanvasResize=function(){this._renderer.dimensions.canvasWidth===this._canvasWidth&&this._renderer.dimensions.canvasHeight===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.dimensions)},t.prototype.dispose=function(){this._renderer.dispose(),e.prototype.dispose.call(this)},t.prototype.setRenderer=function(e){var t=this;this._renderer.dispose(),this._renderer=e,this._renderer.onRequestRefreshRows(function(e){return t.refreshRows(e.start,e.end)}),this.refreshRows(0,this._rowCount-1)},t.prototype._fullRefresh=function(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)},t.prototype.setColors=function(e){this._renderer.setColors(e),this._fullRefresh()},t.prototype.onDevicePixelRatioChange=function(){this._renderer.onDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1)},t.prototype.onResize=function(e,t){this._renderer.onResize(e,t),this._fullRefresh()},t.prototype.onCharSizeChanged=function(){this._renderer.onCharSizeChanged()},t.prototype.onBlur=function(){this._renderer.onBlur()},t.prototype.onFocus=function(){this._renderer.onFocus()},t.prototype.onSelectionChanged=function(e,t,r){this._renderer.onSelectionChanged(e,t,r)},t.prototype.onCursorMove=function(){this._renderer.onCursorMove()},t.prototype.clear=function(){this._renderer.clear()},t.prototype.registerCharacterJoiner=function(e){return this._renderer.registerCharacterJoiner(e)},t.prototype.deregisterCharacterJoiner=function(e){return this._renderer.deregisterCharacterJoiner(e)},t=o([s(3,f.IOptionsService),s(4,_.ICharSizeService)],t)}(l.Disposable);t.RenderService=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),n=r(11),o=r(32);t.DEFAULT_BELL_SOUND="data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",t.DEFAULT_OPTIONS=Object.freeze({cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",bellSound:t.DEFAULT_BELL_SOUND,bellStyle:"none",drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",lineHeight:1,letterSpacing:0,logLevel:"info",scrollback:1e3,scrollSensitivity:1,screenReaderMode:!1,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:n.isMac,rendererType:"canvas",windowsMode:!1,convertEol:!1,termName:"xterm",screenKeys:!1,cancelEvents:!1,useFlowControl:!1,wordSeparator:" ()[]{}',:;\"`"});var s=["cols","rows"],a=function(){function e(e){var r=this;this._onOptionChange=new i.EventEmitter,this.options=o.clone(t.DEFAULT_OPTIONS),Object.keys(e).forEach(function(t){if(t in r.options){var i=e[t];r.options[t]=i}})}return Object.defineProperty(e.prototype,"onOptionChange",{get:function(){return this._onOptionChange.event},enumerable:!0,configurable:!0}),e.prototype.setOption=function(e,r){if(!(e in t.DEFAULT_OPTIONS))throw new Error('No option with key "'+e+'"');if(-1!==s.indexOf(e))throw new Error('Option "'+e+'" can only be set in the constructor');this.options[e]!==r&&(r=this._sanitizeAndValidateOption(e,r),this.options[e]!==r&&(this.options[e]=r,this._onOptionChange.fire(e)))},e.prototype._sanitizeAndValidateOption=function(e,r){switch(e){case"bellStyle":case"cursorStyle":case"fontWeight":case"fontWeightBold":case"rendererType":case"wordSeparator":r||(r=t.DEFAULT_OPTIONS[e]);break;case"lineHeight":case"tabStopWidth":if(r<1)throw new Error(e+" cannot be less than 1, value: "+r);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));case"scrollback":if((r=Math.min(r,4294967295))<0)throw new Error(e+" cannot be less than 0, value: "+r);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw new Error(e+" cannot be less than or equal to 0, value: "+r)}return r},e.prototype.getOption=function(e){if(!(e in t.DEFAULT_OPTIONS))throw new Error('No option with key "'+e+'"');return this.options[e]},e}();t.OptionsService=a},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=r(1),a=function(){function e(e,t,r){this.document=e,this.parentElement=t,this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=new s.EventEmitter,this._measureStrategy=new c(e,t,this._optionsService)}return Object.defineProperty(e.prototype,"hasValidSize",{get:function(){return this.width>0&&this.height>0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCharSizeChange",{get:function(){return this._onCharSizeChange.event},enumerable:!0,configurable:!0}),e.prototype.measure=function(){var e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())},e=i([n(2,o.IOptionsService)],e)}();t.CharSizeService=a;var c=function(){function e(e,t,r){this._document=e,this._parentElement=t,this._optionsService=r,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W",this._measureElement.setAttribute("aria-hidden","true"),this._parentElement.appendChild(this._measureElement)}return e.prototype.measure=function(){this._measureElement.style.fontFamily=this._optionsService.options.fontFamily,this._measureElement.style.fontSize=this._optionsService.options.fontSize+"px";var e=this._measureElement.getBoundingClientRect();return 0!==e.width&&0!==e.height&&(this._result.width=e.width,this._result.height=Math.ceil(e.height)),this._result},e}()},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=r(65);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;var a=function(){function e(e){this._optionsService=e,this.cols=Math.max(e.options.cols,t.MINIMUM_COLS),this.rows=Math.max(e.options.rows,t.MINIMUM_ROWS),this.buffers=new s.BufferSet(e,this)}return Object.defineProperty(e.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!0,configurable:!0}),e.prototype.resize=function(e,t){this.cols=e,this.rows=t},e.prototype.reset=function(){this.buffers=new s.BufferSet(this._optionsService,this)},e=i([n(0,o.IOptionsService)],e)}();t.BufferService=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(66),n=r(1),o=function(){function e(e,t){this.optionsService=e,this.bufferService=t,this._onBufferActivate=new n.EventEmitter,this._normal=new i.Buffer(!0,e,t),this._normal.fillViewportRows(),this._alt=new i.Buffer(!1,e,t),this._activeBuffer=this._normal,this.setupTabStops()}return Object.defineProperty(e.prototype,"onBufferActivate",{get:function(){return this._onBufferActivate.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alt",{get:function(){return this._alt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal},enumerable:!0,configurable:!0}),e.prototype.activateNormalBuffer=function(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))},e.prototype.activateAltBuffer=function(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))},e.prototype.resize=function(e,t){this._normal.resize(e,t),this._alt.resize(e,t)},e.prototype.setupTabStops=function(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)},e}();t.BufferSet=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(67),n=r(16),o=r(5),s=r(3),a=r(68),c=r(69),l=r(18);t.MAX_BUFFER_SIZE=4294967295;var h=function(){function e(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.savedY=0,this.savedX=0,this.savedCurAttrData=n.DEFAULT_ATTR_DATA.clone(),this.savedCharset=l.DEFAULT_CHARSET,this.markers=[],this._nullCell=o.CellData.fromCharData([0,s.NULL_CELL_CHAR,s.NULL_CELL_WIDTH,s.NULL_CELL_CODE]),this._whitespaceCell=o.CellData.fromCharData([0,s.WHITESPACE_CELL_CHAR,s.WHITESPACE_CELL_WIDTH,s.WHITESPACE_CELL_CODE]),this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}return e.prototype.getNullCell=function(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg):(this._nullCell.fg=0,this._nullCell.bg=0),this._nullCell},e.prototype.getWhitespaceCell=function(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0),this._whitespaceCell},e.prototype.getBlankLine=function(e,t){return new n.BufferLine(this._bufferService.cols,this.getNullCell(e),t)},Object.defineProperty(e.prototype,"hasScrollback",{get:function(){return this._hasScrollback&&this.lines.maxLength>this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCursorInViewport",{get:function(){var e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows},enumerable:!0,configurable:!0}),e.prototype._getCorrectBufferLength=function(e){if(!this._hasScrollback)return e;var r=e+this._optionsService.options.scrollback;return r>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:r},e.prototype.fillViewportRows=function(e){if(0===this.lines.length){void 0===e&&(e=n.DEFAULT_ATTR_DATA);for(var t=this._rows;t--;)this.lines.push(this.getBlankLine(e))}},e.prototype.clear=function(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()},e.prototype.resize=function(e,t){var r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(var o=0;o<this.lines.length;o++)this.lines.get(o).resize(e,r);var s=0;if(this._rows<t)for(var a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.options.windowsMode?this.lines.push(new n.BufferLine(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new n.BufferLine(e,r)));else for(a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){var c=this.lines.length-i;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(o=0;o<this.lines.length;o++)this.lines.get(o).resize(e,r);this._cols=e,this._rows=t},Object.defineProperty(e.prototype,"_isReflowEnabled",{get:function(){return this._hasScrollback&&!this._optionsService.options.windowsMode},enumerable:!0,configurable:!0}),e.prototype._reflow=function(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))},e.prototype._reflowLarger=function(e,t){var r=a.reflowLargerGetLinesToRemove(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(n.DEFAULT_ATTR_DATA));if(r.length>0){var i=a.reflowLargerCreateNewLayout(this.lines,r);a.reflowLargerApplyNewLayout(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}},e.prototype._reflowLargerAdjustViewport=function(e,t,r){for(var i=this.getNullCell(n.DEFAULT_ATTR_DATA),o=r;o-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new n.BufferLine(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)},e.prototype._reflowSmaller=function(e,t){for(var r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=[],o=0,s=this.lines.length-1;s>=0;s--){var c=this.lines.get(s);if(!(!c||!c.isWrapped&&c.getTrimmedLength()<=e)){for(var l=[c];c.isWrapped&&s>0;)c=this.lines.get(--s),l.unshift(c);var h=this.ybase+this.y;if(!(h>=s&&h<s+l.length)){var u=l[l.length-1].getTrimmedLength(),f=a.reflowSmallerGetNewLineLengths(l,this._cols,e),_=f.length-l.length,d=void 0;d=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+_):Math.max(0,this.lines.length-this.lines.maxLength+_);for(var p=[],v=0;v<_;v++){var g=this.getBlankLine(n.DEFAULT_ATTR_DATA,!0);p.push(g)}p.length>0&&(i.push({start:s+l.length+o,newLines:p}),o+=p.length),l.push.apply(l,p);var y=f.length-1,b=f[y];0===b&&(b=f[--y]);for(var m=l.length-_-1,C=u;m>=0;){var S=Math.min(C,b);if(l[y].copyCellsFrom(l[m],C-S,b-S,S,!0),0===(b-=S)&&(b=f[--y]),0===(C-=S)){m--;var w=Math.max(m,0);C=a.getWrappedLineTrimmedLength(l,w,this._cols)}}for(v=0;v<l.length;v++)f[v]<e&&l[v].setCell(f[v],r);for(var E=_-d;E-- >0;)0===this.ybase?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+t-1)}}}if(i.length>0){var L=[],A=[];for(v=0;v<this.lines.length;v++)A.push(this.lines.get(v));var R=this.lines.length,x=R-1,k=0,D=i[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);var T=0;for(v=Math.min(this.lines.maxLength-1,R+o-1);v>=0;v--)if(D&&D.start>x+T){for(var M=D.newLines.length-1;M>=0;M--)this.lines.set(v--,D.newLines[M]);v++,L.push({index:x+1,amount:D.newLines.length}),T+=D.newLines.length,D=i[++k]}else this.lines.set(v,A[x--]);var O=0;for(v=L.length-1;v>=0;v--)L[v].index+=O,this.lines.onInsertEmitter.fire(L[v]),O+=L[v].amount;var P=Math.max(0,R+o-this.lines.maxLength);P>0&&this.lines.onTrimEmitter.fire(P)}},e.prototype.stringIndexToBufferIndex=function(e,t,r){for(void 0===r&&(r=!1);t;){var i=this.lines.get(e);if(!i)return[-1,-1];for(var n=r?i.getTrimmedLength():i.length,o=0;o<n;++o)if(i.get(o)[s.CHAR_DATA_WIDTH_INDEX]&&(t-=i.get(o)[s.CHAR_DATA_CHAR_INDEX].length||1),t<0)return[e,o];e++}return[e,0]},e.prototype.translateBufferLineToString=function(e,t,r,i){void 0===r&&(r=0);var n=this.lines.get(e);return n?n.translateToString(t,r,i):""},e.prototype.getWrappedRangeForLine=function(e){for(var t=e,r=e;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}},e.prototype.setupTabStops=function(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.options.tabStopWidth)this.tabs[e]=!0},e.prototype.prevStop=function(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.nextStop=function(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.addMarker=function(e){var t=this,r=new c.Marker(e);return this.markers.push(r),r.register(this.lines.onTrim(function(e){r.line-=e,r.line<0&&r.dispose()})),r.register(this.lines.onInsert(function(e){r.line>=e.index&&(r.line+=e.amount)})),r.register(this.lines.onDelete(function(e){r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)})),r.register(r.onDispose(function(){return t._removeMarker(r)})),r},e.prototype._removeMarker=function(e){this.markers.splice(this.markers.indexOf(e),1)},e.prototype.iterator=function(e,t,r,i,n){return new u(this,e,t,r,i,n)},e}();t.Buffer=h;var u=function(){function e(e,t,r,i,n,o){void 0===r&&(r=0),void 0===i&&(i=e.lines.length),void 0===n&&(n=0),void 0===o&&(o=0),this._buffer=e,this._trimRight=t,this._startIndex=r,this._endIndex=i,this._startOverscan=n,this._endOverscan=o,this._startIndex<0&&(this._startIndex=0),this._endIndex>this._buffer.lines.length&&(this._endIndex=this._buffer.lines.length),this._current=this._startIndex}return e.prototype.hasNext=function(){return this._current<this._endIndex},e.prototype.next=function(){var e=this._buffer.getWrappedRangeForLine(this._current);e.first<this._startIndex-this._startOverscan&&(e.first=this._startIndex-this._startOverscan),e.last>this._endIndex+this._endOverscan&&(e.last=this._endIndex+this._endOverscan),e.first=Math.max(e.first,0),e.last=Math.min(e.last,this._buffer.lines.length);for(var t="",r=e.first;r<=e.last;++r)t+=this._buffer.translateBufferLineToString(r,this._trimRight);return this._current=e.last+1,{range:e,content:t}},e}();t.BufferStringIterator=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(1),n=function(){function e(e){this._maxLength=e,this.onDeleteEmitter=new i.EventEmitter,this.onInsertEmitter=new i.EventEmitter,this.onTrimEmitter=new i.EventEmitter,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}return Object.defineProperty(e.prototype,"onDelete",{get:function(){return this.onDeleteEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onInsert",{get:function(){return this.onInsertEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTrim",{get:function(){return this.onTrimEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxLength",{get:function(){return this._maxLength},set:function(e){if(this._maxLength!==e){for(var t=new Array(e),r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];this._array=t,this._maxLength=e,this._startIndex=0}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._length},set:function(e){if(e>this._length)for(var t=this._length;t<e;t++)this._array[t]=void 0;this._length=e},enumerable:!0,configurable:!0}),e.prototype.get=function(e){return this._array[this._getCyclicIndex(e)]},e.prototype.set=function(e,t){this._array[this._getCyclicIndex(e)]=t},e.prototype.push=function(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++},e.prototype.recycle=function(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]},Object.defineProperty(e.prototype,"isFull",{get:function(){return this._length===this._maxLength},enumerable:!0,configurable:!0}),e.prototype.pop=function(){return this._array[this._getCyclicIndex(this._length---1)]},e.prototype.splice=function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t){for(var n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t}for(n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(this._length+r.length>this._maxLength){var o=this._length+r.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=r.length},e.prototype.trimStart=function(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)},e.prototype.shiftElements=function(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(var i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));var n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(i=0;i<t;i++)this.set(e+i+r,this.get(e+i))}},e.prototype._getCyclicIndex=function(e){return(this._startIndex+e)%this._maxLength},e}();t.CircularList=n},function(e,t,r){"use strict";function i(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();var i=!e[t].hasContent(r-1)&&1===e[t].getWidth(r-1),n=2===e[t+1].getWidth(0);return i&&n?r-1:r}Object.defineProperty(t,"__esModule",{value:!0}),t.reflowLargerGetLinesToRemove=function(e,t,r,n,o){for(var s=[],a=0;a<e.length-1;a++){var c=a,l=e.get(++c);if(l.isWrapped){for(var h=[e.get(a)];c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(n>=a&&n<c)a+=h.length-1;else{for(var u=0,f=i(h,u,t),_=1,d=0;_<h.length;){var p=i(h,_,t),v=p-d,g=r-f,y=Math.min(v,g);h[u].copyCellsFrom(h[_],d,f,y,!1),(f+=y)===r&&(u++,f=0),(d+=y)===p&&(_++,d=0),0===f&&0!==u&&2===h[u-1].getWidth(r-1)&&(h[u].copyCellsFrom(h[u-1],r-1,f++,1,!1),h[u-1].setCell(r-1,o))}h[u].replaceCells(f,r,o);for(var b=0,m=h.length-1;m>0&&(m>u||0===h[m].getTrimmedLength());m--)b++;b>0&&(s.push(a+h.length-b),s.push(b)),a+=h.length-1}}}return s},t.reflowLargerCreateNewLayout=function(e,t){for(var r=[],i=0,n=t[i],o=0,s=0;s<e.length;s++)if(n===s){var a=t[++i];e.onDeleteEmitter.fire({index:s-o,amount:a}),s+=a-1,o+=a,n=t[++i]}else r.push(s);return{layout:r,countRemoved:o}},t.reflowLargerApplyNewLayout=function(e,t){for(var r=[],i=0;i<t.length;i++)r.push(e.get(t[i]));for(i=0;i<r.length;i++)e.set(i,r[i]);e.length=t.length},t.reflowSmallerGetNewLineLengths=function(e,t,r){for(var n=[],o=e.map(function(r,n){return i(e,n,t)}).reduce(function(e,t){return e+t}),s=0,a=0,c=0;c<o;){if(o-c<r){n.push(o-c);break}s+=r;var l=i(e,a,t);s>l&&(s-=l,a++);var h=2===e[a].getWidth(s-1);h&&s--;var u=h?r-1:r;n.push(u),c+=u}return n},t.getWrappedLineTrimmedLength=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=function(e){function t(r){var i=e.call(this)||this;return i.line=r,i._id=t._nextId++,i.isDisposed=!1,i._onDispose=new o.EventEmitter,i}return n(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{get:function(){return this._onDispose.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire())},t._nextId=1,t}(r(2).Disposable);t.Marker=s},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=r(29),a=function(){function e(e,t){this._renderService=e,this._charSizeService=t}return e.prototype.getCoords=function(e,t,r,i,n){return s.getCoords(e,t,r,i,this._charSizeService.hasValidSize,this._renderService.dimensions.actualCellWidth,this._renderService.dimensions.actualCellHeight,n)},e.prototype.getRawByteCoords=function(e,t,r,i){var n=this.getCoords(e,t,r,i);return s.getRawByteCoords(n)},e=i([n(0,o.IRenderService),n(1,o.ICharSizeService)],e)}();t.MouseService=a},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=r(1),a=r(32),c=Object.freeze({applicationCursorKeys:!1}),l=function(){function e(e,t,r,i){this._scrollToBottom=e,this._bufferService=t,this._logService=r,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=new s.EventEmitter,this._onUserInput=new s.EventEmitter,this._onBinary=new s.EventEmitter,this.decPrivateModes=a.clone(c)}return Object.defineProperty(e.prototype,"onData",{get:function(){return this._onData.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onUserInput",{get:function(){return this._onUserInput.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.decPrivateModes=a.clone(c)},e.prototype.triggerDataEvent=function(e,t){if(void 0===t&&(t=!1),!this._optionsService.options.disableStdin){var r=this._bufferService.buffer;r.ybase!==r.ydisp&&this._scrollToBottom(),t&&this._onUserInput.fire(),this._logService.debug('sending data "'+e+'"',function(){return e.split("").map(function(e){return e.charCodeAt(0)})}),this._onData.fire(e)}},e.prototype.triggerBinaryEvent=function(e){this._optionsService.options.disableStdin||(this._logService.debug('sending binary "'+e+'"',function(){return e.split("").map(function(e){return e.charCodeAt(0)})}),this._onBinary.fire(e))},e=i([n(1,o.IBufferService),n(2,o.ILogService),n(3,o.IOptionsService)],e)}();t.CoreService=l},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=Array(e),n=0;for(t=0;t<r;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,n++)i[n]=o[s];return i};Object.defineProperty(t,"__esModule",{value:!0});var s,a=r(0);!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.OFF=4]="OFF"}(s=t.LogLevel||(t.LogLevel={}));var c={debug:s.DEBUG,info:s.INFO,warn:s.WARN,error:s.ERROR,off:s.OFF},l=function(){function e(e){var t=this;this._optionsService=e,this._updateLogLevel(),this._optionsService.onOptionChange(function(e){"logLevel"===e&&t._updateLogLevel()})}return e.prototype._updateLogLevel=function(){this._logLevel=c[this._optionsService.options.logLevel]},e.prototype._evalLazyOptionalParams=function(e){for(var t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())},e.prototype._log=function(e,t,r){this._evalLazyOptionalParams(r),e.call.apply(e,o([console,"xterm.js: "+t],r))},e.prototype.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.DEBUG&&this._log(console.log,e,t)},e.prototype.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.INFO&&this._log(console.info,e,t)},e.prototype.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.WARN&&this._log(console.warn,e,t)},e.prototype.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.ERROR&&this._log(console.error,e,t)},e=i([n(0,a.IOptionsService)],e)}();t.LogService=l},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=function(){function e(e){this._bufferService=e,this.clearRange()}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),e.prototype.clearRange=function(){this._start=this._bufferService.buffer.y,this._end=this._bufferService.buffer.y},e.prototype.markDirty=function(e){e<this._start?this._start=e:e>this._end&&(this._end=e)},e.prototype.markRangeDirty=function(e,t){if(e>t){var r=e;e=t,t=r}e<this._start&&(this._start=e),t>this._end&&(this._end=t)},e.prototype.markAllDirty=function(){this.markRangeDirty(0,this._bufferService.rows-1)},e=i([n(0,o.IBufferService)],e)}();t.DirtyRowService=s},function(e,t,r){"use strict";var i=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=Array(e),n=0;for(t=0;t<r;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,n++)i[n]=o[s];return i};Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(14),s=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._entries=new Map;for(var r=0,i=e;r<i.length;r++){var n=i[r],o=n[0],s=n[1];this.set(o,s)}}return e.prototype.set=function(e,t){var r=this._entries.get(e);return this._entries.set(e,t),r},e.prototype.forEach=function(e){this._entries.forEach(function(t,r){return e(r,t)})},e.prototype.has=function(e){return this._entries.has(e)},e.prototype.get=function(e){return this._entries.get(e)},e}();t.ServiceCollection=s;var a=function(){function e(){this._services=new s,this._services.set(n.IInstantiationService,this)}return e.prototype.setService=function(e,t){this._services.set(e,t)},e.prototype.createInstance=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=o.getServiceDependencies(e).sort(function(e,t){return e.index-t.index}),s=[],a=0,c=n;a<c.length;a++){var l=c[a],h=this._services.get(l.id);if(!h)throw new Error("[createInstance] "+e.name+" depends on UNKNOWN service "+l.id+".");s.push(h)}var u=n.length>0?n[0].index:t.length;if(t.length!==u)throw new Error("[createInstance] First service dependency of "+e.name+" at position "+(u+1)+" conflicts with "+t.length+" static arguments");return new(e.bind.apply(e,i([void 0],i(t,s))))},e}();t.InstantiationService=a},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=r(1),a={NONE:{events:0,restrict:function(){return!1}},X10:{events:1,restrict:function(e){return 4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)}},VT200:{events:19,restrict:function(e){return 32!==e.action}},DRAG:{events:23,restrict:function(e){return 32!==e.action||3!==e.button}},ANY:{events:31,restrict:function(e){return!0}}};function c(e,t){var r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(r|=64,r|=e.action):(r|=3&e.button,4&e.button&&(r|=64),8&e.button&&(r|=128),32===e.action?r|=32:0!==e.action||t||(r|=3)),r}var l=String.fromCharCode,h={DEFAULT:function(e){var t=[c(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":""+l(t[0])+l(t[1])+l(t[2])},SGR:function(e){var t=0===e.action&&4!==e.button?"m":"M";return"[<"+c(e,!0)+";"+e.col+";"+e.row+t}},u=function(){function e(e,t){var r=this;this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._onProtocolChange=new s.EventEmitter,this._lastEvent=null,Object.keys(a).forEach(function(e){return r.addProtocol(e,a[e])}),Object.keys(h).forEach(function(e){return r.addEncoding(e,h[e])}),this.reset()}return e.prototype.addProtocol=function(e,t){this._protocols[e]=t},e.prototype.addEncoding=function(e,t){this._encodings[e]=t},Object.defineProperty(e.prototype,"activeProtocol",{get:function(){return this._activeProtocol},set:function(e){if(!this._protocols[e])throw new Error('unknown protocol "'+e+'"');this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeEncoding",{get:function(){return this._activeEncoding},set:function(e){if(!this._encodings[e])throw new Error('unknown encoding "'+e+'"');this._activeEncoding=e},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null},Object.defineProperty(e.prototype,"onProtocolChange",{get:function(){return this._onProtocolChange.event},enumerable:!0,configurable:!0}),e.prototype.triggerMouseEvent=function(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows)return!1;if(4===e.button&&32===e.action)return!1;if(3===e.button&&32!==e.action)return!1;if(4!==e.button&&(2===e.action||3===e.action))return!1;if(e.col++,e.row++,32===e.action&&this._lastEvent&&this._compareEvents(this._lastEvent,e))return!1;if(!this._protocols[this._activeProtocol].restrict(e))return!1;var t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0},e.prototype.explainEvents=function(e){return{DOWN:!!(1&e),UP:!!(2&e),DRAG:!!(4&e),MOVE:!!(8&e),WHEEL:!!(16&e)}},e.prototype._compareEvents=function(e,t){return e.col===t.col&&(e.row===t.row&&(e.button===t.button&&(e.action===t.action&&(e.ctrl===t.ctrl&&(e.alt===t.alt&&e.shift===t.shift)))))},e=i([n(0,o.IBufferService),n(1,o.ICoreService)],e)}();t.CoreMouseService=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0}return e.prototype.writeSync=function(e){if(this._writeBuffer.length){for(var t=this._bufferOffset;t<this._writeBuffer.length;++t){var r=this._writeBuffer[t],i=this._callbacks[t];this._action(r),i&&i()}this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=2147483647}this._action(e)},e.prototype.write=function(e,t){var r=this;if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");this._writeBuffer.length||(this._bufferOffset=0,setTimeout(function(){return r._innerWrite()})),this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)},e.prototype._innerWrite=function(){for(var e=this,t=Date.now();this._writeBuffer.length>this._bufferOffset;){var r=this._writeBuffer[this._bufferOffset],i=this._callbacks[this._bufferOffset];if(this._bufferOffset++,this._action(r),this._pendingData-=r.length,i&&i(),Date.now()-t>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(function(){return e._innerWrite()},0)):(this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0)},e}();t.WriteBuffer=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._textarea=e}return Object.defineProperty(e.prototype,"isFocused",{get:function(){return document.activeElement===this._textarea&&document.hasFocus()},enumerable:!0,configurable:!0}),e}();t.CoreBrowserService=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._addons=[]}return e.prototype.dispose=function(){for(var e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()},e.prototype.loadAddon=function(e,t){var r=this,i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=function(){return r._wrappedAddonDispose(i)},t.activate(e)},e.prototype._wrappedAddonDispose=function(e){if(!e.isDisposed){for(var t=-1,r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;break}if(-1===t)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},e}();t.AddonManager=i}])});
+//# sourceMappingURL=xterm.js.map
\ No newline at end of file
diff --git a/src/www/xterm.js.map b/src/www/xterm.js.map
index cf96ecb..4733a0b 100644
--- a/src/www/xterm.js.map
+++ b/src/www/xterm.js.map
@@ -1 +1 @@
-{"version":3,"file":"xterm.js","sources":["../src/xterm.ts","../src/ui/ScreenDprMonitor.ts","../src/ui/RenderDebouncer.ts","../src/ui/Lifecycle.ts","../src/renderer/dom/DomRendererRowFactory.ts","../src/renderer/dom/DomRenderer.ts","../src/renderer/atlas/Types.ts","../src/renderer/atlas/StaticCharAtlas.ts","../src/renderer/atlas/NoneCharAtlas.ts","../src/renderer/atlas/LRUMap.ts","../src/renderer/atlas/DynamicCharAtlas.ts","../src/renderer/atlas/CharAtlasUtils.ts","../src/renderer/atlas/CharAtlasGenerator.ts","../src/renderer/atlas/CharAtlasCache.ts","../src/renderer/atlas/BaseCharAtlas.ts","../src/renderer/TextRenderLayer.ts","../src/renderer/SelectionRenderLayer.ts","../src/renderer/Renderer.ts","../src/renderer/LinkRenderLayer.ts","../src/renderer/GridCache.ts","../src/renderer/CursorRenderLayer.ts","../src/renderer/ColorManager.ts","../src/renderer/CharacterJoinerRegistry.ts","../src/renderer/BaseRenderLayer.ts","../src/public/Terminal.ts","../src/handlers/AltClickHandler.ts","../src/core/input/TextDecoder.ts","../src/core/input/Keyboard.ts","../src/core/data/Charsets.ts","../src/common/data/EscapeSequences.ts","../src/common/TypedArrayUtils.ts","../src/common/Platform.ts","../src/common/Lifecycle.ts","../src/common/EventEmitter2.ts","../src/common/EventEmitter.ts","../src/common/Clone.ts","../src/common/CircularList.ts","../src/WindowsMode.ts","../src/Viewport.ts","../src/Terminal.ts","../src/Strings.ts","../src/SoundManager.ts","../src/SelectionModel.ts","../src/SelectionManager.ts","../src/MouseZoneManager.ts","../src/MouseHelper.ts","../src/Linkifier.ts","../src/InputHandler.ts","../src/EscapeSequenceParser.ts","../src/CompositionHelper.ts","../src/Clipboard.ts","../src/CharWidth.ts","../src/CharMeasure.ts","../src/BufferSet.ts","../src/BufferReflow.ts","../src/BufferLine.ts","../src/Buffer.ts","../src/AccessibilityManager.ts","../node_modules/browser-pack/_prelude.js"],"sourcesContent":["/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * This file is the entry point for browserify.\n */\n\nimport { Terminal } from './public/Terminal';\n\nmodule.exports = Terminal;\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Disposable } from '../common/Lifecycle';\n\nexport type ScreenDprListener = (newDevicePixelRatio?: number, oldDevicePixelRatio?: number) => void;\n\n/**\n * The screen device pixel ratio monitor allows listening for when the\n * window.devicePixelRatio value changes. This is done not with polling but with\n * the use of window.matchMedia to watch media queries. When the event fires,\n * the listener will be reattached using a different media query to ensure that\n * any further changes will register.\n *\n * The listener should fire on both window zoom changes and switching to a\n * monitor with a different DPI.\n */\nexport class ScreenDprMonitor extends Disposable {\n  private _currentDevicePixelRatio: number = window.devicePixelRatio;\n  private _outerListener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | undefined;\n  private _listener: ScreenDprListener | undefined;\n  private _resolutionMediaMatchList: MediaQueryList | undefined;\n\n  public setListener(listener: ScreenDprListener): void {\n    if (this._listener) {\n      this.clearListener();\n    }\n    this._listener = listener;\n    this._outerListener = () => {\n      if (!this._listener) {\n        return;\n      }\n      this._listener(window.devicePixelRatio, this._currentDevicePixelRatio);\n      this._updateDpr();\n    };\n    this._updateDpr();\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this.clearListener();\n  }\n\n  private _updateDpr(): void {\n    if (!this._resolutionMediaMatchList || !this._outerListener) {\n      return;\n    }\n\n    // Clear listeners for old DPR\n    this._resolutionMediaMatchList.removeListener(this._outerListener);\n\n    // Add listeners for new DPR\n    this._currentDevicePixelRatio = window.devicePixelRatio;\n    this._resolutionMediaMatchList = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);\n    this._resolutionMediaMatchList.addListener(this._outerListener);\n  }\n\n  public clearListener(): void {\n    if (!this._resolutionMediaMatchList || !this._listener || !this._outerListener) {\n      return;\n    }\n    this._resolutionMediaMatchList.removeListener(this._outerListener);\n    this._resolutionMediaMatchList = undefined;\n    this._listener = undefined;\n    this._outerListener = undefined;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from '../common/Types';\n\n/**\n * Debounces calls to render terminal rows using animation frames.\n */\nexport class RenderDebouncer implements IDisposable {\n  private _rowStart: number | undefined;\n  private _rowEnd: number | undefined;\n  private _rowCount: number | undefined;\n  private _animationFrame: number | undefined;\n\n  constructor(\n    private _renderCallback: (start: number, end: number) => void\n  ) {\n  }\n\n  public dispose(): void {\n    if (this._animationFrame) {\n      window.cancelAnimationFrame(this._animationFrame);\n      this._animationFrame = undefined;\n    }\n  }\n\n  public refresh(rowStart: number, rowEnd: number, rowCount: number): void {\n    this._rowCount = rowCount;\n    // Get the min/max row start/end for the arg values\n    rowStart = rowStart !== undefined ? rowStart : 0;\n    rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;\n    // Set the properties to the updated values\n    this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;\n    this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;\n\n    if (this._animationFrame) {\n      return;\n    }\n\n    this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh());\n  }\n\n  private _innerRefresh(): void {\n    // Make sure values are set\n    if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) {\n      return;\n    }\n\n    // Clamp values\n    this._rowStart = Math.max(this._rowStart, 0);\n    this._rowEnd = Math.min(this._rowEnd, this._rowCount - 1);\n\n    // Run render callback\n    this._renderCallback(this._rowStart, this._rowEnd);\n\n    // Reset debouncer\n    this._rowStart = undefined;\n    this._rowEnd = undefined;\n    this._animationFrame = undefined;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from '../common/Types';\n\n/**\n * Adds a disposable listener to a node in the DOM, returning the disposable.\n * @param type The event type.\n * @param handler The handler for the listener.\n */\nexport function addDisposableDomListener(\n  node: Element | Window | Document,\n  type: string,\n  handler: (e: any) => void,\n  useCapture?: boolean\n): IDisposable {\n  node.addEventListener(type, handler, useCapture);\n  return {\n    dispose: () => {\n      if (!handler) {\n        // Already disposed\n        return;\n      }\n      node.removeEventListener(type, handler, useCapture);\n    }\n  };\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport {  NULL_CELL_CODE, WHITESPACE_CELL_CHAR } from '../../Buffer';\nimport { IBufferLine, ITerminalOptions } from '../../Types';\nimport { INVERTED_DEFAULT_COLOR } from '../atlas/Types';\nimport { CellData, AttributeData } from '../../BufferLine';\n\nexport const BOLD_CLASS = 'xterm-bold';\nexport const DIM_CLASS = 'xterm-dim';\nexport const ITALIC_CLASS = 'xterm-italic';\nexport const UNDERLINE_CLASS = 'xterm-underline';\nexport const CURSOR_CLASS = 'xterm-cursor';\nexport const CURSOR_BLINK_CLASS = 'xterm-cursor-blink';\nexport const CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block';\nexport const CURSOR_STYLE_BAR_CLASS = 'xterm-cursor-bar';\nexport const CURSOR_STYLE_UNDERLINE_CLASS = 'xterm-cursor-underline';\n\nexport class DomRendererRowFactory {\n  private _workCell: CellData = new CellData();\n\n  constructor(\n    private _terminalOptions: ITerminalOptions,\n    private _document: Document\n  ) {\n  }\n\n  public createRow(lineData: IBufferLine, isCursorRow: boolean, cursorStyle: string | undefined, cursorX: number, cursorBlink: boolean, cellWidth: number, cols: number): DocumentFragment {\n    const fragment = this._document.createDocumentFragment();\n\n    // Find the line length first, this prevents the need to output a bunch of\n    // empty cells at the end. This cannot easily be integrated into the main\n    // loop below because of the colCount feature (which can be removed after we\n    // properly support reflow and disallow data to go beyond the right-side of\n    // the viewport).\n    let lineLength = 0;\n    for (let x = Math.min(lineData.length, cols) - 1; x >= 0; x--) {\n      if (lineData.loadCell(x, this._workCell).getCode() !== NULL_CELL_CODE || (isCursorRow && x === cursorX)) {\n        lineLength = x + 1;\n        break;\n      }\n    }\n\n    for (let x = 0; x < lineLength; x++) {\n      lineData.loadCell(x, this._workCell);\n      const width = this._workCell.getWidth();\n\n      // The character to the left is a wide character, drawing is owned by the char at x-1\n      if (width === 0) {\n        continue;\n      }\n\n      const charElement = this._document.createElement('span');\n      if (width > 1) {\n        charElement.style.width = `${cellWidth * width}px`;\n      }\n\n      if (isCursorRow && x === cursorX) {\n        charElement.classList.add(CURSOR_CLASS);\n\n        if (cursorBlink) {\n          charElement.classList.add(CURSOR_BLINK_CLASS);\n        }\n\n        switch (cursorStyle) {\n          case 'bar':\n            charElement.classList.add(CURSOR_STYLE_BAR_CLASS);\n            break;\n          case 'underline':\n            charElement.classList.add(CURSOR_STYLE_UNDERLINE_CLASS);\n            break;\n          default:\n            charElement.classList.add(CURSOR_STYLE_BLOCK_CLASS);\n            break;\n        }\n      }\n\n      if (this._workCell.isBold() && this._terminalOptions.enableBold) {\n        charElement.classList.add(BOLD_CLASS);\n      }\n\n      if (this._workCell.isItalic()) {\n        charElement.classList.add(ITALIC_CLASS);\n      }\n\n      if (this._workCell.isDim()) {\n        charElement.classList.add(DIM_CLASS);\n      }\n\n      if (this._workCell.isUnderline()) {\n        charElement.classList.add(UNDERLINE_CLASS);\n      }\n\n      charElement.textContent = this._workCell.getChars() || WHITESPACE_CELL_CHAR;\n\n      const swapColor = this._workCell.isInverse();\n\n      // fg\n      if (this._workCell.isFgRGB()) {\n        let style = charElement.getAttribute('style') || '';\n        style += `${swapColor ? 'background-' : ''}color:rgb(${(AttributeData.toColorRGB(this._workCell.getFgColor())).join(',')});`;\n        charElement.setAttribute('style', style);\n      } else if (this._workCell.isFgPalette()) {\n        let fg = this._workCell.getFgColor();\n        if (this._workCell.isBold() && fg < 8 && !swapColor &&\n            this._terminalOptions.enableBold && this._terminalOptions.drawBoldTextInBrightColors) {\n          fg += 8;\n        }\n        charElement.classList.add(`xterm-${swapColor ? 'b' : 'f'}g-${fg}`);\n      } else if (swapColor) {\n        charElement.classList.add(`xterm-bg-${INVERTED_DEFAULT_COLOR}`);\n      }\n\n      // bg\n      if (this._workCell.isBgRGB()) {\n        let style = charElement.getAttribute('style') || '';\n        style += `${swapColor ? '' : 'background-'}color:rgb(${(AttributeData.toColorRGB(this._workCell.getBgColor())).join(',')});`;\n        charElement.setAttribute('style', style);\n      } else if (this._workCell.isBgPalette()) {\n        charElement.classList.add(`xterm-${swapColor ? 'f' : 'b'}g-${this._workCell.getBgColor()}`);\n      } else if (swapColor) {\n        charElement.classList.add(`xterm-fg-${INVERTED_DEFAULT_COLOR}`);\n      }\n\n      fragment.appendChild(charElement);\n    }\n    return fragment;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderer, IRenderDimensions, IColorSet } from '../Types';\nimport { ILinkifierEvent, ITerminal, CharacterJoinerHandler } from '../../Types';\nimport { ITheme } from 'xterm';\nimport { ColorManager } from '../ColorManager';\nimport { RenderDebouncer } from '../../ui/RenderDebouncer';\nimport { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from './DomRendererRowFactory';\nimport { INVERTED_DEFAULT_COLOR } from '../atlas/Types';\nimport { EventEmitter2, IEvent } from '../../common/EventEmitter2';\nimport { Disposable } from '../../common/Lifecycle';\n\nconst TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';\nconst ROW_CONTAINER_CLASS = 'xterm-rows';\nconst FG_CLASS_PREFIX = 'xterm-fg-';\nconst BG_CLASS_PREFIX = 'xterm-bg-';\nconst FOCUS_CLASS = 'xterm-focus';\nconst SELECTION_CLASS = 'xterm-selection';\n\nlet nextTerminalId = 1;\n\n// TODO: Pull into an addon when TS composite projects allow easier sharing of code (not just\n// interfaces) between core and addons\n\n/**\n * A fallback renderer for when canvas is slow. This is not meant to be\n * particularly fast or feature complete, more just stable and usable for when\n * canvas is not an option.\n */\nexport class DomRenderer extends Disposable implements IRenderer {\n  private _renderDebouncer: RenderDebouncer;\n  private _rowFactory: DomRendererRowFactory;\n  private _terminalClass: number = nextTerminalId++;\n\n  private _themeStyleElement: HTMLStyleElement;\n  private _dimensionsStyleElement: HTMLStyleElement;\n  private _rowContainer: HTMLElement;\n  private _rowElements: HTMLElement[] = [];\n  private _selectionContainer: HTMLElement;\n\n  public dimensions: IRenderDimensions;\n  public colorManager: ColorManager;\n\n  private _onCanvasResize = new EventEmitter2<{ width: number, height: number }>();\n  public get onCanvasResize(): IEvent<{ width: number, height: number }> { return this._onCanvasResize.event; }\n  private _onRender = new EventEmitter2<{ start: number, end: number }>();\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }\n\n  constructor(private _terminal: ITerminal, theme: ITheme | undefined) {\n    super();\n    const allowTransparency = this._terminal.options.allowTransparency;\n    this.colorManager = new ColorManager(document, allowTransparency);\n    this.setTheme(theme);\n\n    this._rowContainer = document.createElement('div');\n    this._rowContainer.classList.add(ROW_CONTAINER_CLASS);\n    this._rowContainer.style.lineHeight = 'normal';\n    this._rowContainer.setAttribute('aria-hidden', 'true');\n    this._refreshRowElements(this._terminal.cols, this._terminal.rows);\n    this._selectionContainer = document.createElement('div');\n    this._selectionContainer.classList.add(SELECTION_CLASS);\n    this._selectionContainer.setAttribute('aria-hidden', 'true');\n\n    this.dimensions = {\n      scaledCharWidth: null,\n      scaledCharHeight: null,\n      scaledCellWidth: null,\n      scaledCellHeight: null,\n      scaledCharLeft: null,\n      scaledCharTop: null,\n      scaledCanvasWidth: null,\n      scaledCanvasHeight: null,\n      canvasWidth: null,\n      canvasHeight: null,\n      actualCellWidth: null,\n      actualCellHeight: null\n    };\n    this._updateDimensions();\n\n    this._renderDebouncer = new RenderDebouncer(this._renderRows.bind(this));\n    this._rowFactory = new DomRendererRowFactory(_terminal.options, document);\n\n    this._terminal.element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass);\n    this._terminal.screenElement.appendChild(this._rowContainer);\n    this._terminal.screenElement.appendChild(this._selectionContainer);\n\n    this._terminal.linkifier.onLinkHover(e => this._onLinkHover(e));\n    this._terminal.linkifier.onLinkLeave(e => this._onLinkLeave(e));\n  }\n\n  public dispose(): void {\n    this._terminal.element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);\n    this._terminal.screenElement.removeChild(this._rowContainer);\n    this._terminal.screenElement.removeChild(this._selectionContainer);\n    this._terminal.screenElement.removeChild(this._themeStyleElement);\n    this._terminal.screenElement.removeChild(this._dimensionsStyleElement);\n    super.dispose();\n  }\n\n  private _updateDimensions(): void {\n    this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);\n    this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);\n    this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);\n    this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);\n    this.dimensions.scaledCharLeft = 0;\n    this.dimensions.scaledCharTop = 0;\n    this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._terminal.cols;\n    this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._terminal.rows;\n    this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);\n    this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);\n    this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;\n    this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;\n\n    this._rowElements.forEach(element => {\n      element.style.width = `${this.dimensions.canvasWidth}px`;\n      element.style.height = `${this.dimensions.actualCellHeight}px`;\n      element.style.lineHeight = `${this.dimensions.actualCellHeight}px`;\n      // Make sure rows don't overflow onto following row\n      element.style.overflow = 'hidden';\n    });\n\n    if (!this._dimensionsStyleElement) {\n      this._dimensionsStyleElement = document.createElement('style');\n      this._terminal.screenElement.appendChild(this._dimensionsStyleElement);\n    }\n\n    const styles =\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS} span {` +\n        ` display: inline-block;` +\n        ` height: 100%;` +\n        ` vertical-align: top;` +\n        ` width: ${this.dimensions.actualCellWidth}px` +\n        `}`;\n\n    this._dimensionsStyleElement.innerHTML = styles;\n\n    this._selectionContainer.style.height = (<any>this._terminal)._viewportElement.style.height;\n    this._terminal.screenElement.style.width = `${this.dimensions.canvasWidth}px`;\n    this._terminal.screenElement.style.height = `${this.dimensions.canvasHeight}px`;\n  }\n\n  public setTheme(theme: ITheme | undefined): IColorSet {\n    if (theme) {\n      this.colorManager.setTheme(theme);\n    }\n\n    if (!this._themeStyleElement) {\n      this._themeStyleElement = document.createElement('style');\n      this._terminal.screenElement.appendChild(this._themeStyleElement);\n    }\n\n    // Base CSS\n    let styles =\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS} {` +\n        ` color: ${this.colorManager.colors.foreground.css};` +\n        ` background-color: ${this.colorManager.colors.background.css};` +\n        ` font-family: ${this._terminal.getOption('fontFamily')};` +\n        ` font-size: ${this._terminal.getOption('fontSize')}px;` +\n        `}`;\n    // Text styles\n    styles +=\n        `${this._terminalSelector} span:not(.${BOLD_CLASS}) {` +\n        ` font-weight: ${this._terminal.options.fontWeight};` +\n        `}` +\n        `${this._terminalSelector} span.${BOLD_CLASS} {` +\n        ` font-weight: ${this._terminal.options.fontWeightBold};` +\n        `}` +\n        `${this._terminalSelector} span.${ITALIC_CLASS} {` +\n        ` font-style: italic;` +\n        `}`;\n    // Blink animation\n    styles +=\n        `@keyframes blink {` +\n        ` 0% { opacity: 1.0; }` +\n        ` 50% { opacity: 0.0; }` +\n        ` 100% { opacity: 1.0; }` +\n        `}`;\n    // Cursor\n    styles +=\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}:not(.${FOCUS_CLASS}) .${CURSOR_CLASS} {` +\n        ` outline: 1px solid ${this.colorManager.colors.cursor.css};` +\n        ` outline-offset: -1px;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS} {` +\n        ` animation: blink 1s step-end infinite;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +\n        ` background-color: ${this.colorManager.colors.cursor.css};` +\n        ` color: ${this.colorManager.colors.cursorAccent.css};` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BAR_CLASS} {` +\n        ` box-shadow: 1px 0 0 ${this.colorManager.colors.cursor.css} inset;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_UNDERLINE_CLASS} {` +\n        ` box-shadow: 0 -1px 0 ${this.colorManager.colors.cursor.css} inset;` +\n        `}`;\n    // Selection\n    styles +=\n        `${this._terminalSelector} .${SELECTION_CLASS} {` +\n        ` position: absolute;` +\n        ` top: 0;` +\n        ` left: 0;` +\n        ` z-index: 1;` +\n        ` pointer-events: none;` +\n        `}` +\n        `${this._terminalSelector} .${SELECTION_CLASS} div {` +\n        ` position: absolute;` +\n        ` background-color: ${this.colorManager.colors.selection.css};` +\n        `}`;\n    // Colors\n    this.colorManager.colors.ansi.forEach((c, i) => {\n      styles +=\n          `${this._terminalSelector} .${FG_CLASS_PREFIX}${i} { color: ${c.css}; }` +\n          `${this._terminalSelector} .${BG_CLASS_PREFIX}${i} { background-color: ${c.css}; }`;\n    });\n    styles +=\n        `${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${this.colorManager.colors.background.css}; }` +\n        `${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this.colorManager.colors.foreground.css}; }`;\n\n    this._themeStyleElement.innerHTML = styles;\n    return this.colorManager.colors;\n  }\n\n  public onWindowResize(devicePixelRatio: number): void {\n    this._updateDimensions();\n  }\n\n  private _refreshRowElements(cols: number, rows: number): void {\n    // Add missing elements\n    for (let i = this._rowElements.length; i <= rows; i++) {\n      const row = document.createElement('div');\n      this._rowContainer.appendChild(row);\n      this._rowElements.push(row);\n    }\n    // Remove excess elements\n    while (this._rowElements.length > rows) {\n      this._rowContainer.removeChild(this._rowElements.pop());\n    }\n  }\n\n  public onResize(cols: number, rows: number): void {\n    this._refreshRowElements(cols, rows);\n    this._updateDimensions();\n    this._onCanvasResize.fire({\n      width: this.dimensions.canvasWidth,\n      height: this.dimensions.canvasHeight\n    });\n  }\n\n  public onCharSizeChanged(): void {\n    this._updateDimensions();\n  }\n\n  public onBlur(): void {\n    this._rowContainer.classList.remove(FOCUS_CLASS);\n  }\n\n  public onFocus(): void {\n    this._rowContainer.classList.add(FOCUS_CLASS);\n  }\n\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void {\n    // Remove all selections\n    while (this._selectionContainer.children.length) {\n      this._selectionContainer.removeChild(this._selectionContainer.children[0]);\n    }\n\n    // Selection does not exist\n    if (!start || !end) {\n      return;\n    }\n\n    // Translate from buffer position to viewport position\n    const viewportStartRow = start[1] - this._terminal.buffer.ydisp;\n    const viewportEndRow = end[1] - this._terminal.buffer.ydisp;\n    const viewportCappedStartRow = Math.max(viewportStartRow, 0);\n    const viewportCappedEndRow = Math.min(viewportEndRow, this._terminal.rows - 1);\n\n    // No need to draw the selection\n    if (viewportCappedStartRow >= this._terminal.rows || viewportCappedEndRow < 0) {\n      return;\n    }\n\n    // Create the selections\n    const documentFragment = document.createDocumentFragment();\n\n    if (columnSelectMode) {\n      documentFragment.appendChild(\n        this._createSelectionElement(viewportCappedStartRow, start[0], end[0], viewportCappedEndRow - viewportCappedStartRow + 1)\n      );\n    } else {\n      // Draw first row\n      const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;\n      const endCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : this._terminal.cols;\n      documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));\n      // Draw middle rows\n      const middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;\n      documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._terminal.cols, middleRowsCount));\n      // Draw final row\n      if (viewportCappedStartRow !== viewportCappedEndRow) {\n        // Only draw viewportEndRow if it's not the same as viewporttartRow\n        const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._terminal.cols;\n        documentFragment.appendChild(this._createSelectionElement(viewportCappedEndRow, 0, endCol));\n      }\n    }\n    this._selectionContainer.appendChild(documentFragment);\n  }\n\n  /**\n   * Creates a selection element at the specified position.\n   * @param row The row of the selection.\n   * @param colStart The start column.\n   * @param colEnd The end columns.\n   */\n  private _createSelectionElement(row: number, colStart: number, colEnd: number, rowCount: number = 1): HTMLElement {\n    const element = document.createElement('div');\n    element.style.height = `${rowCount * this.dimensions.actualCellHeight}px`;\n    element.style.top = `${row * this.dimensions.actualCellHeight}px`;\n    element.style.left = `${colStart * this.dimensions.actualCellWidth}px`;\n    element.style.width = `${this.dimensions.actualCellWidth * (colEnd - colStart)}px`;\n    return element;\n  }\n\n  public onCursorMove(): void {\n    // No-op, the cursor is drawn when rows are drawn\n  }\n\n  public onOptionsChanged(): void {\n    // Force a refresh\n    this._updateDimensions();\n    this.setTheme(undefined);\n    this._terminal.refresh(0, this._terminal.rows - 1);\n  }\n\n  public clear(): void {\n    this._rowElements.forEach(e => e.innerHTML = '');\n  }\n\n  public refreshRows(start: number, end: number): void {\n    this._renderDebouncer.refresh(start, end, this._terminal.rows);\n  }\n\n  private _renderRows(start: number, end: number): void {\n    const terminal = this._terminal;\n\n    const cursorAbsoluteY = terminal.buffer.ybase + terminal.buffer.y;\n    const cursorX = this._terminal.buffer.x;\n    const cursorBlink = this._terminal.options.cursorBlink;\n\n    for (let y = start; y <= end; y++) {\n      const rowElement = this._rowElements[y];\n      rowElement.innerHTML = '';\n\n      const row = y + terminal.buffer.ydisp;\n      const lineData = terminal.buffer.lines.get(row);\n      const cursorStyle = terminal.options.cursorStyle;\n      rowElement.appendChild(this._rowFactory.createRow(lineData, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, terminal.cols));\n    }\n\n    this._onRender.fire({ start, end });\n  }\n\n  private get _terminalSelector(): string {\n    return `.${TERMINAL_CLASS_PREFIX}${this._terminalClass}`;\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number { return -1; }\n  public deregisterCharacterJoiner(joinerId: number): boolean { return false; }\n\n  private _onLinkHover(e: ILinkifierEvent): void {\n    this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, true);\n  }\n\n  private _onLinkLeave(e: ILinkifierEvent): void {\n    this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, false);\n  }\n\n  private _setCellUnderline(x: number, x2: number, y: number, y2: number, cols: number, enabled: boolean): void {\n    while (x !== x2 || y !== y2) {\n      const row = this._rowElements[y];\n      if (!row) {\n        return;\n      }\n      const span = <HTMLElement>row.children[x];\n      if (span) {\n        span.style.textDecoration = enabled ? 'underline' : 'none';\n      }\n      if (++x >= cols) {\n        x = 0;\n        y++;\n      }\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { FontWeight } from 'xterm';\nimport { IColorSet } from '../Types';\n\nexport const DEFAULT_COLOR = 256;\nexport const INVERTED_DEFAULT_COLOR = 257;\nexport const DIM_OPACITY = 0.5;\n\nexport const CHAR_ATLAS_CELL_SPACING = 1;\n\nexport interface IGlyphIdentifier {\n  chars: string;\n  code: number;\n  bg: number;\n  fg: number;\n  bold: boolean;\n  dim: boolean;\n  italic: boolean;\n}\n\nexport interface ICharAtlasConfig {\n  type: 'none' | 'static' | 'dynamic';\n  devicePixelRatio: number;\n  fontSize: number;\n  fontFamily: string;\n  fontWeight: FontWeight;\n  fontWeightBold: FontWeight;\n  scaledCharWidth: number;\n  scaledCharHeight: number;\n  allowTransparency: boolean;\n  colors: IColorSet;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { DIM_OPACITY, IGlyphIdentifier, DEFAULT_COLOR, ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types';\nimport { generateStaticCharAtlasTexture } from './CharAtlasGenerator';\nimport BaseCharAtlas from './BaseCharAtlas';\nimport { is256Color } from './CharAtlasUtils';\n\nexport default class StaticCharAtlas extends BaseCharAtlas {\n  private _texture: HTMLCanvasElement | ImageBitmap;\n\n  constructor(private _document: Document, private _config: ICharAtlasConfig) {\n    super();\n  }\n\n  private _canvasFactory = (width: number, height: number) => {\n    const canvas = this._document.createElement('canvas');\n    canvas.width = width;\n    canvas.height = height;\n\n    // This is useful for debugging\n    // document.body.appendChild(canvas);\n\n    return canvas;\n  }\n\n  protected _doWarmUp(): void {\n    const result = generateStaticCharAtlasTexture(window, this._canvasFactory, this._config);\n    if (result instanceof HTMLCanvasElement) {\n      this._texture = result;\n    } else {\n      result.then(texture => {\n        this._texture = texture;\n      });\n    }\n  }\n\n  private _isCached(glyph: IGlyphIdentifier, colorIndex: number): boolean {\n    const isAscii = glyph.code < 256;\n    // A color is basic if it is one of the 4 bit ANSI colors.\n    const isBasicColor = glyph.fg < 16;\n    const isDefaultColor = glyph.fg === DEFAULT_COLOR;\n    const isDefaultBackground = glyph.bg === DEFAULT_COLOR;\n    return isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground && !glyph.italic;\n  }\n\n  public draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean {\n    // we're not warmed up yet\n    if (this._texture === null || this._texture === undefined) {\n      return false;\n    }\n\n    let colorIndex = 0;\n    if (is256Color(glyph.fg)) {\n      colorIndex = 2 + glyph.fg + (glyph.bold ? 16 : 0);\n    } else if (glyph.fg === DEFAULT_COLOR) {\n      // If default color and bold\n      if (glyph.bold) {\n        colorIndex = 1;\n      }\n    }\n    if (!this._isCached(glyph, colorIndex)) {\n      return false;\n    }\n\n    ctx.save();\n\n    // ImageBitmap's draw about twice as fast as from a canvas\n    const charAtlasCellWidth = this._config.scaledCharWidth + CHAR_ATLAS_CELL_SPACING;\n    const charAtlasCellHeight = this._config.scaledCharHeight + CHAR_ATLAS_CELL_SPACING;\n\n    // Apply alpha to dim the character\n    if (glyph.dim) {\n      ctx.globalAlpha = DIM_OPACITY;\n    }\n\n    ctx.drawImage(\n      this._texture,\n      glyph.code * charAtlasCellWidth,\n      colorIndex * charAtlasCellHeight,\n      charAtlasCellWidth,\n      this._config.scaledCharHeight,\n      x,\n      y,\n      charAtlasCellWidth,\n      this._config.scaledCharHeight\n    );\n\n    ctx.restore();\n\n    return true;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * A dummy CharAtlas implementation that always fails to draw characters.\n */\n\nimport { IGlyphIdentifier, ICharAtlasConfig } from './Types';\nimport BaseCharAtlas from './BaseCharAtlas';\n\nexport default class NoneCharAtlas extends BaseCharAtlas {\n  constructor(document: Document, config: ICharAtlasConfig) {\n    super();\n  }\n\n  public draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean {\n    return false;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\ninterface ILinkedListNode<T> {\n  prev: ILinkedListNode<T>;\n  next: ILinkedListNode<T>;\n  key: number;\n  value: T;\n}\n\nexport default class LRUMap<T> {\n  private _map: { [key: number]: ILinkedListNode<T> } = {};\n  private _head: ILinkedListNode<T> = null;\n  private _tail: ILinkedListNode<T> = null;\n  private _nodePool: ILinkedListNode<T>[] = [];\n  public size: number = 0;\n\n  constructor(public capacity: number) { }\n\n  private _unlinkNode(node: ILinkedListNode<T>): void {\n    const prev = node.prev;\n    const next = node.next;\n    if (node === this._head) {\n      this._head = next;\n    }\n    if (node === this._tail) {\n      this._tail = prev;\n    }\n    if (prev !== null) {\n      prev.next = next;\n    }\n    if (next !== null) {\n      next.prev = prev;\n    }\n  }\n\n  private _appendNode(node: ILinkedListNode<T>): void {\n    const tail = this._tail;\n    if (tail !== null) {\n      tail.next = node;\n    }\n    node.prev = tail;\n    node.next = null;\n    this._tail = node;\n    if (this._head === null) {\n      this._head = node;\n    }\n  }\n\n  /**\n   * Preallocate a bunch of linked-list nodes. Allocating these nodes ahead of time means that\n   * they're more likely to live next to each other in memory, which seems to improve performance.\n   *\n   * Each empty object only consumes about 60 bytes of memory, so this is pretty cheap, even for\n   * large maps.\n   */\n  public prealloc(count: number): void {\n    const nodePool = this._nodePool;\n    for (let i = 0; i < count; i++) {\n      nodePool.push({\n        prev: null,\n        next: null,\n        key: null,\n        value: null\n      });\n    }\n  }\n\n  public get(key: number): T | null {\n    // This is unsafe: We're assuming our keyspace doesn't overlap with Object.prototype. However,\n    // it's faster than calling hasOwnProperty, and in our case, it would never overlap.\n    const node = this._map[key];\n    if (node !== undefined) {\n      this._unlinkNode(node);\n      this._appendNode(node);\n      return node.value;\n    }\n    return null;\n  }\n\n  /**\n   * Gets a value from a key without marking it as the most recently used item.\n   */\n  public peekValue(key: number): T | null {\n    const node = this._map[key];\n    if (node !== undefined) {\n      return node.value;\n    }\n    return null;\n  }\n\n  public peek(): T | null {\n    const head = this._head;\n    return head === null ? null : head.value;\n  }\n\n  public set(key: number, value: T): void {\n    // This is unsafe: See note above.\n    let node = this._map[key];\n    if (node !== undefined) {\n      // already exists, we just need to mutate it and move it to the end of the list\n      node = this._map[key];\n      this._unlinkNode(node);\n      node.value = value;\n    } else if (this.size >= this.capacity) {\n      // we're out of space: recycle the head node, move it to the tail\n      node = this._head;\n      this._unlinkNode(node);\n      delete this._map[node.key];\n      node.key = key;\n      node.value = value;\n      this._map[key] = node;\n    } else {\n      // make a new element\n      const nodePool = this._nodePool;\n      if (nodePool.length > 0) {\n        // use a preallocated node if we can\n        node = nodePool.pop();\n        node.key = key;\n        node.value = value;\n      } else {\n        node = {\n          prev: null,\n          next: null,\n          key,\n          value\n        };\n      }\n      this._map[key] = node;\n      this.size++;\n    }\n    this._appendNode(node);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types';\nimport BaseCharAtlas from './BaseCharAtlas';\nimport { DEFAULT_ANSI_COLORS } from '../ColorManager';\nimport { clearColor } from './CharAtlasGenerator';\nimport LRUMap from './LRUMap';\nimport { isFirefox, isSafari } from '../../common/Platform';\nimport { IColor } from '../Types';\n\n// In practice we're probably never going to exhaust a texture this large. For debugging purposes,\n// however, it can be useful to set this to a really tiny value, to verify that LRU eviction works.\nconst TEXTURE_WIDTH = 1024;\nconst TEXTURE_HEIGHT = 1024;\n\nconst TRANSPARENT_COLOR = {\n  css: 'rgba(0, 0, 0, 0)',\n  rgba: 0\n};\n\n// Drawing to the cache is expensive: If we have to draw more than this number of glyphs to the\n// cache in a single frame, give up on trying to cache anything else, and try to finish the current\n// frame ASAP.\n//\n// This helps to limit the amount of damage a program can do when it would otherwise thrash the\n// cache.\nconst FRAME_CACHE_DRAW_LIMIT = 100;\n\n/**\n * The number of milliseconds to wait before generating the ImageBitmap, this is to debounce/batch\n * the operation as window.createImageBitmap is asynchronous.\n */\nconst GLYPH_BITMAP_COMMIT_DELAY = 100;\n\ninterface IGlyphCacheValue {\n  index: number;\n  isEmpty: boolean;\n  inBitmap: boolean;\n}\n\nexport function getGlyphCacheKey(glyph: IGlyphIdentifier): number {\n  // Note that this only returns a valid key when code < 256\n  // Layout:\n  // 0b00000000000000000000000000000001: italic (1)\n  // 0b00000000000000000000000000000010: dim (1)\n  // 0b00000000000000000000000000000100: bold (1)\n  // 0b00000000000000000000111111111000: fg (9)\n  // 0b00000000000111111111000000000000: bg (9)\n  // 0b00011111111000000000000000000000: code (8)\n  // 0b11100000000000000000000000000000: unused (3)\n  return glyph.code << 21 | glyph.bg << 12 | glyph.fg << 3 | (glyph.bold ? 0 : 4) + (glyph.dim ? 0 : 2) + (glyph.italic ? 0 : 1);\n}\n\nexport default class DynamicCharAtlas extends BaseCharAtlas {\n  // An ordered map that we're using to keep track of where each glyph is in the atlas texture.\n  // It's ordered so that we can determine when to remove the old entries.\n  private _cacheMap: LRUMap<IGlyphCacheValue>;\n\n  // The texture that the atlas is drawn to\n  private _cacheCanvas: HTMLCanvasElement;\n  private _cacheCtx: CanvasRenderingContext2D;\n\n  // A temporary context that glyphs are drawn to before being transfered to the atlas.\n  private _tmpCtx: CanvasRenderingContext2D;\n\n  // The number of characters stored in the atlas by width/height\n  private _width: number;\n  private _height: number;\n\n  private _drawToCacheCount: number = 0;\n\n  // An array of glyph keys that are waiting on the bitmap to be generated.\n  private _glyphsWaitingOnBitmap: IGlyphCacheValue[] = [];\n\n  // The timeout that is used to batch bitmap generation so it's not requested for every new glyph.\n  private _bitmapCommitTimeout: number | null = null;\n\n  // The bitmap to draw from, this is much faster on other browsers than others.\n  private _bitmap: ImageBitmap | null = null;\n\n  constructor(document: Document, private _config: ICharAtlasConfig) {\n    super();\n    this._cacheCanvas = document.createElement('canvas');\n    this._cacheCanvas.width = TEXTURE_WIDTH;\n    this._cacheCanvas.height = TEXTURE_HEIGHT;\n    // The canvas needs alpha because we use clearColor to convert the background color to alpha.\n    // It might also contain some characters with transparent backgrounds if allowTransparency is\n    // set.\n    this._cacheCtx = this._cacheCanvas.getContext('2d', {alpha: true});\n\n    const tmpCanvas = document.createElement('canvas');\n    tmpCanvas.width = this._config.scaledCharWidth;\n    tmpCanvas.height = this._config.scaledCharHeight;\n    this._tmpCtx = tmpCanvas.getContext('2d', {alpha: this._config.allowTransparency});\n\n    this._width = Math.floor(TEXTURE_WIDTH / this._config.scaledCharWidth);\n    this._height = Math.floor(TEXTURE_HEIGHT / this._config.scaledCharHeight);\n    const capacity = this._width * this._height;\n    this._cacheMap = new LRUMap(capacity);\n    this._cacheMap.prealloc(capacity);\n\n    // This is useful for debugging\n    // document.body.appendChild(this._cacheCanvas);\n  }\n\n  public dispose(): void {\n    if (this._bitmapCommitTimeout !== null) {\n      window.clearTimeout(this._bitmapCommitTimeout);\n      this._bitmapCommitTimeout = null;\n    }\n  }\n\n  public beginFrame(): void {\n    this._drawToCacheCount = 0;\n  }\n\n  public draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean {\n    // Space is always an empty cell, special case this as it's so common\n    if (glyph.code === 32) {\n      return true;\n    }\n\n    // Exit early for uncachable glyphs\n    if (!this._canCache(glyph)) {\n      return false;\n    }\n\n    const glyphKey = getGlyphCacheKey(glyph);\n    const cacheValue = this._cacheMap.get(glyphKey);\n    if (cacheValue !== null && cacheValue !== undefined) {\n      this._drawFromCache(ctx, cacheValue, x, y);\n      return true;\n    } else if (this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {\n      let index;\n      if (this._cacheMap.size < this._cacheMap.capacity) {\n        index = this._cacheMap.size;\n      } else {\n        // we're out of space, so our call to set will delete this item\n        index = this._cacheMap.peek().index;\n      }\n      const cacheValue = this._drawToCache(glyph, index);\n      this._cacheMap.set(glyphKey, cacheValue);\n      this._drawFromCache(ctx, cacheValue, x, y);\n      return true;\n    }\n    return false;\n  }\n\n  private _canCache(glyph: IGlyphIdentifier): boolean {\n    // Only cache ascii and extended characters for now, to be safe. In the future, we could do\n    // something more complicated to determine the expected width of a character.\n    //\n    // If we switch the renderer over to webgl at some point, we may be able to use blending modes\n    // to draw overlapping glyphs from the atlas:\n    // https://github.com/servo/webrender/issues/464#issuecomment-255632875\n    // https://webglfundamentals.org/webgl/lessons/webgl-text-texture.html\n    return glyph.code < 256;\n  }\n\n  private _toCoordinateX(index: number): number {\n    return (index % this._width) * this._config.scaledCharWidth;\n  }\n\n  private _toCoordinateY(index: number): number {\n    return Math.floor(index / this._width) * this._config.scaledCharHeight;\n  }\n\n  private _drawFromCache(\n    ctx: CanvasRenderingContext2D,\n    cacheValue: IGlyphCacheValue,\n    x: number,\n    y: number\n  ): void {\n    // We don't actually need to do anything if this is whitespace.\n    if (cacheValue.isEmpty) {\n      return;\n    }\n    const cacheX = this._toCoordinateX(cacheValue.index);\n    const cacheY = this._toCoordinateY(cacheValue.index);\n    ctx.drawImage(\n      cacheValue.inBitmap ? this._bitmap : this._cacheCanvas,\n      cacheX,\n      cacheY,\n      this._config.scaledCharWidth,\n      this._config.scaledCharHeight,\n      x,\n      y,\n      this._config.scaledCharWidth,\n      this._config.scaledCharHeight\n    );\n  }\n\n  private _getColorFromAnsiIndex(idx: number): IColor {\n    if (idx < this._config.colors.ansi.length) {\n      return this._config.colors.ansi[idx];\n    }\n    return DEFAULT_ANSI_COLORS[idx];\n  }\n\n  private _getBackgroundColor(glyph: IGlyphIdentifier): IColor {\n    if (this._config.allowTransparency) {\n      // The background color might have some transparency, so we need to render it as fully\n      // transparent in the atlas. Otherwise we'd end up drawing the transparent background twice\n      // around the anti-aliased edges of the glyph, and it would look too dark.\n      return TRANSPARENT_COLOR;\n    } else if (glyph.bg === INVERTED_DEFAULT_COLOR) {\n      return this._config.colors.foreground;\n    } else if (glyph.bg < 256) {\n      return this._getColorFromAnsiIndex(glyph.bg);\n    }\n    return this._config.colors.background;\n  }\n\n  private _getForegroundColor(glyph: IGlyphIdentifier): IColor {\n    if (glyph.fg === INVERTED_DEFAULT_COLOR) {\n      return this._config.colors.background;\n    } else if (glyph.fg < 256) {\n      // 256 color support\n      return this._getColorFromAnsiIndex(glyph.fg);\n    }\n    return this._config.colors.foreground;\n  }\n\n  // TODO: We do this (or something similar) in multiple places. We should split this off\n  // into a shared function.\n  private _drawToCache(glyph: IGlyphIdentifier, index: number): IGlyphCacheValue {\n    this._drawToCacheCount++;\n\n    this._tmpCtx.save();\n\n    // draw the background\n    const backgroundColor = this._getBackgroundColor(glyph);\n    // Use a 'copy' composite operation to clear any existing glyph out of _tmpCtxWithAlpha, regardless of\n    // transparency in backgroundColor\n    this._tmpCtx.globalCompositeOperation = 'copy';\n    this._tmpCtx.fillStyle = backgroundColor.css;\n    this._tmpCtx.fillRect(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight);\n    this._tmpCtx.globalCompositeOperation = 'source-over';\n\n    // draw the foreground/glyph\n    const fontWeight = glyph.bold ? this._config.fontWeightBold : this._config.fontWeight;\n    const fontStyle = glyph.italic ? 'italic' : '';\n    this._tmpCtx.font =\n      `${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`;\n    this._tmpCtx.textBaseline = 'middle';\n\n    this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css;\n\n    // Apply alpha to dim the character\n    if (glyph.dim) {\n      this._tmpCtx.globalAlpha = DIM_OPACITY;\n    }\n    // Draw the character\n    this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2);\n    this._tmpCtx.restore();\n\n    // clear the background from the character to avoid issues with drawing over the previous\n    // character if it extends past it's bounds\n    const imageData = this._tmpCtx.getImageData(\n      0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight\n    );\n    let isEmpty = false;\n    if (!this._config.allowTransparency) {\n      isEmpty = clearColor(imageData, backgroundColor);\n    }\n\n    // copy the data from imageData to _cacheCanvas\n    const x = this._toCoordinateX(index);\n    const y = this._toCoordinateY(index);\n    // putImageData doesn't do any blending, so it will overwrite any existing cache entry for us\n    this._cacheCtx.putImageData(imageData, x, y);\n\n    // Add the glyph and queue it to the bitmap (if the browser supports it)\n    const cacheValue = {\n      index,\n      isEmpty,\n      inBitmap: false\n    };\n    this._addGlyphToBitmap(cacheValue);\n\n    return cacheValue;\n  }\n\n  private _addGlyphToBitmap(cacheValue: IGlyphCacheValue): void {\n    // Support is patchy for createImageBitmap at the moment, pass a canvas back\n    // if support is lacking as drawImage works there too. Firefox is also\n    // included here as ImageBitmap appears both buggy and has horrible\n    // performance (tested on v55).\n    if (!('createImageBitmap' in window) || isFirefox || isSafari) {\n      return;\n    }\n\n    // Add the glyph to the queue\n    this._glyphsWaitingOnBitmap.push(cacheValue);\n\n    // Check if bitmap generation timeout already exists\n    if (this._bitmapCommitTimeout !== null) {\n      return;\n    }\n\n    this._bitmapCommitTimeout = window.setTimeout(() => this._generateBitmap(), GLYPH_BITMAP_COMMIT_DELAY);\n  }\n\n  private _generateBitmap(): void {\n    const glyphsMovingToBitmap = this._glyphsWaitingOnBitmap;\n    this._glyphsWaitingOnBitmap = [];\n    window.createImageBitmap(this._cacheCanvas).then(bitmap => {\n      // Set bitmap\n      this._bitmap = bitmap;\n\n      // Mark all new glyphs as in bitmap, excluding glyphs that came in after\n      // the bitmap was requested\n      for (let i = 0; i < glyphsMovingToBitmap.length; i++) {\n        const value = glyphsMovingToBitmap[i];\n        // It doesn't matter if the value was already evicted, it will be\n        // released from memory after this block if so.\n        value.inBitmap = true;\n      }\n    });\n    this._bitmapCommitTimeout = null;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal } from '../../Types';\nimport { IColorSet } from '../Types';\nimport { DEFAULT_COLOR, ICharAtlasConfig } from './Types';\n\nexport function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {\n  // null out some fields that don't matter\n  const clonedColors = <IColorSet>{\n    foreground: colors.foreground,\n    background: colors.background,\n    cursor: null,\n    cursorAccent: null,\n    selection: null,\n    // For the static char atlas, we only use the first 16 colors, but we need all 256 for the\n    // dynamic character atlas.\n    ansi: colors.ansi.slice(0, 16)\n  };\n  return {\n    type: terminal.options.experimentalCharAtlas,\n    devicePixelRatio: window.devicePixelRatio,\n    scaledCharWidth,\n    scaledCharHeight,\n    fontFamily: terminal.options.fontFamily,\n    fontSize: terminal.options.fontSize,\n    fontWeight: terminal.options.fontWeight,\n    fontWeightBold: terminal.options.fontWeightBold,\n    allowTransparency: terminal.options.allowTransparency,\n    colors: clonedColors\n  };\n}\n\nexport function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean {\n  for (let i = 0; i < a.colors.ansi.length; i++) {\n    if (a.colors.ansi[i].rgba !== b.colors.ansi[i].rgba) {\n      return false;\n    }\n  }\n  return a.type === b.type &&\n      a.devicePixelRatio === b.devicePixelRatio &&\n      a.fontFamily === b.fontFamily &&\n      a.fontSize === b.fontSize &&\n      a.fontWeight === b.fontWeight &&\n      a.fontWeightBold === b.fontWeightBold &&\n      a.allowTransparency === b.allowTransparency &&\n      a.scaledCharWidth === b.scaledCharWidth &&\n      a.scaledCharHeight === b.scaledCharHeight &&\n      a.colors.foreground === b.colors.foreground &&\n      a.colors.background === b.colors.background;\n}\n\nexport function is256Color(colorCode: number): boolean {\n  return colorCode < DEFAULT_COLOR;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { FontWeight } from 'xterm';\nimport { isFirefox, isSafari } from '../../common/Platform';\nimport { IColor } from '../Types';\nimport { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types';\n\n/**\n * Generates a char atlas.\n * @param context The window or worker context.\n * @param canvasFactory A function to generate a canvas with a width or height.\n * @param config The config for the new char atlas.\n */\nexport function generateStaticCharAtlasTexture(context: Window, canvasFactory: (width: number, height: number) => HTMLCanvasElement, config: ICharAtlasConfig): HTMLCanvasElement | Promise<ImageBitmap> {\n  const cellWidth = config.scaledCharWidth + CHAR_ATLAS_CELL_SPACING;\n  const cellHeight = config.scaledCharHeight + CHAR_ATLAS_CELL_SPACING;\n  const canvas = canvasFactory(\n    /*255 ascii chars*/255 * cellWidth,\n    (/*default+default bold*/2 + /*0-15*/16 + /*0-15 bold*/16) * cellHeight\n  );\n  const ctx = canvas.getContext('2d', {alpha: config.allowTransparency});\n\n  ctx.fillStyle = config.colors.background.css;\n  ctx.fillRect(0, 0, canvas.width, canvas.height);\n\n  ctx.save();\n  ctx.fillStyle = config.colors.foreground.css;\n  ctx.font = getFont(config.fontWeight, config);\n  ctx.textBaseline = 'middle';\n\n  // Default color\n  for (let i = 0; i < 256; i++) {\n    ctx.save();\n    ctx.beginPath();\n    ctx.rect(i * cellWidth, 0, cellWidth, cellHeight);\n    ctx.clip();\n    ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight / 2);\n    ctx.restore();\n  }\n  // Default color bold\n  ctx.save();\n  ctx.font = getFont(config.fontWeightBold, config);\n  for (let i = 0; i < 256; i++) {\n    ctx.save();\n    ctx.beginPath();\n    ctx.rect(i * cellWidth, cellHeight, cellWidth, cellHeight);\n    ctx.clip();\n    ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight * 1.5);\n    ctx.restore();\n  }\n  ctx.restore();\n\n  // Colors 0-15\n  ctx.font = getFont(config.fontWeight, config);\n  for (let colorIndex = 0; colorIndex < 16; colorIndex++) {\n    const y = (colorIndex + 2) * cellHeight;\n    // Draw ascii characters\n    for (let i = 0; i < 256; i++) {\n      ctx.save();\n      ctx.beginPath();\n      ctx.rect(i * cellWidth, y, cellWidth, cellHeight);\n      ctx.clip();\n      ctx.fillStyle = config.colors.ansi[colorIndex].css;\n      ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2);\n      ctx.restore();\n    }\n  }\n\n  // Colors 0-15 bold\n  ctx.font = getFont(config.fontWeightBold, config);\n  for (let colorIndex = 0; colorIndex < 16; colorIndex++) {\n    const y = (colorIndex + 2 + 16) * cellHeight;\n    // Draw ascii characters\n    for (let i = 0; i < 256; i++) {\n      ctx.save();\n      ctx.beginPath();\n      ctx.rect(i * cellWidth, y, cellWidth, cellHeight);\n      ctx.clip();\n      ctx.fillStyle = config.colors.ansi[colorIndex].css;\n      ctx.fillText(String.fromCharCode(i), i * cellWidth, y + cellHeight / 2);\n      ctx.restore();\n    }\n  }\n  ctx.restore();\n\n  // Support is patchy for createImageBitmap at the moment, pass a canvas back\n  // if support is lacking as drawImage works there too. Firefox is also\n  // included here as ImageBitmap appears both buggy and has horrible\n  // performance (tested on v55).\n  if (!('createImageBitmap' in context) || isFirefox || isSafari) {\n    // Don't attempt to clear background colors if createImageBitmap is not supported\n    return canvas;\n  }\n\n  const charAtlasImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);\n\n  // Remove the background color from the image so characters may overlap\n  clearColor(charAtlasImageData, config.colors.background);\n\n  return context.createImageBitmap(charAtlasImageData);\n}\n\n/**\n * Makes a partiicular rgb color in an ImageData completely transparent.\n * @returns True if the result is \"empty\", meaning all pixels are fully transparent.\n */\nexport function clearColor(imageData: ImageData, color: IColor): boolean {\n  let isEmpty = true;\n  const r = color.rgba >>> 24;\n  const g = color.rgba >>> 16 & 0xFF;\n  const b = color.rgba >>> 8 & 0xFF;\n  for (let offset = 0; offset < imageData.data.length; offset += 4) {\n    if (imageData.data[offset] === r &&\n        imageData.data[offset + 1] === g &&\n        imageData.data[offset + 2] === b) {\n      imageData.data[offset + 3] = 0;\n    } else {\n      isEmpty = false;\n    }\n  }\n  return isEmpty;\n}\n\nfunction getFont(fontWeight: FontWeight, config: ICharAtlasConfig): string {\n  return `${fontWeight} ${config.fontSize * config.devicePixelRatio}px ${config.fontFamily}`;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal } from '../../Types';\nimport { IColorSet } from '../Types';\nimport { generateConfig, configEquals } from './CharAtlasUtils';\nimport BaseCharAtlas from './BaseCharAtlas';\nimport DynamicCharAtlas from './DynamicCharAtlas';\nimport NoneCharAtlas from './NoneCharAtlas';\nimport StaticCharAtlas from './StaticCharAtlas';\nimport { ICharAtlasConfig } from './Types';\n\nconst charAtlasImplementations = {\n  'none': NoneCharAtlas,\n  'static': StaticCharAtlas,\n  'dynamic': DynamicCharAtlas\n};\n\ninterface ICharAtlasCacheEntry {\n  atlas: BaseCharAtlas;\n  config: ICharAtlasConfig;\n  // N.B. This implementation potentially holds onto copies of the terminal forever, so\n  // this may cause memory leaks.\n  ownedBy: ITerminal[];\n}\n\nconst charAtlasCache: ICharAtlasCacheEntry[] = [];\n\n/**\n * Acquires a char atlas, either generating a new one or returning an existing\n * one that is in use by another terminal.\n * @param terminal The terminal.\n * @param colors The colors to use.\n */\nexport function acquireCharAtlas(\n  terminal: ITerminal,\n  colors: IColorSet,\n  scaledCharWidth: number,\n  scaledCharHeight: number\n): BaseCharAtlas {\n  const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);\n\n  // Check to see if the terminal already owns this config\n  for (let i = 0; i < charAtlasCache.length; i++) {\n    const entry = charAtlasCache[i];\n    const ownedByIndex = entry.ownedBy.indexOf(terminal);\n    if (ownedByIndex >= 0) {\n      if (configEquals(entry.config, newConfig)) {\n        return entry.atlas;\n      }\n      // The configs differ, release the terminal from the entry\n      if (entry.ownedBy.length === 1) {\n        entry.atlas.dispose();\n        charAtlasCache.splice(i, 1);\n      } else {\n        entry.ownedBy.splice(ownedByIndex, 1);\n      }\n      break;\n    }\n  }\n\n  // Try match a char atlas from the cache\n  for (let i = 0; i < charAtlasCache.length; i++) {\n    const entry = charAtlasCache[i];\n    if (configEquals(entry.config, newConfig)) {\n      // Add the terminal to the cache entry and return\n      entry.ownedBy.push(terminal);\n      return entry.atlas;\n    }\n  }\n\n  const newEntry: ICharAtlasCacheEntry = {\n    atlas: new charAtlasImplementations[terminal.options.experimentalCharAtlas](\n      document,\n      newConfig\n    ),\n    config: newConfig,\n    ownedBy: [terminal]\n  };\n  charAtlasCache.push(newEntry);\n  return newEntry.atlas;\n}\n\n/**\n * Removes a terminal reference from the cache, allowing its memory to be freed.\n * @param terminal The terminal to remove.\n */\nexport function removeTerminalFromCache(terminal: ITerminal): void {\n  for (let i = 0; i < charAtlasCache.length; i++) {\n    const index = charAtlasCache[i].ownedBy.indexOf(terminal);\n    if (index !== -1) {\n      if (charAtlasCache[i].ownedBy.length === 1) {\n        // Remove the cache entry if it's the only terminal\n        charAtlasCache[i].atlas.dispose();\n        charAtlasCache.splice(i, 1);\n      } else {\n        // Remove the reference from the cache entry\n        charAtlasCache[i].ownedBy.splice(index, 1);\n      }\n      break;\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IGlyphIdentifier } from './Types';\nimport { IDisposable } from 'xterm';\n\nexport default abstract class BaseCharAtlas implements IDisposable {\n  private _didWarmUp: boolean = false;\n\n  public dispose(): void { }\n\n  /**\n   * Perform any work needed to warm the cache before it can be used. May be called multiple times.\n   * Implement _doWarmUp instead if you only want to get called once.\n   */\n  public warmUp(): void {\n    if (!this._didWarmUp) {\n      this._doWarmUp();\n      this._didWarmUp = true;\n    }\n  }\n\n  /**\n   * Perform any work needed to warm the cache before it can be used. Used by the default\n   * implementation of warmUp(), and will only be called once.\n   */\n  protected _doWarmUp(): void { }\n\n  /**\n   * Called when we start drawing a new frame.\n   *\n   * TODO: We rely on this getting called by TextRenderLayer. This should really be called by\n   * Renderer instead, but we need to make Renderer the source-of-truth for the char atlas, instead\n   * of BaseRenderLayer.\n   */\n  public beginFrame(): void { }\n\n  /**\n   * May be called before warmUp finishes, however it is okay for the implementation to\n   * do nothing and return false in that case.\n   *\n   * @param ctx Where to draw the character onto.\n   * @param glyph Information about what to draw\n   * @param x The position on the context to start drawing at\n   * @param y The position on the context to start drawing at\n   * @returns The success state. True if we drew the character.\n   */\n  public abstract draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { NULL_CELL_CODE } from '../Buffer';\nimport { IColorSet, IRenderDimensions, ICharacterJoinerRegistry } from './Types';\nimport { CharData, ITerminal, ICellData } from '../Types';\nimport { GridCache } from './GridCache';\nimport { BaseRenderLayer } from './BaseRenderLayer';\nimport { CellData, AttributeData, Content } from '../BufferLine';\nimport { JoinedCellData } from './CharacterJoinerRegistry';\n\n/**\n * This CharData looks like a null character, which will forc a clear and render\n * when the character changes (a regular space ' ' character may not as it's\n * drawn state is a cleared cell).\n */\n// const OVERLAP_OWNED_CHAR_DATA: CharData = [null, '', 0, -1];\n\nexport class TextRenderLayer extends BaseRenderLayer {\n  private _state: GridCache<CharData>;\n  private _characterWidth: number;\n  private _characterFont: string;\n  private _characterOverlapCache: { [key: string]: boolean } = {};\n  private _characterJoinerRegistry: ICharacterJoinerRegistry;\n  private _workCell = new CellData();\n\n  constructor(container: HTMLElement, zIndex: number, colors: IColorSet, characterJoinerRegistry: ICharacterJoinerRegistry, alpha: boolean) {\n    super(container, 'text', zIndex, alpha, colors);\n    this._state = new GridCache<CharData>();\n    this._characterJoinerRegistry = characterJoinerRegistry;\n  }\n\n  public resize(terminal: ITerminal, dim: IRenderDimensions): void {\n    super.resize(terminal, dim);\n\n    // Clear the character width cache if the font or width has changed\n    const terminalFont = this._getFont(terminal, false, false);\n    if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {\n      this._characterWidth = dim.scaledCharWidth;\n      this._characterFont = terminalFont;\n      this._characterOverlapCache = {};\n    }\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._state.clear();\n    this._state.resize(terminal.cols, terminal.rows);\n  }\n\n  public reset(terminal: ITerminal): void {\n    this._state.clear();\n    this.clearAll();\n  }\n\n  private _forEachCell(\n    terminal: ITerminal,\n    firstRow: number,\n    lastRow: number,\n    joinerRegistry: ICharacterJoinerRegistry | null,\n    callback: (\n      cell: ICellData,\n      x: number,\n      y: number\n    ) => void\n  ): void {\n    for (let y = firstRow; y <= lastRow; y++) {\n      const row = y + terminal.buffer.ydisp;\n      const line = terminal.buffer.lines.get(row);\n      const joinedRanges = joinerRegistry ? joinerRegistry.getJoinedCharacters(row) : [];\n      for (let x = 0; x < terminal.cols; x++) {\n        line.loadCell(x, this._workCell);\n        let cell = this._workCell;\n\n        // If true, indicates that the current character(s) to draw were joined.\n        let isJoined = false;\n        let lastCharX = x;\n\n        // The character to the left is a wide character, drawing is owned by\n        // the char at x-1\n        if (cell.getWidth() === 0) {\n          continue;\n        }\n\n        // Process any joined character ranges as needed. Because of how the\n        // ranges are produced, we know that they are valid for the characters\n        // and attributes of our input.\n        if (joinedRanges.length > 0 && x === joinedRanges[0][0]) {\n          isJoined = true;\n          const range = joinedRanges.shift();\n\n          // We already know the exact start and end column of the joined range,\n          // so we get the string and width representing it directly\n\n          cell = new JoinedCellData(\n            this._workCell,\n            line.translateToString(true, range[0], range[1]),\n            range[1] - range[0]\n          );\n\n          // Skip over the cells occupied by this range in the loop\n          lastCharX = range[1] - 1;\n        }\n\n        // If the character is an overlapping char and the character to the\n        // right is a space, take ownership of the cell to the right. We skip\n        // this check for joined characters because their rendering likely won't\n        // yield the same result as rendering the last character individually.\n        if (!isJoined && this._isOverlapping(cell)) {\n          // If the character is overlapping, we want to force a re-render on every\n          // frame. This is specifically to work around the case where two\n          // overlaping chars `a` and `b` are adjacent, the cursor is moved to b and a\n          // space is added. Without this, the first half of `b` would never\n          // get removed, and `a` would not re-render because it thinks it's\n          // already in the correct state.\n          // this._state.cache[x][y] = OVERLAP_OWNED_CHAR_DATA;\n          if (lastCharX < line.length - 1 && line.getCodePoint(lastCharX + 1) === NULL_CELL_CODE) {\n            // patch width to 2\n            cell.content &= ~Content.WIDTH_MASK;\n            cell.content |= 2 << Content.WIDTH_SHIFT;\n            // this._clearChar(x + 1, y);\n            // The overlapping char's char data will force a clear and render when the\n            // overlapping char is no longer to the left of the character and also when\n            // the space changes to another character.\n            // this._state.cache[x + 1][y] = OVERLAP_OWNED_CHAR_DATA;\n          }\n        }\n\n        callback(\n          cell,\n          x,\n          y\n        );\n\n        x = lastCharX;\n      }\n    }\n  }\n\n  /**\n   * Draws the background for a specified range of columns. Tries to batch adjacent cells of the\n   * same color together to reduce draw calls.\n   */\n  private _drawBackground(terminal: ITerminal, firstRow: number, lastRow: number): void {\n    const ctx = this._ctx;\n    const cols = terminal.cols;\n    let startX: number = 0;\n    let startY: number = 0;\n    let prevFillStyle: string | null = null;\n\n    ctx.save();\n\n    this._forEachCell(terminal, firstRow, lastRow, null, (cell, x, y) => {\n      // libvte and xterm both draw the background (but not foreground) of invisible characters,\n      // so we should too.\n      let nextFillStyle = null; // null represents default background color\n\n      if (cell.isInverse()) {\n        if (cell.isFgDefault()) {\n          nextFillStyle = this._colors.foreground.css;\n        } else if (cell.isFgRGB()) {\n          nextFillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;\n        } else {\n          nextFillStyle = this._colors.ansi[cell.getFgColor()].css;\n        }\n      } else if (cell.isBgRGB()) {\n        nextFillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;\n      } else if (cell.isBgPalette()) {\n        nextFillStyle = this._colors.ansi[cell.getBgColor()].css;\n      }\n\n      if (prevFillStyle === null) {\n        // This is either the first iteration, or the default background was set. Either way, we\n        // don't need to draw anything.\n        startX = x;\n        startY = y;\n      } if (y !== startY) {\n        // our row changed, draw the previous row\n        ctx.fillStyle = prevFillStyle;\n        this.fillCells(startX, startY, cols - startX, 1);\n        startX = x;\n        startY = y;\n      } else if (prevFillStyle !== nextFillStyle) {\n        // our color changed, draw the previous characters in this row\n        ctx.fillStyle = prevFillStyle;\n        this.fillCells(startX, startY, x - startX, 1);\n        startX = x;\n        startY = y;\n      }\n\n      prevFillStyle = nextFillStyle;\n    });\n\n    // flush the last color we encountered\n    if (prevFillStyle !== null) {\n      ctx.fillStyle = prevFillStyle;\n      this.fillCells(startX, startY, cols - startX, 1);\n    }\n\n    ctx.restore();\n  }\n\n  private _drawForeground(terminal: ITerminal, firstRow: number, lastRow: number): void {\n    this._forEachCell(terminal, firstRow, lastRow, this._characterJoinerRegistry, (cell, x, y) => {\n      if (cell.isInvisible()) {\n        return;\n      }\n      if (cell.isUnderline()) {\n        this._ctx.save();\n\n        if (cell.isInverse()) {\n          if (cell.isBgDefault()) {\n            this._ctx.fillStyle = this._colors.background.css;\n          } else if (cell.isBgRGB()) {\n            this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;\n          } else {\n            this._ctx.fillStyle = this._colors.ansi[cell.getBgColor()].css;\n          }\n        } else {\n          if (cell.isFgDefault()) {\n            this._ctx.fillStyle = this._colors.foreground.css;\n          } else if (cell.isFgRGB()) {\n            this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;\n          } else {\n            let fg = cell.getFgColor();\n            if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {\n              fg += 8;\n            }\n            this._ctx.fillStyle = this._colors.ansi[fg].css;\n          }\n        }\n\n        this.fillBottomLineAtCells(x, y, cell.getWidth());\n        this._ctx.restore();\n      }\n      this.drawChars(terminal, cell, x, y);\n    });\n  }\n\n  public onGridChanged(terminal: ITerminal, firstRow: number, lastRow: number): void {\n    // Resize has not been called yet\n    if (this._state.cache.length === 0) {\n      return;\n    }\n\n    if (this._charAtlas) {\n      this._charAtlas.beginFrame();\n    }\n\n    this.clearCells(0, firstRow, terminal.cols, lastRow - firstRow + 1);\n    this._drawBackground(terminal, firstRow, lastRow);\n    this._drawForeground(terminal, firstRow, lastRow);\n  }\n\n  public onOptionsChanged(terminal: ITerminal): void {\n    this.setTransparency(terminal, terminal.options.allowTransparency);\n  }\n\n  /**\n   * Whether a character is overlapping to the next cell.\n   */\n  private _isOverlapping(cell: ICellData): boolean {\n    // Only single cell characters can be overlapping, rendering issues can\n    // occur without this check\n    if (cell.getWidth() !== 1) {\n      return false;\n    }\n\n    // We assume that any ascii character will not overlap\n    if (cell.getCode() < 256) {\n      return false;\n    }\n\n    const chars = cell.getChars();\n\n    // Deliver from cache if available\n    if (this._characterOverlapCache.hasOwnProperty(chars)) {\n      return this._characterOverlapCache[chars];\n    }\n\n    // Setup the font\n    this._ctx.save();\n    this._ctx.font = this._characterFont;\n\n    // Measure the width of the character, but Math.floor it\n    // because that is what the renderer does when it calculates\n    // the character dimensions we are comparing against\n    const overlaps = Math.floor(this._ctx.measureText(chars).width) > this._characterWidth;\n\n    // Restore the original context\n    this._ctx.restore();\n\n    // Cache and return\n    this._characterOverlapCache[chars] = overlaps;\n    return overlaps;\n  }\n\n  /**\n   * Clear the charcater at the cell specified.\n   * @param x The column of the char.\n   * @param y The row of the char.\n   */\n  // private _clearChar(x: number, y: number): void {\n  //   let colsToClear = 1;\n  //   // Clear the adjacent character if it was wide\n  //   const state = this._state.cache[x][y];\n  //   if (state && state[CHAR_DATA_WIDTH_INDEX] === 2) {\n  //     colsToClear = 2;\n  //   }\n  //   this.clearCells(x, y, colsToClear, 1);\n  // }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal } from '../Types';\nimport { IColorSet, IRenderDimensions } from './Types';\nimport { BaseRenderLayer } from './BaseRenderLayer';\n\ninterface ISelectionState {\n  start: [number, number];\n  end: [number, number];\n  columnSelectMode: boolean;\n  ydisp: number;\n}\n\nexport class SelectionRenderLayer extends BaseRenderLayer {\n  private _state: ISelectionState;\n\n  constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {\n    super(container, 'selection', zIndex, true, colors);\n    this._clearState();\n  }\n\n  private _clearState(): void {\n    this._state = {\n      start: null,\n      end: null,\n      columnSelectMode: null,\n      ydisp: null\n    };\n  }\n\n  public resize(terminal: ITerminal, dim: IRenderDimensions): void {\n    super.resize(terminal, dim);\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._clearState();\n  }\n\n  public reset(terminal: ITerminal): void {\n    if (this._state.start && this._state.end) {\n      this._clearState();\n      this.clearAll();\n    }\n  }\n\n  public onSelectionChanged(terminal: ITerminal, start: [number, number], end: [number, number], columnSelectMode: boolean): void {\n    // Selection has not changed\n    if (!this._didStateChange(start, end, columnSelectMode, terminal.buffer.ydisp)) {\n      return;\n    }\n\n    // Remove all selections\n    this.clearAll();\n\n    // Selection does not exist\n    if (!start || !end) {\n      this._clearState();\n      return;\n    }\n\n    // Translate from buffer position to viewport position\n    const viewportStartRow = start[1] - terminal.buffer.ydisp;\n    const viewportEndRow = end[1] - terminal.buffer.ydisp;\n    const viewportCappedStartRow = Math.max(viewportStartRow, 0);\n    const viewportCappedEndRow = Math.min(viewportEndRow, terminal.rows - 1);\n\n    // No need to draw the selection\n    if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) {\n      return;\n    }\n\n    this._ctx.fillStyle = this._colors.selection.css;\n\n    if (columnSelectMode) {\n      const startCol = start[0];\n      const width = end[0] - startCol;\n      const height = viewportCappedEndRow - viewportCappedStartRow + 1;\n      this.fillCells(startCol, viewportCappedStartRow, width, height);\n    } else {\n      // Draw first row\n      const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;\n      const startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;\n      this.fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);\n\n      // Draw middle rows\n      const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);\n      this.fillCells(0, viewportCappedStartRow + 1, terminal.cols, middleRowsCount);\n\n      // Draw final row\n      if (viewportCappedStartRow !== viewportCappedEndRow) {\n        // Only draw viewportEndRow if it's not the same as viewportStartRow\n        const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : terminal.cols;\n        this.fillCells(0, viewportCappedEndRow, endCol, 1);\n      }\n    }\n\n    // Save state for next render\n    this._state.start = [start[0], start[1]];\n    this._state.end = [end[0], end[1]];\n    this._state.columnSelectMode = columnSelectMode;\n    this._state.ydisp = terminal.buffer.ydisp;\n  }\n\n  private _didStateChange(start: [number, number], end: [number, number], columnSelectMode: boolean, ydisp: number): boolean {\n    return !this._areCoordinatesEqual(start, this._state.start) ||\n      !this._areCoordinatesEqual(end, this._state.end) ||\n      columnSelectMode !== this._state.columnSelectMode ||\n      ydisp !== this._state.ydisp;\n  }\n\n  private _areCoordinatesEqual(coord1: [number, number], coord2: [number, number]): boolean {\n    if (!coord1 || !coord2) {\n      return false;\n    }\n\n    return coord1[0] === coord2[0] && coord1[1] === coord2[1];\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { TextRenderLayer } from './TextRenderLayer';\nimport { SelectionRenderLayer } from './SelectionRenderLayer';\nimport { CursorRenderLayer } from './CursorRenderLayer';\nimport { ColorManager } from './ColorManager';\nimport { IRenderLayer, IColorSet, IRenderer, IRenderDimensions, ICharacterJoinerRegistry } from './Types';\nimport { ITerminal, CharacterJoinerHandler } from '../Types';\nimport { LinkRenderLayer } from './LinkRenderLayer';\nimport { RenderDebouncer } from '../ui/RenderDebouncer';\nimport { ScreenDprMonitor } from '../ui/ScreenDprMonitor';\nimport { ITheme } from 'xterm';\nimport { CharacterJoinerRegistry } from '../renderer/CharacterJoinerRegistry';\nimport { EventEmitter2, IEvent } from '../common/EventEmitter2';\nimport { Disposable } from '../common/Lifecycle';\n\nexport class Renderer extends Disposable implements IRenderer {\n  private _renderDebouncer: RenderDebouncer;\n\n  private _renderLayers: IRenderLayer[];\n  private _devicePixelRatio: number;\n  private _screenDprMonitor: ScreenDprMonitor;\n  private _isPaused: boolean = false;\n  private _needsFullRefresh: boolean = false;\n  private _characterJoinerRegistry: ICharacterJoinerRegistry;\n\n  public colorManager: ColorManager;\n  public dimensions: IRenderDimensions;\n\n  private _onCanvasResize = new EventEmitter2<{ width: number, height: number }>();\n  public get onCanvasResize(): IEvent<{ width: number, height: number }> { return this._onCanvasResize.event; }\n  private _onRender = new EventEmitter2<{ start: number, end: number }>();\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }\n\n  constructor(private _terminal: ITerminal, theme: ITheme) {\n    super();\n    const allowTransparency = this._terminal.options.allowTransparency;\n    this.colorManager = new ColorManager(document, allowTransparency);\n    this._characterJoinerRegistry = new CharacterJoinerRegistry(_terminal);\n    if (theme) {\n      this.colorManager.setTheme(theme);\n    }\n\n    this._renderLayers = [\n      new TextRenderLayer(this._terminal.screenElement, 0, this.colorManager.colors, this._characterJoinerRegistry, allowTransparency),\n      new SelectionRenderLayer(this._terminal.screenElement, 1, this.colorManager.colors),\n      new LinkRenderLayer(this._terminal.screenElement, 2, this.colorManager.colors, this._terminal),\n      new CursorRenderLayer(this._terminal.screenElement, 3, this.colorManager.colors)\n    ];\n    this.dimensions = {\n      scaledCharWidth: null,\n      scaledCharHeight: null,\n      scaledCellWidth: null,\n      scaledCellHeight: null,\n      scaledCharLeft: null,\n      scaledCharTop: null,\n      scaledCanvasWidth: null,\n      scaledCanvasHeight: null,\n      canvasWidth: null,\n      canvasHeight: null,\n      actualCellWidth: null,\n      actualCellHeight: null\n    };\n    this._devicePixelRatio = window.devicePixelRatio;\n    this._updateDimensions();\n    this.onOptionsChanged();\n\n    this._renderDebouncer = new RenderDebouncer(this._renderRows.bind(this));\n    this._screenDprMonitor = new ScreenDprMonitor();\n    this._screenDprMonitor.setListener(() => this.onWindowResize(window.devicePixelRatio));\n    this.register(this._screenDprMonitor);\n\n    // Detect whether IntersectionObserver is detected and enable renderer pause\n    // and resume based on terminal visibility if so\n    if ('IntersectionObserver' in window) {\n      const observer = new IntersectionObserver(e => this.onIntersectionChange(e[e.length - 1]), { threshold: 0 });\n      observer.observe(this._terminal.element);\n      this.register({ dispose: () => observer.disconnect() });\n    }\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._renderLayers.forEach(l => l.dispose());\n  }\n\n  public onIntersectionChange(entry: IntersectionObserverEntry): void {\n    this._isPaused = entry.intersectionRatio === 0;\n    if (!this._isPaused && this._needsFullRefresh) {\n      this._terminal.refresh(0, this._terminal.rows - 1);\n      this._needsFullRefresh = false;\n    }\n  }\n\n  public onWindowResize(devicePixelRatio: number): void {\n    // If the device pixel ratio changed, the char atlas needs to be regenerated\n    // and the terminal needs to refreshed\n    if (this._devicePixelRatio !== devicePixelRatio) {\n      this._devicePixelRatio = devicePixelRatio;\n      this.onResize(this._terminal.cols, this._terminal.rows);\n    }\n  }\n\n  public setTheme(theme: ITheme): IColorSet {\n    this.colorManager.setTheme(theme);\n\n    // Clear layers and force a full render\n    this._renderLayers.forEach(l => {\n      l.onThemeChanged(this._terminal, this.colorManager.colors);\n      l.reset(this._terminal);\n    });\n\n    if (this._isPaused) {\n      this._needsFullRefresh = true;\n    } else {\n      this._terminal.refresh(0, this._terminal.rows - 1);\n    }\n\n    return this.colorManager.colors;\n  }\n\n  public onResize(cols: number, rows: number): void {\n    // Update character and canvas dimensions\n    this._updateDimensions();\n\n    // Resize all render layers\n    this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions));\n\n    // Force a refresh\n    if (this._isPaused) {\n      this._needsFullRefresh = true;\n    } else {\n      this._terminal.refresh(0, this._terminal.rows - 1);\n    }\n\n    // Resize the screen\n    this._terminal.screenElement.style.width = `${this.dimensions.canvasWidth}px`;\n    this._terminal.screenElement.style.height = `${this.dimensions.canvasHeight}px`;\n\n    this._onCanvasResize.fire({\n      width: this.dimensions.canvasWidth,\n      height: this.dimensions.canvasHeight\n    });\n  }\n\n  public onCharSizeChanged(): void {\n    this.onResize(this._terminal.cols, this._terminal.rows);\n  }\n\n  public onBlur(): void {\n    this._runOperation(l => l.onBlur(this._terminal));\n  }\n\n  public onFocus(): void {\n    this._runOperation(l => l.onFocus(this._terminal));\n  }\n\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean = false): void {\n    this._runOperation(l => l.onSelectionChanged(this._terminal, start, end, columnSelectMode));\n  }\n\n  public onCursorMove(): void {\n    this._runOperation(l => l.onCursorMove(this._terminal));\n  }\n\n  public onOptionsChanged(): void {\n    this.colorManager.allowTransparency = this._terminal.options.allowTransparency;\n    this._runOperation(l => l.onOptionsChanged(this._terminal));\n  }\n\n  public clear(): void {\n    this._runOperation(l => l.reset(this._terminal));\n  }\n\n  private _runOperation(operation: (layer: IRenderLayer) => void): void {\n    if (this._isPaused) {\n      this._needsFullRefresh = true;\n    } else {\n      this._renderLayers.forEach(l => operation(l));\n    }\n  }\n\n  /**\n   * Queues a refresh between two rows (inclusive), to be done on next animation\n   * frame.\n   * @param start The start row.\n   * @param end The end row.\n   */\n  public refreshRows(start: number, end: number): void {\n    if (this._isPaused) {\n      this._needsFullRefresh = true;\n      return;\n    }\n    this._renderDebouncer.refresh(start, end, this._terminal.rows);\n  }\n\n  /**\n   * Performs the refresh loop callback, calling refresh only if a refresh is\n   * necessary before queueing up the next one.\n   */\n  private _renderRows(start: number, end: number): void {\n    this._renderLayers.forEach(l => l.onGridChanged(this._terminal, start, end));\n    this._onRender.fire({ start, end });\n  }\n\n  /**\n   * Recalculates the character and canvas dimensions.\n   */\n  private _updateDimensions(): void {\n    // Perform a new measure if the CharMeasure dimensions are not yet available\n    if (!this._terminal.charMeasure.width || !this._terminal.charMeasure.height) {\n      return;\n    }\n\n    // Calculate the scaled character width. Width is floored as it must be\n    // drawn to an integer grid in order for the CharAtlas \"stamps\" to not be\n    // blurry. When text is drawn to the grid not using the CharAtlas, it is\n    // clipped to ensure there is no overlap with the next cell.\n    this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);\n\n    // Calculate the scaled character height. Height is ceiled in case\n    // devicePixelRatio is a floating point number in order to ensure there is\n    // enough space to draw the character to the cell.\n    this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);\n\n    // Calculate the scaled cell height, if lineHeight is not 1 then the value\n    // will be floored because since lineHeight can never be lower then 1, there\n    // is a guarentee that the scaled line height will always be larger than\n    // scaled char height.\n    this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);\n\n    // Calculate the y coordinate within a cell that text should draw from in\n    // order to draw in the center of a cell.\n    this.dimensions.scaledCharTop = this._terminal.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);\n\n    // Calculate the scaled cell width, taking the letterSpacing into account.\n    this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);\n\n    // Calculate the x coordinate with a cell that text should draw from in\n    // order to draw in the center of a cell.\n    this.dimensions.scaledCharLeft = Math.floor(this._terminal.options.letterSpacing / 2);\n\n    // Recalculate the canvas dimensions; scaled* define the actual number of\n    // pixel in the canvas\n    this.dimensions.scaledCanvasHeight = this._terminal.rows * this.dimensions.scaledCellHeight;\n    this.dimensions.scaledCanvasWidth = this._terminal.cols * this.dimensions.scaledCellWidth;\n\n    // The the size of the canvas on the page. It's very important that this\n    // rounds to nearest integer and not ceils as browsers often set\n    // window.devicePixelRatio as something like 1.100000023841858, when it's\n    // actually 1.1. Ceiling causes blurriness as the backing canvas image is 1\n    // pixel too large for the canvas element size.\n    this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);\n    this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);\n\n    // Get the _actual_ dimensions of an individual cell. This needs to be\n    // derived from the canvasWidth/Height calculated above which takes into\n    // account window.devicePixelRatio. CharMeasure.width/height by itself is\n    // insufficient when the page is not at 100% zoom level as CharMeasure is\n    // measured in CSS pixels, but the actual char size on the canvas can\n    // differ.\n    this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;\n    this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number {\n    return this._characterJoinerRegistry.registerCharacterJoiner(handler);\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): boolean {\n    return this._characterJoinerRegistry.deregisterCharacterJoiner(joinerId);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ILinkifierEvent, ITerminal, ILinkifierAccessor } from '../Types';\nimport { IColorSet, IRenderDimensions } from './Types';\nimport { BaseRenderLayer } from './BaseRenderLayer';\nimport { INVERTED_DEFAULT_COLOR } from './atlas/Types';\nimport { is256Color } from './atlas/CharAtlasUtils';\n\nexport class LinkRenderLayer extends BaseRenderLayer {\n  private _state: ILinkifierEvent = null;\n\n  constructor(container: HTMLElement, zIndex: number, colors: IColorSet, terminal: ILinkifierAccessor) {\n    super(container, 'link', zIndex, true, colors);\n    terminal.linkifier.onLinkHover(e => this._onLinkHover(e));\n    terminal.linkifier.onLinkLeave(e => this._onLinkLeave(e));\n  }\n\n  public resize(terminal: ITerminal, dim: IRenderDimensions): void {\n    super.resize(terminal, dim);\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._state = null;\n  }\n\n  public reset(terminal: ITerminal): void {\n    this._clearCurrentLink();\n  }\n\n  private _clearCurrentLink(): void {\n    if (this._state) {\n      this.clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);\n      const middleRowCount = this._state.y2 - this._state.y1 - 1;\n      if (middleRowCount > 0) {\n        this.clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);\n      }\n      this.clearCells(0, this._state.y2, this._state.x2, 1);\n      this._state = null;\n    }\n  }\n\n  private _onLinkHover(e: ILinkifierEvent): void {\n    if (e.fg === INVERTED_DEFAULT_COLOR) {\n      this._ctx.fillStyle = this._colors.background.css;\n    } else if (is256Color(e.fg)) {\n      // 256 color support\n      this._ctx.fillStyle = this._colors.ansi[e.fg].css;\n    } else {\n      this._ctx.fillStyle = this._colors.foreground.css;\n    }\n\n    if (e.y1 === e.y2) {\n      // Single line link\n      this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);\n    } else {\n      // Multi-line link\n      this.fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);\n      for (let y = e.y1 + 1; y < e.y2; y++) {\n        this.fillBottomLineAtCells(0, y, e.cols);\n      }\n      this.fillBottomLineAtCells(0, e.y2, e.x2);\n    }\n    this._state = e;\n  }\n\n  private _onLinkLeave(e: ILinkifierEvent): void {\n    this._clearCurrentLink();\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport class GridCache<T> {\n  public cache: T[][];\n\n  public constructor() {\n    this.cache = [];\n  }\n\n  public resize(width: number, height: number): void {\n    for (let x = 0; x < width; x++) {\n      if (this.cache.length <= x) {\n        this.cache.push([]);\n      }\n      for (let y = this.cache[x].length; y < height; y++) {\n        this.cache[x].push(null);\n      }\n      this.cache[x].length = height;\n    }\n    this.cache.length = width;\n  }\n\n  public clear(): void {\n    for (let x = 0; x < this.cache.length; x++) {\n      for (let y = 0; y < this.cache[x].length; y++) {\n        this.cache[x][y] = null;\n      }\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IColorSet, IRenderDimensions } from './Types';\nimport { BaseRenderLayer } from './BaseRenderLayer';\nimport { ITerminal, ICellData } from '../Types';\nimport { CellData } from '../BufferLine';\n\ninterface ICursorState {\n  x: number;\n  y: number;\n  isFocused: boolean;\n  style: string;\n  width: number;\n}\n\n/**\n * The time between cursor blinks.\n */\nconst BLINK_INTERVAL = 600;\n\nexport class CursorRenderLayer extends BaseRenderLayer {\n  private _state: ICursorState;\n  private _cursorRenderers: {[key: string]: (terminal: ITerminal, x: number, y: number, cell: ICellData) => void};\n  private _cursorBlinkStateManager: CursorBlinkStateManager;\n  private _cell: ICellData = new CellData();\n\n  constructor(container: HTMLElement, zIndex: number, colors: IColorSet) {\n    super(container, 'cursor', zIndex, true, colors);\n    this._state = {\n      x: null,\n      y: null,\n      isFocused: null,\n      style: null,\n      width: null\n    };\n    this._cursorRenderers = {\n      'bar': this._renderBarCursor.bind(this),\n      'block': this._renderBlockCursor.bind(this),\n      'underline': this._renderUnderlineCursor.bind(this)\n    };\n    // TODO: Consider initial options? Maybe onOptionsChanged should be called at the end of open?\n  }\n\n  public resize(terminal: ITerminal, dim: IRenderDimensions): void {\n    super.resize(terminal, dim);\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._state = {\n      x: null,\n      y: null,\n      isFocused: null,\n      style: null,\n      width: null\n    };\n  }\n\n  public reset(terminal: ITerminal): void {\n    this._clearCursor();\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.dispose();\n      this._cursorBlinkStateManager = null;\n      this.onOptionsChanged(terminal);\n    }\n  }\n\n  public onBlur(terminal: ITerminal): void {\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.pause();\n    }\n    terminal.refresh(terminal.buffer.y, terminal.buffer.y);\n  }\n\n  public onFocus(terminal: ITerminal): void {\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.resume(terminal);\n    } else {\n      terminal.refresh(terminal.buffer.y, terminal.buffer.y);\n    }\n  }\n\n  public onOptionsChanged(terminal: ITerminal): void {\n    if (terminal.options.cursorBlink) {\n      if (!this._cursorBlinkStateManager) {\n        this._cursorBlinkStateManager = new CursorBlinkStateManager(terminal, () => {\n          this._render(terminal, true);\n        });\n      }\n    } else {\n      if (this._cursorBlinkStateManager) {\n        this._cursorBlinkStateManager.dispose();\n        this._cursorBlinkStateManager = null;\n      }\n      // Request a refresh from the terminal as management of rendering is being\n      // moved back to the terminal\n      terminal.refresh(terminal.buffer.y, terminal.buffer.y);\n    }\n  }\n\n  public onCursorMove(terminal: ITerminal): void {\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.restartBlinkAnimation(terminal);\n    }\n  }\n\n  public onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void {\n    if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {\n      this._render(terminal, false);\n    } else {\n      this._cursorBlinkStateManager.restartBlinkAnimation(terminal);\n    }\n  }\n\n  private _render(terminal: ITerminal, triggeredByAnimationFrame: boolean): void {\n    // Don't draw the cursor if it's hidden\n    if (!terminal.cursorState || terminal.cursorHidden) {\n      this._clearCursor();\n      return;\n    }\n\n    const cursorY = terminal.buffer.ybase + terminal.buffer.y;\n    const viewportRelativeCursorY = cursorY - terminal.buffer.ydisp;\n\n    // Don't draw the cursor if it's off-screen\n    if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= terminal.rows) {\n      this._clearCursor();\n      return;\n    }\n\n    terminal.buffer.lines.get(cursorY).loadCell(terminal.buffer.x, this._cell);\n    if (this._cell.content === undefined) {\n      return;\n    }\n\n    if (!terminal.isFocused) {\n      this._clearCursor();\n      this._ctx.save();\n      this._ctx.fillStyle = this._colors.cursor.css;\n      this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, this._cell);\n      this._ctx.restore();\n      this._state.x = terminal.buffer.x;\n      this._state.y = viewportRelativeCursorY;\n      this._state.isFocused = false;\n      this._state.style = terminal.options.cursorStyle;\n      this._state.width = this._cell.getWidth();\n      return;\n    }\n\n    // Don't draw the cursor if it's blinking\n    if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {\n      this._clearCursor();\n      return;\n    }\n\n    if (this._state) {\n      // The cursor is already in the correct spot, don't redraw\n      if (this._state.x === terminal.buffer.x &&\n          this._state.y === viewportRelativeCursorY &&\n          this._state.isFocused === terminal.isFocused &&\n          this._state.style === terminal.options.cursorStyle &&\n          this._state.width === this._cell.getWidth()) {\n        return;\n      }\n      this._clearCursor();\n    }\n\n    this._ctx.save();\n    this._cursorRenderers[terminal.options.cursorStyle || 'block'](terminal, terminal.buffer.x, viewportRelativeCursorY, this._cell);\n    this._ctx.restore();\n\n    this._state.x = terminal.buffer.x;\n    this._state.y = viewportRelativeCursorY;\n    this._state.isFocused = false;\n    this._state.style = terminal.options.cursorStyle;\n    this._state.width = this._cell.getWidth();\n  }\n\n  private _clearCursor(): void {\n    if (this._state) {\n      this.clearCells(this._state.x, this._state.y, this._state.width, 1);\n      this._state = {\n        x: null,\n        y: null,\n        isFocused: null,\n        style: null,\n        width: null\n      };\n    }\n  }\n\n  private _renderBarCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.fillStyle = this._colors.cursor.css;\n    this.fillLeftLineAtCell(x, y);\n    this._ctx.restore();\n  }\n\n  private _renderBlockCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.fillStyle = this._colors.cursor.css;\n    this.fillCells(x, y, cell.getWidth(), 1);\n    this._ctx.fillStyle = this._colors.cursorAccent.css;\n    this.fillCharTrueColor(terminal, cell, x, y);\n    this._ctx.restore();\n  }\n\n  private _renderUnderlineCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.fillStyle = this._colors.cursor.css;\n    this.fillBottomLineAtCells(x, y);\n    this._ctx.restore();\n  }\n\n  private _renderBlurCursor(terminal: ITerminal, x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.strokeStyle = this._colors.cursor.css;\n    this.strokeRectAtCell(x, y, cell.getWidth(), 1);\n    this._ctx.restore();\n  }\n}\n\nclass CursorBlinkStateManager {\n  public isCursorVisible: boolean;\n\n  private _animationFrame: number;\n  private _blinkStartTimeout: number;\n  private _blinkInterval: number;\n\n  /**\n   * The time at which the animation frame was restarted, this is used on the\n   * next render to restart the timers so they don't need to restart the timers\n   * multiple times over a short period.\n   */\n  private _animationTimeRestarted: number;\n\n  constructor(\n    terminal: ITerminal,\n    private _renderCallback: () => void\n  ) {\n    this.isCursorVisible = true;\n    if (terminal.isFocused) {\n      this._restartInterval();\n    }\n  }\n\n  public get isPaused(): boolean { return !(this._blinkStartTimeout || this._blinkInterval); }\n\n  public dispose(): void {\n    if (this._blinkInterval) {\n      window.clearInterval(this._blinkInterval);\n      this._blinkInterval = null;\n    }\n    if (this._blinkStartTimeout) {\n      window.clearTimeout(this._blinkStartTimeout);\n      this._blinkStartTimeout = null;\n    }\n    if (this._animationFrame) {\n      window.cancelAnimationFrame(this._animationFrame);\n      this._animationFrame = null;\n    }\n  }\n\n  public restartBlinkAnimation(terminal: ITerminal): void {\n    if (this.isPaused) {\n      return;\n    }\n    // Save a timestamp so that the restart can be done on the next interval\n    this._animationTimeRestarted = Date.now();\n    // Force a cursor render to ensure it's visible and in the correct position\n    this.isCursorVisible = true;\n    if (!this._animationFrame) {\n      this._animationFrame = window.requestAnimationFrame(() => {\n        this._renderCallback();\n        this._animationFrame = null;\n      });\n    }\n  }\n\n  private _restartInterval(timeToStart: number = BLINK_INTERVAL): void {\n    // Clear any existing interval\n    if (this._blinkInterval) {\n      window.clearInterval(this._blinkInterval);\n    }\n\n    // Setup the initial timeout which will hide the cursor, this is done before\n    // the regular interval is setup in order to support restarting the blink\n    // animation in a lightweight way (without thrashing clearInterval and\n    // setInterval).\n    this._blinkStartTimeout = <number><any>setTimeout(() => {\n      // Check if another animation restart was requested while this was being\n      // started\n      if (this._animationTimeRestarted) {\n        const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);\n        this._animationTimeRestarted = null;\n        if (time > 0) {\n          this._restartInterval(time);\n          return;\n        }\n      }\n\n      // Hide the cursor\n      this.isCursorVisible = false;\n      this._animationFrame = window.requestAnimationFrame(() => {\n        this._renderCallback();\n        this._animationFrame = null;\n      });\n\n      // Setup the blink interval\n      this._blinkInterval = <number><any>setInterval(() => {\n        // Adjust the animation time if it was restarted\n        if (this._animationTimeRestarted) {\n          // calc time diff\n          // Make restart interval do a setTimeout initially?\n          const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);\n          this._animationTimeRestarted = null;\n          this._restartInterval(time);\n          return;\n        }\n\n        // Invert visibility and render\n        this.isCursorVisible = !this.isCursorVisible;\n        this._animationFrame = window.requestAnimationFrame(() => {\n          this._renderCallback();\n          this._animationFrame = null;\n        });\n      }, BLINK_INTERVAL);\n    }, timeToStart);\n  }\n\n  public pause(): void {\n    this.isCursorVisible = true;\n    if (this._blinkInterval) {\n      window.clearInterval(this._blinkInterval);\n      this._blinkInterval = null;\n    }\n    if (this._blinkStartTimeout) {\n      window.clearTimeout(this._blinkStartTimeout);\n      this._blinkStartTimeout = null;\n    }\n    if (this._animationFrame) {\n      window.cancelAnimationFrame(this._animationFrame);\n      this._animationFrame = null;\n    }\n  }\n\n  public resume(terminal: ITerminal): void {\n    this._animationTimeRestarted = null;\n    this._restartInterval();\n    this.restartBlinkAnimation(terminal);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IColorManager, IColor, IColorSet } from './Types';\nimport { ITheme } from 'xterm';\n\nconst DEFAULT_FOREGROUND = fromHex('#ffffff');\nconst DEFAULT_BACKGROUND = fromHex('#000000');\nconst DEFAULT_CURSOR = fromHex('#ffffff');\nconst DEFAULT_CURSOR_ACCENT = fromHex('#000000');\nconst DEFAULT_SELECTION = {\n  css: 'rgba(255, 255, 255, 0.3)',\n  rgba: 0xFFFFFF77\n};\n\n// An IIFE to generate DEFAULT_ANSI_COLORS. Do not mutate DEFAULT_ANSI_COLORS, instead make a copy\n// and mutate that.\nexport const DEFAULT_ANSI_COLORS = (() => {\n  const colors = [\n    // dark:\n    fromHex('#2e3436'),\n    fromHex('#cc0000'),\n    fromHex('#4e9a06'),\n    fromHex('#c4a000'),\n    fromHex('#3465a4'),\n    fromHex('#75507b'),\n    fromHex('#06989a'),\n    fromHex('#d3d7cf'),\n    // bright:\n    fromHex('#555753'),\n    fromHex('#ef2929'),\n    fromHex('#8ae234'),\n    fromHex('#fce94f'),\n    fromHex('#729fcf'),\n    fromHex('#ad7fa8'),\n    fromHex('#34e2e2'),\n    fromHex('#eeeeec')\n  ];\n\n  // Fill in the remaining 240 ANSI colors.\n  // Generate colors (16-231)\n  const v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];\n  for (let i = 0; i < 216; i++) {\n    const r = v[(i / 36) % 6 | 0];\n    const g = v[(i / 6) % 6 | 0];\n    const b = v[i % 6];\n    colors.push({\n      css: `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}`,\n      // Use >>> 0 to force a conversion to an unsigned int\n      rgba: ((r << 24) | (g << 16) | (b << 8) | 0xFF) >>> 0\n    });\n  }\n\n  // Generate greys (232-255)\n  for (let i = 0; i < 24; i++) {\n    const c = 8 + i * 10;\n    const ch = toPaddedHex(c);\n    colors.push({\n      css: `#${ch}${ch}${ch}`,\n      rgba: ((c << 24) | (c << 16) | (c << 8) | 0xFF) >>> 0\n    });\n  }\n\n  return colors;\n})();\n\nfunction fromHex(css: string): IColor {\n  return {\n    css,\n    rgba: parseInt(css.slice(1), 16) << 8 | 0xFF\n  };\n}\n\nfunction toPaddedHex(c: number): string {\n  const s = c.toString(16);\n  return s.length < 2 ? '0' + s : s;\n}\n\n/**\n * Manages the source of truth for a terminal's colors.\n */\nexport class ColorManager implements IColorManager {\n  public colors: IColorSet;\n  private _ctx: CanvasRenderingContext2D;\n  private _litmusColor: CanvasGradient;\n\n  constructor(document: Document, public allowTransparency: boolean) {\n    const canvas = document.createElement('canvas');\n    canvas.width = 1;\n    canvas.height = 1;\n    this._ctx = canvas.getContext('2d');\n    this._ctx.globalCompositeOperation = 'copy';\n    this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1);\n    this.colors = {\n      foreground: DEFAULT_FOREGROUND,\n      background: DEFAULT_BACKGROUND,\n      cursor: DEFAULT_CURSOR,\n      cursorAccent: DEFAULT_CURSOR_ACCENT,\n      selection: DEFAULT_SELECTION,\n      ansi: DEFAULT_ANSI_COLORS.slice()\n    };\n  }\n\n  /**\n   * Sets the terminal's theme.\n   * @param theme The  theme to use. If a partial theme is provided then default\n   * colors will be used where colors are not defined.\n   */\n  public setTheme(theme: ITheme): void {\n    this.colors.foreground = this._parseColor(theme.foreground, DEFAULT_FOREGROUND);\n    this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);\n    this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);\n    this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);\n    this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);\n    this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);\n    this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);\n    this.colors.ansi[2] = this._parseColor(theme.green, DEFAULT_ANSI_COLORS[2]);\n    this.colors.ansi[3] = this._parseColor(theme.yellow, DEFAULT_ANSI_COLORS[3]);\n    this.colors.ansi[4] = this._parseColor(theme.blue, DEFAULT_ANSI_COLORS[4]);\n    this.colors.ansi[5] = this._parseColor(theme.magenta, DEFAULT_ANSI_COLORS[5]);\n    this.colors.ansi[6] = this._parseColor(theme.cyan, DEFAULT_ANSI_COLORS[6]);\n    this.colors.ansi[7] = this._parseColor(theme.white, DEFAULT_ANSI_COLORS[7]);\n    this.colors.ansi[8] = this._parseColor(theme.brightBlack, DEFAULT_ANSI_COLORS[8]);\n    this.colors.ansi[9] = this._parseColor(theme.brightRed, DEFAULT_ANSI_COLORS[9]);\n    this.colors.ansi[10] = this._parseColor(theme.brightGreen, DEFAULT_ANSI_COLORS[10]);\n    this.colors.ansi[11] = this._parseColor(theme.brightYellow, DEFAULT_ANSI_COLORS[11]);\n    this.colors.ansi[12] = this._parseColor(theme.brightBlue, DEFAULT_ANSI_COLORS[12]);\n    this.colors.ansi[13] = this._parseColor(theme.brightMagenta, DEFAULT_ANSI_COLORS[13]);\n    this.colors.ansi[14] = this._parseColor(theme.brightCyan, DEFAULT_ANSI_COLORS[14]);\n    this.colors.ansi[15] = this._parseColor(theme.brightWhite, DEFAULT_ANSI_COLORS[15]);\n  }\n\n  private _parseColor(\n    css: string,\n    fallback: IColor,\n    allowTransparency: boolean = this.allowTransparency\n  ): IColor {\n    if (!css) {\n      return fallback;\n    }\n\n    // If parsing the value results in failure, then it must be ignored, and the attribute must\n    // retain its previous value.\n    // -- https://html.spec.whatwg.org/multipage/canvas.html#fill-and-stroke-styles\n    this._ctx.fillStyle = this._litmusColor;\n    this._ctx.fillStyle = css;\n    if (typeof this._ctx.fillStyle !== 'string') {\n      console.warn(`Color: ${css} is invalid using fallback ${fallback.css}`);\n      return fallback;\n    }\n\n    this._ctx.fillRect(0, 0, 1, 1);\n    const data = this._ctx.getImageData(0, 0, 1, 1).data;\n\n    if (!allowTransparency && data[3] !== 0xFF) {\n      // Ideally we'd just ignore the alpha channel, but...\n      //\n      // Browsers may not give back exactly the same RGB values we put in, because most/all\n      // convert the color to a pre-multiplied representation. getImageData converts that back to\n      // a un-premultipled representation, but the precision loss may make the RGB channels unuable\n      // on their own.\n      //\n      // E.g. In Chrome #12345610 turns into #10305010, and in the extreme case, 0xFFFFFF00 turns\n      // into 0x00000000.\n      //\n      // \"Note: Due to the lossy nature of converting to and from premultiplied alpha color values,\n      // pixels that have just been set using putImageData() might be returned to an equivalent\n      // getImageData() as different values.\"\n      // -- https://html.spec.whatwg.org/multipage/canvas.html#pixel-manipulation\n      //\n      // So let's just use the fallback color in this case instead.\n      console.warn(\n        `Color: ${css} is using transparency, but allowTransparency is false. ` +\n        `Using fallback ${fallback.css}.`\n      );\n      return fallback;\n    }\n\n    return {\n      css,\n      rgba: (data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]) >>> 0\n    };\n  }\n}\n","import { ITerminal, IBufferLine, ICellData, CharData } from '../Types';\nimport { ICharacterJoinerRegistry, ICharacterJoiner } from './Types';\nimport { CellData, Content, AttributeData } from '../BufferLine';\nimport { WHITESPACE_CELL_CHAR } from '../Buffer';\n\nexport class JoinedCellData extends AttributeData implements ICellData {\n  private _width: number;\n  // .content carries no meaning for joined CellData, simply nullify it\n  // thus we have to overload all other .content accessors\n  public content: number = 0;\n  public fg: number;\n  public bg: number;\n  public combinedData: string = '';\n\n  constructor(firstCell: ICellData, chars: string, width: number) {\n    super();\n    this.fg = firstCell.fg;\n    this.bg = firstCell.bg;\n    this.combinedData = chars;\n    this._width = width;\n  }\n\n  public isCombined(): number {\n    // always mark joined cell data as combined\n    return Content.IS_COMBINED_MASK;\n  }\n\n  public getWidth(): number {\n    return this._width;\n  }\n\n  public getChars(): string {\n    return this.combinedData;\n  }\n\n  public getCode(): number {\n    // code always gets the highest possible fake codepoint (read as -1)\n    // this is needed as code is used by caches as identifier\n    return 0x1FFFFF;\n  }\n\n  public setFromCharData(value: CharData): void {\n    throw new Error('not implemented');\n  }\n\n  public getAsCharData(): CharData {\n    return [this.fg, this.getChars(), this.getWidth(), this.getCode()];\n  }\n}\n\nexport class CharacterJoinerRegistry implements ICharacterJoinerRegistry {\n\n  private _characterJoiners: ICharacterJoiner[] = [];\n  private _nextCharacterJoinerId: number = 0;\n  private _workCell: CellData = new CellData();\n\n  constructor(private _terminal: ITerminal) {\n  }\n\n  public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {\n    const joiner: ICharacterJoiner = {\n      id: this._nextCharacterJoinerId++,\n      handler\n    };\n\n    this._characterJoiners.push(joiner);\n    return joiner.id;\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): boolean {\n    for (let i = 0; i < this._characterJoiners.length; i++) {\n      if (this._characterJoiners[i].id === joinerId) {\n        this._characterJoiners.splice(i, 1);\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  public getJoinedCharacters(row: number): [number, number][] {\n    if (this._characterJoiners.length === 0) {\n      return [];\n    }\n\n    const line = this._terminal.buffer.lines.get(row);\n    if (line.length === 0) {\n      return [];\n    }\n\n    const ranges: [number, number][] = [];\n    const lineStr = line.translateToString(true);\n\n    // Because some cells can be represented by multiple javascript characters,\n    // we track the cell and the string indexes separately. This allows us to\n    // translate the string ranges we get from the joiners back into cell ranges\n    // for use when rendering\n    let rangeStartColumn = 0;\n    let currentStringIndex = 0;\n    let rangeStartStringIndex = 0;\n    let rangeAttrFG = line.getFg(0);\n    let rangeAttrBG = line.getBg(0);\n\n    for (let x = 0; x < line.getTrimmedLength(); x++) {\n      line.loadCell(x, this._workCell);\n\n      if (this._workCell.getWidth() === 0) {\n        // If this character is of width 0, skip it.\n        continue;\n      }\n\n      // End of range\n      if (this._workCell.fg !== rangeAttrFG || this._workCell.bg !== rangeAttrBG) {\n        // If we ended up with a sequence of more than one character,\n        // look for ranges to join.\n        if (x - rangeStartColumn > 1) {\n          const joinedRanges = this._getJoinedRanges(\n            lineStr,\n            rangeStartStringIndex,\n            currentStringIndex,\n            line,\n            rangeStartColumn\n          );\n          for (let i = 0; i < joinedRanges.length; i++) {\n            ranges.push(joinedRanges[i]);\n          }\n        }\n\n        // Reset our markers for a new range.\n        rangeStartColumn = x;\n        rangeStartStringIndex = currentStringIndex;\n        rangeAttrFG = this._workCell.fg;\n        rangeAttrBG = this._workCell.bg;\n      }\n\n      currentStringIndex += this._workCell.getChars().length || WHITESPACE_CELL_CHAR.length;\n    }\n\n    // Process any trailing ranges.\n    if (this._terminal.cols - rangeStartColumn > 1) {\n      const joinedRanges = this._getJoinedRanges(\n        lineStr,\n        rangeStartStringIndex,\n        currentStringIndex,\n        line,\n        rangeStartColumn\n      );\n      for (let i = 0; i < joinedRanges.length; i++) {\n        ranges.push(joinedRanges[i]);\n      }\n    }\n\n    return ranges;\n  }\n\n  /**\n   * Given a segment of a line of text, find all ranges of text that should be\n   * joined in a single rendering unit. Ranges are internally converted to\n   * column ranges, rather than string ranges.\n   * @param line String representation of the full line of text\n   * @param startIndex Start position of the range to search in the string (inclusive)\n   * @param endIndex End position of the range to search in the string (exclusive)\n   */\n  private _getJoinedRanges(line: string, startIndex: number, endIndex: number, lineData: IBufferLine, startCol: number): [number, number][] {\n    const text = line.substring(startIndex, endIndex);\n    // At this point we already know that there is at least one joiner so\n    // we can just pull its value and assign it directly rather than\n    // merging it into an empty array, which incurs unnecessary writes.\n    const joinedRanges: [number, number][] = this._characterJoiners[0].handler(text);\n    for (let i = 1; i < this._characterJoiners.length; i++) {\n      // We merge any overlapping ranges across the different joiners\n      const joinerRanges = this._characterJoiners[i].handler(text);\n      for (let j = 0; j < joinerRanges.length; j++) {\n        CharacterJoinerRegistry._mergeRanges(joinedRanges, joinerRanges[j]);\n      }\n    }\n    this._stringRangesToCellRanges(joinedRanges, lineData, startCol);\n    return joinedRanges;\n  }\n\n  /**\n   * Modifies the provided ranges in-place to adjust for variations between\n   * string length and cell width so that the range represents a cell range,\n   * rather than the string range the joiner provides.\n   * @param ranges String ranges containing start (inclusive) and end (exclusive) index\n   * @param line Cell data for the relevant line in the terminal\n   * @param startCol Offset within the line to start from\n   */\n  private _stringRangesToCellRanges(ranges: [number, number][], line: IBufferLine, startCol: number): void {\n    let currentRangeIndex = 0;\n    let currentRangeStarted = false;\n    let currentStringIndex = 0;\n    let currentRange = ranges[currentRangeIndex];\n\n    // If we got through all of the ranges, stop searching\n    if (!currentRange) {\n      return;\n    }\n\n    for (let x = startCol; x < this._terminal.cols; x++) {\n      const width = line.getWidth(x);\n      const length = line.getString(x).length || WHITESPACE_CELL_CHAR.length;\n\n      // We skip zero-width characters when creating the string to join the text\n      // so we do the same here\n      if (width === 0) {\n        continue;\n      }\n\n      // Adjust the start of the range\n      if (!currentRangeStarted && currentRange[0] <= currentStringIndex) {\n        currentRange[0] = x;\n        currentRangeStarted = true;\n      }\n\n      // Adjust the end of the range\n      if (currentRange[1] <= currentStringIndex) {\n        currentRange[1] = x;\n\n        // We're finished with this range, so we move to the next one\n        currentRange = ranges[++currentRangeIndex];\n\n        // If there are no more ranges left, stop searching\n        if (!currentRange) {\n          break;\n        }\n\n        // Ranges can be on adjacent characters. Because the end index of the\n        // ranges are exclusive, this means that the index for the start of a\n        // range can be the same as the end index of the previous range. To\n        // account for the start of the next range, we check here just in case.\n        if (currentRange[0] <= currentStringIndex) {\n          currentRange[0] = x;\n          currentRangeStarted = true;\n        } else {\n          currentRangeStarted = false;\n        }\n      }\n\n      // Adjust the string index based on the character length to line up with\n      // the column adjustment\n      currentStringIndex += length;\n    }\n\n    // If there is still a range left at the end, it must extend all the way to\n    // the end of the line.\n    if (currentRange) {\n      currentRange[1] = this._terminal.cols;\n    }\n  }\n\n  /**\n   * Merges the range defined by the provided start and end into the list of\n   * existing ranges. The merge is done in place on the existing range for\n   * performance and is also returned.\n   * @param ranges Existing range list\n   * @param newRange Tuple of two numbers representing the new range to merge in.\n   * @returns The ranges input with the new range merged in place\n   */\n  private static _mergeRanges(ranges: [number, number][], newRange: [number, number]): [number, number][] {\n    let inRange = false;\n    for (let i = 0; i < ranges.length; i++) {\n      const range = ranges[i];\n      if (!inRange) {\n        if (newRange[1] <= range[0]) {\n          // Case 1: New range is before the search range\n          ranges.splice(i, 0, newRange);\n          return ranges;\n        }\n\n        if (newRange[1] <= range[1]) {\n          // Case 2: New range is either wholly contained within the\n          // search range or overlaps with the front of it\n          range[0] = Math.min(newRange[0], range[0]);\n          return ranges;\n        }\n\n        if (newRange[0] < range[1]) {\n          // Case 3: New range either wholly contains the search range\n          // or overlaps with the end of it\n          range[0] = Math.min(newRange[0], range[0]);\n          inRange = true;\n        }\n\n        // Case 4: New range starts after the search range\n        continue;\n      } else {\n        if (newRange[1] <= range[0]) {\n          // Case 5: New range extends from previous range but doesn't\n          // reach the current one\n          ranges[i - 1][1] = newRange[1];\n          return ranges;\n        }\n\n        if (newRange[1] <= range[1]) {\n          // Case 6: New range extends from prvious range into the\n          // current range\n          ranges[i - 1][1] = Math.max(newRange[1], range[1]);\n          ranges.splice(i, 1);\n          inRange = false;\n          return ranges;\n        }\n\n        // Case 7: New range extends from previous range past the\n        // end of the current range\n        ranges.splice(i, 1);\n        i--;\n      }\n    }\n\n    if (inRange) {\n      // Case 8: New range extends past the last existing range\n      ranges[ranges.length - 1][1] = newRange[1];\n    } else {\n      // Case 9: New range starts after the last existing range\n      ranges.push(newRange);\n    }\n\n    return ranges;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderLayer, IColorSet, IRenderDimensions } from './Types';\nimport { ITerminal, ICellData } from '../Types';\nimport { DIM_OPACITY, INVERTED_DEFAULT_COLOR, IGlyphIdentifier, DEFAULT_COLOR } from './atlas/Types';\nimport BaseCharAtlas from './atlas/BaseCharAtlas';\nimport { acquireCharAtlas } from './atlas/CharAtlasCache';\nimport { CellData, AttributeData } from '../BufferLine';\nimport { WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE } from '../Buffer';\nimport { JoinedCellData } from './CharacterJoinerRegistry';\n\nexport abstract class BaseRenderLayer implements IRenderLayer {\n  private _canvas: HTMLCanvasElement;\n  protected _ctx: CanvasRenderingContext2D;\n  private _scaledCharWidth: number = 0;\n  private _scaledCharHeight: number = 0;\n  private _scaledCellWidth: number = 0;\n  private _scaledCellHeight: number = 0;\n  private _scaledCharLeft: number = 0;\n  private _scaledCharTop: number = 0;\n\n  protected _charAtlas: BaseCharAtlas;\n\n  /**\n   * An object that's reused when drawing glyphs in order to reduce GC.\n   */\n  private _currentGlyphIdentifier: IGlyphIdentifier = {\n    chars: '',\n    code: 0,\n    bg: 0,\n    fg: 0,\n    bold: false,\n    dim: false,\n    italic: false\n  };\n\n  constructor(\n    private _container: HTMLElement,\n    id: string,\n    zIndex: number,\n    private _alpha: boolean,\n    protected _colors: IColorSet\n  ) {\n    this._canvas = document.createElement('canvas');\n    this._canvas.classList.add(`xterm-${id}-layer`);\n    this._canvas.style.zIndex = zIndex.toString();\n    this._initCanvas();\n    this._container.appendChild(this._canvas);\n  }\n\n  public dispose(): void {\n    this._container.removeChild(this._canvas);\n    if (this._charAtlas) {\n      this._charAtlas.dispose();\n    }\n  }\n\n  private _initCanvas(): void {\n    this._ctx = this._canvas.getContext('2d', {alpha: this._alpha});\n    // Draw the background if this is an opaque layer\n    if (!this._alpha) {\n      this.clearAll();\n    }\n  }\n\n  public onOptionsChanged(terminal: ITerminal): void {}\n  public onBlur(terminal: ITerminal): void {}\n  public onFocus(terminal: ITerminal): void {}\n  public onCursorMove(terminal: ITerminal): void {}\n  public onGridChanged(terminal: ITerminal, startRow: number, endRow: number): void {}\n  public onSelectionChanged(terminal: ITerminal, start: [number, number], end: [number, number], columnSelectMode: boolean = false): void {}\n\n  public onThemeChanged(terminal: ITerminal, colorSet: IColorSet): void {\n    this._refreshCharAtlas(terminal, colorSet);\n  }\n\n  protected setTransparency(terminal: ITerminal, alpha: boolean): void {\n    // Do nothing when alpha doesn't change\n    if (alpha === this._alpha) {\n      return;\n    }\n\n    // Create new canvas and replace old one\n    const oldCanvas = this._canvas;\n    this._alpha = alpha;\n    // Cloning preserves properties\n    this._canvas = <HTMLCanvasElement>this._canvas.cloneNode();\n    this._initCanvas();\n    this._container.replaceChild(this._canvas, oldCanvas);\n\n    // Regenerate char atlas and force a full redraw\n    this._refreshCharAtlas(terminal, this._colors);\n    this.onGridChanged(terminal, 0, terminal.rows - 1);\n  }\n\n  /**\n   * Refreshes the char atlas, aquiring a new one if necessary.\n   * @param terminal The terminal.\n   * @param colorSet The color set to use for the char atlas.\n   */\n  private _refreshCharAtlas(terminal: ITerminal, colorSet: IColorSet): void {\n    if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {\n      return;\n    }\n    this._charAtlas = acquireCharAtlas(terminal, colorSet, this._scaledCharWidth, this._scaledCharHeight);\n    this._charAtlas.warmUp();\n  }\n\n  public resize(terminal: ITerminal, dim: IRenderDimensions): void {\n    this._scaledCellWidth = dim.scaledCellWidth;\n    this._scaledCellHeight = dim.scaledCellHeight;\n    this._scaledCharWidth = dim.scaledCharWidth;\n    this._scaledCharHeight = dim.scaledCharHeight;\n    this._scaledCharLeft = dim.scaledCharLeft;\n    this._scaledCharTop = dim.scaledCharTop;\n    this._canvas.width = dim.scaledCanvasWidth;\n    this._canvas.height = dim.scaledCanvasHeight;\n    this._canvas.style.width = `${dim.canvasWidth}px`;\n    this._canvas.style.height = `${dim.canvasHeight}px`;\n\n    // Draw the background if this is an opaque layer\n    if (!this._alpha) {\n      this.clearAll();\n    }\n\n    this._refreshCharAtlas(terminal, this._colors);\n  }\n\n  public abstract reset(terminal: ITerminal): void;\n\n  /**\n   * Fills 1+ cells completely. This uses the existing fillStyle on the context.\n   * @param x The column to start at.\n   * @param y The row to start at\n   * @param width The number of columns to fill.\n   * @param height The number of rows to fill.\n   */\n  protected fillCells(x: number, y: number, width: number, height: number): void {\n    this._ctx.fillRect(\n        x * this._scaledCellWidth,\n        y * this._scaledCellHeight,\n        width * this._scaledCellWidth,\n        height * this._scaledCellHeight);\n  }\n\n  /**\n   * Fills a 1px line (2px on HDPI) at the bottom of the cell. This uses the\n   * existing fillStyle on the context.\n   * @param x The column to fill.\n   * @param y The row to fill.\n   */\n  protected fillBottomLineAtCells(x: number, y: number, width: number = 1): void {\n    this._ctx.fillRect(\n        x * this._scaledCellWidth,\n        (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */,\n        width * this._scaledCellWidth,\n        window.devicePixelRatio);\n  }\n\n  /**\n   * Fills a 1px line (2px on HDPI) at the left of the cell. This uses the\n   * existing fillStyle on the context.\n   * @param x The column to fill.\n   * @param y The row to fill.\n   */\n  protected fillLeftLineAtCell(x: number, y: number): void {\n    this._ctx.fillRect(\n        x * this._scaledCellWidth,\n        y * this._scaledCellHeight,\n        window.devicePixelRatio,\n        this._scaledCellHeight);\n  }\n\n  /**\n   * Strokes a 1px rectangle (2px on HDPI) around a cell. This uses the existing\n   * strokeStyle on the context.\n   * @param x The column to fill.\n   * @param y The row to fill.\n   */\n  protected strokeRectAtCell(x: number, y: number, width: number, height: number): void {\n    this._ctx.lineWidth = window.devicePixelRatio;\n    this._ctx.strokeRect(\n        x * this._scaledCellWidth + window.devicePixelRatio / 2,\n        y * this._scaledCellHeight + (window.devicePixelRatio / 2),\n        width * this._scaledCellWidth - window.devicePixelRatio,\n        (height * this._scaledCellHeight) - window.devicePixelRatio);\n  }\n\n  /**\n   * Clears the entire canvas.\n   */\n  protected clearAll(): void {\n    if (this._alpha) {\n      this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n    } else {\n      this._ctx.fillStyle = this._colors.background.css;\n      this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n    }\n  }\n\n  /**\n   * Clears 1+ cells completely.\n   * @param x The column to start at.\n   * @param y The row to start at.\n   * @param width The number of columns to clear.\n   * @param height The number of rows to clear.\n   */\n  protected clearCells(x: number, y: number, width: number, height: number): void {\n    if (this._alpha) {\n      this._ctx.clearRect(\n          x * this._scaledCellWidth,\n          y * this._scaledCellHeight,\n          width * this._scaledCellWidth,\n          height * this._scaledCellHeight);\n    } else {\n      this._ctx.fillStyle = this._colors.background.css;\n      this._ctx.fillRect(\n          x * this._scaledCellWidth,\n          y * this._scaledCellHeight,\n          width * this._scaledCellWidth,\n          height * this._scaledCellHeight);\n    }\n  }\n\n  /**\n   * Draws a truecolor character at the cell. The character will be clipped to\n   * ensure that it fits with the cell, including the cell to the right if it's\n   * a wide character. This uses the existing fillStyle on the context.\n   * @param terminal The terminal.\n   * @param cell The cell data for the character to draw.\n   * @param x The column to draw at.\n   * @param y The row to draw at.\n   * @param color The color of the character.\n   */\n  protected fillCharTrueColor(terminal: ITerminal, cell: CellData, x: number, y: number): void {\n    this._ctx.font = this._getFont(terminal, false, false);\n    this._ctx.textBaseline = 'middle';\n    this._clipRow(terminal, y);\n    this._ctx.fillText(\n        cell.getChars(),\n        x * this._scaledCellWidth + this._scaledCharLeft,\n        y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2);\n  }\n\n  /**\n   * Draws one or more characters at a cell. If possible this will draw using\n   * the character atlas to reduce draw time.\n   * @param terminal The terminal.\n   * @param chars The character or characters.\n   * @param code The character code.\n   * @param width The width of the characters.\n   * @param x The column to draw at.\n   * @param y The row to draw at.\n   * @param fg The foreground color, in the format stored within the attributes.\n   * @param bg The background color, in the format stored within the attributes.\n   * This is used to validate whether a cached image can be used.\n   * @param bold Whether the text is bold.\n   */\n  protected drawChars(terminal: ITerminal, cell: ICellData, x: number, y: number): void {\n\n    // skip cache right away if we draw in RGB\n    // Note: to avoid bad runtime JoinedCellData will be skipped\n    //       in the cache handler (atlasDidDraw == false) itself and\n    //       fall through to uncached later down below\n    if (cell.isFgRGB() || cell.isBgRGB() || cell instanceof JoinedCellData) {\n      this._drawUncachedChars(terminal, cell, x, y);\n      return;\n    }\n\n    let fg;\n    let bg;\n    if (cell.isInverse()) {\n      fg = (cell.isBgDefault()) ? INVERTED_DEFAULT_COLOR : cell.getBgColor();\n      bg = (cell.isFgDefault()) ? INVERTED_DEFAULT_COLOR : cell.getFgColor();\n    } else {\n      bg = (cell.isBgDefault()) ? DEFAULT_COLOR : cell.getBgColor();\n      fg = (cell.isFgDefault()) ? DEFAULT_COLOR : cell.getFgColor();\n    }\n\n    const drawInBrightColor = terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8 && fg !== INVERTED_DEFAULT_COLOR;\n\n    fg += drawInBrightColor ? 8 : 0;\n    this._currentGlyphIdentifier.chars = cell.getChars() || WHITESPACE_CELL_CHAR;\n    this._currentGlyphIdentifier.code = cell.getCode() || WHITESPACE_CELL_CODE;\n    this._currentGlyphIdentifier.bg = bg;\n    this._currentGlyphIdentifier.fg = fg;\n    this._currentGlyphIdentifier.bold = cell.isBold() && terminal.options.enableBold;\n    this._currentGlyphIdentifier.dim = !!cell.isDim();\n    this._currentGlyphIdentifier.italic = !!cell.isItalic();\n    const atlasDidDraw = this._charAtlas && this._charAtlas.draw(\n      this._ctx,\n      this._currentGlyphIdentifier,\n      x * this._scaledCellWidth + this._scaledCharLeft,\n      y * this._scaledCellHeight + this._scaledCharTop\n    );\n\n    if (!atlasDidDraw) {\n      this._drawUncachedChars(terminal, cell, x, y);\n    }\n  }\n\n  /**\n   * Draws one or more characters at one or more cells. The character(s) will be\n   * clipped to ensure that they fit with the cell(s), including the cell to the\n   * right if the last character is a wide character.\n   * @param terminal The terminal.\n   * @param chars The character.\n   * @param width The width of the character.\n   * @param fg The foreground color, in the format stored within the attributes.\n   * @param x The column to draw at.\n   * @param y The row to draw at.\n   */\n  private _drawUncachedChars(terminal: ITerminal, cell: ICellData, x: number, y: number): void {\n    this._ctx.save();\n    this._ctx.font = this._getFont(terminal, cell.isBold() && terminal.options.enableBold, !!cell.isItalic());\n    this._ctx.textBaseline = 'middle';\n\n    if (cell.isInverse()) {\n      if (cell.isBgDefault()) {\n        this._ctx.fillStyle = this._colors.background.css;\n      } else if (cell.isBgRGB()) {\n        this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;\n      } else {\n        this._ctx.fillStyle = this._colors.ansi[cell.getBgColor()].css;\n      }\n    } else {\n      if (cell.isFgDefault()) {\n        this._ctx.fillStyle = this._colors.foreground.css;\n      } else if (cell.isFgRGB()) {\n        this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;\n      } else {\n        let fg = cell.getFgColor();\n        if (terminal.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {\n          fg += 8;\n        }\n        this._ctx.fillStyle = this._colors.ansi[fg].css;\n      }\n    }\n\n    this._clipRow(terminal, y);\n\n    // Apply alpha to dim the character\n    if (cell.isDim()) {\n      this._ctx.globalAlpha = DIM_OPACITY;\n    }\n    // Draw the character\n    this._ctx.fillText(\n        cell.getChars(),\n        x * this._scaledCellWidth + this._scaledCharLeft,\n        y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2);\n    this._ctx.restore();\n  }\n\n  /**\n   * Clips a row to ensure no pixels will be drawn outside the cells in the row.\n   * @param terminal The terminal.\n   * @param y The row to clip.\n   */\n  private _clipRow(terminal: ITerminal, y: number): void {\n    this._ctx.beginPath();\n    this._ctx.rect(\n        0,\n        y * this._scaledCellHeight,\n        terminal.cols * this._scaledCellWidth,\n        this._scaledCellHeight);\n    this._ctx.clip();\n  }\n\n  /**\n   * Gets the current font.\n   * @param terminal The terminal.\n   * @param isBold If we should use the bold fontWeight.\n   */\n  protected _getFont(terminal: ITerminal, isBold: boolean, isItalic: boolean): string {\n    const fontWeight = isBold ? terminal.options.fontWeightBold : terminal.options.fontWeight;\n    const fontStyle = isItalic ? 'italic' : '';\n\n    return `${fontStyle} ${fontWeight} ${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;\n  }\n}\n\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings } from 'xterm';\nimport { ITerminal } from '../Types';\nimport { Terminal as TerminalCore } from '../Terminal';\nimport * as Strings from '../Strings';\nimport { IEvent } from '../common/EventEmitter2';\n\nexport class Terminal implements ITerminalApi {\n  private _core: ITerminal;\n\n  constructor(options?: ITerminalOptions) {\n    this._core = new TerminalCore(options);\n  }\n\n  public get onCursorMove(): IEvent<void> { return this._core.onCursorMove; }\n  public get onLineFeed(): IEvent<void> { return this._core.onLineFeed; }\n  public get onSelectionChange(): IEvent<void> { return this._core.onSelectionChange; }\n  public get onData(): IEvent<string> { return this._core.onData; }\n  public get onTitleChange(): IEvent<string> { return this._core.onTitleChange; }\n  public get onScroll(): IEvent<number> { return this._core.onScroll; }\n  public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; }\n  public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }\n\n  public get element(): HTMLElement { return this._core.element; }\n  public get textarea(): HTMLTextAreaElement { return this._core.textarea; }\n  public get rows(): number { return this._core.rows; }\n  public get cols(): number { return this._core.cols; }\n  public get markers(): ReadonlyArray<IMarker> { return this._core.markers; }\n  public blur(): void {\n    this._core.blur();\n  }\n  public focus(): void {\n    this._core.focus();\n  }\n  public on(type: 'blur' | 'focus' | 'linefeed' | 'selection', listener: () => void): void;\n  public on(type: 'data', listener: (...args: any[]) => void): void;\n  public on(type: 'key', listener: (key?: string, event?: KeyboardEvent) => void): void;\n  public on(type: 'keypress' | 'keydown', listener: (event?: KeyboardEvent) => void): void;\n  public on(type: 'refresh', listener: (data?: { start: number; end: number; }) => void): void;\n  public on(type: 'resize', listener: (data?: { cols: number; rows: number; }) => void): void;\n  public on(type: 'scroll', listener: (ydisp?: number) => void): void;\n  public on(type: 'title', listener: (title?: string) => void): void;\n  public on(type: string, listener: (...args: any[]) => void): void;\n  public on(type: any, listener: any): void {\n    this._core.on(type, listener);\n  }\n  public off(type: string, listener: (...args: any[]) => void): void {\n    this._core.off(type, listener);\n  }\n  public emit(type: string, data?: any): void {\n    this._core.emit(type, data);\n  }\n  public addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable {\n    return this._core.addDisposableListener(type, handler);\n  }\n  public resize(columns: number, rows: number): void {\n    this._core.resize(columns, rows);\n  }\n  public writeln(data: string): void {\n    this._core.writeln(data);\n  }\n  public open(parent: HTMLElement): void {\n    this._core.open(parent);\n  }\n  public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {\n    this._core.attachCustomKeyEventHandler(customKeyEventHandler);\n  }\n  public addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable {\n    return this._core.addCsiHandler(flag, callback);\n  }\n  public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    return this._core.addOscHandler(ident, callback);\n  }\n  public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number {\n    return this._core.registerLinkMatcher(regex, handler, options);\n  }\n  public deregisterLinkMatcher(matcherId: number): void {\n    this._core.deregisterLinkMatcher(matcherId);\n  }\n  public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {\n    return this._core.registerCharacterJoiner(handler);\n  }\n  public deregisterCharacterJoiner(joinerId: number): void {\n    this._core.deregisterCharacterJoiner(joinerId);\n  }\n  public addMarker(cursorYOffset: number): IMarker {\n    return this._core.addMarker(cursorYOffset);\n  }\n  public hasSelection(): boolean {\n    return this._core.hasSelection();\n  }\n  public getSelection(): string {\n    return this._core.getSelection();\n  }\n  public clearSelection(): void {\n    this._core.clearSelection();\n  }\n  public selectAll(): void {\n    this._core.selectAll();\n  }\n  public selectLines(start: number, end: number): void {\n    this._core.selectLines(start, end);\n  }\n  public dispose(): void {\n    this._core.dispose();\n  }\n  public destroy(): void {\n    this._core.destroy();\n  }\n  public scrollLines(amount: number): void {\n    this._core.scrollLines(amount);\n  }\n  public scrollPages(pageCount: number): void {\n    this._core.scrollPages(pageCount);\n  }\n  public scrollToTop(): void {\n    this._core.scrollToTop();\n  }\n  public scrollToBottom(): void {\n    this._core.scrollToBottom();\n  }\n  public scrollToLine(line: number): void {\n    this._core.scrollToLine(line);\n  }\n  public clear(): void {\n    this._core.clear();\n  }\n  public write(data: string): void {\n    this._core.write(data);\n  }\n  public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'rendererType' | 'termName'): string;\n  public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;\n  public getOption(key: 'colors'): string[];\n  public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;\n  public getOption(key: 'handler'): (data: string) => void;\n  public getOption(key: string): any;\n  public getOption(key: any): any {\n    return this._core.getOption(key);\n  }\n  public setOption(key: 'bellSound' | 'fontFamily' | 'termName', value: string): void;\n  public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'): void;\n  public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;\n  public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;\n  public setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell', value: boolean): void;\n  public setOption(key: 'colors', value: string[]): void;\n  public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;\n  public setOption(key: 'handler', value: (data: string) => void): void;\n  public setOption(key: 'theme', value: ITheme): void;\n  public setOption(key: 'cols' | 'rows', value: number): void;\n  public setOption(key: string, value: any): void;\n  public setOption(key: any, value: any): void {\n    this._core.setOption(key, value);\n  }\n  public refresh(start: number, end: number): void {\n    this._core.refresh(start, end);\n  }\n  public reset(): void {\n    this._core.reset();\n  }\n  public static applyAddon(addon: any): void {\n    addon.apply(Terminal);\n  }\n  public static get strings(): ILocalizableStrings {\n    return Strings;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal, IBufferLine } from '../Types';\nimport { ICircularList } from '../common/Types';\nimport { C0 } from '../common/data/EscapeSequences';\n\nconst enum Direction {\n  UP = 'A',\n  DOWN = 'B',\n  RIGHT = 'C',\n  LEFT = 'D'\n}\n\nexport class AltClickHandler {\n  private _startRow: number;\n  private _startCol: number;\n  private _endRow: number;\n  private _endCol: number;\n  private _lines: ICircularList<IBufferLine>;\n\n  constructor(\n    private _mouseEvent: MouseEvent,\n    private _terminal: ITerminal\n  ) {\n    this._lines = this._terminal.buffer.lines;\n    this._startCol = this._terminal.buffer.x;\n    this._startRow = this._terminal.buffer.y;\n\n    const coordinates = this._terminal.mouseHelper.getCoords(\n      this._mouseEvent,\n      this._terminal.element,\n      this._terminal.charMeasure,\n      this._terminal.cols,\n      this._terminal.rows,\n      false\n    );\n\n    if (coordinates) {\n      [this._endCol, this._endRow] = coordinates.map((coordinate: number) => {\n        return coordinate - 1;\n      });\n    }\n  }\n\n  /**\n   * Writes the escape sequences of arrows to the terminal\n   */\n  public move(): void {\n    if (this._mouseEvent.altKey && this._endCol !== undefined && this._endRow !== undefined) {\n      this._terminal.handler(this._arrowSequences());\n    }\n  }\n\n  /**\n   * Concatenates all the arrow sequences together.\n   * Resets the starting row to an unwrapped row, moves to the requested row,\n   * then moves to requested col.\n   */\n  private _arrowSequences(): string {\n    // The alt buffer should try to navigate between rows\n    if (!this._terminal.buffer.hasScrollback) {\n      return this._resetStartingRow() + this._moveToRequestedRow() + this._moveToRequestedCol();\n    }\n\n    // Only move horizontally for the normal buffer\n    return this._moveHorizontallyOnly();\n  }\n\n  /**\n   * If the initial position of the cursor is on a row that is wrapped, move the\n   * cursor up to the first row that is not wrapped to have accurate vertical\n   * positioning.\n   */\n  private _resetStartingRow(): string {\n    if (this._moveToRequestedRow().length === 0) {\n      return '';\n    }\n    return repeat(this._bufferLine(\n      this._startCol, this._startRow, this._startCol,\n      this._startRow - this._wrappedRowsForRow(this._startRow), false\n    ).length, this._sequence(Direction.LEFT));\n  }\n\n  /**\n   * Using the reset starting and ending row, move to the requested row,\n   * ignoring wrapped rows\n   */\n  private _moveToRequestedRow(): string {\n    const startRow = this._startRow - this._wrappedRowsForRow(this._startRow);\n    const endRow = this._endRow - this._wrappedRowsForRow(this._endRow);\n\n    const rowsToMove = Math.abs(startRow - endRow) - this._wrappedRowsCount();\n\n    return repeat(rowsToMove, this._sequence(this._verticalDirection()));\n  }\n\n  /**\n   * Move to the requested col on the ending row\n   */\n  private _moveToRequestedCol(): string {\n    let startRow;\n    if (this._moveToRequestedRow().length > 0) {\n      startRow = this._endRow - this._wrappedRowsForRow(this._endRow);\n    } else {\n      startRow = this._startRow;\n    }\n\n    const endRow = this._endRow;\n    const direction = this._horizontalDirection();\n\n    return repeat(this._bufferLine(\n      this._startCol, startRow, this._endCol, endRow,\n      direction === Direction.RIGHT\n    ).length, this._sequence(direction));\n  }\n\n  private _moveHorizontallyOnly(): string {\n    const direction = this._horizontalDirection();\n    return repeat(Math.abs(this._startCol - this._endCol), this._sequence(direction));\n  }\n\n  /**\n   * Utility functions\n   */\n\n  /**\n   * Calculates the number of wrapped rows between the unwrapped starting and\n   * ending rows. These rows need to ignored since the cursor skips over them.\n   */\n  private _wrappedRowsCount(): number {\n    let wrappedRows = 0;\n    const startRow = this._startRow - this._wrappedRowsForRow(this._startRow);\n    const endRow = this._endRow - this._wrappedRowsForRow(this._endRow);\n\n    for (let i = 0; i < Math.abs(startRow - endRow); i++) {\n      const direction = this._verticalDirection() === Direction.UP ? -1 : 1;\n\n      if (this._lines.get(startRow + (direction * i)).isWrapped) {\n        wrappedRows++;\n      }\n    }\n\n    return wrappedRows;\n  }\n\n  /**\n   * Calculates the number of wrapped rows that make up a given row.\n   * @param currentRow The row to determine how many wrapped rows make it up\n   */\n  private _wrappedRowsForRow(currentRow: number): number {\n    let rowCount = 0;\n    let lineWraps = this._lines.get(currentRow).isWrapped;\n\n    while (lineWraps && currentRow >= 0 && currentRow < this._terminal.rows) {\n      rowCount++;\n      currentRow--;\n      lineWraps = this._lines.get(currentRow).isWrapped;\n    }\n\n    return rowCount;\n  }\n\n  /**\n   * Direction determiners\n   */\n\n  /**\n   * Determines if the right or left arrow is needed\n   */\n  private _horizontalDirection(): Direction {\n    let startRow;\n    if (this._moveToRequestedRow().length > 0) {\n      startRow = this._endRow - this._wrappedRowsForRow(this._endRow);\n    } else {\n      startRow = this._startRow;\n    }\n\n    if ((this._startCol < this._endCol &&\n      startRow <= this._endRow) || // down/right or same y/right\n      (this._startCol >= this._endCol &&\n      startRow < this._endRow)) {  // down/left or same y/left\n      return Direction.RIGHT;\n    }\n    return Direction.LEFT;\n  }\n\n  /**\n   * Determines if the up or down arrow is needed\n   */\n  private _verticalDirection(): Direction {\n    if (this._startRow > this._endRow) {\n      return Direction.UP;\n    }\n    return Direction.DOWN;\n  }\n\n  /**\n   * Constructs the string of chars in the buffer from a starting row and col\n   * to an ending row and col\n   * @param startCol The starting column position\n   * @param startRow The starting row position\n   * @param endCol The ending column position\n   * @param endRow The ending row position\n   * @param forward Direction to move\n   */\n  private _bufferLine(\n    startCol: number,\n    startRow: number,\n    endCol: number,\n    endRow: number,\n    forward: boolean\n  ): string {\n    let currentCol = startCol;\n    let currentRow = startRow;\n    let bufferStr = '';\n\n    while (currentCol !== endCol || currentRow !== endRow) {\n      currentCol += forward ? 1 : -1;\n\n      if (forward && currentCol > this._terminal.cols - 1) {\n        bufferStr += this._terminal.buffer.translateBufferLineToString(\n          currentRow, false, startCol, currentCol\n        );\n        currentCol = 0;\n        startCol = 0;\n        currentRow++;\n      } else if (!forward && currentCol < 0) {\n        bufferStr += this._terminal.buffer.translateBufferLineToString(\n          currentRow, false, 0, startCol + 1\n        );\n        currentCol = this._terminal.cols - 1;\n        startCol = currentCol;\n        currentRow--;\n      }\n    }\n\n    return bufferStr + this._terminal.buffer.translateBufferLineToString(\n      currentRow, false, startCol, currentCol\n    );\n  }\n\n  /**\n   * Constructs the escape sequence for clicking an arrow\n   * @param direction The direction to move\n   */\n  private _sequence(direction: Direction): string {\n    const mod = this._terminal.applicationCursor ? 'O' : '[';\n    return C0.ESC + mod + direction;\n  }\n}\n\n/**\n * Returns a string repeated a given number of times\n * Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat\n * @param count The number of times to repeat the string\n * @param string The string that is to be repeated\n */\nfunction repeat(count: number, str: string): string {\n  count = Math.floor(count);\n  let rpt = '';\n  for (let i = 0; i < count; i++) {\n    rpt += str;\n  }\n  return rpt;\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/**\n * StringToUtf32 - decodes UTF16 sequences into UTF32 codepoints.\n * To keep the decoder in line with JS strings it handles single surrogates as UCS2.\n */\nexport class StringToUtf32 {\n  private _interim: number = 0;\n\n  /**\n   * Clears interim and resets decoder to clean state.\n   */\n  public clear(): void {\n    this._interim = 0;\n  }\n\n  /**\n   * Decode JS string to UTF32 codepoints.\n   * The methods assumes stream input and will store partly transmitted\n   * surrogate pairs and decode them with the next data chunk.\n   * Note: The method does no bound checks for target, therefore make sure\n   * the provided input data does not exceed the size of `target`.\n   * Returns the number of written codepoints in `target`.\n   */\n  decode(input: string, target: Uint32Array): number {\n    const length = input.length;\n\n    if (!length) {\n      return 0;\n    }\n\n    let size = 0;\n    let startPos = 0;\n\n    // handle leftover surrogate high\n    if (this._interim) {\n      const second = input.charCodeAt(startPos++);\n      if (0xDC00 <= second && second <= 0xDFFF) {\n        target[size++] = (this._interim - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n      } else {\n        // illegal codepoint (USC2 handling)\n        target[size++] = this._interim;\n        target[size++] = second;\n      }\n      this._interim = 0;\n    }\n\n    for (let i = startPos; i < length; ++i) {\n      const code = input.charCodeAt(i);\n      // surrogate pair first\n      if (0xD800 <= code && code <= 0xDBFF) {\n        if (++i >= length) {\n          this._interim = code;\n          return size;\n        }\n        const second = input.charCodeAt(i);\n        if (0xDC00 <= second && second <= 0xDFFF) {\n          target[size++] = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n        } else {\n          // illegal codepoint (USC2 handling)\n          target[size++] = code;\n          target[size++] = second;\n        }\n        continue;\n      }\n      target[size++] = code;\n    }\n    return size;\n  }\n}\n\n/**\n * Convert UTF32 codepoint into JS string.\n */\nexport function stringFromCodePoint(codePoint: number): string {\n  if (codePoint > 0xFFFF) {\n    // UTF32 to UTF16 conversion (see comments in utf32ToString)\n    codePoint -= 0x10000;\n    return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);\n  }\n  return String.fromCharCode(codePoint);\n}\n\n/**\n * Convert UTF32 char codes into JS string.\n * Basically the same as `stringFromCodePoint` but for multiple codepoints\n * in a loop (which is a lot faster).\n */\nexport function utf32ToString(data: Uint32Array, start: number = 0, end: number = data.length): string {\n  let result = '';\n  for (let i = start; i < end; ++i) {\n    let codepoint = data[i];\n    if (codepoint > 0xFFFF) {\n      // JS string are encoded as UTF16, thus a non BMP codepoint gets converted into a surrogate pair\n      // conversion rules:\n      //  - subtract 0x10000 from code point, leaving a 20 bit number\n      //  - add high 10 bits to 0xD800  --> first surrogate\n      //  - add low 10 bits to 0xDC00   --> second surrogate\n      codepoint -= 0x10000;\n      result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);\n    } else {\n      result += String.fromCharCode(codepoint);\n    }\n  }\n  return result;\n}\n","/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n */\n\nimport { IKeyboardEvent } from '../../common/Types';\nimport { IKeyboardResult, KeyboardResultType } from '../Types';\nimport { C0 } from '../../common/data/EscapeSequences';\n\n// reg + shift key mappings for digits and special chars\nconst KEYCODE_KEY_MAPPINGS: { [key: number]: [string, string]} = {\n  // digits 0-9\n  48: ['0', ')'],\n  49: ['1', '!'],\n  50: ['2', '@'],\n  51: ['3', '#'],\n  52: ['4', '$'],\n  53: ['5', '%'],\n  54: ['6', '^'],\n  55: ['7', '&'],\n  56: ['8', '*'],\n  57: ['9', '('],\n\n  // special chars\n  186: [';', ':'],\n  187: ['=', '+'],\n  188: [',', '<'],\n  189: ['-', '_'],\n  190: ['.', '>'],\n  191: ['/', '?'],\n  192: ['`', '~'],\n  219: ['[', '{'],\n  220: ['\\\\', '|'],\n  221: [']', '}'],\n  222: ['\\'', '\"']\n};\n\nexport function evaluateKeyboardEvent(\n  ev: IKeyboardEvent,\n  applicationCursorMode: boolean,\n  isMac: boolean,\n  macOptionIsMeta: boolean\n): IKeyboardResult {\n  const result: IKeyboardResult = {\n    type: KeyboardResultType.SEND_KEY,\n    // Whether to cancel event propagation (NOTE: this may not be needed since the event is\n    // canceled at the end of keyDown\n    cancel: false,\n    // The new key even to emit\n    key: undefined\n  };\n  const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);\n  switch (ev.keyCode) {\n    case 0:\n      if (ev.key === 'UIKeyInputUpArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OA';\n        } else {\n          result.key = C0.ESC + '[A';\n        }\n      }\n      else if (ev.key === 'UIKeyInputLeftArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OD';\n        } else {\n          result.key = C0.ESC + '[D';\n        }\n      }\n      else if (ev.key === 'UIKeyInputRightArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OC';\n        } else {\n          result.key = C0.ESC + '[C';\n        }\n      }\n      else if (ev.key === 'UIKeyInputDownArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OB';\n        } else {\n          result.key = C0.ESC + '[B';\n        }\n      }\n      break;\n    case 8:\n      // backspace\n      if (ev.shiftKey) {\n        result.key = C0.BS; // ^H\n        break;\n      } else if (ev.altKey) {\n        result.key = C0.ESC + C0.DEL; // \\e ^?\n        break;\n      }\n      result.key = C0.DEL; // ^?\n      break;\n    case 9:\n      // tab\n      if (ev.shiftKey) {\n        result.key = C0.ESC + '[Z';\n        break;\n      }\n      result.key = C0.HT;\n      result.cancel = true;\n      break;\n    case 13:\n      // return/enter\n      result.key = C0.CR;\n      result.cancel = true;\n      break;\n    case 27:\n      // escape\n      result.key = C0.ESC;\n      result.cancel = true;\n      break;\n    case 37:\n      // left-arrow\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'D';\n        // HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards\n        // http://unix.stackexchange.com/a/108106\n        // macOS uses different escape sequences than linux\n        if (result.key === C0.ESC + '[1;3D') {\n          result.key = isMac ? C0.ESC + 'b' : C0.ESC + '[1;5D';\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OD';\n      } else {\n        result.key = C0.ESC + '[D';\n      }\n      break;\n    case 39:\n      // right-arrow\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'C';\n        // HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward\n        // http://unix.stackexchange.com/a/108106\n        // macOS uses different escape sequences than linux\n        if (result.key === C0.ESC + '[1;3C') {\n          result.key = isMac ? C0.ESC + 'f' : C0.ESC + '[1;5C';\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OC';\n      } else {\n        result.key = C0.ESC + '[C';\n      }\n      break;\n    case 38:\n      // up-arrow\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'A';\n        // HACK: Make Alt + up-arrow behave like Ctrl + up-arrow\n        // http://unix.stackexchange.com/a/108106\n        if (result.key === C0.ESC + '[1;3A') {\n          result.key = C0.ESC + '[1;5A';\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OA';\n      } else {\n        result.key = C0.ESC + '[A';\n      }\n      break;\n    case 40:\n      // down-arrow\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'B';\n        // HACK: Make Alt + down-arrow behave like Ctrl + down-arrow\n        // http://unix.stackexchange.com/a/108106\n        if (result.key === C0.ESC + '[1;3B') {\n          result.key = C0.ESC + '[1;5B';\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OB';\n      } else {\n        result.key = C0.ESC + '[B';\n      }\n      break;\n    case 45:\n      // insert\n      if (!ev.shiftKey && !ev.ctrlKey) {\n        // <Ctrl> or <Shift> + <Insert> are used to\n        // copy-paste on some systems.\n        result.key = C0.ESC + '[2~';\n      }\n      break;\n    case 46:\n      // delete\n      if (modifiers) {\n        result.key = C0.ESC + '[3;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[3~';\n      }\n      break;\n    case 36:\n      // home\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'H';\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OH';\n      } else {\n        result.key = C0.ESC + '[H';\n      }\n      break;\n    case 35:\n      // end\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'F';\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OF';\n      } else {\n        result.key = C0.ESC + '[F';\n      }\n      break;\n    case 33:\n      // page up\n      if (ev.shiftKey) {\n        result.type = KeyboardResultType.PAGE_UP;\n      } else {\n        result.key = C0.ESC + '[5~';\n      }\n      break;\n    case 34:\n      // page down\n      if (ev.shiftKey) {\n        result.type = KeyboardResultType.PAGE_DOWN;\n      } else {\n        result.key = C0.ESC + '[6~';\n      }\n      break;\n    case 112:\n      // F1-F12\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'P';\n      } else {\n        result.key = C0.ESC + 'OP';\n      }\n      break;\n    case 113:\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'Q';\n      } else {\n        result.key = C0.ESC + 'OQ';\n      }\n      break;\n    case 114:\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'R';\n      } else {\n        result.key = C0.ESC + 'OR';\n      }\n      break;\n    case 115:\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'S';\n      } else {\n        result.key = C0.ESC + 'OS';\n      }\n      break;\n    case 116:\n      if (modifiers) {\n        result.key = C0.ESC + '[15;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[15~';\n      }\n      break;\n    case 117:\n      if (modifiers) {\n        result.key = C0.ESC + '[17;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[17~';\n      }\n      break;\n    case 118:\n      if (modifiers) {\n        result.key = C0.ESC + '[18;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[18~';\n      }\n      break;\n    case 119:\n      if (modifiers) {\n        result.key = C0.ESC + '[19;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[19~';\n      }\n      break;\n    case 120:\n      if (modifiers) {\n        result.key = C0.ESC + '[20;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[20~';\n      }\n      break;\n    case 121:\n      if (modifiers) {\n        result.key = C0.ESC + '[21;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[21~';\n      }\n      break;\n    case 122:\n      if (modifiers) {\n        result.key = C0.ESC + '[23;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[23~';\n      }\n      break;\n    case 123:\n      if (modifiers) {\n        result.key = C0.ESC + '[24;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[24~';\n      }\n      break;\n    default:\n      // a-z and space\n      if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {\n        if (ev.keyCode >= 65 && ev.keyCode <= 90) {\n          result.key = String.fromCharCode(ev.keyCode - 64);\n        } else if (ev.keyCode === 32) {\n          // NUL\n          result.key = String.fromCharCode(0);\n        } else if (ev.keyCode >= 51 && ev.keyCode <= 55) {\n          // escape, file sep, group sep, record sep, unit sep\n          result.key = String.fromCharCode(ev.keyCode - 51 + 27);\n        } else if (ev.keyCode === 56) {\n          // delete\n          result.key = String.fromCharCode(127);\n        } else if (ev.keyCode === 219) {\n          // ^[ - Control Sequence Introducer (CSI)\n          result.key = String.fromCharCode(27);\n        } else if (ev.keyCode === 220) {\n          // ^\\ - String Terminator (ST)\n          result.key = String.fromCharCode(28);\n        } else if (ev.keyCode === 221) {\n          // ^] - Operating System Command (OSC)\n          result.key = String.fromCharCode(29);\n        }\n      } else if ((!isMac || macOptionIsMeta) && ev.altKey && !ev.metaKey) {\n        // On macOS this is a third level shift when !macOptionIsMeta. Use <Esc> instead.\n        const keyMapping = KEYCODE_KEY_MAPPINGS[ev.keyCode];\n        const key = keyMapping && keyMapping[!ev.shiftKey ? 0 : 1];\n        if (key) {\n          result.key = C0.ESC + key;\n        } else if (ev.keyCode >= 65 && ev.keyCode <= 90) {\n          const keyCode = ev.ctrlKey ? ev.keyCode - 64 : ev.keyCode + 32;\n          result.key = C0.ESC + String.fromCharCode(keyCode);\n        }\n      } else if (isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {\n        if (ev.keyCode === 65) { // cmd + a\n          result.type = KeyboardResultType.SELECT_ALL;\n        }\n      } else if (ev.key && !ev.ctrlKey && !ev.altKey && !ev.metaKey && ev.keyCode >= 48 && ev.key.length === 1) {\n        // Include only keys that that result in a _single_ character; don't include num lock, volume up, etc.\n        result.key = ev.key;\n      } else if (ev.key && ev.ctrlKey) {\n        if (ev.key === '_') { // ^_\n          result.key = C0.US;\n        }\n      }\n      break;\n  }\n\n  return result;\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharset } from '../Types';\n\n/**\n * The character sets supported by the terminal. These enable several languages\n * to be represented within the terminal with only 8-bit encoding. See ISO 2022\n * for a discussion on character sets. Only VT100 character sets are supported.\n */\nexport const CHARSETS: { [key: string]: ICharset | null } = {};\n\n/**\n * The default character set, US.\n */\nexport const DEFAULT_CHARSET: ICharset | null = CHARSETS['B'];\n\n/**\n * DEC Special Character and Line Drawing Set.\n * Reference: http://vt100.net/docs/vt102-ug/table5-13.html\n * A lot of curses apps use this if they see TERM=xterm.\n * testing: echo -e '\\e(0a\\e(B'\n * The xterm output sometimes seems to conflict with the\n * reference above. xterm seems in line with the reference\n * when running vttest however.\n * The table below now uses xterm's output from vttest.\n */\nCHARSETS['0'] = {\n  '`': '\\u25c6', // '◆'\n  'a': '\\u2592', // '▒'\n  'b': '\\u0009', // '\\t'\n  'c': '\\u000c', // '\\f'\n  'd': '\\u000d', // '\\r'\n  'e': '\\u000a', // '\\n'\n  'f': '\\u00b0', // '°'\n  'g': '\\u00b1', // '±'\n  'h': '\\u2424', // '\\u2424' (NL)\n  'i': '\\u000b', // '\\v'\n  'j': '\\u2518', // '┘'\n  'k': '\\u2510', // '┐'\n  'l': '\\u250c', // '┌'\n  'm': '\\u2514', // '└'\n  'n': '\\u253c', // '┼'\n  'o': '\\u23ba', // '⎺'\n  'p': '\\u23bb', // '⎻'\n  'q': '\\u2500', // '─'\n  'r': '\\u23bc', // '⎼'\n  's': '\\u23bd', // '⎽'\n  't': '\\u251c', // '├'\n  'u': '\\u2524', // '┤'\n  'v': '\\u2534', // '┴'\n  'w': '\\u252c', // '┬'\n  'x': '\\u2502', // '│'\n  'y': '\\u2264', // '≤'\n  'z': '\\u2265', // '≥'\n  '{': '\\u03c0', // 'π'\n  '|': '\\u2260', // '≠'\n  '}': '\\u00a3', // '£'\n  '~': '\\u00b7'  // '·'\n};\n\n/**\n * British character set\n * ESC (A\n * Reference: http://vt100.net/docs/vt220-rm/table2-5.html\n */\nCHARSETS['A'] = {\n  '#': '£'\n};\n\n/**\n * United States character set\n * ESC (B\n */\nCHARSETS['B'] = null;\n\n/**\n * Dutch character set\n * ESC (4\n * Reference: http://vt100.net/docs/vt220-rm/table2-6.html\n */\nCHARSETS['4'] = {\n  '#': '£',\n  '@': '¾',\n  '[': 'ij',\n  '\\\\': '½',\n  ']': '|',\n  '{': '¨',\n  '|': 'f',\n  '}': '¼',\n  '~': '´'\n};\n\n/**\n * Finnish character set\n * ESC (C or ESC (5\n * Reference: http://vt100.net/docs/vt220-rm/table2-7.html\n */\nCHARSETS['C'] =\nCHARSETS['5'] = {\n  '[': 'Ä',\n  '\\\\': 'Ö',\n  ']': 'Å',\n  '^': 'Ü',\n  '`': 'é',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'å',\n  '~': 'ü'\n};\n\n/**\n * French character set\n * ESC (R\n * Reference: http://vt100.net/docs/vt220-rm/table2-8.html\n */\nCHARSETS['R'] = {\n  '#': '£',\n  '@': 'à',\n  '[': '°',\n  '\\\\': 'ç',\n  ']': '§',\n  '{': 'é',\n  '|': 'ù',\n  '}': 'è',\n  '~': '¨'\n};\n\n/**\n * French Canadian character set\n * ESC (Q\n * Reference: http://vt100.net/docs/vt220-rm/table2-9.html\n */\nCHARSETS['Q'] = {\n  '@': 'à',\n  '[': 'â',\n  '\\\\': 'ç',\n  ']': 'ê',\n  '^': 'î',\n  '`': 'ô',\n  '{': 'é',\n  '|': 'ù',\n  '}': 'è',\n  '~': 'û'\n};\n\n/**\n * German character set\n * ESC (K\n * Reference: http://vt100.net/docs/vt220-rm/table2-10.html\n */\nCHARSETS['K'] = {\n  '@': '§',\n  '[': 'Ä',\n  '\\\\': 'Ö',\n  ']': 'Ü',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'ü',\n  '~': 'ß'\n};\n\n/**\n * Italian character set\n * ESC (Y\n * Reference: http://vt100.net/docs/vt220-rm/table2-11.html\n */\nCHARSETS['Y'] = {\n  '#': '£',\n  '@': '§',\n  '[': '°',\n  '\\\\': 'ç',\n  ']': 'é',\n  '`': 'ù',\n  '{': 'à',\n  '|': 'ò',\n  '}': 'è',\n  '~': 'ì'\n};\n\n/**\n * Norwegian/Danish character set\n * ESC (E or ESC (6\n * Reference: http://vt100.net/docs/vt220-rm/table2-12.html\n */\nCHARSETS['E'] =\nCHARSETS['6'] = {\n  '@': 'Ä',\n  '[': 'Æ',\n  '\\\\': 'Ø',\n  ']': 'Å',\n  '^': 'Ü',\n  '`': 'ä',\n  '{': 'æ',\n  '|': 'ø',\n  '}': 'å',\n  '~': 'ü'\n};\n\n/**\n * Spanish character set\n * ESC (Z\n * Reference: http://vt100.net/docs/vt220-rm/table2-13.html\n */\nCHARSETS['Z'] = {\n  '#': '£',\n  '@': '§',\n  '[': '¡',\n  '\\\\': 'Ñ',\n  ']': '¿',\n  '{': '°',\n  '|': 'ñ',\n  '}': 'ç'\n};\n\n/**\n * Swedish character set\n * ESC (H or ESC (7\n * Reference: http://vt100.net/docs/vt220-rm/table2-14.html\n */\nCHARSETS['H'] =\nCHARSETS['7'] = {\n  '@': 'É',\n  '[': 'Ä',\n  '\\\\': 'Ö',\n  ']': 'Å',\n  '^': 'Ü',\n  '`': 'é',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'å',\n  '~': 'ü'\n};\n\n/**\n * Swiss character set\n * ESC (=\n * Reference: http://vt100.net/docs/vt220-rm/table2-15.html\n */\nCHARSETS['='] = {\n  '#': 'ù',\n  '@': 'à',\n  '[': 'é',\n  '\\\\': 'ç',\n  ']': 'ê',\n  '^': 'î',\n  '_': 'è',\n  '`': 'ô',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'ü',\n  '~': 'û'\n};\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/**\n * C0 control codes\n * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes\n */\nexport namespace C0 {\n  /** Null (Caret = ^@, C = \\0) */\n  export const NUL = '\\x00';\n  /** Start of Heading (Caret = ^A) */\n  export const SOH = '\\x01';\n  /** Start of Text (Caret = ^B) */\n  export const STX = '\\x02';\n  /** End of Text (Caret = ^C) */\n  export const ETX = '\\x03';\n  /** End of Transmission (Caret = ^D) */\n  export const EOT = '\\x04';\n  /** Enquiry (Caret = ^E) */\n  export const ENQ = '\\x05';\n  /** Acknowledge (Caret = ^F) */\n  export const ACK = '\\x06';\n  /** Bell (Caret = ^G, C = \\a) */\n  export const BEL = '\\x07';\n  /** Backspace (Caret = ^H, C = \\b) */\n  export const BS  = '\\x08';\n  /** Character Tabulation, Horizontal Tabulation (Caret = ^I, C = \\t) */\n  export const HT  = '\\x09';\n  /** Line Feed (Caret = ^J, C = \\n) */\n  export const LF  = '\\x0a';\n  /** Line Tabulation, Vertical Tabulation (Caret = ^K, C = \\v) */\n  export const VT  = '\\x0b';\n  /** Form Feed (Caret = ^L, C = \\f) */\n  export const FF  = '\\x0c';\n  /** Carriage Return (Caret = ^M, C = \\r) */\n  export const CR  = '\\x0d';\n  /** Shift Out (Caret = ^N) */\n  export const SO  = '\\x0e';\n  /** Shift In (Caret = ^O) */\n  export const SI  = '\\x0f';\n  /** Data Link Escape (Caret = ^P) */\n  export const DLE = '\\x10';\n  /** Device Control One (XON) (Caret = ^Q) */\n  export const DC1 = '\\x11';\n  /** Device Control Two (Caret = ^R) */\n  export const DC2 = '\\x12';\n  /** Device Control Three (XOFF) (Caret = ^S) */\n  export const DC3 = '\\x13';\n  /** Device Control Four (Caret = ^T) */\n  export const DC4 = '\\x14';\n  /** Negative Acknowledge (Caret = ^U) */\n  export const NAK = '\\x15';\n  /** Synchronous Idle (Caret = ^V) */\n  export const SYN = '\\x16';\n  /** End of Transmission Block (Caret = ^W) */\n  export const ETB = '\\x17';\n  /** Cancel (Caret = ^X) */\n  export const CAN = '\\x18';\n  /** End of Medium (Caret = ^Y) */\n  export const EM  = '\\x19';\n  /** Substitute (Caret = ^Z) */\n  export const SUB = '\\x1a';\n  /** Escape (Caret = ^[, C = \\e) */\n  export const ESC = '\\x1b';\n  /** File Separator (Caret = ^\\) */\n  export const FS  = '\\x1c';\n  /** Group Separator (Caret = ^]) */\n  export const GS  = '\\x1d';\n  /** Record Separator (Caret = ^^) */\n  export const RS  = '\\x1e';\n  /** Unit Separator (Caret = ^_) */\n  export const US  = '\\x1f';\n  /** Space */\n  export const SP  = '\\x20';\n  /** Delete (Caret = ^?) */\n  export const DEL = '\\x7f';\n}\n\n/**\n * C1 control codes\n * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes\n */\nexport namespace C1 {\n  /** padding character */\n  export const PAD = '\\x80';\n  /** High Octet Preset */\n  export const HOP = '\\x81';\n  /** Break Permitted Here */\n  export const BPH = '\\x82';\n  /** No Break Here */\n  export const NBH = '\\x83';\n  /** Index */\n  export const IND = '\\x84';\n  /** Next Line */\n  export const NEL = '\\x85';\n  /** Start of Selected Area */\n  export const SSA = '\\x86';\n  /** End of Selected Area */\n  export const ESA = '\\x87';\n  /** Horizontal Tabulation Set */\n  export const HTS = '\\x88';\n  /** Horizontal Tabulation With Justification */\n  export const HTJ = '\\x89';\n  /** Vertical Tabulation Set */\n  export const VTS = '\\x8a';\n  /** Partial Line Down */\n  export const PLD = '\\x8b';\n  /** Partial Line Up */\n  export const PLU = '\\x8c';\n  /** Reverse Index */\n  export const RI = '\\x8d';\n  /** Single-Shift 2 */\n  export const SS2 = '\\x8e';\n  /** Single-Shift 3 */\n  export const SS3 = '\\x8f';\n  /** Device Control String */\n  export const DCS = '\\x90';\n  /** Private Use 1 */\n  export const PU1 = '\\x91';\n  /** Private Use 2 */\n  export const PU2 = '\\x92';\n  /** Set Transmit State */\n  export const STS = '\\x93';\n  /** Destructive backspace, intended to eliminate ambiguity about meaning of BS. */\n  export const CCH = '\\x94';\n  /** Message Waiting */\n  export const MW = '\\x95';\n  /** Start of Protected Area */\n  export const SPA = '\\x96';\n  /** End of Protected Area */\n  export const EPA = '\\x97';\n  /** Start of String */\n  export const SOS = '\\x98';\n  /** Single Graphic Character Introducer */\n  export const SGCI = '\\x99';\n  /** Single Character Introducer */\n  export const SCI = '\\x9a';\n  /** Control Sequence Introducer */\n  export const CSI = '\\x9b';\n  /** String Terminator */\n  export const ST = '\\x9c';\n  /** Operating System Command */\n  export const OSC = '\\x9d';\n  /** Privacy Message */\n  export const PM = '\\x9e';\n  /** Application Program Command */\n  export const APC = '\\x9f';\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport type TypedArray = Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray\n  | Int8Array | Int16Array | Int32Array\n  | Float32Array | Float64Array;\n\n\n/**\n * polyfill for TypedArray.fill\n * This is needed to support .fill in all safari versions and IE 11.\n */\nexport function fill<T extends TypedArray>(array: T, value: number, start?: number, end?: number): T {\n  // all modern engines that support .fill\n  if (array.fill) {\n    return array.fill(value, start, end) as T;\n  }\n  return fillFallback(array, value, start, end);\n}\n\nexport function fillFallback<T extends TypedArray>(array: T, value: number, start: number = 0, end: number = array.length): T {\n  // safari and IE 11\n  // since IE 11 does not support Array.prototype.fill either\n  // we cannot use the suggested polyfill from MDN\n  // instead we simply fall back to looping\n  if (start >= array.length) {\n    return array;\n  }\n  start = (array.length + start) % array.length;\n  if (end >= array.length) {\n    end = array.length;\n  } else {\n    end = (array.length + end) % array.length;\n  }\n  for (let i = start; i < end; ++i) {\n    array[i] = value;\n  }\n  return array;\n}\n\n/**\n * Concat two typed arrays `a` and `b`.\n * Returns a new typed array.\n */\nexport function concat<T extends TypedArray>(a: T, b: T): T {\n  const result = new (a.constructor as any)(a.length + b.length);\n  result.set(a);\n  result.set(b, a.length);\n  return result;\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\ninterface INavigator {\n  userAgent: string;\n  language: string;\n  platform: string;\n}\n\n// We're declaring a navigator global here as we expect it in all runtimes (node and browser), but\n// we want this module to live in common.\ndeclare const navigator: INavigator;\n\nconst isNode = (typeof navigator === 'undefined') ? true : false;\nconst userAgent = (isNode) ? 'node' : navigator.userAgent;\nconst platform = (isNode) ? 'node' : navigator.platform;\n\nexport const isFirefox = !!~userAgent.indexOf('Firefox');\nexport const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);\nexport const isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');\n\n// Find the users platform. We use this to interpret the meta key\n// and ISO third level shifts.\n// http://stackoverflow.com/q/19877924/577598\nexport const isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);\nexport const isIpad = platform === 'iPad';\nexport const isIphone = platform === 'iPhone';\nexport const isMSWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);\nexport const isLinux = platform.indexOf('Linux') >= 0;\n\n/**\n * Return if the given array contains the given element\n * @param arr The array to search for the given element.\n * @param el The element to look for into the array\n */\nfunction contains(arr: any[], el: any): boolean {\n  return arr.indexOf(el) >= 0;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from './Types';\n\n/**\n * A base class that can be extended to provide convenience methods for managing the lifecycle of an\n * object and its components.\n */\nexport abstract class Disposable implements IDisposable {\n  protected _disposables: IDisposable[] = [];\n  protected _isDisposed: boolean = false;\n\n  constructor() {\n  }\n\n  /**\n   * Disposes the object, triggering the `dispose` method on all registered IDisposables.\n   */\n  public dispose(): void {\n    this._isDisposed = true;\n    this._disposables.forEach(d => d.dispose());\n    this._disposables.length = 0;\n  }\n\n  /**\n   * Registers a disposable object.\n   * @param d The disposable to register.\n   */\n  public register<T extends IDisposable>(d: T): void {\n    this._disposables.push(d);\n  }\n\n  /**\n   * Unregisters a disposable object if it has been registered, if not do\n   * nothing.\n   * @param d The disposable to unregister.\n   */\n  public unregister<T extends IDisposable>(d: T): void {\n    const index = this._disposables.indexOf(d);\n    if (index !== -1) {\n      this._disposables.splice(index, 1);\n    }\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from './Types';\n\ninterface IListener<T> {\n  (e: T): void;\n}\n\nexport interface IEvent<T> {\n  (listener: (e: T) => any): IDisposable;\n}\n\nexport class EventEmitter2<T> {\n  private _listeners: IListener<T>[] = [];\n  private _event?: IEvent<T>;\n\n  public get event(): IEvent<T> {\n    if (!this._event) {\n      this._event = (listener: (e: T) => any) => {\n        this._listeners.push(listener);\n        const disposable = {\n          dispose: () => {\n            for (let i = 0; i < this._listeners.length; i++) {\n              if (this._listeners[i] === listener) {\n                this._listeners.splice(i, 1);\n                return;\n              }\n            }\n          }\n        };\n        return disposable;\n      };\n    }\n    return this._event;\n  }\n\n  public fire(data: T): void {\n    const queue: IListener<T>[] = [];\n    for (let i = 0; i < this._listeners.length; i++) {\n      queue.push(this._listeners[i]);\n    }\n    for (let i = 0; i < queue.length; i++) {\n      queue[i].call(undefined, data);\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable, IEventEmitter, XtermListener } from './Types';\nimport { Disposable } from './Lifecycle';\n\nexport class EventEmitter extends Disposable implements IEventEmitter, IDisposable {\n  private _events: {[type: string]: XtermListener[]};\n\n  constructor() {\n    super();\n    // Restore the previous events if available, this will happen if the\n    // constructor is called multiple times on the same object (terminal reset).\n    this._events = (<any>this)._events || {};\n  }\n\n  public on(type: string, listener: XtermListener): void {\n    this._events[type] = this._events[type] || [];\n    this._events[type].push(listener);\n  }\n\n  /**\n   * Adds a disposable listener to the EventEmitter, returning the disposable.\n   * @param type The event type.\n   * @param handler The handler for the listener.\n   */\n  public addDisposableListener(type: string, handler: XtermListener): IDisposable {\n    // TODO: Rename addDisposableEventListener to more easily disambiguate from Dom listener\n    this.on(type, handler);\n    let disposed = false;\n    return {\n      dispose: () => {\n        if (disposed) {\n          // Already disposed\n          return;\n        }\n        this.off(type, handler);\n        disposed = true;\n      }\n    };\n  }\n\n  public off(type: string, listener: XtermListener): void {\n    if (!this._events[type]) {\n      return;\n    }\n\n    const obj = this._events[type];\n    let i = obj.length;\n\n    while (i--) {\n      if (obj[i] === listener) {\n        obj.splice(i, 1);\n        return;\n      }\n    }\n  }\n\n  public removeAllListeners(type: string): void {\n    if (this._events[type]) {\n       delete this._events[type];\n    }\n  }\n\n  public emit(type: string, ...args: any[]): void {\n    if (!this._events[type]) {\n      return;\n    }\n    const obj = this._events[type];\n    for (let i = 0; i < obj.length; i++) {\n      obj[i].apply(this, args);\n    }\n  }\n\n  public emitMayRemoveListeners(type: string, ...args: any[]): void {\n    if (!this._events[type]) {\n      return;\n    }\n    const obj = this._events[type];\n    let length = obj.length;\n    for (let i = 0; i < obj.length; i++) {\n      obj[i].apply(this, args);\n      i -= length - obj.length;\n      length = obj.length;\n    }\n  }\n\n  public listeners(type: string): XtermListener[] {\n    return this._events[type] || [];\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._events = {};\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/*\n * A simple utility for cloning values\n */\nexport function clone<T>(val: T, depth: number = 5): T | null {\n  if (typeof val !== 'object') {\n    return val;\n  }\n\n  // cloning null always returns null\n  if (val === null) {\n    return null;\n  }\n\n  // If we're cloning an array, use an array as the base, otherwise use an object\n  const clonedObject: any = Array.isArray(val) ? [] : {};\n\n  for (const key in val) {\n    // Recursively clone eack item unless we're at the maximum depth\n    clonedObject[key] = depth <= 1 ? val[key] : clone(val[key], depth - 1);\n  }\n\n  return clonedObject as T;\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICircularList } from './Types';\nimport { EventEmitter2, IEvent } from './EventEmitter2';\n\nexport interface IInsertEvent {\n  index: number;\n  amount: number;\n}\n\nexport interface IDeleteEvent {\n  index: number;\n  amount: number;\n}\n\n/**\n * Represents a circular list; a list with a maximum size that wraps around when push is called,\n * overriding values at the start of the list.\n */\nexport class CircularList<T> implements ICircularList<T> {\n  protected _array: (T | undefined)[];\n  private _startIndex: number;\n  private _length: number;\n\n  public onDeleteEmitter = new EventEmitter2<IDeleteEvent>();\n  public get onDelete(): IEvent<IDeleteEvent> { return this.onDeleteEmitter.event; }\n  public onInsertEmitter = new EventEmitter2<IInsertEvent>();\n  public get onInsert(): IEvent<IInsertEvent> { return this.onInsertEmitter.event; }\n  public onTrimEmitter = new EventEmitter2<number>();\n  public get onTrim(): IEvent<number> { return this.onTrimEmitter.event; }\n\n  constructor(\n    private _maxLength: number\n  ) {\n    this._array = new Array<T>(this._maxLength);\n    this._startIndex = 0;\n    this._length = 0;\n  }\n\n  public get maxLength(): number {\n    return this._maxLength;\n  }\n\n  public set maxLength(newMaxLength: number) {\n    // There was no change in maxLength, return early.\n    if (this._maxLength === newMaxLength) {\n      return;\n    }\n\n    // Reconstruct array, starting at index 0. Only transfer values from the\n    // indexes 0 to length.\n    const newArray = new Array<T | undefined>(newMaxLength);\n    for (let i = 0; i < Math.min(newMaxLength, this.length); i++) {\n      newArray[i] = this._array[this._getCyclicIndex(i)];\n    }\n    this._array = newArray;\n    this._maxLength = newMaxLength;\n    this._startIndex = 0;\n  }\n\n  public get length(): number {\n    return this._length;\n  }\n\n  public set length(newLength: number) {\n    if (newLength > this._length) {\n      for (let i = this._length; i < newLength; i++) {\n        this._array[i] = undefined;\n      }\n    }\n    this._length = newLength;\n  }\n\n  /**\n   * Gets the value at an index.\n   *\n   * Note that for performance reasons there is no bounds checking here, the index reference is\n   * circular so this should always return a value and never throw.\n   * @param index The index of the value to get.\n   * @return The value corresponding to the index.\n   */\n  public get(index: number): T | undefined {\n    return this._array[this._getCyclicIndex(index)];\n  }\n\n  /**\n   * Sets the value at an index.\n   *\n   * Note that for performance reasons there is no bounds checking here, the index reference is\n   * circular so this should always return a value and never throw.\n   * @param index The index to set.\n   * @param value The value to set.\n   */\n  public set(index: number, value: T | undefined): void {\n    this._array[this._getCyclicIndex(index)] = value;\n  }\n\n  /**\n   * Pushes a new value onto the list, wrapping around to the start of the array, overriding index 0\n   * if the maximum length is reached.\n   * @param value The value to push onto the list.\n   */\n  public push(value: T): void {\n    this._array[this._getCyclicIndex(this._length)] = value;\n    if (this._length === this._maxLength) {\n      this._startIndex = ++this._startIndex % this._maxLength;\n      this.onTrimEmitter.fire(1);\n    } else {\n      this._length++;\n    }\n  }\n\n  /**\n   * Advance ringbuffer index and return current element for recycling.\n   * Note: The buffer must be full for this method to work.\n   * @throws When the buffer is not full.\n   */\n  public recycle(): T {\n    if (this._length !== this._maxLength) {\n      throw new Error('Can only recycle when the buffer is full');\n    }\n    this._startIndex = ++this._startIndex % this._maxLength;\n    this.onTrimEmitter.fire(1);\n    return this._array[this._getCyclicIndex(this._length - 1)]!;\n  }\n\n  /**\n   * Ringbuffer is at max length.\n   */\n  public get isFull(): boolean {\n    return this._length === this._maxLength;\n  }\n\n  /**\n   * Removes and returns the last value on the list.\n   * @return The popped value.\n   */\n  public pop(): T | undefined {\n    return this._array[this._getCyclicIndex(this._length-- - 1)];\n  }\n\n  /**\n   * Deletes and/or inserts items at a particular index (in that order). Unlike\n   * Array.prototype.splice, this operation does not return the deleted items as a new array in\n   * order to save creating a new array. Note that this operation may shift all values in the list\n   * in the worst case.\n   * @param start The index to delete and/or insert.\n   * @param deleteCount The number of elements to delete.\n   * @param items The items to insert.\n   */\n  public splice(start: number, deleteCount: number, ...items: T[]): void {\n    // Delete items\n    if (deleteCount) {\n      for (let i = start; i < this._length - deleteCount; i++) {\n        this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];\n      }\n      this._length -= deleteCount;\n    }\n\n    // Add items\n    for (let i = this._length - 1; i >= start; i--) {\n      this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];\n    }\n    for (let i = 0; i < items.length; i++) {\n      this._array[this._getCyclicIndex(start + i)] = items[i];\n    }\n\n    // Adjust length as needed\n    if (this._length + items.length > this._maxLength) {\n      const countToTrim = (this._length + items.length) - this._maxLength;\n      this._startIndex += countToTrim;\n      this._length = this._maxLength;\n      this.onTrimEmitter.fire(countToTrim);\n    } else {\n      this._length += items.length;\n    }\n  }\n\n  /**\n   * Trims a number of items from the start of the list.\n   * @param count The number of items to remove.\n   */\n  public trimStart(count: number): void {\n    if (count > this._length) {\n      count = this._length;\n    }\n    this._startIndex += count;\n    this._length -= count;\n    this.onTrimEmitter.fire(count);\n  }\n\n  public shiftElements(start: number, count: number, offset: number): void {\n    if (count <= 0) {\n      return;\n    }\n    if (start < 0 || start >= this._length) {\n      throw new Error('start argument out of range');\n    }\n    if (start + offset < 0) {\n      throw new Error('Cannot shift elements in list beyond index 0');\n    }\n\n    if (offset > 0) {\n      for (let i = count - 1; i >= 0; i--) {\n        this.set(start + i + offset, this.get(start + i));\n      }\n      const expandListBy = (start + count + offset) - this._length;\n      if (expandListBy > 0) {\n        this._length += expandListBy;\n        while (this._length > this._maxLength) {\n          this._length--;\n          this._startIndex++;\n          this.onTrimEmitter.fire(1);\n        }\n      }\n    } else {\n      for (let i = 0; i < count; i++) {\n        this.set(start + i + offset, this.get(start + i));\n      }\n    }\n  }\n\n  /**\n   * Gets the cyclic index for the specified regular index. The cyclic index can then be used on the\n   * backing array to get the element associated with the regular index.\n   * @param index The regular index.\n   * @returns The cyclic index.\n   */\n  private _getCyclicIndex(index: number): number {\n    return (this._startIndex + index) % this._maxLength;\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from 'xterm';\nimport { ITerminal } from './Types';\nimport { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from './Buffer';\n\nexport function applyWindowsMode(terminal: ITerminal): IDisposable {\n  // Winpty does not support wraparound mode which means that lines will never\n  // be marked as wrapped. This causes issues for things like copying a line\n  // retaining the wrapped new line characters or if consumers are listening\n  // in on the data stream.\n  //\n  // The workaround for this is to listen to every incoming line feed and mark\n  // the line as wrapped if the last character in the previous line is not a\n  // space. This is certainly not without its problems, but generally on\n  // Windows when text reaches the end of the terminal it's likely going to be\n  // wrapped.\n  return terminal.onLineFeed(() => {\n    const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);\n    const lastChar = line.get(terminal.cols - 1);\n\n    if (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE) {\n      const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);\n      nextLine.isWrapped = true;\n    }\n  });\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IColorSet } from './renderer/Types';\nimport { ITerminal, IViewport } from './Types';\nimport { CharMeasure } from './CharMeasure';\nimport { Disposable } from './common/Lifecycle';\nimport { addDisposableDomListener } from './ui/Lifecycle';\n\nconst FALLBACK_SCROLL_BAR_WIDTH = 15;\n\n/**\n * Represents the viewport of a terminal, the visible area within the larger buffer of output.\n * Logic for the virtual scroll bar is included in this object.\n */\nexport class Viewport extends Disposable implements IViewport {\n  public scrollBarWidth: number = 0;\n  private _currentRowHeight: number = 0;\n  private _lastRecordedBufferLength: number = 0;\n  private _lastRecordedViewportHeight: number = 0;\n  private _lastRecordedBufferHeight: number = 0;\n  private _lastTouchY: number;\n  private _lastScrollTop: number = 0;\n\n  // Stores a partial line amount when scrolling, this is used to keep track of how much of a line\n  // is scrolled so we can \"scroll\" over partial lines and feel natural on touchpads. This is a\n  // quick fix and could have a more robust solution in place that reset the value when needed.\n  private _wheelPartialScroll: number = 0;\n\n  private _refreshAnimationFrame: number | null = null;\n  private _ignoreNextScrollEvent: boolean = false;\n\n  /**\n   * Creates a new Viewport.\n   * @param _terminal The terminal this viewport belongs to.\n   * @param _viewportElement The DOM element acting as the viewport.\n   * @param _scrollArea The DOM element acting as the scroll area.\n   * @param _charMeasure A DOM element used to measure the character size of. the terminal.\n   */\n  constructor(\n    private _terminal: ITerminal,\n    private _viewportElement: HTMLElement,\n    private _scrollArea: HTMLElement,\n    private _charMeasure: CharMeasure\n  ) {\n    super();\n\n    // Measure the width of the scrollbar. If it is 0 we can assume it's an OSX overlay scrollbar.\n    // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case,\n    // therefore we account for a standard amount to make it visible\n    this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;\n    this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this)));\n\n    // Perform this async to ensure the CharMeasure is ready.\n    setTimeout(() => this.syncScrollArea(), 0);\n  }\n\n  public onThemeChanged(colors: IColorSet): void {\n    this._viewportElement.style.backgroundColor = colors.background.css;\n  }\n\n  /**\n   * Refreshes row height, setting line-height, viewport height and scroll area height if\n   * necessary.\n   */\n  private _refresh(): void {\n    if (this._refreshAnimationFrame === null) {\n      this._refreshAnimationFrame = requestAnimationFrame(() => this._innerRefresh());\n    }\n  }\n\n  private _innerRefresh(): void {\n    if (this._charMeasure.height > 0) {\n      this._currentRowHeight = this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;\n      this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;\n      const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._terminal.renderer.dimensions.canvasHeight);\n      if (this._lastRecordedBufferHeight !== newBufferHeight) {\n        this._lastRecordedBufferHeight = newBufferHeight;\n        this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';\n      }\n    }\n\n    // Sync scrollTop\n    const scrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;\n    if (this._viewportElement.scrollTop !== scrollTop) {\n      // Ignore the next scroll event which will be triggered by setting the scrollTop as we do not\n      // want this event to scroll the terminal\n      this._ignoreNextScrollEvent = true;\n      this._viewportElement.scrollTop = scrollTop;\n    }\n\n    this._refreshAnimationFrame = null;\n  }\n\n  /**\n   * Updates dimensions and synchronizes the scroll area if necessary.\n   */\n  public syncScrollArea(): void {\n    // If buffer height changed\n    if (this._lastRecordedBufferLength !== this._terminal.buffer.lines.length) {\n      this._lastRecordedBufferLength = this._terminal.buffer.lines.length;\n      this._refresh();\n      return;\n    }\n\n    // If viewport height changed\n    if (this._lastRecordedViewportHeight !== (<any>this._terminal).renderer.dimensions.canvasHeight) {\n      this._refresh();\n      return;\n    }\n\n    // If the buffer position doesn't match last scroll top\n    const newScrollTop = this._terminal.buffer.ydisp * this._currentRowHeight;\n    if (this._lastScrollTop !== newScrollTop) {\n      this._refresh();\n      return;\n    }\n\n    // If element's scroll top changed, this can happen when hiding the element\n    if (this._lastScrollTop !== this._viewportElement.scrollTop) {\n      this._refresh();\n      return;\n    }\n\n    // If row height changed\n    if (this._terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {\n      this._refresh();\n      return;\n    }\n  }\n\n  /**\n   * Handles scroll events on the viewport, calculating the new viewport and requesting the\n   * terminal to scroll to it.\n   * @param ev The scroll event.\n   */\n  private _onScroll(ev: Event): void {\n    // Record current scroll top position\n    this._lastScrollTop = this._viewportElement.scrollTop;\n\n    // Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt\n    // which causes the terminal to scroll the buffer to the top\n    if (!this._viewportElement.offsetParent) {\n      return;\n    }\n\n    // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport)\n    if (this._ignoreNextScrollEvent) {\n      this._ignoreNextScrollEvent = false;\n      return;\n    }\n\n    const newRow = Math.round(this._lastScrollTop / this._currentRowHeight);\n    const diff = newRow - this._terminal.buffer.ydisp;\n    this._terminal.scrollLines(diff, true);\n  }\n\n  /**\n   * Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual\n   * scrolling to `onScroll`, this event needs to be attached manually by the consumer of\n   * `Viewport`.\n   * @param ev The mouse wheel event.\n   */\n  public onWheel(ev: WheelEvent): void {\n    const amount = this._getPixelsScrolled(ev);\n    if (amount === 0) {\n      return;\n    }\n    this._viewportElement.scrollTop += amount;\n    // Prevent the page from scrolling when the terminal scrolls\n    ev.preventDefault();\n  }\n\n  private _getPixelsScrolled(ev: WheelEvent): number {\n    // Do nothing if it's not a vertical scroll event\n    if (ev.deltaY === 0) {\n      return 0;\n    }\n\n    // Fallback to WheelEvent.DOM_DELTA_PIXEL\n    let amount = ev.deltaY;\n    if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {\n      amount *= this._currentRowHeight;\n    } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {\n      amount *= this._currentRowHeight * this._terminal.rows;\n    }\n    return amount;\n  }\n\n  /**\n   * Gets the number of pixels scrolled by the mouse event taking into account what type of delta\n   * is being used.\n   * @param ev The mouse wheel event.\n   */\n  public getLinesScrolled(ev: WheelEvent): number {\n    // Do nothing if it's not a vertical scroll event\n    if (ev.deltaY === 0) {\n      return 0;\n    }\n\n    // Fallback to WheelEvent.DOM_DELTA_LINE\n    let amount = ev.deltaY;\n    if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {\n      amount /= this._currentRowHeight + 0.0; // Prevent integer division\n      this._wheelPartialScroll += amount;\n      amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);\n      this._wheelPartialScroll %= 1;\n    } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {\n      amount *= this._terminal.rows;\n    }\n    return amount;\n  }\n\n  /**\n   * Handles the touchstart event, recording the touch occurred.\n   * @param ev The touch event.\n   */\n  public onTouchStart(ev: TouchEvent): void {\n    this._lastTouchY = ev.touches[0].pageY;\n  }\n\n  /**\n   * Handles the touchmove event, scrolling the viewport if the position shifted.\n   * @param ev The touch event.\n   */\n  public onTouchMove(ev: TouchEvent): void {\n    const deltaY = this._lastTouchY - ev.touches[0].pageY;\n    this._lastTouchY = ev.touches[0].pageY;\n    if (deltaY === 0) {\n      return;\n    }\n    this._viewportElement.scrollTop += deltaY;\n    ev.preventDefault();\n  }\n}\n","/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n *\n * Originally forked from (with the author's permission):\n *   Fabrice Bellard's javascript vt100 for jslinux:\n *   http://bellard.org/jslinux/\n *   Copyright (c) 2011 Fabrice Bellard\n *   The original design remains. The terminal itself\n *   has been extended to include xterm CSI codes, among\n *   other features.\n *\n * Terminal Emulation References:\n *   http://vt100.net/\n *   http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt\n *   http://invisible-island.net/xterm/ctlseqs/ctlseqs.html\n *   http://invisible-island.net/vttest/\n *   http://www.inwap.com/pdp10/ansicode.txt\n *   http://linux.die.net/man/4/console_codes\n *   http://linux.die.net/man/7/urxvt\n */\n\nimport { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, CharacterJoinerHandler, IBufferLine, IAttributeData, IMouseZoneManager } from './Types';\nimport { IRenderer } from './renderer/Types';\nimport { BufferSet } from './BufferSet';\nimport { Buffer, MAX_BUFFER_SIZE, DEFAULT_ATTR_DATA } from './Buffer';\nimport { CompositionHelper } from './CompositionHelper';\nimport { EventEmitter } from './common/EventEmitter';\nimport { Viewport } from './Viewport';\nimport { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './Clipboard';\nimport { C0 } from './common/data/EscapeSequences';\nimport { InputHandler } from './InputHandler';\nimport { Renderer } from './renderer/Renderer';\nimport { Linkifier } from './Linkifier';\nimport { SelectionManager } from './SelectionManager';\nimport { CharMeasure } from './CharMeasure';\nimport * as Browser from './common/Platform';\nimport { addDisposableDomListener } from './ui/Lifecycle';\nimport * as Strings from './Strings';\nimport { MouseHelper } from './MouseHelper';\nimport { DEFAULT_BELL_SOUND, SoundManager } from './SoundManager';\nimport { MouseZoneManager } from './MouseZoneManager';\nimport { AccessibilityManager } from './AccessibilityManager';\nimport { ScreenDprMonitor } from './ui/ScreenDprMonitor';\nimport { ITheme, IMarker, IDisposable } from 'xterm';\nimport { removeTerminalFromCache } from './renderer/atlas/CharAtlasCache';\nimport { DomRenderer } from './renderer/dom/DomRenderer';\nimport { IKeyboardEvent } from './common/Types';\nimport { evaluateKeyboardEvent } from './core/input/Keyboard';\nimport { KeyboardResultType, ICharset } from './core/Types';\nimport { clone } from './common/Clone';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\nimport { Attributes } from './BufferLine';\nimport { applyWindowsMode } from './WindowsMode';\n\n// Let it work inside Node.js for automated testing purposes.\nconst document = (typeof window !== 'undefined') ? window.document : null;\n\n/**\n * The amount of write requests to queue before sending an XOFF signal to the\n * pty process. This number must be small in order for ^C and similar sequences\n * to be responsive.\n */\nconst WRITE_BUFFER_PAUSE_THRESHOLD = 5;\n\n/**\n * The max number of ms to spend on writes before allowing the renderer to\n * catch up with a 0ms setTimeout. A value of < 33 to keep us close to\n * 30fps, and a value of < 16 to try to run at 60fps. Of course, the real FPS\n * depends on the time it takes for the renderer to draw the frame.\n */\nconst WRITE_TIMEOUT_MS = 12;\n\nconst MINIMUM_COLS = 2; // Less than 2 can mess with wide chars\nconst MINIMUM_ROWS = 1;\n\n/**\n * The set of options that only have an effect when set in the Terminal constructor.\n */\nconst CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows'];\n\nconst DEFAULT_OPTIONS: ITerminalOptions = {\n  cols: 80,\n  rows: 24,\n  convertEol: false,\n  termName: 'xterm',\n  cursorBlink: false,\n  cursorStyle: 'block',\n  bellSound: DEFAULT_BELL_SOUND,\n  bellStyle: 'none',\n  drawBoldTextInBrightColors: true,\n  enableBold: true,\n  experimentalCharAtlas: 'static',\n  fontFamily: 'courier-new, courier, monospace',\n  fontSize: 15,\n  fontWeight: 'normal',\n  fontWeightBold: 'bold',\n  lineHeight: 1.0,\n  letterSpacing: 0,\n  scrollback: 1000,\n  screenKeys: false,\n  screenReaderMode: false,\n  debug: false,\n  macOptionIsMeta: false,\n  macOptionClickForcesSelection: false,\n  cancelEvents: false,\n  disableStdin: false,\n  useFlowControl: false,\n  allowTransparency: false,\n  tabStopWidth: 8,\n  theme: null,\n  rightClickSelectsWord: Browser.isMac,\n  rendererType: 'canvas',\n  windowsMode: false\n};\n\nexport class Terminal extends EventEmitter implements ITerminal, IDisposable, IInputHandlingTerminal {\n  public textarea: HTMLTextAreaElement;\n  public element: HTMLElement;\n  public screenElement: HTMLElement;\n\n  /**\n   * The HTMLElement that the terminal is created in, set by Terminal.open.\n   */\n  private _parent: HTMLElement;\n  private _context: Window;\n  private _document: Document;\n  private _viewportScrollArea: HTMLElement;\n  private _viewportElement: HTMLElement;\n  private _helperContainer: HTMLElement;\n  private _compositionView: HTMLElement;\n\n  private _visualBellTimer: number;\n\n  public browser: IBrowser = <any>Browser;\n\n  public options: ITerminalOptions;\n\n  // TODO: This can be changed to an enum or boolean, 0 and 1 seem to be the only options\n  public cursorState: number;\n  public cursorHidden: boolean;\n\n  private _customKeyEventHandler: CustomKeyEventHandler;\n\n  // modes\n  public applicationKeypad: boolean;\n  public applicationCursor: boolean;\n  public originMode: boolean;\n  public insertMode: boolean;\n  public wraparoundMode: boolean; // defaults: xterm - true, vt100 - false\n  public bracketedPasteMode: boolean;\n\n  // charset\n  // The current charset\n  public charset: ICharset;\n  public gcharset: number;\n  public glevel: number;\n  public charsets: ICharset[];\n\n  // mouse properties\n  private _decLocator: boolean; // This is unstable and never set\n  public x10Mouse: boolean;\n  public vt200Mouse: boolean;\n  private _vt300Mouse: boolean; // This is unstable and never set\n  public normalMouse: boolean;\n  public mouseEvents: boolean;\n  public sendFocus: boolean;\n  public utfMouse: boolean;\n  public sgrMouse: boolean;\n  public urxvtMouse: boolean;\n\n  // misc\n  private _refreshStart: number;\n  private _refreshEnd: number;\n  public savedCols: number;\n\n  public curAttrData: IAttributeData;\n  private _eraseAttrData: IAttributeData;\n\n  public params: (string | number)[];\n  public currentParam: string | number;\n\n  // user input states\n  public writeBuffer: string[];\n  private _writeInProgress: boolean;\n\n  /**\n   * Whether _xterm.js_ sent XOFF in order to catch up with the pty process.\n   * This is a distinct state from writeStopped so that if the user requested\n   * XOFF via ^S that it will not automatically resume when the writeBuffer goes\n   * below threshold.\n   */\n  private _xoffSentToCatchUp: boolean;\n\n  /** Whether writing has been stopped as a result of XOFF */\n  // private _writeStopped: boolean;\n\n  // Store if user went browsing history in scrollback\n  private _userScrolling: boolean;\n\n  private _inputHandler: InputHandler;\n  public soundManager: SoundManager;\n  public renderer: IRenderer;\n  public selectionManager: SelectionManager;\n  public linkifier: ILinkifier;\n  public buffers: BufferSet;\n  public viewport: IViewport;\n  private _compositionHelper: ICompositionHelper;\n  public charMeasure: CharMeasure;\n  private _mouseZoneManager: IMouseZoneManager;\n  public mouseHelper: MouseHelper;\n  private _accessibilityManager: AccessibilityManager;\n  private _screenDprMonitor: ScreenDprMonitor;\n  private _theme: ITheme;\n  private _windowsMode: IDisposable | undefined;\n\n  // bufferline to clone/copy from for new blank lines\n  private _blankLine: IBufferLine = null;\n\n  public cols: number;\n  public rows: number;\n\n  private _onCursorMove = new EventEmitter2<void>();\n  public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }\n  private _onData = new EventEmitter2<string>();\n  public get onData(): IEvent<string> { return this._onData.event; }\n  private _onKey = new EventEmitter2<{ key: string, domEvent: KeyboardEvent }>();\n  public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._onKey.event; }\n  private _onLineFeed = new EventEmitter2<void>();\n  public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }\n  private _onRender = new EventEmitter2<{ start: number, end: number }>();\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }\n  private _onResize = new EventEmitter2<{ cols: number, rows: number }>();\n  public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }\n  private _onScroll = new EventEmitter2<number>();\n  public get onScroll(): IEvent<number> { return this._onScroll.event; }\n  private _onSelectionChange = new EventEmitter2<void>();\n  public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }\n  private _onTitleChange = new EventEmitter2<string>();\n  public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; }\n\n  /**\n   * Creates a new `Terminal` object.\n   *\n   * @param options An object containing a set of options, the available options are:\n   *   - `cursorBlink` (boolean): Whether the terminal cursor blinks\n   *   - `cols` (number): The number of columns of the terminal (horizontal size)\n   *   - `rows` (number): The number of rows of the terminal (vertical size)\n   *\n   * @public\n   * @class Xterm Xterm\n   * @alias module:xterm/src/xterm\n   */\n  constructor(\n    options: ITerminalOptions = {}\n  ) {\n    super();\n    this.options = clone(options);\n    this._setup();\n\n    // TODO: Remove these in v4\n    // Fire old style events from new emitters\n    this.onCursorMove(() => this.emit('cursormove'));\n    this.onData(e => this.emit('data', e));\n    this.onKey(e => this.emit('key', e.key, e.domEvent));\n    this.onLineFeed(() => this.emit('linefeed'));\n    this.onRender(e => this.emit('refresh', e));\n    this.onResize(e => this.emit('resize', e));\n    this.onSelectionChange(() => this.emit('selection'));\n    this.onScroll(e => this.emit('scroll', e));\n    this.onTitleChange(e => this.emit('title', e));\n  }\n\n  public dispose(): void {\n    super.dispose();\n    if (this._windowsMode) {\n      this._windowsMode.dispose();\n      this._windowsMode = undefined;\n    }\n    this._customKeyEventHandler = null;\n    removeTerminalFromCache(this);\n    this.handler = () => {};\n    this.write = () => {};\n    if (this.element && this.element.parentNode) {\n      this.element.parentNode.removeChild(this.element);\n    }\n  }\n\n  /**\n   * @deprecated Use dispose instead.\n   */\n  public destroy(): void {\n    this.dispose();\n  }\n\n  private _setup(): void {\n    Object.keys(DEFAULT_OPTIONS).forEach((key) => {\n      if (this.options[key] === null || this.options[key] === undefined) {\n        this.options[key] = DEFAULT_OPTIONS[key];\n      }\n    });\n\n    // this.context = options.context || window;\n    // this.document = options.document || document;\n    // TODO: WHy not document.body?\n    this._parent = document ? document.body : null;\n\n    this.cols = Math.max(this.options.cols, MINIMUM_COLS);\n    this.rows = Math.max(this.options.rows, MINIMUM_ROWS);\n\n    if (this.options.handler) {\n      this.onData(this.options.handler);\n    }\n\n    this.cursorState = 0;\n    this.cursorHidden = false;\n    this._customKeyEventHandler = null;\n\n    // modes\n    this.applicationKeypad = false;\n    this.applicationCursor = false;\n    this.originMode = false;\n    this.insertMode = false;\n    this.wraparoundMode = true; // defaults: xterm - true, vt100 - false\n    this.bracketedPasteMode = false;\n\n    // charset\n    this.charset = null;\n    this.gcharset = null;\n    this.glevel = 0;\n    // TODO: Can this be just []?\n    this.charsets = [null];\n\n    this.curAttrData = DEFAULT_ATTR_DATA.clone();\n    this._eraseAttrData = DEFAULT_ATTR_DATA.clone();\n\n    this.params = [];\n    this.currentParam = 0;\n\n    // user input states\n    this.writeBuffer = [];\n    this._writeInProgress = false;\n\n    this._xoffSentToCatchUp = false;\n    // this._writeStopped = false;\n    this._userScrolling = false;\n\n    // Register input handler and refire/handle events\n    this._inputHandler = new InputHandler(this);\n    this._inputHandler.onCursorMove(() => this._onCursorMove.fire());\n    this._inputHandler.onLineFeed(() => this._onLineFeed.fire());\n    this._inputHandler.onData(e => this._onData.fire(e));\n    this.register(this._inputHandler);\n\n    // Reuse renderer if the Terminal is being recreated via a reset call.\n    this.renderer = this.renderer || null;\n    this.selectionManager = this.selectionManager || null;\n    this.linkifier = this.linkifier || new Linkifier(this);\n    this._mouseZoneManager = this._mouseZoneManager || null;\n    this.soundManager = this.soundManager || new SoundManager(this);\n\n    // Create the terminal's buffers and set the current buffer\n    this.buffers = new BufferSet(this);\n    if (this.selectionManager) {\n      this.selectionManager.clearSelection();\n      this.selectionManager.initBuffersListeners();\n    }\n\n    if (this.options.windowsMode) {\n      this._windowsMode = applyWindowsMode(this);\n    }\n  }\n\n  /**\n   * Convenience property to active buffer.\n   */\n  public get buffer(): Buffer {\n    return this.buffers.active;\n  }\n\n  /**\n   * back_color_erase feature for xterm.\n   */\n  public eraseAttrData(): IAttributeData {\n    this._eraseAttrData.bg &= ~(Attributes.CM_MASK | 0xFFFFFF);\n    this._eraseAttrData.bg |= this.curAttrData.bg & ~0xFC000000;\n    return this._eraseAttrData;\n  }\n\n  /**\n   * Focus the terminal. Delegates focus handling to the terminal's DOM element.\n   */\n  public focus(): void {\n    if (this.textarea) {\n      this.textarea.focus({ preventScroll: true });\n    }\n  }\n\n  public get isFocused(): boolean {\n    return document.activeElement === this.textarea && document.hasFocus();\n  }\n\n  /**\n   * Retrieves an option's value from the terminal.\n   * @param key The option key.\n   */\n  public getOption(key: string): any {\n    if (!(key in DEFAULT_OPTIONS)) {\n      throw new Error('No option with key \"' + key + '\"');\n    }\n\n    return this.options[key];\n  }\n\n  /**\n   * Sets an option on the terminal.\n   * @param key The option key.\n   * @param value The option value.\n   */\n  public setOption(key: string, value: any): void {\n    if (!(key in DEFAULT_OPTIONS)) {\n      throw new Error('No option with key \"' + key + '\"');\n    }\n    if (CONSTRUCTOR_ONLY_OPTIONS.indexOf(key) !== -1) {\n      console.error(`Option \"${key}\" can only be set in the constructor`);\n    }\n    if (this.options[key] === value) {\n      return;\n    }\n    switch (key) {\n      case 'bellStyle':\n        if (!value) {\n          value = 'none';\n        }\n        break;\n      case 'cursorStyle':\n        if (!value) {\n          value = 'block';\n        }\n        break;\n      case 'fontWeight':\n        if (!value) {\n          value = 'normal';\n        }\n        break;\n      case 'fontWeightBold':\n        if (!value) {\n          value = 'bold';\n        }\n        break;\n      case 'lineHeight':\n        if (value < 1) {\n          console.warn(`${key} cannot be less than 1, value: ${value}`);\n          return;\n        }\n      case 'rendererType':\n        if (!value) {\n          value = 'canvas';\n        }\n        break;\n      case 'tabStopWidth':\n        if (value < 1) {\n          console.warn(`${key} cannot be less than 1, value: ${value}`);\n          return;\n        }\n        break;\n      case 'theme':\n        // If open has been called we do not want to set options.theme as the\n        // source of truth is owned by the renderer.\n        if (this.renderer) {\n          this._setTheme(<ITheme>value);\n          return;\n        }\n        break;\n      case 'scrollback':\n        value = Math.min(value, MAX_BUFFER_SIZE);\n\n        if (value < 0) {\n          console.warn(`${key} cannot be less than 0, value: ${value}`);\n          return;\n        }\n        if (this.options[key] !== value) {\n          const newBufferLength = this.rows + value;\n          if (this.buffer.lines.length > newBufferLength) {\n            const amountToTrim = this.buffer.lines.length - newBufferLength;\n            const needsRefresh = (this.buffer.ydisp - amountToTrim < 0);\n            this.buffer.lines.trimStart(amountToTrim);\n            this.buffer.ybase = Math.max(this.buffer.ybase - amountToTrim, 0);\n            this.buffer.ydisp = Math.max(this.buffer.ydisp - amountToTrim, 0);\n            if (needsRefresh) {\n              this.refresh(0, this.rows - 1);\n            }\n          }\n        }\n        break;\n    }\n    this.options[key] = value;\n    switch (key) {\n      case 'fontFamily':\n      case 'fontSize':\n        // When the font changes the size of the cells may change which requires a renderer clear\n        if (this.renderer) {\n          this.renderer.clear();\n          this.charMeasure.measure(this.options);\n        }\n        break;\n      case 'drawBoldTextInBrightColors':\n      case 'experimentalCharAtlas':\n      case 'enableBold':\n      case 'letterSpacing':\n      case 'lineHeight':\n      case 'fontWeight':\n      case 'fontWeightBold':\n        // When the font changes the size of the cells may change which requires a renderer clear\n        if (this.renderer) {\n          this.renderer.clear();\n          this.renderer.onResize(this.cols, this.rows);\n          this.refresh(0, this.rows - 1);\n        }\n        break;\n      case 'rendererType':\n        if (this.renderer) {\n          this.unregister(this.renderer);\n          this.renderer.dispose();\n          this.renderer = null;\n        }\n        this._setupRenderer();\n        this.renderer.onCharSizeChanged();\n        if (this._theme) {\n          this.renderer.setTheme(this._theme);\n        }\n        this.mouseHelper.setRenderer(this.renderer);\n        break;\n      case 'scrollback':\n        this.buffers.resize(this.cols, this.rows);\n        if (this.viewport) {\n          this.viewport.syncScrollArea();\n        }\n        break;\n      case 'screenReaderMode':\n        if (value) {\n          if (!this._accessibilityManager) {\n            this._accessibilityManager = new AccessibilityManager(this);\n          }\n        } else {\n          if (this._accessibilityManager) {\n            this._accessibilityManager.dispose();\n            this._accessibilityManager = null;\n          }\n        }\n        break;\n      case 'tabStopWidth': this.buffers.setupTabStops(); break;\n      case 'windowsMode':\n        if (value) {\n          if (!this._windowsMode) {\n            this._windowsMode = applyWindowsMode(this);\n          }\n        } else {\n          if (this._windowsMode) {\n            this._windowsMode.dispose();\n            this._windowsMode = undefined;\n          }\n        }\n        break;\n    }\n    // Inform renderer of changes\n    if (this.renderer) {\n      this.renderer.onOptionsChanged();\n    }\n  }\n\n  /**\n   * Binds the desired focus behavior on a given terminal object.\n   */\n  private _onTextAreaFocus(ev: KeyboardEvent): void {\n    if (this.sendFocus) {\n      this.handler(C0.ESC + '[I');\n    }\n    this.updateCursorStyle(ev);\n    this.element.classList.add('focus');\n    this.showCursor();\n    this.emit('focus');\n  }\n\n  /**\n   * Blur the terminal, calling the blur function on the terminal's underlying\n   * textarea.\n   */\n  public blur(): void {\n    return this.textarea.blur();\n  }\n\n  /**\n   * Binds the desired blur behavior on a given terminal object.\n   */\n  private _onTextAreaBlur(): void {\n    // Text can safely be removed on blur. Doing it earlier could interfere with\n    // screen readers reading it out.\n    this.textarea.value = '';\n    this.refresh(this.buffer.y, this.buffer.y);\n    if (this.sendFocus) {\n      this.handler(C0.ESC + '[O');\n    }\n    this.element.classList.remove('focus');\n    this.emit('blur');\n  }\n\n  /**\n   * Initialize default behavior\n   */\n  private _initGlobal(): void {\n    this._bindKeys();\n\n    // Bind clipboard functionality\n    this.register(addDisposableDomListener(this.element, 'copy', (event: ClipboardEvent) => {\n      // If mouse events are active it means the selection manager is disabled and\n      // copy should be handled by the host program.\n      if (!this.hasSelection()) {\n        return;\n      }\n      copyHandler(event, this, this.selectionManager);\n    }));\n    const pasteHandlerWrapper = (event: ClipboardEvent) => pasteHandler(event, this);\n    this.register(addDisposableDomListener(this.textarea, 'paste', pasteHandlerWrapper));\n    this.register(addDisposableDomListener(this.element, 'paste', pasteHandlerWrapper));\n\n    // Handle right click context menus\n    if (Browser.isFirefox) {\n      // Firefox doesn't appear to fire the contextmenu event on right click\n      this.register(addDisposableDomListener(this.element, 'mousedown', (event: MouseEvent) => {\n        if (event.button === 2) {\n          rightClickHandler(event, this, this.selectionManager, this.options.rightClickSelectsWord);\n        }\n      }));\n    } else {\n      this.register(addDisposableDomListener(this.element, 'contextmenu', (event: MouseEvent) => {\n        rightClickHandler(event, this, this.selectionManager, this.options.rightClickSelectsWord);\n      }));\n    }\n\n    // Move the textarea under the cursor when middle clicking on Linux to ensure\n    // middle click to paste selection works. This only appears to work in Chrome\n    // at the time is writing.\n    if (Browser.isLinux) {\n      // Use auxclick event over mousedown the latter doesn't seem to work. Note\n      // that the regular click event doesn't fire for the middle mouse button.\n      this.register(addDisposableDomListener(this.element, 'auxclick', (event: MouseEvent) => {\n        if (event.button === 1) {\n          moveTextAreaUnderMouseCursor(event, this);\n        }\n      }));\n    }\n  }\n\n  /**\n   * Apply key handling to the terminal\n   */\n  private _bindKeys(): void {\n    const self = this;\n    this.register(addDisposableDomListener(this.element, 'keydown', function (ev: KeyboardEvent): void {\n      if (document.activeElement !== this) {\n        return;\n      }\n      self._keyDown(ev);\n    }, true));\n\n    this.register(addDisposableDomListener(this.element, 'keypress', function (ev: KeyboardEvent): void {\n      if (document.activeElement !== this) {\n        return;\n      }\n      self._keyPress(ev);\n    }, true));\n\n    this.register(addDisposableDomListener(this.element, 'keyup', (ev: KeyboardEvent) => {\n      if (!wasModifierKeyOnlyEvent(ev)) {\n        this.focus();\n      }\n\n      self._keyUp(ev);\n    }, true));\n\n    this.register(addDisposableDomListener(this.textarea, 'keydown', (ev: KeyboardEvent) => this._keyDown(ev), true));\n    this.register(addDisposableDomListener(this.textarea, 'keypress', (ev: KeyboardEvent) => this._keyPress(ev), true));\n    this.register(addDisposableDomListener(this.textarea, 'compositionstart', () => this._compositionHelper.compositionstart()));\n    this.register(addDisposableDomListener(this.textarea, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper.compositionupdate(e)));\n    this.register(addDisposableDomListener(this.textarea, 'compositionend', () => this._compositionHelper.compositionend()));\n    this.register(this.onRender(() => this._compositionHelper.updateCompositionElements()));\n    this.register(this.onRender(e => this._queueLinkification(e.start, e.end)));\n  }\n\n  /**\n   * Opens the terminal within an element.\n   *\n   * @param parent The element to create the terminal within.\n   */\n  public open(parent: HTMLElement): void {\n    this._parent = parent || this._parent;\n\n    if (!this._parent) {\n      throw new Error('Terminal requires a parent element.');\n    }\n\n    // Grab global elements\n    this._context = this._parent.ownerDocument.defaultView;\n    this._document = this._parent.ownerDocument;\n\n    this._screenDprMonitor = new ScreenDprMonitor();\n    this._screenDprMonitor.setListener(() => this.emit('dprchange', window.devicePixelRatio));\n    this.register(this._screenDprMonitor);\n\n    // Create main element container\n    this.element = this._document.createElement('div');\n    this.element.dir = 'ltr';   // xterm.css assumes LTR\n    this.element.classList.add('terminal');\n    this.element.classList.add('xterm');\n    this.element.setAttribute('tabindex', '0');\n    this._parent.appendChild(this.element);\n\n    // Performance: Use a document fragment to build the terminal\n    // viewport and helper elements detached from the DOM\n    const fragment = document.createDocumentFragment();\n    this._viewportElement = document.createElement('div');\n    this._viewportElement.classList.add('xterm-viewport');\n    fragment.appendChild(this._viewportElement);\n    this._viewportScrollArea = document.createElement('div');\n    this._viewportScrollArea.classList.add('xterm-scroll-area');\n    this._viewportElement.appendChild(this._viewportScrollArea);\n\n    this.screenElement = document.createElement('div');\n    this.screenElement.classList.add('xterm-screen');\n    // Create the container that will hold helpers like the textarea for\n    // capturing DOM Events. Then produce the helpers.\n    this._helperContainer = document.createElement('div');\n    this._helperContainer.classList.add('xterm-helpers');\n    this.screenElement.appendChild(this._helperContainer);\n    fragment.appendChild(this.screenElement);\n\n    this._mouseZoneManager = new MouseZoneManager(this);\n    this.register(this._mouseZoneManager);\n    this.register(this.onScroll(() => this._mouseZoneManager.clearAll()));\n    this.linkifier.attachToDom(this._mouseZoneManager);\n\n    this.textarea = document.createElement('textarea');\n    this.textarea.classList.add('xterm-helper-textarea');\n    // TODO: New API to set title? This could say \"Terminal bash input\", etc.\n    this.textarea.setAttribute('aria-label', Strings.promptLabel);\n    this.textarea.setAttribute('aria-multiline', 'false');\n    this.textarea.setAttribute('autocorrect', 'off');\n    this.textarea.setAttribute('autocapitalize', 'off');\n    this.textarea.setAttribute('spellcheck', 'false');\n    this.textarea.tabIndex = 0;\n    this.register(addDisposableDomListener(this.textarea, 'focus', (ev: KeyboardEvent) => this._onTextAreaFocus(ev)));\n    this.register(addDisposableDomListener(this.textarea, 'blur', () => this._onTextAreaBlur()));\n    this._helperContainer.appendChild(this.textarea);\n\n    this._compositionView = document.createElement('div');\n    this._compositionView.classList.add('composition-view');\n    this._compositionHelper = new CompositionHelper(this.textarea, this._compositionView, this);\n    this._helperContainer.appendChild(this._compositionView);\n\n    this.charMeasure = new CharMeasure(document, this._helperContainer);\n\n    // Performance: Add viewport and helper elements from the fragment\n    this.element.appendChild(fragment);\n\n    this._setupRenderer();\n    this._theme = this.options.theme;\n    this.options.theme = null;\n    this.viewport = new Viewport(this, this._viewportElement, this._viewportScrollArea, this.charMeasure);\n    this.viewport.onThemeChanged(this.renderer.colorManager.colors);\n    this.register(this.viewport);\n\n    this.register(this.onCursorMove(() => this.renderer.onCursorMove()));\n    this.register(this.onResize(() => this.renderer.onResize(this.cols, this.rows)));\n    this.register(this.addDisposableListener('blur', () => this.renderer.onBlur()));\n    this.register(this.addDisposableListener('focus', () => this.renderer.onFocus()));\n    this.register(this.addDisposableListener('dprchange', () => this.renderer.onWindowResize(window.devicePixelRatio)));\n    // dprchange should handle this case, we need this as well for browsers that don't support the\n    // matchMedia query.\n    this.register(addDisposableDomListener(window, 'resize', () => this.renderer.onWindowResize(window.devicePixelRatio)));\n    this.register(this.charMeasure.onCharSizeChanged(() => this.renderer.onCharSizeChanged()));\n    this.register(this.renderer.onCanvasResize(() => this.viewport.syncScrollArea()));\n\n    this.selectionManager = new SelectionManager(this, this.charMeasure);\n    this.register(this.selectionManager.onSelectionChange(() => this._onSelectionChange.fire()));\n    this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this.selectionManager.onMouseDown(e)));\n    this.register(this.selectionManager.onRedrawRequest(e => this.renderer.onSelectionChanged(e.start, e.end, e.columnSelectMode)));\n    this.register(this.selectionManager.onLinuxMouseSelection(text => {\n      // If there's a new selection, put it into the textarea, focus and select it\n      // in order to register it as a selection on the OS. This event is fired\n      // only on Linux to enable middle click to paste selection.\n      this.textarea.value = text;\n      this.textarea.focus();\n      this.textarea.select();\n    }));\n    this.register(this.onScroll(() => {\n      this.viewport.syncScrollArea();\n      this.selectionManager.refresh();\n    }));\n    this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this.selectionManager.refresh()));\n\n    this.mouseHelper = new MouseHelper(this.renderer);\n    // apply mouse event classes set by escape codes before terminal was attached\n    this.element.classList.toggle('enable-mouse-events', this.mouseEvents);\n    if (this.mouseEvents) {\n      this.selectionManager.disable();\n    } else {\n      this.selectionManager.enable();\n    }\n\n    if (this.options.screenReaderMode) {\n      // Note that this must be done *after* the renderer is created in order to\n      // ensure the correct order of the dprchange event\n      this._accessibilityManager = new AccessibilityManager(this);\n    }\n\n    // Measure the character size\n    this.charMeasure.measure(this.options);\n\n    // Setup loop that draws to screen\n    this.refresh(0, this.rows - 1);\n\n    // Initialize global actions that need to be taken on the document.\n    this._initGlobal();\n\n    // Listen for mouse events and translate\n    // them into terminal mouse protocols.\n    this.bindMouse();\n\n  }\n\n  private _setupRenderer(): void {\n    switch (this.options.rendererType) {\n      case 'canvas': this.renderer = new Renderer(this, this.options.theme); break;\n      case 'dom': this.renderer = new DomRenderer(this, this.options.theme); break;\n      default: throw new Error(`Unrecognized rendererType \"${this.options.rendererType}\"`);\n    }\n    this.renderer.onRender(e => this._onRender.fire(e));\n    this.register(this.renderer);\n  }\n\n  /**\n   * Sets the theme on the renderer. The renderer must have been initialized.\n   * @param theme The theme to set.\n   */\n  private _setTheme(theme: ITheme): void {\n    this._theme = theme;\n    const colors = this.renderer.setTheme(theme);\n    if (this.viewport) {\n      this.viewport.onThemeChanged(colors);\n    }\n  }\n\n  /**\n   * XTerm mouse events\n   * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking\n   * To better understand these\n   * the xterm code is very helpful:\n   * Relevant files:\n   *   button.c, charproc.c, misc.c\n   * Relevant functions in xterm/button.c:\n   *   BtnCode, EmitButtonCode, EditorButton, SendMousePosition\n   */\n  public bindMouse(): void {\n    const el = this.element;\n    const self = this;\n    let pressed = 32;\n\n    // mouseup, mousedown, wheel\n    // left click: ^[[M 3<^[[M#3<\n    // wheel up: ^[[M`3>\n    function sendButton(ev: MouseEvent | WheelEvent): void {\n      let button;\n      let pos;\n\n      // get the xterm-style button\n      button = getButton(ev);\n\n      // get mouse coordinates\n      pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);\n      if (!pos) return;\n\n      sendEvent(button, pos);\n\n      switch ((<any>ev).overrideType || ev.type) {\n        case 'mousedown':\n          pressed = button;\n          break;\n        case 'mouseup':\n          // keep it at the left\n          // button, just in case.\n          pressed = 32;\n          break;\n        case 'wheel':\n          // nothing. don't\n          // interfere with\n          // `pressed`.\n          break;\n      }\n    }\n\n    // motion example of a left click:\n    // ^[[M 3<^[[M at 4<^[[M at 5<^[[M at 6<^[[M at 7<^[[M#7<\n    function sendMove(ev: MouseEvent): void {\n      let button = pressed;\n      const pos = self.mouseHelper.getRawByteCoords(ev, self.screenElement, self.charMeasure, self.cols, self.rows);\n      if (!pos) return;\n\n      // buttons marked as motions\n      // are incremented by 32\n      button += 32;\n\n      sendEvent(button, pos);\n    }\n\n    // encode button and\n    // position to characters\n    function encode(data: number[], ch: number): void {\n      if (!self.utfMouse) {\n        if (ch === 255) {\n          data.push(0);\n          return;\n        }\n        if (ch > 127) ch = 127;\n        data.push(ch);\n      } else {\n        if (ch > 2047) {\n          data.push(2047);\n          return;\n        }\n        data.push(ch);\n      }\n    }\n\n    // send a mouse event:\n    // regular/utf8: ^[[M Cb Cx Cy\n    // urxvt: ^[[ Cb ; Cx ; Cy M\n    // sgr: ^[[ Cb ; Cx ; Cy M/m\n    // vt300: ^[[ 24(1/3/5)~ [ Cx , Cy ] \\r\n    // locator: CSI P e ; P b ; P r ; P c ; P p & w\n    function sendEvent(button: number, pos: {x: number, y: number}): void {\n      // self.emit('mouse', {\n      //   x: pos.x - 32,\n      //   y: pos.x - 32,\n      //   button: button\n      // });\n\n      if (self._vt300Mouse) {\n        // NOTE: Unstable.\n        // http://www.vt100.net/docs/vt3xx-gp/chapter15.html\n        button &= 3;\n        pos.x -= 32;\n        pos.y -= 32;\n        let data = C0.ESC + '[24';\n        if (button === 0) data += '1';\n        else if (button === 1) data += '3';\n        else if (button === 2) data += '5';\n        else if (button === 3) return;\n        else data += '0';\n        data += '~[' + pos.x + ',' + pos.y + ']\\r';\n        self.handler(data);\n        return;\n      }\n\n      if (self._decLocator) {\n        // NOTE: Unstable.\n        button &= 3;\n        pos.x -= 32;\n        pos.y -= 32;\n        if (button === 0) button = 2;\n        else if (button === 1) button = 4;\n        else if (button === 2) button = 6;\n        else if (button === 3) button = 3;\n        self.handler(C0.ESC + '['\n                  + button\n                  + ';'\n                  + (button === 3 ? 4 : 0)\n                  + ';'\n                  + pos.y\n                  + ';'\n                  + pos.x\n                  + ';'\n                  // Not sure what page is meant to be\n                  + (<any>pos).page || 0\n                  + '&w');\n        return;\n      }\n\n      if (self.urxvtMouse) {\n        pos.x -= 32;\n        pos.y -= 32;\n        pos.x++;\n        pos.y++;\n        self.handler(C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');\n        return;\n      }\n\n      if (self.sgrMouse) {\n        pos.x -= 32;\n        pos.y -= 32;\n        self.handler(C0.ESC + '[<'\n                  + (((button & 3) === 3 ? button & ~3 : button) - 32)\n                  + ';'\n                  + pos.x\n                  + ';'\n                  + pos.y\n                  + ((button & 3) === 3 ? 'm' : 'M'));\n        return;\n      }\n\n      const data: number[] = [];\n\n      encode(data, button);\n      encode(data, pos.x);\n      encode(data, pos.y);\n\n      self.handler(C0.ESC + '[M' + String.fromCharCode.apply(String, data));\n    }\n\n    function getButton(ev: MouseEvent): number {\n      let button;\n      let shift;\n      let meta;\n      let ctrl;\n      let mod;\n\n      // two low bits:\n      // 0 = left\n      // 1 = middle\n      // 2 = right\n      // 3 = release\n      // wheel up/down:\n      // 1, and 2 - with 64 added\n      switch ((<any>ev).overrideType || ev.type) {\n        case 'mousedown':\n          button = ev.button !== null && ev.button !== undefined\n            ? +ev.button\n          : ev.which !== null && ev.which !== undefined\n            ? ev.which - 1\n          : null;\n\n          if (Browser.isMSIE) {\n            button = button === 1 ? 0 : button === 4 ? 1 : button;\n          }\n          break;\n        case 'mouseup':\n          button = 3;\n          break;\n        case 'DOMMouseScroll':\n          button = ev.detail < 0\n            ? 64\n          : 65;\n          break;\n        case 'wheel':\n          button = (<WheelEvent>ev).deltaY < 0\n            ? 64\n          : 65;\n          break;\n      }\n\n      // next three bits are the modifiers:\n      // 4 = shift, 8 = meta, 16 = control\n      shift = ev.shiftKey ? 4 : 0;\n      meta = ev.metaKey ? 8 : 0;\n      ctrl = ev.ctrlKey ? 16 : 0;\n      mod = shift | meta | ctrl;\n\n      // no mods\n      if (self.vt200Mouse) {\n        // ctrl only\n        mod &= ctrl;\n      } else if (!self.normalMouse) {\n        mod = 0;\n      }\n\n      // increment to SP\n      button = (32 + (mod << 2)) + button;\n\n      return button;\n    }\n\n    this.register(addDisposableDomListener(el, 'mousedown', (ev: MouseEvent) => {\n\n      // Prevent the focus on the textarea from getting lost\n      // and make sure we get focused on mousedown\n      ev.preventDefault();\n      this.focus();\n\n      // Don't send the mouse button to the pty if mouse events are disabled or\n      // if the selection manager is having selection forced (ie. a modifier is\n      // held).\n      if (!this.mouseEvents || this.selectionManager.shouldForceSelection(ev)) {\n        return;\n      }\n\n      // send the button\n      sendButton(ev);\n\n      // fix for odd bug\n      // if (this.vt200Mouse && !this.normalMouse) {\n      if (this.vt200Mouse) {\n        (<any>ev).overrideType = 'mouseup';\n        sendButton(ev);\n        return this.cancel(ev);\n      }\n\n      // TODO: All mouse handling should be pulled into its own file.\n\n      // bind events\n      let moveHandler: (event: MouseEvent) => void;\n      if (this.normalMouse) {\n        moveHandler = (event: MouseEvent) => {\n          // Do nothing if normal mouse mode is on. This can happen if the mouse is held down when the\n          // terminal exits normalMouse mode.\n          if (!this.normalMouse) {\n            return;\n          }\n          sendMove(event);\n        };\n        // TODO: these event listeners should be managed by the disposable, the Terminal reference may\n        // be kept aroud if Terminal.dispose is fired when the mouse is down\n        this._document.addEventListener('mousemove', moveHandler);\n      }\n\n      // x10 compatibility mode can't send button releases\n      const handler = (ev: MouseEvent) => {\n        if (this.normalMouse && !this.x10Mouse) {\n          sendButton(ev);\n        }\n        if (moveHandler) {\n          // Even though this should only be attached when this.normalMouse is true, holding the\n          // mouse button down when normalMouse changes can happen. Just always try to remove it.\n          this._document.removeEventListener('mousemove', moveHandler);\n          moveHandler = null;\n        }\n        this._document.removeEventListener('mouseup', handler);\n        return this.cancel(ev);\n      };\n      this._document.addEventListener('mouseup', handler);\n\n      return this.cancel(ev);\n    }));\n\n    // if (this.normalMouse) {\n    //  on(this.document, 'mousemove', sendMove);\n    // }\n\n    this.register(addDisposableDomListener(el, 'wheel', (ev: WheelEvent) => {\n      if (!this.mouseEvents) {\n        // Convert wheel events into up/down events when the buffer does not have scrollback, this\n        // enables scrolling in apps hosted in the alt buffer such as vim or tmux.\n        if (!this.buffer.hasScrollback) {\n          const amount = this.viewport.getLinesScrolled(ev);\n\n          // Do nothing if there's no vertical scroll\n          if (amount === 0) {\n            return;\n          }\n\n          // Construct and send sequences\n          const sequence = C0.ESC + (this.applicationCursor ? 'O' : '[') + ( ev.deltaY < 0 ? 'A' : 'B');\n          let data = '';\n          for (let i = 0; i < Math.abs(amount); i++) {\n            data += sequence;\n          }\n          this.handler(data);\n        }\n        return;\n      }\n      if (this.x10Mouse || this._vt300Mouse || this._decLocator) return;\n      sendButton(ev);\n      ev.preventDefault();\n    }));\n\n    // allow wheel scrolling in\n    // the shell for example\n    this.register(addDisposableDomListener(el, 'wheel', (ev: WheelEvent) => {\n      if (this.mouseEvents) return;\n      this.viewport.onWheel(ev);\n      return this.cancel(ev);\n    }));\n\n    this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => {\n      if (this.mouseEvents) return;\n      this.viewport.onTouchStart(ev);\n      return this.cancel(ev);\n    }));\n\n    this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => {\n      if (this.mouseEvents) return;\n      this.viewport.onTouchMove(ev);\n      return this.cancel(ev);\n    }));\n  }\n\n  /**\n   * Tells the renderer to refresh terminal content between two rows (inclusive) at the next\n   * opportunity.\n   * @param start The row to start from (between 0 and this.rows - 1).\n   * @param end The row to end at (between start and this.rows - 1).\n   */\n  public refresh(start: number, end: number): void {\n    if (this.renderer) {\n      this.renderer.refreshRows(start, end);\n    }\n  }\n\n  /**\n   * Queues linkification for the specified rows.\n   * @param start The row to start from (between 0 and this.rows - 1).\n   * @param end The row to end at (between start and this.rows - 1).\n   */\n  private _queueLinkification(start: number, end: number): void {\n    if (this.linkifier) {\n      this.linkifier.linkifyRows(start, end);\n    }\n  }\n\n  /**\n   * Change the cursor style for different selection modes\n   */\n  public updateCursorStyle(ev: KeyboardEvent): void {\n    if (this.selectionManager && this.selectionManager.shouldColumnSelect(ev)) {\n      this.element.classList.add('column-select');\n    } else {\n      this.element.classList.remove('column-select');\n    }\n  }\n\n  /**\n   * Display the cursor element\n   */\n  public showCursor(): void {\n    if (!this.cursorState) {\n      this.cursorState = 1;\n      this.refresh(this.buffer.y, this.buffer.y);\n    }\n  }\n\n  /**\n   * Scroll the terminal down 1 row, creating a blank line.\n   * @param isWrapped Whether the new line is wrapped from the previous line.\n   */\n  public scroll(isWrapped: boolean = false): void {\n    let newLine: IBufferLine;\n    newLine = this._blankLine;\n    const eraseAttr = this.eraseAttrData();\n    if (!newLine || newLine.length !== this.cols || newLine.getFg(0) !== eraseAttr.fg || newLine.getBg(0) !== eraseAttr.bg) {\n      newLine = this.buffer.getBlankLine(eraseAttr, isWrapped);\n      this._blankLine = newLine;\n    }\n    newLine.isWrapped = isWrapped;\n\n    const topRow = this.buffer.ybase + this.buffer.scrollTop;\n    const bottomRow = this.buffer.ybase + this.buffer.scrollBottom;\n\n    if (this.buffer.scrollTop === 0) {\n      // Determine whether the buffer is going to be trimmed after insertion.\n      const willBufferBeTrimmed = this.buffer.lines.isFull;\n\n      // Insert the line using the fastest method\n      if (bottomRow === this.buffer.lines.length - 1) {\n        if (willBufferBeTrimmed) {\n          this.buffer.lines.recycle().copyFrom(newLine);\n        } else {\n          this.buffer.lines.push(newLine.clone());\n        }\n      } else {\n        this.buffer.lines.splice(bottomRow + 1, 0, newLine.clone());\n      }\n\n      // Only adjust ybase and ydisp when the buffer is not trimmed\n      if (!willBufferBeTrimmed) {\n        this.buffer.ybase++;\n        // Only scroll the ydisp with ybase if the user has not scrolled up\n        if (!this._userScrolling) {\n          this.buffer.ydisp++;\n        }\n      } else {\n        // When the buffer is full and the user has scrolled up, keep the text\n        // stable unless ydisp is right at the top\n        if (this._userScrolling) {\n          this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);\n        }\n      }\n    } else {\n      // scrollTop is non-zero which means no line will be going to the\n      // scrollback, instead we can just shift them in-place.\n      const scrollRegionHeight = bottomRow - topRow + 1/*as it's zero-based*/;\n      this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);\n      this.buffer.lines.set(bottomRow, newLine.clone());\n    }\n\n    // Move the viewport to the bottom of the buffer unless the user is\n    // scrolling.\n    if (!this._userScrolling) {\n      this.buffer.ydisp = this.buffer.ybase;\n    }\n\n    // Flag rows that need updating\n    this.updateRange(this.buffer.scrollTop);\n    this.updateRange(this.buffer.scrollBottom);\n\n    this._onScroll.fire(this.buffer.ydisp);\n  }\n\n  /**\n   * Scroll the display of the terminal\n   * @param disp The number of lines to scroll down (negative scroll up).\n   * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used\n   * to avoid unwanted events being handled by the viewport when the event was triggered from the\n   * viewport originally.\n   */\n  public scrollLines(disp: number, suppressScrollEvent?: boolean): void {\n    if (disp < 0) {\n      if (this.buffer.ydisp === 0) {\n        return;\n      }\n      this._userScrolling = true;\n    } else if (disp + this.buffer.ydisp >= this.buffer.ybase) {\n      this._userScrolling = false;\n    }\n\n    const oldYdisp = this.buffer.ydisp;\n    this.buffer.ydisp = Math.max(Math.min(this.buffer.ydisp + disp, this.buffer.ybase), 0);\n\n    // No change occurred, don't trigger scroll/refresh\n    if (oldYdisp === this.buffer.ydisp) {\n      return;\n    }\n\n    if (!suppressScrollEvent) {\n      this._onScroll.fire(this.buffer.ydisp);\n    }\n\n    this.refresh(0, this.rows - 1);\n  }\n\n  /**\n   * Scroll the display of the terminal by a number of pages.\n   * @param pageCount The number of pages to scroll (negative scrolls up).\n   */\n  public scrollPages(pageCount: number): void {\n    this.scrollLines(pageCount * (this.rows - 1));\n  }\n\n  /**\n   * Scrolls the display of the terminal to the top.\n   */\n  public scrollToTop(): void {\n    this.scrollLines(-this.buffer.ydisp);\n  }\n\n  /**\n   * Scrolls the display of the terminal to the bottom.\n   */\n  public scrollToBottom(): void {\n    this.scrollLines(this.buffer.ybase - this.buffer.ydisp);\n  }\n\n  public scrollToLine(line: number): void {\n    const scrollAmount = line - this.buffer.ydisp;\n    if (scrollAmount !== 0) {\n      this.scrollLines(scrollAmount);\n    }\n  }\n\n  /**\n   * Writes text to the terminal.\n   * @param data The text to write to the terminal.\n   */\n  public write(data: string): void {\n    // Ensure the terminal isn't disposed\n    if (this._isDisposed) {\n      return;\n    }\n\n    // Ignore falsy data values (including the empty string)\n    if (!data) {\n      return;\n    }\n\n    this.writeBuffer.push(data);\n\n    // Send XOFF to pause the pty process if the write buffer becomes too large so\n    // xterm.js can catch up before more data is sent. This is necessary in order\n    // to keep signals such as ^C responsive.\n    if (this.options.useFlowControl && !this._xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {\n      // XOFF - stop pty pipe\n      // XON will be triggered by emulator before processing data chunk\n      this.handler(C0.DC3);\n      this._xoffSentToCatchUp = true;\n    }\n\n    if (!this._writeInProgress && this.writeBuffer.length > 0) {\n      // Kick off a write which will write all data in sequence recursively\n      this._writeInProgress = true;\n      // Kick off an async innerWrite so more writes can come in while processing data\n      setTimeout(() => {\n        this._innerWrite();\n      });\n    }\n  }\n\n  protected _innerWrite(bufferOffset: number = 0): void {\n    // Ensure the terminal isn't disposed\n    if (this._isDisposed) {\n      this.writeBuffer = [];\n    }\n\n    const startTime = Date.now();\n    while (this.writeBuffer.length > bufferOffset) {\n      const data = this.writeBuffer[bufferOffset];\n      bufferOffset++;\n\n      // If XOFF was sent in order to catch up with the pty process, resume it if\n      // we reached the end of the writeBuffer to allow more data to come in.\n      if (this._xoffSentToCatchUp && this.writeBuffer.length === bufferOffset) {\n        this.handler(C0.DC1);\n        this._xoffSentToCatchUp = false;\n      }\n\n      this._refreshStart = this.buffer.y;\n      this._refreshEnd = this.buffer.y;\n\n      // HACK: Set the parser state based on it's state at the time of return.\n      // This works around the bug #662 which saw the parser state reset in the\n      // middle of parsing escape sequence in two chunks. For some reason the\n      // state of the parser resets to 0 after exiting parser.parse. This change\n      // just sets the state back based on the correct return statement.\n\n      this._inputHandler.parse(data);\n\n      this.updateRange(this.buffer.y);\n      this.refresh(this._refreshStart, this._refreshEnd);\n\n      if (Date.now() - startTime >= WRITE_TIMEOUT_MS) {\n        break;\n      }\n    }\n    if (this.writeBuffer.length > bufferOffset) {\n      // Allow renderer to catch up before processing the next batch\n      setTimeout(() => this._innerWrite(bufferOffset), 0);\n    } else {\n      this._writeInProgress = false;\n      this.writeBuffer = [];\n    }\n  }\n\n  /**\n   * Writes text to the terminal, followed by a break line character (\\n).\n   * @param data The text to write to the terminal.\n   */\n  public writeln(data: string): void {\n    this.write(data + '\\r\\n');\n  }\n\n  /**\n   * Attaches a custom key event handler which is run before keys are processed,\n   * giving consumers of xterm.js ultimate control as to what keys should be\n   * processed by the terminal and what keys should not.\n   * @param customKeyEventHandler The custom KeyboardEvent handler to attach.\n   * This is a function that takes a KeyboardEvent, allowing consumers to stop\n   * propagation and/or prevent the default action. The function returns whether\n   * the event should be processed by xterm.js.\n   */\n  public attachCustomKeyEventHandler(customKeyEventHandler: CustomKeyEventHandler): void {\n    this._customKeyEventHandler = customKeyEventHandler;\n  }\n\n  /** Add handler for CSI escape sequence. See xterm.d.ts for details. */\n  public addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable {\n    return this._inputHandler.addCsiHandler(flag, callback);\n  }\n  /** Add handler for OSC escape sequence. See xterm.d.ts for details. */\n  public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    return this._inputHandler.addOscHandler(ident, callback);\n  }\n\n  /**\n   * Registers a link matcher, allowing custom link patterns to be matched and\n   * handled.\n   * @param regex The regular expression to search for, specifically\n   * this searches the textContent of the rows. You will want to use \\s to match\n   * a space ' ' character for example.\n   * @param handler The callback when the link is called.\n   * @param options Options for the link matcher.\n   * @return The ID of the new matcher, this can be used to deregister.\n   */\n  public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number {\n    const matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);\n    this.refresh(0, this.rows - 1);\n    return matcherId;\n  }\n\n  /**\n   * Deregisters a link matcher if it has been registered.\n   * @param matcherId The link matcher's ID (returned after register)\n   */\n  public deregisterLinkMatcher(matcherId: number): void {\n    if (this.linkifier.deregisterLinkMatcher(matcherId)) {\n      this.refresh(0, this.rows - 1);\n    }\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number {\n    const joinerId = this.renderer.registerCharacterJoiner(handler);\n    this.refresh(0, this.rows - 1);\n    return joinerId;\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): void {\n    if (this.renderer.deregisterCharacterJoiner(joinerId)) {\n      this.refresh(0, this.rows - 1);\n    }\n  }\n\n  public get markers(): IMarker[] {\n    return this.buffer.markers;\n  }\n\n  public addMarker(cursorYOffset: number): IMarker {\n    // Disallow markers on the alt buffer\n    if (this.buffer !== this.buffers.normal) {\n      return;\n    }\n\n    return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);\n  }\n\n  /**\n   * Gets whether the terminal has an active selection.\n   */\n  public hasSelection(): boolean {\n    return this.selectionManager ? this.selectionManager.hasSelection : false;\n  }\n\n  /**\n   * Gets the terminal's current selection, this is useful for implementing copy\n   * behavior outside of xterm.js.\n   */\n  public getSelection(): string {\n    return this.selectionManager ? this.selectionManager.selectionText : '';\n  }\n\n  /**\n   * Clears the current terminal selection.\n   */\n  public clearSelection(): void {\n    if (this.selectionManager) {\n      this.selectionManager.clearSelection();\n    }\n  }\n\n  /**\n   * Selects all text within the terminal.\n   */\n  public selectAll(): void {\n    if (this.selectionManager) {\n      this.selectionManager.selectAll();\n    }\n  }\n\n  public selectLines(start: number, end: number): void {\n    if (this.selectionManager) {\n      this.selectionManager.selectLines(start, end);\n    }\n  }\n\n  /**\n   * Handle a keydown event\n   * Key Resources:\n   *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent\n   * @param ev The keydown event to be handled.\n   */\n  protected _keyDown(event: KeyboardEvent): boolean {\n    if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {\n      return false;\n    }\n\n    if (!this._compositionHelper.keydown(event)) {\n      if (this.buffer.ybase !== this.buffer.ydisp) {\n        this.scrollToBottom();\n      }\n      return false;\n    }\n\n    const result = evaluateKeyboardEvent(event, this.applicationCursor, this.browser.isMac, this.options.macOptionIsMeta);\n\n    this.updateCursorStyle(event);\n\n    // if (result.key === C0.DC3) { // XOFF\n    //   this._writeStopped = true;\n    // } else if (result.key === C0.DC1) { // XON\n    //   this._writeStopped = false;\n    // }\n\n    if (result.type === KeyboardResultType.PAGE_DOWN || result.type === KeyboardResultType.PAGE_UP) {\n      const scrollCount = this.rows - 1;\n      this.scrollLines(result.type === KeyboardResultType.PAGE_UP ? -scrollCount : scrollCount);\n      return this.cancel(event, true);\n    }\n\n    if (result.type === KeyboardResultType.SELECT_ALL) {\n      this.selectAll();\n    }\n\n    if (this._isThirdLevelShift(this.browser, event)) {\n      return true;\n    }\n\n    if (result.cancel) {\n      // The event is canceled at the end already, is this necessary?\n      this.cancel(event, true);\n    }\n\n    if (!result.key) {\n      return true;\n    }\n\n    this.emit('keydown', event);\n    this._onKey.fire({ key: result.key, domEvent: event });\n    this.showCursor();\n    this.handler(result.key);\n\n    return this.cancel(event, true);\n  }\n\n  private _isThirdLevelShift(browser: IBrowser, ev: IKeyboardEvent): boolean {\n    const thirdLevelKey =\n        (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||\n        (browser.isMSWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);\n\n    if (ev.type === 'keypress') {\n      return thirdLevelKey;\n    }\n\n    // Don't invoke for arrows, pageDown, home, backspace, etc. (on non-keypress events)\n    return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);\n  }\n\n  /**\n   * Set the G level of the terminal\n   * @param g\n   */\n  public setgLevel(g: number): void {\n    this.glevel = g;\n    this.charset = this.charsets[g];\n  }\n\n  /**\n   * Set the charset for the given G level of the terminal\n   * @param g\n   * @param charset\n   */\n  public setgCharset(g: number, charset: ICharset): void {\n    this.charsets[g] = charset;\n    if (this.glevel === g) {\n      this.charset = charset;\n    }\n  }\n\n  protected _keyUp(ev: KeyboardEvent): void {\n    this.updateCursorStyle(ev);\n  }\n\n  /**\n   * Handle a keypress event.\n   * Key Resources:\n   *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent\n   * @param ev The keypress event to be handled.\n   */\n  protected _keyPress(ev: KeyboardEvent): boolean {\n    let key;\n\n    if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {\n      return false;\n    }\n\n    this.cancel(ev);\n\n    if (ev.charCode) {\n      key = ev.charCode;\n    } else if (ev.which === null || ev.which === undefined) {\n      key = ev.keyCode;\n    } else if (ev.which !== 0 && ev.charCode !== 0) {\n      key = ev.which;\n    } else {\n      return false;\n    }\n\n    if (!key || (\n      (ev.altKey || ev.ctrlKey || ev.metaKey) && !this._isThirdLevelShift(this.browser, ev)\n    )) {\n      return false;\n    }\n\n    key = String.fromCharCode(key);\n\n    this.emit('keypress', key, ev);\n    this._onKey.fire({ key, domEvent: ev });\n    this.showCursor();\n    this.handler(key);\n\n    return true;\n  }\n\n  /**\n   * Ring the bell.\n   * Note: We could do sweet things with webaudio here\n   */\n  public bell(): void {\n    this.emit('bell');\n    if (this._soundBell()) {\n      this.soundManager.playBellSound();\n    }\n\n    if (this._visualBell()) {\n      this.element.classList.add('visual-bell-active');\n      clearTimeout(this._visualBellTimer);\n      this._visualBellTimer = window.setTimeout(() => {\n        this.element.classList.remove('visual-bell-active');\n      }, 200);\n    }\n  }\n\n  /**\n   * Log the current state to the console.\n   */\n  public log(text: string, data?: any): void {\n    if (!this.options.debug) return;\n    if (!this._context.console || !this._context.console.log) return;\n    this._context.console.log(text, data);\n  }\n\n  /**\n   * Log the current state as error to the console.\n   */\n  public error(text: string, data?: any): void {\n    if (!this.options.debug) return;\n    if (!this._context.console || !this._context.console.error) return;\n    this._context.console.error(text, data);\n  }\n\n  /**\n   * Resizes the terminal.\n   *\n   * @param x The number of columns to resize to.\n   * @param y The number of rows to resize to.\n   */\n  public resize(x: number, y: number): void {\n    if (isNaN(x) || isNaN(y)) {\n      return;\n    }\n\n    if (x === this.cols && y === this.rows) {\n      // Check if we still need to measure the char size (fixes #785).\n      if (this.charMeasure && (!this.charMeasure.width || !this.charMeasure.height)) {\n        this.charMeasure.measure(this.options);\n      }\n      return;\n    }\n\n    if (x < MINIMUM_COLS) x = MINIMUM_COLS;\n    if (y < MINIMUM_ROWS) y = MINIMUM_ROWS;\n\n    this.buffers.resize(x, y);\n\n    this.cols = x;\n    this.rows = y;\n    this.buffers.setupTabStops(this.cols);\n\n    if (this.charMeasure) {\n      this.charMeasure.measure(this.options);\n    }\n\n    this.refresh(0, this.rows - 1);\n    this._onResize.fire({ cols: x, rows: y });\n  }\n\n  /**\n   * Updates the range of rows to refresh\n   * @param y The number of rows to refresh next.\n   */\n  public updateRange(y: number): void {\n    if (y < this._refreshStart) this._refreshStart = y;\n    if (y > this._refreshEnd) this._refreshEnd = y;\n    // if (y > this.refreshEnd) {\n    //   this.refreshEnd = y;\n    //   if (y > this.rows - 1) {\n    //     this.refreshEnd = this.rows - 1;\n    //   }\n    // }\n  }\n\n  /**\n   * Set the range of refreshing to the maximum value\n   */\n  public maxRange(): void {\n    this._refreshStart = 0;\n    this._refreshEnd = this.rows - 1;\n  }\n\n  /**\n   * Clear the entire buffer, making the prompt line the new first line.\n   */\n  public clear(): void {\n    if (this.buffer.ybase === 0 && this.buffer.y === 0) {\n      // Don't clear if it's already clear\n      return;\n    }\n    this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y));\n    this.buffer.lines.length = 1;\n    this.buffer.ydisp = 0;\n    this.buffer.ybase = 0;\n    this.buffer.y = 0;\n    for (let i = 1; i < this.rows; i++) {\n      this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA));\n    }\n    this.refresh(0, this.rows - 1);\n    this._onScroll.fire(this.buffer.ydisp);\n  }\n\n  /**\n   * Evaluate if the current terminal is the given argument.\n   * @param term The terminal name to evaluate\n   */\n  public is(term: string): boolean {\n    return (this.options.termName + '').indexOf(term) === 0;\n  }\n\n  /**\n   * Emit the data event and populate the given data.\n   * @param data The data to populate in the event.\n   */\n  public handler(data: string): void {\n    // Prevents all events to pty process if stdin is disabled\n    if (this.options.disableStdin) {\n      return;\n    }\n\n    // Clear the selection if the selection manager is available and has an active selection\n    if (this.selectionManager && this.selectionManager.hasSelection) {\n      this.selectionManager.clearSelection();\n    }\n\n    // Input is being sent to the terminal, the terminal should focus the prompt.\n    if (this.buffer.ybase !== this.buffer.ydisp) {\n      this.scrollToBottom();\n    }\n    this._onData.fire(data);\n  }\n\n  /**\n   * Emit the 'title' event and populate the given title.\n   * @param title The title to populate in the event.\n   */\n  public handleTitle(title: string): void {\n    this._onTitleChange.fire(title);\n  }\n\n  /**\n   * ESC\n   */\n\n  /**\n   * ESC D Index (IND is 0x84).\n   */\n  public index(): void {\n    this.buffer.y++;\n    if (this.buffer.y > this.buffer.scrollBottom) {\n      this.buffer.y--;\n      this.scroll();\n    }\n    // If the end of the line is hit, prevent this action from wrapping around to the next line.\n    if (this.buffer.x >= this.cols) {\n      this.buffer.x--;\n    }\n  }\n\n  /**\n   * ESC M Reverse Index (RI is 0x8d).\n   *\n   * Move the cursor up one row, inserting a new blank line if necessary.\n   */\n  public reverseIndex(): void {\n    if (this.buffer.y === this.buffer.scrollTop) {\n      // possibly move the code below to term.reverseScroll();\n      // test: echo -ne '\\e[1;1H\\e[44m\\eM\\e[0m'\n      // blankLine(true) is xterm/linux behavior\n      const scrollRegionHeight = this.buffer.scrollBottom - this.buffer.scrollTop;\n      this.buffer.lines.shiftElements(this.buffer.y + this.buffer.ybase, scrollRegionHeight, 1);\n      this.buffer.lines.set(this.buffer.y + this.buffer.ybase, this.buffer.getBlankLine(this.eraseAttrData()));\n      this.updateRange(this.buffer.scrollTop);\n      this.updateRange(this.buffer.scrollBottom);\n    } else {\n      this.buffer.y--;\n    }\n  }\n\n  /**\n   * ESC c Full Reset (RIS).\n   */\n  public reset(): void {\n    this.options.rows = this.rows;\n    this.options.cols = this.cols;\n    const customKeyEventHandler = this._customKeyEventHandler;\n    const inputHandler = this._inputHandler;\n    const cursorState = this.cursorState;\n    this._setup();\n    this._customKeyEventHandler = customKeyEventHandler;\n    this._inputHandler = inputHandler;\n    this.cursorState = cursorState;\n    this.refresh(0, this.rows - 1);\n    if (this.viewport) {\n      this.viewport.syncScrollArea();\n    }\n  }\n\n\n  /**\n   * ESC H Tab Set (HTS is 0x88).\n   */\n  public tabSet(): void {\n    this.buffer.tabs[this.buffer.x] = true;\n  }\n\n  // TODO: Remove cancel function and cancelEvents option\n  public cancel(ev: Event, force?: boolean): boolean {\n    if (!this.options.cancelEvents && !force) {\n      return;\n    }\n    ev.preventDefault();\n    ev.stopPropagation();\n    return false;\n  }\n\n  private _visualBell(): boolean {\n    return false;\n    // return this.options.bellStyle === 'visual' ||\n    //     this.options.bellStyle === 'both';\n  }\n\n  private _soundBell(): boolean {\n    return this.options.bellStyle === 'sound';\n    // return this.options.bellStyle === 'sound' ||\n    //     this.options.bellStyle === 'both';\n  }\n}\n\n/**\n * Helpers\n */\n\nfunction wasModifierKeyOnlyEvent(ev: KeyboardEvent): boolean {\n  return ev.keyCode === 16 || // Shift\n    ev.keyCode === 17 || // Ctrl\n    ev.keyCode === 18; // Alt\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport let blankLine = 'Blank line';\nexport let promptLabel = 'Terminal input';\nexport let tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal, ISoundManager } from './Types';\n\n// Source: https://freesound.org/people/altemark/sounds/45759/\n// This sound is released under the Creative Commons Attribution 3.0 Unported\n// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been\n// made, apart from the conversion to base64.\nexport const DEFAULT_BELL_SOUND = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';\n\nexport class SoundManager implements ISoundManager {\n  private static _audioContext: AudioContext;\n\n  static get audioContext(): AudioContext | null {\n    if (!SoundManager._audioContext) {\n      const audioContextCtor: typeof AudioContext = (<any>window).AudioContext || (<any>window).webkitAudioContext;\n      if (!audioContextCtor) {\n        console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');\n        return null;\n      }\n      SoundManager._audioContext = new audioContextCtor();\n    }\n    return SoundManager._audioContext;\n  }\n\n  constructor(\n    private _terminal: ITerminal\n  ) {\n  }\n\n  public playBellSound(): void {\n    const ctx = SoundManager.audioContext;\n    if (!ctx) {\n      return;\n    }\n    const bellAudioSource = ctx.createBufferSource();\n    ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._terminal.options.bellSound)), (buffer) => {\n      bellAudioSource.buffer = buffer;\n      bellAudioSource.connect(ctx.destination);\n      bellAudioSource.start(0);\n    });\n  }\n\n  private _base64ToArrayBuffer(base64: string): ArrayBuffer {\n    const binaryString = window.atob(base64);\n    const len = binaryString.length;\n    const bytes = new Uint8Array(len);\n\n    for (let i = 0; i < len; i++) {\n      bytes[i] = binaryString.charCodeAt(i);\n    }\n\n    return bytes.buffer;\n  }\n\n  private _removeMimeType(dataURI: string): string {\n    // Split the input to get the mime-type and the data itself\n    const splitUri = dataURI.split(',');\n\n    // Return only the data\n    return splitUri[1];\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal } from './Types';\n\n/**\n * Represents a selection within the buffer. This model only cares about column\n * and row coordinates, not wide characters.\n */\nexport class SelectionModel {\n  /**\n   * Whether select all is currently active.\n   */\n  public isSelectAllActive: boolean;\n\n  /**\n   * The [x, y] position the selection starts at.\n   */\n  public selectionStart: [number, number];\n\n  /**\n   * The minimal length of the selection from the start position. When double\n   * clicking on a word, the word will be selected which makes the selection\n   * start at the start of the word and makes this variable the length.\n   */\n  public selectionStartLength: number;\n\n  /**\n   * The [x, y] position the selection ends at.\n   */\n  public selectionEnd: [number, number];\n\n  constructor(\n    private _terminal: ITerminal\n  ) {\n    this.clearSelection();\n  }\n\n  /**\n   * Clears the current selection.\n   */\n  public clearSelection(): void {\n    this.selectionStart = null;\n    this.selectionEnd = null;\n    this.isSelectAllActive = false;\n    this.selectionStartLength = 0;\n  }\n\n  /**\n   * The final selection start, taking into consideration select all.\n   */\n  public get finalSelectionStart(): [number, number] {\n    if (this.isSelectAllActive) {\n      return [0, 0];\n    }\n\n    if (!this.selectionEnd || !this.selectionStart) {\n      return this.selectionStart;\n    }\n\n    return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;\n  }\n\n  /**\n   * The final selection end, taking into consideration select all, double click\n   * word selection and triple click line selection.\n   */\n  public get finalSelectionEnd(): [number, number] {\n    if (this.isSelectAllActive) {\n      return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];\n    }\n\n    if (!this.selectionStart) {\n      return null;\n    }\n\n    // Use the selection start + length if the end doesn't exist or they're reversed\n    if (!this.selectionEnd || this.areSelectionValuesReversed()) {\n      const startPlusLength = this.selectionStart[0] + this.selectionStartLength;\n      if (startPlusLength > this._terminal.cols) {\n        return [startPlusLength % this._terminal.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._terminal.cols)];\n      }\n      return [startPlusLength, this.selectionStart[1]];\n    }\n\n    // Ensure the the word/line is selected after a double/triple click\n    if (this.selectionStartLength) {\n      // Select the larger of the two when start and end are on the same line\n      if (this.selectionEnd[1] === this.selectionStart[1]) {\n        return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];\n      }\n    }\n    return this.selectionEnd;\n  }\n\n  /**\n   * Returns whether the selection start and end are reversed.\n   */\n  public areSelectionValuesReversed(): boolean {\n    const start = this.selectionStart;\n    const end = this.selectionEnd;\n    if (!start || !end) {\n      return false;\n    }\n    return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);\n  }\n\n  /**\n   * Handle the buffer being trimmed, adjust the selection position.\n   * @param amount The amount the buffer is being trimmed.\n   * @return Whether a refresh is necessary.\n   */\n  public onTrim(amount: number): boolean {\n    // Adjust the selection position based on the trimmed amount.\n    if (this.selectionStart) {\n      this.selectionStart[1] -= amount;\n    }\n    if (this.selectionEnd) {\n      this.selectionEnd[1] -= amount;\n    }\n\n    // The selection has moved off the buffer, clear it.\n    if (this.selectionEnd && this.selectionEnd[1] < 0) {\n      this.clearSelection();\n      return true;\n    }\n\n    // If the selection start is trimmed, ensure the start column is 0.\n    if (this.selectionStart && this.selectionStart[1] < 0) {\n      this.selectionStart[1] = 0;\n    }\n    return false;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal, ISelectionManager, IBuffer, IBufferLine, ISelectionRedrawRequestEvent } from './Types';\nimport { MouseHelper } from './MouseHelper';\nimport * as Browser from './common/Platform';\nimport { CharMeasure } from './CharMeasure';\nimport { SelectionModel } from './SelectionModel';\nimport { AltClickHandler } from './handlers/AltClickHandler';\nimport { CellData } from './BufferLine';\nimport { IDisposable } from 'xterm';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\n\n/**\n * The number of pixels the mouse needs to be above or below the viewport in\n * order to scroll at the maximum speed.\n */\nconst DRAG_SCROLL_MAX_THRESHOLD = 50;\n\n/**\n * The maximum scrolling speed\n */\nconst DRAG_SCROLL_MAX_SPEED = 15;\n\n/**\n * The number of milliseconds between drag scroll updates.\n */\nconst DRAG_SCROLL_INTERVAL = 50;\n\n/**\n * The maximum amount of time that can have elapsed for an alt click to move the\n * cursor.\n */\nconst ALT_CLICK_MOVE_CURSOR_TIME = 500;\n\n/**\n * A string containing all characters that are considered word separated by the\n * double click to select work logic.\n */\nconst WORD_SEPARATORS = ' ()[]{}\\'\"';\n\nconst NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);\nconst ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');\n\n/**\n * Represents a position of a word on a line.\n */\ninterface IWordPosition {\n  start: number;\n  length: number;\n}\n\n/**\n * A selection mode, this drives how the selection behaves on mouse move.\n */\nexport const enum SelectionMode {\n  NORMAL,\n  WORD,\n  LINE,\n  COLUMN\n}\n\n/**\n * A class that manages the selection of the terminal. With help from\n * SelectionModel, SelectionManager handles with all logic associated with\n * dealing with the selection, including handling mouse interaction, wide\n * characters and fetching the actual text within the selection. Rendering is\n * not handled by the SelectionManager but the onRedrawRequest event is fired\n * when the selection is ready to be redrawn (on an animation frame).\n */\nexport class SelectionManager implements ISelectionManager {\n  protected _model: SelectionModel;\n\n  /**\n   * The amount to scroll every drag scroll update (depends on how far the mouse\n   * drag is above or below the terminal).\n   */\n  private _dragScrollAmount: number;\n\n  /**\n   * The current selection mode.\n   */\n  protected _activeSelectionMode: SelectionMode;\n\n  /**\n   * A setInterval timer that is active while the mouse is down whose callback\n   * scrolls the viewport when necessary.\n   */\n  private _dragScrollIntervalTimer: NodeJS.Timer;\n\n  /**\n   * The animation frame ID used for refreshing the selection.\n   */\n  private _refreshAnimationFrame: number;\n\n  /**\n   * Whether selection is enabled.\n   */\n  private _enabled = true;\n\n  private _mouseMoveListener: EventListener;\n  private _mouseUpListener: EventListener;\n  private _trimListener: IDisposable;\n  private _workCell: CellData = new CellData();\n\n  private _mouseDownTimeStamp: number;\n\n  private _onLinuxMouseSelection = new EventEmitter2<string>();\n  public get onLinuxMouseSelection(): IEvent<string> { return this._onLinuxMouseSelection.event; }\n  private _onRedrawRequest = new EventEmitter2<ISelectionRedrawRequestEvent>();\n  public get onRedrawRequest(): IEvent<ISelectionRedrawRequestEvent> { return this._onRedrawRequest.event; }\n  private _onSelectionChange = new EventEmitter2<void>();\n  public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }\n\n  constructor(\n    private _terminal: ITerminal,\n    private _charMeasure: CharMeasure\n  ) {\n    this._initListeners();\n    this.enable();\n\n    this._model = new SelectionModel(_terminal);\n    this._activeSelectionMode = SelectionMode.NORMAL;\n  }\n\n  public dispose(): void {\n    this._removeMouseDownListeners();\n  }\n\n  private get _buffer(): IBuffer {\n    return this._terminal.buffers.active;\n  }\n\n  /**\n   * Initializes listener variables.\n   */\n  private _initListeners(): void {\n    this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);\n    this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);\n\n    this.initBuffersListeners();\n  }\n\n  public initBuffersListeners(): void {\n    this._trimListener = this._terminal.buffer.lines.onTrim(amount => this._onTrim(amount));\n    this._terminal.buffers.onBufferActivate(e => this._onBufferActivate(e));\n  }\n\n  /**\n   * Disables the selection manager. This is useful for when terminal mouse\n   * are enabled.\n   */\n  public disable(): void {\n    this.clearSelection();\n    this._enabled = false;\n  }\n\n  /**\n   * Enable the selection manager.\n   */\n  public enable(): void {\n    this._enabled = true;\n  }\n\n  public get selectionStart(): [number, number] { return this._model.finalSelectionStart; }\n  public get selectionEnd(): [number, number] { return this._model.finalSelectionEnd; }\n\n  /**\n   * Gets whether there is an active text selection.\n   */\n  public get hasSelection(): boolean {\n    const start = this._model.finalSelectionStart;\n    const end = this._model.finalSelectionEnd;\n    if (!start || !end) {\n      return false;\n    }\n    return start[0] !== end[0] || start[1] !== end[1];\n  }\n\n  /**\n   * Gets the text currently selected.\n   */\n  public get selectionText(): string {\n    const start = this._model.finalSelectionStart;\n    const end = this._model.finalSelectionEnd;\n    if (!start || !end) {\n      return '';\n    }\n\n    const result: string[] = [];\n\n    if (this._activeSelectionMode === SelectionMode.COLUMN) {\n      // Ignore zero width selections\n      if (start[0] === end[0]) {\n        return '';\n      }\n\n      for (let i = start[1]; i <= end[1]; i++) {\n        const lineText = this._buffer.translateBufferLineToString(i, true, start[0], end[0]);\n        result.push(lineText);\n      }\n    } else {\n      // Get first row\n      const startRowEndCol = start[1] === end[1] ? end[0] : undefined;\n      result.push(this._buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));\n\n      // Get middle rows\n      for (let i = start[1] + 1; i <= end[1] - 1; i++) {\n        const bufferLine = this._buffer.lines.get(i);\n        const lineText = this._buffer.translateBufferLineToString(i, true);\n        if (bufferLine.isWrapped) {\n          result[result.length - 1] += lineText;\n        } else {\n          result.push(lineText);\n        }\n      }\n\n      // Get final row\n      if (start[1] !== end[1]) {\n        const bufferLine = this._buffer.lines.get(end[1]);\n        const lineText = this._buffer.translateBufferLineToString(end[1], true, 0, end[0]);\n        if (bufferLine.isWrapped) {\n          result[result.length - 1] += lineText;\n        } else {\n          result.push(lineText);\n        }\n      }\n    }\n\n    // Format string by replacing non-breaking space chars with regular spaces\n    // and joining the array into a multi-line string.\n    const formattedResult = result.map(line => {\n      return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');\n    }).join(Browser.isMSWindows ? '\\r\\n' : '\\n');\n\n    return formattedResult;\n  }\n\n  /**\n   * Clears the current terminal selection.\n   */\n  public clearSelection(): void {\n    this._model.clearSelection();\n    this._removeMouseDownListeners();\n    this.refresh();\n  }\n\n  /**\n   * Queues a refresh, redrawing the selection on the next opportunity.\n   * @param isLinuxMouseSelection Whether the selection should be registered as a new\n   * selection on Linux.\n   */\n  public refresh(isLinuxMouseSelection?: boolean): void {\n    // Queue the refresh for the renderer\n    if (!this._refreshAnimationFrame) {\n      this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());\n    }\n\n    // If the platform is Linux and the refresh call comes from a mouse event,\n    // we need to update the selection for middle click to paste selection.\n    if (Browser.isLinux && isLinuxMouseSelection) {\n      const selectionText = this.selectionText;\n      if (selectionText.length) {\n        this._onLinuxMouseSelection.fire(this.selectionText);\n      }\n    }\n  }\n\n  /**\n   * Fires the refresh event, causing consumers to pick it up and redraw the\n   * selection state.\n   */\n  private _refresh(): void {\n    this._refreshAnimationFrame = null;\n    this._onRedrawRequest.fire({\n      start: this._model.finalSelectionStart,\n      end: this._model.finalSelectionEnd,\n      columnSelectMode: this._activeSelectionMode === SelectionMode.COLUMN\n    });\n  }\n\n  /**\n   * Checks if the current click was inside the current selection\n   * @param event The mouse event\n   */\n  public isClickInSelection(event: MouseEvent): boolean {\n    const coords = this._getMouseBufferCoords(event);\n    const start = this._model.finalSelectionStart;\n    const end = this._model.finalSelectionEnd;\n\n    if (!start || !end) {\n      return false;\n    }\n\n    return this._areCoordsInSelection(coords, start, end);\n  }\n\n  protected _areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean {\n    return (coords[1] > start[1] && coords[1] < end[1]) ||\n        (start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||\n        (start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||\n        (start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);\n  }\n\n  /**\n   * Selects word at the current mouse event coordinates.\n   * @param event The mouse event.\n   */\n  public selectWordAtCursor(event: MouseEvent): void {\n    const coords = this._getMouseBufferCoords(event);\n    if (coords) {\n      this._selectWordAt(coords, false);\n      this._model.selectionEnd = null;\n      this.refresh(true);\n    }\n  }\n\n  /**\n   * Selects all text within the terminal.\n   */\n  public selectAll(): void {\n    this._model.isSelectAllActive = true;\n    this.refresh();\n    this._onSelectionChange.fire();\n  }\n\n  public selectLines(start: number, end: number): void {\n    this._model.clearSelection();\n    start = Math.max(start, 0);\n    end = Math.min(end, this._terminal.buffer.lines.length - 1);\n    this._model.selectionStart = [0, start];\n    this._model.selectionEnd = [this._terminal.cols, end];\n    this.refresh();\n    this._onSelectionChange.fire();\n  }\n\n  /**\n   * Handle the buffer being trimmed, adjust the selection position.\n   * @param amount The amount the buffer is being trimmed.\n   */\n  private _onTrim(amount: number): void {\n    const needsRefresh = this._model.onTrim(amount);\n    if (needsRefresh) {\n      this.refresh();\n    }\n  }\n\n  /**\n   * Gets the 0-based [x, y] buffer coordinates of the current mouse event.\n   * @param event The mouse event.\n   */\n  private _getMouseBufferCoords(event: MouseEvent): [number, number] {\n    const coords = this._terminal.mouseHelper.getCoords(event, this._terminal.screenElement, this._charMeasure, this._terminal.cols, this._terminal.rows, true);\n    if (!coords) {\n      return null;\n    }\n\n    // Convert to 0-based\n    coords[0]--;\n    coords[1]--;\n\n    // Convert viewport coords to buffer coords\n    coords[1] += this._terminal.buffer.ydisp;\n    return coords;\n  }\n\n  /**\n   * Gets the amount the viewport should be scrolled based on how far out of the\n   * terminal the mouse is.\n   * @param event The mouse event.\n   */\n  private _getMouseEventScrollAmount(event: MouseEvent): number {\n    let offset = MouseHelper.getCoordsRelativeToElement(event, this._terminal.screenElement)[1];\n    const terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);\n    if (offset >= 0 && offset <= terminalHeight) {\n      return 0;\n    }\n    if (offset > terminalHeight) {\n      offset -= terminalHeight;\n    }\n\n    offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);\n    offset /= DRAG_SCROLL_MAX_THRESHOLD;\n    return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));\n  }\n\n  /**\n   * Returns whether the selection manager should force selection, regardless of\n   * whether the terminal is in mouse events mode.\n   * @param event The mouse event.\n   */\n  public shouldForceSelection(event: MouseEvent): boolean {\n    if (Browser.isMac) {\n      return event.altKey && this._terminal.options.macOptionClickForcesSelection;\n    }\n\n    return event.shiftKey;\n  }\n\n  /**\n   * Handles te mousedown event, setting up for a new selection.\n   * @param event The mousedown event.\n   */\n  public onMouseDown(event: MouseEvent): void {\n    this._mouseDownTimeStamp = event.timeStamp;\n    // If we have selection, we want the context menu on right click even if the\n    // terminal is in mouse mode.\n    if (event.button === 2 && this.hasSelection) {\n      return;\n    }\n\n    // Only action the primary button\n    if (event.button !== 0) {\n      return;\n    }\n\n    // Allow selection when using a specific modifier key, even when disabled\n    if (!this._enabled) {\n      if (!this.shouldForceSelection(event)) {\n        return;\n      }\n\n      // Don't send the mouse down event to the current process, we want to select\n      event.stopPropagation();\n    }\n\n    // Tell the browser not to start a regular selection\n    event.preventDefault();\n\n    // Reset drag scroll state\n    this._dragScrollAmount = 0;\n\n    if (this._enabled && event.shiftKey) {\n      this._onIncrementalClick(event);\n    } else {\n      if (event.detail === 1) {\n        this._onSingleClick(event);\n      } else if (event.detail === 2) {\n        this._onDoubleClick(event);\n      } else if (event.detail === 3) {\n        this._onTripleClick(event);\n      }\n    }\n\n    this._addMouseDownListeners();\n    this.refresh(true);\n  }\n\n  /**\n   * Adds listeners when mousedown is triggered.\n   */\n  private _addMouseDownListeners(): void {\n    // Listen on the document so that dragging outside of viewport works\n    this._terminal.element.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);\n    this._terminal.element.ownerDocument.addEventListener('mouseup', this._mouseUpListener);\n    this._dragScrollIntervalTimer = setInterval(() => this._dragScroll(), DRAG_SCROLL_INTERVAL);\n  }\n\n  /**\n   * Removes the listeners that are registered when mousedown is triggered.\n   */\n  private _removeMouseDownListeners(): void {\n    if (this._terminal.element.ownerDocument) {\n      this._terminal.element.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);\n      this._terminal.element.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);\n    }\n    clearInterval(this._dragScrollIntervalTimer);\n    this._dragScrollIntervalTimer = null;\n  }\n\n  /**\n   * Performs an incremental click, setting the selection end position to the mouse\n   * position.\n   * @param event The mouse event.\n   */\n  private _onIncrementalClick(event: MouseEvent): void {\n    if (this._model.selectionStart) {\n      this._model.selectionEnd = this._getMouseBufferCoords(event);\n    }\n  }\n\n  /**\n   * Performs a single click, resetting relevant state and setting the selection\n   * start position.\n   * @param event The mouse event.\n   */\n  private _onSingleClick(event: MouseEvent): void {\n    this._model.selectionStartLength = 0;\n    this._model.isSelectAllActive = false;\n    this._activeSelectionMode = this.shouldColumnSelect(event) ? SelectionMode.COLUMN : SelectionMode.NORMAL;\n\n    // Initialize the new selection\n    this._model.selectionStart = this._getMouseBufferCoords(event);\n    if (!this._model.selectionStart) {\n      return;\n    }\n    this._model.selectionEnd = null;\n\n    // Ensure the line exists\n    const line = this._buffer.lines.get(this._model.selectionStart[1]);\n    if (!line) {\n      return;\n    }\n\n    // Return early if the click event is not in the buffer (eg. in scroll bar)\n    if (line.length >= this._model.selectionStart[0]) {\n      return;\n    }\n\n    // If the mouse is over the second half of a wide character, adjust the\n    // selection to cover the whole character\n    if (line.hasWidth(this._model.selectionStart[0]) === 0) {\n      this._model.selectionStart[0]++;\n    }\n  }\n\n  /**\n   * Performs a double click, selecting the current work.\n   * @param event The mouse event.\n   */\n  private _onDoubleClick(event: MouseEvent): void {\n    const coords = this._getMouseBufferCoords(event);\n    if (coords) {\n      this._activeSelectionMode = SelectionMode.WORD;\n      this._selectWordAt(coords, true);\n    }\n  }\n\n  /**\n   * Performs a triple click, selecting the current line and activating line\n   * select mode.\n   * @param event The mouse event.\n   */\n  private _onTripleClick(event: MouseEvent): void {\n    const coords = this._getMouseBufferCoords(event);\n    if (coords) {\n      this._activeSelectionMode = SelectionMode.LINE;\n      this._selectLineAt(coords[1]);\n    }\n  }\n\n  /**\n   * Returns whether the selection manager should operate in column select mode\n   * @param event the mouse or keyboard event\n   */\n  public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean {\n    return event.altKey && !(Browser.isMac && this._terminal.options.macOptionClickForcesSelection);\n  }\n\n  /**\n   * Handles the mousemove event when the mouse button is down, recording the\n   * end of the selection and refreshing the selection.\n   * @param event The mousemove event.\n   */\n  private _onMouseMove(event: MouseEvent): void {\n    // If the mousemove listener is active it means that a selection is\n    // currently being made, we should stop propagation to prevent mouse events\n    // to be sent to the pty.\n    event.stopImmediatePropagation();\n\n    // Record the previous position so we know whether to redraw the selection\n    // at the end.\n    const previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;\n\n    // Set the initial selection end based on the mouse coordinates\n    this._model.selectionEnd = this._getMouseBufferCoords(event);\n    if (!this._model.selectionEnd) {\n      this.refresh(true);\n      return;\n    }\n\n    // Select the entire line if line select mode is active.\n    if (this._activeSelectionMode === SelectionMode.LINE) {\n      if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {\n        this._model.selectionEnd[0] = 0;\n      } else {\n        this._model.selectionEnd[0] = this._terminal.cols;\n      }\n    } else if (this._activeSelectionMode === SelectionMode.WORD) {\n      this._selectToWordAt(this._model.selectionEnd);\n    }\n\n    // Determine the amount of scrolling that will happen.\n    this._dragScrollAmount = this._getMouseEventScrollAmount(event);\n\n    // If the cursor was above or below the viewport, make sure it's at the\n    // start or end of the viewport respectively. This should only happen when\n    // NOT in column select mode.\n    if (this._activeSelectionMode !== SelectionMode.COLUMN) {\n      if (this._dragScrollAmount > 0) {\n        this._model.selectionEnd[0] = this._terminal.cols;\n      } else if (this._dragScrollAmount < 0) {\n        this._model.selectionEnd[0] = 0;\n      }\n    }\n\n    // If the character is a wide character include the cell to the right in the\n    // selection. Note that selections at the very end of the line will never\n    // have a character.\n    if (this._model.selectionEnd[1] < this._buffer.lines.length) {\n      if (this._buffer.lines.get(this._model.selectionEnd[1]).hasWidth(this._model.selectionEnd[0]) === 0) {\n        this._model.selectionEnd[0]++;\n      }\n    }\n\n    // Only draw here if the selection changes.\n    if (!previousSelectionEnd ||\n      previousSelectionEnd[0] !== this._model.selectionEnd[0] ||\n      previousSelectionEnd[1] !== this._model.selectionEnd[1]) {\n      this.refresh(true);\n    }\n  }\n\n  /**\n   * The callback that occurs every DRAG_SCROLL_INTERVAL ms that does the\n   * scrolling of the viewport.\n   */\n  private _dragScroll(): void {\n    if (this._dragScrollAmount) {\n      this._terminal.scrollLines(this._dragScrollAmount, false);\n      // Re-evaluate selection\n      // If the cursor was above or below the viewport, make sure it's at the\n      // start or end of the viewport respectively. This should only happen when\n      // NOT in column select mode.\n      if (this._dragScrollAmount > 0) {\n        if (this._activeSelectionMode !== SelectionMode.COLUMN) {\n          this._model.selectionEnd[0] = this._terminal.cols;\n        }\n        this._model.selectionEnd[1] = Math.min(this._terminal.buffer.ydisp + this._terminal.rows, this._terminal.buffer.lines.length - 1);\n      } else {\n        if (this._activeSelectionMode !== SelectionMode.COLUMN) {\n          this._model.selectionEnd[0] = 0;\n        }\n        this._model.selectionEnd[1] = this._terminal.buffer.ydisp;\n      }\n      this.refresh();\n    }\n  }\n\n  /**\n   * Handles the mouseup event, removing the mousedown listeners.\n   * @param event The mouseup event.\n   */\n  private _onMouseUp(event: MouseEvent): void {\n    const timeElapsed = event.timeStamp - this._mouseDownTimeStamp;\n\n    this._removeMouseDownListeners();\n\n    if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME) {\n      (new AltClickHandler(event, this._terminal)).move();\n    } else if (this.hasSelection) {\n      this._onSelectionChange.fire();\n    }\n  }\n\n  private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {\n    this.clearSelection();\n    // Only adjust the selection on trim, shiftElements is rarely used (only in\n    // reverseIndex) and delete in a splice is only ever used when the same\n    // number of elements was just added. Given this is could actually be\n    // beneficial to leave the selection as is for these cases.\n    if (this._trimListener) {\n      this._trimListener.dispose();\n    }\n    this._trimListener = e.activeBuffer.lines.onTrim(amount => this._onTrim(amount));\n  }\n\n  /**\n   * Converts a viewport column to the character index on the buffer line, the\n   * latter takes into account wide characters.\n   * @param coords The coordinates to find the 2 index for.\n   */\n  private _convertViewportColToCharacterIndex(bufferLine: IBufferLine, coords: [number, number]): number {\n    let charIndex = coords[0];\n    for (let i = 0; coords[0] >= i; i++) {\n      const length = bufferLine.loadCell(i, this._workCell).getChars().length;\n      if (this._workCell.getWidth() === 0) {\n        // Wide characters aren't included in the line string so decrement the\n        // index so the index is back on the wide character.\n        charIndex--;\n      } else if (length > 1 && coords[0] !== i) {\n        // Emojis take up multiple characters, so adjust accordingly. For these\n        // we don't want ot include the character at the column as we're\n        // returning the start index in the string, not the end index.\n        charIndex += length - 1;\n      }\n    }\n    return charIndex;\n  }\n\n  public setSelection(col: number, row: number, length: number): void {\n    this._model.clearSelection();\n    this._removeMouseDownListeners();\n    this._model.selectionStart = [col, row];\n    this._model.selectionStartLength = length;\n    this.refresh();\n  }\n\n  /**\n   * Gets positional information for the word at the coordinated specified.\n   * @param coords The coordinates to get the word at.\n   */\n  private _getWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean, followWrappedLinesAbove: boolean = true, followWrappedLinesBelow: boolean = true): IWordPosition {\n    // Ensure coords are within viewport (eg. not within scroll bar)\n    if (coords[0] >= this._terminal.cols) {\n      return null;\n    }\n\n    const bufferLine = this._buffer.lines.get(coords[1]);\n    if (!bufferLine) {\n      return null;\n    }\n\n    const line = this._buffer.translateBufferLineToString(coords[1], false);\n\n    // Get actual index, taking into consideration wide characters\n    let startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);\n    let endIndex = startIndex;\n\n    // Record offset to be used later\n    const charOffset = coords[0] - startIndex;\n    let leftWideCharCount = 0;\n    let rightWideCharCount = 0;\n    let leftLongCharOffset = 0;\n    let rightLongCharOffset = 0;\n\n    if (line.charAt(startIndex) === ' ') {\n      // Expand until non-whitespace is hit\n      while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {\n        startIndex--;\n      }\n      while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {\n        endIndex++;\n      }\n    } else {\n      // Expand until whitespace is hit. This algorithm works by scanning left\n      // and right from the starting position, keeping both the index format\n      // (line) and the column format (bufferLine) in sync. When a wide\n      // character is hit, it is recorded and the column index is adjusted.\n      let startCol = coords[0];\n      let endCol = coords[0];\n\n      // Consider the initial position, skip it and increment the wide char\n      // variable\n      if (bufferLine.getWidth(startCol) === 0) {\n        leftWideCharCount++;\n        startCol--;\n      }\n      if (bufferLine.getWidth(endCol) === 2) {\n        rightWideCharCount++;\n        endCol++;\n      }\n\n      // Adjust the end index for characters whose length are > 1 (emojis)\n      const length = bufferLine.getString(endCol).length;\n      if (length > 1) {\n        rightLongCharOffset += length - 1;\n        endIndex += length - 1;\n      }\n\n      // Expand the string in both directions until a space is hit\n      while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine.loadCell(startCol - 1, this._workCell))) {\n        bufferLine.loadCell(startCol - 1, this._workCell);\n        const length = this._workCell.getChars().length;\n        if (this._workCell.getWidth() === 0) {\n          // If the next character is a wide char, record it and skip the column\n          leftWideCharCount++;\n          startCol--;\n        } else if (length > 1) {\n          // If the next character's string is longer than 1 char (eg. emoji),\n          // adjust the index\n          leftLongCharOffset += length - 1;\n          startIndex -= length - 1;\n        }\n        startIndex--;\n        startCol--;\n      }\n      while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine.loadCell(endCol + 1, this._workCell))) {\n        bufferLine.loadCell(endCol + 1, this._workCell);\n        const length = this._workCell.getChars().length;\n        if (this._workCell.getWidth() === 2) {\n          // If the next character is a wide char, record it and skip the column\n          rightWideCharCount++;\n          endCol++;\n        } else if (length > 1) {\n          // If the next character's string is longer than 1 char (eg. emoji),\n          // adjust the index\n          rightLongCharOffset += length - 1;\n          endIndex += length - 1;\n        }\n        endIndex++;\n        endCol++;\n      }\n    }\n\n    // Incremenet the end index so it is at the start of the next character\n    endIndex++;\n\n    // Calculate the start _column_, converting the the string indexes back to\n    // column coordinates.\n    let start =\n        startIndex // The index of the selection's start char in the line string\n        + charOffset // The difference between the initial char's column and index\n        - leftWideCharCount // The number of wide chars left of the initial char\n        + leftLongCharOffset; // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)\n\n    // Calculate the length in _columns_, converting the the string indexes back\n    // to column coordinates.\n    let length = Math.min(this._terminal.cols, // Disallow lengths larger than the terminal cols\n        endIndex // The index of the selection's end char in the line string\n        - startIndex // The index of the selection's start char in the line string\n        + leftWideCharCount // The number of wide chars left of the initial char\n        + rightWideCharCount // The number of wide chars right of the initial char (inclusive)\n        - leftLongCharOffset // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)\n        - rightLongCharOffset); // The number of additional chars right of the initial char (inclusive) added by columns with strings longer than 1 (emojis)\n\n    if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {\n      return null;\n    }\n\n    // Recurse upwards if the line is wrapped and the word wraps to the above line\n    if (followWrappedLinesAbove) {\n      if (start === 0 && bufferLine.getCodePoint(0) !== 32 /*' '*/) {\n        const previousBufferLine = this._buffer.lines.get(coords[1] - 1);\n        if (previousBufferLine && bufferLine.isWrapped && previousBufferLine.getCodePoint(this._terminal.cols - 1) !== 32 /*' '*/) {\n          const previousLineWordPosition = this._getWordAt([this._terminal.cols - 1, coords[1] - 1], false, true, false);\n          if (previousLineWordPosition) {\n            const offset = this._terminal.cols - previousLineWordPosition.start;\n            start -= offset;\n            length += offset;\n          }\n        }\n      }\n    }\n\n    // Recurse downwards if the line is wrapped and the word wraps to the next line\n    if (followWrappedLinesBelow) {\n      if (start + length === this._terminal.cols && bufferLine.getCodePoint(this._terminal.cols - 1) !== 32 /*' '*/) {\n        const nextBufferLine = this._buffer.lines.get(coords[1] + 1);\n        if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32 /*' '*/) {\n          const nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);\n          if (nextLineWordPosition) {\n            length += nextLineWordPosition.length;\n          }\n        }\n      }\n    }\n\n    return { start, length };\n  }\n\n  /**\n   * Selects the word at the coordinates specified.\n   * @param coords The coordinates to get the word at.\n   * @param allowWhitespaceOnlySelection If whitespace should be selected\n   */\n  protected _selectWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean): void {\n    const wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);\n    if (wordPosition) {\n      // Adjust negative start value\n      while (wordPosition.start < 0) {\n        wordPosition.start += this._terminal.cols;\n        coords[1]--;\n      }\n      this._model.selectionStart = [wordPosition.start, coords[1]];\n      this._model.selectionStartLength = wordPosition.length;\n    }\n  }\n\n  /**\n   * Sets the selection end to the word at the coordinated specified.\n   * @param coords The coordinates to get the word at.\n   */\n  private _selectToWordAt(coords: [number, number]): void {\n    const wordPosition = this._getWordAt(coords, true);\n    if (wordPosition) {\n      let endRow = coords[1];\n\n      // Adjust negative start value\n      while (wordPosition.start < 0) {\n        wordPosition.start += this._terminal.cols;\n        endRow--;\n      }\n\n      // Adjust wrapped length value, this only needs to happen when values are reversed as in that\n      // case we're interested in the start of the word, not the end\n      if (!this._model.areSelectionValuesReversed()) {\n        while (wordPosition.start + wordPosition.length > this._terminal.cols) {\n          wordPosition.length -= this._terminal.cols;\n          endRow++;\n        }\n      }\n\n      this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : wordPosition.start + wordPosition.length, endRow];\n    }\n  }\n\n  /**\n   * Gets whether the character is considered a word separator by the select\n   * word logic.\n   * @param char The character to check.\n   */\n  private _isCharWordSeparator(cell: CellData): boolean {\n    // Zero width characters are never separators as they are always to the\n    // right of wide characters\n    if (cell.getWidth() === 0) {\n      return false;\n    }\n    return WORD_SEPARATORS.indexOf(cell.getChars()) >= 0;\n  }\n\n  /**\n   * Selects the line specified.\n   * @param line The line index.\n   */\n  protected _selectLineAt(line: number): void {\n    const wrappedRange = this._buffer.getWrappedRangeForLine(line);\n    this._model.selectionStart = [0, wrappedRange.first];\n    this._model.selectionEnd = [this._terminal.cols, wrappedRange.last];\n    this._model.selectionStartLength = 0;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal, IMouseZoneManager, IMouseZone } from './Types';\nimport { Disposable } from './common/Lifecycle';\nimport { addDisposableDomListener } from './ui/Lifecycle';\n\nconst HOVER_DURATION = 500;\n\n/**\n * The MouseZoneManager allows components to register zones within the terminal\n * that trigger hover and click callbacks.\n *\n * This class was intentionally made not so robust initially as the only case it\n * needed to support was single-line links which never overlap. Improvements can\n * be made in the future.\n */\nexport class MouseZoneManager extends Disposable implements IMouseZoneManager {\n  private _zones: IMouseZone[] = [];\n\n  private _areZonesActive: boolean = false;\n  private _mouseMoveListener: (e: MouseEvent) => any;\n  private _mouseLeaveListener: (e: MouseEvent) => any;\n  private _clickListener: (e: MouseEvent) => any;\n\n  private _tooltipTimeout: number = null;\n  private _currentZone: IMouseZone = null;\n  private _lastHoverCoords: [number, number] = [null, null];\n  private _initialSelectionLength: number;\n\n  constructor(\n    private _terminal: ITerminal\n  ) {\n    super();\n\n    this.register(addDisposableDomListener(this._terminal.element, 'mousedown', e => this._onMouseDown(e)));\n\n    // These events are expensive, only listen to it when mouse zones are active\n    this._mouseMoveListener = e => this._onMouseMove(e);\n    this._mouseLeaveListener = e => this._onMouseLeave(e);\n    this._clickListener = e => this._onClick(e);\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._deactivate();\n  }\n\n  public add(zone: IMouseZone): void {\n    this._zones.push(zone);\n    if (this._zones.length === 1) {\n      this._activate();\n    }\n  }\n\n  public clearAll(start?: number, end?: number): void {\n    // Exit if there's nothing to clear\n    if (this._zones.length === 0) {\n      return;\n    }\n\n    // Clear all if start/end weren't set\n    if (!end) {\n      start = 0;\n      end = this._terminal.rows - 1;\n    }\n\n    // Iterate through zones and clear them out if they're within the range\n    for (let i = 0; i < this._zones.length; i++) {\n      const zone = this._zones[i];\n      if ((zone.y1 > start && zone.y1 <= end + 1) ||\n          (zone.y2 > start && zone.y2 <= end + 1) ||\n          (zone.y1 < start && zone.y2 > end + 1)) {\n        if (this._currentZone && this._currentZone === zone) {\n          this._currentZone.leaveCallback();\n          this._currentZone = null;\n        }\n        this._zones.splice(i--, 1);\n      }\n    }\n\n    // Deactivate the mouse zone manager if all the zones have been removed\n    if (this._zones.length === 0) {\n      this._deactivate();\n    }\n  }\n\n  private _activate(): void {\n    if (!this._areZonesActive) {\n      this._areZonesActive = true;\n      this._terminal.element.addEventListener('mousemove', this._mouseMoveListener);\n      this._terminal.element.addEventListener('mouseleave', this._mouseLeaveListener);\n      this._terminal.element.addEventListener('click', this._clickListener);\n    }\n  }\n\n  private _deactivate(): void {\n    if (this._areZonesActive) {\n      this._areZonesActive = false;\n      this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);\n      this._terminal.element.removeEventListener('mouseleave', this._mouseLeaveListener);\n      this._terminal.element.removeEventListener('click', this._clickListener);\n    }\n  }\n\n  private _onMouseMove(e: MouseEvent): void {\n    // TODO: Ideally this would only clear the hover state when the mouse moves\n    // outside of the mouse zone\n    if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {\n      this._onHover(e);\n      // Record the current coordinates\n      this._lastHoverCoords = [e.pageX, e.pageY];\n    }\n  }\n\n  private _onHover(e: MouseEvent): void {\n    const zone = this._findZoneEventAt(e);\n\n    // Do nothing if the zone is the same\n    if (zone === this._currentZone) {\n      return;\n    }\n\n    // Fire the hover end callback and cancel any existing timer if a new zone\n    // is being hovered\n    if (this._currentZone) {\n      this._currentZone.leaveCallback();\n      this._currentZone = null;\n      if (this._tooltipTimeout) {\n        clearTimeout(this._tooltipTimeout);\n      }\n    }\n\n    // Exit if there is not zone\n    if (!zone) {\n      return;\n    }\n    this._currentZone = zone;\n\n    // Trigger the hover callback\n    if (zone.hoverCallback) {\n      zone.hoverCallback(e);\n    }\n\n    // Restart the tooltip timeout\n    this._tooltipTimeout = <number><any>setTimeout(() => this._onTooltip(e), HOVER_DURATION);\n  }\n\n  private _onTooltip(e: MouseEvent): void {\n    this._tooltipTimeout = null;\n    const zone = this._findZoneEventAt(e);\n    if (zone && zone.tooltipCallback) {\n      zone.tooltipCallback(e);\n    }\n  }\n\n  private _onMouseDown(e: MouseEvent): void {\n    // Store current terminal selection length, to check if we're performing\n    // a selection operation\n    this._initialSelectionLength = this._terminal.getSelection().length;\n\n    // Ignore the event if there are no zones active\n    if (!this._areZonesActive) {\n      return;\n    }\n\n    // Find the active zone, prevent event propagation if found to prevent other\n    // components from handling the mouse event.\n    const zone = this._findZoneEventAt(e);\n    if (zone) {\n      if (zone.willLinkActivate(e)) {\n        e.preventDefault();\n        e.stopImmediatePropagation();\n      }\n    }\n  }\n\n  private _onMouseLeave(e: MouseEvent): void {\n    // Fire the hover end callback and cancel any existing timer if the mouse\n    // leaves the terminal element\n    if (this._currentZone) {\n      this._currentZone.leaveCallback();\n      this._currentZone = null;\n      if (this._tooltipTimeout) {\n        clearTimeout(this._tooltipTimeout);\n      }\n    }\n  }\n\n  private _onClick(e: MouseEvent): void {\n    // Find the active zone and click it if found and no selection was\n    // being performed\n    const zone = this._findZoneEventAt(e);\n    const currentSelectionLength = this._terminal.getSelection().length;\n\n    if (zone && currentSelectionLength === this._initialSelectionLength) {\n      zone.clickCallback(e);\n      e.preventDefault();\n      e.stopImmediatePropagation();\n    }\n  }\n\n  private _findZoneEventAt(e: MouseEvent): IMouseZone {\n    const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.screenElement, this._terminal.charMeasure, this._terminal.cols, this._terminal.rows);\n    if (!coords) {\n      return null;\n    }\n    const x = coords[0];\n    const y = coords[1];\n    for (let i = 0; i < this._zones.length; i++) {\n      const zone = this._zones[i];\n      if (zone.y1 === zone.y2) {\n        // Single line link\n        if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {\n          return zone;\n        }\n      } else {\n        // Multi-line link\n        if ((y === zone.y1 && x >= zone.x1) ||\n            (y === zone.y2 && x < zone.x2) ||\n            (y > zone.y1 && y < zone.y2)) {\n          return zone;\n        }\n      }\n    }\n    return null;\n  }\n}\n\nexport class MouseZone implements IMouseZone {\n  constructor(\n    public x1: number,\n    public y1: number,\n    public x2: number,\n    public y2: number,\n    public clickCallback: (e: MouseEvent) => any,\n    public hoverCallback: (e: MouseEvent) => any,\n    public tooltipCallback: (e: MouseEvent) => any,\n    public leaveCallback: () => void,\n    public willLinkActivate: (e: MouseEvent) => boolean\n  ) {\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharMeasure, IMouseHelper } from './Types';\nimport { IRenderer } from './renderer/Types';\n\nexport class MouseHelper implements IMouseHelper {\n  constructor(private _renderer: IRenderer) {}\n\n  public setRenderer(renderer: IRenderer): void {\n    this._renderer = renderer;\n  }\n\n  public static getCoordsRelativeToElement(event: {clientX: number, clientY: number}, element: HTMLElement): [number, number] {\n    const rect = element.getBoundingClientRect();\n    return [event.clientX - rect.left, event.clientY - rect.top];\n  }\n\n  /**\n   * Gets coordinates within the terminal for a particular mouse event. The result\n   * is returned as an array in the form [x, y] instead of an object as it's a\n   * little faster and this function is used in some low level code.\n   * @param event The mouse event.\n   * @param element The terminal's container element.\n   * @param charMeasure The char measure object used to determine character sizes.\n   * @param colCount The number of columns in the terminal.\n   * @param rowCount The number of rows n the terminal.\n   * @param isSelection Whether the request is for the selection or not. This will\n   * apply an offset to the x value such that the left half of the cell will\n   * select that cell and the right half will select the next cell.\n   */\n  public getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number, isSelection?: boolean): [number, number] {\n    // Coordinates cannot be measured if charMeasure has not been initialized\n    if (!charMeasure.width || !charMeasure.height) {\n      return null;\n    }\n\n    const coords = MouseHelper.getCoordsRelativeToElement(event, element);\n    if (!coords) {\n      return null;\n    }\n\n    coords[0] = Math.ceil((coords[0] + (isSelection ? this._renderer.dimensions.actualCellWidth / 2 : 0)) / this._renderer.dimensions.actualCellWidth);\n    coords[1] = Math.ceil(coords[1] / this._renderer.dimensions.actualCellHeight);\n\n    // Ensure coordinates are within the terminal viewport. Note that selections\n    // need an addition point of precision to cover the end point (as characters\n    // cover half of one char and half of the next).\n    coords[0] = Math.min(Math.max(coords[0], 1), colCount + (isSelection ? 1 : 0));\n    coords[1] = Math.min(Math.max(coords[1], 1), rowCount);\n\n    return coords;\n  }\n\n  /**\n   * Gets coordinates within the terminal for a particular mouse event, wrapping\n   * them to the bounds of the terminal and adding 32 to both the x and y values\n   * as expected by xterm.\n   * @param event The mouse event.\n   * @param element The terminal's container element.\n   * @param charMeasure The char measure object used to determine character sizes.\n   * @param colCount The number of columns in the terminal.\n   * @param rowCount The number of rows in the terminal.\n   */\n  public getRawByteCoords(event: MouseEvent, element: HTMLElement, charMeasure: ICharMeasure, colCount: number, rowCount: number): { x: number, y: number } {\n    const coords = this.getCoords(event, element, charMeasure, colCount, rowCount);\n    let x = coords[0];\n    let y = coords[1];\n\n    // xterm sends raw bytes and starts at 32 (SP) for each.\n    x += 32;\n    y += 32;\n\n    return { x, y };\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, ITerminal, IBufferStringIteratorResult, IMouseZoneManager } from './Types';\nimport { MouseZone } from './MouseZoneManager';\nimport { getStringCellWidth } from './CharWidth';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\n\n/**\n * The Linkifier applies links to rows shortly after they have been refreshed.\n */\nexport class Linkifier implements ILinkifier {\n  /**\n   * The time to wait after a row is changed before it is linkified. This prevents\n   * the costly operation of searching every row multiple times, potentially a\n   * huge amount of times.\n   */\n  protected static readonly TIME_BEFORE_LINKIFY = 200;\n\n  /**\n   * Limit of the unwrapping line expansion (overscan) at the top and bottom\n   * of the actual viewport in ASCII characters.\n   * A limit of 2000 should match most sane urls.\n   */\n  protected static readonly OVERSCAN_CHAR_LIMIT = 2000;\n\n  protected _linkMatchers: ILinkMatcher[] = [];\n\n  private _mouseZoneManager: IMouseZoneManager;\n  private _rowsTimeoutId: number;\n  private _nextLinkMatcherId = 0;\n  private _rowsToLinkify: { start: number, end: number };\n\n  private _onLinkHover = new EventEmitter2<ILinkifierEvent>();\n  public get onLinkHover(): IEvent<ILinkifierEvent> { return this._onLinkHover.event; }\n  private _onLinkLeave = new EventEmitter2<ILinkifierEvent>();\n  public get onLinkLeave(): IEvent<ILinkifierEvent> { return this._onLinkLeave.event; }\n  private _onLinkTooltip = new EventEmitter2<ILinkifierEvent>();\n  public get onLinkTooltip(): IEvent<ILinkifierEvent> { return this._onLinkTooltip.event; }\n\n  constructor(\n    protected _terminal: ITerminal\n  ) {\n    this._rowsToLinkify = {\n      start: null,\n      end: null\n    };\n  }\n\n  /**\n   * Attaches the linkifier to the DOM, enabling linkification.\n   * @param mouseZoneManager The mouse zone manager to register link zones with.\n   */\n  public attachToDom(mouseZoneManager: IMouseZoneManager): void {\n    this._mouseZoneManager = mouseZoneManager;\n  }\n\n  /**\n   * Queue linkification on a set of rows.\n   * @param start The row to linkify from (inclusive).\n   * @param end The row to linkify to (inclusive).\n   */\n  public linkifyRows(start: number, end: number): void {\n    // Don't attempt linkify if not yet attached to DOM\n    if (!this._mouseZoneManager) {\n      return;\n    }\n\n    // Increase range to linkify\n    if (this._rowsToLinkify.start === null) {\n      this._rowsToLinkify.start = start;\n      this._rowsToLinkify.end = end;\n    } else {\n      this._rowsToLinkify.start = Math.min(this._rowsToLinkify.start, start);\n      this._rowsToLinkify.end = Math.max(this._rowsToLinkify.end, end);\n    }\n\n    // Clear out any existing links on this row range\n    this._mouseZoneManager.clearAll(start, end);\n\n    // Restart timer\n    if (this._rowsTimeoutId) {\n      clearTimeout(this._rowsTimeoutId);\n    }\n    this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier.TIME_BEFORE_LINKIFY);\n  }\n\n  /**\n   * Linkifies the rows requested.\n   */\n  private _linkifyRows(): void {\n    this._rowsTimeoutId = null;\n    const buffer = this._terminal.buffer;\n\n    // Ensure the start row exists\n    const absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;\n    if (absoluteRowIndexStart >= buffer.lines.length) {\n      return;\n    }\n\n    // Invalidate bad end row values (if a resize happened)\n    const absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._terminal.rows) + 1;\n\n    // Iterate over the range of unwrapped content strings within start..end\n    // (excluding).\n    // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset\n    // for every matcher.\n    // The unwrapping is needed to also match content that got wrapped across\n    // several buffer lines. To avoid a worst case scenario where the whole buffer\n    // contains just a single unwrapped string we limit this line expansion beyond\n    // the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom.\n    // This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT\n    // chars will not match anymore at the viewport borders.\n    const overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols);\n    const iterator = this._terminal.buffer.iterator(\n      false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);\n    while (iterator.hasNext()) {\n      const lineData: IBufferStringIteratorResult = iterator.next();\n      for (let i = 0; i < this._linkMatchers.length; i++) {\n        this._doLinkifyRow(lineData.range.first, lineData.content, this._linkMatchers[i]);\n      }\n    }\n\n    this._rowsToLinkify.start = null;\n    this._rowsToLinkify.end = null;\n  }\n\n  /**\n   * Registers a link matcher, allowing custom link patterns to be matched and\n   * handled.\n   * @param regex The regular expression to search for. Specifically, this\n   * searches the textContent of the rows. You will want to use \\s to match a\n   * space ' ' character for example.\n   * @param handler The callback when the link is called.\n   * @param options Options for the link matcher.\n   * @return The ID of the new matcher, this can be used to deregister.\n   */\n  public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options: ILinkMatcherOptions = {}): number {\n    if (!handler) {\n      throw new Error('handler must be defined');\n    }\n    const matcher: ILinkMatcher = {\n      id: this._nextLinkMatcherId++,\n      regex,\n      handler,\n      matchIndex: options.matchIndex,\n      validationCallback: options.validationCallback,\n      hoverTooltipCallback: options.tooltipCallback,\n      hoverLeaveCallback: options.leaveCallback,\n      willLinkActivate: options.willLinkActivate,\n      priority: options.priority || 0\n    };\n    this._addLinkMatcherToList(matcher);\n    return matcher.id;\n  }\n\n  /**\n   * Inserts a link matcher to the list in the correct position based on the\n   * priority of each link matcher. New link matchers of equal priority are\n   * considered after older link matchers.\n   * @param matcher The link matcher to be added.\n   */\n  private _addLinkMatcherToList(matcher: ILinkMatcher): void {\n    if (this._linkMatchers.length === 0) {\n      this._linkMatchers.push(matcher);\n      return;\n    }\n\n    for (let i = this._linkMatchers.length - 1; i >= 0; i--) {\n      if (matcher.priority <= this._linkMatchers[i].priority) {\n        this._linkMatchers.splice(i + 1, 0, matcher);\n        return;\n      }\n    }\n\n    this._linkMatchers.splice(0, 0, matcher);\n  }\n\n  /**\n   * Deregisters a link matcher if it has been registered.\n   * @param matcherId The link matcher's ID (returned after register)\n   * @return Whether a link matcher was found and deregistered.\n   */\n  public deregisterLinkMatcher(matcherId: number): boolean {\n    for (let i = 0; i < this._linkMatchers.length; i++) {\n      if (this._linkMatchers[i].id === matcherId) {\n        this._linkMatchers.splice(i, 1);\n        return true;\n      }\n    }\n    return false;\n  }\n\n  /**\n   * Linkifies a row given a specific handler.\n   * @param rowIndex The row index to linkify (absolute index).\n   * @param text string content of the unwrapped row.\n   * @param matcher The link matcher for this line.\n   */\n  private _doLinkifyRow(rowIndex: number, text: string, matcher: ILinkMatcher): void {\n    // clone regex to do a global search on text\n    const rex = new RegExp(matcher.regex.source, matcher.regex.flags + 'g');\n    let match;\n    let stringIndex = -1;\n    while ((match = rex.exec(text)) !== null) {\n      const uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];\n      if (!uri) {\n        // something matched but does not comply with the given matchIndex\n        // since this is most likely a bug the regex itself we simply do nothing here\n        // DEBUG: print match and throw\n        if ((<any>this._terminal).debug) {\n          console.log({match, matcher});\n          throw new Error('match found without corresponding matchIndex');\n        }\n        break;\n      }\n\n      // Get index, match.index is for the outer match which includes negated chars\n      // therefore we cannot use match.index directly, instead we search the position\n      // of the match group in text again\n      // also correct regex and string search offsets for the next loop run\n      stringIndex = text.indexOf(uri, stringIndex + 1);\n      rex.lastIndex = stringIndex + uri.length;\n      if (stringIndex < 0) {\n        // invalid stringIndex (should not have happened)\n        break;\n      }\n\n      // get the buffer index as [absolute row, col] for the match\n      const bufferIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex);\n      if (bufferIndex[0] < 0) {\n        // invalid bufferIndex (should not have happened)\n        break;\n      }\n\n      const line = this._terminal.buffer.lines.get(bufferIndex[0]);\n      const attr = line.getFg(bufferIndex[1]);\n      let fg: number | undefined;\n      if (attr) {\n        fg = (attr >> 9) & 0x1ff;\n      }\n\n      if (matcher.validationCallback) {\n        matcher.validationCallback(uri, isValid => {\n          // Discard link if the line has already changed\n          if (this._rowsTimeoutId) {\n            return;\n          }\n          if (isValid) {\n            this._addLink(bufferIndex[1], bufferIndex[0] - this._terminal.buffer.ydisp, uri, matcher, fg);\n          }\n        });\n      } else {\n        this._addLink(bufferIndex[1], bufferIndex[0] - this._terminal.buffer.ydisp, uri, matcher, fg);\n      }\n    }\n  }\n\n  /**\n   * Registers a link to the mouse zone manager.\n   * @param x The column the link starts.\n   * @param y The row the link is on.\n   * @param uri The URI of the link.\n   * @param matcher The link matcher for the link.\n   * @param fg The link color for hover event.\n   */\n  private _addLink(x: number, y: number, uri: string, matcher: ILinkMatcher, fg: number): void {\n    const width = getStringCellWidth(uri);\n    const x1 = x % this._terminal.cols;\n    const y1 = y + Math.floor(x / this._terminal.cols);\n    let x2 = (x1 + width) % this._terminal.cols;\n    let y2 = y1 + Math.floor((x1 + width) / this._terminal.cols);\n    if (x2 === 0) {\n      x2 = this._terminal.cols;\n      y2--;\n    }\n\n    this._mouseZoneManager.add(new MouseZone(\n      x1 + 1,\n      y1 + 1,\n      x2 + 1,\n      y2 + 1,\n      e => {\n        if (matcher.handler) {\n          return matcher.handler(e, uri);\n        }\n        window.open(uri, '_blank');\n      },\n      () => {\n        this._onLinkHover.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));\n        this._terminal.element.classList.add('xterm-cursor-pointer');\n      },\n      e => {\n        this._onLinkTooltip.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));\n        if (matcher.hoverTooltipCallback) {\n          matcher.hoverTooltipCallback(e, uri);\n        }\n      },\n      () => {\n        this._onLinkLeave.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));\n        this._terminal.element.classList.remove('xterm-cursor-pointer');\n        if (matcher.hoverLeaveCallback) {\n          matcher.hoverLeaveCallback();\n        }\n      },\n      e => {\n        if (matcher.willLinkActivate) {\n          return matcher.willLinkActivate(e, uri);\n        }\n        return true;\n      }\n    ));\n  }\n\n  private _createLinkHoverEvent(x1: number, y1: number, x2: number, y2: number, fg: number): ILinkifierEvent {\n    return { x1, y1, x2, y2, cols: this._terminal.cols, fg };\n  }\n}\n","/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n */\n\nimport { IInputHandler, IDcsHandler, IEscapeSequenceParser, IInputHandlingTerminal } from './Types';\nimport { C0, C1 } from './common/data/EscapeSequences';\nimport { CHARSETS, DEFAULT_CHARSET } from './core/data/Charsets';\nimport { NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR_DATA } from './Buffer';\nimport { wcwidth } from './CharWidth';\nimport { EscapeSequenceParser } from './EscapeSequenceParser';\nimport { IDisposable } from 'xterm';\nimport { Disposable } from './common/Lifecycle';\nimport { concat } from './common/TypedArrayUtils';\nimport { StringToUtf32, stringFromCodePoint, utf32ToString } from './core/input/TextDecoder';\nimport { CellData, Attributes, FgFlags, BgFlags, AttributeData } from './BufferLine';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\n\n/**\n * Map collect to glevel. Used in `selectCharset`.\n */\nconst GLEVEL: {[key: string]: number} = {'(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2};\n\n\n/**\n * DCS subparser implementations\n */\n\n/**\n * DCS $ q Pt ST\n *   DECRQSS (https://vt100.net/docs/vt510-rm/DECRQSS.html)\n *   Request Status String (DECRQSS), VT420 and up.\n *   Response: DECRPSS (https://vt100.net/docs/vt510-rm/DECRPSS.html)\n */\nclass DECRQSS implements IDcsHandler {\n  private _data: Uint32Array = new Uint32Array(0);\n\n  constructor(private _terminal: any) { }\n\n  hook(collect: string, params: number[], flag: number): void {\n    this._data = new Uint32Array(0);\n  }\n\n  put(data: Uint32Array, start: number, end: number): void {\n    this._data = concat(this._data, data.subarray(start, end));\n  }\n\n  unhook(): void {\n    const data = utf32ToString(this._data);\n    this._data = new Uint32Array(0);\n    switch (data) {\n      // valid: DCS 1 $ r Pt ST (xterm)\n      case '\"q': // DECSCA\n        return this._terminal.handler(`${C0.ESC}P1$r0\"q${C0.ESC}\\\\`);\n      case '\"p': // DECSCL\n        return this._terminal.handler(`${C0.ESC}P1$r61\"p${C0.ESC}\\\\`);\n      case 'r': // DECSTBM\n        const pt = '' + (this._terminal.buffer.scrollTop + 1) +\n                ';' + (this._terminal.buffer.scrollBottom + 1) + 'r';\n        return this._terminal.handler(`${C0.ESC}P1$r${pt}${C0.ESC}\\\\`);\n      case 'm': // SGR\n        // TODO: report real settings instead of 0m\n        return this._terminal.handler(`${C0.ESC}P1$r0m${C0.ESC}\\\\`);\n      case ' q': // DECSCUSR\n        const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6};\n        let style = STYLES[this._terminal.getOption('cursorStyle')];\n        style -= this._terminal.getOption('cursorBlink');\n        return this._terminal.handler(`${C0.ESC}P1$r${style} q${C0.ESC}\\\\`);\n      default:\n        // invalid: DCS 0 $ r Pt ST (xterm)\n        this._terminal.error('Unknown DCS $q %s', data);\n        this._terminal.handler(`${C0.ESC}P0$r${C0.ESC}\\\\`);\n    }\n  }\n}\n\n/**\n * DCS Ps; Ps| Pt ST\n *   DECUDK (https://vt100.net/docs/vt510-rm/DECUDK.html)\n *   not supported\n */\n\n/**\n * DCS + q Pt ST (xterm)\n *   Request Terminfo String\n *   not implemented\n */\n\n/**\n * DCS + p Pt ST (xterm)\n *   Set Terminfo Data\n *   not supported\n */\n\n\n\n/**\n * The terminal's standard implementation of IInputHandler, this handles all\n * input from the Parser.\n *\n * Refer to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html to understand\n * each function's header comment.\n */\nexport class InputHandler extends Disposable implements IInputHandler {\n  private _parseBuffer: Uint32Array = new Uint32Array(4096);\n  private _stringDecoder: StringToUtf32 = new StringToUtf32();\n  private _workCell: CellData = new CellData();\n\n  private _onCursorMove = new EventEmitter2<void>();\n  public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }\n  private _onData = new EventEmitter2<string>();\n  public get onData(): IEvent<string> { return this._onData.event; }\n  private _onLineFeed = new EventEmitter2<void>();\n  public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }\n  private _onScroll = new EventEmitter2<number>();\n  public get onScroll(): IEvent<number> { return this._onScroll.event; }\n\n  constructor(\n      protected _terminal: IInputHandlingTerminal,\n      private _parser: IEscapeSequenceParser = new EscapeSequenceParser())\n  {\n    super();\n\n    this.register(this._parser);\n\n    /**\n     * custom fallback handlers\n     */\n    this._parser.setCsiHandlerFallback((collect: string, params: number[], flag: number) => {\n      this._terminal.error('Unknown CSI code: ', { collect, params, flag: String.fromCharCode(flag) });\n    });\n    this._parser.setEscHandlerFallback((collect: string, flag: number) => {\n      this._terminal.error('Unknown ESC code: ', { collect, flag: String.fromCharCode(flag) });\n    });\n    this._parser.setExecuteHandlerFallback((code: number) => {\n      this._terminal.error('Unknown EXECUTE code: ', { code });\n    });\n    this._parser.setOscHandlerFallback((identifier: number, data: string) => {\n      this._terminal.error('Unknown OSC code: ', { identifier, data });\n    });\n\n    /**\n     * print handler\n     */\n    this._parser.setPrintHandler((data, start, end): void => this.print(data, start, end));\n\n    /**\n     * CSI handler\n     */\n    this._parser.setCsiHandler('@', (params, collect) => this.insertChars(params));\n    this._parser.setCsiHandler('A', (params, collect) => this.cursorUp(params));\n    this._parser.setCsiHandler('B', (params, collect) => this.cursorDown(params));\n    this._parser.setCsiHandler('C', (params, collect) => this.cursorForward(params));\n    this._parser.setCsiHandler('D', (params, collect) => this.cursorBackward(params));\n    this._parser.setCsiHandler('E', (params, collect) => this.cursorNextLine(params));\n    this._parser.setCsiHandler('F', (params, collect) => this.cursorPrecedingLine(params));\n    this._parser.setCsiHandler('G', (params, collect) => this.cursorCharAbsolute(params));\n    this._parser.setCsiHandler('H', (params, collect) => this.cursorPosition(params));\n    this._parser.setCsiHandler('I', (params, collect) => this.cursorForwardTab(params));\n    this._parser.setCsiHandler('J', (params, collect) => this.eraseInDisplay(params));\n    this._parser.setCsiHandler('K', (params, collect) => this.eraseInLine(params));\n    this._parser.setCsiHandler('L', (params, collect) => this.insertLines(params));\n    this._parser.setCsiHandler('M', (params, collect) => this.deleteLines(params));\n    this._parser.setCsiHandler('P', (params, collect) => this.deleteChars(params));\n    this._parser.setCsiHandler('S', (params, collect) => this.scrollUp(params));\n    this._parser.setCsiHandler('T', (params, collect) => this.scrollDown(params, collect));\n    this._parser.setCsiHandler('X', (params, collect) => this.eraseChars(params));\n    this._parser.setCsiHandler('Z', (params, collect) => this.cursorBackwardTab(params));\n    this._parser.setCsiHandler('`', (params, collect) => this.charPosAbsolute(params));\n    this._parser.setCsiHandler('a', (params, collect) => this.hPositionRelative(params));\n    this._parser.setCsiHandler('b', (params, collect) => this.repeatPrecedingCharacter(params));\n    this._parser.setCsiHandler('c', (params, collect) => this.sendDeviceAttributes(params, collect));\n    this._parser.setCsiHandler('d', (params, collect) => this.linePosAbsolute(params));\n    this._parser.setCsiHandler('e', (params, collect) => this.vPositionRelative(params));\n    this._parser.setCsiHandler('f', (params, collect) => this.hVPosition(params));\n    this._parser.setCsiHandler('g', (params, collect) => this.tabClear(params));\n    this._parser.setCsiHandler('h', (params, collect) => this.setMode(params, collect));\n    this._parser.setCsiHandler('l', (params, collect) => this.resetMode(params, collect));\n    this._parser.setCsiHandler('m', (params, collect) => this.charAttributes(params));\n    this._parser.setCsiHandler('n', (params, collect) => this.deviceStatus(params, collect));\n    this._parser.setCsiHandler('p', (params, collect) => this.softReset(params, collect));\n    this._parser.setCsiHandler('q', (params, collect) => this.setCursorStyle(params, collect));\n    this._parser.setCsiHandler('r', (params, collect) => this.setScrollRegion(params, collect));\n    this._parser.setCsiHandler('s', (params, collect) => this.saveCursor(params));\n    this._parser.setCsiHandler('u', (params, collect) => this.restoreCursor(params));\n\n    /**\n     * execute handler\n     */\n    this._parser.setExecuteHandler(C0.BEL, () => this.bell());\n    this._parser.setExecuteHandler(C0.LF, () => this.lineFeed());\n    this._parser.setExecuteHandler(C0.VT, () => this.lineFeed());\n    this._parser.setExecuteHandler(C0.FF, () => this.lineFeed());\n    this._parser.setExecuteHandler(C0.CR, () => this.carriageReturn());\n    this._parser.setExecuteHandler(C0.BS, () => this.backspace());\n    this._parser.setExecuteHandler(C0.HT, () => this.tab());\n    this._parser.setExecuteHandler(C0.SO, () => this.shiftOut());\n    this._parser.setExecuteHandler(C0.SI, () => this.shiftIn());\n    // FIXME:   What do to with missing? Old code just added those to print.\n\n    // some C1 control codes - FIXME: should those be enabled by default?\n    this._parser.setExecuteHandler(C1.IND, () => this.index());\n    this._parser.setExecuteHandler(C1.NEL, () => this.nextLine());\n    this._parser.setExecuteHandler(C1.HTS, () => this.tabSet());\n\n    /**\n     * OSC handler\n     */\n    //   0 - icon name + title\n    this._parser.setOscHandler(0, (data) => this.setTitle(data));\n    //   1 - icon name\n    //   2 - title\n    this._parser.setOscHandler(2, (data) => this.setTitle(data));\n    //   3 - set property X in the form \"prop=value\"\n    //   4 - Change Color Number\n    //   5 - Change Special Color Number\n    //   6 - Enable/disable Special Color Number c\n    //   7 - current directory? (not in xterm spec, see https://gitlab.com/gnachman/iterm2/issues/3939)\n    //  10 - Change VT100 text foreground color to Pt.\n    //  11 - Change VT100 text background color to Pt.\n    //  12 - Change text cursor color to Pt.\n    //  13 - Change mouse foreground color to Pt.\n    //  14 - Change mouse background color to Pt.\n    //  15 - Change Tektronix foreground color to Pt.\n    //  16 - Change Tektronix background color to Pt.\n    //  17 - Change highlight background color to Pt.\n    //  18 - Change Tektronix cursor color to Pt.\n    //  19 - Change highlight foreground color to Pt.\n    //  46 - Change Log File to Pt.\n    //  50 - Set Font to Pt.\n    //  51 - reserved for Emacs shell.\n    //  52 - Manipulate Selection Data.\n    // 104 ; c - Reset Color Number c.\n    // 105 ; c - Reset Special Color Number c.\n    // 106 ; c; f - Enable/disable Special Color Number c.\n    // 110 - Reset VT100 text foreground color.\n    // 111 - Reset VT100 text background color.\n    // 112 - Reset text cursor color.\n    // 113 - Reset mouse foreground color.\n    // 114 - Reset mouse background color.\n    // 115 - Reset Tektronix foreground color.\n    // 116 - Reset Tektronix background color.\n    // 117 - Reset highlight color.\n    // 118 - Reset Tektronix cursor color.\n    // 119 - Reset highlight foreground color.\n\n    /**\n     * ESC handlers\n     */\n    this._parser.setEscHandler('7', () => this.saveCursor([]));\n    this._parser.setEscHandler('8', () => this.restoreCursor([]));\n    this._parser.setEscHandler('D', () => this.index());\n    this._parser.setEscHandler('E', () => this.nextLine());\n    this._parser.setEscHandler('H', () => this.tabSet());\n    this._parser.setEscHandler('M', () => this.reverseIndex());\n    this._parser.setEscHandler('=', () => this.keypadApplicationMode());\n    this._parser.setEscHandler('>', () => this.keypadNumericMode());\n    this._parser.setEscHandler('c', () => this.reset());\n    this._parser.setEscHandler('n', () => this.setgLevel(2));\n    this._parser.setEscHandler('o', () => this.setgLevel(3));\n    this._parser.setEscHandler('|', () => this.setgLevel(3));\n    this._parser.setEscHandler('}', () => this.setgLevel(2));\n    this._parser.setEscHandler('~', () => this.setgLevel(1));\n    this._parser.setEscHandler('%@', () => this.selectDefaultCharset());\n    this._parser.setEscHandler('%G', () => this.selectDefaultCharset());\n    for (const flag in CHARSETS) {\n      this._parser.setEscHandler('(' + flag, () => this.selectCharset('(' + flag));\n      this._parser.setEscHandler(')' + flag, () => this.selectCharset(')' + flag));\n      this._parser.setEscHandler('*' + flag, () => this.selectCharset('*' + flag));\n      this._parser.setEscHandler('+' + flag, () => this.selectCharset('+' + flag));\n      this._parser.setEscHandler('-' + flag, () => this.selectCharset('-' + flag));\n      this._parser.setEscHandler('.' + flag, () => this.selectCharset('.' + flag));\n      this._parser.setEscHandler('/' + flag, () => this.selectCharset('/' + flag)); // TODO: supported?\n    }\n\n    /**\n     * error handler\n     */\n    this._parser.setErrorHandler((state) => {\n      this._terminal.error('Parsing error: ', state);\n      return state;\n    });\n\n    /**\n     * DCS handler\n     */\n    this._parser.setDcsHandler('$q', new DECRQSS(this._terminal));\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._terminal = null;\n  }\n\n  public parse(data: string): void {\n    // Ensure the terminal is not disposed\n    if (!this._terminal) {\n      return;\n    }\n\n    let buffer = this._terminal.buffer;\n    const cursorStartX = buffer.x;\n    const cursorStartY = buffer.y;\n\n    // TODO: Consolidate debug/logging #1560\n    if ((<any>this._terminal).debug) {\n      this._terminal.log('data: ' + data);\n    }\n\n    if (this._parseBuffer.length < data.length) {\n      this._parseBuffer = new Uint32Array(data.length);\n    }\n    this._parser.parse(this._parseBuffer, this._stringDecoder.decode(data, this._parseBuffer));\n\n    buffer = this._terminal.buffer;\n    if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) {\n      this._onCursorMove.fire();\n    }\n  }\n\n  public print(data: Uint32Array, start: number, end: number): void {\n    let code: number;\n    let chWidth: number;\n    const buffer = this._terminal.buffer;\n    const charset = this._terminal.charset;\n    const screenReaderMode = this._terminal.options.screenReaderMode;\n    const cols = this._terminal.cols;\n    const wraparoundMode = this._terminal.wraparoundMode;\n    const insertMode = this._terminal.insertMode;\n    const curAttr = this._terminal.curAttrData;\n    let bufferRow = buffer.lines.get(buffer.y + buffer.ybase);\n\n    this._terminal.updateRange(buffer.y);\n    for (let pos = start; pos < end; ++pos) {\n      code = data[pos];\n\n      // calculate print space\n      // expensive call, therefore we save width in line buffer\n      chWidth = wcwidth(code);\n\n      // get charset replacement character\n      // charset is only defined for ASCII, therefore we only\n      // search for an replacement char if code < 127\n      if (code < 127 && charset) {\n        const ch = charset[String.fromCharCode(code)];\n        if (ch) {\n          code = ch.charCodeAt(0);\n        }\n      }\n\n      if (screenReaderMode) {\n        this._terminal.emit('a11y.char', stringFromCodePoint(code));\n      }\n\n      // insert combining char at last cursor position\n      // FIXME: needs handling after cursor jumps\n      // buffer.x should never be 0 for a combining char\n      // since they always follow a cell consuming char\n      // therefore we can test for buffer.x to avoid overflow left\n      if (!chWidth && buffer.x) {\n        if (!bufferRow.getWidth(buffer.x - 1)) {\n          // found empty cell after fullwidth, need to go 2 cells back\n          // it is save to step 2 cells back here\n          // since an empty cell is only set by fullwidth chars\n          bufferRow.addCodepointToCell(buffer.x - 2, code);\n        } else {\n          bufferRow.addCodepointToCell(buffer.x - 1, code);\n        }\n        continue;\n      }\n\n      // goto next line if ch would overflow\n      // TODO: needs a global min terminal width of 2\n      // FIXME: additionally ensure chWidth fits into a line\n      //   -->  maybe forbid cols<xy at higher level as it would\n      //        introduce a bad runtime penalty here\n      if (buffer.x + chWidth - 1 >= cols) {\n        // autowrap - DECAWM\n        // automatically wraps to the beginning of the next line\n        if (wraparoundMode) {\n          buffer.x = 0;\n          buffer.y++;\n          if (buffer.y > buffer.scrollBottom) {\n            buffer.y--;\n            this._terminal.scroll(true);\n          } else {\n            // The line already exists (eg. the initial viewport), mark it as a\n            // wrapped line\n            buffer.lines.get(buffer.y).isWrapped = true;\n          }\n          // row changed, get it again\n          bufferRow = buffer.lines.get(buffer.y + buffer.ybase);\n        } else {\n          if (chWidth === 2) {\n            // FIXME: check for xterm behavior\n            // What to do here? We got a wide char that does not fit into last cell\n            continue;\n          }\n          // FIXME: Do we have to set buffer.x to cols - 1, if not wrapping?\n        }\n      }\n\n      // insert mode: move characters to right\n      if (insertMode) {\n        // right shift cells according to the width\n        bufferRow.insertCells(buffer.x, chWidth, buffer.getNullCell(curAttr));\n        // test last cell - since the last cell has only room for\n        // a halfwidth char any fullwidth shifted there is lost\n        // and will be set to empty cell\n        if (bufferRow.getWidth(cols - 1) === 2) {\n          bufferRow.setCellFromCodePoint(cols - 1, NULL_CELL_CODE, NULL_CELL_WIDTH, curAttr.fg, curAttr.bg);\n        }\n      }\n\n      // write current char to buffer and advance cursor\n      bufferRow.setCellFromCodePoint(buffer.x++, code, chWidth, curAttr.fg, curAttr.bg);\n\n      // fullwidth char - also set next cell to placeholder stub and advance cursor\n      // for graphemes bigger than fullwidth we can simply loop to zero\n      // we already made sure above, that buffer.x + chWidth will not overflow right\n      if (chWidth > 0) {\n        while (--chWidth) {\n          // other than a regular empty cell a cell following a wide char has no width\n          bufferRow.setCellFromCodePoint(buffer.x++, 0, 0, curAttr.fg, curAttr.bg);\n        }\n      }\n    }\n    this._terminal.updateRange(buffer.y);\n  }\n\n  /**\n   * Forward addCsiHandler from parser.\n   */\n  public addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable {\n    return this._parser.addCsiHandler(flag, callback);\n  }\n\n  /**\n   * Forward addOscHandler from parser.\n   */\n  public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    return this._parser.addOscHandler(ident, callback);\n  }\n\n  /**\n   * BEL\n   * Bell (Ctrl-G).\n   */\n  public bell(): void {\n    this._terminal.bell();\n  }\n\n  /**\n   * LF\n   * Line Feed or New Line (NL).  (LF  is Ctrl-J).\n   */\n  public lineFeed(): void {\n    // make buffer local for faster access\n    const buffer = this._terminal.buffer;\n\n    if (this._terminal.options.convertEol) {\n      buffer.x = 0;\n    }\n    buffer.y++;\n    if (buffer.y > buffer.scrollBottom) {\n      buffer.y--;\n      this._terminal.scroll();\n    }\n    // If the end of the line is hit, prevent this action from wrapping around to the next line.\n    if (buffer.x >= this._terminal.cols) {\n      buffer.x--;\n    }\n\n    this._onLineFeed.fire();\n  }\n\n  /**\n   * CR\n   * Carriage Return (Ctrl-M).\n   */\n  public carriageReturn(): void {\n    this._terminal.buffer.x = 0;\n  }\n\n  /**\n   * BS\n   * Backspace (Ctrl-H).\n   */\n  public backspace(): void {\n    if (this._terminal.buffer.x > 0) {\n      this._terminal.buffer.x--;\n    }\n  }\n\n  /**\n   * TAB\n   * Horizontal Tab (HT) (Ctrl-I).\n   */\n  public tab(): void {\n    const originalX = this._terminal.buffer.x;\n    this._terminal.buffer.x = this._terminal.buffer.nextStop();\n    if (this._terminal.options.screenReaderMode) {\n      this._terminal.emit('a11y.tab', this._terminal.buffer.x - originalX);\n    }\n  }\n\n  /**\n   * SO\n   * Shift Out (Ctrl-N) -> Switch to Alternate Character Set.  This invokes the\n   * G1 character set.\n   */\n  public shiftOut(): void {\n    this._terminal.setgLevel(1);\n  }\n\n  /**\n   * SI\n   * Shift In (Ctrl-O) -> Switch to Standard Character Set.  This invokes the G0\n   * character set (the default).\n   */\n  public shiftIn(): void {\n    this._terminal.setgLevel(0);\n  }\n\n  /**\n   * CSI Ps @\n   * Insert Ps (Blank) Character(s) (default = 1) (ICH).\n   */\n  public insertChars(params: number[]): void {\n    this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).insertCells(\n      this._terminal.buffer.x,\n      params[0] || 1,\n      this._terminal.buffer.getNullCell(this._terminal.eraseAttrData())\n    );\n    this._terminal.updateRange(this._terminal.buffer.y);\n  }\n\n  /**\n   * CSI Ps A\n   * Cursor Up Ps Times (default = 1) (CUU).\n   */\n  public cursorUp(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.y -= param;\n    if (this._terminal.buffer.y < 0) {\n      this._terminal.buffer.y = 0;\n    }\n  }\n\n  /**\n   * CSI Ps B\n   * Cursor Down Ps Times (default = 1) (CUD).\n   */\n  public cursorDown(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.y += param;\n    if (this._terminal.buffer.y >= this._terminal.rows) {\n      this._terminal.buffer.y = this._terminal.rows - 1;\n    }\n    // If the end of the line is hit, prevent this action from wrapping around to the next line.\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x--;\n    }\n  }\n\n  /**\n   * CSI Ps C\n   * Cursor Forward Ps Times (default = 1) (CUF).\n   */\n  public cursorForward(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.x += param;\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x = this._terminal.cols - 1;\n    }\n  }\n\n  /**\n   * CSI Ps D\n   * Cursor Backward Ps Times (default = 1) (CUB).\n   */\n  public cursorBackward(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    // If the end of the line is hit, prevent this action from wrapping around to the next line.\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x--;\n    }\n    this._terminal.buffer.x -= param;\n    if (this._terminal.buffer.x < 0) {\n      this._terminal.buffer.x = 0;\n    }\n  }\n\n  /**\n   * CSI Ps E\n   * Cursor Next Line Ps Times (default = 1) (CNL).\n   * same as CSI Ps B ?\n   */\n  public cursorNextLine(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.y += param;\n    if (this._terminal.buffer.y >= this._terminal.rows) {\n      this._terminal.buffer.y = this._terminal.rows - 1;\n    }\n    this._terminal.buffer.x = 0;\n  }\n\n\n  /**\n   * CSI Ps F\n   * Cursor Preceding Line Ps Times (default = 1) (CNL).\n   * reuse CSI Ps A ?\n   */\n  public cursorPrecedingLine(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.y -= param;\n    if (this._terminal.buffer.y < 0) {\n      this._terminal.buffer.y = 0;\n    }\n    this._terminal.buffer.x = 0;\n  }\n\n\n  /**\n   * CSI Ps G\n   * Cursor Character Absolute  [column] (default = [row,1]) (CHA).\n   */\n  public cursorCharAbsolute(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.x = param - 1;\n  }\n\n  /**\n   * CSI Ps ; Ps H\n   * Cursor Position [row;column] (default = [1,1]) (CUP).\n   */\n  public cursorPosition(params: number[]): void {\n    let col: number;\n    let row: number = params[0] - 1;\n\n    if (params.length >= 2) {\n      col = params[1] - 1;\n    } else {\n      col = 0;\n    }\n\n    if (row < 0) {\n      row = 0;\n    } else if (row >= this._terminal.rows) {\n      row = this._terminal.rows - 1;\n    }\n\n    if (col < 0) {\n      col = 0;\n    } else if (col >= this._terminal.cols) {\n      col = this._terminal.cols - 1;\n    }\n\n    this._terminal.buffer.x = col;\n    this._terminal.buffer.y = row;\n  }\n\n  /**\n   * CSI Ps I\n   *   Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).\n   */\n  public cursorForwardTab(params: number[]): void {\n    let param = params[0] || 1;\n    while (param--) {\n      this._terminal.buffer.x = this._terminal.buffer.nextStop();\n    }\n  }\n\n  /**\n   * Helper method to erase cells in a terminal row.\n   * The cell gets replaced with the eraseChar of the terminal.\n   * @param y row index\n   * @param start first cell index to be erased\n   * @param end   end - 1 is last erased cell\n   */\n  private _eraseInBufferLine(y: number, start: number, end: number, clearWrap: boolean = false): void {\n    const line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + y);\n    line.replaceCells(\n      start,\n      end,\n      this._terminal.buffer.getNullCell(this._terminal.eraseAttrData())\n    );\n    if (clearWrap) {\n      line.isWrapped = false;\n    }\n  }\n\n  /**\n   * Helper method to reset cells in a terminal row.\n   * The cell gets replaced with the eraseChar of the terminal and the isWrapped property is set to false.\n   * @param y row index\n   */\n  private _resetBufferLine(y: number): void {\n    this._eraseInBufferLine(y, 0, this._terminal.cols, true);\n  }\n\n  /**\n   * CSI Ps J  Erase in Display (ED).\n   *     Ps = 0  -> Erase Below (default).\n   *     Ps = 1  -> Erase Above.\n   *     Ps = 2  -> Erase All.\n   *     Ps = 3  -> Erase Saved Lines (xterm).\n   * CSI ? Ps J\n   *   Erase in Display (DECSED).\n   *     Ps = 0  -> Selective Erase Below (default).\n   *     Ps = 1  -> Selective Erase Above.\n   *     Ps = 2  -> Selective Erase All.\n   */\n  public eraseInDisplay(params: number[]): void {\n    let j;\n    switch (params[0]) {\n      case 0:\n        j = this._terminal.buffer.y;\n        this._terminal.updateRange(j);\n        this._eraseInBufferLine(j++, this._terminal.buffer.x, this._terminal.cols, this._terminal.buffer.x === 0);\n        for (; j < this._terminal.rows; j++) {\n          this._resetBufferLine(j);\n        }\n        this._terminal.updateRange(j);\n        break;\n      case 1:\n        j = this._terminal.buffer.y;\n        this._terminal.updateRange(j);\n        // Deleted front part of line and everything before. This line will no longer be wrapped.\n        this._eraseInBufferLine(j, 0, this._terminal.buffer.x + 1, true);\n        if (this._terminal.buffer.x + 1 >= this._terminal.cols) {\n          // Deleted entire previous line. This next line can no longer be wrapped.\n          this._terminal.buffer.lines.get(j + 1).isWrapped = false;\n        }\n        while (j--) {\n          this._resetBufferLine(j);\n        }\n        this._terminal.updateRange(0);\n        break;\n      case 2:\n        j = this._terminal.rows;\n        this._terminal.updateRange(j - 1);\n        while (j--) {\n          this._resetBufferLine(j);\n        }\n        this._terminal.updateRange(0);\n        break;\n      case 3:\n        // Clear scrollback (everything not in viewport)\n        const scrollBackSize = this._terminal.buffer.lines.length - this._terminal.rows;\n        if (scrollBackSize > 0) {\n          this._terminal.buffer.lines.trimStart(scrollBackSize);\n          this._terminal.buffer.ybase = Math.max(this._terminal.buffer.ybase - scrollBackSize, 0);\n          this._terminal.buffer.ydisp = Math.max(this._terminal.buffer.ydisp - scrollBackSize, 0);\n          // Force a scroll event to refresh viewport\n          this._onScroll.fire(0);\n        }\n        break;\n    }\n  }\n\n  /**\n   * CSI Ps K  Erase in Line (EL).\n   *     Ps = 0  -> Erase to Right (default).\n   *     Ps = 1  -> Erase to Left.\n   *     Ps = 2  -> Erase All.\n   * CSI ? Ps K\n   *   Erase in Line (DECSEL).\n   *     Ps = 0  -> Selective Erase to Right (default).\n   *     Ps = 1  -> Selective Erase to Left.\n   *     Ps = 2  -> Selective Erase All.\n   */\n  public eraseInLine(params: number[]): void {\n    switch (params[0]) {\n      case 0:\n        this._eraseInBufferLine(this._terminal.buffer.y, this._terminal.buffer.x, this._terminal.cols);\n        break;\n      case 1:\n        this._eraseInBufferLine(this._terminal.buffer.y, 0, this._terminal.buffer.x + 1);\n        break;\n      case 2:\n        this._eraseInBufferLine(this._terminal.buffer.y, 0, this._terminal.cols);\n        break;\n    }\n    this._terminal.updateRange(this._terminal.buffer.y);\n  }\n\n  /**\n   * CSI Ps L\n   * Insert Ps Line(s) (default = 1) (IL).\n   */\n  public insertLines(params: number[]): void {\n    let param: number = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n\n    // make buffer local for faster access\n    const buffer = this._terminal.buffer;\n\n    const row: number = buffer.y + buffer.ybase;\n\n    const scrollBottomRowsOffset = this._terminal.rows - 1 - buffer.scrollBottom;\n    const scrollBottomAbsolute = this._terminal.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1;\n    while (param--) {\n      // test: echo -e '\\e[44m\\e[1L\\e[0m'\n      // blankLine(true) - xterm/linux behavior\n      buffer.lines.splice(scrollBottomAbsolute - 1, 1);\n      buffer.lines.splice(row, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));\n    }\n\n    // this.maxRange();\n    this._terminal.updateRange(buffer.y);\n    this._terminal.updateRange(buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps M\n   * Delete Ps Line(s) (default = 1) (DL).\n   */\n  public deleteLines(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n\n    // make buffer local for faster access\n    const buffer = this._terminal.buffer;\n\n    const row: number = buffer.y + buffer.ybase;\n\n    let j: number;\n    j = this._terminal.rows - 1 - buffer.scrollBottom;\n    j = this._terminal.rows - 1 + buffer.ybase - j;\n    while (param--) {\n      // test: echo -e '\\e[44m\\e[1M\\e[0m'\n      // blankLine(true) - xterm/linux behavior\n      buffer.lines.splice(row, 1);\n      buffer.lines.splice(j, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));\n    }\n\n    // this.maxRange();\n    this._terminal.updateRange(buffer.y);\n    this._terminal.updateRange(buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps P\n   * Delete Ps Character(s) (default = 1) (DCH).\n   */\n  public deleteChars(params: number[]): void {\n    this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).deleteCells(\n      this._terminal.buffer.x,\n      params[0] || 1,\n      this._terminal.buffer.getNullCell(this._terminal.eraseAttrData())\n    );\n    this._terminal.updateRange(this._terminal.buffer.y);\n  }\n\n  /**\n   * CSI Ps S  Scroll up Ps lines (default = 1) (SU).\n   */\n  public scrollUp(params: number[]): void {\n    let param = params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._terminal.buffer;\n\n    while (param--) {\n      buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1);\n      buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA));\n    }\n    // this.maxRange();\n    this._terminal.updateRange(buffer.scrollTop);\n    this._terminal.updateRange(buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps T  Scroll down Ps lines (default = 1) (SD).\n   */\n  public scrollDown(params: number[], collect?: string): void {\n    if (params.length < 2 && !collect) {\n      let param = params[0] || 1;\n\n      // make buffer local for faster access\n      const buffer = this._terminal.buffer;\n\n      while (param--) {\n        buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1);\n        buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA));\n      }\n      // this.maxRange();\n      this._terminal.updateRange(buffer.scrollTop);\n      this._terminal.updateRange(buffer.scrollBottom);\n    }\n  }\n\n  /**\n   * CSI Ps X\n   * Erase Ps Character(s) (default = 1) (ECH).\n   */\n  public eraseChars(params: number[]): void {\n    this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).replaceCells(\n      this._terminal.buffer.x,\n      this._terminal.buffer.x + (params[0] || 1),\n      this._terminal.buffer.getNullCell(this._terminal.eraseAttrData())\n    );\n  }\n\n  /**\n   * CSI Ps Z  Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).\n   */\n  public cursorBackwardTab(params: number[]): void {\n    let param = params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._terminal.buffer;\n\n    while (param--) {\n      buffer.x = buffer.prevStop();\n    }\n  }\n\n  /**\n   * CSI Pm `  Character Position Absolute\n   *   [column] (default = [row,1]) (HPA).\n   */\n  public charPosAbsolute(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.x = param - 1;\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x = this._terminal.cols - 1;\n    }\n  }\n\n  /**\n   * CSI Pm a  Character Position Relative\n   *   [columns] (default = [row,col+1]) (HPR)\n   * reuse CSI Ps C ?\n   */\n  public hPositionRelative(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.x += param;\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x = this._terminal.cols - 1;\n    }\n  }\n\n  /**\n   * CSI Ps b  Repeat the preceding graphic character Ps times (REP).\n   */\n  public repeatPrecedingCharacter(params: number[]): void {\n    // make buffer local for faster access\n    const buffer = this._terminal.buffer;\n    const line = buffer.lines.get(buffer.ybase + buffer.y);\n    line.loadCell(buffer.x - 1, this._workCell);\n    line.replaceCells(buffer.x,\n      buffer.x + (params[0] || 1),\n      (this._workCell.content !== undefined) ? this._workCell : buffer.getNullCell(DEFAULT_ATTR_DATA)\n    );\n    // FIXME: no updateRange here?\n  }\n\n  /**\n   * CSI Ps c  Send Device Attributes (Primary DA).\n   *     Ps = 0  or omitted -> request attributes from terminal.  The\n   *     response depends on the decTerminalID resource setting.\n   *     -> CSI ? 1 ; 2 c  (``VT100 with Advanced Video Option'')\n   *     -> CSI ? 1 ; 0 c  (``VT101 with No Options'')\n   *     -> CSI ? 6 c  (``VT102'')\n   *     -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c  (``VT220'')\n   *   The VT100-style response parameters do not mean anything by\n   *   themselves.  VT220 parameters do, telling the host what fea-\n   *   tures the terminal supports:\n   *     Ps = 1  -> 132-columns.\n   *     Ps = 2  -> Printer.\n   *     Ps = 6  -> Selective erase.\n   *     Ps = 8  -> User-defined keys.\n   *     Ps = 9  -> National replacement character sets.\n   *     Ps = 1 5  -> Technical characters.\n   *     Ps = 2 2  -> ANSI color, e.g., VT525.\n   *     Ps = 2 9  -> ANSI text locator (i.e., DEC Locator mode).\n   * CSI > Ps c\n   *   Send Device Attributes (Secondary DA).\n   *     Ps = 0  or omitted -> request the terminal's identification\n   *     code.  The response depends on the decTerminalID resource set-\n   *     ting.  It should apply only to VT220 and up, but xterm extends\n   *     this to VT100.\n   *     -> CSI  > Pp ; Pv ; Pc c\n   *   where Pp denotes the terminal type\n   *     Pp = 0  -> ``VT100''.\n   *     Pp = 1  -> ``VT220''.\n   *   and Pv is the firmware version (for xterm, this was originally\n   *   the XFree86 patch number, starting with 95).  In a DEC termi-\n   *   nal, Pc indicates the ROM cartridge registration number and is\n   *   always zero.\n   * More information:\n   *   xterm/charproc.c - line 2012, for more information.\n   *   vim responds with ^[[?0c or ^[[?1c after the terminal's response (?)\n   */\n  public sendDeviceAttributes(params: number[], collect?: string): void {\n    if (params[0] > 0) {\n      return;\n    }\n\n    if (!collect) {\n      if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {\n        this._terminal.handler(C0.ESC + '[?1;2c');\n      } else if (this._terminal.is('linux')) {\n        this._terminal.handler(C0.ESC + '[?6c');\n      }\n    } else if (collect === '>') {\n      // xterm and urxvt\n      // seem to spit this\n      // out around ~370 times (?).\n      if (this._terminal.is('xterm')) {\n        this._terminal.handler(C0.ESC + '[>0;276;0c');\n      } else if (this._terminal.is('rxvt-unicode')) {\n        this._terminal.handler(C0.ESC + '[>85;95;0c');\n      } else if (this._terminal.is('linux')) {\n        // not supported by linux console.\n        // linux console echoes parameters.\n        this._terminal.handler(params[0] + 'c');\n      } else if (this._terminal.is('screen')) {\n        this._terminal.handler(C0.ESC + '[>83;40003;0c');\n      }\n    }\n  }\n\n  /**\n   * CSI Pm d  Vertical Position Absolute (VPA)\n   *   [row] (default = [1,column])\n   */\n  public linePosAbsolute(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.y = param - 1;\n    if (this._terminal.buffer.y >= this._terminal.rows) {\n      this._terminal.buffer.y = this._terminal.rows - 1;\n    }\n  }\n\n  /**\n   * CSI Pm e  Vertical Position Relative (VPR)\n   *   [rows] (default = [row+1,column])\n   * reuse CSI Ps B ?\n   */\n  public vPositionRelative(params: number[]): void {\n    let param = params[0];\n    if (param < 1) {\n      param = 1;\n    }\n    this._terminal.buffer.y += param;\n    if (this._terminal.buffer.y >= this._terminal.rows) {\n      this._terminal.buffer.y = this._terminal.rows - 1;\n    }\n    // If the end of the line is hit, prevent this action from wrapping around to the next line.\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x--;\n    }\n  }\n\n  /**\n   * CSI Ps ; Ps f\n   *   Horizontal and Vertical Position [row;column] (default =\n   *   [1,1]) (HVP).\n   */\n  public hVPosition(params: number[]): void {\n    if (params[0] < 1) params[0] = 1;\n    if (params[1] < 1) params[1] = 1;\n\n    this._terminal.buffer.y = params[0] - 1;\n    if (this._terminal.buffer.y >= this._terminal.rows) {\n      this._terminal.buffer.y = this._terminal.rows - 1;\n    }\n\n    this._terminal.buffer.x = params[1] - 1;\n    if (this._terminal.buffer.x >= this._terminal.cols) {\n      this._terminal.buffer.x = this._terminal.cols - 1;\n    }\n  }\n\n  /**\n   * CSI Ps g  Tab Clear (TBC).\n   *     Ps = 0  -> Clear Current Column (default).\n   *     Ps = 3  -> Clear All.\n   * Potentially:\n   *   Ps = 2  -> Clear Stops on Line.\n   *   http://vt100.net/annarbor/aaa-ug/section6.html\n   */\n  public tabClear(params: number[]): void {\n    const param = params[0];\n    if (param <= 0) {\n      delete this._terminal.buffer.tabs[this._terminal.buffer.x];\n    } else if (param === 3) {\n      this._terminal.buffer.tabs = {};\n    }\n  }\n\n  /**\n   * CSI Pm h  Set Mode (SM).\n   *     Ps = 2  -> Keyboard Action Mode (AM).\n   *     Ps = 4  -> Insert Mode (IRM).\n   *     Ps = 1 2  -> Send/receive (SRM).\n   *     Ps = 2 0  -> Automatic Newline (LNM).\n   * CSI ? Pm h\n   *   DEC Private Mode Set (DECSET).\n   *     Ps = 1  -> Application Cursor Keys (DECCKM).\n   *     Ps = 2  -> Designate USASCII for character sets G0-G3\n   *     (DECANM), and set VT100 mode.\n   *     Ps = 3  -> 132 Column Mode (DECCOLM).\n   *     Ps = 4  -> Smooth (Slow) Scroll (DECSCLM).\n   *     Ps = 5  -> Reverse Video (DECSCNM).\n   *     Ps = 6  -> Origin Mode (DECOM).\n   *     Ps = 7  -> Wraparound Mode (DECAWM).\n   *     Ps = 8  -> Auto-repeat Keys (DECARM).\n   *     Ps = 9  -> Send Mouse X & Y on button press.  See the sec-\n   *     tion Mouse Tracking.\n   *     Ps = 1 0  -> Show toolbar (rxvt).\n   *     Ps = 1 2  -> Start Blinking Cursor (att610).\n   *     Ps = 1 8  -> Print form feed (DECPFF).\n   *     Ps = 1 9  -> Set print extent to full screen (DECPEX).\n   *     Ps = 2 5  -> Show Cursor (DECTCEM).\n   *     Ps = 3 0  -> Show scrollbar (rxvt).\n   *     Ps = 3 5  -> Enable font-shifting functions (rxvt).\n   *     Ps = 3 8  -> Enter Tektronix Mode (DECTEK).\n   *     Ps = 4 0  -> Allow 80 -> 132 Mode.\n   *     Ps = 4 1  -> more(1) fix (see curses resource).\n   *     Ps = 4 2  -> Enable Nation Replacement Character sets (DECN-\n   *     RCM).\n   *     Ps = 4 4  -> Turn On Margin Bell.\n   *     Ps = 4 5  -> Reverse-wraparound Mode.\n   *     Ps = 4 6  -> Start Logging.  This is normally disabled by a\n   *     compile-time option.\n   *     Ps = 4 7  -> Use Alternate Screen Buffer.  (This may be dis-\n   *     abled by the titeInhibit resource).\n   *     Ps = 6 6  -> Application keypad (DECNKM).\n   *     Ps = 6 7  -> Backarrow key sends backspace (DECBKM).\n   *     Ps = 1 0 0 0  -> Send Mouse X & Y on button press and\n   *     release.  See the section Mouse Tracking.\n   *     Ps = 1 0 0 1  -> Use Hilite Mouse Tracking.\n   *     Ps = 1 0 0 2  -> Use Cell Motion Mouse Tracking.\n   *     Ps = 1 0 0 3  -> Use All Motion Mouse Tracking.\n   *     Ps = 1 0 0 4  -> Send FocusIn/FocusOut events.\n   *     Ps = 1 0 0 5  -> Enable Extended Mouse Mode.\n   *     Ps = 1 0 1 0  -> Scroll to bottom on tty output (rxvt).\n   *     Ps = 1 0 1 1  -> Scroll to bottom on key press (rxvt).\n   *     Ps = 1 0 3 4  -> Interpret \"meta\" key, sets eighth bit.\n   *     (enables the eightBitInput resource).\n   *     Ps = 1 0 3 5  -> Enable special modifiers for Alt and Num-\n   *     Lock keys.  (This enables the numLock resource).\n   *     Ps = 1 0 3 6  -> Send ESC   when Meta modifies a key.  (This\n   *     enables the metaSendsEscape resource).\n   *     Ps = 1 0 3 7  -> Send DEL from the editing-keypad Delete\n   *     key.\n   *     Ps = 1 0 3 9  -> Send ESC  when Alt modifies a key.  (This\n   *     enables the altSendsEscape resource).\n   *     Ps = 1 0 4 0  -> Keep selection even if not highlighted.\n   *     (This enables the keepSelection resource).\n   *     Ps = 1 0 4 1  -> Use the CLIPBOARD selection.  (This enables\n   *     the selectToClipboard resource).\n   *     Ps = 1 0 4 2  -> Enable Urgency window manager hint when\n   *     Control-G is received.  (This enables the bellIsUrgent\n   *     resource).\n   *     Ps = 1 0 4 3  -> Enable raising of the window when Control-G\n   *     is received.  (enables the popOnBell resource).\n   *     Ps = 1 0 4 7  -> Use Alternate Screen Buffer.  (This may be\n   *     disabled by the titeInhibit resource).\n   *     Ps = 1 0 4 8  -> Save cursor as in DECSC.  (This may be dis-\n   *     abled by the titeInhibit resource).\n   *     Ps = 1 0 4 9  -> Save cursor as in DECSC and use Alternate\n   *     Screen Buffer, clearing it first.  (This may be disabled by\n   *     the titeInhibit resource).  This combines the effects of the 1\n   *     0 4 7  and 1 0 4 8  modes.  Use this with terminfo-based\n   *     applications rather than the 4 7  mode.\n   *     Ps = 1 0 5 0  -> Set terminfo/termcap function-key mode.\n   *     Ps = 1 0 5 1  -> Set Sun function-key mode.\n   *     Ps = 1 0 5 2  -> Set HP function-key mode.\n   *     Ps = 1 0 5 3  -> Set SCO function-key mode.\n   *     Ps = 1 0 6 0  -> Set legacy keyboard emulation (X11R6).\n   *     Ps = 1 0 6 1  -> Set VT220 keyboard emulation.\n   *     Ps = 2 0 0 4  -> Set bracketed paste mode.\n   * Modes:\n   *   http: *vt100.net/docs/vt220-rm/chapter4.html\n   */\n  public setMode(params: number[], collect?: string): void {\n    if (params.length > 1) {\n      for (let i = 0; i < params.length; i++) {\n        this.setMode([params[i]]);\n      }\n\n      return;\n    }\n\n    if (!collect) {\n      switch (params[0]) {\n        case 4:\n          this._terminal.insertMode = true;\n          break;\n        case 20:\n          // this._t.convertEol = true;\n          break;\n      }\n    } else if (collect === '?') {\n      switch (params[0]) {\n        case 1:\n          this._terminal.applicationCursor = true;\n          break;\n        case 2:\n          this._terminal.setgCharset(0, DEFAULT_CHARSET);\n          this._terminal.setgCharset(1, DEFAULT_CHARSET);\n          this._terminal.setgCharset(2, DEFAULT_CHARSET);\n          this._terminal.setgCharset(3, DEFAULT_CHARSET);\n          // set VT100 mode here\n          break;\n        case 3: // 132 col mode\n          this._terminal.savedCols = this._terminal.cols;\n          this._terminal.resize(132, this._terminal.rows);\n          break;\n        case 6:\n          this._terminal.originMode = true;\n          break;\n        case 7:\n          this._terminal.wraparoundMode = true;\n          break;\n        case 12:\n          // this.cursorBlink = true;\n          break;\n        case 66:\n          this._terminal.log('Serial port requested application keypad.');\n          this._terminal.applicationKeypad = true;\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          break;\n        case 9: // X10 Mouse\n          // no release, no motion, no wheel, no modifiers.\n        case 1000: // vt200 mouse\n          // no motion.\n          // no modifiers, except control on the wheel.\n        case 1002: // button event mouse\n        case 1003: // any event mouse\n          // any event - sends motion events,\n          // even if there is no button held down.\n\n          // TODO: Why are params[0] compares nested within a switch for params[0]?\n\n          this._terminal.x10Mouse = params[0] === 9;\n          this._terminal.vt200Mouse = params[0] === 1000;\n          this._terminal.normalMouse = params[0] > 1000;\n          this._terminal.mouseEvents = true;\n          if (this._terminal.element) {\n            this._terminal.element.classList.add('enable-mouse-events');\n          }\n          if (this._terminal.selectionManager) {\n            this._terminal.selectionManager.disable();\n          }\n          this._terminal.log('Binding to mouse events.');\n          break;\n        case 1004: // send focusin/focusout events\n          // focusin: ^[[I\n          // focusout: ^[[O\n          this._terminal.sendFocus = true;\n          break;\n        case 1005: // utf8 ext mode mouse\n          this._terminal.utfMouse = true;\n          // for wide terminals\n          // simply encodes large values as utf8 characters\n          break;\n        case 1006: // sgr ext mode mouse\n          this._terminal.sgrMouse = true;\n          // for wide terminals\n          // does not add 32 to fields\n          // press: ^[[<b;x;yM\n          // release: ^[[<b;x;ym\n          break;\n        case 1015: // urxvt ext mode mouse\n          this._terminal.urxvtMouse = true;\n          // for wide terminals\n          // numbers for fields\n          // press: ^[[b;x;yM\n          // motion: ^[[b;x;yT\n          break;\n        case 25: // show cursor\n          this._terminal.cursorHidden = false;\n          break;\n        case 1048: // alt screen cursor\n          this.saveCursor(params);\n          break;\n        case 1049: // alt screen buffer cursor\n          this.saveCursor(params);\n          // FALL-THROUGH\n        case 47: // alt screen buffer\n        case 1047: // alt screen buffer\n          this._terminal.buffers.activateAltBuffer(this._terminal.eraseAttrData());\n          this._terminal.refresh(0, this._terminal.rows - 1);\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          this._terminal.showCursor();\n          break;\n        case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)\n          this._terminal.bracketedPasteMode = true;\n          break;\n      }\n    }\n  }\n\n  /**\n   * CSI Pm l  Reset Mode (RM).\n   *     Ps = 2  -> Keyboard Action Mode (AM).\n   *     Ps = 4  -> Replace Mode (IRM).\n   *     Ps = 1 2  -> Send/receive (SRM).\n   *     Ps = 2 0  -> Normal Linefeed (LNM).\n   * CSI ? Pm l\n   *   DEC Private Mode Reset (DECRST).\n   *     Ps = 1  -> Normal Cursor Keys (DECCKM).\n   *     Ps = 2  -> Designate VT52 mode (DECANM).\n   *     Ps = 3  -> 80 Column Mode (DECCOLM).\n   *     Ps = 4  -> Jump (Fast) Scroll (DECSCLM).\n   *     Ps = 5  -> Normal Video (DECSCNM).\n   *     Ps = 6  -> Normal Cursor Mode (DECOM).\n   *     Ps = 7  -> No Wraparound Mode (DECAWM).\n   *     Ps = 8  -> No Auto-repeat Keys (DECARM).\n   *     Ps = 9  -> Don't send Mouse X & Y on button press.\n   *     Ps = 1 0  -> Hide toolbar (rxvt).\n   *     Ps = 1 2  -> Stop Blinking Cursor (att610).\n   *     Ps = 1 8  -> Don't print form feed (DECPFF).\n   *     Ps = 1 9  -> Limit print to scrolling region (DECPEX).\n   *     Ps = 2 5  -> Hide Cursor (DECTCEM).\n   *     Ps = 3 0  -> Don't show scrollbar (rxvt).\n   *     Ps = 3 5  -> Disable font-shifting functions (rxvt).\n   *     Ps = 4 0  -> Disallow 80 -> 132 Mode.\n   *     Ps = 4 1  -> No more(1) fix (see curses resource).\n   *     Ps = 4 2  -> Disable Nation Replacement Character sets (DEC-\n   *     NRCM).\n   *     Ps = 4 4  -> Turn Off Margin Bell.\n   *     Ps = 4 5  -> No Reverse-wraparound Mode.\n   *     Ps = 4 6  -> Stop Logging.  (This is normally disabled by a\n   *     compile-time option).\n   *     Ps = 4 7  -> Use Normal Screen Buffer.\n   *     Ps = 6 6  -> Numeric keypad (DECNKM).\n   *     Ps = 6 7  -> Backarrow key sends delete (DECBKM).\n   *     Ps = 1 0 0 0  -> Don't send Mouse X & Y on button press and\n   *     release.  See the section Mouse Tracking.\n   *     Ps = 1 0 0 1  -> Don't use Hilite Mouse Tracking.\n   *     Ps = 1 0 0 2  -> Don't use Cell Motion Mouse Tracking.\n   *     Ps = 1 0 0 3  -> Don't use All Motion Mouse Tracking.\n   *     Ps = 1 0 0 4  -> Don't send FocusIn/FocusOut events.\n   *     Ps = 1 0 0 5  -> Disable Extended Mouse Mode.\n   *     Ps = 1 0 1 0  -> Don't scroll to bottom on tty output\n   *     (rxvt).\n   *     Ps = 1 0 1 1  -> Don't scroll to bottom on key press (rxvt).\n   *     Ps = 1 0 3 4  -> Don't interpret \"meta\" key.  (This disables\n   *     the eightBitInput resource).\n   *     Ps = 1 0 3 5  -> Disable special modifiers for Alt and Num-\n   *     Lock keys.  (This disables the numLock resource).\n   *     Ps = 1 0 3 6  -> Don't send ESC  when Meta modifies a key.\n   *     (This disables the metaSendsEscape resource).\n   *     Ps = 1 0 3 7  -> Send VT220 Remove from the editing-keypad\n   *     Delete key.\n   *     Ps = 1 0 3 9  -> Don't send ESC  when Alt modifies a key.\n   *     (This disables the altSendsEscape resource).\n   *     Ps = 1 0 4 0  -> Do not keep selection when not highlighted.\n   *     (This disables the keepSelection resource).\n   *     Ps = 1 0 4 1  -> Use the PRIMARY selection.  (This disables\n   *     the selectToClipboard resource).\n   *     Ps = 1 0 4 2  -> Disable Urgency window manager hint when\n   *     Control-G is received.  (This disables the bellIsUrgent\n   *     resource).\n   *     Ps = 1 0 4 3  -> Disable raising of the window when Control-\n   *     G is received.  (This disables the popOnBell resource).\n   *     Ps = 1 0 4 7  -> Use Normal Screen Buffer, clearing screen\n   *     first if in the Alternate Screen.  (This may be disabled by\n   *     the titeInhibit resource).\n   *     Ps = 1 0 4 8  -> Restore cursor as in DECRC.  (This may be\n   *     disabled by the titeInhibit resource).\n   *     Ps = 1 0 4 9  -> Use Normal Screen Buffer and restore cursor\n   *     as in DECRC.  (This may be disabled by the titeInhibit\n   *     resource).  This combines the effects of the 1 0 4 7  and 1 0\n   *     4 8  modes.  Use this with terminfo-based applications rather\n   *     than the 4 7  mode.\n   *     Ps = 1 0 5 0  -> Reset terminfo/termcap function-key mode.\n   *     Ps = 1 0 5 1  -> Reset Sun function-key mode.\n   *     Ps = 1 0 5 2  -> Reset HP function-key mode.\n   *     Ps = 1 0 5 3  -> Reset SCO function-key mode.\n   *     Ps = 1 0 6 0  -> Reset legacy keyboard emulation (X11R6).\n   *     Ps = 1 0 6 1  -> Reset keyboard emulation to Sun/PC style.\n   *     Ps = 2 0 0 4  -> Reset bracketed paste mode.\n   */\n  public resetMode(params: number[], collect?: string): void {\n    if (params.length > 1) {\n      for (let i = 0; i < params.length; i++) {\n        this.resetMode([params[i]]);\n      }\n\n      return;\n    }\n\n    if (!collect) {\n      switch (params[0]) {\n        case 4:\n          this._terminal.insertMode = false;\n          break;\n        case 20:\n          // this._t.convertEol = false;\n          break;\n      }\n    } else if (collect === '?') {\n      switch (params[0]) {\n        case 1:\n          this._terminal.applicationCursor = false;\n          break;\n        case 3:\n          if (this._terminal.cols === 132 && this._terminal.savedCols) {\n            this._terminal.resize(this._terminal.savedCols, this._terminal.rows);\n          }\n          delete this._terminal.savedCols;\n          break;\n        case 6:\n          this._terminal.originMode = false;\n          break;\n        case 7:\n          this._terminal.wraparoundMode = false;\n          break;\n        case 12:\n          // this.cursorBlink = false;\n          break;\n        case 66:\n          this._terminal.log('Switching back to normal keypad.');\n          this._terminal.applicationKeypad = false;\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          break;\n        case 9: // X10 Mouse\n        case 1000: // vt200 mouse\n        case 1002: // button event mouse\n        case 1003: // any event mouse\n          this._terminal.x10Mouse = false;\n          this._terminal.vt200Mouse = false;\n          this._terminal.normalMouse = false;\n          this._terminal.mouseEvents = false;\n          if (this._terminal.element) {\n            this._terminal.element.classList.remove('enable-mouse-events');\n          }\n          if (this._terminal.selectionManager) {\n            this._terminal.selectionManager.enable();\n          }\n          break;\n        case 1004: // send focusin/focusout events\n          this._terminal.sendFocus = false;\n          break;\n        case 1005: // utf8 ext mode mouse\n          this._terminal.utfMouse = false;\n          break;\n        case 1006: // sgr ext mode mouse\n          this._terminal.sgrMouse = false;\n          break;\n        case 1015: // urxvt ext mode mouse\n          this._terminal.urxvtMouse = false;\n          break;\n        case 25: // hide cursor\n          this._terminal.cursorHidden = true;\n          break;\n        case 1048: // alt screen cursor\n          this.restoreCursor(params);\n          break;\n        case 1049: // alt screen buffer cursor\n           // FALL-THROUGH\n        case 47: // normal screen buffer\n        case 1047: // normal screen buffer - clearing it first\n          // Ensure the selection manager has the correct buffer\n          this._terminal.buffers.activateNormalBuffer();\n          if (params[0] === 1049) {\n            this.restoreCursor(params);\n          }\n          this._terminal.refresh(0, this._terminal.rows - 1);\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          this._terminal.showCursor();\n          break;\n        case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)\n          this._terminal.bracketedPasteMode = false;\n          break;\n      }\n    }\n  }\n\n  /**\n   * CSI Pm m  Character Attributes (SGR).\n   *     Ps = 0  -> Normal (default).\n   *     Ps = 1  -> Bold.\n   *     Ps = 2  -> Faint, decreased intensity (ISO 6429).\n   *     Ps = 4  -> Underlined.\n   *     Ps = 5  -> Blink (appears as Bold).\n   *     Ps = 7  -> Inverse.\n   *     Ps = 8  -> Invisible, i.e., hidden (VT300).\n   *     Ps = 2 2  -> Normal (neither bold nor faint).\n   *     Ps = 2 4  -> Not underlined.\n   *     Ps = 2 5  -> Steady (not blinking).\n   *     Ps = 2 7  -> Positive (not inverse).\n   *     Ps = 2 8  -> Visible, i.e., not hidden (VT300).\n   *     Ps = 3 0  -> Set foreground color to Black.\n   *     Ps = 3 1  -> Set foreground color to Red.\n   *     Ps = 3 2  -> Set foreground color to Green.\n   *     Ps = 3 3  -> Set foreground color to Yellow.\n   *     Ps = 3 4  -> Set foreground color to Blue.\n   *     Ps = 3 5  -> Set foreground color to Magenta.\n   *     Ps = 3 6  -> Set foreground color to Cyan.\n   *     Ps = 3 7  -> Set foreground color to White.\n   *     Ps = 3 9  -> Set foreground color to default (original).\n   *     Ps = 4 0  -> Set background color to Black.\n   *     Ps = 4 1  -> Set background color to Red.\n   *     Ps = 4 2  -> Set background color to Green.\n   *     Ps = 4 3  -> Set background color to Yellow.\n   *     Ps = 4 4  -> Set background color to Blue.\n   *     Ps = 4 5  -> Set background color to Magenta.\n   *     Ps = 4 6  -> Set background color to Cyan.\n   *     Ps = 4 7  -> Set background color to White.\n   *     Ps = 4 9  -> Set background color to default (original).\n   *\n   *   If 16-color support is compiled, the following apply.  Assume\n   *   that xterm's resources are set so that the ISO color codes are\n   *   the first 8 of a set of 16.  Then the aixterm colors are the\n   *   bright versions of the ISO colors:\n   *     Ps = 9 0  -> Set foreground color to Black.\n   *     Ps = 9 1  -> Set foreground color to Red.\n   *     Ps = 9 2  -> Set foreground color to Green.\n   *     Ps = 9 3  -> Set foreground color to Yellow.\n   *     Ps = 9 4  -> Set foreground color to Blue.\n   *     Ps = 9 5  -> Set foreground color to Magenta.\n   *     Ps = 9 6  -> Set foreground color to Cyan.\n   *     Ps = 9 7  -> Set foreground color to White.\n   *     Ps = 1 0 0  -> Set background color to Black.\n   *     Ps = 1 0 1  -> Set background color to Red.\n   *     Ps = 1 0 2  -> Set background color to Green.\n   *     Ps = 1 0 3  -> Set background color to Yellow.\n   *     Ps = 1 0 4  -> Set background color to Blue.\n   *     Ps = 1 0 5  -> Set background color to Magenta.\n   *     Ps = 1 0 6  -> Set background color to Cyan.\n   *     Ps = 1 0 7  -> Set background color to White.\n   *\n   *   If xterm is compiled with the 16-color support disabled, it\n   *   supports the following, from rxvt:\n   *     Ps = 1 0 0  -> Set foreground and background color to\n   *     default.\n   *\n   *   If 88- or 256-color support is compiled, the following apply.\n   *     Ps = 3 8  ; 5  ; Ps -> Set foreground color to the second\n   *     Ps.\n   *     Ps = 4 8  ; 5  ; Ps -> Set background color to the second\n   *     Ps.\n   */\n  public charAttributes(params: number[]): void {\n    // Optimize a single SGR0.\n    if (params.length === 1 && params[0] === 0) {\n      this._terminal.curAttrData.fg = DEFAULT_ATTR_DATA.fg;\n      this._terminal.curAttrData.bg = DEFAULT_ATTR_DATA.bg;\n      return;\n    }\n\n    const l = params.length;\n    let p;\n    const attr = this._terminal.curAttrData;\n\n    for (let i = 0; i < l; i++) {\n      p = params[i];\n      if (p >= 30 && p <= 37) {\n        // fg color 8\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.fg |= Attributes.CM_P16 | (p - 30);\n      } else if (p >= 40 && p <= 47) {\n        // bg color 8\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.bg |= Attributes.CM_P16 | (p - 40);\n      } else if (p >= 90 && p <= 97) {\n        // fg color 16\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.fg |= Attributes.CM_P16 | (p - 90) | 8;\n      } else if (p >= 100 && p <= 107) {\n        // bg color 16\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.bg |= Attributes.CM_P16 | (p - 100) | 8;\n      } else if (p === 0) {\n        // default\n        attr.fg = DEFAULT_ATTR_DATA.fg;\n        attr.bg = DEFAULT_ATTR_DATA.bg;\n      } else if (p === 1) {\n        // bold text\n        attr.fg |= FgFlags.BOLD;\n      } else if (p === 3) {\n        // italic text\n        attr.bg |= BgFlags.ITALIC;\n      } else if (p === 4) {\n        // underlined text\n        attr.fg |= FgFlags.UNDERLINE;\n      } else if (p === 5) {\n        // blink\n        attr.fg |= FgFlags.BLINK;\n      } else if (p === 7) {\n        // inverse and positive\n        // test with: echo -e '\\e[31m\\e[42mhello\\e[7mworld\\e[27mhi\\e[m'\n        attr.fg |= FgFlags.INVERSE;\n      } else if (p === 8) {\n        // invisible\n        attr.fg |= FgFlags.INVISIBLE;\n      } else if (p === 2) {\n        // dimmed text\n        attr.bg |= BgFlags.DIM;\n      } else if (p === 22) {\n        // not bold nor faint\n        attr.fg &= ~FgFlags.BOLD;\n        attr.bg &= ~BgFlags.DIM;\n      } else if (p === 23) {\n        // not italic\n        attr.bg &= ~BgFlags.ITALIC;\n      } else if (p === 24) {\n        // not underlined\n        attr.fg &= ~FgFlags.UNDERLINE;\n      } else if (p === 25) {\n        // not blink\n        attr.fg &= ~FgFlags.BLINK;\n      } else if (p === 27) {\n        // not inverse\n        attr.fg &= ~FgFlags.INVERSE;\n      } else if (p === 28) {\n        // not invisible\n        attr.fg &= ~FgFlags.INVISIBLE;\n      } else if (p === 39) {\n        // reset fg\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.fg |= DEFAULT_ATTR_DATA.fg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n      } else if (p === 49) {\n        // reset bg\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.bg |= DEFAULT_ATTR_DATA.bg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n      } else if (p === 38) {\n        // fg color 256\n        if (params[i + 1] === 2) {\n          i += 2;\n          attr.fg |= Attributes.CM_RGB;\n          attr.fg &= ~Attributes.RGB_MASK;\n          attr.fg |= AttributeData.fromColorRGB([params[i], params[i + 1], params[i + 2]]);\n          i += 2;\n        } else if (params[i + 1] === 5) {\n          i += 2;\n          p = params[i] & 0xff;\n          attr.fg &= ~Attributes.PCOLOR_MASK;\n          attr.fg |= Attributes.CM_P256 | p;\n        }\n      } else if (p === 48) {\n        // bg color 256\n        if (params[i + 1] === 2) {\n          i += 2;\n          attr.bg |= Attributes.CM_RGB;\n          attr.bg &= ~Attributes.RGB_MASK;\n          attr.bg |= AttributeData.fromColorRGB([params[i], params[i + 1], params[i + 2]]);\n          i += 2;\n        } else if (params[i + 1] === 5) {\n          i += 2;\n          p = params[i] & 0xff;\n          attr.bg &= ~Attributes.PCOLOR_MASK;\n          attr.bg |= Attributes.CM_P256 | p;\n        }\n      } else if (p === 100) {\n        // reset fg/bg\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.fg |= DEFAULT_ATTR_DATA.fg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.bg |= DEFAULT_ATTR_DATA.bg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n      } else {\n        this._terminal.error('Unknown SGR attribute: %d.', p);\n      }\n    }\n  }\n\n  /**\n   * CSI Ps n  Device Status Report (DSR).\n   *     Ps = 5  -> Status Report.  Result (``OK'') is\n   *   CSI 0 n\n   *     Ps = 6  -> Report Cursor Position (CPR) [row;column].\n   *   Result is\n   *   CSI r ; c R\n   * CSI ? Ps n\n   *   Device Status Report (DSR, DEC-specific).\n   *     Ps = 6  -> Report Cursor Position (CPR) [row;column] as CSI\n   *     ? r ; c R (assumes page is zero).\n   *     Ps = 1 5  -> Report Printer status as CSI ? 1 0  n  (ready).\n   *     or CSI ? 1 1  n  (not ready).\n   *     Ps = 2 5  -> Report UDK status as CSI ? 2 0  n  (unlocked)\n   *     or CSI ? 2 1  n  (locked).\n   *     Ps = 2 6  -> Report Keyboard status as\n   *   CSI ? 2 7  ;  1  ;  0  ;  0  n  (North American).\n   *   The last two parameters apply to VT400 & up, and denote key-\n   *   board ready and LK01 respectively.\n   *     Ps = 5 3  -> Report Locator status as\n   *   CSI ? 5 3  n  Locator available, if compiled-in, or\n   *   CSI ? 5 0  n  No Locator, if not.\n   */\n  public deviceStatus(params: number[], collect?: string): void {\n    if (!collect) {\n      switch (params[0]) {\n        case 5:\n          // status report\n          this._onData.fire(`${C0.ESC}[0n`);\n          break;\n        case 6:\n          // cursor position\n          const y = this._terminal.buffer.y + 1;\n          const x = this._terminal.buffer.x + 1;\n          this._onData.fire(`${C0.ESC}[${y};${x}R`);\n          break;\n      }\n    } else if (collect === '?') {\n      // modern xterm doesnt seem to\n      // respond to any of these except ?6, 6, and 5\n      switch (params[0]) {\n        case 6:\n          // cursor position\n          const y = this._terminal.buffer.y + 1;\n          const x = this._terminal.buffer.x + 1;\n          this._onData.fire(`${C0.ESC}[?${y};${x}R`);\n          break;\n        case 15:\n          // no printer\n          // this.handler(C0.ESC + '[?11n');\n          break;\n        case 25:\n          // dont support user defined keys\n          // this.handler(C0.ESC + '[?21n');\n          break;\n        case 26:\n          // north american keyboard\n          // this.handler(C0.ESC + '[?27;1;0;0n');\n          break;\n        case 53:\n          // no dec locator/mouse\n          // this.handler(C0.ESC + '[?50n');\n          break;\n      }\n    }\n  }\n\n  /**\n   * CSI ! p   Soft terminal reset (DECSTR).\n   * http://vt100.net/docs/vt220-rm/table4-10.html\n   */\n  public softReset(params: number[], collect?: string): void {\n    if (collect === '!') {\n      this._terminal.cursorHidden = false;\n      this._terminal.insertMode = false;\n      this._terminal.originMode = false;\n      this._terminal.wraparoundMode = true;  // defaults: xterm - true, vt100 - false\n      this._terminal.applicationKeypad = false; // ?\n      if (this._terminal.viewport) {\n        this._terminal.viewport.syncScrollArea();\n      }\n      this._terminal.applicationCursor = false;\n      this._terminal.buffer.scrollTop = 0;\n      this._terminal.buffer.scrollBottom = this._terminal.rows - 1;\n      this._terminal.curAttrData = DEFAULT_ATTR_DATA;\n      this._terminal.buffer.x = this._terminal.buffer.y = 0; // ?\n      this._terminal.charset = null;\n      this._terminal.glevel = 0; // ??\n      this._terminal.charsets = [null]; // ??\n    }\n  }\n\n  /**\n   * CSI Ps SP q  Set cursor style (DECSCUSR, VT520).\n   *   Ps = 0  -> blinking block.\n   *   Ps = 1  -> blinking block (default).\n   *   Ps = 2  -> steady block.\n   *   Ps = 3  -> blinking underline.\n   *   Ps = 4  -> steady underline.\n   *   Ps = 5  -> blinking bar (xterm).\n   *   Ps = 6  -> steady bar (xterm).\n   */\n  public setCursorStyle(params?: number[], collect?: string): void {\n    if (collect === ' ') {\n      const param = params[0] < 1 ? 1 : params[0];\n      switch (param) {\n        case 1:\n        case 2:\n          this._terminal.setOption('cursorStyle', 'block');\n          break;\n        case 3:\n        case 4:\n          this._terminal.setOption('cursorStyle', 'underline');\n          break;\n        case 5:\n        case 6:\n          this._terminal.setOption('cursorStyle', 'bar');\n          break;\n      }\n      const isBlinking = param % 2 === 1;\n      this._terminal.setOption('cursorBlink', isBlinking);\n    }\n  }\n\n  /**\n   * CSI Ps ; Ps r\n   *   Set Scrolling Region [top;bottom] (default = full size of win-\n   *   dow) (DECSTBM).\n   * CSI ? Pm r\n   */\n  public setScrollRegion(params: number[], collect?: string): void {\n    if (collect) {\n      return;\n    }\n    this._terminal.buffer.scrollTop = (params[0] || 1) - 1;\n    this._terminal.buffer.scrollBottom = (params[1] && params[1] <= this._terminal.rows ? params[1] : this._terminal.rows) - 1;\n    this._terminal.buffer.x = 0;\n    this._terminal.buffer.y = 0;\n  }\n\n\n  /**\n   * CSI s\n   * ESC 7\n   *   Save cursor (ANSI.SYS).\n   */\n  public saveCursor(params: number[]): void {\n    this._terminal.buffer.savedX = this._terminal.buffer.x;\n    this._terminal.buffer.savedY = this._terminal.buffer.y;\n    this._terminal.buffer.savedCurAttrData.fg = this._terminal.curAttrData.fg;\n    this._terminal.buffer.savedCurAttrData.bg = this._terminal.curAttrData.bg;\n  }\n\n\n  /**\n   * CSI u\n   * ESC 8\n   *   Restore cursor (ANSI.SYS).\n   */\n  public restoreCursor(params: number[]): void {\n    this._terminal.buffer.x = this._terminal.buffer.savedX || 0;\n    this._terminal.buffer.y = this._terminal.buffer.savedY || 0;\n    this._terminal.curAttrData.fg = this._terminal.buffer.savedCurAttrData.fg;\n    this._terminal.curAttrData.bg = this._terminal.buffer.savedCurAttrData.bg;\n  }\n\n\n  /**\n   * OSC 0; <data> ST (set icon name + window title)\n   * OSC 2; <data> ST (set window title)\n   *   Proxy to set window title. Icon name is not supported.\n   */\n  public setTitle(data: string): void {\n    this._terminal.handleTitle(data);\n  }\n\n  /**\n   * ESC E\n   * C1.NEL\n   *   DEC mnemonic: NEL (https://vt100.net/docs/vt510-rm/NEL)\n   *   Moves cursor to first position on next line.\n   */\n  public nextLine(): void {\n    this._terminal.buffer.x = 0;\n    this.index();\n  }\n\n  /**\n   * ESC =\n   *   DEC mnemonic: DECKPAM (https://vt100.net/docs/vt510-rm/DECKPAM.html)\n   *   Enables the numeric keypad to send application sequences to the host.\n   */\n  public keypadApplicationMode(): void {\n    this._terminal.log('Serial port requested application keypad.');\n    this._terminal.applicationKeypad = true;\n    if (this._terminal.viewport) {\n      this._terminal.viewport.syncScrollArea();\n    }\n  }\n\n  /**\n   * ESC >\n   *   DEC mnemonic: DECKPNM (https://vt100.net/docs/vt510-rm/DECKPNM.html)\n   *   Enables the keypad to send numeric characters to the host.\n   */\n  public keypadNumericMode(): void {\n    this._terminal.log('Switching back to normal keypad.');\n    this._terminal.applicationKeypad = false;\n    if (this._terminal.viewport) {\n      this._terminal.viewport.syncScrollArea();\n    }\n  }\n\n  /**\n   * ESC % @\n   * ESC % G\n   *   Select default character set. UTF-8 is not supported (string are unicode anyways)\n   *   therefore ESC % G does the same.\n   */\n  public selectDefaultCharset(): void {\n    this._terminal.setgLevel(0);\n    this._terminal.setgCharset(0, DEFAULT_CHARSET); // US (default)\n  }\n\n  /**\n   * ESC ( C\n   *   Designate G0 Character Set, VT100, ISO 2022.\n   * ESC ) C\n   *   Designate G1 Character Set (ISO 2022, VT100).\n   * ESC * C\n   *   Designate G2 Character Set (ISO 2022, VT220).\n   * ESC + C\n   *   Designate G3 Character Set (ISO 2022, VT220).\n   * ESC - C\n   *   Designate G1 Character Set (VT300).\n   * ESC . C\n   *   Designate G2 Character Set (VT300).\n   * ESC / C\n   *   Designate G3 Character Set (VT300). C = A  -> ISO Latin-1 Supplemental. - Supported?\n   */\n  public selectCharset(collectAndFlag: string): void {\n    if (collectAndFlag.length !== 2) {\n      this.selectDefaultCharset();\n      return;\n    }\n    if (collectAndFlag[0] === '/') {\n      return;  // TODO: Is this supported?\n    }\n    this._terminal.setgCharset(GLEVEL[collectAndFlag[0]], CHARSETS[collectAndFlag[1]] || DEFAULT_CHARSET);\n    return;\n  }\n\n  /**\n   * ESC D\n   * C1.IND\n   *   DEC mnemonic: IND (https://vt100.net/docs/vt510-rm/IND.html)\n   *   Moves the cursor down one line in the same column.\n   */\n  public index(): void {\n    this._terminal.index();  // TODO: save to move from terminal?\n  }\n\n  /**\n   * ESC H\n   * C1.HTS\n   *   DEC mnemonic: HTS (https://vt100.net/docs/vt510-rm/HTS.html)\n   *   Sets a horizontal tab stop at the column position indicated by\n   *   the value of the active column when the terminal receives an HTS.\n   */\n  public tabSet(): void {\n    this._terminal.tabSet();  // TODO: save to move from terminal?\n  }\n\n  /**\n   * ESC M\n   * C1.RI\n   *   DEC mnemonic: HTS\n   *   Moves the cursor up one line in the same column. If the cursor is at the top margin,\n   *   the page scrolls down.\n   */\n  public reverseIndex(): void {\n    this._terminal.reverseIndex();  // TODO: save to move from terminal?\n  }\n\n  /**\n   * ESC c\n   *   DEC mnemonic: RIS (https://vt100.net/docs/vt510-rm/RIS.html)\n   *   Reset to initial state.\n   */\n  public reset(): void {\n    this._parser.reset();\n    this._terminal.reset();  // TODO: save to move from terminal?\n  }\n\n  /**\n   * ESC n\n   * ESC o\n   * ESC |\n   * ESC }\n   * ESC ~\n   *   DEC mnemonic: LS (https://vt100.net/docs/vt510-rm/LS.html)\n   *   When you use a locking shift, the character set remains in GL or GR until\n   *   you use another locking shift. (partly supported)\n   */\n  public setgLevel(level: number): void {\n    this._terminal.setgLevel(level);  // TODO: save to move from terminal?\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ParserState, ParserAction, IParsingState, IDcsHandler, IEscapeSequenceParser } from './Types';\nimport { IDisposable } from 'xterm';\nimport { Disposable } from './common/Lifecycle';\nimport { utf32ToString } from './core/input/TextDecoder';\n\ninterface IHandlerCollection<T> {\n  [key: string]: T[];\n}\n\ntype CsiHandler = (params: number[], collect: string) => boolean | void;\ntype OscHandler = (data: string) => boolean | void;\n\n/**\n * Returns an array filled with numbers between the low and high parameters (right exclusive).\n * @param low The low number.\n * @param high The high number.\n */\nfunction r(low: number, high: number): number[] {\n  let c = high - low;\n  const arr = new Array(c);\n  while (c--) {\n    arr[c] = --high;\n  }\n  return arr;\n}\n\n/**\n * Transition table for EscapeSequenceParser.\n * NOTE: data in the underlying table is packed like this:\n *   currentState << 8 | characterCode  -->  action << 4 | nextState\n */\nexport class TransitionTable {\n  public table: Uint8Array | number[];\n\n  constructor(length: number) {\n    this.table = (typeof Uint8Array === 'undefined')\n      ? new Array(length)\n      : new Uint8Array(length);\n  }\n\n  /**\n   * Add a transition to the transition table.\n   * @param code input character code\n   * @param state current parser state\n   * @param action parser action to be done\n   * @param next next parser state\n   */\n  add(code: number, state: number, action: number | null, next: number | null): void {\n    this.table[state << 8 | code] = ((action | 0) << 4) | ((next === undefined) ? state : next);\n  }\n\n  /**\n   * Add transitions for multiple input character codes.\n   * @param codes input character code array\n   * @param state current parser state\n   * @param action parser action to be done\n   * @param next next parser state\n   */\n  addMany(codes: number[], state: number, action: number | null, next: number | null): void {\n    for (let i = 0; i < codes.length; i++) {\n      this.add(codes[i], state, action, next);\n    }\n  }\n}\n\n\n/**\n * Default definitions for the VT500_TRANSITION_TABLE.\n */\nconst PRINTABLES = r(0x20, 0x7f);\nconst EXECUTABLES = r(0x00, 0x18);\nEXECUTABLES.push(0x19);\nEXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));\n// Pseudo-character placeholder for printable non-ascii characters.\nconst NON_ASCII_PRINTABLE = 0xA0;\n\n/**\n * VT500 compatible transition table.\n * Taken from https://vt100.net/emu/dec_ansi_parser.\n */\nexport const VT500_TRANSITION_TABLE = (function (): TransitionTable {\n  const table: TransitionTable = new TransitionTable(4095);\n\n  const states: number[] = r(ParserState.GROUND, ParserState.DCS_PASSTHROUGH + 1);\n  let state: any;\n\n  // table with default transition\n  for (state in states) {\n    // NOTE: table lookup is capped at 0xa0 in parse to keep the table small\n    for (let code = 0; code <= NON_ASCII_PRINTABLE; ++code) {\n      table.add(code, state, ParserAction.ERROR, ParserState.GROUND);\n    }\n  }\n  // printables\n  table.addMany(PRINTABLES, ParserState.GROUND, ParserAction.PRINT, ParserState.GROUND);\n  // global anywhere rules\n  for (state in states) {\n    table.addMany([0x18, 0x1a, 0x99, 0x9a], state, ParserAction.EXECUTE, ParserState.GROUND);\n    table.addMany(r(0x80, 0x90), state, ParserAction.EXECUTE, ParserState.GROUND);\n    table.addMany(r(0x90, 0x98), state, ParserAction.EXECUTE, ParserState.GROUND);\n    table.add(0x9c, state, ParserAction.IGNORE, ParserState.GROUND); // ST as terminator\n    table.add(0x1b, state, ParserAction.CLEAR, ParserState.ESCAPE);  // ESC\n    table.add(0x9d, state, ParserAction.OSC_START, ParserState.OSC_STRING);  // OSC\n    table.addMany([0x98, 0x9e, 0x9f], state, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n    table.add(0x9b, state, ParserAction.CLEAR, ParserState.CSI_ENTRY);  // CSI\n    table.add(0x90, state, ParserAction.CLEAR, ParserState.DCS_ENTRY);  // DCS\n  }\n  // rules for executables and 7f\n  table.addMany(EXECUTABLES, ParserState.GROUND, ParserAction.EXECUTE, ParserState.GROUND);\n  table.addMany(EXECUTABLES, ParserState.ESCAPE, ParserAction.EXECUTE, ParserState.ESCAPE);\n  table.add(0x7f, ParserState.ESCAPE, ParserAction.IGNORE, ParserState.ESCAPE);\n  table.addMany(EXECUTABLES, ParserState.OSC_STRING, ParserAction.IGNORE, ParserState.OSC_STRING);\n  table.addMany(EXECUTABLES, ParserState.CSI_ENTRY, ParserAction.EXECUTE, ParserState.CSI_ENTRY);\n  table.add(0x7f, ParserState.CSI_ENTRY, ParserAction.IGNORE, ParserState.CSI_ENTRY);\n  table.addMany(EXECUTABLES, ParserState.CSI_PARAM, ParserAction.EXECUTE, ParserState.CSI_PARAM);\n  table.add(0x7f, ParserState.CSI_PARAM, ParserAction.IGNORE, ParserState.CSI_PARAM);\n  table.addMany(EXECUTABLES, ParserState.CSI_IGNORE, ParserAction.EXECUTE, ParserState.CSI_IGNORE);\n  table.addMany(EXECUTABLES, ParserState.CSI_INTERMEDIATE, ParserAction.EXECUTE, ParserState.CSI_INTERMEDIATE);\n  table.add(0x7f, ParserState.CSI_INTERMEDIATE, ParserAction.IGNORE, ParserState.CSI_INTERMEDIATE);\n  table.addMany(EXECUTABLES, ParserState.ESCAPE_INTERMEDIATE, ParserAction.EXECUTE, ParserState.ESCAPE_INTERMEDIATE);\n  table.add(0x7f, ParserState.ESCAPE_INTERMEDIATE, ParserAction.IGNORE, ParserState.ESCAPE_INTERMEDIATE);\n  // osc\n  table.add(0x5d, ParserState.ESCAPE, ParserAction.OSC_START, ParserState.OSC_STRING);\n  table.addMany(PRINTABLES, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);\n  table.add(0x7f, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);\n  table.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], ParserState.OSC_STRING, ParserAction.OSC_END, ParserState.GROUND);\n  table.addMany(r(0x1c, 0x20), ParserState.OSC_STRING, ParserAction.IGNORE, ParserState.OSC_STRING);\n  // sos/pm/apc does nothing\n  table.addMany([0x58, 0x5e, 0x5f], ParserState.ESCAPE, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  table.addMany(PRINTABLES, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  table.addMany(EXECUTABLES, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  table.add(0x9c, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.GROUND);\n  table.add(0x7f, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  // csi entries\n  table.add(0x5b, ParserState.ESCAPE, ParserAction.CLEAR, ParserState.CSI_ENTRY);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_ENTRY, ParserAction.CSI_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x30, 0x3a), ParserState.CSI_ENTRY, ParserAction.PARAM, ParserState.CSI_PARAM);\n  table.add(0x3b, ParserState.CSI_ENTRY, ParserAction.PARAM, ParserState.CSI_PARAM);\n  table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.CSI_ENTRY, ParserAction.COLLECT, ParserState.CSI_PARAM);\n  table.addMany(r(0x30, 0x3a), ParserState.CSI_PARAM, ParserAction.PARAM, ParserState.CSI_PARAM);\n  table.add(0x3b, ParserState.CSI_PARAM, ParserAction.PARAM, ParserState.CSI_PARAM);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_PARAM, ParserAction.CSI_DISPATCH, ParserState.GROUND);\n  table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], ParserState.CSI_PARAM, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x20, 0x40), ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.add(0x7f, ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.GROUND);\n  table.add(0x3a, ParserState.CSI_ENTRY, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x20, 0x30), ParserState.CSI_ENTRY, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);\n  table.addMany(r(0x20, 0x30), ParserState.CSI_INTERMEDIATE, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);\n  table.addMany(r(0x30, 0x40), ParserState.CSI_INTERMEDIATE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_INTERMEDIATE, ParserAction.CSI_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x20, 0x30), ParserState.CSI_PARAM, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);\n  // esc_intermediate\n  table.addMany(r(0x20, 0x30), ParserState.ESCAPE, ParserAction.COLLECT, ParserState.ESCAPE_INTERMEDIATE);\n  table.addMany(r(0x20, 0x30), ParserState.ESCAPE_INTERMEDIATE, ParserAction.COLLECT, ParserState.ESCAPE_INTERMEDIATE);\n  table.addMany(r(0x30, 0x7f), ParserState.ESCAPE_INTERMEDIATE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x30, 0x50), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x51, 0x58), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany([0x59, 0x5a, 0x5c], ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x60, 0x7f), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  // dcs entry\n  table.add(0x50, ParserState.ESCAPE, ParserAction.CLEAR, ParserState.DCS_ENTRY);\n  table.addMany(EXECUTABLES, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);\n  table.add(0x7f, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);\n  table.addMany(r(0x20, 0x30), ParserState.DCS_ENTRY, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);\n  table.add(0x3a, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x30, 0x3a), ParserState.DCS_ENTRY, ParserAction.PARAM, ParserState.DCS_PARAM);\n  table.add(0x3b, ParserState.DCS_ENTRY, ParserAction.PARAM, ParserState.DCS_PARAM);\n  table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.DCS_ENTRY, ParserAction.COLLECT, ParserState.DCS_PARAM);\n  table.addMany(EXECUTABLES, ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x20, 0x80), ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(EXECUTABLES, ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);\n  table.add(0x7f, ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);\n  table.addMany(r(0x30, 0x3a), ParserState.DCS_PARAM, ParserAction.PARAM, ParserState.DCS_PARAM);\n  table.add(0x3b, ParserState.DCS_PARAM, ParserAction.PARAM, ParserState.DCS_PARAM);\n  table.addMany([0x3a, 0x3c, 0x3d, 0x3e, 0x3f], ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x20, 0x30), ParserState.DCS_PARAM, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);\n  table.addMany(EXECUTABLES, ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);\n  table.add(0x7f, ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x20, 0x30), ParserState.DCS_INTERMEDIATE, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x30, 0x40), ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x40, 0x7f), ParserState.DCS_INTERMEDIATE, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);\n  table.addMany(r(0x40, 0x7f), ParserState.DCS_PARAM, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);\n  table.addMany(r(0x40, 0x7f), ParserState.DCS_ENTRY, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);\n  table.addMany(EXECUTABLES, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);\n  table.addMany(PRINTABLES, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);\n  table.add(0x7f, ParserState.DCS_PASSTHROUGH, ParserAction.IGNORE, ParserState.DCS_PASSTHROUGH);\n  table.addMany([0x1b, 0x9c], ParserState.DCS_PASSTHROUGH, ParserAction.DCS_UNHOOK, ParserState.GROUND);\n  table.add(NON_ASCII_PRINTABLE, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);\n  return table;\n})();\n\n/**\n * Dummy DCS handler as default fallback.\n */\nclass DcsDummy implements IDcsHandler {\n  hook(collect: string, params: number[], flag: number): void { }\n  put(data: Uint32Array, start: number, end: number): void { }\n  unhook(): void { }\n}\n\n/**\n * EscapeSequenceParser.\n * This class implements the ANSI/DEC compatible parser described by\n * Paul Williams (https://vt100.net/emu/dec_ansi_parser).\n * To implement custom ANSI compliant escape sequences it is not needed to\n * alter this parser, instead consider registering a custom handler.\n * For non ANSI compliant sequences change the transition table with\n * the optional `transitions` contructor argument and\n * reimplement the `parse` method.\n * NOTE: The parameter element notation is currently not supported.\n * TODO: implement error recovery hook via error handler return values\n */\nexport class EscapeSequenceParser extends Disposable implements IEscapeSequenceParser {\n  public initialState: number;\n  public currentState: number;\n\n  // buffers over several parse calls\n  protected _osc: string;\n  protected _params: number[];\n  protected _collect: string;\n\n  // handler lookup containers\n  protected _printHandler: (data: Uint32Array, start: number, end: number) => void;\n  protected _executeHandlers: any;\n  protected _csiHandlers: IHandlerCollection<CsiHandler>;\n  protected _escHandlers: any;\n  protected _oscHandlers: IHandlerCollection<OscHandler>;\n  protected _dcsHandlers: any;\n  protected _activeDcsHandler: IDcsHandler | null;\n  protected _errorHandler: (state: IParsingState) => IParsingState;\n\n  // fallback handlers\n  protected _printHandlerFb: (data: Uint32Array, start: number, end: number) => void;\n  protected _executeHandlerFb: (code: number) => void;\n  protected _csiHandlerFb: (collect: string, params: number[], flag: number) => void;\n  protected _escHandlerFb: (collect: string, flag: number) => void;\n  protected _oscHandlerFb: (identifier: number, data: string) => void;\n  protected _dcsHandlerFb: IDcsHandler;\n  protected _errorHandlerFb: (state: IParsingState) => IParsingState;\n\n  constructor(readonly TRANSITIONS: TransitionTable = VT500_TRANSITION_TABLE) {\n    super();\n\n    this.initialState = ParserState.GROUND;\n    this.currentState = this.initialState;\n    this._osc = '';\n    this._params = [0];\n    this._collect = '';\n\n    // set default fallback handlers and handler lookup containers\n    this._printHandlerFb = (data, start, end): void => { };\n    this._executeHandlerFb = (code: number): void => { };\n    this._csiHandlerFb = (collect: string, params: number[], flag: number): void => { };\n    this._escHandlerFb = (collect: string, flag: number): void => { };\n    this._oscHandlerFb = (identifier: number, data: string): void => { };\n    this._dcsHandlerFb = new DcsDummy();\n    this._errorHandlerFb = (state: IParsingState): IParsingState => state;\n    this._printHandler = this._printHandlerFb;\n    this._executeHandlers = Object.create(null);\n    this._csiHandlers = Object.create(null);\n    this._escHandlers = Object.create(null);\n    this._oscHandlers = Object.create(null);\n    this._dcsHandlers = Object.create(null);\n    this._activeDcsHandler = null;\n    this._errorHandler = this._errorHandlerFb;\n\n    // swallow 7bit ST (ESC+\\)\n    this.setEscHandler('\\\\', () => {});\n  }\n\n  public dispose(): void {\n    this._printHandlerFb = null;\n    this._executeHandlerFb = null;\n    this._csiHandlerFb = null;\n    this._escHandlerFb = null;\n    this._oscHandlerFb = null;\n    this._dcsHandlerFb = null;\n    this._errorHandlerFb = null;\n    this._printHandler = null;\n    this._executeHandlers = null;\n    this._escHandlers = null;\n    this._csiHandlers = null;\n    this._oscHandlers = null;\n    this._dcsHandlers = null;\n    this._activeDcsHandler = null;\n    this._errorHandler = null;\n  }\n\n  setPrintHandler(callback: (data: Uint32Array, start: number, end: number) => void): void {\n    this._printHandler = callback;\n  }\n  clearPrintHandler(): void {\n    this._printHandler = this._printHandlerFb;\n  }\n\n  setExecuteHandler(flag: string, callback: () => void): void {\n    this._executeHandlers[flag.charCodeAt(0)] = callback;\n  }\n  clearExecuteHandler(flag: string): void {\n    if (this._executeHandlers[flag.charCodeAt(0)]) delete this._executeHandlers[flag.charCodeAt(0)];\n  }\n  setExecuteHandlerFallback(callback: (code: number) => void): void {\n    this._executeHandlerFb = callback;\n  }\n\n  addCsiHandler(flag: string, callback: CsiHandler): IDisposable {\n    const index = flag.charCodeAt(0);\n    if (this._csiHandlers[index] === undefined) {\n      this._csiHandlers[index] = [];\n    }\n    const handlerList = this._csiHandlers[index];\n    handlerList.push(callback);\n    return {\n      dispose: () => {\n        const handlerIndex = handlerList.indexOf(callback);\n        if (handlerIndex !== -1) {\n          handlerList.splice(handlerIndex, 1);\n        }\n      }\n    };\n  }\n  setCsiHandler(flag: string, callback: (params: number[], collect: string) => void): void {\n    this._csiHandlers[flag.charCodeAt(0)] = [callback];\n  }\n  clearCsiHandler(flag: string): void {\n    if (this._csiHandlers[flag.charCodeAt(0)]) delete this._csiHandlers[flag.charCodeAt(0)];\n  }\n  setCsiHandlerFallback(callback: (collect: string, params: number[], flag: number) => void): void {\n    this._csiHandlerFb = callback;\n  }\n\n  setEscHandler(collectAndFlag: string, callback: () => void): void {\n    this._escHandlers[collectAndFlag] = callback;\n  }\n  clearEscHandler(collectAndFlag: string): void {\n    if (this._escHandlers[collectAndFlag]) delete this._escHandlers[collectAndFlag];\n  }\n  setEscHandlerFallback(callback: (collect: string, flag: number) => void): void {\n    this._escHandlerFb = callback;\n  }\n\n  addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    if (this._oscHandlers[ident] === undefined) {\n      this._oscHandlers[ident] = [];\n    }\n    const handlerList = this._oscHandlers[ident];\n    handlerList.push(callback);\n    return {\n      dispose: () => {\n        const handlerIndex = handlerList.indexOf(callback);\n        if (handlerIndex !== -1) {\n          handlerList.splice(handlerIndex, 1);\n        }\n      }\n    };\n  }\n  setOscHandler(ident: number, callback: (data: string) => void): void {\n    this._oscHandlers[ident] = [callback];\n  }\n  clearOscHandler(ident: number): void {\n    if (this._oscHandlers[ident]) delete this._oscHandlers[ident];\n  }\n  setOscHandlerFallback(callback: (identifier: number, data: string) => void): void {\n    this._oscHandlerFb = callback;\n  }\n\n  setDcsHandler(collectAndFlag: string, handler: IDcsHandler): void {\n    this._dcsHandlers[collectAndFlag] = handler;\n  }\n  clearDcsHandler(collectAndFlag: string): void {\n    if (this._dcsHandlers[collectAndFlag]) delete this._dcsHandlers[collectAndFlag];\n  }\n  setDcsHandlerFallback(handler: IDcsHandler): void {\n    this._dcsHandlerFb = handler;\n  }\n\n  setErrorHandler(callback: (state: IParsingState) => IParsingState): void {\n    this._errorHandler = callback;\n  }\n  clearErrorHandler(): void {\n    this._errorHandler = this._errorHandlerFb;\n  }\n\n  reset(): void {\n    this.currentState = this.initialState;\n    this._osc = '';\n    this._params = [0];\n    this._collect = '';\n    this._activeDcsHandler = null;\n  }\n\n  parse(data: Uint32Array, length: number): void {\n    let code = 0;\n    let transition = 0;\n    let error = false;\n    let currentState = this.currentState;\n    let print = -1;\n    let dcs = -1;\n    let osc = this._osc;\n    let collect = this._collect;\n    let params = this._params;\n    const table: Uint8Array | number[] = this.TRANSITIONS.table;\n    let dcsHandler: IDcsHandler | null = this._activeDcsHandler;\n    let callback: Function | null = null;\n\n    // process input string\n    for (let i = 0; i < length; ++i) {\n      code = data[i];\n\n      // shortcut for most chars (print action)\n      if (currentState === ParserState.GROUND && code > 0x1f && code < 0x80) {\n        print = (~print) ? print : i;\n        do i++;\n        while (i < length && data[i] > 0x1f && data[i] < 0x80);\n        i--;\n        continue;\n      }\n\n      // shortcut for CSI params\n      if (currentState === ParserState.CSI_PARAM && (code > 0x2f && code < 0x39)) {\n        params[params.length - 1] = params[params.length - 1] * 10 + code - 48;\n        continue;\n      }\n\n      // normal transition & action lookup\n      transition = table[currentState << 8 | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)];\n      switch (transition >> 4) {\n        case ParserAction.PRINT:\n          print = (~print) ? print : i;\n          break;\n        case ParserAction.EXECUTE:\n          if (~print) {\n            this._printHandler(data, print, i);\n            print = -1;\n          }\n          callback = this._executeHandlers[code];\n          if (callback) callback();\n          else this._executeHandlerFb(code);\n          break;\n        case ParserAction.IGNORE:\n          // handle leftover print or dcs chars\n          if (~print) {\n            this._printHandler(data, print, i);\n            print = -1;\n          } else if (~dcs) {\n            dcsHandler.put(data, dcs, i);\n            dcs = -1;\n          }\n          break;\n        case ParserAction.ERROR:\n          // chars higher than 0x9f are handled by this action\n          // to keep the transition table small\n          if (code > 0x9f) {\n            switch (currentState) {\n              case ParserState.GROUND:\n                print = (~print) ? print : i;\n                break;\n              case ParserState.CSI_IGNORE:\n                transition |= ParserState.CSI_IGNORE;\n                break;\n              case ParserState.DCS_IGNORE:\n                transition |= ParserState.DCS_IGNORE;\n                break;\n              case ParserState.DCS_PASSTHROUGH:\n                dcs = (~dcs) ? dcs : i;\n                transition |= ParserState.DCS_PASSTHROUGH;\n                break;\n              default:\n                error = true;\n            }\n          } else {\n            error = true;\n          }\n          // if we end up here a real error happened\n          if (error) {\n            const inject: IParsingState = this._errorHandler(\n              {\n                position: i,\n                code,\n                currentState,\n                print,\n                dcs,\n                osc,\n                collect,\n                params,\n                abort: false\n              });\n            if (inject.abort) return;\n          // TODO: inject return values\n            error = false;\n          }\n          break;\n        case ParserAction.CSI_DISPATCH:\n          // Trigger CSI Handler\n          const handlers = this._csiHandlers[code];\n          let j = handlers ? handlers.length - 1 : -1;\n          for (; j >= 0; j--) {\n            // undefined or true means success and to stop bubbling\n            if (handlers[j](params, collect) !== false) {\n              break;\n            }\n          }\n          if (j < 0) {\n            this._csiHandlerFb(collect, params, code);\n          }\n          break;\n        case ParserAction.PARAM:\n          if (code === 0x3b) params.push(0);\n          else params[params.length - 1] = params[params.length - 1] * 10 + code - 48;\n          break;\n        case ParserAction.COLLECT:\n          collect += String.fromCharCode(code);\n          break;\n        case ParserAction.ESC_DISPATCH:\n          callback = this._escHandlers[collect + String.fromCharCode(code)];\n          if (callback) callback(collect, code);\n          else this._escHandlerFb(collect, code);\n          break;\n        case ParserAction.CLEAR:\n          if (~print) {\n            this._printHandler(data, print, i);\n            print = -1;\n          }\n          osc = '';\n          params = [0];\n          collect = '';\n          dcs = -1;\n          break;\n        case ParserAction.DCS_HOOK:\n          dcsHandler = this._dcsHandlers[collect + String.fromCharCode(code)];\n          if (!dcsHandler) dcsHandler = this._dcsHandlerFb;\n          dcsHandler.hook(collect, params, code);\n          break;\n        case ParserAction.DCS_PUT:\n          dcs = (~dcs) ? dcs : i;\n          break;\n        case ParserAction.DCS_UNHOOK:\n          if (dcsHandler) {\n            if (~dcs) dcsHandler.put(data, dcs, i);\n            dcsHandler.unhook();\n            dcsHandler = null;\n          }\n          if (code === 0x1b) transition |= ParserState.ESCAPE;\n          osc = '';\n          params = [0];\n          collect = '';\n          dcs = -1;\n          break;\n        case ParserAction.OSC_START:\n          if (~print) {\n            this._printHandler(data, print, i);\n            print = -1;\n          }\n          osc = '';\n          break;\n        case ParserAction.OSC_PUT:\n          for (let j = i + 1; ; j++) {\n            if (j >= length\n                || (code = data[j]) < 0x20\n                || (code > 0x7f && code <= 0x9f)) {\n              osc += utf32ToString(data, i, j);\n              i = j - 1;\n              break;\n            }\n          }\n          break;\n        case ParserAction.OSC_END:\n          if (osc && code !== 0x18 && code !== 0x1a) {\n            // NOTE: OSC subparsing is not part of the original parser\n            // we do basic identifier parsing here to offer a jump table for OSC as well\n            const idx = osc.indexOf(';');\n            if (idx === -1) {\n              this._oscHandlerFb(-1, osc);  // this is an error (malformed OSC)\n            } else {\n              // Note: NaN is not handled here\n              // either catch it with the fallback handler\n              // or with an explicit NaN OSC handler\n              const identifier = parseInt(osc.substring(0, idx));\n              const content = osc.substring(idx + 1);\n              // Trigger OSC Handler\n              const handlers = this._oscHandlers[identifier];\n              let j = handlers ? handlers.length - 1 : -1;\n              for (; j >= 0; j--) {\n                // undefined or true means success and to stop bubbling\n                if (handlers[j](content) !== false) {\n                  break;\n                }\n              }\n              if (j < 0) {\n                this._oscHandlerFb(identifier, content);\n              }\n            }\n          }\n          if (code === 0x1b) transition |= ParserState.ESCAPE;\n          osc = '';\n          params = [0];\n          collect = '';\n          dcs = -1;\n          break;\n      }\n      currentState = transition & 15;\n    }\n\n    // push leftover pushable buffers to terminal\n    if (currentState === ParserState.GROUND && ~print) {\n      this._printHandler(data, print, length);\n    } else if (currentState === ParserState.DCS_PASSTHROUGH && ~dcs && dcsHandler) {\n      dcsHandler.put(data, dcs, length);\n    }\n\n    // save non pushable buffers\n    this._osc = osc;\n    this._collect = collect;\n    this._params = params;\n\n    // save active dcs handler reference\n    this._activeDcsHandler = dcsHandler;\n\n    // save state\n    this.currentState = currentState;\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal } from './Types';\n\ninterface IPosition {\n  start: number;\n  end: number;\n}\n\n/**\n * Encapsulates the logic for handling compositionstart, compositionupdate and compositionend\n * events, displaying the in-progress composition to the UI and forwarding the final composition\n * to the handler.\n */\nexport class CompositionHelper {\n  /**\n   * Whether input composition is currently happening, eg. via a mobile keyboard, speech input or\n   * IME. This variable determines whether the compositionText should be displayed on the UI.\n   */\n  private _isComposing: boolean;\n\n  /**\n   * The position within the input textarea's value of the current composition.\n   */\n  private _compositionPosition: IPosition;\n\n  /**\n   * Whether a composition is in the process of being sent, setting this to false will cancel any\n   * in-progress composition.\n   */\n  private _isSendingComposition: boolean;\n\n  /**\n   * Creates a new CompositionHelper.\n   * @param _textarea The textarea that xterm uses for input.\n   * @param _compositionView The element to display the in-progress composition in.\n   * @param _terminal The Terminal to forward the finished composition to.\n   */\n  constructor(\n    private _textarea: HTMLTextAreaElement,\n    private _compositionView: HTMLElement,\n    private _terminal: ITerminal\n  ) {\n    this._isComposing = false;\n    this._isSendingComposition = false;\n    this._compositionPosition = { start: null, end: null };\n  }\n\n  /**\n   * Handles the compositionstart event, activating the composition view.\n   */\n  public compositionstart(): void {\n    this._isComposing = true;\n    this._compositionPosition.start = this._textarea.value.length;\n    this._compositionView.textContent = '';\n    this._compositionView.classList.add('active');\n  }\n\n  /**\n   * Handles the compositionupdate event, updating the composition view.\n   * @param ev The event.\n   */\n  public compositionupdate(ev: CompositionEvent): void {\n    this._compositionView.textContent = ev.data;\n    this.updateCompositionElements();\n    setTimeout(() => {\n      this._compositionPosition.end = this._textarea.value.length;\n    }, 0);\n  }\n\n  /**\n   * Handles the compositionend event, hiding the composition view and sending the composition to\n   * the handler.\n   */\n  public compositionend(): void {\n    this._finalizeComposition(true);\n  }\n\n  /**\n   * Handles the keydown event, routing any necessary events to the CompositionHelper functions.\n   * @param ev The keydown event.\n   * @return Whether the Terminal should continue processing the keydown event.\n   */\n  public keydown(ev: KeyboardEvent): boolean {\n    if (this._isComposing || this._isSendingComposition) {\n      if (ev.keyCode === 229) {\n        // Continue composing if the keyCode is the \"composition character\"\n        return false;\n      } else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {\n        // Continue composing if the keyCode is a modifier key\n        return false;\n      }\n      // Finish composition immediately. This is mainly here for the case where enter is\n      // pressed and the handler needs to be triggered before the command is executed.\n      this._finalizeComposition(false);\n    }\n\n    if (ev.keyCode === 229) {\n      // If the \"composition character\" is used but gets to this point it means a non-composition\n      // character (eg. numbers and punctuation) was pressed when the IME was active.\n      this._handleAnyTextareaChanges();\n      return false;\n    }\n\n    return true;\n  }\n\n  /**\n   * Finalizes the composition, resuming regular input actions. This is called when a composition\n   * is ending.\n   * @param waitForPropagation Whether to wait for events to propagate before sending\n   *   the input. This should be false if a non-composition keystroke is entered before the\n   *   compositionend event is triggered, such as enter, so that the composition is sent before\n   *   the command is executed.\n   */\n  private _finalizeComposition(waitForPropagation: boolean): void {\n    this._compositionView.classList.remove('active');\n    this._isComposing = false;\n    this._clearTextareaPosition();\n\n    if (!waitForPropagation) {\n      // Cancel any delayed composition send requests and send the input immediately.\n      this._isSendingComposition = false;\n      const input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);\n      this._terminal.handler(input);\n    } else {\n      // Make a deep copy of the composition position here as a new compositionstart event may\n      // fire before the setTimeout executes.\n      const currentCompositionPosition = {\n        start: this._compositionPosition.start,\n        end: this._compositionPosition.end\n      };\n\n      // Since composition* events happen before the changes take place in the textarea on most\n      // browsers, use a setTimeout with 0ms time to allow the native compositionend event to\n      // complete. This ensures the correct character is retrieved.\n      // This solution was used because:\n      // - The compositionend event's data property is unreliable, at least on Chromium\n      // - The last compositionupdate event's data property does not always accurately describe\n      //   the character, a counter example being Korean where an ending consonsant can move to\n      //   the following character if the following input is a vowel.\n      this._isSendingComposition = true;\n      setTimeout(() => {\n        // Ensure that the input has not already been sent\n        if (this._isSendingComposition) {\n          this._isSendingComposition = false;\n          let input;\n          if (this._isComposing) {\n            // Use the end position to get the string if a new composition has started.\n            input = this._textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);\n          } else {\n            // Don't use the end position here in order to pick up any characters after the\n            // composition has finished, for example when typing a non-composition character\n            // (eg. 2) after a composition character.\n            input = this._textarea.value.substring(currentCompositionPosition.start);\n          }\n          this._terminal.handler(input);\n        }\n      }, 0);\n    }\n  }\n\n  /**\n   * Apply any changes made to the textarea after the current event chain is allowed to complete.\n   * This should be called when not currently composing but a keydown event with the \"composition\n   * character\" (229) is triggered, in order to allow non-composition text to be entered when an\n   * IME is active.\n   */\n  private _handleAnyTextareaChanges(): void {\n    const oldValue = this._textarea.value;\n    setTimeout(() => {\n      // Ignore if a composition has started since the timeout\n      if (!this._isComposing) {\n        const newValue = this._textarea.value;\n        const diff = newValue.replace(oldValue, '');\n        if (diff.length > 0) {\n          this._terminal.handler(diff);\n        }\n      }\n    }, 0);\n  }\n\n  /**\n   * Positions the composition view on top of the cursor and the textarea just below it (so the\n   * IME helper dialog is positioned correctly).\n   * @param dontRecurse Whether to use setTimeout to recursively trigger another update, this is\n   *   necessary as the IME events across browsers are not consistently triggered.\n   */\n  public updateCompositionElements(dontRecurse?: boolean): void {\n    if (!this._isComposing) {\n      return;\n    }\n\n    if (this._terminal.buffer.isCursorInViewport) {\n      const cellHeight = Math.ceil(this._terminal.charMeasure.height * this._terminal.options.lineHeight);\n      const cursorTop = this._terminal.buffer.y * cellHeight;\n      const cursorLeft = this._terminal.buffer.x * this._terminal.charMeasure.width;\n\n      this._compositionView.style.left = cursorLeft + 'px';\n      this._compositionView.style.top = cursorTop + 'px';\n      this._compositionView.style.height = cellHeight + 'px';\n      this._compositionView.style.lineHeight = cellHeight + 'px';\n      this._compositionView.style.fontFamily = this._terminal.options.fontFamily;\n      this._compositionView.style.fontSize = this._terminal.options.fontSize + 'px';\n      // Sync the textarea to the exact position of the composition view so the IME knows where the\n      // text is.\n      const compositionViewBounds = this._compositionView.getBoundingClientRect();\n      this._textarea.style.left = cursorLeft + 'px';\n      this._textarea.style.top = cursorTop + 'px';\n      this._textarea.style.width = compositionViewBounds.width + 'px';\n      this._textarea.style.height = compositionViewBounds.height + 'px';\n      this._textarea.style.lineHeight = compositionViewBounds.height + 'px';\n    }\n\n    if (!dontRecurse) {\n      setTimeout(() => this.updateCompositionElements(true), 0);\n    }\n  }\n\n  /**\n   * Clears the textarea's position so that the cursor does not blink on IE.\n   * @private\n   */\n  private _clearTextareaPosition(): void {\n    this._textarea.style.left = '';\n    this._textarea.style.top = '';\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal, ISelectionManager } from './Types';\n\ninterface IWindow extends Window {\n  clipboardData?: {\n    getData(format: string): string;\n    setData(format: string, data: string): void;\n  };\n}\n\ndeclare var window: IWindow;\n\n/**\n * Prepares text to be pasted into the terminal by normalizing the line endings\n * @param text The pasted text that needs processing before inserting into the terminal\n */\nexport function prepareTextForTerminal(text: string): string {\n  return text.replace(/\\r?\\n/g, '\\r');\n}\n\n/**\n * Bracket text for paste, if necessary, as per https://cirw.in/blog/bracketed-paste\n * @param text The pasted text to bracket\n */\nexport function bracketTextForPaste(text: string, bracketedPasteMode: boolean): string {\n  if (bracketedPasteMode) {\n    return '\\x1b[200~' + text + '\\x1b[201~';\n  }\n  return text;\n}\n\n/**\n * Binds copy functionality to the given terminal.\n * @param ev The original copy event to be handled\n */\nexport function copyHandler(ev: ClipboardEvent, term: ITerminal, selectionManager: ISelectionManager): void {\n  if (term.browser.isMSIE) {\n    window.clipboardData.setData('Text', selectionManager.selectionText);\n  } else {\n    ev.clipboardData.setData('text/plain', selectionManager.selectionText);\n  }\n\n  // Prevent or the original text will be copied.\n  ev.preventDefault();\n}\n\n/**\n * Redirect the clipboard's data to the terminal's input handler.\n * @param ev The original paste event to be handled\n * @param term The terminal on which to apply the handled paste event\n */\nexport function pasteHandler(ev: ClipboardEvent, term: ITerminal): void {\n  ev.stopPropagation();\n\n  let text: string;\n\n  const dispatchPaste = function(text: string): void {\n    text = prepareTextForTerminal(text);\n    text = bracketTextForPaste(text, term.bracketedPasteMode);\n    term.handler(text);\n    term.textarea.value = '';\n    term.emit('paste', text);\n    term.cancel(ev);\n  };\n\n  if (term.browser.isMSIE) {\n    if (window.clipboardData) {\n      text = window.clipboardData.getData('Text');\n      dispatchPaste(text);\n    }\n  } else {\n    if (ev.clipboardData) {\n      text = ev.clipboardData.getData('text/plain');\n      dispatchPaste(text);\n    }\n  }\n}\n\n/**\n * Moves the textarea under the mouse cursor and focuses it.\n * @param ev The original right click event to be handled.\n * @param textarea The terminal's textarea.\n */\nexport function moveTextAreaUnderMouseCursor(ev: MouseEvent, term: ITerminal): void {\n\n  // Calculate textarea position relative to the screen element\n  const pos = term.screenElement.getBoundingClientRect();\n  const left = ev.clientX - pos.left - 10;\n  const top = ev.clientY - pos.top - 10;\n\n  // Bring textarea at the cursor position\n  term.textarea.style.position = 'absolute';\n  term.textarea.style.width = '20px';\n  term.textarea.style.height = '20px';\n  term.textarea.style.left = `${left}px`;\n  term.textarea.style.top = `${top}px`;\n  term.textarea.style.zIndex = '1000';\n\n  term.textarea.focus();\n\n  // Reset the terminal textarea's styling\n  // Timeout needs to be long enough for click event to be handled.\n  setTimeout(() => {\n    term.textarea.style.position = null;\n    term.textarea.style.width = null;\n    term.textarea.style.height = null;\n    term.textarea.style.left = null;\n    term.textarea.style.top = null;\n    term.textarea.style.zIndex = null;\n  }, 200);\n}\n\n/**\n * Bind to right-click event and allow right-click copy and paste.\n * @param ev The original right click event to be handled.\n * @param textarea The terminal's textarea.\n * @param selectionManager The terminal's selection manager.\n * @param shouldSelectWord If true and there is no selection the current word will be selected\n */\nexport function rightClickHandler(ev: MouseEvent, term: ITerminal, selectionManager: ISelectionManager, shouldSelectWord: boolean): void {\n  moveTextAreaUnderMouseCursor(ev, term);\n\n  if (shouldSelectWord && !selectionManager.isClickInSelection(ev)) {\n    selectionManager.selectWordAtCursor(ev);\n  }\n\n  // Get textarea ready to copy from the context menu\n  term.textarea.value = selectionManager.selectionText;\n  term.textarea.select();\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { fill } from './common/TypedArrayUtils';\n\nexport const wcwidth = (function(opts: {nul: number, control: number}): (ucs: number) => number {\n  // extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c\n  // combining characters\n  const COMBINING_BMP = [\n    [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],\n    [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],\n    [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],\n    [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],\n    [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],\n    [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],\n    [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],\n    [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],\n    [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],\n    [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],\n    [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],\n    [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],\n    [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],\n    [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],\n    [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],\n    [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],\n    [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],\n    [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],\n    [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],\n    [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],\n    [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],\n    [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],\n    [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],\n    [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],\n    [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],\n    [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],\n    [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],\n    [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],\n    [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],\n    [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],\n    [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],\n    [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],\n    [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],\n    [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],\n    [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],\n    [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],\n    [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],\n    [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],\n    [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],\n    [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],\n    [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],\n    [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],\n    [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]\n  ];\n  const COMBINING_HIGH = [\n    [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],\n    [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],\n    [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],\n    [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],\n    [0xE0100, 0xE01EF]\n  ];\n  // binary search\n  function bisearch(ucs: number, data: number[][]): boolean {\n    let min = 0;\n    let max = data.length - 1;\n    let mid;\n    if (ucs < data[0][0] || ucs > data[max][1]) {\n      return false;\n    }\n    while (max >= min) {\n      mid = (min + max) >> 1;\n      if (ucs > data[mid][1]) {\n        min = mid + 1;\n      } else if (ucs < data[mid][0]) {\n        max = mid - 1;\n      } else {\n        return true;\n      }\n    }\n    return false;\n  }\n  function wcwidthHigh(ucs: number): 0 | 1 | 2 {\n    if (bisearch(ucs, COMBINING_HIGH)) {\n      return 0;\n    }\n    if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {\n      return 2;\n    }\n    return 1;\n  }\n  const control = opts.control | 0;\n\n  // create lookup table for BMP plane\n  const table = new Uint8Array(65536);\n  fill(table, 1);\n  table[0] = opts.nul;\n  // control chars\n  fill(table, opts.control, 1, 32);\n  fill(table, opts.control, 0x7f, 0xa0);\n\n  // apply wide char rules first\n  // wide chars\n  fill(table, 2, 0x1100, 0x1160);\n  table[0x2329] = 2;\n  table[0x232a] = 2;\n  fill(table, 2, 0x2e80, 0xa4d0);\n  table[0x303f] = 1;  // wrongly in last line\n\n  fill(table, 2, 0xac00, 0xd7a4);\n  fill(table, 2, 0xf900, 0xfb00);\n  fill(table, 2, 0xfe10, 0xfe1a);\n  fill(table, 2, 0xfe30, 0xfe70);\n  fill(table, 2, 0xff00, 0xff61);\n  fill(table, 2, 0xffe0, 0xffe7);\n\n  // apply combining last to ensure we overwrite\n  // wrongly wide set chars:\n  //    the original algo evals combining first and falls\n  //    through to wide check so we simply do here the opposite\n  // combining 0\n  for (let r = 0; r < COMBINING_BMP.length; ++r) {\n    fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);\n  }\n\n  return function (num: number): number {\n    if (num < 32) {\n      return control | 0;\n    }\n    if (num < 127) {\n      return 1;\n    }\n    if (num < 65536) {\n      return table[num];\n    }\n    // do a full search for high codepoints\n    return wcwidthHigh(num);\n  };\n})({nul: 0, control: 0});  // configurable options\n\n/**\n * Get the terminal cell width for a string.\n */\nexport function getStringCellWidth(s: string): number {\n  let result = 0;\n  const length = s.length;\n  for (let i = 0; i < length; ++i) {\n    let code = s.charCodeAt(i);\n    // surrogate pair first\n    if (0xD800 <= code && code <= 0xDBFF) {\n      if (++i >= length) {\n        // this should not happen with strings retrieved from\n        // Buffer.translateToString as it converts from UTF-32\n        // and therefore always should contain the second part\n        // for any other string we still have to handle it somehow:\n        // simply treat the lonely surrogate first as a single char (UCS-2 behavior)\n        return result + wcwidth(code);\n      }\n      const second = s.charCodeAt(i);\n      // convert surrogate pair to high codepoint only for valid second part (UTF-16)\n      // otherwise treat them independently (UCS-2 behavior)\n      if (0xDC00 <= second && second <= 0xDFFF) {\n        code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n      } else {\n        result += wcwidth(second);\n      }\n    }\n    result += wcwidth(code);\n  }\n  return result;\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharMeasure, ITerminalOptions } from './Types';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\n\n/**\n * Utility class that measures the size of a character. Measurements are done in\n * the DOM rather than with a canvas context because support for extracting the\n * height of characters is patchy across browsers.\n */\nexport class CharMeasure implements ICharMeasure {\n  private _document: Document;\n  private _parentElement: HTMLElement;\n  private _measureElement: HTMLElement;\n  private _width: number;\n  private _height: number;\n\n  private _onCharSizeChanged = new EventEmitter2<void>();\n  public get onCharSizeChanged(): IEvent<void> { return this._onCharSizeChanged.event; }\n\n  constructor(document: Document, parentElement: HTMLElement) {\n    this._document = document;\n    this._parentElement = parentElement;\n    this._measureElement = this._document.createElement('span');\n    this._measureElement.classList.add('xterm-char-measure-element');\n    this._measureElement.textContent = 'W';\n    this._measureElement.setAttribute('aria-hidden', 'true');\n    this._parentElement.appendChild(this._measureElement);\n  }\n\n  public get width(): number {\n    return this._width;\n  }\n\n  public get height(): number {\n    return this._height;\n  }\n\n  public measure(options: ITerminalOptions): void {\n    this._measureElement.style.fontFamily = options.fontFamily;\n    this._measureElement.style.fontSize = `${options.fontSize}px`;\n    const geometry = this._measureElement.getBoundingClientRect();\n    // The element is likely currently display:none, we should retain the\n    // previous value.\n    if (geometry.width === 0 || geometry.height === 0) {\n      return;\n    }\n    const adjustedHeight = Math.ceil(geometry.height);\n    if (this._width !== geometry.width || this._height !== adjustedHeight) {\n      this._width = geometry.width;\n      this._height = adjustedHeight;\n      this._onCharSizeChanged.fire();\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminal, IBufferSet, IAttributeData, IBuffer } from './Types';\nimport { Buffer } from './Buffer';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\n\n/**\n * The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and\n * provides also utilities for working with them.\n */\nexport class BufferSet implements IBufferSet {\n  private _normal: Buffer;\n  private _alt: Buffer;\n  private _activeBuffer: Buffer;\n\n\n  private _onBufferActivate = new EventEmitter2<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>();\n  public get onBufferActivate(): IEvent<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}> { return this._onBufferActivate.event; }\n\n  /**\n   * Create a new BufferSet for the given terminal.\n   * @param _terminal - The terminal the BufferSet will belong to\n   */\n  constructor(private _terminal: ITerminal) {\n    this._normal = new Buffer(this._terminal, true);\n    this._normal.fillViewportRows();\n\n    // The alt buffer should never have scrollback.\n    // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer\n    this._alt = new Buffer(this._terminal, false);\n    this._activeBuffer = this._normal;\n\n    this.setupTabStops();\n  }\n\n  /**\n   * Returns the alt Buffer of the BufferSet\n   */\n  public get alt(): Buffer {\n    return this._alt;\n  }\n\n  /**\n   * Returns the normal Buffer of the BufferSet\n   */\n  public get active(): Buffer {\n    return this._activeBuffer;\n  }\n\n  /**\n   * Returns the currently active Buffer of the BufferSet\n   */\n  public get normal(): Buffer {\n    return this._normal;\n  }\n\n  /**\n   * Sets the normal Buffer of the BufferSet as its currently active Buffer\n   */\n  public activateNormalBuffer(): void {\n    if (this._activeBuffer === this._normal) {\n      return;\n    }\n    this._normal.x = this._alt.x;\n    this._normal.y = this._alt.y;\n    // The alt buffer should always be cleared when we switch to the normal\n    // buffer. This frees up memory since the alt buffer should always be new\n    // when activated.\n    this._alt.clear();\n    this._activeBuffer = this._normal;\n    this._onBufferActivate.fire({\n      activeBuffer: this._normal,\n      inactiveBuffer: this._alt\n    });\n  }\n\n  /**\n   * Sets the alt Buffer of the BufferSet as its currently active Buffer\n   */\n  public activateAltBuffer(fillAttr?: IAttributeData): void {\n    if (this._activeBuffer === this._alt) {\n      return;\n    }\n    // Since the alt buffer is always cleared when the normal buffer is\n    // activated, we want to fill it when switching to it.\n    this._alt.fillViewportRows(fillAttr);\n    this._alt.x = this._normal.x;\n    this._alt.y = this._normal.y;\n    this._activeBuffer = this._alt;\n    this._onBufferActivate.fire({\n      activeBuffer: this._alt,\n      inactiveBuffer: this._normal\n    });\n  }\n\n  /**\n   * Resizes both normal and alt buffers, adjusting their data accordingly.\n   * @param newCols The new number of columns.\n   * @param newRows The new number of rows.\n   */\n  public resize(newCols: number, newRows: number): void {\n    this._normal.resize(newCols, newRows);\n    this._alt.resize(newCols, newRows);\n  }\n\n  /**\n   * Setup the tab stops.\n   * @param i The index to start setting up tab stops from.\n   */\n  public setupTabStops(i?: number): void {\n    this._normal.setupTabStops(i);\n    this._alt.setupTabStops(i);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { BufferLine } from './BufferLine';\nimport { CircularList } from './common/CircularList';\nimport { IBufferLine, ICellData } from './Types';\n\nexport interface INewLayoutResult {\n  layout: number[];\n  countRemoved: number;\n}\n\n/**\n * Evaluates and returns indexes to be removed after a reflow larger occurs. Lines will be removed\n * when a wrapped line unwraps.\n * @param lines The buffer lines.\n * @param newCols The columns after resize.\n */\nexport function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData): number[] {\n  // Gather all BufferLines that need to be removed from the Buffer here so that they can be\n  // batched up and only committed once\n  const toRemove: number[] = [];\n\n  for (let y = 0; y < lines.length - 1; y++) {\n    // Check if this row is wrapped\n    let i = y;\n    let nextLine = lines.get(++i) as BufferLine;\n    if (!nextLine.isWrapped) {\n      continue;\n    }\n\n    // Check how many lines it's wrapped for\n    const wrappedLines: BufferLine[] = [lines.get(y) as BufferLine];\n    while (i < lines.length && nextLine.isWrapped) {\n      wrappedLines.push(nextLine);\n      nextLine = lines.get(++i) as BufferLine;\n    }\n\n    // If these lines contain the cursor don't touch them, the program will handle fixing up wrapped\n    // lines with the cursor\n    if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {\n      y += wrappedLines.length - 1;\n      continue;\n    }\n\n    // Copy buffer data to new locations\n    let destLineIndex = 0;\n    let destCol = getWrappedLineTrimmedLength(wrappedLines, destLineIndex, oldCols);\n    let srcLineIndex = 1;\n    let srcCol = 0;\n    while (srcLineIndex < wrappedLines.length) {\n      const srcTrimmedTineLength = getWrappedLineTrimmedLength(wrappedLines, srcLineIndex, oldCols);\n      const srcRemainingCells = srcTrimmedTineLength - srcCol;\n      const destRemainingCells = newCols - destCol;\n      const cellsToCopy = Math.min(srcRemainingCells, destRemainingCells);\n\n      wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol, destCol, cellsToCopy, false);\n\n      destCol += cellsToCopy;\n      if (destCol === newCols) {\n        destLineIndex++;\n        destCol = 0;\n      }\n      srcCol += cellsToCopy;\n      if (srcCol === srcTrimmedTineLength) {\n        srcLineIndex++;\n        srcCol = 0;\n      }\n\n      // Make sure the last cell isn't wide, if it is copy it to the current dest\n      if (destCol === 0 && destLineIndex !== 0) {\n        if (wrappedLines[destLineIndex - 1].getWidth(newCols - 1) === 2) {\n          wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[destLineIndex - 1], newCols - 1, destCol++, 1, false);\n          // Null out the end of the last row\n          wrappedLines[destLineIndex - 1].setCell(newCols - 1, nullCell);\n        }\n      }\n    }\n\n    // Clear out remaining cells or fragments could remain;\n    wrappedLines[destLineIndex].replaceCells(destCol, newCols, nullCell);\n\n    // Work backwards and remove any rows at the end that only contain null cells\n    let countToRemove = 0;\n    for (let i = wrappedLines.length - 1; i > 0; i--) {\n      if (i > destLineIndex || wrappedLines[i].getTrimmedLength() === 0) {\n        countToRemove++;\n      } else {\n        break;\n      }\n    }\n\n    if (countToRemove > 0) {\n      toRemove.push(y + wrappedLines.length - countToRemove); // index\n      toRemove.push(countToRemove);\n    }\n\n    y += wrappedLines.length - 1;\n  }\n  return toRemove;\n}\n\n/**\n * Creates and return the new layout for lines given an array of indexes to be removed.\n * @param lines The buffer lines.\n * @param toRemove The indexes to remove.\n */\nexport function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, toRemove: number[]): INewLayoutResult {\n  const layout: number[] = [];\n  // First iterate through the list and get the actual indexes to use for rows\n  let nextToRemoveIndex = 0;\n  let nextToRemoveStart = toRemove[nextToRemoveIndex];\n  let countRemovedSoFar = 0;\n  for (let i = 0; i < lines.length; i++) {\n    if (nextToRemoveStart === i) {\n      const countToRemove = toRemove[++nextToRemoveIndex];\n\n      // Tell markers that there was a deletion\n      lines.onDeleteEmitter.fire({\n        index: i - countRemovedSoFar,\n        amount: countToRemove\n      });\n\n      i += countToRemove - 1;\n      countRemovedSoFar += countToRemove;\n      nextToRemoveStart = toRemove[++nextToRemoveIndex];\n    } else {\n      layout.push(i);\n    }\n  }\n  return {\n    layout,\n    countRemoved: countRemovedSoFar\n  };\n}\n\n/**\n * Applies a new layout to the buffer. This essentially does the same as many splice calls but it's\n * done all at once in a single iteration through the list since splice is very expensive.\n * @param lines The buffer lines.\n * @param newLayout The new layout to apply.\n */\nexport function reflowLargerApplyNewLayout(lines: CircularList<IBufferLine>, newLayout: number[]): void {\n  // Record original lines so they don't get overridden when we rearrange the list\n  const newLayoutLines: BufferLine[] = [];\n  for (let i = 0; i < newLayout.length; i++) {\n    newLayoutLines.push(lines.get(newLayout[i]) as BufferLine);\n  }\n\n  // Rearrange the list\n  for (let i = 0; i < newLayoutLines.length; i++) {\n    lines.set(i, newLayoutLines[i]);\n  }\n  lines.length = newLayout.length;\n}\n\n/**\n * Gets the new line lengths for a given wrapped line. The purpose of this function it to pre-\n * compute the wrapping points since wide characters may need to be wrapped onto the following line.\n * This function will return an array of numbers of where each line wraps to, the resulting array\n * will only contain the values `newCols` (when the line does not end with a wide character) and\n * `newCols - 1` (when the line does end with a wide character), except for the last value which\n * will contain the remaining items to fill the line.\n *\n * Calling this with a `newCols` value of `1` will lock up.\n *\n * @param wrappedLines The wrapped lines to evaluate.\n * @param oldCols The columns before resize.\n * @param newCols The columns after resize.\n */\nexport function reflowSmallerGetNewLineLengths(wrappedLines: BufferLine[], oldCols: number, newCols: number): number[] {\n  const newLineLengths: number[] = [];\n  const cellsNeeded = wrappedLines.map((l, i) => getWrappedLineTrimmedLength(wrappedLines, i, oldCols)).reduce((p, c) => p + c);\n\n  // Use srcCol and srcLine to find the new wrapping point, use that to get the cellsAvailable and\n  // linesNeeded\n  let srcCol = 0;\n  let srcLine = 0;\n  let cellsAvailable = 0;\n  while (cellsAvailable < cellsNeeded) {\n    if (cellsNeeded - cellsAvailable < newCols) {\n      // Add the final line and exit the loop\n      newLineLengths.push(cellsNeeded - cellsAvailable);\n      break;\n    }\n    srcCol += newCols;\n    const oldTrimmedLength = getWrappedLineTrimmedLength(wrappedLines, srcLine, oldCols);\n    if (srcCol > oldTrimmedLength) {\n      srcCol -= oldTrimmedLength;\n      srcLine++;\n    }\n    const endsWithWide = wrappedLines[srcLine].getWidth(srcCol - 1) === 2;\n    if (endsWithWide) {\n      srcCol--;\n    }\n    const lineLength = endsWithWide ? newCols - 1 : newCols;\n    newLineLengths.push(lineLength);\n    cellsAvailable += lineLength;\n  }\n\n  return newLineLengths;\n}\n\nexport function getWrappedLineTrimmedLength(lines: BufferLine[], i: number, cols: number): number {\n  // If this is the last row in the wrapped line, get the actual trimmed length\n  if (i === lines.length - 1) {\n    return lines[i].getTrimmedLength();\n  }\n  // Detect whether the following line starts with a wide character and the end of the current line\n  // is null, if so then we can be pretty sure the null character should be excluded from the line\n  // length]\n  const endsInNull = !(lines[i].hasContent(cols - 1)) && lines[i].getWidth(cols - 1) === 1;\n  const followingLineStartsWithWide = lines[i + 1].getWidth(0) === 2;\n  if (endsInNull && followingLineStartsWithWide) {\n    return cols - 1;\n  }\n  return cols;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\nimport { CharData, IBufferLine, ICellData, IColorRGB, IAttributeData } from './Types';\nimport { NULL_CELL_CODE, NULL_CELL_WIDTH, NULL_CELL_CHAR, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, WHITESPACE_CELL_CHAR, CHAR_DATA_ATTR_INDEX } from './Buffer';\nimport { stringFromCodePoint } from './core/input/TextDecoder';\n\n\n/**\n * buffer memory layout:\n *\n *   |             uint32_t             |        uint32_t         |        uint32_t         |\n *   |             `content`            |          `FG`           |          `BG`           |\n *   | wcwidth(2) comb(1) codepoint(21) | flags(8) R(8) G(8) B(8) | flags(8) R(8) G(8) B(8) |\n */\n\n\n/** typed array slots taken by one cell */\nconst CELL_SIZE = 3;\n\n/**\n * Cell member indices.\n *\n * Direct access:\n *    `content = data[column * CELL_SIZE + Cell.CONTENT];`\n *    `fg = data[column * CELL_SIZE + Cell.FG];`\n *    `bg = data[column * CELL_SIZE + Cell.BG];`\n */\nconst enum Cell {\n  CONTENT = 0,\n  FG = 1, // currently simply holds all known attrs\n  BG = 2  // currently unused\n}\n\n/**\n * Bitmasks for accessing data in `content`.\n */\nexport const enum Content {\n  /**\n   * bit 1..21    codepoint, max allowed in UTF32 is 0x10FFFF (21 bits taken)\n   *              read:   `codepoint = content & Content.codepointMask;`\n   *              write:  `content |= codepoint & Content.codepointMask;`\n   *                      shortcut if precondition `codepoint <= 0x10FFFF` is met:\n   *                      `content |= codepoint;`\n   */\n  CODEPOINT_MASK = 0x1FFFFF,\n\n  /**\n   * bit 22       flag indication whether a cell contains combined content\n   *              read:   `isCombined = content & Content.isCombined;`\n   *              set:    `content |= Content.isCombined;`\n   *              clear:  `content &= ~Content.isCombined;`\n   */\n  IS_COMBINED_MASK = 0x200000,  // 1 << 21\n\n  /**\n   * bit 1..22    mask to check whether a cell contains any string data\n   *              we need to check for codepoint and isCombined bits to see\n   *              whether a cell contains anything\n   *              read:   `isEmpty = !(content & Content.hasContent)`\n   */\n  HAS_CONTENT_MASK = 0x3FFFFF,\n\n  /**\n   * bit 23..24   wcwidth value of cell, takes 2 bits (ranges from 0..2)\n   *              read:   `width = (content & Content.widthMask) >> Content.widthShift;`\n   *                      `hasWidth = content & Content.widthMask;`\n   *                      as long as wcwidth is highest value in `content`:\n   *                      `width = content >> Content.widthShift;`\n   *              write:  `content |= (width << Content.widthShift) & Content.widthMask;`\n   *                      shortcut if precondition `0 <= width <= 3` is met:\n   *                      `content |= width << Content.widthShift;`\n   */\n  WIDTH_MASK = 0xC00000,   // 3 << 22\n  WIDTH_SHIFT = 22\n}\n\n\nexport const enum Attributes {\n  /**\n   * bit 1..8     blue in RGB, color in P256 and P16\n   */\n  BLUE_MASK = 0xFF,\n  BLUE_SHIFT = 0,\n  PCOLOR_MASK = 0xFF,\n  PCOLOR_SHIFT = 0,\n\n  /**\n   * bit 9..16    green in RGB\n   */\n  GREEN_MASK = 0xFF00,\n  GREEN_SHIFT = 8,\n\n  /**\n   * bit 17..24   red in RGB\n   */\n  RED_MASK = 0xFF0000,\n  RED_SHIFT = 16,\n\n  /**\n   * bit 25..26   color mode: DEFAULT (0) | P16 (1) | P256 (2) | RGB (3)\n   */\n  CM_MASK = 0x3000000,\n  CM_DEFAULT = 0,\n  CM_P16 = 0x1000000,\n  CM_P256 = 0x2000000,\n  CM_RGB = 0x3000000,\n\n  /**\n   * bit 1..24  RGB room\n   */\n  RGB_MASK = 0xFFFFFF\n}\n\nexport const enum FgFlags {\n  /**\n   * bit 27..31 (32th bit unused)\n   */\n  INVERSE = 0x4000000,\n  BOLD = 0x8000000,\n  UNDERLINE = 0x10000000,\n  BLINK = 0x20000000,\n  INVISIBLE = 0x40000000\n}\n\nexport const enum BgFlags {\n  /**\n   * bit 27..32 (upper 4 unused)\n   */\n  ITALIC = 0x4000000,\n  DIM = 0x8000000\n}\n\nexport class AttributeData implements IAttributeData {\n  static toColorRGB(value: number): IColorRGB {\n    return [\n      value >>> Attributes.RED_SHIFT & 255,\n      value >>> Attributes.GREEN_SHIFT & 255,\n      value & 255\n    ];\n  }\n  static fromColorRGB(value: IColorRGB): number {\n    return (value[0] & 255) << Attributes.RED_SHIFT | (value[1] & 255) << Attributes.GREEN_SHIFT | value[2] & 255;\n  }\n\n  public clone(): IAttributeData {\n    const newObj = new AttributeData();\n    newObj.fg = this.fg;\n    newObj.bg = this.bg;\n    return newObj;\n  }\n\n  // data\n  public fg: number = 0;\n  public bg: number = 0;\n\n  // flags\n  public isInverse(): number   { return this.fg & FgFlags.INVERSE; }\n  public isBold(): number      { return this.fg & FgFlags.BOLD; }\n  public isUnderline(): number { return this.fg & FgFlags.UNDERLINE; }\n  public isBlink(): number     { return this.fg & FgFlags.BLINK; }\n  public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; }\n  public isItalic(): number    { return this.bg & BgFlags.ITALIC; }\n  public isDim(): number       { return this.bg & BgFlags.DIM; }\n\n  // color modes\n  public getFgColorMode(): number { return this.fg & Attributes.CM_MASK; }\n  public getBgColorMode(): number { return this.bg & Attributes.CM_MASK; }\n  public isFgRGB(): boolean       { return (this.fg & Attributes.CM_MASK) === Attributes.CM_RGB; }\n  public isBgRGB(): boolean       { return (this.bg & Attributes.CM_MASK) === Attributes.CM_RGB; }\n  public isFgPalette(): boolean   { return (this.fg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.fg & Attributes.CM_MASK) === Attributes.CM_P256; }\n  public isBgPalette(): boolean   { return (this.bg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.bg & Attributes.CM_MASK) === Attributes.CM_P256; }\n  public isFgDefault(): boolean   { return (this.fg & Attributes.CM_MASK) === 0; }\n  public isBgDefault(): boolean   { return (this.bg & Attributes.CM_MASK) === 0; }\n\n  // colors\n  public getFgColor(): number {\n    switch (this.fg & Attributes.CM_MASK) {\n      case Attributes.CM_P16:\n      case Attributes.CM_P256:  return this.fg & Attributes.PCOLOR_MASK;\n      case Attributes.CM_RGB:   return this.fg & Attributes.RGB_MASK;\n      default:                  return -1;  // CM_DEFAULT defaults to -1\n    }\n  }\n  public getBgColor(): number {\n    switch (this.bg & Attributes.CM_MASK) {\n      case Attributes.CM_P16:\n      case Attributes.CM_P256:  return this.bg & Attributes.PCOLOR_MASK;\n      case Attributes.CM_RGB:   return this.bg & Attributes.RGB_MASK;\n      default:                  return -1;  // CM_DEFAULT defaults to -1\n    }\n  }\n}\n\n/**\n * CellData - represents a single Cell in the terminal buffer.\n */\nexport class CellData extends AttributeData implements ICellData {\n\n  /** Helper to create CellData from CharData. */\n  public static fromCharData(value: CharData): CellData {\n    const obj = new CellData();\n    obj.setFromCharData(value);\n    return obj;\n  }\n\n  /** Primitives from terminal buffer. */\n  public content: number = 0;\n  public fg: number = 0;\n  public bg: number = 0;\n  public combinedData: string = '';\n\n  /** Whether cell contains a combined string. */\n  public isCombined(): number {\n    return this.content & Content.IS_COMBINED_MASK;\n  }\n\n  /** Width of the cell. */\n  public getWidth(): number {\n    return this.content >> Content.WIDTH_SHIFT;\n  }\n\n  /** JS string of the content. */\n  public getChars(): string {\n    if (this.content & Content.IS_COMBINED_MASK) {\n      return this.combinedData;\n    }\n    if (this.content & Content.CODEPOINT_MASK) {\n      return stringFromCodePoint(this.content & Content.CODEPOINT_MASK);\n    }\n    return '';\n  }\n\n  /**\n   * Codepoint of cell\n   * Note this returns the UTF32 codepoint of single chars,\n   * if content is a combined string it returns the codepoint\n   * of the last char in string to be in line with code in CharData.\n   * */\n  public getCode(): number {\n    return (this.isCombined())\n      ? this.combinedData.charCodeAt(this.combinedData.length - 1)\n      : this.content & Content.CODEPOINT_MASK;\n  }\n\n  /** Set data from CharData */\n  public setFromCharData(value: CharData): void {\n    this.fg = value[CHAR_DATA_ATTR_INDEX];\n    this.bg = 0;\n    let combined = false;\n\n    // surrogates and combined strings need special treatment\n    if (value[CHAR_DATA_CHAR_INDEX].length > 2) {\n      combined = true;\n    } else if (value[CHAR_DATA_CHAR_INDEX].length === 2) {\n      const code = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0);\n      // if the 2-char string is a surrogate create single codepoint\n      // everything else is combined\n      if (0xD800 <= code && code <= 0xDBFF) {\n        const second = value[CHAR_DATA_CHAR_INDEX].charCodeAt(1);\n        if (0xDC00 <= second && second <= 0xDFFF) {\n          this.content = ((code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n        } else {\n          combined = true;\n        }\n      } else {\n        combined = true;\n      }\n    } else {\n      this.content = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    }\n    if (combined) {\n      this.combinedData = value[CHAR_DATA_CHAR_INDEX];\n      this.content = Content.IS_COMBINED_MASK | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    }\n  }\n\n  /** Get data as CharData. */\n  public getAsCharData(): CharData {\n    return [this.fg, this.getChars(), this.getWidth(), this.getCode()];\n  }\n}\n\n\n/**\n * Typed array based bufferline implementation.\n *\n * There are 2 ways to insert data into the cell buffer:\n * - `setCellFromCodepoint` + `addCodepointToCell`\n *   Use these for data that is already UTF32.\n *   Used during normal input in `InputHandler` for faster buffer access.\n * - `setCell`\n *   This method takes a CellData object and stores the data in the buffer.\n *   Use `CellData.fromCharData` to create the CellData object (e.g. from JS string).\n *\n * To retrieve data from the buffer use either one of the primitive methods\n * (if only one particular value is needed) or `loadCell`. For `loadCell` in a loop\n * memory allocs / GC pressure can be greatly reduced by reusing the CellData object.\n */\nexport class BufferLine implements IBufferLine {\n  protected _data: Uint32Array | null = null;\n  protected _combined: {[index: number]: string} = {};\n  public length: number;\n\n  constructor(cols: number, fillCellData?: ICellData, public isWrapped: boolean = false) {\n    if (cols) {\n      this._data = new Uint32Array(cols * CELL_SIZE);\n      const cell = fillCellData || CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);\n      for (let i = 0; i < cols; ++i) {\n        this.setCell(i, cell);\n      }\n    }\n    this.length = cols;\n  }\n\n  /**\n   * Get cell data CharData.\n   * @deprecated\n   */\n  public get(index: number): CharData {\n    const content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    const cp = content & Content.CODEPOINT_MASK;\n    return [\n      this._data[index * CELL_SIZE + Cell.FG],\n      (content & Content.IS_COMBINED_MASK)\n        ? this._combined[index]\n        : (cp) ? stringFromCodePoint(cp) : '',\n      content >> Content.WIDTH_SHIFT,\n      (content & Content.IS_COMBINED_MASK)\n        ? this._combined[index].charCodeAt(this._combined[index].length - 1)\n        : cp\n    ];\n  }\n\n  /**\n   * Set cell data from CharData.\n   * @deprecated\n   */\n  public set(index: number, value: CharData): void {\n    this._data[index * CELL_SIZE + Cell.FG] = value[CHAR_DATA_ATTR_INDEX];\n    if (value[CHAR_DATA_CHAR_INDEX].length > 1) {\n      this._combined[index] = value[1];\n      this._data[index * CELL_SIZE + Cell.CONTENT] = index | Content.IS_COMBINED_MASK | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    } else {\n      this._data[index * CELL_SIZE + Cell.CONTENT] = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    }\n  }\n\n  /**\n   * primitive getters\n   * use these when only one value is needed, otherwise use `loadCell`\n   */\n  public getWidth(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] >> Content.WIDTH_SHIFT;\n  }\n\n  /** Test whether content has width. */\n  public hasWidth(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] & Content.WIDTH_MASK;\n  }\n\n  /** Get FG cell component. */\n  public getFg(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.FG];\n  }\n\n  /** Get BG cell component. */\n  public getBg(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.BG];\n  }\n\n  /**\n   * Test whether contains any chars.\n   * Basically an empty has no content, but other cells might differ in FG/BG\n   * from real empty cells.\n   * */\n  public hasContent(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] & Content.HAS_CONTENT_MASK;\n  }\n\n  /**\n   * Get codepoint of the cell.\n   * To be in line with `code` in CharData this either returns\n   * a single UTF32 codepoint or the last codepoint of a combined string.\n   */\n  public getCodePoint(index: number): number {\n    const content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    if (content & Content.IS_COMBINED_MASK) {\n      return this._combined[index].charCodeAt(this._combined[index].length - 1);\n    }\n    return content & Content.CODEPOINT_MASK;\n  }\n\n  /** Test whether the cell contains a combined string. */\n  public isCombined(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] & Content.IS_COMBINED_MASK;\n  }\n\n  /** Returns the string content of the cell. */\n  public getString(index: number): string {\n    const content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    if (content & Content.IS_COMBINED_MASK) {\n      return this._combined[index];\n    }\n    if (content & Content.CODEPOINT_MASK) {\n      return stringFromCodePoint(content & Content.CODEPOINT_MASK);\n    }\n    // return empty string for empty cells\n    return '';\n  }\n\n  /**\n   * Load data at `index` into `cell`. This is used to access cells in a way that's more friendly\n   * to GC as it significantly reduced the amount of new objects/references needed.\n   */\n  public loadCell(index: number, cell: ICellData): ICellData {\n    const startIndex = index * CELL_SIZE;\n    cell.content = this._data[startIndex + Cell.CONTENT];\n    cell.fg = this._data[startIndex + Cell.FG];\n    cell.bg = this._data[startIndex + Cell.BG];\n    if (cell.content & Content.IS_COMBINED_MASK) {\n      cell.combinedData = this._combined[index];\n    }\n    return cell;\n  }\n\n  /**\n   * Set data at `index` to `cell`.\n   */\n  public setCell(index: number, cell: ICellData): void {\n    if (cell.content & Content.IS_COMBINED_MASK) {\n      this._combined[index] = cell.combinedData;\n    }\n    this._data[index * CELL_SIZE + Cell.CONTENT] = cell.content;\n    this._data[index * CELL_SIZE + Cell.FG] = cell.fg;\n    this._data[index * CELL_SIZE + Cell.BG] = cell.bg;\n  }\n\n  /**\n   * Set cell data from input handler.\n   * Since the input handler see the incoming chars as UTF32 codepoints,\n   * it gets an optimized access method.\n   */\n  public setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void {\n    this._data[index * CELL_SIZE + Cell.CONTENT] = codePoint | (width << Content.WIDTH_SHIFT);\n    this._data[index * CELL_SIZE + Cell.FG] = fg;\n    this._data[index * CELL_SIZE + Cell.BG] = bg;\n  }\n\n  /**\n   * Add a codepoint to a cell from input handler.\n   * During input stage combining chars with a width of 0 follow and stack\n   * onto a leading char. Since we already set the attrs\n   * by the previous `setDataFromCodePoint` call, we can omit it here.\n   */\n  public addCodepointToCell(index: number, codePoint: number): void {\n    let content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    if (content & Content.IS_COMBINED_MASK) {\n      // we already have a combined string, simply add\n      this._combined[index] += stringFromCodePoint(codePoint);\n    } else {\n      if (content & Content.CODEPOINT_MASK) {\n        // normal case for combining chars:\n        //  - move current leading char + new one into combined string\n        //  - set combined flag\n        this._combined[index] = stringFromCodePoint(content & Content.CODEPOINT_MASK) + stringFromCodePoint(codePoint);\n        content &= ~Content.CODEPOINT_MASK; // set codepoint in buffer to 0\n        content |= Content.IS_COMBINED_MASK;\n      } else {\n        // should not happen - we actually have no data in the cell yet\n        // simply set the data in the cell buffer with a width of 1\n        content = codePoint | (1 << Content.WIDTH_SHIFT);\n      }\n      this._data[index * CELL_SIZE + Cell.CONTENT] = content;\n    }\n  }\n\n  public insertCells(pos: number, n: number, fillCellData: ICellData): void {\n    pos %= this.length;\n    if (n < this.length - pos) {\n      const cell = new CellData();\n      for (let i = this.length - pos - n - 1; i >= 0; --i) {\n        this.setCell(pos + n + i, this.loadCell(pos + i, cell));\n      }\n      for (let i = 0; i < n; ++i) {\n        this.setCell(pos + i, fillCellData);\n      }\n    } else {\n      for (let i = pos; i < this.length; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    }\n  }\n\n  public deleteCells(pos: number, n: number, fillCellData: ICellData): void {\n    pos %= this.length;\n    if (n < this.length - pos) {\n      const cell = new CellData();\n      for (let i = 0; i < this.length - pos - n; ++i) {\n        this.setCell(pos + i, this.loadCell(pos + n + i, cell));\n      }\n      for (let i = this.length - n; i < this.length; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    } else {\n      for (let i = pos; i < this.length; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    }\n  }\n\n  public replaceCells(start: number, end: number, fillCellData: ICellData): void {\n    while (start < end  && start < this.length) {\n      this.setCell(start++, fillCellData);\n    }\n  }\n\n  public resize(cols: number, fillCellData: ICellData): void {\n    if (cols === this.length) {\n      return;\n    }\n    if (cols > this.length) {\n      const data = new Uint32Array(cols * CELL_SIZE);\n      if (this.length) {\n        if (cols * CELL_SIZE < this._data.length) {\n          data.set(this._data.subarray(0, cols * CELL_SIZE));\n        } else {\n          data.set(this._data);\n        }\n      }\n      this._data = data;\n      for (let i = this.length; i < cols; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    } else {\n      if (cols) {\n        const data = new Uint32Array(cols * CELL_SIZE);\n        data.set(this._data.subarray(0, cols * CELL_SIZE));\n        this._data = data;\n        // Remove any cut off combined data\n        const keys = Object.keys(this._combined);\n        for (let i = 0; i < keys.length; i++) {\n          const key = parseInt(keys[i], 10);\n          if (key >= cols) {\n            delete this._combined[key];\n          }\n        }\n      } else {\n        this._data = null;\n        this._combined = {};\n      }\n    }\n    this.length = cols;\n  }\n\n  /** fill a line with fillCharData */\n  public fill(fillCellData: ICellData): void {\n    this._combined = {};\n    for (let i = 0; i < this.length; ++i) {\n      this.setCell(i, fillCellData);\n    }\n  }\n\n  /** alter to a full copy of line  */\n  public copyFrom(line: BufferLine): void {\n    if (this.length !== line.length) {\n      this._data = new Uint32Array(line._data);\n    } else {\n      // use high speed copy if lengths are equal\n      this._data.set(line._data);\n    }\n    this.length = line.length;\n    this._combined = {};\n    for (const el in line._combined) {\n      this._combined[el] = line._combined[el];\n    }\n    this.isWrapped = line.isWrapped;\n  }\n\n  /** create a new clone */\n  public clone(): IBufferLine {\n    const newLine = new BufferLine(0);\n    newLine._data = new Uint32Array(this._data);\n    newLine.length = this.length;\n    for (const el in this._combined) {\n      newLine._combined[el] = this._combined[el];\n    }\n    newLine.isWrapped = this.isWrapped;\n    return newLine;\n  }\n\n  public getTrimmedLength(): number {\n    for (let i = this.length - 1; i >= 0; --i) {\n      if ((this._data[i * CELL_SIZE + Cell.CONTENT] & Content.HAS_CONTENT_MASK)) {\n        return i + (this._data[i * CELL_SIZE + Cell.CONTENT] >> Content.WIDTH_SHIFT);\n      }\n    }\n    return 0;\n  }\n\n  public copyCellsFrom(src: BufferLine, srcCol: number, destCol: number, length: number, applyInReverse: boolean): void {\n    const srcData = src._data;\n    if (applyInReverse) {\n      for (let cell = length - 1; cell >= 0; cell--) {\n        for (let i = 0; i < CELL_SIZE; i++) {\n          this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];\n        }\n      }\n    } else {\n      for (let cell = 0; cell < length; cell++) {\n        for (let i = 0; i < CELL_SIZE; i++) {\n          this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];\n        }\n      }\n    }\n\n    // Move any combined data over as needed\n    const srcCombinedKeys = Object.keys(src._combined);\n    for (let i = 0; i < srcCombinedKeys.length; i++) {\n      const key = parseInt(srcCombinedKeys[i], 10);\n      if (key >= srcCol) {\n        this._combined[key - srcCol + destCol] = src._combined[key];\n      }\n    }\n  }\n\n  public translateToString(trimRight: boolean = false, startCol: number = 0, endCol: number = this.length): string {\n    if (trimRight) {\n      endCol = Math.min(endCol, this.getTrimmedLength());\n    }\n    let result = '';\n    while (startCol < endCol) {\n      const content = this._data[startCol * CELL_SIZE + Cell.CONTENT];\n      const cp = content & Content.CODEPOINT_MASK;\n      result += (content & Content.IS_COMBINED_MASK) ? this._combined[startCol] : (cp) ? stringFromCodePoint(cp) : WHITESPACE_CELL_CHAR;\n      startCol += (content >> Content.WIDTH_SHIFT) || 1; // always advance by 1\n    }\n    return result;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { CircularList, IInsertEvent } from './common/CircularList';\nimport { ITerminal, IBuffer, IBufferLine, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult, ICellData, IAttributeData } from './Types';\nimport { IMarker } from 'xterm';\nimport { BufferLine, CellData, AttributeData } from './BufferLine';\nimport { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from './BufferReflow';\nimport { DEFAULT_COLOR } from './renderer/atlas/Types';\nimport { EventEmitter2, IEvent } from './common/EventEmitter2';\nimport { Disposable } from '../lib/common/Lifecycle';\n\nexport const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);\n\nexport const DEFAULT_ATTR_DATA = new AttributeData();\n\nexport const CHAR_DATA_ATTR_INDEX = 0;\nexport const CHAR_DATA_CHAR_INDEX = 1;\nexport const CHAR_DATA_WIDTH_INDEX = 2;\nexport const CHAR_DATA_CODE_INDEX = 3;\nexport const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1\n\n/**\n * Null cell - a real empty cell (containing nothing).\n * Note that code should always be 0 for a null cell as\n * several test condition of the buffer line rely on this.\n */\nexport const NULL_CELL_CHAR = '';\nexport const NULL_CELL_WIDTH = 1;\nexport const NULL_CELL_CODE = 0;\n\n/**\n * Whitespace cell.\n * This is meant as a replacement for empty cells when needed\n * during rendering lines to preserve correct aligment.\n */\nexport const WHITESPACE_CELL_CHAR = ' ';\nexport const WHITESPACE_CELL_WIDTH = 1;\nexport const WHITESPACE_CELL_CODE = 32;\n\n/**\n * This class represents a terminal buffer (an internal state of the terminal), where the\n * following information is stored (in high-level):\n *   - text content of this particular buffer\n *   - cursor position\n *   - scroll position\n */\nexport class Buffer implements IBuffer {\n  public lines: CircularList<IBufferLine>;\n  public ydisp: number;\n  public ybase: number;\n  public y: number;\n  public x: number;\n  public scrollBottom: number;\n  public scrollTop: number;\n  public tabs: any;\n  public savedY: number;\n  public savedX: number;\n  public savedCurAttrData = DEFAULT_ATTR_DATA.clone();\n  public markers: Marker[] = [];\n  private _nullCell: ICellData = CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);\n  private _whitespaceCell: ICellData = CellData.fromCharData([0, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE]);\n  private _cols: number;\n  private _rows: number;\n\n  /**\n   * Create a new Buffer.\n   * @param _terminal The terminal the Buffer will belong to.\n   * @param _hasScrollback Whether the buffer should respect the scrollback of\n   * the terminal.\n   */\n  constructor(\n    private _terminal: ITerminal,\n    private _hasScrollback: boolean\n  ) {\n    this._cols = this._terminal.cols;\n    this._rows = this._terminal.rows;\n    this.clear();\n  }\n\n  public getNullCell(attr?: IAttributeData): ICellData {\n    if (attr) {\n      this._nullCell.fg = attr.fg;\n      this._nullCell.bg = attr.bg;\n    } else {\n      this._nullCell.fg = 0;\n      this._nullCell.bg = 0;\n    }\n    return this._nullCell;\n  }\n\n  public getWhitespaceCell(attr?: IAttributeData): ICellData {\n    if (attr) {\n      this._whitespaceCell.fg = attr.fg;\n      this._whitespaceCell.bg = attr.bg;\n    } else {\n      this._whitespaceCell.fg = 0;\n      this._whitespaceCell.bg = 0;\n    }\n    return this._whitespaceCell;\n  }\n\n  public getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine {\n    return new BufferLine(this._terminal.cols, this.getNullCell(attr), isWrapped);\n  }\n\n  public get hasScrollback(): boolean {\n    return this._hasScrollback && this.lines.maxLength > this._rows;\n  }\n\n  public get isCursorInViewport(): boolean {\n    const absoluteY = this.ybase + this.y;\n    const relativeY = absoluteY - this.ydisp;\n    return (relativeY >= 0 && relativeY < this._rows);\n  }\n\n  /**\n   * Gets the correct buffer length based on the rows provided, the terminal's\n   * scrollback and whether this buffer is flagged to have scrollback or not.\n   * @param rows The terminal rows to use in the calculation.\n   */\n  private _getCorrectBufferLength(rows: number): number {\n    if (!this._hasScrollback) {\n      return rows;\n    }\n\n    const correctBufferLength = rows + this._terminal.options.scrollback;\n\n    return correctBufferLength > MAX_BUFFER_SIZE ? MAX_BUFFER_SIZE : correctBufferLength;\n  }\n\n  /**\n   * Fills the buffer's viewport with blank lines.\n   */\n  public fillViewportRows(fillAttr?: IAttributeData): void {\n    if (this.lines.length === 0) {\n      if (fillAttr === undefined) {\n        fillAttr = DEFAULT_ATTR_DATA;\n      }\n      let i = this._rows;\n      while (i--) {\n        this.lines.push(this.getBlankLine(fillAttr));\n      }\n    }\n  }\n\n  /**\n   * Clears the buffer to it's initial state, discarding all previous data.\n   */\n  public clear(): void {\n    this.ydisp = 0;\n    this.ybase = 0;\n    this.y = 0;\n    this.x = 0;\n    this.lines = new CircularList<IBufferLine>(this._getCorrectBufferLength(this._rows));\n    this.scrollTop = 0;\n    this.scrollBottom = this._rows - 1;\n    this.setupTabStops();\n  }\n\n  /**\n   * Resizes the buffer, adjusting its data accordingly.\n   * @param newCols The new number of columns.\n   * @param newRows The new number of rows.\n   */\n  public resize(newCols: number, newRows: number): void {\n    // store reference to null cell with default attrs\n    const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);\n\n    // Increase max length if needed before adjustments to allow space to fill\n    // as required.\n    const newMaxLength = this._getCorrectBufferLength(newRows);\n    if (newMaxLength > this.lines.maxLength) {\n      this.lines.maxLength = newMaxLength;\n    }\n\n    // The following adjustments should only happen if the buffer has been\n    // initialized/filled.\n    if (this.lines.length > 0) {\n      // Deal with columns increasing (reducing needs to happen after reflow)\n      if (this._cols < newCols) {\n        for (let i = 0; i < this.lines.length; i++) {\n          this.lines.get(i).resize(newCols, nullCell);\n        }\n      }\n\n      // Resize rows in both directions as needed\n      let addToY = 0;\n      if (this._rows < newRows) {\n        for (let y = this._rows; y < newRows; y++) {\n          if (this.lines.length < newRows + this.ybase) {\n            if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {\n              // There is room above the buffer and there are no empty elements below the line,\n              // scroll up\n              this.ybase--;\n              addToY++;\n              if (this.ydisp > 0) {\n                // Viewport is at the top of the buffer, must increase downwards\n                this.ydisp--;\n              }\n            } else {\n              // Add a blank line if there is no buffer left at the top to scroll to, or if there\n              // are blank lines after the cursor\n              this.lines.push(new BufferLine(newCols, nullCell));\n            }\n          }\n        }\n      } else { // (this._rows >= newRows)\n        for (let y = this._rows; y > newRows; y--) {\n          if (this.lines.length > newRows + this.ybase) {\n            if (this.lines.length > this.ybase + this.y + 1) {\n              // The line is a blank line below the cursor, remove it\n              this.lines.pop();\n            } else {\n              // The line is the cursor, scroll down\n              this.ybase++;\n              this.ydisp++;\n            }\n          }\n        }\n      }\n\n      // Reduce max length if needed after adjustments, this is done after as it\n      // would otherwise cut data from the bottom of the buffer.\n      if (newMaxLength < this.lines.maxLength) {\n        // Trim from the top of the buffer and adjust ybase and ydisp.\n        const amountToTrim = this.lines.length - newMaxLength;\n        if (amountToTrim > 0) {\n          this.lines.trimStart(amountToTrim);\n          this.ybase = Math.max(this.ybase - amountToTrim, 0);\n          this.ydisp = Math.max(this.ydisp - amountToTrim, 0);\n        }\n        this.lines.maxLength = newMaxLength;\n      }\n\n      // Make sure that the cursor stays on screen\n      this.x = Math.min(this.x, newCols - 1);\n      this.y = Math.min(this.y, newRows - 1);\n      if (addToY) {\n        this.y += addToY;\n      }\n      this.savedY = Math.min(this.savedY, newRows - 1);\n      this.savedX = Math.min(this.savedX, newCols - 1);\n\n      this.scrollTop = 0;\n    }\n\n    this.scrollBottom = newRows - 1;\n\n    if (this._isReflowEnabled) {\n      this._reflow(newCols, newRows);\n\n      // Trim the end of the line off if cols shrunk\n      if (this._cols > newCols) {\n        for (let i = 0; i < this.lines.length; i++) {\n          this.lines.get(i).resize(newCols, nullCell);\n        }\n      }\n    }\n\n    this._cols = newCols;\n    this._rows = newRows;\n  }\n\n  private get _isReflowEnabled(): boolean {\n    return this._hasScrollback && !this._terminal.options.windowsMode;\n  }\n\n  private _reflow(newCols: number, newRows: number): void {\n    if (this._cols === newCols) {\n      return;\n    }\n\n    // Iterate through rows, ignore the last one as it cannot be wrapped\n    if (newCols > this._cols) {\n      this._reflowLarger(newCols, newRows);\n    } else {\n      this._reflowSmaller(newCols, newRows);\n    }\n  }\n\n  private _reflowLarger(newCols: number, newRows: number): void {\n    const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA));\n    if (toRemove.length > 0) {\n      const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);\n      reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);\n      this._reflowLargerAdjustViewport(newCols, newRows, newLayoutResult.countRemoved);\n    }\n  }\n\n  private _reflowLargerAdjustViewport(newCols: number, newRows: number, countRemoved: number): void {\n    const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);\n    // Adjust viewport based on number of items removed\n    let viewportAdjustments = countRemoved;\n    while (viewportAdjustments-- > 0) {\n      if (this.ybase === 0) {\n        if (this.y > 0) {\n          this.y--;\n        }\n        if (this.lines.length < newRows) {\n          // Add an extra row at the bottom of the viewport\n          this.lines.push(new BufferLine(newCols, nullCell));\n        }\n      } else {\n        if (this.ydisp === this.ybase) {\n          this.ydisp--;\n        }\n        this.ybase--;\n      }\n    }\n  }\n\n  private _reflowSmaller(newCols: number, newRows: number): void {\n    const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);\n    // Gather all BufferLines that need to be inserted into the Buffer here so that they can be\n    // batched up and only committed once\n    const toInsert = [];\n    let countToInsert = 0;\n    // Go backwards as many lines may be trimmed and this will avoid considering them\n    for (let y = this.lines.length - 1; y >= 0; y--) {\n      // Check whether this line is a problem\n      let nextLine = this.lines.get(y) as BufferLine;\n      if (!nextLine.isWrapped && nextLine.getTrimmedLength() <= newCols) {\n        continue;\n      }\n\n      // Gather wrapped lines and adjust y to be the starting line\n      const wrappedLines: BufferLine[] = [nextLine];\n      while (nextLine.isWrapped && y > 0) {\n        nextLine = this.lines.get(--y) as BufferLine;\n        wrappedLines.unshift(nextLine);\n      }\n\n      // If these lines contain the cursor don't touch them, the program will handle fixing up\n      // wrapped lines with the cursor\n      const absoluteY = this.ybase + this.y;\n      if (absoluteY >= y && absoluteY < y + wrappedLines.length) {\n        continue;\n      }\n\n      const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();\n      const destLineLengths = reflowSmallerGetNewLineLengths(wrappedLines, this._cols, newCols);\n      const linesToAdd = destLineLengths.length - wrappedLines.length;\n      let trimmedLines: number;\n      if (this.ybase === 0 && this.y !== this.lines.length - 1) {\n        // If the top section of the buffer is not yet filled\n        trimmedLines = Math.max(0, this.y - this.lines.maxLength + linesToAdd);\n      } else {\n        trimmedLines = Math.max(0, this.lines.length - this.lines.maxLength + linesToAdd);\n      }\n\n      // Add the new lines\n      const newLines: BufferLine[] = [];\n      for (let i = 0; i < linesToAdd; i++) {\n        const newLine = this.getBlankLine(DEFAULT_ATTR_DATA, true) as BufferLine;\n        newLines.push(newLine);\n      }\n      if (newLines.length > 0) {\n        toInsert.push({\n          // countToInsert here gets the actual index, taking into account other inserted items.\n          // using this we can iterate through the list forwards\n          start: y + wrappedLines.length + countToInsert,\n          newLines\n        });\n        countToInsert += newLines.length;\n      }\n      wrappedLines.push(...newLines);\n\n      // Copy buffer data to new locations, this needs to happen backwards to do in-place\n      let destLineIndex = destLineLengths.length - 1; // Math.floor(cellsNeeded / newCols);\n      let destCol = destLineLengths[destLineIndex]; // cellsNeeded % newCols;\n      if (destCol === 0) {\n        destLineIndex--;\n        destCol = destLineLengths[destLineIndex];\n      }\n      let srcLineIndex = wrappedLines.length - linesToAdd - 1;\n      let srcCol = lastLineLength;\n      while (srcLineIndex >= 0) {\n        const cellsToCopy = Math.min(srcCol, destCol);\n        wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true);\n        destCol -= cellsToCopy;\n        if (destCol === 0) {\n          destLineIndex--;\n          destCol = destLineLengths[destLineIndex];\n        }\n        srcCol -= cellsToCopy;\n        if (srcCol === 0) {\n          srcLineIndex--;\n          const wrappedLinesIndex = Math.max(srcLineIndex, 0);\n          srcCol = getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols);\n        }\n      }\n\n      // Null out the end of the line ends if a wide character wrapped to the following line\n      for (let i = 0; i < wrappedLines.length; i++) {\n        if (destLineLengths[i] < newCols) {\n          wrappedLines[i].setCell(destLineLengths[i], nullCell);\n        }\n      }\n\n      // Adjust viewport as needed\n      let viewportAdjustments = linesToAdd - trimmedLines;\n      while (viewportAdjustments-- > 0) {\n        if (this.ybase === 0) {\n          if (this.y < newRows - 1) {\n            this.y++;\n            this.lines.pop();\n          } else {\n            this.ybase++;\n            this.ydisp++;\n          }\n        } else {\n          // Ensure ybase does not exceed its maximum value\n          if (this.ybase < Math.min(this.lines.maxLength, this.lines.length + countToInsert) - newRows) {\n            if (this.ybase === this.ydisp) {\n              this.ydisp++;\n            }\n            this.ybase++;\n          }\n        }\n      }\n    }\n\n    // Rearrange lines in the buffer if there are any insertions, this is done at the end rather\n    // than earlier so that it's a single O(n) pass through the buffer, instead of O(n^2) from many\n    // costly calls to CircularList.splice.\n    if (toInsert.length > 0) {\n      // Record buffer insert events and then play them back backwards so that the indexes are\n      // correct\n      const insertEvents: IInsertEvent[] = [];\n\n      // Record original lines so they don't get overridden when we rearrange the list\n      const originalLines: BufferLine[] = [];\n      for (let i = 0; i < this.lines.length; i++) {\n        originalLines.push(this.lines.get(i) as BufferLine);\n      }\n      const originalLinesLength = this.lines.length;\n\n      let originalLineIndex = originalLinesLength - 1;\n      let nextToInsertIndex = 0;\n      let nextToInsert = toInsert[nextToInsertIndex];\n      this.lines.length = Math.min(this.lines.maxLength, this.lines.length + countToInsert);\n      let countInsertedSoFar = 0;\n      for (let i = Math.min(this.lines.maxLength - 1, originalLinesLength + countToInsert - 1); i >= 0; i--) {\n        if (nextToInsert && nextToInsert.start > originalLineIndex + countInsertedSoFar) {\n          // Insert extra lines here, adjusting i as needed\n          for (let nextI = nextToInsert.newLines.length - 1; nextI >= 0; nextI--) {\n            this.lines.set(i--, nextToInsert.newLines[nextI]);\n          }\n          i++;\n\n          // Create insert events for later\n          insertEvents.push({\n            index: originalLineIndex + 1,\n            amount: nextToInsert.newLines.length\n          });\n\n          countInsertedSoFar += nextToInsert.newLines.length;\n          nextToInsert = toInsert[++nextToInsertIndex];\n        } else {\n          this.lines.set(i, originalLines[originalLineIndex--]);\n        }\n      }\n\n      // Update markers\n      let insertCountEmitted = 0;\n      for (let i = insertEvents.length - 1; i >= 0; i--) {\n        insertEvents[i].index += insertCountEmitted;\n        this.lines.onInsertEmitter.fire(insertEvents[i]);\n        insertCountEmitted += insertEvents[i].amount;\n      }\n      const amountToTrim = Math.max(0, originalLinesLength + countToInsert - this.lines.maxLength);\n      if (amountToTrim > 0) {\n        this.lines.onTrimEmitter.fire(amountToTrim);\n      }\n    }\n  }\n\n  // private _reflowSmallerGetLinesNeeded()\n\n  /**\n   * Translates a string index back to a BufferIndex.\n   * To get the correct buffer position the string must start at `startCol` 0\n   * (default in translateBufferLineToString).\n   * The method also works on wrapped line strings given rows were not trimmed.\n   * The method operates on the CharData string length, there are no\n   * additional content or boundary checks. Therefore the string and the buffer\n   * should not be altered in between.\n   * TODO: respect trim flag after fixing #1685\n   * @param lineIndex line index the string was retrieved from\n   * @param stringIndex index within the string\n   * @param startCol column offset the string was retrieved from\n   */\n  public stringIndexToBufferIndex(lineIndex: number, stringIndex: number, trimRight: boolean = false): BufferIndex {\n    while (stringIndex) {\n      const line = this.lines.get(lineIndex);\n      if (!line) {\n        return [-1, -1];\n      }\n      const length = (trimRight) ? line.getTrimmedLength() : line.length;\n      for (let i = 0; i < length; ++i) {\n        if (line.get(i)[CHAR_DATA_WIDTH_INDEX]) {\n          // empty cells report a string length of 0, but get replaced\n          // with a whitespace in translateToString, thus replace with 1\n          stringIndex -= line.get(i)[CHAR_DATA_CHAR_INDEX].length || 1;\n        }\n        if (stringIndex < 0) {\n          return [lineIndex, i];\n        }\n      }\n      lineIndex++;\n    }\n    return [lineIndex, 0];\n  }\n\n  /**\n   * Translates a buffer line to a string, with optional start and end columns.\n   * Wide characters will count as two columns in the resulting string. This\n   * function is useful for getting the actual text underneath the raw selection\n   * position.\n   * @param line The line being translated.\n   * @param trimRight Whether to trim whitespace to the right.\n   * @param startCol The column to start at.\n   * @param endCol The column to end at.\n   */\n  public translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol: number = 0, endCol?: number): string {\n    const line = this.lines.get(lineIndex);\n    if (!line) {\n      return '';\n    }\n    return line.translateToString(trimRight, startCol, endCol);\n  }\n\n  public getWrappedRangeForLine(y: number): { first: number, last: number } {\n    let first = y;\n    let last = y;\n    // Scan upwards for wrapped lines\n    while (first > 0 && this.lines.get(first).isWrapped) {\n      first--;\n    }\n    // Scan downwards for wrapped lines\n    while (last + 1 < this.lines.length && this.lines.get(last + 1).isWrapped) {\n      last++;\n    }\n    return { first, last };\n  }\n\n  /**\n   * Setup the tab stops.\n   * @param i The index to start setting up tab stops from.\n   */\n  public setupTabStops(i?: number): void {\n    if (i !== null && i !== undefined) {\n      if (!this.tabs[i]) {\n        i = this.prevStop(i);\n      }\n    } else {\n      this.tabs = {};\n      i = 0;\n    }\n\n    for (; i < this._cols; i += this._terminal.options.tabStopWidth) {\n      this.tabs[i] = true;\n    }\n  }\n\n  /**\n   * Move the cursor to the previous tab stop from the given position (default is current).\n   * @param x The position to move the cursor to the previous tab stop.\n   */\n  public prevStop(x?: number): number {\n    if (x === null || x === undefined) {\n      x = this.x;\n    }\n    while (!this.tabs[--x] && x > 0);\n    return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;\n  }\n\n  /**\n   * Move the cursor one tab stop forward from the given position (default is current).\n   * @param x The position to move the cursor one tab stop forward.\n   */\n  public nextStop(x?: number): number {\n    if (x === null || x === undefined) {\n      x = this.x;\n    }\n    while (!this.tabs[++x] && x < this._cols);\n    return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;\n  }\n\n  public addMarker(y: number): Marker {\n    const marker = new Marker(y);\n    this.markers.push(marker);\n    marker.register(this.lines.onTrim(amount => {\n      marker.line -= amount;\n      // The marker should be disposed when the line is trimmed from the buffer\n      if (marker.line < 0) {\n        marker.dispose();\n      }\n    }));\n    marker.register(this.lines.onInsert(event => {\n      if (marker.line >= event.index) {\n        marker.line += event.amount;\n      }\n    }));\n    marker.register(this.lines.onDelete(event => {\n      // Delete the marker if it's within the range\n      if (marker.line >= event.index && marker.line < event.index + event.amount) {\n        marker.dispose();\n      }\n\n      // Shift the marker if it's after the deleted range\n      if (marker.line > event.index) {\n        marker.line -= event.amount;\n      }\n    }));\n    marker.register(marker.onDispose(() => this._removeMarker(marker)));\n    return marker;\n  }\n\n  private _removeMarker(marker: Marker): void {\n    this.markers.splice(this.markers.indexOf(marker), 1);\n  }\n\n  public iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator {\n    return new BufferStringIterator(this, trimRight, startIndex, endIndex, startOverscan, endOverscan);\n  }\n}\n\nexport class Marker extends Disposable implements IMarker {\n  private static _nextId = 1;\n\n  private _id: number = Marker._nextId++;\n  public isDisposed: boolean = false;\n\n  public get id(): number { return this._id; }\n\n  private _onDispose = new EventEmitter2<void>();\n  public get onDispose(): IEvent<void> { return this._onDispose.event; }\n\n  constructor(\n    public line: number\n  ) {\n    super();\n  }\n\n  public dispose(): void {\n    if (this.isDisposed) {\n      return;\n    }\n    this.isDisposed = true;\n    // Emit before super.dispose such that dispose listeners get a change to react\n    this._onDispose.fire();\n  }\n}\n\n/**\n * Iterator to get unwrapped content strings from the buffer.\n * The iterator returns at least the string data between the borders\n * `startIndex` and `endIndex` (exclusive) and will expand the lines\n * by `startOverscan` to the top and by `endOverscan` to the bottom,\n * if no new line was found in between.\n * It will never read/return string data beyond `startIndex - startOverscan`\n * or `endIndex + endOverscan`. Therefore the first and last line might be truncated.\n * It is possible to always get the full string for the first and last line as well\n * by setting the overscan values to the actual buffer length. This not recommended\n * since it might return the whole buffer within a single string in a worst case scenario.\n */\nexport class BufferStringIterator implements IBufferStringIterator {\n  private _current: number;\n\n  constructor (\n    private _buffer: IBuffer,\n    private _trimRight: boolean,\n    private _startIndex: number = 0,\n    private _endIndex: number = _buffer.lines.length,\n    private _startOverscan: number = 0,\n    private _endOverscan: number = 0\n  ) {\n    if (this._startIndex < 0) {\n      this._startIndex = 0;\n    }\n    if (this._endIndex > this._buffer.lines.length) {\n      this._endIndex = this._buffer.lines.length;\n    }\n    this._current = this._startIndex;\n  }\n\n  public hasNext(): boolean {\n    return this._current < this._endIndex;\n  }\n\n  public next(): IBufferStringIteratorResult {\n    const range = this._buffer.getWrappedRangeForLine(this._current);\n    // limit search window to overscan value at both borders\n    if (range.first < this._startIndex - this._startOverscan) {\n      range.first = this._startIndex - this._startOverscan;\n    }\n    if (range.last > this._endIndex + this._endOverscan) {\n      range.last = this._endIndex + this._endOverscan;\n    }\n    // limit to current buffer length\n    range.first = Math.max(range.first, 0);\n    range.last = Math.min(range.last, this._buffer.lines.length);\n    let result = '';\n    for (let i = range.first; i <= range.last; ++i) {\n      result += this._buffer.translateBufferLineToString(i, this._trimRight);\n    }\n    this._current = range.last + 1;\n    return {range: range, content: result};\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport * as Strings from './Strings';\nimport { ITerminal, IBuffer } from './Types';\nimport { isMac } from './common/Platform';\nimport { RenderDebouncer } from './ui/RenderDebouncer';\nimport { addDisposableDomListener } from './ui/Lifecycle';\nimport { Disposable } from './common/Lifecycle';\n\nconst MAX_ROWS_TO_READ = 20;\n\nconst enum BoundaryPosition {\n  TOP,\n  BOTTOM\n}\n\nexport class AccessibilityManager extends Disposable {\n  private _accessibilityTreeRoot: HTMLElement;\n  private _rowContainer: HTMLElement;\n  private _rowElements: HTMLElement[];\n  private _liveRegion: HTMLElement;\n  private _liveRegionLineCount: number = 0;\n\n  private _renderRowsDebouncer: RenderDebouncer;\n\n  private _topBoundaryFocusListener: (e: FocusEvent) => void;\n  private _bottomBoundaryFocusListener: (e: FocusEvent) => void;\n\n  /**\n   * This queue has a character pushed to it for keys that are pressed, if the\n   * next character added to the terminal is equal to the key char then it is\n   * not announced (added to live region) because it has already been announced\n   * by the textarea event (which cannot be canceled). There are some race\n   * condition cases if there is typing while data is streaming, but this covers\n   * the main case of typing into the prompt and inputting the answer to a\n   * question (Y/N, etc.).\n   */\n  private _charsToConsume: string[] = [];\n\n  constructor(private _terminal: ITerminal) {\n    super();\n    this._accessibilityTreeRoot = document.createElement('div');\n    this._accessibilityTreeRoot.classList.add('xterm-accessibility');\n\n    this._rowContainer = document.createElement('div');\n    this._rowContainer.classList.add('xterm-accessibility-tree');\n    this._rowElements = [];\n    for (let i = 0; i < this._terminal.rows; i++) {\n      this._rowElements[i] = this._createAccessibilityTreeNode();\n      this._rowContainer.appendChild(this._rowElements[i]);\n    }\n\n    this._topBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.TOP);\n    this._bottomBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.BOTTOM);\n    this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);\n    this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);\n\n    this._refreshRowsDimensions();\n    this._accessibilityTreeRoot.appendChild(this._rowContainer);\n\n    this._renderRowsDebouncer = new RenderDebouncer(this._renderRows.bind(this));\n    this._refreshRows();\n\n    this._liveRegion = document.createElement('div');\n    this._liveRegion.classList.add('live-region');\n    this._liveRegion.setAttribute('aria-live', 'assertive');\n    this._accessibilityTreeRoot.appendChild(this._liveRegion);\n\n    this._terminal.element.insertAdjacentElement('afterbegin', this._accessibilityTreeRoot);\n\n    this.register(this._renderRowsDebouncer);\n    this.register(this._terminal.onResize(e => this._onResize(e.rows)));\n    this.register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));\n    this.register(this._terminal.onScroll(() => this._refreshRows()));\n    // Line feed is an issue as the prompt won't be read out after a command is run\n    this.register(this._terminal.addDisposableListener('a11y.char', (char) => this._onChar(char)));\n    this.register(this._terminal.onLineFeed(() => this._onChar('\\n')));\n    this.register(this._terminal.addDisposableListener('a11y.tab', spaceCount => this._onTab(spaceCount)));\n    this.register(this._terminal.onKey(e => this._onKey(e.key)));\n    this.register(this._terminal.addDisposableListener('blur', () => this._clearLiveRegion()));\n    // TODO: Maybe renderer should fire an event on terminal when the characters change and that\n    //       should be listened to instead? That would mean that the order of events are always\n    //       guarenteed\n    this.register(this._terminal.addDisposableListener('dprchange', () => this._refreshRowsDimensions()));\n    this.register(this._terminal.renderer.onCanvasResize(() => this._refreshRowsDimensions()));\n    // This shouldn't be needed on modern browsers but is present in case the\n    // media query that drives the dprchange event isn't supported\n    this.register(addDisposableDomListener(window, 'resize', () => this._refreshRowsDimensions()));\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._terminal.element.removeChild(this._accessibilityTreeRoot);\n    this._rowElements.length = 0;\n  }\n\n  private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {\n    const boundaryElement = <HTMLElement>e.target;\n    const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];\n\n    // Don't scroll if the buffer top has reached the end in that direction\n    const posInSet = boundaryElement.getAttribute('aria-posinset');\n    const lastRowPos = position === BoundaryPosition.TOP ? '1' : `${this._terminal.buffer.lines.length}`;\n    if (posInSet === lastRowPos) {\n      return;\n    }\n\n    // Don't scroll when the last focused item was not the second row (focus is going the other\n    // direction)\n    if (e.relatedTarget !== beforeBoundaryElement) {\n      return;\n    }\n\n    // Remove old boundary element from array\n    let topBoundaryElement: HTMLElement;\n    let bottomBoundaryElement: HTMLElement;\n    if (position === BoundaryPosition.TOP) {\n      topBoundaryElement = boundaryElement;\n      bottomBoundaryElement = this._rowElements.pop()!;\n      this._rowContainer.removeChild(bottomBoundaryElement);\n    } else {\n      topBoundaryElement = this._rowElements.shift()!;\n      bottomBoundaryElement = boundaryElement;\n      this._rowContainer.removeChild(topBoundaryElement);\n    }\n\n    // Remove listeners from old boundary elements\n    topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);\n    bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);\n\n    // Add new element to array/DOM\n    if (position === BoundaryPosition.TOP) {\n      const newElement = this._createAccessibilityTreeNode();\n      this._rowElements.unshift(newElement);\n      this._rowContainer.insertAdjacentElement('afterbegin', newElement);\n    } else {\n      const newElement = this._createAccessibilityTreeNode();\n      this._rowElements.push(newElement);\n      this._rowContainer.appendChild(newElement);\n    }\n\n    // Add listeners to new boundary elements\n    this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);\n    this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);\n\n    // Scroll up\n    this._terminal.scrollLines(position === BoundaryPosition.TOP ? -1 : 1);\n\n    // Focus new boundary before element\n    this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2].focus();\n\n    // Prevent the standard behavior\n    e.preventDefault();\n    e.stopImmediatePropagation();\n  }\n\n  private _onResize(rows: number): void {\n    // Remove bottom boundary listener\n    this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);\n\n    // Grow rows as required\n    for (let i = this._rowContainer.children.length; i < this._terminal.rows; i++) {\n      this._rowElements[i] = this._createAccessibilityTreeNode();\n      this._rowContainer.appendChild(this._rowElements[i]);\n    }\n    // Shrink rows as required\n    while (this._rowElements.length > rows) {\n      this._rowContainer.removeChild(this._rowElements.pop()!);\n    }\n\n    // Add bottom boundary listener\n    this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);\n\n    this._refreshRowsDimensions();\n  }\n\n  private _createAccessibilityTreeNode(): HTMLElement {\n    const element = document.createElement('div');\n    element.setAttribute('role', 'listitem');\n    element.tabIndex = -1;\n    this._refreshRowDimensions(element);\n    return element;\n  }\n\n  private _onTab(spaceCount: number): void {\n    for (let i = 0; i < spaceCount; i++) {\n      this._onChar(' ');\n    }\n  }\n\n  private _onChar(char: string): void {\n    if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {\n      if (this._charsToConsume.length > 0) {\n        // Have the screen reader ignore the char if it was just input\n        const shiftedChar = this._charsToConsume.shift();\n        if (shiftedChar !== char) {\n          this._announceCharacter(char);\n        }\n      } else {\n        this._announceCharacter(char);\n      }\n\n      if (char === '\\n') {\n        this._liveRegionLineCount++;\n        if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) {\n          this._liveRegion.textContent += Strings.tooMuchOutput;\n        }\n      }\n\n      // Only detach/attach on mac as otherwise messages can go unaccounced\n      if (isMac) {\n        if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {\n          setTimeout(() => {\n            this._accessibilityTreeRoot.appendChild(this._liveRegion);\n          }, 0);\n        }\n      }\n    }\n  }\n\n  private _clearLiveRegion(): void {\n    this._liveRegion.textContent = '';\n    this._liveRegionLineCount = 0;\n\n    // Only detach/attach on mac as otherwise messages can go unaccounced\n    if (isMac) {\n      if (this._liveRegion.parentNode) {\n        this._accessibilityTreeRoot.removeChild(this._liveRegion);\n      }\n    }\n  }\n\n  private _onKey(keyChar: string): void {\n    this._clearLiveRegion();\n    this._charsToConsume.push(keyChar);\n  }\n\n  private _refreshRows(start?: number, end?: number): void {\n    this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);\n  }\n\n  private _renderRows(start: number, end: number): void {\n    const buffer: IBuffer = this._terminal.buffer;\n    const setSize = buffer.lines.length.toString();\n    for (let i = start; i <= end; i++) {\n      const lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);\n      const posInSet = (buffer.ydisp + i + 1).toString();\n      const element = this._rowElements[i];\n      if (element) {\n        element.textContent = lineData.length === 0 ? Strings.blankLine : lineData;\n        element.setAttribute('aria-posinset', posInSet);\n        element.setAttribute('aria-setsize', setSize);\n      }\n    }\n  }\n\n  private _refreshRowsDimensions(): void {\n    if (!this._terminal.renderer.dimensions.actualCellHeight) {\n      return;\n    }\n    if (this._rowElements.length !== this._terminal.rows) {\n      this._onResize(this._terminal.rows);\n    }\n    for (let i = 0; i < this._terminal.rows; i++) {\n      this._refreshRowDimensions(this._rowElements[i]);\n    }\n  }\n\n  private _refreshRowDimensions(element: HTMLElement): void {\n    element.style.height = `${this._terminal.renderer.dimensions.actualCellHeight}px`;\n  }\n\n  private _announceCharacter(char: string): void {\n    if (char === ' ') {\n      // Always use nbsp for spaces in order to preserve the space between characters in\n      // voiceover's caption window\n      this._liveRegion.innerHTML += ' ';\n    } else {\n      this._liveRegion.textContent += char;\n    }\n  }\n}\n",null],"names":[],"mappings":"A0DAA;;;;;;;;;;;;;;;;ADKA;AAEA;AACA;AACA;AACA;AAEA;AAOA;AAAA;AAuBA;AAAA;AAAA;AAlBA;AAgBA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAIA;AACA;AAGA;;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AAGA;AAGA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAGA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAzQa;;;;;;;;;;;;;;;;;;ADdb;AAGA;AACA;AACA;AACA;AACA;AAEa;AAEA;AAEA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAOA;AACA;AACA;AASb;AAwBA;AACA;AACA;AAfA;AACA;AACA;AACA;AAcA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAAA;AACA;AACA;AACA;AACA;;;AAAA;AAOA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAEA;AAIA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAGA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AApkBa;AAskBb;AAAA;AAWA;AAAA;AACA;AATA;AACA;AAIA;;AAOA;AATA;AAAA;;;AAAA;AAGA;AAAA;;;AAAA;AAQA;AACA;AACA;AACA;AACA;AAEA;AACA;AAvBA;AAwBA;AAAA;AAzBa;AAuCb;AAGA;AAGA;AACA;AACA;AACA;AALA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA3Ca;;;;;;;;;;;;;;;;;;ADzpBb;AACA;AAaA;AAmHA;AAAA;AAoBA;AACA;AAsCA;AA1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA3Da;AAgEb;AAAA;AAAA;AAAA;AAUA;AACA;AACA;AACA;;AAuEA;AAjFA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AApFa;AAsGb;AAKA;AAAA;AAAA;AAJA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAMA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAOA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AAEA;AACA;AAAA;AACA;AAIA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AApVa;;;;;ADxRb;AAGA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAlFA;AAyFA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3BA;AAmCA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAZA;AA4BA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AA/BA;AAiCA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAdA;;;;;ADvMA;AACA;AAMA;AAaA;AAAA;AAPA;AAQA;AACA;AAIA;AACA;AAEA;AACA;AAhBA;AAAA;;;AAAA;AAqBA;AAAA;AACA;AACA;;;AAAA;AAKA;AAAA;AACA;AACA;;;AAAA;AAKA;AAAA;AACA;AACA;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AAvGa;;;;;ADPb;AAOA;AAUA;AAHA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA;AAAA;;;AAAA;AAYA;AAAA;AACA;AACA;;;AAAA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA5Ca;;;;;ADRb;AAEa;AAGb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AAGA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3BA;;;;;AD3HA;AACA;AACA;AAFA;AAQA;AACA;AACA;AACA;AACA;AACA;AALA;AAWA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AATA;AAgBA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAzBA;AAgCA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3BA;AAoCA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAVA;;;;;AD1GA;AAwBA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAOA;AACA;AACA;AAEA;AACA;AAAA;AAEA;AACA;AAGA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AAUA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AAUA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAAA;AArNa;;;;;;;;;;;;;;;;;;ADVb;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAGA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AAAA;AAhCa;AAsCb;AACA;AACA;AACA;AAEA;AAMa;AACb;AAEA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AAIA;AAHA;AACA;AACA;AACA;AAAA;AAcA;AAAA;AA4BA;AAAA;AAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AAIA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AAGA;AAGA;AACA;AACA;AAAA;AAzZa;;;;;;;;;;;;;;;;;;ADvNb;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAKA;AAaA;AAGA;AAAA;AAFA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AA6BA;AAAA;AAcA;AAEA;AAFA;AACA;AACA;AAfA;AACA;AACA;AAEA;AAEA;AAEA;AAEA;AASA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAMA;AAGA;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAPA;AAAA;AAQA;AAKA;AACA;AACA;AACA;AAKA;;AACA;AAlLA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AA8KA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAIA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAOA;AACA;AAIA;AACA;AAAA;AACA;AACA;AACA;AACA;AAOA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AAAA;AACA;AAGA;AACA;AAEA;AACA;AAGA;AAEA;AAIA;AACA;AACA;AACA;AAGA;AAKA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AAMA;AACA;AACA;AAMA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAOA;AACA;AACA;AAMA;AACA;AAKA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AASA;AAAA;AACA;AACA;AAKA;AACA;AACA;AACA;AAOA;AACA;AACA;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAMA;AACA;AAKA;AACA;AAKA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AAKA;AAKA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAEA;AACA;AACA;AACA;AAKA;AAuCA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AAIA;AACA;AACA;AAAA;AACA;AACA;AAAA;AAGA;AACA;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAOA;AACA;AAAA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAwFA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoFA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAmEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAGA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAyBA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AAGA;AACA;AAGA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AAQA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AASA;AACA;AACA;AASA;AACA;AACA;AAOA;AACA;AACA;AACA;AAYA;AACA;AACA;AACA;AAAA;AAv3Da;;;;;ADlGb;AACA;AACA;AAKA;AA6BA;AACA;AAfA;AAIA;AAGA;AAEA;AAEA;AAMA;AACA;AACA;AACA;AACA;AAbA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAeA;AACA;AACA;AAOA;AAAA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AAYA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAYA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AAAA;AAEA;AACA;AACA;;AAEA;AACA;AAIA;AACA;AACA;AACA;;AAEA;AAMA;AACA;AACA;;AAGA;AAGA;AACA;;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;;;AAlDA;;;;AAmDA;AACA;AAUA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AA3SA;AAOA;AAqSA;AAAA;AAlTa;;;;;ADLb;AACA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAeA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAKA;AACA;AAEA;AACA;AAYA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAAA;AArEa;;;;;;;;;;;;;;;;;;ADFb;AACA;AAEA;AAUA;AAAA;AAaA;AAAA;AACA;AAbA;AAEA;AAKA;AACA;AACA;AAQA;AAGA;AACA;AACA;;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AAGA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAGA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAlNa;AAoNb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAba;;;;;ADjOb;AACA;AAEA;AACA;AACA;AAEA;AAMA;AAKA;AAKA;AAMA;AAMA;AAEA;AACA;AA4BA;AA4CA;AACA;AACA;AAlBA;AAKA;AAIA;AAEA;AAEA;AAOA;AACA;AAEA;AACA;AACA;AAfA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAaA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAKA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAKA;AACA;AACA;AAEA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;AACA;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AAOA;AAAA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AAGA;AAGA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AAAA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAIA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAOA;AAIA;AAIA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AAKA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAGA;AACA;AAAA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAKA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAIA;AAEA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAOA;AAGA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAn1Ba;;;;;AD7Db;AAuBA;AACA;AAEA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;;;AAAA;AAMA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AA5Ha;;;;;ADAA;AAEb;AAeA;AACA;AAEA;AAfA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AAAA;AApDa;;;;;ADRF;AACA;AACA;;;;;;;;;;;;;;;;;;ADkBX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAEA;AAGA;AAOA;AAQA;AAEA;AACA;AAKA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAyIA;AACA;AADA;AAvHA;AAmFA;AAKA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAmBA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAhDA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AAKA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AAGA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAKA;AAAA;AACA;AACA;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAMA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAKA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAKA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AAAA;AACA;AAEA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAGA;AACA;AAGA;AAGA;AAGA;AAIA;AAEA;AAEA;AAAA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AAAA;AACA;AACA;AACA;AAKA;AACA;AACA;AAGA;AAGA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAIA;AACA;AACA;AAIA;AACA;AACA;AACA;AAAA;AAIA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AAOA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAGA;AAEA;AACA;AAAA;AACA;AACA;AAGA;AAEA;AACA;AAEA;AAIA;AACA;AAKA;AACA;AACA;AAGA;AAIA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AAGA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAIA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AACA;AACA;AAIA;AACA;AACA;AAGA;AACA;AAEA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAEA;AAKA;AAGA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AAQA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAWA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAKA;AACA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAQA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AAMA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAQA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAGA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAAA;AACA;AAAA;AACA;AACA;AAKA;AACA;AAAA;AACA;AAAA;AACA;AACA;AAQA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AAAA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAMA;AACA;AAAA;AACA;AAAA;AAOA;AAKA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAMA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAOA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AAEA;AACA;AAGA;AACA;AAAA;AAxyDa;AA8yDb;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AD/5DA;AACA;AAEA;AAMA;AAAA;AAwBA;AAAA;AACA;AACA;AACA;AACA;AA3BA;AACA;AACA;AACA;AACA;AAEA;AAKA;AAEA;AACA;AAoBA;AACA;AAGA;;AACA;AAEA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAGA;AACA;AACA;AAEA;AACA;AAKA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAOA;AAEA;AAIA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAOA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA3Na;;;;;ADVb;AAEA;AAWA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AApBA;;;;;ADHA;AAgBA;AAYA;AACA;AARA;AAEA;AAEA;AAMA;AACA;AACA;AACA;AAZA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAUA;AAAA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAjBA;AAmBA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AATA;AAmBA;AACA;AACA;AAUA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAAA;AACA;AACA;;;AAAA;AAMA;AACA;AACA;AAWA;AAAA;AAAA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AAAA;AApNa;;;;;ADdb;AAAA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AAEA;AAEA;AACA;AAEA;AACA;AAnBA;;;;;;;;;;;;;;;;;;ADFA;AAEA;AAAA;AAGA;AAAA;AAIA;;AACA;AAEA;AACA;AACA;AACA;AAOA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAzFa;;;;;ADOb;AAAA;AACA;AAgCA;AA7BA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAjCa;;;;;ADJb;AAIA;AAHA;AACA;AAGA;AAKA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAnCsB;;;;;ADItB;AACA;AACA;AAEa;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAOb;AACA;AACA;;;;;ADzBA;AAEA;AACA;AACA;AACA;AACA;AANA;AAQA;AAAA;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBA;AAwBA;AACA;AACA;AACA;AACA;AACA;AALA;;;;;ADrCA;AAAA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AACA;AAMA;AAAA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AAEA;AACA;;;;;ADzIa;AAKA;AAYb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAMA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ADtPA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AArUA;;;;;AD7BA;AAAA;AACA;AA8DA;AAzDA;AACA;AACA;AAUA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA/Da;AAoEb;AACA;AAEA;AACA;AACA;AACA;AACA;AAPA;AAcA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAjBA;;;;;ADpFA;AASA;AAOA;;AACA;AACA;AAEA;AACA;AACA;AAEA;AASA;AACA;;AAEA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAOA;AAEA;AACA;AACA;AAGA;AACA;AAOA;AACA;AACA;AACA;AACA;AAIA;AAMA;AACA;AACA;AAEA;AAEA;AACA;AAKA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AAIA;AAEA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AASA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAWA;AAOA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAMA;AACA;AACA;AACA;AACA;AAAA;AA5Oa;AAoPb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ADpQA;AACA;AAGA;AAGA;AACA;AACA;AAEA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AAAA;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;;;AAAA;AACA;AAAA;AA/Ja;;;;;ADJb;AAEA;AACA;AACA;AACA;AAEA;AAyBA;AACA;AAGA;AACA;AA3BA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AAWA;AACA;AAKA;AAQA;AAAA;AACA;AAKA;AAQA;AACA;AAKA;AAQA;AACA;AACA;AAKA;AAKA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AAKA;AAAA;AACA;AACA;AAKA;AACA;AAYA;AACA;AACA;AACA;AACA;AAIA;AAgBA;AAMA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAaA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AAIA;AACA;AAOA;AACA;AACA;AAKA;AACA;AAOA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAhXsB;;;;;;;;;;;;;;;;;;ADZtB;AACA;AAEA;AAAA;AASA;AAAA;AALA;AAGA;AAIA;AACA;AACA;AACA;;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AA3Ca;AA6Cb;AAMA;AAAA;AAJA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAMA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAGA;AAGA;AACA;AAOA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AAOA;AACA;AACA;AACA;AAEA;AACA;AAUA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AAGA;AAGA;AACA;AACA;AAMA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAIA;AACA;AAIA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAGA;AACA;AAAA;AACA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AA9Qa;;;;;AD1Cb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIa;AACb;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAKA;AAKA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAEA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAiBA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAtGa;;;;;;;;;;;;;;;;;;AD7Eb;AAEA;AAaA;AAEA;AAAA;AAMA;AAAA;AAFA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AArMa;AAuMb;AAcA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AAMA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAGA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;;;;;AD1VA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA3Ba;;;;;;;;;;;;;;;;;;ADEb;AACA;AACA;AAEA;AAAA;AAGA;AAAA;AAFA;AAIA;AACA;;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAAA;AACA;AACA;AAEA;AAEA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AA1Da;;;;;;;;;;;;;;;;;;ADNb;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AAkBA;AAAA;AAAA;AAZA;AACA;AAMA;AAEA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;;AACA;AAjDA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AAiDA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AAEA;AAGA;AAGA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AAKA;AAEA;AACA;AACA;AAMA;AAKA;AAMA;AAIA;AAGA;AAIA;AAIA;AACA;AAOA;AACA;AAQA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAhQa;;;;;;;;;;;;;;;;;;ADZb;AASA;AAAA;AAGA;AAAA;AAEA;;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AAGA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAtGa;;;;;;;;;;;;;;;;;;ADXb;AAGA;AACA;AACA;AACA;AASA;AAAA;AAQA;AAAA;AAJA;AAEA;AAIA;AACA;;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAIA;AACA;AACA;AAKA;AACA;AACA;AAKA;AAOA;AACA;AAMA;AAQA;AAEA;AACA;AAMA;AACA;AAEA;AAMA;AACA;AACA;AACA;AAMA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAGA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAKA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAGA;AACA;AAKA;AAGA;AAGA;AACA;AACA;AAgBA;AAAA;AAlSa;;;;;ADZb;AAAA;AACA;AA8CA;AA5CA;AAMA;AACA;AACA;AACA;AACA;AACA;AAMA;AASA;AAkBA;AAAA;;;;;;ADhDA;AAEA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAUA;AAQA;AAMA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AA/CA;AAqDA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AAfA;;;;;ADnFA;AAEA;AAQA;AACA;AACA;AACA;AAIA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AAEA;AACA;AAEA;AAGA;AAEA;AACA;AAvFA;AA6FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAfA;AAiBA;AACA;AACA;;;;;ADzHA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBA;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAjBA;AAmBA;AACA;AACA;AAFA;;;;;;;;;;;;;;;;;;ADjDA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AACA;AACA;AAQA;AAMA;AAQA;AAUA;AACA;AAXA;AAaA;AAAA;AA2BA;AAAA;AAAA;AAXA;AAGA;AAGA;AAGA;AAIA;AACA;AACA;AAIA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAOA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAQA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAOA;AACA;AACA;AACA;AACA;AACA;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAIA;AACA;AAEA;AAGA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AAIA;AAGA;AACA;AACA;AACA;AAGA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AAKA;AACA;AACA;AAGA;AAGA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AAIA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAAA;;;;;;AD7TA;AAOA;AAAA;AANA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;;;;;;;;;;;;;;;;;;;AD/HA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AAAA;;;;;;;;;;;;;;;;;;;ADlBA;AACA;AACA;AACA;AAEA;AAAA;AAGA;AAAA;AAAA;AAAA;AAIA;AACA;AACA;AACA;AAKA;AACA;;AAXA;AAaA;AAAA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AAGA;AACA;AACA;AAEA;AAYA;AAEA;AACA;AACA;AAAA;;;;;;AD3Fa;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;ADJb;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAUA;AAAA;AAmBA;AAAA;AAAA;AAhBA;AAKA;AAMA;AAEA;AAKA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;;AACA;AA5CA;AAAA;;;AAAA;AAEA;AAAA;;;AAAA;AA4CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AAEA;AACA;AAGA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAQA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AA5Wa;;;;;AD3Bb;AAEA;AACA;AAEa;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEb;AAGA;AACA;AACA;AAJA;AAMA;AAEA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AA9Ga;;;;;ADRb;AAMA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAhBA;;;;;ADFA;AAMA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AAGA;AACA;AAGA;AAGA;AACA;AACA;AACA;AACA;AAAA;AApDa;;;;;;;;;;;;;;;;;;ADLb;AAcA;AAAA;AAAA;AAAA;AACA;;AAgDA;AA3CA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAjDa;;;;;ADZb;AAEA;"}
\ No newline at end of file
+{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/common/services/Services.ts","webpack:///./src/common/EventEmitter.ts","webpack:///./src/common/Lifecycle.ts","webpack:///./src/common/buffer/Constants.ts","webpack:///./src/browser/services/Services.ts","webpack:///./src/common/buffer/CellData.ts","webpack:///./src/common/buffer/AttributeData.ts","webpack:///./src/browser/Lifecycle.ts","webpack:///./src/common/input/TextDecoder.ts","webpack:///./src/browser/renderer/atlas/Constants.ts","webpack:///./src/browser/Color.ts","webpack:///./src/common/Platform.ts","webpack:///./src/common/data/EscapeSequences.ts","webpack:///./src/browser/renderer/BaseRenderLayer.ts","webpack:///./src/common/services/ServiceRegistry.ts","webpack:///./src/common/TypedArrayUtils.ts","webpack:///./src/common/buffer/BufferLine.ts","webpack:///./src/browser/LocalizableStrings.ts","webpack:///./src/common/data/Charsets.ts","webpack:///./src/common/CharWidth.ts","webpack:///./src/common/parser/Params.ts","webpack:///./src/common/parser/OscParser.ts","webpack:///./src/common/parser/Constants.ts","webpack:///./src/common/parser/DcsParser.ts","webpack:///./src/browser/renderer/atlas/CharAtlasCache.ts","webpack:///./src/browser/renderer/atlas/CharAtlasUtils.ts","webpack:///./src/browser/ColorManager.ts","webpack:///./src/browser/renderer/RendererUtils.ts","webpack:///./src/browser/renderer/CharacterJoinerRegistry.ts","webpack:///./src/browser/input/Mouse.ts","webpack:///./src/browser/RenderDebouncer.ts","webpack:///./src/browser/ScreenDprMonitor.ts","webpack:///./src/common/Clone.ts","webpack:///./src/public/Terminal.ts","webpack:///./src/Terminal.ts","webpack:///./src/browser/input/CompositionHelper.ts","webpack:///./src/browser/Viewport.ts","webpack:///./src/browser/Clipboard.ts","webpack:///./src/InputHandler.ts","webpack:///./src/common/parser/EscapeSequenceParser.ts","webpack:///./src/browser/renderer/Renderer.ts","webpack:///./src/browser/renderer/TextRenderLayer.ts","webpack:///./src/browser/renderer/GridCache.ts","webpack:///./src/browser/renderer/atlas/DynamicCharAtlas.ts","webpack:///./src/browser/renderer/atlas/BaseCharAtlas.ts","webpack:///./src/browser/ColorContrastCache.ts","webpack:///./src/browser/renderer/atlas/LRUMap.ts","webpack:///./src/browser/renderer/SelectionRenderLayer.ts","webpack:///./src/browser/renderer/CursorRenderLayer.ts","webpack:///./src/browser/renderer/LinkRenderLayer.ts","webpack:///./src/browser/Linkifier.ts","webpack:///./src/browser/services/SelectionService.ts","webpack:///./src/browser/selection/SelectionModel.ts","webpack:///./src/browser/input/MoveToCell.ts","webpack:///./src/browser/services/SoundService.ts","webpack:///./src/browser/MouseZoneManager.ts","webpack:///./src/AccessibilityManager.ts","webpack:///./src/browser/renderer/dom/DomRenderer.ts","webpack:///./src/browser/renderer/dom/DomRendererRowFactory.ts","webpack:///./src/common/input/Keyboard.ts","webpack:///./src/common/WindowsMode.ts","webpack:///./src/browser/services/RenderService.ts","webpack:///./src/common/services/OptionsService.ts","webpack:///./src/browser/services/CharSizeService.ts","webpack:///./src/common/services/BufferService.ts","webpack:///./src/common/buffer/BufferSet.ts","webpack:///./src/common/buffer/Buffer.ts","webpack:///./src/common/CircularList.ts","webpack:///./src/common/buffer/BufferReflow.ts","webpack:///./src/common/buffer/Marker.ts","webpack:///./src/browser/services/MouseService.ts","webpack:///./src/common/services/CoreService.ts","webpack:///./src/common/services/LogService.ts","webpack:///./src/common/services/DirtyRowService.ts","webpack:///./src/common/services/InstantiationService.ts","webpack:///./src/common/services/CoreMouseService.ts","webpack:///./src/common/input/WriteBuffer.ts","webpack:///./src/browser/services/CoreBrowserService.ts","webpack:///./src/public/AddonManager.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","IBufferService","createDecorator","ICoreMouseService","ICoreService","IDirtyRowService","IInstantiationService","ILogService","IOptionsService","_listeners","_disposed","this","_event","listener","push","dispose","length","splice","fire","data","queue","undefined","EventEmitter","_disposables","_isDisposed","forEach","register","unregister","index","indexOf","Disposable","DEFAULT_COLOR","DEFAULT_ATTR","CHAR_DATA_ATTR_INDEX","CHAR_DATA_CHAR_INDEX","CHAR_DATA_WIDTH_INDEX","CHAR_DATA_CODE_INDEX","NULL_CELL_CHAR","NULL_CELL_WIDTH","NULL_CELL_CODE","WHITESPACE_CELL_CHAR","WHITESPACE_CELL_WIDTH","WHITESPACE_CELL_CODE","ICharSizeService","ICoreBrowserService","IMouseService","IRenderService","ISelectionService","ISoundService","content","fg","bg","combinedData","fromCharData","obj","CellData","setFromCharData","isCombined","getWidth","getChars","stringFromCodePoint","getCode","charCodeAt","combined","code","second","getAsCharData","AttributeData","toColorRGB","fromColorRGB","clone","newObj","isInverse","isBold","isUnderline","isBlink","isInvisible","isItalic","isDim","getFgColorMode","getBgColorMode","isFgRGB","isBgRGB","isFgPalette","isBgPalette","isFgDefault","isBgDefault","getFgColor","getBgColor","node","type","handler","useCapture","addEventListener","removeEventListener","codePoint","String","fromCharCode","start","end","result","codepoint","_interim","clear","decode","input","target","size","startPos","StringToUtf32","interim","Uint8Array","fill","byte1","byte2","byte3","byte4","discardInterim","cp","pos","tmp","missing","fourStop","Utf8ToUtf32","INVERTED_DEFAULT_COLOR","DIM_OPACITY","CHAR_ATLAS_CELL_SPACING","toPaddedHex","toString","toCss","g","b","toRgba","fromRgba","rgbRelativeLuminance","rgb","rgbRelativeLuminance2","rs","gs","bs","Math","pow","contrastRatio","l1","l2","rgbaToColor","css","rgba","ensureContrastRatioRgba","bgRgba","fgRgba","ratio","bgL","fgL","reduceLuminance","increaseLuminance","bgR","bgG","bgB","fgR","fgG","fgB","cr","max","ceil","min","round","parseInt","slice","color","isNode","navigator","userAgent","platform","contains","arr","el","isFirefox","isSafari","test","isMac","isIpad","isIphone","isWindows","isLinux","C0","NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","FS","GS","RS","US","SP","DEL","C1","PAD","HOP","BPH","NBH","IND","NEL","SSA","ESA","HTS","HTJ","VTS","PLD","PLU","RI","SS2","SS3","DCS","PU1","PU2","STS","CCH","MW","SPA","EPA","SOS","SGCI","SCI","CSI","ST","OSC","PM","APC","_container","id","zIndex","_alpha","_colors","_rendererId","_bufferService","_optionsService","_scaledCharWidth","_scaledCharHeight","_scaledCellWidth","_scaledCellHeight","_scaledCharLeft","_scaledCharTop","_currentGlyphIdentifier","chars","bold","dim","italic","_canvas","document","createElement","classList","add","style","_initCanvas","appendChild","removeChild","_charAtlas","_ctx","throwIfFalsy","getContext","alpha","_clearAll","onOptionsChanged","onBlur","onFocus","onCursorMove","onGridChanged","startRow","endRow","onSelectionChanged","columnSelectMode","setColors","colorSet","_refreshCharAtlas","_setTransparency","oldCanvas","cloneNode","replaceChild","rows","acquireCharAtlas","options","warmUp","resize","scaledCellWidth","scaledCellHeight","scaledCharWidth","scaledCharHeight","scaledCharLeft","scaledCharTop","width","scaledCanvasWidth","height","scaledCanvasHeight","canvasWidth","canvasHeight","_fillCells","x","y","fillRect","_fillBottomLineAtCells","devicePixelRatio","_fillLeftLineAtCell","_strokeRectAtCell","lineWidth","strokeRect","clearRect","fillStyle","background","_clearCells","_fillCharTrueColor","cell","font","_getFont","textBaseline","_clipRow","fillText","_drawChars","contrastColor","_getContrastColor","_drawUncachedChars","drawBoldTextInBrightColors","draw","fgOverride","save","opaque","join","ansi","foreground","globalAlpha","restore","beginPath","rect","cols","clip","fontWeightBold","fontWeight","fontSize","fontFamily","minimumContrastRatio","adjustedColor","contrastCache","getColor","fgColor","fgColorMode","bgColor","bgColorMode","temp","temp2","_resolveBackgroundRgba","_resolveForegroundRgba","setColor","inverse","BaseRenderLayer","DI_TARGET","DI_DEPENDENCIES","storeServiceDependency","serviceRegistry","Map","ctor","has","decorator","arguments","Error","set","fillFallback","array","constructor","CELL_SIZE","DEFAULT_ATTR_DATA","freeze","fillCellData","isWrapped","_combined","_data","Uint32Array","setCell","hasWidth","getFg","getBg","hasContent","getCodePoint","getString","loadCell","startIndex","setCellFromCodePoint","addCodepointToCell","insertCells","deleteCells","replaceCells","subarray","keys","copyFrom","line","newLine","BufferLine","getTrimmedLength","copyCellsFrom","src","srcCol","destCol","applyInReverse","srcData","srcCombinedKeys","translateToString","trimRight","startCol","endCol","promptLabel","tooMuchOutput","CHARSETS","DEFAULT_CHARSET","wcwidth","opts","COMBINING_BMP","COMBINING_HIGH","control","table","nul","num","ucs","mid","bisearch","MAX_SUBPARAMS","maxLength","maxSubParamsLength","params","Int32Array","_subParams","_subParamsLength","_subParamsIdx","Uint16Array","_rejectDigits","_rejectSubDigits","_digitIsSub","fromArray","values","Params","Array","k","addSubParam","addParam","newParams","toArray","res","reset","hasSubParams","idx","getSubParams","getSubParamsAll","addDigit","store","cur","_state","_id","_handlers","_handlerFb","addHandler","ident","handlerList","handlerIndex","setHandler","clearHandler","setHandlerFallback","_start","handlers","j","_put","put","utf32ToString","_end","success","OscParser","_handler","_hitLimit","PAYLOAD_LIMIT","ret","OscHandler","EMPTY_HANDLERS","_active","_ident","unhook","hook","DcsParser","_params","DcsHandler","charAtlasCache","rendererId","colors","newConfig","generateConfig","ownedByIndex","entry","ownedBy","configEquals","config","atlas","newEntry","DynamicCharAtlas","clonedColors","cursor","cursorAccent","selection","allowTransparency","colorCode","DEFAULT_FOREGROUND","fromCss","DEFAULT_BACKGROUND","DEFAULT_CURSOR","DEFAULT_CURSOR_ACCENT","DEFAULT_SELECTION","DEFAULT_ANSI_COLORS","v","canvas","ctx","globalCompositeOperation","_litmusColor","createLinearGradient","_contrastCache","ColorContrastCache","selectionOpaque","blend","onOptionsChange","setTheme","theme","_parseColor","black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite","fallback","console","warn","getImageData","substr","ColorManager","firstCell","_width","JoinedCellData","_characterJoiners","_nextCharacterJoinerId","_workCell","registerCharacterJoiner","joiner","deregisterCharacterJoiner","joinerId","getJoinedCharacters","row","buffer","lines","ranges","lineStr","rangeStartColumn","currentStringIndex","rangeStartStringIndex","rangeAttrFG","rangeAttrBG","joinedRanges","_getJoinedRanges","endIndex","lineData","text","substring","joinerRanges","CharacterJoinerRegistry","_mergeRanges","_stringRangesToCellRanges","currentRangeIndex","currentRangeStarted","currentRange","newRange","inRange","range","getCoordsRelativeToElement","event","element","getBoundingClientRect","clientX","left","clientY","top","colCount","rowCount","hasValidCharSize","actualCellWidth","actualCellHeight","isSelection","coords","_renderCallback","_animationFrame","cancelAnimationFrame","refresh","rowStart","rowEnd","_rowCount","_rowStart","_rowEnd","requestAnimationFrame","_innerRefresh","RenderDebouncer","_currentDevicePixelRatio","setListener","_listener","clearListener","_outerListener","_updateDpr","_resolutionMediaMatchList","removeListener","matchMedia","addListener","ScreenDprMonitor","val","depth","clonedObject","isArray","_core","Terminal","_addonManager","AddonManager","onLineFeed","onSelectionChange","onData","onBinary","onTitleChange","onScroll","onKey","onRender","onResize","_parser","ParserApi","textarea","BufferApiView","markers","blur","focus","columns","_verifyIntegers","open","parent","attachCustomKeyEventHandler","customKeyEventHandler","registerLinkMatcher","regex","deregisterLinkMatcher","matcherId","addMarker","cursorYOffset","hasSelection","select","column","getSelection","getSelectionPosition","clearSelection","selectAll","selectLines","scrollLines","amount","scrollPages","pageCount","scrollToTop","scrollToBottom","scrollToLine","write","callback","writeUtf8","writeln","paste","getOption","optionsService","setOption","loadAddon","addon","Strings","Infinity","isNaN","_buffer","ydisp","ybase","getLine","BufferLineApiView","_line","getCell","BufferCellApiView","startColumn","endColumn","_x","addCsiHandler","addDcsHandler","addEscHandler","addOscHandler","browser","Browser","mouseEvents","_keyDownHandled","_blankLine","_onCursorMove","_onData","_onBinary","_onKey","_onLineFeed","_onRender","_onResize","_onScroll","_onSelectionChange","_onTitleChange","_onFocus","_onBlur","onA11yCharEmitter","onA11yTabEmitter","_instantiationService","InstantiationService","OptionsService","setService","createInstance","BufferService","_logService","LogService","_coreService","CoreService","e","_coreMouseService","CoreMouseService","_dirtyRowService","DirtyRowService","_setupOptionsListeners","_setup","_writeBuffer","WriteBuffer","_inputHandler","parse","_windowsMode","_renderService","_customKeyEventHandler","parentNode","_parent","body","applicationKeypad","originMode","insertMode","wraparoundMode","bracketedPasteMode","charset","gcharset","glevel","charsets","curAttrData","_eraseAttrData","currentParam","_userScrolling","InputHandler","linkifier","Linkifier","windowsMode","_enableWindowsMode","handleWindowsModeLineFeed","buffers","active","eraseAttrData","preventScroll","onOptionChange","_charSizeService","measure","setRenderer","_createRenderer","viewport","syncScrollArea","screenReaderMode","_accessibilityManager","AccessibilityManager","setupTabStops","_setTheme","_onTextAreaFocus","ev","sendFocus","triggerDataEvent","updateCursorStyle","showCursor","_onTextAreaBlur","remove","_initGlobal","_bindKeys","addDisposableDomListener","copyHandler","_selectionService","pasteHandlerWrapper","handlePasteEvent","button","rightClickHandler","screenElement","rightClickSelectsWord","moveTextAreaUnderMouseCursor","_keyUp","_keyDown","_keyPress","_compositionHelper","compositionstart","compositionupdate","compositionend","updateCompositionElements","_queueLinkification","_document","ownerDocument","dir","setAttribute","fragment","createDocumentFragment","_viewportElement","_viewportScrollArea","_helperContainer","tabIndex","coreBrowserService","CoreBrowserService","CharSizeService","_compositionView","CompositionHelper","_theme","_colorManager","renderer","RenderService","_soundService","SoundService","_mouseService","MouseService","Viewport","suppressEvent","onThemeChange","onDimensionsChange","SelectionService","onRedrawRequest","onLinuxMouseSelection","_mouseZoneManager","MouseZoneManager","clearAll","attachToDom","onMouseDown","disable","enable","bindMouse","rendererType","Renderer","DomRenderer","self","sendEvent","but","action","getRawByteCoords","overrideType","buttons","deltaY","triggerMouseEvent","col","ctrl","ctrlKey","alt","altKey","shift","shiftKey","requestedEvents","mouseup","wheel","mousedrag","mousemove","eventListeners","cancel","preventDefault","onProtocolChange","events","logLevel","debug","explainEvents","activeProtocol","shouldForceSelection","hasScrollback","getLinesScrolled","sequence","decPrivateModes","applicationCursorKeys","abs","onWheel","onTouchStart","onTouchMove","refreshRows","linkifyRows","shouldColumnSelect","isCursorInitialized","scroll","eraseAttr","getBlankLine","topRow","scrollTop","bottomRow","scrollBottom","willBufferBeTrimmed","isFull","recycle","scrollRegionHeight","shiftElements","markRangeDirty","disp","suppressScrollEvent","oldYdisp","scrollAmount","normal","setSelection","selectionText","selectionStart","selectionEnd","keydown","evaluateKeyboardEvent","macOptionIsMeta","scrollCount","_isThirdLevelShift","domEvent","thirdLevelKey","metaKey","keyCode","setgLevel","setgCharset","wasModifierKeyOnlyEvent","charCode","which","bell","_soundBell","playBellSound","_visualBell","clearTimeout","_visualBellTimer","setTimeout","MINIMUM_COLS","MINIMUM_ROWS","hasValidSize","is","term","termName","handleTitle","title","inputHandler","userScrolling","force","cancelEvents","stopPropagation","bellStyle","writeSync","_textarea","_isComposing","_isSendingComposition","_compositionPosition","textContent","_finalizeComposition","_handleAnyTextareaChanges","waitForPropagation","_clearTextareaPosition","oldValue","diff","replace","dontRecurse","isCursorInViewport","cellHeight","lineHeight","cursorTop","cursorLeft","compositionViewBounds","FALLBACK_SCROLL_BAR_WIDTH","_scrollLines","_scrollArea","scrollBarWidth","_currentRowHeight","_lastRecordedBufferLength","_lastRecordedViewportHeight","_lastRecordedBufferHeight","_lastTouchY","_lastScrollTop","_wheelPartialScroll","_refreshAnimationFrame","_ignoreNextScrollEvent","offsetWidth","backgroundColor","_refresh","immediate","dimensions","offsetHeight","newBufferHeight","newScrollTop","offsetParent","_bubbleScroll","scrollPosFromTop","cancelable","_getPixelsScrolled","_applyScrollModifier","deltaMode","WheelEvent","DOM_DELTA_LINE","DOM_DELTA_PAGE","DOM_DELTA_PIXEL","floor","modifier","fastScrollModifier","fastScrollSensitivity","scrollSensitivity","touches","pageY","prepareTextForTerminal","bracketTextForPaste","coreService","position","selectionService","clipboardData","setData","getData","shouldSelectWord","isClickInSelection","selectWordAtCursor","GLEVEL","concat","pt","cursorStyle","cursorBlink","_terminal","EscapeSequenceParser","_parseBuffer","_stringDecoder","_utf8Decoder","setCsiHandlerFallback","identifier","identToString","setEscHandlerFallback","setExecuteHandlerFallback","setOscHandlerFallback","setDcsHandlerFallback","payload","setPrintHandler","print","setCsiHandler","final","insertChars","intermediates","scrollLeft","cursorUp","scrollRight","cursorDown","cursorForward","cursorBackward","cursorNextLine","cursorPrecedingLine","cursorCharAbsolute","cursorPosition","cursorForwardTab","eraseInDisplay","prefix","eraseInLine","insertLines","deleteLines","deleteChars","scrollUp","scrollDown","eraseChars","cursorBackwardTab","charPosAbsolute","hPositionRelative","repeatPrecedingCharacter","sendDeviceAttributesPrimary","sendDeviceAttributesSecondary","linePosAbsolute","vPositionRelative","hVPosition","tabClear","setMode","setModePrivate","resetMode","resetModePrivate","charAttributes","deviceStatus","deviceStatusPrivate","softReset","setCursorStyle","setScrollRegion","saveCursor","restoreCursor","insertColumns","deleteColumns","setExecuteHandler","lineFeed","carriageReturn","backspace","tab","shiftOut","shiftIn","nextLine","tabSet","setOscHandler","setTitle","setEscHandler","reverseIndex","keypadApplicationMode","keypadNumericMode","selectDefaultCharset","flag","selectCharset","screenAlignmentPattern","setErrorHandler","state","error","setDcsHandler","DECRQSS","cursorStartX","cursorStartY","clearRange","len","chWidth","curAttr","bufferRow","markDirty","ch","getNullCell","precedingCodepoint","convertEol","_restrictCursor","originalX","nextStop","_setCursor","_moveCursor","diffToTop","diffToBottom","param","tabs","prevStop","_eraseInBufferLine","clearWrap","_resetBufferLine","scrollBackSize","trimStart","scrollBottomRowsOffset","scrollBottomAbsolute","savedCols","activeEncoding","isCursorHidden","activateAltBuffer","activateNormalBuffer","_extractColor","attr","accu","cSpace","advance","subparams","isBlinking","bottom","savedX","savedY","savedCurAttrData","savedCharset","_savedCharset","collectAndFlag","level","yOffset","markAllDirty","setDefault","next","addMany","codes","TransitionTable","VT500_TRANSITION_TABLE","blueprint","apply","map","unused","PRINTABLES","EXECUTABLES","states","TRANSITIONS","initialState","currentState","_collect","_printHandlerFb","_executeHandlerFb","_csiHandlerFb","_escHandlerFb","_errorHandlerFb","_printHandler","_executeHandlers","_csiHandlers","_escHandlers","_oscParser","_dcsParser","_errorHandler","_identifier","finalRange","intermediate","finalCode","reverse","clearPrintHandler","clearEscHandler","clearExecuteHandler","clearCsiHandler","clearDcsHandler","clearOscHandler","clearErrorHandler","transition","osc","dcs","collect","abort","handlersEsc","jj","nextRendererId","_screenElement","_linkifier","_onRequestRefreshRows","_characterJoinerRegistry","_renderLayers","TextRenderLayer","SelectionRenderLayer","LinkRenderLayer","CursorRenderLayer","_devicePixelRatio","_updateDimensions","removeTerminalFromCache","onDevicePixelRatioChange","onCharSizeChanged","_runOperation","operation","renderRows","letterSpacing","container","characterJoinerRegistry","bufferService","_characterWidth","_characterFont","_characterOverlapCache","GridCache","terminalFont","_forEachCell","firstRow","lastRow","joinerRegistry","isJoined","lastCharX","_isOverlapping","_drawBackground","startX","startY","prevFillStyle","nextFillStyle","_drawForeground","cache","beginFrame","overlaps","measureText","TEXTURE_WIDTH","TEXTURE_HEIGHT","TRANSPARENT_COLOR","getGlyphCacheKey","glyph","_config","_drawToCacheCount","_glyphsWaitingOnBitmap","_bitmapCommitTimeout","_bitmap","_cacheCanvas","_cacheCtx","tmpCanvas","_tmpCtx","_height","capacity","_cacheMap","LRUMap","prealloc","_canCache","glyphKey","cacheValue","_drawFromCache","peek","_drawToCache","_toCoordinateX","_toCoordinateY","isEmpty","cacheX","cacheY","drawImage","inBitmap","_getColorFromAnsiIndex","_getBackgroundColor","_getForegroundColor","fontStyle","imageData","offset","clearColor","putImageData","_addGlyphToBitmap","_generateBitmap","glyphsMovingToBitmap","createImageBitmap","then","bitmap","BaseCharAtlas","NoneCharAtlas","_didWarmUp","_doWarmUp","_color","_rgba","setCss","getCss","_map","_head","_tail","_nodePool","_unlinkNode","prev","_appendNode","tail","count","nodePool","peekValue","head","pop","_clearState","_didStateChange","viewportStartRow","viewportEndRow","viewportCappedStartRow","viewportCappedEndRow","startRowEndCol","middleRowsCount","_areCoordinatesEqual","coord1","coord2","_onRequestRefreshRowsEvent","_coreBrowserService","_cell","isFocused","_cursorRenderers","_renderBarCursor","_renderBlockCursor","_renderUnderlineCursor","_clearCursor","_cursorBlinkStateManager","pause","resume","CursorBlinkStateManager","_render","restartBlinkAnimation","isPaused","triggeredByAnimationFrame","cursorY","viewportRelativeCursorY","_renderBlurCursor","isCursorVisible","strokeStyle","_restartInterval","_blinkStartTimeout","_blinkInterval","clearInterval","_animationTimeRestarted","Date","now","timeToStart","time","setInterval","onLinkHover","_onLinkHover","onLinkLeave","_onLinkLeave","_clearCurrentLink","x1","y1","middleRowCount","y2","x2","is256Color","_linkMatchers","_nextLinkMatcherId","_onLinkTooltip","_rowsToLinkify","mouseZoneManager","_element","_rowsTimeoutId","_linkifyRows","_timeBeforeLatency","absoluteRowIndexStart","absoluteRowIndexEnd","overscanLineLimit","iterator","hasNext","_doLinkifyRow","first","matcher","matchIndex","validationCallback","hoverTooltipCallback","tooltipCallback","hoverLeaveCallback","leaveCallback","willLinkActivate","priority","_addLinkMatcherToList","rowIndex","match","rex","RegExp","source","flags","stringIndex","uri","lastIndex","bufferIndex","stringIndexToBufferIndex","isValid","_addLink","exec","getStringCellWidth","MouseZone","_createLinkHoverEvent","clickCallback","hoverCallback","NON_BREAKING_SPACE_CHAR","ALL_NON_BREAKING_SPACE_REGEX","_dragScrollAmount","_enabled","_mouseDownTimeStamp","_onLinuxMouseSelection","_onRedrawRequest","_mouseMoveListener","_onMouseMove","_mouseUpListener","_onMouseUp","onUserInput","_trimListener","onTrim","_onTrim","onBufferActivate","_onBufferActivate","_model","SelectionModel","_activeSelectionMode","_removeMouseDownListeners","finalSelectionStart","finalSelectionEnd","lineText","translateBufferLineToString","bufferLine","isLinuxMouseSelection","_getMouseBufferCoords","_areCoordsInSelection","_selectWordAt","isSelectAllActive","getCoords","_getMouseEventScrollAmount","terminalHeight","macOptionClickForcesSelection","timeStamp","_onIncrementalClick","detail","_onSingleClick","_onDoubleClick","_onTripleClick","_addMouseDownListeners","_dragScrollIntervalTimer","_dragScroll","selectionStartLength","_selectLineAt","stopImmediatePropagation","previousSelectionEnd","_selectToWordAt","timeElapsed","coordinates","moveToCellSequence","activeBuffer","_convertViewportColToCharacterIndex","charIndex","_getWordAt","allowWhitespaceOnlySelection","followWrappedLinesAbove","followWrappedLinesBelow","charOffset","leftWideCharCount","rightWideCharCount","leftLongCharOffset","rightLongCharOffset","charAt","_isCharWordSeparator","trim","previousBufferLine","previousLineWordPosition","nextBufferLine","nextLineWordPosition","wordPosition","areSelectionValuesReversed","wordSeparator","wrappedRange","getWrappedRangeForLine","last","startPlusLength","moveToRequestedRow","targetY","applicationCursor","wrappedRowsForRow","repeat","wrappedRows","direction","verticalDirection","wrappedRowsCount","currentRow","lineWraps","horizontalDirection","targetX","forward","currentCol","bufferStr","mod","str","rpt","moveHorizontallyOnly","resetStartingRow","moveToRequestedCol","_audioContext","audioContextCtor","AudioContext","webkitAudioContext","audioContext","bellAudioSource","createBufferSource","decodeAudioData","_base64ToArrayBuffer","_removeMimeType","bellSound","connect","destination","base64","binaryString","atob","bytes","dataURI","split","_zones","_areZonesActive","_lastHoverCoords","_initialSelectionLength","_onMouseDown","_mouseLeaveListener","_onMouseLeave","_clickListener","_onClick","_deactivate","zone","_activate","_currentZone","pageX","_onHover","_findZoneEventAt","_tooltipTimeout","_onTooltip","_getSelectionLength","currentSelectionLength","_liveRegionLineCount","_charsToConsume","_charsToAnnounce","_accessibilityTreeRoot","_rowContainer","_rowElements","_createAccessibilityTreeNode","_topBoundaryFocusListener","_onBoundaryFocus","_bottomBoundaryFocusListener","_refreshRowsDimensions","_renderRowsDebouncer","_renderRows","_refreshRows","_liveRegion","insertAdjacentElement","onA11yChar","char","_onChar","onA11yTab","spaceCount","_onTab","_clearLiveRegion","_screenDprMonitor","boundaryElement","beforeBoundaryElement","getAttribute","relatedTarget","topBoundaryElement","bottomBoundaryElement","newElement","unshift","children","_refreshRowDimensions","MAX_ROWS_TO_READ","keyChar","setSize","posInSet","innerHTML","_announceCharacters","TERMINAL_CLASS_PREFIX","ROW_CONTAINER_CLASS","SELECTION_CLASS","nextTerminalId","_terminalClass","_refreshRowElements","_selectionContainer","_injectCss","_rowFactory","DomRendererRowFactory","_themeStyleElement","_dimensionsStyleElement","overflow","styles","_terminalSelector","BOLD_CLASS","ITALIC_CLASS","CURSOR_CLASS","CURSOR_STYLE_BLOCK_CLASS","CURSOR_BLINK_CLASS","CURSOR_STYLE_BAR_CLASS","CURSOR_STYLE_UNDERLINE_CLASS","documentFragment","_createSelectionElement","colStart","colEnd","cursorAbsoluteY","cursorX","rowElement","createRow","_setCellUnderline","enabled","span","textDecoration","DIM_CLASS","UNDERLINE_CLASS","isCursorRow","cellWidth","lineLength","charElement","_applyMinimumContrast","_addStyle","padStart","ensureContrastRatio","padChar","KEYCODE_KEY_MAPPINGS","48","49","50","51","52","53","54","55","56","57","186","187","188","189","190","191","192","219","220","221","222","applicationCursorMode","modifiers","keyMapping","lastChar","_renderer","charSizeService","_isPaused","_needsFullRefresh","_canvasWidth","_canvasHeight","_onDimensionsChange","_onRefreshRequest","_renderDebouncer","onCharSizeChange","onRequestRefreshRows","IntersectionObserver","_onIntersectionChange","threshold","observe","disconnect","intersectionRatio","_fireOnCanvasResize","changeOptions","_fullRefresh","DEFAULT_BELL_SOUND","DEFAULT_OPTIONS","scrollback","disableStdin","tabStopWidth","screenKeys","useFlowControl","CONSTRUCTOR_ONLY_OPTIONS","_onOptionChange","newValue","_sanitizeAndValidateOption","parentElement","_onCharSizeChange","_measureStrategy","DomMeasureStrategy","_parentElement","_result","_measureElement","geometry","BufferSet","_normal","Buffer","fillViewportRows","_alt","_activeBuffer","inactiveBuffer","fillAttr","newCols","newRows","MAX_BUFFER_SIZE","_hasScrollback","_nullCell","_whitespaceCell","_cols","_rows","CircularList","_getCorrectBufferLength","getWhitespaceCell","relativeY","correctBufferLength","nullCell","newMaxLength","addToY","amountToTrim","_isReflowEnabled","_reflow","_reflowLarger","_reflowSmaller","toRemove","reflowLargerGetLinesToRemove","newLayoutResult","reflowLargerCreateNewLayout","reflowLargerApplyNewLayout","layout","_reflowLargerAdjustViewport","countRemoved","viewportAdjustments","toInsert","countToInsert","wrappedLines","absoluteY","lastLineLength","destLineLengths","reflowSmallerGetNewLineLengths","linesToAdd","trimmedLines","newLines","destLineIndex","srcLineIndex","cellsToCopy","wrappedLinesIndex","getWrappedLineTrimmedLength","insertEvents","originalLines","originalLinesLength","originalLineIndex","nextToInsertIndex","nextToInsert","countInsertedSoFar","nextI","insertCountEmitted","onInsertEmitter","onTrimEmitter","lineIndex","marker","Marker","onInsert","onDelete","onDispose","_removeMarker","startOverscan","endOverscan","BufferStringIterator","_trimRight","_startIndex","_endIndex","_startOverscan","_endOverscan","_current","_maxLength","onDeleteEmitter","_array","_length","newArray","_getCyclicIndex","newLength","deleteCount","items","countToTrim","expandListBy","endsInNull","followingLineStartsWithWide","oldCols","bufferAbsoluteY","srcTrimmedTineLength","srcRemainingCells","destRemainingCells","countToRemove","nextToRemoveIndex","nextToRemoveStart","countRemovedSoFar","newLayout","newLayoutLines","newLineLengths","cellsNeeded","reduce","srcLine","cellsAvailable","oldTrimmedLength","endsWithWide","_nextId","isDisposed","_onDispose","DEFAULT_DEC_PRIVATE_MODES","_scrollToBottom","_onUserInput","wasUserInput","triggerBinaryEvent","LogLevel","optionsKeyToLogLevel","DEBUG","info","INFO","WARN","ERROR","off","OFF","_updateLogLevel","_logLevel","_evalLazyOptionalParams","optionalParams","_log","message","log","_entries","entries","service","instance","ServiceCollection","_services","serviceDependencies","getServiceDependencies","sort","serviceArgs","dependency","firstServiceArgPos","args","DEFAULT_PROTOCOLS","NONE","restrict","X10","VT200","DRAG","ANY","eventCode","isSGR","S","DEFAULT_ENCODINGS","DEFAULT","SGR","_protocols","_encodings","_activeProtocol","_activeEncoding","_onProtocolChange","_lastEvent","addProtocol","addEncoding","protocol","encoding","_compareEvents","report","DOWN","UP","MOVE","WHEEL","e1","e2","_action","_callbacks","_pendingData","_bufferOffset","cb","_innerWrite","startTime","activeElement","hasFocus","_addons","terminal","loadedAddon","_wrappedAddonDispose","activate"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB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B,eAAe,KAErCv3D,KAAK+uB,aAAe,GACpB/uB,KAAKm3D,WAAa,GAClBn3D,KAAKo3D,aAAe,EACpBp3D,KAAKq3D,cAAgB,IAG3B,EA5EA,GAAa,EAAAroC,e,8EC1Bb,iBAGE,WACUwN,GAAA,KAAAA,YAOZ,OAHE,sBAAW,wBAAS,C,IAApB,WACE,OAAOlsB,SAASmnD,gBAAkBz3D,KAAKw8B,WAAalsB,SAASonD,Y,gCAEjE,EAXA,GAAa,EAAAtjC,sB,8ECMb,iBAGE,aAFU,KAAAujC,QAA0B,GAyCtC,OApCS,YAAAv3D,QAAP,WACE,IAAK,IAAIlD,EAAI8C,KAAK23D,QAAQt3D,OAAS,EAAGnD,GAAK,EAAGA,IAC5C8C,KAAK23D,QAAQz6D,GAAGu3D,SAASr0D,WAItB,YAAAmrB,UAAP,SAAiBqsC,EAAoBnD,GAArC,WACQoD,EAA4B,CAChCpD,SAAQ,EACRr0D,QAASq0D,EAASr0D,QAClB2yD,YAAY,GAEd/yD,KAAK23D,QAAQx3D,KAAK03D,GAClBpD,EAASr0D,QAAU,WAAM,SAAK03D,qBAAqBD,IACnDpD,EAASsD,SAAcH,IAGjB,YAAAE,qBAAR,SAA6BD,GAC3B,IAAIA,EAAY9E,WAAhB,CAKA,IADA,IAAI9xD,GAAS,EACJ/D,EAAI,EAAGA,EAAI8C,KAAK23D,QAAQt3D,OAAQnD,IACvC,GAAI8C,KAAK23D,QAAQz6D,KAAO26D,EAAa,CACnC52D,EAAQ/D,EACR,MAGJ,IAAe,IAAX+D,EACF,MAAM,IAAIuW,MAAM,uDAElBqgD,EAAY9E,YAAa,EACzB8E,EAAYz3D,QAAQ+pC,MAAM0tB,EAAYpD,UACtCz0D,KAAK23D,QAAQr3D,OAAOW,EAAO,KAE/B,EA1CA,GAAa,EAAAknB","file":"xterm.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 33);\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IEvent } from 'common/EventEmitter';\nimport { IBuffer, IBufferSet } from 'common/buffer/Types';\nimport { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType } from 'common/Types';\nimport { createDecorator } from 'common/services/ServiceRegistry';\n\nexport const IBufferService = createDecorator<IBufferService>('BufferService');\nexport interface IBufferService {\n  serviceBrand: any;\n\n  readonly cols: number;\n  readonly rows: number;\n  readonly buffer: IBuffer;\n  readonly buffers: IBufferSet;\n\n  // TODO: Move resize event here\n\n  resize(cols: number, rows: number): void;\n  reset(): void;\n}\n\nexport const ICoreMouseService = createDecorator<ICoreMouseService>('CoreMouseService');\nexport interface ICoreMouseService {\n  activeProtocol: string;\n  activeEncoding: string;\n  addProtocol(name: string, protocol: ICoreMouseProtocol): void;\n  addEncoding(name: string, encoding: CoreMouseEncoding): void;\n  reset(): void;\n\n  /**\n   * Triggers a mouse event to be sent.\n   *\n   * Returns true if the event passed all protocol restrictions and a report\n   * was sent, otherwise false. The return value may be used to decide whether\n   * the default event action in the bowser component should be omitted.\n   *\n   * Note: The method will change values of the given event object\n   * to fullfill protocol and encoding restrictions.\n   */\n  triggerMouseEvent(event: ICoreMouseEvent): boolean;\n\n  /**\n   * Event to announce changes in mouse tracking.\n   */\n  onProtocolChange: IEvent<CoreMouseEventType>;\n\n  /**\n   * Human readable version of mouse events.\n   */\n  explainEvents(events: CoreMouseEventType): {[event: string]: boolean};\n}\n\nexport const ICoreService = createDecorator<ICoreService>('CoreService');\nexport interface ICoreService {\n  serviceBrand: any;\n\n  /**\n   * Initially the cursor will not be visible until the first time the terminal\n   * is focused.\n   */\n  isCursorInitialized: boolean;\n  isCursorHidden: boolean;\n  readonly decPrivateModes: IDecPrivateModes;\n\n  readonly onData: IEvent<string>;\n  readonly onUserInput: IEvent<void>;\n  readonly onBinary: IEvent<string>;\n\n  reset(): void;\n\n  /**\n   * Triggers the onData event in the public API.\n   * @param data The data that is being emitted.\n   * @param wasFromUser Whether the data originated from the user (as opposed to\n   * resulting from parsing incoming data). When true this will also:\n   * - Scroll to the bottom of the buffer.s\n   * - Fire the `onUserInput` event (so selection can be cleared).\n   */\n  triggerDataEvent(data: string, wasUserInput?: boolean): void;\n\n  /**\n   * Triggers the onBinary event in the public API.\n   * @param data The data that is being emitted.\n   */\n   triggerBinaryEvent(data: string): void;\n}\n\nexport const IDirtyRowService = createDecorator<IDirtyRowService>('DirtyRowService');\nexport interface IDirtyRowService {\n  serviceBrand: any;\n\n  readonly start: number;\n  readonly end: number;\n\n  clearRange(): void;\n  markDirty(y: number): void;\n  markRangeDirty(y1: number, y2: number): void;\n  markAllDirty(): void;\n}\n\nexport interface IServiceIdentifier<T> {\n  (...args: any[]): void;\n  type: T;\n}\n\nexport interface IConstructorSignature0<T> {\n  new(...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature1<A1, T> {\n  new(first: A1, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature2<A1, A2, T> {\n  new(first: A1, second: A2, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature3<A1, A2, A3, T> {\n  new(first: A1, second: A2, third: A3, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature4<A1, A2, A3, A4, T> {\n  new(first: A1, second: A2, third: A3, fourth: A4, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature5<A1, A2, A3, A4, A5, T> {\n  new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature6<A1, A2, A3, A4, A5, A6, T> {\n  new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature7<A1, A2, A3, A4, A5, A6, A7, T> {\n  new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport interface IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T> {\n  new(first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, eigth: A8, ...services: { serviceBrand: any; }[]): T;\n}\n\nexport const IInstantiationService = createDecorator<IInstantiationService>('InstantiationService');\nexport interface IInstantiationService {\n  setService<T>(id: IServiceIdentifier<T>, instance: T): void;\n\n  createInstance<T>(ctor: IConstructorSignature0<T>): T;\n  createInstance<A1, T>(ctor: IConstructorSignature1<A1, T>, first: A1): T;\n  createInstance<A1, A2, T>(ctor: IConstructorSignature2<A1, A2, T>, first: A1, second: A2): T;\n  createInstance<A1, A2, A3, T>(ctor: IConstructorSignature3<A1, A2, A3, T>, first: A1, second: A2, third: A3): T;\n  createInstance<A1, A2, A3, A4, T>(ctor: IConstructorSignature4<A1, A2, A3, A4, T>, first: A1, second: A2, third: A3, fourth: A4): T;\n  createInstance<A1, A2, A3, A4, A5, T>(ctor: IConstructorSignature5<A1, A2, A3, A4, A5, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5): T;\n  createInstance<A1, A2, A3, A4, A5, A6, T>(ctor: IConstructorSignature6<A1, A2, A3, A4, A5, A6, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6): T;\n  createInstance<A1, A2, A3, A4, A5, A6, A7, T>(ctor: IConstructorSignature7<A1, A2, A3, A4, A5, A6, A7, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7): T;\n  createInstance<A1, A2, A3, A4, A5, A6, A7, A8, T>(ctor: IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, eigth: A8): T;\n}\n\nexport const ILogService = createDecorator<ILogService>('LogService');\nexport interface ILogService {\n  serviceBrand: any;\n\n  debug(message: any, ...optionalParams: any[]): void;\n  info(message: any, ...optionalParams: any[]): void;\n  warn(message: any, ...optionalParams: any[]): void;\n  error(message: any, ...optionalParams: any[]): void;\n}\n\nexport const IOptionsService = createDecorator<IOptionsService>('OptionsService');\nexport interface IOptionsService {\n  serviceBrand: any;\n\n  readonly options: ITerminalOptions;\n\n  readonly onOptionChange: IEvent<string>;\n\n  setOption<T>(key: string, value: T): void;\n  getOption<T>(key: string): T | undefined;\n}\n\nexport type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';\nexport type RendererType = 'dom' | 'canvas';\n\nexport interface IPartialTerminalOptions {\n  allowTransparency?: boolean;\n  bellSound?: string;\n  bellStyle?: 'none' /*| 'visual'*/ | 'sound' /*| 'both'*/;\n  cols?: number;\n  cursorBlink?: boolean;\n  cursorStyle?: 'block' | 'underline' | 'bar';\n  disableStdin?: boolean;\n  drawBoldTextInBrightColors?: boolean;\n  fastScrollModifier?: 'alt' | 'ctrl' | 'shift';\n  fastScrollSensitivity?: number;\n  fontSize?: number;\n  fontFamily?: string;\n  fontWeight?: FontWeight;\n  fontWeightBold?: FontWeight;\n  letterSpacing?: number;\n  lineHeight?: number;\n  logLevel?: LogLevel;\n  macOptionIsMeta?: boolean;\n  macOptionClickForcesSelection?: boolean;\n  rendererType?: RendererType;\n  rightClickSelectsWord?: boolean;\n  rows?: number;\n  screenReaderMode?: boolean;\n  scrollback?: number;\n  scrollSensitivity?: number;\n  tabStopWidth?: number;\n  theme?: ITheme;\n  windowsMode?: boolean;\n  wordSeparator?: string;\n}\n\nexport interface ITerminalOptions {\n  allowTransparency: boolean;\n  bellSound: string;\n  bellStyle: 'none' /*| 'visual'*/ | 'sound' /*| 'both'*/;\n  cols: number;\n  cursorBlink: boolean;\n  cursorStyle: 'block' | 'underline' | 'bar';\n  disableStdin: boolean;\n  drawBoldTextInBrightColors: boolean;\n  fastScrollModifier: 'alt' | 'ctrl' | 'shift' | undefined;\n  fastScrollSensitivity: number;\n  fontSize: number;\n  fontFamily: string;\n  fontWeight: FontWeight;\n  fontWeightBold: FontWeight;\n  letterSpacing: number;\n  lineHeight: number;\n  logLevel: LogLevel;\n  macOptionIsMeta: boolean;\n  macOptionClickForcesSelection: boolean;\n  minimumContrastRatio: number;\n  rendererType: RendererType;\n  rightClickSelectsWord: boolean;\n  rows: number;\n  screenReaderMode: boolean;\n  scrollback: number;\n  scrollSensitivity: number;\n  tabStopWidth: number;\n  theme: ITheme;\n  windowsMode: boolean;\n  wordSeparator: string;\n\n  [key: string]: any;\n  cancelEvents: boolean;\n  convertEol: boolean;\n  screenKeys: boolean;\n  termName: string;\n  useFlowControl: boolean;\n}\n\nexport interface ITheme {\n  foreground?: string;\n  background?: string;\n  cursor?: string;\n  cursorAccent?: string;\n  selection?: string;\n  black?: string;\n  red?: string;\n  green?: string;\n  yellow?: string;\n  blue?: string;\n  magenta?: string;\n  cyan?: string;\n  white?: string;\n  brightBlack?: string;\n  brightRed?: string;\n  brightGreen?: string;\n  brightYellow?: string;\n  brightBlue?: string;\n  brightMagenta?: string;\n  brightCyan?: string;\n  brightWhite?: string;\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from 'common/Types';\n\ninterface IListener<T> {\n  (e: T): void;\n}\n\nexport interface IEvent<T> {\n  (listener: (e: T) => any): IDisposable;\n}\n\nexport interface IEventEmitter<T> {\n  event: IEvent<T>;\n  fire(data: T): void;\n  dispose(): void;\n}\n\nexport class EventEmitter<T> implements IEventEmitter<T> {\n  private _listeners: IListener<T>[] = [];\n  private _event?: IEvent<T>;\n  private _disposed: boolean = false;\n\n  public get event(): IEvent<T> {\n    if (!this._event) {\n      this._event = (listener: (e: T) => any) => {\n        this._listeners.push(listener);\n        const disposable = {\n          dispose: () => {\n            if (!this._disposed) {\n              for (let i = 0; i < this._listeners.length; i++) {\n                if (this._listeners[i] === listener) {\n                  this._listeners.splice(i, 1);\n                  return;\n                }\n              }\n            }\n          }\n        };\n        return disposable;\n      };\n    }\n    return this._event;\n  }\n\n  public fire(data: T): void {\n    const queue: IListener<T>[] = [];\n    for (let i = 0; i < this._listeners.length; i++) {\n      queue.push(this._listeners[i]);\n    }\n    for (let i = 0; i < queue.length; i++) {\n      queue[i].call(undefined, data);\n    }\n  }\n\n  public dispose(): void {\n    if (this._listeners) {\n      this._listeners.length = 0;\n    }\n    this._disposed = true;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from 'common/Types';\n\n/**\n * A base class that can be extended to provide convenience methods for managing the lifecycle of an\n * object and its components.\n */\nexport abstract class Disposable implements IDisposable {\n  protected _disposables: IDisposable[] = [];\n  protected _isDisposed: boolean = false;\n\n  constructor() {\n  }\n\n  /**\n   * Disposes the object, triggering the `dispose` method on all registered IDisposables.\n   */\n  public dispose(): void {\n    this._isDisposed = true;\n    this._disposables.forEach(d => d.dispose());\n    this._disposables.length = 0;\n  }\n\n  /**\n   * Registers a disposable object.\n   * @param d The disposable to register.\n   */\n  public register<T extends IDisposable>(d: T): void {\n    this._disposables.push(d);\n  }\n\n  /**\n   * Unregisters a disposable object if it has been registered, if not do\n   * nothing.\n   * @param d The disposable to unregister.\n   */\n  public unregister<T extends IDisposable>(d: T): void {\n    const index = this._disposables.indexOf(d);\n    if (index !== -1) {\n      this._disposables.splice(index, 1);\n    }\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport const DEFAULT_COLOR = 256;\nexport const DEFAULT_ATTR = (0 << 18) | (DEFAULT_COLOR << 9) | (256 << 0);\n\nexport const CHAR_DATA_ATTR_INDEX = 0;\nexport const CHAR_DATA_CHAR_INDEX = 1;\nexport const CHAR_DATA_WIDTH_INDEX = 2;\nexport const CHAR_DATA_CODE_INDEX = 3;\n\n/**\n * Null cell - a real empty cell (containing nothing).\n * Note that code should always be 0 for a null cell as\n * several test condition of the buffer line rely on this.\n */\nexport const NULL_CELL_CHAR = '';\nexport const NULL_CELL_WIDTH = 1;\nexport const NULL_CELL_CODE = 0;\n\n/**\n * Whitespace cell.\n * This is meant as a replacement for empty cells when needed\n * during rendering lines to preserve correct aligment.\n */\nexport const WHITESPACE_CELL_CHAR = ' ';\nexport const WHITESPACE_CELL_WIDTH = 1;\nexport const WHITESPACE_CELL_CODE = 32;\n\n/**\n * Bitmasks for accessing data in `content`.\n */\nexport const enum Content {\n  /**\n   * bit 1..21    codepoint, max allowed in UTF32 is 0x10FFFF (21 bits taken)\n   *              read:   `codepoint = content & Content.codepointMask;`\n   *              write:  `content |= codepoint & Content.codepointMask;`\n   *                      shortcut if precondition `codepoint <= 0x10FFFF` is met:\n   *                      `content |= codepoint;`\n   */\n  CODEPOINT_MASK = 0x1FFFFF,\n\n  /**\n   * bit 22       flag indication whether a cell contains combined content\n   *              read:   `isCombined = content & Content.isCombined;`\n   *              set:    `content |= Content.isCombined;`\n   *              clear:  `content &= ~Content.isCombined;`\n   */\n  IS_COMBINED_MASK = 0x200000,  // 1 << 21\n\n  /**\n   * bit 1..22    mask to check whether a cell contains any string data\n   *              we need to check for codepoint and isCombined bits to see\n   *              whether a cell contains anything\n   *              read:   `isEmpty = !(content & Content.hasContent)`\n   */\n  HAS_CONTENT_MASK = 0x3FFFFF,\n\n  /**\n   * bit 23..24   wcwidth value of cell, takes 2 bits (ranges from 0..2)\n   *              read:   `width = (content & Content.widthMask) >> Content.widthShift;`\n   *                      `hasWidth = content & Content.widthMask;`\n   *                      as long as wcwidth is highest value in `content`:\n   *                      `width = content >> Content.widthShift;`\n   *              write:  `content |= (width << Content.widthShift) & Content.widthMask;`\n   *                      shortcut if precondition `0 <= width <= 3` is met:\n   *                      `content |= width << Content.widthShift;`\n   */\n  WIDTH_MASK = 0xC00000,   // 3 << 22\n  WIDTH_SHIFT = 22\n}\n\nexport const enum Attributes {\n  /**\n   * bit 1..8     blue in RGB, color in P256 and P16\n   */\n  BLUE_MASK = 0xFF,\n  BLUE_SHIFT = 0,\n  PCOLOR_MASK = 0xFF,\n  PCOLOR_SHIFT = 0,\n\n  /**\n   * bit 9..16    green in RGB\n   */\n  GREEN_MASK = 0xFF00,\n  GREEN_SHIFT = 8,\n\n  /**\n   * bit 17..24   red in RGB\n   */\n  RED_MASK = 0xFF0000,\n  RED_SHIFT = 16,\n\n  /**\n   * bit 25..26   color mode: DEFAULT (0) | P16 (1) | P256 (2) | RGB (3)\n   */\n  CM_MASK = 0x3000000,\n  CM_DEFAULT = 0,\n  CM_P16 = 0x1000000,\n  CM_P256 = 0x2000000,\n  CM_RGB = 0x3000000,\n\n  /**\n   * bit 1..24  RGB room\n   */\n  RGB_MASK = 0xFFFFFF\n}\n\nexport const enum FgFlags {\n  /**\n   * bit 27..31 (32th bit unused)\n   */\n  INVERSE = 0x4000000,\n  BOLD = 0x8000000,\n  UNDERLINE = 0x10000000,\n  BLINK = 0x20000000,\n  INVISIBLE = 0x40000000\n}\n\nexport const enum BgFlags {\n  /**\n   * bit 27..32 (upper 4 unused)\n   */\n  ITALIC = 0x4000000,\n  DIM = 0x8000000\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IEvent } from 'common/EventEmitter';\nimport { IRenderDimensions, IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types';\nimport { IColorSet } from 'browser/Types';\nimport { ISelectionRedrawRequestEvent } from 'browser/selection/Types';\nimport { createDecorator } from 'common/services/ServiceRegistry';\nimport { IDisposable } from 'common/Types';\n\nexport const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService');\nexport interface ICharSizeService {\n  serviceBrand: any;\n\n  readonly width: number;\n  readonly height: number;\n  readonly hasValidSize: boolean;\n\n  readonly onCharSizeChange: IEvent<void>;\n\n  measure(): void;\n}\n\nexport const ICoreBrowserService = createDecorator<ICoreBrowserService>('CoreBrowserService');\nexport interface ICoreBrowserService {\n  serviceBrand: any;\n\n  readonly isFocused: boolean;\n}\n\nexport const IMouseService = createDecorator<IMouseService>('MouseService');\nexport interface IMouseService {\n  serviceBrand: any;\n\n  getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, isSelection?: boolean): [number, number] | undefined;\n  getRawByteCoords(event: MouseEvent, element: HTMLElement, colCount: number, rowCount: number): { x: number, y: number } | undefined;\n}\n\nexport const IRenderService = createDecorator<IRenderService>('RenderService');\nexport interface IRenderService extends IDisposable {\n  serviceBrand: any;\n\n  onDimensionsChange: IEvent<IRenderDimensions>;\n  onRender: IEvent<{ start: number, end: number }>;\n  onRefreshRequest: IEvent<{ start: number, end: number }>;\n\n  dimensions: IRenderDimensions;\n\n  refreshRows(start: number, end: number): void;\n  resize(cols: number, rows: number): void;\n  changeOptions(): void;\n  setRenderer(renderer: IRenderer): void;\n  setColors(colors: IColorSet): void;\n  onDevicePixelRatioChange(): void;\n  onResize(cols: number, rows: number): void;\n  // TODO: Is this useful when we have onResize?\n  onCharSizeChanged(): void;\n  onBlur(): void;\n  onFocus(): void;\n  onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void;\n  onCursorMove(): void;\n  clear(): void;\n  registerCharacterJoiner(handler: CharacterJoinerHandler): number;\n  deregisterCharacterJoiner(joinerId: number): boolean;\n}\n\nexport const ISelectionService = createDecorator<ISelectionService>('SelectionService');\nexport interface ISelectionService {\n  serviceBrand: any;\n\n  readonly selectionText: string;\n  readonly hasSelection: boolean;\n  readonly selectionStart: [number, number] | undefined;\n  readonly selectionEnd: [number, number] | undefined;\n\n  readonly onLinuxMouseSelection: IEvent<string>;\n  readonly onRedrawRequest: IEvent<ISelectionRedrawRequestEvent>;\n  readonly onSelectionChange: IEvent<void>;\n\n  disable(): void;\n  enable(): void;\n  reset(): void;\n  setSelection(row: number, col: number, length: number): void;\n  selectAll(): void;\n  selectLines(start: number, end: number): void;\n  clearSelection(): void;\n  isClickInSelection(event: MouseEvent): boolean;\n  selectWordAtCursor(event: MouseEvent): void;\n  shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean;\n  shouldForceSelection(event: MouseEvent): boolean;\n  refresh(isLinuxMouseSelection?: boolean): void;\n  onMouseDown(event: MouseEvent): void;\n}\n\nexport const ISoundService = createDecorator<ISoundService>('SoundService');\nexport interface ISoundService {\n  serviceBrand: any;\n\n  playBellSound(): void;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { CharData, ICellData } from 'common/Types';\nimport { stringFromCodePoint } from 'common/input/TextDecoder';\nimport { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, Content } from 'common/buffer/Constants';\nimport { AttributeData } from 'common/buffer/AttributeData';\n\n/**\n * CellData - represents a single Cell in the terminal buffer.\n */\nexport class CellData extends AttributeData implements ICellData {\n  /** Helper to create CellData from CharData. */\n  public static fromCharData(value: CharData): CellData {\n    const obj = new CellData();\n    obj.setFromCharData(value);\n    return obj;\n  }\n  /** Primitives from terminal buffer. */\n  public content: number = 0;\n  public fg: number = 0;\n  public bg: number = 0;\n  public combinedData: string = '';\n  /** Whether cell contains a combined string. */\n  public isCombined(): number {\n    return this.content & Content.IS_COMBINED_MASK;\n  }\n  /** Width of the cell. */\n  public getWidth(): number {\n    return this.content >> Content.WIDTH_SHIFT;\n  }\n  /** JS string of the content. */\n  public getChars(): string {\n    if (this.content & Content.IS_COMBINED_MASK) {\n      return this.combinedData;\n    }\n    if (this.content & Content.CODEPOINT_MASK) {\n      return stringFromCodePoint(this.content & Content.CODEPOINT_MASK);\n    }\n    return '';\n  }\n  /**\n   * Codepoint of cell\n   * Note this returns the UTF32 codepoint of single chars,\n   * if content is a combined string it returns the codepoint\n   * of the last char in string to be in line with code in CharData.\n   * */\n  public getCode(): number {\n    return (this.isCombined())\n      ? this.combinedData.charCodeAt(this.combinedData.length - 1)\n      : this.content & Content.CODEPOINT_MASK;\n  }\n  /** Set data from CharData */\n  public setFromCharData(value: CharData): void {\n    this.fg = value[CHAR_DATA_ATTR_INDEX];\n    this.bg = 0;\n    let combined = false;\n    // surrogates and combined strings need special treatment\n    if (value[CHAR_DATA_CHAR_INDEX].length > 2) {\n      combined = true;\n    }\n    else if (value[CHAR_DATA_CHAR_INDEX].length === 2) {\n      const code = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0);\n      // if the 2-char string is a surrogate create single codepoint\n      // everything else is combined\n      if (0xD800 <= code && code <= 0xDBFF) {\n        const second = value[CHAR_DATA_CHAR_INDEX].charCodeAt(1);\n        if (0xDC00 <= second && second <= 0xDFFF) {\n          this.content = ((code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n        }\n        else {\n          combined = true;\n        }\n      }\n      else {\n        combined = true;\n      }\n    }\n    else {\n      this.content = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    }\n    if (combined) {\n      this.combinedData = value[CHAR_DATA_CHAR_INDEX];\n      this.content = Content.IS_COMBINED_MASK | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    }\n  }\n  /** Get data as CharData. */\n  public getAsCharData(): CharData {\n    return [this.fg, this.getChars(), this.getWidth(), this.getCode()];\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IAttributeData, IColorRGB } from 'common/Types';\nimport { Attributes, FgFlags, BgFlags } from 'common/buffer/Constants';\n\nexport class AttributeData implements IAttributeData {\n  static toColorRGB(value: number): IColorRGB {\n    return [\n      value >>> Attributes.RED_SHIFT & 255,\n      value >>> Attributes.GREEN_SHIFT & 255,\n      value & 255\n    ];\n  }\n  static fromColorRGB(value: IColorRGB): number {\n    return (value[0] & 255) << Attributes.RED_SHIFT | (value[1] & 255) << Attributes.GREEN_SHIFT | value[2] & 255;\n  }\n\n  public clone(): IAttributeData {\n    const newObj = new AttributeData();\n    newObj.fg = this.fg;\n    newObj.bg = this.bg;\n    return newObj;\n  }\n\n  // data\n  public fg: number = 0;\n  public bg: number = 0;\n\n  // flags\n  public isInverse(): number   { return this.fg & FgFlags.INVERSE; }\n  public isBold(): number      { return this.fg & FgFlags.BOLD; }\n  public isUnderline(): number { return this.fg & FgFlags.UNDERLINE; }\n  public isBlink(): number     { return this.fg & FgFlags.BLINK; }\n  public isInvisible(): number { return this.fg & FgFlags.INVISIBLE; }\n  public isItalic(): number    { return this.bg & BgFlags.ITALIC; }\n  public isDim(): number       { return this.bg & BgFlags.DIM; }\n\n  // color modes\n  public getFgColorMode(): number { return this.fg & Attributes.CM_MASK; }\n  public getBgColorMode(): number { return this.bg & Attributes.CM_MASK; }\n  public isFgRGB(): boolean       { return (this.fg & Attributes.CM_MASK) === Attributes.CM_RGB; }\n  public isBgRGB(): boolean       { return (this.bg & Attributes.CM_MASK) === Attributes.CM_RGB; }\n  public isFgPalette(): boolean   { return (this.fg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.fg & Attributes.CM_MASK) === Attributes.CM_P256; }\n  public isBgPalette(): boolean   { return (this.bg & Attributes.CM_MASK) === Attributes.CM_P16 || (this.bg & Attributes.CM_MASK) === Attributes.CM_P256; }\n  public isFgDefault(): boolean   { return (this.fg & Attributes.CM_MASK) === 0; }\n  public isBgDefault(): boolean   { return (this.bg & Attributes.CM_MASK) === 0; }\n\n  // colors\n  public getFgColor(): number {\n    switch (this.fg & Attributes.CM_MASK) {\n      case Attributes.CM_P16:\n      case Attributes.CM_P256:  return this.fg & Attributes.PCOLOR_MASK;\n      case Attributes.CM_RGB:   return this.fg & Attributes.RGB_MASK;\n      default:                  return -1;  // CM_DEFAULT defaults to -1\n    }\n  }\n  public getBgColor(): number {\n    switch (this.bg & Attributes.CM_MASK) {\n      case Attributes.CM_P16:\n      case Attributes.CM_P256:  return this.bg & Attributes.PCOLOR_MASK;\n      case Attributes.CM_RGB:   return this.bg & Attributes.RGB_MASK;\n      default:                  return -1;  // CM_DEFAULT defaults to -1\n    }\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from 'common/Types';\n\n/**\n * Adds a disposable listener to a node in the DOM, returning the disposable.\n * @param type The event type.\n * @param handler The handler for the listener.\n */\nexport function addDisposableDomListener(\n  node: Element | Window | Document,\n  type: string,\n  handler: (e: any) => void,\n  useCapture?: boolean\n): IDisposable {\n  node.addEventListener(type, handler, useCapture);\n  return {\n    dispose: () => {\n      if (!handler) {\n        // Already disposed\n        return;\n      }\n      node.removeEventListener(type, handler, useCapture);\n    }\n  };\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/**\n * Polyfill - Convert UTF32 codepoint into JS string.\n * Note: The built-in String.fromCodePoint happens to be much slower\n *       due to additional sanity checks. We can avoid them since\n *       we always operate on legal UTF32 (granted by the input decoders)\n *       and use this faster version instead.\n */\nexport function stringFromCodePoint(codePoint: number): string {\n  if (codePoint > 0xFFFF) {\n    codePoint -= 0x10000;\n    return String.fromCharCode((codePoint >> 10) + 0xD800) + String.fromCharCode((codePoint % 0x400) + 0xDC00);\n  }\n  return String.fromCharCode(codePoint);\n}\n\n/**\n * Convert UTF32 char codes into JS string.\n * Basically the same as `stringFromCodePoint` but for multiple codepoints\n * in a loop (which is a lot faster).\n */\nexport function utf32ToString(data: Uint32Array, start: number = 0, end: number = data.length): string {\n  let result = '';\n  for (let i = start; i < end; ++i) {\n    let codepoint = data[i];\n    if (codepoint > 0xFFFF) {\n      // JS strings are encoded as UTF16, thus a non BMP codepoint gets converted into a surrogate pair\n      // conversion rules:\n      //  - subtract 0x10000 from code point, leaving a 20 bit number\n      //  - add high 10 bits to 0xD800  --> first surrogate\n      //  - add low 10 bits to 0xDC00   --> second surrogate\n      codepoint -= 0x10000;\n      result += String.fromCharCode((codepoint >> 10) + 0xD800) + String.fromCharCode((codepoint % 0x400) + 0xDC00);\n    } else {\n      result += String.fromCharCode(codepoint);\n    }\n  }\n  return result;\n}\n\n/**\n * StringToUtf32 - decodes UTF16 sequences into UTF32 codepoints.\n * To keep the decoder in line with JS strings it handles single surrogates as UCS2.\n */\nexport class StringToUtf32 {\n  private _interim: number = 0;\n\n  /**\n   * Clears interim and resets decoder to clean state.\n   */\n  public clear(): void {\n    this._interim = 0;\n  }\n\n  /**\n   * Decode JS string to UTF32 codepoints.\n   * The methods assumes stream input and will store partly transmitted\n   * surrogate pairs and decode them with the next data chunk.\n   * Note: The method does no bound checks for target, therefore make sure\n   * the provided input data does not exceed the size of `target`.\n   * Returns the number of written codepoints in `target`.\n   */\n  decode(input: string, target: Uint32Array): number {\n    const length = input.length;\n\n    if (!length) {\n      return 0;\n    }\n\n    let size = 0;\n    let startPos = 0;\n\n    // handle leftover surrogate high\n    if (this._interim) {\n      const second = input.charCodeAt(startPos++);\n      if (0xDC00 <= second && second <= 0xDFFF) {\n        target[size++] = (this._interim - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n      } else {\n        // illegal codepoint (USC2 handling)\n        target[size++] = this._interim;\n        target[size++] = second;\n      }\n      this._interim = 0;\n    }\n\n    for (let i = startPos; i < length; ++i) {\n      const code = input.charCodeAt(i);\n      // surrogate pair first\n      if (0xD800 <= code && code <= 0xDBFF) {\n        if (++i >= length) {\n          this._interim = code;\n          return size;\n        }\n        const second = input.charCodeAt(i);\n        if (0xDC00 <= second && second <= 0xDFFF) {\n          target[size++] = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n        } else {\n          // illegal codepoint (USC2 handling)\n          target[size++] = code;\n          target[size++] = second;\n        }\n        continue;\n      }\n      target[size++] = code;\n    }\n    return size;\n  }\n}\n\n/**\n * Utf8Decoder - decodes UTF8 byte sequences into UTF32 codepoints.\n */\nexport class Utf8ToUtf32 {\n  public interim: Uint8Array = new Uint8Array(3);\n\n  /**\n   * Clears interim bytes and resets decoder to clean state.\n   */\n  public clear(): void {\n    this.interim.fill(0);\n  }\n\n  /**\n   * Decodes UTF8 byte sequences in `input` to UTF32 codepoints in `target`.\n   * The methods assumes stream input and will store partly transmitted bytes\n   * and decode them with the next data chunk.\n   * Note: The method does no bound checks for target, therefore make sure\n   * the provided data chunk does not exceed the size of `target`.\n   * Returns the number of written codepoints in `target`.\n   */\n  decode(input: Uint8Array, target: Uint32Array): number {\n    const length = input.length;\n\n    if (!length) {\n      return 0;\n    }\n\n    let size = 0;\n    let byte1: number;\n    let byte2: number;\n    let byte3: number;\n    let byte4: number;\n    let codepoint = 0;\n    let startPos = 0;\n\n    // handle leftover bytes\n    if (this.interim[0]) {\n      let discardInterim = false;\n      let cp = this.interim[0];\n      cp &= ((((cp & 0xE0) === 0xC0)) ? 0x1F : (((cp & 0xF0) === 0xE0)) ? 0x0F : 0x07);\n      let pos = 0;\n      let tmp: number;\n      while ((tmp = this.interim[++pos] & 0x3F) && pos < 4) {\n        cp <<= 6;\n        cp |= tmp;\n      }\n      // missing bytes - read ahead from input\n      const type = (((this.interim[0] & 0xE0) === 0xC0)) ? 2 : (((this.interim[0] & 0xF0) === 0xE0)) ? 3 : 4;\n      const missing = type - pos;\n      while (startPos < missing) {\n        if (startPos >= length) {\n          return 0;\n        }\n        tmp = input[startPos++];\n        if ((tmp & 0xC0) !== 0x80) {\n          // wrong continuation, discard interim bytes completely\n          startPos--;\n          discardInterim = true;\n          break;\n        } else {\n          // need to save so we can continue short inputs in next call\n          this.interim[pos++] = tmp;\n          cp <<= 6;\n          cp |= tmp & 0x3F;\n        }\n      }\n      if (!discardInterim) {\n        // final test is type dependent\n        if (type === 2) {\n          if (cp < 0x80) {\n            // wrong starter byte\n            startPos--;\n          } else {\n            target[size++] = cp;\n          }\n        } else if (type === 3) {\n          if (cp < 0x0800 || (cp >= 0xD800 && cp <= 0xDFFF)) {\n            // illegal codepoint\n          } else {\n            target[size++] = cp;\n          }\n        } else {\n          if (cp < 0x010000 || cp > 0x10FFFF) {\n            // illegal codepoint\n          } else {\n            target[size++] = cp;\n          }\n        }\n      }\n      this.interim.fill(0);\n    }\n\n    // loop through input\n    const fourStop = length - 4;\n    let i = startPos;\n    while (i < length) {\n      /**\n       * ASCII shortcut with loop unrolled to 4 consecutive ASCII chars.\n       * This is a compromise between speed gain for ASCII\n       * and penalty for non ASCII:\n       * For best ASCII performance the char should be stored directly into target,\n       * but even a single attempt to write to target and compare afterwards\n       * penalizes non ASCII really bad (-50%), thus we load the char into byteX first,\n       * which reduces ASCII performance by ~15%.\n       * This trial for ASCII reduces non ASCII performance by ~10% which seems acceptible\n       * compared to the gains.\n       * Note that this optimization only takes place for 4 consecutive ASCII chars,\n       * for any shorter it bails out. Worst case - all 4 bytes being read but\n       * thrown away due to the last being a non ASCII char (-10% performance).\n       */\n      while (i < fourStop\n        && !((byte1 = input[i]) & 0x80)\n        && !((byte2 = input[i + 1]) & 0x80)\n        && !((byte3 = input[i + 2]) & 0x80)\n        && !((byte4 = input[i + 3]) & 0x80))\n      {\n        target[size++] = byte1;\n        target[size++] = byte2;\n        target[size++] = byte3;\n        target[size++] = byte4;\n        i += 4;\n      }\n\n      // reread byte1\n      byte1 = input[i++];\n\n      // 1 byte\n      if (byte1 < 0x80) {\n        target[size++] = byte1;\n\n        // 2 bytes\n      } else if ((byte1 & 0xE0) === 0xC0) {\n        if (i >= length) {\n          this.interim[0] = byte1;\n          return size;\n        }\n        byte2 = input[i++];\n        if ((byte2 & 0xC0) !== 0x80) {\n          // wrong continuation\n          i--;\n          continue;\n        }\n        codepoint = (byte1 & 0x1F) << 6 | (byte2 & 0x3F);\n        if (codepoint < 0x80) {\n          // wrong starter byte\n          i--;\n          continue;\n        }\n        target[size++] = codepoint;\n\n        // 3 bytes\n      } else if ((byte1 & 0xF0) === 0xE0) {\n        if (i >= length) {\n          this.interim[0] = byte1;\n          return size;\n        }\n        byte2 = input[i++];\n        if ((byte2 & 0xC0) !== 0x80) {\n          // wrong continuation\n          i--;\n          continue;\n        }\n        if (i >= length) {\n          this.interim[0] = byte1;\n          this.interim[1] = byte2;\n          return size;\n        }\n        byte3 = input[i++];\n        if ((byte3 & 0xC0) !== 0x80) {\n          // wrong continuation\n          i--;\n          continue;\n        }\n        codepoint = (byte1 & 0x0F) << 12 | (byte2 & 0x3F) << 6 | (byte3 & 0x3F);\n        if (codepoint < 0x0800 || (codepoint >= 0xD800 && codepoint <= 0xDFFF)) {\n          // illegal codepoint, no i-- here\n          continue;\n        }\n        target[size++] = codepoint;\n\n        // 4 bytes\n      } else if ((byte1 & 0xF8) === 0xF0) {\n        if (i >= length) {\n          this.interim[0] = byte1;\n          return size;\n        }\n        byte2 = input[i++];\n        if ((byte2 & 0xC0) !== 0x80) {\n          // wrong continuation\n          i--;\n          continue;\n        }\n        if (i >= length) {\n          this.interim[0] = byte1;\n          this.interim[1] = byte2;\n          return size;\n        }\n        byte3 = input[i++];\n        if ((byte3 & 0xC0) !== 0x80) {\n          // wrong continuation\n          i--;\n          continue;\n        }\n        if (i >= length) {\n          this.interim[0] = byte1;\n          this.interim[1] = byte2;\n          this.interim[2] = byte3;\n          return size;\n        }\n        byte4 = input[i++];\n        if ((byte4 & 0xC0) !== 0x80) {\n          // wrong continuation\n          i--;\n          continue;\n        }\n        codepoint = (byte1 & 0x07) << 18 | (byte2 & 0x3F) << 12 | (byte3 & 0x3F) << 6 | (byte4 & 0x3F);\n        if (codepoint < 0x010000 || codepoint > 0x10FFFF) {\n          // illegal codepoint, no i-- here\n          continue;\n        }\n        target[size++] = codepoint;\n      } else {\n        // illegal byte, just skip\n      }\n    }\n    return size;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport const INVERTED_DEFAULT_COLOR = 257;\nexport const DIM_OPACITY = 0.5;\n\nexport const CHAR_ATLAS_CELL_SPACING = 1;\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IColor } from 'browser/Types';\n\nexport function blend(bg: IColor, fg: IColor): IColor {\n  const a = (fg.rgba & 0xFF) / 255;\n  if (a === 1) {\n    return {\n      css: fg.css,\n      rgba: fg.rgba\n    };\n  }\n  const fgR = (fg.rgba >> 24) & 0xFF;\n  const fgG = (fg.rgba >> 16) & 0xFF;\n  const fgB = (fg.rgba >> 8) & 0xFF;\n  const bgR = (bg.rgba >> 24) & 0xFF;\n  const bgG = (bg.rgba >> 16) & 0xFF;\n  const bgB = (bg.rgba >> 8) & 0xFF;\n  const r = bgR + Math.round((fgR - bgR) * a);\n  const g = bgG + Math.round((fgG - bgG) * a);\n  const b = bgB + Math.round((fgB - bgB) * a);\n  const css = toCss(r, g, b);\n  const rgba = toRgba(r, g, b);\n  return { css, rgba };\n}\n\nexport function fromCss(css: string): IColor {\n  return {\n    css,\n    rgba: (parseInt(css.slice(1), 16) << 8 | 0xFF) >>> 0\n  };\n}\n\nexport function toPaddedHex(c: number): string {\n  const s = c.toString(16);\n  return s.length < 2 ? '0' + s : s;\n}\n\nexport function toCss(r: number, g: number, b: number, a?: number): string {\n  if (a !== undefined) {\n    return `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}${toPaddedHex(a)}`;\n  }\n  return `#${toPaddedHex(r)}${toPaddedHex(g)}${toPaddedHex(b)}`;\n}\n\nexport function toRgba(r: number, g: number, b: number, a: number = 0xFF): number {\n  // >>> 0 forces an unsigned int\n  return (r << 24 | g << 16 | b << 8 | a) >>> 0;\n}\n\nexport function fromRgba(value: number): [number, number, number, number] {\n  return [(value >> 24) & 0xFF, (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF];\n}\n\nexport function opaque(color: IColor): IColor {\n  const rgba = (color.rgba | 0xFF) >>> 0;\n  const [r, g, b] = fromRgba(rgba);\n  return {\n    css: toCss(r, g, b),\n    rgba\n  };\n}\n\n/**\n * Gets the relative luminance of an RGB color, this is useful in determining the contrast ratio\n * between two colors.\n * @param rgb The color to use.\n * @see https://www.w3.org/TR/WCAG20/#relativeluminancedef\n */\nexport function rgbRelativeLuminance(rgb: number): number {\n  return rgbRelativeLuminance2(\n    (rgb >> 16) & 0xFF,\n    (rgb >> 8 ) & 0xFF,\n    (rgb      ) & 0xFF);\n}\n\n/**\n * Gets the relative luminance of an RGB color, this is useful in determining the contrast ratio\n * between two colors.\n * @param r The red channel (0x00 to 0xFF).\n * @param g The green channel (0x00 to 0xFF).\n * @param b The blue channel (0x00 to 0xFF).\n * @see https://www.w3.org/TR/WCAG20/#relativeluminancedef\n */\nexport function rgbRelativeLuminance2(r: number, g: number, b: number): number {\n  const rs = r / 255;\n  const gs = g / 255;\n  const bs = b / 255;\n  const rr = rs <= 0.03928 ? rs / 12.92 : Math.pow((rs + 0.055) / 1.055, 2.4);\n  const rg = gs <= 0.03928 ? gs / 12.92 : Math.pow((gs + 0.055) / 1.055, 2.4);\n  const rb = bs <= 0.03928 ? bs / 12.92 : Math.pow((bs + 0.055) / 1.055, 2.4);\n  return rr * 0.2126 + rg * 0.7152 + rb * 0.0722;\n}\n\n/**\n * Gets the contrast ratio between two relative luminance values.\n * @param l1 The first relative luminance.\n * @param l2 The first relative luminance.\n * @see https://www.w3.org/TR/WCAG20/#contrast-ratiodef\n */\nexport function contrastRatio(l1: number, l2: number): number {\n  if (l1 < l2) {\n    return (l2 + 0.05) / (l1 + 0.05);\n  }\n  return (l1 + 0.05) / (l2 + 0.05);\n}\n\nexport function rgbaToColor(r: number, g: number, b: number): IColor {\n  return {\n    css: toCss(r, g, b),\n    rgba: toRgba(r, g, b)\n  };\n}\n\nexport function ensureContrastRatioRgba(bgRgba: number, fgRgba: number, ratio: number): number | undefined {\n  const bgL = rgbRelativeLuminance(bgRgba >> 8);\n  const fgL = rgbRelativeLuminance(fgRgba >> 8);\n  const cr = contrastRatio(bgL, fgL);\n  if (cr < ratio) {\n    if (fgL < bgL) {\n      return reduceLuminance(bgRgba, fgRgba, ratio);\n    }\n    return increaseLuminance(bgRgba, fgRgba, ratio);\n  }\n  return undefined;\n}\n\nexport function ensureContrastRatio(bg: IColor, fg: IColor, ratio: number): IColor | undefined {\n  const result = ensureContrastRatioRgba(bg.rgba, fg.rgba, ratio);\n  if (!result) {\n    return undefined;\n  }\n  return rgbaToColor(\n    (result >> 24 & 0xFF),\n    (result >> 16 & 0xFF),\n    (result >> 8  & 0xFF)\n  );\n}\n\nexport function reduceLuminance(bgRgba: number, fgRgba: number, ratio: number): number {\n  // This is a naive but fast approach to reducing luminance as converting to\n  // HSL and back is expensive\n  const bgR = (bgRgba >> 24) & 0xFF;\n  const bgG = (bgRgba >> 16) & 0xFF;\n  const bgB = (bgRgba >>  8) & 0xFF;\n  let fgR = (fgRgba >> 24) & 0xFF;\n  let fgG = (fgRgba >> 16) & 0xFF;\n  let fgB = (fgRgba >>  8) & 0xFF;\n  let cr = contrastRatio(rgbRelativeLuminance2(fgR, fgB, fgG), rgbRelativeLuminance2(bgR, bgG, bgB));\n  while (cr < ratio && (fgR > 0 || fgG > 0 || fgB > 0)) {\n    // Reduce by 10% until the ratio is hit\n    fgR -= Math.max(0, Math.ceil(fgR * 0.1));\n    fgG -= Math.max(0, Math.ceil(fgG * 0.1));\n    fgB -= Math.max(0, Math.ceil(fgB * 0.1));\n    cr = contrastRatio(rgbRelativeLuminance2(fgR, fgB, fgG), rgbRelativeLuminance2(bgR, bgG, bgB));\n  }\n  return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;\n}\n\nexport function increaseLuminance(bgRgba: number, fgRgba: number, ratio: number): number {\n  // This is a naive but fast approach to increasing luminance as converting to\n  // HSL and back is expensive\n  const bgR = (bgRgba >> 24) & 0xFF;\n  const bgG = (bgRgba >> 16) & 0xFF;\n  const bgB = (bgRgba >>  8) & 0xFF;\n  let fgR = (fgRgba >> 24) & 0xFF;\n  let fgG = (fgRgba >> 16) & 0xFF;\n  let fgB = (fgRgba >>  8) & 0xFF;\n  let cr = contrastRatio(rgbRelativeLuminance2(fgR, fgB, fgG), rgbRelativeLuminance2(bgR, bgG, bgB));\n  while (cr < ratio && (fgR < 0xFF || fgG < 0xFF || fgB < 0xFF)) {\n    // Increase by 10% until the ratio is hit\n    fgR = Math.min(0xFF, fgR + Math.ceil((255 - fgR) * 0.1));\n    fgG = Math.min(0xFF, fgG + Math.ceil((255 - fgG) * 0.1));\n    fgB = Math.min(0xFF, fgB + Math.ceil((255 - fgB) * 0.1));\n    cr = contrastRatio(rgbRelativeLuminance2(fgR, fgB, fgG), rgbRelativeLuminance2(bgR, bgG, bgB));\n  }\n  return (fgR << 24 | fgG << 16 | fgB << 8 | 0xFF) >>> 0;\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\ninterface INavigator {\n  userAgent: string;\n  language: string;\n  platform: string;\n}\n\n// We're declaring a navigator global here as we expect it in all runtimes (node and browser), but\n// we want this module to live in common.\ndeclare const navigator: INavigator;\n\nconst isNode = (typeof navigator === 'undefined') ? true : false;\nconst userAgent = (isNode) ? 'node' : navigator.userAgent;\nconst platform = (isNode) ? 'node' : navigator.platform;\n\nexport const isFirefox = !!~userAgent.indexOf('Firefox');\nexport const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);\n\n// Find the users platform. We use this to interpret the meta key\n// and ISO third level shifts.\n// http://stackoverflow.com/q/19877924/577598\nexport const isMac = contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);\nexport const isIpad = platform === 'iPad';\nexport const isIphone = platform === 'iPhone';\nexport const isWindows = contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);\nexport const isLinux = platform.indexOf('Linux') >= 0;\n\n/**\n * Return if the given array contains the given element\n * @param arr The array to search for the given element.\n * @param el The element to look for into the array\n */\nfunction contains(arr: any[], el: any): boolean {\n  return arr.indexOf(el) >= 0;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/**\n * C0 control codes\n * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes\n */\nexport namespace C0 {\n  /** Null (Caret = ^@, C = \\0) */\n  export const NUL = '\\x00';\n  /** Start of Heading (Caret = ^A) */\n  export const SOH = '\\x01';\n  /** Start of Text (Caret = ^B) */\n  export const STX = '\\x02';\n  /** End of Text (Caret = ^C) */\n  export const ETX = '\\x03';\n  /** End of Transmission (Caret = ^D) */\n  export const EOT = '\\x04';\n  /** Enquiry (Caret = ^E) */\n  export const ENQ = '\\x05';\n  /** Acknowledge (Caret = ^F) */\n  export const ACK = '\\x06';\n  /** Bell (Caret = ^G, C = \\a) */\n  export const BEL = '\\x07';\n  /** Backspace (Caret = ^H, C = \\b) */\n  export const BS  = '\\x08';\n  /** Character Tabulation, Horizontal Tabulation (Caret = ^I, C = \\t) */\n  export const HT  = '\\x09';\n  /** Line Feed (Caret = ^J, C = \\n) */\n  export const LF  = '\\x0a';\n  /** Line Tabulation, Vertical Tabulation (Caret = ^K, C = \\v) */\n  export const VT  = '\\x0b';\n  /** Form Feed (Caret = ^L, C = \\f) */\n  export const FF  = '\\x0c';\n  /** Carriage Return (Caret = ^M, C = \\r) */\n  export const CR  = '\\x0d';\n  /** Shift Out (Caret = ^N) */\n  export const SO  = '\\x0e';\n  /** Shift In (Caret = ^O) */\n  export const SI  = '\\x0f';\n  /** Data Link Escape (Caret = ^P) */\n  export const DLE = '\\x10';\n  /** Device Control One (XON) (Caret = ^Q) */\n  export const DC1 = '\\x11';\n  /** Device Control Two (Caret = ^R) */\n  export const DC2 = '\\x12';\n  /** Device Control Three (XOFF) (Caret = ^S) */\n  export const DC3 = '\\x13';\n  /** Device Control Four (Caret = ^T) */\n  export const DC4 = '\\x14';\n  /** Negative Acknowledge (Caret = ^U) */\n  export const NAK = '\\x15';\n  /** Synchronous Idle (Caret = ^V) */\n  export const SYN = '\\x16';\n  /** End of Transmission Block (Caret = ^W) */\n  export const ETB = '\\x17';\n  /** Cancel (Caret = ^X) */\n  export const CAN = '\\x18';\n  /** End of Medium (Caret = ^Y) */\n  export const EM  = '\\x19';\n  /** Substitute (Caret = ^Z) */\n  export const SUB = '\\x1a';\n  /** Escape (Caret = ^[, C = \\e) */\n  export const ESC = '\\x1b';\n  /** File Separator (Caret = ^\\) */\n  export const FS  = '\\x1c';\n  /** Group Separator (Caret = ^]) */\n  export const GS  = '\\x1d';\n  /** Record Separator (Caret = ^^) */\n  export const RS  = '\\x1e';\n  /** Unit Separator (Caret = ^_) */\n  export const US  = '\\x1f';\n  /** Space */\n  export const SP  = '\\x20';\n  /** Delete (Caret = ^?) */\n  export const DEL = '\\x7f';\n}\n\n/**\n * C1 control codes\n * See = https://en.wikipedia.org/wiki/C0_and_C1_control_codes\n */\nexport namespace C1 {\n  /** padding character */\n  export const PAD = '\\x80';\n  /** High Octet Preset */\n  export const HOP = '\\x81';\n  /** Break Permitted Here */\n  export const BPH = '\\x82';\n  /** No Break Here */\n  export const NBH = '\\x83';\n  /** Index */\n  export const IND = '\\x84';\n  /** Next Line */\n  export const NEL = '\\x85';\n  /** Start of Selected Area */\n  export const SSA = '\\x86';\n  /** End of Selected Area */\n  export const ESA = '\\x87';\n  /** Horizontal Tabulation Set */\n  export const HTS = '\\x88';\n  /** Horizontal Tabulation With Justification */\n  export const HTJ = '\\x89';\n  /** Vertical Tabulation Set */\n  export const VTS = '\\x8a';\n  /** Partial Line Down */\n  export const PLD = '\\x8b';\n  /** Partial Line Up */\n  export const PLU = '\\x8c';\n  /** Reverse Index */\n  export const RI = '\\x8d';\n  /** Single-Shift 2 */\n  export const SS2 = '\\x8e';\n  /** Single-Shift 3 */\n  export const SS3 = '\\x8f';\n  /** Device Control String */\n  export const DCS = '\\x90';\n  /** Private Use 1 */\n  export const PU1 = '\\x91';\n  /** Private Use 2 */\n  export const PU2 = '\\x92';\n  /** Set Transmit State */\n  export const STS = '\\x93';\n  /** Destructive backspace, intended to eliminate ambiguity about meaning of BS. */\n  export const CCH = '\\x94';\n  /** Message Waiting */\n  export const MW = '\\x95';\n  /** Start of Protected Area */\n  export const SPA = '\\x96';\n  /** End of Protected Area */\n  export const EPA = '\\x97';\n  /** Start of String */\n  export const SOS = '\\x98';\n  /** Single Graphic Character Introducer */\n  export const SGCI = '\\x99';\n  /** Single Character Introducer */\n  export const SCI = '\\x9a';\n  /** Control Sequence Introducer */\n  export const CSI = '\\x9b';\n  /** String Terminator */\n  export const ST = '\\x9c';\n  /** Operating System Command */\n  export const OSC = '\\x9d';\n  /** Privacy Message */\n  export const PM = '\\x9e';\n  /** Application Program Command */\n  export const APC = '\\x9f';\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderDimensions, IRenderLayer } from 'browser/renderer/Types';\nimport { ICellData } from 'common/Types';\nimport { DEFAULT_COLOR, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE, Attributes } from 'common/buffer/Constants';\nimport { IGlyphIdentifier } from 'browser/renderer/atlas/Types';\nimport { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';\nimport { BaseCharAtlas } from 'browser/renderer/atlas/BaseCharAtlas';\nimport { acquireCharAtlas } from 'browser/renderer/atlas/CharAtlasCache';\nimport { AttributeData } from 'common/buffer/AttributeData';\nimport { IColorSet, IColor } from 'browser/Types';\nimport { CellData } from 'common/buffer/CellData';\nimport { IBufferService, IOptionsService } from 'common/services/Services';\nimport { throwIfFalsy } from 'browser/renderer/RendererUtils';\nimport { toCss, ensureContrastRatioRgba, opaque } from 'browser/Color';\n\nexport abstract class BaseRenderLayer implements IRenderLayer {\n  private _canvas: HTMLCanvasElement;\n  protected _ctx!: CanvasRenderingContext2D;\n  private _scaledCharWidth: number = 0;\n  private _scaledCharHeight: number = 0;\n  private _scaledCellWidth: number = 0;\n  private _scaledCellHeight: number = 0;\n  private _scaledCharLeft: number = 0;\n  private _scaledCharTop: number = 0;\n\n  protected _charAtlas: BaseCharAtlas | undefined;\n\n  /**\n   * An object that's reused when drawing glyphs in order to reduce GC.\n   */\n  private _currentGlyphIdentifier: IGlyphIdentifier = {\n    chars: '',\n    code: 0,\n    bg: 0,\n    fg: 0,\n    bold: false,\n    dim: false,\n    italic: false\n  };\n\n  constructor(\n    private _container: HTMLElement,\n    id: string,\n    zIndex: number,\n    private _alpha: boolean,\n    protected _colors: IColorSet,\n    private _rendererId: number,\n    protected readonly _bufferService: IBufferService,\n    protected readonly _optionsService: IOptionsService\n  ) {\n    this._canvas = document.createElement('canvas');\n    this._canvas.classList.add(`xterm-${id}-layer`);\n    this._canvas.style.zIndex = zIndex.toString();\n    this._initCanvas();\n    this._container.appendChild(this._canvas);\n  }\n\n  public dispose(): void {\n    this._container.removeChild(this._canvas);\n    this._charAtlas?.dispose();\n  }\n\n  private _initCanvas(): void {\n    this._ctx = throwIfFalsy(this._canvas.getContext('2d', {alpha: this._alpha}));\n    // Draw the background if this is an opaque layer\n    if (!this._alpha) {\n      this._clearAll();\n    }\n  }\n\n  public onOptionsChanged(): void {}\n  public onBlur(): void {}\n  public onFocus(): void {}\n  public onCursorMove(): void {}\n  public onGridChanged(startRow: number, endRow: number): void {}\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean = false): void {}\n\n  public setColors(colorSet: IColorSet): void {\n    this._refreshCharAtlas(colorSet);\n  }\n\n  protected _setTransparency(alpha: boolean): void {\n    // Do nothing when alpha doesn't change\n    if (alpha === this._alpha) {\n      return;\n    }\n\n    // Create new canvas and replace old one\n    const oldCanvas = this._canvas;\n    this._alpha = alpha;\n    // Cloning preserves properties\n    this._canvas = <HTMLCanvasElement>this._canvas.cloneNode();\n    this._initCanvas();\n    this._container.replaceChild(this._canvas, oldCanvas);\n\n    // Regenerate char atlas and force a full redraw\n    this._refreshCharAtlas(this._colors);\n    this.onGridChanged(0, this._bufferService.rows - 1);\n  }\n\n  /**\n   * Refreshes the char atlas, aquiring a new one if necessary.\n   * @param colorSet The color set to use for the char atlas.\n   */\n  private _refreshCharAtlas(colorSet: IColorSet): void {\n    if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {\n      return;\n    }\n    this._charAtlas = acquireCharAtlas(this._optionsService.options, this._rendererId, colorSet, this._scaledCharWidth, this._scaledCharHeight);\n    this._charAtlas.warmUp();\n  }\n\n  public resize(dim: IRenderDimensions): void {\n    this._scaledCellWidth = dim.scaledCellWidth;\n    this._scaledCellHeight = dim.scaledCellHeight;\n    this._scaledCharWidth = dim.scaledCharWidth;\n    this._scaledCharHeight = dim.scaledCharHeight;\n    this._scaledCharLeft = dim.scaledCharLeft;\n    this._scaledCharTop = dim.scaledCharTop;\n    this._canvas.width = dim.scaledCanvasWidth;\n    this._canvas.height = dim.scaledCanvasHeight;\n    this._canvas.style.width = `${dim.canvasWidth}px`;\n    this._canvas.style.height = `${dim.canvasHeight}px`;\n\n    // Draw the background if this is an opaque layer\n    if (!this._alpha) {\n      this._clearAll();\n    }\n\n    this._refreshCharAtlas(this._colors);\n  }\n\n  public abstract reset(): void;\n\n  /**\n   * Fills 1+ cells completely. This uses the existing fillStyle on the context.\n   * @param x The column to start at.\n   * @param y The row to start at\n   * @param width The number of columns to fill.\n   * @param height The number of rows to fill.\n   */\n  protected _fillCells(x: number, y: number, width: number, height: number): void {\n    this._ctx.fillRect(\n        x * this._scaledCellWidth,\n        y * this._scaledCellHeight,\n        width * this._scaledCellWidth,\n        height * this._scaledCellHeight);\n  }\n\n  /**\n   * Fills a 1px line (2px on HDPI) at the bottom of the cell. This uses the\n   * existing fillStyle on the context.\n   * @param x The column to fill.\n   * @param y The row to fill.\n   */\n  protected _fillBottomLineAtCells(x: number, y: number, width: number = 1): void {\n    this._ctx.fillRect(\n        x * this._scaledCellWidth,\n        (y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */,\n        width * this._scaledCellWidth,\n        window.devicePixelRatio);\n  }\n\n  /**\n   * Fills a 1px line (2px on HDPI) at the left of the cell. This uses the\n   * existing fillStyle on the context.\n   * @param x The column to fill.\n   * @param y The row to fill.\n   */\n  protected _fillLeftLineAtCell(x: number, y: number): void {\n    this._ctx.fillRect(\n        x * this._scaledCellWidth,\n        y * this._scaledCellHeight,\n        window.devicePixelRatio,\n        this._scaledCellHeight);\n  }\n\n  /**\n   * Strokes a 1px rectangle (2px on HDPI) around a cell. This uses the existing\n   * strokeStyle on the context.\n   * @param x The column to fill.\n   * @param y The row to fill.\n   */\n  protected _strokeRectAtCell(x: number, y: number, width: number, height: number): void {\n    this._ctx.lineWidth = window.devicePixelRatio;\n    this._ctx.strokeRect(\n        x * this._scaledCellWidth + window.devicePixelRatio / 2,\n        y * this._scaledCellHeight + (window.devicePixelRatio / 2),\n        width * this._scaledCellWidth - window.devicePixelRatio,\n        (height * this._scaledCellHeight) - window.devicePixelRatio);\n  }\n\n  /**\n   * Clears the entire canvas.\n   */\n  protected _clearAll(): void {\n    if (this._alpha) {\n      this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);\n    } else {\n      this._ctx.fillStyle = this._colors.background.css;\n      this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);\n    }\n  }\n\n  /**\n   * Clears 1+ cells completely.\n   * @param x The column to start at.\n   * @param y The row to start at.\n   * @param width The number of columns to clear.\n   * @param height The number of rows to clear.\n   */\n  protected _clearCells(x: number, y: number, width: number, height: number): void {\n    if (this._alpha) {\n      this._ctx.clearRect(\n          x * this._scaledCellWidth,\n          y * this._scaledCellHeight,\n          width * this._scaledCellWidth,\n          height * this._scaledCellHeight);\n    } else {\n      this._ctx.fillStyle = this._colors.background.css;\n      this._ctx.fillRect(\n          x * this._scaledCellWidth,\n          y * this._scaledCellHeight,\n          width * this._scaledCellWidth,\n          height * this._scaledCellHeight);\n    }\n  }\n\n  /**\n   * Draws a truecolor character at the cell. The character will be clipped to\n   * ensure that it fits with the cell, including the cell to the right if it's\n   * a wide character. This uses the existing fillStyle on the context.\n   * @param cell The cell data for the character to draw.\n   * @param x The column to draw at.\n   * @param y The row to draw at.\n   * @param color The color of the character.\n   */\n  protected _fillCharTrueColor(cell: CellData, x: number, y: number): void {\n    this._ctx.font = this._getFont(false, false);\n    this._ctx.textBaseline = 'middle';\n    this._clipRow(y);\n    this._ctx.fillText(\n        cell.getChars(),\n        x * this._scaledCellWidth + this._scaledCharLeft,\n        y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2);\n  }\n\n  /**\n   * Draws one or more characters at a cell. If possible this will draw using\n   * the character atlas to reduce draw time.\n   * @param chars The character or characters.\n   * @param code The character code.\n   * @param width The width of the characters.\n   * @param x The column to draw at.\n   * @param y The row to draw at.\n   * @param fg The foreground color, in the format stored within the attributes.\n   * @param bg The background color, in the format stored within the attributes.\n   * This is used to validate whether a cached image can be used.\n   * @param bold Whether the text is bold.\n   */\n  protected _drawChars(cell: ICellData, x: number, y: number): void {\n    const contrastColor = this._getContrastColor(cell);\n\n    // skip cache right away if we draw in RGB\n    // Note: to avoid bad runtime JoinedCellData will be skipped\n    //       in the cache handler itself (atlasDidDraw == false) and\n    //       fall through to uncached later down below\n    if (contrastColor || cell.isFgRGB() || cell.isBgRGB()) {\n      this._drawUncachedChars(cell, x, y, contrastColor);\n      return;\n    }\n\n    let fg;\n    let bg;\n    if (cell.isInverse()) {\n      fg = (cell.isBgDefault()) ? INVERTED_DEFAULT_COLOR : cell.getBgColor();\n      bg = (cell.isFgDefault()) ? INVERTED_DEFAULT_COLOR : cell.getFgColor();\n    } else {\n      bg = (cell.isBgDefault()) ? DEFAULT_COLOR : cell.getBgColor();\n      fg = (cell.isFgDefault()) ? DEFAULT_COLOR : cell.getFgColor();\n    }\n\n    const drawInBrightColor = this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8;\n\n    fg += drawInBrightColor ? 8 : 0;\n    this._currentGlyphIdentifier.chars = cell.getChars() || WHITESPACE_CELL_CHAR;\n    this._currentGlyphIdentifier.code = cell.getCode() || WHITESPACE_CELL_CODE;\n    this._currentGlyphIdentifier.bg = bg;\n    this._currentGlyphIdentifier.fg = fg;\n    this._currentGlyphIdentifier.bold = !!cell.isBold();\n    this._currentGlyphIdentifier.dim = !!cell.isDim();\n    this._currentGlyphIdentifier.italic = !!cell.isItalic();\n    const atlasDidDraw = this._charAtlas && this._charAtlas.draw(\n      this._ctx,\n      this._currentGlyphIdentifier,\n      x * this._scaledCellWidth + this._scaledCharLeft,\n      y * this._scaledCellHeight + this._scaledCharTop\n    );\n\n    if (!atlasDidDraw) {\n      this._drawUncachedChars(cell, x, y);\n    }\n  }\n\n  /**\n   * Draws one or more characters at one or more cells. The character(s) will be\n   * clipped to ensure that they fit with the cell(s), including the cell to the\n   * right if the last character is a wide character.\n   * @param chars The character.\n   * @param width The width of the character.\n   * @param fg The foreground color, in the format stored within the attributes.\n   * @param x The column to draw at.\n   * @param y The row to draw at.\n   */\n  private _drawUncachedChars(cell: ICellData, x: number, y: number, fgOverride?: IColor): void {\n    this._ctx.save();\n    this._ctx.font = this._getFont(!!cell.isBold(), !!cell.isItalic());\n    this._ctx.textBaseline = 'middle';\n\n    if (cell.isInverse()) {\n      if (fgOverride) {\n        this._ctx.fillStyle = fgOverride.css;\n      } else if (cell.isBgDefault()) {\n        this._ctx.fillStyle = opaque(this._colors.background).css;\n      } else if (cell.isBgRGB()) {\n        this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;\n      } else {\n        let bg = cell.getBgColor();\n        if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && bg < 8) {\n          bg += 8;\n        }\n        this._ctx.fillStyle = this._colors.ansi[bg].css;\n      }\n    } else {\n      if (fgOverride) {\n        this._ctx.fillStyle = fgOverride.css;\n      } else if (cell.isFgDefault()) {\n        this._ctx.fillStyle = this._colors.foreground.css;\n      } else if (cell.isFgRGB()) {\n        this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;\n      } else {\n        let fg = cell.getFgColor();\n        if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {\n          fg += 8;\n        }\n        this._ctx.fillStyle = this._colors.ansi[fg].css;\n      }\n    }\n\n    this._clipRow(y);\n\n    // Apply alpha to dim the character\n    if (cell.isDim()) {\n      this._ctx.globalAlpha = DIM_OPACITY;\n    }\n    // Draw the character\n    this._ctx.fillText(\n        cell.getChars(),\n        x * this._scaledCellWidth + this._scaledCharLeft,\n        y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2);\n    this._ctx.restore();\n  }\n\n  /**\n   * Clips a row to ensure no pixels will be drawn outside the cells in the row.\n   * @param y The row to clip.\n   */\n  private _clipRow(y: number): void {\n    this._ctx.beginPath();\n    this._ctx.rect(\n        0,\n        y * this._scaledCellHeight,\n        this._bufferService.cols * this._scaledCellWidth,\n        this._scaledCellHeight);\n    this._ctx.clip();\n  }\n\n  /**\n   * Gets the current font.\n   * @param isBold If we should use the bold fontWeight.\n   */\n  protected _getFont(isBold: boolean, isItalic: boolean): string {\n    const fontWeight = isBold ? this._optionsService.options.fontWeightBold : this._optionsService.options.fontWeight;\n    const fontStyle = isItalic ? 'italic' : '';\n\n    return `${fontStyle} ${fontWeight} ${this._optionsService.options.fontSize * window.devicePixelRatio}px ${this._optionsService.options.fontFamily}`;\n  }\n\n  private _getContrastColor(cell: CellData): IColor | undefined {\n    if (this._optionsService.options.minimumContrastRatio === 1) {\n      return undefined;\n    }\n\n    // Try get from cache first\n    const adjustedColor = this._colors.contrastCache.getColor(cell.bg, cell.fg);\n    if (adjustedColor !== undefined) {\n      return adjustedColor || undefined;\n    }\n\n    let fgColor = cell.getFgColor();\n    let fgColorMode = cell.getFgColorMode();\n    let bgColor = cell.getBgColor();\n    let bgColorMode = cell.getBgColorMode();\n    const isInverse = !!cell.isInverse();\n    const isBold = !!cell.isInverse();\n    if (isInverse) {\n      const temp = fgColor;\n      fgColor = bgColor;\n      bgColor = temp;\n      const temp2 = fgColorMode;\n      fgColorMode = bgColorMode;\n      bgColorMode = temp2;\n    }\n\n    const bgRgba = this._resolveBackgroundRgba(bgColorMode, bgColor, isInverse);\n    const fgRgba = this._resolveForegroundRgba(fgColorMode, fgColor, isInverse, isBold);\n    const result = ensureContrastRatioRgba(bgRgba, fgRgba, this._optionsService.options.minimumContrastRatio);\n\n    if (!result) {\n      this._colors.contrastCache.setColor(cell.bg, cell.fg, null);\n      return undefined;\n    }\n\n    const color: IColor = {\n      css: toCss(\n        (result >> 24) & 0xFF,\n        (result >> 16) & 0xFF,\n        (result >> 8) & 0xFF\n      ),\n      rgba: result\n    };\n    this._colors.contrastCache.setColor(cell.bg, cell.fg, color);\n\n    return color;\n  }\n\n  private _resolveBackgroundRgba(bgColorMode: number, bgColor: number, inverse: boolean): number {\n    switch (bgColorMode) {\n      case Attributes.CM_P16:\n      case Attributes.CM_P256:\n        return this._colors.ansi[bgColor].rgba;\n      case Attributes.CM_RGB:\n        return bgColor << 8;\n      case Attributes.CM_DEFAULT:\n      default:\n        if (inverse) {\n          return this._colors.foreground.rgba;\n        }\n        return this._colors.background.rgba;\n    }\n  }\n\n  private _resolveForegroundRgba(fgColorMode: number, fgColor: number, inverse: boolean, bold: boolean): number {\n    switch (fgColorMode) {\n      case Attributes.CM_P16:\n      case Attributes.CM_P256:\n        if (this._optionsService.options.drawBoldTextInBrightColors && bold && fgColor < 8) {\n          fgColor += 8;\n        }\n        return this._colors.ansi[fgColor].rgba;\n      case Attributes.CM_RGB:\n        return fgColor << 8;\n      case Attributes.CM_DEFAULT:\n      default:\n        if (inverse) {\n          return this._colors.background.rgba;\n        }\n        return this._colors.foreground.rgba;\n    }\n  }\n}\n\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * This was heavily inspired from microsoft/vscode's dependency injection system (MIT).\n */\n/*---------------------------------------------------------------------------------------------\n *  Copyright (c) Microsoft Corporation. All rights reserved.\n *  Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IServiceIdentifier } from 'common/services/Services';\n\nconst DI_TARGET = 'di$target';\nconst DI_DEPENDENCIES = 'di$dependencies';\n\nexport const serviceRegistry: Map<string, IServiceIdentifier<any>> = new Map();\n\nexport function getServiceDependencies(ctor: any): { id: IServiceIdentifier<any>, index: number, optional: boolean }[] {\n  return ctor[DI_DEPENDENCIES] || [];\n}\n\nexport function createDecorator<T>(id: string): IServiceIdentifier<T> {\n  if (serviceRegistry.has(id)) {\n    return serviceRegistry.get(id)!;\n  }\n\n  const decorator = <any>function (target: Function, key: string, index: number): any {\n    if (arguments.length !== 3) {\n      throw new Error('@IServiceName-decorator can only be used to decorate a parameter');\n    }\n\n    storeServiceDependency(decorator, target, index);\n  };\n\n  decorator.toString = () => id;\n\n  serviceRegistry.set(id, decorator);\n  return decorator;\n}\n\nfunction storeServiceDependency(id: Function, target: Function, index: number): void {\n  if ((target as any)[DI_TARGET] === target) {\n    (target as any)[DI_DEPENDENCIES].push({ id, index });\n  } else {\n    (target as any)[DI_DEPENDENCIES] = [{ id, index }];\n    (target as any)[DI_TARGET] = target;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport type TypedArray = Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray\n  | Int8Array | Int16Array | Int32Array\n  | Float32Array | Float64Array;\n\n\n/**\n * polyfill for TypedArray.fill\n * This is needed to support .fill in all safari versions and IE 11.\n */\nexport function fill<T extends TypedArray>(array: T, value: number, start?: number, end?: number): T {\n  // all modern engines that support .fill\n  if (array.fill) {\n    return array.fill(value, start, end) as T;\n  }\n  return fillFallback(array, value, start, end);\n}\n\nexport function fillFallback<T extends TypedArray>(array: T, value: number, start: number = 0, end: number = array.length): T {\n  // safari and IE 11\n  // since IE 11 does not support Array.prototype.fill either\n  // we cannot use the suggested polyfill from MDN\n  // instead we simply fall back to looping\n  if (start >= array.length) {\n    return array;\n  }\n  start = (array.length + start) % array.length;\n  if (end >= array.length) {\n    end = array.length;\n  } else {\n    end = (array.length + end) % array.length;\n  }\n  for (let i = start; i < end; ++i) {\n    array[i] = value;\n  }\n  return array;\n}\n\n/**\n * Concat two typed arrays `a` and `b`.\n * Returns a new typed array.\n */\nexport function concat<T extends TypedArray>(a: T, b: T): T {\n  const result = new (a.constructor as any)(a.length + b.length);\n  result.set(a);\n  result.set(b, a.length);\n  return result;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { CharData, IBufferLine, ICellData } from 'common/Types';\nimport { stringFromCodePoint } from 'common/input/TextDecoder';\nimport { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants';\nimport { CellData } from 'common/buffer/CellData';\nimport { AttributeData } from 'common/buffer/AttributeData';\n\n/**\n * buffer memory layout:\n *\n *   |             uint32_t             |        uint32_t         |        uint32_t         |\n *   |             `content`            |          `FG`           |          `BG`           |\n *   | wcwidth(2) comb(1) codepoint(21) | flags(8) R(8) G(8) B(8) | flags(8) R(8) G(8) B(8) |\n */\n\n\n/** typed array slots taken by one cell */\nconst CELL_SIZE = 3;\n\n/**\n * Cell member indices.\n *\n * Direct access:\n *    `content = data[column * CELL_SIZE + Cell.CONTENT];`\n *    `fg = data[column * CELL_SIZE + Cell.FG];`\n *    `bg = data[column * CELL_SIZE + Cell.BG];`\n */\nconst enum Cell {\n  CONTENT = 0,\n  FG = 1, // currently simply holds all known attrs\n  BG = 2  // currently unused\n}\n\nexport const DEFAULT_ATTR_DATA = Object.freeze(new AttributeData());\n\n/**\n * Typed array based bufferline implementation.\n *\n * There are 2 ways to insert data into the cell buffer:\n * - `setCellFromCodepoint` + `addCodepointToCell`\n *   Use these for data that is already UTF32.\n *   Used during normal input in `InputHandler` for faster buffer access.\n * - `setCell`\n *   This method takes a CellData object and stores the data in the buffer.\n *   Use `CellData.fromCharData` to create the CellData object (e.g. from JS string).\n *\n * To retrieve data from the buffer use either one of the primitive methods\n * (if only one particular value is needed) or `loadCell`. For `loadCell` in a loop\n * memory allocs / GC pressure can be greatly reduced by reusing the CellData object.\n */\nexport class BufferLine implements IBufferLine {\n  protected _data: Uint32Array;\n  protected _combined: {[index: number]: string} = {};\n  public length: number;\n\n  constructor(cols: number, fillCellData?: ICellData, public isWrapped: boolean = false) {\n    this._data = new Uint32Array(cols * CELL_SIZE);\n    const cell = fillCellData || CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);\n    for (let i = 0; i < cols; ++i) {\n      this.setCell(i, cell);\n    }\n    this.length = cols;\n  }\n\n  /**\n   * Get cell data CharData.\n   * @deprecated\n   */\n  public get(index: number): CharData {\n    const content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    const cp = content & Content.CODEPOINT_MASK;\n    return [\n      this._data[index * CELL_SIZE + Cell.FG],\n      (content & Content.IS_COMBINED_MASK)\n        ? this._combined[index]\n        : (cp) ? stringFromCodePoint(cp) : '',\n      content >> Content.WIDTH_SHIFT,\n      (content & Content.IS_COMBINED_MASK)\n        ? this._combined[index].charCodeAt(this._combined[index].length - 1)\n        : cp\n    ];\n  }\n\n  /**\n   * Set cell data from CharData.\n   * @deprecated\n   */\n  public set(index: number, value: CharData): void {\n    this._data[index * CELL_SIZE + Cell.FG] = value[CHAR_DATA_ATTR_INDEX];\n    if (value[CHAR_DATA_CHAR_INDEX].length > 1) {\n      this._combined[index] = value[1];\n      this._data[index * CELL_SIZE + Cell.CONTENT] = index | Content.IS_COMBINED_MASK | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    } else {\n      this._data[index * CELL_SIZE + Cell.CONTENT] = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);\n    }\n  }\n\n  /**\n   * primitive getters\n   * use these when only one value is needed, otherwise use `loadCell`\n   */\n  public getWidth(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] >> Content.WIDTH_SHIFT;\n  }\n\n  /** Test whether content has width. */\n  public hasWidth(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] & Content.WIDTH_MASK;\n  }\n\n  /** Get FG cell component. */\n  public getFg(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.FG];\n  }\n\n  /** Get BG cell component. */\n  public getBg(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.BG];\n  }\n\n  /**\n   * Test whether contains any chars.\n   * Basically an empty has no content, but other cells might differ in FG/BG\n   * from real empty cells.\n   * */\n  public hasContent(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] & Content.HAS_CONTENT_MASK;\n  }\n\n  /**\n   * Get codepoint of the cell.\n   * To be in line with `code` in CharData this either returns\n   * a single UTF32 codepoint or the last codepoint of a combined string.\n   */\n  public getCodePoint(index: number): number {\n    const content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    if (content & Content.IS_COMBINED_MASK) {\n      return this._combined[index].charCodeAt(this._combined[index].length - 1);\n    }\n    return content & Content.CODEPOINT_MASK;\n  }\n\n  /** Test whether the cell contains a combined string. */\n  public isCombined(index: number): number {\n    return this._data[index * CELL_SIZE + Cell.CONTENT] & Content.IS_COMBINED_MASK;\n  }\n\n  /** Returns the string content of the cell. */\n  public getString(index: number): string {\n    const content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    if (content & Content.IS_COMBINED_MASK) {\n      return this._combined[index];\n    }\n    if (content & Content.CODEPOINT_MASK) {\n      return stringFromCodePoint(content & Content.CODEPOINT_MASK);\n    }\n    // return empty string for empty cells\n    return '';\n  }\n\n  /**\n   * Load data at `index` into `cell`. This is used to access cells in a way that's more friendly\n   * to GC as it significantly reduced the amount of new objects/references needed.\n   */\n  public loadCell(index: number, cell: ICellData): ICellData {\n    const startIndex = index * CELL_SIZE;\n    cell.content = this._data[startIndex + Cell.CONTENT];\n    cell.fg = this._data[startIndex + Cell.FG];\n    cell.bg = this._data[startIndex + Cell.BG];\n    if (cell.content & Content.IS_COMBINED_MASK) {\n      cell.combinedData = this._combined[index];\n    }\n    return cell;\n  }\n\n  /**\n   * Set data at `index` to `cell`.\n   */\n  public setCell(index: number, cell: ICellData): void {\n    if (cell.content & Content.IS_COMBINED_MASK) {\n      this._combined[index] = cell.combinedData;\n    }\n    this._data[index * CELL_SIZE + Cell.CONTENT] = cell.content;\n    this._data[index * CELL_SIZE + Cell.FG] = cell.fg;\n    this._data[index * CELL_SIZE + Cell.BG] = cell.bg;\n  }\n\n  /**\n   * Set cell data from input handler.\n   * Since the input handler see the incoming chars as UTF32 codepoints,\n   * it gets an optimized access method.\n   */\n  public setCellFromCodePoint(index: number, codePoint: number, width: number, fg: number, bg: number): void {\n    this._data[index * CELL_SIZE + Cell.CONTENT] = codePoint | (width << Content.WIDTH_SHIFT);\n    this._data[index * CELL_SIZE + Cell.FG] = fg;\n    this._data[index * CELL_SIZE + Cell.BG] = bg;\n  }\n\n  /**\n   * Add a codepoint to a cell from input handler.\n   * During input stage combining chars with a width of 0 follow and stack\n   * onto a leading char. Since we already set the attrs\n   * by the previous `setDataFromCodePoint` call, we can omit it here.\n   */\n  public addCodepointToCell(index: number, codePoint: number): void {\n    let content = this._data[index * CELL_SIZE + Cell.CONTENT];\n    if (content & Content.IS_COMBINED_MASK) {\n      // we already have a combined string, simply add\n      this._combined[index] += stringFromCodePoint(codePoint);\n    } else {\n      if (content & Content.CODEPOINT_MASK) {\n        // normal case for combining chars:\n        //  - move current leading char + new one into combined string\n        //  - set combined flag\n        this._combined[index] = stringFromCodePoint(content & Content.CODEPOINT_MASK) + stringFromCodePoint(codePoint);\n        content &= ~Content.CODEPOINT_MASK; // set codepoint in buffer to 0\n        content |= Content.IS_COMBINED_MASK;\n      } else {\n        // should not happen - we actually have no data in the cell yet\n        // simply set the data in the cell buffer with a width of 1\n        content = codePoint | (1 << Content.WIDTH_SHIFT);\n      }\n      this._data[index * CELL_SIZE + Cell.CONTENT] = content;\n    }\n  }\n\n  public insertCells(pos: number, n: number, fillCellData: ICellData): void {\n    pos %= this.length;\n    if (n < this.length - pos) {\n      const cell = new CellData();\n      for (let i = this.length - pos - n - 1; i >= 0; --i) {\n        this.setCell(pos + n + i, this.loadCell(pos + i, cell));\n      }\n      for (let i = 0; i < n; ++i) {\n        this.setCell(pos + i, fillCellData);\n      }\n    } else {\n      for (let i = pos; i < this.length; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    }\n  }\n\n  public deleteCells(pos: number, n: number, fillCellData: ICellData): void {\n    pos %= this.length;\n    if (n < this.length - pos) {\n      const cell = new CellData();\n      for (let i = 0; i < this.length - pos - n; ++i) {\n        this.setCell(pos + i, this.loadCell(pos + n + i, cell));\n      }\n      for (let i = this.length - n; i < this.length; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    } else {\n      for (let i = pos; i < this.length; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    }\n  }\n\n  public replaceCells(start: number, end: number, fillCellData: ICellData): void {\n    while (start < end  && start < this.length) {\n      this.setCell(start++, fillCellData);\n    }\n  }\n\n  public resize(cols: number, fillCellData: ICellData): void {\n    if (cols === this.length) {\n      return;\n    }\n    if (cols > this.length) {\n      const data = new Uint32Array(cols * CELL_SIZE);\n      if (this.length) {\n        if (cols * CELL_SIZE < this._data.length) {\n          data.set(this._data.subarray(0, cols * CELL_SIZE));\n        } else {\n          data.set(this._data);\n        }\n      }\n      this._data = data;\n      for (let i = this.length; i < cols; ++i) {\n        this.setCell(i, fillCellData);\n      }\n    } else {\n      if (cols) {\n        const data = new Uint32Array(cols * CELL_SIZE);\n        data.set(this._data.subarray(0, cols * CELL_SIZE));\n        this._data = data;\n        // Remove any cut off combined data\n        const keys = Object.keys(this._combined);\n        for (let i = 0; i < keys.length; i++) {\n          const key = parseInt(keys[i], 10);\n          if (key >= cols) {\n            delete this._combined[key];\n          }\n        }\n      } else {\n        this._data = new Uint32Array(0);\n        this._combined = {};\n      }\n    }\n    this.length = cols;\n  }\n\n  /** fill a line with fillCharData */\n  public fill(fillCellData: ICellData): void {\n    this._combined = {};\n    for (let i = 0; i < this.length; ++i) {\n      this.setCell(i, fillCellData);\n    }\n  }\n\n  /** alter to a full copy of line  */\n  public copyFrom(line: BufferLine): void {\n    if (this.length !== line.length) {\n      this._data = new Uint32Array(line._data);\n    } else {\n      // use high speed copy if lengths are equal\n      this._data.set(line._data);\n    }\n    this.length = line.length;\n    this._combined = {};\n    for (const el in line._combined) {\n      this._combined[el] = line._combined[el];\n    }\n    this.isWrapped = line.isWrapped;\n  }\n\n  /** create a new clone */\n  public clone(): IBufferLine {\n    const newLine = new BufferLine(0);\n    newLine._data = new Uint32Array(this._data);\n    newLine.length = this.length;\n    for (const el in this._combined) {\n      newLine._combined[el] = this._combined[el];\n    }\n    newLine.isWrapped = this.isWrapped;\n    return newLine;\n  }\n\n  public getTrimmedLength(): number {\n    for (let i = this.length - 1; i >= 0; --i) {\n      if ((this._data[i * CELL_SIZE + Cell.CONTENT] & Content.HAS_CONTENT_MASK)) {\n        return i + (this._data[i * CELL_SIZE + Cell.CONTENT] >> Content.WIDTH_SHIFT);\n      }\n    }\n    return 0;\n  }\n\n  public copyCellsFrom(src: BufferLine, srcCol: number, destCol: number, length: number, applyInReverse: boolean): void {\n    const srcData = src._data;\n    if (applyInReverse) {\n      for (let cell = length - 1; cell >= 0; cell--) {\n        for (let i = 0; i < CELL_SIZE; i++) {\n          this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];\n        }\n      }\n    } else {\n      for (let cell = 0; cell < length; cell++) {\n        for (let i = 0; i < CELL_SIZE; i++) {\n          this._data[(destCol + cell) * CELL_SIZE + i] = srcData[(srcCol + cell) * CELL_SIZE + i];\n        }\n      }\n    }\n\n    // Move any combined data over as needed\n    const srcCombinedKeys = Object.keys(src._combined);\n    for (let i = 0; i < srcCombinedKeys.length; i++) {\n      const key = parseInt(srcCombinedKeys[i], 10);\n      if (key >= srcCol) {\n        this._combined[key - srcCol + destCol] = src._combined[key];\n      }\n    }\n  }\n\n  public translateToString(trimRight: boolean = false, startCol: number = 0, endCol: number = this.length): string {\n    if (trimRight) {\n      endCol = Math.min(endCol, this.getTrimmedLength());\n    }\n    let result = '';\n    while (startCol < endCol) {\n      const content = this._data[startCol * CELL_SIZE + Cell.CONTENT];\n      const cp = content & Content.CODEPOINT_MASK;\n      result += (content & Content.IS_COMBINED_MASK) ? this._combined[startCol] : (cp) ? stringFromCodePoint(cp) : WHITESPACE_CELL_CHAR;\n      startCol += (content >> Content.WIDTH_SHIFT) || 1; // always advance by 1\n    }\n    return result;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport let promptLabel = 'Terminal input';\nexport let tooMuchOutput = 'Too much output to announce, navigate to rows manually to read';\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharset } from 'common/Types';\n\n/**\n * The character sets supported by the terminal. These enable several languages\n * to be represented within the terminal with only 8-bit encoding. See ISO 2022\n * for a discussion on character sets. Only VT100 character sets are supported.\n */\nexport const CHARSETS: { [key: string]: ICharset | null } = {};\n\n/**\n * The default character set, US.\n */\nexport const DEFAULT_CHARSET: ICharset | null = CHARSETS['B'];\n\n/**\n * DEC Special Character and Line Drawing Set.\n * Reference: http://vt100.net/docs/vt102-ug/table5-13.html\n * A lot of curses apps use this if they see TERM=xterm.\n * testing: echo -e '\\e(0a\\e(B'\n * The xterm output sometimes seems to conflict with the\n * reference above. xterm seems in line with the reference\n * when running vttest however.\n * The table below now uses xterm's output from vttest.\n */\nCHARSETS['0'] = {\n  '`': '\\u25c6', // '◆'\n  'a': '\\u2592', // '▒'\n  'b': '\\u0009', // '\\t'\n  'c': '\\u000c', // '\\f'\n  'd': '\\u000d', // '\\r'\n  'e': '\\u000a', // '\\n'\n  'f': '\\u00b0', // '°'\n  'g': '\\u00b1', // '±'\n  'h': '\\u2424', // '\\u2424' (NL)\n  'i': '\\u000b', // '\\v'\n  'j': '\\u2518', // '┘'\n  'k': '\\u2510', // '┐'\n  'l': '\\u250c', // '┌'\n  'm': '\\u2514', // '└'\n  'n': '\\u253c', // '┼'\n  'o': '\\u23ba', // '⎺'\n  'p': '\\u23bb', // '⎻'\n  'q': '\\u2500', // '─'\n  'r': '\\u23bc', // '⎼'\n  's': '\\u23bd', // '⎽'\n  't': '\\u251c', // '├'\n  'u': '\\u2524', // '┤'\n  'v': '\\u2534', // '┴'\n  'w': '\\u252c', // '┬'\n  'x': '\\u2502', // '│'\n  'y': '\\u2264', // '≤'\n  'z': '\\u2265', // '≥'\n  '{': '\\u03c0', // 'π'\n  '|': '\\u2260', // '≠'\n  '}': '\\u00a3', // '£'\n  '~': '\\u00b7'  // '·'\n};\n\n/**\n * British character set\n * ESC (A\n * Reference: http://vt100.net/docs/vt220-rm/table2-5.html\n */\nCHARSETS['A'] = {\n  '#': '£'\n};\n\n/**\n * United States character set\n * ESC (B\n */\nCHARSETS['B'] = null;\n\n/**\n * Dutch character set\n * ESC (4\n * Reference: http://vt100.net/docs/vt220-rm/table2-6.html\n */\nCHARSETS['4'] = {\n  '#': '£',\n  '@': '¾',\n  '[': 'ij',\n  '\\\\': '½',\n  ']': '|',\n  '{': '¨',\n  '|': 'f',\n  '}': '¼',\n  '~': '´'\n};\n\n/**\n * Finnish character set\n * ESC (C or ESC (5\n * Reference: http://vt100.net/docs/vt220-rm/table2-7.html\n */\nCHARSETS['C'] =\nCHARSETS['5'] = {\n  '[': 'Ä',\n  '\\\\': 'Ö',\n  ']': 'Å',\n  '^': 'Ü',\n  '`': 'é',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'å',\n  '~': 'ü'\n};\n\n/**\n * French character set\n * ESC (R\n * Reference: http://vt100.net/docs/vt220-rm/table2-8.html\n */\nCHARSETS['R'] = {\n  '#': '£',\n  '@': 'à',\n  '[': '°',\n  '\\\\': 'ç',\n  ']': '§',\n  '{': 'é',\n  '|': 'ù',\n  '}': 'è',\n  '~': '¨'\n};\n\n/**\n * French Canadian character set\n * ESC (Q\n * Reference: http://vt100.net/docs/vt220-rm/table2-9.html\n */\nCHARSETS['Q'] = {\n  '@': 'à',\n  '[': 'â',\n  '\\\\': 'ç',\n  ']': 'ê',\n  '^': 'î',\n  '`': 'ô',\n  '{': 'é',\n  '|': 'ù',\n  '}': 'è',\n  '~': 'û'\n};\n\n/**\n * German character set\n * ESC (K\n * Reference: http://vt100.net/docs/vt220-rm/table2-10.html\n */\nCHARSETS['K'] = {\n  '@': '§',\n  '[': 'Ä',\n  '\\\\': 'Ö',\n  ']': 'Ü',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'ü',\n  '~': 'ß'\n};\n\n/**\n * Italian character set\n * ESC (Y\n * Reference: http://vt100.net/docs/vt220-rm/table2-11.html\n */\nCHARSETS['Y'] = {\n  '#': '£',\n  '@': '§',\n  '[': '°',\n  '\\\\': 'ç',\n  ']': 'é',\n  '`': 'ù',\n  '{': 'à',\n  '|': 'ò',\n  '}': 'è',\n  '~': 'ì'\n};\n\n/**\n * Norwegian/Danish character set\n * ESC (E or ESC (6\n * Reference: http://vt100.net/docs/vt220-rm/table2-12.html\n */\nCHARSETS['E'] =\nCHARSETS['6'] = {\n  '@': 'Ä',\n  '[': 'Æ',\n  '\\\\': 'Ø',\n  ']': 'Å',\n  '^': 'Ü',\n  '`': 'ä',\n  '{': 'æ',\n  '|': 'ø',\n  '}': 'å',\n  '~': 'ü'\n};\n\n/**\n * Spanish character set\n * ESC (Z\n * Reference: http://vt100.net/docs/vt220-rm/table2-13.html\n */\nCHARSETS['Z'] = {\n  '#': '£',\n  '@': '§',\n  '[': '¡',\n  '\\\\': 'Ñ',\n  ']': '¿',\n  '{': '°',\n  '|': 'ñ',\n  '}': 'ç'\n};\n\n/**\n * Swedish character set\n * ESC (H or ESC (7\n * Reference: http://vt100.net/docs/vt220-rm/table2-14.html\n */\nCHARSETS['H'] =\nCHARSETS['7'] = {\n  '@': 'É',\n  '[': 'Ä',\n  '\\\\': 'Ö',\n  ']': 'Å',\n  '^': 'Ü',\n  '`': 'é',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'å',\n  '~': 'ü'\n};\n\n/**\n * Swiss character set\n * ESC (=\n * Reference: http://vt100.net/docs/vt220-rm/table2-15.html\n */\nCHARSETS['='] = {\n  '#': 'ù',\n  '@': 'à',\n  '[': 'é',\n  '\\\\': 'ç',\n  ']': 'ê',\n  '^': 'î',\n  '_': 'è',\n  '`': 'ô',\n  '{': 'ä',\n  '|': 'ö',\n  '}': 'ü',\n  '~': 'û'\n};\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { fill } from 'common/TypedArrayUtils';\n\nexport const wcwidth = (function(opts: {nul: number, control: number}): (ucs: number) => number {\n  // extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c\n  // combining characters\n  const COMBINING_BMP = [\n    [0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],\n    [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2],\n    [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603],\n    [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670],\n    [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED],\n    [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A],\n    [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902],\n    [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D],\n    [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981],\n    [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD],\n    [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C],\n    [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D],\n    [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC],\n    [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD],\n    [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C],\n    [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D],\n    [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0],\n    [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48],\n    [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC],\n    [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD],\n    [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D],\n    [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6],\n    [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E],\n    [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC],\n    [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35],\n    [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E],\n    [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97],\n    [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030],\n    [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039],\n    [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F],\n    [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753],\n    [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD],\n    [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD],\n    [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922],\n    [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B],\n    [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34],\n    [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42],\n    [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF],\n    [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063],\n    [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F],\n    [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B],\n    [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F],\n    [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]\n  ];\n  const COMBINING_HIGH = [\n    [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F],\n    [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169],\n    [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD],\n    [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F],\n    [0xE0100, 0xE01EF]\n  ];\n  // binary search\n  function bisearch(ucs: number, data: number[][]): boolean {\n    let min = 0;\n    let max = data.length - 1;\n    let mid;\n    if (ucs < data[0][0] || ucs > data[max][1]) {\n      return false;\n    }\n    while (max >= min) {\n      mid = (min + max) >> 1;\n      if (ucs > data[mid][1]) {\n        min = mid + 1;\n      } else if (ucs < data[mid][0]) {\n        max = mid - 1;\n      } else {\n        return true;\n      }\n    }\n    return false;\n  }\n  function wcwidthHigh(ucs: number): 0 | 1 | 2 {\n    if (bisearch(ucs, COMBINING_HIGH)) {\n      return 0;\n    }\n    if ((ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd)) {\n      return 2;\n    }\n    return 1;\n  }\n  const control = opts.control | 0;\n\n  // create lookup table for BMP plane\n  const table = new Uint8Array(65536);\n  fill(table, 1);\n  table[0] = opts.nul;\n  // control chars\n  fill(table, opts.control, 1, 32);\n  fill(table, opts.control, 0x7f, 0xa0);\n\n  // apply wide char rules first\n  // wide chars\n  fill(table, 2, 0x1100, 0x1160);\n  table[0x2329] = 2;\n  table[0x232a] = 2;\n  fill(table, 2, 0x2e80, 0xa4d0);\n  table[0x303f] = 1;  // wrongly in last line\n\n  fill(table, 2, 0xac00, 0xd7a4);\n  fill(table, 2, 0xf900, 0xfb00);\n  fill(table, 2, 0xfe10, 0xfe1a);\n  fill(table, 2, 0xfe30, 0xfe70);\n  fill(table, 2, 0xff00, 0xff61);\n  fill(table, 2, 0xffe0, 0xffe7);\n\n  // apply combining last to ensure we overwrite\n  // wrongly wide set chars:\n  //    the original algo evals combining first and falls\n  //    through to wide check so we simply do here the opposite\n  // combining 0\n  for (let r = 0; r < COMBINING_BMP.length; ++r) {\n    fill(table, 0, COMBINING_BMP[r][0], COMBINING_BMP[r][1] + 1);\n  }\n\n  return function (num: number): number {\n    if (num < 32) {\n      return control | 0;\n    }\n    if (num < 127) {\n      return 1;\n    }\n    if (num < 65536) {\n      return table[num];\n    }\n    // do a full search for high codepoints\n    return wcwidthHigh(num);\n  };\n})({nul: 0, control: 0});  // configurable options\n\n/**\n * Get the terminal cell width for a string.\n */\nexport function getStringCellWidth(s: string): number {\n  let result = 0;\n  const length = s.length;\n  for (let i = 0; i < length; ++i) {\n    let code = s.charCodeAt(i);\n    // surrogate pair first\n    if (0xD800 <= code && code <= 0xDBFF) {\n      if (++i >= length) {\n        // this should not happen with strings retrieved from\n        // Buffer.translateToString as it converts from UTF-32\n        // and therefore always should contain the second part\n        // for any other string we still have to handle it somehow:\n        // simply treat the lonely surrogate first as a single char (UCS-2 behavior)\n        return result + wcwidth(code);\n      }\n      const second = s.charCodeAt(i);\n      // convert surrogate pair to high codepoint only for valid second part (UTF-16)\n      // otherwise treat them independently (UCS-2 behavior)\n      if (0xDC00 <= second && second <= 0xDFFF) {\n        code = (code - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;\n      } else {\n        result += wcwidth(second);\n      }\n    }\n    result += wcwidth(code);\n  }\n  return result;\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\nimport { IParams, ParamsArray } from 'common/parser/Types';\n\n// max value supported for a single param/subparam (clamped to positive int32 range)\nconst MAX_VALUE = 0x7FFFFFFF;\n// max allowed subparams for a single sequence (hardcoded limitation)\nconst MAX_SUBPARAMS = 256;\n\n/**\n * Params storage class.\n * This type is used by the parser to accumulate sequence parameters and sub parameters\n * and transmit them to the input handler actions.\n *\n * NOTES:\n *  - params object for action handlers is borrowed, use `.toArray` or `.clone` to get a copy\n *  - never read beyond `params.length - 1` (likely to contain arbitrary data)\n *  - `.getSubParams` returns a borrowed typed array, use `.getSubParamsAll` for cloned sub params\n *  - hardcoded limitations:\n *    - max. value for a single (sub) param is 2^31 - 1 (greater values are clamped to that)\n *    - max. 256 sub params possible\n *    - negative values are not allowed beside -1 (placeholder for default value)\n *\n * About ZDM (Zero Default Mode):\n * ZDM is not orchestrated by this class. If the parser is in ZDM,\n * it should add 0 for empty params, otherwise -1. This does not apply\n * to subparams, empty subparams should always be added with -1.\n */\nexport class Params implements IParams {\n  // params store and length\n  public params: Int32Array;\n  public length: number;\n\n  // sub params store and length\n  protected _subParams: Int32Array;\n  protected _subParamsLength: number;\n\n  // sub params offsets from param: param idx --> [start, end] offset\n  private _subParamsIdx: Uint16Array;\n  private _rejectDigits: boolean;\n  private _rejectSubDigits: boolean;\n  private _digitIsSub: boolean;\n\n  /**\n   * Create a `Params` type from JS array representation.\n   */\n  public static fromArray(values: ParamsArray): Params {\n    const params = new Params();\n    if (!values.length) {\n      return params;\n    }\n    // skip leading sub params\n    for (let i = (values[0] instanceof Array) ? 1 : 0; i < values.length; ++i) {\n      const value = values[i];\n      if (value instanceof Array) {\n        for (let k = 0; k < value.length; ++k) {\n          params.addSubParam(value[k]);\n        }\n      } else {\n        params.addParam(value);\n      }\n    }\n    return params;\n  }\n\n  /**\n   * @param maxLength max length of storable parameters\n   * @param maxSubParamsLength max length of storable sub parameters\n   */\n  constructor(public maxLength: number = 32, public maxSubParamsLength: number = 32) {\n    if (maxSubParamsLength > MAX_SUBPARAMS) {\n      throw new Error('maxSubParamsLength must not be greater than 256');\n    }\n    this.params = new Int32Array(maxLength);\n    this.length = 0;\n    this._subParams = new Int32Array(maxSubParamsLength);\n    this._subParamsLength = 0;\n    this._subParamsIdx = new Uint16Array(maxLength);\n    this._rejectDigits = false;\n    this._rejectSubDigits = false;\n    this._digitIsSub = false;\n  }\n\n  /**\n   * Clone object.\n   */\n  public clone(): Params {\n    const newParams = new Params(this.maxLength, this.maxSubParamsLength);\n    newParams.params.set(this.params);\n    newParams.length = this.length;\n    newParams._subParams.set(this._subParams);\n    newParams._subParamsLength = this._subParamsLength;\n    newParams._subParamsIdx.set(this._subParamsIdx);\n    newParams._rejectDigits = this._rejectDigits;\n    newParams._rejectSubDigits = this._rejectSubDigits;\n    newParams._digitIsSub = this._digitIsSub;\n    return newParams;\n  }\n\n  /**\n   * Get a JS array representation of the current parameters and sub parameters.\n   * The array is structured as follows:\n   *    sequence: \"1;2:3:4;5::6\"\n   *    array   : [1, 2, [3, 4], 5, [-1, 6]]\n   */\n  public toArray(): ParamsArray {\n    const res: ParamsArray = [];\n    for (let i = 0; i < this.length; ++i) {\n      res.push(this.params[i]);\n      const start = this._subParamsIdx[i] >> 8;\n      const end = this._subParamsIdx[i] & 0xFF;\n      if (end - start > 0) {\n        res.push(Array.prototype.slice.call(this._subParams, start, end));\n      }\n    }\n    return res;\n  }\n\n  /**\n   * Reset to initial empty state.\n   */\n  public reset(): void {\n    this.length = 0;\n    this._subParamsLength = 0;\n    this._rejectDigits = false;\n    this._rejectSubDigits = false;\n    this._digitIsSub = false;\n  }\n\n  /**\n   * Add a parameter value.\n   * `Params` only stores up to `maxLength` parameters, any later\n   * parameter will be ignored.\n   * Note: VT devices only stored up to 16 values, xterm seems to\n   * store up to 30.\n   */\n  public addParam(value: number): void {\n    this._digitIsSub = false;\n    if (this.length >= this.maxLength) {\n      this._rejectDigits = true;\n      return;\n    }\n    if (value < -1) {\n      throw new Error('values lesser than -1 are not allowed');\n    }\n    this._subParamsIdx[this.length] = this._subParamsLength << 8 | this._subParamsLength;\n    this.params[this.length++] = value > MAX_VALUE ? MAX_VALUE : value;\n  }\n\n  /**\n   * Add a sub parameter value.\n   * The sub parameter is automatically associated with the last parameter value.\n   * Thus it is not possible to add a subparameter without any parameter added yet.\n   * `Params` only stores up to `subParamsLength` sub parameters, any later\n   * sub parameter will be ignored.\n   */\n  public addSubParam(value: number): void {\n    this._digitIsSub = true;\n    if (!this.length) {\n      return;\n    }\n    if (this._rejectDigits || this._subParamsLength >= this.maxSubParamsLength) {\n      this._rejectSubDigits = true;\n      return;\n    }\n    if (value < -1) {\n      throw new Error('values lesser than -1 are not allowed');\n    }\n    this._subParams[this._subParamsLength++] = value > MAX_VALUE ? MAX_VALUE : value;\n    this._subParamsIdx[this.length - 1]++;\n  }\n\n  /**\n   * Whether parameter at index `idx` has sub parameters.\n   */\n  public hasSubParams(idx: number): boolean {\n    return ((this._subParamsIdx[idx] & 0xFF) - (this._subParamsIdx[idx] >> 8) > 0);\n  }\n\n  /**\n   * Return sub parameters for parameter at index `idx`.\n   * Note: The values are borrowed, thus you need to copy\n   * the values if you need to hold them in nonlocal scope.\n   */\n  public getSubParams(idx: number): Int32Array | null {\n    const start = this._subParamsIdx[idx] >> 8;\n    const end = this._subParamsIdx[idx] & 0xFF;\n    if (end - start > 0) {\n      return this._subParams.subarray(start, end);\n    }\n    return null;\n  }\n\n  /**\n   * Return all sub parameters as {idx: subparams} mapping.\n   * Note: The values are not borrowed.\n   */\n  public getSubParamsAll(): {[idx: number]: Int32Array} {\n    const result: {[idx: number]: Int32Array} = {};\n    for (let i = 0; i < this.length; ++i) {\n      const start = this._subParamsIdx[i] >> 8;\n      const end = this._subParamsIdx[i] & 0xFF;\n      if (end - start > 0) {\n        result[i] = this._subParams.slice(start, end);\n      }\n    }\n    return result;\n  }\n\n  /**\n   * Add a single digit value to current parameter.\n   * This is used by the parser to account digits on a char by char basis.\n   */\n  public addDigit(value: number): void {\n    let length;\n    if (this._rejectDigits\n      || !(length = this._digitIsSub ? this._subParamsLength : this.length)\n      || (this._digitIsSub && this._rejectSubDigits)\n    ) {\n      return;\n    }\n\n    const store = this._digitIsSub ? this._subParams : this.params;\n    const cur = store[length - 1];\n    store[length - 1] = ~cur ? Math.min(cur * 10 + value, MAX_VALUE) : value;\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IOscHandler, IHandlerCollection, OscFallbackHandlerType, IOscParser } from 'common/parser/Types';\nimport { OscState, PAYLOAD_LIMIT } from 'common/parser/Constants';\nimport { utf32ToString } from 'common/input/TextDecoder';\nimport { IDisposable } from 'common/Types';\n\n\nexport class OscParser implements IOscParser {\n  private _state = OscState.START;\n  private _id = -1;\n  private _handlers: IHandlerCollection<IOscHandler> = Object.create(null);\n  private _handlerFb: OscFallbackHandlerType = () => { };\n\n  public addHandler(ident: number, handler: IOscHandler): IDisposable {\n    if (this._handlers[ident] === undefined) {\n      this._handlers[ident] = [];\n    }\n    const handlerList = this._handlers[ident];\n    handlerList.push(handler);\n    return {\n      dispose: () => {\n        const handlerIndex = handlerList.indexOf(handler);\n        if (handlerIndex !== -1) {\n          handlerList.splice(handlerIndex, 1);\n        }\n      }\n    };\n  }\n  public setHandler(ident: number, handler: IOscHandler): void {\n    this._handlers[ident] = [handler];\n  }\n  public clearHandler(ident: number): void {\n    if (this._handlers[ident]) delete this._handlers[ident];\n  }\n  public setHandlerFallback(handler: OscFallbackHandlerType): void {\n    this._handlerFb = handler;\n  }\n\n  public dispose(): void {\n    this._handlers = Object.create(null);\n    this._handlerFb = () => {};\n  }\n\n  public reset(): void {\n    // cleanup handlers if payload was already sent\n    if (this._state === OscState.PAYLOAD) {\n      this.end(false);\n    }\n    this._id = -1;\n    this._state = OscState.START;\n  }\n\n  private _start(): void {\n    const handlers = this._handlers[this._id];\n    if (!handlers) {\n      this._handlerFb(this._id, 'START');\n    } else {\n      for (let j = handlers.length - 1; j >= 0; j--) {\n        handlers[j].start();\n      }\n    }\n  }\n\n  private _put(data: Uint32Array, start: number, end: number): void {\n    const handlers = this._handlers[this._id];\n    if (!handlers) {\n      this._handlerFb(this._id, 'PUT', utf32ToString(data, start, end));\n    } else {\n      for (let j = handlers.length - 1; j >= 0; j--) {\n        handlers[j].put(data, start, end);\n      }\n    }\n  }\n\n  private _end(success: boolean): void {\n    // other than the old code we always have to call .end\n    // to keep the bubbling we use `success` to indicate\n    // whether a handler should execute\n    const handlers = this._handlers[this._id];\n    if (!handlers) {\n      this._handlerFb(this._id, 'END', success);\n    } else {\n      let j = handlers.length - 1;\n      for (; j >= 0; j--) {\n        if (handlers[j].end(success) !== false) {\n          break;\n        }\n      }\n      j--;\n      // cleanup left over handlers\n      for (; j >= 0; j--) {\n        handlers[j].end(false);\n      }\n    }\n  }\n\n  public start(): void {\n    // always reset leftover handlers\n    this.reset();\n    this._id = -1;\n    this._state = OscState.ID;\n  }\n\n  /**\n   * Put data to current OSC command.\n   * Expects the identifier of the OSC command in the form\n   * OSC id ; payload ST/BEL\n   * Payload chunks are not further processed and get\n   * directly passed to the handlers.\n   */\n  public put(data: Uint32Array, start: number, end: number): void {\n    if (this._state === OscState.ABORT) {\n      return;\n    }\n    if (this._state === OscState.ID) {\n      while (start < end) {\n        const code = data[start++];\n        if (code === 0x3b) {\n          this._state = OscState.PAYLOAD;\n          this._start();\n          break;\n        }\n        if (code < 0x30 || 0x39 < code) {\n          this._state = OscState.ABORT;\n          return;\n        }\n        if (this._id === -1) {\n          this._id = 0;\n        }\n        this._id = this._id * 10 + code - 48;\n      }\n    }\n    if (this._state === OscState.PAYLOAD && end - start > 0) {\n      this._put(data, start, end);\n    }\n  }\n\n  /**\n   * Indicates end of an OSC command.\n   * Whether the OSC got aborted or finished normally\n   * is indicated by `success`.\n   */\n  public end(success: boolean): void {\n    if (this._state === OscState.START) {\n      return;\n    }\n    // do nothing if command was faulty\n    if (this._state !== OscState.ABORT) {\n      // if we are still in ID state and get an early end\n      // means that the command has no payload thus we still have\n      // to announce START and send END right after\n      if (this._state === OscState.ID) {\n        this._start();\n      }\n      this._end(success);\n    }\n    this._id = -1;\n    this._state = OscState.START;\n  }\n}\n\n/**\n * Convenient class to allow attaching string based handler functions\n * as OSC handlers.\n */\nexport class OscHandler implements IOscHandler {\n  private _data = '';\n  private _hitLimit: boolean = false;\n\n  constructor(private _handler: (data: string) => any) {}\n\n  public start(): void {\n    this._data = '';\n    this._hitLimit = false;\n  }\n\n  public put(data: Uint32Array, start: number, end: number): void {\n    if (this._hitLimit) {\n      return;\n    }\n    this._data += utf32ToString(data, start, end);\n    if (this._data.length > PAYLOAD_LIMIT) {\n      this._data = '';\n      this._hitLimit = true;\n    }\n  }\n\n  public end(success: boolean): any {\n    let ret;\n    if (this._hitLimit) {\n      ret = false;\n    } else if (success) {\n      ret = this._handler(this._data);\n    }\n    this._data = '';\n    this._hitLimit = false;\n    return ret;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/**\n * Internal states of EscapeSequenceParser.\n */\nexport const enum ParserState {\n  GROUND = 0,\n  ESCAPE = 1,\n  ESCAPE_INTERMEDIATE = 2,\n  CSI_ENTRY = 3,\n  CSI_PARAM = 4,\n  CSI_INTERMEDIATE = 5,\n  CSI_IGNORE = 6,\n  SOS_PM_APC_STRING = 7,\n  OSC_STRING = 8,\n  DCS_ENTRY = 9,\n  DCS_PARAM = 10,\n  DCS_IGNORE = 11,\n  DCS_INTERMEDIATE = 12,\n  DCS_PASSTHROUGH = 13\n}\n\n/**\n* Internal actions of EscapeSequenceParser.\n*/\nexport const enum ParserAction {\n  IGNORE = 0,\n  ERROR = 1,\n  PRINT = 2,\n  EXECUTE = 3,\n  OSC_START = 4,\n  OSC_PUT = 5,\n  OSC_END = 6,\n  CSI_DISPATCH = 7,\n  PARAM = 8,\n  COLLECT = 9,\n  ESC_DISPATCH = 10,\n  CLEAR = 11,\n  DCS_HOOK = 12,\n  DCS_PUT = 13,\n  DCS_UNHOOK = 14\n}\n\n/**\n * Internal states of OscParser.\n */\nexport const enum OscState {\n  START = 0,\n  ID = 1,\n  PAYLOAD = 2,\n  ABORT = 3\n}\n\n// payload limit for OSC and DCS\nexport const PAYLOAD_LIMIT = 10000000;\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from 'common/Types';\nimport { IDcsHandler, IParams, IHandlerCollection, IDcsParser, DcsFallbackHandlerType } from 'common/parser/Types';\nimport { utf32ToString } from 'common/input/TextDecoder';\nimport { Params } from 'common/parser/Params';\nimport { PAYLOAD_LIMIT } from 'common/parser/Constants';\n\nconst EMPTY_HANDLERS: IDcsHandler[] = [];\n\nexport class DcsParser implements IDcsParser {\n  private _handlers: IHandlerCollection<IDcsHandler> = Object.create(null);\n  private _active: IDcsHandler[] = EMPTY_HANDLERS;\n  private _ident: number = 0;\n  private _handlerFb: DcsFallbackHandlerType = () => {};\n\n  public dispose(): void {\n    this._handlers = Object.create(null);\n    this._handlerFb = () => {};\n  }\n\n  public addHandler(ident: number, handler: IDcsHandler): IDisposable {\n    if (this._handlers[ident] === undefined) {\n      this._handlers[ident] = [];\n    }\n    const handlerList = this._handlers[ident];\n    handlerList.push(handler);\n    return {\n      dispose: () => {\n        const handlerIndex = handlerList.indexOf(handler);\n        if (handlerIndex !== -1) {\n          handlerList.splice(handlerIndex, 1);\n        }\n      }\n    };\n  }\n\n  public setHandler(ident: number, handler: IDcsHandler): void {\n    this._handlers[ident] = [handler];\n  }\n\n  public clearHandler(ident: number): void {\n    if (this._handlers[ident]) delete this._handlers[ident];\n  }\n\n  public setHandlerFallback(handler: DcsFallbackHandlerType): void {\n    this._handlerFb = handler;\n  }\n\n  public reset(): void {\n    if (this._active.length) {\n      this.unhook(false);\n    }\n    this._active = EMPTY_HANDLERS;\n    this._ident = 0;\n  }\n\n  public hook(ident: number, params: IParams): void {\n    // always reset leftover handlers\n    this.reset();\n    this._ident = ident;\n    this._active = this._handlers[ident] || EMPTY_HANDLERS;\n    if (!this._active.length) {\n      this._handlerFb(this._ident, 'HOOK', params);\n    } else {\n      for (let j = this._active.length - 1; j >= 0; j--) {\n        this._active[j].hook(params);\n      }\n    }\n  }\n\n  public put(data: Uint32Array, start: number, end: number): void {\n    if (!this._active.length) {\n      this._handlerFb(this._ident, 'PUT', utf32ToString(data, start, end));\n    } else {\n      for (let j = this._active.length - 1; j >= 0; j--) {\n        this._active[j].put(data, start, end);\n      }\n    }\n  }\n\n  public unhook(success: boolean): void {\n    if (!this._active.length) {\n      this._handlerFb(this._ident, 'UNHOOK', success);\n    } else {\n      let j = this._active.length - 1;\n      for (; j >= 0; j--) {\n        if (this._active[j].unhook(success) !== false) {\n          break;\n        }\n      }\n      j--;\n      // cleanup left over handlers\n      for (; j >= 0; j--) {\n        this._active[j].unhook(false);\n      }\n    }\n    this._active = EMPTY_HANDLERS;\n    this._ident = 0;\n  }\n}\n\n/**\n * Convenient class to create a DCS handler from a single callback function.\n * Note: The payload is currently limited to 50 MB (hardcoded).\n */\nexport class DcsHandler implements IDcsHandler {\n  private _data = '';\n  private _params: IParams | undefined;\n  private _hitLimit: boolean = false;\n\n  constructor(private _handler: (data: string, params: IParams) => any) {}\n\n  public hook(params: IParams): void {\n    this._params = params.clone();\n    this._data = '';\n    this._hitLimit = false;\n  }\n\n  public put(data: Uint32Array, start: number, end: number): void {\n    if (this._hitLimit) {\n      return;\n    }\n    this._data += utf32ToString(data, start, end);\n    if (this._data.length > PAYLOAD_LIMIT) {\n      this._data = '';\n      this._hitLimit = true;\n    }\n  }\n\n  public unhook(success: boolean): any {\n    let ret;\n    if (this._hitLimit) {\n      ret = false;\n    } else if (success) {\n      ret = this._handler(this._data, this._params ? this._params : new Params());\n    }\n    this._params = undefined;\n    this._data = '';\n    this._hitLimit = false;\n    return ret;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { generateConfig, configEquals } from 'browser/renderer/atlas/CharAtlasUtils';\nimport { BaseCharAtlas } from 'browser/renderer/atlas/BaseCharAtlas';\nimport { DynamicCharAtlas } from 'browser/renderer/atlas/DynamicCharAtlas';\nimport { ICharAtlasConfig } from 'browser/renderer/atlas/Types';\nimport { IColorSet } from 'browser/Types';\nimport { ITerminalOptions } from 'common/services/Services';\n\ninterface ICharAtlasCacheEntry {\n  atlas: BaseCharAtlas;\n  config: ICharAtlasConfig;\n  // N.B. This implementation potentially holds onto copies of the terminal forever, so\n  // this may cause memory leaks.\n  ownedBy: number[];\n}\n\nconst charAtlasCache: ICharAtlasCacheEntry[] = [];\n\n/**\n * Acquires a char atlas, either generating a new one or returning an existing\n * one that is in use by another terminal.\n */\nexport function acquireCharAtlas(\n  options: ITerminalOptions,\n  rendererId: number,\n  colors: IColorSet,\n  scaledCharWidth: number,\n  scaledCharHeight: number\n): BaseCharAtlas {\n  const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, options, colors);\n\n  // Check to see if the renderer already owns this config\n  for (let i = 0; i < charAtlasCache.length; i++) {\n    const entry = charAtlasCache[i];\n    const ownedByIndex = entry.ownedBy.indexOf(rendererId);\n    if (ownedByIndex >= 0) {\n      if (configEquals(entry.config, newConfig)) {\n        return entry.atlas;\n      }\n      // The configs differ, release the renderer from the entry\n      if (entry.ownedBy.length === 1) {\n        entry.atlas.dispose();\n        charAtlasCache.splice(i, 1);\n      } else {\n        entry.ownedBy.splice(ownedByIndex, 1);\n      }\n      break;\n    }\n  }\n\n  // Try match a char atlas from the cache\n  for (let i = 0; i < charAtlasCache.length; i++) {\n    const entry = charAtlasCache[i];\n    if (configEquals(entry.config, newConfig)) {\n      // Add the renderer to the cache entry and return\n      entry.ownedBy.push(rendererId);\n      return entry.atlas;\n    }\n  }\n\n  const newEntry: ICharAtlasCacheEntry = {\n    atlas: new DynamicCharAtlas(\n      document,\n      newConfig\n    ),\n    config: newConfig,\n    ownedBy: [rendererId]\n  };\n  charAtlasCache.push(newEntry);\n  return newEntry.atlas;\n}\n\n/**\n * Removes a terminal reference from the cache, allowing its memory to be freed.\n */\nexport function removeTerminalFromCache(rendererId: number): void {\n  for (let i = 0; i < charAtlasCache.length; i++) {\n    const index = charAtlasCache[i].ownedBy.indexOf(rendererId);\n    if (index !== -1) {\n      if (charAtlasCache[i].ownedBy.length === 1) {\n        // Remove the cache entry if it's the only renderer\n        charAtlasCache[i].atlas.dispose();\n        charAtlasCache.splice(i, 1);\n      } else {\n        // Remove the reference from the cache entry\n        charAtlasCache[i].ownedBy.splice(index, 1);\n      }\n      break;\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharAtlasConfig } from 'browser/renderer/atlas/Types';\nimport { DEFAULT_COLOR } from 'common/buffer/Constants';\nimport { IColorSet, IPartialColorSet } from 'browser/Types';\nimport { ITerminalOptions } from 'common/services/Services';\n\nexport function generateConfig(scaledCharWidth: number, scaledCharHeight: number, options: ITerminalOptions, colors: IColorSet): ICharAtlasConfig {\n  // null out some fields that don't matter\n  const clonedColors = <IPartialColorSet>{\n    foreground: colors.foreground,\n    background: colors.background,\n    cursor: undefined,\n    cursorAccent: undefined,\n    selection: undefined,\n    // For the static char atlas, we only use the first 16 colors, but we need all 256 for the\n    // dynamic character atlas.\n    ansi: colors.ansi.slice(0, 16)\n  };\n  return {\n    devicePixelRatio: window.devicePixelRatio,\n    scaledCharWidth,\n    scaledCharHeight,\n    fontFamily: options.fontFamily,\n    fontSize: options.fontSize,\n    fontWeight: options.fontWeight,\n    fontWeightBold: options.fontWeightBold,\n    allowTransparency: options.allowTransparency,\n    colors: clonedColors\n  };\n}\n\nexport function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean {\n  for (let i = 0; i < a.colors.ansi.length; i++) {\n    if (a.colors.ansi[i].rgba !== b.colors.ansi[i].rgba) {\n      return false;\n    }\n  }\n  return a.devicePixelRatio === b.devicePixelRatio &&\n      a.fontFamily === b.fontFamily &&\n      a.fontSize === b.fontSize &&\n      a.fontWeight === b.fontWeight &&\n      a.fontWeightBold === b.fontWeightBold &&\n      a.allowTransparency === b.allowTransparency &&\n      a.scaledCharWidth === b.scaledCharWidth &&\n      a.scaledCharHeight === b.scaledCharHeight &&\n      a.colors.foreground === b.colors.foreground &&\n      a.colors.background === b.colors.background;\n}\n\nexport function is256Color(colorCode: number): boolean {\n  return colorCode < DEFAULT_COLOR;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IColorManager, IColor, IColorSet, IColorContrastCache } from 'browser/Types';\nimport { ITheme } from 'common/services/Services';\nimport { fromCss, toCss, blend, toRgba, toPaddedHex } from 'browser/Color';\nimport { ColorContrastCache } from 'browser/ColorContrastCache';\n\nconst DEFAULT_FOREGROUND = fromCss('#ffffff');\nconst DEFAULT_BACKGROUND = fromCss('#000000');\nconst DEFAULT_CURSOR = fromCss('#ffffff');\nconst DEFAULT_CURSOR_ACCENT = fromCss('#000000');\nconst DEFAULT_SELECTION = {\n  css: 'rgba(255, 255, 255, 0.3)',\n  rgba: 0xFFFFFF4D\n};\n\n// An IIFE to generate DEFAULT_ANSI_COLORS. Do not mutate DEFAULT_ANSI_COLORS, instead make a copy\n// and mutate that.\nexport const DEFAULT_ANSI_COLORS = (() => {\n  const colors = [\n    // dark:\n    fromCss('#2e3436'),\n    fromCss('#cc0000'),\n    fromCss('#4e9a06'),\n    fromCss('#c4a000'),\n    fromCss('#3465a4'),\n    fromCss('#75507b'),\n    fromCss('#06989a'),\n    fromCss('#d3d7cf'),\n    // bright:\n    fromCss('#555753'),\n    fromCss('#ef2929'),\n    fromCss('#8ae234'),\n    fromCss('#fce94f'),\n    fromCss('#729fcf'),\n    fromCss('#ad7fa8'),\n    fromCss('#34e2e2'),\n    fromCss('#eeeeec')\n  ];\n\n  // Fill in the remaining 240 ANSI colors.\n  // Generate colors (16-231)\n  const v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];\n  for (let i = 0; i < 216; i++) {\n    const r = v[(i / 36) % 6 | 0];\n    const g = v[(i / 6) % 6 | 0];\n    const b = v[i % 6];\n    colors.push({\n      css: toCss(r, g, b),\n      rgba: toRgba(r, g, b)\n    });\n  }\n\n  // Generate greys (232-255)\n  for (let i = 0; i < 24; i++) {\n    const c = 8 + i * 10;\n    colors.push({\n      css: toCss(c, c, c),\n      rgba: toRgba(c, c, c)\n    });\n  }\n\n  return colors;\n})();\n\n/**\n * Manages the source of truth for a terminal's colors.\n */\nexport class ColorManager implements IColorManager {\n  public colors: IColorSet;\n  private _ctx: CanvasRenderingContext2D;\n  private _litmusColor: CanvasGradient;\n  private _contrastCache: IColorContrastCache;\n\n  constructor(document: Document, public allowTransparency: boolean) {\n    const canvas = document.createElement('canvas');\n    canvas.width = 1;\n    canvas.height = 1;\n    const ctx = canvas.getContext('2d');\n    if (!ctx) {\n      throw new Error('Could not get rendering context');\n    }\n    this._ctx = ctx;\n    this._ctx.globalCompositeOperation = 'copy';\n    this._litmusColor = this._ctx.createLinearGradient(0, 0, 1, 1);\n    this._contrastCache = new ColorContrastCache();\n    this.colors = {\n      foreground: DEFAULT_FOREGROUND,\n      background: DEFAULT_BACKGROUND,\n      cursor: DEFAULT_CURSOR,\n      cursorAccent: DEFAULT_CURSOR_ACCENT,\n      selection: DEFAULT_SELECTION,\n      selectionOpaque: blend(DEFAULT_BACKGROUND, DEFAULT_SELECTION),\n      ansi: DEFAULT_ANSI_COLORS.slice(),\n      contrastCache: this._contrastCache\n    };\n  }\n\n  public onOptionsChange(key: string): void {\n    if (key === 'minimumContrastRatio') {\n      this._contrastCache.clear();\n    }\n  }\n\n  /**\n   * Sets the terminal's theme.\n   * @param theme The  theme to use. If a partial theme is provided then default\n   * colors will be used where colors are not defined.\n   */\n  public setTheme(theme: ITheme = {}): void {\n    this.colors.foreground = this._parseColor(theme.foreground, DEFAULT_FOREGROUND);\n    this.colors.background = this._parseColor(theme.background, DEFAULT_BACKGROUND);\n    this.colors.cursor = this._parseColor(theme.cursor, DEFAULT_CURSOR, true);\n    this.colors.cursorAccent = this._parseColor(theme.cursorAccent, DEFAULT_CURSOR_ACCENT, true);\n    this.colors.selection = this._parseColor(theme.selection, DEFAULT_SELECTION, true);\n    this.colors.selectionOpaque = blend(this.colors.background, this.colors.selection);\n    this.colors.ansi[0] = this._parseColor(theme.black, DEFAULT_ANSI_COLORS[0]);\n    this.colors.ansi[1] = this._parseColor(theme.red, DEFAULT_ANSI_COLORS[1]);\n    this.colors.ansi[2] = this._parseColor(theme.green, DEFAULT_ANSI_COLORS[2]);\n    this.colors.ansi[3] = this._parseColor(theme.yellow, DEFAULT_ANSI_COLORS[3]);\n    this.colors.ansi[4] = this._parseColor(theme.blue, DEFAULT_ANSI_COLORS[4]);\n    this.colors.ansi[5] = this._parseColor(theme.magenta, DEFAULT_ANSI_COLORS[5]);\n    this.colors.ansi[6] = this._parseColor(theme.cyan, DEFAULT_ANSI_COLORS[6]);\n    this.colors.ansi[7] = this._parseColor(theme.white, DEFAULT_ANSI_COLORS[7]);\n    this.colors.ansi[8] = this._parseColor(theme.brightBlack, DEFAULT_ANSI_COLORS[8]);\n    this.colors.ansi[9] = this._parseColor(theme.brightRed, DEFAULT_ANSI_COLORS[9]);\n    this.colors.ansi[10] = this._parseColor(theme.brightGreen, DEFAULT_ANSI_COLORS[10]);\n    this.colors.ansi[11] = this._parseColor(theme.brightYellow, DEFAULT_ANSI_COLORS[11]);\n    this.colors.ansi[12] = this._parseColor(theme.brightBlue, DEFAULT_ANSI_COLORS[12]);\n    this.colors.ansi[13] = this._parseColor(theme.brightMagenta, DEFAULT_ANSI_COLORS[13]);\n    this.colors.ansi[14] = this._parseColor(theme.brightCyan, DEFAULT_ANSI_COLORS[14]);\n    this.colors.ansi[15] = this._parseColor(theme.brightWhite, DEFAULT_ANSI_COLORS[15]);\n    // Clear our the cache\n    this._contrastCache.clear();\n  }\n\n  private _parseColor(\n    css: string | undefined,\n    fallback: IColor,\n    allowTransparency: boolean = this.allowTransparency\n  ): IColor {\n    if (css === undefined) {\n      return fallback;\n    }\n\n    // If parsing the value results in failure, then it must be ignored, and the attribute must\n    // retain its previous value.\n    // -- https://html.spec.whatwg.org/multipage/canvas.html#fill-and-stroke-styles\n    this._ctx.fillStyle = this._litmusColor;\n    this._ctx.fillStyle = css;\n    if (typeof this._ctx.fillStyle !== 'string') {\n      console.warn(`Color: ${css} is invalid using fallback ${fallback.css}`);\n      return fallback;\n    }\n\n    this._ctx.fillRect(0, 0, 1, 1);\n    const data = this._ctx.getImageData(0, 0, 1, 1).data;\n\n    // Check if the printed color was transparent\n    if (data[3] !== 0xFF) {\n      if (!allowTransparency) {\n        // Ideally we'd just ignore the alpha channel, but...\n        //\n        // Browsers may not give back exactly the same RGB values we put in, because most/all\n        // convert the color to a pre-multiplied representation. getImageData converts that back to\n        // a un-premultipled representation, but the precision loss may make the RGB channels unuable\n        // on their own.\n        //\n        // E.g. In Chrome #12345610 turns into #10305010, and in the extreme case, 0xFFFFFF00 turns\n        // into 0x00000000.\n        //\n        // \"Note: Due to the lossy nature of converting to and from premultiplied alpha color values,\n        // pixels that have just been set using putImageData() might be returned to an equivalent\n        // getImageData() as different values.\"\n        // -- https://html.spec.whatwg.org/multipage/canvas.html#pixel-manipulation\n        //\n        // So let's just use the fallback color in this case instead.\n        console.warn(\n          `Color: ${css} is using transparency, but allowTransparency is false. ` +\n          `Using fallback ${fallback.css}.`\n        );\n        return fallback;\n      }\n      let r: number;\n      let g: number;\n      let b: number;\n      let a: number;\n      let rgba: number;\n      if (css.length === 5) {\n        const num = parseInt(css.substr(1), 16);\n        r = ((num >> 12) & 0xF) * 16;\n        g = ((num >> 8) & 0xF) * 16;\n        b = ((num >> 4) & 0xF) * 16;\n        a = (num & 0xF) * 16;\n        rgba = toRgba(r, g, b, a);\n      } else {\n        rgba = parseInt(css.substr(1), 16);\n        r = (rgba >> 24) & 0xFF;\n        g = (rgba >> 16) & 0xFF;\n        b = (rgba >>  8) & 0xFF;\n        a = (rgba      ) & 0xFF;\n      }\n\n      return {\n        rgba,\n        css: toCss(r, g, b, a)\n      };\n    }\n\n    return {\n      css,\n      rgba: toRgba(data[0], data[1], data[2], data[3])\n    };\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport function throwIfFalsy<T>(value: T | undefined | null): T {\n  if (!value) {\n    throw new Error('value must not be falsy');\n  }\n  return value;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IBufferLine, ICellData, CharData } from 'common/Types';\nimport { ICharacterJoinerRegistry, ICharacterJoiner } from 'browser/renderer/Types';\nimport { AttributeData } from 'common/buffer/AttributeData';\nimport { WHITESPACE_CELL_CHAR, Content } from 'common/buffer/Constants';\nimport { CellData } from 'common/buffer/CellData';\nimport { IBufferService } from 'common/services/Services';\n\nexport class JoinedCellData extends AttributeData implements ICellData {\n  private _width: number;\n  // .content carries no meaning for joined CellData, simply nullify it\n  // thus we have to overload all other .content accessors\n  public content: number = 0;\n  public fg: number;\n  public bg: number;\n  public combinedData: string = '';\n\n  constructor(firstCell: ICellData, chars: string, width: number) {\n    super();\n    this.fg = firstCell.fg;\n    this.bg = firstCell.bg;\n    this.combinedData = chars;\n    this._width = width;\n  }\n\n  public isCombined(): number {\n    // always mark joined cell data as combined\n    return Content.IS_COMBINED_MASK;\n  }\n\n  public getWidth(): number {\n    return this._width;\n  }\n\n  public getChars(): string {\n    return this.combinedData;\n  }\n\n  public getCode(): number {\n    // code always gets the highest possible fake codepoint (read as -1)\n    // this is needed as code is used by caches as identifier\n    return 0x1FFFFF;\n  }\n\n  public setFromCharData(value: CharData): void {\n    throw new Error('not implemented');\n  }\n\n  public getAsCharData(): CharData {\n    return [this.fg, this.getChars(), this.getWidth(), this.getCode()];\n  }\n}\n\nexport class CharacterJoinerRegistry implements ICharacterJoinerRegistry {\n\n  private _characterJoiners: ICharacterJoiner[] = [];\n  private _nextCharacterJoinerId: number = 0;\n  private _workCell: CellData = new CellData();\n\n  constructor(private _bufferService: IBufferService) { }\n\n  public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {\n    const joiner: ICharacterJoiner = {\n      id: this._nextCharacterJoinerId++,\n      handler\n    };\n\n    this._characterJoiners.push(joiner);\n    return joiner.id;\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): boolean {\n    for (let i = 0; i < this._characterJoiners.length; i++) {\n      if (this._characterJoiners[i].id === joinerId) {\n        this._characterJoiners.splice(i, 1);\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  public getJoinedCharacters(row: number): [number, number][] {\n    if (this._characterJoiners.length === 0) {\n      return [];\n    }\n\n    const line = this._bufferService.buffer.lines.get(row);\n    if (!line || line.length === 0) {\n      return [];\n    }\n\n    const ranges: [number, number][] = [];\n    const lineStr = line.translateToString(true);\n\n    // Because some cells can be represented by multiple javascript characters,\n    // we track the cell and the string indexes separately. This allows us to\n    // translate the string ranges we get from the joiners back into cell ranges\n    // for use when rendering\n    let rangeStartColumn = 0;\n    let currentStringIndex = 0;\n    let rangeStartStringIndex = 0;\n    let rangeAttrFG = line.getFg(0);\n    let rangeAttrBG = line.getBg(0);\n\n    for (let x = 0; x < line.getTrimmedLength(); x++) {\n      line.loadCell(x, this._workCell);\n\n      if (this._workCell.getWidth() === 0) {\n        // If this character is of width 0, skip it.\n        continue;\n      }\n\n      // End of range\n      if (this._workCell.fg !== rangeAttrFG || this._workCell.bg !== rangeAttrBG) {\n        // If we ended up with a sequence of more than one character,\n        // look for ranges to join.\n        if (x - rangeStartColumn > 1) {\n          const joinedRanges = this._getJoinedRanges(\n            lineStr,\n            rangeStartStringIndex,\n            currentStringIndex,\n            line,\n            rangeStartColumn\n          );\n          for (let i = 0; i < joinedRanges.length; i++) {\n            ranges.push(joinedRanges[i]);\n          }\n        }\n\n        // Reset our markers for a new range.\n        rangeStartColumn = x;\n        rangeStartStringIndex = currentStringIndex;\n        rangeAttrFG = this._workCell.fg;\n        rangeAttrBG = this._workCell.bg;\n      }\n\n      currentStringIndex += this._workCell.getChars().length || WHITESPACE_CELL_CHAR.length;\n    }\n\n    // Process any trailing ranges.\n    if (this._bufferService.cols - rangeStartColumn > 1) {\n      const joinedRanges = this._getJoinedRanges(\n        lineStr,\n        rangeStartStringIndex,\n        currentStringIndex,\n        line,\n        rangeStartColumn\n      );\n      for (let i = 0; i < joinedRanges.length; i++) {\n        ranges.push(joinedRanges[i]);\n      }\n    }\n\n    return ranges;\n  }\n\n  /**\n   * Given a segment of a line of text, find all ranges of text that should be\n   * joined in a single rendering unit. Ranges are internally converted to\n   * column ranges, rather than string ranges.\n   * @param line String representation of the full line of text\n   * @param startIndex Start position of the range to search in the string (inclusive)\n   * @param endIndex End position of the range to search in the string (exclusive)\n   */\n  private _getJoinedRanges(line: string, startIndex: number, endIndex: number, lineData: IBufferLine, startCol: number): [number, number][] {\n    const text = line.substring(startIndex, endIndex);\n    // At this point we already know that there is at least one joiner so\n    // we can just pull its value and assign it directly rather than\n    // merging it into an empty array, which incurs unnecessary writes.\n    const joinedRanges: [number, number][] = this._characterJoiners[0].handler(text);\n    for (let i = 1; i < this._characterJoiners.length; i++) {\n      // We merge any overlapping ranges across the different joiners\n      const joinerRanges = this._characterJoiners[i].handler(text);\n      for (let j = 0; j < joinerRanges.length; j++) {\n        CharacterJoinerRegistry._mergeRanges(joinedRanges, joinerRanges[j]);\n      }\n    }\n    this._stringRangesToCellRanges(joinedRanges, lineData, startCol);\n    return joinedRanges;\n  }\n\n  /**\n   * Modifies the provided ranges in-place to adjust for variations between\n   * string length and cell width so that the range represents a cell range,\n   * rather than the string range the joiner provides.\n   * @param ranges String ranges containing start (inclusive) and end (exclusive) index\n   * @param line Cell data for the relevant line in the terminal\n   * @param startCol Offset within the line to start from\n   */\n  private _stringRangesToCellRanges(ranges: [number, number][], line: IBufferLine, startCol: number): void {\n    let currentRangeIndex = 0;\n    let currentRangeStarted = false;\n    let currentStringIndex = 0;\n    let currentRange = ranges[currentRangeIndex];\n\n    // If we got through all of the ranges, stop searching\n    if (!currentRange) {\n      return;\n    }\n\n    for (let x = startCol; x < this._bufferService.cols; x++) {\n      const width = line.getWidth(x);\n      const length = line.getString(x).length || WHITESPACE_CELL_CHAR.length;\n\n      // We skip zero-width characters when creating the string to join the text\n      // so we do the same here\n      if (width === 0) {\n        continue;\n      }\n\n      // Adjust the start of the range\n      if (!currentRangeStarted && currentRange[0] <= currentStringIndex) {\n        currentRange[0] = x;\n        currentRangeStarted = true;\n      }\n\n      // Adjust the end of the range\n      if (currentRange[1] <= currentStringIndex) {\n        currentRange[1] = x;\n\n        // We're finished with this range, so we move to the next one\n        currentRange = ranges[++currentRangeIndex];\n\n        // If there are no more ranges left, stop searching\n        if (!currentRange) {\n          break;\n        }\n\n        // Ranges can be on adjacent characters. Because the end index of the\n        // ranges are exclusive, this means that the index for the start of a\n        // range can be the same as the end index of the previous range. To\n        // account for the start of the next range, we check here just in case.\n        if (currentRange[0] <= currentStringIndex) {\n          currentRange[0] = x;\n          currentRangeStarted = true;\n        } else {\n          currentRangeStarted = false;\n        }\n      }\n\n      // Adjust the string index based on the character length to line up with\n      // the column adjustment\n      currentStringIndex += length;\n    }\n\n    // If there is still a range left at the end, it must extend all the way to\n    // the end of the line.\n    if (currentRange) {\n      currentRange[1] = this._bufferService.cols;\n    }\n  }\n\n  /**\n   * Merges the range defined by the provided start and end into the list of\n   * existing ranges. The merge is done in place on the existing range for\n   * performance and is also returned.\n   * @param ranges Existing range list\n   * @param newRange Tuple of two numbers representing the new range to merge in.\n   * @returns The ranges input with the new range merged in place\n   */\n  private static _mergeRanges(ranges: [number, number][], newRange: [number, number]): [number, number][] {\n    let inRange = false;\n    for (let i = 0; i < ranges.length; i++) {\n      const range = ranges[i];\n      if (!inRange) {\n        if (newRange[1] <= range[0]) {\n          // Case 1: New range is before the search range\n          ranges.splice(i, 0, newRange);\n          return ranges;\n        }\n\n        if (newRange[1] <= range[1]) {\n          // Case 2: New range is either wholly contained within the\n          // search range or overlaps with the front of it\n          range[0] = Math.min(newRange[0], range[0]);\n          return ranges;\n        }\n\n        if (newRange[0] < range[1]) {\n          // Case 3: New range either wholly contains the search range\n          // or overlaps with the end of it\n          range[0] = Math.min(newRange[0], range[0]);\n          inRange = true;\n        }\n\n        // Case 4: New range starts after the search range\n        continue;\n      } else {\n        if (newRange[1] <= range[0]) {\n          // Case 5: New range extends from previous range but doesn't\n          // reach the current one\n          ranges[i - 1][1] = newRange[1];\n          return ranges;\n        }\n\n        if (newRange[1] <= range[1]) {\n          // Case 6: New range extends from prvious range into the\n          // current range\n          ranges[i - 1][1] = Math.max(newRange[1], range[1]);\n          ranges.splice(i, 1);\n          return ranges;\n        }\n\n        // Case 7: New range extends from previous range past the\n        // end of the current range\n        ranges.splice(i, 1);\n        i--;\n      }\n    }\n\n    if (inRange) {\n      // Case 8: New range extends past the last existing range\n      ranges[ranges.length - 1][1] = newRange[1];\n    } else {\n      // Case 9: New range starts after the last existing range\n      ranges.push(newRange);\n    }\n\n    return ranges;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport function getCoordsRelativeToElement(event: {clientX: number, clientY: number}, element: HTMLElement): [number, number] {\n  const rect = element.getBoundingClientRect();\n  return [event.clientX - rect.left, event.clientY - rect.top];\n}\n\n/**\n * Gets coordinates within the terminal for a particular mouse event. The result\n * is returned as an array in the form [x, y] instead of an object as it's a\n * little faster and this function is used in some low level code.\n * @param event The mouse event.\n * @param element The terminal's container element.\n * @param colCount The number of columns in the terminal.\n * @param rowCount The number of rows n the terminal.\n * @param isSelection Whether the request is for the selection or not. This will\n * apply an offset to the x value such that the left half of the cell will\n * select that cell and the right half will select the next cell.\n */\nexport function getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, hasValidCharSize: boolean, actualCellWidth: number, actualCellHeight: number, isSelection?: boolean): [number, number] | undefined {\n  // Coordinates cannot be measured if there are no valid\n  if (!hasValidCharSize) {\n    return undefined;\n  }\n\n  const coords = getCoordsRelativeToElement(event, element);\n  if (!coords) {\n    return undefined;\n  }\n\n  coords[0] = Math.ceil((coords[0] + (isSelection ? actualCellWidth / 2 : 0)) / actualCellWidth);\n  coords[1] = Math.ceil(coords[1] / actualCellHeight);\n\n  // Ensure coordinates are within the terminal viewport. Note that selections\n  // need an addition point of precision to cover the end point (as characters\n  // cover half of one char and half of the next).\n  coords[0] = Math.min(Math.max(coords[0], 1), colCount + (isSelection ? 1 : 0));\n  coords[1] = Math.min(Math.max(coords[1], 1), rowCount);\n\n  return coords;\n}\n\n/**\n * Gets coordinates within the terminal for a particular mouse event, wrapping\n * them to the bounds of the terminal and adding 32 to both the x and y values\n * as expected by xterm.\n */\nexport function getRawByteCoords(coords: [number, number] | undefined): { x: number, y: number } | undefined {\n  if (!coords) {\n    return undefined;\n  }\n\n  // xterm sends raw bytes and starts at 32 (SP) for each.\n  return { x: coords[0] + 32, y: coords[1] + 32 };\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IDisposable } from 'common/Types';\n\n/**\n * Debounces calls to render terminal rows using animation frames.\n */\nexport class RenderDebouncer implements IDisposable {\n  private _rowStart: number | undefined;\n  private _rowEnd: number | undefined;\n  private _rowCount: number | undefined;\n  private _animationFrame: number | undefined;\n\n  constructor(\n    private _renderCallback: (start: number, end: number) => void\n  ) {\n  }\n\n  public dispose(): void {\n    if (this._animationFrame) {\n      window.cancelAnimationFrame(this._animationFrame);\n      this._animationFrame = undefined;\n    }\n  }\n\n  public refresh(rowStart: number, rowEnd: number, rowCount: number): void {\n    this._rowCount = rowCount;\n    // Get the min/max row start/end for the arg values\n    rowStart = rowStart !== undefined ? rowStart : 0;\n    rowEnd = rowEnd !== undefined ? rowEnd : this._rowCount - 1;\n    // Set the properties to the updated values\n    this._rowStart = this._rowStart !== undefined ? Math.min(this._rowStart, rowStart) : rowStart;\n    this._rowEnd = this._rowEnd !== undefined ? Math.max(this._rowEnd, rowEnd) : rowEnd;\n\n    if (this._animationFrame) {\n      return;\n    }\n\n    this._animationFrame = window.requestAnimationFrame(() => this._innerRefresh());\n  }\n\n  private _innerRefresh(): void {\n    // Make sure values are set\n    if (this._rowStart === undefined || this._rowEnd === undefined || this._rowCount === undefined) {\n      return;\n    }\n\n    // Clamp values\n    this._rowStart = Math.max(this._rowStart, 0);\n    this._rowEnd = Math.min(this._rowEnd, this._rowCount - 1);\n\n    // Run render callback\n    this._renderCallback(this._rowStart, this._rowEnd);\n\n    // Reset debouncer\n    this._rowStart = undefined;\n    this._rowEnd = undefined;\n    this._animationFrame = undefined;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Disposable } from 'common/Lifecycle';\n\nexport type ScreenDprListener = (newDevicePixelRatio?: number, oldDevicePixelRatio?: number) => void;\n\n/**\n * The screen device pixel ratio monitor allows listening for when the\n * window.devicePixelRatio value changes. This is done not with polling but with\n * the use of window.matchMedia to watch media queries. When the event fires,\n * the listener will be reattached using a different media query to ensure that\n * any further changes will register.\n *\n * The listener should fire on both window zoom changes and switching to a\n * monitor with a different DPI.\n */\nexport class ScreenDprMonitor extends Disposable {\n  private _currentDevicePixelRatio: number = window.devicePixelRatio;\n  private _outerListener: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | undefined;\n  private _listener: ScreenDprListener | undefined;\n  private _resolutionMediaMatchList: MediaQueryList | undefined;\n\n  public setListener(listener: ScreenDprListener): void {\n    if (this._listener) {\n      this.clearListener();\n    }\n    this._listener = listener;\n    this._outerListener = () => {\n      if (!this._listener) {\n        return;\n      }\n      this._listener(window.devicePixelRatio, this._currentDevicePixelRatio);\n      this._updateDpr();\n    };\n    this._updateDpr();\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this.clearListener();\n  }\n\n  private _updateDpr(): void {\n    if (!this._resolutionMediaMatchList || !this._outerListener) {\n      return;\n    }\n\n    // Clear listeners for old DPR\n    this._resolutionMediaMatchList.removeListener(this._outerListener);\n\n    // Add listeners for new DPR\n    this._currentDevicePixelRatio = window.devicePixelRatio;\n    this._resolutionMediaMatchList = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);\n    this._resolutionMediaMatchList.addListener(this._outerListener);\n  }\n\n  public clearListener(): void {\n    if (!this._resolutionMediaMatchList || !this._listener || !this._outerListener) {\n      return;\n    }\n    this._resolutionMediaMatchList.removeListener(this._outerListener);\n    this._resolutionMediaMatchList = undefined;\n    this._listener = undefined;\n    this._outerListener = undefined;\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\n/*\n * A simple utility for cloning values\n */\nexport function clone<T>(val: T, depth: number = 5): T {\n  if (typeof val !== 'object') {\n    return val;\n  }\n\n  // If we're cloning an array, use an array as the base, otherwise use an object\n  const clonedObject: any = Array.isArray(val) ? [] : {};\n\n  for (const key in val) {\n    // Recursively clone eack item unless we're at the maximum depth\n    clonedObject[key] = depth <= 1 ? val[key] : (val[key] ? clone(val[key], depth - 1) : val[key]);\n  }\n\n  return clonedObject as T;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier } from 'xterm';\nimport { ITerminal } from '../Types';\nimport { IBufferLine } from 'common/Types';\nimport { IBuffer } from 'common/buffer/Types';\nimport { Terminal as TerminalCore } from '../Terminal';\nimport * as Strings from '../browser/LocalizableStrings';\nimport { IEvent } from 'common/EventEmitter';\nimport { AddonManager } from './AddonManager';\nimport { IParams } from 'common/parser/Types';\n\nexport class Terminal implements ITerminalApi {\n  private _core: ITerminal;\n  private _addonManager: AddonManager;\n  private _parser: IParser;\n\n  constructor(options?: ITerminalOptions) {\n    this._core = new TerminalCore(options);\n    this._addonManager = new AddonManager();\n  }\n\n  public get onCursorMove(): IEvent<void> { return this._core.onCursorMove; }\n  public get onLineFeed(): IEvent<void> { return this._core.onLineFeed; }\n  public get onSelectionChange(): IEvent<void> { return this._core.onSelectionChange; }\n  public get onData(): IEvent<string> { return this._core.onData; }\n  public get onBinary(): IEvent<string> { return this._core.onBinary; }\n  public get onTitleChange(): IEvent<string> { return this._core.onTitleChange; }\n  public get onScroll(): IEvent<number> { return this._core.onScroll; }\n  public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; }\n  public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }\n\n  public get element(): HTMLElement | undefined { return this._core.element; }\n  public get parser(): IParser {\n    if (!this._parser) {\n      this._parser = new ParserApi(this._core);\n    }\n    return this._parser;\n  }\n  public get textarea(): HTMLTextAreaElement | undefined { return this._core.textarea; }\n  public get rows(): number { return this._core.rows; }\n  public get cols(): number { return this._core.cols; }\n  public get buffer(): IBufferApi { return new BufferApiView(this._core.buffer); }\n  public get markers(): ReadonlyArray<IMarker> { return this._core.markers; }\n  public blur(): void {\n    this._core.blur();\n  }\n  public focus(): void {\n    this._core.focus();\n  }\n  public resize(columns: number, rows: number): void {\n    this._verifyIntegers(columns, rows);\n    this._core.resize(columns, rows);\n  }\n  public open(parent: HTMLElement): void {\n    this._core.open(parent);\n  }\n  public attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void {\n    this._core.attachCustomKeyEventHandler(customKeyEventHandler);\n  }\n  public registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): number {\n    return this._core.registerLinkMatcher(regex, handler, options);\n  }\n  public deregisterLinkMatcher(matcherId: number): void {\n    this._core.deregisterLinkMatcher(matcherId);\n  }\n  public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {\n    return this._core.registerCharacterJoiner(handler);\n  }\n  public deregisterCharacterJoiner(joinerId: number): void {\n    this._core.deregisterCharacterJoiner(joinerId);\n  }\n  public addMarker(cursorYOffset: number): IMarker {\n    this._verifyIntegers(cursorYOffset);\n    return this._core.addMarker(cursorYOffset);\n  }\n  public hasSelection(): boolean {\n    return this._core.hasSelection();\n  }\n  public select(column: number, row: number, length: number): void {\n    this._verifyIntegers(column, row, length);\n    this._core.select(column, row, length);\n  }\n  public getSelection(): string {\n    return this._core.getSelection();\n  }\n  public getSelectionPosition(): ISelectionPosition | undefined {\n    return this._core.getSelectionPosition();\n  }\n  public clearSelection(): void {\n    this._core.clearSelection();\n  }\n  public selectAll(): void {\n    this._core.selectAll();\n  }\n  public selectLines(start: number, end: number): void {\n    this._verifyIntegers(start, end);\n    this._core.selectLines(start, end);\n  }\n  public dispose(): void {\n    this._addonManager.dispose();\n    this._core.dispose();\n  }\n  public scrollLines(amount: number): void {\n    this._verifyIntegers(amount);\n    this._core.scrollLines(amount);\n  }\n  public scrollPages(pageCount: number): void {\n    this._verifyIntegers(pageCount);\n    this._core.scrollPages(pageCount);\n  }\n  public scrollToTop(): void {\n    this._core.scrollToTop();\n  }\n  public scrollToBottom(): void {\n    this._core.scrollToBottom();\n  }\n  public scrollToLine(line: number): void {\n    this._verifyIntegers(line);\n    this._core.scrollToLine(line);\n  }\n  public clear(): void {\n    this._core.clear();\n  }\n  public write(data: string | Uint8Array, callback?: () => void): void {\n    this._core.write(data, callback);\n  }\n  public writeUtf8(data: Uint8Array, callback?: () => void): void {\n    this._core.write(data, callback);\n  }\n  public writeln(data: string | Uint8Array, callback?: () => void): void {\n    this._core.write(data);\n    this._core.write('\\r\\n', callback);\n  }\n  public paste(data: string): void {\n    this._core.paste(data);\n  }\n  public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'fontWeight' | 'fontWeightBold' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;\n  public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;\n  public getOption(key: 'colors'): string[];\n  public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;\n  public getOption(key: 'handler'): (data: string) => void;\n  public getOption(key: string): any;\n  public getOption(key: any): any {\n    return this._core.optionsService.getOption(key);\n  }\n  public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;\n  public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'): void;\n  public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void;\n  public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;\n  public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;\n  public setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell', value: boolean): void;\n  public setOption(key: 'colors', value: string[]): void;\n  public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;\n  public setOption(key: 'handler', value: (data: string) => void): void;\n  public setOption(key: 'theme', value: ITheme): void;\n  public setOption(key: 'cols' | 'rows', value: number): void;\n  public setOption(key: string, value: any): void;\n  public setOption(key: any, value: any): void {\n    this._core.optionsService.setOption(key, value);\n  }\n  public refresh(start: number, end: number): void {\n    this._verifyIntegers(start, end);\n    this._core.refresh(start, end);\n  }\n  public reset(): void {\n    this._core.reset();\n  }\n  public loadAddon(addon: ITerminalAddon): void {\n    return this._addonManager.loadAddon(this, addon);\n  }\n  public static get strings(): ILocalizableStrings {\n    return Strings;\n  }\n\n  private _verifyIntegers(...values: number[]): void {\n    values.forEach(value => {\n      if (value === Infinity || isNaN(value) || value % 1 !== 0) {\n        throw new Error('This API only accepts integers');\n      }\n    });\n  }\n}\n\nclass BufferApiView implements IBufferApi {\n  constructor(private _buffer: IBuffer) {}\n\n  public get cursorY(): number { return this._buffer.y; }\n  public get cursorX(): number { return this._buffer.x; }\n  public get viewportY(): number { return this._buffer.ydisp; }\n  public get baseY(): number { return this._buffer.ybase; }\n  public get length(): number { return this._buffer.lines.length; }\n  public getLine(y: number): IBufferLineApi | undefined {\n    const line = this._buffer.lines.get(y);\n    if (!line) {\n      return undefined;\n    }\n    return new BufferLineApiView(line);\n  }\n}\n\nclass BufferLineApiView implements IBufferLineApi {\n  constructor(private _line: IBufferLine) {}\n\n  public get isWrapped(): boolean { return this._line.isWrapped; }\n  public getCell(x: number): IBufferCellApi | undefined {\n    if (x < 0 || x >= this._line.length) {\n      return undefined;\n    }\n    return new BufferCellApiView(this._line, x);\n  }\n  public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string {\n    return this._line.translateToString(trimRight, startColumn, endColumn);\n  }\n}\n\nclass BufferCellApiView implements IBufferCellApi {\n  constructor(private _line: IBufferLine, private _x: number) {}\n  public get char(): string { return this._line.getString(this._x); }\n  public get width(): number { return this._line.getWidth(this._x); }\n}\n\nclass ParserApi implements IParser {\n  constructor(private _core: ITerminal) {}\n\n  public addCsiHandler(id: IFunctionIdentifier, callback: (params: (number | number[])[]) => boolean): IDisposable {\n    return this._core.addCsiHandler(id, (params: IParams) => callback(params.toArray()));\n  }\n  public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: (number | number[])[]) => boolean): IDisposable {\n    return this._core.addDcsHandler(id, (data: string, params: IParams) => callback(data, params.toArray()));\n  }\n  public addEscHandler(id: IFunctionIdentifier, handler: () => boolean): IDisposable {\n    return this._core.addEscHandler(id, handler);\n  }\n  public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    return this._core.addOscHandler(ident, callback);\n  }\n}\n","/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n *\n * Originally forked from (with the author's permission):\n *   Fabrice Bellard's javascript vt100 for jslinux:\n *   http://bellard.org/jslinux/\n *   Copyright (c) 2011 Fabrice Bellard\n *   The original design remains. The terminal itself\n *   has been extended to include xterm CSI codes, among\n *   other features.\n *\n * Terminal Emulation References:\n *   http://vt100.net/\n *   http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt\n *   http://invisible-island.net/xterm/ctlseqs/ctlseqs.html\n *   http://invisible-island.net/vttest/\n *   http://www.inwap.com/pdp10/ansicode.txt\n *   http://linux.die.net/man/4/console_codes\n *   http://linux.die.net/man/7/urxvt\n */\n\nimport { IInputHandlingTerminal, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, CustomKeyEventHandler } from './Types';\nimport { IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types';\nimport { CompositionHelper } from 'browser/input/CompositionHelper';\nimport { Viewport } from 'browser/Viewport';\nimport { rightClickHandler, moveTextAreaUnderMouseCursor, handlePasteEvent, copyHandler, paste } from 'browser/Clipboard';\nimport { C0 } from 'common/data/EscapeSequences';\nimport { InputHandler } from './InputHandler';\nimport { Renderer } from 'browser/renderer/Renderer';\nimport { Linkifier } from 'browser/Linkifier';\nimport { SelectionService } from 'browser/services/SelectionService';\nimport * as Browser from 'common/Platform';\nimport { addDisposableDomListener } from 'browser/Lifecycle';\nimport * as Strings from 'browser/LocalizableStrings';\nimport { SoundService } from 'browser/services/SoundService';\nimport { MouseZoneManager } from 'browser/MouseZoneManager';\nimport { AccessibilityManager } from './AccessibilityManager';\nimport { ITheme, IMarker, IDisposable, ISelectionPosition } from 'xterm';\nimport { DomRenderer } from 'browser/renderer/dom/DomRenderer';\nimport { IKeyboardEvent, KeyboardResultType, ICharset, IBufferLine, IAttributeData, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';\nimport { evaluateKeyboardEvent } from 'common/input/Keyboard';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';\nimport { handleWindowsModeLineFeed } from 'common/WindowsMode';\nimport { ColorManager } from 'browser/ColorManager';\nimport { RenderService } from 'browser/services/RenderService';\nimport { IOptionsService, IBufferService, ICoreMouseService, ICoreService, ILogService, IDirtyRowService, IInstantiationService } from 'common/services/Services';\nimport { OptionsService } from 'common/services/OptionsService';\nimport { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService } from 'browser/services/Services';\nimport { CharSizeService } from 'browser/services/CharSizeService';\nimport { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';\nimport { Disposable } from 'common/Lifecycle';\nimport { IBufferSet, IBuffer } from 'common/buffer/Types';\nimport { Attributes } from 'common/buffer/Constants';\nimport { MouseService } from 'browser/services/MouseService';\nimport { IParams, IFunctionIdentifier } from 'common/parser/Types';\nimport { CoreService } from 'common/services/CoreService';\nimport { LogService } from 'common/services/LogService';\nimport { ILinkifier, IMouseZoneManager, LinkMatcherHandler, ILinkMatcherOptions, IViewport } from 'browser/Types';\nimport { DirtyRowService } from 'common/services/DirtyRowService';\nimport { InstantiationService } from 'common/services/InstantiationService';\nimport { CoreMouseService } from 'common/services/CoreMouseService';\nimport { WriteBuffer } from 'common/input/WriteBuffer';\nimport { CoreBrowserService } from 'browser/services/CoreBrowserService';\n\n// Let it work inside Node.js for automated testing purposes.\nconst document = (typeof window !== 'undefined') ? window.document : null;\n\n\nexport class Terminal extends Disposable implements ITerminal, IDisposable, IInputHandlingTerminal {\n  public textarea: HTMLTextAreaElement;\n  public element: HTMLElement;\n  public screenElement: HTMLElement;\n\n  /**\n   * The HTMLElement that the terminal is created in, set by Terminal.open.\n   */\n  private _parent: HTMLElement | null;\n  private _document: Document;\n  private _viewportScrollArea: HTMLElement;\n  private _viewportElement: HTMLElement;\n  private _helperContainer: HTMLElement;\n  private _compositionView: HTMLElement;\n\n  private _visualBellTimer: number;\n\n  public browser: IBrowser = <any>Browser;\n\n  // TODO: We should remove options once components adopt optionsService\n  public get options(): ITerminalOptions { return this.optionsService.options; }\n\n  private _customKeyEventHandler: CustomKeyEventHandler;\n\n  // common services\n  private _bufferService: IBufferService;\n  private _coreService: ICoreService;\n  private _coreMouseService: ICoreMouseService;\n  private _dirtyRowService: IDirtyRowService;\n  private _instantiationService: IInstantiationService;\n  private _logService: ILogService;\n  public optionsService: IOptionsService;\n\n  // browser services\n  private _charSizeService: ICharSizeService;\n  private _mouseService: IMouseService;\n  private _renderService: IRenderService;\n  private _selectionService: ISelectionService;\n  private _soundService: ISoundService;\n\n  // modes\n  public applicationKeypad: boolean;\n  public originMode: boolean;\n  public insertMode: boolean;\n  public wraparoundMode: boolean; // defaults: xterm - true, vt100 - false\n  public bracketedPasteMode: boolean;\n\n  // charset\n  // The current charset\n  public charset: ICharset;\n  public gcharset: number;\n  public glevel: number;\n  public charsets: ICharset[];\n\n  // mouse properties\n  public mouseEvents: CoreMouseEventType = CoreMouseEventType.NONE;\n  public sendFocus: boolean;\n\n  // misc\n  public savedCols: number;\n\n  public curAttrData: IAttributeData;\n  private _eraseAttrData: IAttributeData;\n\n  public params: (string | number)[];\n  public currentParam: string | number;\n\n  // write buffer\n  private _writeBuffer: WriteBuffer;\n\n  // Store if user went browsing history in scrollback\n  private _userScrolling: boolean;\n\n  /**\n   * Records whether the keydown event has already been handled and triggered a data event, if so\n   * the keypress event should not trigger a data event but should still print to the textarea so\n   * screen readers will announce it.\n   */\n  private _keyDownHandled: boolean = false;\n\n  private _inputHandler: InputHandler;\n  public linkifier: ILinkifier;\n  public viewport: IViewport;\n  private _compositionHelper: ICompositionHelper;\n  private _mouseZoneManager: IMouseZoneManager;\n  private _accessibilityManager: AccessibilityManager;\n  private _colorManager: ColorManager;\n  private _theme: ITheme;\n  private _windowsMode: IDisposable | undefined;\n\n  // bufferline to clone/copy from for new blank lines\n  private _blankLine: IBufferLine = null;\n\n  public get cols(): number { return this._bufferService.cols; }\n  public get rows(): number { return this._bufferService.rows; }\n\n  private _onCursorMove = new EventEmitter<void>();\n  public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }\n  private _onData = new EventEmitter<string>();\n  public get onData(): IEvent<string> { return this._onData.event; }\n  private _onBinary = new EventEmitter<string>();\n  public get onBinary(): IEvent<string> { return this._onBinary.event; }\n  private _onKey = new EventEmitter<{ key: string, domEvent: KeyboardEvent }>();\n  public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._onKey.event; }\n  private _onLineFeed = new EventEmitter<void>();\n  public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }\n  private _onRender = new EventEmitter<{ start: number, end: number }>();\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }\n  private _onResize = new EventEmitter<{ cols: number, rows: number }>();\n  public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }\n  private _onScroll = new EventEmitter<number>();\n  public get onScroll(): IEvent<number> { return this._onScroll.event; }\n  private _onSelectionChange = new EventEmitter<void>();\n  public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }\n  private _onTitleChange = new EventEmitter<string>();\n  public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; }\n\n  private _onFocus = new EventEmitter<void>();\n  public get onFocus(): IEvent<void> { return this._onFocus.event; }\n  private _onBlur = new EventEmitter<void>();\n  public get onBlur(): IEvent<void> { return this._onBlur.event; }\n  public onA11yCharEmitter = new EventEmitter<string>();\n  public get onA11yChar(): IEvent<string> { return this.onA11yCharEmitter.event; }\n  public onA11yTabEmitter = new EventEmitter<number>();\n  public get onA11yTab(): IEvent<number> { return this.onA11yTabEmitter.event; }\n\n  /**\n   * Creates a new `Terminal` object.\n   *\n   * @param options An object containing a set of options, the available options are:\n   *   - `cursorBlink` (boolean): Whether the terminal cursor blinks\n   *   - `cols` (number): The number of columns of the terminal (horizontal size)\n   *   - `rows` (number): The number of rows of the terminal (vertical size)\n   *\n   * @public\n   * @class Xterm Xterm\n   * @alias module:xterm/src/xterm\n   */\n  constructor(\n    options: ITerminalOptions = {}\n  ) {\n    super();\n\n    // Setup and initialize common services\n    this._instantiationService = new InstantiationService();\n    this.optionsService = new OptionsService(options);\n    this._instantiationService.setService(IOptionsService, this.optionsService);\n    this._bufferService = this._instantiationService.createInstance(BufferService);\n    this._instantiationService.setService(IBufferService, this._bufferService);\n    this._logService = this._instantiationService.createInstance(LogService);\n    this._instantiationService.setService(ILogService, this._logService);\n    this._coreService = this._instantiationService.createInstance(CoreService, () => this.scrollToBottom());\n    this._instantiationService.setService(ICoreService, this._coreService);\n    this._coreService.onData(e => this._onData.fire(e));\n    this._coreService.onBinary(e => this._onBinary.fire(e));\n    this._coreMouseService = this._instantiationService.createInstance(CoreMouseService);\n    this._instantiationService.setService(ICoreMouseService, this._coreMouseService);\n    this._dirtyRowService = this._instantiationService.createInstance(DirtyRowService);\n    this._instantiationService.setService(IDirtyRowService, this._dirtyRowService);\n\n    this._setupOptionsListeners();\n    this._setup();\n\n    this._writeBuffer = new WriteBuffer(data => this._inputHandler.parse(data));\n  }\n\n  public dispose(): void {\n    if (this._isDisposed) {\n      return;\n    }\n    super.dispose();\n    this._windowsMode?.dispose();\n    this._windowsMode = undefined;\n    this._renderService?.dispose();\n    this._customKeyEventHandler = null;\n    this.write = () => {};\n    this.element?.parentNode?.removeChild(this.element);\n  }\n\n  private _setup(): void {\n    this._parent = document ? document.body : null;\n\n    this._customKeyEventHandler = null;\n\n    // modes\n    this.applicationKeypad = false;\n    this.originMode = false;\n    this.insertMode = false;\n    this.wraparoundMode = true; // defaults: xterm - true, vt100 - false\n    this.bracketedPasteMode = false;\n\n    // charset\n    this.charset = null;\n    this.gcharset = null;\n    this.glevel = 0;\n    // TODO: Can this be just []?\n    this.charsets = [null];\n\n    this.curAttrData = DEFAULT_ATTR_DATA.clone();\n    this._eraseAttrData = DEFAULT_ATTR_DATA.clone();\n\n    this.params = [];\n    this.currentParam = 0;\n\n    this._userScrolling = false;\n\n    // Register input handler and refire/handle events\n    this._inputHandler = new InputHandler(this, this._bufferService, this._coreService, this._dirtyRowService, this._logService, this.optionsService, this._coreMouseService);\n    this._inputHandler.onCursorMove(() => this._onCursorMove.fire());\n    this._inputHandler.onLineFeed(() => this._onLineFeed.fire());\n    this.register(this._inputHandler);\n\n    this.linkifier = this.linkifier || new Linkifier(this._bufferService, this._logService);\n\n    if (this.options.windowsMode) {\n      this._enableWindowsMode();\n    }\n  }\n\n  private _enableWindowsMode(): void {\n    if (!this._windowsMode) {\n      this._windowsMode = this.onLineFeed(handleWindowsModeLineFeed.bind(null, this._bufferService));\n    }\n  }\n\n  /**\n   * Convenience property to active buffer.\n   */\n  public get buffer(): IBuffer {\n    return this.buffers.active;\n  }\n\n  public get buffers(): IBufferSet {\n    return this._bufferService.buffers;\n  }\n\n  /**\n   * back_color_erase feature for xterm.\n   */\n  public eraseAttrData(): IAttributeData {\n    this._eraseAttrData.bg &= ~(Attributes.CM_MASK | 0xFFFFFF);\n    this._eraseAttrData.bg |= this.curAttrData.bg & ~0xFC000000;\n    return this._eraseAttrData;\n  }\n\n  /**\n   * Focus the terminal. Delegates focus handling to the terminal's DOM element.\n   */\n  public focus(): void {\n    if (this.textarea) {\n      this.textarea.focus({ preventScroll: true });\n    }\n  }\n\n  private _setupOptionsListeners(): void {\n    // TODO: These listeners should be owned by individual components\n    this.optionsService.onOptionChange(key => {\n      switch (key) {\n        case 'fontFamily':\n        case 'fontSize':\n          // When the font changes the size of the cells may change which requires a renderer clear\n          this._renderService?.clear();\n          this._charSizeService?.measure();\n          break;\n        case 'drawBoldTextInBrightColors':\n        case 'letterSpacing':\n        case 'lineHeight':\n        case 'fontWeight':\n        case 'fontWeightBold':\n        case 'minimumContrastRatio':\n          // When the font changes the size of the cells may change which requires a renderer clear\n          if (this._renderService) {\n            this._renderService.clear();\n            this._renderService.onResize(this.cols, this.rows);\n            this.refresh(0, this.rows - 1);\n          }\n          break;\n        case 'rendererType':\n          if (this._renderService) {\n            this._renderService.setRenderer(this._createRenderer());\n            this._renderService.onResize(this.cols, this.rows);\n          }\n          break;\n        case 'scrollback':\n          this.buffers.resize(this.cols, this.rows);\n          this.viewport?.syncScrollArea();\n          break;\n        case 'screenReaderMode':\n          if (this.optionsService.options.screenReaderMode) {\n            if (!this._accessibilityManager && this._renderService) {\n              this._accessibilityManager = new AccessibilityManager(this, this._renderService);\n            }\n          } else {\n            this._accessibilityManager?.dispose();\n            this._accessibilityManager = null;\n          }\n          break;\n        case 'tabStopWidth': this.buffers.setupTabStops(); break;\n        case 'theme':\n          this._setTheme(this.optionsService.options.theme);\n          break;\n        case 'windowsMode':\n          if (this.optionsService.options.windowsMode) {\n            this._enableWindowsMode();\n          } else {\n            this._windowsMode?.dispose();\n            this._windowsMode = undefined;\n          }\n          break;\n      }\n    });\n  }\n\n  /**\n   * Binds the desired focus behavior on a given terminal object.\n   */\n  private _onTextAreaFocus(ev: KeyboardEvent): void {\n    if (this.sendFocus) {\n      this._coreService.triggerDataEvent(C0.ESC + '[I');\n    }\n    this.updateCursorStyle(ev);\n    this.element.classList.add('focus');\n    this.showCursor();\n    this._onFocus.fire();\n  }\n\n  /**\n   * Blur the terminal, calling the blur function on the terminal's underlying\n   * textarea.\n   */\n  public blur(): void {\n    return this.textarea.blur();\n  }\n\n  /**\n   * Binds the desired blur behavior on a given terminal object.\n   */\n  private _onTextAreaBlur(): void {\n    // Text can safely be removed on blur. Doing it earlier could interfere with\n    // screen readers reading it out.\n    this.textarea.value = '';\n    this.refresh(this.buffer.y, this.buffer.y);\n    if (this.sendFocus) {\n      this._coreService.triggerDataEvent(C0.ESC + '[O');\n    }\n    this.element.classList.remove('focus');\n    this._onBlur.fire();\n  }\n\n  /**\n   * Initialize default behavior\n   */\n  private _initGlobal(): void {\n    this._bindKeys();\n\n    // Bind clipboard functionality\n    this.register(addDisposableDomListener(this.element, 'copy', (event: ClipboardEvent) => {\n      // If mouse events are active it means the selection manager is disabled and\n      // copy should be handled by the host program.\n      if (!this.hasSelection()) {\n        return;\n      }\n      copyHandler(event, this._selectionService);\n    }));\n    const pasteHandlerWrapper = (event: ClipboardEvent) => handlePasteEvent(event, this.textarea, this.bracketedPasteMode, this._coreService);\n    this.register(addDisposableDomListener(this.textarea, 'paste', pasteHandlerWrapper));\n    this.register(addDisposableDomListener(this.element, 'paste', pasteHandlerWrapper));\n\n    // Handle right click context menus\n    if (Browser.isFirefox) {\n      // Firefox doesn't appear to fire the contextmenu event on right click\n      this.register(addDisposableDomListener(this.element, 'mousedown', (event: MouseEvent) => {\n        if (event.button === 2) {\n          rightClickHandler(event, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord);\n        }\n      }));\n    } else {\n      this.register(addDisposableDomListener(this.element, 'contextmenu', (event: MouseEvent) => {\n        rightClickHandler(event, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord);\n      }));\n    }\n\n    // Move the textarea under the cursor when middle clicking on Linux to ensure\n    // middle click to paste selection works. This only appears to work in Chrome\n    // at the time is writing.\n    if (Browser.isLinux) {\n      // Use auxclick event over mousedown the latter doesn't seem to work. Note\n      // that the regular click event doesn't fire for the middle mouse button.\n      this.register(addDisposableDomListener(this.element, 'auxclick', (event: MouseEvent) => {\n        if (event.button === 1) {\n          moveTextAreaUnderMouseCursor(event, this.textarea, this.screenElement);\n        }\n      }));\n    }\n  }\n\n  /**\n   * Apply key handling to the terminal\n   */\n  private _bindKeys(): void {\n    this.register(addDisposableDomListener(this.textarea, 'keyup', (ev: KeyboardEvent) => this._keyUp(ev), true));\n    this.register(addDisposableDomListener(this.textarea, 'keydown', (ev: KeyboardEvent) => this._keyDown(ev), true));\n    this.register(addDisposableDomListener(this.textarea, 'keypress', (ev: KeyboardEvent) => this._keyPress(ev), true));\n    this.register(addDisposableDomListener(this.textarea, 'compositionstart', () => this._compositionHelper.compositionstart()));\n    this.register(addDisposableDomListener(this.textarea, 'compositionupdate', (e: CompositionEvent) => this._compositionHelper.compositionupdate(e)));\n    this.register(addDisposableDomListener(this.textarea, 'compositionend', () => this._compositionHelper.compositionend()));\n    this.register(this.onRender(() => this._compositionHelper.updateCompositionElements()));\n    this.register(this.onRender(e => this._queueLinkification(e.start, e.end)));\n  }\n\n  /**\n   * Opens the terminal within an element.\n   *\n   * @param parent The element to create the terminal within.\n   */\n  public open(parent: HTMLElement): void {\n    this._parent = parent || this._parent;\n\n    if (!this._parent) {\n      throw new Error('Terminal requires a parent element.');\n    }\n\n    if (!document.body.contains(parent)) {\n      this._logService.warn('Terminal.open was called on an element that was not attached to the DOM');\n    }\n\n    this._document = this._parent.ownerDocument;\n\n    // Create main element container\n    this.element = this._document.createElement('div');\n    this.element.dir = 'ltr';   // xterm.css assumes LTR\n    this.element.classList.add('terminal');\n    this.element.classList.add('xterm');\n    this.element.setAttribute('tabindex', '0');\n    this._parent.appendChild(this.element);\n\n    // Performance: Use a document fragment to build the terminal\n    // viewport and helper elements detached from the DOM\n    const fragment = document.createDocumentFragment();\n    this._viewportElement = document.createElement('div');\n    this._viewportElement.classList.add('xterm-viewport');\n    fragment.appendChild(this._viewportElement);\n    this._viewportScrollArea = document.createElement('div');\n    this._viewportScrollArea.classList.add('xterm-scroll-area');\n    this._viewportElement.appendChild(this._viewportScrollArea);\n\n    this.screenElement = document.createElement('div');\n    this.screenElement.classList.add('xterm-screen');\n    // Create the container that will hold helpers like the textarea for\n    // capturing DOM Events. Then produce the helpers.\n    this._helperContainer = document.createElement('div');\n    this._helperContainer.classList.add('xterm-helpers');\n    this.screenElement.appendChild(this._helperContainer);\n    fragment.appendChild(this.screenElement);\n\n    this.textarea = document.createElement('textarea');\n    this.textarea.classList.add('xterm-helper-textarea');\n    this.textarea.setAttribute('aria-label', Strings.promptLabel);\n    this.textarea.setAttribute('aria-multiline', 'false');\n    this.textarea.setAttribute('autocorrect', 'off');\n    this.textarea.setAttribute('autocapitalize', 'off');\n    this.textarea.setAttribute('spellcheck', 'false');\n    this.textarea.tabIndex = 0;\n    this.register(addDisposableDomListener(this.textarea, 'focus', (ev: KeyboardEvent) => this._onTextAreaFocus(ev)));\n    this.register(addDisposableDomListener(this.textarea, 'blur', () => this._onTextAreaBlur()));\n    this._helperContainer.appendChild(this.textarea);\n\n    const coreBrowserService = this._instantiationService.createInstance(CoreBrowserService, this.textarea);\n    this._instantiationService.setService(ICoreBrowserService, coreBrowserService);\n\n    this._charSizeService = this._instantiationService.createInstance(CharSizeService, this._document, this._helperContainer);\n    this._instantiationService.setService(ICharSizeService, this._charSizeService);\n\n    this._compositionView = document.createElement('div');\n    this._compositionView.classList.add('composition-view');\n    this._compositionHelper = this._instantiationService.createInstance(CompositionHelper, this.textarea, this._compositionView);\n    this._helperContainer.appendChild(this._compositionView);\n\n    // Performance: Add viewport and helper elements from the fragment\n    this.element.appendChild(fragment);\n\n    this._theme = this.options.theme || this._theme;\n    this.options.theme = undefined;\n    this._colorManager = new ColorManager(document, this.options.allowTransparency);\n    this.optionsService.onOptionChange(e => this._colorManager.onOptionsChange(e));\n    this._colorManager.setTheme(this._theme);\n\n    const renderer = this._createRenderer();\n    this._renderService = this._instantiationService.createInstance(RenderService, renderer, this.rows, this.screenElement);\n    this._instantiationService.setService(IRenderService, this._renderService);\n    this._renderService.onRender(e => this._onRender.fire(e));\n    this.onResize(e => this._renderService.resize(e.cols, e.rows));\n\n    this._soundService = this._instantiationService.createInstance(SoundService);\n    this._instantiationService.setService(ISoundService, this._soundService);\n    this._mouseService = this._instantiationService.createInstance(MouseService);\n    this._instantiationService.setService(IMouseService, this._mouseService);\n\n    this.viewport = this._instantiationService.createInstance(Viewport,\n      (amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent),\n      this._viewportElement,\n      this._viewportScrollArea\n    );\n    this.viewport.onThemeChange(this._colorManager.colors);\n    this.register(this.viewport);\n\n    this.register(this.onCursorMove(() => this._renderService.onCursorMove()));\n    this.register(this.onResize(() => this._renderService.onResize(this.cols, this.rows)));\n    this.register(this.onBlur(() => this._renderService.onBlur()));\n    this.register(this.onFocus(() => this._renderService.onFocus()));\n    this.register(this._renderService.onDimensionsChange(() => this.viewport.syncScrollArea()));\n\n    this._selectionService = this._instantiationService.createInstance(SelectionService,\n      (amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent),\n      this.element,\n      this.screenElement);\n    this._instantiationService.setService(ISelectionService, this._selectionService);\n    this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));\n    this.register(this._selectionService.onRedrawRequest(e => this._renderService.onSelectionChanged(e.start, e.end, e.columnSelectMode)));\n    this.register(this._selectionService.onLinuxMouseSelection(text => {\n      // If there's a new selection, put it into the textarea, focus and select it\n      // in order to register it as a selection on the OS. This event is fired\n      // only on Linux to enable middle click to paste selection.\n      this.textarea.value = text;\n      this.textarea.focus();\n      this.textarea.select();\n    }));\n    this.register(this.onScroll(() => {\n      this.viewport.syncScrollArea();\n      this._selectionService.refresh();\n    }));\n    this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this._selectionService.refresh()));\n\n    this._mouseZoneManager = this._instantiationService.createInstance(MouseZoneManager, this.element, this.screenElement);\n    this.register(this._mouseZoneManager);\n    this.register(this.onScroll(() => this._mouseZoneManager.clearAll()));\n    this.linkifier.attachToDom(this.element, this._mouseZoneManager);\n\n    // This event listener must be registered aftre MouseZoneManager is created\n    this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService.onMouseDown(e)));\n\n    // apply mouse event classes set by escape codes before terminal was attached\n    if (this.mouseEvents) {\n      this._selectionService.disable();\n      this.element.classList.add('enable-mouse-events');\n    } else {\n      this._selectionService.enable();\n    }\n\n    if (this.options.screenReaderMode) {\n      // Note that this must be done *after* the renderer is created in order to\n      // ensure the correct order of the dprchange event\n      this._accessibilityManager = new AccessibilityManager(this, this._renderService);\n    }\n\n    // Measure the character size\n    this._charSizeService.measure();\n\n    // Setup loop that draws to screen\n    this.refresh(0, this.rows - 1);\n\n    // Initialize global actions that need to be taken on the document.\n    this._initGlobal();\n\n    // Listen for mouse events and translate\n    // them into terminal mouse protocols.\n    this.bindMouse();\n  }\n\n  private _createRenderer(): IRenderer {\n    switch (this.options.rendererType) {\n      case 'canvas': return this._instantiationService.createInstance(Renderer, this._colorManager.colors, this.screenElement, this.linkifier);\n      case 'dom': return this._instantiationService.createInstance(DomRenderer, this._colorManager.colors, this.element, this.screenElement, this._viewportElement, this.linkifier);\n      default: throw new Error(`Unrecognized rendererType \"${this.options.rendererType}\"`);\n    }\n  }\n\n  /**\n   * Sets the theme on the renderer. The renderer must have been initialized.\n   * @param theme The theme to set.\n   */\n  private _setTheme(theme: ITheme): void {\n    this._theme = theme;\n    this._colorManager?.setTheme(theme);\n    this._renderService?.setColors(this._colorManager.colors);\n    this.viewport?.onThemeChange(this._colorManager.colors);\n  }\n\n  /**\n   * Bind certain mouse events to the terminal.\n   * By default only 3 button + wheel up/down is ativated. For higher buttons\n   * no mouse report will be created. Typically the standard actions will be active.\n   *\n   * There are several reasons not to enable support for higher buttons/wheel:\n   * - Button 4 and 5 are typically used for history back and forward navigation,\n   *   there is no straight forward way to supress/intercept those standard actions.\n   * - Support for higher buttons does not work in some platform/browser combinations.\n   * - Left/right wheel was not tested.\n   * - Emulators vary in mouse button support, typically only 3 buttons and\n   *   wheel up/down work reliable.\n   *\n   * TODO: Move mouse event code into its own file.\n   */\n  public bindMouse(): void {\n    const self = this;\n    const el = this.element;\n\n    // send event to CoreMouseService\n    function sendEvent(ev: MouseEvent | WheelEvent): boolean {\n      let pos;\n\n      // get mouse coordinates\n      pos = self._mouseService.getRawByteCoords(ev, self.screenElement, self.cols, self.rows);\n      if (!pos) {\n        return false;\n      }\n\n      let but: CoreMouseButton;\n      let action: CoreMouseAction;\n      switch ((<any>ev).overrideType || ev.type) {\n        case 'mousemove':\n          action = CoreMouseAction.MOVE;\n          if (ev.buttons === undefined) {\n            // buttons is not supported on macOS, try to get a value from button instead\n            but = CoreMouseButton.NONE;\n            if (ev.button !== undefined) {\n              but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;\n            }\n          } else {\n            // according to MDN buttons only reports up to button 5 (AUX2)\n            but = ev.buttons & 1 ? CoreMouseButton.LEFT :\n                  ev.buttons & 4 ? CoreMouseButton.MIDDLE :\n                  ev.buttons & 2 ? CoreMouseButton.RIGHT :\n                  CoreMouseButton.NONE; // fallback to NONE\n          }\n          break;\n        case 'mouseup':\n          action = CoreMouseAction.UP;\n          but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;\n          break;\n        case 'mousedown':\n          action = CoreMouseAction.DOWN;\n          but = ev.button < 3 ? ev.button : CoreMouseButton.NONE;\n          break;\n        case 'wheel':\n          // only UP/DOWN wheel events are respected\n          if ((ev as WheelEvent).deltaY !== 0) {\n            action = (ev as WheelEvent).deltaY < 0 ? CoreMouseAction.UP : CoreMouseAction.DOWN;\n          }\n          but = CoreMouseButton.WHEEL;\n          break;\n        default:\n          // dont handle other event types by accident\n          return false;\n      }\n\n      // exit if we cannot determine valid button/action values\n      // do nothing for higher buttons than wheel\n      if (action === undefined || but === undefined || but > CoreMouseButton.WHEEL) {\n        return false;\n      }\n\n      return self._coreMouseService.triggerMouseEvent({\n        col: pos.x - 33, // FIXME: why -33 here?\n        row: pos.y - 33,\n        button: but,\n        action,\n        ctrl: ev.ctrlKey,\n        alt: ev.altKey,\n        shift: ev.shiftKey\n      });\n    }\n\n    /**\n     * Event listener state handling.\n     * We listen to the onProtocolChange event of CoreMouseService and put\n     * requested listeners in `requestedEvents`. With this the listeners\n     * have all bits to do the event listener juggling.\n     * Note: 'mousedown' currently is \"always on\" and not managed\n     * by onProtocolChange.\n     */\n    const requestedEvents: {[key: string]: ((ev: Event) => void) | null} = {\n      mouseup: null,\n      wheel: null,\n      mousedrag: null,\n      mousemove: null\n    };\n    const eventListeners: {[key: string]: (ev: Event) => void} = {\n      mouseup: (ev: MouseEvent) => {\n        sendEvent(ev);\n        if (!ev.buttons) {\n          // if no other button is held remove global handlers\n          this._document.removeEventListener('mouseup', requestedEvents.mouseup);\n          if (requestedEvents.mousedrag) {\n            this._document.removeEventListener('mousemove', requestedEvents.mousedrag);\n          }\n        }\n        return this.cancel(ev);\n      },\n      wheel: (ev: WheelEvent) => {\n        sendEvent(ev);\n        ev.preventDefault();\n        return this.cancel(ev);\n      },\n      mousedrag: (ev: MouseEvent) => {\n        // deal only with move while a button is held\n        if (ev.buttons) {\n          sendEvent(ev);\n        }\n      },\n      mousemove: (ev: MouseEvent) => {\n        // deal only with move without any button\n        if (!ev.buttons) {\n          sendEvent(ev);\n        }\n      }\n    };\n    this._coreMouseService.onProtocolChange(events => {\n      // apply global changes on events\n      this.mouseEvents = events;\n      if (events) {\n        if (this.optionsService.options.logLevel === 'debug') {\n          this._logService.debug('Binding to mouse events:', this._coreMouseService.explainEvents(events));\n        }\n        this.element.classList.add('enable-mouse-events');\n        this._selectionService.disable();\n      } else {\n        this._logService.debug('Unbinding from mouse events.');\n        this.element.classList.remove('enable-mouse-events');\n        this._selectionService.enable();\n      }\n\n      // add/remove handlers from requestedEvents\n\n      if (!(events & CoreMouseEventType.MOVE)) {\n        el.removeEventListener('mousemove', requestedEvents.mousemove);\n        requestedEvents.mousemove = null;\n      } else if (!requestedEvents.mousemove) {\n        el.addEventListener('mousemove', eventListeners.mousemove);\n        requestedEvents.mousemove = eventListeners.mousemove;\n      }\n\n      if (!(events & CoreMouseEventType.WHEEL)) {\n        el.removeEventListener('wheel', requestedEvents.wheel);\n        requestedEvents.wheel = null;\n      } else if (!requestedEvents.wheel) {\n        el.addEventListener('wheel', eventListeners.wheel);\n        requestedEvents.wheel = eventListeners.wheel;\n      }\n\n      if (!(events & CoreMouseEventType.UP)) {\n        this._document.removeEventListener('mouseup', requestedEvents.mouseup);\n        requestedEvents.mouseup = null;\n      } else if (!requestedEvents.mouseup) {\n        requestedEvents.mouseup = eventListeners.mouseup;\n      }\n\n      if (!(events & CoreMouseEventType.DRAG)) {\n        this._document.removeEventListener('mousemove', requestedEvents.mousedrag);\n        requestedEvents.mousedrag = null;\n      } else if (!requestedEvents.mousedrag) {\n        requestedEvents.mousedrag = eventListeners.mousedrag;\n      }\n    });\n    // force initial onProtocolChange so we dont miss early mouse requests\n    this._coreMouseService.activeProtocol = this._coreMouseService.activeProtocol;\n\n    /**\n     * \"Always on\" event listeners.\n     */\n    this.register(addDisposableDomListener(el, 'mousedown', (ev: MouseEvent) => {\n      ev.preventDefault();\n      this.focus();\n\n      // Don't send the mouse button to the pty if mouse events are disabled or\n      // if the selection manager is having selection forced (ie. a modifier is\n      // held).\n      if (!this.mouseEvents || this._selectionService.shouldForceSelection(ev)) {\n        return;\n      }\n\n      sendEvent(ev);\n\n      // Register additional global handlers which should keep reporting outside\n      // of the terminal element.\n      // Note: Other emulators also do this for 'mousedown' while a button\n      // is held, we currently limit 'mousedown' to the terminal only.\n      if (requestedEvents.mouseup) {\n        this._document.addEventListener('mouseup', requestedEvents.mouseup);\n      }\n      if (requestedEvents.mousedrag) {\n        this._document.addEventListener('mousemove', requestedEvents.mousedrag);\n      }\n\n      return this.cancel(ev);\n    }));\n\n    this.register(addDisposableDomListener(el, 'wheel', (ev: WheelEvent) => {\n      if (!requestedEvents.wheel) {\n        // Convert wheel events into up/down events when the buffer does not have scrollback, this\n        // enables scrolling in apps hosted in the alt buffer such as vim or tmux.\n        if (!this.buffer.hasScrollback) {\n          const amount = this.viewport.getLinesScrolled(ev);\n\n          // Do nothing if there's no vertical scroll\n          if (amount === 0) {\n            return;\n          }\n\n          // Construct and send sequences\n          const sequence = C0.ESC + (this._coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + ( ev.deltaY < 0 ? 'A' : 'B');\n          let data = '';\n          for (let i = 0; i < Math.abs(amount); i++) {\n            data += sequence;\n          }\n          this._coreService.triggerDataEvent(data, true);\n        }\n        return;\n      }\n    }));\n\n    // allow wheel scrolling in\n    // the shell for example\n    this.register(addDisposableDomListener(el, 'wheel', (ev: WheelEvent) => {\n      if (requestedEvents.wheel) return;\n      if (!this.viewport.onWheel(ev)) {\n        return this.cancel(ev);\n      }\n    }));\n\n    this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => {\n      if (this.mouseEvents) return;\n      this.viewport.onTouchStart(ev);\n      return this.cancel(ev);\n    }));\n\n    this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => {\n      if (this.mouseEvents) return;\n      if (!this.viewport.onTouchMove(ev)) {\n        return this.cancel(ev);\n      }\n    }));\n  }\n\n\n  /**\n   * Tells the renderer to refresh terminal content between two rows (inclusive) at the next\n   * opportunity.\n   * @param start The row to start from (between 0 and this.rows - 1).\n   * @param end The row to end at (between start and this.rows - 1).\n   */\n  public refresh(start: number, end: number): void {\n    this._renderService?.refreshRows(start, end);\n  }\n\n  /**\n   * Queues linkification for the specified rows.\n   * @param start The row to start from (between 0 and this.rows - 1).\n   * @param end The row to end at (between start and this.rows - 1).\n   */\n  private _queueLinkification(start: number, end: number): void {\n    this.linkifier?.linkifyRows(start, end);\n  }\n\n  /**\n   * Change the cursor style for different selection modes\n   */\n  public updateCursorStyle(ev: KeyboardEvent): void {\n    if (this._selectionService && this._selectionService.shouldColumnSelect(ev)) {\n      this.element.classList.add('column-select');\n    } else {\n      this.element.classList.remove('column-select');\n    }\n  }\n\n  /**\n   * Display the cursor element\n   */\n  public showCursor(): void {\n    if (!this._coreService.isCursorInitialized) {\n      this._coreService.isCursorInitialized = true;\n      this.refresh(this.buffer.y, this.buffer.y);\n    }\n  }\n\n  /**\n   * Scroll the terminal down 1 row, creating a blank line.\n   * @param isWrapped Whether the new line is wrapped from the previous line.\n   */\n  public scroll(isWrapped: boolean = false): void {\n    let newLine: IBufferLine;\n    newLine = this._blankLine;\n    const eraseAttr = this.eraseAttrData();\n    if (!newLine || newLine.length !== this.cols || newLine.getFg(0) !== eraseAttr.fg || newLine.getBg(0) !== eraseAttr.bg) {\n      newLine = this.buffer.getBlankLine(eraseAttr, isWrapped);\n      this._blankLine = newLine;\n    }\n    newLine.isWrapped = isWrapped;\n\n    const topRow = this.buffer.ybase + this.buffer.scrollTop;\n    const bottomRow = this.buffer.ybase + this.buffer.scrollBottom;\n\n    if (this.buffer.scrollTop === 0) {\n      // Determine whether the buffer is going to be trimmed after insertion.\n      const willBufferBeTrimmed = this.buffer.lines.isFull;\n\n      // Insert the line using the fastest method\n      if (bottomRow === this.buffer.lines.length - 1) {\n        if (willBufferBeTrimmed) {\n          this.buffer.lines.recycle().copyFrom(newLine);\n        } else {\n          this.buffer.lines.push(newLine.clone());\n        }\n      } else {\n        this.buffer.lines.splice(bottomRow + 1, 0, newLine.clone());\n      }\n\n      // Only adjust ybase and ydisp when the buffer is not trimmed\n      if (!willBufferBeTrimmed) {\n        this.buffer.ybase++;\n        // Only scroll the ydisp with ybase if the user has not scrolled up\n        if (!this._userScrolling) {\n          this.buffer.ydisp++;\n        }\n      } else {\n        // When the buffer is full and the user has scrolled up, keep the text\n        // stable unless ydisp is right at the top\n        if (this._userScrolling) {\n          this.buffer.ydisp = Math.max(this.buffer.ydisp - 1, 0);\n        }\n      }\n    } else {\n      // scrollTop is non-zero which means no line will be going to the\n      // scrollback, instead we can just shift them in-place.\n      const scrollRegionHeight = bottomRow - topRow + 1/*as it's zero-based*/;\n      this.buffer.lines.shiftElements(topRow + 1, scrollRegionHeight - 1, -1);\n      this.buffer.lines.set(bottomRow, newLine.clone());\n    }\n\n    // Move the viewport to the bottom of the buffer unless the user is\n    // scrolling.\n    if (!this._userScrolling) {\n      this.buffer.ydisp = this.buffer.ybase;\n    }\n\n    // Flag rows that need updating\n    this._dirtyRowService.markRangeDirty(this.buffer.scrollTop, this.buffer.scrollBottom);\n\n    this._onScroll.fire(this.buffer.ydisp);\n  }\n\n  /**\n   * Scroll the display of the terminal\n   * @param disp The number of lines to scroll down (negative scroll up).\n   * @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used\n   * to avoid unwanted events being handled by the viewport when the event was triggered from the\n   * viewport originally.\n   */\n  public scrollLines(disp: number, suppressScrollEvent?: boolean): void {\n    if (disp < 0) {\n      if (this.buffer.ydisp === 0) {\n        return;\n      }\n      this._userScrolling = true;\n    } else if (disp + this.buffer.ydisp >= this.buffer.ybase) {\n      this._userScrolling = false;\n    }\n\n    const oldYdisp = this.buffer.ydisp;\n    this.buffer.ydisp = Math.max(Math.min(this.buffer.ydisp + disp, this.buffer.ybase), 0);\n\n    // No change occurred, don't trigger scroll/refresh\n    if (oldYdisp === this.buffer.ydisp) {\n      return;\n    }\n\n    if (!suppressScrollEvent) {\n      this._onScroll.fire(this.buffer.ydisp);\n    }\n\n    this.refresh(0, this.rows - 1);\n  }\n\n  /**\n   * Scroll the display of the terminal by a number of pages.\n   * @param pageCount The number of pages to scroll (negative scrolls up).\n   */\n  public scrollPages(pageCount: number): void {\n    this.scrollLines(pageCount * (this.rows - 1));\n  }\n\n  /**\n   * Scrolls the display of the terminal to the top.\n   */\n  public scrollToTop(): void {\n    this.scrollLines(-this.buffer.ydisp);\n  }\n\n  /**\n   * Scrolls the display of the terminal to the bottom.\n   */\n  public scrollToBottom(): void {\n    this.scrollLines(this.buffer.ybase - this.buffer.ydisp);\n  }\n\n  public scrollToLine(line: number): void {\n    const scrollAmount = line - this.buffer.ydisp;\n    if (scrollAmount !== 0) {\n      this.scrollLines(scrollAmount);\n    }\n  }\n\n  public paste(data: string): void {\n    paste(data, this.textarea, this.bracketedPasteMode, this._coreService);\n  }\n\n  /**\n   * Attaches a custom key event handler which is run before keys are processed,\n   * giving consumers of xterm.js ultimate control as to what keys should be\n   * processed by the terminal and what keys should not.\n   * @param customKeyEventHandler The custom KeyboardEvent handler to attach.\n   * This is a function that takes a KeyboardEvent, allowing consumers to stop\n   * propagation and/or prevent the default action. The function returns whether\n   * the event should be processed by xterm.js.\n   */\n  public attachCustomKeyEventHandler(customKeyEventHandler: CustomKeyEventHandler): void {\n    this._customKeyEventHandler = customKeyEventHandler;\n  }\n\n  /** Add handler for ESC escape sequence. See xterm.d.ts for details. */\n  public addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable {\n    return this._inputHandler.addEscHandler(id, callback);\n  }\n\n  /** Add handler for DCS escape sequence. See xterm.d.ts for details. */\n  public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable {\n    return this._inputHandler.addDcsHandler(id, callback);\n  }\n\n  /** Add handler for CSI escape sequence. See xterm.d.ts for details. */\n  public addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable {\n    return this._inputHandler.addCsiHandler(id, callback);\n  }\n  /** Add handler for OSC escape sequence. See xterm.d.ts for details. */\n  public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    return this._inputHandler.addOscHandler(ident, callback);\n  }\n\n  /**\n   * Registers a link matcher, allowing custom link patterns to be matched and\n   * handled.\n   * @param regex The regular expression to search for, specifically\n   * this searches the textContent of the rows. You will want to use \\s to match\n   * a space ' ' character for example.\n   * @param handler The callback when the link is called.\n   * @param options Options for the link matcher.\n   * @return The ID of the new matcher, this can be used to deregister.\n   */\n  public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options?: ILinkMatcherOptions): number {\n    const matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);\n    this.refresh(0, this.rows - 1);\n    return matcherId;\n  }\n\n  /**\n   * Deregisters a link matcher if it has been registered.\n   * @param matcherId The link matcher's ID (returned after register)\n   */\n  public deregisterLinkMatcher(matcherId: number): void {\n    if (this.linkifier.deregisterLinkMatcher(matcherId)) {\n      this.refresh(0, this.rows - 1);\n    }\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number {\n    const joinerId = this._renderService.registerCharacterJoiner(handler);\n    this.refresh(0, this.rows - 1);\n    return joinerId;\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): void {\n    if (this._renderService.deregisterCharacterJoiner(joinerId)) {\n      this.refresh(0, this.rows - 1);\n    }\n  }\n\n  public get markers(): IMarker[] {\n    return this.buffer.markers;\n  }\n\n  public addMarker(cursorYOffset: number): IMarker {\n    // Disallow markers on the alt buffer\n    if (this.buffer !== this.buffers.normal) {\n      return;\n    }\n\n    return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);\n  }\n\n  /**\n   * Gets whether the terminal has an active selection.\n   */\n  public hasSelection(): boolean {\n    return this._selectionService ? this._selectionService.hasSelection : false;\n  }\n\n  /**\n   * Selects text within the terminal.\n   * @param column The column the selection starts at..\n   * @param row The row the selection starts at.\n   * @param length The length of the selection.\n   */\n  public select(column: number, row: number, length: number): void {\n    this._selectionService.setSelection(column, row, length);\n  }\n\n  /**\n   * Gets the terminal's current selection, this is useful for implementing copy\n   * behavior outside of xterm.js.\n   */\n  public getSelection(): string {\n    return this._selectionService ? this._selectionService.selectionText : '';\n  }\n\n  public getSelectionPosition(): ISelectionPosition | undefined {\n    if (!this._selectionService.hasSelection) {\n      return undefined;\n    }\n\n    return {\n      startColumn: this._selectionService.selectionStart[0],\n      startRow: this._selectionService.selectionStart[1],\n      endColumn: this._selectionService.selectionEnd[0],\n      endRow: this._selectionService.selectionEnd[1]\n    };\n  }\n\n  /**\n   * Clears the current terminal selection.\n   */\n  public clearSelection(): void {\n    this._selectionService?.clearSelection();\n  }\n\n  /**\n   * Selects all text within the terminal.\n   */\n  public selectAll(): void {\n    this._selectionService?.selectAll();\n  }\n\n  public selectLines(start: number, end: number): void {\n    this._selectionService?.selectLines(start, end);\n  }\n\n  /**\n   * Handle a keydown event\n   * Key Resources:\n   *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent\n   * @param ev The keydown event to be handled.\n   */\n  protected _keyDown(event: KeyboardEvent): boolean {\n    this._keyDownHandled = false;\n\n    if (this._customKeyEventHandler && this._customKeyEventHandler(event) === false) {\n      return false;\n    }\n\n    if (!this._compositionHelper.keydown(event)) {\n      if (this.buffer.ybase !== this.buffer.ydisp) {\n        this.scrollToBottom();\n      }\n      return false;\n    }\n\n    const result = evaluateKeyboardEvent(event, this._coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta);\n\n    this.updateCursorStyle(event);\n\n    if (result.type === KeyboardResultType.PAGE_DOWN || result.type === KeyboardResultType.PAGE_UP) {\n      const scrollCount = this.rows - 1;\n      this.scrollLines(result.type === KeyboardResultType.PAGE_UP ? -scrollCount : scrollCount);\n      return this.cancel(event, true);\n    }\n\n    if (result.type === KeyboardResultType.SELECT_ALL) {\n      this.selectAll();\n    }\n\n    if (this._isThirdLevelShift(this.browser, event)) {\n      return true;\n    }\n\n    if (result.cancel) {\n      // The event is canceled at the end already, is this necessary?\n      this.cancel(event, true);\n    }\n\n    if (!result.key) {\n      return true;\n    }\n\n    // If ctrl+c or enter is being sent, clear out the textarea. This is done so that screen readers\n    // will announce deleted characters. This will not work 100% of the time but it should cover\n    // most scenarios.\n    if (result.key === C0.ETX || result.key === C0.CR) {\n      this.textarea.value = '';\n    }\n\n    this._onKey.fire({ key: result.key, domEvent: event });\n    this.showCursor();\n    this._coreService.triggerDataEvent(result.key, true);\n\n    // Cancel events when not in screen reader mode so events don't get bubbled up and handled by\n    // other listeners. When screen reader mode is enabled, this could cause issues if the event\n    // is handled at a higher level, this is a compromise in order to echo keys to the screen\n    // reader.\n    if (!this.optionsService.options.screenReaderMode) {\n      return this.cancel(event, true);\n    }\n\n    this._keyDownHandled = true;\n  }\n\n  private _isThirdLevelShift(browser: IBrowser, ev: IKeyboardEvent): boolean {\n    const thirdLevelKey =\n        (browser.isMac && !this.options.macOptionIsMeta && ev.altKey && !ev.ctrlKey && !ev.metaKey) ||\n        (browser.isWindows && ev.altKey && ev.ctrlKey && !ev.metaKey);\n\n    if (ev.type === 'keypress') {\n      return thirdLevelKey;\n    }\n\n    // Don't invoke for arrows, pageDown, home, backspace, etc. (on non-keypress events)\n    return thirdLevelKey && (!ev.keyCode || ev.keyCode > 47);\n  }\n\n  /**\n   * Set the G level of the terminal\n   * @param g\n   */\n  public setgLevel(g: number): void {\n    this.glevel = g;\n    this.charset = this.charsets[g];\n  }\n\n  /**\n   * Set the charset for the given G level of the terminal\n   * @param g\n   * @param charset\n   */\n  public setgCharset(g: number, charset: ICharset): void {\n    this.charsets[g] = charset;\n    if (this.glevel === g) {\n      this.charset = charset;\n    }\n  }\n\n  protected _keyUp(ev: KeyboardEvent): void {\n    if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {\n      return;\n    }\n\n    if (!wasModifierKeyOnlyEvent(ev)) {\n      this.focus();\n    }\n\n    this.updateCursorStyle(ev);\n  }\n\n  /**\n   * Handle a keypress event.\n   * Key Resources:\n   *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent\n   * @param ev The keypress event to be handled.\n   */\n  protected _keyPress(ev: KeyboardEvent): boolean {\n    let key;\n\n    if (this._keyDownHandled) {\n      return false;\n    }\n\n    if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {\n      return false;\n    }\n\n    this.cancel(ev);\n\n    if (ev.charCode) {\n      key = ev.charCode;\n    } else if (ev.which === null || ev.which === undefined) {\n      key = ev.keyCode;\n    } else if (ev.which !== 0 && ev.charCode !== 0) {\n      key = ev.which;\n    } else {\n      return false;\n    }\n\n    if (!key || (\n      (ev.altKey || ev.ctrlKey || ev.metaKey) && !this._isThirdLevelShift(this.browser, ev)\n    )) {\n      return false;\n    }\n\n    key = String.fromCharCode(key);\n\n    this._onKey.fire({ key, domEvent: ev });\n    this.showCursor();\n    this._coreService.triggerDataEvent(key, true);\n\n    return true;\n  }\n\n  /**\n   * Ring the bell.\n   * Note: We could do sweet things with webaudio here\n   */\n  public bell(): void {\n    if (this._soundBell()) {\n      this._soundService.playBellSound();\n    }\n\n    if (this._visualBell()) {\n      this.element.classList.add('visual-bell-active');\n      clearTimeout(this._visualBellTimer);\n      this._visualBellTimer = window.setTimeout(() => {\n        this.element.classList.remove('visual-bell-active');\n      }, 200);\n    }\n  }\n\n  /**\n   * Resizes the terminal.\n   *\n   * @param x The number of columns to resize to.\n   * @param y The number of rows to resize to.\n   */\n  public resize(x: number, y: number): void {\n    if (isNaN(x) || isNaN(y)) {\n      return;\n    }\n\n    if (x === this.cols && y === this.rows) {\n      // Check if we still need to measure the char size (fixes #785).\n      if (this._charSizeService && !this._charSizeService.hasValidSize) {\n        this._charSizeService.measure();\n      }\n      return;\n    }\n\n    if (x < MINIMUM_COLS) x = MINIMUM_COLS;\n    if (y < MINIMUM_ROWS) y = MINIMUM_ROWS;\n\n    this.buffers.resize(x, y);\n\n    this._bufferService.resize(x, y);\n    this.buffers.setupTabStops(this.cols);\n\n    this._charSizeService?.measure();\n\n    // Sync the scroll area to make sure scroll events don't fire and scroll the viewport to an\n    // invalid location\n    this.viewport.syncScrollArea(true);\n\n    this.refresh(0, this.rows - 1);\n    this._onResize.fire({ cols: x, rows: y });\n  }\n\n  /**\n   * Clear the entire buffer, making the prompt line the new first line.\n   */\n  public clear(): void {\n    if (this.buffer.ybase === 0 && this.buffer.y === 0) {\n      // Don't clear if it's already clear\n      return;\n    }\n    this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y));\n    this.buffer.lines.length = 1;\n    this.buffer.ydisp = 0;\n    this.buffer.ybase = 0;\n    this.buffer.y = 0;\n    for (let i = 1; i < this.rows; i++) {\n      this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA));\n    }\n    this.refresh(0, this.rows - 1);\n    this._onScroll.fire(this.buffer.ydisp);\n  }\n\n  /**\n   * Evaluate if the current terminal is the given argument.\n   * @param term The terminal name to evaluate\n   */\n  public is(term: string): boolean {\n    return (this.options.termName + '').indexOf(term) === 0;\n  }\n\n  /**\n   * Emit the data event and populate the given data.\n   * @param data The data to populate in the event.\n   */\n  // public handler(data: string): void {\n  //   // Prevents all events to pty process if stdin is disabled\n  //   if (this.options.disableStdin) {\n  //     return;\n  //   }\n\n  //   // Clear the selection if the selection manager is available and has an active selection\n  //   if (this.selectionService && this.selectionService.hasSelection) {\n  //     this.selectionService.clearSelection();\n  //   }\n\n  //   // Input is being sent to the terminal, the terminal should focus the prompt.\n  //   if (this.buffer.ybase !== this.buffer.ydisp) {\n  //     this.scrollToBottom();\n  //   }\n  //   this._onData.fire(data);\n  // }\n\n  /**\n   * Emit the 'title' event and populate the given title.\n   * @param title The title to populate in the event.\n   */\n  public handleTitle(title: string): void {\n    this._onTitleChange.fire(title);\n  }\n\n  /**\n   * Reset terminal.\n   * Note: Calling this directly from JS is synchronous but does not clear\n   * input buffers and does not reset the parser, thus the terminal will\n   * continue to apply pending input data.\n   * If you need in band reset (synchronous with input data) consider\n   * using DECSTR (soft reset, CSI ! p) or RIS instead (hard reset, ESC c).\n   */\n  public reset(): void {\n    /**\n     * Since _setup handles a full terminal creation, we have to carry forward\n     * a few things that should not reset.\n     */\n    this.options.rows = this.rows;\n    this.options.cols = this.cols;\n    const customKeyEventHandler = this._customKeyEventHandler;\n    const inputHandler = this._inputHandler;\n    const userScrolling = this._userScrolling;\n\n    this._setup();\n    this._bufferService.reset();\n    this._coreService.reset();\n    this._coreMouseService.reset();\n    this._selectionService?.reset();\n\n    // reattach\n    this._customKeyEventHandler = customKeyEventHandler;\n    this._inputHandler = inputHandler;\n    this._userScrolling = userScrolling;\n\n    // do a full screen refresh\n    this.refresh(0, this.rows - 1);\n    this.viewport?.syncScrollArea();\n  }\n\n  // TODO: Remove cancel function and cancelEvents option\n  public cancel(ev: Event, force?: boolean): boolean {\n    if (!this.options.cancelEvents && !force) {\n      return;\n    }\n    ev.preventDefault();\n    ev.stopPropagation();\n    return false;\n  }\n\n  private _visualBell(): boolean {\n    return false;\n    // return this.options.bellStyle === 'visual' ||\n    //     this.options.bellStyle === 'both';\n  }\n\n  private _soundBell(): boolean {\n    return this.options.bellStyle === 'sound';\n    // return this.options.bellStyle === 'sound' ||\n    //     this.options.bellStyle === 'both';\n  }\n\n  public write(data: string | Uint8Array, callback?: () => void): void {\n    this._writeBuffer.write(data, callback);\n  }\n\n  public writeSync(data: string | Uint8Array): void {\n    this._writeBuffer.writeSync(data);\n  }\n}\n\n/**\n * Helpers\n */\n\nfunction wasModifierKeyOnlyEvent(ev: KeyboardEvent): boolean {\n  return ev.keyCode === 16 || // Shift\n    ev.keyCode === 17 || // Ctrl\n    ev.keyCode === 18; // Alt\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharSizeService } from 'browser/services/Services';\nimport { IBufferService, ICoreService, IOptionsService } from 'common/services/Services';\n\ninterface IPosition {\n  start: number;\n  end: number;\n}\n\n/**\n * Encapsulates the logic for handling compositionstart, compositionupdate and compositionend\n * events, displaying the in-progress composition to the UI and forwarding the final composition\n * to the handler.\n */\nexport class CompositionHelper {\n  /**\n   * Whether input composition is currently happening, eg. via a mobile keyboard, speech input or\n   * IME. This variable determines whether the compositionText should be displayed on the UI.\n   */\n  private _isComposing: boolean;\n\n  /**\n   * The position within the input textarea's value of the current composition.\n   */\n  private _compositionPosition: IPosition;\n\n  /**\n   * Whether a composition is in the process of being sent, setting this to false will cancel any\n   * in-progress composition.\n   */\n  private _isSendingComposition: boolean;\n\n  constructor(\n    private readonly _textarea: HTMLTextAreaElement,\n    private readonly _compositionView: HTMLElement,\n    @IBufferService private readonly _bufferService: IBufferService,\n    @IOptionsService private readonly _optionsService: IOptionsService,\n    @ICharSizeService private readonly _charSizeService: ICharSizeService,\n    @ICoreService private readonly _coreService: ICoreService\n  ) {\n    this._isComposing = false;\n    this._isSendingComposition = false;\n    this._compositionPosition = { start: 0, end: 0 };\n  }\n\n  /**\n   * Handles the compositionstart event, activating the composition view.\n   */\n  public compositionstart(): void {\n    this._isComposing = true;\n    this._compositionPosition.start = this._textarea.value.length;\n    this._compositionView.textContent = '';\n    this._compositionView.classList.add('active');\n  }\n\n  /**\n   * Handles the compositionupdate event, updating the composition view.\n   * @param ev The event.\n   */\n  public compositionupdate(ev: CompositionEvent): void {\n    this._compositionView.textContent = ev.data;\n    this.updateCompositionElements();\n    setTimeout(() => {\n      this._compositionPosition.end = this._textarea.value.length;\n    }, 0);\n  }\n\n  /**\n   * Handles the compositionend event, hiding the composition view and sending the composition to\n   * the handler.\n   */\n  public compositionend(): void {\n    this._finalizeComposition(true);\n  }\n\n  /**\n   * Handles the keydown event, routing any necessary events to the CompositionHelper functions.\n   * @param ev The keydown event.\n   * @return Whether the Terminal should continue processing the keydown event.\n   */\n  public keydown(ev: KeyboardEvent): boolean {\n    if (this._isComposing || this._isSendingComposition) {\n      if (ev.keyCode === 229) {\n        // Continue composing if the keyCode is the \"composition character\"\n        return false;\n      } else if (ev.keyCode === 16 || ev.keyCode === 17 || ev.keyCode === 18) {\n        // Continue composing if the keyCode is a modifier key\n        return false;\n      }\n      // Finish composition immediately. This is mainly here for the case where enter is\n      // pressed and the handler needs to be triggered before the command is executed.\n      this._finalizeComposition(false);\n    }\n\n    if (ev.keyCode === 229) {\n      // If the \"composition character\" is used but gets to this point it means a non-composition\n      // character (eg. numbers and punctuation) was pressed when the IME was active.\n      this._handleAnyTextareaChanges();\n      return false;\n    }\n\n    return true;\n  }\n\n  /**\n   * Finalizes the composition, resuming regular input actions. This is called when a composition\n   * is ending.\n   * @param waitForPropagation Whether to wait for events to propagate before sending\n   *   the input. This should be false if a non-composition keystroke is entered before the\n   *   compositionend event is triggered, such as enter, so that the composition is sent before\n   *   the command is executed.\n   */\n  private _finalizeComposition(waitForPropagation: boolean): void {\n    this._compositionView.classList.remove('active');\n    this._isComposing = false;\n    this._clearTextareaPosition();\n\n    if (!waitForPropagation) {\n      // Cancel any delayed composition send requests and send the input immediately.\n      this._isSendingComposition = false;\n      const input = this._textarea.value.substring(this._compositionPosition.start, this._compositionPosition.end);\n      this._coreService.triggerDataEvent(input, true);\n    } else {\n      // Make a deep copy of the composition position here as a new compositionstart event may\n      // fire before the setTimeout executes.\n      const currentCompositionPosition = {\n        start: this._compositionPosition.start,\n        end: this._compositionPosition.end\n      };\n\n      // Since composition* events happen before the changes take place in the textarea on most\n      // browsers, use a setTimeout with 0ms time to allow the native compositionend event to\n      // complete. This ensures the correct character is retrieved.\n      // This solution was used because:\n      // - The compositionend event's data property is unreliable, at least on Chromium\n      // - The last compositionupdate event's data property does not always accurately describe\n      //   the character, a counter example being Korean where an ending consonsant can move to\n      //   the following character if the following input is a vowel.\n      this._isSendingComposition = true;\n      setTimeout(() => {\n        // Ensure that the input has not already been sent\n        if (this._isSendingComposition) {\n          this._isSendingComposition = false;\n          let input;\n          if (this._isComposing) {\n            // Use the end position to get the string if a new composition has started.\n            input = this._textarea.value.substring(currentCompositionPosition.start, currentCompositionPosition.end);\n          } else {\n            // Don't use the end position here in order to pick up any characters after the\n            // composition has finished, for example when typing a non-composition character\n            // (eg. 2) after a composition character.\n            input = this._textarea.value.substring(currentCompositionPosition.start);\n          }\n          this._coreService.triggerDataEvent(input, true);\n        }\n      }, 0);\n    }\n  }\n\n  /**\n   * Apply any changes made to the textarea after the current event chain is allowed to complete.\n   * This should be called when not currently composing but a keydown event with the \"composition\n   * character\" (229) is triggered, in order to allow non-composition text to be entered when an\n   * IME is active.\n   */\n  private _handleAnyTextareaChanges(): void {\n    const oldValue = this._textarea.value;\n    setTimeout(() => {\n      // Ignore if a composition has started since the timeout\n      if (!this._isComposing) {\n        const newValue = this._textarea.value;\n        const diff = newValue.replace(oldValue, '');\n        if (diff.length > 0) {\n          this._coreService.triggerDataEvent(diff, true);\n        }\n      }\n    }, 0);\n  }\n\n  /**\n   * Positions the composition view on top of the cursor and the textarea just below it (so the\n   * IME helper dialog is positioned correctly).\n   * @param dontRecurse Whether to use setTimeout to recursively trigger another update, this is\n   *   necessary as the IME events across browsers are not consistently triggered.\n   */\n  public updateCompositionElements(dontRecurse?: boolean): void {\n    if (!this._isComposing) {\n      return;\n    }\n\n    if (this._bufferService.buffer.isCursorInViewport) {\n      const cellHeight = Math.ceil(this._charSizeService.height * this._optionsService.options.lineHeight);\n      const cursorTop = this._bufferService.buffer.y * cellHeight;\n      const cursorLeft = this._bufferService.buffer.x * this._charSizeService.width;\n\n      this._compositionView.style.left = cursorLeft + 'px';\n      this._compositionView.style.top = cursorTop + 'px';\n      this._compositionView.style.height = cellHeight + 'px';\n      this._compositionView.style.lineHeight = cellHeight + 'px';\n      this._compositionView.style.fontFamily = this._optionsService.options.fontFamily;\n      this._compositionView.style.fontSize = this._optionsService.options.fontSize + 'px';\n      // Sync the textarea to the exact position of the composition view so the IME knows where the\n      // text is.\n      const compositionViewBounds = this._compositionView.getBoundingClientRect();\n      this._textarea.style.left = cursorLeft + 'px';\n      this._textarea.style.top = cursorTop + 'px';\n      this._textarea.style.width = compositionViewBounds.width + 'px';\n      this._textarea.style.height = compositionViewBounds.height + 'px';\n      this._textarea.style.lineHeight = compositionViewBounds.height + 'px';\n    }\n\n    if (!dontRecurse) {\n      setTimeout(() => this.updateCompositionElements(true), 0);\n    }\n  }\n\n  /**\n   * Clears the textarea's position so that the cursor does not blink on IE.\n   * @private\n   */\n  private _clearTextareaPosition(): void {\n    this._textarea.style.left = '';\n    this._textarea.style.top = '';\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Disposable } from 'common/Lifecycle';\nimport { addDisposableDomListener } from 'browser/Lifecycle';\nimport { IColorSet, IViewport } from 'browser/Types';\nimport { ICharSizeService, IRenderService } from 'browser/services/Services';\nimport { IBufferService, IOptionsService } from 'common/services/Services';\n\nconst FALLBACK_SCROLL_BAR_WIDTH = 15;\n\n/**\n * Represents the viewport of a terminal, the visible area within the larger buffer of output.\n * Logic for the virtual scroll bar is included in this object.\n */\nexport class Viewport extends Disposable implements IViewport {\n  public scrollBarWidth: number = 0;\n  private _currentRowHeight: number = 0;\n  private _lastRecordedBufferLength: number = 0;\n  private _lastRecordedViewportHeight: number = 0;\n  private _lastRecordedBufferHeight: number = 0;\n  private _lastTouchY: number = 0;\n  private _lastScrollTop: number = 0;\n\n  // Stores a partial line amount when scrolling, this is used to keep track of how much of a line\n  // is scrolled so we can \"scroll\" over partial lines and feel natural on touchpads. This is a\n  // quick fix and could have a more robust solution in place that reset the value when needed.\n  private _wheelPartialScroll: number = 0;\n\n  private _refreshAnimationFrame: number | null = null;\n  private _ignoreNextScrollEvent: boolean = false;\n\n  constructor(\n    private readonly _scrollLines: (amount: number, suppressEvent: boolean) => void,\n    private readonly _viewportElement: HTMLElement,\n    private readonly _scrollArea: HTMLElement,\n    @IBufferService private readonly _bufferService: IBufferService,\n    @IOptionsService private readonly _optionsService: IOptionsService,\n    @ICharSizeService private readonly _charSizeService: ICharSizeService,\n    @IRenderService private readonly _renderService: IRenderService\n  ) {\n    super();\n\n    // Measure the width of the scrollbar. If it is 0 we can assume it's an OSX overlay scrollbar.\n    // Unfortunately the overlay scrollbar would be hidden underneath the screen element in that case,\n    // therefore we account for a standard amount to make it visible\n    this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;\n    this.register(addDisposableDomListener(this._viewportElement, 'scroll', this._onScroll.bind(this)));\n\n    // Perform this async to ensure the ICharSizeService is ready.\n    setTimeout(() => this.syncScrollArea(), 0);\n  }\n\n  public onThemeChange(colors: IColorSet): void {\n    this._viewportElement.style.backgroundColor = colors.background.css;\n  }\n\n  /**\n   * Refreshes row height, setting line-height, viewport height and scroll area height if\n   * necessary.\n   */\n  private _refresh(immediate: boolean): void {\n    if (immediate) {\n      this._innerRefresh();\n      if (this._refreshAnimationFrame !== null) {\n        cancelAnimationFrame(this._refreshAnimationFrame);\n      }\n      return;\n    }\n    if (this._refreshAnimationFrame === null) {\n      this._refreshAnimationFrame = requestAnimationFrame(() => this._innerRefresh());\n    }\n  }\n\n  private _innerRefresh(): void {\n    if (this._charSizeService.height > 0) {\n      this._currentRowHeight = this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio;\n      this._lastRecordedViewportHeight = this._viewportElement.offsetHeight;\n      const newBufferHeight = Math.round(this._currentRowHeight * this._lastRecordedBufferLength) + (this._lastRecordedViewportHeight - this._renderService.dimensions.canvasHeight);\n      if (this._lastRecordedBufferHeight !== newBufferHeight) {\n        this._lastRecordedBufferHeight = newBufferHeight;\n        this._scrollArea.style.height = this._lastRecordedBufferHeight + 'px';\n      }\n    }\n\n    // Sync scrollTop\n    const scrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight;\n    if (this._viewportElement.scrollTop !== scrollTop) {\n      // Ignore the next scroll event which will be triggered by setting the scrollTop as we do not\n      // want this event to scroll the terminal\n      this._ignoreNextScrollEvent = true;\n      this._viewportElement.scrollTop = scrollTop;\n    }\n\n    this._refreshAnimationFrame = null;\n  }\n  /**\n   * Updates dimensions and synchronizes the scroll area if necessary.\n   */\n  public syncScrollArea(immediate: boolean = false): void {\n    // If buffer height changed\n    if (this._lastRecordedBufferLength !== this._bufferService.buffer.lines.length) {\n      this._lastRecordedBufferLength = this._bufferService.buffer.lines.length;\n      this._refresh(immediate);\n      return;\n    }\n\n    // If viewport height changed\n    if (this._lastRecordedViewportHeight !== this._renderService.dimensions.canvasHeight) {\n      this._refresh(immediate);\n      return;\n    }\n\n    // If the buffer position doesn't match last scroll top\n    const newScrollTop = this._bufferService.buffer.ydisp * this._currentRowHeight;\n    if (this._lastScrollTop !== newScrollTop) {\n      this._refresh(immediate);\n      return;\n    }\n\n    // If element's scroll top changed, this can happen when hiding the element\n    if (this._lastScrollTop !== this._viewportElement.scrollTop) {\n      this._refresh(immediate);\n      return;\n    }\n\n    // If row height changed\n    if (this._renderService.dimensions.scaledCellHeight / window.devicePixelRatio !== this._currentRowHeight) {\n      this._refresh(immediate);\n      return;\n    }\n  }\n\n  /**\n   * Handles scroll events on the viewport, calculating the new viewport and requesting the\n   * terminal to scroll to it.\n   * @param ev The scroll event.\n   */\n  private _onScroll(ev: Event): void {\n    // Record current scroll top position\n    this._lastScrollTop = this._viewportElement.scrollTop;\n\n    // Don't attempt to scroll if the element is not visible, otherwise scrollTop will be corrupt\n    // which causes the terminal to scroll the buffer to the top\n    if (!this._viewportElement.offsetParent) {\n      return;\n    }\n\n    // Ignore the event if it was flagged to ignore (when the source of the event is from Viewport)\n    if (this._ignoreNextScrollEvent) {\n      this._ignoreNextScrollEvent = false;\n      return;\n    }\n\n    const newRow = Math.round(this._lastScrollTop / this._currentRowHeight);\n    const diff = newRow - this._bufferService.buffer.ydisp;\n    this._scrollLines(diff, true);\n  }\n\n  /**\n   * Handles bubbling of scroll event in case the viewport has reached top or bottom\n   * @param ev The scroll event.\n   * @param amount The amount scrolled\n   */\n  private _bubbleScroll(ev: Event, amount: number): boolean {\n    const scrollPosFromTop = this._viewportElement.scrollTop + this._lastRecordedViewportHeight;\n    if ((amount < 0 && this._viewportElement.scrollTop !== 0) ||\n        (amount > 0 &&  scrollPosFromTop < this._lastRecordedBufferHeight)) {\n      if (ev.cancelable) {\n        ev.preventDefault();\n      }\n      return false;\n    }\n    return true;\n  }\n\n  /**\n   * Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual\n   * scrolling to `onScroll`, this event needs to be attached manually by the consumer of\n   * `Viewport`.\n   * @param ev The mouse wheel event.\n   */\n  public onWheel(ev: WheelEvent): boolean {\n    const amount = this._getPixelsScrolled(ev);\n    if (amount === 0) {\n      return false;\n    }\n    this._viewportElement.scrollTop += amount;\n    return this._bubbleScroll(ev, amount);\n  }\n\n  private _getPixelsScrolled(ev: WheelEvent): number {\n    // Do nothing if it's not a vertical scroll event\n    if (ev.deltaY === 0) {\n      return 0;\n    }\n\n    // Fallback to WheelEvent.DOM_DELTA_PIXEL\n    let amount = this._applyScrollModifier(ev.deltaY, ev);\n    if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {\n      amount *= this._currentRowHeight;\n    } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {\n      amount *= this._currentRowHeight * this._bufferService.rows;\n    }\n    return amount;\n  }\n\n  /**\n   * Gets the number of pixels scrolled by the mouse event taking into account what type of delta\n   * is being used.\n   * @param ev The mouse wheel event.\n   */\n  public getLinesScrolled(ev: WheelEvent): number {\n    // Do nothing if it's not a vertical scroll event\n    if (ev.deltaY === 0) {\n      return 0;\n    }\n\n    // Fallback to WheelEvent.DOM_DELTA_LINE\n    let amount = this._applyScrollModifier(ev.deltaY, ev);\n    if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {\n      amount /= this._currentRowHeight + 0.0; // Prevent integer division\n      this._wheelPartialScroll += amount;\n      amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);\n      this._wheelPartialScroll %= 1;\n    } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {\n      amount *= this._bufferService.rows;\n    }\n    return amount;\n  }\n\n  private _applyScrollModifier(amount: number, ev: WheelEvent): number {\n    const modifier = this._optionsService.options.fastScrollModifier;\n    // Multiply the scroll speed when the modifier is down\n    if ((modifier === 'alt' && ev.altKey) ||\n        (modifier === 'ctrl' && ev.ctrlKey) ||\n        (modifier === 'shift' && ev.shiftKey)) {\n      return amount * this._optionsService.options.fastScrollSensitivity * this._optionsService.options.scrollSensitivity;\n    }\n\n    return amount * this._optionsService.options.scrollSensitivity;\n  }\n\n  /**\n   * Handles the touchstart event, recording the touch occurred.\n   * @param ev The touch event.\n   */\n  public onTouchStart(ev: TouchEvent): void {\n    this._lastTouchY = ev.touches[0].pageY;\n  }\n\n  /**\n   * Handles the touchmove event, scrolling the viewport if the position shifted.\n   * @param ev The touch event.\n   */\n  public onTouchMove(ev: TouchEvent): boolean {\n    const deltaY = this._lastTouchY - ev.touches[0].pageY;\n    this._lastTouchY = ev.touches[0].pageY;\n    if (deltaY === 0) {\n      return false;\n    }\n    this._viewportElement.scrollTop += deltaY;\n    return this._bubbleScroll(ev, deltaY);\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ISelectionService } from 'browser/services/Services';\nimport { ICoreService } from 'common/services/Services';\n\n/**\n * Prepares text to be pasted into the terminal by normalizing the line endings\n * @param text The pasted text that needs processing before inserting into the terminal\n */\nexport function prepareTextForTerminal(text: string): string {\n  return text.replace(/\\r?\\n/g, '\\r');\n}\n\n/**\n * Bracket text for paste, if necessary, as per https://cirw.in/blog/bracketed-paste\n * @param text The pasted text to bracket\n */\nexport function bracketTextForPaste(text: string, bracketedPasteMode: boolean): string {\n  if (bracketedPasteMode) {\n    return '\\x1b[200~' + text + '\\x1b[201~';\n  }\n  return text;\n}\n\n/**\n * Binds copy functionality to the given terminal.\n * @param ev The original copy event to be handled\n */\nexport function copyHandler(ev: ClipboardEvent, selectionService: ISelectionService): void {\n  if (ev.clipboardData) {\n    ev.clipboardData.setData('text/plain', selectionService.selectionText);\n  }\n  // Prevent or the original text will be copied.\n  ev.preventDefault();\n}\n\n/**\n * Redirect the clipboard's data to the terminal's input handler.\n * @param ev The original paste event to be handled\n * @param term The terminal on which to apply the handled paste event\n */\nexport function handlePasteEvent(ev: ClipboardEvent, textarea: HTMLTextAreaElement, bracketedPasteMode: boolean, coreService: ICoreService): void {\n  ev.stopPropagation();\n  if (ev.clipboardData) {\n    const text = ev.clipboardData.getData('text/plain');\n    paste(text, textarea, bracketedPasteMode, coreService);\n  }\n}\n\nexport function paste(text: string, textarea: HTMLTextAreaElement, bracketedPasteMode: boolean, coreService: ICoreService): void {\n  text = prepareTextForTerminal(text);\n  text = bracketTextForPaste(text, bracketedPasteMode);\n  coreService.triggerDataEvent(text, true);\n  textarea.value = '';\n}\n\n/**\n * Moves the textarea under the mouse cursor and focuses it.\n * @param ev The original right click event to be handled.\n * @param textarea The terminal's textarea.\n */\nexport function moveTextAreaUnderMouseCursor(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement): void {\n\n  // Calculate textarea position relative to the screen element\n  const pos = screenElement.getBoundingClientRect();\n  const left = ev.clientX - pos.left - 10;\n  const top = ev.clientY - pos.top - 10;\n\n  // Bring textarea at the cursor position\n  textarea.style.position = 'absolute';\n  textarea.style.width = '20px';\n  textarea.style.height = '20px';\n  textarea.style.left = `${left}px`;\n  textarea.style.top = `${top}px`;\n  textarea.style.zIndex = '1000';\n\n  textarea.focus();\n\n  // Reset the terminal textarea's styling\n  // Timeout needs to be long enough for click event to be handled.\n  setTimeout(() => {\n    textarea.style.position = '';\n    textarea.style.width = '';\n    textarea.style.height = '';\n    textarea.style.left = '';\n    textarea.style.top = '';\n    textarea.style.zIndex = '';\n  }, 200);\n}\n\n/**\n * Bind to right-click event and allow right-click copy and paste.\n * @param ev The original right click event to be handled.\n * @param textarea The terminal's textarea.\n * @param selectionService The terminal's selection manager.\n * @param shouldSelectWord If true and there is no selection the current word will be selected\n */\nexport function rightClickHandler(ev: MouseEvent, textarea: HTMLTextAreaElement, screenElement: HTMLElement, selectionService: ISelectionService, shouldSelectWord: boolean): void {\n  moveTextAreaUnderMouseCursor(ev, textarea, screenElement);\n\n  if (shouldSelectWord && !selectionService.isClickInSelection(ev)) {\n    selectionService.selectWordAtCursor(ev);\n  }\n\n  // Get textarea ready to copy from the context menu\n  textarea.value = selectionService.selectionText;\n  textarea.select();\n}\n","/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n */\n\nimport { IInputHandler, IInputHandlingTerminal } from './Types';\nimport { C0, C1 } from 'common/data/EscapeSequences';\nimport { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets';\nimport { wcwidth } from 'common/CharWidth';\nimport { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';\nimport { Disposable } from 'common/Lifecycle';\nimport { concat } from 'common/TypedArrayUtils';\nimport { StringToUtf32, stringFromCodePoint, utf32ToString, Utf8ToUtf32 } from 'common/input/TextDecoder';\nimport { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IFunctionIdentifier } from 'common/parser/Types';\nimport { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content } from 'common/buffer/Constants';\nimport { CellData } from 'common/buffer/CellData';\nimport { AttributeData } from 'common/buffer/AttributeData';\nimport { IAttributeData, IDisposable } from 'common/Types';\nimport { ICoreService, IBufferService, IOptionsService, ILogService, IDirtyRowService, ICoreMouseService } from 'common/services/Services';\nimport { OscHandler } from 'common/parser/OscParser';\nimport { DcsHandler } from 'common/parser/DcsParser';\n\n/**\n * Map collect to glevel. Used in `selectCharset`.\n */\nconst GLEVEL: {[key: string]: number} = {'(': 0, ')': 1, '*': 2, '+': 3, '-': 1, '.': 2};\n\n/**\n * Max length of the UTF32 input buffer. Real memory consumption is 4 times higher.\n */\nconst MAX_PARSEBUFFER_LENGTH = 131072;\n\n\n/**\n * DCS subparser implementations\n */\n\n/**\n * DCS $ q Pt ST\n *   DECRQSS (https://vt100.net/docs/vt510-rm/DECRQSS.html)\n *   Request Status String (DECRQSS), VT420 and up.\n *   Response: DECRPSS (https://vt100.net/docs/vt510-rm/DECRPSS.html)\n */\nclass DECRQSS implements IDcsHandler {\n  private _data: Uint32Array = new Uint32Array(0);\n\n  constructor(\n    private _bufferService: IBufferService,\n    private _coreService: ICoreService,\n    private _logService: ILogService,\n    private _optionsService: IOptionsService\n  ) { }\n\n  hook(params: IParams): void {\n    this._data = new Uint32Array(0);\n  }\n\n  put(data: Uint32Array, start: number, end: number): void {\n    this._data = concat(this._data, data.subarray(start, end));\n  }\n\n  unhook(success: boolean): void {\n    if (!success) {\n      this._data = new Uint32Array(0);\n      return;\n    }\n    const data = utf32ToString(this._data);\n    this._data = new Uint32Array(0);\n    switch (data) {\n      // valid: DCS 1 $ r Pt ST (xterm)\n      case '\"q': // DECSCA\n        return this._coreService.triggerDataEvent(`${C0.ESC}P1$r0\"q${C0.ESC}\\\\`);\n      case '\"p': // DECSCL\n        return this._coreService.triggerDataEvent(`${C0.ESC}P1$r61\"p${C0.ESC}\\\\`);\n      case 'r': // DECSTBM\n        const pt = '' + (this._bufferService.buffer.scrollTop + 1) +\n                ';' + (this._bufferService.buffer.scrollBottom + 1) + 'r';\n        return this._coreService.triggerDataEvent(`${C0.ESC}P1$r${pt}${C0.ESC}\\\\`);\n      case 'm': // SGR\n        // TODO: report real settings instead of 0m\n        return this._coreService.triggerDataEvent(`${C0.ESC}P1$r0m${C0.ESC}\\\\`);\n      case ' q': // DECSCUSR\n        const STYLES: {[key: string]: number} = {'block': 2, 'underline': 4, 'bar': 6};\n        let style = STYLES[this._optionsService.options.cursorStyle];\n        style -= this._optionsService.options.cursorBlink ? 1 : 0;\n        return this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\\\`);\n      default:\n        // invalid: DCS 0 $ r Pt ST (xterm)\n        this._logService.debug('Unknown DCS $q %s', data);\n        this._coreService.triggerDataEvent(`${C0.ESC}P0$r${C0.ESC}\\\\`);\n    }\n  }\n}\n\n/**\n * DCS Ps; Ps| Pt ST\n *   DECUDK (https://vt100.net/docs/vt510-rm/DECUDK.html)\n *   not supported\n */\n\n/**\n * DCS + q Pt ST (xterm)\n *   Request Terminfo String\n *   not implemented\n */\n\n/**\n * DCS + p Pt ST (xterm)\n *   Set Terminfo Data\n *   not supported\n */\n\n\n\n/**\n * The terminal's standard implementation of IInputHandler, this handles all\n * input from the Parser.\n *\n * Refer to http://invisible-island.net/xterm/ctlseqs/ctlseqs.html to understand\n * each function's header comment.\n */\nexport class InputHandler extends Disposable implements IInputHandler {\n  private _parseBuffer: Uint32Array = new Uint32Array(4096);\n  private _stringDecoder: StringToUtf32 = new StringToUtf32();\n  private _utf8Decoder: Utf8ToUtf32 = new Utf8ToUtf32();\n  private _workCell: CellData = new CellData();\n\n  private _onCursorMove = new EventEmitter<void>();\n  public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }\n  private _onLineFeed = new EventEmitter<void>();\n  public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }\n  private _onScroll = new EventEmitter<number>();\n  public get onScroll(): IEvent<number> { return this._onScroll.event; }\n\n  constructor(\n    protected _terminal: IInputHandlingTerminal,\n    private readonly _bufferService: IBufferService,\n    private readonly _coreService: ICoreService,\n    private readonly _dirtyRowService: IDirtyRowService,\n    private readonly _logService: ILogService,\n    private readonly _optionsService: IOptionsService,\n    private readonly _coreMouseService: ICoreMouseService,\n    private readonly _parser: IEscapeSequenceParser = new EscapeSequenceParser())\n  {\n    super();\n\n    this.register(this._parser);\n\n    /**\n     * custom fallback handlers\n     */\n    this._parser.setCsiHandlerFallback((ident, params) => {\n      this._logService.debug('Unknown CSI code: ', { identifier: this._parser.identToString(ident), params: params.toArray() });\n    });\n    this._parser.setEscHandlerFallback(ident => {\n      this._logService.debug('Unknown ESC code: ', { identifier: this._parser.identToString(ident) });\n    });\n    this._parser.setExecuteHandlerFallback(code => {\n      this._logService.debug('Unknown EXECUTE code: ', { code });\n    });\n    this._parser.setOscHandlerFallback((identifier, action, data) => {\n      this._logService.debug('Unknown OSC code: ', { identifier, action, data });\n    });\n    this._parser.setDcsHandlerFallback((ident, action, payload) => {\n      if (action === 'HOOK') {\n        payload = payload.toArray();\n      }\n      this._logService.debug('Unknown DCS code: ', { identifier: this._parser.identToString(ident), action, payload });\n    });\n\n    /**\n     * print handler\n     */\n    this._parser.setPrintHandler((data, start, end) => this.print(data, start, end));\n\n    /**\n     * CSI handler\n     */\n    this._parser.setCsiHandler({final: '@'}, params => this.insertChars(params));\n    this._parser.setCsiHandler({intermediates: ' ', final: '@'}, params => this.scrollLeft(params));\n    this._parser.setCsiHandler({final: 'A'}, params => this.cursorUp(params));\n    this._parser.setCsiHandler({intermediates: ' ', final: 'A'}, params => this.scrollRight(params));\n    this._parser.setCsiHandler({final: 'B'}, params => this.cursorDown(params));\n    this._parser.setCsiHandler({final: 'C'}, params => this.cursorForward(params));\n    this._parser.setCsiHandler({final: 'D'}, params => this.cursorBackward(params));\n    this._parser.setCsiHandler({final: 'E'}, params => this.cursorNextLine(params));\n    this._parser.setCsiHandler({final: 'F'}, params => this.cursorPrecedingLine(params));\n    this._parser.setCsiHandler({final: 'G'}, params => this.cursorCharAbsolute(params));\n    this._parser.setCsiHandler({final: 'H'}, params => this.cursorPosition(params));\n    this._parser.setCsiHandler({final: 'I'}, params => this.cursorForwardTab(params));\n    this._parser.setCsiHandler({final: 'J'}, params => this.eraseInDisplay(params));\n    this._parser.setCsiHandler({prefix: '?', final: 'J'}, params => this.eraseInDisplay(params));\n    this._parser.setCsiHandler({final: 'K'}, params => this.eraseInLine(params));\n    this._parser.setCsiHandler({prefix: '?', final: 'K'}, params => this.eraseInLine(params));\n    this._parser.setCsiHandler({final: 'L'}, params => this.insertLines(params));\n    this._parser.setCsiHandler({final: 'M'}, params => this.deleteLines(params));\n    this._parser.setCsiHandler({final: 'P'}, params => this.deleteChars(params));\n    this._parser.setCsiHandler({final: 'S'}, params => this.scrollUp(params));\n    this._parser.setCsiHandler({final: 'T'}, params => this.scrollDown(params));\n    this._parser.setCsiHandler({final: 'X'}, params => this.eraseChars(params));\n    this._parser.setCsiHandler({final: 'Z'}, params => this.cursorBackwardTab(params));\n    this._parser.setCsiHandler({final: '`'}, params => this.charPosAbsolute(params));\n    this._parser.setCsiHandler({final: 'a'}, params => this.hPositionRelative(params));\n    this._parser.setCsiHandler({final: 'b'}, params => this.repeatPrecedingCharacter(params));\n    this._parser.setCsiHandler({final: 'c'}, params => this.sendDeviceAttributesPrimary(params));\n    this._parser.setCsiHandler({prefix: '>', final: 'c'}, params => this.sendDeviceAttributesSecondary(params));\n    this._parser.setCsiHandler({final: 'd'}, params => this.linePosAbsolute(params));\n    this._parser.setCsiHandler({final: 'e'}, params => this.vPositionRelative(params));\n    this._parser.setCsiHandler({final: 'f'}, params => this.hVPosition(params));\n    this._parser.setCsiHandler({final: 'g'}, params => this.tabClear(params));\n    this._parser.setCsiHandler({final: 'h'}, params => this.setMode(params));\n    this._parser.setCsiHandler({prefix: '?', final: 'h'}, params => this.setModePrivate(params));\n    this._parser.setCsiHandler({final: 'l'}, params => this.resetMode(params));\n    this._parser.setCsiHandler({prefix: '?', final: 'l'}, params => this.resetModePrivate(params));\n    this._parser.setCsiHandler({final: 'm'}, params => this.charAttributes(params));\n    this._parser.setCsiHandler({final: 'n'}, params => this.deviceStatus(params));\n    this._parser.setCsiHandler({prefix: '?', final: 'n'}, params => this.deviceStatusPrivate(params));\n    this._parser.setCsiHandler({intermediates: '!', final: 'p'}, params => this.softReset(params));\n    this._parser.setCsiHandler({intermediates: ' ', final: 'q'}, params => this.setCursorStyle(params));\n    this._parser.setCsiHandler({final: 'r'}, params => this.setScrollRegion(params));\n    this._parser.setCsiHandler({final: 's'}, params => this.saveCursor(params));\n    this._parser.setCsiHandler({final: 'u'}, params => this.restoreCursor(params));\n    this._parser.setCsiHandler({intermediates: '\\'', final: '}'}, params => this.insertColumns(params));\n    this._parser.setCsiHandler({intermediates: '\\'', final: '~'}, params => this.deleteColumns(params));\n\n    /**\n     * execute handler\n     */\n    this._parser.setExecuteHandler(C0.BEL, () => this.bell());\n    this._parser.setExecuteHandler(C0.LF, () => this.lineFeed());\n    this._parser.setExecuteHandler(C0.VT, () => this.lineFeed());\n    this._parser.setExecuteHandler(C0.FF, () => this.lineFeed());\n    this._parser.setExecuteHandler(C0.CR, () => this.carriageReturn());\n    this._parser.setExecuteHandler(C0.BS, () => this.backspace());\n    this._parser.setExecuteHandler(C0.HT, () => this.tab());\n    this._parser.setExecuteHandler(C0.SO, () => this.shiftOut());\n    this._parser.setExecuteHandler(C0.SI, () => this.shiftIn());\n    // FIXME:   What do to with missing? Old code just added those to print.\n\n    this._parser.setExecuteHandler(C1.IND, () => this.index());\n    this._parser.setExecuteHandler(C1.NEL, () => this.nextLine());\n    this._parser.setExecuteHandler(C1.HTS, () => this.tabSet());\n\n    /**\n     * OSC handler\n     */\n    //   0 - icon name + title\n    this._parser.setOscHandler(0, new OscHandler((data: string) => this.setTitle(data)));\n    //   1 - icon name\n    //   2 - title\n    this._parser.setOscHandler(2, new OscHandler((data: string) => this.setTitle(data)));\n    //   3 - set property X in the form \"prop=value\"\n    //   4 - Change Color Number\n    //   5 - Change Special Color Number\n    //   6 - Enable/disable Special Color Number c\n    //   7 - current directory? (not in xterm spec, see https://gitlab.com/gnachman/iterm2/issues/3939)\n    //  10 - Change VT100 text foreground color to Pt.\n    //  11 - Change VT100 text background color to Pt.\n    //  12 - Change text cursor color to Pt.\n    //  13 - Change mouse foreground color to Pt.\n    //  14 - Change mouse background color to Pt.\n    //  15 - Change Tektronix foreground color to Pt.\n    //  16 - Change Tektronix background color to Pt.\n    //  17 - Change highlight background color to Pt.\n    //  18 - Change Tektronix cursor color to Pt.\n    //  19 - Change highlight foreground color to Pt.\n    //  46 - Change Log File to Pt.\n    //  50 - Set Font to Pt.\n    //  51 - reserved for Emacs shell.\n    //  52 - Manipulate Selection Data.\n    // 104 ; c - Reset Color Number c.\n    // 105 ; c - Reset Special Color Number c.\n    // 106 ; c; f - Enable/disable Special Color Number c.\n    // 110 - Reset VT100 text foreground color.\n    // 111 - Reset VT100 text background color.\n    // 112 - Reset text cursor color.\n    // 113 - Reset mouse foreground color.\n    // 114 - Reset mouse background color.\n    // 115 - Reset Tektronix foreground color.\n    // 116 - Reset Tektronix background color.\n    // 117 - Reset highlight color.\n    // 118 - Reset Tektronix cursor color.\n    // 119 - Reset highlight foreground color.\n\n    /**\n     * ESC handlers\n     */\n    this._parser.setEscHandler({final: '7'}, () => this.saveCursor());\n    this._parser.setEscHandler({final: '8'}, () => this.restoreCursor());\n    this._parser.setEscHandler({final: 'D'}, () => this.index());\n    this._parser.setEscHandler({final: 'E'}, () => this.nextLine());\n    this._parser.setEscHandler({final: 'H'}, () => this.tabSet());\n    this._parser.setEscHandler({final: 'M'}, () => this.reverseIndex());\n    this._parser.setEscHandler({final: '='}, () => this.keypadApplicationMode());\n    this._parser.setEscHandler({final: '>'}, () => this.keypadNumericMode());\n    this._parser.setEscHandler({final: 'c'}, () => this.reset());\n    this._parser.setEscHandler({final: 'n'}, () => this.setgLevel(2));\n    this._parser.setEscHandler({final: 'o'}, () => this.setgLevel(3));\n    this._parser.setEscHandler({final: '|'}, () => this.setgLevel(3));\n    this._parser.setEscHandler({final: '}'}, () => this.setgLevel(2));\n    this._parser.setEscHandler({final: '~'}, () => this.setgLevel(1));\n    this._parser.setEscHandler({intermediates: '%', final: '@'}, () => this.selectDefaultCharset());\n    this._parser.setEscHandler({intermediates: '%', final: 'G'}, () => this.selectDefaultCharset());\n    for (const flag in CHARSETS) {\n      this._parser.setEscHandler({intermediates: '(', final: flag}, () => this.selectCharset('(' + flag));\n      this._parser.setEscHandler({intermediates: ')', final: flag}, () => this.selectCharset(')' + flag));\n      this._parser.setEscHandler({intermediates: '*', final: flag}, () => this.selectCharset('*' + flag));\n      this._parser.setEscHandler({intermediates: '+', final: flag}, () => this.selectCharset('+' + flag));\n      this._parser.setEscHandler({intermediates: '-', final: flag}, () => this.selectCharset('-' + flag));\n      this._parser.setEscHandler({intermediates: '.', final: flag}, () => this.selectCharset('.' + flag));\n      this._parser.setEscHandler({intermediates: '/', final: flag}, () => this.selectCharset('/' + flag)); // TODO: supported?\n    }\n    this._parser.setEscHandler({intermediates: '#', final: '8'}, () => this.screenAlignmentPattern());\n\n    /**\n     * error handler\n     */\n    this._parser.setErrorHandler((state: IParsingState) => {\n      this._logService.error('Parsing error: ', state);\n      return state;\n    });\n\n    /**\n     * DCS handler\n     */\n    this._parser.setDcsHandler({intermediates: '$', final: 'q'}, new DECRQSS(this._bufferService, this._coreService, this._logService, this._optionsService));\n  }\n\n  public dispose(): void {\n    super.dispose();\n  }\n\n  public parse(data: string | Uint8Array): void {\n    let buffer = this._bufferService.buffer;\n    const cursorStartX = buffer.x;\n    const cursorStartY = buffer.y;\n\n    this._logService.debug('parsing data', data);\n\n    // resize input buffer if needed\n    if (this._parseBuffer.length < data.length) {\n      if (this._parseBuffer.length < MAX_PARSEBUFFER_LENGTH) {\n        this._parseBuffer = new Uint32Array(Math.min(data.length, MAX_PARSEBUFFER_LENGTH));\n      }\n    }\n\n    // Clear the dirty row service so we know which lines changed as a result of parsing\n    this._dirtyRowService.clearRange();\n\n    // process big data in smaller chunks\n    if (data.length > MAX_PARSEBUFFER_LENGTH) {\n      for (let i = 0; i < data.length; i += MAX_PARSEBUFFER_LENGTH) {\n        const end = i + MAX_PARSEBUFFER_LENGTH < data.length ? i + MAX_PARSEBUFFER_LENGTH : data.length;\n        const len = (typeof data === 'string')\n          ? this._stringDecoder.decode(data.substring(i, end), this._parseBuffer)\n          : this._utf8Decoder.decode(data.subarray(i, end), this._parseBuffer);\n        this._parser.parse(this._parseBuffer, len);\n      }\n    } else {\n      const len = (typeof data === 'string')\n        ? this._stringDecoder.decode(data, this._parseBuffer)\n        : this._utf8Decoder.decode(data, this._parseBuffer);\n      this._parser.parse(this._parseBuffer, len);\n    }\n\n    buffer = this._bufferService.buffer;\n    if (buffer.x !== cursorStartX || buffer.y !== cursorStartY) {\n      this._onCursorMove.fire();\n    }\n\n    // Refresh any dirty rows accumulated as part of parsing\n    this._terminal.refresh(this._dirtyRowService.start, this._dirtyRowService.end);\n  }\n\n  public print(data: Uint32Array, start: number, end: number): void {\n    let code: number;\n    let chWidth: number;\n    const buffer = this._bufferService.buffer;\n    const charset = this._terminal.charset;\n    const screenReaderMode = this._optionsService.options.screenReaderMode;\n    const cols = this._bufferService.cols;\n    const wraparoundMode = this._terminal.wraparoundMode;\n    const insertMode = this._terminal.insertMode;\n    const curAttr = this._terminal.curAttrData;\n    let bufferRow = buffer.lines.get(buffer.y + buffer.ybase);\n\n    this._dirtyRowService.markDirty(buffer.y);\n    for (let pos = start; pos < end; ++pos) {\n      code = data[pos];\n\n      // calculate print space\n      // expensive call, therefore we save width in line buffer\n      chWidth = wcwidth(code);\n\n      // get charset replacement character\n      // charset is only defined for ASCII, therefore we only\n      // search for an replacement char if code < 127\n      if (code < 127 && charset) {\n        const ch = charset[String.fromCharCode(code)];\n        if (ch) {\n          code = ch.charCodeAt(0);\n        }\n      }\n\n      if (screenReaderMode) {\n        this._terminal.onA11yCharEmitter.fire(stringFromCodePoint(code));\n      }\n\n      // insert combining char at last cursor position\n      // FIXME: needs handling after cursor jumps\n      // buffer.x should never be 0 for a combining char\n      // since they always follow a cell consuming char\n      // therefore we can test for buffer.x to avoid overflow left\n      if (!chWidth && buffer.x) {\n        if (!bufferRow.getWidth(buffer.x - 1)) {\n          // found empty cell after fullwidth, need to go 2 cells back\n          // it is save to step 2 cells back here\n          // since an empty cell is only set by fullwidth chars\n          bufferRow.addCodepointToCell(buffer.x - 2, code);\n        } else {\n          bufferRow.addCodepointToCell(buffer.x - 1, code);\n        }\n        continue;\n      }\n\n      // goto next line if ch would overflow\n      // TODO: needs a global min terminal width of 2\n      // FIXME: additionally ensure chWidth fits into a line\n      //   -->  maybe forbid cols<xy at higher level as it would\n      //        introduce a bad runtime penalty here\n      if (buffer.x + chWidth - 1 >= cols) {\n        // autowrap - DECAWM\n        // automatically wraps to the beginning of the next line\n        if (wraparoundMode) {\n          buffer.x = 0;\n          buffer.y++;\n          if (buffer.y === buffer.scrollBottom + 1) {\n            buffer.y--;\n            this._terminal.scroll(true);\n          } else {\n            if (buffer.y >= this._bufferService.rows) {\n              buffer.y = this._bufferService.rows - 1;\n            }\n            // The line already exists (eg. the initial viewport), mark it as a\n            // wrapped line\n            buffer.lines.get(buffer.y).isWrapped = true;\n          }\n          // row changed, get it again\n          bufferRow = buffer.lines.get(buffer.y + buffer.ybase);\n        } else {\n          buffer.x = cols - 1;\n          if (chWidth === 2) {\n            // FIXME: check for xterm behavior\n            // What to do here? We got a wide char that does not fit into last cell\n            continue;\n          }\n        }\n      }\n\n      // insert mode: move characters to right\n      if (insertMode) {\n        // right shift cells according to the width\n        bufferRow.insertCells(buffer.x, chWidth, buffer.getNullCell(curAttr));\n        // test last cell - since the last cell has only room for\n        // a halfwidth char any fullwidth shifted there is lost\n        // and will be set to empty cell\n        if (bufferRow.getWidth(cols - 1) === 2) {\n          bufferRow.setCellFromCodePoint(cols - 1, NULL_CELL_CODE, NULL_CELL_WIDTH, curAttr.fg, curAttr.bg);\n        }\n      }\n\n      // write current char to buffer and advance cursor\n      bufferRow.setCellFromCodePoint(buffer.x++, code, chWidth, curAttr.fg, curAttr.bg);\n\n      // fullwidth char - also set next cell to placeholder stub and advance cursor\n      // for graphemes bigger than fullwidth we can simply loop to zero\n      // we already made sure above, that buffer.x + chWidth will not overflow right\n      if (chWidth > 0) {\n        while (--chWidth) {\n          // other than a regular empty cell a cell following a wide char has no width\n          bufferRow.setCellFromCodePoint(buffer.x++, 0, 0, curAttr.fg, curAttr.bg);\n        }\n      }\n    }\n    // store last char in Parser.precedingCodepoint for REP to work correctly\n    // This needs to check whether:\n    //  - fullwidth + surrogates: reset\n    //  - combining: only base char gets carried on (bug in xterm?)\n    if (end) {\n      bufferRow.loadCell(buffer.x - 1, this._workCell);\n      if (this._workCell.getWidth() === 2 || this._workCell.getCode() > 0xFFFF) {\n        this._parser.precedingCodepoint = 0;\n      } else if (this._workCell.isCombined()) {\n        this._parser.precedingCodepoint = this._workCell.getChars().charCodeAt(0);\n      } else {\n        this._parser.precedingCodepoint = this._workCell.content;\n      }\n    }\n    this._dirtyRowService.markDirty(buffer.y);\n  }\n\n  /**\n   * Forward addCsiHandler from parser.\n   */\n  public addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable {\n    return this._parser.addCsiHandler(id, callback);\n  }\n\n  /**\n   * Forward addDcsHandler from parser.\n   */\n  public addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable {\n    return this._parser.addDcsHandler(id, new DcsHandler(callback));\n  }\n\n  /**\n   * Forward addEscHandler from parser.\n   */\n  public addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable {\n    return this._parser.addEscHandler(id, callback);\n  }\n\n  /**\n   * Forward addOscHandler from parser.\n   */\n  public addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable {\n    return this._parser.addOscHandler(ident, new OscHandler(callback));\n  }\n\n  /**\n   * BEL\n   * Bell (Ctrl-G).\n   */\n  public bell(): void {\n    this._terminal.bell();\n  }\n\n  /**\n   * LF\n   * Line Feed or New Line (NL).  (LF  is Ctrl-J).\n   */\n  public lineFeed(): void {\n    // make buffer local for faster access\n    const buffer = this._bufferService.buffer;\n\n    this._dirtyRowService.markDirty(buffer.y);\n    if (this._optionsService.options.convertEol) {\n      buffer.x = 0;\n    }\n    buffer.y++;\n    if (buffer.y === buffer.scrollBottom + 1) {\n      buffer.y--;\n      this._terminal.scroll();\n    } else if (buffer.y >= this._bufferService.rows) {\n      buffer.y = this._bufferService.rows - 1;\n    }\n    // If the end of the line is hit, prevent this action from wrapping around to the next line.\n    if (buffer.x >= this._bufferService.cols) {\n      buffer.x--;\n    }\n    this._dirtyRowService.markDirty(buffer.y);\n\n    this._onLineFeed.fire();\n  }\n\n  /**\n   * CR\n   * Carriage Return (Ctrl-M).\n   */\n  public carriageReturn(): void {\n    this._bufferService.buffer.x = 0;\n  }\n\n  /**\n   * BS\n   * Backspace (Ctrl-H).\n   */\n  public backspace(): void {\n    this._restrictCursor();\n    if (this._bufferService.buffer.x > 0) {\n      this._bufferService.buffer.x--;\n    }\n  }\n\n  /**\n   * TAB\n   * Horizontal Tab (HT) (Ctrl-I).\n   */\n  public tab(): void {\n    if (this._bufferService.buffer.x >= this._bufferService.cols) {\n      return;\n    }\n    const originalX = this._bufferService.buffer.x;\n    this._bufferService.buffer.x = this._bufferService.buffer.nextStop();\n    if (this._optionsService.options.screenReaderMode) {\n      this._terminal.onA11yTabEmitter.fire(this._bufferService.buffer.x - originalX);\n    }\n  }\n\n  /**\n   * SO\n   * Shift Out (Ctrl-N) -> Switch to Alternate Character Set.  This invokes the\n   * G1 character set.\n   */\n  public shiftOut(): void {\n    this._terminal.setgLevel(1);\n  }\n\n  /**\n   * SI\n   * Shift In (Ctrl-O) -> Switch to Standard Character Set.  This invokes the G0\n   * character set (the default).\n   */\n  public shiftIn(): void {\n    this._terminal.setgLevel(0);\n  }\n\n  /**\n   * Restrict cursor to viewport size / scroll margin (origin mode).\n   */\n  private _restrictCursor(): void {\n    this._bufferService.buffer.x = Math.min(this._bufferService.cols - 1, Math.max(0, this._bufferService.buffer.x));\n    this._bufferService.buffer.y = this._terminal.originMode\n      ? Math.min(this._bufferService.buffer.scrollBottom, Math.max(this._bufferService.buffer.scrollTop, this._bufferService.buffer.y))\n      : Math.min(this._bufferService.rows - 1, Math.max(0, this._bufferService.buffer.y));\n    this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n  }\n\n  /**\n   * Set absolute cursor position.\n   */\n  private _setCursor(x: number, y: number): void {\n    this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n    if (this._terminal.originMode) {\n      this._bufferService.buffer.x = x;\n      this._bufferService.buffer.y = this._bufferService.buffer.scrollTop + y;\n    } else {\n      this._bufferService.buffer.x = x;\n      this._bufferService.buffer.y = y;\n    }\n    this._restrictCursor();\n    this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n  }\n\n  /**\n   * Set relative cursor position.\n   */\n  private _moveCursor(x: number, y: number): void {\n    // for relative changes we have to make sure we are within 0 .. cols/rows - 1\n    // before calculating the new position\n    this._restrictCursor();\n    this._setCursor(this._bufferService.buffer.x + x, this._bufferService.buffer.y + y);\n  }\n\n  /**\n   * CSI Ps A\n   * Cursor Up Ps Times (default = 1) (CUU).\n   */\n  public cursorUp(params: IParams): void {\n    // stop at scrollTop\n    const diffToTop = this._bufferService.buffer.y - this._bufferService.buffer.scrollTop;\n    if (diffToTop >= 0) {\n      this._moveCursor(0, -Math.min(diffToTop, params.params[0] || 1));\n    } else {\n      this._moveCursor(0, -(params.params[0] || 1));\n    }\n  }\n\n  /**\n   * CSI Ps B\n   * Cursor Down Ps Times (default = 1) (CUD).\n   */\n  public cursorDown(params: IParams): void {\n    // stop at scrollBottom\n    const diffToBottom = this._bufferService.buffer.scrollBottom - this._bufferService.buffer.y;\n    if (diffToBottom >= 0) {\n      this._moveCursor(0, Math.min(diffToBottom, params.params[0] || 1));\n    } else {\n      this._moveCursor(0, params.params[0] || 1);\n    }\n  }\n\n  /**\n   * CSI Ps C\n   * Cursor Forward Ps Times (default = 1) (CUF).\n   */\n  public cursorForward(params: IParams): void {\n    this._moveCursor(params.params[0] || 1, 0);\n  }\n\n  /**\n   * CSI Ps D\n   * Cursor Backward Ps Times (default = 1) (CUB).\n   */\n  public cursorBackward(params: IParams): void {\n    this._moveCursor(-(params.params[0] || 1), 0);\n  }\n\n  /**\n   * CSI Ps E\n   * Cursor Next Line Ps Times (default = 1) (CNL).\n   * Other than cursorDown (CUD) also set the cursor to first column.\n   */\n  public cursorNextLine(params: IParams): void {\n    this.cursorDown(params);\n    this._bufferService.buffer.x = 0;\n  }\n\n  /**\n   * CSI Ps F\n   * Cursor Previous Line Ps Times (default = 1) (CPL).\n   * Other than cursorUp (CUU) also set the cursor to first column.\n   */\n  public cursorPrecedingLine(params: IParams): void {\n    this.cursorUp(params);\n    this._bufferService.buffer.x = 0;\n  }\n\n  /**\n   * CSI Ps G\n   * Cursor Character Absolute  [column] (default = [row,1]) (CHA).\n   */\n  public cursorCharAbsolute(params: IParams): void {\n    this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y);\n  }\n\n  /**\n   * CSI Ps ; Ps H\n   * Cursor Position [row;column] (default = [1,1]) (CUP).\n   */\n  public cursorPosition(params: IParams): void {\n    this._setCursor(\n      // col\n      (params.length >= 2) ? (params.params[1] || 1) - 1 : 0,\n      // row\n      (params.params[0] || 1) - 1);\n  }\n\n  /**\n   * CSI Pm `  Character Position Absolute\n   *   [column] (default = [row,1]) (HPA).\n   * Currently same functionality as CHA.\n   */\n  public charPosAbsolute(params: IParams): void {\n    this._setCursor((params.params[0] || 1) - 1, this._bufferService.buffer.y);\n  }\n\n  /**\n   * CSI Pm a  Character Position Relative\n   *   [columns] (default = [row,col+1]) (HPR)\n   * Currently same functionality as CUF.\n   */\n  public hPositionRelative(params: IParams): void {\n    this._moveCursor(params.params[0] || 1, 0);\n  }\n\n  /**\n   * CSI Pm d  Vertical Position Absolute (VPA)\n   *   [row] (default = [1,column])\n   */\n  public linePosAbsolute(params: IParams): void {\n    this._setCursor(this._bufferService.buffer.x, (params.params[0] || 1) - 1);\n  }\n\n  /**\n   * CSI Pm e  Vertical Position Relative (VPR)\n   *   [rows] (default = [row+1,column])\n   * reuse CSI Ps B ?\n   */\n  public vPositionRelative(params: IParams): void {\n    this._moveCursor(0, params.params[0] || 1);\n  }\n\n  /**\n   * CSI Ps ; Ps f\n   *   Horizontal and Vertical Position [row;column] (default =\n   *   [1,1]) (HVP).\n   *   Same as CUP.\n   */\n  public hVPosition(params: IParams): void {\n    this.cursorPosition(params);\n  }\n\n  /**\n   * CSI Ps g  Tab Clear (TBC).\n   *     Ps = 0  -> Clear Current Column (default).\n   *     Ps = 3  -> Clear All.\n   * Potentially:\n   *   Ps = 2  -> Clear Stops on Line.\n   *   http://vt100.net/annarbor/aaa-ug/section6.html\n   */\n  public tabClear(params: IParams): void {\n    const param = params.params[0];\n    if (param === 0) {\n      delete this._bufferService.buffer.tabs[this._bufferService.buffer.x];\n    } else if (param === 3) {\n      this._bufferService.buffer.tabs = {};\n    }\n  }\n\n  /**\n   * CSI Ps I\n   *   Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).\n   */\n  public cursorForwardTab(params: IParams): void {\n    if (this._bufferService.buffer.x >= this._bufferService.cols) {\n      return;\n    }\n    let param = params.params[0] || 1;\n    while (param--) {\n      this._bufferService.buffer.x = this._bufferService.buffer.nextStop();\n    }\n  }\n\n  /**\n   * CSI Ps Z  Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).\n   */\n  public cursorBackwardTab(params: IParams): void {\n    if (this._bufferService.buffer.x >= this._bufferService.cols) {\n      return;\n    }\n    let param = params.params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._bufferService.buffer;\n\n    while (param--) {\n      buffer.x = buffer.prevStop();\n    }\n  }\n\n\n  /**\n   * Helper method to erase cells in a terminal row.\n   * The cell gets replaced with the eraseChar of the terminal.\n   * @param y row index\n   * @param start first cell index to be erased\n   * @param end   end - 1 is last erased cell\n   */\n  private _eraseInBufferLine(y: number, start: number, end: number, clearWrap: boolean = false): void {\n    const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + y);\n    line.replaceCells(\n      start,\n      end,\n      this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())\n    );\n    if (clearWrap) {\n      line.isWrapped = false;\n    }\n  }\n\n  /**\n   * Helper method to reset cells in a terminal row.\n   * The cell gets replaced with the eraseChar of the terminal and the isWrapped property is set to false.\n   * @param y row index\n   */\n  private _resetBufferLine(y: number): void {\n    const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase + y);\n    line.fill(this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData()));\n    line.isWrapped = false;\n  }\n\n  /**\n   * CSI Ps J  Erase in Display (ED).\n   *     Ps = 0  -> Erase Below (default).\n   *     Ps = 1  -> Erase Above.\n   *     Ps = 2  -> Erase All.\n   *     Ps = 3  -> Erase Saved Lines (xterm).\n   * CSI ? Ps J\n   *   Erase in Display (DECSED).\n   *     Ps = 0  -> Selective Erase Below (default).\n   *     Ps = 1  -> Selective Erase Above.\n   *     Ps = 2  -> Selective Erase All.\n   */\n  public eraseInDisplay(params: IParams): void {\n    this._restrictCursor();\n    let j;\n    switch (params.params[0]) {\n      case 0:\n        j = this._bufferService.buffer.y;\n        this._dirtyRowService.markDirty(j);\n        this._eraseInBufferLine(j++, this._bufferService.buffer.x, this._bufferService.cols, this._bufferService.buffer.x === 0);\n        for (; j < this._bufferService.rows; j++) {\n          this._resetBufferLine(j);\n        }\n        this._dirtyRowService.markDirty(j);\n        break;\n      case 1:\n        j = this._bufferService.buffer.y;\n        this._dirtyRowService.markDirty(j);\n        // Deleted front part of line and everything before. This line will no longer be wrapped.\n        this._eraseInBufferLine(j, 0, this._bufferService.buffer.x + 1, true);\n        if (this._bufferService.buffer.x + 1 >= this._bufferService.cols) {\n          // Deleted entire previous line. This next line can no longer be wrapped.\n          this._bufferService.buffer.lines.get(j + 1).isWrapped = false;\n        }\n        while (j--) {\n          this._resetBufferLine(j);\n        }\n        this._dirtyRowService.markDirty(0);\n        break;\n      case 2:\n        j = this._bufferService.rows;\n        this._dirtyRowService.markDirty(j - 1);\n        while (j--) {\n          this._resetBufferLine(j);\n        }\n        this._dirtyRowService.markDirty(0);\n        break;\n      case 3:\n        // Clear scrollback (everything not in viewport)\n        const scrollBackSize = this._bufferService.buffer.lines.length - this._bufferService.rows;\n        if (scrollBackSize > 0) {\n          this._bufferService.buffer.lines.trimStart(scrollBackSize);\n          this._bufferService.buffer.ybase = Math.max(this._bufferService.buffer.ybase - scrollBackSize, 0);\n          this._bufferService.buffer.ydisp = Math.max(this._bufferService.buffer.ydisp - scrollBackSize, 0);\n          // Force a scroll event to refresh viewport\n          this._onScroll.fire(0);\n        }\n        break;\n    }\n  }\n\n  /**\n   * CSI Ps K  Erase in Line (EL).\n   *     Ps = 0  -> Erase to Right (default).\n   *     Ps = 1  -> Erase to Left.\n   *     Ps = 2  -> Erase All.\n   * CSI ? Ps K\n   *   Erase in Line (DECSEL).\n   *     Ps = 0  -> Selective Erase to Right (default).\n   *     Ps = 1  -> Selective Erase to Left.\n   *     Ps = 2  -> Selective Erase All.\n   */\n  public eraseInLine(params: IParams): void {\n    this._restrictCursor();\n    switch (params.params[0]) {\n      case 0:\n        this._eraseInBufferLine(this._bufferService.buffer.y, this._bufferService.buffer.x, this._bufferService.cols);\n        break;\n      case 1:\n        this._eraseInBufferLine(this._bufferService.buffer.y, 0, this._bufferService.buffer.x + 1);\n        break;\n      case 2:\n        this._eraseInBufferLine(this._bufferService.buffer.y, 0, this._bufferService.cols);\n        break;\n    }\n    this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n  }\n\n  /**\n   * CSI Ps L\n   * Insert Ps Line(s) (default = 1) (IL).\n   */\n  public insertLines(params: IParams): void {\n    this._restrictCursor();\n    let param = params.params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._bufferService.buffer;\n\n    if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {\n      return;\n    }\n\n    const row: number = buffer.y + buffer.ybase;\n\n    const scrollBottomRowsOffset = this._bufferService.rows - 1 - buffer.scrollBottom;\n    const scrollBottomAbsolute = this._bufferService.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1;\n    while (param--) {\n      // test: echo -e '\\e[44m\\e[1L\\e[0m'\n      // blankLine(true) - xterm/linux behavior\n      buffer.lines.splice(scrollBottomAbsolute - 1, 1);\n      buffer.lines.splice(row, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));\n    }\n\n    this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom);\n    buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only?\n  }\n\n  /**\n   * CSI Ps M\n   * Delete Ps Line(s) (default = 1) (DL).\n   */\n  public deleteLines(params: IParams): void {\n    this._restrictCursor();\n    let param = params.params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._bufferService.buffer;\n\n    if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {\n      return;\n    }\n\n    const row: number = buffer.y + buffer.ybase;\n\n    let j: number;\n    j = this._bufferService.rows - 1 - buffer.scrollBottom;\n    j = this._bufferService.rows - 1 + buffer.ybase - j;\n    while (param--) {\n      // test: echo -e '\\e[44m\\e[1M\\e[0m'\n      // blankLine(true) - xterm/linux behavior\n      buffer.lines.splice(row, 1);\n      buffer.lines.splice(j, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));\n    }\n\n    this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom);\n    buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only?\n  }\n\n  /**\n   * CSI Ps @\n   * Insert Ps (Blank) Character(s) (default = 1) (ICH).\n   */\n  public insertChars(params: IParams): void {\n    this._restrictCursor();\n    const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.y + this._bufferService.buffer.ybase);\n    if (line) {\n      line.insertCells(\n        this._bufferService.buffer.x,\n        params.params[0] || 1,\n        this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())\n      );\n      this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n    }\n  }\n\n  /**\n   * CSI Ps P\n   * Delete Ps Character(s) (default = 1) (DCH).\n   */\n  public deleteChars(params: IParams): void {\n    this._restrictCursor();\n    const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.y + this._bufferService.buffer.ybase);\n    if (line) {\n      line.deleteCells(\n        this._bufferService.buffer.x,\n        params.params[0] || 1,\n        this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())\n      );\n      this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n    }\n  }\n\n  /**\n   * CSI Ps S  Scroll up Ps lines (default = 1) (SU).\n   */\n  public scrollUp(params: IParams): void {\n    let param = params.params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._bufferService.buffer;\n\n    while (param--) {\n      buffer.lines.splice(buffer.ybase + buffer.scrollTop, 1);\n      buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));\n    }\n    this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps T  Scroll down Ps lines (default = 1) (SD).\n   */\n  public scrollDown(params: IParams): void {\n    let param = params.params[0] || 1;\n\n    // make buffer local for faster access\n    const buffer = this._bufferService.buffer;\n\n    while (param--) {\n      buffer.lines.splice(buffer.ybase + buffer.scrollBottom, 1);\n      buffer.lines.splice(buffer.ybase + buffer.scrollTop, 0, buffer.getBlankLine(DEFAULT_ATTR_DATA));\n    }\n    this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps SP @  Scroll left Ps columns (default = 1) (SL) ECMA-48\n   *\n   * Notation: (Pn)\n   * Representation: CSI Pn 02/00 04/00\n   * Parameter default value: Pn = 1\n   * SL causes the data in the presentation component to be moved by n character positions\n   * if the line orientation is horizontal, or by n line positions if the line orientation\n   * is vertical, such that the data appear to move to the left; where n equals the value of Pn.\n   * The active presentation position is not affected by this control function.\n   *\n   * Supported:\n   *   - always left shift (no line orientation setting respected)\n   */\n  public scrollLeft(params: IParams): void {\n    const buffer = this._bufferService.buffer;\n    if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {\n      return;\n    }\n    const param = params.params[0] || 1;\n    for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) {\n      const line = buffer.lines.get(buffer.ybase + y);\n      line.deleteCells(0, param, buffer.getNullCell(this._terminal.eraseAttrData()));\n      line.isWrapped = false;\n    }\n    this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps SP A  Scroll right Ps columns (default = 1) (SR) ECMA-48\n   *\n   * Notation: (Pn)\n   * Representation: CSI Pn 02/00 04/01\n   * Parameter default value: Pn = 1\n   * SR causes the data in the presentation component to be moved by n character positions\n   * if the line orientation is horizontal, or by n line positions if the line orientation\n   * is vertical, such that the data appear to move to the right; where n equals the value of Pn.\n   * The active presentation position is not affected by this control function.\n   *\n   * Supported:\n   *   - always right shift (no line orientation setting respected)\n   */\n  public scrollRight(params: IParams): void {\n    const buffer = this._bufferService.buffer;\n    if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {\n      return;\n    }\n    const param = params.params[0] || 1;\n    for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) {\n      const line = buffer.lines.get(buffer.ybase + y);\n      line.insertCells(0, param, buffer.getNullCell(this._terminal.eraseAttrData()));\n      line.isWrapped = false;\n    }\n    this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Pm ' }\n   * Insert Ps Column(s) (default = 1) (DECIC), VT420 and up.\n   */\n  public insertColumns(params: IParams): void {\n    const buffer = this._bufferService.buffer;\n    if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {\n      return;\n    }\n    const param = params.params[0] || 1;\n    for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) {\n      const line = this._bufferService.buffer.lines.get(buffer.ybase + y);\n      line.insertCells(buffer.x, param, buffer.getNullCell(this._terminal.eraseAttrData()));\n      line.isWrapped = false;\n    }\n    this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Pm ' ~\n   * Delete Ps Column(s) (default = 1) (DECDC), VT420 and up.\n   */\n  public deleteColumns(params: IParams): void {\n    const buffer = this._bufferService.buffer;\n    if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {\n      return;\n    }\n    const param = params.params[0] || 1;\n    for (let y = buffer.scrollTop; y <= buffer.scrollBottom; ++y) {\n      const line = buffer.lines.get(buffer.ybase + y);\n      line.deleteCells(buffer.x, param, buffer.getNullCell(this._terminal.eraseAttrData()));\n      line.isWrapped = false;\n    }\n    this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n  }\n\n  /**\n   * CSI Ps X\n   * Erase Ps Character(s) (default = 1) (ECH).\n   */\n  public eraseChars(params: IParams): void {\n    this._restrictCursor();\n    const line = this._bufferService.buffer.lines.get(this._bufferService.buffer.y + this._bufferService.buffer.ybase);\n    if (line) {\n      line.replaceCells(\n        this._bufferService.buffer.x,\n        this._bufferService.buffer.x + (params.params[0] || 1),\n        this._bufferService.buffer.getNullCell(this._terminal.eraseAttrData())\n      );\n      this._dirtyRowService.markDirty(this._bufferService.buffer.y);\n    }\n  }\n\n  /**\n   * CSI Ps b  Repeat the preceding graphic character Ps times (REP).\n   * From ECMA 48 (@see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf)\n   *    Notation: (Pn)\n   *    Representation: CSI Pn 06/02\n   *    Parameter default value: Pn = 1\n   *    REP is used to indicate that the preceding character in the data stream,\n   *    if it is a graphic character (represented by one or more bit combinations) including SPACE,\n   *    is to be repeated n times, where n equals the value of Pn.\n   *    If the character preceding REP is a control function or part of a control function,\n   *    the effect of REP is not defined by this Standard.\n   *\n   * Since we propagate the terminal as xterm-256color we have to follow xterm's behavior:\n   *    - fullwidth + surrogate chars are ignored\n   *    - for combining chars only the base char gets repeated\n   *    - text attrs are applied normally\n   *    - wrap around is respected\n   *    - any valid sequence resets the carried forward char\n   *\n   * Note: To get reset on a valid sequence working correctly without much runtime penalty,\n   * the preceding codepoint is stored on the parser in `this.print` and reset during `parser.parse`.\n   */\n  public repeatPrecedingCharacter(params: IParams): void {\n    if (!this._parser.precedingCodepoint) {\n      return;\n    }\n    // call print to insert the chars and handle correct wrapping\n    const length = params.params[0] || 1;\n    const data = new Uint32Array(length);\n    for (let i = 0; i < length; ++i) {\n      data[i] = this._parser.precedingCodepoint;\n    }\n    this.print(data, 0, data.length);\n  }\n\n  /**\n   * CSI Ps c  Send Device Attributes (Primary DA).\n   *     Ps = 0  or omitted -> request attributes from terminal.  The\n   *     response depends on the decTerminalID resource setting.\n   *     -> CSI ? 1 ; 2 c  (``VT100 with Advanced Video Option'')\n   *     -> CSI ? 1 ; 0 c  (``VT101 with No Options'')\n   *     -> CSI ? 6 c  (``VT102'')\n   *     -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c  (``VT220'')\n   *   The VT100-style response parameters do not mean anything by\n   *   themselves.  VT220 parameters do, telling the host what fea-\n   *   tures the terminal supports:\n   *     Ps = 1  -> 132-columns.\n   *     Ps = 2  -> Printer.\n   *     Ps = 6  -> Selective erase.\n   *     Ps = 8  -> User-defined keys.\n   *     Ps = 9  -> National replacement character sets.\n   *     Ps = 1 5  -> Technical characters.\n   *     Ps = 2 2  -> ANSI color, e.g., VT525.\n   *     Ps = 2 9  -> ANSI text locator (i.e., DEC Locator mode).\n   * CSI > Ps c\n   *   Send Device Attributes (Secondary DA).\n   *     Ps = 0  or omitted -> request the terminal's identification\n   *     code.  The response depends on the decTerminalID resource set-\n   *     ting.  It should apply only to VT220 and up, but xterm extends\n   *     this to VT100.\n   *     -> CSI  > Pp ; Pv ; Pc c\n   *   where Pp denotes the terminal type\n   *     Pp = 0  -> ``VT100''.\n   *     Pp = 1  -> ``VT220''.\n   *   and Pv is the firmware version (for xterm, this was originally\n   *   the XFree86 patch number, starting with 95).  In a DEC termi-\n   *   nal, Pc indicates the ROM cartridge registration number and is\n   *   always zero.\n   * More information:\n   *   xterm/charproc.c - line 2012, for more information.\n   *   vim responds with ^[[?0c or ^[[?1c after the terminal's response (?)\n   */\n  public sendDeviceAttributesPrimary(params: IParams): void {\n    if (params.params[0] > 0) {\n      return;\n    }\n    if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {\n      this._coreService.triggerDataEvent(C0.ESC + '[?1;2c');\n    } else if (this._terminal.is('linux')) {\n      this._coreService.triggerDataEvent(C0.ESC + '[?6c');\n    }\n  }\n  public sendDeviceAttributesSecondary(params: IParams): void {\n    if (params.params[0] > 0) {\n      return;\n    }\n    // xterm and urxvt\n    // seem to spit this\n    // out around ~370 times (?).\n    if (this._terminal.is('xterm')) {\n      this._coreService.triggerDataEvent(C0.ESC + '[>0;276;0c');\n    } else if (this._terminal.is('rxvt-unicode')) {\n      this._coreService.triggerDataEvent(C0.ESC + '[>85;95;0c');\n    } else if (this._terminal.is('linux')) {\n      // not supported by linux console.\n      // linux console echoes parameters.\n      this._coreService.triggerDataEvent(params.params[0] + 'c');\n    } else if (this._terminal.is('screen')) {\n      this._coreService.triggerDataEvent(C0.ESC + '[>83;40003;0c');\n    }\n  }\n\n  /**\n   * CSI Pm h  Set Mode (SM).\n   *     Ps = 2  -> Keyboard Action Mode (AM).\n   *     Ps = 4  -> Insert Mode (IRM).\n   *     Ps = 1 2  -> Send/receive (SRM).\n   *     Ps = 2 0  -> Automatic Newline (LNM).\n   * CSI ? Pm h\n   *   DEC Private Mode Set (DECSET).\n   *     Ps = 1  -> Application Cursor Keys (DECCKM).\n   *     Ps = 2  -> Designate USASCII for character sets G0-G3\n   *     (DECANM), and set VT100 mode.\n   *     Ps = 3  -> 132 Column Mode (DECCOLM).\n   *     Ps = 4  -> Smooth (Slow) Scroll (DECSCLM).\n   *     Ps = 5  -> Reverse Video (DECSCNM).\n   *     Ps = 6  -> Origin Mode (DECOM).\n   *     Ps = 7  -> Wraparound Mode (DECAWM).\n   *     Ps = 8  -> Auto-repeat Keys (DECARM).\n   *     Ps = 9  -> Send Mouse X & Y on button press.  See the sec-\n   *     tion Mouse Tracking.\n   *     Ps = 1 0  -> Show toolbar (rxvt).\n   *     Ps = 1 2  -> Start Blinking Cursor (att610).\n   *     Ps = 1 8  -> Print form feed (DECPFF).\n   *     Ps = 1 9  -> Set print extent to full screen (DECPEX).\n   *     Ps = 2 5  -> Show Cursor (DECTCEM).\n   *     Ps = 3 0  -> Show scrollbar (rxvt).\n   *     Ps = 3 5  -> Enable font-shifting functions (rxvt).\n   *     Ps = 3 8  -> Enter Tektronix Mode (DECTEK).\n   *     Ps = 4 0  -> Allow 80 -> 132 Mode.\n   *     Ps = 4 1  -> more(1) fix (see curses resource).\n   *     Ps = 4 2  -> Enable Nation Replacement Character sets (DECN-\n   *     RCM).\n   *     Ps = 4 4  -> Turn On Margin Bell.\n   *     Ps = 4 5  -> Reverse-wraparound Mode.\n   *     Ps = 4 6  -> Start Logging.  This is normally disabled by a\n   *     compile-time option.\n   *     Ps = 4 7  -> Use Alternate Screen Buffer.  (This may be dis-\n   *     abled by the titeInhibit resource).\n   *     Ps = 6 6  -> Application keypad (DECNKM).\n   *     Ps = 6 7  -> Backarrow key sends backspace (DECBKM).\n   *     Ps = 1 0 0 0  -> Send Mouse X & Y on button press and\n   *     release.  See the section Mouse Tracking.\n   *     Ps = 1 0 0 1  -> Use Hilite Mouse Tracking.\n   *     Ps = 1 0 0 2  -> Use Cell Motion Mouse Tracking.\n   *     Ps = 1 0 0 3  -> Use All Motion Mouse Tracking.\n   *     Ps = 1 0 0 4  -> Send FocusIn/FocusOut events.\n   *     Ps = 1 0 0 5  -> Enable Extended Mouse Mode.\n   *     Ps = 1 0 1 0  -> Scroll to bottom on tty output (rxvt).\n   *     Ps = 1 0 1 1  -> Scroll to bottom on key press (rxvt).\n   *     Ps = 1 0 3 4  -> Interpret \"meta\" key, sets eighth bit.\n   *     (enables the eightBitInput resource).\n   *     Ps = 1 0 3 5  -> Enable special modifiers for Alt and Num-\n   *     Lock keys.  (This enables the numLock resource).\n   *     Ps = 1 0 3 6  -> Send ESC   when Meta modifies a key.  (This\n   *     enables the metaSendsEscape resource).\n   *     Ps = 1 0 3 7  -> Send DEL from the editing-keypad Delete\n   *     key.\n   *     Ps = 1 0 3 9  -> Send ESC  when Alt modifies a key.  (This\n   *     enables the altSendsEscape resource).\n   *     Ps = 1 0 4 0  -> Keep selection even if not highlighted.\n   *     (This enables the keepSelection resource).\n   *     Ps = 1 0 4 1  -> Use the CLIPBOARD selection.  (This enables\n   *     the selectToClipboard resource).\n   *     Ps = 1 0 4 2  -> Enable Urgency window manager hint when\n   *     Control-G is received.  (This enables the bellIsUrgent\n   *     resource).\n   *     Ps = 1 0 4 3  -> Enable raising of the window when Control-G\n   *     is received.  (enables the popOnBell resource).\n   *     Ps = 1 0 4 7  -> Use Alternate Screen Buffer.  (This may be\n   *     disabled by the titeInhibit resource).\n   *     Ps = 1 0 4 8  -> Save cursor as in DECSC.  (This may be dis-\n   *     abled by the titeInhibit resource).\n   *     Ps = 1 0 4 9  -> Save cursor as in DECSC and use Alternate\n   *     Screen Buffer, clearing it first.  (This may be disabled by\n   *     the titeInhibit resource).  This combines the effects of the 1\n   *     0 4 7  and 1 0 4 8  modes.  Use this with terminfo-based\n   *     applications rather than the 4 7  mode.\n   *     Ps = 1 0 5 0  -> Set terminfo/termcap function-key mode.\n   *     Ps = 1 0 5 1  -> Set Sun function-key mode.\n   *     Ps = 1 0 5 2  -> Set HP function-key mode.\n   *     Ps = 1 0 5 3  -> Set SCO function-key mode.\n   *     Ps = 1 0 6 0  -> Set legacy keyboard emulation (X11R6).\n   *     Ps = 1 0 6 1  -> Set VT220 keyboard emulation.\n   *     Ps = 2 0 0 4  -> Set bracketed paste mode.\n   * Modes:\n   *   http: *vt100.net/docs/vt220-rm/chapter4.html\n   */\n  public setMode(params: IParams): void {\n    for (let i = 0; i < params.length; i++) {\n      switch (params.params[i]) {\n        case 4:\n          this._terminal.insertMode = true;\n          break;\n        case 20:\n          // this._t.convertEol = true;\n          break;\n      }\n    }\n  }\n  public setModePrivate(params: IParams): void {\n    for (let i = 0; i < params.length; i++) {\n      switch (params.params[i]) {\n        case 1:\n          this._coreService.decPrivateModes.applicationCursorKeys = true;\n          break;\n        case 2:\n          this._terminal.setgCharset(0, DEFAULT_CHARSET);\n          this._terminal.setgCharset(1, DEFAULT_CHARSET);\n          this._terminal.setgCharset(2, DEFAULT_CHARSET);\n          this._terminal.setgCharset(3, DEFAULT_CHARSET);\n          // set VT100 mode here\n          break;\n        case 3: // 132 col mode\n          // TODO: move DECCOLM into compat addon\n          this._terminal.savedCols = this._bufferService.cols;\n          this._terminal.resize(132, this._bufferService.rows);\n          this._terminal.reset();\n          break;\n        case 6:\n          this._terminal.originMode = true;\n          this._setCursor(0, 0);\n          break;\n        case 7:\n          this._terminal.wraparoundMode = true;\n          break;\n        case 12:\n          // this.cursorBlink = true;\n          break;\n        case 66:\n          this._logService.debug('Serial port requested application keypad.');\n          this._terminal.applicationKeypad = true;\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          break;\n        case 9: // X10 Mouse\n          // no release, no motion, no wheel, no modifiers.\n          this._coreMouseService.activeProtocol = 'X10';\n          break;\n        case 1000: // vt200 mouse\n          // no motion.\n          this._coreMouseService.activeProtocol = 'VT200';\n          break;\n        case 1002: // button event mouse\n          this._coreMouseService.activeProtocol = 'DRAG';\n          break;\n        case 1003: // any event mouse\n          // any event - sends motion events,\n          // even if there is no button held down.\n          this._coreMouseService.activeProtocol = 'ANY';\n          break;\n        case 1004: // send focusin/focusout events\n          // focusin: ^[[I\n          // focusout: ^[[O\n          this._terminal.sendFocus = true;\n          break;\n        case 1005: // utf8 ext mode mouse - removed in #2507\n          this._logService.debug('DECSET 1005 not supported (see #2507)');\n          break;\n        case 1006: // sgr ext mode mouse\n          this._coreMouseService.activeEncoding = 'SGR';\n          break;\n        case 1015: // urxvt ext mode mouse - removed in #2507\n          this._logService.debug('DECSET 1015 not supported (see #2507)');\n          break;\n        case 25: // show cursor\n          this._coreService.isCursorHidden = false;\n          break;\n        case 1048: // alt screen cursor\n          this.saveCursor();\n          break;\n        case 1049: // alt screen buffer cursor\n          this.saveCursor();\n          // FALL-THROUGH\n        case 47: // alt screen buffer\n        case 1047: // alt screen buffer\n          this._bufferService.buffers.activateAltBuffer(this._terminal.eraseAttrData());\n          this._terminal.refresh(0, this._bufferService.rows - 1);\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          this._terminal.showCursor();\n          break;\n        case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)\n          this._terminal.bracketedPasteMode = true;\n          break;\n      }\n    }\n  }\n\n\n  /**\n   * CSI Pm l  Reset Mode (RM).\n   *     Ps = 2  -> Keyboard Action Mode (AM).\n   *     Ps = 4  -> Replace Mode (IRM).\n   *     Ps = 1 2  -> Send/receive (SRM).\n   *     Ps = 2 0  -> Normal Linefeed (LNM).\n   * CSI ? Pm l\n   *   DEC Private Mode Reset (DECRST).\n   *     Ps = 1  -> Normal Cursor Keys (DECCKM).\n   *     Ps = 2  -> Designate VT52 mode (DECANM).\n   *     Ps = 3  -> 80 Column Mode (DECCOLM).\n   *     Ps = 4  -> Jump (Fast) Scroll (DECSCLM).\n   *     Ps = 5  -> Normal Video (DECSCNM).\n   *     Ps = 6  -> Normal Cursor Mode (DECOM).\n   *     Ps = 7  -> No Wraparound Mode (DECAWM).\n   *     Ps = 8  -> No Auto-repeat Keys (DECARM).\n   *     Ps = 9  -> Don't send Mouse X & Y on button press.\n   *     Ps = 1 0  -> Hide toolbar (rxvt).\n   *     Ps = 1 2  -> Stop Blinking Cursor (att610).\n   *     Ps = 1 8  -> Don't print form feed (DECPFF).\n   *     Ps = 1 9  -> Limit print to scrolling region (DECPEX).\n   *     Ps = 2 5  -> Hide Cursor (DECTCEM).\n   *     Ps = 3 0  -> Don't show scrollbar (rxvt).\n   *     Ps = 3 5  -> Disable font-shifting functions (rxvt).\n   *     Ps = 4 0  -> Disallow 80 -> 132 Mode.\n   *     Ps = 4 1  -> No more(1) fix (see curses resource).\n   *     Ps = 4 2  -> Disable Nation Replacement Character sets (DEC-\n   *     NRCM).\n   *     Ps = 4 4  -> Turn Off Margin Bell.\n   *     Ps = 4 5  -> No Reverse-wraparound Mode.\n   *     Ps = 4 6  -> Stop Logging.  (This is normally disabled by a\n   *     compile-time option).\n   *     Ps = 4 7  -> Use Normal Screen Buffer.\n   *     Ps = 6 6  -> Numeric keypad (DECNKM).\n   *     Ps = 6 7  -> Backarrow key sends delete (DECBKM).\n   *     Ps = 1 0 0 0  -> Don't send Mouse X & Y on button press and\n   *     release.  See the section Mouse Tracking.\n   *     Ps = 1 0 0 1  -> Don't use Hilite Mouse Tracking.\n   *     Ps = 1 0 0 2  -> Don't use Cell Motion Mouse Tracking.\n   *     Ps = 1 0 0 3  -> Don't use All Motion Mouse Tracking.\n   *     Ps = 1 0 0 4  -> Don't send FocusIn/FocusOut events.\n   *     Ps = 1 0 0 5  -> Disable Extended Mouse Mode.\n   *     Ps = 1 0 1 0  -> Don't scroll to bottom on tty output\n   *     (rxvt).\n   *     Ps = 1 0 1 1  -> Don't scroll to bottom on key press (rxvt).\n   *     Ps = 1 0 3 4  -> Don't interpret \"meta\" key.  (This disables\n   *     the eightBitInput resource).\n   *     Ps = 1 0 3 5  -> Disable special modifiers for Alt and Num-\n   *     Lock keys.  (This disables the numLock resource).\n   *     Ps = 1 0 3 6  -> Don't send ESC  when Meta modifies a key.\n   *     (This disables the metaSendsEscape resource).\n   *     Ps = 1 0 3 7  -> Send VT220 Remove from the editing-keypad\n   *     Delete key.\n   *     Ps = 1 0 3 9  -> Don't send ESC  when Alt modifies a key.\n   *     (This disables the altSendsEscape resource).\n   *     Ps = 1 0 4 0  -> Do not keep selection when not highlighted.\n   *     (This disables the keepSelection resource).\n   *     Ps = 1 0 4 1  -> Use the PRIMARY selection.  (This disables\n   *     the selectToClipboard resource).\n   *     Ps = 1 0 4 2  -> Disable Urgency window manager hint when\n   *     Control-G is received.  (This disables the bellIsUrgent\n   *     resource).\n   *     Ps = 1 0 4 3  -> Disable raising of the window when Control-\n   *     G is received.  (This disables the popOnBell resource).\n   *     Ps = 1 0 4 7  -> Use Normal Screen Buffer, clearing screen\n   *     first if in the Alternate Screen.  (This may be disabled by\n   *     the titeInhibit resource).\n   *     Ps = 1 0 4 8  -> Restore cursor as in DECRC.  (This may be\n   *     disabled by the titeInhibit resource).\n   *     Ps = 1 0 4 9  -> Use Normal Screen Buffer and restore cursor\n   *     as in DECRC.  (This may be disabled by the titeInhibit\n   *     resource).  This combines the effects of the 1 0 4 7  and 1 0\n   *     4 8  modes.  Use this with terminfo-based applications rather\n   *     than the 4 7  mode.\n   *     Ps = 1 0 5 0  -> Reset terminfo/termcap function-key mode.\n   *     Ps = 1 0 5 1  -> Reset Sun function-key mode.\n   *     Ps = 1 0 5 2  -> Reset HP function-key mode.\n   *     Ps = 1 0 5 3  -> Reset SCO function-key mode.\n   *     Ps = 1 0 6 0  -> Reset legacy keyboard emulation (X11R6).\n   *     Ps = 1 0 6 1  -> Reset keyboard emulation to Sun/PC style.\n   *     Ps = 2 0 0 4  -> Reset bracketed paste mode.\n   */\n  public resetMode(params: IParams): void {\n    for (let i = 0; i < params.length; i++) {\n      switch (params.params[i]) {\n        case 4:\n          this._terminal.insertMode = false;\n          break;\n        case 20:\n          // this._t.convertEol = false;\n          break;\n      }\n    }\n  }\n  public resetModePrivate(params: IParams): void {\n    for (let i = 0; i < params.length; i++) {\n      switch (params.params[i]) {\n        case 1:\n          this._coreService.decPrivateModes.applicationCursorKeys = false;\n          break;\n        case 3:\n          // TODO: move DECCOLM into compat addon\n          // Note: This impl currently does not enforce col 80, instead reverts\n          // to previous terminal width before entering DECCOLM 132\n          if (this._bufferService.cols === 132 && this._terminal.savedCols) {\n            this._terminal.resize(this._terminal.savedCols, this._bufferService.rows);\n          }\n          delete this._terminal.savedCols;\n          this._terminal.reset();\n          break;\n        case 6:\n          this._terminal.originMode = false;\n          this._setCursor(0, 0);\n          break;\n        case 7:\n          this._terminal.wraparoundMode = false;\n          break;\n        case 12:\n          // this.cursorBlink = false;\n          break;\n        case 66:\n          this._logService.debug('Switching back to normal keypad.');\n          this._terminal.applicationKeypad = false;\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          break;\n        case 9: // X10 Mouse\n        case 1000: // vt200 mouse\n        case 1002: // button event mouse\n        case 1003: // any event mouse\n          this._coreMouseService.activeProtocol = 'NONE';\n          break;\n        case 1004: // send focusin/focusout events\n          this._terminal.sendFocus = false;\n          break;\n        case 1005: // utf8 ext mode mouse - removed in #2507\n          this._logService.debug('DECRST 1005 not supported (see #2507)');\n          break;\n        case 1006: // sgr ext mode mouse\n          this._coreMouseService.activeEncoding = 'DEFAULT';\n          break;\n        case 1015: // urxvt ext mode mouse - removed in #2507\n        this._logService.debug('DECRST 1015 not supported (see #2507)');\n          break;\n        case 25: // hide cursor\n          this._coreService.isCursorHidden = true;\n          break;\n        case 1048: // alt screen cursor\n          this.restoreCursor();\n          break;\n        case 1049: // alt screen buffer cursor\n           // FALL-THROUGH\n        case 47: // normal screen buffer\n        case 1047: // normal screen buffer - clearing it first\n          // Ensure the selection manager has the correct buffer\n          this._bufferService.buffers.activateNormalBuffer();\n          if (params.params[i] === 1049) {\n            this.restoreCursor();\n          }\n          this._terminal.refresh(0, this._bufferService.rows - 1);\n          if (this._terminal.viewport) {\n            this._terminal.viewport.syncScrollArea();\n          }\n          this._terminal.showCursor();\n          break;\n        case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)\n          this._terminal.bracketedPasteMode = false;\n          break;\n      }\n    }\n  }\n\n  /**\n   * Helper to extract and apply color params/subparams.\n   * Returns advance for params index.\n   */\n  private _extractColor(params: IParams, pos: number, attr: IAttributeData): number {\n    // normalize params\n    // meaning: [target, CM, ign, val, val, val]\n    // RGB    : [ 38/48,  2, ign,   r,   g,   b]\n    // P256   : [ 38/48,  5, ign,   v, ign, ign]\n    const accu = [0, 0, -1, 0, 0, 0];\n\n    // alignment placeholder for non color space sequences\n    let cSpace = 0;\n\n    // return advance we took in params\n    let advance = 0;\n\n    do {\n      accu[advance + cSpace] = params.params[pos + advance];\n      if (params.hasSubParams(pos + advance)) {\n        const subparams = params.getSubParams(pos + advance);\n        let i = 0;\n        do {\n          if (accu[1] === 5) {\n            cSpace = 1;\n          }\n          accu[advance + i + 1 + cSpace] = subparams[i];\n        } while (++i < subparams.length && i + advance + 1 + cSpace < accu.length);\n        break;\n      }\n      // exit early if can decide color mode with semicolons\n      if ((accu[1] === 5 && advance + cSpace >= 2)\n          || (accu[1] === 2 && advance + cSpace >= 5)) {\n        break;\n      }\n      // offset colorSpace slot for semicolon mode\n      if (accu[1]) {\n        cSpace = 1;\n      }\n    } while (++advance + pos < params.length && advance + cSpace < accu.length);\n\n    // set default values to 0\n    for (let i = 2; i < accu.length; ++i) {\n      if (accu[i] === -1) {\n        accu[i] = 0;\n      }\n    }\n\n    // apply colors\n    if (accu[0] === 38) {\n      if (accu[1] === 2) {\n        attr.fg |= Attributes.CM_RGB;\n        attr.fg &= ~Attributes.RGB_MASK;\n        attr.fg |= AttributeData.fromColorRGB([accu[3], accu[4], accu[5]]);\n      } else if (accu[1] === 5) {\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.fg |= Attributes.CM_P256 | (accu[3] & 0xff);\n      }\n    } else if (accu[0] === 48) {\n      if (accu[1] === 2) {\n        attr.bg |= Attributes.CM_RGB;\n        attr.bg &= ~Attributes.RGB_MASK;\n        attr.bg |= AttributeData.fromColorRGB([accu[3], accu[4], accu[5]]);\n      } else if (accu[1] === 5) {\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.bg |= Attributes.CM_P256 | (accu[3] & 0xff);\n      }\n    }\n\n    return advance;\n  }\n\n  /**\n   * CSI Pm m  Character Attributes (SGR).\n   *     Ps = 0  -> Normal (default).\n   *     Ps = 1  -> Bold.\n   *     Ps = 2  -> Faint, decreased intensity (ISO 6429).\n   *     Ps = 4  -> Underlined.\n   *     Ps = 5  -> Blink (appears as Bold).\n   *     Ps = 7  -> Inverse.\n   *     Ps = 8  -> Invisible, i.e., hidden (VT300).\n   *     Ps = 2 2  -> Normal (neither bold nor faint).\n   *     Ps = 2 4  -> Not underlined.\n   *     Ps = 2 5  -> Steady (not blinking).\n   *     Ps = 2 7  -> Positive (not inverse).\n   *     Ps = 2 8  -> Visible, i.e., not hidden (VT300).\n   *     Ps = 3 0  -> Set foreground color to Black.\n   *     Ps = 3 1  -> Set foreground color to Red.\n   *     Ps = 3 2  -> Set foreground color to Green.\n   *     Ps = 3 3  -> Set foreground color to Yellow.\n   *     Ps = 3 4  -> Set foreground color to Blue.\n   *     Ps = 3 5  -> Set foreground color to Magenta.\n   *     Ps = 3 6  -> Set foreground color to Cyan.\n   *     Ps = 3 7  -> Set foreground color to White.\n   *     Ps = 3 9  -> Set foreground color to default (original).\n   *     Ps = 4 0  -> Set background color to Black.\n   *     Ps = 4 1  -> Set background color to Red.\n   *     Ps = 4 2  -> Set background color to Green.\n   *     Ps = 4 3  -> Set background color to Yellow.\n   *     Ps = 4 4  -> Set background color to Blue.\n   *     Ps = 4 5  -> Set background color to Magenta.\n   *     Ps = 4 6  -> Set background color to Cyan.\n   *     Ps = 4 7  -> Set background color to White.\n   *     Ps = 4 9  -> Set background color to default (original).\n   *\n   *   If 16-color support is compiled, the following apply.  Assume\n   *   that xterm's resources are set so that the ISO color codes are\n   *   the first 8 of a set of 16.  Then the aixterm colors are the\n   *   bright versions of the ISO colors:\n   *     Ps = 9 0  -> Set foreground color to Black.\n   *     Ps = 9 1  -> Set foreground color to Red.\n   *     Ps = 9 2  -> Set foreground color to Green.\n   *     Ps = 9 3  -> Set foreground color to Yellow.\n   *     Ps = 9 4  -> Set foreground color to Blue.\n   *     Ps = 9 5  -> Set foreground color to Magenta.\n   *     Ps = 9 6  -> Set foreground color to Cyan.\n   *     Ps = 9 7  -> Set foreground color to White.\n   *     Ps = 1 0 0  -> Set background color to Black.\n   *     Ps = 1 0 1  -> Set background color to Red.\n   *     Ps = 1 0 2  -> Set background color to Green.\n   *     Ps = 1 0 3  -> Set background color to Yellow.\n   *     Ps = 1 0 4  -> Set background color to Blue.\n   *     Ps = 1 0 5  -> Set background color to Magenta.\n   *     Ps = 1 0 6  -> Set background color to Cyan.\n   *     Ps = 1 0 7  -> Set background color to White.\n   *\n   *   If xterm is compiled with the 16-color support disabled, it\n   *   supports the following, from rxvt:\n   *     Ps = 1 0 0  -> Set foreground and background color to\n   *     default.\n   *\n   *   If 88- or 256-color support is compiled, the following apply.\n   *     Ps = 3 8  ; 5  ; Ps -> Set foreground color to the second\n   *     Ps.\n   *     Ps = 4 8  ; 5  ; Ps -> Set background color to the second\n   *     Ps.\n   */\n  public charAttributes(params: IParams): void {\n    // Optimize a single SGR0.\n    if (params.length === 1 && params.params[0] === 0) {\n      this._terminal.curAttrData.fg = DEFAULT_ATTR_DATA.fg;\n      this._terminal.curAttrData.bg = DEFAULT_ATTR_DATA.bg;\n      return;\n    }\n\n    const l = params.length;\n    let p;\n    const attr = this._terminal.curAttrData;\n\n    for (let i = 0; i < l; i++) {\n      p = params.params[i];\n      if (p >= 30 && p <= 37) {\n        // fg color 8\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.fg |= Attributes.CM_P16 | (p - 30);\n      } else if (p >= 40 && p <= 47) {\n        // bg color 8\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.bg |= Attributes.CM_P16 | (p - 40);\n      } else if (p >= 90 && p <= 97) {\n        // fg color 16\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.fg |= Attributes.CM_P16 | (p - 90) | 8;\n      } else if (p >= 100 && p <= 107) {\n        // bg color 16\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK);\n        attr.bg |= Attributes.CM_P16 | (p - 100) | 8;\n      } else if (p === 0) {\n        // default\n        attr.fg = DEFAULT_ATTR_DATA.fg;\n        attr.bg = DEFAULT_ATTR_DATA.bg;\n      } else if (p === 1) {\n        // bold text\n        attr.fg |= FgFlags.BOLD;\n      } else if (p === 3) {\n        // italic text\n        attr.bg |= BgFlags.ITALIC;\n      } else if (p === 4) {\n        // underlined text\n        attr.fg |= FgFlags.UNDERLINE;\n      } else if (p === 5) {\n        // blink\n        attr.fg |= FgFlags.BLINK;\n      } else if (p === 7) {\n        // inverse and positive\n        // test with: echo -e '\\e[31m\\e[42mhello\\e[7mworld\\e[27mhi\\e[m'\n        attr.fg |= FgFlags.INVERSE;\n      } else if (p === 8) {\n        // invisible\n        attr.fg |= FgFlags.INVISIBLE;\n      } else if (p === 2) {\n        // dimmed text\n        attr.bg |= BgFlags.DIM;\n      } else if (p === 22) {\n        // not bold nor faint\n        attr.fg &= ~FgFlags.BOLD;\n        attr.bg &= ~BgFlags.DIM;\n      } else if (p === 23) {\n        // not italic\n        attr.bg &= ~BgFlags.ITALIC;\n      } else if (p === 24) {\n        // not underlined\n        attr.fg &= ~FgFlags.UNDERLINE;\n      } else if (p === 25) {\n        // not blink\n        attr.fg &= ~FgFlags.BLINK;\n      } else if (p === 27) {\n        // not inverse\n        attr.fg &= ~FgFlags.INVERSE;\n      } else if (p === 28) {\n        // not invisible\n        attr.fg &= ~FgFlags.INVISIBLE;\n      } else if (p === 39) {\n        // reset fg\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.fg |= DEFAULT_ATTR_DATA.fg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n      } else if (p === 49) {\n        // reset bg\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.bg |= DEFAULT_ATTR_DATA.bg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n      } else if (p === 38 || p === 48) {\n        // fg color 256 and RGB\n        i += this._extractColor(params, i, attr);\n      } else if (p === 100) {\n        // reset fg/bg\n        attr.fg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.fg |= DEFAULT_ATTR_DATA.fg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n        attr.bg &= ~(Attributes.CM_MASK | Attributes.RGB_MASK);\n        attr.bg |= DEFAULT_ATTR_DATA.bg & (Attributes.PCOLOR_MASK | Attributes.RGB_MASK);\n      } else {\n        this._logService.debug('Unknown SGR attribute: %d.', p);\n      }\n    }\n  }\n\n  /**\n   * CSI Ps n  Device Status Report (DSR).\n   *     Ps = 5  -> Status Report.  Result (``OK'') is\n   *   CSI 0 n\n   *     Ps = 6  -> Report Cursor Position (CPR) [row;column].\n   *   Result is\n   *   CSI r ; c R\n   * CSI ? Ps n\n   *   Device Status Report (DSR, DEC-specific).\n   *     Ps = 6  -> Report Cursor Position (CPR) [row;column] as CSI\n   *     ? r ; c R (assumes page is zero).\n   *     Ps = 1 5  -> Report Printer status as CSI ? 1 0  n  (ready).\n   *     or CSI ? 1 1  n  (not ready).\n   *     Ps = 2 5  -> Report UDK status as CSI ? 2 0  n  (unlocked)\n   *     or CSI ? 2 1  n  (locked).\n   *     Ps = 2 6  -> Report Keyboard status as\n   *   CSI ? 2 7  ;  1  ;  0  ;  0  n  (North American).\n   *   The last two parameters apply to VT400 & up, and denote key-\n   *   board ready and LK01 respectively.\n   *     Ps = 5 3  -> Report Locator status as\n   *   CSI ? 5 3  n  Locator available, if compiled-in, or\n   *   CSI ? 5 0  n  No Locator, if not.\n   */\n  public deviceStatus(params: IParams): void {\n    switch (params.params[0]) {\n      case 5:\n        // status report\n        this._coreService.triggerDataEvent(`${C0.ESC}[0n`);\n        break;\n      case 6:\n        // cursor position\n        const y = this._bufferService.buffer.y + 1;\n        const x = this._bufferService.buffer.x + 1;\n        this._coreService.triggerDataEvent(`${C0.ESC}[${y};${x}R`);\n        break;\n    }\n  }\n\n  public deviceStatusPrivate(params: IParams): void {\n    // modern xterm doesnt seem to\n    // respond to any of these except ?6, 6, and 5\n    switch (params.params[0]) {\n      case 6:\n        // cursor position\n        const y = this._bufferService.buffer.y + 1;\n        const x = this._bufferService.buffer.x + 1;\n        this._coreService.triggerDataEvent(`${C0.ESC}[?${y};${x}R`);\n        break;\n      case 15:\n        // no printer\n        // this.handler(C0.ESC + '[?11n');\n        break;\n      case 25:\n        // dont support user defined keys\n        // this.handler(C0.ESC + '[?21n');\n        break;\n      case 26:\n        // north american keyboard\n        // this.handler(C0.ESC + '[?27;1;0;0n');\n        break;\n      case 53:\n        // no dec locator/mouse\n        // this.handler(C0.ESC + '[?50n');\n        break;\n    }\n  }\n\n  /**\n   * CSI ! p   Soft terminal reset (DECSTR).\n   * http://vt100.net/docs/vt220-rm/table4-10.html\n   */\n  public softReset(params: IParams): void {\n    this._coreService.isCursorHidden = false;\n    this._terminal.insertMode = false;\n    this._terminal.originMode = false;\n    this._terminal.wraparoundMode = true;  // defaults: xterm - true, vt100 - false\n    this._terminal.applicationKeypad = false; // ?\n    if (this._terminal.viewport) {\n      this._terminal.viewport.syncScrollArea();\n    }\n    this._coreService.decPrivateModes.applicationCursorKeys = false;\n    this._bufferService.buffer.scrollTop = 0;\n    this._bufferService.buffer.scrollBottom = this._bufferService.rows - 1;\n    this._terminal.curAttrData = DEFAULT_ATTR_DATA.clone();\n    this._bufferService.buffer.x = this._bufferService.buffer.y = 0; // ?\n    this._terminal.charset = null;\n    this._terminal.glevel = 0; // ??\n    this._terminal.charsets = [null]; // ??\n  }\n\n  /**\n   * CSI Ps SP q  Set cursor style (DECSCUSR, VT520).\n   *   Ps = 0  -> blinking block.\n   *   Ps = 1  -> blinking block (default).\n   *   Ps = 2  -> steady block.\n   *   Ps = 3  -> blinking underline.\n   *   Ps = 4  -> steady underline.\n   *   Ps = 5  -> blinking bar (xterm).\n   *   Ps = 6  -> steady bar (xterm).\n   */\n  public setCursorStyle(params: IParams): void {\n    const param = params.params[0] || 1;\n    switch (param) {\n      case 1:\n      case 2:\n        this._optionsService.options.cursorStyle = 'block';\n        break;\n      case 3:\n      case 4:\n        this._optionsService.options.cursorStyle = 'underline';\n        break;\n      case 5:\n      case 6:\n        this._optionsService.options.cursorStyle = 'bar';\n        break;\n    }\n    const isBlinking = param % 2 === 1;\n    this._optionsService.options.cursorBlink = isBlinking;\n  }\n\n  /**\n   * CSI Ps ; Ps r\n   *   Set Scrolling Region [top;bottom] (default = full size of win-\n   *   dow) (DECSTBM).\n   */\n  public setScrollRegion(params: IParams): void {\n    const top = params.params[0] || 1;\n    let bottom: number;\n\n    if (params.length < 2 || (bottom = params.params[1]) >  this._bufferService.rows || bottom === 0) {\n      bottom = this._bufferService.rows;\n    }\n\n    if (bottom > top) {\n      this._bufferService.buffer.scrollTop = top - 1;\n      this._bufferService.buffer.scrollBottom = bottom - 1;\n      this._setCursor(0, 0);\n    }\n  }\n\n\n  /**\n   * CSI s\n   * ESC 7\n   *   Save cursor (ANSI.SYS).\n   */\n  public saveCursor(params?: IParams): void {\n    this._bufferService.buffer.savedX = this._bufferService.buffer.x;\n    this._bufferService.buffer.savedY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;\n    this._bufferService.buffer.savedCurAttrData.fg = this._terminal.curAttrData.fg;\n    this._bufferService.buffer.savedCurAttrData.bg = this._terminal.curAttrData.bg;\n    this._bufferService.buffer.savedCharset = this._terminal.charset;\n  }\n\n\n  /**\n   * CSI u\n   * ESC 8\n   *   Restore cursor (ANSI.SYS).\n   */\n  public restoreCursor(params?: IParams): void {\n    this._bufferService.buffer.x = this._bufferService.buffer.savedX || 0;\n    this._bufferService.buffer.y = Math.max(this._bufferService.buffer.savedY - this._bufferService.buffer.ybase, 0);\n    this._terminal.curAttrData.fg = this._bufferService.buffer.savedCurAttrData.fg;\n    this._terminal.curAttrData.bg = this._bufferService.buffer.savedCurAttrData.bg;\n    this._terminal.charset = (this as any)._savedCharset;\n    if (this._bufferService.buffer.savedCharset) {\n      this._terminal.charset = this._bufferService.buffer.savedCharset;\n    }\n    this._restrictCursor();\n  }\n\n\n  /**\n   * OSC 0; <data> ST (set icon name + window title)\n   * OSC 2; <data> ST (set window title)\n   *   Proxy to set window title. Icon name is not supported.\n   */\n  public setTitle(data: string): void {\n    this._terminal.handleTitle(data);\n  }\n\n  /**\n   * ESC E\n   * C1.NEL\n   *   DEC mnemonic: NEL (https://vt100.net/docs/vt510-rm/NEL)\n   *   Moves cursor to first position on next line.\n   */\n  public nextLine(): void {\n    this._bufferService.buffer.x = 0;\n    this.index();\n  }\n\n  /**\n   * ESC =\n   *   DEC mnemonic: DECKPAM (https://vt100.net/docs/vt510-rm/DECKPAM.html)\n   *   Enables the numeric keypad to send application sequences to the host.\n   */\n  public keypadApplicationMode(): void {\n    this._logService.debug('Serial port requested application keypad.');\n    this._terminal.applicationKeypad = true;\n    if (this._terminal.viewport) {\n      this._terminal.viewport.syncScrollArea();\n    }\n  }\n\n  /**\n   * ESC >\n   *   DEC mnemonic: DECKPNM (https://vt100.net/docs/vt510-rm/DECKPNM.html)\n   *   Enables the keypad to send numeric characters to the host.\n   */\n  public keypadNumericMode(): void {\n    this._logService.debug('Switching back to normal keypad.');\n    this._terminal.applicationKeypad = false;\n    if (this._terminal.viewport) {\n      this._terminal.viewport.syncScrollArea();\n    }\n  }\n\n  /**\n   * ESC % @\n   * ESC % G\n   *   Select default character set. UTF-8 is not supported (string are unicode anyways)\n   *   therefore ESC % G does the same.\n   */\n  public selectDefaultCharset(): void {\n    this._terminal.setgLevel(0);\n    this._terminal.setgCharset(0, DEFAULT_CHARSET); // US (default)\n  }\n\n  /**\n   * ESC ( C\n   *   Designate G0 Character Set, VT100, ISO 2022.\n   * ESC ) C\n   *   Designate G1 Character Set (ISO 2022, VT100).\n   * ESC * C\n   *   Designate G2 Character Set (ISO 2022, VT220).\n   * ESC + C\n   *   Designate G3 Character Set (ISO 2022, VT220).\n   * ESC - C\n   *   Designate G1 Character Set (VT300).\n   * ESC . C\n   *   Designate G2 Character Set (VT300).\n   * ESC / C\n   *   Designate G3 Character Set (VT300). C = A  -> ISO Latin-1 Supplemental. - Supported?\n   */\n  public selectCharset(collectAndFlag: string): void {\n    if (collectAndFlag.length !== 2) {\n      this.selectDefaultCharset();\n      return;\n    }\n    if (collectAndFlag[0] === '/') {\n      return;  // TODO: Is this supported?\n    }\n    this._terminal.setgCharset(GLEVEL[collectAndFlag[0]], CHARSETS[collectAndFlag[1]] || DEFAULT_CHARSET);\n    return;\n  }\n\n  /**\n   * ESC D\n   * C1.IND\n   *   DEC mnemonic: IND (https://vt100.net/docs/vt510-rm/IND.html)\n   *   Moves the cursor down one line in the same column.\n   */\n  public index(): void {\n    this._restrictCursor();\n    const buffer = this._bufferService.buffer;\n    this._bufferService.buffer.y++;\n    if (buffer.y === buffer.scrollBottom + 1) {\n      buffer.y--;\n      this._terminal.scroll();\n    } else if (buffer.y >= this._bufferService.rows) {\n      buffer.y = this._bufferService.rows - 1;\n    }\n    this._restrictCursor();\n  }\n\n  /**\n   * ESC H\n   * C1.HTS\n   *   DEC mnemonic: HTS (https://vt100.net/docs/vt510-rm/HTS.html)\n   *   Sets a horizontal tab stop at the column position indicated by\n   *   the value of the active column when the terminal receives an HTS.\n   */\n  public tabSet(): void {\n    this._bufferService.buffer.tabs[this._bufferService.buffer.x] = true;\n  }\n\n  /**\n   * ESC M\n   * C1.RI\n   *   DEC mnemonic: HTS\n   *   Moves the cursor up one line in the same column. If the cursor is at the top margin,\n   *   the page scrolls down.\n   */\n  public reverseIndex(): void {\n    this._restrictCursor();\n    const buffer = this._bufferService.buffer;\n    if (buffer.y === buffer.scrollTop) {\n      // possibly move the code below to term.reverseScroll();\n      // test: echo -ne '\\e[1;1H\\e[44m\\eM\\e[0m'\n      // blankLine(true) is xterm/linux behavior\n      const scrollRegionHeight = buffer.scrollBottom - buffer.scrollTop;\n      buffer.lines.shiftElements(buffer.y + buffer.ybase, scrollRegionHeight, 1);\n      buffer.lines.set(buffer.y + buffer.ybase, buffer.getBlankLine(this._terminal.eraseAttrData()));\n      this._dirtyRowService.markRangeDirty(buffer.scrollTop, buffer.scrollBottom);\n    } else {\n      buffer.y--;\n      this._restrictCursor(); // quickfix to not run out of bounds\n    }\n  }\n\n  /**\n   * ESC c\n   *   DEC mnemonic: RIS (https://vt100.net/docs/vt510-rm/RIS.html)\n   *   Reset to initial state.\n   */\n  public reset(): void {\n    this._parser.reset();\n    this._terminal.reset();  // TODO: save to move from terminal?\n  }\n\n  /**\n   * ESC n\n   * ESC o\n   * ESC |\n   * ESC }\n   * ESC ~\n   *   DEC mnemonic: LS (https://vt100.net/docs/vt510-rm/LS.html)\n   *   When you use a locking shift, the character set remains in GL or GR until\n   *   you use another locking shift. (partly supported)\n   */\n  public setgLevel(level: number): void {\n    this._terminal.setgLevel(level);  // TODO: save to move from terminal?\n  }\n\n  /**\n   * ESC # 8\n   *   DEC mnemonic: DECALN (https://vt100.net/docs/vt510-rm/DECALN.html)\n   *   This control function fills the complete screen area with\n   *   a test pattern (E) used for adjusting screen alignment.\n   *\n   * TODO: move DECALN into compat addon\n   */\n  public screenAlignmentPattern(): void {\n    // prepare cell data\n    const cell = new CellData();\n    cell.content = 1 << Content.WIDTH_SHIFT | 'E'.charCodeAt(0);\n    cell.fg = this._terminal.curAttrData.fg;\n    cell.bg = this._terminal.curAttrData.bg;\n\n    const buffer = this._bufferService.buffer;\n\n    this._setCursor(0, 0);\n    for (let yOffset = 0; yOffset < this._bufferService.rows; ++yOffset) {\n      const row = buffer.y + buffer.ybase + yOffset;\n      buffer.lines.get(row).fill(cell);\n      buffer.lines.get(row).isWrapped = false;\n    }\n    this._dirtyRowService.markAllDirty();\n    this._setCursor(0, 0);\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType } from 'common/parser/Types';\nimport { ParserState, ParserAction } from 'common/parser/Constants';\nimport { Disposable } from 'common/Lifecycle';\nimport { IDisposable } from 'common/Types';\nimport { fill } from 'common/TypedArrayUtils';\nimport { Params } from 'common/parser/Params';\nimport { OscParser } from 'common/parser/OscParser';\nimport { DcsParser } from 'common/parser/DcsParser';\n\n/**\n * Table values are generated like this:\n *    index:  currentState << TableValue.INDEX_STATE_SHIFT | charCode\n *    value:  action << TableValue.TRANSITION_ACTION_SHIFT | nextState\n */\nconst enum TableAccess {\n  TRANSITION_ACTION_SHIFT = 4,\n  TRANSITION_STATE_MASK = 15,\n  INDEX_STATE_SHIFT = 8\n}\n\n/**\n * Transition table for EscapeSequenceParser.\n */\nexport class TransitionTable {\n  public table: Uint8Array;\n\n  constructor(length: number) {\n    this.table = new Uint8Array(length);\n  }\n\n  /**\n   * Set default transition.\n   * @param action default action\n   * @param next default next state\n   */\n  public setDefault(action: ParserAction, next: ParserState): void {\n    fill(this.table, action << TableAccess.TRANSITION_ACTION_SHIFT | next);\n  }\n\n  /**\n   * Add a transition to the transition table.\n   * @param code input character code\n   * @param state current parser state\n   * @param action parser action to be done\n   * @param next next parser state\n   */\n  public add(code: number, state: ParserState, action: ParserAction, next: ParserState): void {\n    this.table[state << TableAccess.INDEX_STATE_SHIFT | code] = action << TableAccess.TRANSITION_ACTION_SHIFT | next;\n  }\n\n  /**\n   * Add transitions for multiple input character codes.\n   * @param codes input character code array\n   * @param state current parser state\n   * @param action parser action to be done\n   * @param next next parser state\n   */\n  public addMany(codes: number[], state: ParserState, action: ParserAction, next: ParserState): void {\n    for (let i = 0; i < codes.length; i++) {\n      this.table[state << TableAccess.INDEX_STATE_SHIFT | codes[i]] = action << TableAccess.TRANSITION_ACTION_SHIFT | next;\n    }\n  }\n}\n\n\n// Pseudo-character placeholder for printable non-ascii characters (unicode).\nconst NON_ASCII_PRINTABLE = 0xA0;\n\n\n/**\n * VT500 compatible transition table.\n * Taken from https://vt100.net/emu/dec_ansi_parser.\n */\nexport const VT500_TRANSITION_TABLE = (function (): TransitionTable {\n  const table: TransitionTable = new TransitionTable(4095);\n\n  // range macro for byte\n  const BYTE_VALUES = 256;\n  const blueprint = Array.apply(null, Array(BYTE_VALUES)).map((unused: any, i: number) => i);\n  const r = (start: number, end: number) => blueprint.slice(start, end);\n\n  // Default definitions.\n  const PRINTABLES = r(0x20, 0x7f); // 0x20 (SP) included, 0x7F (DEL) excluded\n  const EXECUTABLES = r(0x00, 0x18);\n  EXECUTABLES.push(0x19);\n  EXECUTABLES.push.apply(EXECUTABLES, r(0x1c, 0x20));\n\n  const states: number[] = r(ParserState.GROUND, ParserState.DCS_PASSTHROUGH + 1);\n  let state: any;\n\n  // set default transition\n  table.setDefault(ParserAction.ERROR, ParserState.GROUND);\n  // printables\n  table.addMany(PRINTABLES, ParserState.GROUND, ParserAction.PRINT, ParserState.GROUND);\n  // global anywhere rules\n  for (state in states) {\n    table.addMany([0x18, 0x1a, 0x99, 0x9a], state, ParserAction.EXECUTE, ParserState.GROUND);\n    table.addMany(r(0x80, 0x90), state, ParserAction.EXECUTE, ParserState.GROUND);\n    table.addMany(r(0x90, 0x98), state, ParserAction.EXECUTE, ParserState.GROUND);\n    table.add(0x9c, state, ParserAction.IGNORE, ParserState.GROUND); // ST as terminator\n    table.add(0x1b, state, ParserAction.CLEAR, ParserState.ESCAPE);  // ESC\n    table.add(0x9d, state, ParserAction.OSC_START, ParserState.OSC_STRING);  // OSC\n    table.addMany([0x98, 0x9e, 0x9f], state, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n    table.add(0x9b, state, ParserAction.CLEAR, ParserState.CSI_ENTRY);  // CSI\n    table.add(0x90, state, ParserAction.CLEAR, ParserState.DCS_ENTRY);  // DCS\n  }\n  // rules for executables and 7f\n  table.addMany(EXECUTABLES, ParserState.GROUND, ParserAction.EXECUTE, ParserState.GROUND);\n  table.addMany(EXECUTABLES, ParserState.ESCAPE, ParserAction.EXECUTE, ParserState.ESCAPE);\n  table.add(0x7f, ParserState.ESCAPE, ParserAction.IGNORE, ParserState.ESCAPE);\n  table.addMany(EXECUTABLES, ParserState.OSC_STRING, ParserAction.IGNORE, ParserState.OSC_STRING);\n  table.addMany(EXECUTABLES, ParserState.CSI_ENTRY, ParserAction.EXECUTE, ParserState.CSI_ENTRY);\n  table.add(0x7f, ParserState.CSI_ENTRY, ParserAction.IGNORE, ParserState.CSI_ENTRY);\n  table.addMany(EXECUTABLES, ParserState.CSI_PARAM, ParserAction.EXECUTE, ParserState.CSI_PARAM);\n  table.add(0x7f, ParserState.CSI_PARAM, ParserAction.IGNORE, ParserState.CSI_PARAM);\n  table.addMany(EXECUTABLES, ParserState.CSI_IGNORE, ParserAction.EXECUTE, ParserState.CSI_IGNORE);\n  table.addMany(EXECUTABLES, ParserState.CSI_INTERMEDIATE, ParserAction.EXECUTE, ParserState.CSI_INTERMEDIATE);\n  table.add(0x7f, ParserState.CSI_INTERMEDIATE, ParserAction.IGNORE, ParserState.CSI_INTERMEDIATE);\n  table.addMany(EXECUTABLES, ParserState.ESCAPE_INTERMEDIATE, ParserAction.EXECUTE, ParserState.ESCAPE_INTERMEDIATE);\n  table.add(0x7f, ParserState.ESCAPE_INTERMEDIATE, ParserAction.IGNORE, ParserState.ESCAPE_INTERMEDIATE);\n  // osc\n  table.add(0x5d, ParserState.ESCAPE, ParserAction.OSC_START, ParserState.OSC_STRING);\n  table.addMany(PRINTABLES, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);\n  table.add(0x7f, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);\n  table.addMany([0x9c, 0x1b, 0x18, 0x1a, 0x07], ParserState.OSC_STRING, ParserAction.OSC_END, ParserState.GROUND);\n  table.addMany(r(0x1c, 0x20), ParserState.OSC_STRING, ParserAction.IGNORE, ParserState.OSC_STRING);\n  // sos/pm/apc does nothing\n  table.addMany([0x58, 0x5e, 0x5f], ParserState.ESCAPE, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  table.addMany(PRINTABLES, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  table.addMany(EXECUTABLES, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  table.add(0x9c, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.GROUND);\n  table.add(0x7f, ParserState.SOS_PM_APC_STRING, ParserAction.IGNORE, ParserState.SOS_PM_APC_STRING);\n  // csi entries\n  table.add(0x5b, ParserState.ESCAPE, ParserAction.CLEAR, ParserState.CSI_ENTRY);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_ENTRY, ParserAction.CSI_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x30, 0x3c), ParserState.CSI_ENTRY, ParserAction.PARAM, ParserState.CSI_PARAM);\n  table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.CSI_ENTRY, ParserAction.COLLECT, ParserState.CSI_PARAM);\n  table.addMany(r(0x30, 0x3c), ParserState.CSI_PARAM, ParserAction.PARAM, ParserState.CSI_PARAM);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_PARAM, ParserAction.CSI_DISPATCH, ParserState.GROUND);\n  table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.CSI_PARAM, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x20, 0x40), ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.add(0x7f, ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.GROUND);\n  table.addMany(r(0x20, 0x30), ParserState.CSI_ENTRY, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);\n  table.addMany(r(0x20, 0x30), ParserState.CSI_INTERMEDIATE, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);\n  table.addMany(r(0x30, 0x40), ParserState.CSI_INTERMEDIATE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.addMany(r(0x40, 0x7f), ParserState.CSI_INTERMEDIATE, ParserAction.CSI_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x20, 0x30), ParserState.CSI_PARAM, ParserAction.COLLECT, ParserState.CSI_INTERMEDIATE);\n  // esc_intermediate\n  table.addMany(r(0x20, 0x30), ParserState.ESCAPE, ParserAction.COLLECT, ParserState.ESCAPE_INTERMEDIATE);\n  table.addMany(r(0x20, 0x30), ParserState.ESCAPE_INTERMEDIATE, ParserAction.COLLECT, ParserState.ESCAPE_INTERMEDIATE);\n  table.addMany(r(0x30, 0x7f), ParserState.ESCAPE_INTERMEDIATE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x30, 0x50), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x51, 0x58), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany([0x59, 0x5a, 0x5c], ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  table.addMany(r(0x60, 0x7f), ParserState.ESCAPE, ParserAction.ESC_DISPATCH, ParserState.GROUND);\n  // dcs entry\n  table.add(0x50, ParserState.ESCAPE, ParserAction.CLEAR, ParserState.DCS_ENTRY);\n  table.addMany(EXECUTABLES, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);\n  table.add(0x7f, ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_ENTRY, ParserAction.IGNORE, ParserState.DCS_ENTRY);\n  table.addMany(r(0x20, 0x30), ParserState.DCS_ENTRY, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x30, 0x3c), ParserState.DCS_ENTRY, ParserAction.PARAM, ParserState.DCS_PARAM);\n  table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.DCS_ENTRY, ParserAction.COLLECT, ParserState.DCS_PARAM);\n  table.addMany(EXECUTABLES, ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x20, 0x80), ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(EXECUTABLES, ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);\n  table.add(0x7f, ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_PARAM);\n  table.addMany(r(0x30, 0x3c), ParserState.DCS_PARAM, ParserAction.PARAM, ParserState.DCS_PARAM);\n  table.addMany([0x3c, 0x3d, 0x3e, 0x3f], ParserState.DCS_PARAM, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x20, 0x30), ParserState.DCS_PARAM, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);\n  table.addMany(EXECUTABLES, ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);\n  table.add(0x7f, ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x1c, 0x20), ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x20, 0x30), ParserState.DCS_INTERMEDIATE, ParserAction.COLLECT, ParserState.DCS_INTERMEDIATE);\n  table.addMany(r(0x30, 0x40), ParserState.DCS_INTERMEDIATE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.addMany(r(0x40, 0x7f), ParserState.DCS_INTERMEDIATE, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);\n  table.addMany(r(0x40, 0x7f), ParserState.DCS_PARAM, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);\n  table.addMany(r(0x40, 0x7f), ParserState.DCS_ENTRY, ParserAction.DCS_HOOK, ParserState.DCS_PASSTHROUGH);\n  table.addMany(EXECUTABLES, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);\n  table.addMany(PRINTABLES, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);\n  table.add(0x7f, ParserState.DCS_PASSTHROUGH, ParserAction.IGNORE, ParserState.DCS_PASSTHROUGH);\n  table.addMany([0x1b, 0x9c, 0x18, 0x1a], ParserState.DCS_PASSTHROUGH, ParserAction.DCS_UNHOOK, ParserState.GROUND);\n  // special handling of unicode chars\n  table.add(NON_ASCII_PRINTABLE, ParserState.GROUND, ParserAction.PRINT, ParserState.GROUND);\n  table.add(NON_ASCII_PRINTABLE, ParserState.OSC_STRING, ParserAction.OSC_PUT, ParserState.OSC_STRING);\n  table.add(NON_ASCII_PRINTABLE, ParserState.CSI_IGNORE, ParserAction.IGNORE, ParserState.CSI_IGNORE);\n  table.add(NON_ASCII_PRINTABLE, ParserState.DCS_IGNORE, ParserAction.IGNORE, ParserState.DCS_IGNORE);\n  table.add(NON_ASCII_PRINTABLE, ParserState.DCS_PASSTHROUGH, ParserAction.DCS_PUT, ParserState.DCS_PASSTHROUGH);\n  return table;\n})();\n\n\n/**\n * EscapeSequenceParser.\n * This class implements the ANSI/DEC compatible parser described by\n * Paul Williams (https://vt100.net/emu/dec_ansi_parser).\n *\n * To implement custom ANSI compliant escape sequences it is not needed to\n * alter this parser, instead consider registering a custom handler.\n * For non ANSI compliant sequences change the transition table with\n * the optional `transitions` constructor argument and\n * reimplement the `parse` method.\n *\n * This parser is currently hardcoded to operate in ZDM (Zero Default Mode)\n * as suggested by the original parser, thus empty parameters are set to 0.\n * This this is not in line with the latest ECMA-48 specification\n * (ZDM was part of the early specs and got completely removed later on).\n *\n * Other than the original parser from vt100.net this parser supports\n * sub parameters in digital parameters separated by colons. Empty sub parameters\n * are set to -1 (no ZDM for sub parameters).\n *\n * About prefix and intermediate bytes:\n * This parser follows the assumptions of the vt100.net parser with these restrictions:\n * - only one prefix byte is allowed as first parameter byte, byte range 0x3c .. 0x3f\n * - max. two intermediates are respected, byte range 0x20 .. 0x2f\n * Note that this is not in line with ECMA-48 which does not limit either of those.\n * Furthermore ECMA-48 allows the prefix byte range at any param byte position. Currently\n * there are no known sequences that follow the broader definition of the specification.\n *\n * TODO: implement error recovery hook via error handler return values\n */\nexport class EscapeSequenceParser extends Disposable implements IEscapeSequenceParser {\n  public initialState: number;\n  public currentState: number;\n  public precedingCodepoint: number;\n\n  // buffers over several parse calls\n  protected _params: Params;\n  protected _collect: number;\n\n  // handler lookup containers\n  protected _printHandler: PrintHandlerType;\n  protected _executeHandlers: {[flag: number]: ExecuteHandlerType};\n  protected _csiHandlers: IHandlerCollection<CsiHandlerType>;\n  protected _escHandlers: IHandlerCollection<EscHandlerType>;\n  protected _oscParser: IOscParser;\n  protected _dcsParser: IDcsParser;\n  protected _errorHandler: (state: IParsingState) => IParsingState;\n\n  // fallback handlers\n  protected _printHandlerFb: PrintFallbackHandlerType;\n  protected _executeHandlerFb: ExecuteFallbackHandlerType;\n  protected _csiHandlerFb: CsiFallbackHandlerType;\n  protected _escHandlerFb: EscFallbackHandlerType;\n  protected _errorHandlerFb: (state: IParsingState) => IParsingState;\n\n  constructor(readonly TRANSITIONS: TransitionTable = VT500_TRANSITION_TABLE) {\n    super();\n\n    this.initialState = ParserState.GROUND;\n    this.currentState = this.initialState;\n    this._params = new Params(); // defaults to 32 storable params/subparams\n    this._params.addParam(0);    // ZDM\n    this._collect = 0;\n    this.precedingCodepoint = 0;\n\n    // set default fallback handlers and handler lookup containers\n    this._printHandlerFb = (data, start, end): void => { };\n    this._executeHandlerFb = (code: number): void => { };\n    this._csiHandlerFb = (ident: number, params: IParams): void => { };\n    this._escHandlerFb = (ident: number): void => { };\n    this._errorHandlerFb = (state: IParsingState): IParsingState => state;\n    this._printHandler = this._printHandlerFb;\n    this._executeHandlers = Object.create(null);\n    this._csiHandlers = Object.create(null);\n    this._escHandlers = Object.create(null);\n    this._oscParser = new OscParser();\n    this._dcsParser = new DcsParser();\n    this._errorHandler = this._errorHandlerFb;\n\n    // swallow 7bit ST (ESC+\\)\n    this.setEscHandler({final: '\\\\'}, () => {});\n  }\n\n  protected _identifier(id: IFunctionIdentifier, finalRange: number[] = [0x40, 0x7e]): number {\n    let res = 0;\n    if (id.prefix) {\n      if (id.prefix.length > 1) {\n        throw new Error('only one byte as prefix supported');\n      }\n      res = id.prefix.charCodeAt(0);\n      if (res && 0x3c > res || res > 0x3f) {\n        throw new Error('prefix must be in range 0x3c .. 0x3f');\n      }\n    }\n    if (id.intermediates) {\n      if (id.intermediates.length > 2) {\n        throw new Error('only two bytes as intermediates are supported');\n      }\n      for (let i = 0; i < id.intermediates.length; ++i) {\n        const intermediate = id.intermediates.charCodeAt(i);\n        if (0x20 > intermediate || intermediate > 0x2f) {\n          throw new Error('intermediate must be in range 0x20 .. 0x2f');\n        }\n        res <<= 8;\n        res |= intermediate;\n      }\n    }\n    if (id.final.length !== 1) {\n      throw new Error('final must be a single byte');\n    }\n    const finalCode = id.final.charCodeAt(0);\n    if (finalRange[0] > finalCode || finalCode > finalRange[1]) {\n      throw new Error(`final must be in range ${finalRange[0]} .. ${finalRange[1]}`);\n    }\n    res <<= 8;\n    res |= finalCode;\n\n    return res;\n  }\n\n  public identToString(ident: number): string {\n    const res: string[] = [];\n    while (ident) {\n      res.push(String.fromCharCode(ident & 0xFF));\n      ident >>= 8;\n    }\n    return res.reverse().join('');\n  }\n\n  public dispose(): void {\n    this._csiHandlers = Object.create(null);\n    this._executeHandlers = Object.create(null);\n    this._escHandlers = Object.create(null);\n    this._oscParser.dispose();\n    this._dcsParser.dispose();\n  }\n\n  public setPrintHandler(handler: PrintHandlerType): void {\n    this._printHandler = handler;\n  }\n  public clearPrintHandler(): void {\n    this._printHandler = this._printHandlerFb;\n  }\n\n  public addEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): IDisposable {\n    const ident = this._identifier(id, [0x30, 0x7e]);\n    if (this._escHandlers[ident] === undefined) {\n      this._escHandlers[ident] = [];\n    }\n    const handlerList = this._escHandlers[ident];\n    handlerList.push(handler);\n    return {\n      dispose: () => {\n        const handlerIndex = handlerList.indexOf(handler);\n        if (handlerIndex !== -1) {\n          handlerList.splice(handlerIndex, 1);\n        }\n      }\n    };\n  }\n  public setEscHandler(id: IFunctionIdentifier, handler: EscHandlerType): void {\n    this._escHandlers[this._identifier(id, [0x30, 0x7e])] = [handler];\n  }\n  public clearEscHandler(id: IFunctionIdentifier): void {\n    if (this._escHandlers[this._identifier(id, [0x30, 0x7e])]) delete this._escHandlers[this._identifier(id, [0x30, 0x7e])];\n  }\n  public setEscHandlerFallback(handler: EscFallbackHandlerType): void {\n    this._escHandlerFb = handler;\n  }\n\n  public setExecuteHandler(flag: string, handler: ExecuteHandlerType): void {\n    this._executeHandlers[flag.charCodeAt(0)] = handler;\n  }\n  public clearExecuteHandler(flag: string): void {\n    if (this._executeHandlers[flag.charCodeAt(0)]) delete this._executeHandlers[flag.charCodeAt(0)];\n  }\n  public setExecuteHandlerFallback(handler: ExecuteFallbackHandlerType): void {\n    this._executeHandlerFb = handler;\n  }\n\n  public addCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): IDisposable {\n    const ident = this._identifier(id);\n    if (this._csiHandlers[ident] === undefined) {\n      this._csiHandlers[ident] = [];\n    }\n    const handlerList = this._csiHandlers[ident];\n    handlerList.push(handler);\n    return {\n      dispose: () => {\n        const handlerIndex = handlerList.indexOf(handler);\n        if (handlerIndex !== -1) {\n          handlerList.splice(handlerIndex, 1);\n        }\n      }\n    };\n  }\n  public setCsiHandler(id: IFunctionIdentifier, handler: CsiHandlerType): void {\n    this._csiHandlers[this._identifier(id)] = [handler];\n  }\n  public clearCsiHandler(id: IFunctionIdentifier): void {\n    if (this._csiHandlers[this._identifier(id)]) delete this._csiHandlers[this._identifier(id)];\n  }\n  public setCsiHandlerFallback(callback: (ident: number, params: IParams) => void): void {\n    this._csiHandlerFb = callback;\n  }\n\n  public addDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): IDisposable {\n    return this._dcsParser.addHandler(this._identifier(id), handler);\n  }\n  public setDcsHandler(id: IFunctionIdentifier, handler: IDcsHandler): void {\n    this._dcsParser.setHandler(this._identifier(id), handler);\n  }\n  public clearDcsHandler(id: IFunctionIdentifier): void {\n    this._dcsParser.clearHandler(this._identifier(id));\n  }\n  public setDcsHandlerFallback(handler: DcsFallbackHandlerType): void {\n    this._dcsParser.setHandlerFallback(handler);\n  }\n\n  public addOscHandler(ident: number, handler: IOscHandler): IDisposable {\n    return this._oscParser.addHandler(ident, handler);\n  }\n  public setOscHandler(ident: number, handler: IOscHandler): void {\n    this._oscParser.setHandler(ident, handler);\n  }\n  public clearOscHandler(ident: number): void {\n    this._oscParser.clearHandler(ident);\n  }\n  public setOscHandlerFallback(handler: OscFallbackHandlerType): void {\n    this._oscParser.setHandlerFallback(handler);\n  }\n\n  public setErrorHandler(callback: (state: IParsingState) => IParsingState): void {\n    this._errorHandler = callback;\n  }\n  public clearErrorHandler(): void {\n    this._errorHandler = this._errorHandlerFb;\n  }\n\n  public reset(): void {\n    this.currentState = this.initialState;\n    this._oscParser.reset();\n    this._dcsParser.reset();\n    this._params.reset();\n    this._params.addParam(0); // ZDM\n    this._collect = 0;\n    this.precedingCodepoint = 0;\n  }\n\n\n\n  /**\n   * Parse UTF32 codepoints in `data` up to `length`.\n   *\n   * Note: For several actions with high data load the parsing is optimized\n   * by using local read ahead loops with hardcoded conditions to\n   * avoid costly table lookups. Make sure that any change of table values\n   * will be reflected in the loop conditions as well and vice versa.\n   * Affected states/actions:\n   * - GROUND:PRINT\n   * - CSI_PARAM:PARAM\n   * - DCS_PARAM:PARAM\n   * - OSC_STRING:OSC_PUT\n   * - DCS_PASSTHROUGH:DCS_PUT\n   */\n  public parse(data: Uint32Array, length: number): void {\n    let code = 0;\n    let transition = 0;\n    let currentState = this.currentState;\n    const osc = this._oscParser;\n    const dcs = this._dcsParser;\n    let collect = this._collect;\n    const params = this._params;\n    const table: Uint8Array = this.TRANSITIONS.table;\n\n    // process input string\n    for (let i = 0; i < length; ++i) {\n      code = data[i];\n\n      // normal transition & action lookup\n      transition = table[currentState << TableAccess.INDEX_STATE_SHIFT | (code < 0xa0 ? code : NON_ASCII_PRINTABLE)];\n      switch (transition >> TableAccess.TRANSITION_ACTION_SHIFT) {\n        case ParserAction.PRINT:\n          // read ahead with loop unrolling\n          // Note: 0x20 (SP) is included, 0x7F (DEL) is excluded\n          for (let j = i + 1; ; ++j) {\n            if (j >= length || (code = data[j]) < 0x20 || (code > 0x7e && code < NON_ASCII_PRINTABLE)) {\n              this._printHandler(data, i, j);\n              i = j - 1;\n              break;\n            }\n            if (++j >= length || (code = data[j]) < 0x20 || (code > 0x7e && code < NON_ASCII_PRINTABLE)) {\n              this._printHandler(data, i, j);\n              i = j - 1;\n              break;\n            }\n            if (++j >= length || (code = data[j]) < 0x20 || (code > 0x7e && code < NON_ASCII_PRINTABLE)) {\n              this._printHandler(data, i, j);\n              i = j - 1;\n              break;\n            }\n            if (++j >= length || (code = data[j]) < 0x20 || (code > 0x7e && code < NON_ASCII_PRINTABLE)) {\n              this._printHandler(data, i, j);\n              i = j - 1;\n              break;\n            }\n          }\n          break;\n        case ParserAction.EXECUTE:\n          if (this._executeHandlers[code]) this._executeHandlers[code]();\n          else this._executeHandlerFb(code);\n          this.precedingCodepoint = 0;\n          break;\n        case ParserAction.IGNORE:\n          break;\n        case ParserAction.ERROR:\n          const inject: IParsingState = this._errorHandler(\n            {\n              position: i,\n              code,\n              currentState,\n              collect,\n              params,\n              abort: false\n            });\n          if (inject.abort) return;\n          // inject values: currently not implemented\n          break;\n        case ParserAction.CSI_DISPATCH:\n          // Trigger CSI Handler\n          const handlers = this._csiHandlers[collect << 8 | code];\n          let j = handlers ? handlers.length - 1 : -1;\n          for (; j >= 0; j--) {\n            // undefined or true means success and to stop bubbling\n            if (handlers[j](params) !== false) {\n              break;\n            }\n          }\n          if (j < 0) {\n            this._csiHandlerFb(collect << 8 | code, params);\n          }\n          this.precedingCodepoint = 0;\n          break;\n        case ParserAction.PARAM:\n          // inner loop: digits (0x30 - 0x39) and ; (0x3b) and : (0x3a)\n          do {\n            switch (code) {\n              case 0x3b:\n                params.addParam(0);  // ZDM\n                break;\n              case 0x3a:\n                params.addSubParam(-1);\n                break;\n              default:  // 0x30 - 0x39\n                params.addDigit(code - 48);\n            }\n          } while (++i < length && (code = data[i]) > 0x2f && code < 0x3c);\n          i--;\n          break;\n        case ParserAction.COLLECT:\n          collect <<= 8;\n          collect |= code;\n          break;\n        case ParserAction.ESC_DISPATCH:\n          const handlersEsc = this._escHandlers[collect << 8 | code];\n          let jj = handlersEsc ? handlersEsc.length - 1 : -1;\n          for (; jj >= 0; jj--) {\n            // undefined or true means success and to stop bubbling\n            if (handlersEsc[jj]() !== false) {\n              break;\n            }\n          }\n          if (jj < 0) {\n            this._escHandlerFb(collect << 8 | code);\n          }\n          this.precedingCodepoint = 0;\n          break;\n        case ParserAction.CLEAR:\n          params.reset();\n          params.addParam(0); // ZDM\n          collect = 0;\n          break;\n        case ParserAction.DCS_HOOK:\n          dcs.hook(collect << 8 | code, params);\n          break;\n        case ParserAction.DCS_PUT:\n          // inner loop - exit DCS_PUT: 0x18, 0x1a, 0x1b, 0x7f, 0x80 - 0x9f\n          // unhook triggered by: 0x1b, 0x9c (success) and 0x18, 0x1a (abort)\n          for (let j = i + 1; ; ++j) {\n            if (j >= length || (code = data[j]) === 0x18 || code === 0x1a || code === 0x1b || (code > 0x7f && code < NON_ASCII_PRINTABLE)) {\n              dcs.put(data, i, j);\n              i = j - 1;\n              break;\n            }\n          }\n          break;\n        case ParserAction.DCS_UNHOOK:\n          dcs.unhook(code !== 0x18 && code !== 0x1a);\n          if (code === 0x1b) transition |= ParserState.ESCAPE;\n          params.reset();\n          params.addParam(0); // ZDM\n          collect = 0;\n          this.precedingCodepoint = 0;\n          break;\n        case ParserAction.OSC_START:\n          osc.start();\n          break;\n        case ParserAction.OSC_PUT:\n          // inner loop: 0x20 (SP) included, 0x7F (DEL) included\n          for (let j = i + 1; ; j++) {\n            if (j >= length || (code = data[j]) < 0x20 || (code > 0x7f && code <= 0x9f)) {\n              osc.put(data, i, j);\n              i = j - 1;\n              break;\n            }\n          }\n          break;\n        case ParserAction.OSC_END:\n          osc.end(code !== 0x18 && code !== 0x1a);\n          if (code === 0x1b) transition |= ParserState.ESCAPE;\n          params.reset();\n          params.addParam(0); // ZDM\n          collect = 0;\n          this.precedingCodepoint = 0;\n          break;\n      }\n      currentState = transition & TableAccess.TRANSITION_STATE_MASK;\n    }\n\n    // save collected intermediates\n    this._collect = collect;\n\n    // save state\n    this.currentState = currentState;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { TextRenderLayer } from 'browser/renderer/TextRenderLayer';\nimport { SelectionRenderLayer } from 'browser/renderer/SelectionRenderLayer';\nimport { CursorRenderLayer } from 'browser/renderer/CursorRenderLayer';\nimport { IRenderLayer, IRenderer, IRenderDimensions, CharacterJoinerHandler, ICharacterJoinerRegistry, IRequestRefreshRowsEvent } from 'browser/renderer/Types';\nimport { LinkRenderLayer } from 'browser/renderer/LinkRenderLayer';\nimport { CharacterJoinerRegistry } from 'browser/renderer/CharacterJoinerRegistry';\nimport { Disposable } from 'common/Lifecycle';\nimport { IColorSet, ILinkifier } from 'browser/Types';\nimport { ICharSizeService, ICoreBrowserService } from 'browser/services/Services';\nimport { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';\nimport { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\n\nlet nextRendererId = 1;\n\nexport class Renderer extends Disposable implements IRenderer {\n  private _id = nextRendererId++;\n\n  private _renderLayers: IRenderLayer[];\n  private _devicePixelRatio: number;\n  private _characterJoinerRegistry: ICharacterJoinerRegistry;\n\n  public dimensions: IRenderDimensions;\n\n  private _onRequestRefreshRows = new EventEmitter<IRequestRefreshRowsEvent>();\n  public get onRequestRefreshRows(): IEvent<IRequestRefreshRowsEvent> { return this._onRequestRefreshRows.event; }\n\n  constructor(\n    private _colors: IColorSet,\n    private readonly _screenElement: HTMLElement,\n    private readonly _linkifier: ILinkifier,\n    @IBufferService private readonly _bufferService: IBufferService,\n    @ICharSizeService private readonly _charSizeService: ICharSizeService,\n    @IOptionsService private readonly _optionsService: IOptionsService,\n    @ICoreService readonly coreService: ICoreService,\n    @ICoreBrowserService readonly coreBrowserService: ICoreBrowserService\n  ) {\n    super();\n    const allowTransparency = this._optionsService.options.allowTransparency;\n    this._characterJoinerRegistry = new CharacterJoinerRegistry(this._bufferService);\n\n    this._renderLayers = [\n      new TextRenderLayer(this._screenElement, 0, this._colors, this._characterJoinerRegistry, allowTransparency, this._id, this._bufferService, _optionsService),\n      new SelectionRenderLayer(this._screenElement, 1, this._colors, this._id, this._bufferService, _optionsService),\n      new LinkRenderLayer(this._screenElement, 2, this._colors, this._id, this._linkifier, this._bufferService, _optionsService),\n      new CursorRenderLayer(this._screenElement, 3, this._colors, this._id, this._onRequestRefreshRows, this._bufferService, _optionsService, coreService, coreBrowserService)\n    ];\n    this.dimensions = {\n      scaledCharWidth: 0,\n      scaledCharHeight: 0,\n      scaledCellWidth: 0,\n      scaledCellHeight: 0,\n      scaledCharLeft: 0,\n      scaledCharTop: 0,\n      scaledCanvasWidth: 0,\n      scaledCanvasHeight: 0,\n      canvasWidth: 0,\n      canvasHeight: 0,\n      actualCellWidth: 0,\n      actualCellHeight: 0\n    };\n    this._devicePixelRatio = window.devicePixelRatio;\n    this._updateDimensions();\n    this.onOptionsChanged();\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._renderLayers.forEach(l => l.dispose());\n    removeTerminalFromCache(this._id);\n  }\n\n  public onDevicePixelRatioChange(): void {\n    // If the device pixel ratio changed, the char atlas needs to be regenerated\n    // and the terminal needs to refreshed\n    if (this._devicePixelRatio !== window.devicePixelRatio) {\n      this._devicePixelRatio = window.devicePixelRatio;\n      this.onResize(this._bufferService.cols, this._bufferService.rows);\n    }\n  }\n\n  public setColors(colors: IColorSet): void {\n    this._colors = colors;\n\n    // Clear layers and force a full render\n    this._renderLayers.forEach(l => {\n      l.setColors(this._colors);\n      l.reset();\n    });\n  }\n\n  public onResize(cols: number, rows: number): void {\n    // Update character and canvas dimensions\n    this._updateDimensions();\n\n    // Resize all render layers\n    this._renderLayers.forEach(l => l.resize(this.dimensions));\n\n    // Resize the screen\n    this._screenElement.style.width = `${this.dimensions.canvasWidth}px`;\n    this._screenElement.style.height = `${this.dimensions.canvasHeight}px`;\n  }\n\n  public onCharSizeChanged(): void {\n    this.onResize(this._bufferService.cols, this._bufferService.rows);\n  }\n\n  public onBlur(): void {\n    this._runOperation(l => l.onBlur());\n  }\n\n  public onFocus(): void {\n    this._runOperation(l => l.onFocus());\n  }\n\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean = false): void {\n    this._runOperation(l => l.onSelectionChanged(start, end, columnSelectMode));\n  }\n\n  public onCursorMove(): void {\n    this._runOperation(l => l.onCursorMove());\n  }\n\n  public onOptionsChanged(): void {\n    this._runOperation(l => l.onOptionsChanged());\n  }\n\n  public clear(): void {\n    this._runOperation(l => l.reset());\n  }\n\n  private _runOperation(operation: (layer: IRenderLayer) => void): void {\n    this._renderLayers.forEach(l => operation(l));\n  }\n\n  /**\n   * Performs the refresh loop callback, calling refresh only if a refresh is\n   * necessary before queueing up the next one.\n   */\n  public renderRows(start: number, end: number): void {\n    this._renderLayers.forEach(l => l.onGridChanged(start, end));\n  }\n\n  /**\n   * Recalculates the character and canvas dimensions.\n   */\n  private _updateDimensions(): void {\n    if (!this._charSizeService.hasValidSize) {\n      return;\n    }\n\n    // Calculate the scaled character width. Width is floored as it must be\n    // drawn to an integer grid in order for the CharAtlas \"stamps\" to not be\n    // blurry. When text is drawn to the grid not using the CharAtlas, it is\n    // clipped to ensure there is no overlap with the next cell.\n    this.dimensions.scaledCharWidth = Math.floor(this._charSizeService.width * window.devicePixelRatio);\n\n    // Calculate the scaled character height. Height is ceiled in case\n    // devicePixelRatio is a floating point number in order to ensure there is\n    // enough space to draw the character to the cell.\n    this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio);\n\n    // Calculate the scaled cell height, if lineHeight is not 1 then the value\n    // will be floored because since lineHeight can never be lower then 1, there\n    // is a guarentee that the scaled line height will always be larger than\n    // scaled char height.\n    this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.options.lineHeight);\n\n    // Calculate the y coordinate within a cell that text should draw from in\n    // order to draw in the center of a cell.\n    this.dimensions.scaledCharTop = this._optionsService.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);\n\n    // Calculate the scaled cell width, taking the letterSpacing into account.\n    this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.options.letterSpacing);\n\n    // Calculate the x coordinate with a cell that text should draw from in\n    // order to draw in the center of a cell.\n    this.dimensions.scaledCharLeft = Math.floor(this._optionsService.options.letterSpacing / 2);\n\n    // Recalculate the canvas dimensions; scaled* define the actual number of\n    // pixel in the canvas\n    this.dimensions.scaledCanvasHeight = this._bufferService.rows * this.dimensions.scaledCellHeight;\n    this.dimensions.scaledCanvasWidth = this._bufferService.cols * this.dimensions.scaledCellWidth;\n\n    // The the size of the canvas on the page. It's very important that this\n    // rounds to nearest integer and not ceils as browsers often set\n    // window.devicePixelRatio as something like 1.100000023841858, when it's\n    // actually 1.1. Ceiling causes blurriness as the backing canvas image is 1\n    // pixel too large for the canvas element size.\n    this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);\n    this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);\n\n    // Get the _actual_ dimensions of an individual cell. This needs to be\n    // derived from the canvasWidth/Height calculated above which takes into\n    // account window.devicePixelRatio. ICharSizeService.width/height by itself\n    // is insufficient when the page is not at 100% zoom level as it's measured\n    // in CSS pixels, but the actual char size on the canvas can differ.\n    this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows;\n    this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols;\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number {\n    return this._characterJoinerRegistry.registerCharacterJoiner(handler);\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): boolean {\n    return this._characterJoinerRegistry.deregisterCharacterJoiner(joinerId);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharacterJoinerRegistry, IRenderDimensions } from 'browser/renderer/Types';\nimport { CharData, ICellData } from 'common/Types';\nimport { GridCache } from 'browser/renderer/GridCache';\nimport { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';\nimport { AttributeData } from 'common/buffer/AttributeData';\nimport { NULL_CELL_CODE, Content } from 'common/buffer/Constants';\nimport { JoinedCellData } from 'browser/renderer/CharacterJoinerRegistry';\nimport { IColorSet } from 'browser/Types';\nimport { CellData } from 'common/buffer/CellData';\nimport { IOptionsService, IBufferService } from 'common/services/Services';\n\n/**\n * This CharData looks like a null character, which will forc a clear and render\n * when the character changes (a regular space ' ' character may not as it's\n * drawn state is a cleared cell).\n */\n// const OVERLAP_OWNED_CHAR_DATA: CharData = [null, '', 0, -1];\n\nexport class TextRenderLayer extends BaseRenderLayer {\n  private _state: GridCache<CharData>;\n  private _characterWidth: number = 0;\n  private _characterFont: string = '';\n  private _characterOverlapCache: { [key: string]: boolean } = {};\n  private _characterJoinerRegistry: ICharacterJoinerRegistry;\n  private _workCell = new CellData();\n\n  constructor(\n    container: HTMLElement,\n    zIndex: number,\n    colors: IColorSet,\n    characterJoinerRegistry: ICharacterJoinerRegistry,\n    alpha: boolean,\n    rendererId: number,\n    readonly bufferService: IBufferService,\n    readonly optionsService: IOptionsService\n  ) {\n    super(container, 'text', zIndex, alpha, colors, rendererId, bufferService, optionsService);\n    this._state = new GridCache<CharData>();\n    this._characterJoinerRegistry = characterJoinerRegistry;\n  }\n\n  public resize(dim: IRenderDimensions): void {\n    super.resize(dim);\n\n    // Clear the character width cache if the font or width has changed\n    const terminalFont = this._getFont(false, false);\n    if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {\n      this._characterWidth = dim.scaledCharWidth;\n      this._characterFont = terminalFont;\n      this._characterOverlapCache = {};\n    }\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._state.clear();\n    this._state.resize(this._bufferService.cols, this._bufferService.rows);\n  }\n\n  public reset(): void {\n    this._state.clear();\n    this._clearAll();\n  }\n\n  private _forEachCell(\n    firstRow: number,\n    lastRow: number,\n    joinerRegistry: ICharacterJoinerRegistry | null,\n    callback: (\n      cell: ICellData,\n      x: number,\n      y: number\n    ) => void\n  ): void {\n    for (let y = firstRow; y <= lastRow; y++) {\n      const row = y + this._bufferService.buffer.ydisp;\n      const line = this._bufferService.buffer.lines.get(row);\n      const joinedRanges = joinerRegistry ? joinerRegistry.getJoinedCharacters(row) : [];\n      for (let x = 0; x < this._bufferService.cols; x++) {\n        line!.loadCell(x, this._workCell);\n        let cell = this._workCell;\n\n        // If true, indicates that the current character(s) to draw were joined.\n        let isJoined = false;\n        let lastCharX = x;\n\n        // The character to the left is a wide character, drawing is owned by\n        // the char at x-1\n        if (cell.getWidth() === 0) {\n          continue;\n        }\n\n        // Process any joined character ranges as needed. Because of how the\n        // ranges are produced, we know that they are valid for the characters\n        // and attributes of our input.\n        if (joinedRanges.length > 0 && x === joinedRanges[0][0]) {\n          isJoined = true;\n          const range = joinedRanges.shift()!;\n\n          // We already know the exact start and end column of the joined range,\n          // so we get the string and width representing it directly\n\n          cell = new JoinedCellData(\n            this._workCell,\n            line!.translateToString(true, range[0], range[1]),\n            range[1] - range[0]\n          );\n\n          // Skip over the cells occupied by this range in the loop\n          lastCharX = range[1] - 1;\n        }\n\n        // If the character is an overlapping char and the character to the\n        // right is a space, take ownership of the cell to the right. We skip\n        // this check for joined characters because their rendering likely won't\n        // yield the same result as rendering the last character individually.\n        if (!isJoined && this._isOverlapping(cell)) {\n          // If the character is overlapping, we want to force a re-render on every\n          // frame. This is specifically to work around the case where two\n          // overlaping chars `a` and `b` are adjacent, the cursor is moved to b and a\n          // space is added. Without this, the first half of `b` would never\n          // get removed, and `a` would not re-render because it thinks it's\n          // already in the correct state.\n          // this._state.cache[x][y] = OVERLAP_OWNED_CHAR_DATA;\n          if (lastCharX < line!.length - 1 && line!.getCodePoint(lastCharX + 1) === NULL_CELL_CODE) {\n            // patch width to 2\n            cell.content &= ~Content.WIDTH_MASK;\n            cell.content |= 2 << Content.WIDTH_SHIFT;\n            // this._clearChar(x + 1, y);\n            // The overlapping char's char data will force a clear and render when the\n            // overlapping char is no longer to the left of the character and also when\n            // the space changes to another character.\n            // this._state.cache[x + 1][y] = OVERLAP_OWNED_CHAR_DATA;\n          }\n        }\n\n        callback(\n          cell,\n          x,\n          y\n        );\n\n        x = lastCharX;\n      }\n    }\n  }\n\n  /**\n   * Draws the background for a specified range of columns. Tries to batch adjacent cells of the\n   * same color together to reduce draw calls.\n   */\n  private _drawBackground(firstRow: number, lastRow: number): void {\n    const ctx = this._ctx;\n    const cols = this._bufferService.cols;\n    let startX: number = 0;\n    let startY: number = 0;\n    let prevFillStyle: string | null = null;\n\n    ctx.save();\n\n    this._forEachCell(firstRow, lastRow, null, (cell, x, y) => {\n      // libvte and xterm both draw the background (but not foreground) of invisible characters,\n      // so we should too.\n      let nextFillStyle = null; // null represents default background color\n\n      if (cell.isInverse()) {\n        if (cell.isFgDefault()) {\n          nextFillStyle = this._colors.foreground.css;\n        } else if (cell.isFgRGB()) {\n          nextFillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;\n        } else {\n          nextFillStyle = this._colors.ansi[cell.getFgColor()].css;\n        }\n      } else if (cell.isBgRGB()) {\n        nextFillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;\n      } else if (cell.isBgPalette()) {\n        nextFillStyle = this._colors.ansi[cell.getBgColor()].css;\n      }\n\n      if (prevFillStyle === null) {\n        // This is either the first iteration, or the default background was set. Either way, we\n        // don't need to draw anything.\n        startX = x;\n        startY = y;\n      }\n\n      if (y !== startY) {\n        // our row changed, draw the previous row\n        ctx.fillStyle = prevFillStyle ? prevFillStyle : '';\n        this._fillCells(startX, startY, cols - startX, 1);\n        startX = x;\n        startY = y;\n      } else if (prevFillStyle !== nextFillStyle) {\n        // our color changed, draw the previous characters in this row\n        ctx.fillStyle = prevFillStyle ? prevFillStyle : '';\n        this._fillCells(startX, startY, x - startX, 1);\n        startX = x;\n        startY = y;\n      }\n\n      prevFillStyle = nextFillStyle;\n    });\n\n    // flush the last color we encountered\n    if (prevFillStyle !== null) {\n      ctx.fillStyle = prevFillStyle;\n      this._fillCells(startX, startY, cols - startX, 1);\n    }\n\n    ctx.restore();\n  }\n\n  private _drawForeground(firstRow: number, lastRow: number): void {\n    this._forEachCell(firstRow, lastRow, this._characterJoinerRegistry, (cell, x, y) => {\n      if (cell.isInvisible()) {\n        return;\n      }\n      this._drawChars(cell, x, y);\n      if (cell.isUnderline()) {\n        this._ctx.save();\n\n        if (cell.isInverse()) {\n          if (cell.isBgDefault()) {\n            this._ctx.fillStyle = this._colors.background.css;\n          } else if (cell.isBgRGB()) {\n            this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;\n          } else {\n            let bg = cell.getBgColor();\n            if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && bg < 8) {\n              bg += 8;\n            }\n            this._ctx.fillStyle = this._colors.ansi[bg].css;\n          }\n        } else {\n          if (cell.isFgDefault()) {\n            this._ctx.fillStyle = this._colors.foreground.css;\n          } else if (cell.isFgRGB()) {\n            this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;\n          } else {\n            let fg = cell.getFgColor();\n            if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {\n              fg += 8;\n            }\n            this._ctx.fillStyle = this._colors.ansi[fg].css;\n          }\n        }\n\n        this._fillBottomLineAtCells(x, y, cell.getWidth());\n        this._ctx.restore();\n      }\n    });\n  }\n\n  public onGridChanged(firstRow: number, lastRow: number): void {\n    // Resize has not been called yet\n    if (this._state.cache.length === 0) {\n      return;\n    }\n\n    if (this._charAtlas) {\n      this._charAtlas.beginFrame();\n    }\n\n    this._clearCells(0, firstRow, this._bufferService.cols, lastRow - firstRow + 1);\n    this._drawBackground(firstRow, lastRow);\n    this._drawForeground(firstRow, lastRow);\n  }\n\n  public onOptionsChanged(): void {\n    this._setTransparency(this._optionsService.options.allowTransparency);\n  }\n\n  /**\n   * Whether a character is overlapping to the next cell.\n   */\n  private _isOverlapping(cell: ICellData): boolean {\n    // Only single cell characters can be overlapping, rendering issues can\n    // occur without this check\n    if (cell.getWidth() !== 1) {\n      return false;\n    }\n\n    // We assume that any ascii character will not overlap\n    if (cell.getCode() < 256) {\n      return false;\n    }\n\n    const chars = cell.getChars();\n\n    // Deliver from cache if available\n    if (this._characterOverlapCache.hasOwnProperty(chars)) {\n      return this._characterOverlapCache[chars];\n    }\n\n    // Setup the font\n    this._ctx.save();\n    this._ctx.font = this._characterFont;\n\n    // Measure the width of the character, but Math.floor it\n    // because that is what the renderer does when it calculates\n    // the character dimensions we are comparing against\n    const overlaps = Math.floor(this._ctx.measureText(chars).width) > this._characterWidth;\n\n    // Restore the original context\n    this._ctx.restore();\n\n    // Cache and return\n    this._characterOverlapCache[chars] = overlaps;\n    return overlaps;\n  }\n\n  /**\n   * Clear the charcater at the cell specified.\n   * @param x The column of the char.\n   * @param y The row of the char.\n   */\n  // private _clearChar(x: number, y: number): void {\n  //   let colsToClear = 1;\n  //   // Clear the adjacent character if it was wide\n  //   const state = this._state.cache[x][y];\n  //   if (state && state[CHAR_DATA_WIDTH_INDEX] === 2) {\n  //     colsToClear = 2;\n  //   }\n  //   this.clearCells(x, y, colsToClear, 1);\n  // }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nexport class GridCache<T> {\n  public cache: (T | undefined)[][];\n\n  public constructor() {\n    this.cache = [];\n  }\n\n  public resize(width: number, height: number): void {\n    for (let x = 0; x < width; x++) {\n      if (this.cache.length <= x) {\n        this.cache.push([]);\n      }\n      for (let y = this.cache[x].length; y < height; y++) {\n        this.cache[x].push(undefined);\n      }\n      this.cache[x].length = height;\n    }\n    this.cache.length = width;\n  }\n\n  public clear(): void {\n    for (let x = 0; x < this.cache.length; x++) {\n      for (let y = 0; y < this.cache[x].length; y++) {\n        this.cache[x][y] = undefined;\n      }\n    }\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { DIM_OPACITY, INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';\nimport { IGlyphIdentifier, ICharAtlasConfig } from 'browser/renderer/atlas/Types';\nimport { BaseCharAtlas } from 'browser/renderer/atlas/BaseCharAtlas';\nimport { DEFAULT_ANSI_COLORS } from 'browser/ColorManager';\nimport { LRUMap } from 'browser/renderer/atlas/LRUMap';\nimport { isFirefox, isSafari } from 'common/Platform';\nimport { IColor } from 'browser/Types';\nimport { throwIfFalsy } from 'browser/renderer/RendererUtils';\nimport { opaque } from 'browser/Color';\n\n// In practice we're probably never going to exhaust a texture this large. For debugging purposes,\n// however, it can be useful to set this to a really tiny value, to verify that LRU eviction works.\nconst TEXTURE_WIDTH = 1024;\nconst TEXTURE_HEIGHT = 1024;\n\nconst TRANSPARENT_COLOR = {\n  css: 'rgba(0, 0, 0, 0)',\n  rgba: 0\n};\n\n// Drawing to the cache is expensive: If we have to draw more than this number of glyphs to the\n// cache in a single frame, give up on trying to cache anything else, and try to finish the current\n// frame ASAP.\n//\n// This helps to limit the amount of damage a program can do when it would otherwise thrash the\n// cache.\nconst FRAME_CACHE_DRAW_LIMIT = 100;\n\n/**\n * The number of milliseconds to wait before generating the ImageBitmap, this is to debounce/batch\n * the operation as window.createImageBitmap is asynchronous.\n */\nconst GLYPH_BITMAP_COMMIT_DELAY = 100;\n\ninterface IGlyphCacheValue {\n  index: number;\n  isEmpty: boolean;\n  inBitmap: boolean;\n}\n\nexport function getGlyphCacheKey(glyph: IGlyphIdentifier): number {\n  // Note that this only returns a valid key when code < 256\n  // Layout:\n  // 0b00000000000000000000000000000001: italic (1)\n  // 0b00000000000000000000000000000010: dim (1)\n  // 0b00000000000000000000000000000100: bold (1)\n  // 0b00000000000000000000111111111000: fg (9)\n  // 0b00000000000111111111000000000000: bg (9)\n  // 0b00011111111000000000000000000000: code (8)\n  // 0b11100000000000000000000000000000: unused (3)\n  return glyph.code << 21 | glyph.bg << 12 | glyph.fg << 3 | (glyph.bold ? 0 : 4) + (glyph.dim ? 0 : 2) + (glyph.italic ? 0 : 1);\n}\n\nexport class DynamicCharAtlas extends BaseCharAtlas {\n  // An ordered map that we're using to keep track of where each glyph is in the atlas texture.\n  // It's ordered so that we can determine when to remove the old entries.\n  private _cacheMap: LRUMap<IGlyphCacheValue>;\n\n  // The texture that the atlas is drawn to\n  private _cacheCanvas: HTMLCanvasElement;\n  private _cacheCtx: CanvasRenderingContext2D;\n\n  // A temporary context that glyphs are drawn to before being transfered to the atlas.\n  private _tmpCtx: CanvasRenderingContext2D;\n\n  // The number of characters stored in the atlas by width/height\n  private _width: number;\n  private _height: number;\n\n  private _drawToCacheCount: number = 0;\n\n  // An array of glyph keys that are waiting on the bitmap to be generated.\n  private _glyphsWaitingOnBitmap: IGlyphCacheValue[] = [];\n\n  // The timeout that is used to batch bitmap generation so it's not requested for every new glyph.\n  private _bitmapCommitTimeout: number | null = null;\n\n  // The bitmap to draw from, this is much faster on other browsers than others.\n  private _bitmap: ImageBitmap | null = null;\n\n  constructor(document: Document, private _config: ICharAtlasConfig) {\n    super();\n    this._cacheCanvas = document.createElement('canvas');\n    this._cacheCanvas.width = TEXTURE_WIDTH;\n    this._cacheCanvas.height = TEXTURE_HEIGHT;\n    // The canvas needs alpha because we use clearColor to convert the background color to alpha.\n    // It might also contain some characters with transparent backgrounds if allowTransparency is\n    // set.\n    this._cacheCtx = throwIfFalsy(this._cacheCanvas.getContext('2d', {alpha: true}));\n\n    const tmpCanvas = document.createElement('canvas');\n    tmpCanvas.width = this._config.scaledCharWidth;\n    tmpCanvas.height = this._config.scaledCharHeight;\n    this._tmpCtx = throwIfFalsy(tmpCanvas.getContext('2d', {alpha: this._config.allowTransparency}));\n\n    this._width = Math.floor(TEXTURE_WIDTH / this._config.scaledCharWidth);\n    this._height = Math.floor(TEXTURE_HEIGHT / this._config.scaledCharHeight);\n    const capacity = this._width * this._height;\n    this._cacheMap = new LRUMap(capacity);\n    this._cacheMap.prealloc(capacity);\n\n    // This is useful for debugging\n    // document.body.appendChild(this._cacheCanvas);\n  }\n\n  public dispose(): void {\n    if (this._bitmapCommitTimeout !== null) {\n      window.clearTimeout(this._bitmapCommitTimeout);\n      this._bitmapCommitTimeout = null;\n    }\n  }\n\n  public beginFrame(): void {\n    this._drawToCacheCount = 0;\n  }\n\n  public draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean {\n    // Space is always an empty cell, special case this as it's so common\n    if (glyph.code === 32) {\n      return true;\n    }\n\n    // Exit early for uncachable glyphs\n    if (!this._canCache(glyph)) {\n      return false;\n    }\n\n    const glyphKey = getGlyphCacheKey(glyph);\n    const cacheValue = this._cacheMap.get(glyphKey);\n    if (cacheValue !== null && cacheValue !== undefined) {\n      this._drawFromCache(ctx, cacheValue, x, y);\n      return true;\n    } else if (this._drawToCacheCount < FRAME_CACHE_DRAW_LIMIT) {\n      let index;\n      if (this._cacheMap.size < this._cacheMap.capacity) {\n        index = this._cacheMap.size;\n      } else {\n        // we're out of space, so our call to set will delete this item\n        index = this._cacheMap.peek()!.index;\n      }\n      const cacheValue = this._drawToCache(glyph, index);\n      this._cacheMap.set(glyphKey, cacheValue);\n      this._drawFromCache(ctx, cacheValue, x, y);\n      return true;\n    }\n    return false;\n  }\n\n  private _canCache(glyph: IGlyphIdentifier): boolean {\n    // Only cache ascii and extended characters for now, to be safe. In the future, we could do\n    // something more complicated to determine the expected width of a character.\n    //\n    // If we switch the renderer over to webgl at some point, we may be able to use blending modes\n    // to draw overlapping glyphs from the atlas:\n    // https://github.com/servo/webrender/issues/464#issuecomment-255632875\n    // https://webglfundamentals.org/webgl/lessons/webgl-text-texture.html\n    return glyph.code < 256;\n  }\n\n  private _toCoordinateX(index: number): number {\n    return (index % this._width) * this._config.scaledCharWidth;\n  }\n\n  private _toCoordinateY(index: number): number {\n    return Math.floor(index / this._width) * this._config.scaledCharHeight;\n  }\n\n  private _drawFromCache(\n    ctx: CanvasRenderingContext2D,\n    cacheValue: IGlyphCacheValue,\n    x: number,\n    y: number\n  ): void {\n    // We don't actually need to do anything if this is whitespace.\n    if (cacheValue.isEmpty) {\n      return;\n    }\n    const cacheX = this._toCoordinateX(cacheValue.index);\n    const cacheY = this._toCoordinateY(cacheValue.index);\n    ctx.drawImage(\n      cacheValue.inBitmap ? this._bitmap! : this._cacheCanvas,\n      cacheX,\n      cacheY,\n      this._config.scaledCharWidth,\n      this._config.scaledCharHeight,\n      x,\n      y,\n      this._config.scaledCharWidth,\n      this._config.scaledCharHeight\n    );\n  }\n\n  private _getColorFromAnsiIndex(idx: number): IColor {\n    if (idx < this._config.colors.ansi.length) {\n      return this._config.colors.ansi[idx];\n    }\n    return DEFAULT_ANSI_COLORS[idx];\n  }\n\n  private _getBackgroundColor(glyph: IGlyphIdentifier): IColor {\n    if (this._config.allowTransparency) {\n      // The background color might have some transparency, so we need to render it as fully\n      // transparent in the atlas. Otherwise we'd end up drawing the transparent background twice\n      // around the anti-aliased edges of the glyph, and it would look too dark.\n      return TRANSPARENT_COLOR;\n    } else if (glyph.bg === INVERTED_DEFAULT_COLOR) {\n      return this._config.colors.foreground;\n    } else if (glyph.bg < 256) {\n      return this._getColorFromAnsiIndex(glyph.bg);\n    }\n    return this._config.colors.background;\n  }\n\n  private _getForegroundColor(glyph: IGlyphIdentifier): IColor {\n    if (glyph.fg === INVERTED_DEFAULT_COLOR) {\n      return opaque(this._config.colors.background);\n    } else if (glyph.fg < 256) {\n      // 256 color support\n      return this._getColorFromAnsiIndex(glyph.fg);\n    }\n    return this._config.colors.foreground;\n  }\n\n  // TODO: We do this (or something similar) in multiple places. We should split this off\n  // into a shared function.\n  private _drawToCache(glyph: IGlyphIdentifier, index: number): IGlyphCacheValue {\n    this._drawToCacheCount++;\n\n    this._tmpCtx.save();\n\n    // draw the background\n    const backgroundColor = this._getBackgroundColor(glyph);\n    // Use a 'copy' composite operation to clear any existing glyph out of _tmpCtxWithAlpha, regardless of\n    // transparency in backgroundColor\n    this._tmpCtx.globalCompositeOperation = 'copy';\n    this._tmpCtx.fillStyle = backgroundColor.css;\n    this._tmpCtx.fillRect(0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight);\n    this._tmpCtx.globalCompositeOperation = 'source-over';\n\n    // draw the foreground/glyph\n    const fontWeight = glyph.bold ? this._config.fontWeightBold : this._config.fontWeight;\n    const fontStyle = glyph.italic ? 'italic' : '';\n    this._tmpCtx.font =\n      `${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`;\n    this._tmpCtx.textBaseline = 'middle';\n\n    this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css;\n\n    // Apply alpha to dim the character\n    if (glyph.dim) {\n      this._tmpCtx.globalAlpha = DIM_OPACITY;\n    }\n    // Draw the character\n    this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2);\n    this._tmpCtx.restore();\n\n    // clear the background from the character to avoid issues with drawing over the previous\n    // character if it extends past it's bounds\n    const imageData = this._tmpCtx.getImageData(\n      0, 0, this._config.scaledCharWidth, this._config.scaledCharHeight\n    );\n    let isEmpty = false;\n    if (!this._config.allowTransparency) {\n      isEmpty = clearColor(imageData, backgroundColor);\n    }\n\n    // copy the data from imageData to _cacheCanvas\n    const x = this._toCoordinateX(index);\n    const y = this._toCoordinateY(index);\n    // putImageData doesn't do any blending, so it will overwrite any existing cache entry for us\n    this._cacheCtx.putImageData(imageData, x, y);\n\n    // Add the glyph and queue it to the bitmap (if the browser supports it)\n    const cacheValue = {\n      index,\n      isEmpty,\n      inBitmap: false\n    };\n    this._addGlyphToBitmap(cacheValue);\n\n    return cacheValue;\n  }\n\n  private _addGlyphToBitmap(cacheValue: IGlyphCacheValue): void {\n    // Support is patchy for createImageBitmap at the moment, pass a canvas back\n    // if support is lacking as drawImage works there too. Firefox is also\n    // included here as ImageBitmap appears both buggy and has horrible\n    // performance (tested on v55).\n    if (!('createImageBitmap' in window) || isFirefox || isSafari) {\n      return;\n    }\n\n    // Add the glyph to the queue\n    this._glyphsWaitingOnBitmap.push(cacheValue);\n\n    // Check if bitmap generation timeout already exists\n    if (this._bitmapCommitTimeout !== null) {\n      return;\n    }\n\n    this._bitmapCommitTimeout = window.setTimeout(() => this._generateBitmap(), GLYPH_BITMAP_COMMIT_DELAY);\n  }\n\n  private _generateBitmap(): void {\n    const glyphsMovingToBitmap = this._glyphsWaitingOnBitmap;\n    this._glyphsWaitingOnBitmap = [];\n    window.createImageBitmap(this._cacheCanvas).then(bitmap => {\n      // Set bitmap\n      this._bitmap = bitmap;\n\n      // Mark all new glyphs as in bitmap, excluding glyphs that came in after\n      // the bitmap was requested\n      for (let i = 0; i < glyphsMovingToBitmap.length; i++) {\n        const value = glyphsMovingToBitmap[i];\n        // It doesn't matter if the value was already evicted, it will be\n        // released from memory after this block if so.\n        value.inBitmap = true;\n      }\n    });\n    this._bitmapCommitTimeout = null;\n  }\n}\n\n// This is used for debugging the renderer, just swap out `new DynamicCharAtlas` with\n// `new NoneCharAtlas`.\nexport class NoneCharAtlas extends BaseCharAtlas {\n  constructor(document: Document, config: ICharAtlasConfig) {\n    super();\n  }\n\n  public draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean {\n    return false;\n  }\n}\n\n/**\n * Makes a partiicular rgb color in an ImageData completely transparent.\n * @returns True if the result is \"empty\", meaning all pixels are fully transparent.\n */\nfunction clearColor(imageData: ImageData, color: IColor): boolean {\n  let isEmpty = true;\n  const r = color.rgba >>> 24;\n  const g = color.rgba >>> 16 & 0xFF;\n  const b = color.rgba >>> 8 & 0xFF;\n  for (let offset = 0; offset < imageData.data.length; offset += 4) {\n    if (imageData.data[offset] === r &&\n        imageData.data[offset + 1] === g &&\n        imageData.data[offset + 2] === b) {\n      imageData.data[offset + 3] = 0;\n    } else {\n      isEmpty = false;\n    }\n  }\n  return isEmpty;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IGlyphIdentifier } from 'browser/renderer/atlas/Types';\nimport { IDisposable } from 'common/Types';\n\nexport abstract class BaseCharAtlas implements IDisposable {\n  private _didWarmUp: boolean = false;\n\n  public dispose(): void { }\n\n  /**\n   * Perform any work needed to warm the cache before it can be used. May be called multiple times.\n   * Implement _doWarmUp instead if you only want to get called once.\n   */\n  public warmUp(): void {\n    if (!this._didWarmUp) {\n      this._doWarmUp();\n      this._didWarmUp = true;\n    }\n  }\n\n  /**\n   * Perform any work needed to warm the cache before it can be used. Used by the default\n   * implementation of warmUp(), and will only be called once.\n   */\n  protected _doWarmUp(): void { }\n\n  /**\n   * Called when we start drawing a new frame.\n   *\n   * TODO: We rely on this getting called by TextRenderLayer. This should really be called by\n   * Renderer instead, but we need to make Renderer the source-of-truth for the char atlas, instead\n   * of BaseRenderLayer.\n   */\n  public beginFrame(): void { }\n\n  /**\n   * May be called before warmUp finishes, however it is okay for the implementation to\n   * do nothing and return false in that case.\n   *\n   * @param ctx Where to draw the character onto.\n   * @param glyph Information about what to draw\n   * @param x The position on the context to start drawing at\n   * @param y The position on the context to start drawing at\n   * @returns The success state. True if we drew the character.\n   */\n  public abstract draw(\n    ctx: CanvasRenderingContext2D,\n    glyph: IGlyphIdentifier,\n    x: number,\n    y: number\n  ): boolean;\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IColor, IColorContrastCache } from 'browser/Types';\n\nexport class ColorContrastCache implements IColorContrastCache {\n  private _color: { [bg: number]: { [fg: number]: IColor | null | undefined } | undefined } = {};\n  private _rgba: { [bg: number]: { [fg: number]: string | null | undefined } | undefined } = {};\n\n  public clear(): void {\n    this._color = {};\n    this._rgba = {};\n  }\n\n  public setCss(bg: number, fg: number, value: string | null): void {\n    if (!this._rgba[bg]) {\n      this._rgba[bg] = {};\n    }\n    this._rgba[bg]![fg] = value;\n  }\n\n  public getCss(bg: number, fg: number): string | null | undefined {\n    return this._rgba[bg] ? this._rgba[bg]![fg] : undefined;\n  }\n\n  public setColor(bg: number, fg: number, value: IColor | null): void {\n    if (!this._color[bg]) {\n      this._color[bg] = {};\n    }\n    this._color[bg]![fg] = value;\n  }\n\n  public getColor(bg: number, fg: number): IColor | null | undefined {\n    return this._color[bg] ? this._color[bg]![fg] : undefined;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\ninterface ILinkedListNode<T> {\n  prev: ILinkedListNode<T> | null;\n  next: ILinkedListNode<T> | null;\n  key: number | null;\n  value: T | null;\n}\n\nexport class LRUMap<T> {\n  private _map: { [key: number]: ILinkedListNode<T> } = {};\n  private _head: ILinkedListNode<T> | null = null;\n  private _tail: ILinkedListNode<T> | null = null;\n  private _nodePool: ILinkedListNode<T>[] = [];\n  public size: number = 0;\n\n  constructor(public capacity: number) { }\n\n  private _unlinkNode(node: ILinkedListNode<T>): void {\n    const prev = node.prev;\n    const next = node.next;\n    if (node === this._head) {\n      this._head = next;\n    }\n    if (node === this._tail) {\n      this._tail = prev;\n    }\n    if (prev !== null) {\n      prev.next = next;\n    }\n    if (next !== null) {\n      next.prev = prev;\n    }\n  }\n\n  private _appendNode(node: ILinkedListNode<T>): void {\n    const tail = this._tail;\n    if (tail !== null) {\n      tail.next = node;\n    }\n    node.prev = tail;\n    node.next = null;\n    this._tail = node;\n    if (this._head === null) {\n      this._head = node;\n    }\n  }\n\n  /**\n   * Preallocate a bunch of linked-list nodes. Allocating these nodes ahead of time means that\n   * they're more likely to live next to each other in memory, which seems to improve performance.\n   *\n   * Each empty object only consumes about 60 bytes of memory, so this is pretty cheap, even for\n   * large maps.\n   */\n  public prealloc(count: number): void {\n    const nodePool = this._nodePool;\n    for (let i = 0; i < count; i++) {\n      nodePool.push({\n        prev: null,\n        next: null,\n        key: null,\n        value: null\n      });\n    }\n  }\n\n  public get(key: number): T | null {\n    // This is unsafe: We're assuming our keyspace doesn't overlap with Object.prototype. However,\n    // it's faster than calling hasOwnProperty, and in our case, it would never overlap.\n    const node = this._map[key];\n    if (node !== undefined) {\n      this._unlinkNode(node);\n      this._appendNode(node);\n      return node.value;\n    }\n    return null;\n  }\n\n  /**\n   * Gets a value from a key without marking it as the most recently used item.\n   */\n  public peekValue(key: number): T | null {\n    const node = this._map[key];\n    if (node !== undefined) {\n      return node.value;\n    }\n    return null;\n  }\n\n  public peek(): T | null {\n    const head = this._head;\n    return head === null ? null : head.value;\n  }\n\n  public set(key: number, value: T): void {\n    // This is unsafe: See note above.\n    let node = this._map[key];\n    if (node !== undefined) {\n      // already exists, we just need to mutate it and move it to the end of the list\n      node = this._map[key];\n      this._unlinkNode(node);\n      node.value = value;\n    } else if (this.size >= this.capacity) {\n      // we're out of space: recycle the head node, move it to the tail\n      node = this._head!;\n      this._unlinkNode(node);\n      delete this._map[node.key!];\n      node.key = key;\n      node.value = value;\n      this._map[key] = node;\n    } else {\n      // make a new element\n      const nodePool = this._nodePool;\n      if (nodePool.length > 0) {\n        // use a preallocated node if we can\n        node = nodePool.pop()!;\n        node.key = key;\n        node.value = value;\n      } else {\n        node = {\n          prev: null,\n          next: null,\n          key,\n          value\n        };\n      }\n      this._map[key] = node;\n      this.size++;\n    }\n    this._appendNode(node);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderDimensions } from 'browser/renderer/Types';\nimport { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';\nimport { IColorSet } from 'browser/Types';\nimport { IBufferService, IOptionsService } from 'common/services/Services';\n\ninterface ISelectionState {\n  start?: [number, number];\n  end?: [number, number];\n  columnSelectMode?: boolean;\n  ydisp?: number;\n}\n\nexport class SelectionRenderLayer extends BaseRenderLayer {\n  private _state!: ISelectionState;\n\n  constructor(\n    container: HTMLElement,\n    zIndex: number,\n    colors: IColorSet,\n    rendererId: number,\n    readonly bufferService: IBufferService,\n    readonly optionsService: IOptionsService\n  ) {\n    super(container, 'selection', zIndex, true, colors, rendererId, bufferService, optionsService);\n    this._clearState();\n  }\n\n  private _clearState(): void {\n    this._state = {\n      start: undefined,\n      end: undefined,\n      columnSelectMode: undefined,\n      ydisp: undefined\n    };\n  }\n\n  public resize(dim: IRenderDimensions): void {\n    super.resize(dim);\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._clearState();\n  }\n\n  public reset(): void {\n    if (this._state.start && this._state.end) {\n      this._clearState();\n      this._clearAll();\n    }\n  }\n\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void {\n    // Selection has not changed\n    if (!this._didStateChange(start, end, columnSelectMode, this._bufferService.buffer.ydisp)) {\n      return;\n    }\n\n    // Remove all selections\n    this._clearAll();\n\n    // Selection does not exist\n    if (!start || !end) {\n      this._clearState();\n      return;\n    }\n\n    // Translate from buffer position to viewport position\n    const viewportStartRow = start[1] - this._bufferService.buffer.ydisp;\n    const viewportEndRow = end[1] - this._bufferService.buffer.ydisp;\n    const viewportCappedStartRow = Math.max(viewportStartRow, 0);\n    const viewportCappedEndRow = Math.min(viewportEndRow, this._bufferService.rows - 1);\n\n    // No need to draw the selection\n    if (viewportCappedStartRow >= this._bufferService.rows || viewportCappedEndRow < 0) {\n      return;\n    }\n\n    this._ctx.fillStyle = this._colors.selection.css;\n\n    if (columnSelectMode) {\n      const startCol = start[0];\n      const width = end[0] - startCol;\n      const height = viewportCappedEndRow - viewportCappedStartRow + 1;\n      this._fillCells(startCol, viewportCappedStartRow, width, height);\n    } else {\n      // Draw first row\n      const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;\n      const startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;\n      this._fillCells(startCol, viewportCappedStartRow, startRowEndCol - startCol, 1);\n\n      // Draw middle rows\n      const middleRowsCount = Math.max(viewportCappedEndRow - viewportCappedStartRow - 1, 0);\n      this._fillCells(0, viewportCappedStartRow + 1, this._bufferService.cols, middleRowsCount);\n\n      // Draw final row\n      if (viewportCappedStartRow !== viewportCappedEndRow) {\n        // Only draw viewportEndRow if it's not the same as viewportStartRow\n        const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;\n        this._fillCells(0, viewportCappedEndRow, endCol, 1);\n      }\n    }\n\n    // Save state for next render\n    this._state.start = [start[0], start[1]];\n    this._state.end = [end[0], end[1]];\n    this._state.columnSelectMode = columnSelectMode;\n    this._state.ydisp = this._bufferService.buffer.ydisp;\n  }\n\n  private _didStateChange(start: [number, number], end: [number, number], columnSelectMode: boolean, ydisp: number): boolean {\n    return !this._areCoordinatesEqual(start, this._state.start) ||\n      !this._areCoordinatesEqual(end, this._state.end) ||\n      columnSelectMode !== this._state.columnSelectMode ||\n      ydisp !== this._state.ydisp;\n  }\n\n  private _areCoordinatesEqual(coord1: [number, number] | undefined, coord2: [number, number] | undefined): boolean {\n    if (!coord1 || !coord2) {\n      return false;\n    }\n\n    return coord1[0] === coord2[0] && coord1[1] === coord2[1];\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderDimensions, IRequestRefreshRowsEvent } from 'browser/renderer/Types';\nimport { BaseRenderLayer } from 'browser/renderer/BaseRenderLayer';\nimport { ICellData } from 'common/Types';\nimport { CellData } from 'common/buffer/CellData';\nimport { IColorSet } from 'browser/Types';\nimport { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';\nimport { IEventEmitter } from 'common/EventEmitter';\nimport { ICoreBrowserService } from 'browser/services/Services';\n\ninterface ICursorState {\n  x: number;\n  y: number;\n  isFocused: boolean;\n  style: string;\n  width: number;\n}\n\n/**\n * The time between cursor blinks.\n */\nconst BLINK_INTERVAL = 600;\n\nexport class CursorRenderLayer extends BaseRenderLayer {\n  private _state: ICursorState;\n  private _cursorRenderers: {[key: string]: (x: number, y: number, cell: ICellData) => void};\n  private _cursorBlinkStateManager: CursorBlinkStateManager | undefined;\n  private _cell: ICellData = new CellData();\n\n  constructor(\n    container: HTMLElement,\n    zIndex: number,\n    colors: IColorSet,\n    rendererId: number,\n    private _onRequestRefreshRowsEvent: IEventEmitter<IRequestRefreshRowsEvent>,\n    readonly bufferService: IBufferService,\n    readonly optionsService: IOptionsService,\n    private readonly _coreService: ICoreService,\n    private readonly _coreBrowserService: ICoreBrowserService\n  ) {\n    super(container, 'cursor', zIndex, true, colors, rendererId, bufferService, optionsService);\n    this._state = {\n      x: 0,\n      y: 0,\n      isFocused: false,\n      style: '',\n      width: 0\n    };\n    this._cursorRenderers = {\n      'bar': this._renderBarCursor.bind(this),\n      'block': this._renderBlockCursor.bind(this),\n      'underline': this._renderUnderlineCursor.bind(this)\n    };\n    // TODO: Consider initial options? Maybe onOptionsChanged should be called at the end of open?\n  }\n\n  public resize(dim: IRenderDimensions): void {\n    super.resize(dim);\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._state = {\n      x: 0,\n      y: 0,\n      isFocused: false,\n      style: '',\n      width: 0\n    };\n  }\n\n  public reset(): void {\n    this._clearCursor();\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.dispose();\n      this._cursorBlinkStateManager = undefined;\n      this.onOptionsChanged();\n    }\n  }\n\n  public onBlur(): void {\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.pause();\n    }\n    this._onRequestRefreshRowsEvent.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });\n  }\n\n  public onFocus(): void {\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.resume();\n    } else {\n      this._onRequestRefreshRowsEvent.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });\n    }\n  }\n\n  public onOptionsChanged(): void {\n    if (this._optionsService.options.cursorBlink) {\n      if (!this._cursorBlinkStateManager) {\n        this._cursorBlinkStateManager = new CursorBlinkStateManager(this._coreBrowserService.isFocused, () => {\n          this._render(true);\n        });\n      }\n    } else {\n      this._cursorBlinkStateManager?.dispose();\n      this._cursorBlinkStateManager = undefined;\n    }\n    // Request a refresh from the terminal as management of rendering is being\n    // moved back to the terminal\n    this._onRequestRefreshRowsEvent.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });\n  }\n\n  public onCursorMove(): void {\n    if (this._cursorBlinkStateManager) {\n      this._cursorBlinkStateManager.restartBlinkAnimation();\n    }\n  }\n\n  public onGridChanged(startRow: number, endRow: number): void {\n    if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {\n      this._render(false);\n    } else {\n      this._cursorBlinkStateManager.restartBlinkAnimation();\n    }\n  }\n\n  private _render(triggeredByAnimationFrame: boolean): void {\n    // Don't draw the cursor if it's hidden\n    if (!this._coreService.isCursorInitialized || this._coreService.isCursorHidden) {\n      this._clearCursor();\n      return;\n    }\n\n    const cursorY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;\n    const viewportRelativeCursorY = cursorY - this._bufferService.buffer.ydisp;\n\n    // Don't draw the cursor if it's off-screen\n    if (viewportRelativeCursorY < 0 || viewportRelativeCursorY >= this._bufferService.rows) {\n      this._clearCursor();\n      return;\n    }\n\n    this._bufferService.buffer.lines.get(cursorY)!.loadCell(this._bufferService.buffer.x, this._cell);\n    if (this._cell.content === undefined) {\n      return;\n    }\n\n    if (!this._coreBrowserService.isFocused) {\n      this._clearCursor();\n      this._ctx.save();\n      this._ctx.fillStyle = this._colors.cursor.css;\n      const cursorStyle = this._optionsService.options.cursorStyle;\n      if (cursorStyle && cursorStyle !== 'block') {\n        this._cursorRenderers[cursorStyle](this._bufferService.buffer.x, viewportRelativeCursorY, this._cell);\n      } else {\n        this._renderBlurCursor(this._bufferService.buffer.x, viewportRelativeCursorY, this._cell);\n      }\n      this._ctx.restore();\n      this._state.x = this._bufferService.buffer.x;\n      this._state.y = viewportRelativeCursorY;\n      this._state.isFocused = false;\n      this._state.style = cursorStyle;\n      this._state.width = this._cell.getWidth();\n      return;\n    }\n\n    // Don't draw the cursor if it's blinking\n    if (this._cursorBlinkStateManager && !this._cursorBlinkStateManager.isCursorVisible) {\n      this._clearCursor();\n      return;\n    }\n\n    if (this._state) {\n      // The cursor is already in the correct spot, don't redraw\n      if (this._state.x === this._bufferService.buffer.x &&\n          this._state.y === viewportRelativeCursorY &&\n          this._state.isFocused === this._coreBrowserService.isFocused &&\n          this._state.style === this._optionsService.options.cursorStyle &&\n          this._state.width === this._cell.getWidth()) {\n        return;\n      }\n      this._clearCursor();\n    }\n\n    this._ctx.save();\n    this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](this._bufferService.buffer.x, viewportRelativeCursorY, this._cell);\n    this._ctx.restore();\n\n    this._state.x = this._bufferService.buffer.x;\n    this._state.y = viewportRelativeCursorY;\n    this._state.isFocused = false;\n    this._state.style = this._optionsService.options.cursorStyle;\n    this._state.width = this._cell.getWidth();\n  }\n\n  private _clearCursor(): void {\n    if (this._state) {\n      this._clearCells(this._state.x, this._state.y, this._state.width, 1);\n      this._state = {\n        x: 0,\n        y: 0,\n        isFocused: false,\n        style: '',\n        width: 0\n      };\n    }\n  }\n\n  private _renderBarCursor(x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.fillStyle = this._colors.cursor.css;\n    this._fillLeftLineAtCell(x, y);\n    this._ctx.restore();\n  }\n\n  private _renderBlockCursor(x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.fillStyle = this._colors.cursor.css;\n    this._fillCells(x, y, cell.getWidth(), 1);\n    this._ctx.fillStyle = this._colors.cursorAccent.css;\n    this._fillCharTrueColor(cell, x, y);\n    this._ctx.restore();\n  }\n\n  private _renderUnderlineCursor(x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.fillStyle = this._colors.cursor.css;\n    this._fillBottomLineAtCells(x, y);\n    this._ctx.restore();\n  }\n\n  private _renderBlurCursor(x: number, y: number, cell: ICellData): void {\n    this._ctx.save();\n    this._ctx.strokeStyle = this._colors.cursor.css;\n    this._strokeRectAtCell(x, y, cell.getWidth(), 1);\n    this._ctx.restore();\n  }\n}\n\nclass CursorBlinkStateManager {\n  public isCursorVisible: boolean;\n\n  private _animationFrame: number | undefined;\n  private _blinkStartTimeout: number | undefined;\n  private _blinkInterval: number | undefined;\n\n  /**\n   * The time at which the animation frame was restarted, this is used on the\n   * next render to restart the timers so they don't need to restart the timers\n   * multiple times over a short period.\n   */\n  private _animationTimeRestarted: number | undefined;\n\n  constructor(\n    isFocused: boolean,\n    private _renderCallback: () => void\n  ) {\n    this.isCursorVisible = true;\n    if (isFocused) {\n      this._restartInterval();\n    }\n  }\n\n  public get isPaused(): boolean { return !(this._blinkStartTimeout || this._blinkInterval); }\n\n  public dispose(): void {\n    if (this._blinkInterval) {\n      window.clearInterval(this._blinkInterval);\n      this._blinkInterval = undefined;\n    }\n    if (this._blinkStartTimeout) {\n      window.clearTimeout(this._blinkStartTimeout);\n      this._blinkStartTimeout = undefined;\n    }\n    if (this._animationFrame) {\n      window.cancelAnimationFrame(this._animationFrame);\n      this._animationFrame = undefined;\n    }\n  }\n\n  public restartBlinkAnimation(): void {\n    if (this.isPaused) {\n      return;\n    }\n    // Save a timestamp so that the restart can be done on the next interval\n    this._animationTimeRestarted = Date.now();\n    // Force a cursor render to ensure it's visible and in the correct position\n    this.isCursorVisible = true;\n    if (!this._animationFrame) {\n      this._animationFrame = window.requestAnimationFrame(() => {\n        this._renderCallback();\n        this._animationFrame = undefined;\n      });\n    }\n  }\n\n  private _restartInterval(timeToStart: number = BLINK_INTERVAL): void {\n    // Clear any existing interval\n    if (this._blinkInterval) {\n      window.clearInterval(this._blinkInterval);\n    }\n\n    // Setup the initial timeout which will hide the cursor, this is done before\n    // the regular interval is setup in order to support restarting the blink\n    // animation in a lightweight way (without thrashing clearInterval and\n    // setInterval).\n    this._blinkStartTimeout = <number><any>setTimeout(() => {\n      // Check if another animation restart was requested while this was being\n      // started\n      if (this._animationTimeRestarted) {\n        const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);\n        this._animationTimeRestarted = undefined;\n        if (time > 0) {\n          this._restartInterval(time);\n          return;\n        }\n      }\n\n      // Hide the cursor\n      this.isCursorVisible = false;\n      this._animationFrame = window.requestAnimationFrame(() => {\n        this._renderCallback();\n        this._animationFrame = undefined;\n      });\n\n      // Setup the blink interval\n      this._blinkInterval = <number><any>setInterval(() => {\n        // Adjust the animation time if it was restarted\n        if (this._animationTimeRestarted) {\n          // calc time diff\n          // Make restart interval do a setTimeout initially?\n          const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);\n          this._animationTimeRestarted = undefined;\n          this._restartInterval(time);\n          return;\n        }\n\n        // Invert visibility and render\n        this.isCursorVisible = !this.isCursorVisible;\n        this._animationFrame = window.requestAnimationFrame(() => {\n          this._renderCallback();\n          this._animationFrame = undefined;\n        });\n      }, BLINK_INTERVAL);\n    }, timeToStart);\n  }\n\n  public pause(): void {\n    this.isCursorVisible = true;\n    if (this._blinkInterval) {\n      window.clearInterval(this._blinkInterval);\n      this._blinkInterval = undefined;\n    }\n    if (this._blinkStartTimeout) {\n      window.clearTimeout(this._blinkStartTimeout);\n      this._blinkStartTimeout = undefined;\n    }\n    if (this._animationFrame) {\n      window.cancelAnimationFrame(this._animationFrame);\n      this._animationFrame = undefined;\n    }\n  }\n\n  public resume(): void {\n    this._animationTimeRestarted = undefined;\n    this._restartInterval();\n    this.restartBlinkAnimation();\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderDimensions } from 'browser/renderer/Types';\nimport { BaseRenderLayer } from './BaseRenderLayer';\nimport { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';\nimport { is256Color } from 'browser/renderer/atlas/CharAtlasUtils';\nimport { IColorSet, ILinkifierEvent, ILinkifier } from 'browser/Types';\nimport { IBufferService, IOptionsService } from 'common/services/Services';\n\nexport class LinkRenderLayer extends BaseRenderLayer {\n  private _state: ILinkifierEvent | undefined;\n\n  constructor(\n    container: HTMLElement,\n    zIndex: number,\n    colors: IColorSet,\n    rendererId: number,\n    linkifier: ILinkifier,\n    readonly bufferService: IBufferService,\n    readonly optionsService: IOptionsService\n  ) {\n    super(container, 'link', zIndex, true, colors, rendererId, bufferService, optionsService);\n    linkifier.onLinkHover(e => this._onLinkHover(e));\n    linkifier.onLinkLeave(e => this._onLinkLeave(e));\n  }\n\n  public resize(dim: IRenderDimensions): void {\n    super.resize(dim);\n    // Resizing the canvas discards the contents of the canvas so clear state\n    this._state = undefined;\n  }\n\n  public reset(): void {\n    this._clearCurrentLink();\n  }\n\n  private _clearCurrentLink(): void {\n    if (this._state) {\n      this._clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);\n      const middleRowCount = this._state.y2 - this._state.y1 - 1;\n      if (middleRowCount > 0) {\n        this._clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);\n      }\n      this._clearCells(0, this._state.y2, this._state.x2, 1);\n      this._state = undefined;\n    }\n  }\n\n  private _onLinkHover(e: ILinkifierEvent): void {\n    if (e.fg === INVERTED_DEFAULT_COLOR) {\n      this._ctx.fillStyle = this._colors.background.css;\n    } else if (e.fg && is256Color(e.fg)) {\n      // 256 color support\n      this._ctx.fillStyle = this._colors.ansi[e.fg].css;\n    } else {\n      this._ctx.fillStyle = this._colors.foreground.css;\n    }\n\n    if (e.y1 === e.y2) {\n      // Single line link\n      this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);\n    } else {\n      // Multi-line link\n      this._fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);\n      for (let y = e.y1 + 1; y < e.y2; y++) {\n        this._fillBottomLineAtCells(0, y, e.cols);\n      }\n      this._fillBottomLineAtCells(0, e.y2, e.x2);\n    }\n    this._state = e;\n  }\n\n  private _onLinkLeave(e: ILinkifierEvent): void {\n    this._clearCurrentLink();\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions, ILinkifier, IMouseZoneManager, IMouseZone, IRegisteredLinkMatcher } from 'browser/Types';\nimport { IBufferStringIteratorResult } from 'common/buffer/Types';\nimport { getStringCellWidth } from 'common/CharWidth';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { ILogService, IBufferService } from 'common/services/Services';\n\n/**\n * Limit of the unwrapping line expansion (overscan) at the top and bottom\n * of the actual viewport in ASCII characters.\n * A limit of 2000 should match most sane urls.\n */\nconst OVERSCAN_CHAR_LIMIT = 2000;\n\n/**\n * The Linkifier applies links to rows shortly after they have been refreshed.\n */\nexport class Linkifier implements ILinkifier {\n  /**\n   * The time to wait after a row is changed before it is linkified. This prevents\n   * the costly operation of searching every row multiple times, potentially a\n   * huge amount of times.\n   */\n  protected static _timeBeforeLatency = 200;\n\n  protected _linkMatchers: IRegisteredLinkMatcher[] = [];\n\n  private _mouseZoneManager: IMouseZoneManager | undefined;\n  private _element: HTMLElement | undefined;\n\n  private _rowsTimeoutId: number | undefined;\n  private _nextLinkMatcherId = 0;\n  private _rowsToLinkify: { start: number | undefined, end: number | undefined };\n\n  private _onLinkHover = new EventEmitter<ILinkifierEvent>();\n  public get onLinkHover(): IEvent<ILinkifierEvent> { return this._onLinkHover.event; }\n  private _onLinkLeave = new EventEmitter<ILinkifierEvent>();\n  public get onLinkLeave(): IEvent<ILinkifierEvent> { return this._onLinkLeave.event; }\n  private _onLinkTooltip = new EventEmitter<ILinkifierEvent>();\n  public get onLinkTooltip(): IEvent<ILinkifierEvent> { return this._onLinkTooltip.event; }\n\n  constructor(\n    protected readonly _bufferService: IBufferService,\n    private readonly _logService: ILogService\n  ) {\n    this._rowsToLinkify = {\n      start: undefined,\n      end: undefined\n    };\n  }\n\n  /**\n   * Attaches the linkifier to the DOM, enabling linkification.\n   * @param mouseZoneManager The mouse zone manager to register link zones with.\n   */\n  public attachToDom(element: HTMLElement, mouseZoneManager: IMouseZoneManager): void {\n    this._element = element;\n    this._mouseZoneManager = mouseZoneManager;\n  }\n\n  /**\n   * Queue linkification on a set of rows.\n   * @param start The row to linkify from (inclusive).\n   * @param end The row to linkify to (inclusive).\n   */\n  public linkifyRows(start: number, end: number): void {\n    // Don't attempt linkify if not yet attached to DOM\n    if (!this._mouseZoneManager) {\n      return;\n    }\n\n    // Increase range to linkify\n    if (this._rowsToLinkify.start === undefined || this._rowsToLinkify.end === undefined) {\n      this._rowsToLinkify.start = start;\n      this._rowsToLinkify.end = end;\n    } else {\n      this._rowsToLinkify.start = Math.min(this._rowsToLinkify.start, start);\n      this._rowsToLinkify.end = Math.max(this._rowsToLinkify.end, end);\n    }\n\n    // Clear out any existing links on this row range\n    this._mouseZoneManager.clearAll(start, end);\n\n    // Restart timer\n    if (this._rowsTimeoutId) {\n      clearTimeout(this._rowsTimeoutId);\n    }\n    this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency);\n  }\n\n  /**\n   * Linkifies the rows requested.\n   */\n  private _linkifyRows(): void {\n    this._rowsTimeoutId = undefined;\n    const buffer = this._bufferService.buffer;\n\n    if (this._rowsToLinkify.start === undefined || this._rowsToLinkify.end === undefined) {\n      this._logService.debug('_rowToLinkify was unset before _linkifyRows was called');\n      return;\n    }\n\n    // Ensure the start row exists\n    const absoluteRowIndexStart = buffer.ydisp + this._rowsToLinkify.start;\n    if (absoluteRowIndexStart >= buffer.lines.length) {\n      return;\n    }\n\n    // Invalidate bad end row values (if a resize happened)\n    const absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._bufferService.rows) + 1;\n\n    // Iterate over the range of unwrapped content strings within start..end\n    // (excluding).\n    // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset\n    // for every matcher.\n    // The unwrapping is needed to also match content that got wrapped across\n    // several buffer lines. To avoid a worst case scenario where the whole buffer\n    // contains just a single unwrapped string we limit this line expansion beyond\n    // the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom.\n    // This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT\n    // chars will not match anymore at the viewport borders.\n    const overscanLineLimit = Math.ceil(OVERSCAN_CHAR_LIMIT / this._bufferService.cols);\n    const iterator = this._bufferService.buffer.iterator(\n      false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);\n    while (iterator.hasNext()) {\n      const lineData: IBufferStringIteratorResult = iterator.next();\n      for (let i = 0; i < this._linkMatchers.length; i++) {\n        this._doLinkifyRow(lineData.range.first, lineData.content, this._linkMatchers[i]);\n      }\n    }\n\n    this._rowsToLinkify.start = undefined;\n    this._rowsToLinkify.end = undefined;\n  }\n\n  /**\n   * Registers a link matcher, allowing custom link patterns to be matched and\n   * handled.\n   * @param regex The regular expression to search for. Specifically, this\n   * searches the textContent of the rows. You will want to use \\s to match a\n   * space ' ' character for example.\n   * @param handler The callback when the link is called.\n   * @param options Options for the link matcher.\n   * @return The ID of the new matcher, this can be used to deregister.\n   */\n  public registerLinkMatcher(regex: RegExp, handler: LinkMatcherHandler, options: ILinkMatcherOptions = {}): number {\n    if (!handler) {\n      throw new Error('handler must be defined');\n    }\n    const matcher: IRegisteredLinkMatcher = {\n      id: this._nextLinkMatcherId++,\n      regex,\n      handler,\n      matchIndex: options.matchIndex,\n      validationCallback: options.validationCallback,\n      hoverTooltipCallback: options.tooltipCallback,\n      hoverLeaveCallback: options.leaveCallback,\n      willLinkActivate: options.willLinkActivate,\n      priority: options.priority || 0\n    };\n    this._addLinkMatcherToList(matcher);\n    return matcher.id;\n  }\n\n  /**\n   * Inserts a link matcher to the list in the correct position based on the\n   * priority of each link matcher. New link matchers of equal priority are\n   * considered after older link matchers.\n   * @param matcher The link matcher to be added.\n   */\n  private _addLinkMatcherToList(matcher: IRegisteredLinkMatcher): void {\n    if (this._linkMatchers.length === 0) {\n      this._linkMatchers.push(matcher);\n      return;\n    }\n\n    for (let i = this._linkMatchers.length - 1; i >= 0; i--) {\n      if (matcher.priority <= this._linkMatchers[i].priority) {\n        this._linkMatchers.splice(i + 1, 0, matcher);\n        return;\n      }\n    }\n\n    this._linkMatchers.splice(0, 0, matcher);\n  }\n\n  /**\n   * Deregisters a link matcher if it has been registered.\n   * @param matcherId The link matcher's ID (returned after register)\n   * @return Whether a link matcher was found and deregistered.\n   */\n  public deregisterLinkMatcher(matcherId: number): boolean {\n    for (let i = 0; i < this._linkMatchers.length; i++) {\n      if (this._linkMatchers[i].id === matcherId) {\n        this._linkMatchers.splice(i, 1);\n        return true;\n      }\n    }\n    return false;\n  }\n\n  /**\n   * Linkifies a row given a specific handler.\n   * @param rowIndex The row index to linkify (absolute index).\n   * @param text string content of the unwrapped row.\n   * @param matcher The link matcher for this line.\n   */\n  private _doLinkifyRow(rowIndex: number, text: string, matcher: ILinkMatcher): void {\n    // clone regex to do a global search on text\n    const rex = new RegExp(matcher.regex.source, (matcher.regex.flags || '') + 'g');\n    let match;\n    let stringIndex = -1;\n    while ((match = rex.exec(text)) !== null) {\n      const uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];\n      if (!uri) {\n        // something matched but does not comply with the given matchIndex\n        // since this is most likely a bug the regex itself we simply do nothing here\n        this._logService.debug('match found without corresponding matchIndex', match, matcher);\n        break;\n      }\n\n      // Get index, match.index is for the outer match which includes negated chars\n      // therefore we cannot use match.index directly, instead we search the position\n      // of the match group in text again\n      // also correct regex and string search offsets for the next loop run\n      stringIndex = text.indexOf(uri, stringIndex + 1);\n      rex.lastIndex = stringIndex + uri.length;\n      if (stringIndex < 0) {\n        // invalid stringIndex (should not have happened)\n        break;\n      }\n\n      // get the buffer index as [absolute row, col] for the match\n      const bufferIndex = this._bufferService.buffer.stringIndexToBufferIndex(rowIndex, stringIndex);\n      if (bufferIndex[0] < 0) {\n        // invalid bufferIndex (should not have happened)\n        break;\n      }\n\n      const line = this._bufferService.buffer.lines.get(bufferIndex[0]);\n      if (!line) {\n        break;\n      }\n\n      const attr = line.getFg(bufferIndex[1]);\n      const fg = attr ? (attr >> 9) & 0x1ff : undefined;\n\n      if (matcher.validationCallback) {\n        matcher.validationCallback(uri, isValid => {\n          // Discard link if the line has already changed\n          if (this._rowsTimeoutId) {\n            return;\n          }\n          if (isValid) {\n            this._addLink(bufferIndex[1], bufferIndex[0] - this._bufferService.buffer.ydisp, uri, matcher, fg);\n          }\n        });\n      } else {\n        this._addLink(bufferIndex[1], bufferIndex[0] - this._bufferService.buffer.ydisp, uri, matcher, fg);\n      }\n    }\n  }\n\n  /**\n   * Registers a link to the mouse zone manager.\n   * @param x The column the link starts.\n   * @param y The row the link is on.\n   * @param uri The URI of the link.\n   * @param matcher The link matcher for the link.\n   * @param fg The link color for hover event.\n   */\n  private _addLink(x: number, y: number, uri: string, matcher: ILinkMatcher, fg: number | undefined): void {\n    if (!this._mouseZoneManager || !this._element) {\n      return;\n    }\n\n    const width = getStringCellWidth(uri);\n    const x1 = x % this._bufferService.cols;\n    const y1 = y + Math.floor(x / this._bufferService.cols);\n    let x2 = (x1 + width) % this._bufferService.cols;\n    let y2 = y1 + Math.floor((x1 + width) / this._bufferService.cols);\n    if (x2 === 0) {\n      x2 = this._bufferService.cols;\n      y2--;\n    }\n\n    this._mouseZoneManager.add(new MouseZone(\n      x1 + 1,\n      y1 + 1,\n      x2 + 1,\n      y2 + 1,\n      e => {\n        if (matcher.handler) {\n          return matcher.handler(e, uri);\n        }\n        window.open(uri, '_blank');\n      },\n      () => {\n        this._onLinkHover.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));\n        this._element!.classList.add('xterm-cursor-pointer');\n      },\n      e => {\n        this._onLinkTooltip.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));\n        if (matcher.hoverTooltipCallback) {\n          // Note that IViewportRange use 1-based coordinates to align with escape sequences such\n          // as CUP which use 1,1 as the default for row/col\n          matcher.hoverTooltipCallback(e, uri, { start: { x: x1, y: y1 }, end: { x: x2, y: y2 } });\n        }\n      },\n      () => {\n        this._onLinkLeave.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));\n        this._element!.classList.remove('xterm-cursor-pointer');\n        if (matcher.hoverLeaveCallback) {\n          matcher.hoverLeaveCallback();\n        }\n      },\n      e => {\n        if (matcher.willLinkActivate) {\n          return matcher.willLinkActivate(e, uri);\n        }\n        return true;\n      }\n    ));\n  }\n\n  private _createLinkHoverEvent(x1: number, y1: number, x2: number, y2: number, fg: number | undefined): ILinkifierEvent {\n    return { x1, y1, x2, y2, cols: this._bufferService.cols, fg };\n  }\n}\n\nexport class MouseZone implements IMouseZone {\n  constructor(\n    public x1: number,\n    public y1: number,\n    public x2: number,\n    public y2: number,\n    public clickCallback: (e: MouseEvent) => any,\n    public hoverCallback: (e: MouseEvent) => any,\n    public tooltipCallback: (e: MouseEvent) => any,\n    public leaveCallback: () => void,\n    public willLinkActivate: (e: MouseEvent) => boolean\n  ) {\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ISelectionRedrawRequestEvent } from 'browser/selection/Types';\nimport { IBuffer } from 'common/buffer/Types';\nimport { IBufferLine, IDisposable } from 'common/Types';\nimport * as Browser from 'common/Platform';\nimport { SelectionModel } from 'browser/selection/SelectionModel';\nimport { CellData } from 'common/buffer/CellData';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { ICharSizeService, IMouseService, ISelectionService } from 'browser/services/Services';\nimport { IBufferService, IOptionsService, ICoreService } from 'common/services/Services';\nimport { getCoordsRelativeToElement } from 'browser/input/Mouse';\nimport { moveToCellSequence } from 'browser/input/MoveToCell';\n\n/**\n * The number of pixels the mouse needs to be above or below the viewport in\n * order to scroll at the maximum speed.\n */\nconst DRAG_SCROLL_MAX_THRESHOLD = 50;\n\n/**\n * The maximum scrolling speed\n */\nconst DRAG_SCROLL_MAX_SPEED = 15;\n\n/**\n * The number of milliseconds between drag scroll updates.\n */\nconst DRAG_SCROLL_INTERVAL = 50;\n\n/**\n * The maximum amount of time that can have elapsed for an alt click to move the\n * cursor.\n */\nconst ALT_CLICK_MOVE_CURSOR_TIME = 500;\n\nconst NON_BREAKING_SPACE_CHAR = String.fromCharCode(160);\nconst ALL_NON_BREAKING_SPACE_REGEX = new RegExp(NON_BREAKING_SPACE_CHAR, 'g');\n\n/**\n * Represents a position of a word on a line.\n */\ninterface IWordPosition {\n  start: number;\n  length: number;\n}\n\n/**\n * A selection mode, this drives how the selection behaves on mouse move.\n */\nexport const enum SelectionMode {\n  NORMAL,\n  WORD,\n  LINE,\n  COLUMN\n}\n\n/**\n * A class that manages the selection of the terminal. With help from\n * SelectionModel, SelectionService handles with all logic associated with\n * dealing with the selection, including handling mouse interaction, wide\n * characters and fetching the actual text within the selection. Rendering is\n * not handled by the SelectionService but the onRedrawRequest event is fired\n * when the selection is ready to be redrawn (on an animation frame).\n */\nexport class SelectionService implements ISelectionService {\n  serviceBrand: any;\n\n  protected _model: SelectionModel;\n\n  /**\n   * The amount to scroll every drag scroll update (depends on how far the mouse\n   * drag is above or below the terminal).\n   */\n  private _dragScrollAmount: number = 0;\n\n  /**\n   * The current selection mode.\n   */\n  protected _activeSelectionMode: SelectionMode;\n\n  /**\n   * A setInterval timer that is active while the mouse is down whose callback\n   * scrolls the viewport when necessary.\n   */\n  private _dragScrollIntervalTimer: number | undefined;\n\n  /**\n   * The animation frame ID used for refreshing the selection.\n   */\n  private _refreshAnimationFrame: number | undefined;\n\n  /**\n   * Whether selection is enabled.\n   */\n  private _enabled = true;\n\n  private _mouseMoveListener: EventListener;\n  private _mouseUpListener: EventListener;\n  private _trimListener: IDisposable;\n  private _workCell: CellData = new CellData();\n\n  private _mouseDownTimeStamp: number = 0;\n\n  private _onLinuxMouseSelection = new EventEmitter<string>();\n  public get onLinuxMouseSelection(): IEvent<string> { return this._onLinuxMouseSelection.event; }\n  private _onRedrawRequest = new EventEmitter<ISelectionRedrawRequestEvent>();\n  public get onRedrawRequest(): IEvent<ISelectionRedrawRequestEvent> { return this._onRedrawRequest.event; }\n  private _onSelectionChange = new EventEmitter<void>();\n  public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }\n\n  constructor(\n    private readonly _scrollLines: (amount: number, suppressEvent: boolean) => void,\n    private readonly _element: HTMLElement,\n    private readonly _screenElement: HTMLElement,\n    @ICharSizeService private readonly _charSizeService: ICharSizeService,\n    @IBufferService private readonly _bufferService: IBufferService,\n    @ICoreService private readonly _coreService: ICoreService,\n    @IMouseService private readonly _mouseService: IMouseService,\n    @IOptionsService private readonly _optionsService: IOptionsService\n  ) {\n    // Init listeners\n    this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);\n    this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);\n    this._coreService.onUserInput(() => {\n      if (this.hasSelection) {\n        this.clearSelection();\n      }\n    });\n    this._trimListener = this._bufferService.buffer.lines.onTrim(amount => this._onTrim(amount));\n    this._bufferService.buffers.onBufferActivate(e => this._onBufferActivate(e));\n\n    this.enable();\n\n    this._model = new SelectionModel(this._bufferService);\n    this._activeSelectionMode = SelectionMode.NORMAL;\n  }\n\n  public dispose(): void {\n    this._removeMouseDownListeners();\n  }\n\n  public reset(): void {\n    this.clearSelection();\n  }\n\n  /**\n   * Disables the selection manager. This is useful for when terminal mouse\n   * are enabled.\n   */\n  public disable(): void {\n    this.clearSelection();\n    this._enabled = false;\n  }\n\n  /**\n   * Enable the selection manager.\n   */\n  public enable(): void {\n    this._enabled = true;\n  }\n\n  public get selectionStart(): [number, number] | undefined { return this._model.finalSelectionStart; }\n  public get selectionEnd(): [number, number] | undefined { return this._model.finalSelectionEnd; }\n\n  /**\n   * Gets whether there is an active text selection.\n   */\n  public get hasSelection(): boolean {\n    const start = this._model.finalSelectionStart;\n    const end = this._model.finalSelectionEnd;\n    if (!start || !end) {\n      return false;\n    }\n    return start[0] !== end[0] || start[1] !== end[1];\n  }\n\n  /**\n   * Gets the text currently selected.\n   */\n  public get selectionText(): string {\n    const start = this._model.finalSelectionStart;\n    const end = this._model.finalSelectionEnd;\n    if (!start || !end) {\n      return '';\n    }\n\n    const buffer = this._bufferService.buffer;\n    const result: string[] = [];\n\n    if (this._activeSelectionMode === SelectionMode.COLUMN) {\n      // Ignore zero width selections\n      if (start[0] === end[0]) {\n        return '';\n      }\n\n      for (let i = start[1]; i <= end[1]; i++) {\n        const lineText = buffer.translateBufferLineToString(i, true, start[0], end[0]);\n        result.push(lineText);\n      }\n    } else {\n      // Get first row\n      const startRowEndCol = start[1] === end[1] ? end[0] : undefined;\n      result.push(buffer.translateBufferLineToString(start[1], true, start[0], startRowEndCol));\n\n      // Get middle rows\n      for (let i = start[1] + 1; i <= end[1] - 1; i++) {\n        const bufferLine = buffer.lines.get(i);\n        const lineText = buffer.translateBufferLineToString(i, true);\n        if (bufferLine && bufferLine.isWrapped) {\n          result[result.length - 1] += lineText;\n        } else {\n          result.push(lineText);\n        }\n      }\n\n      // Get final row\n      if (start[1] !== end[1]) {\n        const bufferLine = buffer.lines.get(end[1]);\n        const lineText = buffer.translateBufferLineToString(end[1], true, 0, end[0]);\n        if (bufferLine && bufferLine!.isWrapped) {\n          result[result.length - 1] += lineText;\n        } else {\n          result.push(lineText);\n        }\n      }\n    }\n\n    // Format string by replacing non-breaking space chars with regular spaces\n    // and joining the array into a multi-line string.\n    const formattedResult = result.map(line => {\n      return line.replace(ALL_NON_BREAKING_SPACE_REGEX, ' ');\n    }).join(Browser.isWindows ? '\\r\\n' : '\\n');\n\n    return formattedResult;\n  }\n\n  /**\n   * Clears the current terminal selection.\n   */\n  public clearSelection(): void {\n    this._model.clearSelection();\n    this._removeMouseDownListeners();\n    this.refresh();\n    this._onSelectionChange.fire();\n  }\n\n  /**\n   * Queues a refresh, redrawing the selection on the next opportunity.\n   * @param isLinuxMouseSelection Whether the selection should be registered as a new\n   * selection on Linux.\n   */\n  public refresh(isLinuxMouseSelection?: boolean): void {\n    // Queue the refresh for the renderer\n    if (!this._refreshAnimationFrame) {\n      this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());\n    }\n\n    // If the platform is Linux and the refresh call comes from a mouse event,\n    // we need to update the selection for middle click to paste selection.\n    if (Browser.isLinux && isLinuxMouseSelection) {\n      const selectionText = this.selectionText;\n      if (selectionText.length) {\n        this._onLinuxMouseSelection.fire(this.selectionText);\n      }\n    }\n  }\n\n  /**\n   * Fires the refresh event, causing consumers to pick it up and redraw the\n   * selection state.\n   */\n  private _refresh(): void {\n    this._refreshAnimationFrame = undefined;\n    this._onRedrawRequest.fire({\n      start: this._model.finalSelectionStart,\n      end: this._model.finalSelectionEnd,\n      columnSelectMode: this._activeSelectionMode === SelectionMode.COLUMN\n    });\n  }\n\n  /**\n   * Checks if the current click was inside the current selection\n   * @param event The mouse event\n   */\n  public isClickInSelection(event: MouseEvent): boolean {\n    const coords = this._getMouseBufferCoords(event);\n    const start = this._model.finalSelectionStart;\n    const end = this._model.finalSelectionEnd;\n\n    if (!start || !end || !coords) {\n      return false;\n    }\n\n    return this._areCoordsInSelection(coords, start, end);\n  }\n\n  protected _areCoordsInSelection(coords: [number, number], start: [number, number], end: [number, number]): boolean {\n    return (coords[1] > start[1] && coords[1] < end[1]) ||\n        (start[1] === end[1] && coords[1] === start[1] && coords[0] >= start[0] && coords[0] < end[0]) ||\n        (start[1] < end[1] && coords[1] === end[1] && coords[0] < end[0]) ||\n        (start[1] < end[1] && coords[1] === start[1] && coords[0] >= start[0]);\n  }\n\n  /**\n   * Selects word at the current mouse event coordinates.\n   * @param event The mouse event.\n   */\n  public selectWordAtCursor(event: MouseEvent): void {\n    const coords = this._getMouseBufferCoords(event);\n    if (coords) {\n      this._selectWordAt(coords, false);\n      this._model.selectionEnd = undefined;\n      this.refresh(true);\n    }\n  }\n\n  /**\n   * Selects all text within the terminal.\n   */\n  public selectAll(): void {\n    this._model.isSelectAllActive = true;\n    this.refresh();\n    this._onSelectionChange.fire();\n  }\n\n  public selectLines(start: number, end: number): void {\n    this._model.clearSelection();\n    start = Math.max(start, 0);\n    end = Math.min(end, this._bufferService.buffer.lines.length - 1);\n    this._model.selectionStart = [0, start];\n    this._model.selectionEnd = [this._bufferService.cols, end];\n    this.refresh();\n    this._onSelectionChange.fire();\n  }\n\n  /**\n   * Handle the buffer being trimmed, adjust the selection position.\n   * @param amount The amount the buffer is being trimmed.\n   */\n  private _onTrim(amount: number): void {\n    const needsRefresh = this._model.onTrim(amount);\n    if (needsRefresh) {\n      this.refresh();\n    }\n  }\n\n  /**\n   * Gets the 0-based [x, y] buffer coordinates of the current mouse event.\n   * @param event The mouse event.\n   */\n  private _getMouseBufferCoords(event: MouseEvent): [number, number] | undefined {\n    const coords = this._mouseService.getCoords(event, this._screenElement, this._bufferService.cols, this._bufferService.rows, true);\n    if (!coords) {\n      return undefined;\n    }\n\n    // Convert to 0-based\n    coords[0]--;\n    coords[1]--;\n\n    // Convert viewport coords to buffer coords\n    coords[1] += this._bufferService.buffer.ydisp;\n    return coords;\n  }\n\n  /**\n   * Gets the amount the viewport should be scrolled based on how far out of the\n   * terminal the mouse is.\n   * @param event The mouse event.\n   */\n  private _getMouseEventScrollAmount(event: MouseEvent): number {\n    let offset = getCoordsRelativeToElement(event, this._screenElement)[1];\n    const terminalHeight = this._bufferService.rows * Math.ceil(this._charSizeService.height * this._optionsService.options.lineHeight);\n    if (offset >= 0 && offset <= terminalHeight) {\n      return 0;\n    }\n    if (offset > terminalHeight) {\n      offset -= terminalHeight;\n    }\n\n    offset = Math.min(Math.max(offset, -DRAG_SCROLL_MAX_THRESHOLD), DRAG_SCROLL_MAX_THRESHOLD);\n    offset /= DRAG_SCROLL_MAX_THRESHOLD;\n    return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1));\n  }\n\n  /**\n   * Returns whether the selection manager should force selection, regardless of\n   * whether the terminal is in mouse events mode.\n   * @param event The mouse event.\n   */\n  public shouldForceSelection(event: MouseEvent): boolean {\n    if (Browser.isMac) {\n      return event.altKey && this._optionsService.options.macOptionClickForcesSelection;\n    }\n\n    return event.shiftKey;\n  }\n\n  /**\n   * Handles te mousedown event, setting up for a new selection.\n   * @param event The mousedown event.\n   */\n  public onMouseDown(event: MouseEvent): void {\n    this._mouseDownTimeStamp = event.timeStamp;\n    // If we have selection, we want the context menu on right click even if the\n    // terminal is in mouse mode.\n    if (event.button === 2 && this.hasSelection) {\n      return;\n    }\n\n    // Only action the primary button\n    if (event.button !== 0) {\n      return;\n    }\n\n    // Allow selection when using a specific modifier key, even when disabled\n    if (!this._enabled) {\n      if (!this.shouldForceSelection(event)) {\n        return;\n      }\n\n      // Don't send the mouse down event to the current process, we want to select\n      event.stopPropagation();\n    }\n\n    // Tell the browser not to start a regular selection\n    event.preventDefault();\n\n    // Reset drag scroll state\n    this._dragScrollAmount = 0;\n\n    if (this._enabled && event.shiftKey) {\n      this._onIncrementalClick(event);\n    } else {\n      if (event.detail === 1) {\n        this._onSingleClick(event);\n      } else if (event.detail === 2) {\n        this._onDoubleClick(event);\n      } else if (event.detail === 3) {\n        this._onTripleClick(event);\n      }\n    }\n\n    this._addMouseDownListeners();\n    this.refresh(true);\n  }\n\n  /**\n   * Adds listeners when mousedown is triggered.\n   */\n  private _addMouseDownListeners(): void {\n    // Listen on the document so that dragging outside of viewport works\n    if (this._screenElement.ownerDocument) {\n      this._screenElement.ownerDocument.addEventListener('mousemove', this._mouseMoveListener);\n      this._screenElement.ownerDocument.addEventListener('mouseup', this._mouseUpListener);\n    }\n    this._dragScrollIntervalTimer = window.setInterval(() => this._dragScroll(), DRAG_SCROLL_INTERVAL);\n  }\n\n  /**\n   * Removes the listeners that are registered when mousedown is triggered.\n   */\n  private _removeMouseDownListeners(): void {\n    if (this._screenElement.ownerDocument) {\n      this._screenElement.ownerDocument.removeEventListener('mousemove', this._mouseMoveListener);\n      this._screenElement.ownerDocument.removeEventListener('mouseup', this._mouseUpListener);\n    }\n    clearInterval(this._dragScrollIntervalTimer);\n    this._dragScrollIntervalTimer = undefined;\n  }\n\n  /**\n   * Performs an incremental click, setting the selection end position to the mouse\n   * position.\n   * @param event The mouse event.\n   */\n  private _onIncrementalClick(event: MouseEvent): void {\n    if (this._model.selectionStart) {\n      this._model.selectionEnd = this._getMouseBufferCoords(event);\n    }\n  }\n\n  /**\n   * Performs a single click, resetting relevant state and setting the selection\n   * start position.\n   * @param event The mouse event.\n   */\n  private _onSingleClick(event: MouseEvent): void {\n    this._model.selectionStartLength = 0;\n    this._model.isSelectAllActive = false;\n    this._activeSelectionMode = this.shouldColumnSelect(event) ? SelectionMode.COLUMN : SelectionMode.NORMAL;\n\n    // Initialize the new selection\n    this._model.selectionStart = this._getMouseBufferCoords(event);\n    if (!this._model.selectionStart) {\n      return;\n    }\n    this._model.selectionEnd = undefined;\n\n    // Ensure the line exists\n    const line = this._bufferService.buffer.lines.get(this._model.selectionStart[1]);\n    if (!line) {\n      return;\n    }\n\n    // Return early if the click event is not in the buffer (eg. in scroll bar)\n    if (line.length === this._model.selectionStart[0]) {\n      return;\n    }\n\n    // If the mouse is over the second half of a wide character, adjust the\n    // selection to cover the whole character\n    if (line.hasWidth(this._model.selectionStart[0]) === 0) {\n      this._model.selectionStart[0]++;\n    }\n  }\n\n  /**\n   * Performs a double click, selecting the current work.\n   * @param event The mouse event.\n   */\n  private _onDoubleClick(event: MouseEvent): void {\n    const coords = this._getMouseBufferCoords(event);\n    if (coords) {\n      this._activeSelectionMode = SelectionMode.WORD;\n      this._selectWordAt(coords, true);\n    }\n  }\n\n  /**\n   * Performs a triple click, selecting the current line and activating line\n   * select mode.\n   * @param event The mouse event.\n   */\n  private _onTripleClick(event: MouseEvent): void {\n    const coords = this._getMouseBufferCoords(event);\n    if (coords) {\n      this._activeSelectionMode = SelectionMode.LINE;\n      this._selectLineAt(coords[1]);\n    }\n  }\n\n  /**\n   * Returns whether the selection manager should operate in column select mode\n   * @param event the mouse or keyboard event\n   */\n  public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean {\n    return event.altKey && !(Browser.isMac && this._optionsService.options.macOptionClickForcesSelection);\n  }\n\n  /**\n   * Handles the mousemove event when the mouse button is down, recording the\n   * end of the selection and refreshing the selection.\n   * @param event The mousemove event.\n   */\n  private _onMouseMove(event: MouseEvent): void {\n    // If the mousemove listener is active it means that a selection is\n    // currently being made, we should stop propagation to prevent mouse events\n    // to be sent to the pty.\n    event.stopImmediatePropagation();\n\n    // Do nothing if there is no selection start, this can happen if the first\n    // click in the terminal is an incremental click\n    if (!this._model.selectionStart) {\n      return;\n    }\n\n    // Record the previous position so we know whether to redraw the selection\n    // at the end.\n    const previousSelectionEnd = this._model.selectionEnd ? [this._model.selectionEnd[0], this._model.selectionEnd[1]] : null;\n\n    // Set the initial selection end based on the mouse coordinates\n    this._model.selectionEnd = this._getMouseBufferCoords(event);\n    if (!this._model.selectionEnd) {\n      this.refresh(true);\n      return;\n    }\n\n    // Select the entire line if line select mode is active.\n    if (this._activeSelectionMode === SelectionMode.LINE) {\n      if (this._model.selectionEnd[1] < this._model.selectionStart[1]) {\n        this._model.selectionEnd[0] = 0;\n      } else {\n        this._model.selectionEnd[0] = this._bufferService.cols;\n      }\n    } else if (this._activeSelectionMode === SelectionMode.WORD) {\n      this._selectToWordAt(this._model.selectionEnd);\n    }\n\n    // Determine the amount of scrolling that will happen.\n    this._dragScrollAmount = this._getMouseEventScrollAmount(event);\n\n    // If the cursor was above or below the viewport, make sure it's at the\n    // start or end of the viewport respectively. This should only happen when\n    // NOT in column select mode.\n    if (this._activeSelectionMode !== SelectionMode.COLUMN) {\n      if (this._dragScrollAmount > 0) {\n        this._model.selectionEnd[0] = this._bufferService.cols;\n      } else if (this._dragScrollAmount < 0) {\n        this._model.selectionEnd[0] = 0;\n      }\n    }\n\n    // If the character is a wide character include the cell to the right in the\n    // selection. Note that selections at the very end of the line will never\n    // have a character.\n    const buffer = this._bufferService.buffer;\n    if (this._model.selectionEnd[1] < buffer.lines.length) {\n      const line = buffer.lines.get(this._model.selectionEnd[1]);\n      if (line && line.hasWidth(this._model.selectionEnd[0]) === 0) {\n        this._model.selectionEnd[0]++;\n      }\n    }\n\n    // Only draw here if the selection changes.\n    if (!previousSelectionEnd ||\n      previousSelectionEnd[0] !== this._model.selectionEnd[0] ||\n      previousSelectionEnd[1] !== this._model.selectionEnd[1]) {\n      this.refresh(true);\n    }\n  }\n\n  /**\n   * The callback that occurs every DRAG_SCROLL_INTERVAL ms that does the\n   * scrolling of the viewport.\n   */\n  private _dragScroll(): void {\n    if (!this._model.selectionEnd || !this._model.selectionStart) {\n      return;\n    }\n    if (this._dragScrollAmount) {\n      this._scrollLines(this._dragScrollAmount, false);\n      // Re-evaluate selection\n      // If the cursor was above or below the viewport, make sure it's at the\n      // start or end of the viewport respectively. This should only happen when\n      // NOT in column select mode.\n      const buffer = this._bufferService.buffer;\n      if (this._dragScrollAmount > 0) {\n        if (this._activeSelectionMode !== SelectionMode.COLUMN) {\n          this._model.selectionEnd[0] = this._bufferService.cols;\n        }\n        this._model.selectionEnd[1] = Math.min(buffer.ydisp + this._bufferService.rows, buffer.lines.length - 1);\n      } else {\n        if (this._activeSelectionMode !== SelectionMode.COLUMN) {\n          this._model.selectionEnd[0] = 0;\n        }\n        this._model.selectionEnd[1] = buffer.ydisp;\n      }\n      this.refresh();\n    }\n  }\n\n  /**\n   * Handles the mouseup event, removing the mousedown listeners.\n   * @param event The mouseup event.\n   */\n  private _onMouseUp(event: MouseEvent): void {\n    const timeElapsed = event.timeStamp - this._mouseDownTimeStamp;\n\n    this._removeMouseDownListeners();\n\n    if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME) {\n      if (event.altKey && this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) {\n        const coordinates = this._mouseService.getCoords(\n          event,\n          this._element,\n          this._bufferService.cols,\n          this._bufferService.rows,\n          false\n        );\n        if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) {\n          const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys);\n          this._coreService.triggerDataEvent(sequence, true);\n        }\n      }\n    } else if (this.hasSelection) {\n      this._onSelectionChange.fire();\n    }\n  }\n\n  private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {\n    this.clearSelection();\n    // Only adjust the selection on trim, shiftElements is rarely used (only in\n    // reverseIndex) and delete in a splice is only ever used when the same\n    // number of elements was just added. Given this is could actually be\n    // beneficial to leave the selection as is for these cases.\n    this._trimListener.dispose();\n    this._trimListener = e.activeBuffer.lines.onTrim(amount => this._onTrim(amount));\n  }\n\n  /**\n   * Converts a viewport column to the character index on the buffer line, the\n   * latter takes into account wide characters.\n   * @param coords The coordinates to find the 2 index for.\n   */\n  private _convertViewportColToCharacterIndex(bufferLine: IBufferLine, coords: [number, number]): number {\n    let charIndex = coords[0];\n    for (let i = 0; coords[0] >= i; i++) {\n      const length = bufferLine.loadCell(i, this._workCell).getChars().length;\n      if (this._workCell.getWidth() === 0) {\n        // Wide characters aren't included in the line string so decrement the\n        // index so the index is back on the wide character.\n        charIndex--;\n      } else if (length > 1 && coords[0] !== i) {\n        // Emojis take up multiple characters, so adjust accordingly. For these\n        // we don't want ot include the character at the column as we're\n        // returning the start index in the string, not the end index.\n        charIndex += length - 1;\n      }\n    }\n    return charIndex;\n  }\n\n  public setSelection(col: number, row: number, length: number): void {\n    this._model.clearSelection();\n    this._removeMouseDownListeners();\n    this._model.selectionStart = [col, row];\n    this._model.selectionStartLength = length;\n    this.refresh();\n  }\n\n  /**\n   * Gets positional information for the word at the coordinated specified.\n   * @param coords The coordinates to get the word at.\n   */\n  private _getWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean, followWrappedLinesAbove: boolean = true, followWrappedLinesBelow: boolean = true): IWordPosition | undefined {\n    // Ensure coords are within viewport (eg. not within scroll bar)\n    if (coords[0] >= this._bufferService.cols) {\n      return undefined;\n    }\n\n    const buffer = this._bufferService.buffer;\n    const bufferLine = buffer.lines.get(coords[1]);\n    if (!bufferLine) {\n      return undefined;\n    }\n\n    const line = buffer.translateBufferLineToString(coords[1], false);\n\n    // Get actual index, taking into consideration wide characters\n    let startIndex = this._convertViewportColToCharacterIndex(bufferLine, coords);\n    let endIndex = startIndex;\n\n    // Record offset to be used later\n    const charOffset = coords[0] - startIndex;\n    let leftWideCharCount = 0;\n    let rightWideCharCount = 0;\n    let leftLongCharOffset = 0;\n    let rightLongCharOffset = 0;\n\n    if (line.charAt(startIndex) === ' ') {\n      // Expand until non-whitespace is hit\n      while (startIndex > 0 && line.charAt(startIndex - 1) === ' ') {\n        startIndex--;\n      }\n      while (endIndex < line.length && line.charAt(endIndex + 1) === ' ') {\n        endIndex++;\n      }\n    } else {\n      // Expand until whitespace is hit. This algorithm works by scanning left\n      // and right from the starting position, keeping both the index format\n      // (line) and the column format (bufferLine) in sync. When a wide\n      // character is hit, it is recorded and the column index is adjusted.\n      let startCol = coords[0];\n      let endCol = coords[0];\n\n      // Consider the initial position, skip it and increment the wide char\n      // variable\n      if (bufferLine.getWidth(startCol) === 0) {\n        leftWideCharCount++;\n        startCol--;\n      }\n      if (bufferLine.getWidth(endCol) === 2) {\n        rightWideCharCount++;\n        endCol++;\n      }\n\n      // Adjust the end index for characters whose length are > 1 (emojis)\n      const length = bufferLine.getString(endCol).length;\n      if (length > 1) {\n        rightLongCharOffset += length - 1;\n        endIndex += length - 1;\n      }\n\n      // Expand the string in both directions until a space is hit\n      while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine.loadCell(startCol - 1, this._workCell))) {\n        bufferLine.loadCell(startCol - 1, this._workCell);\n        const length = this._workCell.getChars().length;\n        if (this._workCell.getWidth() === 0) {\n          // If the next character is a wide char, record it and skip the column\n          leftWideCharCount++;\n          startCol--;\n        } else if (length > 1) {\n          // If the next character's string is longer than 1 char (eg. emoji),\n          // adjust the index\n          leftLongCharOffset += length - 1;\n          startIndex -= length - 1;\n        }\n        startIndex--;\n        startCol--;\n      }\n      while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine.loadCell(endCol + 1, this._workCell))) {\n        bufferLine.loadCell(endCol + 1, this._workCell);\n        const length = this._workCell.getChars().length;\n        if (this._workCell.getWidth() === 2) {\n          // If the next character is a wide char, record it and skip the column\n          rightWideCharCount++;\n          endCol++;\n        } else if (length > 1) {\n          // If the next character's string is longer than 1 char (eg. emoji),\n          // adjust the index\n          rightLongCharOffset += length - 1;\n          endIndex += length - 1;\n        }\n        endIndex++;\n        endCol++;\n      }\n    }\n\n    // Incremenet the end index so it is at the start of the next character\n    endIndex++;\n\n    // Calculate the start _column_, converting the the string indexes back to\n    // column coordinates.\n    let start =\n        startIndex // The index of the selection's start char in the line string\n        + charOffset // The difference between the initial char's column and index\n        - leftWideCharCount // The number of wide chars left of the initial char\n        + leftLongCharOffset; // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)\n\n    // Calculate the length in _columns_, converting the the string indexes back\n    // to column coordinates.\n    let length = Math.min(this._bufferService.cols, // Disallow lengths larger than the terminal cols\n        endIndex // The index of the selection's end char in the line string\n        - startIndex // The index of the selection's start char in the line string\n        + leftWideCharCount // The number of wide chars left of the initial char\n        + rightWideCharCount // The number of wide chars right of the initial char (inclusive)\n        - leftLongCharOffset // The number of additional chars left of the initial char added by columns with strings longer than 1 (emojis)\n        - rightLongCharOffset); // The number of additional chars right of the initial char (inclusive) added by columns with strings longer than 1 (emojis)\n\n    if (!allowWhitespaceOnlySelection && line.slice(startIndex, endIndex).trim() === '') {\n      return undefined;\n    }\n\n    // Recurse upwards if the line is wrapped and the word wraps to the above line\n    if (followWrappedLinesAbove) {\n      if (start === 0 && bufferLine.getCodePoint(0) !== 32 /*' '*/) {\n        const previousBufferLine = buffer.lines.get(coords[1] - 1);\n        if (previousBufferLine && bufferLine.isWrapped && previousBufferLine.getCodePoint(this._bufferService.cols - 1) !== 32 /*' '*/) {\n          const previousLineWordPosition = this._getWordAt([this._bufferService.cols - 1, coords[1] - 1], false, true, false);\n          if (previousLineWordPosition) {\n            const offset = this._bufferService.cols - previousLineWordPosition.start;\n            start -= offset;\n            length += offset;\n          }\n        }\n      }\n    }\n\n    // Recurse downwards if the line is wrapped and the word wraps to the next line\n    if (followWrappedLinesBelow) {\n      if (start + length === this._bufferService.cols && bufferLine.getCodePoint(this._bufferService.cols - 1) !== 32 /*' '*/) {\n        const nextBufferLine = buffer.lines.get(coords[1] + 1);\n        if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32 /*' '*/) {\n          const nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);\n          if (nextLineWordPosition) {\n            length += nextLineWordPosition.length;\n          }\n        }\n      }\n    }\n\n    return { start, length };\n  }\n\n  /**\n   * Selects the word at the coordinates specified.\n   * @param coords The coordinates to get the word at.\n   * @param allowWhitespaceOnlySelection If whitespace should be selected\n   */\n  protected _selectWordAt(coords: [number, number], allowWhitespaceOnlySelection: boolean): void {\n    const wordPosition = this._getWordAt(coords, allowWhitespaceOnlySelection);\n    if (wordPosition) {\n      // Adjust negative start value\n      while (wordPosition.start < 0) {\n        wordPosition.start += this._bufferService.cols;\n        coords[1]--;\n      }\n      this._model.selectionStart = [wordPosition.start, coords[1]];\n      this._model.selectionStartLength = wordPosition.length;\n    }\n  }\n\n  /**\n   * Sets the selection end to the word at the coordinated specified.\n   * @param coords The coordinates to get the word at.\n   */\n  private _selectToWordAt(coords: [number, number]): void {\n    const wordPosition = this._getWordAt(coords, true);\n    if (wordPosition) {\n      let endRow = coords[1];\n\n      // Adjust negative start value\n      while (wordPosition.start < 0) {\n        wordPosition.start += this._bufferService.cols;\n        endRow--;\n      }\n\n      // Adjust wrapped length value, this only needs to happen when values are reversed as in that\n      // case we're interested in the start of the word, not the end\n      if (!this._model.areSelectionValuesReversed()) {\n        while (wordPosition.start + wordPosition.length > this._bufferService.cols) {\n          wordPosition.length -= this._bufferService.cols;\n          endRow++;\n        }\n      }\n\n      this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : wordPosition.start + wordPosition.length, endRow];\n    }\n  }\n\n  /**\n   * Gets whether the character is considered a word separator by the select\n   * word logic.\n   * @param char The character to check.\n   */\n  private _isCharWordSeparator(cell: CellData): boolean {\n    // Zero width characters are never separators as they are always to the\n    // right of wide characters\n    if (cell.getWidth() === 0) {\n      return false;\n    }\n    return this._optionsService.options.wordSeparator.indexOf(cell.getChars()) >= 0;\n  }\n\n  /**\n   * Selects the line specified.\n   * @param line The line index.\n   */\n  protected _selectLineAt(line: number): void {\n    const wrappedRange = this._bufferService.buffer.getWrappedRangeForLine(line);\n    this._model.selectionStart = [0, wrappedRange.first];\n    this._model.selectionEnd = [this._bufferService.cols, wrappedRange.last];\n    this._model.selectionStartLength = 0;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IBufferService } from 'common/services/Services';\n\n/**\n * Represents a selection within the buffer. This model only cares about column\n * and row coordinates, not wide characters.\n */\nexport class SelectionModel {\n  /**\n   * Whether select all is currently active.\n   */\n  public isSelectAllActive: boolean = false;\n\n  /**\n   * The minimal length of the selection from the start position. When double\n   * clicking on a word, the word will be selected which makes the selection\n   * start at the start of the word and makes this variable the length.\n   */\n  public selectionStartLength: number = 0;\n\n  /**\n   * The [x, y] position the selection starts at.\n   */\n  public selectionStart: [number, number] | undefined;\n\n  /**\n   * The [x, y] position the selection ends at.\n   */\n  public selectionEnd: [number, number] | undefined;\n\n  constructor(\n    private _bufferService: IBufferService\n  ) {\n  }\n\n  /**\n   * Clears the current selection.\n   */\n  public clearSelection(): void {\n    this.selectionStart = undefined;\n    this.selectionEnd = undefined;\n    this.isSelectAllActive = false;\n    this.selectionStartLength = 0;\n  }\n\n  /**\n   * The final selection start, taking into consideration select all.\n   */\n  public get finalSelectionStart(): [number, number] | undefined {\n    if (this.isSelectAllActive) {\n      return [0, 0];\n    }\n\n    if (!this.selectionEnd || !this.selectionStart) {\n      return this.selectionStart;\n    }\n\n    return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;\n  }\n\n  /**\n   * The final selection end, taking into consideration select all, double click\n   * word selection and triple click line selection.\n   */\n  public get finalSelectionEnd(): [number, number] | undefined {\n    if (this.isSelectAllActive) {\n      return [this._bufferService.cols, this._bufferService.buffer.ybase + this._bufferService.rows - 1];\n    }\n\n    if (!this.selectionStart) {\n      return undefined;\n    }\n\n    // Use the selection start + length if the end doesn't exist or they're reversed\n    if (!this.selectionEnd || this.areSelectionValuesReversed()) {\n      const startPlusLength = this.selectionStart[0] + this.selectionStartLength;\n      if (startPlusLength > this._bufferService.cols) {\n        return [startPlusLength % this._bufferService.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._bufferService.cols)];\n      }\n      return [startPlusLength, this.selectionStart[1]];\n    }\n\n    // Ensure the the word/line is selected after a double/triple click\n    if (this.selectionStartLength) {\n      // Select the larger of the two when start and end are on the same line\n      if (this.selectionEnd[1] === this.selectionStart[1]) {\n        return [Math.max(this.selectionStart[0] + this.selectionStartLength, this.selectionEnd[0]), this.selectionEnd[1]];\n      }\n    }\n    return this.selectionEnd;\n  }\n\n  /**\n   * Returns whether the selection start and end are reversed.\n   */\n  public areSelectionValuesReversed(): boolean {\n    const start = this.selectionStart;\n    const end = this.selectionEnd;\n    if (!start || !end) {\n      return false;\n    }\n    return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);\n  }\n\n  /**\n   * Handle the buffer being trimmed, adjust the selection position.\n   * @param amount The amount the buffer is being trimmed.\n   * @return Whether a refresh is necessary.\n   */\n  public onTrim(amount: number): boolean {\n    // Adjust the selection position based on the trimmed amount.\n    if (this.selectionStart) {\n      this.selectionStart[1] -= amount;\n    }\n    if (this.selectionEnd) {\n      this.selectionEnd[1] -= amount;\n    }\n\n    // The selection has moved off the buffer, clear it.\n    if (this.selectionEnd && this.selectionEnd[1] < 0) {\n      this.clearSelection();\n      return true;\n    }\n\n    // If the selection start is trimmed, ensure the start column is 0.\n    if (this.selectionStart && this.selectionStart[1] < 0) {\n      this.selectionStart[1] = 0;\n    }\n    return false;\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { C0 } from 'common/data/EscapeSequences';\nimport { IBufferService } from 'common/services/Services';\n\nconst enum Direction {\n  UP = 'A',\n  DOWN = 'B',\n  RIGHT = 'C',\n  LEFT = 'D'\n}\n\n/**\n * Concatenates all the arrow sequences together.\n * Resets the starting row to an unwrapped row, moves to the requested row,\n * then moves to requested col.\n */\nexport function moveToCellSequence(targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {\n  const startX = bufferService.buffer.x;\n  const startY = bufferService.buffer.y;\n\n  // The alt buffer should try to navigate between rows\n  if (!bufferService.buffer.hasScrollback) {\n    return resetStartingRow(startX, startY, targetX, targetY, bufferService, applicationCursor) +\n      moveToRequestedRow(startY, targetY, bufferService, applicationCursor) +\n      moveToRequestedCol(startX, startY, targetX, targetY, bufferService, applicationCursor);\n  }\n\n  // Only move horizontally for the normal buffer\n  return moveHorizontallyOnly(startX, startY, targetX, targetY, bufferService, applicationCursor);\n}\n\n/**\n * If the initial position of the cursor is on a row that is wrapped, move the\n * cursor up to the first row that is not wrapped to have accurate vertical\n * positioning.\n */\nfunction resetStartingRow(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {\n  if (moveToRequestedRow(startY, targetY, bufferService, applicationCursor).length === 0) {\n    return '';\n  }\n  return repeat(bufferLine(\n    startX, startY, startX,\n    startY - wrappedRowsForRow(bufferService, startY), false, bufferService\n  ).length, sequence(Direction.LEFT, applicationCursor));\n}\n\n/**\n * Using the reset starting and ending row, move to the requested row,\n * ignoring wrapped rows\n */\nfunction moveToRequestedRow(startY: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {\n  const startRow = startY - wrappedRowsForRow(bufferService, startY);\n  const endRow = targetY - wrappedRowsForRow(bufferService, targetY);\n\n  const rowsToMove = Math.abs(startRow - endRow) - wrappedRowsCount(startY, targetY, bufferService);\n\n  return repeat(rowsToMove, sequence(verticalDirection(startY, targetY), applicationCursor));\n}\n\n/**\n * Move to the requested col on the ending row\n */\nfunction moveToRequestedCol(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {\n  let startRow;\n  if (moveToRequestedRow(startY, targetY, bufferService, applicationCursor).length > 0) {\n    startRow = targetY - wrappedRowsForRow(bufferService, targetY);\n  } else {\n    startRow = startY;\n  }\n\n  const endRow = targetY;\n  const direction = horizontalDirection(startX, startY, targetX, targetY, bufferService, applicationCursor);\n\n  return repeat(bufferLine(\n    startX, startRow, targetX, endRow,\n    direction === Direction.RIGHT, bufferService\n  ).length, sequence(direction, applicationCursor));\n}\n\nfunction moveHorizontallyOnly(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): string {\n  const direction = horizontalDirection(startX, startY, targetX, targetY, bufferService, applicationCursor);\n  return repeat(Math.abs(startX - targetX), sequence(direction, applicationCursor));\n}\n\n/**\n * Utility functions\n */\n\n/**\n * Calculates the number of wrapped rows between the unwrapped starting and\n * ending rows. These rows need to ignored since the cursor skips over them.\n */\nfunction wrappedRowsCount(startY: number, targetY: number, bufferService: IBufferService): number {\n  let wrappedRows = 0;\n  const startRow = startY - wrappedRowsForRow(bufferService, startY);\n  const endRow = targetY - wrappedRowsForRow(bufferService, targetY);\n\n  for (let i = 0; i < Math.abs(startRow - endRow); i++) {\n    const direction = verticalDirection(startY, targetY) === Direction.UP ? -1 : 1;\n    const line = bufferService.buffer.lines.get(startRow + (direction * i));\n    if (line && line.isWrapped) {\n      wrappedRows++;\n    }\n  }\n\n  return wrappedRows;\n}\n\n/**\n * Calculates the number of wrapped rows that make up a given row.\n * @param currentRow The row to determine how many wrapped rows make it up\n */\nfunction wrappedRowsForRow(bufferService: IBufferService, currentRow: number): number {\n  let rowCount = 0;\n  let line = bufferService.buffer.lines.get(currentRow);\n  let lineWraps = line && line.isWrapped;\n\n  while (lineWraps && currentRow >= 0 && currentRow < bufferService.rows) {\n    rowCount++;\n    line = bufferService.buffer.lines.get(--currentRow);\n    lineWraps = line && line.isWrapped;\n  }\n\n  return rowCount;\n}\n\n/**\n * Direction determiners\n */\n\n/**\n * Determines if the right or left arrow is needed\n */\nfunction horizontalDirection(startX: number, startY: number, targetX: number, targetY: number, bufferService: IBufferService, applicationCursor: boolean): Direction {\n  let startRow;\n  if (moveToRequestedRow(targetX, targetY, bufferService, applicationCursor).length > 0) {\n    startRow = targetY - wrappedRowsForRow(bufferService, targetY);\n  } else {\n    startRow = startY;\n  }\n\n  if ((startX < targetX &&\n    startRow <= targetY) || // down/right or same y/right\n    (startX >= targetX &&\n    startRow < targetY)) {  // down/left or same y/left\n    return Direction.RIGHT;\n  }\n  return Direction.LEFT;\n}\n\n/**\n * Determines if the up or down arrow is needed\n */\nfunction verticalDirection(startY: number, targetY: number): Direction {\n  return startY > targetY ? Direction.UP : Direction.DOWN;\n}\n\n/**\n * Constructs the string of chars in the buffer from a starting row and col\n * to an ending row and col\n * @param startCol The starting column position\n * @param startRow The starting row position\n * @param endCol The ending column position\n * @param endRow The ending row position\n * @param forward Direction to move\n */\nfunction bufferLine(\n  startCol: number,\n  startRow: number,\n  endCol: number,\n  endRow: number,\n  forward: boolean,\n  bufferService: IBufferService\n): string {\n  let currentCol = startCol;\n  let currentRow = startRow;\n  let bufferStr = '';\n\n  while (currentCol !== endCol || currentRow !== endRow) {\n    currentCol += forward ? 1 : -1;\n\n    if (forward && currentCol > bufferService.cols - 1) {\n      bufferStr += bufferService.buffer.translateBufferLineToString(\n        currentRow, false, startCol, currentCol\n      );\n      currentCol = 0;\n      startCol = 0;\n      currentRow++;\n    } else if (!forward && currentCol < 0) {\n      bufferStr += bufferService.buffer.translateBufferLineToString(\n        currentRow, false, 0, startCol + 1\n      );\n      currentCol = bufferService.cols - 1;\n      startCol = currentCol;\n      currentRow--;\n    }\n  }\n\n  return bufferStr + bufferService.buffer.translateBufferLineToString(\n    currentRow, false, startCol, currentCol\n  );\n}\n\n/**\n * Constructs the escape sequence for clicking an arrow\n * @param direction The direction to move\n */\nfunction sequence(direction: Direction, applicationCursor: boolean): string {\n  const mod =  applicationCursor ? 'O' : '[';\n  return C0.ESC + mod + direction;\n}\n\n/**\n * Returns a string repeated a given number of times\n * Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat\n * @param count The number of times to repeat the string\n * @param string The string that is to be repeated\n */\nfunction repeat(count: number, str: string): string {\n  count = Math.floor(count);\n  let rpt = '';\n  for (let i = 0; i < count; i++) {\n    rpt += str;\n  }\n  return rpt;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IOptionsService } from 'common/services/Services';\nimport { ISoundService } from 'browser/services/Services';\n\nexport class SoundService implements ISoundService {\n  serviceBrand: any;\n\n  private static _audioContext: AudioContext;\n\n  static get audioContext(): AudioContext | null {\n    if (!SoundService._audioContext) {\n      const audioContextCtor: typeof AudioContext = (<any>window).AudioContext || (<any>window).webkitAudioContext;\n      if (!audioContextCtor) {\n        console.warn('Web Audio API is not supported by this browser. Consider upgrading to the latest version');\n        return null;\n      }\n      SoundService._audioContext = new audioContextCtor();\n    }\n    return SoundService._audioContext;\n  }\n\n  constructor(\n    @IOptionsService private _optionsService: IOptionsService\n  ) {\n  }\n\n  public playBellSound(): void {\n    const ctx = SoundService.audioContext;\n    if (!ctx) {\n      return;\n    }\n    const bellAudioSource = ctx.createBufferSource();\n    ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.options.bellSound)), (buffer) => {\n      bellAudioSource.buffer = buffer;\n      bellAudioSource.connect(ctx.destination);\n      bellAudioSource.start(0);\n    });\n  }\n\n  private _base64ToArrayBuffer(base64: string): ArrayBuffer {\n    const binaryString = window.atob(base64);\n    const len = binaryString.length;\n    const bytes = new Uint8Array(len);\n\n    for (let i = 0; i < len; i++) {\n      bytes[i] = binaryString.charCodeAt(i);\n    }\n\n    return bytes.buffer;\n  }\n\n  private _removeMimeType(dataURI: string): string {\n    // Split the input to get the mime-type and the data itself\n    const splitUri = dataURI.split(',');\n\n    // Return only the data\n    return splitUri[1];\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Disposable } from 'common/Lifecycle';\nimport { addDisposableDomListener } from 'browser/Lifecycle';\nimport { IMouseService, ISelectionService } from 'browser/services/Services';\nimport { IMouseZoneManager, IMouseZone } from 'browser/Types';\nimport { IBufferService } from 'common/services/Services';\n\nconst HOVER_DURATION = 500;\n\n/**\n * The MouseZoneManager allows components to register zones within the terminal\n * that trigger hover and click callbacks.\n *\n * This class was intentionally made not so robust initially as the only case it\n * needed to support was single-line links which never overlap. Improvements can\n * be made in the future.\n */\nexport class MouseZoneManager extends Disposable implements IMouseZoneManager {\n  private _zones: IMouseZone[] = [];\n\n  private _areZonesActive: boolean = false;\n  private _mouseMoveListener: (e: MouseEvent) => any;\n  private _mouseLeaveListener: (e: MouseEvent) => any;\n  private _clickListener: (e: MouseEvent) => any;\n\n  private _tooltipTimeout: number | undefined;\n  private _currentZone: IMouseZone | undefined;\n  private _lastHoverCoords: [number | undefined, number | undefined] = [undefined, undefined];\n  private _initialSelectionLength: number = 0;\n\n  constructor(\n    private readonly _element: HTMLElement,\n    private readonly _screenElement: HTMLElement,\n    @IBufferService private readonly _bufferService: IBufferService,\n    @IMouseService private readonly _mouseService: IMouseService,\n    @ISelectionService private readonly _selectionService: ISelectionService\n  ) {\n    super();\n\n    this.register(addDisposableDomListener(this._element, 'mousedown', e => this._onMouseDown(e)));\n\n    // These events are expensive, only listen to it when mouse zones are active\n    this._mouseMoveListener = e => this._onMouseMove(e);\n    this._mouseLeaveListener = e => this._onMouseLeave(e);\n    this._clickListener = e => this._onClick(e);\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._deactivate();\n  }\n\n  public add(zone: IMouseZone): void {\n    this._zones.push(zone);\n    if (this._zones.length === 1) {\n      this._activate();\n    }\n  }\n\n  public clearAll(start?: number, end?: number): void {\n    // Exit if there's nothing to clear\n    if (this._zones.length === 0) {\n      return;\n    }\n\n    // Clear all if start/end weren't set\n    if (!start || !end) {\n      start = 0;\n      end = this._bufferService.rows - 1;\n    }\n\n    // Iterate through zones and clear them out if they're within the range\n    for (let i = 0; i < this._zones.length; i++) {\n      const zone = this._zones[i];\n      if ((zone.y1 > start && zone.y1 <= end + 1) ||\n          (zone.y2 > start && zone.y2 <= end + 1) ||\n          (zone.y1 < start && zone.y2 > end + 1)) {\n        if (this._currentZone && this._currentZone === zone) {\n          this._currentZone.leaveCallback();\n          this._currentZone = undefined;\n        }\n        this._zones.splice(i--, 1);\n      }\n    }\n\n    // Deactivate the mouse zone manager if all the zones have been removed\n    if (this._zones.length === 0) {\n      this._deactivate();\n    }\n  }\n\n  private _activate(): void {\n    if (!this._areZonesActive) {\n      this._areZonesActive = true;\n      this._element.addEventListener('mousemove', this._mouseMoveListener);\n      this._element.addEventListener('mouseleave', this._mouseLeaveListener);\n      this._element.addEventListener('click', this._clickListener);\n    }\n  }\n\n  private _deactivate(): void {\n    if (this._areZonesActive) {\n      this._areZonesActive = false;\n      this._element.removeEventListener('mousemove', this._mouseMoveListener);\n      this._element.removeEventListener('mouseleave', this._mouseLeaveListener);\n      this._element.removeEventListener('click', this._clickListener);\n    }\n  }\n\n  private _onMouseMove(e: MouseEvent): void {\n    // TODO: Ideally this would only clear the hover state when the mouse moves\n    // outside of the mouse zone\n    if (this._lastHoverCoords[0] !== e.pageX || this._lastHoverCoords[1] !== e.pageY) {\n      this._onHover(e);\n      // Record the current coordinates\n      this._lastHoverCoords = [e.pageX, e.pageY];\n    }\n  }\n\n  private _onHover(e: MouseEvent): void {\n    const zone = this._findZoneEventAt(e);\n\n    // Do nothing if the zone is the same\n    if (zone === this._currentZone) {\n      return;\n    }\n\n    // Fire the hover end callback and cancel any existing timer if a new zone\n    // is being hovered\n    if (this._currentZone) {\n      this._currentZone.leaveCallback();\n      this._currentZone = undefined;\n      if (this._tooltipTimeout) {\n        clearTimeout(this._tooltipTimeout);\n      }\n    }\n\n    // Exit if there is not zone\n    if (!zone) {\n      return;\n    }\n    this._currentZone = zone;\n\n    // Trigger the hover callback\n    if (zone.hoverCallback) {\n      zone.hoverCallback(e);\n    }\n\n    // Restart the tooltip timeout\n    this._tooltipTimeout = <number><any>setTimeout(() => this._onTooltip(e), HOVER_DURATION);\n  }\n\n  private _onTooltip(e: MouseEvent): void {\n    this._tooltipTimeout = undefined;\n    const zone = this._findZoneEventAt(e);\n    if (zone && zone.tooltipCallback) {\n      zone.tooltipCallback(e);\n    }\n  }\n\n  private _onMouseDown(e: MouseEvent): void {\n    // Store current terminal selection length, to check if we're performing\n    // a selection operation\n    this._initialSelectionLength = this._getSelectionLength();\n\n    // Ignore the event if there are no zones active\n    if (!this._areZonesActive) {\n      return;\n    }\n\n    // Find the active zone, prevent event propagation if found to prevent other\n    // components from handling the mouse event.\n    const zone = this._findZoneEventAt(e);\n    if (zone?.willLinkActivate(e)) {\n      e.preventDefault();\n      e.stopImmediatePropagation();\n    }\n  }\n\n  private _onMouseLeave(e: MouseEvent): void {\n    // Fire the hover end callback and cancel any existing timer if the mouse\n    // leaves the terminal element\n    if (this._currentZone) {\n      this._currentZone.leaveCallback();\n      this._currentZone = undefined;\n      if (this._tooltipTimeout) {\n        clearTimeout(this._tooltipTimeout);\n      }\n    }\n  }\n\n  private _onClick(e: MouseEvent): void {\n    // Find the active zone and click it if found and no selection was\n    // being performed\n    const zone = this._findZoneEventAt(e);\n    const currentSelectionLength = this._getSelectionLength();\n\n    if (zone && currentSelectionLength === this._initialSelectionLength) {\n      zone.clickCallback(e);\n      e.preventDefault();\n      e.stopImmediatePropagation();\n    }\n  }\n\n  private _getSelectionLength(): number {\n    const selectionText = this._selectionService.selectionText;\n    return selectionText ? selectionText.length : 0;\n  }\n\n  private _findZoneEventAt(e: MouseEvent): IMouseZone | undefined {\n    const coords = this._mouseService.getCoords(e, this._screenElement, this._bufferService.cols, this._bufferService.rows);\n    if (!coords) {\n      return undefined;\n    }\n    const x = coords[0];\n    const y = coords[1];\n    for (let i = 0; i < this._zones.length; i++) {\n      const zone = this._zones[i];\n      if (zone.y1 === zone.y2) {\n        // Single line link\n        if (y === zone.y1 && x >= zone.x1 && x < zone.x2) {\n          return zone;\n        }\n      } else {\n        // Multi-line link\n        if ((y === zone.y1 && x >= zone.x1) ||\n            (y === zone.y2 && x < zone.x2) ||\n            (y > zone.y1 && y < zone.y2)) {\n          return zone;\n        }\n      }\n    }\n    return undefined;\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport * as Strings from './browser/LocalizableStrings';\nimport { ITerminal } from './Types';\nimport { IBuffer } from 'common/buffer/Types';\nimport { isMac } from 'common/Platform';\nimport { RenderDebouncer } from 'browser/RenderDebouncer';\nimport { addDisposableDomListener } from 'browser/Lifecycle';\nimport { Disposable } from 'common/Lifecycle';\nimport { ScreenDprMonitor } from 'browser/ScreenDprMonitor';\nimport { IRenderService } from 'browser/services/Services';\n\nconst MAX_ROWS_TO_READ = 20;\n\nconst enum BoundaryPosition {\n  TOP,\n  BOTTOM\n}\n\nexport class AccessibilityManager extends Disposable {\n  private _accessibilityTreeRoot: HTMLElement;\n  private _rowContainer: HTMLElement;\n  private _rowElements: HTMLElement[];\n  private _liveRegion: HTMLElement;\n  private _liveRegionLineCount: number = 0;\n\n  private _renderRowsDebouncer: RenderDebouncer;\n  private _screenDprMonitor: ScreenDprMonitor;\n\n  private _topBoundaryFocusListener: (e: FocusEvent) => void;\n  private _bottomBoundaryFocusListener: (e: FocusEvent) => void;\n\n  /**\n   * This queue has a character pushed to it for keys that are pressed, if the\n   * next character added to the terminal is equal to the key char then it is\n   * not announced (added to live region) because it has already been announced\n   * by the textarea event (which cannot be canceled). There are some race\n   * condition cases if there is typing while data is streaming, but this covers\n   * the main case of typing into the prompt and inputting the answer to a\n   * question (Y/N, etc.).\n   */\n  private _charsToConsume: string[] = [];\n\n  private _charsToAnnounce: string = '';\n\n  constructor(\n    private readonly _terminal: ITerminal,\n    private readonly _renderService: IRenderService\n  ) {\n    super();\n    this._accessibilityTreeRoot = document.createElement('div');\n    this._accessibilityTreeRoot.classList.add('xterm-accessibility');\n\n    this._rowContainer = document.createElement('div');\n    this._rowContainer.classList.add('xterm-accessibility-tree');\n    this._rowElements = [];\n    for (let i = 0; i < this._terminal.rows; i++) {\n      this._rowElements[i] = this._createAccessibilityTreeNode();\n      this._rowContainer.appendChild(this._rowElements[i]);\n    }\n\n    this._topBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.TOP);\n    this._bottomBoundaryFocusListener = e => this._onBoundaryFocus(e, BoundaryPosition.BOTTOM);\n    this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);\n    this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);\n\n    this._refreshRowsDimensions();\n    this._accessibilityTreeRoot.appendChild(this._rowContainer);\n\n    this._renderRowsDebouncer = new RenderDebouncer(this._renderRows.bind(this));\n    this._refreshRows();\n\n    this._liveRegion = document.createElement('div');\n    this._liveRegion.classList.add('live-region');\n    this._liveRegion.setAttribute('aria-live', 'assertive');\n    this._accessibilityTreeRoot.appendChild(this._liveRegion);\n\n    this._terminal.element.insertAdjacentElement('afterbegin', this._accessibilityTreeRoot);\n\n    this.register(this._renderRowsDebouncer);\n    this.register(this._terminal.onResize(e => this._onResize(e.rows)));\n    this.register(this._terminal.onRender(e => this._refreshRows(e.start, e.end)));\n    this.register(this._terminal.onScroll(() => this._refreshRows()));\n    // Line feed is an issue as the prompt won't be read out after a command is run\n    this.register(this._terminal.onA11yChar(char => this._onChar(char)));\n    this.register(this._terminal.onLineFeed(() => this._onChar('\\n')));\n    this.register(this._terminal.onA11yTab(spaceCount => this._onTab(spaceCount)));\n    this.register(this._terminal.onKey(e => this._onKey(e.key)));\n    this.register(this._terminal.onBlur(() => this._clearLiveRegion()));\n    this.register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions()));\n\n    this._screenDprMonitor = new ScreenDprMonitor();\n    this.register(this._screenDprMonitor);\n    this._screenDprMonitor.setListener(() => this._refreshRowsDimensions());\n    // This shouldn't be needed on modern browsers but is present in case the\n    // media query that drives the ScreenDprMonitor isn't supported\n    this.register(addDisposableDomListener(window, 'resize', () => this._refreshRowsDimensions()));\n  }\n\n  public dispose(): void {\n    super.dispose();\n    this._terminal.element.removeChild(this._accessibilityTreeRoot);\n    this._rowElements.length = 0;\n  }\n\n  private _onBoundaryFocus(e: FocusEvent, position: BoundaryPosition): void {\n    const boundaryElement = <HTMLElement>e.target;\n    const beforeBoundaryElement = this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2];\n\n    // Don't scroll if the buffer top has reached the end in that direction\n    const posInSet = boundaryElement.getAttribute('aria-posinset');\n    const lastRowPos = position === BoundaryPosition.TOP ? '1' : `${this._terminal.buffer.lines.length}`;\n    if (posInSet === lastRowPos) {\n      return;\n    }\n\n    // Don't scroll when the last focused item was not the second row (focus is going the other\n    // direction)\n    if (e.relatedTarget !== beforeBoundaryElement) {\n      return;\n    }\n\n    // Remove old boundary element from array\n    let topBoundaryElement: HTMLElement;\n    let bottomBoundaryElement: HTMLElement;\n    if (position === BoundaryPosition.TOP) {\n      topBoundaryElement = boundaryElement;\n      bottomBoundaryElement = this._rowElements.pop()!;\n      this._rowContainer.removeChild(bottomBoundaryElement);\n    } else {\n      topBoundaryElement = this._rowElements.shift()!;\n      bottomBoundaryElement = boundaryElement;\n      this._rowContainer.removeChild(topBoundaryElement);\n    }\n\n    // Remove listeners from old boundary elements\n    topBoundaryElement.removeEventListener('focus', this._topBoundaryFocusListener);\n    bottomBoundaryElement.removeEventListener('focus', this._bottomBoundaryFocusListener);\n\n    // Add new element to array/DOM\n    if (position === BoundaryPosition.TOP) {\n      const newElement = this._createAccessibilityTreeNode();\n      this._rowElements.unshift(newElement);\n      this._rowContainer.insertAdjacentElement('afterbegin', newElement);\n    } else {\n      const newElement = this._createAccessibilityTreeNode();\n      this._rowElements.push(newElement);\n      this._rowContainer.appendChild(newElement);\n    }\n\n    // Add listeners to new boundary elements\n    this._rowElements[0].addEventListener('focus', this._topBoundaryFocusListener);\n    this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);\n\n    // Scroll up\n    this._terminal.scrollLines(position === BoundaryPosition.TOP ? -1 : 1);\n\n    // Focus new boundary before element\n    this._rowElements[position === BoundaryPosition.TOP ? 1 : this._rowElements.length - 2].focus();\n\n    // Prevent the standard behavior\n    e.preventDefault();\n    e.stopImmediatePropagation();\n  }\n\n  private _onResize(rows: number): void {\n    // Remove bottom boundary listener\n    this._rowElements[this._rowElements.length - 1].removeEventListener('focus', this._bottomBoundaryFocusListener);\n\n    // Grow rows as required\n    for (let i = this._rowContainer.children.length; i < this._terminal.rows; i++) {\n      this._rowElements[i] = this._createAccessibilityTreeNode();\n      this._rowContainer.appendChild(this._rowElements[i]);\n    }\n    // Shrink rows as required\n    while (this._rowElements.length > rows) {\n      this._rowContainer.removeChild(this._rowElements.pop()!);\n    }\n\n    // Add bottom boundary listener\n    this._rowElements[this._rowElements.length - 1].addEventListener('focus', this._bottomBoundaryFocusListener);\n\n    this._refreshRowsDimensions();\n  }\n\n  private _createAccessibilityTreeNode(): HTMLElement {\n    const element = document.createElement('div');\n    element.setAttribute('role', 'listitem');\n    element.tabIndex = -1;\n    this._refreshRowDimensions(element);\n    return element;\n  }\n\n  private _onTab(spaceCount: number): void {\n    for (let i = 0; i < spaceCount; i++) {\n      this._onChar(' ');\n    }\n  }\n\n  private _onChar(char: string): void {\n    if (this._liveRegionLineCount < MAX_ROWS_TO_READ + 1) {\n      if (this._charsToConsume.length > 0) {\n        // Have the screen reader ignore the char if it was just input\n        const shiftedChar = this._charsToConsume.shift();\n        if (shiftedChar !== char) {\n          this._charsToAnnounce += char;\n        }\n      } else {\n        this._charsToAnnounce += char;\n      }\n\n      if (char === '\\n') {\n        this._liveRegionLineCount++;\n        if (this._liveRegionLineCount === MAX_ROWS_TO_READ + 1) {\n          this._liveRegion.textContent += Strings.tooMuchOutput;\n        }\n      }\n\n      // Only detach/attach on mac as otherwise messages can go unaccounced\n      if (isMac) {\n        if (this._liveRegion.textContent && this._liveRegion.textContent.length > 0 && !this._liveRegion.parentNode) {\n          setTimeout(() => {\n            this._accessibilityTreeRoot.appendChild(this._liveRegion);\n          }, 0);\n        }\n      }\n    }\n  }\n\n  private _clearLiveRegion(): void {\n    this._liveRegion.textContent = '';\n    this._liveRegionLineCount = 0;\n\n    // Only detach/attach on mac as otherwise messages can go unaccounced\n    if (isMac) {\n      if (this._liveRegion.parentNode) {\n        this._accessibilityTreeRoot.removeChild(this._liveRegion);\n      }\n    }\n  }\n\n  private _onKey(keyChar: string): void {\n    this._clearLiveRegion();\n    this._charsToConsume.push(keyChar);\n  }\n\n  private _refreshRows(start?: number, end?: number): void {\n    this._renderRowsDebouncer.refresh(start, end, this._terminal.rows);\n  }\n\n  private _renderRows(start: number, end: number): void {\n    const buffer: IBuffer = this._terminal.buffer;\n    const setSize = buffer.lines.length.toString();\n    for (let i = start; i <= end; i++) {\n      const lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);\n      const posInSet = (buffer.ydisp + i + 1).toString();\n      const element = this._rowElements[i];\n      if (element) {\n        if (lineData.length === 0) {\n          element.innerHTML = ' ';\n        } else {\n          element.textContent = lineData;\n        }\n        element.setAttribute('aria-posinset', posInSet);\n        element.setAttribute('aria-setsize', setSize);\n      }\n    }\n    this._announceCharacters();\n  }\n\n  private _refreshRowsDimensions(): void {\n    if (!this._renderService.dimensions.actualCellHeight) {\n      return;\n    }\n    if (this._rowElements.length !== this._terminal.rows) {\n      this._onResize(this._terminal.rows);\n    }\n    for (let i = 0; i < this._terminal.rows; i++) {\n      this._refreshRowDimensions(this._rowElements[i]);\n    }\n  }\n\n  private _refreshRowDimensions(element: HTMLElement): void {\n    element.style.height = `${this._renderService.dimensions.actualCellHeight}px`;\n  }\n\n  private _announceCharacters(): void {\n    if (this._charsToAnnounce.length === 0) {\n      return;\n    }\n    this._liveRegion.textContent += this._charsToAnnounce;\n    this._charsToAnnounce = '';\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderer, IRenderDimensions, CharacterJoinerHandler, IRequestRefreshRowsEvent } from 'browser/renderer/Types';\nimport { BOLD_CLASS, ITALIC_CLASS, CURSOR_CLASS, CURSOR_STYLE_BLOCK_CLASS, CURSOR_BLINK_CLASS, CURSOR_STYLE_BAR_CLASS, CURSOR_STYLE_UNDERLINE_CLASS, DomRendererRowFactory } from 'browser/renderer/dom/DomRendererRowFactory';\nimport { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';\nimport { Disposable } from 'common/Lifecycle';\nimport { IColorSet, ILinkifierEvent, ILinkifier } from 'browser/Types';\nimport { ICharSizeService } from 'browser/services/Services';\nimport { IOptionsService, IBufferService } from 'common/services/Services';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { opaque } from 'browser/Color';\n\nconst TERMINAL_CLASS_PREFIX = 'xterm-dom-renderer-owner-';\nconst ROW_CONTAINER_CLASS = 'xterm-rows';\nconst FG_CLASS_PREFIX = 'xterm-fg-';\nconst BG_CLASS_PREFIX = 'xterm-bg-';\nconst FOCUS_CLASS = 'xterm-focus';\nconst SELECTION_CLASS = 'xterm-selection';\n\nlet nextTerminalId = 1;\n\n/**\n * A fallback renderer for when canvas is slow. This is not meant to be\n * particularly fast or feature complete, more just stable and usable for when\n * canvas is not an option.\n */\nexport class DomRenderer extends Disposable implements IRenderer {\n  private _rowFactory: DomRendererRowFactory;\n  private _terminalClass: number = nextTerminalId++;\n\n  private _themeStyleElement!: HTMLStyleElement;\n  private _dimensionsStyleElement!: HTMLStyleElement;\n  private _rowContainer: HTMLElement;\n  private _rowElements: HTMLElement[] = [];\n  private _selectionContainer: HTMLElement;\n\n  public dimensions: IRenderDimensions;\n\n  private _onRequestRefreshRows = new EventEmitter<IRequestRefreshRowsEvent>();\n  public get onRequestRefreshRows(): IEvent<IRequestRefreshRowsEvent> { return this._onRequestRefreshRows.event; }\n\n  constructor(\n    private _colors: IColorSet,\n    private readonly _element: HTMLElement,\n    private readonly _screenElement: HTMLElement,\n    private readonly _viewportElement: HTMLElement,\n    private readonly _linkifier: ILinkifier,\n    @ICharSizeService private readonly _charSizeService: ICharSizeService,\n    @IOptionsService private readonly _optionsService: IOptionsService,\n    @IBufferService private readonly _bufferService: IBufferService\n  ) {\n    super();\n\n    this._rowContainer = document.createElement('div');\n    this._rowContainer.classList.add(ROW_CONTAINER_CLASS);\n    this._rowContainer.style.lineHeight = 'normal';\n    this._rowContainer.setAttribute('aria-hidden', 'true');\n    this._refreshRowElements(this._bufferService.cols, this._bufferService.rows);\n    this._selectionContainer = document.createElement('div');\n    this._selectionContainer.classList.add(SELECTION_CLASS);\n    this._selectionContainer.setAttribute('aria-hidden', 'true');\n\n    this.dimensions = {\n      scaledCharWidth: 0,\n      scaledCharHeight: 0,\n      scaledCellWidth: 0,\n      scaledCellHeight: 0,\n      scaledCharLeft: 0,\n      scaledCharTop: 0,\n      scaledCanvasWidth: 0,\n      scaledCanvasHeight: 0,\n      canvasWidth: 0,\n      canvasHeight: 0,\n      actualCellWidth: 0,\n      actualCellHeight: 0\n    };\n    this._updateDimensions();\n    this._injectCss();\n\n    this._rowFactory = new DomRendererRowFactory(document, this._optionsService, this._colors);\n\n    this._element.classList.add(TERMINAL_CLASS_PREFIX + this._terminalClass);\n    this._screenElement.appendChild(this._rowContainer);\n    this._screenElement.appendChild(this._selectionContainer);\n\n    this._linkifier.onLinkHover(e => this._onLinkHover(e));\n    this._linkifier.onLinkLeave(e => this._onLinkLeave(e));\n  }\n\n  public dispose(): void {\n    this._element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);\n    this._screenElement.removeChild(this._rowContainer);\n    this._screenElement.removeChild(this._selectionContainer);\n    this._screenElement.removeChild(this._themeStyleElement);\n    this._screenElement.removeChild(this._dimensionsStyleElement);\n    super.dispose();\n  }\n\n  private _updateDimensions(): void {\n    this.dimensions.scaledCharWidth = this._charSizeService.width * window.devicePixelRatio;\n    this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio);\n    this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.options.letterSpacing);\n    this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.options.lineHeight);\n    this.dimensions.scaledCharLeft = 0;\n    this.dimensions.scaledCharTop = 0;\n    this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._bufferService.cols;\n    this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._bufferService.rows;\n    this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);\n    this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);\n    this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._bufferService.cols;\n    this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._bufferService.rows;\n\n    this._rowElements.forEach(element => {\n      element.style.width = `${this.dimensions.canvasWidth}px`;\n      element.style.height = `${this.dimensions.actualCellHeight}px`;\n      element.style.lineHeight = `${this.dimensions.actualCellHeight}px`;\n      // Make sure rows don't overflow onto following row\n      element.style.overflow = 'hidden';\n    });\n\n    if (!this._dimensionsStyleElement) {\n      this._dimensionsStyleElement = document.createElement('style');\n      this._screenElement.appendChild(this._dimensionsStyleElement);\n    }\n\n    const styles =\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS} span {` +\n        ` display: inline-block;` +\n        ` height: 100%;` +\n        ` vertical-align: top;` +\n        ` width: ${this.dimensions.actualCellWidth}px` +\n        `}`;\n\n    this._dimensionsStyleElement.innerHTML = styles;\n\n    this._selectionContainer.style.height = this._viewportElement.style.height;\n    this._screenElement.style.width = `${this.dimensions.canvasWidth}px`;\n    this._screenElement.style.height = `${this.dimensions.canvasHeight}px`;\n  }\n\n  public setColors(colors: IColorSet): void {\n    this._colors = colors;\n    this._injectCss();\n  }\n\n  private _injectCss(): void {\n    if (!this._themeStyleElement) {\n      this._themeStyleElement = document.createElement('style');\n      this._screenElement.appendChild(this._themeStyleElement);\n    }\n\n    // Base CSS\n    let styles =\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS} {` +\n        ` color: ${this._colors.foreground.css};` +\n        ` background-color: ${this._colors.background.css};` +\n        ` font-family: ${this._optionsService.options.fontFamily};` +\n        ` font-size: ${this._optionsService.options.fontSize}px;` +\n        `}`;\n    // Text styles\n    styles +=\n        `${this._terminalSelector} span:not(.${BOLD_CLASS}) {` +\n        ` font-weight: ${this._optionsService.options.fontWeight};` +\n        `}` +\n        `${this._terminalSelector} span.${BOLD_CLASS} {` +\n        ` font-weight: ${this._optionsService.options.fontWeightBold};` +\n        `}` +\n        `${this._terminalSelector} span.${ITALIC_CLASS} {` +\n        ` font-style: italic;` +\n        `}`;\n    // Blink animation\n    styles +=\n        `@keyframes blink_box_shadow {` +\n        ` 50% {` +\n        `  box-shadow: none;` +\n        ` }` +\n        `}`;\n    styles +=\n        `@keyframes blink_block {` +\n        ` 0% {` +\n        `  background-color: ${this._colors.cursor.css};` +\n        `  color: ${this._colors.cursorAccent.css};` +\n        ` }` +\n        ` 50% {` +\n        `  background-color: ${this._colors.cursorAccent.css};` +\n        `  color: ${this._colors.cursor.css};` +\n        ` }` +\n        `}`;\n    // Cursor\n    styles +=\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}:not(.${FOCUS_CLASS}) .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +\n        ` outline: 1px solid ${this._colors.cursor.css};` +\n        ` outline-offset: -1px;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS}:not(.${CURSOR_STYLE_BLOCK_CLASS}) {` +\n        ` animation: blink_box_shadow 1s step-end infinite;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_BLINK_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +\n        ` animation: blink_block 1s step-end infinite;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS}.${FOCUS_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BLOCK_CLASS} {` +\n        ` background-color: ${this._colors.cursor.css};` +\n        ` color: ${this._colors.cursorAccent.css};` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BAR_CLASS} {` +\n        ` box-shadow: 1px 0 0 ${this._colors.cursor.css} inset;` +\n        `}` +\n        `${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_UNDERLINE_CLASS} {` +\n        ` box-shadow: 0 -1px 0 ${this._colors.cursor.css} inset;` +\n        `}`;\n    // Selection\n    styles +=\n        `${this._terminalSelector} .${SELECTION_CLASS} {` +\n        ` position: absolute;` +\n        ` top: 0;` +\n        ` left: 0;` +\n        ` z-index: 1;` +\n        ` pointer-events: none;` +\n        `}` +\n        `${this._terminalSelector} .${SELECTION_CLASS} div {` +\n        ` position: absolute;` +\n        ` background-color: ${this._colors.selection.css};` +\n        `}`;\n    // Colors\n    this._colors.ansi.forEach((c, i) => {\n      styles +=\n          `${this._terminalSelector} .${FG_CLASS_PREFIX}${i} { color: ${c.css}; }` +\n          `${this._terminalSelector} .${BG_CLASS_PREFIX}${i} { background-color: ${c.css}; }`;\n    });\n    styles +=\n        `${this._terminalSelector} .${FG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { color: ${opaque(this._colors.background).css}; }` +\n        `${this._terminalSelector} .${BG_CLASS_PREFIX}${INVERTED_DEFAULT_COLOR} { background-color: ${this._colors.foreground.css}; }`;\n\n    this._themeStyleElement.innerHTML = styles;\n  }\n\n  public onDevicePixelRatioChange(): void {\n    this._updateDimensions();\n  }\n\n  private _refreshRowElements(cols: number, rows: number): void {\n    // Add missing elements\n    for (let i = this._rowElements.length; i <= rows; i++) {\n      const row = document.createElement('div');\n      this._rowContainer.appendChild(row);\n      this._rowElements.push(row);\n    }\n    // Remove excess elements\n    while (this._rowElements.length > rows) {\n      this._rowContainer.removeChild(this._rowElements.pop()!);\n    }\n  }\n\n  public onResize(cols: number, rows: number): void {\n    this._refreshRowElements(cols, rows);\n    this._updateDimensions();\n  }\n\n  public onCharSizeChanged(): void {\n    this._updateDimensions();\n  }\n\n  public onBlur(): void {\n    this._rowContainer.classList.remove(FOCUS_CLASS);\n  }\n\n  public onFocus(): void {\n    this._rowContainer.classList.add(FOCUS_CLASS);\n  }\n\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void {\n    // Remove all selections\n    while (this._selectionContainer.children.length) {\n      this._selectionContainer.removeChild(this._selectionContainer.children[0]);\n    }\n\n    // Selection does not exist\n    if (!start || !end) {\n      return;\n    }\n\n    // Translate from buffer position to viewport position\n    const viewportStartRow = start[1] - this._bufferService.buffer.ydisp;\n    const viewportEndRow = end[1] - this._bufferService.buffer.ydisp;\n    const viewportCappedStartRow = Math.max(viewportStartRow, 0);\n    const viewportCappedEndRow = Math.min(viewportEndRow, this._bufferService.rows - 1);\n\n    // No need to draw the selection\n    if (viewportCappedStartRow >= this._bufferService.rows || viewportCappedEndRow < 0) {\n      return;\n    }\n\n    // Create the selections\n    const documentFragment = document.createDocumentFragment();\n\n    if (columnSelectMode) {\n      documentFragment.appendChild(\n        this._createSelectionElement(viewportCappedStartRow, start[0], end[0], viewportCappedEndRow - viewportCappedStartRow + 1)\n      );\n    } else {\n      // Draw first row\n      const startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;\n      const endCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;\n      documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow, startCol, endCol));\n      // Draw middle rows\n      const middleRowsCount = viewportCappedEndRow - viewportCappedStartRow - 1;\n      documentFragment.appendChild(this._createSelectionElement(viewportCappedStartRow + 1, 0, this._bufferService.cols, middleRowsCount));\n      // Draw final row\n      if (viewportCappedStartRow !== viewportCappedEndRow) {\n        // Only draw viewportEndRow if it's not the same as viewporttartRow\n        const endCol = viewportEndRow === viewportCappedEndRow ? end[0] : this._bufferService.cols;\n        documentFragment.appendChild(this._createSelectionElement(viewportCappedEndRow, 0, endCol));\n      }\n    }\n    this._selectionContainer.appendChild(documentFragment);\n  }\n\n  /**\n   * Creates a selection element at the specified position.\n   * @param row The row of the selection.\n   * @param colStart The start column.\n   * @param colEnd The end columns.\n   */\n  private _createSelectionElement(row: number, colStart: number, colEnd: number, rowCount: number = 1): HTMLElement {\n    const element = document.createElement('div');\n    element.style.height = `${rowCount * this.dimensions.actualCellHeight}px`;\n    element.style.top = `${row * this.dimensions.actualCellHeight}px`;\n    element.style.left = `${colStart * this.dimensions.actualCellWidth}px`;\n    element.style.width = `${this.dimensions.actualCellWidth * (colEnd - colStart)}px`;\n    return element;\n  }\n\n  public onCursorMove(): void {\n    // No-op, the cursor is drawn when rows are drawn\n  }\n\n  public onOptionsChanged(): void {\n    // Force a refresh\n    this._updateDimensions();\n    this._injectCss();\n  }\n\n  public clear(): void {\n    this._rowElements.forEach(e => e.innerHTML = '');\n  }\n\n  public renderRows(start: number, end: number): void {\n    const cursorAbsoluteY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;\n    const cursorX = this._bufferService.buffer.x;\n    const cursorBlink = this._optionsService.options.cursorBlink;\n\n    for (let y = start; y <= end; y++) {\n      const rowElement = this._rowElements[y];\n      rowElement.innerHTML = '';\n\n      const row = y + this._bufferService.buffer.ydisp;\n      const lineData = this._bufferService.buffer.lines.get(row);\n      const cursorStyle = this._optionsService.options.cursorStyle;\n      rowElement.appendChild(this._rowFactory.createRow(lineData!, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols));\n    }\n  }\n\n  private get _terminalSelector(): string {\n    return `.${TERMINAL_CLASS_PREFIX}${this._terminalClass}`;\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number { return -1; }\n  public deregisterCharacterJoiner(joinerId: number): boolean { return false; }\n\n  private _onLinkHover(e: ILinkifierEvent): void {\n    this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, true);\n  }\n\n  private _onLinkLeave(e: ILinkifierEvent): void {\n    this._setCellUnderline(e.x1, e.x2, e.y1, e.y2, e.cols, false);\n  }\n\n  private _setCellUnderline(x: number, x2: number, y: number, y2: number, cols: number, enabled: boolean): void {\n    while (x !== x2 || y !== y2) {\n      const row = this._rowElements[y];\n      if (!row) {\n        return;\n      }\n      const span = <HTMLElement>row.children[x];\n      if (span) {\n        span.style.textDecoration = enabled ? 'underline' : 'none';\n      }\n      if (++x >= cols) {\n        x = 0;\n        y++;\n      }\n    }\n  }\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IBufferLine } from 'common/Types';\nimport { INVERTED_DEFAULT_COLOR } from 'browser/renderer/atlas/Constants';\nimport { NULL_CELL_CODE, WHITESPACE_CELL_CHAR, Attributes } from 'common/buffer/Constants';\nimport { CellData } from 'common/buffer/CellData';\nimport { IOptionsService } from 'common/services/Services';\nimport { ensureContrastRatio, rgbaToColor } from 'browser/Color';\nimport { IColorSet, IColor } from 'browser/Types';\n\nexport const BOLD_CLASS = 'xterm-bold';\nexport const DIM_CLASS = 'xterm-dim';\nexport const ITALIC_CLASS = 'xterm-italic';\nexport const UNDERLINE_CLASS = 'xterm-underline';\nexport const CURSOR_CLASS = 'xterm-cursor';\nexport const CURSOR_BLINK_CLASS = 'xterm-cursor-blink';\nexport const CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block';\nexport const CURSOR_STYLE_BAR_CLASS = 'xterm-cursor-bar';\nexport const CURSOR_STYLE_UNDERLINE_CLASS = 'xterm-cursor-underline';\n\nexport class DomRendererRowFactory {\n  private _workCell: CellData = new CellData();\n\n  constructor(\n    private readonly _document: Document,\n    private readonly _optionsService: IOptionsService,\n    private _colors: IColorSet\n  ) {\n  }\n\n  public setColors(colors: IColorSet): void {\n    this._colors = colors;\n  }\n\n  public createRow(lineData: IBufferLine, isCursorRow: boolean, cursorStyle: string | undefined, cursorX: number, cursorBlink: boolean, cellWidth: number, cols: number): DocumentFragment {\n    const fragment = this._document.createDocumentFragment();\n\n    // Find the line length first, this prevents the need to output a bunch of\n    // empty cells at the end. This cannot easily be integrated into the main\n    // loop below because of the colCount feature (which can be removed after we\n    // properly support reflow and disallow data to go beyond the right-side of\n    // the viewport).\n    let lineLength = 0;\n    for (let x = Math.min(lineData.length, cols) - 1; x >= 0; x--) {\n      if (lineData.loadCell(x, this._workCell).getCode() !== NULL_CELL_CODE || (isCursorRow && x === cursorX)) {\n        lineLength = x + 1;\n        break;\n      }\n    }\n\n    for (let x = 0; x < lineLength; x++) {\n      lineData.loadCell(x, this._workCell);\n      const width = this._workCell.getWidth();\n\n      // The character to the left is a wide character, drawing is owned by the char at x-1\n      if (width === 0) {\n        continue;\n      }\n\n      const charElement = this._document.createElement('span');\n      if (width > 1) {\n        charElement.style.width = `${cellWidth * width}px`;\n      }\n\n      if (isCursorRow && x === cursorX) {\n        charElement.classList.add(CURSOR_CLASS);\n\n        if (cursorBlink) {\n          charElement.classList.add(CURSOR_BLINK_CLASS);\n        }\n\n        switch (cursorStyle) {\n          case 'bar':\n            charElement.classList.add(CURSOR_STYLE_BAR_CLASS);\n            break;\n          case 'underline':\n            charElement.classList.add(CURSOR_STYLE_UNDERLINE_CLASS);\n            break;\n          default:\n            charElement.classList.add(CURSOR_STYLE_BLOCK_CLASS);\n            break;\n        }\n      }\n\n      if (this._workCell.isBold()) {\n        charElement.classList.add(BOLD_CLASS);\n      }\n\n      if (this._workCell.isItalic()) {\n        charElement.classList.add(ITALIC_CLASS);\n      }\n\n      if (this._workCell.isDim()) {\n        charElement.classList.add(DIM_CLASS);\n      }\n\n      if (this._workCell.isUnderline()) {\n        charElement.classList.add(UNDERLINE_CLASS);\n      }\n\n      charElement.textContent = this._workCell.getChars() || WHITESPACE_CELL_CHAR;\n\n      let fg = this._workCell.getFgColor();\n      let fgColorMode = this._workCell.getFgColorMode();\n      let bg = this._workCell.getBgColor();\n      let bgColorMode = this._workCell.getBgColorMode();\n      const isInverse = !!this._workCell.isInverse();\n      if (isInverse) {\n        const temp = fg;\n        fg = bg;\n        bg = temp;\n        const temp2 = fgColorMode;\n        fgColorMode = bgColorMode;\n        bgColorMode = temp2;\n      }\n\n      // Foreground\n      switch (fgColorMode) {\n        case Attributes.CM_P16:\n        case Attributes.CM_P256:\n          if (this._workCell.isBold() && fg < 8 && this._optionsService.options.drawBoldTextInBrightColors) {\n            fg += 8;\n          }\n          if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.ansi[fg])) {\n            charElement.classList.add(`xterm-fg-${fg}`);\n          }\n          break;\n        case Attributes.CM_RGB:\n          const color = rgbaToColor(\n            (fg >> 16) & 0xFF,\n            (fg >>  8) & 0xFF,\n            (fg      ) & 0xFF\n          );\n          if (!this._applyMinimumContrast(charElement, this._colors.background, color)) {\n            this._addStyle(charElement, `color:#${padStart(fg.toString(16), '0', 6)}`);\n          }\n          break;\n        case Attributes.CM_DEFAULT:\n        default:\n          if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.foreground)) {\n            if (isInverse) {\n              charElement.classList.add(`xterm-fg-${INVERTED_DEFAULT_COLOR}`);\n            }\n          }\n      }\n\n      // Background\n      switch (bgColorMode) {\n        case Attributes.CM_P16:\n        case Attributes.CM_P256:\n          charElement.classList.add(`xterm-bg-${bg}`);\n          break;\n        case Attributes.CM_RGB:\n          this._addStyle(charElement, `background-color:#${padStart(bg.toString(16), '0', 6)}`);\n          break;\n        case Attributes.CM_DEFAULT:\n        default:\n          if (isInverse) {\n            charElement.classList.add(`xterm-bg-${INVERTED_DEFAULT_COLOR}`);\n          }\n      }\n\n      fragment.appendChild(charElement);\n    }\n    return fragment;\n  }\n\n  private _applyMinimumContrast(element: HTMLElement, bg: IColor, fg: IColor): boolean {\n    if (this._optionsService.options.minimumContrastRatio === 1) {\n      return false;\n    }\n\n    // Try get from cache first\n    let adjustedColor = this._colors.contrastCache.getColor(this._workCell.bg, this._workCell.fg);\n\n    // Calculate and store in cache\n    if (adjustedColor === undefined) {\n      adjustedColor = ensureContrastRatio(bg, fg, this._optionsService.options.minimumContrastRatio);\n      this._colors.contrastCache.setColor(this._workCell.bg, this._workCell.fg, adjustedColor ?? null);\n    }\n\n    if (adjustedColor) {\n      this._addStyle(element, `color:${adjustedColor.css}`);\n      return true;\n    }\n\n    return false;\n  }\n\n  private _addStyle(element: HTMLElement, style: string): void {\n    element.setAttribute('style', `${element.getAttribute('style') || ''}${style};`);\n  }\n}\n\nfunction padStart(text: string, padChar: string, length: number): string {\n  while (text.length < length) {\n    text = padChar + text;\n  }\n  return text;\n}\n","/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * @license MIT\n */\n\nimport { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/Types';\nimport { C0 } from 'common/data/EscapeSequences';\n\n// reg + shift key mappings for digits and special chars\nconst KEYCODE_KEY_MAPPINGS: { [key: number]: [string, string]} = {\n  // digits 0-9\n  48: ['0', ')'],\n  49: ['1', '!'],\n  50: ['2', '@'],\n  51: ['3', '#'],\n  52: ['4', '$'],\n  53: ['5', '%'],\n  54: ['6', '^'],\n  55: ['7', '&'],\n  56: ['8', '*'],\n  57: ['9', '('],\n\n  // special chars\n  186: [';', ':'],\n  187: ['=', '+'],\n  188: [',', '<'],\n  189: ['-', '_'],\n  190: ['.', '>'],\n  191: ['/', '?'],\n  192: ['`', '~'],\n  219: ['[', '{'],\n  220: ['\\\\', '|'],\n  221: [']', '}'],\n  222: ['\\'', '\"']\n};\n\nexport function evaluateKeyboardEvent(\n  ev: IKeyboardEvent,\n  applicationCursorMode: boolean,\n  isMac: boolean,\n  macOptionIsMeta: boolean\n): IKeyboardResult {\n  const result: IKeyboardResult = {\n    type: KeyboardResultType.SEND_KEY,\n    // Whether to cancel event propagation (NOTE: this may not be needed since the event is\n    // canceled at the end of keyDown\n    cancel: false,\n    // The new key even to emit\n    key: undefined\n  };\n  const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);\n  switch (ev.keyCode) {\n    case 0:\n      if (ev.key === 'UIKeyInputUpArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OA';\n        } else {\n          result.key = C0.ESC + '[A';\n        }\n      }\n      else if (ev.key === 'UIKeyInputLeftArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OD';\n        } else {\n          result.key = C0.ESC + '[D';\n        }\n      }\n      else if (ev.key === 'UIKeyInputRightArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OC';\n        } else {\n          result.key = C0.ESC + '[C';\n        }\n      }\n      else if (ev.key === 'UIKeyInputDownArrow') {\n        if (applicationCursorMode) {\n          result.key = C0.ESC + 'OB';\n        } else {\n          result.key = C0.ESC + '[B';\n        }\n      }\n      break;\n    case 8:\n      // backspace\n      if (ev.shiftKey) {\n        result.key = C0.BS; // ^H\n        break;\n      } else if (ev.altKey) {\n        result.key = C0.ESC + C0.DEL; // \\e ^?\n        break;\n      }\n      result.key = C0.DEL; // ^?\n      break;\n    case 9:\n      // tab\n      if (ev.shiftKey) {\n        result.key = C0.ESC + '[Z';\n        break;\n      }\n      result.key = C0.HT;\n      result.cancel = true;\n      break;\n    case 13:\n      // return/enter\n      result.key = C0.CR;\n      result.cancel = true;\n      break;\n    case 27:\n      // escape\n      result.key = C0.ESC;\n      result.cancel = true;\n      break;\n    case 37:\n      // left-arrow\n      if (ev.metaKey) {\n        break;\n      }\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'D';\n        // HACK: Make Alt + left-arrow behave like Ctrl + left-arrow: move one word backwards\n        // http://unix.stackexchange.com/a/108106\n        // macOS uses different escape sequences than linux\n        if (result.key === C0.ESC + '[1;3D') {\n          result.key = C0.ESC + (isMac ? 'b' : '[1;5D');\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OD';\n      } else {\n        result.key = C0.ESC + '[D';\n      }\n      break;\n    case 39:\n      // right-arrow\n      if (ev.metaKey) {\n        break;\n      }\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'C';\n        // HACK: Make Alt + right-arrow behave like Ctrl + right-arrow: move one word forward\n        // http://unix.stackexchange.com/a/108106\n        // macOS uses different escape sequences than linux\n        if (result.key === C0.ESC + '[1;3C') {\n          result.key = C0.ESC + (isMac ? 'f' : '[1;5C');\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OC';\n      } else {\n        result.key = C0.ESC + '[C';\n      }\n      break;\n    case 38:\n      // up-arrow\n      if (ev.metaKey) {\n        break;\n      }\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'A';\n        // HACK: Make Alt + up-arrow behave like Ctrl + up-arrow\n        // http://unix.stackexchange.com/a/108106\n        // macOS uses different escape sequences than linux\n        if (!isMac && result.key === C0.ESC + '[1;3A') {\n          result.key = C0.ESC + '[1;5A';\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OA';\n      } else {\n        result.key = C0.ESC + '[A';\n      }\n      break;\n    case 40:\n      // down-arrow\n      if (ev.metaKey) {\n        break;\n      }\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'B';\n        // HACK: Make Alt + down-arrow behave like Ctrl + down-arrow\n        // http://unix.stackexchange.com/a/108106\n        // macOS uses different escape sequences than linux\n        if (!isMac && result.key === C0.ESC + '[1;3B') {\n          result.key = C0.ESC + '[1;5B';\n        }\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OB';\n      } else {\n        result.key = C0.ESC + '[B';\n      }\n      break;\n    case 45:\n      // insert\n      if (!ev.shiftKey && !ev.ctrlKey) {\n        // <Ctrl> or <Shift> + <Insert> are used to\n        // copy-paste on some systems.\n        result.key = C0.ESC + '[2~';\n      }\n      break;\n    case 46:\n      // delete\n      if (modifiers) {\n        result.key = C0.ESC + '[3;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[3~';\n      }\n      break;\n    case 36:\n      // home\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'H';\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OH';\n      } else {\n        result.key = C0.ESC + '[H';\n      }\n      break;\n    case 35:\n      // end\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'F';\n      } else if (applicationCursorMode) {\n        result.key = C0.ESC + 'OF';\n      } else {\n        result.key = C0.ESC + '[F';\n      }\n      break;\n    case 33:\n      // page up\n      if (ev.shiftKey) {\n        result.type = KeyboardResultType.PAGE_UP;\n      } else {\n        result.key = C0.ESC + '[5~';\n      }\n      break;\n    case 34:\n      // page down\n      if (ev.shiftKey) {\n        result.type = KeyboardResultType.PAGE_DOWN;\n      } else {\n        result.key = C0.ESC + '[6~';\n      }\n      break;\n    case 112:\n      // F1-F12\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'P';\n      } else {\n        result.key = C0.ESC + 'OP';\n      }\n      break;\n    case 113:\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'Q';\n      } else {\n        result.key = C0.ESC + 'OQ';\n      }\n      break;\n    case 114:\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'R';\n      } else {\n        result.key = C0.ESC + 'OR';\n      }\n      break;\n    case 115:\n      if (modifiers) {\n        result.key = C0.ESC + '[1;' + (modifiers + 1) + 'S';\n      } else {\n        result.key = C0.ESC + 'OS';\n      }\n      break;\n    case 116:\n      if (modifiers) {\n        result.key = C0.ESC + '[15;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[15~';\n      }\n      break;\n    case 117:\n      if (modifiers) {\n        result.key = C0.ESC + '[17;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[17~';\n      }\n      break;\n    case 118:\n      if (modifiers) {\n        result.key = C0.ESC + '[18;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[18~';\n      }\n      break;\n    case 119:\n      if (modifiers) {\n        result.key = C0.ESC + '[19;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[19~';\n      }\n      break;\n    case 120:\n      if (modifiers) {\n        result.key = C0.ESC + '[20;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[20~';\n      }\n      break;\n    case 121:\n      if (modifiers) {\n        result.key = C0.ESC + '[21;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[21~';\n      }\n      break;\n    case 122:\n      if (modifiers) {\n        result.key = C0.ESC + '[23;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[23~';\n      }\n      break;\n    case 123:\n      if (modifiers) {\n        result.key = C0.ESC + '[24;' + (modifiers + 1) + '~';\n      } else {\n        result.key = C0.ESC + '[24~';\n      }\n      break;\n    default:\n      // a-z and space\n      if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {\n        if (ev.keyCode >= 65 && ev.keyCode <= 90) {\n          result.key = String.fromCharCode(ev.keyCode - 64);\n        } else if (ev.keyCode === 32) {\n          result.key = C0.NUL;\n        } else if (ev.keyCode >= 51 && ev.keyCode <= 55) {\n          // escape, file sep, group sep, record sep, unit sep\n          result.key = String.fromCharCode(ev.keyCode - 51 + 27);\n        } else if (ev.keyCode === 56) {\n          result.key = C0.DEL;\n        } else if (ev.keyCode === 219) {\n          result.key = C0.ESC;\n        } else if (ev.keyCode === 220) {\n          result.key = C0.FS;\n        } else if (ev.keyCode === 221) {\n          result.key = C0.GS;\n        }\n      } else if ((!isMac || macOptionIsMeta) && ev.altKey && !ev.metaKey) {\n        // On macOS this is a third level shift when !macOptionIsMeta. Use <Esc> instead.\n        const keyMapping = KEYCODE_KEY_MAPPINGS[ev.keyCode];\n        const key = keyMapping && keyMapping[!ev.shiftKey ? 0 : 1];\n        if (key) {\n          result.key = C0.ESC + key;\n        } else if (ev.keyCode >= 65 && ev.keyCode <= 90) {\n          const keyCode = ev.ctrlKey ? ev.keyCode - 64 : ev.keyCode + 32;\n          result.key = C0.ESC + String.fromCharCode(keyCode);\n        }\n      } else if (isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {\n        if (ev.keyCode === 65) { // cmd + a\n          result.type = KeyboardResultType.SELECT_ALL;\n        }\n      } else if (ev.key && !ev.ctrlKey && !ev.altKey && !ev.metaKey && ev.keyCode >= 48 && ev.key.length === 1) {\n        // Include only keys that that result in a _single_ character; don't include num lock, volume up, etc.\n        result.key = ev.key;\n      } else if (ev.key && ev.ctrlKey) {\n        if (ev.key === '_') { // ^_\n          result.key = C0.US;\n        }\n      }\n      break;\n  }\n\n  return result;\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { CHAR_DATA_CODE_INDEX, NULL_CELL_CODE, WHITESPACE_CELL_CODE } from 'common/buffer/Constants';\nimport { IBufferService } from 'common/services/Services';\n\nexport function handleWindowsModeLineFeed(bufferService: IBufferService): void {\n  // Winpty does not support wraparound mode which means that lines will never\n  // be marked as wrapped. This causes issues for things like copying a line\n  // retaining the wrapped new line characters or if consumers are listening\n  // in on the data stream.\n  //\n  // The workaround for this is to listen to every incoming line feed and mark\n  // the line as wrapped if the last character in the previous line is not a\n  // space. This is certainly not without its problems, but generally on\n  // Windows when text reaches the end of the terminal it's likely going to be\n  // wrapped.\n  const line = bufferService.buffer.lines.get(bufferService.buffer.ybase + bufferService.buffer.y - 1);\n  const lastChar = line?.get(bufferService.cols - 1);\n\n  const nextLine = bufferService.buffer.lines.get(bufferService.buffer.ybase + bufferService.buffer.y);\n  if (nextLine && lastChar) {\n    nextLine.isWrapped = (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IRenderer, IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types';\nimport { RenderDebouncer } from 'browser/RenderDebouncer';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { Disposable } from 'common/Lifecycle';\nimport { ScreenDprMonitor } from 'browser/ScreenDprMonitor';\nimport { addDisposableDomListener } from 'browser/Lifecycle';\nimport { IColorSet } from 'browser/Types';\nimport { IOptionsService } from 'common/services/Services';\nimport { ICharSizeService, IRenderService } from 'browser/services/Services';\n\nexport class RenderService extends Disposable implements IRenderService {\n  serviceBrand: any;\n\n  private _renderDebouncer: RenderDebouncer;\n  private _screenDprMonitor: ScreenDprMonitor;\n\n  private _isPaused: boolean = false;\n  private _needsFullRefresh: boolean = false;\n  private _canvasWidth: number = 0;\n  private _canvasHeight: number = 0;\n\n  private _onDimensionsChange = new EventEmitter<IRenderDimensions>();\n  public get onDimensionsChange(): IEvent<IRenderDimensions> { return this._onDimensionsChange.event; }\n  private _onRender = new EventEmitter<{ start: number, end: number }>();\n  public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }\n  private _onRefreshRequest = new EventEmitter<{ start: number, end: number }>();\n  public get onRefreshRequest(): IEvent<{ start: number, end: number }> { return this._onRefreshRequest.event; }\n\n  public get dimensions(): IRenderDimensions { return this._renderer.dimensions; }\n\n  constructor(\n    private _renderer: IRenderer,\n    private _rowCount: number,\n    readonly screenElement: HTMLElement,\n    @IOptionsService readonly optionsService: IOptionsService,\n    @ICharSizeService readonly charSizeService: ICharSizeService\n  ) {\n    super();\n    this._renderDebouncer = new RenderDebouncer((start, end) => this._renderRows(start, end));\n    this.register(this._renderDebouncer);\n\n    this._screenDprMonitor = new ScreenDprMonitor();\n    this._screenDprMonitor.setListener(() => this.onDevicePixelRatioChange());\n    this.register(this._screenDprMonitor);\n\n    this.register(optionsService.onOptionChange(() => this._renderer.onOptionsChanged()));\n    this.register(charSizeService.onCharSizeChange(() => this.onCharSizeChanged()));\n\n    // No need to register this as renderer is explicitly disposed in RenderService.dispose\n    this._renderer.onRequestRefreshRows(e => this.refreshRows(e.start, e.end));\n\n    // dprchange should handle this case, we need this as well for browsers that don't support the\n    // matchMedia query.\n    this.register(addDisposableDomListener(window, 'resize', () => this.onDevicePixelRatioChange()));\n\n    // Detect whether IntersectionObserver is detected and enable renderer pause\n    // and resume based on terminal visibility if so\n    if ('IntersectionObserver' in window) {\n      const observer = new IntersectionObserver(e => this._onIntersectionChange(e[e.length - 1]), { threshold: 0 });\n      observer.observe(screenElement);\n      this.register({ dispose: () => observer.disconnect() });\n    }\n  }\n\n  private _onIntersectionChange(entry: IntersectionObserverEntry): void {\n    this._isPaused = entry.intersectionRatio === 0;\n    if (!this._isPaused && this._needsFullRefresh) {\n      this.refreshRows(0, this._rowCount - 1);\n      this._needsFullRefresh = false;\n    }\n  }\n\n  public refreshRows(start: number, end: number): void {\n    if (this._isPaused) {\n      this._needsFullRefresh = true;\n      return;\n    }\n    this._renderDebouncer.refresh(start, end, this._rowCount);\n  }\n\n  private _renderRows(start: number, end: number): void {\n    this._renderer.renderRows(start, end);\n    this._onRender.fire({ start, end });\n  }\n\n  public resize(cols: number, rows: number): void {\n    this._rowCount = rows;\n    this._fireOnCanvasResize();\n  }\n\n  public changeOptions(): void {\n    this._renderer.onOptionsChanged();\n    this.refreshRows(0, this._rowCount - 1);\n    this._fireOnCanvasResize();\n  }\n\n  private _fireOnCanvasResize(): void {\n    // Don't fire the event if the dimensions haven't changed\n    if (this._renderer.dimensions.canvasWidth === this._canvasWidth && this._renderer.dimensions.canvasHeight === this._canvasHeight) {\n      return;\n    }\n    this._onDimensionsChange.fire(this._renderer.dimensions);\n  }\n\n  public dispose(): void {\n    this._renderer.dispose();\n    super.dispose();\n  }\n\n  public setRenderer(renderer: IRenderer): void {\n    // TODO: RenderService should be the only one to dispose the renderer\n    this._renderer.dispose();\n    this._renderer = renderer;\n    this._renderer.onRequestRefreshRows(e => this.refreshRows(e.start, e.end));\n    this.refreshRows(0, this._rowCount - 1);\n  }\n\n  private _fullRefresh(): void {\n    if (this._isPaused) {\n      this._needsFullRefresh = true;\n    } else {\n      this.refreshRows(0, this._rowCount - 1);\n    }\n  }\n\n  public setColors(colors: IColorSet): void {\n    this._renderer.setColors(colors);\n    this._fullRefresh();\n  }\n\n  public onDevicePixelRatioChange(): void {\n    this._renderer.onDevicePixelRatioChange();\n    this.refreshRows(0, this._rowCount - 1);\n  }\n\n  public onResize(cols: number, rows: number): void {\n    this._renderer.onResize(cols, rows);\n    this._fullRefresh();\n  }\n\n  // TODO: Is this useful when we have onResize?\n  public onCharSizeChanged(): void {\n    this._renderer.onCharSizeChanged();\n  }\n\n  public onBlur(): void {\n    this._renderer.onBlur();\n  }\n\n  public onFocus(): void {\n    this._renderer.onFocus();\n  }\n\n  public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void {\n    this._renderer.onSelectionChanged(start, end, columnSelectMode);\n  }\n\n  public onCursorMove(): void {\n    this._renderer.onCursorMove();\n  }\n\n  public clear(): void {\n    this._renderer.clear();\n  }\n\n  public registerCharacterJoiner(handler: CharacterJoinerHandler): number {\n    return this._renderer.registerCharacterJoiner(handler);\n  }\n\n  public deregisterCharacterJoiner(joinerId: number): boolean {\n    return this._renderer.deregisterCharacterJoiner(joinerId);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IOptionsService, ITerminalOptions, IPartialTerminalOptions } from 'common/services/Services';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { isMac } from 'common/Platform';\nimport { clone } from 'common/Clone';\n\n// Source: https://freesound.org/people/altemark/sounds/45759/\n// This sound is released under the Creative Commons Attribution 3.0 Unported\n// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been\n// made, apart from the conversion to base64.\nexport const DEFAULT_BELL_SOUND = 'data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq';\n\n// TODO: Freeze?\nexport const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({\n  cols: 80,\n  rows: 24,\n  cursorBlink: false,\n  cursorStyle: 'block',\n  bellSound:  DEFAULT_BELL_SOUND,\n  bellStyle: 'none',\n  drawBoldTextInBrightColors: true,\n  fastScrollModifier: 'alt',\n  fastScrollSensitivity: 5,\n  fontFamily: 'courier-new, courier, monospace',\n  fontSize: 15,\n  fontWeight: 'normal',\n  fontWeightBold: 'bold',\n  lineHeight: 1.0,\n  letterSpacing: 0,\n  logLevel: 'info',\n  scrollback: 1000,\n  scrollSensitivity: 1,\n  screenReaderMode: false,\n  macOptionIsMeta: false,\n  macOptionClickForcesSelection: false,\n  minimumContrastRatio: 1,\n  disableStdin: false,\n  allowTransparency: false,\n  tabStopWidth: 8,\n  theme: {},\n  rightClickSelectsWord: isMac,\n  rendererType: 'canvas',\n  windowsMode: false,\n\n  convertEol: false,\n  termName: 'xterm',\n  screenKeys: false,\n  cancelEvents: false,\n  useFlowControl: false,\n  wordSeparator: ' ()[]{}\\',:;\"`'\n});\n\n/**\n * The set of options that only have an effect when set in the Terminal constructor.\n */\nconst CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows'];\n\nexport class OptionsService implements IOptionsService {\n  serviceBrand: any;\n\n  public options: ITerminalOptions;\n\n  private _onOptionChange = new EventEmitter<string>();\n  public get onOptionChange(): IEvent<string> { return this._onOptionChange.event; }\n\n  constructor(options: IPartialTerminalOptions) {\n    this.options = clone(DEFAULT_OPTIONS);\n    Object.keys(options).forEach(k => {\n      if (k in this.options) {\n        const newValue = options[k as keyof IPartialTerminalOptions] as any;\n        this.options[k] = newValue;\n      }\n    });\n  }\n\n  public setOption(key: string, value: any): void {\n    if (!(key in DEFAULT_OPTIONS)) {\n      throw new Error('No option with key \"' + key + '\"');\n    }\n    if (CONSTRUCTOR_ONLY_OPTIONS.indexOf(key) !== -1) {\n      throw new Error(`Option \"${key}\" can only be set in the constructor`);\n    }\n    if (this.options[key] === value) {\n      return;\n    }\n\n    value = this._sanitizeAndValidateOption(key, value);\n\n    // Don't fire an option change event if they didn't change\n    if (this.options[key] === value) {\n      return;\n    }\n\n    this.options[key] = value;\n    this._onOptionChange.fire(key);\n  }\n\n  private _sanitizeAndValidateOption(key: string, value: any): any {\n    switch (key) {\n      case 'bellStyle':\n      case 'cursorStyle':\n      case 'fontWeight':\n      case 'fontWeightBold':\n      case 'rendererType':\n      case 'wordSeparator':\n        if (!value) {\n          value = DEFAULT_OPTIONS[key];\n        }\n        break;\n      case 'lineHeight':\n      case 'tabStopWidth':\n        if (value < 1) {\n          throw new Error(`${key} cannot be less than 1, value: ${value}`);\n        }\n        break;\n      case 'minimumContrastRatio':\n        value = Math.max(1, Math.min(21, Math.round(value * 10) / 10));\n      case 'scrollback':\n        value = Math.min(value, 4294967295);\n        if (value < 0) {\n          throw new Error(`${key} cannot be less than 0, value: ${value}`);\n        }\n        break;\n      case 'fastScrollSensitivity':\n      case 'scrollSensitivity':\n        if (value <= 0) {\n          throw new Error(`${key} cannot be less than or equal to 0, value: ${value}`);\n        }\n        break;\n    }\n    return value;\n  }\n\n  public getOption(key: string): any {\n    if (!(key in DEFAULT_OPTIONS)) {\n      throw new Error(`No option with key \"${key}\"`);\n    }\n    return this.options[key];\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IOptionsService } from 'common/services/Services';\nimport { IEvent, EventEmitter } from 'common/EventEmitter';\nimport { ICharSizeService } from 'browser/services/Services';\n\nexport class CharSizeService implements ICharSizeService {\n  serviceBrand: any;\n\n  public width: number = 0;\n  public height: number = 0;\n  private _measureStrategy: IMeasureStrategy;\n\n  public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }\n\n  private _onCharSizeChange = new EventEmitter<void>();\n  public get onCharSizeChange(): IEvent<void> { return this._onCharSizeChange.event; }\n\n  constructor(\n    readonly document: Document,\n    readonly parentElement: HTMLElement,\n    @IOptionsService private readonly _optionsService: IOptionsService\n  ) {\n    this._measureStrategy = new DomMeasureStrategy(document, parentElement, this._optionsService);\n  }\n\n  public measure(): void {\n    const result = this._measureStrategy.measure();\n    if (result.width !== this.width || result.height !== this.height) {\n      this.width = result.width;\n      this.height = result.height;\n      this._onCharSizeChange.fire();\n    }\n  }\n}\n\ninterface IMeasureStrategy {\n  measure(): IReadonlyMeasureResult;\n}\n\ninterface IReadonlyMeasureResult {\n  readonly width: number;\n  readonly height: number;\n}\n\ninterface IMeasureResult {\n  width: number;\n  height: number;\n}\n\n// TODO: For supporting browsers we should also provide a CanvasCharDimensionsProvider that uses ctx.measureText\nclass DomMeasureStrategy implements IMeasureStrategy {\n  private _result: IMeasureResult = { width: 0, height: 0 };\n  private _measureElement: HTMLElement;\n\n  constructor(\n    private _document: Document,\n    private _parentElement: HTMLElement,\n    private _optionsService: IOptionsService\n  ) {\n    this._measureElement = this._document.createElement('span');\n    this._measureElement.classList.add('xterm-char-measure-element');\n    this._measureElement.textContent = 'W';\n    this._measureElement.setAttribute('aria-hidden', 'true');\n    this._parentElement.appendChild(this._measureElement);\n  }\n\n  public measure(): IReadonlyMeasureResult {\n    this._measureElement.style.fontFamily = this._optionsService.options.fontFamily;\n    this._measureElement.style.fontSize = `${this._optionsService.options.fontSize}px`;\n\n    // Note that this triggers a synchronous layout\n    const geometry = this._measureElement.getBoundingClientRect();\n\n    // If values are 0 then the element is likely currently display:none, in which case we should\n    // retain the previous value.\n    if (geometry.width !== 0 && geometry.height !== 0) {\n      this._result.width = geometry.width;\n      this._result.height = Math.ceil(geometry.height);\n    }\n\n    return this._result;\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IBufferService, IOptionsService } from 'common/services/Services';\nimport { BufferSet } from 'common/buffer/BufferSet';\nimport { IBufferSet, IBuffer } from 'common/buffer/Types';\n\nexport const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars\nexport const MINIMUM_ROWS = 1;\n\nexport class BufferService implements IBufferService {\n  serviceBrand: any;\n\n  public cols: number;\n  public rows: number;\n  public buffers: IBufferSet;\n\n  public get buffer(): IBuffer { return this.buffers.active; }\n\n  constructor(\n    @IOptionsService private _optionsService: IOptionsService\n  ) {\n    this.cols = Math.max(_optionsService.options.cols, MINIMUM_COLS);\n    this.rows = Math.max(_optionsService.options.rows, MINIMUM_ROWS);\n    this.buffers = new BufferSet(_optionsService, this);\n  }\n\n  public resize(cols: number, rows: number): void {\n    this.cols = cols;\n    this.rows = rows;\n  }\n\n  public reset(): void {\n    this.buffers = new BufferSet(this._optionsService, this);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IBuffer, IBufferSet } from 'common/buffer/Types';\nimport { IAttributeData } from 'common/Types';\nimport { Buffer } from 'common/buffer/Buffer';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { IOptionsService, IBufferService } from 'common/services/Services';\n\n/**\n * The BufferSet represents the set of two buffers used by xterm terminals (normal and alt) and\n * provides also utilities for working with them.\n */\nexport class BufferSet implements IBufferSet {\n  private _normal: Buffer;\n  private _alt: Buffer;\n  private _activeBuffer: Buffer;\n\n\n  private _onBufferActivate = new EventEmitter<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>();\n  public get onBufferActivate(): IEvent<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}> { return this._onBufferActivate.event; }\n\n  /**\n   * Create a new BufferSet for the given terminal.\n   * @param _terminal - The terminal the BufferSet will belong to\n   */\n  constructor(\n    readonly optionsService: IOptionsService,\n    readonly bufferService: IBufferService\n  ) {\n    this._normal = new Buffer(true, optionsService, bufferService);\n    this._normal.fillViewportRows();\n\n    // The alt buffer should never have scrollback.\n    // See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer\n    this._alt = new Buffer(false, optionsService, bufferService);\n    this._activeBuffer = this._normal;\n\n    this.setupTabStops();\n  }\n\n  /**\n   * Returns the alt Buffer of the BufferSet\n   */\n  public get alt(): Buffer {\n    return this._alt;\n  }\n\n  /**\n   * Returns the normal Buffer of the BufferSet\n   */\n  public get active(): Buffer {\n    return this._activeBuffer;\n  }\n\n  /**\n   * Returns the currently active Buffer of the BufferSet\n   */\n  public get normal(): Buffer {\n    return this._normal;\n  }\n\n  /**\n   * Sets the normal Buffer of the BufferSet as its currently active Buffer\n   */\n  public activateNormalBuffer(): void {\n    if (this._activeBuffer === this._normal) {\n      return;\n    }\n    this._normal.x = this._alt.x;\n    this._normal.y = this._alt.y;\n    // The alt buffer should always be cleared when we switch to the normal\n    // buffer. This frees up memory since the alt buffer should always be new\n    // when activated.\n    this._alt.clear();\n    this._activeBuffer = this._normal;\n    this._onBufferActivate.fire({\n      activeBuffer: this._normal,\n      inactiveBuffer: this._alt\n    });\n  }\n\n  /**\n   * Sets the alt Buffer of the BufferSet as its currently active Buffer\n   */\n  public activateAltBuffer(fillAttr?: IAttributeData): void {\n    if (this._activeBuffer === this._alt) {\n      return;\n    }\n    // Since the alt buffer is always cleared when the normal buffer is\n    // activated, we want to fill it when switching to it.\n    this._alt.fillViewportRows(fillAttr);\n    this._alt.x = this._normal.x;\n    this._alt.y = this._normal.y;\n    this._activeBuffer = this._alt;\n    this._onBufferActivate.fire({\n      activeBuffer: this._alt,\n      inactiveBuffer: this._normal\n    });\n  }\n\n  /**\n   * Resizes both normal and alt buffers, adjusting their data accordingly.\n   * @param newCols The new number of columns.\n   * @param newRows The new number of rows.\n   */\n  public resize(newCols: number, newRows: number): void {\n    this._normal.resize(newCols, newRows);\n    this._alt.resize(newCols, newRows);\n  }\n\n  /**\n   * Setup the tab stops.\n   * @param i The index to start setting up tab stops from.\n   */\n  public setupTabStops(i?: number): void {\n    this._normal.setupTabStops(i);\n    this._alt.setupTabStops(i);\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { CircularList, IInsertEvent } from 'common/CircularList';\nimport { IBuffer, BufferIndex, IBufferStringIterator, IBufferStringIteratorResult } from 'common/buffer/Types';\nimport { IBufferLine, ICellData, IAttributeData, ICharset } from 'common/Types';\nimport { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';\nimport { CellData } from 'common/buffer/CellData';\nimport { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from 'common/buffer/Constants';\nimport { reflowLargerApplyNewLayout, reflowLargerCreateNewLayout, reflowLargerGetLinesToRemove, reflowSmallerGetNewLineLengths, getWrappedLineTrimmedLength } from 'common/buffer/BufferReflow';\nimport { Marker } from 'common/buffer/Marker';\nimport { IOptionsService, IBufferService } from 'common/services/Services';\nimport { DEFAULT_CHARSET } from 'common/data/Charsets';\n\nexport const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1\n\n/**\n * This class represents a terminal buffer (an internal state of the terminal), where the\n * following information is stored (in high-level):\n *   - text content of this particular buffer\n *   - cursor position\n *   - scroll position\n */\nexport class Buffer implements IBuffer {\n  public lines: CircularList<IBufferLine>;\n  public ydisp: number = 0;\n  public ybase: number = 0;\n  public y: number = 0;\n  public x: number = 0;\n  public scrollBottom: number;\n  public scrollTop: number;\n  // TODO: Type me\n  public tabs: any;\n  public savedY: number = 0;\n  public savedX: number = 0;\n  public savedCurAttrData = DEFAULT_ATTR_DATA.clone();\n  public savedCharset: ICharset | null = DEFAULT_CHARSET;\n  public markers: Marker[] = [];\n  private _nullCell: ICellData = CellData.fromCharData([0, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]);\n  private _whitespaceCell: ICellData = CellData.fromCharData([0, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE]);\n  private _cols: number;\n  private _rows: number;\n\n  constructor(\n    private _hasScrollback: boolean,\n    private _optionsService: IOptionsService,\n    private _bufferService: IBufferService\n  ) {\n    this._cols = this._bufferService.cols;\n    this._rows = this._bufferService.rows;\n    this.lines = new CircularList<IBufferLine>(this._getCorrectBufferLength(this._rows));\n    this.scrollTop = 0;\n    this.scrollBottom = this._rows - 1;\n    this.setupTabStops();\n  }\n\n  public getNullCell(attr?: IAttributeData): ICellData {\n    if (attr) {\n      this._nullCell.fg = attr.fg;\n      this._nullCell.bg = attr.bg;\n    } else {\n      this._nullCell.fg = 0;\n      this._nullCell.bg = 0;\n    }\n    return this._nullCell;\n  }\n\n  public getWhitespaceCell(attr?: IAttributeData): ICellData {\n    if (attr) {\n      this._whitespaceCell.fg = attr.fg;\n      this._whitespaceCell.bg = attr.bg;\n    } else {\n      this._whitespaceCell.fg = 0;\n      this._whitespaceCell.bg = 0;\n    }\n    return this._whitespaceCell;\n  }\n\n  public getBlankLine(attr: IAttributeData, isWrapped?: boolean): IBufferLine {\n    return new BufferLine(this._bufferService.cols, this.getNullCell(attr), isWrapped);\n  }\n\n  public get hasScrollback(): boolean {\n    return this._hasScrollback && this.lines.maxLength > this._rows;\n  }\n\n  public get isCursorInViewport(): boolean {\n    const absoluteY = this.ybase + this.y;\n    const relativeY = absoluteY - this.ydisp;\n    return (relativeY >= 0 && relativeY < this._rows);\n  }\n\n  /**\n   * Gets the correct buffer length based on the rows provided, the terminal's\n   * scrollback and whether this buffer is flagged to have scrollback or not.\n   * @param rows The terminal rows to use in the calculation.\n   */\n  private _getCorrectBufferLength(rows: number): number {\n    if (!this._hasScrollback) {\n      return rows;\n    }\n\n    const correctBufferLength = rows + this._optionsService.options.scrollback;\n\n    return correctBufferLength > MAX_BUFFER_SIZE ? MAX_BUFFER_SIZE : correctBufferLength;\n  }\n\n  /**\n   * Fills the buffer's viewport with blank lines.\n   */\n  public fillViewportRows(fillAttr?: IAttributeData): void {\n    if (this.lines.length === 0) {\n      if (fillAttr === undefined) {\n        fillAttr = DEFAULT_ATTR_DATA;\n      }\n      let i = this._rows;\n      while (i--) {\n        this.lines.push(this.getBlankLine(fillAttr));\n      }\n    }\n  }\n\n  /**\n   * Clears the buffer to it's initial state, discarding all previous data.\n   */\n  public clear(): void {\n    this.ydisp = 0;\n    this.ybase = 0;\n    this.y = 0;\n    this.x = 0;\n    this.lines = new CircularList<IBufferLine>(this._getCorrectBufferLength(this._rows));\n    this.scrollTop = 0;\n    this.scrollBottom = this._rows - 1;\n    this.setupTabStops();\n  }\n\n  /**\n   * Resizes the buffer, adjusting its data accordingly.\n   * @param newCols The new number of columns.\n   * @param newRows The new number of rows.\n   */\n  public resize(newCols: number, newRows: number): void {\n    // store reference to null cell with default attrs\n    const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);\n\n    // Increase max length if needed before adjustments to allow space to fill\n    // as required.\n    const newMaxLength = this._getCorrectBufferLength(newRows);\n    if (newMaxLength > this.lines.maxLength) {\n      this.lines.maxLength = newMaxLength;\n    }\n\n    // The following adjustments should only happen if the buffer has been\n    // initialized/filled.\n    if (this.lines.length > 0) {\n      // Deal with columns increasing (reducing needs to happen after reflow)\n      if (this._cols < newCols) {\n        for (let i = 0; i < this.lines.length; i++) {\n          this.lines.get(i)!.resize(newCols, nullCell);\n        }\n      }\n\n      // Resize rows in both directions as needed\n      let addToY = 0;\n      if (this._rows < newRows) {\n        for (let y = this._rows; y < newRows; y++) {\n          if (this.lines.length < newRows + this.ybase) {\n            if (this._optionsService.options.windowsMode) {\n              // Just add the new missing rows on Windows as conpty reprints the screen with it's\n              // view of the world. Once a line enters scrollback for conpty it remains there\n              this.lines.push(new BufferLine(newCols, nullCell));\n            } else {\n              if (this.ybase > 0 && this.lines.length <= this.ybase + this.y + addToY + 1) {\n                // There is room above the buffer and there are no empty elements below the line,\n                // scroll up\n                this.ybase--;\n                addToY++;\n                if (this.ydisp > 0) {\n                  // Viewport is at the top of the buffer, must increase downwards\n                  this.ydisp--;\n                }\n              } else {\n                // Add a blank line if there is no buffer left at the top to scroll to, or if there\n                // are blank lines after the cursor\n                this.lines.push(new BufferLine(newCols, nullCell));\n              }\n            }\n          }\n        }\n      } else { // (this._rows >= newRows)\n        for (let y = this._rows; y > newRows; y--) {\n          if (this.lines.length > newRows + this.ybase) {\n            if (this.lines.length > this.ybase + this.y + 1) {\n              // The line is a blank line below the cursor, remove it\n              this.lines.pop();\n            } else {\n              // The line is the cursor, scroll down\n              this.ybase++;\n              this.ydisp++;\n            }\n          }\n        }\n      }\n\n      // Reduce max length if needed after adjustments, this is done after as it\n      // would otherwise cut data from the bottom of the buffer.\n      if (newMaxLength < this.lines.maxLength) {\n        // Trim from the top of the buffer and adjust ybase and ydisp.\n        const amountToTrim = this.lines.length - newMaxLength;\n        if (amountToTrim > 0) {\n          this.lines.trimStart(amountToTrim);\n          this.ybase = Math.max(this.ybase - amountToTrim, 0);\n          this.ydisp = Math.max(this.ydisp - amountToTrim, 0);\n          this.savedY = Math.max(this.savedY - amountToTrim, 0);\n        }\n        this.lines.maxLength = newMaxLength;\n      }\n\n      // Make sure that the cursor stays on screen\n      this.x = Math.min(this.x, newCols - 1);\n      this.y = Math.min(this.y, newRows - 1);\n      if (addToY) {\n        this.y += addToY;\n      }\n      this.savedX = Math.min(this.savedX, newCols - 1);\n\n      this.scrollTop = 0;\n    }\n\n    this.scrollBottom = newRows - 1;\n\n    if (this._isReflowEnabled) {\n      this._reflow(newCols, newRows);\n\n      // Trim the end of the line off if cols shrunk\n      if (this._cols > newCols) {\n        for (let i = 0; i < this.lines.length; i++) {\n          this.lines.get(i)!.resize(newCols, nullCell);\n        }\n      }\n    }\n\n    this._cols = newCols;\n    this._rows = newRows;\n  }\n\n  private get _isReflowEnabled(): boolean {\n    return this._hasScrollback && !this._optionsService.options.windowsMode;\n  }\n\n  private _reflow(newCols: number, newRows: number): void {\n    if (this._cols === newCols) {\n      return;\n    }\n\n    // Iterate through rows, ignore the last one as it cannot be wrapped\n    if (newCols > this._cols) {\n      this._reflowLarger(newCols, newRows);\n    } else {\n      this._reflowSmaller(newCols, newRows);\n    }\n  }\n\n  private _reflowLarger(newCols: number, newRows: number): void {\n    const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA));\n    if (toRemove.length > 0) {\n      const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);\n      reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);\n      this._reflowLargerAdjustViewport(newCols, newRows, newLayoutResult.countRemoved);\n    }\n  }\n\n  private _reflowLargerAdjustViewport(newCols: number, newRows: number, countRemoved: number): void {\n    const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);\n    // Adjust viewport based on number of items removed\n    let viewportAdjustments = countRemoved;\n    while (viewportAdjustments-- > 0) {\n      if (this.ybase === 0) {\n        if (this.y > 0) {\n          this.y--;\n        }\n        if (this.lines.length < newRows) {\n          // Add an extra row at the bottom of the viewport\n          this.lines.push(new BufferLine(newCols, nullCell));\n        }\n      } else {\n        if (this.ydisp === this.ybase) {\n          this.ydisp--;\n        }\n        this.ybase--;\n      }\n    }\n    this.savedY = Math.max(this.savedY - countRemoved, 0);\n  }\n\n  private _reflowSmaller(newCols: number, newRows: number): void {\n    const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);\n    // Gather all BufferLines that need to be inserted into the Buffer here so that they can be\n    // batched up and only committed once\n    const toInsert = [];\n    let countToInsert = 0;\n    // Go backwards as many lines may be trimmed and this will avoid considering them\n    for (let y = this.lines.length - 1; y >= 0; y--) {\n      // Check whether this line is a problem\n      let nextLine = this.lines.get(y) as BufferLine;\n      if (!nextLine || !nextLine.isWrapped && nextLine.getTrimmedLength() <= newCols) {\n        continue;\n      }\n\n      // Gather wrapped lines and adjust y to be the starting line\n      const wrappedLines: BufferLine[] = [nextLine];\n      while (nextLine.isWrapped && y > 0) {\n        nextLine = this.lines.get(--y) as BufferLine;\n        wrappedLines.unshift(nextLine);\n      }\n\n      // If these lines contain the cursor don't touch them, the program will handle fixing up\n      // wrapped lines with the cursor\n      const absoluteY = this.ybase + this.y;\n      if (absoluteY >= y && absoluteY < y + wrappedLines.length) {\n        continue;\n      }\n\n      const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();\n      const destLineLengths = reflowSmallerGetNewLineLengths(wrappedLines, this._cols, newCols);\n      const linesToAdd = destLineLengths.length - wrappedLines.length;\n      let trimmedLines: number;\n      if (this.ybase === 0 && this.y !== this.lines.length - 1) {\n        // If the top section of the buffer is not yet filled\n        trimmedLines = Math.max(0, this.y - this.lines.maxLength + linesToAdd);\n      } else {\n        trimmedLines = Math.max(0, this.lines.length - this.lines.maxLength + linesToAdd);\n      }\n\n      // Add the new lines\n      const newLines: BufferLine[] = [];\n      for (let i = 0; i < linesToAdd; i++) {\n        const newLine = this.getBlankLine(DEFAULT_ATTR_DATA, true) as BufferLine;\n        newLines.push(newLine);\n      }\n      if (newLines.length > 0) {\n        toInsert.push({\n          // countToInsert here gets the actual index, taking into account other inserted items.\n          // using this we can iterate through the list forwards\n          start: y + wrappedLines.length + countToInsert,\n          newLines\n        });\n        countToInsert += newLines.length;\n      }\n      wrappedLines.push(...newLines);\n\n      // Copy buffer data to new locations, this needs to happen backwards to do in-place\n      let destLineIndex = destLineLengths.length - 1; // Math.floor(cellsNeeded / newCols);\n      let destCol = destLineLengths[destLineIndex]; // cellsNeeded % newCols;\n      if (destCol === 0) {\n        destLineIndex--;\n        destCol = destLineLengths[destLineIndex];\n      }\n      let srcLineIndex = wrappedLines.length - linesToAdd - 1;\n      let srcCol = lastLineLength;\n      while (srcLineIndex >= 0) {\n        const cellsToCopy = Math.min(srcCol, destCol);\n        wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol - cellsToCopy, destCol - cellsToCopy, cellsToCopy, true);\n        destCol -= cellsToCopy;\n        if (destCol === 0) {\n          destLineIndex--;\n          destCol = destLineLengths[destLineIndex];\n        }\n        srcCol -= cellsToCopy;\n        if (srcCol === 0) {\n          srcLineIndex--;\n          const wrappedLinesIndex = Math.max(srcLineIndex, 0);\n          srcCol = getWrappedLineTrimmedLength(wrappedLines, wrappedLinesIndex, this._cols);\n        }\n      }\n\n      // Null out the end of the line ends if a wide character wrapped to the following line\n      for (let i = 0; i < wrappedLines.length; i++) {\n        if (destLineLengths[i] < newCols) {\n          wrappedLines[i].setCell(destLineLengths[i], nullCell);\n        }\n      }\n\n      // Adjust viewport as needed\n      let viewportAdjustments = linesToAdd - trimmedLines;\n      while (viewportAdjustments-- > 0) {\n        if (this.ybase === 0) {\n          if (this.y < newRows - 1) {\n            this.y++;\n            this.lines.pop();\n          } else {\n            this.ybase++;\n            this.ydisp++;\n          }\n        } else {\n          // Ensure ybase does not exceed its maximum value\n          if (this.ybase < Math.min(this.lines.maxLength, this.lines.length + countToInsert) - newRows) {\n            if (this.ybase === this.ydisp) {\n              this.ydisp++;\n            }\n            this.ybase++;\n          }\n        }\n      }\n      this.savedY = Math.min(this.savedY + linesToAdd, this.ybase + newRows - 1);\n    }\n\n    // Rearrange lines in the buffer if there are any insertions, this is done at the end rather\n    // than earlier so that it's a single O(n) pass through the buffer, instead of O(n^2) from many\n    // costly calls to CircularList.splice.\n    if (toInsert.length > 0) {\n      // Record buffer insert events and then play them back backwards so that the indexes are\n      // correct\n      const insertEvents: IInsertEvent[] = [];\n\n      // Record original lines so they don't get overridden when we rearrange the list\n      const originalLines: BufferLine[] = [];\n      for (let i = 0; i < this.lines.length; i++) {\n        originalLines.push(this.lines.get(i) as BufferLine);\n      }\n      const originalLinesLength = this.lines.length;\n\n      let originalLineIndex = originalLinesLength - 1;\n      let nextToInsertIndex = 0;\n      let nextToInsert = toInsert[nextToInsertIndex];\n      this.lines.length = Math.min(this.lines.maxLength, this.lines.length + countToInsert);\n      let countInsertedSoFar = 0;\n      for (let i = Math.min(this.lines.maxLength - 1, originalLinesLength + countToInsert - 1); i >= 0; i--) {\n        if (nextToInsert && nextToInsert.start > originalLineIndex + countInsertedSoFar) {\n          // Insert extra lines here, adjusting i as needed\n          for (let nextI = nextToInsert.newLines.length - 1; nextI >= 0; nextI--) {\n            this.lines.set(i--, nextToInsert.newLines[nextI]);\n          }\n          i++;\n\n          // Create insert events for later\n          insertEvents.push({\n            index: originalLineIndex + 1,\n            amount: nextToInsert.newLines.length\n          });\n\n          countInsertedSoFar += nextToInsert.newLines.length;\n          nextToInsert = toInsert[++nextToInsertIndex];\n        } else {\n          this.lines.set(i, originalLines[originalLineIndex--]);\n        }\n      }\n\n      // Update markers\n      let insertCountEmitted = 0;\n      for (let i = insertEvents.length - 1; i >= 0; i--) {\n        insertEvents[i].index += insertCountEmitted;\n        this.lines.onInsertEmitter.fire(insertEvents[i]);\n        insertCountEmitted += insertEvents[i].amount;\n      }\n      const amountToTrim = Math.max(0, originalLinesLength + countToInsert - this.lines.maxLength);\n      if (amountToTrim > 0) {\n        this.lines.onTrimEmitter.fire(amountToTrim);\n      }\n    }\n  }\n\n  // private _reflowSmallerGetLinesNeeded()\n\n  /**\n   * Translates a string index back to a BufferIndex.\n   * To get the correct buffer position the string must start at `startCol` 0\n   * (default in translateBufferLineToString).\n   * The method also works on wrapped line strings given rows were not trimmed.\n   * The method operates on the CharData string length, there are no\n   * additional content or boundary checks. Therefore the string and the buffer\n   * should not be altered in between.\n   * TODO: respect trim flag after fixing #1685\n   * @param lineIndex line index the string was retrieved from\n   * @param stringIndex index within the string\n   * @param startCol column offset the string was retrieved from\n   */\n  public stringIndexToBufferIndex(lineIndex: number, stringIndex: number, trimRight: boolean = false): BufferIndex {\n    while (stringIndex) {\n      const line = this.lines.get(lineIndex);\n      if (!line) {\n        return [-1, -1];\n      }\n      const length = (trimRight) ? line.getTrimmedLength() : line.length;\n      for (let i = 0; i < length; ++i) {\n        if (line.get(i)[CHAR_DATA_WIDTH_INDEX]) {\n          // empty cells report a string length of 0, but get replaced\n          // with a whitespace in translateToString, thus replace with 1\n          stringIndex -= line.get(i)[CHAR_DATA_CHAR_INDEX].length || 1;\n        }\n        if (stringIndex < 0) {\n          return [lineIndex, i];\n        }\n      }\n      lineIndex++;\n    }\n    return [lineIndex, 0];\n  }\n\n  /**\n   * Translates a buffer line to a string, with optional start and end columns.\n   * Wide characters will count as two columns in the resulting string. This\n   * function is useful for getting the actual text underneath the raw selection\n   * position.\n   * @param line The line being translated.\n   * @param trimRight Whether to trim whitespace to the right.\n   * @param startCol The column to start at.\n   * @param endCol The column to end at.\n   */\n  public translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol: number = 0, endCol?: number): string {\n    const line = this.lines.get(lineIndex);\n    if (!line) {\n      return '';\n    }\n    return line.translateToString(trimRight, startCol, endCol);\n  }\n\n  public getWrappedRangeForLine(y: number): { first: number, last: number } {\n    let first = y;\n    let last = y;\n    // Scan upwards for wrapped lines\n    while (first > 0 && this.lines.get(first)!.isWrapped) {\n      first--;\n    }\n    // Scan downwards for wrapped lines\n    while (last + 1 < this.lines.length && this.lines.get(last + 1)!.isWrapped) {\n      last++;\n    }\n    return { first, last };\n  }\n\n  /**\n   * Setup the tab stops.\n   * @param i The index to start setting up tab stops from.\n   */\n  public setupTabStops(i?: number): void {\n    if (i !== null && i !== undefined) {\n      if (!this.tabs[i]) {\n        i = this.prevStop(i);\n      }\n    } else {\n      this.tabs = {};\n      i = 0;\n    }\n\n    for (; i < this._cols; i += this._optionsService.options.tabStopWidth) {\n      this.tabs[i] = true;\n    }\n  }\n\n  /**\n   * Move the cursor to the previous tab stop from the given position (default is current).\n   * @param x The position to move the cursor to the previous tab stop.\n   */\n  public prevStop(x?: number): number {\n    if (x === null || x === undefined) {\n      x = this.x;\n    }\n    while (!this.tabs[--x] && x > 0);\n    return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;\n  }\n\n  /**\n   * Move the cursor one tab stop forward from the given position (default is current).\n   * @param x The position to move the cursor one tab stop forward.\n   */\n  public nextStop(x?: number): number {\n    if (x === null || x === undefined) {\n      x = this.x;\n    }\n    while (!this.tabs[++x] && x < this._cols);\n    return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x;\n  }\n\n  public addMarker(y: number): Marker {\n    const marker = new Marker(y);\n    this.markers.push(marker);\n    marker.register(this.lines.onTrim(amount => {\n      marker.line -= amount;\n      // The marker should be disposed when the line is trimmed from the buffer\n      if (marker.line < 0) {\n        marker.dispose();\n      }\n    }));\n    marker.register(this.lines.onInsert(event => {\n      if (marker.line >= event.index) {\n        marker.line += event.amount;\n      }\n    }));\n    marker.register(this.lines.onDelete(event => {\n      // Delete the marker if it's within the range\n      if (marker.line >= event.index && marker.line < event.index + event.amount) {\n        marker.dispose();\n      }\n\n      // Shift the marker if it's after the deleted range\n      if (marker.line > event.index) {\n        marker.line -= event.amount;\n      }\n    }));\n    marker.register(marker.onDispose(() => this._removeMarker(marker)));\n    return marker;\n  }\n\n  private _removeMarker(marker: Marker): void {\n    this.markers.splice(this.markers.indexOf(marker), 1);\n  }\n\n  public iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator {\n    return new BufferStringIterator(this, trimRight, startIndex, endIndex, startOverscan, endOverscan);\n  }\n}\n\n/**\n * Iterator to get unwrapped content strings from the buffer.\n * The iterator returns at least the string data between the borders\n * `startIndex` and `endIndex` (exclusive) and will expand the lines\n * by `startOverscan` to the top and by `endOverscan` to the bottom,\n * if no new line was found in between.\n * It will never read/return string data beyond `startIndex - startOverscan`\n * or `endIndex + endOverscan`. Therefore the first and last line might be truncated.\n * It is possible to always get the full string for the first and last line as well\n * by setting the overscan values to the actual buffer length. This not recommended\n * since it might return the whole buffer within a single string in a worst case scenario.\n */\nexport class BufferStringIterator implements IBufferStringIterator {\n  private _current: number;\n\n  constructor (\n    private _buffer: IBuffer,\n    private _trimRight: boolean,\n    private _startIndex: number = 0,\n    private _endIndex: number = _buffer.lines.length,\n    private _startOverscan: number = 0,\n    private _endOverscan: number = 0\n  ) {\n    if (this._startIndex < 0) {\n      this._startIndex = 0;\n    }\n    if (this._endIndex > this._buffer.lines.length) {\n      this._endIndex = this._buffer.lines.length;\n    }\n    this._current = this._startIndex;\n  }\n\n  public hasNext(): boolean {\n    return this._current < this._endIndex;\n  }\n\n  public next(): IBufferStringIteratorResult {\n    const range = this._buffer.getWrappedRangeForLine(this._current);\n    // limit search window to overscan value at both borders\n    if (range.first < this._startIndex - this._startOverscan) {\n      range.first = this._startIndex - this._startOverscan;\n    }\n    if (range.last > this._endIndex + this._endOverscan) {\n      range.last = this._endIndex + this._endOverscan;\n    }\n    // limit to current buffer length\n    range.first = Math.max(range.first, 0);\n    range.last = Math.min(range.last, this._buffer.lines.length);\n    let result = '';\n    for (let i = range.first; i <= range.last; ++i) {\n      result += this._buffer.translateBufferLineToString(i, this._trimRight);\n    }\n    this._current = range.last + 1;\n    return {range: range, content: result};\n  }\n}\n","/**\n * Copyright (c) 2016 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICircularList } from 'common/Types';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\n\nexport interface IInsertEvent {\n  index: number;\n  amount: number;\n}\n\nexport interface IDeleteEvent {\n  index: number;\n  amount: number;\n}\n\n/**\n * Represents a circular list; a list with a maximum size that wraps around when push is called,\n * overriding values at the start of the list.\n */\nexport class CircularList<T> implements ICircularList<T> {\n  protected _array: (T | undefined)[];\n  private _startIndex: number;\n  private _length: number;\n\n  public onDeleteEmitter = new EventEmitter<IDeleteEvent>();\n  public get onDelete(): IEvent<IDeleteEvent> { return this.onDeleteEmitter.event; }\n  public onInsertEmitter = new EventEmitter<IInsertEvent>();\n  public get onInsert(): IEvent<IInsertEvent> { return this.onInsertEmitter.event; }\n  public onTrimEmitter = new EventEmitter<number>();\n  public get onTrim(): IEvent<number> { return this.onTrimEmitter.event; }\n\n  constructor(\n    private _maxLength: number\n  ) {\n    this._array = new Array<T>(this._maxLength);\n    this._startIndex = 0;\n    this._length = 0;\n  }\n\n  public get maxLength(): number {\n    return this._maxLength;\n  }\n\n  public set maxLength(newMaxLength: number) {\n    // There was no change in maxLength, return early.\n    if (this._maxLength === newMaxLength) {\n      return;\n    }\n\n    // Reconstruct array, starting at index 0. Only transfer values from the\n    // indexes 0 to length.\n    const newArray = new Array<T | undefined>(newMaxLength);\n    for (let i = 0; i < Math.min(newMaxLength, this.length); i++) {\n      newArray[i] = this._array[this._getCyclicIndex(i)];\n    }\n    this._array = newArray;\n    this._maxLength = newMaxLength;\n    this._startIndex = 0;\n  }\n\n  public get length(): number {\n    return this._length;\n  }\n\n  public set length(newLength: number) {\n    if (newLength > this._length) {\n      for (let i = this._length; i < newLength; i++) {\n        this._array[i] = undefined;\n      }\n    }\n    this._length = newLength;\n  }\n\n  /**\n   * Gets the value at an index.\n   *\n   * Note that for performance reasons there is no bounds checking here, the index reference is\n   * circular so this should always return a value and never throw.\n   * @param index The index of the value to get.\n   * @return The value corresponding to the index.\n   */\n  public get(index: number): T | undefined {\n    return this._array[this._getCyclicIndex(index)];\n  }\n\n  /**\n   * Sets the value at an index.\n   *\n   * Note that for performance reasons there is no bounds checking here, the index reference is\n   * circular so this should always return a value and never throw.\n   * @param index The index to set.\n   * @param value The value to set.\n   */\n  public set(index: number, value: T | undefined): void {\n    this._array[this._getCyclicIndex(index)] = value;\n  }\n\n  /**\n   * Pushes a new value onto the list, wrapping around to the start of the array, overriding index 0\n   * if the maximum length is reached.\n   * @param value The value to push onto the list.\n   */\n  public push(value: T): void {\n    this._array[this._getCyclicIndex(this._length)] = value;\n    if (this._length === this._maxLength) {\n      this._startIndex = ++this._startIndex % this._maxLength;\n      this.onTrimEmitter.fire(1);\n    } else {\n      this._length++;\n    }\n  }\n\n  /**\n   * Advance ringbuffer index and return current element for recycling.\n   * Note: The buffer must be full for this method to work.\n   * @throws When the buffer is not full.\n   */\n  public recycle(): T {\n    if (this._length !== this._maxLength) {\n      throw new Error('Can only recycle when the buffer is full');\n    }\n    this._startIndex = ++this._startIndex % this._maxLength;\n    this.onTrimEmitter.fire(1);\n    return this._array[this._getCyclicIndex(this._length - 1)]!;\n  }\n\n  /**\n   * Ringbuffer is at max length.\n   */\n  public get isFull(): boolean {\n    return this._length === this._maxLength;\n  }\n\n  /**\n   * Removes and returns the last value on the list.\n   * @return The popped value.\n   */\n  public pop(): T | undefined {\n    return this._array[this._getCyclicIndex(this._length-- - 1)];\n  }\n\n  /**\n   * Deletes and/or inserts items at a particular index (in that order). Unlike\n   * Array.prototype.splice, this operation does not return the deleted items as a new array in\n   * order to save creating a new array. Note that this operation may shift all values in the list\n   * in the worst case.\n   * @param start The index to delete and/or insert.\n   * @param deleteCount The number of elements to delete.\n   * @param items The items to insert.\n   */\n  public splice(start: number, deleteCount: number, ...items: T[]): void {\n    // Delete items\n    if (deleteCount) {\n      for (let i = start; i < this._length - deleteCount; i++) {\n        this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];\n      }\n      this._length -= deleteCount;\n    }\n\n    // Add items\n    for (let i = this._length - 1; i >= start; i--) {\n      this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];\n    }\n    for (let i = 0; i < items.length; i++) {\n      this._array[this._getCyclicIndex(start + i)] = items[i];\n    }\n\n    // Adjust length as needed\n    if (this._length + items.length > this._maxLength) {\n      const countToTrim = (this._length + items.length) - this._maxLength;\n      this._startIndex += countToTrim;\n      this._length = this._maxLength;\n      this.onTrimEmitter.fire(countToTrim);\n    } else {\n      this._length += items.length;\n    }\n  }\n\n  /**\n   * Trims a number of items from the start of the list.\n   * @param count The number of items to remove.\n   */\n  public trimStart(count: number): void {\n    if (count > this._length) {\n      count = this._length;\n    }\n    this._startIndex += count;\n    this._length -= count;\n    this.onTrimEmitter.fire(count);\n  }\n\n  public shiftElements(start: number, count: number, offset: number): void {\n    if (count <= 0) {\n      return;\n    }\n    if (start < 0 || start >= this._length) {\n      throw new Error('start argument out of range');\n    }\n    if (start + offset < 0) {\n      throw new Error('Cannot shift elements in list beyond index 0');\n    }\n\n    if (offset > 0) {\n      for (let i = count - 1; i >= 0; i--) {\n        this.set(start + i + offset, this.get(start + i));\n      }\n      const expandListBy = (start + count + offset) - this._length;\n      if (expandListBy > 0) {\n        this._length += expandListBy;\n        while (this._length > this._maxLength) {\n          this._length--;\n          this._startIndex++;\n          this.onTrimEmitter.fire(1);\n        }\n      }\n    } else {\n      for (let i = 0; i < count; i++) {\n        this.set(start + i + offset, this.get(start + i));\n      }\n    }\n  }\n\n  /**\n   * Gets the cyclic index for the specified regular index. The cyclic index can then be used on the\n   * backing array to get the element associated with the regular index.\n   * @param index The regular index.\n   * @returns The cyclic index.\n   */\n  private _getCyclicIndex(index: number): number {\n    return (this._startIndex + index) % this._maxLength;\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { BufferLine } from 'common/buffer/BufferLine';\nimport { CircularList } from 'common/CircularList';\nimport { IBufferLine, ICellData } from 'common/Types';\n\nexport interface INewLayoutResult {\n  layout: number[];\n  countRemoved: number;\n}\n\n/**\n * Evaluates and returns indexes to be removed after a reflow larger occurs. Lines will be removed\n * when a wrapped line unwraps.\n * @param lines The buffer lines.\n * @param newCols The columns after resize.\n */\nexport function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData): number[] {\n  // Gather all BufferLines that need to be removed from the Buffer here so that they can be\n  // batched up and only committed once\n  const toRemove: number[] = [];\n\n  for (let y = 0; y < lines.length - 1; y++) {\n    // Check if this row is wrapped\n    let i = y;\n    let nextLine = lines.get(++i) as BufferLine;\n    if (!nextLine.isWrapped) {\n      continue;\n    }\n\n    // Check how many lines it's wrapped for\n    const wrappedLines: BufferLine[] = [lines.get(y) as BufferLine];\n    while (i < lines.length && nextLine.isWrapped) {\n      wrappedLines.push(nextLine);\n      nextLine = lines.get(++i) as BufferLine;\n    }\n\n    // If these lines contain the cursor don't touch them, the program will handle fixing up wrapped\n    // lines with the cursor\n    if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {\n      y += wrappedLines.length - 1;\n      continue;\n    }\n\n    // Copy buffer data to new locations\n    let destLineIndex = 0;\n    let destCol = getWrappedLineTrimmedLength(wrappedLines, destLineIndex, oldCols);\n    let srcLineIndex = 1;\n    let srcCol = 0;\n    while (srcLineIndex < wrappedLines.length) {\n      const srcTrimmedTineLength = getWrappedLineTrimmedLength(wrappedLines, srcLineIndex, oldCols);\n      const srcRemainingCells = srcTrimmedTineLength - srcCol;\n      const destRemainingCells = newCols - destCol;\n      const cellsToCopy = Math.min(srcRemainingCells, destRemainingCells);\n\n      wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[srcLineIndex], srcCol, destCol, cellsToCopy, false);\n\n      destCol += cellsToCopy;\n      if (destCol === newCols) {\n        destLineIndex++;\n        destCol = 0;\n      }\n      srcCol += cellsToCopy;\n      if (srcCol === srcTrimmedTineLength) {\n        srcLineIndex++;\n        srcCol = 0;\n      }\n\n      // Make sure the last cell isn't wide, if it is copy it to the current dest\n      if (destCol === 0 && destLineIndex !== 0) {\n        if (wrappedLines[destLineIndex - 1].getWidth(newCols - 1) === 2) {\n          wrappedLines[destLineIndex].copyCellsFrom(wrappedLines[destLineIndex - 1], newCols - 1, destCol++, 1, false);\n          // Null out the end of the last row\n          wrappedLines[destLineIndex - 1].setCell(newCols - 1, nullCell);\n        }\n      }\n    }\n\n    // Clear out remaining cells or fragments could remain;\n    wrappedLines[destLineIndex].replaceCells(destCol, newCols, nullCell);\n\n    // Work backwards and remove any rows at the end that only contain null cells\n    let countToRemove = 0;\n    for (let i = wrappedLines.length - 1; i > 0; i--) {\n      if (i > destLineIndex || wrappedLines[i].getTrimmedLength() === 0) {\n        countToRemove++;\n      } else {\n        break;\n      }\n    }\n\n    if (countToRemove > 0) {\n      toRemove.push(y + wrappedLines.length - countToRemove); // index\n      toRemove.push(countToRemove);\n    }\n\n    y += wrappedLines.length - 1;\n  }\n  return toRemove;\n}\n\n/**\n * Creates and return the new layout for lines given an array of indexes to be removed.\n * @param lines The buffer lines.\n * @param toRemove The indexes to remove.\n */\nexport function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, toRemove: number[]): INewLayoutResult {\n  const layout: number[] = [];\n  // First iterate through the list and get the actual indexes to use for rows\n  let nextToRemoveIndex = 0;\n  let nextToRemoveStart = toRemove[nextToRemoveIndex];\n  let countRemovedSoFar = 0;\n  for (let i = 0; i < lines.length; i++) {\n    if (nextToRemoveStart === i) {\n      const countToRemove = toRemove[++nextToRemoveIndex];\n\n      // Tell markers that there was a deletion\n      lines.onDeleteEmitter.fire({\n        index: i - countRemovedSoFar,\n        amount: countToRemove\n      });\n\n      i += countToRemove - 1;\n      countRemovedSoFar += countToRemove;\n      nextToRemoveStart = toRemove[++nextToRemoveIndex];\n    } else {\n      layout.push(i);\n    }\n  }\n  return {\n    layout,\n    countRemoved: countRemovedSoFar\n  };\n}\n\n/**\n * Applies a new layout to the buffer. This essentially does the same as many splice calls but it's\n * done all at once in a single iteration through the list since splice is very expensive.\n * @param lines The buffer lines.\n * @param newLayout The new layout to apply.\n */\nexport function reflowLargerApplyNewLayout(lines: CircularList<IBufferLine>, newLayout: number[]): void {\n  // Record original lines so they don't get overridden when we rearrange the list\n  const newLayoutLines: BufferLine[] = [];\n  for (let i = 0; i < newLayout.length; i++) {\n    newLayoutLines.push(lines.get(newLayout[i]) as BufferLine);\n  }\n\n  // Rearrange the list\n  for (let i = 0; i < newLayoutLines.length; i++) {\n    lines.set(i, newLayoutLines[i]);\n  }\n  lines.length = newLayout.length;\n}\n\n/**\n * Gets the new line lengths for a given wrapped line. The purpose of this function it to pre-\n * compute the wrapping points since wide characters may need to be wrapped onto the following line.\n * This function will return an array of numbers of where each line wraps to, the resulting array\n * will only contain the values `newCols` (when the line does not end with a wide character) and\n * `newCols - 1` (when the line does end with a wide character), except for the last value which\n * will contain the remaining items to fill the line.\n *\n * Calling this with a `newCols` value of `1` will lock up.\n *\n * @param wrappedLines The wrapped lines to evaluate.\n * @param oldCols The columns before resize.\n * @param newCols The columns after resize.\n */\nexport function reflowSmallerGetNewLineLengths(wrappedLines: BufferLine[], oldCols: number, newCols: number): number[] {\n  const newLineLengths: number[] = [];\n  const cellsNeeded = wrappedLines.map((l, i) => getWrappedLineTrimmedLength(wrappedLines, i, oldCols)).reduce((p, c) => p + c);\n\n  // Use srcCol and srcLine to find the new wrapping point, use that to get the cellsAvailable and\n  // linesNeeded\n  let srcCol = 0;\n  let srcLine = 0;\n  let cellsAvailable = 0;\n  while (cellsAvailable < cellsNeeded) {\n    if (cellsNeeded - cellsAvailable < newCols) {\n      // Add the final line and exit the loop\n      newLineLengths.push(cellsNeeded - cellsAvailable);\n      break;\n    }\n    srcCol += newCols;\n    const oldTrimmedLength = getWrappedLineTrimmedLength(wrappedLines, srcLine, oldCols);\n    if (srcCol > oldTrimmedLength) {\n      srcCol -= oldTrimmedLength;\n      srcLine++;\n    }\n    const endsWithWide = wrappedLines[srcLine].getWidth(srcCol - 1) === 2;\n    if (endsWithWide) {\n      srcCol--;\n    }\n    const lineLength = endsWithWide ? newCols - 1 : newCols;\n    newLineLengths.push(lineLength);\n    cellsAvailable += lineLength;\n  }\n\n  return newLineLengths;\n}\n\nexport function getWrappedLineTrimmedLength(lines: BufferLine[], i: number, cols: number): number {\n  // If this is the last row in the wrapped line, get the actual trimmed length\n  if (i === lines.length - 1) {\n    return lines[i].getTrimmedLength();\n  }\n  // Detect whether the following line starts with a wide character and the end of the current line\n  // is null, if so then we can be pretty sure the null character should be excluded from the line\n  // length]\n  const endsInNull = !(lines[i].hasContent(cols - 1)) && lines[i].getWidth(cols - 1) === 1;\n  const followingLineStartsWithWide = lines[i + 1].getWidth(0) === 2;\n  if (endsInNull && followingLineStartsWithWide) {\n    return cols - 1;\n  }\n  return cols;\n}\n","/**\n * Copyright (c) 2018 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { Disposable } from 'common/Lifecycle';\nimport { IMarker } from 'common/Types';\n\nexport class Marker extends Disposable implements IMarker {\n  private static _nextId = 1;\n\n  private _id: number = Marker._nextId++;\n  public isDisposed: boolean = false;\n\n  public get id(): number { return this._id; }\n\n  private _onDispose = new EventEmitter<void>();\n  public get onDispose(): IEvent<void> { return this._onDispose.event; }\n\n  constructor(\n    public line: number\n  ) {\n    super();\n  }\n\n  public dispose(): void {\n    if (this.isDisposed) {\n      return;\n    }\n    this.isDisposed = true;\n    this.line = -1;\n    // Emit before super.dispose such that dispose listeners get a change to react\n    this._onDispose.fire();\n  }\n}\n","/**\n * Copyright (c) 2017 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICharSizeService, IRenderService, IMouseService } from './Services';\nimport { getCoords, getRawByteCoords } from 'browser/input/Mouse';\n\nexport class MouseService implements IMouseService {\n  serviceBrand: any;\n\n  constructor(\n    @IRenderService private readonly _renderService: IRenderService,\n    @ICharSizeService private readonly _charSizeService: ICharSizeService\n  ) {\n  }\n\n  public getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, isSelection?: boolean): [number, number] | undefined {\n    return getCoords(\n      event,\n      element,\n      colCount,\n      rowCount,\n      this._charSizeService.hasValidSize,\n      this._renderService.dimensions.actualCellWidth,\n      this._renderService.dimensions.actualCellHeight,\n      isSelection\n    );\n  }\n\n  public getRawByteCoords(event: MouseEvent, element: HTMLElement, colCount: number, rowCount: number): { x: number, y: number } | undefined {\n    const coords = this.getCoords(event, element, colCount, rowCount);\n    return getRawByteCoords(coords);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICoreService, ILogService, IOptionsService, IBufferService } from 'common/services/Services';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { IDecPrivateModes } from 'common/Types';\nimport { clone } from 'common/Clone';\n\nconst DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({\n  applicationCursorKeys: false\n});\n\nexport class CoreService implements ICoreService {\n  serviceBrand: any;\n\n  public isCursorInitialized: boolean = false;\n  public isCursorHidden: boolean = false;\n  public decPrivateModes: IDecPrivateModes;\n\n  private _onData = new EventEmitter<string>();\n  public get onData(): IEvent<string> { return this._onData.event; }\n  private _onUserInput = new EventEmitter<void>();\n  public get onUserInput(): IEvent<void> { return this._onUserInput.event; }\n  private _onBinary = new EventEmitter<string>();\n  public get onBinary(): IEvent<string> { return this._onBinary.event; }\n\n  constructor(\n    // TODO: Move this into a service\n    private readonly _scrollToBottom: () => void,\n    @IBufferService private readonly _bufferService: IBufferService,\n    @ILogService private readonly _logService: ILogService,\n    @IOptionsService private readonly _optionsService: IOptionsService\n  ) {\n    this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);\n  }\n\n  public reset(): void {\n    this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);\n  }\n\n  public triggerDataEvent(data: string, wasUserInput: boolean = false): void {\n    // Prevents all events to pty process if stdin is disabled\n    if (this._optionsService.options.disableStdin) {\n      return;\n    }\n\n    // Input is being sent to the terminal, the terminal should focus the prompt.\n    const buffer = this._bufferService.buffer;\n    if (buffer.ybase !== buffer.ydisp) {\n      this._scrollToBottom();\n    }\n\n    // Fire onUserInput so listeners can react as well (eg. clear selection)\n    if (wasUserInput) {\n      this._onUserInput.fire();\n    }\n\n    // Fire onData API\n    this._logService.debug(`sending data \"${data}\"`, () => data.split('').map(e => e.charCodeAt(0)));\n    this._onData.fire(data);\n  }\n\n  public triggerBinaryEvent(data: string): void {\n    if (this._optionsService.options.disableStdin) {\n      return;\n    }\n    this._logService.debug(`sending binary \"${data}\"`, () => data.split('').map(e => e.charCodeAt(0)));\n    this._onBinary.fire(data);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ILogService, IOptionsService } from 'common/services/Services';\n\ntype LogType = (message?: any, ...optionalParams: any[]) => void;\n\ninterface IConsole {\n  log: LogType;\n  error: LogType;\n  info: LogType;\n  trace: LogType;\n  warn: LogType;\n}\n\n// console is available on both node.js and browser contexts but the common\n// module doesn't depend on them so we need to explicitly declare it.\ndeclare const console: IConsole;\n\n\nexport enum LogLevel {\n  DEBUG = 0,\n  INFO = 1,\n  WARN = 2,\n  ERROR = 3,\n  OFF = 4\n}\n\nconst optionsKeyToLogLevel: { [key: string]: LogLevel } = {\n  debug: LogLevel.DEBUG,\n  info: LogLevel.INFO,\n  warn: LogLevel.WARN,\n  error: LogLevel.ERROR,\n  off: LogLevel.OFF\n};\n\nconst LOG_PREFIX = 'xterm.js: ';\n\nexport class LogService implements ILogService {\n  serviceBrand: any;\n\n  private _logLevel!: LogLevel;\n\n  constructor(\n    @IOptionsService private readonly _optionsService: IOptionsService\n  ) {\n    this._updateLogLevel();\n    this._optionsService.onOptionChange(key => {\n      if (key === 'logLevel') {\n        this._updateLogLevel();\n      }\n    });\n  }\n\n  private _updateLogLevel(): void {\n    this._logLevel = optionsKeyToLogLevel[this._optionsService.options.logLevel];\n  }\n\n  private _evalLazyOptionalParams(optionalParams: any[]): void {\n    for (let i = 0; i < optionalParams.length; i++) {\n      if (typeof optionalParams[i] === 'function') {\n        optionalParams[i] = optionalParams[i]();\n      }\n    }\n  }\n\n  private _log(type: LogType, message: string, optionalParams: any[]): void {\n    this._evalLazyOptionalParams(optionalParams);\n    type.call(console, LOG_PREFIX + message, ...optionalParams);\n  }\n\n  debug(message: string, ...optionalParams: any[]): void {\n    if (this._logLevel <= LogLevel.DEBUG) {\n      this._log(console.log, message, optionalParams);\n    }\n  }\n\n  info(message: string, ...optionalParams: any[]): void {\n    if (this._logLevel <= LogLevel.INFO) {\n      this._log(console.info, message, optionalParams);\n    }\n  }\n\n  warn(message: string, ...optionalParams: any[]): void {\n    if (this._logLevel <= LogLevel.WARN) {\n      this._log(console.warn, message, optionalParams);\n    }\n  }\n\n  error(message: string, ...optionalParams: any[]): void {\n    if (this._logLevel <= LogLevel.ERROR) {\n      this._log(console.error, message, optionalParams);\n    }\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { IBufferService, IDirtyRowService } from 'common/services/Services';\n\nexport class DirtyRowService implements IDirtyRowService {\n  serviceBrand: any;\n\n  private _start!: number;\n  private _end!: number;\n\n  public get start(): number { return this._start; }\n  public get end(): number { return this._end; }\n\n  constructor(\n    @IBufferService private readonly _bufferService: IBufferService\n  ) {\n    this.clearRange();\n  }\n\n  public clearRange(): void {\n    this._start = this._bufferService.buffer.y;\n    this._end = this._bufferService.buffer.y;\n  }\n\n  public markDirty(y: number): void {\n    if (y < this._start) {\n      this._start = y;\n    } else if (y > this._end) {\n      this._end = y;\n    }\n  }\n\n  public markRangeDirty(y1: number, y2: number): void {\n    if (y1 > y2) {\n      const temp = y1;\n      y1 = y2;\n      y2 = temp;\n    }\n    if (y1 < this._start) {\n      this._start = y1;\n    }\n    if (y2 > this._end) {\n      this._end = y2;\n    }\n  }\n\n  public markAllDirty(): void {\n    this.markRangeDirty(0, this._bufferService.rows - 1);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * This was heavily inspired from microsoft/vscode's dependency injection system (MIT).\n */\n/*---------------------------------------------------------------------------------------------\n *  Copyright (c) Microsoft Corporation. All rights reserved.\n *  Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IInstantiationService, IServiceIdentifier } from 'common/services/Services';\nimport { getServiceDependencies } from 'common/services/ServiceRegistry';\n\nexport class ServiceCollection {\n\n  private _entries = new Map<IServiceIdentifier<any>, any>();\n\n  constructor(...entries: [IServiceIdentifier<any>, any][]) {\n    for (const [id, service] of entries) {\n      this.set(id, service);\n    }\n  }\n\n  set<T>(id: IServiceIdentifier<T>, instance: T): T {\n    const result = this._entries.get(id);\n    this._entries.set(id, instance);\n    return result;\n  }\n\n  forEach(callback: (id: IServiceIdentifier<any>, instance: any) => any): void {\n    this._entries.forEach((value, key) => callback(key, value));\n  }\n\n  has(id: IServiceIdentifier<any>): boolean {\n    return this._entries.has(id);\n  }\n\n  get<T>(id: IServiceIdentifier<T>): T {\n    return this._entries.get(id);\n  }\n}\n\nexport class InstantiationService implements IInstantiationService {\n  private readonly _services: ServiceCollection = new ServiceCollection();\n\n  constructor() {\n    this._services.set(IInstantiationService, this);\n  }\n\n  public setService<T>(id: IServiceIdentifier<T>, instance: T): void {\n    this._services.set(id, instance);\n  }\n\n  public createInstance<T>(ctor: any, ...args: any[]): any {\n    const serviceDependencies = getServiceDependencies(ctor).sort((a, b) => a.index - b.index);\n\n    const serviceArgs: any[] = [];\n    for (const dependency of serviceDependencies) {\n      const service = this._services.get(dependency.id);\n      if (!service) {\n        throw new Error(`[createInstance] ${ctor.name} depends on UNKNOWN service ${dependency.id}.`);\n      }\n      serviceArgs.push(service);\n    }\n\n    const firstServiceArgPos = serviceDependencies.length > 0 ? serviceDependencies[0].index : args.length;\n\n    // check for argument mismatches, adjust static args if needed\n    if (args.length !== firstServiceArgPos) {\n      throw new Error(`[createInstance] First service dependency of ${ctor.name} at position ${firstServiceArgPos + 1} conflicts with ${args.length} static arguments`);\n    }\n\n    // now create the instance\n    return <T>new ctor(...[...args, ...serviceArgs]);\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\nimport { IBufferService, ICoreService, ICoreMouseService } from 'common/services/Services';\nimport { EventEmitter, IEvent } from 'common/EventEmitter';\nimport { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';\n\n/**\n * Supported default protocols.\n */\nconst DEFAULT_PROTOCOLS: {[key: string]: ICoreMouseProtocol} = {\n  /**\n   * NONE\n   * Events: none\n   * Modifiers: none\n   */\n  NONE: {\n    events: CoreMouseEventType.NONE,\n    restrict: () => false\n  },\n  /**\n   * X10\n   * Events: mousedown\n   * Modifiers: none\n   */\n  X10: {\n    events: CoreMouseEventType.DOWN,\n    restrict: (e: ICoreMouseEvent) => {\n      // no wheel, no move, no up\n      if (e.button === CoreMouseButton.WHEEL || e.action !== CoreMouseAction.DOWN) {\n        return false;\n      }\n      // no modifiers\n      e.ctrl = false;\n      e.alt = false;\n      e.shift = false;\n      return true;\n    }\n  },\n  /**\n   * VT200\n   * Events: mousedown / mouseup / wheel\n   * Modifiers: all\n   */\n  VT200: {\n    events: CoreMouseEventType.DOWN | CoreMouseEventType.UP | CoreMouseEventType.WHEEL,\n    restrict: (e: ICoreMouseEvent) => {\n      // no move\n      if (e.action === CoreMouseAction.MOVE) {\n        return false;\n      }\n      return true;\n    }\n  },\n  /**\n   * DRAG\n   * Events: mousedown / mouseup / wheel / mousedrag\n   * Modifiers: all\n   */\n  DRAG: {\n    events: CoreMouseEventType.DOWN | CoreMouseEventType.UP | CoreMouseEventType.WHEEL | CoreMouseEventType.DRAG,\n    restrict: (e: ICoreMouseEvent) => {\n      // no move without button\n      if (e.action === CoreMouseAction.MOVE && e.button === CoreMouseButton.NONE) {\n        return false;\n      }\n      return true;\n    }\n  },\n  /**\n   * ANY\n   * Events: all mouse related events\n   * Modifiers: all\n   */\n  ANY: {\n    events:\n      CoreMouseEventType.DOWN | CoreMouseEventType.UP | CoreMouseEventType.WHEEL\n      | CoreMouseEventType.DRAG | CoreMouseEventType.MOVE,\n    restrict: (e: ICoreMouseEvent) => true\n  }\n};\n\nconst enum Modifiers {\n  SHIFT = 4,\n  ALT = 8,\n  CTRL = 16\n}\n\n// helper for default encoders to generate the event code.\nfunction eventCode(e: ICoreMouseEvent, isSGR: boolean): number {\n  let code = (e.ctrl ? Modifiers.CTRL : 0) | (e.shift ? Modifiers.SHIFT : 0) | (e.alt ? Modifiers.ALT : 0);\n  if (e.button === CoreMouseButton.WHEEL) {\n    code |= 64;\n    code |= e.action;\n  } else {\n    code |= e.button & 3;\n    if (e.button & 4) {\n      code |= 64;\n    }\n    if (e.button & 8) {\n      code |= 128;\n    }\n    if (e.action === CoreMouseAction.MOVE) {\n      code |= CoreMouseAction.MOVE;\n    } else if (e.action === CoreMouseAction.UP && !isSGR) {\n      // special case - only SGR can report button on release\n      // all others have to go with NONE\n      code |= CoreMouseButton.NONE;\n    }\n  }\n  return code;\n}\n\nconst S = String.fromCharCode;\n\n/**\n * Supported default encodings.\n */\nconst DEFAULT_ENCODINGS: {[key: string]: CoreMouseEncoding} = {\n  /**\n   * DEFAULT - CSI M Pb Px Py\n   * Single byte encoding for coords and event code.\n   * Can encode values up to 223 (1-based).\n   */\n  DEFAULT: (e: ICoreMouseEvent) => {\n    const params = [eventCode(e, false) + 32, e.col + 32, e.row + 32];\n    // supress mouse report if we exceed addressible range\n    // Note this is handled differently by emulators\n    // - xterm:         sends 0;0 coords instead\n    // - vte, konsole:  no report\n    if (params[0] > 255 || params[1] > 255 || params[2] > 255) {\n      return '';\n    }\n    return `\\x1b[M${S(params[0])}${S(params[1])}${S(params[2])}`;\n  },\n  /**\n   * SGR - CSI < Pb ; Px ; Py M|m\n   * No encoding limitation.\n   * Can report button on release and works with a well formed sequence.\n   */\n  SGR: (e: ICoreMouseEvent) => {\n    const final = (e.action === CoreMouseAction.UP && e.button !== CoreMouseButton.WHEEL) ? 'm' : 'M';\n    return `\\x1b[<${eventCode(e, true)};${e.col};${e.row}${final}`;\n  }\n};\n\n/**\n * CoreMouseService\n *\n * Provides mouse tracking reports with different protocols and encodings.\n *  - protocols: NONE (default), X10, VT200, DRAG, ANY\n *  - encodings: DEFAULT, SGR (UTF8, URXVT removed in #2507)\n *\n * Custom protocols/encodings can be added by `addProtocol` / `addEncoding`.\n * To activate a protocol/encoding, set `activeProtocol` / `activeEncoding`.\n * Switching a protocol will send a notification event `onProtocolChange`\n * with a list of needed events to track.\n *\n * The service handles the mouse tracking state and decides whether to send\n * a tracking report to the backend based on protocol and encoding limitations.\n * To send a mouse event call `triggerMouseEvent`.\n */\nexport class CoreMouseService implements ICoreMouseService {\n  private _protocols: {[name: string]: ICoreMouseProtocol} = {};\n  private _encodings: {[name: string]: CoreMouseEncoding} = {};\n  private _activeProtocol: string = '';\n  private _activeEncoding: string = '';\n  private _onProtocolChange = new EventEmitter<CoreMouseEventType>();\n  private _lastEvent: ICoreMouseEvent | null = null;\n\n  constructor(\n    @IBufferService private readonly _bufferService: IBufferService,\n    @ICoreService private readonly _coreService: ICoreService\n  ) {\n    // register default protocols and encodings\n    Object.keys(DEFAULT_PROTOCOLS).forEach(name => this.addProtocol(name, DEFAULT_PROTOCOLS[name]));\n    Object.keys(DEFAULT_ENCODINGS).forEach(name => this.addEncoding(name, DEFAULT_ENCODINGS[name]));\n    // call reset to set defaults\n    this.reset();\n  }\n\n  public addProtocol(name: string, protocol: ICoreMouseProtocol): void {\n    this._protocols[name] = protocol;\n  }\n\n  public addEncoding(name: string, encoding: CoreMouseEncoding): void {\n    this._encodings[name] = encoding;\n  }\n\n  public get activeProtocol(): string {\n    return this._activeProtocol;\n  }\n\n  public set activeProtocol(name: string) {\n    if (!this._protocols[name]) {\n      throw new Error(`unknown protocol \"${name}\"`);\n    }\n    this._activeProtocol = name;\n    this._onProtocolChange.fire(this._protocols[name].events);\n  }\n\n  public get activeEncoding(): string {\n    return this._activeEncoding;\n  }\n\n  public set activeEncoding(name: string) {\n    if (!this._encodings[name]) {\n      throw new Error(`unknown encoding \"${name}\"`);\n    }\n    this._activeEncoding = name;\n  }\n\n  public reset(): void {\n    this.activeProtocol = 'NONE';\n    this.activeEncoding = 'DEFAULT';\n    this._lastEvent = null;\n  }\n\n  /**\n   * Event to announce changes in mouse tracking.\n   */\n  public get onProtocolChange(): IEvent<CoreMouseEventType> {\n    return this._onProtocolChange.event;\n  }\n\n  /**\n   * Triggers a mouse event to be sent.\n   *\n   * Returns true if the event passed all protocol restrictions and a report\n   * was sent, otherwise false. The return value may be used to decide whether\n   * the default event action in the bowser component should be omitted.\n   *\n   * Note: The method will change values of the given event object\n   * to fullfill protocol and encoding restrictions.\n   */\n  public triggerMouseEvent(e: ICoreMouseEvent): boolean {\n    // range check for col/row\n    if (e.col < 0 || e.col >= this._bufferService.cols\n        || e.row < 0 || e.row >= this._bufferService.rows) {\n      return false;\n    }\n\n    // filter nonsense combinations of button + action\n    if (e.button === CoreMouseButton.WHEEL && e.action === CoreMouseAction.MOVE) {\n      return false;\n    }\n    if (e.button === CoreMouseButton.NONE && e.action !== CoreMouseAction.MOVE) {\n      return false;\n    }\n    if (e.button !== CoreMouseButton.WHEEL && (e.action === CoreMouseAction.LEFT || e.action === CoreMouseAction.RIGHT)) {\n      return false;\n    }\n\n    // report 1-based coords\n    e.col++;\n    e.row++;\n\n    // debounce move at grid level\n    if (e.action === CoreMouseAction.MOVE && this._lastEvent && this._compareEvents(this._lastEvent, e)) {\n      return false;\n    }\n\n    // apply protocol restrictions\n    if (!this._protocols[this._activeProtocol].restrict(e)) {\n      return false;\n    }\n\n    // encode report and send\n    const report = this._encodings[this._activeEncoding](e);\n    if (report) {\n      // always send DEFAULT as binary data\n      if (this._activeEncoding === 'DEFAULT') {\n        this._coreService.triggerBinaryEvent(report);\n      } else {\n        this._coreService.triggerDataEvent(report, true);\n      }\n    }\n\n    this._lastEvent = e;\n\n    return true;\n  }\n\n  public explainEvents(events: CoreMouseEventType): {[event: string]: boolean} {\n    return {\n      DOWN: !!(events & CoreMouseEventType.DOWN),\n      UP: !!(events & CoreMouseEventType.UP),\n      DRAG: !!(events & CoreMouseEventType.DRAG),\n      MOVE: !!(events & CoreMouseEventType.MOVE),\n      WHEEL: !!(events & CoreMouseEventType.WHEEL)\n    };\n  }\n\n  private _compareEvents(e1: ICoreMouseEvent, e2: ICoreMouseEvent): boolean {\n    if (e1.col !== e2.col) return false;\n    if (e1.row !== e2.row) return false;\n    if (e1.button !== e2.button) return false;\n    if (e1.action !== e2.action) return false;\n    if (e1.ctrl !== e2.ctrl) return false;\n    if (e1.alt !== e2.alt) return false;\n    if (e1.shift !== e2.shift) return false;\n    return true;\n  }\n}\n","\n/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\ndeclare const setTimeout: (handler: () => void, timeout?: number) => void;\n\n/**\n * Safety watermark to avoid memory exhaustion and browser engine crash on fast data input.\n * Enable flow control to avoid this limit and make sure that your backend correctly\n * propagates this to the underlying pty. (see docs for further instructions)\n * Since this limit is meant as a safety parachute to prevent browser crashs,\n * it is set to a very high number. Typically xterm.js gets unresponsive with\n * a 100 times lower number (>500 kB).\n */\nconst DISCARD_WATERMARK = 50000000; // ~50 MB\n\n/**\n * The max number of ms to spend on writes before allowing the renderer to\n * catch up with a 0ms setTimeout. A value of < 33 to keep us close to\n * 30fps, and a value of < 16 to try to run at 60fps. Of course, the real FPS\n * depends on the time it takes for the renderer to draw the frame.\n */\nconst WRITE_TIMEOUT_MS = 12;\n\n/**\n * Threshold of max held chunks in the write buffer, that were already processed.\n * This is a tradeoff between extensive write buffer shifts (bad runtime) and high\n * memory consumption by data thats not used anymore.\n */\nconst WRITE_BUFFER_LENGTH_THRESHOLD = 50;\n\nexport class WriteBuffer {\n  private _writeBuffer: (string | Uint8Array)[] = [];\n  private _callbacks: ((() => void) | undefined)[] = [];\n  private _pendingData = 0;\n  private _bufferOffset = 0;\n\n  constructor(private _action: (data: string | Uint8Array) => void) { }\n\n  public writeSync(data: string | Uint8Array): void {\n    // force sync processing on pending data chunks to avoid in-band data scrambling\n    // does the same as innerWrite but without event loop\n    if (this._writeBuffer.length) {\n      for (let i = this._bufferOffset; i < this._writeBuffer.length; ++i) {\n        const data = this._writeBuffer[i];\n        const cb = this._callbacks[i];\n        this._action(data);\n        if (cb) cb();\n      }\n      // reset all to avoid reprocessing of chunks with scheduled innerWrite call\n      this._writeBuffer = [];\n      this._callbacks = [];\n      this._pendingData = 0;\n      // stop scheduled innerWrite by offset > length condition\n      this._bufferOffset = 0x7FFFFFFF;\n    }\n    // handle current data chunk\n    this._action(data);\n  }\n\n  public write(data: string | Uint8Array, callback?: () => void): void {\n    if (this._pendingData > DISCARD_WATERMARK) {\n      throw new Error('write data discarded, use flow control to avoid losing data');\n    }\n\n    // schedule chunk processing for next event loop run\n    if (!this._writeBuffer.length) {\n      this._bufferOffset = 0;\n      setTimeout(() => this._innerWrite());\n    }\n\n    this._pendingData += data.length;\n    this._writeBuffer.push(data);\n    this._callbacks.push(callback);\n  }\n\n  protected _innerWrite(): void {\n    const startTime = Date.now();\n    while (this._writeBuffer.length > this._bufferOffset) {\n      const data = this._writeBuffer[this._bufferOffset];\n      const cb = this._callbacks[this._bufferOffset];\n      this._bufferOffset++;\n\n      this._action(data);\n      this._pendingData -= data.length;\n      if (cb) cb();\n\n      if (Date.now() - startTime >= WRITE_TIMEOUT_MS) {\n        break;\n      }\n    }\n    if (this._writeBuffer.length > this._bufferOffset) {\n      // Allow renderer to catch up before processing the next batch\n      // trim already processed chunks if we are above threshold\n      if (this._bufferOffset > WRITE_BUFFER_LENGTH_THRESHOLD) {\n        this._writeBuffer = this._writeBuffer.slice(this._bufferOffset);\n        this._callbacks = this._callbacks.slice(this._bufferOffset);\n        this._bufferOffset = 0;\n      }\n      setTimeout(() => this._innerWrite(), 0);\n    } else {\n      this._writeBuffer = [];\n      this._callbacks = [];\n      this._pendingData = 0;\n      this._bufferOffset = 0;\n    }\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ICoreBrowserService } from './Services';\n\nexport class CoreBrowserService implements ICoreBrowserService {\n  serviceBrand: any;\n\n  constructor(\n    private _textarea: HTMLTextAreaElement\n  ) {\n  }\n\n  public get isFocused(): boolean {\n    return document.activeElement === this._textarea && document.hasFocus();\n  }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ITerminalAddon, IDisposable, Terminal } from 'xterm';\n\nexport interface ILoadedAddon {\n  instance: ITerminalAddon;\n  dispose: () => void;\n  isDisposed: boolean;\n}\n\nexport class AddonManager implements IDisposable {\n  protected _addons: ILoadedAddon[] = [];\n\n  constructor() {\n  }\n\n  public dispose(): void {\n    for (let i = this._addons.length - 1; i >= 0; i--) {\n      this._addons[i].instance.dispose();\n    }\n  }\n\n  public loadAddon(terminal: Terminal, instance: ITerminalAddon): void {\n    const loadedAddon: ILoadedAddon = {\n      instance,\n      dispose: instance.dispose,\n      isDisposed: false\n    };\n    this._addons.push(loadedAddon);\n    instance.dispose = () => this._wrappedAddonDispose(loadedAddon);\n    instance.activate(<any>terminal);\n  }\n\n  private _wrappedAddonDispose(loadedAddon: ILoadedAddon): void {\n    if (loadedAddon.isDisposed) {\n      // Do nothing if already disposed\n      return;\n    }\n    let index = -1;\n    for (let i = 0; i < this._addons.length; i++) {\n      if (this._addons[i] === loadedAddon) {\n        index = i;\n        break;\n      }\n    }\n    if (index === -1) {\n      throw new Error('Could not dispose an addon that has not been loaded');\n    }\n    loadedAddon.isDisposed = true;\n    loadedAddon.dispose.apply(loadedAddon.instance);\n    this._addons.splice(index, 1);\n  }\n}\n"],"sourceRoot":""}
\ No newline at end of file
-- 
2.20.1





More information about the pve-devel mailing list