/* * The MIT License (MIT) * * Author: Gildas Lormeau * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ // Derived from https://github.com/csstree/csstree // The minified code is generated by running the following command and keeping in the API (i.e. syntax object) only the methods "generate" and "parse". // npm run gen:syntax && rollup --config && terser dist/csstree.js -o dist/csstree.js /* * The MIT License (MIT) * Copyright (C) 2016-2019 by Roman Dvornov * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ this.singlefile.lib.vendor.cssTree = this.singlefile.lib.vendor.cssTree || (() => { (function (global, factory) { typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.csstree = factory()) })(this, (function () { "use strict"; var createCustomError = function createCustomError(name, message) { var error = Object.create(SyntaxError.prototype); var errorStack = new Error; error.name = name; error.message = message; Object.defineProperty(error, "stack", { get: function () { return (errorStack.stack || "").replace(/^(.+\n){1,3}/, name + ": " + message + "\n") } }); return error }; function noop(value) { return value } function generateMultiplier(multiplier) { if (multiplier.min === 0 && multiplier.max === 0) { return "*" } if (multiplier.min === 0 && multiplier.max === 1) { return "?" } if (multiplier.min === 1 && multiplier.max === 0) { return multiplier.comma ? "#" : "+" } if (multiplier.min === 1 && multiplier.max === 1) { return "" } return (multiplier.comma ? "#" : "") + (multiplier.min === multiplier.max ? "{" + multiplier.min + "}" : "{" + multiplier.min + "," + (multiplier.max !== 0 ? multiplier.max : "") + "}") } function generateTypeOpts(node) { switch (node.type) { case "Range": return " [" + (node.min === null ? "-∞" : node.min) + "," + (node.max === null ? "∞" : node.max) + "]"; default: throw new Error("Unknown node type `" + node.type + "`") } } function generateSequence(node, decorate, forceBraces, compact) { var combinator = node.combinator === " " || compact ? node.combinator : " " + node.combinator + " "; var result = node.terms.map((function (term) { return generate(term, decorate, forceBraces, compact) })).join(combinator); if (node.explicit || forceBraces) { result = (compact || result[0] === "," ? "[" : "[ ") + result + (compact ? "]" : " ]") } return result } function generate(node, decorate, forceBraces, compact) { var result; switch (node.type) { case "Group": result = generateSequence(node, decorate, forceBraces, compact) + (node.disallowEmpty ? "!" : ""); break; case "Multiplier": return generate(node.term, decorate, forceBraces, compact) + decorate(generateMultiplier(node), node); case "Type": result = "<" + node.name + (node.opts ? decorate(generateTypeOpts(node.opts), node.opts) : "") + ">"; break; case "Property": result = "<'" + node.name + "'>"; break; case "Keyword": result = node.name; break; case "AtKeyword": result = "@" + node.name; break; case "Function": result = node.name + "("; break; case "String": case "Token": result = node.value; break; case "Comma": result = ","; break; default: throw new Error("Unknown node type `" + node.type + "`") }return decorate(result, node) } var generate_1 = function (node, options) { var decorate = noop; var forceBraces = false; var compact = false; if (typeof options === "function") { decorate = options } else if (options) { forceBraces = Boolean(options.forceBraces); compact = Boolean(options.compact); if (typeof options.decorate === "function") { decorate = options.decorate } } return generate(node, decorate, forceBraces, compact) }; function fromMatchResult(matchResult) { var tokens = matchResult.tokens; var longestMatch = matchResult.longestMatch; var node = longestMatch < tokens.length ? tokens[longestMatch].node : null; var mismatchOffset = -1; var entries = 0; var css = ""; for (var i = 0; i < tokens.length; i++) { if (i === longestMatch) { mismatchOffset = css.length } if (node !== null && tokens[i].node === node) { if (i <= longestMatch) { entries++ } else { entries = 0 } } css += tokens[i].value } return { node: node, css: css, mismatchOffset: mismatchOffset === -1 ? css.length : mismatchOffset, last: node === null || entries > 1 } } function getLocation(node, point) { var loc = node && node.loc && node.loc[point]; if (loc) { return { offset: loc.offset, line: loc.line, column: loc.column } } return null } var SyntaxReferenceError = function (type, referenceName) { var error = createCustomError("SyntaxReferenceError", type + (referenceName ? " `" + referenceName + "`" : "")); error.reference = referenceName; return error }; var MatchError = function (message, syntax, node, matchResult) { var error = createCustomError("SyntaxMatchError", message); var details = fromMatchResult(matchResult); var mismatchOffset = details.mismatchOffset || 0; var badNode = details.node || node; var end = getLocation(badNode, "end"); var start = details.last ? end : getLocation(badNode, "start"); var css = details.css; error.rawMessage = message; error.syntax = syntax ? generate_1(syntax) : ""; error.css = css; error.mismatchOffset = mismatchOffset; error.loc = { source: badNode && badNode.loc && badNode.loc.source || "", start: start, end: end }; error.line = start ? start.line : undefined; error.column = start ? start.column : undefined; error.offset = start ? start.offset : undefined; error.message = message + "\n" + " syntax: " + error.syntax + "\n" + " value: " + (error.css || "") + "\n" + " --------" + new Array(error.mismatchOffset + 1).join("-") + "^"; return error }; var error = { SyntaxReferenceError: SyntaxReferenceError, MatchError: MatchError }; var hasOwnProperty = Object.prototype.hasOwnProperty; var keywords = Object.create(null); var properties = Object.create(null); var HYPHENMINUS = 45; function isCustomProperty(str, offset) { offset = offset || 0; return str.length - offset >= 2 && str.charCodeAt(offset) === HYPHENMINUS && str.charCodeAt(offset + 1) === HYPHENMINUS } function getVendorPrefix(str, offset) { offset = offset || 0; if (str.length - offset >= 3) { if (str.charCodeAt(offset) === HYPHENMINUS && str.charCodeAt(offset + 1) !== HYPHENMINUS) { var secondDashIndex = str.indexOf("-", offset + 2); if (secondDashIndex !== -1) { return str.substring(offset, secondDashIndex + 1) } } } return "" } function getKeywordDescriptor(keyword) { if (hasOwnProperty.call(keywords, keyword)) { return keywords[keyword] } var name = keyword.toLowerCase(); if (hasOwnProperty.call(keywords, name)) { return keywords[keyword] = keywords[name] } var custom = isCustomProperty(name, 0); var vendor = !custom ? getVendorPrefix(name, 0) : ""; return keywords[keyword] = Object.freeze({ basename: name.substr(vendor.length), name: name, vendor: vendor, prefix: vendor, custom: custom }) } function getPropertyDescriptor(property) { if (hasOwnProperty.call(properties, property)) { return properties[property] } var name = property; var hack = property[0]; if (hack === "/") { hack = property[1] === "/" ? "//" : "/" } else if (hack !== "_" && hack !== "*" && hack !== "$" && hack !== "#" && hack !== "+" && hack !== "&") { hack = "" } var custom = isCustomProperty(name, hack.length); if (!custom) { name = name.toLowerCase(); if (hasOwnProperty.call(properties, name)) { return properties[property] = properties[name] } } var vendor = !custom ? getVendorPrefix(name, hack.length) : ""; var prefix = name.substr(0, hack.length + vendor.length); return properties[property] = Object.freeze({ basename: name.substr(prefix.length), name: name.substr(hack.length), hack: hack, vendor: vendor, prefix: prefix, custom: custom }) } var names = { keyword: getKeywordDescriptor, property: getPropertyDescriptor, isCustomProperty: isCustomProperty, vendorPrefix: getVendorPrefix }; var TYPE = { EOF: 0, Ident: 1, Function: 2, AtKeyword: 3, Hash: 4, String: 5, BadString: 6, Url: 7, BadUrl: 8, Delim: 9, Number: 10, Percentage: 11, Dimension: 12, WhiteSpace: 13, CDO: 14, CDC: 15, Colon: 16, Semicolon: 17, Comma: 18, LeftSquareBracket: 19, RightSquareBracket: 20, LeftParenthesis: 21, RightParenthesis: 22, LeftCurlyBracket: 23, RightCurlyBracket: 24, Comment: 25 }; var NAME = Object.keys(TYPE).reduce((function (result, key) { result[TYPE[key]] = key; return result }), {}); var _const = { TYPE: TYPE, NAME: NAME }; var EOF = 0; function isDigit(code) { return code >= 48 && code <= 57 } function isHexDigit(code) { return isDigit(code) || code >= 65 && code <= 70 || code >= 97 && code <= 102 } function isUppercaseLetter(code) { return code >= 65 && code <= 90 } function isLowercaseLetter(code) { return code >= 97 && code <= 122 } function isLetter(code) { return isUppercaseLetter(code) || isLowercaseLetter(code) } function isNonAscii(code) { return code >= 128 } function isNameStart(code) { return isLetter(code) || isNonAscii(code) || code === 95 } function isName(code) { return isNameStart(code) || isDigit(code) || code === 45 } function isNonPrintable(code) { return code >= 0 && code <= 8 || code === 11 || code >= 14 && code <= 31 || code === 127 } function isNewline(code) { return code === 10 || code === 13 || code === 12 } function isWhiteSpace(code) { return isNewline(code) || code === 32 || code === 9 } function isValidEscape(first, second) { if (first !== 92) { return false } if (isNewline(second) || second === EOF) { return false } return true } function isIdentifierStart(first, second, third) { if (first === 45) { return isNameStart(second) || second === 45 || isValidEscape(second, third) } if (isNameStart(first)) { return true } if (first === 92) { return isValidEscape(first, second) } return false } function isNumberStart(first, second, third) { if (first === 43 || first === 45) { if (isDigit(second)) { return 2 } return second === 46 && isDigit(third) ? 3 : 0 } if (first === 46) { return isDigit(second) ? 2 : 0 } if (isDigit(first)) { return 1 } return 0 } function isBOM(code) { if (code === 65279) { return 1 } if (code === 65534) { return 1 } return 0 } var CATEGORY = new Array(128); charCodeCategory.Eof = 128; charCodeCategory.WhiteSpace = 130; charCodeCategory.Digit = 131; charCodeCategory.NameStart = 132; charCodeCategory.NonPrintable = 133; for (var i = 0; i < CATEGORY.length; i++) { switch (true) { case isWhiteSpace(i): CATEGORY[i] = charCodeCategory.WhiteSpace; break; case isDigit(i): CATEGORY[i] = charCodeCategory.Digit; break; case isNameStart(i): CATEGORY[i] = charCodeCategory.NameStart; break; case isNonPrintable(i): CATEGORY[i] = charCodeCategory.NonPrintable; break; default: CATEGORY[i] = i || charCodeCategory.Eof } } function charCodeCategory(code) { return code < 128 ? CATEGORY[code] : charCodeCategory.NameStart } var charCodeDefinitions = { isDigit: isDigit, isHexDigit: isHexDigit, isUppercaseLetter: isUppercaseLetter, isLowercaseLetter: isLowercaseLetter, isLetter: isLetter, isNonAscii: isNonAscii, isNameStart: isNameStart, isName: isName, isNonPrintable: isNonPrintable, isNewline: isNewline, isWhiteSpace: isWhiteSpace, isValidEscape: isValidEscape, isIdentifierStart: isIdentifierStart, isNumberStart: isNumberStart, isBOM: isBOM, charCodeCategory: charCodeCategory }; var isDigit$1 = charCodeDefinitions.isDigit; var isHexDigit$1 = charCodeDefinitions.isHexDigit; var isUppercaseLetter$1 = charCodeDefinitions.isUppercaseLetter; var isName$1 = charCodeDefinitions.isName; var isWhiteSpace$1 = charCodeDefinitions.isWhiteSpace; var isValidEscape$1 = charCodeDefinitions.isValidEscape; function getCharCode(source, offset) { return offset < source.length ? source.charCodeAt(offset) : 0 } function getNewlineLength(source, offset, code) { if (code === 13 && getCharCode(source, offset + 1) === 10) { return 2 } return 1 } function cmpChar(testStr, offset, referenceCode) { var code = testStr.charCodeAt(offset); if (isUppercaseLetter$1(code)) { code = code | 32 } return code === referenceCode } function cmpStr(testStr, start, end, referenceStr) { if (end - start !== referenceStr.length) { return false } if (start < 0 || end > testStr.length) { return false } for (var i = start; i < end; i++) { var testCode = testStr.charCodeAt(i); var referenceCode = referenceStr.charCodeAt(i - start); if (isUppercaseLetter$1(testCode)) { testCode = testCode | 32 } if (testCode !== referenceCode) { return false } } return true } function findWhiteSpaceStart(source, offset) { for (; offset >= 0; offset--) { if (!isWhiteSpace$1(source.charCodeAt(offset))) { break } } return offset + 1 } function findWhiteSpaceEnd(source, offset) { for (; offset < source.length; offset++) { if (!isWhiteSpace$1(source.charCodeAt(offset))) { break } } return offset } function findDecimalNumberEnd(source, offset) { for (; offset < source.length; offset++) { if (!isDigit$1(source.charCodeAt(offset))) { break } } return offset } function consumeEscaped(source, offset) { offset += 2; if (isHexDigit$1(getCharCode(source, offset - 1))) { for (var maxOffset = Math.min(source.length, offset + 5); offset < maxOffset; offset++) { if (!isHexDigit$1(getCharCode(source, offset))) { break } } var code = getCharCode(source, offset); if (isWhiteSpace$1(code)) { offset += getNewlineLength(source, offset, code) } } return offset } function consumeName(source, offset) { for (; offset < source.length; offset++) { var code = source.charCodeAt(offset); if (isName$1(code)) { continue } if (isValidEscape$1(code, getCharCode(source, offset + 1))) { offset = consumeEscaped(source, offset) - 1; continue } break } return offset } function consumeNumber(source, offset) { var code = source.charCodeAt(offset); if (code === 43 || code === 45) { code = source.charCodeAt(offset += 1) } if (isDigit$1(code)) { offset = findDecimalNumberEnd(source, offset + 1); code = source.charCodeAt(offset) } if (code === 46 && isDigit$1(source.charCodeAt(offset + 1))) { code = source.charCodeAt(offset += 2); offset = findDecimalNumberEnd(source, offset) } if (cmpChar(source, offset, 101)) { var sign = 0; code = source.charCodeAt(offset + 1); if (code === 45 || code === 43) { sign = 1; code = source.charCodeAt(offset + 2) } if (isDigit$1(code)) { offset = findDecimalNumberEnd(source, offset + 1 + sign + 1) } } return offset } function consumeBadUrlRemnants(source, offset) { for (; offset < source.length; offset++) { var code = source.charCodeAt(offset); if (code === 41) { offset++; break } if (isValidEscape$1(code, getCharCode(source, offset + 1))) { offset = consumeEscaped(source, offset) } } return offset } var utils = { consumeEscaped: consumeEscaped, consumeName: consumeName, consumeNumber: consumeNumber, consumeBadUrlRemnants: consumeBadUrlRemnants, cmpChar: cmpChar, cmpStr: cmpStr, getNewlineLength: getNewlineLength, findWhiteSpaceStart: findWhiteSpaceStart, findWhiteSpaceEnd: findWhiteSpaceEnd }; var TYPE$1 = _const.TYPE; var NAME$1 = _const.NAME; var cmpStr$1 = utils.cmpStr; var EOF$1 = TYPE$1.EOF; var WHITESPACE = TYPE$1.WhiteSpace; var COMMENT = TYPE$1.Comment; var OFFSET_MASK = 16777215; var TYPE_SHIFT = 24; var TokenStream = function () { this.offsetAndType = null; this.balance = null; this.reset() }; TokenStream.prototype = { reset: function () { this.eof = false; this.tokenIndex = -1; this.tokenType = 0; this.tokenStart = this.firstCharOffset; this.tokenEnd = this.firstCharOffset }, lookupType: function (offset) { offset += this.tokenIndex; if (offset < this.tokenCount) { return this.offsetAndType[offset] >> TYPE_SHIFT } return EOF$1 }, lookupOffset: function (offset) { offset += this.tokenIndex; if (offset < this.tokenCount) { return this.offsetAndType[offset - 1] & OFFSET_MASK } return this.source.length }, lookupValue: function (offset, referenceStr) { offset += this.tokenIndex; if (offset < this.tokenCount) { return cmpStr$1(this.source, this.offsetAndType[offset - 1] & OFFSET_MASK, this.offsetAndType[offset] & OFFSET_MASK, referenceStr) } return false }, getTokenStart: function (tokenIndex) { if (tokenIndex === this.tokenIndex) { return this.tokenStart } if (tokenIndex > 0) { return tokenIndex < this.tokenCount ? this.offsetAndType[tokenIndex - 1] & OFFSET_MASK : this.offsetAndType[this.tokenCount] & OFFSET_MASK } return this.firstCharOffset }, getRawLength: function (startToken, mode) { var cursor = startToken; var balanceEnd; var offset = this.offsetAndType[Math.max(cursor - 1, 0)] & OFFSET_MASK; var type; loop: for (; cursor < this.tokenCount; cursor++) { balanceEnd = this.balance[cursor]; if (balanceEnd < startToken) { break loop } type = this.offsetAndType[cursor] >> TYPE_SHIFT; switch (mode(type, this.source, offset)) { case 1: break loop; case 2: cursor++; break loop; default: offset = this.offsetAndType[cursor] & OFFSET_MASK; if (this.balance[balanceEnd] === cursor) { cursor = balanceEnd } } } return cursor - this.tokenIndex }, isBalanceEdge: function (pos) { return this.balance[this.tokenIndex] < pos }, isDelim: function (code, offset) { if (offset) { return this.lookupType(offset) === TYPE$1.Delim && this.source.charCodeAt(this.lookupOffset(offset)) === code } return this.tokenType === TYPE$1.Delim && this.source.charCodeAt(this.tokenStart) === code }, getTokenValue: function () { return this.source.substring(this.tokenStart, this.tokenEnd) }, getTokenLength: function () { return this.tokenEnd - this.tokenStart }, substrToCursor: function (start) { return this.source.substring(start, this.tokenStart) }, skipWS: function () { for (var i = this.tokenIndex, skipTokenCount = 0; i < this.tokenCount; i++ , skipTokenCount++) { if (this.offsetAndType[i] >> TYPE_SHIFT !== WHITESPACE) { break } } if (skipTokenCount > 0) { this.skip(skipTokenCount) } }, skipSC: function () { while (this.tokenType === WHITESPACE || this.tokenType === COMMENT) { this.next() } }, skip: function (tokenCount) { var next = this.tokenIndex + tokenCount; if (next < this.tokenCount) { this.tokenIndex = next; this.tokenStart = this.offsetAndType[next - 1] & OFFSET_MASK; next = this.offsetAndType[next]; this.tokenType = next >> TYPE_SHIFT; this.tokenEnd = next & OFFSET_MASK } else { this.tokenIndex = this.tokenCount; this.next() } }, next: function () { var next = this.tokenIndex + 1; if (next < this.tokenCount) { this.tokenIndex = next; this.tokenStart = this.tokenEnd; next = this.offsetAndType[next]; this.tokenType = next >> TYPE_SHIFT; this.tokenEnd = next & OFFSET_MASK } else { this.tokenIndex = this.tokenCount; this.eof = true; this.tokenType = EOF$1; this.tokenStart = this.tokenEnd = this.source.length } }, dump: function () { var offset = this.firstCharOffset; return Array.prototype.slice.call(this.offsetAndType, 0, this.tokenCount).map((function (item, idx) { var start = offset; var end = item & OFFSET_MASK; offset = end; return { idx: idx, type: NAME$1[item >> TYPE_SHIFT], chunk: this.source.substring(start, end), balance: this.balance[idx] } }), this) } }; var TokenStream_1 = TokenStream; var MIN_SIZE = 16 * 1024; var SafeUint32Array = typeof Uint32Array !== "undefined" ? Uint32Array : Array; var adoptBuffer = function adoptBuffer(buffer, size) { if (buffer === null || buffer.length < size) { return new SafeUint32Array(Math.max(size + 1024, MIN_SIZE)) } return buffer }; var TYPE$2 = _const.TYPE; var isNewline$1 = charCodeDefinitions.isNewline; var isName$2 = charCodeDefinitions.isName; var isValidEscape$2 = charCodeDefinitions.isValidEscape; var isNumberStart$1 = charCodeDefinitions.isNumberStart; var isIdentifierStart$1 = charCodeDefinitions.isIdentifierStart; var charCodeCategory$1 = charCodeDefinitions.charCodeCategory; var isBOM$1 = charCodeDefinitions.isBOM; var cmpStr$2 = utils.cmpStr; var getNewlineLength$1 = utils.getNewlineLength; var findWhiteSpaceEnd$1 = utils.findWhiteSpaceEnd; var consumeEscaped$1 = utils.consumeEscaped; var consumeName$1 = utils.consumeName; var consumeNumber$1 = utils.consumeNumber; var consumeBadUrlRemnants$1 = utils.consumeBadUrlRemnants; var OFFSET_MASK$1 = 16777215; var TYPE_SHIFT$1 = 24; function tokenize(source, stream) { function getCharCode(offset) { return offset < sourceLength ? source.charCodeAt(offset) : 0 } function consumeNumericToken() { offset = consumeNumber$1(source, offset); if (isIdentifierStart$1(getCharCode(offset), getCharCode(offset + 1), getCharCode(offset + 2))) { type = TYPE$2.Dimension; offset = consumeName$1(source, offset); return } if (getCharCode(offset) === 37) { type = TYPE$2.Percentage; offset++; return } type = TYPE$2.Number } function consumeIdentLikeToken() { const nameStartOffset = offset; offset = consumeName$1(source, offset); if (cmpStr$2(source, nameStartOffset, offset, "url") && getCharCode(offset) === 40) { offset = findWhiteSpaceEnd$1(source, offset + 1); if (getCharCode(offset) === 34 || getCharCode(offset) === 39) { type = TYPE$2.Function; offset = nameStartOffset + 4; return } consumeUrlToken(); return } if (getCharCode(offset) === 40) { type = TYPE$2.Function; offset++; return } type = TYPE$2.Ident } function consumeStringToken(endingCodePoint) { if (!endingCodePoint) { endingCodePoint = getCharCode(offset++) } type = TYPE$2.String; for (; offset < source.length; offset++) { var code = source.charCodeAt(offset); switch (charCodeCategory$1(code)) { case endingCodePoint: offset++; return; case charCodeCategory$1.Eof: return; case charCodeCategory$1.WhiteSpace: if (isNewline$1(code)) { offset += getNewlineLength$1(source, offset, code); type = TYPE$2.BadString; return } break; case 92: if (offset === source.length - 1) { break } var nextCode = getCharCode(offset + 1); if (isNewline$1(nextCode)) { offset += getNewlineLength$1(source, offset + 1, nextCode) } else if (isValidEscape$2(code, nextCode)) { offset = consumeEscaped$1(source, offset) - 1 } break } } } function consumeUrlToken() { type = TYPE$2.Url; offset = findWhiteSpaceEnd$1(source, offset); for (; offset < source.length; offset++) { var code = source.charCodeAt(offset); switch (charCodeCategory$1(code)) { case 41: offset++; return; case charCodeCategory$1.Eof: return; case charCodeCategory$1.WhiteSpace: offset = findWhiteSpaceEnd$1(source, offset); if (getCharCode(offset) === 41 || offset >= source.length) { if (offset < source.length) { offset++ } return } offset = consumeBadUrlRemnants$1(source, offset); type = TYPE$2.BadUrl; return; case 34: case 39: case 40: case charCodeCategory$1.NonPrintable: offset = consumeBadUrlRemnants$1(source, offset); type = TYPE$2.BadUrl; return; case 92: if (isValidEscape$2(code, getCharCode(offset + 1))) { offset = consumeEscaped$1(source, offset) - 1; break } offset = consumeBadUrlRemnants$1(source, offset); type = TYPE$2.BadUrl; return } } } if (!stream) { stream = new TokenStream_1 } source = String(source || ""); var sourceLength = source.length; var offsetAndType = adoptBuffer(stream.offsetAndType, sourceLength + 1); var balance = adoptBuffer(stream.balance, sourceLength + 1); var tokenCount = 0; var start = isBOM$1(getCharCode(0)); var offset = start; var balanceCloseType = 0; var balanceStart = 0; var balancePrev = 0; while (offset < sourceLength) { var code = source.charCodeAt(offset); var type = 0; balance[tokenCount] = sourceLength; switch (charCodeCategory$1(code)) { case charCodeCategory$1.WhiteSpace: type = TYPE$2.WhiteSpace; offset = findWhiteSpaceEnd$1(source, offset + 1); break; case 34: consumeStringToken(); break; case 35: if (isName$2(getCharCode(offset + 1)) || isValidEscape$2(getCharCode(offset + 1), getCharCode(offset + 2))) { type = TYPE$2.Hash; offset = consumeName$1(source, offset + 1) } else { type = TYPE$2.Delim; offset++ } break; case 39: consumeStringToken(); break; case 40: type = TYPE$2.LeftParenthesis; offset++; break; case 41: type = TYPE$2.RightParenthesis; offset++; break; case 43: if (isNumberStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) { consumeNumericToken() } else { type = TYPE$2.Delim; offset++ } break; case 44: type = TYPE$2.Comma; offset++; break; case 45: if (isNumberStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) { consumeNumericToken() } else { if (getCharCode(offset + 1) === 45 && getCharCode(offset + 2) === 62) { type = TYPE$2.CDC; offset = offset + 3 } else { if (isIdentifierStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) { consumeIdentLikeToken() } else { type = TYPE$2.Delim; offset++ } } } break; case 46: if (isNumberStart$1(code, getCharCode(offset + 1), getCharCode(offset + 2))) { consumeNumericToken() } else { type = TYPE$2.Delim; offset++ } break; case 47: if (getCharCode(offset + 1) === 42) { type = TYPE$2.Comment; offset = source.indexOf("*/", offset + 2) + 2; if (offset === 1) { offset = source.length } } else { type = TYPE$2.Delim; offset++ } break; case 58: type = TYPE$2.Colon; offset++; break; case 59: type = TYPE$2.Semicolon; offset++; break; case 60: if (getCharCode(offset + 1) === 33 && getCharCode(offset + 2) === 45 && getCharCode(offset + 3) === 45) { type = TYPE$2.CDO; offset = offset + 4 } else { type = TYPE$2.Delim; offset++ } break; case 64: if (isIdentifierStart$1(getCharCode(offset + 1), getCharCode(offset + 2), getCharCode(offset + 3))) { type = TYPE$2.AtKeyword; offset = consumeName$1(source, offset + 1) } else { type = TYPE$2.Delim; offset++ } break; case 91: type = TYPE$2.LeftSquareBracket; offset++; break; case 92: if (isValidEscape$2(code, getCharCode(offset + 1))) { consumeIdentLikeToken() } else { type = TYPE$2.Delim; offset++ } break; case 93: type = TYPE$2.RightSquareBracket; offset++; break; case 123: type = TYPE$2.LeftCurlyBracket; offset++; break; case 125: type = TYPE$2.RightCurlyBracket; offset++; break; case charCodeCategory$1.Digit: consumeNumericToken(); break; case charCodeCategory$1.NameStart: consumeIdentLikeToken(); break; case charCodeCategory$1.Eof: break; default: type = TYPE$2.Delim; offset++ }switch (type) { case balanceCloseType: balancePrev = balanceStart & OFFSET_MASK$1; balanceStart = balance[balancePrev]; balanceCloseType = balanceStart >> TYPE_SHIFT$1; balance[tokenCount] = balancePrev; balance[balancePrev++] = tokenCount; for (; balancePrev < tokenCount; balancePrev++) { if (balance[balancePrev] === sourceLength) { balance[balancePrev] = tokenCount } } break; case TYPE$2.LeftParenthesis: case TYPE$2.Function: balance[tokenCount] = balanceStart; balanceCloseType = TYPE$2.RightParenthesis; balanceStart = balanceCloseType << TYPE_SHIFT$1 | tokenCount; break; case TYPE$2.LeftSquareBracket: balance[tokenCount] = balanceStart; balanceCloseType = TYPE$2.RightSquareBracket; balanceStart = balanceCloseType << TYPE_SHIFT$1 | tokenCount; break; case TYPE$2.LeftCurlyBracket: balance[tokenCount] = balanceStart; balanceCloseType = TYPE$2.RightCurlyBracket; balanceStart = balanceCloseType << TYPE_SHIFT$1 | tokenCount; break }offsetAndType[tokenCount++] = type << TYPE_SHIFT$1 | offset } offsetAndType[tokenCount] = TYPE$2.EOF << TYPE_SHIFT$1 | offset; balance[tokenCount] = sourceLength; balance[sourceLength] = sourceLength; while (balanceStart !== 0) { balancePrev = balanceStart & OFFSET_MASK$1; balanceStart = balance[balancePrev]; balance[balancePrev] = sourceLength } stream.source = source; stream.firstCharOffset = start; stream.offsetAndType = offsetAndType; stream.tokenCount = tokenCount; stream.balance = balance; stream.reset(); stream.next(); return stream } Object.keys(_const).forEach((function (key) { tokenize[key] = _const[key] })); Object.keys(charCodeDefinitions).forEach((function (key) { tokenize[key] = charCodeDefinitions[key] })); Object.keys(utils).forEach((function (key) { tokenize[key] = utils[key] })); var tokenizer = tokenize; var isDigit$2 = tokenizer.isDigit; var cmpChar$1 = tokenizer.cmpChar; var TYPE$3 = tokenizer.TYPE; var DELIM = TYPE$3.Delim; var WHITESPACE$1 = TYPE$3.WhiteSpace; var COMMENT$1 = TYPE$3.Comment; var IDENT = TYPE$3.Ident; var NUMBER = TYPE$3.Number; var DIMENSION = TYPE$3.Dimension; var PLUSSIGN = 43; var HYPHENMINUS$1 = 45; var N = 110; var DISALLOW_SIGN = true; var ALLOW_SIGN = false; function isDelim(token, code) { return token !== null && token.type === DELIM && token.value.charCodeAt(0) === code } function skipSC(token, offset, getNextToken) { while (token !== null && (token.type === WHITESPACE$1 || token.type === COMMENT$1)) { token = getNextToken(++offset) } return offset } function checkInteger(token, valueOffset, disallowSign, offset) { if (!token) { return 0 } var code = token.value.charCodeAt(valueOffset); if (code === PLUSSIGN || code === HYPHENMINUS$1) { if (disallowSign) { return 0 } valueOffset++ } for (; valueOffset < token.value.length; valueOffset++) { if (!isDigit$2(token.value.charCodeAt(valueOffset))) { return 0 } } return offset + 1 } function consumeB(token, offset_, getNextToken) { var sign = false; var offset = skipSC(token, offset_, getNextToken); token = getNextToken(offset); if (token === null) { return offset_ } if (token.type !== NUMBER) { if (isDelim(token, PLUSSIGN) || isDelim(token, HYPHENMINUS$1)) { sign = true; offset = skipSC(getNextToken(++offset), offset, getNextToken); token = getNextToken(offset); if (token === null && token.type !== NUMBER) { return 0 } } else { return offset_ } } if (!sign) { var code = token.value.charCodeAt(0); if (code !== PLUSSIGN && code !== HYPHENMINUS$1) { return 0 } } return checkInteger(token, sign ? 0 : 1, sign, offset) } var genericAnPlusB = function anPlusB(token, getNextToken) { var offset = 0; if (!token) { return 0 } if (token.type === NUMBER) { return checkInteger(token, 0, ALLOW_SIGN, offset) } else if (token.type === IDENT && token.value.charCodeAt(0) === HYPHENMINUS$1) { if (!cmpChar$1(token.value, 1, N)) { return 0 } switch (token.value.length) { case 2: return consumeB(getNextToken(++offset), offset, getNextToken); case 3: if (token.value.charCodeAt(2) !== HYPHENMINUS$1) { return 0 } offset = skipSC(getNextToken(++offset), offset, getNextToken); token = getNextToken(offset); return checkInteger(token, 0, DISALLOW_SIGN, offset); default: if (token.value.charCodeAt(2) !== HYPHENMINUS$1) { return 0 } return checkInteger(token, 3, DISALLOW_SIGN, offset) } } else if (token.type === IDENT || isDelim(token, PLUSSIGN) && getNextToken(offset + 1).type === IDENT) { if (token.type !== IDENT) { token = getNextToken(++offset) } if (token === null || !cmpChar$1(token.value, 0, N)) { return 0 } switch (token.value.length) { case 1: return consumeB(getNextToken(++offset), offset, getNextToken); case 2: if (token.value.charCodeAt(1) !== HYPHENMINUS$1) { return 0 } offset = skipSC(getNextToken(++offset), offset, getNextToken); token = getNextToken(offset); return checkInteger(token, 0, DISALLOW_SIGN, offset); default: if (token.value.charCodeAt(1) !== HYPHENMINUS$1) { return 0 } return checkInteger(token, 2, DISALLOW_SIGN, offset) } } else if (token.type === DIMENSION) { var code = token.value.charCodeAt(0); var sign = code === PLUSSIGN || code === HYPHENMINUS$1 ? 1 : 0; for (var i = sign; i < token.value.length; i++) { if (!isDigit$2(token.value.charCodeAt(i))) { break } } if (i === sign) { return 0 } if (!cmpChar$1(token.value, i, N)) { return 0 } if (i + 1 === token.value.length) { return consumeB(getNextToken(++offset), offset, getNextToken) } else { if (token.value.charCodeAt(i + 1) !== HYPHENMINUS$1) { return 0 } if (i + 2 === token.value.length) { offset = skipSC(getNextToken(++offset), offset, getNextToken); token = getNextToken(offset); return checkInteger(token, 0, DISALLOW_SIGN, offset) } else { return checkInteger(token, i + 2, DISALLOW_SIGN, offset) } } } return 0 }; var isHexDigit$2 = tokenizer.isHexDigit; var cmpChar$2 = tokenizer.cmpChar; var TYPE$4 = tokenizer.TYPE; var IDENT$1 = TYPE$4.Ident; var DELIM$1 = TYPE$4.Delim; var NUMBER$1 = TYPE$4.Number; var DIMENSION$1 = TYPE$4.Dimension; var PLUSSIGN$1 = 43; var HYPHENMINUS$2 = 45; var QUESTIONMARK = 63; var U = 117; function isDelim$1(token, code) { return token !== null && token.type === DELIM$1 && token.value.charCodeAt(0) === code } function startsWith(token, code) { return token.value.charCodeAt(0) === code } function hexSequence(token, offset, allowDash) { for (var pos = offset, hexlen = 0; pos < token.value.length; pos++) { var code = token.value.charCodeAt(pos); if (code === HYPHENMINUS$2 && allowDash && hexlen !== 0) { if (hexSequence(token, offset + hexlen + 1, false) > 0) { return 6 } return 0 } if (!isHexDigit$2(code)) { return 0 } if (++hexlen > 6) { return 0 } } return hexlen } function withQuestionMarkSequence(consumed, length, getNextToken) { if (!consumed) { return 0 } while (isDelim$1(getNextToken(length), QUESTIONMARK)) { if (++consumed > 6) { return 0 } length++ } return length } var genericUrange = function urange(token, getNextToken) { var length = 0; if (token === null || token.type !== IDENT$1 || !cmpChar$2(token.value, 0, U)) { return 0 } token = getNextToken(++length); if (token === null) { return 0 } if (isDelim$1(token, PLUSSIGN$1)) { token = getNextToken(++length); if (token === null) { return 0 } if (token.type === IDENT$1) { return withQuestionMarkSequence(hexSequence(token, 0, true), ++length, getNextToken) } if (isDelim$1(token, QUESTIONMARK)) { return withQuestionMarkSequence(1, ++length, getNextToken) } return 0 } if (token.type === NUMBER$1) { if (!startsWith(token, PLUSSIGN$1)) { return 0 } var consumedHexLength = hexSequence(token, 1, true); if (consumedHexLength === 0) { return 0 } token = getNextToken(++length); if (token === null) { return length } if (token.type === DIMENSION$1 || token.type === NUMBER$1) { if (!startsWith(token, HYPHENMINUS$2) || !hexSequence(token, 1, false)) { return 0 } return length + 1 } return withQuestionMarkSequence(consumedHexLength, length, getNextToken) } if (token.type === DIMENSION$1) { if (!startsWith(token, PLUSSIGN$1)) { return 0 } return withQuestionMarkSequence(hexSequence(token, 1, true), ++length, getNextToken) } return 0 }; var isIdentifierStart$2 = tokenizer.isIdentifierStart; var isHexDigit$3 = tokenizer.isHexDigit; var isDigit$3 = tokenizer.isDigit; var cmpStr$3 = tokenizer.cmpStr; var consumeNumber$2 = tokenizer.consumeNumber; var TYPE$5 = tokenizer.TYPE; var cssWideKeywords = ["unset", "initial", "inherit"]; var calcFunctionNames = ["calc(", "-moz-calc(", "-webkit-calc("]; var LENGTH = { px: true, mm: true, cm: true, in: true, pt: true, pc: true, q: true, em: true, ex: true, ch: true, rem: true, vh: true, vw: true, vmin: true, vmax: true, vm: true }; var ANGLE = { deg: true, grad: true, rad: true, turn: true }; var TIME = { s: true, ms: true }; var FREQUENCY = { hz: true, khz: true }; var RESOLUTION = { dpi: true, dpcm: true, dppx: true, x: true }; var FLEX = { fr: true }; var DECIBEL = { db: true }; var SEMITONES = { st: true }; function charCode(str, index) { return index < str.length ? str.charCodeAt(index) : 0 } function eqStr(actual, expected) { return cmpStr$3(actual, 0, actual.length, expected) } function eqStrAny(actual, expected) { for (var i = 0; i < expected.length; i++) { if (eqStr(actual, expected[i])) { return true } } return false } function isPostfixIeHack(str, offset) { if (offset !== str.length - 2) { return false } return str.charCodeAt(offset) === 92 && isDigit$3(str.charCodeAt(offset + 1)) } function outOfRange(opts, value, numEnd) { if (opts && opts.type === "Range") { var num = Number(numEnd !== undefined && numEnd !== value.length ? value.substr(0, numEnd) : value); if (isNaN(num)) { return true } if (opts.min !== null && num < opts.min) { return true } if (opts.max !== null && num > opts.max) { return true } } return false } function consumeFunction(token, getNextToken) { var startIdx = token.index; var length = 0; do { length++; if (token.balance <= startIdx) { break } } while (token = getNextToken(length)); return length } function calc(next) { return function (token, getNextToken, opts) { if (token === null) { return 0 } if (token.type === TYPE$5.Function && eqStrAny(token.value, calcFunctionNames)) { return consumeFunction(token, getNextToken) } return next(token, getNextToken, opts) } } function tokenType(expectedTokenType) { return function (token) { if (token === null || token.type !== expectedTokenType) { return 0 } return 1 } } function func(name) { name = name + "("; return function (token, getNextToken) { if (token !== null && eqStr(token.value, name)) { return consumeFunction(token, getNextToken) } return 0 } } function customIdent(token) { if (token === null || token.type !== TYPE$5.Ident) { return 0 } var name = token.value.toLowerCase(); if (eqStrAny(name, cssWideKeywords)) { return 0 } if (eqStr(name, "default")) { return 0 } return 1 } function customPropertyName(token) { if (token === null || token.type !== TYPE$5.Ident) { return 0 } if (charCode(token.value, 0) !== 45 || charCode(token.value, 1) !== 45) { return 0 } return 1 } function hexColor(token) { if (token === null || token.type !== TYPE$5.Hash) { return 0 } var length = token.value.length; if (length !== 4 && length !== 5 && length !== 7 && length !== 9) { return 0 } for (var i = 1; i < length; i++) { if (!isHexDigit$3(token.value.charCodeAt(i))) { return 0 } } return 1 } function idSelector(token) { if (token === null || token.type !== TYPE$5.Hash) { return 0 } if (!isIdentifierStart$2(charCode(token.value, 1), charCode(token.value, 2), charCode(token.value, 3))) { return 0 } return 1 } function declarationValue(token, getNextToken) { if (!token) { return 0 } var length = 0; var level = 0; var startIdx = token.index; scan: do { switch (token.type) { case TYPE$5.BadString: case TYPE$5.BadUrl: break scan; case TYPE$5.RightCurlyBracket: case TYPE$5.RightParenthesis: case TYPE$5.RightSquareBracket: if (token.balance > token.index || token.balance < startIdx) { break scan } level--; break; case TYPE$5.Semicolon: if (level === 0) { break scan } break; case TYPE$5.Delim: if (token.value === "!" && level === 0) { break scan } break; case TYPE$5.Function: case TYPE$5.LeftParenthesis: case TYPE$5.LeftSquareBracket: case TYPE$5.LeftCurlyBracket: level++; break }length++; if (token.balance <= startIdx) { break } } while (token = getNextToken(length)); return length } function anyValue(token, getNextToken) { if (!token) { return 0 } var startIdx = token.index; var length = 0; scan: do { switch (token.type) { case TYPE$5.BadString: case TYPE$5.BadUrl: break scan; case TYPE$5.RightCurlyBracket: case TYPE$5.RightParenthesis: case TYPE$5.RightSquareBracket: if (token.balance > token.index || token.balance < startIdx) { break scan } break }length++; if (token.balance <= startIdx) { break } } while (token = getNextToken(length)); return length } function dimension(type) { return function (token, getNextToken, opts) { if (token === null || token.type !== TYPE$5.Dimension) { return 0 } var numberEnd = consumeNumber$2(token.value, 0); if (type !== null) { var reverseSolidusOffset = token.value.indexOf("\\", numberEnd); var unit = reverseSolidusOffset === -1 || !isPostfixIeHack(token.value, reverseSolidusOffset) ? token.value.substr(numberEnd) : token.value.substring(numberEnd, reverseSolidusOffset); if (type.hasOwnProperty(unit.toLowerCase()) === false) { return 0 } } if (outOfRange(opts, token.value, numberEnd)) { return 0 } return 1 } } function percentage(token, getNextToken, opts) { if (token === null || token.type !== TYPE$5.Percentage) { return 0 } if (outOfRange(opts, token.value, token.value.length - 1)) { return 0 } return 1 } function zero(next) { if (typeof next !== "function") { next = function () { return 0 } } return function (token, getNextToken, opts) { if (token !== null && token.type === TYPE$5.Number) { if (Number(token.value) === 0) { return 1 } } return next(token, getNextToken, opts) } } function number(token, getNextToken, opts) { if (token === null) { return 0 } var numberEnd = consumeNumber$2(token.value, 0); var isNumber = numberEnd === token.value.length; if (!isNumber && !isPostfixIeHack(token.value, numberEnd)) { return 0 } if (outOfRange(opts, token.value, numberEnd)) { return 0 } return 1 } function integer(token, getNextToken, opts) { if (token === null || token.type !== TYPE$5.Number) { return 0 } var i = token.value.charCodeAt(0) === 43 || token.value.charCodeAt(0) === 45 ? 1 : 0; for (; i < token.value.length; i++) { if (!isDigit$3(token.value.charCodeAt(i))) { return 0 } } if (outOfRange(opts, token.value, i)) { return 0 } return 1 } var generic = { "ident-token": tokenType(TYPE$5.Ident), "function-token": tokenType(TYPE$5.Function), "at-keyword-token": tokenType(TYPE$5.AtKeyword), "hash-token": tokenType(TYPE$5.Hash), "string-token": tokenType(TYPE$5.String), "bad-string-token": tokenType(TYPE$5.BadString), "url-token": tokenType(TYPE$5.Url), "bad-url-token": tokenType(TYPE$5.BadUrl), "delim-token": tokenType(TYPE$5.Delim), "number-token": tokenType(TYPE$5.Number), "percentage-token": tokenType(TYPE$5.Percentage), "dimension-token": tokenType(TYPE$5.Dimension), "whitespace-token": tokenType(TYPE$5.WhiteSpace), "CDO-token": tokenType(TYPE$5.CDO), "CDC-token": tokenType(TYPE$5.CDC), "colon-token": tokenType(TYPE$5.Colon), "semicolon-token": tokenType(TYPE$5.Semicolon), "comma-token": tokenType(TYPE$5.Comma), "[-token": tokenType(TYPE$5.LeftSquareBracket), "]-token": tokenType(TYPE$5.RightSquareBracket), "(-token": tokenType(TYPE$5.LeftParenthesis), ")-token": tokenType(TYPE$5.RightParenthesis), "{-token": tokenType(TYPE$5.LeftCurlyBracket), "}-token": tokenType(TYPE$5.RightCurlyBracket), string: tokenType(TYPE$5.String), ident: tokenType(TYPE$5.Ident), "custom-ident": customIdent, "custom-property-name": customPropertyName, "hex-color": hexColor, "id-selector": idSelector, "an-plus-b": genericAnPlusB, urange: genericUrange, "declaration-value": declarationValue, "any-value": anyValue, dimension: calc(dimension(null)), angle: calc(dimension(ANGLE)), decibel: calc(dimension(DECIBEL)), frequency: calc(dimension(FREQUENCY)), flex: calc(dimension(FLEX)), length: calc(zero(dimension(LENGTH))), resolution: calc(dimension(RESOLUTION)), semitones: calc(dimension(SEMITONES)), time: calc(dimension(TIME)), percentage: calc(percentage), zero: zero(), number: calc(number), integer: calc(integer), "-ms-legacy-expression": func("expression") }; var _SyntaxError = function SyntaxError(message, input, offset) { var error = createCustomError("SyntaxError", message); error.input = input; error.offset = offset; error.rawMessage = message; error.message = error.rawMessage + "\n" + " " + error.input + "\n" + "--" + new Array((error.offset || error.input.length) + 1).join("-") + "^"; return error }; var TAB = 9; var N$1 = 10; var F = 12; var R = 13; var SPACE = 32; var Tokenizer = function (str) { this.str = str; this.pos = 0 }; Tokenizer.prototype = { charCodeAt: function (pos) { return pos < this.str.length ? this.str.charCodeAt(pos) : 0 }, charCode: function () { return this.charCodeAt(this.pos) }, nextCharCode: function () { return this.charCodeAt(this.pos + 1) }, nextNonWsCode: function (pos) { return this.charCodeAt(this.findWsEnd(pos)) }, findWsEnd: function (pos) { for (; pos < this.str.length; pos++) { var code = this.str.charCodeAt(pos); if (code !== R && code !== N$1 && code !== F && code !== SPACE && code !== TAB) { break } } return pos }, substringToPos: function (end) { return this.str.substring(this.pos, this.pos = end) }, eat: function (code) { if (this.charCode() !== code) { this.error("Expect `" + String.fromCharCode(code) + "`") } this.pos++ }, peek: function () { return this.pos < this.str.length ? this.str.charAt(this.pos++) : "" }, error: function (message) { throw new _SyntaxError(message, this.str, this.pos) } }; var tokenizer$1 = Tokenizer; var TAB$1 = 9; var N$2 = 10; var F$1 = 12; var R$1 = 13; var SPACE$1 = 32; var EXCLAMATIONMARK = 33; var NUMBERSIGN = 35; var AMPERSAND = 38; var APOSTROPHE = 39; var LEFTPARENTHESIS = 40; var RIGHTPARENTHESIS = 41; var ASTERISK = 42; var PLUSSIGN$2 = 43; var COMMA = 44; var HYPERMINUS = 45; var LESSTHANSIGN = 60; var GREATERTHANSIGN = 62; var QUESTIONMARK$1 = 63; var COMMERCIALAT = 64; var LEFTSQUAREBRACKET = 91; var RIGHTSQUAREBRACKET = 93; var LEFTCURLYBRACKET = 123; var VERTICALLINE = 124; var RIGHTCURLYBRACKET = 125; var INFINITY = 8734; var NAME_CHAR = createCharMap((function (ch) { return /[a-zA-Z0-9\-]/.test(ch) })); var COMBINATOR_PRECEDENCE = { " ": 1, "&&": 2, "||": 3, "|": 4 }; function createCharMap(fn) { var array = typeof Uint32Array === "function" ? new Uint32Array(128) : new Array(128); for (var i = 0; i < 128; i++) { array[i] = fn(String.fromCharCode(i)) ? 1 : 0 } return array } function scanSpaces(tokenizer) { return tokenizer.substringToPos(tokenizer.findWsEnd(tokenizer.pos)) } function scanWord(tokenizer) { var end = tokenizer.pos; for (; end < tokenizer.str.length; end++) { var code = tokenizer.str.charCodeAt(end); if (code >= 128 || NAME_CHAR[code] === 0) { break } } if (tokenizer.pos === end) { tokenizer.error("Expect a keyword") } return tokenizer.substringToPos(end) } function scanNumber(tokenizer) { var end = tokenizer.pos; for (; end < tokenizer.str.length; end++) { var code = tokenizer.str.charCodeAt(end); if (code < 48 || code > 57) { break } } if (tokenizer.pos === end) { tokenizer.error("Expect a number") } return tokenizer.substringToPos(end) } function scanString(tokenizer) { var end = tokenizer.str.indexOf("'", tokenizer.pos + 1); if (end === -1) { tokenizer.pos = tokenizer.str.length; tokenizer.error("Expect an apostrophe") } return tokenizer.substringToPos(end + 1) } function readMultiplierRange(tokenizer) { var min = null; var max = null; tokenizer.eat(LEFTCURLYBRACKET); min = scanNumber(tokenizer); if (tokenizer.charCode() === COMMA) { tokenizer.pos++; if (tokenizer.charCode() !== RIGHTCURLYBRACKET) { max = scanNumber(tokenizer) } } else { max = min } tokenizer.eat(RIGHTCURLYBRACKET); return { min: Number(min), max: max ? Number(max) : 0 } } function readMultiplier(tokenizer) { var range = null; var comma = false; switch (tokenizer.charCode()) { case ASTERISK: tokenizer.pos++; range = { min: 0, max: 0 }; break; case PLUSSIGN$2: tokenizer.pos++; range = { min: 1, max: 0 }; break; case QUESTIONMARK$1: tokenizer.pos++; range = { min: 0, max: 1 }; break; case NUMBERSIGN: tokenizer.pos++; comma = true; if (tokenizer.charCode() === LEFTCURLYBRACKET) { range = readMultiplierRange(tokenizer) } else { range = { min: 1, max: 0 } } break; case LEFTCURLYBRACKET: range = readMultiplierRange(tokenizer); break; default: return null }return { type: "Multiplier", comma: comma, min: range.min, max: range.max, term: null } } function maybeMultiplied(tokenizer, node) { var multiplier = readMultiplier(tokenizer); if (multiplier !== null) { multiplier.term = node; return multiplier } return node } function maybeToken(tokenizer) { var ch = tokenizer.peek(); if (ch === "") { return null } return { type: "Token", value: ch } } function readProperty(tokenizer) { var name; tokenizer.eat(LESSTHANSIGN); tokenizer.eat(APOSTROPHE); name = scanWord(tokenizer); tokenizer.eat(APOSTROPHE); tokenizer.eat(GREATERTHANSIGN); return maybeMultiplied(tokenizer, { type: "Property", name: name }) } function readTypeRange(tokenizer) { var min = null; var max = null; var sign = 1; tokenizer.eat(LEFTSQUAREBRACKET); if (tokenizer.charCode() === HYPERMINUS) { tokenizer.peek(); sign = -1 } if (sign == -1 && tokenizer.charCode() === INFINITY) { tokenizer.peek() } else { min = sign * Number(scanNumber(tokenizer)) } scanSpaces(tokenizer); tokenizer.eat(COMMA); scanSpaces(tokenizer); if (tokenizer.charCode() === INFINITY) { tokenizer.peek() } else { sign = 1; if (tokenizer.charCode() === HYPERMINUS) { tokenizer.peek(); sign = -1 } max = sign * Number(scanNumber(tokenizer)) } tokenizer.eat(RIGHTSQUAREBRACKET); if (min === null && max === null) { return null } return { type: "Range", min: min, max: max } } function readType(tokenizer) { var name; var opts = null; tokenizer.eat(LESSTHANSIGN); name = scanWord(tokenizer); if (tokenizer.charCode() === LEFTPARENTHESIS && tokenizer.nextCharCode() === RIGHTPARENTHESIS) { tokenizer.pos += 2; name += "()" } if (tokenizer.charCodeAt(tokenizer.findWsEnd(tokenizer.pos)) === LEFTSQUAREBRACKET) { scanSpaces(tokenizer); opts = readTypeRange(tokenizer) } tokenizer.eat(GREATERTHANSIGN); return maybeMultiplied(tokenizer, { type: "Type", name: name, opts: opts }) } function readKeywordOrFunction(tokenizer) { var name; name = scanWord(tokenizer); if (tokenizer.charCode() === LEFTPARENTHESIS) { tokenizer.pos++; return { type: "Function", name: name } } return maybeMultiplied(tokenizer, { type: "Keyword", name: name }) } function regroupTerms(terms, combinators) { function createGroup(terms, combinator) { return { type: "Group", terms: terms, combinator: combinator, disallowEmpty: false, explicit: false } } combinators = Object.keys(combinators).sort((function (a, b) { return COMBINATOR_PRECEDENCE[a] - COMBINATOR_PRECEDENCE[b] })); while (combinators.length > 0) { var combinator = combinators.shift(); for (var i = 0, subgroupStart = 0; i < terms.length; i++) { var term = terms[i]; if (term.type === "Combinator") { if (term.value === combinator) { if (subgroupStart === -1) { subgroupStart = i - 1 } terms.splice(i, 1); i-- } else { if (subgroupStart !== -1 && i - subgroupStart > 1) { terms.splice(subgroupStart, i - subgroupStart, createGroup(terms.slice(subgroupStart, i), combinator)); i = subgroupStart + 1 } subgroupStart = -1 } } } if (subgroupStart !== -1 && combinators.length) { terms.splice(subgroupStart, i - subgroupStart, createGroup(terms.slice(subgroupStart, i), combinator)) } } return combinator } function readImplicitGroup(tokenizer) { var terms = []; var combinators = {}; var token; var prevToken = null; var prevTokenPos = tokenizer.pos; while (token = peek(tokenizer)) { if (token.type !== "Spaces") { if (token.type === "Combinator") { if (prevToken === null || prevToken.type === "Combinator") { tokenizer.pos = prevTokenPos; tokenizer.error("Unexpected combinator") } combinators[token.value] = true } else if (prevToken !== null && prevToken.type !== "Combinator") { combinators[" "] = true; terms.push({ type: "Combinator", value: " " }) } terms.push(token); prevToken = token; prevTokenPos = tokenizer.pos } } if (prevToken !== null && prevToken.type === "Combinator") { tokenizer.pos -= prevTokenPos; tokenizer.error("Unexpected combinator") } return { type: "Group", terms: terms, combinator: regroupTerms(terms, combinators) || " ", disallowEmpty: false, explicit: false } } function readGroup(tokenizer) { var result; tokenizer.eat(LEFTSQUAREBRACKET); result = readImplicitGroup(tokenizer); tokenizer.eat(RIGHTSQUAREBRACKET); result.explicit = true; if (tokenizer.charCode() === EXCLAMATIONMARK) { tokenizer.pos++; result.disallowEmpty = true } return result } function peek(tokenizer) { var code = tokenizer.charCode(); if (code < 128 && NAME_CHAR[code] === 1) { return readKeywordOrFunction(tokenizer) } switch (code) { case RIGHTSQUAREBRACKET: break; case LEFTSQUAREBRACKET: return maybeMultiplied(tokenizer, readGroup(tokenizer)); case LESSTHANSIGN: return tokenizer.nextCharCode() === APOSTROPHE ? readProperty(tokenizer) : readType(tokenizer); case VERTICALLINE: return { type: "Combinator", value: tokenizer.substringToPos(tokenizer.nextCharCode() === VERTICALLINE ? tokenizer.pos + 2 : tokenizer.pos + 1) }; case AMPERSAND: tokenizer.pos++; tokenizer.eat(AMPERSAND); return { type: "Combinator", value: "&&" }; case COMMA: tokenizer.pos++; return { type: "Comma" }; case APOSTROPHE: return maybeMultiplied(tokenizer, { type: "String", value: scanString(tokenizer) }); case SPACE$1: case TAB$1: case N$2: case R$1: case F$1: return { type: "Spaces", value: scanSpaces(tokenizer) }; case COMMERCIALAT: code = tokenizer.nextCharCode(); if (code < 128 && NAME_CHAR[code] === 1) { tokenizer.pos++; return { type: "AtKeyword", name: scanWord(tokenizer) } } return maybeToken(tokenizer); case ASTERISK: case PLUSSIGN$2: case QUESTIONMARK$1: case NUMBERSIGN: case EXCLAMATIONMARK: break; case LEFTCURLYBRACKET: code = tokenizer.nextCharCode(); if (code < 48 || code > 57) { return maybeToken(tokenizer) } break; default: return maybeToken(tokenizer) } } function parse(source) { var tokenizer = new tokenizer$1(source); var result = readImplicitGroup(tokenizer); if (tokenizer.pos !== source.length) { tokenizer.error("Unexpected input") } if (result.terms.length === 1 && result.terms[0].type === "Group") { result = result.terms[0] } return result } parse("[a&&#|<'c'>*||e() f{2} /,(% g#{1,2} h{2,})]!"); var parse_1 = parse; var noop$1 = function () { }; function ensureFunction(value) { return typeof value === "function" ? value : noop$1 } var walk = function (node, options, context) { function walk(node) { enter.call(context, node); switch (node.type) { case "Group": node.terms.forEach(walk); break; case "Multiplier": walk(node.term); break; case "Type": case "Property": case "Keyword": case "AtKeyword": case "Function": case "String": case "Token": case "Comma": break; default: throw new Error("Unknown type: " + node.type) }leave.call(context, node) } var enter = noop$1; var leave = noop$1; if (typeof options === "function") { enter = options } else if (options) { enter = ensureFunction(options.enter); leave = ensureFunction(options.leave) } if (enter === noop$1 && leave === noop$1) { throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function") } walk(node) }; var tokenStream = new TokenStream_1; var astToTokens = { decorator: function (handlers) { var curNode = null; var prev = { len: 0, node: null }; var nodes = [prev]; var buffer = ""; return { children: handlers.children, node: function (node) { var tmp = curNode; curNode = node; handlers.node.call(this, node); curNode = tmp }, chunk: function (chunk) { buffer += chunk; if (prev.node !== curNode) { nodes.push({ len: chunk.length, node: curNode }) } else { prev.len += chunk.length } }, result: function () { return prepareTokens(buffer, nodes) } } } }; function prepareTokens(str, nodes) { var tokens = []; var nodesOffset = 0; var nodesIndex = 0; var currentNode = nodes ? nodes[nodesIndex].node : null; tokenizer(str, tokenStream); while (!tokenStream.eof) { if (nodes) { while (nodesIndex < nodes.length && nodesOffset + nodes[nodesIndex].len <= tokenStream.tokenStart) { nodesOffset += nodes[nodesIndex++].len; currentNode = nodes[nodesIndex].node } } tokens.push({ type: tokenStream.tokenType, value: tokenStream.getTokenValue(), index: tokenStream.tokenIndex, balance: tokenStream.balance[tokenStream.tokenIndex], node: currentNode }); tokenStream.next() } return tokens } var prepareTokens_1 = function (value, syntax) { if (typeof value === "string") { return prepareTokens(value, null) } return syntax.generate(value, astToTokens) }; var MATCH = { type: "Match" }; var MISMATCH = { type: "Mismatch" }; var DISALLOW_EMPTY = { type: "DisallowEmpty" }; var LEFTPARENTHESIS$1 = 40; var RIGHTPARENTHESIS$1 = 41; function createCondition(match, thenBranch, elseBranch) { if (thenBranch === MATCH && elseBranch === MISMATCH) { return match } if (match === MATCH && thenBranch === MATCH && elseBranch === MATCH) { return match } if (match.type === "If" && match.else === MISMATCH && thenBranch === MATCH) { thenBranch = match.then; match = match.match } return { type: "If", match: match, then: thenBranch, else: elseBranch } } function isFunctionType(name) { return name.length > 2 && name.charCodeAt(name.length - 2) === LEFTPARENTHESIS$1 && name.charCodeAt(name.length - 1) === RIGHTPARENTHESIS$1 } function isEnumCapatible(term) { return term.type === "Keyword" || term.type === "AtKeyword" || term.type === "Function" || term.type === "Type" && isFunctionType(term.name) } function buildGroupMatchGraph(combinator, terms, atLeastOneTermMatched) { switch (combinator) { case " ": var result = MATCH; for (var i = terms.length - 1; i >= 0; i--) { var term = terms[i]; result = createCondition(term, result, MISMATCH) } return result; case "|": var result = MISMATCH; var map = null; for (var i = terms.length - 1; i >= 0; i--) { var term = terms[i]; if (isEnumCapatible(term)) { if (map === null && i > 0 && isEnumCapatible(terms[i - 1])) { map = Object.create(null); result = createCondition({ type: "Enum", map: map }, MATCH, result) } if (map !== null) { var key = (isFunctionType(term.name) ? term.name.slice(0, -1) : term.name).toLowerCase(); if (key in map === false) { map[key] = term; continue } } } map = null; result = createCondition(term, MATCH, result) } return result; case "&&": if (terms.length > 5) { return { type: "MatchOnce", terms: terms, all: true } } var result = MISMATCH; for (var i = terms.length - 1; i >= 0; i--) { var term = terms[i]; var thenClause; if (terms.length > 1) { thenClause = buildGroupMatchGraph(combinator, terms.filter((function (newGroupTerm) { return newGroupTerm !== term })), false) } else { thenClause = MATCH } result = createCondition(term, thenClause, result) } return result; case "||": if (terms.length > 5) { return { type: "MatchOnce", terms: terms, all: false } } var result = atLeastOneTermMatched ? MATCH : MISMATCH; for (var i = terms.length - 1; i >= 0; i--) { var term = terms[i]; var thenClause; if (terms.length > 1) { thenClause = buildGroupMatchGraph(combinator, terms.filter((function (newGroupTerm) { return newGroupTerm !== term })), true) } else { thenClause = MATCH } result = createCondition(term, thenClause, result) } return result } } function buildMultiplierMatchGraph(node) { var result = MATCH; var matchTerm = buildMatchGraph(node.term); if (node.max === 0) { matchTerm = createCondition(matchTerm, DISALLOW_EMPTY, MISMATCH); result = createCondition(matchTerm, null, MISMATCH); result.then = createCondition(MATCH, MATCH, result); if (node.comma) { result.then.else = createCondition({ type: "Comma", syntax: node }, result, MISMATCH) } } else { for (var i = node.min || 1; i <= node.max; i++) { if (node.comma && result !== MATCH) { result = createCondition({ type: "Comma", syntax: node }, result, MISMATCH) } result = createCondition(matchTerm, createCondition(MATCH, MATCH, result), MISMATCH) } } if (node.min === 0) { result = createCondition(MATCH, MATCH, result) } else { for (var i = 0; i < node.min - 1; i++) { if (node.comma && result !== MATCH) { result = createCondition({ type: "Comma", syntax: node }, result, MISMATCH) } result = createCondition(matchTerm, result, MISMATCH) } } return result } function buildMatchGraph(node) { if (typeof node === "function") { return { type: "Generic", fn: node } } switch (node.type) { case "Group": var result = buildGroupMatchGraph(node.combinator, node.terms.map(buildMatchGraph), false); if (node.disallowEmpty) { result = createCondition(result, DISALLOW_EMPTY, MISMATCH) } return result; case "Multiplier": return buildMultiplierMatchGraph(node); case "Type": case "Property": return { type: node.type, name: node.name, syntax: node }; case "Keyword": return { type: node.type, name: node.name.toLowerCase(), syntax: node }; case "AtKeyword": return { type: node.type, name: "@" + node.name.toLowerCase(), syntax: node }; case "Function": return { type: node.type, name: node.name.toLowerCase() + "(", syntax: node }; case "String": if (node.value.length === 3) { return { type: "Token", value: node.value.charAt(1), syntax: node } } return { type: node.type, value: node.value.substr(1, node.value.length - 2).replace(/\\'/g, "'"), syntax: node }; case "Token": return { type: node.type, value: node.value, syntax: node }; case "Comma": return { type: node.type, syntax: node }; default: throw new Error("Unknown node type:", node.type) } } var matchGraph = { MATCH: MATCH, MISMATCH: MISMATCH, DISALLOW_EMPTY: DISALLOW_EMPTY, buildMatchGraph: function (syntaxTree, ref) { if (typeof syntaxTree === "string") { syntaxTree = parse_1(syntaxTree) } return { type: "MatchGraph", match: buildMatchGraph(syntaxTree), syntax: ref || null, source: syntaxTree } } }; var hasOwnProperty$1 = Object.prototype.hasOwnProperty; var MATCH$1 = matchGraph.MATCH; var MISMATCH$1 = matchGraph.MISMATCH; var DISALLOW_EMPTY$1 = matchGraph.DISALLOW_EMPTY; var TYPE$6 = _const.TYPE; var STUB = 0; var TOKEN = 1; var OPEN_SYNTAX = 2; var CLOSE_SYNTAX = 3; var EXIT_REASON_MATCH = "Match"; var EXIT_REASON_MISMATCH = "Mismatch"; var EXIT_REASON_ITERATION_LIMIT = "Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)"; var ITERATION_LIMIT = 15e3; var totalIterationCount = 0; function reverseList(list) { var prev = null; var next = null; var item = list; while (item !== null) { next = item.prev; item.prev = prev; prev = item; item = next } return prev } function areStringsEqualCaseInsensitive(testStr, referenceStr) { if (testStr.length !== referenceStr.length) { return false } for (var i = 0; i < testStr.length; i++) { var testCode = testStr.charCodeAt(i); var referenceCode = referenceStr.charCodeAt(i); if (testCode >= 65 && testCode <= 90) { testCode = testCode | 32 } if (testCode !== referenceCode) { return false } } return true } function isCommaContextStart(token) { if (token === null) { return true } return token.type === TYPE$6.Comma || token.type === TYPE$6.Function || token.type === TYPE$6.LeftParenthesis || token.type === TYPE$6.LeftSquareBracket || token.type === TYPE$6.LeftCurlyBracket || token.type === TYPE$6.Delim } function isCommaContextEnd(token) { if (token === null) { return true } return token.type === TYPE$6.RightParenthesis || token.type === TYPE$6.RightSquareBracket || token.type === TYPE$6.RightCurlyBracket || token.type === TYPE$6.Delim } function internalMatch(tokens, state, syntaxes) { function moveToNextToken() { do { tokenIndex++; token = tokenIndex < tokens.length ? tokens[tokenIndex] : null } while (token !== null && (token.type === TYPE$6.WhiteSpace || token.type === TYPE$6.Comment)) } function getNextToken(offset) { var nextIndex = tokenIndex + offset; return nextIndex < tokens.length ? tokens[nextIndex] : null } function stateSnapshotFromSyntax(nextState, prev) { return { nextState: nextState, matchStack: matchStack, syntaxStack: syntaxStack, thenStack: thenStack, tokenIndex: tokenIndex, prev: prev } } function pushThenStack(nextState) { thenStack = { nextState: nextState, matchStack: matchStack, syntaxStack: syntaxStack, prev: thenStack } } function pushElseStack(nextState) { elseStack = stateSnapshotFromSyntax(nextState, elseStack) } function addTokenToMatch() { matchStack = { type: TOKEN, syntax: state.syntax, token: token, prev: matchStack }; moveToNextToken(); syntaxStash = null; if (tokenIndex > longestMatch) { longestMatch = tokenIndex } } function openSyntax() { syntaxStack = { syntax: state.syntax, opts: state.syntax.opts || syntaxStack !== null && syntaxStack.opts || null, prev: syntaxStack }; matchStack = { type: OPEN_SYNTAX, syntax: state.syntax, token: matchStack.token, prev: matchStack } } function closeSyntax() { if (matchStack.type === OPEN_SYNTAX) { matchStack = matchStack.prev } else { matchStack = { type: CLOSE_SYNTAX, syntax: syntaxStack.syntax, token: matchStack.token, prev: matchStack } } syntaxStack = syntaxStack.prev } var syntaxStack = null; var thenStack = null; var elseStack = null; var syntaxStash = null; var iterationCount = 0; var exitReason = null; var token = null; var tokenIndex = -1; var longestMatch = 0; var matchStack = { type: STUB, syntax: null, token: null, prev: null }; moveToNextToken(); while (exitReason === null && ++iterationCount < ITERATION_LIMIT) { switch (state.type) { case "Match": if (thenStack === null) { if (token !== null) { if (tokenIndex !== tokens.length - 1 || token.value !== "\\0" && token.value !== "\\9") { state = MISMATCH$1; break } } exitReason = EXIT_REASON_MATCH; break } state = thenStack.nextState; if (state === DISALLOW_EMPTY$1) { if (thenStack.matchStack === matchStack) { state = MISMATCH$1; break } else { state = MATCH$1 } } while (thenStack.syntaxStack !== syntaxStack) { closeSyntax() } thenStack = thenStack.prev; break; case "Mismatch": if (syntaxStash !== null && syntaxStash !== false) { if (elseStack === null || tokenIndex > elseStack.tokenIndex) { elseStack = syntaxStash; syntaxStash = false } } else if (elseStack === null) { exitReason = EXIT_REASON_MISMATCH; break } state = elseStack.nextState; thenStack = elseStack.thenStack; syntaxStack = elseStack.syntaxStack; matchStack = elseStack.matchStack; tokenIndex = elseStack.tokenIndex; token = tokenIndex < tokens.length ? tokens[tokenIndex] : null; elseStack = elseStack.prev; break; case "MatchGraph": state = state.match; break; case "If": if (state.else !== MISMATCH$1) { pushElseStack(state.else) } if (state.then !== MATCH$1) { pushThenStack(state.then) } state = state.match; break; case "MatchOnce": state = { type: "MatchOnceBuffer", syntax: state, index: 0, mask: 0 }; break; case "MatchOnceBuffer": var terms = state.syntax.terms; if (state.index === terms.length) { if (state.mask === 0 || state.syntax.all) { state = MISMATCH$1; break } state = MATCH$1; break } if (state.mask === (1 << terms.length) - 1) { state = MATCH$1; break } for (; state.index < terms.length; state.index++) { var matchFlag = 1 << state.index; if ((state.mask & matchFlag) === 0) { pushElseStack(state); pushThenStack({ type: "AddMatchOnce", syntax: state.syntax, mask: state.mask | matchFlag }); state = terms[state.index++]; break } } break; case "AddMatchOnce": state = { type: "MatchOnceBuffer", syntax: state.syntax, index: 0, mask: state.mask }; break; case "Enum": if (token !== null) { var name = token.value.toLowerCase(); if (name.indexOf("\\") !== -1) { name = name.replace(/\\[09].*$/, "") } if (hasOwnProperty$1.call(state.map, name)) { state = state.map[name]; break } } state = MISMATCH$1; break; case "Generic": var opts = syntaxStack !== null ? syntaxStack.opts : null; var lastTokenIndex = tokenIndex + Math.floor(state.fn(token, getNextToken, opts)); if (!isNaN(lastTokenIndex) && lastTokenIndex > tokenIndex) { while (tokenIndex < lastTokenIndex) { addTokenToMatch() } state = MATCH$1 } else { state = MISMATCH$1 } break; case "Type": case "Property": var syntaxDict = state.type === "Type" ? "types" : "properties"; var dictSyntax = hasOwnProperty$1.call(syntaxes, syntaxDict) ? syntaxes[syntaxDict][state.name] : null; if (!dictSyntax || !dictSyntax.match) { throw new Error("Bad syntax reference: " + (state.type === "Type" ? "<" + state.name + ">" : "<'" + state.name + "'>")) } if (syntaxStash !== false && token !== null && state.type === "Type") { var lowPriorityMatching = state.name === "custom-ident" && token.type === TYPE$6.Ident || state.name === "length" && token.value === "0"; if (lowPriorityMatching) { if (syntaxStash === null) { syntaxStash = stateSnapshotFromSyntax(state, elseStack) } state = MISMATCH$1; break } } openSyntax(); state = dictSyntax.match; break; case "Keyword": var name = state.name; if (token !== null) { var keywordName = token.value; if (keywordName.indexOf("\\") !== -1) { keywordName = keywordName.replace(/\\[09].*$/, "") } if (areStringsEqualCaseInsensitive(keywordName, name)) { addTokenToMatch(); state = MATCH$1; break } } state = MISMATCH$1; break; case "AtKeyword": case "Function": if (token !== null && areStringsEqualCaseInsensitive(token.value, state.name)) { addTokenToMatch(); state = MATCH$1; break } state = MISMATCH$1; break; case "Token": if (token !== null && token.value === state.value) { addTokenToMatch(); state = MATCH$1; break } state = MISMATCH$1; break; case "Comma": if (token !== null && token.type === TYPE$6.Comma) { if (isCommaContextStart(matchStack.token)) { state = MISMATCH$1 } else { addTokenToMatch(); state = isCommaContextEnd(token) ? MISMATCH$1 : MATCH$1 } } else { state = isCommaContextStart(matchStack.token) || isCommaContextEnd(token) ? MATCH$1 : MISMATCH$1 } break; case "String": var string = ""; for (var lastTokenIndex = tokenIndex; lastTokenIndex < tokens.length && string.length < state.value.length; lastTokenIndex++) { string += tokens[lastTokenIndex].value } if (areStringsEqualCaseInsensitive(string, state.value)) { while (tokenIndex < lastTokenIndex) { addTokenToMatch() } state = MATCH$1 } else { state = MISMATCH$1 } break; default: throw new Error("Unknown node type: " + state.type) } } totalIterationCount += iterationCount; switch (exitReason) { case null: console.warn("[csstree-match] BREAK after " + ITERATION_LIMIT + " iterations"); exitReason = EXIT_REASON_ITERATION_LIMIT; matchStack = null; break; case EXIT_REASON_MATCH: while (syntaxStack !== null) { closeSyntax() } break; default: matchStack = null }return { tokens: tokens, reason: exitReason, iterations: iterationCount, match: matchStack, longestMatch: longestMatch } } function matchAsList(tokens, matchGraph, syntaxes) { var matchResult = internalMatch(tokens, matchGraph, syntaxes || {}); if (matchResult.match !== null) { var item = reverseList(matchResult.match).prev; matchResult.match = []; while (item !== null) { switch (item.type) { case STUB: break; case OPEN_SYNTAX: case CLOSE_SYNTAX: matchResult.match.push({ type: item.type, syntax: item.syntax }); break; default: matchResult.match.push({ token: item.token.value, node: item.token.node }); break }item = item.prev } } return matchResult } function matchAsTree(tokens, matchGraph, syntaxes) { var matchResult = internalMatch(tokens, matchGraph, syntaxes || {}); if (matchResult.match === null) { return matchResult } var item = matchResult.match; var host = matchResult.match = { syntax: matchGraph.syntax || null, match: [] }; var hostStack = [host]; item = reverseList(item).prev; while (item !== null) { switch (item.type) { case OPEN_SYNTAX: host.match.push(host = { syntax: item.syntax, match: [] }); hostStack.push(host); break; case CLOSE_SYNTAX: hostStack.pop(); host = hostStack[hostStack.length - 1]; break; default: host.match.push({ syntax: item.syntax || null, token: item.token.value, node: item.token.node }) }item = item.prev } return matchResult } var match = { matchAsList: matchAsList, matchAsTree: matchAsTree, getTotalIterationCount: function () { return totalIterationCount } }; function getTrace(node) { function shouldPutToTrace(syntax) { if (syntax === null) { return false } return syntax.type === "Type" || syntax.type === "Property" || syntax.type === "Keyword" } function hasMatch(matchNode) { if (Array.isArray(matchNode.match)) { for (var i = 0; i < matchNode.match.length; i++) { if (hasMatch(matchNode.match[i])) { if (shouldPutToTrace(matchNode.syntax)) { result.unshift(matchNode.syntax) } return true } } } else if (matchNode.node === node) { result = shouldPutToTrace(matchNode.syntax) ? [matchNode.syntax] : []; return true } return false } var result = null; if (this.matched !== null) { hasMatch(this.matched) } return result } function testNode(match, node, fn) { var trace = getTrace.call(match, node); if (trace === null) { return false } return trace.some(fn) } function isType(node, type) { return testNode(this, node, (function (matchNode) { return matchNode.type === "Type" && matchNode.name === type })) } function isProperty(node, property) { return testNode(this, node, (function (matchNode) { return matchNode.type === "Property" && matchNode.name === property })) } function isKeyword(node) { return testNode(this, node, (function (matchNode) { return matchNode.type === "Keyword" })) } var trace = { getTrace: getTrace, isType: isType, isProperty: isProperty, isKeyword: isKeyword }; function createItem(data) { return { prev: null, next: null, data: data } } function allocateCursor(node, prev, next) { var cursor; if (cursors !== null) { cursor = cursors; cursors = cursors.cursor; cursor.prev = prev; cursor.next = next; cursor.cursor = node.cursor } else { cursor = { prev: prev, next: next, cursor: node.cursor } } node.cursor = cursor; return cursor } function releaseCursor(node) { var cursor = node.cursor; node.cursor = cursor.cursor; cursor.prev = null; cursor.next = null; cursor.cursor = cursors; cursors = cursor } var cursors = null; var List = function () { this.cursor = null; this.head = null; this.tail = null }; List.createItem = createItem; List.prototype.createItem = createItem; List.prototype.updateCursors = function (prevOld, prevNew, nextOld, nextNew) { var cursor = this.cursor; while (cursor !== null) { if (cursor.prev === prevOld) { cursor.prev = prevNew } if (cursor.next === nextOld) { cursor.next = nextNew } cursor = cursor.cursor } }; List.prototype.getSize = function () { var size = 0; var cursor = this.head; while (cursor) { size++; cursor = cursor.next } return size }; List.prototype.fromArray = function (array) { var cursor = null; this.head = null; for (var i = 0; i < array.length; i++) { var item = createItem(array[i]); if (cursor !== null) { cursor.next = item } else { this.head = item } item.prev = cursor; cursor = item } this.tail = cursor; return this }; List.prototype.toArray = function () { var cursor = this.head; var result = []; while (cursor) { result.push(cursor.data); cursor = cursor.next } return result }; List.prototype.toJSON = List.prototype.toArray; List.prototype.isEmpty = function () { return this.head === null }; List.prototype.first = function () { return this.head && this.head.data }; List.prototype.last = function () { return this.tail && this.tail.data }; List.prototype.each = function (fn, context) { var item; if (context === undefined) { context = this } var cursor = allocateCursor(this, null, this.head); while (cursor.next !== null) { item = cursor.next; cursor.next = item.next; fn.call(context, item.data, item, this) } releaseCursor(this) }; List.prototype.forEach = List.prototype.each; List.prototype.eachRight = function (fn, context) { var item; if (context === undefined) { context = this } var cursor = allocateCursor(this, this.tail, null); while (cursor.prev !== null) { item = cursor.prev; cursor.prev = item.prev; fn.call(context, item.data, item, this) } releaseCursor(this) }; List.prototype.forEachRight = List.prototype.eachRight; List.prototype.nextUntil = function (start, fn, context) { if (start === null) { return } var item; if (context === undefined) { context = this } var cursor = allocateCursor(this, null, start); while (cursor.next !== null) { item = cursor.next; cursor.next = item.next; if (fn.call(context, item.data, item, this)) { break } } releaseCursor(this) }; List.prototype.prevUntil = function (start, fn, context) { if (start === null) { return } var item; if (context === undefined) { context = this } var cursor = allocateCursor(this, start, null); while (cursor.prev !== null) { item = cursor.prev; cursor.prev = item.prev; if (fn.call(context, item.data, item, this)) { break } } releaseCursor(this) }; List.prototype.some = function (fn, context) { var cursor = this.head; if (context === undefined) { context = this } while (cursor !== null) { if (fn.call(context, cursor.data, cursor, this)) { return true } cursor = cursor.next } return false }; List.prototype.map = function (fn, context) { var result = new List; var cursor = this.head; if (context === undefined) { context = this } while (cursor !== null) { result.appendData(fn.call(context, cursor.data, cursor, this)); cursor = cursor.next } return result }; List.prototype.filter = function (fn, context) { var result = new List; var cursor = this.head; if (context === undefined) { context = this } while (cursor !== null) { if (fn.call(context, cursor.data, cursor, this)) { result.appendData(cursor.data) } cursor = cursor.next } return result }; List.prototype.clear = function () { this.head = null; this.tail = null }; List.prototype.copy = function () { var result = new List; var cursor = this.head; while (cursor !== null) { result.insert(createItem(cursor.data)); cursor = cursor.next } return result }; List.prototype.prepend = function (item) { this.updateCursors(null, item, this.head, item); if (this.head !== null) { this.head.prev = item; item.next = this.head } else { this.tail = item } this.head = item; return this }; List.prototype.prependData = function (data) { return this.prepend(createItem(data)) }; List.prototype.append = function (item) { return this.insert(item) }; List.prototype.appendData = function (data) { return this.insert(createItem(data)) }; List.prototype.insert = function (item, before) { if (before !== undefined && before !== null) { this.updateCursors(before.prev, item, before, item); if (before.prev === null) { if (this.head !== before) { throw new Error("before doesn't belong to list") } this.head = item; before.prev = item; item.next = before; this.updateCursors(null, item) } else { before.prev.next = item; item.prev = before.prev; before.prev = item; item.next = before } } else { this.updateCursors(this.tail, item, null, item); if (this.tail !== null) { this.tail.next = item; item.prev = this.tail } else { this.head = item } this.tail = item } return this }; List.prototype.insertData = function (data, before) { return this.insert(createItem(data), before) }; List.prototype.remove = function (item) { this.updateCursors(item, item.prev, item, item.next); if (item.prev !== null) { item.prev.next = item.next } else { if (this.head !== item) { throw new Error("item doesn't belong to list") } this.head = item.next } if (item.next !== null) { item.next.prev = item.prev } else { if (this.tail !== item) { throw new Error("item doesn't belong to list") } this.tail = item.prev } item.prev = null; item.next = null; return item }; List.prototype.push = function (data) { this.insert(createItem(data)) }; List.prototype.pop = function () { if (this.tail !== null) { return this.remove(this.tail) } }; List.prototype.unshift = function (data) { this.prepend(createItem(data)) }; List.prototype.shift = function () { if (this.head !== null) { return this.remove(this.head) } }; List.prototype.prependList = function (list) { return this.insertList(list, this.head) }; List.prototype.appendList = function (list) { return this.insertList(list) }; List.prototype.insertList = function (list, before) { if (list.head === null) { return this } if (before !== undefined && before !== null) { this.updateCursors(before.prev, list.tail, before, list.head); if (before.prev !== null) { before.prev.next = list.head; list.head.prev = before.prev } else { this.head = list.head } before.prev = list.tail; list.tail.next = before } else { this.updateCursors(this.tail, list.tail, null, list.head); if (this.tail !== null) { this.tail.next = list.head; list.head.prev = this.tail } else { this.head = list.head } this.tail = list.tail } list.head = null; list.tail = null; return this }; List.prototype.replace = function (oldItem, newItemOrList) { if ("head" in newItemOrList) { this.insertList(newItemOrList, oldItem) } else { this.insert(newItemOrList, oldItem) } this.remove(oldItem) }; var List_1 = List; function getFirstMatchNode(matchNode) { if ("node" in matchNode) { return matchNode.node } return getFirstMatchNode(matchNode.match[0]) } function getLastMatchNode(matchNode) { if ("node" in matchNode) { return matchNode.node } return getLastMatchNode(matchNode.match[matchNode.match.length - 1]) } function matchFragments(lexer, ast, match, type, name) { function findFragments(matchNode) { if (matchNode.syntax !== null && matchNode.syntax.type === type && matchNode.syntax.name === name) { var start = getFirstMatchNode(matchNode); var end = getLastMatchNode(matchNode); lexer.syntax.walk(ast, (function (node, item, list) { if (node === start) { var nodes = new List_1; do { nodes.appendData(item.data); if (item.data === end) { break } item = item.next } while (item !== null); fragments.push({ parent: list, nodes: nodes }) } })) } if (Array.isArray(matchNode.match)) { matchNode.match.forEach(findFragments) } } var fragments = []; if (match.matched !== null) { findFragments(match.matched) } return fragments } var search = { matchFragments: matchFragments }; var hasOwnProperty$2 = Object.prototype.hasOwnProperty; function isValidNumber(value) { return typeof value === "number" && isFinite(value) && Math.floor(value) === value && value >= 0 } function isValidLocation(loc) { return Boolean(loc) && isValidNumber(loc.offset) && isValidNumber(loc.line) && isValidNumber(loc.column) } function createNodeStructureChecker(type, fields) { return function checkNode(node, warn) { if (!node || node.constructor !== Object) { return warn(node, "Type of node should be an Object") } for (var key in node) { var valid = true; if (hasOwnProperty$2.call(node, key) === false) { continue } if (key === "type") { if (node.type !== type) { warn(node, "Wrong node type `" + node.type + "`, expected `" + type + "`") } } else if (key === "loc") { if (node.loc === null) { continue } else if (node.loc && node.loc.constructor === Object) { if (typeof node.loc.source !== "string") { key += ".source" } else if (!isValidLocation(node.loc.start)) { key += ".start" } else if (!isValidLocation(node.loc.end)) { key += ".end" } else { continue } } valid = false } else if (fields.hasOwnProperty(key)) { for (var i = 0, valid = false; !valid && i < fields[key].length; i++) { var fieldType = fields[key][i]; switch (fieldType) { case String: valid = typeof node[key] === "string"; break; case Boolean: valid = typeof node[key] === "boolean"; break; case null: valid = node[key] === null; break; default: if (typeof fieldType === "string") { valid = node[key] && node[key].type === fieldType } else if (Array.isArray(fieldType)) { valid = node[key] instanceof List_1 } } } } else { warn(node, "Unknown field `" + key + "` for " + type + " node type") } if (!valid) { warn(node, "Bad value for `" + type + "." + key + "`") } } for (var key in fields) { if (hasOwnProperty$2.call(fields, key) && hasOwnProperty$2.call(node, key) === false) { warn(node, "Field `" + type + "." + key + "` is missed") } } } } function processStructure(name, nodeType) { var structure = nodeType.structure; var fields = { type: String, loc: true }; var docs = { type: '"' + name + '"' }; for (var key in structure) { if (hasOwnProperty$2.call(structure, key) === false) { continue } var docsTypes = []; var fieldTypes = fields[key] = Array.isArray(structure[key]) ? structure[key].slice() : [structure[key]]; for (var i = 0; i < fieldTypes.length; i++) { var fieldType = fieldTypes[i]; if (fieldType === String || fieldType === Boolean) { docsTypes.push(fieldType.name) } else if (fieldType === null) { docsTypes.push("null") } else if (typeof fieldType === "string") { docsTypes.push("<" + fieldType + ">") } else if (Array.isArray(fieldType)) { docsTypes.push("List") } else { throw new Error("Wrong value `" + fieldType + "` in `" + name + "." + key + "` structure definition") } } docs[key] = docsTypes.join(" | ") } return { docs: docs, check: createNodeStructureChecker(name, fields) } } var structure = { getStructureFromConfig: function (config) { var structure = {}; if (config.node) { for (var name in config.node) { if (hasOwnProperty$2.call(config.node, name)) { var nodeType = config.node[name]; if (nodeType.structure) { structure[name] = processStructure(name, nodeType) } else { throw new Error("Missed `structure` field in `" + name + "` node type definition") } } } } return structure } }; var SyntaxReferenceError$1 = error.SyntaxReferenceError; var MatchError$1 = error.MatchError; var buildMatchGraph$1 = matchGraph.buildMatchGraph; var matchAsTree$1 = match.matchAsTree; var getStructureFromConfig = structure.getStructureFromConfig; var cssWideKeywords$1 = buildMatchGraph$1("inherit | initial | unset"); var cssWideKeywordsWithExpression = buildMatchGraph$1("inherit | initial | unset | <-ms-legacy-expression>"); function dumpMapSyntax(map, compact, syntaxAsAst) { var result = {}; for (var name in map) { if (map[name].syntax) { result[name] = syntaxAsAst ? map[name].syntax : generate_1(map[name].syntax, { compact: compact }) } } return result } function valueHasVar(tokens) { for (var i = 0; i < tokens.length; i++) { if (tokens[i].value.toLowerCase() === "var(") { return true } } return false } function buildMatchResult(match, error, iterations) { return { matched: match, iterations: iterations, error: error, getTrace: trace.getTrace, isType: trace.isType, isProperty: trace.isProperty, isKeyword: trace.isKeyword } } function matchSyntax(lexer, syntax, value, useCommon) { var tokens = prepareTokens_1(value, lexer.syntax); var result; if (valueHasVar(tokens)) { return buildMatchResult(null, new Error("Matching for a tree with var() is not supported")) } if (useCommon) { result = matchAsTree$1(tokens, lexer.valueCommonSyntax, lexer) } if (!useCommon || !result.match) { result = matchAsTree$1(tokens, syntax.match, lexer); if (!result.match) { return buildMatchResult(null, new MatchError$1(result.reason, syntax.syntax, value, result), result.iterations) } } return buildMatchResult(result.match, null, result.iterations) } var Lexer = function (config, syntax, structure) { this.valueCommonSyntax = cssWideKeywords$1; this.syntax = syntax; this.generic = false; this.properties = {}; this.types = {}; this.structure = structure || getStructureFromConfig(config); if (config) { if (config.types) { for (var name in config.types) { this.addType_(name, config.types[name]) } } if (config.generic) { this.generic = true; for (var name in generic) { this.addType_(name, generic[name]) } } if (config.properties) { for (var name in config.properties) { this.addProperty_(name, config.properties[name]) } } } }; Lexer.prototype = { structure: {}, checkStructure: function (ast) { function collectWarning(node, message) { warns.push({ node: node, message: message }) } var structure = this.structure; var warns = []; this.syntax.walk(ast, (function (node) { if (structure.hasOwnProperty(node.type)) { structure[node.type].check(node, collectWarning) } else { collectWarning(node, "Unknown node type `" + node.type + "`") } })); return warns.length ? warns : false }, createDescriptor: function (syntax, type, name) { var ref = { type: type, name: name }; var descriptor = { type: type, name: name, syntax: null, match: null }; if (typeof syntax === "function") { descriptor.match = buildMatchGraph$1(syntax, ref) } else { if (typeof syntax === "string") { Object.defineProperty(descriptor, "syntax", { get: function () { Object.defineProperty(descriptor, "syntax", { value: parse_1(syntax) }); return descriptor.syntax } }) } else { descriptor.syntax = syntax } Object.defineProperty(descriptor, "match", { get: function () { Object.defineProperty(descriptor, "match", { value: buildMatchGraph$1(descriptor.syntax, ref) }); return descriptor.match } }) } return descriptor }, addProperty_: function (name, syntax) { this.properties[name] = this.createDescriptor(syntax, "Property", name) }, addType_: function (name, syntax) { this.types[name] = this.createDescriptor(syntax, "Type", name); if (syntax === generic["-ms-legacy-expression"]) { this.valueCommonSyntax = cssWideKeywordsWithExpression } }, matchDeclaration: function (node) { if (node.type !== "Declaration") { return buildMatchResult(null, new Error("Not a Declaration node")) } return this.matchProperty(node.property, node.value) }, matchProperty: function (propertyName, value) { var property = names.property(propertyName); if (property.custom) { return buildMatchResult(null, new Error("Lexer matching doesn't applicable for custom properties")) } var propertySyntax = property.vendor ? this.getProperty(property.name) || this.getProperty(property.basename) : this.getProperty(property.name); if (!propertySyntax) { return buildMatchResult(null, new SyntaxReferenceError$1("Unknown property", propertyName)) } return matchSyntax(this, propertySyntax, value, true) }, matchType: function (typeName, value) { var typeSyntax = this.getType(typeName); if (!typeSyntax) { return buildMatchResult(null, new SyntaxReferenceError$1("Unknown type", typeName)) } return matchSyntax(this, typeSyntax, value, false) }, match: function (syntax, value) { if (typeof syntax !== "string" && (!syntax || !syntax.type)) { return buildMatchResult(null, new SyntaxReferenceError$1("Bad syntax")) } if (typeof syntax === "string" || !syntax.match) { syntax = this.createDescriptor(syntax, "Type", "anonymous") } return matchSyntax(this, syntax, value, false) }, findValueFragments: function (propertyName, value, type, name) { return search.matchFragments(this, value, this.matchProperty(propertyName, value), type, name) }, findDeclarationValueFragments: function (declaration, type, name) { return search.matchFragments(this, declaration.value, this.matchDeclaration(declaration), type, name) }, findAllFragments: function (ast, type, name) { var result = []; this.syntax.walk(ast, { visit: "Declaration", enter: function (declaration) { result.push.apply(result, this.findDeclarationValueFragments(declaration, type, name)) }.bind(this) }); return result }, getProperty: function (name) { return this.properties.hasOwnProperty(name) ? this.properties[name] : null }, getType: function (name) { return this.types.hasOwnProperty(name) ? this.types[name] : null }, validate: function () { function validate(syntax, name, broken, descriptor) { if (broken.hasOwnProperty(name)) { return broken[name] } broken[name] = false; if (descriptor.syntax !== null) { walk(descriptor.syntax, (function (node) { if (node.type !== "Type" && node.type !== "Property") { return } var map = node.type === "Type" ? syntax.types : syntax.properties; var brokenMap = node.type === "Type" ? brokenTypes : brokenProperties; if (!map.hasOwnProperty(node.name) || validate(syntax, node.name, brokenMap, map[node.name])) { broken[name] = true } }), this) } } var brokenTypes = {}; var brokenProperties = {}; for (var key in this.types) { validate(this, key, brokenTypes, this.types[key]) } for (var key in this.properties) { validate(this, key, brokenProperties, this.properties[key]) } brokenTypes = Object.keys(brokenTypes).filter((function (name) { return brokenTypes[name] })); brokenProperties = Object.keys(brokenProperties).filter((function (name) { return brokenProperties[name] })); if (brokenTypes.length || brokenProperties.length) { return { types: brokenTypes, properties: brokenProperties } } return null }, dump: function (syntaxAsAst, pretty) { return { generic: this.generic, types: dumpMapSyntax(this.types, !pretty, syntaxAsAst), properties: dumpMapSyntax(this.properties, !pretty, syntaxAsAst) } }, toString: function () { return JSON.stringify(this.dump()) } }; var Lexer_1 = Lexer; var isBOM$2 = tokenizer.isBOM; var N$3 = 10; var F$2 = 12; var R$2 = 13; function computeLinesAndColumns(host, source) { var sourceLength = source.length; var lines = adoptBuffer(host.lines, sourceLength); var line = host.startLine; var columns = adoptBuffer(host.columns, sourceLength); var column = host.startColumn; var startOffset = source.length > 0 ? isBOM$2(source.charCodeAt(0)) : 0; for (var i = startOffset; i < sourceLength; i++) { var code = source.charCodeAt(i); lines[i] = line; columns[i] = column++; if (code === N$3 || code === R$2 || code === F$2) { if (code === R$2 && i + 1 < sourceLength && source.charCodeAt(i + 1) === N$3) { i++; lines[i] = line; columns[i] = column } line++; column = 1 } } lines[i] = line; columns[i] = column; host.lines = lines; host.columns = columns } var OffsetToLocation = function () { this.lines = null; this.columns = null; this.linesAndColumnsComputed = false }; OffsetToLocation.prototype = { setSource: function (source, startOffset, startLine, startColumn) { this.source = source; this.startOffset = typeof startOffset === "undefined" ? 0 : startOffset; this.startLine = typeof startLine === "undefined" ? 1 : startLine; this.startColumn = typeof startColumn === "undefined" ? 1 : startColumn; this.linesAndColumnsComputed = false }, ensureLinesAndColumnsComputed: function () { if (!this.linesAndColumnsComputed) { computeLinesAndColumns(this, this.source); this.linesAndColumnsComputed = true } }, getLocation: function (offset, filename) { this.ensureLinesAndColumnsComputed(); return { source: filename, offset: this.startOffset + offset, line: this.lines[offset], column: this.columns[offset] } }, getLocationRange: function (start, end, filename) { this.ensureLinesAndColumnsComputed(); return { source: filename, start: { offset: this.startOffset + start, line: this.lines[start], column: this.columns[start] }, end: { offset: this.startOffset + end, line: this.lines[end], column: this.columns[end] } } } }; var OffsetToLocation_1 = OffsetToLocation; var MAX_LINE_LENGTH = 100; var OFFSET_CORRECTION = 60; var TAB_REPLACEMENT = " "; function sourceFragment(error, extraLines) { function processLines(start, end) { return lines.slice(start, end).map((function (line, idx) { var num = String(start + idx + 1); while (num.length < maxNumLength) { num = " " + num } return num + " |" + line })).join("\n") } var lines = error.source.split(/\r\n?|\n|\f/); var line = error.line; var column = error.column; var startLine = Math.max(1, line - extraLines) - 1; var endLine = Math.min(line + extraLines, lines.length + 1); var maxNumLength = Math.max(4, String(endLine).length) + 1; var cutLeft = 0; column += (TAB_REPLACEMENT.length - 1) * (lines[line - 1].substr(0, column - 1).match(/\t/g) || []).length; if (column > MAX_LINE_LENGTH) { cutLeft = column - OFFSET_CORRECTION + 3; column = OFFSET_CORRECTION - 2 } for (var i = startLine; i <= endLine; i++) { if (i >= 0 && i < lines.length) { lines[i] = lines[i].replace(/\t/g, TAB_REPLACEMENT); lines[i] = (cutLeft > 0 && lines[i].length > cutLeft ? "…" : "") + lines[i].substr(cutLeft, MAX_LINE_LENGTH - 2) + (lines[i].length > cutLeft + MAX_LINE_LENGTH - 1 ? "…" : "") } } return [processLines(startLine, line), new Array(column + maxNumLength + 2).join("-") + "^", processLines(line, endLine)].filter(Boolean).join("\n") } var SyntaxError$1 = function (message, source, offset, line, column) { var error = createCustomError("SyntaxError", message); error.source = source; error.offset = offset; error.line = line; error.column = column; error.sourceFragment = function (extraLines) { return sourceFragment(error, isNaN(extraLines) ? 0 : extraLines) }; Object.defineProperty(error, "formattedMessage", { get: function () { return "Parse error: " + error.message + "\n" + sourceFragment(error, 2) } }); error.parseError = { offset: offset, line: line, column: column }; return error }; var _SyntaxError$1 = SyntaxError$1; var TYPE$7 = tokenizer.TYPE; var WHITESPACE$2 = TYPE$7.WhiteSpace; var COMMENT$2 = TYPE$7.Comment; var sequence = function readSequence(recognizer) { var children = this.createList(); var child = null; var context = { recognizer: recognizer, space: null, ignoreWS: false, ignoreWSAfter: false }; this.scanner.skipSC(); while (!this.scanner.eof) { switch (this.scanner.tokenType) { case COMMENT$2: this.scanner.next(); continue; case WHITESPACE$2: if (context.ignoreWS) { this.scanner.next() } else { context.space = this.WhiteSpace() } continue }child = recognizer.getNode.call(this, context); if (child === undefined) { break } if (context.space !== null) { children.push(context.space); context.space = null } children.push(child); if (context.ignoreWSAfter) { context.ignoreWSAfter = false; context.ignoreWS = true } else { context.ignoreWS = false } } return children }; var findWhiteSpaceStart$1 = utils.findWhiteSpaceStart; var noop$2 = function () { }; var TYPE$8 = _const.TYPE; var NAME$2 = _const.NAME; var WHITESPACE$3 = TYPE$8.WhiteSpace; var IDENT$2 = TYPE$8.Ident; var FUNCTION = TYPE$8.Function; var URL = TYPE$8.Url; var HASH = TYPE$8.Hash; var PERCENTAGE = TYPE$8.Percentage; var NUMBER$2 = TYPE$8.Number; var NUMBERSIGN$1 = 35; var NULL = 0; function createParseContext(name) { return function () { return this[name]() } } function processConfig(config) { var parserConfig = { context: {}, scope: {}, atrule: {}, pseudo: {} }; if (config.parseContext) { for (var name in config.parseContext) { switch (typeof config.parseContext[name]) { case "function": parserConfig.context[name] = config.parseContext[name]; break; case "string": parserConfig.context[name] = createParseContext(config.parseContext[name]); break } } } if (config.scope) { for (var name in config.scope) { parserConfig.scope[name] = config.scope[name] } } if (config.atrule) { for (var name in config.atrule) { var atrule = config.atrule[name]; if (atrule.parse) { parserConfig.atrule[name] = atrule.parse } } } if (config.pseudo) { for (var name in config.pseudo) { var pseudo = config.pseudo[name]; if (pseudo.parse) { parserConfig.pseudo[name] = pseudo.parse } } } if (config.node) { for (var name in config.node) { parserConfig[name] = config.node[name].parse } } return parserConfig } var create = function createParser(config) { var parser = { scanner: new TokenStream_1, locationMap: new OffsetToLocation_1, filename: "", needPositions: false, onParseError: noop$2, onParseErrorThrow: false, parseAtrulePrelude: true, parseRulePrelude: true, parseValue: true, parseCustomProperty: false, readSequence: sequence, createList: function () { return new List_1 }, createSingleNodeList: function (node) { return (new List_1).appendData(node) }, getFirstListNode: function (list) { return list && list.first() }, getLastListNode: function (list) { return list.last() }, parseWithFallback: function (consumer, fallback) { var startToken = this.scanner.tokenIndex; try { return consumer.call(this) } catch (e) { if (this.onParseErrorThrow) { throw e } var fallbackNode = fallback.call(this, startToken); this.onParseErrorThrow = true; this.onParseError(e, fallbackNode); this.onParseErrorThrow = false; return fallbackNode } }, lookupNonWSType: function (offset) { do { var type = this.scanner.lookupType(offset++); if (type !== WHITESPACE$3) { return type } } while (type !== NULL); return NULL }, eat: function (tokenType) { if (this.scanner.tokenType !== tokenType) { var offset = this.scanner.tokenStart; var message = NAME$2[tokenType] + " is expected"; switch (tokenType) { case IDENT$2: if (this.scanner.tokenType === FUNCTION || this.scanner.tokenType === URL) { offset = this.scanner.tokenEnd - 1; message = "Identifier is expected but function found" } else { message = "Identifier is expected" } break; case HASH: if (this.scanner.isDelim(NUMBERSIGN$1)) { this.scanner.next(); offset++; message = "Name is expected" } break; case PERCENTAGE: if (this.scanner.tokenType === NUMBER$2) { offset = this.scanner.tokenEnd; message = "Percent sign is expected" } break; default: if (this.scanner.source.charCodeAt(this.scanner.tokenStart) === tokenType) { offset = offset + 1 } }this.error(message, offset) } this.scanner.next() }, consume: function (tokenType) { var value = this.scanner.getTokenValue(); this.eat(tokenType); return value }, consumeFunctionName: function () { var name = this.scanner.source.substring(this.scanner.tokenStart, this.scanner.tokenEnd - 1); this.eat(FUNCTION); return name }, getLocation: function (start, end) { if (this.needPositions) { return this.locationMap.getLocationRange(start, end, this.filename) } return null }, getLocationFromList: function (list) { if (this.needPositions) { var head = this.getFirstListNode(list); var tail = this.getLastListNode(list); return this.locationMap.getLocationRange(head !== null ? head.loc.start.offset - this.locationMap.startOffset : this.scanner.tokenStart, tail !== null ? tail.loc.end.offset - this.locationMap.startOffset : this.scanner.tokenStart, this.filename) } return null }, error: function (message, offset) { var location = typeof offset !== "undefined" && offset < this.scanner.source.length ? this.locationMap.getLocation(offset) : this.scanner.eof ? this.locationMap.getLocation(findWhiteSpaceStart$1(this.scanner.source, this.scanner.source.length - 1)) : this.locationMap.getLocation(this.scanner.tokenStart); throw new _SyntaxError$1(message || "Unexpected input", this.scanner.source, location.offset, location.line, location.column) } }; config = processConfig(config || {}); for (var key in config) { parser[key] = config[key] } return function (source, options) { options = options || {}; var context = options.context || "default"; var ast; tokenizer(source, parser.scanner); parser.locationMap.setSource(source, options.offset, options.line, options.column); parser.filename = options.filename || ""; parser.needPositions = Boolean(options.positions); parser.onParseError = typeof options.onParseError === "function" ? options.onParseError : noop$2; parser.onParseErrorThrow = false; parser.parseAtrulePrelude = "parseAtrulePrelude" in options ? Boolean(options.parseAtrulePrelude) : true; parser.parseRulePrelude = "parseRulePrelude" in options ? Boolean(options.parseRulePrelude) : true; parser.parseValue = "parseValue" in options ? Boolean(options.parseValue) : true; parser.parseCustomProperty = "parseCustomProperty" in options ? Boolean(options.parseCustomProperty) : false; if (!parser.context.hasOwnProperty(context)) { throw new Error("Unknown context `" + context + "`") } ast = parser.context[context].call(parser, options); if (!parser.scanner.eof) { parser.error() } return ast } }; var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); var encode = function (number) { if (0 <= number && number < intToCharMap.length) { return intToCharMap[number] } throw new TypeError("Must be between 0 and 63: " + number) }; var decode = function (charCode) { var bigA = 65; var bigZ = 90; var littleA = 97; var littleZ = 122; var zero = 48; var nine = 57; var plus = 43; var slash = 47; var littleOffset = 26; var numberOffset = 52; if (bigA <= charCode && charCode <= bigZ) { return charCode - bigA } if (littleA <= charCode && charCode <= littleZ) { return charCode - littleA + littleOffset } if (zero <= charCode && charCode <= nine) { return charCode - zero + numberOffset } if (charCode == plus) { return 62 } if (charCode == slash) { return 63 } return -1 }; var base64 = { encode: encode, decode: decode }; var VLQ_BASE_SHIFT = 5; var VLQ_BASE = 1 << VLQ_BASE_SHIFT; var VLQ_BASE_MASK = VLQ_BASE - 1; var VLQ_CONTINUATION_BIT = VLQ_BASE; function toVLQSigned(aValue) { return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0 } function fromVLQSigned(aValue) { var isNegative = (aValue & 1) === 1; var shifted = aValue >> 1; return isNegative ? -shifted : shifted } var encode$1 = function base64VLQ_encode(aValue) { var encoded = ""; var digit; var vlq = toVLQSigned(aValue); do { digit = vlq & VLQ_BASE_MASK; vlq >>>= VLQ_BASE_SHIFT; if (vlq > 0) { digit |= VLQ_CONTINUATION_BIT } encoded += base64.encode(digit) } while (vlq > 0); return encoded }; var decode$1 = function base64VLQ_decode(aStr, aIndex, aOutParam) { var strLen = aStr.length; var result = 0; var shift = 0; var continuation, digit; do { if (aIndex >= strLen) { throw new Error("Expected more digits in base 64 VLQ value.") } digit = base64.decode(aStr.charCodeAt(aIndex++)); if (digit === -1) { throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)) } continuation = !!(digit & VLQ_CONTINUATION_BIT); digit &= VLQ_BASE_MASK; result = result + (digit << shift); shift += VLQ_BASE_SHIFT } while (continuation); aOutParam.value = fromVLQSigned(result); aOutParam.rest = aIndex }; var base64Vlq = { encode: encode$1, decode: decode$1 }; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports } function getCjsExportFromNamespace(n) { return n && n["default"] || n } var util = createCommonjsModule((function (module, exports) { function getArg(aArgs, aName, aDefaultValue) { if (aName in aArgs) { return aArgs[aName] } else if (arguments.length === 3) { return aDefaultValue } else { throw new Error('"' + aName + '" is a required argument.') } } exports.getArg = getArg; var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; var dataUrlRegexp = /^data:.+\,.+$/; function urlParse(aUrl) { var match = aUrl.match(urlRegexp); if (!match) { return null } return { scheme: match[1], auth: match[2], host: match[3], port: match[4], path: match[5] } } exports.urlParse = urlParse; function urlGenerate(aParsedUrl) { var url = ""; if (aParsedUrl.scheme) { url += aParsedUrl.scheme + ":" } url += "//"; if (aParsedUrl.auth) { url += aParsedUrl.auth + "@" } if (aParsedUrl.host) { url += aParsedUrl.host } if (aParsedUrl.port) { url += ":" + aParsedUrl.port } if (aParsedUrl.path) { url += aParsedUrl.path } return url } exports.urlGenerate = urlGenerate; function normalize(aPath) { var path = aPath; var url = urlParse(aPath); if (url) { if (!url.path) { return aPath } path = url.path } var isAbsolute = exports.isAbsolute(path); var parts = path.split(/\/+/); for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { part = parts[i]; if (part === ".") { parts.splice(i, 1) } else if (part === "..") { up++ } else if (up > 0) { if (part === "") { parts.splice(i + 1, up); up = 0 } else { parts.splice(i, 2); up-- } } } path = parts.join("/"); if (path === "") { path = isAbsolute ? "/" : "." } if (url) { url.path = path; return urlGenerate(url) } return path } exports.normalize = normalize; function join(aRoot, aPath) { if (aRoot === "") { aRoot = "." } if (aPath === "") { aPath = "." } var aPathUrl = urlParse(aPath); var aRootUrl = urlParse(aRoot); if (aRootUrl) { aRoot = aRootUrl.path || "/" } if (aPathUrl && !aPathUrl.scheme) { if (aRootUrl) { aPathUrl.scheme = aRootUrl.scheme } return urlGenerate(aPathUrl) } if (aPathUrl || aPath.match(dataUrlRegexp)) { return aPath } if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { aRootUrl.host = aPath; return urlGenerate(aRootUrl) } var joined = aPath.charAt(0) === "/" ? aPath : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath); if (aRootUrl) { aRootUrl.path = joined; return urlGenerate(aRootUrl) } return joined } exports.join = join; exports.isAbsolute = function (aPath) { return aPath.charAt(0) === "/" || urlRegexp.test(aPath) }; function relative(aRoot, aPath) { if (aRoot === "") { aRoot = "." } aRoot = aRoot.replace(/\/$/, ""); var level = 0; while (aPath.indexOf(aRoot + "/") !== 0) { var index = aRoot.lastIndexOf("/"); if (index < 0) { return aPath } aRoot = aRoot.slice(0, index); if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { return aPath } ++level } return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1) } exports.relative = relative; var supportsNullProto = function () { var obj = Object.create(null); return !("__proto__" in obj) }(); function identity(s) { return s } function toSetString(aStr) { if (isProtoString(aStr)) { return "$" + aStr } return aStr } exports.toSetString = supportsNullProto ? identity : toSetString; function fromSetString(aStr) { if (isProtoString(aStr)) { return aStr.slice(1) } return aStr } exports.fromSetString = supportsNullProto ? identity : fromSetString; function isProtoString(s) { if (!s) { return false } var length = s.length; if (length < 9) { return false } if (s.charCodeAt(length - 1) !== 95 || s.charCodeAt(length - 2) !== 95 || s.charCodeAt(length - 3) !== 111 || s.charCodeAt(length - 4) !== 116 || s.charCodeAt(length - 5) !== 111 || s.charCodeAt(length - 6) !== 114 || s.charCodeAt(length - 7) !== 112 || s.charCodeAt(length - 8) !== 95 || s.charCodeAt(length - 9) !== 95) { return false } for (var i = length - 10; i >= 0; i--) { if (s.charCodeAt(i) !== 36) { return false } } return true } function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { var cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp } cmp = mappingA.originalColumn - mappingB.originalColumn; if (cmp !== 0 || onlyCompareOriginal) { return cmp } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0) { return cmp } cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp } return strcmp(mappingA.name, mappingB.name) } exports.compareByOriginalPositions = compareByOriginalPositions; function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { var cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0 || onlyCompareGenerated) { return cmp } cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp } cmp = mappingA.originalColumn - mappingB.originalColumn; if (cmp !== 0) { return cmp } return strcmp(mappingA.name, mappingB.name) } exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; function strcmp(aStr1, aStr2) { if (aStr1 === aStr2) { return 0 } if (aStr1 === null) { return 1 } if (aStr2 === null) { return -1 } if (aStr1 > aStr2) { return 1 } return -1 } function compareByGeneratedPositionsInflated(mappingA, mappingB) { var cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0) { return cmp } cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp } cmp = mappingA.originalColumn - mappingB.originalColumn; if (cmp !== 0) { return cmp } return strcmp(mappingA.name, mappingB.name) } exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; function parseSourceMapInput(str) { return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, "")) } exports.parseSourceMapInput = parseSourceMapInput; function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { sourceURL = sourceURL || ""; if (sourceRoot) { if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") { sourceRoot += "/" } sourceURL = sourceRoot + sourceURL } if (sourceMapURL) { var parsed = urlParse(sourceMapURL); if (!parsed) { throw new Error("sourceMapURL could not be parsed") } if (parsed.path) { var index = parsed.path.lastIndexOf("/"); if (index >= 0) { parsed.path = parsed.path.substring(0, index + 1) } } sourceURL = join(urlGenerate(parsed), sourceURL) } return normalize(sourceURL) } exports.computeSourceURL = computeSourceURL })); var util_1 = util.getArg; var util_2 = util.urlParse; var util_3 = util.urlGenerate; var util_4 = util.normalize; var util_5 = util.join; var util_6 = util.isAbsolute; var util_7 = util.relative; var util_8 = util.toSetString; var util_9 = util.fromSetString; var util_10 = util.compareByOriginalPositions; var util_11 = util.compareByGeneratedPositionsDeflated; var util_12 = util.compareByGeneratedPositionsInflated; var util_13 = util.parseSourceMapInput; var util_14 = util.computeSourceURL; var has = Object.prototype.hasOwnProperty; var hasNativeMap = typeof Map !== "undefined"; function ArraySet() { this._array = []; this._set = hasNativeMap ? new Map : Object.create(null) } ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { var set = new ArraySet; for (var i = 0, len = aArray.length; i < len; i++) { set.add(aArray[i], aAllowDuplicates) } return set }; ArraySet.prototype.size = function ArraySet_size() { return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length }; ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { var sStr = hasNativeMap ? aStr : util.toSetString(aStr); var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); var idx = this._array.length; if (!isDuplicate || aAllowDuplicates) { this._array.push(aStr) } if (!isDuplicate) { if (hasNativeMap) { this._set.set(aStr, idx) } else { this._set[sStr] = idx } } }; ArraySet.prototype.has = function ArraySet_has(aStr) { if (hasNativeMap) { return this._set.has(aStr) } else { var sStr = util.toSetString(aStr); return has.call(this._set, sStr) } }; ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { if (hasNativeMap) { var idx = this._set.get(aStr); if (idx >= 0) { return idx } } else { var sStr = util.toSetString(aStr); if (has.call(this._set, sStr)) { return this._set[sStr] } } throw new Error('"' + aStr + '" is not in the set.') }; ArraySet.prototype.at = function ArraySet_at(aIdx) { if (aIdx >= 0 && aIdx < this._array.length) { return this._array[aIdx] } throw new Error("No element indexed by " + aIdx) }; ArraySet.prototype.toArray = function ArraySet_toArray() { return this._array.slice() }; var ArraySet_1 = ArraySet; var arraySet = { ArraySet: ArraySet_1 }; function generatedPositionAfter(mappingA, mappingB) { var lineA = mappingA.generatedLine; var lineB = mappingB.generatedLine; var columnA = mappingA.generatedColumn; var columnB = mappingB.generatedColumn; return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0 } function MappingList() { this._array = []; this._sorted = true; this._last = { generatedLine: -1, generatedColumn: 0 } } MappingList.prototype.unsortedForEach = function MappingList_forEach(aCallback, aThisArg) { this._array.forEach(aCallback, aThisArg) }; MappingList.prototype.add = function MappingList_add(aMapping) { if (generatedPositionAfter(this._last, aMapping)) { this._last = aMapping; this._array.push(aMapping) } else { this._sorted = false; this._array.push(aMapping) } }; MappingList.prototype.toArray = function MappingList_toArray() { if (!this._sorted) { this._array.sort(util.compareByGeneratedPositionsInflated); this._sorted = true } return this._array }; var MappingList_1 = MappingList; var mappingList = { MappingList: MappingList_1 }; var ArraySet$1 = arraySet.ArraySet; var MappingList$1 = mappingList.MappingList; function SourceMapGenerator(aArgs) { if (!aArgs) { aArgs = {} } this._file = util.getArg(aArgs, "file", null); this._sourceRoot = util.getArg(aArgs, "sourceRoot", null); this._skipValidation = util.getArg(aArgs, "skipValidation", false); this._sources = new ArraySet$1; this._names = new ArraySet$1; this._mappings = new MappingList$1; this._sourcesContents = null } SourceMapGenerator.prototype._version = 3; SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { var sourceRoot = aSourceMapConsumer.sourceRoot; var generator = new SourceMapGenerator({ file: aSourceMapConsumer.file, sourceRoot: sourceRoot }); aSourceMapConsumer.eachMapping((function (mapping) { var newMapping = { generated: { line: mapping.generatedLine, column: mapping.generatedColumn } }; if (mapping.source != null) { newMapping.source = mapping.source; if (sourceRoot != null) { newMapping.source = util.relative(sourceRoot, newMapping.source) } newMapping.original = { line: mapping.originalLine, column: mapping.originalColumn }; if (mapping.name != null) { newMapping.name = mapping.name } } generator.addMapping(newMapping) })); aSourceMapConsumer.sources.forEach((function (sourceFile) { var sourceRelative = sourceFile; if (sourceRoot !== null) { sourceRelative = util.relative(sourceRoot, sourceFile) } if (!generator._sources.has(sourceRelative)) { generator._sources.add(sourceRelative) } var content = aSourceMapConsumer.sourceContentFor(sourceFile); if (content != null) { generator.setSourceContent(sourceFile, content) } })); return generator }; SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) { var generated = util.getArg(aArgs, "generated"); var original = util.getArg(aArgs, "original", null); var source = util.getArg(aArgs, "source", null); var name = util.getArg(aArgs, "name", null); if (!this._skipValidation) { this._validateMapping(generated, original, source, name) } if (source != null) { source = String(source); if (!this._sources.has(source)) { this._sources.add(source) } } if (name != null) { name = String(name); if (!this._names.has(name)) { this._names.add(name) } } this._mappings.add({ generatedLine: generated.line, generatedColumn: generated.column, originalLine: original != null && original.line, originalColumn: original != null && original.column, source: source, name: name }) }; SourceMapGenerator.prototype.setSourceContent = function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { var source = aSourceFile; if (this._sourceRoot != null) { source = util.relative(this._sourceRoot, source) } if (aSourceContent != null) { if (!this._sourcesContents) { this._sourcesContents = Object.create(null) } this._sourcesContents[util.toSetString(source)] = aSourceContent } else if (this._sourcesContents) { delete this._sourcesContents[util.toSetString(source)]; if (Object.keys(this._sourcesContents).length === 0) { this._sourcesContents = null } } }; SourceMapGenerator.prototype.applySourceMap = function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { var sourceFile = aSourceFile; if (aSourceFile == null) { if (aSourceMapConsumer.file == null) { throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, " + 'or the source map\'s "file" property. Both were omitted.') } sourceFile = aSourceMapConsumer.file } var sourceRoot = this._sourceRoot; if (sourceRoot != null) { sourceFile = util.relative(sourceRoot, sourceFile) } var newSources = new ArraySet$1; var newNames = new ArraySet$1; this._mappings.unsortedForEach((function (mapping) { if (mapping.source === sourceFile && mapping.originalLine != null) { var original = aSourceMapConsumer.originalPositionFor({ line: mapping.originalLine, column: mapping.originalColumn }); if (original.source != null) { mapping.source = original.source; if (aSourceMapPath != null) { mapping.source = util.join(aSourceMapPath, mapping.source) } if (sourceRoot != null) { mapping.source = util.relative(sourceRoot, mapping.source) } mapping.originalLine = original.line; mapping.originalColumn = original.column; if (original.name != null) { mapping.name = original.name } } } var source = mapping.source; if (source != null && !newSources.has(source)) { newSources.add(source) } var name = mapping.name; if (name != null && !newNames.has(name)) { newNames.add(name) } }), this); this._sources = newSources; this._names = newNames; aSourceMapConsumer.sources.forEach((function (sourceFile) { var content = aSourceMapConsumer.sourceContentFor(sourceFile); if (content != null) { if (aSourceMapPath != null) { sourceFile = util.join(aSourceMapPath, sourceFile) } if (sourceRoot != null) { sourceFile = util.relative(sourceRoot, sourceFile) } this.setSourceContent(sourceFile, content) } }), this) }; SourceMapGenerator.prototype._validateMapping = function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, aName) { if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") { throw new Error("original.line and original.column are not numbers -- you probably meant to omit " + "the original mapping entirely and only map the generated position. If so, pass " + "null for the original mapping instead of an object with empty or null values.") } if (aGenerated && "line" in aGenerated && "column" in aGenerated && aGenerated.line > 0 && aGenerated.column >= 0 && !aOriginal && !aSource && !aName) { return } else if (aGenerated && "line" in aGenerated && "column" in aGenerated && aOriginal && "line" in aOriginal && "column" in aOriginal && aGenerated.line > 0 && aGenerated.column >= 0 && aOriginal.line > 0 && aOriginal.column >= 0 && aSource) { return } else { throw new Error("Invalid mapping: " + JSON.stringify({ generated: aGenerated, source: aSource, original: aOriginal, name: aName })) } }; SourceMapGenerator.prototype._serializeMappings = function SourceMapGenerator_serializeMappings() { var previousGeneratedColumn = 0; var previousGeneratedLine = 1; var previousOriginalColumn = 0; var previousOriginalLine = 0; var previousName = 0; var previousSource = 0; var result = ""; var next; var mapping; var nameIdx; var sourceIdx; var mappings = this._mappings.toArray(); for (var i = 0, len = mappings.length; i < len; i++) { mapping = mappings[i]; next = ""; if (mapping.generatedLine !== previousGeneratedLine) { previousGeneratedColumn = 0; while (mapping.generatedLine !== previousGeneratedLine) { next += ";"; previousGeneratedLine++ } } else { if (i > 0) { if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { continue } next += "," } } next += base64Vlq.encode(mapping.generatedColumn - previousGeneratedColumn); previousGeneratedColumn = mapping.generatedColumn; if (mapping.source != null) { sourceIdx = this._sources.indexOf(mapping.source); next += base64Vlq.encode(sourceIdx - previousSource); previousSource = sourceIdx; next += base64Vlq.encode(mapping.originalLine - 1 - previousOriginalLine); previousOriginalLine = mapping.originalLine - 1; next += base64Vlq.encode(mapping.originalColumn - previousOriginalColumn); previousOriginalColumn = mapping.originalColumn; if (mapping.name != null) { nameIdx = this._names.indexOf(mapping.name); next += base64Vlq.encode(nameIdx - previousName); previousName = nameIdx } } result += next } return result }; SourceMapGenerator.prototype._generateSourcesContent = function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { return aSources.map((function (source) { if (!this._sourcesContents) { return null } if (aSourceRoot != null) { source = util.relative(aSourceRoot, source) } var key = util.toSetString(source); return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) ? this._sourcesContents[key] : null }), this) }; SourceMapGenerator.prototype.toJSON = function SourceMapGenerator_toJSON() { var map = { version: this._version, sources: this._sources.toArray(), names: this._names.toArray(), mappings: this._serializeMappings() }; if (this._file != null) { map.file = this._file } if (this._sourceRoot != null) { map.sourceRoot = this._sourceRoot } if (this._sourcesContents) { map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot) } return map }; SourceMapGenerator.prototype.toString = function SourceMapGenerator_toString() { return JSON.stringify(this.toJSON()) }; var SourceMapGenerator_1 = SourceMapGenerator; var sourceMapGenerator = { SourceMapGenerator: SourceMapGenerator_1 }; var SourceMapGenerator$1 = sourceMapGenerator.SourceMapGenerator; var trackNodes = { Atrule: true, Selector: true, Declaration: true }; var sourceMap = function generateSourceMap(handlers) { var map = new SourceMapGenerator$1; var line = 1; var column = 0; var generated = { line: 1, column: 0 }; var original = { line: 0, column: 0 }; var sourceMappingActive = false; var activatedGenerated = { line: 1, column: 0 }; var activatedMapping = { generated: activatedGenerated }; var handlersNode = handlers.node; handlers.node = function (node) { if (node.loc && node.loc.start && trackNodes.hasOwnProperty(node.type)) { var nodeLine = node.loc.start.line; var nodeColumn = node.loc.start.column - 1; if (original.line !== nodeLine || original.column !== nodeColumn) { original.line = nodeLine; original.column = nodeColumn; generated.line = line; generated.column = column; if (sourceMappingActive) { sourceMappingActive = false; if (generated.line !== activatedGenerated.line || generated.column !== activatedGenerated.column) { map.addMapping(activatedMapping) } } sourceMappingActive = true; map.addMapping({ source: node.loc.source, original: original, generated: generated }) } } handlersNode.call(this, node); if (sourceMappingActive && trackNodes.hasOwnProperty(node.type)) { activatedGenerated.line = line; activatedGenerated.column = column } }; var handlersChunk = handlers.chunk; handlers.chunk = function (chunk) { for (var i = 0; i < chunk.length; i++) { if (chunk.charCodeAt(i) === 10) { line++; column = 0 } else { column++ } } handlersChunk(chunk) }; var handlersResult = handlers.result; handlers.result = function () { if (sourceMappingActive) { map.addMapping(activatedMapping) } return { css: handlersResult(), map: map } }; return handlers }; var hasOwnProperty$3 = Object.prototype.hasOwnProperty; function processChildren(node, delimeter) { var list = node.children; var prev = null; if (typeof delimeter !== "function") { list.forEach(this.node, this) } else { list.forEach((function (node) { if (prev !== null) { delimeter.call(this, prev) } this.node(node); prev = node }), this) } } var create$1 = function createGenerator(config) { function processNode(node) { if (hasOwnProperty$3.call(types, node.type)) { types[node.type].call(this, node) } else { throw new Error("Unknown node type: " + node.type) } } var types = {}; if (config.node) { for (var name in config.node) { types[name] = config.node[name].generate } } return function (node, options) { var buffer = ""; var handlers = { children: processChildren, node: processNode, chunk: function (chunk) { buffer += chunk }, result: function () { return buffer } }; if (options) { if (typeof options.decorator === "function") { handlers = options.decorator(handlers) } if (options.sourceMap) { handlers = sourceMap(handlers) } } handlers.node(node); return handlers.result() } }; var hasOwnProperty$4 = Object.prototype.hasOwnProperty; var shape = { generic: true, types: {}, properties: {}, parseContext: {}, scope: {}, atrule: ["parse"], pseudo: ["parse"], node: ["name", "structure", "parse", "generate", "walkContext"] }; function isObject(value) { return value && value.constructor === Object } function copy(value) { if (isObject(value)) { var res = {}; for (var key in value) { if (hasOwnProperty$4.call(value, key)) { res[key] = value[key] } } return res } else { return value } } function extend(dest, src) { for (var key in src) { if (hasOwnProperty$4.call(src, key)) { if (isObject(dest[key])) { extend(dest[key], copy(src[key])) } else { dest[key] = copy(src[key]) } } } } function mix(dest, src, shape) { for (var key in shape) { if (hasOwnProperty$4.call(shape, key) === false) { continue } if (shape[key] === true) { if (key in src) { if (hasOwnProperty$4.call(src, key)) { dest[key] = copy(src[key]) } } } else if (shape[key]) { if (isObject(shape[key])) { var res = {}; extend(res, dest[key]); extend(res, src[key]); dest[key] = res } else if (Array.isArray(shape[key])) { var res = {}; var innerShape = shape[key].reduce((function (s, k) { s[k] = true; return s }), {}); for (var name in dest[key]) { if (hasOwnProperty$4.call(dest[key], name)) { res[name] = {}; if (dest[key] && dest[key][name]) { mix(res[name], dest[key][name], innerShape) } } } for (var name in src[key]) { if (hasOwnProperty$4.call(src[key], name)) { if (!res[name]) { res[name] = {} } if (src[key] && src[key][name]) { mix(res[name], src[key][name], innerShape) } } } dest[key] = res } } } return dest } var mix_1 = function (dest, src) { return mix(dest, src, shape) }; function createSyntax(config) { var parse = create(config); var generate = create$1(config); var syntax = { parse: parse, generate: generate }; syntax.lexer = new Lexer_1({ generic: true, types: config.types, properties: config.properties, node: config.node }, syntax); return syntax } var create_1 = function (config) { return createSyntax(mix_1({}, config)) }; var create$2 = { create: create_1 }; var generic$1 = true; var types = { "absolute-size": "xx-small|x-small|small|medium|large|x-large|xx-large", "alpha-value": "|", "angle-percentage": "|", "angular-color-hint": "", "angular-color-stop": "&&?", "angular-color-stop-list": "[ [, ]?]# , ", "animateable-feature": "scroll-position|contents|", attachment: "scroll|fixed|local", "attr()": "attr( ? [, ]? )", "attr-matcher": "['~'|'|'|'^'|'$'|'*']? '='", "attr-modifier": "i|s", "attribute-selector": "'[' ']'|'[' [|] ? ']'", "auto-repeat": "repeat( [auto-fill|auto-fit] , [? ]+ ? )", "auto-track-list": "[? [|]]* ? [? [|]]* ?", "baseline-position": "[first|last]? baseline", "basic-shape": "|||", "bg-image": "none|", "bg-layer": "|| [/ ]?||||||||", "bg-position": "[[left|center|right|top|bottom|]|[left|center|right|] [top|center|bottom|]|[center|[left|right] ?]&&[center|[top|bottom] ?]]", "bg-size": "[|auto]{1,2}|cover|contain", "blur()": "blur( )", "blend-mode": "normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity", box: "border-box|padding-box|content-box", "brightness()": "brightness( )", "calc()": "calc( )", "calc-sum": " [['+'|'-'] ]*", "calc-product": " ['*' |'/' ]*", "calc-value": "|||( )", "cf-final-image": "|", "cf-mixing-image": "?&&", "circle()": "circle( []? [at ]? )", "clamp()": "clamp( #{3} )", "class-selector": "'.' ", "clip-source": "", color: "||||||currentcolor|", "color-stop": "|", "color-stop-angle": "{1,2}", "color-stop-length": "{1,2}", "color-stop-list": "[ [, ]?]# , ", combinator: "'>'|'+'|'~'|['||']", "common-lig-values": "[common-ligatures|no-common-ligatures]", compat: "searchfield|textarea|push-button|button-bevel|slider-horizontal|checkbox|radio|square-button|menulist|menulist-button|listbox|meter|progress-bar", "composite-style": "clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor", "compositing-operator": "add|subtract|intersect|exclude", "compound-selector": "[? * [ *]*]!", "compound-selector-list": "#", "complex-selector": " [? ]*", "complex-selector-list": "#", "conic-gradient()": "conic-gradient( [from ]? [at ]? , )", "contextual-alt-values": "[contextual|no-contextual]", "content-distribution": "space-between|space-around|space-evenly|stretch", "content-list": "[|contents||||counter( , <'list-style-type'>? )]+", "content-position": "center|start|end|flex-start|flex-end", "content-replacement": "", "contrast()": "contrast( [] )", "counter()": "counter( , [|none]? )", "counter-style": "|symbols( )", "counter-style-name": "", "counters()": "counters( , , [|none]? )", "cross-fade()": "cross-fade( , ? )", "cubic-bezier-timing-function": "ease|ease-in|ease-out|ease-in-out|cubic-bezier( , , , )", "deprecated-system-color": "ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText", "discretionary-lig-values": "[discretionary-ligatures|no-discretionary-ligatures]", "display-box": "contents|none", "display-inside": "flow|flow-root|table|flex|grid|ruby", "display-internal": "table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container", "display-legacy": "inline-block|inline-list-item|inline-table|inline-flex|inline-grid", "display-listitem": "?&&[flow|flow-root]?&&list-item", "display-outside": "block|inline|run-in", "drop-shadow()": "drop-shadow( {2,3} ? )", "east-asian-variant-values": "[jis78|jis83|jis90|jis04|simplified|traditional]", "east-asian-width-values": "[full-width|proportional-width]", "element()": "element( )", "ellipse()": "ellipse( [{2}]? [at ]? )", "ending-shape": "circle|ellipse", "env()": "env( , ? )", "explicit-track-list": "[? ]+ ?", "family-name": "|+", "feature-tag-value": " [|on|off]?", "feature-type": "@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation", "feature-value-block": " '{' '}'", "feature-value-block-list": "+", "feature-value-declaration": " : + ;", "feature-value-declaration-list": "", "feature-value-name": "", "fill-rule": "nonzero|evenodd", "filter-function": "|||||||||", "filter-function-list": "[|]+", "final-bg-layer": "<'background-color'>|||| [/ ]?||||||||", "fit-content()": "fit-content( [|] )", "fixed-breadth": "", "fixed-repeat": "repeat( [] , [? ]+ ? )", "fixed-size": "|minmax( , )|minmax( , )", "font-stretch-absolute": "normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|", "font-variant-css21": "[normal|small-caps]", "font-weight-absolute": "normal|bold|", "frequency-percentage": "|", "general-enclosed": "[ )]|( )", "generic-family": "serif|sans-serif|cursive|fantasy|monospace|-apple-system", "generic-name": "serif|sans-serif|cursive|fantasy|monospace", "geometry-box": "|fill-box|stroke-box|view-box", gradient: "|||||<-legacy-gradient>", "grayscale()": "grayscale( )", "grid-line": "auto||[&&?]|[span&&[||]]", "historical-lig-values": "[historical-ligatures|no-historical-ligatures]", "hsl()": "hsl( [/ ]? )|hsl( , , , ? )", "hsla()": "hsla( [/ ]? )|hsla( , , , ? )", hue: "|", "hue-rotate()": "hue-rotate( )", image: "|||||", "image()": "image( ? [? , ?]! )", "image-set()": "image-set( # )", "image-set-option": "[|] ", "image-src": "|", "image-tags": "ltr|rtl", "inflexible-breadth": "||min-content|max-content|auto", "inset()": "inset( {1,4} [round <'border-radius'>]? )", "invert()": "invert( )", "keyframes-name": "|", "keyframe-block": "# { }", "keyframe-block-list": "+", "keyframe-selector": "from|to|", "leader()": "leader( )", "leader-type": "dotted|solid|space|", "length-percentage": "|", "line-names": "'[' * ']'", "line-name-list": "[|]+", "line-style": "none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset", "line-width": "|thin|medium|thick", "linear-color-hint": "", "linear-color-stop": " ?", "linear-gradient()": "linear-gradient( [|to ]? , )", "mask-layer": "|| [/ ]?||||||[|no-clip]||||", "mask-position": "[|left|center|right] [|top|center|bottom]?", "mask-reference": "none||", "mask-source": "", "masking-mode": "alpha|luminance|match-source", "matrix()": "matrix( #{6} )", "matrix3d()": "matrix3d( #{16} )", "max()": "max( # )", "media-and": " [and ]+", "media-condition": "|||", "media-condition-without-or": "||", "media-feature": "( [||] )", "media-in-parens": "( )||", "media-not": "not ", "media-or": " [or ]+", "media-query": "|[not|only]? [and ]?", "media-query-list": "#", "media-type": "", "mf-boolean": "", "mf-name": "", "mf-plain": " : ", "mf-range": " ['<'|'>']? '='? | ['<'|'>']? '='? | '<' '='? '<' '='? | '>' '='? '>' '='? ", "mf-value": "|||", "min()": "min( # )", "minmax()": "minmax( [|||min-content|max-content|auto] , [|||min-content|max-content|auto] )", "named-color": "transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|<-non-standard-color>", "namespace-prefix": "", "ns-prefix": "[|'*']? '|'", "number-percentage": "|", "numeric-figure-values": "[lining-nums|oldstyle-nums]", "numeric-fraction-values": "[diagonal-fractions|stacked-fractions]", "numeric-spacing-values": "[proportional-nums|tabular-nums]", nth: "|even|odd", "opacity()": "opacity( [] )", "overflow-position": "unsafe|safe", "outline-radius": "|", "page-body": "? [; ]?| ", "page-margin-box": " '{' '}'", "page-margin-box-type": "@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom", "page-selector-list": "[#]?", "page-selector": "+| *", "perspective()": "perspective( )", "polygon()": "polygon( ? , [ ]# )", position: "[[left|center|right]||[top|center|bottom]|[left|center|right|] [top|center|bottom|]?|[[left|right] ]&&[[top|bottom] ]]", "pseudo-class-selector": "':' |':' ')'", "pseudo-element-selector": "':' ", "pseudo-page": ": [left|right|first|blank]", quote: "open-quote|close-quote|no-open-quote|no-close-quote", "radial-gradient()": "radial-gradient( [||]? [at ]? , )", "relative-selector": "? ", "relative-selector-list": "#", "relative-size": "larger|smaller", "repeat-style": "repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}", "repeating-linear-gradient()": "repeating-linear-gradient( [|to ]? , )", "repeating-radial-gradient()": "repeating-radial-gradient( [||]? [at ]? , )", "rgb()": "rgb( {3} [/ ]? )|rgb( {3} [/ ]? )|rgb( #{3} , ? )|rgb( #{3} , ? )", "rgba()": "rgba( {3} [/ ]? )|rgba( {3} [/ ]? )|rgba( #{3} , ? )|rgba( #{3} , ? )", "rotate()": "rotate( [|] )", "rotate3d()": "rotate3d( , , , [|] )", "rotateX()": "rotateX( [|] )", "rotateY()": "rotateY( [|] )", "rotateZ()": "rotateZ( [|] )", "saturate()": "saturate( )", "scale()": "scale( , ? )", "scale3d()": "scale3d( , , )", "scaleX()": "scaleX( )", "scaleY()": "scaleY( )", "scaleZ()": "scaleZ( )", "self-position": "center|start|end|self-start|self-end|flex-start|flex-end", "shape-radius": "|closest-side|farthest-side", "skew()": "skew( [|] , [|]? )", "skewX()": "skewX( [|] )", "skewY()": "skewY( [|] )", "sepia()": "sepia( )", shadow: "inset?&&{2,4}&&?", "shadow-t": "[{2,3}&&?]", shape: "rect( , , , )|rect( )", "shape-box": "|margin-box", "side-or-corner": "[left|right]||[top|bottom]", "single-animation": "