diff --git a/master.js b/master.js index 9030c38..b9eb849 100644 --- a/master.js +++ b/master.js @@ -6162,95 +6162,125 @@ bot.addCommand({ }()); ; -(function () { -var parse; - -function learn ( args ) { - bot.log( args, '/learn input' ); - - var commandParts = args.parse(); - var command = { - name : commandParts[ 0 ], - output : commandParts[ 1 ], - input : commandParts[ 2 ] || '.*' - }; - - //a truthy value, unintuitively, means it isn't valid, because it returns - // an error message - var errorMessage = checkCommand( command ); - if ( errorMessage ) { - return errorMessage; - } - command.name = command.name.toLowerCase(); - command.input = new RegExp( command.input ); - - parse = bot.getCommand( 'parse' ); - if ( parse.error ) { - console.error( '/parse not loaded, cannot /learn' ); - return 'Failed; /parse not loaded'; - } - console.log( parse ); - - bot.log( command, '/learn parsed' ); - - addCustomCommand( command ); - return 'Command ' + command.name + ' learned'; -}; - -function addCustomCommand ( command ) { - bot.addCommand({ - name : command.name, - description : 'User-taught command: ' + command.output, - - fun : makeCustomCommand( command ), - permissions : { - use : 'ALL', - del : 'ALL' - } - }); -} -function makeCustomCommand ( command ) { - - return function ( args ) { - bot.log( args, command.name + ' input' ); - - var cmdArgs = bot.Message( command.output, args.get() ); - return parse.exec( cmdArgs, command.input.exec(args) ); - }; -} - -//return a truthy value (an error message) if it's invalid, falsy if it's -// valid -function checkCommand ( cmd ) { - var somethingUndefined = Object.keys( cmd ).some(function ( key ) { - return !cmd[ key ]; - }), - error; - - if ( somethingUndefined ) { - error = 'Illegal /learn object'; - } - - if ( !/^[\w\-]+$/.test(cmd.name) ) { - error = 'Invalid command name'; - } - - if ( bot.commandExists(cmd.name.toLowerCase()) ) { - error = 'Command ' + cmd.name + ' already exists'; - } - - return error; -} - - -bot.addCommand({ - name : 'learn', - fun : learn, - privileges : { - del : 'NONE', - }, - - description : 'Teaches the bot a command. ' + - '`/learn cmdName cmdOutputMacro [cmdInputRegex]`' -}); -}()); +(function () { +"use strict"; +var parse = bot.getCommand( 'parse' ); +var storage = JSON.parse( localStorage.bot_learn || '{}' ); +loadCommands(); + +function learn ( args ) { + bot.log( args, '/learn input' ); + + var commandParts = args.parse(); + var command = { + name : commandParts[ 0 ], + output : commandParts[ 1 ], + input : commandParts[ 2 ] || '.*' + }; + + //a truthy value, unintuitively, means it isn't valid, because it returns + // an error message + var errorMessage = checkCommand( command ); + if ( errorMessage ) { + return errorMessage; + } + command.name = command.name.toLowerCase(); + command.input = new RegExp( command.input ); + + bot.log( command, '/learn parsed' ); + + addCustomCommand( command ); + saveCommand( command ); + return 'Command ' + command.name + ' learned'; +} + +function addCustomCommand ( command ) { + var cmd = bot.Command({ + name : command.name, + description : 'User-taught command: ' + command.output, + + fun : makeCustomCommand( command ), + permissions : { + use : 'ALL', + del : 'ALL' + } + }); + + cmd.del = (function ( old ) { + return function () { + deleteCommand( command.name ); + old(); + }; + }( cmd.del )); + + bot.log( cmd, '/learn addCustomCommand' ); + bot.addCommand( cmd ); +} +function makeCustomCommand ( command ) { + bot.log( command, '/learn makeCustomCommand' ); + return function ( args ) { + bot.log( args, command.name + ' input' ); + + var cmdArgs = bot.Message( command.output, args.get() ); + return parse.exec( cmdArgs, command.input.exec(args) ); + }; +} + +//return a truthy value (an error message) if it's invalid, falsy if it's +// valid +function checkCommand ( cmd ) { + var somethingUndefined = Object.keys( cmd ).some(function ( key ) { + return !cmd[ key ]; + }), + error; + + if ( somethingUndefined ) { + error = 'Illegal /learn object'; + } + + else if ( !/^[\w\-]+$/.test(cmd.name) ) { + error = 'Invalid command name'; + } + + else if ( bot.commandExists(cmd.name.toLowerCase()) ) { + error = 'Command ' + cmd.name + ' already exists'; + } + + return error; +} + +function loadCommands () { + Object.keys( storage ).forEach( teach ); + + function teach ( key ) { + var cmd = JSON.parse( storage[key] ); + cmd.input = new RegExp( cmd.input ); + + bot.log( cmd, '/learn loadCommands' ); + addCustomCommand( cmd ); + } +} +function saveCommand ( command ) { + storage[ command.name ] = JSON.stringify({ + name : command.name, + input : command.input.source, + output : command.output + }); + localStorage.bot_learn = JSON.stringify( storage ); +} +function deleteCommand ( name ) { + delete storage[ name ]; + localStorage.bot_learn = JSON.stringify( storage ); +} + +bot.addCommand({ + name : 'learn', + fun : learn, + privileges : { + del : 'NONE' + }, + + description : 'Teaches the bot a command. ' + + '`/learn cmdName cmdOutputMacro [cmdInputRegex]`' +}); +}()); diff --git a/master.min.js b/master.min.js index ad66f2b..39d5fad 100644 --- a/master.min.js +++ b/master.min.js @@ -1,3 +1,3 @@ -function js_beautify(e,t){function n(e){for(e=e===void 0?!1:e;_.length&&(" "===_[_.length-1]||_[_.length-1]===w||_[_.length-1]===G||e&&("\n"===_[_.length-1]||"\r"===_[_.length-1]));)_.pop()}function o(e){return e.replace(/^\s\s*|\s\s*$/,"")}function i(e){e=e.replace(/\x0d/g,"");for(var t=[],n=e.indexOf("\n");-1!==n;)t.push(e.substring(0,n)),e=e.substring(n+1),n=e.indexOf("\n");return e.length&&t.push(e),t}function r(){var e=H;H=!1,a(),H=e}function a(e){if(C.eat_next_space=!1,(!H||!p(C.mode))&&(e=e===void 0?!0:e,C.if_line=!1,n(),_.length)){"\n"===_[_.length-1]&&e||(U=!0,_.push("\n")),G&&_.push(G);for(var t=0;C.indentation_level>t;t+=1)_.push(w);C.var_line&&C.var_line_reindented&&_.push(w),C.case_body&&_.push(w)}}function s(){if("TK_COMMENT"===T)return a();if(C.eat_next_space)return C.eat_next_space=!1,void 0;var e=" ";_.length&&(e=_[_.length-1])," "!==e&&"\n"!==e&&e!==w&&_.push(" ")}function c(){U=!1,C.eat_next_space=!1,_.push(O)}function u(){C.indentation_level+=1}function m(){_.length&&_[_.length-1]===w&&_.pop()}function l(e){C&&A.push(C),C={previous_mode:C?C.mode:"BLOCK",mode:e,var_line:!1,var_line_tainted:!1,var_line_reindented:!1,in_html_comment:!1,if_line:!1,in_case_statement:!1,in_case:!1,case_body:!1,eat_next_space:!1,indentation_baseline:-1,indentation_level:C?C.indentation_level+(C.case_body?1:0)+(C.var_line&&C.var_line_reindented?1:0):0,ternary_depth:0}}function p(e){return"[EXPRESSION]"===e||"[INDENTED-EXPRESSION]"===e}function h(e){return x(e,["[EXPRESSION]","(EXPRESSION)","(FOR-EXPRESSION)","(COND-EXPRESSION)"])}function d(){if(L="DO_BLOCK"===C.mode,A.length>0){var e=C.mode;C=A.pop(),C.previous_mode=e}}function f(e,t){for(var n=0;e.length>n;n++){var i=o(e[n]);if(i.charAt(0)!==t)return!1}return!0}function g(e){return x(e,["case","return","do","if","throw","else"])}function x(e,t){for(var n=0;t.length>n;n+=1)if(t[n]===e)return!0;return!1}function y(e){for(var t=R,n=b.charAt(t);x(n,I)&&n!==e;){if(t++,t>=Z)return 0;n=b.charAt(t)}return n}function v(){var e,t;if(F=0,R>=Z)return["","TK_EOF"];B=!1;var i=b.charAt(R);R+=1;var r=H&&p(C.mode);if(r){for(var s=0;x(i,I);){if("\n"===i?(n(),_.push("\n"),U=!0,s=0):" "===i?s+=4:"\r"===i||(s+=1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(-1===C.indentation_baseline&&(C.indentation_baseline=s),U){for(e=0;C.indentation_level+1>e;e+=1)_.push(w);if(-1!==C.indentation_baseline)for(e=0;s-C.indentation_baseline>e;e++)_.push(" ")}}else{for(;x(i,I);){if("\n"===i&&(F+=V?V>=F?1:0:1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(Y&&F>1)for(e=0;F>e;e+=1)a(0===e),U=!0;B=F>0}if(x(i,k)){if(Z>R)for(;x(b.charAt(R),k)&&(i+=b.charAt(R),R+=1,R!==Z););if(R!==Z&&i.match(/^[0-9]+[Ee]$/)&&("-"===b.charAt(R)||"+"===b.charAt(R))){var c=b.charAt(R);R+=1;var u=v();return i+=c+u[0],[i,"TK_WORD"]}return"in"===i?[i,"TK_OPERATOR"]:(!B||"TK_OPERATOR"===T||"TK_EQUALS"===T||C.if_line||!Y&&"var"===E||a(),[i,"TK_WORD"])}if("("===i||"["===i)return[i,"TK_START_EXPR"];if(")"===i||"]"===i)return[i,"TK_END_EXPR"];if("{"===i)return[i,"TK_START_BLOCK"];if("}"===i)return[i,"TK_END_BLOCK"];if(";"===i)return[i,"TK_SEMICOLON"];if("/"===i){var m="",l=!0;if("*"===b.charAt(R)){if(R+=1,Z>R)for(;Z>R&&("*"!==b.charAt(R)||!b.charAt(R+1)||"/"!==b.charAt(R+1))&&(i=b.charAt(R),m+=i,("\n"===i||"\r"===i)&&(l=!1),R+=1,!(R>=Z)););return R+=2,l&&0===F?["/*"+m+"*/","TK_INLINE_COMMENT"]:["/*"+m+"*/","TK_BLOCK_COMMENT"]}if("/"===b.charAt(R)){for(m=i;"\r"!==b.charAt(R)&&"\n"!==b.charAt(R)&&(m+=b.charAt(R),R+=1,!(R>=Z)););return B&&a(),[m,"TK_COMMENT"]}}if("'"===i||'"'===i||"/"===i&&("TK_WORD"===T&&g(E)||")"===E&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])||"TK_COMMA"===T||"TK_COMMENT"===T||"TK_START_EXPR"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_OPERATOR"===T||"TK_EQUALS"===T||"TK_EOF"===T||"TK_SEMICOLON"===T)){var h=i,d=!1,f=0,y=0;if(t=i,Z>R)if("/"===h){for(var O=!1;d||O||b.charAt(R)!==h;)if(t+=b.charAt(R),d?d=!1:(d="\\"===b.charAt(R),"["===b.charAt(R)?O=!0:"]"===b.charAt(R)&&(O=!1)),R+=1,R>=Z)return[t,"TK_STRING"]}else for(;d||b.charAt(R)!==h;)if(t+=b.charAt(R),f&&f>=y&&(f=parseInt(t.substr(-y),16),f&&f>=32&&126>=f&&(f=String.fromCharCode(f),t=t.substr(0,t.length-y-2)+(f===h||"\\"===f?"\\":"")+f),f=0),f?f++:d?(d=!1,Q&&("x"===b.charAt(R)?(f++,y=2):"u"===b.charAt(R)&&(f++,y=4))):d="\\"===b.charAt(R),R+=1,R>=Z)return[t,"TK_STRING"];if(R+=1,t+=h,"/"===h)for(;Z>R&&x(b.charAt(R),k);)t+=b.charAt(R),R+=1;return[t,"TK_STRING"]}if("#"===i){if(0===_.length&&"!"===b.charAt(R)){for(t=i;Z>R&&"\n"!==i;)i=b.charAt(R),t+=i,R+=1;return _.push(o(t)+"\n"),a(),v()}var N="#";if(Z>R&&x(b.charAt(R),P)){do i=b.charAt(R),N+=i,R+=1;while(Z>R&&"#"!==i&&"="!==i);return"#"===i||("["===b.charAt(R)&&"]"===b.charAt(R+1)?(N+="[]",R+=2):"{"===b.charAt(R)&&"}"===b.charAt(R+1)&&(N+="{}",R+=2)),[N,"TK_WORD"]}}if("<"===i&&""===b.substring(R-1,R+2))return C.in_html_comment=!1,R+=2,B&&a(),["-->","TK_COMMENT"];if(x(i,j)){for(;Z>R&&x(i+b.charAt(R),j)&&(i+=b.charAt(R),R+=1,!(R>=Z)););return","===i?[i,"TK_COMMA"]:"="===i?[i,"TK_EQUALS"]:[i,"TK_OPERATOR"]}return[i,"TK_UNKNOWN"]}var b,_,O,T,E,N,S,C,A,w,I,k,j,R,D,P,M,K,L,B,U,F,G="";t=t?t:{};var X;void 0!==t.space_after_anon_function&&void 0===t.jslint_happy&&(t.jslint_happy=t.space_after_anon_function),void 0!==t.braces_on_own_line&&(X=t.braces_on_own_line?"expand":"collapse"),X=t.brace_style?t.brace_style:X?X:"collapse";var q=t.indent_size?t.indent_size:4,W=t.indent_char?t.indent_char:" ",Y=t.preserve_newlines===void 0?!0:t.preserve_newlines,V=t.max_preserve_newlines===void 0?!1:t.max_preserve_newlines,z="undefined"===t.jslint_happy?!1:t.jslint_happy,H=t.keep_array_indentation===void 0?!1:t.keep_array_indentation,$=t.space_before_conditional===void 0?!0:t.space_before_conditional,J=t.indent_case===void 0?!1:t.indent_case,Q=t.unescape_strings===void 0?!1:t.unescape_strings;U=!1;var Z=e.length;for(w="";q>0;)w+=W,q-=1;for(;e&&(" "===e.charAt(0)||" "===e.charAt(0));)G+=e.charAt(0),e=e.substring(1);for(b=e,S="",T="TK_START_EXPR",E="",N="",_=[],L=!1,I="\n\r ".split(""),k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$".split(""),P="0123456789".split(""),j="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::",j+=" <%= <% %> = ?>",j=j.split(" "),D="continue,try,throw,return,var,if,switch,case,default,for,while,break,function".split(","),A=[],l("BLOCK"),R=0;;){var et=v();if(O=et[0],K=et[1],"TK_EOF"===K)break;switch(K){case"TK_START_EXPR":if("["===O){if("TK_WORD"===T||")"===E){x(E,D)&&s(),l("(EXPRESSION)"),c();break}"[EXPRESSION]"===C.mode||"[INDENTED-EXPRESSION]"===C.mode?"]"===N&&","===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):"["===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):l("[EXPRESSION]"):l("[EXPRESSION]")}else"for"===S?l("(FOR-EXPRESSION)"):x(S,["if","while"])?l("(COND-EXPRESSION)"):l("(EXPRESSION)");";"===E||"TK_START_BLOCK"===T?a():"TK_END_EXPR"===T||"TK_START_EXPR"===T||"TK_END_BLOCK"===T||"."===E?B&&a():"TK_WORD"!==T&&"TK_OPERATOR"!==T?s():"function"===S||"typeof"===S?z&&s():(x(E,D)||"catch"===E)&&$&&s(),c();break;case"TK_END_EXPR":if("]"===O)if(H){if("}"===E){m(),c(),d();break}}else if("[INDENTED-EXPRESSION]"===C.mode&&"]"===E){d(),a(),c();break}d(),c();break;case"TK_START_BLOCK":if("do"===S?l("DO_BLOCK"):l("BLOCK"),"expand"===X||"expand-strict"===X){var tt=!1;"expand-strict"===X?(tt="}"===y(),tt||a(!0)):"TK_OPERATOR"!==T&&("="===E||g(E)&&"else"!==E?s():a(!0)),c(),tt||u()}else"TK_OPERATOR"!==T&&"TK_START_EXPR"!==T?"TK_START_BLOCK"===T?a():s():p(C.previous_mode)&&","===E&&("}"===N?s():a()),u(),c();break;case"TK_END_BLOCK":d(),"expand"===X||"expand-strict"===X?("{"!==E&&a(),c()):("TK_START_BLOCK"===T?U?m():n():p(C.mode)&&H?(H=!1,a(),H=!0):a(),c());break;case"TK_WORD":if(L){s(),c(),s(),L=!1;break}if(M="NONE","function"===O){if(C.var_line&&"TK_EQUALS"!==T&&(C.var_line_reindented=!0),(U||";"===E)&&"{"!==E&&"TK_BLOCK_COMMENT"!==T&&"TK_COMMENT"!==T){F=U?F:0,Y||(F=1);for(var nt=0;2-F>nt;nt++)a(!1)}"TK_WORD"===T?"get"===E||"set"===E||"new"===E||"return"===E?s():a():"TK_OPERATOR"===T||"="===E?s():h(C.mode)||a(),c(),S=O;break}if("case"===O||"default"===O&&C.in_case_statement){":"===E||C.case_body?m():(J||C.indentation_level--,a(),J||C.indentation_level++),c(),C.in_case=!0,C.in_case_statement=!0,C.case_body=!1;break}"TK_END_BLOCK"===T?x(O.toLowerCase(),["else","catch","finally"])?"expand"===X||"end-expand"===X||"expand-strict"===X?M="NEWLINE":(M="SPACE",s()):M="NEWLINE":"TK_SEMICOLON"!==T||"BLOCK"!==C.mode&&"DO_BLOCK"!==C.mode?"TK_SEMICOLON"===T&&h(C.mode)?M="SPACE":"TK_STRING"===T?M="NEWLINE":"TK_WORD"===T?("else"===E&&n(!0),M="SPACE"):"TK_START_BLOCK"===T?M="NEWLINE":"TK_END_EXPR"===T&&(s(),M="NEWLINE"):M="NEWLINE",x(O,D)&&")"!==E&&(M="else"===E?"SPACE":"NEWLINE"),C.if_line&&"TK_END_EXPR"===T&&(C.if_line=!1),x(O.toLowerCase(),["else","catch","finally"])?"TK_END_BLOCK"!==T||"expand"===X||"end-expand"===X||"expand-strict"===X?a():(n(!0),s()):"NEWLINE"===M?g(E)?s():"TK_END_EXPR"!==T?"TK_START_EXPR"===T&&"var"===O||":"===E||("if"===O&&"else"===S&&"{"!==E?s():(C.var_line=!1,C.var_line_reindented=!1,a())):x(O,D)&&")"!==E&&(C.var_line=!1,C.var_line_reindented=!1,a()):p(C.mode)&&","===E&&"}"===N?a():"SPACE"===M&&s(),c(),S=O,"var"===O&&(C.var_line=!0,C.var_line_reindented=!1,C.var_line_tainted=!1),"if"===O&&(C.if_line=!0),"else"===O&&(C.if_line=!1);break;case"TK_SEMICOLON":c(),C.var_line=!1,C.var_line_reindented=!1,"OBJECT"===C.mode&&(C.mode="BLOCK");break;case"TK_STRING":"TK_END_EXPR"===T&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])?s():"TK_COMMENT"===T||"TK_STRING"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_SEMICOLON"===T?a():"TK_WORD"===T&&s(),c();break;case"TK_EQUALS":C.var_line&&(C.var_line_tainted=!0),s(),c(),s();break;case"TK_COMMA":if(C.var_line){if((h(C.mode)||"TK_END_BLOCK"===T)&&(C.var_line_tainted=!1),C.var_line_tainted){c(),C.var_line_reindented=!0,C.var_line_tainted=!1,a();break}C.var_line_tainted=!1,c(),s();break}"TK_COMMENT"===T&&a(),"TK_END_BLOCK"===T&&"(EXPRESSION)"!==C.mode?(c(),"OBJECT"===C.mode&&"}"===E?a():s()):"OBJECT"===C.mode?(c(),a()):(c(),s());break;case"TK_OPERATOR":var ot=!0,it=!0;if(g(E)){s(),c();break}if("*"===O&&"TK_UNKNOWN"===T&&!N.match(/^\d+$/)){c();break}if(":"===O&&C.in_case){J&&(C.case_body=!0),c(),a(),C.in_case=!1;break}if("::"===O){c();break}x(O,["--","++","!"])||x(O,["-","+"])&&(x(T,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||x(E,D))?(ot=!1,it=!1,";"===E&&h(C.mode)&&(ot=!0),"TK_WORD"===T&&x(E,D)&&(ot=!0),"BLOCK"!==C.mode||"{"!==E&&";"!==E||a()):"."===O?ot=!1:":"===O?0===C.ternary_depth?("BLOCK"===C.mode&&(C.mode="OBJECT"),ot=!1):C.ternary_depth-=1:"?"===O&&(C.ternary_depth+=1),ot&&s(),c(),it&&s();break;case"TK_BLOCK_COMMENT":var rt,at=i(O);if(f(at.slice(1),"*"))for(a(),_.push(at[0]),rt=1;at.length>rt;rt++)a(),_.push(" "),_.push(o(at[rt]));else for(at.length>1?a():"TK_END_BLOCK"===T?a():s(),rt=0;at.length>rt;rt++)_.push(at[rt]),_.push("\n");"\n"!==y("\n")&&a();break;case"TK_INLINE_COMMENT":s(),c(),h(C.mode)?s():r();break;case"TK_COMMENT":","!==E||B||n(!0),"TK_COMMENT"!==T&&(B?a():s()),c(),a();break;case"TK_UNKNOWN":g(E)&&s(),c()}N=E,T=K,E=O}var st=G+_.join("").replace(/[\r\n ]+$/,"");return st}function style_html(e,t){function n(){return this.pos=0,this.token="",this.current_mode="CONTENT",this.tags={parent:"parent1",parentcount:1,parent1:""},this.tag_type="",this.token_text=this.last_token=this.last_text=this.token_type="",this.Utils={whitespace:"\n\r ".split(""),single_token:"br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed".split(","),extra_liners:"head,body,/html".split(","),in_array:function(e,t){for(var n=0;t.length>n;n++)if(e===t[n])return!0;return!1}},this.get_content=function(){for(var e="",t=[],n=!1;"<"!==this.input.charAt(this.pos);){if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];if(e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace))t.length&&(n=!0),this.line_char_count--;else{if(n){if(this.line_char_count>=this.max_char){t.push("\n");for(var o=0;this.indent_level>o;o++)t.push(this.indent_string);this.line_char_count=0}else t.push(" "),this.line_char_count++;n=!1}t.push(e)}}return t.length?t.join(""):""},this.get_contents_to=function(e){if(this.pos==this.input.length)return["","TK_EOF"];var t="",n=RegExp(""+e+"\\s*>","igm");n.lastIndex=this.pos;var o=n.exec(this.input),i=o?o.index:this.input.length;return i>this.pos&&(t=this.input.substring(this.pos,i),this.pos=i),t},this.record_tag=function(e){this.tags[e+"count"]?(this.tags[e+"count"]++,this.tags[e+this.tags[e+"count"]]=this.indent_level):(this.tags[e+"count"]=1,this.tags[e+this.tags[e+"count"]]=this.indent_level),this.tags[e+this.tags[e+"count"]+"parent"]=this.tags.parent,this.tags.parent=e+this.tags[e+"count"]},this.retrieve_tag=function(e){if(this.tags[e+"count"]){for(var t=this.tags.parent;t&&e+this.tags[e+"count"]!==t;)t=this.tags[t+"parent"];t&&(this.indent_level=this.tags[e+this.tags[e+"count"]],this.tags.parent=this.tags[t+"parent"]),delete this.tags[e+this.tags[e+"count"]+"parent"],delete this.tags[e+this.tags[e+"count"]],1==this.tags[e+"count"]?delete this.tags[e+"count"]:this.tags[e+"count"]--}},this.get_tag=function(){var e="",t=[],n=!1;do{if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace)?(n=!0,this.line_char_count--):(("'"===e||'"'===e)&&(t[1]&&"!"===t[1]||(e+=this.get_unformatted(e),n=!0)),"="===e&&(n=!1),t.length&&"="!==t[t.length-1]&&">"!==e&&n&&(this.line_char_count>=this.max_char?(this.print_newline(!1,t),this.line_char_count=0):(t.push(" "),this.line_char_count++),n=!1),t.push(e))}while(">"!==e);var o,i=t.join("");o=-1!=i.indexOf(" ")?i.indexOf(" "):i.indexOf(">");var r=i.substring(1,o).toLowerCase();if("/"===i.charAt(i.length-2)||this.Utils.in_array(r,this.Utils.single_token))this.tag_type="SINGLE";else if("script"===r)this.record_tag(r),this.tag_type="SCRIPT";else if("style"===r)this.record_tag(r),this.tag_type="STYLE";else if(this.Utils.in_array(r,unformatted)){var a=this.get_unformatted(""+r+">",i);t.push(a),this.tag_type="SINGLE"}else if("!"===r.charAt(0))if(-1!=r.indexOf("[if")){if(-1!=i.indexOf("!IE")){var a=this.get_unformatted("-->",i);t.push(a)}this.tag_type="START"}else if(-1!=r.indexOf("[endif"))this.tag_type="END",this.unindent();else if(-1!=r.indexOf("[cdata[")){var a=this.get_unformatted("]]>",i);t.push(a),this.tag_type="SINGLE"}else{var a=this.get_unformatted("-->",i);t.push(a),this.tag_type="SINGLE"}else"/"===r.charAt(0)?(this.retrieve_tag(r.substring(1)),this.tag_type="END"):(this.record_tag(r),this.tag_type="START"),this.Utils.in_array(r,this.Utils.extra_liners)&&this.print_newline(!0,this.output);return t.join("")},this.get_unformatted=function(e,t){if(t&&-1!=t.indexOf(e))return"";var n="",o="",i=!0;do{if(this.pos>=this.input.length)return o;if(n=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(n,this.Utils.whitespace)){if(!i){this.line_char_count--;continue}if("\n"===n||"\r"===n){o+="\n",this.line_char_count=0;continue}}o+=n,this.line_char_count++,i=!0}while(-1==o.indexOf(e));return o},this.get_token=function(){var e;if("TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token){var t=this.last_token.substr(7);return e=this.get_contents_to(t),"string"!=typeof e?e:[e,"TK_"+t]}if("CONTENT"===this.current_mode)return e=this.get_content(),"string"!=typeof e?e:[e,"TK_CONTENT"];if("TAG"===this.current_mode){if(e=this.get_tag(),"string"!=typeof e)return e;var n="TK_TAG_"+this.tag_type;return[e,n]}},this.get_full_indent=function(e){return e=this.indent_level+e||0,1>e?"":Array(e+1).join(this.indent_string)},this.printer=function(e,t,n,o,i){this.input=e||"",this.output=[],this.indent_character=t,this.indent_string="",this.indent_size=n,this.brace_style=i,this.indent_level=0,this.max_char=o,this.line_char_count=0;for(var r=0;this.indent_size>r;r++)this.indent_string+=this.indent_character;this.print_newline=function(e,t){if(this.line_char_count=0,t&&t.length){if(!e)for(;this.Utils.in_array(t[t.length-1],this.Utils.whitespace);)t.pop();t.push("\n");for(var n=0;this.indent_level>n;n++)t.push(this.indent_string)}},this.print_token=function(e){this.output.push(e)},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var o,i,r,a,s;for(t=t||{},i=t.indent_size||4,r=t.indent_char||" ",s=t.brace_style||"collapse",a=0==t.max_char?1/0:t.max_char||70,unformatted=t.unformatted||["a"],o=new n,o.printer(e,r,i,a,s);;){var c=o.get_token();if(o.token_text=c[0],o.token_type=c[1],"TK_EOF"===o.token_type)break;switch(o.token_type){case"TK_TAG_START":o.print_newline(!1,o.output),o.print_token(o.token_text),o.indent(),o.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_END":if("TK_CONTENT"===o.last_token&&""===o.last_text){var u=o.token_text.match(/\w+/)[0],m=o.output[o.output.length-1].match(/<\s*(\w+)/);(null===m||m[1]!==u)&&o.print_newline(!0,o.output)}o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_SINGLE":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_CONTENT":""!==o.token_text&&o.print_token(o.token_text),o.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(""!==o.token_text){o.output.push("\n");var l=o.token_text;if("TK_SCRIPT"==o.token_type)var p="function"==typeof js_beautify&&js_beautify;else if("TK_STYLE"==o.token_type)var p="function"==typeof css_beautify&&css_beautify;if("keep"==t.indent_scripts)var h=0;else if("separate"==t.indent_scripts)var h=-o.indent_level;else var h=1;var d=o.get_full_indent(h);if(p)l=p(l.replace(/^\s*/,d),t);else{var f=l.match(/^\s*/)[0],g=f.match(/[^\n\r]*$/)[0].split(o.indent_string).length-1,x=o.get_full_indent(h-g);l=l.replace(/^\s*/,d).replace(/\r\n|\r|\n/g,"\n"+x).replace(/\s*$/,"")}l&&(o.print_token(l),o.print_newline(!0,o.output))}o.current_mode="TAG"}o.last_token=o.token_type,o.last_text=o.token_text}return o.output.join("")}function css_beautify(e,t){function n(){return h=e.charAt(++f)}function o(){return e.charAt(f+1)}function i(t){for(var o=f;n();)if("\\"==h)n(),n();else{if(h==t)break;if("\n"==h)break}return e.substring(o,f+1)}function r(){for(var e=f;d.test(o());)f++;return f!=e}function a(){var e=f;do;while(d.test(n()));return f!=e+1}function s(){var t=f;for(n();n();)if("*"==h&&"/"==o()){f++;break}return e.substring(t,f+1)}function c(e,t){return v.slice(-e.length+(t||0),t).join("").toLowerCase()==e}function u(){y++,g+=x}function m(){y--,g=g.slice(0,-l)}t=t||{};var l=t.indent_size||4,p=t.indent_char||" ";"string"==typeof l&&(l=parseInt(l));var h,d=/^\s+$/,f=-1,g=e.match(/^[\r\n]*[\t ]*/)[0],x=Array(l+1).join(p),y=0;print={},print["{"]=function(e){print.singleSpace(),v.push(e),print.newLine()},print["}"]=function(e){print.newLine(),v.push(e),print.newLine()},print.newLine=function(e){if(!e)for(;d.test(v[v.length-1]);)v.pop();v.length&&v.push("\n"),g&&v.push(g)},print.singleSpace=function(){v.length&&!d.test(v[v.length-1])&&v.push(" ")};var v=[];for(g&&v.push(g);;){var b=a();if(!h)break;"{"==h?(u(),print["{"](h)):"}"==h?(m(),print["}"](h)):'"'==h||"'"==h?v.push(i(h)):";"==h?v.push(h,"\n",g):"/"==h&&"*"==o()?(print.newLine(),v.push(s(),"\n",g)):"("==h?(v.push(h),r(),c("url",-1)&&n()&&(")"!=h&&'"'!=h&&"'"!=h?v.push(i(")")):f--)):")"==h?v.push(h):","==h?(r(),v.push(h),print.singleSpace()):"]"==h?v.push(h):"["==h||"="==h?(r(),v.push(h)):(b&&print.singleSpace(),v.push(h))}var _=v.join("").replace(/[\n ]+$/,"");return _}var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(""+t):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var i=e[t];return Array.isArray(i)?n(t,i):o(t,i)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return"#"===t[0]?i(t):e[t]||t},i=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),t.addEventListener("readystatechange",function(){4===t.readyState&&e.complete.call(e.thisArg,t.responseText,t)}),Object.keys(e.headers).forEach(function(n){t.setRequestHeader(n,e.headers[n])}),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO_"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+=this.urlstringify(e.data),n.src=e.url,document.head.appendChild(n)},IO.jsonp.define=function(e,t){IO.jsonp({url:"http://api.duckduckgo.com/",jsonpName:"callback",data:{format:"json",q:"define "+e},fun:t})},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},function(){"use strict";var e=window.bot={invocationPattern:"!!",commandRegex:/^\/\s?([\w\-]+)(?:\s(.+))?$/,commands:{},commandDictionary:null,listeners:[],parseMessage:function(t){if(!this.validateMessage(t))return e.log(t,"parseMessage invalid"),void 0;var n=this.prepareMessage(t);if(e.log(n,"parseMessage valid"),this.banlist.contains(n.get("user_id")))return e.log(t,"parseMessage banned"),n.reply("You iz in mindjail"),void 0;try{n.startsWith("/")?this.parseCommand(n):n.startsWith(">")?this.eval(n):this.callListeners(n)}catch(o){var i="Could not process input. Error: "+o.message;o.lineNumber&&(i+=" on line "+o.lineNumber),o.column&&(i+=" on column "+o.column),n.directreply(i),console.error(o,i)}},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.decodehtmlEntities(e.content);return this.Message(t.slice(this.invocationPattern.length).trim(),e)},parseCommand:function(t){e.log(t,"parseCommand input");var n=this.commandRegex.exec(t);if(!n)return t.reply("Invalid command "+t),void 0;var o=n[1].toLowerCase();e.log(n,"parseCommand matched");var i=this.getCommand(o);if(i.error)return t.reply(i.error),void 0;if(!i.canUse(t.get("user_id")))return t.reply("You do not have permission to use the command "+o),void 0;e.log(i,"parseCommand calling");var r=this.Message(t.slice(o.length+1).trim(),t.get()),a=i.exec(r);a&&t.reply(a)},validateMessage:function(e){var t=e.content.trim();return t.startsWith(this.invocationPattern)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){if(this.commandExists(e))return this.commands[e];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var t="Command "+e+" does not exist.",n=this.commandDictionary.search(e);return n.length&&(t+=" Did you mean: "+n.join(", ")),{error:t}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(t){var n=!1;this.listeners.forEach(function(o){var i,r=t.exec(o.pattern);r&&(i=o.fun.call(o.thisArg,t),e.log(r,i),i&&t.reply(i),i!==!1&&(n=!0))}),n||t.reply("Y U NO MAEK SENSE!? Could not understand `"+t+"`")},reply:function(e,t){var n=this.adapter.reply(e,t);this.adapter.out.add(n,t.room_id)},directreply:function(e,t){var n=this.adapter.directreply(e,t);this.adapter.out.add(n,t.room_id)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1}};e.banlist=[],e.banlist.contains=function(e){return this.indexOf(e)>=0},e.banlist.add=function(e){return this.push(e)},e.banlist.remove=function(e){var t=this.indexOf(e);return t>=0?this.splice(t,1):null},e.eval=function(e){function t(t){r.terminate(),e.directreply(t)}function n(e){var t,n=e.answer,i=e.log;return t=o(n),i&&i.length&&(t+=" Logged: "+o(i)+""),t}function o(e){var t;return t=e.length>400?"(snip) `"+e.slice(0,400)+"`":"`"+e+"`"}var i,r=new Worker("codeWorker.js");r.onmessage=function(e){clearTimeout(i),t(n(e.data))},r.onerror=function(e){clearTimeout(i),t(""+e)},r.postMessage({code:e.content.substr(1)}),i=window.setTimeout(function(){t("Maximum execution time exceeded")},50)},e.Command=function(t){return t.name=t.name.toLowerCase(),t.permissions=t.permissions||{},t.permissions.use=t.permissions.use||"ALL",t.permissions.del=t.permissions.del||"NONE",t.description=t.description||"",["Use","Del"].forEach(function(e){var n=e.toLowerCase();t["can"+e]=function(e){var t=this.permissions[n];return"ALL"===t||"NONE"!==t&&t.indexOf(e)>-1}}),t.exec=function(){return this.fun.apply(this.thisArg,arguments)},t.del=function(){delete e.commands[t.name]},t},e.Message=function(t,n){var o=Object(t);o.content=t;var i={respond:function(t){e.adapter.out.add(t,n.room_id)},reply:function(t,o){o=o||n.user_name,e.reply(t,Object.merge(n,{user_name:o}))},directreply:function(t,o){o=o||n.message_id,e.directreply(t,Object.merge(n,{message_id:o}))},parse:function(o,i){!!o===o&&(i=o,o=t);var r=e.parseCommandArgs(o||t);return i?r.map(function(t){return e.Message(t,n)}):r},exec:function(e){var n=e.exec(t);return this.matches=n?n:[],n},findUserid:function(e){var t=[].slice.call(document.getElementById("sidebar").getElementsByClassName("user-container")),n=t.map(function(e){return e.id.match(/\d+/)[0]}),o=t.map(function(e){return e.getElementsByTagName("img")[0].title.toLowerCase()}),i=o.indexOf((""+e).toLowerCase());return 0>i?void 0:Number(n[i])}.memoize(),codify:e.adapter.codify.bind(e.adapter),escape:e.adapter.escape.bind(e.adapter),link:e.adapter.link.bind(e.adapter),get:function(e){return e?n[e]:n},set:function(e,t){return n[e]=t}};return Object.keys(i).forEach(function(e){o[e]=i[e]}),o},e.owners=[419970,342129,170224,94197,617762],e.isOwner=function(e){return this.owners.indexOf(e)>-1},IO.register("input",e.parseMessage,e),Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){var t=[].slice.call(arguments,1);return this.map(function(n){var o=n;return n[e]&&n[e].apply&&(o=n[e].apply(n,t)),o})},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this,e=e||function(e){return e};return function(){function o(){t[a]=arguments,r.apply(null,arguments)}var i=[].slice.call(arguments),r=i.pop(),a=e.apply(null,arguments);return a in t?(r.apply(null,t[a]),void 0):(i.push(o),n.apply(this,i),void 0)}},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},String.prototype.supplant=function(e){function t(t,n){return e.hasOwnProperty(n)?e[n]:t}return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.add=function(e,t){return this+e+(t?"":"\n")},function(){var t;t=e!==void 0?e:"undefined"!=typeof exports?exports:window,t.parseCommandArgs=function(){var e=0,t=1,n=2,o=3,i="'",r='"',a={parse:function(t,n,o){this.source=t,this.pos=0,this.length=t.length,this.state=e,this.lookahead="",this.escaper=o||"~",this.separator=n||" "; +function js_beautify(e,t){function n(e){for(e=e===void 0?!1:e;_.length&&(" "===_[_.length-1]||_[_.length-1]===w||_[_.length-1]===G||e&&("\n"===_[_.length-1]||"\r"===_[_.length-1]));)_.pop()}function o(e){return e.replace(/^\s\s*|\s\s*$/,"")}function i(e){e=e.replace(/\x0d/g,"");for(var t=[],n=e.indexOf("\n");-1!==n;)t.push(e.substring(0,n)),e=e.substring(n+1),n=e.indexOf("\n");return e.length&&t.push(e),t}function r(){var e=H;H=!1,a(),H=e}function a(e){if(C.eat_next_space=!1,(!H||!p(C.mode))&&(e=e===void 0?!0:e,C.if_line=!1,n(),_.length)){"\n"===_[_.length-1]&&e||(U=!0,_.push("\n")),G&&_.push(G);for(var t=0;C.indentation_level>t;t+=1)_.push(w);C.var_line&&C.var_line_reindented&&_.push(w),C.case_body&&_.push(w)}}function s(){if("TK_COMMENT"===T)return a();if(C.eat_next_space)return C.eat_next_space=!1,void 0;var e=" ";_.length&&(e=_[_.length-1])," "!==e&&"\n"!==e&&e!==w&&_.push(" ")}function c(){U=!1,C.eat_next_space=!1,_.push(O)}function u(){C.indentation_level+=1}function m(){_.length&&_[_.length-1]===w&&_.pop()}function l(e){C&&A.push(C),C={previous_mode:C?C.mode:"BLOCK",mode:e,var_line:!1,var_line_tainted:!1,var_line_reindented:!1,in_html_comment:!1,if_line:!1,in_case_statement:!1,in_case:!1,case_body:!1,eat_next_space:!1,indentation_baseline:-1,indentation_level:C?C.indentation_level+(C.case_body?1:0)+(C.var_line&&C.var_line_reindented?1:0):0,ternary_depth:0}}function p(e){return"[EXPRESSION]"===e||"[INDENTED-EXPRESSION]"===e}function h(e){return x(e,["[EXPRESSION]","(EXPRESSION)","(FOR-EXPRESSION)","(COND-EXPRESSION)"])}function d(){if(L="DO_BLOCK"===C.mode,A.length>0){var e=C.mode;C=A.pop(),C.previous_mode=e}}function f(e,t){for(var n=0;e.length>n;n++){var i=o(e[n]);if(i.charAt(0)!==t)return!1}return!0}function g(e){return x(e,["case","return","do","if","throw","else"])}function x(e,t){for(var n=0;t.length>n;n+=1)if(t[n]===e)return!0;return!1}function y(e){for(var t=R,n=b.charAt(t);x(n,I)&&n!==e;){if(t++,t>=Z)return 0;n=b.charAt(t)}return n}function v(){var e,t;if(F=0,R>=Z)return["","TK_EOF"];B=!1;var i=b.charAt(R);R+=1;var r=H&&p(C.mode);if(r){for(var s=0;x(i,I);){if("\n"===i?(n(),_.push("\n"),U=!0,s=0):" "===i?s+=4:"\r"===i||(s+=1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(-1===C.indentation_baseline&&(C.indentation_baseline=s),U){for(e=0;C.indentation_level+1>e;e+=1)_.push(w);if(-1!==C.indentation_baseline)for(e=0;s-C.indentation_baseline>e;e++)_.push(" ")}}else{for(;x(i,I);){if("\n"===i&&(F+=V?V>=F?1:0:1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(Y&&F>1)for(e=0;F>e;e+=1)a(0===e),U=!0;B=F>0}if(x(i,k)){if(Z>R)for(;x(b.charAt(R),k)&&(i+=b.charAt(R),R+=1,R!==Z););if(R!==Z&&i.match(/^[0-9]+[Ee]$/)&&("-"===b.charAt(R)||"+"===b.charAt(R))){var c=b.charAt(R);R+=1;var u=v();return i+=c+u[0],[i,"TK_WORD"]}return"in"===i?[i,"TK_OPERATOR"]:(!B||"TK_OPERATOR"===T||"TK_EQUALS"===T||C.if_line||!Y&&"var"===E||a(),[i,"TK_WORD"])}if("("===i||"["===i)return[i,"TK_START_EXPR"];if(")"===i||"]"===i)return[i,"TK_END_EXPR"];if("{"===i)return[i,"TK_START_BLOCK"];if("}"===i)return[i,"TK_END_BLOCK"];if(";"===i)return[i,"TK_SEMICOLON"];if("/"===i){var m="",l=!0;if("*"===b.charAt(R)){if(R+=1,Z>R)for(;Z>R&&("*"!==b.charAt(R)||!b.charAt(R+1)||"/"!==b.charAt(R+1))&&(i=b.charAt(R),m+=i,("\n"===i||"\r"===i)&&(l=!1),R+=1,!(R>=Z)););return R+=2,l&&0===F?["/*"+m+"*/","TK_INLINE_COMMENT"]:["/*"+m+"*/","TK_BLOCK_COMMENT"]}if("/"===b.charAt(R)){for(m=i;"\r"!==b.charAt(R)&&"\n"!==b.charAt(R)&&(m+=b.charAt(R),R+=1,!(R>=Z)););return B&&a(),[m,"TK_COMMENT"]}}if("'"===i||'"'===i||"/"===i&&("TK_WORD"===T&&g(E)||")"===E&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])||"TK_COMMA"===T||"TK_COMMENT"===T||"TK_START_EXPR"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_OPERATOR"===T||"TK_EQUALS"===T||"TK_EOF"===T||"TK_SEMICOLON"===T)){var h=i,d=!1,f=0,y=0;if(t=i,Z>R)if("/"===h){for(var O=!1;d||O||b.charAt(R)!==h;)if(t+=b.charAt(R),d?d=!1:(d="\\"===b.charAt(R),"["===b.charAt(R)?O=!0:"]"===b.charAt(R)&&(O=!1)),R+=1,R>=Z)return[t,"TK_STRING"]}else for(;d||b.charAt(R)!==h;)if(t+=b.charAt(R),f&&f>=y&&(f=parseInt(t.substr(-y),16),f&&f>=32&&126>=f&&(f=String.fromCharCode(f),t=t.substr(0,t.length-y-2)+(f===h||"\\"===f?"\\":"")+f),f=0),f?f++:d?(d=!1,Q&&("x"===b.charAt(R)?(f++,y=2):"u"===b.charAt(R)&&(f++,y=4))):d="\\"===b.charAt(R),R+=1,R>=Z)return[t,"TK_STRING"];if(R+=1,t+=h,"/"===h)for(;Z>R&&x(b.charAt(R),k);)t+=b.charAt(R),R+=1;return[t,"TK_STRING"]}if("#"===i){if(0===_.length&&"!"===b.charAt(R)){for(t=i;Z>R&&"\n"!==i;)i=b.charAt(R),t+=i,R+=1;return _.push(o(t)+"\n"),a(),v()}var N="#";if(Z>R&&x(b.charAt(R),P)){do i=b.charAt(R),N+=i,R+=1;while(Z>R&&"#"!==i&&"="!==i);return"#"===i||("["===b.charAt(R)&&"]"===b.charAt(R+1)?(N+="[]",R+=2):"{"===b.charAt(R)&&"}"===b.charAt(R+1)&&(N+="{}",R+=2)),[N,"TK_WORD"]}}if("<"===i&&""===b.substring(R-1,R+2))return C.in_html_comment=!1,R+=2,B&&a(),["-->","TK_COMMENT"];if(x(i,j)){for(;Z>R&&x(i+b.charAt(R),j)&&(i+=b.charAt(R),R+=1,!(R>=Z)););return","===i?[i,"TK_COMMA"]:"="===i?[i,"TK_EQUALS"]:[i,"TK_OPERATOR"]}return[i,"TK_UNKNOWN"]}var b,_,O,T,E,N,S,C,A,w,I,k,j,R,D,P,M,K,L,B,U,F,G="";t=t?t:{};var X;void 0!==t.space_after_anon_function&&void 0===t.jslint_happy&&(t.jslint_happy=t.space_after_anon_function),void 0!==t.braces_on_own_line&&(X=t.braces_on_own_line?"expand":"collapse"),X=t.brace_style?t.brace_style:X?X:"collapse";var q=t.indent_size?t.indent_size:4,W=t.indent_char?t.indent_char:" ",Y=t.preserve_newlines===void 0?!0:t.preserve_newlines,V=t.max_preserve_newlines===void 0?!1:t.max_preserve_newlines,z="undefined"===t.jslint_happy?!1:t.jslint_happy,H=t.keep_array_indentation===void 0?!1:t.keep_array_indentation,J=t.space_before_conditional===void 0?!0:t.space_before_conditional,$=t.indent_case===void 0?!1:t.indent_case,Q=t.unescape_strings===void 0?!1:t.unescape_strings;U=!1;var Z=e.length;for(w="";q>0;)w+=W,q-=1;for(;e&&(" "===e.charAt(0)||" "===e.charAt(0));)G+=e.charAt(0),e=e.substring(1);for(b=e,S="",T="TK_START_EXPR",E="",N="",_=[],L=!1,I="\n\r ".split(""),k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$".split(""),P="0123456789".split(""),j="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::",j+=" <%= <% %> = ?>",j=j.split(" "),D="continue,try,throw,return,var,if,switch,case,default,for,while,break,function".split(","),A=[],l("BLOCK"),R=0;;){var et=v();if(O=et[0],K=et[1],"TK_EOF"===K)break;switch(K){case"TK_START_EXPR":if("["===O){if("TK_WORD"===T||")"===E){x(E,D)&&s(),l("(EXPRESSION)"),c();break}"[EXPRESSION]"===C.mode||"[INDENTED-EXPRESSION]"===C.mode?"]"===N&&","===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):"["===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):l("[EXPRESSION]"):l("[EXPRESSION]")}else"for"===S?l("(FOR-EXPRESSION)"):x(S,["if","while"])?l("(COND-EXPRESSION)"):l("(EXPRESSION)");";"===E||"TK_START_BLOCK"===T?a():"TK_END_EXPR"===T||"TK_START_EXPR"===T||"TK_END_BLOCK"===T||"."===E?B&&a():"TK_WORD"!==T&&"TK_OPERATOR"!==T?s():"function"===S||"typeof"===S?z&&s():(x(E,D)||"catch"===E)&&J&&s(),c();break;case"TK_END_EXPR":if("]"===O)if(H){if("}"===E){m(),c(),d();break}}else if("[INDENTED-EXPRESSION]"===C.mode&&"]"===E){d(),a(),c();break}d(),c();break;case"TK_START_BLOCK":if("do"===S?l("DO_BLOCK"):l("BLOCK"),"expand"===X||"expand-strict"===X){var tt=!1;"expand-strict"===X?(tt="}"===y(),tt||a(!0)):"TK_OPERATOR"!==T&&("="===E||g(E)&&"else"!==E?s():a(!0)),c(),tt||u()}else"TK_OPERATOR"!==T&&"TK_START_EXPR"!==T?"TK_START_BLOCK"===T?a():s():p(C.previous_mode)&&","===E&&("}"===N?s():a()),u(),c();break;case"TK_END_BLOCK":d(),"expand"===X||"expand-strict"===X?("{"!==E&&a(),c()):("TK_START_BLOCK"===T?U?m():n():p(C.mode)&&H?(H=!1,a(),H=!0):a(),c());break;case"TK_WORD":if(L){s(),c(),s(),L=!1;break}if(M="NONE","function"===O){if(C.var_line&&"TK_EQUALS"!==T&&(C.var_line_reindented=!0),(U||";"===E)&&"{"!==E&&"TK_BLOCK_COMMENT"!==T&&"TK_COMMENT"!==T){F=U?F:0,Y||(F=1);for(var nt=0;2-F>nt;nt++)a(!1)}"TK_WORD"===T?"get"===E||"set"===E||"new"===E||"return"===E?s():a():"TK_OPERATOR"===T||"="===E?s():h(C.mode)||a(),c(),S=O;break}if("case"===O||"default"===O&&C.in_case_statement){":"===E||C.case_body?m():($||C.indentation_level--,a(),$||C.indentation_level++),c(),C.in_case=!0,C.in_case_statement=!0,C.case_body=!1;break}"TK_END_BLOCK"===T?x(O.toLowerCase(),["else","catch","finally"])?"expand"===X||"end-expand"===X||"expand-strict"===X?M="NEWLINE":(M="SPACE",s()):M="NEWLINE":"TK_SEMICOLON"!==T||"BLOCK"!==C.mode&&"DO_BLOCK"!==C.mode?"TK_SEMICOLON"===T&&h(C.mode)?M="SPACE":"TK_STRING"===T?M="NEWLINE":"TK_WORD"===T?("else"===E&&n(!0),M="SPACE"):"TK_START_BLOCK"===T?M="NEWLINE":"TK_END_EXPR"===T&&(s(),M="NEWLINE"):M="NEWLINE",x(O,D)&&")"!==E&&(M="else"===E?"SPACE":"NEWLINE"),C.if_line&&"TK_END_EXPR"===T&&(C.if_line=!1),x(O.toLowerCase(),["else","catch","finally"])?"TK_END_BLOCK"!==T||"expand"===X||"end-expand"===X||"expand-strict"===X?a():(n(!0),s()):"NEWLINE"===M?g(E)?s():"TK_END_EXPR"!==T?"TK_START_EXPR"===T&&"var"===O||":"===E||("if"===O&&"else"===S&&"{"!==E?s():(C.var_line=!1,C.var_line_reindented=!1,a())):x(O,D)&&")"!==E&&(C.var_line=!1,C.var_line_reindented=!1,a()):p(C.mode)&&","===E&&"}"===N?a():"SPACE"===M&&s(),c(),S=O,"var"===O&&(C.var_line=!0,C.var_line_reindented=!1,C.var_line_tainted=!1),"if"===O&&(C.if_line=!0),"else"===O&&(C.if_line=!1);break;case"TK_SEMICOLON":c(),C.var_line=!1,C.var_line_reindented=!1,"OBJECT"===C.mode&&(C.mode="BLOCK");break;case"TK_STRING":"TK_END_EXPR"===T&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])?s():"TK_COMMENT"===T||"TK_STRING"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_SEMICOLON"===T?a():"TK_WORD"===T&&s(),c();break;case"TK_EQUALS":C.var_line&&(C.var_line_tainted=!0),s(),c(),s();break;case"TK_COMMA":if(C.var_line){if((h(C.mode)||"TK_END_BLOCK"===T)&&(C.var_line_tainted=!1),C.var_line_tainted){c(),C.var_line_reindented=!0,C.var_line_tainted=!1,a();break}C.var_line_tainted=!1,c(),s();break}"TK_COMMENT"===T&&a(),"TK_END_BLOCK"===T&&"(EXPRESSION)"!==C.mode?(c(),"OBJECT"===C.mode&&"}"===E?a():s()):"OBJECT"===C.mode?(c(),a()):(c(),s());break;case"TK_OPERATOR":var ot=!0,it=!0;if(g(E)){s(),c();break}if("*"===O&&"TK_UNKNOWN"===T&&!N.match(/^\d+$/)){c();break}if(":"===O&&C.in_case){$&&(C.case_body=!0),c(),a(),C.in_case=!1;break}if("::"===O){c();break}x(O,["--","++","!"])||x(O,["-","+"])&&(x(T,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||x(E,D))?(ot=!1,it=!1,";"===E&&h(C.mode)&&(ot=!0),"TK_WORD"===T&&x(E,D)&&(ot=!0),"BLOCK"!==C.mode||"{"!==E&&";"!==E||a()):"."===O?ot=!1:":"===O?0===C.ternary_depth?("BLOCK"===C.mode&&(C.mode="OBJECT"),ot=!1):C.ternary_depth-=1:"?"===O&&(C.ternary_depth+=1),ot&&s(),c(),it&&s();break;case"TK_BLOCK_COMMENT":var rt,at=i(O);if(f(at.slice(1),"*"))for(a(),_.push(at[0]),rt=1;at.length>rt;rt++)a(),_.push(" "),_.push(o(at[rt]));else for(at.length>1?a():"TK_END_BLOCK"===T?a():s(),rt=0;at.length>rt;rt++)_.push(at[rt]),_.push("\n");"\n"!==y("\n")&&a();break;case"TK_INLINE_COMMENT":s(),c(),h(C.mode)?s():r();break;case"TK_COMMENT":","!==E||B||n(!0),"TK_COMMENT"!==T&&(B?a():s()),c(),a();break;case"TK_UNKNOWN":g(E)&&s(),c()}N=E,T=K,E=O}var st=G+_.join("").replace(/[\r\n ]+$/,"");return st}function style_html(e,t){function n(){return this.pos=0,this.token="",this.current_mode="CONTENT",this.tags={parent:"parent1",parentcount:1,parent1:""},this.tag_type="",this.token_text=this.last_token=this.last_text=this.token_type="",this.Utils={whitespace:"\n\r ".split(""),single_token:"br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed".split(","),extra_liners:"head,body,/html".split(","),in_array:function(e,t){for(var n=0;t.length>n;n++)if(e===t[n])return!0;return!1}},this.get_content=function(){for(var e="",t=[],n=!1;"<"!==this.input.charAt(this.pos);){if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];if(e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace))t.length&&(n=!0),this.line_char_count--;else{if(n){if(this.line_char_count>=this.max_char){t.push("\n");for(var o=0;this.indent_level>o;o++)t.push(this.indent_string);this.line_char_count=0}else t.push(" "),this.line_char_count++;n=!1}t.push(e)}}return t.length?t.join(""):""},this.get_contents_to=function(e){if(this.pos==this.input.length)return["","TK_EOF"];var t="",n=RegExp(""+e+"\\s*>","igm");n.lastIndex=this.pos;var o=n.exec(this.input),i=o?o.index:this.input.length;return i>this.pos&&(t=this.input.substring(this.pos,i),this.pos=i),t},this.record_tag=function(e){this.tags[e+"count"]?(this.tags[e+"count"]++,this.tags[e+this.tags[e+"count"]]=this.indent_level):(this.tags[e+"count"]=1,this.tags[e+this.tags[e+"count"]]=this.indent_level),this.tags[e+this.tags[e+"count"]+"parent"]=this.tags.parent,this.tags.parent=e+this.tags[e+"count"]},this.retrieve_tag=function(e){if(this.tags[e+"count"]){for(var t=this.tags.parent;t&&e+this.tags[e+"count"]!==t;)t=this.tags[t+"parent"];t&&(this.indent_level=this.tags[e+this.tags[e+"count"]],this.tags.parent=this.tags[t+"parent"]),delete this.tags[e+this.tags[e+"count"]+"parent"],delete this.tags[e+this.tags[e+"count"]],1==this.tags[e+"count"]?delete this.tags[e+"count"]:this.tags[e+"count"]--}},this.get_tag=function(){var e="",t=[],n=!1;do{if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace)?(n=!0,this.line_char_count--):(("'"===e||'"'===e)&&(t[1]&&"!"===t[1]||(e+=this.get_unformatted(e),n=!0)),"="===e&&(n=!1),t.length&&"="!==t[t.length-1]&&">"!==e&&n&&(this.line_char_count>=this.max_char?(this.print_newline(!1,t),this.line_char_count=0):(t.push(" "),this.line_char_count++),n=!1),t.push(e))}while(">"!==e);var o,i=t.join("");o=-1!=i.indexOf(" ")?i.indexOf(" "):i.indexOf(">");var r=i.substring(1,o).toLowerCase();if("/"===i.charAt(i.length-2)||this.Utils.in_array(r,this.Utils.single_token))this.tag_type="SINGLE";else if("script"===r)this.record_tag(r),this.tag_type="SCRIPT";else if("style"===r)this.record_tag(r),this.tag_type="STYLE";else if(this.Utils.in_array(r,unformatted)){var a=this.get_unformatted(""+r+">",i);t.push(a),this.tag_type="SINGLE"}else if("!"===r.charAt(0))if(-1!=r.indexOf("[if")){if(-1!=i.indexOf("!IE")){var a=this.get_unformatted("-->",i);t.push(a)}this.tag_type="START"}else if(-1!=r.indexOf("[endif"))this.tag_type="END",this.unindent();else if(-1!=r.indexOf("[cdata[")){var a=this.get_unformatted("]]>",i);t.push(a),this.tag_type="SINGLE"}else{var a=this.get_unformatted("-->",i);t.push(a),this.tag_type="SINGLE"}else"/"===r.charAt(0)?(this.retrieve_tag(r.substring(1)),this.tag_type="END"):(this.record_tag(r),this.tag_type="START"),this.Utils.in_array(r,this.Utils.extra_liners)&&this.print_newline(!0,this.output);return t.join("")},this.get_unformatted=function(e,t){if(t&&-1!=t.indexOf(e))return"";var n="",o="",i=!0;do{if(this.pos>=this.input.length)return o;if(n=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(n,this.Utils.whitespace)){if(!i){this.line_char_count--;continue}if("\n"===n||"\r"===n){o+="\n",this.line_char_count=0;continue}}o+=n,this.line_char_count++,i=!0}while(-1==o.indexOf(e));return o},this.get_token=function(){var e;if("TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token){var t=this.last_token.substr(7);return e=this.get_contents_to(t),"string"!=typeof e?e:[e,"TK_"+t]}if("CONTENT"===this.current_mode)return e=this.get_content(),"string"!=typeof e?e:[e,"TK_CONTENT"];if("TAG"===this.current_mode){if(e=this.get_tag(),"string"!=typeof e)return e;var n="TK_TAG_"+this.tag_type;return[e,n]}},this.get_full_indent=function(e){return e=this.indent_level+e||0,1>e?"":Array(e+1).join(this.indent_string)},this.printer=function(e,t,n,o,i){this.input=e||"",this.output=[],this.indent_character=t,this.indent_string="",this.indent_size=n,this.brace_style=i,this.indent_level=0,this.max_char=o,this.line_char_count=0;for(var r=0;this.indent_size>r;r++)this.indent_string+=this.indent_character;this.print_newline=function(e,t){if(this.line_char_count=0,t&&t.length){if(!e)for(;this.Utils.in_array(t[t.length-1],this.Utils.whitespace);)t.pop();t.push("\n");for(var n=0;this.indent_level>n;n++)t.push(this.indent_string)}},this.print_token=function(e){this.output.push(e)},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var o,i,r,a,s;for(t=t||{},i=t.indent_size||4,r=t.indent_char||" ",s=t.brace_style||"collapse",a=0==t.max_char?1/0:t.max_char||70,unformatted=t.unformatted||["a"],o=new n,o.printer(e,r,i,a,s);;){var c=o.get_token();if(o.token_text=c[0],o.token_type=c[1],"TK_EOF"===o.token_type)break;switch(o.token_type){case"TK_TAG_START":o.print_newline(!1,o.output),o.print_token(o.token_text),o.indent(),o.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_END":if("TK_CONTENT"===o.last_token&&""===o.last_text){var u=o.token_text.match(/\w+/)[0],m=o.output[o.output.length-1].match(/<\s*(\w+)/);(null===m||m[1]!==u)&&o.print_newline(!0,o.output)}o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_SINGLE":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_CONTENT":""!==o.token_text&&o.print_token(o.token_text),o.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(""!==o.token_text){o.output.push("\n");var l=o.token_text;if("TK_SCRIPT"==o.token_type)var p="function"==typeof js_beautify&&js_beautify;else if("TK_STYLE"==o.token_type)var p="function"==typeof css_beautify&&css_beautify;if("keep"==t.indent_scripts)var h=0;else if("separate"==t.indent_scripts)var h=-o.indent_level;else var h=1;var d=o.get_full_indent(h);if(p)l=p(l.replace(/^\s*/,d),t);else{var f=l.match(/^\s*/)[0],g=f.match(/[^\n\r]*$/)[0].split(o.indent_string).length-1,x=o.get_full_indent(h-g);l=l.replace(/^\s*/,d).replace(/\r\n|\r|\n/g,"\n"+x).replace(/\s*$/,"")}l&&(o.print_token(l),o.print_newline(!0,o.output))}o.current_mode="TAG"}o.last_token=o.token_type,o.last_text=o.token_text}return o.output.join("")}function css_beautify(e,t){function n(){return h=e.charAt(++f)}function o(){return e.charAt(f+1)}function i(t){for(var o=f;n();)if("\\"==h)n(),n();else{if(h==t)break;if("\n"==h)break}return e.substring(o,f+1)}function r(){for(var e=f;d.test(o());)f++;return f!=e}function a(){var e=f;do;while(d.test(n()));return f!=e+1}function s(){var t=f;for(n();n();)if("*"==h&&"/"==o()){f++;break}return e.substring(t,f+1)}function c(e,t){return v.slice(-e.length+(t||0),t).join("").toLowerCase()==e}function u(){y++,g+=x}function m(){y--,g=g.slice(0,-l)}t=t||{};var l=t.indent_size||4,p=t.indent_char||" ";"string"==typeof l&&(l=parseInt(l));var h,d=/^\s+$/,f=-1,g=e.match(/^[\r\n]*[\t ]*/)[0],x=Array(l+1).join(p),y=0;print={},print["{"]=function(e){print.singleSpace(),v.push(e),print.newLine()},print["}"]=function(e){print.newLine(),v.push(e),print.newLine()},print.newLine=function(e){if(!e)for(;d.test(v[v.length-1]);)v.pop();v.length&&v.push("\n"),g&&v.push(g)},print.singleSpace=function(){v.length&&!d.test(v[v.length-1])&&v.push(" ")};var v=[];for(g&&v.push(g);;){var b=a();if(!h)break;"{"==h?(u(),print["{"](h)):"}"==h?(m(),print["}"](h)):'"'==h||"'"==h?v.push(i(h)):";"==h?v.push(h,"\n",g):"/"==h&&"*"==o()?(print.newLine(),v.push(s(),"\n",g)):"("==h?(v.push(h),r(),c("url",-1)&&n()&&(")"!=h&&'"'!=h&&"'"!=h?v.push(i(")")):f--)):")"==h?v.push(h):","==h?(r(),v.push(h),print.singleSpace()):"]"==h?v.push(h):"["==h||"="==h?(r(),v.push(h)):(b&&print.singleSpace(),v.push(h))}var _=v.join("").replace(/[\n ]+$/,"");return _}var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(""+t):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var i=e[t];return Array.isArray(i)?n(t,i):o(t,i)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return"#"===t[0]?i(t):e[t]||t},i=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),t.addEventListener("readystatechange",function(){4===t.readyState&&e.complete.call(e.thisArg,t.responseText,t)}),Object.keys(e.headers).forEach(function(n){t.setRequestHeader(n,e.headers[n])}),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO_"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+=this.urlstringify(e.data),n.src=e.url,document.head.appendChild(n)},IO.jsonp.define=function(e,t){IO.jsonp({url:"http://api.duckduckgo.com/",jsonpName:"callback",data:{format:"json",q:"define "+e},fun:t})},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},function(){"use strict";var e=window.bot={invocationPattern:"!!",commandRegex:/^\/\s?([\w\-]+)(?:\s(.+))?$/,commands:{},commandDictionary:null,listeners:[],parseMessage:function(t){if(!this.validateMessage(t))return e.log(t,"parseMessage invalid"),void 0;var n=this.prepareMessage(t);if(e.log(n,"parseMessage valid"),this.banlist.contains(n.get("user_id")))return e.log(t,"parseMessage banned"),n.reply("You iz in mindjail"),void 0;try{n.startsWith("/")?this.parseCommand(n):n.startsWith(">")?this.eval(n):this.callListeners(n)}catch(o){var i="Could not process input. Error: "+o.message;o.lineNumber&&(i+=" on line "+o.lineNumber),o.column&&(i+=" on column "+o.column),n.directreply(i),console.error(o,i)}},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.decodehtmlEntities(e.content);return this.Message(t.slice(this.invocationPattern.length).trim(),e)},parseCommand:function(t){e.log(t,"parseCommand input");var n=this.commandRegex.exec(t);if(!n)return t.reply("Invalid command "+t),void 0;var o=n[1].toLowerCase();e.log(n,"parseCommand matched");var i=this.getCommand(o);if(i.error)return t.reply(i.error),void 0;if(!i.canUse(t.get("user_id")))return t.reply("You do not have permission to use the command "+o),void 0;e.log(i,"parseCommand calling");var r=this.Message(t.slice(o.length+1).trim(),t.get()),a=i.exec(r);a&&t.reply(a)},validateMessage:function(e){var t=e.content.trim();return t.startsWith(this.invocationPattern)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){if(this.commandExists(e))return this.commands[e];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var t="Command "+e+" does not exist.",n=this.commandDictionary.search(e);return n.length&&(t+=" Did you mean: "+n.join(", ")),{error:t}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(t){var n=!1;this.listeners.forEach(function(o){var i,r=t.exec(o.pattern);r&&(i=o.fun.call(o.thisArg,t),e.log(r,i),i&&t.reply(i),i!==!1&&(n=!0))}),n||t.reply("Y U NO MAEK SENSE!? Could not understand `"+t+"`")},reply:function(e,t){var n=this.adapter.reply(e,t);this.adapter.out.add(n,t.room_id)},directreply:function(e,t){var n=this.adapter.directreply(e,t);this.adapter.out.add(n,t.room_id)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1}};e.banlist=[],e.banlist.contains=function(e){return this.indexOf(e)>=0},e.banlist.add=function(e){return this.push(e)},e.banlist.remove=function(e){var t=this.indexOf(e);return t>=0?this.splice(t,1):null},e.eval=function(e){function t(t){r.terminate(),e.directreply(t)}function n(e){var t,n=e.answer,i=e.log;return t=o(n),i&&i.length&&(t+=" Logged: "+o(i)+""),t}function o(e){var t;return t=e.length>400?"(snip) `"+e.slice(0,400)+"`":"`"+e+"`"}var i,r=new Worker("codeWorker.js");r.onmessage=function(e){clearTimeout(i),t(n(e.data))},r.onerror=function(e){clearTimeout(i),t(""+e)},r.postMessage({code:e.content.substr(1)}),i=window.setTimeout(function(){t("Maximum execution time exceeded")},50)},e.Command=function(t){return t.name=t.name.toLowerCase(),t.permissions=t.permissions||{},t.permissions.use=t.permissions.use||"ALL",t.permissions.del=t.permissions.del||"NONE",t.description=t.description||"",["Use","Del"].forEach(function(e){var n=e.toLowerCase();t["can"+e]=function(e){var t=this.permissions[n];return"ALL"===t||"NONE"!==t&&t.indexOf(e)>-1}}),t.exec=function(){return this.fun.apply(this.thisArg,arguments)},t.del=function(){delete e.commands[t.name]},t},e.Message=function(t,n){var o=Object(t);o.content=t;var i={respond:function(t){e.adapter.out.add(t,n.room_id)},reply:function(t,o){o=o||n.user_name,e.reply(t,Object.merge(n,{user_name:o}))},directreply:function(t,o){o=o||n.message_id,e.directreply(t,Object.merge(n,{message_id:o}))},parse:function(o,i){!!o===o&&(i=o,o=t);var r=e.parseCommandArgs(o||t);return i?r.map(function(t){return e.Message(t,n)}):r},exec:function(e){var n=e.exec(t);return this.matches=n?n:[],n},findUserid:function(e){var t=[].slice.call(document.getElementById("sidebar").getElementsByClassName("user-container")),n=t.map(function(e){return e.id.match(/\d+/)[0]}),o=t.map(function(e){return e.getElementsByTagName("img")[0].title.toLowerCase()}),i=o.indexOf((""+e).toLowerCase());return 0>i?void 0:Number(n[i])}.memoize(),codify:e.adapter.codify.bind(e.adapter),escape:e.adapter.escape.bind(e.adapter),link:e.adapter.link.bind(e.adapter),get:function(e){return e?n[e]:n},set:function(e,t){return n[e]=t}};return Object.keys(i).forEach(function(e){o[e]=i[e]}),o},e.owners=[419970,342129,170224,94197,617762],e.isOwner=function(e){return this.owners.indexOf(e)>-1},IO.register("input",e.parseMessage,e),Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){var t=[].slice.call(arguments,1);return this.map(function(n){var o=n;return n[e]&&n[e].apply&&(o=n[e].apply(n,t)),o})},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this,e=e||function(e){return e};return function(){function o(){t[a]=arguments,r.apply(null,arguments)}var i=[].slice.call(arguments),r=i.pop(),a=e.apply(null,arguments);return a in t?(r.apply(null,t[a]),void 0):(i.push(o),n.apply(this,i),void 0)}},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},String.prototype.supplant=function(e){function t(t,n){return e.hasOwnProperty(n)?e[n]:t}return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.add=function(e,t){return this+e+(t?"":"\n")},function(){var t;t=e!==void 0?e:"undefined"!=typeof exports?exports:window,t.parseCommandArgs=function(){var e=0,t=1,n=2,o=3,i="'",r='"',a={parse:function(t,n,o){this.source=t,this.pos=0,this.length=t.length,this.state=e,this.lookahead="",this.escaper=o||"~",this.separator=n||" "; var i=this.tokenize();return this.state!==e&&this.throwFinishError(),i},tokenize:function(){for(var e,t=[];this.length>this.pos;)e=this.nextArg(),e&&t.push(e);return t},nextArg:function(){var t,n="";for(this.state=e;;){if(t=this.nextChar(),null===t||this.state===o)break;n+=t}return n},nextChar:function(t){var n=this.lookahead=this.source[this.pos];return this.pos++,n?t?n:n===this.escaper?this.nextChar(!0):n===this.separator&&this.state===e?(this.state=o,n):this.string():null},string:function(){var e=this.lookahead;return e===i?this.singleQuotedString():e===r?this.doubleQuotedString():e},singleQuotedString:function(){return this.state===n?this.lookahead:(this.state=this.state!==t?t:e,this.nextChar())},doubleQuotedString:function(){return this.state===t?this.lookahead:(this.state=this.state!==n?n:e,this.nextChar())},throwFinishError:function(){var e="";this.state===t?e="Expected "+i:this.state===n&&(e="Expected "+r);var o=Error("Unexpected end of input: "+e);throw o.column=this.pos,o}};return function(){return a.parse.apply(a,arguments)}}()}();var t=function(){function e(){this.word=null,this.children={}}function t(n){if(!(this instanceof t))throw new TypeError("Illegal function call");if(n=parseInt(n,10),isNaN(n)||1>n)throw new TypeError("maxCost must be an integer > 1 ");this.maxCost=n,this.trie=new e}function n(e,t){var n,o,i,r=[];for(void 0===t?(i=0,o=e):(i=e,o=t-i),n=0;o>n;++n)r[n]=i++;return r}function o(e,t,o){var r=[],a=n(e.length+1);return Object.keys(o.children).forEach(function(n){i(o.children[n],n,e,a,r,t)}),r}function i(e,t,n,o,r,a){var s,c,u,m,l,p=n.length+1,h=[o[0]+1];for(s=1;p>s;++s)c=h[s-1]+1,u=o[s]+1,m=n.charAt(s-1)!==t?o[s-1]+1:o[s-1],h.push(Math.min(c,u,m));l=h[h.length-1],a>=l&&null!==e.word&&r.push([e.word,l]),a>=Math.min.apply(Math,h)&&Object.keys(e.children).forEach(function(t){i(e.children[t],t,n,h,r,a)})}return e.prototype.add=function(t){for(var n,o=this,i=0;n=t.charAt(i++);)n in o.children||(o.children[n]=new e),o=o.children[n];o.word=t},t.prototype={constructor:t,build:function(t){if(!Array.isArray(t))throw new TypeError("Cannot build a dictionary from "+t);this.trie=new e,t.forEach(function(e){this.trie.add(e)},this)},__sortfn:function(e,t){return e[1]-t[1]},search:function(e){e=e.valueOf();var t;if("string"!=typeof e)throw new TypeError("Cannot search "+e);if(void 0===this.trie)throw new TypeError("Cannot search, dictionary isn't built yet");return t=o(e,this.maxCost,this.trie),t.sort(this.__sortfn),t.map(function(e){return e[0]})}},t}();e.commandDictionary=new t(3),function(){var t={help:function(t){if(t.length){var n=e.getCommand(t);if(n.error)return n.error;var o=n.description||"No info is available";return t+": "+o}return"https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot"},listen:function(t){return e.callListeners(t)},live:function(){return e.stopped?(e.continue(),"And on this day, you shall paint eggs for a giant bunny."):"I'm not dead! Honest!"},die:function(){return e.stopped?"Kill me once, shame on you, kill me twice...":(e.stop(),"You killed me!")},forget:function(t){var n=t.toLowerCase(),o=e.getCommand(n);return o.error?o.error:o.canDel(t.get("user_id"))?(o.del(),"Command "+n+" forgotten."):"You are not authorized to delete the command "+t},ban:function(t){function n(t){0>t||(e.banlist.contains(t)?o+="User "+t+" already in mindjail. ":(e.banlist.add(t),o+="User "+t+" added to mindjail. "))}var o="";return t.parse().map(function(n){var i=Number(n);return/^\d+$/.test(n)&&(i=t.findUserid(n)),i?e.isOwner(i)&&(o+="Cannot mindjail owner "+n+". ",i=-1):o+="Cannot find user "+n+". ",i}).forEach(n),o},unban:function(t){function n(t){e.banlist.contains(t)?(e.banlist.remove(t),o+="User "+t+" freed from mindjail. "):o+="User "+t+" isn't in mindjail. "}var o="";return t.parse().map(function(e){var n=Number(e);return/^\d+$/.test(e)&&(n=t.findUserid(e)),n||(o+="Cannot find user "+e+". "),Number(n)}).forEach(n),o},regex:function(t){var n=t.parse(),o=n.shift(),i=n.shift(),r=n.shift()||"",a=RegExp(i,r.toLowerCase()),s=a.exec(o);return e.log(o,i,r,a,"regex parsed"),e.log(s,"regex matched"),s?s.map(function(e){return"`"+e+"`"}).join(", "):"No matches."},jquery:function n(t){var o=t.parse(!0);if(o.length>1)return o.map(n).join(" ");var i,r=t.trim().replace(/^\$/,"jQuery"),a=r.split("."),s=!1,c=r;return e.log(r,a,"/jquery input"),3===a.length&&(a=[a[2]]),"jQuery"===a[0]&&jQuery[a[1]]?s=!0:1===a.length&&jQuery.prototype[a[0]]?(c=a[0],s=!0):jQuery[a[0]]&&(c="jQuery."+a[0],s=!0),i=s?"http://api.jquery.com/"+c:"http://api.jquery.com/?s="+encodeURIComponent(t),e.log(i,"/jquery link"),i},choose:function(t){function n(e){return"or"!==e}var o=t.parse().filter(n),i=Math.random(),r=o.length;return e.log(o,i,"/choose input"),.1>i?2===r?"Neither":"None of the above":.25>i?2===r?"Both!":"All of the above":o[Math.floor(Math.random()*r)]},user:function(e){var t=e.parse(),n=t[0]||e.get("user_id"),o=n;return/^\d+$/.test(n)||(o=e.findUserid(n))?(e.directreply("http://stackoverflow.com/users/"+o),void 0):"Can't find user "+n+" in this chatroom."},listcommands:function(){return"Available commands: "+Object.keys(e.commands).join(", ")}};t.define=function(){var t=Object.create(null);return function(n,o){function i(o){var i=o.AbstractURL,a=o.AbstractText;e.log(i,a,"/define finishCall input"),"Merriam-Webster"===o.AbstractSource&&(a=a.replace(n+" definition: ",""),e.log(a,"/define finishCall webster")),a?(a=n+": "+a,a+=" [\\(source\\)]("+i+")",t[n]=a):(a="Could not find definition for "+n+". Trying Urban Dictionary",e.getCommand("urban").exec(n)),e.log(a,"/define finishCall output"),r(a)}function r(e){o&&o.call?o(e):n.directreply(e)}return t[n]?r(t[n]):(IO.jsonp.define(""+n,i),void 0)}}(),t.define.async=!0,t.norris=function(e,t){function n(n){var o;o="success"!==n.type?"Chuck Norris is too awesome for this API. Try again.":IO.decodehtmlEntities(n.value.joke),t&&t.call?t(o):e.reply(o)}var o="http://api.icndb.com/jokes/random";IO.jsonp({url:o,fun:n,jsonpName:"callback"})},t.norris.async=!0,t.urban=function(){var e=Object.create(null);return function(t,n){function o(n){var o;o="no_results"===n.result_type?"Y U NO MAEK SENSE!!!???!!?11 No results for "+t:r(n.list[0]),e[t]=o,i(o)}function i(e){n&&n.call?n(e):t.reply(e)}function r(e){return t.link(""+t,e.permalink)+" "+e.definition}return t.length?e[t]?i(e[t]):(IO.jsonp({url:"http://www.urbandictionary.com/iphone/search/define",data:{term:t.content},jsonpName:"callback",fun:o}),void 0):"Y U NO PROVIDE ARGUMENTS!?"}}(),t.urban.async=!0,t.parse=function(){var t={who:function(){return[].pop.call(arguments).get("user_name")},someone:function(){var e=document.getElementById("sidebar").getElementsByClassName("present-user"),t=[].filter.call(e,function(e){return Number(e.style.opacity)>=.5}),n=t[Math.floor(Math.random()*(t.length-1))];return n?n.getElementsByTagName("img")[0].title:"Nobody! I'm all alone :("},digit:function(){return Math.floor(10*Math.random())},encode:function(e){return encodeURIComponent(e)},rand:function(e,t){return e=Number(e),t=Number(t),e?t||(t=e,e=0):(e=0,t=9),Math.floor(Math.random()*(t-e+1))+e}},n=/(?:.|^)\$(\w+)(?:\((.*?)\))?/g;return function o(i,r){function a(t,n,o){if(t.startsWith("$$"))return t.slice(1);var i="";"$"!==t[0]&&(i=t[0]);var r=c(n);return r?(e.log(r,n,o,"/parse replaceMacro"),i+=r.apply?r.apply(null,s(o)):r):n}function s(e){return console.log(e,"/parse parseMacroArgs"),e?o(e,r).split(",").invoke("trim").concat(i):[]}function c(e){function n(t){return t.hasOwnProperty(e)}return([t,u,r].first(n)||[])[e]}var u=i.get&&i.get()||{};return r=r||{},e.log(i,r,"/parse input"),i.replace(n,a)}}(),t.tell=function(){var t={tell:!0,forget:!0};return function(n){function o(e){e&&(c?n.directreply(e):n.reply(e))}var i=n.parse();e.log(n.valueOf(),i,"/tell input");var r,a=i[0],s=i[1];if(!a||!s)return"Invalid /tell arguments. Use /help for usage info";if(r=e.getCommand(s),r.error)return r.error;if(t.hasOwnProperty(s))return"Command "+s+" cannot be used in /tell.";if(!r.canUse(n.get("user_id")))return"You do not have permission to use command "+s;var c=!1,u=n.get();/^:?\d+$/.test(a)?(u.message_id=a.replace(/^:/,""),c=!0):u.user_name=a.replace(/^@/,"");var m=e.Message(n.slice(a.length+s.length+2).trim(),u);e.log(m,"/tell calling "+s),r.async?r.exec(m,o):o(r.exec(m))}}(),t.mdn=function(t,n){function o(t){if(200!==t.responseStatus)return i("Something went on fire; status "+t.responseStatus),void 0;var n=t.responseData.results[0];e.log(n,"/mdn result"),i(r.supplant(n))}function i(e){n&&n.call?n(e):t.reply(e)}var r="[{titleNoFormatting}]({url})";IO.jsonp.google(""+t+" site:developer.mozilla.org",o)},t.mdn.async=!0,t.get=function(){var t={answer:!0,question:!0},n={first:function(e){return e[e.length-1]},last:function(e){return e[0]},between:function(e){return e}};return function(o,i){function r(t){if(t.error)return o.reply(t.error.message),void 0;var r,a=[].concat(n[u](t[c])),m="http://stackoverflow.com/q/";e.log(a.slice(),"/get parseResponse parsing"),r=a[0]?a.map(function(e){return m+(e[s+"_id"]||"")}).join(" "):"User did not submit any "+c,e.log(r,"/get parseResponse parsed"),i&&i.call?i(r):o.directreply(r)}var a=o.parse(),s=a[0]||"answer",c=s+"s",u=a[1]||"last",m=a[2];if("between"===u&&(m=a[4]),m||isNaN(u)||(m=u,u="last"),m||(m=o.get("user_id")),e.log(a,"get input"),!t.hasOwnProperty(s))return'Invalid "getter" name '+s;if(!n.hasOwnProperty(u))return"Invalid range specifier "+u;var l="http://api.stackoverflow.com/1.1/users/"+m+"/"+c,p={sort:"creation"};e.log(l,p,"/get building url"),"between"===u&&(p.fromdate=Date.parse(a[2]),p.todate=Date.parse(a[3]),e.log(l,p,"/get building url between")),IO.jsonp({url:l,data:p,fun:r})}}(),t.get.async=!0;var o={help:"Fetches documentation for given command, or general help article. `/help [cmdName]`",listen:"Forwards the message to the listen API (as if called withoutthe /)",live:"Resurrects the bot if it's down",die:"Kills the bot",forget:"Forgets a given command. `/forget cmdName`",ban:"Bans a user from using a bot. `/ban usr_id|usr_name`",unban:"Removes a user from bot's mindjail. `/unban usr_id|usr_name`",regex:"Executes a regex against text input. `/regex text regex [flags]`",jquery:"Fetches documentation link from jQuery API. `/jquery what`",choose:'"Randomly" choose an option given. `/choose option0 option1 ...`',user:"Fetches user-link for specified user. `/user usr_id|usr_name`",listcommands:"This seems pretty obvious",define:"Fetches definition for a given word. `/define something`",norris:"Random chuck norris joke!",urban:"Fetches UrbanDictionary definition. `/urban something`",parse:'Returns result of "parsing" message according to the bot\'s mini-macro capabilities',tell:"Redirect command result to user/message. /tell `msg_id|usr_name cmdName [cmdArgs]`",mdn:"Fetches mdn documentation. `/mdn what`",get:"",learn:"Teach the bot a command. "};Object.keys(t).forEach(function(n){e.addCommand({name:n,fun:t[n],permissions:{del:"NONE"},description:o[n],async:t[n].async})}),["die","live","ban","unban"].forEach(function(t){e.commands[t].permissions.use=e.owners})}(),function(){var t=["A robot may not injure a human being or, through inaction, allow a human being to come to harm.","A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.","A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws."].map(function(e,t,n){return n+1+")"+t}).join("\n");e.listen(/^tell (me (your|the) )?(rules|laws)/,function(){return t}),e.listen(/^give ([\w\s]+) a lick/,function(e){var t=e.matches[1],n="s";return"me"===t?(t="you",n=""):"yourself"===t&&(t="I",n=""),"Mmmm! "+t+" taste"+n+" just like raisin"});var n=[/^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/,/^define\s(?:(?:an|a)\s)?([\w\s\-]+)/];e.listen(n,function(t){var n=t.matches[1],o=e.getCommand("define");o.exec(n,function(e){e=e.replace(n+":",""),t.reply(e)})})}()}(),function(){var e="[{text}]({url})";bot.adapter={roomid:(/\d+/.exec(location)||[0])[0],transform:function(e){return e},escape:function(e){return e.replace(/([`\*_\(\)\[\]])/g,"\\$1")},reply:function(e,t){var n=t.user_name.replace(/\s/g,"");return"@"+n+" "+e},directreply:function(e,t){return":"+t.message_id+" "+e},codify:function(e){var t=" ",n=e.replace(" ",t),o=n.split(/[\r\n]/g);return 1===o.length?"`"+o[0]+"`":o.map(function(e){return t+e}).join("\n")},link:function(t,n){return e.supplant({text:this.escape(t),url:n})}};var t=bot.adapter.in={times:{},interval:5e3,init:function(){function e(e){e=JSON.parse(e),bot.log(e),t.times["r"+n]=e.time,t.loopage()}var t=this,n=bot.adapter.roomid;IO.xhr({url:"/chats/"+n+"/events/",data:fkey({since:0,mode:"Messages",msgCount:0}),method:"POST",complete:e})},poll:function(){var e=this;IO.xhr({url:"/events",data:fkey(e.times),method:"POST",complete:e.pollComplete,thisArg:e})},pollComplete:function(e){if(e){e=JSON.parse(e);var t=this;Object.keys(e).forEach(function(n){var o=e[n];o.t&&(t.times[n]=o.t),o.e&&o.e.forEach(t.handleMessageObject,t)}),IO.in.flush()}},handleMessageObject:function(e){return 1===e.event_type||2===e.event_type?e.content.startsWith("