@rohal12/twee-ts 1.16.0 → 1.16.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-Bmpbelqj.js","names":["_exhaustive","parsePath","_exhaustive","_exhaustive","CharCodes","isTag","Text","Comment","CDATA","isTagRaw","CREATOR_NAME","CREATOR_NAME","_exhaustive","_exhaustive"],"sources":["../src/ifid.ts","../src/escape.ts","../src/passage.ts","../src/story.ts","../src/media-types.ts","../src/filesystem.ts","../src/source-text.ts","../src/util.ts","../src/formats.ts","../src/remote-formats.ts","../src/format-resolution.ts","../src/types.ts","../src/lexer.ts","../src/twee2-compat.ts","../src/parser.ts","../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode-codepoint.js","../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/decode-shared.js","../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/generated/decode-data-html.js","../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/generated/decode-data-xml.js","../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/bin-trie-flags.js","../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode.js","../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Tokenizer.js","../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Parser.js","../node_modules/.pnpm/domelementtype@3.0.0/node_modules/domelementtype/dist/index.js","../node_modules/.pnpm/domhandler@6.0.1/node_modules/domhandler/dist/node.js","../node_modules/.pnpm/domhandler@6.0.1/node_modules/domhandler/dist/index.js","../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/index.js","../src/html-parser.ts","../src/loader.ts","../src/version.ts","../src/output-twine2.ts","../src/output-twine1.ts","../src/output-twee.ts","../src/modules.ts","../src/start-passage.ts","../src/compiler.ts"],"sourcesContent":["/**\n * IFID (Interactive Fiction IDentifier) generation and validation.\n * Ported from ifid.go.\n */\nimport { randomUUID } from 'node:crypto';\nimport type { IFID } from './types.js';\n\n/** Generate a new IFID (UUID v4, uppercase). */\nexport function generateIFID(): IFID {\n return randomUUID().toUpperCase() as IFID;\n}\n\n/** Validate and brand an IFID string. Throws on invalid input. */\nexport function createIFID(value: string): IFID {\n const err = validateIFID(value);\n if (err) throw new Error(`Invalid IFID: ${err}`);\n return value.toUpperCase() as IFID;\n}\n\n/**\n * Validate an IFID string.\n * Accepts both bare UUIDs and UUID://...// wrapped format.\n * Returns null if valid, or an error message string.\n */\nexport function validateIFID(ifid: string): string | null {\n let uuid = ifid;\n\n switch (ifid.length) {\n case 36:\n break;\n case 45: {\n if (ifid.slice(0, 7).toUpperCase() !== 'UUID://' || ifid.slice(43) !== '//') {\n return 'invalid IFID UUID://...// format';\n }\n uuid = ifid.slice(7, 43);\n break;\n }\n default:\n return `invalid IFID length: ${ifid.length}`;\n }\n\n for (let i = 0; i < uuid.length; i++) {\n const ch = uuid[i]!;\n switch (i) {\n case 8:\n case 13:\n case 18:\n case 23:\n if (ch !== '-') {\n return `invalid IFID character '${ch}' at position ${i + 1}`;\n }\n break;\n case 14:\n if (ch < '1' || ch > '5') {\n return `invalid version '${ch}' at position ${i + 1}`;\n }\n break;\n case 19:\n if (!['8', '9', 'a', 'A', 'b', 'B'].includes(ch)) {\n return `invalid variant '${ch}' at position ${i + 1}`;\n }\n break;\n default:\n if (!/^[0-9a-fA-F]$/.test(ch)) {\n return `invalid IFID hex value '${ch}' at position ${i + 1}`;\n }\n break;\n }\n }\n\n return null;\n}\n","/**\n * HTML, attribute, tiddler, and twee escaping/unescaping utilities.\n * Ported from escaping.go.\n */\n\n/** Escape the minimum characters required for HTML attribute values. */\nexport function attrEscape(s: string): string {\n if (s.length === 0) return s;\n return s.replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/'/g, '&#39;');\n}\n\n/** Escape for HTML attribute values including < and > (for spec-compliant output). */\nexport function fullAttrEscape(s: string): string {\n if (s.length === 0) return s;\n return s\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n}\n\n/** Escape the minimum characters required for general HTML content. */\nexport function htmlEscape(s: string): string {\n if (s.length === 0) return s;\n return s\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n}\n\n/** Escape for Twine 1 tiddler format. */\nexport function tiddlerEscape(s: string): string {\n if (s.length === 0) return s;\n return s\n .replace(/\\\\/g, '\\\\s')\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/\\t/g, '\\\\t')\n .replace(/\\n/g, '\\\\n');\n}\n\n/** Unescape from Twine 1 tiddler format. */\nexport function tiddlerUnescape(s: string): string {\n if (s.length === 0) return s;\n return s.replace(/\\\\n/g, '\\n').replace(/\\\\t/g, '\\t').replace(/\\\\s/g, '\\\\');\n}\n\n/** Escape characters that are special in Twee passage names/tags. */\nexport function tweeEscape(s: string): string {\n if (s.length === 0) return s;\n return s.replace(/[\\\\[\\]{}]/g, (ch) => '\\\\' + ch);\n}\n\n/** Escape a string for safe inclusion in a JavaScript string literal. */\nexport function jsStringEscape(s: string): string {\n if (s.length === 0) return s;\n return s\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n .replace(/\\t/g, '\\\\t');\n}\n\n/** Sanitize a string for safe inclusion in a CSS or JS block comment. */\nexport function commentSanitize(s: string): string {\n return s.replace(/\\*\\//g, '* /');\n}\n\n/** Sanitize a string for safe inclusion in an HTML comment. */\nexport function htmlCommentSanitize(s: string): string {\n return s.replace(/-->/g, '-- >');\n}\n\n/**\n * Escape JavaScript for the content of an HTML `<script>` element, so that the HTML parser reads all of it as\n * the element's text and ends the element at the end tag written after it.\n *\n * - Every `</script` (in any letter case) becomes `<\\/script`. HTML ends a script element at the first\n * `</script` followed by whitespace, `/` or `>`, wherever it is in the JavaScript, even inside a string.\n * - Every `<!--` becomes `<\\!--`, but only if the text would otherwise end in the HTML tokenizer's \"script\n * data double escaped\" state: after a `<!--` and then a `<script` start tag with no `-->` between them, the\n * end tag after the text would not end the element.\n *\n * Inserting a backslash after `<` keeps the value of every string, template, and regular expression literal\n * and every comment where these sequences can be written (`\\/` and `\\!` are identity escapes; a backslash\n * already before the `<` escapes the `<`, as it did before); `<\\/script` is also how minifiers such as Terser\n * write inline scripts. It only changes code that uses them outside literals (`a </script/ b`, an HTML-like `<!--`\n * comment that is escaped because of a later `<script`), the raw text of a tagged template, and a `<!--` in a\n * regular expression with the `u` or `v` flag. The result is unchanged by escaping it again.\n */\nexport function scriptContentEscape(s: string): string {\n const escaped = s.replace(/<(?=\\/script)/gi, '<\\\\');\n return endsDoubleEscaped(escaped) ? escaped.replace(/<(?=!--)/g, '<\\\\') : escaped;\n}\n\n/**\n * Whether the HTML tokenizer, reading `s` as script element content with no `</script` in it, ends in the\n * \"script data double escaped\" state, where an end tag after `s` would not end the element.\n * See https://html.spec.whatwg.org/multipage/parsing.html#script-data-escaped-state.\n */\nfunction endsDoubleEscaped(s: string): boolean {\n const scriptStartTag = /<script[\\t\\n\\f\\r />]/gi;\n let pos = 0;\n for (;;) {\n // Script data: a `<!--` enters the escaped state.\n const open = s.indexOf('<!--', pos);\n if (open === -1) return false;\n // Escaped: a `-->` leaves it (the dashes of `<!--` count, so `<!-->` leaves at once); a `<script` start\n // tag enters the double escaped state.\n const escapedFrom = open + 2;\n const close = s.indexOf('-->', escapedFrom);\n scriptStartTag.lastIndex = escapedFrom;\n const start = scriptStartTag.exec(s);\n if (start === null || (close !== -1 && close < start.index)) {\n if (close === -1) return false;\n pos = close + 3;\n continue;\n }\n // Double escaped: only a `</script` (none are left) or a `-->` leaves it.\n const end = s.indexOf('-->', start.index + start[0].length);\n if (end === -1) return true;\n pos = end + 3;\n }\n}\n\n/**\n * Escape CSS for the content of an HTML `<style>` element: every `</style` (in any letter case) becomes\n * `<\\/style`, since HTML ends a style element at the first `</style` followed by whitespace, `/` or `>`.\n * `\\/` stands for `/` in CSS strings and URLs, and comments don't matter; `</style` anywhere else isn't valid\n * CSS anyway.\n */\nexport function styleContentEscape(s: string): string {\n return s.replace(/<(?=\\/style)/gi, '<\\\\');\n}\n\n/** Apply ROT13 encoding to a string (only affects [A-Za-z]). */\nexport function rot13(s: string): string {\n if (s.length === 0) return s;\n return s.replace(/[A-Za-z]/g, (ch) => {\n const base = ch <= 'Z' ? 65 : 97;\n return String.fromCharCode(((ch.charCodeAt(0) - base + 13) % 26) + base);\n });\n}\n\n/** Unescape backslash-escaped Twee characters. */\nexport function tweeUnescape(s: string): string {\n if (s.length === 0) return s;\n let result = '';\n for (let i = 0; i < s.length; i++) {\n if (s[i] === '\\\\') {\n i++;\n if (i >= s.length) {\n result += '\\\\';\n break;\n }\n }\n result += s[i];\n }\n return result;\n}\n","/**\n * Passage helpers and output methods.\n * Ported from passage.go / passagedata.go.\n */\nimport type { Passage, PassageMetadata, OutputMode, WordCountMethod } from './types.js';\nimport { attrEscape, fullAttrEscape, htmlEscape, tiddlerEscape, tweeEscape, rot13, commentSanitize } from './escape.js';\n\n// Info passages contain structural data, metadata, and code rather than story content.\nconst INFO_PASSAGE_NAMES = new Set([\n 'StoryAuthor',\n 'StoryInit',\n 'StoryMenu',\n 'StorySubtitle',\n 'StoryTitle',\n 'PassageReady',\n 'PassageDone',\n 'PassageHeader',\n 'PassageFooter',\n 'StoryBanner',\n 'StoryCaption',\n 'MenuOptions',\n 'MenuShare',\n 'MenuStory',\n 'StoryInterface',\n 'StoryShare',\n 'StorySettings',\n 'StoryData',\n 'StoryIncludes',\n]);\n\nconst INFO_TAGS = ['annotation', 'script', 'stylesheet', 'widget'];\n\nexport function hasTag(p: Passage, tag: string): boolean {\n return p.tags.includes(tag);\n}\n\nexport function hasAnyTag(p: Passage, ...tags: string[]): boolean {\n return p.tags.some((t) => tags.includes(t));\n}\n\nexport function hasTagStartingWith(p: Passage, prefix: string): boolean {\n return p.tags.some((t) => t.startsWith(prefix));\n}\n\nexport function hasInfoTags(p: Passage): boolean {\n return hasAnyTag(p, ...INFO_TAGS) || hasTagStartingWith(p, 'Twine.');\n}\n\nexport function hasInfoName(p: Passage): boolean {\n return INFO_PASSAGE_NAMES.has(p.name);\n}\n\nexport function isInfoPassage(p: Passage): boolean {\n return hasInfoName(p) || hasInfoTags(p);\n}\n\nexport function isStoryPassage(p: Passage): boolean {\n return !hasInfoName(p) && !hasInfoTags(p);\n}\n\nexport function hasMetadataPosition(p: Passage): boolean {\n return p.metadata != null && p.metadata.position != null && p.metadata.position !== '';\n}\n\nexport function hasMetadataSize(p: Passage): boolean {\n return p.metadata != null && p.metadata.size != null && p.metadata.size !== '';\n}\n\nexport function hasAnyMetadata(p: Passage): boolean {\n if (!p.metadata) return false;\n return Object.values(p.metadata).some((v) => v != null && v !== '');\n}\n\nexport function marshalMetadata(meta: PassageMetadata): string {\n const obj: Record<string, string> = {};\n for (const [key, value] of Object.entries(meta)) {\n if (typeof value === 'string' && value) obj[key] = value;\n }\n return JSON.stringify(obj);\n}\n\nexport function unmarshalMetadata(json: string): PassageMetadata {\n const raw: unknown = JSON.parse(json);\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n return {};\n }\n const parsed = raw as Record<string, unknown>;\n const meta: PassageMetadata = {};\n for (const [key, value] of Object.entries(parsed)) {\n if (typeof value === 'string') meta[key] = value;\n }\n return meta;\n}\n\n/** Convert passage to Twee source. */\nexport function passageToTwee(p: Passage, outMode: OutputMode): string {\n let output: string;\n if (outMode === 'twee3') {\n output = ':: ' + tweeEscape(p.name);\n if (p.tags.length > 0) {\n output += ' [' + tweeEscape(p.tags.join(' ')) + ']';\n }\n if (hasAnyMetadata(p) && p.metadata) {\n output += ' ' + marshalMetadata(p.metadata);\n }\n } else {\n output = ':: ' + p.name;\n if (p.tags.length > 0) {\n output += ' [' + p.tags.join(' ') + ']';\n }\n }\n output += '\\n';\n if (p.text.length > 0) {\n output += p.text + '\\n';\n }\n output += '\\n\\n';\n return output;\n}\n\n/** Generate `<tw-passagedata>` HTML for Twine 2. */\nexport function passageToPassagedata(p: Passage, pid: number, options?: { readonly sourceInfo?: boolean }): string {\n let position: string;\n let size: string;\n\n if (hasMetadataPosition(p)) {\n position = p.metadata?.position ?? '';\n } else {\n const x = pid % 10;\n const y = Math.floor(pid / 10);\n const xp = x === 0 ? 10 : x;\n const yp = x === 0 ? y : y + 1;\n position = `${xp * 125 - 25},${yp * 125 - 25}`;\n }\n\n if (hasMetadataSize(p)) {\n size = p.metadata?.size ?? '';\n } else {\n size = '100,100';\n }\n\n let attrs = `<tw-passagedata pid=\"${pid}\" name=${quote(fullAttrEscape(p.name))} tags=${quote(attrEscape(p.tags.join(' ')))} position=${quote(attrEscape(position))} size=${quote(attrEscape(size))}`;\n if (options?.sourceInfo && p.source) {\n attrs += ` data-source-file=${quote(attrEscape(p.source.file))} data-source-line=\"${p.source.line}\"`;\n }\n return `${attrs}>${htmlEscape(p.text)}</tw-passagedata>`;\n}\n\n/** Generate `<div tiddler>` HTML for Twine 1. */\nexport function passageToTiddler(p: Passage, pid: number, obfuscateRot13 = false): string {\n let position: string;\n\n if (hasMetadataPosition(p)) {\n position = p.metadata?.position ?? '';\n } else {\n const x = pid % 10;\n const y = Math.floor(pid / 10);\n const xp = x === 0 ? 10 : x;\n const yp = x === 0 ? y : y + 1;\n position = `${xp * 140 - 130},${yp * 140 - 130}`;\n }\n\n const created = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 12);\n const content = obfuscateRot13 && p.name !== 'StorySettings' ? tiddlerEscape(rot13(p.text)) : tiddlerEscape(p.text);\n const nameComment = obfuscateRot13 ? `<!-- ${commentSanitize(p.name)} -->` : '';\n return `<div tiddler=${quote(attrEscape(p.name))} tags=${quote(attrEscape(p.tags.join(' ')))} created=${quote(created)} modifier=${quote('twee')} twine-position=${quote(attrEscape(position))}>${nameComment}${content}</div>`;\n}\n\n/**\n * Count words in a passage.\n *\n * - `'tweego'` (default): Strip newlines, strip comments, count NFKD-normalized characters, divide by 5.\n * - `'whitespace'`: Strip comments and markup, split on whitespace, count tokens.\n */\nexport function countWords(p: Passage, method: WordCountMethod = 'tweego'): number {\n switch (method) {\n case 'tweego': {\n let text = p.text;\n text = text.replace(/\\n/g, '');\n text = text.replace(/(?:\\/%.+?%\\/|\\/\\*.+?\\*\\/|<!--.+?-->)/gs, '');\n const normalized = text.normalize('NFKD');\n const count = [...normalized].length;\n if (count === 0) return 0;\n const words = Math.floor(count / 5);\n return count % 5 > 0 ? words + 1 : words;\n }\n case 'whitespace': {\n let text = p.text;\n // Strip comments\n text = text.replace(/(?:\\/%.+?%\\/|\\/\\*.+?\\*\\/|<!--.+?-->)/gs, '');\n // Strip Twine macros <<...>>\n text = text.replace(/<<[^>]*>>/g, '');\n // Strip Twine links [[...]] — keep display text\n text = text.replace(/\\[\\[([^\\]|]*?)(?:\\|[^\\]]*?)?\\]\\]/g, '$1');\n // Strip HTML tags\n text = text.replace(/<[^>]+>/g, '');\n const tokens = text.split(/\\s+/).filter((t) => t.length > 0);\n return tokens.length;\n }\n default: {\n const _exhaustive: never = method;\n throw new Error(`Unhandled word count method: ${_exhaustive as string}`);\n }\n }\n}\n\n/**\n * Apply tag aliases: for each passage carrying an alias tag, add the canonical\n * tag if not already present. Returns new passage objects where tags changed;\n * unchanged passages are returned as-is. Idempotent — safe to call multiple times.\n */\nexport function applyTagAliases(passages: readonly Passage[], aliases: Record<string, string>): Passage[] {\n const entries = Object.entries(aliases);\n if (entries.length === 0) return [...passages];\n return passages.map((p) => {\n const original = p.tags;\n const added: string[] = [];\n for (const [alias, canonical] of entries) {\n if (original.includes(alias) && !original.includes(canonical) && !added.includes(canonical)) {\n added.push(canonical);\n }\n }\n return added.length > 0 ? { ...p, tags: [...original, ...added] } : p;\n });\n}\n\nfunction quote(s: string): string {\n return `\"${s}\"`;\n}\n","/**\n * Story model + StoryData JSON marshal/unmarshal.\n * Ported from story.go + storydata.go.\n */\nimport type { Story, ReadonlyStory, Passage, Diagnostic, WordCountMethod, IFID } from './types.js';\nimport { validateIFID } from './ifid.js';\nimport { isStoryPassage, countWords } from './passage.js';\n\n/** Module-level index: maps passage names to their array indices for O(1) lookups. */\nconst passageIndex = new WeakMap<Story, Map<string, number>>();\n\nfunction getIndex(story: Story): Map<string, number> {\n let index = passageIndex.get(story);\n if (!index) {\n // Rebuild for stories not created via createStory() (e.g., tests, external code)\n index = new Map();\n for (let i = 0; i < story.passages.length; i++) {\n const passage = story.passages[i];\n if (passage) index.set(passage.name, i);\n }\n passageIndex.set(story, index);\n }\n return index;\n}\n\nexport function createStory(): Story {\n const story: Story = {\n name: '',\n ifid: '' as IFID,\n passages: [],\n legacyIFID: '' as IFID,\n twine1: { settings: new Map() },\n twine2: {\n format: '',\n formatVersion: '',\n options: new Map(),\n start: '',\n tags: '',\n tagColors: new Map(),\n zoom: 1,\n },\n };\n passageIndex.set(story, new Map());\n return story;\n}\n\nexport function storyHas(story: Story, name: string): boolean {\n return getIndex(story).has(name);\n}\n\nexport function storyIndex(story: Story, name: string): number {\n return getIndex(story).get(name) ?? -1;\n}\n\nexport function storyGet(story: Story, name: string): Passage | undefined {\n const i = storyIndex(story, name);\n return i === -1 ? undefined : story.passages[i];\n}\n\nexport function storyAppend(story: Story, p: Passage, diagnostics: Diagnostic[]): void {\n const index = getIndex(story);\n const i = index.get(p.name) ?? -1;\n if (i === -1) {\n index.set(p.name, story.passages.length);\n story.passages.push(p);\n } else {\n diagnostics.push({\n level: 'warning',\n message: `Replacing existing passage \"${p.name}\" with duplicate.`,\n });\n story.passages[i] = p;\n }\n}\n\nexport function storyPrepend(story: Story, p: Passage, diagnostics: Diagnostic[]): void {\n const index = getIndex(story);\n const i = index.get(p.name) ?? -1;\n if (i === -1) {\n story.passages.unshift(p);\n // Rebuild index: unshift shifts all existing indices by 1\n index.clear();\n for (let j = 0; j < story.passages.length; j++) {\n const passage = story.passages[j];\n if (passage) index.set(passage.name, j);\n }\n } else {\n diagnostics.push({\n level: 'warning',\n message: `Replacing existing passage \"${p.name}\" with duplicate.`,\n });\n story.passages[i] = p;\n }\n}\n\n// --- StoryData JSON ---\n\ninterface StoryDataJSON {\n ifid?: string;\n format?: string;\n 'format-version'?: string;\n options?: string[];\n start?: string;\n tags?: string;\n 'tag-colors'?: Record<string, string>;\n zoom?: number;\n}\n\nexport function marshalStoryData(story: Story): string {\n const data: StoryDataJSON = {};\n if (story.ifid) data.ifid = story.ifid;\n if (story.twine2.format) data.format = story.twine2.format;\n if (story.twine2.formatVersion) data['format-version'] = story.twine2.formatVersion;\n\n const options: string[] = [];\n for (const [opt, val] of story.twine2.options) {\n if (val) options.push(opt);\n }\n if (options.length > 0) data.options = options;\n\n if (story.twine2.start) data.start = story.twine2.start;\n if (story.twine2.tags) data.tags = story.twine2.tags;\n\n if (story.twine2.tagColors.size > 0) {\n data['tag-colors'] = Object.fromEntries(story.twine2.tagColors);\n }\n if (story.twine2.zoom !== 1) data.zoom = story.twine2.zoom;\n\n return JSON.stringify(data, null, '\\t');\n}\n\nexport function unmarshalStoryData(story: Story, json: string): string | null {\n let raw: unknown;\n try {\n raw = JSON.parse(json) as unknown;\n } catch (e) {\n return `Cannot unmarshal \"StoryData\"; ${e instanceof Error ? e.message : String(e)}`;\n }\n\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n return 'Cannot unmarshal \"StoryData\"; expected a JSON object';\n }\n const data = raw as StoryDataJSON;\n\n if (typeof data.ifid === 'string' && data.ifid) story.ifid = data.ifid.toUpperCase() as IFID;\n if (typeof data.format === 'string' && data.format) story.twine2.format = data.format;\n if (typeof data['format-version'] === 'string' && data['format-version'])\n story.twine2.formatVersion = data['format-version'];\n if (Array.isArray(data.options)) {\n for (const opt of data.options) {\n if (typeof opt === 'string') story.twine2.options.set(opt, true);\n }\n }\n if (typeof data.start === 'string' && data.start) story.twine2.start = data.start;\n if (typeof data.tags === 'string') story.twine2.tags = data.tags;\n if (typeof data['tag-colors'] === 'object' && data['tag-colors'] !== null && !Array.isArray(data['tag-colors'])) {\n for (const [tag, color] of Object.entries(data['tag-colors'])) {\n if (typeof color === 'string') story.twine2.tagColors.set(tag, color);\n }\n }\n if (typeof data.zoom === 'number' && data.zoom !== 0) story.twine2.zoom = data.zoom;\n\n return null;\n}\n\n// --- StorySettings (legacy) ---\n\nexport function unmarshalStorySettings(story: Story, text: string, diagnostics: Diagnostic[]): void {\n const obsolete: string[] = [];\n\n for (const rawLine of text.split('\\n')) {\n const line = rawLine.trim();\n if (line.length === 0) continue;\n\n const colonIdx = line.indexOf(':');\n if (colonIdx === -1) {\n diagnostics.push({\n level: 'warning',\n message: `Malformed \"StorySettings\" entry; skipping \"${line}\".`,\n });\n continue;\n }\n\n const key = line.slice(0, colonIdx).trim().toLowerCase();\n const val = line\n .slice(colonIdx + 1)\n .trim()\n .toLowerCase();\n\n switch (key) {\n case 'ifid': {\n const err = validateIFID(val);\n if (err === null) {\n story.legacyIFID = val.toUpperCase() as IFID;\n }\n obsolete.push('\"ifid\"');\n continue;\n }\n case 'zoom':\n obsolete.push('\"zoom\"');\n continue;\n }\n\n story.twine1.settings.set(key, val);\n }\n\n if (obsolete.length > 0) {\n const entries = obsolete.length === 1 ? 'entry' : 'entries';\n const pronoun = obsolete.length === 1 ? 'it' : 'them';\n diagnostics.push({\n level: 'warning',\n message:\n `Detected obsolete \"StorySettings\" ${entries}: ${obsolete.join(', ')}. ` +\n `Please remove ${pronoun} from the \"StorySettings\" special passage.`,\n });\n }\n}\n\n/**\n * Process a passage and add it to the story, handling special passages.\n * Creates new passage objects where text is modified rather than mutating the input.\n */\nexport function storyAdd(story: Story, p: Passage, diagnostics: Diagnostic[]): void {\n let processed = p;\n\n switch (p.name) {\n case 'StoryIncludes':\n diagnostics.push({\n level: 'warning',\n message:\n 'Ignoring \"StoryIncludes\" compiler special passage; twee-ts allows you to specify project files and/or directories to recursively search.',\n });\n break;\n\n case 'StoryData': {\n const err = unmarshalStoryData(story, p.text);\n if (err === null) {\n // Validate the IFID if present.\n if (story.ifid.length > 0) {\n const vErr = validateIFID(story.ifid);\n if (vErr !== null) {\n diagnostics.push({\n level: 'error',\n message: `Cannot validate IFID; ${vErr}.`,\n });\n }\n }\n // Rebuild passage contents to normalize.\n processed = { ...p, text: marshalStoryData(story) };\n } else {\n diagnostics.push({\n level: 'warning',\n message: `Cannot unmarshal \"StoryData\" compiler special passage; ${err}.`,\n });\n }\n break;\n }\n\n case 'StorySettings':\n unmarshalStorySettings(story, p.text, diagnostics);\n break;\n\n case 'StoryTitle': {\n const trimmed = p.text.trim();\n processed = { ...p, text: trimmed };\n story.name = trimmed;\n break;\n }\n }\n\n storyAppend(story, processed, diagnostics);\n}\n\n/** Get story passage count and word count stats. */\nexport function getStoryStats(\n story: Story,\n wordCountMethod: WordCountMethod = 'tweego',\n): { passages: number; storyPassages: number; words: number } {\n let storyPassages = 0;\n let words = 0;\n for (const p of story.passages) {\n if (isStoryPassage(p)) {\n storyPassages++;\n words += countWords(p, wordCountMethod);\n }\n }\n return { passages: story.passages.length, storyPassages, words };\n}\n\n/**\n * Builder that separates the mutable construction phase from the immutable consumption phase.\n * During construction, the internal `Story` is mutable via `add()` and direct access.\n * After `build()`, the story is returned as `ReadonlyStory`.\n */\nexport class StoryBuilder {\n /** The mutable story, accessible during construction for loader functions. */\n readonly story: Story;\n\n constructor() {\n this.story = createStory();\n }\n\n /** Add a passage, handling special passages (StoryData, StoryTitle, etc.). */\n add(passage: Passage, diagnostics: Diagnostic[]): void {\n storyAdd(this.story, passage, diagnostics);\n }\n\n /** Check if a passage name exists. */\n has(name: string): boolean {\n return storyHas(this.story, name);\n }\n\n /** Finalize and return the story as read-only. */\n build(): ReadonlyStory {\n return this.story;\n }\n}\n","/**\n * Extension → MIME type mapping.\n * Ported from util.go:mediaTypeFromExt().\n */\n\nimport { extname } from 'node:path';\n\nconst MEDIA_TYPE_MAP: Record<string, string> = {\n // Audio\n aac: 'audio/aac',\n flac: 'audio/flac',\n ogg: 'audio/ogg',\n wav: 'audio/wav',\n mp3: 'audio/mpeg',\n m4a: 'audio/mp4',\n oga: 'audio/ogg',\n opus: 'audio/ogg',\n wave: 'audio/wav',\n weba: 'audio/webm',\n\n // Fonts\n otf: 'font/otf',\n ttf: 'font/ttf',\n woff: 'font/woff',\n woff2: 'font/woff2',\n\n // Images\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n jpg: 'image/jpeg',\n png: 'image/png',\n svg: 'image/svg+xml',\n tif: 'image/tiff',\n tiff: 'image/tiff',\n webp: 'image/webp',\n\n // Metadata\n vtt: 'text/vtt',\n\n // Video\n mp4: 'video/mp4',\n ogv: 'video/ogg',\n webm: 'video/webm',\n};\n\nexport function mediaTypeFromExt(ext: string): string {\n return MEDIA_TYPE_MAP[ext] ?? 'application/octet-stream';\n}\n\nexport function mediaTypeFromFilename(filename: string): string {\n return mediaTypeFromExt(normalizedFileExt(filename));\n}\n\nexport function normalizedFileExt(filename: string): string {\n const ext = extname(filename);\n if (!ext) return '';\n return ext.slice(1).toLowerCase();\n}\n\n/** Slugify a string for safe use as a DOM ID. */\nexport function slugify(original: string): string {\n return original.replace(/[\\x00-\\x20!-/:-@[-^`{-\\x9f]+/g, '_');\n}\n\n/** Check if a file has a known type that should be processed. */\nexport function isKnownFileType(filename: string): boolean {\n const ext = normalizedFileExt(filename);\n return KNOWN_EXTENSIONS.has(ext);\n}\n\nconst KNOWN_EXTENSIONS = new Set([\n 'tw',\n 'twee',\n 'tw2',\n 'twee2',\n 'htm',\n 'html',\n 'css',\n 'js',\n 'otf',\n 'ttf',\n 'woff',\n 'woff2',\n 'gif',\n 'jpeg',\n 'jpg',\n 'png',\n 'svg',\n 'tif',\n 'tiff',\n 'webp',\n 'aac',\n 'flac',\n 'm4a',\n 'mp3',\n 'oga',\n 'ogg',\n 'opus',\n 'wav',\n 'wave',\n 'weba',\n 'mp4',\n 'ogv',\n 'webm',\n 'vtt',\n]);\n\n/** Font format hint for @font-face. */\nexport function fontFormatHint(ext: string): string {\n switch (ext) {\n case 'ttf':\n return 'truetype';\n case 'otf':\n return 'opentype';\n default:\n return ext;\n }\n}\n","/**\n * File system utilities: path walking, file type detection, watch mode.\n * Ported from filesystem.go.\n */\nimport { readdirSync, statSync, watch as fsWatch } from 'node:fs';\nimport * as nodePath from 'node:path';\nimport { dirname, resolve, relative, join, sep } from 'node:path';\nimport { isKnownFileType } from './media-types.js';\nimport type { Diagnostic } from './types.js';\n\n/**\n * Whether `filename` matches one of the `exclude` globs. The globs are matched\n * against the file's path relative to the working directory, the path\n * getFilenames reports; an absolute `filename` is made relative first. A leading\n * `./` in a glob is dropped. Matching is Node's `path.matchesGlob`.\n */\nexport function isExcluded(filename: string, exclude: readonly string[]): boolean {\n if (exclude.length === 0) return false;\n // Read from the namespace, not imported by name: path.matchesGlob arrived in\n // Node 22.5, and a named import would stop this module loading on 22.0-22.4.\n const { matchesGlob } = nodePath;\n if (typeof matchesGlob !== 'function') {\n throw new Error(`The exclude option needs Node.js 22.5 or newer (found ${process.version}).`);\n }\n const rel = relative(process.cwd(), resolve(filename)) || filename;\n return exclude.some((pattern) => matchesGlob(rel, pattern.replace(/^\\.\\//, '')));\n}\n\nexport interface FilenamesResult {\n readonly filenames: string[];\n /** One warning per path that could not be read. */\n readonly diagnostics: Diagnostic[];\n}\n\n/**\n * Recursively walk directories, collecting regular file paths.\n * Filters out the output file to prevent circular compilation, and the files\n * that match an `exclude` glob (see isExcluded).\n * Like Tweego, a path that cannot be read is reported as a warning and skipped.\n */\nexport function getFilenames(\n pathnames: string[],\n outFilename?: string,\n exclude: readonly string[] = [],\n): FilenamesResult {\n const filenames: string[] = [];\n const diagnostics: Diagnostic[] = [];\n const absOutFile = outFilename ? resolve(outFilename) : '';\n\n function warn(pathname: string, e: unknown): void {\n diagnostics.push({ level: 'warning', message: `path ${pathname}: ${e instanceof Error ? e.message : String(e)}` });\n }\n\n function walk(pathname: string): void {\n let stat;\n try {\n stat = statSync(pathname);\n } catch (e) {\n warn(pathname, e);\n return;\n }\n\n if (stat.isFile()) {\n const abs = resolve(pathname);\n if (abs === absOutFile) return;\n const rel = relative(process.cwd(), abs);\n if (isExcluded(rel || abs, exclude)) return;\n filenames.push(rel || abs);\n } else if (stat.isDirectory()) {\n let entries;\n try {\n entries = readdirSync(pathname);\n } catch (e) {\n warn(pathname, e);\n return;\n }\n for (const entry of entries) {\n walk(join(pathname, entry));\n }\n }\n }\n\n for (const pathname of pathnames) {\n walk(pathname);\n }\n\n return { filenames, diagnostics };\n}\n\nexport interface WatchHandle {\n close(): void;\n}\n\n/** Whether the absolute path `file` is the absolute path `dir` or inside it. */\nfunction isInsideDir(file: string, dir: string): boolean {\n return file === dir || file.startsWith(dir.endsWith(sep) ? dir : dir + sep);\n}\n\n/**\n * The watched paths split into folders (as given) and files (absolute). A path\n * that cannot be read counts as a folder, which fs.watch then fails to watch.\n */\nfunction splitWatchRoots(pathnames: readonly string[]): { dirs: string[]; files: Set<string> } {\n const dirs: string[] = [];\n const files = new Set<string>();\n for (const pathname of pathnames) {\n let isFile = false;\n try {\n isFile = statSync(pathname).isFile();\n } catch {\n // Unreadable: left to fs.watch, as a folder.\n }\n if (isFile) files.add(resolve(pathname));\n else dirs.push(pathname);\n }\n return { dirs, files };\n}\n\n/**\n * Watch paths for changes, calling the build callback on known file type changes.\n * A folder is watched recursively; a file is watched on its own and counts\n * whatever its type (a head file, say). A change to a file `ignore` returns true\n * for (given the path relative to the working directory) schedules no build.\n * Uses debouncing to avoid rapid rebuilds.\n */\nexport function watchFilesystem(\n pathnames: string[],\n outFilename: string,\n callback: (changedFiles?: ReadonlySet<string>) => void,\n ignore: (filename: string) => boolean = () => false,\n): WatchHandle {\n const absOutFile = resolve(outFilename);\n const watchers: ReturnType<typeof fsWatch>[] = [];\n let buildTimer: ReturnType<typeof setTimeout> | null = null;\n const BUILD_DEBOUNCE = 500;\n const pendingFiles = new Set<string>();\n\n function scheduleBuild(changedFile?: string): void {\n if (changedFile) pendingFiles.add(changedFile);\n if (buildTimer) clearTimeout(buildTimer);\n buildTimer = setTimeout(() => {\n buildTimer = null;\n const files = pendingFiles.size > 0 ? new Set(pendingFiles) : undefined;\n pendingFiles.clear();\n callback(files);\n }, BUILD_DEBOUNCE);\n }\n\n // A changed file, as an absolute path. `named`: it is one of the watched paths\n // itself, so it counts whatever its type. Reported relative to the working\n // directory, the form getFilenames gives and the incremental cache is keyed by.\n function fileChanged(abs: string, named: boolean): void {\n if (abs === absOutFile) return;\n if (!named && !isKnownFileType(abs)) return;\n const rel = relative(process.cwd(), abs);\n if (!ignore(rel || abs)) scheduleBuild(rel || abs);\n }\n\n function watchPath(pathname: string, recursive: boolean, listener: (filename: string) => void): void {\n try {\n watchers.push(\n fsWatch(pathname, { recursive }, (_event, filename) => {\n if (filename) listener(filename);\n }),\n );\n } catch {\n // Ignore inaccessible paths\n }\n }\n\n const { dirs, files } = splitWatchRoots(pathnames);\n const absDirs = dirs.map((dir) => resolve(dir));\n for (const dir of dirs) {\n watchPath(dir, true, (filename) => {\n const abs = resolve(dir, filename);\n fileChanged(abs, files.has(abs));\n });\n }\n\n // A file is watched through its folder, not on its own: the OS reports only the\n // file's name for a watch on the file, and an editor that saves by replacing the\n // file would leave such a watch on the old one. A file inside a watched folder is\n // seen by that folder's watcher.\n const fileDirs = new Set(\n [...files].filter((file) => !absDirs.some((dir) => isInsideDir(file, dir))).map((file) => dirname(file)),\n );\n for (const dir of fileDirs) {\n watchPath(dir, false, (filename) => {\n const abs = resolve(dir, filename);\n if (files.has(abs)) fileChanged(abs, true);\n });\n }\n\n // Build once initially (no changedFiles = full build).\n callback();\n\n return {\n close() {\n if (buildTimer) clearTimeout(buildTimer);\n for (const w of watchers) w.close();\n },\n };\n}\n","/**\n * Source text normalization shared by every input path (files, in-memory sources, `parseTwee`).\n */\n\n/**\n * Strip a leading UTF-8 byte order mark and convert CRLF and bare CR line endings to LF.\n * Idempotent, so text that is already normalized passes through unchanged.\n */\nexport function normalizeSourceText(text: string): string {\n const withoutBOM = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;\n return withoutBOM.replace(/\\r\\n?/g, '\\n');\n}\n","/**\n * Shared file I/O utilities.\n */\nimport { readFileSync } from 'node:fs';\nimport { parse as parsePath } from 'node:path';\nimport { normalizeSourceText } from './source-text.js';\n\n/** Read a file as UTF-8 with BOM stripping and line ending normalization. */\nexport function readUTF8(filename: string): string {\n return normalizeSourceText(readFileSync(filename, 'utf-8'));\n}\n\n/** Read a file as base64. */\nexport function readBase64(filename: string): string {\n return readFileSync(filename).toString('base64');\n}\n\n/** Get the filename without extension, falling back to the full basename for dotfiles. */\nexport function baseNameWithoutExt(filename: string): string {\n const { name, ext } = parsePath(filename);\n return name || ext;\n}\n","/**\n * Story format discovery, loading, and SemVer matching.\n * Ported from formats.go + config.go.\n */\nimport { readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { homedir } from 'node:os';\nimport type { FormatRequest, StoryFormatInfo, Twine2FormatJSON } from './types.js';\nimport { readUTF8 } from './util.js';\n\n/**\n * Attempt to fix non-strict JSON (trailing commas, single quotes, unquoted keys).\n */\nfunction relaxedJSONParse(json: string): unknown {\n // First try standard parse\n try {\n return JSON.parse(json);\n } catch {\n // fall through to relaxed parsing\n }\n\n let fixed = json;\n\n // Replace single-quoted string values with double-quoted\n // Match single-quoted strings: 'value' -> \"value\"\n fixed = fixed.replace(/'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'/g, '\"$1\"');\n\n // Add quotes around unquoted property names\n // Match word chars before a colon that aren't already quoted\n fixed = fixed.replace(/(?<=^|[{,]\\s*)([A-Za-z_$][A-Za-z0-9_$]*)\\s*:/gm, '\"$1\":');\n\n // Remove trailing commas before } or ]\n fixed = fixed.replace(/,\\s*([}\\]])/g, '$1');\n\n return JSON.parse(fixed);\n}\n\n/** A `\"setup\": function` property, which Harlowe appends to its otherwise-JSON format object. */\nconst SETUP_FUNCTION_PROPERTY = /,\\s*\"setup\"\\s*:\\s*function\\b/g;\n\n/** Drop a trailing `\"setup\": function(){…}` property from a format object, if it has one. */\nfunction stripSetupFunction(chunk: string): string | undefined {\n let lastIndex = -1;\n for (const match of chunk.matchAll(SETUP_FUNCTION_PROPERTY)) lastIndex = match.index;\n return lastIndex === -1 ? undefined : chunk.slice(0, lastIndex) + '}';\n}\n\n/**\n * Parse the Twine 2 format.js JSON chunk.\n * Handles Harlowe's malformed JSON by stripping the \"setup\" function property. The workaround\n * keys on the property itself, so the same bytes parse whether they come from a `harlowe-3`\n * directory or a direct download.\n * Per spec, the name key is Optional.\n *\n * @param _formatId No longer used; kept so existing callers keep compiling.\n */\nexport function parseFormatJSON(source: string, _formatId?: string): Twine2FormatJSON | null {\n const first = source.indexOf('{');\n const last = source.lastIndexOf('}');\n if (first === -1 || last === -1) return null;\n\n const chunk = source.slice(first, last + 1);\n\n const parse = (json: string): Twine2FormatJSON | null => {\n const raw: unknown = relaxedJSONParse(json);\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) return null;\n const obj = raw as Record<string, unknown>;\n // version and source are required; name is optional per spec\n if (typeof obj.version !== 'string' || typeof obj.source !== 'string') return null;\n // Validate version is semver\n if (!parseSemver(obj.version)) return null;\n const name = typeof obj.name === 'string' ? obj.name : 'Untitled Story Format';\n const result: Twine2FormatJSON = {\n name,\n version: obj.version,\n source: obj.source,\n proofing: obj.proofing === true,\n };\n if (typeof obj.author === 'string') result.author = obj.author;\n if (typeof obj.description === 'string') result.description = obj.description;\n if (typeof obj.image === 'string') result.image = obj.image;\n if (typeof obj.url === 'string') result.url = obj.url;\n if (typeof obj.license === 'string') result.license = obj.license;\n return result;\n };\n\n try {\n return parse(chunk);\n } catch {\n // Harlowe workaround: strip the \"setup\" function property\n const stripped = stripSetupFunction(chunk);\n if (stripped === undefined) return null;\n try {\n return parse(stripped);\n } catch {\n return null;\n }\n }\n}\n\n/**\n * Discover all story formats in the given search directories.\n * Implements SemVer-based version pruning: within each (name, major) group,\n * only the highest minor.patch survives.\n */\nexport function discoverFormats(searchDirs: string[]): Map<string, StoryFormatInfo> {\n const formats = new Map<string, StoryFormatInfo>();\n const baseFilenames = ['format.js', 'header.html'];\n\n for (const searchDir of searchDirs) {\n try {\n const stat = statSync(searchDir);\n if (!stat.isDirectory()) continue;\n } catch {\n continue;\n }\n\n let entries;\n try {\n entries = readdirSync(searchDir);\n } catch {\n continue;\n }\n\n for (const entry of entries) {\n const formatDir = join(searchDir, entry);\n try {\n if (!statSync(formatDir).isDirectory()) continue;\n } catch {\n continue;\n }\n\n for (const baseFilename of baseFilenames) {\n const formatFilename = join(formatDir, baseFilename);\n try {\n const stat = statSync(formatFilename);\n if (!stat.isFile()) continue;\n } catch {\n continue;\n }\n\n const isTwine2 = baseFilename === 'format.js';\n const format: StoryFormatInfo = {\n id: entry,\n filename: formatFilename,\n isTwine2,\n name: '',\n version: '',\n proofing: false,\n };\n\n if (isTwine2) {\n try {\n const source = readUTF8(formatFilename);\n const data = parseFormatJSON(source, entry);\n if (!data) continue;\n format.name = data.name;\n format.version = data.version;\n format.proofing = data.proofing ?? false;\n if (data.author) format.author = data.author;\n if (data.description) format.description = data.description;\n if (data.image) format.image = data.image;\n if (data.url) format.url = data.url;\n if (data.license) format.license = data.license;\n } catch {\n continue;\n }\n } else {\n // Twine 1 format: use folder name as default name\n format.name = entry;\n }\n\n formats.set(entry, format);\n break; // Found format file for this directory\n }\n }\n }\n\n // SemVer pruning: for formats with the same name, within each major version\n // keep only the highest minor.patch. Also, same name+version from different\n // directories: keep the first one found.\n pruneFormats(formats);\n\n return formats;\n}\n\n/**\n * Prune formats by SemVer: within each (name, major) group,\n * keep only the highest version. First-found wins for same name+version.\n */\nfunction pruneFormats(formats: Map<string, StoryFormatInfo>): void {\n // Group by (name, major) -> best entry\n const bestByNameMajor = new Map<string, { id: string; version: [number, number, number] }>();\n // Track seen name+version combos (first wins)\n const seenNameVersion = new Set<string>();\n\n for (const [id, f] of formats) {\n if (!f.isTwine2 || !f.name || !f.version) continue;\n const v = parseSemver(f.version);\n if (!v) continue;\n\n const nameVersionKey = `${f.name}@${f.version}`;\n if (seenNameVersion.has(nameVersionKey)) {\n // Duplicate name+version: remove the later one\n formats.delete(id);\n continue;\n }\n seenNameVersion.add(nameVersionKey);\n\n const groupKey = `${f.name}@${v[0]}`;\n const existing = bestByNameMajor.get(groupKey);\n if (!existing || semverCompare(v, existing.version) > 0) {\n bestByNameMajor.set(groupKey, { id, version: v });\n }\n }\n\n // Remove all non-best entries within each group\n for (const [id, f] of [...formats]) {\n if (!f.isTwine2 || !f.name || !f.version) continue;\n const v = parseSemver(f.version);\n if (!v) continue;\n\n const groupKey = `${f.name}@${v[0]}`;\n const best = bestByNameMajor.get(groupKey);\n if (best && best.id !== id) {\n formats.delete(id);\n }\n }\n}\n\n/**\n * Get the default format search directories.\n */\nexport function getFormatSearchDirs(extraPaths: string[] = [], useTweegoPath = true): string[] {\n const subdirNames = ['storyformats', '.storyformats', 'story-formats', 'storyFormats', 'targets'];\n const basePaths = new Set<string>();\n\n // Home directory\n try {\n basePaths.add(homedir());\n } catch {\n // ignore\n }\n\n // Working directory\n basePaths.add(process.cwd());\n\n const dirs: string[] = [];\n for (const base of basePaths) {\n for (const sub of subdirNames) {\n const dir = join(base, sub);\n try {\n if (statSync(dir).isDirectory()) {\n dirs.push(dir);\n }\n } catch {\n // skip\n }\n }\n }\n\n // Extra user-provided paths\n dirs.push(...extraPaths);\n\n // TWEEGO_PATH environment variable\n if (useTweegoPath) {\n const tweegoPath = process.env.TWEEGO_PATH;\n if (tweegoPath) {\n dirs.push(...tweegoPath.split(process.platform === 'win32' ? ';' : ':'));\n }\n }\n\n return dirs;\n}\n\n/** Parse a simple semver string into [major, minor, patch]. */\nexport function parseSemver(v: string): [number, number, number] | null {\n const m = /^(\\d+)\\.(\\d+)\\.(\\d+)/.exec(v);\n if (!m) return null;\n return [Number(m[1]), Number(m[2]), Number(m[3])];\n}\n\nexport function semverCompare(a: [number, number, number], b: [number, number, number]): number {\n const [aMajor, aMinor, aPatch] = a;\n const [bMajor, bMinor, bPatch] = b;\n if (aMajor !== bMajor) return aMajor - bMajor;\n if (aMinor !== bMinor) return aMinor - bMinor;\n if (aPatch !== bPatch) return aPatch - bPatch;\n return 0;\n}\n\n/** Build a directory-style format ID from a name and version, e.g. ('SugarCube', '2.37.3') → 'sugarcube-2'. */\nexport function makeFormatId(name: string, version: string): string {\n const major = parseSemver(version)?.[0] ?? 0;\n return `${name.toLowerCase().replace(/\\s+/g, '-')}-${major}`;\n}\n\n/** Describe a format request for diagnostics. */\nexport function describeFormatRequest(request: FormatRequest): string {\n switch (request.kind) {\n case 'id':\n return `\"${request.id}\"`;\n case 'name':\n return request.version ? `\"${request.name}\" at version \"${request.version}\"` : `\"${request.name}\"`;\n default: {\n const _exhaustive: never = request;\n throw new Error(`unhandled format request: ${JSON.stringify(_exhaustive)}`);\n }\n }\n}\n\n/** Options for {@link selectFormatCandidate}. */\nexport interface SelectFormatOptions {\n /** For a name request, also accept a version older than the one asked for (same major only). */\n readonly allowOlder?: boolean;\n}\n\n/**\n * Pick the candidate that best answers a format request.\n *\n * - An ID request ('sugarcube-2') matches a candidate whose name and major version build that ID,\n * and takes the greatest such version.\n * - A name request matches the name case-insensitively. An exact version wins outright; otherwise\n * the greatest version with the same major that is not older than the one asked for (or, with\n * `allowOlder`, the greatest same-major version). An unparseable requested version takes the\n * greatest version of any major.\n */\nexport function selectFormatCandidate<T>(\n request: FormatRequest,\n candidates: readonly T[],\n describe: (candidate: T) => { readonly name: string; readonly version: string },\n options: SelectFormatOptions = {},\n): T | undefined {\n const allowOlder = options.allowOlder ?? false;\n const wanted = request.kind === 'name' ? parseSemver(request.version) : null;\n let best: { readonly candidate: T; readonly version: [number, number, number] } | undefined;\n\n for (const candidate of candidates) {\n const { name, version } = describe(candidate);\n const have = parseSemver(version);\n if (!have) continue;\n\n if (request.kind === 'id') {\n if (makeFormatId(name, version) !== request.id.toLowerCase()) continue;\n } else {\n if (name.toLowerCase() !== request.name.toLowerCase()) continue;\n if (wanted) {\n if (semverCompare(have, wanted) === 0) return candidate;\n if (have[0] !== wanted[0]) continue;\n if (!allowOlder && semverCompare(have, wanted) < 0) continue;\n }\n }\n\n if (!best || semverCompare(have, best.version) > 0) best = { candidate, version: have };\n }\n\n return best?.candidate;\n}\n\n/** Get format ID from Twine 2 name, picking the greatest version. */\nexport function getFormatIdByName(formats: Map<string, StoryFormatInfo>, name: string): string | undefined {\n let bestVersion: [number, number, number] | null = null;\n let bestId: string | undefined;\n\n for (const [id, f] of formats) {\n if (!f.isTwine2 || f.name !== name) continue;\n const v = parseSemver(f.version);\n if (!v) continue;\n if (!bestVersion || semverCompare(v, bestVersion) > 0) {\n bestVersion = v;\n bestId = id;\n }\n }\n\n return bestId;\n}\n\n/** Get format ID from Twine 2 name and version, using SemVer major matching. */\nexport function getFormatIdByNameAndVersion(\n formats: Map<string, StoryFormatInfo>,\n name: string,\n version: string,\n): string | undefined {\n const wanted = parseSemver(version);\n let bestVersion: [number, number, number] | null = null;\n let bestId: string | undefined;\n\n for (const [id, f] of formats) {\n if (!f.isTwine2 || f.name !== name) continue;\n const have = parseSemver(f.version);\n if (!have) continue;\n\n if (wanted === null || (have[0] === wanted[0] && semverCompare(have, wanted) >= 0)) {\n if (!bestVersion || semverCompare(have, bestVersion) > 0) {\n bestVersion = have;\n bestId = id;\n }\n }\n }\n\n return bestId;\n}\n\n/** Read the story format source (for Twine 2, extract the `source` property from JSON). */\nexport function readFormatSource(format: StoryFormatInfo): string {\n const source = readUTF8(format.filename);\n if (format.isTwine2) {\n const data = parseFormatJSON(source, format.id);\n if (!data) throw new Error(`Cannot parse format ${format.id} JSON`);\n return data.source;\n }\n return source;\n}\n\n/** Read a file as UTF-8 (re-exported for loader use). */\nexport { readUTF8 as readFileUTF8 } from './util.js';\n","/**\n * Remote story format fetching, caching, and checksum verification.\n * Uses the Story Formats Archive (SFA) as the default source.\n */\nimport { mkdirSync, readFileSync, writeFileSync, existsSync, readdirSync, statSync, rmSync, lstatSync } from 'node:fs';\nimport { isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport { homedir } from 'node:os';\nimport type { FormatRequest, SFAIndex, SFAIndexEntry, StoryFormatInfo } from './types.js';\nimport { parseSemver, parseFormatJSON, makeFormatId, selectFormatCandidate } from './formats.js';\nimport type { SelectFormatOptions } from './formats.js';\n\nconst DEFAULT_SFA_INDICES = [\n 'https://videlais.github.io/story-formats-archive/official/index.json',\n 'https://videlais.github.io/story-formats-archive/unofficial/index.json',\n];\n\n/** Get the cache directory for downloaded story formats. */\nexport function getCacheDir(): string {\n const xdg = process.env['XDG_CACHE_HOME'];\n const base = xdg || join(homedir(), '.cache');\n return join(base, 'twee-ts', 'storyformats');\n}\n\n/**\n * Whether a string can serve as one directory name inside the cache: not empty, not `.` or `..`,\n * and free of path separators. Format names and versions come from downloaded metadata, so they\n * are untrusted path input.\n */\nfunction isSafeSegment(segment: string): boolean {\n return segment !== '' && segment !== '.' && segment !== '..' && !/[/\\\\\\0]/.test(segment);\n}\n\n/** Whether absolute path `target` lies strictly inside absolute path `root`. */\nfunction isInside(root: string, target: string): boolean {\n const rel = relative(root, target);\n return rel !== '' && !isAbsolute(rel) && rel.split(sep)[0] !== '..';\n}\n\n/** The cache directory for one format version. Throws when the name or version could leave the cache. */\nfunction cachedFormatDir(name: string, version: string): string {\n if (!isSafeSegment(name)) {\n throw new Error(`Refusing to cache a story format with an unsafe name: ${JSON.stringify(name)}`);\n }\n if (!isSafeSegment(version) || !parseSemver(version)) {\n throw new Error(`Refusing to cache story format \"${name}\" with an unsafe version: ${JSON.stringify(version)}`);\n }\n const root = resolve(getCacheDir());\n const dir = resolve(root, name, version);\n if (!isInside(root, dir)) {\n throw new Error(`Refusing to cache a story format outside the cache directory ${root}: ${dir}`);\n }\n return dir;\n}\n\n/** Create `dir` as a plain directory, or check that it already is one (a symlink could lead out of the cache). */\nfunction ensurePlainDirectory(dir: string): void {\n const stat = lstatSync(dir, { throwIfNoEntry: false });\n if (stat === undefined) {\n mkdirSync(dir);\n return;\n }\n if (stat.isSymbolicLink() || !stat.isDirectory()) {\n throw new Error(`Refusing to write a story format outside the cache directory: ${dir} is not a plain directory`);\n }\n}\n\n/** Write a downloaded format.js to `<cache>/<name>/<version>/format.js` and return its path. */\nfunction writeCachedFormat(name: string, version: string, text: string): string {\n const dir = cachedFormatDir(name, version);\n const root = resolve(getCacheDir());\n mkdirSync(root, { recursive: true });\n ensurePlainDirectory(join(root, name));\n ensurePlainDirectory(dir);\n\n const formatPath = join(dir, 'format.js');\n if (lstatSync(formatPath, { throwIfNoEntry: false })?.isSymbolicLink()) {\n throw new Error(`Refusing to write a story format outside the cache directory: ${formatPath} is a symlink`);\n }\n writeFileSync(formatPath, text, 'utf-8');\n return formatPath;\n}\n\n/** In-memory index cache, keyed by URL. Cleared each compile. */\nconst indexCache = new Map<string, SFAIndex>();\n\n/** Clear the in-memory index cache. */\nexport function clearIndexCache(): void {\n indexCache.clear();\n}\n\n/** Validate that a JSON value is a valid SFAIndexEntry. */\nfunction isValidEntry(val: unknown): val is SFAIndexEntry {\n if (typeof val !== 'object' || val === null || Array.isArray(val)) return false;\n const obj = val as Record<string, unknown>;\n return (\n typeof obj.name === 'string' &&\n typeof obj.version === 'string' &&\n typeof obj.checksums === 'object' &&\n obj.checksums !== null &&\n !Array.isArray(obj.checksums)\n );\n}\n\n/** Validate that a JSON value conforms to the SFAIndex shape. */\nfunction validateSFAIndex(json: unknown): SFAIndex {\n if (typeof json !== 'object' || json === null) {\n throw new Error('SFA index is not an object');\n }\n const obj = json as Record<string, unknown>;\n const twine1 = Array.isArray(obj['twine1']) ? (obj['twine1'] as unknown[]).filter(isValidEntry) : [];\n const twine2 = Array.isArray(obj['twine2']) ? (obj['twine2'] as unknown[]).filter(isValidEntry) : [];\n return { twine1, twine2 };\n}\n\n/** Fetch and parse an SFA index.json, with in-memory caching. */\nexport async function fetchIndex(url: string): Promise<SFAIndex> {\n const cached = indexCache.get(url);\n if (cached) return cached;\n\n const res = await fetch(url);\n if (!res.ok) {\n throw new Error(`Failed to fetch format index from ${url}: ${res.status} ${res.statusText}`);\n }\n const data = validateSFAIndex(await res.json());\n indexCache.set(url, data);\n return data;\n}\n\ninterface FindEntryResult {\n entry: SFAIndexEntry;\n formatType: 'twine1' | 'twine2';\n}\n\n/**\n * Find the best matching entry in an SFA index.\n * Exact version preferred, then highest version with same major.\n */\nexport function findEntry(index: SFAIndex, name: string, version: string): FindEntryResult | undefined {\n return findEntryForRequest(index, { kind: 'name', name, version });\n}\n\n/** Find the best matching entry in an SFA index for a name or ID request (twine2 entries first). */\nfunction findEntryForRequest(index: SFAIndex, request: FormatRequest): FindEntryResult | undefined {\n const candidates: FindEntryResult[] = [\n ...(index.twine2 ?? []).map((entry) => ({ entry, formatType: 'twine2' as const })),\n ...(index.twine1 ?? []).map((entry) => ({ entry, formatType: 'twine1' as const })),\n ];\n return selectFormatCandidate(request, candidates, (c) => c.entry);\n}\n\n/** Verify SHA-256 checksum using Web Crypto API (Node 22 built-in). */\nexport async function verifySHA256(content: Uint8Array<ArrayBuffer>, expectedHex: string): Promise<boolean> {\n const digest = await crypto.subtle.digest('SHA-256', content);\n const hex = Array.from(new Uint8Array(digest))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hex === expectedHex.toLowerCase();\n}\n\n/** Derive the download URL for a format.js from the index URL and entry. */\nfunction getDownloadUrl(indexUrl: string, entry: SFAIndexEntry, formatType: 'twine1' | 'twine2'): string {\n const base = indexUrl.replace(/\\/index\\.json$/, '');\n return `${base}/${formatType}/${entry.name}/${entry.version}/format.js`;\n}\n\n/** Download a format, verify its checksum, write to cache, and return StoryFormatInfo. */\nexport async function fetchAndCacheFormat(entry: SFAIndexEntry, downloadUrl: string): Promise<StoryFormatInfo> {\n // Index metadata is untrusted: reject a name or version that would leave the cache before downloading.\n cachedFormatDir(entry.name, entry.version);\n\n const res = await fetch(downloadUrl);\n if (!res.ok) {\n throw new Error(`Failed to download format from ${downloadUrl}: ${res.status} ${res.statusText}`);\n }\n const text = await res.text();\n\n // Verify checksum if available\n const checksumKey = Object.keys(entry.checksums ?? {}).find((k) => k.endsWith('format.js'));\n if (checksumKey) {\n const expected = entry.checksums[checksumKey];\n if (!expected) throw new Error(`Missing checksum value for key \"${checksumKey}\"`);\n const encoder = new TextEncoder();\n const valid = await verifySHA256(encoder.encode(text), expected);\n if (!valid) {\n throw new Error(`Checksum verification failed for ${entry.name} ${entry.version}`);\n }\n }\n\n // Parse format JSON to extract name/version/source\n const id = makeFormatId(entry.name, entry.version);\n const data = parseFormatJSON(text, id);\n if (!data) {\n throw new Error(`Failed to parse format JSON from ${downloadUrl}`);\n }\n\n const formatPath = writeCachedFormat(entry.name, entry.version, text);\n\n return {\n id,\n filename: formatPath,\n isTwine2: true,\n name: data.name,\n version: data.version,\n proofing: data.proofing ?? false,\n };\n}\n\n/** Download a direct format.js URL, parse its JSON, cache it, and return StoryFormatInfo. */\nexport async function fetchDirectFormat(url: string): Promise<StoryFormatInfo> {\n const res = await fetch(url);\n if (!res.ok) {\n throw new Error(`Failed to download format from ${url}: ${res.status} ${res.statusText}`);\n }\n const text = await res.text();\n\n const data = parseFormatJSON(text);\n if (!data) {\n throw new Error(`Failed to parse format JSON from ${url}`);\n }\n\n const id = makeFormatId(data.name, data.version);\n const formatPath = writeCachedFormat(data.name, data.version, text);\n\n return {\n id,\n filename: formatPath,\n isTwine2: true,\n name: data.name,\n version: data.version,\n proofing: data.proofing ?? false,\n };\n}\n\n/**\n * Try to resolve a remote story format by name and version.\n * 0. Use an exactly matching cached download, without touching the network\n * 1. Try direct format URLs\n * 2. Try custom index URLs\n * 3. Try default SFA indices\n * 4. Fall back to a compatible cached download (e.g. when offline)\n */\nexport async function resolveRemoteFormat(\n name: string,\n version: string,\n indices?: string[],\n urls?: string[],\n): Promise<StoryFormatInfo | undefined> {\n return resolveRemoteFormatRequest({ kind: 'name', name, version }, indices, urls);\n}\n\n/**\n * Resolve a story format request remotely, in the same order as {@link resolveRemoteFormat}.\n * An ID request such as 'sugarcube-2' matches the format whose name and major version build that ID\n * (SugarCube 2.x), taking the greatest version available.\n */\nexport async function resolveRemoteFormatRequest(\n request: FormatRequest,\n indices?: string[],\n urls?: string[],\n): Promise<StoryFormatInfo | undefined> {\n let lastError: Error | undefined;\n\n // 0. An exact version already downloaded needs no network access.\n const cached = findCachedFormat(request);\n if (cached && request.kind === 'name' && isExactVersion(cached.version, request.version)) return cached;\n\n // 1. Try direct URLs — use the first that answers the request\n for (const url of urls ?? []) {\n try {\n const info = await fetchDirectFormat(url);\n if (selectFormatCandidate(request, [info], (f) => f)) return info;\n } catch (e) {\n lastError = e instanceof Error ? e : new Error(String(e));\n }\n }\n\n // 2. Try custom indices, then default SFA indices\n const allIndices = [...(indices ?? []), ...DEFAULT_SFA_INDICES];\n for (const indexUrl of allIndices) {\n try {\n const index = await fetchIndex(indexUrl);\n const result = findEntryForRequest(index, request);\n if (result) {\n // Check cache first\n const hit = getCachedFormat(result.entry.name, result.entry.version);\n if (hit) return hit;\n\n const downloadUrl = getDownloadUrl(indexUrl, result.entry, result.formatType);\n return await fetchAndCacheFormat(result.entry, downloadUrl);\n }\n } catch (e) {\n lastError = e instanceof Error ? e : new Error(String(e));\n }\n }\n\n // 3. No source had it (or none could be reached): a compatible cached download still answers the request.\n if (cached) return cached;\n\n // If all sources failed with errors, propagate the last one\n if (lastError) throw lastError;\n return undefined;\n}\n\n/** Whether two version strings name the same SemVer version. */\nfunction isExactVersion(have: string, wanted: string): boolean {\n const a = parseSemver(have);\n const b = parseSemver(wanted);\n return a !== null && b !== null && a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Find the cached download that best answers a format request, without network access.\n * Matching follows {@link selectFormatCandidate}.\n */\nexport function findCachedFormat(\n request: FormatRequest,\n options: SelectFormatOptions = {},\n): StoryFormatInfo | undefined {\n return selectFormatCandidate(request, [...discoverCachedFormats().values()], (f) => f, options);\n}\n\n/** Check if a format is already in the local cache. */\nfunction getCachedFormat(name: string, version: string): StoryFormatInfo | undefined {\n if (!isSafeSegment(name) || !isSafeSegment(version)) return undefined;\n const formatPath = join(getCacheDir(), name, version, 'format.js');\n try {\n if (!existsSync(formatPath)) return undefined;\n const source = readFileSync(formatPath, 'utf-8');\n const id = makeFormatId(name, version);\n const data = parseFormatJSON(source, id);\n if (!data) return undefined;\n return {\n id,\n filename: formatPath,\n isTwine2: true,\n name: data.name,\n version: data.version,\n proofing: data.proofing ?? false,\n };\n } catch {\n return undefined;\n }\n}\n\n/** Discover all cached remote formats. Returns a Map like discoverFormats(). */\nexport function discoverCachedFormats(): Map<string, StoryFormatInfo> {\n const formats = new Map<string, StoryFormatInfo>();\n const cacheDir = getCacheDir();\n\n try {\n if (!existsSync(cacheDir)) return formats;\n } catch {\n return formats;\n }\n\n let names: string[];\n try {\n names = readdirSync(cacheDir);\n } catch {\n return formats;\n }\n\n for (const name of names) {\n const nameDir = join(cacheDir, name);\n try {\n if (!statSync(nameDir).isDirectory()) continue;\n } catch {\n continue;\n }\n\n let versions: string[];\n try {\n versions = readdirSync(nameDir);\n } catch {\n continue;\n }\n\n for (const version of versions) {\n const info = getCachedFormat(name, version);\n if (info) {\n formats.set(`${info.id}-${version}`, info);\n }\n }\n }\n\n return formats;\n}\n\n/** Info about a cached format entry with size and modification date. */\nexport interface CachedFormatEntry {\n readonly name: string;\n readonly version: string;\n readonly sizeBytes: number;\n readonly modifiedAt: Date;\n}\n\n/** List all cached formats with size and modification date. */\nexport function listCachedFormats(): readonly CachedFormatEntry[] {\n const cacheDir = getCacheDir();\n const entries: CachedFormatEntry[] = [];\n\n try {\n if (!existsSync(cacheDir)) return entries;\n } catch {\n return entries;\n }\n\n let names: string[];\n try {\n names = readdirSync(cacheDir);\n } catch {\n return entries;\n }\n\n for (const name of names) {\n const nameDir = join(cacheDir, name);\n try {\n if (!statSync(nameDir).isDirectory()) continue;\n } catch {\n continue;\n }\n\n let versions: string[];\n try {\n versions = readdirSync(nameDir);\n } catch {\n continue;\n }\n\n for (const version of versions) {\n const formatPath = join(nameDir, version, 'format.js');\n try {\n const stat = statSync(formatPath);\n entries.push({\n name,\n version,\n sizeBytes: stat.size,\n modifiedAt: stat.mtime,\n });\n } catch {\n // Skip entries without a valid format.js\n }\n }\n }\n\n return entries;\n}\n\n/**\n * Clear all cached formats, or only those matching a given name. Returns the number of entries removed.\n * A name must be a single cache entry name (as `listCachedFormats()` reports it); anything with a\n * path separator or `.`/`..` throws instead of deleting outside the format's own directory.\n */\nexport function clearCachedFormats(name?: string): number {\n if (name && !isSafeSegment(name)) {\n throw new Error(\n `Refusing to clear ${JSON.stringify(name)}: it is not a cached format name. Use a name as \"cache list\" shows it.`,\n );\n }\n\n const cacheDir = getCacheDir();\n if (!existsSync(cacheDir)) return 0;\n\n if (!name) {\n const entries = listCachedFormats();\n const count = entries.length;\n rmSync(cacheDir, { recursive: true, force: true });\n return count;\n }\n\n const root = resolve(cacheDir);\n const nameDir = resolve(root, name);\n if (!isInside(root, nameDir)) {\n throw new Error(`Refusing to clear ${JSON.stringify(name)}: it is not a cached format name.`);\n }\n // lstat, so a symlinked entry is never followed out of the cache: only plain directories are entries.\n if (!lstatSync(nameDir, { throwIfNoEntry: false })?.isDirectory()) return 0;\n\n let versions: string[];\n try {\n versions = readdirSync(nameDir);\n } catch {\n return 0;\n }\n const count = versions.length;\n rmSync(nameDir, { recursive: true, force: true });\n return count;\n}\n\n/** Get total cache size in bytes and format count. */\nexport function getCacheSize(): { totalBytes: number; count: number } {\n const entries = listCachedFormats();\n const totalBytes = entries.reduce((sum, e) => sum + e.sizeBytes, 0);\n return { totalBytes, count: entries.length };\n}\n","/**\n * Story format selection for a compile.\n *\n * The request comes from the explicit `formatId` option, else the StoryData format name and\n * version, else the default ID. That one request is then looked up in the local format\n * directories, the download cache, and (unless disabled) remote sources. A request that none of\n * them can answer is reported as an error rather than swapped for a different story format.\n */\nimport type { Diagnostic, FormatRequest, StoryFormatInfo } from './types.js';\nimport {\n describeFormatRequest,\n discoverFormats,\n getFormatIdByNameAndVersion,\n getFormatSearchDirs,\n selectFormatCandidate,\n} from './formats.js';\nimport { findCachedFormat, resolveRemoteFormatRequest } from './remote-formats.js';\n\n/** Where to look for story formats. */\nexport interface FormatResolutionOptions {\n readonly formatPaths?: string[];\n readonly useTweegoPath?: boolean;\n readonly noRemote?: boolean;\n readonly formatIndices?: string[];\n readonly formatUrls?: string[];\n}\n\n/** Choose the format request: explicit format ID > StoryData format > default ID. */\nexport function formatRequestFor(\n formatId: string | undefined,\n storyFormat: string,\n storyFormatVersion: string,\n defaultId: string,\n): FormatRequest {\n if (formatId) return { kind: 'id', id: formatId };\n if (storyFormat) return { kind: 'name', name: storyFormat, version: storyFormatVersion };\n return { kind: 'id', id: defaultId };\n}\n\n/** Look a request up among the formats found in local format directories. */\nfunction findLocalFormat(formats: Map<string, StoryFormatInfo>, request: FormatRequest): StoryFormatInfo | undefined {\n switch (request.kind) {\n case 'id':\n return formats.get(request.id);\n case 'name': {\n const id = getFormatIdByNameAndVersion(formats, request.name, request.version);\n return id === undefined ? undefined : formats.get(id);\n }\n default: {\n const _exhaustive: never = request;\n throw new Error(`unhandled format request: ${JSON.stringify(_exhaustive)}`);\n }\n }\n}\n\n/**\n * Resolve a format request to a story format.\n *\n * Order: local format directories, then the download cache, then remote sources (unless\n * `noRemote`). When a StoryData request names a version that none of them has, an older version of\n * the same format and major version is used with a warning. Anything else is an error diagnostic,\n * and the result is `undefined`.\n */\nexport async function resolveStoryFormat(\n request: FormatRequest,\n options: FormatResolutionOptions,\n diagnostics: Diagnostic[],\n): Promise<StoryFormatInfo | undefined> {\n const noRemote = options.noRemote ?? false;\n const formats = discoverFormats(getFormatSearchDirs(options.formatPaths, options.useTweegoPath ?? true));\n const wanted = describeFormatRequest(request);\n\n const local = findLocalFormat(formats, request);\n if (local) return local;\n\n const cached = findCachedFormat(request);\n if (cached) return cached;\n\n if (!noRemote) {\n try {\n const remote = await resolveRemoteFormatRequest(request, options.formatIndices, options.formatUrls);\n if (remote) return remote;\n } catch (e) {\n diagnostics.push({\n level: 'warning',\n message: `Remote format fetch failed for ${wanted}: ${e instanceof Error ? e.message : String(e)}`,\n });\n }\n }\n\n // A same-major older version keeps the story in its own format; it never crosses majors.\n if (request.kind === 'name') {\n const older =\n selectFormatCandidate(\n request,\n [...formats.values()].filter((f) => f.isTwine2),\n (f) => f,\n { allowOlder: true },\n ) ?? findCachedFormat(request, { allowOlder: true });\n if (older) {\n diagnostics.push({\n level: 'warning',\n message: `Story format ${wanted} is not available; using ${older.name} ${older.version} instead.`,\n });\n return older;\n }\n }\n\n const reason = noRemote ? ' (remote fetching disabled)' : '';\n diagnostics.push({\n level: 'error',\n message: `Story format ${wanted} is not available${reason}. Found: ${[...formats.keys()].join(', ') || 'none'}`,\n });\n return undefined;\n}\n","/**\n * All public interfaces for twee-ts.\n */\n\n// --- Output modes ---\n\nexport type OutputMode = 'html' | 'twee3' | 'twee1' | 'twine2-archive' | 'twine1-archive' | 'json';\n\n// --- Word count ---\n\nexport type WordCountMethod = 'tweego' | 'whitespace';\n\n// --- Source input ---\n\nexport type InlineSource = { filename: string; content: string | Buffer };\nexport type SourceInput = string | InlineSource;\n\n// --- Compile options ---\n\nexport interface CompileOptions {\n /** Files, directories, or inline sources to compile. */\n sources: SourceInput[];\n /**\n * Glob patterns for files to leave out of `sources`, matched against each file's\n * path relative to the working directory (as `stats.files` lists it). Modules are not affected.\n */\n exclude?: string[];\n /** Output mode. Default: 'html'. */\n outputMode?: OutputMode;\n /** Story format directory ID (e.g. 'sugarcube-2'). */\n formatId?: string;\n /** Name of the starting passage. Default: 'Start'. */\n startPassage?: string;\n /** Extra directories to search for story formats. */\n formatPaths?: string[];\n /** Also search TWEEGO_PATH env for formats. Default: true. */\n useTweegoPath?: boolean;\n /** Module files to inject into <head>. */\n modules?: string[];\n /** Raw HTML file to append to <head>. */\n headFile?: string;\n /** Trim passage whitespace. Default: true. */\n trim?: boolean;\n /** Twee2 compatibility mode. Default: false. */\n twee2Compat?: boolean;\n /** Enable debug/test mode option. Default: false. */\n testMode?: boolean;\n /** URLs to SFA-compatible index.json files for remote format lookup. */\n formatIndices?: string[];\n /** Direct URLs to format.js files. */\n formatUrls?: string[];\n /** Disable remote format fetching. Default: false. */\n noRemote?: boolean;\n /** Map alias tags to canonical special tags (e.g. { library: 'script' }). */\n tagAliases?: Record<string, string>;\n /** Emit source file and line as data- attributes on passage elements. Default: false. */\n sourceInfo?: boolean;\n /** Word counting method. Default: 'tweego'. */\n wordCountMethod?: WordCountMethod;\n}\n\nexport interface CompileToFileOptions extends CompileOptions {\n /** Output file path. */\n outFile: string;\n}\n\nexport interface WatchOptions extends CompileToFileOptions {\n /** Called after each successful rebuild. */\n onBuild?: (result: CompileResult) => void;\n /** Called on build errors. */\n onError?: (error: Error) => void;\n}\n\n// --- Compile result ---\n\nexport type Diagnostic =\n | { level: 'warning'; message: string; file?: string; line?: number }\n | { level: 'error'; message: string; file?: string; line?: number; fatal?: boolean };\n\nexport interface CompileResult {\n /** The compiled output string (HTML, Twee, JSON, etc.). */\n output: string;\n /** The parsed story model (read-only after compilation). */\n story: ReadonlyStory;\n /** The format used for compilation (undefined for non-HTML modes). */\n format?: StoryFormatInfo;\n /** Collected diagnostics. */\n diagnostics: Diagnostic[];\n /** Compilation statistics. */\n stats: CompileStats;\n}\n\nexport interface CompileStats {\n passages: number;\n storyPassages: number;\n words: number;\n files: string[];\n}\n\n// --- Passage ---\n\nexport interface SourceLocation {\n readonly file: string;\n readonly line: number;\n}\n\nexport interface PassageMetadata {\n position?: string;\n size?: string;\n [key: string]: string | undefined;\n}\n\nexport interface Passage {\n name: string;\n tags: string[];\n text: string;\n metadata?: PassageMetadata;\n source?: SourceLocation;\n}\n\n// --- Branded types ---\n\nexport type IFID = string & { readonly __brand: 'IFID' };\n\n// --- Story ---\n\nexport interface Twine1Metadata {\n settings: Map<string, string>;\n}\n\nexport interface Twine2Metadata {\n format: string;\n formatVersion: string;\n options: Map<string, boolean>;\n start: string;\n tags: string;\n tagColors: Map<string, string>;\n zoom: number;\n}\n\nexport interface Story {\n name: string;\n ifid: IFID;\n passages: Passage[];\n legacyIFID: IFID;\n twine1: Twine1Metadata;\n twine2: Twine2Metadata;\n}\n\n// --- Readonly story (post-construction) ---\n\nexport type ReadonlyPassage = Readonly<Passage> & {\n readonly tags: readonly string[];\n};\n\nexport type ReadonlyStory = Readonly<Omit<Story, 'passages' | 'twine1' | 'twine2'>> & {\n readonly passages: readonly ReadonlyPassage[];\n readonly twine1: Readonly<Omit<Twine1Metadata, 'settings'>> & {\n readonly settings: ReadonlyMap<string, string>;\n };\n readonly twine2: Readonly<Omit<Twine2Metadata, 'options' | 'tagColors'>> & {\n readonly options: ReadonlyMap<string, boolean>;\n readonly tagColors: ReadonlyMap<string, string>;\n };\n};\n\n// --- Passage omission (why an output leaves a passage out) ---\n\nexport type OmittingTag = 'Twine.private' | 'script' | 'stylesheet';\n\nexport type PassageOmission =\n | { readonly kind: 'special-name'; readonly name: 'StoryData' | 'StoryTitle' }\n | { readonly kind: 'tag'; readonly tag: OmittingTag }\n | { readonly kind: 'empty-story-settings' };\n\n// --- Story format ---\n\nexport interface StoryFormatInfo {\n id: string;\n filename: string;\n isTwine2: boolean;\n name: string;\n version: string;\n proofing: boolean;\n author?: string;\n description?: string;\n image?: string;\n url?: string;\n license?: string;\n}\n\n/**\n * The story format a compile asks for: a directory-style ID (e.g. 'sugarcube-2', which names\n * a format and a major version) or a Twine 2 format name with a version (as StoryData has it).\n */\nexport type FormatRequest =\n | { readonly kind: 'id'; readonly id: string }\n | { readonly kind: 'name'; readonly name: string; readonly version: string };\n\nexport interface Twine2FormatJSON {\n name: string;\n version: string;\n proofing?: boolean;\n source: string;\n author?: string;\n description?: string;\n image?: string;\n url?: string;\n license?: string;\n}\n\n// --- Lexer ---\n\nexport const ItemType = {\n Error: 0,\n EOF: 1,\n Header: 2,\n Name: 3,\n Tags: 4,\n Metadata: 5,\n Content: 6,\n} as const;\nexport type ItemType = (typeof ItemType)[keyof typeof ItemType];\n\nexport interface LexerItem {\n type: ItemType;\n line: number;\n pos: number;\n val: string;\n}\n\n// --- Story Format Archive (SFA) ---\n\nexport interface SFAIndexEntry {\n name: string;\n version: string;\n proofing: boolean;\n files: string[];\n checksums: Record<string, string>;\n}\n\nexport interface SFAIndex {\n twine1: SFAIndexEntry[];\n twine2: SFAIndexEntry[];\n}\n\n// --- Incremental compilation cache ---\n\nexport interface FileCacheEntry {\n readonly mtimeMs: number;\n /**\n * Identity of the parse options (`trim`, `twee2Compat`) the entry was parsed with. An entry is\n * reused only when this matches the current options; an entry without it is treated as stale\n * and reparsed. The value is opaque: leave it to twee-ts to set.\n */\n readonly parseOptionsKey?: string;\n readonly passages: readonly Passage[];\n readonly diagnostics: readonly Diagnostic[];\n}\n\n// --- Config file ---\n\nexport interface TweeTsConfig {\n sources?: string[];\n exclude?: string[];\n output?: string;\n outputMode?: OutputMode;\n formatId?: string;\n startPassage?: string;\n formatPaths?: string[];\n formatIndices?: string[];\n formatUrls?: string[];\n useTweegoPath?: boolean;\n modules?: string[];\n headFile?: string;\n trim?: boolean;\n twee2Compat?: boolean;\n testMode?: boolean;\n noRemote?: boolean;\n tagAliases?: Record<string, string>;\n sourceInfo?: boolean;\n wordCountMethod?: WordCountMethod;\n}\n","/**\n * Twee 3 state-machine lexer implemented as a synchronous generator.\n * Ported from tweelexer.go — Go channels become `yield`.\n */\nimport type { LexerItem } from './types.js';\nimport { ItemType } from './types.js';\n\nconst EOF = -1;\nconst HEADER_DELIM = '::';\nconst NEWLINE_HEADER_DELIM = '\\n::';\n\ntype StateFn = ((ctx: LexerContext) => StateFn | null) | null;\n\nclass LexerContext {\n readonly input: string;\n line = 1;\n start = 0;\n pos = 0;\n private items: LexerItem[] = [];\n\n constructor(input: string) {\n this.input = input;\n }\n\n next(): number {\n if (this.pos >= this.input.length) return EOF;\n const ch = this.input.charCodeAt(this.pos);\n this.pos++;\n if (ch === 0x0a) this.line++;\n return ch;\n }\n\n peek(): number {\n if (this.pos >= this.input.length) return EOF;\n return this.input.charCodeAt(this.pos);\n }\n\n backup(): void {\n if (this.pos > this.start) {\n this.pos--;\n if (this.input.charCodeAt(this.pos) === 0x0a) this.line--;\n } else {\n throw new Error('backup would leave pos < start');\n }\n }\n\n // Line-counting invariant: next() increments this.line for each newline during\n // character-by-character scanning. However, Content items are produced by jumping\n // this.pos directly (e.g. via indexOf) without calling next(), so those newlines\n // haven't been counted yet. emit() re-counts newlines in [start, pos) for Content\n // items to compensate. This is safe because this.start is reset to this.pos after\n // every emit(), so no range is ever counted twice.\n emit(type: ItemType): void {\n const val = this.input.slice(this.start, this.pos);\n this.items.push({ type, line: this.line, pos: this.start, val });\n if (type === ItemType.Content) {\n for (let i = this.start; i < this.pos; i++) {\n if (this.input.charCodeAt(i) === 0x0a) this.line++;\n }\n }\n this.start = this.pos;\n }\n\n ignore(): void {\n for (let i = this.start; i < this.pos; i++) {\n if (this.input.charCodeAt(i) === 0x0a) this.line++;\n }\n this.start = this.pos;\n }\n\n acceptRun(valid: string): void {\n let ch: number;\n for (ch = this.next(); ch !== EOF && valid.includes(String.fromCharCode(ch)); ch = this.next()) {\n // consume\n }\n if (ch !== EOF) this.backup();\n }\n\n errorf(message: string): null {\n this.items.push({\n type: ItemType.Error,\n line: this.line,\n pos: this.start,\n val: message,\n });\n return null;\n }\n\n /** Drain all pending items and return them. */\n drainItems(): LexerItem[] {\n const result = this.items;\n this.items = [];\n return result;\n }\n}\n\nfunction acceptQuoted(ctx: LexerContext, quote: number): string | null {\n for (;;) {\n const ch = ctx.next();\n switch (ch) {\n case 0x5c: {\n // backslash\n const r = ctx.next();\n if (r !== 0x0a && r !== EOF) break;\n // fall through\n }\n // falls through\n case 0x0a:\n case EOF:\n return 'unterminated quoted string';\n default:\n if (ch === quote) return null;\n break;\n }\n }\n}\n\n// --- State functions ---\n\nfunction lexProlog(ctx: LexerContext): StateFn {\n if (ctx.input.startsWith(HEADER_DELIM, ctx.pos)) {\n return lexHeaderDelim;\n }\n const i = ctx.input.indexOf(NEWLINE_HEADER_DELIM, ctx.pos);\n if (i > -1) {\n ctx.pos = i + 1; // skip to the newline, then past it\n ctx.ignore();\n return lexHeaderDelim;\n }\n ctx.emit(ItemType.EOF);\n return null;\n}\n\nfunction lexContent(ctx: LexerContext): StateFn {\n if (ctx.input.startsWith(HEADER_DELIM, ctx.pos)) {\n return lexHeaderDelim;\n }\n const i = ctx.input.indexOf(NEWLINE_HEADER_DELIM, ctx.pos);\n if (i > -1) {\n ctx.pos = i + 1;\n ctx.emit(ItemType.Content);\n return lexHeaderDelim;\n }\n ctx.pos = ctx.input.length;\n if (ctx.pos > ctx.start) {\n ctx.emit(ItemType.Content);\n }\n ctx.emit(ItemType.EOF);\n return null;\n}\n\nfunction lexHeaderDelim(ctx: LexerContext): StateFn {\n ctx.pos += HEADER_DELIM.length;\n ctx.emit(ItemType.Header);\n return lexName;\n}\n\nfunction lexName(ctx: LexerContext): StateFn {\n let r: number;\n outer: for (;;) {\n r = ctx.next();\n switch (r) {\n case 0x5c: {\n // backslash\n const next = ctx.next();\n if (next !== 0x0a && next !== EOF) break;\n // fall through to terminators\n r = next;\n }\n // falls through\n case 0x5b: // [\n case 0x5d: // ]\n case 0x7b: // {\n case 0x7d: // }\n case 0x0a: // \\n\n case EOF:\n if (r !== EOF) ctx.backup();\n break outer;\n }\n }\n // Always emit a name item, even if empty.\n ctx.emit(ItemType.Name);\n\n switch (r) {\n case 0x5b:\n return lexTags; // [\n case 0x5d:\n return ctx.errorf(`unexpected right square bracket ']'`);\n case 0x7b:\n return lexMetadata; // {\n case 0x7d:\n return ctx.errorf(`unexpected right curly brace '}'`);\n case 0x0a: // newline\n ctx.pos++;\n ctx.ignore();\n return lexContent;\n }\n ctx.emit(ItemType.EOF);\n return null;\n}\n\nfunction lexNextOptionalBlock(ctx: LexerContext): StateFn {\n // Consume whitespace.\n ctx.acceptRun(' \\t');\n ctx.ignore();\n\n const r = ctx.peek();\n switch (r) {\n case 0x5b:\n return lexTags; // [\n case 0x5d:\n return ctx.errorf(`unexpected right square bracket ']'`);\n case 0x7b:\n return lexMetadata; // {\n case 0x7d:\n return ctx.errorf(`unexpected right curly brace '}'`);\n case 0x0a: // newline\n ctx.pos++;\n ctx.ignore();\n return lexContent;\n case EOF:\n ctx.emit(ItemType.EOF);\n return null;\n }\n return ctx.errorf(`illegal character '${String.fromCharCode(r)}' amid the optional blocks`);\n}\n\nfunction lexTags(ctx: LexerContext): StateFn {\n // Consume the left delimiter '['.\n ctx.pos++;\n\n for (;;) {\n const r = ctx.next();\n switch (r) {\n case 0x5c: {\n // backslash\n const next = ctx.next();\n if (next !== 0x0a && next !== EOF) break;\n // fall through\n }\n // falls through\n case 0x0a:\n case EOF:\n if (r === 0x0a) ctx.backup();\n return ctx.errorf('unterminated tag block');\n case 0x5d: // ]\n if (ctx.pos > ctx.start) ctx.emit(ItemType.Tags);\n return lexNextOptionalBlock;\n case 0x5b: // [\n return ctx.errorf(`unexpected left square bracket '['`);\n case 0x7b: // {\n return ctx.errorf(`unexpected left curly brace '{'`);\n case 0x7d: // }\n return ctx.errorf(`unexpected right curly brace '}'`);\n }\n }\n}\n\nfunction lexMetadata(ctx: LexerContext): StateFn {\n // Consume the left delimiter '{'.\n ctx.pos++;\n\n let depth = 1;\n for (;;) {\n const r = ctx.next();\n switch (r) {\n case 0x22: {\n // double quote\n const err = acceptQuoted(ctx, 0x22);\n if (err) return ctx.errorf(err);\n break;\n }\n case 0x0a: // newline\n ctx.backup();\n // falls through\n case EOF:\n return ctx.errorf('unterminated metadata block');\n case 0x7b: // {\n depth++;\n break;\n case 0x7d: // }\n depth--;\n if (depth === 0) {\n if (ctx.pos > ctx.start) ctx.emit(ItemType.Metadata);\n return lexNextOptionalBlock;\n }\n break;\n }\n }\n}\n\n/**\n * Twee 3 lexer — yields LexerItem tokens from Twee source text.\n *\n * In the Go reference, this uses goroutines and channels.\n * Here we use a synchronous generator that accumulates items per state step.\n */\nexport function* tweeLexer(input: string): Generator<LexerItem, void, undefined> {\n const ctx = new LexerContext(input);\n let state: StateFn = lexProlog;\n while (state !== null) {\n state = state(ctx);\n const items = ctx.drainItems();\n for (const item of items) {\n yield item;\n }\n }\n // Drain any remaining items.\n const remaining = ctx.drainItems();\n for (const item of remaining) {\n yield item;\n }\n}\n\n/** Convenience class wrapper for the lexer generator. */\nexport class TweeLexer {\n private gen: Generator<LexerItem, void, undefined>;\n\n constructor(input: string) {\n this.gen = tweeLexer(input);\n }\n\n nextItem(): { item: LexerItem; done: boolean } {\n const result = this.gen.next();\n if (result.done) {\n return { item: { type: ItemType.EOF, line: 0, pos: 0, val: '' }, done: true };\n }\n return { item: result.value, done: false };\n }\n\n *[Symbol.iterator](): Generator<LexerItem, void, undefined> {\n yield* this.gen;\n }\n}\n","/**\n * Twee2 to Twee3 header syntax conversion.\n * Ported from twee2compat.go.\n */\n\nconst twee2DetectRe = /^:: *[^[]*?(?: *\\[.*?\\])? *<(.*?)> *$/m;\nconst twee2HeaderRe = /^(:: *[^[]*?)( *\\[.*?\\])?(?: *<(.*?)>)? *$/gm;\nconst twee2BadPosRe = /^(::.*?) *\\{\"position\":\" *\"\\}$/gm;\n\nfunction hasTwee2Syntax(s: string): boolean {\n return twee2DetectRe.test(s);\n}\n\n/**\n * Convert Twee2-style position blocks `<x,y>` to Twee3 metadata blocks `{\"position\":\"x,y\"}`.\n */\nexport function twee2ToV3(s: string): string {\n if (!hasTwee2Syntax(s)) return s;\n let result = s.replace(twee2HeaderRe, (_, p1: string, p2: string | undefined, p3: string | undefined) => {\n const tags = p2 ?? '';\n const pos = p3 ?? '';\n return `${p1}${tags} {\"position\":\"${pos}\"}`;\n });\n result = result.replace(twee2BadPosRe, '$1');\n return result;\n}\n","/**\n * Parse lexer items into Passage[].\n * Ported from storyload.go:loadTwee().\n */\nimport type { Passage, PassageMetadata, Diagnostic } from './types.js';\nimport { ItemType } from './types.js';\nimport { tweeLexer } from './lexer.js';\nimport { tweeUnescape } from './escape.js';\nimport { twee2ToV3 } from './twee2-compat.js';\nimport { normalizeSourceText } from './source-text.js';\n\nexport interface ParseOptions {\n /** Filename for diagnostics. */\n filename?: string;\n /** Trim whitespace from passage content. Default: true. */\n trim?: boolean;\n /** Enable Twee2 compatibility. Default: false. */\n twee2Compat?: boolean;\n}\n\nexport interface ParseResult {\n passages: Passage[];\n diagnostics: Diagnostic[];\n}\n\n/**\n * Parse Twee source text into passages.\n *\n * The source is normalized first, as files are when they are read: a leading UTF-8 BOM is\n * removed and CRLF and bare CR line endings become LF.\n */\nexport function parseTwee(source: string, options: ParseOptions = {}): ParseResult {\n const { filename = '<inline>', trim = true, twee2Compat = false } = options;\n const diagnostics: Diagnostic[] = [];\n\n const normalized = normalizeSourceText(source);\n const tweeSource = twee2Compat ? twee2ToV3(normalized) : normalized;\n\n const passages: Passage[] = [];\n let current: Passage | null = null;\n let pCount = 0;\n let lastType: ItemType = ItemType.EOF;\n\n for (const item of tweeLexer(tweeSource)) {\n switch (item.type) {\n case ItemType.Error:\n diagnostics.push({\n level: 'error',\n message: `line ${item.line}: Malformed twee source; ${item.val}.`,\n file: filename,\n line: item.line,\n });\n // Fatal: return what we have\n return { passages, diagnostics };\n\n case ItemType.EOF:\n if (pCount > 0 && current) {\n passages.push(current);\n }\n return { passages, diagnostics };\n\n case ItemType.Header:\n pCount++;\n if (pCount > 1 && current) {\n passages.push(current);\n }\n current = { name: '', tags: [], text: '', source: { file: filename, line: item.line } };\n break;\n\n case ItemType.Name: {\n if (!current) break;\n const name = tweeUnescape(item.val).trim();\n if (name.length === 0) {\n diagnostics.push({\n level: 'error',\n message: `line ${item.line}: Malformed twee source; passage with no name.`,\n file: filename,\n line: item.line,\n });\n return { passages, diagnostics };\n }\n current.name = name;\n break;\n }\n\n case ItemType.Tags: {\n if (!current) break;\n if (lastType !== ItemType.Name) {\n diagnostics.push({\n level: 'error',\n message: `line ${item.line}: Malformed twee source; optional tags block must immediately follow the passage name.`,\n file: filename,\n line: item.line,\n });\n return { passages, diagnostics };\n }\n // Strip the surrounding [ and ]\n const inner = item.val.slice(1, -1);\n current.tags = tweeUnescape(inner).split(/\\s+/).filter(Boolean);\n break;\n }\n\n case ItemType.Metadata: {\n if (!current) break;\n if (lastType !== ItemType.Name && lastType !== ItemType.Tags) {\n diagnostics.push({\n level: 'error',\n message: `line ${item.line}: Malformed twee source; optional metadata block must immediately follow the passage name or tags block.`,\n file: filename,\n line: item.line,\n });\n return { passages, diagnostics };\n }\n try {\n const raw: unknown = JSON.parse(item.val);\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n throw new Error('expected a JSON object');\n }\n const parsed = raw as Record<string, unknown>;\n const meta: PassageMetadata = {};\n for (const [key, value] of Object.entries(parsed)) {\n if (typeof value === 'string') {\n meta[key] = value;\n }\n }\n current.metadata = meta;\n } catch (e) {\n diagnostics.push({\n level: 'warning',\n message: `load ${filename}: line ${item.line}: Malformed twee source; could not decode metadata (reason: ${e instanceof Error ? e.message : String(e)}).`,\n file: filename,\n line: item.line,\n });\n }\n break;\n }\n\n case ItemType.Content: {\n if (!current) break;\n if (trim) {\n current.text = item.val.trim();\n } else {\n // Per spec: trailing blank lines MUST be stripped regardless of trim option\n current.text = item.val.replace(/\\n\\s*$/, '');\n }\n break;\n }\n\n default: {\n const _exhaustive: never = item.type;\n diagnostics.push({\n level: 'error',\n message: `line ${item.line}: Unhandled lexer item type: ${_exhaustive}.`,\n file: filename,\n line: item.line,\n });\n return { passages, diagnostics };\n }\n }\n\n lastType = item.type;\n }\n\n // Shouldn't reach here (EOF is always emitted), but just in case:\n if (pCount > 0 && current) {\n passages.push(current);\n }\n return { passages, diagnostics };\n}\n","// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134\n/**\n * C1 Unicode control character reference replacements (code points 128–159).\n * Index i gives the replacement for code point 128+i; 0 means \"no replacement\".\n */\nconst c1 = [\n 8364, 0, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 0,\n 381, 0, 0, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250,\n 339, 0, 382, 376,\n];\n/**\n * True for NUL, UTF-16 surrogates, and values past U+10FFFF.\n * @param codePoint Unicode code point to check.\n */\nfunction isInvalidCodePoint(codePoint) {\n return (codePoint === 0 ||\n (codePoint >= 0xd8_00 && codePoint <= 0xdf_ff) ||\n codePoint > 0x10_ff_ff);\n}\n/**\n * Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or\n * outside the valid Unicode range. Code points in the C1 controls range\n * (128–159) are remapped to their Windows-1252 equivalents, following the\n * HTML spec. All other code points are returned unchanged.\n * @param codePoint Unicode code point to convert.\n */\nexport function replaceCodePoint(codePoint) {\n if (isInvalidCodePoint(codePoint)) {\n return 0xff_fd;\n }\n if (codePoint >= 128 && codePoint <= 159) {\n return c1[codePoint - 128] || codePoint;\n }\n return codePoint;\n}\n/**\n * XML numeric character references are the referenced Unicode code point.\n * Invalid values still become U+FFFD; the HTML Windows-1252 C1 remap is not\n * applied.\n * @see https://www.w3.org/TR/xml/#NT-CharRef\n * @param codePoint Unicode code point to convert.\n */\nexport function replaceCodePointXML(codePoint) {\n return isInvalidCodePoint(codePoint) ? 0xff_fd : codePoint;\n}\n/**\n * Convert the code point of a decoded numeric entity to a string, replacing\n * invalid values.\n *\n * Fast path for plain BMP code points: [1..0x7F] and [0xA0..0xD7FF] pass\n * `replaceCodePoint` unchanged (no NUL, C1 remap, surrogate, or out-of-range\n * handling) and fit a single charCode. 0xd760 = 0xD800 (the first surrogate)\n * - 0xA0.\n * @param codePoint Unicode code point to convert.\n */\nexport function codePointToString(codePoint) {\n return (codePoint - 1) >>> 0 < 0x7f || (codePoint - 0xa0) >>> 0 < 0xd7_60\n ? String.fromCharCode(codePoint)\n : String.fromCodePoint(replaceCodePoint(codePoint));\n}\n//# sourceMappingURL=decode-codepoint.js.map","/*\n * Inverse of the encoder's SAFE alphabet (0x21..0x7E minus 0x22, 0x24, 0x5C),\n * precomputed once at module load. Entries for excluded chars stay 0 but\n * are never read.\n */\nconst BASE91_INVERSE = /* #__PURE__ */ (() => {\n const table = new Uint8Array(127);\n let code = 0;\n for (let char = 0x21; char <= 0x7e; char++) {\n if (char !== 0x22 && char !== 0x24 && char !== 0x5c) {\n table[char] = code++;\n }\n }\n return table;\n})();\n/**\n * Decode a dictionary-encoded trie string back into its Uint16Array.\n *\n * Stream layout (consumed in this order):\n * 1. dict1 atoms — `dict1AtomCount` uint16 values, delta+RLE encoded.\n * 2. dict2 atoms — `atomCount - dict1AtomCount` values, delta+RLE.\n * 3. dict2 ngrams — `ngramCount - (dictSize - dict1AtomCount)` entries,\n * each a pair of slot codes that resolve to earlier slots.\n * 4. dict1 ngrams — `dictSize - dict1AtomCount` entries, same shape.\n * 5. data — slot codes, each expanding to one or more uint16 values.\n *\n * Codes use a 91-char base (printable ASCII minus `\"`, `$`, `\\`):\n * - char1 < dictSize → 1-char code, slot = char1\n * - char1 ≥ dictSize → 2-char code, slot = dictSize + (char1 - dictSize)*91 + char2\n *\n * Slot index → token kind:\n * [0, A) dict1 atoms (1-char codes)\n * [A, dictSize) dict1 ngrams (1-char codes)\n * [dictSize, dictSize+D) dict2 atoms (2-char codes)\n * [dictSize+D, end) dict2 ngrams (2-char codes)\n *\n * Both atom dicts decode before any ngram, and dict2 ngrams decode before\n * dict1 ngrams. So every ngram entry references slots whose contents are\n * already filled — no forward references to handle.\n *\n * This runs on library import. Flat typed arrays store each slot as either\n * a plain value (`single`, covering every atom) or a range in a shared\n * `pool` (ngrams).\n * @param input Packed trie string.\n * @param resultLength Expected number of uint16 values in the output.\n * @param atomCount Total number of distinct uint16 values in the trie.\n * @param dict1AtomCount Atoms in the 1-char range (`A` above).\n * @param ngramCount Total number of ngram entries (dict1 + dict2).\n * @param dictSize Number of 1-char code slots; the rest of `BASE - dictSize`\n * first-byte values are 2-char codes.\n */\nexport function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {\n const base = 91;\n const inputLength = input.length;\n // For 2-char codes, slot = char1 * base - twoCharBias + char2.\n const twoCharBias = dictSize * (base - 1);\n let pos = 0;\n /** Read one slot code at `pos` and return its slot index, advancing pos. */\n const readSlotCode = () => {\n const c1 = BASE91_INVERSE[input.charCodeAt(pos++)];\n return c1 < dictSize\n ? c1\n : c1 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];\n };\n const dict2AtomCount = atomCount - dict1AtomCount;\n const slotCount = atomCount + ngramCount;\n /*\n * Per-slot contents: atoms (always a single value) live directly in\n * `single`; ngram slots hold -1 there and expand to\n * `pool[start[slot] .. start[slot] + length[slot])`.\n */\n const single = new Int32Array(slotCount);\n single.fill(-1, dict1AtomCount, dictSize);\n single.fill(-1, dictSize + dict2AtomCount, slotCount);\n const start = new Int32Array(slotCount);\n const length = new Int32Array(slotCount);\n /**\n * Decode `count` ascending uint16 values from a delta+RLE stream into\n * `single[off..off+count)`.\n *\n * code < 89 → delta = code\n * code == 89 → run-length: next char encodes runLength-2; emit `runLength` consecutive +1 values\n * code == 90, next < 90 → escape: delta = 89 + next * BASE + after-next\n * code == 90, next == 90 → double-escape: extra char for very large deltas\n * @param count\n * @param off\n */\n function decodeDelta(count, off) {\n let previous = 0;\n let slot = off;\n const end = off + count;\n while (slot < end) {\n const code = BASE91_INVERSE[input.charCodeAt(pos++)];\n if (code < 89) {\n previous += code;\n single[slot++] = previous;\n }\n else if (code === 89) {\n let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;\n while (runLength--)\n single[slot++] = ++previous;\n }\n else {\n const next = BASE91_INVERSE[input.charCodeAt(pos++)];\n previous +=\n 89 +\n // eslint-disable-next-line unicorn/prefer-minimal-ternary -- branches read a different number of side-effecting input bytes\n (next < 90\n ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)]\n : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 +\n BASE91_INVERSE[input.charCodeAt(pos++)] * base +\n BASE91_INVERSE[input.charCodeAt(pos++)]);\n single[slot++] = previous;\n }\n }\n }\n // Streams 1 & 2: atoms decoded into their slot ranges.\n decodeDelta(dict1AtomCount, 0);\n decodeDelta(dict2AtomCount, dictSize);\n /*\n * Streams 3 & 4 are read in two passes: first collect every ngram's two\n * references and derive its expanded length (each ref resolves to an earlier\n * slot, so lengths are already known), which sizes the shared pool.\n * Pool ranges are handed out in decode order, so the second pass fills\n * the pool contiguously with a single write cursor.\n */\n const references = new Int32Array(ngramCount * 2);\n let poolSize = 0;\n let ngramIndex = 0;\n /**\n * Read `count` ngram entries (each = 2 slot-code references) for the slots\n * starting at `startSlot`, recording references and assigning pool ranges.\n * @param count\n * @param startSlot\n */\n function readNgramReferences(count, startSlot) {\n for (let index = 0; index < count; index++) {\n const slot = startSlot + index;\n const a = readSlotCode();\n const b = readSlotCode();\n references[ngramIndex * 2] = a;\n references[ngramIndex * 2 + 1] = b;\n ngramIndex += 1;\n start[slot] = poolSize;\n const entryLength = (single[a] < 0 ? length[a] : 1) +\n (single[b] < 0 ? length[b] : 1);\n length[slot] = entryLength;\n poolSize += entryLength;\n }\n }\n readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);\n readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);\n // Second pass: concatenate each ngram's two halves into the pool.\n const pool = new Uint16Array(poolSize);\n let write = 0;\n for (let index = 0; index < ngramIndex; index++) {\n for (let half = 0; half < 2; half++) {\n const source = references[index * 2 + half];\n const value = single[source];\n if (value < 0) {\n let read = start[source];\n const readEnd = read + length[source];\n while (read < readEnd)\n pool[write++] = pool[read++];\n }\n else {\n pool[write++] = value;\n }\n }\n }\n // Stream 5: data. Each code expands to its slot's stored values.\n const out = new Uint16Array(resultLength);\n let outIndex = 0;\n while (pos < inputLength) {\n let slot = BASE91_INVERSE[input.charCodeAt(pos++)];\n if (slot >= dictSize) {\n slot =\n slot * base -\n twoCharBias +\n BASE91_INVERSE[input.charCodeAt(pos++)];\n }\n const value = single[slot];\n if (value < 0) {\n let read = start[slot];\n const readEnd = read + length[slot];\n while (read < readEnd)\n out[outIndex++] = pool[read++];\n }\n else {\n out[outIndex++] = value;\n }\n }\n return out;\n}\n//# sourceMappingURL=decode-shared.js.map","// Generated using scripts/write-decode-map.ts\nimport { decodeTrieDict } from \"../internal/decode-shared.js\";\n/** Packed HTML decode trie data. */\nexport const htmlDecodeTree = /* #__PURE__ */ decodeTrieDict(\"!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&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eg>unwfh;9:4E|YjQsBt|vjx'hYq3!(?C2F|J:2<BaY?C2F|GOu!5x,g|p{ah!-(?C2F|c9:4E|OjXuvvNr}:Rh&i[w*t|cd+U#jJvsu)vsSn~Mkfrmu9p}u7vwv]So!McW#Xa!ax5@A5aY:5;5<H|>kJv~vYrquJu3x4ib#T)2@SmZM?C2F|Bj:rmu9@xPhI(a*a#U#`a3-5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P\", 13_494, 2713, 49, 25, 61);\n//# sourceMappingURL=decode-data-html.js.map","// Generated using scripts/write-decode-map.ts\n/** Packed XML decode trie data. */\nexport const xmlDecodeTree = /* #__PURE__ */ new Uint16Array([\n 512, 26_465, 29_036, 7, 0, 2, 4, 116, 24_638, 116, 24_636, 8693, 29_807,\n 24_610, 621, 1, 0, 0, 3, 112, 24_614, 111, 115, 24_615,\n]);\n//# sourceMappingURL=decode-data-xml.js.map","/**\n * Bit flags & masks for the binary trie encoding used for entity decoding.\n *\n * The trie is a flat `Uint16Array`. Every node starts with one header word:\n *\n * 15..14 VALUE_LENGTH Number of words the value occupies, +1.\n * 0 = no value; 1 = value inline in bits 12..0;\n * 2/3 = value in the 1/2 words after the header.\n * 13 FLAG13 If VALUE_LENGTH > 0: semicolon required (\"strict\"\n * entity; `;` is never stored as a branch).\n * If VALUE_LENGTH == 0: this node is a compact run.\n * 12..7 BRANCH_LENGTH Number of branches (or run length for runs).\n * 6..0 JUMP_TABLE Jump-table offset / single-branch char / first\n * run char (see below).\n *\n * Branch data follows the header and any value words. Its shape is selected\n * by (JUMP_TABLE, BRANCH_LENGTH) in the header:\n *\n * Single branch JUMP_TABLE = the only child's char, BRANCH_LENGTH = 0.\n * No branch words; the child node follows immediately.\n * Jump table JUMP_TABLE = first covered char (> 0), BRANCH_LENGTH =\n * table length. One word per covered char: 0 = no branch,\n * otherwise the child's offset from the END of the table,\n * +1 (so 0 stays the no-branch sentinel).\n * Dictionary JUMP_TABLE = 0, BRANCH_LENGTH = number of branches.\n * ceil(n/2) words of sorted keys packed two per word\n * (low byte first), then n pointer words storing the\n * child's offset from the END of the branch data.\n * Compact run VALUE_LENGTH = 0, FLAG13 set. BRANCH_LENGTH = run\n * length (3..63), JUMP_TABLE = first char; remaining run\n * chars packed two per word after the header. The target\n * node follows the packed words immediately.\n *\n * Pointers are end-relative (rather than relative to the pointer's own\n * position) because that makes the common \"child encoded right after the\n * branch data\" case a small constant, which compresses far better. Offsets\n * to already-encoded (shared) nodes wrap via uint16 modulo arithmetic; the\n * decoder masks navigation results with `& 0xff_ff` to match.\n */\nexport var BinTrieFlags;\n(function (BinTrieFlags) {\n BinTrieFlags[BinTrieFlags[\"VALUE_LENGTH\"] = 49152] = \"VALUE_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"FLAG13\"] = 8192] = \"FLAG13\";\n BinTrieFlags[BinTrieFlags[\"BRANCH_LENGTH\"] = 8064] = \"BRANCH_LENGTH\";\n BinTrieFlags[BinTrieFlags[\"JUMP_TABLE\"] = 127] = \"JUMP_TABLE\";\n /** Bits 12..0: the inline value of a VALUE_LENGTH = 1 header word. */\n BinTrieFlags[BinTrieFlags[\"VALUE_MASK\"] = 8191] = \"VALUE_MASK\";\n})(BinTrieFlags || (BinTrieFlags = {}));\n//# sourceMappingURL=bin-trie-flags.js.map","import { codePointToString, replaceCodePoint, replaceCodePointXML, } from \"./decode-codepoint.js\";\nimport { htmlDecodeTree } from \"./generated/decode-data-html.js\";\nimport { xmlDecodeTree } from \"./generated/decode-data-xml.js\";\nimport { BinTrieFlags } from \"./internal/bin-trie-flags.js\";\nvar CharCodes;\n(function (CharCodes) {\n CharCodes[CharCodes[\"AMP\"] = 38] = \"AMP\";\n CharCodes[CharCodes[\"NUM\"] = 35] = \"NUM\";\n CharCodes[CharCodes[\"SEMI\"] = 59] = \"SEMI\";\n CharCodes[CharCodes[\"EQUALS\"] = 61] = \"EQUALS\";\n CharCodes[CharCodes[\"ZERO\"] = 48] = \"ZERO\";\n CharCodes[CharCodes[\"NINE\"] = 57] = \"NINE\";\n CharCodes[CharCodes[\"LOWER_A\"] = 97] = \"LOWER_A\";\n CharCodes[CharCodes[\"LOWER_X\"] = 120] = \"LOWER_X\";\n})(CharCodes || (CharCodes = {}));\n/** Bit that needs to be set to convert an upper case ASCII character to lower case */\nconst TO_LOWER_BIT = 0b10_0000;\n/*\n * `parseNumericEntity` packs its two results into one 32-bit integer:\n * `(consumed << CONSUMED_SHIFT) | codePoint`. The 21-bit code point field\n * fits any valid Unicode value (max 0x10FFFF, clamped before packing); the\n * consumed count excludes `&` and gets the remaining 11 bits. Extract it\n * with `>>>` so the topmost bit isn't treated as a sign.\n *\n * Plain consts rather than a `const enum`: with `isolatedModules`, enum\n * member reads compile to runtime property loads.\n */\nconst CONSUMED_SHIFT = 21;\nconst CODE_POINT_MASK = 0x1f_ff_ff;\n/**\n * Reserved consumed field for counts of at least 2047 characters after `&`.\n * The true count is in `longNumericConsumed`.\n */\nconst CONSUMED_OVERFLOW = 0x7_ff;\n/**\n * Side channel for numeric entities of at least 2048 characters including\n * `&`. Set by `parseNumericEntity` when its consumed count reaches the\n * reserved value `CONSUMED_OVERFLOW`; callers read the true count from here.\n * A module-level slot avoids a tuple allocation on the hot path.\n */\nlet longNumericConsumed = 0;\n/**\n * Extract the consumed count from a `parseNumericEntity` packed result,\n * recovering the true length from `longNumericConsumed` when the packed\n * field contains the sentinel. Read it before the next `parseNumericEntity`\n * call, which may overwrite the side channel. This helper owns that protocol.\n * @param packed Packed result of `parseNumericEntity`.\n */\nfunction unpackConsumed(packed) {\n const consumed = packed >>> CONSUMED_SHIFT;\n return consumed === CONSUMED_OVERFLOW ? longNumericConsumed : consumed;\n}\n/**\n * Unsigned subtraction trick: (code - lo) >>> 0 wraps negatives to large\n * values, so a single `<=` covers the entire [lo..hi] range check.\n * @param code Code point to check.\n */\nfunction isNumber(code) {\n return (code - CharCodes.ZERO) >>> 0 <= 9;\n}\nfunction isHexadecimalCharacter(code) {\n return ((code | TO_LOWER_BIT) - CharCodes.LOWER_A) >>> 0 <= 5; // F - a\n}\nfunction isAlpha(code) {\n return ((code | TO_LOWER_BIT) - CharCodes.LOWER_A) >>> 0 <= 25; // Z - a\n}\n/**\n * Checks if the given character is a valid end character for an entity in an attribute.\n *\n * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.\n * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state\n * @param code Code point to check.\n */\nfunction isEntityInAttributeInvalidEnd(code) {\n return code === CharCodes.EQUALS || isAlpha(code) || isNumber(code);\n}\nvar EntityDecoderState;\n(function (EntityDecoderState) {\n EntityDecoderState[EntityDecoderState[\"EntityStart\"] = 0] = \"EntityStart\";\n EntityDecoderState[EntityDecoderState[\"NumericStart\"] = 1] = \"NumericStart\";\n EntityDecoderState[EntityDecoderState[\"NumericDecimal\"] = 2] = \"NumericDecimal\";\n EntityDecoderState[EntityDecoderState[\"NumericHex\"] = 3] = \"NumericHex\";\n EntityDecoderState[EntityDecoderState[\"NamedEntity\"] = 4] = \"NamedEntity\";\n})(EntityDecoderState || (EntityDecoderState = {}));\n/**\n * Decoding mode for named entities.\n */\nexport var DecodingMode;\n(function (DecodingMode) {\n /** Entities in text nodes that can end with any character. */\n DecodingMode[DecodingMode[\"Legacy\"] = 0] = \"Legacy\";\n /** Only allow entities terminated with a semicolon. */\n DecodingMode[DecodingMode[\"Strict\"] = 1] = \"Strict\";\n /** Entities in attributes have limitations on ending characters. */\n DecodingMode[DecodingMode[\"Attribute\"] = 2] = \"Attribute\";\n})(DecodingMode || (DecodingMode = {}));\n/**\n * Token decoder with support of writing partial entities.\n */\nexport class EntityDecoder {\n decodeTree;\n emitCodePoint;\n errors;\n /** The current state of the decoder. */\n state = EntityDecoderState.EntityStart;\n /** Characters that were consumed while parsing an entity. */\n consumed = 1;\n /**\n * The result of the entity.\n *\n * For named entities: the trie index of the best legacy match so far\n * (0 = none). For numeric entities: the accumulated code point.\n */\n result = 0;\n /** The current index in the decode tree. */\n treeIndex = 0;\n /**\n * Characters consumed since the last recorded legacy match, plus one.\n * Invariant at the top of the `stateNamedEntity` loop: `excess` equals\n * the number of unrecorded consumed characters + 1.\n */\n // biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive (read via destructuring)\n excess = 1;\n /** The mode in which the decoder is operating. */\n decodeMode = DecodingMode.Strict;\n /** The number of characters that have been consumed in the current run. */\n // biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive\n runConsumed = 0;\n constructor(\n /** The predefined HTML or XML decode tree. */\n decodeTree, \n /**\n * The function that is called when a codepoint is decoded.\n *\n * For named entities that decode to multiple code points, this will\n * be called multiple times, with the second codepoint, and the same\n * `consumed` value.\n * @param codepoint The decoded codepoint.\n * @param consumed The number of characters consumed by the decoder.\n */\n emitCodePoint, \n /** An object that is used to produce errors. */\n errors) {\n this.decodeTree = decodeTree;\n this.emitCodePoint = emitCodePoint;\n this.errors = errors;\n }\n /**\n * Resets the instance to make it reusable.\n * @param decodeMode Entity decoding mode to use.\n */\n startEntity(decodeMode) {\n this.decodeMode = decodeMode;\n this.state = EntityDecoderState.EntityStart;\n this.result = 0;\n this.treeIndex = 0;\n this.excess = 1;\n this.consumed = 1;\n this.runConsumed = 0;\n }\n /**\n * Write an entity to the decoder. This can be called multiple times with partial entities.\n * If the entity is incomplete, the decoder will return -1.\n *\n * Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the\n * entity is incomplete, and resume when the next string is written.\n * @param input The string containing the entity (or a continuation of the entity).\n * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n write(input, offset) {\n switch (this.state) {\n case EntityDecoderState.EntityStart: {\n if (input.charCodeAt(offset) === CharCodes.NUM) {\n this.state = EntityDecoderState.NumericStart;\n this.consumed += 1;\n return this.stateNumericStart(input, offset + 1);\n }\n this.state = EntityDecoderState.NamedEntity;\n return this.stateNamedEntity(input, offset);\n }\n case EntityDecoderState.NumericStart: {\n return this.stateNumericStart(input, offset);\n }\n case EntityDecoderState.NumericDecimal: {\n return this.stateNumericDecimal(input, offset);\n }\n case EntityDecoderState.NumericHex: {\n return this.stateNumericHex(input, offset);\n }\n default: {\n // NamedEntity — the only remaining state.\n return this.stateNamedEntity(input, offset);\n }\n }\n }\n /**\n * Switches between the numeric decimal and hexadecimal states.\n *\n * Equivalent to the `Numeric character reference state` in the HTML spec.\n * @param input The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n // eslint-disable-next-line unicorn/consistent-class-member-order\n stateNumericStart(input, offset) {\n if (offset >= input.length) {\n return -1;\n }\n if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {\n this.state = EntityDecoderState.NumericHex;\n this.consumed += 1;\n return this.stateNumericHex(input, offset + 1);\n }\n this.state = EntityDecoderState.NumericDecimal;\n return this.stateNumericDecimal(input, offset);\n }\n /**\n * Parses a hexadecimal numeric entity.\n *\n * Equivalent to the `Hexademical character reference state` in the HTML\n * spec. Digit parsing matches the hex loop in `parseNumericEntity`.\n * The accumulated value is preserved for numeric validation callbacks.\n * @param input The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericHex(input, offset) {\n const inputLength = input.length;\n // Local accumulators; flushed before any exit (see stateNamedEntity).\n let { result } = this;\n let { consumed } = this;\n while (offset < inputLength) {\n const char = input.charCodeAt(offset);\n if (isNumber(char) || isHexadecimalCharacter(char)) {\n // Convert hex digit to value (0-15); 'a'/'A' -> 10.\n const digit = char <= CharCodes.NINE\n ? char - CharCodes.ZERO\n : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10;\n result = result * 16 + digit;\n consumed += 1;\n offset += 1;\n }\n else {\n this.result = result;\n this.consumed = consumed;\n return this.emitNumericEntity(char, 3);\n }\n }\n this.result = result;\n this.consumed = consumed;\n return -1; // Incomplete entity\n }\n /**\n * Parses a decimal numeric entity.\n *\n * Equivalent to the `Decimal character reference state` in the HTML\n * spec. Digit parsing matches the decimal loop in `parseNumericEntity`.\n * The accumulated value is preserved for numeric validation callbacks.\n * @param input The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNumericDecimal(input, offset) {\n const inputLength = input.length;\n // Local accumulators; flushed before any exit (see stateNamedEntity).\n let { result } = this;\n let { consumed } = this;\n while (offset < inputLength) {\n const digit = input.charCodeAt(offset) - CharCodes.ZERO;\n if (digit >>> 0 > 9) {\n this.result = result;\n this.consumed = consumed;\n return this.emitNumericEntity(digit + CharCodes.ZERO, 2);\n }\n result = result * 10 + digit;\n consumed += 1;\n offset += 1;\n }\n this.result = result;\n this.consumed = consumed;\n return -1; // Incomplete entity\n }\n /**\n * Validate and emit a numeric entity.\n *\n * Implements the logic from the `Hexademical character reference start\n * state` and `Numeric character reference end state` in the HTML spec.\n * @param lastCp The last code point of the entity. Used to see if the\n * entity was terminated with a semicolon.\n * @param expectedLength The minimum number of characters that should be\n * consumed. Used to validate that at least one digit\n * was consumed.\n * @returns The number of characters that were consumed.\n */\n emitNumericEntity(lastCp, expectedLength) {\n // Ensure we consumed at least one digit.\n if (this.consumed <= expectedLength) {\n this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n // Figure out if this is a legit end of the entity\n if (lastCp === CharCodes.SEMI) {\n this.consumed += 1;\n }\n else if (this.decodeMode === DecodingMode.Strict) {\n return 0;\n }\n this.emitCodePoint((this.decodeTree === xmlDecodeTree\n ? replaceCodePointXML\n : replaceCodePoint)(this.result), this.consumed);\n if (this.errors) {\n if (lastCp !== CharCodes.SEMI) {\n this.errors.missingSemicolonAfterCharacterReference();\n }\n this.errors.validateNumericCharacterReference(this.result);\n }\n return this.consumed;\n }\n /**\n * Flush locally-tracked walk state back to the fields, then emit the\n * recorded legacy match or reject (cold path — at most once per\n * entity). Called after failed navigation (leaf node, branch miss, or\n * compact-run mismatch). In attribute mode, reject if no legacy was\n * recorded at the current node, if we descended past it, or if the\n * pending input character is an invalid attribute terminator.\n * @param consumed Locally-tracked consumed count.\n * @param excess Locally-tracked excess count.\n * @param char Pending input character (may be the mismatching char).\n * @param valueLength Value length at the current trie node.\n */\n flushAndEmitLegacyOrReject(consumed, excess, char, valueLength) {\n this.consumed = consumed;\n this.excess = excess;\n return this.result === 0 ||\n (this.decodeMode === DecodingMode.Attribute &&\n (valueLength === 0 ||\n excess > 1 ||\n isEntityInAttributeInvalidEnd(char)))\n ? 0\n : this.emitNotTerminatedNamedEntity();\n }\n /**\n * Parses a named entity.\n *\n * Equivalent to the `Named character reference state` in the HTML spec.\n * @param input The string containing the entity (or a continuation of the entity).\n * @param offset The current offset.\n * @returns The number of characters that were consumed, or -1 if the entity is incomplete.\n */\n stateNamedEntity(input, offset) {\n const { decodeTree } = this;\n const inputLength = input.length;\n const isStrict = this.decodeMode === DecodingMode.Strict;\n /*\n * Local copies of the resumable walk state avoid per-character\n * field writes. They are flushed back to the fields\n * on every exit (chunk end, and before any emit helper that reads\n * them). `this.result` is only written at the (rare) record points,\n * so it stays a direct field write.\n *\n * Legacy-match recording happens in two idempotent places: at the\n * loop top when sitting on a value node, and in the chunk-end\n * epilogue (so `end()` sees matches that land exactly on a chunk\n * boundary). Recording applies `consumed += excess - 1; excess = 1`,\n * which is a no-op when repeated — the loop-top invariant is\n * `excess` = unrecorded consumed characters + 1.\n */\n let { treeIndex } = this;\n let { excess } = this;\n let { consumed } = this;\n let current = decodeTree[treeIndex];\n while (offset < inputLength) {\n /*\n * Descend through value-less jump-table nodes (including the\n * single-branch encoding) inline, mirroring `decodeWithTrie`:\n * this avoids a `determineBranch` call per level for the\n * dominant node shape — including the root on the first write.\n */\n while ((current &\n (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===\n 0 &&\n (current & BinTrieFlags.JUMP_TABLE) !== 0) {\n const char = input.charCodeAt(offset);\n const jumpOffset = current & BinTrieFlags.JUMP_TABLE;\n const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n if (branchCount === 0) {\n // Single branch encoded inline in the jump offset bits.\n if (char !== jumpOffset) {\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);\n }\n treeIndex += 1;\n }\n else {\n const slot = char - jumpOffset;\n if (slot >>> 0 >= branchCount) {\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);\n }\n const stored = decodeTree[treeIndex + 1 + slot];\n if (stored === 0) {\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);\n }\n // End-relative: branch data ends at treeIndex+1+branchCount.\n treeIndex = (treeIndex + branchCount + stored) & 0xff_ff;\n }\n current = decodeTree[treeIndex];\n offset += 1;\n excess += 1;\n /*\n * `charCodeAt` past the end returns NaN, which would alias\n * to slot 0 after `>>> 0` — bail out explicitly.\n */\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n if (offset >= inputLength)\n break;\n }\n if (offset >= inputLength)\n break;\n // Handle compact runs (resumable across chunks).\n if ((current &\n (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===\n BinTrieFlags.FLAG13) {\n const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7; /* 3..63 */\n let { runConsumed } = this;\n // If we are starting a run, check the first char.\n if (runConsumed === 0) {\n const char = input.charCodeAt(offset);\n if (char !== (current & BinTrieFlags.JUMP_TABLE)) {\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);\n }\n offset += 1;\n excess += 1;\n runConsumed = 1;\n }\n // Check remaining characters in the run (packed two per uint16 word).\n while (runConsumed < runLength) {\n if (offset >= inputLength) {\n this.treeIndex = treeIndex;\n this.excess = excess;\n this.consumed = consumed;\n this.runConsumed = runConsumed;\n return -1;\n }\n const charIndexInPacked = runConsumed - 1;\n const packedWord = decodeTree[treeIndex + 1 + (charIndexInPacked >> 1)];\n const expectedChar = (packedWord >> ((charIndexInPacked & 1) << 3)) & 0xff;\n const char = input.charCodeAt(offset);\n if (char !== expectedChar) {\n this.runConsumed = 0;\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);\n }\n offset += 1;\n excess += 1;\n runConsumed += 1;\n }\n this.runConsumed = 0;\n treeIndex += 1 + (runLength >> 1);\n current = decodeTree[treeIndex];\n // Loop top handles the landed-on node (record/emit/branch).\n continue;\n }\n // Header plus out-of-line value words; 0 means no value.\n const valueLength = current >>> 14;\n const char = input.charCodeAt(offset);\n if (valueLength !== 0) {\n // Record a legacy match (FLAG13 clear = semicolon optional).\n if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {\n this.result = treeIndex;\n consumed += excess - 1;\n excess = 1;\n }\n /*\n * Implicit semicolon handling: emit immediately. Covers both\n * strict (FLAG13 set) and legacy entities — neither stores\n * an explicit `;` branch in the trie.\n */\n if (char === CharCodes.SEMI) {\n return this.emitNamedEntityData(treeIndex, valueLength, consumed + excess);\n }\n /*\n * `valueLength === 1` packs the codepoint into the header\n * word's low 13 bits, where branch metadata also lives. Skip\n * the branch lookup on leaves so those value bits aren't\n * reinterpreted as branch offsets.\n */\n if (valueLength === 1) {\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);\n }\n }\n // Value-bearing or dictionary node: dispatch through determineBranch.\n const next = determineBranch(decodeTree, current, treeIndex + (valueLength || 1), char);\n if (next < 0) {\n return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);\n }\n treeIndex = next;\n current = decodeTree[treeIndex];\n offset += 1;\n excess += 1;\n }\n /*\n * Chunk exhausted. Record a legacy match we may be sitting on, so a\n * subsequent `end()` emits it, then persist the walk state.\n */\n if (!isStrict &&\n current >>> 14 !== 0 &&\n (current & BinTrieFlags.FLAG13) === 0) {\n this.result = treeIndex;\n consumed += excess - 1;\n excess = 1;\n }\n this.treeIndex = treeIndex;\n this.excess = excess;\n this.consumed = consumed;\n return -1;\n }\n /**\n * Emit a named entity that was not terminated with a semicolon.\n * @returns The number of characters consumed.\n */\n emitNotTerminatedNamedEntity() {\n const { result, decodeTree } = this;\n const valueLength = decodeTree[result] >>> 14;\n this.emitNamedEntityData(result, valueLength, this.consumed);\n this.errors?.missingSemicolonAfterCharacterReference();\n return this.consumed;\n }\n /**\n * Emit a named entity.\n * @param result The index of the entity in the decode tree.\n * @param valueLength Encoded value length (header plus any value words).\n * @param consumed The number of characters consumed.\n * @returns The number of characters consumed.\n */\n emitNamedEntityData(result, valueLength, consumed) {\n const { decodeTree } = this;\n this.emitCodePoint(valueLength === 1\n ? decodeTree[result] & BinTrieFlags.VALUE_MASK\n : decodeTree[result + 1], consumed);\n if (valueLength === 3) {\n // Emit the second UTF-16 code unit.\n this.emitCodePoint(decodeTree[result + 2], consumed);\n }\n return consumed;\n }\n /**\n * Signal to the parser that the end of the input was reached.\n *\n * Remaining data will be emitted and relevant errors will be produced.\n * @returns The number of characters consumed.\n */\n end() {\n switch (this.state) {\n case EntityDecoderState.NamedEntity: {\n // Emit a named entity if we have one.\n return this.result !== 0 &&\n (this.decodeMode !== DecodingMode.Attribute ||\n this.result === this.treeIndex)\n ? this.emitNotTerminatedNamedEntity()\n : 0;\n }\n // Otherwise, emit a numeric entity if we have one.\n case EntityDecoderState.NumericDecimal: {\n return this.emitNumericEntity(0, 2);\n }\n case EntityDecoderState.NumericHex: {\n return this.emitNumericEntity(0, 3);\n }\n case EntityDecoderState.NumericStart: {\n this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);\n return 0;\n }\n default: {\n // EntityStart or unknown — return 0.\n return 0;\n }\n }\n }\n}\n/**\n * Determines the branch of the current node that is taken given the current\n * character. This function is used to traverse the trie.\n *\n * See `BinTrieFlags` for the branch-data layouts handled here.\n * @param decodeTree The trie.\n * @param current The current node's header word.\n * @param nodeIndex Index of the node's first branch-data word (the header\n * plus any value words have been skipped by the caller).\n * @param char The current character.\n * @returns The index of the next node, or -1 if no branch is taken.\n */\nexport function determineBranch(decodeTree, current, nodeIndex, char) {\n const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n const jumpOffset = current & BinTrieFlags.JUMP_TABLE;\n // Case 1: Single branch or jump table (jumpOffset encodes the first/only char code).\n if (jumpOffset) {\n if (branchCount === 0) {\n // Single branch encoded inline in the jump offset bits.\n return char === jumpOffset ? nodeIndex : -1;\n }\n /*\n * Jump table: branchCount consecutive slots starting at jumpOffset.\n * Unsigned comparison handles both < 0 and >= branchCount in one check.\n */\n const slot = char - jumpOffset;\n if (slot >>> 0 >= branchCount)\n return -1;\n const stored = decodeTree[nodeIndex + slot];\n /*\n * 0 = empty slot (no branch); otherwise the child's offset from the\n * end of the branch array, +1 (end-relative pointers compress\n * better). `& 0xff_ff` mirrors the encoder's uint16 wrap for\n * backreferences to already-encoded nodes.\n */\n return stored === 0\n ? -1\n : (nodeIndex + branchCount + stored - 1) & 0xff_ff;\n }\n /*\n * Case 2: Packed dictionary. Linear scan — over 90% of dict nodes have\n * <= 4 branches in the HTML trie, where the constant-factor savings\n * dominate over binary search's asymptotic edge.\n */\n if (branchCount === 0)\n return -1;\n const packedKeySlots = (branchCount + 1) >> 1;\n const branchEnd = nodeIndex + packedKeySlots + branchCount;\n for (let index = 0; index < branchCount; index++) {\n const packed = decodeTree[nodeIndex + (index >> 1)];\n const key = (packed >> ((index & 1) << 3)) & 0xff;\n if (key === char) {\n const pointerIndex = nodeIndex + packedKeySlots + index;\n // Pointers are relative to the end of the branch data.\n return (branchEnd + decodeTree[pointerIndex]) & 0xff_ff;\n }\n // Keys are sorted; if we've passed `char`, no match is possible.\n if (key > char)\n return -1;\n }\n return -1;\n}\n/**\n * Read the decoded value from a trie node.\n * @param decodeTree The trie.\n * @param nodeIndex The index of the node.\n * @param valueLength The length of the value (1, 2, or 3).\n * @returns The decoded string.\n */\nfunction readTrieValue(decodeTree, nodeIndex, valueLength) {\n if (valueLength === 1) {\n return String.fromCharCode(decodeTree[nodeIndex] & BinTrieFlags.VALUE_MASK);\n }\n if (valueLength === 2) {\n return String.fromCharCode(decodeTree[nodeIndex + 1]);\n }\n return String.fromCharCode(decodeTree[nodeIndex + 1], decodeTree[nodeIndex + 2]);\n}\n/**\n * Parse a numeric entity (`&#DDD;` or `&#xHHH;`).\n *\n * Encodes the result as `(consumed << CONSUMED_SHIFT) | codepoint` (see\n * the packing comment at the top of the file; overlong entities spill\n * their length into `longNumericConsumed`). Returns 0 when no digits were\n * found.\n *\n * This is the sync counterpart of the streaming\n * `EntityDecoder#stateNumericDecimal` / `#stateNumericHex`. Digit parsing\n * matches those methods; only this packed result needs a value clamp.\n * @param input The input string.\n * @param numberStart Index of the `#` character.\n * @param inputLength Cached `input.length`.\n */\nfunction parseNumericEntity(input, numberStart, inputLength) {\n let offset = numberStart + 1; // Skip \"#\"\n let cp = 0;\n let digitStart = offset;\n /*\n * Separate decimal and hexadecimal loops: each multiplies by a constant\n * and runs a single digit test, instead of a per-character base check.\n */\n if (offset < inputLength &&\n (input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {\n offset += 1;\n digitStart = offset;\n while (offset < inputLength) {\n const char = input.charCodeAt(offset);\n if (isNumber(char)) {\n cp = cp * 16 + (char - CharCodes.ZERO);\n }\n else if (isHexadecimalCharacter(char)) {\n cp = cp * 16 + ((char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10);\n }\n else {\n break;\n }\n offset += 1;\n }\n }\n else {\n while (offset < inputLength) {\n const digit = input.charCodeAt(offset) - CharCodes.ZERO;\n if (digit >>> 0 > 9)\n break;\n cp = cp * 10 + digit;\n offset += 1;\n }\n }\n if (offset === digitStart)\n return 0;\n // Include the semicolon in consumed when present.\n if (offset < inputLength && input.charCodeAt(offset) === CharCodes.SEMI) {\n offset += 1;\n }\n /*\n * Clamp out-of-range values to 0x110000 so they fit the 21-bit field\n * and decode to U+FFFD. Lengths at or above CONSUMED_OVERFLOW use the\n * side channel described with the packing constants.\n */\n if (cp > 0x10_ff_ff)\n cp = 0x11_00_00;\n let consumed = offset - numberStart;\n if (consumed >= CONSUMED_OVERFLOW) {\n // eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- deliberate side channel, see `longNumericConsumed`\n longNumericConsumed = consumed;\n consumed = CONSUMED_OVERFLOW;\n }\n return (consumed << CONSUMED_SHIFT) | cp;\n}\n/**\n * Decode all entities in `input` using the HTML trie.\n *\n * Hard-wired to `htmlDecodeTree`: the inline root navigation below assumes\n * the HTML root's jump-table shape, so this must not be generalized to\n * other tries (the XML trie's dictionary root would silently match no\n * entities — `decodeXML` has its own hand-coded fast path instead).\n * @param input The string to decode.\n * @param isStrict Only match semicolon-terminated entities.\n * @param isAttribute Whether to apply attribute-specific parsing rules (disallowing certain non-semicolon terminators).\n * @returns The decoded string.\n */\nfunction decodeWithTrie(input, isStrict, isAttribute) {\n const decodeTree = htmlDecodeTree;\n // Fast path: no entities at all — return input without any allocation.\n let offset = input.indexOf(\"&\");\n if (offset < 0)\n return input;\n const inputLength = input.length;\n /*\n * `chunkStart` marks the start of the next pending slice. Rejected\n * entities don't advance it, so consecutive rejections are stitched\n * into a single `slice` once a real match (or end of input) is hit.\n */\n let chunkStart = 0;\n let result = \"\";\n /*\n * Root navigation fields, hoisted out of the per-entity loop. The HTML\n * root is a multi-branch jump-table covering [A-Za-z]; see the inline\n * first-iteration comment below.\n */\n const root = decodeTree[0];\n const rootJumpOffset = root & BinTrieFlags.JUMP_TABLE;\n const rootBranchCount = (root & BinTrieFlags.BRANCH_LENGTH) >> 7;\n do {\n const entityStart = offset + 1;\n // Quick check: entity names must start with [A-Za-z], numeric with #.\n const firstChar = input.charCodeAt(entityStart);\n let consumed;\n let value;\n if (firstChar === CharCodes.NUM) {\n const packed = parseNumericEntity(input, entityStart, inputLength);\n consumed = unpackConsumed(packed);\n // In strict mode, require semicolon termination.\n if (isStrict &&\n consumed > 0 &&\n input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI) {\n consumed = 0;\n }\n value =\n consumed === 0\n ? \"\"\n : codePointToString(packed & CODE_POINT_MASK);\n }\n else if (isAlpha(firstChar)) {\n consumed = 0;\n value = \"\";\n /*\n * The generator guarantees a jump-table root. Consume the first\n * character directly, then walk from its child.\n */\n const rootSlotIndex = firstChar - rootJumpOffset;\n let nodeIndex;\n if (rootSlotIndex >>> 0 < rootBranchCount) {\n const stored = decodeTree[1 + rootSlotIndex];\n nodeIndex =\n stored === 0 ? -1 : (rootBranchCount + stored) & 0xff_ff;\n }\n else {\n nodeIndex = -1;\n }\n /*\n * Best legacy (no-semicolon) match so far, as trie coordinates.\n * Deferring `readTrieValue` to the end avoids allocating a\n * string for matches that longer matches supersede.\n */\n let bestNodeIndex = 0;\n let bestValueLength = 0;\n let current = nodeIndex < 0 ? 0 : decodeTree[nodeIndex];\n let index = entityStart + 1;\n /*\n * Walk the trie from the root child. The `trie` label lets the\n * inner descent and compact-run loops abandon the entity (and\n * fall through to the legacy/reject handling) directly.\n */\n trie: while (index < inputLength) {\n /*\n * Inline value-less jump tables and single branches. A miss\n * falls through to the recorded legacy match or rejection.\n */\n while (\n // Value-less, non-run node with a nonzero jump offset.\n (current &\n (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===\n 0 &&\n (current & BinTrieFlags.JUMP_TABLE) !== 0) {\n const jumpOffset = current & BinTrieFlags.JUMP_TABLE;\n const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n if (branchCount === 0) {\n // Single branch encoded inline in the jump offset bits.\n if (input.charCodeAt(index) !== jumpOffset)\n break trie;\n nodeIndex += 1;\n }\n else {\n const slot = input.charCodeAt(index) - jumpOffset;\n if (slot >>> 0 >= branchCount)\n break trie;\n const stored = decodeTree[nodeIndex + 1 + slot];\n if (stored === 0)\n break trie;\n // End-relative: branch data ends at nodeIndex+1+branchCount.\n nodeIndex =\n (nodeIndex + branchCount + stored) & 0xff_ff;\n }\n current = decodeTree[nodeIndex];\n index += 1;\n /*\n * `charCodeAt` past the end returns NaN, which would\n * alias to slot 0 after `>>> 0` — bail out explicitly.\n */\n if (index >= inputLength)\n break trie;\n }\n // FLAG13 without a value marks a compact run.\n if ((current &\n (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) ===\n BinTrieFlags.FLAG13) {\n const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;\n // Check first char (stored in JUMP_TABLE bits).\n if (input.charCodeAt(index) !==\n (current & BinTrieFlags.JUMP_TABLE)) {\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n break;\n }\n index += 1;\n // Check remaining characters (packed two per uint16 word).\n const remaining = runLength - 1;\n let wordIndex = nodeIndex + 1;\n let charIndexInPacked = 0;\n /*\n * Process pairs: read one packed word, compare low byte then high byte.\n * No explicit bounds check needed — charCodeAt returns NaN for OOB,\n * which never equals an integer, so the mismatch break fires naturally.\n */\n for (; charIndexInPacked + 1 < remaining; charIndexInPacked += 2) {\n const packed = decodeTree[wordIndex];\n if (input.charCodeAt(index) !== (packed & 0xff))\n break trie;\n index += 1;\n if (input.charCodeAt(index) !== ((packed >> 8) & 0xff))\n break trie;\n index += 1;\n wordIndex += 1;\n }\n // Handle odd trailing char.\n if (charIndexInPacked < remaining) {\n if (input.charCodeAt(index) !==\n (decodeTree[wordIndex] & 0xff))\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n break;\n index += 1;\n }\n nodeIndex += 1 + (runLength >> 1);\n current = decodeTree[nodeIndex];\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n continue;\n }\n // Header plus out-of-line value words; 0 means no value.\n const valueLength = current >>> 14;\n const char = input.charCodeAt(index);\n /*\n * Check current node for a value before navigating.\n * This handles both: (a) values reached via compact runs on the\n * previous iteration, and (b) values at regular branch targets.\n */\n if (valueLength !== 0) {\n // If char is `;`, emit immediately.\n if (char === CharCodes.SEMI) {\n consumed = index - entityStart + 1;\n // Inline leaves carry the value in the low 13 bits.\n value =\n valueLength === 1\n ? String.fromCharCode(current & BinTrieFlags.VALUE_MASK)\n : readTrieValue(decodeTree, nodeIndex, valueLength);\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n break;\n }\n // Record non-terminated (legacy) match (FLAG13 clear = semicolon optional).\n if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {\n consumed = index - entityStart;\n bestNodeIndex = nodeIndex;\n bestValueLength = valueLength;\n }\n /*\n * A valueLength of 1 means the value is packed inline in the header\n * word — these are always leaf nodes with no branches, so we can\n * stop walking the trie.\n */\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n if (valueLength === 1)\n break;\n }\n // Navigate to the next node (valueLength || 1: skip past value words, minimum 1 for header).\n const next = determineBranch(decodeTree, current, nodeIndex + (valueLength || 1), char);\n // eslint-disable-next-line unicorn/no-break-in-nested-loop\n if (next < 0)\n break;\n nodeIndex = next;\n current = decodeTree[nodeIndex];\n index += 1;\n }\n /*\n * Post-loop: if the semicolon path didn't set value,\n * check for a final legacy match. The last navigation may\n * have landed on a legacy node whose value hasn't been\n * recorded yet (loop exited before the top-of-loop check\n * could run).\n */\n if (value === \"\") {\n const finalVL = current >>> 14;\n if (finalVL !== 0 &&\n !isStrict &&\n (current & BinTrieFlags.FLAG13) === 0) {\n consumed = index - entityStart;\n bestNodeIndex = nodeIndex;\n bestValueLength = finalVL;\n }\n if (consumed > 0) {\n value = readTrieValue(decodeTree, bestNodeIndex, bestValueLength);\n }\n }\n }\n else {\n consumed = 0;\n value = \"\";\n }\n /*\n * The attribute end-char rule (HTML spec §13.2.5.73) only applies to\n * unterminated *named* references. Semicolon-terminated entities and\n * numeric entities are always accepted, matching EntityDecoder behavior.\n *\n * When `attribute` is false (the common case), short-circuit skips all\n * the unterminated-named checks entirely.\n */\n if (consumed === 0 ||\n (isAttribute &&\n firstChar !== CharCodes.NUM &&\n input.charCodeAt(entityStart + consumed - 1) !==\n CharCodes.SEMI &&\n entityStart + consumed < inputLength &&\n isEntityInAttributeInvalidEnd(input.charCodeAt(entityStart + consumed)))) {\n // Rejected: leave `&` in the pending chunk, scan past it.\n offset = entityStart;\n }\n else {\n if (chunkStart < offset) {\n result += input.slice(chunkStart, offset);\n }\n result += value;\n offset = chunkStart = entityStart + consumed;\n }\n /*\n * Adjacent entities (`&x;&y;`) are common in entity-dense input;\n * checking the single character at `offset` first skips the\n * `indexOf` call (and its per-call overhead) for that case.\n */\n if (input.charCodeAt(offset) !== CharCodes.AMP) {\n offset = input.indexOf(\"&\", offset);\n }\n } while (offset >= 0);\n return result + input.slice(chunkStart);\n}\n/**\n * Decodes an HTML string.\n * @param htmlString The string to decode.\n * @param mode The decoding mode.\n * @returns The decoded string.\n */\nexport function decodeHTML(htmlString, mode = DecodingMode.Legacy) {\n return decodeWithTrie(htmlString, mode === DecodingMode.Strict, mode === DecodingMode.Attribute);\n}\n/**\n * Decodes an HTML string in an attribute.\n * @param htmlAttribute The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLAttribute(htmlAttribute) {\n return decodeWithTrie(htmlAttribute, false, true);\n}\n/**\n * Decodes an HTML string, requiring all entities to be terminated by a semicolon.\n * @param htmlString The string to decode.\n * @returns The decoded string.\n */\nexport function decodeHTMLStrict(htmlString) {\n return decodeWithTrie(htmlString, true, false);\n}\n/**\n * Decodes an XML string, requiring all entities to be terminated by a semicolon.\n *\n * Uses a hand-coded fast path for the 5 XML named entities (amp, lt, gt,\n * quot, apos) plus numeric entities, bypassing the trie entirely.\n * @param xmlString The string to decode.\n * @returns The decoded string.\n */\nexport function decodeXML(xmlString) {\n let offset = xmlString.indexOf(\"&\");\n if (offset < 0)\n return xmlString;\n let lastIndex = 0;\n let result = \"\";\n do {\n const start = offset + 1;\n let consumed = 0;\n let value = \"\";\n const c1 = xmlString.charCodeAt(start);\n if (c1 === CharCodes.NUM) {\n const packed = parseNumericEntity(xmlString, start, xmlString.length);\n consumed = unpackConsumed(packed);\n // XML is always strict — require semicolon.\n if (consumed === 0 ||\n xmlString.charCodeAt(start + consumed - 1) !== CharCodes.SEMI) {\n consumed = 0;\n }\n else {\n const codePoint = packed & CODE_POINT_MASK;\n // Nonzero BMP values below the surrogate range need no replacement.\n value =\n (codePoint - 1) >>> 0 < 0xd7_ff\n ? String.fromCharCode(codePoint)\n : String.fromCodePoint(replaceCodePointXML(codePoint));\n }\n }\n else {\n /* eslint-disable unicorn/no-break-in-nested-loop -- Keep XML name dispatch inline with the decode loop. */\n switch (c1) {\n // &lt; / &gt;\n case 0x6c:\n case 0x67: {\n if (xmlString.charCodeAt(start + 1) === 0x74 &&\n xmlString.charCodeAt(start + 2) === CharCodes.SEMI) {\n consumed = 3;\n value = c1 === 0x6c ? \"<\" : \">\";\n }\n break;\n }\n // &amp; / &apos;\n case 0x61: {\n const c2 = xmlString.charCodeAt(start + 1);\n if (c2 === 0x6d &&\n xmlString.charCodeAt(start + 2) === 0x70 &&\n xmlString.charCodeAt(start + 3) === CharCodes.SEMI) {\n consumed = 4;\n value = \"&\";\n }\n else if (c2 === 0x70 &&\n xmlString.charCodeAt(start + 2) === 0x6f &&\n xmlString.charCodeAt(start + 3) === 0x73 &&\n xmlString.charCodeAt(start + 4) === CharCodes.SEMI) {\n consumed = 5;\n value = \"'\";\n }\n break;\n }\n // &quot;\n case 0x71: {\n if (xmlString.charCodeAt(start + 1) === 0x75 &&\n xmlString.charCodeAt(start + 2) === 0x6f &&\n xmlString.charCodeAt(start + 3) === 0x74 &&\n xmlString.charCodeAt(start + 4) === CharCodes.SEMI) {\n consumed = 5;\n value = '\"';\n }\n break;\n }\n }\n /* eslint-enable unicorn/no-break-in-nested-loop */\n }\n if (consumed > 0) {\n if (lastIndex < offset)\n result += xmlString.slice(lastIndex, offset);\n result += value;\n offset = lastIndex = start + consumed;\n }\n else {\n offset = start;\n }\n /*\n * Adjacent entities (`&x;&y;`) are common in entity-dense input;\n * checking the single character at `lastIndex` first skips the\n * `indexOf` call (and its per-call overhead) for that case.\n */\n offset =\n xmlString.charCodeAt(offset) === CharCodes.AMP\n ? offset\n : xmlString.indexOf(\"&\", offset);\n } while (offset >= 0);\n return result + xmlString.slice(lastIndex);\n}\nexport { replaceCodePoint, replaceCodePointXML, } from \"./decode-codepoint.js\";\n// Re-export for use by eg. htmlparser2\nexport { htmlDecodeTree } from \"./generated/decode-data-html.js\";\nexport { xmlDecodeTree } from \"./generated/decode-data-xml.js\";\n//# sourceMappingURL=decode.js.map","import { DecodingMode, EntityDecoder, htmlDecodeTree, xmlDecodeTree, } from \"entities/decode\";\nvar CharCodes;\n(function (CharCodes) {\n CharCodes[CharCodes[\"Tab\"] = 9] = \"Tab\";\n CharCodes[CharCodes[\"NewLine\"] = 10] = \"NewLine\";\n CharCodes[CharCodes[\"FormFeed\"] = 12] = \"FormFeed\";\n CharCodes[CharCodes[\"CarriageReturn\"] = 13] = \"CarriageReturn\";\n CharCodes[CharCodes[\"Space\"] = 32] = \"Space\";\n CharCodes[CharCodes[\"ExclamationMark\"] = 33] = \"ExclamationMark\";\n CharCodes[CharCodes[\"Number\"] = 35] = \"Number\";\n CharCodes[CharCodes[\"Amp\"] = 38] = \"Amp\";\n CharCodes[CharCodes[\"SingleQuote\"] = 39] = \"SingleQuote\";\n CharCodes[CharCodes[\"DoubleQuote\"] = 34] = \"DoubleQuote\";\n CharCodes[CharCodes[\"Dash\"] = 45] = \"Dash\";\n CharCodes[CharCodes[\"Slash\"] = 47] = \"Slash\";\n CharCodes[CharCodes[\"Zero\"] = 48] = \"Zero\";\n CharCodes[CharCodes[\"Nine\"] = 57] = \"Nine\";\n CharCodes[CharCodes[\"Semi\"] = 59] = \"Semi\";\n CharCodes[CharCodes[\"Lt\"] = 60] = \"Lt\";\n CharCodes[CharCodes[\"Eq\"] = 61] = \"Eq\";\n CharCodes[CharCodes[\"Gt\"] = 62] = \"Gt\";\n CharCodes[CharCodes[\"Questionmark\"] = 63] = \"Questionmark\";\n CharCodes[CharCodes[\"UpperA\"] = 65] = \"UpperA\";\n CharCodes[CharCodes[\"LowerA\"] = 97] = \"LowerA\";\n CharCodes[CharCodes[\"UpperF\"] = 70] = \"UpperF\";\n CharCodes[CharCodes[\"LowerF\"] = 102] = \"LowerF\";\n CharCodes[CharCodes[\"UpperZ\"] = 90] = \"UpperZ\";\n CharCodes[CharCodes[\"LowerZ\"] = 122] = \"LowerZ\";\n CharCodes[CharCodes[\"LowerX\"] = 120] = \"LowerX\";\n CharCodes[CharCodes[\"OpeningSquareBracket\"] = 91] = \"OpeningSquareBracket\";\n})(CharCodes || (CharCodes = {}));\n/** All the states the tokenizer can be in. */\nvar State;\n(function (State) {\n State[State[\"Text\"] = 1] = \"Text\";\n State[State[\"BeforeTagName\"] = 2] = \"BeforeTagName\";\n State[State[\"InTagName\"] = 3] = \"InTagName\";\n State[State[\"InSelfClosingTag\"] = 4] = \"InSelfClosingTag\";\n State[State[\"BeforeClosingTagName\"] = 5] = \"BeforeClosingTagName\";\n State[State[\"InClosingTagName\"] = 6] = \"InClosingTagName\";\n State[State[\"AfterClosingTagName\"] = 7] = \"AfterClosingTagName\";\n // Attributes\n State[State[\"BeforeAttributeName\"] = 8] = \"BeforeAttributeName\";\n State[State[\"InAttributeName\"] = 9] = \"InAttributeName\";\n State[State[\"AfterAttributeName\"] = 10] = \"AfterAttributeName\";\n State[State[\"BeforeAttributeValue\"] = 11] = \"BeforeAttributeValue\";\n State[State[\"InAttributeValueDq\"] = 12] = \"InAttributeValueDq\";\n State[State[\"InAttributeValueSq\"] = 13] = \"InAttributeValueSq\";\n State[State[\"InAttributeValueNq\"] = 14] = \"InAttributeValueNq\";\n // Declarations\n State[State[\"BeforeDeclaration\"] = 15] = \"BeforeDeclaration\";\n State[State[\"InDeclaration\"] = 16] = \"InDeclaration\";\n // Processing instructions\n State[State[\"InProcessingInstruction\"] = 17] = \"InProcessingInstruction\";\n // Comments & CDATA\n State[State[\"BeforeComment\"] = 18] = \"BeforeComment\";\n State[State[\"CDATASequence\"] = 19] = \"CDATASequence\";\n State[State[\"DeclarationSequence\"] = 20] = \"DeclarationSequence\";\n State[State[\"InSpecialComment\"] = 21] = \"InSpecialComment\";\n State[State[\"InCommentLike\"] = 22] = \"InCommentLike\";\n // Special tags\n State[State[\"SpecialStartSequence\"] = 23] = \"SpecialStartSequence\";\n State[State[\"InSpecialTag\"] = 24] = \"InSpecialTag\";\n State[State[\"InPlainText\"] = 25] = \"InPlainText\";\n State[State[\"InEntity\"] = 26] = \"InEntity\";\n})(State || (State = {}));\nfunction isWhitespace(c) {\n return (c === CharCodes.Space ||\n c === CharCodes.NewLine ||\n c === CharCodes.Tab ||\n c === CharCodes.FormFeed ||\n c === CharCodes.CarriageReturn);\n}\nfunction isEndOfTagSection(c) {\n return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace(c);\n}\nfunction isASCIIAlpha(c) {\n return ((c >= CharCodes.LowerA && c <= CharCodes.LowerZ) ||\n (c >= CharCodes.UpperA && c <= CharCodes.UpperZ));\n}\n/**\n * Quote style used for parsed attributes.\n */\nexport var QuoteType;\n(function (QuoteType) {\n QuoteType[QuoteType[\"NoValue\"] = 0] = \"NoValue\";\n QuoteType[QuoteType[\"Unquoted\"] = 1] = \"Unquoted\";\n QuoteType[QuoteType[\"Single\"] = 2] = \"Single\";\n QuoteType[QuoteType[\"Double\"] = 3] = \"Double\";\n})(QuoteType || (QuoteType = {}));\n/**\n * Sequences used to match longer strings.\n *\n * We don't have `Script`, `Style`, or `Title` here. Instead, we re-use the *End\n * sequences with an increased offset.\n */\nconst Sequences = {\n Empty: new Uint8Array(0),\n Cdata: new Uint8Array([0x43, 0x44, 0x41, 0x54, 0x41, 0x5b]), // CDATA[\n CdataEnd: new Uint8Array([0x5d, 0x5d, 0x3e]), // ]]>\n CommentEnd: new Uint8Array([0x2d, 0x2d, 0x21, 0x3e]), // `--!>`\n Doctype: new Uint8Array([0x64, 0x6f, 0x63, 0x74, 0x79, 0x70, 0x65]), // `doctype`\n IframeEnd: new Uint8Array([0x3c, 0x2f, 0x69, 0x66, 0x72, 0x61, 0x6d, 0x65]), // `</iframe`\n NoembedEnd: new Uint8Array([\n 0x3c, 0x2f, 0x6e, 0x6f, 0x65, 0x6d, 0x62, 0x65, 0x64,\n ]), // `</noembed`\n NoframesEnd: new Uint8Array([\n 0x3c, 0x2f, 0x6e, 0x6f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73,\n ]), // `</noframes`\n Plaintext: new Uint8Array([\n 0x3c, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x78, 0x74,\n ]), // `</plaintext`\n ScriptEnd: new Uint8Array([0x3c, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74]), // `</script`\n StyleEnd: new Uint8Array([0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65]), // `</style`\n TitleEnd: new Uint8Array([0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65]), // `</title`\n TextareaEnd: new Uint8Array([\n 0x3c, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61,\n ]), // `</textarea`\n XmpEnd: new Uint8Array([0x3c, 0x2f, 0x78, 0x6d, 0x70]), // `</xmp`\n};\n/**\n * Maps the first lowercase character of an HTML tag name to the sequence\n * used for special-tag detection. All sequences share a common layout\n * where index 2 is the first tag-name character, so matching always\n * continues from offset 3.\n */\nconst specialStartSequences = new Map([\n [Sequences.IframeEnd[2], Sequences.IframeEnd],\n [Sequences.NoembedEnd[2], Sequences.NoembedEnd],\n [Sequences.Plaintext[2], Sequences.Plaintext],\n [Sequences.ScriptEnd[2], Sequences.ScriptEnd],\n [Sequences.TitleEnd[2], Sequences.TitleEnd],\n [Sequences.XmpEnd[2], Sequences.XmpEnd],\n]);\n/**\n * Tokenizer implementation used by `Parser`.\n */\nexport default class Tokenizer {\n cbs;\n /** The current state the tokenizer is in. */\n state = State.Text;\n /** The read buffer. */\n buffer = \"\";\n /** The beginning of the section that is currently being read. */\n sectionStart = 0;\n /** The index within the buffer that we are currently looking at. */\n index = 0;\n /** The start of the last entity. */\n entityStart = 0;\n /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */\n baseState = State.Text;\n /** For special parsing behavior inside of script and style tags. */\n isSpecial = false;\n /** Indicates whether the tokenizer has been paused. */\n running = true;\n /** The offset of the current buffer. */\n offset = 0;\n xmlMode;\n decodeEntities;\n recognizeSelfClosing;\n entityDecoder;\n constructor({ xmlMode = false, decodeEntities = true, recognizeSelfClosing = xmlMode, }, cbs) {\n this.cbs = cbs;\n this.xmlMode = xmlMode;\n this.decodeEntities = decodeEntities;\n this.recognizeSelfClosing = recognizeSelfClosing;\n this.entityDecoder = new EntityDecoder(xmlMode ? xmlDecodeTree : htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));\n }\n reset() {\n this.state = State.Text;\n this.buffer = \"\";\n this.sectionStart = 0;\n this.index = 0;\n this.baseState = State.Text;\n this.isSpecial = false;\n this.currentSequence = Sequences.Empty;\n this.sequenceIndex = 0;\n this.running = true;\n this.offset = 0;\n }\n write(chunk) {\n this.offset += this.buffer.length;\n this.buffer = chunk;\n this.parse();\n }\n end() {\n if (this.running)\n this.finish();\n }\n pause() {\n this.running = false;\n }\n resume() {\n this.running = true;\n if (this.index < this.buffer.length + this.offset) {\n this.parse();\n }\n }\n stateText(c) {\n if (c === CharCodes.Lt ||\n (!this.decodeEntities && this.fastForwardTo(CharCodes.Lt))) {\n if (this.index > this.sectionStart) {\n this.cbs.ontext(this.sectionStart, this.index);\n }\n this.state = State.BeforeTagName;\n this.sectionStart = this.index;\n }\n else if (this.decodeEntities && c === CharCodes.Amp) {\n this.startEntity();\n }\n }\n currentSequence = Sequences.Empty;\n sequenceIndex = 0;\n enterTagBody() {\n if (this.currentSequence === Sequences.Plaintext) {\n this.currentSequence = Sequences.Empty;\n this.state = State.InPlainText;\n }\n else if (this.isSpecial) {\n this.state = State.InSpecialTag;\n this.sequenceIndex = 0;\n }\n else {\n this.state = State.Text;\n }\n }\n /**\n * Match the opening tag name against an HTML text-only tag sequence.\n *\n * Some tags share an initial prefix (`script`/`style`, `title`/`textarea`,\n * `noembed`/`noframes`), so we may switch to an alternate sequence at the\n * first distinguishing byte. On a successful full match we fall back to\n * the normal tag-name state; a later `>` will enter raw-text, RCDATA, or\n * plaintext mode based on `currentSequence` / `isSpecial`.\n * @param c Current character code point.\n */\n stateSpecialStartSequence(c) {\n const lower = c | 0x20;\n // Still matching — check for an alternate sequence at branch points.\n if (this.sequenceIndex < this.currentSequence.length) {\n if (lower === this.currentSequence[this.sequenceIndex]) {\n this.sequenceIndex++;\n return;\n }\n if (this.sequenceIndex === 3) {\n if (this.currentSequence === Sequences.ScriptEnd &&\n lower === Sequences.StyleEnd[3]) {\n this.currentSequence = Sequences.StyleEnd;\n this.sequenceIndex = 4;\n return;\n }\n if (this.currentSequence === Sequences.TitleEnd &&\n lower === Sequences.TextareaEnd[3]) {\n this.currentSequence = Sequences.TextareaEnd;\n this.sequenceIndex = 4;\n return;\n }\n }\n else if (this.sequenceIndex === 4 &&\n this.currentSequence === Sequences.NoembedEnd &&\n lower === Sequences.NoframesEnd[4]) {\n this.currentSequence = Sequences.NoframesEnd;\n this.sequenceIndex = 5;\n return;\n }\n }\n else if (isEndOfTagSection(c)) {\n // Full match on a valid tag boundary — keep the sequence.\n this.sequenceIndex = 0;\n this.state = State.InTagName;\n this.stateInTagName(c);\n return;\n }\n // No match — abandon special-tag detection.\n this.isSpecial = false;\n this.currentSequence = Sequences.Empty;\n this.sequenceIndex = 0;\n this.state = State.InTagName;\n this.stateInTagName(c);\n }\n stateCDATASequence(c) {\n if (c === Sequences.Cdata[this.sequenceIndex]) {\n if (++this.sequenceIndex === Sequences.Cdata.length) {\n this.state = State.InCommentLike;\n this.currentSequence = Sequences.CdataEnd;\n this.sequenceIndex = 0;\n this.sectionStart = this.index + 1;\n }\n }\n else {\n this.sequenceIndex = 0;\n if (this.xmlMode) {\n this.state = State.InDeclaration;\n this.stateInDeclaration(c); // Reconsume the character\n }\n else {\n this.state = State.InSpecialComment;\n this.stateInSpecialComment(c); // Reconsume the character\n }\n }\n }\n /**\n * When we wait for one specific character, we can speed things up\n * by skipping through the buffer until we find it.\n * @param c Current character code point.\n * @returns Whether the character was found.\n */\n fastForwardTo(c) {\n while (++this.index < this.buffer.length + this.offset) {\n if (this.buffer.charCodeAt(this.index - this.offset) === c) {\n return true;\n }\n }\n /*\n * We increment the index at the end of the `parse` loop,\n * so set it to `buffer.length - 1` here.\n *\n * TODO: Refactor `parse` to increment index before calling states.\n */\n this.index = this.buffer.length + this.offset - 1;\n return false;\n }\n /**\n * Emit a comment token and return to the text state.\n * @param offset Number of characters in the end sequence that have already been matched.\n */\n emitComment(offset) {\n this.cbs.oncomment(this.sectionStart, this.index, offset);\n this.sequenceIndex = 0;\n this.sectionStart = this.index + 1;\n this.state = State.Text;\n }\n /**\n * Comments and CDATA end with `-->` and `]]>`.\n *\n * Their common qualities are:\n * - Their end sequences have a distinct character they start with.\n * - That character is then repeated, so we have to check multiple repeats.\n * - All characters but the start character of the sequence can be skipped.\n * @param c Current character code point.\n */\n stateInCommentLike(c) {\n if (!this.xmlMode &&\n this.currentSequence === Sequences.CommentEnd &&\n this.sequenceIndex <= 1 &&\n /*\n * We're still at the very start of the comment: the only\n * characters consumed since `<!--` are the dashes that\n * advanced sequenceIndex (0 for `<!-->`, 1 for `<!--->`).\n */\n this.index === this.sectionStart + this.sequenceIndex &&\n c === CharCodes.Gt) {\n // Abruptly closed empty HTML comment.\n this.emitComment(this.sequenceIndex);\n }\n else if (this.currentSequence === Sequences.CommentEnd &&\n this.sequenceIndex === 2 &&\n c === CharCodes.Gt) {\n // `!` is optional here, so the same sequence also accepts `-->`.\n this.emitComment(2);\n }\n else if (this.currentSequence === Sequences.CommentEnd &&\n this.sequenceIndex === this.currentSequence.length - 1 &&\n c !== CharCodes.Gt) {\n this.sequenceIndex = Number(c === CharCodes.Dash);\n }\n else if (c === this.currentSequence[this.sequenceIndex]) {\n if (++this.sequenceIndex === this.currentSequence.length) {\n if (this.currentSequence === Sequences.CdataEnd) {\n this.cbs.oncdata(this.sectionStart, this.index, 2);\n }\n else {\n this.cbs.oncomment(this.sectionStart, this.index, 3);\n }\n this.sequenceIndex = 0;\n this.sectionStart = this.index + 1;\n this.state = State.Text;\n }\n }\n else if (this.sequenceIndex === 0) {\n // Fast-forward to the first character of the sequence\n if (this.fastForwardTo(this.currentSequence[0])) {\n this.sequenceIndex = 1;\n }\n }\n else if (c !== this.currentSequence[this.sequenceIndex - 1]) {\n // Allow long sequences, eg. --->, ]]]>\n this.sequenceIndex = 0;\n }\n }\n /**\n * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.\n *\n * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).\n * We allow anything that wouldn't end the tag.\n * @param c Current character code point.\n */\n isTagStartChar(c) {\n return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);\n }\n /**\n * Scan raw-text / RCDATA content for the matching end tag.\n *\n * For RCDATA tags (`<title>`, `<textarea>`) entities are decoded inline.\n * For raw-text tags (`<script>`, `<style>`, etc.) we fast-forward to `<`.\n * @param c Current character code point.\n */\n stateInSpecialTag(c) {\n if (this.sequenceIndex === this.currentSequence.length) {\n if (isEndOfTagSection(c)) {\n const endOfText = this.index - this.currentSequence.length;\n if (this.sectionStart < endOfText) {\n // Spoof the index so that reported locations match up.\n const actualIndex = this.index;\n this.index = endOfText;\n this.cbs.ontext(this.sectionStart, endOfText);\n this.index = actualIndex;\n }\n this.isSpecial = false;\n this.sectionStart = endOfText + 2; // Skip over the `</`\n this.stateInClosingTagName(c);\n return; // We are done; skip the rest of the function.\n }\n this.sequenceIndex = 0;\n }\n if ((c | 0x20) === this.currentSequence[this.sequenceIndex]) {\n this.sequenceIndex += 1;\n }\n else if (this.sequenceIndex === 0) {\n if (this.currentSequence === Sequences.TitleEnd ||\n this.currentSequence === Sequences.TextareaEnd) {\n // RCDATA tags have to parse entities while still looking for their end tag.\n if (this.decodeEntities && c === CharCodes.Amp) {\n this.startEntity();\n }\n }\n else if (this.fastForwardTo(CharCodes.Lt)) {\n // Outside of RCDATA tags, we can fast-forward.\n this.sequenceIndex = 1;\n }\n }\n else {\n // If we see a `<`, set the sequence index to 1; useful for eg. `<</script>`.\n this.sequenceIndex = Number(c === CharCodes.Lt);\n }\n }\n stateBeforeTagName(c) {\n if (c === CharCodes.ExclamationMark) {\n this.state = State.BeforeDeclaration;\n this.sectionStart = this.index + 1;\n }\n else if (c === CharCodes.Questionmark) {\n if (this.xmlMode) {\n this.state = State.InProcessingInstruction;\n this.sequenceIndex = 0;\n this.sectionStart = this.index + 1;\n }\n else {\n this.state = State.InSpecialComment;\n this.sectionStart = this.index;\n }\n }\n else if (this.isTagStartChar(c)) {\n this.sectionStart = this.index;\n const special = this.xmlMode || this.cbs.isInForeignContext?.()\n ? undefined\n : specialStartSequences.get(c | 0x20);\n if (special === undefined) {\n this.state = State.InTagName;\n }\n else {\n this.isSpecial = true;\n this.currentSequence = special;\n this.sequenceIndex = 3;\n this.state = State.SpecialStartSequence;\n }\n }\n else if (c === CharCodes.Slash) {\n this.state = State.BeforeClosingTagName;\n }\n else {\n this.state = State.Text;\n this.stateText(c);\n }\n }\n stateInTagName(c) {\n if (isEndOfTagSection(c)) {\n this.cbs.onopentagname(this.sectionStart, this.index);\n this.sectionStart = -1;\n this.state = State.BeforeAttributeName;\n this.stateBeforeAttributeName(c);\n }\n }\n stateBeforeClosingTagName(c) {\n if (isWhitespace(c)) {\n if (this.xmlMode) {\n // Ignore\n }\n else {\n this.state = State.InSpecialComment;\n this.sectionStart = this.index;\n }\n }\n else if (c === CharCodes.Gt) {\n this.state = State.Text;\n if (!this.xmlMode) {\n this.sectionStart = this.index + 1;\n }\n }\n else {\n this.state = this.isTagStartChar(c)\n ? State.InClosingTagName\n : State.InSpecialComment;\n this.sectionStart = this.index;\n }\n }\n stateInClosingTagName(c) {\n if (isEndOfTagSection(c)) {\n this.cbs.onclosetag(this.sectionStart, this.index);\n this.sectionStart = -1;\n this.state = State.AfterClosingTagName;\n this.stateAfterClosingTagName(c);\n }\n }\n stateAfterClosingTagName(c) {\n // Skip everything until \">\"\n if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n }\n stateBeforeAttributeName(c) {\n if (c === CharCodes.Gt) {\n this.cbs.onopentagend(this.index);\n this.enterTagBody();\n this.sectionStart = this.index + 1;\n }\n else if (c === CharCodes.Slash) {\n this.state = State.InSelfClosingTag;\n }\n else if (!isWhitespace(c)) {\n this.state = State.InAttributeName;\n this.sectionStart = this.index;\n }\n }\n /**\n * Handle `/` before `>` in an opening tag.\n *\n * In HTML mode, text-only tags ignore the self-closing flag and still enter\n * their raw-text/RCDATA/plaintext state unless self-closing tags are being\n * recognized. In XML mode, or for ordinary tags, the tokenizer returns to\n * regular text parsing after emitting the self-closing callback.\n * @param c Current character code point.\n */\n stateInSelfClosingTag(c) {\n if (c === CharCodes.Gt) {\n this.cbs.onselfclosingtag(this.index);\n this.sectionStart = this.index + 1;\n if (!this.recognizeSelfClosing) {\n this.enterTagBody();\n return;\n }\n this.state = State.Text;\n this.isSpecial = false; // Reset special state, in case of self-closing special tags\n this.currentSequence = Sequences.Empty;\n }\n else if (!isWhitespace(c)) {\n this.state = State.BeforeAttributeName;\n this.stateBeforeAttributeName(c);\n }\n }\n stateInAttributeName(c) {\n if (c === CharCodes.Eq || isEndOfTagSection(c)) {\n this.cbs.onattribname(this.sectionStart, this.index);\n this.sectionStart = this.index;\n this.state = State.AfterAttributeName;\n this.stateAfterAttributeName(c);\n }\n }\n stateAfterAttributeName(c) {\n if (c === CharCodes.Eq) {\n this.state = State.BeforeAttributeValue;\n }\n else if (c === CharCodes.Slash || c === CharCodes.Gt) {\n this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);\n this.sectionStart = -1;\n this.state = State.BeforeAttributeName;\n this.stateBeforeAttributeName(c);\n }\n else if (!isWhitespace(c)) {\n this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);\n this.state = State.InAttributeName;\n this.sectionStart = this.index;\n }\n }\n stateBeforeAttributeValue(c) {\n if (c === CharCodes.DoubleQuote) {\n this.state = State.InAttributeValueDq;\n this.sectionStart = this.index + 1;\n }\n else if (c === CharCodes.SingleQuote) {\n this.state = State.InAttributeValueSq;\n this.sectionStart = this.index + 1;\n }\n else if (!isWhitespace(c)) {\n this.sectionStart = this.index;\n this.state = State.InAttributeValueNq;\n this.stateInAttributeValueNoQuotes(c); // Reconsume token\n }\n }\n handleInAttributeValue(c, quote) {\n if (c === quote ||\n (!this.decodeEntities && this.fastForwardTo(quote))) {\n this.cbs.onattribdata(this.sectionStart, this.index);\n this.sectionStart = -1;\n this.cbs.onattribend(quote === CharCodes.DoubleQuote\n ? QuoteType.Double\n : QuoteType.Single, this.index + 1);\n this.state = State.BeforeAttributeName;\n }\n else if (this.decodeEntities && c === CharCodes.Amp) {\n this.startEntity();\n }\n }\n stateInAttributeValueDoubleQuotes(c) {\n this.handleInAttributeValue(c, CharCodes.DoubleQuote);\n }\n stateInAttributeValueSingleQuotes(c) {\n this.handleInAttributeValue(c, CharCodes.SingleQuote);\n }\n stateInAttributeValueNoQuotes(c) {\n if (isWhitespace(c) || c === CharCodes.Gt) {\n this.cbs.onattribdata(this.sectionStart, this.index);\n this.sectionStart = -1;\n this.cbs.onattribend(QuoteType.Unquoted, this.index);\n this.state = State.BeforeAttributeName;\n this.stateBeforeAttributeName(c);\n }\n else if (this.decodeEntities && c === CharCodes.Amp) {\n this.startEntity();\n }\n }\n /**\n * Distinguish between CDATA, declarations, HTML comments, and HTML bogus\n * comments after `<!`.\n *\n * In HTML mode, only real comments and doctypes stay on declaration paths;\n * everything else becomes a bogus comment terminated by the next `>`.\n * @param c Current character code point.\n */\n stateBeforeDeclaration(c) {\n if (c === CharCodes.OpeningSquareBracket) {\n this.state = State.CDATASequence;\n this.sequenceIndex = 0;\n }\n else if (this.xmlMode) {\n this.state =\n c === CharCodes.Dash\n ? State.BeforeComment\n : State.InDeclaration;\n }\n else if ((c | 0x20) === Sequences.Doctype[0]) {\n this.state = State.DeclarationSequence;\n this.currentSequence = Sequences.Doctype;\n this.sequenceIndex = 1;\n }\n else if (c === CharCodes.Gt) {\n this.cbs.oncomment(this.sectionStart, this.index, 0);\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n else if (c === CharCodes.Dash) {\n this.state = State.BeforeComment;\n }\n else {\n this.state = State.InSpecialComment;\n }\n }\n /**\n * Continue matching `doctype` after `<!d`.\n *\n * A full `doctype` match stays on the declaration path; any other name falls\n * back to an HTML bogus comment, which matches browser behavior for\n * non-doctype `<!...>` constructs.\n * @param c Current character code point.\n */\n stateDeclarationSequence(c) {\n if (this.sequenceIndex === this.currentSequence.length) {\n this.state = State.InDeclaration;\n this.stateInDeclaration(c);\n }\n else if ((c | 0x20) === this.currentSequence[this.sequenceIndex]) {\n this.sequenceIndex += 1;\n }\n else if (c === CharCodes.Gt) {\n this.cbs.oncomment(this.sectionStart, this.index, 0);\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n else {\n this.state = State.InSpecialComment;\n }\n }\n stateInDeclaration(c) {\n if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {\n this.cbs.ondeclaration(this.sectionStart, this.index);\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n }\n /**\n * XML processing instructions (`<?...?>`).\n *\n * In HTML mode `<?` is routed to `InSpecialComment` instead, so this\n * state is only reachable in XML mode.\n * @param c Current character code point.\n */\n stateInProcessingInstruction(c) {\n if (c === CharCodes.Questionmark) {\n // Remember that we just consumed `?`, so the next `>` closes the PI.\n this.sequenceIndex = 1;\n }\n else if (c === CharCodes.Gt && this.sequenceIndex === 1) {\n this.cbs.onprocessinginstruction(this.sectionStart, this.index - 1);\n this.sequenceIndex = 0;\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n else {\n // Keep scanning for the next `?`, which can start a closing `?>`.\n this.sequenceIndex = Number(this.fastForwardTo(CharCodes.Questionmark));\n }\n }\n stateBeforeComment(c) {\n if (c === CharCodes.Dash) {\n this.state = State.InCommentLike;\n this.currentSequence = Sequences.CommentEnd;\n this.sequenceIndex = 0;\n this.sectionStart = this.index + 1;\n }\n else if (this.xmlMode) {\n this.state = State.InDeclaration;\n }\n else if (c === CharCodes.Gt) {\n this.cbs.oncomment(this.sectionStart, this.index, 0);\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n else {\n this.state = State.InSpecialComment;\n }\n }\n stateInSpecialComment(c) {\n if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {\n this.cbs.oncomment(this.sectionStart, this.index, 0);\n this.state = State.Text;\n this.sectionStart = this.index + 1;\n }\n }\n startEntity() {\n this.baseState = this.state;\n this.state = State.InEntity;\n this.entityStart = this.index;\n this.entityDecoder.startEntity(this.xmlMode\n ? DecodingMode.Strict\n : this.baseState === State.Text ||\n this.baseState === State.InSpecialTag\n ? DecodingMode.Legacy\n : DecodingMode.Attribute);\n }\n stateInEntity() {\n const indexInBuffer = this.index - this.offset;\n const length = this.entityDecoder.write(this.buffer, indexInBuffer);\n // If `length` is positive, we are done with the entity.\n if (length >= 0) {\n this.state = this.baseState;\n if (length === 0) {\n this.index -= 1;\n }\n }\n else {\n if (indexInBuffer < this.buffer.length &&\n this.buffer.charCodeAt(indexInBuffer) === CharCodes.Amp) {\n this.state = this.baseState;\n this.index -= 1;\n return;\n }\n // Mark buffer as consumed.\n this.index = this.offset + this.buffer.length - 1;\n }\n }\n /**\n * Remove data that has already been consumed from the buffer.\n */\n cleanup() {\n // If we are inside of text or attributes, emit what we already have.\n if (this.running && this.sectionStart !== this.index) {\n if (this.state === State.Text ||\n this.state === State.InPlainText ||\n (this.state === State.InSpecialTag && this.sequenceIndex === 0)) {\n this.cbs.ontext(this.sectionStart, this.index);\n this.sectionStart = this.index;\n }\n else if (this.state === State.InAttributeValueDq ||\n this.state === State.InAttributeValueSq ||\n this.state === State.InAttributeValueNq) {\n this.cbs.onattribdata(this.sectionStart, this.index);\n this.sectionStart = this.index;\n }\n }\n }\n shouldContinue() {\n return this.index < this.buffer.length + this.offset && this.running;\n }\n /**\n * Iterates through the buffer, calling the function corresponding to the current state.\n *\n * States that are more likely to be hit are higher up, as a performance improvement.\n */\n parse() {\n while (this.shouldContinue()) {\n const c = this.buffer.charCodeAt(this.index - this.offset);\n switch (this.state) {\n case State.Text: {\n this.stateText(c);\n break;\n }\n case State.InPlainText: {\n // Skip to end of buffer; cleanup() emits the text.\n this.index = this.buffer.length + this.offset - 1;\n break;\n }\n case State.SpecialStartSequence: {\n this.stateSpecialStartSequence(c);\n break;\n }\n case State.InSpecialTag: {\n this.stateInSpecialTag(c);\n break;\n }\n case State.CDATASequence: {\n this.stateCDATASequence(c);\n break;\n }\n case State.DeclarationSequence: {\n this.stateDeclarationSequence(c);\n break;\n }\n case State.InAttributeValueDq: {\n this.stateInAttributeValueDoubleQuotes(c);\n break;\n }\n case State.InAttributeName: {\n this.stateInAttributeName(c);\n break;\n }\n case State.InCommentLike: {\n this.stateInCommentLike(c);\n break;\n }\n case State.InSpecialComment: {\n this.stateInSpecialComment(c);\n break;\n }\n case State.BeforeAttributeName: {\n this.stateBeforeAttributeName(c);\n break;\n }\n case State.InTagName: {\n this.stateInTagName(c);\n break;\n }\n case State.InClosingTagName: {\n this.stateInClosingTagName(c);\n break;\n }\n case State.BeforeTagName: {\n this.stateBeforeTagName(c);\n break;\n }\n case State.AfterAttributeName: {\n this.stateAfterAttributeName(c);\n break;\n }\n case State.InAttributeValueSq: {\n this.stateInAttributeValueSingleQuotes(c);\n break;\n }\n case State.BeforeAttributeValue: {\n this.stateBeforeAttributeValue(c);\n break;\n }\n case State.BeforeClosingTagName: {\n this.stateBeforeClosingTagName(c);\n break;\n }\n case State.AfterClosingTagName: {\n this.stateAfterClosingTagName(c);\n break;\n }\n case State.InAttributeValueNq: {\n this.stateInAttributeValueNoQuotes(c);\n break;\n }\n case State.InSelfClosingTag: {\n this.stateInSelfClosingTag(c);\n break;\n }\n case State.InDeclaration: {\n this.stateInDeclaration(c);\n break;\n }\n case State.BeforeDeclaration: {\n this.stateBeforeDeclaration(c);\n break;\n }\n case State.BeforeComment: {\n this.stateBeforeComment(c);\n break;\n }\n case State.InProcessingInstruction: {\n this.stateInProcessingInstruction(c);\n break;\n }\n case State.InEntity: {\n this.stateInEntity();\n break;\n }\n }\n this.index++;\n }\n this.cleanup();\n }\n finish() {\n if (this.state === State.InEntity) {\n this.entityDecoder.end();\n this.state = this.baseState;\n }\n this.handleTrailingData();\n this.cbs.onend();\n }\n handleTrailingCommentLikeData(endIndex) {\n if (this.state !== State.InCommentLike) {\n return false;\n }\n if (this.currentSequence === Sequences.CdataEnd) {\n if (this.xmlMode) {\n if (this.sectionStart < endIndex) {\n this.cbs.oncdata(this.sectionStart, endIndex, 0);\n }\n }\n else {\n /* In HTML mode, unclosed CDATA is a bogus comment. */\n const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;\n this.cbs.oncomment(cdataStart, endIndex, 0);\n }\n }\n else {\n const offset = this.xmlMode\n ? 0\n : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);\n this.cbs.oncomment(this.sectionStart, endIndex, offset);\n }\n return true;\n }\n handleTrailingMarkupDeclaration(endIndex) {\n if (this.xmlMode) {\n switch (this.state) {\n case State.InSpecialComment:\n case State.BeforeComment:\n case State.CDATASequence:\n case State.DeclarationSequence:\n case State.InDeclaration: {\n this.cbs.ontext(this.sectionStart, endIndex);\n return true;\n }\n default: {\n return false;\n }\n }\n }\n switch (this.state) {\n case State.BeforeDeclaration:\n case State.InSpecialComment:\n case State.BeforeComment:\n case State.CDATASequence: {\n this.cbs.oncomment(this.sectionStart, endIndex, 0);\n return true;\n }\n case State.DeclarationSequence: {\n if (this.sequenceIndex !== Sequences.Doctype.length) {\n this.cbs.oncomment(this.sectionStart, endIndex, 0);\n }\n return true;\n }\n case State.InDeclaration: {\n return true;\n }\n default: {\n return false;\n }\n }\n }\n /** Handle any trailing data. */\n handleTrailingData() {\n const endIndex = this.buffer.length + this.offset;\n if (this.handleTrailingCommentLikeData(endIndex) ||\n this.handleTrailingMarkupDeclaration(endIndex)) {\n return;\n }\n // If there is no remaining data, we are done.\n if (this.sectionStart >= endIndex) {\n return;\n }\n switch (this.state) {\n case State.InTagName:\n case State.BeforeAttributeName:\n case State.BeforeAttributeValue:\n case State.AfterAttributeName:\n case State.InAttributeName:\n case State.InAttributeValueSq:\n case State.InAttributeValueDq:\n case State.InAttributeValueNq:\n case State.InClosingTagName: {\n /*\n * If we are currently in an opening or closing tag, us not calling the\n * respective callback signals that the tag should be ignored.\n */\n break;\n }\n default: {\n this.cbs.ontext(this.sectionStart, endIndex);\n }\n }\n }\n emitCodePoint(cp, consumed) {\n if (this.baseState !== State.Text &&\n this.baseState !== State.InSpecialTag) {\n if (this.sectionStart < this.entityStart) {\n this.cbs.onattribdata(this.sectionStart, this.entityStart);\n }\n this.sectionStart = this.entityStart + consumed;\n this.index = this.sectionStart - 1;\n this.cbs.onattribentity(cp);\n }\n else {\n if (this.sectionStart < this.entityStart) {\n this.cbs.ontext(this.sectionStart, this.entityStart);\n }\n this.sectionStart = this.entityStart + consumed;\n this.index = this.sectionStart - 1;\n this.cbs.ontextentity(cp, this.sectionStart);\n }\n }\n}\n//# sourceMappingURL=Tokenizer.js.map","const { fromCodePoint } = String;\nimport Tokenizer, { QuoteType } from \"./Tokenizer.js\";\nconst formTags = new Set([\n \"input\",\n \"option\",\n \"optgroup\",\n \"select\",\n \"button\",\n \"datalist\",\n \"textarea\",\n]);\nconst pTag = new Set([\"p\"]);\nconst headingTags = new Set([\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"p\"]);\nconst tableSectionTags = new Set([\"thead\", \"tbody\"]);\nconst ddtTags = new Set([\"dd\", \"dt\"]);\nconst rtpTags = new Set([\"rt\", \"rp\"]);\nconst openImpliesClose = new Map([\n [\"tr\", new Set([\"tr\", \"th\", \"td\"])],\n [\"th\", new Set([\"th\"])],\n [\"td\", new Set([\"thead\", \"th\", \"td\"])],\n [\"body\", new Set([\"head\", \"link\", \"script\"])],\n [\"a\", new Set([\"a\"])],\n [\"li\", new Set([\"li\"])],\n [\"p\", pTag],\n [\"h1\", headingTags],\n [\"h2\", headingTags],\n [\"h3\", headingTags],\n [\"h4\", headingTags],\n [\"h5\", headingTags],\n [\"h6\", headingTags],\n [\"select\", formTags],\n [\"input\", formTags],\n [\"output\", formTags],\n [\"button\", formTags],\n [\"datalist\", formTags],\n [\"textarea\", formTags],\n [\"option\", new Set([\"option\"])],\n [\"optgroup\", new Set([\"optgroup\", \"option\"])],\n [\"dd\", ddtTags],\n [\"dt\", ddtTags],\n [\"address\", pTag],\n [\"article\", pTag],\n [\"aside\", pTag],\n [\"blockquote\", pTag],\n [\"details\", pTag],\n [\"div\", pTag],\n [\"dl\", pTag],\n [\"fieldset\", pTag],\n [\"figcaption\", pTag],\n [\"figure\", pTag],\n [\"footer\", pTag],\n [\"form\", pTag],\n [\"header\", pTag],\n [\"hr\", pTag],\n [\"main\", pTag],\n [\"nav\", pTag],\n [\"ol\", pTag],\n [\"pre\", pTag],\n [\"section\", pTag],\n [\"table\", pTag],\n [\"ul\", pTag],\n [\"rt\", rtpTags],\n [\"rp\", rtpTags],\n [\"tbody\", tableSectionTags],\n [\"tfoot\", tableSectionTags],\n]);\nconst DOCUMENT_TYPE = \"doctype\";\nconst voidElements = new Set([\n \"area\",\n \"base\",\n \"basefont\",\n \"br\",\n \"col\",\n \"command\",\n \"embed\",\n \"frame\",\n \"hr\",\n \"img\",\n \"input\",\n \"isindex\",\n \"keygen\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\nconst foreignContextElements = new Set([\"math\", \"svg\"]);\n/**\n * Elements that can be used to integrate HTML content within foreign namespaces (e.g., SVG or MathML).\n *\n * Entries must use the SVG-adjusted casing (e.g. \"foreignObject\" not\n * \"foreignobject\") since they are compared against adjusted tag names.\n */\nconst htmlIntegrationElements = new Set([\n \"mi\",\n \"mo\",\n \"mn\",\n \"ms\",\n \"mtext\",\n \"annotation-xml\",\n \"foreignObject\",\n \"desc\",\n \"title\",\n]);\nconst svgTagNameAdjustments = new Map([\n [\"altglyph\", \"altGlyph\"],\n [\"altglyphdef\", \"altGlyphDef\"],\n [\"altglyphitem\", \"altGlyphItem\"],\n [\"animatecolor\", \"animateColor\"],\n [\"animatemotion\", \"animateMotion\"],\n [\"animatetransform\", \"animateTransform\"],\n [\"clippath\", \"clipPath\"],\n [\"feblend\", \"feBlend\"],\n [\"fecolormatrix\", \"feColorMatrix\"],\n [\"fecomponenttransfer\", \"feComponentTransfer\"],\n [\"fecomposite\", \"feComposite\"],\n [\"feconvolvematrix\", \"feConvolveMatrix\"],\n [\"fediffuselighting\", \"feDiffuseLighting\"],\n [\"fedisplacementmap\", \"feDisplacementMap\"],\n [\"fedistantlight\", \"feDistantLight\"],\n [\"fedropshadow\", \"feDropShadow\"],\n [\"feflood\", \"feFlood\"],\n [\"fefunca\", \"feFuncA\"],\n [\"fefuncb\", \"feFuncB\"],\n [\"fefuncg\", \"feFuncG\"],\n [\"fefuncr\", \"feFuncR\"],\n [\"fegaussianblur\", \"feGaussianBlur\"],\n [\"feimage\", \"feImage\"],\n [\"femerge\", \"feMerge\"],\n [\"femergenode\", \"feMergeNode\"],\n [\"femorphology\", \"feMorphology\"],\n [\"feoffset\", \"feOffset\"],\n [\"fepointlight\", \"fePointLight\"],\n [\"fespecularlighting\", \"feSpecularLighting\"],\n [\"fespotlight\", \"feSpotLight\"],\n [\"fetile\", \"feTile\"],\n [\"feturbulence\", \"feTurbulence\"],\n [\"foreignobject\", \"foreignObject\"],\n [\"glyphref\", \"glyphRef\"],\n [\"lineargradient\", \"linearGradient\"],\n [\"radialgradient\", \"radialGradient\"],\n [\"textpath\", \"textPath\"],\n]);\nvar ForeignContext;\n(function (ForeignContext) {\n ForeignContext[ForeignContext[\"None\"] = 0] = \"None\";\n ForeignContext[ForeignContext[\"Svg\"] = 1] = \"Svg\";\n ForeignContext[ForeignContext[\"MathML\"] = 2] = \"MathML\";\n})(ForeignContext || (ForeignContext = {}));\nconst reNameEnd = /\\s|\\//;\n/**\n * Incremental parser implementation.\n */\nexport class Parser {\n options;\n /** The start index of the last event. */\n startIndex = 0;\n /** The end index of the last event. */\n endIndex = 0;\n /**\n * Store the start index of the current open tag,\n * so we can update the start index for attributes.\n */\n openTagStart = 0;\n tagname = \"\";\n attribname = \"\";\n attribvalue = \"\";\n attribs = null;\n stack = [];\n foreignContext;\n cbs;\n lowerCaseTagNames;\n lowerCaseAttributeNames;\n recognizeSelfClosing;\n /** We are parsing HTML. Inverse of the `xmlMode` option. */\n htmlMode;\n tokenizer;\n buffers = [];\n bufferOffset = 0;\n /** The index of the last written buffer. Used when resuming after a `pause()`. */\n writeIndex = 0;\n /** Indicates whether the parser has finished running / `.end` has been called. */\n ended = false;\n constructor(cbs, options = {}) {\n this.options = options;\n this.cbs = cbs ?? {};\n this.htmlMode = !this.options.xmlMode;\n this.lowerCaseTagNames = options.lowerCaseTags ?? this.htmlMode;\n this.lowerCaseAttributeNames =\n options.lowerCaseAttributeNames ?? this.htmlMode;\n this.recognizeSelfClosing =\n options.recognizeSelfClosing ?? !this.htmlMode;\n this.tokenizer = new (options.Tokenizer ?? Tokenizer)(this.options, this);\n this.foreignContext = [ForeignContext.None];\n this.cbs.onparserinit?.(this);\n }\n // Tokenizer event handlers\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n ontext(start, endIndex) {\n const data = this.getSlice(start, endIndex);\n this.endIndex = endIndex - 1;\n this.cbs.ontext?.(data);\n this.startIndex = endIndex;\n }\n /**\n * @param cp Current Unicode code point.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n ontextentity(cp, endIndex) {\n this.endIndex = endIndex - 1;\n this.cbs.ontext?.(fromCodePoint(cp));\n this.startIndex = endIndex;\n }\n /** @internal */\n isInForeignContext() {\n return this.foreignContext[0] !== ForeignContext.None;\n }\n /**\n * Checks if the current tag is a void element. Override this if you want\n * to specify your own additional void elements.\n * @param name Name of the pseudo selector.\n */\n isVoidElement(name) {\n return this.htmlMode && voidElements.has(name);\n }\n /**\n * Read a tag name from the buffer.\n *\n * When `lowerCaseTagNames` is enabled (the default in HTML mode), the name\n * is lowercased and may be adjusted for SVG casing or the `image` → `img`\n * alias.\n * @param start Start index of the tag name in the buffer.\n * @param endIndex End index of the tag name in the buffer.\n */\n readTagName(start, endIndex) {\n const name = this.lowerCaseTagNames\n ? this.getSlice(start, endIndex).toLowerCase()\n : this.getSlice(start, endIndex);\n if (!(this.lowerCaseTagNames && this.htmlMode)) {\n return name;\n }\n if (this.foreignContext[0] === ForeignContext.Svg) {\n return svgTagNameAdjustments.get(name) ?? name;\n }\n /*\n * Closing tags for SVG elements inside HTML integration points\n * (e.g. </foreignObject> while inside its own content) need case\n * adjustment so the name matches what was pushed to the stack.\n * `foreignContext.length > 1` means a foreign ancestor exists —\n * the base [None] entry plus at least one pushed context.\n */\n if (this.foreignContext.length > 1) {\n const adjusted = svgTagNameAdjustments.get(name);\n if (adjusted !== undefined && this.stack.includes(adjusted)) {\n return adjusted;\n }\n }\n if (!this.isInForeignContext()) {\n return name === \"image\" ? \"img\" : name;\n }\n return name;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onopentagname(start, endIndex) {\n this.endIndex = endIndex;\n this.emitOpenTag(this.readTagName(start, endIndex));\n }\n emitOpenTag(name) {\n this.openTagStart = this.startIndex;\n this.tagname = name;\n /*\n * The spec ignores a second <form> when one is already open.\n * Setting tagname to \"\" suppresses all downstream effects: attribs\n * stays null so endOpenTag is a no-op, and closeCurrentTag can't\n * match \"\" on the stack.\n */\n if (this.htmlMode && name === \"form\" && this.stack.includes(\"form\")) {\n this.tagname = \"\";\n return;\n }\n const impliesClose = this.htmlMode && openImpliesClose.get(name);\n if (impliesClose) {\n while (this.stack.length > 0 && impliesClose.has(this.stack[0])) {\n this.popElement(true);\n }\n }\n if (!this.isVoidElement(name)) {\n this.stack.unshift(name);\n if (this.htmlMode) {\n if (name === \"svg\") {\n this.foreignContext.unshift(ForeignContext.Svg);\n }\n else if (name === \"math\") {\n this.foreignContext.unshift(ForeignContext.MathML);\n }\n else if (htmlIntegrationElements.has(name)) {\n this.foreignContext.unshift(ForeignContext.None);\n }\n }\n }\n this.cbs.onopentagname?.(name);\n if (this.cbs.onopentag)\n this.attribs = {};\n }\n endOpenTag(isImplied) {\n this.startIndex = this.openTagStart;\n if (this.attribs) {\n this.cbs.onopentag?.(this.tagname, this.attribs, isImplied);\n this.attribs = null;\n }\n if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) {\n this.cbs.onclosetag(this.tagname, true);\n }\n this.tagname = \"\";\n }\n /**\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onopentagend(endIndex) {\n this.endIndex = endIndex;\n this.endOpenTag(false);\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onclosetag(start, endIndex) {\n this.endIndex = endIndex;\n const name = this.readTagName(start, endIndex);\n if (!this.isVoidElement(name)) {\n const pos = this.stack.indexOf(name);\n if (pos !== -1) {\n for (let index = 0; index < pos; index++) {\n this.popElement(true);\n }\n this.popElement(false);\n }\n else if (this.htmlMode && name === \"p\") {\n // Implicit open before close\n this.emitOpenTag(\"p\");\n this.closeCurrentTag(true);\n }\n }\n else if (this.htmlMode && name === \"br\") {\n // We can't use `emitOpenTag` for implicit open, as `br` would be implicitly closed.\n this.cbs.onopentagname?.(\"br\");\n this.cbs.onopentag?.(\"br\", {}, true);\n this.cbs.onclosetag?.(\"br\", false);\n }\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n /**\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onselfclosingtag(endIndex) {\n this.endIndex = endIndex;\n if (this.recognizeSelfClosing || this.isInForeignContext()) {\n this.closeCurrentTag(false);\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n else {\n // Ignore the fact that the tag is self-closing.\n this.onopentagend(endIndex);\n }\n }\n /**\n * Pop the top element off the stack, emit a close event, and maintain\n * the foreign context stack.\n * @param implied Whether this close is implied (not from an explicit end tag).\n */\n popElement(implied) {\n // biome-ignore lint/style/noNonNullAssertion: The element is guaranteed to exist.\n const element = this.stack.shift();\n if (this.htmlMode &&\n (foreignContextElements.has(element) ||\n htmlIntegrationElements.has(element))) {\n this.foreignContext.shift();\n }\n this.cbs.onclosetag?.(element, implied);\n }\n closeCurrentTag(isOpenImplied) {\n const name = this.tagname;\n this.endOpenTag(isOpenImplied);\n // Self-closing tags will be on the top of the stack\n if (this.stack[0] === name) {\n this.popElement(!isOpenImplied);\n }\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onattribname(start, endIndex) {\n this.startIndex = start;\n const name = this.getSlice(start, endIndex);\n this.attribname = this.lowerCaseAttributeNames\n ? name.toLowerCase()\n : name;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onattribdata(start, endIndex) {\n this.attribvalue += this.getSlice(start, endIndex);\n }\n /**\n * @param cp Current Unicode code point.\n * @internal\n */\n onattribentity(cp) {\n this.attribvalue += fromCodePoint(cp);\n }\n /**\n * @param quote Quote type used for the current attribute.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onattribend(quote, endIndex) {\n this.endIndex = endIndex;\n this.cbs.onattribute?.(this.attribname, this.attribvalue, quote === QuoteType.Double\n ? '\"'\n : quote === QuoteType.Single\n ? \"'\"\n : quote === QuoteType.NoValue\n ? undefined\n : null);\n if (this.attribs && !Object.hasOwn(this.attribs, this.attribname)) {\n this.attribs[this.attribname] = this.attribvalue;\n }\n this.attribvalue = \"\";\n }\n getInstructionName(value) {\n const index = value.search(reNameEnd);\n let name = index < 0 ? value : value.substr(0, index);\n if (this.lowerCaseTagNames) {\n name = name.toLowerCase();\n }\n return name;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n ondeclaration(start, endIndex) {\n this.endIndex = endIndex;\n const value = this.getSlice(start, endIndex);\n if (this.cbs.onprocessinginstruction) {\n /*\n * In HTML mode, ondeclaration is only reached for DOCTYPE\n * (the tokenizer routes everything else to bogus comments).\n */\n const name = this.htmlMode\n ? this.lowerCaseTagNames\n ? DOCUMENT_TYPE\n : value.slice(0, DOCUMENT_TYPE.length)\n : this.getInstructionName(value);\n this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);\n }\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @internal\n */\n onprocessinginstruction(start, endIndex) {\n this.endIndex = endIndex;\n const value = this.getSlice(start, endIndex);\n if (this.cbs.onprocessinginstruction) {\n const name = this.getInstructionName(value);\n this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);\n }\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @param offset Offset applied when computing parser indices.\n * @internal\n */\n oncomment(start, endIndex, offset) {\n this.endIndex = endIndex;\n this.cbs.oncomment?.(this.getSlice(start, endIndex - offset));\n this.cbs.oncommentend?.();\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n /**\n * @param start Start index for the current parser event.\n * @param endIndex End index for the current parser event.\n * @param offset Offset applied when computing parser indices.\n * @internal\n */\n oncdata(start, endIndex, offset) {\n this.endIndex = endIndex;\n const value = this.getSlice(start, endIndex - offset);\n if (!this.htmlMode || this.options.recognizeCDATA) {\n this.cbs.oncdatastart?.();\n this.cbs.ontext?.(value);\n this.cbs.oncdataend?.();\n }\n else if (this.isInForeignContext()) {\n this.cbs.ontext?.(value);\n }\n else {\n this.cbs.oncomment?.(`[CDATA[${value}]]`);\n this.cbs.oncommentend?.();\n }\n // Set `startIndex` for next node\n this.startIndex = endIndex + 1;\n }\n /** @internal */\n onend() {\n if (this.cbs.onclosetag) {\n // Set the end index for all remaining tags\n this.endIndex = this.startIndex;\n for (let index = 0; index < this.stack.length; index++) {\n this.cbs.onclosetag(this.stack[index], true);\n }\n }\n this.cbs.onend?.();\n }\n /**\n * Resets the parser to a blank state, ready to parse a new HTML document\n */\n reset() {\n this.cbs.onreset?.();\n this.tokenizer.reset();\n this.tagname = \"\";\n this.attribname = \"\";\n this.attribvalue = \"\";\n this.attribs = null;\n this.stack.length = 0;\n this.startIndex = 0;\n this.endIndex = 0;\n this.cbs.onparserinit?.(this);\n this.buffers.length = 0;\n this.foreignContext.length = 0;\n this.foreignContext.unshift(ForeignContext.None);\n this.bufferOffset = 0;\n this.writeIndex = 0;\n this.ended = false;\n }\n /**\n * Resets the parser, then parses a complete document and\n * pushes it to the handler.\n * @param data Document to parse.\n */\n parseComplete(data) {\n this.reset();\n this.end(data);\n }\n getSlice(start, end) {\n if (start === end) {\n return \"\";\n }\n while (start - this.bufferOffset >= this.buffers[0].length) {\n this.shiftBuffer();\n }\n let slice = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);\n while (end - this.bufferOffset > this.buffers[0].length) {\n this.shiftBuffer();\n slice += this.buffers[0].slice(0, end - this.bufferOffset);\n }\n return slice;\n }\n shiftBuffer() {\n this.bufferOffset += this.buffers[0].length;\n this.writeIndex--;\n this.buffers.shift();\n }\n /**\n * Parses a chunk of data and calls the corresponding callbacks.\n * @param chunk Chunk to parse.\n */\n write(chunk) {\n if (this.ended) {\n this.cbs.onerror?.(new Error(\".write() after done!\"));\n return;\n }\n this.buffers.push(chunk);\n if (this.tokenizer.running) {\n this.tokenizer.write(chunk);\n this.writeIndex++;\n }\n }\n /**\n * Parses the end of the buffer and clears the stack, calls onend.\n * @param chunk Optional final chunk to parse.\n */\n end(chunk) {\n if (this.ended) {\n this.cbs.onerror?.(new Error(\".end() after done!\"));\n return;\n }\n if (chunk)\n this.write(chunk);\n this.ended = true;\n this.tokenizer.end();\n }\n /**\n * Pauses parsing. The parser won't emit events until `resume` is called.\n */\n pause() {\n this.tokenizer.pause();\n }\n /**\n * Resumes parsing after `pause` was called.\n */\n resume() {\n this.tokenizer.resume();\n while (this.tokenizer.running &&\n this.writeIndex < this.buffers.length) {\n this.tokenizer.write(this.buffers[this.writeIndex++]);\n }\n if (this.ended)\n this.tokenizer.end();\n }\n}\n//# sourceMappingURL=Parser.js.map","/** Types of elements found in htmlparser2's DOM */\nexport var ElementType;\n(function (ElementType) {\n /** Type for the root element of a document */\n ElementType[\"Root\"] = \"root\";\n /** Type for Text */\n ElementType[\"Text\"] = \"text\";\n /** Type for <? ... ?> */\n ElementType[\"Directive\"] = \"directive\";\n /** Type for <!-- ... --> */\n ElementType[\"Comment\"] = \"comment\";\n /** Type for <script> tags */\n ElementType[\"Script\"] = \"script\";\n /** Type for <style> tags */\n ElementType[\"Style\"] = \"style\";\n /** Type for Any tag */\n ElementType[\"Tag\"] = \"tag\";\n /** Type for <![CDATA[ ... ]]> */\n ElementType[\"CDATA\"] = \"cdata\";\n /** Type for <!doctype ...> */\n ElementType[\"Doctype\"] = \"doctype\";\n})(ElementType || (ElementType = {}));\n/**\n * Tests whether an element is a tag or not.\n * @param element Element to test\n * @param element.type Node type discriminator to check.\n */\nexport function isTag(element) {\n return (element.type === ElementType.Tag ||\n element.type === ElementType.Script ||\n element.type === ElementType.Style);\n}\n// Exports for backwards compatibility\n/** Type for the root element of a document */\n// eslint-disable-next-line prefer-destructuring\nexport const Root = ElementType.Root;\n/** Type for Text */\n// eslint-disable-next-line prefer-destructuring\nexport const Text = ElementType.Text;\n/** Type for <? ... ?> */\n// eslint-disable-next-line prefer-destructuring\nexport const Directive = ElementType.Directive;\n/** Type for <!-- ... --> */\n// eslint-disable-next-line prefer-destructuring\nexport const Comment = ElementType.Comment;\n/** Type for <script> tags */\n// eslint-disable-next-line prefer-destructuring\nexport const Script = ElementType.Script;\n/** Type for <style> tags */\n// eslint-disable-next-line prefer-destructuring\nexport const Style = ElementType.Style;\n/** Type for Any tag */\n// eslint-disable-next-line prefer-destructuring\nexport const Tag = ElementType.Tag;\n/** Type for <![CDATA[ ... ]]> */\n// eslint-disable-next-line prefer-destructuring\nexport const CDATA = ElementType.CDATA;\n/** Type for <!doctype ...> */\n// eslint-disable-next-line prefer-destructuring\nexport const Doctype = ElementType.Doctype;\n","import { ElementType, isTag as isTagRaw } from \"domelementtype\";\n/**\n * This object will be used as the prototype for Nodes when creating a\n * DOM-Level-1-compliant structure.\n */\nexport class Node {\n /** Parent of the node */\n parent = null;\n /** Previous sibling */\n prev = null;\n /** Next sibling */\n next = null;\n /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */\n startIndex = null;\n /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */\n endIndex = null;\n // Read-write aliases for properties\n /**\n * Same as {@link parent}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get parentNode() {\n return this.parent;\n }\n set parentNode(parent) {\n this.parent = parent;\n }\n /**\n * Same as {@link prev}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get previousSibling() {\n return this.prev;\n }\n set previousSibling(previous) {\n this.prev = previous;\n }\n /**\n * Same as {@link next}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get nextSibling() {\n return this.next;\n }\n set nextSibling(next) {\n this.next = next;\n }\n /**\n * Clone this node, and optionally its children.\n * @param recursive Clone child nodes as well.\n * @returns A clone of the node.\n */\n cloneNode(recursive = false) {\n return cloneNode(this, recursive);\n }\n}\n/**\n * A node that contains some data.\n */\nexport class DataNode extends Node {\n data;\n /**\n * @param data The content of the data node\n */\n constructor(data) {\n super();\n this.data = data;\n }\n /**\n * Same as {@link data}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get nodeValue() {\n return this.data;\n }\n set nodeValue(data) {\n this.data = data;\n }\n}\n/**\n * Text within the document.\n */\nexport class Text extends DataNode {\n type = ElementType.Text;\n get nodeType() {\n return 3;\n }\n}\n/**\n * Comments within the document.\n */\nexport class Comment extends DataNode {\n type = ElementType.Comment;\n get nodeType() {\n return 8;\n }\n}\n/**\n * Processing instructions, including doc types.\n */\nexport class ProcessingInstruction extends DataNode {\n type = ElementType.Directive;\n name;\n constructor(name, data) {\n super(data);\n this.name = name;\n }\n get nodeType() {\n return 1;\n }\n /** If this is a doctype, the document type name (parse5 only). */\n \"x-name\";\n /** If this is a doctype, the document type public identifier (parse5 only). */\n \"x-publicId\";\n /** If this is a doctype, the document type system identifier (parse5 only). */\n \"x-systemId\";\n}\n/**\n * A node that can have children.\n */\nexport class NodeWithChildren extends Node {\n children;\n /**\n * @param children Children of the node. Only certain node types can have children.\n */\n constructor(children) {\n super();\n this.children = children;\n }\n // Aliases\n /** First child of the node. */\n get firstChild() {\n return this.children[0] ?? null;\n }\n /** Last child of the node. */\n get lastChild() {\n return this.children.length > 0\n ? this.children[this.children.length - 1]\n : null;\n }\n /**\n * Same as {@link children}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get childNodes() {\n return this.children;\n }\n set childNodes(children) {\n this.children = children;\n }\n}\n/**\n * CDATA nodes.\n */\nexport class CDATA extends NodeWithChildren {\n type = ElementType.CDATA;\n get nodeType() {\n return 4;\n }\n}\n/**\n * The root node of the document.\n */\nexport class Document extends NodeWithChildren {\n type = ElementType.Root;\n get nodeType() {\n return 9;\n }\n}\n/**\n * An element within the DOM.\n */\nexport class Element extends NodeWithChildren {\n name;\n attribs;\n type;\n /**\n * @param name Name of the tag, eg. `div`, `span`.\n * @param attribs Object mapping attribute names to attribute values.\n * @param children Children of the node.\n * @param type Node type used for the new node instance.\n */\n constructor(name, attribs, children = [], type = name === \"script\"\n ? ElementType.Script\n : name === \"style\"\n ? ElementType.Style\n : ElementType.Tag) {\n super(children);\n this.name = name;\n this.attribs = attribs;\n this.type = type;\n }\n get nodeType() {\n return 1;\n }\n // DOM Level 1 aliases\n /**\n * Same as {@link name}.\n * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.\n */\n get tagName() {\n return this.name;\n }\n set tagName(name) {\n this.name = name;\n }\n get attributes() {\n return Object.keys(this.attribs).map((name) => ({\n name,\n value: this.attribs[name],\n namespace: this[\"x-attribsNamespace\"]?.[name],\n prefix: this[\"x-attribsPrefix\"]?.[name],\n }));\n }\n /** Element namespace (parse5 only). */\n namespace;\n /** Element attribute namespaces (parse5 only). */\n \"x-attribsNamespace\";\n /** Element attribute namespace-related prefixes (parse5 only). */\n \"x-attribsPrefix\";\n}\n/**\n * Checks if `node` is an element node.\n * @param node Node to check.\n * @returns `true` if the node is an element node.\n */\nexport function isTag(node) {\n return isTagRaw(node);\n}\n/**\n * Checks if `node` is a CDATA node.\n * @param node Node to check.\n * @returns `true` if the node is a CDATA node.\n */\nexport function isCDATA(node) {\n return node.type === ElementType.CDATA;\n}\n/**\n * Checks if `node` is a text node.\n * @param node Node to check.\n * @returns `true` if the node is a text node.\n */\nexport function isText(node) {\n return node.type === ElementType.Text;\n}\n/**\n * Checks if `node` is a comment node.\n * @param node Node to check.\n * @returns `true` if the node is a comment node.\n */\nexport function isComment(node) {\n return node.type === ElementType.Comment;\n}\n/**\n * Checks if `node` is a directive node.\n * @param node Node to check.\n * @returns `true` if the node is a directive node.\n */\nexport function isDirective(node) {\n return node.type === ElementType.Directive;\n}\n/**\n * Checks if `node` is a document node.\n * @param node Node to check.\n * @returns `true` if the node is a document node.\n */\nexport function isDocument(node) {\n return node.type === ElementType.Root;\n}\n/**\n * Checks if `node` has children.\n * @param node Node to check.\n * @returns `true` if the node has children.\n */\nexport function hasChildren(node) {\n return Object.hasOwn(node, \"children\");\n}\n/**\n * Clone a node, and optionally its children.\n * @param node Node to clone.\n * @param recursive Clone child nodes as well.\n * @returns A clone of the node.\n */\nexport function cloneNode(node, recursive = false) {\n let result;\n if (isText(node)) {\n result = new Text(node.data);\n }\n else if (isComment(node)) {\n result = new Comment(node.data);\n }\n else if (isTag(node)) {\n const children = recursive ? cloneChildren(node.children) : [];\n const clone = new Element(node.name, { ...node.attribs }, children);\n for (const child of children) {\n child.parent = clone;\n }\n if (node.namespace != null) {\n clone.namespace = node.namespace;\n }\n if (node[\"x-attribsNamespace\"]) {\n clone[\"x-attribsNamespace\"] = { ...node[\"x-attribsNamespace\"] };\n }\n if (node[\"x-attribsPrefix\"]) {\n clone[\"x-attribsPrefix\"] = { ...node[\"x-attribsPrefix\"] };\n }\n result = clone;\n }\n else if (isCDATA(node)) {\n const children = recursive ? cloneChildren(node.children) : [];\n const clone = new CDATA(children);\n for (const child of children) {\n child.parent = clone;\n }\n result = clone;\n }\n else if (isDocument(node)) {\n const children = recursive ? cloneChildren(node.children) : [];\n const clone = new Document(children);\n for (const child of children) {\n child.parent = clone;\n }\n if (node[\"x-mode\"]) {\n clone[\"x-mode\"] = node[\"x-mode\"];\n }\n result = clone;\n }\n else if (isDirective(node)) {\n const instruction = new ProcessingInstruction(node.name, node.data);\n if (node[\"x-name\"] != null) {\n instruction[\"x-name\"] = node[\"x-name\"];\n instruction[\"x-publicId\"] = node[\"x-publicId\"];\n instruction[\"x-systemId\"] = node[\"x-systemId\"];\n }\n result = instruction;\n }\n else {\n throw new Error(`Not implemented yet: ${node.type}`);\n }\n result.startIndex = node.startIndex;\n result.endIndex = node.endIndex;\n if (node.sourceCodeLocation != null) {\n result.sourceCodeLocation = node.sourceCodeLocation;\n }\n return result;\n}\n/**\n * Clone a list of child nodes.\n * @param childs The child nodes to clone.\n * @returns A list of cloned child nodes.\n */\nfunction cloneChildren(childs) {\n const children = childs.map((child) => cloneNode(child, true));\n for (let index = 1; index < children.length; index++) {\n children[index].prev = children[index - 1];\n children[index - 1].next = children[index];\n }\n return children;\n}\n","import { ElementType } from \"domelementtype\";\nimport { CDATA, Comment, Document, Element, ProcessingInstruction, Text, } from \"./node.js\";\nexport * from \"./node.js\";\n// Default options\nconst defaultOptions = {\n withStartIndices: false,\n withEndIndices: false,\n xmlMode: false,\n};\n/**\n * Event-based handler that builds a DOM tree from parser callbacks.\n */\nexport class DomHandler {\n /** The elements of the DOM */\n dom = [];\n /** The root element for the DOM */\n root = new Document(this.dom);\n /** Called once parsing has completed. */\n callback;\n /** Settings for the handler. */\n options;\n /** Callback whenever a tag is closed. */\n elementCB;\n /** Indicated whether parsing has been completed. */\n done = false;\n /** Stack of open tags. */\n tagStack = [this.root];\n /** A data node that is still being written to. */\n lastNode = null;\n /** Reference to the parser instance. Used for location information. */\n parser = null;\n /**\n * @param callback Called once parsing has completed.\n * @param options Settings for the handler.\n * @param elementCB Callback whenever a tag is closed.\n */\n constructor(callback, options, elementCB) {\n // Make it possible to skip arguments, for backwards-compatibility\n if (typeof options === \"function\") {\n elementCB = options;\n options = defaultOptions;\n }\n if (typeof callback === \"object\") {\n options = callback;\n callback = undefined;\n }\n this.callback = callback ?? null;\n this.options = options ?? defaultOptions;\n this.elementCB = elementCB ?? null;\n }\n onparserinit(parser) {\n this.parser = parser;\n }\n // Resets the handler back to starting state\n onreset() {\n this.dom = [];\n this.root = new Document(this.dom);\n this.done = false;\n this.tagStack = [this.root];\n this.lastNode = null;\n this.parser = null;\n }\n // Signals the handler that parsing is done\n onend() {\n if (this.done)\n return;\n this.done = true;\n this.parser = null;\n this.handleCallback(null);\n }\n onerror(error) {\n this.handleCallback(error);\n }\n onclosetag() {\n this.lastNode = null;\n const element = this.tagStack.pop();\n if (this.options.withEndIndices && this.parser) {\n element.endIndex = this.parser.endIndex;\n }\n if (this.elementCB)\n this.elementCB(element);\n }\n onopentag(name, attribs) {\n const type = this.options.xmlMode ? ElementType.Tag : undefined;\n const element = new Element(name, attribs, undefined, type);\n this.addNode(element);\n this.tagStack.push(element);\n }\n ontext(data) {\n const { lastNode } = this;\n if (lastNode && lastNode.type === ElementType.Text) {\n lastNode.data += data;\n if (this.options.withEndIndices && this.parser) {\n lastNode.endIndex = this.parser.endIndex;\n }\n }\n else {\n const node = new Text(data);\n this.addNode(node);\n this.lastNode = node;\n }\n }\n oncomment(data) {\n if (this.lastNode && this.lastNode.type === ElementType.Comment) {\n this.lastNode.data += data;\n return;\n }\n const node = new Comment(data);\n this.addNode(node);\n this.lastNode = node;\n }\n oncommentend() {\n this.lastNode = null;\n }\n oncdatastart() {\n const text = new Text(\"\");\n const node = new CDATA([text]);\n this.addNode(node);\n text.parent = node;\n this.lastNode = text;\n }\n oncdataend() {\n this.lastNode = null;\n }\n onprocessinginstruction(name, data) {\n const node = new ProcessingInstruction(name, data);\n this.addNode(node);\n }\n handleCallback(error) {\n if (typeof this.callback === \"function\") {\n this.callback(error, this.dom);\n }\n else if (error) {\n throw error;\n }\n }\n addNode(node) {\n const parent = this.tagStack[this.tagStack.length - 1];\n const previousSibling = parent.children[parent.children.length - 1];\n if (this.options.withStartIndices && this.parser) {\n node.startIndex = this.parser.startIndex;\n }\n if (this.options.withEndIndices && this.parser) {\n node.endIndex = this.parser.endIndex;\n }\n parent.children.push(node);\n if (previousSibling) {\n node.prev = previousSibling;\n previousSibling.next = node;\n }\n node.parent = parent;\n this.lastNode = null;\n }\n}\nexport default DomHandler;\n","import { Parser } from \"./Parser.js\";\nexport { Parser } from \"./Parser.js\";\nimport { DomHandler, } from \"domhandler\";\nexport { DomHandler, \n// Old name for DomHandler\nDomHandler as DefaultHandler, } from \"domhandler\";\n// Helper methods\n/**\n * Parses the data, returns the resulting document.\n * @param data The data that should be parsed.\n * @param options Optional options for the parser and DOM handler.\n */\nexport function parseDocument(data, options) {\n const handler = new DomHandler(undefined, options);\n new Parser(handler, options).end(data);\n return handler.root;\n}\n/**\n * Creates a parser instance, with an attached DOM handler.\n * @param callback A callback that will be called once parsing has been completed, with the resulting document.\n * @param options Optional options for the parser and DOM handler.\n * @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.\n */\nexport function createDocumentStream(callback, options, elementCallback) {\n const handler = new DomHandler((error) => callback(error, handler.root), options, elementCallback);\n return new Parser(handler, options);\n}\n/*\n * All of the following exports exist for backwards-compatibility.\n * They should probably be removed eventually.\n */\nexport * as ElementType from \"domelementtype\";\nexport { default as Tokenizer, QuoteType, } from \"./Tokenizer.js\";\nimport { getFeed } from \"domutils\";\nexport { getFeed } from \"domutils\";\nconst parseFeedDefaultOptions = { xmlMode: true };\n/**\n * Parse a feed.\n * @param feed The feed that should be parsed, as a string.\n * @param options Optionally, options for parsing. When using this, you should set `xmlMode` to `true`.\n */\nexport function parseFeed(feed, options = parseFeedDefaultOptions) {\n return getFeed(parseDocument(feed, options).children);\n}\nexport * as DomUtils from \"domutils\";\n//# sourceMappingURL=index.js.map","/**\n * Twine HTML decompiler: parse compiled Twine 2 or Twine 1 HTML back into a Story model.\n * Ported from storyload.go:loadHTML().\n */\nimport { parseDocument } from 'htmlparser2';\nimport type { Passage, PassageMetadata, Diagnostic, IFID } from './types.js';\nimport { createStory, storyAdd, storyPrepend, marshalStoryData, unmarshalStorySettings } from './story.js';\nimport { rot13, tiddlerUnescape } from './escape.js';\n\nexport interface DecompileResult {\n story: import('./types.js').Story;\n diagnostics: Diagnostic[];\n}\n\n// Structural types matching domhandler's API (avoids direct import of domhandler).\ninterface HtmlNode {\n type: string;\n name?: string;\n attribs?: Record<string, string>;\n children?: HtmlNode[];\n data?: string;\n}\n\n/**\n * Parse a Twine 2 or Twine 1 compiled HTML file back into a Story model.\n */\nexport function decompileHTML(html: string): DecompileResult {\n const diagnostics: Diagnostic[] = [];\n const story = createStory();\n\n const doc = parseDocument(html) as unknown as HtmlNode;\n\n // Try Twine 2 first (<tw-storydata>), then Twine 1 (<div id=\"store-area\"> or <div id=\"storeArea\">).\n const twine2Data = findElement(doc, 'tw-storydata');\n if (twine2Data) {\n decompileTwine2(twine2Data, story, diagnostics);\n return { story, diagnostics };\n }\n\n const twine1Data = findElementByIdPattern(doc, /^store(?:-a|A)rea$/);\n if (twine1Data) {\n decompileTwine1(twine1Data, story, diagnostics);\n return { story, diagnostics };\n }\n\n diagnostics.push({ level: 'error', message: 'Malformed HTML source; story data not found.' });\n return { story, diagnostics };\n}\n\nfunction decompileTwine2(storyData: HtmlNode, story: import('./types.js').Story, diagnostics: Diagnostic[]): void {\n // Parse tw-storydata attributes.\n let startnode = 0;\n const attrs = storyData.attribs ?? {};\n\n if (attrs['name']) story.name = attrs['name'];\n if (attrs['startnode']) {\n const parsed = parseInt(attrs['startnode'], 10);\n if (Number.isNaN(parsed)) {\n diagnostics.push({\n level: 'warning',\n message: `Cannot parse \"tw-storydata\" content attribute \"startnode\" as an integer; value \"${attrs['startnode']}\".`,\n });\n } else {\n startnode = parsed;\n }\n }\n if (attrs['ifid']) story.ifid = attrs['ifid'].toUpperCase() as IFID;\n if (attrs['zoom']) {\n const parsed = parseFloat(attrs['zoom']);\n if (Number.isNaN(parsed)) {\n diagnostics.push({\n level: 'warning',\n message: `Cannot parse \"tw-storydata\" content attribute \"zoom\" as a float; value \"${attrs['zoom']}\".`,\n });\n } else {\n story.twine2.zoom = parsed;\n }\n }\n if (attrs['tags']) story.twine2.tags = attrs['tags'];\n if (attrs['format']) story.twine2.format = attrs['format'];\n if (attrs['format-version']) story.twine2.formatVersion = attrs['format-version'];\n if (attrs['options']) {\n for (const opt of attrs['options'].split(/\\s+/).filter((s: string) => s.length > 0)) {\n story.twine2.options.set(opt, true);\n }\n }\n\n // Process child elements.\n // htmlparser2 uses type 'style'/'script' for those elements instead of 'tag'.\n for (const node of storyData.children ?? []) {\n if (node.type !== 'tag' && node.type !== 'style' && node.type !== 'script') continue;\n\n switch (node.name) {\n case 'style':\n case 'script': {\n const text = getTextContent(node).trim();\n if (text.length === 0) continue;\n const name = node.name === 'style' ? 'Story Stylesheet' : 'Story JavaScript';\n const tags = node.name === 'style' ? ['stylesheet'] : ['script'];\n storyAdd(story, { name, tags, text }, diagnostics);\n break;\n }\n\n case 'tw-tag': {\n const tagAttrs = node.attribs ?? {};\n const tagName = tagAttrs['name'] ?? '';\n const tagColor = tagAttrs['color'] ?? '';\n if (tagName) story.twine2.tagColors.set(tagName, tagColor);\n break;\n }\n\n case 'tw-passagedata': {\n let pid = 0;\n const pAttrs = node.attribs ?? {};\n const name = pAttrs['name'] ?? '';\n const tags = pAttrs['tags'] ? pAttrs['tags'].split(/\\s+/).filter((s: string) => s.length > 0) : [];\n const metadata: PassageMetadata = {};\n\n if (pAttrs['pid']) {\n const parsed = parseInt(pAttrs['pid'], 10);\n if (Number.isNaN(parsed)) {\n diagnostics.push({\n level: 'warning',\n message: `Cannot parse \"tw-passagedata\" content attribute \"pid\" as an integer; value \"${pAttrs['pid']}\".`,\n });\n } else {\n pid = parsed;\n }\n }\n\n if (pAttrs['position']) metadata.position = pAttrs['position'];\n if (pAttrs['size']) metadata.size = pAttrs['size'];\n\n if (pid === startnode && pid !== 0) {\n story.twine2.start = name;\n }\n\n const text = getTextContent(node).trim();\n const passage: Passage = { name, tags, text };\n if (metadata.position || metadata.size) {\n passage.metadata = metadata;\n }\n storyAdd(story, passage, diagnostics);\n break;\n }\n }\n }\n\n // Prepend StoryData passage with serialized metadata.\n storyPrepend(story, { name: 'StoryData', tags: [], text: marshalStoryData(story) }, diagnostics);\n}\n\nfunction decompileTwine1(storeArea: HtmlNode, story: import('./types.js').Story, diagnostics: Diagnostic[]): void {\n const passages = (storeArea.children ?? []).filter(isTiddler).map(tiddlerToPassage);\n\n // The Twine 1 writer ROT13-encodes every tiddler but StorySettings when StorySettings says\n // `obfuscate:rot13`, so read the settings before adding (and so interpreting) anything else.\n const obfuscated = isRot13Obfuscated(passages);\n for (const p of passages) {\n const passage = obfuscated && p.name !== 'StorySettings' ? { ...p, text: rot13(p.text) } : p;\n storyAdd(story, passage, diagnostics);\n }\n}\n\nfunction isTiddler(node: HtmlNode): boolean {\n return node.type === 'tag' && node.name === 'div' && node.attribs !== undefined && 'tiddler' in node.attribs;\n}\n\nfunction tiddlerToPassage(node: HtmlNode): Passage {\n const nodeAttrs = node.attribs ?? {};\n const name = nodeAttrs['tiddler'] ?? '';\n const tags = nodeAttrs['tags'] ? nodeAttrs['tags'].split(/\\s+/).filter((s: string) => s.length > 0) : [];\n const text = tiddlerUnescape(getTextContent(node)).trim();\n\n const passage: Passage = { name, tags, text };\n const position = nodeAttrs['twine-position'];\n if (position) {\n passage.metadata = { position };\n }\n return passage;\n}\n\n/** Whether the StorySettings tiddlers turn on ROT13 obfuscation, read the way the writer reads them. */\nfunction isRot13Obfuscated(passages: readonly Passage[]): boolean {\n const settings = createStory();\n for (const p of passages) {\n // Diagnostics are dropped here; storyAdd() reports them when the passage is added.\n if (p.name === 'StorySettings') unmarshalStorySettings(settings, p.text, []);\n }\n return settings.twine1.settings.get('obfuscate') === 'rot13';\n}\n\nfunction findElement(node: HtmlNode, tagName: string): HtmlNode | undefined {\n if (node.type === 'tag' && node.name === tagName) return node;\n for (const child of node.children ?? []) {\n const found = findElement(child, tagName);\n if (found) return found;\n }\n return undefined;\n}\n\nfunction findElementByIdPattern(node: HtmlNode, idPattern: RegExp): HtmlNode | undefined {\n if (node.type === 'tag' && node.attribs?.['id'] && idPattern.test(node.attribs['id'])) return node;\n for (const child of node.children ?? []) {\n const found = findElementByIdPattern(child, idPattern);\n if (found) return found;\n }\n return undefined;\n}\n\nfunction getTextContent(el: HtmlNode): string {\n let text = '';\n for (const child of el.children ?? []) {\n if (child.type === 'text' && child.data) {\n text += child.data;\n }\n }\n return text;\n}\n","/**\n * File loading: dispatch by file extension.\n * Ported from storyload.go.\n */\nimport { basename } from 'node:path';\nimport { statSync } from 'node:fs';\nimport type { Story, Diagnostic, InlineSource, Passage, FileCacheEntry } from './types.js';\nimport { normalizedFileExt, mediaTypeFromFilename, mediaTypeFromExt, fontFormatHint } from './media-types.js';\nimport { storyAdd, storyHas, storyPrepend } from './story.js';\nimport { parseTwee } from './parser.js';\nimport { decompileHTML } from './html-parser.js';\nimport { readUTF8, readBase64, baseNameWithoutExt } from './util.js';\nimport { normalizeSourceText } from './source-text.js';\n\ninterface LoadOptions {\n trim?: boolean;\n twee2Compat?: boolean;\n}\n\n/**\n * Load all source files into a story.\n */\nexport function loadSources(\n story: Story,\n filenames: string[],\n opts: LoadOptions,\n diagnostics: Diagnostic[],\n processedFiles: Set<string>,\n): void {\n for (const filename of filenames) {\n if (processedFiles.has(filename)) {\n diagnostics.push({ level: 'warning', message: `load ${filename}: Skipping duplicate.` });\n continue;\n }\n\n const ext = normalizedFileExt(filename);\n try {\n switch (ext) {\n case 'tw':\n case 'twee':\n loadTwee(story, filename, opts, diagnostics);\n break;\n case 'tw2':\n case 'twee2':\n loadTwee(story, filename, { ...opts, twee2Compat: true }, diagnostics);\n break;\n case 'htm':\n case 'html':\n loadHTML(story, filename, diagnostics);\n break;\n case 'css':\n loadTagged(story, 'stylesheet', filename, diagnostics);\n break;\n case 'js':\n loadTagged(story, 'script', filename, diagnostics);\n break;\n case 'otf':\n case 'ttf':\n case 'woff':\n case 'woff2':\n loadFont(story, filename, diagnostics);\n break;\n case 'gif':\n case 'jpeg':\n case 'jpg':\n case 'png':\n case 'svg':\n case 'tif':\n case 'tiff':\n case 'webp':\n loadMedia(story, 'Twine.image', filename, diagnostics);\n break;\n case 'aac':\n case 'flac':\n case 'm4a':\n case 'mp3':\n case 'oga':\n case 'ogg':\n case 'opus':\n case 'wav':\n case 'wave':\n case 'weba':\n loadMedia(story, 'Twine.audio', filename, diagnostics);\n break;\n case 'mp4':\n case 'ogv':\n case 'webm':\n loadMedia(story, 'Twine.video', filename, diagnostics);\n break;\n case 'vtt':\n loadMedia(story, 'Twine.vtt', filename, diagnostics);\n break;\n default:\n continue;\n }\n } catch (e) {\n diagnostics.push({\n level: 'error',\n message: `load ${filename}: ${e instanceof Error ? e.message : String(e)}`,\n file: filename,\n });\n continue;\n }\n processedFiles.add(filename);\n }\n\n // Prepend StoryTitle if we have a name but no StoryTitle passage.\n if (story.name !== '' && !story.passages.some((p) => p.name === 'StoryTitle')) {\n storyPrepend(story, { name: 'StoryTitle', tags: [], text: story.name }, diagnostics);\n }\n}\n\n/**\n * Load inline sources (string content or InlineSource objects).\n */\nexport function loadInlineSources(\n story: Story,\n sources: (string | InlineSource)[],\n opts: LoadOptions,\n diagnostics: Diagnostic[],\n): void {\n for (const source of sources) {\n if (typeof source === 'string') {\n // Treat as a file path — handled externally\n continue;\n }\n // Normalize like readUTF8() does for files, so in-memory and on-disk sources load the same.\n const content = normalizeSourceText(\n typeof source.content === 'string' ? source.content : source.content.toString('utf-8'),\n );\n\n const ext = normalizedFileExt(source.filename);\n switch (ext) {\n case '':\n case 'tw':\n case 'twee':\n case 'tw2':\n case 'twee2': {\n const twee2 = ext === 'tw2' || ext === 'twee2' || opts.twee2Compat;\n const result = parseTwee(content, {\n filename: source.filename,\n trim: opts.trim ?? true,\n twee2Compat: twee2,\n });\n diagnostics.push(...result.diagnostics);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n break;\n }\n case 'css':\n storyAdd(story, { name: basename(source.filename), tags: ['stylesheet'], text: content }, diagnostics);\n break;\n case 'js':\n storyAdd(story, { name: basename(source.filename), tags: ['script'], text: content }, diagnostics);\n break;\n default:\n diagnostics.push({\n level: 'warning',\n message: `load ${source.filename}: in-memory sources of type .${ext} are not supported; skipped.`,\n });\n }\n }\n}\n\ninterface ParseResult {\n passages: Passage[];\n diagnostics: Diagnostic[];\n}\n\nfunction parseTweeFile(filename: string, opts: LoadOptions): ParseResult {\n const source = readUTF8(filename);\n const result = parseTwee(source, {\n filename,\n trim: opts.trim ?? true,\n twee2Compat: opts.twee2Compat ?? false,\n });\n return { passages: result.passages, diagnostics: [...result.diagnostics] };\n}\n\nfunction parseTaggedFile(tag: string, filename: string): ParseResult {\n const source = readUTF8(filename);\n return { passages: [{ name: basename(filename), tags: [tag], text: source }], diagnostics: [] };\n}\n\nfunction parseMediaFile(tag: string, filename: string): ParseResult {\n const source = readBase64(filename);\n const name = baseNameWithoutExt(filename);\n return {\n passages: [{ name, tags: [tag], text: `data:${mediaTypeFromFilename(filename)};base64,${source}` }],\n diagnostics: [],\n };\n}\n\nfunction parseFontFile(filename: string): ParseResult {\n const source = readBase64(filename);\n const name = basename(filename);\n const family = baseNameWithoutExt(filename);\n const ext = normalizedFileExt(filename);\n const mediaType = mediaTypeFromExt(ext);\n const hint = fontFormatHint(ext);\n return {\n passages: [\n {\n name,\n tags: ['stylesheet'],\n text: `@font-face {\\n\\tfont-family: \"${family}\";\\n\\tsrc: url(\"data:${mediaType};base64,${source}\") format(\"${hint}\");\\n}`,\n },\n ],\n diagnostics: [],\n };\n}\n\nfunction parseHTMLFile(filename: string): ParseResult {\n const { story, diagnostics } = decompileHTML(readUTF8(filename));\n // Twine 2 HTML keeps the story name in an attribute, not a passage. Only passages reach the\n // outer story (and the cache), so carry the name as a StoryTitle passage, as Twine 1 HTML does.\n const passages =\n story.name !== '' && !storyHas(story, 'StoryTitle')\n ? [{ name: 'StoryTitle', tags: [], text: story.name }, ...story.passages]\n : story.passages;\n return { passages, diagnostics: [...diagnostics] };\n}\n\n/**\n * Identity of the options that affect how a file parses, stored on its cache entry.\n * Only Twee files depend on them; every other file type yields the same key for all options.\n */\nfunction parseOptionsKey(filename: string, opts: LoadOptions): string {\n const ext = normalizedFileExt(filename);\n const twee2File = ext === 'tw2' || ext === 'twee2';\n if (!twee2File && ext !== 'tw' && ext !== 'twee') return '';\n return JSON.stringify({ trim: opts.trim ?? true, twee2Compat: twee2File || (opts.twee2Compat ?? false) });\n}\n\nfunction parseFile(filename: string, opts: LoadOptions): ParseResult | undefined {\n const ext = normalizedFileExt(filename);\n switch (ext) {\n case 'tw':\n case 'twee':\n return parseTweeFile(filename, opts);\n case 'tw2':\n case 'twee2':\n return parseTweeFile(filename, { ...opts, twee2Compat: true });\n case 'htm':\n case 'html':\n return parseHTMLFile(filename);\n case 'css':\n return parseTaggedFile('stylesheet', filename);\n case 'js':\n return parseTaggedFile('script', filename);\n case 'otf':\n case 'ttf':\n case 'woff':\n case 'woff2':\n return parseFontFile(filename);\n case 'gif':\n case 'jpeg':\n case 'jpg':\n case 'png':\n case 'svg':\n case 'tif':\n case 'tiff':\n case 'webp':\n return parseMediaFile('Twine.image', filename);\n case 'aac':\n case 'flac':\n case 'm4a':\n case 'mp3':\n case 'oga':\n case 'ogg':\n case 'opus':\n case 'wav':\n case 'wave':\n case 'weba':\n return parseMediaFile('Twine.audio', filename);\n case 'mp4':\n case 'ogv':\n case 'webm':\n return parseMediaFile('Twine.video', filename);\n case 'vtt':\n return parseMediaFile('Twine.vtt', filename);\n default:\n return undefined;\n }\n}\n\nfunction loadHTML(story: Story, filename: string, diagnostics: Diagnostic[]): void {\n const result = parseHTMLFile(filename);\n diagnostics.push(...result.diagnostics);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n}\n\nfunction loadTwee(story: Story, filename: string, opts: LoadOptions, diagnostics: Diagnostic[]): void {\n const result = parseTweeFile(filename, opts);\n diagnostics.push(...result.diagnostics);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n}\n\nfunction loadTagged(story: Story, tag: string, filename: string, diagnostics: Diagnostic[]): void {\n const result = parseTaggedFile(tag, filename);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n}\n\nfunction loadMedia(story: Story, tag: string, filename: string, diagnostics: Diagnostic[]): void {\n const result = parseMediaFile(tag, filename);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n}\n\nfunction loadFont(story: Story, filename: string, diagnostics: Diagnostic[]): void {\n const result = parseFontFile(filename);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n}\n\n/**\n * Load sources with mtime-based caching for incremental rebuilds.\n * Always creates a fresh Story; cached passages are replayed via storyAdd().\n */\nexport function loadSourcesCached(\n story: Story,\n filenames: string[],\n opts: LoadOptions,\n diagnostics: Diagnostic[],\n processedFiles: Set<string>,\n cache: Map<string, FileCacheEntry>,\n changedFiles?: ReadonlySet<string>,\n): void {\n const currentFiles = new Set<string>();\n\n for (const filename of filenames) {\n if (processedFiles.has(filename)) {\n diagnostics.push({ level: 'warning', message: `load ${filename}: Skipping duplicate.` });\n continue;\n }\n\n currentFiles.add(filename);\n const optionsKey = parseOptionsKey(filename, opts);\n // An entry parsed under other options (or without a recorded key) is stale.\n const entry = cache.get(filename);\n const cached = entry?.parseOptionsKey === optionsKey ? entry : undefined;\n\n // If changedFiles is provided and this file isn't changed and we have a cache hit, skip stat\n if (changedFiles && cached && !changedFiles.has(filename)) {\n diagnostics.push(...cached.diagnostics);\n for (const p of cached.passages) {\n storyAdd(story, p, diagnostics);\n }\n processedFiles.add(filename);\n continue;\n }\n\n // stat the file to check mtime\n let mtimeMs: number;\n try {\n mtimeMs = statSync(filename).mtimeMs;\n } catch {\n // File may have been deleted between getFilenames and here\n continue;\n }\n\n // Cache hit with matching mtime: replay\n if (cached && cached.mtimeMs === mtimeMs) {\n diagnostics.push(...cached.diagnostics);\n for (const p of cached.passages) {\n storyAdd(story, p, diagnostics);\n }\n processedFiles.add(filename);\n continue;\n }\n\n // Cache miss: parse and store\n try {\n const result = parseFile(filename, opts);\n if (!result) continue;\n\n cache.set(filename, {\n mtimeMs,\n parseOptionsKey: optionsKey,\n passages: result.passages,\n diagnostics: result.diagnostics,\n });\n\n diagnostics.push(...result.diagnostics);\n for (const p of result.passages) {\n storyAdd(story, p, diagnostics);\n }\n } catch (e) {\n diagnostics.push({\n level: 'error',\n message: `load ${filename}: ${e instanceof Error ? e.message : String(e)}`,\n file: filename,\n });\n continue;\n }\n processedFiles.add(filename);\n }\n\n // Purge cache entries for deleted files\n for (const key of cache.keys()) {\n if (!currentFiles.has(key)) {\n cache.delete(key);\n }\n }\n\n // Prepend StoryTitle if we have a name but no StoryTitle passage.\n if (story.name !== '' && !story.passages.some((p) => p.name === 'StoryTitle')) {\n storyPrepend(story, { name: 'StoryTitle', tags: [], text: story.name }, diagnostics);\n }\n}\n","/**\n * The twee-ts version, read at runtime from the package's own package.json.\n *\n * The release workflow (semantic-release) writes the new version into the\n * published package.json only; git keeps the old one. Reading it at runtime\n * is the only way the CLI and `creator-version` report the published version.\n */\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst PACKAGE_NAME = '@rohal12/twee-ts';\n\n/** Walks up from `startDir` to the nearest package.json named @rohal12/twee-ts and returns its version. */\nexport function findPackageVersion(startDir: string): string | undefined {\n let dir = startDir;\n for (;;) {\n try {\n const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8')) as { name?: unknown; version?: unknown };\n if (pkg.name === PACKAGE_NAME && typeof pkg.version === 'string') return pkg.version;\n } catch {\n // No readable package.json here; keep walking up.\n }\n const parent = dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\n/** This module's directory: `__dirname` in the CJS build, `import.meta.url` in ESM and in source. */\nfunction moduleDir(): string {\n return typeof __dirname === 'string' ? __dirname : dirname(fileURLToPath(import.meta.url));\n}\n\nexport const VERSION: string = findPackageVersion(moduleDir()) ?? '0.0.0';\n","/**\n * Twine 2 HTML and archive output.\n * Ported from storyout.go.\n */\nimport type { OmittingTag, PassageOmission, ReadonlyStory, ReadonlyPassage, StoryFormatInfo } from './types.js';\nimport {\n attrEscape,\n htmlEscape,\n commentSanitize,\n htmlCommentSanitize,\n scriptContentEscape,\n styleContentEscape,\n} from './escape.js';\nimport { passageToPassagedata, hasTag } from './passage.js';\nimport { readFormatSource } from './formats.js';\nimport { VERSION } from './version.js';\n\nconst CREATOR_NAME = 'Twee-ts';\n\nexport function toTwine2Archive(\n story: ReadonlyStory,\n startName: string,\n options?: { readonly sourceInfo?: boolean },\n): string {\n return getTwine2DataChunk(story, startName, options) + '\\n';\n}\n\nexport function toTwine2HTML(\n story: ReadonlyStory,\n format: StoryFormatInfo,\n startName: string,\n options?: { readonly sourceInfo?: boolean },\n): string {\n let template = readFormatSource(format);\n\n if (template.includes('{{STORY_NAME}}')) {\n const name = htmlEscape(story.name);\n template = template.replaceAll('{{STORY_NAME}}', () => name);\n }\n if (template.includes('{{STORY_DATA}}')) {\n // Advertise the format this HTML was built with (as Tweego does), not whatever StoryData named.\n const built = { ...story, twine2: { ...story.twine2, format: format.name, formatVersion: format.version } };\n const data = getTwine2DataChunk(built, startName, options);\n template = template.replace('{{STORY_DATA}}', () => data);\n }\n\n return template;\n}\n\nconst OMITTING_TAGS: readonly OmittingTag[] = ['Twine.private', 'script', 'stylesheet'];\n\n/**\n * Why Twine 2 output leaves a passage out of its `<tw-passagedata>` elements,\n * or `undefined` when the passage is emitted (and so can be the starting passage).\n */\nexport function twine2PassageOmission(story: ReadonlyStory, p: ReadonlyPassage): PassageOmission | undefined {\n if (p.name === 'StoryTitle' || p.name === 'StoryData') return { kind: 'special-name', name: p.name };\n const tag = OMITTING_TAGS.find((t) => hasTag(p, t));\n if (tag !== undefined) return { kind: 'tag', tag };\n // Drop empty StorySettings\n if (p.name === 'StorySettings' && story.twine1.settings.size === 0) return { kind: 'empty-story-settings' };\n return undefined;\n}\n\nfunction getTwine2DataChunk(\n story: ReadonlyStory,\n startName: string,\n options?: { readonly sourceInfo?: boolean },\n): string {\n const parts: string[] = [];\n let startID = '';\n let pid = 0;\n\n // Gather script and stylesheet passages.\n const scripts: ReadonlyPassage[] = [];\n const stylesheets: ReadonlyPassage[] = [];\n for (const p of story.passages) {\n if (hasTag(p, 'Twine.private')) continue;\n if (hasTag(p, 'script')) scripts.push(p);\n else if (hasTag(p, 'stylesheet')) stylesheets.push(p);\n }\n\n // Style element\n let styleContent = '';\n if (stylesheets.length === 1) {\n styleContent = stylesheets[0]?.text ?? '';\n } else if (stylesheets.length > 1) {\n let pidS = 1;\n for (const p of stylesheets) {\n if (pidS > 1 && !styleContent.endsWith('\\n')) styleContent += '\\n';\n styleContent += `/* twine-user-stylesheet #${pidS}: \"${commentSanitize(p.name)}\" */\\n`;\n styleContent += p.text;\n pidS++;\n }\n }\n parts.push(\n `<style role=\"stylesheet\" id=\"twine-user-stylesheet\" type=\"text/twine-css\">${styleContentEscape(styleContent)}</style>`,\n );\n\n // Script element\n let scriptContent = '';\n if (scripts.length === 1) {\n scriptContent = scripts[0]?.text ?? '';\n } else if (scripts.length > 1) {\n let pidS = 1;\n for (const p of scripts) {\n if (pidS > 1 && !scriptContent.endsWith('\\n')) scriptContent += '\\n';\n scriptContent += `/* twine-user-script #${pidS}: \"${commentSanitize(p.name)}\" */\\n`;\n scriptContent += p.text;\n pidS++;\n }\n }\n parts.push(\n `<script role=\"script\" id=\"twine-user-script\" type=\"text/twine-javascript\">${scriptContentEscape(scriptContent)}</script>`,\n );\n\n // Tag color elements (only spec-valid colors: 7 named colors or hex values)\n const validTagColors = new Set(['gray', 'red', 'orange', 'yellow', 'green', 'blue', 'purple']);\n const hexColorPattern = /^#[0-9a-fA-F]{3,8}$/;\n for (const [tag, color] of story.twine2.tagColors) {\n if (validTagColors.has(color) || hexColorPattern.test(color)) {\n parts.push(`<tw-tag name=\"${attrEscape(tag)}\" color=\"${attrEscape(color)}\"></tw-tag>`);\n }\n }\n\n // Normal passage elements\n pid = 1;\n for (const p of story.passages) {\n if (twine2PassageOmission(story, p) !== undefined) continue;\n\n parts.push(passageToPassagedata(p, pid, options));\n if (startName === p.name) {\n startID = String(pid);\n }\n pid++;\n }\n\n // Build options string\n const opts: string[] = [];\n for (const [opt, val] of story.twine2.options) {\n if (val) opts.push(opt);\n }\n const optionsStr = opts.join(' ');\n\n // Wrap in tw-storydata\n const zoom = String(story.twine2.zoom);\n\n const wrapper =\n `<!-- UUID://${htmlCommentSanitize(story.ifid)}// -->` +\n `<tw-storydata name=\"${attrEscape(story.name)}\" startnode=\"${attrEscape(startID)}\" ` +\n `creator=\"${attrEscape(CREATOR_NAME)}\" creator-version=\"${attrEscape(VERSION)}\" ` +\n `ifid=\"${attrEscape(story.ifid)}\" zoom=\"${attrEscape(zoom)}\" ` +\n `format=\"${attrEscape(story.twine2.format)}\" ` +\n `format-version=\"${attrEscape(story.twine2.formatVersion)}\" ` +\n `options=\"${attrEscape(optionsStr)}\" tags=\"${attrEscape(story.twine2.tags)}\" hidden>`;\n\n return wrapper + parts.join('') + '</tw-storydata>';\n}\n","/**\n * Twine 1 HTML and archive output.\n * Ported from storyout.go.\n */\nimport { readFileSync } from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport type { PassageOmission, ReadonlyPassage, ReadonlyStory, StoryFormatInfo } from './types.js';\nimport { hasTag, passageToTiddler } from './passage.js';\nimport { readFormatSource } from './formats.js';\nimport { jsStringEscape, htmlCommentSanitize } from './escape.js';\nimport { VERSION } from './version.js';\n\nconst CREATOR_NAME = 'twee-ts';\n\nexport function toTwine1Archive(story: ReadonlyStory, _startName: string): string {\n const { data, count } = getTwine1PassageChunk(story);\n return `<div id=\"storeArea\" data-size=\"${count}\">${data}</div>\\n`;\n}\n\nexport function toTwine1HTML(story: ReadonlyStory, format: StoryFormatInfo, startName: string): string {\n const formatDir = dirname(format.filename);\n const parentDir = dirname(formatDir);\n let template = readFormatSource(format);\n const { data, count } = getTwine1PassageChunk(story);\n\n // Component replacements\n template = tryReplaceComponent(template, '\"USER_LIB\"', join(formatDir, 'userlib.js'), false);\n template = tryReplaceComponent(template, '\"ENGINE\"', join(parentDir, 'engine.js'), true);\n template = tryReplaceComponent(template, '\"SUGARCANE\"', join(formatDir, 'code.js'), true);\n template = tryReplaceComponent(template, '\"JONAH\"', join(formatDir, 'code.js'), true);\n\n if (story.twine1.settings.get('jquery') === 'on') {\n template = tryReplaceComponent(template, '\"JQUERY\"', join(parentDir, 'jquery.js'), true);\n }\n if (story.twine1.settings.get('modernizr') === 'on') {\n template = tryReplaceComponent(template, '\"MODERNIZR\"', join(parentDir, 'modernizr.js'), true);\n }\n\n // Story instance replacements\n const displayStart = startName === 'Start' ? '' : startName;\n template = template.replace('\"VERSION\"', `Compiled with ${CREATOR_NAME}, ${VERSION}`);\n template = template.replace('\"TIME\"', `Built on ${new Date().toUTCString()}`);\n const startAtValue = `\"${jsStringEscape(displayStart)}\"`;\n template = template.replace('\"START_AT\"', () => startAtValue);\n template = template.replace('\"STORY_SIZE\"', `\"${count}\"`);\n\n if (template.includes('\"STORY\"')) {\n template = template.replace('\"STORY\"', () => data);\n } else {\n // Pre-1.4 format: append data + footer\n let footer: string;\n try {\n footer = readFileSync(join(formatDir, 'footer.html'), 'utf-8');\n } catch {\n footer = '</div>\\n</body>\\n</html>\\n';\n }\n template += data + footer;\n }\n\n // IFID replacement\n if (story.ifid) {\n const safeIfid = htmlCommentSanitize(story.ifid);\n if (template.includes('<div id=\"store-area\"')) {\n template = template.replace('<div id=\"store-area\"', `<!-- UUID://${safeIfid}// --><div id=\"store-area\"`);\n } else {\n template = template.replace('<div id=\"storeArea\"', `<!-- UUID://${safeIfid}// --><div id=\"storeArea\"`);\n }\n }\n\n return template;\n}\n\n/**\n * Why Twine 1 output leaves a passage out of its tiddlers, or `undefined` when the passage is emitted.\n */\nexport function twine1PassageOmission(p: ReadonlyPassage): PassageOmission | undefined {\n return hasTag(p, 'Twine.private') ? { kind: 'tag', tag: 'Twine.private' } : undefined;\n}\n\nfunction getTwine1PassageChunk(story: ReadonlyStory): { data: string; count: number } {\n const obfuscateRot13 = story.twine1.settings.get('obfuscate') === 'rot13';\n let data = '';\n let count = 0;\n\n for (const p of story.passages) {\n if (twine1PassageOmission(p) !== undefined) continue;\n count++;\n data += passageToTiddler(p, count, obfuscateRot13);\n }\n\n return { data, count };\n}\n\nfunction tryReplaceComponent(template: string, placeholder: string, componentPath: string, required: boolean): string {\n if (!template.includes(placeholder)) return template;\n try {\n let content = readFileSync(componentPath, 'utf-8');\n if (content.charCodeAt(0) === 0xfeff) content = content.slice(1);\n return template.replace(placeholder, () => content);\n } catch (e) {\n if (required) {\n throw new Error(\n `Required format component not found: ${componentPath}: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n return template;\n }\n}\n","/**\n * Twee 3/1 decompile output.\n * Ported from storyout.go.\n */\nimport type { ReadonlyStory, OutputMode } from './types.js';\nimport { passageToTwee } from './passage.js';\n\nexport function toTwee(story: ReadonlyStory, outMode: OutputMode): string {\n let data = '';\n for (const p of story.passages) {\n data += passageToTwee(p, outMode);\n }\n return data;\n}\n","/**\n * Module/head injection into <head>.\n * Ported from module.go + io.go:modifyHead().\n */\nimport type { Diagnostic } from './types.js';\nimport { normalizedFileExt, mediaTypeFromExt, fontFormatHint, slugify } from './media-types.js';\nimport { readUTF8, readBase64, baseNameWithoutExt } from './util.js';\nimport { scriptContentEscape, styleContentEscape } from './escape.js';\n\n/**\n * Load modules and return HTML tags to inject before </head>.\n */\nexport function loadModules(filenames: string[]): string {\n const processed = new Set<string>();\n const headTags: string[] = [];\n\n for (const filename of filenames) {\n if (processed.has(filename)) continue;\n\n const ext = normalizedFileExt(filename);\n let tag: string | null = null;\n\n switch (ext) {\n case 'css':\n tag = loadModuleTagged('style', filename);\n break;\n case 'js':\n tag = loadModuleTagged('script', filename);\n break;\n case 'otf':\n case 'ttf':\n case 'woff':\n case 'woff2':\n tag = loadModuleFont(filename);\n break;\n default:\n continue;\n }\n\n if (tag) headTags.push(tag);\n processed.add(filename);\n }\n\n return headTags.join('\\n');\n}\n\nfunction loadModuleTagged(tag: 'script' | 'style', filename: string): string | null {\n const source = readUTF8(filename).trim();\n if (source.length === 0) return null;\n\n const family = baseNameWithoutExt(filename);\n const idSlug = `${tag}-module-${slugify(family)}`;\n const mimeType = tag === 'script' ? 'text/javascript' : 'text/css';\n const content = tag === 'script' ? scriptContentEscape(source) : styleContentEscape(source);\n\n return `<${tag} id=\"${idSlug}\" type=\"${mimeType}\">${content}</${tag}>`;\n}\n\nfunction loadModuleFont(filename: string): string | null {\n const source = readBase64(filename);\n const family = baseNameWithoutExt(filename);\n const idSlug = `style-module-${slugify(family)}`;\n const ext = normalizedFileExt(filename);\n const mediaType = mediaTypeFromExt(ext);\n const hint = fontFormatHint(ext);\n\n return `<style id=\"${idSlug}\" type=\"text/css\">@font-face {\\n\\tfont-family: \"${family}\";\\n\\tsrc: url(\"data:${mediaType};base64,${source}\") format(\"${hint}\");\\n}</style>`;\n}\n\n/**\n * Inject modules and head file content before </head>.\n */\nexport function modifyHead(html: string, modulePaths: string[], headFile?: string, diagnostics?: Diagnostic[]): string {\n const parts: string[] = [];\n\n if (modulePaths.length > 0) {\n const modules = loadModules(modulePaths).trim();\n if (modules.length > 0) parts.push(modules);\n }\n\n if (headFile) {\n try {\n const source = readUTF8(headFile).trim();\n if (source.length > 0) parts.push(source);\n } catch (e) {\n diagnostics?.push({\n level: 'warning',\n message: `Failed to read head file \"${headFile}\": ${e instanceof Error ? e.message : String(e)}`,\n });\n }\n }\n\n if (parts.length > 0) {\n parts.push('</head>');\n const replacement = parts.join('\\n');\n return html.replace('</head>', () => replacement);\n }\n return html;\n}\n","/**\n * Starting passage validation: the effective start must exist and be a\n * passage that the output actually emits, or the story has nowhere to begin.\n */\nimport type { Diagnostic, PassageOmission, ReadonlyPassage, ReadonlyStory } from './types.js';\nimport { twine2PassageOmission } from './output-twine2.js';\nimport { twine1PassageOmission } from './output-twine1.js';\n\n/** Which output's passage rules decide whether the start passage is emitted. */\nexport type StartPassageTarget = 'twine1' | 'twine2';\n\nfunction describeOmission(omission: PassageOmission): string {\n switch (omission.kind) {\n case 'special-name':\n return `is the special \"${omission.name}\" passage`;\n case 'tag':\n return `is tagged \"${omission.tag}\"`;\n case 'empty-story-settings':\n return 'is an empty \"StorySettings\" passage';\n default: {\n const _exhaustive: never = omission;\n throw new Error(`unhandled passage omission: ${JSON.stringify(_exhaustive)}`);\n }\n }\n}\n\nfunction omissionFor(\n story: ReadonlyStory,\n passage: ReadonlyPassage,\n target: StartPassageTarget,\n): PassageOmission | undefined {\n switch (target) {\n case 'twine2':\n return twine2PassageOmission(story, passage);\n case 'twine1':\n return twine1PassageOmission(passage);\n default: {\n const _exhaustive: never = target;\n throw new Error(`unhandled start passage target: ${String(_exhaustive)}`);\n }\n }\n}\n\n/**\n * Check that `startName` names a passage the `target` output emits.\n * Returns the error diagnostics to report (empty when the start is usable).\n */\nexport function startPassageDiagnostics(\n story: ReadonlyStory,\n startName: string,\n target: StartPassageTarget,\n): readonly Diagnostic[] {\n const passage = story.passages.find((p) => p.name === startName);\n if (passage === undefined) {\n return [{ level: 'error', message: `Starting passage \"${startName}\" not found.` }];\n }\n const omission = omissionFor(story, passage, target);\n if (omission === undefined) return [];\n return [\n {\n level: 'error',\n message: `Starting passage \"${startName}\" ${describeOmission(omission)}, so it is left out of the story data. Choose a story passage.`,\n },\n ];\n}\n","/**\n * Main compiler orchestrator.\n * compile(), compileToFile(), watch().\n * Ported from tweego.go + config.go.\n */\nimport { writeFileSync } from 'node:fs';\nimport { resolve, sep } from 'node:path';\nimport type {\n CompileOptions,\n CompileToFileOptions,\n WatchOptions,\n CompileResult,\n CompileStats,\n Diagnostic,\n Story,\n StoryFormatInfo,\n OutputMode,\n InlineSource,\n FileCacheEntry,\n} from './types.js';\nimport { createStory, storyHas, getStoryStats } from './story.js';\nimport { getFilenames, isExcluded, watchFilesystem } from './filesystem.js';\nimport { formatRequestFor, resolveStoryFormat } from './format-resolution.js';\nimport { loadSources, loadInlineSources, loadSourcesCached } from './loader.js';\nimport { applyTagAliases, hasTag } from './passage.js';\nimport { generateIFID } from './ifid.js';\nimport { toTwine2HTML, toTwine2Archive } from './output-twine2.js';\nimport { toTwine1HTML, toTwine1Archive } from './output-twine1.js';\nimport { toTwee } from './output-twee.js';\nimport { modifyHead } from './modules.js';\nimport { startPassageDiagnostics } from './start-passage.js';\nimport { clearIndexCache } from './remote-formats.js';\nimport { VERSION } from './version.js';\n\nconst CREATOR_NAME = 'Twee-ts';\n\nconst DEFAULT_FORMAT_ID = 'sugarcube-2';\nconst DEFAULT_START_NAME = 'Start';\n\nexport class TweeTsError extends Error {\n constructor(\n message: string,\n public diagnostics: Diagnostic[] = [],\n ) {\n super(message);\n this.name = 'TweeTsError';\n }\n}\n\n/**\n * Compile Twee sources to HTML, Twee, or JSON.\n */\nexport async function compile(options: CompileOptions): Promise<CompileResult> {\n return buildOutput(options);\n}\n\n/**\n * Compile and write to a file.\n */\nexport async function compileToFile(options: CompileToFileOptions): Promise<CompileResult> {\n // The output may sit inside a source folder; its last build must not be read back as a source.\n const result = await buildOutput(options, undefined, undefined, options.outFile);\n writeFileSync(options.outFile, result.output, 'utf-8');\n return result;\n}\n\n/**\n * Compile with incremental caching support.\n * Plugins and advanced users can manage their own cache and changed-file tracking.\n */\nexport async function compileIncremental(\n options: CompileOptions,\n cache: Map<string, FileCacheEntry>,\n changedFiles?: ReadonlySet<string>,\n): Promise<CompileResult> {\n return buildOutput(options, cache, changedFiles);\n}\n\n/**\n * Watch for file changes and recompile.\n */\nexport async function watch(options: WatchOptions): Promise<AbortController> {\n const controller = new AbortController();\n const cache = new Map<string, FileCacheEntry>();\n\n // Separate file paths from inline sources\n const filePaths = options.sources.filter((s): s is string => typeof s === 'string');\n const modulePaths = options.modules ?? [];\n const headPaths = options.headFile ? [options.headFile] : [];\n const allPaths = [...filePaths, ...modulePaths, ...headPaths];\n\n // A change to an excluded source builds nothing. `exclude` leaves modules and the\n // head file alone, so a module (or a file in a module folder) or the head file\n // still rebuilds when a glob matches it.\n const exclude = options.exclude ?? [];\n const notExcludable = [...modulePaths, ...headPaths].map((p) => resolve(p));\n const ignore = (filename: string): boolean => {\n if (!isExcluded(filename, exclude)) return false;\n const abs = resolve(filename);\n return !notExcludable.some((root) => abs === root || abs.startsWith(root + sep));\n };\n\n const handle = watchFilesystem(\n allPaths,\n options.outFile,\n (changedFiles) => {\n buildOutput(options, cache, changedFiles, options.outFile)\n .then((result) => {\n writeFileSync(options.outFile, result.output, 'utf-8');\n options.onBuild?.(result);\n })\n .catch((e) => {\n options.onError?.(e instanceof Error ? e : new Error(String(e)));\n });\n },\n ignore,\n );\n\n controller.signal.addEventListener('abort', () => handle.close());\n return controller;\n}\n\n/**\n * `outFile`: the file the build is written to, which source and module discovery\n * skip (as Tweego does), so an output inside a source folder is never loaded back.\n */\nasync function buildOutput(\n options: CompileOptions,\n cache?: Map<string, FileCacheEntry>,\n changedFiles?: ReadonlySet<string>,\n outFile?: string,\n): Promise<CompileResult> {\n const diagnostics: Diagnostic[] = [];\n const outputMode: OutputMode = options.outputMode ?? 'html';\n const trim = options.trim ?? true;\n const twee2Compat = options.twee2Compat ?? false;\n const testMode = options.testMode ?? false;\n const noRemote = options.noRemote ?? false;\n const sourceInfo = options.sourceInfo ?? false;\n\n // Clear per-compile index cache\n clearIndexCache();\n\n // Separate file paths from inline sources\n const filePaths: string[] = [];\n const inlineSources: InlineSource[] = [];\n for (const source of options.sources) {\n if (typeof source === 'string') {\n filePaths.push(source);\n } else {\n inlineSources.push(source);\n }\n }\n\n // Walk file paths to get all source filenames\n const { filenames: sourceFilenames, diagnostics: sourcePathDiagnostics } = getFilenames(\n filePaths,\n outFile,\n options.exclude,\n );\n diagnostics.push(...sourcePathDiagnostics);\n\n // Create story and load sources\n const story = createStory();\n const processedFiles = new Set<string>();\n\n if (cache) {\n loadSourcesCached(story, sourceFilenames, { trim, twee2Compat }, diagnostics, processedFiles, cache, changedFiles);\n } else {\n loadSources(story, sourceFilenames, { trim, twee2Compat }, diagnostics, processedFiles);\n }\n loadInlineSources(story, inlineSources, { trim, twee2Compat }, diagnostics);\n\n // Apply tag aliases (e.g. library → script)\n if (options.tagAliases) {\n story.passages = applyTagAliases(story.passages, options.tagAliases);\n }\n\n // Resolve format: explicit formatId > StoryData format > default, looked up locally,\n // in the download cache, then remotely. An unavailable request is an error, never another format.\n let format: StoryFormatInfo | undefined;\n\n if (outputMode === 'html') {\n const request = formatRequestFor(\n options.formatId,\n story.twine2.format,\n story.twine2.formatVersion,\n DEFAULT_FORMAT_ID,\n );\n format = await resolveStoryFormat(request, { ...options, noRemote }, diagnostics);\n }\n\n // Merge config from StoryData: command-line > StoryData > default.\n // An explicit override is recorded on the story so JSON output and inspection see it too.\n if (options.startPassage) story.twine2.start = options.startPassage;\n const startName = story.twine2.start || DEFAULT_START_NAME;\n\n // Apply test mode\n if (testMode) {\n story.twine2.options.set('debug', true);\n }\n\n // Ensure IFID is set before output generation\n ensureIFID(story, diagnostics);\n\n // Generate output\n let output: string;\n\n switch (outputMode) {\n case 'twee3':\n case 'twee1':\n output = toTwee(story, outputMode);\n break;\n\n case 'twine2-archive':\n output = toTwine2Archive(story, startName, { sourceInfo });\n break;\n\n case 'twine1-archive':\n output = toTwine1Archive(story, startName);\n break;\n\n case 'json':\n output = storyToJSON(story);\n break;\n\n case 'html': {\n // Sanity checks for HTML mode\n diagnostics.push(...startPassageDiagnostics(story, startName, format?.isTwine2 === false ? 'twine1' : 'twine2'));\n\n if (!format) {\n throw new TweeTsError('No story format available for HTML output.', diagnostics);\n }\n\n if (format.isTwine2) {\n output = toTwine2HTML(story, format, startName, { sourceInfo });\n } else {\n if (story.name === '' && !storyHas(story, 'StoryTitle')) {\n diagnostics.push({\n level: 'error',\n message: 'Special passage \"StoryTitle\" not found.',\n });\n }\n output = toTwine1HTML(story, format, startName);\n }\n\n // Inject modules and head file\n const modules = getFilenames(options.modules ?? [], outFile);\n diagnostics.push(...modules.diagnostics);\n output = modifyHead(output, modules.filenames, options.headFile, diagnostics);\n break;\n }\n\n default: {\n const _exhaustive: never = outputMode;\n throw new TweeTsError(`Unhandled output mode: ${_exhaustive as string}`, diagnostics);\n }\n }\n\n // Compute stats\n const stats: CompileStats = {\n ...getStoryStats(story, options.wordCountMethod),\n files: [...processedFiles],\n };\n\n return { output, story, format, diagnostics, stats };\n}\n\nfunction ensureIFID(story: Story, diagnostics: Diagnostic[]): void {\n if (story.ifid !== '') return;\n\n if (story.legacyIFID !== '') {\n story.ifid = story.legacyIFID;\n diagnostics.push({\n level: 'warning',\n message: 'Story IFID not found; reusing \"ifid\" entry from the \"StorySettings\" special passage.',\n });\n } else {\n const ifid = generateIFID();\n story.ifid = ifid;\n diagnostics.push({\n level: 'error',\n message: `Story IFID not found. Add an IFID to your story: {\"ifid\":\"${ifid}\"}`,\n });\n }\n}\n\n/**\n * Serialize a Story to JSON per the Twine 2 JSON Output Specification (v1.0):\n * https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-jsonoutput-doc.md\n */\nfunction storyToJSON(story: Story): string {\n // Gather script and stylesheet content, excluding them from passages.\n const scripts: string[] = [];\n const stylesheets: string[] = [];\n const storyPassages: { name: string; tags: string[]; text: string; metadata?: Record<string, string> }[] = [];\n\n for (const p of story.passages) {\n if (p.name === 'StoryTitle' || p.name === 'StoryData') continue;\n if (hasTag(p, 'Twine.private')) continue;\n\n if (hasTag(p, 'script')) {\n scripts.push(p.text);\n } else if (hasTag(p, 'stylesheet')) {\n stylesheets.push(p.text);\n } else {\n const entry: { name: string; tags: string[]; text: string; metadata?: Record<string, string> } = {\n name: p.name,\n tags: p.tags,\n text: p.text,\n };\n if (p.metadata) {\n const meta: Record<string, string> = {};\n for (const [key, value] of Object.entries(p.metadata)) {\n if (typeof value === 'string') meta[key] = value;\n }\n if (Object.keys(meta).length > 0) {\n entry.metadata = meta;\n }\n }\n storyPassages.push(entry);\n }\n }\n\n const obj: Record<string, unknown> = {\n name: story.name,\n };\n\n if (story.ifid) obj.ifid = story.ifid;\n if (story.twine2.format) obj.format = story.twine2.format;\n if (story.twine2.formatVersion) obj['format-version'] = story.twine2.formatVersion;\n if (story.twine2.start) obj.start = story.twine2.start;\n if (story.twine2.tagColors.size > 0) obj['tag-colors'] = Object.fromEntries(story.twine2.tagColors);\n if (story.twine2.zoom !== 1) obj.zoom = story.twine2.zoom;\n obj.creator = CREATOR_NAME;\n obj['creator-version'] = VERSION;\n obj.style = stylesheets.join('\\n');\n obj.script = scripts.join('\\n');\n obj.passages = storyPassages;\n\n return JSON.stringify(obj, null, 2);\n}\n"],"x_google_ignoreList":[15,16,17,18,19,20,21,22,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