@glodon-aiot/agent-cli-ui 3.9.0-alpha.7 → 3.9.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/es/Dialog/AgentChat/HistoryItem/SessionRefer/index.mjs +8 -8
  2. package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +4 -4
  3. package/dist/es/Dialog/SessionList/index.mjs +178 -166
  4. package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +51 -51
  5. package/dist/es/packages/agent-cli-ui/package.json.mjs +11 -11
  6. package/dist/es/packages/react-components/dist/es/components/Markdown/index.mjs +22 -23
  7. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  8. package/dist/es/src/style13.css +1 -1
  9. package/dist/es/src/style14.css +1 -1
  10. package/dist/es/src/style15.css +1 -1
  11. package/dist/es/src/style16.css +1 -1
  12. package/dist/es/src/style17.css +1 -1
  13. package/dist/es/src/style18.css +1 -1
  14. package/dist/es/src/style20.css +1 -1
  15. package/dist/es/src/style21.css +1 -1
  16. package/dist/es/src/style22.css +1 -1
  17. package/dist/es/src/style24.css +1 -1
  18. package/dist/es/src/style25.css +1 -1
  19. package/dist/es/src/style27.css +1 -1
  20. package/dist/es/src/style28.css +1 -1
  21. package/dist/es/src/style7.css +1 -1
  22. package/dist/es/src/style9.css +1 -1
  23. package/dist/lib/index.js +69 -70
  24. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/fetch.d.ts +44 -0
  25. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/index.d.ts +1 -0
  26. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/parse.d.ts +36 -0
  27. package/dist/src/utils/reactCompatibility.d.ts +27 -0
  28. package/dist/src/utils/testAntdPrefix.d.ts +3 -0
  29. package/package.json +3 -3
  30. package/dist/es/node_modules/hast-util-from-parse5/lib/index.mjs +0 -162
  31. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/index.mjs +0 -12
  32. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/aria.mjs +0 -61
  33. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/find.mjs +0 -33
  34. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/html.mjs +0 -368
  35. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/normalize.mjs +0 -6
  36. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/svg.mjs +0 -566
  37. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/case-insensitive-transform.mjs +0 -7
  38. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/case-sensitive-transform.mjs +0 -6
  39. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/create.mjs +0 -14
  40. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/defined-info.mjs +0 -36
  41. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/info.mjs +0 -28
  42. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/merge.mjs +0 -10
  43. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/schema.mjs +0 -21
  44. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/util/types.mjs +0 -15
  45. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/xlink.mjs +0 -19
  46. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/xml.mjs +0 -15
  47. package/dist/es/node_modules/hast-util-from-parse5/node_modules/property-information/lib/xmlns.mjs +0 -16
  48. package/dist/es/node_modules/hast-util-from-parse5/node_modules/vfile-location/lib/index.mjs +0 -47
  49. package/dist/es/node_modules/hast-util-from-parse5/node_modules/web-namespaces/index.mjs +0 -11
  50. package/dist/es/node_modules/rehype-raw/lib/index.mjs +0 -26
  51. package/dist/es/node_modules/rehype-raw/node_modules/entities/dist/esm/decode-codepoint.mjs +0 -38
  52. package/dist/es/node_modules/rehype-raw/node_modules/entities/dist/esm/decode.mjs +0 -251
  53. package/dist/es/node_modules/rehype-raw/node_modules/entities/dist/esm/generated/decode-data-html.mjs +0 -7
  54. package/dist/es/node_modules/rehype-raw/node_modules/hast-util-raw/lib/index.mjs +0 -249
  55. package/dist/es/node_modules/rehype-raw/node_modules/hast-util-to-parse5/lib/index.mjs +0 -125
  56. package/dist/es/node_modules/rehype-raw/node_modules/html-void-elements/index.mjs +0 -4
  57. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/common/doctype.mjs +0 -34
  58. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/common/error-codes.mjs +0 -7
  59. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/common/foreign-content.mjs +0 -103
  60. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/common/html.mjs +0 -44
  61. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/common/token.mjs +0 -14
  62. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/common/unicode.mjs +0 -38
  63. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/parser/formatting-element-list.mjs +0 -91
  64. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/parser/index.mjs +0 -2308
  65. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/parser/open-element-stack.mjs +0 -220
  66. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/serializer/index.mjs +0 -2
  67. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/tokenizer/index.mjs +0 -1948
  68. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/tokenizer/preprocessor.mjs +0 -92
  69. package/dist/es/node_modules/rehype-raw/node_modules/parse5/dist/tree-adapters/default.mjs +0 -173
  70. package/dist/es/node_modules/rehype-raw/node_modules/property-information/index.mjs +0 -12
  71. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/aria.mjs +0 -61
  72. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/find.mjs +0 -33
  73. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/html.mjs +0 -368
  74. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/normalize.mjs +0 -6
  75. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/svg.mjs +0 -566
  76. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/case-insensitive-transform.mjs +0 -7
  77. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/case-sensitive-transform.mjs +0 -6
  78. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/create.mjs +0 -17
  79. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/defined-info.mjs +0 -27
  80. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/info.mjs +0 -23
  81. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/merge.mjs +0 -11
  82. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/schema.mjs +0 -17
  83. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/util/types.mjs +0 -15
  84. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/xlink.mjs +0 -19
  85. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/xml.mjs +0 -15
  86. package/dist/es/node_modules/rehype-raw/node_modules/property-information/lib/xmlns.mjs +0 -16
  87. package/dist/es/node_modules/rehype-raw/node_modules/unist-util-visit/lib/index.mjs +0 -16
  88. package/dist/es/node_modules/rehype-raw/node_modules/web-namespaces/index.mjs +0 -11
  89. package/dist/es/node_modules/zwitch/index.mjs +0 -18
