"use strict";var default_options={};function $(b){return document.getElementById(b)}var uglify_options,$options=$("options"),$out=$("out"),$in=$("in"),$error=$("error"),$stats=$("stats"),$body=document.body,$btn_options=$("btn-options"),$btn_options_save=$("btn-options-save"),$cb_as_i_type=$("cb-as-i-type");$("header-link").onclick=go_to_start,$("btn-go").onclick=go,$btn_options.onclick=show_options,$btn_options_save.onclick=set_options,$("btn-options-reset").onclick=reset_options,$in.oninput=$in.onkeyup=$in.onblur=$in.onfocus=go_ait,$cb_as_i_type.onclick=set_options_ait,$out.onfocus=select_text;var default_options_text;set_options_initial();function hide(e){for(var a=e.split(" "),b=" "+$body.className+" ",c=0;c<a.length;c++)for(;0<=b.indexOf(" "+a[c]+" ");)b=b.replace(" "+a[c]+" "," ");$body.className=b.replace(/^\s+|\s+$/g,"")}function show(b){$body.className+=" "+b}function show_options(){show("s-options"),hide("s-input")}function get_options(b){return new Function("return ("+(b||$options.value)+");")()}function set_options(){var c=uglify_options;try{uglify_options=get_options();try{default_options_text===$options.value?localStorage.removeItem("uglify-options"):localStorage.setItem("uglify-options",$options.value)}catch(b){}return go(!0),show("s-input"),hide("s-options"),!0}catch(a){return a instanceof JS_Parse_Error?(show_error(a,$in.value),!0):(uglify_options=c,show_error(a),!1)}}function reset_options(){$options.value=default_options_text,set_options()}function set_options_ait(){try{$cb_as_i_type.checked?localStorage.removeItem("uglify-options-disable-ait"):localStorage.setItem("uglify-options-disable-ait",1)}catch(b){}}function set_options_initial(){default_options_text=$options.textContent||$options.innerText,default_options=get_options(default_options_text);try{var b=localStorage.getItem("uglify-options");b&&($options.value=b),$cb_as_i_type.checked=!localStorage.getItem("uglify-options-disable-ait")}catch(b){}try{uglify_options=get_options()}catch(b){$options.value=default_options_text,uglify_options=default_options}}function encodeHTML(b){return(b+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}var last_input;function go(d){function a(){if(!b||b===$in.textContent)return void go_to_start();var c=minify(b,uglify_options);if(c.error)throw c.error;hide("s-info s-error"),show("s-output"),$out.value=c.code||"/* no output! */",$stats.innerHTML=c.code.length+" bytes, saved "+(100*(1-c.code.length/b.length)||0).toFixed(2)+"%"}var b=$in.value;if(last_input=b,!0===d)a();else try{a()}catch(c){show_error(c,b)}}var ait_timeout,ait_last_duration=50;function go_ait(){if($cb_as_i_type.checked){var b=$in.value;b===last_input||(last_input=b,clearTimeout(ait_timeout),ait_timeout=setTimeout(function(){var b=new Date;go(),ait_last_duration=new Date-b},ait_last_duration))}}function show_error(e,a){if(console.error("Error",e),hide("s-info s-output"),show("s-error"),e instanceof JS_Parse_Error){var b=a.split("\n"),c=b[e.line-1];e="Parse error: <strong>"+encodeHTML(e.message)+"</strong>\n<small>Line "+e.line+", column "+(e.col+1)+"</small>\n\n"+(b[e.line-2]?e.line-1+": "+encodeHTML(b[e.line-2])+"\n":"")+e.line+": "+encodeHTML(c.substr(0,e.col))+"<mark>"+encodeHTML(c.substr(e.col,1)||" ")+"</mark>"+encodeHTML(c.substr(e.col+1))+"\n"+(b[e.line]?e.line+1+": "+encodeHTML(b[e.line]):"")}else e=e instanceof Error?e.name+": <strong>"+encodeHTML(e.message)+"</strong>":"<strong>"+encodeHTML(e)+"</strong>";$error.innerHTML=e}function go_to_start(){return clearTimeout(ait_timeout),hide("s-options s-error s-output"),show("s-input s-info"),!1}function select_text(){var b=this;return b.select(),b.onmouseup=b.onkeyup=function(){return b.onmouseup=b.onkeyup=null,b.scrollTop=0,!1},!1}