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.69e5b77.js

4 lines
114 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=9)}([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 c(e){e.style.display="","none"===s(e,"display")&&(e.style.display="block")}function h(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 u(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,h=[],v=!1;if(e)if(e.nodeType&&1===e.nodeType)h=[e];else if("object"===(void 0===e?"undefined":i(e)))v="number"!=typeof e.length,h=e;else if("string"==typeof e)for(n=w.querySelectorAll(e),a=0;a<n.length;a+=1)h[a]=n[a];return t=v?{}:h,t.each=function(e){return"function"==typeof e&&r(function(t){return e.apply(t,arguments)},h),t},t.first=function(){return f(h.shift())},t.last=function(){return f(h.pop())},t.odd=function(){var e,t=[];for(e=0;e<h.length;e+=2)t.push(h[e]);return f(t)},t.even=function(){var e,t=[];for(e=1;e<h.length;e+=2)t.push(h[e]);return f(t)},t.hide=function(){return r(function(e){e.style.display="none"},h),t},t.show=function(){return r(function(e){c(e)},h),t},t.toggle=function(e){return void 0!==e?e?t.show():t.hide():r(function(e){"none"===s(e,"display")?c(e):e.style.display="none"},h),t},t.remove=function(){return r(function(e){try{e.parentNode.removeChild(e)}catch(e){}},h),f()},t.css=function(e,n){if(e){if(n||""===n)return r(function(t){l(t,e,n)},h),t;if(h[0]){if(h[0].style[o(e)])return h[0].style[o(e)];if(s(h[0],e))return s(h[0],e)}}},t.getClass=function(){if(h[0]&&h[0].className.length>0)return h[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},h),t},t.addClass=function(e){return u(e,"add",h),t},t.removeClass=function(e){return u(e,"remove",h),t},t.toggleClass=function(e,n){return u(e,void 0===n?"toggle":+n?"add":"remove",h),t},t.hasClass=function(e){return u(e,"has",h)},t.html=function(e){return e||""===e?(r(function(t){t.innerHTML=e},h),t):h[0]?h[0].innerHTML:void 0},t.htmlBefore=function(e){return d(e,"before",h),t},t.htmlAfter=function(e){return d(e,"after",h),t},t.htmlAppend=function(e){return d(e,"append",h),t},t.htmlPrepend=function(e){return d(e,"prepend",h),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)},h),t;if(h[0])if("style"===e){if(h[0].style.cssText)return h[0].style.cssText}else if("class"===e){if(h[0].className)return h[0].className}else if(h[0].getAttribute(e))return h[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}},h),t;if(h[0])switch(h[0].nodeName){case"SELECT":for(n=[],i=0;i<h[0].length;i+=1)h[0][i].selected&&n.push(h[0][i].value);return n.length>1?n:n[0];case"INPUT":case"TEXTAREA":case"BUTTON":return h[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)},h),t):!h[0]||"INPUT"!==h[0].nodeName||"checkbox"!==h[0].type&&"radio"!==h[0].type?void 0:!!h[0].checked},t.on=function(n,i){return e!==y&&e!==w||(h=[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]))},h),t},t.off=function(n,i){return e!==y&&e!==w||(h=[e]),r(function(e){w.addEventListener?e.removeEventListener(n,i,!1):w.attachEvent&&(e.detachEvent("on"+n,e[n+i]),e[n+i]=null)},h),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=h(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,c=!1,h=function(){clearTimeout(a),clearTimeout(l)};o.show=function(e,t,n){s.toggleClass("error",!0===n),s.html(e),r.show(s),h(),(!t||t<=0)&&(t=2500),a=setTimeout(o.hide,t),c=!1,setTimeout(function(){c=!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(){c&&o.hide(this)}),s.on("click",function(e){return e.stopImmediatePropagation(),!1}),s.on("mouseenter",function(){h(),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,c;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 h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}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),c=n.slice(),r=c.length,l=0;l<r;l++)c[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(7),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 c=10*l+8;a.push(o(c,c,c))}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.toHex=function(e,n){return/^\d+$/.test(e)&&(e=+e,e=e<16?s[n][e]:t.buildColorTable()[e]),e}},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}}(),c=n(4),h=n(0),u=h.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(),c=i.shift(),h=i.shift(),u=256+(l<<16|c<<8|h);38===s&&this.handler("set-color-fg",u),48===s&&this.handler("set-color-bg",u)}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=["","","^C","","Help"],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.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(7),e+=v(0),e+=v(0),e+=v(0);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(5),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,c=l[1].slice();if(this.rainbow){var h=n%this.width,u=Math.floor(n/this.width),d=(h+u)/10+Date.now()/1e3;this.superRainbow&&(d=(h*u+Date.now())/100+Date.now()/1e3),c[0]=g(d),c[1]=0,this.superRainbow&&(c[1]=g(d/10)),c[2]=1|c[2],!this.superRainbow&&2&c[2]&&(c[2]^=2),n++}var f=c[0],p=c[1],m=c[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=c,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}(c),b={buttons:{1:"",2:"",3:function(e,t){return t.write("")},4:"",5:function(e,t){t.child&&t.child.destroy();var n="info\r",i=function e(){t.write(n[0]),(n=n.substr(1))&&setTimeout(e,100)};setTimeout(i,200)}},mouseReceiver:null},_={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 or and may not work as expected in this demo\r\n")}},{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 c=o-i;c>0&&l(c,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 _)"string"!=typeof _[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(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"color",value:function(e){e=parseInt(e.substr(1),16);var t=e>>16,n=e>>8&255,i=255&e;this.emit("write","[48;2;"+t+";"+n+";"+i+"m"),(t+n+i)/3>127?this.emit("write",""):this.emit("write","")}},{key:"run",value:function(){for(var e in f){var t=f[e],n=(" "+e).substr(-2);this.emit("write","Theme "+n+": ");for(var i=0;i<16;i++){var r=(" "+i).substr(-2);this.color(t[i]),this.emit("write",r),this.emit("write"," ")}this.emit("write","\n")}this.destroy()}}]),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(){this.shell.terminal.trackMouse=!0,b.mouseReceiver=this,this.randomData=[],this.highlighted={};for(var e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",t=0;t<23;t++){for(var n="",i=0;i<79;i++)n+=e[Math.floor(e.length*Math.random())];this.randomData.push(n)}this.scrollOffset=0,this.render()}},{key:"render",value:function(){this.emit("write",""),this.emit("write","Mouse Demo\r\nMouse movement, clicking, and scrolling!");for(var e=0;e<23;e++){var t=e+this.scrollOffset;t=(t%this.randomData.length+this.randomData.length)%this.randomData.length;var n=this.randomData[t],i="["+(3+e)+";1H";for(var r in n)this.highlighted[80*(e+2)+ +r]&&(i+=""),i+=n[r],this.highlighted[80*(e+2)+ +r]&&(i+="");this.emit("write",i)}this.mouse&&this.emit("write","["+(this.mouse.y+1)+";"+(this.mouse.x+1)+"H")}},{key:"mouseMove",value:function(e,t){this.mouse={x:e,y:t},this.render()}},{key:"mouseDown",value:function(e,t,n){4===n?this.scrollOffset--:5===n?this.scrollOffset++:this.highlighted[80*t+e]=!this.highlighted[80*t+e],this.render()}},{key:"mouseUp",value:function(e,t,n){}},{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)};s.on("write",a),s.on("exit",function(t){s.removeListener("write",a),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.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)},k={"local-echo":"local-echo [--suppress-note]",theme:"theme [n]",cursor:"cursor [block|line|bar] [--steady]",sudo:"sudo [command]"},C=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=_,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}},{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}for(var r in this.index)if(r.startsWith(t)&&r!==t)return e&&r in k?n+k[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){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 c=t.shift();c in this.index?this.spawn(c,t):(this.terminal.write("demosh: Unknown command: "+c+"\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.child=new r(this);var s=function(e){return t.terminal.write(e)};this.child.on("write",s),this.child.on("exit",function(e){t.child&&t.child.removeListener("write",s),t.child=null,t.prompt(!e)}),(o=this.child).run.apply(o,i(n))}else this.terminal.write(r),this.prompt()}}]),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),r=b.buttons[i];r&&("string"==typeof r?this.shell.write(r):r instanceof Function&&r(this.terminal,this.shell))}else if("m"===t||"p"===t||"r"===t){var o=u(n,0),s=u(n,2),a=u(n,4),l=u(n,6);b.mouseReceiver&&("m"===t?b.mouseReceiver.mouseMove(s,o,a,l):"p"===t?b.mouseReceiver.mouseDown(s,o,a,l):"r"===t&&b.mouseReceiver.mouseUp(s,o,a,l))}},didInit:!1,init:function(e){this.didInit||(this.didInit=!0,this.terminal=new w(e),this.shell=new C(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,c=void 0;c=i<.5?i*(1+n):i+n-n*i,l=2*i-c,r=t.hue2rgb(l,c,e+1/3),s=t.hue2rgb(l,c,e),a=t.hue2rgb(l,c,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,c=void 0,h=void 0;if(h=(s+i)/2,0===a)l=c=0;else{c=h<.5?a/(s+i):a/(2-s-i);var u=((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+u-f:n===s&&(l=2/3+d-u),l<0?l+=1:l>1&&(l-=1)}return l*=o,[l,c,h]},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={"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"};e.exports=function(e){return i[e]||"?"+e+"?"}},function(e,t,n){"use strict";n(10),n(2),n(3),n(11);try{n(6)}catch(e){}n(12);var i=n(1),r=n(0),o=r.qs;window.termInit=n(13),window.$=i,window.qs=o,window.themes=n(5),window.TermConf=n(23)},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,c=o.cr,h=n(2),u=n(3);r.ready(function(){function e(){r("#menu").toggleClass("expanded")}r("#brand").on("click",e).on("keypress",c(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",c(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",c(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(h.init(),u.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),i()}},2e3):setTimeout(function(){i()},1)})},function(e,t,n){"use strict";var i=n(1),r=n(0),o=r.mk,s=n(8),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"))},c=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"),c=i.htmlEscape(e.essid);i(a).addClass("inner").htmlAppend('<div class="rssi">'+e.rssi_perc+"</div>").htmlAppend('<div class="essid" title="'+c+'">'+c+"</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)}})}},h=function(){i("#ap-loader").removeClass("hidden"),i("#ap-scan").addClass("hidden"),i("#ap-loader .anim-dots").html("."),u()},u=function(){window._demo?c(window._demo_aps,200):i.get("http://"+window._root+"/cfg/wifi/scan",c)},d=function(e){setTimeout(u,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=h},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(0),o=r.qs,s=r.mk,a=n(8),l=n(3),c=n(14),h=n(17),u=n(18),d=n(19),f=n(20),v=n(21),p=n(22);e.exports=function(e){var t=new c,n=new h(t),r=u(n,t),m=d(n,r,t);t.input=r,t.conn=n,r.termUpload=m;var g=p(r);t.on("button-labels",function(e){var t;(t=g.labels).splice.apply(t,[0,g.labels.length].concat(i(e))),g.update()});var w=null,y=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;clearTimeout(w),w=setTimeout(function(){t.window.statusScreen=e},n)};n.on("open",function(){y({title:a("term_conn.connecting"),loading:!0})}),n.on("connect",function(){y({title:a("term_conn.waiting_content"),loading:!0})}),n.on("load",function(){clearTimeout(w),t.window.statusScreen&&(t.window.statusScreen=null)}),n.on("disconnect",function(){y({title:a("term_conn.disconnected")},500),t.screen=[],t.screenFG=[],t.screenBG=[],t.screenAttrs=[]}),n.on("silence",function(){y({title:a("term_conn.waiting_server"),loading:!0},0)}),n.on("ping-success",function(){y({title:a("term_conn.reconnecting"),loading:!0},0)}),n.init(),r.init(e),m.init(),l.init(),window.onerror=function(e,t,n,i){return l.show("<b>JS ERROR!</b><br>"+e+"<br>at "+t+":"+n+":"+i,1e4,!0),!1},o("#screen").appendChild(t.canvas),f(t,r),v&&v(t);var b={},_=!1,k=!1,C=!1,x=t.window.padding,S=function(){_?(b.className="icn-resize-small",k?(t.window.fitIntoWidth=window.screen.width,t.window.fitIntoHeight=window.screen.height,t.window.padding=0):(t.window.fitIntoWidth=window.innerWidth,o("#term-nav").classList.contains("hidden")?t.window.fitIntoHeight=window.innerHeight:t.window.fitIntoHeight=window.innerHeight-24,t.window.padding=0)):(b.className="icn-resize-full",t.window.fitIntoWidth=C?window.innerWidth-4:0,t.window.fitIntoHeight=C?window.innerHeight:0,t.window.padding=x)};S(),window.addEventListener("resize",S);var T=function(){C=!C;var e=o("#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")),S()};if(o("#term-fit-screen").addEventListener("click",function(){return T(),!1}),window.Element.prototype.requestFullscreen||window.Element.prototype.webkitRequestFullscreen){k=!0;var E=function(){!_||window.innerWidth===window.screen.width&&window.innerHeight===window.screen.height||(_=!1,S())};setInterval(E,500)}var P=s("a");P.id="fullscreen-button",P.href="#",P.addEventListener("click",function(e){if(e.preventDefault(),document.body.classList.contains("pseudo-fullscreen"))return document.body.classList.remove("pseudo-fullscreen"),_=!1,void S();_=!0,S(),t.updateSize(),k?t.canvas.requestFullscreen?t.canvas.requestFullscreen():t.canvas.webkitRequestFullscreen():document.body.classList.add("pseudo-fullscreen")}),b=s("i"),b.className="icn-resize-full",P.appendChild(b);var L=s("span");L.textContent=a("term_nav.fullscreen"),P.appendChild(L),o("#term-nav").insertBefore(P,o("#term-nav").firstChild),window.termScreen=t,window.conn=n,window.input=r,window.termUpl=m}},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),c=n(1),h=n(0),u=h.mk,d=h.qs,f=n(3),v=n(15),p=n(16);e.exports=function(e){function t(){r(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));e.canvas=u("canvas"),e.ctx=e.canvas.getContext("2d"),e.parser=new v(e),e.renderer=new p(e),e._debug=null,"AudioContext"in window||"webkitAudioContext"in window?e.audioCtx=new(window.AudioContext||window.webkitAudioContext):console.warn("No AudioContext!"),e.input=new Proxy({},{get:function(){return function(){return console.warn("TermScreen#input not set!")}}}),e.conn=new Proxy({},{get:function(){return function(){return console.warn("TermScreen#conn not set!")}},set:function(e,t){return function(){return console.warn("TermScreen#conn not set!")}}}),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:!1,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},e.selection={selectable:!0,start:[0,0],end:[0,0]},e.mouseMode={clicks:!1,movement:!1};var n=e;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"))},h=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){if((e.selection.selectable||t.altKey)&&0===t.button)a(t.offsetX,t.offsetY);else{var n;(n=e.input).onMouseDown.apply(n,i(e.screenToGrid(t.offsetX,t.offsetY)).concat([t.button+1]))}}),window.addEventListener("mousemove",function(e){l(e.offsetX,e.offsetY)}),window.addEventListener("mouseup",function(e){h(e.offsetX,e.offsetY)});var f=null,m=0,g=!1,w=function(t){var n=e.canvas.getBoundingClientRect();return[t.clientX-n.left,t.clientY-n.top]};e.canvas.addEventListener("touchstart",function(e){f=w(e.touches[0]),g=!1,m=Date.now()},{passive:!0}),e.canvas.addEventListener("touchmove",function(e){f=w(e.touches[0]),s||!1!==g?s&&(e.preventDefault(),l.apply(void 0,i(f))):m<Date.now()-500&&a.apply(void 0,i(f)),g=!0}),e.canvas.addEventListener("touchend",function(t){if(t.touches[0]&&(f=w(t.touches[0])),s){t.preventDefault(),h.apply(void 0,i(f));var n=d("#touch-select-menu");n.classList.add("open");var r=n.getBoundingClientRect(),o=e.gridToScreen((e.selection.start[0]+e.selection.end[0])/2,e.selection.start[1]-1);o[0]-=r.width/2,o[1]-=r.height/2,n.style.transform="translate("+o[0]+"px, "+o[1]+"px)"}g||e.mouseMode.clicks||e.emit("tap",Object.assign(t,{x:f[0],y:f[1]})),f=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],d("#touch-select-menu").classList.remove("open"),e.renderer.scheduleDraw("select-reset")):(t.preventDefault(),e.emit("open-soft-keyboard"))}),c.ready(function(){var t=d("#touch-select-copy-btn");t&&t.addEventListener("click",function(){e.copySelectionToClipboard()})}),e.canvas.addEventListener("mousemove",function(t){if(!s){var n;(n=e.input).onMouseMove.apply(n,i(e.screenToGrid(t.offsetX,t.offsetY)))}}),e.canvas.addEventListener("mouseup",function(t){if(!s){var n;(n=e.input).onMouseUp.apply(n,i(e.screenToGrid(t.offsetX,t.offsetY)).concat([t.button+1]))}});var y=0;return e.canvas.addEventListener("wheel",function(t){if(e.mouseMode.clicks){if(120===Math.abs(t.wheelDeltaY)){var n;(n=e.input).onMouseWheel.apply(n,i(e.screenToGrid(t.offsetX,t.offsetY)).concat([t.deltaY>0?1:-1]))}else if(y-=t.wheelDeltaY,Math.abs(y)>=40){var r;(r=e.input).onMouseWheel.apply(r,i(e.screenToGrid(t.offsetX,t.offsetY)).concat([y>0?1:-1])),y=0}t.preventDefault()}}),e.canvas.addEventListener("contextmenu",function(t){e.mouseMode.clicks&&t.preventDefault(),h(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(),c=i*l.width,h=r*l.height,u=c;if(o&&s){var d=c/h;d<o/s?(h=s-2*a,c=h*d):(c=o-2*a,h=c/d)}this._windowScale=c/u,c+=2*a,h+=2*a,this._padding=a*(u/c);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=c+"px",this.canvas.height=(r*l.height+2*Math.round(this._padding))*f,this.canvas.style.height=h+"px",this.renderer.resetDrawn(),this.renderer.draw("update-size")}}},{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=u("textarea");document.body.appendChild(t),t.value=e,t.select(),document.execCommand("copy")?f.show("Copied to clipboard"):f.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():f.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;(e=this.parser).load.apply(e,arguments)}}]),t}(l)},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){var t=e.codePointAt(0);return t>57343&&(t-=2048),t-1}var o=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}}(),s=n(1),a=n(0),l=a.qs;e.exports=function(){function e(t){i(this,e),this.screen=t,this.contentLoaded=!1}return o(e,[{key:"hideLoadFailedMsg",value:function(){if(!this.contentLoaded){var e=l("#load-failed");e&&e.parentNode.removeChild(e),this.contentLoaded=!0}}},{key:"loadUpdate",value:function(e){for(var t=this,n=0,i=Array.from?Array.from(e):e.split(""),o=void 0,a=!1,c=r(i[n++]);n<i.length;){var h=i[n++];if("O"===h){var u=r(i[n++]),d=r(i[n++]),f=r(i[n++]),v=65535&r(i[n++])|(65535&r(i[n++]))<<16,p=65535&r(i[n++])|(65535&r(i[n++]))<<16,m=r(i[n++]);this.screen.renderer.loadTheme(f),this.screen.renderer.setDefaultColors(v,p),a=this.screen.window.height!==u||this.screen.window.width!==d,this.screen.window.height=u,this.screen.window.width=d,this.screen.cursor.visible=!!(1&m),this.screen.input.setAlts(!!(4&m),!!(8&m),!!(16&m),!!(4096&m));var g=!!(32&m),w=!!(64&m),y=m>>9&7;y>0&&y--;var b=y>>1,_=!(1&y);0===b?this.screen.cursor.style="block":1===b?this.screen.cursor.style="line":2===b&&(this.screen.cursor.style="bar"),this.screen.cursor.blinking!==_&&(this.screen.cursor.blinking=_,this.screen.renderer.resetCursorBlink()),this.screen.input.setMouseMode(g,w),this.screen.selection.selectable=!g&&!w,s(this.screen.canvas).toggleClass("selectable",this.screen.selection.selectable),this.screen.mouseMode={clicks:g,movement:w};var k=!!(128&m),C=!!(256&m);s(".x-term-conf-btn").toggleClass("hidden",!C),s("#action-buttons").toggleClass("hidden",!k),this.screen.bracketedPaste=!!(8192&m),this.screen.reverseVideo=!!(16384&m)}else if("C"===h){var x=r(i[n++]),S=r(i[n++]),T=r(i[n++]),E=T!==this.screen.cursor.hanging||S!==this.screen.cursor.x||x!==this.screen.cursor.y;this.screen.cursor.x=S,this.screen.cursor.y=x,this.screen.cursor.hanging=!!T,E&&(this.screen.renderer.resetCursorBlink(),this.screen.emit("cursor-moved")),this.screen.renderer.scheduleDraw("cursor-moved")}else if("T"===h){for(o="";n<i.length;){var P=i[n++];if(""===P)break;o+=P}l("#screen-title").textContent=o,0===o.length&&(o="Terminal"),l("title").textContent=o+" :: ESPTerm"}else if("B"===h){for(var L=r(i[n++]),A=[],F=0;F<L;F++){for(o="";n<i.length;){var O=i[n++];if(""===O)break;o+=O}A.push(o)}this.screen.emit("button-labels",A)}else if("!"===h)this.screen.beep();else if("D"===h){var R=r(i[n++]),D=r(i[n++]),M=r(i[n++]),B=r(i[n++]),N=r(i[n++]),I=i[n++],H=i[n++],j=r(i[n++]),z=r(i[n++]);this.screen.emit("internal",{flags:R,cursorAttrs:D,regionStart:M,regionEnd:B,charsetGx:N,charsetG0:I,charsetG1:H,freeHeap:j,clientCount:z})}else"S"===h&&function(){var e=r(i[n++]),o=r(i[n++]),s=r(i[n++]),l=r(i[n++]);t.screen._debug&&t.screen.window.debug&&t.screen._debug.pushFrame([o,e,l,s]);var c=7,h=0,u=0,d=0,f=" ",v=l*s,p=t.screen.window.width*t.screen.window.height;a&&(t.screen.updateSize(),t.screen.blinkingCellCount=0,t.screen.screen=new Array(p).fill(" "),t.screen.screenFG=new Array(p).fill(" "),t.screen.screenBG=new Array(p).fill(" "),t.screen.screenAttrs=new Array(p).fill(0));for(var m=function(){var n=u,i=1&u,r=2&u,s=c,a=h;i||(s=0),r||(a=0),0!=(32&n)&&(" "===f&&0==(392&n)||c===h&&i&&r)&&(n^=32),(32&t.screen.screenAttrs[d])!=(32&n)&&(32&n?t.screen.blinkingCellCount++:t.screen.blinkingCellCount--);var v=d%l,p=Math.floor(d/l),m=(e+p)*t.screen.window.width+o+v;4&n&&!(512&n)&&i&&s<8&&(s+=8),t.screen.screen[m]=f,t.screen.screenFG[m]=s,t.screen.screenBG[m]=a,t.screen.screenAttrs[m]=n};n<i.length&&d<v;){var g=i[n++],w=g.codePointAt(0),y=void 0,b=void 0;switch(w){case 2:b=r(i[n++]);for(var _=0;_<b&&(m(),!(++d>v));_++);break;case 1:d+=r(i[n++]);break;case 3:y=r(i[n++]),c=255&y,h=y>>8&255;break;case 4:y=r(i[n++]),u=65535&y;break;case 7:u=0;break;case 5:y=r(i[n++]),65536&y&&(y&=4095,y|=(4095&r(i[n++]))<<12,y+=256),c=y;break;case 6:y=r(i[n++]),65536&y&&(y&=4095,y|=(4095&r(i[n++]))<<12,y+=256),h=y;break;default:w<32&&(g="<EFBFBD>"),f=g,m(),d++}}t.screen.window.debug&&console.log("Blinky cells: "+t.screen.blinkingCellCount),t.screen.renderer.scheduleDraw("load",16),t.screen.conn.emit("load")}();0!=(59&c)&&this.hideLoadFailedMsg()}}},{key:"load",value:function(e){var t=e.substr(1);switch(e[0]){case"U":this.loadUpdate(t);break;case"G":this.screen.showNotification(t);break;default:console.warn("Bad data message type; ignoring.\n"+JSON.stringify(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")}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.SELECTION_FG,c=o.SELECTION_BG,h={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"))}},{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){if(e<16&&e in this.palette)return this.palette[e];if(-1===e)return l;if(-2===e)return c;if(e>15&&e<256)return this.colorTable256[e];if(e>255){e-=256;return"rgb("+(e>>16&255)+", "+(e>>8&255)+", "+(255&e)+")"}return Date.now()/1e3%2==0?"#f0f":"#0f0"}},{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=this.ctx,a=this.screen.window,l=a.width,c=a.height,h=Math.round(this.screen._padding);s.fillStyle=this.getColor(o);var u=t*i+h,d=n*r+h;if(0===t||0===n||t===l-1||n===c-1){var f=u,v=d,p=u+i,m=d+r;0===t?f-=h:t===l-1&&(p+=h),0===n?v-=h:n===c-1&&(m+=h),s.clearRect(f,v,p-f,m-v),s.fillRect(f,v,p-f,m-v)}else s.clearRect(u,d,i,r),s.fillRect(u,d,i,r)}},{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,c=t.attrs;if(a){var h=this.ctx,u=Math.round(this.screen._padding),d=!1,f=!1,v=!1;512&c&&(h.globalAlpha=.5),8&c&&(d=!0),1024&c&&(a=e.alphaToFraktur(a)),128&c&&(f=!0),256&c&&(v=!0),h.fillStyle=this.getColor(l);var p=n*o+u,m=i*s+u,g=a.codePointAt(0);if(g>=9600&&g<=9631){h.beginPath();var w=p,y=m,b=o,_=s,k=o/2,C=s/2;if(9600===g)h.rect(w,y,b,C);else if(g<=9608){var x=(1-(g-9600)/8)*_;h.rect(w,y+x,b,_-x)}else if(g<=9615){var S=(g-9608)/8*b;h.rect(w,y,b-S,_)}else if(9616===g)h.rect(w+k,y,k,_);else if(g<=9619){var T=void 0,E=void 0,P=void 0;9617===g?(T=b/4,E=_/10,P=1):9618===g?(T=b/6,E=b/10,P=1):9619===g&&(T=b/4,E=b/7,P=2);for(var L=!1,A=0;A<_;A+=E){for(var F=0;F<b;F+=T){var O=Math.min(P,_-A);h.rect(w+(L?b-F-P:F),y+A,P,O)}L=!L}}else 9620===g?h.rect(w,y,b,_/8):9621===g?h.rect(w+7/8*b,y,b/8,_):9622===g?h.rect(w,y+C,k,C):9623===g?h.rect(w+k,y+C,k,C):9624===g?h.rect(w,y,k,C):9625===g?(h.rect(w,y,k,_),h.rect(w+k,y+C,k,C)):9626===g?(h.rect(w,y,k,C),h.rect(w+k,y+C,k,C)):9627===g?(h.rect(w,y,k,_),h.rect(w+k,y,k,C)):9628===g?(h.rect(w,y,b,C),h.rect(w+k,y+C,k,C)):9629===g?h.rect(w+k,y,k,C):9630===g?(h.rect(w,y+C,k,C),h.rect(w+k,y,k,C)):9631===g&&(h.rect(w,y+C,k,C),h.rect(w+k,y,k,_));h.fill()}else g>=57520&&g<=57523?(h.beginPath(),57520===g||57521===g?(h.moveTo(p,m),h.lineTo(p+o,m+s/2),h.lineTo(p,m+s)):57522!==g&&57523!==g||(h.moveTo(p+o,m),h.lineTo(p,m+s/2),h.lineTo(p+o,m+s)),g%2==0?h.fill():(h.strokeStyle=h.fillStyle,h.stroke())):h.fillText(a,p+.5*o,m+.5*s);if(d||f||v){if(h.strokeStyle=this.getColor(l),h.lineWidth=1,h.lineCap="round",h.beginPath(),d){var R=Math.round(m+r.height)+.5;h.moveTo(p,R),h.lineTo(p+o,R)}if(f){var D=Math.round(m+.5*s)+.5;h.moveTo(p,D),h.lineTo(p+o,D)}if(v){var M=Math.round(m)+.5;h.moveTo(p,M),h.lineTo(p+o,M)}h.stroke()}h.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(),c=this.screen.getCellSize(),h=c.width,u=c.height,d=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 f=new Map,v=new Map,p=0;p<d;p++){var m=p%r,g=Math.floor(p/r),w=this.cursorBlinkOn&&this.screen.cursor.x===m&&this.screen.cursor.y===g&&this.screen.cursor.visible,y=m===this.drawnCursor[0]&&g===this.drawnCursor[1],b=this.screen.isInSelection(m,g),_=this.screen.screen[p],k=0|this.screen.screenFG[p],C=0|this.screen.screenBG[p],x=0|this.screen.screenAttrs[p];if(1&x||(k=this.defaultFgNum),2&x||(C=this.defaultBgNum),16&x){var S=[C,k];k=S[0],C=S[1]}if(this.screen.reverseVideo){var T=[C,k];k=T[0],C=T[1]}32&x&&!this.blinkStyleOn&&(_=""),b&&(k=-1,C=-2);var E=_!==this.drawnScreen[p]||k!==this.drawnScreenFG[p]||C!==this.drawnScreenBG[p]||x!==this.drawnScreenAttrs[p]||w!==y||w&&this.screen.cursor.style!==this.drawnCursor[2]||w&&this.screen.cursor.hanging!==this.drawnCursor[3],P=68&x;f.has(P)||f.set(P,[]),f.get(P).push({cell:p,x:m,y:g,text:_,fg:k,bg:C,attrs:x,isCursor:w,inSelection:b}),v.set(p,E)}var L=new Map,A=function(e){return" "!==e&&n.measureText(e).width>=h+.05},F=!0,O=!1,R=void 0;try{for(var D,M=v.keys()[Symbol.iterator]();!(F=(D=M.next()).done);F=!0){var B=D.value;!function(e){var n=v.get(e)||L.get(e)||!1,i=t.screen.screen[e],r=A(i),o=r?2:1;if(!n){var s=!1,a=!0,l=!1,c=void 0;try{for(var h,u=t.getAdjacentCells(e,o)[Symbol.iterator]();!(a=(h=u.next()).done);a=!0){var d=h.value;if(v.get(d)&&(t.screen.window.graphics<2||r||A(t.screen.screen[d]))){s=!0;break}}}catch(e){l=!0,c=e}finally{try{!a&&u.return&&u.return()}finally{if(l)throw c}}s&&(n=!0)}L.set(e,n)}(B)}}catch(e){O=!0,R=e}finally{try{!F&&M.return&&M.return()}finally{if(O)throw R}}if(this.screen.window.graphics>=1){var N=this.screen.window.debug&&this.screen._debug,I=Math.round(this.screen._padding);n.save(),n.beginPath();for(var H=0;H<o;H++){for(var j=null,z=0;z<r;z++){var W=H*r+z,q=L.get(W);q&&null===j&&(j=z),q||null===j||(n.rect(I+j*h,I+H*u,(z-j)*h,u),N&&this.screen._debug.clipRect(j*h,H*u,(z-j)*h,u),j=null)}null!==j&&(n.rect(I+j*h,I+H*u,(r-j)*h,u),N&&this.screen._debug.clipRect(j*h,H*u,(r-j)*h,u))}n.clip()}var G=!0,U=!1,X=void 0;try{for(var K,Y=f.keys()[Symbol.iterator]();!(G=(K=Y.next()).done);G=!0){var $=K.value,J=!0,V=!1,Q=void 0;try{for(var Z,ee=f.get($)[Symbol.iterator]();!(J=(Z=ee.next()).done);J=!0){var te=Z.value,ne=te.cell,ie=te.x,re=te.y,oe=te.text,se=te.bg;if(L.get(ne)&&(this.drawBackground({x:ie,y:re,cellWidth:h,cellHeight:u,bg:se}),this.screen.window.debug&&this.screen._debug)){var ae=+L.get(ne);ae|=+v.get(ne)<<1,ae|=+A(oe)<<2,this.screen._debug.setCell(ne,ae)}}}catch(e){V=!0,Q=e}finally{try{!J&&ee.return&&ee.return()}finally{if(V)throw Q}}}}catch(e){U=!0,X=e}finally{try{!G&&Y.return&&Y.return()}finally{if(U)throw X}}this.drawnCursor=[-1,-1,-1];var le=!0,ce=!1,he=void 0;try{for(var ue,de=f.keys()[Symbol.iterator]();!(le=(ue=de.next()).done);le=!0){var fe=ue.value,ve={};4&fe&&(ve.weight="bold"),64&fe&&(ve.style="italic"),n.font=this.screen.getFont(ve);var pe=!0,me=!1,ge=void 0;try{for(var we,ye=f.get(fe)[Symbol.iterator]();!(pe=(we=ye.next()).done);pe=!0){var be=we.value,_e=be.cell,ke=be.x,Ce=be.y,xe=be.text,Se=be.fg,Te=be.bg,Ee=be.attrs,Pe=be.isCursor,Le=be.inSelection;if(L.get(_e)&&(this.drawCharacter({x:ke,y:Ce,charSize:l,cellWidth:h,cellHeight:u,text:xe,fg:Se,attrs:Ee}),this.drawnScreen[_e]=xe,this.drawnScreenFG[_e]=Se,this.drawnScreenBG[_e]=Te,this.drawnScreenAttrs[_e]=Ee,Pe&&(this.drawnCursor=[ke,Ce,this.screen.cursor.style,this.screen.cursor.hanging]),Pe&&!Le)){n.save(),n.beginPath();var Ae=ke,Fe=Ce;this.screen.cursor.hanging&&(Ae+=1);var Oe=Ae*h+this.screen._padding,Re=Fe*u+this.screen._padding;if("block"===this.screen.cursor.style)n.rect(Oe,Re,h,u);else if("bar"===this.screen.cursor.style){n.rect(Oe,Re,2,u)}else if("line"===this.screen.cursor.style){n.rect(Oe,Re+l.height,h,2)}n.clip();var De=[Te,Se];Se=De[0],Te=De[1],Se===Te&&(Te=0===Se?7:0),this.drawBackground({x:Ae,y:Fe,cellWidth:h,cellHeight:u,bg:Te}),this.drawCharacter({x:Ae,y:Fe,charSize:l,cellWidth:h,cellHeight:u,text:xe,fg:Se,attrs:Ee}),n.restore()}}}catch(e){me=!0,ge=e}finally{try{!pe&&ye.return&&ye.return()}finally{if(me)throw ge}}}}catch(e){ce=!0,he=e}finally{try{!le&&de.return&&de.return()}finally{if(ce)throw he}}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,c=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,c),t.font="24px "+i,t.fillStyle=this.getColor(this.defaultFgNum),t.textAlign="center",t.textBaseline="middle",t.fillText(e.title||"",l/2,c/2-50),e.loading){t.save(),t.translate(l/2,c/2+20),t.strokeStyle=this.getColor(this.defaultFgNum),t.lineWidth=5,t.lineCap="round";for(var h=Date.now()/1e3,u=0;u<12;u++){t.rotate(Math.PI/6);var d=(12*h-u)%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=h[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),c=void 0;try{c=n(6)}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;try{n.blobReader=new 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".":console.log(e);break;case"-":this.xoff=!0,this.autoXoffTimeout=setTimeout(function(){t.xoff=!1},250);break;case"+":this.xoff=!1,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?c.input(e):console.log("TX: "+JSON.stringify(e)),!0):this.xoff?(console.log("Can't send, flood control."),!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:"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!"):c.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;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(1),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",C),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&&(x=1),1===e.button&&(S=1),2===e.button&&(T=1)}),window.addEventListener("mouseup",function(e){0===e.button&&(x=0),1===e.button&&(S=0),2===e.button&&(T=0)})}function a(){return E}for(var l=void 0,c={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"},h=48;h<=57;h++)c[h]=String.fromCharCode(h);for(var u=65;u<=90;u++)c[u]=String.fromCharCode(u);for(var d=112;d<=131;d++)c[d]="F"+(d-112+1);for(var f=96;f<=105;f++)c[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)},_=["F5","F11","F12","Shift+F5"],k={alt:!1,ctrl:!1,meta:!1,shift:!1},C=function(e){if(b()){var t=[];(e.altKey||k.alt)&&t.push("Alt"),(e.ctrlKey||k.ctrl)&&t.push("Control"),(e.metaKey||k.meta)&&t.push("Meta"),(e.shiftKey||k.shift)&&t.push("Shift");var i=c[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(_.includes(o)&&!v.all_fn)continue;r=w[o];break}}r&&(r instanceof Function&&(r=r()),e.preventDefault(),"string"==typeof r&&n(r))}}},x=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=x?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:C,softModifiers:k}}},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 c(){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..."),h()}function h(){if(i("#fu_modal").hasClass("visible")){if(!e.canSend())return void(p=setTimeout(h,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(h,m):u()}}function u(){e.canSend()?(l("Done."),d()):(l("Waiting for Tx buffer..."),setTimeout(u,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(){return r(),!1}),o("#term-fu-start").addEventListener("click",function(){return c(),!1}),o("#term-fu-close").addEventListener("click",function(){return d(),!1})},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="",c=function(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?c(e.data):e.isComposing?c(n.value):"insertCompositionText"===e.inputType?t.sendString(e.data):"deleteContentBackward"===e.inputType?(l="",c("")):"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 h={Control:"ctrl",Esc:27,Tab:9,"←":37,"↓":40,"↑":38,"→":39},u=!1;for(var d in h)!function(e){var n=document.createElement("button");n.classList.add("shortcut-button"),n.textContent=e,r.appendChild(n);var i=h[e];"string"==typeof i&&n.classList.add("modifier"),n.addEventListener("touchstart",function(e){u=!1,"string"==typeof i&&(t.softModifiers[i]=!0,n.classList.add("enabled"),e.preventDefault())}),window.addEventListener("touchmove",function(e){u=!0}),n.addEventListener("touchend",function(e){if(e.preventDefault(),"number"==typeof i){if(u)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){var t=s("canvas"),n=t.getContext("2d");t.classList.add("debug-canvas");var o=null,a=void 0,l=function(t){o=e.screenToGrid(t.offsetX,t.offsetY),b(),a()},c=function(){return o=null},h=function(){t.parentNode||(e.canvas.parentNode.appendChild(t),e.canvas.addEventListener("mousemove",l),e.canvas.addEventListener("mouseout",c))},u=function(){t.parentNode&&(t.parentNode.removeChild(t),e.canvas.removeEventListener("mousemove",l),e.canvas.removeEventListener("mouseout",c),c())},d=function(){var n=e.window,i=n.width,r=n.height,o=n.devicePixelRatio,s=e.getCellSize();t.width=i*s.width*o,t.height=r*s.height*o,t.style.width=i*s.width+"px",t.style.height=r*s.height+"px"},f=s("div");f.classList.add("draw-info");var v=void 0,p=void 0,m=void 0,g=new Map,w=[],y=[],b=void 0;e._debug={drawStart:function(e){m=e,v=Date.now(),w=[]},drawEnd:function(){p=Date.now(),console.log(f.textContent="Draw: "+m+" ("+(p-v)+" ms) with graphics="+e.window.graphics),b()},setCell:function(e,t){g.set(e,[t,Date.now()])},clipRect:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];w.push(t)},pushFrame:function(e){e.push(Date.now()),y.push(e),b()}};var _=void 0,k=document.createElement("canvas");k.width=k.height=12;var C=k.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(),_=n.createPattern(k,"repeat");var x=!1,S=0,T=0,E=function t(){x&&window.requestAnimationFrame(t);var s=(Date.now()-S)/1e3;S=Date.now(),T+=s;var a=e.window,l=a.devicePixelRatio,c=a.width,h=a.height,d=e.getCellSize(),f=d.width,v=d.height,p=c*h,m=Date.now();n.setTransform(l,0,0,l,0,0),n.clearRect(0,0,c*f,h*v);for(var b=0,k=0;k<p;k++)if(g.has(k)&&0!==g.get(k)[0]){var C=g.get(k),E=r(C,2),P=E[0],L=E[1],A=(m-L)/1e3;if(!(A>1)){b++,n.globalAlpha=.5*Math.max(0,1-A);var F=k%c,O=Math.floor(k/c);1&P&&(n.fillStyle="#f0f"),2&P&&(n.fillStyle="#0f0"),n.fillRect(F*f,O*v,f,v),4&P&&(n.lineWidth=2,n.strokeStyle="#f00",n.strokeRect(F*f,O*v,f,v))}}if(w.length){n.globalAlpha=.5,n.beginPath();var R=!0,D=!1,M=void 0;try{for(var B,N=w[Symbol.iterator]();!(R=(B=N.next()).done);R=!0){var I=B.value;n.rect.apply(n,i(I))}}catch(e){D=!0,M=e}finally{try{!R&&N.return&&N.return()}finally{if(D)throw M}}n.fillStyle=_,n.fill()}var H=!1;if(y.length){var j=[],z=!0,W=!1,q=void 0;try{for(var G,U=y[Symbol.iterator]();!(z=(G=U.next()).done);z=!0){var X=G.value,K=X[4],Y=Date.now()-K;Y>1e3?j.push(X):(H=!0,n.globalAlpha=1-Y/1e3,n.strokeStyle="#ff0",n.lineWidth=2,n.strokeRect(X[0]*f,X[1]*v,X[2]*f,X[3]*v))}}catch(e){W=!0,q=e}finally{try{!z&&U.return&&U.return()}finally{if(W)throw q}}var $=!0,J=!1,V=void 0;try{for(var Q,Z=j[Symbol.iterator]();!($=(Q=Z.next()).done);$=!0){var ee=Q.value;y.splice(y.indexOf(ee),1)}}catch(e){J=!0,V=e}finally{try{!$&&Z.return&&Z.return()}finally{if(J)throw V}}}o&&(n.save(),n.globalAlpha=1,n.lineWidth=1+.5*Math.sin(10*T),n.strokeStyle="#fff",n.lineJoin="round",n.setLineDash([2,2]),n.lineDashOffset=10*T,n.strokeRect(o[0]*f,o[1]*v,f,v),n.lineDashOffset+=2,n.strokeStyle="#000",n.strokeRect(o[0]*f,o[1]*v,f,v),n.restore()),0!==b||o||H||(x=!1,u())};b=function(){x||(h(),d(),x=!0,S=Date.now(),E())};var P=s("div");P.classList.add("debug-toolbar");var L=!1,A=s("div");A.classList.add("data-display"),P.appendChild(A);var F=s("div");F.classList.add("internal-display"),P.appendChild(F),P.appendChild(f);var O=s("div");O.classList.add("toolbar-buttons"),P.appendChild(O);var R=s("button");R.textContent="Redraw",R.addEventListener("click",function(t){e.renderer.resetDrawn(),e.renderer.draw("debug-redraw")}),O.appendChild(R);var D=s("button");D.textContent="Toggle Graphics",D.addEventListener("click",function(t){e.window.graphics=+!e.window.graphics}),O.appendChild(D);var M=function(){e.canvas.parentNode.appendChild(P)},B=function(){P.parentNode.removeChild(P)};e.on("update-window:debug",function(e){e!==L&&(L=e,e?M():(B(),u()))});var N=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()},I=function(e){return e<256?e:"#"+("000000"+(e-256).toString(16)).substr(-6)},H=function(t){if(t<0||t>e.screen.length)return"(-)";var n=0|e.renderer.drawnScreenAttrs[t],i=0|I(e.renderer.drawnScreenFG[t]),r=0|I(e.renderer.drawnScreenBG[t]),o=0|(e.renderer.drawnScreen[t]||"").codePointAt(0),s=o.toString(16).toUpperCase();s.length<4&&(s=("0000"+s).substr(-4)),s="U+"+s;var a=t%e.window.width;return"(("+Math.floor(t/e.window.width)+","+a+")="+t+":\\(bold)"+s+"\\():F"+i+":B"+r+":A("+N(n)+"))"},j=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,c=void 0;try{for(var h,u=o[Symbol.iterator]();!(a=(h=u.next()).done);a=!0){var d=h.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,c=e}finally{try{!a&&u.return&&u.return()}finally{if(l)throw c}}t=t.substr(n.index+n[0].length)}t&&r(t)},z={};a=function(){if(L){var t="C(("+e.cursor.y+","+e.cursor.x+"),hang:"+e.cursor.hanging+",vis:"+e.cursor.visible+")";if(o&&(t+=" m"+H(o[1]*e.window.width+o[0])),j(A,t),"flags"in z){var n=" ";n+=" flags:"+z.flags.toString(2),n+=" curAttrs:"+z.cursorAttrs.toString(2),n+=" Region:"+z.regionStart+"->"+z.regionEnd,n+=" Charset:"+z.charsetGx+" (0:"+z.charsetG0+",1:"+z.charsetG1+")",n+=" Heap:"+z.freeHeap,n+=" Clients:"+z.clientCount,j(F,n)}}},e.on("draw",a),e.on("internal",function(e){z=e,a()})}},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)}),n},s=function(){var e=i.pop();e.parentNode.removeChild(e)};return{update: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.add("inactive")}},labels:n}}},function(e,t,n){"use strict";function i(){return+s("#theme").val()}function r(){var e=c(".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(24),s=n(1),a=n(5),l=n(0),c=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(c("#default_fg"),e),o.initInput(c("#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],h=l[0],u=l[1],d=l[2],f=l[3];t.htmlAppend('<span class="preset" data-xfg="'+h+'" data-xbg="'+u+'" style="color:'+h+";background:"+u+'" 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=c("#theme"),t=e.selectedIndex;e.options[++t%e.options.length].selected=!0,r()},t.prevTheme=function(){var e=c("#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 c=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}}(),h=n(4),u=n(7),d=u.rgb2hex,f=u.hex2rgb,v=u.hsl2rgb,p=u.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),c(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,c=this.vx=w.cos(t+n)*e,h=this.vy=-w.sin(t+n)*e,u=(a+c)/2,d=(l+h)/2,f=(1-2*w.abs(r-.5))*i;this.x=a+(c-a)*r+(o-u)*f,this.y=l+(h-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),c="hsla("+w.round(this.hue*(360/y))+", 100%, 50%, ";l.addColorStop(0,c+"1)"),l.addColorStop(1,c+"0)"),a.fillStyle=l,a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s);var h=a.createLinearGradient(r,o,(e+n)/2,(t+i)/2);h.addColorStop(0,"#fff"),h.addColorStop(1,"rgba(255, 255, 255, 0)"),a.globalCompositeOperation="lighter",a.fillStyle=h,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 c=w.tan(r)*a,h=w.atan(c/l);h>y/6?h=y/6:h<-y/6&&(h=-y/6),n+=h-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 u=this.lightness=w.sin(i)*a/this.triangleSideLength+.5,d=1-2*w.abs(u-.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=u,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}(h)}]);
//# sourceMappingURL=app.69e5b77.js.map