@@ -1,1948 +0,0 @@
1
- import { Preprocessor as u } from "./preprocessor.mjs";
2
- import { CODE_POINTS as t, REPLACEMENT_CHARACTER as _, SEQUENCES as T, isSurrogate as O, isUndefinedCodePoint as R, isControlCodePoint as m } from "../common/unicode.mjs";
3
- import { TokenType as A, getTokenAttr as P } from "../common/token.mjs";
4
- import { EntityDecoder as k, DecodingMode as D } from "../../../entities/dist/esm/decode.mjs";
5
- import { ERR as i } from "../common/error-codes.mjs";
6
- import { TAG_ID as C, getTagID as l } from "../common/html.mjs";
7
- import { htmlDecodeTree as d } from "../../../entities/dist/esm/generated/decode-data-html.mjs";
8
- var s;
9
- (function(a) {
10
- a[a.DATA = 0] = "DATA", a[a.RCDATA = 1] = "RCDATA", a[a.RAWTEXT = 2] = "RAWTEXT", a[a.SCRIPT_DATA = 3] = "SCRIPT_DATA", a[a.PLAINTEXT = 4] = "PLAINTEXT", a[a.TAG_OPEN = 5] = "TAG_OPEN", a[a.END_TAG_OPEN = 6] = "END_TAG_OPEN", a[a.TAG_NAME = 7] = "TAG_NAME", a[a.RCDATA_LESS_THAN_SIGN = 8] = "RCDATA_LESS_THAN_SIGN", a[a.RCDATA_END_TAG_OPEN = 9] = "RCDATA_END_TAG_OPEN", a[a.RCDATA_END_TAG_NAME = 10] = "RCDATA_END_TAG_NAME", a[a.RAWTEXT_LESS_THAN_SIGN = 11] = "RAWTEXT_LESS_THAN_SIGN", a[a.RAWTEXT_END_TAG_OPEN = 12] = "RAWTEXT_END_TAG_OPEN", a[a.RAWTEXT_END_TAG_NAME = 13] = "RAWTEXT_END_TAG_NAME", a[a.SCRIPT_DATA_LESS_THAN_SIGN = 14] = "SCRIPT_DATA_LESS_THAN_SIGN", a[a.SCRIPT_DATA_END_TAG_OPEN = 15] = "SCRIPT_DATA_END_TAG_OPEN", a[a.SCRIPT_DATA_END_TAG_NAME = 16] = "SCRIPT_DATA_END_TAG_NAME", a[a.SCRIPT_DATA_ESCAPE_START = 17] = "SCRIPT_DATA_ESCAPE_START", a[a.SCRIPT_DATA_ESCAPE_START_DASH = 18] = "SCRIPT_DATA_ESCAPE_START_DASH", a[a.SCRIPT_DATA_ESCAPED = 19] = "SCRIPT_DATA_ESCAPED", a[a.SCRIPT_DATA_ESCAPED_DASH = 20] = "SCRIPT_DATA_ESCAPED_DASH", a[a.SCRIPT_DATA_ESCAPED_DASH_DASH = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH", a[a.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN", a[a.SCRIPT_DATA_ESCAPED_END_TAG_OPEN = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN", a[a.SCRIPT_DATA_ESCAPED_END_TAG_NAME = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME", a[a.SCRIPT_DATA_DOUBLE_ESCAPE_START = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START", a[a.SCRIPT_DATA_DOUBLE_ESCAPED = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED", a[a.SCRIPT_DATA_DOUBLE_ESCAPED_DASH = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH", a[a.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH", a[a.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN", a[a.SCRIPT_DATA_DOUBLE_ESCAPE_END = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END", a[a.BEFORE_ATTRIBUTE_NAME = 31] = "BEFORE_ATTRIBUTE_NAME", a[a.ATTRIBUTE_NAME = 32] = "ATTRIBUTE_NAME", a[a.AFTER_ATTRIBUTE_NAME = 33] = "AFTER_ATTRIBUTE_NAME", a[a.BEFORE_ATTRIBUTE_VALUE = 34] = "BEFORE_ATTRIBUTE_VALUE", a[a.ATTRIBUTE_VALUE_DOUBLE_QUOTED = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED", a[a.ATTRIBUTE_VALUE_SINGLE_QUOTED = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED", a[a.ATTRIBUTE_VALUE_UNQUOTED = 37] = "ATTRIBUTE_VALUE_UNQUOTED", a[a.AFTER_ATTRIBUTE_VALUE_QUOTED = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED", a[a.SELF_CLOSING_START_TAG = 39] = "SELF_CLOSING_START_TAG", a[a.BOGUS_COMMENT = 40] = "BOGUS_COMMENT", a[a.MARKUP_DECLARATION_OPEN = 41] = "MARKUP_DECLARATION_OPEN", a[a.COMMENT_START = 42] = "COMMENT_START", a[a.COMMENT_START_DASH = 43] = "COMMENT_START_DASH", a[a.COMMENT = 44] = "COMMENT", a[a.COMMENT_LESS_THAN_SIGN = 45] = "COMMENT_LESS_THAN_SIGN", a[a.COMMENT_LESS_THAN_SIGN_BANG = 46] = "COMMENT_LESS_THAN_SIGN_BANG", a[a.COMMENT_LESS_THAN_SIGN_BANG_DASH = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH", a[a.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH", a[a.COMMENT_END_DASH = 49] = "COMMENT_END_DASH", a[a.COMMENT_END = 50] = "COMMENT_END", a[a.COMMENT_END_BANG = 51] = "COMMENT_END_BANG", a[a.DOCTYPE = 52] = "DOCTYPE", a[a.BEFORE_DOCTYPE_NAME = 53] = "BEFORE_DOCTYPE_NAME", a[a.DOCTYPE_NAME = 54] = "DOCTYPE_NAME", a[a.AFTER_DOCTYPE_NAME = 55] = "AFTER_DOCTYPE_NAME", a[a.AFTER_DOCTYPE_PUBLIC_KEYWORD = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD", a[a.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER", a[a.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED", a[a.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED", a[a.AFTER_DOCTYPE_PUBLIC_IDENTIFIER = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER", a[a.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS", a[a.AFTER_DOCTYPE_SYSTEM_KEYWORD = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD", a[a.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER", a[a.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED", a[a.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED", a[a.AFTER_DOCTYPE_SYSTEM_IDENTIFIER = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER", a[a.BOGUS_DOCTYPE = 67] = "BOGUS_DOCTYPE", a[a.CDATA_SECTION = 68] = "CDATA_SECTION", a[a.CDATA_SECTION_BRACKET = 69] = "CDATA_SECTION_BRACKET", a[a.CDATA_SECTION_END = 70] = "CDATA_SECTION_END", a[a.CHARACTER_REFERENCE = 71] = "CHARACTER_REFERENCE", a[a.AMBIGUOUS_AMPERSAND = 72] = "AMBIGUOUS_AMPERSAND";
11
- })(s || (s = {}));
12
- const H = {
13
- DATA: s.DATA,
14
- RCDATA: s.RCDATA,
15
- RAWTEXT: s.RAWTEXT,
16
- SCRIPT_DATA: s.SCRIPT_DATA,
17
- PLAINTEXT: s.PLAINTEXT,
18
- CDATA_SECTION: s.CDATA_SECTION
19
- };
20
- function f(a) {
21
- return a >= t.DIGIT_0 && a <= t.DIGIT_9;
22
- }
23
- function o(a) {
24
- return a >= t.LATIN_CAPITAL_A && a <= t.LATIN_CAPITAL_Z;
25
- }
26
- function L(a) {
27
- return a >= t.LATIN_SMALL_A && a <= t.LATIN_SMALL_Z;
28
- }
29
- function n(a) {
30
- return L(a) || o(a);
31
- }
32
- function S(a) {
33
- return n(a) || f(a);
34
- }
35
- function c(a) {
36
- return a + 32;
37
- }
38
- function I(a) {
39
- return a === t.SPACE || a === t.LINE_FEED || a === t.TABULATION || a === t.FORM_FEED;
40
- }
41
- function N(a) {
42
- return I(a) || a === t.SOLIDUS || a === t.GREATER_THAN_SIGN;
43
- }
44
- function b(a) {
45
- return a === t.NULL ? i.nullCharacterReference : a > 1114111 ? i.characterReferenceOutsideUnicodeRange : O(a) ? i.surrogateCharacterReference : R(a) ? i.noncharacterCharacterReference : m(a) || a === t.CARRIAGE_RETURN ? i.controlCharacterReference : null;
46
- }
47
- class y {
48
- constructor(e, r) {
49
- this.options = e, this.handler = r, this.paused = !1, this.inLoop = !1, this.inForeignNode = !1, this.lastStartTagName = "", this.active = !1, this.state = s.DATA, this.returnState = s.DATA, this.entityStartPos = 0, this.consumedAfterSnapshot = -1, this.currentCharacterToken = null, this.currentToken = null, this.currentAttr = {
50
- name: "",
51
- value: ""
52
- }, this.preprocessor = new u(r), this.currentLocation = this.getCurrentLocation(-1), this.entityDecoder = new k(d, (E, h) => {
53
- this.preprocessor.pos = this.entityStartPos + h - 1, this._flushCodePointConsumedAsCharacterReference(E);
54
- }, r.onParseError ? {
55
- missingSemicolonAfterCharacterReference: () => {
56
- this._err(i.missingSemicolonAfterCharacterReference, 1);
57
- },
58
- absenceOfDigitsInNumericCharacterReference: (E) => {
59
- this._err(i.absenceOfDigitsInNumericCharacterReference, this.entityStartPos - this.preprocessor.pos + E);
60
- },
61
- validateNumericCharacterReference: (E) => {
62
- const h = b(E);
63
- h && this._err(h, 1);
64
- }
65
- } : void 0);
66
- }
67
- //Errors
68
- _err(e, r = 0) {
69
- var E, h;
70
- (h = (E = this.handler).onParseError) === null || h === void 0 || h.call(E, this.preprocessor.getError(e, r));
71
- }
72
- // NOTE: `offset` may never run across line boundaries.
73
- getCurrentLocation(e) {
74
- return this.options.sourceCodeLocationInfo ? {
75
- startLine: this.preprocessor.line,
76
- startCol: this.preprocessor.col - e,
77
- startOffset: this.preprocessor.offset - e,
78
- endLine: -1,
79
- endCol: -1,
80
- endOffset: -1
81
- } : null;
82
- }
83
- _runParsingLoop() {
84
- if (!this.inLoop) {
85
- for (this.inLoop = !0; this.active && !this.paused; ) {
86
- this.consumedAfterSnapshot = 0;
87
- const e = this._consume();
88
- this._ensureHibernation() || this._callState(e);
89
- }
90
- this.inLoop = !1;
91
- }
92
- }
93
- //API
94
- pause() {
95
- this.paused = !0;
96
- }
97
- resume(e) {
98
- if (!this.paused)
99
- throw new Error("Parser was already resumed");
100
- this.paused = !1, !this.inLoop && (this._runParsingLoop(), this.paused || e == null || e());
101
- }
102
- write(e, r, E) {
103
- this.active = !0, this.preprocessor.write(e, r), this._runParsingLoop(), this.paused || E == null || E();
104
- }
105
- insertHtmlAtCurrentPos(e) {
106
- this.active = !0, this.preprocessor.insertHtmlAtCurrentPos(e), this._runParsingLoop();
107
- }
108
- //Hibernation
109
- _ensureHibernation() {
110
- return this.preprocessor.endOfChunkHit ? (this.preprocessor.retreat(this.consumedAfterSnapshot), this.consumedAfterSnapshot = 0, this.active = !1, !0) : !1;
111
- }
112
- //Consumption
113
- _consume() {
114
- return this.consumedAfterSnapshot++, this.preprocessor.advance();
115
- }
116
- _advanceBy(e) {
117
- this.consumedAfterSnapshot += e;
118
- for (let r = 0; r < e; r++)
119
- this.preprocessor.advance();
120
- }
121
- _consumeSequenceIfMatch(e, r) {
122
- return this.preprocessor.startsWith(e, r) ? (this._advanceBy(e.length - 1), !0) : !1;
123
- }
124
- //Token creation
125
- _createStartTagToken() {
126
- this.currentToken = {
127
- type: A.START_TAG,
128
- tagName: "",
129
- tagID: C.UNKNOWN,
130
- selfClosing: !1,
131
- ackSelfClosing: !1,
132
- attrs: [],
133
- location: this.getCurrentLocation(1)
134
- };
135
- }
136
- _createEndTagToken() {
137
- this.currentToken = {
138
- type: A.END_TAG,
139
- tagName: "",
140
- tagID: C.UNKNOWN,
141
- selfClosing: !1,
142
- ackSelfClosing: !1,
143
- attrs: [],
144
- location: this.getCurrentLocation(2)
145
- };
146
- }
147
- _createCommentToken(e) {
148
- this.currentToken = {
149
- type: A.COMMENT,
150
- data: "",
151
- location: this.getCurrentLocation(e)
152
- };
153
- }
154
- _createDoctypeToken(e) {
155
- this.currentToken = {
156
- type: A.DOCTYPE,
157
- name: e,
158
- forceQuirks: !1,
159
- publicId: null,
160
- systemId: null,
161
- location: this.currentLocation
162
- };
163
- }
164
- _createCharacterToken(e, r) {
165
- this.currentCharacterToken = {
166
- type: e,
167
- chars: r,
168
- location: this.currentLocation
169
- };
170
- }
171
- //Tag attributes
172
- _createAttr(e) {
173
- this.currentAttr = {
174
- name: e,
175
- value: ""
176
- }, this.currentLocation = this.getCurrentLocation(0);
177
- }
178
- _leaveAttrName() {
179
- var e, r;
180
- const E = this.currentToken;
181
- if (P(E, this.currentAttr.name) === null) {
182
- if (E.attrs.push(this.currentAttr), E.location && this.currentLocation) {
183
- const h = (e = (r = E.location).attrs) !== null && e !== void 0 ? e : r.attrs = /* @__PURE__ */ Object.create(null);
184
- h[this.currentAttr.name] = this.currentLocation, this._leaveAttrValue();
185
- }
186
- } else
187
- this._err(i.duplicateAttribute);
188
- }
189
- _leaveAttrValue() {
190
- this.currentLocation && (this.currentLocation.endLine = this.preprocessor.line, this.currentLocation.endCol = this.preprocessor.col, this.currentLocation.endOffset = this.preprocessor.offset);
191
- }
192
- //Token emission
193
- prepareToken(e) {
194
- this._emitCurrentCharacterToken(e.location), this.currentToken = null, e.location && (e.location.endLine = this.preprocessor.line, e.location.endCol = this.preprocessor.col + 1, e.location.endOffset = this.preprocessor.offset + 1), this.currentLocation = this.getCurrentLocation(-1);
195
- }
196
- emitCurrentTagToken() {
197
- const e = this.currentToken;
198
- this.prepareToken(e), e.tagID = l(e.tagName), e.type === A.START_TAG ? (this.lastStartTagName = e.tagName, this.handler.onStartTag(e)) : (e.attrs.length > 0 && this._err(i.endTagWithAttributes), e.selfClosing && this._err(i.endTagWithTrailingSolidus), this.handler.onEndTag(e)), this.preprocessor.dropParsedChunk();
199
- }
200
- emitCurrentComment(e) {
201
- this.prepareToken(e), this.handler.onComment(e), this.preprocessor.dropParsedChunk();
202
- }
203
- emitCurrentDoctype(e) {
204
- this.prepareToken(e), this.handler.onDoctype(e), this.preprocessor.dropParsedChunk();
205
- }
206
- _emitCurrentCharacterToken(e) {
207
- if (this.currentCharacterToken) {
208
- switch (e && this.currentCharacterToken.location && (this.currentCharacterToken.location.endLine = e.startLine, this.currentCharacterToken.location.endCol = e.startCol, this.currentCharacterToken.location.endOffset = e.startOffset), this.currentCharacterToken.type) {
209
- case A.CHARACTER: {
210
- this.handler.onCharacter(this.currentCharacterToken);
211
- break;
212
- }
213
- case A.NULL_CHARACTER: {
214
- this.handler.onNullCharacter(this.currentCharacterToken);
215
- break;
216
- }
217
- case A.WHITESPACE_CHARACTER: {
218
- this.handler.onWhitespaceCharacter(this.currentCharacterToken);
219
- break;
220
- }
221
- }
222
- this.currentCharacterToken = null;
223
- }
224
- }
225
- _emitEOFToken() {
226
- const e = this.getCurrentLocation(0);
227
- e && (e.endLine = e.startLine, e.endCol = e.startCol, e.endOffset = e.startOffset), this._emitCurrentCharacterToken(e), this.handler.onEof({
228
- type: A.EOF,
229
- location: e
230
- }), this.active = !1;
231
- }
232
- //Characters emission
233
- //OPTIMIZATION: The specification uses only one type of character token (one token per character).
234
- //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
235
- //If we have a sequence of characters that belong to the same group, the parser can process it
236
- //as a single solid character token.
237
- //So, there are 3 types of character tokens in parse5:
238
- //1)TokenType.NULL_CHARACTER - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
239
- //2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\n \r\t \f')
240
- //3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
241
- _appendCharToCurrentCharacterToken(e, r) {
242
- if (this.currentCharacterToken)
243
- if (this.currentCharacterToken.type === e) {
244
- this.currentCharacterToken.chars += r;
245
- return;
246
- } else
247
- this.currentLocation = this.getCurrentLocation(0), this._emitCurrentCharacterToken(this.currentLocation), this.preprocessor.dropParsedChunk();
248
- this._createCharacterToken(e, r);
249
- }
250
- _emitCodePoint(e) {
251
- const r = I(e) ? A.WHITESPACE_CHARACTER : e === t.NULL ? A.NULL_CHARACTER : A.CHARACTER;
252
- this._appendCharToCurrentCharacterToken(r, String.fromCodePoint(e));
253
- }
254
- //NOTE: used when we emit characters explicitly.
255
- //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
256
- _emitChars(e) {
257
- this._appendCharToCurrentCharacterToken(A.CHARACTER, e);
258
- }
259
- // Character reference helpers
260
- _startCharacterReference() {
261
- this.returnState = this.state, this.state = s.CHARACTER_REFERENCE, this.entityStartPos = this.preprocessor.pos, this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute() ? D.Attribute : D.Legacy);
262
- }
263
- _isCharacterReferenceInAttribute() {
264
- return this.returnState === s.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === s.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === s.ATTRIBUTE_VALUE_UNQUOTED;
265
- }
266
- _flushCodePointConsumedAsCharacterReference(e) {
267
- this._isCharacterReferenceInAttribute() ? this.currentAttr.value += String.fromCodePoint(e) : this._emitCodePoint(e);
268
- }
269
- // Calling states this way turns out to be much faster than any other approach.
270
- _callState(e) {
271
- switch (this.state) {
272
- case s.DATA: {
273
- this._stateData(e);
274
- break;
275
- }
276
- case s.RCDATA: {
277
- this._stateRcdata(e);
278
- break;
279
- }
280
- case s.RAWTEXT: {
281
- this._stateRawtext(e);
282
- break;
283
- }
284
- case s.SCRIPT_DATA: {
285
- this._stateScriptData(e);
286
- break;
287
- }
288
- case s.PLAINTEXT: {
289
- this._statePlaintext(e);
290
- break;
291
- }
292
- case s.TAG_OPEN: {
293
- this._stateTagOpen(e);
294
- break;
295
- }
296
- case s.END_TAG_OPEN: {
297
- this._stateEndTagOpen(e);
298
- break;
299
- }
300
- case s.TAG_NAME: {
301
- this._stateTagName(e);
302
- break;
303
- }
304
- case s.RCDATA_LESS_THAN_SIGN: {
305
- this._stateRcdataLessThanSign(e);
306
- break;
307
- }
308
- case s.RCDATA_END_TAG_OPEN: {
309
- this._stateRcdataEndTagOpen(e);
310
- break;
311
- }
312
- case s.RCDATA_END_TAG_NAME: {
313
- this._stateRcdataEndTagName(e);
314
- break;
315
- }
316
- case s.RAWTEXT_LESS_THAN_SIGN: {
317
- this._stateRawtextLessThanSign(e);
318
- break;
319
- }
320
- case s.RAWTEXT_END_TAG_OPEN: {
321
- this._stateRawtextEndTagOpen(e);
322
- break;
323
- }
324
- case s.RAWTEXT_END_TAG_NAME: {
325
- this._stateRawtextEndTagName(e);
326
- break;
327
- }
328
- case s.SCRIPT_DATA_LESS_THAN_SIGN: {
329
- this._stateScriptDataLessThanSign(e);
330
- break;
331
- }
332
- case s.SCRIPT_DATA_END_TAG_OPEN: {
333
- this._stateScriptDataEndTagOpen(e);
334
- break;
335
- }
336
- case s.SCRIPT_DATA_END_TAG_NAME: {
337
- this._stateScriptDataEndTagName(e);
338
- break;
339
- }
340
- case s.SCRIPT_DATA_ESCAPE_START: {
341
- this._stateScriptDataEscapeStart(e);
342
- break;
343
- }
344
- case s.SCRIPT_DATA_ESCAPE_START_DASH: {
345
- this._stateScriptDataEscapeStartDash(e);
346
- break;
347
- }
348
- case s.SCRIPT_DATA_ESCAPED: {
349
- this._stateScriptDataEscaped(e);
350
- break;
351
- }
352
- case s.SCRIPT_DATA_ESCAPED_DASH: {
353
- this._stateScriptDataEscapedDash(e);
354
- break;
355
- }
356
- case s.SCRIPT_DATA_ESCAPED_DASH_DASH: {
357
- this._stateScriptDataEscapedDashDash(e);
358
- break;
359
- }
360
- case s.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
361
- this._stateScriptDataEscapedLessThanSign(e);
362
- break;
363
- }
364
- case s.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {
365
- this._stateScriptDataEscapedEndTagOpen(e);
366
- break;
367
- }
368
- case s.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {
369
- this._stateScriptDataEscapedEndTagName(e);
370
- break;
371
- }
372
- case s.SCRIPT_DATA_DOUBLE_ESCAPE_START: {
373
- this._stateScriptDataDoubleEscapeStart(e);
374
- break;
375
- }
376
- case s.SCRIPT_DATA_DOUBLE_ESCAPED: {
377
- this._stateScriptDataDoubleEscaped(e);
378
- break;
379
- }
380
- case s.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
381
- this._stateScriptDataDoubleEscapedDash(e);
382
- break;
383
- }
384
- case s.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
385
- this._stateScriptDataDoubleEscapedDashDash(e);
386
- break;
387
- }
388
- case s.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
389
- this._stateScriptDataDoubleEscapedLessThanSign(e);
390
- break;
391
- }
392
- case s.SCRIPT_DATA_DOUBLE_ESCAPE_END: {
393
- this._stateScriptDataDoubleEscapeEnd(e);
394
- break;
395
- }
396
- case s.BEFORE_ATTRIBUTE_NAME: {
397
- this._stateBeforeAttributeName(e);
398
- break;
399
- }
400
- case s.ATTRIBUTE_NAME: {
401
- this._stateAttributeName(e);
402
- break;
403
- }
404
- case s.AFTER_ATTRIBUTE_NAME: {
405
- this._stateAfterAttributeName(e);
406
- break;
407
- }
408
- case s.BEFORE_ATTRIBUTE_VALUE: {
409
- this._stateBeforeAttributeValue(e);
410
- break;
411
- }
412
- case s.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
413
- this._stateAttributeValueDoubleQuoted(e);
414
- break;
415
- }
416
- case s.ATTRIBUTE_VALUE_SINGLE_QUOTED: {
417
- this._stateAttributeValueSingleQuoted(e);
418
- break;
419
- }
420
- case s.ATTRIBUTE_VALUE_UNQUOTED: {
421
- this._stateAttributeValueUnquoted(e);
422
- break;
423
- }
424
- case s.AFTER_ATTRIBUTE_VALUE_QUOTED: {
425
- this._stateAfterAttributeValueQuoted(e);
426
- break;
427
- }
428
- case s.SELF_CLOSING_START_TAG: {
429
- this._stateSelfClosingStartTag(e);
430
- break;
431
- }
432
- case s.BOGUS_COMMENT: {
433
- this._stateBogusComment(e);
434
- break;
435
- }
436
- case s.MARKUP_DECLARATION_OPEN: {
437
- this._stateMarkupDeclarationOpen(e);
438
- break;
439
- }
440
- case s.COMMENT_START: {
441
- this._stateCommentStart(e);
442
- break;
443
- }
444
- case s.COMMENT_START_DASH: {
445
- this._stateCommentStartDash(e);
446
- break;
447
- }
448
- case s.COMMENT: {
449
- this._stateComment(e);
450
- break;
451
- }
452
- case s.COMMENT_LESS_THAN_SIGN: {
453
- this._stateCommentLessThanSign(e);
454
- break;
455
- }
456
- case s.COMMENT_LESS_THAN_SIGN_BANG: {
457
- this._stateCommentLessThanSignBang(e);
458
- break;
459
- }
460
- case s.COMMENT_LESS_THAN_SIGN_BANG_DASH: {
461
- this._stateCommentLessThanSignBangDash(e);
462
- break;
463
- }
464
- case s.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {
465
- this._stateCommentLessThanSignBangDashDash(e);
466
- break;
467
- }
468
- case s.COMMENT_END_DASH: {
469
- this._stateCommentEndDash(e);
470
- break;
471
- }
472
- case s.COMMENT_END: {
473
- this._stateCommentEnd(e);
474
- break;
475
- }
476
- case s.COMMENT_END_BANG: {
477
- this._stateCommentEndBang(e);
478
- break;
479
- }
480
- case s.DOCTYPE: {
481
- this._stateDoctype(e);
482
- break;
483
- }
484
- case s.BEFORE_DOCTYPE_NAME: {
485
- this._stateBeforeDoctypeName(e);
486
- break;
487
- }
488
- case s.DOCTYPE_NAME: {
489
- this._stateDoctypeName(e);
490
- break;
491
- }
492
- case s.AFTER_DOCTYPE_NAME: {
493
- this._stateAfterDoctypeName(e);
494
- break;
495
- }
496
- case s.AFTER_DOCTYPE_PUBLIC_KEYWORD: {
497
- this._stateAfterDoctypePublicKeyword(e);
498
- break;
499
- }
500
- case s.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
501
- this._stateBeforeDoctypePublicIdentifier(e);
502
- break;
503
- }
504
- case s.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
505
- this._stateDoctypePublicIdentifierDoubleQuoted(e);
506
- break;
507
- }
508
- case s.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
509
- this._stateDoctypePublicIdentifierSingleQuoted(e);
510
- break;
511
- }
512
- case s.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
513
- this._stateAfterDoctypePublicIdentifier(e);
514
- break;
515
- }
516
- case s.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
517
- this._stateBetweenDoctypePublicAndSystemIdentifiers(e);
518
- break;
519
- }
520
- case s.AFTER_DOCTYPE_SYSTEM_KEYWORD: {
521
- this._stateAfterDoctypeSystemKeyword(e);
522
- break;
523
- }
524
- case s.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
525
- this._stateBeforeDoctypeSystemIdentifier(e);
526
- break;
527
- }
528
- case s.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
529
- this._stateDoctypeSystemIdentifierDoubleQuoted(e);
530
- break;
531
- }
532
- case s.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
533
- this._stateDoctypeSystemIdentifierSingleQuoted(e);
534
- break;
535
- }
536
- case s.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
537
- this._stateAfterDoctypeSystemIdentifier(e);
538
- break;
539
- }
540
- case s.BOGUS_DOCTYPE: {
541
- this._stateBogusDoctype(e);
542
- break;
543
- }
544
- case s.CDATA_SECTION: {
545
- this._stateCdataSection(e);
546
- break;
547
- }
548
- case s.CDATA_SECTION_BRACKET: {
549
- this._stateCdataSectionBracket(e);
550
- break;
551
- }
552
- case s.CDATA_SECTION_END: {
553
- this._stateCdataSectionEnd(e);
554
- break;
555
- }
556
- case s.CHARACTER_REFERENCE: {
557
- this._stateCharacterReference();
558
- break;
559
- }
560
- case s.AMBIGUOUS_AMPERSAND: {
561
- this._stateAmbiguousAmpersand(e);
562
- break;
563
- }
564
- default:
565
- throw new Error("Unknown state");
566
- }
567
- }
568
- // State machine
569
- // Data state
570
- //------------------------------------------------------------------
571
- _stateData(e) {
572
- switch (e) {
573
- case t.LESS_THAN_SIGN: {
574
- this.state = s.TAG_OPEN;
575
- break;
576
- }
577
- case t.AMPERSAND: {
578
- this._startCharacterReference();
579
- break;
580
- }
581
- case t.NULL: {
582
- this._err(i.unexpectedNullCharacter), this._emitCodePoint(e);
583
- break;
584
- }
585
- case t.EOF: {
586
- this._emitEOFToken();
587
- break;
588
- }
589
- default:
590
- this._emitCodePoint(e);
591
- }
592
- }
593
- // RCDATA state
594
- //------------------------------------------------------------------
595
- _stateRcdata(e) {
596
- switch (e) {
597
- case t.AMPERSAND: {
598
- this._startCharacterReference();
599
- break;
600
- }
601
- case t.LESS_THAN_SIGN: {
602
- this.state = s.RCDATA_LESS_THAN_SIGN;
603
- break;
604
- }
605
- case t.NULL: {
606
- this._err(i.unexpectedNullCharacter), this._emitChars(_);
607
- break;
608
- }
609
- case t.EOF: {
610
- this._emitEOFToken();
611
- break;
612
- }
613
- default:
614
- this._emitCodePoint(e);
615
- }
616
- }
617
- // RAWTEXT state
618
- //------------------------------------------------------------------
619
- _stateRawtext(e) {
620
- switch (e) {
621
- case t.LESS_THAN_SIGN: {
622
- this.state = s.RAWTEXT_LESS_THAN_SIGN;
623
- break;
624
- }
625
- case t.NULL: {
626
- this._err(i.unexpectedNullCharacter), this._emitChars(_);
627
- break;
628
- }
629
- case t.EOF: {
630
- this._emitEOFToken();
631
- break;
632
- }
633
- default:
634
- this._emitCodePoint(e);
635
- }
636
- }
637
- // Script data state
638
- //------------------------------------------------------------------
639
- _stateScriptData(e) {
640
- switch (e) {
641
- case t.LESS_THAN_SIGN: {
642
- this.state = s.SCRIPT_DATA_LESS_THAN_SIGN;
643
- break;
644
- }
645
- case t.NULL: {
646
- this._err(i.unexpectedNullCharacter), this._emitChars(_);
647
- break;
648
- }
649
- case t.EOF: {
650
- this._emitEOFToken();
651
- break;
652
- }
653
- default:
654
- this._emitCodePoint(e);
655
- }
656
- }
657
- // PLAINTEXT state
658
- //------------------------------------------------------------------
659
- _statePlaintext(e) {
660
- switch (e) {
661
- case t.NULL: {
662
- this._err(i.unexpectedNullCharacter), this._emitChars(_);
663
- break;
664
- }
665
- case t.EOF: {
666
- this._emitEOFToken();
667
- break;
668
- }
669
- default:
670
- this._emitCodePoint(e);
671
- }
672
- }
673
- // Tag open state
674
- //------------------------------------------------------------------
675
- _stateTagOpen(e) {
676
- if (n(e))
677
- this._createStartTagToken(), this.state = s.TAG_NAME, this._stateTagName(e);
678
- else
679
- switch (e) {
680
- case t.EXCLAMATION_MARK: {
681
- this.state = s.MARKUP_DECLARATION_OPEN;
682
- break;
683
- }
684
- case t.SOLIDUS: {
685
- this.state = s.END_TAG_OPEN;
686
- break;
687
- }
688
- case t.QUESTION_MARK: {
689
- this._err(i.unexpectedQuestionMarkInsteadOfTagName), this._createCommentToken(1), this.state = s.BOGUS_COMMENT, this._stateBogusComment(e);
690
- break;
691
- }
692
- case t.EOF: {
693
- this._err(i.eofBeforeTagName), this._emitChars("<"), this._emitEOFToken();
694
- break;
695
- }
696
- default:
697
- this._err(i.invalidFirstCharacterOfTagName), this._emitChars("<"), this.state = s.DATA, this._stateData(e);
698
- }
699
- }
700
- // End tag open state
701
- //------------------------------------------------------------------
702
- _stateEndTagOpen(e) {
703
- if (n(e))
704
- this._createEndTagToken(), this.state = s.TAG_NAME, this._stateTagName(e);
705
- else
706
- switch (e) {
707
- case t.GREATER_THAN_SIGN: {
708
- this._err(i.missingEndTagName), this.state = s.DATA;
709
- break;
710
- }
711
- case t.EOF: {
712
- this._err(i.eofBeforeTagName), this._emitChars("</"), this._emitEOFToken();
713
- break;
714
- }
715
- default:
716
- this._err(i.invalidFirstCharacterOfTagName), this._createCommentToken(2), this.state = s.BOGUS_COMMENT, this._stateBogusComment(e);
717
- }
718
- }
719
- // Tag name state
720
- //------------------------------------------------------------------
721
- _stateTagName(e) {
722
- const r = this.currentToken;
723
- switch (e) {
724
- case t.SPACE:
725
- case t.LINE_FEED:
726
- case t.TABULATION:
727
- case t.FORM_FEED: {
728
- this.state = s.BEFORE_ATTRIBUTE_NAME;
729
- break;
730
- }
731
- case t.SOLIDUS: {
732
- this.state = s.SELF_CLOSING_START_TAG;
733
- break;
734
- }
735
- case t.GREATER_THAN_SIGN: {
736
- this.state = s.DATA, this.emitCurrentTagToken();
737
- break;
738
- }
739
- case t.NULL: {
740
- this._err(i.unexpectedNullCharacter), r.tagName += _;
741
- break;
742
- }
743
- case t.EOF: {
744
- this._err(i.eofInTag), this._emitEOFToken();
745
- break;
746
- }
747
- default:
748
- r.tagName += String.fromCodePoint(o(e) ? c(e) : e);
749
- }
750
- }
751
- // RCDATA less-than sign state
752
- //------------------------------------------------------------------
753
- _stateRcdataLessThanSign(e) {
754
- e === t.SOLIDUS ? this.state = s.RCDATA_END_TAG_OPEN : (this._emitChars("<"), this.state = s.RCDATA, this._stateRcdata(e));
755
- }
756
- // RCDATA end tag open state
757
- //------------------------------------------------------------------
758
- _stateRcdataEndTagOpen(e) {
759
- n(e) ? (this.state = s.RCDATA_END_TAG_NAME, this._stateRcdataEndTagName(e)) : (this._emitChars("</"), this.state = s.RCDATA, this._stateRcdata(e));
760
- }
761
- handleSpecialEndTag(e) {
762
- if (!this.preprocessor.startsWith(this.lastStartTagName, !1))
763
- return !this._ensureHibernation();
764
- this._createEndTagToken();
765
- const r = this.currentToken;
766
- switch (r.tagName = this.lastStartTagName, this.preprocessor.peek(this.lastStartTagName.length)) {
767
- case t.SPACE:
768
- case t.LINE_FEED:
769
- case t.TABULATION:
770
- case t.FORM_FEED:
771
- return this._advanceBy(this.lastStartTagName.length), this.state = s.BEFORE_ATTRIBUTE_NAME, !1;
772
- case t.SOLIDUS:
773
- return this._advanceBy(this.lastStartTagName.length), this.state = s.SELF_CLOSING_START_TAG, !1;
774
- case t.GREATER_THAN_SIGN:
775
- return this._advanceBy(this.lastStartTagName.length), this.emitCurrentTagToken(), this.state = s.DATA, !1;
776
- default:
777
- return !this._ensureHibernation();
778
- }
779
- }
780
- // RCDATA end tag name state
781
- //------------------------------------------------------------------
782
- _stateRcdataEndTagName(e) {
783
- this.handleSpecialEndTag(e) && (this._emitChars("</"), this.state = s.RCDATA, this._stateRcdata(e));
784
- }
785
- // RAWTEXT less-than sign state
786
- //------------------------------------------------------------------
787
- _stateRawtextLessThanSign(e) {
788
- e === t.SOLIDUS ? this.state = s.RAWTEXT_END_TAG_OPEN : (this._emitChars("<"), this.state = s.RAWTEXT, this._stateRawtext(e));
789
- }
790
- // RAWTEXT end tag open state
791
- //------------------------------------------------------------------
792
- _stateRawtextEndTagOpen(e) {
793
- n(e) ? (this.state = s.RAWTEXT_END_TAG_NAME, this._stateRawtextEndTagName(e)) : (this._emitChars("</"), this.state = s.RAWTEXT, this._stateRawtext(e));
794
- }
795
- // RAWTEXT end tag name state
796
- //------------------------------------------------------------------
797
- _stateRawtextEndTagName(e) {
798
- this.handleSpecialEndTag(e) && (this._emitChars("</"), this.state = s.RAWTEXT, this._stateRawtext(e));
799
- }
800
- // Script data less-than sign state
801
- //------------------------------------------------------------------
802
- _stateScriptDataLessThanSign(e) {
803
- switch (e) {
804
- case t.SOLIDUS: {
805
- this.state = s.SCRIPT_DATA_END_TAG_OPEN;
806
- break;
807
- }
808
- case t.EXCLAMATION_MARK: {
809
- this.state = s.SCRIPT_DATA_ESCAPE_START, this._emitChars("<!");
810
- break;
811
- }
812
- default:
813
- this._emitChars("<"), this.state = s.SCRIPT_DATA, this._stateScriptData(e);
814
- }
815
- }
816
- // Script data end tag open state
817
- //------------------------------------------------------------------
818
- _stateScriptDataEndTagOpen(e) {
819
- n(e) ? (this.state = s.SCRIPT_DATA_END_TAG_NAME, this._stateScriptDataEndTagName(e)) : (this._emitChars("</"), this.state = s.SCRIPT_DATA, this._stateScriptData(e));
820
- }
821
- // Script data end tag name state
822
- //------------------------------------------------------------------
823
- _stateScriptDataEndTagName(e) {
824
- this.handleSpecialEndTag(e) && (this._emitChars("</"), this.state = s.SCRIPT_DATA, this._stateScriptData(e));
825
- }
826
- // Script data escape start state
827
- //------------------------------------------------------------------
828
- _stateScriptDataEscapeStart(e) {
829
- e === t.HYPHEN_MINUS ? (this.state = s.SCRIPT_DATA_ESCAPE_START_DASH, this._emitChars("-")) : (this.state = s.SCRIPT_DATA, this._stateScriptData(e));
830
- }
831
- // Script data escape start dash state
832
- //------------------------------------------------------------------
833
- _stateScriptDataEscapeStartDash(e) {
834
- e === t.HYPHEN_MINUS ? (this.state = s.SCRIPT_DATA_ESCAPED_DASH_DASH, this._emitChars("-")) : (this.state = s.SCRIPT_DATA, this._stateScriptData(e));
835
- }
836
- // Script data escaped state
837
- //------------------------------------------------------------------
838
- _stateScriptDataEscaped(e) {
839
- switch (e) {
840
- case t.HYPHEN_MINUS: {
841
- this.state = s.SCRIPT_DATA_ESCAPED_DASH, this._emitChars("-");
842
- break;
843
- }
844
- case t.LESS_THAN_SIGN: {
845
- this.state = s.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
846
- break;
847
- }
848
- case t.NULL: {
849
- this._err(i.unexpectedNullCharacter), this._emitChars(_);
850
- break;
851
- }
852
- case t.EOF: {
853
- this._err(i.eofInScriptHtmlCommentLikeText), this._emitEOFToken();
854
- break;
855
- }
856
- default:
857
- this._emitCodePoint(e);
858
- }
859
- }
860
- // Script data escaped dash state
861
- //------------------------------------------------------------------
862
- _stateScriptDataEscapedDash(e) {
863
- switch (e) {
864
- case t.HYPHEN_MINUS: {
865
- this.state = s.SCRIPT_DATA_ESCAPED_DASH_DASH, this._emitChars("-");
866
- break;
867
- }
868
- case t.LESS_THAN_SIGN: {
869
- this.state = s.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
870
- break;
871
- }
872
- case t.NULL: {
873
- this._err(i.unexpectedNullCharacter), this.state = s.SCRIPT_DATA_ESCAPED, this._emitChars(_);
874
- break;
875
- }
876
- case t.EOF: {
877
- this._err(i.eofInScriptHtmlCommentLikeText), this._emitEOFToken();
878
- break;
879
- }
880
- default:
881
- this.state = s.SCRIPT_DATA_ESCAPED, this._emitCodePoint(e);
882
- }
883
- }
884
- // Script data escaped dash dash state
885
- //------------------------------------------------------------------
886
- _stateScriptDataEscapedDashDash(e) {
887
- switch (e) {
888
- case t.HYPHEN_MINUS: {
889
- this._emitChars("-");
890
- break;
891
- }
892
- case t.LESS_THAN_SIGN: {
893
- this.state = s.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
894
- break;
895
- }
896
- case t.GREATER_THAN_SIGN: {
897
- this.state = s.SCRIPT_DATA, this._emitChars(">");
898
- break;
899
- }
900
- case t.NULL: {
901
- this._err(i.unexpectedNullCharacter), this.state = s.SCRIPT_DATA_ESCAPED, this._emitChars(_);
902
- break;
903
- }
904
- case t.EOF: {
905
- this._err(i.eofInScriptHtmlCommentLikeText), this._emitEOFToken();
906
- break;
907
- }
908
- default:
909
- this.state = s.SCRIPT_DATA_ESCAPED, this._emitCodePoint(e);
910
- }
911
- }
912
- // Script data escaped less-than sign state
913
- //------------------------------------------------------------------
914
- _stateScriptDataEscapedLessThanSign(e) {
915
- e === t.SOLIDUS ? this.state = s.SCRIPT_DATA_ESCAPED_END_TAG_OPEN : n(e) ? (this._emitChars("<"), this.state = s.SCRIPT_DATA_DOUBLE_ESCAPE_START, this._stateScriptDataDoubleEscapeStart(e)) : (this._emitChars("<"), this.state = s.SCRIPT_DATA_ESCAPED, this._stateScriptDataEscaped(e));
916
- }
917
- // Script data escaped end tag open state
918
- //------------------------------------------------------------------
919
- _stateScriptDataEscapedEndTagOpen(e) {
920
- n(e) ? (this.state = s.SCRIPT_DATA_ESCAPED_END_TAG_NAME, this._stateScriptDataEscapedEndTagName(e)) : (this._emitChars("</"), this.state = s.SCRIPT_DATA_ESCAPED, this._stateScriptDataEscaped(e));
921
- }
922
- // Script data escaped end tag name state
923
- //------------------------------------------------------------------
924
- _stateScriptDataEscapedEndTagName(e) {
925
- this.handleSpecialEndTag(e) && (this._emitChars("</"), this.state = s.SCRIPT_DATA_ESCAPED, this._stateScriptDataEscaped(e));
926
- }
927
- // Script data double escape start state
928
- //------------------------------------------------------------------
929
- _stateScriptDataDoubleEscapeStart(e) {
930
- if (this.preprocessor.startsWith(T.SCRIPT, !1) && N(this.preprocessor.peek(T.SCRIPT.length))) {
931
- this._emitCodePoint(e);
932
- for (let r = 0; r < T.SCRIPT.length; r++)
933
- this._emitCodePoint(this._consume());
934
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED;
935
- } else
936
- this._ensureHibernation() || (this.state = s.SCRIPT_DATA_ESCAPED, this._stateScriptDataEscaped(e));
937
- }
938
- // Script data double escaped state
939
- //------------------------------------------------------------------
940
- _stateScriptDataDoubleEscaped(e) {
941
- switch (e) {
942
- case t.HYPHEN_MINUS: {
943
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED_DASH, this._emitChars("-");
944
- break;
945
- }
946
- case t.LESS_THAN_SIGN: {
947
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, this._emitChars("<");
948
- break;
949
- }
950
- case t.NULL: {
951
- this._err(i.unexpectedNullCharacter), this._emitChars(_);
952
- break;
953
- }
954
- case t.EOF: {
955
- this._err(i.eofInScriptHtmlCommentLikeText), this._emitEOFToken();
956
- break;
957
- }
958
- default:
959
- this._emitCodePoint(e);
960
- }
961
- }
962
- // Script data double escaped dash state
963
- //------------------------------------------------------------------
964
- _stateScriptDataDoubleEscapedDash(e) {
965
- switch (e) {
966
- case t.HYPHEN_MINUS: {
967
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH, this._emitChars("-");
968
- break;
969
- }
970
- case t.LESS_THAN_SIGN: {
971
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, this._emitChars("<");
972
- break;
973
- }
974
- case t.NULL: {
975
- this._err(i.unexpectedNullCharacter), this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED, this._emitChars(_);
976
- break;
977
- }
978
- case t.EOF: {
979
- this._err(i.eofInScriptHtmlCommentLikeText), this._emitEOFToken();
980
- break;
981
- }
982
- default:
983
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED, this._emitCodePoint(e);
984
- }
985
- }
986
- // Script data double escaped dash dash state
987
- //------------------------------------------------------------------
988
- _stateScriptDataDoubleEscapedDashDash(e) {
989
- switch (e) {
990
- case t.HYPHEN_MINUS: {
991
- this._emitChars("-");
992
- break;
993
- }
994
- case t.LESS_THAN_SIGN: {
995
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN, this._emitChars("<");
996
- break;
997
- }
998
- case t.GREATER_THAN_SIGN: {
999
- this.state = s.SCRIPT_DATA, this._emitChars(">");
1000
- break;
1001
- }
1002
- case t.NULL: {
1003
- this._err(i.unexpectedNullCharacter), this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED, this._emitChars(_);
1004
- break;
1005
- }
1006
- case t.EOF: {
1007
- this._err(i.eofInScriptHtmlCommentLikeText), this._emitEOFToken();
1008
- break;
1009
- }
1010
- default:
1011
- this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED, this._emitCodePoint(e);
1012
- }
1013
- }
1014
- // Script data double escaped less-than sign state
1015
- //------------------------------------------------------------------
1016
- _stateScriptDataDoubleEscapedLessThanSign(e) {
1017
- e === t.SOLIDUS ? (this.state = s.SCRIPT_DATA_DOUBLE_ESCAPE_END, this._emitChars("/")) : (this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED, this._stateScriptDataDoubleEscaped(e));
1018
- }
1019
- // Script data double escape end state
1020
- //------------------------------------------------------------------
1021
- _stateScriptDataDoubleEscapeEnd(e) {
1022
- if (this.preprocessor.startsWith(T.SCRIPT, !1) && N(this.preprocessor.peek(T.SCRIPT.length))) {
1023
- this._emitCodePoint(e);
1024
- for (let r = 0; r < T.SCRIPT.length; r++)
1025
- this._emitCodePoint(this._consume());
1026
- this.state = s.SCRIPT_DATA_ESCAPED;
1027
- } else
1028
- this._ensureHibernation() || (this.state = s.SCRIPT_DATA_DOUBLE_ESCAPED, this._stateScriptDataDoubleEscaped(e));
1029
- }
1030
- // Before attribute name state
1031
- //------------------------------------------------------------------
1032
- _stateBeforeAttributeName(e) {
1033
- switch (e) {
1034
- case t.SPACE:
1035
- case t.LINE_FEED:
1036
- case t.TABULATION:
1037
- case t.FORM_FEED:
1038
- break;
1039
- case t.SOLIDUS:
1040
- case t.GREATER_THAN_SIGN:
1041
- case t.EOF: {
1042
- this.state = s.AFTER_ATTRIBUTE_NAME, this._stateAfterAttributeName(e);
1043
- break;
1044
- }
1045
- case t.EQUALS_SIGN: {
1046
- this._err(i.unexpectedEqualsSignBeforeAttributeName), this._createAttr("="), this.state = s.ATTRIBUTE_NAME;
1047
- break;
1048
- }
1049
- default:
1050
- this._createAttr(""), this.state = s.ATTRIBUTE_NAME, this._stateAttributeName(e);
1051
- }
1052
- }
1053
- // Attribute name state
1054
- //------------------------------------------------------------------
1055
- _stateAttributeName(e) {
1056
- switch (e) {
1057
- case t.SPACE:
1058
- case t.LINE_FEED:
1059
- case t.TABULATION:
1060
- case t.FORM_FEED:
1061
- case t.SOLIDUS:
1062
- case t.GREATER_THAN_SIGN:
1063
- case t.EOF: {
1064
- this._leaveAttrName(), this.state = s.AFTER_ATTRIBUTE_NAME, this._stateAfterAttributeName(e);
1065
- break;
1066
- }
1067
- case t.EQUALS_SIGN: {
1068
- this._leaveAttrName(), this.state = s.BEFORE_ATTRIBUTE_VALUE;
1069
- break;
1070
- }
1071
- case t.QUOTATION_MARK:
1072
- case t.APOSTROPHE:
1073
- case t.LESS_THAN_SIGN: {
1074
- this._err(i.unexpectedCharacterInAttributeName), this.currentAttr.name += String.fromCodePoint(e);
1075
- break;
1076
- }
1077
- case t.NULL: {
1078
- this._err(i.unexpectedNullCharacter), this.currentAttr.name += _;
1079
- break;
1080
- }
1081
- default:
1082
- this.currentAttr.name += String.fromCodePoint(o(e) ? c(e) : e);
1083
- }
1084
- }
1085
- // After attribute name state
1086
- //------------------------------------------------------------------
1087
- _stateAfterAttributeName(e) {
1088
- switch (e) {
1089
- case t.SPACE:
1090
- case t.LINE_FEED:
1091
- case t.TABULATION:
1092
- case t.FORM_FEED:
1093
- break;
1094
- case t.SOLIDUS: {
1095
- this.state = s.SELF_CLOSING_START_TAG;
1096
- break;
1097
- }
1098
- case t.EQUALS_SIGN: {
1099
- this.state = s.BEFORE_ATTRIBUTE_VALUE;
1100
- break;
1101
- }
1102
- case t.GREATER_THAN_SIGN: {
1103
- this.state = s.DATA, this.emitCurrentTagToken();
1104
- break;
1105
- }
1106
- case t.EOF: {
1107
- this._err(i.eofInTag), this._emitEOFToken();
1108
- break;
1109
- }
1110
- default:
1111
- this._createAttr(""), this.state = s.ATTRIBUTE_NAME, this._stateAttributeName(e);
1112
- }
1113
- }
1114
- // Before attribute value state
1115
- //------------------------------------------------------------------
1116
- _stateBeforeAttributeValue(e) {
1117
- switch (e) {
1118
- case t.SPACE:
1119
- case t.LINE_FEED:
1120
- case t.TABULATION:
1121
- case t.FORM_FEED:
1122
- break;
1123
- case t.QUOTATION_MARK: {
1124
- this.state = s.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
1125
- break;
1126
- }
1127
- case t.APOSTROPHE: {
1128
- this.state = s.ATTRIBUTE_VALUE_SINGLE_QUOTED;
1129
- break;
1130
- }
1131
- case t.GREATER_THAN_SIGN: {
1132
- this._err(i.missingAttributeValue), this.state = s.DATA, this.emitCurrentTagToken();
1133
- break;
1134
- }
1135
- default:
1136
- this.state = s.ATTRIBUTE_VALUE_UNQUOTED, this._stateAttributeValueUnquoted(e);
1137
- }
1138
- }
1139
- // Attribute value (double-quoted) state
1140
- //------------------------------------------------------------------
1141
- _stateAttributeValueDoubleQuoted(e) {
1142
- switch (e) {
1143
- case t.QUOTATION_MARK: {
1144
- this.state = s.AFTER_ATTRIBUTE_VALUE_QUOTED;
1145
- break;
1146
- }
1147
- case t.AMPERSAND: {
1148
- this._startCharacterReference();
1149
- break;
1150
- }
1151
- case t.NULL: {
1152
- this._err(i.unexpectedNullCharacter), this.currentAttr.value += _;
1153
- break;
1154
- }
1155
- case t.EOF: {
1156
- this._err(i.eofInTag), this._emitEOFToken();
1157
- break;
1158
- }
1159
- default:
1160
- this.currentAttr.value += String.fromCodePoint(e);
1161
- }
1162
- }
1163
- // Attribute value (single-quoted) state
1164
- //------------------------------------------------------------------
1165
- _stateAttributeValueSingleQuoted(e) {
1166
- switch (e) {
1167
- case t.APOSTROPHE: {
1168
- this.state = s.AFTER_ATTRIBUTE_VALUE_QUOTED;
1169
- break;
1170
- }
1171
- case t.AMPERSAND: {
1172
- this._startCharacterReference();
1173
- break;
1174
- }
1175
- case t.NULL: {
1176
- this._err(i.unexpectedNullCharacter), this.currentAttr.value += _;
1177
- break;
1178
- }
1179
- case t.EOF: {
1180
- this._err(i.eofInTag), this._emitEOFToken();
1181
- break;
1182
- }
1183
- default:
1184
- this.currentAttr.value += String.fromCodePoint(e);
1185
- }
1186
- }
1187
- // Attribute value (unquoted) state
1188
- //------------------------------------------------------------------
1189
- _stateAttributeValueUnquoted(e) {
1190
- switch (e) {
1191
- case t.SPACE:
1192
- case t.LINE_FEED:
1193
- case t.TABULATION:
1194
- case t.FORM_FEED: {
1195
- this._leaveAttrValue(), this.state = s.BEFORE_ATTRIBUTE_NAME;
1196
- break;
1197
- }
1198
- case t.AMPERSAND: {
1199
- this._startCharacterReference();
1200
- break;
1201
- }
1202
- case t.GREATER_THAN_SIGN: {
1203
- this._leaveAttrValue(), this.state = s.DATA, this.emitCurrentTagToken();
1204
- break;
1205
- }
1206
- case t.NULL: {
1207
- this._err(i.unexpectedNullCharacter), this.currentAttr.value += _;
1208
- break;
1209
- }
1210
- case t.QUOTATION_MARK:
1211
- case t.APOSTROPHE:
1212
- case t.LESS_THAN_SIGN:
1213
- case t.EQUALS_SIGN:
1214
- case t.GRAVE_ACCENT: {
1215
- this._err(i.unexpectedCharacterInUnquotedAttributeValue), this.currentAttr.value += String.fromCodePoint(e);
1216
- break;
1217
- }
1218
- case t.EOF: {
1219
- this._err(i.eofInTag), this._emitEOFToken();
1220
- break;
1221
- }
1222
- default:
1223
- this.currentAttr.value += String.fromCodePoint(e);
1224
- }
1225
- }
1226
- // After attribute value (quoted) state
1227
- //------------------------------------------------------------------
1228
- _stateAfterAttributeValueQuoted(e) {
1229
- switch (e) {
1230
- case t.SPACE:
1231
- case t.LINE_FEED:
1232
- case t.TABULATION:
1233
- case t.FORM_FEED: {
1234
- this._leaveAttrValue(), this.state = s.BEFORE_ATTRIBUTE_NAME;
1235
- break;
1236
- }
1237
- case t.SOLIDUS: {
1238
- this._leaveAttrValue(), this.state = s.SELF_CLOSING_START_TAG;
1239
- break;
1240
- }
1241
- case t.GREATER_THAN_SIGN: {
1242
- this._leaveAttrValue(), this.state = s.DATA, this.emitCurrentTagToken();
1243
- break;
1244
- }
1245
- case t.EOF: {
1246
- this._err(i.eofInTag), this._emitEOFToken();
1247
- break;
1248
- }
1249
- default:
1250
- this._err(i.missingWhitespaceBetweenAttributes), this.state = s.BEFORE_ATTRIBUTE_NAME, this._stateBeforeAttributeName(e);
1251
- }
1252
- }
1253
- // Self-closing start tag state
1254
- //------------------------------------------------------------------
1255
- _stateSelfClosingStartTag(e) {
1256
- switch (e) {
1257
- case t.GREATER_THAN_SIGN: {
1258
- const r = this.currentToken;
1259
- r.selfClosing = !0, this.state = s.DATA, this.emitCurrentTagToken();
1260
- break;
1261
- }
1262
- case t.EOF: {
1263
- this._err(i.eofInTag), this._emitEOFToken();
1264
- break;
1265
- }
1266
- default:
1267
- this._err(i.unexpectedSolidusInTag), this.state = s.BEFORE_ATTRIBUTE_NAME, this._stateBeforeAttributeName(e);
1268
- }
1269
- }
1270
- // Bogus comment state
1271
- //------------------------------------------------------------------
1272
- _stateBogusComment(e) {
1273
- const r = this.currentToken;
1274
- switch (e) {
1275
- case t.GREATER_THAN_SIGN: {
1276
- this.state = s.DATA, this.emitCurrentComment(r);
1277
- break;
1278
- }
1279
- case t.EOF: {
1280
- this.emitCurrentComment(r), this._emitEOFToken();
1281
- break;
1282
- }
1283
- case t.NULL: {
1284
- this._err(i.unexpectedNullCharacter), r.data += _;
1285
- break;
1286
- }
1287
- default:
1288
- r.data += String.fromCodePoint(e);
1289
- }
1290
- }
1291
- // Markup declaration open state
1292
- //------------------------------------------------------------------
1293
- _stateMarkupDeclarationOpen(e) {
1294
- this._consumeSequenceIfMatch(T.DASH_DASH, !0) ? (this._createCommentToken(T.DASH_DASH.length + 1), this.state = s.COMMENT_START) : this._consumeSequenceIfMatch(T.DOCTYPE, !1) ? (this.currentLocation = this.getCurrentLocation(T.DOCTYPE.length + 1), this.state = s.DOCTYPE) : this._consumeSequenceIfMatch(T.CDATA_START, !0) ? this.inForeignNode ? this.state = s.CDATA_SECTION : (this._err(i.cdataInHtmlContent), this._createCommentToken(T.CDATA_START.length + 1), this.currentToken.data = "[CDATA[", this.state = s.BOGUS_COMMENT) : this._ensureHibernation() || (this._err(i.incorrectlyOpenedComment), this._createCommentToken(2), this.state = s.BOGUS_COMMENT, this._stateBogusComment(e));
1295
- }
1296
- // Comment start state
1297
- //------------------------------------------------------------------
1298
- _stateCommentStart(e) {
1299
- switch (e) {
1300
- case t.HYPHEN_MINUS: {
1301
- this.state = s.COMMENT_START_DASH;
1302
- break;
1303
- }
1304
- case t.GREATER_THAN_SIGN: {
1305
- this._err(i.abruptClosingOfEmptyComment), this.state = s.DATA;
1306
- const r = this.currentToken;
1307
- this.emitCurrentComment(r);
1308
- break;
1309
- }
1310
- default:
1311
- this.state = s.COMMENT, this._stateComment(e);
1312
- }
1313
- }
1314
- // Comment start dash state
1315
- //------------------------------------------------------------------
1316
- _stateCommentStartDash(e) {
1317
- const r = this.currentToken;
1318
- switch (e) {
1319
- case t.HYPHEN_MINUS: {
1320
- this.state = s.COMMENT_END;
1321
- break;
1322
- }
1323
- case t.GREATER_THAN_SIGN: {
1324
- this._err(i.abruptClosingOfEmptyComment), this.state = s.DATA, this.emitCurrentComment(r);
1325
- break;
1326
- }
1327
- case t.EOF: {
1328
- this._err(i.eofInComment), this.emitCurrentComment(r), this._emitEOFToken();
1329
- break;
1330
- }
1331
- default:
1332
- r.data += "-", this.state = s.COMMENT, this._stateComment(e);
1333
- }
1334
- }
1335
- // Comment state
1336
- //------------------------------------------------------------------
1337
- _stateComment(e) {
1338
- const r = this.currentToken;
1339
- switch (e) {
1340
- case t.HYPHEN_MINUS: {
1341
- this.state = s.COMMENT_END_DASH;
1342
- break;
1343
- }
1344
- case t.LESS_THAN_SIGN: {
1345
- r.data += "<", this.state = s.COMMENT_LESS_THAN_SIGN;
1346
- break;
1347
- }
1348
- case t.NULL: {
1349
- this._err(i.unexpectedNullCharacter), r.data += _;
1350
- break;
1351
- }
1352
- case t.EOF: {
1353
- this._err(i.eofInComment), this.emitCurrentComment(r), this._emitEOFToken();
1354
- break;
1355
- }
1356
- default:
1357
- r.data += String.fromCodePoint(e);
1358
- }
1359
- }
1360
- // Comment less-than sign state
1361
- //------------------------------------------------------------------
1362
- _stateCommentLessThanSign(e) {
1363
- const r = this.currentToken;
1364
- switch (e) {
1365
- case t.EXCLAMATION_MARK: {
1366
- r.data += "!", this.state = s.COMMENT_LESS_THAN_SIGN_BANG;
1367
- break;
1368
- }
1369
- case t.LESS_THAN_SIGN: {
1370
- r.data += "<";
1371
- break;
1372
- }
1373
- default:
1374
- this.state = s.COMMENT, this._stateComment(e);
1375
- }
1376
- }
1377
- // Comment less-than sign bang state
1378
- //------------------------------------------------------------------
1379
- _stateCommentLessThanSignBang(e) {
1380
- e === t.HYPHEN_MINUS ? this.state = s.COMMENT_LESS_THAN_SIGN_BANG_DASH : (this.state = s.COMMENT, this._stateComment(e));
1381
- }
1382
- // Comment less-than sign bang dash state
1383
- //------------------------------------------------------------------
1384
- _stateCommentLessThanSignBangDash(e) {
1385
- e === t.HYPHEN_MINUS ? this.state = s.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH : (this.state = s.COMMENT_END_DASH, this._stateCommentEndDash(e));
1386
- }
1387
- // Comment less-than sign bang dash dash state
1388
- //------------------------------------------------------------------
1389
- _stateCommentLessThanSignBangDashDash(e) {
1390
- e !== t.GREATER_THAN_SIGN && e !== t.EOF && this._err(i.nestedComment), this.state = s.COMMENT_END, this._stateCommentEnd(e);
1391
- }
1392
- // Comment end dash state
1393
- //------------------------------------------------------------------
1394
- _stateCommentEndDash(e) {
1395
- const r = this.currentToken;
1396
- switch (e) {
1397
- case t.HYPHEN_MINUS: {
1398
- this.state = s.COMMENT_END;
1399
- break;
1400
- }
1401
- case t.EOF: {
1402
- this._err(i.eofInComment), this.emitCurrentComment(r), this._emitEOFToken();
1403
- break;
1404
- }
1405
- default:
1406
- r.data += "-", this.state = s.COMMENT, this._stateComment(e);
1407
- }
1408
- }
1409
- // Comment end state
1410
- //------------------------------------------------------------------
1411
- _stateCommentEnd(e) {
1412
- const r = this.currentToken;
1413
- switch (e) {
1414
- case t.GREATER_THAN_SIGN: {
1415
- this.state = s.DATA, this.emitCurrentComment(r);
1416
- break;
1417
- }
1418
- case t.EXCLAMATION_MARK: {
1419
- this.state = s.COMMENT_END_BANG;
1420
- break;
1421
- }
1422
- case t.HYPHEN_MINUS: {
1423
- r.data += "-";
1424
- break;
1425
- }
1426
- case t.EOF: {
1427
- this._err(i.eofInComment), this.emitCurrentComment(r), this._emitEOFToken();
1428
- break;
1429
- }
1430
- default:
1431
- r.data += "--", this.state = s.COMMENT, this._stateComment(e);
1432
- }
1433
- }
1434
- // Comment end bang state
1435
- //------------------------------------------------------------------
1436
- _stateCommentEndBang(e) {
1437
- const r = this.currentToken;
1438
- switch (e) {
1439
- case t.HYPHEN_MINUS: {
1440
- r.data += "--!", this.state = s.COMMENT_END_DASH;
1441
- break;
1442
- }
1443
- case t.GREATER_THAN_SIGN: {
1444
- this._err(i.incorrectlyClosedComment), this.state = s.DATA, this.emitCurrentComment(r);
1445
- break;
1446
- }
1447
- case t.EOF: {
1448
- this._err(i.eofInComment), this.emitCurrentComment(r), this._emitEOFToken();
1449
- break;
1450
- }
1451
- default:
1452
- r.data += "--!", this.state = s.COMMENT, this._stateComment(e);
1453
- }
1454
- }
1455
- // DOCTYPE state
1456
- //------------------------------------------------------------------
1457
- _stateDoctype(e) {
1458
- switch (e) {
1459
- case t.SPACE:
1460
- case t.LINE_FEED:
1461
- case t.TABULATION:
1462
- case t.FORM_FEED: {
1463
- this.state = s.BEFORE_DOCTYPE_NAME;
1464
- break;
1465
- }
1466
- case t.GREATER_THAN_SIGN: {
1467
- this.state = s.BEFORE_DOCTYPE_NAME, this._stateBeforeDoctypeName(e);
1468
- break;
1469
- }
1470
- case t.EOF: {
1471
- this._err(i.eofInDoctype), this._createDoctypeToken(null);
1472
- const r = this.currentToken;
1473
- r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1474
- break;
1475
- }
1476
- default:
1477
- this._err(i.missingWhitespaceBeforeDoctypeName), this.state = s.BEFORE_DOCTYPE_NAME, this._stateBeforeDoctypeName(e);
1478
- }
1479
- }
1480
- // Before DOCTYPE name state
1481
- //------------------------------------------------------------------
1482
- _stateBeforeDoctypeName(e) {
1483
- if (o(e))
1484
- this._createDoctypeToken(String.fromCharCode(c(e))), this.state = s.DOCTYPE_NAME;
1485
- else
1486
- switch (e) {
1487
- case t.SPACE:
1488
- case t.LINE_FEED:
1489
- case t.TABULATION:
1490
- case t.FORM_FEED:
1491
- break;
1492
- case t.NULL: {
1493
- this._err(i.unexpectedNullCharacter), this._createDoctypeToken(_), this.state = s.DOCTYPE_NAME;
1494
- break;
1495
- }
1496
- case t.GREATER_THAN_SIGN: {
1497
- this._err(i.missingDoctypeName), this._createDoctypeToken(null);
1498
- const r = this.currentToken;
1499
- r.forceQuirks = !0, this.emitCurrentDoctype(r), this.state = s.DATA;
1500
- break;
1501
- }
1502
- case t.EOF: {
1503
- this._err(i.eofInDoctype), this._createDoctypeToken(null);
1504
- const r = this.currentToken;
1505
- r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1506
- break;
1507
- }
1508
- default:
1509
- this._createDoctypeToken(String.fromCodePoint(e)), this.state = s.DOCTYPE_NAME;
1510
- }
1511
- }
1512
- // DOCTYPE name state
1513
- //------------------------------------------------------------------
1514
- _stateDoctypeName(e) {
1515
- const r = this.currentToken;
1516
- switch (e) {
1517
- case t.SPACE:
1518
- case t.LINE_FEED:
1519
- case t.TABULATION:
1520
- case t.FORM_FEED: {
1521
- this.state = s.AFTER_DOCTYPE_NAME;
1522
- break;
1523
- }
1524
- case t.GREATER_THAN_SIGN: {
1525
- this.state = s.DATA, this.emitCurrentDoctype(r);
1526
- break;
1527
- }
1528
- case t.NULL: {
1529
- this._err(i.unexpectedNullCharacter), r.name += _;
1530
- break;
1531
- }
1532
- case t.EOF: {
1533
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1534
- break;
1535
- }
1536
- default:
1537
- r.name += String.fromCodePoint(o(e) ? c(e) : e);
1538
- }
1539
- }
1540
- // After DOCTYPE name state
1541
- //------------------------------------------------------------------
1542
- _stateAfterDoctypeName(e) {
1543
- const r = this.currentToken;
1544
- switch (e) {
1545
- case t.SPACE:
1546
- case t.LINE_FEED:
1547
- case t.TABULATION:
1548
- case t.FORM_FEED:
1549
- break;
1550
- case t.GREATER_THAN_SIGN: {
1551
- this.state = s.DATA, this.emitCurrentDoctype(r);
1552
- break;
1553
- }
1554
- case t.EOF: {
1555
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1556
- break;
1557
- }
1558
- default:
1559
- this._consumeSequenceIfMatch(T.PUBLIC, !1) ? this.state = s.AFTER_DOCTYPE_PUBLIC_KEYWORD : this._consumeSequenceIfMatch(T.SYSTEM, !1) ? this.state = s.AFTER_DOCTYPE_SYSTEM_KEYWORD : this._ensureHibernation() || (this._err(i.invalidCharacterSequenceAfterDoctypeName), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e));
1560
- }
1561
- }
1562
- // After DOCTYPE public keyword state
1563
- //------------------------------------------------------------------
1564
- _stateAfterDoctypePublicKeyword(e) {
1565
- const r = this.currentToken;
1566
- switch (e) {
1567
- case t.SPACE:
1568
- case t.LINE_FEED:
1569
- case t.TABULATION:
1570
- case t.FORM_FEED: {
1571
- this.state = s.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;
1572
- break;
1573
- }
1574
- case t.QUOTATION_MARK: {
1575
- this._err(i.missingWhitespaceAfterDoctypePublicKeyword), r.publicId = "", this.state = s.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
1576
- break;
1577
- }
1578
- case t.APOSTROPHE: {
1579
- this._err(i.missingWhitespaceAfterDoctypePublicKeyword), r.publicId = "", this.state = s.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
1580
- break;
1581
- }
1582
- case t.GREATER_THAN_SIGN: {
1583
- this._err(i.missingDoctypePublicIdentifier), r.forceQuirks = !0, this.state = s.DATA, this.emitCurrentDoctype(r);
1584
- break;
1585
- }
1586
- case t.EOF: {
1587
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1588
- break;
1589
- }
1590
- default:
1591
- this._err(i.missingQuoteBeforeDoctypePublicIdentifier), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1592
- }
1593
- }
1594
- // Before DOCTYPE public identifier state
1595
- //------------------------------------------------------------------
1596
- _stateBeforeDoctypePublicIdentifier(e) {
1597
- const r = this.currentToken;
1598
- switch (e) {
1599
- case t.SPACE:
1600
- case t.LINE_FEED:
1601
- case t.TABULATION:
1602
- case t.FORM_FEED:
1603
- break;
1604
- case t.QUOTATION_MARK: {
1605
- r.publicId = "", this.state = s.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
1606
- break;
1607
- }
1608
- case t.APOSTROPHE: {
1609
- r.publicId = "", this.state = s.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
1610
- break;
1611
- }
1612
- case t.GREATER_THAN_SIGN: {
1613
- this._err(i.missingDoctypePublicIdentifier), r.forceQuirks = !0, this.state = s.DATA, this.emitCurrentDoctype(r);
1614
- break;
1615
- }
1616
- case t.EOF: {
1617
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1618
- break;
1619
- }
1620
- default:
1621
- this._err(i.missingQuoteBeforeDoctypePublicIdentifier), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1622
- }
1623
- }
1624
- // DOCTYPE public identifier (double-quoted) state
1625
- //------------------------------------------------------------------
1626
- _stateDoctypePublicIdentifierDoubleQuoted(e) {
1627
- const r = this.currentToken;
1628
- switch (e) {
1629
- case t.QUOTATION_MARK: {
1630
- this.state = s.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
1631
- break;
1632
- }
1633
- case t.NULL: {
1634
- this._err(i.unexpectedNullCharacter), r.publicId += _;
1635
- break;
1636
- }
1637
- case t.GREATER_THAN_SIGN: {
1638
- this._err(i.abruptDoctypePublicIdentifier), r.forceQuirks = !0, this.emitCurrentDoctype(r), this.state = s.DATA;
1639
- break;
1640
- }
1641
- case t.EOF: {
1642
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1643
- break;
1644
- }
1645
- default:
1646
- r.publicId += String.fromCodePoint(e);
1647
- }
1648
- }
1649
- // DOCTYPE public identifier (single-quoted) state
1650
- //------------------------------------------------------------------
1651
- _stateDoctypePublicIdentifierSingleQuoted(e) {
1652
- const r = this.currentToken;
1653
- switch (e) {
1654
- case t.APOSTROPHE: {
1655
- this.state = s.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
1656
- break;
1657
- }
1658
- case t.NULL: {
1659
- this._err(i.unexpectedNullCharacter), r.publicId += _;
1660
- break;
1661
- }
1662
- case t.GREATER_THAN_SIGN: {
1663
- this._err(i.abruptDoctypePublicIdentifier), r.forceQuirks = !0, this.emitCurrentDoctype(r), this.state = s.DATA;
1664
- break;
1665
- }
1666
- case t.EOF: {
1667
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1668
- break;
1669
- }
1670
- default:
1671
- r.publicId += String.fromCodePoint(e);
1672
- }
1673
- }
1674
- // After DOCTYPE public identifier state
1675
- //------------------------------------------------------------------
1676
- _stateAfterDoctypePublicIdentifier(e) {
1677
- const r = this.currentToken;
1678
- switch (e) {
1679
- case t.SPACE:
1680
- case t.LINE_FEED:
1681
- case t.TABULATION:
1682
- case t.FORM_FEED: {
1683
- this.state = s.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;
1684
- break;
1685
- }
1686
- case t.GREATER_THAN_SIGN: {
1687
- this.state = s.DATA, this.emitCurrentDoctype(r);
1688
- break;
1689
- }
1690
- case t.QUOTATION_MARK: {
1691
- this._err(i.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers), r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
1692
- break;
1693
- }
1694
- case t.APOSTROPHE: {
1695
- this._err(i.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers), r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
1696
- break;
1697
- }
1698
- case t.EOF: {
1699
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1700
- break;
1701
- }
1702
- default:
1703
- this._err(i.missingQuoteBeforeDoctypeSystemIdentifier), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1704
- }
1705
- }
1706
- // Between DOCTYPE public and system identifiers state
1707
- //------------------------------------------------------------------
1708
- _stateBetweenDoctypePublicAndSystemIdentifiers(e) {
1709
- const r = this.currentToken;
1710
- switch (e) {
1711
- case t.SPACE:
1712
- case t.LINE_FEED:
1713
- case t.TABULATION:
1714
- case t.FORM_FEED:
1715
- break;
1716
- case t.GREATER_THAN_SIGN: {
1717
- this.emitCurrentDoctype(r), this.state = s.DATA;
1718
- break;
1719
- }
1720
- case t.QUOTATION_MARK: {
1721
- r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
1722
- break;
1723
- }
1724
- case t.APOSTROPHE: {
1725
- r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
1726
- break;
1727
- }
1728
- case t.EOF: {
1729
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1730
- break;
1731
- }
1732
- default:
1733
- this._err(i.missingQuoteBeforeDoctypeSystemIdentifier), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1734
- }
1735
- }
1736
- // After DOCTYPE system keyword state
1737
- //------------------------------------------------------------------
1738
- _stateAfterDoctypeSystemKeyword(e) {
1739
- const r = this.currentToken;
1740
- switch (e) {
1741
- case t.SPACE:
1742
- case t.LINE_FEED:
1743
- case t.TABULATION:
1744
- case t.FORM_FEED: {
1745
- this.state = s.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;
1746
- break;
1747
- }
1748
- case t.QUOTATION_MARK: {
1749
- this._err(i.missingWhitespaceAfterDoctypeSystemKeyword), r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
1750
- break;
1751
- }
1752
- case t.APOSTROPHE: {
1753
- this._err(i.missingWhitespaceAfterDoctypeSystemKeyword), r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
1754
- break;
1755
- }
1756
- case t.GREATER_THAN_SIGN: {
1757
- this._err(i.missingDoctypeSystemIdentifier), r.forceQuirks = !0, this.state = s.DATA, this.emitCurrentDoctype(r);
1758
- break;
1759
- }
1760
- case t.EOF: {
1761
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1762
- break;
1763
- }
1764
- default:
1765
- this._err(i.missingQuoteBeforeDoctypeSystemIdentifier), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1766
- }
1767
- }
1768
- // Before DOCTYPE system identifier state
1769
- //------------------------------------------------------------------
1770
- _stateBeforeDoctypeSystemIdentifier(e) {
1771
- const r = this.currentToken;
1772
- switch (e) {
1773
- case t.SPACE:
1774
- case t.LINE_FEED:
1775
- case t.TABULATION:
1776
- case t.FORM_FEED:
1777
- break;
1778
- case t.QUOTATION_MARK: {
1779
- r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
1780
- break;
1781
- }
1782
- case t.APOSTROPHE: {
1783
- r.systemId = "", this.state = s.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
1784
- break;
1785
- }
1786
- case t.GREATER_THAN_SIGN: {
1787
- this._err(i.missingDoctypeSystemIdentifier), r.forceQuirks = !0, this.state = s.DATA, this.emitCurrentDoctype(r);
1788
- break;
1789
- }
1790
- case t.EOF: {
1791
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1792
- break;
1793
- }
1794
- default:
1795
- this._err(i.missingQuoteBeforeDoctypeSystemIdentifier), r.forceQuirks = !0, this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1796
- }
1797
- }
1798
- // DOCTYPE system identifier (double-quoted) state
1799
- //------------------------------------------------------------------
1800
- _stateDoctypeSystemIdentifierDoubleQuoted(e) {
1801
- const r = this.currentToken;
1802
- switch (e) {
1803
- case t.QUOTATION_MARK: {
1804
- this.state = s.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
1805
- break;
1806
- }
1807
- case t.NULL: {
1808
- this._err(i.unexpectedNullCharacter), r.systemId += _;
1809
- break;
1810
- }
1811
- case t.GREATER_THAN_SIGN: {
1812
- this._err(i.abruptDoctypeSystemIdentifier), r.forceQuirks = !0, this.emitCurrentDoctype(r), this.state = s.DATA;
1813
- break;
1814
- }
1815
- case t.EOF: {
1816
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1817
- break;
1818
- }
1819
- default:
1820
- r.systemId += String.fromCodePoint(e);
1821
- }
1822
- }
1823
- // DOCTYPE system identifier (single-quoted) state
1824
- //------------------------------------------------------------------
1825
- _stateDoctypeSystemIdentifierSingleQuoted(e) {
1826
- const r = this.currentToken;
1827
- switch (e) {
1828
- case t.APOSTROPHE: {
1829
- this.state = s.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
1830
- break;
1831
- }
1832
- case t.NULL: {
1833
- this._err(i.unexpectedNullCharacter), r.systemId += _;
1834
- break;
1835
- }
1836
- case t.GREATER_THAN_SIGN: {
1837
- this._err(i.abruptDoctypeSystemIdentifier), r.forceQuirks = !0, this.emitCurrentDoctype(r), this.state = s.DATA;
1838
- break;
1839
- }
1840
- case t.EOF: {
1841
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1842
- break;
1843
- }
1844
- default:
1845
- r.systemId += String.fromCodePoint(e);
1846
- }
1847
- }
1848
- // After DOCTYPE system identifier state
1849
- //------------------------------------------------------------------
1850
- _stateAfterDoctypeSystemIdentifier(e) {
1851
- const r = this.currentToken;
1852
- switch (e) {
1853
- case t.SPACE:
1854
- case t.LINE_FEED:
1855
- case t.TABULATION:
1856
- case t.FORM_FEED:
1857
- break;
1858
- case t.GREATER_THAN_SIGN: {
1859
- this.emitCurrentDoctype(r), this.state = s.DATA;
1860
- break;
1861
- }
1862
- case t.EOF: {
1863
- this._err(i.eofInDoctype), r.forceQuirks = !0, this.emitCurrentDoctype(r), this._emitEOFToken();
1864
- break;
1865
- }
1866
- default:
1867
- this._err(i.unexpectedCharacterAfterDoctypeSystemIdentifier), this.state = s.BOGUS_DOCTYPE, this._stateBogusDoctype(e);
1868
- }
1869
- }
1870
- // Bogus DOCTYPE state
1871
- //------------------------------------------------------------------
1872
- _stateBogusDoctype(e) {
1873
- const r = this.currentToken;
1874
- switch (e) {
1875
- case t.GREATER_THAN_SIGN: {
1876
- this.emitCurrentDoctype(r), this.state = s.DATA;
1877
- break;
1878
- }
1879
- case t.NULL: {
1880
- this._err(i.unexpectedNullCharacter);
1881
- break;
1882
- }
1883
- case t.EOF: {
1884
- this.emitCurrentDoctype(r), this._emitEOFToken();
1885
- break;
1886
- }
1887
- }
1888
- }
1889
- // CDATA section state
1890
- //------------------------------------------------------------------
1891
- _stateCdataSection(e) {
1892
- switch (e) {
1893
- case t.RIGHT_SQUARE_BRACKET: {
1894
- this.state = s.CDATA_SECTION_BRACKET;
1895
- break;
1896
- }
1897
- case t.EOF: {
1898
- this._err(i.eofInCdata), this._emitEOFToken();
1899
- break;
1900
- }
1901
- default:
1902
- this._emitCodePoint(e);
1903
- }
1904
- }
1905
- // CDATA section bracket state
1906
- //------------------------------------------------------------------
1907
- _stateCdataSectionBracket(e) {
1908
- e === t.RIGHT_SQUARE_BRACKET ? this.state = s.CDATA_SECTION_END : (this._emitChars("]"), this.state = s.CDATA_SECTION, this._stateCdataSection(e));
1909
- }
1910
- // CDATA section end state
1911
- //------------------------------------------------------------------
1912
- _stateCdataSectionEnd(e) {
1913
- switch (e) {
1914
- case t.GREATER_THAN_SIGN: {
1915
- this.state = s.DATA;
1916
- break;
1917
- }
1918
- case t.RIGHT_SQUARE_BRACKET: {
1919
- this._emitChars("]");
1920
- break;
1921
- }
1922
- default:
1923
- this._emitChars("]]"), this.state = s.CDATA_SECTION, this._stateCdataSection(e);
1924
- }
1925
- }
1926
- // Character reference state
1927
- //------------------------------------------------------------------
1928
- _stateCharacterReference() {
1929
- let e = this.entityDecoder.write(this.preprocessor.html, this.preprocessor.pos);
1930
- if (e < 0)
1931
- if (this.preprocessor.lastChunkWritten)
1932
- e = this.entityDecoder.end();
1933
- else {
1934
- this.active = !1, this.preprocessor.pos = this.preprocessor.html.length - 1, this.consumedAfterSnapshot = 0, this.preprocessor.endOfChunkHit = !0;
1935
- return;
1936
- }
1937
- e === 0 ? (this.preprocessor.pos = this.entityStartPos, this._flushCodePointConsumedAsCharacterReference(t.AMPERSAND), this.state = !this._isCharacterReferenceInAttribute() && S(this.preprocessor.peek(1)) ? s.AMBIGUOUS_AMPERSAND : this.returnState) : this.state = this.returnState;
1938
- }
1939
- // Ambiguos ampersand state
1940
- //------------------------------------------------------------------
1941
- _stateAmbiguousAmpersand(e) {
1942
- S(e) ? this._flushCodePointConsumedAsCharacterReference(e) : (e === t.SEMICOLON && this._err(i.unknownNamedCharacterReference), this.state = this.returnState, this._callState(e));
1943
- }
1944
- }
1945
- export {
1946
- y as Tokenizer,
1947
- H as TokenizerMode
1948
- };