On masque le menu des styles.
[ckeditor.git] / skins / ckeditor / plugins / codemirror / js / beautify.min.js
1 (function(){function n(n,i){"use strict";var r=new t(n,i);return r.beautify()}function t(n,t){"use strict";function ii(n,t){return{mode:t,last_text:n?n.last_text:"",last_word:n?n.last_word:"",var_line:!1,var_line_tainted:!1,var_line_reindented:!1,in_html_comment:!1,multiline_array:!1,if_block:!1,do_block:!1,do_while:!1,in_case_statement:!1,in_case:!1,case_body:!1,indentation_level:n?n.indentation_level+(n.var_line&&n.var_line_reindented?1:0):0,ternary_depth:0}}function ri(n){for(n=n===undefined?!1:n;h.length&&(h[h.length-1]===" "||h[h.length-1]===rt||h[h.length-1]===lt||n&&(h[h.length-1]==="\n"||h[h.length-1]==="\r"));)h.pop()}function kt(n){return n.replace(/^\s\s*|\s\s*$/,"")}function ei(n){n=n.replace(/\x0d/g,"");for(var i=[],t=n.indexOf("\n");t!==-1;)i.push(n.substring(0,t)),n=n.substring(t+1),t=n.indexOf("\n");return n.length&&i.push(n),i}function d(){return h.length&&h[h.length-1]==="\n"}function oi(){return d()&&h.length-1>0&&h[h.length-2]==="\n"}function si(n,t){var i=n.length-1;for(i<0&&(i+=n.length),i>n.length-1&&(i=n.length-1),i++;i-->0;)if(i in n&&n[i]===t)return i;return-1}function at(n){if(n=n===undefined?!1:n,u.wrap_line_length&&!n){var t="",i=0,r=si(h,"\n")+1;r<h.length&&(t=h.slice(r).join(""),i=t.length+c.length+(o?1:0),i>=u.wrap_line_length&&(n=!0))}(u.preserve_newlines&&k||n)&&!d()&&(s(!1,!0),st=!0,k=!1)}function s(n,t){if(st=!1,o=!1,!t&&i.last_text!==";")while(i.mode===l.Statement&&!i.if_block)et();(i.mode===l.ArrayLiteral&&(i.multiline_array=!0),h.length)&&(n||!d())&&h.push("\n")}function hi(){d()&&(u.keep_array_indentation&&nt(i.mode)&&ft.length?h.push(ft.join("")+""):(lt&&h.push(lt),dt(i.indentation_level),dt(i.var_line&&i.var_line_reindented),dt(st)))}function dt(n){if(n===undefined?n=1:typeof n!="number"&&(n=n?1:0),i.last_text!=="")for(var t=0;t<n;t+=1)h.push(rt)}function ci(){if(o&&h.length){var n=h[h.length-1];d()||n===" "||n===rt||h.push(" ")}}function a(n){n=n||c,hi(),st=!1,ci(),o=!1,h.push(n)}function vt(){i.indentation_level+=1}function g(n){i?(pt.push(i),w=i):w=ii(null,n),i=ii(w,n)}function nt(n){return n===l.ArrayLiteral}function yt(n){return v(n,[l.Expression,l.ForInitializer,l.Conditional])}function et(){pt.length>0&&(w=i,i=pt.pop())}function gt(){return i.last_text==="do"||i.last_text==="else"&&c!=="if"||f==="TK_END_EXPR"&&(w.mode===l.ForInitializer||w.mode===l.Conditional)?(at(),g(l.Statement),vt(),st=!1,!0):!1}function li(n,t){for(var r,i=0;i<n.length;i++)if(r=kt(n[i]),r.charAt(0)!==t)return!1;return!0}function ht(n){return v(n,["case","return","do","if","throw","else"])}function v(n,t){for(var i=0;i<t.length;i+=1)if(t[i]===n)return!0;return!1}function ai(n){for(var e=!1,u="",r=0,f="",t=0,i;e||r<n.length;)if(i=n.charAt(r),r++,e){if(e=!1,i==="x")f=n.substr(r,2),r+=2;else if(i==="u")f=n.substr(r,4),r+=4;else{u+="\\"+i;continue}if(!f.match(/^[0123456789abcdefABCDEF]+$/))return n;if(t=parseInt(f,16),t>=0&&t<32){u+=i==="x"?"\\x"+f:"\\u"+f;continue}else if(t===34||t===39||t===92)u+="\\"+String.fromCharCode(t);else{if(i==="x"&&t>126&&t<=255)return n;u+=String.fromCharCode(t)}}else i==="\\"?e=!0:u+=i;return u}function ui(n){for(var t=r,i=e.charAt(t);v(i,bt)&&i!==n;){if(t++,t>=y)return!1;i=e.charAt(t)}return i===n}function fi(){var t,n,ut,et,c,tt,d,lt,nt,it,p;if(b=0,r>=y)return["","TK_EOF"];for(k=!1,ft=[],n=e.charAt(r),r+=1;v(n,bt);){if(n==="\n"?(b+=1,ft=[]):b&&(n===rt?ft.push(rt):n!=="\r"&&ft.push(" ")),r>=y)return["","TK_EOF"];n=e.charAt(r),r+=1}if(v(n,wt)){if(r<y)while(v(e.charAt(r),wt))if(n+=e.charAt(r),r+=1,r===y)break;return r!==y&&n.match(/^[0-9]+[Ee]$/)&&(e.charAt(r)==="-"||e.charAt(r)==="+")?(ut=e.charAt(r),r+=1,et=fi(),n+=ut+et[0],[n,"TK_WORD"]):n==="in"?[n,"TK_OPERATOR"]:[n,"TK_WORD"]}if(n==="("||n==="[")return[n,"TK_START_EXPR"];if(n===")"||n==="]")return[n,"TK_END_EXPR"];if(n==="{")return[n,"TK_START_BLOCK"];if(n==="}")return[n,"TK_END_BLOCK"];if(n===";")return[n,"TK_SEMICOLON"];if(n==="/"){if(c="",tt=!0,e.charAt(r)==="*"){if(r+=1,r<y)while(r<y&&!(e.charAt(r)==="*"&&e.charAt(r+1)&&e.charAt(r+1)==="/"))if(n=e.charAt(r),c+=n,(n==="\n"||n==="\r")&&(tt=!1),r+=1,r>=y)break;return r+=2,tt&&b===0?["/*"+c+"*/","TK_INLINE_COMMENT"]:["/*"+c+"*/","TK_BLOCK_COMMENT"]}if(e.charAt(r)==="/"){for(c=n;e.charAt(r)!=="\r"&&e.charAt(r)!=="\n";)if(c+=e.charAt(r),r+=1,r>=y)break;return[c,"TK_COMMENT"]}}if(n==="'"||n==='"'||(n==="/"||u.e4x&&n==="<"&&e.slice(r-1).match(/^<[a-zA-Z:0-9]+\s*([a-zA-Z:0-9]+="[^"]*"\s*)*\/?\s*>/))&&(f==="TK_WORD"&&ht(i.last_text)||f==="TK_END_EXPR"&&v(w.mode,[l.Conditional,l.ForInitializer])||v(f,["TK_COMMENT","TK_START_EXPR","TK_START_BLOCK","TK_END_BLOCK","TK_OPERATOR","TK_EQUALS","TK_EOF","TK_SEMICOLON","TK_COMMA"]))){var a=n,s=!1,st=!1;if(t=n,r<y)if(a==="/"){for(d=!1;s||d||e.charAt(r)!==a;)if(t+=e.charAt(r),s?s=!1:(s=e.charAt(r)==="\\",e.charAt(r)==="["?d=!0:e.charAt(r)==="]"&&(d=!1)),r+=1,r>=y)return[t,"TK_STRING"]}else if(u.e4x&&a==="<"){var ct=/<(\/?)([a-zA-Z:0-9]+)\s*([a-zA-Z:0-9]+="[^"]*"\s*)*(\/?)\s*>/g,g=e.slice(r-1),o=ct.exec(g);if(o&&o.index===0){for(lt=o[2],nt=0;o;){var at=!!o[1],vt=o[2],yt=!!o[o.length-1];if(vt!==lt||yt||(at?--nt:++nt),nt<=0)break;o=ct.exec(g)}return it=o?o.index+o[0].length:g.length,r+=it-1,[g.slice(0,it),"TK_STRING"]}}else while(s||e.charAt(r)!==a)if(t+=e.charAt(r),s?((e.charAt(r)==="x"||e.charAt(r)==="u")&&(st=!0),s=!1):s=e.charAt(r)==="\\",r+=1,r>=y)return[t,"TK_STRING"];if(r+=1,t+=a,st&&u.unescape_strings&&(t=ai(t)),a==="/")while(r<y&&v(e.charAt(r),wt))t+=e.charAt(r),r+=1;return[t,"TK_STRING"]}if(n==="#"){if(h.length===0&&e.charAt(r)==="!"){for(t=n;r<y&&n!=="\n";)n=e.charAt(r),t+=n,r+=1;return[kt(t)+"\n","TK_UNKNOWN"]}if(p="#",r<y&&v(e.charAt(r),ni)){do n=e.charAt(r),p+=n,r+=1;while(r<y&&n!=="#"&&n!=="=");return n==="#"||(e.charAt(r)==="["&&e.charAt(r+1)==="]"?(p+="[]",r+=2):e.charAt(r)==="{"&&e.charAt(r+1)==="}"&&(p+="{}",r+=2)),[p,"TK_WORD"]}}if(n==="<"&&e.substring(r-1,r+3)==="<!--"){for(r+=3,n="<!--";e.charAt(r)!=="\n"&&r<y;)n+=e.charAt(r),r++;return i.in_html_comment=!0,[n,"TK_COMMENT"]}if(n==="-"&&i.in_html_comment&&e.substring(r-1,r+2)==="-->")return i.in_html_comment=!1,r+=2,["-->","TK_COMMENT"];if(n===".")return[n,"TK_DOT"];if(v(n,ot)){while(r<y&&v(n+e.charAt(r),ot))if(n+=e.charAt(r),r+=1,r>=y)break;return n===","?[n,"TK_COMMA"]:n==="="?[n,"TK_EQUALS"]:[n,"TK_OPERATOR"]}return[n,"TK_UNKNOWN"]}function vi(){if(gt(),c==="["){if(f==="TK_WORD"||i.last_text===")"){v(i.last_text,ut)&&(o=!0),g(l.Expression),a(),u.space_in_paren&&(o=!0);return}nt(i.mode)&&(i.last_text==="["||i.last_text===","&&(it==="]"||it==="}"))&&(u.keep_array_indentation||s())}else i.last_text==="for"?g(l.ForInitializer):v(i.last_text,["if","while"])?g(l.Conditional):g(l.Expression);i.last_text===";"||f==="TK_START_BLOCK"?s():f==="TK_END_EXPR"||f==="TK_START_EXPR"||f==="TK_END_BLOCK"||i.last_text==="."?k&&s():f!=="TK_WORD"&&f!=="TK_OPERATOR"?o=!0:i.last_word==="function"||i.last_word==="typeof"?u.jslint_happy&&(o=!0):(v(i.last_text,ut)||i.last_text==="catch")&&u.space_before_conditional&&(o=!0),c==="("&&(f==="TK_EQUALS"||f==="TK_OPERATOR")&&i.mode!==l.ObjectLiteral&&at(),a(),u.space_in_paren&&(o=!0),c==="["&&(g(l.ArrayLiteral),vt()),ct&&(ct=!1,vt())}function yi(){while(i.mode===l.Statement)et();c==="]"&&nt(i.mode)&&i.multiline_array&&!u.keep_array_indentation&&s(),et(),u.space_in_paren&&(o=!0),a(),i.do_while&&w.mode===l.Conditional&&(w.mode=l.Expression,i.do_block=!1,i.do_while=!1)}function pi(){g(l.BlockStatement);var n=ui("}"),t=n&&i.last_word==="function"&&f==="TK_END_EXPR";u.brace_style==="expand"?f!=="TK_OPERATOR"&&(t||f==="TK_EQUALS"||ht(i.last_text)&&i.last_text!=="else")?o=!0:s():f!=="TK_OPERATOR"&&f!=="TK_START_EXPR"?f==="TK_START_BLOCK"?s():o=!0:nt(w.mode)&&i.last_text===","&&(it==="}"?o=!0:s()),a(),vt()}function wi(){while(i.mode===l.Statement)et();et();var n=f==="TK_START_BLOCK";u.brace_style==="expand"?n||s():n||(nt(i.mode)&&u.keep_array_indentation?(u.keep_array_indentation=!1,s(),u.keep_array_indentation=!0):s()),a()}function bi(){if(gt()||k&&!yt(i.mode)&&(f!=="TK_OPERATOR"||i.last_text==="--"||i.last_text==="++")&&f!=="TK_EQUALS"&&(u.preserve_newlines||i.last_text!=="var")&&s(),i.do_block&&!i.do_while){if(c==="while"){o=!0,a(),o=!0,i.do_while=!0;return}s(),i.do_block=!1}if(ct&&ht(c)&&(ct=!1),i.if_block&&c!=="else"){while(i.mode===l.Statement)et();i.if_block=!1}if(c==="function"){i.var_line&&f!=="TK_EQUALS"&&(i.var_line_reindented=!0),(d()||i.last_text===";"||i.last_text==="}")&&i.last_text!=="{"&&!nt(i.mode)&&(d()||s(!0),oi()||s(!0)),f==="TK_WORD"?i.last_text==="get"||i.last_text==="set"||i.last_text==="new"||i.last_text==="return"?o=!0:s():f==="TK_OPERATOR"||i.last_text==="="?o=!0:yt(i.mode)||s(),a(),i.last_word=c;return}if(c==="case"||c==="default"&&i.in_case_statement){s(),(i.case_body||u.jslint_happy)&&(i.indentation_level--,i.case_body=!1),a(),i.in_case=!0,i.in_case_statement=!0;return}p="NONE",f==="TK_END_BLOCK"?v(c,["else","catch","finally"])?u.brace_style==="expand"||u.brace_style==="end-expand"?p="NEWLINE":(p="SPACE",o=!0):p="NEWLINE":f==="TK_SEMICOLON"&&i.mode===l.BlockStatement?p="NEWLINE":f==="TK_SEMICOLON"&&yt(i.mode)?p="SPACE":f==="TK_STRING"?p="NEWLINE":f==="TK_WORD"?p="SPACE":f==="TK_START_BLOCK"?p="NEWLINE":f==="TK_END_EXPR"&&(o=!0,p="NEWLINE"),v(c,ut)&&i.last_text!==")"&&(p=i.last_text==="else"?"SPACE":"NEWLINE"),(f==="TK_COMMA"||f==="TK_START_EXPR"||f==="TK_EQUALS"||f==="TK_OPERATOR")&&i.mode!==l.ObjectLiteral&&at(),v(c,["else","catch","finally"])?f!=="TK_END_BLOCK"||u.brace_style==="expand"||u.brace_style==="end-expand"?s():(ri(!0),h[h.length-1]!=="}"&&s(),o=!0):p==="NEWLINE"?ht(i.last_text)?o=!0:f!=="TK_END_EXPR"?(f!=="TK_START_EXPR"||c!=="var")&&i.last_text!==":"&&(c==="if"&&i.last_word==="else"&&i.last_text!=="{"?o=!0:(i.var_line=!1,i.var_line_reindented=!1,s())):v(c,ut)&&i.last_text!==")"&&(i.var_line=!1,i.var_line_reindented=!1,s()):nt(i.mode)&&i.last_text===","&&it==="}"?s():p==="SPACE"&&(o=!0),a(),i.last_word=c,c==="var"&&(i.var_line=!0,i.var_line_reindented=!1,i.var_line_tainted=!1),c==="do"&&(i.do_block=!0),c==="if"&&(i.if_block=!0)}function ki(){while(i.mode===l.Statement&&!i.if_block)et();a(),i.var_line=!1,i.var_line_reindented=!1,i.mode===l.ObjectLiteral&&(i.mode=l.BlockStatement)}function di(){gt()?o=!0:f==="TK_WORD"?o=!0:f==="TK_COMMA"||f==="TK_START_EXPR"||f==="TK_EQUALS"||f==="TK_OPERATOR"?i.mode!==l.ObjectLiteral&&at():s(),a()}function gi(){i.var_line&&(i.var_line_tainted=!0),o=!0,a(),o=!0}function nr(){if(i.var_line){(yt(i.mode)||f==="TK_END_BLOCK")&&(i.var_line_tainted=!1),i.var_line&&(i.var_line_reindented=!0),a(),i.var_line_tainted?(i.var_line_tainted=!1,s()):o=!0;return}f==="TK_END_BLOCK"&&i.mode!==l.Expression?(a(),i.mode===l.ObjectLiteral&&i.last_text==="}"?s():o=!0):i.mode===l.ObjectLiteral?(a(),s()):(a(),o=!0)}function tr(){var n=!0,t=!0;if(ht(i.last_text)){o=!0,a();return}if(c==="*"&&f==="TK_DOT"&&!it.match(/^\d+$/)){a();return}if(c===":"&&i.in_case){i.case_body=!0,vt(),a(),s(),i.in_case=!1;return}if(c==="::"){a();return}k&&(c==="--"||c==="++")&&s(),v(c,["--","++","!"])||v(c,["-","+"])&&(v(f,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||v(i.last_text,ut)||i.last_text===",")?(n=!1,t=!1,i.last_text===";"&&yt(i.mode)&&(n=!0),f==="TK_WORD"&&v(i.last_text,ut)&&(n=!0),(i.mode===l.BlockStatement||i.mode===l.Statement)&&(i.last_text==="{"||i.last_text===";")&&s()):c===":"?i.ternary_depth===0?(i.mode===l.BlockStatement&&(i.mode=l.ObjectLiteral),n=!1):i.ternary_depth-=1:c==="?"&&(i.ternary_depth+=1),o=o||n,a(),o=t}function ir(){var n=ei(c),t;if(li(n.slice(1),"*"))for(s(!1,!0),a(n[0]),t=1;t<n.length;t++)s(!1,!0),a(" "+kt(n[t]));else for(n.length>1?s(!1,!0):f==="TK_END_BLOCK"?s(!1,!0):o=!0,a(n[0]),h.push("\n"),t=1;t<n.length;t++)h.push(n[t]),h.push("\n");ui("\n")||s(!1,!0)}function rr(){o=!0,a(),o=!0}function ur(){k?s(!1,!0):ri(!0),o=!0,a(),s(!1,!0)}function fr(){ht(i.last_text)?o=!0:at(i.last_text===")"&&u.break_chained_methods),d()&&(ct=!0),a()}function er(){a(),c[c.length-1]==="\n"&&s()}var e,h,c,tt,f,it,rt,i,w,pt,bt,wt,ot,r,ut,ni,p,ct,k,st,o,y,b,ft,ti,l,u,lt="";for(bt="\n\r\t ".split(""),wt="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$".split(""),ni="0123456789".split(""),ot="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::",ot+=" <%= <% %> <?= <? ?>",ot=ot.split(" "),ut="continue,try,throw,return,var,if,switch,case,default,for,while,break,function".split(","),l={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"},ti={TK_START_EXPR:vi,TK_END_EXPR:yi,TK_START_BLOCK:pi,TK_END_BLOCK:wi,TK_WORD:bi,TK_SEMICOLON:ki,TK_STRING:di,TK_EQUALS:gi,TK_OPERATOR:tr,TK_COMMA:nr,TK_BLOCK_COMMENT:ir,TK_INLINE_COMMENT:rr,TK_COMMENT:ur,TK_DOT:fr,TK_UNKNOWN:er},t=t?t:{},u={},t.space_after_anon_function!==undefined&&t.jslint_happy===undefined&&(t.jslint_happy=t.space_after_anon_function),t.braces_on_own_line!==undefined&&(u.brace_style=t.braces_on_own_line?"expand":"collapse"),u.brace_style=t.brace_style?t.brace_style:u.brace_style?u.brace_style:"collapse",u.brace_style==="expand-strict"&&(u.brace_style="expand"),u.indent_size=t.indent_size?parseInt(t.indent_size,10):4,u.indent_char=t.indent_char?t.indent_char:" ",u.preserve_newlines=t.preserve_newlines===undefined?!0:t.preserve_newlines,u.break_chained_methods=t.break_chained_methods===undefined?!1:t.break_chained_methods,u.max_preserve_newlines=t.max_preserve_newlines===undefined?0:parseInt(t.max_preserve_newlines,10),u.space_in_paren=t.space_in_paren===undefined?!1:t.space_in_paren,u.jslint_happy=t.jslint_happy===undefined?!1:t.jslint_happy,u.keep_array_indentation=t.keep_array_indentation===undefined?!1:t.keep_array_indentation,u.space_before_conditional=t.space_before_conditional===undefined?!0:t.space_before_conditional,u.unescape_strings=t.unescape_strings===undefined?!1:t.unescape_strings,u.wrap_line_length=t.wrap_line_length===undefined?0:parseInt(t.wrap_line_length,10),u.e4x=t.e4x===undefined?!1:t.e4x,rt="";u.indent_size>0;)rt+=u.indent_char,u.indent_size-=1;while(n&&(n.charAt(0)===" "||n.charAt(0)==="\t"))lt+=n.charAt(0),n=n.substring(1);e=n,y=n.length,f="TK_START_BLOCK",it="",h=[],st=!1,o=!1,ft=[],pt=[],g(l.BlockStatement),r=0,this.beautify=function(){for(var t,n,r;;){if(t=fi(),c=t[0],tt=t[1],tt==="TK_EOF")break;if(r=u.keep_array_indentation&&nt(i.mode),r)for(n=0;n<b;n+=1)s(!0);else if(k=b>0,u.max_preserve_newlines&&b>u.max_preserve_newlines&&(b=u.max_preserve_newlines),u.preserve_newlines&&b>1)for(s(),n=1;n<b;n+=1)s(!0);ti[tt](),tt!=="TK_INLINE_COMMENT"&&tt!=="TK_COMMENT"&&tt!=="TK_UNKNOWN"&&(it=i.last_text,f=tt,i.last_text=c)}return lt+h.join("").replace(/[\r\n ]+$/,"")}}typeof define=="function"?define(function(t,i){i.js_beautify=n}):typeof exports!="undefined"?exports.js_beautify=n:typeof window!="undefined"?window.js_beautify=n:typeof global!="undefined"&&(global.js_beautify=n)})(),function(){function n(n,t,i,r){function k(){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\t ".split(""),single_token:"br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?=".split(","),extra_liners:"head,body,/html".split(","),in_array:function(n,t){for(var i=0;i<t.length;i++)if(n===t[i])return!0;return!1}},this.get_content=function(){for(var t="",n=[],i=!1,r;this.input.charAt(this.pos)!=="<";){if(this.pos>=this.input.length)return n.length?n.join(""):["","TK_EOF"];if(t=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(t,this.Utils.whitespace)){n.length&&(i=!0),this.line_char_count--;continue}else if(i){if(this.line_char_count>=this.max_char){for(n.push("\n"),r=0;r<this.indent_level;r++)n.push(this.indent_string);this.line_char_count=0}else n.push(" "),this.line_char_count++;i=!1}n.push(t)}return n.length?n.join(""):""},this.get_contents_to=function(n){var i,t;if(this.pos===this.input.length)return["","TK_EOF"];var r="",u=new RegExp("<\/"+n+"\\s*>","igm");return u.lastIndex=this.pos,i=u.exec(this.input),t=i?i.index:this.input.length,this.pos<t&&(r=this.input.substring(this.pos,t),this.pos=t),r},this.record_tag=function(n){this.tags[n+"count"]?(this.tags[n+"count"]++,this.tags[n+this.tags[n+"count"]]=this.indent_level):(this.tags[n+"count"]=1,this.tags[n+this.tags[n+"count"]]=this.indent_level),this.tags[n+this.tags[n+"count"]+"parent"]=this.tags.parent,this.tags.parent=n+this.tags[n+"count"]},this.retrieve_tag=function(n){if(this.tags[n+"count"]){for(var t=this.tags.parent;t;){if(n+this.tags[n+"count"]===t)break;t=this.tags[t+"parent"]}t&&(this.indent_level=this.tags[n+this.tags[n+"count"]],this.tags.parent=this.tags[t+"parent"]),delete this.tags[n+this.tags[n+"count"]+"parent"],delete this.tags[n+this.tags[n+"count"]],this.tags[n+"count"]===1?delete this.tags[n+"count"]:this.tags[n+"count"]--}},this.get_tag=function(n){var u="",t=[],f="",e=!1,o,h,c=this.pos,l=this.line_char_count,r,a,i;n=n!==undefined?n:!1;do{if(this.pos>=this.input.length)return n&&(this.pos=c,this.line_char_count=l),t.length?t.join(""):["","TK_EOF"];if(u=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(u,this.Utils.whitespace)){e=!0,this.line_char_count--;continue}(u==="'"||u==='"')&&(t[1]&&t[1]==="!"||(u+=this.get_unformatted(u),e=!0)),u==="="&&(e=!1),t.length&&t[t.length-1]!=="="&&u!==">"&&e&&(this.line_char_count>=this.max_char?(this.print_newline(!1,t),this.line_char_count=0):(t.push(" "),this.line_char_count++),e=!1),u==="<"&&(o=this.pos-1),t.push(u)}while(u!==">");return r=t.join(""),a=r.indexOf(" ")!==-1?r.indexOf(" "):r.indexOf(">"),i=r.substring(1,a).toLowerCase(),r.charAt(r.length-2)==="/"||this.Utils.in_array(i,this.Utils.single_token)?n||(this.tag_type="SINGLE"):i==="script"?n||(this.record_tag(i),this.tag_type="SCRIPT"):i==="style"?n||(this.record_tag(i),this.tag_type="STYLE"):this.is_unformatted(i,s)?(f=this.get_unformatted("<\/"+i+">",r),t.push(f),o>0&&this.Utils.in_array(this.input.charAt(o-1),this.Utils.whitespace)&&t.splice(0,0,this.input.charAt(o-1)),h=this.pos-1,this.Utils.in_array(this.input.charAt(h+1),this.Utils.whitespace)&&t.push(this.input.charAt(h+1)),this.tag_type="SINGLE"):i.charAt(0)==="!"?i.indexOf("[if")!==-1?(r.indexOf("!IE")!==-1&&(f=this.get_unformatted("-->",r),t.push(f)),n||(this.tag_type="START")):i.indexOf("[endif")!==-1?(this.tag_type="END",this.unindent()):i.indexOf("[cdata[")!==-1?(f=this.get_unformatted("]\]>",r),t.push(f),n||(this.tag_type="SINGLE")):(f=this.get_unformatted("-->",r),t.push(f),this.tag_type="SINGLE"):n||(i.charAt(0)==="/"?(this.retrieve_tag(i.substring(1)),this.tag_type="END"):(this.record_tag(i),this.tag_type="START"),this.Utils.in_array(i,this.Utils.extra_liners)&&this.print_newline(!0,this.output)),n&&(this.pos=c,this.line_char_count=l),t.join("")},this.get_unformatted=function(n,t){if(t&&t.toLowerCase().indexOf(n)!==-1)return"";var i="",r="",u=!0;do{if(this.pos>=this.input.length)return r;if(i=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(i,this.Utils.whitespace)){if(!u){this.line_char_count--;continue}if(i==="\n"||i==="\r"){r+="\n",this.line_char_count=0;continue}}r+=i,this.line_char_count++,u=!0}while(r.toLowerCase().indexOf(n)===-1);return r},this.get_token=function(){var n,t,i;return this.last_token==="TK_TAG_SCRIPT"||this.last_token==="TK_TAG_STYLE"?(t=this.last_token.substr(7),n=this.get_contents_to(t),typeof n!="string")?n:[n,"TK_"+t]:this.current_mode==="CONTENT"?(n=this.get_content(),typeof n!="string"?n:[n,"TK_CONTENT"]):this.current_mode==="TAG"?(n=this.get_tag(),typeof n!="string"?n:(i="TK_TAG_"+this.tag_type,[n,i])):void 0},this.get_full_indent=function(n){return(n=this.indent_level+n||0,n<1)?"":Array(n+1).join(this.indent_string)},this.is_unformatted=function(n,t){if(!this.Utils.in_array(n,t))return!1;if(n.toLowerCase()!=="a"||!this.Utils.in_array("a",t))return!0;var r=this.get_tag(!0),i=(r||"").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);return!i||this.Utils.in_array(i,t)?!0:!1},this.printer=function(n,t,i,r,u){this.input=n||"",this.output=[],this.indent_character=t,this.indent_string="",this.indent_size=i,this.brace_style=u,this.indent_level=0,this.max_char=r,this.line_char_count=0;for(var f=0;f<this.indent_size;f++)this.indent_string+=this.indent_character;this.print_newline=function(n,t){if(this.line_char_count=0,t&&t.length){if(!n)while(this.Utils.in_array(t[t.length-1],this.Utils.whitespace))t.pop();t.push("\n");for(var i=0;i<this.indent_level;i++)t.push(this.indent_string)}},this.print_token=function(n){this.output.push(n)},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var u,v,y,p,w,s,h,b,c,l,f,o,e,a;for(t=t||{},v=t.indent_size||4,y=t.indent_char||" ",w=t.brace_style||"collapse",p=t.max_char===0?Infinity:t.max_char||250,s=t.unformatted||["a","span","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"],u=new k,u.printer(n,y,v,p,w);;){if(h=u.get_token(),u.token_text=h[0],u.token_type=h[1],u.token_type==="TK_EOF")break;switch(u.token_type){case"TK_TAG_START":u.print_newline(!1,u.output),u.print_token(u.token_text),u.indent(),u.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":u.print_newline(!1,u.output),u.print_token(u.token_text),u.current_mode="CONTENT";break;case"TK_TAG_END":u.last_token==="TK_CONTENT"&&u.last_text===""&&(b=u.token_text.match(/\w+/)[0],c=u.output[u.output.length-1].match(/<\s*(\w+)/),(c===null||c[1]!==b)&&u.print_newline(!0,u.output)),u.print_token(u.token_text),u.current_mode="CONTENT";break;case"TK_TAG_SINGLE":l=u.token_text.match(/^\s*<([a-z]+)/i),l&&u.Utils.in_array(l[1],s)||u.print_newline(!1,u.output),u.print_token(u.token_text),u.current_mode="CONTENT";break;case"TK_CONTENT":u.token_text!==""&&u.print_token(u.token_text),u.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(u.token_text!==""){if(u.output.push("\n"),f=u.token_text,e=1,u.token_type==="TK_SCRIPT"?o=typeof i=="function"&&i:u.token_type==="TK_STYLE"&&(o=typeof r=="function"&&r),t.indent_scripts==="keep"?e=0:t.indent_scripts==="separate"&&(e=-u.indent_level),a=u.get_full_indent(e),o)f=o(f.replace(/^\s*/,a),t);else{var d=f.match(/^\s*/)[0],g=d.match(/[^\n\r]*$/)[0].split(u.indent_string).length-1,nt=u.get_full_indent(e-g);f=f.replace(/^\s*/,a).replace(/\r\n|\r|\n/g,"\n"+nt).replace(/\s*$/,"")}f&&(u.print_token(f),u.print_newline(!0,u.output))}u.current_mode="TAG"}u.last_token=u.token_type,u.last_text=u.token_text}return u.output.join("")}if(typeof define=="function")define(function(t,i){var r=t("./beautify.js").js_beautify,u=t("./beautify-css.js").css_beautify;i.html_beautify=function(t,i){return n(t,i,r,u)}});else if(typeof exports!="undefined"){var t=require("./beautify.js").js_beautify,i=require("./beautify-css.js").css_beautify;exports.html_beautify=function(r,u){return n(r,u,t,i)}}else typeof window!="undefined"?window.html_beautify=function(t,i){return n(t,i,window.js_beautify,window.css_beautify)}:typeof global!="undefined"&&(global.html_beautify=function(t,i){return n(t,i,global.js_beautify,global.css_beautify)})}()