* This file is part of jQuery Terminal. http://terminal.jcubic.pl
*
* Copyright (c) 2010-2017 Jakub Jankiewicz <http://jcubic.pl/me>
* Released under the MIT license
*
* Contains:
*
* Storage plugin Distributed under the MIT License
* Copyright (c) 2010 Dave Schindler
*
* jQuery Timers licenced with the WTFPL
* <http://jquery.offput.ca/timers/>
*
* Cross-Browser Split 1.1.1
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
* Available under the MIT License
*
* jQuery Caret
* Copyright (c) 2009, Gideon Sireling
* 3 clause BSD License
*
* sprintf.js
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 09 Apr 2017 08:41:51 +0000
*/
(function(e){varn=function(){if(!n.cache.hasOwnProperty(arguments[0])){n.cache[arguments[0]]=n.parse(arguments[0])}returnn.format.call(null,n.cache[arguments[0]],arguments)};n.format=function(e,t){varo=1,a=e.length,s="",l,f=[],c,u,p,m,h,d;for(c=0;c<a;c++){s=r(e[c]);if(s==="string"){f.push(e[c])}elseif(s==="array"){p=e[c];if(p[2]){l=t[o];for(u=0;u<p[2].length;u++){if(!l.hasOwnProperty(p[2][u])){thrown('[sprintf] property "%s" does not exist',p[2][u])}l=l[p[2][u]]}}elseif(p[1]){l=t[p[1]]}else{l=t[o++]}if(/[^s]/.test(p[8])&&r(l)!=="number"){thrown("[sprintf] expecting number but found %s",r(l))}switch(p[8]){case"b":l=l.toString(2);break;case"c":l=String.fromCharCode(l);break;case"d":l=parseInt(l,10);break;case"e":l=p[7]?l.toExponential(p[7]):l.toExponential();break;case"f":l=p[7]?parseFloat(l).toFixed(p[7]):parseFloat(l);break;case"o":l=l.toString(8);break;case"s":l=(l=String(l))&&p[7]?l.substring(0,p[7]):l;break;case"u":l=l>>>0;break;case"x":l=l.toString(16);break;case"X":l=l.toString(16).toUpperCase();break}l=/[def]/.test(p[8])&&p[3]&&l>=0?" +"+l:l;h=p[4]?p[4]==="0"?"0":p[4].charAt(1):" ";d=p[6]-String(l).length;m=p[6]?i(h,d):"";f.push(p[5]?l+m:m+l)}}returnf.join("")};n.cache={};n.parse=function(e){varn=e,t=[],r=[],i=0;while(n){if((t=/^[^\x25]+/.exec(n))!==null){r.push(t[0])}elseif((t=/^\x25{2}/.exec(n))!==null){r.push("%")}elseif((t=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(n))!==null){if(t[2]){i|=1;varo=[],a=t[2],s=[];if((s=/^([a-z_][a-z_\d]*)/i.exec(a))!==null){o.push(s[1]);while((a=a.substring(s[0].length))!==""){if((s=/^\.([a-z_][a-z_\d]*)/i.exec(a))!==null){o.push(s[1])}elseif((s=/^\[(\d+)\]/.exec(a))!==null){o.push(s[1])}else{throw"[sprintf] huh?"}}}else{throw"[sprintf] huh?"}t[2]=o}else{i|=2}if(i===3){throw"[sprintf] mixing positional and named placeholders is not (yet) supported"}r.push(t)}else{throw"[sprintf] huh?"}n=n.substring(t[0].length)}returnr};vart=function(e,t,r){r=t.slice(0);r.splice(0,0,e);returnn.apply(null,r)};functionr(e){returnObject.prototype.toString.call(e).slice(8,-1).toLowerCase()}functioni(e,n){for(vart=[];n>0;t[--n]=e){}returnt.join("")}e.sprintf=n;e.vsprintf=t})(typeofglobal!=="undefined"?global:window);(function(e,n){"use strict";e.omap=function(n,t){varr={};e.each(n,function(e,i){r[e]=t.call(n,e,i)});returnr};vart={clone_object:function(n){vart={};if(typeofn==="object"){if(e.isArray(n)){returnthis.clone_array(n)}elseif(n===null){returnn}else{for(varrinn){if(e.isArray(n[r])){t[r]=this.clone_array(n[r])}elseif(typeofn[r]==="object"){t[r]=this.clone_object(n[r])}else{t[r]=n[r]}}}}returnt},clone_array:function(n){if(!e.isFunction(Array.prototype.map)){thrownewError("Your browser don't support ES5 array map "+"use es5-shim")}returnn.slice(0).map(function(e){if(typeofe==="object"){returnthis.clone_object(e)}else{returne}}.bind(this))}};varr=function(e){returnt.clone_object(e)};vari=function(){vare="test",n=window.localStorage;try{n.setItem(e,"1");n.removeItem(e);returntrue}catch(t){returnfalse}};varo=i();functiona(e,n){vart;if(typeofe==="string"&&typeofn==="string"){localStorage[e]=n;returntrue}elseif(typeofe==="object"&&typeofn==="undefined"){for(tine){if(e.hasOwnProperty(t)){localStorage[t]=e[t]}}returntrue}returnfalse}functions(e,n){vart,r,i;t=newDate;t.setTime(t.getTime()+31536e6);r="; expires="+t.toGMTString();if(typeofe==="string"&&typeofn==="string"){document.cookie=e+"="+n+r+"; path=/";returntrue}elseif(typeofe==="object"&&typeofn==="undefined"){for(iine){if(e.hasOwnProperty(i)){document.cookie=i+"="+e[i]+r+"; path=/"}}returntrue}returnfalse}functionl(e){returnlocalStorage[e]}functionf(e){varn,t,r,i;n=e+"=";t=document.cookie.split(";");for(r=0;r<t.length;r++){i=t[r];while(i.charAt(0)===" "){i=i.substring(1,i.length)}if(i.indexOf(n)===0){returni.substring(n.length,i.length)}}returnnull}functionc(e){returndeletelocalStorage[e]}functionu(e){returns(e,"",-1)}e.extend({Storage:{set:o?a:s,get:o?l:f,remove:o?c:u}});varp=e;p.fn.extend({everyTime:function(e,n,t,r,i){returnthis.each(function(){p.timer.add(this,e,n,t,r,i)})},oneTime:function(e,n,t){returnthis.each(function(){p.timer.add(this,e,n,t,1)})},stopTime:function(e,n){returnthis.each(function(){p.timer.remove(this,e,n)})}});p.extend({timer:{guid:1,global:{},regex:/^([0-9]+)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1e3,das:1e4,hs:1e5,ks:1e6},timeParse:function(e){if(e===n||e===null){returnnull}vart=this.regex.exec(p.trim(e.toString()));if(t[2]){varr=parseInt(t[1],10);vari=this.powers[t[2]]||1;returnr*i}else{returne}},add:function(e,n,t,r,i,o){vara=0;if(p.isFunction(t)){if(!i){i=r}r=t;t=n}n=p.timer.timeParse(n);if(typeofn!=="number"||isNaN(n)||n<=0){return}if(i&&i.constructor!==Number){o=!!i;i=0}i=i||0;o=o||false;if(!e.$timers){e.$timers={}}if(!e.$timers[t]){e.$timers[t]={}}r.$timerID=r.$timerID||this.guid++;vars=function(){if(o&&s.inProgress){return}s.inProgress=true;if(++a>i&&i!==0||r.call(e,a)===false){p.timer.remove(e,t,r)}s.inProgress=false};s.$timerID=r.$timerID;if(!e.$timers[t][r.$timerID]){e.$timers[t][r.$timerID]=window.setInterval(s,n)}if(!this.global[t]){this.global[t]=[]}this.global[t].push(e)},remove:function(e,n,t){varr=e.$timers,i;if(r){if(!n){for(varoinr){if(r.hasOwnProperty(o)){this.remove(e,o,t)}}}elseif(r[n]){if(t){if(t.$timerID){window.clearInterval(r[n][t.$timerID]);deleter[n][t.$timerID]}}else{for(varainr[n]){if(r[n].hasOwnProperty(a)){window.clearInterval(r[n][a]);deleter[n][a]}}}for(iinr[n]){if(r[n].hasOwnProperty(i)){break}}if(!i){i=null;deleter[n]}}for(iinr){if(r.hasOwnProperty(i)){break}}if(!i){e.$timers=null}}}}});if(/(msie)([\w.]+)/.exec(navigator.userAgent.toLowerCase())){p(window).one("unload",function(){vare=p.timer.global;for(varnine){if(e.hasOwnProperty(n)){vart=e[n],r=t.length;while(--r){p.timer.remove(t[r],n)}}}})}(function(e){if(!String.prototype.split.toString().match(/\[native/)){return}varn=String.prototype.split,t=/()??/.exec("")[1]===e,r;r=function(r,i,o){if(Object.prototype.toString.call(i)!=="[object RegExp]"){returnn.call(r,i,o)}vara=[],s=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.extended?"x":"")+(i.sticky?"y":""),l=0,f,c,u,p;i=newRegExp(i.source,s+"g");r+="";if(!t){f=newRegExp("^"+i.source+"$(?!\\s)",s)}o=o===e?-1>>>0:o>>>0;while(c=i.exec(r)){u=c.index+c[0].length;if(u>l){a.push(r.slice(l,c.index));if(!t&&c.length>1){c[0].replace(f,function(){for(varn=1;n<arguments.length-2;n++){if(arguments[n]===e){c[n]=e}}})}if(c.length>1&&c.index<r.length){Array.prototype.push.apply(a,c.slice(1))}p=c[0].length;l=u;if(a.length>=o){break}}if(i.lastIndex===c.index){i.lastIndex++}}if(l===r.length){if(p||!i.test("")){a.push("")}}else{a.push(r.slice(l))}returna.length>o?a.slice(0,o):a};String.prototype.split=function(e,n){returnr(this,e,n)};returnr})();e.fn.caret=function(e){varn=this[0];vart=n.contentEditable==="true";if(arguments.length===0){if(window.getSelection){if(t){n.focus();varr=window.getSelection().getRangeAt(0),i=r.cloneRange();i.selectNodeContents(n);i.setEnd(r.endContainer,r.endOffset);returni.toString().length}returnn.selectionStart}if(document.selection){n.focus();if(t){varr=document.selection.createRange(),i=document.body.createTextRange();i.moveToElementText(n);i.setEndPoint("EndToEnd",r);returni.text.length}vare=0,o=n.createTextRange(),i=document.selection.createRange().duplicate(),a=i.getBookmark();o.moveToBookmark(a);while(o.moveStart("character",-1)!==0)e++;returne}return0}if(e===-1)e=this[t?"text":"val"]().length;if(window.getSelection){if(t){n.focus();window.getSelection().collapse(n.firstChild,e)}elsen.setSelectionRange(e,e)}elseif(document.body.createTextRange){varo=document.body.createTextRange();o.moveToElementText(n);o.moveStart("character",e);o.collapse(true);o.select()}if(!t)n.focus();returne};functionm(e,n){vart=[];varr=e.length;if(r<n){return[e]}elseif(n<0){thrownewError("str_parts: length can't be negative")}for(vari=0;i<r;i+=n){t.push(e.substring(i,i+n))}returnt}functionh(n){vart=n?[n]:[];varr=0;e.extend(this,{get:function(){returnt},rotate:function(){if(!t.filter(Boolean).length){return}if(t.length===1){returnt[0]}else{if(r===t.length-1){r=0}else{++r}if(t[r]){returnt[r]}else{returnthis.rotate()}}},length:function(){returnt.length},remove:function(e){deletet[e]},set:function(e){for(varn=t.length;n--;){if(t[n]===e){r=n;return}}this.append(e)},front:function(){if(t.length){vare=r;varn=false;while(!t[e]){e++;if(e>t.length){if(n){break}e=0;n=true}}returnt[e]}},append:function(e){t.push(e)}})}functiond(n){vart=ninstanceofArray?n:n?[n]:[];e.extend(this,{data:function(){returnt},map:function(n){returne.map(t,n)},size:function(){returnt.length},pop:function(){if(t.length===0){returnnull}else{vare=t[t.length-1];t=t.slice(0,t.length-1);returne}},push:function(e){t=t.concat([e]);returne},top:function(){returnt.length>0?t[t.length-1]:null},clone:function(){returnnewd(t.slice(0))}})}functiong(n,t,r){vari=true;varo="";if(typeofn==="string"&&n!==""){o=n+"_"}o+="commands";vara;if(r){a=[]}else{a=e.Storage.get(o);a=a?e.parseJSON(a):[]}vars=a.length-1;e.extend(this,{append:function(n){if(i){if(a[a.length-1]!==n){a.push(n);if(t&&a.length>t){a=a.slice(-t)}s=a.length-1;if(!r){e.Storage.set(o,JSON.stringify(a))}}}},set:function(n){if(ninstanceofArray){a=n;if(!r){e.Storage.set(o,JSON.stringify(a))}}},data:function(){returna},reset:function(){s=a.length-1},last:function(){returna[a.length-1]},end:function(){returns===a.length-1},position:function(){returns},current:function(){returna[s]},next:function(){if(s<a.length-1){++s}if(s!==-1){returna[s]}},previous:function(){vare=s;if(s>0){--s}if(e!==-1){returna[s]}},clear:function(){a=[];this.purge()},enabled:function(){returni},enable:function(){i=true},purge:function(){if(!r){e.Storage.remove(o)}},disable:function(){i=false}})}varv=0;e.fn.cmd=function(t){varr=e.extend({pauseEvents:true},t);vari=this;varo=i.data("cmd");if(o){returno}vara=v++;i.addClass("cmd");i.append('<span class="prompt"></span><span></span>'+'<span class="cursor"> </span><span></span>');vars=e("<textarea>").attr({autocapitalize:"off",spellcheck:"false"}).addClass("clipboard").appendTo(i);if(r.width){i.width(r.width)}varl;varf;varc=i.find(".prompt");varu=false;varp="";varh=null;vard;varw=r.mask||false;varb="";vark;varx="";varT=0;varE;varR;varC=r.historySize||60;varS,A;varF=i.find(".cursor");varL;varO=0;functionP(){varn=e("<span> </span>").appendTo(i);vart=n[0].getBoundingClientRect();n.remove();returnt}functionj(e){varn=i.find(".prompt").text().length;vart=P();varr=t.width;varo=t.height;vara=i.offset();vars=Math.floor((e.x-a.left)/r);varl=Math.floor((e.y-a.top)/o);varf=te(b);varc;if(l>0&&f.length>1){c=s+f.slice(0,l).reduce(function(e,n){returne+n.length},0)}else{c=s-n}varu=b.replace(/\t/g,"\x00\x00\x00\x00");varp=u.slice(0,c);varm=p.replace(/\x00{4}/g," ").replace(/\x00+/,"").length;returnm>b.length?b.length:m}functionI(e){if(e.key){varn=e.key.toUpperCase();if(n==="CONTROL"){return"CTRL"}else{vart=[];if(e.ctrlKey){t.push("CTRL")}if(e.metaKey&&n!=="META"){t.push("META")}if(e.shiftKey&&n!=="SHIFT"){t.push("SHIFT")}if(e.altKey&&n!=="ALT"){t.push("ALT")}if(e.key){if(n==="DEL"){t.push("DELETE")}else{t.push(n)}}returnt.join("+")}}}varN;var$={"ALT+D":function(){i.set(b.slice(0,T)+b.slice(T).replace(/ *[^]+ *(?=)|[^]+$/,""),true);returnfalse},ENTER:function(){if(A&&b&&!w&&(e.isFunction(r.historyFilter)&&r.historyFilter(b))||r.historyFilterinstanceofRegExp&&b.match(r.historyFilter)||!r.historyFilter){A.append(b)}varn=b;A.reset();i.set("");if(r.commands){r.commands(n)}if(e.isFunction(E)){oe()}e(".clipboard").val("");returntrue},"SHIFT+ENTER":function(){i.insert("\n");returnfalse},BACKSPACE:function(){if(u){p=p.slice(0,-1);Q()}elseif(b!==""&&T>0){i["delete"](-1)}returnfalse},TAB:function(){i.insert(" ")},"CTRL+D":function(){i["delete"](1);returnfalse},DELETE:function(){i["delete"](1);returntrue},ARROWUP:B,UP:B,"CTRL+P":B,ARROWDOWN:M,DOWN:M,"CTRL+N":M,ARROWLEFT:W,LEFT:W,"CTRL+B":W,"CTRL+ARROWLEFT":function(){vare=T-1;varn=0;if(b[e]===" "){--e}for(vart=e;t>0;--t){if(b[t]===" "&&b[t+1]!==" "){n=t+1;break}elseif(b[t]==="\n"&&b[t+1]!=="\n"){n=t;break}}i.position(n)},"CTRL+R":function(){if(u){ee(true)}else{d=E;Q();k=b;i.set("");ie();u=true}returnfalse},"CTRL+G":function(){if(u){E=d;oe();i.set(k);ie();u=false;p="";returnfalse}},ARROWRIGHT:U,"CTRL+F":U,RIGHT:U,"CTRL+ARROWRIGHT":function(){if(b[T]===" "){++T}vare=/\S[\n\s]{2,}|[\n\s]+\S?/;varn=b.slice(T).match(e);if(!n||n[0].match(/^\s+$/)){i.position(b.length)}elseif(n[0][0]!==" "){T+=n.index+1}else{T+=n.index+n[0].length-1;if(n[0][n[0].length-1]!==" "){--T}}ie()},F12:H,END:J,"CTRL+E":J,HOME:q,"CTRL+A":q,"SHIFT+INSERT":D,"CTRL+SHIFT+T":H,"CTRL+W":function(){if(b!==""&&T!==0){vare=b.slice(0,T).match(/([^]+ *$)/);x=i["delete"](-e[0].length);K(i,x)}returnfalse},"CTRL+H":function(){if(b!==""&&T>0){i["delete"](-1)}returnfalse},"CTRL+X":H,"CTRL+C":H,"CTRL+T":H,"CTRL+Y":function(){if(x!==""){i.insert(x)}},"CTRL+V":D,"META+V":D,"CTRL+K":function(){x=i["delete"](b.length-T);K(i,x);returnfalse},"CTRL+U":function(){if(b!==""&&T!==0){x=i["delete"](-T);K(i,x)}returnfalse},"CTRL+TAB":function(){returnfalse},"META+`":H,"META+R":H,"META+L":H};functionH(){returntrue}functionD(){s.val("");O=0;s.focus();s.on("input",functione(n){ae(n);s.off("input",e)});returntrue}functionB(){if(le){k=b;i.set(A.current())}else{i.set(A.previous())}le=false;returnfalse}functionM(){i.set(A.end()?k:A.next());returnfalse}functionW(){if(T>0){i.position(-1,true);ie()}}functionU(){if(T<b.length){i.position(1,true)}returnfalse}functionq(){i.position(0)}functionJ(){i.position(b.length)}functionG(){vare=s.is(":focus");if(R){if(!e){s.focus();i.oneTime(10,function(){s.focus()})}}elseif(e){s.blur()}}functionY(){i.oneTime(10,function(){s.val(b);if(R){i.oneTime(10,function(){try{s.caret(T)}catch(e){}})}})}if(y&&!_){L=function(e){if(e){F.addClass("blink")}else{F.removeClass("blink")}}}else{varX=false;L=function(e){if(e&&!X){X=true;F.addClass("inverted blink");i.everyTime(500,"blink",V)}elseif(X&&!e){X=false;i.stopTime("blink",V);F.removeClass("inverted blink")}}}functionV(){F.toggleClass("inverted")}functionQ(){E="(reverse-i-search)`"+p+"': ";oe()}functionZ(){E=d;u=false;h=null;p=""}functionee(n){vart=A.data();varr,o;vara=t.length;if(n&&h>0){a-=h}if(p.length>0){for(vars=p.length;s>0;s--){o=e.terminal.escape_regex(p.substring(0,s));r=newRegExp(o);for(varl=a;l--;){if(r.test(t[l])){h=t.length-l;i.position(t[l].indexOf(o));i.set(t[l],true);ie();if(p.length!==s){p=p.substring(0,s);Q()}return}}}}p=""}functionne(){vare=i.width();varn=F[0].getBoundingClientRect().width;l=Math.floor(e/n)}functionte(e){varn;if(e.match(/\n/)){vart=e.split("\n");varr=l-f-1;for(vari=0;i<t.length-1;++i){t[i]+=" "}if(t[0].length>r){n=[t[0].substring(0,r)];varo=t[0].substring(r);n=n.concat(m(o,l))}else{n=[t[0]]}for(i=1;i<t.length;++i){if(t[i].length>l){n=n.concat(m(t[i],l))}else{n.push(t[i])}}}else{vara=e.substring(0,l-f);vars=e.substring(l-f);n=[a].concat(m(s,l))}returnn}functionre(n){vart=e.terminal.defaults.formatters;for(varr=0;r<t.length;++r){try{if(typeoft[r]==="function"){vari=t[r](n);if(typeofi==="string"){n=i}}}catch(o){alert("formatting error at formatters["+r+"]\n"+(o.stack?o.stack:o))}}returne.terminal.format(e.terminal.encode(n))}varie=function(){vart=F.prev();varr=F.next();functiono(e,n){vari=e.length;if(n===i){t.html(re(e));F.html(" ");r.html("")}elseif(n===0){t.html("");F.html(re(e.slice(0,1)));r.html(re(e.slice(1)))}else{varo=e.slice(0,n);t.html(re(o));vara=e.slice(n,n+1);F.html(re(a));if(n===e.length-1){r.html("")}else{r.html(re(e.slice(n+1)))}}}functiona(e){return"<div>"+re(e)+"</div>"}functions(n){vart=r;e.each(n,function(n,r){t=e(a(r)).insertAfter(t)})}functionc(n){e.each(n,function(e,n){t.before(a(n))})}returnfunction(){varu;switch(typeofw){case"boolean":u=w?b.replace(/./g,"*"):b;break;case"string":u=b.replace(/./g,w);break}varp;i.find("div").remove();t.html("");if(u.length>l-f-1||u.match(/\n/)){varm=u.match(/\t/g);varh=m?m.length*3:0;if(m){u=u.replace(/\t/g,"\x00\x00\x00\x00")}vard=te(u);if(m){d=e.map(d,function(e){returne.replace(/\x00\x00\x00\x00/g," ")})}varg=d[0].length;if(g===0&&d.length===1){}elseif(T<g){o(d[0],T);s(d.slice(1))}elseif(T===g){t.before(a(d[0]));o(d[1]||"",0);if(d.length>1){s(d.slice(2))}}else{varv=d.length;if(T<g){o(d[0],T);s(d.slice(1))}elseif(T===g){t.before(a(d[0]));o(d[1],0);s(d.slice(2))}else{vary=d.slice(-1)[0];var_=u.length-T-h;vark=y.length;varx=0;if(_<=k){c(d.slice(0,-1));if(k===_){x=0}else{x=k-_}o(y,x)}elseif(v===3){varE=re(d[0]);t.before("<div>"+E+"</div>");o(d[1],T-g-1);E=re(d[2]);r.after("<div>"+E+"</div>")}else{varR;varC;x=T;for(p=0;p<d.length;++p){varS=d[p].length;if(x>S){x-=S}else{break}}C=d[p];R=p;if(x===C.length){x=0;C=d[++R];if(C===n){varA=e.terminal.defaults.strings.redrawError;thrownewError(A)}}o(C,x);c(d.slice(0,R));s(d.slice(R+1))}}}}elseif(u===""){t.html("");F.html(" ");r.html("")}else{o(u,T)}}}();varoe=function(){functionn(n){c.html(e.terminal.format(e.terminal.encode(n)));f=c.text().length}returnfunction(){switch(typeofE){case"string":n(E);break;case"function":E(n);break}}}();functionae(){if(O++>0){return}if(i.isenabled()){vare=i.find("textarea");if(!e.is(":focus")){e.focus()}i.oneTime(100,function(){i.insert(e.val());e.val("");Y()})}}functionse(){if(e.isFunction(r.onCommandChange)){r.onCommandChange(b)}}e.extend(i,{name:function(e){if(e!==n){S=e;vart=A&&A.enabled()||!A;A=newg(e,C,r.history==="memory");if(!t){A.disable()}returni}else{returnS}},purge:function(){A.clear();returni},history:function(){returnA},"delete":function(e,n){vart;if(e===0){returni}elseif(e<0){if(T>0){t=b.slice(0,T).slice(e);b=b.slice(0,T+e)+b.slice(T,b.length);if(!n){i.position(T+e)}se()}}elseif(b!==""&&T<b.length){t=b.slice(T).slice(0,e);b=b.slice(0,T)+b.slice(T+e,b.length);se()}ie();Y();returnt},set:function(e,t){if(e!==n){b=e;if(!t){i.position(b.length)}ie();Y();se()}returni},keymap:function(n){if(typeofn==="undefined"){returnN}else{N=e.extend({},$,e.omap(n||{},function(e,n){returnfunction(t){returnn(t,$[e])}}));returni}},insert:function(e,n){if(T===b.length){b+=e}elseif(T===0){b=e+b}else{b=b.slice(0,T)+e+b.slice(T)}if(!n){i.position(e.length,true)}else{Y()}ie();se();returni},get:function(){returnb},commands:function(e){if(e){r.commands=e;returni}else{returne}},destroy:function(){ye.unbind("keypress.cmd",_e);ye.unbind("keydown.cmd",ve);ye.unbind("paste.cmd",ae);ye.unbind("input.cmd",we);i.stopTime("blink",V);i.find(".cursor").next().remove().end().prev().remove().end().remove();i.find(".prompt, .clipboard").remove();i.removeClass("cmd").removeData("cmd").off(".cmd");returni},prompt:function(e){if(e===n){returnE}else{if(typeofe==="string"||typeofe==="function"){E=e}else{thrownewError("prompt must be a function or string")}oe();ie();returni}},kill_text:function(){returnx},position:function(n,t){if(typeofn==="number"){if(t){T+=n}elseif(n<0){T=0}elseif(n>b.length){T=b.length}else{T=n}if(e.isFunction(r.onPositionChange)){r.onPositionChange(T)}ie();Y();returni}else{returnT}},visible:function(){vare=i.visible;returnfunction(){e.apply(i,[]);ie();oe()}}(),show:function(){vare=i.show;returnfunction(){e.apply(i,[]);ie();oe()}}(),resize:function(e){if(e){l=e}else{ne()}ie();returni},enable:function(){R=true;i.addClass("enabled");try{s.caret(T)}catch(e){}L(true);G();returni},isenabled:function(){returnR},disable:function(){R=false;i.removeClass("enabled");L(false);G();returni},mask:function(e){if(typeofe==="undefined"){returnw}else{w=e;ie();returni}}});i.name(r.name||r.prompt||"");if(typeofr.prompt==="string"){E=r.prompt}else{E="> "}oe();if(r.enabled===n||r.enabled===true){i.enable()}if(!r.history){A.disable()}varle=true;varfe=false;varce=false;varue=false;varpe=false;varme=false;varhe=false;varde;varge;functionve(t){varo;ce=pe&&ue;try{ue=t.key&&t.key.length===1;me=String(t.key).toLowerCase()==="unidentified";he=t.key.toUpperCase()==="BACKSPACE"||t.which===8}catch(a){}ge=s.val();pe=true;varl=I(t);if(R||!r.pauseEvents){if(e.isFunction(r.keydown)){o=r.keydown(t);if(o!==n){returno}}}if(R){de=["CTRL+V","META+V"].indexOf(l)!==-1;if(t.which!==38&&!(t.which===80&&t.ctrlKey)){le=true}if(u&&(t.which===35||t.which===36||t.which===37||t.which===38||t.which===39||t.which===40||t.which===13||t.which===27)){Z();oe();if(t.which===27){i.set("")}ie();ve.call(this,t)}elseif(e.isFunction(N[l])){o=N[l]();if(o===true){return}if(o!==n){returno}}elseif(t.altKey){return}else{fe=false;return}t.preventDefault()}elseif(!r.pauseEvents&&e.isFunction(N[l])){o=N[l]();if(o===true){return}if(o!==n){returno}}}varye=e(document.documentElement||window);i.keymap(r.keymap);function_e(t){varo;pe=false;if((t.ctrlKey||t.metaKey)&&[99,118,86].indexOf(t.which)!==-1){return}if(fe){return}if(R||!r.pauseEvents){if(e.isFunction(r.keypress)){o=r.keypress(t);if(o!==n){returno}}}vara;if(z()){a=t.key}if(!a||me){a=String.fromCharCode(t.which)}if(a.toUpperCase()==="SPACEBAR"){a=" "}if(R){if(e.inArray(t.which,[13,0,8])>-1){if(t.keyCode===123){return}returnfalse}elseif(a&&(!t.ctrlKey||t.ctrlKey&&t.ctrlKey)&&(!(t.altKey&&t.which===100)||t.altKey)&&!ce){if(u){p+=a;ee();Q()}else{i.insert(a)}returnfalse}}}functionwe(){if((pe||ce)&&!de&&(ue||me)&&!he){vare=T;varn=s.val();if(n!==""){if(u){p=n;ee();Q()}else{i.set(n)}if(he||n.length<ge.length){i.position(e-1)}else{i.position(e+Math.abs(n.length-ge.length))}}}}ye.bind("keypress.cmd",_e).bind("keydown.cmd",ve).bind("input.cmd",we);(function(){varn=false;vart=false;varo=0;i.on("mousedown.cmd",function(){t=true;i.oneTime(1,function(){e(window).on("mousemove.cmd_"+a,function(){n=true;e(window).off("mousemove.cmd_"+a)})})}).on("mouseup.cmd",function(s){varl=n;n=false;e(window).off("mousemove.cmd_"+a);if(!l){varf="click_"+a;if(++o===1){varc=t;if(R){i.oneTime(r.clickTimeout,f,function(){if(!e(s.target).is(".prompt")&&c){i.position(j({x:s.pageX,y:s.pageY}))}o=0})}else{o=0}}else{i.stopTime(f);o=0}}t=false})})();i.data("cmd",i);if(!("KeyboardEvent"inwindow&&"key"inwindow.KeyboardEvent.prototype)){setTimeout(function(){thrownewError("key event property not supported try "+"https://github.com/cvan/keyboardevent-key-polyfill")},0)}returni};vary=function(){vare=false,t="Webkit Moz O ms Khtml".split(" "),r=document.createElement("div");if(r.style.animationName){e=true}if(e===false){for(vari=0;i<t.length;i++){varo=t[i]+"AnimationName";if(r.style[o]!==n){e=true;break}}}returne}();var_=navigator.userAgent.toLowerCase().indexOf("android")!==-1;varw=function(){return"ontouchstart"inwindow||!!window.DocumentTouch&&documentinstanceofwindow.DocumentTouch}();functionb(e,n){vart=n(e);if(t.length){varr=t.shift();vari=e.substring(r.length).trim();return{command:e,name:r,args:t,rest:i}}else{return{command:e,name:"",args:[],rest:""}}}vark=/(\[\[[!gbiuso]*;[^;]*;[^\]]*\](?:[^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?)/i;varx=/\[\[([!gbiuso]*);([^;]*);([^;\]]*);?([^;\]]*);?([^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?/gi;varT=/\[\[([!gbiuso]*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]?/gi;varE=/\[\[([!gbiuso]*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]/gi;varR=/^\[\[([!gbiuso]*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^[]*\[[^\]]*)\]$/gi;varC=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i;varS=/(\bhttps?:\/\/(?:(?:(?!&[^;]+;)|(?=&))[^\s"'<>\][)])+\b)/gi;varA=/\b(https?:\/\/(?:(?:(?!&[^;]+;)|(?=&))[^\s"'<>\][)])+)\b(?![^[\]]*])/gi;varF=/((([^<>('")[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))/g;varL=/('(?:[^']|\\')*'|"(\\"|[^"])*"|(?:\/(\\\/|[^\/])+\/[gimy]*)(?=:? |$)|(\\\s|\S)+|[\w-]+)/gi;varO=/(\[\[[!gbiuso]*;[^;]*;[^\]]*\])/i;varP=/^(\[\[[!gbiuso]*;[^;]*;[^\]]*\])/i;varj=/\[\[[!gbiuso]*;[^;]*;[^\]]*\]?$/i;varI=/(\[\[(?:[^\]]|\\\])*\]\])/;varN=/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;var$=/^\/((?:\\\/|[^\/]|\[[^\]]*\/[^\]]*\])+)\/([gimy]*)$/;e.terminal={version:"1.1.1",color_names:["transparent","currentcolor","black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],valid_color:function(n){if(n.match(C)){returntrue}else{returne.inArray(n.toLowerCase(),e.terminal.color_names)!==-1}},escape_regex:function(e){if(typeofe==="string"){varn=/([-\\^$[\]()+{}?*.|])/g;returne.replace(n,"\\$1")}},have_formatting:function(e){returntypeofe==="string"&&!!e.match(E)},is_formatting:function(e){returntypeofe==="string"&&!!e.match(R)},format_split:function(e){returne.split(k)},split_equal:function(n,t,r){vari=false;varo=false;vara="";vars=[];varl=n.replace(T,function(e,n,t){varr=n.match(/;/g).length;if(r>=4){returne}elseif(r===2){r=";;"}elseif(r===3){r=";"}else{r=""}vari=t.replace(/\\\]/g,"]").replace(/\n/g,"\\n").replace(/ /g," ");return"[["+n+r+i+"]"+t+"]"}).split(/\n/g);functionf(){returnm.substring(y-6,y)===" "||m.substring(y-1,y)===" "}functionc(){vare=g.match(T);if(e){varn=e[e.length-1];if(n[n.length-1]!=="]"){a=n.match(O)[1];g+="]"}elseif(g.match(j)){g=g.replace(j,"");a=n.match(O)[1]}}}for(varu=0,p=l.length;u<p;++u){if(l[u]===""){s.push("");continue}varm=l[u];varh=0;vard=0;varg;varv=-1;for(vary=0,_=m.length;y<_;++y){if(m.substring(y).match(P)){i=true;o=false}elseif(i&&m[y]==="]"){if(o){i=false;o=false}else{o=true}}elseif(i&&o||!i){if(m[y]==="&"){varw=m.substring(y).match(/^(&[^;]+;)/);if(!w){thrownewError("Unclosed html entity in line "+(u+1)+" at char "+(y+1))}y+=w[1].length-2;if(y===_-1){s.push(g+w[1])}continue}elseif(m[y]==="]"&&m[y-1]==="\\"){--d}else{++d}}if(f()&&(i&&o||!i||m[y]==="["&&m[y+1]==="[")){v=y}if((d===t||y===_-1)&&(i&&o||!i)){var b=e.terminal.strip(m.substring(v));b=e("<span>"+b+"</span>").text();var k=b.length;b=b.substring(0,y+t+1);var x=!!b.match(/\s/)||y+t+1>k;if(r&&v!==-1&&y!==_-1&&x){g=m.substring(h,v);y=v-1}else{g=m.substring(h,y+1)}if(r){g=g.replace(/( |\s)+$/g,"")}v=-1;h=y+1;d=0;if(a){g=a+g;if(g.match("]")){a=""}}c();s.push(g)}}}returns},encode:function(e){e=e.replace(/&(?!#[0-9]+;|[a-zA-Z]+;)/g,"&");returne.replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\t/g," ")},escape_formatting:function(n){returne.terminal.escape_brackets(e.terminal.encode(n))},format:function(n,t){varr=e.extend({},{linksNoReferrer:false},t||{});if(typeofn==="string"){vari=e.terminal.format_split(n);n=e.map(i,function(n){if(n===""){returnn}elseif(e.terminal.is_formatting(n)){n=n.replace(/\[\[[^\]]+\]/,function(e){returne.replace(/ /g," ")});returnn.replace(x,function(n,t,i,o,a,s,l){if(l===""){return""}l=l.replace(/\\]/g,"]");varf="";if(t.indexOf("b")!==-1){f+="font-weight:bold;"}varc=[];if(t.indexOf("u")!==-1){c.push("underline")}if(t.indexOf("s")!==-1){c.push("line-through")}if(t.indexOf("o")!==-1){c.push("overline")}if(c.length){f+="text-decoration:"+c.join(" ")+";"}if(t.indexOf("i")!==-1){f+="font-style:italic;"}if(e.terminal.valid_color(i)){f+="color:"+i+";";if(t.indexOf("g")!==-1){f+="text-shadow:0 0 5px "+i+";"}}if(e.terminal.valid_color(o)){f+="background-color:"+o}varu;if(s===""){u=l}else{u=s.replace(/]/g,"]")}varp;if(t.indexOf("!")!==-1){if(u.match(F)){p='<a href="mailto:'+u+'" '}else{p='<a target="_blank" href="'+u+'" ';if(r.linksNoReferrer){p+='rel="noreferrer" '}}}else{p="<span"}if(f!==""){p+=' style="'+f+'"'}if(a!==""){p+=' class="'+a+'"'}if(t.indexOf("!")!==-1){p+=">"+l+"</a>"}else{p+=' data-text="'+u.replace('"',""e;")+'">'+l+"</span>"}returnp})}else{return"<span>"+n.replace(/\\\]/g,"]")+"</span>"}}).join("");returnn.replace(/<span><br\s*\/?><\/span>/gi,"<br/>")}else{return""}},escape_brackets:function(e){returne.replace(/\[/g,"[").replace(/\]/g,"]")},strip:function(e){returne.replace(x,"$6")},active:function(){returnZ.front()},last_id:function(){vare=Z.length();if(e){returne-1}},parse_arguments:function(n){returne.map(n.match(L)||[],function(n){vart=n.match($);if(t){returnnewRegExp(t[1],t[2])}elseif(n[0]==="'"&&n[n.length-1]==="'"&&n.length>1){returnn.replace(/^'|'$/g,"")}elseif(n[0]==='"'&&n[n.length-1]==='"'&&n.length>1){returne.parseJSON(n)}elseif(n.match(/^-?[0-9]+$/)){returnparseInt(n,10)}elseif(n.match(N)){returnparseFloat(n)}elseif(n.match(/^['"]$/)){return""}else{returnn.replace(/\\(['"() ])/g,"$1")}})},split_arguments:function(n){returne.map(n.match(L)||[],function(e){if(e[0]==="'"&&e[e.length-1]==="'"){returne.replace(/^'|'$/g,"")}elseif(e[0]==='"'&&e[e.length-1]==='"'){returne.replace(/^"|"$/g,"").replace(/\\([" ])/g,"$1")}elseif(e.match(/\/.*\/[gimy]*$/)){returne}else{returne.replace(/\\ /g," ")}})},parse_command:function(n){returnb(n,e.terminal.parse_arguments)},split_command:function(n){returnb(n,e.terminal.split_arguments)},extended_command:function(e,n){try{te=false;e.exec(n,true).then(function(){te=true})}catch(t){}}};e.fn.visible=function(){returnthis.css("visibility","visible")};e.fn.hidden=function(){returnthis.css("visibility","hidden")};e.fn.scroll_element=function(){varn=e.fn.scroll_element.defaults;returnthis.map(function(){vart=e(this);if(t.is("body")){varr=e("html");vari=e("body");varo=i.scrollTop()||r.scrollTop();vara=e("<pre/>").css(n.pre).appendTo("body");a.html(newArray(n.lines).join("\n"));e("body,html").scrollTop(10);vars;if(i.scrollTop()===10){i.scrollTop(o);s=i[0]}elseif(r.scrollTop()===10){r.scrollTop(o);s=r[0]}a.remove();returns}else{returnthis}})};e.fn.scroll_element.defaults={lines:2e3,pre:{"font-size":"14px","white-space":"pre"}};functionz(){if(!("KeyboardEvent"inwindow&&"key"inwindow.KeyboardEvent.prototype)){returnfalse}vare=window.KeyboardEvent.prototype;varn=Object.getOwnPropertyDescriptor(e,"key").get;returnn.toString().match(/\[native code\]/)}functionH(e){if(console&&console.warn){console.warn(e)}else{thrownewError("WARN: "+e)}}varD={};e.jrpc=function(n,t,r,i,o){