diff --git a/lib/editor/atto/plugins/html/thirdpartylibs.xml b/lib/editor/atto/plugins/html/thirdpartylibs.xml index c5c62d3729d74..80e7baaacef38 100644 --- a/lib/editor/atto/plugins/html/thirdpartylibs.xml +++ b/lib/editor/atto/plugins/html/thirdpartylibs.xml @@ -12,7 +12,7 @@ yui/src/beautify jsbeautify Beautify HTML code in Atto. - 1.14.0 + 1.14.6 MIT https://github.com/beautify-web/js-beautify diff --git a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-debug.js b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-debug.js index 9db40eb0564e7..8c0e70977d2bd 100644 --- a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-debug.js +++ b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-debug.js @@ -143,8 +143,8 @@ var legacy_beautify_js; -var Beautifier = __webpack_require__(1).Beautifier, - Options = __webpack_require__(5).Options; +var Beautifier = (__webpack_require__(1).Beautifier), + Options = (__webpack_require__(5).Options); function js_beautify(js_source_text, options) { var beautifier = new Beautifier(js_source_text, options); @@ -191,14 +191,14 @@ module.exports.defaultOptions = function() { -var Output = __webpack_require__(2).Output; -var Token = __webpack_require__(3).Token; +var Output = (__webpack_require__(2).Output); +var Token = (__webpack_require__(3).Token); var acorn = __webpack_require__(4); -var Options = __webpack_require__(5).Options; -var Tokenizer = __webpack_require__(7).Tokenizer; -var line_starters = __webpack_require__(7).line_starters; -var positionable_operators = __webpack_require__(7).positionable_operators; -var TOKEN = __webpack_require__(7).TOKEN; +var Options = (__webpack_require__(5).Options); +var Tokenizer = (__webpack_require__(7).Tokenizer); +var line_starters = (__webpack_require__(7).line_starters); +var positionable_operators = (__webpack_require__(7).positionable_operators); +var TOKEN = (__webpack_require__(7).TOKEN); function in_array(what, arr) { @@ -348,12 +348,14 @@ Beautifier.prototype.create_flags = function(flags_base, mode) { inline_frame: false, if_block: false, else_block: false, + class_start_block: false, // class A { INSIDE HERE } or class B extends C { INSIDE HERE } do_block: false, do_while: false, import_block: false, in_case_statement: false, // switch(..){ INSIDE HERE } in_case: false, // we're on the exact line with "case 0:" case_body: false, // the indented case-action block + case_block: false, // the indented case-action block is wrapped with {} indentation_level: next_indent_level, alignment: 0, line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level, @@ -759,6 +761,8 @@ Beautifier.prototype.handle_start_expr = function(current_token) { (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) { this._output.space_before_token = true; } + } else if (this._flags.parent && this._flags.parent.class_start_block) { + this._output.space_before_token = true; } } } else { @@ -853,10 +857,10 @@ Beautifier.prototype.handle_start_block = function(current_token) { )) { // We don't support TypeScript,but we didn't break it for a very long time. // We'll try to keep not breaking it. - if (!in_array(this._last_last_text, ['class', 'interface'])) { - this.set_mode(MODE.ObjectLiteral); - } else { + if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) { this.set_mode(MODE.BlockStatement); + } else { + this.set_mode(MODE.ObjectLiteral); } } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') { // arrow function: (param1, paramN) => { statements } @@ -873,6 +877,12 @@ Beautifier.prototype.handle_start_block = function(current_token) { this.set_mode(MODE.BlockStatement); } + if (this._flags.last_token) { + if (reserved_array(this._flags.last_token.previous, ['class', 'extends'])) { + this._flags.class_start_block = true; + } + } + var empty_braces = !next_token.comments_before && next_token.text === '}'; var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' && this._flags.last_token.type === TOKEN.END_EXPR; @@ -972,7 +982,7 @@ Beautifier.prototype.handle_word = function(current_token) { if (current_token.type === TOKEN.RESERVED) { if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) { current_token.type = TOKEN.WORD; - } else if (current_token.text === 'import' && this._tokens.peek().text === '(') { + } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) { current_token.type = TOKEN.WORD; } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) { current_token.type = TOKEN.WORD; @@ -1032,7 +1042,7 @@ Beautifier.prototype.handle_word = function(current_token) { if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) { this.print_newline(); - if (this._flags.last_token.type !== TOKEN.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) { + if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) { // switch cases following one another this.deindent(); } @@ -1313,13 +1323,6 @@ Beautifier.prototype.handle_operator = function(current_token) { this.handle_whitespace_and_comments(current_token, preserve_statement_flags); } - if (reserved_array(this._flags.last_token, special_words)) { - // "return" had a special handling in TK_WORD. Now we need to return the favor - this._output.space_before_token = true; - this.print_token(current_token); - return; - } - // hack for actionscript's import .*; if (current_token.text === '*' && this._flags.last_token.type === TOKEN.DOT) { this.print_token(current_token); @@ -1346,7 +1349,9 @@ Beautifier.prototype.handle_operator = function(current_token) { if (this._tokens.peek().type !== TOKEN.START_BLOCK) { this.indent(); this.print_newline(); + this._flags.case_block = false; } else { + this._flags.case_block = true; this._output.space_before_token = true; } return; @@ -1444,8 +1449,12 @@ Beautifier.prototype.handle_operator = function(current_token) { // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1 // if there is a newline between -- or ++ and anything else we should preserve it. - if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) { - this.print_newline(false, true); + if (current_token.newlines && (current_token.text === '--' || current_token.text === '++' || current_token.text === '~')) { + var new_line_needed = reserved_array(this._flags.last_token, special_words) && current_token.newlines; + if (new_line_needed && (this._previous_flags.if_block || this._previous_flags.else_block)) { + this.restore_mode(); + } + this.print_newline(new_line_needed, true); } if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) { @@ -1585,6 +1594,10 @@ Beautifier.prototype.handle_dot = function(current_token) { this.handle_whitespace_and_comments(current_token, true); } + if (this._flags.last_token.text.match('^[0-9]+$')) { + this._output.space_before_token = true; + } + if (reserved_array(this._flags.last_token, special_words)) { this._output.space_before_token = false; } else { @@ -2204,7 +2217,7 @@ exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline']; @@ -2502,13 +2515,13 @@ module.exports.mergeOpts = _mergeOpts; -var InputScanner = __webpack_require__(8).InputScanner; -var BaseTokenizer = __webpack_require__(9).Tokenizer; -var BASETOKEN = __webpack_require__(9).TOKEN; -var Directives = __webpack_require__(13).Directives; +var InputScanner = (__webpack_require__(8).InputScanner); +var BaseTokenizer = (__webpack_require__(9).Tokenizer); +var BASETOKEN = (__webpack_require__(9).TOKEN); +var Directives = (__webpack_require__(13).Directives); var acorn = __webpack_require__(4); -var Pattern = __webpack_require__(12).Pattern; -var TemplatablePattern = __webpack_require__(14).TemplatablePattern; +var Pattern = (__webpack_require__(12).Pattern); +var TemplatablePattern = (__webpack_require__(14).TemplatablePattern); function in_array(what, arr) { @@ -2548,7 +2561,7 @@ var digit = /[0-9]/; var dot_pattern = /[^\d\.]/; var positionable_operators = ( - ">>> === !== " + + ">>> === !== &&= ??= ||= " + "<< && >= ** != == <= >> || ?? |> " + "< / - + > : & % ? ^ | *").split(' '); @@ -2556,7 +2569,7 @@ var positionable_operators = ( // Also, you must update possitionable operators separately from punct var punct = ">>>= " + - "... >>= <<= === >>> !== **= " + + "... >>= <<= === >>> !== **= &&= ??= ||= " + "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " + "= ! ? > < : / ^ - + * & % ~ |"; @@ -2569,7 +2582,7 @@ var punct_pattern = new RegExp(punct); // words which should always start on new line. var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(','); -var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']); +var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as', 'class', 'extends']); var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$'); // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g; @@ -2600,7 +2613,7 @@ var Tokenizer = function(input_string, options) { html_comment_end: pattern_reader.matching(/-->/), include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak), shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak), - xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\]|)(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), + xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/), single_quote: templatable.until(/['\\\n\r\u2028\u2029]/), double_quote: templatable.until(/["\\\n\r\u2028\u2029]/), template_text: templatable.until(/[`\\$]/), @@ -2660,7 +2673,8 @@ Tokenizer.prototype._read_word = function(previous_token) { if (!(previous_token.type === TOKEN.DOT || (previous_token.type === TOKEN.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) && reserved_word_pattern.test(resulting_string)) { - if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators + if ((resulting_string === 'in' || resulting_string === 'of') && + (previous_token.type === TOKEN.WORD || previous_token.type === TOKEN.STRING)) { // hack for 'in' and 'of' operators return this._create_token(TOKEN.OPERATOR, resulting_string); } return this._create_token(TOKEN.RESERVED, resulting_string); @@ -3272,10 +3286,10 @@ module.exports.InputScanner = InputScanner; -var InputScanner = __webpack_require__(8).InputScanner; -var Token = __webpack_require__(3).Token; -var TokenStream = __webpack_require__(10).TokenStream; -var WhitespacePattern = __webpack_require__(11).WhitespacePattern; +var InputScanner = (__webpack_require__(8).InputScanner); +var Token = (__webpack_require__(3).Token); +var TokenStream = (__webpack_require__(10).TokenStream); +var WhitespacePattern = (__webpack_require__(11).WhitespacePattern); var TOKEN = { START: 'TK_START', @@ -3502,7 +3516,7 @@ module.exports.TokenStream = TokenStream; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); function WhitespacePattern(input_scanner, parent) { Pattern.call(this, input_scanner, parent); @@ -3781,7 +3795,7 @@ module.exports.Directives = Directives; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); var template_names = { @@ -5027,8 +5041,8 @@ module.exports.Directives = Directives; -var Beautifier = __webpack_require__(16).Beautifier, - Options = __webpack_require__(17).Options; +var Beautifier = (__webpack_require__(16).Beautifier), + Options = (__webpack_require__(17).Options); function css_beautify(source_text, options) { var beautifier = new Beautifier(source_text, options); @@ -5075,10 +5089,10 @@ module.exports.defaultOptions = function() { -var Options = __webpack_require__(17).Options; -var Output = __webpack_require__(2).Output; -var InputScanner = __webpack_require__(8).InputScanner; -var Directives = __webpack_require__(13).Directives; +var Options = (__webpack_require__(17).Options); +var Output = (__webpack_require__(2).Output); +var InputScanner = (__webpack_require__(8).InputScanner); +var Directives = (__webpack_require__(13).Directives); var directives_core = new Directives(/\/\*/, /\*\//); @@ -5114,6 +5128,10 @@ function Beautifier(source_text, options) { "@supports": true, "@document": true }; + this.NON_SEMICOLON_NEWLINE_PROPERTY = [ + "grid-template-areas", + "grid-template" + ]; } @@ -5238,7 +5256,9 @@ Beautifier.prototype.beautify = function() { var enteringConditionalGroup = false; var insideAtExtend = false; var insideAtImport = false; + var insideScssMap = false; var topCharacter = this._ch; + var insideNonSemiColonValues = false; var whitespace; var isAfterSpace; var previous_ch; @@ -5290,7 +5310,7 @@ Beautifier.prototype.beautify = function() { // Ensures any new lines following the comment are preserved this.eatWhitespace(true); - } else if (this._ch === '@') { + } else if (this._ch === '@' || this._ch === '$') { this.preserveSingleSpace(isAfterSpace); // deal with less propery mixins @{...} @@ -5361,7 +5381,12 @@ Beautifier.prototype.beautify = function() { this.indent(); this._output.set_indent(this._indentLevel); } else { - this.indent(); + // inside mixin and first param is object + if (previous_ch === '(') { + this._output.space_before_token = false; + } else if (previous_ch !== ',') { + this.indent(); + } this.print_string(this._ch); } @@ -5393,7 +5418,21 @@ Beautifier.prototype.beautify = function() { this._output.add_new_line(true); } } + if (this._input.peek() === ')') { + this._output.trim(true); + if (this._options.brace_style === "expand") { + this._output.add_new_line(true); + } + } } else if (this._ch === ":") { + + for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) { + if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) { + insideNonSemiColonValues = true; + break; + } + } + if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { // 'property: value' delimiter // which could be in a conditional group query @@ -5422,10 +5461,12 @@ Beautifier.prototype.beautify = function() { } } } else if (this._ch === '"' || this._ch === '\'') { - this.preserveSingleSpace(isAfterSpace); + var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\''; + this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace); this.print_string(this._ch + this.eatString(this._ch)); this.eatWhitespace(true); } else if (this._ch === ';') { + insideNonSemiColonValues = false; if (parenLevel === 0) { if (insidePropertyValue) { this.outdent(); @@ -5465,22 +5506,39 @@ Beautifier.prototype.beautify = function() { } } } else { - this.preserveSingleSpace(isAfterSpace); + var space_needed = false; + if (this._input.lookBack("with")) { + // look back is not an accurate solution, we need tokens to confirm without whitespaces + space_needed = true; + } + this.preserveSingleSpace(isAfterSpace || space_needed); this.print_string(this._ch); - this.eatWhitespace(); - parenLevel++; - this.indent(); + + // handle scss/sass map + if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) { + this._output.add_new_line(); + insideScssMap = true; + } else { + this.eatWhitespace(); + parenLevel++; + this.indent(); + } } } else if (this._ch === ')') { if (parenLevel) { parenLevel--; this.outdent(); } + if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) { + insideScssMap = false; + this.outdent(); + this._output.add_new_line(); + } this.print_string(this._ch); } else if (this._ch === ',') { this.print_string(this._ch); this.eatWhitespace(true); - if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { + if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) { this._output.add_new_line(); } else { this._output.space_before_token = true; @@ -5511,11 +5569,16 @@ Beautifier.prototype.beautify = function() { this._ch = ''; } } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important - this.print_string(' '); + this._output.space_before_token = true; this.print_string(this._ch); } else { - this.preserveSingleSpace(isAfterSpace); + var preserveAfterSpace = previous_ch === '"' || previous_ch === '\''; + this.preserveSingleSpace(preserveAfterSpace || isAfterSpace); this.print_string(this._ch); + + if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) { + this._output.add_new_line(); + } } } @@ -5561,7 +5624,7 @@ module.exports.Beautifier = Beautifier; -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); function Options(options) { BaseOptions.call(this, options, 'css'); @@ -6649,10 +6712,10 @@ module.exports.InputScanner = InputScanner; -var InputScanner = __webpack_require__(8).InputScanner; -var Token = __webpack_require__(3).Token; -var TokenStream = __webpack_require__(10).TokenStream; -var WhitespacePattern = __webpack_require__(11).WhitespacePattern; +var InputScanner = (__webpack_require__(8).InputScanner); +var Token = (__webpack_require__(3).Token); +var TokenStream = (__webpack_require__(10).TokenStream); +var WhitespacePattern = (__webpack_require__(11).WhitespacePattern); var TOKEN = { START: 'TK_START', @@ -6879,7 +6942,7 @@ module.exports.TokenStream = TokenStream; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); function WhitespacePattern(input_scanner, parent) { Pattern.call(this, input_scanner, parent); @@ -7158,7 +7221,7 @@ module.exports.Directives = Directives; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); var template_names = { @@ -7378,8 +7441,8 @@ module.exports.TemplatablePattern = TemplatablePattern; -var Beautifier = __webpack_require__(19).Beautifier, - Options = __webpack_require__(20).Options; +var Beautifier = (__webpack_require__(19).Beautifier), + Options = (__webpack_require__(20).Options); function style_html(html_source, options, js_beautify, css_beautify) { var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify); @@ -7426,10 +7489,10 @@ module.exports.defaultOptions = function() { -var Options = __webpack_require__(20).Options; -var Output = __webpack_require__(2).Output; -var Tokenizer = __webpack_require__(21).Tokenizer; -var TOKEN = __webpack_require__(21).TOKEN; +var Options = (__webpack_require__(20).Options); +var Output = (__webpack_require__(2).Output); +var Tokenizer = (__webpack_require__(21).Tokenizer); +var TOKEN = (__webpack_require__(21).TOKEN); var lineBreak = /\r\n|[\r\n]/; var allLineBreaks = /\r\n|[\r\n]/g; @@ -8005,14 +8068,19 @@ var TagOpenParserToken = function(parent, raw_token) { tag_check_match = raw_token.text.match(/^<([^\s>]*)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; } else { - tag_check_match = raw_token.text.match(/^{{(?:[\^]|#\*?)?([^\s}]+)/); + tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; - // handle "{{#> myPartial}} - if (raw_token.text === '{{#>' && this.tag_check === '>' && raw_token.next !== null) { - this.tag_check = raw_token.next.text; + // handle "{{#> myPartial}}" or "{{~#> myPartial}}" + if ((raw_token.text.startsWith('{{#>') || raw_token.text.startsWith('{{~#>')) && this.tag_check[0] === '>') { + if (this.tag_check === '>' && raw_token.next !== null) { + this.tag_check = raw_token.next.text.split(' ')[0]; + } else { + this.tag_check = raw_token.text.split('>')[1]; + } } } + this.tag_check = this.tag_check.toLowerCase(); if (raw_token.type === TOKEN.COMMENT) { @@ -8024,9 +8092,17 @@ var TagOpenParserToken = function(parent, raw_token) { this.is_end_tag = !this.is_start_tag || (raw_token.closed && raw_token.closed.text === '/>'); + // if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2 + var handlebar_starts = 2; + if (this.tag_start_char === '{' && this.text.length >= 3) { + if (this.text.charAt(2) === '~') { + handlebar_starts = 3; + } + } + // handlebars tags that don't start with # or ^ are single_tags, and so also start and end. this.is_end_tag = this.is_end_tag || - (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2))))); + (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts))))); } }; @@ -8297,7 +8373,7 @@ module.exports.Beautifier = Beautifier; -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); function Options(options) { BaseOptions.call(this, options, 'html'); @@ -8394,11 +8470,11 @@ module.exports.Options = Options; -var BaseTokenizer = __webpack_require__(9).Tokenizer; -var BASETOKEN = __webpack_require__(9).TOKEN; -var Directives = __webpack_require__(13).Directives; -var TemplatablePattern = __webpack_require__(14).TemplatablePattern; -var Pattern = __webpack_require__(12).Pattern; +var BaseTokenizer = (__webpack_require__(9).Tokenizer); +var BASETOKEN = (__webpack_require__(9).TOKEN); +var Directives = (__webpack_require__(13).Directives); +var TemplatablePattern = (__webpack_require__(14).TemplatablePattern); +var Pattern = (__webpack_require__(12).Pattern); var TOKEN = { TAG_OPEN: 'TK_TAG_OPEN', diff --git a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-min.js b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-min.js index c8b8c2e9dbbec..6faa1105c3f1d 100644 --- a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-min.js +++ b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify-min.js @@ -1,24 +1,24 @@ -YUI.add("moodle-atto_html-beautify",function(t,e){var s,a,u,n,i,_,r={};t.namespace("M.atto_html").beautify=r,function(){"use strict";var t,n=[function(t,e,n){var i=n(1).Beautifier,_=n(5).Options;t.exports=function(t,e){return new i(t,e).beautify()},t.exports.defaultOptions=function(){return new _}},function(n,_,t){var d,f,g,o,h,s,a,r,b,m,y,w=t(2).Output,k=t(3).Token,x=t(4),v=t(5).Options,E=t(7).Tokenizer,O=t(7).line_starters,T=t(7).positionable_operators,p=t(7).TOKEN;function l(t,e){return-1!==e.indexOf(t)}function i(t,e){return t&&t.type===p.RESERVED&&t.text===e}function c(t,e){return t&&t.type===p.RESERVED&&l(t.text,e)}function R(t,e){e.multiline_frame||e.mode===r||e.mode===b||t.remove_indent(e.start_line_index)}function u(t){return t===a}function A(t){return l(t,[m,r,b])}function e(t,e){e=e||{},this._source_text=t||"",this._output=null,this._tokens=null,this._last_last_text=null,this._flags=null,this._previous_flags=null,this._flag_store=null,this._options=new v(e)}d=["case","return","do","if","throw","else","await","break","continue","async"],f=function(t){for(var e={},n=0;nn&&(n=t.line_indent_level)),{mode:e,parent:t,last_token:t?t.last_token:new k(p.START_BLOCK,""),last_word:t?t.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,inline_frame:!1,if_block:!1,else_block:!1,do_block:!1,do_while:!1,import_block:!1,in_case_statement:!1,in_case:!1,case_body:!1,indentation_level:n,alignment:0,line_indent_level:t?t.line_indent_level:n,start_line_index:this._output.get_line_number(),ternary_depth:0}},e.prototype._reset=function(t){var e=t.match(/^[\t ]*/)[0];return this._last_last_text="",this._output=new w(this._options,e),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(o),e=new E(t,this._options),this._tokens=e.tokenize(),t},e.prototype.beautify=function(){var t,e,n;if(this._options.disabled)return this._source_text;for(t=this._reset(this._source_text),e=this._options.eol,"auto"===this._options.eol&&(e="\n",t&&x.lineBreak.test(t||"")&&(e=t.match(x.lineBreak)[0])),n=this._tokens.next();n;)this.handle_token(n),this._last_last_text=this._flags.last_token.text,this._flags.last_token=n,n=this._tokens.next();return this._output.get_code(e)},e.prototype.handle_token=function(t,e){t.type===p.START_EXPR?this.handle_start_expr(t):t.type===p.END_EXPR?this.handle_end_expr(t):t.type===p.START_BLOCK?this.handle_start_block(t):t.type===p.END_BLOCK?this.handle_end_block(t):t.type===p.WORD||t.type===p.RESERVED?this.handle_word(t):t.type===p.SEMICOLON?this.handle_semicolon(t):t.type===p.STRING?this.handle_string(t):t.type===p.EQUALS?this.handle_equals(t):t.type===p.OPERATOR?this.handle_operator(t):t.type===p.COMMA?this.handle_comma(t):t.type===p.BLOCK_COMMENT?this.handle_block_comment(t,e):t.type===p.COMMENT?this.handle_comment(t,e):t.type===p.DOT?this.handle_dot(t):t.type===p.EOF?this.handle_eof(t):(t.type,p.UNKNOWN,this.handle_unknown(t,e))},e.prototype.handle_whitespace_and_comments=function(t,e){var n,i,_,s=t.newlines,a=this._options.keep_array_indentation&&u(this._flags.mode);if(t.comments_before)for(n=t.comments_before.next();n;)this.handle_whitespace_and_comments(n,e),this.handle_token(n,e),n=t.comments_before.next();if(a)for(i=0;ithis._options.max_preserve_newlines&&(s=this._options.max_preserve_newlines),this._options.preserve_newlines&&1this._flags.parent.indentation_level)&&(--this._flags.indentation_level,this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},e.prototype.set_mode=function(t){this._flags?(this._flag_store.push(this._flags),this._previous_flags=this._flags):this._previous_flags=this.create_flags(null,t),this._flags=this.create_flags(this._previous_flags,t),this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},e.prototype.restore_mode=function(){0"!==this._flags.last_token.text)&&(l(this._flags.last_token.type,[p.EQUALS,p.START_EXPR,p.COMMA,p.OPERATOR])||c(this._flags.last_token,["return","throw","import","default"]))?this.set_mode(s):this.set_mode(o),n=(e=!n.comments_before&&"}"===n.text)&&"function"===this._flags.last_word&&this._flags.last_token.type===p.END_EXPR,this._options.brace_preserve_inline){i=0,this._flags.inline_frame=!(_=null);do{if((_=this._tokens.peek((i+=1)-1)).newlines){this._flags.inline_frame=!1;break}}while(_.type!==p.EOF&&(_.type!==p.END_BLOCK||_.opened!==t))}("expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==p.OPERATOR&&(n||this._flags.last_token.type===p.EQUALS||c(this._flags.last_token,d)&&"else"!==this._flags.last_token.text)?this._output.space_before_token=!0:this.print_newline(!1,!0):(!u(this._previous_flags.mode)||this._flags.last_token.type!==p.START_EXPR&&this._flags.last_token.type!==p.COMMA||(this._flags.last_token.type!==p.COMMA&&!this._options.space_in_paren||(this._output.space_before_token=!0),(this._flags.last_token.type===p.COMMA||this._flags.last_token.type===p.START_EXPR&&this._flags.inline_frame)&&(this.allow_wrap_or_preserved_newline(t),this._previous_flags.multiline_frame=this._previous_flags.multiline_frame||this._flags.multiline_frame,this._flags.multiline_frame=!1)),this._flags.last_token.type!==p.OPERATOR&&this._flags.last_token.type!==p.START_EXPR&&(this._flags.last_token.type!==p.START_BLOCK||this._flags.inline_frame?this._output.space_before_token=!0:this.print_newline())),this.print_token(t),this.indent(),e||this._options.brace_preserve_inline&&this._flags.inline_frame||this.print_newline()},e.prototype.handle_end_block=function(t){for(this.handle_whitespace_and_comments(t);this._flags.mode===h;)this.restore_mode();var e=this._flags.last_token.type===p.START_BLOCK;this._flags.inline_frame&&!e?this._output.space_before_token=!0:"expand"===this._options.brace_style?e||this.print_newline():e||(u(this._flags.mode)&&this._options.keep_array_indentation?(this._options.keep_array_indentation=!1,this.print_newline(),this._options.keep_array_indentation=!0):this.print_newline()),this.restore_mode(),this.print_token(t)},e.prototype.handle_word=function(t){var e;if(t.type===p.RESERVED&&(l(t.text,["set","get"])&&this._flags.mode!==s||"import"===t.text&&"("===this._tokens.peek().text||l(t.text,["as","from"])&&!this._flags.import_block||this._flags.mode===s&&":"===this._tokens.peek().text)&&(t.type=p.WORD),this.start_of_statement(t)?c(this._flags.last_token,["var","let","const"])&&t.type===p.WORD&&(this._flags.declaration_statement=!0):!t.newlines||A(this._flags.mode)||this._flags.last_token.type===p.OPERATOR&&"--"!==this._flags.last_token.text&&"++"!==this._flags.last_token.text||this._flags.last_token.type===p.EQUALS||!this._options.preserve_newlines&&c(this._flags.last_token,["var","let","const","set","get"])?this.handle_whitespace_and_comments(t):(this.handle_whitespace_and_comments(t),this.print_newline()),this._flags.do_block&&!this._flags.do_while){if(i(t,"while"))return this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0,void(this._flags.do_while=!0);this.print_newline(),this._flags.do_block=!1}if(this._flags.if_block)if(!this._flags.else_block&&i(t,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===h;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}return this._flags.in_case_statement&&c(t,["case","default"])?(this.print_newline(),this._flags.last_token.type!==p.END_BLOCK&&(this._flags.case_body||this._options.jslint_happy)&&this.deindent(),this._flags.case_body=!1,this.print_token(t),void(this._flags.in_case=!0)):(this._flags.last_token.type!==p.COMMA&&this._flags.last_token.type!==p.START_EXPR&&this._flags.last_token.type!==p.EQUALS&&this._flags.last_token.type!==p.OPERATOR||this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t),i(t,"function")?((l(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!l(this._flags.last_token.text,["(","[","{",":","=",","])&&this._flags.last_token.type!==p.OPERATOR)&&(this._output.just_added_blankline()||t.comments_before||(this.print_newline(),this.print_newline(!0))),this._flags.last_token.type===p.RESERVED||this._flags.last_token.type===p.WORD?c(this._flags.last_token,["get","set","new","export"])||c(this._flags.last_token,y)||i(this._flags.last_token,"default")&&"export"===this._last_last_text||"declare"===this._flags.last_token.text?this._output.space_before_token=!0:this.print_newline():this._flags.last_token.type===p.OPERATOR||"="===this._flags.last_token.text?this._output.space_before_token=!0:!this._flags.multiline_frame&&(A(this._flags.mode)||u(this._flags.mode))||this.print_newline(),this.print_token(t),void(this._flags.last_word=t.text)):(e="NONE",this._flags.last_token.type===p.END_BLOCK?this._previous_flags.inline_frame?e="SPACE":!c(t,["else","catch","finally","from"])||"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines?e="NEWLINE":(e="SPACE",this._output.space_before_token=!0):this._flags.last_token.type===p.SEMICOLON&&this._flags.mode===o?e="NEWLINE":this._flags.last_token.type===p.SEMICOLON&&A(this._flags.mode)?e="SPACE":this._flags.last_token.type===p.STRING?e="NEWLINE":this._flags.last_token.type===p.RESERVED||this._flags.last_token.type===p.WORD||"*"===this._flags.last_token.text&&(l(this._last_last_text,["function","yield"])||this._flags.mode===s&&l(this._last_last_text,["{",","]))?e="SPACE":this._flags.last_token.type===p.START_BLOCK?e=this._flags.inline_frame?"SPACE":"NEWLINE":this._flags.last_token.type===p.END_EXPR&&(this._output.space_before_token=!0,e="NEWLINE"),c(t,O)&&")"!==this._flags.last_token.text&&( -e=this._flags.inline_frame||"else"===this._flags.last_token.text||"export"===this._flags.last_token.text?"SPACE":"NEWLINE"),c(t,["else","catch","finally"])?(this._flags.last_token.type!==p.END_BLOCK||this._previous_flags.mode!==o||"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines)&&!this._flags.inline_frame?this.print_newline():(this._output.trim(!0),"}"!==this._output.current_line.last()&&this.print_newline(),this._output.space_before_token=!0):"NEWLINE"===e?c(this._flags.last_token,d)||"declare"===this._flags.last_token.text&&c(t,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==p.END_EXPR?this._flags.last_token.type===p.START_EXPR&&c(t,["var","let","const"])||":"===this._flags.last_token.text||(i(t,"if")&&i(t.previous,"else")?this._output.space_before_token=!0:this.print_newline()):c(t,O)&&")"!==this._flags.last_token.text&&this.print_newline():this._flags.multiline_frame&&u(this._flags.mode)&&","===this._flags.last_token.text&&"}"===this._last_last_text?this.print_newline():"SPACE"===e&&(this._output.space_before_token=!0),!t.previous||t.previous.type!==p.WORD&&t.previous.type!==p.RESERVED||(this._output.space_before_token=!0),this.print_token(t),this._flags.last_word=t.text,void(t.type===p.RESERVED&&("do"===t.text?this._flags.do_block=!0:"if"===t.text?this._flags.if_block=!0:"import"===t.text?this._flags.import_block=!0:this._flags.import_block&&i(t,"from")&&(this._flags.import_block=!1)))))},e.prototype.handle_semicolon=function(t){this.start_of_statement(t)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(t);for(var e=this._tokens.peek();!(this._flags.mode!==h||this._flags.if_block&&i(e,"else")||this._flags.do_block);)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(t)},e.prototype.handle_string=function(t){t.text.startsWith("`")&&0===t.newlines&&""===t.whitespace_before&&(")"===t.previous.text||this._flags.last_token.type===p.WORD)||(this.start_of_statement(t)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(t),this._flags.last_token.type===p.RESERVED||this._flags.last_token.type===p.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===p.COMMA||this._flags.last_token.type===p.START_EXPR||this._flags.last_token.type===p.EQUALS||this._flags.last_token.type===p.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t):!t.text.startsWith("`")||this._flags.last_token.type!==p.END_EXPR||"]"!==t.previous.text&&")"!==t.previous.text||0!==t.newlines?this.print_newline():this._output.space_before_token=!0)),this.print_token(t)},e.prototype.handle_equals=function(t){this.start_of_statement(t)||this.handle_whitespace_and_comments(t),this._flags.declaration_statement&&(this._flags.declaration_assignment=!0),this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0},e.prototype.handle_comma=function(t){this.handle_whitespace_and_comments(t,!0),this.print_token(t),this._output.space_before_token=!0,this._flags.declaration_statement?(A(this._flags.parent.mode)&&(this._flags.declaration_assignment=!1),this._flags.declaration_assignment?(this._flags.declaration_assignment=!1,this.print_newline(!1,!0)):this._options.comma_first&&this.allow_wrap_or_preserved_newline(t)):this._flags.mode===s||this._flags.mode===h&&this._flags.parent.mode===s?(this._flags.mode===h&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(t)},e.prototype.handle_operator=function(t){var e,n,i,_,s,a,u="*"===t.text&&(c(this._flags.last_token,["function","yield"])||l(this._flags.last_token.type,[p.START_BLOCK,p.COMMA,p.END_BLOCK,p.SEMICOLON])),r=l(t.text,["-","+"])&&(l(this._flags.last_token.type,[p.START_BLOCK,p.START_EXPR,p.EQUALS,p.OPERATOR])||l(this._flags.last_token.text,O)||","===this._flags.last_token.text);if(this.start_of_statement(t)||this.handle_whitespace_and_comments(t,!u),c(this._flags.last_token,d))return this._output.space_before_token=!0,void this.print_token(t);if("*"!==t.text||this._flags.last_token.type!==p.DOT)if("::"!==t.text){if(this._flags.last_token.type===p.OPERATOR&&l(this._options.operator_position,g)&&this.allow_wrap_or_preserved_newline(t),":"===t.text&&this._flags.in_case)return this.print_token(t),this._flags.in_case=!1,this._flags.case_body=!0,void(this._tokens.peek().type!==p.START_BLOCK?(this.indent(),this.print_newline()):this._output.space_before_token=!0);if(a=!(n=e=!0),":"===t.text?0===this._flags.ternary_depth?e=!1:(--this._flags.ternary_depth,a=!0):"?"===t.text&&(this._flags.ternary_depth+=1),!r&&!u&&this._options.preserve_newlines&&l(t.text,T))switch(_=(i=":"===t.text)&&a,s=i&&!a,this._options.operator_position){case f.before_newline:return this._output.space_before_token=!s,this.print_token(t),i&&!_||this.allow_wrap_or_preserved_newline(t),void(this._output.space_before_token=!0);case f.after_newline:return this._output.space_before_token=!0,!i||_?this._tokens.peek().newlines?this.print_newline(!1,!0):this.allow_wrap_or_preserved_newline(t):this._output.space_before_token=!1,this.print_token(t),void(this._output.space_before_token=!0);case f.preserve_newline:return s||this.allow_wrap_or_preserved_newline(t),e=!(this._output.just_added_newline()||s),this._output.space_before_token=e,this.print_token(t),void(this._output.space_before_token=!0)}u?(this.allow_wrap_or_preserved_newline(t),e=!1,n=(a=this._tokens.peek())&&l(a.type,[p.WORD,p.RESERVED])):"..."===t.text?(this.allow_wrap_or_preserved_newline(t),e=this._flags.last_token.type===p.START_BLOCK,n=!1):(l(t.text,["--","++","!","~"])||r)&&(this._flags.last_token.type!==p.COMMA&&this._flags.last_token.type!==p.START_EXPR||this.allow_wrap_or_preserved_newline(t),n=e=!1,!t.newlines||"--"!==t.text&&"++"!==t.text||this.print_newline(!1,!0), -";"===this._flags.last_token.text&&A(this._flags.mode)&&(e=!0),this._flags.last_token.type===p.RESERVED?e=!0:this._flags.last_token.type===p.END_EXPR?e=!("]"===this._flags.last_token.text&&("--"===t.text||"++"===t.text)):this._flags.last_token.type===p.OPERATOR&&(e=l(t.text,["--","-","++","+"])&&l(this._flags.last_token.text,["--","-","++","+"]),l(t.text,["+","-"])&&l(this._flags.last_token.text,["--","++"])&&(n=!0)),(this._flags.mode!==o||this._flags.inline_frame)&&this._flags.mode!==h||"{"!==this._flags.last_token.text&&";"!==this._flags.last_token.text||this.print_newline()),this._output.space_before_token=this._output.space_before_token||e,this.print_token(t),this._output.space_before_token=n}else this.print_token(t);else this.print_token(t)},e.prototype.handle_block_comment=function(t,e){return this._output.raw?(this._output.add_raw_token(t),void(t.directives&&"end"===t.directives.preserve&&(this._output.raw=this._options.test_output_raw))):t.directives?(this.print_newline(!1,e),this.print_token(t),"start"===t.directives.preserve&&(this._output.raw=!0),void this.print_newline(!1,!0)):void(x.newline.test(t.text)||t.newlines?this.print_block_commment(t,e):(this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0))},e.prototype.print_block_commment=function(t,e){var n,i,_,s=function(t){for(var e=[],n=(t=t.replace(x.allLineBreaks,"\n")).indexOf("\n");-1!==n;)e.push(t.substring(0,n)),n=(t=t.substring(n+1)).indexOf("\n");return t.length&&e.push(t),e}(t.text),a=t.whitespace_before,u=a.length;if(this.print_newline(!1,e),this.print_token_line_indentation(t),this._output.add_token(s[0]),this.print_newline(!1,e),1this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},_.prototype._allow_wrap=function(){var t;return!!this._should_wrap()&&(this.__parent.add_new_line(),(t=this.__parent.current_line).set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),--t.__character_count),!0)},_.prototype.is_empty=function(){return 0===this.__items.length},_.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},_.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length} -,_.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},_.prototype._remove_indent=function(){0=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var t,e=this.__cache.length,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},e.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},e.prototype.get_line_number=function(){return this.__lines.length},e.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},e.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},e.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},e.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},e.prototype.get_code=function(t){var e;return this.trim(!0),(e=this.current_line.pop())&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline(),e=this.__lines.join("\n"),e="\n"!==t?e.replace(/[\n]/g,t):e},e.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},e.prototype.set_indent=function(t,e){return this.next_line.set_indent(t=t||0,e=e||0),1n&&(n=t.line_indent_level)),{mode:e,parent:t,last_token:t?t.last_token:new k(p.START_BLOCK,""),last_word:t?t.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,inline_frame:!1,if_block:!1,else_block:!1,class_start_block:!1,do_block:!1,do_while:!1,import_block:!1,in_case_statement:!1,in_case:!1,case_body:!1,case_block:!1,indentation_level:n,alignment:0,line_indent_level:t?t.line_indent_level:n,start_line_index:this._output.get_line_number(),ternary_depth:0}},e.prototype._reset=function(t){var e=t.match(/^[\t ]*/)[0];return this._last_last_text="",this._output=new w(this._options,e),this._output.raw=this._options.test_output_raw,this._flag_store=[],this.set_mode(o),e=new E(t,this._options),this._tokens=e.tokenize(),t},e.prototype.beautify=function(){var t,e,n;if(this._options.disabled)return this._source_text;for(t=this._reset(this._source_text),e=this._options.eol,"auto"===this._options.eol&&(e="\n",t&&x.lineBreak.test(t||"")&&(e=t.match(x.lineBreak)[0])),n=this._tokens.next();n;)this.handle_token(n),this._last_last_text=this._flags.last_token.text,this._flags.last_token=n,n=this._tokens.next();return this._output.get_code(e)},e.prototype.handle_token=function(t,e){t.type===p.START_EXPR?this.handle_start_expr(t):t.type===p.END_EXPR?this.handle_end_expr(t):t.type===p.START_BLOCK?this.handle_start_block(t):t.type===p.END_BLOCK?this.handle_end_block(t):t.type===p.WORD||t.type===p.RESERVED?this.handle_word(t):t.type===p.SEMICOLON?this.handle_semicolon(t):t.type===p.STRING?this.handle_string(t):t.type===p.EQUALS?this.handle_equals(t):t.type===p.OPERATOR?this.handle_operator(t):t.type===p.COMMA?this.handle_comma(t):t.type===p.BLOCK_COMMENT?this.handle_block_comment(t,e):t.type===p.COMMENT?this.handle_comment(t,e):t.type===p.DOT?this.handle_dot(t):t.type===p.EOF?this.handle_eof(t):(t.type,p.UNKNOWN,this.handle_unknown(t,e))},e.prototype.handle_whitespace_and_comments=function(t,e){var n,i,_,s=t.newlines,a=this._options.keep_array_indentation&&u(this._flags.mode);if(t.comments_before)for(n=t.comments_before.next();n;)this.handle_whitespace_and_comments(n,e),this.handle_token(n,e),n=t.comments_before.next();if(a)for(i=0;ithis._options.max_preserve_newlines&&(s=this._options.max_preserve_newlines),this._options.preserve_newlines&&1this._flags.parent.indentation_level)&&(--this._flags.indentation_level,this._output.set_indent(this._flags.indentation_level,this._flags.alignment))},e.prototype.set_mode=function(t){this._flags?(this._flag_store.push(this._flags),this._previous_flags=this._flags):this._previous_flags=this.create_flags(null,t),this._flags=this.create_flags(this._previous_flags,t),this._output.set_indent(this._flags.indentation_level,this._flags.alignment)},e.prototype.restore_mode=function(){0"!==this._flags.last_token.text)&&(l(this._flags.last_token.type,[p.EQUALS,p.START_EXPR,p.COMMA,p.OPERATOR])||c(this._flags.last_token,["return","throw","import","default"]))?this.set_mode(s):this.set_mode(o),this._flags.last_token&&c(this._flags.last_token.previous,["class","extends"])&&(this._flags.class_start_block=!0),n=(e=!n.comments_before&&"}"===n.text)&&"function"===this._flags.last_word&&this._flags.last_token.type===p.END_EXPR,this._options.brace_preserve_inline){i=0,this._flags.inline_frame=!(_=null);do{if((_=this._tokens.peek((i+=1)-1)).newlines){this._flags.inline_frame=!1;break}}while(_.type!==p.EOF&&(_.type!==p.END_BLOCK||_.opened!==t))}("expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines)&&!this._flags.inline_frame?this._flags.last_token.type!==p.OPERATOR&&(n||this._flags.last_token.type===p.EQUALS||c(this._flags.last_token,d)&&"else"!==this._flags.last_token.text)?this._output.space_before_token=!0:this.print_newline(!1,!0):(!u(this._previous_flags.mode)||this._flags.last_token.type!==p.START_EXPR&&this._flags.last_token.type!==p.COMMA||(this._flags.last_token.type!==p.COMMA&&!this._options.space_in_paren||(this._output.space_before_token=!0),(this._flags.last_token.type===p.COMMA||this._flags.last_token.type===p.START_EXPR&&this._flags.inline_frame)&&(this.allow_wrap_or_preserved_newline(t),this._previous_flags.multiline_frame=this._previous_flags.multiline_frame||this._flags.multiline_frame,this._flags.multiline_frame=!1)),this._flags.last_token.type!==p.OPERATOR&&this._flags.last_token.type!==p.START_EXPR&&(this._flags.last_token.type!==p.START_BLOCK||this._flags.inline_frame?this._output.space_before_token=!0:this.print_newline())),this.print_token(t),this.indent(),e||this._options.brace_preserve_inline&&this._flags.inline_frame||this.print_newline()},e.prototype.handle_end_block=function(t){for(this.handle_whitespace_and_comments(t);this._flags.mode===h;)this.restore_mode();var e=this._flags.last_token.type===p.START_BLOCK;this._flags.inline_frame&&!e?this._output.space_before_token=!0:"expand"===this._options.brace_style?e||this.print_newline():e||(u(this._flags.mode)&&this._options.keep_array_indentation?(this._options.keep_array_indentation=!1,this.print_newline(),this._options.keep_array_indentation=!0):this.print_newline()),this.restore_mode(),this.print_token(t)},e.prototype.handle_word=function(t){var e;if(t.type===p.RESERVED&&(l(t.text,["set","get"])&&this._flags.mode!==s||"import"===t.text&&l(this._tokens.peek().text,["(","."])||l(t.text,["as","from"])&&!this._flags.import_block||this._flags.mode===s&&":"===this._tokens.peek().text)&&(t.type=p.WORD),this.start_of_statement(t)?c(this._flags.last_token,["var","let","const"])&&t.type===p.WORD&&(this._flags.declaration_statement=!0):!t.newlines||A(this._flags.mode)||this._flags.last_token.type===p.OPERATOR&&"--"!==this._flags.last_token.text&&"++"!==this._flags.last_token.text||this._flags.last_token.type===p.EQUALS||!this._options.preserve_newlines&&c(this._flags.last_token,["var","let","const","set","get"])?this.handle_whitespace_and_comments(t):(this.handle_whitespace_and_comments(t),this.print_newline()),this._flags.do_block&&!this._flags.do_while){if(i(t,"while"))return this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0,void(this._flags.do_while=!0);this.print_newline(),this._flags.do_block=!1}if(this._flags.if_block)if(!this._flags.else_block&&i(t,"else"))this._flags.else_block=!0;else{for(;this._flags.mode===h;)this.restore_mode();this._flags.if_block=!1,this._flags.else_block=!1}return this._flags.in_case_statement&&c(t,["case","default"])?(this.print_newline(),this._flags.case_block||!this._flags.case_body&&!this._options.jslint_happy||this.deindent(),this._flags.case_body=!1,this.print_token(t),void(this._flags.in_case=!0)):(this._flags.last_token.type!==p.COMMA&&this._flags.last_token.type!==p.START_EXPR&&this._flags.last_token.type!==p.EQUALS&&this._flags.last_token.type!==p.OPERATOR||this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t),i(t,"function")?((l(this._flags.last_token.text,["}",";"])||this._output.just_added_newline()&&!l(this._flags.last_token.text,["(","[","{",":","=",","])&&this._flags.last_token.type!==p.OPERATOR)&&(this._output.just_added_blankline()||t.comments_before||(this.print_newline(),this.print_newline(!0))),this._flags.last_token.type===p.RESERVED||this._flags.last_token.type===p.WORD?c(this._flags.last_token,["get","set","new","export"])||c(this._flags.last_token,y)||i(this._flags.last_token,"default")&&"export"===this._last_last_text||"declare"===this._flags.last_token.text?this._output.space_before_token=!0:this.print_newline():this._flags.last_token.type===p.OPERATOR||"="===this._flags.last_token.text?this._output.space_before_token=!0:!this._flags.multiline_frame&&(A(this._flags.mode)||u(this._flags.mode))||this.print_newline(),this.print_token(t),void(this._flags.last_word=t.text)):(e="NONE",this._flags.last_token.type===p.END_BLOCK?this._previous_flags.inline_frame?e="SPACE":!c(t,["else","catch","finally","from"])||"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines?e="NEWLINE":(e="SPACE",this._output.space_before_token=!0):this._flags.last_token.type===p.SEMICOLON&&this._flags.mode===o?e="NEWLINE":this._flags.last_token.type===p.SEMICOLON&&A(this._flags.mode)?e="SPACE":this._flags.last_token.type===p.STRING?e="NEWLINE":this._flags.last_token.type===p.RESERVED||this._flags.last_token.type===p.WORD||"*"===this._flags.last_token.text&&(l(this._last_last_text,["function","yield"])||this._flags.mode===s&&l(this._last_last_text,["{",","]) +)?e="SPACE":this._flags.last_token.type===p.START_BLOCK?e=this._flags.inline_frame?"SPACE":"NEWLINE":this._flags.last_token.type===p.END_EXPR&&(this._output.space_before_token=!0,e="NEWLINE"),c(t,O)&&")"!==this._flags.last_token.text&&(e=this._flags.inline_frame||"else"===this._flags.last_token.text||"export"===this._flags.last_token.text?"SPACE":"NEWLINE"),c(t,["else","catch","finally"])?(this._flags.last_token.type!==p.END_BLOCK||this._previous_flags.mode!==o||"expand"===this._options.brace_style||"end-expand"===this._options.brace_style||"none"===this._options.brace_style&&t.newlines)&&!this._flags.inline_frame?this.print_newline():(this._output.trim(!0),"}"!==this._output.current_line.last()&&this.print_newline(),this._output.space_before_token=!0):"NEWLINE"===e?c(this._flags.last_token,d)||"declare"===this._flags.last_token.text&&c(t,["var","let","const"])?this._output.space_before_token=!0:this._flags.last_token.type!==p.END_EXPR?this._flags.last_token.type===p.START_EXPR&&c(t,["var","let","const"])||":"===this._flags.last_token.text||(i(t,"if")&&i(t.previous,"else")?this._output.space_before_token=!0:this.print_newline()):c(t,O)&&")"!==this._flags.last_token.text&&this.print_newline():this._flags.multiline_frame&&u(this._flags.mode)&&","===this._flags.last_token.text&&"}"===this._last_last_text?this.print_newline():"SPACE"===e&&(this._output.space_before_token=!0),!t.previous||t.previous.type!==p.WORD&&t.previous.type!==p.RESERVED||(this._output.space_before_token=!0),this.print_token(t),this._flags.last_word=t.text,void(t.type===p.RESERVED&&("do"===t.text?this._flags.do_block=!0:"if"===t.text?this._flags.if_block=!0:"import"===t.text?this._flags.import_block=!0:this._flags.import_block&&i(t,"from")&&(this._flags.import_block=!1)))))},e.prototype.handle_semicolon=function(t){this.start_of_statement(t)?this._output.space_before_token=!1:this.handle_whitespace_and_comments(t);for(var e=this._tokens.peek();!(this._flags.mode!==h||this._flags.if_block&&i(e,"else")||this._flags.do_block);)this.restore_mode();this._flags.import_block&&(this._flags.import_block=!1),this.print_token(t)},e.prototype.handle_string=function(t){t.text.startsWith("`")&&0===t.newlines&&""===t.whitespace_before&&(")"===t.previous.text||this._flags.last_token.type===p.WORD)||(this.start_of_statement(t)?this._output.space_before_token=!0:(this.handle_whitespace_and_comments(t),this._flags.last_token.type===p.RESERVED||this._flags.last_token.type===p.WORD||this._flags.inline_frame?this._output.space_before_token=!0:this._flags.last_token.type===p.COMMA||this._flags.last_token.type===p.START_EXPR||this._flags.last_token.type===p.EQUALS||this._flags.last_token.type===p.OPERATOR?this.start_of_object_property()||this.allow_wrap_or_preserved_newline(t):!t.text.startsWith("`")||this._flags.last_token.type!==p.END_EXPR||"]"!==t.previous.text&&")"!==t.previous.text||0!==t.newlines?this.print_newline():this._output.space_before_token=!0)),this.print_token(t)},e.prototype.handle_equals=function(t){this.start_of_statement(t)||this.handle_whitespace_and_comments(t),this._flags.declaration_statement&&(this._flags.declaration_assignment=!0),this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0},e.prototype.handle_comma=function(t){this.handle_whitespace_and_comments(t,!0),this.print_token(t),this._output.space_before_token=!0,this._flags.declaration_statement?(A(this._flags.parent.mode)&&(this._flags.declaration_assignment=!1),this._flags.declaration_assignment?(this._flags.declaration_assignment=!1,this.print_newline(!1,!0)):this._options.comma_first&&this.allow_wrap_or_preserved_newline(t)):this._flags.mode===s||this._flags.mode===h&&this._flags.parent.mode===s?(this._flags.mode===h&&this.restore_mode(),this._flags.inline_frame||this.print_newline()):this._options.comma_first&&this.allow_wrap_or_preserved_newline(t)},e.prototype.handle_operator=function(t){var e,n,i,_,s,a,u="*"===t.text&&(c(this._flags.last_token,["function","yield"])||l(this._flags.last_token.type,[p.START_BLOCK,p.COMMA,p.END_BLOCK,p.SEMICOLON])),r=l(t.text,["-","+"])&&(l(this._flags.last_token.type,[p.START_BLOCK,p.START_EXPR,p.EQUALS,p.OPERATOR])||l(this._flags.last_token.text,O)||","===this._flags.last_token.text);if(this.start_of_statement(t)||this.handle_whitespace_and_comments(t,!u),"*"!==t.text||this._flags.last_token.type!==p.DOT)if("::"!==t.text){if(this._flags.last_token.type===p.OPERATOR&&l(this._options.operator_position,g)&&this.allow_wrap_or_preserved_newline(t),":"===t.text&&this._flags.in_case)return this.print_token(t),this._flags.in_case=!1,this._flags.case_body=!0,void(this._tokens.peek().type!==p.START_BLOCK?(this.indent(),this.print_newline(),this._flags.case_block=!1):(this._flags.case_block=!0,this._output.space_before_token=!0));if(a=!(n=e=!0),":"===t.text?0===this._flags.ternary_depth?e=!1:(--this._flags.ternary_depth,a=!0):"?"===t.text&&(this._flags.ternary_depth+=1),!r&&!u&&this._options.preserve_newlines&&l(t.text,T))switch(_=(i=":"===t.text)&&a,s=i&&!a,this._options.operator_position){case f.before_newline:return this._output.space_before_token=!s,this.print_token(t),i&&!_||this.allow_wrap_or_preserved_newline(t),void(this._output.space_before_token=!0);case f.after_newline:return this._output.space_before_token=!0,!i||_?this._tokens.peek().newlines?this.print_newline(!1,!0):this.allow_wrap_or_preserved_newline(t):this._output.space_before_token=!1,this.print_token(t),void(this._output.space_before_token=!0);case f.preserve_newline:return s||this.allow_wrap_or_preserved_newline(t),e=!(this._output.just_added_newline()||s),this._output.space_before_token=e,this.print_token(t),void(this._output.space_before_token=!0)}u?(this.allow_wrap_or_preserved_newline(t),e=!1,n=(a=this._tokens.peek())&&l(a.type,[p.WORD,p.RESERVED])):"..."===t.text?(this.allow_wrap_or_preserved_newline(t),e=this._flags.last_token.type===p.START_BLOCK,n=!1):(l(t.text,["--","++","!","~"])||r)&&( +this._flags.last_token.type!==p.COMMA&&this._flags.last_token.type!==p.START_EXPR||this.allow_wrap_or_preserved_newline(t),n=e=!1,!t.newlines||"--"!==t.text&&"++"!==t.text&&"~"!==t.text||((u=c(this._flags.last_token,d)&&t.newlines)&&(this._previous_flags.if_block||this._previous_flags.else_block)&&this.restore_mode(),this.print_newline(u,!0)),";"===this._flags.last_token.text&&A(this._flags.mode)&&(e=!0),this._flags.last_token.type===p.RESERVED?e=!0:this._flags.last_token.type===p.END_EXPR?e=!("]"===this._flags.last_token.text&&("--"===t.text||"++"===t.text)):this._flags.last_token.type===p.OPERATOR&&(e=l(t.text,["--","-","++","+"])&&l(this._flags.last_token.text,["--","-","++","+"]),l(t.text,["+","-"])&&l(this._flags.last_token.text,["--","++"])&&(n=!0)),(this._flags.mode!==o||this._flags.inline_frame)&&this._flags.mode!==h||"{"!==this._flags.last_token.text&&";"!==this._flags.last_token.text||this.print_newline()),this._output.space_before_token=this._output.space_before_token||e,this.print_token(t),this._output.space_before_token=n}else this.print_token(t);else this.print_token(t)},e.prototype.handle_block_comment=function(t,e){return this._output.raw?(this._output.add_raw_token(t),void(t.directives&&"end"===t.directives.preserve&&(this._output.raw=this._options.test_output_raw))):t.directives?(this.print_newline(!1,e),this.print_token(t),"start"===t.directives.preserve&&(this._output.raw=!0),void this.print_newline(!1,!0)):void(x.newline.test(t.text)||t.newlines?this.print_block_commment(t,e):(this._output.space_before_token=!0,this.print_token(t),this._output.space_before_token=!0))},e.prototype.print_block_commment=function(t,e){var n,i,_,s=function(t){for(var e=[],n=(t=t.replace(x.allLineBreaks,"\n")).indexOf("\n");-1!==n;)e.push(t.substring(0,n)),n=(t=t.substring(n+1)).indexOf("\n");return t.length&&e.push(t),e}(t.text),a=t.whitespace_before,u=a.length;if(this.print_newline(!1,e),this.print_token_line_indentation(t),this._output.add_token(s[0]),this.print_newline(!1,e),1this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},_.prototype._allow_wrap=function(){var t;return!!this._should_wrap()&&(this.__parent.add_new_line(),(t=this.__parent.current_line).set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count, +this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),--t.__character_count),!0)},_.prototype.is_empty=function(){return 0===this.__items.length},_.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},_.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length},_.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},_.prototype._remove_indent=function(){0=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var t,e=this.__cache.length,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},e.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},e.prototype.get_line_number=function(){return this.__lines.length},e.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},e.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},e.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},e.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},e.prototype.get_code=function(t){var e;return this.trim(!0),(e=this.current_line.pop())&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline(),e=this.__lines.join("\n"),e="\n"!==t?e.replace(/[\n]/g,t):e},e.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},e.prototype.set_indent=function(t,e){return this.next_line.set_indent(t=t||0,e=e||0),1>> === !== << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),s=(s="\\?\\.(?!\\d) "+(s=(s=">>>= ... >>= <<= === >>> !== **= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |").replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"))).replace(/ /g,"|"),c=new RegExp(s),s=(a="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",")).concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as"]),d=new RegExp("^(?:"+s.join("|")+")$"),((s=function(t,e){g.call(this,t,e), -this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source),t=new b(this._input),e=new m(this._input).read_options(this._options),this.__patterns={template:e,identifier:e.starting_with(h.identifier).matching(h.identifierMatch),number:t.matching(n),punct:t.matching(c),comment:t.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:t.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:t.matching(//),include:t.starting_with(/#include/).until_after(h.lineBreak),shebang:t.starting_with(/#!/).until_after(h.lineBreak),xml:t.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\]|)(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/),single_quote:e.until(/['\\\n\r\u2028\u2029]/),double_quote:e.until(/["\\\n\r\u2028\u2029]/),template_text:e.until(/[`\\$]/),template_expression:e.until(/[`}\\]/)}}).prototype=new g)._is_comment=function(t){return t.type===o.COMMENT||t.type===o.BLOCK_COMMENT||t.type===o.UNKNOWN},s.prototype._is_opening=function(t){return t.type===o.START_BLOCK||t.type===o.START_EXPR},s.prototype._is_closing=function(t,e){return(t.type===o.END_BLOCK||t.type===o.END_EXPR)&&e&&("]"===t.text&&"["===e.text||")"===t.text&&"("===e.text||"}"===t.text&&"{"===e.text)},s.prototype._reset=function(){_=!1},s.prototype._get_next_token=function(t,e){var n;return this._readWhitespace(),null===(n=this._input.peek())?this._create_token(o.EOF,""):this._read_non_javascript(n)||this._read_string(n)||this._read_word(t)||this._read_singles(n)||this._read_comment(n)||this._read_regexp(n,t)||this._read_xml(n,t)||this._read_punctuation()||this._create_token(o.UNKNOWN,this._input.next())},s.prototype._read_word=function(t){var e=this.__patterns.identifier.read();return""!==e?(e=e.replace(h.allLineBreaks,"\n"),t.type!==o.DOT&&(t.type!==o.RESERVED||"set"!==t.text&&"get"!==t.text)&&d.test(e)?"in"===e||"of"===e?this._create_token(o.OPERATOR,e):this._create_token(o.RESERVED,e):this._create_token(o.WORD,e)):""!==(e=this.__patterns.number.read())?this._create_token(o.WORD,e):void 0},s.prototype._read_singles=function(t){var e=null;return"("===t||"["===t?e=this._create_token(o.START_EXPR,t):")"===t||"]"===t?e=this._create_token(o.END_EXPR,t):"{"===t?e=this._create_token(o.START_BLOCK,t):"}"===t?e=this._create_token(o.END_BLOCK,t):";"===t?e=this._create_token(o.SEMICOLON,t):"."===t&&l.test(this._input.peek(1))?e=this._create_token(o.DOT,t):","===t&&(e=this._create_token(o.COMMA,t)),e&&this._input.next(),e},s.prototype._read_punctuation=function(){var t=this.__patterns.punct.read();if(""!==t)return"="===t?this._create_token(o.EQUALS,t):"?."===t?this._create_token(o.DOT,t):this._create_token(o.OPERATOR,t)},s.prototype._read_non_javascript=function(t){var e,n="";if("#"===t){if(this._is_first_token()&&(n=this.__patterns.shebang.read()))return this._create_token(o.UNKNOWN,n.trim()+"\n");if(n=this.__patterns.include.read())return this._create_token(o.UNKNOWN,n.trim()+"\n");if(t=this._input.next(),e="#",this._input.hasNext()&&this._input.testChar(p)){for(;e+=t=this._input.next(),this._input.hasNext()&&"#"!==t&&"="!==t;);return"#"===t||("["===this._input.peek()&&"]"===this._input.peek(1)?(e+="[]",this._input.next(),this._input.next()):"{"===this._input.peek()&&"}"===this._input.peek(1)&&(e+="{}",this._input.next(),this._input.next())),this._create_token(o.WORD,e)}this._input.back()}else if("<"===t&&this._is_first_token()){if(n=this.__patterns.html_comment_start.read()){for(;this._input.hasNext()&&!this._input.testChar(h.newline);)n+=this._input.next();return _=!0,this._create_token(o.COMMENT,n)}}else if(_&&"-"===t&&(n=this.__patterns.html_comment_end.read()))return _=!1,this._create_token(o.COMMENT,n);return null},s.prototype._read_comment=function(t){var e,n=null;return"/"===t&&(t="","*"===this._input.peek(1)?(t=this.__patterns.block_comment.read(),(e=i.get_directives(t))&&"start"===e.ignore&&(t+=i.readIgnored(this._input)),t=t.replace(h.allLineBreaks,"\n"),(n=this._create_token(o.BLOCK_COMMENT,t)).directives=e):"/"===this._input.peek(1)&&(t=this.__patterns.comment.read(),n=this._create_token(o.COMMENT,t))),n},s.prototype._read_string=function(t){var e;return"`"===t||"'"===t||'"'===t?(e=this._input.next(),this.has_char_escapes=!1,e+="`"===t?this._read_string_recursive("`",!0,"${"):this._read_string_recursive(t),this.has_char_escapes&&this._options.unescape_strings&&(e=function(t){var e="",n=0,i=new f(t),_=null;for(;i.hasNext();)if((_=i.match(/([\s]|[^\\]|\\\\)+/g))&&(e+=_[0]),"\\"===i.peek()){if(i.next(),"x"===i.peek())_=i.match(/x([0-9A-Fa-f]{2})/g);else{if("u"!==i.peek()){e+="\\",i.hasNext()&&(e+=i.next());continue}_=i.match(/u([0-9A-Fa-f]{4})/g)}if(!_)return t;if(126<(n=parseInt(_[1],16))&&n<=255&&0===_[0].indexOf("x"))return t;e+=0<=n&&n<32?"\\"+_[0]:34===n||39===n||92===n?"\\"+String.fromCharCode(n):String.fromCharCode(n)}return e}(e)),this._input.peek()===t&&(e+=this._input.next()),e=e.replace(h.allLineBreaks,"\n"),this._create_token(o.STRING,e)):null},s.prototype._allow_regexp_or_xml=function(t){return t.type===o.RESERVED&&u(t.text,["return","case","throw","else","do","typeof","yield"])||t.type===o.END_EXPR&&")"===t.text&&t.opened.previous.type===o.RESERVED&&u(t.opened.previous.text,["if","while","for"])||u(t.type,[o.COMMENT,o.START_EXPR,o.START_BLOCK,o.START,o.END_BLOCK,o.OPERATOR,o.EQUALS,o.EOF,o.SEMICOLON,o.COMMA])},s.prototype._read_regexp=function(t,e){var n,i,_;if("/"===t&&this._allow_regexp_or_xml(e)){for(n=this._input.next(),_=i=!1;this._input.hasNext()&&(i||_||this._input.peek()!==t)&&!this._input.testChar(h.newline);)n+=this._input.peek(),i?i=!1:(i="\\"===this._input.peek(),"["===this._input.peek()?_=!0:"]"===this._input.peek()&&(_=!1)),this._input.next();return this._input.peek()===t&&(n=(n+=this._input.next())+this._input.read(h.identifier)),this._create_token(o.STRING,n)}return null}, -s.prototype._read_xml=function(t,e){var n,i,_,s,a,u,r;if(this._options.e4x&&"<"===t&&this._allow_regexp_or_xml(e)&&(n="",i=this.__patterns.xml.read_match())){for(s=0===(_=i[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}")).indexOf("{"),a=0;i&&(u=!!i[1],r=i[2],!(!!i[i.length-1]||"![CDATA["===r.slice(0,8))&&(r===_||s&&r.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&(u?--a:++a),n+=i[0],!(a<=0));)i=this.__patterns.xml.read_match();return i||(n+=this._input.match(/[\s\S]*/g)[0]),n=n.replace(h.allLineBreaks,"\n"),this._create_token(o.STRING,n)}return null},s.prototype._read_string_recursive=function(t,e,n){var i,_,s,a;for("'"===t?_=this.__patterns.single_quote:'"'===t?_=this.__patterns.double_quote:"`"===t?_=this.__patterns.template_text:"}"===t&&(_=this.__patterns.template_expression),s=_.read(),a="";this._input.hasNext();){if((a=this._input.next())===t||!e&&h.newline.test(a)){this._input.back();break}"\\"===a&&this._input.hasNext()?("x"===(i=this._input.peek())||"u"===i?this.has_char_escapes=!0:"\r"===i&&"\n"===this._input.peek(1)&&this._input.next(),a+=this._input.next()):n&&("${"===n&&"$"===a&&"{"===this._input.peek()&&(a+=this._input.next()),n===a&&(a+="`"===t?this._read_string_recursive("}",e,"`"):this._read_string_recursive("`",e,"${"),this._input.hasNext()&&(a+=this._input.next()))),s+=a+=_.read()}return s},t.exports.Tokenizer=s,t.exports.TOKEN=o,t.exports.positionable_operators=e.slice(),t.exports.line_starters=a.slice()},function(t){var i=RegExp.prototype.hasOwnProperty("sticky");function e(t){this.__input=t||"",this.__input_length=this.__input.length,this.__position=0}e.prototype.restart=function(){this.__position=0},e.prototype.back=function(){0=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},t.exports.InputScanner=e},function(t,e,n){var i=n(8).InputScanner,s=n(3).Token,a=n(10).TokenStream,_=n(11).WhitespacePattern,u={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},n=function(t,e){this._input=new i(t),this._options=e||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new _(this._input)};n.prototype.tokenize=function(){var t,e,n,i,_;for(this._input.restart(),this.__tokens=new a,this._reset(),e=new s(u.START,""),n=null,i=[],_=new a;e.type!==u.EOF;){for(t=this._get_next_token(e,n);this._is_comment(t);)_.add(t),t=this._get_next_token(e,n);_.isEmpty()||(t.comments_before=_,_=new a),t.parent=n,this._is_opening(t)?(i.push(n),n=t):n&&this._is_closing(t,n)&&((t.opened=n).closed=t,n=i.pop(),t.parent=n),(t.previous=e).next=t,this.__tokens.add(t),e=t}return this.__tokens},n.prototype._is_first_token=function(){return this.__tokens.isEmpty()},n.prototype._reset=function(){},n.prototype._get_next_token=function(t,e){this._readWhitespace();var n=this._input.read(/.+/g);return n?this._create_token(u.RAW,n):this._create_token(u.EOF,"")},n.prototype._is_comment=function(t){return!1},n.prototype._is_opening=function(t){return!1},n.prototype._is_closing=function(t,e){return!1},n.prototype._create_token=function(t,e){return new s(t,e,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},n.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},t.exports.Tokenizer=n,t.exports.TOKEN=u},function(t){function e(t){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=t}e.prototype.restart=function(){this.__position=0},e.prototype.isEmpty=function(){return 0===this.__tokens_length},e.prototype.hasNext=function(){return this.__position/),erb:e.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:e.starting_with(/{%/).until_after(/%}/),django_value:e.starting_with(/{{/).until_after(/}}/),django_comment:e.starting_with(/{#/).until_after(/#}/),smarty:e.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:e.starting_with(/{\*/).until_after(/\*}/),smarty_literal:e.starting_with(/{literal}/).until_after(/{\/literal}/)}}(s.prototype=new i)._create=function(){return new s(this._input,this)},s.prototype._update=function(){this.__set_templated_pattern()},s.prototype.disable=function(t){var e=this._create();return e._disabled[t]=!0,e._update(),e},s.prototype.read_options=function(t){var e,n=this._create();for(e in _)n._disabled[e]=-1===t.templating.indexOf(e);return n._update(),n},s.prototype.exclude=function(t){var e=this._create();return e._excluded[t]=!0,e._update(),e},s.prototype.read=function(){for(var t="",t=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern),e=this._read_template();e;)this._match_pattern?e+=this._input.read(this._match_pattern):e+=this._input.readUntil(this.__template_pattern),t+=e,e=this._read_template();return this._until_after&&(t+=this._input.readUntilAfter(this._until_pattern)),t},s.prototype.__set_templated_pattern=function(){var t=[];this._disabled.php||t.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||t.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||t.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(t.push(this.__patterns.django._starting_pattern.source),t.push(this.__patterns.django_value._starting_pattern.source),t.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||t.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&t.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+t.join("|")+")")},s.prototype._read_template=function(){var t,e="",n=this._input.peek();return"<"===n?(t=this._input.peek(1),this._disabled.php||this._excluded.php||"?"!==t||(e=e||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==t||(e=e||this.__patterns.erb.read())):"{"===n&&(this._disabled.handlebars||this._excluded.handlebars||(e=(e=(e=e||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(e=e||this.__patterns.django_value.read()),this._excluded.django||(e=( -e=e||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(e=(e=(e=e||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read())),e},t.exports.TemplatablePattern=s}],i={};t=function _(t){var e=i[t];return e!==undefined||(e=i[t]={exports:{}},n[t](e,e.exports,_)),e.exports}(0),s=t}(),t=s,void 0!==r?r.js_beautify=t:"undefined"!=typeof window?window.js_beautify=t:"undefined"!=typeof global&&(global.js_beautify=t),function(){"use strict";var t,n=[,,function(t){function _(t){this.__parent=t,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}function n(t,e){this.__cache=[""],this.__indent_size=t.indent_size,this.__indent_string=t.indent_char,t.indent_with_tabs||(this.__indent_string=new Array(t.indent_size+1).join(t.indent_char)),e=e||"",0this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},_.prototype._allow_wrap=function(){var t;return!!this._should_wrap()&&(this.__parent.add_new_line(),(t=this.__parent.current_line).set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),--t.__character_count),!0)},_.prototype.is_empty=function(){return 0===this.__items.length},_.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},_.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length},_.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},_.prototype._remove_indent=function(){0=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var t,e=this.__cache.length,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},e.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},e.prototype.get_line_number=function(){return this.__lines.length},e.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},e.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},e.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},e.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},e.prototype.get_code=function(t){var e;return this.trim(!0),(e=this.current_line.pop())&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline(),e=this.__lines.join("\n"),e="\n"!==t?e.replace(/[\n]/g,t):e},e.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},e.prototype.set_indent=function(t,e){return this.next_line.set_indent(t=t||0,e=e||0),1=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},t.exports.InputScanner=e},,,,,function(t){function e(t,e){t="string"==typeof t?t:t.source,e="string"==typeof e?e:e.source,this.__directives_block_pattern=new RegExp(t+/ beautify( \w+[:]\w+)+ /.source+e,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(t+/\sbeautify\signore:end\s/.source+e,"g")}e.prototype.get_directives=function(t){var e,n;if(!t.match(this.__directives_block_pattern))return null;for(e={},this.__directive_pattern.lastIndex=0,n=this.__directive_pattern.exec(t);n;)e[n[1]]=n[2],n=this.__directive_pattern.exec(t);return e},e.prototype.readIgnored=function(t){return t.readUntilAfter(this.__directives_end_ignore_pattern)},t.exports.Directives=e},,function(t,e,n){var i=n(16).Beautifier,_=n(17).Options;t.exports=function(t,e){return new i(t,e).beautify()},t.exports.defaultOptions=function(){return new _}},function(t,_,e){var n=e(17).Options,d=e(2).Output,f=e(8).InputScanner,e=e(13).Directives,g=new e(/\/\*/,/\*\//),b=/\r\n|[\r\n]/,m=/\r\n|[\r\n]/g,y=/\s/,w=/(?:\s|\n)+/g,k=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,x=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function i(t,e){this._source_text=t||"",this._options=new n(e),this._ch=null,this._input=null,this.NESTED_AT_RULE={"@page":!0,"@font-face":!0,"@keyframes":!0,"@media":!0,"@supports":!0,"@document":!0},this.CONDITIONAL_GROUP_RULE={"@media":!0,"@supports":!0,"@document":!0}}i.prototype.eatString=function(t){var e="";for(this._ch=this._input.next();this._ch;){if(e+=this._ch,"\\"===this._ch)e+=this._input.next();else if(-1!==t.indexOf(this._ch)||"\n"===this._ch)break;this._ch=this._input.next()}return e},i.prototype.eatWhitespace=function(t){for(var e=y.test(this._input.peek()),n=0;y.test(this._input.peek());)this._ch=this._input.next(),t&&"\n"===this._ch&&(0===n||n=this._nestedLevel):this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&i&&this._output.previous_line&&"{"!==this._output.previous_line.item(-1)&&this._output.ensure_empty_line_above("/",","),this._output.space_before_token=!0,"expand"===this._options.brace_style?(this._output.add_new_line(),this.print_string(this._ch),this.indent(),this._output.set_indent(this._indentLevel)):(this.indent(),this.print_string(this._ch)),this.eatWhitespace(!0),this._output.add_new_line()):"}"===this._ch?(this.outdent(),this._output.add_new_line(),"{"===l&&this._output.trim(!0),a=u=!1,_&&(this.outdent(),_=!1),this.print_string(this._ch),i=!1,this._nestedLevel&&this._nestedLevel--,this.eatWhitespace(!0),this._output.add_new_line(),this._options.newline_between_rules&&!this._output.just_added_blankline()&&"}"!==this._input.peek()&&this._output.add_new_line(!0)):":"===this._ch?!i&&!s||this._input.lookBack("&")||this.foundNestedPseudoClass()||this._input.lookBack("(")||a||0!==n?(this._input.lookBack(" ")&&(this._output.space_before_token=!0),":"===this._input.peek()?(this._ch=this._input.next(),this.print_string("::")):this.print_string(":")):(this.print_string(":"),_||(this._output.space_before_token=_=!0,this.eatWhitespace(!0),this.indent())):'"'===this._ch||"'"===this._ch?(this.preserveSingleSpace(r),this.print_string(this._ch+this.eatString(this._ch)),this.eatWhitespace(!0)):";"===this._ch?0===n?(_&&(this.outdent(),_=!1),u=a=!1,this.print_string(this._ch),this.eatWhitespace(!0), -"/"!==this._input.peek()&&this._output.add_new_line()):(this.print_string(this._ch),this.eatWhitespace(!0),this._output.space_before_token=!0):"("===this._ch?this._input.lookBack("url")?(this.print_string(this._ch),this.eatWhitespace(),n++,this.indent(),this._ch=this._input.next(),")"===this._ch||'"'===this._ch||"'"===this._ch?this._input.back():this._ch&&(this.print_string(this._ch+this.eatString(")")),n&&(n--,this.outdent()))):(this.preserveSingleSpace(r),this.print_string(this._ch),this.eatWhitespace(),n++,this.indent()):")"===this._ch?(n&&(n--,this.outdent()),this.print_string(this._ch)):","===this._ch?(this.print_string(this._ch),this.eatWhitespace(!0),!this._options.selector_separator_newline||_||0!==n||u||a?this._output.space_before_token=!0:this._output.add_new_line()):">"!==this._ch&&"+"!==this._ch&&"~"!==this._ch||_||0!==n?"]"===this._ch?this.print_string(this._ch):"["===this._ch?(this.preserveSingleSpace(r),this.print_string(this._ch)):"="===this._ch?(this.eatWhitespace(),this.print_string("="),y.test(this._ch)&&(this._ch="")):("!"!==this._ch||this._input.lookBack("\\")?this.preserveSingleSpace(r):this.print_string(" "),this.print_string(this._ch)):this._options.space_around_combinator?(this._output.space_before_token=!0,this.print_string(this._ch),this._output.space_before_token=!0):(this.print_string(this._ch),this.eatWhitespace(),this._ch&&y.test(this._ch)&&(this._ch=""))}return this._output.get_code(e)},t.exports.Beautifier=i},function(t,e,n){var i=n(6).Options;function _(t){var e,n;for(i.call(this,t,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0),t=this._get_boolean("space_around_selector_separator"),this.space_around_combinator=this._get_boolean("space_around_combinator")||t,e=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]),this.brace_style="collapse",n=0;nthis.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},_.prototype._allow_wrap=function(){var t;return!!this._should_wrap()&&(this.__parent.add_new_line(),(t=this.__parent.current_line).set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),--t.__character_count),!0)},_.prototype.is_empty=function(){return 0===this.__items.length},_.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},_.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length},_.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},_.prototype._remove_indent=function(){0=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var t,e=this.__cache.length,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},e.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},e.prototype.get_line_number=function(){return this.__lines.length},e.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},e.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},e.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},e.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},e.prototype.get_code=function(t){var e;return this.trim(!0),(e=this.current_line.pop())&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline(),e=this.__lines.join("\n"),e="\n"!==t?e.replace(/[\n]/g,t):e},e.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},e.prototype.set_indent=function(t,e){return this.next_line.set_indent(t=t||0,e=e||0),1=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},t.exports.InputScanner=e},function(t,e,n){var i=n(8).InputScanner,s=n(3).Token,a=n(10).TokenStream,_=n(11).WhitespacePattern,u={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},n=function(t,e){this._input=new i(t),this._options=e||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new _(this._input)};n.prototype.tokenize=function(){var t,e,n,i,_;for(this._input.restart(),this.__tokens=new a,this._reset(),e=new s(u.START,""),n=null,i=[],_=new a;e.type!==u.EOF;){for(t=this._get_next_token(e,n);this._is_comment(t);)_.add(t),t=this._get_next_token(e,n);_.isEmpty()||(t.comments_before=_,_=new a),t.parent=n,this._is_opening(t)?(i.push(n),n=t):n&&this._is_closing(t,n)&&((t.opened=n).closed=t,n=i.pop(),t.parent=n),(t.previous=e).next=t,this.__tokens.add(t),e=t}return this.__tokens},n.prototype._is_first_token=function(){return this.__tokens.isEmpty()},n.prototype._reset=function(){},n.prototype._get_next_token=function(t,e){this._readWhitespace();var n=this._input.read(/.+/g);return n?this._create_token(u.RAW,n):this._create_token(u.EOF,"")},n.prototype._is_comment=function(t){return!1},n.prototype._is_opening=function(t){return!1},n.prototype._is_closing=function(t,e){return!1},n.prototype._create_token=function(t,e){return new s(t,e,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},n.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},t.exports.Tokenizer=n,t.exports.TOKEN=u},function(t){function e(t){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=t}e.prototype.restart=function(){this.__position=0},e.prototype.isEmpty=function(){return 0===this.__tokens_length},e.prototype.hasNext=function(){return this.__position/),erb:e.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:e.starting_with(/{%/).until_after(/%}/),django_value:e.starting_with(/{{/).until_after(/}}/),django_comment:e.starting_with(/{#/).until_after(/#}/),smarty:e.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:e.starting_with(/{\*/).until_after(/\*}/),smarty_literal:e.starting_with(/{literal}/).until_after(/{\/literal}/)}}(s.prototype=new i)._create=function(){return new s(this._input,this)},s.prototype._update=function(){this.__set_templated_pattern()},s.prototype.disable=function(t){var e=this._create();return e._disabled[t]=!0,e._update(),e},s.prototype.read_options=function(t){var e,n=this._create();for(e in _)n._disabled[e]=-1===t.templating.indexOf(e);return n._update(),n},s.prototype.exclude=function(t){var e=this._create();return e._excluded[t]=!0,e._update(),e},s.prototype.read=function(){for(var t="",t=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern),e=this._read_template();e;)this._match_pattern?e+=this._input.read(this._match_pattern):e+=this._input.readUntil(this.__template_pattern),t+=e,e=this._read_template();return this._until_after&&(t+=this._input.readUntilAfter(this._until_pattern)),t},s.prototype.__set_templated_pattern=function(){var t=[];this._disabled.php||t.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||t.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||t.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(t.push(this.__patterns.django._starting_pattern.source),t.push(this.__patterns.django_value._starting_pattern.source),t.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||t.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&t.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+t.join("|")+")")},s.prototype._read_template=function(){var t,e="",n=this._input.peek();return"<"===n?(t=this._input.peek(1),this._disabled.php||this._excluded.php||"?"!==t||(e=e||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==t||(e=e||this.__patterns.erb.read())):"{"===n&&(this._disabled.handlebars||this._excluded.handlebars||(e=(e=(e=e||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(e=e||this.__patterns.django_value.read()),this._excluded.django||(e=(e=e||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(e=(e=(e=e||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read())),e},t.exports.TemplatablePattern=s},,,,function(t,e,n){var _=n(19).Beautifier,i=n(20).Options;t.exports=function(t,e,n,i){return new _(t,e,n,i).beautify()},t.exports.defaultOptions=function(){return new i}},function(e,n,t){var _,s,o,i,u,r=t(20).Options,d=t(2).Output,f=t(21).Tokenizer,h=t(21).TOKEN,g=/\r\n|[\r\n]/,b=/\r\n|[\r\n]/g,p=function(t,e){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=t.max_preserve_newlines,this.preserve_newlines=t.preserve_newlines,this._output=new d(t,e)};function a(t,e){return-1!==e.indexOf(t)}function m(t,e,n){this.parent=t||null,this.tag=e?e.tag_name:"",this.indent_level=n||0,this.parser_token=e||null}function l(t){this._printer=t,this._current_frame=null}function c(t,e,n,i){this._source_text=t||"", -e=e||{},this._js_beautify=n,this._css_beautify=i,this._tag_stack=null;t=new r(e,"html");this._options=t,this._is_wrap_attributes_force="force"===this._options.wrap_attributes.substr(0,"force".length),this._is_wrap_attributes_force_expand_multiline="force-expand-multiline"===this._options.wrap_attributes,this._is_wrap_attributes_force_aligned="force-aligned"===this._options.wrap_attributes,this._is_wrap_attributes_aligned_multiple="aligned-multiple"===this._options.wrap_attributes,this._is_wrap_attributes_preserve="preserve"===this._options.wrap_attributes.substr(0,"preserve".length),this._is_wrap_attributes_preserve_aligned="preserve-aligned"===this._options.wrap_attributes}p.prototype.current_line_has_match=function(t){return this._output.current_line.has_match(t)},p.prototype.set_space_before_token=function(t,e){this._output.space_before_token=t,this._output.non_breaking_space=e},p.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},p.prototype.add_raw_token=function(t){this._output.add_raw_token(t)},p.prototype.print_preserved_newlines=function(t){var e,n=0;for(t.type!==h.TEXT&&t.previous.type!==h.TEXT&&(n=t.newlines?1:0),this.preserve_newlines&&(n=t.newlines|]]>)$/.exec(i)))return void t.add_raw_token(e);s=u+n[1]+"\n",i=n[4],n[5]&&(a=u+n[5]),i=i.replace(/\n[ \t]*$/,""),(n[2]||-1!==n[3].indexOf("\n"))&&(n=n[3].match(/[ \t]+$/))&&(e.whitespace_before=n[0])}i=i&&(_?((n=function(){this.eol="\n"}).prototype=this._options.raw_options,_(u+i,new n)):u+(i=(n=e.whitespace_before)?i.replace(new RegExp("\n("+n+")?","g"),"\n"):i).replace(/\n/g,"\n"+u)),s&&(i=i?s+i+"\n"+a:s+a),t.print_newline(!1),i&&(e.text=i,e.whitespace_before="",e.newlines=0,t.add_raw_token(e),t.print_newline(!0))}},c.prototype._handle_tag_open=function(t,e,n,i){var _=this._get_tag_open_token(e);return!n.is_unformatted&&!n.is_content_unformatted||n.is_empty_element||e.type!==h.TAG_OPEN||0!==e.text.indexOf("]*)/),this.tag_check=n?n[1]:""):(n=e.text.match(/^{{(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=n?n[1]:"","{{#>"===e.text&&">"===this.tag_check&&null!==e.next&&(this.tag_check=e.next.text)),this.tag_check=this.tag_check.toLowerCase(),e.type===h.COMMENT&&(this.tag_complete=!0),this.is_start_tag="/"!==this.tag_check.charAt(0),this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||e.closed&&"/>"===e.closed.text,this.is_end_tag=this.is_end_tag||"{"===this.tag_start_char&&(this.text.length<3||/[^#\^]/.test(this.text.charAt(2)))):this.tag_complete=!0},c.prototype._get_tag_open_token=function(t){t=new o(this._tag_stack.get_parser_token(),t);return t.alignment_size=this._options.wrap_attributes_indent_size,t.is_end_tag=t.is_end_tag||a(t.tag_check,this._options.void_elements),t.is_empty_element=t.tag_complete||t.is_start_tag&&t.is_end_tag,t.is_unformatted=!t.tag_complete&&a(t.tag_check,this._options.unformatted),t.is_content_unformatted=!t.is_empty_element&&a(t.tag_check,this._options.content_unformatted),t.is_inline_element=a(t.tag_name,this._options.inline)||"{"===t.tag_start_char,t},c.prototype._set_tag_position=function(t,e,n,i,_){n.is_empty_element||(n.is_end_tag?n.start_tag_token=this._tag_stack.try_pop(n.tag_name):(this._do_optional_end_element(n)&&(n.is_inline_element||t.print_newline(!1)),this._tag_stack.record_tag(n),"script"!==n.tag_name&&"style"!==n.tag_name||n.is_unformatted||n.is_content_unformatted||(n.custom_beautifier_name=s(n.tag_check,e)))),a(n.tag_check,this._options.extra_liners)&&(t.print_newline(!1),t._output.just_added_blankline()||t.print_newline(!0)),n.is_empty_element?("{"===n.tag_start_char&&"else"===n.tag_check&&(this._tag_stack.indent_to_tag(["if","unless","each"]),n.indent_content=!0,t.current_line_has_match(/{{#if/)||t.print_newline(!1)),"!--"===n.tag_name&&_.type===h.TAG_CLOSE&&i.is_end_tag&&-1===n.text.indexOf("\n")||(n.is_inline_element||n.is_unformatted||t.print_newline(!1),this._calcluate_parent_multiline(t,n))):n.is_end_tag?(e=!1,e=(e=n.start_tag_token&&n.start_tag_token.multiline_content)||!n.is_inline_element&&!(i.is_inline_element||i.is_unformatted)&&!(_.type===h.TAG_CLOSE&&n.start_tag_token===i)&&"TK_CONTENT"!==_.type,(e=n.is_content_unformatted||n.is_unformatted?!1:e)&&t.print_newline(!1)):(n.indent_content=!n.custom_beautifier_name,"<"===n.tag_start_char&&("html"===n.tag_name?n.indent_content=this._options.indent_inner_html:"head"===n.tag_name?n.indent_content=this._options.indent_head_inner_html:"body"===n.tag_name&&(n.indent_content=this._options.indent_body_inner_html)),n.is_inline_element||n.is_unformatted||"TK_CONTENT"===_.type&&!n.is_content_unformatted||t.print_newline(!1),this._calcluate_parent_multiline(t,n))},c.prototype._calcluate_parent_multiline=function(t,e){!e.parent||!t._output.just_added_newline()||(e.is_inline_element||e.is_unformatted)&&e.parent.is_inline_element||(e.parent.multiline_content=!0)},i=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"],u=["a","audio","del","ins","map","noscript","video"],c.prototype._do_optional_end_element=function(t){var e,n=null;if(!t.is_empty_element&&t.is_start_tag&&t.parent)return"body"===t.tag_name?n=n||this._tag_stack.try_pop("head"):"li"===t.tag_name?n=n||this._tag_stack.try_pop("li",["ol","ul"]):"dd"===t.tag_name||"dt"===t.tag_name?n=( -n=n||this._tag_stack.try_pop("dt",["dl"]))||this._tag_stack.try_pop("dd",["dl"]):"p"===t.parent.tag_name&&-1!==i.indexOf(t.tag_name)?(e=t.parent.parent)&&-1!==u.indexOf(e.tag_name)||(n=n||this._tag_stack.try_pop("p")):"rp"===t.tag_name||"rt"===t.tag_name?n=(n=n||this._tag_stack.try_pop("rt",["ruby","rtc"]))||this._tag_stack.try_pop("rp",["ruby","rtc"]):"optgroup"===t.tag_name?n=n||this._tag_stack.try_pop("optgroup",["select"]):"option"===t.tag_name?n=n||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):"colgroup"===t.tag_name?n=n||this._tag_stack.try_pop("caption",["table"]):"thead"===t.tag_name?n=(n=n||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]):"tbody"===t.tag_name||"tfoot"===t.tag_name?n=(n=(n=(n=n||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("thead",["table"]))||this._tag_stack.try_pop("tbody",["table"]):"tr"===t.tag_name?n=(n=(n=n||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"]):"th"!==t.tag_name&&"td"!==t.tag_name||(n=(n=n||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]))||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"])),t.parent=this._tag_stack.get_parser_token(),n},e.exports.Beautifier=c},function(t,e,n){var i=n(6).Options;function _(t){i.call(this,t,"html"),1===this.templating.length&&"auto"===this.templating[0]&&(this.templating=["django","erb","handlebars","php"]),this.indent_inner_html=this._get_boolean("indent_inner_html"),this.indent_body_inner_html=this._get_boolean("indent_body_inner_html",!0),this.indent_head_inner_html=this._get_boolean("indent_head_inner_html",!0),this.indent_handlebars=this._get_boolean("indent_handlebars",!0),this.wrap_attributes=this._get_selection("wrap_attributes",["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"]),this.wrap_attributes_indent_size=this._get_number("wrap_attributes_indent_size",this.indent_size),this.extra_liners=this._get_array("extra_liners",["head","body","/html"]),this.inline=this._get_array("inline",["a","abbr","area","audio","b","bdi","bdo","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","s","samp","select","small","span","strong","sub","sup","svg","template","textarea","time","u","var","video","wbr","text","acronym","big","strike","tt"]),this.void_elements=this._get_array("void_elements",["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr","!doctype","?xml","basefont","isindex"]),this.unformatted=this._get_array("unformatted",[]),this.content_unformatted=this._get_array("content_unformatted",["pre","textarea"]),this.unformatted_content_delimiter=this._get_characters("unformatted_content_delimiter"),this.indent_scripts=this._get_selection("indent_scripts",["normal","keep","separate"])}_.prototype=new i,t.exports.Options=_},function(t,o,e){var n=e(9).Tokenizer,i=e(9).TOKEN,_=e(13).Directives,s=e(14).TemplatablePattern,a=e(12).Pattern,u={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:i.START,RAW:i.RAW,EOF:i.EOF},r=new _(/<\!--/,/-->/),e=function(t,e){n.call(this,t,e),this._current_tag_name="",t=new s(this._input).read_options(this._options),e=new a(this._input),this.__patterns={word:t.until(/[\n\r\t <]/),single_quote:t.until_after(/'/),double_quote:t.until_after(/"/),attribute:t.until(/[\n\r\t =>]|\/>/),element_name:t.until(/[\n\r\t >\/]/),handlebars_comment:e.starting_with(/{{!--/).until_after(/--}}/),handlebars:e.starting_with(/{{/).until_after(/}}/),handlebars_open:e.until(/[\n\r\t }]/),handlebars_raw_close:e.until(/}}/),comment:e.starting_with(//),cdata:e.starting_with(//),conditional_comment:e.starting_with(//),processing:e.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter&&(t=this._input.get_literal_regexp(this._options.unformatted_content_delimiter),this.__patterns.unformatted_content_delimiter=e.matching(t).until_after(t))};(e.prototype=new n)._is_comment=function(t){return!1},e.prototype._is_opening=function(t){return t.type===u.TAG_OPEN},e.prototype._is_closing=function(t,e){return t.type===u.TAG_CLOSE&&e&&((">"===t.text||"/>"===t.text)&&"<"===e.text[0]||"}}"===t.text&&"{"===e.text[0]&&"{"===e.text[1])},e.prototype._reset=function(){this._current_tag_name=""},e.prototype._get_next_token=function(t,e){var n;return this._readWhitespace(),null===(n=this._input.peek())?this._create_token(u.EOF,""):this._read_open_handlebars(n,e)||this._read_attribute(n,t,e)||this._read_close(n,e)||this._read_raw_content(n,t,e)||this._read_content_word(n)||this._read_comment_or_cdata(n)||this._read_processing(n)||this._read_open(n,e)||this._create_token(u.UNKNOWN,this._input.next())},e.prototype._read_comment_or_cdata=function(t){var e=null,n=null,i=null;return"<"===t&&("!"===this._input.peek(1)&&((n=this.__patterns.comment.read())?(i=r.get_directives(n))&&"start"===i.ignore&&(n+=r.readIgnored(this._input)):n=this.__patterns.cdata.read()),n&&((e=this._create_token(u.COMMENT,n)).directives=i)),e},e.prototype._read_processing=function(t){var e=null,n=null;return"<"===t&&(n="!"!==(t=this._input.peek(1))&&"?"!==t?n:(n=this.__patterns.conditional_comment.read())||this.__patterns.processing.read())&&((e=this._create_token(u.COMMENT,n)).directives=null),e},e.prototype._read_open=function(t,e){var n=null, -i=null;return e||"<"===t&&(n=this._input.next(),"/"===this._input.peek()&&(n+=this._input.next()),n+=this.__patterns.element_name.read(),i=this._create_token(u.TAG_OPEN,n)),i},e.prototype._read_open_handlebars=function(t,e){var n=null,i=null;return e||this._options.indent_handlebars&&"{"===t&&"{"===this._input.peek(1)&&(i="!"===this._input.peek(2)?(n=(n=this.__patterns.handlebars_comment.read())||this.__patterns.handlebars.read(),this._create_token(u.COMMENT,n)):(n=this.__patterns.handlebars_open.read(),this._create_token(u.TAG_OPEN,n))),i},e.prototype._read_close=function(t,e){var n=null,i=null;return e&&("<"===e.text[0]&&(">"===t||"/"===t&&">"===this._input.peek(1))?(n=this._input.next(),"/"===t&&(n+=this._input.next()),i=this._create_token(u.TAG_CLOSE,n)):"{"===e.text[0]&&"}"===t&&"}"===this._input.peek(1)&&(this._input.next(),this._input.next(),i=this._create_token(u.TAG_CLOSE,"}}"))),i},e.prototype._read_attribute=function(t,e,n){var i=null;return n&&"<"===n.text[0]&&("="===t?i=this._create_token(u.EQUALS,this._input.next()):'"'===t||"'"===t?(n=this._input.next(),n+=('"'===t?this.__patterns.double_quote:this.__patterns.single_quote).read(),i=this._create_token(u.VALUE,n)):(t=this.__patterns.attribute.read())&&(i=e.type===u.EQUALS?this._create_token(u.VALUE,t):this._create_token(u.ATTRIBUTE,t))),i},e.prototype._is_content_unformatted=function(t){return-1===this._options.void_elements.indexOf(t)&&(-1!==this._options.content_unformatted.indexOf(t)||-1!==this._options.unformatted.indexOf(t))},e.prototype._read_raw_content=function(t,e,n){var i="";if(n&&"{"===n.text[0])i=this.__patterns.handlebars_raw_close.read();else if(e.type===u.TAG_CLOSE&&"<"===e.opened.text[0]&&"/"!==e.text[0])if("script"===(n=e.opened.text.substr(1).toLowerCase())||"style"===n){if(e=this._read_comment_or_cdata(t))return e.type=u.TEXT,e;i=this._input.readUntil(new RegExp("","ig"))}else this._is_content_unformatted(n)&&(i=this._input.readUntil(new RegExp("","ig")));return i?this._create_token(u.TEXT,i):null},e.prototype._read_content_word=function(t){var e="";if(e=(e=this._options.unformatted_content_delimiter&&t===this._options.unformatted_content_delimiter[0]?this.__patterns.unformatted_content_delimiter.read():e)||this.__patterns.word.read())return this._create_token(u.TEXT,e)},t.exports.Tokenizer=e,t.exports.TOKEN=u}],i={};t=function _(t){var e=i[t];return e!==undefined||(e=i[t]={exports:{}},n[t](e,e.exports,_)),e.exports}(18),u=t}(),n=u,void 0!==r?(_=i=r).html_beautify=function(t,e){return n(t,e,i.js_beautify,_.css_beautify)}:"undefined"!=typeof window?window.html_beautify=function(t,e){return n(t,e,window.js_beautify,window.css_beautify)}:"undefined"!=typeof global&&(global.html_beautify=function(t,e){return n(t,e,global.js_beautify,global.css_beautify)})},"@VERSION@"); \ No newline at end of file +,"g"),e.identifierStart=new RegExp(s),e.identifierMatch=new RegExp("(?:\\\\u[0-9a-fA-F]{4}|["+n+i+_+"])+"),e.newline=/[\n\r\u2028\u2029]/,e.lineBreak=new RegExp("\r\n|"+e.newline.source),e.allLineBreaks=new RegExp(e.lineBreak.source,"g")},function(t,e,n){var i=n(6).Options,_=["before-newline","after-newline","preserve-newline"];function s(t){var e,n;for(i.call(this,t,"js"),"expand-strict"===(t=this.raw_options.brace_style||null)?this.raw_options.brace_style="expand":"collapse-preserve-inline"===t?this.raw_options.brace_style="collapse,preserve-inline":this.raw_options.braces_on_own_line!==undefined&&(this.raw_options.brace_style=this.raw_options.braces_on_own_line?"expand":"collapse"),e=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]),this.brace_preserve_inline=!1,this.brace_style="collapse",n=0;n>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" "),s=(s="\\?\\.(?!\\d) "+(s=(s=">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |").replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"))).replace(/ /g,"|"),c=new RegExp(s),s=(a="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",")).concat(["do","in","of","else","get","set","new","catch","finally","typeof","yield","async","await","from","as","class","extends"]),d=new RegExp("^(?:"+s.join("|")+")$"),((s=function(t,e){ +g.call(this,t,e),this._patterns.whitespace=this._patterns.whitespace.matching(/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,/\u2028\u2029/.source),t=new b(this._input),e=new m(this._input).read_options(this._options),this.__patterns={template:e,identifier:e.starting_with(h.identifier).matching(h.identifierMatch),number:t.matching(n),punct:t.matching(c),comment:t.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),block_comment:t.starting_with(/\/\*/).until_after(/\*\//),html_comment_start:t.matching(//),include:t.starting_with(/#include/).until_after(h.lineBreak),shebang:t.starting_with(/#!/).until_after(h.lineBreak),xml:t.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),single_quote:e.until(/['\\\n\r\u2028\u2029]/),double_quote:e.until(/["\\\n\r\u2028\u2029]/),template_text:e.until(/[`\\$]/),template_expression:e.until(/[`}\\]/)}}).prototype=new g)._is_comment=function(t){return t.type===o.COMMENT||t.type===o.BLOCK_COMMENT||t.type===o.UNKNOWN},s.prototype._is_opening=function(t){return t.type===o.START_BLOCK||t.type===o.START_EXPR},s.prototype._is_closing=function(t,e){return(t.type===o.END_BLOCK||t.type===o.END_EXPR)&&e&&("]"===t.text&&"["===e.text||")"===t.text&&"("===e.text||"}"===t.text&&"{"===e.text)},s.prototype._reset=function(){_=!1},s.prototype._get_next_token=function(t,e){var n;return this._readWhitespace(),null===(n=this._input.peek())?this._create_token(o.EOF,""):this._read_non_javascript(n)||this._read_string(n)||this._read_word(t)||this._read_singles(n)||this._read_comment(n)||this._read_regexp(n,t)||this._read_xml(n,t)||this._read_punctuation()||this._create_token(o.UNKNOWN,this._input.next())},s.prototype._read_word=function(t){var e=this.__patterns.identifier.read();return""!==e?(e=e.replace(h.allLineBreaks,"\n"),t.type!==o.DOT&&(t.type!==o.RESERVED||"set"!==t.text&&"get"!==t.text)&&d.test(e)?"in"!==e&&"of"!==e||t.type!==o.WORD&&t.type!==o.STRING?this._create_token(o.RESERVED,e):this._create_token(o.OPERATOR,e):this._create_token(o.WORD,e)):""!==(e=this.__patterns.number.read())?this._create_token(o.WORD,e):void 0},s.prototype._read_singles=function(t){var e=null;return"("===t||"["===t?e=this._create_token(o.START_EXPR,t):")"===t||"]"===t?e=this._create_token(o.END_EXPR,t):"{"===t?e=this._create_token(o.START_BLOCK,t):"}"===t?e=this._create_token(o.END_BLOCK,t):";"===t?e=this._create_token(o.SEMICOLON,t):"."===t&&l.test(this._input.peek(1))?e=this._create_token(o.DOT,t):","===t&&(e=this._create_token(o.COMMA,t)),e&&this._input.next(),e},s.prototype._read_punctuation=function(){var t=this.__patterns.punct.read();if(""!==t)return"="===t?this._create_token(o.EQUALS,t):"?."===t?this._create_token(o.DOT,t):this._create_token(o.OPERATOR,t)},s.prototype._read_non_javascript=function(t){var e,n="";if("#"===t){if(this._is_first_token()&&(n=this.__patterns.shebang.read()))return this._create_token(o.UNKNOWN,n.trim()+"\n");if(n=this.__patterns.include.read())return this._create_token(o.UNKNOWN,n.trim()+"\n");if(t=this._input.next(),e="#",this._input.hasNext()&&this._input.testChar(p)){for(;e+=t=this._input.next(),this._input.hasNext()&&"#"!==t&&"="!==t;);return"#"===t||("["===this._input.peek()&&"]"===this._input.peek(1)?(e+="[]",this._input.next(),this._input.next()):"{"===this._input.peek()&&"}"===this._input.peek(1)&&(e+="{}",this._input.next(),this._input.next())),this._create_token(o.WORD,e)}this._input.back()}else if("<"===t&&this._is_first_token()){if(n=this.__patterns.html_comment_start.read()){for(;this._input.hasNext()&&!this._input.testChar(h.newline);)n+=this._input.next();return _=!0,this._create_token(o.COMMENT,n)}}else if(_&&"-"===t&&(n=this.__patterns.html_comment_end.read()))return _=!1,this._create_token(o.COMMENT,n);return null},s.prototype._read_comment=function(t){var e,n=null;return"/"===t&&(t="","*"===this._input.peek(1)?(t=this.__patterns.block_comment.read(),(e=i.get_directives(t))&&"start"===e.ignore&&(t+=i.readIgnored(this._input)),t=t.replace(h.allLineBreaks,"\n"),(n=this._create_token(o.BLOCK_COMMENT,t)).directives=e):"/"===this._input.peek(1)&&(t=this.__patterns.comment.read(),n=this._create_token(o.COMMENT,t))),n},s.prototype._read_string=function(t){var e;return"`"===t||"'"===t||'"'===t?(e=this._input.next(),this.has_char_escapes=!1,e+="`"===t?this._read_string_recursive("`",!0,"${"):this._read_string_recursive(t),this.has_char_escapes&&this._options.unescape_strings&&(e=function(t){var e="",n=0,i=new f(t),_=null;for(;i.hasNext();)if((_=i.match(/([\s]|[^\\]|\\\\)+/g))&&(e+=_[0]),"\\"===i.peek()){if(i.next(),"x"===i.peek())_=i.match(/x([0-9A-Fa-f]{2})/g);else{if("u"!==i.peek()){e+="\\",i.hasNext()&&(e+=i.next());continue}_=i.match(/u([0-9A-Fa-f]{4})/g)}if(!_)return t;if(126<(n=parseInt(_[1],16))&&n<=255&&0===_[0].indexOf("x"))return t;e+=0<=n&&n<32?"\\"+_[0]:34===n||39===n||92===n?"\\"+String.fromCharCode(n):String.fromCharCode(n)}return e}(e)),this._input.peek()===t&&(e+=this._input.next()),e=e.replace(h.allLineBreaks,"\n"),this._create_token(o.STRING,e)):null},s.prototype._allow_regexp_or_xml=function(t){return t.type===o.RESERVED&&u(t.text,["return","case","throw","else","do","typeof","yield"])||t.type===o.END_EXPR&&")"===t.text&&t.opened.previous.type===o.RESERVED&&u(t.opened.previous.text,["if","while","for"])||u(t.type,[o.COMMENT,o.START_EXPR,o.START_BLOCK,o.START,o.END_BLOCK,o.OPERATOR,o.EQUALS,o.EOF,o.SEMICOLON,o.COMMA])},s.prototype._read_regexp=function(t,e){var n,i,_;if("/"===t&&this._allow_regexp_or_xml(e)){for(n=this._input.next(),_=i=!1;this._input.hasNext()&&(i||_||this._input.peek()!==t)&&!this._input.testChar(h.newline);)n+=this._input.peek(),i?i=!1:(i="\\"===this._input.peek(),"["===this._input.peek()?_=!0:"]"===this._input.peek()&&(_=!1)),this._input.next();return this._input.peek()===t&&(n=(n+=this._input.next())+this._input.read( +h.identifier)),this._create_token(o.STRING,n)}return null},s.prototype._read_xml=function(t,e){var n,i,_,s,a,u,r;if(this._options.e4x&&"<"===t&&this._allow_regexp_or_xml(e)&&(n="",i=this.__patterns.xml.read_match())){for(s=0===(_=i[2].replace(/^{\s+/,"{").replace(/\s+}$/,"}")).indexOf("{"),a=0;i&&(u=!!i[1],r=i[2],!(!!i[i.length-1]||"![CDATA["===r.slice(0,8))&&(r===_||s&&r.replace(/^{\s+/,"{").replace(/\s+}$/,"}"))&&(u?--a:++a),n+=i[0],!(a<=0));)i=this.__patterns.xml.read_match();return i||(n+=this._input.match(/[\s\S]*/g)[0]),n=n.replace(h.allLineBreaks,"\n"),this._create_token(o.STRING,n)}return null},s.prototype._read_string_recursive=function(t,e,n){var i,_,s,a;for("'"===t?_=this.__patterns.single_quote:'"'===t?_=this.__patterns.double_quote:"`"===t?_=this.__patterns.template_text:"}"===t&&(_=this.__patterns.template_expression),s=_.read(),a="";this._input.hasNext();){if((a=this._input.next())===t||!e&&h.newline.test(a)){this._input.back();break}"\\"===a&&this._input.hasNext()?("x"===(i=this._input.peek())||"u"===i?this.has_char_escapes=!0:"\r"===i&&"\n"===this._input.peek(1)&&this._input.next(),a+=this._input.next()):n&&("${"===n&&"$"===a&&"{"===this._input.peek()&&(a+=this._input.next()),n===a&&(a+="`"===t?this._read_string_recursive("}",e,"`"):this._read_string_recursive("`",e,"${"),this._input.hasNext()&&(a+=this._input.next()))),s+=a+=_.read()}return s},t.exports.Tokenizer=s,t.exports.TOKEN=o,t.exports.positionable_operators=e.slice(),t.exports.line_starters=a.slice()},function(t){var i=RegExp.prototype.hasOwnProperty("sticky");function e(t){this.__input=t||"",this.__input_length=this.__input.length,this.__position=0}e.prototype.restart=function(){this.__position=0},e.prototype.back=function(){0=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},t.exports.InputScanner=e},function(t,e,n){var i=n(8).InputScanner,s=n(3).Token,a=n(10).TokenStream,_=n(11).WhitespacePattern,u={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},n=function(t,e){this._input=new i(t),this._options=e||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new _(this._input)};n.prototype.tokenize=function(){var t,e,n,i,_;for(this._input.restart(),this.__tokens=new a,this._reset(),e=new s(u.START,""),n=null,i=[],_=new a;e.type!==u.EOF;){for(t=this._get_next_token(e,n);this._is_comment(t);)_.add(t),t=this._get_next_token(e,n);_.isEmpty()||(t.comments_before=_,_=new a),t.parent=n,this._is_opening(t)?(i.push(n),n=t):n&&this._is_closing(t,n)&&((t.opened=n).closed=t,n=i.pop(),t.parent=n),(t.previous=e).next=t,this.__tokens.add(t),e=t}return this.__tokens},n.prototype._is_first_token=function(){return this.__tokens.isEmpty()},n.prototype._reset=function(){},n.prototype._get_next_token=function(t,e){this._readWhitespace();var n=this._input.read(/.+/g);return n?this._create_token(u.RAW,n):this._create_token(u.EOF,"")},n.prototype._is_comment=function(t){return!1},n.prototype._is_opening=function(t){return!1},n.prototype._is_closing=function(t,e){return!1},n.prototype._create_token=function(t,e){return new s(t,e,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},n.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},t.exports.Tokenizer=n,t.exports.TOKEN=u},function(t){function e(t){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=t}e.prototype.restart=function(){this.__position=0},e.prototype.isEmpty=function(){return 0===this.__tokens_length},e.prototype.hasNext=function(){return this.__position/),erb:e.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:e.starting_with(/{%/).until_after(/%}/),django_value:e.starting_with(/{{/).until_after(/}}/),django_comment:e.starting_with(/{#/).until_after(/#}/),smarty:e.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:e.starting_with(/{\*/).until_after(/\*}/),smarty_literal:e.starting_with(/{literal}/).until_after(/{\/literal}/)}}(s.prototype=new i)._create=function(){return new s(this._input,this)},s.prototype._update=function(){this.__set_templated_pattern()},s.prototype.disable=function(t){var e=this._create();return e._disabled[t]=!0,e._update(),e},s.prototype.read_options=function(t){var e,n=this._create();for(e in _)n._disabled[e]=-1===t.templating.indexOf(e);return n._update(),n},s.prototype.exclude=function(t){var e=this._create();return e._excluded[t]=!0,e._update(),e},s.prototype.read=function(){for(var t="",t=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern),e=this._read_template();e;)this._match_pattern?e+=this._input.read(this._match_pattern):e+=this._input.readUntil(this.__template_pattern),t+=e,e=this._read_template();return this._until_after&&(t+=this._input.readUntilAfter(this._until_pattern)),t},s.prototype.__set_templated_pattern=function(){var t=[];this._disabled.php||t.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||t.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||t.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(t.push(this.__patterns.django._starting_pattern.source),t.push(this.__patterns.django_value._starting_pattern.source),t.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||t.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&t.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+t.join("|")+")")},s.prototype._read_template=function(){var t,e="",n=this._input.peek();return"<"===n?(t=this._input.peek(1),this._disabled.php||this._excluded.php||"?"!==t||(e=e||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==t||(e=e||this.__patterns.erb.read())):"{"===n&&(this._disabled.handlebars||this._excluded.handlebars||(e=(e=(e=e||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(e=e||this.__patterns.django_value.read()), +this._excluded.django||(e=(e=e||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(e=(e=(e=e||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read())),e},t.exports.TemplatablePattern=s}],i={};t=function _(t){var e=i[t];return e!==undefined||(e=i[t]={exports:{}},n[t](e,e.exports,_)),e.exports}(0),s=t}(),t=s,void 0!==r?r.js_beautify=t:"undefined"!=typeof window?window.js_beautify=t:"undefined"!=typeof global&&(global.js_beautify=t),function(){"use strict";var t,n=[,,function(t){function _(t){this.__parent=t,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}function n(t,e){this.__cache=[""],this.__indent_size=t.indent_size,this.__indent_string=t.indent_char,t.indent_with_tabs||(this.__indent_string=new Array(t.indent_size+1).join(t.indent_char)),e=e||"",0this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},_.prototype._allow_wrap=function(){var t;return!!this._should_wrap()&&(this.__parent.add_new_line(),(t=this.__parent.current_line).set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),--t.__character_count),!0)},_.prototype.is_empty=function(){return 0===this.__items.length},_.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},_.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length},_.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},_.prototype._remove_indent=function(){0=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var t,e=this.__cache.length,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},e.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},e.prototype.get_line_number=function(){return this.__lines.length},e.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},e.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},e.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},e.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},e.prototype.get_code=function(t){var e;return this.trim(!0),(e=this.current_line.pop())&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline(),e=this.__lines.join("\n"),e="\n"!==t?e.replace(/[\n]/g,t):e},e.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},e.prototype.set_indent=function(t,e){return this.next_line.set_indent(t=t||0,e=e||0), +1=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},t.exports.InputScanner=e},,,,,function(t){function e(t,e){t="string"==typeof t?t:t.source,e="string"==typeof e?e:e.source,this.__directives_block_pattern=new RegExp(t+/ beautify( \w+[:]\w+)+ /.source+e,"g"),this.__directive_pattern=/ (\w+)[:](\w+)/g,this.__directives_end_ignore_pattern=new RegExp(t+/\sbeautify\signore:end\s/.source+e,"g")}e.prototype.get_directives=function(t){var e,n;if(!t.match(this.__directives_block_pattern))return null;for(e={},this.__directive_pattern.lastIndex=0,n=this.__directive_pattern.exec(t);n;)e[n[1]]=n[2],n=this.__directive_pattern.exec(t);return e},e.prototype.readIgnored=function(t){return t.readUntilAfter(this.__directives_end_ignore_pattern)},t.exports.Directives=e},,function(t,e,n){var i=n(16).Beautifier,_=n(17).Options;t.exports=function(t,e){return new i(t,e).beautify()},t.exports.defaultOptions=function(){return new _}},function(t,_,e){var n=e(17).Options,b=e(2).Output,m=e(8).InputScanner,e=e(13).Directives,y=new e(/\/\*/,/\*\//),w=/\r\n|[\r\n]/,k=/\r\n|[\r\n]/g,x=/\s/,v=/(?:\s|\n)+/g,E=/\/\*(?:[\s\S]*?)((?:\*\/)|$)/g,O=/\/\/(?:[^\n\r\u2028\u2029]*)/g;function i(t,e){this._source_text=t||"",this._options=new n(e),this._ch=null,this._input=null,this.NESTED_AT_RULE={"@page":!0,"@font-face":!0,"@keyframes":!0,"@media":!0,"@supports":!0,"@document":!0},this.CONDITIONAL_GROUP_RULE={"@media":!0,"@supports":!0,"@document":!0},this.NON_SEMICOLON_NEWLINE_PROPERTY=["grid-template-areas","grid-template"]}i.prototype.eatString=function(t){var e="";for(this._ch=this._input.next();this._ch;){if(e+=this._ch,"\\"===this._ch)e+=this._input.next();else if(-1!==t.indexOf(this._ch)||"\n"===this._ch)break;this._ch=this._input.next()}return e},i.prototype.eatWhitespace=function(t){for(var e=x.test(this._input.peek()),n=0;x.test(this._input.peek());)this._ch=this._input.next(),t&&"\n"===this._ch&&(0===n||n=this._nestedLevel):this._indentLevel>=this._nestedLevel-1,this._options.newline_between_rules&&n&&this._output.previous_line&&"{"!==this._output.previous_line.item(-1)&&this._output.ensure_empty_line_above("/",","),this._output.space_before_token=!0,"expand"===this._options.brace_style?(this._output.add_new_line(),this.print_string(this._ch),this.indent(),this._output.set_indent(this._indentLevel)):("("===u?this._output.space_before_token=!1:","!==u&&this.indent(),this.print_string(this._ch)),this.eatWhitespace(!0),this._output.add_new_line();else if("}"===this._ch)this.outdent(),this._output.add_new_line(),"{"===u&&this._output.trim(!0),s=l=!1,i&&(this.outdent(),i=!1),this.print_string(this._ch),n=!1,this._nestedLevel&&this._nestedLevel--,this.eatWhitespace(!0),this._output.add_new_line(),this._options.newline_between_rules&&!this._output.just_added_blankline()&&"}"!==this._input.peek()&&this._output.add_new_line(!0),")"===this._input.peek()&&(this._output.trim(!0),"expand"===this._options.brace_style&&this._output.add_new_line(!0));else if(":"===this._ch){for(g=0;g"!==this._ch&&"+"!==this._ch&&"~"!==this._ch||i||0!==e?"]"===this._ch?this.print_string(this._ch):"["===this._ch?(this.preserveSingleSpace(a),this.print_string(this._ch)):"="===this._ch?(this.eatWhitespace(),this.print_string("="),x.test(this._ch)&&(this._ch="")):"!"!==this._ch||this._input.lookBack("\\")?(this.preserveSingleSpace('"'===u||"'"===u||a),this.print_string(this._ch),!this._output.just_added_newline()&&"\n"===this._input.peek()&&f&&this._output.add_new_line()):(this._output.space_before_token=!0,this.print_string(this._ch)):this._options.space_around_combinator?(this._output.space_before_token=!0,this.print_string(this._ch),this._output.space_before_token=!0):(this.print_string(this._ch),this.eatWhitespace(),this._ch&&x.test(this._ch)&&(this._ch=""))}return this._output.get_code(h)},t.exports.Beautifier=i},function(t,e,n){var i=n(6).Options;function _(t){var e,n;for(i.call(this,t,"css"),this.selector_separator_newline=this._get_boolean("selector_separator_newline",!0),this.newline_between_rules=this._get_boolean("newline_between_rules",!0),t=this._get_boolean("space_around_selector_separator"),this.space_around_combinator=this._get_boolean("space_around_combinator")||t,e=this._get_selection_list("brace_style",["collapse","expand","end-expand","none","preserve-inline"]),this.brace_style="collapse",n=0;nthis.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},_.prototype._allow_wrap=function(){var t;return!!this._should_wrap()&&(this.__parent.add_new_line(),(t=this.__parent.current_line).set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),t.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),t.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count," "===t.__items[0]&&(t.__items.splice(0,1),--t.__character_count),!0)},_.prototype.is_empty=function(){return 0===this.__items.length},_.prototype.last=function(){return this.is_empty( +)?null:this.__items[this.__items.length-1]},_.prototype.push=function(t){this.__items.push(t);var e=t.lastIndexOf("\n");-1!==e?this.__character_count=t.length-e:this.__character_count+=t.length},_.prototype.pop=function(){var t=null;return this.is_empty()||(t=this.__items.pop(),this.__character_count-=t.length),t},_.prototype._remove_indent=function(){0=this.__cache.length;)this.__add_column()},n.prototype.__add_column=function(){var t,e=this.__cache.length,n="";this.__indent_size&&e>=this.__indent_size&&(e-=(t=Math.floor(e/this.__indent_size))*this.__indent_size,n=new Array(t+1).join(this.__indent_string)),e&&(n+=new Array(e+1).join(" ")),this.__cache.push(n)},e.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},e.prototype.get_line_number=function(){return this.__lines.length},e.prototype.get_indent_string=function(t,e){return this.__indent_cache.get_indent_string(t,e)},e.prototype.get_indent_size=function(t,e){return this.__indent_cache.get_indent_size(t,e)},e.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},e.prototype.add_new_line=function(t){return!(this.is_empty()||!t&&this.just_added_newline())&&(this.raw||this.__add_outputline(),!0)},e.prototype.get_code=function(t){var e;return this.trim(!0),(e=this.current_line.pop())&&("\n"===e[e.length-1]&&(e=e.replace(/\n+$/g,"")),this.current_line.push(e)),this._end_with_newline&&this.__add_outputline(),e=this.__lines.join("\n"),e="\n"!==t?e.replace(/[\n]/g,t):e},e.prototype.set_wrap_point=function(){this.current_line._set_wrap_point()},e.prototype.set_indent=function(t,e){return this.next_line.set_indent(t=t||0,e=e||0),1=t.length&&this.__input.substring(e-t.length,e).toLowerCase()===t},t.exports.InputScanner=e},function(t,e,n){var i=n(8).InputScanner,s=n(3).Token,a=n(10).TokenStream,_=n(11).WhitespacePattern,u={START:"TK_START",RAW:"TK_RAW",EOF:"TK_EOF"},n=function(t,e){this._input=new i(t),this._options=e||{},this.__tokens=null,this._patterns={},this._patterns.whitespace=new _(this._input)};n.prototype.tokenize=function(){var t,e,n,i,_;for(this._input.restart(),this.__tokens=new a,this._reset(),e=new s(u.START,""),n=null,i=[],_=new a;e.type!==u.EOF;){for(t=this._get_next_token(e,n);this._is_comment(t);)_.add(t),t=this._get_next_token(e,n);_.isEmpty()||(t.comments_before=_,_=new a),t.parent=n,this._is_opening(t)?(i.push(n),n=t):n&&this._is_closing(t,n)&&((t.opened=n).closed=t,n=i.pop(),t.parent=n),(t.previous=e).next=t,this.__tokens.add(t),e=t}return this.__tokens},n.prototype._is_first_token=function(){return this.__tokens.isEmpty()},n.prototype._reset=function(){},n.prototype._get_next_token=function(t,e){this._readWhitespace();var n=this._input.read(/.+/g);return n?this._create_token(u.RAW,n):this._create_token(u.EOF,"")},n.prototype._is_comment=function(t){return!1},n.prototype._is_opening=function(t){return!1},n.prototype._is_closing=function(t,e){return!1},n.prototype._create_token=function(t,e){return new s(t,e,this._patterns.whitespace.newline_count,this._patterns.whitespace.whitespace_before_token)},n.prototype._readWhitespace=function(){return this._patterns.whitespace.read()},t.exports.Tokenizer=n,t.exports.TOKEN=u},function(t){function e(t){this.__tokens=[],this.__tokens_length=this.__tokens.length,this.__position=0,this.__parent_token=t}e.prototype.restart=function(){this.__position=0},e.prototype.isEmpty=function(){return 0===this.__tokens_length},e.prototype.hasNext=function(){return this.__position/),erb:e.starting_with(/<%[^%]/).until_after(/[^%]%>/),django:e.starting_with(/{%/).until_after(/%}/),django_value:e.starting_with(/{{/).until_after(/}}/),django_comment:e.starting_with(/{#/).until_after(/#}/),smarty:e.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),smarty_comment:e.starting_with(/{\*/).until_after(/\*}/),smarty_literal:e.starting_with(/{literal}/).until_after(/{\/literal}/)}}(s.prototype=new i)._create=function(){return new s(this._input,this)},s.prototype._update=function(){this.__set_templated_pattern()},s.prototype.disable=function(t){var e=this._create();return e._disabled[t]=!0,e._update(),e},s.prototype.read_options=function(t){var e,n=this._create();for(e in _)n._disabled[e]=-1===t.templating.indexOf(e);return n._update(),n},s.prototype.exclude=function(t){var e=this._create();return e._excluded[t]=!0,e._update(),e},s.prototype.read=function(){for(var t="",t=this._match_pattern?this._input.read(this._starting_pattern):this._input.read(this._starting_pattern,this.__template_pattern),e=this._read_template();e;)this._match_pattern?e+=this._input.read(this._match_pattern):e+=this._input.readUntil(this.__template_pattern),t+=e,e=this._read_template();return this._until_after&&(t+=this._input.readUntilAfter(this._until_pattern)),t},s.prototype.__set_templated_pattern=function(){var t=[];this._disabled.php||t.push(this.__patterns.php._starting_pattern.source),this._disabled.handlebars||t.push(this.__patterns.handlebars._starting_pattern.source),this._disabled.erb||t.push(this.__patterns.erb._starting_pattern.source),this._disabled.django||(t.push(this.__patterns.django._starting_pattern.source),t.push(this.__patterns.django_value._starting_pattern.source),t.push(this.__patterns.django_comment._starting_pattern.source)),this._disabled.smarty||t.push(this.__patterns.smarty._starting_pattern.source),this._until_pattern&&t.push(this._until_pattern.source),this.__template_pattern=this._input.get_regexp("(?:"+t.join("|")+")")},s.prototype._read_template=function(){var t,e="",n=this._input.peek();return"<"===n?(t=this._input.peek(1),this._disabled.php||this._excluded.php||"?"!==t||(e=e||this.__patterns.php.read()),this._disabled.erb||this._excluded.erb||"%"!==t||(e=e||this.__patterns.erb.read())):"{"===n&&(this._disabled.handlebars||this._excluded.handlebars||(e=(e=(e=e||this.__patterns.handlebars_comment.read())||this.__patterns.handlebars_unescaped.read())||this.__patterns.handlebars.read()),this._disabled.django||(this._excluded.django||this._excluded.handlebars||(e=e||this.__patterns.django_value.read()),this._excluded.django||(e=(e=e||this.__patterns.django_comment.read())||this.__patterns.django.read())),this._disabled.smarty||this._disabled.django&&this._disabled.handlebars&&(e=(e=( +e=e||this.__patterns.smarty_comment.read())||this.__patterns.smarty_literal.read())||this.__patterns.smarty.read())),e},t.exports.TemplatablePattern=s},,,,function(t,e,n){var _=n(19).Beautifier,i=n(20).Options;t.exports=function(t,e,n,i){return new _(t,e,n,i).beautify()},t.exports.defaultOptions=function(){return new i}},function(e,n,t){var _,s,o,i,u,r=t(20).Options,d=t(2).Output,f=t(21).Tokenizer,h=t(21).TOKEN,g=/\r\n|[\r\n]/,b=/\r\n|[\r\n]/g,p=function(t,e){this.indent_level=0,this.alignment_size=0,this.max_preserve_newlines=t.max_preserve_newlines,this.preserve_newlines=t.preserve_newlines,this._output=new d(t,e)};function a(t,e){return-1!==e.indexOf(t)}function m(t,e,n){this.parent=t||null,this.tag=e?e.tag_name:"",this.indent_level=n||0,this.parser_token=e||null}function l(t){this._printer=t,this._current_frame=null}function c(t,e,n,i){this._source_text=t||"",e=e||{},this._js_beautify=n,this._css_beautify=i,this._tag_stack=null;t=new r(e,"html");this._options=t,this._is_wrap_attributes_force="force"===this._options.wrap_attributes.substr(0,"force".length),this._is_wrap_attributes_force_expand_multiline="force-expand-multiline"===this._options.wrap_attributes,this._is_wrap_attributes_force_aligned="force-aligned"===this._options.wrap_attributes,this._is_wrap_attributes_aligned_multiple="aligned-multiple"===this._options.wrap_attributes,this._is_wrap_attributes_preserve="preserve"===this._options.wrap_attributes.substr(0,"preserve".length),this._is_wrap_attributes_preserve_aligned="preserve-aligned"===this._options.wrap_attributes}p.prototype.current_line_has_match=function(t){return this._output.current_line.has_match(t)},p.prototype.set_space_before_token=function(t,e){this._output.space_before_token=t,this._output.non_breaking_space=e},p.prototype.set_wrap_point=function(){this._output.set_indent(this.indent_level,this.alignment_size),this._output.set_wrap_point()},p.prototype.add_raw_token=function(t){this._output.add_raw_token(t)},p.prototype.print_preserved_newlines=function(t){var e,n=0;for(t.type!==h.TEXT&&t.previous.type!==h.TEXT&&(n=t.newlines?1:0),this.preserve_newlines&&(n=t.newlines|]]>)$/.exec(i)))return void t.add_raw_token(e);s=u+n[1]+"\n",i=n[4],n[5]&&(a=u+n[5]),i=i.replace(/\n[ \t]*$/,""),(n[2]||-1!==n[3].indexOf("\n"))&&(n=n[3].match(/[ \t]+$/))&&(e.whitespace_before=n[0])}i=i&&(_?((n=function(){this.eol="\n"}).prototype=this._options.raw_options,_(u+i,new n)):u+(i=(n=e.whitespace_before)?i.replace(new RegExp("\n("+n+")?","g"),"\n"):i).replace(/\n/g,"\n"+u)),s&&(i=i?s+i+"\n"+a:s+a),t.print_newline(!1),i&&(e.text=i,e.whitespace_before="",e.newlines=0,t.add_raw_token(e),t.print_newline(!0))}},c.prototype._handle_tag_open=function(t,e,n,i){var _=this._get_tag_open_token(e);return!n.is_unformatted&&!n.is_content_unformatted||n.is_empty_element||e.type!==h.TAG_OPEN||0!==e.text.indexOf("]*)/),this.tag_check=n?n[1]:""):(n=e.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/),this.tag_check=n?n[1]:"",(e.text.startsWith("{{#>")||e.text.startsWith("{{~#>"))&&">"===this.tag_check[0]&&(">"===this.tag_check&&null!==e.next?this.tag_check=e.next.text.split(" ")[0]:this.tag_check=e.text.split(">")[1])),this.tag_check=this.tag_check.toLowerCase(),e.type===h.COMMENT&&(this.tag_complete=!0),this.is_start_tag="/"!==this.tag_check.charAt(0),this.tag_name=this.is_start_tag?this.tag_check:this.tag_check.substr(1),this.is_end_tag=!this.is_start_tag||e.closed&&"/>"===e.closed.text,t=2,"{"===this.tag_start_char&&3<=this.text.length&&"~"===this.text.charAt(2)&&(t=3),this.is_end_tag=this.is_end_tag||"{"===this.tag_start_char&&(this.text.length<3||/[^#\^]/.test(this.text.charAt(t)))):this.tag_complete=!0},c.prototype._get_tag_open_token=function(t){t=new o(this._tag_stack.get_parser_token(),t);return t.alignment_size=this._options.wrap_attributes_indent_size,t.is_end_tag=t.is_end_tag||a(t.tag_check,this._options.void_elements),t.is_empty_element=t.tag_complete||t.is_start_tag&&t.is_end_tag,t.is_unformatted=!t.tag_complete&&a(t.tag_check,this._options.unformatted),t.is_content_unformatted=!t.is_empty_element&&a(t.tag_check,this._options.content_unformatted),t.is_inline_element=a(t.tag_name,this._options.inline)||"{"===t.tag_start_char,t},c.prototype._set_tag_position=function(t,e,n,i,_){n.is_empty_element||(n.is_end_tag?n.start_tag_token=this._tag_stack.try_pop(n.tag_name):(this._do_optional_end_element(n)&&(n.is_inline_element||t.print_newline(!1)),this._tag_stack.record_tag(n),"script"!==n.tag_name&&"style"!==n.tag_name||n.is_unformatted||n.is_content_unformatted||(n.custom_beautifier_name=s(n.tag_check,e)))),a(n.tag_check,this._options.extra_liners)&&(t.print_newline(!1),t._output.just_added_blankline()||t.print_newline(!0)),n.is_empty_element?("{"===n.tag_start_char&&"else"===n.tag_check&&(this._tag_stack.indent_to_tag(["if","unless","each"]),n.indent_content=!0,t.current_line_has_match(/{{#if/)||t.print_newline(!1)),"!--"===n.tag_name&&_.type===h.TAG_CLOSE&&i.is_end_tag&&-1===n.text.indexOf("\n")||(n.is_inline_element||n.is_unformatted||t.print_newline(!1),this._calcluate_parent_multiline(t,n))):n.is_end_tag?(e=!1,e=(e=n.start_tag_token&&n.start_tag_token.multiline_content)||!n.is_inline_element&&!(i.is_inline_element||i.is_unformatted)&&!(_.type===h.TAG_CLOSE&&n.start_tag_token===i)&&"TK_CONTENT"!==_.type,(e=n.is_content_unformatted||n.is_unformatted?!1:e)&&t.print_newline(!1)):(n.indent_content=!n.custom_beautifier_name,"<"===n.tag_start_char&&( +"html"===n.tag_name?n.indent_content=this._options.indent_inner_html:"head"===n.tag_name?n.indent_content=this._options.indent_head_inner_html:"body"===n.tag_name&&(n.indent_content=this._options.indent_body_inner_html)),n.is_inline_element||n.is_unformatted||"TK_CONTENT"===_.type&&!n.is_content_unformatted||t.print_newline(!1),this._calcluate_parent_multiline(t,n))},c.prototype._calcluate_parent_multiline=function(t,e){!e.parent||!t._output.just_added_newline()||(e.is_inline_element||e.is_unformatted)&&e.parent.is_inline_element||(e.parent.multiline_content=!0)},i=["address","article","aside","blockquote","details","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"],u=["a","audio","del","ins","map","noscript","video"],c.prototype._do_optional_end_element=function(t){var e,n=null;if(!t.is_empty_element&&t.is_start_tag&&t.parent)return"body"===t.tag_name?n=n||this._tag_stack.try_pop("head"):"li"===t.tag_name?n=n||this._tag_stack.try_pop("li",["ol","ul"]):"dd"===t.tag_name||"dt"===t.tag_name?n=(n=n||this._tag_stack.try_pop("dt",["dl"]))||this._tag_stack.try_pop("dd",["dl"]):"p"===t.parent.tag_name&&-1!==i.indexOf(t.tag_name)?(e=t.parent.parent)&&-1!==u.indexOf(e.tag_name)||(n=n||this._tag_stack.try_pop("p")):"rp"===t.tag_name||"rt"===t.tag_name?n=(n=n||this._tag_stack.try_pop("rt",["ruby","rtc"]))||this._tag_stack.try_pop("rp",["ruby","rtc"]):"optgroup"===t.tag_name?n=n||this._tag_stack.try_pop("optgroup",["select"]):"option"===t.tag_name?n=n||this._tag_stack.try_pop("option",["select","datalist","optgroup"]):"colgroup"===t.tag_name?n=n||this._tag_stack.try_pop("caption",["table"]):"thead"===t.tag_name?n=(n=n||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]):"tbody"===t.tag_name||"tfoot"===t.tag_name?n=(n=(n=(n=n||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("thead",["table"]))||this._tag_stack.try_pop("tbody",["table"]):"tr"===t.tag_name?n=(n=(n=n||this._tag_stack.try_pop("caption",["table"]))||this._tag_stack.try_pop("colgroup",["table"]))||this._tag_stack.try_pop("tr",["table","thead","tbody","tfoot"]):"th"!==t.tag_name&&"td"!==t.tag_name||(n=(n=n||this._tag_stack.try_pop("td",["table","thead","tbody","tfoot","tr"]))||this._tag_stack.try_pop("th",["table","thead","tbody","tfoot","tr"])),t.parent=this._tag_stack.get_parser_token(),n},e.exports.Beautifier=c},function(t,e,n){var i=n(6).Options;function _(t){i.call(this,t,"html"),1===this.templating.length&&"auto"===this.templating[0]&&(this.templating=["django","erb","handlebars","php"]),this.indent_inner_html=this._get_boolean("indent_inner_html"),this.indent_body_inner_html=this._get_boolean("indent_body_inner_html",!0),this.indent_head_inner_html=this._get_boolean("indent_head_inner_html",!0),this.indent_handlebars=this._get_boolean("indent_handlebars",!0),this.wrap_attributes=this._get_selection("wrap_attributes",["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"]),this.wrap_attributes_indent_size=this._get_number("wrap_attributes_indent_size",this.indent_size),this.extra_liners=this._get_array("extra_liners",["head","body","/html"]),this.inline=this._get_array("inline",["a","abbr","area","audio","b","bdi","bdo","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","s","samp","select","small","span","strong","sub","sup","svg","template","textarea","time","u","var","video","wbr","text","acronym","big","strike","tt"]),this.void_elements=this._get_array("void_elements",["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr","!doctype","?xml","basefont","isindex"]),this.unformatted=this._get_array("unformatted",[]),this.content_unformatted=this._get_array("content_unformatted",["pre","textarea"]),this.unformatted_content_delimiter=this._get_characters("unformatted_content_delimiter"),this.indent_scripts=this._get_selection("indent_scripts",["normal","keep","separate"])}_.prototype=new i,t.exports.Options=_},function(t,o,e){var n=e(9).Tokenizer,i=e(9).TOKEN,_=e(13).Directives,s=e(14).TemplatablePattern,a=e(12).Pattern,u={TAG_OPEN:"TK_TAG_OPEN",TAG_CLOSE:"TK_TAG_CLOSE",ATTRIBUTE:"TK_ATTRIBUTE",EQUALS:"TK_EQUALS",VALUE:"TK_VALUE",COMMENT:"TK_COMMENT",TEXT:"TK_TEXT",UNKNOWN:"TK_UNKNOWN",START:i.START,RAW:i.RAW,EOF:i.EOF},r=new _(/<\!--/,/-->/),e=function(t,e){n.call(this,t,e),this._current_tag_name="",t=new s(this._input).read_options(this._options),e=new a(this._input),this.__patterns={word:t.until(/[\n\r\t <]/),single_quote:t.until_after(/'/),double_quote:t.until_after(/"/),attribute:t.until(/[\n\r\t =>]|\/>/),element_name:t.until(/[\n\r\t >\/]/),handlebars_comment:e.starting_with(/{{!--/).until_after(/--}}/),handlebars:e.starting_with(/{{/).until_after(/}}/),handlebars_open:e.until(/[\n\r\t }]/),handlebars_raw_close:e.until(/}}/),comment:e.starting_with(//),cdata:e.starting_with(//),conditional_comment:e.starting_with(//),processing:e.starting_with(/<\?/).until_after(/\?>/)},this._options.indent_handlebars&&(this.__patterns.word=this.__patterns.word.exclude("handlebars")),this._unformatted_content_delimiter=null,this._options.unformatted_content_delimiter&&(t=this._input.get_literal_regexp(this._options.unformatted_content_delimiter),this.__patterns.unformatted_content_delimiter=e.matching(t).until_after(t))};(e.prototype=new n)._is_comment=function(t){return!1},e.prototype._is_opening=function(t){return t.type===u.TAG_OPEN},e.prototype._is_closing=function(t,e){return t.type===u.TAG_CLOSE&&e&&((">"===t.text||"/>"===t.text +)&&"<"===e.text[0]||"}}"===t.text&&"{"===e.text[0]&&"{"===e.text[1])},e.prototype._reset=function(){this._current_tag_name=""},e.prototype._get_next_token=function(t,e){var n;return this._readWhitespace(),null===(n=this._input.peek())?this._create_token(u.EOF,""):this._read_open_handlebars(n,e)||this._read_attribute(n,t,e)||this._read_close(n,e)||this._read_raw_content(n,t,e)||this._read_content_word(n)||this._read_comment_or_cdata(n)||this._read_processing(n)||this._read_open(n,e)||this._create_token(u.UNKNOWN,this._input.next())},e.prototype._read_comment_or_cdata=function(t){var e=null,n=null,i=null;return"<"===t&&("!"===this._input.peek(1)&&((n=this.__patterns.comment.read())?(i=r.get_directives(n))&&"start"===i.ignore&&(n+=r.readIgnored(this._input)):n=this.__patterns.cdata.read()),n&&((e=this._create_token(u.COMMENT,n)).directives=i)),e},e.prototype._read_processing=function(t){var e=null,n=null;return"<"===t&&(n="!"!==(t=this._input.peek(1))&&"?"!==t?n:(n=this.__patterns.conditional_comment.read())||this.__patterns.processing.read())&&((e=this._create_token(u.COMMENT,n)).directives=null),e},e.prototype._read_open=function(t,e){var n=null,i=null;return e||"<"===t&&(n=this._input.next(),"/"===this._input.peek()&&(n+=this._input.next()),n+=this.__patterns.element_name.read(),i=this._create_token(u.TAG_OPEN,n)),i},e.prototype._read_open_handlebars=function(t,e){var n=null,i=null;return e||this._options.indent_handlebars&&"{"===t&&"{"===this._input.peek(1)&&(i="!"===this._input.peek(2)?(n=(n=this.__patterns.handlebars_comment.read())||this.__patterns.handlebars.read(),this._create_token(u.COMMENT,n)):(n=this.__patterns.handlebars_open.read(),this._create_token(u.TAG_OPEN,n))),i},e.prototype._read_close=function(t,e){var n=null,i=null;return e&&("<"===e.text[0]&&(">"===t||"/"===t&&">"===this._input.peek(1))?(n=this._input.next(),"/"===t&&(n+=this._input.next()),i=this._create_token(u.TAG_CLOSE,n)):"{"===e.text[0]&&"}"===t&&"}"===this._input.peek(1)&&(this._input.next(),this._input.next(),i=this._create_token(u.TAG_CLOSE,"}}"))),i},e.prototype._read_attribute=function(t,e,n){var i=null;return n&&"<"===n.text[0]&&("="===t?i=this._create_token(u.EQUALS,this._input.next()):'"'===t||"'"===t?(n=this._input.next(),n+=('"'===t?this.__patterns.double_quote:this.__patterns.single_quote).read(),i=this._create_token(u.VALUE,n)):(t=this.__patterns.attribute.read())&&(i=e.type===u.EQUALS?this._create_token(u.VALUE,t):this._create_token(u.ATTRIBUTE,t))),i},e.prototype._is_content_unformatted=function(t){return-1===this._options.void_elements.indexOf(t)&&(-1!==this._options.content_unformatted.indexOf(t)||-1!==this._options.unformatted.indexOf(t))},e.prototype._read_raw_content=function(t,e,n){var i="";if(n&&"{"===n.text[0])i=this.__patterns.handlebars_raw_close.read();else if(e.type===u.TAG_CLOSE&&"<"===e.opened.text[0]&&"/"!==e.text[0])if("script"===(n=e.opened.text.substr(1).toLowerCase())||"style"===n){if(e=this._read_comment_or_cdata(t))return e.type=u.TEXT,e;i=this._input.readUntil(new RegExp("","ig"))}else this._is_content_unformatted(n)&&(i=this._input.readUntil(new RegExp("","ig")));return i?this._create_token(u.TEXT,i):null},e.prototype._read_content_word=function(t){var e="";if(e=(e=this._options.unformatted_content_delimiter&&t===this._options.unformatted_content_delimiter[0]?this.__patterns.unformatted_content_delimiter.read():e)||this.__patterns.word.read())return this._create_token(u.TEXT,e)},t.exports.Tokenizer=e,t.exports.TOKEN=u}],i={};t=function _(t){var e=i[t];return e!==undefined||(e=i[t]={exports:{}},n[t](e,e.exports,_)),e.exports}(18),u=t}(),n=u,void 0!==r?(_=i=r).html_beautify=function(t,e){return n(t,e,i.js_beautify,_.css_beautify)}:"undefined"!=typeof window?window.html_beautify=function(t,e){return n(t,e,window.js_beautify,window.css_beautify)}:"undefined"!=typeof global&&(global.html_beautify=function(t,e){return n(t,e,global.js_beautify,global.css_beautify)})},"@VERSION@"); \ No newline at end of file diff --git a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify.js b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify.js index 9db40eb0564e7..8c0e70977d2bd 100644 --- a/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify.js +++ b/lib/editor/atto/plugins/html/yui/build/moodle-atto_html-beautify/moodle-atto_html-beautify.js @@ -143,8 +143,8 @@ var legacy_beautify_js; -var Beautifier = __webpack_require__(1).Beautifier, - Options = __webpack_require__(5).Options; +var Beautifier = (__webpack_require__(1).Beautifier), + Options = (__webpack_require__(5).Options); function js_beautify(js_source_text, options) { var beautifier = new Beautifier(js_source_text, options); @@ -191,14 +191,14 @@ module.exports.defaultOptions = function() { -var Output = __webpack_require__(2).Output; -var Token = __webpack_require__(3).Token; +var Output = (__webpack_require__(2).Output); +var Token = (__webpack_require__(3).Token); var acorn = __webpack_require__(4); -var Options = __webpack_require__(5).Options; -var Tokenizer = __webpack_require__(7).Tokenizer; -var line_starters = __webpack_require__(7).line_starters; -var positionable_operators = __webpack_require__(7).positionable_operators; -var TOKEN = __webpack_require__(7).TOKEN; +var Options = (__webpack_require__(5).Options); +var Tokenizer = (__webpack_require__(7).Tokenizer); +var line_starters = (__webpack_require__(7).line_starters); +var positionable_operators = (__webpack_require__(7).positionable_operators); +var TOKEN = (__webpack_require__(7).TOKEN); function in_array(what, arr) { @@ -348,12 +348,14 @@ Beautifier.prototype.create_flags = function(flags_base, mode) { inline_frame: false, if_block: false, else_block: false, + class_start_block: false, // class A { INSIDE HERE } or class B extends C { INSIDE HERE } do_block: false, do_while: false, import_block: false, in_case_statement: false, // switch(..){ INSIDE HERE } in_case: false, // we're on the exact line with "case 0:" case_body: false, // the indented case-action block + case_block: false, // the indented case-action block is wrapped with {} indentation_level: next_indent_level, alignment: 0, line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level, @@ -759,6 +761,8 @@ Beautifier.prototype.handle_start_expr = function(current_token) { (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) { this._output.space_before_token = true; } + } else if (this._flags.parent && this._flags.parent.class_start_block) { + this._output.space_before_token = true; } } } else { @@ -853,10 +857,10 @@ Beautifier.prototype.handle_start_block = function(current_token) { )) { // We don't support TypeScript,but we didn't break it for a very long time. // We'll try to keep not breaking it. - if (!in_array(this._last_last_text, ['class', 'interface'])) { - this.set_mode(MODE.ObjectLiteral); - } else { + if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) { this.set_mode(MODE.BlockStatement); + } else { + this.set_mode(MODE.ObjectLiteral); } } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') { // arrow function: (param1, paramN) => { statements } @@ -873,6 +877,12 @@ Beautifier.prototype.handle_start_block = function(current_token) { this.set_mode(MODE.BlockStatement); } + if (this._flags.last_token) { + if (reserved_array(this._flags.last_token.previous, ['class', 'extends'])) { + this._flags.class_start_block = true; + } + } + var empty_braces = !next_token.comments_before && next_token.text === '}'; var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' && this._flags.last_token.type === TOKEN.END_EXPR; @@ -972,7 +982,7 @@ Beautifier.prototype.handle_word = function(current_token) { if (current_token.type === TOKEN.RESERVED) { if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) { current_token.type = TOKEN.WORD; - } else if (current_token.text === 'import' && this._tokens.peek().text === '(') { + } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) { current_token.type = TOKEN.WORD; } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) { current_token.type = TOKEN.WORD; @@ -1032,7 +1042,7 @@ Beautifier.prototype.handle_word = function(current_token) { if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) { this.print_newline(); - if (this._flags.last_token.type !== TOKEN.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) { + if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) { // switch cases following one another this.deindent(); } @@ -1313,13 +1323,6 @@ Beautifier.prototype.handle_operator = function(current_token) { this.handle_whitespace_and_comments(current_token, preserve_statement_flags); } - if (reserved_array(this._flags.last_token, special_words)) { - // "return" had a special handling in TK_WORD. Now we need to return the favor - this._output.space_before_token = true; - this.print_token(current_token); - return; - } - // hack for actionscript's import .*; if (current_token.text === '*' && this._flags.last_token.type === TOKEN.DOT) { this.print_token(current_token); @@ -1346,7 +1349,9 @@ Beautifier.prototype.handle_operator = function(current_token) { if (this._tokens.peek().type !== TOKEN.START_BLOCK) { this.indent(); this.print_newline(); + this._flags.case_block = false; } else { + this._flags.case_block = true; this._output.space_before_token = true; } return; @@ -1444,8 +1449,12 @@ Beautifier.prototype.handle_operator = function(current_token) { // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1 // if there is a newline between -- or ++ and anything else we should preserve it. - if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) { - this.print_newline(false, true); + if (current_token.newlines && (current_token.text === '--' || current_token.text === '++' || current_token.text === '~')) { + var new_line_needed = reserved_array(this._flags.last_token, special_words) && current_token.newlines; + if (new_line_needed && (this._previous_flags.if_block || this._previous_flags.else_block)) { + this.restore_mode(); + } + this.print_newline(new_line_needed, true); } if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) { @@ -1585,6 +1594,10 @@ Beautifier.prototype.handle_dot = function(current_token) { this.handle_whitespace_and_comments(current_token, true); } + if (this._flags.last_token.text.match('^[0-9]+$')) { + this._output.space_before_token = true; + } + if (reserved_array(this._flags.last_token, special_words)) { this._output.space_before_token = false; } else { @@ -2204,7 +2217,7 @@ exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline']; @@ -2502,13 +2515,13 @@ module.exports.mergeOpts = _mergeOpts; -var InputScanner = __webpack_require__(8).InputScanner; -var BaseTokenizer = __webpack_require__(9).Tokenizer; -var BASETOKEN = __webpack_require__(9).TOKEN; -var Directives = __webpack_require__(13).Directives; +var InputScanner = (__webpack_require__(8).InputScanner); +var BaseTokenizer = (__webpack_require__(9).Tokenizer); +var BASETOKEN = (__webpack_require__(9).TOKEN); +var Directives = (__webpack_require__(13).Directives); var acorn = __webpack_require__(4); -var Pattern = __webpack_require__(12).Pattern; -var TemplatablePattern = __webpack_require__(14).TemplatablePattern; +var Pattern = (__webpack_require__(12).Pattern); +var TemplatablePattern = (__webpack_require__(14).TemplatablePattern); function in_array(what, arr) { @@ -2548,7 +2561,7 @@ var digit = /[0-9]/; var dot_pattern = /[^\d\.]/; var positionable_operators = ( - ">>> === !== " + + ">>> === !== &&= ??= ||= " + "<< && >= ** != == <= >> || ?? |> " + "< / - + > : & % ? ^ | *").split(' '); @@ -2556,7 +2569,7 @@ var positionable_operators = ( // Also, you must update possitionable operators separately from punct var punct = ">>>= " + - "... >>= <<= === >>> !== **= " + + "... >>= <<= === >>> !== **= &&= ??= ||= " + "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " + "= ! ? > < : / ^ - + * & % ~ |"; @@ -2569,7 +2582,7 @@ var punct_pattern = new RegExp(punct); // words which should always start on new line. var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(','); -var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']); +var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as', 'class', 'extends']); var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$'); // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g; @@ -2600,7 +2613,7 @@ var Tokenizer = function(input_string, options) { html_comment_end: pattern_reader.matching(/-->/), include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak), shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak), - xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\]|)(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), + xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/), single_quote: templatable.until(/['\\\n\r\u2028\u2029]/), double_quote: templatable.until(/["\\\n\r\u2028\u2029]/), template_text: templatable.until(/[`\\$]/), @@ -2660,7 +2673,8 @@ Tokenizer.prototype._read_word = function(previous_token) { if (!(previous_token.type === TOKEN.DOT || (previous_token.type === TOKEN.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) && reserved_word_pattern.test(resulting_string)) { - if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators + if ((resulting_string === 'in' || resulting_string === 'of') && + (previous_token.type === TOKEN.WORD || previous_token.type === TOKEN.STRING)) { // hack for 'in' and 'of' operators return this._create_token(TOKEN.OPERATOR, resulting_string); } return this._create_token(TOKEN.RESERVED, resulting_string); @@ -3272,10 +3286,10 @@ module.exports.InputScanner = InputScanner; -var InputScanner = __webpack_require__(8).InputScanner; -var Token = __webpack_require__(3).Token; -var TokenStream = __webpack_require__(10).TokenStream; -var WhitespacePattern = __webpack_require__(11).WhitespacePattern; +var InputScanner = (__webpack_require__(8).InputScanner); +var Token = (__webpack_require__(3).Token); +var TokenStream = (__webpack_require__(10).TokenStream); +var WhitespacePattern = (__webpack_require__(11).WhitespacePattern); var TOKEN = { START: 'TK_START', @@ -3502,7 +3516,7 @@ module.exports.TokenStream = TokenStream; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); function WhitespacePattern(input_scanner, parent) { Pattern.call(this, input_scanner, parent); @@ -3781,7 +3795,7 @@ module.exports.Directives = Directives; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); var template_names = { @@ -5027,8 +5041,8 @@ module.exports.Directives = Directives; -var Beautifier = __webpack_require__(16).Beautifier, - Options = __webpack_require__(17).Options; +var Beautifier = (__webpack_require__(16).Beautifier), + Options = (__webpack_require__(17).Options); function css_beautify(source_text, options) { var beautifier = new Beautifier(source_text, options); @@ -5075,10 +5089,10 @@ module.exports.defaultOptions = function() { -var Options = __webpack_require__(17).Options; -var Output = __webpack_require__(2).Output; -var InputScanner = __webpack_require__(8).InputScanner; -var Directives = __webpack_require__(13).Directives; +var Options = (__webpack_require__(17).Options); +var Output = (__webpack_require__(2).Output); +var InputScanner = (__webpack_require__(8).InputScanner); +var Directives = (__webpack_require__(13).Directives); var directives_core = new Directives(/\/\*/, /\*\//); @@ -5114,6 +5128,10 @@ function Beautifier(source_text, options) { "@supports": true, "@document": true }; + this.NON_SEMICOLON_NEWLINE_PROPERTY = [ + "grid-template-areas", + "grid-template" + ]; } @@ -5238,7 +5256,9 @@ Beautifier.prototype.beautify = function() { var enteringConditionalGroup = false; var insideAtExtend = false; var insideAtImport = false; + var insideScssMap = false; var topCharacter = this._ch; + var insideNonSemiColonValues = false; var whitespace; var isAfterSpace; var previous_ch; @@ -5290,7 +5310,7 @@ Beautifier.prototype.beautify = function() { // Ensures any new lines following the comment are preserved this.eatWhitespace(true); - } else if (this._ch === '@') { + } else if (this._ch === '@' || this._ch === '$') { this.preserveSingleSpace(isAfterSpace); // deal with less propery mixins @{...} @@ -5361,7 +5381,12 @@ Beautifier.prototype.beautify = function() { this.indent(); this._output.set_indent(this._indentLevel); } else { - this.indent(); + // inside mixin and first param is object + if (previous_ch === '(') { + this._output.space_before_token = false; + } else if (previous_ch !== ',') { + this.indent(); + } this.print_string(this._ch); } @@ -5393,7 +5418,21 @@ Beautifier.prototype.beautify = function() { this._output.add_new_line(true); } } + if (this._input.peek() === ')') { + this._output.trim(true); + if (this._options.brace_style === "expand") { + this._output.add_new_line(true); + } + } } else if (this._ch === ":") { + + for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) { + if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) { + insideNonSemiColonValues = true; + break; + } + } + if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { // 'property: value' delimiter // which could be in a conditional group query @@ -5422,10 +5461,12 @@ Beautifier.prototype.beautify = function() { } } } else if (this._ch === '"' || this._ch === '\'') { - this.preserveSingleSpace(isAfterSpace); + var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\''; + this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace); this.print_string(this._ch + this.eatString(this._ch)); this.eatWhitespace(true); } else if (this._ch === ';') { + insideNonSemiColonValues = false; if (parenLevel === 0) { if (insidePropertyValue) { this.outdent(); @@ -5465,22 +5506,39 @@ Beautifier.prototype.beautify = function() { } } } else { - this.preserveSingleSpace(isAfterSpace); + var space_needed = false; + if (this._input.lookBack("with")) { + // look back is not an accurate solution, we need tokens to confirm without whitespaces + space_needed = true; + } + this.preserveSingleSpace(isAfterSpace || space_needed); this.print_string(this._ch); - this.eatWhitespace(); - parenLevel++; - this.indent(); + + // handle scss/sass map + if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) { + this._output.add_new_line(); + insideScssMap = true; + } else { + this.eatWhitespace(); + parenLevel++; + this.indent(); + } } } else if (this._ch === ')') { if (parenLevel) { parenLevel--; this.outdent(); } + if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) { + insideScssMap = false; + this.outdent(); + this._output.add_new_line(); + } this.print_string(this._ch); } else if (this._ch === ',') { this.print_string(this._ch); this.eatWhitespace(true); - if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { + if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) { this._output.add_new_line(); } else { this._output.space_before_token = true; @@ -5511,11 +5569,16 @@ Beautifier.prototype.beautify = function() { this._ch = ''; } } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important - this.print_string(' '); + this._output.space_before_token = true; this.print_string(this._ch); } else { - this.preserveSingleSpace(isAfterSpace); + var preserveAfterSpace = previous_ch === '"' || previous_ch === '\''; + this.preserveSingleSpace(preserveAfterSpace || isAfterSpace); this.print_string(this._ch); + + if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) { + this._output.add_new_line(); + } } } @@ -5561,7 +5624,7 @@ module.exports.Beautifier = Beautifier; -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); function Options(options) { BaseOptions.call(this, options, 'css'); @@ -6649,10 +6712,10 @@ module.exports.InputScanner = InputScanner; -var InputScanner = __webpack_require__(8).InputScanner; -var Token = __webpack_require__(3).Token; -var TokenStream = __webpack_require__(10).TokenStream; -var WhitespacePattern = __webpack_require__(11).WhitespacePattern; +var InputScanner = (__webpack_require__(8).InputScanner); +var Token = (__webpack_require__(3).Token); +var TokenStream = (__webpack_require__(10).TokenStream); +var WhitespacePattern = (__webpack_require__(11).WhitespacePattern); var TOKEN = { START: 'TK_START', @@ -6879,7 +6942,7 @@ module.exports.TokenStream = TokenStream; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); function WhitespacePattern(input_scanner, parent) { Pattern.call(this, input_scanner, parent); @@ -7158,7 +7221,7 @@ module.exports.Directives = Directives; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); var template_names = { @@ -7378,8 +7441,8 @@ module.exports.TemplatablePattern = TemplatablePattern; -var Beautifier = __webpack_require__(19).Beautifier, - Options = __webpack_require__(20).Options; +var Beautifier = (__webpack_require__(19).Beautifier), + Options = (__webpack_require__(20).Options); function style_html(html_source, options, js_beautify, css_beautify) { var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify); @@ -7426,10 +7489,10 @@ module.exports.defaultOptions = function() { -var Options = __webpack_require__(20).Options; -var Output = __webpack_require__(2).Output; -var Tokenizer = __webpack_require__(21).Tokenizer; -var TOKEN = __webpack_require__(21).TOKEN; +var Options = (__webpack_require__(20).Options); +var Output = (__webpack_require__(2).Output); +var Tokenizer = (__webpack_require__(21).Tokenizer); +var TOKEN = (__webpack_require__(21).TOKEN); var lineBreak = /\r\n|[\r\n]/; var allLineBreaks = /\r\n|[\r\n]/g; @@ -8005,14 +8068,19 @@ var TagOpenParserToken = function(parent, raw_token) { tag_check_match = raw_token.text.match(/^<([^\s>]*)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; } else { - tag_check_match = raw_token.text.match(/^{{(?:[\^]|#\*?)?([^\s}]+)/); + tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; - // handle "{{#> myPartial}} - if (raw_token.text === '{{#>' && this.tag_check === '>' && raw_token.next !== null) { - this.tag_check = raw_token.next.text; + // handle "{{#> myPartial}}" or "{{~#> myPartial}}" + if ((raw_token.text.startsWith('{{#>') || raw_token.text.startsWith('{{~#>')) && this.tag_check[0] === '>') { + if (this.tag_check === '>' && raw_token.next !== null) { + this.tag_check = raw_token.next.text.split(' ')[0]; + } else { + this.tag_check = raw_token.text.split('>')[1]; + } } } + this.tag_check = this.tag_check.toLowerCase(); if (raw_token.type === TOKEN.COMMENT) { @@ -8024,9 +8092,17 @@ var TagOpenParserToken = function(parent, raw_token) { this.is_end_tag = !this.is_start_tag || (raw_token.closed && raw_token.closed.text === '/>'); + // if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2 + var handlebar_starts = 2; + if (this.tag_start_char === '{' && this.text.length >= 3) { + if (this.text.charAt(2) === '~') { + handlebar_starts = 3; + } + } + // handlebars tags that don't start with # or ^ are single_tags, and so also start and end. this.is_end_tag = this.is_end_tag || - (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2))))); + (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts))))); } }; @@ -8297,7 +8373,7 @@ module.exports.Beautifier = Beautifier; -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); function Options(options) { BaseOptions.call(this, options, 'html'); @@ -8394,11 +8470,11 @@ module.exports.Options = Options; -var BaseTokenizer = __webpack_require__(9).Tokenizer; -var BASETOKEN = __webpack_require__(9).TOKEN; -var Directives = __webpack_require__(13).Directives; -var TemplatablePattern = __webpack_require__(14).TemplatablePattern; -var Pattern = __webpack_require__(12).Pattern; +var BaseTokenizer = (__webpack_require__(9).Tokenizer); +var BASETOKEN = (__webpack_require__(9).TOKEN); +var Directives = (__webpack_require__(13).Directives); +var TemplatablePattern = (__webpack_require__(14).TemplatablePattern); +var Pattern = (__webpack_require__(12).Pattern); var TOKEN = { TAG_OPEN: 'TK_TAG_OPEN', diff --git a/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-css.js b/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-css.js index 79f65643de2d1..aa7d008bd8a43 100644 --- a/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-css.js +++ b/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-css.js @@ -1003,8 +1003,8 @@ module.exports.Directives = Directives; -var Beautifier = __webpack_require__(16).Beautifier, - Options = __webpack_require__(17).Options; +var Beautifier = (__webpack_require__(16).Beautifier), + Options = (__webpack_require__(17).Options); function css_beautify(source_text, options) { var beautifier = new Beautifier(source_text, options); @@ -1051,10 +1051,10 @@ module.exports.defaultOptions = function() { -var Options = __webpack_require__(17).Options; -var Output = __webpack_require__(2).Output; -var InputScanner = __webpack_require__(8).InputScanner; -var Directives = __webpack_require__(13).Directives; +var Options = (__webpack_require__(17).Options); +var Output = (__webpack_require__(2).Output); +var InputScanner = (__webpack_require__(8).InputScanner); +var Directives = (__webpack_require__(13).Directives); var directives_core = new Directives(/\/\*/, /\*\//); @@ -1090,6 +1090,10 @@ function Beautifier(source_text, options) { "@supports": true, "@document": true }; + this.NON_SEMICOLON_NEWLINE_PROPERTY = [ + "grid-template-areas", + "grid-template" + ]; } @@ -1214,7 +1218,9 @@ Beautifier.prototype.beautify = function() { var enteringConditionalGroup = false; var insideAtExtend = false; var insideAtImport = false; + var insideScssMap = false; var topCharacter = this._ch; + var insideNonSemiColonValues = false; var whitespace; var isAfterSpace; var previous_ch; @@ -1266,7 +1272,7 @@ Beautifier.prototype.beautify = function() { // Ensures any new lines following the comment are preserved this.eatWhitespace(true); - } else if (this._ch === '@') { + } else if (this._ch === '@' || this._ch === '$') { this.preserveSingleSpace(isAfterSpace); // deal with less propery mixins @{...} @@ -1337,7 +1343,12 @@ Beautifier.prototype.beautify = function() { this.indent(); this._output.set_indent(this._indentLevel); } else { - this.indent(); + // inside mixin and first param is object + if (previous_ch === '(') { + this._output.space_before_token = false; + } else if (previous_ch !== ',') { + this.indent(); + } this.print_string(this._ch); } @@ -1369,7 +1380,21 @@ Beautifier.prototype.beautify = function() { this._output.add_new_line(true); } } + if (this._input.peek() === ')') { + this._output.trim(true); + if (this._options.brace_style === "expand") { + this._output.add_new_line(true); + } + } } else if (this._ch === ":") { + + for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) { + if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) { + insideNonSemiColonValues = true; + break; + } + } + if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { // 'property: value' delimiter // which could be in a conditional group query @@ -1398,10 +1423,12 @@ Beautifier.prototype.beautify = function() { } } } else if (this._ch === '"' || this._ch === '\'') { - this.preserveSingleSpace(isAfterSpace); + var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\''; + this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace); this.print_string(this._ch + this.eatString(this._ch)); this.eatWhitespace(true); } else if (this._ch === ';') { + insideNonSemiColonValues = false; if (parenLevel === 0) { if (insidePropertyValue) { this.outdent(); @@ -1441,22 +1468,39 @@ Beautifier.prototype.beautify = function() { } } } else { - this.preserveSingleSpace(isAfterSpace); + var space_needed = false; + if (this._input.lookBack("with")) { + // look back is not an accurate solution, we need tokens to confirm without whitespaces + space_needed = true; + } + this.preserveSingleSpace(isAfterSpace || space_needed); this.print_string(this._ch); - this.eatWhitespace(); - parenLevel++; - this.indent(); + + // handle scss/sass map + if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) { + this._output.add_new_line(); + insideScssMap = true; + } else { + this.eatWhitespace(); + parenLevel++; + this.indent(); + } } } else if (this._ch === ')') { if (parenLevel) { parenLevel--; this.outdent(); } + if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) { + insideScssMap = false; + this.outdent(); + this._output.add_new_line(); + } this.print_string(this._ch); } else if (this._ch === ',') { this.print_string(this._ch); this.eatWhitespace(true); - if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { + if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) { this._output.add_new_line(); } else { this._output.space_before_token = true; @@ -1487,11 +1531,16 @@ Beautifier.prototype.beautify = function() { this._ch = ''; } } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important - this.print_string(' '); + this._output.space_before_token = true; this.print_string(this._ch); } else { - this.preserveSingleSpace(isAfterSpace); + var preserveAfterSpace = previous_ch === '"' || previous_ch === '\''; + this.preserveSingleSpace(preserveAfterSpace || isAfterSpace); this.print_string(this._ch); + + if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) { + this._output.add_new_line(); + } } } @@ -1537,7 +1586,7 @@ module.exports.Beautifier = Beautifier; -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); function Options(options) { BaseOptions.call(this, options, 'css'); diff --git a/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-html.js b/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-html.js index f69c07e643530..e5e029a4e7cc1 100644 --- a/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-html.js +++ b/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify-html.js @@ -999,10 +999,10 @@ module.exports.InputScanner = InputScanner; -var InputScanner = __webpack_require__(8).InputScanner; -var Token = __webpack_require__(3).Token; -var TokenStream = __webpack_require__(10).TokenStream; -var WhitespacePattern = __webpack_require__(11).WhitespacePattern; +var InputScanner = (__webpack_require__(8).InputScanner); +var Token = (__webpack_require__(3).Token); +var TokenStream = (__webpack_require__(10).TokenStream); +var WhitespacePattern = (__webpack_require__(11).WhitespacePattern); var TOKEN = { START: 'TK_START', @@ -1229,7 +1229,7 @@ module.exports.TokenStream = TokenStream; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); function WhitespacePattern(input_scanner, parent) { Pattern.call(this, input_scanner, parent); @@ -1508,7 +1508,7 @@ module.exports.Directives = Directives; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); var template_names = { @@ -1728,8 +1728,8 @@ module.exports.TemplatablePattern = TemplatablePattern; -var Beautifier = __webpack_require__(19).Beautifier, - Options = __webpack_require__(20).Options; +var Beautifier = (__webpack_require__(19).Beautifier), + Options = (__webpack_require__(20).Options); function style_html(html_source, options, js_beautify, css_beautify) { var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify); @@ -1776,10 +1776,10 @@ module.exports.defaultOptions = function() { -var Options = __webpack_require__(20).Options; -var Output = __webpack_require__(2).Output; -var Tokenizer = __webpack_require__(21).Tokenizer; -var TOKEN = __webpack_require__(21).TOKEN; +var Options = (__webpack_require__(20).Options); +var Output = (__webpack_require__(2).Output); +var Tokenizer = (__webpack_require__(21).Tokenizer); +var TOKEN = (__webpack_require__(21).TOKEN); var lineBreak = /\r\n|[\r\n]/; var allLineBreaks = /\r\n|[\r\n]/g; @@ -2355,14 +2355,19 @@ var TagOpenParserToken = function(parent, raw_token) { tag_check_match = raw_token.text.match(/^<([^\s>]*)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; } else { - tag_check_match = raw_token.text.match(/^{{(?:[\^]|#\*?)?([^\s}]+)/); + tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/); this.tag_check = tag_check_match ? tag_check_match[1] : ''; - // handle "{{#> myPartial}} - if (raw_token.text === '{{#>' && this.tag_check === '>' && raw_token.next !== null) { - this.tag_check = raw_token.next.text; + // handle "{{#> myPartial}}" or "{{~#> myPartial}}" + if ((raw_token.text.startsWith('{{#>') || raw_token.text.startsWith('{{~#>')) && this.tag_check[0] === '>') { + if (this.tag_check === '>' && raw_token.next !== null) { + this.tag_check = raw_token.next.text.split(' ')[0]; + } else { + this.tag_check = raw_token.text.split('>')[1]; + } } } + this.tag_check = this.tag_check.toLowerCase(); if (raw_token.type === TOKEN.COMMENT) { @@ -2374,9 +2379,17 @@ var TagOpenParserToken = function(parent, raw_token) { this.is_end_tag = !this.is_start_tag || (raw_token.closed && raw_token.closed.text === '/>'); + // if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2 + var handlebar_starts = 2; + if (this.tag_start_char === '{' && this.text.length >= 3) { + if (this.text.charAt(2) === '~') { + handlebar_starts = 3; + } + } + // handlebars tags that don't start with # or ^ are single_tags, and so also start and end. this.is_end_tag = this.is_end_tag || - (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2))))); + (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts))))); } }; @@ -2647,7 +2660,7 @@ module.exports.Beautifier = Beautifier; -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); function Options(options) { BaseOptions.call(this, options, 'html'); @@ -2744,11 +2757,11 @@ module.exports.Options = Options; -var BaseTokenizer = __webpack_require__(9).Tokenizer; -var BASETOKEN = __webpack_require__(9).TOKEN; -var Directives = __webpack_require__(13).Directives; -var TemplatablePattern = __webpack_require__(14).TemplatablePattern; -var Pattern = __webpack_require__(12).Pattern; +var BaseTokenizer = (__webpack_require__(9).Tokenizer); +var BASETOKEN = (__webpack_require__(9).TOKEN); +var Directives = (__webpack_require__(13).Directives); +var TemplatablePattern = (__webpack_require__(14).TemplatablePattern); +var Pattern = (__webpack_require__(12).Pattern); var TOKEN = { TAG_OPEN: 'TK_TAG_OPEN', diff --git a/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify.js b/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify.js index 3ddd92b8db016..d02605dca719d 100644 --- a/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify.js +++ b/lib/editor/atto/plugins/html/yui/src/beautify/js/beautify.js @@ -125,8 +125,8 @@ var legacy_beautify_js; -var Beautifier = __webpack_require__(1).Beautifier, - Options = __webpack_require__(5).Options; +var Beautifier = (__webpack_require__(1).Beautifier), + Options = (__webpack_require__(5).Options); function js_beautify(js_source_text, options) { var beautifier = new Beautifier(js_source_text, options); @@ -173,14 +173,14 @@ module.exports.defaultOptions = function() { -var Output = __webpack_require__(2).Output; -var Token = __webpack_require__(3).Token; +var Output = (__webpack_require__(2).Output); +var Token = (__webpack_require__(3).Token); var acorn = __webpack_require__(4); -var Options = __webpack_require__(5).Options; -var Tokenizer = __webpack_require__(7).Tokenizer; -var line_starters = __webpack_require__(7).line_starters; -var positionable_operators = __webpack_require__(7).positionable_operators; -var TOKEN = __webpack_require__(7).TOKEN; +var Options = (__webpack_require__(5).Options); +var Tokenizer = (__webpack_require__(7).Tokenizer); +var line_starters = (__webpack_require__(7).line_starters); +var positionable_operators = (__webpack_require__(7).positionable_operators); +var TOKEN = (__webpack_require__(7).TOKEN); function in_array(what, arr) { @@ -330,12 +330,14 @@ Beautifier.prototype.create_flags = function(flags_base, mode) { inline_frame: false, if_block: false, else_block: false, + class_start_block: false, // class A { INSIDE HERE } or class B extends C { INSIDE HERE } do_block: false, do_while: false, import_block: false, in_case_statement: false, // switch(..){ INSIDE HERE } in_case: false, // we're on the exact line with "case 0:" case_body: false, // the indented case-action block + case_block: false, // the indented case-action block is wrapped with {} indentation_level: next_indent_level, alignment: 0, line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level, @@ -741,6 +743,8 @@ Beautifier.prototype.handle_start_expr = function(current_token) { (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) { this._output.space_before_token = true; } + } else if (this._flags.parent && this._flags.parent.class_start_block) { + this._output.space_before_token = true; } } } else { @@ -835,10 +839,10 @@ Beautifier.prototype.handle_start_block = function(current_token) { )) { // We don't support TypeScript,but we didn't break it for a very long time. // We'll try to keep not breaking it. - if (!in_array(this._last_last_text, ['class', 'interface'])) { - this.set_mode(MODE.ObjectLiteral); - } else { + if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) { this.set_mode(MODE.BlockStatement); + } else { + this.set_mode(MODE.ObjectLiteral); } } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') { // arrow function: (param1, paramN) => { statements } @@ -855,6 +859,12 @@ Beautifier.prototype.handle_start_block = function(current_token) { this.set_mode(MODE.BlockStatement); } + if (this._flags.last_token) { + if (reserved_array(this._flags.last_token.previous, ['class', 'extends'])) { + this._flags.class_start_block = true; + } + } + var empty_braces = !next_token.comments_before && next_token.text === '}'; var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' && this._flags.last_token.type === TOKEN.END_EXPR; @@ -954,7 +964,7 @@ Beautifier.prototype.handle_word = function(current_token) { if (current_token.type === TOKEN.RESERVED) { if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) { current_token.type = TOKEN.WORD; - } else if (current_token.text === 'import' && this._tokens.peek().text === '(') { + } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) { current_token.type = TOKEN.WORD; } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) { current_token.type = TOKEN.WORD; @@ -1014,7 +1024,7 @@ Beautifier.prototype.handle_word = function(current_token) { if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) { this.print_newline(); - if (this._flags.last_token.type !== TOKEN.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) { + if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) { // switch cases following one another this.deindent(); } @@ -1295,13 +1305,6 @@ Beautifier.prototype.handle_operator = function(current_token) { this.handle_whitespace_and_comments(current_token, preserve_statement_flags); } - if (reserved_array(this._flags.last_token, special_words)) { - // "return" had a special handling in TK_WORD. Now we need to return the favor - this._output.space_before_token = true; - this.print_token(current_token); - return; - } - // hack for actionscript's import .*; if (current_token.text === '*' && this._flags.last_token.type === TOKEN.DOT) { this.print_token(current_token); @@ -1328,7 +1331,9 @@ Beautifier.prototype.handle_operator = function(current_token) { if (this._tokens.peek().type !== TOKEN.START_BLOCK) { this.indent(); this.print_newline(); + this._flags.case_block = false; } else { + this._flags.case_block = true; this._output.space_before_token = true; } return; @@ -1426,8 +1431,12 @@ Beautifier.prototype.handle_operator = function(current_token) { // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1 // if there is a newline between -- or ++ and anything else we should preserve it. - if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) { - this.print_newline(false, true); + if (current_token.newlines && (current_token.text === '--' || current_token.text === '++' || current_token.text === '~')) { + var new_line_needed = reserved_array(this._flags.last_token, special_words) && current_token.newlines; + if (new_line_needed && (this._previous_flags.if_block || this._previous_flags.else_block)) { + this.restore_mode(); + } + this.print_newline(new_line_needed, true); } if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) { @@ -1567,6 +1576,10 @@ Beautifier.prototype.handle_dot = function(current_token) { this.handle_whitespace_and_comments(current_token, true); } + if (this._flags.last_token.text.match('^[0-9]+$')) { + this._output.space_before_token = true; + } + if (reserved_array(this._flags.last_token, special_words)) { this._output.space_before_token = false; } else { @@ -2186,7 +2199,7 @@ exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g'); -var BaseOptions = __webpack_require__(6).Options; +var BaseOptions = (__webpack_require__(6).Options); var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline']; @@ -2484,13 +2497,13 @@ module.exports.mergeOpts = _mergeOpts; -var InputScanner = __webpack_require__(8).InputScanner; -var BaseTokenizer = __webpack_require__(9).Tokenizer; -var BASETOKEN = __webpack_require__(9).TOKEN; -var Directives = __webpack_require__(13).Directives; +var InputScanner = (__webpack_require__(8).InputScanner); +var BaseTokenizer = (__webpack_require__(9).Tokenizer); +var BASETOKEN = (__webpack_require__(9).TOKEN); +var Directives = (__webpack_require__(13).Directives); var acorn = __webpack_require__(4); -var Pattern = __webpack_require__(12).Pattern; -var TemplatablePattern = __webpack_require__(14).TemplatablePattern; +var Pattern = (__webpack_require__(12).Pattern); +var TemplatablePattern = (__webpack_require__(14).TemplatablePattern); function in_array(what, arr) { @@ -2530,7 +2543,7 @@ var digit = /[0-9]/; var dot_pattern = /[^\d\.]/; var positionable_operators = ( - ">>> === !== " + + ">>> === !== &&= ??= ||= " + "<< && >= ** != == <= >> || ?? |> " + "< / - + > : & % ? ^ | *").split(' '); @@ -2538,7 +2551,7 @@ var positionable_operators = ( // Also, you must update possitionable operators separately from punct var punct = ">>>= " + - "... >>= <<= === >>> !== **= " + + "... >>= <<= === >>> !== **= &&= ??= ||= " + "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " + "= ! ? > < : / ^ - + * & % ~ |"; @@ -2551,7 +2564,7 @@ var punct_pattern = new RegExp(punct); // words which should always start on new line. var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(','); -var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']); +var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as', 'class', 'extends']); var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$'); // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g; @@ -2582,7 +2595,7 @@ var Tokenizer = function(input_string, options) { html_comment_end: pattern_reader.matching(/-->/), include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak), shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak), - xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\]|)(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), + xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/), single_quote: templatable.until(/['\\\n\r\u2028\u2029]/), double_quote: templatable.until(/["\\\n\r\u2028\u2029]/), template_text: templatable.until(/[`\\$]/), @@ -2642,7 +2655,8 @@ Tokenizer.prototype._read_word = function(previous_token) { if (!(previous_token.type === TOKEN.DOT || (previous_token.type === TOKEN.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) && reserved_word_pattern.test(resulting_string)) { - if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators + if ((resulting_string === 'in' || resulting_string === 'of') && + (previous_token.type === TOKEN.WORD || previous_token.type === TOKEN.STRING)) { // hack for 'in' and 'of' operators return this._create_token(TOKEN.OPERATOR, resulting_string); } return this._create_token(TOKEN.RESERVED, resulting_string); @@ -3254,10 +3268,10 @@ module.exports.InputScanner = InputScanner; -var InputScanner = __webpack_require__(8).InputScanner; -var Token = __webpack_require__(3).Token; -var TokenStream = __webpack_require__(10).TokenStream; -var WhitespacePattern = __webpack_require__(11).WhitespacePattern; +var InputScanner = (__webpack_require__(8).InputScanner); +var Token = (__webpack_require__(3).Token); +var TokenStream = (__webpack_require__(10).TokenStream); +var WhitespacePattern = (__webpack_require__(11).WhitespacePattern); var TOKEN = { START: 'TK_START', @@ -3484,7 +3498,7 @@ module.exports.TokenStream = TokenStream; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); function WhitespacePattern(input_scanner, parent) { Pattern.call(this, input_scanner, parent); @@ -3763,7 +3777,7 @@ module.exports.Directives = Directives; -var Pattern = __webpack_require__(12).Pattern; +var Pattern = (__webpack_require__(12).Pattern); var template_names = { diff --git a/lib/editor/atto/plugins/html/yui/src/beautify/readme_moodle.txt b/lib/editor/atto/plugins/html/yui/src/beautify/readme_moodle.txt index 29fc6d1395927..50583795bcd44 100644 --- a/lib/editor/atto/plugins/html/yui/src/beautify/readme_moodle.txt +++ b/lib/editor/atto/plugins/html/yui/src/beautify/readme_moodle.txt @@ -1,7 +1,7 @@ Description of importing the js-beautify library into Moodle. * Download the latest version from https://github.com/beautify-web/js-beautify/releases -* Copy lib/beautify*.js into lib/yui/src/beautify/js -* Copy LICENSE into lib/yui/src/beautify -* Update lib/thirdpartylibs.xml +* Copy lib/beautify*.js into lib/editor/atto/plugins/html/yui/src/beautify/js +* Copy LICENSE into lib/editor/atto/plugins/html/yui/src/beautify +* Update lib/editor/atto/plugins/html/thirdpartylibs.xml * Rebuild the module