See espterm.github.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
espterm-demo-website/js/app.32c889b-en.js

4 lines
124 KiB

!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=10)}([function(e,t,n){"use strict";t.mk=function(e){return document.createElement(e)},t.qs=function(e){return document.querySelector(e)},t.qsa=function(e){return document.querySelectorAll(e)},t.cr=function(e){return function(t){10!==t.which&&13!==t.which&&32!==t.which||e()}},t.parse2B=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.charCodeAt(t++)-1+127*(e.charCodeAt(t)-1)},t.parse3B=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.charCodeAt(t)-1+127*(e.charCodeAt(t+1)-1)+127*(e.charCodeAt(t+2)-1)*127},t.encode2B=function(e){var t=void 0,n=void 0;return t=e%127,e=(e-t)/127,t+=1,n=e+1,String.fromCharCode(t)+String.fromCharCode(n)},t.encode3B=function(e){var t=void 0,n=void 0,i=void 0;return t=e%127,e=(e-t)/127,t+=1,n=e%127,e=(e-n)/127,n+=1,i=e+1,String.fromCharCode(t)+String.fromCharCode(n)+String.fromCharCode(i)}},function(e,t,n){"use strict";var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!chibi 3.0.7, Copyright 2012-2016 Kyle Barrow, released under MIT license */
!function(){function t(){var e;for(m=!0,e=0;e<v.length;e+=1)v[e]();v=[]}function n(){var e;for(g=!0,m||t(),e=0;e<p.length;e+=1)p[e]();p=[]}function r(e,t){var n;for(n=t.length-1;n>=0;n-=1)e(t[n])}function o(e){return e.replace(/-\w/g,function(e){return e.charAt(1).toUpperCase()})}function s(e,t){return e.currentStyle?e.currentStyle[o(t)]:y.getComputedStyle?y.getComputedStyle(e,null).getPropertyValue(t):null}function a(e,t){return encodeURIComponent(e).replace(/%20/g,"+")+"="+encodeURIComponent(t).replace(/%20/g,"+")}function l(e,t,n){try{e.style[o(t)]=n}catch(e){}}function u(e){e.style.display="","none"===s(e,"display")&&(e.style.display="block")}function c(e){var t,n,i,o="";if(e.constructor===Object){for(t in e)if(e.hasOwnProperty(t))if(e[t].constructor===Array)for(n=0;n<e[t].length;n+=1)o+="&"+a(t,e[t][n]);else o+="&"+a(t,e[t])}else r(function(e){if("FORM"===e.nodeName)for(n=0;n<e.elements.length;n+=1)if(t=e.elements[n],!t.disabled)switch(t.type){case"button":case"image":case"file":case"submit":case"reset":break;case"select-one":t.length>0&&(o+="&"+a(t.name,t.value));break;case"select-multiple":for(i=0;i<t.length;i+=1)t[i].selected&&(o+="&"+a(t.name,t[i].value));break;case"checkbox":case"radio":t.checked&&(o+="&"+a(t.name,t.value));break;default:o+="&"+a(t.name,t.value)}},e);return o.length>0?o.substring(1):""}function h(e,t,n){var i,o,s=!1;return e&&(i=e.split(/\s+/),r(function(e){for(o=0;o<i.length;o+=1){var n=i[o];if("remove"===t)e.classList.remove(n);else if("add"===t)e.classList.add(n);else if("toggle"===t)e.classList.toggle(n);else if("has"===t&&e.classList.contains(n)){s=!0;break}}},n)),s}function d(e,t,n){var i,o;e&&r(function(n){for(i=w.createElement("div"),i.innerHTML=e;null!==(o=i.lastChild);)try{"before"===t?n.parentNode.insertBefore(o,n):"after"===t?n.parentNode.insertBefore(o,n.nextSibling):"append"===t?n.appendChild(o):"prepend"===t&&n.insertBefore(o,n.firstChild)}catch(e){break}},n)}function f(e){var t,n,a,c=[],v=!1;if(e)if(e.nodeType&&1===e.nodeType)c=[e];else if("object"===(void 0===e?"undefined":i(e)))v="number"!=typeof e.length,c=e;else if("string"==typeof e)for(n=w.querySelectorAll(e),a=0;a<n.length;a+=1)c[a]=n[a];return t=v?{}:c,t.each=function(e){return"function"==typeof e&&r(function(t){return e.apply(t,arguments)},c),t},t.first=function(){return f(c.shift())},t.last=function(){return f(c.pop())},t.odd=function(){var e,t=[];for(e=0;e<c.length;e+=2)t.push(c[e]);return f(t)},t.even=function(){var e,t=[];for(e=1;e<c.length;e+=2)t.push(c[e]);return f(t)},t.hide=function(){return r(function(e){e.style.display="none"},c),t},t.show=function(){return r(function(e){u(e)},c),t},t.toggle=function(e){return void 0!==e?e?t.show():t.hide():r(function(e){"none"===s(e,"display")?u(e):e.style.display="none"},c),t},t.remove=function(){return r(function(e){try{e.parentNode.removeChild(e)}catch(e){}},c),f()},t.css=function(e,n){if(e){if(n||""===n)return r(function(t){l(t,e,n)},c),t;if(c[0]){if(c[0].style[o(e)])return c[0].style[o(e)];if(s(c[0],e))return s(c[0],e)}}},t.getClass=function(){if(c[0]&&c[0].className.length>0)return c[0].className.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"").replace(/\s+/," ")},t.setClass=function(e){return(e||""===e)&&r(function(t){t.className=e},c),t},t.addClass=function(e){return h(e,"add",c),t},t.removeClass=function(e){return h(e,"remove",c),t},t.toggleClass=function(e,n){return h(e,void 0===n?"toggle":+n?"add":"remove",c),t},t.hasClass=function(e){return h(e,"has",c)},t.html=function(e){return e||""===e?(r(function(t){t.innerHTML=e},c),t):c[0]?c[0].innerHTML:void 0},t.htmlBefore=function(e){return d(e,"before",c),t},t.htmlAfter=function(e){return d(e,"after",c),t},t.htmlAppend=function(e){return d(e,"append",c),t},t.htmlPrepend=function(e){return d(e,"prepend",c),t},t.attr=function(e,n){if(e){if(e=e.toLowerCase(),void 0!==n)return r(function(t){"style"===e?t.style.cssText=n:"class"===e?t.className=n:t.setAttribute(e,n)},c),t;if(c[0])if("style"===e){if(c[0].style.cssText)return c[0].style.cssText}else if("class"===e){if(c[0].className)return c[0].className}else if(c[0].getAttribute(e))return c[0].getAttribute(e)}},t.data=function(e,n){if(e)return t.attr("data-"+e,n)},t.val=function(e){var n,i,o;if(void 0!==e)return r(function(t){switch(t.nodeName){case"SELECT":for("string"!=typeof e&&"number"!=typeof e||(e=[e]),i=0;i<t.length;i+=1)for(o=0;o<e.length;o+=1)if(t[i].selected="",t[i].value===""+e[o]){t[i].selected="selected";break}break;case"INPUT":case"TEXTAREA":case"BUTTON":t.value=e}},c),t;if(c[0])switch(c[0].nodeName){case"SELECT":for(n=[],i=0;i<c[0].length;i+=1)c[0][i].selected&&n.push(c[0][i].value);return n.length>1?n:n[0];case"INPUT":case"TEXTAREA":case"BUTTON":return c[0].value}},t.checked=function(e){return"boolean"==typeof e?(r(function(t){"INPUT"!==t.nodeName||"checkbox"!==t.type&&"radio"!==t.type||(t.checked=e)},c),t):!c[0]||"INPUT"!==c[0].nodeName||"checkbox"!==c[0].type&&"radio"!==c[0].type?void 0:!!c[0].checked},t.on=function(n,i){return e!==y&&e!==w||(c=[e]),r(function(e){w.addEventListener?e.addEventListener(n,i,!1):w.attachEvent&&(e[n+i]=function(){return i.apply(e,arguments)},e.attachEvent("on"+n,e[n+i]))},c),t},t.off=function(n,i){return e!==y&&e!==w||(c=[e]),r(function(e){w.addEventListener?e.removeEventListener(n,i,!1):w.attachEvent&&(e.detachEvent("on"+n,e[n+i]),e[n+i]=null)},c),t},t}var v=[],p=[],m=!1,g=!1,w=document,y=window;w.addEventListener?(w.addEventListener("DOMContentLoaded",t,!1),y.addEventListener("load",n,!1)):w.attachEvent?(w.attachEvent("onreadystatechange",t),y.attachEvent("onload",n)):y.onload=n,f.ajax=function(e){var t=Object.assign({method:"GET",nocache:!0,timeout:5e3,loader:!0,callback:null},e);t.method=t.method.toUpperCase();var n=t.loader?f._loader:function(){},i=t.url,r=t.method,o=null;t.data&&(o=c(t.data)),o&&"GET"===r&&(i+=-1===i.indexOf("?")?"?"+o:"&"+o,o=null);var s=new XMLHttpRequest;if(t.nocache){var a=(+new Date).toString(36);i+=(-1===i.indexOf("?")?"?":"&")+"_="+a}n(!0),s.open(r,i,!0),s.timeout=t.timeout;var l=setTimeout(function(){console.error("XHR timed out."),s.abort(),n(!1)},t.timeout+10);return s.onreadystatechange=function(){4===s.readyState&&(n(!1),t.callback&&t.callback(s.responseText,s.status),clearTimeout(l))},s.setRequestHeader("X-Requested-With","XMLHttpRequest"),"POST"===r&&s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s},f._loader=function(){},f.get=function(e,t,n){return n=n||{},n.url=e,n.callback=t,n.method="GET",f.ajax(n)},f.post=function(e,t,n){return n=n||{},n.url=e,n.callback=t,n.method="POST",f.ajax(n)},f.ready=function(e){if(e){if(m)return e(),f;v.push(e)}},f.loaded=function(e){if(e){if(g)return e(),f;p.push(e)}};var b={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};f.htmlEscape=function(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return b[e]})},e.exports=f}()},function(e,t,n){"use strict";var i=n(1),r={},o=null;r.show=function(e,t){var n=i(e);n.removeClass("hidden visible"),setTimeout(function(){n.addClass("visible")},1),o=t},r.hide=function(e){var t=i(e);t.removeClass("visible"),setTimeout(function(){t.addClass("hidden"),o&&o()},500)},r.init=function(){i(".Modal").on("click",function(){i(this).hasClass("no-close")||r.hide(this)}),i(".Dialog").on("click",function(e){e.stopImmediatePropagation()}),i(window).on("keydown",function(e){27===e.which&&r.hide(".Modal")})},e.exports=r},function(e,t,n){"use strict";var i=n(1),r=n(2),o={},s=void 0,a=void 0,l=void 0,u=!1,c=function(){clearTimeout(a),clearTimeout(l)};o.show=function(e,t,n){s.toggleClass("error",!0===n),s.html(e),r.show(s),c(),(!t||t<=0)&&(t=2500),a=setTimeout(o.hide,t),u=!1,setTimeout(function(){u=!0},500)},o.hide=function(){var e=i("#notif");e.removeClass("visible"),l=setTimeout(function(){e.addClass("hidden")},250)},o.init=function(){s=i("#notif"),i(document).on("click",function(){u&&o.hide(this)}),s.on("click",function(e){return e.stopImmediatePropagation(),!1}),s.on("mouseenter",function(){c(),s.removeClass("hidden").addClass("visible")})},e.exports=o},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function r(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!r(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,r,a,l,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(n=this._events[e],s(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(o(n))for(a=Array.prototype.slice.call(arguments,1),u=n.slice(),r=u.length,l=0;l<r;l++)u[l].apply(this,a);return!0},n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,r,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";var i=n(1),r=n(8),o=r.rgb255ToHex,s=t.themes=[["#111213","#CC0000","#4E9A06","#C4A000","#3465A4","#75507B","#06989A","#D3D7CF","#555753","#EF2929","#8AE234","#FCE94F","#729FCF","#AD7FA8","#34E2E2","#EEEEEC"],["#000000","#aa0000","#00aa00","#aa5500","#0000aa","#aa00aa","#00aaaa","#aaaaaa","#555555","#ff5555","#55ff55","#ffff55","#5555ff","#ff55ff","#55ffff","#ffffff"],["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"],["#000000","#cd0000","#00cd00","#cdcd00","#0000cd","#cd00cd","#00cdcd","#faebd7","#404040","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"],["#2e3436","#cc0000","#4e9a06","#c4a000","#3465a4","#75507b","#06989a","#d3d7cf","#555753","#ef2929","#8ae234","#fce94f","#729fcf","#ad7fa8","#34e2e2","#eeeeec"],["#073642","#dc322f","#859900","#b58900","#268bd2","#d33682","#2aa198","#eee8d5","#002b36","#cb4b16","#586e75","#657b83","#839496","#6c71c4","#93a1a1","#fdf6e3"],["#000000","#69001A","#117800","#769100","#1A00A6","#8019AB","#289E76","#A4A4A4","#484848","#C54E76","#6DD441","#D2ED46","#765BFF","#DC75FF","#84FAD2","#FFFFFF"],["#000000","#aa0000","#00aa00","#aaaa00","#0000aa","#aa00aa","#00aaaa","#aaaaaa","#000000","#ff0000","#00FF00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"],["#000000","#722640","#0E5940","#808080","#40337F","#E434FE","#1B9AFE","#BFB3FF","#404C00","#E46501","#1BCB01","#BFCC80","#808080","#F1A6BF","#8DD9BF","#ffffff"],["#000000","#8D3E37","#55A049","#AAB95D","#40318D","#80348B","#72C1C8","#D59F74","#8B5429","#B86962","#94E089","#FFFFB2","#8071CC","#AA5FB6","#87D6DD","#ffffff"],["#eee8d5","#dc322f","#859900","#b58900","#268bd2","#d33682","#2aa198","#073642","#fdf6e3","#cb4b16","#93a1a1","#839496","#657b83","#6c71c4","#586e75","#002b36"],["#073642","#dc322f","#859900","#b58900","#268bd2","#d33682","#2aa198","#fdf6e3","#002b36","#cb4b16","#657b83","#839496","#93a1a1","#6c71c4","#eee8d5","#fdf6e3"]];t.fgbgThemes=[["#AAAAAA","#000000","Lnx","Linux"],["#FFFFFF","#000000","W+K","White on Black"],["#00FF00","#000000","Lim","Lime"],["#E53C00","#000000","Nix","Nixie"],["#EFF0F1","#31363B","Brz","Breeze"],["#FFFFFF","#300A24","Amb","Ambiance"],["#839496","#002B36","SoD","Solarized Dark"],["#93a1a1","#002b36","SoH","Solarized Dark (High Contrast)"],["#657B83","#FDF6E3","SoL","Solarized Light"],["#000000","#FFD75F","Wsp","Wasp"],["#000000","#FFFFDD","K+Y","Black on Yellow"],["#000000","#FFFFFF","K+W","Black on White"]];var a=null;t.buildColorTable=function(){if(null!==a)return a;a=new Array(16).fill("#000000");for(var e=0;e<6;e++)for(var t=0;t<6;t++)for(var n=0;n<6;n++){var i=40*e+(e?55:0),r=40*t+(t?55:0),s=40*n+(n?55:0);a.push(o(i,r,s))}for(var l=0;l<24;l++){var u=10*l+8;a.push(o(u,u,u))}return a},t.SELECTION_FG="#333",t.SELECTION_BG="#b2d7fe",t.themePreview=function(e){i("[data-fg]").forEach(function(n){var i=n.dataset.fg;/^\d+$/.test(i)&&(i=t.toHex(i,e)),n.style.color=i}),i("[data-bg]").forEach(function(n){var i=n.dataset.bg;/^\d+$/.test(i)&&(i=t.toHex(i,e)),n.style.backgroundColor=i})},t.colorTable256=null,t.ensureColorTable256=function(){t.colorTable256||(t.colorTable256=t.buildColorTable())},t.getColor=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e<16&&e in n?n[e]:-1===e?t.SELECTION_FG:-2===e?t.SELECTION_BG:e>15&&e<256?(t.ensureColorTable256(),t.colorTable256[e]):e>255?(e-=256,"#"+("000000"+e.toString(16)).substr(-6)):Math.floor(Date.now()/1e3)%2==0?"#f0f":"#0f0"},t.toHex=function(e,n){return/^\d+$/.test(e)?(e=+e,t.getColor(e,s[n])):e}},function(e,t,n){"use strict";t.ATTR_FG=1,t.ATTR_BG=2,t.ATTR_BOLD=4,t.ATTR_UNDERLINE=8,t.ATTR_INVERSE=16,t.ATTR_BLINK=32,t.ATTR_ITALIC=64,t.ATTR_STRIKE=128,t.ATTR_OVERLINE=256,t.ATTR_FAINT=512,t.ATTR_FRAKTUR=1024},function(e,t,n){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function e(t,n,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,i)}if("value"in r)return r.value;var s=r.get;if(void 0!==s)return s.call(i)},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=n(4),c=n(0),h=c.parse2B,d=n(5),f=d.themes,v=function(e){return String.fromCodePoint(e+(e>=55296?2049:1))},p=function(){function e(t){s(this,e),this.reset(),this.handler=t,this.joinChunks=!0}return l(e,[{key:"reset",value:function(){this.currentSequence=0,this.sequence=""}},{key:"parseSequence",value:function(e){if("["===e[0]){var t=e[e.length-1],n=e.substring(1,e.length-1),i=n?n.split(";").map(function(e){return+e.replace(/\D/g,"")}):[],r=i.length?i[0]:1;if("H"===t)this.handler("set-cursor",(0|i[0])-1,(0|i[1])-1);else if(t>="A"&&t<="D")this.handler("move-cursor-"+(t<="B"?"y":"x"),("B"===t||"C"===t?1:-1)*r);else if("E"===t||"F"===t)this.handler("move-cursor-line",("E"===t?1:-1)*r);else if("G"===t)this.handler("set-cursor-x",r-1);else if("J"===t){var o=i.length?i[0]:2;2===o&&this.handler("clear")}else if("P"===t)this.handler("delete",r);else if("@"===t)this.handler("insert-blanks",r);else if("q"===t)this.handler("set-cursor-style",r);else if("m"===t){if(!i.length)return void this.handler("reset-style");for(var s=void 0;s=i.shift();)if(0===s)this.handler("reset-style");else if(1===s)this.handler("add-attrs",4);else if(2===s)this.handler("add-attrs",512);else if(3===s)this.handler("add-attrs",64);else if(4===s)this.handler("add-attrs",8);else if(5===s||6===s)this.handler("add-attrs",32);else if(7===s)this.handler("add-attrs",16);else if(9===s)this.handler("add-attrs",128);else if(20===s)this.handler("add-attrs",1024);else if(s>=30&&s<=37)this.handler("set-color-fg",s%10);else if(s>=40&&s<=47)this.handler("set-color-bg",s%10);else if(39===s)this.handler("reset-color-fg");else if(49===s)this.handler("reset-color-bg");else if(s>=90&&s<=98)this.handler("set-color-fg",s%10+8);else if(s>=100&&s<=108)this.handler("set-color-bg",s%10+8);else if(38===s||48===s){var a=i.shift();if(2===a){var l=i.shift(),u=i.shift(),c=i.shift(),h=256+(l<<16|u<<8|c);38===s&&this.handler("set-color-fg",h),48===s&&this.handler("set-color-bg",h)}else if(5===a){var d=255&(0|i.shift());38===s&&this.handler("set-color-fg",d),48===s&&this.handler("set-color-bg",d)}}}else"h"!==t&&"l"!==t||"?25"===n&&("h"===t?this.handler("show-cursor"):"l"===t&&this.handler("hide-cursor"))}}},{key:"write",value:function(e){var t=!0,n=!1,i=void 0;try{for(var r,o=e.toString()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value,a=s.codePointAt(0);27===a?this.currentSequence=1:1===this.currentSequence&&"["===s?(this.currentSequence=2,this.sequence+="["):this.currentSequence&&s.match(/[\x40-\x7e]/)?(this.parseSequence(this.sequence+s),this.currentSequence=0,this.sequence=""):this.currentSequence>1?this.sequence+=s:1===this.currentSequence?(this.currentSequence=0,this.handler("write",s)):a<3?this.handler("_null"):3===a?this.handler("sigint"):a<=6?this.handler("_null"):7===a?this.handler("bell"):8===a?this.handler("back"):9===a?this.handler("tab"):10===a?this.handler("new-line"):13===a?this.handler("return"):21===a?this.handler("delete-line"):23===a?this.handler("delete-word"):this.handler("write",s)}}catch(e){n=!0,i=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw i}}this.joinChunks||this.reset()}}]),e}(),m=[0,0,0],g=function(e){return 16+36*Math.floor(2.5*Math.sin(e)+2.5)+6*Math.floor(2.5*Math.sin(e+2/3*Math.PI)+2.5)+Math.floor(2.5*Math.sin(e+4/3*Math.PI)+2.5)},w=function(){function e(t){var n=this;s(this,e),this.width=80,this.height=25,this.termScreen=t,this.parser=new p(function(){return n.handleParsed.apply(n,arguments)}),this.buttonLabels=[],this.reset(),this._lastLoad=Date.now(),this.loadTimer(),window.showPage()}return l(e,[{key:"reset",value:function(){this.style=m.slice(),this.cursor={x:0,y:0,style:1,visible:!0},this.trackMouse=!1,this.theme=0,this.defaultFG=7,this.defaultBG=0,this.rainbow=this.superRainbow=!1,this.parser.reset(),this.clear()}},{key:"clear",value:function(){this.screen=[];for(var e=0;e<this.width*this.height;e++)this.screen.push([" ",this.style.slice()])}},{key:"scroll",value:function(){this.screen.splice(0,this.width);for(var e=0;e<this.width;e++)this.screen.push([" ",m.slice()]);this.cursor.y--}},{key:"newLine",value:function(){++this.cursor.y>=this.height&&this.scroll()}},{key:"writeChar",value:function(e){this.screen[this.cursor.y*this.width+this.cursor.x]=[e,this.style.slice()],++this.cursor.x>=this.width&&(this.cursor.x=0,this.newLine())}},{key:"moveBack",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=0;t<e;t++)--this.cursor.x<0&&(this.cursor.y>0?this.cursor.x=this.width-1:this.cursor.x=0,this.cursor.y=Math.max(0,this.cursor.y-1))}},{key:"moveForward",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=0;t<e;t++)++this.cursor.x>=this.width&&(this.cursor.x=0,++this.cursor.y>=this.height&&this.scroll())}},{key:"deleteChar",value:function(){this.moveBack(),this.screen.splice((this.cursor.y+1)*this.width,0,[" ",m.slice()]),this.screen.splice(this.cursor.y*this.width+this.cursor.x,1)}},{key:"deleteForward",value:function(e){e=Math.min(this.width,e);for(var t=0;t<e;t++)this.screen.splice((this.cursor.y+1)*this.width,0,[" ",m.slice()]);this.screen.splice(this.cursor.y*this.width+this.cursor.x,e)}},{key:"clampCursor",value:function(){this.cursor.x<0&&(this.cursor.x=0),this.cursor.y<0&&(this.cursor.y=0),this.cursor.x>this.width-1&&(this.cursor.x=this.width-1),this.cursor.y>this.height-1&&(this.cursor.y=this.height-1)}},{key:"handleParsed",value:function(e){"write"===e?this.writeChar(arguments.length<=1?void 0:arguments[1]):"delete"===e?this.deleteForward(arguments.length<=1?void 0:arguments[1]):"insert-blanks"===e?this.insertBlanks(arguments.length<=1?void 0:arguments[1]):"clear"===e?this.clear():"bell"===e?this.termScreen.load("UB"):"back"===e?this.moveBack():"new-line"===e?(this.newLine(),this.cursor.x=0):"return"===e?this.cursor.x=0:"set-cursor"===e?(this.cursor.x=arguments.length<=2?void 0:arguments[2],this.cursor.y=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"move-cursor-y"===e?(this.cursor.y+=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"move-cursor-x"===e?(this.cursor.x+=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"move-cursor-line"===e?(this.cursor.x=0,this.cursor.y+=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"set-cursor-x"===e?this.cursor.x=arguments.length<=1?void 0:arguments[1]:"set-cursor-style"===e?this.cursor.style=Math.max(0,Math.min(6,arguments.length<=1?void 0:arguments[1])):"reset-style"===e?this.style=m.slice():"add-attrs"===e?this.style[2]|=arguments.length<=1?void 0:arguments[1]:"set-color-fg"===e?(this.style[0]=arguments.length<=1?void 0:arguments[1],this.style[2]|=1):"set-color-bg"===e?(this.style[1]=arguments.length<=1?void 0:arguments[1],this.style[2]|=2):"reset-color-fg"===e?(this.style[0]=0,1&this.style[2]&&(this.style[2]^=1)):"reset-color-bg"===e?(this.style[1]=0,2&this.style[2]&&(this.style[2]^=2)):"hide-cursor"===e?this.cursor.visible=!1:"show-cursor"===e&&(this.cursor.visible=!0)}},{key:"write",value:function(e){this.parser.write(e)}},{key:"getScreenOpts",value:function(){var e="O";e+=v(25),e+=v(80),e+=v(this.theme),e+=v(65535&this.defaultFG),e+=v(this.defaultFG>>16),e+=v(65535&this.defaultBG),e+=v(this.defaultBG>>16);var t=+this.cursor.visible;return t|=96*+this.trackMouse,t|=384,t|=this.cursor.style<<9,e+=v(t)}},{key:"getButtons",value:function(){var e="B";return e+=v(this.buttonLabels.length),e+=this.buttonLabels.map(function(e){return e+""}).join("")}},{key:"getTitle",value:function(){return"TESPTerm Web UI Demo"}},{key:"getCursor",value:function(){var e="C";return e+=v(this.cursor.y),e+=v(this.cursor.x),e+=v(0)}},{key:"encodeColor",value:function(e){return e<256?v(e):(e-=256,v(4095&e|65536)+v(e>>12))}},{key:"serializeScreen",value:function(){var e="S";e+=v(0)+v(0),e+=v(this.height)+v(this.width);var t=[null,null,null],n=0,i=!0,r=!1,o=void 0;try{for(var s,a=this.screen[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var l=s.value,u=l[1].slice();if(this.rainbow){var c=n%this.width,h=Math.floor(n/this.width),d=(c+h)/10+Date.now()/1e3;this.superRainbow&&(d=(c*h+Date.now())/100+Date.now()/1e3),u[0]=g(d),u[1]=0,this.superRainbow&&(u[1]=g(d/10)),u[2]=1|u[2],!this.superRainbow&&2&u[2]&&(u[2]^=2),n++}var f=u[0],p=u[1],m=u[2],w=f!==t[0],y=p!==t[1],b=m!==t[2];w&&y?f<256&&p<256?e+=""+v(p<<8|f):(e+=""+this.encodeColor(f),e+=""+this.encodeColor(p)):w?e+=""+this.encodeColor(f):y&&(e+=""+this.encodeColor(p)),b&&(e+=""+v(m)),t=u,e+=l[0]}}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}return e}},{key:"getUpdate",value:function(){var e=[],t=this.getScreenOpts(),n=this.getTitle(),i=this.getButtons(),r=this.getCursor(),o=this.serializeScreen();return this._screenOpts!==t&&(this._screenOpts=t,e.push(t)),this._title!==n&&(this._title=n,e.push(n)),this._buttons!==i&&(this._buttons=i,e.push(i)),this._cursor!==r&&(this._cursor=r,e.push(r)),this._screen!==o&&(this._screen=o,e.push(o)),e.length?"U"+v(0)+e.join(""):""}},{key:"loadTimer",value:function(){var e=this;clearInterval(this._loadTimer),this._loadTimer=setInterval(function(){var t=e.getUpdate();t&&e.termScreen.load(t)},30)}}]),e}(),y=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"write",value:function(e){this.emit("in",e)}},{key:"destroy",value:function(){this.emit("exit",0)}},{key:"run",value:function(){}}]),t}(u),b={buttons:[],mouseReceiver:null},k={clear:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){this.emit("write",""),this.destroy()}}]),t}(y),screenfetch:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){for(var e=this,t=("\n ###. ESPTerm Demo\n '###. Hostname: "+window.location.hostname+"\n '###. Shell: ESPTerm Demo Shell\n '###. Resolution: 80x25@"+window.devicePixelRatio+"x\n :###-\n .###'\n .###'\n .###' ###############\n ###' ###############\n ").split("\n").filter(function(e){return e.trim()}),n="",i=0;i<t.length;i++)for(var r=0;r<80;r++)t[i][r]?n+="[38;5;"+g((r+i)/10)+"m"+t[i][r]:n+=" ";this.emit("write","\r\n[?25l");!function t(){e.emit("write",n.substr(0,80)),n=n.substr(80),n.length?setTimeout(t,50):(e.emit("write","\r\n[?25h"),e.destroy())}()}}]),t}(y),"local-echo":function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];t.includes("--suppress-note")||this.emit("write","Note: not all terminal features are supported and may not work as expected in this demo\n"),this.emit("buttons",[{label:"Exit",action:function(e){e.write("")}}])}},{key:"write",value:function(e){this.emit("write",e)}}]),t}(y),info:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){for(var e=this,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];var r=n.includes("--fast");this.showSplash().then(function(){e.printText(r)})}},{key:"showSplash",value:function(){var e=this,t="\n -#####- -###*..#####- ######-\n -#* -#- .## .##. *#-\n -##### .-###*..#####- *#- -*##*- #*-#--#**#-*##-\n -#* -#-.##. *#- *##@#* ##. -#* *# .#*\n -#####--####- .##. *#- -*#@@- ##. -#* *# .#*\n ".split("\n").filter(function(e){return e.trim()}),n={" ":-231,".":4,"-":8,"*":17,"#":24},i={" ":" ",".":"░","-":"▒","*":"▓","#":"█"};for(var r in t)t[r].length<79&&(t[r]+=" ".repeat(79-t[r].length));this.emit("write","\r\n".repeat(t.length+1)),this.emit("write","".repeat(t.length)),this.emit("write","[?25l");var o=0,s=0,a=function(t,n){var i=t-o,r=n-s;e.emit("write","["+Math.abs(i)+(i>0?"C":"D")),e.emit("write","["+Math.abs(r)+(r>0?"B":"A")),o=t,s=n},l=function(r,o){if(a(r,o),"@"===t[o][r])e.emit("write","▄\b");else{var s=231+n[t[o][r]],l=i[t[o][r]];e.emit("write","[48;5;"+s+"m[38;5;"+s+"m"+l+"\b")}};return new Promise(function(n,i){var r=e,o=13,s=0;!function e(){for(var i=0;i<t.length;i++){var u=o-i;u>0&&l(u,i)}++o<70?++s>=3?(setTimeout(e,50),s=0):e():(a(0,t.length),r.emit("write","[?25h"),n())}()})}},{key:"printText",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=[""," ESPTerm is a VT100-like terminal emulator running on the ESP8266 WiFi chip.",""," This is an online demo of the web user interface, simulating a simple "," terminal in your browser.",""," Type ls to list available commands."," Use the links below this screen for a demo of the options and more info.",""];if(e)this.emit("write",t.join("\r\n")+"\r\n"),this.destroy();else{var n=this;!function e(){n.emit("write",t.shift()+"\r\n"),t.length?setTimeout(e,17):n.destroy()}()}}}]),t}(y),colors:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){this.emit("write","\r\n");this.emit("write"," ");for(var e=0;e<16;e++)this.emit("write","["+(e<8?"3"+e:"9"+(e-8))+"m"),this.emit("write","foreground-color"[e]+" ");this.emit("write","\r\n ");for(var t=0;t<16;t++)this.emit("write","["+(t<8?"4"+t:"10"+(t-8))+"m ");this.emit("write","\r\n");for(var n=0;n<6;n++){this.emit("write"," ");for(var i=0;i<6;i++){for(var r=0;r<6;r++)this.emit("write","[48;5;"+(16+36*n+6*i+r)+"m ");this.emit("write","")}this.emit("write","\r\n")}this.emit("write"," ");for(var o=0;o<24;o++)this.emit("write","[48;5;"+(232+o)+"m ");this.emit("write","\r\n\n"),this.destroy()}}]),t}(y),ls:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){this.emit("write","List of demo commands\r\n");for(var e in k)"string"!=typeof k[e]&&this.emit("write",e+"\r\n");this.destroy()}}]),t}(y),theme:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),l(t,[{key:"run",value:function(){var e=0|+(arguments.length<=0?void 0:arguments[0]),t=f.length;if(!arguments.length||!Number.isFinite(e)||e<0||e>=t)return this.emit("write","Usage: theme [0–"+(t-1)+"]\n"),void this.destroy();this.shell.terminal.theme=e,this.shell.terminal.termScreen.drawnScreenFG=[],this.emit("write",""),this.destroy()}}]),t}(y),themes:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n.parser=new p(function(){return n.handler.apply(n,arguments)}),n}return o(t,e),l(t,[{key:"destroy",value:function(){this.shell.terminal.cursor.style=this.savedCursorStyle,this.emit("write","\n\n"),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"run",value:function(){var e=this;this.savedCursorStyle=this.shell.terminal.cursor.style,this.shell.terminal.cursor.style=3,this.fgType=0,this.bgType=0;var t=function(){return e.shell.terminal.defaultFG-256},n=function(t){e.shell.terminal.defaultFG=t+256},i=function(){return e.shell.terminal.defaultBG-256},r=function(t){e.shell.terminal.defaultBG=t+256},o=function(t,n,i,r,o){return n*=4,{label:t,length:1,getValue:function(){return i()>>n&15},getDisplay:function(){return(i()>>n&15).toString(16)},setValue:function(e){r(i()&(16777215^15<<n)|(15&e)<<n)},shouldShow:function(){return 1===e[o+"Type"]},parseValue:function(e){return 15&parseInt(e,16)},moveAfterInput:0!==n}};this.controls=[{label:"Theme: ",length:f.length.toString().length,getValue:function(){return e.shell.terminal.theme},setValue:function(t){var n=f.length;e.shell.terminal.theme=(t%n+n)%n}},{label:" Default Foreground: ",length:6,getValue:function(){return e.fgType},getDisplay:function(){return 0===e.fgType?"256":"24-bit"},setValue:function(t){e.fgType=(t%2+2)%2}},{label:" ",length:3,getValue:function(){return 255&e.shell.terminal.defaultFG},setValue:function(t){e.shell.terminal.defaultFG=255&t},shouldShow:function(){return 0===e.fgType},parseValue:function(e){return parseInt(e,16)}},o(" #",5,t,n,"fg"),o("",4,t,n,"fg"),o("",3,t,n,"fg"),o("",2,t,n,"fg"),o("",1,t,n,"fg"),o("",0,t,n,"fg"),{label:" Default Background: ",length:6,getValue:function(){return e.bgType},getDisplay:function(){return 0===e.bgType?"256":"24-bit"},setValue:function(t){e.bgType=(t%2+2)%2}},{label:" ",length:3,getValue:function(){return 255&e.shell.terminal.defaultBG},setValue:function(t){e.shell.terminal.defaultBG=255&t},shouldShow:function(){return 0===e.bgType},parseValue:function(e){return parseInt(e,16)}},o(" #",5,i,r,"bg"),o("",4,i,r,"bg"),o("",3,i,r,"bg"),o("",2,i,r,"bg"),o("",1,i,r,"bg"),o("",0,i,r,"bg")],this.selection=0,this.emit("write","Themes\n\n\n\n"),this.render()}},{key:"render",value:function(){this.emit("write","\r"),this.emit("write"," ".repeat(this.shell.terminal.width-1)+"\r");var e=0,t=0,n=!0,i=!1,r=void 0;try{for(var o,s=this.controls[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;if(!a.shouldShow||a.shouldShow()){a.label&&this.emit("write",""+a.label+""),this.emit("write","");var l=a.getDisplay?a.getDisplay():a.getValue().toString();this.emit("write",(a.fill||" ").repeat(Math.max(0,a.length-l.length))),this.emit("write",l.substr(0,a.length)),this.emit("write",""),e===this.selection?(t=this.shell.terminal.cursor.x-1,this.emit("write","▲▼")):this.emit("write","  "),e++}}}catch(e){i=!0,r=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw r}}this.shell.terminal.cursor.x=t}},{key:"write",value:function(e){this.parser.write(e)}},{key:"getControlCount",value:function(){var e=0,t=!0,n=!1,i=void 0;try{for(var r,o=this.controls[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;s.shouldShow&&!s.shouldShow()||e++}}catch(e){n=!0,i=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw i}}return e}},{key:"getSelectedControl",value:function(){var e=null,t=0,n=!0,i=!1,r=void 0;try{for(var o,s=this.controls[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;if(!a.shouldShow||a.shouldShow()){if(t===this.selection){e=a;break}t++}}}catch(e){i=!0,r=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw r}}return e}},{key:"handler",value:function(e){for(var t,n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];if((t=console).log.apply(t,[e].concat(i)),"move-cursor-x"===e){this.selection+=i[0];var o=this.getControlCount();this.selection=(this.selection%o+o)%o}else if("move-cursor-y"===e){var s=this.getSelectedControl();s&&s.setValue(s.getValue()-i[0])}else if("write"===e){var a=this.getSelectedControl();if(a&&a.parseValue){var l=a.parseValue(i[0]);Number.isFinite(l)&&(a.setValue(l),a.moveAfterInput&&this.selection<this.getControlCount()-1&&this.selection++)}}this.render()}}]),t}(y),cursor:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t.includes("--steady");t.includes("block")?this.emit("write","["+2*i+" q"):t.includes("line")?this.emit("write","["+(3+i)+" q"):t.includes("bar")||t.includes("beam")?this.emit("write","["+(5+i)+" q"):this.emit("write","Usage: cursor [block|line|bar] [--steady]\r\n"),this.destroy()}}]),t}(y),rainbow:function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.shell=e,i.su=n.su,i.abort=!1,i}return o(t,e),l(t,[{key:"write",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"y"===e?(this.shell.terminal.rainbow=!this.shell.terminal.rainbow,this.shell.terminal.superRainbow=!0,b._didWarnRainbow=!0):this.emit("write",e),t&&this.emit("write","Rainbow!\n"),this.destroy()}},{key:"run",value:function(){this.su&&!this.shell.terminal.rainbow?b._didWarnRainbow?this.write("y",!1):this.emit("write","Warning: flashy colors. Continue? [y/N] "):(this.shell.terminal.rainbow=!this.shell.terminal.rainbow,this.shell.terminal.superRainbow=!1,this.destroy())}},{key:"destroy",value:function(){this.abort=!0,a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}}]),t}(y),mouse:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),l(t,[{key:"run",value:function(){var e=this,t=this;this.emit("buttons",[{label:"Exit",action:function(e){e.write("")}},{label:"Add Box",action:function(){t.boxes.push(t.generateRandomBox()),t.render()}}]),this.shell.terminal.trackMouse=!0,b.mouseReceiver=this,this.boxes=Array(3).fill(0).map(function(t){return e.generateRandomBox()}),this.grabbedBox=null,this.grabOffset=[0,0],this.render()}},{key:"render",value:function(){this.emit("write",""),this.emit("write","Mouse Demo\r\nMove boxes around or scroll their contents!");var e=!0,t=!1,n=void 0;try{for(var i,r=this.boxes[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){var o=i.value;this.emit("write","["+(o.y+1)+";"+(o.x+1)+"H"),this.emit("write","[48;2;"+o.color.join(";")+"m");for(var s=o.y;s<o.y+o.height;s++){for(var a=0,l=o.x;l<o.x+o.width;l++)l<0||l>=this.shell.terminal.width-1||s<0||s>=this.shell.terminal.height||(a++,this.emit("write",o.content[s-o.y][l-o.x]));this.emit("write","".repeat(a)+"")}}}catch(e){t=!0,n=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw n}}this.mouse&&this.emit("write","["+(this.mouse.y+1)+";"+(this.mouse.x+1)+"H")}},{key:"generateRandomBox",value:function(){for(var e="abcdefghijklmnopqrstuvwxyz-*()!@#$%",t=[],n=[5,10,15][Math.floor(3*Math.random())],i=[4,5,6][Math.floor(3*Math.random())],r=0;r<i;r++){t.push("");for(var o=0;o<n;o++)Math.random()>.6?t[r]+=e[Math.floor(Math.random()*e.length)]:t[r]+=" "}return{x:Math.floor(Math.random()*(this.shell.terminal.width-1))+1,y:Math.floor(Math.random()*(this.shell.terminal.height-1))+1,width:n,height:i,color:[Math.random(),Math.random(),Math.random()].map(function(e){return Math.floor(255*e)}),content:t}}},{key:"getBoxAt",value:function(e,t){var n=this.boxes.slice().reverse(),i=!0,r=!1,o=void 0;try{for(var s,a=n[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var l=s.value;if(l.x<=e&&l.x+l.width>e&&l.y<=t&&l.y+l.height>t)return l}}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}}},{key:"mouseMove",value:function(e,t){this.mouse={x:e,y:t},this.grabbedBox&&(this.grabbedBox.x=e+this.grabOffset[0],this.grabbedBox.y=t+this.grabOffset[1]),this.render()}},{key:"mouseDown",value:function(e,t,n){if(4===n)this.scrollInsideBox(this.getBoxAt(e,t),-1);else if(5===n)this.scrollInsideBox(this.getBoxAt(e,t),1);else{var r=this.getBoxAt(e,t);if(r){var o;this.grabbedBox=r,this.grabOffset=[r.x-e,r.y-t],(o=this.boxes).push.apply(o,i(this.boxes.splice(this.boxes.indexOf(r),1)))}}this.render()}},{key:"mouseUp",value:function(e,t,n){this.grabbedBox=null}},{key:"scrollInsideBox",value:function(e,t){if(e){var n=e.content.slice();e.content=[];for(var i=0;i<n.length;i++)e.content.push(n[(i+t%n.length+n.length)%n.length])}}},{key:"destroy",value:function(){this.shell.terminal.write(""),this.shell.terminal.trackMouse=!1,b.mouseReceiver===this&&(b.mouseReceiver=null),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}}]),t}(y),sudo:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n.didDestroy=!1,n}return o(t,e),l(t,[{key:"run",value:function(){for(var e=this,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];if(0===n.length)this.emit("write","Usage: sudo [command]\r\n"),this.destroy();else{var r=n.shift();if(this.shell.index[r]){var o=this.shell.index[r];if(o instanceof Function){var s=this.child=new o(this.shell,{su:!0});this.on("in",function(e){return s.write(e)});var a=function(t){return e.emit("write",t)},l=function(t){return e.emit("buttons",t)};s.on("write",a),s.on("buttons",l),s.on("exit",function(t){s.removeListener("write",a),s.removeListener("buttons",l),e.destroy()}),s.run.apply(s,n)}else this.emit("write",o),this.destroy()}else this.emit("write","sudo: "+r+": command not found\r\n"),this.destroy()}}},{key:"destroy",value:function(){this.didDestroy||(this.didDestroy=!0,this.child&&this.child.destroy(),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this))}}]),t}(y),make:function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.su=n.su,i}return o(t,e),l(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(0===t.length)this.emit("write","make: *** No targets specified. Stop.\r\n");else if(3===t.length&&"me a sandwich"===t.join(" ").toLowerCase())if(this.su){var i="",r="",o="",s="";this.emit("write"," _.---._\r\n _.-~ ~-._\r\n _.-~ ~-._\r\n _.-~ ~---._\r\n _.-~ ~\\\r\n .-~ _.;\r\n :-._ _.-~ ./\r\n `-._~-._ _..__.-~ _.-~\r\n "+o+"/ "+i+"~-._~-._ / .__..--"+o+"~-"+r+"---._\r\n"+o+" \\_____(_"+i+";-._\\. _.-~_/"+o+" ~)"+r+".. . \\\r\n"+r+" /(_____ "+i+"\\`--...--~_.-~"+o+"______..-+"+r+"_______)\r\n"+r+" .(_________/"+i+"`--...--~/"+r+" _/ "+s+" "+i+"/\\\r\n"+i+" /-._"+s+" \\_ "+r+"(___./_..-~"+s+"__....."+i+"__..-~./\r\n"+i+" `-._~-._"+s+" ~\\--------~ .-~"+i+"_..__.-~ _.-~\r\n"+i+" ~-._~-._ "+s+"~---------` "+i+"/ .__..--~\r\n"+i+" ~-._\\. _.-~_/\r\n"+i+" \\`--...--~_.-~\r\n"+i+" `--...--~\r\n")}else this.emit("write","make: me a sandwich : Permission denied\r\n");else this.emit("write","make: *** No rule to make target '"+t.join(" ").toLowerCase()+"'. Stop.\r\n");this.destroy()}}]),t}(y),pwd:"/this/is/a/demo\r\n",cd:"No directories to change to\r\n",whoami:window.navigator.userAgent+"\r\n",hostname:""+window.location.hostname,uname:"ESPTerm Demo\r\n",mkdir:"Did not create a directory because this is a demo.\r\n",rm:"Did not delete anything because this is a demo.\r\n",cp:"Nothing to copy because this is a demo.\r\n",mv:"Nothing to move because this is a demo.\r\n",ln:"Nothing to link because this is a demo.\r\n",touch:"Nothing to touch\r\n",exit:"Nowhere to go\r\n",github:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){window.open("https://github.com/espterm/espterm-firmware"),this.destroy()}}]),t}(y)},_={"local-echo":"local-echo [--suppress-note]",theme:"theme [n]",cursor:"cursor [block|line|bar] [--steady]",sudo:"sudo [command]"},x=function(){function e(t,n){var i=this;s(this,e),this.terminal=t,this.terminal.reset(),this.parser=new p(function(){return i.handleParsed.apply(i,arguments)}),this.history=[],this.historyIndex=0,this.cursorPos=0,this.lastInputLength=0,this.child=null,this.index=k,n?this.run("info"):this.prompt()}return l(e,[{key:"write",value:function(e){this.child?3===e.codePointAt(0)?this.child.destroy():this.child.write(e):this.parser.write(e)}},{key:"prompt",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];0!==this.terminal.cursor.x&&this.terminal.write("⏎\r\n"),this.terminal.write("demosh "),e||this.terminal.write(""),this.terminal.write("$ "),this.history.unshift(""),this.cursorPos=0,this.setButtons()}},{key:"copyFromHistoryIndex",value:function(){if(this.historyIndex){var e=this.history[this.historyIndex];this.history[0]=e,this.historyIndex=0}}},{key:"getCompleted",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.history[0]){var t=this.history[0],n="";if(t.startsWith("sudo ")){var i=t.replace(/^(sudo\s+)+/,"");n=t.substr(0,t.length-i.length),t=i}if(!t)return null;for(var r in this.index)if(r.startsWith(t)&&r!==t)return e&&r in _?n+_[r]:n+r;return null}return null}},{key:"handleParsed",value:function(e){if(this.terminal.write("["+(this.lastInputLength-this.cursorPos)+"P"),this.terminal.write("\b".repeat(this.cursorPos)),"write"===e)this.copyFromHistoryIndex(),this.history[0]=this.history[0].substr(0,this.cursorPos)+(arguments.length<=1?void 0:arguments[1])+this.history[0].substr(this.cursorPos),this.cursorPos++;else if("back"===e)this.copyFromHistoryIndex(),this.history[0]=this.history[0].substr(0,this.cursorPos-1)+this.history[0].substr(this.cursorPos),--this.cursorPos<0&&(this.cursorPos=0);else if("tab"===e){var t=this.getCompleted();t&&(this.history[0]=t,this.cursorPos=this.history[0].length)}else if("move-cursor-x"===e)this.cursorPos=Math.max(0,Math.min(this.history[this.historyIndex].length,this.cursorPos+(arguments.length<=1?void 0:arguments[1])));else if("delete-line"===e)this.copyFromHistoryIndex(),this.history[0]="",this.cursorPos=0;else if("delete-word"===e){this.copyFromHistoryIndex();var n=this.history[0].substr(0,this.cursorPos).split(" ");n.pop(),this.history[0]=n.join(" ")+this.history[0].substr(this.cursorPos),this.cursorPos=n.join(" ").length}else"move-cursor-y"===e&&(this.historyIndex-=arguments.length<=1?void 0:arguments[1],this.historyIndex<0&&(this.historyIndex=0),this.historyIndex>=this.history.length&&(this.historyIndex=this.history.length-1),this.cursorPos=this.history[this.historyIndex].length);this.terminal.write(this.history[this.historyIndex]),this.terminal.write("\b".repeat(this.history[this.historyIndex].length)),this.terminal.moveForward(this.cursorPos),this.lastInputLength=this.cursorPos;var i=this.getCompleted(!0);if(0===this.historyIndex&&i&&"return"!==e){var r=i.substr(this.history[0].length);this.terminal.write(""+r+""+"\b".repeat(r.length)),this.lastInputLength+=r.length}"return"===e&&(this.terminal.write("\n"),this.parse(this.history[this.historyIndex]))}},{key:"parse",value:function(e){"help"===e&&(e="info"),e?this.run(e):this.prompt()}},{key:"run",value:function(e){var t=[""],n=!1,i=!0,r=!1,o=void 0;try{for(var s,a=e.trim()[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var l=s.value;n&&l!==n?t[t.length-1]+=l:n?n=!1:'"'===l||"'"===l?n=l:l.match(/\s/)?t[t.length-1]&&t.push(""):t[t.length-1]+=l}}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}var u=t.shift();u in this.index?this.spawn(u,t):(this.terminal.write("demosh: Unknown command: "+u+"\r\n"),this.prompt(!1))}},{key:"spawn",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.index[e];if(r instanceof Function){var o;this.setButtons([]),this.child=new r(this);var s=function(e){return t.terminal.write(e)},a=function(e){return t.setButtons(e)};this.child.on("write",s),this.child.on("buttons",a),this.child.on("exit",function(e){t.child&&(t.child.removeListener("write",s),t.child.removeListener("buttons",a)),t.child=null,t.prompt(!e)}),(o=this.child).run.apply(o,i(n))}else this.terminal.write(r),this.prompt()}},{key:"setButtons",value:function(e){if(!e){var t=this,n=function(e){var n=function n(){t.write(e[0]),(e=e.substr(1))&&setTimeout(n,100)};setTimeout(n,200)};e=[{label:"Open GitHub",action:function(e){e.child&&e.child.destroy(),n("github\r")}},{label:"Help",action:function(e){e.child&&e.child.destroy(),n("info\r")}}]}e.length||e.push({label:"",action:function(){}}),this.buttons=e,this.terminal.buttonLabels=e.map(function(e){return e.label})}},{key:"onButtonPress",value:function(e){var t=this.buttons[e];t&&t.action(this,this.terminal)}}]),e}();window.demoInterface=e.exports={input:function(e){var t=e[0],n=e.substr(1);if("s"===t)this.shell.write(n);else if("b"===t){var i=n.charCodeAt(0);this.shell.onButtonPress(i-1)}else if("m"===t||"p"===t||"r"===t){var r=h(n,0),o=h(n,2),s=h(n,4),a=h(n,6);b.mouseReceiver&&("m"===t?b.mouseReceiver.mouseMove(o,r,s,a):"p"===t?b.mouseReceiver.mouseDown(o,r,s,a):"r"===t&&b.mouseReceiver.mouseUp(o,r,s,a))}},didInit:!1,init:function(e){this.didInit||(this.didInit=!0,this.terminal=new w(e),this.shell=new x(this.terminal,!0))}}},function(e,t,n){"use strict";function i(e){return("00"+e).substr(-2)}var r=Math,o=2*r.PI;t.hue2rgb=function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),6*n<1?e+6*(t-e)*n:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e},t.hsl2rgb=function(e,n,i){e/=o;var r=void 0,s=void 0,a=void 0;if(0===n)r=s=a=i;else{var l=void 0,u=void 0;u=i<.5?i*(1+n):i+n-n*i,l=2*i-u,r=t.hue2rgb(l,u,e+1/3),s=t.hue2rgb(l,u,e),a=t.hue2rgb(l,u,e-1/3)}return[r,s,a]},t.rgb2hsl=function(e,t,n){var i=r.min(e,t,n),s=r.max(e,t,n),a=s-i,l=void 0,u=void 0,c=void 0;if(c=(s+i)/2,0===a)l=u=0;else{u=c<.5?a/(s+i):a/(2-s-i);var h=((s-e)/6+a/2)/a,d=((s-t)/6+a/2)/a,f=((s-n)/6+a/2)/a;e===s?l=f-d:t===s?l=1/3+h-f:n===s&&(l=2/3+d-h),l<0?l+=1:l>1&&(l-=1)}return l*=o,[l,u,c]},t.hex2rgb=function(e){var t=e.match(/^#([\da-f]{3,6})$/i);if(t){e=t[1];var n=e.length/3,i=Math.pow(16,n)-1;return[0,1,2].map(function(t){return parseInt(e.slice(t*n,(t+1)*n),16)/i})}return[0,0,0]},t.rgb255ToHex=function(e,t,n){return"#"+[e,t,n].map(function(e){return i(e.toString(16))}).join("")},t.rgb2hex=function(e,t,n){return"#"+[e,t,n].map(function(e){return i(Math.round(255*e).toString(16))}).join("")}},function(e,t,n){"use strict";var i=n(14);e.exports=function(e){return i[e]||"?"+e+"?"}},function(e,t,n){"use strict";n(11),n(2),n(3),n(12);try{n(7)}catch(e){}n(13);var i=n(1),r=n(0),o=r.qs;window.termInit=n(15),window.$=i,window.qs=o,window.themes=n(5),window.TermConf=n(25)},function(e,t,n){"use strict";/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
String.fromCodePoint||function(){var e=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),t=String.fromCharCode,n=Math.floor,i=function(){var e,i,r=[],o=-1,s=arguments.length;if(!s)return"";for(var a="";++o<s;){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||n(l)!=l)throw RangeError("Invalid code point: "+l);l<=65535?r.push(l):(l-=65536,e=55296+(l>>10),i=l%1024+56320,r.push(e,i)),(o+1==s||r.length>16384)&&(a+=t.apply(null,r),r.length=0)}return a};e?e(String,"fromCodePoint",{value:i,configurable:!0,writable:!0}):String.fromCodePoint=i}()},function(e,t,n){"use strict";function i(){d=!0,r("#content").addClass("load")}var r=n(1),o=n(0),s=o.mk,a=o.qs,l=o.qsa,u=o.cr,c=n(2),h=n(3);r.ready(function(){function e(){r("#menu").toggleClass("expanded")}r("#brand").on("click",e).on("keypress",u(e)),r(".Row.checkbox").forEach(function(e){var t=e.querySelector("input"),n=e.querySelector(".box");r(n).toggleClass("checked",t.value);var i=function(){t.value=1-t.value,r(n).toggleClass("checked",t.value)};r(e).on("click",i).on("keypress",u(i))}),r(".Box.mobcol,.Box.fold").forEach(function(e){var t=e.querySelector("h2"),n=function(){r(e).hasClass("d-expanded")?r(e).removeClass("d-expanded"):r(e).toggleClass("expanded")};r(t).on("click",n).on("keypress",u(n))}),r("form").forEach(function(e){r(e).on("keypress",function(t){10!==t.keyCode&&13!==t.keyCode||!t.ctrlKey||e.submit()})}),setInterval(function(){r(".anim-dots").each(function(e){var t=r(e),n=t.html()+".";5===n.length&&(n="."),t.html(n)})},1e3),r("input[type=number]").on("wheel",function(e){var t=r(this),n=+t.val();isNaN(n)&&(n=1);var i=+(t.attr("step")||1),o=+t.attr("min"),s=+t.attr("max");if(e.deltaY>0?n+=i:n-=i,Number.isFinite(o)&&(n=Math.max(n,+o)),Number.isFinite(s)&&(n=Math.min(n,+s)),t.val(n),"createEvent"in document){var a=document.createEvent("HTMLEvents");a.initEvent("change",!1,!0),t[0].dispatchEvent(a)}else t[0].fireEvent("onchange");e.preventDefault()});var t=window.location.search.indexOf("err=");if(-1!==t&&a(".Box.errors")){var n=decodeURIComponent(window.location.search.substr(t+4)).split(","),i=[];n.forEach(function(e){var t=l('label[for="'+e+'"]');if(t)for(var n=0;n<t.length;n++){var r=t[n];r.classList.add("error"),0===n&&i.push(r.childNodes[0].textContent.trim().replace(/: ?$/,""))}else i.push(e)}),a(".Box.errors .list").innerHTML=i.join(", "),a(".Box.errors").classList.remove("hidden")}var o=window.location.search.indexOf("msg=");if(-1!==o&&a(".Box.message")){var s=decodeURIComponent(window.location.search.substr(o+4)),d=a(".Box.message");d.innerHTML=s,d.classList.remove("hidden"),setTimeout(function(){d.classList.add("hiding"),setTimeout(function(){d.classList.add("hidden")},1e3)},2e3)}if(c.init(),h.init(),window.innerWidth>550){r(".Box h2").forEach(function(e){e.removeAttribute("tabindex")});var f=a("#brand");f&&f.addEventListener("click",function(){window.location.href="/"})}}),r._loader=function(e){r("#loader").toggleClass("show",e)};var d=!1;window.showPage=i,r.ready(function(){!0===window.noAutoShow?setTimeout(function(){if(!d){var e=s("P");e.id="load-failed",e.innerHTML='Server connection failed! Trying again<span class="anim-dots" style="width:1.5em;text-align:left;display:inline-block">.</span>',a("#screen").appendChild(e),a("#screen").classList.add("failed"),i()}},2e3):setTimeout(function(){i()},1)})},function(e,t,n){"use strict";var i=n(1),r=n(0),o=r.mk,s=n(9),a=function(e){return"+"+(.25*e.value).toFixed(2)+" dBm"},l=function(e,t,n){i("#sta_ssid").val(e),i("#sta_password").val(t),i("#sta-nw").toggleClass("hidden",0===e.length),i("#sta-nw-nil").toggleClass("hidden",e.length>0),i("#sta-nw .essid").html(i.htmlEscape(e));var r=!!t;i("#sta-nw .passwd").toggleClass("hidden",!r),i("#sta-nw .nopasswd").toggleClass("hidden",r),i("#sta-nw .ip").html(n.length>0?s("wifi.connected_ip_is")+n:s("wifi.not_conn"))},u=function(e,t){if(200!==t)return void d(5e3);try{e=JSON.parse(e)}catch(e){return console.log(e),void d(5e3)}var n=!e.result.inProgress&&e.result.APs.length>0;if(d(n?15e3:1e3),n){var r=i("#ap-list");i("#ap-list .AP").remove(),r.toggleClass("hidden",!n),i("#ap-loader").toggleClass("hidden",n),e.result.APs.sort(function(e,t){return t.rssi-e.rssi}).forEach(function(e){if(e.enc=parseInt(e.enc),!(e.enc>4)){var t=o("div"),n=i(t).data("ssid",e.essid).data("pwd",e.enc).attr("tabindex",0).addClass("AP");e.essid===m&&n.addClass("selected");var a=o("div"),u=i.htmlEscape(e.essid);i(a).addClass("inner").htmlAppend('<div class="rssi">'+e.rssi_perc+"</div>").htmlAppend('<div class="essid" title="'+u+'">'+u+"</div>").htmlAppend('<div class="auth">'+p[e.enc]+"</div>"),n.on("click",function(){var e=i(this),t=e.data("ssid"),n="";+e.data("pwd")&&!(n=window.prompt(s("wifi.enter_passwd").replace(":ssid:",t)))||(i("#sta_password").val(n),i("#sta_ssid").val(t),l(t,n,""))}),t.appendChild(a),r[0].appendChild(t)}})}},c=function(){i("#ap-loader").removeClass("hidden"),i("#ap-scan").addClass("hidden"),i("#ap-loader .anim-dots").html("."),h()},h=function(){window._demo?u(window._demo_aps,200):i.get("http://"+window._root+"/cfg/wifi/scan",u)},d=function(e){setTimeout(h,e)},f=function(e){i(".Row.range").forEach(function(e){var t=e.querySelector("input"),n=e.querySelector(".x-disp1"),r=e.querySelector(".x-disp2"),o=a(t);i(n).html(o),i(r).html(o),i(t).on("input",function(){o=a(t),i(n).html(o),i(r).html(o)})}),i("#forget-sta").on("click",function(){return l("","",""),!1}),l(e.sta_ssid,e.sta_password,e.sta_active_ip),m=e.sta_active_ssid},v=window.WiFi={},p=["Open","WEP","WPA","WPA2","WPA/WPA2"],m=void 0;v.init=f,v.startScanning=c},function(e,t){e.exports={"wifi.connected_ip_is":"Connected, IP is ","wifi.not_conn":"Not connected.","wifi.enter_passwd":'Enter password for ":ssid:"',"term_nav.fullscreen":"Fullscreen","term_conn.connecting":"Connecting","term_conn.waiting_content":"Waiting for content","term_conn.disconnected":"Disconnected","term_conn.waiting_server":"Waiting for server","term_conn.reconnecting":"Reconnecting"}},function(e,t,n){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var r=n(1),o=n(0),s=o.qs,a=o.mk,l=n(9),u=n(3),c=n(16),h=n(19),d=n(20),f=n(21),v=n(22),p=n(23),m=n(24);e.exports=function(e){var t=new c,n=new h(t),o=d(n,t),g=f(n,o,t);o.termUpload=g,t.on("mousedown",function(){return o.onMouseDown.apply(o,arguments)}),t.on("mousemove",function(){return o.onMouseMove.apply(o,arguments)}),t.on("mouseup",function(){return o.onMouseUp.apply(o,arguments)}),t.on("mousewheel",function(){return o.onMouseWheel.apply(o,arguments)}),t.on("input-alts",function(){return o.setAlts.apply(o,arguments)}),t.on("mouse-mode",function(){return o.setMouseMode.apply(o,arguments)}),r.ready(function(){var e=s("#touch-select-menu");t.on("show-touch-select-menu",function(t,n){var i=e.getBoundingClientRect();t-=i.width/2,n-=i.height/2,e.classList.add("open"),e.style.transform="translate("+t+"px,"+n+"px)"}),t.on("hide-touch-select-menu",function(){return e.classList.remove("open")});var n=s("#touch-select-copy-btn");n&&n.addEventListener("click",function(){t.copySelectionToClipboard()})});var w=m(o);t.on("button-labels",function(e){w.labels=e}),t.on("TEMP:hide-load-failed-msg",function(){var e=s("#screen"),t=s("#load-failed");e&&e.classList.remove("failed"),t&&t.parentNode.removeChild(t)}),t.on("TEMP:show-config-links",function(e){var t=[].concat(i(document.querySelectorAll(".x-term-conf-btn")));e?t.forEach(function(e){return e.classList.remove("hidden")}):t.forEach(function(e){return e.classList.add("hidden")})}),t.on("TEMP:show-buttons",function(e){e?s("#action-buttons").classList.remove("hidden"):s("#action-buttons").classList.add("hidden")}),t.on("TEMP:update-title",function(e){s("#screen-title").textContent=e,e||(e="Terminal"),s("title").textContent=e+" :: ESPTerm"});var y=null,b=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;clearTimeout(y),y=setTimeout(function(){t.window.statusScreen=e},n)};n.on("open",function(){b({title:l("term_conn.connecting"),loading:!0})}),n.on("connect",function(){b({title:l("term_conn.waiting_content"),loading:!0})}),t.on("load",function(){clearTimeout(y),t.window.statusScreen&&(t.window.statusScreen=null)}),n.on("disconnect",function(){b({title:l("term_conn.disconnected")},500),t.screen=[],t.screenFG=[],t.screenBG=[],t.screenAttrs=[]}),n.on("silence",function(){b({title:l("term_conn.waiting_server"),loading:!0},0)}),n.on("ping-success",function(){b({title:l("term_conn.reconnecting"),loading:!0},0)}),n.init(),o.init(e),g.init(),u.init(),window.onerror=function(e,t,n,i){return u.show("<b>JS ERROR!</b><br>"+e+"<br>at "+t+":"+n+":"+i,1e4,!0),!1},s("#screen").appendChild(t.canvas),v(t,o),p&&p(t,n);var k={},_=!1,x=!1,C=!1,S=t.window.padding,T=function(){_?(k.className="icn-resize-small",x?(t.window.fitIntoWidth=window.screen.width,t.window.fitIntoHeight=window.screen.height,t.window.padding=0):(t.window.fitIntoWidth=window.innerWidth,s("#term-nav").classList.contains("hidden")?t.window.fitIntoHeight=window.innerHeight:t.window.fitIntoHeight=window.innerHeight-24,t.window.padding=0)):(k.className="icn-resize-full",t.window.fitIntoWidth=C?window.innerWidth-4:0,t.window.fitIntoHeight=C?window.innerHeight:0,t.window.padding=S)};T(),window.addEventListener("resize",T);var E=function(){C=!C;var e=s("#resize-button-icon");C?(e.classList.remove("icn-resize-small"),e.classList.add("icn-resize-full")):(e.classList.remove("icn-resize-full"),e.classList.add("icn-resize-small")),T()};if(s("#term-fit-screen").addEventListener("click",function(){return E(),!1}),window.Element.prototype.requestFullscreen||window.Element.prototype.webkitRequestFullscreen){x=!0;var A=function(){!_||window.innerWidth===window.screen.width&&window.innerHeight===window.screen.height||(_=!1,T())};setInterval(A,500)}var L=a("a");L.id="fullscreen-button",L.href="#",L.addEventListener("click",function(e){if(e.preventDefault(),document.body.classList.contains("pseudo-fullscreen"))return document.body.classList.remove("pseudo-fullscreen"),_=!1,void T();_=!0,T(),t.updateSize(),x?t.canvas.requestFullscreen?t.canvas.requestFullscreen():t.canvas.webkitRequestFullscreen():document.body.classList.add("pseudo-fullscreen")}),k=a("i"),k.className="icn-resize-full",L.appendChild(k);var P=a("span");P.textContent=l("term_nav.fullscreen"),L.appendChild(P),s("#term-nav").insertBefore(L,s("#term-nav").firstChild),window.termScreen=t,window.conn=n,window.input=o,window.termUpl=g}},function(e,t,n){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(4),u=n(0),c=u.mk,h=n(3),d=n(17),f=n(18),v=n(6),p=v.ATTR_BLINK;e.exports=function(e){function t(){r(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));e.canvas=c("canvas"),e.ctx=e.canvas.getContext("2d"),e.parser=new d,e.renderer=new f(e),e._debug=null,"AudioContext"in window||"webkitAudioContext"in window?e.audioCtx=new(window.AudioContext||window.webkitAudioContext):console.warn("No AudioContext!"),e.cursor={x:0,y:0,blinking:!0,visible:!0,hanging:!1,style:"block"},e._window={width:0,height:0,devicePixelRatio:1,fontFamily:'"DejaVu Sans Mono", "Liberation Mono", "Inconsolata", "Menlo", monospace',fontSize:20,padding:6,gridScaleX:1,gridScaleY:1.2,fitIntoWidth:0,fitIntoHeight:0,debug:0,graphics:0,statusScreen:null},e._windowScale=1,e._padding=0,e.windowState={width:0,height:0,devicePixelRatio:0,padding:0,gridScaleX:0,gridScaleY:0,fontFamily:"",fontSize:0,fitIntoWidth:0,fitIntoHeight:0};var n=e;e.selection={selectable:null,start:[0,0],end:[0,0],setSelectable:function(e){e!==this.selectable&&(this.selectable=e,e?n.canvas.classList.add("selectable"):n.canvas.classList.remove("selectable"))}},e.mouseMode={clicks:!1,movement:!1},e.window=new Proxy(e._window,{set:function(e,t,i,r){return e[t]!==i&&(e[t]=i,n.scheduleSizeUpdate(),n.renderer.scheduleDraw("window:"+t+"="+i),n.emit("update-window:"+t,i)),!0}}),e.bracketedPaste=!1,e.blinkingCellCount=0,e.reverseVideo=!1,e.screen=[],e.screenFG=[],e.screenBG=[],e.screenAttrs=[];var s=!1,a=function(t,n){s||(s=!0,e.selection.start=e.selection.end=e.screenToGrid(t,n,!0),e.renderer.scheduleDraw("select-start"))},l=function(t,n){s&&(e.selection.end=e.screenToGrid(t,n,!0),e.renderer.scheduleDraw("select-move"))},u=function(t,n){s&&(s=!1,e.selection.end=e.screenToGrid(t,n,!0),e.renderer.scheduleDraw("select-end"),Object.assign(e.selection,e.getNormalizedSelection()))};e.canvas.addEventListener("mousedown",function(t){e.emit("hide-touch-select-menu"),(e.selection.selectable||t.altKey)&&0===t.button?a(t.offsetX,t.offsetY):e.emit.apply(e,["mousedown"].concat(i(e.screenToGrid(t.offsetX,t.offsetY)),[t.button+1]))}),window.addEventListener("mousemove",function(e){l(e.offsetX,e.offsetY)}),window.addEventListener("mouseup",function(e){u(e.offsetX,e.offsetY)});var h=null,v=0,p=!1,m=function(t){var n=e.canvas.getBoundingClientRect();return[t.clientX-n.left,t.clientY-n.top]};e.canvas.addEventListener("touchstart",function(e){h=m(e.touches[0]),p=!1,v=Date.now()},{passive:!0}),e.canvas.addEventListener("touchmove",function(e){h=m(e.touches[0]),s||!1!==p?s&&(e.preventDefault(),l.apply(void 0,i(h))):v<Date.now()-500&&a.apply(void 0,i(h)),p=!0}),e.canvas.addEventListener("touchend",function(t){if(t.touches[0]&&(h=m(t.touches[0])),s){t.preventDefault(),u.apply(void 0,i(h));var n=e.gridToScreen((e.selection.start[0]+e.selection.end[0])/2,e.selection.start[1]-1);e.emit("show-touch-select-menu",n[0],n[1])}p||e.mouseMode.clicks||e.emit("tap",Object.assign(t,{x:h[0],y:h[1]})),h=null}),e.on("tap",function(t){e.selection.start[0]!==e.selection.end[0]||e.selection.start[1]!==e.selection.end[1]?(e.selection.start=e.selection.end=[0,0],e.emit("hide-touch-select-menu"),e.renderer.scheduleDraw("select-reset")):(t.preventDefault(),e.emit("open-soft-keyboard"))}),e.canvas.addEventListener("mousemove",function(t){s||e.emit.apply(e,["mousemove"].concat(i(e.screenToGrid(t.offsetX,t.offsetY))))}),e.canvas.addEventListener("mouseup",function(t){s||e.emit.apply(e,["mouseup"].concat(i(e.screenToGrid(t.offsetX,t.offsetY)),[t.button+1]))});var g=0;return e.canvas.addEventListener("wheel",function(t){e.mouseMode.clicks&&(120===Math.abs(t.wheelDeltaY)?e.emit.apply(e,["mousewheel"].concat(i(e.screenToGrid(t.offsetX,t.offsetY)),[t.deltaY>0?1:-1])):(g-=t.wheelDeltaY,Math.abs(g)>=40&&(e.emit.apply(e,["mousewheel"].concat(i(e.screenToGrid(t.offsetX,t.offsetY)),[g>0?1:-1])),g=0)),t.preventDefault())}),e.canvas.addEventListener("contextmenu",function(t){e.mouseMode.clicks&&t.preventDefault(),u(t.offsetX,t.offsetY)}),e}return s(t,e),a(t,[{key:"scheduleSizeUpdate",value:function(){var e=this;clearTimeout(this._scheduledSizeUpdate),this._scheduledSizeUpdate=setTimeout(function(){return e.updateSize()},1)}},{key:"getFont",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(e.style||"normal")+" normal "+(e.weight||"normal")+" "+this.window.fontSize+"px "+this.window.fontFamily}},{key:"screenToGrid",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.getCellSize();return e=e/this._windowScale-this._padding,t=t/this._windowScale-this._padding,e=Math.floor((e+(n?i.width/2:0))/i.width),t=Math.floor(t/i.height),e=Math.max(0,Math.min(this.window.width-1,e)),t=Math.max(0,Math.min(this.window.height-1,t)),[e,t]}},{key:"gridToScreen",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.getCellSize();return[e*r.width,t*r.height].map(function(e){return n._padding+(i?e*n._windowScale:e)})}},{key:"getCharSize",value:function(){return this.ctx.font=this.getFont(),{width:Math.floor(this.ctx.measureText(" ").width),height:this.window.fontSize}}},{key:"getCellSize",value:function(){var e=this.getCharSize();return{width:Math.ceil(e.width*this.window.gridScaleX),height:Math.ceil(e.height*this.window.gridScaleY)}}},{key:"updateSize",value:function(){this._window.devicePixelRatio=Math.ceil(this._windowScale*(window.devicePixelRatio||1));var e=!1;for(var t in this.windowState)this.windowState.hasOwnProperty(t)&&this.windowState[t]!==this.window[t]&&(e=!0,this.windowState[t]=this.window[t]);if(e){var n=this.window,i=n.width,r=n.height,o=n.fitIntoWidth,s=n.fitIntoHeight,a=n.padding,l=this.getCellSize(),u=i*l.width,c=r*l.height,h=u;if(o&&s){var d=u/c;d<o/s?(c=s-2*a,u=c*d):(u=o-2*a,c=u/d)}this._windowScale=u/h,u+=2*a,c+=2*a,this._padding=a*(h/u);var f=this._window.devicePixelRatio=Math.ceil(this._windowScale*(window.devicePixelRatio||1));this.canvas.width=(i*l.width+2*Math.round(this._padding))*f,this.canvas.style.width=u+"px",this.canvas.height=(r*l.height+2*Math.round(this._padding))*f,this.canvas.style.height=c+"px",this.renderer.resetDrawn(),this.renderer.draw("update-size")}}},{key:"resetScreen",value:function(){var e=this.window,t=e.width,n=e.height;this.blinkingCellCount=0,this.screen.screen=new Array(t*n).fill(" "),this.screen.screenFG=new Array(t*n).fill(0),this.screen.screenBG=new Array(t*n).fill(0),this.screen.screenAttrs=new Array(t*n).fill(0)}},{key:"getNormalizedSelection",value:function(){var e=this.selection,t=e.start,n=e.end;if(t[1]>n[1]||t[1]===n[1]&&t[0]>n[0]){var i=[n,t];t=i[0],n=i[1]}return{start:t,end:n}}},{key:"isInSelection",value:function(e,t){var n=this.getNormalizedSelection(),i=n.start,r=n.end,o=i[0]<=e,s=e<r[0],a=t===i[1],l=t===r[1];return a&&l?o&&s:a?o:l?s:i[1]<t&&t<r[1]}},{key:"getSelectedText",value:function(){for(var e=this.window.width*this.window.height,t=[],n=-1,i=0;i<e;i++){var r=i%this.window.width,o=Math.floor(i/this.window.width);this.isInSelection(r,o)&&(n!==o&&(n=o,t.push("")),t[t.length-1]+=this.screen[i])}return t.join("\n")}},{key:"copySelectionToClipboard",value:function(){var e=this.getSelectedText();if(e){var t=c("textarea");document.body.appendChild(t),t.value=e,t.select(),document.execCommand("copy")?h.show("Copied to clipboard"):h.show("Failed to copy"),document.body.removeChild(t)}}},{key:"showNotification",value:function(e){if(console.info("Notification: "+e),window.Notification&&"granted"===window.Notification.permission){new window.Notification("ESPTerm",{body:e}).addEventListener("click",function(){return window.focus()})}else window.Notification&&"denied"!==window.Notification.permission?window.Notification.requestPermission():h.show(e)}},{key:"beep",value:function(){var e=this.audioCtx;if(e&&!(this._lastBeep&&this._lastBeep>Date.now()-50)){if(this._lastBeep=Date.now(),!this._convolver){this._convolver=e.createConvolver();for(var t=.8*e.sampleRate,n=e.createBuffer(2,t,e.sampleRate),i=0;i<t;i++)n.getChannelData(0)[i]=Math.pow(1-i/t,7+Math.random()),n.getChannelData(1)[i]=Math.pow(1-i/t,7+Math.random());this._convolver.buffer=n,this._convolver.connect(e.destination)}var r=e.createOscillator(),o=e.createGain();r.connect(o),o.gain.value=4,r.frequency.value=750,r.type="sine";var s=e.createOscillator(),a=e.createGain();s.connect(a),a.gain.value=2,s.frequency.value=400,s.type="sine",o.connect(this._convolver),a.connect(this._convolver);var l=e.currentTime;r.start(),r.stop(l+.5),s.start(l+.05),s.stop(l+.8);!function t(){e.currentTime<l+.8&&window.requestAnimationFrame(t),o.gain.value*=.8,a.gain.value*=.8}()}}},{key:"load",value:function(){var e,t=(e=this.parser).parse.apply(e,arguments),n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var l=s.value;switch(l.topic){case"screen-opts":l.width===this.window.width&&l.height===this.window.height||(this.window.width=l.width,this.window.height=l.height,this.resetScreen()),this.renderer.loadTheme(l.theme),this.renderer.setDefaultColors(l.defFG,l.defBG),this.cursor.visible=l.cursorVisible,this.emit.apply(this,["input-alts"].concat(i(l.inputAlts))),this.mouseMode.clicks=l.trackMouseClicks,this.mouseMode.movement=l.trackMouseMovement,this.emit("mouse-mode",l.trackMouseClicks,l.trackMouseMovement),this.selection.setSelectable(!l.trackMouseClicks&&!l.trackMouseMovement),this.cursor.blinking!==l.cursorBlinking&&(this.cursor.blinking=l.cursorBlinking,this.renderer.resetCursorBlink()),this.cursor.style=l.cursorStyle,this.bracketedPaste=l.bracketedPaste,this.reverseVideo=l.reverseVideo,this.window.debug&=1,this.window.debug|=+l.debugEnabled<<1,this.emit("TEMP:show-buttons",l.showButtons),this.emit("TEMP:show-links",l.showConfigLinks);break;case"cursor":this.cursor.x===l.x&&this.cursor.y===l.y&&this.cursor.hanging===l.hanging||(this.cursor.x=l.x,this.cursor.y=l.y,this.cursor.hanging=l.hanging,this.renderer.resetCursorBlink(),this.emit("cursor-moved"),this.renderer.scheduleDraw("cursor-moved"));break;case"title":this.emit("TEMP:update-title",l.title);break;case"button-labels":this.emit("button-labels",l.labels);break;case"backdrop":this.backgroundImage=l.image;break;case"bell":this.beep();break;case"internal":this.emit("internal",l);break;case"content":var u=l.frameX,c=l.frameY,h=l.frameWidth,d=l.frameHeight,f=l.cells;this._debug&&this.window.debug&&this._debug.pushFrame([u,c,h,d]);for(var v=0;v<f.length;v++){var m=f[v],g=v%h,w=Math.floor(v/h),y=(c+w)*this.window.width+u+g;this.screenAttrs[y]&p!==m[3]&p&&(m[3]&p?this.blinkingCellCount++:this.blinkingCellCount--),this.screen[y]=m[0],this.screenFG[y]=m[1],this.screenBG[y]=m[2],this.screenAttrs[y]=m[3]}this.window.debug&&console.log("Blinking cells: "+this.blinkingCellCount),this.renderer.scheduleDraw("load",16),this.emit("load");break;case"full-load-complete":this.emit("TEMP:hide-load-failed-msg");break;case"notification":this.showNotification(l.content);break;default:console.warn("Unhandled update",l)}}}catch(e){r=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw o}}}},{key:"backgroundImage",get:function(){return this.canvas.style.backgroundImage},set:function(e){this.canvas.style.backgroundImage=e?"url("+e+")":"",this.renderer.backgroundImage!==!!e&&(this.renderer.backgroundImage=!!e,this.renderer.resetDrawn(),this.renderer.scheduleDraw("background-image"))}}]),t}(l)},function(e,t,n){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){if(!e)return NaN;var t=e.codePointAt(0);return t>57343&&(t-=2048),t-1}var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(6),l=a.ATTR_FG,u=a.ATTR_BG,c=a.ATTR_BOLD,h=a.ATTR_UNDERLINE,d=a.ATTR_BLINK,f=a.ATTR_STRIKE,v=a.ATTR_OVERLINE,p=a.ATTR_FAINT;e.exports=function(){function e(){r(this,e),this.contentLoaded=!1}return s(e,[{key:"parseUpdate",value:function(e){for(var t=0,n=Array.from?Array.from(e):e.split(""),i=void 0,r=o(n[t++]),s=function(){for(i="";t<n.length;){var e=n[t++];if(""===e)break;i+=e}return i},a=[];t<n.length;){var m=n[t++];if("O"===m){var g=o(n[t++]),w=o(n[t++]),y=o(n[t++]),b=65535&o(n[t++])|(65535&o(n[t++]))<<16,k=65535&o(n[t++])|(65535&o(n[t++]))<<16,_=o(n[t++]),x=!!(1&_),C=[!!(4&_),!!(8&_),!!(16&_),!!(4096&_)],S=!!(32&_),T=!!(64&_),E=_>>9&7;E>0&&E--;var A=E>>1,L=!(1&E);A=0===A?"block":1===A?"line":"bar";var P=!!(128&_),R=!!(256&_),F=!!(8192&_),O=!!(16384&_),B=!!(2&_);a.push({topic:"screen-opts",width:w,height:g,theme:y,defFG:b,defBG:k,cursorVisible:x,cursorBlinking:L,cursorStyle:A,inputAlts:C,trackMouseClicks:S,trackMouseMovement:T,showButtons:P,showConfigLinks:R,bracketedPaste:F,reverseVideo:O,debugEnabled:B})}else if("C"===m){var D=o(n[t++]),M=o(n[t++]),I=!!o(n[t++]);a.push({topic:"cursor",x:M,y:D,hanging:I})}else if("T"===m)a.push({topic:"title",title:s()});else if("B"===m){for(var N=o(n[t++]),j=[],H=0;H<N;H++)i=s(),j.push(i);a.push({topic:"button-labels",labels:j})}else if("W"===m)a.push({topic:"backdrop",image:s()});else if("!"===m)a.push({topic:"bell"});else if("D"===m){var G=o(n[t++]),z=o(n[t++]),W=o(n[t++]),q=o(n[t++]),U=o(n[t++]),K=n[t++],V=n[t++],X=o(n[t++]),Y=o(n[t++]);a.push({topic:"internal",flags:G,cursorAttrs:z,regionStart:W,regionEnd:q,charsetGx:U,charsetG0:K,charsetG1:V,freeHeap:X,clientCount:Y})}else"S"===m&&function(){for(var e=o(n[t++]),i=o(n[t++]),r=o(n[t++]),s=o(n[t++]),m=7,g=0,w=0,y=0,b=" ",k=s*r,_=h|v|f,x=d,C=[],S=function(){var e=w&l,t=w&u,n=m,i=g,r=w;e||(n=0),t||(i=0),r&x&&(" "===b&&0==(r&_)||m===g&&e&&t)&&(r^=x),r&c&&!(r&p)&&e&&n<8&&(n+=8),C.push([b,n,i,r])};t<n.length&&y<k;){var T=n[t++],E=T.codePointAt(0),A=void 0,L=void 0;switch(E){case 2:L=o(n[t++]);for(var P=0;P<L&&(S(),!(++y>k));P++);break;case 1:y+=o(n[t++]);break;case 3:A=o(n[t++]),m=255&A,g=A>>8&255;break;case 4:A=o(n[t++]),w=65535&A;break;case 7:w=0;break;case 5:A=o(n[t++]),65536&A&&(A&=4095,A|=(4095&o(n[t++]))<<12,A+=256),m=A;break;case 6:A=o(n[t++]),65536&A&&(A&=4095,A|=(4095&o(n[t++]))<<12,A+=256),g=A;break;default:E<32&&(T="<EFBFBD>"),b=T,S(),y++}}a.push({topic:"content",frameX:i,frameY:e,frameWidth:s,frameHeight:r,cells:C})}();59&r&&!this.contentLoaded&&(a.push({topic:"full-load-complete"}),this.contentLoaded=!0)}return a}},{key:"parse",value:function(e){var t=e.substr(1),n=[];switch(e[0]){case"U":n.push.apply(n,i(this.parseUpdate(t)));break;case"G":return[{topic:"notification",content:t}];default:console.warn("Bad data message type; ignoring.\n"+JSON.stringify(e))}return n}}]),e}()},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),o=n(5),s=o.themes,a=o.buildColorTable,l=o.getColor,u=n(6),c=u.ATTR_FG,h=u.ATTR_BG,d=u.ATTR_BOLD,f=u.ATTR_UNDERLINE,v=u.ATTR_INVERSE,p=u.ATTR_BLINK,m=u.ATTR_ITALIC,g=u.ATTR_STRIKE,w=u.ATTR_OVERLINE,y=u.ATTR_FAINT,b=u.ATTR_FRAKTUR,k={C:"ℭ",H:"ℌ",I:"ℑ",R:"ℜ",Z:"ℨ"};e.exports=function(){function e(t){i(this,e),this.screen=t,this.ctx=t.ctx,this._palette=null,this.defaultBgNum=0,this.defaultFgNum=7,this.colorTable256=a(),this.resetDrawn(),this.blinkStyleOn=!1,this.blinkInterval=null,this.cursorBlinkOn=!1,this.cursorBlinkInterval=null,this.resetBlink(),this.resetCursorBlink()}return r(e,[{key:"resetDrawn",value:function(){this.screen.window&&this.screen.window.debug&&console.log("Resetting drawn screen"),this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.drawnCursor=[-1,-1,""]}},{key:"loadTheme",value:function(e){e in s&&(this.palette=s[e])}},{key:"setDefaultColors",value:function(e,t){e===this.defaultFgNum&&t===this.defaultBgNum||(this.resetDrawn(),this.defaultFgNum=e,this.defaultBgNum=t,this.scheduleDraw("default-colors"),this.screen.canvas.style.backgroundColor=this.getColor(t))}},{key:"scheduleDraw",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;clearTimeout(this._scheduledDraw),this._scheduledDraw=setTimeout(function(){return t.draw(e)},n)}},{key:"getColor",value:function(e){return l(e,this.palette)}},{key:"resetCursorBlink",value:function(){var e=this;this.cursorBlinkOn=!0,clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=setInterval(function(){e.cursorBlinkOn=!e.screen.cursor.blinking||!e.cursorBlinkOn,e.screen.cursor.blinking&&e.scheduleDraw("cursor-blink")},500)}},{key:"resetBlink",value:function(){var e=this;this.blinkStyleOn=!0,clearInterval(this.blinkInterval);var t=0;this.blinkInterval=setInterval(function(){e.screen.blinkingCellCount<=0||(t++,t>=4&&e.blinkStyleOn?(e.blinkStyleOn=!1,t=0,e.scheduleDraw("blink-style")):t>=1&&!e.blinkStyleOn&&(e.blinkStyleOn=!0,t=0,e.scheduleDraw("blink-style")))},200)}},{key:"drawBackground",value:function(e){var t=e.x,n=e.y,i=e.cellWidth,r=e.cellHeight,o=e.bg,s=e.isDefaultBG,a=this.ctx,l=this.screen.window,u=l.width,c=l.height,h=Math.round(this.screen._padding);a.fillStyle=this.getColor(o);var d=t*i+h,f=n*r+h,v=0===t||0===n||t===u-1||n===c-1,p=void 0,m=void 0,g=void 0,w=void 0;if(v){var y=d,b=f,k=d+i,_=f+r;0===t?y-=h:t===u-1&&(k+=h),0===n?b-=h:n===c-1&&(_+=h),p=y,m=b,g=k-y,w=_-b}else p=d,m=f,g=i,w=r;a.clearRect(p,m,g,w),(!s||o<0||!this.backgroundImage)&&a.fillRect(p,m,g,w)}},{key:"drawCharacter",value:function(t){var n=t.x,i=t.y,r=t.charSize,o=t.cellWidth,s=t.cellHeight,a=t.text,l=t.fg,u=t.attrs;if(a){var c=this.ctx,h=Math.round(this.screen._padding),d=!1,v=!1,p=!1;u&y&&(c.globalAlpha=.5),u&f&&(d=!0),u&b&&(a=e.alphaToFraktur(a)),u&g&&(v=!0),u&w&&(p=!0),c.fillStyle=this.getColor(l);var m=n*o+h,k=i*s+h,_=a.codePointAt(0);if(_>=9600&&_<=9631){c.beginPath();var x=m,C=k,S=o,T=s,E=o/2,A=s/2;if(9600===_)c.rect(x,C,S,A);else if(_<=9608){var L=(1-(_-9600)/8)*T;c.rect(x,C+L,S,T-L)}else if(_<=9615){var P=(_-9608)/8*S;c.rect(x,C,S-P,T)}else if(9616===_)c.rect(x+E,C,E,T);else if(_<=9619){var R=void 0,F=void 0,O=void 0;9617===_?(R=S/4,F=T/10,O=1):9618===_?(R=S/6,F=S/10,O=1):9619===_&&(R=S/4,F=S/7,O=2);for(var B=!1,D=0;D<T;D+=F){for(var M=0;M<S;M+=R){var I=Math.min(O,T-D);c.rect(x+(B?S-M-O:M),C+D,O,I)}B=!B}}else 9620===_?c.rect(x,C,S,T/8):9621===_?c.rect(x+7/8*S,C,S/8,T):9622===_?c.rect(x,C+A,E,A):9623===_?c.rect(x+E,C+A,E,A):9624===_?c.rect(x,C,E,A):9625===_?(c.rect(x,C,E,T),c.rect(x+E,C+A,E,A)):9626===_?(c.rect(x,C,E,A),c.rect(x+E,C+A,E,A)):9627===_?(c.rect(x,C,E,T),c.rect(x+E,C,E,A)):9628===_?(c.rect(x,C,S,A),c.rect(x+E,C+A,E,A)):9629===_?c.rect(x+E,C,E,A):9630===_?(c.rect(x,C+A,E,A),c.rect(x+E,C,E,A)):9631===_&&(c.rect(x,C+A,E,A),c.rect(x+E,C,E,T));c.fill()}else _>=57520&&_<=57523?(c.beginPath(),57520===_||57521===_?(c.moveTo(m,k),c.lineTo(m+o,k+s/2),c.lineTo(m,k+s)):57522!==_&&57523!==_||(c.moveTo(m+o,k),c.lineTo(m,k+s/2),c.lineTo(m+o,k+s)),_%2==0?c.fill():(c.strokeStyle=c.fillStyle,c.stroke())):c.fillText(a,m+.5*o,k+.5*s);if(d||v||p){if(c.strokeStyle=this.getColor(l),c.lineWidth=1,c.lineCap="round",c.beginPath(),d){var N=Math.round(k+r.height)+.5;c.moveTo(m,N),c.lineTo(m+o,N)}if(v){var j=Math.round(k+.5*s)+.5;c.moveTo(m,j),c.lineTo(m+o,j)}if(p){var H=Math.round(k)+.5;c.moveTo(m,H),c.lineTo(m+o,H)}c.stroke()}c.globalAlpha=1}}},{key:"getAdjacentCells",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.screen.window,i=n.width,r=n.height,o=i*r,s=[],a=-t;a<=t;a++)for(var l=-t;l<=t;l++)0===a&&0===l||s.push(e+a+l*i);return s.filter(function(e){return e>=0&&e<o})}},{key:"draw",value:function(e){var t=this,n=this.ctx,i=this.screen.window,r=i.width,o=i.height,s=i.devicePixelRatio,a=i.statusScreen;if(a)return this.drawStatus(a),void this.startDrawLoop();this.stopDrawLoop();var l=this.screen.getCharSize(),u=this.screen.getCellSize(),f=u.width,g=u.height,w=r*o;n.setTransform(s,0,0,s,0,0),this.screen.window.debug&&this.screen._debug&&this.screen._debug.drawStart(e),n.font=this.screen.getFont(),n.textAlign="center",n.textBaseline="middle";for(var y=d|m,b=new Map,k=new Map,_=0;_<w;_++){var x=_%r,C=Math.floor(_/r),S=this.cursorBlinkOn&&this.screen.cursor.x===x&&this.screen.cursor.y===C&&this.screen.cursor.visible,T=x===this.drawnCursor[0]&&C===this.drawnCursor[1],E=this.screen.isInSelection(x,C),A=this.screen.screen[_],L=0|this.screen.screenFG[_],P=0|this.screen.screenBG[_],R=0|this.screen.screenAttrs[_],F=!1;if(R&c||(L=this.defaultFgNum),R&h||(P=this.defaultBgNum,F=!0),R&v){var O=[P,L];L=O[0],P=O[1]}if(this.screen.reverseVideo){var B=[P,L];L=B[0],P=B[1]}R&p&&!this.blinkStyleOn&&(A=""),E&&(L=-1,P=-2);var D=A!==this.drawnScreen[_]||L!==this.drawnScreenFG[_]||P!==this.drawnScreenBG[_]||R!==this.drawnScreenAttrs[_]||S!==T||S&&this.screen.cursor.style!==this.drawnCursor[2]||S&&this.screen.cursor.hanging!==this.drawnCursor[3],M=R&y;b.has(M)||b.set(M,[]),b.get(M).push({cell:_,x:x,y:C,text:A,fg:L,bg:P,attrs:R,isCursor:S,inSelection:E,isDefaultBG:F}),k.set(_,D)}var I=new Map,N=function(e){return" "!==e&&n.measureText(e).width>=f+.05},j=!0,H=!1,G=void 0;try{for(var z,W=k.keys()[Symbol.iterator]();!(j=(z=W.next()).done);j=!0){var q=z.value;!function(e){var n=k.get(e)||I.get(e)||!1,i=t.screen.screen[e],r=N(i),o=r?2:1;if(!n){var s=!1,a=!0,l=!1,u=void 0;try{for(var c,h=t.getAdjacentCells(e,o)[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){var d=c.value;if(k.get(d)&&(t.screen.window.graphics<2||r||N(t.screen.screen[d]))){s=!0;break}}}catch(e){l=!0,u=e}finally{try{!a&&h.return&&h.return()}finally{if(l)throw u}}s&&(n=!0)}I.set(e,n)}(q)}}catch(e){H=!0,G=e}finally{try{!j&&W.return&&W.return()}finally{if(H)throw G}}if(this.screen.window.graphics>=1){var U=this.screen.window.debug&&this.screen._debug,K=Math.round(this.screen._padding);n.save(),n.beginPath();for(var V=0;V<o;V++){for(var X=null,Y=0;Y<r;Y++){var $=V*r+Y,J=I.get($);J&&null===X&&(X=Y),J||null===X||(n.rect(K+X*f,K+V*g,(Y-X)*f,g),U&&this.screen._debug.clipRect(X*f,V*g,(Y-X)*f,g),X=null)}null!==X&&(n.rect(K+X*f,K+V*g,(r-X)*f,g),U&&this.screen._debug.clipRect(X*f,V*g,(r-X)*f,g))}n.clip()}var Q=!0,Z=!1,ee=void 0;try{for(var te,ne=b.keys()[Symbol.iterator]();!(Q=(te=ne.next()).done);Q=!0){var ie=te.value,re=!0,oe=!1,se=void 0;try{for(var ae,le=b.get(ie)[Symbol.iterator]();!(re=(ae=le.next()).done);re=!0){var ue=ae.value,ce=ue.cell,he=ue.x,de=ue.y,fe=ue.text,ve=ue.bg,pe=ue.isDefaultBG;if(I.get(ce)&&(this.drawBackground({x:he,y:de,cellWidth:f,cellHeight:g,bg:ve,isDefaultBG:pe}),this.screen.window.debug&&this.screen._debug)){var me=+I.get(ce);me|=+k.get(ce)<<1,me|=+N(fe)<<2,this.screen._debug.setCell(ce,me)}}}catch(e){oe=!0,se=e}finally{try{!re&&le.return&&le.return()}finally{if(oe)throw se}}}}catch(e){Z=!0,ee=e}finally{try{!Q&&ne.return&&ne.return()}finally{if(Z)throw ee}}this.drawnCursor=[-1,-1,-1];var ge=!0,we=!1,ye=void 0;try{for(var be,ke=b.keys()[Symbol.iterator]();!(ge=(be=ke.next()).done);ge=!0){var _e=be.value,xe={};_e&d&&(xe.weight="bold"),_e&m&&(xe.style="italic"),n.font=this.screen.getFont(xe);var Ce=!0,Se=!1,Te=void 0;try{for(var Ee,Ae=b.get(_e)[Symbol.iterator]();!(Ce=(Ee=Ae.next()).done);Ce=!0){var Le=Ee.value,Pe=Le.cell,Re=Le.x,Fe=Le.y,Oe=Le.text,Be=Le.fg,De=Le.bg,Me=Le.attrs,Ie=Le.isCursor,Ne=Le.inSelection;if(I.get(Pe)&&(this.drawCharacter({x:Re,y:Fe,charSize:l,cellWidth:f,cellHeight:g,text:Oe,fg:Be,attrs:Me}),this.drawnScreen[Pe]=Oe,this.drawnScreenFG[Pe]=Be,this.drawnScreenBG[Pe]=De,this.drawnScreenAttrs[Pe]=Me,Ie&&(this.drawnCursor=[Re,Fe,this.screen.cursor.style,this.screen.cursor.hanging]),Ie&&!Ne)){n.save(),n.beginPath();var je=Re,He=Fe;this.screen.cursor.hanging&&(je+=1);var Ge=je*f+this.screen._padding,ze=He*g+this.screen._padding;if("block"===this.screen.cursor.style)n.rect(Ge,ze,f,g);else if("bar"===this.screen.cursor.style){n.rect(Ge,ze,2,g)}else if("line"===this.screen.cursor.style){n.rect(Ge,ze+l.height,f,2)}n.clip();var We=[De,Be];Be=We[0],De=We[1],Be===De&&(De=0===Be?7:0),this.drawBackground({x:je,y:He,cellWidth:f,cellHeight:g,bg:De}),this.drawCharacter({x:je,y:He,charSize:l,cellWidth:f,cellHeight:g,text:Oe,fg:Be,attrs:Me}),n.restore()}}}catch(e){Se=!0,Te=e}finally{try{!Ce&&Ae.return&&Ae.return()}finally{if(Se)throw Te}}}}catch(e){we=!0,ye=e}finally{try{!ge&&ke.return&&ke.return()}finally{if(we)throw ye}}this.screen.window.graphics>=1&&n.restore(),this.screen.window.debug&&this.screen._debug&&this.screen._debug.drawEnd(),this.screen.emit("draw",e)}},{key:"drawStatus",value:function(e){var t=this.ctx,n=this.screen.window,i=n.fontFamily,r=n.width,o=n.height,s=n.devicePixelRatio;this.drawnScreen=[];var a=this.screen.getCellSize(),l=r*a.width+2*this.screen._padding,u=o*a.height+2*this.screen._padding;if(t.setTransform(s,0,0,s,0,0),t.fillStyle=this.getColor(this.defaultBgNum),t.fillRect(0,0,l,u),t.font="24px "+i,t.fillStyle=this.getColor(this.defaultFgNum),t.textAlign="center",t.textBaseline="middle",t.fillText(e.title||"",l/2,u/2-50),e.loading){t.save(),t.translate(l/2,u/2+20),t.strokeStyle=this.getColor(this.defaultFgNum),t.lineWidth=5,t.lineCap="round";for(var c=Date.now()/1e3,h=0;h<12;h++){t.rotate(Math.PI/6);var d=(12*c-h)%12;t.globalAlpha=Math.max(.2,1-d/3),t.beginPath(),t.moveTo(0,15),t.lineTo(0,30),t.stroke()}t.restore()}}},{key:"startDrawLoop",value:function(){if(!this._drawTimerThread){var e=Math.random().toString(36);this._drawTimerThread=e,this.drawTimerLoop(e)}}},{key:"stopDrawLoop",value:function(){this._drawTimerThread=null}},{key:"drawTimerLoop",value:function(e){var t=this;e&&e===this._drawTimerThread&&(window.requestAnimationFrame(function(){return t.drawTimerLoop(e)}),this.draw("draw-loop"))}},{key:"palette",get:function(){return this._palette||s[0]},set:function(e){this._palette!==e&&(this._palette=e,this.resetDrawn(),this.scheduleDraw("palette"))}}],[{key:"alphaToFraktur",value:function(e){return e>="a"&&e<="z"?e=String.fromCodePoint(119997+e.charCodeAt(0)):e>="A"&&e<="Z"&&(e=k[e]||String.fromCodePoint(120003+e.charCodeAt(0))),e}}]),e}()},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(4),l=n(1),u=void 0;try{u=n(7)}catch(e){}e.exports=function(e){function t(e){i(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));n.screen=e,n.ws=null,n.heartbeatTimeout=null,n.pingInterval=null,n.xoff=!1,n.autoXoffTimeout=null,n.reconnTimeout=null,n.forceClosing=!1,n.queue=[];try{n.blobReader=new window.FileReader,n.blobReader.onload=function(e){n.onDecodedWSMessage(n.blobReader.result)},n.blobReader.onerror=function(e){console.error(e)}}catch(e){n.blobReader=null}return n.pageShown=!1,n.disconnectTimeout=null,document.addEventListener("visibilitychange",function(){!0===document.hidden?(console.info("Window lost focus, freeing socket"),n.disconnectTimeout=setTimeout(function(){n.closeSocket(),clearTimeout(n.heartbeatTimeout)},1e3)):(clearTimeout(n.disconnectTimeout),console.info("Window got focus, re-connecting"),n.init())},!1),n}return o(t,e),s(t,[{key:"onWSOpen",value:function(e){console.log("CONNECTED"),this.heartbeat(),this.send("i"),this.forceClosing=!1,this.emit("connect")}},{key:"onWSClose",value:function(e){var t=this;if(this.forceClosing)return void(this.forceClosing=!1);console.warn("SOCKET CLOSED, code "+e.code+". Reconnecting..."),e.code<1e3&&console.error("Bad code from socket!"),clearTimeout(this.reconnTimeout),this.reconnTimeout=setTimeout(function(){return t.init()},2e3),this.emit("disconnect",e.code)}},{key:"onDecodedWSMessage",value:function(e){var t=this;switch(e.charAt(0)){case".":break;case"-":this.xoff=!0,this.autoXoffTimeout=setTimeout(function(){t.xoff=!1,t.flushQueue()},250);break;case"+":this.xoff=!1,this.flushQueue(),clearTimeout(this.autoXoffTimeout);break;default:this.screen.load(e),this.pageShown||(window.showPage(),this.pageShown=!0)}this.heartbeat()}},{key:"onWSMessage",value:function(e){var t=this;if("string"==typeof e.data)this.onDecodedWSMessage(e.data);else{if(!this.blobReader)return void console.error("No FileReader!");1!==this.blobReader.readyState?this.blobReader.readAsText(e.data):setTimeout(function(){t.onWSMessage(e)},1)}}},{key:"canSend",value:function(){return!this.xoff}},{key:"send",value:function(e){return window._demo?(void 0!==window.demoInterface?u.input(e):console.log("TX: "+JSON.stringify(e)),!0):this.xoff?(console.log("Can't send, flood control. Queueing"),this.queue.push(e),!1):!!this.ws&&(1!==this.ws.readyState?(console.error("Socket not ready"),!1):("string"!=typeof e&&(e=JSON.stringify(e)),this.ws.send(e),!0))}},{key:"flushQueue",value:function(){console.log("Flushing input queue");var e=!0,t=!1,n=void 0;try{for(var i,r=this.queue[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){var o=i.value;this.send(o)}}catch(e){t=!0,n=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw n}}this.queue=[]}},{key:"closeSocket",value:function(){this.ws&&(this.forceClosing=!0,1===this.ws.readyState&&this.ws.close(),this.ws=null)}},{key:"init",value:function(){var e=this;if(window._demo)return void(void 0===window.demoInterface?window.alert("Demoing non-demo build!"):u.init(this.screen));clearTimeout(this.reconnTimeout),clearTimeout(this.heartbeatTimeout),this.closeSocket(),this.ws=new window.WebSocket("ws://"+window._root+"/term/update.ws"),this.ws.addEventListener("open",function(){return e.onWSOpen.apply(e,arguments)}),this.ws.addEventListener("close",function(){return e.onWSClose.apply(e,arguments)}),this.ws.addEventListener("message",function(){return e.onWSMessage.apply(e,arguments)}),console.log("Opening socket."),this.heartbeat(),this.emit("open")}},{key:"heartbeat",value:function(){var e=this;this.emit("heartbeat"),clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=setTimeout(function(){return e.onHeartbeatFail()},3e3)}},{key:"sendPing",value:function(){var e=this;console.log("> ping"),this.emit("ping"),l.get("http://"+window._root+"/api/v1/ping",function(t,n){200===n?(clearInterval(e.pingInterval),console.info("Server ready, opening socket…"),e.emit("ping-success"),e.init()):e.emit("ping-fail",n)},{timeout:100,loader:!1})}},{key:"onHeartbeatFail",value:function(){var e=this;this.closeSocket(),this.emit("silence"),console.error("Heartbeat lost, probing server..."),clearInterval(this.pingInterval),this.pingInterval=setInterval(function(){e.sendPing()},1e3),setTimeout(function(){e.sendPing()},200)}}]),t}(a)},function(e,t,n){"use strict";var i=n(0),r=i.encode2B;e.exports=function(e,t){function n(t){return e.send("s"+t)}function i(t){e.send("b"+String.fromCharCode(t+1))}function o(e){var i=e.allFn;window.addEventListener("keypress",function(e){if(b()&&!e.ctrlKey&&!e.metaKey){var t="";e.key&&1===e.key.length?t=e.key:e.which&&229!==e.which&&(t=String.fromCodePoint(e.which)),t.length>0&&t.charCodeAt(0)>=32&&(32===e.which&&e.preventDefault(),n(t))}}),window.addEventListener("keydown",x),window.addEventListener("copy",function(e){if(b()){var n=t.getSelectedText();n&&(e.preventDefault(),e.clipboardData.setData("text/plain",n))}}),window.addEventListener("paste",function(e){if(b()){e.preventDefault();var i=e.clipboardData.getData("text/plain");i.includes("\n")||i.length>90?(l.termUpload||console.error("input.termUpload is undefined"),l.termUpload.setContent(i),l.termUpload.open()):(t.bracketedPaste&&(i="[200~"+i+"[201~"),n(i))}}),v.all_fn=i}function s(e){o(e),window.addEventListener("mousedown",function(e){0===e.button&&(C=1),1===e.button&&(S=1),2===e.button&&(T=1)}),window.addEventListener("mouseup",function(e){0===e.button&&(C=0),1===e.button&&(S=0),2===e.button&&(T=0)})}function a(){return E}for(var l=void 0,u={3:"Cancel",6:"Help",8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",42:"Print",43:"Execute",44:"PrintScreen",45:"Insert",46:"Delete",58:":",59:";",60:"<",61:"=",62:">",63:"?",64:"@",91:"Meta",92:"Meta",93:"ContextMenu",106:"Numpad*",107:"Numpad+",109:"Numpad-",110:"Numpad.",111:"Numpad/",144:"NumLock",145:"ScrollLock",160:"^",161:"!",162:'"',163:"#",164:"$",165:"%",166:"&",167:"_",168:"(",169:")",170:"*",171:"+",172:"|",173:"-",174:"{",175:"}",176:"~",186:";",187:"=",188:"Numpad,",189:"-",190:"Numpad,",192:"`",194:"Numpad,",219:"[",220:"\\",221:"]",222:"'",224:"Meta"},c=48;c<=57;c++)u[c]=String.fromCharCode(c);for(var h=65;h<=90;h++)u[h]=String.fromCharCode(h);for(var d=112;d<=131;d++)u[d]="F"+(d-112+1);for(var f=96;f<=105;f++)u[f]="Numpad"+(f-96);for(var v={np_alt:!1,cu_alt:!1,fn_alt:!1,mt_click:!1,mt_move:!1,no_keys:!1,crlf_mode:!1,all_fn:!1},p=function(e,t){return v.fn_alt?e:t},m=function(e,t){return v.cu_alt?e:t},g=function(e,t){return v.np_alt?e:t},w={Backspace:"\b",Tab:"\t",Enter:function(){return v.crlf_mode?"\r\n":"\r"},"Control+Enter":"\n",Escape:"",ArrowUp:function(){return m("OA","")},ArrowDown:function(){return m("OB","")},ArrowRight:function(){return m("OC","")},ArrowLeft:function(){return m("OD","")},Home:function(){return m("OH",p("","[1~"))},Insert:"[2~",Delete:"[3~",End:function(){return m("OF",p("","[4~"))},PageUp:"[5~",PageDown:"[6~",F1:function(){return p("OP","[11~")},F2:function(){return p("OQ","[12~")},F3:function(){return p("OR","[13~")},F4:function(){return p("OS","[14~")},F5:"[15~",F6:"[17~",F7:"[18~",F8:"[19~",F9:"[20~",F10:"[21~",F11:"[23~",F12:"[24~","Shift+F1":function(){return p("O1;2P","[25~")},"Shift+F2":function(){return p("O1;2Q","[26~")},"Shift+F3":function(){return p("O1;2R","[28~")},"Shift+F4":function(){return p("O1;2S","[29~")},"Shift+F5":function(){return p("[15;2~","[31~")},"Shift+F6":function(){return p("[17;2~","[32~")},"Shift+F7":function(){return p("[18;2~","[33~")},"Shift+F8":function(){return p("[19;2~","[34~")},"Shift+F9":function(){return p("[20;2~","[35~")},"Shift+F10":function(){return p("[21;2~","[36~")},"Shift+F11":function(){return p("[22;2~","[37~")},"Shift+F12":function(){return p("[23;2~","[38~")},Numpad0:function(){return g("Op","0")},Numpad1:function(){return g("Oq","1")},Numpad2:function(){return g("Or","2")},Numpad3:function(){return g("Os","3")},Numpad4:function(){return g("Ot","4")},Numpad5:function(){return g("Ou","5")},Numpad6:function(){return g("Ov","6")},Numpad7:function(){return g("Ow","7")},Numpad8:function(){return g("Ox","8")},Numpad9:function(){return g("Oy","9")},"Numpad*":function(){return g("OR","*")},"Numpad+":function(){return g("Ol","+")},"Numpad-":function(){return g("OS","-")},"Numpad.":function(){return g("On",".")},"Numpad/":function(){return g("OQ","/")},"Control+]":"","Control+\\":"","Control+[":"","Control+^":"","Control+_":"","Control+ArrowLeft":"[1;5D","Control+ArrowRight":"[1;5C","Control+ArrowUp":"[1;5A","Control+ArrowDown":"[1;5B","Control+Home":"[1;5H","Control+End":"[1;5F","Shift+ArrowLeft":"[1;2D","Shift+ArrowRight":"[1;2C","Shift+ArrowUp":"[1;2A","Shift+ArrowDown":"[1;2B","Shift+Home":"[1;2H","Shift+End":"[1;2F","Alt+ArrowLeft":"b","Alt+ArrowRight":"f","Meta+ArrowLeft":"","Meta+ArrowRight":"","Alt+Backspace":"","Meta+Backspace":"","Control+Shift+C":function(){t.copySelectionToClipboard()},"Control+Insert":function(){t.copySelectionToClipboard()},"Control+F12":function(){t.window.debug^=1}},y=1;y<=26;y++)w["Control+"+String.fromCharCode(64+y)]=String.fromCharCode(y);var b=function(){return!v.no_keys&&!(document.activeElement instanceof window.HTMLTextAreaElement)},k=["F5","F11","F12","Shift+F5"],_={alt:!1,ctrl:!1,meta:!1,shift:!1},x=function(e){if(b()){var t=[];(e.altKey||_.alt)&&t.push("Alt"),(e.ctrlKey||_.ctrl)&&t.push("Control"),(e.metaKey||_.meta)&&t.push("Meta"),(e.shiftKey||_.shift)&&t.push("Shift");var i=u[e.which]||e.key;if(!e.ctrlKey&&!e.metaKey||"V"!==i){var r=null;for(var o in w){var s=o.split("+");if(s.pop()===i&&s.sort().join()===t.join()){if(k.includes(o)&&!v.all_fn)continue;r=w[o];break}}r&&(r instanceof Function&&(r=r()),e.preventDefault(),"string"==typeof r&&n(r))}}},C=0,S=0,T=0,E=0;return window.addEventListener("keydown",function(e){e.ctrlKey&&(E|=1),e.shiftKey&&(E|=2),e.altKey&&(E|=4),e.metaKey&&(E|=8)}),window.addEventListener("keyup",function(e){E=0,e.ctrlKey&&(E|=1),e.shiftKey&&(E|=2),e.altKey&&(E|=4),e.metaKey&&(E|=8)}),l={init:s,sendString:n,sendButton:i,setAlts:function(e,t,n,i){v.cu_alt===e&&v.np_alt===t&&v.fn_alt===n&&v.crlf_mode===i||(v.cu_alt=e,v.np_alt=t,v.fn_alt=n,v.crlf_mode=i)},setMouseMode:function(e,t){v.mt_click=e,v.mt_move=t},onMouseMove:function(t,n){if(v.mt_move){var i=C?1:S?2:T?3:0,o=a();e.send("m"+r(n)+r(t)+r(i)+r(o))}},onMouseDown:function(t,n,i){if(v.mt_click&&!(i>3||i<1)){var o=a();e.send("p"+r(n)+r(t)+r(i)+r(o))}},onMouseUp:function(t,n,i){if(v.mt_click&&!(i>3||i<1)){var o=a();e.send("r"+r(n)+r(t)+r(i)+r(o))}},onMouseWheel:function(t,n,i){if(v.mt_click){var o=a(),s=i<0?4:5;e.send("p"+r(n)+r(t)+r(s)+r(o))}},blockKeys:function(e){v.no_keys=e},handleKeyDown:x,softModifiers:_}}},function(e,t,n){"use strict";var i=n(1),r=n(0),o=r.qs,s=n(2);e.exports=function(e,t,n){function r(){l("Ready..."),s.show("#fu_modal",a),i("#fu_form").toggleClass("busy",!1),t.blockKeys(!0)}function a(){console.log("Upload modal closed."),clearTimeout(p),v=0,t.blockKeys(!1)}function l(e){o("#fu_prog").textContent=e}function u(){var e=o("#fu_text").value;if(!e.length)return void d();f=e.split("\n"),v=0,y=0,m=+o("#fu_delay").value,m<0&&(m=0,o("#fu_delay").value=m),g={CR:"\r",LF:"\n",CRLF:"\r\n"}[o("#fu_crlf").value],i("#fu_form").toggleClass("busy",!0),l("Starting..."),c()}function c(){if(i("#fu_modal").hasClass("visible")){if(!e.canSend())return void(p=setTimeout(c,1));0===y&&(w="",0===v&&n.bracketedPaste&&(w="[200~"),w+=f[v++]+g,v===f.length&&n.bracketedPaste&&(w+="[201~"));var r=+o("#fu_chunk").value;(0===r||r>b)&&(r=b);var s=void 0;if(w.length-y<=r?(s=w.substr(y,r),y=0):(s=w.substr(y,r),y+=r),!t.sendString(s))return void l("FAILED!");var a=Math.round(v/f.length*1e3)/10;l(v+" / "+f.length+" ("+a+"%)"),f.length>v||y>0?p=setTimeout(c,m):h()}}function h(){e.canSend()?(l("Done."),d()):(l("Waiting for Tx buffer..."),setTimeout(h,100))}function d(){s.hide("#fu_modal")}var f=void 0,v=void 0,p=void 0,m=void 0,g=void 0,w=void 0,y=void 0,b=128;return{init:function(){o("#fu_file").addEventListener("change",function(e){var t=new window.FileReader,n=e.target.files[0],i=n.type||"application/octet-stream";if(console.log("Selected file type: "+i),!i.match(/text\/.*|application\/(json|csv|.*xml.*|.*script.*|x-php)/)&&!window.confirm("This does not look like a text file: "+i+"\nReally load?"))return void(o("#fu_file").value="");t.onload=function(e){var t=e.target.result.replace(/[\r\n]+/,"\n");o("#fu_text").value=t},console.log("Loading file..."),t.readAsText(n)},!1),o("#term-fu-open").addEventListener("click",function(e){e.preventDefault(),r()}),o("#term-fu-start").addEventListener("click",function(e){e.preventDefault(),u()}),o("#term-fu-close").addEventListener("click",function(e){e.preventDefault(),d()})},open:r,setContent:function(e){o("#fu_text").value=e}}}},function(e,t,n){"use strict";var i=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=n(0),o=r.qs;e.exports=function(e,t){var n=o("#softkb-input");if(n){var r=document.createElement("div");r.id="keyboard-shortcut-bar",navigator.userAgent.match(/iPad|iPhone|iPod/)&&o("#screen").appendChild(r);var s=!1,a=function(){if(s){var t=e.gridToScreen(e.cursor.x,e.cursor.y,!0),r=i(t,2),o=r[0],a=r[1];n.style.transform="translate("+o+"px, "+a+"px)"}};n.addEventListener("focus",function(){s=!0,a(),r.classList.add("open")}),n.addEventListener("blur",function(){s=!1,r.classList.remove("open")}),e.on("cursor-moved",a),o("#term-kb-open").addEventListener("click",function(e){e.preventDefault(),n.focus()});var l="",u=function(e){null===e&&(e="");var n=!1;e.length>l.length?e.startsWith(l)?t.sendString(e.substr(l.length)):n=!0:e.length<l.length?l.startsWith(e)?t.sendString("\b".repeat(l.length-e.length)):n=!0:e!==l&&(n=!0),n&&t.sendString("\b".repeat(l.length)+e),l=e};n.addEventListener("keydown",function(e){"Unidentified"!==e.key&&(n.value="",e.stopPropagation(),t.handleKeyDown(e))}),n.addEventListener("keypress",function(e){e.stopPropagation()}),n.addEventListener("input",function(e){e.stopPropagation(),e.isComposing&&"data"in e?u(e.data):e.isComposing?u(n.value):"insertCompositionText"===e.inputType?t.sendString(e.data):"deleteContentBackward"===e.inputType?(l="",u("")):"insertText"===e.inputType&&t.sendString(e.data)}),n.addEventListener("compositionstart",function(e){l=""}),n.addEventListener("compositionend",function(e){l="",n.value=""}),e.on("open-soft-keyboard",function(){return n.focus()});var c={Control:"ctrl",Esc:27,Tab:9,"←":37,"↓":40,"↑":38,"→":39},h=!1;for(var d in c)!function(e){var n=document.createElement("button");n.classList.add("shortcut-button"),n.textContent=e,r.appendChild(n);var i=c[e];"string"==typeof i&&n.classList.add("modifier"),n.addEventListener("touchstart",function(e){h=!1,"string"==typeof i&&(t.softModifiers[i]=!0,n.classList.add("enabled"),e.preventDefault())}),window.addEventListener("touchmove",function(e){h=!0}),n.addEventListener("touchend",function(e){if(e.preventDefault(),"number"==typeof i){if(h)return;var r={which:i,preventDefault:function(){}};t.handleKeyDown(r)}else"string"==typeof i&&(n.classList.remove("enabled"),t.softModifiers[i]=!1)})}(d)}}},function(e,t,n){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var r=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=n(0),s=o.mk;e.exports=function(e,t){var n=s("canvas"),o=n.getContext("2d");n.classList.add("debug-canvas");var a=null,l=void 0,u=function(t){a=e.screenToGrid(t.offsetX,t.offsetY),k(),l()},c=function(){return a=null},h=function(){n.parentNode||(e.canvas.parentNode.appendChild(n),e.canvas.addEventListener("mousemove",u),e.canvas.addEventListener("mouseout",c))},d=function(){n.parentNode&&(n.parentNode.removeChild(n),e.canvas.removeEventListener("mousemove",u),e.canvas.removeEventListener("mouseout",c),c())},f=function(){var t=e.window,i=t.width,r=t.height,o=t.devicePixelRatio,s=e.getCellSize();n.width=i*s.width*o,n.height=r*s.height*o,n.style.width=i*s.width+"px",n.style.height=r*s.height+"px"},v=s("div");v.classList.add("draw-info");var p=void 0,m=void 0,g=void 0,w=new Map,y=[],b=[],k=void 0;e._debug={drawStart:function(e){g=e,p=Date.now(),y=[]},drawEnd:function(){m=Date.now(),v.textContent="Draw: "+g+" ("+(m-p)+" ms), fancy_gfx="+e.window.graphics,k()},setCell:function(e,t){w.set(e,[t,Date.now()])},clipRect:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];y.push(t)},pushFrame:function(e){e.push(Date.now()),b.push(e),k()}};var _=void 0,x=document.createElement("canvas");x.width=x.height=12;var C=x.getContext("2d");C.lineWidth=1,C.strokeStyle="#00f",C.beginPath(),C.moveTo(0,0),C.lineTo(-4,12),C.moveTo(4,0),C.lineTo(0,12),C.moveTo(8,0),C.lineTo(4,12),C.moveTo(12,0),C.lineTo(8,12),C.moveTo(16,0),C.lineTo(12,12),C.stroke(),_=o.createPattern(x,"repeat");var S=!1,T=0,E=0,A=function t(){S&&window.requestAnimationFrame(t);var n=(Date.now()-T)/1e3;T=Date.now(),E+=n;var s=e.window,l=s.devicePixelRatio,u=s.width,c=s.height,h=e.getCellSize(),f=h.width,v=h.height,p=u*c,m=Date.now();o.setTransform(l,0,0,l,0,0),o.clearRect(0,0,u*f,c*v);for(var g=0,k=0;k<p;k++)if(w.has(k)&&0!==w.get(k)[0]){var x=w.get(k),C=r(x,2),A=C[0],L=C[1],P=(m-L)/1e3;if(!(P>1)){g++,o.globalAlpha=.5*Math.max(0,1-P);var R=k%u,F=Math.floor(k/u);1&A&&(o.fillStyle="#f0f"),2&A&&(o.fillStyle="#0f0"),o.fillRect(R*f,F*v,f,v),4&A&&(o.lineWidth=2,o.strokeStyle="#f00",o.strokeRect(R*f,F*v,f,v))}}if(y.length){o.globalAlpha=.5,o.beginPath();var O=!0,B=!1,D=void 0;try{for(var M,I=y[Symbol.iterator]();!(O=(M=I.next()).done);O=!0){var N=M.value;o.rect.apply(o,i(N))}}catch(e){B=!0,D=e}finally{try{!O&&I.return&&I.return()}finally{if(B)throw D}}o.fillStyle=_,o.fill()}var j=!1;if(b.length){var H=[],G=!0,z=!1,W=void 0;try{for(var q,U=b[Symbol.iterator]();!(G=(q=U.next()).done);G=!0){var K=q.value,V=K[4],X=Date.now()-V;X>1e3?H.push(K):(j=!0,o.globalAlpha=1-X/1e3,o.strokeStyle="#ff0",o.lineWidth=2,o.strokeRect(K[0]*f,K[1]*v,K[2]*f,K[3]*v))}}catch(e){z=!0,W=e}finally{try{!G&&U.return&&U.return()}finally{if(z)throw W}}var Y=!0,$=!1,J=void 0;try{for(var Q,Z=H[Symbol.iterator]();!(Y=(Q=Z.next()).done);Y=!0){var ee=Q.value;b.splice(b.indexOf(ee),1)}}catch(e){$=!0,J=e}finally{try{!Y&&Z.return&&Z.return()}finally{if($)throw J}}}a&&(o.save(),o.globalAlpha=1,o.lineWidth=1+.5*Math.sin(10*E),o.strokeStyle="#fff",o.lineJoin="round",o.setLineDash([2,2]),o.lineDashOffset=10*E,o.strokeRect(a[0]*f,a[1]*v,f,v),o.lineDashOffset+=2,o.strokeStyle="#000",o.strokeRect(a[0]*f,a[1]*v,f,v),o.restore()),0!==g||a||j||(S=!1,d())};k=function(){S||(h(),f(),S=!0,T=Date.now(),A())};var L=s("div");L.classList.add("debug-toolbar");var P=!1,R=s("div");R.classList.add("heartbeat"),R.textContent="❤",L.appendChild(R);var F=s("div");F.classList.add("data-display"),L.appendChild(F);var O=s("div");O.classList.add("internal-display"),L.appendChild(O),L.appendChild(v);var B=s("div");B.classList.add("toolbar-buttons"),L.appendChild(B),t.on("heartbeat",function(){R.classList.remove("beat"),window.requestAnimationFrame(function(){R.classList.add("beat")})});var D=s("button");D.textContent="Redraw",D.addEventListener("click",function(t){e.renderer.resetDrawn(),e.renderer.draw("debug-redraw")}),B.appendChild(D);var M=s("button");M.textContent="Toggle Fancy Graphics",M.addEventListener("click",function(t){e.window.graphics=+!e.window.graphics}),B.appendChild(M);var I=function(){e.canvas.parentNode.appendChild(L)},N=function(){L.parentNode.removeChild(L)};e.on("update-window:debug",function(e){e!==P&&(P=e,e?I():(N(),d()))});var j=function(e){var t=e.toString(16);(1&e||2&e)&&(t+=":has(",1&e&&(t+="fg"),2&e&&(t+=(1&e?",":"")+"bg"),t+=")");var n=[];return 4&e&&n.push("\\[bold]bold\\()"),8&e&&n.push("\\[underline]underln\\()"),16&e&&n.push("\\[invert]invert\\()"),32&e&&n.push("blink"),64&e&&n.push("\\[italic]italic\\()"),128&e&&n.push("\\[strike]strike\\()"),256&e&&n.push("\\[overline]overln\\()"),512&e&&n.push("\\[faint]faint\\()"),1024&e&&n.push("fraktur"),n.length&&(t+=":"+n.join()),t.trim()},H=function(e){return e<256?e:"#"+("000000"+(e-256).toString(16)).substr(-6)},G=function(t){if(t<0||t>e.screen.length)return"(-)";var n=0|e.renderer.drawnScreenAttrs[t],i=0|e.renderer.drawnScreenFG[t],r=0|e.renderer.drawnScreenBG[t],o=H(i),s=H(r);o+="\\[color="+e.renderer.getColor(i).replace(/ /g,"")+"]●\\[]",s+="\\[color="+e.renderer.getColor(r).replace(/ /g,"")+"]●\\[]";var a=0|(e.renderer.drawnScreen[t]||"").codePointAt(0),l=a.toString(16).toUpperCase();l.length<4&&(l=("0000"+l).substr(-4)),l="U+"+l;var u=t%e.window.width;return"(("+Math.floor(t/e.window.width)+","+u+")="+t+":\\[bold]"+l+"\\[]:F"+o+":B"+s+":A("+j(n)+"))"},z=function(e,t){e.innerHTML="";for(var n=void 0,i={},r=function(t){var n=s("span");e.appendChild(n),n.textContent=t;for(var r in i)n[r]=i[r]};n=t.match(/\\\[(.*?)\]/);){n.index>0&&r(t.substr(0,n.index)),i={style:""};var o=n[1].split(" "),a=!0,l=!1,u=void 0;try{for(var c,h=o[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){var d=c.value;if(d){var f=void 0,v=void 0;d.indexOf("=")>-1?(f=d.substr(0,d.indexOf("=")),v=d.substr(d.indexOf("=")+1)):(f=d,v=!0),"bold"===f&&(i.style+="font-weight:bold;"),"italic"===f&&(i.style+="font-style:italic;"),"underline"===f&&(i.style+="text-decoration:underline;"),"invert"===f&&(i.style+="background:#000;filter:invert(1);"),"strike"===f&&(i.style+="text-decoration:line-through;"),"overline"===f&&(i.style+="text-decoration:overline;"),"faint"===f?i.style+="opacity:0.5;":"color"===f?i.style+="color:"+v+";":i[f]=v}}}catch(e){l=!0,u=e}finally{try{!a&&h.return&&h.return()}finally{if(l)throw u}}t=t.substr(n.index+n[0].length)}t&&r(t)},W={};l=function(){if(P){var t="C(("+e.cursor.y+","+e.cursor.x+"),hang:"+e.cursor.hanging+",vis:"+e.cursor.visible+")";if(a&&(t+=" m"+G(a[1]*e.window.width+a[0])),z(F,t),"flags"in W){var n=" ";n+=" flags:"+W.flags.toString(2),n+=" curAttrs:"+W.cursorAttrs.toString(2),n+=" Region:"+W.regionStart+"->"+W.regionEnd,n+=" Charset:"+W.charsetGx+" (0:"+W.charsetG0+",1:"+W.charsetG1+")",n+=" Heap:"+W.freeHeap,n+=" Clients:"+W.clientCount,z(O,n)}}},e.on("draw",l),e.on("internal",function(e){W=e,l()})}},function(e,t,n){"use strict";var i=n(0),r=i.qs;e.exports=function(e){var t=r("#action-buttons"),n=[],i=[],o=function(){var n=document.createElement("button");return n.classList.add("action-button"),n.setAttribute("data-n",i.length),i.push(n),t.appendChild(n),n.addEventListener("click",function(t){var i=+n.getAttribute("data-n");e.sendButton(i),t.target.blur()}),n.addEventListener("mouseleave",function(e){e.target.blur()}),n},s=function(){var e=i.pop();e.parentNode.removeChild(e)},a=function(){if(n.length>i.length)for(var e=i.length;e<n.length;e++)o();else if(i.length>n.length)for(var t=n.length;t<=i.length;t++)s();for(var r=0;r<n.length;r++){var a=n[r].trim(),l=i[r];l.textContent=a||" ",a?l.classList.remove("inactive"):l.classList.add("inactive")}};return{update:a,get labels(){return n},set labels(e){n=e,a()}}}},function(e,t,n){"use strict";function i(){return+s("#theme").val()}function r(){var e=u(".color-example"),t=s("#default_fg").val(),n=s("#default_bg").val();/^\d+$/.test(t)?t=+t:/^#[\da-f]{6}$/i.test(t)||(t="black"),/^\d+$/.test(n)?n=+n:/^#[\da-f]{6}$/i.test(n)||(n="black");var r=i();e.dataset.fg=t,e.dataset.bg=n,a.themePreview(r),s(".colorprev.fg span").css("background",a.toHex(n,r))}var o=n(26),s=n(1),a=n(5),l=n(0),u=l.qs;t.init=function(){s("#theme").on("change",r),s("#default_fg").on("input",r),s("#default_bg").on("input",r);var e={padding:10,event:"drag",uppercase:!0,trianglePointerSize:20,size:200,parseColor:function(e){return a.toHex(e,i())}};o.initInput(u("#default_fg"),e),o.initInput(u("#default_bg"),e),s(".colorprev.bg span").on("click",function(){var e=this.dataset.bg;void 0!==e&&s("#default_bg").val(e),r()}),s(".colorprev.fg span").on("click",function(){var e=this.dataset.fg;void 0!==e&&s("#default_fg").val(e),r()});for(var t=s("#fgbg_presets"),n=0;n<a.fgbgThemes.length;n++){var l=a.fgbgThemes[n],c=l[0],h=l[1],d=l[2],f=l[3];t.htmlAppend('<span class="preset" data-xfg="'+c+'" data-xbg="'+h+'" style="color:'+c+";background:"+h+'" title="'+f+'">&nbsp;'+d+"&nbsp;</span>"),(n+1)%5==0&&t.htmlAppend("<br>")}s(".preset").on("click",function(){s("#default_fg").val(this.dataset.xfg),s("#default_bg").val(this.dataset.xbg),r()}),r()},t.nextTheme=function(){var e=u("#theme"),t=e.selectedIndex;e.options[++t%e.options.length].selected=!0,r()},t.prevTheme=function(){var e=u("#theme"),t=e.selectedIndex;e.options[(e.options.length+--t)%e.options.length].selected=!0,r()}},function(e,t,n){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){for(var n=0;n<e;n++)t(n)}function l(e,t){if(e.length)a(e.length,function(n){t(e[n],n)});else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),c=n(4),h=n(8),d=h.rgb2hex,f=h.hex2rgb,v=h.hsl2rgb,p=h.rgb2hsl,m=window,g=document,w=Math,y=2*w.PI;e.exports=function(e){function t(e,n){r(this,t);var i=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.options={size:150,padding:8,triangleSize:.8,wheelPointerColor1:"#444",wheelPointerColor2:"#eee",trianglePointerSize:16,trianglePointerColor1:"#eee",trianglePointerColor2:"#444",background:"transparent"},i.pixelRatio=window.devicePixelRatio,i.setOptions(n),i.calculateProperties(),i.createContainer(),i.createTriangle(),i.createWheel(),i.createWheelPointer(),i.createTrianglePointer(),i.attachEvents(),e=e||"#f00","string"==typeof e&&i.setHEX(e),i}return s(t,e),u(t,[{key:"calculateProperties",value:function(){var e=this.options;this.padding=e.padding,this.innerSize=e.size-2*e.padding,this.triangleSize=e.triangleSize*this.innerSize,this.wheelThickness=(this.innerSize-this.triangleSize)/2,this.wheelPointerSize=e.wheelPointerSize||this.wheelThickness,this.wheelRadius=this.innerSize/2,this.triangleRadius=this.triangleSize/2,this.triangleSideLength=w.sqrt(3)*this.triangleRadius}},{key:"calculatePositions",value:function(){var e=this.triangleRadius,t=this.hue,n=y/3,i=this.saturation,r=this.lightness,o=this.hx=w.cos(t)*e,s=this.hy=-w.sin(t)*e,a=this.sx=w.cos(t-n)*e,l=this.sy=-w.sin(t-n)*e,u=this.vx=w.cos(t+n)*e,c=this.vy=-w.sin(t+n)*e,h=(a+u)/2,d=(l+c)/2,f=(1-2*w.abs(r-.5))*i;this.x=a+(u-a)*r+(o-h)*f,this.y=l+(c-l)*r+(s-d)*f}},{key:"createContainer",value:function(){var e=this.container=g.createElement("div");e.className="color-triangle",e.style.display="block",e.style.padding=this.padding+"px",e.style.position="relative",e.style.boxShadow="0 1px 10px black",e.style.borderRadius="5px",e.style.width=e.style.height=this.innerSize+2*this.padding+"px",e.style.background=this.options.background}},{key:"createWheel",value:function(){var e=this.wheel=g.createElement("canvas");e.width=e.height=this.innerSize*this.pixelRatio,e.style.width=e.style.height=this.innerSize+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",e.style.left=e.style.top=this.padding+"px",this.drawWheel(e.getContext("2d")),this.container.appendChild(e)}},{key:"drawWheel",value:function(e){var t=void 0,n=void 0;for(e.save(),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),e.translate(this.wheelRadius,this.wheelRadius),t=this.wheelRadius-this.triangleRadius,n=0;n<360;n++)e.rotate(y/-360),e.beginPath(),e.fillStyle="hsl("+n+", 100%, 50%)",e.arc(this.wheelRadius-t/2,0,t/2,0,y,!0),e.fill();e.restore()}},{key:"createTriangle",value:function(){var e=this.triangle=g.createElement("canvas");e.width=e.height=this.innerSize*this.pixelRatio,e.style.width=e.style.height=this.innerSize+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",e.style.left=e.style.top=this.padding+"px",this.triangleCtx=e.getContext("2d"),this.container.appendChild(e)}},{key:"drawTriangle",value:function(){var e=this.hx,t=this.hy,n=this.sx,i=this.sy,r=this.vx,o=this.vy,s=this.innerSize,a=this.triangleCtx;a.clearRect(0,0,s*this.pixelRatio,s*this.pixelRatio),a.save(),a.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),a.translate(this.wheelRadius,this.wheelRadius),a.beginPath(),a.moveTo(e,t),a.lineTo(n,i),a.lineTo(r,o),a.closePath(),a.clip(),a.fillStyle="#000",a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s);var l=a.createLinearGradient(e,t,(n+r)/2,(i+o)/2),u="hsla("+w.round(this.hue*(360/y))+", 100%, 50%, ";l.addColorStop(0,u+"1)"),l.addColorStop(1,u+"0)"),a.fillStyle=l,a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s);var c=a.createLinearGradient(r,o,(e+n)/2,(t+i)/2);c.addColorStop(0,"#fff"),c.addColorStop(1,"rgba(255, 255, 255, 0)"),a.globalCompositeOperation="lighter",a.fillStyle=c,a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s),a.restore()}},{key:"createWheelPointer",value:function(){var e=this.wheelPointer=g.createElement("canvas"),t=this.wheelPointerSize;e.width=e.height=t*this.pixelRatio,e.style.width=e.style.height=t+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",this.drawPointer(e.getContext("2d"),t/2,this.options.wheelPointerColor1,this.options.wheelPointerColor2),this.container.appendChild(e)}},{key:"moveWheelPointer",value:function(){var e=this.wheelPointerSize/2,t=this.wheelPointer.style;t.top=this.padding+this.wheelRadius-w.sin(this.hue)*(this.triangleRadius+this.wheelThickness/2)-e+"px",t.left=this.padding+this.wheelRadius+w.cos(this.hue)*(this.triangleRadius+this.wheelThickness/2)-e+"px"}},{key:"createTrianglePointer",value:function(){var e=this.trianglePointer=g.createElement("canvas"),t=this.options.trianglePointerSize;e.width=e.height=t*this.pixelRatio,e.style.width=e.style.height=t+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",this.drawPointer(e.getContext("2d"),t/2,this.options.trianglePointerColor1,this.options.trianglePointerColor2),this.container.appendChild(e)}},{key:"moveTrianglePointer",value:function(e,t){var n=this.trianglePointer.style,i=this.options.trianglePointerSize/2;n.top=this.y+this.wheelRadius+this.padding-i+"px",n.left=this.x+this.wheelRadius+this.padding-i+"px"}},{key:"drawPointer",value:function(e,t,n,i){e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),e.fillStyle=i,e.beginPath(),e.arc(t,t,t,0,y,!0),e.fill(),e.fillStyle=n,e.beginPath(),e.arc(t,t,t-2,0,y,!0),e.fill(),e.fillStyle=i,e.beginPath(),e.arc(t,t,t/4+2,0,y,!0),e.fill(),e.globalCompositeOperation="destination-out",e.beginPath(),e.arc(t,t,t/4,0,y,!0),e.fill()}},{key:"inject",value:function(e){e.appendChild(this.container)}},{key:"getRelativeCoordinates",value:function(e){var t=this.triangle,n=t.getBoundingClientRect();return{x:e.clientX-n.x,y:e.clientY-n.y}}},{key:"dispose",value:function(){var e=this.container.parentNode;e&&e.removeChild(this.container)}},{key:"getElement",value:function(){return this.container}},{key:"getCSS",value:function(){return"hsl("+Math.round(this.hue*(360/y))+", "+Math.round(100*this.saturation)+"%, "+Math.round(100*this.lightness)+"%)"}},{key:"getHEX",value:function(){return d.apply(void 0,i(this.getRGB()))}},{key:"setHEX",value:function(e){this.setRGB.apply(this,i(f(e)))}},{key:"getRGB",value:function(){return v.apply(void 0,i(this.getHSL()))}},{key:"setRGB",value:function(e,t,n){this.setHSL.apply(this,i(p(e,t,n)))}},{key:"getHSL",value:function(){return[this.hue,this.saturation,this.lightness]}},{key:"setHSL",value:function(e,t,n){this.hue=e,this.saturation=t,this.lightness=n,this.initColor()}},{key:"initColor",value:function(){this.calculatePositions(),this.moveWheelPointer(),this.drawTriangle(),this.moveTrianglePointer()}},{key:"attachEvents",value:function(){var e=this;this.down=null;var t=function(t){t.stopPropagation(),t.preventDefault(),g.body.addEventListener("mousemove",n,!1),g.body.addEventListener("mouseup",i,!1);var r=e.getRelativeCoordinates(t);e.map(r.x,r.y)},n=function(t){var n=e.getRelativeCoordinates(t);e.move(n.x,n.y)},i=function t(i){e.down&&(e.down=null,e.emit("dragend")),g.body.removeEventListener("mousemove",n,!1),g.body.removeEventListener("mouseup",t,!1)};this.container.addEventListener("mousedown",t,!1),this.container.addEventListener("mousemove",n,!1)}},{key:"map",value:function(e,t){var n=e,i=t;e-=this.wheelRadius,t-=this.wheelRadius;var r=w.sqrt(e*e+t*t);r>this.triangleRadius&&r<this.wheelRadius?(this.down="wheel",this.emit("dragstart"),this.move(n,i)):r<this.triangleRadius&&(this.down="triangle",this.emit("dragstart"),this.move(n,i))}},{key:"move",value:function(e,t){if(this.down){e-=this.wheelRadius,t-=this.wheelRadius;var n=w.atan2(-t,e);if(n<0&&(n+=y),"wheel"===this.down)this.hue=n,this.initColor(),this.emit("drag");else if("triangle"===this.down){var i=(n+y-this.hue)%y,r=i%(y/3)-y/6,o=.5*this.triangleRadius,s=w.tan(r)*o,a=w.sqrt(e*e+t*t),l=w.sqrt(o*o+s*s);if(a>l){var u=w.tan(r)*a,c=w.atan(u/l);c>y/6?c=y/6:c<-y/6&&(c=-y/6),n+=c-r,i=(n+y-this.hue)%y,r=i%(y/3)-y/6,s=w.tan(r)*o,a=l=w.sqrt(o*o+s*s)}e=w.round(w.cos(n)*a),t=w.round(-w.sin(n)*a);var h=this.lightness=w.sin(i)*a/this.triangleSideLength+.5,d=1-2*w.abs(h-.5),f=this.saturation=(w.cos(i)*a+this.triangleRadius/2)/(1.5*this.triangleRadius)/d;f=w.max(0,f),f=w.min(1,f),this.lightness=h,this.saturation=f,this.x=e,this.y=t,this.moveTrianglePointer(),this.emit("drag")}}}},{key:"setOptions",value:function(e){e=e||{};var t=this.options,n=this.options={};l(t,function(t,i){n[i]=e.hasOwnProperty(i)?e[i]:t})}}],[{key:"initInput",value:function(e,n){n=n||{};var i=void 0,r=function(){var r=e.value;n.parseColor&&(r=n.parseColor(r)),i?i.setHEX(r):(n.size=n.size||e.offsetWidth,n.background=m.getComputedStyle(e,null).backgroundColor,n.margin=n.margin||10,n.event=n.event||"dragend",i=new t(r,n),i.on(n.event,function(){var t=i.getHEX();e.value=n.uppercase?t.toUpperCase():t,s()}));var o=e.offsetTop;m.innerHeight-e.getBoundingClientRect().top>e.offsetHeight+n.margin+n.size?o+=e.offsetHeight+n.margin:o-=n.margin+n.size;var a=i.getElement();a.style.position="absolute",a.style.left=e.offsetLeft+"px",a.style.top=o+"px",a.style.zIndex="1338",i.inject(e.parentNode)},o=function(){i&&i.dispose()},s=function(){var t=g.createEvent("HTMLEvents");t.initEvent("input",!0,!1),e.dispatchEvent(t)};e.addEventListener("focus",r,!1),e.addEventListener("blur",o,!1),e.addEventListener("keyup",function(){e.value.match(/^#((?:[0-9A-Fa-f]{3})|(?:[0-9A-Fa-f]{6}))$/)?(r(),s()):o()},!1)}}]),t}(c)}]);
//# sourceMappingURL=app.32c889b-en.js.map