diff options
author | cjihrig <cjihrig@gmail.com> | 2021-02-12 18:39:10 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2021-02-15 10:38:36 -0500 |
commit | ac24e50502d157140da6095ac2ebf00969a41f05 (patch) | |
tree | 41c5333d87a9bc427ea40c161cdad5bfa55f58f2 /tools/node_modules | |
parent | a7ba592483cc90cdedae4b395b638972f75619b6 (diff) | |
download | node-new-ac24e50502d157140da6095ac2ebf00969a41f05.tar.gz |
tools: update ESLint to 7.20.0
Update ESLint to 7.20.0
PR-URL: https://github.com/nodejs/node/pull/37339
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'tools/node_modules')
60 files changed, 6412 insertions, 1030 deletions
diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 624ad9e3ad..92298bd955 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -280,10 +280,10 @@ The following companies, organizations, and individuals support ESLint's ongoing <!-- NOTE: This section is autogenerated. Do not manually edit.--> <!--sponsorsstart--> <h3>Platinum Sponsors</h3> -<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/ff91f0b/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3> -<p><a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3> +<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3> +<p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3> <p><a href="https://retool.com/"><img src="https://images.opencollective.com/retool/98ea68e/logo.png" alt="Retool" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/c8a3b25/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3> -<p><a href="https://streamat.se"><img src="https://images.opencollective.com/streamat/46890db/logo.png" alt="Streamat" height="32"></a> <a href="https://thestandarddaily.com/"><img src="https://images.opencollective.com/eric-watson/db4e598/avatar.png" alt="The Standard Daily" height="32"></a> <a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/february-calendar.html"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="February 2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p> +<p><a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/march-calendar.html"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="March 2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p> <!--sponsorsend--> ## <a name="technology-sponsors"></a>Technology Sponsors diff --git a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js index 9a41406150..3fd4f5ee1e 100644 --- a/tools/node_modules/eslint/lib/cli-engine/cli-engine.js +++ b/tools/node_modules/eslint/lib/cli-engine/cli-engine.js @@ -531,7 +531,7 @@ function directoryExists(resolvedPath) { try { return fs.statSync(resolvedPath).isDirectory(); } catch (error) { - if (error && error.code === "ENOENT") { + if (error && (error.code === "ENOENT" || error.code === "ENOTDIR")) { return false; } throw error; diff --git a/tools/node_modules/eslint/lib/init/autoconfig.js b/tools/node_modules/eslint/lib/init/autoconfig.js index 0ace177aa1..19d016a54c 100644 --- a/tools/node_modules/eslint/lib/init/autoconfig.js +++ b/tools/node_modules/eslint/lib/init/autoconfig.js @@ -85,7 +85,7 @@ class Registry { * @returns {void} */ populateFromCoreRules() { - const rulesConfig = configRule.createCoreRuleConfigs(); + const rulesConfig = configRule.createCoreRuleConfigs(/* noDeprecated = */ true); this.rules = makeRegistryItems(rulesConfig); } diff --git a/tools/node_modules/eslint/lib/linter/linter.js b/tools/node_modules/eslint/lib/linter/linter.js index 5c1a8d78aa..adb5c21559 100644 --- a/tools/node_modules/eslint/lib/linter/linter.js +++ b/tools/node_modules/eslint/lib/linter/linter.js @@ -942,7 +942,9 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser }); // only run code path analyzer if the top level node is "Program", skip otherwise - const eventGenerator = nodeQueue[0].node.type === "Program" ? new CodePathAnalyzer(new NodeEventGenerator(emitter)) : new NodeEventGenerator(emitter); + const eventGenerator = nodeQueue[0].node.type === "Program" + ? new CodePathAnalyzer(new NodeEventGenerator(emitter, { visitorKeys: sourceCode.visitorKeys, fallback: Traverser.getKeys })) + : new NodeEventGenerator(emitter, { visitorKeys: sourceCode.visitorKeys, fallback: Traverser.getKeys }); nodeQueue.forEach(traversalInfo => { currentNode = traversalInfo.node; diff --git a/tools/node_modules/eslint/lib/linter/node-event-generator.js b/tools/node_modules/eslint/lib/linter/node-event-generator.js index 6f3b251399..0b4e50fc4b 100644 --- a/tools/node_modules/eslint/lib/linter/node-event-generator.js +++ b/tools/node_modules/eslint/lib/linter/node-event-generator.js @@ -208,10 +208,12 @@ class NodeEventGenerator { * An SafeEmitter which is the destination of events. This emitter must already * have registered listeners for all of the events that it needs to listen for. * (See lib/linter/safe-emitter.js for more details on `SafeEmitter`.) + * @param {ESQueryOptions} esqueryOptions `esquery` options for traversing custom nodes. * @returns {NodeEventGenerator} new instance */ - constructor(emitter) { + constructor(emitter, esqueryOptions) { this.emitter = emitter; + this.esqueryOptions = esqueryOptions; this.currentAncestry = []; this.enterSelectorsByNodeType = new Map(); this.exitSelectorsByNodeType = new Map(); @@ -250,7 +252,7 @@ class NodeEventGenerator { * @returns {void} */ applySelector(node, selector) { - if (esquery.matches(node, selector.parsedSelector, this.currentAncestry)) { + if (esquery.matches(node, selector.parsedSelector, this.currentAncestry, this.esqueryOptions)) { this.emitter.emit(selector.rawSelector, node); } } diff --git a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js index 882a0fd1c1..58c9b33418 100644 --- a/tools/node_modules/eslint/lib/rules/no-unused-expressions.js +++ b/tools/node_modules/eslint/lib/rules/no-unused-expressions.js @@ -50,6 +50,10 @@ module.exports = { allowTaggedTemplates: { type: "boolean", default: false + }, + enforceForJSX: { + type: "boolean", + default: false } }, additionalProperties: false @@ -65,7 +69,8 @@ module.exports = { const config = context.options[0] || {}, allowShortCircuit = config.allowShortCircuit || false, allowTernary = config.allowTernary || false, - allowTaggedTemplates = config.allowTaggedTemplates || false; + allowTaggedTemplates = config.allowTaggedTemplates || false, + enforceForJSX = config.enforceForJSX || false; // eslint-disable-next-line jsdoc/require-description /** @@ -140,6 +145,12 @@ module.exports = { }, FunctionExpression: alwaysTrue, Identifier: alwaysTrue, + JSXElement() { + return enforceForJSX; + }, + JSXFragment() { + return enforceForJSX; + }, Literal: alwaysTrue, LogicalExpression(node) { if (allowShortCircuit) { diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/README.md b/tools/node_modules/eslint/node_modules/@babel/highlight/README.md index 72dae60945..f8887ad2ca 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/README.md +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/README.md @@ -2,7 +2,7 @@ > Syntax highlight JavaScript strings for output in terminals. -See our website [@babel/highlight](https://babeljs.io/docs/en/next/babel-highlight.html) for more information. +See our website [@babel/highlight](https://babeljs.io/docs/en/babel-highlight) for more information. ## Install diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js index b0d1be7f55..3cd2aed36a 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/lib/index.js @@ -7,7 +7,7 @@ exports.shouldHighlight = shouldHighlight; exports.getChalk = getChalk; exports.default = highlight; -var _jsTokens = _interopRequireWildcard(require("js-tokens")); +var jsTokensNs = _interopRequireWildcard(require("js-tokens")); var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); @@ -19,11 +19,13 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } +const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]); + function getDefs(chalk) { return { keyword: chalk.cyan, capitalized: chalk.yellow, - jsx_tag: chalk.yellow, + jsxIdentifier: chalk.yellow, punctuator: chalk.yellow, number: chalk.magenta, string: chalk.green, @@ -34,49 +36,70 @@ function getDefs(chalk) { } const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; -const JSX_TAG = /^[a-z][\w-]*$/i; const BRACKET = /^[()[\]{}]$/; - -function getTokenType(match) { - const [offset, text] = match.slice(-2); - const token = (0, _jsTokens.matchToToken)(match); - - if (token.type === "name") { - if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isReservedWord)(token.value)) { - return "keyword"; +let tokenize; +{ + const { + matchToToken + } = jsTokensNs; + const JSX_TAG = /^[a-z][\w-]*$/i; + + const getTokenType = function (token, offset, text) { + if (token.type === "name") { + if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) { + return "keyword"; + } + + if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { + return "jsxIdentifier"; + } + + if (token.value[0] !== token.value[0].toLowerCase()) { + return "capitalized"; + } } - if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { - return "jsx_tag"; + if (token.type === "punctuator" && BRACKET.test(token.value)) { + return "bracket"; } - if (token.value[0] !== token.value[0].toLowerCase()) { - return "capitalized"; + if (token.type === "invalid" && (token.value === "@" || token.value === "#")) { + return "punctuator"; } - } - if (token.type === "punctuator" && BRACKET.test(token.value)) { - return "bracket"; - } + return token.type; + }; - if (token.type === "invalid" && (token.value === "@" || token.value === "#")) { - return "punctuator"; - } + tokenize = function* (text) { + let match; - return token.type; + while (match = jsTokensNs.default.exec(text)) { + const token = matchToToken(match); + yield { + type: getTokenType(token, match.index, text), + value: token.value + }; + } + }; } function highlightTokens(defs, text) { - return text.replace(_jsTokens.default, function (...args) { - const type = getTokenType(args); + let highlighted = ""; + + for (const { + type, + value + } of tokenize(text)) { const colorize = defs[type]; if (colorize) { - return args[0].split(NEWLINE).map(str => colorize(str)).join("\n"); + highlighted += value.split(NEWLINE).map(str => colorize(str)).join("\n"); } else { - return args[0]; + highlighted += value; } - }); + } + + return highlighted; } function shouldHighlight(options) { diff --git a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json index f126bb84aa..5f693c7180 100644 --- a/tools/node_modules/eslint/node_modules/@babel/highlight/package.json +++ b/tools/node_modules/eslint/node_modules/@babel/highlight/package.json @@ -8,7 +8,7 @@ }, "bundleDependencies": false, "dependencies": { - "@babel/helper-validator-identifier": "^7.10.4", + "@babel/helper-validator-identifier": "^7.12.11", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -17,8 +17,7 @@ "devDependencies": { "strip-ansi": "^4.0.0" }, - "gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df", - "homepage": "https://babeljs.io/", + "homepage": "https://babel.dev/docs/en/next/babel-highlight", "license": "MIT", "main": "lib/index.js", "name": "@babel/highlight", @@ -30,5 +29,5 @@ "url": "git+https://github.com/babel/babel.git", "directory": "packages/babel-highlight" }, - "version": "7.10.4" + "version": "7.12.13" }
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/esprima/package.json b/tools/node_modules/eslint/node_modules/esprima/package.json index 4dfb4a142e..03d154ee72 100644 --- a/tools/node_modules/eslint/node_modules/esprima/package.json +++ b/tools/node_modules/eslint/node_modules/esprima/package.json @@ -4,8 +4,8 @@ "email": "ariya.hidayat@gmail.com" }, "bin": { - "esparse": "./bin/esparse.js", - "esvalidate": "./bin/esvalidate.js" + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" }, "bugs": { "url": "https://github.com/jquery/esprima/issues" diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js index 88abe0ffb9..7a62b8b39a 100644 --- a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js +++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js @@ -66,7 +66,7 @@ function _unsupportedIterableToArray(o, minLen) { if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(n); + if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } @@ -86,6 +86,63 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, module) { @@ -182,6 +239,7 @@ var estraverse = createCommonjsModule(function (module, exports) { BreakStatement: 'BreakStatement', CallExpression: 'CallExpression', CatchClause: 'CatchClause', + ChainExpression: 'ChainExpression', ClassBody: 'ClassBody', ClassDeclaration: 'ClassDeclaration', ClassExpression: 'ClassExpression', @@ -260,6 +318,7 @@ var estraverse = createCommonjsModule(function (module, exports) { BreakStatement: ['label'], CallExpression: ['callee', 'arguments'], CatchClause: ['param', 'body'], + ChainExpression: ['expression'], ClassBody: ['body'], ClassDeclaration: ['id', 'superClass', 'body'], ClassExpression: ['id', 'superClass', 'body'], @@ -1126,7 +1185,10 @@ var parser = createCommonjsModule(function (module) { peg$c41 = peg$classExpectation([">", "<"], false, false), peg$c42 = ".", peg$c43 = peg$literalExpectation(".", false), - peg$c44 = function peg$c44(name, op, value) { + peg$c44 = function peg$c44(a, as) { + return [].concat.apply([a], as).join(''); + }, + peg$c45 = function peg$c45(name, op, value) { return { type: 'attribute', name: name, @@ -1134,35 +1196,35 @@ var parser = createCommonjsModule(function (module) { value: value }; }, - peg$c45 = function peg$c45(name) { + peg$c46 = function peg$c46(name) { return { type: 'attribute', name: name }; }, - peg$c46 = "\"", - peg$c47 = peg$literalExpectation("\"", false), - peg$c48 = /^[^\\"]/, - peg$c49 = peg$classExpectation(["\\", "\""], true, false), - peg$c50 = "\\", - peg$c51 = peg$literalExpectation("\\", false), - peg$c52 = peg$anyExpectation(), - peg$c53 = function peg$c53(a, b) { + peg$c47 = "\"", + peg$c48 = peg$literalExpectation("\"", false), + peg$c49 = /^[^\\"]/, + peg$c50 = peg$classExpectation(["\\", "\""], true, false), + peg$c51 = "\\", + peg$c52 = peg$literalExpectation("\\", false), + peg$c53 = peg$anyExpectation(), + peg$c54 = function peg$c54(a, b) { return a + b; }, - peg$c54 = function peg$c54(d) { + peg$c55 = function peg$c55(d) { return { type: 'literal', value: strUnescape(d.join('')) }; }, - peg$c55 = "'", - peg$c56 = peg$literalExpectation("'", false), - peg$c57 = /^[^\\']/, - peg$c58 = peg$classExpectation(["\\", "'"], true, false), - peg$c59 = /^[0-9]/, - peg$c60 = peg$classExpectation([["0", "9"]], false, false), - peg$c61 = function peg$c61(a, b) { + peg$c56 = "'", + peg$c57 = peg$literalExpectation("'", false), + peg$c58 = /^[^\\']/, + peg$c59 = peg$classExpectation(["\\", "'"], true, false), + peg$c60 = /^[0-9]/, + peg$c61 = peg$classExpectation([["0", "9"]], false, false), + peg$c62 = function peg$c62(a, b) { // Can use `a.flat().join('')` once supported var leadingDecimals = a ? [].concat.apply([], a).join('') : ''; return { @@ -1170,37 +1232,37 @@ var parser = createCommonjsModule(function (module) { value: parseFloat(leadingDecimals + b.join('')) }; }, - peg$c62 = function peg$c62(i) { + peg$c63 = function peg$c63(i) { return { type: 'literal', value: i }; }, - peg$c63 = "type(", - peg$c64 = peg$literalExpectation("type(", false), - peg$c65 = /^[^ )]/, - peg$c66 = peg$classExpectation([" ", ")"], true, false), - peg$c67 = ")", - peg$c68 = peg$literalExpectation(")", false), - peg$c69 = function peg$c69(t) { + peg$c64 = "type(", + peg$c65 = peg$literalExpectation("type(", false), + peg$c66 = /^[^ )]/, + peg$c67 = peg$classExpectation([" ", ")"], true, false), + peg$c68 = ")", + peg$c69 = peg$literalExpectation(")", false), + peg$c70 = function peg$c70(t) { return { type: 'type', value: t.join('') }; }, - peg$c70 = /^[imsu]/, - peg$c71 = peg$classExpectation(["i", "m", "s", "u"], false, false), - peg$c72 = "/", - peg$c73 = peg$literalExpectation("/", false), - peg$c74 = /^[^\/]/, - peg$c75 = peg$classExpectation(["/"], true, false), - peg$c76 = function peg$c76(d, flgs) { + peg$c71 = /^[imsu]/, + peg$c72 = peg$classExpectation(["i", "m", "s", "u"], false, false), + peg$c73 = "/", + peg$c74 = peg$literalExpectation("/", false), + peg$c75 = /^[^\/]/, + peg$c76 = peg$classExpectation(["/"], true, false), + peg$c77 = function peg$c77(d, flgs) { return { type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') }; }, - peg$c77 = function peg$c77(i, is) { + peg$c78 = function peg$c78(i, is) { return { type: 'field', name: is.reduce(function (memo, p) { @@ -1208,63 +1270,63 @@ var parser = createCommonjsModule(function (module) { }, i) }; }, - peg$c78 = ":not(", - peg$c79 = peg$literalExpectation(":not(", false), - peg$c80 = function peg$c80(ss) { + peg$c79 = ":not(", + peg$c80 = peg$literalExpectation(":not(", false), + peg$c81 = function peg$c81(ss) { return { type: 'not', selectors: ss }; }, - peg$c81 = ":matches(", - peg$c82 = peg$literalExpectation(":matches(", false), - peg$c83 = function peg$c83(ss) { + peg$c82 = ":matches(", + peg$c83 = peg$literalExpectation(":matches(", false), + peg$c84 = function peg$c84(ss) { return { type: 'matches', selectors: ss }; }, - peg$c84 = ":has(", - peg$c85 = peg$literalExpectation(":has(", false), - peg$c86 = function peg$c86(ss) { + peg$c85 = ":has(", + peg$c86 = peg$literalExpectation(":has(", false), + peg$c87 = function peg$c87(ss) { return { type: 'has', selectors: ss }; }, - peg$c87 = ":first-child", - peg$c88 = peg$literalExpectation(":first-child", false), - peg$c89 = function peg$c89() { + peg$c88 = ":first-child", + peg$c89 = peg$literalExpectation(":first-child", false), + peg$c90 = function peg$c90() { return nth(1); }, - peg$c90 = ":last-child", - peg$c91 = peg$literalExpectation(":last-child", false), - peg$c92 = function peg$c92() { + peg$c91 = ":last-child", + peg$c92 = peg$literalExpectation(":last-child", false), + peg$c93 = function peg$c93() { return nthLast(1); }, - peg$c93 = ":nth-child(", - peg$c94 = peg$literalExpectation(":nth-child(", false), - peg$c95 = function peg$c95(n) { + peg$c94 = ":nth-child(", + peg$c95 = peg$literalExpectation(":nth-child(", false), + peg$c96 = function peg$c96(n) { return nth(parseInt(n.join(''), 10)); }, - peg$c96 = ":nth-last-child(", - peg$c97 = peg$literalExpectation(":nth-last-child(", false), - peg$c98 = function peg$c98(n) { + peg$c97 = ":nth-last-child(", + peg$c98 = peg$literalExpectation(":nth-last-child(", false), + peg$c99 = function peg$c99(n) { return nthLast(parseInt(n.join(''), 10)); }, - peg$c99 = ":", - peg$c100 = peg$literalExpectation(":", false), - peg$c101 = "statement", - peg$c102 = peg$literalExpectation("statement", true), - peg$c103 = "expression", - peg$c104 = peg$literalExpectation("expression", true), - peg$c105 = "declaration", - peg$c106 = peg$literalExpectation("declaration", true), - peg$c107 = "function", - peg$c108 = peg$literalExpectation("function", true), - peg$c109 = "pattern", - peg$c110 = peg$literalExpectation("pattern", true), - peg$c111 = function peg$c111(c) { + peg$c100 = ":", + peg$c101 = peg$literalExpectation(":", false), + peg$c102 = "statement", + peg$c103 = peg$literalExpectation("statement", true), + peg$c104 = "expression", + peg$c105 = peg$literalExpectation("expression", true), + peg$c106 = "declaration", + peg$c107 = peg$literalExpectation("declaration", true), + peg$c108 = "function", + peg$c109 = peg$literalExpectation("function", true), + peg$c110 = "pattern", + peg$c111 = peg$literalExpectation("pattern", true), + peg$c112 = function peg$c112(c) { return { type: 'class', name: c @@ -2295,7 +2357,7 @@ var parser = createCommonjsModule(function (module) { } function peg$parseattrName() { - var s0, s1, s2; + var s0, s1, s2, s3, s4, s5; var key = peg$currPos * 30 + 13, cached = peg$resultsCache[key]; @@ -2305,49 +2367,81 @@ var parser = createCommonjsModule(function (module) { } s0 = peg$currPos; - s1 = []; - s2 = peg$parseidentifierName(); + s1 = peg$parseidentifierName(); + + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; - if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c42; + s4 = peg$c42; peg$currPos++; } else { - s2 = peg$FAILED; + s4 = peg$FAILED; { peg$fail(peg$c43); } } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parseidentifierName(); + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c42; - peg$currPos++; - } else { - s2 = peg$FAILED; + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } - { - peg$fail(peg$c43); - } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c42; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c43); } } + + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); + + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s1 = peg$c6(s1); + if (s2 !== peg$FAILED) { + s1 = peg$c44(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - s0 = s1; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 @@ -2385,7 +2479,7 @@ var parser = createCommonjsModule(function (module) { } if (s5 !== peg$FAILED) { - s1 = peg$c44(s1, s3, s5); + s1 = peg$c45(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; @@ -2433,7 +2527,7 @@ var parser = createCommonjsModule(function (module) { } if (s5 !== peg$FAILED) { - s1 = peg$c44(s1, s3, s5); + s1 = peg$c45(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; @@ -2461,7 +2555,7 @@ var parser = createCommonjsModule(function (module) { s1 = peg$parseattrName(); if (s1 !== peg$FAILED) { - s1 = peg$c45(s1); + s1 = peg$c46(s1); } s0 = s1; @@ -2488,27 +2582,27 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c46; + s1 = peg$c47; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c47); + peg$fail(peg$c48); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c48.test(input.charAt(peg$currPos))) { + if (peg$c49.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c49); + peg$fail(peg$c50); } } @@ -2516,13 +2610,13 @@ var parser = createCommonjsModule(function (module) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2534,12 +2628,12 @@ var parser = createCommonjsModule(function (module) { s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2554,14 +2648,14 @@ var parser = createCommonjsModule(function (module) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c48.test(input.charAt(peg$currPos))) { + if (peg$c49.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c49); + peg$fail(peg$c50); } } @@ -2569,13 +2663,13 @@ var parser = createCommonjsModule(function (module) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2587,12 +2681,12 @@ var parser = createCommonjsModule(function (module) { s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2607,18 +2701,18 @@ var parser = createCommonjsModule(function (module) { if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c46; + s3 = peg$c47; peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c47); + peg$fail(peg$c48); } } if (s3 !== peg$FAILED) { - s1 = peg$c54(s2); + s1 = peg$c55(s2); s0 = s1; } else { peg$currPos = s0; @@ -2637,27 +2731,27 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c55; + s1 = peg$c56; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c56); + peg$fail(peg$c57); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c57.test(input.charAt(peg$currPos))) { + if (peg$c58.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c58); + peg$fail(peg$c59); } } @@ -2665,13 +2759,13 @@ var parser = createCommonjsModule(function (module) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2683,12 +2777,12 @@ var parser = createCommonjsModule(function (module) { s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2703,14 +2797,14 @@ var parser = createCommonjsModule(function (module) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c57.test(input.charAt(peg$currPos))) { + if (peg$c58.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c58); + peg$fail(peg$c59); } } @@ -2718,13 +2812,13 @@ var parser = createCommonjsModule(function (module) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2736,12 +2830,12 @@ var parser = createCommonjsModule(function (module) { s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2756,18 +2850,18 @@ var parser = createCommonjsModule(function (module) { if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c55; + s3 = peg$c56; peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c56); + peg$fail(peg$c57); } } if (s3 !== peg$FAILED) { - s1 = peg$c54(s2); + s1 = peg$c55(s2); s0 = s1; } else { peg$currPos = s0; @@ -2804,28 +2898,28 @@ var parser = createCommonjsModule(function (module) { s1 = peg$currPos; s2 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -2861,14 +2955,14 @@ var parser = createCommonjsModule(function (module) { if (s1 !== peg$FAILED) { s2 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } @@ -2876,14 +2970,14 @@ var parser = createCommonjsModule(function (module) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -2892,7 +2986,7 @@ var parser = createCommonjsModule(function (module) { } if (s2 !== peg$FAILED) { - s1 = peg$c61(s1, s2); + s1 = peg$c62(s1, s2); s0 = s1; } else { peg$currPos = s0; @@ -2924,7 +3018,7 @@ var parser = createCommonjsModule(function (module) { s1 = peg$parseidentifierName(); if (s1 !== peg$FAILED) { - s1 = peg$c62(s1); + s1 = peg$c63(s1); } s0 = s1; @@ -2947,14 +3041,14 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c63) { - s1 = peg$c63; + if (input.substr(peg$currPos, 5) === peg$c64) { + s1 = peg$c64; peg$currPos += 5; } else { s1 = peg$FAILED; { - peg$fail(peg$c64); + peg$fail(peg$c65); } } @@ -2964,14 +3058,14 @@ var parser = createCommonjsModule(function (module) { if (s2 !== peg$FAILED) { s3 = []; - if (peg$c65.test(input.charAt(peg$currPos))) { + if (peg$c66.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c66); + peg$fail(peg$c67); } } @@ -2979,14 +3073,14 @@ var parser = createCommonjsModule(function (module) { while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c65.test(input.charAt(peg$currPos))) { + if (peg$c66.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c66); + peg$fail(peg$c67); } } } @@ -2999,18 +3093,18 @@ var parser = createCommonjsModule(function (module) { if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c69(s3); + s1 = peg$c70(s3); s0 = s1; } else { peg$currPos = s0; @@ -3052,14 +3146,14 @@ var parser = createCommonjsModule(function (module) { s0 = []; - if (peg$c70.test(input.charAt(peg$currPos))) { + if (peg$c71.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c71); + peg$fail(peg$c72); } } @@ -3067,14 +3161,14 @@ var parser = createCommonjsModule(function (module) { while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$c70.test(input.charAt(peg$currPos))) { + if (peg$c71.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c71); + peg$fail(peg$c72); } } } @@ -3102,27 +3196,27 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { - s1 = peg$c72; + s1 = peg$c73; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c73); + peg$fail(peg$c74); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c74.test(input.charAt(peg$currPos))) { + if (peg$c75.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c75); + peg$fail(peg$c76); } } @@ -3130,14 +3224,14 @@ var parser = createCommonjsModule(function (module) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c74.test(input.charAt(peg$currPos))) { + if (peg$c75.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c75); + peg$fail(peg$c76); } } } @@ -3147,13 +3241,13 @@ var parser = createCommonjsModule(function (module) { if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { - s3 = peg$c72; + s3 = peg$c73; peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c73); + peg$fail(peg$c74); } } @@ -3165,7 +3259,7 @@ var parser = createCommonjsModule(function (module) { } if (s4 !== peg$FAILED) { - s1 = peg$c76(s2, s4); + s1 = peg$c77(s2, s4); s0 = s1; } else { peg$currPos = s0; @@ -3279,7 +3373,7 @@ var parser = createCommonjsModule(function (module) { } if (s3 !== peg$FAILED) { - s1 = peg$c77(s2, s3); + s1 = peg$c78(s2, s3); s0 = s1; } else { peg$currPos = s0; @@ -3313,14 +3407,14 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c78) { - s1 = peg$c78; + if (input.substr(peg$currPos, 5) === peg$c79) { + s1 = peg$c79; peg$currPos += 5; } else { s1 = peg$FAILED; { - peg$fail(peg$c79); + peg$fail(peg$c80); } } @@ -3335,18 +3429,18 @@ var parser = createCommonjsModule(function (module) { if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c80(s3); + s1 = peg$c81(s3); s0 = s1; } else { peg$currPos = s0; @@ -3388,14 +3482,14 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c81) { - s1 = peg$c81; + if (input.substr(peg$currPos, 9) === peg$c82) { + s1 = peg$c82; peg$currPos += 9; } else { s1 = peg$FAILED; { - peg$fail(peg$c82); + peg$fail(peg$c83); } } @@ -3410,18 +3504,18 @@ var parser = createCommonjsModule(function (module) { if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c83(s3); + s1 = peg$c84(s3); s0 = s1; } else { peg$currPos = s0; @@ -3463,14 +3557,14 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c84) { - s1 = peg$c84; + if (input.substr(peg$currPos, 5) === peg$c85) { + s1 = peg$c85; peg$currPos += 5; } else { s1 = peg$FAILED; { - peg$fail(peg$c85); + peg$fail(peg$c86); } } @@ -3485,18 +3579,18 @@ var parser = createCommonjsModule(function (module) { if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c86(s3); + s1 = peg$c87(s3); s0 = s1; } else { peg$currPos = s0; @@ -3538,19 +3632,19 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 12) === peg$c87) { - s1 = peg$c87; + if (input.substr(peg$currPos, 12) === peg$c88) { + s1 = peg$c88; peg$currPos += 12; } else { s1 = peg$FAILED; { - peg$fail(peg$c88); + peg$fail(peg$c89); } } if (s1 !== peg$FAILED) { - s1 = peg$c89(); + s1 = peg$c90(); } s0 = s1; @@ -3573,19 +3667,19 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 11) === peg$c91) { + s1 = peg$c91; peg$currPos += 11; } else { s1 = peg$FAILED; { - peg$fail(peg$c91); + peg$fail(peg$c92); } } if (s1 !== peg$FAILED) { - s1 = peg$c92(); + s1 = peg$c93(); } s0 = s1; @@ -3608,14 +3702,14 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c93) { - s1 = peg$c93; + if (input.substr(peg$currPos, 11) === peg$c94) { + s1 = peg$c94; peg$currPos += 11; } else { s1 = peg$FAILED; { - peg$fail(peg$c94); + peg$fail(peg$c95); } } @@ -3625,14 +3719,14 @@ var parser = createCommonjsModule(function (module) { if (s2 !== peg$FAILED) { s3 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } @@ -3640,14 +3734,14 @@ var parser = createCommonjsModule(function (module) { while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -3660,18 +3754,18 @@ var parser = createCommonjsModule(function (module) { if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c95(s3); + s1 = peg$c96(s3); s0 = s1; } else { peg$currPos = s0; @@ -3713,14 +3807,14 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; - if (input.substr(peg$currPos, 16) === peg$c96) { - s1 = peg$c96; + if (input.substr(peg$currPos, 16) === peg$c97) { + s1 = peg$c97; peg$currPos += 16; } else { s1 = peg$FAILED; { - peg$fail(peg$c97); + peg$fail(peg$c98); } } @@ -3730,14 +3824,14 @@ var parser = createCommonjsModule(function (module) { if (s2 !== peg$FAILED) { s3 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } @@ -3745,14 +3839,14 @@ var parser = createCommonjsModule(function (module) { while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -3765,18 +3859,18 @@ var parser = createCommonjsModule(function (module) { if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c98(s3); + s1 = peg$c99(s3); s0 = s1; } else { peg$currPos = s0; @@ -3819,73 +3913,73 @@ var parser = createCommonjsModule(function (module) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 58) { - s1 = peg$c99; + s1 = peg$c100; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c100); + peg$fail(peg$c101); } } if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c101) { + if (input.substr(peg$currPos, 9).toLowerCase() === peg$c102) { s2 = input.substr(peg$currPos, 9); peg$currPos += 9; } else { s2 = peg$FAILED; { - peg$fail(peg$c102); + peg$fail(peg$c103); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) { + if (input.substr(peg$currPos, 10).toLowerCase() === peg$c104) { s2 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s2 = peg$FAILED; { - peg$fail(peg$c104); + peg$fail(peg$c105); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c105) { + if (input.substr(peg$currPos, 11).toLowerCase() === peg$c106) { s2 = input.substr(peg$currPos, 11); peg$currPos += 11; } else { s2 = peg$FAILED; { - peg$fail(peg$c106); + peg$fail(peg$c107); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c107) { + if (input.substr(peg$currPos, 8).toLowerCase() === peg$c108) { s2 = input.substr(peg$currPos, 8); peg$currPos += 8; } else { s2 = peg$FAILED; { - peg$fail(peg$c108); + peg$fail(peg$c109); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c109) { + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c110) { s2 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s2 = peg$FAILED; { - peg$fail(peg$c110); + peg$fail(peg$c111); } } } @@ -3894,7 +3988,7 @@ var parser = createCommonjsModule(function (module) { } if (s2 !== peg$FAILED) { - s1 = peg$c111(s2); + s1 = peg$c112(s2); s0 = s1; } else { peg$currPos = s0; @@ -4020,12 +4114,23 @@ var RIGHT_SIDE = 'RIGHT_SIDE'; function getPath(obj, key) { var keys = key.split('.'); - for (var i = 0; i < keys.length; i++) { - if (obj == null) { - return obj; - } + var _iterator = _createForOfIteratorHelper(keys), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _key = _step.value; + + if (obj == null) { + return obj; + } - obj = obj[keys[i]]; + obj = obj[_key]; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); } return obj; @@ -4053,10 +4158,21 @@ function inPath(node, ancestor, path) { var remainingPath = path.slice(1); if (Array.isArray(field)) { - for (var i = 0, l = field.length; i < l; ++i) { - if (inPath(node, field[i], remainingPath)) { - return true; + var _iterator2 = _createForOfIteratorHelper(field), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var component = _step2.value; + + if (inPath(node, component, remainingPath)) { + return true; + } } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } return false; @@ -4065,18 +4181,31 @@ function inPath(node, ancestor, path) { } } /** + * @callback TraverseOptionFallback + * @param {external:AST} node The given node. + * @returns {string[]} An array of visitor keys for the given node. + */ + +/** + * @typedef {object} ESQueryOptions + * @property { { [nodeType: string]: string[] } } [visitorKeys] By passing `visitorKeys` mapping, we can extend the properties of the nodes that traverse the node. + * @property {TraverseOptionFallback} [fallback] By passing `fallback` option, we can control the properties of traversing nodes when encountering unknown nodes. + */ + +/** * Given a `node` and its ancestors, determine if `node` is matched * by `selector`. * @param {?external:AST} node * @param {?SelectorAST} selector * @param {external:AST[]} [ancestry=[]] + * @param {ESQueryOptions} [options] * @throws {Error} Unknowns (operator, class name, selector type, or * selector value type) * @returns {boolean} */ -function matches(node, selector, ancestry) { +function matches(node, selector, ancestry, options) { if (!selector) { return true; } @@ -4104,28 +4233,61 @@ function matches(node, selector, ancestry) { } case 'matches': - for (var i = 0, l = selector.selectors.length; i < l; ++i) { - if (matches(node, selector.selectors[i], ancestry)) { - return true; + var _iterator3 = _createForOfIteratorHelper(selector.selectors), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var sel = _step3.value; + + if (matches(node, sel, ancestry, options)) { + return true; + } } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); } return false; case 'compound': - for (var _i = 0, _l = selector.selectors.length; _i < _l; ++_i) { - if (!matches(node, selector.selectors[_i], ancestry)) { - return false; + var _iterator4 = _createForOfIteratorHelper(selector.selectors), + _step4; + + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var _sel = _step4.value; + + if (!matches(node, _sel, ancestry, options)) { + return false; + } } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); } return true; case 'not': - for (var _i2 = 0, _l2 = selector.selectors.length; _i2 < _l2; ++_i2) { - if (matches(node, selector.selectors[_i2], ancestry)) { - return false; + var _iterator5 = _createForOfIteratorHelper(selector.selectors), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _sel2 = _step5.value; + + if (matches(node, _sel2, ancestry, options)) { + return false; + } } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); } return true; @@ -4135,27 +4297,38 @@ function matches(node, selector, ancestry) { var _ret = function () { var collector = []; - var _loop = function _loop(_i3, _l3) { - var a = []; - estraverse.traverse(node, { - enter: function enter(node, parent) { - if (parent != null) { - a.unshift(parent); - } - - if (matches(node, selector.selectors[_i3], a)) { - collector.push(node); - } - }, - leave: function leave() { - a.shift(); - }, - fallback: 'iteration' - }); - }; + var _iterator6 = _createForOfIteratorHelper(selector.selectors), + _step6; + + try { + var _loop = function _loop() { + var sel = _step6.value; + var a = []; + estraverse.traverse(node, { + enter: function enter(node, parent) { + if (parent != null) { + a.unshift(parent); + } - for (var _i3 = 0, _l3 = selector.selectors.length; _i3 < _l3; ++_i3) { - _loop(_i3); + if (matches(node, sel, a, options)) { + collector.push(node); + } + }, + leave: function leave() { + a.shift(); + }, + keys: options && options.visitorKeys, + fallback: options && options.fallback || 'iteration' + }); + }; + + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + _loop(); + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); } return { @@ -4167,16 +4340,16 @@ function matches(node, selector, ancestry) { } case 'child': - if (matches(node, selector.right, ancestry)) { - return matches(ancestry[0], selector.left, ancestry.slice(1)); + if (matches(node, selector.right, ancestry, options)) { + return matches(ancestry[0], selector.left, ancestry.slice(1), options); } return false; case 'descendant': - if (matches(node, selector.right, ancestry)) { - for (var _i4 = 0, _l4 = ancestry.length; _i4 < _l4; ++_i4) { - if (matches(ancestry[_i4], selector.left, ancestry.slice(_i4 + 1))) { + if (matches(node, selector.right, ancestry, options)) { + for (var i = 0, l = ancestry.length; i < l; ++i) { + if (matches(ancestry[i], selector.left, ancestry.slice(i + 1), options)) { return true; } } @@ -4237,20 +4410,20 @@ function matches(node, selector, ancestry) { } case 'sibling': - return matches(node, selector.right, ancestry) && sibling(node, selector.left, ancestry, LEFT_SIDE) || selector.left.subject && matches(node, selector.left, ancestry) && sibling(node, selector.right, ancestry, RIGHT_SIDE); + return matches(node, selector.right, ancestry, options) && sibling(node, selector.left, ancestry, LEFT_SIDE, options) || selector.left.subject && matches(node, selector.left, ancestry, options) && sibling(node, selector.right, ancestry, RIGHT_SIDE, options); case 'adjacent': - return matches(node, selector.right, ancestry) && adjacent(node, selector.left, ancestry, LEFT_SIDE) || selector.right.subject && matches(node, selector.left, ancestry) && adjacent(node, selector.right, ancestry, RIGHT_SIDE); + return matches(node, selector.right, ancestry, options) && adjacent(node, selector.left, ancestry, LEFT_SIDE, options) || selector.right.subject && matches(node, selector.left, ancestry, options) && adjacent(node, selector.right, ancestry, RIGHT_SIDE, options); case 'nth-child': - return matches(node, selector.right, ancestry) && nthChild(node, ancestry, function () { + return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function () { return selector.index.value - 1; - }); + }, options); case 'nth-last-child': - return matches(node, selector.right, ancestry) && nthChild(node, ancestry, function (length) { + return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function (length) { return length - selector.index.value; - }); + }, options); case 'class': switch (selector.name.toLowerCase()) { @@ -4278,17 +4451,56 @@ function matches(node, selector, ancestry) { throw new Error("Unknown selector type: ".concat(selector.type)); } /** + * Get visitor keys of a given node. + * @param {external:AST} node The AST node to get keys. + * @param {ESQueryOptions|undefined} options + * @returns {string[]} Visitor keys of the node. + */ + + +function getVisitorKeys(node, options) { + var nodeType = node.type; + + if (options && options.visitorKeys && options.visitorKeys[nodeType]) { + return options.visitorKeys[nodeType]; + } + + if (estraverse.VisitorKeys[nodeType]) { + return estraverse.VisitorKeys[nodeType]; + } + + if (options && typeof options.fallback === 'function') { + return options.fallback(node); + } // 'iteration' fallback + + + return Object.keys(node).filter(function (key) { + return key !== 'type'; + }); +} +/** + * Check whether the given value is an ASTNode or not. + * @param {any} node The value to check. + * @returns {boolean} `true` if the value is an ASTNode. + */ + + +function isNode(node) { + return node !== null && _typeof(node) === 'object' && typeof node.type === 'string'; +} +/** * Determines if the given node has a sibling that matches the * given selector. * @param {external:AST} node * @param {SelectorSequenceAST} selector * @param {external:AST[]} ancestry * @param {Side} side + * @param {ESQueryOptions|undefined} options * @returns {boolean} */ -function sibling(node, selector, ancestry, side) { +function sibling(node, selector, ancestry, side, options) { var _ancestry = _slicedToArray(ancestry, 1), parent = _ancestry[0]; @@ -4296,35 +4508,45 @@ function sibling(node, selector, ancestry, side) { return false; } - var keys = estraverse.VisitorKeys[parent.type]; + var keys = getVisitorKeys(parent, options); - for (var i = 0, l = keys.length; i < l; ++i) { - var listProp = parent[keys[i]]; + var _iterator7 = _createForOfIteratorHelper(keys), + _step7; - if (Array.isArray(listProp)) { - var startIndex = listProp.indexOf(node); + try { + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var key = _step7.value; + var listProp = parent[key]; - if (startIndex < 0) { - continue; - } + if (Array.isArray(listProp)) { + var startIndex = listProp.indexOf(node); - var lowerBound = void 0, - upperBound = void 0; + if (startIndex < 0) { + continue; + } - if (side === LEFT_SIDE) { - lowerBound = 0; - upperBound = startIndex; - } else { - lowerBound = startIndex + 1; - upperBound = listProp.length; - } + var lowerBound = void 0, + upperBound = void 0; - for (var k = lowerBound; k < upperBound; ++k) { - if (matches(listProp[k], selector, ancestry)) { - return true; + if (side === LEFT_SIDE) { + lowerBound = 0; + upperBound = startIndex; + } else { + lowerBound = startIndex + 1; + upperBound = listProp.length; + } + + for (var k = lowerBound; k < upperBound; ++k) { + if (isNode(listProp[k]) && matches(listProp[k], selector, ancestry, options)) { + return true; + } } } } + } catch (err) { + _iterator7.e(err); + } finally { + _iterator7.f(); } return false; @@ -4336,11 +4558,12 @@ function sibling(node, selector, ancestry, side) { * @param {SelectorSequenceAST} selector * @param {external:AST[]} ancestry * @param {Side} side + * @param {ESQueryOptions|undefined} options * @returns {boolean} */ -function adjacent(node, selector, ancestry, side) { +function adjacent(node, selector, ancestry, side, options) { var _ancestry2 = _slicedToArray(ancestry, 1), parent = _ancestry2[0]; @@ -4348,26 +4571,36 @@ function adjacent(node, selector, ancestry, side) { return false; } - var keys = estraverse.VisitorKeys[parent.type]; + var keys = getVisitorKeys(parent, options); - for (var i = 0, l = keys.length; i < l; ++i) { - var listProp = parent[keys[i]]; + var _iterator8 = _createForOfIteratorHelper(keys), + _step8; - if (Array.isArray(listProp)) { - var idx = listProp.indexOf(node); + try { + for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { + var key = _step8.value; + var listProp = parent[key]; - if (idx < 0) { - continue; - } + if (Array.isArray(listProp)) { + var idx = listProp.indexOf(node); - if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) { - return true; - } + if (idx < 0) { + continue; + } - if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) { - return true; + if (side === LEFT_SIDE && idx > 0 && isNode(listProp[idx - 1]) && matches(listProp[idx - 1], selector, ancestry, options)) { + return true; + } + + if (side === RIGHT_SIDE && idx < listProp.length - 1 && isNode(listProp[idx + 1]) && matches(listProp[idx + 1], selector, ancestry, options)) { + return true; + } } } + } catch (err) { + _iterator8.e(err); + } finally { + _iterator8.f(); } return false; @@ -4384,11 +4617,12 @@ function adjacent(node, selector, ancestry, side) { * @param {external:AST} node * @param {external:AST[]} ancestry * @param {IndexFunction} idxFn + * @param {ESQueryOptions|undefined} options * @returns {boolean} */ -function nthChild(node, ancestry, idxFn) { +function nthChild(node, ancestry, idxFn, options) { var _ancestry3 = _slicedToArray(ancestry, 1), parent = _ancestry3[0]; @@ -4396,18 +4630,28 @@ function nthChild(node, ancestry, idxFn) { return false; } - var keys = estraverse.VisitorKeys[parent.type]; + var keys = getVisitorKeys(parent, options); - for (var i = 0, l = keys.length; i < l; ++i) { - var listProp = parent[keys[i]]; + var _iterator9 = _createForOfIteratorHelper(keys), + _step9; - if (Array.isArray(listProp)) { - var idx = listProp.indexOf(node); + try { + for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { + var key = _step9.value; + var listProp = parent[key]; - if (idx >= 0 && idx === idxFn(listProp.length)) { - return true; + if (Array.isArray(listProp)) { + var idx = listProp.indexOf(node); + + if (idx >= 0 && idx === idxFn(listProp.length)) { + return true; + } } } + } catch (err) { + _iterator9.e(err); + } finally { + _iterator9.f(); } return false; @@ -4432,8 +4676,8 @@ function subjects(selector, ancestor) { var results = selector.subject ? [ancestor] : []; - for (var _i5 = 0, _Object$entries = _objectEntries(selector); _i5 < _Object$entries.length; _i5++) { - var _Object$entries$_i = _slicedToArray(_Object$entries[_i5], 2), + for (var _i = 0, _Object$entries = _objectEntries(selector); _i < _Object$entries.length; _i++) { + var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), p = _Object$entries$_i[0], sel = _Object$entries$_i[1]; @@ -4455,11 +4699,12 @@ function subjects(selector, ancestor) { * @param {external:AST} ast * @param {?SelectorAST} selector * @param {TraverseVisitor} visitor + * @param {ESQueryOptions} [options] * @returns {external:AST[]} */ -function traverse(ast, selector, visitor) { +function traverse(ast, selector, visitor, options) { if (!selector) { return; } @@ -4472,17 +4717,17 @@ function traverse(ast, selector, visitor) { ancestry.unshift(parent); } - if (matches(node, selector, ancestry)) { + if (matches(node, selector, ancestry, options)) { if (altSubjects.length) { for (var i = 0, l = altSubjects.length; i < l; ++i) { - if (matches(node, altSubjects[i], ancestry)) { + if (matches(node, altSubjects[i], ancestry, options)) { visitor(node, parent, ancestry); } for (var k = 0, m = ancestry.length; k < m; ++k) { var succeedingAncestry = ancestry.slice(k + 1); - if (matches(ancestry[k], altSubjects[i], succeedingAncestry)) { + if (matches(ancestry[k], altSubjects[i], succeedingAncestry, options)) { visitor(ancestry[k], parent, succeedingAncestry); } } @@ -4495,7 +4740,8 @@ function traverse(ast, selector, visitor) { leave: function leave() { ancestry.shift(); }, - fallback: 'iteration' + keys: options && options.visitorKeys, + fallback: options && options.fallback || 'iteration' }); } /** @@ -4503,15 +4749,16 @@ function traverse(ast, selector, visitor) { * match the selector. * @param {external:AST} ast * @param {?SelectorAST} selector + * @param {ESQueryOptions} [options] * @returns {external:AST[]} */ -function match(ast, selector) { +function match(ast, selector, options) { var results = []; traverse(ast, selector, function (node) { results.push(node); - }); + }, options); return results; } /** @@ -4528,12 +4775,13 @@ function parse(selector) { * Query the code AST using the selector string. * @param {external:AST} ast * @param {string} selector + * @param {ESQueryOptions} [options] * @returns {external:AST[]} */ -function query(ast, selector) { - return match(ast, parse(selector)); +function query(ast, selector, options) { + return match(ast, parse(selector), options); } query.parse = parse; diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js index 474e093dcc..cd5ac34bd4 100644 --- a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js +++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js @@ -1,2 +1,2 @@ -function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var s,i=e[Symbol.iterator]();!(n=(s=i.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function a(e,t){return e(t={exports:{}},t.exports),t.exports}var s=a((function(e,t){!function e(t){var r,n,o,a,s,i;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function p(){}function f(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function d(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function y(e,t){return(new p).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,o,a;for(n=e.length,o=0;n;)t(e[a=o+(r=n>>>1)])?n=r:(o=a+1,n-=r+1);return o}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},o={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},n={Break:a={},Skip:s={},Remove:i={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},p.prototype.path=function(){var e,t,r,n,o;function a(e,t){if(Array.isArray(t))for(r=0,n=t.length;r<n;++r)e.push(t[r]);else e.push(t)}if(!this.__current.path)return null;for(o=[],e=2,t=this.__leavelist.length;e<t;++e)a(o,this.__leavelist[e].path);return a(o,this.__current.path),o},p.prototype.type=function(){return this.current().type||this.__current.wrap},p.prototype.parents=function(){var e,t,r;for(r=[],e=1,t=this.__leavelist.length;e<t;++e)r.push(this.__leavelist[e].node);return r},p.prototype.current=function(){return this.__current.node},p.prototype.__execute=function(e,t){var r,n;return n=void 0,r=this.__current,this.__current=t,this.__state=null,e&&(n=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,n},p.prototype.notify=function(e){this.__state=e},p.prototype.skip=function(){this.notify(s)},p.prototype.break=function(){this.notify(a)},p.prototype.remove=function(){this.notify(i)},p.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,"iteration"===t.fallback?this.__fallback=Object.keys:"function"==typeof t.fallback&&(this.__fallback=t.fallback),this.__keys=o,t.keys&&(this.__keys=Object.assign(Object.create(this.__keys),t.keys))},p.prototype.traverse=function(e,t){var r,n,o,i,l,u,p,y,m,x,g,v;for(this.__initialize(e,t),v={},r=this.__worklist,n=this.__leavelist,r.push(new c(e,null,null,null)),n.push(new c(null,null,null,null));r.length;)if((o=r.pop())!==v){if(o.node){if(u=this.__execute(t.enter,o),this.__state===a||u===a)return;if(r.push(v),n.push(o),this.__state===s||u===s)continue;if(l=(i=o.node).type||o.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(i)}for(y=x.length;(y-=1)>=0;)if(g=i[p=x[y]])if(Array.isArray(g)){for(m=g.length;(m-=1)>=0;)if(g[m]&&!d(n,g[m])){if(h(l,x[y]))o=new c(g[m],[p,m],"Property",null);else{if(!f(g[m]))continue;o=new c(g[m],[p,m],null,null)}r.push(o)}}else if(f(g)){if(d(n,g))continue;r.push(new c(g,p,null,null))}}}else if(o=n.pop(),u=this.__execute(t.leave,o),this.__state===a||u===a)return},p.prototype.replace=function(e,t){var r,n,o,l,p,d,y,m,x,g,v,A,b;function E(e){var t,n,o,a;if(e.ref.remove())for(n=e.ref.key,a=e.ref.parent,t=r.length;t--;)if((o=r[t]).ref&&o.ref.parent===a){if(o.ref.key<n)break;--o.ref.key}}for(this.__initialize(e,t),v={},r=this.__worklist,n=this.__leavelist,d=new c(e,null,null,new u(A={root:e},"root")),r.push(d),n.push(d);r.length;)if((d=r.pop())!==v){if(void 0!==(p=this.__execute(t.enter,d))&&p!==a&&p!==s&&p!==i&&(d.ref.replace(p),d.node=p),this.__state!==i&&p!==i||(E(d),d.node=null),this.__state===a||p===a)return A.root;if((o=d.node)&&(r.push(v),n.push(d),this.__state!==s&&p!==s)){if(l=o.type||d.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(o)}for(y=x.length;(y-=1)>=0;)if(g=o[b=x[y]])if(Array.isArray(g)){for(m=g.length;(m-=1)>=0;)if(g[m]){if(h(l,x[y]))d=new c(g[m],[b,m],"Property",new u(g,m));else{if(!f(g[m]))continue;d=new c(g[m],[b,m],null,new u(g,m))}r.push(d)}}else f(g)&&r.push(new c(g,b,null,new u(o,b)))}}else if(d=n.pop(),void 0!==(p=this.__execute(t.leave,d))&&p!==a&&p!==s&&p!==i&&d.ref.replace(p),this.__state!==i&&p!==i||E(d),this.__state===a||p===a)return A.root;return A.root},t.Syntax=r,t.traverse=y,t.replace=function(e,t){return(new p).replace(e,t)},t.attachComments=function(e,t,r){var o,a,s,i,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(s=0,a=t.length;s<a;s+=1)(o=l(t[s])).extendedRange=[0,e.range[0]],u.push(o);e.leadingComments=u}return e}for(s=0,a=t.length;s<a;s+=1)u.push(m(l(t[s]),r));return i=0,y(e,{enter:function(e){for(var t;i<u.length&&!((t=u[i]).extendedRange[1]>e.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(i,1)):i+=1;return i===u.length?n.Break:u[i].extendedRange[0]>e.range[1]?n.Skip:void 0}}),i=0,y(e,{leave:function(e){for(var t;i<u.length&&(t=u[i],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),u.splice(i,1)):i+=1;return i===u.length?n.Break:u[i].extendedRange[0]>e.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=o,t.VisitorOption=n,t.Controller=p,t.cloneEnvironment=function(){return e({})},t}(t)})),i=a((function(e){e.exports&&(e.exports=function(){function e(t,r,n,o){this.message=t,this.expected=r,this.found=n,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.buildMessage=function(e,t){var r={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?a(e.parts[t][0])+"-"+a(e.parts[t][1]):a(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function a(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}return"Expected "+function(e){var t,n,o,a=new Array(e.length);for(t=0;t<e.length;t++)a[t]=(o=e[t],r[o.type](o));if(a.sort(),a.length>0){for(t=1,n=1;t<a.length;t++)a[t-1]!==a[t]&&(a[n]=a[t],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){r=void 0!==r?r:{};var n,o,a,s,i={},l={start:be},u=be,c=me(" ",!1),p=/^[^ [\],():#!=><~+.]/,f=xe([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),h=function(e){return e.join("")},d=me(">",!1),y=me("~",!1),m=me("+",!1),x=me(",",!1),g=me("!",!1),v=me("*",!1),A=me("#",!1),b=me("[",!1),E=me("]",!1),S=/^[><!]/,_=xe([">","<","!"],!1,!1),w=me("=",!1),C=function(e){return(e||"")+"="},P=/^[><]/,k=xe([">","<"],!1,!1),D=me(".",!1),I=function(e,t,r){return{type:"attribute",name:e,operator:t,value:r}},j=me('"',!1),F=/^[^\\"]/,T=xe(["\\",'"'],!0,!1),L=me("\\",!1),R={type:"any"},O=function(e,t){return e+t},B=function(e){return{type:"literal",value:(t=e.join(""),t.replace(/\\(.)/g,(function(e,t){switch(t){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return t}})))};var t},M=me("'",!1),U=/^[^\\']/,V=xe(["\\","'"],!0,!1),q=/^[0-9]/,N=xe([["0","9"]],!1,!1),W=me("type(",!1),G=/^[^ )]/,z=xe([" ",")"],!0,!1),K=me(")",!1),H=/^[imsu]/,Y=xe(["i","m","s","u"],!1,!1),$=me("/",!1),J=/^[^\/]/,Q=xe(["/"],!0,!1),X=me(":not(",!1),Z=me(":matches(",!1),ee=me(":has(",!1),te=me(":first-child",!1),re=me(":last-child",!1),ne=me(":nth-child(",!1),oe=me(":nth-last-child(",!1),ae=me(":",!1),se=me("statement",!0),ie=me("expression",!0),le=me("declaration",!0),ue=me("function",!0),ce=me("pattern",!0),pe=0,fe=[{line:1,column:1}],he=0,de=[],ye={};if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function me(e,t){return{type:"literal",text:e,ignoreCase:t}}function xe(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function ge(e){var r,n=fe[e];if(n)return n;for(r=e-1;!fe[r];)r--;for(n={line:(n=fe[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return fe[e]=n,n}function ve(e,t){var r=ge(e),n=ge(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function Ae(e){pe<he||(pe>he&&(he=pe,de=[]),de.push(e))}function be(){var e,t,r,n,o=30*pe+0,a=ye[o];return a?(pe=a.nextPos,a.result):(e=pe,(t=Ee())!==i&&(r=we())!==i&&Ee()!==i?e=t=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(pe=e,e=i),e===i&&(e=pe,(t=Ee())!==i&&(t=void 0),e=t),ye[o]={nextPos:pe,result:e},e)}function Ee(){var e,r,n=30*pe+1,o=ye[n];if(o)return pe=o.nextPos,o.result;for(e=[],32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c));r!==i;)e.push(r),32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c));return ye[n]={nextPos:pe,result:e},e}function Se(){var e,r,n,o=30*pe+2,a=ye[o];if(a)return pe=a.nextPos,a.result;if(r=[],p.test(t.charAt(pe))?(n=t.charAt(pe),pe++):(n=i,Ae(f)),n!==i)for(;n!==i;)r.push(n),p.test(t.charAt(pe))?(n=t.charAt(pe),pe++):(n=i,Ae(f));else r=i;return r!==i&&(r=h(r)),e=r,ye[o]={nextPos:pe,result:e},e}function _e(){var e,r,n,o=30*pe+3,a=ye[o];return a?(pe=a.nextPos,a.result):(e=pe,(r=Ee())!==i?(62===t.charCodeAt(pe)?(n=">",pe++):(n=i,Ae(d)),n!==i&&Ee()!==i?e=r="child":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=Ee())!==i?(126===t.charCodeAt(pe)?(n="~",pe++):(n=i,Ae(y)),n!==i&&Ee()!==i?e=r="sibling":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=Ee())!==i?(43===t.charCodeAt(pe)?(n="+",pe++):(n=i,Ae(m)),n!==i&&Ee()!==i?e=r="adjacent":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c)),r!==i&&(n=Ee())!==i?e=r="descendant":(pe=e,e=i)))),ye[o]={nextPos:pe,result:e},e)}function we(){var e,r,n,o,a,s,l,u,c=30*pe+4,p=ye[c];if(p)return pe=p.nextPos,p.result;if(e=pe,(r=Ce())!==i){for(n=[],o=pe,(a=Ee())!==i?(44===t.charCodeAt(pe)?(s=",",pe++):(s=i,Ae(x)),s!==i&&(l=Ee())!==i&&(u=Ce())!==i?o=a=[a,s,l,u]:(pe=o,o=i)):(pe=o,o=i);o!==i;)n.push(o),o=pe,(a=Ee())!==i?(44===t.charCodeAt(pe)?(s=",",pe++):(s=i,Ae(x)),s!==i&&(l=Ee())!==i&&(u=Ce())!==i?o=a=[a,s,l,u]:(pe=o,o=i)):(pe=o,o=i);n!==i?e=r=[r].concat(n.map((function(e){return e[3]}))):(pe=e,e=i)}else pe=e,e=i;return ye[c]={nextPos:pe,result:e},e}function Ce(){var e,t,r,n,o,a,s,l=30*pe+5,u=ye[l];if(u)return pe=u.nextPos,u.result;if(e=pe,(t=Pe())!==i){for(r=[],n=pe,(o=_e())!==i&&(a=Pe())!==i?n=o=[o,a]:(pe=n,n=i);n!==i;)r.push(n),n=pe,(o=_e())!==i&&(a=Pe())!==i?n=o=[o,a]:(pe=n,n=i);r!==i?(s=t,e=t=r.reduce((function(e,t){return{type:t[0],left:e,right:t[1]}}),s)):(pe=e,e=i)}else pe=e,e=i;return ye[l]={nextPos:pe,result:e},e}function Pe(){var e,r,n,o,a,s,l,u=30*pe+6,c=ye[u];if(c)return pe=c.nextPos,c.result;if(e=pe,33===t.charCodeAt(pe)?(r="!",pe++):(r=i,Ae(g)),r===i&&(r=null),r!==i){if(n=[],(o=ke())!==i)for(;o!==i;)n.push(o),o=ke();else n=i;n!==i?(a=r,l=1===(s=n).length?s[0]:{type:"compound",selectors:s},a&&(l.subject=!0),e=r=l):(pe=e,e=i)}else pe=e,e=i;return ye[u]={nextPos:pe,result:e},e}function ke(){var e,r=30*pe+7,n=ye[r];return n?(pe=n.nextPos,n.result):((e=function(){var e,r,n=30*pe+8,o=ye[n];return o?(pe=o.nextPos,o.result):(42===t.charCodeAt(pe)?(r="*",pe++):(r=i,Ae(v)),r!==i&&(r={type:"wildcard",value:r}),e=r,ye[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,o=30*pe+9,a=ye[o];return a?(pe=a.nextPos,a.result):(e=pe,35===t.charCodeAt(pe)?(r="#",pe++):(r=i,Ae(A)),r===i&&(r=null),r!==i&&(n=Se())!==i?e=r={type:"identifier",value:n}:(pe=e,e=i),ye[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a=30*pe+10,s=ye[a];return s?(pe=s.nextPos,s.result):(e=pe,91===t.charCodeAt(pe)?(r="[",pe++):(r=i,Ae(b)),r!==i&&Ee()!==i&&(n=function(){var e,r,n,o,a=30*pe+14,s=ye[a];return s?(pe=s.nextPos,s.result):(e=pe,(r=De())!==i&&Ee()!==i&&(n=function(){var e,r,n,o=30*pe+12,a=ye[o];return a?(pe=a.nextPos,a.result):(e=pe,33===t.charCodeAt(pe)?(r="!",pe++):(r=i,Ae(g)),r===i&&(r=null),r!==i?(61===t.charCodeAt(pe)?(n="=",pe++):(n=i,Ae(w)),n!==i?(r=C(r),e=r):(pe=e,e=i)):(pe=e,e=i),ye[o]={nextPos:pe,result:e},e)}())!==i&&Ee()!==i?((o=function(){var e,r,n,o,a,s=30*pe+18,l=ye[s];if(l)return pe=l.nextPos,l.result;if(e=pe,"type("===t.substr(pe,5)?(r="type(",pe+=5):(r=i,Ae(W)),r!==i)if(Ee()!==i){if(n=[],G.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(z)),o!==i)for(;o!==i;)n.push(o),G.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(z));else n=i;n!==i&&(o=Ee())!==i?(41===t.charCodeAt(pe)?(a=")",pe++):(a=i,Ae(K)),a!==i?(r={type:"type",value:n.join("")},e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return ye[s]={nextPos:pe,result:e},e}())===i&&(o=function(){var e,r,n,o,a,s,l=30*pe+20,u=ye[l];if(u)return pe=u.nextPos,u.result;if(e=pe,47===t.charCodeAt(pe)?(r="/",pe++):(r=i,Ae($)),r!==i){if(n=[],J.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(Q)),o!==i)for(;o!==i;)n.push(o),J.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(Q));else n=i;n!==i?(47===t.charCodeAt(pe)?(o="/",pe++):(o=i,Ae($)),o!==i?((a=function(){var e,r,n=30*pe+19,o=ye[n];if(o)return pe=o.nextPos,o.result;if(e=[],H.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(Y)),r!==i)for(;r!==i;)e.push(r),H.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(Y));else e=i;return ye[n]={nextPos:pe,result:e},e}())===i&&(a=null),a!==i?(s=a,r={type:"regexp",value:new RegExp(n.join(""),s?s.join(""):"")},e=r):(pe=e,e=i)):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;return ye[l]={nextPos:pe,result:e},e}()),o!==i?(r=I(r,n,o),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=De())!==i&&Ee()!==i&&(n=function(){var e,r,n,o=30*pe+11,a=ye[o];return a?(pe=a.nextPos,a.result):(e=pe,S.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(_)),r===i&&(r=null),r!==i?(61===t.charCodeAt(pe)?(n="=",pe++):(n=i,Ae(w)),n!==i?(r=C(r),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(P.test(t.charAt(pe))?(e=t.charAt(pe),pe++):(e=i,Ae(k))),ye[o]={nextPos:pe,result:e},e)}())!==i&&Ee()!==i?((o=function(){var e,r,n,o,a,s,l=30*pe+15,u=ye[l];if(u)return pe=u.nextPos,u.result;if(e=pe,34===t.charCodeAt(pe)?(r='"',pe++):(r=i,Ae(j)),r!==i){for(n=[],F.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(T)),o===i&&(o=pe,92===t.charCodeAt(pe)?(a="\\",pe++):(a=i,Ae(L)),a!==i?(t.length>pe?(s=t.charAt(pe),pe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(pe=o,o=i)):(pe=o,o=i));o!==i;)n.push(o),F.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(T)),o===i&&(o=pe,92===t.charCodeAt(pe)?(a="\\",pe++):(a=i,Ae(L)),a!==i?(t.length>pe?(s=t.charAt(pe),pe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(pe=o,o=i)):(pe=o,o=i));n!==i?(34===t.charCodeAt(pe)?(o='"',pe++):(o=i,Ae(j)),o!==i?(r=B(n),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;if(e===i)if(e=pe,39===t.charCodeAt(pe)?(r="'",pe++):(r=i,Ae(M)),r!==i){for(n=[],U.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(V)),o===i&&(o=pe,92===t.charCodeAt(pe)?(a="\\",pe++):(a=i,Ae(L)),a!==i?(t.length>pe?(s=t.charAt(pe),pe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(pe=o,o=i)):(pe=o,o=i));o!==i;)n.push(o),U.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(V)),o===i&&(o=pe,92===t.charCodeAt(pe)?(a="\\",pe++):(a=i,Ae(L)),a!==i?(t.length>pe?(s=t.charAt(pe),pe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(pe=o,o=i)):(pe=o,o=i));n!==i?(39===t.charCodeAt(pe)?(o="'",pe++):(o=i,Ae(M)),o!==i?(r=B(n),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;return ye[l]={nextPos:pe,result:e},e}())===i&&(o=function(){var e,r,n,o,a,s,l,u=30*pe+16,c=ye[u];if(c)return pe=c.nextPos,c.result;for(e=pe,r=pe,n=[],q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N));o!==i;)n.push(o),q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N));if(n!==i?(46===t.charCodeAt(pe)?(o=".",pe++):(o=i,Ae(D)),o!==i?r=n=[n,o]:(pe=r,r=i)):(pe=r,r=i),r===i&&(r=null),r!==i){if(n=[],q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N)),o!==i)for(;o!==i;)n.push(o),q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N));else n=i;n!==i?(s=n,l=(a=r)?[].concat.apply([],a).join(""):"",r={type:"literal",value:parseFloat(l+s.join(""))},e=r):(pe=e,e=i)}else pe=e,e=i;return ye[u]={nextPos:pe,result:e},e}())===i&&(o=function(){var e,t,r=30*pe+17,n=ye[r];return n?(pe=n.nextPos,n.result):((t=Se())!==i&&(t={type:"literal",value:t}),e=t,ye[r]={nextPos:pe,result:e},e)}()),o!==i?(r=I(r,n,o),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=De())!==i&&(r={type:"attribute",name:r}),e=r)),ye[a]={nextPos:pe,result:e},e)}())!==i&&Ee()!==i?(93===t.charCodeAt(pe)?(o="]",pe++):(o=i,Ae(E)),o!==i?e=r=n:(pe=e,e=i)):(pe=e,e=i),ye[a]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a,s,l,u,c=30*pe+21,p=ye[c];if(p)return pe=p.nextPos,p.result;if(e=pe,46===t.charCodeAt(pe)?(r=".",pe++):(r=i,Ae(D)),r!==i)if((n=Se())!==i){for(o=[],a=pe,46===t.charCodeAt(pe)?(s=".",pe++):(s=i,Ae(D)),s!==i&&(l=Se())!==i?a=s=[s,l]:(pe=a,a=i);a!==i;)o.push(a),a=pe,46===t.charCodeAt(pe)?(s=".",pe++):(s=i,Ae(D)),s!==i&&(l=Se())!==i?a=s=[s,l]:(pe=a,a=i);o!==i?(u=n,r={type:"field",name:o.reduce((function(e,t){return e+t[0]+t[1]}),u)},e=r):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return ye[c]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,o,a=30*pe+22,s=ye[a];return s?(pe=s.nextPos,s.result):(e=pe,":not("===t.substr(pe,5)?(r=":not(",pe+=5):(r=i,Ae(X)),r!==i&&Ee()!==i&&(n=we())!==i&&Ee()!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(K)),o!==i?e=r={type:"not",selectors:n}:(pe=e,e=i)):(pe=e,e=i),ye[a]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a=30*pe+23,s=ye[a];return s?(pe=s.nextPos,s.result):(e=pe,":matches("===t.substr(pe,9)?(r=":matches(",pe+=9):(r=i,Ae(Z)),r!==i&&Ee()!==i&&(n=we())!==i&&Ee()!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(K)),o!==i?e=r={type:"matches",selectors:n}:(pe=e,e=i)):(pe=e,e=i),ye[a]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a=30*pe+24,s=ye[a];return s?(pe=s.nextPos,s.result):(e=pe,":has("===t.substr(pe,5)?(r=":has(",pe+=5):(r=i,Ae(ee)),r!==i&&Ee()!==i&&(n=we())!==i&&Ee()!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(K)),o!==i?e=r={type:"has",selectors:n}:(pe=e,e=i)):(pe=e,e=i),ye[a]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n=30*pe+25,o=ye[n];return o?(pe=o.nextPos,o.result):(":first-child"===t.substr(pe,12)?(r=":first-child",pe+=12):(r=i,Ae(te)),r!==i&&(r=Ie(1)),e=r,ye[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n=30*pe+26,o=ye[n];return o?(pe=o.nextPos,o.result):(":last-child"===t.substr(pe,11)?(r=":last-child",pe+=11):(r=i,Ae(re)),r!==i&&(r=je(1)),e=r,ye[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a,s=30*pe+27,l=ye[s];if(l)return pe=l.nextPos,l.result;if(e=pe,":nth-child("===t.substr(pe,11)?(r=":nth-child(",pe+=11):(r=i,Ae(ne)),r!==i)if(Ee()!==i){if(n=[],q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N)),o!==i)for(;o!==i;)n.push(o),q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N));else n=i;n!==i&&(o=Ee())!==i?(41===t.charCodeAt(pe)?(a=")",pe++):(a=i,Ae(K)),a!==i?(r=Ie(parseInt(n.join(""),10)),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return ye[s]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,o,a,s=30*pe+28,l=ye[s];if(l)return pe=l.nextPos,l.result;if(e=pe,":nth-last-child("===t.substr(pe,16)?(r=":nth-last-child(",pe+=16):(r=i,Ae(oe)),r!==i)if(Ee()!==i){if(n=[],q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N)),o!==i)for(;o!==i;)n.push(o),q.test(t.charAt(pe))?(o=t.charAt(pe),pe++):(o=i,Ae(N));else n=i;n!==i&&(o=Ee())!==i?(41===t.charCodeAt(pe)?(a=")",pe++):(a=i,Ae(K)),a!==i?(r=je(parseInt(n.join(""),10)),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return ye[s]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,o=30*pe+29,a=ye[o];return a?(pe=a.nextPos,a.result):(e=pe,58===t.charCodeAt(pe)?(r=":",pe++):(r=i,Ae(ae)),r!==i?("statement"===t.substr(pe,9).toLowerCase()?(n=t.substr(pe,9),pe+=9):(n=i,Ae(se)),n===i&&("expression"===t.substr(pe,10).toLowerCase()?(n=t.substr(pe,10),pe+=10):(n=i,Ae(ie)),n===i&&("declaration"===t.substr(pe,11).toLowerCase()?(n=t.substr(pe,11),pe+=11):(n=i,Ae(le)),n===i&&("function"===t.substr(pe,8).toLowerCase()?(n=t.substr(pe,8),pe+=8):(n=i,Ae(ue)),n===i&&("pattern"===t.substr(pe,7).toLowerCase()?(n=t.substr(pe,7),pe+=7):(n=i,Ae(ce)))))),n!==i?e=r={type:"class",name:n}:(pe=e,e=i)):(pe=e,e=i),ye[o]={nextPos:pe,result:e},e)}()),ye[r]={nextPos:pe,result:e},e)}function De(){var e,r,n,o=30*pe+13,a=ye[o];if(a)return pe=a.nextPos,a.result;if(r=[],(n=Se())===i&&(46===t.charCodeAt(pe)?(n=".",pe++):(n=i,Ae(D))),n!==i)for(;n!==i;)r.push(n),(n=Se())===i&&(46===t.charCodeAt(pe)?(n=".",pe++):(n=i,Ae(D)));else r=i;return r!==i&&(r=h(r)),e=r,ye[o]={nextPos:pe,result:e},e}function Ie(e){return{type:"nth-child",index:{type:"literal",value:e}}}function je(e){return{type:"nth-last-child",index:{type:"literal",value:e}}}if((n=u())!==i&&pe===t.length)return n;throw n!==i&&pe<t.length&&Ae({type:"end"}),o=de,a=he<t.length?t.charAt(he):null,s=he<t.length?ve(he,he+1):ve(he,he),new e(e.buildMessage(o,a),o,a,s)}}}())}));function l(t,r,n){if(!r)return!0;if(!t)return!1;switch(n||(n=[]),r.type){case"wildcard":return!0;case"identifier":return r.value.toLowerCase()===t.type.toLowerCase();case"field":var o=r.name.split("."),a=n[o.length-1];return function e(t,r,n){if(0===n.length)return t===r;if(null==r)return!1;var o=r[n[0]],a=n.slice(1);if(Array.isArray(o)){for(var s=0,i=o.length;s<i;++s)if(e(t,o[s],a))return!0;return!1}return e(t,o,a)}(t,a,o);case"matches":for(var i=0,f=r.selectors.length;i<f;++i)if(l(t,r.selectors[i],n))return!0;return!1;case"compound":for(var h=0,d=r.selectors.length;h<d;++h)if(!l(t,r.selectors[h],n))return!1;return!0;case"not":for(var y=0,m=r.selectors.length;y<m;++y)if(l(t,r.selectors[y],n))return!1;return!0;case"has":var x=function(){for(var e=[],n=function(n,o){var a=[];s.traverse(t,{enter:function(t,o){null!=o&&a.unshift(o),l(t,r.selectors[n],a)&&e.push(t)},leave:function(){a.shift()},fallback:"iteration"})},o=0,a=r.selectors.length;o<a;++o)n(o);return{v:0!==e.length}}();if("object"===e(x))return x.v;case"child":return!!l(t,r.right,n)&&l(n[0],r.left,n.slice(1));case"descendant":if(l(t,r.right,n))for(var g=0,v=n.length;g<v;++g)if(l(n[g],r.left,n.slice(g+1)))return!0;return!1;case"attribute":var A=function(e,t){for(var r=t.split("."),n=0;n<r.length;n++){if(null==e)return e;e=e[r[n]]}return e}(t,r.name);switch(r.operator){case void 0:return null!=A;case"=":switch(r.value.type){case"regexp":return"string"==typeof A&&r.value.value.test(A);case"literal":return"".concat(r.value.value)==="".concat(A);case"type":return r.value.value===e(A)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"!=":switch(r.value.type){case"regexp":return!r.value.value.test(A);case"literal":return"".concat(r.value.value)!=="".concat(A);case"type":return r.value.value!==e(A)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"<=":return A<=r.value.value;case"<":return A<r.value.value;case">":return A>r.value.value;case">=":return A>=r.value.value}throw new Error("Unknown operator: ".concat(r.operator));case"sibling":return l(t,r.right,n)&&u(t,r.left,n,"LEFT_SIDE")||r.left.subject&&l(t,r.left,n)&&u(t,r.right,n,"RIGHT_SIDE");case"adjacent":return l(t,r.right,n)&&c(t,r.left,n,"LEFT_SIDE")||r.right.subject&&l(t,r.left,n)&&c(t,r.right,n,"RIGHT_SIDE");case"nth-child":return l(t,r.right,n)&&p(t,n,(function(){return r.index.value-1}));case"nth-last-child":return l(t,r.right,n)&&p(t,n,(function(e){return e-r.index.value}));case"class":switch(r.name.toLowerCase()){case"statement":if("Statement"===t.type.slice(-9))return!0;case"declaration":return"Declaration"===t.type.slice(-11);case"pattern":if("Pattern"===t.type.slice(-7))return!0;case"expression":return"Expression"===t.type.slice(-10)||"Literal"===t.type.slice(-7)||"Identifier"===t.type&&(0===n.length||"MetaProperty"!==n[0].type)||"MetaProperty"===t.type;case"function":return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type}throw new Error("Unknown class name: ".concat(r.name))}throw new Error("Unknown selector type: ".concat(r.type))}function u(e,r,n,o){var a=t(n,1)[0];if(!a)return!1;for(var i=s.VisitorKeys[a.type],u=0,c=i.length;u<c;++u){var p=a[i[u]];if(Array.isArray(p)){var f=p.indexOf(e);if(f<0)continue;var h=void 0,d=void 0;"LEFT_SIDE"===o?(h=0,d=f):(h=f+1,d=p.length);for(var y=h;y<d;++y)if(l(p[y],r,n))return!0}}return!1}function c(e,r,n,o){var a=t(n,1)[0];if(!a)return!1;for(var i=s.VisitorKeys[a.type],u=0,c=i.length;u<c;++u){var p=a[i[u]];if(Array.isArray(p)){var f=p.indexOf(e);if(f<0)continue;if("LEFT_SIDE"===o&&f>0&&l(p[f-1],r,n))return!0;if("RIGHT_SIDE"===o&&f<p.length-1&&l(p[f+1],r,n))return!0}}return!1}function p(e,r,n){var o=t(r,1)[0];if(!o)return!1;for(var a=s.VisitorKeys[o.type],i=0,l=a.length;i<l;++i){var u=o[a[i]];if(Array.isArray(u)){var c=u.indexOf(e);if(c>=0&&c===n(u.length))return!0}}return!1}function f(n,o){if(null==n||"object"!=e(n))return[];null==o&&(o=n);for(var a=n.subject?[o]:[],s=0,i=function(e){for(var t=[],r=Object.keys(e),n=0;n<r.length;n++)t.push([r[n],e[r[n]]]);return t}(n);s<i.length;s++){var l=t(i[s],2),u=l[0],c=l[1];a.push.apply(a,r(f(c,"left"===u?c:o)))}return a}function h(e,t,r){if(t){var n=[],o=f(t);s.traverse(e,{enter:function(e,a){if(null!=a&&n.unshift(a),l(e,t,n))if(o.length)for(var s=0,i=o.length;s<i;++s){l(e,o[s],n)&&r(e,a,n);for(var u=0,c=n.length;u<c;++u){var p=n.slice(u+1);l(n[u],o[s],p)&&r(n[u],a,p)}}else r(e,a,n)},leave:function(){n.shift()},fallback:"iteration"})}}function d(e,t){var r=[];return h(e,t,(function(e){r.push(e)})),r}function y(e){return i.parse(e)}function m(e,t){return d(e,y(t))}m.parse=y,m.match=d,m.traverse=h,m.matches=l,m.query=m;export default m; +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(a)throw o}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,o=function(){};return{s:o,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){l=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw i}}}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function i(e,t){return e(t={exports:{}},t.exports),t.exports}var s=i((function(e,t){!function e(t){var r,n,a,o,i,s;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function f(){}function p(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function y(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function d(e,t){return(new f).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,a,o;for(n=e.length,a=0;n;)t(e[o=a+(r=n>>>1)])?n=r:(a=o+1,n-=r+1);return a}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},a={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},n={Break:o={},Skip:i={},Remove:s={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},f.prototype.path=function(){var e,t,r,n,a;function o(e,t){if(Array.isArray(t))for(r=0,n=t.length;r<n;++r)e.push(t[r]);else e.push(t)}if(!this.__current.path)return null;for(a=[],e=2,t=this.__leavelist.length;e<t;++e)o(a,this.__leavelist[e].path);return o(a,this.__current.path),a},f.prototype.type=function(){return this.current().type||this.__current.wrap},f.prototype.parents=function(){var e,t,r;for(r=[],e=1,t=this.__leavelist.length;e<t;++e)r.push(this.__leavelist[e].node);return r},f.prototype.current=function(){return this.__current.node},f.prototype.__execute=function(e,t){var r,n;return n=void 0,r=this.__current,this.__current=t,this.__state=null,e&&(n=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,n},f.prototype.notify=function(e){this.__state=e},f.prototype.skip=function(){this.notify(i)},f.prototype.break=function(){this.notify(o)},f.prototype.remove=function(){this.notify(s)},f.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,"iteration"===t.fallback?this.__fallback=Object.keys:"function"==typeof t.fallback&&(this.__fallback=t.fallback),this.__keys=a,t.keys&&(this.__keys=Object.assign(Object.create(this.__keys),t.keys))},f.prototype.traverse=function(e,t){var r,n,a,s,l,u,f,d,m,x,v,g;for(this.__initialize(e,t),g={},r=this.__worklist,n=this.__leavelist,r.push(new c(e,null,null,null)),n.push(new c(null,null,null,null));r.length;)if((a=r.pop())!==g){if(a.node){if(u=this.__execute(t.enter,a),this.__state===o||u===o)return;if(r.push(g),n.push(a),this.__state===i||u===i)continue;if(l=(s=a.node).type||a.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(s)}for(d=x.length;(d-=1)>=0;)if(v=s[f=x[d]])if(Array.isArray(v)){for(m=v.length;(m-=1)>=0;)if(v[m]&&!y(n,v[m])){if(h(l,x[d]))a=new c(v[m],[f,m],"Property",null);else{if(!p(v[m]))continue;a=new c(v[m],[f,m],null,null)}r.push(a)}}else if(p(v)){if(y(n,v))continue;r.push(new c(v,f,null,null))}}}else if(a=n.pop(),u=this.__execute(t.leave,a),this.__state===o||u===o)return},f.prototype.replace=function(e,t){var r,n,a,l,f,y,d,m,x,v,g,b,A;function E(e){var t,n,a,o;if(e.ref.remove())for(n=e.ref.key,o=e.ref.parent,t=r.length;t--;)if((a=r[t]).ref&&a.ref.parent===o){if(a.ref.key<n)break;--a.ref.key}}for(this.__initialize(e,t),g={},r=this.__worklist,n=this.__leavelist,y=new c(e,null,null,new u(b={root:e},"root")),r.push(y),n.push(y);r.length;)if((y=r.pop())!==g){if(void 0!==(f=this.__execute(t.enter,y))&&f!==o&&f!==i&&f!==s&&(y.ref.replace(f),y.node=f),this.__state!==s&&f!==s||(E(y),y.node=null),this.__state===o||f===o)return b.root;if((a=y.node)&&(r.push(g),n.push(y),this.__state!==i&&f!==i)){if(l=a.type||y.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(a)}for(d=x.length;(d-=1)>=0;)if(v=a[A=x[d]])if(Array.isArray(v)){for(m=v.length;(m-=1)>=0;)if(v[m]){if(h(l,x[d]))y=new c(v[m],[A,m],"Property",new u(v,m));else{if(!p(v[m]))continue;y=new c(v[m],[A,m],null,new u(v,m))}r.push(y)}}else p(v)&&r.push(new c(v,A,null,new u(a,A)))}}else if(y=n.pop(),void 0!==(f=this.__execute(t.leave,y))&&f!==o&&f!==i&&f!==s&&y.ref.replace(f),this.__state!==s&&f!==s||E(y),this.__state===o||f===o)return b.root;return b.root},t.Syntax=r,t.traverse=d,t.replace=function(e,t){return(new f).replace(e,t)},t.attachComments=function(e,t,r){var a,o,i,s,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(i=0,o=t.length;i<o;i+=1)(a=l(t[i])).extendedRange=[0,e.range[0]],u.push(a);e.leadingComments=u}return e}for(i=0,o=t.length;i<o;i+=1)u.push(m(l(t[i]),r));return s=0,d(e,{enter:function(e){for(var t;s<u.length&&!((t=u[s]).extendedRange[1]>e.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(s,1)):s+=1;return s===u.length?n.Break:u[s].extendedRange[0]>e.range[1]?n.Skip:void 0}}),s=0,d(e,{leave:function(e){for(var t;s<u.length&&(t=u[s],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),u.splice(s,1)):s+=1;return s===u.length?n.Break:u[s].extendedRange[0]>e.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=a,t.VisitorOption=n,t.Controller=f,t.cloneEnvironment=function(){return e({})},t}(t)})),l=i((function(e){e.exports&&(e.exports=function(){function e(t,r,n,a){this.message=t,this.expected=r,this.found=n,this.location=a,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.buildMessage=function(e,t){var r={literal:function(e){return'"'+a(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?o(e.parts[t][0])+"-"+o(e.parts[t][1]):o(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function a(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}return"Expected "+function(e){var t,n,a,o=new Array(e.length);for(t=0;t<e.length;t++)o[t]=(a=e[t],r[a.type](a));if(o.sort(),o.length>0){for(t=1,n=1;t<o.length;t++)o[t-1]!==o[t]&&(o[n]=o[t],n++);o.length=n}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(e)+" but "+function(e){return e?'"'+a(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){r=void 0!==r?r:{};var n,a,o,i,s={},l={start:be},u=be,c=de(" ",!1),f=/^[^ [\],():#!=><~+.]/,p=me([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),h=de(">",!1),y=de("~",!1),d=de("+",!1),m=de(",",!1),x=de("!",!1),v=de("*",!1),g=de("#",!1),b=de("[",!1),A=de("]",!1),E=/^[><!]/,S=me([">","<","!"],!1,!1),_=de("=",!1),w=function(e){return(e||"")+"="},C=/^[><]/,P=me([">","<"],!1,!1),k=de(".",!1),D=function(e,t,r){return{type:"attribute",name:e,operator:t,value:r}},j=de('"',!1),I=/^[^\\"]/,T=me(["\\",'"'],!0,!1),F=de("\\",!1),L={type:"any"},O=function(e,t){return e+t},R=function(e){return{type:"literal",value:(t=e.join(""),t.replace(/\\(.)/g,(function(e,t){switch(t){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return t}})))};var t},B=de("'",!1),M=/^[^\\']/,U=me(["\\","'"],!0,!1),V=/^[0-9]/,q=me([["0","9"]],!1,!1),N=de("type(",!1),W=/^[^ )]/,K=me([" ",")"],!0,!1),G=de(")",!1),z=/^[imsu]/,H=me(["i","m","s","u"],!1,!1),Y=de("/",!1),$=/^[^\/]/,J=me(["/"],!0,!1),Q=de(":not(",!1),X=de(":matches(",!1),Z=de(":has(",!1),ee=de(":first-child",!1),te=de(":last-child",!1),re=de(":nth-child(",!1),ne=de(":nth-last-child(",!1),ae=de(":",!1),oe=de("statement",!0),ie=de("expression",!0),se=de("declaration",!0),le=de("function",!0),ue=de("pattern",!0),ce=0,fe=[{line:1,column:1}],pe=0,he=[],ye={};if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function de(e,t){return{type:"literal",text:e,ignoreCase:t}}function me(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function xe(e){var r,n=fe[e];if(n)return n;for(r=e-1;!fe[r];)r--;for(n={line:(n=fe[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return fe[e]=n,n}function ve(e,t){var r=xe(e),n=xe(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function ge(e){ce<pe||(ce>pe&&(pe=ce,he=[]),he.push(e))}function be(){var e,t,r,n,a=30*ce+0,o=ye[a];return o?(ce=o.nextPos,o.result):(e=ce,(t=Ae())!==s&&(r=_e())!==s&&Ae()!==s?e=t=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(ce=e,e=s),e===s&&(e=ce,(t=Ae())!==s&&(t=void 0),e=t),ye[a]={nextPos:ce,result:e},e)}function Ae(){var e,r,n=30*ce+1,a=ye[n];if(a)return ce=a.nextPos,a.result;for(e=[],32===t.charCodeAt(ce)?(r=" ",ce++):(r=s,ge(c));r!==s;)e.push(r),32===t.charCodeAt(ce)?(r=" ",ce++):(r=s,ge(c));return ye[n]={nextPos:ce,result:e},e}function Ee(){var e,r,n,a=30*ce+2,o=ye[a];if(o)return ce=o.nextPos,o.result;if(r=[],f.test(t.charAt(ce))?(n=t.charAt(ce),ce++):(n=s,ge(p)),n!==s)for(;n!==s;)r.push(n),f.test(t.charAt(ce))?(n=t.charAt(ce),ce++):(n=s,ge(p));else r=s;return r!==s&&(r=r.join("")),e=r,ye[a]={nextPos:ce,result:e},e}function Se(){var e,r,n,a=30*ce+3,o=ye[a];return o?(ce=o.nextPos,o.result):(e=ce,(r=Ae())!==s?(62===t.charCodeAt(ce)?(n=">",ce++):(n=s,ge(h)),n!==s&&Ae()!==s?e=r="child":(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=Ae())!==s?(126===t.charCodeAt(ce)?(n="~",ce++):(n=s,ge(y)),n!==s&&Ae()!==s?e=r="sibling":(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=Ae())!==s?(43===t.charCodeAt(ce)?(n="+",ce++):(n=s,ge(d)),n!==s&&Ae()!==s?e=r="adjacent":(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,32===t.charCodeAt(ce)?(r=" ",ce++):(r=s,ge(c)),r!==s&&(n=Ae())!==s?e=r="descendant":(ce=e,e=s)))),ye[a]={nextPos:ce,result:e},e)}function _e(){var e,r,n,a,o,i,l,u,c=30*ce+4,f=ye[c];if(f)return ce=f.nextPos,f.result;if(e=ce,(r=we())!==s){for(n=[],a=ce,(o=Ae())!==s?(44===t.charCodeAt(ce)?(i=",",ce++):(i=s,ge(m)),i!==s&&(l=Ae())!==s&&(u=we())!==s?a=o=[o,i,l,u]:(ce=a,a=s)):(ce=a,a=s);a!==s;)n.push(a),a=ce,(o=Ae())!==s?(44===t.charCodeAt(ce)?(i=",",ce++):(i=s,ge(m)),i!==s&&(l=Ae())!==s&&(u=we())!==s?a=o=[o,i,l,u]:(ce=a,a=s)):(ce=a,a=s);n!==s?e=r=[r].concat(n.map((function(e){return e[3]}))):(ce=e,e=s)}else ce=e,e=s;return ye[c]={nextPos:ce,result:e},e}function we(){var e,t,r,n,a,o,i,l=30*ce+5,u=ye[l];if(u)return ce=u.nextPos,u.result;if(e=ce,(t=Ce())!==s){for(r=[],n=ce,(a=Se())!==s&&(o=Ce())!==s?n=a=[a,o]:(ce=n,n=s);n!==s;)r.push(n),n=ce,(a=Se())!==s&&(o=Ce())!==s?n=a=[a,o]:(ce=n,n=s);r!==s?(i=t,e=t=r.reduce((function(e,t){return{type:t[0],left:e,right:t[1]}}),i)):(ce=e,e=s)}else ce=e,e=s;return ye[l]={nextPos:ce,result:e},e}function Ce(){var e,r,n,a,o,i,l,u=30*ce+6,c=ye[u];if(c)return ce=c.nextPos,c.result;if(e=ce,33===t.charCodeAt(ce)?(r="!",ce++):(r=s,ge(x)),r===s&&(r=null),r!==s){if(n=[],(a=Pe())!==s)for(;a!==s;)n.push(a),a=Pe();else n=s;n!==s?(o=r,l=1===(i=n).length?i[0]:{type:"compound",selectors:i},o&&(l.subject=!0),e=r=l):(ce=e,e=s)}else ce=e,e=s;return ye[u]={nextPos:ce,result:e},e}function Pe(){var e,r=30*ce+7,n=ye[r];return n?(ce=n.nextPos,n.result):((e=function(){var e,r,n=30*ce+8,a=ye[n];return a?(ce=a.nextPos,a.result):(42===t.charCodeAt(ce)?(r="*",ce++):(r=s,ge(v)),r!==s&&(r={type:"wildcard",value:r}),e=r,ye[n]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,a=30*ce+9,o=ye[a];return o?(ce=o.nextPos,o.result):(e=ce,35===t.charCodeAt(ce)?(r="#",ce++):(r=s,ge(g)),r===s&&(r=null),r!==s&&(n=Ee())!==s?e=r={type:"identifier",value:n}:(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,a,o=30*ce+10,i=ye[o];return i?(ce=i.nextPos,i.result):(e=ce,91===t.charCodeAt(ce)?(r="[",ce++):(r=s,ge(b)),r!==s&&Ae()!==s&&(n=function(){var e,r,n,a,o=30*ce+14,i=ye[o];return i?(ce=i.nextPos,i.result):(e=ce,(r=ke())!==s&&Ae()!==s&&(n=function(){var e,r,n,a=30*ce+12,o=ye[a];return o?(ce=o.nextPos,o.result):(e=ce,33===t.charCodeAt(ce)?(r="!",ce++):(r=s,ge(x)),r===s&&(r=null),r!==s?(61===t.charCodeAt(ce)?(n="=",ce++):(n=s,ge(_)),n!==s?(r=w(r),e=r):(ce=e,e=s)):(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}())!==s&&Ae()!==s?((a=function(){var e,r,n,a,o,i=30*ce+18,l=ye[i];if(l)return ce=l.nextPos,l.result;if(e=ce,"type("===t.substr(ce,5)?(r="type(",ce+=5):(r=s,ge(N)),r!==s)if(Ae()!==s){if(n=[],W.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(K)),a!==s)for(;a!==s;)n.push(a),W.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(K));else n=s;n!==s&&(a=Ae())!==s?(41===t.charCodeAt(ce)?(o=")",ce++):(o=s,ge(G)),o!==s?(r={type:"type",value:n.join("")},e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[i]={nextPos:ce,result:e},e}())===s&&(a=function(){var e,r,n,a,o,i,l=30*ce+20,u=ye[l];if(u)return ce=u.nextPos,u.result;if(e=ce,47===t.charCodeAt(ce)?(r="/",ce++):(r=s,ge(Y)),r!==s){if(n=[],$.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(J)),a!==s)for(;a!==s;)n.push(a),$.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(J));else n=s;n!==s?(47===t.charCodeAt(ce)?(a="/",ce++):(a=s,ge(Y)),a!==s?((o=function(){var e,r,n=30*ce+19,a=ye[n];if(a)return ce=a.nextPos,a.result;if(e=[],z.test(t.charAt(ce))?(r=t.charAt(ce),ce++):(r=s,ge(H)),r!==s)for(;r!==s;)e.push(r),z.test(t.charAt(ce))?(r=t.charAt(ce),ce++):(r=s,ge(H));else e=s;return ye[n]={nextPos:ce,result:e},e}())===s&&(o=null),o!==s?(i=o,r={type:"regexp",value:new RegExp(n.join(""),i?i.join(""):"")},e=r):(ce=e,e=s)):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;return ye[l]={nextPos:ce,result:e},e}()),a!==s?(r=D(r,n,a),e=r):(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=ke())!==s&&Ae()!==s&&(n=function(){var e,r,n,a=30*ce+11,o=ye[a];return o?(ce=o.nextPos,o.result):(e=ce,E.test(t.charAt(ce))?(r=t.charAt(ce),ce++):(r=s,ge(S)),r===s&&(r=null),r!==s?(61===t.charCodeAt(ce)?(n="=",ce++):(n=s,ge(_)),n!==s?(r=w(r),e=r):(ce=e,e=s)):(ce=e,e=s),e===s&&(C.test(t.charAt(ce))?(e=t.charAt(ce),ce++):(e=s,ge(P))),ye[a]={nextPos:ce,result:e},e)}())!==s&&Ae()!==s?((a=function(){var e,r,n,a,o,i,l=30*ce+15,u=ye[l];if(u)return ce=u.nextPos,u.result;if(e=ce,34===t.charCodeAt(ce)?(r='"',ce++):(r=s,ge(j)),r!==s){for(n=[],I.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(T)),a===s&&(a=ce,92===t.charCodeAt(ce)?(o="\\",ce++):(o=s,ge(F)),o!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(o=O(o,i),a=o):(ce=a,a=s)):(ce=a,a=s));a!==s;)n.push(a),I.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(T)),a===s&&(a=ce,92===t.charCodeAt(ce)?(o="\\",ce++):(o=s,ge(F)),o!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(o=O(o,i),a=o):(ce=a,a=s)):(ce=a,a=s));n!==s?(34===t.charCodeAt(ce)?(a='"',ce++):(a=s,ge(j)),a!==s?(r=R(n),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;if(e===s)if(e=ce,39===t.charCodeAt(ce)?(r="'",ce++):(r=s,ge(B)),r!==s){for(n=[],M.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(U)),a===s&&(a=ce,92===t.charCodeAt(ce)?(o="\\",ce++):(o=s,ge(F)),o!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(o=O(o,i),a=o):(ce=a,a=s)):(ce=a,a=s));a!==s;)n.push(a),M.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(U)),a===s&&(a=ce,92===t.charCodeAt(ce)?(o="\\",ce++):(o=s,ge(F)),o!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(o=O(o,i),a=o):(ce=a,a=s)):(ce=a,a=s));n!==s?(39===t.charCodeAt(ce)?(a="'",ce++):(a=s,ge(B)),a!==s?(r=R(n),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;return ye[l]={nextPos:ce,result:e},e}())===s&&(a=function(){var e,r,n,a,o,i,l,u=30*ce+16,c=ye[u];if(c)return ce=c.nextPos,c.result;for(e=ce,r=ce,n=[],V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q));a!==s;)n.push(a),V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q));if(n!==s?(46===t.charCodeAt(ce)?(a=".",ce++):(a=s,ge(k)),a!==s?r=n=[n,a]:(ce=r,r=s)):(ce=r,r=s),r===s&&(r=null),r!==s){if(n=[],V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q)),a!==s)for(;a!==s;)n.push(a),V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q));else n=s;n!==s?(i=n,l=(o=r)?[].concat.apply([],o).join(""):"",r={type:"literal",value:parseFloat(l+i.join(""))},e=r):(ce=e,e=s)}else ce=e,e=s;return ye[u]={nextPos:ce,result:e},e}())===s&&(a=function(){var e,t,r=30*ce+17,n=ye[r];return n?(ce=n.nextPos,n.result):((t=Ee())!==s&&(t={type:"literal",value:t}),e=t,ye[r]={nextPos:ce,result:e},e)}()),a!==s?(r=D(r,n,a),e=r):(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=ke())!==s&&(r={type:"attribute",name:r}),e=r)),ye[o]={nextPos:ce,result:e},e)}())!==s&&Ae()!==s?(93===t.charCodeAt(ce)?(a="]",ce++):(a=s,ge(A)),a!==s?e=r=n:(ce=e,e=s)):(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,a,o,i,l,u,c=30*ce+21,f=ye[c];if(f)return ce=f.nextPos,f.result;if(e=ce,46===t.charCodeAt(ce)?(r=".",ce++):(r=s,ge(k)),r!==s)if((n=Ee())!==s){for(a=[],o=ce,46===t.charCodeAt(ce)?(i=".",ce++):(i=s,ge(k)),i!==s&&(l=Ee())!==s?o=i=[i,l]:(ce=o,o=s);o!==s;)a.push(o),o=ce,46===t.charCodeAt(ce)?(i=".",ce++):(i=s,ge(k)),i!==s&&(l=Ee())!==s?o=i=[i,l]:(ce=o,o=s);a!==s?(u=n,r={type:"field",name:a.reduce((function(e,t){return e+t[0]+t[1]}),u)},e=r):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[c]={nextPos:ce,result:e},e}())===s&&(e=function(){var e,r,n,a,o=30*ce+22,i=ye[o];return i?(ce=i.nextPos,i.result):(e=ce,":not("===t.substr(ce,5)?(r=":not(",ce+=5):(r=s,ge(Q)),r!==s&&Ae()!==s&&(n=_e())!==s&&Ae()!==s?(41===t.charCodeAt(ce)?(a=")",ce++):(a=s,ge(G)),a!==s?e=r={type:"not",selectors:n}:(ce=e,e=s)):(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,a,o=30*ce+23,i=ye[o];return i?(ce=i.nextPos,i.result):(e=ce,":matches("===t.substr(ce,9)?(r=":matches(",ce+=9):(r=s,ge(X)),r!==s&&Ae()!==s&&(n=_e())!==s&&Ae()!==s?(41===t.charCodeAt(ce)?(a=")",ce++):(a=s,ge(G)),a!==s?e=r={type:"matches",selectors:n}:(ce=e,e=s)):(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,a,o=30*ce+24,i=ye[o];return i?(ce=i.nextPos,i.result):(e=ce,":has("===t.substr(ce,5)?(r=":has(",ce+=5):(r=s,ge(Z)),r!==s&&Ae()!==s&&(n=_e())!==s&&Ae()!==s?(41===t.charCodeAt(ce)?(a=")",ce++):(a=s,ge(G)),a!==s?e=r={type:"has",selectors:n}:(ce=e,e=s)):(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n=30*ce+25,a=ye[n];return a?(ce=a.nextPos,a.result):(":first-child"===t.substr(ce,12)?(r=":first-child",ce+=12):(r=s,ge(ee)),r!==s&&(r=De(1)),e=r,ye[n]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n=30*ce+26,a=ye[n];return a?(ce=a.nextPos,a.result):(":last-child"===t.substr(ce,11)?(r=":last-child",ce+=11):(r=s,ge(te)),r!==s&&(r=je(1)),e=r,ye[n]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,a,o,i=30*ce+27,l=ye[i];if(l)return ce=l.nextPos,l.result;if(e=ce,":nth-child("===t.substr(ce,11)?(r=":nth-child(",ce+=11):(r=s,ge(re)),r!==s)if(Ae()!==s){if(n=[],V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q)),a!==s)for(;a!==s;)n.push(a),V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q));else n=s;n!==s&&(a=Ae())!==s?(41===t.charCodeAt(ce)?(o=")",ce++):(o=s,ge(G)),o!==s?(r=De(parseInt(n.join(""),10)),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[i]={nextPos:ce,result:e},e}())===s&&(e=function(){var e,r,n,a,o,i=30*ce+28,l=ye[i];if(l)return ce=l.nextPos,l.result;if(e=ce,":nth-last-child("===t.substr(ce,16)?(r=":nth-last-child(",ce+=16):(r=s,ge(ne)),r!==s)if(Ae()!==s){if(n=[],V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q)),a!==s)for(;a!==s;)n.push(a),V.test(t.charAt(ce))?(a=t.charAt(ce),ce++):(a=s,ge(q));else n=s;n!==s&&(a=Ae())!==s?(41===t.charCodeAt(ce)?(o=")",ce++):(o=s,ge(G)),o!==s?(r=je(parseInt(n.join(""),10)),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[i]={nextPos:ce,result:e},e}())===s&&(e=function(){var e,r,n,a=30*ce+29,o=ye[a];return o?(ce=o.nextPos,o.result):(e=ce,58===t.charCodeAt(ce)?(r=":",ce++):(r=s,ge(ae)),r!==s?("statement"===t.substr(ce,9).toLowerCase()?(n=t.substr(ce,9),ce+=9):(n=s,ge(oe)),n===s&&("expression"===t.substr(ce,10).toLowerCase()?(n=t.substr(ce,10),ce+=10):(n=s,ge(ie)),n===s&&("declaration"===t.substr(ce,11).toLowerCase()?(n=t.substr(ce,11),ce+=11):(n=s,ge(se)),n===s&&("function"===t.substr(ce,8).toLowerCase()?(n=t.substr(ce,8),ce+=8):(n=s,ge(le)),n===s&&("pattern"===t.substr(ce,7).toLowerCase()?(n=t.substr(ce,7),ce+=7):(n=s,ge(ue)))))),n!==s?e=r={type:"class",name:n}:(ce=e,e=s)):(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}()),ye[r]={nextPos:ce,result:e},e)}function ke(){var e,r,n,a,o,i,l,u,c=30*ce+13,f=ye[c];if(f)return ce=f.nextPos,f.result;if(e=ce,(r=Ee())!==s){for(n=[],a=ce,46===t.charCodeAt(ce)?(o=".",ce++):(o=s,ge(k)),o!==s&&(i=Ee())!==s?a=o=[o,i]:(ce=a,a=s);a!==s;)n.push(a),a=ce,46===t.charCodeAt(ce)?(o=".",ce++):(o=s,ge(k)),o!==s&&(i=Ee())!==s?a=o=[o,i]:(ce=a,a=s);n!==s?(l=r,u=n,e=r=[].concat.apply([l],u).join("")):(ce=e,e=s)}else ce=e,e=s;return ye[c]={nextPos:ce,result:e},e}function De(e){return{type:"nth-child",index:{type:"literal",value:e}}}function je(e){return{type:"nth-last-child",index:{type:"literal",value:e}}}if((n=u())!==s&&ce===t.length)return n;throw n!==s&&ce<t.length&&ge({type:"end"}),a=he,o=pe<t.length?t.charAt(pe):null,i=pe<t.length?ve(pe,pe+1):ve(pe,pe),new e(e.buildMessage(a,o),a,o,i)}}}())}));function u(t,r,n,a){if(!r)return!0;if(!t)return!1;switch(n||(n=[]),r.type){case"wildcard":return!0;case"identifier":return r.value.toLowerCase()===t.type.toLowerCase();case"field":var i=r.name.split("."),l=n[i.length-1];return function e(t,r,n){if(0===n.length)return t===r;if(null==r)return!1;var a=r[n[0]],i=n.slice(1);if(Array.isArray(a)){var s,l=o(a);try{for(l.s();!(s=l.n()).done;){if(e(t,s.value,i))return!0}}catch(e){l.e(e)}finally{l.f()}return!1}return e(t,a,i)}(t,l,i);case"matches":var c,f=o(r.selectors);try{for(f.s();!(c=f.n()).done;){var d=c.value;if(u(t,d,n,a))return!0}}catch(e){f.e(e)}finally{f.f()}return!1;case"compound":var m,x=o(r.selectors);try{for(x.s();!(m=x.n()).done;){var v=m.value;if(!u(t,v,n,a))return!1}}catch(e){x.e(e)}finally{x.f()}return!0;case"not":var g,b=o(r.selectors);try{for(b.s();!(g=b.n()).done;){var A=g.value;if(u(t,A,n,a))return!1}}catch(e){b.e(e)}finally{b.f()}return!0;case"has":var E=function(){var e,n=[],i=o(r.selectors);try{var l=function(){var r=e.value,o=[];s.traverse(t,{enter:function(e,t){null!=t&&o.unshift(t),u(e,r,o,a)&&n.push(e)},leave:function(){o.shift()},keys:a&&a.visitorKeys,fallback:a&&a.fallback||"iteration"})};for(i.s();!(e=i.n()).done;)l()}catch(e){i.e(e)}finally{i.f()}return{v:0!==n.length}}();if("object"===e(E))return E.v;case"child":return!!u(t,r.right,n,a)&&u(n[0],r.left,n.slice(1),a);case"descendant":if(u(t,r.right,n,a))for(var S=0,_=n.length;S<_;++S)if(u(n[S],r.left,n.slice(S+1),a))return!0;return!1;case"attribute":var w=function(e,t){var r,n=o(t.split("."));try{for(n.s();!(r=n.n()).done;){var a=r.value;if(null==e)return e;e=e[a]}}catch(e){n.e(e)}finally{n.f()}return e}(t,r.name);switch(r.operator){case void 0:return null!=w;case"=":switch(r.value.type){case"regexp":return"string"==typeof w&&r.value.value.test(w);case"literal":return"".concat(r.value.value)==="".concat(w);case"type":return r.value.value===e(w)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"!=":switch(r.value.type){case"regexp":return!r.value.value.test(w);case"literal":return"".concat(r.value.value)!=="".concat(w);case"type":return r.value.value!==e(w)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"<=":return w<=r.value.value;case"<":return w<r.value.value;case">":return w>r.value.value;case">=":return w>=r.value.value}throw new Error("Unknown operator: ".concat(r.operator));case"sibling":return u(t,r.right,n,a)&&p(t,r.left,n,"LEFT_SIDE",a)||r.left.subject&&u(t,r.left,n,a)&&p(t,r.right,n,"RIGHT_SIDE",a);case"adjacent":return u(t,r.right,n,a)&&h(t,r.left,n,"LEFT_SIDE",a)||r.right.subject&&u(t,r.left,n,a)&&h(t,r.right,n,"RIGHT_SIDE",a);case"nth-child":return u(t,r.right,n,a)&&y(t,n,(function(){return r.index.value-1}),a);case"nth-last-child":return u(t,r.right,n,a)&&y(t,n,(function(e){return e-r.index.value}),a);case"class":switch(r.name.toLowerCase()){case"statement":if("Statement"===t.type.slice(-9))return!0;case"declaration":return"Declaration"===t.type.slice(-11);case"pattern":if("Pattern"===t.type.slice(-7))return!0;case"expression":return"Expression"===t.type.slice(-10)||"Literal"===t.type.slice(-7)||"Identifier"===t.type&&(0===n.length||"MetaProperty"!==n[0].type)||"MetaProperty"===t.type;case"function":return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type}throw new Error("Unknown class name: ".concat(r.name))}throw new Error("Unknown selector type: ".concat(r.type))}function c(e,t){var r=e.type;return t&&t.visitorKeys&&t.visitorKeys[r]?t.visitorKeys[r]:s.VisitorKeys[r]?s.VisitorKeys[r]:t&&"function"==typeof t.fallback?t.fallback(e):Object.keys(e).filter((function(e){return"type"!==e}))}function f(t){return null!==t&&"object"===e(t)&&"string"==typeof t.type}function p(e,r,n,a,i){var s=t(n,1)[0];if(!s)return!1;var l,p=o(c(s,i));try{for(p.s();!(l=p.n()).done;){var h=s[l.value];if(Array.isArray(h)){var y=h.indexOf(e);if(y<0)continue;var d=void 0,m=void 0;"LEFT_SIDE"===a?(d=0,m=y):(d=y+1,m=h.length);for(var x=d;x<m;++x)if(f(h[x])&&u(h[x],r,n,i))return!0}}}catch(e){p.e(e)}finally{p.f()}return!1}function h(e,r,n,a,i){var s=t(n,1)[0];if(!s)return!1;var l,p=o(c(s,i));try{for(p.s();!(l=p.n()).done;){var h=s[l.value];if(Array.isArray(h)){var y=h.indexOf(e);if(y<0)continue;if("LEFT_SIDE"===a&&y>0&&f(h[y-1])&&u(h[y-1],r,n,i))return!0;if("RIGHT_SIDE"===a&&y<h.length-1&&f(h[y+1])&&u(h[y+1],r,n,i))return!0}}}catch(e){p.e(e)}finally{p.f()}return!1}function y(e,r,n,a){var i=t(r,1)[0];if(!i)return!1;var s,l=o(c(i,a));try{for(l.s();!(s=l.n()).done;){var u=i[s.value];if(Array.isArray(u)){var f=u.indexOf(e);if(f>=0&&f===n(u.length))return!0}}}catch(e){l.e(e)}finally{l.f()}return!1}function d(n,a){if(null==n||"object"!=e(n))return[];null==a&&(a=n);for(var o=n.subject?[a]:[],i=0,s=function(e){for(var t=[],r=Object.keys(e),n=0;n<r.length;n++)t.push([r[n],e[r[n]]]);return t}(n);i<s.length;i++){var l=t(s[i],2),u=l[0],c=l[1];o.push.apply(o,r(d(c,"left"===u?c:a)))}return o}function m(e,t,r,n){if(t){var a=[],o=d(t);s.traverse(e,{enter:function(e,i){if(null!=i&&a.unshift(i),u(e,t,a,n))if(o.length)for(var s=0,l=o.length;s<l;++s){u(e,o[s],a,n)&&r(e,i,a);for(var c=0,f=a.length;c<f;++c){var p=a.slice(c+1);u(a[c],o[s],p,n)&&r(a[c],i,p)}}else r(e,i,a)},leave:function(){a.shift()},keys:n&&n.visitorKeys,fallback:n&&n.fallback||"iteration"})}}function x(e,t,r){var n=[];return m(e,t,(function(e){n.push(e)}),r),n}function v(e){return l.parse(e)}function g(e,t,r){return x(e,v(t),r)}g.parse=v,g.match=x,g.traverse=m,g.matches=u,g.query=g;export default g; //# sourceMappingURL=esquery.esm.min.js.map diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.js index e2c80afc13..adc2a5ed6f 100644 --- a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.js +++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.js @@ -72,7 +72,7 @@ if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(n); + if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } @@ -92,6 +92,63 @@ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, module) { @@ -188,6 +245,7 @@ BreakStatement: 'BreakStatement', CallExpression: 'CallExpression', CatchClause: 'CatchClause', + ChainExpression: 'ChainExpression', ClassBody: 'ClassBody', ClassDeclaration: 'ClassDeclaration', ClassExpression: 'ClassExpression', @@ -266,6 +324,7 @@ BreakStatement: ['label'], CallExpression: ['callee', 'arguments'], CatchClause: ['param', 'body'], + ChainExpression: ['expression'], ClassBody: ['body'], ClassDeclaration: ['id', 'superClass', 'body'], ClassExpression: ['id', 'superClass', 'body'], @@ -1132,7 +1191,10 @@ peg$c41 = peg$classExpectation([">", "<"], false, false), peg$c42 = ".", peg$c43 = peg$literalExpectation(".", false), - peg$c44 = function peg$c44(name, op, value) { + peg$c44 = function peg$c44(a, as) { + return [].concat.apply([a], as).join(''); + }, + peg$c45 = function peg$c45(name, op, value) { return { type: 'attribute', name: name, @@ -1140,35 +1202,35 @@ value: value }; }, - peg$c45 = function peg$c45(name) { + peg$c46 = function peg$c46(name) { return { type: 'attribute', name: name }; }, - peg$c46 = "\"", - peg$c47 = peg$literalExpectation("\"", false), - peg$c48 = /^[^\\"]/, - peg$c49 = peg$classExpectation(["\\", "\""], true, false), - peg$c50 = "\\", - peg$c51 = peg$literalExpectation("\\", false), - peg$c52 = peg$anyExpectation(), - peg$c53 = function peg$c53(a, b) { + peg$c47 = "\"", + peg$c48 = peg$literalExpectation("\"", false), + peg$c49 = /^[^\\"]/, + peg$c50 = peg$classExpectation(["\\", "\""], true, false), + peg$c51 = "\\", + peg$c52 = peg$literalExpectation("\\", false), + peg$c53 = peg$anyExpectation(), + peg$c54 = function peg$c54(a, b) { return a + b; }, - peg$c54 = function peg$c54(d) { + peg$c55 = function peg$c55(d) { return { type: 'literal', value: strUnescape(d.join('')) }; }, - peg$c55 = "'", - peg$c56 = peg$literalExpectation("'", false), - peg$c57 = /^[^\\']/, - peg$c58 = peg$classExpectation(["\\", "'"], true, false), - peg$c59 = /^[0-9]/, - peg$c60 = peg$classExpectation([["0", "9"]], false, false), - peg$c61 = function peg$c61(a, b) { + peg$c56 = "'", + peg$c57 = peg$literalExpectation("'", false), + peg$c58 = /^[^\\']/, + peg$c59 = peg$classExpectation(["\\", "'"], true, false), + peg$c60 = /^[0-9]/, + peg$c61 = peg$classExpectation([["0", "9"]], false, false), + peg$c62 = function peg$c62(a, b) { // Can use `a.flat().join('')` once supported var leadingDecimals = a ? [].concat.apply([], a).join('') : ''; return { @@ -1176,37 +1238,37 @@ value: parseFloat(leadingDecimals + b.join('')) }; }, - peg$c62 = function peg$c62(i) { + peg$c63 = function peg$c63(i) { return { type: 'literal', value: i }; }, - peg$c63 = "type(", - peg$c64 = peg$literalExpectation("type(", false), - peg$c65 = /^[^ )]/, - peg$c66 = peg$classExpectation([" ", ")"], true, false), - peg$c67 = ")", - peg$c68 = peg$literalExpectation(")", false), - peg$c69 = function peg$c69(t) { + peg$c64 = "type(", + peg$c65 = peg$literalExpectation("type(", false), + peg$c66 = /^[^ )]/, + peg$c67 = peg$classExpectation([" ", ")"], true, false), + peg$c68 = ")", + peg$c69 = peg$literalExpectation(")", false), + peg$c70 = function peg$c70(t) { return { type: 'type', value: t.join('') }; }, - peg$c70 = /^[imsu]/, - peg$c71 = peg$classExpectation(["i", "m", "s", "u"], false, false), - peg$c72 = "/", - peg$c73 = peg$literalExpectation("/", false), - peg$c74 = /^[^\/]/, - peg$c75 = peg$classExpectation(["/"], true, false), - peg$c76 = function peg$c76(d, flgs) { + peg$c71 = /^[imsu]/, + peg$c72 = peg$classExpectation(["i", "m", "s", "u"], false, false), + peg$c73 = "/", + peg$c74 = peg$literalExpectation("/", false), + peg$c75 = /^[^\/]/, + peg$c76 = peg$classExpectation(["/"], true, false), + peg$c77 = function peg$c77(d, flgs) { return { type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') }; }, - peg$c77 = function peg$c77(i, is) { + peg$c78 = function peg$c78(i, is) { return { type: 'field', name: is.reduce(function (memo, p) { @@ -1214,63 +1276,63 @@ }, i) }; }, - peg$c78 = ":not(", - peg$c79 = peg$literalExpectation(":not(", false), - peg$c80 = function peg$c80(ss) { + peg$c79 = ":not(", + peg$c80 = peg$literalExpectation(":not(", false), + peg$c81 = function peg$c81(ss) { return { type: 'not', selectors: ss }; }, - peg$c81 = ":matches(", - peg$c82 = peg$literalExpectation(":matches(", false), - peg$c83 = function peg$c83(ss) { + peg$c82 = ":matches(", + peg$c83 = peg$literalExpectation(":matches(", false), + peg$c84 = function peg$c84(ss) { return { type: 'matches', selectors: ss }; }, - peg$c84 = ":has(", - peg$c85 = peg$literalExpectation(":has(", false), - peg$c86 = function peg$c86(ss) { + peg$c85 = ":has(", + peg$c86 = peg$literalExpectation(":has(", false), + peg$c87 = function peg$c87(ss) { return { type: 'has', selectors: ss }; }, - peg$c87 = ":first-child", - peg$c88 = peg$literalExpectation(":first-child", false), - peg$c89 = function peg$c89() { + peg$c88 = ":first-child", + peg$c89 = peg$literalExpectation(":first-child", false), + peg$c90 = function peg$c90() { return nth(1); }, - peg$c90 = ":last-child", - peg$c91 = peg$literalExpectation(":last-child", false), - peg$c92 = function peg$c92() { + peg$c91 = ":last-child", + peg$c92 = peg$literalExpectation(":last-child", false), + peg$c93 = function peg$c93() { return nthLast(1); }, - peg$c93 = ":nth-child(", - peg$c94 = peg$literalExpectation(":nth-child(", false), - peg$c95 = function peg$c95(n) { + peg$c94 = ":nth-child(", + peg$c95 = peg$literalExpectation(":nth-child(", false), + peg$c96 = function peg$c96(n) { return nth(parseInt(n.join(''), 10)); }, - peg$c96 = ":nth-last-child(", - peg$c97 = peg$literalExpectation(":nth-last-child(", false), - peg$c98 = function peg$c98(n) { + peg$c97 = ":nth-last-child(", + peg$c98 = peg$literalExpectation(":nth-last-child(", false), + peg$c99 = function peg$c99(n) { return nthLast(parseInt(n.join(''), 10)); }, - peg$c99 = ":", - peg$c100 = peg$literalExpectation(":", false), - peg$c101 = "statement", - peg$c102 = peg$literalExpectation("statement", true), - peg$c103 = "expression", - peg$c104 = peg$literalExpectation("expression", true), - peg$c105 = "declaration", - peg$c106 = peg$literalExpectation("declaration", true), - peg$c107 = "function", - peg$c108 = peg$literalExpectation("function", true), - peg$c109 = "pattern", - peg$c110 = peg$literalExpectation("pattern", true), - peg$c111 = function peg$c111(c) { + peg$c100 = ":", + peg$c101 = peg$literalExpectation(":", false), + peg$c102 = "statement", + peg$c103 = peg$literalExpectation("statement", true), + peg$c104 = "expression", + peg$c105 = peg$literalExpectation("expression", true), + peg$c106 = "declaration", + peg$c107 = peg$literalExpectation("declaration", true), + peg$c108 = "function", + peg$c109 = peg$literalExpectation("function", true), + peg$c110 = "pattern", + peg$c111 = peg$literalExpectation("pattern", true), + peg$c112 = function peg$c112(c) { return { type: 'class', name: c @@ -2301,7 +2363,7 @@ } function peg$parseattrName() { - var s0, s1, s2; + var s0, s1, s2, s3, s4, s5; var key = peg$currPos * 30 + 13, cached = peg$resultsCache[key]; @@ -2311,49 +2373,81 @@ } s0 = peg$currPos; - s1 = []; - s2 = peg$parseidentifierName(); + s1 = peg$parseidentifierName(); + + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; - if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c42; + s4 = peg$c42; peg$currPos++; } else { - s2 = peg$FAILED; + s4 = peg$FAILED; { peg$fail(peg$c43); } } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parseidentifierName(); + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c42; - peg$currPos++; - } else { - s2 = peg$FAILED; + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } - { - peg$fail(peg$c43); - } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c42; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c43); } } + + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); + + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s1 = peg$c6(s1); + if (s2 !== peg$FAILED) { + s1 = peg$c44(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - s0 = s1; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 @@ -2391,7 +2485,7 @@ } if (s5 !== peg$FAILED) { - s1 = peg$c44(s1, s3, s5); + s1 = peg$c45(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; @@ -2439,7 +2533,7 @@ } if (s5 !== peg$FAILED) { - s1 = peg$c44(s1, s3, s5); + s1 = peg$c45(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; @@ -2467,7 +2561,7 @@ s1 = peg$parseattrName(); if (s1 !== peg$FAILED) { - s1 = peg$c45(s1); + s1 = peg$c46(s1); } s0 = s1; @@ -2494,27 +2588,27 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c46; + s1 = peg$c47; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c47); + peg$fail(peg$c48); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c48.test(input.charAt(peg$currPos))) { + if (peg$c49.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c49); + peg$fail(peg$c50); } } @@ -2522,13 +2616,13 @@ s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2540,12 +2634,12 @@ s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2560,14 +2654,14 @@ while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c48.test(input.charAt(peg$currPos))) { + if (peg$c49.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c49); + peg$fail(peg$c50); } } @@ -2575,13 +2669,13 @@ s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2593,12 +2687,12 @@ s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2613,18 +2707,18 @@ if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c46; + s3 = peg$c47; peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c47); + peg$fail(peg$c48); } } if (s3 !== peg$FAILED) { - s1 = peg$c54(s2); + s1 = peg$c55(s2); s0 = s1; } else { peg$currPos = s0; @@ -2643,27 +2737,27 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c55; + s1 = peg$c56; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c56); + peg$fail(peg$c57); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c57.test(input.charAt(peg$currPos))) { + if (peg$c58.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c58); + peg$fail(peg$c59); } } @@ -2671,13 +2765,13 @@ s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2689,12 +2783,12 @@ s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2709,14 +2803,14 @@ while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c57.test(input.charAt(peg$currPos))) { + if (peg$c58.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c58); + peg$fail(peg$c59); } } @@ -2724,13 +2818,13 @@ s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c51); + peg$fail(peg$c52); } } @@ -2742,12 +2836,12 @@ s5 = peg$FAILED; { - peg$fail(peg$c52); + peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -2762,18 +2856,18 @@ if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c55; + s3 = peg$c56; peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c56); + peg$fail(peg$c57); } } if (s3 !== peg$FAILED) { - s1 = peg$c54(s2); + s1 = peg$c55(s2); s0 = s1; } else { peg$currPos = s0; @@ -2810,28 +2904,28 @@ s1 = peg$currPos; s2 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -2867,14 +2961,14 @@ if (s1 !== peg$FAILED) { s2 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } @@ -2882,14 +2976,14 @@ while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -2898,7 +2992,7 @@ } if (s2 !== peg$FAILED) { - s1 = peg$c61(s1, s2); + s1 = peg$c62(s1, s2); s0 = s1; } else { peg$currPos = s0; @@ -2930,7 +3024,7 @@ s1 = peg$parseidentifierName(); if (s1 !== peg$FAILED) { - s1 = peg$c62(s1); + s1 = peg$c63(s1); } s0 = s1; @@ -2953,14 +3047,14 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c63) { - s1 = peg$c63; + if (input.substr(peg$currPos, 5) === peg$c64) { + s1 = peg$c64; peg$currPos += 5; } else { s1 = peg$FAILED; { - peg$fail(peg$c64); + peg$fail(peg$c65); } } @@ -2970,14 +3064,14 @@ if (s2 !== peg$FAILED) { s3 = []; - if (peg$c65.test(input.charAt(peg$currPos))) { + if (peg$c66.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c66); + peg$fail(peg$c67); } } @@ -2985,14 +3079,14 @@ while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c65.test(input.charAt(peg$currPos))) { + if (peg$c66.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c66); + peg$fail(peg$c67); } } } @@ -3005,18 +3099,18 @@ if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c69(s3); + s1 = peg$c70(s3); s0 = s1; } else { peg$currPos = s0; @@ -3058,14 +3152,14 @@ s0 = []; - if (peg$c70.test(input.charAt(peg$currPos))) { + if (peg$c71.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c71); + peg$fail(peg$c72); } } @@ -3073,14 +3167,14 @@ while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$c70.test(input.charAt(peg$currPos))) { + if (peg$c71.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c71); + peg$fail(peg$c72); } } } @@ -3108,27 +3202,27 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { - s1 = peg$c72; + s1 = peg$c73; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c73); + peg$fail(peg$c74); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c74.test(input.charAt(peg$currPos))) { + if (peg$c75.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c75); + peg$fail(peg$c76); } } @@ -3136,14 +3230,14 @@ while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c74.test(input.charAt(peg$currPos))) { + if (peg$c75.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c75); + peg$fail(peg$c76); } } } @@ -3153,13 +3247,13 @@ if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { - s3 = peg$c72; + s3 = peg$c73; peg$currPos++; } else { s3 = peg$FAILED; { - peg$fail(peg$c73); + peg$fail(peg$c74); } } @@ -3171,7 +3265,7 @@ } if (s4 !== peg$FAILED) { - s1 = peg$c76(s2, s4); + s1 = peg$c77(s2, s4); s0 = s1; } else { peg$currPos = s0; @@ -3285,7 +3379,7 @@ } if (s3 !== peg$FAILED) { - s1 = peg$c77(s2, s3); + s1 = peg$c78(s2, s3); s0 = s1; } else { peg$currPos = s0; @@ -3319,14 +3413,14 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c78) { - s1 = peg$c78; + if (input.substr(peg$currPos, 5) === peg$c79) { + s1 = peg$c79; peg$currPos += 5; } else { s1 = peg$FAILED; { - peg$fail(peg$c79); + peg$fail(peg$c80); } } @@ -3341,18 +3435,18 @@ if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c80(s3); + s1 = peg$c81(s3); s0 = s1; } else { peg$currPos = s0; @@ -3394,14 +3488,14 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c81) { - s1 = peg$c81; + if (input.substr(peg$currPos, 9) === peg$c82) { + s1 = peg$c82; peg$currPos += 9; } else { s1 = peg$FAILED; { - peg$fail(peg$c82); + peg$fail(peg$c83); } } @@ -3416,18 +3510,18 @@ if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c83(s3); + s1 = peg$c84(s3); s0 = s1; } else { peg$currPos = s0; @@ -3469,14 +3563,14 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c84) { - s1 = peg$c84; + if (input.substr(peg$currPos, 5) === peg$c85) { + s1 = peg$c85; peg$currPos += 5; } else { s1 = peg$FAILED; { - peg$fail(peg$c85); + peg$fail(peg$c86); } } @@ -3491,18 +3585,18 @@ if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c86(s3); + s1 = peg$c87(s3); s0 = s1; } else { peg$currPos = s0; @@ -3544,19 +3638,19 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 12) === peg$c87) { - s1 = peg$c87; + if (input.substr(peg$currPos, 12) === peg$c88) { + s1 = peg$c88; peg$currPos += 12; } else { s1 = peg$FAILED; { - peg$fail(peg$c88); + peg$fail(peg$c89); } } if (s1 !== peg$FAILED) { - s1 = peg$c89(); + s1 = peg$c90(); } s0 = s1; @@ -3579,19 +3673,19 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 11) === peg$c91) { + s1 = peg$c91; peg$currPos += 11; } else { s1 = peg$FAILED; { - peg$fail(peg$c91); + peg$fail(peg$c92); } } if (s1 !== peg$FAILED) { - s1 = peg$c92(); + s1 = peg$c93(); } s0 = s1; @@ -3614,14 +3708,14 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c93) { - s1 = peg$c93; + if (input.substr(peg$currPos, 11) === peg$c94) { + s1 = peg$c94; peg$currPos += 11; } else { s1 = peg$FAILED; { - peg$fail(peg$c94); + peg$fail(peg$c95); } } @@ -3631,14 +3725,14 @@ if (s2 !== peg$FAILED) { s3 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } @@ -3646,14 +3740,14 @@ while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -3666,18 +3760,18 @@ if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c95(s3); + s1 = peg$c96(s3); s0 = s1; } else { peg$currPos = s0; @@ -3719,14 +3813,14 @@ s0 = peg$currPos; - if (input.substr(peg$currPos, 16) === peg$c96) { - s1 = peg$c96; + if (input.substr(peg$currPos, 16) === peg$c97) { + s1 = peg$c97; peg$currPos += 16; } else { s1 = peg$FAILED; { - peg$fail(peg$c97); + peg$fail(peg$c98); } } @@ -3736,14 +3830,14 @@ if (s2 !== peg$FAILED) { s3 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } @@ -3751,14 +3845,14 @@ while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; { - peg$fail(peg$c60); + peg$fail(peg$c61); } } } @@ -3771,18 +3865,18 @@ if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; { - peg$fail(peg$c68); + peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { - s1 = peg$c98(s3); + s1 = peg$c99(s3); s0 = s1; } else { peg$currPos = s0; @@ -3825,73 +3919,73 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 58) { - s1 = peg$c99; + s1 = peg$c100; peg$currPos++; } else { s1 = peg$FAILED; { - peg$fail(peg$c100); + peg$fail(peg$c101); } } if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c101) { + if (input.substr(peg$currPos, 9).toLowerCase() === peg$c102) { s2 = input.substr(peg$currPos, 9); peg$currPos += 9; } else { s2 = peg$FAILED; { - peg$fail(peg$c102); + peg$fail(peg$c103); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) { + if (input.substr(peg$currPos, 10).toLowerCase() === peg$c104) { s2 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s2 = peg$FAILED; { - peg$fail(peg$c104); + peg$fail(peg$c105); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c105) { + if (input.substr(peg$currPos, 11).toLowerCase() === peg$c106) { s2 = input.substr(peg$currPos, 11); peg$currPos += 11; } else { s2 = peg$FAILED; { - peg$fail(peg$c106); + peg$fail(peg$c107); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c107) { + if (input.substr(peg$currPos, 8).toLowerCase() === peg$c108) { s2 = input.substr(peg$currPos, 8); peg$currPos += 8; } else { s2 = peg$FAILED; { - peg$fail(peg$c108); + peg$fail(peg$c109); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c109) { + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c110) { s2 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s2 = peg$FAILED; { - peg$fail(peg$c110); + peg$fail(peg$c111); } } } @@ -3900,7 +3994,7 @@ } if (s2 !== peg$FAILED) { - s1 = peg$c111(s2); + s1 = peg$c112(s2); s0 = s1; } else { peg$currPos = s0; @@ -4026,12 +4120,23 @@ function getPath(obj, key) { var keys = key.split('.'); - for (var i = 0; i < keys.length; i++) { - if (obj == null) { - return obj; - } + var _iterator = _createForOfIteratorHelper(keys), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _key = _step.value; + + if (obj == null) { + return obj; + } - obj = obj[keys[i]]; + obj = obj[_key]; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); } return obj; @@ -4059,10 +4164,21 @@ var remainingPath = path.slice(1); if (Array.isArray(field)) { - for (var i = 0, l = field.length; i < l; ++i) { - if (inPath(node, field[i], remainingPath)) { - return true; + var _iterator2 = _createForOfIteratorHelper(field), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var component = _step2.value; + + if (inPath(node, component, remainingPath)) { + return true; + } } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } return false; @@ -4071,18 +4187,31 @@ } } /** + * @callback TraverseOptionFallback + * @param {external:AST} node The given node. + * @returns {string[]} An array of visitor keys for the given node. + */ + + /** + * @typedef {object} ESQueryOptions + * @property { { [nodeType: string]: string[] } } [visitorKeys] By passing `visitorKeys` mapping, we can extend the properties of the nodes that traverse the node. + * @property {TraverseOptionFallback} [fallback] By passing `fallback` option, we can control the properties of traversing nodes when encountering unknown nodes. + */ + + /** * Given a `node` and its ancestors, determine if `node` is matched * by `selector`. * @param {?external:AST} node * @param {?SelectorAST} selector * @param {external:AST[]} [ancestry=[]] + * @param {ESQueryOptions} [options] * @throws {Error} Unknowns (operator, class name, selector type, or * selector value type) * @returns {boolean} */ - function matches(node, selector, ancestry) { + function matches(node, selector, ancestry, options) { if (!selector) { return true; } @@ -4110,28 +4239,61 @@ } case 'matches': - for (var i = 0, l = selector.selectors.length; i < l; ++i) { - if (matches(node, selector.selectors[i], ancestry)) { - return true; + var _iterator3 = _createForOfIteratorHelper(selector.selectors), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var sel = _step3.value; + + if (matches(node, sel, ancestry, options)) { + return true; + } } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); } return false; case 'compound': - for (var _i = 0, _l = selector.selectors.length; _i < _l; ++_i) { - if (!matches(node, selector.selectors[_i], ancestry)) { - return false; + var _iterator4 = _createForOfIteratorHelper(selector.selectors), + _step4; + + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var _sel = _step4.value; + + if (!matches(node, _sel, ancestry, options)) { + return false; + } } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); } return true; case 'not': - for (var _i2 = 0, _l2 = selector.selectors.length; _i2 < _l2; ++_i2) { - if (matches(node, selector.selectors[_i2], ancestry)) { - return false; + var _iterator5 = _createForOfIteratorHelper(selector.selectors), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _sel2 = _step5.value; + + if (matches(node, _sel2, ancestry, options)) { + return false; + } } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); } return true; @@ -4141,27 +4303,38 @@ var _ret = function () { var collector = []; - var _loop = function _loop(_i3, _l3) { - var a = []; - estraverse.traverse(node, { - enter: function enter(node, parent) { - if (parent != null) { - a.unshift(parent); - } - - if (matches(node, selector.selectors[_i3], a)) { - collector.push(node); - } - }, - leave: function leave() { - a.shift(); - }, - fallback: 'iteration' - }); - }; + var _iterator6 = _createForOfIteratorHelper(selector.selectors), + _step6; + + try { + var _loop = function _loop() { + var sel = _step6.value; + var a = []; + estraverse.traverse(node, { + enter: function enter(node, parent) { + if (parent != null) { + a.unshift(parent); + } - for (var _i3 = 0, _l3 = selector.selectors.length; _i3 < _l3; ++_i3) { - _loop(_i3); + if (matches(node, sel, a, options)) { + collector.push(node); + } + }, + leave: function leave() { + a.shift(); + }, + keys: options && options.visitorKeys, + fallback: options && options.fallback || 'iteration' + }); + }; + + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + _loop(); + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); } return { @@ -4173,16 +4346,16 @@ } case 'child': - if (matches(node, selector.right, ancestry)) { - return matches(ancestry[0], selector.left, ancestry.slice(1)); + if (matches(node, selector.right, ancestry, options)) { + return matches(ancestry[0], selector.left, ancestry.slice(1), options); } return false; case 'descendant': - if (matches(node, selector.right, ancestry)) { - for (var _i4 = 0, _l4 = ancestry.length; _i4 < _l4; ++_i4) { - if (matches(ancestry[_i4], selector.left, ancestry.slice(_i4 + 1))) { + if (matches(node, selector.right, ancestry, options)) { + for (var i = 0, l = ancestry.length; i < l; ++i) { + if (matches(ancestry[i], selector.left, ancestry.slice(i + 1), options)) { return true; } } @@ -4243,20 +4416,20 @@ } case 'sibling': - return matches(node, selector.right, ancestry) && sibling(node, selector.left, ancestry, LEFT_SIDE) || selector.left.subject && matches(node, selector.left, ancestry) && sibling(node, selector.right, ancestry, RIGHT_SIDE); + return matches(node, selector.right, ancestry, options) && sibling(node, selector.left, ancestry, LEFT_SIDE, options) || selector.left.subject && matches(node, selector.left, ancestry, options) && sibling(node, selector.right, ancestry, RIGHT_SIDE, options); case 'adjacent': - return matches(node, selector.right, ancestry) && adjacent(node, selector.left, ancestry, LEFT_SIDE) || selector.right.subject && matches(node, selector.left, ancestry) && adjacent(node, selector.right, ancestry, RIGHT_SIDE); + return matches(node, selector.right, ancestry, options) && adjacent(node, selector.left, ancestry, LEFT_SIDE, options) || selector.right.subject && matches(node, selector.left, ancestry, options) && adjacent(node, selector.right, ancestry, RIGHT_SIDE, options); case 'nth-child': - return matches(node, selector.right, ancestry) && nthChild(node, ancestry, function () { + return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function () { return selector.index.value - 1; - }); + }, options); case 'nth-last-child': - return matches(node, selector.right, ancestry) && nthChild(node, ancestry, function (length) { + return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function (length) { return length - selector.index.value; - }); + }, options); case 'class': switch (selector.name.toLowerCase()) { @@ -4284,17 +4457,56 @@ throw new Error("Unknown selector type: ".concat(selector.type)); } /** + * Get visitor keys of a given node. + * @param {external:AST} node The AST node to get keys. + * @param {ESQueryOptions|undefined} options + * @returns {string[]} Visitor keys of the node. + */ + + + function getVisitorKeys(node, options) { + var nodeType = node.type; + + if (options && options.visitorKeys && options.visitorKeys[nodeType]) { + return options.visitorKeys[nodeType]; + } + + if (estraverse.VisitorKeys[nodeType]) { + return estraverse.VisitorKeys[nodeType]; + } + + if (options && typeof options.fallback === 'function') { + return options.fallback(node); + } // 'iteration' fallback + + + return Object.keys(node).filter(function (key) { + return key !== 'type'; + }); + } + /** + * Check whether the given value is an ASTNode or not. + * @param {any} node The value to check. + * @returns {boolean} `true` if the value is an ASTNode. + */ + + + function isNode(node) { + return node !== null && _typeof(node) === 'object' && typeof node.type === 'string'; + } + /** * Determines if the given node has a sibling that matches the * given selector. * @param {external:AST} node * @param {SelectorSequenceAST} selector * @param {external:AST[]} ancestry * @param {Side} side + * @param {ESQueryOptions|undefined} options * @returns {boolean} */ - function sibling(node, selector, ancestry, side) { + function sibling(node, selector, ancestry, side, options) { var _ancestry = _slicedToArray(ancestry, 1), parent = _ancestry[0]; @@ -4302,35 +4514,45 @@ return false; } - var keys = estraverse.VisitorKeys[parent.type]; + var keys = getVisitorKeys(parent, options); - for (var i = 0, l = keys.length; i < l; ++i) { - var listProp = parent[keys[i]]; + var _iterator7 = _createForOfIteratorHelper(keys), + _step7; - if (Array.isArray(listProp)) { - var startIndex = listProp.indexOf(node); + try { + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var key = _step7.value; + var listProp = parent[key]; - if (startIndex < 0) { - continue; - } + if (Array.isArray(listProp)) { + var startIndex = listProp.indexOf(node); - var lowerBound = void 0, - upperBound = void 0; + if (startIndex < 0) { + continue; + } - if (side === LEFT_SIDE) { - lowerBound = 0; - upperBound = startIndex; - } else { - lowerBound = startIndex + 1; - upperBound = listProp.length; - } + var lowerBound = void 0, + upperBound = void 0; - for (var k = lowerBound; k < upperBound; ++k) { - if (matches(listProp[k], selector, ancestry)) { - return true; + if (side === LEFT_SIDE) { + lowerBound = 0; + upperBound = startIndex; + } else { + lowerBound = startIndex + 1; + upperBound = listProp.length; + } + + for (var k = lowerBound; k < upperBound; ++k) { + if (isNode(listProp[k]) && matches(listProp[k], selector, ancestry, options)) { + return true; + } } } } + } catch (err) { + _iterator7.e(err); + } finally { + _iterator7.f(); } return false; @@ -4342,11 +4564,12 @@ * @param {SelectorSequenceAST} selector * @param {external:AST[]} ancestry * @param {Side} side + * @param {ESQueryOptions|undefined} options * @returns {boolean} */ - function adjacent(node, selector, ancestry, side) { + function adjacent(node, selector, ancestry, side, options) { var _ancestry2 = _slicedToArray(ancestry, 1), parent = _ancestry2[0]; @@ -4354,26 +4577,36 @@ return false; } - var keys = estraverse.VisitorKeys[parent.type]; + var keys = getVisitorKeys(parent, options); - for (var i = 0, l = keys.length; i < l; ++i) { - var listProp = parent[keys[i]]; + var _iterator8 = _createForOfIteratorHelper(keys), + _step8; - if (Array.isArray(listProp)) { - var idx = listProp.indexOf(node); + try { + for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { + var key = _step8.value; + var listProp = parent[key]; - if (idx < 0) { - continue; - } + if (Array.isArray(listProp)) { + var idx = listProp.indexOf(node); - if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) { - return true; - } + if (idx < 0) { + continue; + } - if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) { - return true; + if (side === LEFT_SIDE && idx > 0 && isNode(listProp[idx - 1]) && matches(listProp[idx - 1], selector, ancestry, options)) { + return true; + } + + if (side === RIGHT_SIDE && idx < listProp.length - 1 && isNode(listProp[idx + 1]) && matches(listProp[idx + 1], selector, ancestry, options)) { + return true; + } } } + } catch (err) { + _iterator8.e(err); + } finally { + _iterator8.f(); } return false; @@ -4390,11 +4623,12 @@ * @param {external:AST} node * @param {external:AST[]} ancestry * @param {IndexFunction} idxFn + * @param {ESQueryOptions|undefined} options * @returns {boolean} */ - function nthChild(node, ancestry, idxFn) { + function nthChild(node, ancestry, idxFn, options) { var _ancestry3 = _slicedToArray(ancestry, 1), parent = _ancestry3[0]; @@ -4402,18 +4636,28 @@ return false; } - var keys = estraverse.VisitorKeys[parent.type]; + var keys = getVisitorKeys(parent, options); - for (var i = 0, l = keys.length; i < l; ++i) { - var listProp = parent[keys[i]]; + var _iterator9 = _createForOfIteratorHelper(keys), + _step9; - if (Array.isArray(listProp)) { - var idx = listProp.indexOf(node); + try { + for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { + var key = _step9.value; + var listProp = parent[key]; - if (idx >= 0 && idx === idxFn(listProp.length)) { - return true; + if (Array.isArray(listProp)) { + var idx = listProp.indexOf(node); + + if (idx >= 0 && idx === idxFn(listProp.length)) { + return true; + } } } + } catch (err) { + _iterator9.e(err); + } finally { + _iterator9.f(); } return false; @@ -4438,8 +4682,8 @@ var results = selector.subject ? [ancestor] : []; - for (var _i5 = 0, _Object$entries = _objectEntries(selector); _i5 < _Object$entries.length; _i5++) { - var _Object$entries$_i = _slicedToArray(_Object$entries[_i5], 2), + for (var _i = 0, _Object$entries = _objectEntries(selector); _i < _Object$entries.length; _i++) { + var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), p = _Object$entries$_i[0], sel = _Object$entries$_i[1]; @@ -4461,11 +4705,12 @@ * @param {external:AST} ast * @param {?SelectorAST} selector * @param {TraverseVisitor} visitor + * @param {ESQueryOptions} [options] * @returns {external:AST[]} */ - function traverse(ast, selector, visitor) { + function traverse(ast, selector, visitor, options) { if (!selector) { return; } @@ -4478,17 +4723,17 @@ ancestry.unshift(parent); } - if (matches(node, selector, ancestry)) { + if (matches(node, selector, ancestry, options)) { if (altSubjects.length) { for (var i = 0, l = altSubjects.length; i < l; ++i) { - if (matches(node, altSubjects[i], ancestry)) { + if (matches(node, altSubjects[i], ancestry, options)) { visitor(node, parent, ancestry); } for (var k = 0, m = ancestry.length; k < m; ++k) { var succeedingAncestry = ancestry.slice(k + 1); - if (matches(ancestry[k], altSubjects[i], succeedingAncestry)) { + if (matches(ancestry[k], altSubjects[i], succeedingAncestry, options)) { visitor(ancestry[k], parent, succeedingAncestry); } } @@ -4501,7 +4746,8 @@ leave: function leave() { ancestry.shift(); }, - fallback: 'iteration' + keys: options && options.visitorKeys, + fallback: options && options.fallback || 'iteration' }); } /** @@ -4509,15 +4755,16 @@ * match the selector. * @param {external:AST} ast * @param {?SelectorAST} selector + * @param {ESQueryOptions} [options] * @returns {external:AST[]} */ - function match(ast, selector) { + function match(ast, selector, options) { var results = []; traverse(ast, selector, function (node) { results.push(node); - }); + }, options); return results; } /** @@ -4534,12 +4781,13 @@ * Query the code AST using the selector string. * @param {external:AST} ast * @param {string} selector + * @param {ESQueryOptions} [options] * @returns {external:AST[]} */ - function query(ast, selector) { - return match(ast, parse(selector)); + function query(ast, selector, options) { + return match(ast, parse(selector), options); } query.parse = parse; diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.lite.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.lite.js new file mode 100644 index 0000000000..8a181abec8 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.lite.js @@ -0,0 +1,3995 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('estraverse')) : + typeof define === 'function' && define.amd ? define(['estraverse'], factory) : + (global = global || self, global.esquery = factory(global.estraverse)); +}(this, (function (estraverse) { 'use strict'; + + estraverse = estraverse && Object.prototype.hasOwnProperty.call(estraverse, 'default') ? estraverse['default'] : estraverse; + + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + + function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); + } + + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + + function _iterableToArrayLimit(arr, i) { + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; + } + + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it; + + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { + if (it) o = it; + var i = 0; + + var F = function () {}; + + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = o[Symbol.iterator](); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; + } + + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + var parser = createCommonjsModule(function (module) { + /* + * Generated by PEG.js 0.10.0. + * + * http://pegjs.org/ + */ + (function (root, factory) { + if ( module.exports) { + module.exports = factory(); + } + })(commonjsGlobal, function () { + + function peg$subclass(child, parent) { + function ctor() { + this.constructor = child; + } + + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function peg$SyntaxError(message, expected, found, location) { + this.message = message; + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; + + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } + } + + peg$subclass(peg$SyntaxError, Error); + + peg$SyntaxError.buildMessage = function (expected, found) { + var DESCRIBE_EXPECTATION_FNS = { + literal: function literal(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, + "class": function _class(expectation) { + var escapedParts = "", + i; + + for (i = 0; i < expectation.parts.length; i++) { + escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); + } + + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, + any: function any(expectation) { + return "any character"; + }, + end: function end(expectation) { + return "end of input"; + }, + other: function other(expectation) { + return expectation.description; + } + }; + + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } + + function literalEscape(s) { + return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { + return '\\x' + hex(ch); + }); + } + + function classEscape(s) { + return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) { + return '\\x0' + hex(ch); + }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { + return '\\x' + hex(ch); + }); + } + + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } + + function describeExpected(expected) { + var descriptions = new Array(expected.length), + i, + j; + + for (i = 0; i < expected.length; i++) { + descriptions[i] = describeExpectation(expected[i]); + } + + descriptions.sort(); + + if (descriptions.length > 0) { + for (i = 1, j = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } + } + + descriptions.length = j; + } + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; + } + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + }; + + function peg$parse(input, options) { + options = options !== void 0 ? options : {}; + + var peg$FAILED = {}, + peg$startRuleFunctions = { + start: peg$parsestart + }, + peg$startRuleFunction = peg$parsestart, + peg$c0 = function peg$c0(ss) { + return ss.length === 1 ? ss[0] : { + type: 'matches', + selectors: ss + }; + }, + peg$c1 = function peg$c1() { + return void 0; + }, + peg$c2 = " ", + peg$c3 = peg$literalExpectation(" ", false), + peg$c4 = /^[^ [\],():#!=><~+.]/, + peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false), + peg$c6 = function peg$c6(i) { + return i.join(''); + }, + peg$c7 = ">", + peg$c8 = peg$literalExpectation(">", false), + peg$c9 = function peg$c9() { + return 'child'; + }, + peg$c10 = "~", + peg$c11 = peg$literalExpectation("~", false), + peg$c12 = function peg$c12() { + return 'sibling'; + }, + peg$c13 = "+", + peg$c14 = peg$literalExpectation("+", false), + peg$c15 = function peg$c15() { + return 'adjacent'; + }, + peg$c16 = function peg$c16() { + return 'descendant'; + }, + peg$c17 = ",", + peg$c18 = peg$literalExpectation(",", false), + peg$c19 = function peg$c19(s, ss) { + return [s].concat(ss.map(function (s) { + return s[3]; + })); + }, + peg$c20 = function peg$c20(a, ops) { + return ops.reduce(function (memo, rhs) { + return { + type: rhs[0], + left: memo, + right: rhs[1] + }; + }, a); + }, + peg$c21 = "!", + peg$c22 = peg$literalExpectation("!", false), + peg$c23 = function peg$c23(subject, as) { + var b = as.length === 1 ? as[0] : { + type: 'compound', + selectors: as + }; + if (subject) b.subject = true; + return b; + }, + peg$c24 = "*", + peg$c25 = peg$literalExpectation("*", false), + peg$c26 = function peg$c26(a) { + return { + type: 'wildcard', + value: a + }; + }, + peg$c27 = "#", + peg$c28 = peg$literalExpectation("#", false), + peg$c29 = function peg$c29(i) { + return { + type: 'identifier', + value: i + }; + }, + peg$c30 = "[", + peg$c31 = peg$literalExpectation("[", false), + peg$c32 = "]", + peg$c33 = peg$literalExpectation("]", false), + peg$c34 = function peg$c34(v) { + return v; + }, + peg$c35 = /^[><!]/, + peg$c36 = peg$classExpectation([">", "<", "!"], false, false), + peg$c37 = "=", + peg$c38 = peg$literalExpectation("=", false), + peg$c39 = function peg$c39(a) { + return (a || '') + '='; + }, + peg$c40 = /^[><]/, + peg$c41 = peg$classExpectation([">", "<"], false, false), + peg$c42 = ".", + peg$c43 = peg$literalExpectation(".", false), + peg$c44 = function peg$c44(a, as) { + return [].concat.apply([a], as).join(''); + }, + peg$c45 = function peg$c45(name, op, value) { + return { + type: 'attribute', + name: name, + operator: op, + value: value + }; + }, + peg$c46 = function peg$c46(name) { + return { + type: 'attribute', + name: name + }; + }, + peg$c47 = "\"", + peg$c48 = peg$literalExpectation("\"", false), + peg$c49 = /^[^\\"]/, + peg$c50 = peg$classExpectation(["\\", "\""], true, false), + peg$c51 = "\\", + peg$c52 = peg$literalExpectation("\\", false), + peg$c53 = peg$anyExpectation(), + peg$c54 = function peg$c54(a, b) { + return a + b; + }, + peg$c55 = function peg$c55(d) { + return { + type: 'literal', + value: strUnescape(d.join('')) + }; + }, + peg$c56 = "'", + peg$c57 = peg$literalExpectation("'", false), + peg$c58 = /^[^\\']/, + peg$c59 = peg$classExpectation(["\\", "'"], true, false), + peg$c60 = /^[0-9]/, + peg$c61 = peg$classExpectation([["0", "9"]], false, false), + peg$c62 = function peg$c62(a, b) { + // Can use `a.flat().join('')` once supported + var leadingDecimals = a ? [].concat.apply([], a).join('') : ''; + return { + type: 'literal', + value: parseFloat(leadingDecimals + b.join('')) + }; + }, + peg$c63 = function peg$c63(i) { + return { + type: 'literal', + value: i + }; + }, + peg$c64 = "type(", + peg$c65 = peg$literalExpectation("type(", false), + peg$c66 = /^[^ )]/, + peg$c67 = peg$classExpectation([" ", ")"], true, false), + peg$c68 = ")", + peg$c69 = peg$literalExpectation(")", false), + peg$c70 = function peg$c70(t) { + return { + type: 'type', + value: t.join('') + }; + }, + peg$c71 = /^[imsu]/, + peg$c72 = peg$classExpectation(["i", "m", "s", "u"], false, false), + peg$c73 = "/", + peg$c74 = peg$literalExpectation("/", false), + peg$c75 = /^[^\/]/, + peg$c76 = peg$classExpectation(["/"], true, false), + peg$c77 = function peg$c77(d, flgs) { + return { + type: 'regexp', + value: new RegExp(d.join(''), flgs ? flgs.join('') : '') + }; + }, + peg$c78 = function peg$c78(i, is) { + return { + type: 'field', + name: is.reduce(function (memo, p) { + return memo + p[0] + p[1]; + }, i) + }; + }, + peg$c79 = ":not(", + peg$c80 = peg$literalExpectation(":not(", false), + peg$c81 = function peg$c81(ss) { + return { + type: 'not', + selectors: ss + }; + }, + peg$c82 = ":matches(", + peg$c83 = peg$literalExpectation(":matches(", false), + peg$c84 = function peg$c84(ss) { + return { + type: 'matches', + selectors: ss + }; + }, + peg$c85 = ":has(", + peg$c86 = peg$literalExpectation(":has(", false), + peg$c87 = function peg$c87(ss) { + return { + type: 'has', + selectors: ss + }; + }, + peg$c88 = ":first-child", + peg$c89 = peg$literalExpectation(":first-child", false), + peg$c90 = function peg$c90() { + return nth(1); + }, + peg$c91 = ":last-child", + peg$c92 = peg$literalExpectation(":last-child", false), + peg$c93 = function peg$c93() { + return nthLast(1); + }, + peg$c94 = ":nth-child(", + peg$c95 = peg$literalExpectation(":nth-child(", false), + peg$c96 = function peg$c96(n) { + return nth(parseInt(n.join(''), 10)); + }, + peg$c97 = ":nth-last-child(", + peg$c98 = peg$literalExpectation(":nth-last-child(", false), + peg$c99 = function peg$c99(n) { + return nthLast(parseInt(n.join(''), 10)); + }, + peg$c100 = ":", + peg$c101 = peg$literalExpectation(":", false), + peg$c102 = "statement", + peg$c103 = peg$literalExpectation("statement", true), + peg$c104 = "expression", + peg$c105 = peg$literalExpectation("expression", true), + peg$c106 = "declaration", + peg$c107 = peg$literalExpectation("declaration", true), + peg$c108 = "function", + peg$c109 = peg$literalExpectation("function", true), + peg$c110 = "pattern", + peg$c111 = peg$literalExpectation("pattern", true), + peg$c112 = function peg$c112(c) { + return { + type: 'class', + name: c + }; + }, + peg$currPos = 0, + peg$posDetailsCache = [{ + line: 1, + column: 1 + }], + peg$maxFailPos = 0, + peg$maxFailExpected = [], + peg$resultsCache = {}, + peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function peg$literalExpectation(text, ignoreCase) { + return { + type: "literal", + text: text, + ignoreCase: ignoreCase + }; + } + + function peg$classExpectation(parts, inverted, ignoreCase) { + return { + type: "class", + parts: parts, + inverted: inverted, + ignoreCase: ignoreCase + }; + } + + function peg$anyExpectation() { + return { + type: "any" + }; + } + + function peg$endExpectation() { + return { + type: "end" + }; + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos], + p; + + if (details) { + return details; + } else { + p = pos - 1; + + while (!peg$posDetailsCache[p]) { + p--; + } + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; + } else { + details.column++; + } + + p++; + } + + peg$posDetailsCache[pos] = details; + return details; + } + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos), + endPosDetails = peg$computePosDetails(endPos); + return { + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } + }; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { + return; + } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location); + } + + function peg$parsestart() { + var s0, s1, s2, s3; + var key = peg$currPos * 30 + 0, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parse_(); + + if (s1 !== peg$FAILED) { + s2 = peg$parseselectors(); + + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + + if (s3 !== peg$FAILED) { + s1 = peg$c0(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + + if (s1 !== peg$FAILED) { + s1 = peg$c1(); + } + + s0 = s1; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parse_() { + var s0, s1; + var key = peg$currPos * 30 + 1, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = []; + + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c2; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c3); + } + } + + while (s1 !== peg$FAILED) { + s0.push(s1); + + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c2; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c3); + } + } + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseidentifierName() { + var s0, s1, s2; + var key = peg$currPos * 30 + 2, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = []; + + if (peg$c4.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c5); + } + } + + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + + if (peg$c4.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c5); + } + } + } + } else { + s1 = peg$FAILED; + } + + if (s1 !== peg$FAILED) { + s1 = peg$c6(s1); + } + + s0 = s1; + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsebinaryOp() { + var s0, s1, s2, s3; + var key = peg$currPos * 30 + 3, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parse_(); + + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 62) { + s2 = peg$c7; + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c8); + } + } + + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + + if (s3 !== peg$FAILED) { + s1 = peg$c9(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 126) { + s2 = peg$c10; + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c11); + } + } + + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + + if (s3 !== peg$FAILED) { + s1 = peg$c12(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s2 = peg$c13; + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c14); + } + } + + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + + if (s3 !== peg$FAILED) { + s1 = peg$c15(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c2; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c3); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s1 = peg$c16(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + } + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseselectors() { + var s0, s1, s2, s3, s4, s5, s6, s7; + var key = peg$currPos * 30 + 4, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parseselector(); + + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s5 = peg$c17; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c18); + } + } + + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + + if (s6 !== peg$FAILED) { + s7 = peg$parseselector(); + + if (s7 !== peg$FAILED) { + s4 = [s4, s5, s6, s7]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s5 = peg$c17; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c18); + } + } + + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + + if (s6 !== peg$FAILED) { + s7 = peg$parseselector(); + + if (s7 !== peg$FAILED) { + s4 = [s4, s5, s6, s7]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + + if (s2 !== peg$FAILED) { + s1 = peg$c19(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseselector() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 5, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parsesequence(); + + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$parsebinaryOp(); + + if (s4 !== peg$FAILED) { + s5 = peg$parsesequence(); + + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$parsebinaryOp(); + + if (s4 !== peg$FAILED) { + s5 = peg$parsesequence(); + + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + + if (s2 !== peg$FAILED) { + s1 = peg$c20(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsesequence() { + var s0, s1, s2, s3; + var key = peg$currPos * 30 + 6, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 33) { + s1 = peg$c21; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c22); + } + } + + if (s1 === peg$FAILED) { + s1 = null; + } + + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseatom(); + + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseatom(); + } + } else { + s2 = peg$FAILED; + } + + if (s2 !== peg$FAILED) { + s1 = peg$c23(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseatom() { + var s0; + var key = peg$currPos * 30 + 7, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$parsewildcard(); + + if (s0 === peg$FAILED) { + s0 = peg$parseidentifier(); + + if (s0 === peg$FAILED) { + s0 = peg$parseattr(); + + if (s0 === peg$FAILED) { + s0 = peg$parsefield(); + + if (s0 === peg$FAILED) { + s0 = peg$parsenegation(); + + if (s0 === peg$FAILED) { + s0 = peg$parsematches(); + + if (s0 === peg$FAILED) { + s0 = peg$parsehas(); + + if (s0 === peg$FAILED) { + s0 = peg$parsefirstChild(); + + if (s0 === peg$FAILED) { + s0 = peg$parselastChild(); + + if (s0 === peg$FAILED) { + s0 = peg$parsenthChild(); + + if (s0 === peg$FAILED) { + s0 = peg$parsenthLastChild(); + + if (s0 === peg$FAILED) { + s0 = peg$parseclass(); + } + } + } + } + } + } + } + } + } + } + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsewildcard() { + var s0, s1; + var key = peg$currPos * 30 + 8, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 42) { + s1 = peg$c24; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c25); + } + } + + if (s1 !== peg$FAILED) { + s1 = peg$c26(s1); + } + + s0 = s1; + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseidentifier() { + var s0, s1, s2; + var key = peg$currPos * 30 + 9, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 35) { + s1 = peg$c27; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c28); + } + } + + if (s1 === peg$FAILED) { + s1 = null; + } + + if (s1 !== peg$FAILED) { + s2 = peg$parseidentifierName(); + + if (s2 !== peg$FAILED) { + s1 = peg$c29(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseattr() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 10, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 91) { + s1 = peg$c30; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c31); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = peg$parseattrValue(); + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s5 = peg$c32; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c33); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c34(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseattrOps() { + var s0, s1, s2; + var key = peg$currPos * 30 + 11, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (peg$c35.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c36); + } + } + + if (s1 === peg$FAILED) { + s1 = null; + } + + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s2 = peg$c37; + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c38); + } + } + + if (s2 !== peg$FAILED) { + s1 = peg$c39(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + if (peg$c40.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + + { + peg$fail(peg$c41); + } + } + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseattrEqOps() { + var s0, s1, s2; + var key = peg$currPos * 30 + 12, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 33) { + s1 = peg$c21; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c22); + } + } + + if (s1 === peg$FAILED) { + s1 = null; + } + + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s2 = peg$c37; + peg$currPos++; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c38); + } + } + + if (s2 !== peg$FAILED) { + s1 = peg$c39(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseattrName() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 13, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parseidentifierName(); + + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c42; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c43); + } + } + + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); + + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c42; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c43); + } + } + + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); + + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + + if (s2 !== peg$FAILED) { + s1 = peg$c44(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseattrValue() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 14, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parseattrName(); + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = peg$parseattrEqOps(); + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + s5 = peg$parsetype(); + + if (s5 === peg$FAILED) { + s5 = peg$parseregex(); + } + + if (s5 !== peg$FAILED) { + s1 = peg$c45(s1, s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseattrName(); + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = peg$parseattrOps(); + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + s5 = peg$parsestring(); + + if (s5 === peg$FAILED) { + s5 = peg$parsenumber(); + + if (s5 === peg$FAILED) { + s5 = peg$parsepath(); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c45(s1, s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseattrName(); + + if (s1 !== peg$FAILED) { + s1 = peg$c46(s1); + } + + s0 = s1; + } + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsestring() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 15, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c47; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c48); + } + } + + if (s1 !== peg$FAILED) { + s2 = []; + + if (peg$c49.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c50); + } + } + + if (s3 === peg$FAILED) { + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 92) { + s4 = peg$c51; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c52); + } + } + + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c53); + } + } + + if (s5 !== peg$FAILED) { + s4 = peg$c54(s4, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + + while (s3 !== peg$FAILED) { + s2.push(s3); + + if (peg$c49.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c50); + } + } + + if (s3 === peg$FAILED) { + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 92) { + s4 = peg$c51; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c52); + } + } + + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c53); + } + } + + if (s5 !== peg$FAILED) { + s4 = peg$c54(s4, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c47; + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c48); + } + } + + if (s3 !== peg$FAILED) { + s1 = peg$c55(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + if (s0 === peg$FAILED) { + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c56; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c57); + } + } + + if (s1 !== peg$FAILED) { + s2 = []; + + if (peg$c58.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c59); + } + } + + if (s3 === peg$FAILED) { + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 92) { + s4 = peg$c51; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c52); + } + } + + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c53); + } + } + + if (s5 !== peg$FAILED) { + s4 = peg$c54(s4, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + + while (s3 !== peg$FAILED) { + s2.push(s3); + + if (peg$c58.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c59); + } + } + + if (s3 === peg$FAILED) { + s3 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 92) { + s4 = peg$c51; + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c52); + } + } + + if (s4 !== peg$FAILED) { + if (input.length > peg$currPos) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c53); + } + } + + if (s5 !== peg$FAILED) { + s4 = peg$c54(s4, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } + + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c56; + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c57); + } + } + + if (s3 !== peg$FAILED) { + s1 = peg$c55(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsenumber() { + var s0, s1, s2, s3; + var key = peg$currPos * 30 + 16, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$currPos; + s2 = []; + + if (peg$c60.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + + while (s3 !== peg$FAILED) { + s2.push(s3); + + if (peg$c60.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + } + + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c42; + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c43); + } + } + + if (s3 !== peg$FAILED) { + s2 = [s2, s3]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + + if (s1 === peg$FAILED) { + s1 = null; + } + + if (s1 !== peg$FAILED) { + s2 = []; + + if (peg$c60.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + + if (peg$c60.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + } + } else { + s2 = peg$FAILED; + } + + if (s2 !== peg$FAILED) { + s1 = peg$c62(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsepath() { + var s0, s1; + var key = peg$currPos * 30 + 17, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + s1 = peg$parseidentifierName(); + + if (s1 !== peg$FAILED) { + s1 = peg$c63(s1); + } + + s0 = s1; + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsetype() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 18, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 5) === peg$c64) { + s1 = peg$c64; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c65); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = []; + + if (peg$c66.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c67); + } + } + + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + + if (peg$c66.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c67); + } + } + } + } else { + s3 = peg$FAILED; + } + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c68; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c69); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c70(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseflags() { + var s0, s1; + var key = peg$currPos * 30 + 19, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = []; + + if (peg$c71.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c72); + } + } + + if (s1 !== peg$FAILED) { + while (s1 !== peg$FAILED) { + s0.push(s1); + + if (peg$c71.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c72); + } + } + } + } else { + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseregex() { + var s0, s1, s2, s3, s4; + var key = peg$currPos * 30 + 20, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 47) { + s1 = peg$c73; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c74); + } + } + + if (s1 !== peg$FAILED) { + s2 = []; + + if (peg$c75.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c76); + } + } + + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + + if (peg$c75.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c76); + } + } + } + } else { + s2 = peg$FAILED; + } + + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s3 = peg$c73; + peg$currPos++; + } else { + s3 = peg$FAILED; + + { + peg$fail(peg$c74); + } + } + + if (s3 !== peg$FAILED) { + s4 = peg$parseflags(); + + if (s4 === peg$FAILED) { + s4 = null; + } + + if (s4 !== peg$FAILED) { + s1 = peg$c77(s2, s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsefield() { + var s0, s1, s2, s3, s4, s5, s6; + var key = peg$currPos * 30 + 21, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s1 = peg$c42; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c43); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parseidentifierName(); + + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s5 = peg$c42; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c43); + } + } + + if (s5 !== peg$FAILED) { + s6 = peg$parseidentifierName(); + + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 46) { + s5 = peg$c42; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c43); + } + } + + if (s5 !== peg$FAILED) { + s6 = peg$parseidentifierName(); + + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } else { + peg$currPos = s4; + s4 = peg$FAILED; + } + } + + if (s3 !== peg$FAILED) { + s1 = peg$c78(s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsenegation() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 22, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 5) === peg$c79) { + s1 = peg$c79; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c80); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = peg$parseselectors(); + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c68; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c69); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c81(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsematches() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 23, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 9) === peg$c82) { + s1 = peg$c82; + peg$currPos += 9; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c83); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = peg$parseselectors(); + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c68; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c69); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c84(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsehas() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 24, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 5) === peg$c85) { + s1 = peg$c85; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c86); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = peg$parseselectors(); + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c68; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c69); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c87(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsefirstChild() { + var s0, s1; + var key = peg$currPos * 30 + 25, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 12) === peg$c88) { + s1 = peg$c88; + peg$currPos += 12; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c89); + } + } + + if (s1 !== peg$FAILED) { + s1 = peg$c90(); + } + + s0 = s1; + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parselastChild() { + var s0, s1; + var key = peg$currPos * 30 + 26, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 11) === peg$c91) { + s1 = peg$c91; + peg$currPos += 11; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c92); + } + } + + if (s1 !== peg$FAILED) { + s1 = peg$c93(); + } + + s0 = s1; + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsenthChild() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 27, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 11) === peg$c94) { + s1 = peg$c94; + peg$currPos += 11; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c95); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = []; + + if (peg$c60.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + + if (peg$c60.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + } + } else { + s3 = peg$FAILED; + } + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c68; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c69); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c96(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parsenthLastChild() { + var s0, s1, s2, s3, s4, s5; + var key = peg$currPos * 30 + 28, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.substr(peg$currPos, 16) === peg$c97) { + s1 = peg$c97; + peg$currPos += 16; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c98); + } + } + + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + + if (s2 !== peg$FAILED) { + s3 = []; + + if (peg$c60.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + + if (peg$c60.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + + { + peg$fail(peg$c61); + } + } + } + } else { + s3 = peg$FAILED; + } + + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c68; + peg$currPos++; + } else { + s5 = peg$FAILED; + + { + peg$fail(peg$c69); + } + } + + if (s5 !== peg$FAILED) { + s1 = peg$c99(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function peg$parseclass() { + var s0, s1, s2; + var key = peg$currPos * 30 + 29, + cached = peg$resultsCache[key]; + + if (cached) { + peg$currPos = cached.nextPos; + return cached.result; + } + + s0 = peg$currPos; + + if (input.charCodeAt(peg$currPos) === 58) { + s1 = peg$c100; + peg$currPos++; + } else { + s1 = peg$FAILED; + + { + peg$fail(peg$c101); + } + } + + if (s1 !== peg$FAILED) { + if (input.substr(peg$currPos, 9).toLowerCase() === peg$c102) { + s2 = input.substr(peg$currPos, 9); + peg$currPos += 9; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c103); + } + } + + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 10).toLowerCase() === peg$c104) { + s2 = input.substr(peg$currPos, 10); + peg$currPos += 10; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c105); + } + } + + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 11).toLowerCase() === peg$c106) { + s2 = input.substr(peg$currPos, 11); + peg$currPos += 11; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c107); + } + } + + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 8).toLowerCase() === peg$c108) { + s2 = input.substr(peg$currPos, 8); + peg$currPos += 8; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c109); + } + } + + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c110) { + s2 = input.substr(peg$currPos, 7); + peg$currPos += 7; + } else { + s2 = peg$FAILED; + + { + peg$fail(peg$c111); + } + } + } + } + } + } + + if (s2 !== peg$FAILED) { + s1 = peg$c112(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + peg$resultsCache[key] = { + nextPos: peg$currPos, + result: s0 + }; + return s0; + } + + function nth(n) { + return { + type: 'nth-child', + index: { + type: 'literal', + value: n + } + }; + } + + function nthLast(n) { + return { + type: 'nth-last-child', + index: { + type: 'literal', + value: n + } + }; + } + + function strUnescape(s) { + return s.replace(/\\(.)/g, function (match, ch) { + switch (ch) { + case 'b': + return '\b'; + + case 'f': + return '\f'; + + case 'n': + return '\n'; + + case 'r': + return '\r'; + + case 't': + return '\t'; + + case 'v': + return '\v'; + + default: + return ch; + } + }); + } + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail(peg$endExpectation()); + } + + throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)); + } + } + + return { + SyntaxError: peg$SyntaxError, + parse: peg$parse + }; + }); + }); + + function _objectEntries(obj) { + var entries = []; + var keys = Object.keys(obj); + + for (var k = 0; k < keys.length; k++) entries.push([keys[k], obj[keys[k]]]); + + return entries; + } + /** + * @typedef {"LEFT_SIDE"|"RIGHT_SIDE"} Side + */ + + var LEFT_SIDE = 'LEFT_SIDE'; + var RIGHT_SIDE = 'RIGHT_SIDE'; + /** + * @external AST + * @see https://esprima.readthedocs.io/en/latest/syntax-tree-format.html + */ + + /** + * One of the rules of `grammar.pegjs` + * @typedef {PlainObject} SelectorAST + * @see grammar.pegjs + */ + + /** + * The `sequence` production of `grammar.pegjs` + * @typedef {PlainObject} SelectorSequenceAST + */ + + /** + * Get the value of a property which may be multiple levels down + * in the object. + * @param {?PlainObject} obj + * @param {string} key + * @returns {undefined|boolean|string|number|external:AST} + */ + + function getPath(obj, key) { + var keys = key.split('.'); + + var _iterator = _createForOfIteratorHelper(keys), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _key = _step.value; + + if (obj == null) { + return obj; + } + + obj = obj[_key]; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return obj; + } + /** + * Determine whether `node` can be reached by following `path`, + * starting at `ancestor`. + * @param {?external:AST} node + * @param {?external:AST} ancestor + * @param {string[]} path + * @returns {boolean} + */ + + + function inPath(node, ancestor, path) { + if (path.length === 0) { + return node === ancestor; + } + + if (ancestor == null) { + return false; + } + + var field = ancestor[path[0]]; + var remainingPath = path.slice(1); + + if (Array.isArray(field)) { + var _iterator2 = _createForOfIteratorHelper(field), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var component = _step2.value; + + if (inPath(node, component, remainingPath)) { + return true; + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + return false; + } else { + return inPath(node, field, remainingPath); + } + } + /** + * @callback TraverseOptionFallback + * @param {external:AST} node The given node. + * @returns {string[]} An array of visitor keys for the given node. + */ + + /** + * @typedef {object} ESQueryOptions + * @property { { [nodeType: string]: string[] } } [visitorKeys] By passing `visitorKeys` mapping, we can extend the properties of the nodes that traverse the node. + * @property {TraverseOptionFallback} [fallback] By passing `fallback` option, we can control the properties of traversing nodes when encountering unknown nodes. + */ + + /** + * Given a `node` and its ancestors, determine if `node` is matched + * by `selector`. + * @param {?external:AST} node + * @param {?SelectorAST} selector + * @param {external:AST[]} [ancestry=[]] + * @param {ESQueryOptions} [options] + * @throws {Error} Unknowns (operator, class name, selector type, or + * selector value type) + * @returns {boolean} + */ + + + function matches(node, selector, ancestry, options) { + if (!selector) { + return true; + } + + if (!node) { + return false; + } + + if (!ancestry) { + ancestry = []; + } + + switch (selector.type) { + case 'wildcard': + return true; + + case 'identifier': + return selector.value.toLowerCase() === node.type.toLowerCase(); + + case 'field': + { + var path = selector.name.split('.'); + var ancestor = ancestry[path.length - 1]; + return inPath(node, ancestor, path); + } + + case 'matches': + var _iterator3 = _createForOfIteratorHelper(selector.selectors), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var sel = _step3.value; + + if (matches(node, sel, ancestry, options)) { + return true; + } + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + + return false; + + case 'compound': + var _iterator4 = _createForOfIteratorHelper(selector.selectors), + _step4; + + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var _sel = _step4.value; + + if (!matches(node, _sel, ancestry, options)) { + return false; + } + } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); + } + + return true; + + case 'not': + var _iterator5 = _createForOfIteratorHelper(selector.selectors), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _sel2 = _step5.value; + + if (matches(node, _sel2, ancestry, options)) { + return false; + } + } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + + return true; + + case 'has': + { + var _ret = function () { + var collector = []; + + var _iterator6 = _createForOfIteratorHelper(selector.selectors), + _step6; + + try { + var _loop = function _loop() { + var sel = _step6.value; + var a = []; + estraverse.traverse(node, { + enter: function enter(node, parent) { + if (parent != null) { + a.unshift(parent); + } + + if (matches(node, sel, a, options)) { + collector.push(node); + } + }, + leave: function leave() { + a.shift(); + }, + keys: options && options.visitorKeys, + fallback: options && options.fallback || 'iteration' + }); + }; + + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + _loop(); + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); + } + + return { + v: collector.length !== 0 + }; + }(); + + if (_typeof(_ret) === "object") return _ret.v; + } + + case 'child': + if (matches(node, selector.right, ancestry, options)) { + return matches(ancestry[0], selector.left, ancestry.slice(1), options); + } + + return false; + + case 'descendant': + if (matches(node, selector.right, ancestry, options)) { + for (var i = 0, l = ancestry.length; i < l; ++i) { + if (matches(ancestry[i], selector.left, ancestry.slice(i + 1), options)) { + return true; + } + } + } + + return false; + + case 'attribute': + { + var p = getPath(node, selector.name); + + switch (selector.operator) { + case void 0: + return p != null; + + case '=': + switch (selector.value.type) { + case 'regexp': + return typeof p === 'string' && selector.value.value.test(p); + + case 'literal': + return "".concat(selector.value.value) === "".concat(p); + + case 'type': + return selector.value.value === _typeof(p); + } + + throw new Error("Unknown selector value type: ".concat(selector.value.type)); + + case '!=': + switch (selector.value.type) { + case 'regexp': + return !selector.value.value.test(p); + + case 'literal': + return "".concat(selector.value.value) !== "".concat(p); + + case 'type': + return selector.value.value !== _typeof(p); + } + + throw new Error("Unknown selector value type: ".concat(selector.value.type)); + + case '<=': + return p <= selector.value.value; + + case '<': + return p < selector.value.value; + + case '>': + return p > selector.value.value; + + case '>=': + return p >= selector.value.value; + } + + throw new Error("Unknown operator: ".concat(selector.operator)); + } + + case 'sibling': + return matches(node, selector.right, ancestry, options) && sibling(node, selector.left, ancestry, LEFT_SIDE, options) || selector.left.subject && matches(node, selector.left, ancestry, options) && sibling(node, selector.right, ancestry, RIGHT_SIDE, options); + + case 'adjacent': + return matches(node, selector.right, ancestry, options) && adjacent(node, selector.left, ancestry, LEFT_SIDE, options) || selector.right.subject && matches(node, selector.left, ancestry, options) && adjacent(node, selector.right, ancestry, RIGHT_SIDE, options); + + case 'nth-child': + return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function () { + return selector.index.value - 1; + }, options); + + case 'nth-last-child': + return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function (length) { + return length - selector.index.value; + }, options); + + case 'class': + switch (selector.name.toLowerCase()) { + case 'statement': + if (node.type.slice(-9) === 'Statement') return true; + // fallthrough: interface Declaration <: Statement { } + + case 'declaration': + return node.type.slice(-11) === 'Declaration'; + + case 'pattern': + if (node.type.slice(-7) === 'Pattern') return true; + // fallthrough: interface Expression <: Node, Pattern { } + + case 'expression': + return node.type.slice(-10) === 'Expression' || node.type.slice(-7) === 'Literal' || node.type === 'Identifier' && (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty') || node.type === 'MetaProperty'; + + case 'function': + return node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression'; + } + + throw new Error("Unknown class name: ".concat(selector.name)); + } + + throw new Error("Unknown selector type: ".concat(selector.type)); + } + /** + * Get visitor keys of a given node. + * @param {external:AST} node The AST node to get keys. + * @param {ESQueryOptions|undefined} options + * @returns {string[]} Visitor keys of the node. + */ + + + function getVisitorKeys(node, options) { + var nodeType = node.type; + + if (options && options.visitorKeys && options.visitorKeys[nodeType]) { + return options.visitorKeys[nodeType]; + } + + if (estraverse.VisitorKeys[nodeType]) { + return estraverse.VisitorKeys[nodeType]; + } + + if (options && typeof options.fallback === 'function') { + return options.fallback(node); + } // 'iteration' fallback + + + return Object.keys(node).filter(function (key) { + return key !== 'type'; + }); + } + /** + * Check whether the given value is an ASTNode or not. + * @param {any} node The value to check. + * @returns {boolean} `true` if the value is an ASTNode. + */ + + + function isNode(node) { + return node !== null && _typeof(node) === 'object' && typeof node.type === 'string'; + } + /** + * Determines if the given node has a sibling that matches the + * given selector. + * @param {external:AST} node + * @param {SelectorSequenceAST} selector + * @param {external:AST[]} ancestry + * @param {Side} side + * @param {ESQueryOptions|undefined} options + * @returns {boolean} + */ + + + function sibling(node, selector, ancestry, side, options) { + var _ancestry = _slicedToArray(ancestry, 1), + parent = _ancestry[0]; + + if (!parent) { + return false; + } + + var keys = getVisitorKeys(parent, options); + + var _iterator7 = _createForOfIteratorHelper(keys), + _step7; + + try { + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var key = _step7.value; + var listProp = parent[key]; + + if (Array.isArray(listProp)) { + var startIndex = listProp.indexOf(node); + + if (startIndex < 0) { + continue; + } + + var lowerBound = void 0, + upperBound = void 0; + + if (side === LEFT_SIDE) { + lowerBound = 0; + upperBound = startIndex; + } else { + lowerBound = startIndex + 1; + upperBound = listProp.length; + } + + for (var k = lowerBound; k < upperBound; ++k) { + if (isNode(listProp[k]) && matches(listProp[k], selector, ancestry, options)) { + return true; + } + } + } + } + } catch (err) { + _iterator7.e(err); + } finally { + _iterator7.f(); + } + + return false; + } + /** + * Determines if the given node has an adjacent sibling that matches + * the given selector. + * @param {external:AST} node + * @param {SelectorSequenceAST} selector + * @param {external:AST[]} ancestry + * @param {Side} side + * @param {ESQueryOptions|undefined} options + * @returns {boolean} + */ + + + function adjacent(node, selector, ancestry, side, options) { + var _ancestry2 = _slicedToArray(ancestry, 1), + parent = _ancestry2[0]; + + if (!parent) { + return false; + } + + var keys = getVisitorKeys(parent, options); + + var _iterator8 = _createForOfIteratorHelper(keys), + _step8; + + try { + for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { + var key = _step8.value; + var listProp = parent[key]; + + if (Array.isArray(listProp)) { + var idx = listProp.indexOf(node); + + if (idx < 0) { + continue; + } + + if (side === LEFT_SIDE && idx > 0 && isNode(listProp[idx - 1]) && matches(listProp[idx - 1], selector, ancestry, options)) { + return true; + } + + if (side === RIGHT_SIDE && idx < listProp.length - 1 && isNode(listProp[idx + 1]) && matches(listProp[idx + 1], selector, ancestry, options)) { + return true; + } + } + } + } catch (err) { + _iterator8.e(err); + } finally { + _iterator8.f(); + } + + return false; + } + /** + * @callback IndexFunction + * @param {Integer} len Containing list's length + * @returns {Integer} + */ + + /** + * Determines if the given node is the nth child, determined by + * `idxFn`, which is given the containing list's length. + * @param {external:AST} node + * @param {external:AST[]} ancestry + * @param {IndexFunction} idxFn + * @param {ESQueryOptions|undefined} options + * @returns {boolean} + */ + + + function nthChild(node, ancestry, idxFn, options) { + var _ancestry3 = _slicedToArray(ancestry, 1), + parent = _ancestry3[0]; + + if (!parent) { + return false; + } + + var keys = getVisitorKeys(parent, options); + + var _iterator9 = _createForOfIteratorHelper(keys), + _step9; + + try { + for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { + var key = _step9.value; + var listProp = parent[key]; + + if (Array.isArray(listProp)) { + var idx = listProp.indexOf(node); + + if (idx >= 0 && idx === idxFn(listProp.length)) { + return true; + } + } + } + } catch (err) { + _iterator9.e(err); + } finally { + _iterator9.f(); + } + + return false; + } + /** + * For each selector node marked as a subject, find the portion of the + * selector that the subject must match. + * @param {SelectorAST} selector + * @param {SelectorAST} [ancestor] Defaults to `selector` + * @returns {SelectorAST[]} + */ + + + function subjects(selector, ancestor) { + if (selector == null || _typeof(selector) != 'object') { + return []; + } + + if (ancestor == null) { + ancestor = selector; + } + + var results = selector.subject ? [ancestor] : []; + + for (var _i = 0, _Object$entries = _objectEntries(selector); _i < _Object$entries.length; _i++) { + var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), + p = _Object$entries$_i[0], + sel = _Object$entries$_i[1]; + + results.push.apply(results, _toConsumableArray(subjects(sel, p === 'left' ? sel : ancestor))); + } + + return results; + } + /** + * @callback TraverseVisitor + * @param {?external:AST} node + * @param {?external:AST} parent + * @param {external:AST[]} ancestry + */ + + /** + * From a JS AST and a selector AST, collect all JS AST nodes that + * match the selector. + * @param {external:AST} ast + * @param {?SelectorAST} selector + * @param {TraverseVisitor} visitor + * @param {ESQueryOptions} [options] + * @returns {external:AST[]} + */ + + + function traverse(ast, selector, visitor, options) { + if (!selector) { + return; + } + + var ancestry = []; + var altSubjects = subjects(selector); + estraverse.traverse(ast, { + enter: function enter(node, parent) { + if (parent != null) { + ancestry.unshift(parent); + } + + if (matches(node, selector, ancestry, options)) { + if (altSubjects.length) { + for (var i = 0, l = altSubjects.length; i < l; ++i) { + if (matches(node, altSubjects[i], ancestry, options)) { + visitor(node, parent, ancestry); + } + + for (var k = 0, m = ancestry.length; k < m; ++k) { + var succeedingAncestry = ancestry.slice(k + 1); + + if (matches(ancestry[k], altSubjects[i], succeedingAncestry, options)) { + visitor(ancestry[k], parent, succeedingAncestry); + } + } + } + } else { + visitor(node, parent, ancestry); + } + } + }, + leave: function leave() { + ancestry.shift(); + }, + keys: options && options.visitorKeys, + fallback: options && options.fallback || 'iteration' + }); + } + /** + * From a JS AST and a selector AST, collect all JS AST nodes that + * match the selector. + * @param {external:AST} ast + * @param {?SelectorAST} selector + * @param {ESQueryOptions} [options] + * @returns {external:AST[]} + */ + + + function match(ast, selector, options) { + var results = []; + traverse(ast, selector, function (node) { + results.push(node); + }, options); + return results; + } + /** + * Parse a selector string and return its AST. + * @param {string} selector + * @returns {SelectorAST} + */ + + + function parse(selector) { + return parser.parse(selector); + } + /** + * Query the code AST using the selector string. + * @param {external:AST} ast + * @param {string} selector + * @param {ESQueryOptions} [options] + * @returns {external:AST[]} + */ + + + function query(ast, selector, options) { + return match(ast, parse(selector), options); + } + + query.parse = parse; + query.match = match; + query.traverse = traverse; + query.matches = matches; + query.query = query; + + return query; + +}))); diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.lite.min.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.lite.min.js new file mode 100644 index 0000000000..70d7b762a9 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.lite.min.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("estraverse")):"function"==typeof define&&define.amd?define(["estraverse"],e):(t=t||self).esquery=e(t.estraverse)}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,a=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(r.push(u.value),!e||r.length!==e);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(a)throw o}}return r}(t,e)||a(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=a(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,s=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,u=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw u}}}}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var s=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){t.exports&&(t.exports=function(){function t(e,r,n,a){this.message=e,this.expected=r,this.found=n,this.location=a,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.buildMessage=function(t,e){var r={literal:function(t){return'"'+a(t.text)+'"'},class:function(t){var e,r="";for(e=0;e<t.parts.length;e++)r+=t.parts[e]instanceof Array?o(t.parts[e][0])+"-"+o(t.parts[e][1]):o(t.parts[e]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function a(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function o(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var e,n,a,o=new Array(t.length);for(e=0;e<t.length;e++)o[e]=(a=t[e],r[a.type](a));if(o.sort(),o.length>0){for(e=1,n=1;e<o.length;e++)o[e-1]!==o[e]&&(o[n]=o[e],n++);o.length=n}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(t)+" but "+function(t){return t?'"'+a(t)+'"':"end of input"}(e)+" found."},{SyntaxError:t,parse:function(e,r){r=void 0!==r?r:{};var n,a,o,u,s={},c={start:bt},i=bt,l=vt(" ",!1),f=/^[^ [\],():#!=><~+.]/,h=dt([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),p=vt(">",!1),y=vt("~",!1),v=vt("+",!1),d=vt(",",!1),A=vt("!",!1),x=vt("*",!1),g=vt("#",!1),b=vt("[",!1),m=vt("]",!1),P=/^[><!]/,w=dt([">","<","!"],!1,!1),C=vt("=",!1),j=function(t){return(t||"")+"="},S=/^[><]/,E=dt([">","<"],!1,!1),I=vt(".",!1),k=function(t,e,r){return{type:"attribute",name:t,operator:e,value:r}},F=vt('"',!1),T=/^[^\\"]/,L=dt(["\\",'"'],!0,!1),O=vt("\\",!1),D={type:"any"},R=function(t,e){return t+e},K=function(t){return{type:"literal",value:(e=t.join(""),e.replace(/\\(.)/g,(function(t,e){switch(e){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return e}})))};var e},U=vt("'",!1),_=/^[^\\']/,M=dt(["\\","'"],!0,!1),q=/^[0-9]/,G=dt([["0","9"]],!1,!1),H=vt("type(",!1),V=/^[^ )]/,$=dt([" ",")"],!0,!1),z=vt(")",!1),B=/^[imsu]/,J=dt(["i","m","s","u"],!1,!1),N=vt("/",!1),Q=/^[^\/]/,W=dt(["/"],!0,!1),X=vt(":not(",!1),Y=vt(":matches(",!1),Z=vt(":has(",!1),tt=vt(":first-child",!1),et=vt(":last-child",!1),rt=vt(":nth-child(",!1),nt=vt(":nth-last-child(",!1),at=vt(":",!1),ot=vt("statement",!0),ut=vt("expression",!0),st=vt("declaration",!0),ct=vt("function",!0),it=vt("pattern",!0),lt=0,ft=[{line:1,column:1}],ht=0,pt=[],yt={};if("startRule"in r){if(!(r.startRule in c))throw new Error("Can't start parsing from rule \""+r.startRule+'".');i=c[r.startRule]}function vt(t,e){return{type:"literal",text:t,ignoreCase:e}}function dt(t,e,r){return{type:"class",parts:t,inverted:e,ignoreCase:r}}function At(t){var r,n=ft[t];if(n)return n;for(r=t-1;!ft[r];)r--;for(n={line:(n=ft[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return ft[t]=n,n}function xt(t,e){var r=At(t),n=At(e);return{start:{offset:t,line:r.line,column:r.column},end:{offset:e,line:n.line,column:n.column}}}function gt(t){lt<ht||(lt>ht&&(ht=lt,pt=[]),pt.push(t))}function bt(){var t,e,r,n,a=30*lt+0,o=yt[a];return o?(lt=o.nextPos,o.result):(t=lt,(e=mt())!==s&&(r=Ct())!==s&&mt()!==s?t=e=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(lt=t,t=s),t===s&&(t=lt,(e=mt())!==s&&(e=void 0),t=e),yt[a]={nextPos:lt,result:t},t)}function mt(){var t,r,n=30*lt+1,a=yt[n];if(a)return lt=a.nextPos,a.result;for(t=[],32===e.charCodeAt(lt)?(r=" ",lt++):(r=s,gt(l));r!==s;)t.push(r),32===e.charCodeAt(lt)?(r=" ",lt++):(r=s,gt(l));return yt[n]={nextPos:lt,result:t},t}function Pt(){var t,r,n,a=30*lt+2,o=yt[a];if(o)return lt=o.nextPos,o.result;if(r=[],f.test(e.charAt(lt))?(n=e.charAt(lt),lt++):(n=s,gt(h)),n!==s)for(;n!==s;)r.push(n),f.test(e.charAt(lt))?(n=e.charAt(lt),lt++):(n=s,gt(h));else r=s;return r!==s&&(r=r.join("")),t=r,yt[a]={nextPos:lt,result:t},t}function wt(){var t,r,n,a=30*lt+3,o=yt[a];return o?(lt=o.nextPos,o.result):(t=lt,(r=mt())!==s?(62===e.charCodeAt(lt)?(n=">",lt++):(n=s,gt(p)),n!==s&&mt()!==s?t=r="child":(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=mt())!==s?(126===e.charCodeAt(lt)?(n="~",lt++):(n=s,gt(y)),n!==s&&mt()!==s?t=r="sibling":(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=mt())!==s?(43===e.charCodeAt(lt)?(n="+",lt++):(n=s,gt(v)),n!==s&&mt()!==s?t=r="adjacent":(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,32===e.charCodeAt(lt)?(r=" ",lt++):(r=s,gt(l)),r!==s&&(n=mt())!==s?t=r="descendant":(lt=t,t=s)))),yt[a]={nextPos:lt,result:t},t)}function Ct(){var t,r,n,a,o,u,c,i,l=30*lt+4,f=yt[l];if(f)return lt=f.nextPos,f.result;if(t=lt,(r=jt())!==s){for(n=[],a=lt,(o=mt())!==s?(44===e.charCodeAt(lt)?(u=",",lt++):(u=s,gt(d)),u!==s&&(c=mt())!==s&&(i=jt())!==s?a=o=[o,u,c,i]:(lt=a,a=s)):(lt=a,a=s);a!==s;)n.push(a),a=lt,(o=mt())!==s?(44===e.charCodeAt(lt)?(u=",",lt++):(u=s,gt(d)),u!==s&&(c=mt())!==s&&(i=jt())!==s?a=o=[o,u,c,i]:(lt=a,a=s)):(lt=a,a=s);n!==s?t=r=[r].concat(n.map((function(t){return t[3]}))):(lt=t,t=s)}else lt=t,t=s;return yt[l]={nextPos:lt,result:t},t}function jt(){var t,e,r,n,a,o,u,c=30*lt+5,i=yt[c];if(i)return lt=i.nextPos,i.result;if(t=lt,(e=St())!==s){for(r=[],n=lt,(a=wt())!==s&&(o=St())!==s?n=a=[a,o]:(lt=n,n=s);n!==s;)r.push(n),n=lt,(a=wt())!==s&&(o=St())!==s?n=a=[a,o]:(lt=n,n=s);r!==s?(u=e,t=e=r.reduce((function(t,e){return{type:e[0],left:t,right:e[1]}}),u)):(lt=t,t=s)}else lt=t,t=s;return yt[c]={nextPos:lt,result:t},t}function St(){var t,r,n,a,o,u,c,i=30*lt+6,l=yt[i];if(l)return lt=l.nextPos,l.result;if(t=lt,33===e.charCodeAt(lt)?(r="!",lt++):(r=s,gt(A)),r===s&&(r=null),r!==s){if(n=[],(a=Et())!==s)for(;a!==s;)n.push(a),a=Et();else n=s;n!==s?(o=r,c=1===(u=n).length?u[0]:{type:"compound",selectors:u},o&&(c.subject=!0),t=r=c):(lt=t,t=s)}else lt=t,t=s;return yt[i]={nextPos:lt,result:t},t}function Et(){var t,r=30*lt+7,n=yt[r];return n?(lt=n.nextPos,n.result):((t=function(){var t,r,n=30*lt+8,a=yt[n];return a?(lt=a.nextPos,a.result):(42===e.charCodeAt(lt)?(r="*",lt++):(r=s,gt(x)),r!==s&&(r={type:"wildcard",value:r}),t=r,yt[n]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,a=30*lt+9,o=yt[a];return o?(lt=o.nextPos,o.result):(t=lt,35===e.charCodeAt(lt)?(r="#",lt++):(r=s,gt(g)),r===s&&(r=null),r!==s&&(n=Pt())!==s?t=r={type:"identifier",value:n}:(lt=t,t=s),yt[a]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,a,o=30*lt+10,u=yt[o];return u?(lt=u.nextPos,u.result):(t=lt,91===e.charCodeAt(lt)?(r="[",lt++):(r=s,gt(b)),r!==s&&mt()!==s&&(n=function(){var t,r,n,a,o=30*lt+14,u=yt[o];return u?(lt=u.nextPos,u.result):(t=lt,(r=It())!==s&&mt()!==s&&(n=function(){var t,r,n,a=30*lt+12,o=yt[a];return o?(lt=o.nextPos,o.result):(t=lt,33===e.charCodeAt(lt)?(r="!",lt++):(r=s,gt(A)),r===s&&(r=null),r!==s?(61===e.charCodeAt(lt)?(n="=",lt++):(n=s,gt(C)),n!==s?(r=j(r),t=r):(lt=t,t=s)):(lt=t,t=s),yt[a]={nextPos:lt,result:t},t)}())!==s&&mt()!==s?((a=function(){var t,r,n,a,o,u=30*lt+18,c=yt[u];if(c)return lt=c.nextPos,c.result;if(t=lt,"type("===e.substr(lt,5)?(r="type(",lt+=5):(r=s,gt(H)),r!==s)if(mt()!==s){if(n=[],V.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt($)),a!==s)for(;a!==s;)n.push(a),V.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt($));else n=s;n!==s&&(a=mt())!==s?(41===e.charCodeAt(lt)?(o=")",lt++):(o=s,gt(z)),o!==s?(r={type:"type",value:n.join("")},t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return yt[u]={nextPos:lt,result:t},t}())===s&&(a=function(){var t,r,n,a,o,u,c=30*lt+20,i=yt[c];if(i)return lt=i.nextPos,i.result;if(t=lt,47===e.charCodeAt(lt)?(r="/",lt++):(r=s,gt(N)),r!==s){if(n=[],Q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(W)),a!==s)for(;a!==s;)n.push(a),Q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(W));else n=s;n!==s?(47===e.charCodeAt(lt)?(a="/",lt++):(a=s,gt(N)),a!==s?((o=function(){var t,r,n=30*lt+19,a=yt[n];if(a)return lt=a.nextPos,a.result;if(t=[],B.test(e.charAt(lt))?(r=e.charAt(lt),lt++):(r=s,gt(J)),r!==s)for(;r!==s;)t.push(r),B.test(e.charAt(lt))?(r=e.charAt(lt),lt++):(r=s,gt(J));else t=s;return yt[n]={nextPos:lt,result:t},t}())===s&&(o=null),o!==s?(u=o,r={type:"regexp",value:new RegExp(n.join(""),u?u.join(""):"")},t=r):(lt=t,t=s)):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;return yt[c]={nextPos:lt,result:t},t}()),a!==s?(r=k(r,n,a),t=r):(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=It())!==s&&mt()!==s&&(n=function(){var t,r,n,a=30*lt+11,o=yt[a];return o?(lt=o.nextPos,o.result):(t=lt,P.test(e.charAt(lt))?(r=e.charAt(lt),lt++):(r=s,gt(w)),r===s&&(r=null),r!==s?(61===e.charCodeAt(lt)?(n="=",lt++):(n=s,gt(C)),n!==s?(r=j(r),t=r):(lt=t,t=s)):(lt=t,t=s),t===s&&(S.test(e.charAt(lt))?(t=e.charAt(lt),lt++):(t=s,gt(E))),yt[a]={nextPos:lt,result:t},t)}())!==s&&mt()!==s?((a=function(){var t,r,n,a,o,u,c=30*lt+15,i=yt[c];if(i)return lt=i.nextPos,i.result;if(t=lt,34===e.charCodeAt(lt)?(r='"',lt++):(r=s,gt(F)),r!==s){for(n=[],T.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(L)),a===s&&(a=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(u=e.charAt(lt),lt++):(u=s,gt(D)),u!==s?(o=R(o,u),a=o):(lt=a,a=s)):(lt=a,a=s));a!==s;)n.push(a),T.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(L)),a===s&&(a=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(u=e.charAt(lt),lt++):(u=s,gt(D)),u!==s?(o=R(o,u),a=o):(lt=a,a=s)):(lt=a,a=s));n!==s?(34===e.charCodeAt(lt)?(a='"',lt++):(a=s,gt(F)),a!==s?(r=K(n),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;if(t===s)if(t=lt,39===e.charCodeAt(lt)?(r="'",lt++):(r=s,gt(U)),r!==s){for(n=[],_.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(M)),a===s&&(a=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(u=e.charAt(lt),lt++):(u=s,gt(D)),u!==s?(o=R(o,u),a=o):(lt=a,a=s)):(lt=a,a=s));a!==s;)n.push(a),_.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(M)),a===s&&(a=lt,92===e.charCodeAt(lt)?(o="\\",lt++):(o=s,gt(O)),o!==s?(e.length>lt?(u=e.charAt(lt),lt++):(u=s,gt(D)),u!==s?(o=R(o,u),a=o):(lt=a,a=s)):(lt=a,a=s));n!==s?(39===e.charCodeAt(lt)?(a="'",lt++):(a=s,gt(U)),a!==s?(r=K(n),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;return yt[c]={nextPos:lt,result:t},t}())===s&&(a=function(){var t,r,n,a,o,u,c,i=30*lt+16,l=yt[i];if(l)return lt=l.nextPos,l.result;for(t=lt,r=lt,n=[],q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G));a!==s;)n.push(a),q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G));if(n!==s?(46===e.charCodeAt(lt)?(a=".",lt++):(a=s,gt(I)),a!==s?r=n=[n,a]:(lt=r,r=s)):(lt=r,r=s),r===s&&(r=null),r!==s){if(n=[],q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G)),a!==s)for(;a!==s;)n.push(a),q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G));else n=s;n!==s?(u=n,c=(o=r)?[].concat.apply([],o).join(""):"",r={type:"literal",value:parseFloat(c+u.join(""))},t=r):(lt=t,t=s)}else lt=t,t=s;return yt[i]={nextPos:lt,result:t},t}())===s&&(a=function(){var t,e,r=30*lt+17,n=yt[r];return n?(lt=n.nextPos,n.result):((e=Pt())!==s&&(e={type:"literal",value:e}),t=e,yt[r]={nextPos:lt,result:t},t)}()),a!==s?(r=k(r,n,a),t=r):(lt=t,t=s)):(lt=t,t=s),t===s&&(t=lt,(r=It())!==s&&(r={type:"attribute",name:r}),t=r)),yt[o]={nextPos:lt,result:t},t)}())!==s&&mt()!==s?(93===e.charCodeAt(lt)?(a="]",lt++):(a=s,gt(m)),a!==s?t=r=n:(lt=t,t=s)):(lt=t,t=s),yt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,a,o,u,c,i,l=30*lt+21,f=yt[l];if(f)return lt=f.nextPos,f.result;if(t=lt,46===e.charCodeAt(lt)?(r=".",lt++):(r=s,gt(I)),r!==s)if((n=Pt())!==s){for(a=[],o=lt,46===e.charCodeAt(lt)?(u=".",lt++):(u=s,gt(I)),u!==s&&(c=Pt())!==s?o=u=[u,c]:(lt=o,o=s);o!==s;)a.push(o),o=lt,46===e.charCodeAt(lt)?(u=".",lt++):(u=s,gt(I)),u!==s&&(c=Pt())!==s?o=u=[u,c]:(lt=o,o=s);a!==s?(i=n,r={type:"field",name:a.reduce((function(t,e){return t+e[0]+e[1]}),i)},t=r):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return yt[l]={nextPos:lt,result:t},t}())===s&&(t=function(){var t,r,n,a,o=30*lt+22,u=yt[o];return u?(lt=u.nextPos,u.result):(t=lt,":not("===e.substr(lt,5)?(r=":not(",lt+=5):(r=s,gt(X)),r!==s&&mt()!==s&&(n=Ct())!==s&&mt()!==s?(41===e.charCodeAt(lt)?(a=")",lt++):(a=s,gt(z)),a!==s?t=r={type:"not",selectors:n}:(lt=t,t=s)):(lt=t,t=s),yt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,a,o=30*lt+23,u=yt[o];return u?(lt=u.nextPos,u.result):(t=lt,":matches("===e.substr(lt,9)?(r=":matches(",lt+=9):(r=s,gt(Y)),r!==s&&mt()!==s&&(n=Ct())!==s&&mt()!==s?(41===e.charCodeAt(lt)?(a=")",lt++):(a=s,gt(z)),a!==s?t=r={type:"matches",selectors:n}:(lt=t,t=s)):(lt=t,t=s),yt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,a,o=30*lt+24,u=yt[o];return u?(lt=u.nextPos,u.result):(t=lt,":has("===e.substr(lt,5)?(r=":has(",lt+=5):(r=s,gt(Z)),r!==s&&mt()!==s&&(n=Ct())!==s&&mt()!==s?(41===e.charCodeAt(lt)?(a=")",lt++):(a=s,gt(z)),a!==s?t=r={type:"has",selectors:n}:(lt=t,t=s)):(lt=t,t=s),yt[o]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n=30*lt+25,a=yt[n];return a?(lt=a.nextPos,a.result):(":first-child"===e.substr(lt,12)?(r=":first-child",lt+=12):(r=s,gt(tt)),r!==s&&(r=kt(1)),t=r,yt[n]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n=30*lt+26,a=yt[n];return a?(lt=a.nextPos,a.result):(":last-child"===e.substr(lt,11)?(r=":last-child",lt+=11):(r=s,gt(et)),r!==s&&(r=Ft(1)),t=r,yt[n]={nextPos:lt,result:t},t)}())===s&&(t=function(){var t,r,n,a,o,u=30*lt+27,c=yt[u];if(c)return lt=c.nextPos,c.result;if(t=lt,":nth-child("===e.substr(lt,11)?(r=":nth-child(",lt+=11):(r=s,gt(rt)),r!==s)if(mt()!==s){if(n=[],q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G)),a!==s)for(;a!==s;)n.push(a),q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G));else n=s;n!==s&&(a=mt())!==s?(41===e.charCodeAt(lt)?(o=")",lt++):(o=s,gt(z)),o!==s?(r=kt(parseInt(n.join(""),10)),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return yt[u]={nextPos:lt,result:t},t}())===s&&(t=function(){var t,r,n,a,o,u=30*lt+28,c=yt[u];if(c)return lt=c.nextPos,c.result;if(t=lt,":nth-last-child("===e.substr(lt,16)?(r=":nth-last-child(",lt+=16):(r=s,gt(nt)),r!==s)if(mt()!==s){if(n=[],q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G)),a!==s)for(;a!==s;)n.push(a),q.test(e.charAt(lt))?(a=e.charAt(lt),lt++):(a=s,gt(G));else n=s;n!==s&&(a=mt())!==s?(41===e.charCodeAt(lt)?(o=")",lt++):(o=s,gt(z)),o!==s?(r=Ft(parseInt(n.join(""),10)),t=r):(lt=t,t=s)):(lt=t,t=s)}else lt=t,t=s;else lt=t,t=s;return yt[u]={nextPos:lt,result:t},t}())===s&&(t=function(){var t,r,n,a=30*lt+29,o=yt[a];return o?(lt=o.nextPos,o.result):(t=lt,58===e.charCodeAt(lt)?(r=":",lt++):(r=s,gt(at)),r!==s?("statement"===e.substr(lt,9).toLowerCase()?(n=e.substr(lt,9),lt+=9):(n=s,gt(ot)),n===s&&("expression"===e.substr(lt,10).toLowerCase()?(n=e.substr(lt,10),lt+=10):(n=s,gt(ut)),n===s&&("declaration"===e.substr(lt,11).toLowerCase()?(n=e.substr(lt,11),lt+=11):(n=s,gt(st)),n===s&&("function"===e.substr(lt,8).toLowerCase()?(n=e.substr(lt,8),lt+=8):(n=s,gt(ct)),n===s&&("pattern"===e.substr(lt,7).toLowerCase()?(n=e.substr(lt,7),lt+=7):(n=s,gt(it)))))),n!==s?t=r={type:"class",name:n}:(lt=t,t=s)):(lt=t,t=s),yt[a]={nextPos:lt,result:t},t)}()),yt[r]={nextPos:lt,result:t},t)}function It(){var t,r,n,a,o,u,c,i,l=30*lt+13,f=yt[l];if(f)return lt=f.nextPos,f.result;if(t=lt,(r=Pt())!==s){for(n=[],a=lt,46===e.charCodeAt(lt)?(o=".",lt++):(o=s,gt(I)),o!==s&&(u=Pt())!==s?a=o=[o,u]:(lt=a,a=s);a!==s;)n.push(a),a=lt,46===e.charCodeAt(lt)?(o=".",lt++):(o=s,gt(I)),o!==s&&(u=Pt())!==s?a=o=[o,u]:(lt=a,a=s);n!==s?(c=r,i=n,t=r=[].concat.apply([c],i).join("")):(lt=t,t=s)}else lt=t,t=s;return yt[l]={nextPos:lt,result:t},t}function kt(t){return{type:"nth-child",index:{type:"literal",value:t}}}function Ft(t){return{type:"nth-last-child",index:{type:"literal",value:t}}}if((n=i())!==s&<===e.length)return n;throw n!==s&<<e.length&>({type:"end"}),a=pt,o=ht<e.length?e.charAt(ht):null,u=ht<e.length?xt(ht,ht+1):xt(ht,ht),new t(t.buildMessage(a,o),a,o,u)}}}())}));function c(r,n,a,o){if(!n)return!0;if(!r)return!1;switch(a||(a=[]),n.type){case"wildcard":return!0;case"identifier":return n.value.toLowerCase()===r.type.toLowerCase();case"field":var s=n.name.split("."),i=a[s.length-1];return function t(e,r,n){if(0===n.length)return e===r;if(null==r)return!1;var a=r[n[0]],o=n.slice(1);if(Array.isArray(a)){var s,c=u(a);try{for(c.s();!(s=c.n()).done;){if(t(e,s.value,o))return!0}}catch(t){c.e(t)}finally{c.f()}return!1}return t(e,a,o)}(r,i,s);case"matches":var l,y=u(n.selectors);try{for(y.s();!(l=y.n()).done;){var v=l.value;if(c(r,v,a,o))return!0}}catch(t){y.e(t)}finally{y.f()}return!1;case"compound":var d,A=u(n.selectors);try{for(A.s();!(d=A.n()).done;){var x=d.value;if(!c(r,x,a,o))return!1}}catch(t){A.e(t)}finally{A.f()}return!0;case"not":var g,b=u(n.selectors);try{for(b.s();!(g=b.n()).done;){var m=g.value;if(c(r,m,a,o))return!1}}catch(t){b.e(t)}finally{b.f()}return!0;case"has":var P=function(){var e,a=[],s=u(n.selectors);try{var i=function(){var n=e.value,u=[];t.traverse(r,{enter:function(t,e){null!=e&&u.unshift(e),c(t,n,u,o)&&a.push(t)},leave:function(){u.shift()},keys:o&&o.visitorKeys,fallback:o&&o.fallback||"iteration"})};for(s.s();!(e=s.n()).done;)i()}catch(t){s.e(t)}finally{s.f()}return{v:0!==a.length}}();if("object"===e(P))return P.v;case"child":return!!c(r,n.right,a,o)&&c(a[0],n.left,a.slice(1),o);case"descendant":if(c(r,n.right,a,o))for(var w=0,C=a.length;w<C;++w)if(c(a[w],n.left,a.slice(w+1),o))return!0;return!1;case"attribute":var j=function(t,e){var r,n=u(e.split("."));try{for(n.s();!(r=n.n()).done;){var a=r.value;if(null==t)return t;t=t[a]}}catch(t){n.e(t)}finally{n.f()}return t}(r,n.name);switch(n.operator){case void 0:return null!=j;case"=":switch(n.value.type){case"regexp":return"string"==typeof j&&n.value.value.test(j);case"literal":return"".concat(n.value.value)==="".concat(j);case"type":return n.value.value===e(j)}throw new Error("Unknown selector value type: ".concat(n.value.type));case"!=":switch(n.value.type){case"regexp":return!n.value.value.test(j);case"literal":return"".concat(n.value.value)!=="".concat(j);case"type":return n.value.value!==e(j)}throw new Error("Unknown selector value type: ".concat(n.value.type));case"<=":return j<=n.value.value;case"<":return j<n.value.value;case">":return j>n.value.value;case">=":return j>=n.value.value}throw new Error("Unknown operator: ".concat(n.operator));case"sibling":return c(r,n.right,a,o)&&f(r,n.left,a,"LEFT_SIDE",o)||n.left.subject&&c(r,n.left,a,o)&&f(r,n.right,a,"RIGHT_SIDE",o);case"adjacent":return c(r,n.right,a,o)&&h(r,n.left,a,"LEFT_SIDE",o)||n.right.subject&&c(r,n.left,a,o)&&h(r,n.right,a,"RIGHT_SIDE",o);case"nth-child":return c(r,n.right,a,o)&&p(r,a,(function(){return n.index.value-1}),o);case"nth-last-child":return c(r,n.right,a,o)&&p(r,a,(function(t){return t-n.index.value}),o);case"class":switch(n.name.toLowerCase()){case"statement":if("Statement"===r.type.slice(-9))return!0;case"declaration":return"Declaration"===r.type.slice(-11);case"pattern":if("Pattern"===r.type.slice(-7))return!0;case"expression":return"Expression"===r.type.slice(-10)||"Literal"===r.type.slice(-7)||"Identifier"===r.type&&(0===a.length||"MetaProperty"!==a[0].type)||"MetaProperty"===r.type;case"function":return"FunctionDeclaration"===r.type||"FunctionExpression"===r.type||"ArrowFunctionExpression"===r.type}throw new Error("Unknown class name: ".concat(n.name))}throw new Error("Unknown selector type: ".concat(n.type))}function i(e,r){var n=e.type;return r&&r.visitorKeys&&r.visitorKeys[n]?r.visitorKeys[n]:t.VisitorKeys[n]?t.VisitorKeys[n]:r&&"function"==typeof r.fallback?r.fallback(e):Object.keys(e).filter((function(t){return"type"!==t}))}function l(t){return null!==t&&"object"===e(t)&&"string"==typeof t.type}function f(t,e,n,a,o){var s=r(n,1)[0];if(!s)return!1;var f,h=u(i(s,o));try{for(h.s();!(f=h.n()).done;){var p=s[f.value];if(Array.isArray(p)){var y=p.indexOf(t);if(y<0)continue;var v=void 0,d=void 0;"LEFT_SIDE"===a?(v=0,d=y):(v=y+1,d=p.length);for(var A=v;A<d;++A)if(l(p[A])&&c(p[A],e,n,o))return!0}}}catch(t){h.e(t)}finally{h.f()}return!1}function h(t,e,n,a,o){var s=r(n,1)[0];if(!s)return!1;var f,h=u(i(s,o));try{for(h.s();!(f=h.n()).done;){var p=s[f.value];if(Array.isArray(p)){var y=p.indexOf(t);if(y<0)continue;if("LEFT_SIDE"===a&&y>0&&l(p[y-1])&&c(p[y-1],e,n,o))return!0;if("RIGHT_SIDE"===a&&y<p.length-1&&l(p[y+1])&&c(p[y+1],e,n,o))return!0}}}catch(t){h.e(t)}finally{h.f()}return!1}function p(t,e,n,a){var o=r(e,1)[0];if(!o)return!1;var s,c=u(i(o,a));try{for(c.s();!(s=c.n()).done;){var l=o[s.value];if(Array.isArray(l)){var f=l.indexOf(t);if(f>=0&&f===n(l.length))return!0}}}catch(t){c.e(t)}finally{c.f()}return!1}function y(t,a){if(null==t||"object"!=e(t))return[];null==a&&(a=t);for(var o=t.subject?[a]:[],u=0,s=function(t){for(var e=[],r=Object.keys(t),n=0;n<r.length;n++)e.push([r[n],t[r[n]]]);return e}(t);u<s.length;u++){var c=r(s[u],2),i=c[0],l=c[1];o.push.apply(o,n(y(l,"left"===i?l:a)))}return o}function v(e,r,n,a){if(r){var o=[],u=y(r);t.traverse(e,{enter:function(t,e){if(null!=e&&o.unshift(e),c(t,r,o,a))if(u.length)for(var s=0,i=u.length;s<i;++s){c(t,u[s],o,a)&&n(t,e,o);for(var l=0,f=o.length;l<f;++l){var h=o.slice(l+1);c(o[l],u[s],h,a)&&n(o[l],e,h)}}else n(t,e,o)},leave:function(){o.shift()},keys:a&&a.visitorKeys,fallback:a&&a.fallback||"iteration"})}}function d(t,e,r){var n=[];return v(t,e,(function(t){n.push(t)}),r),n}function A(t){return s.parse(t)}function x(t,e,r){return d(t,A(e),r)}return x.parse=A,x.match=d,x.traverse=v,x.matches=c,x.query=x,x})); +//# sourceMappingURL=esquery.lite.min.js.map diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js index e0f73217da..279d1c73fe 100644 --- a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js +++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).esquery=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var s,i=e[Symbol.iterator]();!(n=(s=i.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function a(e,t){return e(t={exports:{}},t.exports),t.exports}var s=a((function(e,t){!function e(t){var r,n,o,a,s,i;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function f(){}function p(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function d(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function y(e,t){return(new f).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,o,a;for(n=e.length,o=0;n;)t(e[a=o+(r=n>>>1)])?n=r:(o=a+1,n-=r+1);return o}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},o={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},n={Break:a={},Skip:s={},Remove:i={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},f.prototype.path=function(){var e,t,r,n,o;function a(e,t){if(Array.isArray(t))for(r=0,n=t.length;r<n;++r)e.push(t[r]);else e.push(t)}if(!this.__current.path)return null;for(o=[],e=2,t=this.__leavelist.length;e<t;++e)a(o,this.__leavelist[e].path);return a(o,this.__current.path),o},f.prototype.type=function(){return this.current().type||this.__current.wrap},f.prototype.parents=function(){var e,t,r;for(r=[],e=1,t=this.__leavelist.length;e<t;++e)r.push(this.__leavelist[e].node);return r},f.prototype.current=function(){return this.__current.node},f.prototype.__execute=function(e,t){var r,n;return n=void 0,r=this.__current,this.__current=t,this.__state=null,e&&(n=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,n},f.prototype.notify=function(e){this.__state=e},f.prototype.skip=function(){this.notify(s)},f.prototype.break=function(){this.notify(a)},f.prototype.remove=function(){this.notify(i)},f.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,"iteration"===t.fallback?this.__fallback=Object.keys:"function"==typeof t.fallback&&(this.__fallback=t.fallback),this.__keys=o,t.keys&&(this.__keys=Object.assign(Object.create(this.__keys),t.keys))},f.prototype.traverse=function(e,t){var r,n,o,i,l,u,f,y,m,x,g,v;for(this.__initialize(e,t),v={},r=this.__worklist,n=this.__leavelist,r.push(new c(e,null,null,null)),n.push(new c(null,null,null,null));r.length;)if((o=r.pop())!==v){if(o.node){if(u=this.__execute(t.enter,o),this.__state===a||u===a)return;if(r.push(v),n.push(o),this.__state===s||u===s)continue;if(l=(i=o.node).type||o.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(i)}for(y=x.length;(y-=1)>=0;)if(g=i[f=x[y]])if(Array.isArray(g)){for(m=g.length;(m-=1)>=0;)if(g[m]&&!d(n,g[m])){if(h(l,x[y]))o=new c(g[m],[f,m],"Property",null);else{if(!p(g[m]))continue;o=new c(g[m],[f,m],null,null)}r.push(o)}}else if(p(g)){if(d(n,g))continue;r.push(new c(g,f,null,null))}}}else if(o=n.pop(),u=this.__execute(t.leave,o),this.__state===a||u===a)return},f.prototype.replace=function(e,t){var r,n,o,l,f,d,y,m,x,g,v,A,b;function E(e){var t,n,o,a;if(e.ref.remove())for(n=e.ref.key,a=e.ref.parent,t=r.length;t--;)if((o=r[t]).ref&&o.ref.parent===a){if(o.ref.key<n)break;--o.ref.key}}for(this.__initialize(e,t),v={},r=this.__worklist,n=this.__leavelist,d=new c(e,null,null,new u(A={root:e},"root")),r.push(d),n.push(d);r.length;)if((d=r.pop())!==v){if(void 0!==(f=this.__execute(t.enter,d))&&f!==a&&f!==s&&f!==i&&(d.ref.replace(f),d.node=f),this.__state!==i&&f!==i||(E(d),d.node=null),this.__state===a||f===a)return A.root;if((o=d.node)&&(r.push(v),n.push(d),this.__state!==s&&f!==s)){if(l=o.type||d.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(o)}for(y=x.length;(y-=1)>=0;)if(g=o[b=x[y]])if(Array.isArray(g)){for(m=g.length;(m-=1)>=0;)if(g[m]){if(h(l,x[y]))d=new c(g[m],[b,m],"Property",new u(g,m));else{if(!p(g[m]))continue;d=new c(g[m],[b,m],null,new u(g,m))}r.push(d)}}else p(g)&&r.push(new c(g,b,null,new u(o,b)))}}else if(d=n.pop(),void 0!==(f=this.__execute(t.leave,d))&&f!==a&&f!==s&&f!==i&&d.ref.replace(f),this.__state!==i&&f!==i||E(d),this.__state===a||f===a)return A.root;return A.root},t.Syntax=r,t.traverse=y,t.replace=function(e,t){return(new f).replace(e,t)},t.attachComments=function(e,t,r){var o,a,s,i,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(s=0,a=t.length;s<a;s+=1)(o=l(t[s])).extendedRange=[0,e.range[0]],u.push(o);e.leadingComments=u}return e}for(s=0,a=t.length;s<a;s+=1)u.push(m(l(t[s]),r));return i=0,y(e,{enter:function(e){for(var t;i<u.length&&!((t=u[i]).extendedRange[1]>e.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(i,1)):i+=1;return i===u.length?n.Break:u[i].extendedRange[0]>e.range[1]?n.Skip:void 0}}),i=0,y(e,{leave:function(e){for(var t;i<u.length&&(t=u[i],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),u.splice(i,1)):i+=1;return i===u.length?n.Break:u[i].extendedRange[0]>e.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=o,t.VisitorOption=n,t.Controller=f,t.cloneEnvironment=function(){return e({})},t}(t)})),i=a((function(e){e.exports&&(e.exports=function(){function e(t,r,n,o){this.message=t,this.expected=r,this.found=n,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.buildMessage=function(e,t){var r={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?a(e.parts[t][0])+"-"+a(e.parts[t][1]):a(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function a(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}return"Expected "+function(e){var t,n,o,a=new Array(e.length);for(t=0;t<e.length;t++)a[t]=(o=e[t],r[o.type](o));if(a.sort(),a.length>0){for(t=1,n=1;t<a.length;t++)a[t-1]!==a[t]&&(a[n]=a[t],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){r=void 0!==r?r:{};var n,o,a,s,i={},l={start:be},u=be,c=me(" ",!1),f=/^[^ [\],():#!=><~+.]/,p=xe([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),h=function(e){return e.join("")},d=me(">",!1),y=me("~",!1),m=me("+",!1),x=me(",",!1),g=me("!",!1),v=me("*",!1),A=me("#",!1),b=me("[",!1),E=me("]",!1),S=/^[><!]/,_=xe([">","<","!"],!1,!1),w=me("=",!1),C=function(e){return(e||"")+"="},P=/^[><]/,k=xe([">","<"],!1,!1),D=me(".",!1),I=function(e,t,r){return{type:"attribute",name:e,operator:t,value:r}},j=me('"',!1),F=/^[^\\"]/,T=xe(["\\",'"'],!0,!1),L=me("\\",!1),R={type:"any"},O=function(e,t){return e+t},B=function(e){return{type:"literal",value:(t=e.join(""),t.replace(/\\(.)/g,(function(e,t){switch(t){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return t}})))};var t},M=me("'",!1),U=/^[^\\']/,V=xe(["\\","'"],!0,!1),q=/^[0-9]/,N=xe([["0","9"]],!1,!1),W=me("type(",!1),G=/^[^ )]/,z=xe([" ",")"],!0,!1),K=me(")",!1),H=/^[imsu]/,Y=xe(["i","m","s","u"],!1,!1),$=me("/",!1),J=/^[^\/]/,Q=xe(["/"],!0,!1),X=me(":not(",!1),Z=me(":matches(",!1),ee=me(":has(",!1),te=me(":first-child",!1),re=me(":last-child",!1),ne=me(":nth-child(",!1),oe=me(":nth-last-child(",!1),ae=me(":",!1),se=me("statement",!0),ie=me("expression",!0),le=me("declaration",!0),ue=me("function",!0),ce=me("pattern",!0),fe=0,pe=[{line:1,column:1}],he=0,de=[],ye={};if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function me(e,t){return{type:"literal",text:e,ignoreCase:t}}function xe(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function ge(e){var r,n=pe[e];if(n)return n;for(r=e-1;!pe[r];)r--;for(n={line:(n=pe[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return pe[e]=n,n}function ve(e,t){var r=ge(e),n=ge(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function Ae(e){fe<he||(fe>he&&(he=fe,de=[]),de.push(e))}function be(){var e,t,r,n,o=30*fe+0,a=ye[o];return a?(fe=a.nextPos,a.result):(e=fe,(t=Ee())!==i&&(r=we())!==i&&Ee()!==i?e=t=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(fe=e,e=i),e===i&&(e=fe,(t=Ee())!==i&&(t=void 0),e=t),ye[o]={nextPos:fe,result:e},e)}function Ee(){var e,r,n=30*fe+1,o=ye[n];if(o)return fe=o.nextPos,o.result;for(e=[],32===t.charCodeAt(fe)?(r=" ",fe++):(r=i,Ae(c));r!==i;)e.push(r),32===t.charCodeAt(fe)?(r=" ",fe++):(r=i,Ae(c));return ye[n]={nextPos:fe,result:e},e}function Se(){var e,r,n,o=30*fe+2,a=ye[o];if(a)return fe=a.nextPos,a.result;if(r=[],f.test(t.charAt(fe))?(n=t.charAt(fe),fe++):(n=i,Ae(p)),n!==i)for(;n!==i;)r.push(n),f.test(t.charAt(fe))?(n=t.charAt(fe),fe++):(n=i,Ae(p));else r=i;return r!==i&&(r=h(r)),e=r,ye[o]={nextPos:fe,result:e},e}function _e(){var e,r,n,o=30*fe+3,a=ye[o];return a?(fe=a.nextPos,a.result):(e=fe,(r=Ee())!==i?(62===t.charCodeAt(fe)?(n=">",fe++):(n=i,Ae(d)),n!==i&&Ee()!==i?e=r="child":(fe=e,e=i)):(fe=e,e=i),e===i&&(e=fe,(r=Ee())!==i?(126===t.charCodeAt(fe)?(n="~",fe++):(n=i,Ae(y)),n!==i&&Ee()!==i?e=r="sibling":(fe=e,e=i)):(fe=e,e=i),e===i&&(e=fe,(r=Ee())!==i?(43===t.charCodeAt(fe)?(n="+",fe++):(n=i,Ae(m)),n!==i&&Ee()!==i?e=r="adjacent":(fe=e,e=i)):(fe=e,e=i),e===i&&(e=fe,32===t.charCodeAt(fe)?(r=" ",fe++):(r=i,Ae(c)),r!==i&&(n=Ee())!==i?e=r="descendant":(fe=e,e=i)))),ye[o]={nextPos:fe,result:e},e)}function we(){var e,r,n,o,a,s,l,u,c=30*fe+4,f=ye[c];if(f)return fe=f.nextPos,f.result;if(e=fe,(r=Ce())!==i){for(n=[],o=fe,(a=Ee())!==i?(44===t.charCodeAt(fe)?(s=",",fe++):(s=i,Ae(x)),s!==i&&(l=Ee())!==i&&(u=Ce())!==i?o=a=[a,s,l,u]:(fe=o,o=i)):(fe=o,o=i);o!==i;)n.push(o),o=fe,(a=Ee())!==i?(44===t.charCodeAt(fe)?(s=",",fe++):(s=i,Ae(x)),s!==i&&(l=Ee())!==i&&(u=Ce())!==i?o=a=[a,s,l,u]:(fe=o,o=i)):(fe=o,o=i);n!==i?e=r=[r].concat(n.map((function(e){return e[3]}))):(fe=e,e=i)}else fe=e,e=i;return ye[c]={nextPos:fe,result:e},e}function Ce(){var e,t,r,n,o,a,s,l=30*fe+5,u=ye[l];if(u)return fe=u.nextPos,u.result;if(e=fe,(t=Pe())!==i){for(r=[],n=fe,(o=_e())!==i&&(a=Pe())!==i?n=o=[o,a]:(fe=n,n=i);n!==i;)r.push(n),n=fe,(o=_e())!==i&&(a=Pe())!==i?n=o=[o,a]:(fe=n,n=i);r!==i?(s=t,e=t=r.reduce((function(e,t){return{type:t[0],left:e,right:t[1]}}),s)):(fe=e,e=i)}else fe=e,e=i;return ye[l]={nextPos:fe,result:e},e}function Pe(){var e,r,n,o,a,s,l,u=30*fe+6,c=ye[u];if(c)return fe=c.nextPos,c.result;if(e=fe,33===t.charCodeAt(fe)?(r="!",fe++):(r=i,Ae(g)),r===i&&(r=null),r!==i){if(n=[],(o=ke())!==i)for(;o!==i;)n.push(o),o=ke();else n=i;n!==i?(a=r,l=1===(s=n).length?s[0]:{type:"compound",selectors:s},a&&(l.subject=!0),e=r=l):(fe=e,e=i)}else fe=e,e=i;return ye[u]={nextPos:fe,result:e},e}function ke(){var e,r=30*fe+7,n=ye[r];return n?(fe=n.nextPos,n.result):((e=function(){var e,r,n=30*fe+8,o=ye[n];return o?(fe=o.nextPos,o.result):(42===t.charCodeAt(fe)?(r="*",fe++):(r=i,Ae(v)),r!==i&&(r={type:"wildcard",value:r}),e=r,ye[n]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n,o=30*fe+9,a=ye[o];return a?(fe=a.nextPos,a.result):(e=fe,35===t.charCodeAt(fe)?(r="#",fe++):(r=i,Ae(A)),r===i&&(r=null),r!==i&&(n=Se())!==i?e=r={type:"identifier",value:n}:(fe=e,e=i),ye[o]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a=30*fe+10,s=ye[a];return s?(fe=s.nextPos,s.result):(e=fe,91===t.charCodeAt(fe)?(r="[",fe++):(r=i,Ae(b)),r!==i&&Ee()!==i&&(n=function(){var e,r,n,o,a=30*fe+14,s=ye[a];return s?(fe=s.nextPos,s.result):(e=fe,(r=De())!==i&&Ee()!==i&&(n=function(){var e,r,n,o=30*fe+12,a=ye[o];return a?(fe=a.nextPos,a.result):(e=fe,33===t.charCodeAt(fe)?(r="!",fe++):(r=i,Ae(g)),r===i&&(r=null),r!==i?(61===t.charCodeAt(fe)?(n="=",fe++):(n=i,Ae(w)),n!==i?(r=C(r),e=r):(fe=e,e=i)):(fe=e,e=i),ye[o]={nextPos:fe,result:e},e)}())!==i&&Ee()!==i?((o=function(){var e,r,n,o,a,s=30*fe+18,l=ye[s];if(l)return fe=l.nextPos,l.result;if(e=fe,"type("===t.substr(fe,5)?(r="type(",fe+=5):(r=i,Ae(W)),r!==i)if(Ee()!==i){if(n=[],G.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(z)),o!==i)for(;o!==i;)n.push(o),G.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(z));else n=i;n!==i&&(o=Ee())!==i?(41===t.charCodeAt(fe)?(a=")",fe++):(a=i,Ae(K)),a!==i?(r={type:"type",value:n.join("")},e=r):(fe=e,e=i)):(fe=e,e=i)}else fe=e,e=i;else fe=e,e=i;return ye[s]={nextPos:fe,result:e},e}())===i&&(o=function(){var e,r,n,o,a,s,l=30*fe+20,u=ye[l];if(u)return fe=u.nextPos,u.result;if(e=fe,47===t.charCodeAt(fe)?(r="/",fe++):(r=i,Ae($)),r!==i){if(n=[],J.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(Q)),o!==i)for(;o!==i;)n.push(o),J.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(Q));else n=i;n!==i?(47===t.charCodeAt(fe)?(o="/",fe++):(o=i,Ae($)),o!==i?((a=function(){var e,r,n=30*fe+19,o=ye[n];if(o)return fe=o.nextPos,o.result;if(e=[],H.test(t.charAt(fe))?(r=t.charAt(fe),fe++):(r=i,Ae(Y)),r!==i)for(;r!==i;)e.push(r),H.test(t.charAt(fe))?(r=t.charAt(fe),fe++):(r=i,Ae(Y));else e=i;return ye[n]={nextPos:fe,result:e},e}())===i&&(a=null),a!==i?(s=a,r={type:"regexp",value:new RegExp(n.join(""),s?s.join(""):"")},e=r):(fe=e,e=i)):(fe=e,e=i)):(fe=e,e=i)}else fe=e,e=i;return ye[l]={nextPos:fe,result:e},e}()),o!==i?(r=I(r,n,o),e=r):(fe=e,e=i)):(fe=e,e=i),e===i&&(e=fe,(r=De())!==i&&Ee()!==i&&(n=function(){var e,r,n,o=30*fe+11,a=ye[o];return a?(fe=a.nextPos,a.result):(e=fe,S.test(t.charAt(fe))?(r=t.charAt(fe),fe++):(r=i,Ae(_)),r===i&&(r=null),r!==i?(61===t.charCodeAt(fe)?(n="=",fe++):(n=i,Ae(w)),n!==i?(r=C(r),e=r):(fe=e,e=i)):(fe=e,e=i),e===i&&(P.test(t.charAt(fe))?(e=t.charAt(fe),fe++):(e=i,Ae(k))),ye[o]={nextPos:fe,result:e},e)}())!==i&&Ee()!==i?((o=function(){var e,r,n,o,a,s,l=30*fe+15,u=ye[l];if(u)return fe=u.nextPos,u.result;if(e=fe,34===t.charCodeAt(fe)?(r='"',fe++):(r=i,Ae(j)),r!==i){for(n=[],F.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(T)),o===i&&(o=fe,92===t.charCodeAt(fe)?(a="\\",fe++):(a=i,Ae(L)),a!==i?(t.length>fe?(s=t.charAt(fe),fe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(fe=o,o=i)):(fe=o,o=i));o!==i;)n.push(o),F.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(T)),o===i&&(o=fe,92===t.charCodeAt(fe)?(a="\\",fe++):(a=i,Ae(L)),a!==i?(t.length>fe?(s=t.charAt(fe),fe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(fe=o,o=i)):(fe=o,o=i));n!==i?(34===t.charCodeAt(fe)?(o='"',fe++):(o=i,Ae(j)),o!==i?(r=B(n),e=r):(fe=e,e=i)):(fe=e,e=i)}else fe=e,e=i;if(e===i)if(e=fe,39===t.charCodeAt(fe)?(r="'",fe++):(r=i,Ae(M)),r!==i){for(n=[],U.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(V)),o===i&&(o=fe,92===t.charCodeAt(fe)?(a="\\",fe++):(a=i,Ae(L)),a!==i?(t.length>fe?(s=t.charAt(fe),fe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(fe=o,o=i)):(fe=o,o=i));o!==i;)n.push(o),U.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(V)),o===i&&(o=fe,92===t.charCodeAt(fe)?(a="\\",fe++):(a=i,Ae(L)),a!==i?(t.length>fe?(s=t.charAt(fe),fe++):(s=i,Ae(R)),s!==i?(a=O(a,s),o=a):(fe=o,o=i)):(fe=o,o=i));n!==i?(39===t.charCodeAt(fe)?(o="'",fe++):(o=i,Ae(M)),o!==i?(r=B(n),e=r):(fe=e,e=i)):(fe=e,e=i)}else fe=e,e=i;return ye[l]={nextPos:fe,result:e},e}())===i&&(o=function(){var e,r,n,o,a,s,l,u=30*fe+16,c=ye[u];if(c)return fe=c.nextPos,c.result;for(e=fe,r=fe,n=[],q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N));o!==i;)n.push(o),q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N));if(n!==i?(46===t.charCodeAt(fe)?(o=".",fe++):(o=i,Ae(D)),o!==i?r=n=[n,o]:(fe=r,r=i)):(fe=r,r=i),r===i&&(r=null),r!==i){if(n=[],q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N)),o!==i)for(;o!==i;)n.push(o),q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N));else n=i;n!==i?(s=n,l=(a=r)?[].concat.apply([],a).join(""):"",r={type:"literal",value:parseFloat(l+s.join(""))},e=r):(fe=e,e=i)}else fe=e,e=i;return ye[u]={nextPos:fe,result:e},e}())===i&&(o=function(){var e,t,r=30*fe+17,n=ye[r];return n?(fe=n.nextPos,n.result):((t=Se())!==i&&(t={type:"literal",value:t}),e=t,ye[r]={nextPos:fe,result:e},e)}()),o!==i?(r=I(r,n,o),e=r):(fe=e,e=i)):(fe=e,e=i),e===i&&(e=fe,(r=De())!==i&&(r={type:"attribute",name:r}),e=r)),ye[a]={nextPos:fe,result:e},e)}())!==i&&Ee()!==i?(93===t.charCodeAt(fe)?(o="]",fe++):(o=i,Ae(E)),o!==i?e=r=n:(fe=e,e=i)):(fe=e,e=i),ye[a]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a,s,l,u,c=30*fe+21,f=ye[c];if(f)return fe=f.nextPos,f.result;if(e=fe,46===t.charCodeAt(fe)?(r=".",fe++):(r=i,Ae(D)),r!==i)if((n=Se())!==i){for(o=[],a=fe,46===t.charCodeAt(fe)?(s=".",fe++):(s=i,Ae(D)),s!==i&&(l=Se())!==i?a=s=[s,l]:(fe=a,a=i);a!==i;)o.push(a),a=fe,46===t.charCodeAt(fe)?(s=".",fe++):(s=i,Ae(D)),s!==i&&(l=Se())!==i?a=s=[s,l]:(fe=a,a=i);o!==i?(u=n,r={type:"field",name:o.reduce((function(e,t){return e+t[0]+t[1]}),u)},e=r):(fe=e,e=i)}else fe=e,e=i;else fe=e,e=i;return ye[c]={nextPos:fe,result:e},e}())===i&&(e=function(){var e,r,n,o,a=30*fe+22,s=ye[a];return s?(fe=s.nextPos,s.result):(e=fe,":not("===t.substr(fe,5)?(r=":not(",fe+=5):(r=i,Ae(X)),r!==i&&Ee()!==i&&(n=we())!==i&&Ee()!==i?(41===t.charCodeAt(fe)?(o=")",fe++):(o=i,Ae(K)),o!==i?e=r={type:"not",selectors:n}:(fe=e,e=i)):(fe=e,e=i),ye[a]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a=30*fe+23,s=ye[a];return s?(fe=s.nextPos,s.result):(e=fe,":matches("===t.substr(fe,9)?(r=":matches(",fe+=9):(r=i,Ae(Z)),r!==i&&Ee()!==i&&(n=we())!==i&&Ee()!==i?(41===t.charCodeAt(fe)?(o=")",fe++):(o=i,Ae(K)),o!==i?e=r={type:"matches",selectors:n}:(fe=e,e=i)):(fe=e,e=i),ye[a]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a=30*fe+24,s=ye[a];return s?(fe=s.nextPos,s.result):(e=fe,":has("===t.substr(fe,5)?(r=":has(",fe+=5):(r=i,Ae(ee)),r!==i&&Ee()!==i&&(n=we())!==i&&Ee()!==i?(41===t.charCodeAt(fe)?(o=")",fe++):(o=i,Ae(K)),o!==i?e=r={type:"has",selectors:n}:(fe=e,e=i)):(fe=e,e=i),ye[a]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n=30*fe+25,o=ye[n];return o?(fe=o.nextPos,o.result):(":first-child"===t.substr(fe,12)?(r=":first-child",fe+=12):(r=i,Ae(te)),r!==i&&(r=Ie(1)),e=r,ye[n]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n=30*fe+26,o=ye[n];return o?(fe=o.nextPos,o.result):(":last-child"===t.substr(fe,11)?(r=":last-child",fe+=11):(r=i,Ae(re)),r!==i&&(r=je(1)),e=r,ye[n]={nextPos:fe,result:e},e)}())===i&&(e=function(){var e,r,n,o,a,s=30*fe+27,l=ye[s];if(l)return fe=l.nextPos,l.result;if(e=fe,":nth-child("===t.substr(fe,11)?(r=":nth-child(",fe+=11):(r=i,Ae(ne)),r!==i)if(Ee()!==i){if(n=[],q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N)),o!==i)for(;o!==i;)n.push(o),q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N));else n=i;n!==i&&(o=Ee())!==i?(41===t.charCodeAt(fe)?(a=")",fe++):(a=i,Ae(K)),a!==i?(r=Ie(parseInt(n.join(""),10)),e=r):(fe=e,e=i)):(fe=e,e=i)}else fe=e,e=i;else fe=e,e=i;return ye[s]={nextPos:fe,result:e},e}())===i&&(e=function(){var e,r,n,o,a,s=30*fe+28,l=ye[s];if(l)return fe=l.nextPos,l.result;if(e=fe,":nth-last-child("===t.substr(fe,16)?(r=":nth-last-child(",fe+=16):(r=i,Ae(oe)),r!==i)if(Ee()!==i){if(n=[],q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N)),o!==i)for(;o!==i;)n.push(o),q.test(t.charAt(fe))?(o=t.charAt(fe),fe++):(o=i,Ae(N));else n=i;n!==i&&(o=Ee())!==i?(41===t.charCodeAt(fe)?(a=")",fe++):(a=i,Ae(K)),a!==i?(r=je(parseInt(n.join(""),10)),e=r):(fe=e,e=i)):(fe=e,e=i)}else fe=e,e=i;else fe=e,e=i;return ye[s]={nextPos:fe,result:e},e}())===i&&(e=function(){var e,r,n,o=30*fe+29,a=ye[o];return a?(fe=a.nextPos,a.result):(e=fe,58===t.charCodeAt(fe)?(r=":",fe++):(r=i,Ae(ae)),r!==i?("statement"===t.substr(fe,9).toLowerCase()?(n=t.substr(fe,9),fe+=9):(n=i,Ae(se)),n===i&&("expression"===t.substr(fe,10).toLowerCase()?(n=t.substr(fe,10),fe+=10):(n=i,Ae(ie)),n===i&&("declaration"===t.substr(fe,11).toLowerCase()?(n=t.substr(fe,11),fe+=11):(n=i,Ae(le)),n===i&&("function"===t.substr(fe,8).toLowerCase()?(n=t.substr(fe,8),fe+=8):(n=i,Ae(ue)),n===i&&("pattern"===t.substr(fe,7).toLowerCase()?(n=t.substr(fe,7),fe+=7):(n=i,Ae(ce)))))),n!==i?e=r={type:"class",name:n}:(fe=e,e=i)):(fe=e,e=i),ye[o]={nextPos:fe,result:e},e)}()),ye[r]={nextPos:fe,result:e},e)}function De(){var e,r,n,o=30*fe+13,a=ye[o];if(a)return fe=a.nextPos,a.result;if(r=[],(n=Se())===i&&(46===t.charCodeAt(fe)?(n=".",fe++):(n=i,Ae(D))),n!==i)for(;n!==i;)r.push(n),(n=Se())===i&&(46===t.charCodeAt(fe)?(n=".",fe++):(n=i,Ae(D)));else r=i;return r!==i&&(r=h(r)),e=r,ye[o]={nextPos:fe,result:e},e}function Ie(e){return{type:"nth-child",index:{type:"literal",value:e}}}function je(e){return{type:"nth-last-child",index:{type:"literal",value:e}}}if((n=u())!==i&&fe===t.length)return n;throw n!==i&&fe<t.length&&Ae({type:"end"}),o=de,a=he<t.length?t.charAt(he):null,s=he<t.length?ve(he,he+1):ve(he,he),new e(e.buildMessage(o,a),o,a,s)}}}())}));function l(t,r,n){if(!r)return!0;if(!t)return!1;switch(n||(n=[]),r.type){case"wildcard":return!0;case"identifier":return r.value.toLowerCase()===t.type.toLowerCase();case"field":var o=r.name.split("."),a=n[o.length-1];return function e(t,r,n){if(0===n.length)return t===r;if(null==r)return!1;var o=r[n[0]],a=n.slice(1);if(Array.isArray(o)){for(var s=0,i=o.length;s<i;++s)if(e(t,o[s],a))return!0;return!1}return e(t,o,a)}(t,a,o);case"matches":for(var i=0,p=r.selectors.length;i<p;++i)if(l(t,r.selectors[i],n))return!0;return!1;case"compound":for(var h=0,d=r.selectors.length;h<d;++h)if(!l(t,r.selectors[h],n))return!1;return!0;case"not":for(var y=0,m=r.selectors.length;y<m;++y)if(l(t,r.selectors[y],n))return!1;return!0;case"has":var x=function(){for(var e=[],n=function(n,o){var a=[];s.traverse(t,{enter:function(t,o){null!=o&&a.unshift(o),l(t,r.selectors[n],a)&&e.push(t)},leave:function(){a.shift()},fallback:"iteration"})},o=0,a=r.selectors.length;o<a;++o)n(o);return{v:0!==e.length}}();if("object"===e(x))return x.v;case"child":return!!l(t,r.right,n)&&l(n[0],r.left,n.slice(1));case"descendant":if(l(t,r.right,n))for(var g=0,v=n.length;g<v;++g)if(l(n[g],r.left,n.slice(g+1)))return!0;return!1;case"attribute":var A=function(e,t){for(var r=t.split("."),n=0;n<r.length;n++){if(null==e)return e;e=e[r[n]]}return e}(t,r.name);switch(r.operator){case void 0:return null!=A;case"=":switch(r.value.type){case"regexp":return"string"==typeof A&&r.value.value.test(A);case"literal":return"".concat(r.value.value)==="".concat(A);case"type":return r.value.value===e(A)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"!=":switch(r.value.type){case"regexp":return!r.value.value.test(A);case"literal":return"".concat(r.value.value)!=="".concat(A);case"type":return r.value.value!==e(A)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"<=":return A<=r.value.value;case"<":return A<r.value.value;case">":return A>r.value.value;case">=":return A>=r.value.value}throw new Error("Unknown operator: ".concat(r.operator));case"sibling":return l(t,r.right,n)&&u(t,r.left,n,"LEFT_SIDE")||r.left.subject&&l(t,r.left,n)&&u(t,r.right,n,"RIGHT_SIDE");case"adjacent":return l(t,r.right,n)&&c(t,r.left,n,"LEFT_SIDE")||r.right.subject&&l(t,r.left,n)&&c(t,r.right,n,"RIGHT_SIDE");case"nth-child":return l(t,r.right,n)&&f(t,n,(function(){return r.index.value-1}));case"nth-last-child":return l(t,r.right,n)&&f(t,n,(function(e){return e-r.index.value}));case"class":switch(r.name.toLowerCase()){case"statement":if("Statement"===t.type.slice(-9))return!0;case"declaration":return"Declaration"===t.type.slice(-11);case"pattern":if("Pattern"===t.type.slice(-7))return!0;case"expression":return"Expression"===t.type.slice(-10)||"Literal"===t.type.slice(-7)||"Identifier"===t.type&&(0===n.length||"MetaProperty"!==n[0].type)||"MetaProperty"===t.type;case"function":return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type}throw new Error("Unknown class name: ".concat(r.name))}throw new Error("Unknown selector type: ".concat(r.type))}function u(e,r,n,o){var a=t(n,1)[0];if(!a)return!1;for(var i=s.VisitorKeys[a.type],u=0,c=i.length;u<c;++u){var f=a[i[u]];if(Array.isArray(f)){var p=f.indexOf(e);if(p<0)continue;var h=void 0,d=void 0;"LEFT_SIDE"===o?(h=0,d=p):(h=p+1,d=f.length);for(var y=h;y<d;++y)if(l(f[y],r,n))return!0}}return!1}function c(e,r,n,o){var a=t(n,1)[0];if(!a)return!1;for(var i=s.VisitorKeys[a.type],u=0,c=i.length;u<c;++u){var f=a[i[u]];if(Array.isArray(f)){var p=f.indexOf(e);if(p<0)continue;if("LEFT_SIDE"===o&&p>0&&l(f[p-1],r,n))return!0;if("RIGHT_SIDE"===o&&p<f.length-1&&l(f[p+1],r,n))return!0}}return!1}function f(e,r,n){var o=t(r,1)[0];if(!o)return!1;for(var a=s.VisitorKeys[o.type],i=0,l=a.length;i<l;++i){var u=o[a[i]];if(Array.isArray(u)){var c=u.indexOf(e);if(c>=0&&c===n(u.length))return!0}}return!1}function p(n,o){if(null==n||"object"!=e(n))return[];null==o&&(o=n);for(var a=n.subject?[o]:[],s=0,i=function(e){for(var t=[],r=Object.keys(e),n=0;n<r.length;n++)t.push([r[n],e[r[n]]]);return t}(n);s<i.length;s++){var l=t(i[s],2),u=l[0],c=l[1];a.push.apply(a,r(p(c,"left"===u?c:o)))}return a}function h(e,t,r){if(t){var n=[],o=p(t);s.traverse(e,{enter:function(e,a){if(null!=a&&n.unshift(a),l(e,t,n))if(o.length)for(var s=0,i=o.length;s<i;++s){l(e,o[s],n)&&r(e,a,n);for(var u=0,c=n.length;u<c;++u){var f=n.slice(u+1);l(n[u],o[s],f)&&r(n[u],a,f)}}else r(e,a,n)},leave:function(){n.shift()},fallback:"iteration"})}}function d(e,t){var r=[];return h(e,t,(function(e){r.push(e)})),r}function y(e){return i.parse(e)}function m(e,t){return d(e,y(t))}return m.parse=y,m.match=d,m.traverse=h,m.matches=l,m.query=m,m})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).esquery=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw a}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function a(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){l=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw i}}}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function i(e,t){return e(t={exports:{}},t.exports),t.exports}var s=i((function(e,t){!function e(t){var r,n,o,a,i,s;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function f(){}function p(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function y(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function d(e,t){return(new f).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,o,a;for(n=e.length,o=0;n;)t(e[a=o+(r=n>>>1)])?n=r:(o=a+1,n-=r+1);return o}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},o={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},n={Break:a={},Skip:i={},Remove:s={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},f.prototype.path=function(){var e,t,r,n,o;function a(e,t){if(Array.isArray(t))for(r=0,n=t.length;r<n;++r)e.push(t[r]);else e.push(t)}if(!this.__current.path)return null;for(o=[],e=2,t=this.__leavelist.length;e<t;++e)a(o,this.__leavelist[e].path);return a(o,this.__current.path),o},f.prototype.type=function(){return this.current().type||this.__current.wrap},f.prototype.parents=function(){var e,t,r;for(r=[],e=1,t=this.__leavelist.length;e<t;++e)r.push(this.__leavelist[e].node);return r},f.prototype.current=function(){return this.__current.node},f.prototype.__execute=function(e,t){var r,n;return n=void 0,r=this.__current,this.__current=t,this.__state=null,e&&(n=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,n},f.prototype.notify=function(e){this.__state=e},f.prototype.skip=function(){this.notify(i)},f.prototype.break=function(){this.notify(a)},f.prototype.remove=function(){this.notify(s)},f.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,"iteration"===t.fallback?this.__fallback=Object.keys:"function"==typeof t.fallback&&(this.__fallback=t.fallback),this.__keys=o,t.keys&&(this.__keys=Object.assign(Object.create(this.__keys),t.keys))},f.prototype.traverse=function(e,t){var r,n,o,s,l,u,f,d,m,x,v,g;for(this.__initialize(e,t),g={},r=this.__worklist,n=this.__leavelist,r.push(new c(e,null,null,null)),n.push(new c(null,null,null,null));r.length;)if((o=r.pop())!==g){if(o.node){if(u=this.__execute(t.enter,o),this.__state===a||u===a)return;if(r.push(g),n.push(o),this.__state===i||u===i)continue;if(l=(s=o.node).type||o.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(s)}for(d=x.length;(d-=1)>=0;)if(v=s[f=x[d]])if(Array.isArray(v)){for(m=v.length;(m-=1)>=0;)if(v[m]&&!y(n,v[m])){if(h(l,x[d]))o=new c(v[m],[f,m],"Property",null);else{if(!p(v[m]))continue;o=new c(v[m],[f,m],null,null)}r.push(o)}}else if(p(v)){if(y(n,v))continue;r.push(new c(v,f,null,null))}}}else if(o=n.pop(),u=this.__execute(t.leave,o),this.__state===a||u===a)return},f.prototype.replace=function(e,t){var r,n,o,l,f,y,d,m,x,v,g,b,A;function E(e){var t,n,o,a;if(e.ref.remove())for(n=e.ref.key,a=e.ref.parent,t=r.length;t--;)if((o=r[t]).ref&&o.ref.parent===a){if(o.ref.key<n)break;--o.ref.key}}for(this.__initialize(e,t),g={},r=this.__worklist,n=this.__leavelist,y=new c(e,null,null,new u(b={root:e},"root")),r.push(y),n.push(y);r.length;)if((y=r.pop())!==g){if(void 0!==(f=this.__execute(t.enter,y))&&f!==a&&f!==i&&f!==s&&(y.ref.replace(f),y.node=f),this.__state!==s&&f!==s||(E(y),y.node=null),this.__state===a||f===a)return b.root;if((o=y.node)&&(r.push(g),n.push(y),this.__state!==i&&f!==i)){if(l=o.type||y.wrap,!(x=this.__keys[l])){if(!this.__fallback)throw new Error("Unknown node type "+l+".");x=this.__fallback(o)}for(d=x.length;(d-=1)>=0;)if(v=o[A=x[d]])if(Array.isArray(v)){for(m=v.length;(m-=1)>=0;)if(v[m]){if(h(l,x[d]))y=new c(v[m],[A,m],"Property",new u(v,m));else{if(!p(v[m]))continue;y=new c(v[m],[A,m],null,new u(v,m))}r.push(y)}}else p(v)&&r.push(new c(v,A,null,new u(o,A)))}}else if(y=n.pop(),void 0!==(f=this.__execute(t.leave,y))&&f!==a&&f!==i&&f!==s&&y.ref.replace(f),this.__state!==s&&f!==s||E(y),this.__state===a||f===a)return b.root;return b.root},t.Syntax=r,t.traverse=d,t.replace=function(e,t){return(new f).replace(e,t)},t.attachComments=function(e,t,r){var o,a,i,s,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(i=0,a=t.length;i<a;i+=1)(o=l(t[i])).extendedRange=[0,e.range[0]],u.push(o);e.leadingComments=u}return e}for(i=0,a=t.length;i<a;i+=1)u.push(m(l(t[i]),r));return s=0,d(e,{enter:function(e){for(var t;s<u.length&&!((t=u[s]).extendedRange[1]>e.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(s,1)):s+=1;return s===u.length?n.Break:u[s].extendedRange[0]>e.range[1]?n.Skip:void 0}}),s=0,d(e,{leave:function(e){for(var t;s<u.length&&(t=u[s],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),u.splice(s,1)):s+=1;return s===u.length?n.Break:u[s].extendedRange[0]>e.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=o,t.VisitorOption=n,t.Controller=f,t.cloneEnvironment=function(){return e({})},t}(t)})),l=i((function(e){e.exports&&(e.exports=function(){function e(t,r,n,o){this.message=t,this.expected=r,this.found=n,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.buildMessage=function(e,t){var r={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?a(e.parts[t][0])+"-"+a(e.parts[t][1]):a(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}function a(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(e){return"\\x0"+n(e)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(e){return"\\x"+n(e)}))}return"Expected "+function(e){var t,n,o,a=new Array(e.length);for(t=0;t<e.length;t++)a[t]=(o=e[t],r[o.type](o));if(a.sort(),a.length>0){for(t=1,n=1;t<a.length;t++)a[t-1]!==a[t]&&(a[n]=a[t],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."},{SyntaxError:e,parse:function(t,r){r=void 0!==r?r:{};var n,o,a,i,s={},l={start:be},u=be,c=de(" ",!1),f=/^[^ [\],():#!=><~+.]/,p=me([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),h=de(">",!1),y=de("~",!1),d=de("+",!1),m=de(",",!1),x=de("!",!1),v=de("*",!1),g=de("#",!1),b=de("[",!1),A=de("]",!1),E=/^[><!]/,S=me([">","<","!"],!1,!1),_=de("=",!1),w=function(e){return(e||"")+"="},C=/^[><]/,P=me([">","<"],!1,!1),k=de(".",!1),D=function(e,t,r){return{type:"attribute",name:e,operator:t,value:r}},j=de('"',!1),I=/^[^\\"]/,T=me(["\\",'"'],!0,!1),F=de("\\",!1),L={type:"any"},O=function(e,t){return e+t},R=function(e){return{type:"literal",value:(t=e.join(""),t.replace(/\\(.)/g,(function(e,t){switch(t){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return t}})))};var t},B=de("'",!1),M=/^[^\\']/,U=me(["\\","'"],!0,!1),q=/^[0-9]/,V=me([["0","9"]],!1,!1),N=de("type(",!1),W=/^[^ )]/,K=me([" ",")"],!0,!1),G=de(")",!1),z=/^[imsu]/,H=me(["i","m","s","u"],!1,!1),Y=de("/",!1),$=/^[^\/]/,J=me(["/"],!0,!1),Q=de(":not(",!1),X=de(":matches(",!1),Z=de(":has(",!1),ee=de(":first-child",!1),te=de(":last-child",!1),re=de(":nth-child(",!1),ne=de(":nth-last-child(",!1),oe=de(":",!1),ae=de("statement",!0),ie=de("expression",!0),se=de("declaration",!0),le=de("function",!0),ue=de("pattern",!0),ce=0,fe=[{line:1,column:1}],pe=0,he=[],ye={};if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function de(e,t){return{type:"literal",text:e,ignoreCase:t}}function me(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function xe(e){var r,n=fe[e];if(n)return n;for(r=e-1;!fe[r];)r--;for(n={line:(n=fe[r]).line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return fe[e]=n,n}function ve(e,t){var r=xe(e),n=xe(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function ge(e){ce<pe||(ce>pe&&(pe=ce,he=[]),he.push(e))}function be(){var e,t,r,n,o=30*ce+0,a=ye[o];return a?(ce=a.nextPos,a.result):(e=ce,(t=Ae())!==s&&(r=_e())!==s&&Ae()!==s?e=t=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(ce=e,e=s),e===s&&(e=ce,(t=Ae())!==s&&(t=void 0),e=t),ye[o]={nextPos:ce,result:e},e)}function Ae(){var e,r,n=30*ce+1,o=ye[n];if(o)return ce=o.nextPos,o.result;for(e=[],32===t.charCodeAt(ce)?(r=" ",ce++):(r=s,ge(c));r!==s;)e.push(r),32===t.charCodeAt(ce)?(r=" ",ce++):(r=s,ge(c));return ye[n]={nextPos:ce,result:e},e}function Ee(){var e,r,n,o=30*ce+2,a=ye[o];if(a)return ce=a.nextPos,a.result;if(r=[],f.test(t.charAt(ce))?(n=t.charAt(ce),ce++):(n=s,ge(p)),n!==s)for(;n!==s;)r.push(n),f.test(t.charAt(ce))?(n=t.charAt(ce),ce++):(n=s,ge(p));else r=s;return r!==s&&(r=r.join("")),e=r,ye[o]={nextPos:ce,result:e},e}function Se(){var e,r,n,o=30*ce+3,a=ye[o];return a?(ce=a.nextPos,a.result):(e=ce,(r=Ae())!==s?(62===t.charCodeAt(ce)?(n=">",ce++):(n=s,ge(h)),n!==s&&Ae()!==s?e=r="child":(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=Ae())!==s?(126===t.charCodeAt(ce)?(n="~",ce++):(n=s,ge(y)),n!==s&&Ae()!==s?e=r="sibling":(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=Ae())!==s?(43===t.charCodeAt(ce)?(n="+",ce++):(n=s,ge(d)),n!==s&&Ae()!==s?e=r="adjacent":(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,32===t.charCodeAt(ce)?(r=" ",ce++):(r=s,ge(c)),r!==s&&(n=Ae())!==s?e=r="descendant":(ce=e,e=s)))),ye[o]={nextPos:ce,result:e},e)}function _e(){var e,r,n,o,a,i,l,u,c=30*ce+4,f=ye[c];if(f)return ce=f.nextPos,f.result;if(e=ce,(r=we())!==s){for(n=[],o=ce,(a=Ae())!==s?(44===t.charCodeAt(ce)?(i=",",ce++):(i=s,ge(m)),i!==s&&(l=Ae())!==s&&(u=we())!==s?o=a=[a,i,l,u]:(ce=o,o=s)):(ce=o,o=s);o!==s;)n.push(o),o=ce,(a=Ae())!==s?(44===t.charCodeAt(ce)?(i=",",ce++):(i=s,ge(m)),i!==s&&(l=Ae())!==s&&(u=we())!==s?o=a=[a,i,l,u]:(ce=o,o=s)):(ce=o,o=s);n!==s?e=r=[r].concat(n.map((function(e){return e[3]}))):(ce=e,e=s)}else ce=e,e=s;return ye[c]={nextPos:ce,result:e},e}function we(){var e,t,r,n,o,a,i,l=30*ce+5,u=ye[l];if(u)return ce=u.nextPos,u.result;if(e=ce,(t=Ce())!==s){for(r=[],n=ce,(o=Se())!==s&&(a=Ce())!==s?n=o=[o,a]:(ce=n,n=s);n!==s;)r.push(n),n=ce,(o=Se())!==s&&(a=Ce())!==s?n=o=[o,a]:(ce=n,n=s);r!==s?(i=t,e=t=r.reduce((function(e,t){return{type:t[0],left:e,right:t[1]}}),i)):(ce=e,e=s)}else ce=e,e=s;return ye[l]={nextPos:ce,result:e},e}function Ce(){var e,r,n,o,a,i,l,u=30*ce+6,c=ye[u];if(c)return ce=c.nextPos,c.result;if(e=ce,33===t.charCodeAt(ce)?(r="!",ce++):(r=s,ge(x)),r===s&&(r=null),r!==s){if(n=[],(o=Pe())!==s)for(;o!==s;)n.push(o),o=Pe();else n=s;n!==s?(a=r,l=1===(i=n).length?i[0]:{type:"compound",selectors:i},a&&(l.subject=!0),e=r=l):(ce=e,e=s)}else ce=e,e=s;return ye[u]={nextPos:ce,result:e},e}function Pe(){var e,r=30*ce+7,n=ye[r];return n?(ce=n.nextPos,n.result):((e=function(){var e,r,n=30*ce+8,o=ye[n];return o?(ce=o.nextPos,o.result):(42===t.charCodeAt(ce)?(r="*",ce++):(r=s,ge(v)),r!==s&&(r={type:"wildcard",value:r}),e=r,ye[n]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,o=30*ce+9,a=ye[o];return a?(ce=a.nextPos,a.result):(e=ce,35===t.charCodeAt(ce)?(r="#",ce++):(r=s,ge(g)),r===s&&(r=null),r!==s&&(n=Ee())!==s?e=r={type:"identifier",value:n}:(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,o,a=30*ce+10,i=ye[a];return i?(ce=i.nextPos,i.result):(e=ce,91===t.charCodeAt(ce)?(r="[",ce++):(r=s,ge(b)),r!==s&&Ae()!==s&&(n=function(){var e,r,n,o,a=30*ce+14,i=ye[a];return i?(ce=i.nextPos,i.result):(e=ce,(r=ke())!==s&&Ae()!==s&&(n=function(){var e,r,n,o=30*ce+12,a=ye[o];return a?(ce=a.nextPos,a.result):(e=ce,33===t.charCodeAt(ce)?(r="!",ce++):(r=s,ge(x)),r===s&&(r=null),r!==s?(61===t.charCodeAt(ce)?(n="=",ce++):(n=s,ge(_)),n!==s?(r=w(r),e=r):(ce=e,e=s)):(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}())!==s&&Ae()!==s?((o=function(){var e,r,n,o,a,i=30*ce+18,l=ye[i];if(l)return ce=l.nextPos,l.result;if(e=ce,"type("===t.substr(ce,5)?(r="type(",ce+=5):(r=s,ge(N)),r!==s)if(Ae()!==s){if(n=[],W.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(K)),o!==s)for(;o!==s;)n.push(o),W.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(K));else n=s;n!==s&&(o=Ae())!==s?(41===t.charCodeAt(ce)?(a=")",ce++):(a=s,ge(G)),a!==s?(r={type:"type",value:n.join("")},e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[i]={nextPos:ce,result:e},e}())===s&&(o=function(){var e,r,n,o,a,i,l=30*ce+20,u=ye[l];if(u)return ce=u.nextPos,u.result;if(e=ce,47===t.charCodeAt(ce)?(r="/",ce++):(r=s,ge(Y)),r!==s){if(n=[],$.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(J)),o!==s)for(;o!==s;)n.push(o),$.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(J));else n=s;n!==s?(47===t.charCodeAt(ce)?(o="/",ce++):(o=s,ge(Y)),o!==s?((a=function(){var e,r,n=30*ce+19,o=ye[n];if(o)return ce=o.nextPos,o.result;if(e=[],z.test(t.charAt(ce))?(r=t.charAt(ce),ce++):(r=s,ge(H)),r!==s)for(;r!==s;)e.push(r),z.test(t.charAt(ce))?(r=t.charAt(ce),ce++):(r=s,ge(H));else e=s;return ye[n]={nextPos:ce,result:e},e}())===s&&(a=null),a!==s?(i=a,r={type:"regexp",value:new RegExp(n.join(""),i?i.join(""):"")},e=r):(ce=e,e=s)):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;return ye[l]={nextPos:ce,result:e},e}()),o!==s?(r=D(r,n,o),e=r):(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=ke())!==s&&Ae()!==s&&(n=function(){var e,r,n,o=30*ce+11,a=ye[o];return a?(ce=a.nextPos,a.result):(e=ce,E.test(t.charAt(ce))?(r=t.charAt(ce),ce++):(r=s,ge(S)),r===s&&(r=null),r!==s?(61===t.charCodeAt(ce)?(n="=",ce++):(n=s,ge(_)),n!==s?(r=w(r),e=r):(ce=e,e=s)):(ce=e,e=s),e===s&&(C.test(t.charAt(ce))?(e=t.charAt(ce),ce++):(e=s,ge(P))),ye[o]={nextPos:ce,result:e},e)}())!==s&&Ae()!==s?((o=function(){var e,r,n,o,a,i,l=30*ce+15,u=ye[l];if(u)return ce=u.nextPos,u.result;if(e=ce,34===t.charCodeAt(ce)?(r='"',ce++):(r=s,ge(j)),r!==s){for(n=[],I.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(T)),o===s&&(o=ce,92===t.charCodeAt(ce)?(a="\\",ce++):(a=s,ge(F)),a!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(a=O(a,i),o=a):(ce=o,o=s)):(ce=o,o=s));o!==s;)n.push(o),I.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(T)),o===s&&(o=ce,92===t.charCodeAt(ce)?(a="\\",ce++):(a=s,ge(F)),a!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(a=O(a,i),o=a):(ce=o,o=s)):(ce=o,o=s));n!==s?(34===t.charCodeAt(ce)?(o='"',ce++):(o=s,ge(j)),o!==s?(r=R(n),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;if(e===s)if(e=ce,39===t.charCodeAt(ce)?(r="'",ce++):(r=s,ge(B)),r!==s){for(n=[],M.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(U)),o===s&&(o=ce,92===t.charCodeAt(ce)?(a="\\",ce++):(a=s,ge(F)),a!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(a=O(a,i),o=a):(ce=o,o=s)):(ce=o,o=s));o!==s;)n.push(o),M.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(U)),o===s&&(o=ce,92===t.charCodeAt(ce)?(a="\\",ce++):(a=s,ge(F)),a!==s?(t.length>ce?(i=t.charAt(ce),ce++):(i=s,ge(L)),i!==s?(a=O(a,i),o=a):(ce=o,o=s)):(ce=o,o=s));n!==s?(39===t.charCodeAt(ce)?(o="'",ce++):(o=s,ge(B)),o!==s?(r=R(n),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;return ye[l]={nextPos:ce,result:e},e}())===s&&(o=function(){var e,r,n,o,a,i,l,u=30*ce+16,c=ye[u];if(c)return ce=c.nextPos,c.result;for(e=ce,r=ce,n=[],q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V));o!==s;)n.push(o),q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V));if(n!==s?(46===t.charCodeAt(ce)?(o=".",ce++):(o=s,ge(k)),o!==s?r=n=[n,o]:(ce=r,r=s)):(ce=r,r=s),r===s&&(r=null),r!==s){if(n=[],q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V)),o!==s)for(;o!==s;)n.push(o),q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V));else n=s;n!==s?(i=n,l=(a=r)?[].concat.apply([],a).join(""):"",r={type:"literal",value:parseFloat(l+i.join(""))},e=r):(ce=e,e=s)}else ce=e,e=s;return ye[u]={nextPos:ce,result:e},e}())===s&&(o=function(){var e,t,r=30*ce+17,n=ye[r];return n?(ce=n.nextPos,n.result):((t=Ee())!==s&&(t={type:"literal",value:t}),e=t,ye[r]={nextPos:ce,result:e},e)}()),o!==s?(r=D(r,n,o),e=r):(ce=e,e=s)):(ce=e,e=s),e===s&&(e=ce,(r=ke())!==s&&(r={type:"attribute",name:r}),e=r)),ye[a]={nextPos:ce,result:e},e)}())!==s&&Ae()!==s?(93===t.charCodeAt(ce)?(o="]",ce++):(o=s,ge(A)),o!==s?e=r=n:(ce=e,e=s)):(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,o,a,i,l,u,c=30*ce+21,f=ye[c];if(f)return ce=f.nextPos,f.result;if(e=ce,46===t.charCodeAt(ce)?(r=".",ce++):(r=s,ge(k)),r!==s)if((n=Ee())!==s){for(o=[],a=ce,46===t.charCodeAt(ce)?(i=".",ce++):(i=s,ge(k)),i!==s&&(l=Ee())!==s?a=i=[i,l]:(ce=a,a=s);a!==s;)o.push(a),a=ce,46===t.charCodeAt(ce)?(i=".",ce++):(i=s,ge(k)),i!==s&&(l=Ee())!==s?a=i=[i,l]:(ce=a,a=s);o!==s?(u=n,r={type:"field",name:o.reduce((function(e,t){return e+t[0]+t[1]}),u)},e=r):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[c]={nextPos:ce,result:e},e}())===s&&(e=function(){var e,r,n,o,a=30*ce+22,i=ye[a];return i?(ce=i.nextPos,i.result):(e=ce,":not("===t.substr(ce,5)?(r=":not(",ce+=5):(r=s,ge(Q)),r!==s&&Ae()!==s&&(n=_e())!==s&&Ae()!==s?(41===t.charCodeAt(ce)?(o=")",ce++):(o=s,ge(G)),o!==s?e=r={type:"not",selectors:n}:(ce=e,e=s)):(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,o,a=30*ce+23,i=ye[a];return i?(ce=i.nextPos,i.result):(e=ce,":matches("===t.substr(ce,9)?(r=":matches(",ce+=9):(r=s,ge(X)),r!==s&&Ae()!==s&&(n=_e())!==s&&Ae()!==s?(41===t.charCodeAt(ce)?(o=")",ce++):(o=s,ge(G)),o!==s?e=r={type:"matches",selectors:n}:(ce=e,e=s)):(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,o,a=30*ce+24,i=ye[a];return i?(ce=i.nextPos,i.result):(e=ce,":has("===t.substr(ce,5)?(r=":has(",ce+=5):(r=s,ge(Z)),r!==s&&Ae()!==s&&(n=_e())!==s&&Ae()!==s?(41===t.charCodeAt(ce)?(o=")",ce++):(o=s,ge(G)),o!==s?e=r={type:"has",selectors:n}:(ce=e,e=s)):(ce=e,e=s),ye[a]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n=30*ce+25,o=ye[n];return o?(ce=o.nextPos,o.result):(":first-child"===t.substr(ce,12)?(r=":first-child",ce+=12):(r=s,ge(ee)),r!==s&&(r=De(1)),e=r,ye[n]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n=30*ce+26,o=ye[n];return o?(ce=o.nextPos,o.result):(":last-child"===t.substr(ce,11)?(r=":last-child",ce+=11):(r=s,ge(te)),r!==s&&(r=je(1)),e=r,ye[n]={nextPos:ce,result:e},e)}())===s&&(e=function(){var e,r,n,o,a,i=30*ce+27,l=ye[i];if(l)return ce=l.nextPos,l.result;if(e=ce,":nth-child("===t.substr(ce,11)?(r=":nth-child(",ce+=11):(r=s,ge(re)),r!==s)if(Ae()!==s){if(n=[],q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V)),o!==s)for(;o!==s;)n.push(o),q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V));else n=s;n!==s&&(o=Ae())!==s?(41===t.charCodeAt(ce)?(a=")",ce++):(a=s,ge(G)),a!==s?(r=De(parseInt(n.join(""),10)),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[i]={nextPos:ce,result:e},e}())===s&&(e=function(){var e,r,n,o,a,i=30*ce+28,l=ye[i];if(l)return ce=l.nextPos,l.result;if(e=ce,":nth-last-child("===t.substr(ce,16)?(r=":nth-last-child(",ce+=16):(r=s,ge(ne)),r!==s)if(Ae()!==s){if(n=[],q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V)),o!==s)for(;o!==s;)n.push(o),q.test(t.charAt(ce))?(o=t.charAt(ce),ce++):(o=s,ge(V));else n=s;n!==s&&(o=Ae())!==s?(41===t.charCodeAt(ce)?(a=")",ce++):(a=s,ge(G)),a!==s?(r=je(parseInt(n.join(""),10)),e=r):(ce=e,e=s)):(ce=e,e=s)}else ce=e,e=s;else ce=e,e=s;return ye[i]={nextPos:ce,result:e},e}())===s&&(e=function(){var e,r,n,o=30*ce+29,a=ye[o];return a?(ce=a.nextPos,a.result):(e=ce,58===t.charCodeAt(ce)?(r=":",ce++):(r=s,ge(oe)),r!==s?("statement"===t.substr(ce,9).toLowerCase()?(n=t.substr(ce,9),ce+=9):(n=s,ge(ae)),n===s&&("expression"===t.substr(ce,10).toLowerCase()?(n=t.substr(ce,10),ce+=10):(n=s,ge(ie)),n===s&&("declaration"===t.substr(ce,11).toLowerCase()?(n=t.substr(ce,11),ce+=11):(n=s,ge(se)),n===s&&("function"===t.substr(ce,8).toLowerCase()?(n=t.substr(ce,8),ce+=8):(n=s,ge(le)),n===s&&("pattern"===t.substr(ce,7).toLowerCase()?(n=t.substr(ce,7),ce+=7):(n=s,ge(ue)))))),n!==s?e=r={type:"class",name:n}:(ce=e,e=s)):(ce=e,e=s),ye[o]={nextPos:ce,result:e},e)}()),ye[r]={nextPos:ce,result:e},e)}function ke(){var e,r,n,o,a,i,l,u,c=30*ce+13,f=ye[c];if(f)return ce=f.nextPos,f.result;if(e=ce,(r=Ee())!==s){for(n=[],o=ce,46===t.charCodeAt(ce)?(a=".",ce++):(a=s,ge(k)),a!==s&&(i=Ee())!==s?o=a=[a,i]:(ce=o,o=s);o!==s;)n.push(o),o=ce,46===t.charCodeAt(ce)?(a=".",ce++):(a=s,ge(k)),a!==s&&(i=Ee())!==s?o=a=[a,i]:(ce=o,o=s);n!==s?(l=r,u=n,e=r=[].concat.apply([l],u).join("")):(ce=e,e=s)}else ce=e,e=s;return ye[c]={nextPos:ce,result:e},e}function De(e){return{type:"nth-child",index:{type:"literal",value:e}}}function je(e){return{type:"nth-last-child",index:{type:"literal",value:e}}}if((n=u())!==s&&ce===t.length)return n;throw n!==s&&ce<t.length&&ge({type:"end"}),o=he,a=pe<t.length?t.charAt(pe):null,i=pe<t.length?ve(pe,pe+1):ve(pe,pe),new e(e.buildMessage(o,a),o,a,i)}}}())}));function u(t,r,n,o){if(!r)return!0;if(!t)return!1;switch(n||(n=[]),r.type){case"wildcard":return!0;case"identifier":return r.value.toLowerCase()===t.type.toLowerCase();case"field":var i=r.name.split("."),l=n[i.length-1];return function e(t,r,n){if(0===n.length)return t===r;if(null==r)return!1;var o=r[n[0]],i=n.slice(1);if(Array.isArray(o)){var s,l=a(o);try{for(l.s();!(s=l.n()).done;){if(e(t,s.value,i))return!0}}catch(e){l.e(e)}finally{l.f()}return!1}return e(t,o,i)}(t,l,i);case"matches":var c,f=a(r.selectors);try{for(f.s();!(c=f.n()).done;){var d=c.value;if(u(t,d,n,o))return!0}}catch(e){f.e(e)}finally{f.f()}return!1;case"compound":var m,x=a(r.selectors);try{for(x.s();!(m=x.n()).done;){var v=m.value;if(!u(t,v,n,o))return!1}}catch(e){x.e(e)}finally{x.f()}return!0;case"not":var g,b=a(r.selectors);try{for(b.s();!(g=b.n()).done;){var A=g.value;if(u(t,A,n,o))return!1}}catch(e){b.e(e)}finally{b.f()}return!0;case"has":var E=function(){var e,n=[],i=a(r.selectors);try{var l=function(){var r=e.value,a=[];s.traverse(t,{enter:function(e,t){null!=t&&a.unshift(t),u(e,r,a,o)&&n.push(e)},leave:function(){a.shift()},keys:o&&o.visitorKeys,fallback:o&&o.fallback||"iteration"})};for(i.s();!(e=i.n()).done;)l()}catch(e){i.e(e)}finally{i.f()}return{v:0!==n.length}}();if("object"===e(E))return E.v;case"child":return!!u(t,r.right,n,o)&&u(n[0],r.left,n.slice(1),o);case"descendant":if(u(t,r.right,n,o))for(var S=0,_=n.length;S<_;++S)if(u(n[S],r.left,n.slice(S+1),o))return!0;return!1;case"attribute":var w=function(e,t){var r,n=a(t.split("."));try{for(n.s();!(r=n.n()).done;){var o=r.value;if(null==e)return e;e=e[o]}}catch(e){n.e(e)}finally{n.f()}return e}(t,r.name);switch(r.operator){case void 0:return null!=w;case"=":switch(r.value.type){case"regexp":return"string"==typeof w&&r.value.value.test(w);case"literal":return"".concat(r.value.value)==="".concat(w);case"type":return r.value.value===e(w)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"!=":switch(r.value.type){case"regexp":return!r.value.value.test(w);case"literal":return"".concat(r.value.value)!=="".concat(w);case"type":return r.value.value!==e(w)}throw new Error("Unknown selector value type: ".concat(r.value.type));case"<=":return w<=r.value.value;case"<":return w<r.value.value;case">":return w>r.value.value;case">=":return w>=r.value.value}throw new Error("Unknown operator: ".concat(r.operator));case"sibling":return u(t,r.right,n,o)&&p(t,r.left,n,"LEFT_SIDE",o)||r.left.subject&&u(t,r.left,n,o)&&p(t,r.right,n,"RIGHT_SIDE",o);case"adjacent":return u(t,r.right,n,o)&&h(t,r.left,n,"LEFT_SIDE",o)||r.right.subject&&u(t,r.left,n,o)&&h(t,r.right,n,"RIGHT_SIDE",o);case"nth-child":return u(t,r.right,n,o)&&y(t,n,(function(){return r.index.value-1}),o);case"nth-last-child":return u(t,r.right,n,o)&&y(t,n,(function(e){return e-r.index.value}),o);case"class":switch(r.name.toLowerCase()){case"statement":if("Statement"===t.type.slice(-9))return!0;case"declaration":return"Declaration"===t.type.slice(-11);case"pattern":if("Pattern"===t.type.slice(-7))return!0;case"expression":return"Expression"===t.type.slice(-10)||"Literal"===t.type.slice(-7)||"Identifier"===t.type&&(0===n.length||"MetaProperty"!==n[0].type)||"MetaProperty"===t.type;case"function":return"FunctionDeclaration"===t.type||"FunctionExpression"===t.type||"ArrowFunctionExpression"===t.type}throw new Error("Unknown class name: ".concat(r.name))}throw new Error("Unknown selector type: ".concat(r.type))}function c(e,t){var r=e.type;return t&&t.visitorKeys&&t.visitorKeys[r]?t.visitorKeys[r]:s.VisitorKeys[r]?s.VisitorKeys[r]:t&&"function"==typeof t.fallback?t.fallback(e):Object.keys(e).filter((function(e){return"type"!==e}))}function f(t){return null!==t&&"object"===e(t)&&"string"==typeof t.type}function p(e,r,n,o,i){var s=t(n,1)[0];if(!s)return!1;var l,p=a(c(s,i));try{for(p.s();!(l=p.n()).done;){var h=s[l.value];if(Array.isArray(h)){var y=h.indexOf(e);if(y<0)continue;var d=void 0,m=void 0;"LEFT_SIDE"===o?(d=0,m=y):(d=y+1,m=h.length);for(var x=d;x<m;++x)if(f(h[x])&&u(h[x],r,n,i))return!0}}}catch(e){p.e(e)}finally{p.f()}return!1}function h(e,r,n,o,i){var s=t(n,1)[0];if(!s)return!1;var l,p=a(c(s,i));try{for(p.s();!(l=p.n()).done;){var h=s[l.value];if(Array.isArray(h)){var y=h.indexOf(e);if(y<0)continue;if("LEFT_SIDE"===o&&y>0&&f(h[y-1])&&u(h[y-1],r,n,i))return!0;if("RIGHT_SIDE"===o&&y<h.length-1&&f(h[y+1])&&u(h[y+1],r,n,i))return!0}}}catch(e){p.e(e)}finally{p.f()}return!1}function y(e,r,n,o){var i=t(r,1)[0];if(!i)return!1;var s,l=a(c(i,o));try{for(l.s();!(s=l.n()).done;){var u=i[s.value];if(Array.isArray(u)){var f=u.indexOf(e);if(f>=0&&f===n(u.length))return!0}}}catch(e){l.e(e)}finally{l.f()}return!1}function d(n,o){if(null==n||"object"!=e(n))return[];null==o&&(o=n);for(var a=n.subject?[o]:[],i=0,s=function(e){for(var t=[],r=Object.keys(e),n=0;n<r.length;n++)t.push([r[n],e[r[n]]]);return t}(n);i<s.length;i++){var l=t(s[i],2),u=l[0],c=l[1];a.push.apply(a,r(d(c,"left"===u?c:o)))}return a}function m(e,t,r,n){if(t){var o=[],a=d(t);s.traverse(e,{enter:function(e,i){if(null!=i&&o.unshift(i),u(e,t,o,n))if(a.length)for(var s=0,l=a.length;s<l;++s){u(e,a[s],o,n)&&r(e,i,o);for(var c=0,f=o.length;c<f;++c){var p=o.slice(c+1);u(o[c],a[s],p,n)&&r(o[c],i,p)}}else r(e,i,o)},leave:function(){o.shift()},keys:n&&n.visitorKeys,fallback:n&&n.fallback||"iteration"})}}function x(e,t,r){var n=[];return m(e,t,(function(e){n.push(e)}),r),n}function v(e){return l.parse(e)}function g(e,t,r){return x(e,v(t),r)}return g.parse=v,g.match=x,g.traverse=m,g.matches=u,g.query=g,g})); //# sourceMappingURL=esquery.min.js.map diff --git a/tools/node_modules/eslint/node_modules/esquery/package.json b/tools/node_modules/eslint/node_modules/esquery/package.json index eac205c94b..6f9a3e44bf 100644 --- a/tools/node_modules/eslint/node_modules/esquery/package.json +++ b/tools/node_modules/eslint/node_modules/esquery/package.json @@ -81,5 +81,5 @@ "test": "nyc npm run mocha && npm run lint", "test:ci": "npm run mocha" }, - "version": "1.3.1" + "version": "1.4.0" }
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/esquery/parser.js b/tools/node_modules/eslint/node_modules/esquery/parser.js index ef8bf10a44..36d590c581 100644 --- a/tools/node_modules/eslint/node_modules/esquery/parser.js +++ b/tools/node_modules/eslint/node_modules/esquery/parser.js @@ -203,86 +203,89 @@ peg$c41 = peg$classExpectation([">", "<"], false, false), peg$c42 = ".", peg$c43 = peg$literalExpectation(".", false), - peg$c44 = function(name, op, value) { + peg$c44 = function(a, as) { + return [].concat.apply([a], as).join(''); + }, + peg$c45 = function(name, op, value) { return { type: 'attribute', name: name, operator: op, value: value }; }, - peg$c45 = function(name) { return { type: 'attribute', name: name }; }, - peg$c46 = "\"", - peg$c47 = peg$literalExpectation("\"", false), - peg$c48 = /^[^\\"]/, - peg$c49 = peg$classExpectation(["\\", "\""], true, false), - peg$c50 = "\\", - peg$c51 = peg$literalExpectation("\\", false), - peg$c52 = peg$anyExpectation(), - peg$c53 = function(a, b) { return a + b; }, - peg$c54 = function(d) { + peg$c46 = function(name) { return { type: 'attribute', name: name }; }, + peg$c47 = "\"", + peg$c48 = peg$literalExpectation("\"", false), + peg$c49 = /^[^\\"]/, + peg$c50 = peg$classExpectation(["\\", "\""], true, false), + peg$c51 = "\\", + peg$c52 = peg$literalExpectation("\\", false), + peg$c53 = peg$anyExpectation(), + peg$c54 = function(a, b) { return a + b; }, + peg$c55 = function(d) { return { type: 'literal', value: strUnescape(d.join('')) }; }, - peg$c55 = "'", - peg$c56 = peg$literalExpectation("'", false), - peg$c57 = /^[^\\']/, - peg$c58 = peg$classExpectation(["\\", "'"], true, false), - peg$c59 = /^[0-9]/, - peg$c60 = peg$classExpectation([["0", "9"]], false, false), - peg$c61 = function(a, b) { + peg$c56 = "'", + peg$c57 = peg$literalExpectation("'", false), + peg$c58 = /^[^\\']/, + peg$c59 = peg$classExpectation(["\\", "'"], true, false), + peg$c60 = /^[0-9]/, + peg$c61 = peg$classExpectation([["0", "9"]], false, false), + peg$c62 = function(a, b) { // Can use `a.flat().join('')` once supported const leadingDecimals = a ? [].concat.apply([], a).join('') : ''; return { type: 'literal', value: parseFloat(leadingDecimals + b.join('')) }; }, - peg$c62 = function(i) { return { type: 'literal', value: i }; }, - peg$c63 = "type(", - peg$c64 = peg$literalExpectation("type(", false), - peg$c65 = /^[^ )]/, - peg$c66 = peg$classExpectation([" ", ")"], true, false), - peg$c67 = ")", - peg$c68 = peg$literalExpectation(")", false), - peg$c69 = function(t) { return { type: 'type', value: t.join('') }; }, - peg$c70 = /^[imsu]/, - peg$c71 = peg$classExpectation(["i", "m", "s", "u"], false, false), - peg$c72 = "/", - peg$c73 = peg$literalExpectation("/", false), - peg$c74 = /^[^\/]/, - peg$c75 = peg$classExpectation(["/"], true, false), - peg$c76 = function(d, flgs) { return { + peg$c63 = function(i) { return { type: 'literal', value: i }; }, + peg$c64 = "type(", + peg$c65 = peg$literalExpectation("type(", false), + peg$c66 = /^[^ )]/, + peg$c67 = peg$classExpectation([" ", ")"], true, false), + peg$c68 = ")", + peg$c69 = peg$literalExpectation(")", false), + peg$c70 = function(t) { return { type: 'type', value: t.join('') }; }, + peg$c71 = /^[imsu]/, + peg$c72 = peg$classExpectation(["i", "m", "s", "u"], false, false), + peg$c73 = "/", + peg$c74 = peg$literalExpectation("/", false), + peg$c75 = /^[^\/]/, + peg$c76 = peg$classExpectation(["/"], true, false), + peg$c77 = function(d, flgs) { return { type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') }; }, - peg$c77 = function(i, is) { + peg$c78 = function(i, is) { return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)}; }, - peg$c78 = ":not(", - peg$c79 = peg$literalExpectation(":not(", false), - peg$c80 = function(ss) { return { type: 'not', selectors: ss }; }, - peg$c81 = ":matches(", - peg$c82 = peg$literalExpectation(":matches(", false), - peg$c83 = function(ss) { return { type: 'matches', selectors: ss }; }, - peg$c84 = ":has(", - peg$c85 = peg$literalExpectation(":has(", false), - peg$c86 = function(ss) { return { type: 'has', selectors: ss }; }, - peg$c87 = ":first-child", - peg$c88 = peg$literalExpectation(":first-child", false), - peg$c89 = function() { return nth(1); }, - peg$c90 = ":last-child", - peg$c91 = peg$literalExpectation(":last-child", false), - peg$c92 = function() { return nthLast(1); }, - peg$c93 = ":nth-child(", - peg$c94 = peg$literalExpectation(":nth-child(", false), - peg$c95 = function(n) { return nth(parseInt(n.join(''), 10)); }, - peg$c96 = ":nth-last-child(", - peg$c97 = peg$literalExpectation(":nth-last-child(", false), - peg$c98 = function(n) { return nthLast(parseInt(n.join(''), 10)); }, - peg$c99 = ":", - peg$c100 = peg$literalExpectation(":", false), - peg$c101 = "statement", - peg$c102 = peg$literalExpectation("statement", true), - peg$c103 = "expression", - peg$c104 = peg$literalExpectation("expression", true), - peg$c105 = "declaration", - peg$c106 = peg$literalExpectation("declaration", true), - peg$c107 = "function", - peg$c108 = peg$literalExpectation("function", true), - peg$c109 = "pattern", - peg$c110 = peg$literalExpectation("pattern", true), - peg$c111 = function(c) { + peg$c79 = ":not(", + peg$c80 = peg$literalExpectation(":not(", false), + peg$c81 = function(ss) { return { type: 'not', selectors: ss }; }, + peg$c82 = ":matches(", + peg$c83 = peg$literalExpectation(":matches(", false), + peg$c84 = function(ss) { return { type: 'matches', selectors: ss }; }, + peg$c85 = ":has(", + peg$c86 = peg$literalExpectation(":has(", false), + peg$c87 = function(ss) { return { type: 'has', selectors: ss }; }, + peg$c88 = ":first-child", + peg$c89 = peg$literalExpectation(":first-child", false), + peg$c90 = function() { return nth(1); }, + peg$c91 = ":last-child", + peg$c92 = peg$literalExpectation(":last-child", false), + peg$c93 = function() { return nthLast(1); }, + peg$c94 = ":nth-child(", + peg$c95 = peg$literalExpectation(":nth-child(", false), + peg$c96 = function(n) { return nth(parseInt(n.join(''), 10)); }, + peg$c97 = ":nth-last-child(", + peg$c98 = peg$literalExpectation(":nth-last-child(", false), + peg$c99 = function(n) { return nthLast(parseInt(n.join(''), 10)); }, + peg$c100 = ":", + peg$c101 = peg$literalExpectation(":", false), + peg$c102 = "statement", + peg$c103 = peg$literalExpectation("statement", true), + peg$c104 = "expression", + peg$c105 = peg$literalExpectation("expression", true), + peg$c106 = "declaration", + peg$c107 = peg$literalExpectation("declaration", true), + peg$c108 = "function", + peg$c109 = peg$literalExpectation("function", true), + peg$c110 = "pattern", + peg$c111 = peg$literalExpectation("pattern", true), + peg$c112 = function(c) { return { type: 'class', name: c }; }, @@ -1205,7 +1208,7 @@ } function peg$parseattrName() { - var s0, s1, s2; + var s0, s1, s2, s3, s4, s5; var key = peg$currPos * 30 + 13, cached = peg$resultsCache[key]; @@ -1217,39 +1220,66 @@ } s0 = peg$currPos; - s1 = []; - s2 = peg$parseidentifierName(); - if (s2 === peg$FAILED) { + s1 = peg$parseidentifierName(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c42; + s4 = peg$c42; peg$currPos++; } else { - s2 = peg$FAILED; + s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parseidentifierName(); - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c42; - peg$currPos++; + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c42; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c43); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseidentifierName(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c43); } + peg$currPos = s3; + s3 = peg$FAILED; } + } else { + peg$currPos = s3; + s3 = peg$FAILED; } } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c44(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c6(s1); + peg$currPos = s0; + s0 = peg$FAILED; } - s0 = s1; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; @@ -1283,7 +1313,7 @@ } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c44(s1, s3, s5); + s1 = peg$c45(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; @@ -1324,7 +1354,7 @@ } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c44(s1, s3, s5); + s1 = peg$c45(s1, s3, s5); s0 = s1; } else { peg$currPos = s0; @@ -1351,7 +1381,7 @@ s1 = peg$parseattrName(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c45(s1); + s1 = peg$c46(s1); } s0 = s1; } @@ -1376,29 +1406,29 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c46; + s1 = peg$c47; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c47); } + if (peg$silentFails === 0) { peg$fail(peg$c48); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c48.test(input.charAt(peg$currPos))) { + if (peg$c49.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } + if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s3 === peg$FAILED) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { @@ -1406,11 +1436,11 @@ peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { peg$savedPos = s3; - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -1423,21 +1453,21 @@ } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c48.test(input.charAt(peg$currPos))) { + if (peg$c49.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } + if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s3 === peg$FAILED) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { @@ -1445,11 +1475,11 @@ peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { peg$savedPos = s3; - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -1463,15 +1493,15 @@ } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c46; + s3 = peg$c47; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c47); } + if (peg$silentFails === 0) { peg$fail(peg$c48); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c54(s2); + s1 = peg$c55(s2); s0 = s1; } else { peg$currPos = s0; @@ -1488,29 +1518,29 @@ if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c55; + s1 = peg$c56; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c57); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c57.test(input.charAt(peg$currPos))) { + if (peg$c58.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s3 === peg$FAILED) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { @@ -1518,11 +1548,11 @@ peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { peg$savedPos = s3; - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -1535,21 +1565,21 @@ } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c57.test(input.charAt(peg$currPos))) { + if (peg$c58.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s3 === peg$FAILED) { s3 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s4 = peg$c50; + s4 = peg$c51; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { @@ -1557,11 +1587,11 @@ peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s5 !== peg$FAILED) { peg$savedPos = s3; - s4 = peg$c53(s4, s5); + s4 = peg$c54(s4, s5); s3 = s4; } else { peg$currPos = s3; @@ -1575,15 +1605,15 @@ } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c55; + s3 = peg$c56; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c57); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c54(s2); + s1 = peg$c55(s2); s0 = s1; } else { peg$currPos = s0; @@ -1619,21 +1649,21 @@ s0 = peg$currPos; s1 = peg$currPos; s2 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } } if (s2 !== peg$FAILED) { @@ -1660,22 +1690,22 @@ } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } } } else { @@ -1683,7 +1713,7 @@ } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c61(s1, s2); + s1 = peg$c62(s1, s2); s0 = s1; } else { peg$currPos = s0; @@ -1715,7 +1745,7 @@ s1 = peg$parseidentifierName(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c62(s1); + s1 = peg$c63(s1); } s0 = s1; @@ -1737,33 +1767,33 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c63) { - s1 = peg$c63; + if (input.substr(peg$currPos, 5) === peg$c64) { + s1 = peg$c64; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c65); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = []; - if (peg$c65.test(input.charAt(peg$currPos))) { + if (peg$c66.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } + if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c65.test(input.charAt(peg$currPos))) { + if (peg$c66.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } + if (peg$silentFails === 0) { peg$fail(peg$c67); } } } } else { @@ -1773,15 +1803,15 @@ s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c69(s3); + s1 = peg$c70(s3); s0 = s1; } else { peg$currPos = s0; @@ -1822,22 +1852,22 @@ } s0 = []; - if (peg$c70.test(input.charAt(peg$currPos))) { + if (peg$c71.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c71); } + if (peg$silentFails === 0) { peg$fail(peg$c72); } } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$c70.test(input.charAt(peg$currPos))) { + if (peg$c71.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c71); } + if (peg$silentFails === 0) { peg$fail(peg$c72); } } } } else { @@ -1863,30 +1893,30 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { - s1 = peg$c72; + s1 = peg$c73; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c73); } + if (peg$silentFails === 0) { peg$fail(peg$c74); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c74.test(input.charAt(peg$currPos))) { + if (peg$c75.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c75); } + if (peg$silentFails === 0) { peg$fail(peg$c76); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c74.test(input.charAt(peg$currPos))) { + if (peg$c75.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c75); } + if (peg$silentFails === 0) { peg$fail(peg$c76); } } } } else { @@ -1894,11 +1924,11 @@ } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { - s3 = peg$c72; + s3 = peg$c73; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c73); } + if (peg$silentFails === 0) { peg$fail(peg$c74); } } if (s3 !== peg$FAILED) { s4 = peg$parseflags(); @@ -1907,7 +1937,7 @@ } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c76(s2, s4); + s1 = peg$c77(s2, s4); s0 = s1; } else { peg$currPos = s0; @@ -2002,7 +2032,7 @@ } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c77(s2, s3); + s1 = peg$c78(s2, s3); s0 = s1; } else { peg$currPos = s0; @@ -2035,12 +2065,12 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c78) { - s1 = peg$c78; + if (input.substr(peg$currPos, 5) === peg$c79) { + s1 = peg$c79; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); @@ -2050,15 +2080,15 @@ s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c80(s3); + s1 = peg$c81(s3); s0 = s1; } else { peg$currPos = s0; @@ -2099,12 +2129,12 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c81) { - s1 = peg$c81; + if (input.substr(peg$currPos, 9) === peg$c82) { + s1 = peg$c82; peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); @@ -2114,15 +2144,15 @@ s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c83(s3); + s1 = peg$c84(s3); s0 = s1; } else { peg$currPos = s0; @@ -2163,12 +2193,12 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c84) { - s1 = peg$c84; + if (input.substr(peg$currPos, 5) === peg$c85) { + s1 = peg$c85; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c86); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); @@ -2178,15 +2208,15 @@ s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c86(s3); + s1 = peg$c87(s3); s0 = s1; } else { peg$currPos = s0; @@ -2227,16 +2257,16 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 12) === peg$c87) { - s1 = peg$c87; + if (input.substr(peg$currPos, 12) === peg$c88) { + s1 = peg$c88; peg$currPos += 12; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c88); } + if (peg$silentFails === 0) { peg$fail(peg$c89); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c89(); + s1 = peg$c90(); } s0 = s1; @@ -2258,16 +2288,16 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 11) === peg$c91) { + s1 = peg$c91; peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } + if (peg$silentFails === 0) { peg$fail(peg$c92); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c92(); + s1 = peg$c93(); } s0 = s1; @@ -2289,33 +2319,33 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 11) === peg$c93) { - s1 = peg$c93; + if (input.substr(peg$currPos, 11) === peg$c94) { + s1 = peg$c94; peg$currPos += 11; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c94); } + if (peg$silentFails === 0) { peg$fail(peg$c95); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } } } else { @@ -2325,15 +2355,15 @@ s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c95(s3); + s1 = peg$c96(s3); s0 = s1; } else { peg$currPos = s0; @@ -2374,33 +2404,33 @@ } s0 = peg$currPos; - if (input.substr(peg$currPos, 16) === peg$c96) { - s1 = peg$c96; + if (input.substr(peg$currPos, 16) === peg$c97) { + s1 = peg$c97; peg$currPos += 16; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c97); } + if (peg$silentFails === 0) { peg$fail(peg$c98); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = []; - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c59.test(input.charAt(peg$currPos))) { + if (peg$c60.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } } } else { @@ -2410,15 +2440,15 @@ s4 = peg$parse_(); if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c67; + s5 = peg$c68; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s5 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c98(s3); + s1 = peg$c99(s3); s0 = s1; } else { peg$currPos = s0; @@ -2460,51 +2490,51 @@ s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 58) { - s1 = peg$c99; + s1 = peg$c100; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c100); } + if (peg$silentFails === 0) { peg$fail(peg$c101); } } if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c101) { + if (input.substr(peg$currPos, 9).toLowerCase() === peg$c102) { s2 = input.substr(peg$currPos, 9); peg$currPos += 9; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c102); } + if (peg$silentFails === 0) { peg$fail(peg$c103); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) { + if (input.substr(peg$currPos, 10).toLowerCase() === peg$c104) { s2 = input.substr(peg$currPos, 10); peg$currPos += 10; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c104); } + if (peg$silentFails === 0) { peg$fail(peg$c105); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c105) { + if (input.substr(peg$currPos, 11).toLowerCase() === peg$c106) { s2 = input.substr(peg$currPos, 11); peg$currPos += 11; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c106); } + if (peg$silentFails === 0) { peg$fail(peg$c107); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c107) { + if (input.substr(peg$currPos, 8).toLowerCase() === peg$c108) { s2 = input.substr(peg$currPos, 8); peg$currPos += 8; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c108); } + if (peg$silentFails === 0) { peg$fail(peg$c109); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c109) { + if (input.substr(peg$currPos, 7).toLowerCase() === peg$c110) { s2 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c110); } + if (peg$silentFails === 0) { peg$fail(peg$c111); } } } } @@ -2512,7 +2542,7 @@ } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c111(s2); + s1 = peg$c112(s2); s0 = s1; } else { peg$currPos = s0; diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md index 65368f5fe1..41a995cc76 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/README.md @@ -1,8 +1,8 @@ <img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/images/ajv_logo.png"> -# Ajv: Another JSON Schema Validator +# Ajv: Another JSON schema validator -The fastest JSON Schema validator for Node.js and browser. Supports draft-06/07/2019-09 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)). +The fastest JSON schema validator for Node.js and browser. Supports JSON Schema draft-06/07/2019-09 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/). [![build](https://github.com/ajv-validator/ajv/workflows/build/badge.svg)](https://github.com/ajv-validator/ajv/actions?query=workflow%3Abuild) [![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv) @@ -17,9 +17,10 @@ The fastest JSON Schema validator for Node.js and browser. Supports draft-06/07/ ## Using version 7 -Ajv version 7 is released with these changes: +Ajv version 7 has these new features: - support of JSON Schema draft-2019-09 features: [`unevaluatedProperties`](./docs/json-schema.md#unevaluatedproperties) and [`unevaluatedItems`](./docs/json-schema.md#unevaluateditems), [dynamic recursive references](./docs/validation.md#extending-recursive-schemas) and other [additional keywords](./docs/json-schema.md#json-schema-draft-2019-09). +- NEW: support of JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/) (from [v7.1.0](https://github.com/ajv-validator/ajv-keywords/releases/tag/v7.1.0)) - to reduce the mistakes in JSON schemas and unexpected validation results, [strict mode](./docs/strict-mode.md) is added - it prohibits ignored or ambiguous JSON Schema elements. - to make code injection from untrusted schemas impossible, [code generation](./docs/codegen.md) is fully re-written to be safe and to allow code optimization (compiled schema code size is reduced by more than 10%). - to simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas. [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package was updated to use the new API (in [v4.0.0](https://github.com/ajv-validator/ajv-keywords/releases/tag/v4.0.0)) @@ -71,6 +72,9 @@ Please review [Contributing guidelines](./CONTRIBUTING.md) and [Code components] - [Performance](#performance) - [Features](#features) - [Getting started](#usage) +- [Choosing schema language](#choosing-schema-language) + - [JSON Schema](#json-schema) + - [JSON Type Definition](#json-type-definition) - [Frequently Asked Questions](./docs/faq.md) - [Using in browser](#using-in-browser) - [Content Security Policy](./docs/security.md#content-security-policy) @@ -166,7 +170,7 @@ Performance of different validators by [json-schema-benchmark](https://github.co ## Features -- Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) standards (draft-04 is supported in v6): +- Ajv implements JSON Schema [draft-06/07/2019-09](http://json-schema.org/) standards (draft-04 is supported in v6): - all validation keywords (see [JSON Schema validation keywords](./docs/json-schema.md)) - keyword "nullable" from [Open API 3 specification](https://swagger.io/docs/specification/data-models/data-types/). - full support of remote references (remote schemas have to be added with `addSchema` or compiled to be available) @@ -174,6 +178,10 @@ Performance of different validators by [json-schema-benchmark](https://github.co - correct string lengths for strings with unicode pairs - [formats](#formats) defined by JSON Schema draft-07 standard (with [ajv-formats](https://github.com/ajv-validator/ajv-formats) plugin) and additional formats (can be turned off) - [validates schemas against meta-schema](./docs/api.md#api-validateschema) +- NEW: supports [JSON Type Definition](https://datatracker.ietf.org/doc/rfc8927/): + - all forms (see [JSON Type Definition schema forms](./docs/json-type-definition.md)) + - meta-schema for JTD schemas + - "union" keyword and user-defined keywords (can be used inside "metadata" member of the schema) - supports [browsers](#using-in-browser) and Node.js 0.10-14.x - [asynchronous loading](./docs/validation.md#asynchronous-schema-compilation) of referenced schemas during compilation - "All errors" validation mode with [option allErrors](./docs/api.md#options) @@ -262,6 +270,26 @@ if (validate(data)) { } ``` +With JSON Type Definition schema: + +```javascript +const Ajv = require("ajv").default + +const ajv = new Ajv() // options can be passed, e.g. {allErrors: true} +const schema = { + properties: { + foo: {type: "float64"}, + }, +} +const validate = ajv.compile(schema) +const valid = validate({foo: 1}) // true +if (!valid) console.log(validate.errors) +// Unlike JSON Schema: +const valid1 = validate(1) // false, bot an object +const valid2 = validate({}) // false, foo is required +const valid3 = validate({foo: 1, bar: 2}) // false, bar is additional +``` + See [this test](./spec/types/json-schema.spec.ts) for an advanced example, [API reference](./docs/api.md) and [Options](./docs/api.md#options) for more details. Ajv compiles schemas to functions and caches them in all cases (using schema itself as a key for Map) or another function passed via options), so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again. @@ -290,7 +318,7 @@ Then you need to load Ajv with support of JSON Schema draft-07 in the browser: </script> ``` -or to load the bundle that supports JSONSchema draft-2019-09: +To load the bundle that supports JSON Schema draft-2019-09: ```html <script src="bundle/ajv2019.min.js"></script> @@ -302,12 +330,75 @@ or to load the bundle that supports JSONSchema draft-2019-09: </script> ``` +To load the bundle that supports JSON Type Definition: + +```html +<script src="bundle/ajvJTD.min.js"></script> +<script> + ;(function () { + const Ajv = window.ajvJTD.default + const ajv = new Ajv() + })() +</script> +``` + This bundle can be used with different module systems; it creates global `ajv` (or `ajv2019`) if no module system is found. The browser bundle is available on [cdnjs](https://cdnjs.com/libraries/ajv). **Please note**: some frameworks, e.g. Dojo, may redefine global require in a way that is not compatible with CommonJS module format. In this case Ajv bundle has to be loaded before the framework and then you can use global `ajv` (see issue [#234](https://github.com/ajv-validator/ajv/issues/234)). +## Choosing schema language + +Both JSON Schema and JSON Type Definition are cross-platform specifications with implementations in multiple programming languages that help you define the shape and requirements to your JSON data. + +This section compares their pros/cons to help decide which specification fits your application better. + +### JSON Schema + +- Pros + - Wide specification adoption. + - Used as part of OpenAPI specification. + - Support of complex validation scenarios: + - untagged unions and boolean logic + - conditional schemas and dependencies + - restrictions on the number ranges and the size of strings, arrays and objects + - semantic validation with formats, patterns and content keywords + - distribute strict record definitions across multiple schemas (with unevaluatedProperties) + - Can be effectively used for validation of any JavaScript objects and configuration files. +- Cons + - Defines the collection of restrictions on the data, rather than the shape of the data. + - No standard support for tagged unions. + - Complex and error prone for the new users (Ajv has [strict mode](./docs/strict-mode) to compensate for it, but it is not cross-platform). + - Some parts of specification are difficult to implement, creating the risk of implementations divergence: + - reference resolution model + - unevaluatedProperties/unevaluatedItems + - dynamic recursive references + - Internet draft status (rather than RFC) + +See [JSON Schema](./docs/json-schema.md) for the list of defined keywords. + +### JSON Type Definition + +- Pros: + - Aligned with type systems of many languages - can be used to generate type definitions and efficient parsers and serializers to/from these types. + - Very simple, enforcing the best practices for cross-platform JSON API modelling. + - Simple to implement, ensuring consistency across implementations. + - Defines the shape of JSON data via strictly defined schema forms (rather than the collection of restrictions). + - Effective support for tagged unions. + - Designed to protect against user mistakes. + - Approved as [RFC8927](https://datatracker.ietf.org/doc/rfc8927/) +- Cons: + - Limited, compared with JSON Schema - no support for untagged unions<sup>\*</sup>, conditionals, references between different schema files<sup>\*\*</sup>, etc. + - No meta-schema in the specification<sup>\*</sup>. + - Brand new - limited industry adoption (as of January 2021). + +<sup>\*</sup> Ajv defines meta-schema for JTD schemas and non-standard keyword "union" that can be used inside "metadata" object. + +<sup>\*\*</sup> You can still combine schemas from multiple files in the application code. + +See [JSON Type Definition](./docs/json-type-definition.md) for the list of defined schema forms. + ## Using in ES5 environment You need to: @@ -334,7 +425,7 @@ CLI is available as a separate npm package [ajv-cli](https://github.com/ajv-vali - user-defined meta-schemas, validation keywords and formats - files in JSON, JSON5, YAML, and JavaScript format - all Ajv options -- reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format +- reporting changes in data after validation in [JSON-patch](https://datatracker.ietf.org/doc/rfc6902/) format ## Extending Ajv diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/ajv.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/ajv.js index be8275b51a..8aa6397289 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/ajv.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/ajv.js @@ -22,10 +22,9 @@ class Ajv extends core_1.default { } _addDefaultMetaSchema() { super._addDefaultMetaSchema(); - const { $data, meta } = this.opts; - if (!meta) + if (!this.opts.meta) return; - const metaSchema = $data + const metaSchema = this.opts.$data ? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA) : draft7MetaSchema; this.addMetaSchema(metaSchema, META_SCHEMA_ID, false); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/codegen/scope.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/codegen/scope.js index ef1b167012..91919e8880 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/codegen/scope.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/codegen/scope.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = void 0; +exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0; const code_1 = require("./code"); class ValueError extends Error { constructor(name) { @@ -8,6 +8,11 @@ class ValueError extends Error { this.value = name.value; } } +var UsedValueState; +(function (UsedValueState) { + UsedValueState[UsedValueState["Started"] = 0] = "Started"; + UsedValueState[UsedValueState["Completed"] = 1] = "Completed"; +})(UsedValueState = exports.UsedValueState || (exports.UsedValueState = {})); exports.varKinds = { const: new code_1.Name("const"), let: new code_1.Name("let"), @@ -112,11 +117,11 @@ class ValueScope extends Scope { const vs = values[prefix]; if (!vs) continue; - const nameSet = (usedValues[prefix] = usedValues[prefix] || new Set()); + const nameSet = (usedValues[prefix] = usedValues[prefix] || new Map()); vs.forEach((name) => { if (nameSet.has(name)) return; - nameSet.add(name); + nameSet.set(name, UsedValueState.Started); let c = valueCode(name); if (c) { const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const; @@ -128,6 +133,7 @@ class ValueScope extends Scope { else { throw new ValueError(name); } + nameSet.set(name, UsedValueState.Completed); }); } return code; diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/context.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/context.js index fc3e3f7e1d..17dd9ba110 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/context.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/context.js @@ -79,7 +79,7 @@ class KeywordCxt { } error(append) { ; - (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error || errors_1.keywordError); + (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error); } $dataError() { errors_1.reportError(this, this.def.$dataError || errors_1.keyword$DataError); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/error_classes.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/error_classes.js index 753d657af0..ef39107000 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/error_classes.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/error_classes.js @@ -11,8 +11,8 @@ class ValidationError extends Error { } exports.ValidationError = ValidationError; class MissingRefError extends Error { - constructor(baseId, ref) { - super(`can't resolve reference ${ref} from id ${baseId}`); + constructor(baseId, ref, msg) { + super(msg || `can't resolve reference ${ref} from id ${baseId}`); this.missingRef = resolve_1.resolveUrl(baseId, ref); this.missingSchema = resolve_1.normalizeId(resolve_1.getFullPath(this.missingRef)); } diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/errors.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/errors.js index f248e67c2c..fa886d80d9 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/errors.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/errors.js @@ -11,7 +11,7 @@ exports.keyword$DataError = { ? codegen_1.str `"${keyword}" keyword must be ${schemaType} ($data)` : codegen_1.str `"${keyword}" keyword is invalid ($data)`, }; -function reportError(cxt, error, overrideAllErrors) { +function reportError(cxt, error = exports.keywordError, overrideAllErrors) { const { it } = cxt; const { gen, compositeRule, allErrors } = it; const errObj = errorObjectCode(cxt, error); @@ -23,7 +23,7 @@ function reportError(cxt, error, overrideAllErrors) { } } exports.reportError = reportError; -function reportExtraError(cxt, error) { +function reportExtraError(cxt, error = exports.keywordError) { const { it } = cxt; const { gen, compositeRule, allErrors } = it; const errObj = errorObjectCode(cxt, error); @@ -77,11 +77,30 @@ const E = { message: new codegen_1.Name("message"), schema: new codegen_1.Name("schema"), parentSchema: new codegen_1.Name("parentSchema"), + // JTD error properties + instancePath: new codegen_1.Name("instancePath"), }; function errorObjectCode(cxt, error) { - const { keyword, data, schemaValue, it: { gen, createErrors, topSchemaRef, schemaPath, errorPath, errSchemaPath, propertyName, opts }, } = cxt; + const { createErrors, opts } = cxt.it; if (createErrors === false) return codegen_1._ `{}`; + return (opts.jtd && !opts.ajvErrors ? jtdErrorObject : ajvErrorObject)(cxt, error); +} +function jtdErrorObject(cxt, { message }) { + const { gen, keyword, it } = cxt; + const { errorPath, errSchemaPath, opts } = it; + const keyValues = [ + [E.instancePath, codegen_1.strConcat(names_1.default.dataPath, errorPath)], + [E.schemaPath, codegen_1.str `${errSchemaPath}/${keyword}`], + ]; + if (opts.messages) { + keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]); + } + return gen.object(...keyValues); +} +function ajvErrorObject(cxt, error) { + const { gen, keyword, data, schemaValue, it } = cxt; + const { topSchemaRef, schemaPath, errorPath, errSchemaPath, propertyName, opts } = it; const { params, message } = error; const keyValues = [ [E.keyword, keyword], @@ -91,9 +110,8 @@ function errorObjectCode(cxt, error) { ]; if (propertyName) keyValues.push([E.propertyName, propertyName]); - if (opts.messages !== false) { - const msg = typeof message == "function" ? message(cxt) : message; - keyValues.push([E.message, msg]); + if (opts.messages) { + keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]); } if (opts.verbose) { keyValues.push([E.schema, schemaValue], [E.parentSchema, codegen_1._ `${topSchemaRef}${schemaPath}`], [names_1.default.data, data]); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/index.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/index.js index b9d9bfb099..05a7a27df2 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/index.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/index.js @@ -64,11 +64,10 @@ function compileSchema(sch) { ValidationError: _ValidationError, schema: sch.schema, schemaEnv: sch, - strictSchema: true, rootId, baseId: sch.baseId || rootId, schemaPath: codegen_1.nil, - errSchemaPath: "#", + errSchemaPath: this.opts.jtd ? "" : "#", errorPath: codegen_1._ `""`, opts: this.opts, self: this, @@ -171,7 +170,7 @@ ref // reference to resolve ) { const p = URI.parse(ref); const refPath = resolve_1._getFullPath(p); - const baseId = resolve_1.getFullPath(root.baseId); + let baseId = resolve_1.getFullPath(root.baseId); // TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests if (Object.keys(root.schema).length > 0 && refPath === baseId) { return getJsonPointer.call(this, p, root); @@ -188,8 +187,12 @@ ref // reference to resolve return; if (!schOrRef.validate) compileSchema.call(this, schOrRef); - if (id === resolve_1.normalizeId(ref)) - return new SchemaEnv({ schema: schOrRef.schema, root, baseId }); + if (id === resolve_1.normalizeId(ref)) { + const { schema } = schOrRef; + if (schema.$id) + baseId = resolve_1.resolveUrl(baseId, schema.$id); + return new SchemaEnv({ schema, root, baseId }); + } return getJsonPointer.call(this, p, schOrRef); } exports.resolveSchema = resolveSchema; diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/rules.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/rules.js index 11c114a4c3..82a591ff4d 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/rules.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/rules.js @@ -18,8 +18,8 @@ function getRules() { types: { ...groups, integer: true, boolean: true, null: true }, rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object], post: { rules: [] }, - all: { type: true, $comment: true }, - keywords: { type: true, $comment: true }, + all: {}, + keywords: {}, }; } exports.getRules = getRules; diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/subschema.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/subschema.js index df69e4cc54..1d6de63586 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/subschema.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/subschema.js @@ -18,7 +18,7 @@ function applySubschema(it, appl, valid) { return nextContext; } exports.applySubschema = applySubschema; -function getSubschema(it, { keyword, schemaProp, schema, strictSchema, schemaPath, errSchemaPath, topSchemaRef, }) { +function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) { if (keyword !== undefined && schema !== undefined) { throw new Error('both "keyword" and "schema" passed, only one allowed'); } @@ -42,7 +42,6 @@ function getSubschema(it, { keyword, schemaProp, schema, strictSchema, schemaPat } return { schema, - strictSchema, schemaPath, topSchemaRef, errSchemaPath, @@ -80,14 +79,15 @@ function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, da subschema.dataNames = [...it.dataNames, _nextData]; } } -function extendSubschemaMode(subschema, { compositeRule, createErrors, allErrors, strictSchema }) { +function extendSubschemaMode(subschema, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) { if (compositeRule !== undefined) subschema.compositeRule = compositeRule; if (createErrors !== undefined) subschema.createErrors = createErrors; if (allErrors !== undefined) subschema.allErrors = allErrors; - subschema.strictSchema = strictSchema; // not inherited + subschema.jtdDiscriminator = jtdDiscriminator; // not inherited + subschema.jtdMetadata = jtdMetadata; // not inherited } function getErrorPath(dataProp, dataPropType, jsPropertySyntax) { // let path diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/timestamp.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/timestamp.js new file mode 100644 index 0000000000..fcb61fe51c --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/timestamp.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const DATE_TIME = /^(\d\d\d\d)-(\d\d)-(\d\d)(?:t|\s)(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i; +const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +function validTimestamp(str) { + // http://tools.ietf.org/html/rfc3339#section-5.6 + const matches = DATE_TIME.exec(str); + if (!matches) + return false; + const y = +matches[1]; + const m = +matches[2]; + const d = +matches[3]; + const hr = +matches[4]; + const min = +matches[5]; + const sec = +matches[6]; + const tzH = +(matches[7] || 0); + const tzM = +(matches[8] || 0); + return (m >= 1 && + m <= 12 && + d >= 1 && + (d <= DAYS[m] || + // leap year: https://tools.ietf.org/html/rfc3339#appendix-C + (m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0))) && + ((hr <= 23 && min <= 59 && sec <= 59) || + // leap second + (hr - tzH === 23 && min - tzM === 59 && sec === 60))); +} +exports.default = validTimestamp; +//# sourceMappingURL=timestamp.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/index.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/index.js index 0db360a2cf..eb26357b1f 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/index.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/index.js @@ -119,6 +119,8 @@ function checkKeywords(it) { checkRefsAndKeywords(it); } function typeAndKeywords(it, errsCount) { + if (it.opts.jtd) + return iterate_1.schemaKeywords(it, [], false, errsCount); const types = dataType_1.getSchemaTypes(it.schema); const checkedTypes = dataType_1.coerceAndCheckDataType(it, types); iterate_1.schemaKeywords(it, types, !checkedTypes, errsCount); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/iterate.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/iterate.js index fb97c64def..cabe37a971 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/iterate.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/compile/validate/iterate.js @@ -16,7 +16,8 @@ function schemaKeywords(it, types, typeErrors, errsCount) { gen.block(() => keyword_1.keywordCode(it, "$ref", RULES.all.$ref.definition)); // TODO typecast return; } - checkStrictTypes(it, types); + if (!opts.jtd) + checkStrictTypes(it, types); gen.block(() => { for (const group of RULES.rules) groupKeywords(group); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/core.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/core.js index 23aae7ea64..465201b212 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/core.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/core.js @@ -409,8 +409,11 @@ class Ajv { } } _addSchema(schema, meta, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) { - if (typeof schema != "object" && typeof schema != "boolean") { - throw new Error("schema must be object or boolean"); + if (typeof schema != "object") { + if (this.opts.jtd) + throw new Error("schema must be object"); + else if (typeof schema != "boolean") + throw new Error("schema must be object or boolean"); } let sch = this._cache.get(schema); if (sch !== undefined) @@ -515,7 +518,7 @@ function getLogger(logger) { return logger; throw new Error("logger must implement log, warn and error methods"); } -const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-]*$/i; +const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-:]*$/i; function checkKeyword(keyword, def) { const { RULES } = this; util_1.eachItem(keyword, (kwd) => { diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/jtd.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/jtd.js new file mode 100644 index 0000000000..6d7924b97a --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/jtd.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; +const context_1 = require("./compile/context"); +exports.KeywordCxt = context_1.default; +// export {DefinedError} from "./vocabularies/errors" +var codegen_1 = require("./compile/codegen"); +Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } }); +Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } }); +Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } }); +Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } }); +Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } }); +Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } }); +const core_1 = require("./core"); +const jtd_1 = require("./vocabularies/jtd"); +const jtd_schema_1 = require("./refs/jtd-schema"); +// const META_SUPPORT_DATA = ["/properties"] +const META_SCHEMA_ID = "JTD-meta-schema"; +class Ajv extends core_1.default { + constructor(opts = {}) { + var _a; + super({ + ...opts, + jtd: true, + messages: (_a = opts.messages) !== null && _a !== void 0 ? _a : false, + }); + } + _addVocabularies() { + super._addVocabularies(); + this.addVocabulary(jtd_1.default); + } + _addDefaultMetaSchema() { + super._addDefaultMetaSchema(); + if (!this.opts.meta) + return; + this.addMetaSchema(jtd_schema_1.default, META_SCHEMA_ID, false); + } + defaultMeta() { + return (this.opts.defaultMeta = + super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined)); + } +} +exports.default = Ajv; +//# sourceMappingURL=jtd.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/refs/jtd-schema.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/refs/jtd-schema.js new file mode 100644 index 0000000000..1ee940afb2 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/refs/jtd-schema.js @@ -0,0 +1,118 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const shared = (root) => { + const sch = { + nullable: { type: "boolean" }, + metadata: { + optionalProperties: { + union: { elements: { ref: "schema" } }, + }, + additionalProperties: true, + }, + }; + if (root) + sch.definitions = { values: { ref: "schema" } }; + return sch; +}; +const emptyForm = (root) => ({ + optionalProperties: shared(root), +}); +const refForm = (root) => ({ + properties: { + ref: { type: "string" }, + }, + optionalProperties: shared(root), +}); +const typeForm = (root) => ({ + properties: { + type: { + enum: [ + "boolean", + "timestamp", + "string", + "float32", + "float64", + "int8", + "uint8", + "int16", + "uint16", + "int32", + "uint32", + ], + }, + }, + optionalProperties: shared(root), +}); +const enumForm = (root) => ({ + properties: { + enum: { elements: { type: "string" } }, + }, + optionalProperties: shared(root), +}); +const elementsForm = (root) => ({ + properties: { + elements: { ref: "schema" }, + }, + optionalProperties: shared(root), +}); +const propertiesForm = (root) => ({ + properties: { + properties: { values: { ref: "schema" } }, + }, + optionalProperties: { + optionalProperties: { values: { ref: "schema" } }, + additionalProperties: { type: "boolean" }, + ...shared(root), + }, +}); +const optionalPropertiesForm = (root) => ({ + properties: { + optionalProperties: { values: { ref: "schema" } }, + }, + optionalProperties: { + additionalProperties: { type: "boolean" }, + ...shared(root), + }, +}); +const discriminatorForm = (root) => ({ + properties: { + discriminator: { type: "string" }, + mapping: { + values: { + metadata: { + union: [propertiesForm(false), optionalPropertiesForm(false)], + }, + }, + }, + }, + optionalProperties: shared(root), +}); +const valuesForm = (root) => ({ + properties: { + values: { ref: "schema" }, + }, + optionalProperties: shared(root), +}); +const schema = (root) => ({ + metadata: { + union: [ + emptyForm, + refForm, + typeForm, + enumForm, + elementsForm, + propertiesForm, + optionalPropertiesForm, + discriminatorForm, + valuesForm, + ].map((s) => s(root)), + }, +}); +const jtdMetaSchema = { + definitions: { + schema: schema(false), + }, + ...schema(true), +}; +exports.default = jtdMetaSchema; +//# sourceMappingURL=jtd-schema.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/standalone/index.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/standalone/index.js index c49bde936b..f58ebb6977 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/standalone/index.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/standalone/index.js @@ -40,9 +40,9 @@ function standaloneCode(ajv, refsOrFunc) { function validateCode(usedValues, s) { if (!s) throw new Error('moduleCode: function does not have "source" property'); - const { prefix } = s.validateName; - const nameSet = (usedValues[prefix] = usedValues[prefix] || new Set()); - nameSet.add(s.validateName); + if (usedState(s.validateName) === scope_1.UsedValueState.Completed) + return code_1.nil; + setUsedState(s.validateName, scope_1.UsedValueState.Started); const scopeCode = ajv.scope.scopeCode(s.scopeValues, usedValues, refValidateCode); const code = new code_1._Code(`${scopeCode}${_n}${s.validateCode}`); return s.evaluated ? code_1._ `${code}${s.validateName}.evaluated = ${s.evaluated};${_n}` : code; @@ -55,12 +55,26 @@ function standaloneCode(ajv, refsOrFunc) { } else if ((n.prefix === "root" || n.prefix === "wrapper") && typeof vRef == "object") { const { validate, validateName } = vRef; - const vCode = validateCode(usedValues, validate === null || validate === void 0 ? void 0 : validate.source); + if (!validateName) + throw new Error("ajv internal error"); const def = ajv.opts.code.es5 ? scope_1.varKinds.var : scope_1.varKinds.const; - return code_1._ `${def} ${n} = {validate: ${validateName}};${_n}${vCode}`; + const wrapper = code_1._ `${def} ${n} = {validate: ${validateName}};`; + if (usedState(validateName) === scope_1.UsedValueState.Started) + return wrapper; + const vCode = validateCode(usedValues, validate === null || validate === void 0 ? void 0 : validate.source); + return code_1._ `${wrapper}${_n}${vCode}`; } return undefined; } + function usedState(name) { + var _a; + return (_a = usedValues[name.prefix]) === null || _a === void 0 ? void 0 : _a.get(name); + } + function setUsedState(name, state) { + const { prefix } = name; + const names = (usedValues[prefix] = usedValues[prefix] || new Map()); + names.set(name, state); + } } } exports.default = standaloneCode; diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js index 226c2a7a13..998b966692 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js @@ -41,8 +41,13 @@ const def = { let definedProp; if (props.length > 8) { // TODO maybe an option instead of hard-coded 8? + const hasProp = gen.scopeValue("func", { + // eslint-disable-next-line @typescript-eslint/unbound-method + ref: Object.prototype.hasOwnProperty, + code: codegen_1._ `Object.prototype.hasOwnProperty`, + }); const propsSchema = util_1.schemaRefOrVal(it, parentSchema.properties, "properties"); - definedProp = codegen_1._ `${propsSchema}.hasOwnProperty(${key})`; + definedProp = codegen_1._ `${hasProp}.call(${propsSchema}, ${key})`; } else if (props.length) { definedProp = codegen_1.or(...props.map((p) => codegen_1._ `${key} === ${p}`)); @@ -53,7 +58,7 @@ const def = { if (patProps.length) { definedProp = codegen_1.or(definedProp, ...patProps.map((p) => codegen_1._ `${code_1.usePattern(gen, p)}.test(${key})`)); } - return codegen_1._ `!(${definedProp})`; + return codegen_1.not(definedProp); } function deleteAdditional(key) { gen.code(codegen_1._ `delete ${data}[${key}]`); @@ -91,7 +96,6 @@ const def = { keyword: "additionalProperties", dataProp: key, dataPropType: subschema_1.Type.Str, - strictSchema: it.strictSchema, }; if (errors === false) { Object.assign(subschema, { diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/anyOf.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/anyOf.js index e209708a54..784c475d42 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/anyOf.js @@ -1,36 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const codegen_1 = require("../../compile/codegen"); -const util_1 = require("../../compile/util"); +const code_1 = require("../code"); const def = { keyword: "anyOf", schemaType: "array", trackErrors: true, - code(cxt) { - const { gen, schema, it } = cxt; - /* istanbul ignore if */ - if (!Array.isArray(schema)) - throw new Error("ajv implementation error"); - const alwaysValid = schema.some((sch) => util_1.alwaysValidSchema(it, sch)); - if (alwaysValid && !it.opts.unevaluated) - return; - const valid = gen.let("valid", false); - const schValid = gen.name("_valid"); - gen.block(() => schema.forEach((_sch, i) => { - const schCxt = cxt.subschema({ - keyword: "anyOf", - schemaProp: i, - compositeRule: true, - }, schValid); - gen.assign(valid, codegen_1._ `${valid} || ${schValid}`); - const merged = cxt.mergeValidEvaluated(schCxt, schValid); - // can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true) - // or if all properties and items were evaluated (it.props === true && it.items === true) - if (!merged) - gen.if(codegen_1.not(valid)); - })); - cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); - }, + code: code_1.validateUnion, error: { message: "should match some schema in anyOf", }, diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/items.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/items.js index e398dfbc7a..ecc6f1a5c1 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/items.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/items.js @@ -1,17 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const codegen_1 = require("../../compile/codegen"); -const subschema_1 = require("../../compile/subschema"); const util_1 = require("../../compile/util"); const validate_1 = require("../../compile/validate"); +const code_1 = require("../code"); const def = { keyword: "items", type: "array", schemaType: ["object", "array", "boolean"], before: "uniqueItems", code(cxt) { - const { gen, schema, parentSchema, data, it } = cxt; - const len = gen.const("len", codegen_1._ `${data}.length`); + const { gen, schema, it } = cxt; if (Array.isArray(schema)) { if (it.opts.unevaluated && schema.length && it.items !== true) { it.items = util_1.mergeEvaluated.items(gen, schema.length, it.items); @@ -20,15 +19,18 @@ const def = { } else { it.items = true; - if (!util_1.alwaysValidSchema(it, schema)) - validateArray(); + if (util_1.alwaysValidSchema(it, schema)) + return; + cxt.ok(code_1.validateArray(cxt)); } function validateTuple(schArr) { - if (it.opts.strictTuples && !fullTupleSchema(schema.length, parentSchema)) { + const { parentSchema, data } = cxt; + if (it.opts.strictTuples && !fullTupleSchema(schArr.length, parentSchema)) { const msg = `"items" is ${schArr.length}-tuple, but minItems or maxItems/additionalItems are not specified or different`; validate_1.checkStrictMode(it, msg, it.opts.strictTuples); } const valid = gen.name("valid"); + const len = gen.const("len", codegen_1._ `${data}.length`); schArr.forEach((sch, i) => { if (util_1.alwaysValidSchema(it, sch)) return; @@ -36,25 +38,10 @@ const def = { keyword: "items", schemaProp: i, dataProp: i, - strictSchema: it.strictSchema, }, valid)); cxt.ok(valid); }); } - function validateArray() { - const valid = gen.name("valid"); - gen.forRange("i", 0, len, (i) => { - cxt.subschema({ - keyword: "items", - dataProp: i, - dataPropType: subschema_1.Type.Num, - strictSchema: it.strictSchema, - }, valid); - if (!it.allErrors) - gen.if(codegen_1.not(valid), () => gen.break()); - }); - cxt.ok(valid); - } }, }; function fullTupleSchema(len, sch) { diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js index 25e9e4f5fb..5b188c2402 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js @@ -52,7 +52,6 @@ const def = { schemaProp: pat, dataProp: key, dataPropType: subschema_1.Type.Str, - strictSchema: it.strictSchema, }, valid); if (it.opts.unevaluated && props !== true) { gen.assign(codegen_1._ `${props}[${key}]`, true); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/properties.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/properties.js index 23dadd7b7c..12fab3ce28 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/properties.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/properties.js @@ -42,7 +42,6 @@ const def = { keyword: "properties", schemaProp: prop, dataProp: prop, - strictSchema: it.strictSchema, }, valid); } }, diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js index 9467ce79e1..d38f9a5eb7 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js @@ -24,7 +24,6 @@ const def = { dataTypes: ["string"], propertyName: key, compositeRule: true, - strictSchema: it.strictSchema, }, valid); gen.if(codegen_1.not(valid), () => { cxt.error(true); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/code.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/code.js index 7f87715152..a019e59b21 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/code.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/code.js @@ -1,8 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0; +exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0; const codegen_1 = require("../compile/codegen"); const util_1 = require("../compile/util"); +const subschema_1 = require("../compile/subschema"); const names_1 = require("../compile/names"); function checkReportMissingProp(cxt, prop) { const { gen, data, it } = cxt; @@ -64,4 +65,54 @@ function usePattern(gen, pattern) { }); } exports.usePattern = usePattern; +function validateArray(cxt) { + const { gen, data, keyword, it } = cxt; + const valid = gen.name("valid"); + if (it.allErrors) { + const validArr = gen.let("valid", true); + validateItems(() => gen.assign(validArr, false)); + return validArr; + } + gen.var(valid, true); + validateItems(() => gen.break()); + return valid; + function validateItems(notValid) { + const len = gen.const("len", codegen_1._ `${data}.length`); + gen.forRange("i", 0, len, (i) => { + cxt.subschema({ + keyword, + dataProp: i, + dataPropType: subschema_1.Type.Num, + }, valid); + gen.if(codegen_1.not(valid), notValid); + }); + } +} +exports.validateArray = validateArray; +function validateUnion(cxt) { + const { gen, schema, keyword, it } = cxt; + /* istanbul ignore if */ + if (!Array.isArray(schema)) + throw new Error("ajv implementation error"); + const alwaysValid = schema.some((sch) => util_1.alwaysValidSchema(it, sch)); + if (alwaysValid && !it.opts.unevaluated) + return; + const valid = gen.let("valid", false); + const schValid = gen.name("_valid"); + gen.block(() => schema.forEach((_sch, i) => { + const schCxt = cxt.subschema({ + keyword, + schemaProp: i, + compositeRule: true, + }, schValid); + gen.assign(valid, codegen_1._ `${valid} || ${schValid}`); + const merged = cxt.mergeValidEvaluated(schCxt, schValid); + // can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true) + // or if all properties and items were evaluated (it.props === true && it.items === true) + if (!merged) + gen.if(codegen_1.not(valid)); + })); + cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); +} +exports.validateUnion = validateUnion; //# sourceMappingURL=code.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/index.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/index.js index d3981d4b58..87656d7436 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/index.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/index.js @@ -7,6 +7,7 @@ const core = [ "$id", "$defs", "$vocabulary", + { keyword: "$comment" }, "definitions", id_1.default, ref_1.default, diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/ref.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/ref.js index b56fbcc511..10e68389de 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/ref.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/core/ref.js @@ -38,7 +38,6 @@ const def = { const valid = gen.name("valid"); const schCxt = cxt.subschema({ schema: sch, - strictSchema: true, dataTypes: [], schemaPath: codegen_1.nil, topSchemaRef: schName, diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/discriminator.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/discriminator.js new file mode 100644 index 0000000000..ca5d4d0ad8 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/discriminator.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const codegen_1 = require("../../compile/codegen"); +const metadata_1 = require("./metadata"); +const nullable_1 = require("./nullable"); +const def = { + keyword: "discriminator", + schemaType: "string", + implements: ["mapping"], + code(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, schema, parentSchema } = cxt; + const [valid, cond] = nullable_1.checkNullableObject(cxt, data); + gen.if(cond, () => { + const tag = gen.const("tag", codegen_1._ `${data}${codegen_1.getProperty(schema)}`); + gen.if(codegen_1._ `typeof ${tag} == "string"`, () => { + gen.if(false); + for (const tagValue in parentSchema.mapping) { + gen.elseIf(codegen_1._ `${tag} === ${tagValue}`); + gen.assign(valid, applyTagSchema(tagValue)); + } + gen.endIf(); + }); + }); + cxt.pass(valid); + function applyTagSchema(schemaProp) { + const _valid = gen.name("valid"); + cxt.subschema({ + keyword: "mapping", + schemaProp, + jtdDiscriminator: schema, + }, _valid); + return _valid; + } + }, +}; +exports.default = def; +//# sourceMappingURL=discriminator.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/elements.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/elements.js new file mode 100644 index 0000000000..77a46ca11d --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/elements.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const util_1 = require("../../compile/util"); +const code_1 = require("../code"); +const codegen_1 = require("../../compile/codegen"); +const metadata_1 = require("./metadata"); +const nullable_1 = require("./nullable"); +const def = { + keyword: "elements", + schemaType: "object", + code(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, schema, it } = cxt; + if (util_1.alwaysValidSchema(it, schema)) + return; + const [valid, cond] = nullable_1.checkNullable(cxt, codegen_1.nil); + gen.if(codegen_1.and(cond, codegen_1._ `Array.isArray(${data})`), () => gen.assign(valid, code_1.validateArray(cxt))); + cxt.pass(valid); + }, +}; +exports.default = def; +//# sourceMappingURL=elements.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/enum.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/enum.js new file mode 100644 index 0000000000..2995909048 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/enum.js @@ -0,0 +1,41 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const codegen_1 = require("../../compile/codegen"); +const metadata_1 = require("./metadata"); +const def = { + keyword: "enum", + schemaType: "array", + code(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, schema, schemaValue, parentSchema, it } = cxt; + if (schema.length === 0) + throw new Error("enum must have non-empty array"); + if (schema.length !== new Set(schema).size) + throw new Error("enum items must be unique"); + let valid; + if (schema.length >= it.opts.loopEnum) { + if (parentSchema.nullable) { + valid = gen.let("valid", codegen_1._ `${data} === null`); + gen.if(codegen_1.not(valid), loopEnum); + } + else { + valid = gen.let("valid", false); + loopEnum(); + } + } + else { + /* istanbul ignore if */ + if (!Array.isArray(schema)) + throw new Error("ajv implementation error"); + valid = codegen_1.or(...schema.map((value) => codegen_1._ `${data} === ${value}`)); + if (parentSchema.nullable) + valid = codegen_1.or(codegen_1._ `${data} === null`, valid); + } + cxt.pass(valid); + function loopEnum() { + gen.forOf("v", schemaValue, (v) => gen.if(codegen_1._ `${valid} = ${data} === ${v}`, () => gen.break())); + } + }, +}; +exports.default = def; +//# sourceMappingURL=enum.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/index.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/index.js new file mode 100644 index 0000000000..f0ba74daf1 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/index.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// import definitions from "./definitions" +const ref_1 = require("./ref"); +const type_1 = require("./type"); +const enum_1 = require("./enum"); +const elements_1 = require("./elements"); +const properties_1 = require("./properties"); +const optionalProperties_1 = require("./optionalProperties"); +const discriminator_1 = require("./discriminator"); +const values_1 = require("./values"); +const union_1 = require("./union"); +const metadata_1 = require("./metadata"); +const jtdVocabulary = [ + "definitions", + ref_1.default, + type_1.default, + enum_1.default, + elements_1.default, + properties_1.default, + optionalProperties_1.default, + discriminator_1.default, + values_1.default, + union_1.default, + metadata_1.default, + { keyword: "additionalProperties", schemaType: "boolean" }, + { keyword: "nullable", schemaType: "boolean" }, +]; +exports.default = jtdVocabulary; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/metadata.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/metadata.js new file mode 100644 index 0000000000..acd00ffcad --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/metadata.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.checkMetadata = void 0; +const util_1 = require("../../compile/util"); +const def = { + keyword: "metadata", + schemaType: "object", + code(cxt) { + checkMetadata(cxt); + const { gen, schema, it } = cxt; + if (util_1.alwaysValidSchema(it, schema)) + return; + const valid = gen.name("valid"); + cxt.subschema({ keyword: "metadata", jtdMetadata: true }, valid); + cxt.ok(valid); + }, +}; +function checkMetadata({ it, keyword }, metadata) { + if (it.jtdMetadata !== metadata) { + throw new Error(`JTD: "${keyword}" cannot be used in this schema location`); + } +} +exports.checkMetadata = checkMetadata; +exports.default = def; +//# sourceMappingURL=metadata.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/nullable.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/nullable.js new file mode 100644 index 0000000000..ee2e6935eb --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/nullable.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.checkNullableObject = exports.checkNullable = void 0; +const codegen_1 = require("../../compile/codegen"); +function checkNullable({ gen, data, parentSchema }, cond) { + const valid = gen.name("valid"); + if (parentSchema.nullable) { + gen.let(valid, codegen_1._ `${data} === null`); + cond = codegen_1.not(valid); + } + else { + gen.let(valid, false); + } + return [valid, cond]; +} +exports.checkNullable = checkNullable; +function checkNullableObject(cxt, cond) { + const [valid, cond_] = checkNullable(cxt, cond); + return [valid, codegen_1._ `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`]; +} +exports.checkNullableObject = checkNullableObject; +//# sourceMappingURL=nullable.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js new file mode 100644 index 0000000000..c9058251d3 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const properties_1 = require("./properties"); +const def = { + keyword: "optionalProperties", + schemaType: "object", + code(cxt) { + if (cxt.parentSchema.properties) + return; + properties_1.validateProperties(cxt); + }, +}; +exports.default = def; +//# sourceMappingURL=optionalProperties.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/properties.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/properties.js new file mode 100644 index 0000000000..c9a29a01c5 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/properties.js @@ -0,0 +1,123 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateProperties = void 0; +const code_1 = require("../code"); +const util_1 = require("../../compile/util"); +const codegen_1 = require("../../compile/codegen"); +const metadata_1 = require("./metadata"); +const nullable_1 = require("./nullable"); +const def = { + keyword: "properties", + schemaType: "object", + code: validateProperties, +}; +function validateProperties(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, parentSchema, it } = cxt; + const { additionalProperties, nullable } = parentSchema; + if (it.jtdDiscriminator && nullable) + throw new Error("JTD: nullable inside discriminator mapping"); + if (commonProperties()) { + throw new Error("JTD: properties and optionalProperties have common members"); + } + const [allProps, properties] = schemaProperties("properties"); + const [allOptProps, optProperties] = schemaProperties("optionalProperties"); + if (properties.length === 0 && optProperties.length === 0 && additionalProperties) { + return; + } + const [valid, cond] = it.jtdDiscriminator === undefined + ? nullable_1.checkNullableObject(cxt, data) + : [gen.let("valid", false), true]; + gen.if(cond, () => gen.assign(valid, true).block(() => { + validateProps(properties, "properties", true); + validateProps(optProperties, "optionalProperties"); + if (!additionalProperties) + validateAdditional(); + })); + cxt.pass(valid); + function commonProperties() { + const props = parentSchema.properties; + const optProps = parentSchema.optionalProperties; + if (!(props && optProps)) + return false; + for (const p in props) { + if (Object.prototype.hasOwnProperty.call(optProps, p)) + return true; + } + return false; + } + function schemaProperties(keyword) { + const schema = parentSchema[keyword]; + const allPs = schema ? code_1.allSchemaProperties(schema) : []; + if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) { + throw new Error(`JTD: discriminator tag used in ${keyword}`); + } + const ps = allPs.filter((p) => !util_1.alwaysValidSchema(it, schema[p])); + return [allPs, ps]; + } + function validateProps(props, keyword, required) { + const _valid = gen.var("valid"); + for (const prop of props) { + gen.if(code_1.propertyInData(data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), missingProperty); + cxt.ok(_valid); + } + function missingProperty() { + if (required) { + gen.assign(_valid, false); + cxt.error(); + } + else { + gen.assign(_valid, true); + } + } + } + function applyPropertySchema(prop, keyword, _valid) { + cxt.subschema({ + keyword, + schemaProp: prop, + dataProp: prop, + }, _valid); + } + function validateAdditional() { + gen.forIn("key", data, (key) => { + const _allProps = it.jtdDiscriminator === undefined ? allProps : [it.jtdDiscriminator].concat(allProps); + const addProp = isAdditional(key, _allProps, "properties"); + const addOptProp = isAdditional(key, allOptProps, "optionalProperties"); + const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : codegen_1.and(addProp, addOptProp); + gen.if(extra, () => { + if (it.opts.removeAdditional) { + gen.code(codegen_1._ `delete ${data}[${key}]`); + } + else { + // cxt.setParams({additionalProperty: key}) + cxt.error(); + if (!it.opts.allErrors) + gen.break(); + } + }); + }); + } + function isAdditional(key, props, keyword) { + let additional; + if (props.length > 8) { + // TODO maybe an option instead of hard-coded 8? + const propsSchema = util_1.schemaRefOrVal(it, parentSchema[keyword], keyword); + const hasProp = gen.scopeValue("func", { + // eslint-disable-next-line @typescript-eslint/unbound-method + ref: Object.prototype.hasOwnProperty, + code: codegen_1._ `Object.prototype.hasOwnProperty`, + }); + additional = codegen_1._ `!${hasProp}.call(${propsSchema}, ${key})`; + } + else if (props.length) { + additional = codegen_1.and(...props.map((p) => codegen_1._ `${key} !== ${p}`)); + } + else { + additional = true; + } + return additional; + } +} +exports.validateProperties = validateProperties; +exports.default = def; +//# sourceMappingURL=properties.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/ref.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/ref.js new file mode 100644 index 0000000000..acfd31748d --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/ref.js @@ -0,0 +1,64 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const compile_1 = require("../../compile"); +const codegen_1 = require("../../compile/codegen"); +const error_classes_1 = require("../../compile/error_classes"); +const names_1 = require("../../compile/names"); +const ref_1 = require("../core/ref"); +const metadata_1 = require("./metadata"); +const def = { + keyword: "ref", + schemaType: "string", + code(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, schema: ref, parentSchema, it } = cxt; + const { schemaEnv: { root }, } = it; + const valid = gen.name("valid"); + if (parentSchema.nullable) { + gen.var(valid, codegen_1._ `${data} === null`); + gen.if(codegen_1.not(valid), validateJtdRef); + } + else { + gen.var(valid, false); + validateJtdRef(); + } + cxt.ok(valid); + function validateJtdRef() { + var _a; + const refSchema = (_a = root.schema.definitions) === null || _a === void 0 ? void 0 : _a[ref]; + if (!refSchema) + throw new error_classes_1.MissingRefError("", ref, `No definition ${ref}`); + if (hasRef(refSchema) || !it.opts.inlineRefs) + callValidate(refSchema); + else + inlineRefSchema(refSchema); + } + function callValidate(schema) { + const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root })); + const v = ref_1.getValidate(cxt, sch); + const errsCount = gen.const("_errs", names_1.default.errors); + ref_1.callRef(cxt, v, sch, sch.$async); + gen.assign(valid, codegen_1._ `${errsCount} === ${names_1.default.errors}`); + } + function inlineRefSchema(schema) { + const schName = gen.scopeValue("schema", it.opts.code.source === true ? { ref: schema, code: codegen_1.stringify(schema) } : { ref: schema }); + cxt.subschema({ + schema, + dataTypes: [], + schemaPath: codegen_1.nil, + topSchemaRef: schName, + errSchemaPath: `/definitions/${ref}`, + }, valid); + } + function hasRef(schema) { + for (const key in schema) { + let sch; + if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch))) + return true; + } + return false; + } + }, +}; +exports.default = def; +//# sourceMappingURL=ref.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/type.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/type.js new file mode 100644 index 0000000000..1eedbb8648 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/type.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const codegen_1 = require("../../compile/codegen"); +const timestamp_1 = require("../../compile/timestamp"); +const metadata_1 = require("./metadata"); +const intRange = { + int8: [-128, 127], + uint8: [0, 255], + int16: [-32768, 32767], + uint16: [0, 65535], + int32: [-2147483648, 2147483647], + uint32: [0, 4294967295], +}; +const def = { + keyword: "type", + schemaType: "string", + code(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, schema, parentSchema } = cxt; + let cond; + switch (schema) { + case "boolean": + case "string": + cond = codegen_1._ `typeof ${data} == ${schema}`; + break; + case "timestamp": { + const vts = gen.scopeValue("func", { + ref: timestamp_1.default, + code: codegen_1._ `require("ajv/dist/compile/timestamp").default`, + }); + cond = codegen_1._ `${data} instanceof Date || (typeof ${data} == "string" && ${vts}(${data}))`; + break; + } + case "float32": + case "float64": + cond = codegen_1._ `typeof ${data} == "number"`; + break; + default: { + const [min, max] = intRange[schema]; + cond = codegen_1._ `typeof ${data} == "number" && isFinite(${data}) && ${data} >= ${min} && ${data} <= ${max} && !(${data} % 1)`; + } + } + cxt.pass(parentSchema.nullable ? codegen_1.or(codegen_1._ `${data} === null`, cond) : cond); + }, +}; +exports.default = def; +//# sourceMappingURL=type.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/union.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/union.js new file mode 100644 index 0000000000..e3bc5033e1 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/union.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const code_1 = require("../code"); +const def = { + keyword: "union", + schemaType: "array", + trackErrors: true, + code: code_1.validateUnion, +}; +exports.default = def; +//# sourceMappingURL=union.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/values.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/values.js new file mode 100644 index 0000000000..68682ef119 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/values.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const subschema_1 = require("../../compile/subschema"); +const util_1 = require("../../compile/util"); +const codegen_1 = require("../../compile/codegen"); +const metadata_1 = require("./metadata"); +const nullable_1 = require("./nullable"); +const def = { + keyword: "values", + schemaType: "object", + code(cxt) { + metadata_1.checkMetadata(cxt); + const { gen, data, schema, it } = cxt; + if (util_1.alwaysValidSchema(it, schema)) + return; + const [valid, cond] = nullable_1.checkNullableObject(cxt, data); + gen.if(cond, () => gen.assign(valid, validateMap())); + cxt.pass(valid); + function validateMap() { + const _valid = gen.name("valid"); + if (it.allErrors) { + const validMap = gen.let("valid", true); + validateValues(() => gen.assign(validMap, false)); + return validMap; + } + gen.var(_valid, true); + validateValues(() => gen.break()); + return _valid; + function validateValues(notValid) { + gen.forIn("key", data, (key) => { + cxt.subschema({ + keyword: "values", + dataProp: key, + dataPropType: subschema_1.Type.Str, + }, _valid); + gen.if(codegen_1.not(_valid), notValid); + }); + } + } + }, +}; +exports.default = def; +//# sourceMappingURL=values.js.map
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js index ce77b261ca..6ab14c01a5 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js @@ -44,7 +44,6 @@ const def = { keyword: "unevaluatedProperties", dataProp: key, dataPropType: subschema_1.Type.Str, - strictSchema: it.strictSchema, }, valid); if (!allErrors) gen.if(codegen_1.not(valid), () => gen.break()); diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/validation/index.js b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/validation/index.js index 9a7b711c1b..7b56b4e453 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/validation/index.js +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/validation/index.js @@ -24,6 +24,7 @@ const validation = [ limitItems_1.default, uniqueItems_1.default, // any + { keyword: "type", schemaType: ["string", "array"] }, { keyword: "nullable", schemaType: "boolean" }, const_1.default, enum_1.default, diff --git a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json index 032498f33b..bace75fe97 100644 --- a/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json +++ b/tools/node_modules/eslint/node_modules/table/node_modules/ajv/package.json @@ -33,7 +33,7 @@ "eslint": "^7.8.1", "eslint-config-prettier": "^7.0.0", "glob": "^7.0.0", - "husky": "^4.2.5", + "husky": "^5.0.9", "if-node-version": "^1.0.0", "js-beautify": "^1.7.3", "json-schema-test": "^2.0.0", @@ -98,8 +98,8 @@ "url": "git+https://github.com/ajv-validator/ajv.git" }, "scripts": { - "build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts", - "bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019", + "build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts && rm dist/refs/jtd-schema.ts", + "bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019 && node ./scripts/bundle.js jtd ajvJTD ajvJTD", "eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" scripts --ignore-pattern spec/JSON-Schema-Test-Suite", "json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests", "prepublish": "npm run build", @@ -117,5 +117,5 @@ }, "tonicExampleFilename": ".tonic_example.js", "types": "dist/ajv.d.ts", - "version": "7.0.3" + "version": "7.1.0" }
\ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/which/package.json b/tools/node_modules/eslint/node_modules/which/package.json index 9620a99a29..32eaa57575 100644 --- a/tools/node_modules/eslint/node_modules/which/package.json +++ b/tools/node_modules/eslint/node_modules/which/package.json @@ -5,7 +5,7 @@ "url": "http://blog.izs.me" }, "bin": { - "node-which": "./bin/node-which" + "node-which": "bin/node-which" }, "bugs": { "url": "https://github.com/isaacs/node-which/issues" diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 24c8bc57f6..a2977ce589 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -11,7 +11,7 @@ }, "bundleDependencies": false, "dependencies": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.3.0", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -24,7 +24,7 @@ "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^2.0.0", "espree": "^7.3.1", - "esquery": "^1.2.0", + "esquery": "^1.4.0", "esutils": "^2.0.2", "file-entry-cache": "^6.0.0", "functional-red-black-tree": "^1.0.1", @@ -154,5 +154,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "7.19.0" + "version": "7.20.0" }
\ No newline at end of file |