webssh2/public/webssh2.bundle.js
2018-02-09 09:06:56 -05:00

8616 lines
No EOL
380 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_socket_io_client_dist_socket_io_js__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_socket_io_client_dist_socket_io_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__node_modules_socket_io_client_dist_socket_io_js__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_xterm_dist_xterm__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_xterm_dist_xterm___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__node_modules_xterm_dist_xterm__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__node_modules_xterm_dist_addons_fit_fit__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__node_modules_xterm_dist_addons_fit_fit___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__node_modules_xterm_dist_addons_fit_fit__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__fortawesome_fontawesome__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__fortawesome_fontawesome_free_solid_faBars__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__fortawesome_fontawesome_free_solid_faBars___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__fortawesome_fontawesome_free_solid_faBars__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__fortawesome_fontawesome_free_solid_faClipboard__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__fortawesome_fontawesome_free_solid_faClipboard___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5__fortawesome_fontawesome_free_solid_faClipboard__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__fortawesome_fontawesome_free_solid_faDownload__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__fortawesome_fontawesome_free_solid_faDownload___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__fortawesome_fontawesome_free_solid_faDownload__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__fortawesome_fontawesome_free_solid_faKey__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__fortawesome_fontawesome_free_solid_faKey___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__fortawesome_fontawesome_free_solid_faKey__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_solid_faCog__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_solid_faCog___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_solid_faCog__);
// import faQuestion from '@fortawesome/fontawesome-free-solid/faQuestion'
__WEBPACK_IMPORTED_MODULE_3__fortawesome_fontawesome__["a" /* default */].library.add(__WEBPACK_IMPORTED_MODULE_4__fortawesome_fontawesome_free_solid_faBars___default.a, __WEBPACK_IMPORTED_MODULE_5__fortawesome_fontawesome_free_solid_faClipboard___default.a, __WEBPACK_IMPORTED_MODULE_6__fortawesome_fontawesome_free_solid_faDownload___default.a, __WEBPACK_IMPORTED_MODULE_7__fortawesome_fontawesome_free_solid_faKey___default.a, __WEBPACK_IMPORTED_MODULE_8__fortawesome_fontawesome_free_solid_faCog___default.a)
__WEBPACK_IMPORTED_MODULE_3__fortawesome_fontawesome__["a" /* default */].config.searchPseudoElements = true
__WEBPACK_IMPORTED_MODULE_3__fortawesome_fontawesome__["a" /* default */].dom.i2svg()
__webpack_require__(11)
__webpack_require__(12)
__WEBPACK_IMPORTED_MODULE_1__node_modules_xterm_dist_xterm__["applyAddon"](__WEBPACK_IMPORTED_MODULE_2__node_modules_xterm_dist_addons_fit_fit__)
/* global Blob */
var sessionLogEnable = false
var loggedData = false
var sessionLog, sessionFooter, logDate, currentDate, myFile, errorExists
var downloadLogBtn = document.getElementById('downloadLogBtn')
var credentialsBtn = document.getElementById('credentialsBtn')
var logBtn = document.getElementById('logBtn')
logBtn.addEventListener('click', toggleLog)
logBtn.style.color = '#000'
var terminalContainer = document.getElementById('terminal-container')
var term = new __WEBPACK_IMPORTED_MODULE_1__node_modules_xterm_dist_xterm__({
cursorBlink: true
})
var socket, termid // eslint-disable-line
term.open(terminalContainer)
term.focus()
term.fit()
if (document.location.pathname) {
var parts = document.location.pathname.split('/')
var base = parts.slice(0, parts.length - 1).join('/') + '/'
var resource = base.substring(1) + 'socket.io'
socket = __WEBPACK_IMPORTED_MODULE_0__node_modules_socket_io_client_dist_socket_io_js__["connect"](null, {
resource: resource
})
} else {
socket = __WEBPACK_IMPORTED_MODULE_0__node_modules_socket_io_client_dist_socket_io_js__["connect"]()
}
socket.on('connect', function () {
socket.emit('geometry', term.cols, term.rows)
console.log('geometry cols: ' + term.cols + ' rows: ' + term.rows)
})
term.on('data', function (data) {
socket.emit('data', data)
})
socket.on('title', function (data) {
document.title = data
}).on('status', function (data) {
document.getElementById('status').innerHTML = data
}).on('ssherror', function (data) {
document.getElementById('status').innerHTML = data
document.getElementById('status').style.backgroundColor = 'red'
errorExists = true
}).on('headerBackground', function (data) {
document.getElementById('header').style.backgroundColor = data
}).on('header', function (data) {
document.getElementById('header').innerHTML = data
}).on('footer', function (data) {
sessionFooter = data
document.getElementById('footer').innerHTML = data
}).on('statusBackground', function (data) {
document.getElementById('status').style.backgroundColor = data
}).on('allowreplay', function (data) {
if (data === true) {
console.log('allowreplay: ' + data)
credentialsBtn.style.color = '#000'
credentialsBtn.addEventListener('click', replayCredentials)
} else {
console.log('allowreplay: ' + data)
credentialsBtn.style.color = '#666'
}
}).on('data', function (data) {
term.write(data)
if (sessionLogEnable) {
sessionLog = sessionLog + data
}
}).on('disconnect', function (err) {
if (!errorExists) {
document.getElementById('status').style.backgroundColor = 'red'
document.getElementById('status').innerHTML =
'WEBSOCKET SERVER DISCONNECTED: ' + err
}
socket.io.reconnection(false)
}).on('error', function (err) {
if (!errorExists) {
document.getElementById('status').style.backgroundColor = 'red'
document.getElementById('status').innerHTML = 'ERROR: ' + err
}
})
// replay password to server, requires
function replayCredentials () { // eslint-disable-line
socket.emit('control', 'replayCredentials')
console.log('replaying credentials')
term.focus()
return false
}
// Set variable to toggle log data from client/server to a varialble
// for later download
function toggleLog () { // eslint-disable-line
if (sessionLogEnable === true) {
sessionLogEnable = false
loggedData = true
logBtn.innerHTML = '<i class="fas fa-clipboard fa-fw"></i> Start Log'
console.log('stopping log, ' + sessionLogEnable)
currentDate = new Date()
sessionLog = sessionLog + '\r\n\r\nLog End for ' + sessionFooter + ': ' +
currentDate.getFullYear() + '/' + (currentDate.getMonth() + 1) + '/' +
currentDate.getDate() + ' @ ' + currentDate.getHours() + ':' +
currentDate.getMinutes() + ':' + currentDate.getSeconds() + '\r\n'
logDate = currentDate
term.focus()
return false
} else {
sessionLogEnable = true
loggedData = true
logBtn.innerHTML = '<i class="fas fa-cog fa-spin fa-fw"></i> Stop Log'
downloadLogBtn.style.color = '#000'
downloadLogBtn.addEventListener('click', downloadLog)
console.log('starting log, ' + sessionLogEnable)
currentDate = new Date()
sessionLog = 'Log Start for ' + sessionFooter + ': ' +
currentDate.getFullYear() + '/' + (currentDate.getMonth() + 1) + '/' +
currentDate.getDate() + ' @ ' + currentDate.getHours() + ':' +
currentDate.getMinutes() + ':' + currentDate.getSeconds() + '\r\n\r\n'
logDate = currentDate
term.focus()
return false
}
}
// cross browser method to "download" an element to the local system
// used for our client-side logging feature
function downloadLog () { // eslint-disable-line
if (loggedData === true) {
myFile = 'WebSSH2-' + logDate.getFullYear() + (logDate.getMonth() + 1) +
logDate.getDate() + '_' + logDate.getHours() + logDate.getMinutes() +
logDate.getSeconds() + '.log'
// regex should eliminate escape sequences from being logged.
var blob = new Blob([sessionLog.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '')], {
type: 'text/plain'
})
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveBlob(blob, myFile)
} else {
var elem = window.document.createElement('a')
elem.href = window.URL.createObjectURL(blob)
elem.download = myFile
document.body.appendChild(elem)
elem.click()
document.body.removeChild(elem)
}
}
term.focus()
}
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
!function(t,e){ true?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.io=e():t.io=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e){"object"===("undefined"==typeof t?"undefined":o(t))&&(e=t,t=void 0),e=e||{};var n,r=i(t),s=r.source,u=r.id,h=r.path,f=p[u]&&h in p[u].nsps,l=e.forceNew||e["force new connection"]||!1===e.multiplex||f;return l?(c("ignoring socket cache for %s",s),n=a(s,e)):(p[u]||(c("new io instance for %s",s),p[u]=a(s,e)),n=p[u]),r.query&&!e.query&&(e.query=r.query),n.socket(r.path,e)}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=n(1),s=n(7),a=n(13),c=n(3)("socket.io-client");t.exports=e=r;var p=e.managers={};e.protocol=s.protocol,e.connect=r,e.Manager=n(13),e.Socket=n(37)},function(t,e,n){(function(e){"use strict";function r(t,n){var r=t;n=n||e.location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(i("protocol-less url %s",t),t="undefined"!=typeof n?n.protocol+"//"+t:"https://"+t),i("parse %s",t),r=o(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var s=r.host.indexOf(":")!==-1,a=s?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+a+":"+r.port,r.href=r.protocol+"://"+a+(n&&n.port===r.port?"":":"+r.port),r}var o=n(2),i=n(3)("socket.io-client:url");t.exports=r}).call(e,function(){return this}())},function(t,e){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,o=t.indexOf("["),i=t.indexOf("]");o!=-1&&i!=-1&&(t=t.substring(0,o)+t.substring(o,i).replace(/:/g,";")+t.substring(i,t.length));for(var s=n.exec(t||""),a={},c=14;c--;)a[r[c]]=s[c]||"";return o!=-1&&i!=-1&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(t,e,n){(function(r){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(t){var n=this.useColors;if(t[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+e.humanize(this.diff),n){var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(o++,"%c"===t&&(i=o))}),t.splice(i,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(n){}}function c(){var t;try{t=e.storage.debug}catch(n){}return!t&&"undefined"!=typeof r&&"env"in r&&(t=r.env.DEBUG),t}function p(){try{return window.localStorage}catch(t){}}e=t.exports=n(5),e.log=s,e.formatArgs=i,e.save=a,e.load=c,e.useColors=o,e.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:p(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},e.enable(c())}).call(e,n(4))},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(t){if(u===setTimeout)return setTimeout(t,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function i(t){if(h===clearTimeout)return clearTimeout(t);if((h===r||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(t);try{return h(t)}catch(e){try{return h.call(null,t)}catch(e){return h.call(this,t)}}}function s(){y&&l&&(y=!1,l.length?d=l.concat(d):m=-1,d.length&&a())}function a(){if(!y){var t=o(s);y=!0;for(var e=d.length;e;){for(l=d,d=[];++m<e;)l&&l[m].run();m=-1,e=d.length}l=null,y=!1,i(t)}}function c(t,e){this.fun=t,this.array=e}function p(){}var u,h,f=t.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:n}catch(t){u=n}try{h="function"==typeof clearTimeout?clearTimeout:r}catch(t){h=r}}();var l,d=[],y=!1,m=-1;f.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];d.push(new c(t,e)),1!==d.length||y||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=p,f.addListener=p,f.once=p,f.off=p,f.removeListener=p,f.removeAllListeners=p,f.emit=p,f.prependListener=p,f.prependOnceListener=p,f.listeners=function(t){return[]},f.binding=function(t){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(t){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}},function(t,e,n){function r(t){var n,r=0;for(n in t)r=(r<<5)-r+t.charCodeAt(n),r|=0;return e.colors[Math.abs(r)%e.colors.length]}function o(t){function n(){if(n.enabled){var t=n,r=+new Date,o=r-(p||r);t.diff=o,t.prev=p,t.curr=r,p=r;for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];i[0]=e.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");var a=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,function(n,r){if("%%"===n)return n;a++;var o=e.formatters[r];if("function"==typeof o){var s=i[a];n=o.call(t,s),i.splice(a,1),a--}return n}),e.formatArgs.call(t,i);var c=n.log||e.log||console.log.bind(console);c.apply(t,i)}}return n.namespace=t,n.enabled=e.enabled(t),n.useColors=e.useColors(),n.color=r(t),"function"==typeof e.init&&e.init(n),n}function i(t){e.save(t),e.names=[],e.skips=[];for(var n=("string"==typeof t?t:"").split(/[\s,]+/),r=n.length,o=0;o<r;o++)n[o]&&(t=n[o].replace(/\*/g,".*?"),"-"===t[0]?e.skips.push(new RegExp("^"+t.substr(1)+"$")):e.names.push(new RegExp("^"+t+"$")))}function s(){e.enable("")}function a(t){var n,r;for(n=0,r=e.skips.length;n<r;n++)if(e.skips[n].test(t))return!1;for(n=0,r=e.names.length;n<r;n++)if(e.names[n].test(t))return!0;return!1}function c(t){return t instanceof Error?t.stack||t.message:t}e=t.exports=o.debug=o["default"]=o,e.coerce=c,e.disable=s,e.enable=i,e.enabled=a,e.humanize=n(6),e.names=[],e.skips=[],e.formatters={};var p},function(t,e){function n(t){if(t=String(t),!(t.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*u;case"days":case"day":case"d":return n*p;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*a;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function r(t){return t>=p?Math.round(t/p)+"d":t>=c?Math.round(t/c)+"h":t>=a?Math.round(t/a)+"m":t>=s?Math.round(t/s)+"s":t+"ms"}function o(t){return i(t,p,"day")||i(t,c,"hour")||i(t,a,"minute")||i(t,s,"second")||t+" ms"}function i(t,e,n){if(!(t<e))return t<1.5*e?Math.floor(t/e)+" "+n:Math.ceil(t/e)+" "+n+"s"}var s=1e3,a=60*s,c=60*a,p=24*c,u=365.25*p;t.exports=function(t,e){e=e||{};var i=typeof t;if("string"===i&&t.length>0)return n(t);if("number"===i&&isNaN(t)===!1)return e["long"]?o(t):r(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,n){function r(){}function o(t){var n=""+t.type;return e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(n+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(n+=t.nsp+","),null!=t.id&&(n+=t.id),null!=t.data&&(n+=JSON.stringify(t.data)),h("encoded %j as %s",t,n),n}function i(t,e){function n(t){var n=d.deconstructPacket(t),r=o(n.packet),i=n.buffers;i.unshift(r),e(i)}d.removeBlobs(t,n)}function s(){this.reconstructor=null}function a(t){var n=0,r={type:Number(t.charAt(0))};if(null==e.types[r.type])return u();if(e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(o)}if("/"===t.charAt(n+1))for(r.nsp="";++n;){var i=t.charAt(n);if(","===i)break;if(r.nsp+=i,n===t.length)break}else r.nsp="/";var s=t.charAt(n+1);if(""!==s&&Number(s)==s){for(r.id="";++n;){var i=t.charAt(n);if(null==i||Number(i)!=i){--n;break}if(r.id+=t.charAt(n),n===t.length)break}r.id=Number(r.id)}return t.charAt(++n)&&(r=c(r,t.substr(n))),h("decoded %s as %j",t,r),r}function c(t,e){try{t.data=JSON.parse(e)}catch(n){return u()}return t}function p(t){this.reconPack=t,this.buffers=[]}function u(){return{type:e.ERROR,data:"parser error"}}var h=n(3)("socket.io-parser"),f=n(8),l=n(9),d=n(11),y=n(12);e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=s,r.prototype.encode=function(t,n){if(t.type!==e.EVENT&&t.type!==e.ACK||!l(t.data)||(t.type=t.type===e.EVENT?e.BINARY_EVENT:e.BINARY_ACK),h("encoding packet %j",t),e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type)i(t,n);else{var r=o(t);n([r])}},f(s.prototype),s.prototype.add=function(t){var n;if("string"==typeof t)n=a(t),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type?(this.reconstructor=new p(n),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",n)):this.emit("decoded",n);else{if(!y(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,this.emit("decoded",n))}},s.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},p.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=d.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},p.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,n){function r(t){if(t)return o(t)}function o(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r,o=0;o<n.length;o++)if(r=n[o],r===e||r.fn===e){n.splice(o,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n){n=n.slice(0);for(var r=0,o=n.length;r<o;++r)n[r].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,n){(function(e){function r(t){if(!t||"object"!=typeof t)return!1;if(o(t)){for(var n=0,i=t.length;n<i;n++)if(r(t[n]))return!0;return!1}if("function"==typeof e.Buffer&&e.Buffer.isBuffer&&e.Buffer.isBuffer(t)||"function"==typeof e.ArrayBuffer&&t instanceof ArrayBuffer||s&&t instanceof Blob||a&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return r(t.toJSON(),!0);for(var c in t)if(Object.prototype.hasOwnProperty.call(t,c)&&r(t[c]))return!0;return!1}var o=n(10),i=Object.prototype.toString,s="function"==typeof e.Blob||"[object BlobConstructor]"===i.call(e.Blob),a="function"==typeof e.File||"[object FileConstructor]"===i.call(e.File);t.exports=r}).call(e,function(){return this}())},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){(function(t){function r(t,e){if(!t)return t;if(s(t)){var n={_placeholder:!0,num:e.length};return e.push(t),n}if(i(t)){for(var o=new Array(t.length),a=0;a<t.length;a++)o[a]=r(t[a],e);return o}if("object"==typeof t&&!(t instanceof Date)){var o={};for(var c in t)o[c]=r(t[c],e);return o}return t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(i(t))for(var n=0;n<t.length;n++)t[n]=o(t[n],e);else if("object"==typeof t)for(var r in t)t[r]=o(t[r],e);return t}var i=n(10),s=n(12),a=Object.prototype.toString,c="function"==typeof t.Blob||"[object BlobConstructor]"===a.call(t.Blob),p="function"==typeof t.File||"[object FileConstructor]"===a.call(t.File);e.deconstructPacket=function(t){var e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}},e.reconstructPacket=function(t,e){return t.data=o(t.data,e),t.attachments=void 0,t},e.removeBlobs=function(t,e){function n(t,a,u){if(!t)return t;if(c&&t instanceof Blob||p&&t instanceof File){r++;var h=new FileReader;h.onload=function(){u?u[a]=this.result:o=this.result,--r||e(o)},h.readAsArrayBuffer(t)}else if(i(t))for(var f=0;f<t.length;f++)n(t[f],f,t);else if("object"==typeof t&&!s(t))for(var l in t)n(t[l],l,t)}var r=0,o=t;n(o),r||e(o)}}).call(e,function(){return this}())},function(t,e){(function(e){function n(t){return e.Buffer&&e.Buffer.isBuffer(t)||e.ArrayBuffer&&t instanceof ArrayBuffer}t.exports=n}).call(e,function(){return this}())},function(t,e,n){"use strict";function r(t,e){if(!(this instanceof r))return new r(t,e);t&&"object"===("undefined"==typeof t?"undefined":o(t))&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new l({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=e.parser||c;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=e.autoConnect!==!1,this.autoConnect&&this.open()}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=n(14),s=n(37),a=n(8),c=n(7),p=n(39),u=n(40),h=n(3)("socket.io-client:manager"),f=n(36),l=n(41),d=Object.prototype.hasOwnProperty;t.exports=r,r.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var t in this.nsps)d.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},r.prototype.updateSocketIds=function(){for(var t in this.nsps)d.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},r.prototype.generateId=function(t){return("/"===t?"":t+"#")+this.engine.id},a(r.prototype),r.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},r.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},r.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},r.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},r.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},r.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},r.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},r.prototype.open=r.prototype.connect=function(t,e){if(h("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;h("opening %s",this.uri),this.engine=i(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=p(n,"open",function(){r.onopen(),t&&t()}),s=p(n,"error",function(e){if(h("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",e),t){var n=new Error("Connection error");n.data=e,t(n)}else r.maybeReconnectOnOpen()});if(!1!==this._timeout){var a=this._timeout;h("connect attempt will timeout after %d",a);var c=setTimeout(function(){h("connect attempt timed out after %d",a),o.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",a)},a);this.subs.push({destroy:function(){clearTimeout(c)}})}return this.subs.push(o),this.subs.push(s),this},r.prototype.onopen=function(){h("open"),this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(p(t,"data",u(this,"ondata"))),this.subs.push(p(t,"ping",u(this,"onping"))),this.subs.push(p(t,"pong",u(this,"onpong"))),this.subs.push(p(t,"error",u(this,"onerror"))),this.subs.push(p(t,"close",u(this,"onclose"))),this.subs.push(p(this.decoder,"decoded",u(this,"ondecoded")))},r.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},r.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},r.prototype.ondata=function(t){this.decoder.add(t)},r.prototype.ondecoded=function(t){this.emit("packet",t)},r.prototype.onerror=function(t){h("error",t),this.emitAll("error",t)},r.prototype.socket=function(t,e){function n(){~f(o.connecting,r)||o.connecting.push(r)}var r=this.nsps[t];if(!r){r=new s(this,t,e),this.nsps[t]=r;var o=this;r.on("connecting",n),r.on("connect",function(){r.id=o.generateId(t)}),this.autoConnect&&n()}return r},r.prototype.destroy=function(t){var e=f(this.connecting,t);~e&&this.connecting.splice(e,1),this.connecting.length||this.close()},r.prototype.packet=function(t){h("writing packet %j",t);var e=this;t.query&&0===t.type&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,function(n){for(var r=0;r<n.length;r++)e.engine.write(n[r],t.options);e.encoding=!1,e.processPacketQueue()}))},r.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},r.prototype.cleanup=function(){h("cleanup");for(var t=this.subs.length,e=0;e<t;e++){var n=this.subs.shift();n.destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},r.prototype.close=r.prototype.disconnect=function(){h("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},r.prototype.onclose=function(t){h("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},r.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)h("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();h("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var n=setTimeout(function(){t.skipReconnect||(h("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open(function(e){e?(h("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):(h("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(n)}})}},r.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,n){t.exports=n(15),t.exports.parser=n(22)},function(t,e,n){(function(e){function r(t,n){if(!(this instanceof r))return new r(t,n);n=n||{},t&&"object"==typeof t&&(n=t,t=null),t?(t=u(t),n.hostname=t.host,n.secure="https"===t.protocol||"wss"===t.protocol,n.port=t.port,t.query&&(n.query=t.query)):n.host&&(n.hostname=u(n.host).host),this.secure=null!=n.secure?n.secure:e.location&&"https:"===location.protocol,n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.agent=n.agent||!1,this.hostname=n.hostname||(e.location?location.hostname:"localhost"),this.port=n.port||(e.location&&location.port?location.port:this.secure?443:80),this.query=n.query||{},"string"==typeof this.query&&(this.query=h.decode(this.query)),this.upgrade=!1!==n.upgrade,this.path=(n.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!n.forceJSONP,this.jsonp=!1!==n.jsonp,this.forceBase64=!!n.forceBase64,this.enablesXDR=!!n.enablesXDR,this.timestampParam=n.timestampParam||"t",this.timestampRequests=n.timestampRequests,this.transports=n.transports||["polling","websocket"],this.transportOptions=n.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=n.policyPort||843,this.rememberUpgrade=n.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=n.onlyBinaryUpgrades,this.perMessageDeflate=!1!==n.perMessageDeflate&&(n.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=n.pfx||null,this.key=n.key||null,this.passphrase=n.passphrase||null,this.cert=n.cert||null,this.ca=n.ca||null,this.ciphers=n.ciphers||null,this.rejectUnauthorized=void 0===n.rejectUnauthorized||n.rejectUnauthorized,this.forceNode=!!n.forceNode;var o="object"==typeof e&&e;o.global===o&&(n.extraHeaders&&Object.keys(n.extraHeaders).length>0&&(this.extraHeaders=n.extraHeaders),n.localAddress&&(this.localAddress=n.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}function o(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}var i=n(16),s=n(8),a=n(3)("engine.io-client:socket"),c=n(36),p=n(22),u=n(2),h=n(30);t.exports=r,r.priorWebsocketSuccess=!1,s(r.prototype),r.protocol=p.protocol,r.Socket=r,r.Transport=n(21),r.transports=n(16),r.parser=n(22),r.prototype.createTransport=function(t){a('creating transport "%s"',t);var e=o(this.query);e.EIO=p.protocol,e.transport=t;var n=this.transportOptions[t]||{};this.id&&(e.sid=this.id);var r=new i[t]({query:e,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0});return r},r.prototype.open=function(){var t;if(this.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout(function(){e.emit("error","No transports available")},0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(n){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},r.prototype.setTransport=function(t){a("setting transport %s",t.name);var e=this;this.transport&&(a("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},r.prototype.probe=function(t){function e(){if(f.onlyBinaryUpgrades){var e=!this.supportsBinary&&f.transport.supportsBinary;h=h||e}h||(a('probe transport "%s" opened',t),u.send([{type:"ping",data:"probe"}]),u.once("packet",function(e){if(!h)if("pong"===e.type&&"probe"===e.data){if(a('probe transport "%s" pong',t),f.upgrading=!0,f.emit("upgrading",u),!u)return;r.priorWebsocketSuccess="websocket"===u.name,a('pausing current transport "%s"',f.transport.name),f.transport.pause(function(){h||"closed"!==f.readyState&&(a("changing transport and sending upgrade packet"),p(),f.setTransport(u),u.send([{type:"upgrade"}]),f.emit("upgrade",u),u=null,f.upgrading=!1,f.flush())})}else{a('probe transport "%s" failed',t);var n=new Error("probe error");n.transport=u.name,f.emit("upgradeError",n)}}))}function n(){h||(h=!0,p(),u.close(),u=null)}function o(e){var r=new Error("probe error: "+e);r.transport=u.name,n(),a('probe transport "%s" failed because of error: %s',t,e),f.emit("upgradeError",r)}function i(){o("transport closed")}function s(){o("socket closed")}function c(t){u&&t.name!==u.name&&(a('"%s" works - aborting "%s"',t.name,u.name),n())}function p(){u.removeListener("open",e),u.removeListener("error",o),u.removeListener("close",i),f.removeListener("close",s),f.removeListener("upgrading",c)}a('probing transport "%s"',t);var u=this.createTransport(t,{probe:1}),h=!1,f=this;r.priorWebsocketSuccess=!1,u.once("open",e),u.once("error",o),u.once("close",i),this.once("close",s),this.once("upgrading",c),u.open()},r.prototype.onOpen=function(){if(a("socket open"),this.readyState="open",r.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){a("starting upgrade probes");for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},r.prototype.onPacket=function(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(a('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data)}else a('packet received with socket readyState "%s"',this.readyState)},r.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},r.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){"closed"!==e.readyState&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},r.prototype.setPing=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){a("writing ping packet - expecting pong within %sms",t.pingTimeout),t.ping(),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},r.prototype.ping=function(){var t=this;this.sendPacket("ping",function(){t.emit("ping")})},r.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},r.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(a("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},r.prototype.write=r.prototype.send=function(t,e,n){return this.sendPacket("message",t,e,n),this},r.prototype.sendPacket=function(t,e,n,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){n=n||{},n.compress=!1!==n.compress;var o={type:t,data:e,options:n};this.emit("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}},r.prototype.close=function(){function t(){r.onClose("forced close"),a("socket closing - telling transport to close"),r.transport.close()}function e(){r.removeListener("upgrade",e),r.removeListener("upgradeError",e),t()}function n(){r.once("upgrade",e),r.once("upgradeError",e)}if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var r=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?n():t()}):this.upgrading?n():t()}return this},r.prototype.onError=function(t){a("socket error %j",t),r.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)},r.prototype.onClose=function(t,e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){a('socket close with reason: "%s"',t);var n=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",t,e),n.writeBuffer=[],n.prevBufferLen=0}},r.prototype.filterUpgrades=function(t){for(var e=[],n=0,r=t.length;n<r;n++)~c(this.transports,t[n])&&e.push(t[n]);return e}}).call(e,function(){return this}())},function(t,e,n){(function(t){function r(e){var n,r=!1,a=!1,c=!1!==e.jsonp;if(t.location){var p="https:"===location.protocol,u=location.port;u||(u=p?443:80),r=e.hostname!==location.hostname||u!==e.port,a=e.secure!==p}if(e.xdomain=r,e.xscheme=a,n=new o(e),"open"in n&&!e.forceJSONP)return new i(e);if(!c)throw new Error("JSONP disabled");return new s(e)}var o=n(17),i=n(19),s=n(33),a=n(34);e.polling=r,e.websocket=a}).call(e,function(){return this}())},function(t,e,n){(function(e){var r=n(18);t.exports=function(t){var n=t.xdomain,o=t.xscheme,i=t.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!n||r))return new XMLHttpRequest}catch(s){}try{if("undefined"!=typeof XDomainRequest&&!o&&i)return new XDomainRequest}catch(s){}if(!n)try{return new(e[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP");
}catch(s){}}}).call(e,function(){return this}())},function(t,e){try{t.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(n){t.exports=!1}},function(t,e,n){(function(e){function r(){}function o(t){if(c.call(this,t),this.requestTimeout=t.requestTimeout,this.extraHeaders=t.extraHeaders,e.location){var n="https:"===location.protocol,r=location.port;r||(r=n?443:80),this.xd=t.hostname!==e.location.hostname||r!==t.port,this.xs=t.secure!==n}}function i(t){this.method=t.method||"GET",this.uri=t.uri,this.xd=!!t.xd,this.xs=!!t.xs,this.async=!1!==t.async,this.data=void 0!==t.data?t.data:null,this.agent=t.agent,this.isBinary=t.isBinary,this.supportsBinary=t.supportsBinary,this.enablesXDR=t.enablesXDR,this.requestTimeout=t.requestTimeout,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.extraHeaders=t.extraHeaders,this.create()}function s(){for(var t in i.requests)i.requests.hasOwnProperty(t)&&i.requests[t].abort()}var a=n(17),c=n(20),p=n(8),u=n(31),h=n(3)("engine.io-client:polling-xhr");t.exports=o,t.exports.Request=i,u(o,c),o.prototype.supportsBinary=!0,o.prototype.request=function(t){return t=t||{},t.uri=this.uri(),t.xd=this.xd,t.xs=this.xs,t.agent=this.agent||!1,t.supportsBinary=this.supportsBinary,t.enablesXDR=this.enablesXDR,t.pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized,t.requestTimeout=this.requestTimeout,t.extraHeaders=this.extraHeaders,new i(t)},o.prototype.doWrite=function(t,e){var n="string"!=typeof t&&void 0!==t,r=this.request({method:"POST",data:t,isBinary:n}),o=this;r.on("success",e),r.on("error",function(t){o.onError("xhr post error",t)}),this.sendXhr=r},o.prototype.doPoll=function(){h("xhr poll");var t=this.request(),e=this;t.on("data",function(t){e.onData(t)}),t.on("error",function(t){e.onError("xhr poll error",t)}),this.pollXhr=t},p(i.prototype),i.prototype.create=function(){var t={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};t.pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized;var n=this.xhr=new a(t),r=this;try{h("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,this.async);try{if(this.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(var o in this.extraHeaders)this.extraHeaders.hasOwnProperty(o)&&n.setRequestHeader(o,this.extraHeaders[o])}}catch(s){}if("POST"===this.method)try{this.isBinary?n.setRequestHeader("Content-type","application/octet-stream"):n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(s){}try{n.setRequestHeader("Accept","*/*")}catch(s){}"withCredentials"in n&&(n.withCredentials=!0),this.requestTimeout&&(n.timeout=this.requestTimeout),this.hasXDR()?(n.onload=function(){r.onLoad()},n.onerror=function(){r.onError(n.responseText)}):n.onreadystatechange=function(){if(2===n.readyState){var t;try{t=n.getResponseHeader("Content-Type")}catch(e){}"application/octet-stream"===t&&(n.responseType="arraybuffer")}4===n.readyState&&(200===n.status||1223===n.status?r.onLoad():setTimeout(function(){r.onError(n.status)},0))},h("xhr data %s",this.data),n.send(this.data)}catch(s){return void setTimeout(function(){r.onError(s)},0)}e.document&&(this.index=i.requestsCount++,i.requests[this.index]=this)},i.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},i.prototype.onData=function(t){this.emit("data",t),this.onSuccess()},i.prototype.onError=function(t){this.emit("error",t),this.cleanup(!0)},i.prototype.cleanup=function(t){if("undefined"!=typeof this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=r:this.xhr.onreadystatechange=r,t)try{this.xhr.abort()}catch(n){}e.document&&delete i.requests[this.index],this.xhr=null}},i.prototype.onLoad=function(){var t;try{var e;try{e=this.xhr.getResponseHeader("Content-Type")}catch(n){}t="application/octet-stream"===e?this.xhr.response||this.xhr.responseText:this.xhr.responseText}catch(n){this.onError(n)}null!=t&&this.onData(t)},i.prototype.hasXDR=function(){return"undefined"!=typeof e.XDomainRequest&&!this.xs&&this.enablesXDR},i.prototype.abort=function(){this.cleanup()},i.requestsCount=0,i.requests={},e.document&&(e.attachEvent?e.attachEvent("onunload",s):e.addEventListener&&e.addEventListener("beforeunload",s,!1))}).call(e,function(){return this}())},function(t,e,n){function r(t){var e=t&&t.forceBase64;u&&!e||(this.supportsBinary=!1),o.call(this,t)}var o=n(21),i=n(30),s=n(22),a=n(31),c=n(32),p=n(3)("engine.io-client:polling");t.exports=r;var u=function(){var t=n(17),e=new t({xdomain:!1});return null!=e.responseType}();a(r,o),r.prototype.name="polling",r.prototype.doOpen=function(){this.poll()},r.prototype.pause=function(t){function e(){p("paused"),n.readyState="paused",t()}var n=this;if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(p("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){p("pre-pause polling complete"),--r||e()})),this.writable||(p("we are currently writing - waiting to pause"),r++,this.once("drain",function(){p("pre-pause writing complete"),--r||e()}))}else e()},r.prototype.poll=function(){p("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},r.prototype.onData=function(t){var e=this;p("polling got data %s",t);var n=function(t,n,r){return"opening"===e.readyState&&e.onOpen(),"close"===t.type?(e.onClose(),!1):void e.onPacket(t)};s.decodePayload(t,this.socket.binaryType,n),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():p('ignoring poll - transport state "%s"',this.readyState))},r.prototype.doClose=function(){function t(){p("writing close packet"),e.write([{type:"close"}])}var e=this;"open"===this.readyState?(p("transport open - closing"),t()):(p("transport not open - deferring close"),this.once("open",t))},r.prototype.write=function(t){var e=this;this.writable=!1;var n=function(){e.writable=!0,e.emit("drain")};s.encodePayload(t,this.supportsBinary,function(t){e.doWrite(t,n)})},r.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",n="";!1!==this.timestampRequests&&(t[this.timestampParam]=c()),this.supportsBinary||t.sid||(t.b64=1),t=i.encode(t),this.port&&("https"===e&&443!==Number(this.port)||"http"===e&&80!==Number(this.port))&&(n=":"+this.port),t.length&&(t="?"+t);var r=this.hostname.indexOf(":")!==-1;return e+"://"+(r?"["+this.hostname+"]":this.hostname)+n+this.path+t}},function(t,e,n){function r(t){this.path=t.path,this.hostname=t.hostname,this.port=t.port,this.secure=t.secure,this.query=t.query,this.timestampParam=t.timestampParam,this.timestampRequests=t.timestampRequests,this.readyState="",this.agent=t.agent||!1,this.socket=t.socket,this.enablesXDR=t.enablesXDR,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.forceNode=t.forceNode,this.extraHeaders=t.extraHeaders,this.localAddress=t.localAddress}var o=n(22),i=n(8);t.exports=r,i(r.prototype),r.prototype.onError=function(t,e){var n=new Error(t);return n.type="TransportError",n.description=e,this.emit("error",n),this},r.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},r.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},r.prototype.send=function(t){if("open"!==this.readyState)throw new Error("Transport not open");this.write(t)},r.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},r.prototype.onData=function(t){var e=o.decodePacket(t,this.socket.binaryType);this.onPacket(e)},r.prototype.onPacket=function(t){this.emit("packet",t)},r.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(t,e,n){(function(t){function r(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}function o(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=v[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}function i(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){t.data=o.result,e.encodePacket(t,n,!0,r)},o.readAsArrayBuffer(t.data)}function s(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(g)return i(t,n,r);var o=new Uint8Array(1);o[0]=v[t.type];var s=new k([o.buffer,t.data]);return r(s)}function a(t){try{t=d.decode(t,{strict:!1})}catch(e){return!1}return t}function c(t,e,n){for(var r=new Array(t.length),o=l(t.length,n),i=function(t,n,o){e(n,function(e,n){r[t]=n,o(e,r)})},s=0;s<t.length;s++)i(s,t[s],o)}var p,u=n(23),h=n(9),f=n(24),l=n(25),d=n(26);t&&t.ArrayBuffer&&(p=n(28));var y="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),m="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),g=y||m;e.protocol=3;var v=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},b=u(v),w={type:"error",data:"parser error"},k=n(29);e.encodePacket=function(e,n,i,a){"function"==typeof n&&(a=n,n=!1),"function"==typeof i&&(a=i,i=null);var c=void 0===e.data?void 0:e.data.buffer||e.data;if(t.ArrayBuffer&&c instanceof ArrayBuffer)return o(e,n,a);if(k&&c instanceof t.Blob)return s(e,n,a);if(c&&c.base64)return r(e,a);var p=v[e.type];return void 0!==e.data&&(p+=i?d.encode(String(e.data),{strict:!1}):String(e.data)),a(""+p)},e.encodeBase64Packet=function(n,r){var o="b"+e.packets[n.type];if(k&&n.data instanceof t.Blob){var i=new FileReader;return i.onload=function(){var t=i.result.split(",")[1];r(o+t)},i.readAsDataURL(n.data)}var s;try{s=String.fromCharCode.apply(null,new Uint8Array(n.data))}catch(a){for(var c=new Uint8Array(n.data),p=new Array(c.length),u=0;u<c.length;u++)p[u]=c[u];s=String.fromCharCode.apply(null,p)}return o+=t.btoa(s),r(o)},e.decodePacket=function(t,n,r){if(void 0===t)return w;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&(t=a(t),t===!1))return w;var o=t.charAt(0);return Number(o)==o&&b[o]?t.length>1?{type:b[o],data:t.substring(1)}:{type:b[o]}:w}var i=new Uint8Array(t),o=i[0],s=f(t,1);return k&&"blob"===n&&(s=new k([s])),{type:b[o],data:s}},e.decodeBase64Packet=function(t,e){var n=b[t.charAt(0)];if(!p)return{type:n,data:{base64:!0,data:t.substr(1)}};var r=p.decode(t.substr(1));return"blob"===e&&k&&(r=new k([r])),{type:n,data:r}},e.encodePayload=function(t,n,r){function o(t){return t.length+":"+t}function i(t,r){e.encodePacket(t,!!s&&n,!1,function(t){r(null,o(t))})}"function"==typeof n&&(r=n,n=null);var s=h(t);return n&&s?k&&!g?e.encodePayloadAsBlob(t,r):e.encodePayloadAsArrayBuffer(t,r):t.length?void c(t,i,function(t,e){return r(e.join(""))}):r("0:")},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);"function"==typeof n&&(r=n,n=null);var o;if(""===t)return r(w,0,1);for(var i,s,a="",c=0,p=t.length;c<p;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return r(w,0,1);if(s=t.substr(c+1,i),a!=s.length)return r(w,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),w.type===o.type&&w.data===o.data)return r(w,0,1);var h=r(o,c+i,p);if(!1===h)return}c+=i,a=""}else a+=u}return""!==a?r(w,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){function r(t,n){e.encodePacket(t,!0,!0,function(t){return n(null,t)})}return t.length?void c(t,r,function(t,e){var r=e.reduce(function(t,e){var n;return n="string"==typeof e?e.length:e.byteLength,t+n.toString().length+n+2},0),o=new Uint8Array(r),i=0;return e.forEach(function(t){var e="string"==typeof t,n=t;if(e){for(var r=new Uint8Array(t.length),s=0;s<t.length;s++)r[s]=t.charCodeAt(s);n=r.buffer}e?o[i++]=0:o[i++]=1;for(var a=n.byteLength.toString(),s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(var r=new Uint8Array(n),s=0;s<r.length;s++)o[i++]=r[s]}),n(o.buffer)}):n(new ArrayBuffer(0))},e.encodePayloadAsBlob=function(t,n){function r(t,n){e.encodePacket(t,!0,!0,function(t){var e=new Uint8Array(1);if(e[0]=1,"string"==typeof t){for(var r=new Uint8Array(t.length),o=0;o<t.length;o++)r[o]=t.charCodeAt(o);t=r.buffer,e[0]=0}for(var i=t instanceof ArrayBuffer?t.byteLength:t.size,s=i.toString(),a=new Uint8Array(s.length+1),o=0;o<s.length;o++)a[o]=parseInt(s[o]);if(a[s.length]=255,k){var c=new k([e.buffer,a.buffer,t]);n(null,c)}})}c(t,r,function(t,e){return n(new k(e))})},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var o=t,i=[];o.byteLength>0;){for(var s=new Uint8Array(o),a=0===s[0],c="",p=1;255!==s[p];p++){if(c.length>310)return r(w,0,1);c+=s[p]}o=f(o,2+c.length),c=parseInt(c);var u=f(o,0,c);if(a)try{u=String.fromCharCode.apply(null,new Uint8Array(u))}catch(h){var l=new Uint8Array(u);u="";for(var p=0;p<l.length;p++)u+=String.fromCharCode(l[p])}i.push(u),o=f(o,c)}var d=i.length;i.forEach(function(t,o){r(e.decodePacket(t,n,!0),o,d)})}}).call(e,function(){return this}())},function(t,e){t.exports=Object.keys||function(t){var e=[],n=Object.prototype.hasOwnProperty;for(var r in t)n.call(t,r)&&e.push(r);return e}},function(t,e){t.exports=function(t,e,n){var r=t.byteLength;if(e=e||0,n=n||r,t.slice)return t.slice(e,n);if(e<0&&(e+=r),n<0&&(n+=r),n>r&&(n=r),e>=r||e>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(t),i=new Uint8Array(n-e),s=e,a=0;s<n;s++,a++)i[a]=o[s];return i.buffer}},function(t,e){function n(t,e,n){function o(t,r){if(o.count<=0)throw new Error("after called too many times");--o.count,t?(i=!0,e(t),e=n):0!==o.count||i||e(null,r)}var i=!1;return n=n||r,o.count=t,0===t?e():o}function r(){}t.exports=n},function(t,e,n){var r;(function(t,o){!function(i){function s(t){for(var e,n,r=[],o=0,i=t.length;o<i;)e=t.charCodeAt(o++),e>=55296&&e<=56319&&o<i?(n=t.charCodeAt(o++),56320==(64512&n)?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),o--)):r.push(e);return r}function a(t){for(var e,n=t.length,r=-1,o="";++r<n;)e=t[r],e>65535&&(e-=65536,o+=w(e>>>10&1023|55296),e=56320|1023&e),o+=w(e);return o}function c(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function p(t,e){return w(t>>e&63|128)}function u(t,e){if(0==(4294967168&t))return w(t);var n="";return 0==(4294965248&t)?n=w(t>>6&31|192):0==(4294901760&t)?(c(t,e)||(t=65533),n=w(t>>12&15|224),n+=p(t,6)):0==(4292870144&t)&&(n=w(t>>18&7|240),n+=p(t,12),n+=p(t,6)),n+=w(63&t|128)}function h(t,e){e=e||{};for(var n,r=!1!==e.strict,o=s(t),i=o.length,a=-1,c="";++a<i;)n=o[a],c+=u(n,r);return c}function f(){if(b>=v)throw Error("Invalid byte index");var t=255&g[b];if(b++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function l(t){var e,n,r,o,i;if(b>v)throw Error("Invalid byte index");if(b==v)return!1;if(e=255&g[b],b++,0==(128&e))return e;if(192==(224&e)){if(n=f(),i=(31&e)<<6|n,i>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&e)){if(n=f(),r=f(),i=(15&e)<<12|n<<6|r,i>=2048)return c(i,t)?i:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(n=f(),r=f(),o=f(),i=(7&e)<<18|n<<12|r<<6|o,i>=65536&&i<=1114111))return i;throw Error("Invalid UTF-8 detected")}function d(t,e){e=e||{};var n=!1!==e.strict;g=s(t),v=g.length,b=0;for(var r,o=[];(r=l(n))!==!1;)o.push(r);return a(o)}var y="object"==typeof e&&e,m=("object"==typeof t&&t&&t.exports==y&&t,"object"==typeof o&&o);m.global!==m&&m.window!==m||(i=m);var g,v,b,w=String.fromCharCode,k={version:"2.1.2",encode:h,decode:d};r=function(){return k}.call(e,n,e,t),!(void 0!==r&&(t.exports=r))}(this)}).call(e,n(27)(t),function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){!function(){"use strict";for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(256),r=0;r<t.length;r++)n[t.charCodeAt(r)]=r;e.encode=function(e){var n,r=new Uint8Array(e),o=r.length,i="";for(n=0;n<o;n+=3)i+=t[r[n]>>2],i+=t[(3&r[n])<<4|r[n+1]>>4],i+=t[(15&r[n+1])<<2|r[n+2]>>6],i+=t[63&r[n+2]];return o%3===2?i=i.substring(0,i.length-1)+"=":o%3===1&&(i=i.substring(0,i.length-2)+"=="),i},e.decode=function(t){var e,r,o,i,s,a=.75*t.length,c=t.length,p=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(e=0;e<c;e+=4)r=n[t.charCodeAt(e)],o=n[t.charCodeAt(e+1)],i=n[t.charCodeAt(e+2)],s=n[t.charCodeAt(e+3)],h[p++]=r<<2|o>>4,h[p++]=(15&o)<<4|i>>2,h[p++]=(3&i)<<6|63&s;return u}}()},function(t,e){(function(e){function n(t){for(var e=0;e<t.length;e++){var n=t[e];if(n.buffer instanceof ArrayBuffer){var r=n.buffer;if(n.byteLength!==r.byteLength){var o=new Uint8Array(n.byteLength);o.set(new Uint8Array(r,n.byteOffset,n.byteLength)),r=o.buffer}t[e]=r}}}function r(t,e){e=e||{};var r=new i;n(t);for(var o=0;o<t.length;o++)r.append(t[o]);return e.type?r.getBlob(e.type):r.getBlob()}function o(t,e){return n(t),new Blob(t,e||{})}var i=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,s=function(){try{var t=new Blob(["hi"]);return 2===t.size}catch(e){return!1}}(),a=s&&function(){try{var t=new Blob([new Uint8Array([1,2])]);return 2===t.size}catch(e){return!1}}(),c=i&&i.prototype.append&&i.prototype.getBlob;t.exports=function(){return s?a?e.Blob:o:c?r:void 0}()}).call(e,function(){return this}())},function(t,e){e.encode=function(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e},e.decode=function(t){for(var e={},n=t.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}},function(t,e){t.exports=function(t,e){var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},function(t,e){"use strict";function n(t){var e="";do e=s[t%a]+e,t=Math.floor(t/a);while(t>0);return e}function r(t){var e=0;for(u=0;u<t.length;u++)e=e*a+c[t.charAt(u)];return e}function o(){var t=n(+new Date);return t!==i?(p=0,i=t):t+"."+n(p++)}for(var i,s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),a=64,c={},p=0,u=0;u<a;u++)c[s[u]]=u;o.encode=n,o.decode=r,t.exports=o},function(t,e,n){(function(e){function r(){}function o(t){i.call(this,t),this.query=this.query||{},a||(e.___eio||(e.___eio=[]),a=e.___eio),this.index=a.length;var n=this;a.push(function(t){n.onData(t)}),this.query.j=this.index,e.document&&e.addEventListener&&e.addEventListener("beforeunload",function(){n.script&&(n.script.onerror=r)},!1)}var i=n(20),s=n(31);t.exports=o;var a,c=/\n/g,p=/\\n/g;s(o,i),o.prototype.supportsBinary=!1,o.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),i.prototype.doClose.call(this)},o.prototype.doPoll=function(){var t=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(e){t.onError("jsonp poll error",e)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(e,n):(document.head||document.body).appendChild(e),this.script=e;var r="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent);r&&setTimeout(function(){var t=document.createElement("iframe");document.body.appendChild(t),document.body.removeChild(t)},100)},o.prototype.doWrite=function(t,e){function n(){r(),e()}function r(){if(o.iframe)try{o.form.removeChild(o.iframe)}catch(t){o.onError("jsonp polling iframe removal error",t)}try{var e='<iframe src="javascript:0" name="'+o.iframeId+'">';i=document.createElement(e)}catch(t){i=document.createElement("iframe"),i.name=o.iframeId,i.src="javascript:0"}i.id=o.iframeId,o.form.appendChild(i),o.iframe=i}var o=this;if(!this.form){var i,s=document.createElement("form"),a=document.createElement("textarea"),u=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=u,s.method="POST",s.setAttribute("accept-charset","utf-8"),a.name="d",s.appendChild(a),document.body.appendChild(s),this.form=s,this.area=a}this.form.action=this.uri(),r(),t=t.replace(p,"\\\n"),this.area.value=t.replace(c,"\\n");try{this.form.submit()}catch(h){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===o.iframe.readyState&&n()}:this.iframe.onload=n}}).call(e,function(){return this}())},function(t,e,n){(function(e){function r(t){var e=t&&t.forceBase64;e&&(this.supportsBinary=!1),this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=h&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(l=o),i.call(this,t)}var o,i=n(21),s=n(22),a=n(30),c=n(31),p=n(32),u=n(3)("engine.io-client:websocket"),h=e.WebSocket||e.MozWebSocket;if("undefined"==typeof window)try{o=n(35)}catch(f){}var l=h;l||"undefined"!=typeof window||(l=o),t.exports=r,c(r,i),r.prototype.name="websocket",r.prototype.supportsBinary=!0,r.prototype.doOpen=function(){if(this.check()){var t=this.uri(),e=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket?e?new l(t,e):new l(t):new l(t,e,n)}catch(r){return this.emit("error",r)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},r.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},r.prototype.write=function(t){function n(){r.emit("flush"),setTimeout(function(){r.writable=!0,r.emit("drain")},0)}var r=this;this.writable=!1;for(var o=t.length,i=0,a=o;i<a;i++)!function(t){s.encodePacket(t,r.supportsBinary,function(i){if(!r.usingBrowserWebSocket){var s={};if(t.options&&(s.compress=t.options.compress),r.perMessageDeflate){var a="string"==typeof i?e.Buffer.byteLength(i):i.length;a<r.perMessageDeflate.threshold&&(s.compress=!1)}}try{r.usingBrowserWebSocket?r.ws.send(i):r.ws.send(i,s)}catch(c){u("websocket closed before onclose event")}--o||n()})}(t[i])},r.prototype.onClose=function(){i.prototype.onClose.call(this)},r.prototype.doClose=function(){"undefined"!=typeof this.ws&&this.ws.close()},r.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",n="";this.port&&("wss"===e&&443!==Number(this.port)||"ws"===e&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=p()),this.supportsBinary||(t.b64=1),t=a.encode(t),t.length&&(t="?"+t);var r=this.hostname.indexOf(":")!==-1;return e+"://"+(r?"["+this.hostname+"]":this.hostname)+n+this.path+t},r.prototype.check=function(){return!(!l||"__initialize"in l&&this.name===r.prototype.name)}}).call(e,function(){return this}())},function(t,e){},function(t,e){var n=[].indexOf;t.exports=function(t,e){if(n)return t.indexOf(e);for(var r=0;r<t.length;++r)if(t[r]===e)return r;return-1}},function(t,e,n){"use strict";function r(t,e,n){this.io=t,this.nsp=e,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=n(7),s=n(8),a=n(38),c=n(39),p=n(40),u=n(3)("socket.io-client:socket"),h=n(30);t.exports=e=r;var f={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},l=s.prototype.emit;s(r.prototype),r.prototype.subEvents=function(){if(!this.subs){var t=this.io;this.subs=[c(t,"open",p(this,"onopen")),c(t,"packet",p(this,"onpacket")),c(t,"close",p(this,"onclose"))]}},r.prototype.open=r.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting"),this)},r.prototype.send=function(){var t=a(arguments);return t.unshift("message"),this.emit.apply(this,t),this},r.prototype.emit=function(t){if(f.hasOwnProperty(t))return l.apply(this,arguments),this;var e=a(arguments),n={type:i.EVENT,data:e};return n.options={},n.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(u("emitting packet with ack id %d",this.ids),this.acks[this.ids]=e.pop(),n.id=this.ids++),this.connected?this.packet(n):this.sendBuffer.push(n),delete this.flags,this},r.prototype.packet=function(t){t.nsp=this.nsp,this.io.packet(t)},r.prototype.onopen=function(){if(u("transport is open - connecting"),"/"!==this.nsp)if(this.query){var t="object"===o(this.query)?h.encode(this.query):this.query;u("sending connect packet with query %s",t),this.packet({type:i.CONNECT,query:t})}else this.packet({type:i.CONNECT})},r.prototype.onclose=function(t){u("close (%s)",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",t)},r.prototype.onpacket=function(t){if(t.nsp===this.nsp)switch(t.type){case i.CONNECT:this.onconnect();break;case i.EVENT:this.onevent(t);break;case i.BINARY_EVENT:this.onevent(t);break;case i.ACK:this.onack(t);break;case i.BINARY_ACK:this.onack(t);break;case i.DISCONNECT:this.ondisconnect();break;case i.ERROR:this.emit("error",t.data)}},r.prototype.onevent=function(t){var e=t.data||[];u("emitting event %j",e),null!=t.id&&(u("attaching ack callback to event"),e.push(this.ack(t.id))),this.connected?l.apply(this,e):this.receiveBuffer.push(e)},r.prototype.ack=function(t){var e=this,n=!1;return function(){if(!n){n=!0;var r=a(arguments);u("sending ack %j",r),e.packet({type:i.ACK,id:t,data:r})}}},r.prototype.onack=function(t){var e=this.acks[t.id];"function"==typeof e?(u("calling ack %s with %j",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):u("bad ack %s",t.id)},r.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},r.prototype.emitBuffered=function(){var t;for(t=0;t<this.receiveBuffer.length;t++)l.apply(this,this.receiveBuffer[t]);for(this.receiveBuffer=[],t=0;t<this.sendBuffer.length;t++)this.packet(this.sendBuffer[t]);this.sendBuffer=[]},r.prototype.ondisconnect=function(){u("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},r.prototype.destroy=function(){if(this.subs){for(var t=0;t<this.subs.length;t++)this.subs[t].destroy();this.subs=null}this.io.destroy(this)},r.prototype.close=r.prototype.disconnect=function(){return this.connected&&(u("performing disconnect (%s)",this.nsp),this.packet({type:i.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},r.prototype.compress=function(t){return this.flags=this.flags||{},this.flags.compress=t,this}},function(t,e){function n(t,e){var n=[];e=e||0;for(var r=e||0;r<t.length;r++)n[r-e]=t[r];return n}t.exports=n},function(t,e){"use strict";function n(t,e,n){return t.on(e,n),{destroy:function(){t.removeListener(e,n)}}}t.exports=n},function(t,e){var n=[].slice;t.exports=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var r=n.call(arguments,2);return function(){return e.apply(t,r.concat(n.call(arguments)))}}},function(t,e){function n(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=n,n.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(t){this.ms=t},n.prototype.setMax=function(t){this.max=t},n.prototype.setJitter=function(t){this.jitter=t}}])});
//# sourceMappingURL=socket.io.js.map
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
var require;var require;(function(f){if(true){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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return require(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CircularList_1 = require("./utils/CircularList");
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;
var Buffer = (function () {
function Buffer(_terminal, _hasScrollback) {
this._terminal = _terminal;
this._hasScrollback = _hasScrollback;
this.clear();
}
Object.defineProperty(Buffer.prototype, "lines", {
get: function () {
return this._lines;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Buffer.prototype, "hasScrollback", {
get: function () {
return this._hasScrollback && this.lines.maxLength > this._terminal.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._terminal.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 () {
if (this._lines.length === 0) {
var i = this._terminal.rows;
while (i--) {
this.lines.push(this._terminal.blankLine());
}
}
};
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._terminal.rows));
this.scrollTop = 0;
this.scrollBottom = this._terminal.rows - 1;
this.setupTabStops();
};
Buffer.prototype.resize = function (newCols, newRows) {
var newMaxLength = this._getCorrectBufferLength(newRows);
if (newMaxLength > this._lines.maxLength) {
this._lines.maxLength = newMaxLength;
}
if (this._lines.length > 0) {
if (this._terminal.cols < newCols) {
var ch = [this._terminal.defAttr, ' ', 1, 32];
for (var i = 0; i < this._lines.length; i++) {
if (this._lines.get(i) === undefined) {
this._lines.set(i, this._terminal.blankLine(undefined, undefined, newCols));
}
while (this._lines.get(i).length < newCols) {
this._lines.get(i).push(ch);
}
}
}
var addToY = 0;
if (this._terminal.rows < newRows) {
for (var y = this._terminal.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(this._terminal.blankLine(undefined, undefined, newCols));
}
}
}
}
else {
for (var y = this._terminal.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;
}
if (this.y >= newRows) {
this.y = newRows - 1;
}
if (addToY) {
this.y += addToY;
}
if (this.x >= newCols) {
this.x = newCols - 1;
}
this.scrollTop = 0;
}
this.scrollBottom = newRows - 1;
};
Buffer.prototype.translateBufferLineToString = function (lineIndex, trimRight, startCol, endCol) {
if (startCol === void 0) { startCol = 0; }
if (endCol === void 0) { endCol = null; }
var lineString = '';
var line = this.lines.get(lineIndex);
if (!line) {
return '';
}
var startIndex = startCol;
endCol = endCol || line.length;
var endIndex = endCol;
for (var i = 0; i < line.length; i++) {
var char = line[i];
lineString += char[exports.CHAR_DATA_CHAR_INDEX];
if (char[exports.CHAR_DATA_WIDTH_INDEX] === 0) {
if (startCol >= i) {
startIndex--;
}
if (endCol >= i) {
endIndex--;
}
}
else {
if (char[exports.CHAR_DATA_CHAR_INDEX].length > 1) {
if (startCol > i) {
startIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1;
}
if (endCol > i) {
endIndex += char[exports.CHAR_DATA_CHAR_INDEX].length - 1;
}
}
}
}
if (trimRight) {
var rightWhitespaceIndex = lineString.search(/\s+$/);
if (rightWhitespaceIndex !== -1) {
endIndex = Math.min(endIndex, rightWhitespaceIndex);
}
if (endIndex <= startIndex) {
return '';
}
}
return lineString.substring(startIndex, endIndex);
};
Buffer.prototype.setupTabStops = function (i) {
if (i != null) {
if (!this.tabs[i]) {
i = this.prevStop(i);
}
}
else {
this.tabs = {};
i = 0;
}
for (; i < this._terminal.cols; i += this._terminal.options.tabStopWidth) {
this.tabs[i] = true;
}
};
Buffer.prototype.prevStop = function (x) {
if (x == null) {
x = this.x;
}
while (!this.tabs[--x] && x > 0)
;
return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;
};
Buffer.prototype.nextStop = function (x) {
if (x == null) {
x = this.x;
}
while (!this.tabs[++x] && x < this._terminal.cols)
;
return x >= this._terminal.cols ? this._terminal.cols - 1 : x < 0 ? 0 : x;
};
return Buffer;
}());
exports.Buffer = Buffer;
},{"./utils/CircularList":30}],2:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 EventEmitter_1 = require("./EventEmitter");
var BufferSet = (function (_super) {
__extends(BufferSet, _super);
function BufferSet(_terminal) {
var _this = _super.call(this) || this;
_this._terminal = _terminal;
_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();
return _this;
}
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 () {
this._alt.clear();
this._activeBuffer = this._normal;
this.emit('activate', this._normal);
};
BufferSet.prototype.activateAltBuffer = function () {
this._alt.fillViewportRows();
this._activeBuffer = this._alt;
this.emit('activate', this._alt);
};
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;
}(EventEmitter_1.EventEmitter));
exports.BufferSet = BufferSet;
},{"./Buffer":1,"./EventEmitter":7}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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 wcwidthBMP(ucs) {
if (ucs === 0)
return opts.nul;
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
return opts.control;
if (bisearch(ucs, COMBINING_BMP))
return 0;
if (isWideBMP(ucs)) {
return 2;
}
return 1;
}
function isWideBMP(ucs) {
return (ucs >= 0x1100 && (ucs <= 0x115f ||
ucs === 0x2329 ||
ucs === 0x232a ||
(ucs >= 0x2e80 && ucs <= 0xa4cf && ucs !== 0x303f) ||
(ucs >= 0xac00 && ucs <= 0xd7a3) ||
(ucs >= 0xf900 && ucs <= 0xfaff) ||
(ucs >= 0xfe10 && ucs <= 0xfe19) ||
(ucs >= 0xfe30 && ucs <= 0xfe6f) ||
(ucs >= 0xff00 && ucs <= 0xff60) ||
(ucs >= 0xffe0 && ucs <= 0xffe6)));
}
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 = null;
function init_table() {
var CODEPOINTS = 65536;
var BITWIDTH = 2;
var ITEMSIZE = 32;
var CONTAINERSIZE = CODEPOINTS * BITWIDTH / ITEMSIZE;
var CODEPOINTS_PER_ITEM = ITEMSIZE / BITWIDTH;
table = (typeof Uint32Array === 'undefined')
? new Array(CONTAINERSIZE)
: new Uint32Array(CONTAINERSIZE);
for (var i = 0; i < CONTAINERSIZE; ++i) {
var num = 0;
var pos = CODEPOINTS_PER_ITEM;
while (pos--)
num = (num << 2) | wcwidthBMP(CODEPOINTS_PER_ITEM * i + pos);
table[i] = num;
}
return table;
}
return function (num) {
num = num | 0;
if (num < 32)
return control | 0;
if (num < 127)
return 1;
var t = table || init_table();
if (num < 65536)
return t[num >> 4] >> ((num & 15) << 1) & 3;
return wcwidthHigh(num);
};
})({ nul: 0, control: 0 });
},{}],4:[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['='] = {
'#': 'ù',
'@': 'à',
'[': 'é',
'\\': 'ç',
']': 'ê',
'^': 'î',
'_': 'è',
'`': 'ô',
'{': 'ä',
'|': 'ö',
'}': 'ü',
'~': 'û'
};
},{}],5:[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;
}
else {
this.finalizeComposition(false);
}
}
if (ev.keyCode === 229) {
this.handleAnyTextareaChanges();
return false;
}
return true;
};
CompositionHelper.prototype.finalizeComposition = function (waitForPropogation) {
var _this = this;
this.compositionView.classList.remove('active');
this.isComposing = false;
this.clearTextareaPosition();
if (!waitForPropogation) {
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';
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;
},{}],6:[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 = {}));
;
},{}],7:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var EventEmitter = (function () {
function EventEmitter() {
this._events = this._events || {};
}
EventEmitter.prototype.on = function (type, listener) {
this._events[type] = this._events[type] || [];
this._events[type].push(listener);
};
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[i].listener === listener) {
obj.splice(i, 1);
return;
}
}
};
EventEmitter.prototype.removeAllListeners = function (type) {
if (this._events[type]) {
delete this._events[type];
}
};
EventEmitter.prototype.once = function (type, listener) {
function on() {
var args = Array.prototype.slice.call(arguments);
this.off(type, on);
listener.apply(this, args);
}
on.listener = listener;
this.on(type, on);
};
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.listeners = function (type) {
return this._events[type] || [];
};
EventEmitter.prototype.destroy = function () {
this._events = {};
};
return EventEmitter;
}());
exports.EventEmitter = EventEmitter;
},{}],8:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var EscapeSequences_1 = require("./EscapeSequences");
var Charsets_1 = require("./Charsets");
var Buffer_1 = require("./Buffer");
var Types_1 = require("./renderer/Types");
var CharWidth_1 = require("./CharWidth");
var InputHandler = (function () {
function InputHandler(_terminal) {
this._terminal = _terminal;
}
InputHandler.prototype.addChar = function (char, code) {
if (char >= ' ') {
var ch_width = CharWidth_1.wcwidth(code);
if (this._terminal.charset && this._terminal.charset[char]) {
char = this._terminal.charset[char];
}
var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
if (!ch_width && this._terminal.buffer.x) {
if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1]) {
if (!this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][Buffer_1.CHAR_DATA_WIDTH_INDEX]) {
if (this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2]) {
this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][Buffer_1.CHAR_DATA_CHAR_INDEX] += char;
this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 2][3] = char.charCodeAt(0);
}
}
else {
this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][Buffer_1.CHAR_DATA_CHAR_INDEX] += char;
this._terminal.buffer.lines.get(row)[this._terminal.buffer.x - 1][3] = char.charCodeAt(0);
}
this._terminal.updateRange(this._terminal.buffer.y);
}
return;
}
if (this._terminal.buffer.x + ch_width - 1 >= this._terminal.cols) {
if (this._terminal.wraparoundMode) {
this._terminal.buffer.x = 0;
this._terminal.buffer.y++;
if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {
this._terminal.buffer.y--;
this._terminal.scroll(true);
}
else {
this._terminal.buffer.lines.get(this._terminal.buffer.y).isWrapped = true;
}
}
else {
if (ch_width === 2)
return;
}
}
row = this._terminal.buffer.y + this._terminal.buffer.ybase;
if (this._terminal.insertMode) {
for (var moves = 0; moves < ch_width; ++moves) {
var removed = this._terminal.buffer.lines.get(this._terminal.buffer.y + this._terminal.buffer.ybase).pop();
if (removed[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0
&& this._terminal.buffer.lines.get(row)[this._terminal.cols - 2]
&& this._terminal.buffer.lines.get(row)[this._terminal.cols - 2][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
this._terminal.buffer.lines.get(row)[this._terminal.cols - 2] = [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)];
}
this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 0, [this._terminal.curAttr, ' ', 1, ' '.charCodeAt(0)]);
}
}
this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, char, ch_width, char.charCodeAt(0)];
this._terminal.buffer.x++;
this._terminal.updateRange(this._terminal.buffer.y);
if (ch_width === 2) {
this._terminal.buffer.lines.get(row)[this._terminal.buffer.x] = [this._terminal.curAttr, '', 0, undefined];
this._terminal.buffer.x++;
}
}
};
InputHandler.prototype.bell = function () {
this._terminal.bell();
};
InputHandler.prototype.lineFeed = function () {
if (this._terminal.convertEol) {
this._terminal.buffer.x = 0;
}
this._terminal.buffer.y++;
if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {
this._terminal.buffer.y--;
this._terminal.scroll();
}
if (this._terminal.buffer.x >= this._terminal.cols) {
this._terminal.buffer.x--;
}
this._terminal.emit('linefeed');
};
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 () {
this._terminal.buffer.x = this._terminal.buffer.nextStop();
};
InputHandler.prototype.shiftOut = function () {
this._terminal.setgLevel(1);
};
InputHandler.prototype.shiftIn = function () {
this._terminal.setgLevel(0);
};
InputHandler.prototype.insertChars = function (params) {
var param = params[0];
if (param < 1)
param = 1;
var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
var j = this._terminal.buffer.x;
var ch = [this._terminal.eraseAttr(), ' ', 1, 32];
while (param-- && j < this._terminal.cols) {
this._terminal.buffer.lines.get(row).splice(j++, 0, ch);
this._terminal.buffer.lines.get(row).pop();
}
};
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.eraseInDisplay = function (params) {
var j;
switch (params[0]) {
case 0:
this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);
j = this._terminal.buffer.y + 1;
for (; j < this._terminal.rows; j++) {
this._terminal.eraseLine(j);
}
break;
case 1:
this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);
j = this._terminal.buffer.y;
while (j--) {
this._terminal.eraseLine(j);
}
break;
case 2:
j = this._terminal.rows;
while (j--)
this._terminal.eraseLine(j);
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._terminal.emit('scroll', 0);
}
break;
}
};
InputHandler.prototype.eraseInLine = function (params) {
switch (params[0]) {
case 0:
this._terminal.eraseRight(this._terminal.buffer.x, this._terminal.buffer.y);
break;
case 1:
this._terminal.eraseLeft(this._terminal.buffer.x, this._terminal.buffer.y);
break;
case 2:
this._terminal.eraseLine(this._terminal.buffer.y);
break;
}
};
InputHandler.prototype.insertLines = function (params) {
var param = params[0];
if (param < 1) {
param = 1;
}
var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
var scrollBottomRowsOffset = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;
var scrollBottomAbsolute = this._terminal.rows - 1 + this._terminal.buffer.ybase - scrollBottomRowsOffset + 1;
while (param--) {
this._terminal.buffer.lines.splice(scrollBottomAbsolute - 1, 1);
this._terminal.buffer.lines.splice(row, 0, this._terminal.blankLine(true));
}
this._terminal.updateRange(this._terminal.buffer.y);
this._terminal.updateRange(this._terminal.buffer.scrollBottom);
};
InputHandler.prototype.deleteLines = function (params) {
var param = params[0];
if (param < 1) {
param = 1;
}
var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
var j;
j = this._terminal.rows - 1 - this._terminal.buffer.scrollBottom;
j = this._terminal.rows - 1 + this._terminal.buffer.ybase - j;
while (param--) {
this._terminal.buffer.lines.splice(row, 1);
this._terminal.buffer.lines.splice(j, 0, this._terminal.blankLine(true));
}
this._terminal.updateRange(this._terminal.buffer.y);
this._terminal.updateRange(this._terminal.buffer.scrollBottom);
};
InputHandler.prototype.deleteChars = function (params) {
var param = params[0];
if (param < 1) {
param = 1;
}
var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
var ch = [this._terminal.eraseAttr(), ' ', 1, 32];
while (param--) {
this._terminal.buffer.lines.get(row).splice(this._terminal.buffer.x, 1);
this._terminal.buffer.lines.get(row).push(ch);
}
this._terminal.updateRange(this._terminal.buffer.y);
};
InputHandler.prototype.scrollUp = function (params) {
var param = params[0] || 1;
while (param--) {
this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 1);
this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 0, this._terminal.blankLine());
}
this._terminal.updateRange(this._terminal.buffer.scrollTop);
this._terminal.updateRange(this._terminal.buffer.scrollBottom);
};
InputHandler.prototype.scrollDown = function (params) {
var param = params[0] || 1;
while (param--) {
this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollBottom, 1);
this._terminal.buffer.lines.splice(this._terminal.buffer.ybase + this._terminal.buffer.scrollTop, 0, this._terminal.blankLine());
}
this._terminal.updateRange(this._terminal.buffer.scrollTop);
this._terminal.updateRange(this._terminal.buffer.scrollBottom);
};
InputHandler.prototype.eraseChars = function (params) {
var param = params[0];
if (param < 1) {
param = 1;
}
var row = this._terminal.buffer.y + this._terminal.buffer.ybase;
var j = this._terminal.buffer.x;
var ch = [this._terminal.eraseAttr(), ' ', 1, 32];
while (param-- && j < this._terminal.cols) {
this._terminal.buffer.lines.get(row)[j++] = ch;
}
};
InputHandler.prototype.cursorBackwardTab = function (params) {
var param = params[0] || 1;
while (param--) {
this._terminal.buffer.x = this._terminal.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 param = params[0] || 1;
var line = this._terminal.buffer.lines.get(this._terminal.buffer.ybase + this._terminal.buffer.y);
var ch = line[this._terminal.buffer.x - 1] || [this._terminal.defAttr, ' ', 1, 32];
while (param--) {
line[this._terminal.buffer.x++] = ch;
}
};
InputHandler.prototype.sendDeviceAttributes = function (params) {
if (params[0] > 0) {
return;
}
if (!this._terminal.prefix) {
if (this._terminal.is('xterm') || this._terminal.is('rxvt-unicode') || this._terminal.is('screen')) {
this._terminal.send(EscapeSequences_1.C0.ESC + '[?1;2c');
}
else if (this._terminal.is('linux')) {
this._terminal.send(EscapeSequences_1.C0.ESC + '[?6c');
}
}
else if (this._terminal.prefix === '>') {
if (this._terminal.is('xterm')) {
this._terminal.send(EscapeSequences_1.C0.ESC + '[>0;276;0c');
}
else if (this._terminal.is('rxvt-unicode')) {
this._terminal.send(EscapeSequences_1.C0.ESC + '[>85;95;0c');
}
else if (this._terminal.is('linux')) {
this._terminal.send(params[0] + 'c');
}
else if (this._terminal.is('screen')) {
this._terminal.send(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) {
if (params.length > 1) {
for (var i = 0; i < params.length; i++) {
this.setMode([params[i]]);
}
return;
}
if (!this._terminal.prefix) {
switch (params[0]) {
case 4:
this._terminal.insertMode = true;
break;
case 20:
break;
}
}
else if (this._terminal.prefix === '?') {
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;
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;
this._terminal.element.classList.add('enable-mouse-events');
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 1049:
case 47:
case 1047:
this._terminal.buffers.activateAltBuffer();
this._terminal.selectionManager.setBuffer(this._terminal.buffer);
this._terminal.viewport.syncScrollArea();
this._terminal.showCursor();
break;
case 2004:
this._terminal.bracketedPasteMode = true;
break;
}
}
};
InputHandler.prototype.resetMode = function (params) {
if (params.length > 1) {
for (var i = 0; i < params.length; i++) {
this.resetMode([params[i]]);
}
return;
}
if (!this._terminal.prefix) {
switch (params[0]) {
case 4:
this._terminal.insertMode = false;
break;
case 20:
break;
}
}
else if (this._terminal.prefix === '?') {
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;
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;
this._terminal.element.classList.remove('enable-mouse-events');
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 1049:
case 47:
case 1047:
this._terminal.buffers.activateNormalBuffer();
this._terminal.selectionManager.setBuffer(this._terminal.buffer);
this._terminal.refresh(0, this._terminal.rows - 1);
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.curAttr = this._terminal.defAttr;
return;
}
var l = params.length;
var flags = this._terminal.curAttr >> 18;
var fg = (this._terminal.curAttr >> 9) & 0x1ff;
var bg = this._terminal.curAttr & 0x1ff;
var p;
for (var i = 0; i < l; i++) {
p = params[i];
if (p >= 30 && p <= 37) {
fg = p - 30;
}
else if (p >= 40 && p <= 47) {
bg = p - 40;
}
else if (p >= 90 && p <= 97) {
p += 8;
fg = p - 90;
}
else if (p >= 100 && p <= 107) {
p += 8;
bg = p - 100;
}
else if (p === 0) {
flags = this._terminal.defAttr >> 18;
fg = (this._terminal.defAttr >> 9) & 0x1ff;
bg = this._terminal.defAttr & 0x1ff;
}
else if (p === 1) {
flags |= Types_1.FLAGS.BOLD;
}
else if (p === 4) {
flags |= Types_1.FLAGS.UNDERLINE;
}
else if (p === 5) {
flags |= Types_1.FLAGS.BLINK;
}
else if (p === 7) {
flags |= Types_1.FLAGS.INVERSE;
}
else if (p === 8) {
flags |= Types_1.FLAGS.INVISIBLE;
}
else if (p === 2) {
flags |= Types_1.FLAGS.DIM;
}
else if (p === 22) {
flags &= ~Types_1.FLAGS.BOLD;
flags &= ~Types_1.FLAGS.DIM;
}
else if (p === 24) {
flags &= ~Types_1.FLAGS.UNDERLINE;
}
else if (p === 25) {
flags &= ~Types_1.FLAGS.BLINK;
}
else if (p === 27) {
flags &= ~Types_1.FLAGS.INVERSE;
}
else if (p === 28) {
flags &= ~Types_1.FLAGS.INVISIBLE;
}
else if (p === 39) {
fg = (this._terminal.defAttr >> 9) & 0x1ff;
}
else if (p === 49) {
bg = this._terminal.defAttr & 0x1ff;
}
else if (p === 38) {
if (params[i + 1] === 2) {
i += 2;
fg = this._terminal.matchColor(params[i] & 0xff, params[i + 1] & 0xff, params[i + 2] & 0xff);
if (fg === -1)
fg = 0x1ff;
i += 2;
}
else if (params[i + 1] === 5) {
i += 2;
p = params[i] & 0xff;
fg = p;
}
}
else if (p === 48) {
if (params[i + 1] === 2) {
i += 2;
bg = this._terminal.matchColor(params[i] & 0xff, params[i + 1] & 0xff, params[i + 2] & 0xff);
if (bg === -1)
bg = 0x1ff;
i += 2;
}
else if (params[i + 1] === 5) {
i += 2;
p = params[i] & 0xff;
bg = p;
}
}
else if (p === 100) {
fg = (this._terminal.defAttr >> 9) & 0x1ff;
bg = this._terminal.defAttr & 0x1ff;
}
else {
this._terminal.error('Unknown SGR attribute: %d.', p);
}
}
this._terminal.curAttr = (flags << 18) | (fg << 9) | bg;
};
InputHandler.prototype.deviceStatus = function (params) {
if (!this._terminal.prefix) {
switch (params[0]) {
case 5:
this._terminal.send(EscapeSequences_1.C0.ESC + '[0n');
break;
case 6:
this._terminal.send(EscapeSequences_1.C0.ESC + '['
+ (this._terminal.buffer.y + 1)
+ ';'
+ (this._terminal.buffer.x + 1)
+ 'R');
break;
}
}
else if (this._terminal.prefix === '?') {
switch (params[0]) {
case 6:
this._terminal.send(EscapeSequences_1.C0.ESC + '[?'
+ (this._terminal.buffer.y + 1)
+ ';'
+ (this._terminal.buffer.x + 1)
+ 'R');
break;
case 15:
break;
case 25:
break;
case 26:
break;
case 53:
break;
}
}
};
InputHandler.prototype.softReset = function (params) {
this._terminal.cursorHidden = false;
this._terminal.insertMode = false;
this._terminal.originMode = false;
this._terminal.wraparoundMode = true;
this._terminal.applicationKeypad = false;
this._terminal.viewport.syncScrollArea();
this._terminal.applicationCursor = false;
this._terminal.buffer.scrollTop = 0;
this._terminal.buffer.scrollBottom = this._terminal.rows - 1;
this._terminal.curAttr = this._terminal.defAttr;
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) {
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) {
if (this._terminal.prefix)
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;
};
InputHandler.prototype.restoreCursor = function (params) {
this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
};
return InputHandler;
}());
exports.InputHandler = InputHandler;
},{"./Buffer":1,"./CharWidth":3,"./Charsets":4,"./EscapeSequences":6,"./renderer/Types":27}],9:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 MouseZoneManager_1 = require("./input/MouseZoneManager");
var EventEmitter_1 = require("./EventEmitter");
var protocolClause = '(https?:\\/\\/)';
var domainCharacterSet = '[\\da-z\\.-]+';
var negatedDomainCharacterSet = '[^\\da-z\\.-]+';
var domainBodyClause = '(' + domainCharacterSet + ')';
var tldClause = '([a-z\\.]{2,6})';
var ipClause = '((\\d{1,3}\\.){3}\\d{1,3})';
var localHostClause = '(localhost)';
var portClause = '(:\\d{1,5})';
var hostClause = '((' + domainBodyClause + '\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';
var pathClause = '(\\/[\\/\\w\\.\\-%~]*)*';
var queryStringHashFragmentCharacterSet = '[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&\'*+,:;~\\=\\.\\-]*';
var queryStringClause = '(\\?' + queryStringHashFragmentCharacterSet + ')?';
var hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';
var negatedPathCharacterSet = '[^\\/\\w\\.\\-%]+';
var bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;
var start = '(?:^|' + negatedDomainCharacterSet + ')(';
var end = ')($|' + negatedPathCharacterSet + ')';
var strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);
var HYPERTEXT_LINK_MATCHER_ID = 0;
var Linkifier = (function (_super) {
__extends(Linkifier, _super);
function Linkifier(_terminal) {
var _this = _super.call(this) || this;
_this._terminal = _terminal;
_this._linkMatchers = [];
_this._nextLinkMatcherId = HYPERTEXT_LINK_MATCHER_ID;
_this._rowsToLinkify = {
start: null,
end: null
};
_this.registerLinkMatcher(strictUrlRegex, null, { matchIndex: 1 });
return _this;
}
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) {
this._rowsToLinkify.start = start;
this._rowsToLinkify.end = end;
}
else {
this._rowsToLinkify.start = this._rowsToLinkify.start < start ? this._rowsToLinkify.start : start;
this._rowsToLinkify.end = this._rowsToLinkify.end > end ? 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;
for (var i = this._rowsToLinkify.start; i <= this._rowsToLinkify.end; i++) {
this._linkifyRow(i);
}
this._rowsToLinkify.start = null;
this._rowsToLinkify.end = null;
};
Linkifier.prototype.setHypertextLinkHandler = function (handler) {
this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].handler = handler;
};
Linkifier.prototype.setHypertextValidationCallback = function (callback) {
this._linkMatchers[HYPERTEXT_LINK_MATCHER_ID].validationCallback = callback;
};
Linkifier.prototype.registerLinkMatcher = function (regex, handler, options) {
if (options === void 0) { options = {}; }
if (this._nextLinkMatcherId !== HYPERTEXT_LINK_MATCHER_ID && !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,
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 = 1; i < this._linkMatchers.length; i++) {
if (this._linkMatchers[i].id === matcherId) {
this._linkMatchers.splice(i, 1);
return true;
}
}
return false;
};
Linkifier.prototype._linkifyRow = function (rowIndex) {
var absoluteRowIndex = this._terminal.buffer.ydisp + rowIndex;
if (absoluteRowIndex >= this._terminal.buffer.lines.length) {
return;
}
var text = this._terminal.buffer.translateBufferLineToString(absoluteRowIndex, false);
for (var i = 0; i < this._linkMatchers.length; i++) {
this._doLinkifyRow(rowIndex, text, this._linkMatchers[i]);
}
};
Linkifier.prototype._doLinkifyRow = function (rowIndex, text, matcher, offset) {
var _this = this;
if (offset === void 0) { offset = 0; }
var result = [];
var isHttpLinkMatcher = matcher.id === HYPERTEXT_LINK_MATCHER_ID;
var match = text.match(matcher.regex);
if (!match || match.length === 0) {
return;
}
var uri = match[typeof matcher.matchIndex !== 'number' ? 0 : matcher.matchIndex];
var index = text.indexOf(uri);
if (matcher.validationCallback) {
matcher.validationCallback(uri, function (isValid) {
if (_this._rowsTimeoutId) {
return;
}
if (isValid) {
_this._addLink(offset + index, rowIndex, uri, matcher);
}
});
}
else {
this._addLink(offset + index, rowIndex, uri, matcher);
}
var remainingStartIndex = index + uri.length;
var remainingText = text.substr(remainingStartIndex);
if (remainingText.length > 0) {
this._doLinkifyRow(rowIndex, remainingText, matcher, offset + remainingStartIndex);
}
};
Linkifier.prototype._addLink = function (x, y, uri, matcher) {
var _this = this;
this._mouseZoneManager.add(new MouseZoneManager_1.MouseZone(x + 1, x + 1 + uri.length, y + 1, function (e) {
if (matcher.handler) {
return matcher.handler(e, uri);
}
window.open(uri, '_blank');
}, function (e) {
_this.emit(Types_1.LinkHoverEventTypes.HOVER, { x: x, y: y, length: uri.length });
_this._terminal.element.style.cursor = 'pointer';
}, function (e) {
_this.emit(Types_1.LinkHoverEventTypes.TOOLTIP, { x: x, y: y, length: uri.length });
if (matcher.hoverTooltipCallback) {
matcher.hoverTooltipCallback(e, uri);
}
}, function () {
_this.emit(Types_1.LinkHoverEventTypes.LEAVE, { x: x, y: y, length: uri.length });
_this._terminal.element.style.cursor = '';
if (matcher.hoverLeaveCallback) {
matcher.hoverLeaveCallback();
}
}));
};
Linkifier.TIME_BEFORE_LINKIFY = 200;
return Linkifier;
}(EventEmitter_1.EventEmitter));
exports.Linkifier = Linkifier;
},{"./EventEmitter":7,"./Types":14,"./input/MouseZoneManager":17}],10:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var EscapeSequences_1 = require("./EscapeSequences");
var Charsets_1 = require("./Charsets");
var normalStateHandler = {};
normalStateHandler[EscapeSequences_1.C0.BEL] = function (parser, handler) { return handler.bell(); };
normalStateHandler[EscapeSequences_1.C0.LF] = function (parser, handler) { return handler.lineFeed(); };
normalStateHandler[EscapeSequences_1.C0.VT] = normalStateHandler[EscapeSequences_1.C0.LF];
normalStateHandler[EscapeSequences_1.C0.FF] = normalStateHandler[EscapeSequences_1.C0.LF];
normalStateHandler[EscapeSequences_1.C0.CR] = function (parser, handler) { return handler.carriageReturn(); };
normalStateHandler[EscapeSequences_1.C0.BS] = function (parser, handler) { return handler.backspace(); };
normalStateHandler[EscapeSequences_1.C0.HT] = function (parser, handler) { return handler.tab(); };
normalStateHandler[EscapeSequences_1.C0.SO] = function (parser, handler) { return handler.shiftOut(); };
normalStateHandler[EscapeSequences_1.C0.SI] = function (parser, handler) { return handler.shiftIn(); };
normalStateHandler[EscapeSequences_1.C0.ESC] = function (parser, handler) { return parser.setState(ParserState.ESCAPED); };
var escapedStateHandler = {};
escapedStateHandler['['] = function (parser, terminal) {
terminal.params = [];
terminal.currentParam = 0;
parser.setState(ParserState.CSI_PARAM);
};
escapedStateHandler[']'] = function (parser, terminal) {
terminal.params = [];
terminal.currentParam = 0;
parser.setState(ParserState.OSC);
};
escapedStateHandler['P'] = function (parser, terminal) {
terminal.params = [];
terminal.currentParam = 0;
parser.setState(ParserState.DCS);
};
escapedStateHandler['_'] = function (parser, terminal) {
parser.setState(ParserState.IGNORE);
};
escapedStateHandler['^'] = function (parser, terminal) {
parser.setState(ParserState.IGNORE);
};
escapedStateHandler['c'] = function (parser, terminal) {
terminal.reset();
};
escapedStateHandler['E'] = function (parser, terminal) {
terminal.buffer.x = 0;
terminal.index();
parser.setState(ParserState.NORMAL);
};
escapedStateHandler['D'] = function (parser, terminal) {
terminal.index();
parser.setState(ParserState.NORMAL);
};
escapedStateHandler['M'] = function (parser, terminal) {
terminal.reverseIndex();
parser.setState(ParserState.NORMAL);
};
escapedStateHandler['%'] = function (parser, terminal) {
terminal.setgLevel(0);
terminal.setgCharset(0, Charsets_1.DEFAULT_CHARSET);
parser.setState(ParserState.NORMAL);
parser.skipNextChar();
};
escapedStateHandler[EscapeSequences_1.C0.CAN] = function (parser) { return parser.setState(ParserState.NORMAL); };
var csiParamStateHandler = {};
csiParamStateHandler['?'] = function (parser) { return parser.setPrefix('?'); };
csiParamStateHandler['>'] = function (parser) { return parser.setPrefix('>'); };
csiParamStateHandler['!'] = function (parser) { return parser.setPrefix('!'); };
csiParamStateHandler['0'] = function (parser) { return parser.setParam(parser.getParam() * 10); };
csiParamStateHandler['1'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 1); };
csiParamStateHandler['2'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 2); };
csiParamStateHandler['3'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 3); };
csiParamStateHandler['4'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 4); };
csiParamStateHandler['5'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 5); };
csiParamStateHandler['6'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 6); };
csiParamStateHandler['7'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 7); };
csiParamStateHandler['8'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 8); };
csiParamStateHandler['9'] = function (parser) { return parser.setParam(parser.getParam() * 10 + 9); };
csiParamStateHandler['$'] = function (parser) { return parser.setPostfix('$'); };
csiParamStateHandler['"'] = function (parser) { return parser.setPostfix('"'); };
csiParamStateHandler[' '] = function (parser) { return parser.setPostfix(' '); };
csiParamStateHandler['\''] = function (parser) { return parser.setPostfix('\''); };
csiParamStateHandler[';'] = function (parser) { return parser.finalizeParam(); };
csiParamStateHandler[EscapeSequences_1.C0.CAN] = function (parser) { return parser.setState(ParserState.NORMAL); };
var csiStateHandler = {};
csiStateHandler['@'] = function (handler, params, prefix) { return handler.insertChars(params); };
csiStateHandler['A'] = function (handler, params, prefix) { return handler.cursorUp(params); };
csiStateHandler['B'] = function (handler, params, prefix) { return handler.cursorDown(params); };
csiStateHandler['C'] = function (handler, params, prefix) { return handler.cursorForward(params); };
csiStateHandler['D'] = function (handler, params, prefix) { return handler.cursorBackward(params); };
csiStateHandler['E'] = function (handler, params, prefix) { return handler.cursorNextLine(params); };
csiStateHandler['F'] = function (handler, params, prefix) { return handler.cursorPrecedingLine(params); };
csiStateHandler['G'] = function (handler, params, prefix) { return handler.cursorCharAbsolute(params); };
csiStateHandler['H'] = function (handler, params, prefix) { return handler.cursorPosition(params); };
csiStateHandler['I'] = function (handler, params, prefix) { return handler.cursorForwardTab(params); };
csiStateHandler['J'] = function (handler, params, prefix) { return handler.eraseInDisplay(params); };
csiStateHandler['K'] = function (handler, params, prefix) { return handler.eraseInLine(params); };
csiStateHandler['L'] = function (handler, params, prefix) { return handler.insertLines(params); };
csiStateHandler['M'] = function (handler, params, prefix) { return handler.deleteLines(params); };
csiStateHandler['P'] = function (handler, params, prefix) { return handler.deleteChars(params); };
csiStateHandler['S'] = function (handler, params, prefix) { return handler.scrollUp(params); };
csiStateHandler['T'] = function (handler, params, prefix) {
if (params.length < 2 && !prefix) {
handler.scrollDown(params);
}
};
csiStateHandler['X'] = function (handler, params, prefix) { return handler.eraseChars(params); };
csiStateHandler['Z'] = function (handler, params, prefix) { return handler.cursorBackwardTab(params); };
csiStateHandler['`'] = function (handler, params, prefix) { return handler.charPosAbsolute(params); };
csiStateHandler['a'] = function (handler, params, prefix) { return handler.HPositionRelative(params); };
csiStateHandler['b'] = function (handler, params, prefix) { return handler.repeatPrecedingCharacter(params); };
csiStateHandler['c'] = function (handler, params, prefix) { return handler.sendDeviceAttributes(params); };
csiStateHandler['d'] = function (handler, params, prefix) { return handler.linePosAbsolute(params); };
csiStateHandler['e'] = function (handler, params, prefix) { return handler.VPositionRelative(params); };
csiStateHandler['f'] = function (handler, params, prefix) { return handler.HVPosition(params); };
csiStateHandler['g'] = function (handler, params, prefix) { return handler.tabClear(params); };
csiStateHandler['h'] = function (handler, params, prefix) { return handler.setMode(params); };
csiStateHandler['l'] = function (handler, params, prefix) { return handler.resetMode(params); };
csiStateHandler['m'] = function (handler, params, prefix) { return handler.charAttributes(params); };
csiStateHandler['n'] = function (handler, params, prefix) { return handler.deviceStatus(params); };
csiStateHandler['p'] = function (handler, params, prefix) {
switch (prefix) {
case '!':
handler.softReset(params);
break;
}
};
csiStateHandler['q'] = function (handler, params, prefix, postfix) {
if (postfix === ' ') {
handler.setCursorStyle(params);
}
};
csiStateHandler['r'] = function (handler, params) { return handler.setScrollRegion(params); };
csiStateHandler['s'] = function (handler, params) { return handler.saveCursor(params); };
csiStateHandler['u'] = function (handler, params) { return handler.restoreCursor(params); };
csiStateHandler[EscapeSequences_1.C0.CAN] = function (handler, params, prefix, postfix, parser) { return parser.setState(ParserState.NORMAL); };
var ParserState;
(function (ParserState) {
ParserState[ParserState["NORMAL"] = 0] = "NORMAL";
ParserState[ParserState["ESCAPED"] = 1] = "ESCAPED";
ParserState[ParserState["CSI_PARAM"] = 2] = "CSI_PARAM";
ParserState[ParserState["CSI"] = 3] = "CSI";
ParserState[ParserState["OSC"] = 4] = "OSC";
ParserState[ParserState["CHARSET"] = 5] = "CHARSET";
ParserState[ParserState["DCS"] = 6] = "DCS";
ParserState[ParserState["IGNORE"] = 7] = "IGNORE";
})(ParserState = exports.ParserState || (exports.ParserState = {}));
var Parser = (function () {
function Parser(_inputHandler, _terminal) {
this._inputHandler = _inputHandler;
this._terminal = _terminal;
this._state = ParserState.NORMAL;
}
Parser.prototype.parse = function (data) {
var l = data.length;
var j;
var cs;
var ch;
var code;
var low;
var cursorStartX = this._terminal.buffer.x;
var cursorStartY = this._terminal.buffer.y;
if (this._terminal.debug) {
this._terminal.log('data: ' + data);
}
this._position = 0;
if (this._terminal.surrogate_high) {
data = this._terminal.surrogate_high + data;
this._terminal.surrogate_high = '';
}
for (; this._position < l; this._position++) {
ch = data[this._position];
code = data.charCodeAt(this._position);
if (0xD800 <= code && code <= 0xDBFF) {
low = data.charCodeAt(this._position + 1);
if (isNaN(low)) {
this._terminal.surrogate_high = ch;
continue;
}
code = ((code - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
ch += data.charAt(this._position + 1);
}
if (0xDC00 <= code && code <= 0xDFFF)
continue;
switch (this._state) {
case ParserState.NORMAL:
if (ch in normalStateHandler) {
normalStateHandler[ch](this, this._inputHandler);
}
else {
this._inputHandler.addChar(ch, code);
}
break;
case ParserState.ESCAPED:
if (ch in escapedStateHandler) {
escapedStateHandler[ch](this, this._terminal);
break;
}
switch (ch) {
case '(':
case ')':
case '*':
case '+':
case '-':
case '.':
switch (ch) {
case '(':
this._terminal.gcharset = 0;
break;
case ')':
this._terminal.gcharset = 1;
break;
case '*':
this._terminal.gcharset = 2;
break;
case '+':
this._terminal.gcharset = 3;
break;
case '-':
this._terminal.gcharset = 1;
break;
case '.':
this._terminal.gcharset = 2;
break;
}
this._state = ParserState.CHARSET;
break;
case '/':
this._terminal.gcharset = 3;
this._state = ParserState.CHARSET;
this._position--;
break;
case 'N':
break;
case 'O':
break;
case 'n':
this._terminal.setgLevel(2);
break;
case 'o':
this._terminal.setgLevel(3);
break;
case '|':
this._terminal.setgLevel(3);
break;
case '}':
this._terminal.setgLevel(2);
break;
case '~':
this._terminal.setgLevel(1);
break;
case '7':
this._inputHandler.saveCursor();
this._state = ParserState.NORMAL;
break;
case '8':
this._inputHandler.restoreCursor();
this._state = ParserState.NORMAL;
break;
case '#':
this._state = ParserState.NORMAL;
this._position++;
break;
case 'H':
this._terminal.tabSet();
this._state = ParserState.NORMAL;
break;
case '=':
this._terminal.log('Serial port requested application keypad.');
this._terminal.applicationKeypad = true;
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._state = ParserState.NORMAL;
break;
case '>':
this._terminal.log('Switching back to normal keypad.');
this._terminal.applicationKeypad = false;
if (this._terminal.viewport) {
this._terminal.viewport.syncScrollArea();
}
this._state = ParserState.NORMAL;
break;
default:
this._state = ParserState.NORMAL;
this._terminal.error('Unknown ESC control: %s.', ch);
break;
}
break;
case ParserState.CHARSET:
if (ch in Charsets_1.CHARSETS) {
cs = Charsets_1.CHARSETS[ch];
if (ch === '/') {
this.skipNextChar();
}
}
else {
cs = Charsets_1.DEFAULT_CHARSET;
}
this._terminal.setgCharset(this._terminal.gcharset, cs);
this._terminal.gcharset = null;
this._state = ParserState.NORMAL;
break;
case ParserState.OSC:
if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {
if (ch === EscapeSequences_1.C0.ESC)
this._position++;
this._terminal.params.push(this._terminal.currentParam);
switch (this._terminal.params[0]) {
case 0:
case 1:
case 2:
if (this._terminal.params[1]) {
this._terminal.title = this._terminal.params[1];
this._terminal.handleTitle(this._terminal.title);
}
break;
case 3:
break;
case 4:
case 5:
break;
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
break;
case 46:
break;
case 50:
break;
case 51:
break;
case 52:
break;
case 104:
case 105:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
break;
}
this._terminal.params = [];
this._terminal.currentParam = 0;
this._state = ParserState.NORMAL;
}
else {
if (!this._terminal.params.length) {
if (ch >= '0' && ch <= '9') {
this._terminal.currentParam =
this._terminal.currentParam * 10 + ch.charCodeAt(0) - 48;
}
else if (ch === ';') {
this._terminal.params.push(this._terminal.currentParam);
this._terminal.currentParam = '';
}
}
else {
this._terminal.currentParam += ch;
}
}
break;
case ParserState.CSI_PARAM:
if (ch in csiParamStateHandler) {
csiParamStateHandler[ch](this);
break;
}
this.finalizeParam();
this._state = ParserState.CSI;
case ParserState.CSI:
if (ch in csiStateHandler) {
if (this._terminal.debug) {
this._terminal.log("CSI " + (this._terminal.prefix ? this._terminal.prefix : '') + " " + (this._terminal.params ? this._terminal.params.join(';') : '') + " " + (this._terminal.postfix ? this._terminal.postfix : '') + " " + ch);
}
csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);
}
else {
this._terminal.error('Unknown CSI code: %s.', ch);
}
this._state = ParserState.NORMAL;
this._terminal.prefix = '';
this._terminal.postfix = '';
break;
case ParserState.DCS:
if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {
if (ch === EscapeSequences_1.C0.ESC)
this._position++;
var pt = void 0;
var valid = void 0;
switch (this._terminal.prefix) {
case '':
break;
case '$q':
pt = this._terminal.currentParam;
valid = false;
switch (pt) {
case '"q':
pt = '0"q';
break;
case '"p':
pt = '61"p';
break;
case 'r':
pt = ''
+ (this._terminal.buffer.scrollTop + 1)
+ ';'
+ (this._terminal.buffer.scrollBottom + 1)
+ 'r';
break;
case 'm':
pt = '0m';
break;
default:
this._terminal.error('Unknown DCS Pt: %s.', pt);
pt = '';
break;
}
this._terminal.send(EscapeSequences_1.C0.ESC + 'P' + +valid + '$r' + pt + EscapeSequences_1.C0.ESC + '\\');
break;
case '+p':
break;
case '+q':
pt = this._terminal.currentParam;
valid = false;
this._terminal.send(EscapeSequences_1.C0.ESC + 'P' + +valid + '+r' + pt + EscapeSequences_1.C0.ESC + '\\');
break;
default:
this._terminal.error('Unknown DCS prefix: %s.', this._terminal.prefix);
break;
}
this._terminal.currentParam = 0;
this._terminal.prefix = '';
this._state = ParserState.NORMAL;
}
else if (!this._terminal.currentParam) {
if (!this._terminal.prefix && ch !== '$' && ch !== '+') {
this._terminal.currentParam = ch;
}
else if (this._terminal.prefix.length === 2) {
this._terminal.currentParam = ch;
}
else {
this._terminal.prefix += ch;
}
}
else {
this._terminal.currentParam += ch;
}
break;
case ParserState.IGNORE:
if (ch === EscapeSequences_1.C0.ESC || ch === EscapeSequences_1.C0.BEL) {
if (ch === EscapeSequences_1.C0.ESC)
this._position++;
this._state = ParserState.NORMAL;
}
break;
}
}
if (this._terminal.buffer.x !== cursorStartX || this._terminal.buffer.y !== cursorStartY) {
this._terminal.emit('cursormove');
}
return this._state;
};
Parser.prototype.setState = function (state) {
this._state = state;
};
Parser.prototype.setPrefix = function (prefix) {
this._terminal.prefix = prefix;
};
Parser.prototype.setPostfix = function (postfix) {
this._terminal.postfix = postfix;
};
Parser.prototype.setParam = function (param) {
this._terminal.currentParam = param;
};
Parser.prototype.getParam = function () {
return this._terminal.currentParam;
};
Parser.prototype.finalizeParam = function () {
this._terminal.params.push(this._terminal.currentParam);
this._terminal.currentParam = 0;
};
Parser.prototype.skipNextChar = function () {
this._position++;
};
return Parser;
}());
exports.Parser = Parser;
},{"./Charsets":4,"./EscapeSequences":6}],11:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 MouseHelper_1 = require("./utils/MouseHelper");
var Browser = require("./utils/Browser");
var EventEmitter_1 = require("./EventEmitter");
var SelectionModel_1 = require("./SelectionModel");
var Buffer_1 = require("./Buffer");
var DRAG_SCROLL_MAX_THRESHOLD = 50;
var DRAG_SCROLL_MAX_SPEED = 15;
var DRAG_SCROLL_INTERVAL = 50;
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 SelectionMode;
(function (SelectionMode) {
SelectionMode[SelectionMode["NORMAL"] = 0] = "NORMAL";
SelectionMode[SelectionMode["WORD"] = 1] = "WORD";
SelectionMode[SelectionMode["LINE"] = 2] = "LINE";
})(SelectionMode || (SelectionMode = {}));
var SelectionManager = (function (_super) {
__extends(SelectionManager, _super);
function SelectionManager(_terminal, _buffer, _charMeasure) {
var _this = _super.call(this) || this;
_this._terminal = _terminal;
_this._buffer = _buffer;
_this._charMeasure = _charMeasure;
_this._enabled = true;
_this._initListeners();
_this.enable();
_this._model = new SelectionModel_1.SelectionModel(_terminal);
_this._activeSelectionMode = SelectionMode.NORMAL;
return _this;
}
SelectionManager.prototype._initListeners = function () {
var _this = this;
this._mouseMoveListener = function (event) { return _this._onMouseMove(event); };
this._mouseUpListener = function (event) { return _this._onMouseUp(event); };
this._buffer.lines.on('trim', function (amount) { return _this._onTrim(amount); });
};
SelectionManager.prototype.disable = function () {
this.clearSelection();
this._enabled = false;
};
SelectionManager.prototype.enable = function () {
this._enabled = true;
};
SelectionManager.prototype.setBuffer = function (buffer) {
this._buffer = buffer;
this.clearSelection();
};
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 startRowEndCol = start[1] === end[1] ? end[0] : null;
var result = [];
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 (isNewSelection) {
var _this = this;
if (!this._refreshAnimationFrame) {
this._refreshAnimationFrame = window.requestAnimationFrame(function () { return _this._refresh(); });
}
if (Browser.isLinux && isNewSelection) {
var selectionText = this.selectionText;
if (selectionText.length) {
this.emit('newselection', this.selectionText);
}
}
};
SelectionManager.prototype._refresh = function () {
this._refreshAnimationFrame = null;
this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });
};
SelectionManager.prototype.selectAll = function () {
this._model.isSelectAllActive = true;
this.refresh();
this._terminal.emit('selection');
};
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.element, this._charMeasure, this._terminal.options.lineHeight, 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.element)[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) {
return Browser.isMac ? event.altKey : event.shiftKey;
};
SelectionManager.prototype.onMouseDown = function (event) {
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 () {
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 = SelectionMode.NORMAL;
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;
}
var char = line[this._model.selectionStart[0]];
if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
this._model.selectionStart[0]++;
}
};
SelectionManager.prototype._onDoubleClick = function (event) {
var coords = this._getMouseBufferCoords(event);
if (coords) {
this._activeSelectionMode = SelectionMode.WORD;
this._selectWordAt(coords);
}
};
SelectionManager.prototype._onTripleClick = function (event) {
var coords = this._getMouseBufferCoords(event);
if (coords) {
this._activeSelectionMode = SelectionMode.LINE;
this._selectLineAt(coords[1]);
}
};
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 === SelectionMode.LINE) {
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 === SelectionMode.WORD) {
this._selectToWordAt(this._model.selectionEnd);
}
this._dragScrollAmount = this._getMouseEventScrollAmount(event);
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) {
var char = this._buffer.lines.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];
if (char && char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 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) {
this._model.selectionEnd = [this._terminal.cols - 1, this._terminal.buffer.ydisp + this._terminal.rows];
}
else {
this._model.selectionEnd = [0, this._terminal.buffer.ydisp];
}
this.refresh();
}
};
SelectionManager.prototype._onMouseUp = function (event) {
this._removeMouseDownListeners();
if (this.hasSelection)
this._terminal.emit('selection');
};
SelectionManager.prototype._convertViewportColToCharacterIndex = function (bufferLine, coords) {
var charIndex = coords[0];
for (var i = 0; coords[0] >= i; i++) {
var char = bufferLine[i];
if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
charIndex--;
}
else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1 && coords[0] !== i) {
charIndex += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 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) {
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[startCol][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
leftWideCharCount++;
startCol--;
}
if (bufferLine[endCol][Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
rightWideCharCount++;
endCol++;
}
if (bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
rightLongCharOffset += bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
endIndex += bufferLine[endCol][Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
}
while (startCol > 0 && startIndex > 0 && !this._isCharWordSeparator(bufferLine[startCol - 1])) {
var char = bufferLine[startCol - 1];
if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
leftWideCharCount++;
startCol--;
}
else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
leftLongCharOffset += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
startIndex -= char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
}
startIndex--;
startCol--;
}
while (endCol < bufferLine.length && endIndex + 1 < line.length && !this._isCharWordSeparator(bufferLine[endCol + 1])) {
var char = bufferLine[endCol + 1];
if (char[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
rightWideCharCount++;
endCol++;
}
else if (char[Buffer_1.CHAR_DATA_CHAR_INDEX].length > 1) {
rightLongCharOffset += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
endIndex += char[Buffer_1.CHAR_DATA_CHAR_INDEX].length - 1;
}
endIndex++;
endCol++;
}
}
endIndex++;
var start = startIndex
+ charOffset
- leftWideCharCount
+ leftLongCharOffset;
var length = Math.min(this._terminal.cols, endIndex
- startIndex
+ leftWideCharCount
+ rightWideCharCount
- leftLongCharOffset
- rightLongCharOffset);
return { start: start, length: length };
};
SelectionManager.prototype._selectWordAt = function (coords) {
var wordPosition = this._getWordAt(coords);
if (wordPosition) {
this._model.selectionStart = [wordPosition.start, coords[1]];
this._model.selectionStartLength = wordPosition.length;
}
};
SelectionManager.prototype._selectToWordAt = function (coords) {
var wordPosition = this._getWordAt(coords);
if (wordPosition) {
this._model.selectionEnd = [this._model.areSelectionValuesReversed() ? wordPosition.start : (wordPosition.start + wordPosition.length), coords[1]];
}
};
SelectionManager.prototype._isCharWordSeparator = function (charData) {
if (charData[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 0) {
return false;
}
return WORD_SEPARATORS.indexOf(charData[Buffer_1.CHAR_DATA_CHAR_INDEX]) >= 0;
};
SelectionManager.prototype._selectLineAt = function (line) {
this._model.selectionStart = [0, line];
this._model.selectionStartLength = this._terminal.cols;
};
return SelectionManager;
}(EventEmitter_1.EventEmitter));
exports.SelectionManager = SelectionManager;
},{"./Buffer":1,"./EventEmitter":7,"./SelectionModel":12,"./utils/Browser":28,"./utils/MouseHelper":32}],12:[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()) {
return [this.selectionStart[0] + this.selectionStartLength, 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;
},{}],13:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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("./EventEmitter");
var Viewport_1 = require("./Viewport");
var Clipboard_1 = require("./handlers/Clipboard");
var EscapeSequences_1 = require("./EscapeSequences");
var InputHandler_1 = require("./InputHandler");
var Parser_1 = require("./Parser");
var Renderer_1 = require("./renderer/Renderer");
var Linkifier_1 = require("./Linkifier");
var SelectionManager_1 = require("./SelectionManager");
var CharMeasure_1 = require("./utils/CharMeasure");
var Browser = require("./utils/Browser");
var MouseHelper_1 = require("./utils/MouseHelper");
var Sounds_1 = require("./utils/Sounds");
var ColorManager_1 = require("./renderer/ColorManager");
var MouseZoneManager_1 = require("./input/MouseZoneManager");
var CharAtlas_1 = require("./renderer/CharAtlas");
var document = (typeof window !== 'undefined') ? window.document : null;
var WRITE_BUFFER_PAUSE_THRESHOLD = 5;
var WRITE_BATCH_SIZE = 300;
var DEFAULT_OPTIONS = {
cols: 80,
rows: 24,
convertEol: false,
termName: 'xterm',
cursorBlink: false,
cursorStyle: 'block',
bellSound: Sounds_1.BellSound,
bellStyle: 'none',
enableBold: true,
fontFamily: 'courier-new, courier, monospace',
fontSize: 15,
lineHeight: 1.0,
letterSpacing: 0,
scrollback: 1000,
screenKeys: false,
debug: false,
cancelEvents: false,
disableStdin: false,
useFlowControl: false,
tabStopWidth: 8,
theme: null
};
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.options = options;
_this.setup();
return _this;
}
Terminal.prototype.setup = function () {
var _this = this;
Object.keys(DEFAULT_OPTIONS).forEach(function (key) {
if (_this.options[key] == null) {
_this.options[key] = DEFAULT_OPTIONS[key];
}
_this[key] = _this.options[key];
});
this.parent = document ? document.body : null;
this.cols = this.options.cols;
this.rows = this.options.rows;
if (this.options.handler) {
this.on('data', this.options.handler);
}
this.cursorState = 0;
this.cursorHidden = false;
this.sendDataQueue = '';
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.readable = true;
this.writable = true;
this.defAttr = (0 << 18) | (257 << 9) | (256 << 0);
this.curAttr = (0 << 18) | (257 << 9) | (256 << 0);
this.params = [];
this.currentParam = 0;
this.prefix = '';
this.postfix = '';
this.writeBuffer = [];
this.writeInProgress = false;
this.xoffSentToCatchUp = false;
this.writeStopped = false;
this.surrogate_high = '';
this.userScrolling = false;
this.inputHandler = new InputHandler_1.InputHandler(this);
this.parser = new Parser_1.Parser(this.inputHandler, this);
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.buffers = new BufferSet_1.BufferSet(this);
this.buffer = this.buffers.active;
this.buffers.on('activate', function (buffer) {
_this.buffer = buffer;
});
if (this.selectionManager) {
this.selectionManager.setBuffer(this.buffer);
}
};
Terminal.prototype.eraseAttr = function () {
return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);
};
Terminal.prototype.focus = function () {
if (this.textarea) {
this.textarea.focus();
}
};
Object.defineProperty(Terminal.prototype, "isFocused", {
get: function () {
return document.activeElement === this.textarea;
},
enumerable: true,
configurable: true
});
Terminal.prototype.getOption = function (key) {
if (!(key in DEFAULT_OPTIONS)) {
throw new Error('No option with key "' + key + '"');
}
if (typeof this.options[key] !== 'undefined') {
return this.options[key];
}
return this[key];
};
Terminal.prototype.setOption = function (key, value) {
if (!(key in DEFAULT_OPTIONS)) {
throw new Error('No option with key "' + key + '"');
}
switch (key) {
case 'bellStyle':
if (!value) {
value = 'none';
}
break;
case 'cursorStyle':
if (!value) {
value = 'block';
}
break;
case 'lineHeight':
if (value < 1) {
console.warn(key + " cannot be less than 1, value: " + value);
return;
}
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[key] = value;
this.options[key] = value;
switch (key) {
case 'fontFamily':
case 'fontSize':
this.renderer.clear();
this.charMeasure.measure(this.options);
break;
case 'enableBold':
case 'letterSpacing':
case 'lineHeight':
this.renderer.clear();
this.renderer.onResize(this.cols, this.rows, false);
this.refresh(0, this.rows - 1);
case 'scrollback':
this.buffers.resize(this.cols, this.rows);
this.viewport.syncScrollArea();
break;
case 'tabStopWidth':
this.buffers.setupTabStops();
break;
case 'bellSound':
case 'bellStyle':
this.syncBellSound();
break;
}
if (this.renderer) {
this.renderer.onOptionsChanged();
}
};
Terminal.prototype._onTextAreaFocus = function () {
if (this.sendFocus) {
this.send(EscapeSequences_1.C0.ESC + '[I');
}
this.element.classList.add('focus');
this.showCursor();
this.emit('focus');
};
;
Terminal.prototype.blur = function () {
return this.textarea.blur();
};
Terminal.prototype._onTextAreaBlur = function () {
this.refresh(this.buffer.y, this.buffer.y);
if (this.sendFocus) {
this.send(EscapeSequences_1.C0.ESC + '[O');
}
this.element.classList.remove('focus');
this.emit('blur');
};
Terminal.prototype.initGlobal = function () {
var _this = this;
this.bindKeys();
on(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); };
on(this.textarea, 'paste', pasteHandlerWrapper);
on(this.element, 'paste', pasteHandlerWrapper);
if (Browser.isFirefox) {
on(this.element, 'mousedown', function (event) {
if (event.button === 2) {
Clipboard_1.rightClickHandler(event, _this.textarea, _this.selectionManager);
}
});
}
else {
on(this.element, 'contextmenu', function (event) {
Clipboard_1.rightClickHandler(event, _this.textarea, _this.selectionManager);
});
}
if (Browser.isLinux) {
on(this.element, 'auxclick', function (event) {
if (event.button === 1) {
Clipboard_1.moveTextAreaUnderMouseCursor(event, _this.textarea);
}
});
}
};
Terminal.prototype.bindKeys = function () {
var _this = this;
var self = this;
on(this.element, 'keydown', function (ev) {
if (document.activeElement !== this) {
return;
}
self._keyDown(ev);
}, true);
on(this.element, 'keypress', function (ev) {
if (document.activeElement !== this) {
return;
}
self._keyPress(ev);
}, true);
on(this.element, 'keyup', function (ev) {
if (!wasMondifierKeyOnlyEvent(ev)) {
_this.focus();
}
}, true);
on(this.textarea, 'keydown', function (ev) {
_this._keyDown(ev);
}, true);
on(this.textarea, 'keypress', function (ev) {
_this._keyPress(ev);
_this.textarea.value = '';
}, true);
on(this.textarea, 'compositionstart', function () { return _this.compositionHelper.compositionstart(); });
on(this.textarea, 'compositionupdate', function (e) { return _this.compositionHelper.compositionupdate(e); });
on(this.textarea, 'compositionend', function () { return _this.compositionHelper.compositionend(); });
this.on('refresh', function () { return _this.compositionHelper.updateCompositionElements(); });
this.on('refresh', function (data) { return _this.queueLinkification(data.start, data.end); });
};
Terminal.prototype.open = function (parent) {
var _this = this;
var i = 0;
var div;
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.body = this.document.body;
CharAtlas_1.initialize(this.document);
this.element = this.document.createElement('div');
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._mouseZoneManager = new MouseZoneManager_1.MouseZoneManager(this);
this.on('scroll', function () { return _this._mouseZoneManager.clearAll(); });
this.linkifier.attachToDom(this._mouseZoneManager);
this.helperContainer = document.createElement('div');
this.helperContainer.classList.add('xterm-helpers');
fragment.appendChild(this.helperContainer);
this.textarea = document.createElement('textarea');
this.textarea.classList.add('xterm-helper-textarea');
this.textarea.setAttribute('autocorrect', 'off');
this.textarea.setAttribute('autocapitalize', 'off');
this.textarea.setAttribute('spellcheck', 'false');
this.textarea.tabIndex = 0;
this.textarea.addEventListener('focus', function () { return _this._onTextAreaFocus(); });
this.textarea.addEventListener('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.charSizeStyleElement = document.createElement('style');
this.helperContainer.appendChild(this.charSizeStyleElement);
this.charMeasure = new CharMeasure_1.CharMeasure(document, this.helperContainer);
this.syncBellSound();
this.element.appendChild(fragment);
this.renderer = new Renderer_1.Renderer(this, 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.on('cursormove', function () { return _this.renderer.onCursorMove(); });
this.on('resize', function () { return _this.renderer.onResize(_this.cols, _this.rows, false); });
this.on('blur', function () { return _this.renderer.onBlur(); });
this.on('focus', function () { return _this.renderer.onFocus(); });
window.addEventListener('resize', function () { return _this.renderer.onWindowResize(window.devicePixelRatio); });
this.charMeasure.on('charsizechanged', function () { return _this.renderer.onResize(_this.cols, _this.rows, true); });
this.renderer.on('resize', function (dimensions) { return _this.viewport.syncScrollArea(); });
this.selectionManager = new SelectionManager_1.SelectionManager(this, this.buffer, this.charMeasure);
this.element.addEventListener('mousedown', function (e) { return _this.selectionManager.onMouseDown(e); });
this.selectionManager.on('refresh', function (data) { return _this.renderer.onSelectionChanged(data.start, data.end); });
this.selectionManager.on('newselection', function (text) {
_this.textarea.value = text;
_this.textarea.focus();
_this.textarea.select();
});
this.on('scroll', function () {
_this.viewport.syncScrollArea();
_this.selectionManager.refresh();
});
this.viewportElement.addEventListener('scroll', function () { return _this.selectionManager.refresh(); });
this.mouseHelper = new MouseHelper_1.MouseHelper(this.renderer);
this.charMeasure.measure(this.options);
this.refresh(0, this.rows - 1);
this.initGlobal();
this.bindMouse();
};
Terminal.prototype._setTheme = function (theme) {
var colors = this.renderer.setTheme(theme);
if (this.viewport) {
this.viewport.onThemeChanged(colors);
}
};
Terminal.applyAddon = function (addon) {
addon.apply(Terminal);
};
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.element, self.charMeasure, self.options.lineHeight, 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.element, self.charMeasure, self.options.lineHeight, 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(0);
return;
}
if (ch < 127) {
data.push(ch);
}
else {
if (ch > 2047)
ch = 2047;
data.push(0xC0 | (ch >> 6));
data.push(0x80 | (ch & 0x3F));
}
}
}
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.send(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.send(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.send(EscapeSequences_1.C0.ESC + '[' + button + ';' + pos.x + ';' + pos.y + 'M');
return;
}
if (self.sgrMouse) {
pos.x -= 32;
pos.y -= 32;
self.send(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.send(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
: ev.which != null
? 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.wheelDeltaY > 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;
}
on(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);
}
if (_this.normalMouse)
on(_this.document, 'mousemove', sendMove);
if (!_this.x10Mouse) {
var handler_1 = function (ev) {
sendButton(ev);
if (_this.normalMouse)
off(_this.document, 'mousemove', sendMove);
off(_this.document, 'mouseup', handler_1);
return _this.cancel(ev);
};
on(_this.document, 'mouseup', handler_1);
}
return _this.cancel(ev);
});
on(el, 'wheel', function (ev) {
if (!_this.mouseEvents)
return;
if (_this.x10Mouse || _this.vt300Mouse || _this.decLocator)
return;
sendButton(ev);
ev.preventDefault();
});
on(el, 'wheel', function (ev) {
if (_this.mouseEvents)
return;
_this.viewport.onWheel(ev);
return _this.cancel(ev);
});
on(el, 'touchstart', function (ev) {
if (_this.mouseEvents)
return;
_this.viewport.onTouchStart(ev);
return _this.cancel(ev);
});
on(el, 'touchmove', function (ev) {
if (_this.mouseEvents)
return;
_this.viewport.onTouchMove(ev);
return _this.cancel(ev);
});
};
Terminal.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.readable = false;
this.writable = false;
this.handler = function () { };
this.write = function () { };
if (this.element && this.element.parentNode) {
this.element.parentNode.removeChild(this.element);
}
};
Terminal.prototype.refresh = function (start, end) {
if (this.renderer) {
this.renderer.queueRefresh(start, end);
}
};
Terminal.prototype.queueLinkification = function (start, end) {
if (this.linkifier) {
this.linkifier.linkifyRows(start, end);
}
};
Terminal.prototype.showCursor = function () {
if (!this.cursorState) {
this.cursorState = 1;
this.refresh(this.buffer.y, this.buffer.y);
}
};
Terminal.prototype.scroll = function (isWrapped) {
var newLine = this.blankLine(undefined, 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.length === this.buffer.lines.maxLength;
if (bottomRow === this.buffer.lines.length - 1) {
this.buffer.lines.push(newLine);
}
else {
this.buffer.lines.splice(bottomRow + 1, 0, newLine);
}
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);
}
if (!this.userScrolling) {
this.buffer.ydisp = this.buffer.ybase;
}
this.updateRange(this.buffer.scrollTop);
this.updateRange(this.buffer.scrollBottom);
this.emit('scroll', 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.emit('scroll', 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.write = function (data) {
var _this = this;
this.writeBuffer.push(data);
if (this.options.useFlowControl && !this.xoffSentToCatchUp && this.writeBuffer.length >= WRITE_BUFFER_PAUSE_THRESHOLD) {
this.send(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 () {
var _this = this;
var writeBatch = this.writeBuffer.splice(0, WRITE_BATCH_SIZE);
while (writeBatch.length > 0) {
var data = writeBatch.shift();
if (this.xoffSentToCatchUp && writeBatch.length === 0 && this.writeBuffer.length === 0) {
this.send(EscapeSequences_1.C0.DC1);
this.xoffSentToCatchUp = false;
}
this.refreshStart = this.buffer.y;
this.refreshEnd = this.buffer.y;
var state = this.parser.parse(data);
this.parser.setState(state);
this.updateRange(this.buffer.y);
this.refresh(this.refreshStart, this.refreshEnd);
}
if (this.writeBuffer.length > 0) {
setTimeout(function () { return _this.innerWrite(); }, 0);
}
else {
this.writeInProgress = false;
}
};
Terminal.prototype.writeln = function (data) {
this.write(data + '\r\n');
};
Terminal.prototype.attachCustomKeyEventHandler = function (customKeyEventHandler) {
this.customKeyEventHandler = customKeyEventHandler;
};
Terminal.prototype.setHypertextLinkHandler = function (handler) {
if (!this.linkifier) {
throw new Error('Cannot attach a hypertext link handler before Terminal.open is called');
}
this.linkifier.setHypertextLinkHandler(handler);
this.refresh(0, this.rows - 1);
};
Terminal.prototype.setHypertextValidationCallback = function (callback) {
if (!this.linkifier) {
throw new Error('Cannot attach a hypertext validation callback before Terminal.open is called');
}
this.linkifier.setHypertextValidationCallback(callback);
this.refresh(0, this.rows - 1);
};
Terminal.prototype.registerLinkMatcher = function (regex, handler, options) {
if (this.linkifier) {
var matcherId = this.linkifier.registerLinkMatcher(regex, handler, options);
this.refresh(0, this.rows - 1);
return matcherId;
}
return 0;
};
Terminal.prototype.deregisterLinkMatcher = function (matcherId) {
if (this.linkifier) {
if (this.linkifier.deregisterLinkMatcher(matcherId)) {
this.refresh(0, this.rows - 1);
}
}
};
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._keyDown = function (ev) {
if (this.customKeyEventHandler && this.customKeyEventHandler(ev) === false) {
return false;
}
if (!this.compositionHelper.keydown(ev)) {
if (this.buffer.ybase !== this.buffer.ydisp) {
this.scrollToBottom();
}
return false;
}
var result = this._evaluateKeyEscapeSequence(ev);
if (result.key === EscapeSequences_1.C0.DC3) {
this.writeStopped = true;
}
else if (result.key === EscapeSequences_1.C0.DC1) {
this.writeStopped = false;
}
if (result.scrollLines) {
this.scrollLines(result.scrollLines);
return this.cancel(ev, true);
}
if (isThirdLevelShift(this.browser, ev)) {
return true;
}
if (result.cancel) {
this.cancel(ev, true);
}
if (!result.key) {
return true;
}
this.emit('keydown', ev);
this.emit('key', result.key, ev);
this.showCursor();
this.handler(result.key);
return this.cancel(ev, true);
};
Terminal.prototype._evaluateKeyEscapeSequence = function (ev) {
var result = {
cancel: false,
key: undefined,
scrollLines: 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 (this.applicationCursor) {
result.key = EscapeSequences_1.C0.ESC + 'OA';
}
else {
result.key = EscapeSequences_1.C0.ESC + '[A';
}
}
else if (ev.key === 'UIKeyInputLeftArrow') {
if (this.applicationCursor) {
result.key = EscapeSequences_1.C0.ESC + 'OD';
}
else {
result.key = EscapeSequences_1.C0.ESC + '[D';
}
}
else if (ev.key === 'UIKeyInputRightArrow') {
if (this.applicationCursor) {
result.key = EscapeSequences_1.C0.ESC + 'OC';
}
else {
result.key = EscapeSequences_1.C0.ESC + '[C';
}
}
else if (ev.key === 'UIKeyInputDownArrow') {
if (this.applicationCursor) {
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;
}
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 = (this.browser.isMac) ? EscapeSequences_1.C0.ESC + 'b' : EscapeSequences_1.C0.ESC + '[1;5D';
}
}
else if (this.applicationCursor) {
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 = (this.browser.isMac) ? EscapeSequences_1.C0.ESC + 'f' : EscapeSequences_1.C0.ESC + '[1;5C';
}
}
else if (this.applicationCursor) {
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 (this.applicationCursor) {
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 (this.applicationCursor) {
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 (this.applicationCursor)
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 (this.applicationCursor)
result.key = EscapeSequences_1.C0.ESC + 'OF';
else
result.key = EscapeSequences_1.C0.ESC + '[F';
break;
case 33:
if (ev.shiftKey) {
result.scrollLines = -(this.rows - 1);
}
else {
result.key = EscapeSequences_1.C0.ESC + '[5~';
}
break;
case 34:
if (ev.shiftKey) {
result.scrollLines = this.rows - 1;
}
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 (!this.browser.isMac && ev.altKey && !ev.ctrlKey && !ev.metaKey) {
if (ev.keyCode >= 65 && ev.keyCode <= 90) {
result.key = EscapeSequences_1.C0.ESC + String.fromCharCode(ev.keyCode + 32);
}
else if (ev.keyCode === 192) {
result.key = EscapeSequences_1.C0.ESC + '`';
}
else if (ev.keyCode >= 48 && ev.keyCode <= 57) {
result.key = EscapeSequences_1.C0.ESC + (ev.keyCode - 48);
}
}
else if (this.browser.isMac && !ev.altKey && !ev.ctrlKey && ev.metaKey) {
if (ev.keyCode === 65) {
this.selectAll();
}
}
break;
}
return result;
};
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._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) {
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) && !isThirdLevelShift(this.browser, ev))) {
return false;
}
key = String.fromCharCode(key);
this.emit('keypress', key, ev);
this.emit('key', key, ev);
this.showCursor();
this.handler(key);
return true;
};
Terminal.prototype.send = function (data) {
var _this = this;
if (!this.sendDataQueue) {
setTimeout(function () {
_this.handler(_this.sendDataQueue);
_this.sendDataQueue = '';
}, 1);
}
this.sendDataQueue += data;
};
Terminal.prototype.bell = function () {
var _this = this;
this.emit('bell');
if (this.soundBell())
this.bellAudioElement.play();
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.width || !this.charMeasure.height) {
this.charMeasure.measure(this.options);
}
return;
}
if (x < 1)
x = 1;
if (y < 1)
y = 1;
this.buffers.resize(x, y);
this.cols = x;
this.rows = y;
this.buffers.setupTabStops(this.cols);
this.charMeasure.measure(this.options);
this.refresh(0, this.rows - 1);
this.emit('resize', { 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.eraseRight = function (x, y) {
var line = this.buffer.lines.get(this.buffer.ybase + y);
if (!line) {
return;
}
var ch = [this.eraseAttr(), ' ', 1, 32];
for (; x < this.cols; x++) {
line[x] = ch;
}
this.updateRange(y);
};
Terminal.prototype.eraseLeft = function (x, y) {
var line = this.buffer.lines.get(this.buffer.ybase + y);
if (!line) {
return;
}
var ch = [this.eraseAttr(), ' ', 1, 32];
x++;
while (x--) {
line[x] = ch;
}
this.updateRange(y);
};
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.blankLine());
}
this.refresh(0, this.rows - 1);
this.emit('scroll', this.buffer.ydisp);
};
Terminal.prototype.eraseLine = function (y) {
this.eraseRight(0, y);
};
Terminal.prototype.blankLine = function (cur, isWrapped, cols) {
var attr = cur ? this.eraseAttr() : this.defAttr;
var ch = [attr, ' ', 1, 32];
var line = [];
if (isWrapped) {
line.isWrapped = isWrapped;
}
cols = cols || this.cols;
for (var i = 0; i < cols; i++) {
line[i] = ch;
}
return line;
};
Terminal.prototype.ch = function (cur) {
if (cur) {
return [this.eraseAttr(), ' ', 1, 32];
}
return [this.defAttr, ' ', 1, 32];
};
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.emit('data', data);
};
Terminal.prototype.handleTitle = function (title) {
this.emit('title', 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.blankLine(true));
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 buffers = this.buffers;
this.setup();
this.customKeyEventHandler = customKeyEventHandler;
this.inputHandler = inputHandler;
this.buffers = buffers;
this.refresh(0, this.rows - 1);
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.matchColor = function (r1, g1, b1) {
return matchColor_(r1, g1, b1);
};
Terminal.prototype.visualBell = function () {
return this.options.bellStyle === 'visual' ||
this.options.bellStyle === 'both';
};
Terminal.prototype.soundBell = function () {
return this.options.bellStyle === 'sound' ||
this.options.bellStyle === 'both';
};
Terminal.prototype.syncBellSound = function () {
if (!this.element) {
return;
}
if (this.soundBell() && this.bellAudioElement) {
this.bellAudioElement.setAttribute('src', this.options.bellSound);
}
else if (this.soundBell()) {
this.bellAudioElement = document.createElement('audio');
this.bellAudioElement.setAttribute('preload', 'auto');
this.bellAudioElement.setAttribute('src', this.options.bellSound);
this.helperContainer.appendChild(this.bellAudioElement);
}
else if (this.bellAudioElement) {
this.helperContainer.removeChild(this.bellAudioElement);
}
};
return Terminal;
}(EventEmitter_1.EventEmitter));
exports.Terminal = Terminal;
function globalOn(el, type, handler, capture) {
if (!Array.isArray(el)) {
el = [el];
}
el.forEach(function (element) {
element.addEventListener(type, handler, capture || false);
});
}
var on = globalOn;
function off(el, type, handler, capture) {
if (capture === void 0) { capture = false; }
el.removeEventListener(type, handler, capture);
}
function isThirdLevelShift(browser, ev) {
var thirdLevelKey = (browser.isMac && 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);
}
function wasMondifierKeyOnlyEvent(ev) {
return ev.keyCode === 16 ||
ev.keyCode === 17 ||
ev.keyCode === 18;
}
var vcolors = (function () {
var result = ColorManager_1.DEFAULT_ANSI_COLORS.map(function (c) {
c = c.substring(1);
return [
parseInt(c.substring(0, 2), 16),
parseInt(c.substring(2, 4), 16),
parseInt(c.substring(4, 6), 16)
];
});
var r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
for (var i = 0; i < 216; i++) {
result.push([
r[(i / 36) % 6 | 0],
r[(i / 6) % 6 | 0],
r[i % 6]
]);
}
var c;
for (var i = 0; i < 24; i++) {
c = 8 + i * 10;
result.push([c, c, c]);
}
return result;
})();
var matchColorCache = {};
function matchColorDistance(r1, g1, b1, r2, g2, b2) {
return Math.pow(30 * (r1 - r2), 2)
+ Math.pow(59 * (g1 - g2), 2)
+ Math.pow(11 * (b1 - b2), 2);
}
;
function matchColor_(r1, g1, b1) {
var hash = (r1 << 16) | (g1 << 8) | b1;
if (matchColorCache[hash] != null) {
return matchColorCache[hash];
}
var ldiff = Infinity;
var li = -1;
var i = 0;
var c;
var r2;
var g2;
var b2;
var diff;
for (; i < vcolors.length; i++) {
c = vcolors[i];
r2 = c[0];
g2 = c[1];
b2 = c[2];
diff = matchColorDistance(r1, g1, b1, r2, g2, b2);
if (diff === 0) {
li = i;
break;
}
if (diff < ldiff) {
ldiff = diff;
li = i;
}
}
return matchColorCache[hash] = li;
}
},{"./Buffer":1,"./BufferSet":2,"./CompositionHelper":5,"./EscapeSequences":6,"./EventEmitter":7,"./InputHandler":8,"./Linkifier":9,"./Parser":10,"./SelectionManager":11,"./Viewport":15,"./handlers/Clipboard":16,"./input/MouseZoneManager":17,"./renderer/CharAtlas":19,"./renderer/ColorManager":20,"./renderer/Renderer":24,"./utils/Browser":28,"./utils/CharMeasure":29,"./utils/MouseHelper":32,"./utils/Sounds":33}],14:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LinkHoverEventTypes;
(function (LinkHoverEventTypes) {
LinkHoverEventTypes["HOVER"] = "linkhover";
LinkHoverEventTypes["TOOLTIP"] = "linktooltip";
LinkHoverEventTypes["LEAVE"] = "linkleave";
})(LinkHoverEventTypes = exports.LinkHoverEventTypes || (exports.LinkHoverEventTypes = {}));
;
},{}],15:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Viewport = (function () {
function Viewport(terminal, viewportElement, scrollArea, charMeasure) {
var _this = this;
this.terminal = terminal;
this.viewportElement = viewportElement;
this.scrollArea = scrollArea;
this.charMeasure = charMeasure;
this.currentRowHeight = 0;
this.lastRecordedBufferLength = 0;
this.lastRecordedViewportHeight = 0;
this.lastRecordedBufferHeight = 0;
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
setTimeout(function () { return _this.syncScrollArea(); }, 0);
}
Viewport.prototype.onThemeChanged = function (colors) {
this.viewportElement.style.backgroundColor = colors.background;
};
Viewport.prototype.refresh = function () {
if (this.charMeasure.height > 0) {
this.currentRowHeight = this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio;
if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {
this.lastRecordedViewportHeight = this.terminal.renderer.dimensions.canvasHeight;
this.viewportElement.style.height = this.lastRecordedViewportHeight + 'px';
}
var newBufferHeight = Math.round(this.currentRowHeight * this.lastRecordedBufferLength);
if (this.lastRecordedBufferHeight !== newBufferHeight) {
this.lastRecordedBufferHeight = newBufferHeight;
this.scrollArea.style.height = this.lastRecordedBufferHeight + 'px';
}
}
};
Viewport.prototype.syncScrollArea = function () {
if (this.lastRecordedBufferLength !== this.terminal.buffer.lines.length) {
this.lastRecordedBufferLength = this.terminal.buffer.lines.length;
this.refresh();
}
else if (this.lastRecordedViewportHeight !== this.terminal.renderer.dimensions.canvasHeight) {
this.refresh();
}
else {
if (this.terminal.renderer.dimensions.scaledCellHeight / window.devicePixelRatio !== this.currentRowHeight) {
this.refresh();
}
}
var scrollTop = this.terminal.buffer.ydisp * this.currentRowHeight;
if (this.viewportElement.scrollTop !== scrollTop) {
this.viewportElement.scrollTop = scrollTop;
}
};
Viewport.prototype.onScroll = function (ev) {
var newRow = Math.round(this.viewportElement.scrollTop / this.currentRowHeight);
var diff = newRow - this.terminal.buffer.ydisp;
this.terminal.scrollLines(diff, true);
};
Viewport.prototype.onWheel = function (ev) {
if (ev.deltaY === 0) {
return;
}
var multiplier = 1;
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
multiplier = this.currentRowHeight;
}
else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
multiplier = this.currentRowHeight * this.terminal.rows;
}
this.viewportElement.scrollTop += ev.deltaY * multiplier;
ev.preventDefault();
};
;
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;
}());
exports.Viewport = Viewport;
},{}],16:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function prepareTextForTerminal(text, isMSWindows) {
if (isMSWindows) {
return text.replace(/\r?\n/g, '\r');
}
return text;
}
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, term.browser.isMSWindows);
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, textarea) {
textarea.style.position = 'fixed';
textarea.style.width = '20px';
textarea.style.height = '20px';
textarea.style.left = (ev.clientX - 10) + 'px';
textarea.style.top = (ev.clientY - 10) + 'px';
textarea.style.zIndex = '1000';
textarea.focus();
setTimeout(function () {
textarea.style.position = null;
textarea.style.width = null;
textarea.style.height = null;
textarea.style.left = null;
textarea.style.top = null;
textarea.style.zIndex = null;
}, 4);
}
exports.moveTextAreaUnderMouseCursor = moveTextAreaUnderMouseCursor;
function rightClickHandler(ev, textarea, selectionManager) {
moveTextAreaUnderMouseCursor(ev, textarea);
textarea.value = selectionManager.selectionText;
textarea.select();
}
exports.rightClickHandler = rightClickHandler;
},{}],17:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var HOVER_DURATION = 500;
var MouseZoneManager = (function () {
function MouseZoneManager(_terminal) {
var _this = this;
this._terminal = _terminal;
this._zones = [];
this._areZonesActive = false;
this._tooltipTimeout = null;
this._currentZone = null;
this._lastHoverCoords = [null, null];
this._terminal.element.addEventListener('mousedown', function (e) { return _this._onMouseDown(e); });
this._mouseMoveListener = function (e) { return _this._onMouseMove(e); };
this._clickListener = function (e) { return _this._onClick(e); };
}
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.y > start && zone.y <= 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('click', this._clickListener);
}
};
MouseZoneManager.prototype._deactivate = function () {
if (this._areZonesActive) {
this._areZonesActive = false;
this._terminal.element.removeEventListener('mousemove', this._mouseMoveListener);
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) {
if (!this._areZonesActive) {
return;
}
var zone = this._findZoneEventAt(e);
if (zone) {
e.preventDefault();
e.stopImmediatePropagation();
}
};
MouseZoneManager.prototype._onClick = function (e) {
var zone = this._findZoneEventAt(e);
if (zone) {
zone.clickCallback(e);
e.preventDefault();
e.stopImmediatePropagation();
}
};
MouseZoneManager.prototype._findZoneEventAt = function (e) {
var coords = this._terminal.mouseHelper.getCoords(e, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);
if (!coords) {
return null;
}
for (var i = 0; i < this._zones.length; i++) {
var zone = this._zones[i];
if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {
return zone;
}
}
;
return null;
};
return MouseZoneManager;
}());
exports.MouseZoneManager = MouseZoneManager;
var MouseZone = (function () {
function MouseZone(x1, x2, y, clickCallback, hoverCallback, tooltipCallback, leaveCallback) {
this.x1 = x1;
this.x2 = x2;
this.y = y;
this.clickCallback = clickCallback;
this.hoverCallback = hoverCallback;
this.tooltipCallback = tooltipCallback;
this.leaveCallback = leaveCallback;
}
return MouseZone;
}());
exports.MouseZone = MouseZone;
},{}],18:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CharAtlas_1 = require("./CharAtlas");
var Buffer_1 = require("../Buffer");
exports.INVERTED_DEFAULT_COLOR = -1;
var DIM_OPACITY = 0.5;
var BaseRenderLayer = (function () {
function BaseRenderLayer(container, id, zIndex, _alpha, _colors) {
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._canvas = document.createElement('canvas');
this._canvas.id = "xterm-" + id + "-layer";
this._canvas.style.zIndex = zIndex.toString();
this._ctx = this._canvas.getContext('2d', { alpha: _alpha });
this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
if (!_alpha) {
this.clearAll();
}
container.appendChild(this._canvas);
}
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) { };
BaseRenderLayer.prototype.onThemeChanged = function (terminal, colorSet) {
this._refreshCharAtlas(terminal, colorSet);
};
BaseRenderLayer.prototype._refreshCharAtlas = function (terminal, colorSet) {
var _this = this;
if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {
return;
}
this._charAtlas = null;
var result = CharAtlas_1.acquireCharAtlas(terminal, this._colors, this._scaledCharWidth, this._scaledCharHeight);
if (result instanceof HTMLCanvasElement) {
this._charAtlas = result;
}
else {
result.then(function (bitmap) { return _this._charAtlas = bitmap; });
}
};
BaseRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
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();
}
if (charSizeChanged) {
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;
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;
this._ctx.fillRect(x * this._scaledCellWidth, y * this._scaledCellHeight, width * this._scaledCellWidth, height * this._scaledCellHeight);
}
};
BaseRenderLayer.prototype.fillCharTrueColor = function (terminal, charData, x, y) {
this._ctx.font = terminal.options.fontSize * window.devicePixelRatio + "px " + terminal.options.fontFamily;
this._ctx.textBaseline = 'top';
this._clipRow(terminal, y);
this._ctx.fillText(charData[Buffer_1.CHAR_DATA_CHAR_INDEX], x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);
};
BaseRenderLayer.prototype.drawChar = function (terminal, char, code, width, x, y, fg, bg, bold, dim) {
var colorIndex = 0;
if (fg < 256) {
colorIndex = fg + 2;
}
else {
if (bold && terminal.options.enableBold) {
colorIndex = 1;
}
}
var isAscii = code < 256;
var isBasicColor = (colorIndex > 1 && fg < 16) && (fg < 8 || bold);
var isDefaultColor = fg >= 256;
var isDefaultBackground = bg >= 256;
if (this._charAtlas && isAscii && (isBasicColor || isDefaultColor) && isDefaultBackground) {
var charAtlasCellWidth = this._scaledCharWidth + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;
var charAtlasCellHeight = this._scaledCharHeight + CharAtlas_1.CHAR_ATLAS_CELL_SPACING;
if (dim) {
this._ctx.globalAlpha = DIM_OPACITY;
}
if (bold && !terminal.options.enableBold) {
if (colorIndex > 1) {
colorIndex -= 8;
}
}
this._ctx.drawImage(this._charAtlas, code * charAtlasCellWidth, colorIndex * charAtlasCellHeight, charAtlasCellWidth, this._scaledCharHeight, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop, charAtlasCellWidth, this._scaledCharHeight);
}
else {
this._drawUncachedChar(terminal, char, width, fg, x, y, bold, dim);
}
};
BaseRenderLayer.prototype._drawUncachedChar = function (terminal, char, width, fg, x, y, bold, dim) {
this._ctx.save();
this._ctx.font = terminal.options.fontSize * window.devicePixelRatio + "px " + terminal.options.fontFamily;
if (bold && terminal.options.enableBold) {
this._ctx.font = "bold " + this._ctx.font;
}
this._ctx.textBaseline = 'top';
if (fg === exports.INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background;
}
else if (fg < 256) {
this._ctx.fillStyle = this._colors.ansi[fg];
}
else {
this._ctx.fillStyle = this._colors.foreground;
}
this._clipRow(terminal, y);
if (dim) {
this._ctx.globalAlpha = DIM_OPACITY;
}
this._ctx.fillText(char, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);
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();
};
return BaseRenderLayer;
}());
exports.BaseRenderLayer = BaseRenderLayer;
},{"../Buffer":1,"./CharAtlas":19}],19:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Browser_1 = require("../utils/Browser");
exports.CHAR_ATLAS_CELL_SPACING = 1;
var charAtlasCache = [];
function acquireCharAtlas(terminal, colors, scaledCharWidth, scaledCharHeight) {
var newConfig = 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 (configEquals(entry.config, newConfig)) {
return entry.bitmap;
}
else {
if (entry.ownedBy.length === 1) {
charAtlasCache.splice(i, 1);
}
else {
entry.ownedBy.splice(ownedByIndex, 1);
}
break;
}
}
}
for (var i = 0; i < charAtlasCache.length; i++) {
var entry = charAtlasCache[i];
if (configEquals(entry.config, newConfig)) {
entry.ownedBy.push(terminal);
return entry.bitmap;
}
}
var newEntry = {
bitmap: generator.generate(scaledCharWidth, scaledCharHeight, terminal.options.fontSize, terminal.options.fontFamily, colors.background, colors.foreground, colors.ansi),
config: newConfig,
ownedBy: [terminal]
};
charAtlasCache.push(newEntry);
return newEntry.bitmap;
}
exports.acquireCharAtlas = acquireCharAtlas;
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 {
scaledCharWidth: scaledCharWidth,
scaledCharHeight: scaledCharHeight,
fontFamily: terminal.options.fontFamily,
fontSize: terminal.options.fontSize,
colors: clonedColors
};
}
function configEquals(a, b) {
for (var i = 0; i < a.colors.ansi.length; i++) {
if (a.colors.ansi[i] !== b.colors.ansi[i]) {
return false;
}
}
return a.fontFamily === b.fontFamily &&
a.fontSize === b.fontSize &&
a.scaledCharWidth === b.scaledCharWidth &&
a.scaledCharHeight === b.scaledCharHeight &&
a.colors.foreground === b.colors.foreground &&
a.colors.background === b.colors.background;
}
var generator;
function initialize(document) {
if (!generator) {
generator = new CharAtlasGenerator(document);
}
}
exports.initialize = initialize;
var CharAtlasGenerator = (function () {
function CharAtlasGenerator(_document) {
this._document = _document;
this._canvas = this._document.createElement('canvas');
this._ctx = this._canvas.getContext('2d', { alpha: false });
this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
}
CharAtlasGenerator.prototype.generate = function (scaledCharWidth, scaledCharHeight, fontSize, fontFamily, background, foreground, ansiColors) {
var cellWidth = scaledCharWidth + exports.CHAR_ATLAS_CELL_SPACING;
var cellHeight = scaledCharHeight + exports.CHAR_ATLAS_CELL_SPACING;
this._canvas.width = 255 * cellWidth;
this._canvas.height = (2 + 16) * cellHeight;
this._ctx.fillStyle = background;
this._ctx.fillRect(0, 0, this._canvas.width, this._canvas.height);
this._ctx.save();
this._ctx.fillStyle = foreground;
this._ctx.font = fontSize * window.devicePixelRatio + "px " + fontFamily;
this._ctx.textBaseline = 'top';
for (var i = 0; i < 256; i++) {
this._ctx.save();
this._ctx.beginPath();
this._ctx.rect(i * cellWidth, 0, cellWidth, cellHeight);
this._ctx.clip();
this._ctx.fillText(String.fromCharCode(i), i * cellWidth, 0);
this._ctx.restore();
}
this._ctx.save();
this._ctx.font = "bold " + this._ctx.font;
for (var i = 0; i < 256; i++) {
this._ctx.save();
this._ctx.beginPath();
this._ctx.rect(i * cellWidth, cellHeight, cellWidth, cellHeight);
this._ctx.clip();
this._ctx.fillText(String.fromCharCode(i), i * cellWidth, cellHeight);
this._ctx.restore();
}
this._ctx.restore();
this._ctx.font = fontSize * window.devicePixelRatio + "px " + fontFamily;
for (var colorIndex = 0; colorIndex < 16; colorIndex++) {
if (colorIndex === 8) {
this._ctx.font = "bold " + this._ctx.font;
}
var y = (colorIndex + 2) * cellHeight;
for (var i = 0; i < 256; i++) {
this._ctx.save();
this._ctx.beginPath();
this._ctx.rect(i * cellWidth, y, cellWidth, cellHeight);
this._ctx.clip();
this._ctx.fillStyle = ansiColors[colorIndex];
this._ctx.fillText(String.fromCharCode(i), i * cellWidth, y);
this._ctx.restore();
}
}
this._ctx.restore();
if (!('createImageBitmap' in window) || Browser_1.isFirefox) {
var result = this._canvas;
this._canvas = this._document.createElement('canvas');
this._ctx = this._canvas.getContext('2d');
this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
return result;
}
var charAtlasImageData = this._ctx.getImageData(0, 0, this._canvas.width, this._canvas.height);
var r = parseInt(background.substr(1, 2), 16);
var g = parseInt(background.substr(3, 2), 16);
var b = parseInt(background.substr(5, 2), 16);
this._clearColor(charAtlasImageData, r, g, b);
var promise = window.createImageBitmap(charAtlasImageData);
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
return promise;
};
CharAtlasGenerator.prototype._clearColor = function (imageData, r, g, b) {
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;
}
}
};
return CharAtlasGenerator;
}());
},{"../utils/Browser":28}],20:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DEFAULT_FOREGROUND = '#ffffff';
var DEFAULT_BACKGROUND = '#000000';
var DEFAULT_CURSOR = '#ffffff';
var DEFAULT_CURSOR_ACCENT = '#000000';
var DEFAULT_SELECTION = 'rgba(255, 255, 255, 0.3)';
exports.DEFAULT_ANSI_COLORS = [
'#2e3436',
'#cc0000',
'#4e9a06',
'#c4a000',
'#3465a4',
'#75507b',
'#06989a',
'#d3d7cf',
'#555753',
'#ef2929',
'#8ae234',
'#fce94f',
'#729fcf',
'#ad7fa8',
'#34e2e2',
'#eeeeec'
];
function generate256Colors(first16Colors) {
var colors = first16Colors.slice();
var v = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
for (var i = 0; i < 216; i++) {
var r = toPaddedHex(v[(i / 36) % 6 | 0]);
var g = toPaddedHex(v[(i / 6) % 6 | 0]);
var b = toPaddedHex(v[i % 6]);
colors.push("#" + r + g + b);
}
for (var i = 0; i < 24; i++) {
var c = toPaddedHex(8 + i * 10);
colors.push("#" + c + c + c);
}
return colors;
}
function toPaddedHex(c) {
var s = c.toString(16);
return s.length < 2 ? '0' + s : s;
}
var ColorManager = (function () {
function ColorManager() {
this.colors = {
foreground: DEFAULT_FOREGROUND,
background: DEFAULT_BACKGROUND,
cursor: DEFAULT_CURSOR,
cursorAccent: DEFAULT_CURSOR_ACCENT,
selection: DEFAULT_SELECTION,
ansi: generate256Colors(exports.DEFAULT_ANSI_COLORS)
};
}
ColorManager.prototype.setTheme = function (theme) {
this.colors.foreground = theme.foreground || DEFAULT_FOREGROUND;
this.colors.background = this._validateColor(theme.background, DEFAULT_BACKGROUND);
this.colors.cursor = theme.cursor || DEFAULT_CURSOR;
this.colors.cursorAccent = theme.cursorAccent || DEFAULT_CURSOR_ACCENT;
this.colors.selection = theme.selection || DEFAULT_SELECTION;
this.colors.ansi[0] = theme.black || exports.DEFAULT_ANSI_COLORS[0];
this.colors.ansi[1] = theme.red || exports.DEFAULT_ANSI_COLORS[1];
this.colors.ansi[2] = theme.green || exports.DEFAULT_ANSI_COLORS[2];
this.colors.ansi[3] = theme.yellow || exports.DEFAULT_ANSI_COLORS[3];
this.colors.ansi[4] = theme.blue || exports.DEFAULT_ANSI_COLORS[4];
this.colors.ansi[5] = theme.magenta || exports.DEFAULT_ANSI_COLORS[5];
this.colors.ansi[6] = theme.cyan || exports.DEFAULT_ANSI_COLORS[6];
this.colors.ansi[7] = theme.white || exports.DEFAULT_ANSI_COLORS[7];
this.colors.ansi[8] = theme.brightBlack || exports.DEFAULT_ANSI_COLORS[8];
this.colors.ansi[9] = theme.brightRed || exports.DEFAULT_ANSI_COLORS[9];
this.colors.ansi[10] = theme.brightGreen || exports.DEFAULT_ANSI_COLORS[10];
this.colors.ansi[11] = theme.brightYellow || exports.DEFAULT_ANSI_COLORS[11];
this.colors.ansi[12] = theme.brightBlue || exports.DEFAULT_ANSI_COLORS[12];
this.colors.ansi[13] = theme.brightMagenta || exports.DEFAULT_ANSI_COLORS[13];
this.colors.ansi[14] = theme.brightCyan || exports.DEFAULT_ANSI_COLORS[14];
this.colors.ansi[15] = theme.brightWhite || exports.DEFAULT_ANSI_COLORS[15];
};
ColorManager.prototype._validateColor = function (color, fallback) {
if (!color) {
return fallback;
}
if (color.length === 7 && color.charAt(0) === '#') {
return color;
}
if (color.length === 4 && color.charAt(0) === '#') {
var r = color.charAt(1);
var g = color.charAt(2);
var b = color.charAt(3);
return "#" + r + r + g + g + b + b;
}
return fallback;
};
return ColorManager;
}());
exports.ColorManager = ColorManager;
},{}],21:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 BaseRenderLayer_1 = require("./BaseRenderLayer");
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._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, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
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);
}
};
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;
}
var charData = terminal.buffer.lines.get(cursorY)[terminal.buffer.x];
if (!charData) {
return;
}
if (!terminal.isFocused) {
this._clearCursor();
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this._renderBlurCursor(terminal, terminal.buffer.x, viewportRelativeCursorY, charData);
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 = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];
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 === charData[Buffer_1.CHAR_DATA_WIDTH_INDEX]) {
return;
}
this._clearCursor();
}
this._ctx.save();
this._cursorRenderers[terminal.options.cursorStyle || 'block'](terminal, terminal.buffer.x, viewportRelativeCursorY, charData);
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 = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];
};
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, charData) {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this.fillLeftLineAtCell(x, y);
this._ctx.restore();
};
CursorRenderLayer.prototype._renderBlockCursor = function (terminal, x, y, charData) {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this.fillCells(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 1);
this._ctx.fillStyle = this._colors.cursorAccent;
this.fillCharTrueColor(terminal, charData, x, y);
this._ctx.restore();
};
CursorRenderLayer.prototype._renderUnderlineCursor = function (terminal, x, y, charData) {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor;
this.fillBottomLineAtCells(x, y);
this._ctx.restore();
};
CursorRenderLayer.prototype._renderBlurCursor = function (terminal, x, y, charData) {
this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor;
this.strokeRectAtCell(x, y, charData[Buffer_1.CHAR_DATA_WIDTH_INDEX], 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;
}());
},{"../Buffer":1,"./BaseRenderLayer":18}],22:[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;
},{}],23:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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("../Types");
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.on(Types_1.LinkHoverEventTypes.HOVER, function (e) { return _this._onLinkHover(e); });
terminal.linkifier.on(Types_1.LinkHoverEventTypes.LEAVE, function (e) { return _this._onLinkLeave(e); });
return _this;
}
LinkRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
this._state = null;
};
LinkRenderLayer.prototype.reset = function (terminal) {
this._clearCurrentLink();
};
LinkRenderLayer.prototype._clearCurrentLink = function () {
if (this._state) {
this.clearCells(this._state.x, this._state.y, this._state.length, 1);
this._state = null;
}
};
LinkRenderLayer.prototype._onLinkHover = function (e) {
this._ctx.fillStyle = this._colors.foreground;
this.fillBottomLineAtCells(e.x, e.y, e.length);
this._state = e;
};
LinkRenderLayer.prototype._onLinkLeave = function (e) {
this._clearCurrentLink();
};
return LinkRenderLayer;
}(BaseRenderLayer_1.BaseRenderLayer));
exports.LinkRenderLayer = LinkRenderLayer;
},{"../Types":14,"./BaseRenderLayer":18}],24:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 EventEmitter_1 = require("../EventEmitter");
var Renderer = (function (_super) {
__extends(Renderer, _super);
function Renderer(_terminal, theme) {
var _this = _super.call(this) || this;
_this._terminal = _terminal;
_this._refreshRowsQueue = [];
_this._refreshAnimationFrame = null;
_this.colorManager = new ColorManager_1.ColorManager();
if (theme) {
_this.colorManager.setTheme(theme);
}
_this._renderLayers = [
new TextRenderLayer_1.TextRenderLayer(_this._terminal.element, 0, _this.colorManager.colors),
new SelectionRenderLayer_1.SelectionRenderLayer(_this._terminal.element, 1, _this.colorManager.colors),
new LinkRenderLayer_1.LinkRenderLayer(_this._terminal.element, 2, _this.colorManager.colors, _this._terminal),
new CursorRenderLayer_1.CursorRenderLayer(_this._terminal.element, 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();
return _this;
}
Renderer.prototype.onWindowResize = function (devicePixelRatio) {
if (this._devicePixelRatio !== devicePixelRatio) {
this._devicePixelRatio = devicePixelRatio;
this.onResize(this._terminal.cols, this._terminal.rows, true);
}
};
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);
});
this._terminal.refresh(0, this._terminal.rows - 1);
return this.colorManager.colors;
};
Renderer.prototype.onResize = function (cols, rows, didCharSizeChange) {
var _this = this;
this._updateDimensions();
this._renderLayers.forEach(function (l) { return l.resize(_this._terminal, _this.dimensions, didCharSizeChange); });
this._terminal.refresh(0, this._terminal.rows - 1);
this.emit('resize', {
width: this.dimensions.canvasWidth,
height: this.dimensions.canvasHeight
});
};
Renderer.prototype.onCharSizeChanged = function () {
this.onResize(this._terminal.cols, this._terminal.rows, true);
};
Renderer.prototype.onBlur = function () {
var _this = this;
this._renderLayers.forEach(function (l) { return l.onBlur(_this._terminal); });
};
Renderer.prototype.onFocus = function () {
var _this = this;
this._renderLayers.forEach(function (l) { return l.onFocus(_this._terminal); });
};
Renderer.prototype.onSelectionChanged = function (start, end) {
var _this = this;
this._renderLayers.forEach(function (l) { return l.onSelectionChanged(_this._terminal, start, end); });
};
Renderer.prototype.onCursorMove = function () {
var _this = this;
this._renderLayers.forEach(function (l) { return l.onCursorMove(_this._terminal); });
};
Renderer.prototype.onOptionsChanged = function () {
var _this = this;
this._renderLayers.forEach(function (l) { return l.onOptionsChanged(_this._terminal); });
};
Renderer.prototype.clear = function () {
var _this = this;
this._renderLayers.forEach(function (l) { return l.reset(_this._terminal); });
};
Renderer.prototype.queueRefresh = function (start, end) {
this._refreshRowsQueue.push({ start: start, end: end });
if (!this._refreshAnimationFrame) {
this._refreshAnimationFrame = window.requestAnimationFrame(this._refreshLoop.bind(this));
}
};
Renderer.prototype._refreshLoop = function () {
var _this = this;
var start;
var end;
if (this._refreshRowsQueue.length > 4) {
start = 0;
end = this._terminal.rows - 1;
}
else {
start = this._refreshRowsQueue[0].start;
end = this._refreshRowsQueue[0].end;
for (var i = 1; i < this._refreshRowsQueue.length; i++) {
if (this._refreshRowsQueue[i].start < start) {
start = this._refreshRowsQueue[i].start;
}
if (this._refreshRowsQueue[i].end > end) {
end = this._refreshRowsQueue[i].end;
}
}
}
this._refreshRowsQueue = [];
this._refreshAnimationFrame = null;
start = Math.max(start, 0);
end = Math.min(end, this._terminal.rows - 1);
this._renderLayers.forEach(function (l) { return l.onGridChanged(_this._terminal, start, end); });
this._terminal.emit('refresh', { 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;
};
return Renderer;
}(EventEmitter_1.EventEmitter));
exports.Renderer = Renderer;
},{"../EventEmitter":7,"./ColorManager":20,"./CursorRenderLayer":21,"./LinkRenderLayer":23,"./SelectionRenderLayer":25,"./TextRenderLayer":26}],25:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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._state = {
start: null,
end: null
};
return _this;
}
SelectionRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
this._state = {
start: null,
end: null
};
};
SelectionRenderLayer.prototype.reset = function (terminal) {
if (this._state.start && this._state.end) {
this._state = {
start: null,
end: null
};
this.clearAll();
}
};
SelectionRenderLayer.prototype.onSelectionChanged = function (terminal, start, end) {
if (this._state.start === start || this._state.end === end) {
return;
}
this.clearAll();
if (!start || !end) {
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;
}
var startCol = viewportStartRow === viewportCappedStartRow ? start[0] : 0;
var startRowEndCol = viewportCappedStartRow === viewportCappedEndRow ? end[0] : terminal.cols;
this._ctx.fillStyle = this._colors.selection;
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]];
};
return SelectionRenderLayer;
}(BaseRenderLayer_1.BaseRenderLayer));
exports.SelectionRenderLayer = SelectionRenderLayer;
},{"./BaseRenderLayer":18}],26:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 Types_1 = require("./Types");
var GridCache_1 = require("./GridCache");
var BaseRenderLayer_1 = require("./BaseRenderLayer");
var OVERLAP_OWNED_CHAR_DATA = [null, '', 0, -1];
var TextRenderLayer = (function (_super) {
__extends(TextRenderLayer, _super);
function TextRenderLayer(container, zIndex, colors) {
var _this = _super.call(this, container, 'text', zIndex, false, colors) || this;
_this._characterOverlapCache = {};
_this._state = new GridCache_1.GridCache();
return _this;
}
TextRenderLayer.prototype.resize = function (terminal, dim, charSizeChanged) {
_super.prototype.resize.call(this, terminal, dim, charSizeChanged);
var terminalFont = terminal.options.fontSize * window.devicePixelRatio + "px " + terminal.options.fontFamily;
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.onGridChanged = function (terminal, startRow, endRow) {
if (this._state.cache.length === 0) {
return;
}
for (var y = startRow; y <= endRow; y++) {
var row = y + terminal.buffer.ydisp;
var line = terminal.buffer.lines.get(row);
this.clearCells(0, y, terminal.cols, 1);
for (var x = 0; x < terminal.cols; x++) {
var charData = line[x];
var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];
var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];
var attr = charData[Buffer_1.CHAR_DATA_ATTR_INDEX];
var width = charData[Buffer_1.CHAR_DATA_WIDTH_INDEX];
if (width === 0) {
continue;
}
if (code === 32) {
if (x > 0) {
var previousChar = line[x - 1];
if (this._isOverlapping(previousChar)) {
continue;
}
}
}
var flags = attr >> 18;
var bg = attr & 0x1ff;
var isDefaultBackground = bg >= 256;
var isInvisible = flags & Types_1.FLAGS.INVISIBLE;
var isInverted = flags & Types_1.FLAGS.INVERSE;
if (!code || (code === 32 && isDefaultBackground && !isInverted) || isInvisible) {
continue;
}
if (width !== 0 && this._isOverlapping(charData)) {
if (x < line.length - 1 && line[x + 1][Buffer_1.CHAR_DATA_CODE_INDEX] === 32) {
width = 2;
}
}
var fg = (attr >> 9) & 0x1ff;
if (isInverted) {
var temp = bg;
bg = fg;
fg = temp;
if (fg === 256) {
fg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;
}
if (bg === 257) {
bg = BaseRenderLayer_1.INVERTED_DEFAULT_COLOR;
}
}
if (width === 2) {
}
if (bg < 256) {
this._ctx.save();
this._ctx.fillStyle = (bg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR ? this._colors.foreground : this._colors.ansi[bg]);
this.fillCells(x, y, width, 1);
this._ctx.restore();
}
this._ctx.save();
if (flags & Types_1.FLAGS.BOLD) {
this._ctx.font = "bold " + this._ctx.font;
if (fg < 8) {
fg += 8;
}
}
if (flags & Types_1.FLAGS.UNDERLINE) {
if (fg === BaseRenderLayer_1.INVERTED_DEFAULT_COLOR) {
this._ctx.fillStyle = this._colors.background;
}
else if (fg < 256) {
this._ctx.fillStyle = this._colors.ansi[fg];
}
else {
this._ctx.fillStyle = this._colors.foreground;
}
this.fillBottomLineAtCells(x, y);
}
this.drawChar(terminal, char, code, width, x, y, fg, bg, !!(flags & Types_1.FLAGS.BOLD), !!(flags & Types_1.FLAGS.DIM));
this._ctx.restore();
}
}
};
TextRenderLayer.prototype._isOverlapping = function (charData) {
if (charData[Buffer_1.CHAR_DATA_WIDTH_INDEX] !== 1) {
return false;
}
var code = charData[Buffer_1.CHAR_DATA_CODE_INDEX];
if (code < 256) {
return false;
}
var char = charData[Buffer_1.CHAR_DATA_CHAR_INDEX];
if (this._characterOverlapCache.hasOwnProperty(char)) {
return this._characterOverlapCache[char];
}
this._ctx.save();
this._ctx.font = this._characterFont;
var overlaps = Math.floor(this._ctx.measureText(char).width) > this._characterWidth;
this._ctx.restore();
this._characterOverlapCache[char] = overlaps;
return overlaps;
};
TextRenderLayer.prototype._clearChar = function (x, y) {
var colsToClear = 1;
var state = this._state.cache[x][y];
if (state && state[Buffer_1.CHAR_DATA_WIDTH_INDEX] === 2) {
colsToClear = 2;
}
this.clearCells(x, y, colsToClear, 1);
};
return TextRenderLayer;
}(BaseRenderLayer_1.BaseRenderLayer));
exports.TextRenderLayer = TextRenderLayer;
},{"../Buffer":1,"./BaseRenderLayer":18,"./GridCache":22,"./Types":27}],27:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FLAGS;
(function (FLAGS) {
FLAGS[FLAGS["BOLD"] = 1] = "BOLD";
FLAGS[FLAGS["UNDERLINE"] = 2] = "UNDERLINE";
FLAGS[FLAGS["BLINK"] = 4] = "BLINK";
FLAGS[FLAGS["INVERSE"] = 8] = "INVERSE";
FLAGS[FLAGS["INVISIBLE"] = 16] = "INVISIBLE";
FLAGS[FLAGS["DIM"] = 32] = "DIM";
})(FLAGS = exports.FLAGS || (exports.FLAGS = {}));
;
},{}],28:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Generic_1 = require("./Generic");
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.isMSIE = !!~userAgent.indexOf('MSIE') || !!~userAgent.indexOf('Trident');
exports.isMac = Generic_1.contains(['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], platform);
exports.isIpad = platform === 'iPad';
exports.isIphone = platform === 'iPhone';
exports.isMSWindows = Generic_1.contains(['Windows', 'Win16', 'Win32', 'WinCE'], platform);
exports.isLinux = platform.indexOf('Linux') >= 0;
},{"./Generic":31}],29:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 EventEmitter_1 = require("../EventEmitter");
var CharMeasure = (function (_super) {
__extends(CharMeasure, _super);
function CharMeasure(document, parentElement) {
var _this = _super.call(this) || this;
_this._document = document;
_this._parentElement = parentElement;
_this._measureElement = _this._document.createElement('span');
_this._measureElement.style.position = 'absolute';
_this._measureElement.style.top = '0';
_this._measureElement.style.left = '-9999em';
_this._measureElement.style.lineHeight = 'normal';
_this._measureElement.textContent = 'W';
_this._measureElement.setAttribute('aria-hidden', 'true');
_this._parentElement.appendChild(_this._measureElement);
return _this;
}
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;
}
if (this._width !== geometry.width || this._height !== geometry.height) {
this._width = geometry.width;
this._height = Math.ceil(geometry.height);
this.emit('charsizechanged');
}
};
return CharMeasure;
}(EventEmitter_1.EventEmitter));
exports.CharMeasure = CharMeasure;
},{"../EventEmitter":7}],30:[function(require,module,exports){
"use strict";
var __extends = (this && this.__extends) || (function () {
var 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 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 EventEmitter_1 = require("../EventEmitter");
var CircularList = (function (_super) {
__extends(CircularList, _super);
function CircularList(_maxLength) {
var _this = _super.call(this) || this;
_this._maxLength = _maxLength;
_this._array = new Array(_this._maxLength);
_this._startIndex = 0;
_this._length = 0;
return _this;
}
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
});
Object.defineProperty(CircularList.prototype, "forEach", {
get: function () {
var _this = this;
return function (callbackfn) {
var i = 0;
var length = _this.length;
for (var i_1 = 0; i_1 < length; i_1++) {
callbackfn(_this.get(i_1), i_1);
}
};
},
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++;
if (this._startIndex === this._maxLength) {
this._startIndex = 0;
}
this.emit('trim', 1);
}
else {
this._length++;
}
};
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;
}
if (items && items.length) {
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.emit('trim', 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.emit('trim', 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.emit('trim', 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;
}(EventEmitter_1.EventEmitter));
exports.CircularList = CircularList;
},{"../EventEmitter":7}],31:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function contains(arr, el) {
return arr.indexOf(el) >= 0;
}
exports.contains = contains;
;
},{}],32:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MouseHelper = (function () {
function MouseHelper(_renderer) {
this._renderer = _renderer;
}
MouseHelper.getCoordsRelativeToElement = function (event, element) {
if (event.pageX == null) {
return null;
}
var originalElement = element;
var x = event.pageX;
var y = event.pageY;
while (element) {
x -= element.offsetLeft;
y -= element.offsetTop;
element = 'offsetParent' in element ? element.offsetParent : element.parentElement;
}
element = originalElement;
while (element && element !== element.ownerDocument.body) {
x += element.scrollLeft;
y += element.scrollTop;
element = element.parentElement;
}
return [x, y];
};
MouseHelper.prototype.getCoords = function (event, element, charMeasure, lineHeight, 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, lineHeight, colCount, rowCount) {
var coords = this.getCoords(event, element, charMeasure, lineHeight, colCount, rowCount);
var x = coords[0];
var y = coords[1];
x += 32;
y += 32;
return { x: x, y: y };
};
return MouseHelper;
}());
exports.MouseHelper = MouseHelper;
},{}],33:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BellSound = 'data:audio/wav;base64,UklGRigBAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQBAADpAFgCwAMlBZoG/wdmCcoKRAypDQ8PbRDBEQQTOxRtFYcWlBePGIUZXhoiG88bcBz7HHIdzh0WHlMeZx51HmkeUx4WHs8dah0AHXwc3hs9G4saxRnyGBIYGBcQFv8U4RPAEoYRQBACD70NWwwHC6gJOwjWBloF7gOBAhABkf8b/qv8R/ve+Xf4Ife79W/0JfPZ8Z/wde9N7ijtE+wU6xvqM+lb6H7nw+YX5mrlxuQz5Mzje+Ma49fioeKD4nXiYeJy4pHitOL04j/jn+MN5IPkFOWs5U3mDefM55/ogOl36m7rdOyE7abuyu8D8Unyj/Pg9D/2qfcb+Yn6/vuK/Qj/lAAlAg==';
},{}],34:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Terminal_1 = require("./Terminal");
module.exports = Terminal_1.Terminal;
},{"./Terminal":13}]},{},[34])(34)
});
//# sourceMappingURL=xterm.js.map
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
var require;var require;(function(f){if(true){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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return require(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({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')) - 17);
var elementStyle = window.getComputedStyle(term.element);
var elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom'));
var elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left'));
var availableHeight = parentElementHeight - elementPaddingVer;
var availableWidth = parentElementWidth - elementPaddingHor;
var geometry = {
cols: Math.floor(availableWidth / term.renderer.dimensions.actualCellWidth),
rows: Math.floor(availableHeight / term.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.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 () {
return fit(this);
};
}
exports.apply = apply;
},{}]},{},[1])(1)
});
//# sourceMappingURL=fit.js.map
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/* unused harmony export config */
/* unused harmony export icon */
/* unused harmony export noAuto */
/* unused harmony export layer */
/* unused harmony export text */
/* unused harmony export library */
/* unused harmony export dom */
/* unused harmony export parse */
/* unused harmony export findIconDefinition */
/*!
* Font Awesome Free 5.0.5 by @fontawesome - http://fontawesome.com
* License - http://fontawesome.com/license (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/
var noop = function noop() {};
var _WINDOW = {};
var _DOCUMENT = {};
var _MUTATION_OBSERVER$1 = null;
var _PERFORMANCE = { mark: noop, measure: noop };
try {
if (typeof window !== 'undefined') _WINDOW = window;
if (typeof document !== 'undefined') _DOCUMENT = document;
if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER$1 = MutationObserver;
if (typeof performance !== 'undefined') _PERFORMANCE = performance;
} catch (e) {}
var _ref = _WINDOW.navigator || {};
var _ref$userAgent = _ref.userAgent;
var userAgent = _ref$userAgent === undefined ? '' : _ref$userAgent;
var WINDOW = _WINDOW;
var DOCUMENT = _DOCUMENT;
var MUTATION_OBSERVER = _MUTATION_OBSERVER$1;
var PERFORMANCE = _PERFORMANCE;
var IS_BROWSER = !!WINDOW.document;
var IS_DOM = !!DOCUMENT.documentElement && !!DOCUMENT.head && typeof DOCUMENT.addEventListener === 'function' && typeof DOCUMENT.createElement === 'function';
var IS_IE = ~userAgent.indexOf('MSIE') || ~userAgent.indexOf('Trident/');
var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
var UNITS_IN_GRID = 16;
var DEFAULT_FAMILY_PREFIX = 'fa';
var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
var DATA_FA_I2SVG = 'data-fa-i2svg';
var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
var PRODUCTION = function () {
try {
return process.env.NODE_ENV === 'production';
} catch (e) {
return false;
}
}();
var oneToTen = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var oneToTwenty = oneToTen.concat([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
var ATTRIBUTES_WATCHED_FOR_MUTATION = ['class', 'data-prefix', 'data-icon', 'data-fa-transform', 'data-fa-mask'];
var RESERVED_CLASSES = ['xs', 'sm', 'lg', 'fw', 'ul', 'li', 'border', 'pull-left', 'pull-right', 'spin', 'pulse', 'rotate-90', 'rotate-180', 'rotate-270', 'flip-horizontal', 'flip-vertical', 'stack', 'stack-1x', 'stack-2x', 'inverse', 'layers', 'layers-text', 'layers-counter'].concat(oneToTen.map(function (n) {
return n + 'x';
})).concat(oneToTwenty.map(function (n) {
return 'w-' + n;
}));
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
var initial = WINDOW.FontAwesomeConfig || {};
var initialKeys = Object.keys(initial);
var _default = _extends({
familyPrefix: DEFAULT_FAMILY_PREFIX,
replacementClass: DEFAULT_REPLACEMENT_CLASS,
autoReplaceSvg: true,
autoAddCss: true,
autoA11y: true,
searchPseudoElements: false,
observeMutations: true,
keepOriginalSource: true,
measurePerformance: false,
showMissingIcons: true
}, initial);
if (!_default.autoReplaceSvg) _default.observeMutations = false;
var config$1 = _extends({}, _default);
WINDOW.FontAwesomeConfig = config$1;
function update(newConfig) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _params$asNewDefault = params.asNewDefault,
asNewDefault = _params$asNewDefault === undefined ? false : _params$asNewDefault;
var validKeys = Object.keys(config$1);
var ok = asNewDefault ? function (k) {
return ~validKeys.indexOf(k) && !~initialKeys.indexOf(k);
} : function (k) {
return ~validKeys.indexOf(k);
};
Object.keys(newConfig).forEach(function (configKey) {
if (ok(configKey)) config$1[configKey] = newConfig[configKey];
});
}
function auto(value) {
update({
autoReplaceSvg: value,
observeMutations: value
});
}
var w = WINDOW || {};
if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
if (!w[NAMESPACE_IDENTIFIER].styles) w[NAMESPACE_IDENTIFIER].styles = {};
if (!w[NAMESPACE_IDENTIFIER].hooks) w[NAMESPACE_IDENTIFIER].hooks = {};
if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
var namespace = w[NAMESPACE_IDENTIFIER];
var functions = [];
var listener = function listener() {
DOCUMENT.removeEventListener('DOMContentLoaded', listener);
loaded = 1;
functions.map(function (fn) {
return fn();
});
};
var loaded = false;
if (IS_DOM) {
loaded = (DOCUMENT.documentElement.doScroll ? /^loaded|^c/ : /^loaded|^i|^c/).test(DOCUMENT.readyState);
if (!loaded) DOCUMENT.addEventListener('DOMContentLoaded', listener);
}
var domready = function (fn) {
if (!IS_DOM) return;
loaded ? setTimeout(fn, 0) : functions.push(fn);
};
var d = UNITS_IN_GRID;
var meaninglessTransform = {
size: 16,
x: 0,
y: 0,
rotate: 0,
flipX: false,
flipY: false
};
function isReserved(name) {
return ~RESERVED_CLASSES.indexOf(name);
}
function bunker(fn) {
try {
fn();
} catch (e) {
if (!PRODUCTION) {
throw e;
}
}
}
function insertCss(css) {
if (!css || !IS_DOM) {
return;
}
var style = DOCUMENT.createElement('style');
style.setAttribute('type', 'text/css');
style.innerHTML = css;
var headChildren = DOCUMENT.head.childNodes;
var beforeChild = null;
for (var i = headChildren.length - 1; i > -1; i--) {
var child = headChildren[i];
var tagName = (child.tagName || '').toUpperCase();
if (['STYLE', 'LINK'].indexOf(tagName) > -1) {
beforeChild = child;
}
}
DOCUMENT.head.insertBefore(style, beforeChild);
return css;
}
var _uniqueId = 0;
function nextUniqueId() {
_uniqueId++;
return _uniqueId;
}
function toArray(obj) {
var array = [];
for (var i = (obj || []).length >>> 0; i--;) {
array[i] = obj[i];
}
return array;
}
function classArray(node) {
if (node.classList) {
return toArray(node.classList);
} else {
return (node.getAttribute('class') || '').split(' ').filter(function (i) {
return i;
});
}
}
function getIconName(familyPrefix, cls) {
var parts = cls.split('-');
var prefix = parts[0];
var iconName = parts.slice(1).join('-');
if (prefix === familyPrefix && iconName !== '' && !isReserved(iconName)) {
return iconName;
} else {
return null;
}
}
function htmlEscape(str) {
return ('' + str).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function joinAttributes(attributes) {
return Object.keys(attributes || {}).reduce(function (acc, attributeName) {
return acc + (attributeName + '="' + htmlEscape(attributes[attributeName]) + '" ');
}, '').trim();
}
function joinStyles(styles) {
return Object.keys(styles || {}).reduce(function (acc, styleName) {
return acc + (styleName + ': ' + styles[styleName] + ';');
}, '');
}
function transformIsMeaningful(transform) {
return transform.size !== meaninglessTransform.size || transform.x !== meaninglessTransform.x || transform.y !== meaninglessTransform.y || transform.rotate !== meaninglessTransform.rotate || transform.flipX || transform.flipY;
}
function transformForSvg(_ref) {
var transform = _ref.transform,
containerWidth = _ref.containerWidth,
iconWidth = _ref.iconWidth;
var outer = {
transform: 'translate(' + containerWidth / 2 + ' 256)'
};
var innerTranslate = 'translate(' + transform.x * 32 + ', ' + transform.y * 32 + ') ';
var innerScale = 'scale(' + transform.size / 16 * (transform.flipX ? -1 : 1) + ', ' + transform.size / 16 * (transform.flipY ? -1 : 1) + ') ';
var innerRotate = 'rotate(' + transform.rotate + ' 0 0)';
var inner = {
transform: innerTranslate + ' ' + innerScale + ' ' + innerRotate
};
var path = {
transform: 'translate(' + iconWidth / 2 * -1 + ' -256)'
};
return {
outer: outer,
inner: inner,
path: path
};
}
function transformForCss(_ref2) {
var transform = _ref2.transform,
_ref2$width = _ref2.width,
width = _ref2$width === undefined ? UNITS_IN_GRID : _ref2$width,
_ref2$height = _ref2.height,
height = _ref2$height === undefined ? UNITS_IN_GRID : _ref2$height,
_ref2$startCentered = _ref2.startCentered,
startCentered = _ref2$startCentered === undefined ? false : _ref2$startCentered;
var val = '';
if (startCentered && IS_IE) {
val += 'translate(' + (transform.x / d - width / 2) + 'em, ' + (transform.y / d - height / 2) + 'em) ';
} else if (startCentered) {
val += 'translate(calc(-50% + ' + transform.x / d + 'em), calc(-50% + ' + transform.y / d + 'em)) ';
} else {
val += 'translate(' + transform.x / d + 'em, ' + transform.y / d + 'em) ';
}
val += 'scale(' + transform.size / d * (transform.flipX ? -1 : 1) + ', ' + transform.size / d * (transform.flipY ? -1 : 1) + ') ';
val += 'rotate(' + transform.rotate + 'deg) ';
return val;
}
var ALL_SPACE = {
x: 0,
y: 0,
width: '100%',
height: '100%'
};
var makeIconMasking = function (_ref) {
var children = _ref.children,
attributes = _ref.attributes,
main = _ref.main,
mask = _ref.mask,
transform = _ref.transform;
var mainWidth = main.width,
mainPath = main.icon;
var maskWidth = mask.width,
maskPath = mask.icon;
var trans = transformForSvg({ transform: transform, containerWidth: maskWidth, iconWidth: mainWidth });
var maskRect = {
tag: 'rect',
attributes: _extends({}, ALL_SPACE, {
fill: 'white'
})
};
var maskInnerGroup = {
tag: 'g',
attributes: _extends({}, trans.inner),
children: [{ tag: 'path', attributes: _extends({}, mainPath.attributes, trans.path, { fill: 'black' }) }]
};
var maskOuterGroup = {
tag: 'g',
attributes: _extends({}, trans.outer),
children: [maskInnerGroup]
};
var maskId = 'mask-' + nextUniqueId();
var clipId = 'clip-' + nextUniqueId();
var maskTag = {
tag: 'mask',
attributes: _extends({}, ALL_SPACE, {
id: maskId,
maskUnits: 'userSpaceOnUse',
maskContentUnits: 'userSpaceOnUse'
}),
children: [maskRect, maskOuterGroup]
};
var defs = {
tag: 'defs',
children: [{ tag: 'clipPath', attributes: { id: clipId }, children: [maskPath] }, maskTag]
};
children.push(defs, { tag: 'rect', attributes: _extends({ fill: 'currentColor', 'clip-path': 'url(#' + clipId + ')', mask: 'url(#' + maskId + ')' }, ALL_SPACE) });
return {
children: children,
attributes: attributes
};
};
var makeIconStandard = function (_ref) {
var children = _ref.children,
attributes = _ref.attributes,
main = _ref.main,
transform = _ref.transform,
styles = _ref.styles;
var styleString = joinStyles(styles);
if (styleString.length > 0) {
attributes['style'] = styleString;
}
if (transformIsMeaningful(transform)) {
var trans = transformForSvg({ transform: transform, containerWidth: main.width, iconWidth: main.width });
children.push({
tag: 'g',
attributes: _extends({}, trans.outer),
children: [{
tag: 'g',
attributes: _extends({}, trans.inner),
children: [{
tag: main.icon.tag,
children: main.icon.children,
attributes: _extends({}, main.icon.attributes, trans.path)
}]
}]
});
} else {
children.push(main.icon);
}
return {
children: children,
attributes: attributes
};
};
var asIcon = function (_ref) {
var children = _ref.children,
main = _ref.main,
mask = _ref.mask,
attributes = _ref.attributes,
styles = _ref.styles,
transform = _ref.transform;
if (transformIsMeaningful(transform) && main.found && !mask.found) {
var width = main.width,
height = main.height;
var offset = {
x: width / height / 2,
y: 0.5
};
attributes['style'] = joinStyles(_extends({}, styles, {
'transform-origin': offset.x + transform.x / 16 + 'em ' + (offset.y + transform.y / 16) + 'em'
}));
}
return [{
tag: 'svg',
attributes: attributes,
children: children
}];
};
var asSymbol = function (_ref) {
var prefix = _ref.prefix,
iconName = _ref.iconName,
children = _ref.children,
attributes = _ref.attributes,
symbol = _ref.symbol;
var id = symbol === true ? prefix + '-' + config$1.familyPrefix + '-' + iconName : symbol;
return [{
tag: 'svg',
attributes: {
style: 'display: none;'
},
children: [{
tag: 'symbol',
attributes: _extends({}, attributes, { id: id }),
children: children
}]
}];
};
function makeInlineSvgAbstract(params) {
var _params$icons = params.icons,
main = _params$icons.main,
mask = _params$icons.mask,
prefix = params.prefix,
iconName = params.iconName,
transform = params.transform,
symbol = params.symbol,
title = params.title,
extra = params.extra,
_params$watchable = params.watchable,
watchable = _params$watchable === undefined ? false : _params$watchable;
var _ref = mask.found ? mask : main,
width = _ref.width,
height = _ref.height;
var widthClass = 'fa-w-' + Math.ceil(width / height * 16);
var attrClass = [config$1.replacementClass, iconName ? config$1.familyPrefix + '-' + iconName : '', widthClass].concat(extra.classes).join(' ');
var content = {
children: [],
attributes: _extends({}, extra.attributes, {
'data-prefix': prefix,
'data-icon': iconName,
'class': attrClass,
'role': 'img',
'xmlns': 'http://www.w3.org/2000/svg',
'viewBox': '0 0 ' + width + ' ' + height
})
};
if (watchable) {
content.attributes[DATA_FA_I2SVG] = '';
}
if (title) content.children.push({ tag: 'title', attributes: { id: content.attributes['aria-labelledby'] || 'title-' + nextUniqueId() }, children: [title] });
var args = _extends({}, content, {
prefix: prefix,
iconName: iconName,
main: main,
mask: mask,
transform: transform,
symbol: symbol,
styles: extra.styles
});
var _ref2 = mask.found && main.found ? makeIconMasking(args) : makeIconStandard(args),
children = _ref2.children,
attributes = _ref2.attributes;
args.children = children;
args.attributes = attributes;
if (symbol) {
return asSymbol(args);
} else {
return asIcon(args);
}
}
function makeLayersTextAbstract(params) {
var content = params.content,
width = params.width,
height = params.height,
transform = params.transform,
title = params.title,
extra = params.extra,
_params$watchable2 = params.watchable,
watchable = _params$watchable2 === undefined ? false : _params$watchable2;
var attributes = _extends({}, extra.attributes, title ? { 'title': title } : {}, {
'class': extra.classes.join(' ')
});
if (watchable) {
attributes[DATA_FA_I2SVG] = '';
}
var styles = _extends({}, extra.styles);
if (transformIsMeaningful(transform)) {
styles['transform'] = transformForCss({ transform: transform, startCentered: true, width: width, height: height });
styles['-webkit-transform'] = styles['transform'];
}
var styleString = joinStyles(styles);
if (styleString.length > 0) {
attributes['style'] = styleString;
}
var val = [];
val.push({
tag: 'span',
attributes: attributes,
children: [content]
});
if (title) {
val.push({ tag: 'span', attributes: { class: 'sr-only' }, children: [title] });
}
return val;
}
var noop$2 = function noop() {};
var p = config$1.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : { mark: noop$2, measure: noop$2 };
var preamble = 'FA "5.0.5"';
var begin = function begin(name) {
p.mark(preamble + ' ' + name + ' begins');
return function () {
return end(name);
};
};
var end = function end(name) {
p.mark(preamble + ' ' + name + ' ends');
p.measure(preamble + ' ' + name, preamble + ' ' + name + ' begins', preamble + ' ' + name + ' ends');
};
var perf = { begin: begin, end: end };
'use strict';
/**
* Internal helper to bind a function known to have 4 arguments
* to a given context.
*/
var bindInternal4 = function bindInternal4 (func, thisContext) {
return function (a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
};
'use strict';
/**
* # Reduce
*
* A fast object `.reduce()` implementation.
*
* @param {Object} subject The object to reduce over.
* @param {Function} fn The reducer function.
* @param {mixed} initialValue The initial value for the reducer, defaults to subject[0].
* @param {Object} thisContext The context for the reducer.
* @return {mixed} The final result.
*/
var reduce = function fastReduceObject (subject, fn, initialValue, thisContext) {
var keys = Object.keys(subject),
length = keys.length,
iterator = thisContext !== undefined ? bindInternal4(fn, thisContext) : fn,
i, key, result;
if (initialValue === undefined) {
i = 1;
result = subject[keys[0]];
}
else {
i = 0;
result = initialValue;
}
for (; i < length; i++) {
key = keys[i];
result = iterator(result, subject[key], key, subject);
}
return result;
};
var styles$2 = namespace.styles;
var shims = namespace.shims;
var _byUnicode = {};
var _byLigature = {};
var _byOldName = {};
var build = function build() {
var lookup = function lookup(reducer) {
return reduce(styles$2, function (o, style, prefix) {
o[prefix] = reduce(style, reducer, {});
return o;
}, {});
};
_byUnicode = lookup(function (acc, icon, iconName) {
acc[icon[3]] = iconName;
return acc;
});
_byLigature = lookup(function (acc, icon, iconName) {
var ligatures = icon[2];
acc[iconName] = iconName;
ligatures.forEach(function (ligature) {
acc[ligature] = iconName;
});
return acc;
});
var hasRegular = 'far' in styles$2;
_byOldName = reduce(shims, function (acc, shim) {
var oldName = shim[0];
var prefix = shim[1];
var iconName = shim[2];
if (prefix === 'far' && !hasRegular) {
prefix = 'fas';
}
acc[oldName] = { prefix: prefix, iconName: iconName };
return acc;
}, {});
};
build();
function byUnicode(prefix, unicode) {
return _byUnicode[prefix][unicode];
}
function byLigature(prefix, ligature) {
return _byLigature[prefix][ligature];
}
function byOldName(name) {
return _byOldName[name] || { prefix: null, iconName: null };
}
var styles$1 = namespace.styles;
var emptyCanonicalIcon = function emptyCanonicalIcon() {
return { prefix: null, iconName: null, rest: [] };
};
function getCanonicalIcon(values) {
return values.reduce(function (acc, cls) {
var iconName = getIconName(config$1.familyPrefix, cls);
if (styles$1[cls]) {
acc.prefix = cls;
} else if (iconName) {
var shim = acc.prefix === 'fa' ? byOldName(iconName) : {};
acc.iconName = shim.iconName || iconName;
acc.prefix = shim.prefix || acc.prefix;
} else if (cls !== config$1.replacementClass && cls.indexOf('fa-w-') !== 0) {
acc.rest.push(cls);
}
return acc;
}, emptyCanonicalIcon());
}
function iconFromMapping(mapping, prefix, iconName) {
if (mapping && mapping[prefix] && mapping[prefix][iconName]) {
return {
prefix: prefix,
iconName: iconName,
icon: mapping[prefix][iconName]
};
}
}
function toHtml(abstractNodes) {
var tag = abstractNodes.tag,
_abstractNodes$attrib = abstractNodes.attributes,
attributes = _abstractNodes$attrib === undefined ? {} : _abstractNodes$attrib,
_abstractNodes$childr = abstractNodes.children,
children = _abstractNodes$childr === undefined ? [] : _abstractNodes$childr;
if (typeof abstractNodes === 'string') {
return htmlEscape(abstractNodes);
} else {
return '<' + tag + ' ' + joinAttributes(attributes) + '>' + children.map(toHtml).join('') + '</' + tag + '>';
}
}
var noop$1 = function noop() {};
function isWatched(node) {
var i2svg = node.getAttribute ? node.getAttribute(DATA_FA_I2SVG) : null;
return typeof i2svg === 'string';
}
function getMutator() {
if (config$1.autoReplaceSvg === true) {
return mutators.replace;
}
var mutator = mutators[config$1.autoReplaceSvg];
return mutator || mutators.replace;
}
var mutators = {
replace: function replace(mutation) {
var node = mutation[0];
var abstract = mutation[1];
var newOuterHTML = abstract.map(function (a) {
return toHtml(a);
}).join('\n');
if (node.parentNode && node.outerHTML) {
node.outerHTML = newOuterHTML + (config$1.keepOriginalSource && node.tagName.toLowerCase() !== 'svg' ? '<!-- ' + node.outerHTML + ' -->' : '');
} else if (node.parentNode) {
var newNode = document.createElement('span');
node.parentNode.replaceChild(newNode, node);
newNode.outerHTML = newOuterHTML;
}
},
nest: function nest(mutation) {
var node = mutation[0];
var abstract = mutation[1];
// If we already have a replaced node we do not want to continue nesting within it.
// Short-circuit to the standard replacement
if (~classArray(node).indexOf(config$1.replacementClass)) {
return mutators.replace(mutation);
}
var forSvg = new RegExp(config$1.familyPrefix + '-.*');
delete abstract[0].attributes.style;
var splitClasses = abstract[0].attributes.class.split(' ').reduce(function (acc, cls) {
if (cls === config$1.replacementClass || cls.match(forSvg)) {
acc.toSvg.push(cls);
} else {
acc.toNode.push(cls);
}
return acc;
}, { toNode: [], toSvg: [] });
abstract[0].attributes.class = splitClasses.toSvg.join(' ');
var newInnerHTML = abstract.map(function (a) {
return toHtml(a);
}).join('\n');
node.setAttribute('class', splitClasses.toNode.join(' '));
node.setAttribute(DATA_FA_I2SVG, '');
node.innerHTML = newInnerHTML;
}
};
function perform(mutations, callback) {
var callbackFunction = typeof callback === 'function' ? callback : noop$1;
if (mutations.length === 0) {
callbackFunction();
} else {
var frame = WINDOW.requestAnimationFrame || function (op) {
return op();
};
frame(function () {
var mutator = getMutator();
var mark = perf.begin('mutate');
mutations.map(mutator);
mark();
callbackFunction();
});
}
}
var disabled = false;
function disableObservation(operation) {
disabled = true;
operation();
disabled = false;
}
function observe(options) {
if (!MUTATION_OBSERVER) return;
var treeCallback = options.treeCallback,
nodeCallback = options.nodeCallback,
pseudoElementsCallback = options.pseudoElementsCallback;
var mo = new MUTATION_OBSERVER(function (objects) {
if (disabled) return;
toArray(objects).forEach(function (mutationRecord) {
if (mutationRecord.type === 'childList' && mutationRecord.addedNodes.length > 0 && !isWatched(mutationRecord.addedNodes[0])) {
if (config$1.searchPseudoElements) {
pseudoElementsCallback(mutationRecord.target);
}
treeCallback(mutationRecord.target);
}
if (mutationRecord.type === 'attributes' && mutationRecord.target.parentNode && config$1.searchPseudoElements) {
pseudoElementsCallback(mutationRecord.target.parentNode);
}
if (mutationRecord.type === 'attributes' && isWatched(mutationRecord.target) && ~ATTRIBUTES_WATCHED_FOR_MUTATION.indexOf(mutationRecord.attributeName)) {
if (mutationRecord.attributeName === 'class') {
var _getCanonicalIcon = getCanonicalIcon(classArray(mutationRecord.target)),
prefix = _getCanonicalIcon.prefix,
iconName = _getCanonicalIcon.iconName;
if (prefix) mutationRecord.target.setAttribute('data-prefix', prefix);
if (iconName) mutationRecord.target.setAttribute('data-icon', iconName);
} else {
nodeCallback(mutationRecord.target);
}
}
});
});
if (!IS_DOM) return;
mo.observe(DOCUMENT.getElementsByTagName('body')[0], {
childList: true, attributes: true, characterData: true, subtree: true
});
}
var styleParser = function (node) {
var style = node.getAttribute('style');
var val = [];
if (style) {
val = style.split(';').reduce(function (acc, style) {
var styles = style.split(':');
var prop = styles[0];
var value = styles.slice(1);
if (prop && value.length > 0) {
acc[prop] = value.join(':').trim();
}
return acc;
}, {});
}
return val;
};
function toHex(unicode) {
var result = '';
for (var i = 0; i < unicode.length; i++) {
var hex = unicode.charCodeAt(i).toString(16);
result += ('000' + hex).slice(-4);
}
return result;
}
var classParser = function (node) {
var existingPrefix = node.getAttribute('data-prefix');
var existingIconName = node.getAttribute('data-icon');
var innerText = node.innerText !== undefined ? node.innerText.trim() : '';
var val = getCanonicalIcon(classArray(node));
if (existingPrefix && existingIconName) {
val.prefix = existingPrefix;
val.iconName = existingIconName;
}
if (val.prefix && innerText.length > 1) {
val.iconName = byLigature(val.prefix, node.innerText);
} else if (val.prefix && innerText.length === 1) {
val.iconName = byUnicode(val.prefix, toHex(node.innerText));
}
return val;
};
var parseTransformString = function parseTransformString(transformString) {
var transform = {
size: 16,
x: 0,
y: 0,
flipX: false,
flipY: false,
rotate: 0
};
if (!transformString) {
return transform;
} else {
return transformString.toLowerCase().split(' ').reduce(function (acc, n) {
var parts = n.toLowerCase().split('-');
var first = parts[0];
var rest = parts.slice(1).join('-');
if (first && rest === 'h') {
acc.flipX = true;
return acc;
}
if (first && rest === 'v') {
acc.flipY = true;
return acc;
}
rest = parseFloat(rest);
if (isNaN(rest)) {
return acc;
}
switch (first) {
case 'grow':
acc.size = acc.size + rest;
break;
case 'shrink':
acc.size = acc.size - rest;
break;
case 'left':
acc.x = acc.x - rest;
break;
case 'right':
acc.x = acc.x + rest;
break;
case 'up':
acc.y = acc.y - rest;
break;
case 'down':
acc.y = acc.y + rest;
break;
case 'rotate':
acc.rotate = acc.rotate + rest;
break;
}
return acc;
}, transform);
}
};
var transformParser = function (node) {
return parseTransformString(node.getAttribute('data-fa-transform'));
};
var symbolParser = function (node) {
var symbol = node.getAttribute('data-fa-symbol');
return symbol === null ? false : symbol === '' ? true : symbol;
};
var attributesParser = function (node) {
var extraAttributes = toArray(node.attributes).reduce(function (acc, attr) {
if (acc.name !== 'class' && acc.name !== 'style') {
acc[attr.name] = attr.value;
}
return acc;
}, {});
var title = node.getAttribute('title');
if (config$1.autoA11y) {
if (title) {
extraAttributes['aria-labelledby'] = config$1.replacementClass + '-title-' + nextUniqueId();
} else {
extraAttributes['aria-hidden'] = 'true';
}
}
return extraAttributes;
};
var maskParser = function (node) {
var mask = node.getAttribute('data-fa-mask');
if (!mask) {
return emptyCanonicalIcon();
} else {
return getCanonicalIcon(mask.split(' ').map(function (i) {
return i.trim();
}));
}
};
function parseMeta(node) {
var _classParser = classParser(node),
iconName = _classParser.iconName,
prefix = _classParser.prefix,
extraClasses = _classParser.rest;
var extraStyles = styleParser(node);
var transform = transformParser(node);
var symbol = symbolParser(node);
var extraAttributes = attributesParser(node);
var mask = maskParser(node);
return {
iconName: iconName,
title: node.getAttribute('title'),
prefix: prefix,
transform: transform,
symbol: symbol,
mask: mask,
extra: {
classes: extraClasses,
styles: extraStyles,
attributes: extraAttributes
}
};
}
function MissingIcon(error) {
this.name = 'MissingIcon';
this.message = error || 'Icon unavailable';
this.stack = new Error().stack;
}
MissingIcon.prototype = Object.create(Error.prototype);
MissingIcon.prototype.constructor = MissingIcon;
var FILL = { fill: 'currentColor' };
var ANIMATION_BASE = {
attributeType: 'XML',
repeatCount: 'indefinite',
dur: '2s'
};
var RING = {
tag: 'path',
attributes: _extends({}, FILL, {
d: 'M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z'
})
};
var OPACITY_ANIMATE = _extends({}, ANIMATION_BASE, {
attributeName: 'opacity'
});
var DOT = {
tag: 'circle',
attributes: _extends({}, FILL, {
cx: '256',
cy: '364',
r: '28'
}),
children: [{ tag: 'animate', attributes: _extends({}, ANIMATION_BASE, { attributeName: 'r', values: '28;14;28;28;14;28;' }) }, { tag: 'animate', attributes: _extends({}, OPACITY_ANIMATE, { values: '1;0;1;1;0;1;' }) }]
};
var QUESTION = {
tag: 'path',
attributes: _extends({}, FILL, {
opacity: '1',
d: 'M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z'
}),
children: [{ tag: 'animate', attributes: _extends({}, OPACITY_ANIMATE, { values: '1;0;0;0;0;1;' }) }]
};
var EXCLAMATION = {
tag: 'path',
attributes: _extends({}, FILL, {
opacity: '0',
d: 'M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z'
}),
children: [{ tag: 'animate', attributes: _extends({}, OPACITY_ANIMATE, { values: '0;0;1;1;0;0;' }) }]
};
var missing = { tag: 'g', children: [RING, DOT, QUESTION, EXCLAMATION] };
var styles = namespace.styles;
var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Brands)/;
var STYLE_TO_PREFIX = {
'Solid': 'fas',
'Regular': 'far',
'Light': 'fal',
'Brands': 'fab'
};
function findIcon(iconName, prefix) {
var val = {
found: false,
width: 512,
height: 512,
icon: missing
};
if (iconName && prefix && styles[prefix] && styles[prefix][iconName]) {
var icon = styles[prefix][iconName];
var width = icon[0];
var height = icon[1];
var vectorData = icon.slice(4);
val = {
found: true,
width: width,
height: height,
icon: { tag: 'path', attributes: { fill: 'currentColor', d: vectorData[0] } }
};
} else if (iconName && prefix && !config$1.showMissingIcons) {
throw new MissingIcon('Icon is missing for prefix ' + prefix + ' with icon name ' + iconName);
}
return val;
}
function generateSvgReplacementMutation(node, nodeMeta) {
var iconName = nodeMeta.iconName,
title = nodeMeta.title,
prefix = nodeMeta.prefix,
transform = nodeMeta.transform,
symbol = nodeMeta.symbol,
mask = nodeMeta.mask,
extra = nodeMeta.extra;
return [node, makeInlineSvgAbstract({
icons: {
main: findIcon(iconName, prefix),
mask: findIcon(mask.iconName, mask.prefix)
},
prefix: prefix,
iconName: iconName,
transform: transform,
symbol: symbol,
mask: mask,
title: title,
extra: extra,
watchable: true
})];
}
function generateLayersText(node, nodeMeta) {
var title = nodeMeta.title,
transform = nodeMeta.transform,
extra = nodeMeta.extra;
var width = null;
var height = null;
if (IS_IE) {
var computedFontSize = parseInt(getComputedStyle(node).fontSize, 10);
var boundingClientRect = node.getBoundingClientRect();
width = boundingClientRect.width / computedFontSize;
height = boundingClientRect.height / computedFontSize;
}
if (config$1.autoA11y && !title) {
extra.attributes['aria-hidden'] = 'true';
}
return [node, makeLayersTextAbstract({
content: node.innerHTML,
width: width,
height: height,
transform: transform,
title: title,
extra: extra,
watchable: true
})];
}
function generateMutation(node) {
var nodeMeta = parseMeta(node);
if (~nodeMeta.extra.classes.indexOf(LAYERS_TEXT_CLASSNAME)) {
return generateLayersText(node, nodeMeta);
} else {
return generateSvgReplacementMutation(node, nodeMeta);
}
}
function remove(node) {
if (typeof node.remove === 'function') {
node.remove();
} else if (node && node.parentNode) {
node.parentNode.removeChild(node);
}
}
function searchPseudoElements(root) {
if (!IS_DOM) return;
var end = perf.begin('searchPseudoElements');
disableObservation(function () {
toArray(root.querySelectorAll('*')).forEach(function (node) {
[':before', ':after'].forEach(function (pos) {
var styles = WINDOW.getComputedStyle(node, pos);
var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
var children = toArray(node.children);
var pseudoElement = children.filter(function (c) {
return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === pos;
})[0];
if (pseudoElement) {
if (pseudoElement.nextSibling && pseudoElement.nextSibling.textContent.indexOf(DATA_FA_PSEUDO_ELEMENT) > -1) {
remove(pseudoElement.nextSibling);
}
remove(pseudoElement);
pseudoElement = null;
}
if (fontFamily && !pseudoElement) {
var content = styles.getPropertyValue('content');
var i = DOCUMENT.createElement('i');
i.setAttribute('class', '' + STYLE_TO_PREFIX[fontFamily[1]]);
i.setAttribute(DATA_FA_PSEUDO_ELEMENT, pos);
i.innerText = content.length === 3 ? content.substr(1, 1) : content;
if (pos === ':before') {
node.insertBefore(i, node.firstChild);
} else {
node.appendChild(i);
}
}
});
});
});
end();
}
function onTree(root) {
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!IS_DOM) return;
var htmlClassList = DOCUMENT.documentElement.classList;
var hclAdd = function hclAdd(suffix) {
return htmlClassList.add(HTML_CLASS_I2SVG_BASE_CLASS + '-' + suffix);
};
var hclRemove = function hclRemove(suffix) {
return htmlClassList.remove(HTML_CLASS_I2SVG_BASE_CLASS + '-' + suffix);
};
var prefixes = Object.keys(styles);
var prefixesDomQuery = ['.' + LAYERS_TEXT_CLASSNAME + ':not([' + DATA_FA_I2SVG + '])'].concat(prefixes.map(function (p) {
return '.' + p + ':not([' + DATA_FA_I2SVG + '])';
})).join(', ');
if (prefixesDomQuery.length === 0) {
return;
}
var candidates = toArray(root.querySelectorAll(prefixesDomQuery));
if (candidates.length > 0) {
hclAdd('pending');
hclRemove('complete');
} else {
return;
}
var mark = perf.begin('onTree');
var mutations = candidates.reduce(function (acc, node) {
try {
var mutation = generateMutation(node);
if (mutation) {
acc.push(mutation);
}
} catch (e) {
if (!PRODUCTION) {
if (e instanceof MissingIcon) {
console.error(e);
}
}
}
return acc;
}, []);
mark();
perform(mutations, function () {
hclAdd('active');
hclAdd('complete');
hclRemove('pending');
if (typeof callback === 'function') callback();
});
}
function onNode(node) {
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var mutation = generateMutation(node);
if (mutation) {
perform([mutation], callback);
}
}
var baseStyles = "svg:not(:root).svg-inline--fa {\n overflow: visible; }\n\n.svg-inline--fa {\n display: inline-block;\n font-size: inherit;\n height: 1em;\n overflow: visible;\n vertical-align: -.125em; }\n .svg-inline--fa.fa-lg {\n vertical-align: -.225em; }\n .svg-inline--fa.fa-w-1 {\n width: 0.0625em; }\n .svg-inline--fa.fa-w-2 {\n width: 0.125em; }\n .svg-inline--fa.fa-w-3 {\n width: 0.1875em; }\n .svg-inline--fa.fa-w-4 {\n width: 0.25em; }\n .svg-inline--fa.fa-w-5 {\n width: 0.3125em; }\n .svg-inline--fa.fa-w-6 {\n width: 0.375em; }\n .svg-inline--fa.fa-w-7 {\n width: 0.4375em; }\n .svg-inline--fa.fa-w-8 {\n width: 0.5em; }\n .svg-inline--fa.fa-w-9 {\n width: 0.5625em; }\n .svg-inline--fa.fa-w-10 {\n width: 0.625em; }\n .svg-inline--fa.fa-w-11 {\n width: 0.6875em; }\n .svg-inline--fa.fa-w-12 {\n width: 0.75em; }\n .svg-inline--fa.fa-w-13 {\n width: 0.8125em; }\n .svg-inline--fa.fa-w-14 {\n width: 0.875em; }\n .svg-inline--fa.fa-w-15 {\n width: 0.9375em; }\n .svg-inline--fa.fa-w-16 {\n width: 1em; }\n .svg-inline--fa.fa-w-17 {\n width: 1.0625em; }\n .svg-inline--fa.fa-w-18 {\n width: 1.125em; }\n .svg-inline--fa.fa-w-19 {\n width: 1.1875em; }\n .svg-inline--fa.fa-w-20 {\n width: 1.25em; }\n .svg-inline--fa.fa-pull-left {\n margin-right: .3em;\n width: auto; }\n .svg-inline--fa.fa-pull-right {\n margin-left: .3em;\n width: auto; }\n .svg-inline--fa.fa-border {\n height: 1.5em; }\n .svg-inline--fa.fa-li {\n width: 2em; }\n .svg-inline--fa.fa-fw {\n width: 1.25em; }\n\n.fa-layers svg.svg-inline--fa {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0; }\n\n.fa-layers {\n display: inline-block;\n height: 1em;\n position: relative;\n text-align: center;\n vertical-align: -.125em;\n width: 1em; }\n .fa-layers svg.svg-inline--fa {\n -webkit-transform-origin: center center;\n transform-origin: center center; }\n\n.fa-layers-text, .fa-layers-counter {\n display: inline-block;\n position: absolute;\n text-align: center; }\n\n.fa-layers-text {\n left: 50%;\n top: 50%;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n -webkit-transform-origin: center center;\n transform-origin: center center; }\n\n.fa-layers-counter {\n background-color: #ff253a;\n border-radius: 1em;\n color: #fff;\n height: 1.5em;\n line-height: 1;\n max-width: 5em;\n min-width: 1.5em;\n overflow: hidden;\n padding: .25em;\n right: 0;\n text-overflow: ellipsis;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right; }\n\n.fa-layers-bottom-right {\n bottom: 0;\n right: 0;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom right;\n transform-origin: bottom right; }\n\n.fa-layers-bottom-left {\n bottom: 0;\n left: 0;\n right: auto;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom left;\n transform-origin: bottom left; }\n\n.fa-layers-top-right {\n right: 0;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right; }\n\n.fa-layers-top-left {\n left: 0;\n right: auto;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top left;\n transform-origin: top left; }\n\n.fa-lg {\n font-size: 1.33333em;\n line-height: 0.75em;\n vertical-align: -.0667em; }\n\n.fa-xs {\n font-size: .75em; }\n\n.fa-sm {\n font-size: .875em; }\n\n.fa-1x {\n font-size: 1em; }\n\n.fa-2x {\n font-size: 2em; }\n\n.fa-3x {\n font-size: 3em; }\n\n.fa-4x {\n font-size: 4em; }\n\n.fa-5x {\n font-size: 5em; }\n\n.fa-6x {\n font-size: 6em; }\n\n.fa-7x {\n font-size: 7em; }\n\n.fa-8x {\n font-size: 8em; }\n\n.fa-9x {\n font-size: 9em; }\n\n.fa-10x {\n font-size: 10em; }\n\n.fa-fw {\n text-align: center;\n width: 1.25em; }\n\n.fa-ul {\n list-style-type: none;\n margin-left: 2.5em;\n padding-left: 0; }\n .fa-ul > li {\n position: relative; }\n\n.fa-li {\n left: -2em;\n position: absolute;\n text-align: center;\n width: 2em;\n line-height: inherit; }\n\n.fa-border {\n border: solid 0.08em #eee;\n border-radius: .1em;\n padding: .2em .25em .15em; }\n\n.fa-pull-left {\n float: left; }\n\n.fa-pull-right {\n float: right; }\n\n.fa.fa-pull-left,\n.fas.fa-pull-left,\n.far.fa-pull-left,\n.fal.fa-pull-left,\n.fab.fa-pull-left {\n margin-right: .3em; }\n\n.fa.fa-pull-right,\n.fas.fa-pull-right,\n.far.fa-pull-right,\n.fal.fa-pull-right,\n.fab.fa-pull-right {\n margin-left: .3em; }\n\n.fa-spin {\n -webkit-animation: fa-spin 2s infinite linear;\n animation: fa-spin 2s infinite linear; }\n\n.fa-pulse {\n -webkit-animation: fa-spin 1s infinite steps(8);\n animation: fa-spin 1s infinite steps(8); }\n\n@-webkit-keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg); } }\n\n@keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg); } }\n\n.fa-rotate-90 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)\";\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg); }\n\n.fa-rotate-180 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)\";\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg); }\n\n.fa-rotate-270 {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)\";\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg); }\n\n.fa-flip-horizontal {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)\";\n -webkit-transform: scale(-1, 1);\n transform: scale(-1, 1); }\n\n.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(1, -1);\n transform: scale(1, -1); }\n\n.fa-flip-horizontal.fa-flip-vertical {\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n -webkit-transform: scale(-1, -1);\n transform: scale(-1, -1); }\n\n:root .fa-rotate-90,\n:root .fa-rotate-180,\n:root .fa-rotate-270,\n:root .fa-flip-horizontal,\n:root .fa-flip-vertical {\n -webkit-filter: none;\n filter: none; }\n\n.fa-stack {\n display: inline-block;\n height: 2em;\n position: relative;\n width: 2em; }\n\n.fa-stack-1x,\n.fa-stack-2x {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0; }\n\n.svg-inline--fa.fa-stack-1x {\n height: 1em;\n width: 1em; }\n\n.svg-inline--fa.fa-stack-2x {\n height: 2em;\n width: 2em; }\n\n.fa-inverse {\n color: #fff; }\n\n.sr-only {\n border: 0;\n clip: rect(0, 0, 0, 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px; }\n\n.sr-only-focusable:active, .sr-only-focusable:focus {\n clip: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n position: static;\n width: auto; }\n";
var css = function () {
var dfp = DEFAULT_FAMILY_PREFIX;
var drc = DEFAULT_REPLACEMENT_CLASS;
var fp = config$1.familyPrefix;
var rc = config$1.replacementClass;
var s = baseStyles;
if (fp !== dfp || rc !== drc) {
var dPatt = new RegExp('\\.' + dfp + '\\-', 'g');
var rPatt = new RegExp('\\.' + drc, 'g');
s = s.replace(dPatt, '.' + fp + '-').replace(rPatt, '.' + rc);
}
return s;
};
function define(prefix, icons) {
var normalized = Object.keys(icons).reduce(function (acc, iconName) {
var icon = icons[iconName];
var expanded = !!icon.icon;
if (expanded) {
acc[icon.iconName] = icon.icon;
} else {
acc[iconName] = icon;
}
return acc;
}, {});
if (typeof namespace.hooks.addPack === 'function') {
namespace.hooks.addPack(prefix, normalized);
} else {
namespace.styles[prefix] = _extends({}, namespace.styles[prefix] || {}, normalized);
}
/**
* Font Awesome 4 used the prefix of `fa` for all icons. With the introduction
* of new styles we needed to differentiate between them. Prefix `fa` is now an alias
* for `fas` so we'll easy the upgrade process for our users by automatically defining
* this as well.
*/
if (prefix === 'fas') {
define('fa', icons);
}
}
var Library = function () {
function Library() {
classCallCheck(this, Library);
this.definitions = {};
}
createClass(Library, [{
key: 'add',
value: function add() {
var _this = this;
for (var _len = arguments.length, definitions = Array(_len), _key = 0; _key < _len; _key++) {
definitions[_key] = arguments[_key];
}
var additions = definitions.reduce(this._pullDefinitions, {});
Object.keys(additions).forEach(function (key) {
_this.definitions[key] = _extends({}, _this.definitions[key] || {}, additions[key]);
define(key, additions[key]);
});
}
}, {
key: 'reset',
value: function reset() {
this.definitions = {};
}
}, {
key: '_pullDefinitions',
value: function _pullDefinitions(additions, definition) {
var normalized = definition.prefix && definition.iconName && definition.icon ? { 0: definition } : definition;
Object.keys(normalized).map(function (key) {
var _normalized$key = normalized[key],
prefix = _normalized$key.prefix,
iconName = _normalized$key.iconName,
icon = _normalized$key.icon;
if (!additions[prefix]) additions[prefix] = {};
additions[prefix][iconName] = icon;
});
return additions;
}
}]);
return Library;
}();
function prepIcon(icon) {
var width = icon[0];
var height = icon[1];
var vectorData = icon.slice(4);
return {
found: true,
width: width,
height: height,
icon: { tag: 'path', attributes: { fill: 'currentColor', d: vectorData[0] } }
};
}
var _cssInserted = false;
function ensureCss() {
if (!config$1.autoAddCss) {
return;
}
if (!_cssInserted) {
insertCss(css());
}
_cssInserted = true;
}
function apiObject(val, abstractCreator) {
Object.defineProperty(val, 'abstract', {
get: abstractCreator
});
Object.defineProperty(val, 'html', {
get: function get() {
return val.abstract.map(function (a) {
return toHtml(a);
});
}
});
Object.defineProperty(val, 'node', {
get: function get() {
if (!IS_DOM) return;
var container = DOCUMENT.createElement('div');
container.innerHTML = val.html;
return container.children;
}
});
return val;
}
function findIconDefinition(params) {
var _params$prefix = params.prefix,
prefix = _params$prefix === undefined ? 'fa' : _params$prefix,
iconName = params.iconName;
if (!iconName) return;
return iconFromMapping(library.definitions, prefix, iconName) || iconFromMapping(namespace.styles, prefix, iconName);
}
function resolveIcons(next) {
return function (maybeIconDefinition) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var iconDefinition = (maybeIconDefinition || {}).icon ? maybeIconDefinition : findIconDefinition(maybeIconDefinition || {});
var mask = params.mask;
if (mask) {
mask = (mask || {}).icon ? mask : findIconDefinition(mask || {});
}
return next(iconDefinition, _extends({}, params, { mask: mask }));
};
}
var library = new Library();
var noAuto = function noAuto() {
return auto(false);
};
var dom = {
i2svg: function i2svg() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (IS_DOM) {
ensureCss();
var _params$node = params.node,
node = _params$node === undefined ? DOCUMENT : _params$node,
_params$callback = params.callback,
callback = _params$callback === undefined ? function () {} : _params$callback;
if (config$1.searchPseudoElements) {
searchPseudoElements(node);
}
onTree(node, callback);
}
},
css: css,
insertCss: function insertCss$$1() {
insertCss(css());
}
};
var parse = {
transform: function transform(transformString) {
return parseTransformString(transformString);
}
};
var icon = resolveIcons(function (iconDefinition) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _params$transform = params.transform,
transform = _params$transform === undefined ? meaninglessTransform : _params$transform,
_params$symbol = params.symbol,
symbol = _params$symbol === undefined ? false : _params$symbol,
_params$mask = params.mask,
mask = _params$mask === undefined ? null : _params$mask,
_params$title = params.title,
title = _params$title === undefined ? null : _params$title,
_params$classes = params.classes,
classes = _params$classes === undefined ? [] : _params$classes,
_params$attributes = params.attributes,
attributes = _params$attributes === undefined ? {} : _params$attributes,
_params$styles = params.styles,
styles = _params$styles === undefined ? {} : _params$styles;
if (!iconDefinition) return;
var prefix = iconDefinition.prefix,
iconName = iconDefinition.iconName,
icon = iconDefinition.icon;
return apiObject(_extends({ type: 'icon' }, iconDefinition), function () {
ensureCss();
if (config$1.autoA11y) {
if (title) {
attributes['aria-labelledby'] = config$1.replacementClass + '-title-' + nextUniqueId();
} else {
attributes['aria-hidden'] = 'true';
}
}
return makeInlineSvgAbstract({
icons: {
main: prepIcon(icon),
mask: mask ? prepIcon(mask.icon) : { found: false, width: null, height: null, icon: {} }
},
prefix: prefix,
iconName: iconName,
transform: _extends({}, meaninglessTransform, transform),
symbol: symbol,
title: title,
extra: {
attributes: attributes,
styles: styles,
classes: classes
}
});
});
});
var text = function text(content) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _params$transform2 = params.transform,
transform = _params$transform2 === undefined ? meaninglessTransform : _params$transform2,
_params$title2 = params.title,
title = _params$title2 === undefined ? null : _params$title2,
_params$classes2 = params.classes,
classes = _params$classes2 === undefined ? [] : _params$classes2,
_params$attributes2 = params.attributes,
attributes = _params$attributes2 === undefined ? {} : _params$attributes2,
_params$styles2 = params.styles,
styles = _params$styles2 === undefined ? {} : _params$styles2;
return apiObject({ type: 'text', content: content }, function () {
ensureCss();
return makeLayersTextAbstract({
content: content,
transform: _extends({}, meaninglessTransform, transform),
title: title,
extra: {
attributes: attributes,
styles: styles,
classes: [config$1.familyPrefix + '-layers-text'].concat(toConsumableArray(classes))
}
});
});
};
var layer = function layer(assembler) {
return apiObject({ type: 'layer' }, function () {
ensureCss();
var children = [];
assembler(function (args) {
Array.isArray(args) ? children = args.map(function (a) {
children = children.concat(a.abstract);
}) : children = children.concat(args.abstract);
});
return [{
tag: 'span',
attributes: { class: config$1.familyPrefix + '-layers' },
children: children
}];
});
};
var api$1 = {
noAuto: noAuto,
dom: dom,
library: library,
parse: parse,
findIconDefinition: findIconDefinition,
icon: icon,
text: text,
layer: layer
};
var autoReplace = function autoReplace() {
if (IS_DOM && config$1.autoReplaceSvg) api$1.dom.i2svg({ node: DOCUMENT });
};
function bootstrap() {
if (IS_BROWSER) {
if (!WINDOW.FontAwesome) {
WINDOW.FontAwesome = api$1;
}
domready(function () {
if (Object.keys(namespace.styles).length > 0) {
autoReplace();
}
if (config$1.observeMutations && typeof MutationObserver === 'function') {
observe({
treeCallback: onTree,
nodeCallback: onNode,
pseudoElementsCallback: searchPseudoElements
});
}
});
}
namespace.hooks = _extends({}, namespace.hooks, {
addPack: function addPack(prefix, icons) {
namespace.styles[prefix] = _extends({}, namespace.styles[prefix] || {}, icons);
build();
autoReplace();
},
addShims: function addShims(shims) {
var _namespace$shims;
(_namespace$shims = namespace.shims).push.apply(_namespace$shims, toConsumableArray(shims));
build();
autoReplace();
}
});
}
Object.defineProperty(api$1, 'config', {
get: function get() {
return config$1;
},
set: function set(newConfig) {
update(newConfig);
}
});
if (IS_DOM) bunker(bootstrap);
var config = api$1.config;
/* harmony default export */ __webpack_exports__["a"] = (api$1);
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(5)))
/***/ }),
/* 5 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = { prefix: 'fas', iconName: 'bars', icon: [448, 512, [], "f0c9", "M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"] };
/***/ }),
/* 7 */
/***/ (function(module, exports) {
module.exports = { prefix: 'fas', iconName: 'clipboard', icon: [384, 512, [], "f328", "M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z"] };
/***/ }),
/* 8 */
/***/ (function(module, exports) {
module.exports = { prefix: 'fas', iconName: 'download', icon: [512, 512, [], "f019", "M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"] };
/***/ }),
/* 9 */
/***/ (function(module, exports) {
module.exports = { prefix: 'fas', iconName: 'key', icon: [512, 512, [], "f084", "M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z"] };
/***/ }),
/* 10 */
/***/ (function(module, exports) {
module.exports = { prefix: 'fas', iconName: 'cog', icon: [512, 512, [], "f013", "M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z"] };
/***/ }),
/* 11 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 12 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ })
/******/ ]);