(function(){function l(e,b,l,v){var a,w,k,p,h,q,r,x,y,m,z,A,B,C,n;b=b||{};void 0!==b.wrap_line_length&&0!==parseInt(b.wrap_line_length,10)||void 0===b.max_char||0===parseInt(b.max_char,10)||(b.wrap_line_length=b.max_char);w=void 0===b.indent_inner_html?!1:b.indent_inner_html;k=void 0===b.indent_size?4:parseInt(b.indent_size,10);p=void 0===b.indent_char?" ":b.indent_char;q=void 0===b.brace_style?"collapse":b.brace_style;h=0===parseInt(b.wrap_line_length,10)?32786:parseInt(b.wrap_line_length||250,10);
r=b.unformatted||"a span img bdo em strong dfn code samp kbd var cite abbr acronym q sub sup tt i b big small u s strike font ins del pre address dt h1 h2 h3 h4 h5 h6".split(" ");y=(x=void 0===b.preserve_newlines?!0:b.preserve_newlines)?isNaN(parseInt(b.max_preserve_newlines,10))?32786:parseInt(b.max_preserve_newlines,10):0;m=void 0===b.indent_handlebars?!1:b.indent_handlebars;z=void 0===b.wrap_attributes?"auto":b.wrap_attributes;A=void 0===b.wrap_attributes_indent_size?k:parseInt(b.wrap_attributes_indent_size,
10)||k;B=void 0===b.end_with_newline?!1:b.end_with_newline;C="object"==typeof b.extra_liners&&b.extra_liners?b.extra_liners.concat():"string"===typeof b.extra_liners?b.extra_liners.split(","):["head","body","/html"];n=b.eol?b.eol:"\n";b.indent_with_tabs&&(p="\t",k=1);n=n.replace(/\\r/,"\r").replace(/\\n/,"\n");a=new function(){this.pos=0;this.token="";this.current_mode="CONTENT";this.tags={parent:"parent1",parentcount:1,parent1:""};this.token_text=this.last_token=this.last_text=this.token_type=this.tag_type=
"";this.newlines=0;this.indent_content=w;this.Utils={whitespace:["\n","\r","\t"," "],single_token:"br input link meta source !doctype basefont base area hr wbr param img isindex embed".split(" "),extra_liners:C,in_array:function(c,D){for(var a=0;a<D.length;a++)if(c===D[a])return!0;return!1}};this.is_whitespace=function(c){for(;0<c.length;c++)if(!this.Utils.in_array(c.charAt(0),this.Utils.whitespace))return!1;return!0};this.traverse_whitespace=function(){var c="",c=this.input.charAt(this.pos);if(this.Utils.in_array(c,
this.Utils.whitespace)){for(this.newlines=0;this.Utils.in_array(c,this.Utils.whitespace);)x&&"\n"===c&&this.newlines<=y&&(this.newlines+=1),this.pos++,c=this.input.charAt(this.pos);return!0}return!1};this.space_or_wrap=function(c){this.line_char_count>=this.wrap_line_length?(this.print_newline(!1,c),this.print_indentation(c)):(this.line_char_count++,c.push(" "))};this.get_content=function(){for(var c="",a=[];"\x3c"!==this.input.charAt(this.pos);){if(this.pos>=this.input.length)return a.length?a.join(""):
["","TK_EOF"];if(this.traverse_whitespace())this.space_or_wrap(a);else{if(m)if(c=this.input.substr(this.pos,3),"{{#"===c||"{{/"===c)break;else{if("{{!"===c)return[this.get_tag(),"TK_TAG_HANDLEBARS_COMMENT"];if("{{"===this.input.substr(this.pos,2)&&"{{else}}"===this.get_tag(!0))break}c=this.input.charAt(this.pos);this.pos++;this.line_char_count++;a.push(c)}}return a.length?a.join(""):""};this.get_contents_to=function(c){if(this.pos===this.input.length)return["","TK_EOF"];var a="";c=new RegExp("\x3c/"+
c+"\\s*\x3e","igm");c.lastIndex=this.pos;c=(c=c.exec(this.input))?c.index:this.input.length;this.pos<c&&(a=this.input.substring(this.pos,c),this.pos=c);return a};this.record_tag=function(c){this.tags[c+"count"]?this.tags[c+"count"]++:this.tags[c+"count"]=1;this.tags[c+this.tags[c+"count"]]=this.indent_level;this.tags[c+this.tags[c+"count"]+"parent"]=this.tags.parent;this.tags.parent=c+this.tags[c+"count"]};this.retrieve_tag=function(c){if(this.tags[c+"count"]){for(var a=this.tags.parent;a&&c+this.tags[c+
"count"]!==a;)a=this.tags[a+"parent"];a&&(this.indent_level=this.tags[c+this.tags[c+"count"]],this.tags.parent=this.tags[a+"parent"]);delete this.tags[c+this.tags[c+"count"]+"parent"];delete this.tags[c+this.tags[c+"count"]];1===this.tags[c+"count"]?delete this.tags[c+"count"]:this.tags[c+"count"]--}};this.indent_to_tag=function(c){if(this.tags[c+"count"]){for(var a=this.tags.parent;a&&c+this.tags[c+"count"]!==a;)a=this.tags[a+"parent"];a&&(this.indent_level=this.tags[c+this.tags[c+"count"]])}};this.get_tag=
function(c){var a="",d=[],a="",b=!1,e=!0,f,g,h=this.pos,k=this.line_char_count;c=void 0!==c?c:!1;do{if(this.pos>=this.input.length)return c&&(this.pos=h,this.line_char_count=k),d.length?d.join(""):["","TK_EOF"];a=this.input.charAt(this.pos);this.pos++;if(this.Utils.in_array(a,this.Utils.whitespace))b=!0;else{if("'"===a||'"'===a)a+=this.get_unformatted(a),b=!0;"\x3d"===a&&(b=!1);if(d.length&&"\x3d"!==d[d.length-1]&&"\x3e"!==a&&b){this.space_or_wrap(d);b=!1;if(!e&&"force"===z&&"/"!==a){this.print_newline(!0,
d);this.print_indentation(d);for(var l=0;l<A;l++)d.push(p)}for(l=0;l<d.length;l++)if(" "===d[l]){e=!1;break}}m&&"\x3c"===g&&"{{"===a+this.input.charAt(this.pos)&&(a+=this.get_unformatted("}}"),d.length&&" "!==d[d.length-1]&&"\x3c"!==d[d.length-1]&&(a=" "+a),b=!0);"\x3c"!==a||g||(f=this.pos-1,g="\x3c");m&&!g&&2<=d.length&&"{"===d[d.length-1]&&"{"===d[d.length-2]&&(f="#"===a||"/"===a||"!"===a?this.pos-3:this.pos-2,g="{");this.line_char_count++;d.push(a);if(d[1]&&("!"===d[1]||"?"===d[1]||"%"===d[1])){d=
[this.get_comment(f)];break}if(m&&d[1]&&"{"===d[1]&&d[2]&&"!"===d[2]){d=[this.get_comment(f)];break}if(m&&"{"===g&&2<d.length&&"}"===d[d.length-2]&&"}"===d[d.length-1])break}}while("\x3e"!==a);f=d.join("");g=-1!==f.indexOf(" ")?f.indexOf(" "):"{"===f.charAt(0)?f.indexOf("}"):f.indexOf("\x3e");a="\x3c"!==f.charAt(0)&&m?"#"===f.charAt(2)?3:2:1;g=f.substring(a,g).toLowerCase();"/"===f.charAt(f.length-2)||this.Utils.in_array(g,this.Utils.single_token)?c||(this.tag_type="SINGLE"):m&&"{"===f.charAt(0)&&
"else"===g?c||(this.indent_to_tag("if"),this.tag_type="HANDLEBARS_ELSE",this.indent_content=!0,this.traverse_whitespace()):this.is_unformatted(g,r)?(a=this.get_unformatted("\x3c/"+g+"\x3e",f),d.push(a),this.tag_type="SINGLE"):"script"===g&&(-1===f.search("type")||-1<f.search("type")&&-1<f.search(/\b(text|application)\/(x-)?(javascript|ecmascript|jscript|livescript)/))?c||(this.record_tag(g),this.tag_type="SCRIPT"):"style"===g&&(-1===f.search("type")||-1<f.search("type")&&-1<f.search("text/css"))?
c||(this.record_tag(g),this.tag_type="STYLE"):"!"===g.charAt(0)?c||(this.tag_type="SINGLE",this.traverse_whitespace()):c||("/"===g.charAt(0)?(this.retrieve_tag(g.substring(1)),this.tag_type="END"):(this.record_tag(g),"html"!==g.toLowerCase()&&(this.indent_content=!0),this.tag_type="START"),this.traverse_whitespace()&&this.space_or_wrap(d),this.Utils.in_array(g,this.Utils.extra_liners)&&(this.print_newline(!1,this.output),this.output.length&&"\n"!==this.output[this.output.length-2]&&this.print_newline(!0,
this.output)));c&&(this.pos=h,this.line_char_count=k);return d.join("")};this.get_comment=function(a){var b="",d="\x3e",e=!1;this.pos=a;input_char=this.input.charAt(this.pos);for(this.pos++;this.pos<=this.input.length;){b+=input_char;if(b.charAt(b.length-1)===d.charAt(d.length-1)&&-1!==b.indexOf(d))break;!e&&10>b.length&&(0===b.indexOf("\x3c![if")?(d="\x3c![endif]\x3e",e=!0):0===b.indexOf("\x3c![cdata[")?(d="]]\x3e",e=!0):0===b.indexOf("\x3c![")?(d="]\x3e",e=!0):0===b.indexOf("\x3c!--")?(d="--\x3e",
e=!0):0===b.indexOf("{{!")?(d="}}",e=!0):0===b.indexOf("\x3c?")?(d="?\x3e",e=!0):0===b.indexOf("\x3c%")&&(d="%\x3e",e=!0));input_char=this.input.charAt(this.pos);this.pos++}return b};this.get_unformatted=function(a,b){if(b&&-1!==b.toLowerCase().indexOf(a))return"";var d="",e="",h=0,f=!0;do{if(this.pos>=this.input.length)break;d=this.input.charAt(this.pos);this.pos++;if(this.Utils.in_array(d,this.Utils.whitespace)){if(!f){this.line_char_count--;continue}if("\n"===d||"\r"===d){e+="\n";this.line_char_count=
0;continue}}e+=d;this.line_char_count++;f=!0;m&&"{"===d&&e.length&&"{"===e.charAt(e.length-2)&&(e+=this.get_unformatted("}}"),h=e.length)}while(-1===e.toLowerCase().indexOf(a,h));return e};this.get_token=function(){var a;if("TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token){var b=this.last_token.substr(7);a=this.get_contents_to(b);return"string"!==typeof a?a:[a,"TK_"+b]}if("CONTENT"===this.current_mode)return a=this.get_content(),"string"!==typeof a?a:[a,"TK_CONTENT"];if("TAG"===
this.current_mode)return a=this.get_tag(),"string"!==typeof a?a:[a,"TK_TAG_"+this.tag_type]};this.get_full_indent=function(a){a=this.indent_level+a||0;return 1>a?"":Array(a+1).join(this.indent_string)};this.is_unformatted=function(a,b){if(!this.Utils.in_array(a,b))return!1;if("a"!==a.toLowerCase()||!this.Utils.in_array("a",b))return!0;var d=(this.get_tag(!0)||"").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);return!d||this.Utils.in_array(d,b)?!0:!1};this.printer=function(a,b,d,e,h){this.input=a||"";this.input=
this.input.replace(/\r\n|[\r\u2028\u2029]/g,"\n");this.output=[];this.indent_character=b;this.indent_string="";this.indent_size=d;this.brace_style=h;this.indent_level=0;this.wrap_line_length=e;for(a=this.line_char_count=0;a<this.indent_size;a++)this.indent_string+=this.indent_character;this.print_newline=function(a,b){this.line_char_count=0;b&&b.length&&(a||"\n"!==b[b.length-1])&&("\n"!==b[b.length-1]&&(b[b.length-1]=b[b.length-1].replace(/\s+$/g,"")),b.push("\n"))};this.print_indentation=function(a){for(var b=
0;b<this.indent_level;b++)a.push(this.indent_string),this.line_char_count+=this.indent_string.length};this.print_token=function(a){if(!this.is_whitespace(a)||this.output.length)(a||""!==a)&&this.output.length&&"\n"===this.output[this.output.length-1]&&(this.print_indentation(this.output),a=a.replace(/^\s+/g,"")),this.print_token_raw(a)};this.print_token_raw=function(a){0<this.newlines&&(a=a.replace(/\s+$/g,""));a&&""!==a&&(1<a.length&&"\n"===a.charAt(a.length-1)?(this.output.push(a.slice(0,-1)),this.print_newline(!1,
this.output)):this.output.push(a));for(a=0;a<this.newlines;a++)this.print_newline(0<a,this.output);this.newlines=0};this.indent=function(){this.indent_level++};this.unindent=function(){0<this.indent_level&&this.indent_level--}};return this};for(a.printer(e,p,k,h,q);;){e=a.get_token();a.token_text=e[0];a.token_type=e[1];if("TK_EOF"===a.token_type)break;switch(a.token_type){case "TK_TAG_START":a.print_newline(!1,a.output);a.print_token(a.token_text);a.indent_content&&(a.indent(),a.indent_content=!1);
a.current_mode="CONTENT";break;case "TK_TAG_STYLE":case "TK_TAG_SCRIPT":a.print_newline(!1,a.output);a.print_token(a.token_text);a.current_mode="CONTENT";break;case "TK_TAG_END":"TK_CONTENT"===a.last_token&&""===a.last_text&&(e=a.token_text.match(/\w+/)[0],k=null,a.output.length&&(k=a.output[a.output.length-1].match(/(?:<|{{#)\s*(\w+)/)),(null===k||k[1]!==e&&!a.Utils.in_array(k[1],r))&&a.print_newline(!1,a.output));a.print_token(a.token_text);a.current_mode="CONTENT";break;case "TK_TAG_SINGLE":(e=
a.token_text.match(/^\s*<([a-z-]+)/i))&&a.Utils.in_array(e[1],r)||a.print_newline(!1,a.output);a.print_token(a.token_text);a.current_mode="CONTENT";break;case "TK_TAG_HANDLEBARS_ELSE":a.print_token(a.token_text);a.indent_content&&(a.indent(),a.indent_content=!1);a.current_mode="CONTENT";break;case "TK_TAG_HANDLEBARS_COMMENT":a.print_token(a.token_text);a.current_mode="TAG";break;case "TK_CONTENT":a.print_token(a.token_text);a.current_mode="TAG";break;case "TK_STYLE":case "TK_SCRIPT":if(""!==a.token_text){a.print_newline(!1,
a.output);e=a.token_text;var t;h=1;"TK_SCRIPT"===a.token_type?t="function"===typeof l&&l:"TK_STYLE"===a.token_type&&(t="function"===typeof v&&v);"keep"===b.indent_scripts?h=0:"separate"===b.indent_scripts&&(h=-a.indent_level);k=a.get_full_indent(h);t?(h=function(){this.eol="\n"},h.prototype=b,h=new h,e=t(e.replace(/^\s*/,k),h)):(q=e.match(/^\s*/)[0].match(/[^\n\r]*$/)[0].split(a.indent_string).length-1,h=a.get_full_indent(h-q),e=e.replace(/^\s*/,k).replace(/\r\n|\r|\n/g,"\n"+h).replace(/\s+$/,""));
e&&(a.print_token_raw(e),a.print_newline(!0,a.output))}a.current_mode="TAG";break;default:""!==a.token_text&&a.print_token(a.token_text)}a.last_token=a.token_type;a.last_text=a.token_text}b=a.output.join("").replace(/[\r\n\t ]+$/,"");B&&(b+="\n");"\n"!=n&&(b=b.replace(/[\n]/g,n));return b}if("function"===typeof define&&define.amd)define(["require","./beautify","./beautify-css"],function(e){var b=e("./beautify"),u=e("./beautify-css");return{html_beautify:function(e,a){return l(e,a,b.js_beautify,u.css_beautify)}}});
else if("undefined"!==typeof exports){var u=require("./beautify.js"),E=require("./beautify-css.js");exports.html_beautify=function(e,b){return l(e,b,u.js_beautify,E.css_beautify)}}else"undefined"!==typeof window?window.html_beautify=function(e,b){return l(e,b,window.js_beautify,window.css_beautify)}:"undefined"!==typeof global&&(global.html_beautify=function(e,b){return l(e,b,global.js_beautify,global.css_beautify)})})();