Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / vue-eslint-parser / index.js
1 /**
2  * @author Toru Nagashima <https://github.com/mysticatea>
3  * See LICENSE file in root directory for full license.
4  */
5 'use strict';
6
7 Object.defineProperty(exports, '__esModule', { value: true });
8
9 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
10
11 var path = require('path');
12 var path__default = _interopDefault(path);
13 var Evk = _interopDefault(require('eslint-visitor-keys'));
14 var sortedLastIndex = _interopDefault(require('lodash/sortedLastIndex'));
15 var assert = _interopDefault(require('assert'));
16 var last = _interopDefault(require('lodash/last'));
17 var findLastIndex = _interopDefault(require('lodash/findLastIndex'));
18 var debugFactory = _interopDefault(require('debug'));
19 var sortedIndexBy = _interopDefault(require('lodash/sortedIndexBy'));
20 var sortedLastIndexBy = _interopDefault(require('lodash/sortedLastIndexBy'));
21 var first = _interopDefault(require('lodash/first'));
22 var escope = _interopDefault(require('eslint-scope'));
23 var Module = _interopDefault(require('module'));
24 var EventEmitter = _interopDefault(require('events'));
25 var esquery = _interopDefault(require('esquery'));
26 var union = _interopDefault(require('lodash/union'));
27 var intersection = _interopDefault(require('lodash/intersection'));
28 var memoize = _interopDefault(require('lodash/memoize'));
29
30 function isAcornStyleParseError(x) {
31     return (typeof x.message === "string" &&
32         typeof x.pos === "number" &&
33         typeof x.loc === "object" &&
34         x.loc !== null &&
35         typeof x.loc.line === "number" &&
36         typeof x.loc.column === "number");
37 }
38 class ParseError extends SyntaxError {
39     static fromCode(code, offset, line, column) {
40         return new ParseError(code, code, offset, line, column);
41     }
42     static normalize(x) {
43         if (ParseError.isParseError(x)) {
44             return x;
45         }
46         if (isAcornStyleParseError(x)) {
47             return new ParseError(x.message, undefined, x.pos, x.loc.line, x.loc.column);
48         }
49         return null;
50     }
51     constructor(message, code, offset, line, column) {
52         super(message);
53         this.code = code;
54         this.index = offset;
55         this.lineNumber = line;
56         this.column = column;
57     }
58     static isParseError(x) {
59         return (x instanceof ParseError ||
60             (typeof x.message === "string" &&
61                 typeof x.index === "number" &&
62                 typeof x.lineNumber === "number" &&
63                 typeof x.column === "number"));
64     }
65 }
66
67 const NS = Object.freeze({
68     HTML: "http://www.w3.org/1999/xhtml",
69     MathML: "http://www.w3.org/1998/Math/MathML",
70     SVG: "http://www.w3.org/2000/svg",
71     XLink: "http://www.w3.org/1999/xlink",
72     XML: "http://www.w3.org/XML/1998/namespace",
73     XMLNS: "http://www.w3.org/2000/xmlns/",
74 });
75
76 const KEYS = Evk.unionWith({
77     VAttribute: ["key", "value"],
78     VDirectiveKey: ["name", "argument", "modifiers"],
79     VDocumentFragment: ["children"],
80     VElement: ["startTag", "children", "endTag"],
81     VEndTag: [],
82     VExpressionContainer: ["expression"],
83     VFilter: ["callee", "arguments"],
84     VFilterSequenceExpression: ["expression", "filters"],
85     VForExpression: ["left", "right"],
86     VIdentifier: [],
87     VLiteral: [],
88     VOnExpression: ["body"],
89     VSlotScopeExpression: ["params"],
90     VStartTag: ["attributes"],
91     VText: [],
92 });
93 function fallbackKeysFilter(key) {
94     let value = null;
95     return (key !== "comments" &&
96         key !== "leadingComments" &&
97         key !== "loc" &&
98         key !== "parent" &&
99         key !== "range" &&
100         key !== "tokens" &&
101         key !== "trailingComments" &&
102         (value = this[key]) !== null &&
103         typeof value === "object" &&
104         (typeof value.type === "string" || Array.isArray(value)));
105 }
106 function getFallbackKeys(node) {
107     return Object.keys(node).filter(fallbackKeysFilter, node);
108 }
109 function isNode(x) {
110     return x !== null && typeof x === "object" && typeof x.type === "string";
111 }
112 function traverse(node, parent, visitor) {
113     let i = 0;
114     let j = 0;
115     visitor.enterNode(node, parent);
116     const keys = (visitor.visitorKeys || KEYS)[node.type] || getFallbackKeys(node);
117     for (i = 0; i < keys.length; ++i) {
118         const child = node[keys[i]];
119         if (Array.isArray(child)) {
120             for (j = 0; j < child.length; ++j) {
121                 if (isNode(child[j])) {
122                     traverse(child[j], node, visitor);
123                 }
124             }
125         }
126         else if (isNode(child)) {
127             traverse(child, node, visitor);
128         }
129     }
130     visitor.leaveNode(node, parent);
131 }
132 function traverseNodes(node, visitor) {
133     traverse(node, null, visitor);
134 }
135
136
137
138 var index = /*#__PURE__*/Object.freeze({
139     __proto__: null,
140     ParseError: ParseError,
141     NS: NS,
142     traverseNodes: traverseNodes,
143     getFallbackKeys: getFallbackKeys
144 });
145
146 class LocationCalculator {
147     constructor(gapOffsets, ltOffsets, baseOffset, shiftOffset = 0) {
148         this.gapOffsets = gapOffsets;
149         this.ltOffsets = ltOffsets;
150         this.baseOffset = baseOffset || 0;
151         this.baseIndexOfGap =
152             this.baseOffset === 0
153                 ? 0
154                 : sortedLastIndex(gapOffsets, this.baseOffset);
155         this.shiftOffset = shiftOffset;
156     }
157     getSubCalculatorAfter(offset) {
158         return new LocationCalculator(this.gapOffsets, this.ltOffsets, this.baseOffset + offset, this.shiftOffset);
159     }
160     getSubCalculatorShift(offset) {
161         return new LocationCalculator(this.gapOffsets, this.ltOffsets, this.baseOffset, this.shiftOffset + offset);
162     }
163     _getLocation(offset) {
164         const line = sortedLastIndex(this.ltOffsets, offset) + 1;
165         const column = offset - (line === 1 ? 0 : this.ltOffsets[line - 2]);
166         return { line, column };
167     }
168     _getGap(index) {
169         const offsets = this.gapOffsets;
170         let g0 = sortedLastIndex(offsets, index + this.baseOffset);
171         let pos = index + this.baseOffset + g0 - this.baseIndexOfGap;
172         while (g0 < offsets.length && offsets[g0] <= pos) {
173             g0 += 1;
174             pos += 1;
175         }
176         return g0 - this.baseIndexOfGap;
177     }
178     getLocation(index) {
179         return this._getLocation(this.baseOffset + index + this.shiftOffset);
180     }
181     getOffsetWithGap(index) {
182         const shiftOffset = this.shiftOffset;
183         return (this.baseOffset +
184             index +
185             shiftOffset +
186             this._getGap(index + shiftOffset));
187     }
188     fixLocation(node) {
189         const shiftOffset = this.shiftOffset;
190         const range = node.range;
191         const loc = node.loc;
192         const gap0 = this._getGap(range[0] + shiftOffset);
193         const gap1 = this._getGap(range[1] + shiftOffset);
194         const d0 = this.baseOffset + Math.max(0, gap0) + shiftOffset;
195         const d1 = this.baseOffset + Math.max(0, gap1) + shiftOffset;
196         if (d0 !== 0) {
197             range[0] += d0;
198             if (node.start != null) {
199                 node.start += d0;
200             }
201             loc.start = this._getLocation(range[0]);
202         }
203         if (d1 !== 0) {
204             range[1] += d1;
205             if (node.end != null) {
206                 node.end += d0;
207             }
208             loc.end = this._getLocation(range[1]);
209         }
210         return node;
211     }
212     fixErrorLocation(error) {
213         const shiftOffset = this.shiftOffset;
214         const gap = this._getGap(error.index + shiftOffset);
215         const diff = this.baseOffset + Math.max(0, gap) + shiftOffset;
216         error.index += diff;
217         const loc = this._getLocation(error.index);
218         error.lineNumber = loc.line;
219         error.column = loc.column;
220     }
221 }
222
223 const debug = debugFactory("vue-eslint-parser");
224
225 function isUnique(reference, index, references) {
226     return (index === 0 || reference.identifier !== references[index - 1].identifier);
227 }
228 function hasDefinition(variable) {
229     return variable.defs.length >= 1;
230 }
231 function transformReference(reference) {
232     const ret = {
233         id: reference.identifier,
234         mode: reference.isReadOnly()
235             ? "r"
236             : reference.isWriteOnly()
237                 ? "w"
238                 : "rw",
239         variable: null,
240     };
241     Object.defineProperty(ret, "variable", { enumerable: false });
242     return ret;
243 }
244 function transformVariable(variable) {
245     const ret = {
246         id: variable.defs[0].name,
247         kind: variable.scope.type === "for" ? "v-for" : "scope",
248         references: [],
249     };
250     Object.defineProperty(ret, "references", { enumerable: false });
251     return ret;
252 }
253 function getForScope(scope) {
254     const child = scope.childScopes[0];
255     return child.block === scope.block ? child.childScopes[0] : child;
256 }
257 function analyze(ast, parserOptions) {
258     const ecmaVersion = parserOptions.ecmaVersion || 2017;
259     const ecmaFeatures = parserOptions.ecmaFeatures || {};
260     const sourceType = parserOptions.sourceType || "script";
261     const result = escope.analyze(ast, {
262         ignoreEval: true,
263         nodejsScope: false,
264         impliedStrict: ecmaFeatures.impliedStrict,
265         ecmaVersion,
266         sourceType,
267         fallback: getFallbackKeys,
268     });
269     return result.globalScope;
270 }
271 function analyzeExternalReferences(ast, parserOptions) {
272     const scope = analyze(ast, parserOptions);
273     return scope.through.filter(isUnique).map(transformReference);
274 }
275 function analyzeVariablesAndExternalReferences(ast, parserOptions) {
276     const scope = analyze(ast, parserOptions);
277     return {
278         variables: getForScope(scope)
279             .variables.filter(hasDefinition)
280             .map(transformVariable),
281         references: scope.through.filter(isUnique).map(transformReference),
282     };
283 }
284
285 const createRequire = Module.createRequire ||
286     Module.createRequireFromPath ||
287     (filename => {
288         const mod = new Module(filename);
289         mod.filename = filename;
290         mod.paths = Module._nodeModulePaths(path__default.dirname(filename));
291         mod._compile("module.exports = require;", filename);
292         return mod.exports;
293     });
294 let espreeCache = null;
295 function isLinterPath(p) {
296     return (p.includes(`eslint${path__default.sep}lib${path__default.sep}linter${path__default.sep}linter.js`) ||
297         p.includes(`eslint${path__default.sep}lib${path__default.sep}linter.js`));
298 }
299 function getEspree() {
300     if (!espreeCache) {
301         const linterPath = Object.keys(require.cache).find(isLinterPath);
302         if (linterPath) {
303             try {
304                 espreeCache = createRequire(linterPath)("espree");
305             }
306             catch (_a) {
307             }
308         }
309         if (!espreeCache) {
310             espreeCache = require("espree");
311         }
312     }
313     return espreeCache;
314 }
315
316 const ALIAS_PARENS = /^(\s*)\(([\s\S]+)\)(\s*(?:in|of)\b[\s\S]+)$/u;
317 const DUMMY_PARENT = {};
318 const IS_FUNCTION_EXPRESSION = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/u;
319 const IS_SIMPLE_PATH = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?'\]|\["[^"]*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/u;
320 function postprocess(result, locationCalculator) {
321     const traversed = new Set();
322     traverseNodes(result.ast, {
323         visitorKeys: result.visitorKeys,
324         enterNode(node, parent) {
325             if (!traversed.has(node)) {
326                 traversed.add(node);
327                 node.parent = parent;
328                 if (!traversed.has(node.range)) {
329                     traversed.add(node.range);
330                     locationCalculator.fixLocation(node);
331                 }
332             }
333         },
334         leaveNode() {
335         },
336     });
337     for (const token of result.ast.tokens || []) {
338         locationCalculator.fixLocation(token);
339     }
340     for (const comment of result.ast.comments || []) {
341         locationCalculator.fixLocation(comment);
342     }
343 }
344 function replaceAliasParens(code) {
345     const match = ALIAS_PARENS.exec(code);
346     if (match != null) {
347         return `${match[1]}[${match[2]}]${match[3]}`;
348     }
349     return code;
350 }
351 function normalizeLeft(left, replaced) {
352     if (left.type !== "VariableDeclaration") {
353         throw new Error("unreachable");
354     }
355     const id = left.declarations[0].id;
356     if (replaced) {
357         return id.elements;
358     }
359     return [id];
360 }
361 function getCommaTokenBeforeNode(tokens, node) {
362     let tokenIndex = sortedIndexBy(tokens, { range: node.range }, t => t.range[0]);
363     while (tokenIndex >= 0) {
364         const token = tokens[tokenIndex];
365         if (token.type === "Punctuator" && token.value === ",") {
366             return token;
367         }
368         tokenIndex -= 1;
369     }
370     return null;
371 }
372 function throwEmptyError(locationCalculator, expected) {
373     const loc = locationCalculator.getLocation(0);
374     const err = new ParseError(`Expected to be ${expected}, but got empty.`, undefined, 0, loc.line, loc.column);
375     locationCalculator.fixErrorLocation(err);
376     throw err;
377 }
378 function throwUnexpectedTokenError(name, token) {
379     const err = new ParseError(`Unexpected token '${name}'.`, undefined, token.range[0], token.loc.start.line, token.loc.start.column);
380     throw err;
381 }
382 function throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator) {
383     if (ParseError.isParseError(err)) {
384         const endOffset = locationCalculator.getOffsetWithGap(code.length);
385         if (err.index >= endOffset) {
386             err.message = "Unexpected end of expression.";
387         }
388     }
389     throw err;
390 }
391 function parseScriptFragment(code, locationCalculator, parserOptions) {
392     try {
393         const result = parseScript(code, parserOptions);
394         postprocess(result, locationCalculator);
395         return result;
396     }
397     catch (err) {
398         const perr = ParseError.normalize(err);
399         if (perr) {
400             locationCalculator.fixErrorLocation(perr);
401             throw perr;
402         }
403         throw err;
404     }
405 }
406 const validDivisionCharRE = /[\w).+\-_$\]]/u;
407 function splitFilters(exp) {
408     const result = [];
409     let inSingle = false;
410     let inDouble = false;
411     let inTemplateString = false;
412     let inRegex = false;
413     let curly = 0;
414     let square = 0;
415     let paren = 0;
416     let lastFilterIndex = 0;
417     let c = 0;
418     let prev = 0;
419     for (let i = 0; i < exp.length; i++) {
420         prev = c;
421         c = exp.charCodeAt(i);
422         if (inSingle) {
423             if (c === 0x27 && prev !== 0x5c) {
424                 inSingle = false;
425             }
426         }
427         else if (inDouble) {
428             if (c === 0x22 && prev !== 0x5c) {
429                 inDouble = false;
430             }
431         }
432         else if (inTemplateString) {
433             if (c === 0x60 && prev !== 0x5c) {
434                 inTemplateString = false;
435             }
436         }
437         else if (inRegex) {
438             if (c === 0x2f && prev !== 0x5c) {
439                 inRegex = false;
440             }
441         }
442         else if (c === 0x7c &&
443             exp.charCodeAt(i + 1) !== 0x7c &&
444             exp.charCodeAt(i - 1) !== 0x7c &&
445             !curly &&
446             !square &&
447             !paren) {
448             result.push(exp.slice(lastFilterIndex, i));
449             lastFilterIndex = i + 1;
450         }
451         else {
452             switch (c) {
453                 case 0x22:
454                     inDouble = true;
455                     break;
456                 case 0x27:
457                     inSingle = true;
458                     break;
459                 case 0x60:
460                     inTemplateString = true;
461                     break;
462                 case 0x28:
463                     paren++;
464                     break;
465                 case 0x29:
466                     paren--;
467                     break;
468                 case 0x5b:
469                     square++;
470                     break;
471                 case 0x5d:
472                     square--;
473                     break;
474                 case 0x7b:
475                     curly++;
476                     break;
477                 case 0x7d:
478                     curly--;
479                     break;
480             }
481             if (c === 0x2f) {
482                 let j = i - 1;
483                 let p;
484                 for (; j >= 0; j--) {
485                     p = exp.charAt(j);
486                     if (p !== " ") {
487                         break;
488                     }
489                 }
490                 if (!p || !validDivisionCharRE.test(p)) {
491                     inRegex = true;
492                 }
493             }
494         }
495     }
496     result.push(exp.slice(lastFilterIndex));
497     return result;
498 }
499 function parseExpressionBody(code, locationCalculator, parserOptions, allowEmpty = false) {
500     debug('[script] parse expression: "0(%s)"', code);
501     try {
502         const ast = parseScriptFragment(`0(${code})`, locationCalculator.getSubCalculatorShift(-2), parserOptions).ast;
503         const tokens = ast.tokens || [];
504         const comments = ast.comments || [];
505         const references = analyzeExternalReferences(ast, parserOptions);
506         const statement = ast.body[0];
507         const callExpression = statement.expression;
508         const expression = callExpression.arguments[0];
509         if (!allowEmpty && !expression) {
510             return throwEmptyError(locationCalculator, "an expression");
511         }
512         if (expression && expression.type === "SpreadElement") {
513             return throwUnexpectedTokenError("...", expression);
514         }
515         if (callExpression.arguments[1]) {
516             const node = callExpression.arguments[1];
517             return throwUnexpectedTokenError(",", getCommaTokenBeforeNode(tokens, node) || node);
518         }
519         tokens.shift();
520         tokens.shift();
521         tokens.pop();
522         return { expression, tokens, comments, references, variables: [] };
523     }
524     catch (err) {
525         return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
526     }
527 }
528 function parseFilter(code, locationCalculator, parserOptions) {
529     debug('[script] parse filter: "%s"', code);
530     try {
531         const expression = {
532             type: "VFilter",
533             parent: null,
534             range: [0, 0],
535             loc: {},
536             callee: null,
537             arguments: [],
538         };
539         const tokens = [];
540         const comments = [];
541         const references = [];
542         const paren = code.indexOf("(");
543         const calleeCode = paren === -1 ? code : code.slice(0, paren);
544         const argsCode = paren === -1 ? null : code.slice(paren);
545         if (calleeCode.trim()) {
546             const spaces = /^\s*/u.exec(calleeCode)[0];
547             const subCalculator = locationCalculator.getSubCalculatorShift(spaces.length);
548             const { ast } = parseScriptFragment(`"${calleeCode.trim()}"`, subCalculator, parserOptions);
549             const statement = ast.body[0];
550             const callee = statement.expression;
551             if (callee.type !== "Literal") {
552                 const { loc, range } = ast.tokens[0];
553                 return throwUnexpectedTokenError('"', {
554                     range: [range[1] - 1, range[1]],
555                     loc: {
556                         start: {
557                             line: loc.end.line,
558                             column: loc.end.column - 1,
559                         },
560                         end: loc.end,
561                     },
562                 });
563             }
564             expression.callee = {
565                 type: "Identifier",
566                 parent: expression,
567                 range: [
568                     callee.range[0],
569                     subCalculator.getOffsetWithGap(calleeCode.trim().length),
570                 ],
571                 loc: {
572                     start: callee.loc.start,
573                     end: subCalculator.getLocation(calleeCode.trim().length),
574                 },
575                 name: String(callee.value),
576             };
577             tokens.push({
578                 type: "Identifier",
579                 value: calleeCode.trim(),
580                 range: expression.callee.range,
581                 loc: expression.callee.loc,
582             });
583         }
584         else {
585             return throwEmptyError(locationCalculator, "a filter name");
586         }
587         if (argsCode != null) {
588             const { ast } = parseScriptFragment(`0${argsCode}`, locationCalculator
589                 .getSubCalculatorAfter(paren)
590                 .getSubCalculatorShift(-1), parserOptions);
591             const statement = ast.body[0];
592             const callExpression = statement.expression;
593             ast.tokens.shift();
594             if (callExpression.type !== "CallExpression" ||
595                 callExpression.callee.type !== "Literal") {
596                 let nestCount = 1;
597                 for (const token of ast.tokens.slice(1)) {
598                     if (nestCount === 0) {
599                         return throwUnexpectedTokenError(token.value, token);
600                     }
601                     if (token.type === "Punctuator" && token.value === "(") {
602                         nestCount += 1;
603                     }
604                     if (token.type === "Punctuator" && token.value === ")") {
605                         nestCount -= 1;
606                     }
607                 }
608                 const token = last(ast.tokens);
609                 return throwUnexpectedTokenError(token.value, token);
610             }
611             for (const argument of callExpression.arguments) {
612                 argument.parent = expression;
613                 expression.arguments.push(argument);
614             }
615             tokens.push(...ast.tokens);
616             comments.push(...ast.comments);
617             references.push(...analyzeExternalReferences(ast, parserOptions));
618         }
619         const firstToken = tokens[0];
620         const lastToken = last(tokens);
621         expression.range = [firstToken.range[0], lastToken.range[1]];
622         expression.loc = { start: firstToken.loc.start, end: lastToken.loc.end };
623         return { expression, tokens, comments, references, variables: [] };
624     }
625     catch (err) {
626         return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
627     }
628 }
629 function parseScript(code, parserOptions) {
630     const parser = typeof parserOptions.parser === "string"
631         ?
632             require(parserOptions.parser)
633         : getEspree();
634     const result = typeof parser.parseForESLint === "function"
635         ? parser.parseForESLint(code, parserOptions)
636         : parser.parse(code, parserOptions);
637     if (result.ast != null) {
638         return result;
639     }
640     return { ast: result };
641 }
642 function parseScriptElement(node, globalLocationCalculator, parserOptions) {
643     const text = node.children[0];
644     const offset = text != null && text.type === "VText"
645         ? text.range[0]
646         : node.startTag.range[1];
647     const code = text != null && text.type === "VText" ? text.value : "";
648     const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(offset);
649     const result = parseScriptFragment(code, locationCalculator, parserOptions);
650     if (result.ast.tokens != null) {
651         const startTag = node.startTag;
652         const endTag = node.endTag;
653         if (startTag != null) {
654             result.ast.tokens.unshift({
655                 type: "Punctuator",
656                 range: startTag.range,
657                 loc: startTag.loc,
658                 value: "<script>",
659             });
660         }
661         if (endTag != null) {
662             result.ast.tokens.push({
663                 type: "Punctuator",
664                 range: endTag.range,
665                 loc: endTag.loc,
666                 value: "</script>",
667             });
668         }
669     }
670     return result;
671 }
672 function parseExpression(code, locationCalculator, parserOptions, { allowEmpty = false, allowFilters = false } = {}) {
673     debug('[script] parse expression: "%s"', code);
674     const [mainCode, ...filterCodes] = allowFilters
675         ? splitFilters(code)
676         : [code];
677     if (filterCodes.length === 0) {
678         return parseExpressionBody(code, locationCalculator, parserOptions, allowEmpty);
679     }
680     const retB = parseExpressionBody(mainCode, locationCalculator, parserOptions);
681     if (!retB.expression) {
682         return retB;
683     }
684     const ret = retB;
685     ret.expression = {
686         type: "VFilterSequenceExpression",
687         parent: null,
688         expression: retB.expression,
689         filters: [],
690         range: retB.expression.range.slice(0),
691         loc: Object.assign({}, retB.expression.loc),
692     };
693     ret.expression.expression.parent = ret.expression;
694     let prevLoc = mainCode.length;
695     for (const filterCode of filterCodes) {
696         ret.tokens.push(locationCalculator.fixLocation({
697             type: "Punctuator",
698             value: "|",
699             range: [prevLoc, prevLoc + 1],
700             loc: {},
701         }));
702         const retF = parseFilter(filterCode, locationCalculator.getSubCalculatorShift(prevLoc + 1), parserOptions);
703         if (retF) {
704             if (retF.expression) {
705                 ret.expression.filters.push(retF.expression);
706                 retF.expression.parent = ret.expression;
707             }
708             ret.tokens.push(...retF.tokens);
709             ret.comments.push(...retF.comments);
710             ret.references.push(...retF.references);
711         }
712         prevLoc += 1 + filterCode.length;
713     }
714     const lastToken = last(ret.tokens);
715     ret.expression.range[1] = lastToken.range[1];
716     ret.expression.loc.end = lastToken.loc.end;
717     return ret;
718 }
719 function parseVForExpression(code, locationCalculator, parserOptions) {
720     const processedCode = replaceAliasParens(code);
721     debug('[script] parse v-for expression: "for(%s);"', processedCode);
722     if (code.trim() === "") {
723         throwEmptyError(locationCalculator, "'<alias> in <expression>'");
724     }
725     try {
726         const replaced = processedCode !== code;
727         const ast = parseScriptFragment(`for(let ${processedCode});`, locationCalculator.getSubCalculatorShift(-8), parserOptions).ast;
728         const tokens = ast.tokens || [];
729         const comments = ast.comments || [];
730         const scope = analyzeVariablesAndExternalReferences(ast, parserOptions);
731         const references = scope.references;
732         const variables = scope.variables;
733         const statement = ast.body[0];
734         const left = normalizeLeft(statement.left, replaced);
735         const right = statement.right;
736         const firstToken = tokens[3] || statement.left;
737         const lastToken = tokens[tokens.length - 3] || statement.right;
738         const expression = {
739             type: "VForExpression",
740             range: [firstToken.range[0], lastToken.range[1]],
741             loc: { start: firstToken.loc.start, end: lastToken.loc.end },
742             parent: DUMMY_PARENT,
743             left,
744             right,
745         };
746         for (const l of left) {
747             if (l != null) {
748                 l.parent = expression;
749             }
750         }
751         right.parent = expression;
752         tokens.shift();
753         tokens.shift();
754         tokens.shift();
755         tokens.pop();
756         tokens.pop();
757         if (replaced) {
758             const closeOffset = statement.left.range[1] - 1;
759             const open = tokens[0];
760             const close = tokens.find(t => t.range[0] === closeOffset);
761             if (open != null) {
762                 open.value = "(";
763             }
764             if (close != null) {
765                 close.value = ")";
766             }
767         }
768         return { expression, tokens, comments, references, variables };
769     }
770     catch (err) {
771         return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
772     }
773 }
774 function parseVOnExpression(code, locationCalculator, parserOptions) {
775     if (IS_FUNCTION_EXPRESSION.test(code) || IS_SIMPLE_PATH.test(code)) {
776         return parseExpressionBody(code, locationCalculator, parserOptions);
777     }
778     return parseVOnExpressionBody(code, locationCalculator, parserOptions);
779 }
780 function parseVOnExpressionBody(code, locationCalculator, parserOptions) {
781     debug('[script] parse v-on expression: "void function($event){%s}"', code);
782     if (code.trim() === "") {
783         throwEmptyError(locationCalculator, "statements");
784     }
785     try {
786         const ast = parseScriptFragment(`void function($event){${code}}`, locationCalculator.getSubCalculatorShift(-22), parserOptions).ast;
787         const references = analyzeExternalReferences(ast, parserOptions);
788         const outermostStatement = ast.body[0];
789         const functionDecl = outermostStatement.expression
790             .argument;
791         const block = functionDecl.body;
792         const body = block.body;
793         const firstStatement = first(body);
794         const lastStatement = last(body);
795         const expression = {
796             type: "VOnExpression",
797             range: [
798                 firstStatement != null
799                     ? firstStatement.range[0]
800                     : block.range[0] + 1,
801                 lastStatement != null
802                     ? lastStatement.range[1]
803                     : block.range[1] - 1,
804             ],
805             loc: {
806                 start: firstStatement != null
807                     ? firstStatement.loc.start
808                     : locationCalculator.getLocation(1),
809                 end: lastStatement != null
810                     ? lastStatement.loc.end
811                     : locationCalculator.getLocation(code.length + 1),
812             },
813             parent: DUMMY_PARENT,
814             body,
815         };
816         const tokens = ast.tokens || [];
817         const comments = ast.comments || [];
818         for (const b of body) {
819             b.parent = expression;
820         }
821         tokens.splice(0, 6);
822         tokens.pop();
823         return { expression, tokens, comments, references, variables: [] };
824     }
825     catch (err) {
826         return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
827     }
828 }
829 function parseSlotScopeExpression(code, locationCalculator, parserOptions) {
830     debug('[script] parse slot-scope expression: "void function(%s) {}"', code);
831     if (code.trim() === "") {
832         throwEmptyError(locationCalculator, "an identifier or an array/object pattern");
833     }
834     try {
835         const ast = parseScriptFragment(`void function(${code}) {}`, locationCalculator.getSubCalculatorShift(-14), parserOptions).ast;
836         const statement = ast.body[0];
837         const rawExpression = statement.expression;
838         const functionDecl = rawExpression.argument;
839         const params = functionDecl.params;
840         if (params.length === 0) {
841             return {
842                 expression: null,
843                 tokens: [],
844                 comments: [],
845                 references: [],
846                 variables: [],
847             };
848         }
849         const tokens = ast.tokens || [];
850         const comments = ast.comments || [];
851         const scope = analyzeVariablesAndExternalReferences(ast, parserOptions);
852         const references = scope.references;
853         const variables = scope.variables;
854         const firstParam = first(params);
855         const lastParam = last(params);
856         const expression = {
857             type: "VSlotScopeExpression",
858             range: [firstParam.range[0], lastParam.range[1]],
859             loc: { start: firstParam.loc.start, end: lastParam.loc.end },
860             parent: DUMMY_PARENT,
861             params: functionDecl.params,
862         };
863         for (const param of params) {
864             param.parent = expression;
865         }
866         tokens.shift();
867         tokens.shift();
868         tokens.shift();
869         tokens.pop();
870         tokens.pop();
871         tokens.pop();
872         return { expression, tokens, comments, references, variables };
873     }
874     catch (err) {
875         return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
876     }
877 }
878
879 const shorthandSign = /^[.:@#]/u;
880 const shorthandNameMap = { ":": "bind", ".": "bind", "@": "on", "#": "slot" };
881 const invalidDynamicArgumentNextChar = /^[\s\r\n=/>]$/u;
882 function getOwnerDocument(leafNode) {
883     let node = leafNode;
884     while (node != null && node.type !== "VDocumentFragment") {
885         node = node.parent;
886     }
887     return node;
888 }
889 function createSimpleToken(type, start, end, value, globalLocationCalculator) {
890     return {
891         type,
892         range: [start, end],
893         loc: {
894             start: globalLocationCalculator.getLocation(start),
895             end: globalLocationCalculator.getLocation(end),
896         },
897         value,
898     };
899 }
900 function parseDirectiveKeyStatically(node, document) {
901     const { name: text, rawName: rawText, range: [offset], loc: { start: { column, line }, }, } = node;
902     const directiveKey = {
903         type: "VDirectiveKey",
904         range: node.range,
905         loc: node.loc,
906         parent: node.parent,
907         name: null,
908         argument: null,
909         modifiers: [],
910     };
911     let i = 0;
912     function createIdentifier(start, end, name) {
913         return {
914             type: "VIdentifier",
915             parent: directiveKey,
916             range: [offset + start, offset + end],
917             loc: {
918                 start: { column: column + start, line },
919                 end: { column: column + end, line },
920             },
921             name: name || text.slice(start, end),
922             rawName: rawText.slice(start, end),
923         };
924     }
925     if (shorthandSign.test(text)) {
926         const sign = text[0];
927         directiveKey.name = createIdentifier(0, 1, shorthandNameMap[sign]);
928         i = 1;
929     }
930     else {
931         const colon = text.indexOf(":");
932         if (colon !== -1) {
933             directiveKey.name = createIdentifier(0, colon);
934             i = colon + 1;
935         }
936     }
937     if (directiveKey.name != null && text[i] === "[") {
938         const len = text.slice(i).lastIndexOf("]");
939         if (len !== -1) {
940             directiveKey.argument = createIdentifier(i, i + len + 1);
941             i = i + len + 1 + (text[i + len + 1] === "." ? 1 : 0);
942         }
943     }
944     const modifiers = text
945         .slice(i)
946         .split(".")
947         .map(modifierName => {
948         const modifier = createIdentifier(i, i + modifierName.length);
949         if (modifierName === "" && i < text.length) {
950             insertError(document, new ParseError(`Unexpected token '${text[i]}'`, undefined, offset + i, line, column + i));
951         }
952         i += modifierName.length + 1;
953         return modifier;
954     });
955     if (directiveKey.name == null) {
956         directiveKey.name = modifiers.shift();
957     }
958     else if (directiveKey.argument == null && modifiers[0].name !== "") {
959         directiveKey.argument = modifiers.shift() || null;
960     }
961     directiveKey.modifiers = modifiers.filter(isNotEmptyModifier);
962     if (directiveKey.name.name === "v-") {
963         insertError(document, new ParseError(`Unexpected token '${text[directiveKey.name.range[1] - offset]}'`, undefined, directiveKey.name.range[1], directiveKey.name.loc.end.line, directiveKey.name.loc.end.column));
964     }
965     if (directiveKey.name.rawName === "." &&
966         !directiveKey.modifiers.some(isPropModifier)) {
967         const pos = (directiveKey.argument || directiveKey.name).range[1] - offset;
968         const propModifier = createIdentifier(pos, pos, "prop");
969         directiveKey.modifiers.unshift(propModifier);
970     }
971     return directiveKey;
972 }
973 function isPropModifier(node) {
974     return node.name === "prop";
975 }
976 function isNotEmptyModifier(node) {
977     return node.name !== "";
978 }
979 function parseDirectiveKeyTokens(node) {
980     const { name, argument, modifiers } = node;
981     const shorthand = name.range[1] - name.range[0] === 1;
982     const tokens = [];
983     if (shorthand) {
984         tokens.push({
985             type: "Punctuator",
986             range: name.range,
987             loc: name.loc,
988             value: name.rawName,
989         });
990     }
991     else {
992         tokens.push({
993             type: "HTMLIdentifier",
994             range: name.range,
995             loc: name.loc,
996             value: name.rawName,
997         });
998         if (argument) {
999             tokens.push({
1000                 type: "Punctuator",
1001                 range: [name.range[1], argument.range[0]],
1002                 loc: { start: name.loc.end, end: argument.loc.start },
1003                 value: ":",
1004             });
1005         }
1006     }
1007     if (argument) {
1008         tokens.push({
1009             type: "HTMLIdentifier",
1010             range: argument.range,
1011             loc: argument.loc,
1012             value: argument.rawName,
1013         });
1014     }
1015     let lastNode = argument || name;
1016     for (const modifier of modifiers) {
1017         if (modifier.rawName === "") {
1018             continue;
1019         }
1020         tokens.push({
1021             type: "Punctuator",
1022             range: [lastNode.range[1], modifier.range[0]],
1023             loc: { start: lastNode.loc.end, end: modifier.loc.start },
1024             value: ".",
1025         }, {
1026             type: "HTMLIdentifier",
1027             range: modifier.range,
1028             loc: modifier.loc,
1029             value: modifier.rawName,
1030         });
1031         lastNode = modifier;
1032     }
1033     return tokens;
1034 }
1035 function convertDynamicArgument(node, document, parserOptions, locationCalculator) {
1036     const { argument } = node;
1037     if (!(argument != null &&
1038         argument.type === "VIdentifier" &&
1039         argument.name.startsWith("[") &&
1040         argument.name.endsWith("]"))) {
1041         return;
1042     }
1043     const { rawName, range, loc } = argument;
1044     try {
1045         const { comments, expression, references, tokens } = parseExpression(rawName.slice(1, -1), locationCalculator.getSubCalculatorAfter(range[0] + 1), parserOptions);
1046         node.argument = {
1047             type: "VExpressionContainer",
1048             range,
1049             loc,
1050             parent: node,
1051             expression,
1052             references,
1053         };
1054         if (expression != null) {
1055             expression.parent = node.argument;
1056         }
1057         tokens.unshift(createSimpleToken("Punctuator", range[0], range[0] + 1, "[", locationCalculator));
1058         tokens.push(createSimpleToken("Punctuator", range[1] - 1, range[1], "]", locationCalculator));
1059         replaceTokens(document, node.argument, tokens);
1060         insertComments(document, comments);
1061     }
1062     catch (error) {
1063         debug("[template] Parse error: %s", error);
1064         if (ParseError.isParseError(error)) {
1065             node.argument = {
1066                 type: "VExpressionContainer",
1067                 range,
1068                 loc,
1069                 parent: node,
1070                 expression: null,
1071                 references: [],
1072             };
1073             insertError(document, error);
1074         }
1075         else {
1076             throw error;
1077         }
1078     }
1079 }
1080 function createDirectiveKey(node, document, parserOptions, locationCalculator) {
1081     const directiveKey = parseDirectiveKeyStatically(node, document);
1082     const tokens = parseDirectiveKeyTokens(directiveKey);
1083     replaceTokens(document, directiveKey, tokens);
1084     if (directiveKey.name.name.startsWith("v-")) {
1085         directiveKey.name.name = directiveKey.name.name.slice(2);
1086     }
1087     if (directiveKey.name.rawName.startsWith("v-")) {
1088         directiveKey.name.rawName = directiveKey.name.rawName.slice(2);
1089     }
1090     convertDynamicArgument(directiveKey, document, parserOptions, locationCalculator);
1091     return directiveKey;
1092 }
1093 function byRange0(x) {
1094     return x.range[0];
1095 }
1096 function byRange1(x) {
1097     return x.range[1];
1098 }
1099 function byIndex(x) {
1100     return x.index;
1101 }
1102 function replaceTokens(document, node, newTokens) {
1103     if (document == null) {
1104         return;
1105     }
1106     const index = sortedIndexBy(document.tokens, node, byRange0);
1107     const count = sortedLastIndexBy(document.tokens, node, byRange1) - index;
1108     document.tokens.splice(index, count, ...newTokens);
1109 }
1110 function insertComments(document, newComments) {
1111     if (document == null || newComments.length === 0) {
1112         return;
1113     }
1114     const index = sortedIndexBy(document.comments, newComments[0], byRange0);
1115     document.comments.splice(index, 0, ...newComments);
1116 }
1117 function insertError(document, error) {
1118     if (document == null) {
1119         return;
1120     }
1121     const index = sortedIndexBy(document.errors, error, byIndex);
1122     document.errors.splice(index, 0, error);
1123 }
1124 function parseAttributeValue(code, parserOptions, globalLocationCalculator, node, tagName, directiveKey) {
1125     const firstChar = code[node.range[0]];
1126     const quoted = firstChar === '"' || firstChar === "'";
1127     const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(node.range[0] + (quoted ? 1 : 0));
1128     const directiveName = directiveKey.name.name;
1129     let result;
1130     if (quoted && node.value === "") {
1131         result = {
1132             expression: null,
1133             tokens: [],
1134             comments: [],
1135             variables: [],
1136             references: [],
1137         };
1138     }
1139     else if (directiveName === "for") {
1140         result = parseVForExpression(node.value, locationCalculator, parserOptions);
1141     }
1142     else if (directiveName === "on" && directiveKey.argument != null) {
1143         result = parseVOnExpression(node.value, locationCalculator, parserOptions);
1144     }
1145     else if (directiveName === "slot" ||
1146         directiveName === "slot-scope" ||
1147         (tagName === "template" && directiveName === "scope")) {
1148         result = parseSlotScopeExpression(node.value, locationCalculator, parserOptions);
1149     }
1150     else if (directiveName === "bind") {
1151         result = parseExpression(node.value, locationCalculator, parserOptions, { allowFilters: true });
1152     }
1153     else {
1154         result = parseExpression(node.value, locationCalculator, parserOptions);
1155     }
1156     if (quoted) {
1157         result.tokens.unshift(createSimpleToken("Punctuator", node.range[0], node.range[0] + 1, firstChar, globalLocationCalculator));
1158         result.tokens.push(createSimpleToken("Punctuator", node.range[1] - 1, node.range[1], firstChar, globalLocationCalculator));
1159     }
1160     return result;
1161 }
1162 function resolveReference(referene, element) {
1163     let node = element;
1164     while (node != null && node.type === "VElement") {
1165         for (const variable of node.variables) {
1166             if (variable.id.name === referene.id.name) {
1167                 referene.variable = variable;
1168                 variable.references.push(referene);
1169                 return;
1170             }
1171         }
1172         node = node.parent;
1173     }
1174 }
1175 function convertToDirective(code, parserOptions, locationCalculator, node) {
1176     debug('[template] convert to directive: %s="%s" %j', node.key.name, node.value && node.value.value, node.range);
1177     const document = getOwnerDocument(node);
1178     const directive = node;
1179     directive.directive = true;
1180     directive.key = createDirectiveKey(node.key, document, parserOptions, locationCalculator);
1181     const { argument } = directive.key;
1182     if (argument &&
1183         argument.type === "VIdentifier" &&
1184         argument.name.startsWith("[")) {
1185         const nextChar = code[argument.range[1]];
1186         if (nextChar == null || invalidDynamicArgumentNextChar.test(nextChar)) {
1187             const char = nextChar == null ? "EOF" : JSON.stringify(nextChar).slice(1, -1);
1188             insertError(document, new ParseError(`Dynamic argument cannot contain the '${char}' character.`, undefined, argument.range[1], argument.loc.end.line, argument.loc.end.column));
1189         }
1190     }
1191     if (node.value == null) {
1192         return;
1193     }
1194     try {
1195         const ret = parseAttributeValue(code, parserOptions, locationCalculator, node.value, node.parent.parent.name, directive.key);
1196         directive.value = {
1197             type: "VExpressionContainer",
1198             range: node.value.range,
1199             loc: node.value.loc,
1200             parent: directive,
1201             expression: ret.expression,
1202             references: ret.references,
1203         };
1204         if (ret.expression != null) {
1205             ret.expression.parent = directive.value;
1206         }
1207         for (const variable of ret.variables) {
1208             node.parent.parent.variables.push(variable);
1209         }
1210         replaceTokens(document, node.value, ret.tokens);
1211         insertComments(document, ret.comments);
1212     }
1213     catch (err) {
1214         debug("[template] Parse error: %s", err);
1215         if (ParseError.isParseError(err)) {
1216             directive.value = {
1217                 type: "VExpressionContainer",
1218                 range: node.value.range,
1219                 loc: node.value.loc,
1220                 parent: directive,
1221                 expression: null,
1222                 references: [],
1223             };
1224             insertError(document, err);
1225         }
1226         else {
1227             throw err;
1228         }
1229     }
1230 }
1231 function processMustache(parserOptions, globalLocationCalculator, node, mustache) {
1232     const range = [
1233         mustache.startToken.range[1],
1234         mustache.endToken.range[0],
1235     ];
1236     debug("[template] convert mustache {{%s}} %j", mustache.value, range);
1237     const document = getOwnerDocument(node);
1238     try {
1239         const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(range[0]);
1240         const ret = parseExpression(mustache.value, locationCalculator, parserOptions, { allowEmpty: true, allowFilters: true });
1241         node.expression = ret.expression || null;
1242         node.references = ret.references;
1243         if (ret.expression != null) {
1244             ret.expression.parent = node;
1245         }
1246         replaceTokens(document, { range }, ret.tokens);
1247         insertComments(document, ret.comments);
1248     }
1249     catch (err) {
1250         debug("[template] Parse error: %s", err);
1251         if (ParseError.isParseError(err)) {
1252             insertError(document, err);
1253         }
1254         else {
1255             throw err;
1256         }
1257     }
1258 }
1259 function resolveReferences(container) {
1260     let element = container.parent;
1261     while (element != null && element.type !== "VElement") {
1262         element = element.parent;
1263     }
1264     if (element != null) {
1265         for (const reference of container.references) {
1266             resolveReference(reference, element);
1267         }
1268     }
1269 }
1270
1271 const SVG_ATTRIBUTE_NAME_MAP = new Map([
1272     ["attributename", "attributeName"],
1273     ["attributetype", "attributeType"],
1274     ["basefrequency", "baseFrequency"],
1275     ["baseprofile", "baseProfile"],
1276     ["calcmode", "calcMode"],
1277     ["clippathunits", "clipPathUnits"],
1278     ["diffuseconstant", "diffuseConstant"],
1279     ["edgemode", "edgeMode"],
1280     ["filterunits", "filterUnits"],
1281     ["glyphref", "glyphRef"],
1282     ["gradienttransform", "gradientTransform"],
1283     ["gradientunits", "gradientUnits"],
1284     ["kernelmatrix", "kernelMatrix"],
1285     ["kernelunitlength", "kernelUnitLength"],
1286     ["keypoints", "keyPoints"],
1287     ["keysplines", "keySplines"],
1288     ["keytimes", "keyTimes"],
1289     ["lengthadjust", "lengthAdjust"],
1290     ["limitingconeangle", "limitingConeAngle"],
1291     ["markerheight", "markerHeight"],
1292     ["markerunits", "markerUnits"],
1293     ["markerwidth", "markerWidth"],
1294     ["maskcontentunits", "maskContentUnits"],
1295     ["maskunits", "maskUnits"],
1296     ["numoctaves", "numOctaves"],
1297     ["pathlength", "pathLength"],
1298     ["patterncontentunits", "patternContentUnits"],
1299     ["patterntransform", "patternTransform"],
1300     ["patternunits", "patternUnits"],
1301     ["pointsatx", "pointsAtX"],
1302     ["pointsaty", "pointsAtY"],
1303     ["pointsatz", "pointsAtZ"],
1304     ["preservealpha", "preserveAlpha"],
1305     ["preserveaspectratio", "preserveAspectRatio"],
1306     ["primitiveunits", "primitiveUnits"],
1307     ["refx", "refX"],
1308     ["refy", "refY"],
1309     ["repeatcount", "repeatCount"],
1310     ["repeatdur", "repeatDur"],
1311     ["requiredextensions", "requiredExtensions"],
1312     ["requiredfeatures", "requiredFeatures"],
1313     ["specularconstant", "specularConstant"],
1314     ["specularexponent", "specularExponent"],
1315     ["spreadmethod", "spreadMethod"],
1316     ["startoffset", "startOffset"],
1317     ["stddeviation", "stdDeviation"],
1318     ["stitchtiles", "stitchTiles"],
1319     ["surfacescale", "surfaceScale"],
1320     ["systemlanguage", "systemLanguage"],
1321     ["tablevalues", "tableValues"],
1322     ["targetx", "targetX"],
1323     ["targety", "targetY"],
1324     ["textlength", "textLength"],
1325     ["viewbox", "viewBox"],
1326     ["viewtarget", "viewTarget"],
1327     ["xchannelselector", "xChannelSelector"],
1328     ["ychannelselector", "yChannelSelector"],
1329     ["zoomandpan", "zoomAndPan"],
1330 ]);
1331 const MATHML_ATTRIBUTE_NAME_MAP = new Map([
1332     ["definitionurl", "definitionUrl"]
1333 ]);
1334
1335 const HTML_VOID_ELEMENT_TAGS = new Set([
1336     "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta",
1337     "param", "source", "track", "wbr",
1338 ]);
1339 const HTML_CAN_BE_LEFT_OPEN_TAGS = new Set([
1340     "colgroup", "li", "options", "p", "td", "tfoot", "th", "thead",
1341     "tr", "source",
1342 ]);
1343 const HTML_NON_FHRASING_TAGS = new Set([
1344     "address", "article", "aside", "base", "blockquote", "body", "caption",
1345     "col", "colgroup", "dd", "details", "dialog", "div", "dl", "dt", "fieldset",
1346     "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5",
1347     "h6", "head", "header", "hgroup", "hr", "html", "legend", "li", "menuitem",
1348     "meta", "optgroup", "option", "param", "rp", "rt", "source", "style",
1349     "summary", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track",
1350 ]);
1351 const HTML_RCDATA_TAGS = new Set([
1352     "title", "textarea",
1353 ]);
1354 const HTML_RAWTEXT_TAGS = new Set([
1355     "style", "xmp", "iframe", "noembed", "noframes", "noscript", "script",
1356 ]);
1357 const SVG_TAGS = new Set([
1358     "a", "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor",
1359     "animateMotion", "animateTransform", "animation", "audio", "canvas",
1360     "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "discard",
1361     "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite",
1362     "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap",
1363     "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB",
1364     "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode",
1365     "feMorphology", "feOffset", "fePointLight", "feSpecularLighting",
1366     "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face",
1367     "font-face-format", "font-face-name", "font-face-src", "font-face-uri",
1368     "foreignObject", "g", "glyph", "glyphRef", "handler", "hatch", "hatchpath",
1369     "hkern", "iframe", "image", "line", "linearGradient", "listener", "marker",
1370     "mask", "mesh", "meshgradient", "meshpatch", "meshrow", "metadata",
1371     "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline",
1372     "prefetch", "radialGradient", "rect", "script", "set", "solidColor",
1373     "solidcolor", "stop", "style", "svg", "switch", "symbol", "tbreak", "text",
1374     "textArea", "textPath", "title", "tref", "tspan", "unknown", "use", "video",
1375     "view", "vkern",
1376 ]);
1377 const SVG_ELEMENT_NAME_MAP = new Map();
1378 for (const name of SVG_TAGS) {
1379     if (/[A-Z]/.test(name)) {
1380         SVG_ELEMENT_NAME_MAP.set(name.toLowerCase(), name);
1381     }
1382 }
1383
1384 const DUMMY_PARENT$1 = Object.freeze({});
1385 function concat(text, token) {
1386     return text + token.value;
1387 }
1388 class IntermediateTokenizer {
1389     get text() {
1390         return this.tokenizer.text;
1391     }
1392     get errors() {
1393         return this.tokenizer.errors;
1394     }
1395     get state() {
1396         return this.tokenizer.state;
1397     }
1398     set state(value) {
1399         this.tokenizer.state = value;
1400     }
1401     get namespace() {
1402         return this.tokenizer.namespace;
1403     }
1404     set namespace(value) {
1405         this.tokenizer.namespace = value;
1406     }
1407     get expressionEnabled() {
1408         return this.tokenizer.expressionEnabled;
1409     }
1410     set expressionEnabled(value) {
1411         this.tokenizer.expressionEnabled = value;
1412     }
1413     constructor(tokenizer) {
1414         this.tokenizer = tokenizer;
1415         this.currentToken = null;
1416         this.attribute = null;
1417         this.attributeNames = new Set();
1418         this.expressionStartToken = null;
1419         this.expressionTokens = [];
1420         this.tokens = [];
1421         this.comments = [];
1422     }
1423     nextToken() {
1424         let token = null;
1425         let result = null;
1426         while (result == null && (token = this.tokenizer.nextToken()) != null) {
1427             result = this[token.type](token);
1428         }
1429         if (result == null && token == null && this.currentToken != null) {
1430             result = this.commit();
1431         }
1432         return result;
1433     }
1434     commit() {
1435         assert(this.currentToken != null || this.expressionStartToken != null);
1436         let token = this.currentToken;
1437         this.currentToken = null;
1438         this.attribute = null;
1439         if (this.expressionStartToken != null) {
1440             const start = this.expressionStartToken;
1441             const end = last(this.expressionTokens) || start;
1442             const value = this.expressionTokens.reduce(concat, start.value);
1443             this.expressionStartToken = null;
1444             this.expressionTokens = [];
1445             if (token == null) {
1446                 token = {
1447                     type: "Text",
1448                     range: [start.range[0], end.range[1]],
1449                     loc: { start: start.loc.start, end: end.loc.end },
1450                     value,
1451                 };
1452             }
1453             else if (token.type === "Text") {
1454                 token.range[1] = end.range[1];
1455                 token.loc.end = end.loc.end;
1456                 token.value += value;
1457             }
1458             else {
1459                 throw new Error("unreachable");
1460             }
1461         }
1462         return token;
1463     }
1464     reportParseError(token, code) {
1465         const error = ParseError.fromCode(code, token.range[0], token.loc.start.line, token.loc.start.column);
1466         this.errors.push(error);
1467         debug("[html] syntax error:", error.message);
1468     }
1469     processComment(token) {
1470         this.comments.push(token);
1471         if (this.currentToken != null && this.currentToken.type === "Text") {
1472             return this.commit();
1473         }
1474         return null;
1475     }
1476     processText(token) {
1477         this.tokens.push(token);
1478         let result = null;
1479         if (this.expressionStartToken != null) {
1480             const lastToken = last(this.expressionTokens) || this.expressionStartToken;
1481             if (lastToken.range[1] === token.range[0]) {
1482                 this.expressionTokens.push(token);
1483                 return null;
1484             }
1485             result = this.commit();
1486         }
1487         else if (this.currentToken != null) {
1488             if (this.currentToken.type === "Text" &&
1489                 this.currentToken.range[1] === token.range[0]) {
1490                 this.currentToken.value += token.value;
1491                 this.currentToken.range[1] = token.range[1];
1492                 this.currentToken.loc.end = token.loc.end;
1493                 return null;
1494             }
1495             result = this.commit();
1496         }
1497         assert(this.currentToken == null);
1498         this.currentToken = {
1499             type: "Text",
1500             range: [token.range[0], token.range[1]],
1501             loc: { start: token.loc.start, end: token.loc.end },
1502             value: token.value,
1503         };
1504         return result;
1505     }
1506     HTMLAssociation(token) {
1507         this.tokens.push(token);
1508         if (this.attribute != null) {
1509             this.attribute.range[1] = token.range[1];
1510             this.attribute.loc.end = token.loc.end;
1511             if (this.currentToken == null ||
1512                 this.currentToken.type !== "StartTag") {
1513                 throw new Error("unreachable");
1514             }
1515             this.currentToken.range[1] = token.range[1];
1516             this.currentToken.loc.end = token.loc.end;
1517         }
1518         return null;
1519     }
1520     HTMLBogusComment(token) {
1521         return this.processComment(token);
1522     }
1523     HTMLCDataText(token) {
1524         return this.processText(token);
1525     }
1526     HTMLComment(token) {
1527         return this.processComment(token);
1528     }
1529     HTMLEndTagOpen(token) {
1530         this.tokens.push(token);
1531         let result = null;
1532         if (this.currentToken != null || this.expressionStartToken != null) {
1533             result = this.commit();
1534         }
1535         this.currentToken = {
1536             type: "EndTag",
1537             range: [token.range[0], token.range[1]],
1538             loc: { start: token.loc.start, end: token.loc.end },
1539             name: token.value,
1540         };
1541         return result;
1542     }
1543     HTMLIdentifier(token) {
1544         this.tokens.push(token);
1545         if (this.currentToken == null ||
1546             this.currentToken.type === "Text" ||
1547             this.currentToken.type === "Mustache") {
1548             throw new Error("unreachable");
1549         }
1550         if (this.currentToken.type === "EndTag") {
1551             this.reportParseError(token, "end-tag-with-attributes");
1552             return null;
1553         }
1554         if (this.attributeNames.has(token.value)) {
1555             this.reportParseError(token, "duplicate-attribute");
1556         }
1557         this.attributeNames.add(token.value);
1558         this.attribute = {
1559             type: "VAttribute",
1560             range: [token.range[0], token.range[1]],
1561             loc: { start: token.loc.start, end: token.loc.end },
1562             parent: DUMMY_PARENT$1,
1563             directive: false,
1564             key: {
1565                 type: "VIdentifier",
1566                 range: [token.range[0], token.range[1]],
1567                 loc: { start: token.loc.start, end: token.loc.end },
1568                 parent: DUMMY_PARENT$1,
1569                 name: token.value,
1570                 rawName: this.text.slice(token.range[0], token.range[1]),
1571             },
1572             value: null,
1573         };
1574         this.attribute.key.parent = this.attribute;
1575         this.currentToken.range[1] = token.range[1];
1576         this.currentToken.loc.end = token.loc.end;
1577         this.currentToken.attributes.push(this.attribute);
1578         return null;
1579     }
1580     HTMLLiteral(token) {
1581         this.tokens.push(token);
1582         if (this.attribute != null) {
1583             this.attribute.range[1] = token.range[1];
1584             this.attribute.loc.end = token.loc.end;
1585             this.attribute.value = {
1586                 type: "VLiteral",
1587                 range: [token.range[0], token.range[1]],
1588                 loc: { start: token.loc.start, end: token.loc.end },
1589                 parent: this.attribute,
1590                 value: token.value,
1591             };
1592             if (this.currentToken == null ||
1593                 this.currentToken.type !== "StartTag") {
1594                 throw new Error("unreachable");
1595             }
1596             this.currentToken.range[1] = token.range[1];
1597             this.currentToken.loc.end = token.loc.end;
1598         }
1599         return null;
1600     }
1601     HTMLRCDataText(token) {
1602         return this.processText(token);
1603     }
1604     HTMLRawText(token) {
1605         return this.processText(token);
1606     }
1607     HTMLSelfClosingTagClose(token) {
1608         this.tokens.push(token);
1609         if (this.currentToken == null || this.currentToken.type === "Text") {
1610             throw new Error("unreachable");
1611         }
1612         if (this.currentToken.type === "StartTag") {
1613             this.currentToken.selfClosing = true;
1614         }
1615         else {
1616             this.reportParseError(token, "end-tag-with-trailing-solidus");
1617         }
1618         this.currentToken.range[1] = token.range[1];
1619         this.currentToken.loc.end = token.loc.end;
1620         return this.commit();
1621     }
1622     HTMLTagClose(token) {
1623         this.tokens.push(token);
1624         if (this.currentToken == null || this.currentToken.type === "Text") {
1625             throw new Error("unreachable");
1626         }
1627         this.currentToken.range[1] = token.range[1];
1628         this.currentToken.loc.end = token.loc.end;
1629         return this.commit();
1630     }
1631     HTMLTagOpen(token) {
1632         this.tokens.push(token);
1633         let result = null;
1634         if (this.currentToken != null || this.expressionStartToken != null) {
1635             result = this.commit();
1636         }
1637         this.currentToken = {
1638             type: "StartTag",
1639             range: [token.range[0], token.range[1]],
1640             loc: { start: token.loc.start, end: token.loc.end },
1641             name: token.value,
1642             rawName: this.text.slice(token.range[0] + 1, token.range[1]),
1643             selfClosing: false,
1644             attributes: [],
1645         };
1646         this.attribute = null;
1647         this.attributeNames.clear();
1648         return result;
1649     }
1650     HTMLText(token) {
1651         return this.processText(token);
1652     }
1653     HTMLWhitespace(token) {
1654         return this.processText(token);
1655     }
1656     VExpressionStart(token) {
1657         if (this.expressionStartToken != null) {
1658             return this.processText(token);
1659         }
1660         const separated = this.currentToken != null &&
1661             this.currentToken.range[1] !== token.range[0];
1662         const result = separated ? this.commit() : null;
1663         this.tokens.push(token);
1664         this.expressionStartToken = token;
1665         return result;
1666     }
1667     VExpressionEnd(token) {
1668         if (this.expressionStartToken == null) {
1669             return this.processText(token);
1670         }
1671         const start = this.expressionStartToken;
1672         const end = last(this.expressionTokens) || start;
1673         if (token.range[0] === start.range[1]) {
1674             this.tokens.pop();
1675             this.expressionStartToken = null;
1676             const result = this.processText(start);
1677             this.processText(token);
1678             return result;
1679         }
1680         if (end.range[1] !== token.range[0]) {
1681             const result = this.commit();
1682             this.processText(token);
1683             return result;
1684         }
1685         const value = this.expressionTokens.reduce(concat, "");
1686         this.tokens.push(token);
1687         this.expressionStartToken = null;
1688         this.expressionTokens = [];
1689         const result = this.currentToken != null ? this.commit() : null;
1690         this.currentToken = {
1691             type: "Mustache",
1692             range: [start.range[0], token.range[1]],
1693             loc: { start: start.loc.start, end: token.loc.end },
1694             value,
1695             startToken: start,
1696             endToken: token,
1697         };
1698         return result || this.commit();
1699     }
1700 }
1701
1702 const DIRECTIVE_NAME = /^(?:v-|[.:@#]).*[^.:@#]$/u;
1703 const DT_DD = /^d[dt]$/u;
1704 const DUMMY_PARENT$2 = Object.freeze({});
1705 function isMathMLIntegrationPoint(element) {
1706     if (element.namespace === NS.MathML) {
1707         const name = element.name;
1708         return (name === "mi" ||
1709             name === "mo" ||
1710             name === "mn" ||
1711             name === "ms" ||
1712             name === "mtext");
1713     }
1714     return false;
1715 }
1716 function isHTMLIntegrationPoint(element) {
1717     if (element.namespace === NS.MathML) {
1718         return (element.name === "annotation-xml" &&
1719             element.startTag.attributes.some(a => a.directive === false &&
1720                 a.key.name === "encoding" &&
1721                 a.value != null &&
1722                 (a.value.value === "text/html" ||
1723                     a.value.value === "application/xhtml+xml")));
1724     }
1725     if (element.namespace === NS.SVG) {
1726         const name = element.name;
1727         return name === "foreignObject" || name === "desc" || name === "title";
1728     }
1729     return false;
1730 }
1731 function adjustElementName(name, namespace) {
1732     if (namespace === NS.SVG) {
1733         return SVG_ELEMENT_NAME_MAP.get(name) || name;
1734     }
1735     return name;
1736 }
1737 function adjustAttributeName(name, namespace) {
1738     if (namespace === NS.SVG) {
1739         return SVG_ATTRIBUTE_NAME_MAP.get(name) || name;
1740     }
1741     if (namespace === NS.MathML) {
1742         return MATHML_ATTRIBUTE_NAME_MAP.get(name) || name;
1743     }
1744     return name;
1745 }
1746 function propagateEndLocation(node) {
1747     const lastChild = (node.type === "VElement" ? node.endTag : null) || last(node.children);
1748     if (lastChild != null) {
1749         node.range[1] = lastChild.range[1];
1750         node.loc.end = lastChild.loc.end;
1751     }
1752 }
1753 class Parser {
1754     get text() {
1755         return this.tokenizer.text;
1756     }
1757     get tokens() {
1758         return this.tokenizer.tokens;
1759     }
1760     get comments() {
1761         return this.tokenizer.comments;
1762     }
1763     get errors() {
1764         return this.tokenizer.errors;
1765     }
1766     get namespace() {
1767         return this.tokenizer.namespace;
1768     }
1769     set namespace(value) {
1770         this.tokenizer.namespace = value;
1771     }
1772     get expressionEnabled() {
1773         return this.tokenizer.expressionEnabled;
1774     }
1775     set expressionEnabled(value) {
1776         this.tokenizer.expressionEnabled = value;
1777     }
1778     get currentNode() {
1779         return last(this.elementStack) || this.document;
1780     }
1781     get isInVPreElement() {
1782         return this.vPreElement != null;
1783     }
1784     constructor(tokenizer, parserOptions) {
1785         this.tokenizer = new IntermediateTokenizer(tokenizer);
1786         this.locationCalculator = new LocationCalculator(tokenizer.gaps, tokenizer.lineTerminators);
1787         this.parserOptions = parserOptions;
1788         this.document = {
1789             type: "VDocumentFragment",
1790             range: [0, 0],
1791             loc: {
1792                 start: { line: 1, column: 0 },
1793                 end: { line: 1, column: 0 },
1794             },
1795             parent: null,
1796             children: [],
1797             tokens: this.tokens,
1798             comments: this.comments,
1799             errors: this.errors,
1800         };
1801         this.elementStack = [];
1802         this.vPreElement = null;
1803     }
1804     parse() {
1805         let token = null;
1806         while ((token = this.tokenizer.nextToken()) != null) {
1807             this[token.type](token);
1808         }
1809         this.popElementStackUntil(0);
1810         propagateEndLocation(this.document);
1811         return this.document;
1812     }
1813     reportParseError(token, code) {
1814         const error = ParseError.fromCode(code, token.range[0], token.loc.start.line, token.loc.start.column);
1815         this.errors.push(error);
1816         debug("[html] syntax error:", error.message);
1817     }
1818     popElementStack() {
1819         assert(this.elementStack.length >= 1);
1820         const element = this.elementStack.pop();
1821         propagateEndLocation(element);
1822         const current = this.currentNode;
1823         this.namespace =
1824             current.type === "VElement" ? current.namespace : NS.HTML;
1825         if (this.vPreElement === element) {
1826             this.vPreElement = null;
1827             this.expressionEnabled = true;
1828         }
1829         if (this.elementStack.length === 0) {
1830             this.expressionEnabled = false;
1831         }
1832     }
1833     popElementStackUntil(index) {
1834         while (this.elementStack.length > index) {
1835             this.popElementStack();
1836         }
1837     }
1838     detectNamespace(token) {
1839         const name = token.name;
1840         let ns = this.namespace;
1841         if (ns === NS.MathML || ns === NS.SVG) {
1842             const element = this.currentNode;
1843             if (element.type === "VElement") {
1844                 if (element.namespace === NS.MathML &&
1845                     element.name === "annotation-xml" &&
1846                     name === "svg") {
1847                     return NS.SVG;
1848                 }
1849                 if (isHTMLIntegrationPoint(element) ||
1850                     (isMathMLIntegrationPoint(element) &&
1851                         name !== "mglyph" &&
1852                         name !== "malignmark")) {
1853                     ns = NS.HTML;
1854                 }
1855             }
1856         }
1857         if (ns === NS.HTML) {
1858             if (name === "svg") {
1859                 return NS.SVG;
1860             }
1861             if (name === "math") {
1862                 return NS.MathML;
1863             }
1864         }
1865         if (name === "template") {
1866             const xmlns = token.attributes.find(a => a.key.name === "xmlns");
1867             const value = xmlns && xmlns.value && xmlns.value.value;
1868             if (value === NS.HTML || value === NS.MathML || value === NS.SVG) {
1869                 return value;
1870             }
1871         }
1872         return ns;
1873     }
1874     closeCurrentElementIfNecessary(name) {
1875         const element = this.currentNode;
1876         if (element.type !== "VElement") {
1877             return;
1878         }
1879         if (element.name === "p" && HTML_NON_FHRASING_TAGS.has(name)) {
1880             this.popElementStack();
1881         }
1882         if (element.name === name && HTML_CAN_BE_LEFT_OPEN_TAGS.has(name)) {
1883             this.popElementStack();
1884         }
1885         if (DT_DD.test(element.name) && DT_DD.test(name)) {
1886             this.popElementStack();
1887         }
1888     }
1889     processAttribute(node, namespace) {
1890         const tagName = node.parent.parent.name;
1891         const attrName = node.key.name;
1892         if ((this.expressionEnabled ||
1893             (attrName === "v-pre" && !this.isInVPreElement)) &&
1894             (DIRECTIVE_NAME.test(attrName) ||
1895                 attrName === "slot-scope" ||
1896                 (tagName === "template" && attrName === "scope"))) {
1897             convertToDirective(this.text, this.parserOptions, this.locationCalculator, node);
1898             return;
1899         }
1900         const key = (node.key.name = adjustAttributeName(node.key.name, namespace));
1901         const value = node.value && node.value.value;
1902         if (key === "xmlns" && value !== namespace) {
1903             this.reportParseError(node, "x-invalid-namespace");
1904         }
1905         else if (key === "xmlns:xlink" && value !== NS.XLink) {
1906             this.reportParseError(node, "x-invalid-namespace");
1907         }
1908     }
1909     StartTag(token) {
1910         debug("[html] StartTag %j", token);
1911         this.closeCurrentElementIfNecessary(token.name);
1912         const parent = this.currentNode;
1913         const namespace = this.detectNamespace(token);
1914         const element = {
1915             type: "VElement",
1916             range: [token.range[0], token.range[1]],
1917             loc: { start: token.loc.start, end: token.loc.end },
1918             parent,
1919             name: adjustElementName(token.name, namespace),
1920             rawName: token.rawName,
1921             namespace,
1922             startTag: {
1923                 type: "VStartTag",
1924                 range: token.range,
1925                 loc: token.loc,
1926                 parent: DUMMY_PARENT$2,
1927                 selfClosing: token.selfClosing,
1928                 attributes: token.attributes,
1929             },
1930             children: [],
1931             endTag: null,
1932             variables: [],
1933         };
1934         const hasVPre = !this.isInVPreElement &&
1935             token.attributes.some(a => a.key.name === "v-pre");
1936         if (hasVPre) {
1937             this.expressionEnabled = false;
1938         }
1939         parent.children.push(element);
1940         element.startTag.parent = element;
1941         for (const attribute of token.attributes) {
1942             attribute.parent = element.startTag;
1943             this.processAttribute(attribute, namespace);
1944         }
1945         for (const attribute of element.startTag.attributes) {
1946             if (attribute.directive) {
1947                 if (attribute.key.argument != null &&
1948                     attribute.key.argument.type === "VExpressionContainer") {
1949                     resolveReferences(attribute.key.argument);
1950                 }
1951                 if (attribute.value != null) {
1952                     resolveReferences(attribute.value);
1953                 }
1954             }
1955         }
1956         const isVoid = namespace === NS.HTML && HTML_VOID_ELEMENT_TAGS.has(element.name);
1957         if (token.selfClosing && !isVoid && namespace === NS.HTML) {
1958             this.reportParseError(token, "non-void-html-element-start-tag-with-trailing-solidus");
1959         }
1960         if (token.selfClosing || isVoid) {
1961             this.expressionEnabled = !this.isInVPreElement;
1962             return;
1963         }
1964         this.elementStack.push(element);
1965         if (hasVPre) {
1966             assert(this.vPreElement === null);
1967             this.vPreElement = element;
1968         }
1969         this.namespace = namespace;
1970         if (namespace === NS.HTML) {
1971             if (element.name === "template" &&
1972                 element.parent.type === "VDocumentFragment") {
1973                 const langAttr = element.startTag.attributes.find(a => !a.directive && a.key.name === "lang");
1974                 const lang = (langAttr && langAttr.value && langAttr.value.value) ||
1975                     "html";
1976                 if (lang !== "html") {
1977                     this.tokenizer.state = "RAWTEXT";
1978                 }
1979                 this.expressionEnabled = true;
1980             }
1981             if (HTML_RCDATA_TAGS.has(element.name)) {
1982                 this.tokenizer.state = "RCDATA";
1983             }
1984             if (HTML_RAWTEXT_TAGS.has(element.name)) {
1985                 this.tokenizer.state = "RAWTEXT";
1986             }
1987         }
1988     }
1989     EndTag(token) {
1990         debug("[html] EndTag %j", token);
1991         const i = findLastIndex(this.elementStack, el => el.name.toLowerCase() === token.name);
1992         if (i === -1) {
1993             this.reportParseError(token, "x-invalid-end-tag");
1994             return;
1995         }
1996         const element = this.elementStack[i];
1997         element.endTag = {
1998             type: "VEndTag",
1999             range: token.range,
2000             loc: token.loc,
2001             parent: element,
2002         };
2003         this.popElementStackUntil(i);
2004     }
2005     Text(token) {
2006         debug("[html] Text %j", token);
2007         const parent = this.currentNode;
2008         parent.children.push({
2009             type: "VText",
2010             range: token.range,
2011             loc: token.loc,
2012             parent,
2013             value: token.value,
2014         });
2015     }
2016     Mustache(token) {
2017         debug("[html] Mustache %j", token);
2018         const parent = this.currentNode;
2019         const container = {
2020             type: "VExpressionContainer",
2021             range: token.range,
2022             loc: token.loc,
2023             parent,
2024             expression: null,
2025             references: [],
2026         };
2027         processMustache(this.parserOptions, this.locationCalculator, container, token);
2028         parent.children.push(container);
2029         resolveReferences(container);
2030     }
2031 }
2032
2033 const alternativeCR = new Map([[128, 8364], [130, 8218], [131, 402], [132, 8222], [133, 8230], [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], [140, 338], [142, 381], [145, 8216], [146, 8217], [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], [153, 8482], [154, 353], [155, 8250], [156, 339], [158, 382], [159, 376]]);
2034
2035 const entitySets = [{ "length": 32, "entities": { "CounterClockwiseContourIntegral;": [8755] } }, { "length": 25, "entities": { "ClockwiseContourIntegral;": [8754], "DoubleLongLeftRightArrow;": [10234] } }, { "length": 24, "entities": { "NotNestedGreaterGreater;": [10914, 824] } }, { "length": 23, "entities": { "DiacriticalDoubleAcute;": [733], "NotSquareSupersetEqual;": [8931] } }, { "length": 22, "entities": { "CloseCurlyDoubleQuote;": [8221], "DoubleContourIntegral;": [8751], "FilledVerySmallSquare;": [9642], "NegativeVeryThinSpace;": [8203], "NotPrecedesSlantEqual;": [8928], "NotRightTriangleEqual;": [8941], "NotSucceedsSlantEqual;": [8929] } }, { "length": 21, "entities": { "CapitalDifferentialD;": [8517], "DoubleLeftRightArrow;": [8660], "DoubleLongRightArrow;": [10233], "EmptyVerySmallSquare;": [9643], "NestedGreaterGreater;": [8811], "NotDoubleVerticalBar;": [8742], "NotGreaterSlantEqual;": [10878, 824], "NotLeftTriangleEqual;": [8940], "NotSquareSubsetEqual;": [8930], "OpenCurlyDoubleQuote;": [8220], "ReverseUpEquilibrium;": [10607] } }, { "length": 20, "entities": { "DoubleLongLeftArrow;": [10232], "DownLeftRightVector;": [10576], "LeftArrowRightArrow;": [8646], "NegativeMediumSpace;": [8203], "NotGreaterFullEqual;": [8807, 824], "NotRightTriangleBar;": [10704, 824], "RightArrowLeftArrow;": [8644], "SquareSupersetEqual;": [8850], "leftrightsquigarrow;": [8621] } }, { "length": 19, "entities": { "DownRightTeeVector;": [10591], "DownRightVectorBar;": [10583], "LongLeftRightArrow;": [10231], "Longleftrightarrow;": [10234], "NegativeThickSpace;": [8203], "NotLeftTriangleBar;": [10703, 824], "PrecedesSlantEqual;": [8828], "ReverseEquilibrium;": [8651], "RightDoubleBracket;": [10215], "RightDownTeeVector;": [10589], "RightDownVectorBar;": [10581], "RightTriangleEqual;": [8885], "SquareIntersection;": [8851], "SucceedsSlantEqual;": [8829], "blacktriangleright;": [9656], "longleftrightarrow;": [10231] } }, { "length": 18, "entities": { "DoubleUpDownArrow;": [8661], "DoubleVerticalBar;": [8741], "DownLeftTeeVector;": [10590], "DownLeftVectorBar;": [10582], "FilledSmallSquare;": [9724], "GreaterSlantEqual;": [10878], "LeftDoubleBracket;": [10214], "LeftDownTeeVector;": [10593], "LeftDownVectorBar;": [10585], "LeftTriangleEqual;": [8884], "NegativeThinSpace;": [8203], "NotGreaterGreater;": [8811, 824], "NotLessSlantEqual;": [10877, 824], "NotNestedLessLess;": [10913, 824], "NotReverseElement;": [8716], "NotSquareSuperset;": [8848, 824], "NotTildeFullEqual;": [8775], "RightAngleBracket;": [10217], "RightUpDownVector;": [10575], "SquareSubsetEqual;": [8849], "VerticalSeparator;": [10072], "blacktriangledown;": [9662], "blacktriangleleft;": [9666], "leftrightharpoons;": [8651], "rightleftharpoons;": [8652], "twoheadrightarrow;": [8608] } }, { "length": 17, "entities": { "DiacriticalAcute;": [180], "DiacriticalGrave;": [96], "DiacriticalTilde;": [732], "DoubleRightArrow;": [8658], "DownArrowUpArrow;": [8693], "EmptySmallSquare;": [9723], "GreaterEqualLess;": [8923], "GreaterFullEqual;": [8807], "LeftAngleBracket;": [10216], "LeftUpDownVector;": [10577], "LessEqualGreater;": [8922], "NonBreakingSpace;": [160], "NotPrecedesEqual;": [10927, 824], "NotRightTriangle;": [8939], "NotSucceedsEqual;": [10928, 824], "NotSucceedsTilde;": [8831, 824], "NotSupersetEqual;": [8841], "RightTriangleBar;": [10704], "RightUpTeeVector;": [10588], "RightUpVectorBar;": [10580], "UnderParenthesis;": [9181], "UpArrowDownArrow;": [8645], "circlearrowright;": [8635], "downharpoonright;": [8642], "ntrianglerighteq;": [8941], "rightharpoondown;": [8641], "rightrightarrows;": [8649], "twoheadleftarrow;": [8606], "vartriangleright;": [8883] } }, { "length": 16, "entities": { "CloseCurlyQuote;": [8217], "ContourIntegral;": [8750], "DoubleDownArrow;": [8659], "DoubleLeftArrow;": [8656], "DownRightVector;": [8641], "LeftRightVector;": [10574], "LeftTriangleBar;": [10703], "LeftUpTeeVector;": [10592], "LeftUpVectorBar;": [10584], "LowerRightArrow;": [8600], "NotGreaterEqual;": [8817], "NotGreaterTilde;": [8821], "NotHumpDownHump;": [8782, 824], "NotLeftTriangle;": [8938], "NotSquareSubset;": [8847, 824], "OverParenthesis;": [9180], "RightDownVector;": [8642], "ShortRightArrow;": [8594], "UpperRightArrow;": [8599], "bigtriangledown;": [9661], "circlearrowleft;": [8634], "curvearrowright;": [8631], "downharpoonleft;": [8643], "leftharpoondown;": [8637], "leftrightarrows;": [8646], "nLeftrightarrow;": [8654], "nleftrightarrow;": [8622], "ntrianglelefteq;": [8940], "rightleftarrows;": [8644], "rightsquigarrow;": [8605], "rightthreetimes;": [8908], "straightepsilon;": [1013], "trianglerighteq;": [8885], "vartriangleleft;": [8882] } }, { "length": 15, "entities": { "DiacriticalDot;": [729], "DoubleRightTee;": [8872], "DownLeftVector;": [8637], "GreaterGreater;": [10914], "HorizontalLine;": [9472], "InvisibleComma;": [8291], "InvisibleTimes;": [8290], "LeftDownVector;": [8643], "LeftRightArrow;": [8596], "Leftrightarrow;": [8660], "LessSlantEqual;": [10877], "LongRightArrow;": [10230], "Longrightarrow;": [10233], "LowerLeftArrow;": [8601], "NestedLessLess;": [8810], "NotGreaterLess;": [8825], "NotLessGreater;": [8824], "NotSubsetEqual;": [8840], "NotVerticalBar;": [8740], "OpenCurlyQuote;": [8216], "ReverseElement;": [8715], "RightTeeVector;": [10587], "RightVectorBar;": [10579], "ShortDownArrow;": [8595], "ShortLeftArrow;": [8592], "SquareSuperset;": [8848], "TildeFullEqual;": [8773], "UpperLeftArrow;": [8598], "ZeroWidthSpace;": [8203], "curvearrowleft;": [8630], "doublebarwedge;": [8966], "downdownarrows;": [8650], "hookrightarrow;": [8618], "leftleftarrows;": [8647], "leftrightarrow;": [8596], "leftthreetimes;": [8907], "longrightarrow;": [10230], "looparrowright;": [8620], "nshortparallel;": [8742], "ntriangleright;": [8939], "rightarrowtail;": [8611], "rightharpoonup;": [8640], "trianglelefteq;": [8884], "upharpoonright;": [8638] } }, { "length": 14, "entities": { "ApplyFunction;": [8289], "DifferentialD;": [8518], "DoubleLeftTee;": [10980], "DoubleUpArrow;": [8657], "LeftTeeVector;": [10586], "LeftVectorBar;": [10578], "LessFullEqual;": [8806], "LongLeftArrow;": [10229], "Longleftarrow;": [10232], "NotEqualTilde;": [8770, 824], "NotTildeEqual;": [8772], "NotTildeTilde;": [8777], "Poincareplane;": [8460], "PrecedesEqual;": [10927], "PrecedesTilde;": [8830], "RightArrowBar;": [8677], "RightTeeArrow;": [8614], "RightTriangle;": [8883], "RightUpVector;": [8638], "SucceedsEqual;": [10928], "SucceedsTilde;": [8831], "SupersetEqual;": [8839], "UpEquilibrium;": [10606], "VerticalTilde;": [8768], "VeryThinSpace;": [8202], "bigtriangleup;": [9651], "blacktriangle;": [9652], "divideontimes;": [8903], "fallingdotseq;": [8786], "hookleftarrow;": [8617], "leftarrowtail;": [8610], "leftharpoonup;": [8636], "longleftarrow;": [10229], "looparrowleft;": [8619], "measuredangle;": [8737], "ntriangleleft;": [8938], "shortparallel;": [8741], "smallsetminus;": [8726], "triangleright;": [9657], "upharpoonleft;": [8639], "varsubsetneqq;": [10955, 65024], "varsupsetneqq;": [10956, 65024] } }, { "length": 13, "entities": { "DownArrowBar;": [10515], "DownTeeArrow;": [8615], "ExponentialE;": [8519], "GreaterEqual;": [8805], "GreaterTilde;": [8819], "HilbertSpace;": [8459], "HumpDownHump;": [8782], "Intersection;": [8898], "LeftArrowBar;": [8676], "LeftTeeArrow;": [8612], "LeftTriangle;": [8882], "LeftUpVector;": [8639], "NotCongruent;": [8802], "NotHumpEqual;": [8783, 824], "NotLessEqual;": [8816], "NotLessTilde;": [8820], "Proportional;": [8733], "RightCeiling;": [8969], "RoundImplies;": [10608], "ShortUpArrow;": [8593], "SquareSubset;": [8847], "UnderBracket;": [9141], "VerticalLine;": [124], "blacklozenge;": [10731], "exponentiale;": [8519], "risingdotseq;": [8787], "triangledown;": [9663], "triangleleft;": [9667], "varsubsetneq;": [8842, 65024], "varsupsetneq;": [8843, 65024] } }, { "length": 12, "entities": { "CircleMinus;": [8854], "CircleTimes;": [8855], "Equilibrium;": [8652], "GreaterLess;": [8823], "LeftCeiling;": [8968], "LessGreater;": [8822], "MediumSpace;": [8287], "NotLessLess;": [8810, 824], "NotPrecedes;": [8832], "NotSucceeds;": [8833], "NotSuperset;": [8835, 8402], "OverBracket;": [9140], "RightVector;": [8640], "Rrightarrow;": [8667], "RuleDelayed;": [10740], "SmallCircle;": [8728], "SquareUnion;": [8852], "SubsetEqual;": [8838], "UpDownArrow;": [8597], "Updownarrow;": [8661], "VerticalBar;": [8739], "backepsilon;": [1014], "blacksquare;": [9642], "circledcirc;": [8858], "circleddash;": [8861], "curlyeqprec;": [8926], "curlyeqsucc;": [8927], "diamondsuit;": [9830], "eqslantless;": [10901], "expectation;": [8496], "nRightarrow;": [8655], "nrightarrow;": [8603], "preccurlyeq;": [8828], "precnapprox;": [10937], "quaternions;": [8461], "straightphi;": [981], "succcurlyeq;": [8829], "succnapprox;": [10938], "thickapprox;": [8776], "updownarrow;": [8597] } }, { "length": 11, "entities": { "Bernoullis;": [8492], "CirclePlus;": [8853], "EqualTilde;": [8770], "Fouriertrf;": [8497], "ImaginaryI;": [8520], "Laplacetrf;": [8466], "LeftVector;": [8636], "Lleftarrow;": [8666], "NotElement;": [8713], "NotGreater;": [8815], "Proportion;": [8759], "RightArrow;": [8594], "RightFloor;": [8971], "Rightarrow;": [8658], "ThickSpace;": [8287, 8202], "TildeEqual;": [8771], "TildeTilde;": [8776], "UnderBrace;": [9183], "UpArrowBar;": [10514], "UpTeeArrow;": [8613], "circledast;": [8859], "complement;": [8705], "curlywedge;": [8911], "eqslantgtr;": [10902], "gtreqqless;": [10892], "lessapprox;": [10885], "lesseqqgtr;": [10891], "lmoustache;": [9136], "longmapsto;": [10236], "mapstodown;": [8615], "mapstoleft;": [8612], "nLeftarrow;": [8653], "nleftarrow;": [8602], "nsubseteqq;": [10949, 824], "nsupseteqq;": [10950, 824], "precapprox;": [10935], "rightarrow;": [8594], "rmoustache;": [9137], "sqsubseteq;": [8849], "sqsupseteq;": [8850], "subsetneqq;": [10955], "succapprox;": [10936], "supsetneqq;": [10956], "upuparrows;": [8648], "varepsilon;": [1013], "varnothing;": [8709] } }, { "length": 10, "entities": { "Backslash;": [8726], "CenterDot;": [183], "CircleDot;": [8857], "Congruent;": [8801], "Coproduct;": [8720], "DoubleDot;": [168], "DownArrow;": [8595], "DownBreve;": [785], "Downarrow;": [8659], "HumpEqual;": [8783], "LeftArrow;": [8592], "LeftFloor;": [8970], "Leftarrow;": [8656], "LessTilde;": [8818], "Mellintrf;": [8499], "MinusPlus;": [8723], "NotCupCap;": [8813], "NotExists;": [8708], "NotSubset;": [8834, 8402], "OverBrace;": [9182], "PlusMinus;": [177], "Therefore;": [8756], "ThinSpace;": [8201], "TripleDot;": [8411], "UnionPlus;": [8846], "backprime;": [8245], "backsimeq;": [8909], "bigotimes;": [10754], "centerdot;": [183], "checkmark;": [10003], "complexes;": [8450], "dotsquare;": [8865], "downarrow;": [8595], "gtrapprox;": [10886], "gtreqless;": [8923], "gvertneqq;": [8809, 65024], "heartsuit;": [9829], "leftarrow;": [8592], "lesseqgtr;": [8922], "lvertneqq;": [8808, 65024], "ngeqslant;": [10878, 824], "nleqslant;": [10877, 824], "nparallel;": [8742], "nshortmid;": [8740], "nsubseteq;": [8840], "nsupseteq;": [8841], "pitchfork;": [8916], "rationals;": [8474], "spadesuit;": [9824], "subseteqq;": [10949], "subsetneq;": [8842], "supseteqq;": [10950], "supsetneq;": [8843], "therefore;": [8756], "triangleq;": [8796], "varpropto;": [8733] } }, { "length": 9, "entities": { "DDotrahd;": [10513], "DotEqual;": [8784], "Integral;": [8747], "LessLess;": [10913], "NotEqual;": [8800], "NotTilde;": [8769], "PartialD;": [8706], "Precedes;": [8826], "RightTee;": [8866], "Succeeds;": [8827], "SuchThat;": [8715], "Superset;": [8835], "Uarrocir;": [10569], "UnderBar;": [95], "andslope;": [10840], "angmsdaa;": [10664], "angmsdab;": [10665], "angmsdac;": [10666], "angmsdad;": [10667], "angmsdae;": [10668], "angmsdaf;": [10669], "angmsdag;": [10670], "angmsdah;": [10671], "angrtvbd;": [10653], "approxeq;": [8778], "awconint;": [8755], "backcong;": [8780], "barwedge;": [8965], "bbrktbrk;": [9142], "bigoplus;": [10753], "bigsqcup;": [10758], "biguplus;": [10756], "bigwedge;": [8896], "boxminus;": [8863], "boxtimes;": [8864], "bsolhsub;": [10184], "capbrcup;": [10825], "circledR;": [174], "circledS;": [9416], "cirfnint;": [10768], "clubsuit;": [9827], "cupbrcap;": [10824], "curlyvee;": [8910], "cwconint;": [8754], "doteqdot;": [8785], "dotminus;": [8760], "drbkarow;": [10512], "dzigrarr;": [10239], "elinters;": [9191], "emptyset;": [8709], "eqvparsl;": [10725], "fpartint;": [10765], "geqslant;": [10878], "gesdotol;": [10884], "gnapprox;": [10890], "hksearow;": [10533], "hkswarow;": [10534], "imagline;": [8464], "imagpart;": [8465], "infintie;": [10717], "integers;": [8484], "intercal;": [8890], "intlarhk;": [10775], "laemptyv;": [10676], "ldrushar;": [10571], "leqslant;": [10877], "lesdotor;": [10883], "llcorner;": [8990], "lnapprox;": [10889], "lrcorner;": [8991], "lurdshar;": [10570], "mapstoup;": [8613], "multimap;": [8888], "naturals;": [8469], "ncongdot;": [10861, 824], "notindot;": [8949, 824], "otimesas;": [10806], "parallel;": [8741], "plusacir;": [10787], "pointint;": [10773], "precneqq;": [10933], "precnsim;": [8936], "profalar;": [9006], "profline;": [8978], "profsurf;": [8979], "raemptyv;": [10675], "realpart;": [8476], "rppolint;": [10770], "rtriltri;": [10702], "scpolint;": [10771], "setminus;": [8726], "shortmid;": [8739], "smeparsl;": [10724], "sqsubset;": [8847], "sqsupset;": [8848], "subseteq;": [8838], "succneqq;": [10934], "succnsim;": [8937], "supseteq;": [8839], "thetasym;": [977], "thicksim;": [8764], "timesbar;": [10801], "triangle;": [9653], "triminus;": [10810], "trpezium;": [9186], "ulcorner;": [8988], "urcorner;": [8989], "varkappa;": [1008], "varsigma;": [962], "vartheta;": [977] } }, { "length": 8, "entities": { "Because;": [8757], "Cayleys;": [8493], "Cconint;": [8752], "Cedilla;": [184], "Diamond;": [8900], "DownTee;": [8868], "Element;": [8712], "Epsilon;": [917], "Implies;": [8658], "LeftTee;": [8867], "NewLine;": [10], "NoBreak;": [8288], "NotLess;": [8814], "Omicron;": [927], "OverBar;": [8254], "Product;": [8719], "UpArrow;": [8593], "Uparrow;": [8657], "Upsilon;": [933], "alefsym;": [8501], "angrtvb;": [8894], "angzarr;": [9084], "asympeq;": [8781], "backsim;": [8765], "because;": [8757], "bemptyv;": [10672], "between;": [8812], "bigcirc;": [9711], "bigodot;": [10752], "bigstar;": [9733], "bnequiv;": [8801, 8421], "boxplus;": [8862], "ccupssm;": [10832], "cemptyv;": [10674], "cirscir;": [10690], "coloneq;": [8788], "congdot;": [10861], "cudarrl;": [10552], "cudarrr;": [10549], "cularrp;": [10557], "curarrm;": [10556], "dbkarow;": [10511], "ddagger;": [8225], "ddotseq;": [10871], "demptyv;": [10673], "diamond;": [8900], "digamma;": [989], "dotplus;": [8724], "dwangle;": [10662], "epsilon;": [949], "eqcolon;": [8789], "equivDD;": [10872], "gesdoto;": [10882], "gtquest;": [10876], "gtrless;": [8823], "harrcir;": [10568], "intprod;": [10812], "isindot;": [8949], "larrbfs;": [10527], "larrsim;": [10611], "lbrksld;": [10639], "lbrkslu;": [10637], "ldrdhar;": [10599], "lesdoto;": [10881], "lessdot;": [8918], "lessgtr;": [8822], "lesssim;": [8818], "lotimes;": [10804], "lozenge;": [9674], "ltquest;": [10875], "luruhar;": [10598], "maltese;": [10016], "minusdu;": [10794], "napprox;": [8777], "natural;": [9838], "nearrow;": [8599], "nexists;": [8708], "notinva;": [8713], "notinvb;": [8951], "notinvc;": [8950], "notniva;": [8716], "notnivb;": [8958], "notnivc;": [8957], "npolint;": [10772], "npreceq;": [10927, 824], "nsqsube;": [8930], "nsqsupe;": [8931], "nsubset;": [8834, 8402], "nsucceq;": [10928, 824], "nsupset;": [8835, 8402], "nvinfin;": [10718], "nvltrie;": [8884, 8402], "nvrtrie;": [8885, 8402], "nwarrow;": [8598], "olcross;": [10683], "omicron;": [959], "orderof;": [8500], "orslope;": [10839], "pertenk;": [8241], "planckh;": [8462], "pluscir;": [10786], "plussim;": [10790], "plustwo;": [10791], "precsim;": [8830], "quatint;": [10774], "questeq;": [8799], "rarrbfs;": [10528], "rarrsim;": [10612], "rbrksld;": [10638], "rbrkslu;": [10640], "rdldhar;": [10601], "realine;": [8475], "rotimes;": [10805], "ruluhar;": [10600], "searrow;": [8600], "simplus;": [10788], "simrarr;": [10610], "subedot;": [10947], "submult;": [10945], "subplus;": [10943], "subrarr;": [10617], "succsim;": [8831], "supdsub;": [10968], "supedot;": [10948], "suphsol;": [10185], "suphsub;": [10967], "suplarr;": [10619], "supmult;": [10946], "supplus;": [10944], "swarrow;": [8601], "topfork;": [10970], "triplus;": [10809], "tritime;": [10811], "uparrow;": [8593], "upsilon;": [965], "uwangle;": [10663], "vzigzag;": [10650], "zigrarr;": [8669] } }, { "length": 7, "entities": { "Aacute;": [193], "Abreve;": [258], "Agrave;": [192], "Assign;": [8788], "Atilde;": [195], "Barwed;": [8966], "Bumpeq;": [8782], "Cacute;": [262], "Ccaron;": [268], "Ccedil;": [199], "Colone;": [10868], "Conint;": [8751], "CupCap;": [8781], "Dagger;": [8225], "Dcaron;": [270], "DotDot;": [8412], "Dstrok;": [272], "Eacute;": [201], "Ecaron;": [282], "Egrave;": [200], "Exists;": [8707], "ForAll;": [8704], "Gammad;": [988], "Gbreve;": [286], "Gcedil;": [290], "HARDcy;": [1066], "Hstrok;": [294], "Iacute;": [205], "Igrave;": [204], "Itilde;": [296], "Jsercy;": [1032], "Kcedil;": [310], "Lacute;": [313], "Lambda;": [923], "Lcaron;": [317], "Lcedil;": [315], "Lmidot;": [319], "Lstrok;": [321], "Nacute;": [323], "Ncaron;": [327], "Ncedil;": [325], "Ntilde;": [209], "Oacute;": [211], "Odblac;": [336], "Ograve;": [210], "Oslash;": [216], "Otilde;": [213], "Otimes;": [10807], "Racute;": [340], "Rarrtl;": [10518], "Rcaron;": [344], "Rcedil;": [342], "SHCHcy;": [1065], "SOFTcy;": [1068], "Sacute;": [346], "Scaron;": [352], "Scedil;": [350], "Square;": [9633], "Subset;": [8912], "Supset;": [8913], "Tcaron;": [356], "Tcedil;": [354], "Tstrok;": [358], "Uacute;": [218], "Ubreve;": [364], "Udblac;": [368], "Ugrave;": [217], "Utilde;": [360], "Vdashl;": [10982], "Verbar;": [8214], "Vvdash;": [8874], "Yacute;": [221], "Zacute;": [377], "Zcaron;": [381], "aacute;": [225], "abreve;": [259], "agrave;": [224], "andand;": [10837], "angmsd;": [8737], "angsph;": [8738], "apacir;": [10863], "approx;": [8776], "atilde;": [227], "barvee;": [8893], "barwed;": [8965], "becaus;": [8757], "bernou;": [8492], "bigcap;": [8898], "bigcup;": [8899], "bigvee;": [8897], "bkarow;": [10509], "bottom;": [8869], "bowtie;": [8904], "boxbox;": [10697], "bprime;": [8245], "brvbar;": [166], "bullet;": [8226], "bumpeq;": [8783], "cacute;": [263], "capand;": [10820], "capcap;": [10827], "capcup;": [10823], "capdot;": [10816], "ccaron;": [269], "ccedil;": [231], "circeq;": [8791], "cirmid;": [10991], "colone;": [8788], "commat;": [64], "compfn;": [8728], "conint;": [8750], "coprod;": [8720], "copysr;": [8471], "cularr;": [8630], "cupcap;": [10822], "cupcup;": [10826], "cupdot;": [8845], "curarr;": [8631], "curren;": [164], "cylcty;": [9005], "dagger;": [8224], "daleth;": [8504], "dcaron;": [271], "dfisht;": [10623], "divide;": [247], "divonx;": [8903], "dlcorn;": [8990], "dlcrop;": [8973], "dollar;": [36], "drcorn;": [8991], "drcrop;": [8972], "dstrok;": [273], "eacute;": [233], "easter;": [10862], "ecaron;": [283], "ecolon;": [8789], "egrave;": [232], "egsdot;": [10904], "elsdot;": [10903], "emptyv;": [8709], "emsp13;": [8196], "emsp14;": [8197], "eparsl;": [10723], "eqcirc;": [8790], "equals;": [61], "equest;": [8799], "female;": [9792], "ffilig;": [64259], "ffllig;": [64260], "forall;": [8704], "frac12;": [189], "frac13;": [8531], "frac14;": [188], "frac15;": [8533], "frac16;": [8537], "frac18;": [8539], "frac23;": [8532], "frac25;": [8534], "frac34;": [190], "frac35;": [8535], "frac38;": [8540], "frac45;": [8536], "frac56;": [8538], "frac58;": [8541], "frac78;": [8542], "gacute;": [501], "gammad;": [989], "gbreve;": [287], "gesdot;": [10880], "gesles;": [10900], "gtlPar;": [10645], "gtrarr;": [10616], "gtrdot;": [8919], "gtrsim;": [8819], "hairsp;": [8202], "hamilt;": [8459], "hardcy;": [1098], "hearts;": [9829], "hellip;": [8230], "hercon;": [8889], "homtht;": [8763], "horbar;": [8213], "hslash;": [8463], "hstrok;": [295], "hybull;": [8259], "hyphen;": [8208], "iacute;": [237], "igrave;": [236], "iiiint;": [10764], "iinfin;": [10716], "incare;": [8453], "inodot;": [305], "intcal;": [8890], "iquest;": [191], "isinsv;": [8947], "itilde;": [297], "jsercy;": [1112], "kappav;": [1008], "kcedil;": [311], "kgreen;": [312], "lAtail;": [10523], "lacute;": [314], "lagran;": [8466], "lambda;": [955], "langle;": [10216], "larrfs;": [10525], "larrhk;": [8617], "larrlp;": [8619], "larrpl;": [10553], "larrtl;": [8610], "latail;": [10521], "lbrace;": [123], "lbrack;": [91], "lcaron;": [318], "lcedil;": [316], "ldquor;": [8222], "lesdot;": [10879], "lesges;": [10899], "lfisht;": [10620], "lfloor;": [8970], "lharul;": [10602], "llhard;": [10603], "lmidot;": [320], "lmoust;": [9136], "loplus;": [10797], "lowast;": [8727], "lowbar;": [95], "lparlt;": [10643], "lrhard;": [10605], "lsaquo;": [8249], "lsquor;": [8218], "lstrok;": [322], "lthree;": [8907], "ltimes;": [8905], "ltlarr;": [10614], "ltrPar;": [10646], "mapsto;": [8614], "marker;": [9646], "mcomma;": [10793], "midast;": [42], "midcir;": [10992], "middot;": [183], "minusb;": [8863], "minusd;": [8760], "mnplus;": [8723], "models;": [8871], "mstpos;": [8766], "nVDash;": [8879], "nVdash;": [8878], "nacute;": [324], "nbumpe;": [8783, 824], "ncaron;": [328], "ncedil;": [326], "nearhk;": [10532], "nequiv;": [8802], "nesear;": [10536], "nexist;": [8708], "nltrie;": [8940], "notinE;": [8953, 824], "nparsl;": [11005, 8421], "nprcue;": [8928], "nrarrc;": [10547, 824], "nrarrw;": [8605, 824], "nrtrie;": [8941], "nsccue;": [8929], "nsimeq;": [8772], "ntilde;": [241], "numero;": [8470], "nvDash;": [8877], "nvHarr;": [10500], "nvdash;": [8876], "nvlArr;": [10498], "nvrArr;": [10499], "nwarhk;": [10531], "nwnear;": [10535], "oacute;": [243], "odblac;": [337], "odsold;": [10684], "ograve;": [242], "ominus;": [8854], "origof;": [8886], "oslash;": [248], "otilde;": [245], "otimes;": [8855], "parsim;": [10995], "percnt;": [37], "period;": [46], "permil;": [8240], "phmmat;": [8499], "planck;": [8463], "plankv;": [8463], "plusdo;": [8724], "plusdu;": [10789], "plusmn;": [177], "preceq;": [10927], "primes;": [8473], "prnsim;": [8936], "propto;": [8733], "prurel;": [8880], "puncsp;": [8200], "qprime;": [8279], "rAtail;": [10524], "racute;": [341], "rangle;": [10217], "rarrap;": [10613], "rarrfs;": [10526], "rarrhk;": [8618], "rarrlp;": [8620], "rarrpl;": [10565], "rarrtl;": [8611], "ratail;": [10522], "rbrace;": [125], "rbrack;": [93], "rcaron;": [345], "rcedil;": [343], "rdquor;": [8221], "rfisht;": [10621], "rfloor;": [8971], "rharul;": [10604], "rmoust;": [9137], "roplus;": [10798], "rpargt;": [10644], "rsaquo;": [8250], "rsquor;": [8217], "rthree;": [8908], "rtimes;": [8906], "sacute;": [347], "scaron;": [353], "scedil;": [351], "scnsim;": [8937], "searhk;": [10533], "seswar;": [10537], "sfrown;": [8994], "shchcy;": [1097], "sigmaf;": [962], "sigmav;": [962], "simdot;": [10858], "smashp;": [10803], "softcy;": [1100], "solbar;": [9023], "spades;": [9824], "sqcaps;": [8851, 65024], "sqcups;": [8852, 65024], "sqsube;": [8849], "sqsupe;": [8850], "square;": [9633], "squarf;": [9642], "ssetmn;": [8726], "ssmile;": [8995], "sstarf;": [8902], "subdot;": [10941], "subset;": [8834], "subsim;": [10951], "subsub;": [10965], "subsup;": [10963], "succeq;": [10928], "supdot;": [10942], "supset;": [8835], "supsim;": [10952], "supsub;": [10964], "supsup;": [10966], "swarhk;": [10534], "swnwar;": [10538], "target;": [8982], "tcaron;": [357], "tcedil;": [355], "telrec;": [8981], "there4;": [8756], "thetav;": [977], "thinsp;": [8201], "thksim;": [8764], "timesb;": [8864], "timesd;": [10800], "topbot;": [9014], "topcir;": [10993], "tprime;": [8244], "tridot;": [9708], "tstrok;": [359], "uacute;": [250], "ubreve;": [365], "udblac;": [369], "ufisht;": [10622], "ugrave;": [249], "ulcorn;": [8988], "ulcrop;": [8975], "urcorn;": [8989], "urcrop;": [8974], "utilde;": [361], "vangrt;": [10652], "varphi;": [981], "varrho;": [1009], "veebar;": [8891], "vellip;": [8942], "verbar;": [124], "vsubnE;": [10955, 65024], "vsubne;": [8842, 65024], "vsupnE;": [10956, 65024], "vsupne;": [8843, 65024], "wedbar;": [10847], "wedgeq;": [8793], "weierp;": [8472], "wreath;": [8768], "xoplus;": [10753], "xotime;": [10754], "xsqcup;": [10758], "xuplus;": [10756], "xwedge;": [8896], "yacute;": [253], "zacute;": [378], "zcaron;": [382], "zeetrf;": [8488] } }, { "length": 6, "entities": { "AElig;": [198], "Aacute": [193], "Acirc;": [194], "Agrave": [192], "Alpha;": [913], "Amacr;": [256], "Aogon;": [260], "Aring;": [197], "Atilde": [195], "Breve;": [728], "Ccedil": [199], "Ccirc;": [264], "Colon;": [8759], "Cross;": [10799], "Dashv;": [10980], "Delta;": [916], "Eacute": [201], "Ecirc;": [202], "Egrave": [200], "Emacr;": [274], "Eogon;": [280], "Equal;": [10869], "Gamma;": [915], "Gcirc;": [284], "Hacek;": [711], "Hcirc;": [292], "IJlig;": [306], "Iacute": [205], "Icirc;": [206], "Igrave": [204], "Imacr;": [298], "Iogon;": [302], "Iukcy;": [1030], "Jcirc;": [308], "Jukcy;": [1028], "Kappa;": [922], "Ntilde": [209], "OElig;": [338], "Oacute": [211], "Ocirc;": [212], "Ograve": [210], "Omacr;": [332], "Omega;": [937], "Oslash": [216], "Otilde": [213], "Prime;": [8243], "RBarr;": [10512], "Scirc;": [348], "Sigma;": [931], "THORN;": [222], "TRADE;": [8482], "TSHcy;": [1035], "Theta;": [920], "Tilde;": [8764], "Uacute": [218], "Ubrcy;": [1038], "Ucirc;": [219], "Ugrave": [217], "Umacr;": [362], "Union;": [8899], "Uogon;": [370], "UpTee;": [8869], "Uring;": [366], "VDash;": [8875], "Vdash;": [8873], "Wcirc;": [372], "Wedge;": [8896], "Yacute": [221], "Ycirc;": [374], "aacute": [225], "acirc;": [226], "acute;": [180], "aelig;": [230], "agrave": [224], "aleph;": [8501], "alpha;": [945], "amacr;": [257], "amalg;": [10815], "angle;": [8736], "angrt;": [8735], "angst;": [197], "aogon;": [261], "aring;": [229], "asymp;": [8776], "atilde": [227], "awint;": [10769], "bcong;": [8780], "bdquo;": [8222], "bepsi;": [1014], "blank;": [9251], "blk12;": [9618], "blk14;": [9617], "blk34;": [9619], "block;": [9608], "boxDL;": [9559], "boxDR;": [9556], "boxDl;": [9558], "boxDr;": [9555], "boxHD;": [9574], "boxHU;": [9577], "boxHd;": [9572], "boxHu;": [9575], "boxUL;": [9565], "boxUR;": [9562], "boxUl;": [9564], "boxUr;": [9561], "boxVH;": [9580], "boxVL;": [9571], "boxVR;": [9568], "boxVh;": [9579], "boxVl;": [9570], "boxVr;": [9567], "boxdL;": [9557], "boxdR;": [9554], "boxdl;": [9488], "boxdr;": [9484], "boxhD;": [9573], "boxhU;": [9576], "boxhd;": [9516], "boxhu;": [9524], "boxuL;": [9563], "boxuR;": [9560], "boxul;": [9496], "boxur;": [9492], "boxvH;": [9578], "boxvL;": [9569], "boxvR;": [9566], "boxvh;": [9532], "boxvl;": [9508], "boxvr;": [9500], "breve;": [728], "brvbar": [166], "bsemi;": [8271], "bsime;": [8909], "bsolb;": [10693], "bumpE;": [10926], "bumpe;": [8783], "caret;": [8257], "caron;": [711], "ccaps;": [10829], "ccedil": [231], "ccirc;": [265], "ccups;": [10828], "cedil;": [184], "check;": [10003], "clubs;": [9827], "colon;": [58], "comma;": [44], "crarr;": [8629], "cross;": [10007], "csube;": [10961], "csupe;": [10962], "ctdot;": [8943], "cuepr;": [8926], "cuesc;": [8927], "cupor;": [10821], "curren": [164], "cuvee;": [8910], "cuwed;": [8911], "cwint;": [8753], "dashv;": [8867], "dblac;": [733], "ddarr;": [8650], "delta;": [948], "dharl;": [8643], "dharr;": [8642], "diams;": [9830], "disin;": [8946], "divide": [247], "doteq;": [8784], "dtdot;": [8945], "dtrif;": [9662], "duarr;": [8693], "duhar;": [10607], "eDDot;": [10871], "eacute": [233], "ecirc;": [234], "efDot;": [8786], "egrave": [232], "emacr;": [275], "empty;": [8709], "eogon;": [281], "eplus;": [10865], "epsiv;": [1013], "eqsim;": [8770], "equiv;": [8801], "erDot;": [8787], "erarr;": [10609], "esdot;": [8784], "exist;": [8707], "fflig;": [64256], "filig;": [64257], "fjlig;": [102, 106], "fllig;": [64258], "fltns;": [9649], "forkv;": [10969], "frac12": [189], "frac14": [188], "frac34": [190], "frasl;": [8260], "frown;": [8994], "gamma;": [947], "gcirc;": [285], "gescc;": [10921], "gimel;": [8503], "gneqq;": [8809], "gnsim;": [8935], "grave;": [96], "gsime;": [10894], "gsiml;": [10896], "gtcir;": [10874], "gtdot;": [8919], "harrw;": [8621], "hcirc;": [293], "hoarr;": [8703], "iacute": [237], "icirc;": [238], "iexcl;": [161], "igrave": [236], "iiint;": [8749], "iiota;": [8489], "ijlig;": [307], "imacr;": [299], "image;": [8465], "imath;": [305], "imped;": [437], "infin;": [8734], "iogon;": [303], "iprod;": [10812], "iquest": [191], "isinE;": [8953], "isins;": [8948], "isinv;": [8712], "iukcy;": [1110], "jcirc;": [309], "jmath;": [567], "jukcy;": [1108], "kappa;": [954], "lAarr;": [8666], "lBarr;": [10510], "langd;": [10641], "laquo;": [171], "larrb;": [8676], "lates;": [10925, 65024], "lbarr;": [10508], "lbbrk;": [10098], "lbrke;": [10635], "lceil;": [8968], "ldquo;": [8220], "lescc;": [10920], "lhard;": [8637], "lharu;": [8636], "lhblk;": [9604], "llarr;": [8647], "lltri;": [9722], "lneqq;": [8808], "lnsim;": [8934], "loang;": [10220], "loarr;": [8701], "lobrk;": [10214], "lopar;": [10629], "lrarr;": [8646], "lrhar;": [8651], "lrtri;": [8895], "lsime;": [10893], "lsimg;": [10895], "lsquo;": [8216], "ltcir;": [10873], "ltdot;": [8918], "ltrie;": [8884], "ltrif;": [9666], "mDDot;": [8762], "mdash;": [8212], "micro;": [181], "middot": [183], "minus;": [8722], "mumap;": [8888], "nabla;": [8711], "napid;": [8779, 824], "napos;": [329], "natur;": [9838], "nbump;": [8782, 824], "ncong;": [8775], "ndash;": [8211], "neArr;": [8663], "nearr;": [8599], "nedot;": [8784, 824], "nesim;": [8770, 824], "ngeqq;": [8807, 824], "ngsim;": [8821], "nhArr;": [8654], "nharr;": [8622], "nhpar;": [10994], "nlArr;": [8653], "nlarr;": [8602], "nleqq;": [8806, 824], "nless;": [8814], "nlsim;": [8820], "nltri;": [8938], "notin;": [8713], "notni;": [8716], "npart;": [8706, 824], "nprec;": [8832], "nrArr;": [8655], "nrarr;": [8603], "nrtri;": [8939], "nsime;": [8772], "nsmid;": [8740], "nspar;": [8742], "nsubE;": [10949, 824], "nsube;": [8840], "nsucc;": [8833], "nsupE;": [10950, 824], "nsupe;": [8841], "ntilde": [241], "numsp;": [8199], "nvsim;": [8764, 8402], "nwArr;": [8662], "nwarr;": [8598], "oacute": [243], "ocirc;": [244], "odash;": [8861], "oelig;": [339], "ofcir;": [10687], "ograve": [242], "ohbar;": [10677], "olarr;": [8634], "olcir;": [10686], "oline;": [8254], "omacr;": [333], "omega;": [969], "operp;": [10681], "oplus;": [8853], "orarr;": [8635], "order;": [8500], "oslash": [248], "otilde": [245], "ovbar;": [9021], "parsl;": [11005], "phone;": [9742], "plusb;": [8862], "pluse;": [10866], "plusmn": [177], "pound;": [163], "prcue;": [8828], "prime;": [8242], "prnap;": [10937], "prsim;": [8830], "quest;": [63], "rAarr;": [8667], "rBarr;": [10511], "radic;": [8730], "rangd;": [10642], "range;": [10661], "raquo;": [187], "rarrb;": [8677], "rarrc;": [10547], "rarrw;": [8605], "ratio;": [8758], "rbarr;": [10509], "rbbrk;": [10099], "rbrke;": [10636], "rceil;": [8969], "rdquo;": [8221], "reals;": [8477], "rhard;": [8641], "rharu;": [8640], "rlarr;": [8644], "rlhar;": [8652], "rnmid;": [10990], "roang;": [10221], "roarr;": [8702], "robrk;": [10215], "ropar;": [10630], "rrarr;": [8649], "rsquo;": [8217], "rtrie;": [8885], "rtrif;": [9656], "sbquo;": [8218], "sccue;": [8829], "scirc;": [349], "scnap;": [10938], "scsim;": [8831], "sdotb;": [8865], "sdote;": [10854], "seArr;": [8664], "searr;": [8600], "setmn;": [8726], "sharp;": [9839], "sigma;": [963], "simeq;": [8771], "simgE;": [10912], "simlE;": [10911], "simne;": [8774], "slarr;": [8592], "smile;": [8995], "smtes;": [10924, 65024], "sqcap;": [8851], "sqcup;": [8852], "sqsub;": [8847], "sqsup;": [8848], "srarr;": [8594], "starf;": [9733], "strns;": [175], "subnE;": [10955], "subne;": [8842], "supnE;": [10956], "supne;": [8843], "swArr;": [8665], "swarr;": [8601], "szlig;": [223], "theta;": [952], "thkap;": [8776], "thorn;": [254], "tilde;": [732], "times;": [215], "trade;": [8482], "trisb;": [10701], "tshcy;": [1115], "twixt;": [8812], "uacute": [250], "ubrcy;": [1118], "ucirc;": [251], "udarr;": [8645], "udhar;": [10606], "ugrave": [249], "uharl;": [8639], "uharr;": [8638], "uhblk;": [9600], "ultri;": [9720], "umacr;": [363], "uogon;": [371], "uplus;": [8846], "upsih;": [978], "uring;": [367], "urtri;": [9721], "utdot;": [8944], "utrif;": [9652], "uuarr;": [8648], "vBarv;": [10985], "vDash;": [8872], "varpi;": [982], "vdash;": [8866], "veeeq;": [8794], "vltri;": [8882], "vnsub;": [8834, 8402], "vnsup;": [8835, 8402], "vprop;": [8733], "vrtri;": [8883], "wcirc;": [373], "wedge;": [8743], "xcirc;": [9711], "xdtri;": [9661], "xhArr;": [10234], "xharr;": [10231], "xlArr;": [10232], "xlarr;": [10229], "xodot;": [10752], "xrArr;": [10233], "xrarr;": [10230], "xutri;": [9651], "yacute": [253], "ycirc;": [375] } }, { "length": 5, "entities": { "AElig": [198], "Acirc": [194], "Aopf;": [120120], "Aring": [197], "Ascr;": [119964], "Auml;": [196], "Barv;": [10983], "Beta;": [914], "Bopf;": [120121], "Bscr;": [8492], "CHcy;": [1063], "COPY;": [169], "Cdot;": [266], "Copf;": [8450], "Cscr;": [119966], "DJcy;": [1026], "DScy;": [1029], "DZcy;": [1039], "Darr;": [8609], "Dopf;": [120123], "Dscr;": [119967], "Ecirc": [202], "Edot;": [278], "Eopf;": [120124], "Escr;": [8496], "Esim;": [10867], "Euml;": [203], "Fopf;": [120125], "Fscr;": [8497], "GJcy;": [1027], "Gdot;": [288], "Gopf;": [120126], "Gscr;": [119970], "Hopf;": [8461], "Hscr;": [8459], "IEcy;": [1045], "IOcy;": [1025], "Icirc": [206], "Idot;": [304], "Iopf;": [120128], "Iota;": [921], "Iscr;": [8464], "Iuml;": [207], "Jopf;": [120129], "Jscr;": [119973], "KHcy;": [1061], "KJcy;": [1036], "Kopf;": [120130], "Kscr;": [119974], "LJcy;": [1033], "Lang;": [10218], "Larr;": [8606], "Lopf;": [120131], "Lscr;": [8466], "Mopf;": [120132], "Mscr;": [8499], "NJcy;": [1034], "Nopf;": [8469], "Nscr;": [119977], "Ocirc": [212], "Oopf;": [120134], "Oscr;": [119978], "Ouml;": [214], "Popf;": [8473], "Pscr;": [119979], "QUOT;": [34], "Qopf;": [8474], "Qscr;": [119980], "Rang;": [10219], "Rarr;": [8608], "Ropf;": [8477], "Rscr;": [8475], "SHcy;": [1064], "Sopf;": [120138], "Sqrt;": [8730], "Sscr;": [119982], "Star;": [8902], "THORN": [222], "TScy;": [1062], "Topf;": [120139], "Tscr;": [119983], "Uarr;": [8607], "Ucirc": [219], "Uopf;": [120140], "Upsi;": [978], "Uscr;": [119984], "Uuml;": [220], "Vbar;": [10987], "Vert;": [8214], "Vopf;": [120141], "Vscr;": [119985], "Wopf;": [120142], "Wscr;": [119986], "Xopf;": [120143], "Xscr;": [119987], "YAcy;": [1071], "YIcy;": [1031], "YUcy;": [1070], "Yopf;": [120144], "Yscr;": [119988], "Yuml;": [376], "ZHcy;": [1046], "Zdot;": [379], "Zeta;": [918], "Zopf;": [8484], "Zscr;": [119989], "acirc": [226], "acute": [180], "aelig": [230], "andd;": [10844], "andv;": [10842], "ange;": [10660], "aopf;": [120146], "apid;": [8779], "apos;": [39], "aring": [229], "ascr;": [119990], "auml;": [228], "bNot;": [10989], "bbrk;": [9141], "beta;": [946], "beth;": [8502], "bnot;": [8976], "bopf;": [120147], "boxH;": [9552], "boxV;": [9553], "boxh;": [9472], "boxv;": [9474], "bscr;": [119991], "bsim;": [8765], "bsol;": [92], "bull;": [8226], "bump;": [8782], "caps;": [8745, 65024], "cdot;": [267], "cedil": [184], "cent;": [162], "chcy;": [1095], "cirE;": [10691], "circ;": [710], "cire;": [8791], "comp;": [8705], "cong;": [8773], "copf;": [120148], "copy;": [169], "cscr;": [119992], "csub;": [10959], "csup;": [10960], "cups;": [8746, 65024], "dArr;": [8659], "dHar;": [10597], "darr;": [8595], "dash;": [8208], "diam;": [8900], "djcy;": [1106], "dopf;": [120149], "dscr;": [119993], "dscy;": [1109], "dsol;": [10742], "dtri;": [9663], "dzcy;": [1119], "eDot;": [8785], "ecir;": [8790], "ecirc": [234], "edot;": [279], "emsp;": [8195], "ensp;": [8194], "eopf;": [120150], "epar;": [8917], "epsi;": [949], "escr;": [8495], "esim;": [8770], "euml;": [235], "euro;": [8364], "excl;": [33], "flat;": [9837], "fnof;": [402], "fopf;": [120151], "fork;": [8916], "fscr;": [119995], "gdot;": [289], "geqq;": [8807], "gesl;": [8923, 65024], "gjcy;": [1107], "gnap;": [10890], "gneq;": [10888], "gopf;": [120152], "gscr;": [8458], "gsim;": [8819], "gtcc;": [10919], "gvnE;": [8809, 65024], "hArr;": [8660], "half;": [189], "harr;": [8596], "hbar;": [8463], "hopf;": [120153], "hscr;": [119997], "icirc": [238], "iecy;": [1077], "iexcl": [161], "imof;": [8887], "iocy;": [1105], "iopf;": [120154], "iota;": [953], "iscr;": [119998], "isin;": [8712], "iuml;": [239], "jopf;": [120155], "jscr;": [119999], "khcy;": [1093], "kjcy;": [1116], "kopf;": [120156], "kscr;": [120000], "lArr;": [8656], "lHar;": [10594], "lang;": [10216], "laquo": [171], "larr;": [8592], "late;": [10925], "lcub;": [123], "ldca;": [10550], "ldsh;": [8626], "leqq;": [8806], "lesg;": [8922, 65024], "ljcy;": [1113], "lnap;": [10889], "lneq;": [10887], "lopf;": [120157], "lozf;": [10731], "lpar;": [40], "lscr;": [120001], "lsim;": [8818], "lsqb;": [91], "ltcc;": [10918], "ltri;": [9667], "lvnE;": [8808, 65024], "macr;": [175], "male;": [9794], "malt;": [10016], "micro": [181], "mlcp;": [10971], "mldr;": [8230], "mopf;": [120158], "mscr;": [120002], "nGtv;": [8811, 824], "nLtv;": [8810, 824], "nang;": [8736, 8402], "napE;": [10864, 824], "nbsp;": [160], "ncap;": [10819], "ncup;": [10818], "ngeq;": [8817], "nges;": [10878, 824], "ngtr;": [8815], "nisd;": [8954], "njcy;": [1114], "nldr;": [8229], "nleq;": [8816], "nles;": [10877, 824], "nmid;": [8740], "nopf;": [120159], "npar;": [8742], "npre;": [10927, 824], "nsce;": [10928, 824], "nscr;": [120003], "nsim;": [8769], "nsub;": [8836], "nsup;": [8837], "ntgl;": [8825], "ntlg;": [8824], "nvap;": [8781, 8402], "nvge;": [8805, 8402], "nvgt;": [62, 8402], "nvle;": [8804, 8402], "nvlt;": [60, 8402], "oast;": [8859], "ocir;": [8858], "ocirc": [244], "odiv;": [10808], "odot;": [8857], "ogon;": [731], "oint;": [8750], "omid;": [10678], "oopf;": [120160], "opar;": [10679], "ordf;": [170], "ordm;": [186], "oror;": [10838], "oscr;": [8500], "osol;": [8856], "ouml;": [246], "para;": [182], "part;": [8706], "perp;": [8869], "phiv;": [981], "plus;": [43], "popf;": [120161], "pound": [163], "prap;": [10935], "prec;": [8826], "prnE;": [10933], "prod;": [8719], "prop;": [8733], "pscr;": [120005], "qint;": [10764], "qopf;": [120162], "qscr;": [120006], "quot;": [34], "rArr;": [8658], "rHar;": [10596], "race;": [8765, 817], "rang;": [10217], "raquo": [187], "rarr;": [8594], "rcub;": [125], "rdca;": [10551], "rdsh;": [8627], "real;": [8476], "rect;": [9645], "rhov;": [1009], "ring;": [730], "ropf;": [120163], "rpar;": [41], "rscr;": [120007], "rsqb;": [93], "rtri;": [9657], "scap;": [10936], "scnE;": [10934], "sdot;": [8901], "sect;": [167], "semi;": [59], "sext;": [10038], "shcy;": [1096], "sime;": [8771], "simg;": [10910], "siml;": [10909], "smid;": [8739], "smte;": [10924], "solb;": [10692], "sopf;": [120164], "spar;": [8741], "squf;": [9642], "sscr;": [120008], "star;": [9734], "subE;": [10949], "sube;": [8838], "succ;": [8827], "sung;": [9834], "sup1;": [185], "sup2;": [178], "sup3;": [179], "supE;": [10950], "supe;": [8839], "szlig": [223], "tbrk;": [9140], "tdot;": [8411], "thorn": [254], "times": [215], "tint;": [8749], "toea;": [10536], "topf;": [120165], "tosa;": [10537], "trie;": [8796], "tscr;": [120009], "tscy;": [1094], "uArr;": [8657], "uHar;": [10595], "uarr;": [8593], "ucirc": [251], "uopf;": [120166], "upsi;": [965], "uscr;": [120010], "utri;": [9653], "uuml;": [252], "vArr;": [8661], "vBar;": [10984], "varr;": [8597], "vert;": [124], "vopf;": [120167], "vscr;": [120011], "wopf;": [120168], "wscr;": [120012], "xcap;": [8898], "xcup;": [8899], "xmap;": [10236], "xnis;": [8955], "xopf;": [120169], "xscr;": [120013], "xvee;": [8897], "yacy;": [1103], "yicy;": [1111], "yopf;": [120170], "yscr;": [120014], "yucy;": [1102], "yuml;": [255], "zdot;": [380], "zeta;": [950], "zhcy;": [1078], "zopf;": [120171], "zscr;": [120015], "zwnj;": [8204] } }, { "length": 4, "entities": { "AMP;": [38], "Acy;": [1040], "Afr;": [120068], "And;": [10835], "Auml": [196], "Bcy;": [1041], "Bfr;": [120069], "COPY": [169], "Cap;": [8914], "Cfr;": [8493], "Chi;": [935], "Cup;": [8915], "Dcy;": [1044], "Del;": [8711], "Dfr;": [120071], "Dot;": [168], "ENG;": [330], "ETH;": [208], "Ecy;": [1069], "Efr;": [120072], "Eta;": [919], "Euml": [203], "Fcy;": [1060], "Ffr;": [120073], "Gcy;": [1043], "Gfr;": [120074], "Hat;": [94], "Hfr;": [8460], "Icy;": [1048], "Ifr;": [8465], "Int;": [8748], "Iuml": [207], "Jcy;": [1049], "Jfr;": [120077], "Kcy;": [1050], "Kfr;": [120078], "Lcy;": [1051], "Lfr;": [120079], "Lsh;": [8624], "Map;": [10501], "Mcy;": [1052], "Mfr;": [120080], "Ncy;": [1053], "Nfr;": [120081], "Not;": [10988], "Ocy;": [1054], "Ofr;": [120082], "Ouml": [214], "Pcy;": [1055], "Pfr;": [120083], "Phi;": [934], "Psi;": [936], "QUOT": [34], "Qfr;": [120084], "REG;": [174], "Rcy;": [1056], "Rfr;": [8476], "Rho;": [929], "Rsh;": [8625], "Scy;": [1057], "Sfr;": [120086], "Sub;": [8912], "Sum;": [8721], "Sup;": [8913], "Tab;": [9], "Tau;": [932], "Tcy;": [1058], "Tfr;": [120087], "Ucy;": [1059], "Ufr;": [120088], "Uuml": [220], "Vcy;": [1042], "Vee;": [8897], "Vfr;": [120089], "Wfr;": [120090], "Xfr;": [120091], "Ycy;": [1067], "Yfr;": [120092], "Zcy;": [1047], "Zfr;": [8488], "acE;": [8766, 819], "acd;": [8767], "acy;": [1072], "afr;": [120094], "amp;": [38], "and;": [8743], "ang;": [8736], "apE;": [10864], "ape;": [8778], "ast;": [42], "auml": [228], "bcy;": [1073], "bfr;": [120095], "bne;": [61, 8421], "bot;": [8869], "cap;": [8745], "cent": [162], "cfr;": [120096], "chi;": [967], "cir;": [9675], "copy": [169], "cup;": [8746], "dcy;": [1076], "deg;": [176], "dfr;": [120097], "die;": [168], "div;": [247], "dot;": [729], "ecy;": [1101], "efr;": [120098], "egs;": [10902], "ell;": [8467], "els;": [10901], "eng;": [331], "eta;": [951], "eth;": [240], "euml": [235], "fcy;": [1092], "ffr;": [120099], "gEl;": [10892], "gap;": [10886], "gcy;": [1075], "gel;": [8923], "geq;": [8805], "ges;": [10878], "gfr;": [120100], "ggg;": [8921], "glE;": [10898], "gla;": [10917], "glj;": [10916], "gnE;": [8809], "gne;": [10888], "hfr;": [120101], "icy;": [1080], "iff;": [8660], "ifr;": [120102], "int;": [8747], "iuml": [239], "jcy;": [1081], "jfr;": [120103], "kcy;": [1082], "kfr;": [120104], "lEg;": [10891], "lap;": [10885], "lat;": [10923], "lcy;": [1083], "leg;": [8922], "leq;": [8804], "les;": [10877], "lfr;": [120105], "lgE;": [10897], "lnE;": [8808], "lne;": [10887], "loz;": [9674], "lrm;": [8206], "lsh;": [8624], "macr": [175], "map;": [8614], "mcy;": [1084], "mfr;": [120106], "mho;": [8487], "mid;": [8739], "nGg;": [8921, 824], "nGt;": [8811, 8402], "nLl;": [8920, 824], "nLt;": [8810, 8402], "nap;": [8777], "nbsp": [160], "ncy;": [1085], "nfr;": [120107], "ngE;": [8807, 824], "nge;": [8817], "ngt;": [8815], "nis;": [8956], "niv;": [8715], "nlE;": [8806, 824], "nle;": [8816], "nlt;": [8814], "not;": [172], "npr;": [8832], "nsc;": [8833], "num;": [35], "ocy;": [1086], "ofr;": [120108], "ogt;": [10689], "ohm;": [937], "olt;": [10688], "ord;": [10845], "ordf": [170], "ordm": [186], "orv;": [10843], "ouml": [246], "par;": [8741], "para": [182], "pcy;": [1087], "pfr;": [120109], "phi;": [966], "piv;": [982], "prE;": [10931], "pre;": [10927], "psi;": [968], "qfr;": [120110], "quot": [34], "rcy;": [1088], "reg;": [174], "rfr;": [120111], "rho;": [961], "rlm;": [8207], "rsh;": [8625], "scE;": [10932], "sce;": [10928], "scy;": [1089], "sect": [167], "sfr;": [120112], "shy;": [173], "sim;": [8764], "smt;": [10922], "sol;": [47], "squ;": [9633], "sub;": [8834], "sum;": [8721], "sup1": [185], "sup2": [178], "sup3": [179], "sup;": [8835], "tau;": [964], "tcy;": [1090], "tfr;": [120113], "top;": [8868], "ucy;": [1091], "ufr;": [120114], "uml;": [168], "uuml": [252], "vcy;": [1074], "vee;": [8744], "vfr;": [120115], "wfr;": [120116], "xfr;": [120117], "ycy;": [1099], "yen;": [165], "yfr;": [120118], "yuml": [255], "zcy;": [1079], "zfr;": [120119], "zwj;": [8205] } }, { "length": 3, "entities": { "AMP": [38], "DD;": [8517], "ETH": [208], "GT;": [62], "Gg;": [8921], "Gt;": [8811], "Im;": [8465], "LT;": [60], "Ll;": [8920], "Lt;": [8810], "Mu;": [924], "Nu;": [925], "Or;": [10836], "Pi;": [928], "Pr;": [10939], "REG": [174], "Re;": [8476], "Sc;": [10940], "Xi;": [926], "ac;": [8766], "af;": [8289], "amp": [38], "ap;": [8776], "dd;": [8518], "deg": [176], "ee;": [8519], "eg;": [10906], "el;": [10905], "eth": [240], "gE;": [8807], "ge;": [8805], "gg;": [8811], "gl;": [8823], "gt;": [62], "ic;": [8291], "ii;": [8520], "in;": [8712], "it;": [8290], "lE;": [8806], "le;": [8804], "lg;": [8822], "ll;": [8810], "lt;": [60], "mp;": [8723], "mu;": [956], "ne;": [8800], "ni;": [8715], "not": [172], "nu;": [957], "oS;": [9416], "or;": [8744], "pi;": [960], "pm;": [177], "pr;": [8826], "reg": [174], "rx;": [8478], "sc;": [8827], "shy": [173], "uml": [168], "wp;": [8472], "wr;": [8768], "xi;": [958], "yen": [165] } }, { "length": 2, "entities": { "GT": [62], "LT": [60], "gt": [62], "lt": [60] } }];
2036
2037 const EOF = -1;
2038 const NULL = 0x00;
2039 const TABULATION = 0x09;
2040 const CARRIAGE_RETURN = 0x0D;
2041 const LINE_FEED = 0x0A;
2042 const FORM_FEED = 0x0C;
2043 const SPACE = 0x20;
2044 const EXCLAMATION_MARK = 0x21;
2045 const QUOTATION_MARK = 0x22;
2046 const NUMBER_SIGN = 0x23;
2047 const AMPERSAND = 0x26;
2048 const APOSTROPHE = 0x27;
2049 const HYPHEN_MINUS = 0x2D;
2050 const SOLIDUS = 0x2F;
2051 const DIGIT_0 = 0x30;
2052 const DIGIT_9 = 0x39;
2053 const SEMICOLON = 0x3B;
2054 const LESS_THAN_SIGN = 0x3C;
2055 const EQUALS_SIGN = 0x3D;
2056 const GREATER_THAN_SIGN = 0x3E;
2057 const QUESTION_MARK = 0x3F;
2058 const LATIN_CAPITAL_A = 0x41;
2059 const LATIN_CAPITAL_D = 0x44;
2060 const LATIN_CAPITAL_F = 0x46;
2061 const LATIN_CAPITAL_X = 0x58;
2062 const LATIN_CAPITAL_Z = 0x5A;
2063 const LEFT_SQUARE_BRACKET = 0x5B;
2064 const RIGHT_SQUARE_BRACKET = 0x5D;
2065 const GRAVE_ACCENT = 0x60;
2066 const LATIN_SMALL_A = 0x61;
2067 const LATIN_SMALL_F = 0x66;
2068 const LATIN_SMALL_X = 0x78;
2069 const LATIN_SMALL_Z = 0x7A;
2070 const LEFT_CURLY_BRACKET = 0x7B;
2071 const RIGHT_CURLY_BRACKET = 0x7D;
2072 const NULL_REPLACEMENT = 0xFFFD;
2073 function isWhitespace(cp) {
2074     return cp === TABULATION || cp === LINE_FEED || cp === FORM_FEED || cp === CARRIAGE_RETURN || cp === SPACE;
2075 }
2076 function isUpperLetter(cp) {
2077     return cp >= LATIN_CAPITAL_A && cp <= LATIN_CAPITAL_Z;
2078 }
2079 function isLowerLetter(cp) {
2080     return cp >= LATIN_SMALL_A && cp <= LATIN_SMALL_Z;
2081 }
2082 function isLetter(cp) {
2083     return isLowerLetter(cp) || isUpperLetter(cp);
2084 }
2085 function isDigit(cp) {
2086     return cp >= DIGIT_0 && cp <= DIGIT_9;
2087 }
2088 function isUpperHexDigit(cp) {
2089     return cp >= LATIN_CAPITAL_A && cp <= LATIN_CAPITAL_F;
2090 }
2091 function isLowerHexDigit(cp) {
2092     return cp >= LATIN_SMALL_A && cp <= LATIN_SMALL_F;
2093 }
2094 function isHexDigit(cp) {
2095     return isDigit(cp) || isUpperHexDigit(cp) || isLowerHexDigit(cp);
2096 }
2097 function isControl(cp) {
2098     return (cp >= 0 && cp <= 0x1F) || (cp >= 0x7F && cp <= 0x9F);
2099 }
2100 function isSurrogate(cp) {
2101     return cp >= 0xD800 && cp <= 0xDFFF;
2102 }
2103 function isSurrogatePair(cp) {
2104     return cp >= 0xDC00 && cp <= 0xDFFF;
2105 }
2106 function isNonCharacter(cp) {
2107     return ((cp >= 0xFDD0 && cp <= 0xFDEF) ||
2108         ((cp & 0xFFFE) === 0xFFFE && cp <= 0x10FFFF));
2109 }
2110 function toLowerCodePoint(cp) {
2111     return cp + 0x0020;
2112 }
2113
2114 class Tokenizer {
2115     constructor(text) {
2116         debug("[html] the source code length: %d", text.length);
2117         this.text = text;
2118         this.gaps = [];
2119         this.lineTerminators = [];
2120         this.lastCodePoint = NULL;
2121         this.offset = -1;
2122         this.column = -1;
2123         this.line = 1;
2124         this.state = "DATA";
2125         this.returnState = "DATA";
2126         this.reconsuming = false;
2127         this.buffer = [];
2128         this.crStartOffset = -1;
2129         this.crCode = 0;
2130         this.errors = [];
2131         this.committedToken = null;
2132         this.provisionalToken = null;
2133         this.currentToken = null;
2134         this.lastTagOpenToken = null;
2135         this.tokenStartOffset = -1;
2136         this.tokenStartColumn = -1;
2137         this.tokenStartLine = 1;
2138         this.namespace = NS.HTML;
2139         this.expressionEnabled = false;
2140     }
2141     nextToken() {
2142         let cp = this.lastCodePoint;
2143         while (this.committedToken == null &&
2144             (cp !== EOF || this.reconsuming)) {
2145             if (this.provisionalToken != null && !this.isProvisionalState()) {
2146                 this.commitProvisionalToken();
2147                 if (this.committedToken != null) {
2148                     break;
2149                 }
2150             }
2151             if (this.reconsuming) {
2152                 this.reconsuming = false;
2153                 cp = this.lastCodePoint;
2154             }
2155             else {
2156                 cp = this.consumeNextCodePoint();
2157             }
2158             debug("[html] parse", cp, this.state);
2159             this.state = this[this.state](cp);
2160         }
2161         {
2162             const token = this.consumeCommittedToken();
2163             if (token != null) {
2164                 return token;
2165             }
2166         }
2167         assert(cp === EOF);
2168         if (this.currentToken != null) {
2169             this.endToken();
2170             const token = this.consumeCommittedToken();
2171             if (token != null) {
2172                 return token;
2173             }
2174         }
2175         return this.currentToken;
2176     }
2177     consumeCommittedToken() {
2178         const token = this.committedToken;
2179         this.committedToken = null;
2180         return token;
2181     }
2182     consumeNextCodePoint() {
2183         if (this.offset >= this.text.length) {
2184             this.lastCodePoint = EOF;
2185             return EOF;
2186         }
2187         this.offset += this.lastCodePoint >= 0x10000 ? 2 : 1;
2188         if (this.offset >= this.text.length) {
2189             this.advanceLocation();
2190             this.lastCodePoint = EOF;
2191             return EOF;
2192         }
2193         const cp = this.text.codePointAt(this.offset);
2194         if (isSurrogate(this.text.charCodeAt(this.offset)) &&
2195             !isSurrogatePair(this.text.charCodeAt(this.offset + 1))) {
2196             this.reportParseError("surrogate-in-input-stream");
2197         }
2198         if (isNonCharacter(cp)) {
2199             this.reportParseError("noncharacter-in-input-stream");
2200         }
2201         if (isControl(cp) && !isWhitespace(cp) && cp !== NULL) {
2202             this.reportParseError("control-character-in-input-stream");
2203         }
2204         if (this.lastCodePoint === CARRIAGE_RETURN && cp === LINE_FEED) {
2205             this.lastCodePoint = LINE_FEED;
2206             this.gaps.push(this.offset);
2207             return this.consumeNextCodePoint();
2208         }
2209         this.advanceLocation();
2210         this.lastCodePoint = cp;
2211         if (cp === CARRIAGE_RETURN) {
2212             return LINE_FEED;
2213         }
2214         return cp;
2215     }
2216     advanceLocation() {
2217         if (this.lastCodePoint === LINE_FEED) {
2218             this.lineTerminators.push(this.offset);
2219             this.line += 1;
2220             this.column = 0;
2221         }
2222         else {
2223             this.column += this.lastCodePoint >= 0x10000 ? 2 : 1;
2224         }
2225     }
2226     reconsumeAs(state) {
2227         this.reconsuming = true;
2228         return state;
2229     }
2230     reportParseError(code) {
2231         const error = ParseError.fromCode(code, this.offset, this.line, this.column);
2232         this.errors.push(error);
2233         debug("[html] syntax error:", error.message);
2234     }
2235     setStartTokenMark() {
2236         this.tokenStartOffset = this.offset;
2237         this.tokenStartLine = this.line;
2238         this.tokenStartColumn = this.column;
2239     }
2240     clearStartTokenMark() {
2241         this.tokenStartOffset = -1;
2242     }
2243     startToken(type) {
2244         if (this.tokenStartOffset === -1) {
2245             this.setStartTokenMark();
2246         }
2247         const offset = this.tokenStartOffset;
2248         const line = this.tokenStartLine;
2249         const column = this.tokenStartColumn;
2250         if (this.currentToken != null) {
2251             this.endToken();
2252         }
2253         this.tokenStartOffset = -1;
2254         const token = (this.currentToken = {
2255             type,
2256             range: [offset, -1],
2257             loc: {
2258                 start: { line, column },
2259                 end: { line: -1, column: -1 },
2260             },
2261             value: "",
2262         });
2263         debug("[html] start token: %d %s", offset, token.type);
2264         return this.currentToken;
2265     }
2266     endToken() {
2267         if (this.currentToken == null) {
2268             throw new Error("Invalid state");
2269         }
2270         if (this.tokenStartOffset === -1) {
2271             this.setStartTokenMark();
2272         }
2273         const token = this.currentToken;
2274         const offset = this.tokenStartOffset;
2275         const line = this.tokenStartLine;
2276         const column = this.tokenStartColumn;
2277         const provisional = this.isProvisionalState();
2278         this.currentToken = null;
2279         this.tokenStartOffset = -1;
2280         token.range[1] = offset;
2281         token.loc.end.line = line;
2282         token.loc.end.column = column;
2283         if (token.range[0] === offset && !provisional) {
2284             debug("[html] abandon token: %j %s %j", token.range, token.type, token.value);
2285             return null;
2286         }
2287         if (provisional) {
2288             if (this.provisionalToken != null) {
2289                 this.commitProvisionalToken();
2290             }
2291             this.provisionalToken = token;
2292             debug("[html] provisional-commit token: %j %s %j", token.range, token.type, token.value);
2293         }
2294         else {
2295             this.commitToken(token);
2296         }
2297         return token;
2298     }
2299     commitToken(token) {
2300         assert(this.committedToken == null, "Invalid state: the commited token existed already.");
2301         debug("[html] commit token: %j %j %s %j", token.range, token.loc, token.type, token.value);
2302         this.committedToken = token;
2303         if (token.type === "HTMLTagOpen") {
2304             this.lastTagOpenToken = token;
2305         }
2306     }
2307     isProvisionalState() {
2308         return (this.state.startsWith("RCDATA_") ||
2309             this.state.startsWith("RAWTEXT_"));
2310     }
2311     commitProvisionalToken() {
2312         assert(this.provisionalToken != null, "Invalid state: the provisional token was not found.");
2313         const token = this.provisionalToken;
2314         this.provisionalToken = null;
2315         if (token.range[0] < token.range[1]) {
2316             this.commitToken(token);
2317         }
2318     }
2319     rollbackProvisionalToken() {
2320         assert(this.currentToken != null);
2321         assert(this.provisionalToken != null);
2322         const token = this.currentToken;
2323         debug("[html] rollback token: %d %s", token.range[0], token.type);
2324         this.currentToken = this.provisionalToken;
2325         this.provisionalToken = null;
2326     }
2327     appendTokenValue(cp, expected) {
2328         const token = this.currentToken;
2329         if (token == null || (expected != null && token.type !== expected)) {
2330             const msg1 = expected ? `"${expected}" type` : "any token";
2331             const msg2 = token ? `"${token.type}" type` : "no token";
2332             throw new Error(`Tokenizer: Invalid state. Expected ${msg1}, but got ${msg2}.`);
2333         }
2334         token.value += String.fromCodePoint(cp);
2335     }
2336     isAppropriateEndTagOpen() {
2337         return (this.currentToken != null &&
2338             this.lastTagOpenToken != null &&
2339             this.currentToken.type === "HTMLEndTagOpen" &&
2340             this.currentToken.value === this.lastTagOpenToken.value);
2341     }
2342     DATA(cp) {
2343         this.clearStartTokenMark();
2344         while (true) {
2345             const type = isWhitespace(cp) ? "HTMLWhitespace" : "HTMLText";
2346             if (this.currentToken != null && this.currentToken.type !== type) {
2347                 this.endToken();
2348                 return this.reconsumeAs(this.state);
2349             }
2350             if (this.currentToken == null) {
2351                 this.startToken(type);
2352             }
2353             if (cp === AMPERSAND) {
2354                 this.returnState = "DATA";
2355                 return "CHARACTER_REFERENCE";
2356             }
2357             if (cp === LESS_THAN_SIGN) {
2358                 this.setStartTokenMark();
2359                 return "TAG_OPEN";
2360             }
2361             if (cp === LEFT_CURLY_BRACKET && this.expressionEnabled) {
2362                 this.setStartTokenMark();
2363                 this.returnState = "DATA";
2364                 return "V_EXPRESSION_START";
2365             }
2366             if (cp === RIGHT_CURLY_BRACKET && this.expressionEnabled) {
2367                 this.setStartTokenMark();
2368                 this.returnState = "DATA";
2369                 return "V_EXPRESSION_END";
2370             }
2371             if (cp === EOF) {
2372                 return "DATA";
2373             }
2374             if (cp === NULL) {
2375                 this.reportParseError("unexpected-null-character");
2376             }
2377             this.appendTokenValue(cp, type);
2378             cp = this.consumeNextCodePoint();
2379         }
2380     }
2381     RCDATA(cp) {
2382         this.clearStartTokenMark();
2383         while (true) {
2384             const type = isWhitespace(cp) ? "HTMLWhitespace" : "HTMLRCDataText";
2385             if (this.currentToken != null && this.currentToken.type !== type) {
2386                 this.endToken();
2387                 return this.reconsumeAs(this.state);
2388             }
2389             if (this.currentToken == null) {
2390                 this.startToken(type);
2391             }
2392             if (cp === AMPERSAND) {
2393                 this.returnState = "RCDATA";
2394                 return "CHARACTER_REFERENCE";
2395             }
2396             if (cp === LESS_THAN_SIGN) {
2397                 this.setStartTokenMark();
2398                 return "RCDATA_LESS_THAN_SIGN";
2399             }
2400             if (cp === LEFT_CURLY_BRACKET && this.expressionEnabled) {
2401                 this.setStartTokenMark();
2402                 this.returnState = "RCDATA";
2403                 return "V_EXPRESSION_START";
2404             }
2405             if (cp === RIGHT_CURLY_BRACKET && this.expressionEnabled) {
2406                 this.setStartTokenMark();
2407                 this.returnState = "RCDATA";
2408                 return "V_EXPRESSION_END";
2409             }
2410             if (cp === EOF) {
2411                 return "DATA";
2412             }
2413             if (cp === NULL) {
2414                 this.reportParseError("unexpected-null-character");
2415                 cp = NULL_REPLACEMENT;
2416             }
2417             this.appendTokenValue(cp, type);
2418             cp = this.consumeNextCodePoint();
2419         }
2420     }
2421     RAWTEXT(cp) {
2422         this.clearStartTokenMark();
2423         while (true) {
2424             const type = isWhitespace(cp) ? "HTMLWhitespace" : "HTMLRawText";
2425             if (this.currentToken != null && this.currentToken.type !== type) {
2426                 this.endToken();
2427                 return this.reconsumeAs(this.state);
2428             }
2429             if (this.currentToken == null) {
2430                 this.startToken(type);
2431             }
2432             if (cp === LESS_THAN_SIGN) {
2433                 this.setStartTokenMark();
2434                 return "RAWTEXT_LESS_THAN_SIGN";
2435             }
2436             if (cp === LEFT_CURLY_BRACKET && this.expressionEnabled) {
2437                 this.setStartTokenMark();
2438                 this.returnState = "RAWTEXT";
2439                 return "V_EXPRESSION_START";
2440             }
2441             if (cp === RIGHT_CURLY_BRACKET && this.expressionEnabled) {
2442                 this.setStartTokenMark();
2443                 this.returnState = "RAWTEXT";
2444                 return "V_EXPRESSION_END";
2445             }
2446             if (cp === EOF) {
2447                 return "DATA";
2448             }
2449             if (cp === NULL) {
2450                 this.reportParseError("unexpected-null-character");
2451                 cp = NULL_REPLACEMENT;
2452             }
2453             this.appendTokenValue(cp, type);
2454             cp = this.consumeNextCodePoint();
2455         }
2456     }
2457     TAG_OPEN(cp) {
2458         if (cp === EXCLAMATION_MARK) {
2459             return "MARKUP_DECLARATION_OPEN";
2460         }
2461         if (cp === SOLIDUS) {
2462             return "END_TAG_OPEN";
2463         }
2464         if (isLetter(cp)) {
2465             this.startToken("HTMLTagOpen");
2466             return this.reconsumeAs("TAG_NAME");
2467         }
2468         if (cp === QUESTION_MARK) {
2469             this.reportParseError("unexpected-question-mark-instead-of-tag-name");
2470             this.startToken("HTMLBogusComment");
2471             return this.reconsumeAs("BOGUS_COMMENT");
2472         }
2473         if (cp === EOF) {
2474             this.clearStartTokenMark();
2475             this.reportParseError("eof-before-tag-name");
2476             this.appendTokenValue(LESS_THAN_SIGN, "HTMLText");
2477             return "DATA";
2478         }
2479         this.reportParseError("invalid-first-character-of-tag-name");
2480         this.appendTokenValue(LESS_THAN_SIGN, "HTMLText");
2481         return this.reconsumeAs("DATA");
2482     }
2483     END_TAG_OPEN(cp) {
2484         if (isLetter(cp)) {
2485             this.startToken("HTMLEndTagOpen");
2486             return this.reconsumeAs("TAG_NAME");
2487         }
2488         if (cp === GREATER_THAN_SIGN) {
2489             this.endToken();
2490             this.reportParseError("missing-end-tag-name");
2491             return "DATA";
2492         }
2493         if (cp === EOF) {
2494             this.clearStartTokenMark();
2495             this.reportParseError("eof-before-tag-name");
2496             this.appendTokenValue(LESS_THAN_SIGN, "HTMLText");
2497             this.appendTokenValue(SOLIDUS, "HTMLText");
2498             return "DATA";
2499         }
2500         this.reportParseError("invalid-first-character-of-tag-name");
2501         this.startToken("HTMLBogusComment");
2502         return this.reconsumeAs("BOGUS_COMMENT");
2503     }
2504     TAG_NAME(cp) {
2505         while (true) {
2506             if (isWhitespace(cp)) {
2507                 this.endToken();
2508                 return "BEFORE_ATTRIBUTE_NAME";
2509             }
2510             if (cp === SOLIDUS) {
2511                 this.endToken();
2512                 this.setStartTokenMark();
2513                 return "SELF_CLOSING_START_TAG";
2514             }
2515             if (cp === GREATER_THAN_SIGN) {
2516                 this.startToken("HTMLTagClose");
2517                 return "DATA";
2518             }
2519             if (cp === EOF) {
2520                 this.reportParseError("eof-in-tag");
2521                 return "DATA";
2522             }
2523             if (cp === NULL) {
2524                 this.reportParseError("unexpected-null-character");
2525                 cp = NULL_REPLACEMENT;
2526             }
2527             this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, null);
2528             cp = this.consumeNextCodePoint();
2529         }
2530     }
2531     RCDATA_LESS_THAN_SIGN(cp) {
2532         if (cp === SOLIDUS) {
2533             this.buffer = [];
2534             return "RCDATA_END_TAG_OPEN";
2535         }
2536         this.appendTokenValue(LESS_THAN_SIGN, "HTMLRCDataText");
2537         return this.reconsumeAs("RCDATA");
2538     }
2539     RCDATA_END_TAG_OPEN(cp) {
2540         if (isLetter(cp)) {
2541             this.startToken("HTMLEndTagOpen");
2542             return this.reconsumeAs("RCDATA_END_TAG_NAME");
2543         }
2544         this.appendTokenValue(LESS_THAN_SIGN, "HTMLRCDataText");
2545         this.appendTokenValue(SOLIDUS, "HTMLRCDataText");
2546         return this.reconsumeAs("RCDATA");
2547     }
2548     RCDATA_END_TAG_NAME(cp) {
2549         while (true) {
2550             if (isWhitespace(cp) && this.isAppropriateEndTagOpen()) {
2551                 this.endToken();
2552                 return "BEFORE_ATTRIBUTE_NAME";
2553             }
2554             if (cp === SOLIDUS && this.isAppropriateEndTagOpen()) {
2555                 this.endToken();
2556                 this.setStartTokenMark();
2557                 return "SELF_CLOSING_START_TAG";
2558             }
2559             if (cp === GREATER_THAN_SIGN && this.isAppropriateEndTagOpen()) {
2560                 this.startToken("HTMLTagClose");
2561                 return "DATA";
2562             }
2563             if (!isLetter(cp)) {
2564                 this.rollbackProvisionalToken();
2565                 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRCDataText");
2566                 this.appendTokenValue(SOLIDUS, "HTMLRCDataText");
2567                 for (const cp1 of this.buffer) {
2568                     this.appendTokenValue(cp1, "HTMLRCDataText");
2569                 }
2570                 return this.reconsumeAs("RCDATA");
2571             }
2572             this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, "HTMLEndTagOpen");
2573             this.buffer.push(cp);
2574             cp = this.consumeNextCodePoint();
2575         }
2576     }
2577     RAWTEXT_LESS_THAN_SIGN(cp) {
2578         if (cp === SOLIDUS) {
2579             this.buffer = [];
2580             return "RAWTEXT_END_TAG_OPEN";
2581         }
2582         this.appendTokenValue(LESS_THAN_SIGN, "HTMLRawText");
2583         return this.reconsumeAs("RAWTEXT");
2584     }
2585     RAWTEXT_END_TAG_OPEN(cp) {
2586         if (isLetter(cp)) {
2587             this.startToken("HTMLEndTagOpen");
2588             return this.reconsumeAs("RAWTEXT_END_TAG_NAME");
2589         }
2590         this.appendTokenValue(LESS_THAN_SIGN, "HTMLRawText");
2591         this.appendTokenValue(SOLIDUS, "HTMLRawText");
2592         return this.reconsumeAs("RAWTEXT");
2593     }
2594     RAWTEXT_END_TAG_NAME(cp) {
2595         while (true) {
2596             if (cp === SOLIDUS && this.isAppropriateEndTagOpen()) {
2597                 this.endToken();
2598                 this.setStartTokenMark();
2599                 return "SELF_CLOSING_START_TAG";
2600             }
2601             if (cp === GREATER_THAN_SIGN && this.isAppropriateEndTagOpen()) {
2602                 this.startToken("HTMLTagClose");
2603                 return "DATA";
2604             }
2605             if (isWhitespace(cp) && this.isAppropriateEndTagOpen()) {
2606                 this.endToken();
2607                 return "BEFORE_ATTRIBUTE_NAME";
2608             }
2609             if (!isLetter(cp)) {
2610                 this.rollbackProvisionalToken();
2611                 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRawText");
2612                 this.appendTokenValue(SOLIDUS, "HTMLRawText");
2613                 for (const cp1 of this.buffer) {
2614                     this.appendTokenValue(cp1, "HTMLRawText");
2615                 }
2616                 return this.reconsumeAs("RAWTEXT");
2617             }
2618             this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, "HTMLEndTagOpen");
2619             this.buffer.push(cp);
2620             cp = this.consumeNextCodePoint();
2621         }
2622     }
2623     BEFORE_ATTRIBUTE_NAME(cp) {
2624         while (isWhitespace(cp)) {
2625             cp = this.consumeNextCodePoint();
2626         }
2627         if (cp === SOLIDUS || cp === GREATER_THAN_SIGN || cp === EOF) {
2628             return this.reconsumeAs("AFTER_ATTRIBUTE_NAME");
2629         }
2630         if (cp === EQUALS_SIGN) {
2631             this.reportParseError("unexpected-equals-sign-before-attribute-name");
2632             this.startToken("HTMLIdentifier");
2633             this.appendTokenValue(cp, "HTMLIdentifier");
2634             return "ATTRIBUTE_NAME";
2635         }
2636         this.startToken("HTMLIdentifier");
2637         return this.reconsumeAs("ATTRIBUTE_NAME");
2638     }
2639     ATTRIBUTE_NAME(cp) {
2640         while (true) {
2641             if (isWhitespace(cp) ||
2642                 cp === SOLIDUS ||
2643                 cp === GREATER_THAN_SIGN ||
2644                 cp === EOF) {
2645                 this.endToken();
2646                 return this.reconsumeAs("AFTER_ATTRIBUTE_NAME");
2647             }
2648             if (cp === EQUALS_SIGN) {
2649                 this.startToken("HTMLAssociation");
2650                 return "BEFORE_ATTRIBUTE_VALUE";
2651             }
2652             if (cp === NULL) {
2653                 this.reportParseError("unexpected-null-character");
2654                 cp = NULL_REPLACEMENT;
2655             }
2656             if (cp === QUOTATION_MARK ||
2657                 cp === APOSTROPHE ||
2658                 cp === LESS_THAN_SIGN) {
2659                 this.reportParseError("unexpected-character-in-attribute-name");
2660             }
2661             this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, "HTMLIdentifier");
2662             cp = this.consumeNextCodePoint();
2663         }
2664     }
2665     AFTER_ATTRIBUTE_NAME(cp) {
2666         while (isWhitespace(cp)) {
2667             cp = this.consumeNextCodePoint();
2668         }
2669         if (cp === SOLIDUS) {
2670             this.setStartTokenMark();
2671             return "SELF_CLOSING_START_TAG";
2672         }
2673         if (cp === EQUALS_SIGN) {
2674             this.startToken("HTMLAssociation");
2675             return "BEFORE_ATTRIBUTE_VALUE";
2676         }
2677         if (cp === GREATER_THAN_SIGN) {
2678             this.startToken("HTMLTagClose");
2679             return "DATA";
2680         }
2681         if (cp === EOF) {
2682             this.reportParseError("eof-in-tag");
2683             return "DATA";
2684         }
2685         this.startToken("HTMLIdentifier");
2686         return this.reconsumeAs("ATTRIBUTE_NAME");
2687     }
2688     BEFORE_ATTRIBUTE_VALUE(cp) {
2689         this.endToken();
2690         while (isWhitespace(cp)) {
2691             cp = this.consumeNextCodePoint();
2692         }
2693         if (cp === GREATER_THAN_SIGN) {
2694             this.reportParseError("missing-attribute-value");
2695             this.startToken("HTMLTagClose");
2696             return "DATA";
2697         }
2698         this.startToken("HTMLLiteral");
2699         if (cp === QUOTATION_MARK) {
2700             return "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
2701         }
2702         if (cp === APOSTROPHE) {
2703             return "ATTRIBUTE_VALUE_SINGLE_QUOTED";
2704         }
2705         return this.reconsumeAs("ATTRIBUTE_VALUE_UNQUOTED");
2706     }
2707     ATTRIBUTE_VALUE_DOUBLE_QUOTED(cp) {
2708         while (true) {
2709             if (cp === QUOTATION_MARK) {
2710                 return "AFTER_ATTRIBUTE_VALUE_QUOTED";
2711             }
2712             if (cp === AMPERSAND) {
2713                 this.returnState = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
2714                 return "CHARACTER_REFERENCE";
2715             }
2716             if (cp === NULL) {
2717                 this.reportParseError("unexpected-null-character");
2718                 cp = NULL_REPLACEMENT;
2719             }
2720             if (cp === EOF) {
2721                 this.reportParseError("eof-in-tag");
2722                 return "DATA";
2723             }
2724             this.appendTokenValue(cp, "HTMLLiteral");
2725             cp = this.consumeNextCodePoint();
2726         }
2727     }
2728     ATTRIBUTE_VALUE_SINGLE_QUOTED(cp) {
2729         while (true) {
2730             if (cp === APOSTROPHE) {
2731                 return "AFTER_ATTRIBUTE_VALUE_QUOTED";
2732             }
2733             if (cp === AMPERSAND) {
2734                 this.returnState = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
2735                 return "CHARACTER_REFERENCE";
2736             }
2737             if (cp === NULL) {
2738                 this.reportParseError("unexpected-null-character");
2739                 cp = NULL_REPLACEMENT;
2740             }
2741             if (cp === EOF) {
2742                 this.reportParseError("eof-in-tag");
2743                 return "DATA";
2744             }
2745             this.appendTokenValue(cp, "HTMLLiteral");
2746             cp = this.consumeNextCodePoint();
2747         }
2748     }
2749     ATTRIBUTE_VALUE_UNQUOTED(cp) {
2750         while (true) {
2751             if (isWhitespace(cp)) {
2752                 this.endToken();
2753                 return "BEFORE_ATTRIBUTE_NAME";
2754             }
2755             if (cp === AMPERSAND) {
2756                 this.returnState = "ATTRIBUTE_VALUE_UNQUOTED";
2757                 return "CHARACTER_REFERENCE";
2758             }
2759             if (cp === GREATER_THAN_SIGN) {
2760                 this.startToken("HTMLTagClose");
2761                 return "DATA";
2762             }
2763             if (cp === NULL) {
2764                 this.reportParseError("unexpected-null-character");
2765                 cp = NULL_REPLACEMENT;
2766             }
2767             if (cp === QUOTATION_MARK ||
2768                 cp === APOSTROPHE ||
2769                 cp === LESS_THAN_SIGN ||
2770                 cp === EQUALS_SIGN ||
2771                 cp === GRAVE_ACCENT) {
2772                 this.reportParseError("unexpected-character-in-unquoted-attribute-value");
2773             }
2774             if (cp === EOF) {
2775                 this.reportParseError("eof-in-tag");
2776                 return "DATA";
2777             }
2778             this.appendTokenValue(cp, "HTMLLiteral");
2779             cp = this.consumeNextCodePoint();
2780         }
2781     }
2782     AFTER_ATTRIBUTE_VALUE_QUOTED(cp) {
2783         this.endToken();
2784         if (isWhitespace(cp)) {
2785             return "BEFORE_ATTRIBUTE_NAME";
2786         }
2787         if (cp === SOLIDUS) {
2788             this.setStartTokenMark();
2789             return "SELF_CLOSING_START_TAG";
2790         }
2791         if (cp === GREATER_THAN_SIGN) {
2792             this.startToken("HTMLTagClose");
2793             return "DATA";
2794         }
2795         if (cp === EOF) {
2796             this.reportParseError("eof-in-tag");
2797             return "DATA";
2798         }
2799         this.reportParseError("missing-whitespace-between-attributes");
2800         return this.reconsumeAs("BEFORE_ATTRIBUTE_NAME");
2801     }
2802     SELF_CLOSING_START_TAG(cp) {
2803         if (cp === GREATER_THAN_SIGN) {
2804             this.startToken("HTMLSelfClosingTagClose");
2805             return "DATA";
2806         }
2807         if (cp === EOF) {
2808             this.reportParseError("eof-in-tag");
2809             return "DATA";
2810         }
2811         this.reportParseError("unexpected-solidus-in-tag");
2812         this.clearStartTokenMark();
2813         return this.reconsumeAs("BEFORE_ATTRIBUTE_NAME");
2814     }
2815     BOGUS_COMMENT(cp) {
2816         while (true) {
2817             if (cp === GREATER_THAN_SIGN) {
2818                 return "DATA";
2819             }
2820             if (cp === EOF) {
2821                 return "DATA";
2822             }
2823             if (cp === NULL) {
2824                 cp = NULL_REPLACEMENT;
2825             }
2826             this.appendTokenValue(cp, null);
2827             cp = this.consumeNextCodePoint();
2828         }
2829     }
2830     MARKUP_DECLARATION_OPEN(cp) {
2831         if (cp === HYPHEN_MINUS && this.text[this.offset + 1] === "-") {
2832             this.offset += 1;
2833             this.column += 1;
2834             this.startToken("HTMLComment");
2835             return "COMMENT_START";
2836         }
2837         if (cp === LATIN_CAPITAL_D &&
2838             this.text.slice(this.offset + 1, this.offset + 7) === "OCTYPE") {
2839             this.startToken("HTMLBogusComment");
2840             this.appendTokenValue(cp, "HTMLBogusComment");
2841             return "BOGUS_COMMENT";
2842         }
2843         if (cp === LEFT_SQUARE_BRACKET &&
2844             this.text.slice(this.offset + 1, this.offset + 7) === "CDATA[") {
2845             this.offset += 6;
2846             this.column += 6;
2847             if (this.namespace === NS.HTML) {
2848                 this.reportParseError("cdata-in-html-content");
2849                 this.startToken("HTMLBogusComment").value = "[CDATA[";
2850                 return "BOGUS_COMMENT";
2851             }
2852             this.startToken("HTMLCDataText");
2853             return "CDATA_SECTION";
2854         }
2855         this.reportParseError("incorrectly-opened-comment");
2856         this.startToken("HTMLBogusComment");
2857         return this.reconsumeAs("BOGUS_COMMENT");
2858     }
2859     COMMENT_START(cp) {
2860         if (cp === HYPHEN_MINUS) {
2861             return "COMMENT_START_DASH";
2862         }
2863         if (cp === GREATER_THAN_SIGN) {
2864             this.reportParseError("abrupt-closing-of-empty-comment");
2865             return "DATA";
2866         }
2867         return this.reconsumeAs("COMMENT");
2868     }
2869     COMMENT_START_DASH(cp) {
2870         if (cp === HYPHEN_MINUS) {
2871             return "COMMENT_END";
2872         }
2873         if (cp === GREATER_THAN_SIGN) {
2874             this.reportParseError("abrupt-closing-of-empty-comment");
2875             return "DATA";
2876         }
2877         if (cp === EOF) {
2878             this.reportParseError("eof-in-comment");
2879             return "DATA";
2880         }
2881         this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2882         return this.reconsumeAs("COMMENT");
2883     }
2884     COMMENT(cp) {
2885         while (true) {
2886             if (cp === LESS_THAN_SIGN) {
2887                 this.appendTokenValue(LESS_THAN_SIGN, "HTMLComment");
2888                 return "COMMENT_LESS_THAN_SIGN";
2889             }
2890             if (cp === HYPHEN_MINUS) {
2891                 return "COMMENT_END_DASH";
2892             }
2893             if (cp === NULL) {
2894                 this.reportParseError("unexpected-null-character");
2895                 cp = NULL_REPLACEMENT;
2896             }
2897             if (cp === EOF) {
2898                 this.reportParseError("eof-in-comment");
2899                 return "DATA";
2900             }
2901             this.appendTokenValue(cp, "HTMLComment");
2902             cp = this.consumeNextCodePoint();
2903         }
2904     }
2905     COMMENT_LESS_THAN_SIGN(cp) {
2906         while (true) {
2907             if (cp === EXCLAMATION_MARK) {
2908                 this.appendTokenValue(cp, "HTMLComment");
2909                 return "COMMENT_LESS_THAN_SIGN_BANG";
2910             }
2911             if (cp !== LESS_THAN_SIGN) {
2912                 return this.reconsumeAs("COMMENT");
2913             }
2914             this.appendTokenValue(cp, "HTMLComment");
2915             cp = this.consumeNextCodePoint();
2916         }
2917     }
2918     COMMENT_LESS_THAN_SIGN_BANG(cp) {
2919         if (cp === HYPHEN_MINUS) {
2920             return "COMMENT_LESS_THAN_SIGN_BANG_DASH";
2921         }
2922         return this.reconsumeAs("COMMENT");
2923     }
2924     COMMENT_LESS_THAN_SIGN_BANG_DASH(cp) {
2925         if (cp === HYPHEN_MINUS) {
2926             return "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
2927         }
2928         return this.reconsumeAs("COMMENT_END_DASH");
2929     }
2930     COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH(cp) {
2931         if (cp !== GREATER_THAN_SIGN && cp !== EOF) {
2932             this.reportParseError("nested-comment");
2933         }
2934         return this.reconsumeAs("COMMENT_END");
2935     }
2936     COMMENT_END_DASH(cp) {
2937         if (cp === HYPHEN_MINUS) {
2938             return "COMMENT_END";
2939         }
2940         if (cp === EOF) {
2941             this.reportParseError("eof-in-comment");
2942             return "DATA";
2943         }
2944         this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2945         return this.reconsumeAs("COMMENT");
2946     }
2947     COMMENT_END(cp) {
2948         while (true) {
2949             if (cp === GREATER_THAN_SIGN) {
2950                 return "DATA";
2951             }
2952             if (cp === EXCLAMATION_MARK) {
2953                 return "COMMENT_END_BANG";
2954             }
2955             if (cp === EOF) {
2956                 this.reportParseError("eof-in-comment");
2957                 return "DATA";
2958             }
2959             this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2960             if (cp !== HYPHEN_MINUS) {
2961                 this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2962                 return this.reconsumeAs("COMMENT");
2963             }
2964             cp = this.consumeNextCodePoint();
2965         }
2966     }
2967     COMMENT_END_BANG(cp) {
2968         if (cp === HYPHEN_MINUS) {
2969             this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2970             this.appendTokenValue(EXCLAMATION_MARK, "HTMLComment");
2971             return "COMMENT_END_DASH";
2972         }
2973         if (cp === GREATER_THAN_SIGN) {
2974             this.reportParseError("incorrectly-closed-comment");
2975             return "DATA";
2976         }
2977         if (cp === EOF) {
2978             this.reportParseError("eof-in-comment");
2979             return "DATA";
2980         }
2981         this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2982         this.appendTokenValue(EXCLAMATION_MARK, "HTMLComment");
2983         return this.reconsumeAs("COMMENT");
2984     }
2985     CDATA_SECTION(cp) {
2986         while (true) {
2987             if (cp === RIGHT_SQUARE_BRACKET) {
2988                 return "CDATA_SECTION_BRACKET";
2989             }
2990             if (cp === EOF) {
2991                 this.reportParseError("eof-in-cdata");
2992                 return "DATA";
2993             }
2994             this.appendTokenValue(cp, "HTMLCDataText");
2995             cp = this.consumeNextCodePoint();
2996         }
2997     }
2998     CDATA_SECTION_BRACKET(cp) {
2999         if (cp === RIGHT_SQUARE_BRACKET) {
3000             return "CDATA_SECTION_END";
3001         }
3002         this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
3003         return this.reconsumeAs("CDATA_SECTION");
3004     }
3005     CDATA_SECTION_END(cp) {
3006         while (true) {
3007             if (cp === GREATER_THAN_SIGN) {
3008                 return "DATA";
3009             }
3010             if (cp !== RIGHT_SQUARE_BRACKET) {
3011                 this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
3012                 this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
3013                 return this.reconsumeAs("CDATA_SECTION");
3014             }
3015             this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
3016             cp = this.consumeNextCodePoint();
3017         }
3018     }
3019     CHARACTER_REFERENCE(cp) {
3020         this.crStartOffset = this.offset - 1;
3021         this.buffer = [AMPERSAND];
3022         if (isWhitespace(cp) || cp === LESS_THAN_SIGN || cp === EOF) {
3023             return this.reconsumeAs("CHARACTER_REFERENCE_END");
3024         }
3025         if (cp === NUMBER_SIGN) {
3026             this.buffer.push(cp);
3027             return "NUMERIC_CHARACTER_REFERENCE";
3028         }
3029         return this.reconsumeAs("NAMED_CHARACTER_REFERENCE");
3030     }
3031     NAMED_CHARACTER_REFERENCE(cp) {
3032         for (const entitySet of entitySets) {
3033             const length = entitySet.length;
3034             const entities = entitySet.entities;
3035             const text = this.text.slice(this.offset, this.offset + length);
3036             const codepoints = entities[text];
3037             if (codepoints == null) {
3038                 continue;
3039             }
3040             const semi = text.endsWith(";");
3041             const next = this.text.codePointAt(this.offset + 1);
3042             this.offset += length - 1;
3043             this.column += length - 1;
3044             if (this.returnState.startsWith("ATTR") &&
3045                 !semi &&
3046                 next != null &&
3047                 (next === EQUALS_SIGN || isLetter(next) || isDigit(next))) {
3048                 for (const cp1 of text) {
3049                     this.buffer.push(cp1.codePointAt(0));
3050                 }
3051             }
3052             else {
3053                 if (!semi) {
3054                     this.reportParseError("missing-semicolon-after-character-reference");
3055                 }
3056                 this.buffer = codepoints;
3057             }
3058             return "CHARACTER_REFERENCE_END";
3059         }
3060         for (const cp0 of this.buffer) {
3061             this.appendTokenValue(cp0, null);
3062         }
3063         this.appendTokenValue(cp, null);
3064         return "AMBIGUOUS_AMPERSAND";
3065     }
3066     AMBIGUOUS_AMPERSAND(cp) {
3067         while (isDigit(cp) || isLetter(cp)) {
3068             this.appendTokenValue(cp, null);
3069             cp = this.consumeNextCodePoint();
3070         }
3071         if (cp === SEMICOLON) {
3072             this.reportParseError("unknown-named-character-reference");
3073         }
3074         return this.reconsumeAs(this.returnState);
3075     }
3076     NUMERIC_CHARACTER_REFERENCE(cp) {
3077         this.crCode = 0;
3078         if (cp === LATIN_SMALL_X || cp === LATIN_CAPITAL_X) {
3079             this.buffer.push(cp);
3080             return "HEXADEMICAL_CHARACTER_REFERENCE_START";
3081         }
3082         return this.reconsumeAs("DECIMAL_CHARACTER_REFERENCE_START");
3083     }
3084     HEXADEMICAL_CHARACTER_REFERENCE_START(cp) {
3085         if (isHexDigit(cp)) {
3086             return this.reconsumeAs("HEXADEMICAL_CHARACTER_REFERENCE");
3087         }
3088         this.reportParseError("absence-of-digits-in-numeric-character-reference");
3089         return this.reconsumeAs("CHARACTER_REFERENCE_END");
3090     }
3091     DECIMAL_CHARACTER_REFERENCE_START(cp) {
3092         if (isDigit(cp)) {
3093             return this.reconsumeAs("DECIMAL_CHARACTER_REFERENCE");
3094         }
3095         this.reportParseError("absence-of-digits-in-numeric-character-reference");
3096         return this.reconsumeAs("CHARACTER_REFERENCE_END");
3097     }
3098     HEXADEMICAL_CHARACTER_REFERENCE(cp) {
3099         while (true) {
3100             if (isDigit(cp)) {
3101                 this.crCode = 16 * this.crCode + (cp - 0x30);
3102             }
3103             else if (isUpperHexDigit(cp)) {
3104                 this.crCode = 16 * this.crCode + (cp - 0x37);
3105             }
3106             else if (isLowerHexDigit(cp)) {
3107                 this.crCode = 16 * this.crCode + (cp - 0x57);
3108             }
3109             else {
3110                 if (cp === SEMICOLON) {
3111                     return "NUMERIC_CHARACTER_REFERENCE_END";
3112                 }
3113                 this.reportParseError("missing-semicolon-after-character-reference");
3114                 return this.reconsumeAs("NUMERIC_CHARACTER_REFERENCE_END");
3115             }
3116             cp = this.consumeNextCodePoint();
3117         }
3118     }
3119     DECIMAL_CHARACTER_REFERENCE(cp) {
3120         while (true) {
3121             if (isDigit(cp)) {
3122                 this.crCode = 10 * this.crCode + (cp - 0x30);
3123             }
3124             else {
3125                 if (cp === SEMICOLON) {
3126                     return "NUMERIC_CHARACTER_REFERENCE_END";
3127                 }
3128                 this.reportParseError("missing-semicolon-after-character-reference");
3129                 return this.reconsumeAs("NUMERIC_CHARACTER_REFERENCE_END");
3130             }
3131             cp = this.consumeNextCodePoint();
3132         }
3133     }
3134     NUMERIC_CHARACTER_REFERENCE_END(_cp) {
3135         let code = this.crCode;
3136         if (code === 0) {
3137             this.reportParseError("null-character-reference");
3138             code = NULL_REPLACEMENT;
3139         }
3140         else if (code > 0x10ffff) {
3141             this.reportParseError("character-reference-outside-unicode-range");
3142             code = NULL_REPLACEMENT;
3143         }
3144         else if (isSurrogate(code)) {
3145             this.reportParseError("surrogate-character-reference");
3146             code = NULL_REPLACEMENT;
3147         }
3148         else if (isNonCharacter(code)) {
3149             this.reportParseError("noncharacter-character-reference");
3150         }
3151         else if (code === 0x0d || (isControl(code) && !isWhitespace(code))) {
3152             this.reportParseError("control-character-reference");
3153             code = alternativeCR.get(code) || code;
3154         }
3155         this.buffer = [code];
3156         return this.reconsumeAs("CHARACTER_REFERENCE_END");
3157     }
3158     CHARACTER_REFERENCE_END(_cp) {
3159         assert(this.currentToken != null);
3160         const token = this.currentToken;
3161         const len0 = token.value.length;
3162         for (const cp1 of this.buffer) {
3163             this.appendTokenValue(cp1, null);
3164         }
3165         const newLength = token.value.length - len0;
3166         for (let i = this.crStartOffset + newLength; i < this.offset; ++i) {
3167             this.gaps.push(i);
3168         }
3169         return this.reconsumeAs(this.returnState);
3170     }
3171     V_EXPRESSION_START(cp) {
3172         if (cp === LEFT_CURLY_BRACKET) {
3173             this.startToken("VExpressionStart");
3174             this.appendTokenValue(LEFT_CURLY_BRACKET, null);
3175             this.appendTokenValue(LEFT_CURLY_BRACKET, null);
3176             return this.returnState;
3177         }
3178         this.appendTokenValue(LEFT_CURLY_BRACKET, null);
3179         return this.reconsumeAs(this.returnState);
3180     }
3181     V_EXPRESSION_END(cp) {
3182         if (cp === RIGHT_CURLY_BRACKET) {
3183             this.startToken("VExpressionEnd");
3184             this.appendTokenValue(RIGHT_CURLY_BRACKET, null);
3185             this.appendTokenValue(RIGHT_CURLY_BRACKET, null);
3186             return this.returnState;
3187         }
3188         this.appendTokenValue(RIGHT_CURLY_BRACKET, null);
3189         return this.reconsumeAs(this.returnState);
3190     }
3191 }
3192
3193 function getPossibleTypes(parsedSelector) {
3194     switch (parsedSelector.type) {
3195         case "identifier":
3196             return [parsedSelector.value];
3197         case "matches": {
3198             const typesForComponents = parsedSelector.selectors.map(getPossibleTypes);
3199             if (typesForComponents.every(Boolean)) {
3200                 return union(...typesForComponents);
3201             }
3202             return null;
3203         }
3204         case "compound": {
3205             const typesForComponents = parsedSelector.selectors.map(getPossibleTypes).filter(Boolean);
3206             if (!typesForComponents.length) {
3207                 return null;
3208             }
3209             return intersection(...typesForComponents);
3210         }
3211         case "child":
3212         case "descendant":
3213         case "sibling":
3214         case "adjacent":
3215             return getPossibleTypes(parsedSelector.right);
3216         default:
3217             return null;
3218     }
3219 }
3220 function countClassAttributes(parsedSelector) {
3221     switch (parsedSelector.type) {
3222         case "child":
3223         case "descendant":
3224         case "sibling":
3225         case "adjacent":
3226             return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
3227         case "compound":
3228         case "not":
3229         case "matches":
3230             return parsedSelector.selectors.reduce((sum, childSelector) => sum + countClassAttributes(childSelector), 0);
3231         case "attribute":
3232         case "field":
3233         case "nth-child":
3234         case "nth-last-child":
3235             return 1;
3236         default:
3237             return 0;
3238     }
3239 }
3240 function countIdentifiers(parsedSelector) {
3241     switch (parsedSelector.type) {
3242         case "child":
3243         case "descendant":
3244         case "sibling":
3245         case "adjacent":
3246             return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
3247         case "compound":
3248         case "not":
3249         case "matches":
3250             return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0);
3251         case "identifier":
3252             return 1;
3253         default:
3254             return 0;
3255     }
3256 }
3257 function compareSpecificity(selectorA, selectorB) {
3258     return selectorA.attributeCount - selectorB.attributeCount ||
3259         selectorA.identifierCount - selectorB.identifierCount ||
3260         (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
3261 }
3262 function tryParseSelector(rawSelector) {
3263     try {
3264         return esquery.parse(rawSelector.replace(/:exit$/, ""));
3265     }
3266     catch (err) {
3267         if (typeof err.offset === "number") {
3268             throw new Error(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`);
3269         }
3270         throw err;
3271     }
3272 }
3273 const parseSelector = memoize(rawSelector => {
3274     const parsedSelector = tryParseSelector(rawSelector);
3275     return {
3276         rawSelector,
3277         isExit: rawSelector.endsWith(":exit"),
3278         parsedSelector,
3279         listenerTypes: getPossibleTypes(parsedSelector),
3280         attributeCount: countClassAttributes(parsedSelector),
3281         identifierCount: countIdentifiers(parsedSelector),
3282     };
3283 });
3284 class NodeEventGenerator {
3285     constructor(emitter) {
3286         this.emitter = emitter;
3287         this.currentAncestry = [];
3288         this.enterSelectorsByNodeType = new Map();
3289         this.exitSelectorsByNodeType = new Map();
3290         this.anyTypeEnterSelectors = [];
3291         this.anyTypeExitSelectors = [];
3292         const eventNames = typeof emitter.eventNames === "function"
3293             ? emitter.eventNames()
3294             : Object.keys(emitter._events);
3295         for (const rawSelector of eventNames) {
3296             if (typeof rawSelector === "symbol") {
3297                 continue;
3298             }
3299             const selector = parseSelector(rawSelector);
3300             if (selector.listenerTypes) {
3301                 for (const nodeType of selector.listenerTypes) {
3302                     const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
3303                     let selectors = typeMap.get(nodeType);
3304                     if (selectors == null) {
3305                         typeMap.set(nodeType, (selectors = []));
3306                     }
3307                     selectors.push(selector);
3308                 }
3309             }
3310             else {
3311                 (selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors).push(selector);
3312             }
3313         }
3314         this.anyTypeEnterSelectors.sort(compareSpecificity);
3315         this.anyTypeExitSelectors.sort(compareSpecificity);
3316         for (const selectorList of this.enterSelectorsByNodeType.values()) {
3317             selectorList.sort(compareSpecificity);
3318         }
3319         for (const selectorList of this.exitSelectorsByNodeType.values()) {
3320             selectorList.sort(compareSpecificity);
3321         }
3322     }
3323     applySelector(node, selector) {
3324         if (esquery.matches(node, selector.parsedSelector, this.currentAncestry)) {
3325             this.emitter.emit(selector.rawSelector, node);
3326         }
3327     }
3328     applySelectors(node, isExit) {
3329         const selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || [];
3330         const anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
3331         let selectorsByTypeIndex = 0;
3332         let anyTypeSelectorsIndex = 0;
3333         while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) {
3334             if (selectorsByTypeIndex >= selectorsByNodeType.length ||
3335                 (anyTypeSelectorsIndex < anyTypeSelectors.length && compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0)) {
3336                 this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]);
3337             }
3338             else {
3339                 this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]);
3340             }
3341         }
3342     }
3343     enterNode(node) {
3344         if (node.parent) {
3345             this.currentAncestry.unshift(node.parent);
3346         }
3347         this.applySelectors(node, false);
3348     }
3349     leaveNode(node) {
3350         this.applySelectors(node, true);
3351         this.currentAncestry.shift();
3352     }
3353 }
3354
3355 function getStartLocation(token) {
3356     return token.range[0];
3357 }
3358 function search(tokens, location) {
3359     return sortedIndexBy(tokens, { range: [location] }, getStartLocation);
3360 }
3361 function getFirstIndex(tokens, indexMap, startLoc) {
3362     if (startLoc in indexMap) {
3363         return indexMap[startLoc];
3364     }
3365     if ((startLoc - 1) in indexMap) {
3366         const index = indexMap[startLoc - 1];
3367         const token = (index >= 0 && index < tokens.length) ? tokens[index] : null;
3368         if (token && token.range[0] >= startLoc) {
3369             return index;
3370         }
3371         return index + 1;
3372     }
3373     return 0;
3374 }
3375 function getLastIndex(tokens, indexMap, endLoc) {
3376     if (endLoc in indexMap) {
3377         return indexMap[endLoc] - 1;
3378     }
3379     if ((endLoc - 1) in indexMap) {
3380         const index = indexMap[endLoc - 1];
3381         const token = (index >= 0 && index < tokens.length) ? tokens[index] : null;
3382         if (token && token.range[1] > endLoc) {
3383             return index - 1;
3384         }
3385         return index;
3386     }
3387     return tokens.length - 1;
3388 }
3389
3390 class Cursor {
3391     constructor() {
3392         this.current = null;
3393     }
3394     getOneToken() {
3395         return this.moveNext() ? this.current : null;
3396     }
3397     getAllTokens() {
3398         const tokens = [];
3399         while (this.moveNext()) {
3400             tokens.push(this.current);
3401         }
3402         return tokens;
3403     }
3404 }
3405
3406 class BackwardTokenCommentCursor extends Cursor {
3407     constructor(tokens, comments, indexMap, startLoc, endLoc) {
3408         super();
3409         this.tokens = tokens;
3410         this.comments = comments;
3411         this.tokenIndex = getLastIndex(tokens, indexMap, endLoc);
3412         this.commentIndex = search(comments, endLoc) - 1;
3413         this.border = startLoc;
3414     }
3415     moveNext() {
3416         const token = (this.tokenIndex >= 0) ? this.tokens[this.tokenIndex] : null;
3417         const comment = (this.commentIndex >= 0) ? this.comments[this.commentIndex] : null;
3418         if (token && (!comment || token.range[1] > comment.range[1])) {
3419             this.current = token;
3420             this.tokenIndex -= 1;
3421         }
3422         else if (comment) {
3423             this.current = comment;
3424             this.commentIndex -= 1;
3425         }
3426         else {
3427             this.current = null;
3428         }
3429         return this.current != null && (this.border === -1 || this.current.range[0] >= this.border);
3430     }
3431 }
3432
3433 class BackwardTokenCursor extends Cursor {
3434     constructor(tokens, _comments, indexMap, startLoc, endLoc) {
3435         super();
3436         this.tokens = tokens;
3437         this.index = getLastIndex(tokens, indexMap, endLoc);
3438         this.indexEnd = getFirstIndex(tokens, indexMap, startLoc);
3439     }
3440     moveNext() {
3441         if (this.index >= this.indexEnd) {
3442             this.current = this.tokens[this.index];
3443             this.index -= 1;
3444             return true;
3445         }
3446         return false;
3447     }
3448     getOneToken() {
3449         return (this.index >= this.indexEnd) ? this.tokens[this.index] : null;
3450     }
3451 }
3452
3453 class DecorativeCursor extends Cursor {
3454     constructor(cursor) {
3455         super();
3456         this.cursor = cursor;
3457     }
3458     moveNext() {
3459         const retv = this.cursor.moveNext();
3460         this.current = this.cursor.current;
3461         return retv;
3462     }
3463 }
3464
3465 class FilterCursor extends DecorativeCursor {
3466     constructor(cursor, predicate) {
3467         super(cursor);
3468         this.predicate = predicate;
3469     }
3470     moveNext() {
3471         const predicate = this.predicate;
3472         while (super.moveNext()) {
3473             if (predicate(this.current)) {
3474                 return true;
3475             }
3476         }
3477         return false;
3478     }
3479 }
3480
3481 class ForwardTokenCommentCursor extends Cursor {
3482     constructor(tokens, comments, indexMap, startLoc, endLoc) {
3483         super();
3484         this.tokens = tokens;
3485         this.comments = comments;
3486         this.tokenIndex = getFirstIndex(tokens, indexMap, startLoc);
3487         this.commentIndex = search(comments, startLoc);
3488         this.border = endLoc;
3489     }
3490     moveNext() {
3491         const token = (this.tokenIndex < this.tokens.length) ? this.tokens[this.tokenIndex] : null;
3492         const comment = (this.commentIndex < this.comments.length) ? this.comments[this.commentIndex] : null;
3493         if (token && (!comment || token.range[0] < comment.range[0])) {
3494             this.current = token;
3495             this.tokenIndex += 1;
3496         }
3497         else if (comment) {
3498             this.current = comment;
3499             this.commentIndex += 1;
3500         }
3501         else {
3502             this.current = null;
3503         }
3504         return this.current != null && (this.border === -1 || this.current.range[1] <= this.border);
3505     }
3506 }
3507
3508 class ForwardTokenCursor extends Cursor {
3509     constructor(tokens, _comments, indexMap, startLoc, endLoc) {
3510         super();
3511         this.tokens = tokens;
3512         this.index = getFirstIndex(tokens, indexMap, startLoc);
3513         this.indexEnd = getLastIndex(tokens, indexMap, endLoc);
3514     }
3515     moveNext() {
3516         if (this.index <= this.indexEnd) {
3517             this.current = this.tokens[this.index];
3518             this.index += 1;
3519             return true;
3520         }
3521         return false;
3522     }
3523     getOneToken() {
3524         return (this.index <= this.indexEnd) ? this.tokens[this.index] : null;
3525     }
3526     getAllTokens() {
3527         return this.tokens.slice(this.index, this.indexEnd + 1);
3528     }
3529 }
3530
3531 class LimitCursor extends DecorativeCursor {
3532     constructor(cursor, count) {
3533         super(cursor);
3534         this.count = count;
3535     }
3536     moveNext() {
3537         if (this.count > 0) {
3538             this.count -= 1;
3539             return super.moveNext();
3540         }
3541         return false;
3542     }
3543 }
3544
3545 class SkipCursor extends DecorativeCursor {
3546     constructor(cursor, count) {
3547         super(cursor);
3548         this.count = count;
3549     }
3550     moveNext() {
3551         while (this.count > 0) {
3552             this.count -= 1;
3553             if (!super.moveNext()) {
3554                 return false;
3555             }
3556         }
3557         return super.moveNext();
3558     }
3559 }
3560
3561 class CursorFactory {
3562     constructor(TokenCursor, TokenCommentCursor) {
3563         this.TokenCursor = TokenCursor;
3564         this.TokenCommentCursor = TokenCommentCursor;
3565     }
3566     createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) {
3567         const TokenCursor = includeComments ? this.TokenCommentCursor : this.TokenCursor;
3568         return new TokenCursor(tokens, comments, indexMap, startLoc, endLoc);
3569     }
3570     createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) {
3571         let cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments);
3572         if (filter) {
3573             cursor = new FilterCursor(cursor, filter);
3574         }
3575         if (skip >= 1) {
3576             cursor = new SkipCursor(cursor, skip);
3577         }
3578         if (count >= 0) {
3579             cursor = new LimitCursor(cursor, count);
3580         }
3581         return cursor;
3582     }
3583 }
3584 const forward = new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor);
3585 const backward = new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor);
3586
3587 class PaddedTokenCursor extends ForwardTokenCursor {
3588     constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
3589         super(tokens, comments, indexMap, startLoc, endLoc);
3590         this.index = Math.max(0, this.index - beforeCount);
3591         this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount);
3592     }
3593 }
3594
3595 function isCommentToken(token) {
3596     return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
3597 }
3598 function createIndexMap(tokens, comments) {
3599     const map = Object.create(null);
3600     let tokenIndex = 0;
3601     let commentIndex = 0;
3602     let nextStart = 0;
3603     let range = null;
3604     while (tokenIndex < tokens.length || commentIndex < comments.length) {
3605         nextStart = (commentIndex < comments.length) ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER;
3606         while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) {
3607             map[range[0]] = tokenIndex;
3608             map[range[1] - 1] = tokenIndex;
3609             tokenIndex += 1;
3610         }
3611         nextStart = (tokenIndex < tokens.length) ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER;
3612         while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) {
3613             map[range[0]] = tokenIndex;
3614             map[range[1] - 1] = tokenIndex;
3615             commentIndex += 1;
3616         }
3617     }
3618     return map;
3619 }
3620 function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
3621     let includeComments = false;
3622     let skip = 0;
3623     let filter = null;
3624     if (typeof opts === "number") {
3625         skip = opts | 0;
3626     }
3627     else if (typeof opts === "function") {
3628         filter = opts;
3629     }
3630     else if (opts) {
3631         includeComments = Boolean(opts.includeComments);
3632         skip = opts.skip || 0;
3633         filter = opts.filter || null;
3634     }
3635     assert(skip >= 0, "options.skip should be zero or a positive integer.");
3636     assert(!filter || typeof filter === "function", "options.filter should be a function.");
3637     return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
3638 }
3639 function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
3640     let includeComments = false;
3641     let count = 0;
3642     let countExists = false;
3643     let filter = null;
3644     if (typeof opts === "number") {
3645         count = opts | 0;
3646         countExists = true;
3647     }
3648     else if (typeof opts === "function") {
3649         filter = opts;
3650     }
3651     else if (opts) {
3652         includeComments = Boolean(opts.includeComments);
3653         count = opts.count || 0;
3654         countExists = typeof opts.count === "number";
3655         filter = opts.filter || null;
3656     }
3657     assert(count >= 0, "options.count should be zero or a positive integer.");
3658     assert(!filter || typeof filter === "function", "options.filter should be a function.");
3659     return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
3660 }
3661 function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
3662     if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") {
3663         return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc);
3664     }
3665     if (typeof beforeCount === "number" || typeof beforeCount === "undefined") {
3666         return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount || 0, afterCount || 0);
3667     }
3668     return createCursorWithCount(forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount);
3669 }
3670 function getAdjacentCommentTokensFromCursor(cursor) {
3671     const tokens = [];
3672     let currentToken = cursor.getOneToken();
3673     while (currentToken && isCommentToken(currentToken)) {
3674         tokens.push(currentToken);
3675         currentToken = cursor.getOneToken();
3676     }
3677     return tokens;
3678 }
3679 class TokenStore {
3680     constructor(tokens, comments) {
3681         this._tokens = tokens;
3682         this._comments = comments;
3683         this._indexMap = createIndexMap(tokens, comments);
3684     }
3685     getTokenByRangeStart(offset, options) {
3686         const includeComments = Boolean(options && options.includeComments);
3687         const token = forward.createBaseCursor(this._tokens, this._comments, this._indexMap, offset, -1, includeComments).getOneToken();
3688         if (token && token.range[0] === offset) {
3689             return token;
3690         }
3691         return null;
3692     }
3693     getFirstToken(node, options) {
3694         return createCursorWithSkip(forward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getOneToken();
3695     }
3696     getLastToken(node, options) {
3697         return createCursorWithSkip(backward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getOneToken();
3698     }
3699     getTokenBefore(node, options) {
3700         return createCursorWithSkip(backward, this._tokens, this._comments, this._indexMap, -1, node.range[0], options).getOneToken();
3701     }
3702     getTokenAfter(node, options) {
3703         return createCursorWithSkip(forward, this._tokens, this._comments, this._indexMap, node.range[1], -1, options).getOneToken();
3704     }
3705     getFirstTokenBetween(left, right, options) {
3706         return createCursorWithSkip(forward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getOneToken();
3707     }
3708     getLastTokenBetween(left, right, options) {
3709         return createCursorWithSkip(backward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getOneToken();
3710     }
3711     getTokenOrCommentBefore(node, skip) {
3712         return this.getTokenBefore(node, { includeComments: true, skip });
3713     }
3714     getTokenOrCommentAfter(node, skip) {
3715         return this.getTokenAfter(node, { includeComments: true, skip });
3716     }
3717     getFirstTokens(node, options) {
3718         return createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getAllTokens();
3719     }
3720     getLastTokens(node, options) {
3721         return createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getAllTokens().reverse();
3722     }
3723     getTokensBefore(node, options) {
3724         return createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, -1, node.range[0], options).getAllTokens().reverse();
3725     }
3726     getTokensAfter(node, options) {
3727         return createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, node.range[1], -1, options).getAllTokens();
3728     }
3729     getFirstTokensBetween(left, right, options) {
3730         return createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getAllTokens();
3731     }
3732     getLastTokensBetween(left, right, options) {
3733         return createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getAllTokens().reverse();
3734     }
3735     getTokens(node, beforeCount, afterCount) {
3736         return createCursorWithPadding(this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], beforeCount, afterCount).getAllTokens();
3737     }
3738     getTokensBetween(left, right, padding) {
3739         return createCursorWithPadding(this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], padding, typeof padding === "number" ? padding : undefined).getAllTokens();
3740     }
3741     commentsExistBetween(left, right) {
3742         const index = search(this._comments, left.range[1]);
3743         return (index < this._comments.length &&
3744             this._comments[index].range[1] <= right.range[0]);
3745     }
3746     getCommentsBefore(nodeOrToken) {
3747         const cursor = createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, -1, nodeOrToken.range[0], { includeComments: true });
3748         return getAdjacentCommentTokensFromCursor(cursor).reverse();
3749     }
3750     getCommentsAfter(nodeOrToken) {
3751         const cursor = createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, nodeOrToken.range[1], -1, { includeComments: true });
3752         return getAdjacentCommentTokensFromCursor(cursor);
3753     }
3754     getCommentsInside(node) {
3755         return this.getTokens(node, {
3756             includeComments: true,
3757             filter: isCommentToken,
3758         });
3759     }
3760 }
3761
3762 const emitters = new WeakMap();
3763 const stores = new WeakMap();
3764 function define(rootAST, document) {
3765     return {
3766         defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor) {
3767             if (scriptVisitor == null) {
3768                 scriptVisitor = {};
3769             }
3770             if (rootAST.templateBody == null) {
3771                 return scriptVisitor;
3772             }
3773             let emitter = emitters.get(rootAST);
3774             if (emitter == null) {
3775                 emitter = new EventEmitter();
3776                 emitter.setMaxListeners(0);
3777                 emitters.set(rootAST, emitter);
3778                 const programExitHandler = scriptVisitor["Program:exit"];
3779                 scriptVisitor["Program:exit"] = node => {
3780                     try {
3781                         if (typeof programExitHandler === "function") {
3782                             programExitHandler(node);
3783                         }
3784                         const generator = new NodeEventGenerator(emitter);
3785                         traverseNodes(rootAST.templateBody, generator);
3786                     }
3787                     finally {
3788                         scriptVisitor["Program:exit"] = programExitHandler;
3789                         emitters.delete(rootAST);
3790                     }
3791                 };
3792             }
3793             for (const selector of Object.keys(templateBodyVisitor)) {
3794                 emitter.on(selector, templateBodyVisitor[selector]);
3795             }
3796             return scriptVisitor;
3797         },
3798         getTemplateBodyTokenStore() {
3799             const ast = rootAST.templateBody;
3800             const key = ast || stores;
3801             let store = stores.get(key);
3802             if (!store) {
3803                 store =
3804                     ast != null
3805                         ? new TokenStore(ast.tokens, ast.comments)
3806                         : new TokenStore([], []);
3807                 stores.set(key, store);
3808             }
3809             return store;
3810         },
3811         getDocumentFragment() {
3812             return document;
3813         },
3814     };
3815 }
3816
3817 const STARTS_WITH_LT = /^\s*</u;
3818 function isVueFile(code, options) {
3819     const filePath = options.filePath || "unknown.js";
3820     return path.extname(filePath) === ".vue" || STARTS_WITH_LT.test(code);
3821 }
3822 function isTemplateElement(node) {
3823     return node.type === "VElement" && node.name === "template";
3824 }
3825 function isScriptElement(node) {
3826     return node.type === "VElement" && node.name === "script";
3827 }
3828 function isLang(attribute) {
3829     return attribute.directive === false && attribute.key.name === "lang";
3830 }
3831 function getLang(element, defaultLang) {
3832     const langAttr = element && element.startTag.attributes.find(isLang);
3833     const lang = langAttr && langAttr.value && langAttr.value.value;
3834     return lang || defaultLang;
3835 }
3836 function parseForESLint(code, options) {
3837     options = Object.assign({
3838         comment: true,
3839         ecmaVersion: 2015,
3840         loc: true,
3841         range: true,
3842         tokens: true,
3843     }, options || {});
3844     let result;
3845     let document;
3846     if (!isVueFile(code, options)) {
3847         result = parseScript(code, options);
3848         document = null;
3849     }
3850     else {
3851         const skipParsingScript = options.parser === false;
3852         const tokenizer = new Tokenizer(code);
3853         const rootAST = new Parser(tokenizer, options).parse();
3854         const locationCalcurator = new LocationCalculator(tokenizer.gaps, tokenizer.lineTerminators);
3855         const script = rootAST.children.find(isScriptElement);
3856         const template = rootAST.children.find(isTemplateElement);
3857         const templateLang = getLang(template, "html");
3858         const concreteInfo = {
3859             tokens: rootAST.tokens,
3860             comments: rootAST.comments,
3861             errors: rootAST.errors,
3862         };
3863         const templateBody = template != null && templateLang === "html"
3864             ? Object.assign(template, concreteInfo)
3865             : undefined;
3866         if (skipParsingScript || script == null) {
3867             result = parseScript("", options);
3868         }
3869         else {
3870             result = parseScriptElement(script, locationCalcurator, options);
3871         }
3872         result.ast.templateBody = templateBody;
3873         document = rootAST;
3874     }
3875     result.services = Object.assign(result.services || {}, define(result.ast, document));
3876     return result;
3877 }
3878 function parse(code, options) {
3879     return parseForESLint(code, options).ast;
3880 }
3881
3882 exports.AST = index;
3883 exports.parse = parse;
3884 exports.parseForESLint = parseForESLint;
3885 //# sourceMappingURL=index.js.map