@torpor/view 1.0.3 → 1.1.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"compile.mjs","names":["#mapped","#text","#space","isElementLike","maybeAppend","buildElementAttributes","importsMap"],"sources":["../src/compile/utils/endOfString.ts","../src/compile/utils/codeScanner.ts","../src/compile/utils/Builder.ts","../src/compile/utils/isParentNode.ts","../src/compile/utils/collectMarkupExpressions.ts","../src/compile/utils/markupRendersComponent.ts","../src/compile/build/client/addMappedText.ts","../src/compile/build/client/addPopDevBoundary.ts","../src/compile/build/client/addPushDevBoundary.ts","../src/compile/types/comments.ts","../src/compile/utils/isControlNode.ts","../src/compile/utils/isElementNode.ts","../src/compile/utils/nonRenderingOperations.ts","../src/compile/utils/getSingleElementRoot.ts","../src/compile/utils/isReactive.ts","../src/compile/utils/trimQuotes.ts","../src/compile/utils/voidTags.ts","../src/compile/build/client/buildFragmentText.ts","../src/compile/utils/bindingTarget.ts","../src/compile/utils/isSpecialNode.ts","../src/compile/build/utils/nextVarName.ts","../src/compile/build/client/addMappedTextWithOffsets.ts","../src/compile/build/client/buildAddFragment.ts","../src/compile/parse/utils/isSpaceChar.ts","../src/compile/parse/utils/isSpace.ts","../src/compile/utils/isTextNode.ts","../src/compile/build/client/buildFragment.ts","../src/compile/utils/forVarsReadIn.ts","../src/compile/build/client/replaceForVarNames.ts","../src/compile/build/client/buildRun.ts","../src/compile/build/client/getAttributeOffsets.ts","../src/compile/build/client/buildComponentNode.ts","../src/compile/build/client/buildAwaitNode.ts","../src/compile/utils/hasNestedControl.ts","../src/compile/utils/isForBodyLeafSafe.ts","../src/compile/utils/isForBodyNoProxySafe.ts","../src/compile/utils/trimMatched.ts","../src/compile/build/client/buildForNode.ts","../src/compile/build/client/buildHtmlNode.ts","../src/compile/build/client/buildIfNode.ts","../src/compile/build/client/buildReplaceNode.ts","../src/compile/build/client/buildScriptNode.ts","../src/compile/build/client/buildSwitchNode.ts","../src/compile/build/client/buildTryNode.ts","../src/compile/build/client/buildControlNode.ts","../src/compile/utils/trimEnd.ts","../src/compile/build/client/buildMount.ts","../src/compile/build/client/stashRun.ts","../src/compile/build/client/stashRunWithOffsets.ts","../src/compile/build/client/buildElementNode.ts","../src/compile/build/client/buildRootNode.ts","../src/compile/build/client/buildSlotNode.ts","../src/compile/build/client/buildSpecialNode.ts","../src/compile/build/client/buildTextNode.ts","../src/compile/build/client/buildNode.ts","../src/compile/build/client/buildCode.ts","../src/compile/build/client/buildStyles.ts","../src/compile/build/server/flushOutput.ts","../src/compile/build/server/buildServerComponentNode.ts","../src/compile/build/server/buildServerAwaitNode.ts","../src/compile/build/server/buildServerForNode.ts","../src/compile/build/server/buildServerHtmlNode.ts","../src/compile/build/server/buildServerIfNode.ts","../src/compile/build/server/buildServerReplaceNode.ts","../src/compile/build/server/buildServerScriptNode.ts","../src/compile/build/server/buildServerSwitchNode.ts","../src/compile/build/server/buildServerTryNode.ts","../src/compile/build/server/buildServerControlNode.ts","../src/compile/build/server/buildServerElementNode.ts","../src/compile/build/server/buildServerRootNode.ts","../src/compile/build/server/buildServerSlotNode.ts","../src/compile/build/server/buildServerSpecialNode.ts","../src/compile/build/server/buildServerTextNode.ts","../src/compile/build/server/buildServerNode.ts","../src/compile/build/server/buildServerCode.ts","../src/compile/utils/trimWhitespace.ts","../src/compile/build.ts","../src/compile/buildType.ts","../src/compile/utils/endOfTemplateString.ts","../src/compile/utils/isSpaceNode.ts","../src/compile/parse/utils/accept.ts","../src/compile/parse/parseInlineScript.ts","../src/compile/utils/trimStart.ts","../src/compile/parse/utils/consumeSpace.ts","../src/compile/parse/addSpaceElement.ts","../src/compile/utils/isFullyReactive.ts","../src/compile/parse/utils/addError.ts","../src/compile/parse/utils/isAlphaNumericChar.ts","../src/compile/parse/utils/consumeAlphaNumeric.ts","../src/compile/parse/utils/consumeUntil.ts","../src/compile/parse/parseTag.ts","../src/compile/parse/parseText.ts","../src/compile/parse/utils/usesSlot.ts","../src/compile/parse/slottifyChildNodes.ts","../src/compile/parse/parseElement.ts","../src/compile/parse/parseControl.ts","../src/compile/parse/parseMarkup.ts","../src/compile/utils/hash.ts","../src/compile/parse/utils/expect.ts","../src/compile/parse/parseStyles.ts","../src/compile/utils/isComponentNode.ts","../src/compile/parse/scopeStyles.ts","../src/compile/parse/parseCode.ts","../src/compile/parse.ts"],"sourcesContent":["export default function endOfString(char: string, content: string, start: number): number {\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === char && content[j - 1] !== \"\\\\\") {\n\t\t\treturn j;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import endOfString from \"./endOfString\";\n\n/**\n * Shared scanner for skipping over non-code parts of JavaScript expression\n * text: string literals, template literals (including their interpolations),\n * comments, and regex literals. Used everywhere the compiler scans\n * expression text and needs to tell code from literal text.\n *\n * Note: this is for *code* contexts. For torpor template text (where quotes\n * are literal characters and `{...}` are interpolation delimiters), use this\n * only for the *interiors* of `{...}` expressions -- the template level\n * itself has different rules.\n */\n\n// Keywords after which a `/` starts a regex literal, even though the\n// previous character is an identifier character\nconst REGEX_KEYWORDS = new Set([\n\t\"return\",\n\t\"typeof\",\n\t\"instanceof\",\n\t\"in\",\n\t\"of\",\n\t\"new\",\n\t\"delete\",\n\t\"void\",\n\t\"throw\",\n\t\"case\",\n\t\"do\",\n\t\"else\",\n\t\"yield\",\n\t\"await\",\n]);\n\n/**\n * If the character at `start` begins a string literal, a template literal, a\n * comment (line or block), or a regex literal, returns the index just after\n * it. Returns -1 if it doesn't (a `/` that is division, or any other\n * character).\n */\nexport function skipStringOrComment(value: string, start: number): number {\n\treturn skipInRange(value, start);\n}\n\n/**\n * Returns the [start, end) ranges of `value` that are code -- i.e. not the\n * contents of string literals, regex literals, or comments. Template string\n * contents are skipped, except for the contents of `${...}` interpolations,\n * which are code again.\n */\nexport function codeRanges(value: string): [number, number][] {\n\tconst ranges: [number, number][] = [];\n\tlet codeStart = 0;\n\tlet i = 0;\n\twhile (i < value.length) {\n\t\tconst next = skipInRange(value, i, ranges, codeStart);\n\t\tif (next !== -1) {\n\t\t\ti = next;\n\t\t\tcodeStart = i;\n\t\t} else {\n\t\t\ti += 1;\n\t\t}\n\t}\n\tpushRange(ranges, codeStart, value.length);\n\treturn ranges;\n}\n\n/**\n * `skipStringOrComment` with optional collection of the interrupted code\n * range (for `codeRanges`), so there is a single implementation of the scan\n * order.\n */\nfunction skipInRange(\n\tvalue: string,\n\tstart: number,\n\tranges?: [number, number][],\n\tcodeStart?: number,\n): number {\n\tconst char = value[start];\n\tif (char === \"'\" || char === '\"') {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\treturn endOfString(char, value, start) + 1;\n\t}\n\tif (char === \"`\") {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\treturn skipTemplateString(value, start, ranges);\n\t}\n\tif (char === \"/\" && value[start + 1] === \"/\") {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\tconst end = value.indexOf(\"\\n\", start + 2);\n\t\treturn end === -1 ? value.length : end;\n\t}\n\tif (char === \"/\" && value[start + 1] === \"*\") {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\tconst end = value.indexOf(\"*/\", start + 2);\n\t\treturn end === -1 ? value.length : end + 2;\n\t}\n\tif (char === \"/\" && isRegexPosition(value, start)) {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\treturn skipRegexLiteral(value, start);\n\t}\n\treturn -1;\n}\n\n/**\n * Skips over a template string, given the index of its opening backtick, and\n * returns the index just after the closing backtick. Handles escaped\n * characters, and scans `${...}` interpolations correctly (nested strings,\n * templates, comments and regexes within them can't desync the scan).\n */\nfunction skipTemplateString(value: string, start: number, ranges?: [number, number][]): number {\n\tlet i = start + 1;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\t\tif (char === \"\\\\\") {\n\t\t\t// Skip escaped characters\n\t\t\ti += 2;\n\t\t} else if (char === \"`\") {\n\t\t\treturn i + 1;\n\t\t} else if (char === \"$\" && value[i + 1] === \"{\") {\n\t\t\ti = endOfInterpolation(value, i + 2, ranges) + 1;\n\t\t} else {\n\t\t\ti += 1;\n\t\t}\n\t}\n\treturn value.length;\n}\n\n/**\n * Skips over the code inside a `${...}` interpolation, given the index just\n * after the `${`, collecting its code ranges when provided. Returns the\n * index of the matching `}`.\n */\nfunction endOfInterpolation(value: string, start: number, ranges?: [number, number][]): number {\n\tlet level = 0;\n\tlet codeStart = start;\n\tlet i = start;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel += 1;\n\t\t\ti += 1;\n\t\t} else if (char === \"}\") {\n\t\t\tif (level === 0) {\n\t\t\t\tpushRange(ranges, codeStart, i);\n\t\t\t\treturn i;\n\t\t\t}\n\t\t\tlevel -= 1;\n\t\t\ti += 1;\n\t\t} else {\n\t\t\tconst next = skipInRange(value, i, ranges, codeStart);\n\t\t\tif (next !== -1) {\n\t\t\t\ti = next;\n\t\t\t\tcodeStart = i;\n\t\t\t} else {\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t}\n\t}\n\tpushRange(ranges, codeStart, value.length);\n\treturn value.length;\n}\n\n/**\n * Decides whether the `/` at `slashIndex` starts a regex literal (rather\n * than being division), by looking at the previous significant character.\n * The standard lexical heuristic -- not a full parse, but correct for\n * real-world code.\n */\nfunction isRegexPosition(value: string, slashIndex: number): boolean {\n\tlet i = slashIndex - 1;\n\twhile (i >= 0) {\n\t\tconst char = value[i];\n\t\tif (char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\r\") {\n\t\t\ti -= 1;\n\t\t} else if (char === \"/\" && value[i - 1] === \"*\") {\n\t\t\t// Step back over a block comment\n\t\t\tconst open = value.lastIndexOf(\"/*\", i - 2);\n\t\t\tif (open === -1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ti = open - 1;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (i < 0) {\n\t\t// Start of the expression\n\t\treturn true;\n\t}\n\tconst char = value[i];\n\tif (\n\t\tchar === \")\" ||\n\t\tchar === \"]\" ||\n\t\tchar === \"}\" ||\n\t\tchar === '\"' ||\n\t\tchar === \"'\" ||\n\t\tchar === \"`\"\n\t) {\n\t\t// After a completed value -- division\n\t\treturn false;\n\t}\n\tif (/[a-z0-9_$]/i.test(char)) {\n\t\t// After an identifier or number -- division, unless it's a keyword\n\t\t// that can be followed by an expression\n\t\tlet wordStart = i;\n\t\twhile (wordStart >= 0 && /[a-z0-9_$]/i.test(value[wordStart])) {\n\t\t\twordStart -= 1;\n\t\t}\n\t\treturn REGEX_KEYWORDS.has(value.substring(wordStart + 1, i + 1));\n\t}\n\tif (char === \"+\" || char === \"-\") {\n\t\t// `a++ / 2` is division (postfix update); `x + /re/` is a regex\n\t\tif (value[i - 1] === char) {\n\t\t\tconst before = value[i - 2];\n\t\t\treturn !(before && /[a-z0-9_$)\\]]/i.test(before));\n\t\t}\n\t\treturn true;\n\t}\n\t// After any other operator or punctuation -- regex\n\treturn true;\n}\n\n/**\n * Skips over a regex literal, given the index of its opening `/`, and\n * returns the index just after its flags. Returns -1 if the literal is\n * unterminated (in which case the `/` is treated as division).\n */\nfunction skipRegexLiteral(value: string, start: number): number {\n\tlet i = start + 1;\n\tlet inClass = false;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\t\tif (char === \"\\\\\") {\n\t\t\ti += 2;\n\t\t} else if (char === \"\\n\") {\n\t\t\t// Unterminated regex -- treat the `/` as division\n\t\t\treturn -1;\n\t\t} else if (char === \"[\") {\n\t\t\tinClass = true;\n\t\t\ti += 1;\n\t\t} else if (char === \"]\") {\n\t\t\tinClass = false;\n\t\t\ti += 1;\n\t\t} else if (char === \"/\" && !inClass) {\n\t\t\t// Skip flags\n\t\t\ti += 1;\n\t\t\twhile (i < value.length && /[a-z]/i.test(value[i])) {\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t\treturn i;\n\t\t} else {\n\t\t\ti += 1;\n\t\t}\n\t}\n\treturn -1;\n}\n\nfunction pushRange(ranges: [number, number][] | undefined, start: number, end: number): void {\n\tif (ranges && end > start) {\n\t\tranges.push([start, end]);\n\t}\n}\n","import { skipStringOrComment } from \"./codeScanner\";\n\nexport default class Builder {\n\t#text = \"\";\n\t#space = 0;\n\t#mapped = false;\n\n\tlineMap: number[] = [];\n\n\tconstructor(mapped?: boolean) {\n\t\tthis.#mapped = mapped === true;\n\t}\n\n\tprepend(text: string): void {\n\t\t// TODO: adjust line map\n\t\tthis.#text = text + \"\\n\" + this.#text;\n\t}\n\n\tappend(text: string): void {\n\t\tif (this.#mapped) {\n\t\t\tthis.lineMap.push(this.#text.length);\n\t\t\tfor (let i = 0; i < text.length; i++) {\n\t\t\t\tif (text[i] === \"\\n\") {\n\t\t\t\t\tthis.lineMap.push(this.#text.length + i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#text += \"\\n\" + text;\n\t\t\treturn;\n\t\t}\n\n\t\tconst start = this.#text.length;\n\n\t\ttext = text.trim();\n\t\tlet i = 0;\n\t\t//let newline = !!text.length && !text.endsWith(\"\\n\");\n\n\t\twhile (i < text.length) {\n\t\t\t// Skip spaces\n\t\t\twhile (text[i] === \" \" || text[i] === \"\\t\") {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (text[i] === \";\") {\n\t\t\t\t// HACK: we just set ; to ignore the line\n\t\t\t\ti++;\n\t\t\t} else if (text[i] === \"\\n\") {\n\t\t\t\tthis.lineMap.push(start + i);\n\t\t\t\tthis.#text += \"\\n\";\n\t\t\t} else {\n\t\t\t\t// Maybe outdent\n\t\t\t\tif (text[i] === \"}\" || text[i] === \")\" || text[i] === \"]\") {\n\t\t\t\t\tthis.#space -= 1;\n\t\t\t\t}\n\n\t\t\t\t// Add indentation\n\t\t\t\tthis.#text += \"\\t\".repeat(Math.max(0, this.#space));\n\t\t\t\t// Add from text until the next newline or the end of text\n\t\t\t\tconst start = i;\n\t\t\t\twhile (i < text.length && text[i] !== \"\\n\") {\n\t\t\t\t\t// Just add backticked text as-is\n\t\t\t\t\tif (text[i] === \"`\") {\n\t\t\t\t\t\ti = skipStringOrComment(text, i) - 1;\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tconst line = text.substring(start, i + 1);\n\n\t\t\t\tif (line.startsWith(\"*\")) {\n\t\t\t\t\t// JSDoc\n\t\t\t\t\tthis.#text += \" \";\n\t\t\t\t}\n\t\t\t\tthis.#text += line;\n\n\t\t\t\t// Maybe indent\n\t\t\t\tif (text[i - 1] === \"{\" || text[i - 1] === \"(\" || text[i - 1] === \"[\") {\n\t\t\t\t\tthis.#space += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t\tif (!this.#text.endsWith(\"\\n\\n\")) {\n\t\t\tthis.#text += \"\\n\";\n\t\t}\n\t}\n\n\ttoString(): string {\n\t\treturn this.#text;\n\t}\n}\n","import type ParentNode from \"../types/nodes/ParentNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isParentNode(node: TemplateNode): node is ParentNode {\n\treturn \"children\" in node;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type ParentNode from \"../types/nodes/ParentNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"./codeScanner\";\nimport isParentNode from \"./isParentNode\";\n\n/**\n * Walks a markup tree and returns every expression string it contains —\n * `@control (...)` statements, reactive attribute values, and `{...}` text\n * interpolations — concatenated. Used for import detection: `$`-primitives\n * used inside markup (e.g. `@if ($pending(() => $state.data))`,\n * `disabled={$pending(...)}`) must be imported, and the script-only scan in\n * `buildCode`/`buildServerCode` doesn't see them.\n *\n * Static attribute values and literal text outside `{...}` are excluded, so a\n * plain string containing e.g. `$pending` does not produce a spurious import.\n */\nexport default function collectMarkupExpressions(root: TemplateNode): string {\n\tlet out = \"\";\n\tconst walk = (node: TemplateNode): void => {\n\t\tif (node.type === \"control\") {\n\t\t\tout += (node as ControlNode).statement + \"\\n\";\n\t\t}\n\t\tif (node.type === \"element\" || node.type === \"component\" || node.type === \"special\") {\n\t\t\tfor (const attribute of (node as ElementNode).attributes) {\n\t\t\t\tif (attribute.reactive && attribute.value !== undefined) {\n\t\t\t\t\tout += attribute.value + \"\\n\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (node.type === \"text\") {\n\t\t\tout += extractInterpolations((node as TextNode).content) + \"\\n\";\n\t\t}\n\t\tif (isParentNode(node)) {\n\t\t\tfor (const child of (node as ParentNode).children) {\n\t\t\t\twalk(child);\n\t\t\t}\n\t\t}\n\t};\n\twalk(root);\n\treturn out;\n}\n\n/**\n * Extracts the `{expr}` interpolation segments from text content (level 0\n * text is prose and is dropped), skipping string literals, template strings,\n * comments and regex literals inside the braces (they're copied into the\n * output verbatim).\n */\nfunction extractInterpolations(content: string): string {\n\tlet out = \"\";\n\tlet level = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tif (char === \"{\") {\n\t\t\tif (level === 0) out += \"\\n\";\n\t\t\tlevel++;\n\t\t\tout += char;\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tout += char;\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(content, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\tout += content.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tout += char;\n\t\t}\n\t}\n\treturn out;\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\n/**\n * Returns true if `markup` renders anything that forwards the component's\n * `$context` parameter: a child component invocation (`<Child />`), a\n * self-recursive `<@component self>`, or a `<slot>` definition (whose\n * generated render call passes `$context` through to the filling parent).\n *\n * `contextProps` only captures *direct* `$context.x` reads in the script, so\n * this is needed to decide whether the `$context` parameter is actually used:\n * every child-component / slot render call passes `$context` positionally\n * (see buildComponentNode / buildSlotNode and their server counterparts),\n * even when the component never names `$context` explicitly.\n *\n * Bias is towards `true`: when uncertain we keep `$context` named, which is\n * always safe at the cost of a missed unused-parameter cleanup.\n */\nexport default function markupRendersComponent(markup: RootNode): boolean {\n\treturn nodeRendersComponent(markup);\n}\n\nfunction nodeRendersComponent(node: TemplateNode): boolean {\n\tif (node.type === \"component\") return true;\n\tif (node.type === \"special\") {\n\t\tconst tagName = (node as ElementNode).tagName;\n\t\tif (tagName === \"@component\" || tagName === \"slot\") return true;\n\t}\n\tconst children = (node as { children?: TemplateNode[] }).children;\n\tif (children) {\n\t\tfor (const child of children) {\n\t\t\tif (nodeRendersComponent(child)) return true;\n\t\t}\n\t}\n\treturn false;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedText(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet start = b.toString().length + preText.length;\n\t\tb.append(preText + text + postText);\n\t\tlet end = start + text.length;\n\t\tstatus.map.push({\n\t\t\tscript: text,\n\t\t\tsource: span,\n\t\t\tcompiled: { start, end },\n\t\t});\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPopDevBoundary(status: BuildStatus, b: Builder): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_pop_dev_bound\");\n\t\tb.append(\"\");\n\t\tb.append(`t_pop_dev_bound();`);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPushDevBoundary(\n\ttype: \"component\" | \"region\" | \"run\" | \"watch\" | \"control\" | \"branch\",\n\tname: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_push_dev_bound\");\n\n\t\t// Ensure the name is wrapped with quotes, and internal quotes are escaped\n\t\tconst nameHasQuotes =\n\t\t\t(name.startsWith(\"'\") && name.endsWith(\"'\")) ||\n\t\t\t(name.startsWith('\"') && name.endsWith('\"')) ||\n\t\t\t(name.startsWith(\"`\") && name.endsWith(\"`\"));\n\t\tif (nameHasQuotes) {\n\t\t\tconst quote = name[0];\n\t\t\tname = quote + name.substring(1, name.length - 1).replaceAll(quote, \"\\\\\" + quote) + quote;\n\t\t} else {\n\t\t\tname = `\"${name.replaceAll('\"', '\\\\\"')}\"`;\n\t\t}\n\n\t\tb.append(`t_push_dev_bound(\"${type}\", ${name});`);\n\t\tb.append(\"\");\n\t}\n}\n","const ANCHOR_COMMENT = \"<!>\";\nconst HYDRATION_START_COMMENT = \"<![>\";\nconst HYDRATION_END_COMMENT = \"<!]>\";\nconst HYDRATION_BREAK_COMMENT = \"<!^>\";\n\nexport { ANCHOR_COMMENT, HYDRATION_START_COMMENT, HYDRATION_END_COMMENT, HYDRATION_BREAK_COMMENT };\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isControlNode(node: TemplateNode): node is ControlNode {\n\treturn node.type === \"control\";\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isElementNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\";\n}\n","import type OperationType from \"../types/nodes/OperationType\";\n\n/**\n * Control operations that produce no DOM output within a fragment.\n *\n * Used by both the fragment builder (to find the first child that actually\n * renders) and the whitespace trimmer (so that whitespace adjacent to these\n * nodes is treated as leading/trailing whitespace of the container, rather\n * than as significant inter-sibling whitespace — without this, every row of\n * a `@for { @key = ...; <tr>...</tr> }` would emit a leading whitespace\n * text node, since the whitespace sits between the @key and the <tr>).\n */\nexport const NON_RENDERING_OPERATIONS: Set<OperationType> = new Set<OperationType>([\n\t\"@key\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n]);\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isControlNode from \"./isControlNode\";\nimport isElementNode from \"./isElementNode\";\nimport { NON_RENDERING_OPERATIONS } from \"./nonRenderingOperations\";\n\n/**\n * Returns the single rendering `Element` root child of `children` if the\n * fragment is \"single-root element\" — i.e. it has exactly one child that\n * renders to the DOM, that child is an `Element`, and every other child is a\n * non-rendering control node (`@key`, `@const`, …) or a comment. Returns\n * `undefined` otherwise.\n *\n * When this returns an `Element`, the compiler emits the\n * `t_fragment_el` / `t_root_el` / `t_add_element` codegen path, which clones\n * the cached template's `firstElementChild` directly into the parent and\n * skips the per-instance `DocumentFragment` allocation that `getFragment`\n * produces.\n *\n * Text-root fragments (`{row.label}` standalone inside a `@for` body) are\n * intentionally excluded: their root is a `Text`, not an `Element`, so\n * `template.content.firstElementChild` would be `null`. Multi-root fragments\n * (`<tr>...</tr><tr>...</tr>`) are excluded because no single element\n * represents the whole fragment.\n */\nexport default function getSingleElementRoot(children: TemplateNode[]): ElementNode | undefined {\n\tlet renderingRoot: ElementNode | undefined;\n\tfor (const child of children) {\n\t\tif (child.type === \"comment\") continue;\n\t\tif (isControlNode(child) && NON_RENDERING_OPERATIONS.has(child.operation)) continue;\n\t\tif (renderingRoot) return undefined;\n\t\tif (!isElementNode(child)) return undefined;\n\t\trenderingRoot = child;\n\t}\n\treturn renderingRoot;\n}\n","/**\n * Checks whether the supplied string is fully or partially reactive (i.e. contains braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully or partially reactive\n */\nexport default function isReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.includes(\"{\") && text.includes(\"}\");\n}\n","/**\n * Trims matching quotes from the start and end of the supplied text\n *\n * @param text The text to trim\n *\n * @returns The text without the quotes at the start or the end\n */\nexport default function trimQuotes(text: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (\n\t\t(text[start] === \"'\" && text[end - 1] === \"'\") ||\n\t\t(text[start] === '\"' && text[end - 1] === '\"') ||\n\t\t(text[start] === \"`\" && text[end - 1] === \"`\")\n\t) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","// From https://developer.mozilla.org/en-US/docs/Glossary/Void_element\nconst voidTags: string[] = [\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n];\nexport default voidTags;\n","import { ANCHOR_COMMENT } from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport getSingleElementRoot from \"../../utils/getSingleElementRoot\";\nimport isReactive from \"../../utils/isReactive\";\nimport { NON_RENDERING_OPERATIONS } from \"../../utils/nonRenderingOperations\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport voidTags from \"../../utils/voidTags\";\nimport type BuildStatus from \"./BuildStatus\";\n\n/**\n * Builds the HTML template text for all of the fragments in a component\n */\nexport default function buildFragmentText(\n\tnode: RootNode | ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tconst fragments: Fragment[] = [];\n\tbuildNodeFragmentText(node, status, fragments);\n\n\tif (fragments.length) {\n\t\t// `t_fragments` is only referenced by the `t_fragment` codegen path\n\t\t// (multi-root fragments). Single-root-element fragments take the\n\t\t// `t_fragment_el` path and never touch `t_fragments`, so declaring it\n\t\t// there would leave it unused.\n\t\tif (fragments.some((f) => !f.singleRootElement && f.usesFragmentCache !== false)) {\n\t\t\tb.append(`const t_fragments: DocumentFragment[] = [];`);\n\t\t}\n\t\t// The single-root-element cache stores the cached `firstElementChild`\n\t\t// directly (no DocumentFragment wrapper). Only emitted when at least\n\t\t// one fragment in this component takes the `t_fragment_el` codegen\n\t\t// path; the cost of one extra empty array per component is negligible.\n\t\tif (fragments.some((f) => f.singleRootElement)) {\n\t\t\tb.append(`const t_fragment_els: Element[] = [];`);\n\t\t}\n\t}\n}\n\nfunction buildNodeFragmentText(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment?: Fragment,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootFragmentText(node as RootNode, status, fragments);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlFragmentText(node as ControlNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\t// NOTE: We don't support nested SVG for now\n\t\t\tlet ns = (node as ElementNode).tagName === \"svg\";\n\t\t\tif (ns) status.ns = true;\n\t\t\tbuildElementFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tif (ns) status.ns = false;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tconst content = (node as TextNode).content;\n\t\t\tif (currentFragment) {\n\t\t\t\tcurrentFragment.text += isReactive(content) ? \"#\" : content;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildRootFragmentText(node: RootNode, status: BuildStatus, fragments: Fragment[]) {\n\tnode.fragment = {\n\t\tnumber: fragments.length,\n\t\ttext: \"\",\n\t\tns: status.ns,\n\t\teffects: [],\n\t\tevents: [],\n\t\tanimations: [],\n\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t};\n\tfragments.push(node.fragment);\n\tfor (let child of node.children) {\n\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t}\n}\n\nfunction buildControlFragmentText(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@try group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\t// Add a placeholder if it's a branching control node\n\t\t\t//if (!node.singleRooted) {\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\t//}\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// Non-rendering nodes (@const, @key, @function, ...) produce no DOM,\n\t\t\t// so they must not spawn their own fragment. Spawning one here would\n\t\t\t// leave an empty multi-root fragment that forces the `t_fragments`\n\t\t\t// cache to be declared even when every rendering fragment is a\n\t\t\t// single-root element (leaving `t_fragments` unused).\n\t\t\tif (NON_RENDERING_OPERATIONS.has(node.operation)) {\n\t\t\t\tfor (let child of node.children) {\n\t\t\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Add a new fragment if it's a control branch and it has children\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t\t\t\t// `@html` builds its content at runtime from an innerHTML string\n\t\t\t\t// (see buildHtmlNode) and only uses this fragment's `number` for\n\t\t\t\t// naming — it never goes through the `buildFragment` cache path, so\n\t\t\t\t// it must not force an unused `t_fragments` declaration.\n\t\t\t\tusesFragmentCache: node.operation !== \"@html\",\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildComponentFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tcurrentFragment.text += ANCHOR_COMMENT;\n\n\t// Add fragments for slots if there are children\n\tif (node.children.length) {\n\t\tnode.fragment = {\n\t\t\tnumber: fragments.length,\n\t\t\ttext: \"\",\n\t\t\tns: status.ns,\n\t\t\teffects: [],\n\t\t\tevents: [],\n\t\t\tanimations: [],\n\t\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t\t};\n\t\tfragments.push(node.fragment);\n\t\tfor (let child of node.children) {\n\t\t\t// TODO: Make sure it's not a fill node\n\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t}\n\t}\n}\n\nfunction buildElementFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tconst tagName = node.tagName === \"@element\" ? \"el\" : node.tagName;\n\tlet needsClass = node.scopeStyles;\n\tcurrentFragment.text += `<${tagName}`;\n\tlet attributesText = node.attributes\n\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t.filter((a) => !(a.name === \"self\" && node.tagName === \"@element\"))\n\t\t.map((a) => {\n\t\t\tif (a.value && a.reactive) {\n\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t// up, especially in the case of data attributes. Otherwise don't set it\n\t\t\t\tif (a.name.startsWith(\"data-\")) {\n\t\t\t\t\treturn `${a.name}=\"\"`;\n\t\t\t\t}\n\t\t\t} else if (a.name === \"class\" && node.scopeStyles) {\n\t\t\t\tneedsClass = false;\n\t\t\t\tlet value = a.value\n\t\t\t\t\t? `\"${trimQuotes(a.value)} torp-${status.styleHash}\"`\n\t\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\t\treturn `${a.name}=${value}`;\n\t\t\t} else {\n\t\t\t\treturn `${a.name}${a.value != null ? `=${a.value}` : \"\"}`;\n\t\t\t}\n\t\t})\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\tif (attributesText) {\n\t\tcurrentFragment.text += \" \" + attributesText;\n\t}\n\tif (needsClass) {\n\t\tcurrentFragment.text += ` class=\"torp-${status.styleHash}\"`;\n\t}\n\n\tcurrentFragment.text += \">\";\n\n\tif (!voidTags.includes(node.tagName)) {\n\t\tfor (let child of node.children) {\n\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t}\n\t\tcurrentFragment.text += `</${tagName}>`;\n\t}\n}\n\nfunction buildSpecialFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\t// Add an anchor for the slot\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\t// Add a new fragment for filled slot content\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildElementFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import { skipStringOrComment } from \"./codeScanner\";\n\n/**\n * Builds the statements that write a component's prop value back to the\n * expression it is bound to (e.g. for `&name={$state.user?.name}`).\n *\n * The bound expression may use optional chaining, which can't be assigned to\n * directly. In that case the write is compiled to a guarded assignment: the\n * prop value is read first (so the write re-runs when the child changes it),\n * the target object is read with `$peek` (so that replacing it doesn't re-run\n * the write with a stale prop value), and the value is written through it\n * when it exists:\n *\n * ```\n * bindingTarget(\"$state.user?.name\", `props[\"name\"]`, \"name\", imports)\n * // => const t_bind_name = props[\"name\"];\n * // const t_target_name = $peek(() => $state.user);\n * // if (t_target_name != null) t_target_name.name = t_bind_name;\n * ```\n *\n * @param value The bound expression\n * @param right The value to assign to it\n * @param name The prop name, used to make the temp variable names unique\n * @param imports The set of runtime imports to add `$peek` to when the\n * expression needs a guarded write\n *\n * @returns The assignment statements\n */\nexport default function bindingTarget(\n\tvalue: string,\n\tright: string,\n\tname: string,\n\timports?: Set<string>,\n): string {\n\t// Find the optional chains in the expression, keeping track of the last\n\t// chain so that the write can be guarded on it\n\tlet lastChainStart = -1;\n\n\tfor (let i = 0; i < value.length; i++) {\n\t\tlet char = value[i];\n\t\tif (char === '\"' || char === \"'\" || char === \"`\" || char === \"/\") {\n\t\t\t// Skip strings, template strings, comments and regex literals\n\t\t\tconst skipped = skipStringOrComment(value, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (char === \"?\" && value[i + 1] === \".\" && !/[0-9]/.test(value[i + 2] ?? \"\")) {\n\t\t\t// NOTE: `?.` followed by a digit is a ternary (e.g. `a ?.5 : b`),\n\t\t\t// not an optional chain\n\t\t\tlet next = value[i + 2];\n\t\t\tif (next === \"(\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot bind to \"${value}\": optional calls are not supported in binding expressions`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlastChainStart = i;\n\t\t\tif (next === \"[\") {\n\t\t\t\t// Skip the whole `?.` -- `a?.[key]` becomes `a[key]`\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t\t// Otherwise skip just the `?` -- `a?.name` becomes `a.name`\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (lastChainStart === -1) {\n\t\treturn `${value} = ${right};`;\n\t}\n\n\t// The guard reads the chain up to (but not including) its last link. If\n\t// that isn't nullish, no link in the chain is, so the write is safe --\n\t// optional chaining short-circuits the whole chain when a link is missing\n\tlet guard = value.substring(0, lastChainStart);\n\t// The part after the last `?.` -- `.name` for a property access, `[key]`\n\t// for a computed one\n\tlet next = value[lastChainStart + 2];\n\tif (next !== \"[\" && !/[A-Za-z0-9_$]/.test(next ?? \"\")) {\n\t\t// e.g. a chain nested inside a computed key (`a?.[b?.c]`) splits the\n\t\t// expression in a place that can't be assigned to\n\t\tthrow new Error(`Cannot bind to \"${value}\": unsupported optional chain in binding expression`);\n\t}\n\tlet suffix = value.substring(lastChainStart + (next === \"[\" ? 2 : 1));\n\tlet varSuffix = name.replace(/[^a-zA-Z0-9_$]/g, \"_\");\n\timports?.add(\"$peek\");\n\treturn (\n\t\t`const t_bind_${varSuffix} = ${right};\\n` +\n\t\t`const t_target_${varSuffix} = $peek(() => ${guard});\\n` +\n\t\t`if (t_target_${varSuffix} != null) t_target_${varSuffix}${suffix} = t_bind_${varSuffix};`\n\t);\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isSpecialNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"special\";\n}\n","import type BuildStatus from \"../client/BuildStatus\";\nimport type BuildServerStatus from \"../server/BuildServerStatus\";\n\n/**\n * Makes a supplied variable name (hopefully!) unique by prepending `t_` and\n * appending a sequence number\n *\n * @param name The variable name\n * @param status The build status\n *\n * @returns A unique variable name\n */\nexport default function nextVarName(name: string, status: BuildStatus | BuildServerStatus): string {\n\tif (!status.varNames[name]) {\n\t\tstatus.varNames[name] = 1;\n\t}\n\tlet varName = `t_${name}_${status.varNames[name]}`;\n\tstatus.varNames[name] += 1;\n\treturn varName;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedTextWithOffsets(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet mappedStart = b.toString().length + preText.length;\n\t\tlet functionBody = preText + text + postText;\n\t\tb.append(functionBody);\n\t\tfor (let i = 0; i < spans.length; i++) {\n\t\t\tlet start = mappedStart + offsets[i];\n\t\t\tlet end = start + lengths[i];\n\t\t\tstatus.map.push({\n\t\t\t\tscript: functionBody,\n\t\t\t\tsource: spans[i],\n\t\t\t\tcompiled: { start, end },\n\t\t\t});\n\t\t}\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\n\nexport default function buildAddFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tif (fragment.effects.length > 0) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\t// Union the forVarMask of every stashed effect in this fragment —\n\t\t\t// they all share a single `$run`, so the run's forVarMask is the\n\t\t\t// bitwise OR of its constituents'.\n\t\t\tlet forVarMask: number | undefined;\n\t\t\tfor (let effect of fragment.effects) {\n\t\t\t\tif (effect.forVarMask !== undefined) {\n\t\t\t\t\tif (forVarMask === undefined) forVarMask = 0;\n\t\t\t\t\tforVarMask |= effect.forVarMask;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet trailing = \"\";\n\t\t\tif (forVarMask !== undefined) {\n\t\t\t\ttrailing = `, undefined, { forVarMask: ${forVarMask} }`;\n\t\t\t}\n\t\t\tb.append(\"$run(() => {\");\n\t\t\tif (status.options.mapped === true) {\n\t\t\t\tfor (let effect of fragment.effects) {\n\t\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.functionBody,\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.spans,\n\t\t\t\t\t\teffect.offsets,\n\t\t\t\t\t\teffect.lengths,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tb,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tb.append(fragment.effects.map((e) => e.functionBody).join(\"\\n\"));\n\t\t\t}\n\t\t\tb.append(`}${status.options.dev === true ? `, \"setAttributes\"${trailing}` : trailing});`);\n\t\t}\n\t\tif (fragment.singleRootElement) {\n\t\t\t// Single-root-element fast path: the cloned element is both the\n\t\t\t// fragment and the end node, so `t_add_element(node, parent,\n\t\t\t// before)` replaces `t_add_fragment(fragment, parent, before,\n\t\t\t// endNode)`. Saves the `firstChild` / `lastChild` reads and the\n\t\t\t// `DocumentFragment`-aware branches inside `t_add_fragment`.\n\t\t\tstatus.imports.add(\"t_add_element\");\n\t\t\tb.append(\n\t\t\t\t`t_add_element(${fragment.endVarName ?? fragmentName}, ${parentName}, ${anchorName});`,\n\t\t\t);\n\t\t\tif (fragment.endVarName) {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tb.append(`t_next(${fragment.endVarName});`);\n\t\t\t}\n\t\t} else {\n\t\t\tstatus.imports.add(\"t_add_fragment\");\n\t\t\tlet params = [fragmentName, parentName, anchorName];\n\t\t\tif (fragment.endVarName) {\n\t\t\t\tparams.push(fragment.endVarName);\n\t\t\t}\n\t\t\t// Pass the root node so `addFragment` can restore the active\n\t\t\t// region's `startNode` during hydration. Child component rendering\n\t\t\t// (via `addElement`) overwrites `startNode` before `addFragment`\n\t\t\t// runs; without this, the region's bounds are wrong and slot\n\t\t\t// reuse clears the wrong parent.\n\t\t\tif (fragment.endVarName && fragment.rootVarName) {\n\t\t\t\tparams.push(fragment.rootVarName);\n\t\t\t}\n\t\t\tb.append(`t_add_fragment(${params.join(\", \")});`);\n\t\t\t// TODO: Don't need to do this if the last thing we hydrated was the end node\n\t\t\tif (fragment.endVarName) {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tb.append(`t_next(${fragment.endVarName});`);\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied character is a space\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is a space\n */\nexport default function isSpaceChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn code === 32 || (code >= 9 && code <= 13);\n}\n","import isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Checks whether the supplied string contains only space characters\n *\n * @param text The string to check\n *\n * @returns True if the supplied string contains only space characters\n */\nexport default function isSpace(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tif (!isSpaceChar(text, i)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\n\nexport default function isTextNode(node: TemplateNode): node is TextNode {\n\treturn node.type === \"text\";\n}\n","import isSpace from \"../../parse/utils/isSpace\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport isReactive from \"../../utils/isReactive\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport isTextNode from \"../../utils/isTextNode\";\nimport { NON_RENDERING_OPERATIONS } from \"../../utils/nonRenderingOperations\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildNode from \"./buildNode\";\n\ninterface VariablePath {\n\tparent: VariablePath | null;\n\ttype: string;\n\tchildren: VariablePath[];\n}\n\n/**\n * Builds the variables and code in a fragment\n */\nexport default function buildFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tif (status.options.useCreateElement === true) {\n\t\t\t// Declarations, then createXxx calls\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tfragmentPath.children.length = 0;\n\t\t\tvarPaths.clear();\n\t\t\tstatus.imports.add(\"t_frg\");\n\t\t\tb.append(`const ${fragmentName} = t_frg([`);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tb.append(`]);`);\n\t\t} else {\n\t\t\t// Text, then declarations\n\t\t\tconst fragmentText = fragment.text.replaceAll(\"`\", \"\\\\`\").replaceAll(/\\s+/g, \" \");\n\t\t\tif (fragment.singleRootElement) {\n\t\t\t\t// Single-root-element fast path: clone the cached template's\n\t\t\t\t// `firstElementChild` directly (skipping the per-instance\n\t\t\t\t// `DocumentFragment` wrapper that `t_fragment` produces).\n\t\t\t\t// Saves one allocation per created list-item / branch render,\n\t\t\t\t// which dominates the cost of bulk-row creates (`run`/`add`/\n\t\t\t\t// `runlots`) in the js-framework-bench.\n\t\t\t\tstatus.imports.add(\"t_fragment_el\");\n\t\t\t\tb.append(\n\t\t\t\t\t`const ${fragmentName} = t_fragment_el($parent.ownerDocument!, t_fragment_els, ${fragment.number}, \\`${fragmentText}\\`${fragment.ns ? \", true\" : \"\"});`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_fragment\");\n\t\t\t\tb.append(\n\t\t\t\t\t`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \\`${fragmentText}\\`${fragment.ns ? \", true\" : \"\"});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tmaybeAddRootNodeDeclaration(node, fragment, fragmentName, status, b, varPaths);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction maybeAddRootNodeDeclaration(\n\tnode: RootNode | ControlNode | ElementNode,\n\tfragment: Fragment,\n\tfragmentName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n) {\n\tif (!node.children.length) return;\n\n\t// Always create a root variable. We need it both for subsequent node\n\t// traversal AND to pass to `t_add_fragment` so it can restore the active\n\t// region's `startNode` during hydration (child component rendering via\n\t// `addElement` overwrites it before `addFragment` runs).\n\tconst rootName = `t_root_${fragment.number}`;\n\tconst firstRendering = firstRenderingChild(node.children);\n\tconst isTextRoot = !!(firstRendering && isTextNode(firstRendering));\n\n\tconst rootFn = fragment.singleRootElement ? \"t_root_el\" : \"t_root\";\n\tstatus.imports.add(rootFn);\n\tconst params = [fragmentName];\n\tif (!fragment.singleRootElement && isTextRoot) {\n\t\tparams.push(\"true\");\n\t}\n\tconst rootPath = `${rootFn}(${params.join(\", \")})`;\n\tb.append(`const ${rootName} = ${rootPath};`);\n\t// Register the root access for shortening so subsequent\n\t// `declareFragmentVars` traversals reuse `rootName` instead of\n\t// re-emitting the (matching) root function call.\n\tvarPaths.set(`${rootFn}(${fragmentName})`, rootName);\n\t// Track the root variable for `t_add_fragment` (only needed for\n\t// multi-root fragments — single-root uses `t_add_element` which already\n\t// sets both start/end correctly).\n\tif (!fragment.singleRootElement) {\n\t\tfragment.rootVarName = rootName;\n\t}\n\n\tprintDebug(rootName, status, b);\n}\n\n/**\n * Returns the first child that actually renders to the DOM, skipping comments\n * and no-output control nodes like @key/@const.\n */\nfunction firstRenderingChild(children: TemplateNode[]): TemplateNode | undefined {\n\tfor (const child of children) {\n\t\tif (child.type === \"comment\") continue;\n\t\tif (isControlNode(child) && NON_RENDERING_OPERATIONS.has(child.operation)) continue;\n\t\treturn child;\n\t}\n\treturn undefined;\n}\n\nfunction declareFragmentVars(\n\tfragment: Fragment,\n\tnode: TemplateNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tdeclareRootFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as RootNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tdeclareControlFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ControlNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tdeclareTextFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as TextNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tdeclareSpecialFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't output comments!\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n\nfunction declareRootFragmentVars(\n\tfragment: Fragment,\n\tnode: RootNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n}\n\nfunction declareControlFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@try group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\tconst operation = node.operation.substring(1).replace(\" group\", \"\");\n\t\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\toperation,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction declareComponentFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tdeclareParentAndAnchorFragmentVars(\n\t\tfragment,\n\t\tnode,\n\t\tpath,\n\t\tstatus,\n\t\tb,\n\t\tparentName,\n\t\tanchorName,\n\t\tvarPaths,\n\t\t\"comp\",\n\t\tdeclare,\n\t);\n}\n\nfunction elementTypeName(node: ElementNode) {\n\t// TODO: Etc\n\tswitch (node.tagName.toLowerCase()) {\n\t\tcase \"div\":\n\t\tcase \"span\":\n\t\tcase \"input\":\n\t\tcase \"select\":\n\t\tcase \"option\":\n\t\tcase \"button\":\n\t\tcase \"form\":\n\t\t\treturn `HTML${node.tagName.substring(0, 1).toUpperCase() + node.tagName.substring(1)}Element`;\n\t\tcase \"a\":\n\t\t\treturn \"HTMLAnchorElement\";\n\t\tcase \"img\":\n\t\t\treturn \"HTMLImageElement\";\n\t\tcase \"textarea\":\n\t\t\treturn \"HTMLTextAreaElement\";\n\t\tcase \"svg\":\n\t\t\treturn \"SVGElement\";\n\t\tcase \"line\":\n\t\tcase \"text\":\n\t\tcase \"path\":\n\t\tcase \"rect\":\n\t\t\treturn `SVG${node.tagName.substring(0, 1).toUpperCase() + node.tagName.substring(1)}Element`;\n\t}\n\treturn \"HTMLElement\";\n}\n\nfunction declareElementFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tconst tagName = node.tagName === \"@element\" ? \"element\" : node.tagName;\n\n\tlet elementPath = { parent: path, type: tagName, children: [] };\n\tpath.children.push(elementPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = elementNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(tagName, status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, elementPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tif (node.tagName === \"@element\") {\n\t\t\t\t\tb.append(`let ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t\t}\n\n\t\t\t\t// Do &ref first, just in case any other attributes or\n\t\t\t\t// components depend on it being set e.g. if you have a `style`\n\t\t\t\t// attribute that depends on the element's size, or you are\n\t\t\t\t// passing the element to a component as an anchor\n\t\t\t\tconst refAttribute = node.attributes.find((a) => a.name === \"&ref\");\n\t\t\t\tif (refAttribute) {\n\t\t\t\t\tlet { value, fullyReactive } = refAttribute;\n\t\t\t\t\tif (value != null && fullyReactive) {\n\t\t\t\t\t\t// Bind the DOM element to a user-defined variable\n\t\t\t\t\t\tb.append(`${value} = ${node.varName};`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If there is an immediate child of this element that has this element as its parent,\n\t// we need to assign the element to the parent var\n\t// @ts-ignore\n\tlet childParentName = node.children.find((c) => !!c.parentName)?.parentName;\n\n\tif (!declare) {\n\t\tlet attributes = node.attributes\n\t\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t\t.map((a) => {\n\t\t\t\tif (a.value && a.reactive) {\n\t\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t\t// up, especially in the case of data attributes\n\t\t\t\t\treturn `\"${a.name}\": \"#\"`;\n\t\t\t\t} else if (a.value) {\n\t\t\t\t\treturn `\"${a.name}\": \"${trimQuotes(a.value) || a.name}\"`;\n\t\t\t\t} else {\n\t\t\t\t\treturn `\"${a.name}\": true\"`;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.join(\", \");\n\n\t\tstatus.imports.add(\"t_elm\");\n\t\tif (declareVariable) {\n\t\t\tb.append(\n\t\t\t\t`(${childParentName ? `${childParentName} = ` : \"\"}${node.varName} = t_elm(\"${node.tagName}\", {${attributes}}, [`,\n\t\t\t);\n\t\t} else if (childParentName) {\n\t\t\tb.append(`(${childParentName} = t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t} else {\n\t\t\tb.append(`t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t}\n\t}\n\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\telementPath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tif (!declare) {\n\t\tif (declareVariable || childParentName) {\n\t\t\tb.append(\"])),\");\n\t\t} else {\n\t\t\tb.append(\"]),\");\n\t\t}\n\t}\n}\n\nfunction elementNodeNeedsDeclaration(node: ElementNode, topLevel: boolean, lastChild: boolean) {\n\tconst hasReactiveAttribute = node.attributes.some((a) => a.value && a.reactive);\n\tconst isDynamicElement =\n\t\tnode.tagName === \"@element\" && node.attributes.find((a) => a.name === \"self\");\n\treturn hasReactiveAttribute || isDynamicElement || (topLevel && lastChild);\n}\n\nfunction declareTextFragmentVars(\n\tfragment: Fragment,\n\tnode: TextNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\t// HACK: Text nodes get merged together\n\t// Is this because of control nodes like @key and @const??\n\t// TODO: We should do this when building for the server too\n\tconst lastType = path.children[path.children.length - 1]?.type;\n\tif (lastType === \"text\" || lastType === \"space\") {\n\t\treturn;\n\t}\n\n\tlet textPath = { parent: path, type: isSpace(node.content) ? \"space\" : \"text\", children: [] };\n\tpath.children.push(textPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = textNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(\"text\", status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, textPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tb.append(`const ${node.varName} = ${varPath};`);\n\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_txt\");\n\t\tif (declareVariable) {\n\t\t\tb.append(`(${node.varName} = t_txt(\" \")),`);\n\t\t} else {\n\t\t\tb.append(`t_txt(\"${node.content}\"),`);\n\t\t}\n\t}\n}\n\nfunction textNodeNeedsDeclaration(node: TextNode, topLevel: boolean, lastChild: boolean) {\n\treturn isReactive(node.content) || (topLevel && lastChild);\n}\n\nfunction declareSpecialFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tif (node.tagName === \"slot\") {\n\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\tfragment,\n\t\t\tnode,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\t\"slot\",\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tswitch (node.tagName) {\n\t\tcase \"slot\":\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\t// Don't build the fill node twice\n\t\t\t\tif (\n\t\t\t\t\tnode.tagName === \"slot\" &&\n\t\t\t\t\tisSpecialNode(child) &&\n\t\t\t\t\t(child.tagName === \"fill\" || child.tagName === \"filldef\")\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n\nfunction declareParentAndAnchorFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode | ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tname: string,\n\tdeclare: boolean,\n) {\n\tconst topLevel = !path.parent;\n\n\t// Declare the parent\n\tif (topLevel) {\n\t\t// If this is a top-level element, then the parent is the fragment\n\t\tnode.parentName = `t_fragment_${fragment.number}`;\n\t} else {\n\t\tconst parentPath = path;\n\t\tconst oldChildren = parentPath.children;\n\t\tparentPath.children = [];\n\t\tconst parentVarPath = getFragmentVarPath(fragment, status, \"?\", parentPath, varPaths);\n\t\tparentPath.children = oldChildren;\n\t\t// TODO: Should do this thing for the last child as well\n\t\tif (varPaths.has(parentVarPath)) {\n\t\t\tnode.parentName = varPaths.get(parentVarPath);\n\t\t} else {\n\t\t\tif (declare) {\n\t\t\t\tnode.parentName = nextVarName(`${name}_parent`, status);\n\t\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\t\tb.append(`let ${node.parentName} as HTMLElement;`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.parentName} = ${parentVarPath} as HTMLElement;`);\n\n\t\t\t\t\tprintDebug(node.parentName, status, b);\n\t\t\t\t}\n\t\t\t\tvarPaths.set(parentVarPath, node.parentName);\n\t\t\t} else {\n\t\t\t\t// HACK: For the createElement option, this gets done in the parent\n\t\t\t}\n\t\t}\n\t}\n\n\t// Declare the anchor\n\tif (declare) {\n\t\tconst anchorPath = { parent: path, type: \"#\", children: [] };\n\t\tpath.children.push(anchorPath);\n\n\t\tnode.varName = nextVarName(`${name}_anchor`, status);\n\t\t// A top-level control node or component is the last node in its\n\t\t// fragment (its anchor comment is emitted after the preceding\n\t\t// elements). Track it as the fragment's end node so that region\n\t\t// clearing covers the whole fragment — mirroring what\n\t\t// `declareElementFragmentVars` / `declareTextFragmentVars` do for\n\t\t// element and text children.\n\t\tif (topLevel) {\n\t\t\tfragment.endVarName = node.varName;\n\t\t}\n\t\tconst anchorVarPath = getFragmentVarPath(fragment, status, node.varName, anchorPath, varPaths);\n\t\tif (status.options.useCreateElement === true) {\n\t\t\tb.append(`let ${node.varName};`);\n\t\t} else {\n\t\t\tstatus.imports.add(\"t_anchor\");\n\t\t\tb.append(`let ${node.varName} = t_anchor(${anchorVarPath}) as HTMLElement;`);\n\n\t\t\tprintDebug(node.varName, status, b);\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_cmt\");\n\t\tb.append(`(${node.varName} = t_cmt()),`);\n\t}\n\n\t// Build nodes with anchors immediately, while we have their anchor node,\n\t// rather than at the end of the fragment\n\tbuildNode(node, status, b, parentName, anchorName);\n\tnode.handled = true;\n}\n\nfunction getFragmentVarPath(\n\tfragment: Fragment,\n\tstatus: BuildStatus,\n\tname: string,\n\tpath: VariablePath,\n\tvarPaths: Map<string, string>,\n): string {\n\tlet node = path;\n\twhile (node.parent) {\n\t\tnode = node.parent;\n\t}\n\tlet varName = `t_fragment_${fragment.number}`;\n\t// Single-root-element fragments clone the cached template's\n\t// `firstElementChild` directly, so the root access goes through\n\t// `t_root_el` (which passes the cloned element through in the\n\t// non-hydrating case and walks the hydration cursor when hydrating)\n\t// rather than `t_root` (which reads `fragment.firstChild`).\n\tconst rootFn = fragment.singleRootElement ? \"t_root_el\" : \"t_root\";\n\tlet varPath = getFragmentVarPathPart(node, varName, status, true, rootFn);\n\n\t// Check for parts of the path that have already been run to shorten our\n\t// traversal\n\tfor (let [existingPath, existingName] of varPaths) {\n\t\tif (varPath.includes(existingPath)) {\n\t\t\tvarPath = varPath.replace(existingPath, existingName);\n\t\t}\n\t}\n\n\t// HACK: allow passing in \"?\" to not add the parentVarPath to the existing\n\t// paths\n\tif (name !== \"?\") {\n\t\t// Add the path, so that we can shorten subsequent paths e.g.\n\t\t// const div = t_next(t_child(root));\n\t\t// const p = t_next(t_next(t_next(t_child(root))))\n\t\t// => const p = t_next(t_next(div))\n\t\tvarPaths.set(varPath, name);\n\t\t// Add the name, so that we are always using the last declared name\n\t\tvarPaths.set(name, name);\n\t}\n\n\t// Shorten `t_next(t_next(x))` to `t_skip(x, 2)`\n\twhile (varPath.includes(\"t_next(t_next(\")) {\n\t\tstatus.imports.add(\"t_skip\");\n\t\tconst match = varPath.match(/(t_next\\(){2,}/)![0];\n\t\tconst count = match.length / \"t_next(\".length;\n\t\tconst pos = varPath.indexOf(\"t_next(t_next(\");\n\t\tconst head = varPath.substring(0, pos);\n\t\tlet level = 0;\n\t\tlet end = 0;\n\t\tfor (let i = pos + match.length; i < varPath.length; i++) {\n\t\t\tif (varPath[i] === \"(\") {\n\t\t\t\tlevel++;\n\t\t\t} else if (varPath[i] === \")\") {\n\t\t\t\tif (level === 0) {\n\t\t\t\t\tend = i;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tlevel--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst tail = varPath.substring(end + count);\n\t\tconst param = varPath.substring(pos + match.length, end);\n\t\tvarPath = `${head}t_skip(${param}, ${count})${tail}`;\n\t}\n\n\t// Set t_next_text back to t_next\n\tvarPath = varPath.replaceAll(\"t_next_text\", \"t_next\");\n\n\treturn varPath;\n}\n\nfunction getFragmentVarPathPart(\n\tpath: VariablePath,\n\tvarPath: string,\n\tstatus: BuildStatus,\n\troot = false,\n\trootFn = \"t_root\",\n): string {\n\tif (root) {\n\t\tstatus.imports.add(rootFn);\n\t\tvarPath = `${rootFn}(${varPath})`;\n\t} else {\n\t\tstatus.imports.add(\"t_child\");\n\t\tvarPath = `t_child(${varPath})`;\n\t}\n\tfor (let [i, child] of path.children.entries()) {\n\t\tif (i > 0) {\n\t\t\tif (child.type === \"text\" || child.type === \"space\") {\n\t\t\t\t// HACK: Using t_next_text just stops t_next(node, true) from\n\t\t\t\t// being converted into t_skip\n\t\t\t\tvarPath = `t_next_text(${varPath}, true)`;\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tvarPath = `t_next(${varPath})`;\n\t\t\t}\n\t\t}\n\n\t\tif (i === path.children.length - 1 && child.children.length) {\n\t\t\t// Nested levels always use `t_child`, never the single-root\n\t\t\t// `t_root_el` — that's only for the top of the path.\n\t\t\tvarPath = getFragmentVarPathPart(child, varPath, status);\n\t\t}\n\t}\n\treturn varPath;\n}\n\nconst debug = false;\nfunction printDebug(varName: string, status: BuildStatus, b: Builder) {\n\tif (debug) {\n\t\tstatus.imports.add(\"t_print\");\n\t\tb.append(`console.log(\"${varName}:\", t_print(${varName}));`);\n\t}\n}\n\n/*\nfunction printPath(path: VariablePath) {\n\tlet parent = path;\n\twhile (parent.parent) {\n\t\tparent = parent.parent;\n\t}\n\tprintPathPart(parent);\n}\n\nfunction printPathPart(path: VariablePath, indent = 0) {\n\tconsole.log(`${\" \".repeat(indent * 2)}${path.type}`);\n\tfor (let child of path.children) {\n\t\tprintPathPart(child, indent + 1);\n\t}\n}\n*/\n","/**\n * Returns a bitmask of the for-loop variables whose substituted paths appear\n * in `expr`. Bit N is set when the Nth for-var (by position in `forVarNames`)\n * is read.\n *\n * After `replaceForVarNames` has run, every reference to a for-var in the\n * body has been rewritten to its data-bag path (e.g. `row` →\n * `t_item_42.data.row`, or `t_item_42.data` for single-var loops). This\n * helper scans the POST-substitution `expr` for those paths and returns a\n * bitmask — used to annotate each effect with `forVarMask` so the keyed-list\n * reconciler's no-proxy force-rerun path (`rerunRegionEffects`) can skip\n * effects that don't depend on the changed for-vars via a single bitwise AND.\n *\n * Conservative by design: a false positive (claiming a dependency that\n * doesn't really exist) just causes an unnecessary re-run, while a false\n * negative would drop a needed update. String literals that happen to\n * contain the substituted path are extremely unlikely and harmless.\n */\nexport default function forVarsReadIn(expr: string, forVarNames: string[][]): number {\n\tlet mask = 0;\n\tfor (let i = 0; i < forVarNames.length; i++) {\n\t\tconst subPath = forVarNames[i][1];\n\t\tif (subPath && expr.includes(subPath)) {\n\t\t\tmask |= 1 << i;\n\t\t}\n\t}\n\treturn mask;\n}\n","import { codeRanges } from \"../../utils/codeScanner\";\nimport type BuildStatus from \"./BuildStatus\";\n\n/**\n * Variables used within a for loop need to be retrieved from the loop data.\n */\nexport default function replaceForVarNames(value: string, status: BuildStatus): string {\n\t// HACK: If a value from a for loop is used in the function body,\n\t// get it from the loop data to trigger an update when it is changed\n\tif (status.forVarNames.length === 0) {\n\t\treturn value;\n\t}\n\n\t// Only rewrite code: the contents of string literals, regex literals and\n\t// comments are left alone, so that e.g. prose inside a template string is\n\t// not mangled. The contents of `${...}` interpolations inside template\n\t// strings are code again.\n\tlet result = \"\";\n\tlet index = 0;\n\tfor (let [start, end] of codeRanges(value)) {\n\t\tresult += value.substring(index, start);\n\t\tresult += replaceVarNames(value.substring(start, end), status);\n\t\tindex = end;\n\t}\n\tresult += value.substring(index);\n\treturn result;\n}\n\nfunction replaceVarNames(code: string, status: BuildStatus): string {\n\tfor (let varName of status.forVarNames) {\n\t\tcode = code.replaceAll(\n\t\t\tnew RegExp(\n\t\t\t\t// The boundary characters are the ones that can legitimately\n\t\t\t\t// precede/follow an identifier reference -- including `?` for\n\t\t\t\t// optional chaining (`item?.name`) and nullish coalescing\n\t\t\t\t// (`fallback ?? item`).\n\t\t\t\t`(^|\\\\s|\\\\(|\\\\[|\\\\{|!|\\\\?|\\\\.\\\\.\\\\.)${varName[0]}($|\\\\s|\\\\.|,|\\\\(|\\\\)|\\\\[|\\\\]|\\\\}|;|\\\\?)`,\n\t\t\t\t\"g\",\n\t\t\t),\n\t\t\t`$1${varName[1]}$2`,\n\t\t);\n\t}\n\treturn code;\n}\n","import Builder from \"../../utils/Builder\";\nimport forVarsReadIn from \"../../utils/forVarsReadIn\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildRun(\n\tfunctionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\taddPushDevBoundary(\"run\", functionName, status, b);\n\n\tlet forVarMask =\n\t\tstatus.forVarNames.length > 0 ? forVarsReadIn(functionBody, status.forVarNames) : undefined;\n\tlet trailing = \"\";\n\tif (status.options.dev === true) {\n\t\ttrailing = `, \"${functionName}\"`;\n\t\tif (forVarMask !== undefined) {\n\t\t\ttrailing += `, { forVarMask: ${forVarMask} }`;\n\t\t}\n\t} else if (forVarMask !== undefined) {\n\t\ttrailing = `, undefined, { forVarMask: ${forVarMask} }`;\n\t}\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(functionBody);\n\tb.append(`}${trailing});`);\n\n\taddPopDevBoundary(status, b);\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport { skipStringOrComment } from \"../../utils/codeScanner\";\nimport trimQuotes from \"../../utils/trimQuotes\";\n\nexport default function getAttributeOffsets(\n\tvalue: string,\n\tspan: SourceSpan,\n): {\n\tnewValue: string;\n\tspans: SourceSpan[];\n\toffsets: number[];\n\tlengths: number[];\n} {\n\t// Build offsets for interpolated values e.g. attribute=\"value {x}\n\t// and {y}\" should have offsets for where the x and y are\n\t// interpolated into the output\n\tvalue = trimQuotes(value);\n\tlet spans: SourceSpan[] = [];\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\n\tlet textContent = \"\";\n\tlet reactiveStart = 0;\n\tlet level = 0;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst char = value[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\t//maxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\t//reactiveCount += 1;\n\t\t\t\ttextContent += \"${\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.push({ start: span.start + i + 2, end: -1 });\n\t\t\t\toffsets.push(reactiveStart + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.at(-1)!.end = span.start + i + 2;\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \"}\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(value, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\t// Copy strings, template strings, comments and regex literals\n\t\t\t\t// into the output as-is\n\t\t\t\ttextContent += value.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += value[i];\n\t}\n\tvalue = `\\`${textContent}\\``;\n\n\treturn {\n\t\tnewValue: value,\n\t\tspans,\n\t\toffsets,\n\t\tlengths,\n\t};\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport bindingTarget from \"../../utils/bindingTarget\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\troot = false,\n): void {\n\tb.append(\"\");\n\tb.append(\"/* @component */\");\n\n\t// TODO: map params to props\n\n\t// Props\n\tconst componentHasProps = node.attributes.length || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// NOTE: The $props object is wrapped in a proxy so that components can\n\t\t// be updated if they refer to a $props.property in e.g. an element's\n\t\t// attribute\n\t\t// TODO: default props etc\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: {\n\t\t\tname: string;\n\t\t\t// Text to be ignored in the mapping e.g. `t_class(`\n\t\t\tpreText?: string;\n\t\t\tvalue: string;\n\t\t\t// Text to be ignored in the mapping e.g. `)`\n\t\t\tpostText?: string;\n\t\t\tspans: SourceSpan[];\n\t\t\toffsets?: number[];\n\t\t\tlengths?: number[];\n\t\t}[] = [];\n\t\tlet runs: string[] = [];\n\t\tlet bindingRuns: string[] = [];\n\n\t\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\t\tif (name === \"self\" && node.tagName === \"@component\") {\n\t\t\t\t// Ignore this special attribute\n\t\t\t} else if (value != null && fullyReactive) {\n\t\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\t\t// It's a bound property\n\t\t\t\t\t// Add two $runs -- one to update the props, and one to update the value\n\t\t\t\t\t// The component author will need to make sure $props.x is updated\n\t\t\t\t\t// TODO: Maybe allow adding a Bindable<T> type to the $props interface??\n\t\t\t\t\t// e.g. Component($props: { text: Bindable<string> })\n\t\t\t\t\tname = name.substring(1);\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t\tbindingRuns.push(bindingTarget(value, `${propsName}[\"${name}\"]`, name, status.imports));\n\t\t\t\t} else if (name === \"class\") {\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tvalue = `[${value}, \"torp-${status.styleHash}\"]`;\n\t\t\t\t\t}\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null && reactive) {\n\t\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\t\tvalue = newValue;\n\t\t\t\tif (name === \"class\") {\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tvalue = `[${value}, \"torp-${status.styleHash}\"]`;\n\t\t\t\t\t}\n\t\t\t\t\tprops.push({ name, value, spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tprops.push({ name, value, spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({ name, value, spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null) {\n\t\t\t\tif (name === \"class\" && node.scopeStyles) {\n\t\t\t\t\tvalue = `\"${trimQuotes(value)} torp-${status.styleHash}\"`;\n\t\t\t\t}\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tvalue,\n\t\t\t\t\t// Set non-reactive props with `as const` so that typescript\n\t\t\t\t\t// won't complain when passing e.g. strings to string unions\n\t\t\t\t\tpostText: \" as const\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tvalue: \"true\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`let ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\tp.preText ??= \"\";\n\t\t\tp.postText ??= \"\";\n\t\t\tif (p.spans.length === 1) {\n\t\t\t\taddMappedText(\n\t\t\t\t\tp.name ? `${p.name}: ` + p.preText : p.preText,\n\t\t\t\t\tvalue,\n\t\t\t\t\tp.postText + \",\",\n\t\t\t\t\tp.spans[0],\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\tp.name ? `${p.name}: ` + p.preText : p.preText,\n\t\t\t\t\tvalue,\n\t\t\t\t\tp.postText + \",\",\n\t\t\t\t\tp.spans,\n\t\t\t\t\tp.offsets!,\n\t\t\t\t\tp.lengths!,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t\tif (bindingRuns.length) {\n\t\t\tbuildRun(\"setBindings\", replaceForVarNames(bindingRuns.join(\"\\n\"), status), status, b);\n\t\t}\n\n\t\t// PERF: Does this have much of an impact??\n\t\tif (root) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t$run(() => ${propsName}[name] = $props[name]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, SlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && (slot.tagName === \"fill\" || slot.tagName === \"filldef\")) {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\t\"$sparent: ParentNode\",\n\t\t\t\t\t\"$sanchor: Node | null\",\n\t\t\t\t\t// NOTE: The $slot param is only declared with its real name\n\t\t\t\t\t// when the fill reads it (hasSlotProps), otherwise it would\n\t\t\t\t\t// be reported as unused\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$slot: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"_$slot?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n// eslint-disable-next-line no-unused-vars\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\t// NOTE: The @ts-ignore suppresses the assignability error from\n\t\t\t\t// the required $slot param, which is not compatible with the\n\t\t\t\t// optional $slot param of the SlotRender type\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\n\t\t\t\tbuildFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tstatus.fragmentStack.push({\n\t\t\t\t\tfragment: slot.fragment,\n\t\t\t\t\tpath: \"\",\n\t\t\t\t});\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildNode(child, status, b, \"$sparent\", \"$sanchor\");\n\t\t\t\t}\n\t\t\t\tstatus.fragmentStack.pop();\n\n\t\t\t\tbuildAddFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Render the component\n\tconst compParentName = node.parentName;\n\tconst compAnchorName = node.varName;\n\tlet renderParams = `${compParentName}, ${compAnchorName}, ${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// TODO: Map the params properly, either by checking for things ourselves,\n\t// or better checking for $props being undefined in components\n\t//addMappedText(\"\", componentName, `(${renderParams});`, node.span, status, b);\n\taddMappedText(\"\", `${componentName}(${renderParams})`, \";\", node.span, status, b);\n\n\tb.append(\"\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\n\nexport default function buildAwaitNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"await_region\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\tconst awaitBranch = branches.find((n) => n.operation === \"@await\");\n\tconst withBranch = branches.find((n) => n.operation === \"@with\");\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_await\");\n\n\tb.append(\"\");\n\tb.append(\"/* @await */\");\n\n\taddPushDevBoundary(\"control\", \"@await\", status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"await\"` : \"\"});\n\t\tt_run_await(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\t// Content branch children\n\tif (awaitBranch !== undefined && awaitBranch.children.length > 0) {\n\t\tbuildFragment(awaitBranch, status, b, parentName, \"t_before\");\n\t\tstatus.fragmentStack.push({ fragment: awaitBranch.fragment, path: \"\" });\n\t\tfor (let child of awaitBranch.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\t\tbuildAddFragment(awaitBranch, status, b, parentName, \"t_before\");\n\t}\n\n\t// Close content callback; open with-branch (or pass null)\n\tif (withBranch !== undefined) {\n\t\tb.append(`}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\t\tif (withBranch.children.length > 0) {\n\t\t\tbuildFragment(withBranch, status, b, parentName, \"t_before\");\n\t\t\tstatus.fragmentStack.push({ fragment: withBranch.fragment, path: \"\" });\n\t\t\tfor (let child of withBranch.children) {\n\t\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t\t}\n\t\t\tstatus.fragmentStack.pop();\n\t\t\tbuildAddFragment(withBranch, status, b, parentName, \"t_before\");\n\t\t}\n\t\tb.append(`}${status.options.dev === true ? `, \"runAwait\"` : \"\"});`);\n\t} else {\n\t\tb.append(`}, null${status.options.dev === true ? `, \"runAwait\"` : \"\"});`);\n\t}\n\n\taddPopDevBoundary(status, b);\n\tb.append(\"\");\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isControlNode from \"./isControlNode\";\nimport { NON_RENDERING_OPERATIONS } from \"./nonRenderingOperations\";\n\n/**\n * Returns true if any descendant of a `@for` body is a control node that\n * creates its own region and effects (`@if`, `@for`, `@await`, `@switch`,\n * `@replace`, `@html`).\n *\n * Operations that produce no DOM and no region (`@key`, `@const`, `@console`,\n * `@debugger`, `@function`) are fine — same category as `@key`. They are\n * descended through, so a real control statement nested under a `@key` (a\n * common shape — `@for` bodies almost always lead with `@key = ...`) is still\n * detected.\n *\n * Extracted from `isForBodyNoProxySafe` so the no-proxy specialization, the\n * leaf-row region-chain specialization (`isForBodyLeafSafe`), and any future\n * pass that needs the same structural predicate can share one source of\n * truth.\n */\nexport default function hasNestedControl(children: TemplateNode[]): boolean {\n\tfor (const child of children) {\n\t\tif (isControlNode(child)) {\n\t\t\tif (!NON_RENDERING_OPERATIONS.has(child.operation)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t// A non-rendering control node (e.g. `@key`) wraps the actual\n\t\t\t// body content; keep descending so we still detect a real\n\t\t\t// control statement nested under it.\n\t\t\tif (hasNestedControl(child.children)) return true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isElementLike(child)) {\n\t\t\tif (hasNestedControl(child.children)) return true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction isElementLike(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\" || node.type === \"component\" || node.type === \"special\";\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport hasNestedControl from \"./hasNestedControl\";\n\n/**\n * Returns true if the body of a `@for` loop contains no nested control\n * statements (`@if`, `@for`, `@await`, `@switch`, `@replace`, `@html`).\n *\n * When true, every effect created by the row template lives directly on the\n * item's own region — never on a descendant region chained off it. The\n * compiler can then emit a \"leaf-row\" `createListItem` that skips the\n * per-item `pushRegion(item)` / `popRegion(oldRegion)` calls: `runListItems`\n * has already pushed the item onto the active region (via\n * `pushRegion(item, true)`) before calling `create()`, and a leaf body never\n * creates descendant regions, so `context.activeRegion` stays put at the item\n * for the whole callback. Saves two function calls per row plus the\n * `devContext.onRegionPushed` / `onRegionPopped` invocations, which on the\n * 10k-row js-framework-bench `runlots` op is 20000 fewer calls per pass.\n *\n * Note: every no-proxy-safe body is also leaf-safe (`isForBodyNoProxySafe`\n * includes `hasNestedControl`), but the converse is not true — a body that\n * writes to a for-var (disqualifying it from no-proxy) can still be leaf-safe\n * and earn this specialization.\n */\nexport default function isForBodyLeafSafe(forBodyChildren: TemplateNode[]): boolean {\n\treturn !hasNestedControl(forBodyChildren);\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport hasNestedControl from \"./hasNestedControl\";\nimport isControlNode from \"./isControlNode\";\nimport isTextNode from \"./isTextNode\";\n\n/**\n * Returns true if the body of a `@for` loop never writes to any of its loop\n * variables (`forVars`) — neither directly (`row = ...`, `row.x = ...`,\n * `row[k] = ...`) nor via compound assignment (`+=`, `++`, etc.) — AND the\n * body contains no nested control statements (`@if`, `@for`, `@await`, …).\n *\n * When both hold, the compiler can emit a \"no-proxy\" `@for` specialization\n * that skips the per-item shallow `$watch` Proxy around the loop variable\n * bag: reads of `data.<forVar>` are plain property accesses (no proxyGet\n * trap), and the compiler-emitted `updateListItem` callback re-runs item\n * effects manually (via `t_rerun_region_effects`) when a forVar's reference\n * actually changes.\n *\n * The \"no nested controls\" constraint keeps the manual effect re-run sound:\n * without it, a nested `@if`'s effects would live on a descendant region\n * chained off the original item, but after keyed reconciliation that chain\n * is orphaned (the live item is a different object), so the re-run walk\n * couldn't find them. With no nested controls every row effect is on the\n * item itself, which is exactly what `t_rerun_region_effects` walks.\n *\n * Detection is intentionally conservative: a regex scan over every\n * expression-like string in the body (text interpolation, attribute values,\n * event handlers, control statements). Anything ambiguous falls back to the\n * proxy path. The for-statement itself (`for (let row of ...)`) is NOT\n * scanned — that's the loop header, not the body — so `for (...; i++)` style\n * loops with `i++` in the header are still eligible.\n */\nexport default function isForBodyNoProxySafe(\n\tforBodyChildren: TemplateNode[],\n\tforVars: string[],\n): boolean {\n\tif (forVars.length === 0) return false;\n\tif (hasNestedControl(forBodyChildren)) return false;\n\n\tconst collected: string[] = [];\n\tfor (const child of forBodyChildren) {\n\t\tcollectExpressionStrings(child, collected);\n\t}\n\n\t// One alternation per for-var; the alternation covers direct / property /\n\t// index writes plus prefix/postfix updates. `=(?![=>])` distinguishes `=`\n\t// from `==` / `===` / `=>`.\n\t//\n\t// The destructuring alternatives (`[forVar] =`, `{forVar} =`,\n\t// `{forVar: ...} =`) all require an `=` *after* the closing bracket /\n\t// brace: without that anchor they'd false-positive on torpor's own text\n\t// interpolation syntax (`<p>{forVar}</p>`) and on regular indexed-read\n\t// expressions (`arr[forVar]`).\n\tfor (const varName of forVars) {\n\t\tconst escaped = varName.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\tconst writePattern = new RegExp(\n\t\t\t// `[forVar] =` or `{forVar} =` or `{forVar: ...} =` — array / object\n\t\t\t// destructuring assignment targets. The trailing `=` is required so\n\t\t\t// we don't match `{forVar}` text interpolations or `arr[forVar]`\n\t\t\t// indexed reads.\n\t\t\t`\\\\[\\\\s*${escaped}\\\\s*\\\\]\\\\s*=(?![=>])|` +\n\t\t\t\t`\\\\{\\\\s*${escaped}\\\\s*(:[^}]+)?\\\\}\\\\s*=(?![=>])|` +\n\t\t\t\t// forVar or forVar.prop or forVar[key], optionally followed by\n\t\t\t\t// an assignment / compound-assignment / update operator\n\t\t\t\t`\\\\b${escaped}(?:\\\\.[a-zA-Z_$][\\\\w$]*|\\\\[[^\\\\]]+\\\\])?\\\\s*(?:=(?![=>])|[+\\\\-*/%&|^]=|\\\\+\\\\+|--)|` +\n\t\t\t\t// prefix ++/--\n\t\t\t\t`(?:\\\\+\\\\+|--)\\\\s*${escaped}\\\\b`,\n\t\t);\n\t\tfor (const text of collected) {\n\t\t\tif (writePattern.test(text)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isElementLike(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\" || node.type === \"component\" || node.type === \"special\";\n}\n\nfunction collectExpressionStrings(node: TemplateNode, out: string[]): void {\n\tif (isTextNode(node)) {\n\t\tout.push(node.content);\n\t\treturn;\n\t}\n\tif (isElementLike(node)) {\n\t\t// Attribute names + values cover static attrs, reactive class/style\n\t\t// bindings, and event handlers (`onclick={() => select(row)}`).\n\t\tfor (const attr of node.attributes) {\n\t\t\tif (attr.value !== undefined) {\n\t\t\t\tif (attr.name.startsWith(\"&\")) {\n\t\t\t\t\t// Two-way bindings (`&value={i}`, `&checked={x}`,\n\t\t\t\t\t// `&group={g}`, `&foo={bar}` on components) emit\n\t\t\t\t\t// `${value} = …` assignment handlers, so the value\n\t\t\t\t\t// expression is a *write* target, not just a read.\n\t\t\t\t\t// Appending ` =` lets the regex flag any for-var that\n\t\t\t\t\t// appears in it as assigned.\n\t\t\t\t\tout.push(`${attr.value} =`);\n\t\t\t\t} else {\n\t\t\t\t\tout.push(attr.value);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fully-reactive attribute spreads / dynamic attribute names are\n\t\t\t// emitted verbatim too — the value carries the expression.\n\t\t\tif (attr.fullyReactive && attr.name !== attr.value) {\n\t\t\t\tout.push(attr.name);\n\t\t\t}\n\t\t}\n\t\tfor (const child of node.children) {\n\t\t\tcollectExpressionStrings(child, out);\n\t\t}\n\t\treturn;\n\t}\n\tif (isControlNode(node)) {\n\t\t// `@key = row.id` is a *read* of `row.id`; we still scan the\n\t\t// statement because the key expression is the most common place a\n\t\t// for-var shows up, and reads are correctly ignored by the regex\n\t\t// (no assignment operator follows). For nested `@if`/`@for`/etc.,\n\t\t// the statement may also read for-vars.\n\t\tout.push(node.statement);\n\t\tfor (const child of node.children) {\n\t\t\tcollectExpressionStrings(child, out);\n\t\t}\n\t}\n}\n","/**\n * Trims chars from the start and end of the supplied text when both the start and end match\n *\n * @param text The text to trim\n *\n * @returns The text without the chars at the start or the end\n */\nexport default function trimMatched(text: string, startChar: string, endChar: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (text[start] === startChar && text[end - 1] === endChar) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport isForBodyLeafSafe from \"../../utils/isForBodyLeafSafe\";\nimport isForBodyNoProxySafe from \"../../utils/isForBodyNoProxySafe\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nconst forLoopRegex = /for\\s*\\((.+?);.*?;.*?\\)/;\nconst forLoopVarsRegex = /(?:let\\s+|var\\s+){0,1}([^\\s,;+=]+)(?:\\s*=\\s*[^,;]+){0,1}/g;\nconst forOfRegex = /for\\s*\\(\\s*(?:let\\s*|var\\s*){0,1}(.+?)\\s+(?:of|in).*?\\)/;\n\nexport default function buildForNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst parentName = node.parentName!;\n\tconst anchorName = node.varName ?? \"null\";\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\t// HACK: Need to wrangle the declaration(s) out of the for loop and put them in data\n\t// TODO: Handle destructuring, quotes, comments etc\n\tconst forVarNames: string[] = [];\n\tconst forLoopMatch = node.statement.match(forLoopRegex);\n\tif (forLoopMatch) {\n\t\tconst forVarMatches = forLoopMatch[1].matchAll(forLoopVarsRegex);\n\t\tfor (let match of forVarMatches) {\n\t\t\tforVarNames.push(match[1]);\n\t\t}\n\t} else {\n\t\tconst forOfMatch = node.statement.match(forOfRegex);\n\t\tif (forOfMatch) {\n\t\t\tconst match = forOfMatch[1];\n\t\t\tif (\n\t\t\t\t(match.startsWith(\"{\") && match.endsWith(\"}\")) ||\n\t\t\t\t(match.startsWith(\"[\") && match.endsWith(\"]\"))\n\t\t\t) {\n\t\t\t\tforVarNames.push(\n\t\t\t\t\t...trimMatched(trimMatched(match, \"{\", \"}\"), \"[\", \"]\")\n\t\t\t\t\t\t.split(\",\")\n\t\t\t\t\t\t.map((m) => m.trim()),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tforVarNames.push(match);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst regionName = nextVarName(\"for_region\", status);\n\tconst listItemsName = nextVarName(\"new_items\", status);\n\tconst itemName = nextVarName(\"item\", status);\n\tconst beforeName = nextVarName(\"before\", status);\n\n\t// Get the key node if it's been set\n\tlet keyStatement = \"\";\n\tconst key = node.children.find(\n\t\t(n) => n.type === \"control\" && (n as ControlNode).operation === \"@key\",\n\t) as ControlNode;\n\tif (key !== undefined) {\n\t\tlet matches = key.statement.match(/^(\\s*@*key\\s*=\\s*)(.+?)\\s*;*\\s*$/);\n\t\tif (matches) {\n\t\t\tkey.span.start += matches[1].length;\n\t\t\tkeyStatement = matches[2];\n\t\t}\n\t}\n\n\t// Detect \"no-proxy safe\" @for body: when none of the for-vars are ever\n\t// written inside the body, the per-item data bag doesn't need to be\n\t// wrapped in a shallow `$watch` Proxy. The compiler-emitted updateListItem\n\t// then compares each forVar's reference and re-runs the item's effects\n\t// manually (via t_rerun_region_effects) when one has actually changed.\n\t// Skips a Proxy + ProxyData + signals Map allocation per created row, and\n\t// a proxyGet trap per property read during every row effect run.\n\tconst noWatch = isForBodyNoProxySafe(node.children, forVarNames);\n\tif (noWatch) {\n\t\tstatus.imports.add(\"t_rerun_region_effects\");\n\t}\n\n\t// Single-loop-var specialization of the no-proxy path: when the body\n\t// binds exactly one loop variable, the per-row spec can store it\n\t// directly (`data: row`) instead of wrapping it (`data: { row }`). This\n\t// drops one object allocation per row on EVERY list update — a\n\t// `removeFirst` click on a 1000-row list allocates 999 `{ row }`\n\t// wrappers today, all to be GC'd moments later — and turns the\n\t// `updateListItem` per-field compare into a single reference check. The\n\t// body's loop-var access flips from `item.data.<var>.x` to\n\t// `item.data.x` (the substitution below maps `<var>` → `item.data`\n\t// rather than `item.data.<var>`).\n\tconst singleVar = noWatch && forVarNames.length === 1;\n\n\t// Detect \"leaf-row safe\" @for body: when the body has no nested control\n\t// statements (`@if`/`@for`/`@await`/…), the create callback can skip its\n\t// `pushRegion(item)` / `popRegion(oldRegion)` calls. `runListItems` has\n\t// already pushed the item onto the active region before calling\n\t// `create()`, and a leaf body never creates descendant regions that\n\t// would shift `context.activeRegion` away from the item — so the\n\t// push/pop in the callback is purely redundant. Saves two function calls\n\t// per row plus the `devContext.onRegionPushed`/`onRegionPopped`\n\t// invocations (~20000 calls saved on a 10k-row `runlots`).\n\t//\n\t// Every no-proxy-safe body is also leaf-safe (`isForBodyNoProxySafe`\n\t// gates on the same nested-control check), but the converse is not true\n\t// — a body that writes to a for-var can still be leaf-safe — so this is\n\t// an independent check.\n\tconst leafRow = isForBodyLeafSafe(node.children);\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_list\");\n\tstatus.imports.add(\"ListItemSpec\");\n\n\tb.append(\"\");\n\tb.append(\"/* @for */\");\n\taddPushDevBoundary(\"control\", `@${node.statement}`, status, b);\n\tb.append(`\n\t\tlet ${regionName} = t_region(${status.options.dev === true ? `\"for\"` : \"\"});\n\t\tt_run_list(\n\t\t${regionName},\n\t\t${parentName},\n\t\t${anchorName},\n\t\t${status.options.dev === true ? \"function createNewItems() {\" : \"() => {\"}\n\t\t\tlet ${listItemsName}: ListItemSpec[] = [];`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\t// Push a lightweight {key, data} spec per row. The reconciler reuses old\n\t// ListItems for survivors and only mounts fresh ones for genuinely new\n\t// keys, so a survivor costs only this 2-field allocation per update — no\n\t// full ListItem, no effects migration, no per-row chain re-link. When the\n\t// body is no-proxy safe and binds a single loop var, store it directly\n\t// (`data: row`) rather than wrapping it (`data: { row }`) so we skip the\n\t// per-row wrapper-object allocation entirely.\n\tif (singleVar) {\n\t\tb.append(`${listItemsName}.push({ data: ${forVarNames[0]}, key: `);\n\t} else {\n\t\tb.append(`${listItemsName}.push({ data: { ${forVarNames.join(\", \")} }, key: `);\n\t}\n\tif (key !== undefined) {\n\t\taddMappedText(\"\", `${keyStatement || \"undefined\"}`, \" });\", key.span, status, b);\n\t} else {\n\t\tb.append(`undefined });`);\n\t}\n\tb.append(`}`);\n\tb.append(`return ${listItemsName};`);\n\tb.append(`},\n\t\t${status.options.dev === true ? `function createListItem(${itemName}, ${beforeName}) {` : `(${itemName}, ${beforeName}) => {`}`);\n\n\tlet oldForVarNames = status.forVarNames;\n\t// The bit base for this loop's for-vars in `forVarMask`. Outer for-loops\n\t// (if any) occupy lower bit positions in `status.forVarNames`; this\n\t// loop's vars start at `oldForVarNames.length`. Captured before the body\n\t// is built so `forVarsReadIn` and `t_changed_mask` use the same index\n\t// space.\n\tconst forVarBitBase = oldForVarNames.length;\n\tstatus.forVarNames = [\n\t\t...status.forVarNames,\n\t\t// singleVar stores the loop var directly as `data`, so the body\n\t\t// reads it as `item.data.<x>`; otherwise it's wrapped as\n\t\t// `data: { <var> }` and the body reads `item.data.<var>.<x>`.\n\t\t...(singleVar\n\t\t\t? forVarNames.map((v) => [v, `${itemName}.data`])\n\t\t\t: forVarNames.map((v) => [v, `${itemName}.data.${v}`])),\n\t];\n\tbuildForItem(node, status, b, parentName, beforeName, itemName, leafRow);\n\tstatus.forVarNames = oldForVarNames;\n\n\tb.append(`},\n${status.options.dev === true ? \"function updateListItem(t_old_item, t_new_item) {\" : \"(t_old_item, t_new_item) => {\"}`);\n\tif (noWatch) {\n\t\t// Compare each forVar's reference. Only when one has actually changed\n\t\t// do we copy it across and re-run the item's effects. Unchanged rows\n\t\t// (the common case during a partial `update`) cost only the\n\t\t// reference-equality check — no allocation, no effect re-run.\n\t\t// singleVar collapses this to a single `data` reference check (the\n\t\t// loop var IS the data bag, no per-field walk).\n\t\t//\n\t\t// We OR the changed for-var positions into `t_changed_mask` (a\n\t\t// bitmask). Bit positions are offset by `forVarBitBase` to match\n\t\t// the indices `forVarsReadIn` used when annotating effects (which\n\t\t// iterates over the full `status.forVarNames`, including outer\n\t\t// loops). `t_rerun_region_effects` then uses each effect's\n\t\t// `forVarMask & changedMask` to skip unrelated effects.\n\t\tb.append(`let t_changed_mask = 0;`);\n\t\tif (singleVar) {\n\t\t\tconst bit = 1 << forVarBitBase;\n\t\t\tb.append(\n\t\t\t\t`if (t_old_item.data !== t_new_item.data) {\n\t\t\t\t\tt_old_item.data = t_new_item.data;\n\t\t\t\t\tt_changed_mask = ${bit};\n\t\t\t\t}`,\n\t\t\t);\n\t\t} else {\n\t\t\tfor (let i = 0; i < forVarNames.length; i++) {\n\t\t\t\tconst varName = forVarNames[i];\n\t\t\t\tconst bit = 1 << (forVarBitBase + i);\n\t\t\t\tb.append(\n\t\t\t\t\t`if (t_old_item.data.${varName} !== t_new_item.data.${varName}) {\n\t\t\t\t\t\tt_old_item.data.${varName} = t_new_item.data.${varName};\n\t\t\t\t\t\tt_changed_mask |= ${bit};\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tb.append(`if (t_changed_mask) t_rerun_region_effects(t_old_item, t_changed_mask);`);\n\t} else {\n\t\tfor (let varName of forVarNames) {\n\t\t\tb.append(`t_old_item.data.${varName} = t_new_item.data.${varName};`);\n\t\t}\n\t}\n\tb.append(`}${noWatch ? \",\\ntrue\" : \"\"}\\n);`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildForItem(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tbeforeName: string,\n\titemName: string,\n\tleafRow: boolean,\n) {\n\tconst oldRegionName = nextVarName(\"old_region\", status);\n\n\t// Leaf-row specialization: skip the per-item `pushRegion(item)` /\n\t// `popRegion(oldRegion)` calls. `runListItems` has already pushed the\n\t// item onto the active region (via `pushRegion(item, true)`) before\n\t// calling `create()`, and the leaf body never creates descendant regions\n\t// that would shift `context.activeRegion` away from the item — so the\n\t// push/pop here is purely redundant. The effect created by the body's\n\t// `$run` still lands on the right region (`context.activeRegion.effects`\n\t// === `item.effects`), and the chain bookkeeping in `runListItems`\n\t// (which uses `context.previousRegion` to link siblings) is unaffected.\n\tif (!leafRow) {\n\t\tstatus.imports.add(\"t_push_region\");\n\t\tb.append(`let ${oldRegionName} = t_push_region(${itemName});`);\n\t}\n\n\tbuildFragment(node, status, b, parentName, beforeName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment!,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tif (isControlNode(child) && child.operation === \"@key\") {\n\t\t\tcontinue;\n\t\t}\n\t\tbuildNode(child, status, b, parentName, beforeName);\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, beforeName);\n\n\tif (!leafRow) {\n\t\tstatus.imports.add(\"t_pop_region\");\n\t\tb.append(`t_pop_region(${oldRegionName});`);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildHtmlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst htmlAnchorName = node.varName!;\n\tconst htmlParentName = node.parentName || htmlAnchorName + \".parentNode\";\n\n\t// HACK: I'm not actually sure we need this here (or in @replace, where I copied it from)\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\n\tconst firstNodeVar = nextVarName(\"html_first\", status);\n\tconst lastNodeVar = nextVarName(\"html_last\", status);\n\n\tb.append(\"\");\n\tb.append(`/* @html */`);\n\tb.append(`let ${firstNodeVar}: ChildNode | null = null;`);\n\tb.append(`let ${lastNodeVar}: ChildNode | null = null;`);\n\tb.append(`t_run_control(t_region(), ${htmlAnchorName}, (t_before) => {`);\n\n\t// Read the html expression (for reactivity tracking)\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\n\t// Clear previously rendered content\n\tb.append(`if (${firstNodeVar} !== null && ${lastNodeVar} !== null) {`);\n\tb.append(`let t_node: ChildNode | null = ${lastNodeVar};`);\n\tb.append(`while (t_node !== null && t_node !== ${firstNodeVar}) {`);\n\tb.append(`const t_prev: ChildNode | null = t_node.previousSibling;`);\n\tb.append(`t_node.remove();`);\n\tb.append(`t_node = t_prev;`);\n\tb.append(`}`);\n\tb.append(`if (${firstNodeVar}) ${firstNodeVar}.remove();`);\n\tb.append(`${firstNodeVar} = ${lastNodeVar} = null;`);\n\tb.append(`}`);\n\n\tconst templateName = nextVarName(\"template\", status);\n\tconst fragmentName = `t_fragment_${node.fragment!.number}`;\n\tb.append(`let ${templateName} = document.createElement(\"template\");`);\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tnode.span.start += \"html(\".length;\n\tnode.span.end -= 2;\n\taddMappedText(\n\t\t\"\",\n\t\t`${templateName}.innerHTML = ${replaceForVarNames(node.statement, status)};`,\n\t\t\"\",\n\t\tnode.span,\n\t\tstatus,\n\t\tb,\n\t);\n\tb.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);\n\tb.append(`${firstNodeVar} = ${fragmentName}.firstChild;`);\n\tb.append(`${lastNodeVar} = ${fragmentName}.lastChild;`);\n\n\tbuildAddFragment(node, status, b, htmlParentName, \"t_before\");\n\n\t// During hydration the fragment isn't inserted, so adopt the existing\n\t// server-rendered nodes from the DOM instead\n\tstatus.imports.add(\"t_first_inside\");\n\tb.append(`if (${firstNodeVar} !== null && ${firstNodeVar}.parentNode !== ${htmlParentName}) {`);\n\tb.append(`${lastNodeVar} = ${htmlAnchorName}.previousSibling as ChildNode | null;`);\n\tb.append(`if (${lastNodeVar} !== null) {`);\n\tb.append(`const t_stashed_first = t_first_inside(${htmlAnchorName} as ChildNode);`);\n\t// The first node inside the hydration block is stashed by `t_anchor`\n\t// (`nodeAnchor`) when it strips the hydration markers. Scanning backwards\n\t// is only a fallback, as content can contain whitespace text nodes that\n\t// would truncate the region.\n\tb.append(`if (t_stashed_first !== undefined && t_stashed_first !== null) {`);\n\tb.append(`${firstNodeVar} = t_stashed_first;`);\n\tb.append(`} else {`);\n\tb.append(`${firstNodeVar} = ${lastNodeVar};`);\n\tb.append(`let t_scan: ChildNode | null = ${lastNodeVar};`);\n\tb.append(\n\t\t`while (t_scan !== null && t_scan.previousSibling !== null && t_scan.previousSibling !== ${htmlAnchorName} && (t_scan.previousSibling.nodeType !== 3 || (t_scan.previousSibling.textContent ?? \"\").trim() !== \"\")) {`,\n\t);\n\tb.append(`t_scan = t_scan.previousSibling;`);\n\tb.append(`}`);\n\tb.append(`${firstNodeVar} = t_scan;`);\n\tb.append(`}`);\n\tb.append(`}`);\n\tb.append(`}`);\n\n\tb.append(`}${status.options.dev === true ? ', \"html\"' : \"\"});`);\n\tb.append(\"\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: Are there too many branches for ifs etc?\n\nexport default function buildIfNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"if_region\", status);\n\tconst indexName = nextVarName(\"if_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add an else branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@else\") === -1) {\n\t\tconst elseBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@else\",\n\t\t\tstatement: \"else\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(elseBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @if */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"if\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildIfBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\n\tb.append(`}${status.options.dev === true ? `, \"runIf\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildIfBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"if_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`${indexName} = ${index};`);\n\tb.append(\"}\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildReplaceNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst replaceAnchorName = node.varName!;\n\tconst replaceParentName = node.parentName || replaceAnchorName + \".parentNode\";\n\tconst replaceRegionName = nextVarName(\"replace_region\", status);\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(`\n\t/* @replace */\n\tconst ${replaceRegionName} = t_region(${status.options.dev === true ? `\"replace\"` : \"\"});\n\tt_run_control(${replaceRegionName}, ${replaceAnchorName}, (t_before) => {`);\n\n\tbuildReplaceBranch(node, status, b, replaceParentName, replaceRegionName);\n\n\tb.append(`}${status.options.dev === true ? ', \"replace\"' : \"\"});`);\n\tb.append(\"\");\n}\n\nfunction buildReplaceBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n) {\n\tstatus.imports.add(\"t_run_branch\");\n\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\tb.append(`if (!t_run_branch(${regionName}, 0, -1)) return;`);\n\n\tb.append(`\n\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"replace_branch\"` : \"\"});\n\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t`);\n\n\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\tb.append(\"t_pop_region(t_old_region);\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\n\nexport default function buildScriptNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tb.append(`/* ${node.operation} */`);\n\taddMappedText(\"\", `${maybeAppend(node.statement, \";\")}`, \"\", node.span, status, b);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSwitchNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName!;\n\tconst regionName = nextVarName(\"switch_region\", status);\n\tconst indexName = nextVarName(\"switch_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add a default branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@default\") === -1) {\n\t\tconst defaultBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@default\",\n\t\t\tstatement: \"default:\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(defaultBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @switch */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"switch\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildSwitchBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\tb.append(`\n\t\t}\n\t}${status.options.dev === true ? `, \"runSwitch\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildSwitchBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"switch_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`\n\t\t\t${indexName} = ${index};\n\t\t\tbreak;\n\t\t}`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildTryNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"try_region\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\tconst tryBranch = branches.find((n) => n.operation === \"@try\")!;\n\tconst catchBranch = branches.find((n) => n.operation === \"@catch\");\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_try\");\n\n\tb.append(\"\");\n\tb.append(\"/* @try */\");\n\n\taddPushDevBoundary(\"control\", \"@try\", status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"try\"` : \"\"});\n\t\tt_run_try(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\tbuildTryBranchBody(tryBranch, status, b, parentName);\n\n\t// Close the try callback; open the catch callback (or pass null). The\n\t// catch variable becomes the callback's second parameter\n\tconst catchVar = catchBranch\n\t\t? trimMatched(catchBranch.statement.substring(\"catch\".length).trim(), \"(\", \")\") || \"err\"\n\t\t: null;\n\tif (catchBranch && catchVar) {\n\t\taddMappedText(\n\t\t\t\"},\",\n\t\t\t`(${status.inHead ? \"\" : \"t_before\"}, ${replaceForVarNames(catchVar, status)}) => {`,\n\t\t\t\"\",\n\t\t\tcatchBranch.span,\n\t\t\tstatus,\n\t\t\tb,\n\t\t);\n\t\tbuildTryBranchBody(catchBranch, status, b, parentName);\n\t\tb.append(`}${status.options.dev === true ? `, \"runTry\"` : \"\"});`);\n\t} else {\n\t\t// No catch branch: errors propagate up to the nearest boundary\n\t\tb.append(`}, null${status.options.dev === true ? `, \"runTry\"` : \"\"});`);\n\t}\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildTryBranchBody(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n): void {\n\t// NOTE: no region push here — the branch region is pushed by `runTry`'s\n\t// `renderBranch` (the same shape as `@await` branches), so that the\n\t// branch's node window and effects land on the region that\n\t// `runControlBranch` clears\n\tif (node.children.length > 0) {\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAwaitNode from \"./buildAwaitNode\";\nimport buildForNode from \"./buildForNode\";\nimport buildHtmlNode from \"./buildHtmlNode\";\nimport buildIfNode from \"./buildIfNode\";\nimport buildReplaceNode from \"./buildReplaceNode\";\nimport buildScriptNode from \"./buildScriptNode\";\nimport buildSwitchNode from \"./buildSwitchNode\";\nimport buildTryNode from \"./buildTryNode\";\n\nexport default function buildControlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@with\":\n\t\tcase \"@try\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group or @try group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@try group\": {\n\t\t\tbuildTryNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildHtmlNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\":\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tb.append(\"\");\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tb.append(\"\");\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","/**\n * Trims a char from the end of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the end of the text\n *\n * @returns The text without the char on the end\n */\nexport default function trimEnd(text: string, char: string): string {\n\tlet end = text.length;\n\twhile (text[end - 1] === char) {\n\t\tend -= 1;\n\t}\n\treturn text.substring(0, end);\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildMount(\n\t// TODO: like in buildRun\n\t_functionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\tstatus.imports.add(\"$onmount\");\n\t// Ignore errors if the user hasn't returned a cleanup function\n\tb.append(\"// @ts-ignore\\n$onmount(() => {\");\n\tb.append(functionBody);\n\tb.append(\"});\");\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport forVarsReadIn from \"../../utils/forVarsReadIn\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRun(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n): void {\n\tvalue = replaceForVarNames(value, status);\n\tlet functionBody = functionStart + value + functionEnd;\n\tlet forVarMask =\n\t\tstatus.forVarNames.length > 0 ? forVarsReadIn(value, status.forVarNames) : undefined;\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: [span],\n\t\toffsets: [functionStart.length],\n\t\tlengths: [value.length],\n\t\tforVarMask,\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport forVarsReadIn from \"../../utils/forVarsReadIn\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRunWithOffsets(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n): void {\n\tlet functionBody = functionStart + value + functionEnd;\n\n\tfor (let i = 0; i < offsets.length; i++) {\n\t\toffsets[i] += functionStart.length;\n\t\tconst oldLength = functionBody.length;\n\t\tfunctionBody =\n\t\t\tfunctionBody.substring(0, offsets[i]) +\n\t\t\treplaceForVarNames(functionBody.substring(offsets[i], offsets[i] + lengths[i]), status) +\n\t\t\tfunctionBody.substring(offsets[i] + lengths[i]);\n\t\tconst changedLength = functionBody.length - oldLength;\n\t\tlengths[i] += changedLength;\n\t\tfor (let j = i + 1; j < offsets.length; j++) {\n\t\t\toffsets[j] += changedLength;\n\t\t}\n\t}\n\n\tlet forVarMask =\n\t\tstatus.forVarNames.length > 0 ? forVarsReadIn(functionBody, status.forVarNames) : undefined;\n\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: spans,\n\t\toffsets,\n\t\tlengths,\n\t\tforVarMask,\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimEnd from \"../../utils/trimEnd\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildMount from \"./buildMount\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\nimport stashRun from \"./stashRun\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildElementNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n): void {\n\tif (status.inHead) {\n\t\tif (node.tagName === \"title\") {\n\t\t\tbuildTitleNode(node, status, b);\n\t\t} else {\n\t\t\tbuildHeadNode(node, status, b);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst svgElement = node.tagName === \"svg\";\n\tconst oldns = status.ns;\n\tif (svgElement) {\n\t\tstatus.ns = true;\n\t}\n\n\tconst varName = node.varName;\n\tif (varName) {\n\t\tif (node.tagName === \"@element\") {\n\t\t\tbuildDynamicElementNode(node, status, b);\n\t\t\treturn;\n\t\t}\n\n\t\tbuildElementAttributes(node, varName, status, b);\n\t}\n\n\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\tstatus.preserveWhitespace = node.tagName === \"code\" || node.tagName === \"pre\";\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"null\");\n\t}\n\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\n\tif (svgElement) {\n\t\tstatus.ns = oldns;\n\t}\n}\n\nfunction buildDynamicElementNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\n\tif (selfAttribute && selfAttribute.value) {\n\t\tstatus.imports.add(\"t_dynamic\");\n\t\tlet selfValue = selfAttribute.value;\n\n\t\tif (selfAttribute.fullyReactive) {\n\t\t\t// Swap the tag whenever the expression changes. Emitted BEFORE\n\t\t\t// the attributes below, so the events it stashes (and the\n\t\t\t// reactive attribute runs) apply to the swapped element;\n\t\t\t// t_dynamic copies the current attribute values and event\n\t\t\t// listeners onto the new tag\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(\"$run(() => {\");\n\t\t\tb.append(`${node.varName} = t_dynamic(${node.varName}, ${selfValue});`);\n\t\t\tb.append(`}${status.options.dev === true ? `, \"setDynamic\"` : \"\"});`);\n\t\t} else {\n\t\t\t// A static (or interpolated, non-reactive) tag: swap once\n\t\t\tb.append(`${node.varName} = t_dynamic(${node.varName}, ${selfValue});`);\n\t\t}\n\t}\n\n\t// Apply the element's reactive attributes and events —\n\t// buildElementAttributes skips `self` (and &ref) itself. Static\n\t// attributes are already in the fragment's template HTML and are\n\t// carried across tag swaps by t_dynamic's attribute copy\n\tbuildElementAttributes(node, node.varName!, status, b);\n\n\t// Process children with the existing fragment stack (parent's fragment),\n\t// so text content effects are properly stashed and emitted by the parent\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, node.varName!, \"null\");\n\t}\n}\n\nfunction buildTitleNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet content = (node.children[0] as TextNode).content || \"\";\n\n\t// Replace all spaces with a single space, both to save space and to remove\n\t// newlines from generated JS strings\n\tcontent = content.replace(/\\s+/g, \" \");\n\n\t// TODO: Should be fancier about this in parse -- e.g. ignore braces in\n\t// quotes, unclosed, etc\n\tlet reactiveStarted = false;\n\tlet reactiveCount = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tif (content[i] === \"{\") {\n\t\t\treactiveStarted = true;\n\t\t} else if (content[i] === \"}\") {\n\t\t\tif (reactiveStarted) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\treactiveStarted = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (reactiveCount) {\n\t\tstatus.imports.add(\"t_fmt\");\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\tcontent = `t_fmt(${content.substring(1, content.length - 1)})`;\n\t\t} else {\n\t\t\tcontent = `\\`${content.replaceAll(\"{\", \"${t_fmt(\").replaceAll(\"}\", \")}\")}\\``;\n\t\t}\n\t} else {\n\t\tcontent = `\"${content}\"`;\n\t}\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_old_title = document.title;\n\t\t\tdocument.title = ${content};\n\t\t\treturn () => document.title = t_old_title;\n\t\t}${status.options.dev === true ? `, \"runTitle\"` : \"\"});`);\n}\n\nfunction buildHeadNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tstatus.imports.add(\"$run\");\n\tstatus.imports.add(\"t_head_element\");\n\t// Look for an existing element to reuse, so that hydrating server rendered\n\t// tags (or revisiting a page with the same tags) doesn't add duplicates\n\t// to the head. The title is handled separately, in buildTitleNode\n\tconst selector = headElementSelector(node);\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_head_el = t_head_element(\"${node.tagName}\", ${JSON.stringify(selector)});`);\n\tfor (let { name, value, span } of node.attributes) {\n\t\tif (value != null) {\n\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\tvalue = replaceForVarNames(value, status);\n\t\t\taddMappedText(`t_attribute(t_head_el, \"${name}\", `, value, \");\", span, status, b);\n\t\t}\n\t}\n\tb.append(`}${status.options.dev === true ? `, \"runHead\"` : \"\"});`);\n}\n\n/**\n * Builds a selector that finds an equivalent element in the head, from the\n * attributes that identify it (e.g. `meta[name=\"description\"]`). Returns an\n * empty string when the element has no identifying attributes, in which case\n * a new element is always created.\n */\nfunction headElementSelector(node: ElementNode): string {\n\tconst identityAttributes = [\"name\", \"property\", \"rel\", \"charset\", \"http-equiv\", \"itemprop\"];\n\tconst parts: string[] = [];\n\tfor (let { name, value, reactive } of node.attributes) {\n\t\tif (!identityAttributes.includes(name) || value == null || reactive) continue;\n\t\tconst attributeValue = trimQuotes(value).replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n\t\tparts.push(`[${name}=\"${attributeValue}\"]`);\n\t}\n\treturn parts.length ? node.tagName + parts.join(\"\") : \"\";\n}\n\nfunction buildElementAttributes(\n\tnode: ElementNode,\n\tvarName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) throw new Error(\"No fragment on stack\");\n\n\t// TODO: Add an error if any reactive attributes are used non-reactively\n\n\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// Ignore this one, it should have been done already, above\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&group\") {\n\t\t\t\tbuildBindGroupAttribute(node, varName, value, status, b);\n\t\t\t} else if (name === \"&value\" || name === \"&checked\") {\n\t\t\t\tbuildBindAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"onmount\") {\n\t\t\t\t// The onmount event is faked by us by creating an $onmount. This\n\t\t\t\t// also means that you can have unmount functionality by\n\t\t\t\t// returning a cleanup function\n\t\t\t\tbuildMount(\"elMount\", `return (${trimEnd(value.trim(), \";\")})(${varName});`, status, b);\n\t\t\t} else if (name.startsWith(\"on\")) {\n\t\t\t\tbuildEventAttribute(varName, name, value, span, status, b);\n\t\t\t} else if (name.startsWith(\"transition\")) {\n\t\t\t\tbuildTransitionAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRun(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspan,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRun(fragment, `${varName}.style.cssText += t_style(`, value, \");\", span, status);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\tvalue = newValue;\n\t\t\tif (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${varName}.style.cssText += t_style(`,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction buildBindGroupAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Only tested this with radio buttons\n\tlet eventName = \"change\";\n\tlet inputValue = node.attributes.find((a) => a.name === \"value\")?.value;\n\tlet set = `${value} == ${inputValue}`;\n\tlet propName = \"checked\";\n\tconst setAttribute = `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => {\n\t\t\tif (e.target.${propName}) ${value} = ${inputValue};\n\t\t});`);\n}\n\nfunction buildBindAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Need to check the element to find out what type of event to add\n\tlet eventName = \"input\";\n\tlet defaultValue = '\"\"';\n\tlet inputValue = \"e.target.value\";\n\tif (node.tagName === \"input\") {\n\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\tcase \"number\": {\n\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\tinputValue = \"Number(e.target.value)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\tinputValue = \"e.target.checked\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"radio\": {\n\t\t\t\t\teventName = \"change\";\n\t\t\t\t\tinputValue = \"e.target.value\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (node.tagName === \"select\") {\n\t\teventName = \"change\";\n\t\t// <select multiple> binds an array of selected option values\n\t\tlet multipleAttribute = node.attributes.find((a) => a.name === \"multiple\");\n\t\tif (multipleAttribute) {\n\t\t\tbuildRun(\n\t\t\t\t\"setBinding\",\n\t\t\t\t`Array.from(${varName}.options).forEach((opt) => opt.selected = Array.isArray(${value}) && ${value}.includes(opt.value));`,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t);\n\t\t\tstatus.imports.add(\"t_event\");\n\t\t\tb.append(\n\t\t\t\t`t_event(${varName}, \"change\", (e) => ${value} = Array.from(e.target.selectedOptions).map((opt) => opt.value));`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t}\n\tlet set = `${value} || ${defaultValue}`;\n\tconst propName = name.substring(1);\n\t// NOTE: The DOM value property is always a string, while the bound state\n\t// may be a number (e.g. with `<input type=\"number\">`), so convert\n\tconst setAttribute =\n\t\tpropName === \"value\"\n\t\t\t? `${varName}.${propName} = String(${set})`\n\t\t\t: `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => ${value} = ${inputValue});`);\n}\n\nfunction buildEventAttribute(\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Add an event listener, after the fragment has been added\n\tconst eventName = name.substring(2);\n\tstatus.imports.add(\"t_event\");\n\taddMappedText(`t_event(${varName}, \"${eventName}\", `, value, `);`, span, status, b);\n}\n\nfunction buildTransitionAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\tstatus.imports.add(\"t_animate\");\n\n\t// Add an in and out transition, after the fragment has been added\n\t// TODO: Separate these -- you should be able to have multiple,\n\t// unrelated entry and exit transitions?\n\tlet entryVarName = nextVarName(\"trans_in\", status);\n\tlet exitVarName = nextVarName(\"trans_out\", status);\n\n\tif (name === \"transition\") {\n\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\tb.append(`const ${exitVarName} = ${entryVarName};`);\n\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t} else if (name === \"transition-in\") {\n\t\tlet outAttribute = node.attributes.find((a) => a.name === \"transition-out\");\n\t\tif (outAttribute && outAttribute.value && outAttribute.fullyReactive) {\n\t\t\tlet outValue = outAttribute.value;\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`const ${exitVarName} = (${outValue})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t\t} else {\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName});`);\n\t\t}\n\t} else if (name === \"transition-out\") {\n\t\tlet inAttribute = node.attributes.find((a) => a.name === \"transition-in\");\n\t\tif (inAttribute) {\n\t\t\t// This has already been handled with transition-in, above\n\t\t\treturn;\n\t\t} else {\n\t\t\tb.append(`const ${exitVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, null, ${entryVarName});`);\n\t\t}\n\t} else {\n\t\t// TODO: Add an error\n\t}\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\n\nexport default function buildRootNode(\n\tnode: RootNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tbuildFragment(node, status, b, parentName, anchorName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"0:ch/\",\n\t});\n\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, anchorName, true);\n\t}\n\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, anchorName);\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSlotNode(node: ElementNode, status: BuildStatus, b: Builder): void {\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"slot_props\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: { name: string; value: string; span: SourceSpan }[] = [];\n\t\tlet runs: string[] = [];\n\n\t\tfor (let { name, value, reactive, span } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tprops.push({ name, value, span });\n\t\t\t\tif (reactive) {\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\", span });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`const ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\taddMappedText(`${p.name}: `, value, \",\", p.span, status, b);\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t}\n\n\tconst slotParentName = node.parentName!;\n\tconst slotAnchorName = node.varName!;\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tlet params = [slotParentName, slotAnchorName, slotHasProps ? propsName : \"undefined\", \"$context\"];\n\tb.append(`$slots[\"${slotName}\"](${params.join(\", \")})`);\n\n\t// TODO: Maybe not if there's only a single space node?\n\tconst fill = node.children.find(\n\t\t(c) => isSpecialNode(c) && (c.tagName === \"fill\" || c.tagName === \"filldef\"),\n\t);\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tbuildFragment(fill, status, b, slotParentName, slotAnchorName);\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: fill.fragment,\n\t\t\tpath: \"0:ch/\",\n\t\t});\n\t\tfor (let child of fill.children) {\n\t\t\tbuildNode(child, status, b, slotParentName, slotAnchorName);\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(fill, status, b, slotParentName, slotAnchorName);\n\t}\n\n\tb.append(`}`);\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildSlotNode from \"./buildSlotNode\";\n\nexport default function buildSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\troot = false,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildElementNode(node, status, b, parentName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentNode(node, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"../../utils/codeScanner\";\nimport type BuildStatus from \"./BuildStatus\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildTextNode(node: TextNode, status: BuildStatus): void {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) return; // probably in @head...\n\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Should we be parsing out the spans here? Like we do with\n\t// attributes? And should we merge this with the attributes logic?\n\tlet textContent = \"\";\n\tlet reactiveCount = 0;\n\tlet reactiveStart = 0;\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\tlet level = 0;\n\tlet maxLevel = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tmaxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\ttextContent += \"${t_fmt(\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\toffsets.push(reactiveStart);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(content, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\t// Copy strings, template strings, comments and regex literals\n\t\t\t\t// into the output as-is\n\t\t\t\ttextContent += content.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += content[i];\n\t}\n\n\t// Only need to build if there is any reactive content, otherwise the plain\n\t// text content will be output in fragment text\n\tif (maxLevel) {\n\t\tlet offsetChange = 0;\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\ttextContent = textContent.substring(2, textContent.length - 1);\n\t\t\toffsetChange = -2;\n\t\t} else {\n\t\t\ttextContent = `\\`${textContent}\\``;\n\t\t\toffsetChange = 1;\n\t\t}\n\n\t\tstatus.imports.add(\"t_fmt\");\n\t\toffsets.map((_, i) => (offsets[i] += offsetChange));\n\n\t\tstashRunWithOffsets(\n\t\t\tfragment,\n\t\t\t`${node.varName}.textContent = `,\n\t\t\ttextContent,\n\t\t\t\";\",\n\t\t\tnode.spans,\n\t\t\toffsets,\n\t\t\tlengths,\n\t\t\tstatus,\n\t\t);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildControlNode from \"./buildControlNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildRootNode from \"./buildRootNode\";\nimport buildSpecialNode from \"./buildSpecialNode\";\nimport buildTextNode from \"./buildTextNode\";\n\nexport default function buildNode(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\troot = false,\n): void {\n\t// Nodes with anchors will have been handled when their containing fragment\n\t// was built so we want to skip them here\n\tif (node.handled) {\n\t\tnode.handled = false;\n\t\treturn;\n\t}\n\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootNode(node as RootNode, status, b, parentName, anchorName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentNode(node as ElementNode, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildElementNode(node as ElementNode, status, b, parentName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialNode(node as ElementNode, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't output comments!\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type TemplateComponent from \"../../../types/TemplateComponent\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport type SourceMapping from \"../../types/SourceMapping\";\nimport Builder from \"../../utils/Builder\";\nimport { codeRanges } from \"../../utils/codeScanner\";\nimport collectMarkupExpressions from \"../../utils/collectMarkupExpressions\";\nimport markupRendersComponent from \"../../utils/markupRendersComponent\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildFragmentText from \"./buildFragmentText\";\nimport buildNode from \"./buildNode\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$bind: 'import { $bind } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$async: 'import { $async } from \"${folder}\";',\n\t$pending: 'import { $pending } from \"${folder}\";',\n\t$refresh: 'import { $refresh } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$onmount: 'import { $onmount } from \"${folder}\";',\n\t$stream: 'import { $stream } from \"${folder}\";',\n\tfromElement: 'import { fromElement } from \"${folder}\";',\n\tfromServer: 'import { fromServer } from \"${folder}\";',\n\tfromWebSocket: 'import { fromWebSocket } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_region: 'import { t_region } from \"${folder}\";',\n\tt_push_region: 'import { t_push_region } from \"${folder}\";',\n\tt_pop_region: 'import { t_pop_region } from \"${folder}\";',\n\tt_rerun_region_effects: 'import { t_rerun_region_effects } from \"${folder}\";',\n\tt_run_control: 'import { t_run_control } from \"${folder}\";',\n\tt_run_branch: 'import { t_run_branch } from \"${folder}\";',\n\tt_list_item: 'import { t_list_item } from \"${folder}\";',\n\tt_run_list: 'import { t_run_list } from \"${folder}\";',\n\tt_run_await: 'import { t_run_await } from \"${folder}\";',\n\tt_run_try: 'import { t_run_try } from \"${folder}\";',\n\tt_add_fragment: 'import { t_add_fragment } from \"${folder}\";',\n\tt_add_element: 'import { t_add_element } from \"${folder}\";',\n\tt_apply_props: 'import { t_apply_props } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tt_attribute: 'import { t_attribute } from \"${folder}\";',\n\tt_dynamic: 'import { t_dynamic } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_head_element: 'import { t_head_element } from \"${folder}\";',\n\tt_fragment: 'import { t_fragment } from \"${folder}\";',\n\tt_fragment_el: 'import { t_fragment_el } from \"${folder}\";',\n\tt_event: 'import { t_event } from \"${folder}\";',\n\tt_animate: 'import { t_animate } from \"${folder}\";',\n\tt_root: 'import { t_root } from \"${folder}\";',\n\tt_root_el: 'import { t_root_el } from \"${folder}\";',\n\tt_anchor: 'import { t_anchor } from \"${folder}\";',\n\tt_first_inside: 'import { t_first_inside } from \"${folder}\";',\n\tt_child: 'import { t_child } from \"${folder}\";',\n\tt_next: 'import { t_next } from \"${folder}\";',\n\tt_skip: 'import { t_skip } from \"${folder}\";',\n\tt_frg: 'import { t_frg } from \"${folder}\";',\n\tt_save_hydration: 'import { t_save_hydration } from \"${folder}\";',\n\tt_restore_hydration: 'import { t_restore_hydration } from \"${folder}\";',\n\tt_elm: 'import { t_elm } from \"${folder}\";',\n\tt_txt: 'import { t_txt } from \"${folder}\";',\n\tt_cmt: 'import { t_cmt } from \"${folder}\";',\n\tt_print: 'import { t_print } from \"${folder}\";',\n\tListItem: 'import { type ListItem } from \"${folder}\";',\n\tListItemSpec: 'import { type ListItemSpec } from \"${folder}\";',\n\tSlotRender: 'import { type SlotRender } from \"${folder}\";',\n\t// HACK: this one's a bit different\n\tdevContext: 'import { devContext } from \"${folder}/dev\";',\n\tt_push_dev_bound: 'import { t_push_dev_bound } from \"${folder}/dev\";',\n\tt_pop_dev_bound: 'import { t_pop_dev_bound } from \"${folder}/dev\";',\n};\n\nexport default function buildCode(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\toptions?: BuildOptions,\n): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"SlotRender\");\n\n\t// Build the component\n\tbuildTemplate(template, map, imports, b, options);\n\n\tlet startSize = b.toString().length;\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tconst folder = options?.renderFolder ?? \"@torpor/view\";\n\t\tconst sortedImports = Array.from(imports)\n\t\t\t.map((imp) => (importsMap[imp] ?? imp).replace(\"${folder}\", folder))\n\t\t\t.sort()\n\t\t\t.reverse();\n\t\tb.prepend(\"\");\n\t\tfor (let imp of sortedImports) {\n\t\t\tb.prepend(imp);\n\t\t}\n\t}\n\n\tif (options?.mapped) {\n\t\tlet endSize = b.toString().length;\n\t\tlet diff = endSize - startSize + 1;\n\t\tfor (let m of map) {\n\t\t\tm.compiled.start += diff;\n\t\t\tm.compiled.end += diff;\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildTemplate(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Include markup expressions in import detection: `$`-primitives used\n\t// inside markup (e.g. `@if ($pending(...))`, `disabled={$pending(...)}`)\n\t// live in the template, not the script.\n\tfor (const component of template.components) {\n\t\tif (component.markup) script += \"\\n\" + collectMarkupExpressions(component.markup);\n\t\tif (component.error) script += \"\\n\" + collectMarkupExpressions(component.error);\n\t\tif (component.head) script += \"\\n\" + collectMarkupExpressions(component.head);\n\t}\n\n\t// Scan only the code in the script: strings, comments and regex literals\n\t// are stripped, so e.g. `$onmount` inside a sample-code string doesn't\n\t// inject an import that nothing uses\n\tlet scriptCode = codeRanges(script)\n\t\t.map(([start, end]) => script.substring(start, end))\n\t\t.join(\"\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(scriptCode)) imports.add(\"$watch\");\n\tif (/\\$bind\\b/.test(scriptCode)) imports.add(\"$bind\");\n\tif (/\\$cache\\b/.test(scriptCode)) imports.add(\"$cache\");\n\tif (/\\$async\\b/.test(scriptCode)) imports.add(\"$async\");\n\tif (/\\$pending\\b/.test(scriptCode)) imports.add(\"$pending\");\n\tif (/\\$refresh\\b/.test(scriptCode)) imports.add(\"$refresh\");\n\tif (/\\$run\\b/.test(scriptCode)) imports.add(\"$run\");\n\tif (/\\$onmount\\b/.test(scriptCode)) imports.add(\"$onmount\");\n\tif (/\\$stream\\b/.test(scriptCode)) imports.add(\"$stream\");\n\tif (/\\bfromElement\\b/.test(scriptCode)) imports.add(\"fromElement\");\n\tif (/\\bfromServer\\b/.test(scriptCode)) imports.add(\"fromServer\");\n\tif (/\\bfromWebSocket\\b/.test(scriptCode)) imports.add(\"fromWebSocket\");\n\tif (/\\$unwrap\\b/.test(scriptCode)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(scriptCode)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(scriptCode)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\tlet status: BuildStatus = makeStatus(imports, map, current, options);\n\tlet first = true;\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// Reset the status for each new function body\n\t\t\tif (!first) {\n\t\t\t\tstatus = makeStatus(imports, map, current, options);\n\t\t\t}\n\t\t\tfirst = false;\n\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tb.append(`\n\t\t\t\t\t${current.markup ? \"$parent\" : \"_$parent\"}: ParentNode,\n\t\t\t\t\t${current.markup ? \"$anchor\" : \"_$anchor\"}: Node | null,`);\n\t\t\tif (current.params !== undefined) {\n\t\t\t\taddMappedText(\"\", current.params, \",\", chunk.span, status, b);\n\t\t\t} else {\n\t\t\t\tb.append(\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"_$props?: Record<PropertyKey, any>\"},`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t\t${\n\t\t\t\t\tcurrent.contextProps?.length ||\n\t\t\t\t\t(current.markup && markupRendersComponent(current.markup)) ||\n\t\t\t\t\t(current.error && markupRendersComponent(current.error))\n\t\t\t\t\t\t? \"$context\"\n\t\t\t\t\t\t: \"_$context\"\n\t\t\t\t}?: Record<PropertyKey, any>,\n\t\t\t\t${current.slotProps?.length ? \"$slots\" : \"_$slots\"}?: Record<string, SlotRender>,`);\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): void {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Add the component to devContext for display in DevTools\n\t\t\taddPushDevBoundary(\"component\", current.name || \"Anon Component\", status, b);\n\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\tif (current.markup) {\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\n\t\t\t\t// An @error block wraps the render in an error boundary\n\t\t\t\t// (t_run_try), so that BOTH sync render errors and later\n\t\t\t\t// effect re-run errors (routed from triggerEffects) render\n\t\t\t\t// the error content, and a recovery re-render restores the\n\t\t\t\t// normal content. The content builds into $parent/$anchor\n\t\t\t\t// exactly as before — the boundary re-inserts at the same\n\t\t\t\t// position when it switches branches\n\t\t\t\tif (current.error) {\n\t\t\t\t\tstatus.imports.add(\"t_region\");\n\t\t\t\t\tstatus.imports.add(\"t_run_try\");\n\t\t\t\t\tb.append(`const t_error_region = t_region();`);\n\t\t\t\t\tb.append(`t_run_try(t_error_region, $anchor, () => {`);\n\t\t\t\t}\n\n\t\t\t\tbuildFragmentText(current.markup, status, b);\n\t\t\t\tb.append(\"\");\n\t\t\t\tbuildNode(current.markup, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @error */\") {\n\t\t\tif (current.markup && current.error) {\n\t\t\t\tb.append(`}, (_, ${current.errorVar ?? \"err\"}) => {`);\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface error */\");\n\t\t\t\tbuildFragmentText(current.error, status, b);\n\t\t\t\tb.append(\"\");\n\t\t\t\tbuildNode(current.error, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t\tb.append(`}${status.options.dev === true ? ', \"runError\"' : \"\"});`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\tif (current.head) {\n\t\t\t\t// Add the head tags\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Head */\");\n\t\t\t\tstatus.inHead = true;\n\t\t\t\tbuildNode(current.head, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t\tstatus.inHead = false;\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t// No styles in the client\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\taddPopDevBoundary(status, b);\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\taddMappedText(\"\", chunk.script, \"\", chunk.span, status, b);\n\t\t}\n\t}\n}\n\nfunction makeStatus(\n\timports: Set<string>,\n\tmap: SourceMapping[],\n\tcurrent?: TemplateComponent,\n\toptions?: BuildOptions,\n): BuildStatus {\n\treturn {\n\t\timports,\n\t\tprops: current?.props ?? [],\n\t\tcontextProps: current?.contextProps ?? [],\n\t\tslotProps: current?.slotProps ?? [],\n\t\tstyleHash: current?.style?.hash ?? \"\",\n\t\tmap,\n\t\tvarNames: {},\n\t\tfragmentStack: [],\n\t\tforVarNames: [],\n\t\tns: false,\n\t\tpreserveWhitespace: false,\n\t\tinHead: false,\n\t\toptions: options ?? {},\n\t};\n}\n","import type AttributeNode from \"../../types/styles/AttributeNode\";\nimport type BlockNode from \"../../types/styles/BlockNode\";\nimport type Style from \"../../types/styles/Style\";\nimport type StyleNode from \"../../types/styles/StyleNode\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildStyles(style: Style, styleHash: string): string {\n\tconst b = new Builder();\n\n\tfor (let block of style.children) {\n\t\tbuildStyleNode(block, b, styleHash);\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildStyleNode(node: StyleNode, b: Builder, styleHash: string) {\n\tswitch (node.type) {\n\t\tcase \"block\": {\n\t\t\tbuildBlockNode(node as BlockNode, b, styleHash);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"attribute\": {\n\t\t\tbuildAttributeNode(node as AttributeNode, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't include comments\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid style node type: ${node.type}`);\n\t\t}\n\t}\n}\n\nfunction buildBlockNode(block: BlockNode, b: Builder, styleHash: string) {\n\t// TODO: This should probably be done while parsing\n\t// And handle attribute selectors\n\tif (block.selector.startsWith(\"@\")) {\n\t\t// Just output media queries and properties as-is\n\t\tb.append(`${block.selector} {`);\n\t} else {\n\t\tblock.selector = block.selector.replaceAll(/\\s+/g, \" \");\n\t\tlet selectors: string[] = [];\n\t\tlet global = false;\n\t\tlet start = 0;\n\t\tfor (let i = 0; i <= block.selector.length; i++) {\n\t\t\tif (block.selector.substring(i).startsWith(\":global(\")) {\n\t\t\t\ti += \":global\".length;\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = true;\n\t\t\t} else if (global && block.selector[i] === \")\") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = false;\n\t\t\t} else if (\"*,>+~\".includes(block.selector[i])) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tselectors.push(block.selector[i]);\n\t\t\t\tstart = i + 1;\n\t\t\t} else if (i === block.selector.length) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t} else if (block.selector[i] === \" \") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t}\n\t\t}\n\t\tb.append(`${selectors.join(\" \").replaceAll(\" ,\", \",\")} {`);\n\t}\n\tfor (let child of block.children) {\n\t\tbuildStyleNode(child, b, styleHash);\n\t}\n\tb.append(`}`);\n}\n\nfunction addSelector(\n\tselectors: string[],\n\tselector: string,\n\tstyleHash: string,\n\tstart: number,\n\tend: number,\n\tglobal: boolean,\n) {\n\tif (end > start) {\n\t\tlet s = selector.substring(start, end);\n\t\tif (!global) {\n\t\t\tlet pre = s;\n\t\t\tlet post = \"\";\n\t\t\t// We might need to handle e.g. `:hover` or `::before`\n\t\t\tlet colonPosition = s.indexOf(\":\");\n\t\t\tif (colonPosition !== -1) {\n\t\t\t\tpre = s.substring(0, colonPosition);\n\t\t\t\tpost = s.substring(colonPosition);\n\t\t\t}\n\t\t\ts = `${pre}.torp-${styleHash}${post}`;\n\t\t}\n\t\tselectors.push(s);\n\t}\n}\n\nfunction buildAttributeNode(attribute: AttributeNode, b: Builder) {\n\tb.append(`${attribute.name}: ${attribute.value};`);\n}\n","import type Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\n/**\n * Appends any pending output to the generated code, targeting the body\n * string -- or the head string, when building inside a @head block.\n */\nexport default function flushOutput(status: BuildServerStatus, b: Builder): void {\n\tif (status.output) {\n\t\tb.append(`${status.inHead ? \"t_head\" : \"t_body\"} += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Props\n\tconst componentHasProps = node.attributes.length; // || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// TODO: defaults etc props\n\n\t\t// Gather props, and set them all at once\n\t\tlet props: { name: string; value: string }[] = [];\n\n\t\tfor (let { name, value } of node.attributes) {\n\t\t\t// No binding on the server\n\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\tname = name.substring(1);\n\t\t\t}\n\n\t\t\tif (name === \"class\" && value != null) {\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tvalue = `[${value}, \"torp-${status.styleHash}\"]`;\n\t\t\t\t}\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else if (name === \"style\" && value != null) {\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else if (value != null) {\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\" });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props that we gathered\n\t\tb.append(`const ${propsName} = {`);\n\t\tfor (let p of props) {\n\t\t\tb.append(p.name ? `${p.name}: ${p.value},` : `${p.value},`);\n\t\t}\n\t\tb.append(\"};\");\n\n\t\t// NOTE: Not sure if this is needed\n\t\t/*\n\t\tif (root) {\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t${propsName}[name] = $props[name];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t\t*/\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, ServerSlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && (slot.tagName === \"fill\" || slot.tagName === \"filldef\")) {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\t// NOTE: The $slot param is only declared with its real name\n\t\t\t\t\t// when the fill reads it (hasSlotProps), otherwise it would\n\t\t\t\t\t// be reported as unused\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$slot: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"_$slot?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n// eslint-disable-next-line no-unused-vars\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\t// NOTE: The @ts-ignore suppresses the assignability error from\n\t\t\t\t// the required $slot param, which is not compatible with the\n\t\t\t\t// optional $slot param of the ServerSlotRender type\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\t\t\t\tb.append(`let t_body = \"\";`);\n\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildServerNode(child, status, b);\n\t\t\t\t}\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\n\t\t\t\tb.append(\"return t_body;\");\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// Render the component\n\tlet renderParams = `${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\tconst componentResult = nextVarName(\"comp\", status);\n\tb.append(`const ${componentResult} = ${componentName}(${renderParams});`);\n\tb.append(`${status.inHead ? \"t_head\" : \"t_body\"} += ${componentResult}.body;`);\n\tb.append(`t_head += ${componentResult}.head;`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerAwaitNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// On the server, render the `with` branch (the pending state) since the\n\t// promise hasn't resolved yet. The client will hydrate and swap to content\n\t// when the $async getter resolves.\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch) && branch.operation === \"@with\") {\n\t\t\tbuildServerAwaitBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerAwaitBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerForNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the for statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerForBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerForBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerHtmlNode(node: ControlNode, status: BuildServerStatus): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\t// Build the html statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tstatus.output += `\\${${branch.statement}}`;\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerIfNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the if statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerIfBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerIfBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerReplaceNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the replace statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerReplaceBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerReplaceBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement};`);\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildServerScriptNode(node: ControlNode, b: Builder): void {\n\tb.append(`${maybeAppend(node.statement, \";\")}`);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerSwitchNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the switch statement\n\tb.append(`${node.statement} {`);\n\tfor (let branch of node.children.filter((c) => isControlNode(c))) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerSwitchBranch(branch, status, b);\n\t\t}\n\t}\n\tb.append(\"}\");\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerSwitchBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n\n\tb.append(\"break;\");\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerTryNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\tlet tryBranch = branches.find((n) => n.operation === \"@try\");\n\tlet catchBranch = branches.find((n) => n.operation === \"@catch\");\n\n\tif (catchBranch) {\n\t\t// Snapshot t_body and t_head so that any partially-flushed try output\n\t\t// is discarded if the try branch throws — including <head> tags\n\t\t// appended by child components or styles rendered before the throw\n\t\tb.append(`const t_try_body = t_body;`);\n\t\tb.append(`const t_try_head = t_head;`);\n\t\tb.append(\"try {\");\n\t\tif (tryBranch) {\n\t\t\tbuildServerTryBranch(tryBranch, status, b);\n\t\t}\n\n\t\tconst catchVar = trimMatched(catchBranch.statement.substring(\"catch\".length).trim(), \"(\", \")\");\n\t\tb.append(`} catch (${catchVar || \"err\"}) {`);\n\t\tb.append(\"t_body = t_try_body;\");\n\t\tb.append(\"t_head = t_try_head;\");\n\t\tbuildServerTryBranch(catchBranch, status, b);\n\t\tb.append(\"}\");\n\t} else if (tryBranch) {\n\t\tbuildServerTryBranch(tryBranch, status, b);\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerTryBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerAwaitNode from \"./buildServerAwaitNode\";\nimport buildServerForNode from \"./buildServerForNode\";\nimport buildServerHtmlNode from \"./buildServerHtmlNode\";\nimport buildServerIfNode from \"./buildServerIfNode\";\nimport buildServerReplaceNode from \"./buildServerReplaceNode\";\nimport buildServerScriptNode from \"./buildServerScriptNode\";\nimport buildServerSwitchNode from \"./buildServerSwitchNode\";\nimport buildServerTryNode from \"./buildServerTryNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerControlNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildServerIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildServerSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildServerForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildServerAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@with\":\n\t\tcase \"@try\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group or @try group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@try group\": {\n\t\t\tbuildServerTryNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildServerReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildServerHtmlNode(node, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\": {\n\t\t\tflushOutput(status, b);\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tflushOutput(status, b);\n\t\t\t//b.append(\"/* eslint-disable */\");\n\t\t\tb.append(\"\");\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tb.append(\"\");\n\t\t\t//b.append(\"/* eslint-enable */\");\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\t// These can't be used on the server\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport voidTags from \"../../utils/voidTags\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerElementNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tlet attributes = buildElementAttributes(node, status);\n\tif (attributes.length) {\n\t\tattributes = \" \" + attributes;\n\t}\n\n\tlet tagName = node.tagName;\n\tif (tagName === \"@element\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute) {\n\t\t\ttagName = `$\\{${selfAttribute.value}}`;\n\t\t}\n\t}\n\n\t// NOTE: Only void tags can be self-closed in HTML, although we allow it in\n\t// templates and auto-expand it here\n\tstatus.output += `<${tagName}${attributes}>`;\n\tif (!voidTags.includes(tagName)) {\n\t\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\t\tstatus.preserveWhitespace = [\"pre\", \"code\"].includes(tagName);\n\t\tfor (let child of node.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\t\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\t\tstatus.output += `</${tagName}>`;\n\t}\n}\n\nfunction buildElementAttributes(node: ElementNode, status: BuildServerStatus) {\n\t// Elements in a @head block never get the scoped class name\n\tlet needsClass = node.scopeStyles && !status.inHead;\n\tlet attributes: string[] = [];\n\tfor (let { name, value, reactive, fullyReactive } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// No elements on the server\n\t\t} else if (name.startsWith(\"on\") || name.startsWith(\":on\")) {\n\t\t\t// No events on the server\n\t\t} else if (name.startsWith(\"transition\") && value) {\n\t\t\t// TODO: No animation on the server, but we do need to set the\n\t\t\t// attributes from the first keyframe\n\t\t\t// HACK: use a regex instead maybe?\n\t\t\t//value = value.split(\",\")[0].trim();\n\t\t\t//if (value.startsWith(\"[\")) {\n\t\t\t//\tvalue = value.substring(1);\n\t\t\t//} else {\n\t\t\t//\tvalue = value + \"[0]\";\n\t\t\t//}\n\t\t\t//attributes.push(\n\t\t\t//\t`style=\"\\${Object.entries(${value}).map(([k, v]) => \\`$\\{k}: $\\{v}\\`).join(\"; \")}\"`,\n\t\t\t//);\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&value\" || name === \"&checked\" || name === \"&group\") {\n\t\t\t\t// <select multiple> doesn't use a value attribute; the client\n\t\t\t\t// sets option.selected during hydration\n\t\t\t\tif (\n\t\t\t\t\tname === \"&value\" &&\n\t\t\t\t\tnode.tagName === \"select\" &&\n\t\t\t\t\tnode.attributes.some((a) => a.name === \"multiple\")\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet defaultValue = \"\";\n\t\t\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\t\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\t\t\tcase \"number\": {\n\t\t\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultValue) {\n\t\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\t\tvalue = `t_attr(${value})`;\n\t\t\t\t\tdefaultValue = '\"\"';\n\t\t\t\t}\n\t\t\t\tlet valueOrDefault = `${value} || ${defaultValue}`;\n\t\t\t\tconst propName = name.substring(1);\n\t\t\t\tattributes.push(`${propName}=\"\\${${valueOrDefault}}\"`);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tlet params = [value];\n\t\t\t\tif (node.scopeStyles && !status.inHead) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\tneedsClass = false;\n\t\t\t\t}\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// HACK: don't call t_class twice -- maybe there should be a buildServerClasses?\n\t\t\t\tvalue = params.join(\", \");\n\t\t\t\tattributes.push(`\\${t_class(${value}) !== \"\" ? \\`class=\"\\${t_class(${value})}\"\\` : \"\"}`);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// HACK: don't call t_style twice -- maybe there should be a buildServerStyles?\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tattributes.push(`\\${t_style(${value}) !== \"\" ? \\`style=\"\\${t_style(${value})}\"\\` : \"\"}`);\n\t\t\t} else {\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// e.g. `... ${className ? `class=\"${className}\"` : ''} ...`\n\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\tattributes.push(`\\${${value} ? \\`${name}=\"\\${t_attr(${value})}\"\\` : \"\"}`);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\t// TODO: Match braces, don't replace braces inside code\n\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\tattributes.push(\n\t\t\t\t`${name}=\"${trimQuotes(value).replaceAll(\"{\", \"${t_attr(\").replaceAll(\"}\", \")}\")}\"`,\n\t\t\t);\n\t\t} else if (name === \"class\" && node.scopeStyles && !status.inHead) {\n\t\t\tvalue = value\n\t\t\t\t? `\"${trimQuotes(value)} torp-${status.styleHash}\"`\n\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t\tneedsClass = false;\n\t\t} else if (value != null) {\n\t\t\t// Just set the attribute\n\t\t\t// TODO: Probably check if it's a boolean attribute e.g. disabled\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t} else {\n\t\t\tattributes.push(`${name}`);\n\t\t}\n\t}\n\tif (needsClass) {\n\t\tattributes.push(`class=\"torp-${status.styleHash}\"`);\n\t}\n\treturn attributes.join(\" \");\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerRootNode(\n\tnode: RootNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerSlotNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"slot_props\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tb.append(`const ${propsName}: any = {};`);\n\t\tfor (let { name, value } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t} else {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = true;`);\n\t\t\t}\n\t\t}\n\t}\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tb.append(\n\t\t`${status.inHead ? \"t_head\" : \"t_body\"} += $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`,\n\t);\n\t////const slotResult = nextVarName(\"comp\", status);\n\t////b.append(\n\t////\t`const ${slotResult} = $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`,\n\t////);\n\t////b.append(`t_body += ${slotResult}.body;`);\n\t////b.append(`t_head += ${slotResult}.head;`);\n\n\t// TODO: Not if there's only a single space node -- maybe check in parse\n\tconst fill = node.children.find(\n\t\t(c) => isSpecialNode(c) && (c.tagName === \"fill\" || c.tagName === \"filldef\"),\n\t);\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tfor (let child of fill.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\n\t\tflushOutput(status, b);\n\t}\n\n\tb.append(`}`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerSlotNode from \"./buildServerSlotNode\";\n\nexport default function buildServerSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildServerSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildServerElementNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildServerComponentNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"../../utils/codeScanner\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerTextNode(node: TextNode, status: BuildServerStatus): void {\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Move all of this logic into parse, for text nodes and attribute values\n\tlet level = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tif (level === 1) {\n\t\t\t\tstatus.imports.add(\"t_fmt\");\n\t\t\t\tstatus.output += \"${t_fmt(\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tstatus.output += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\tstatus.output += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(content, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\t// Copy strings, template strings, comments and regex literals\n\t\t\t\t// into the output as-is. HTML escaping is done at runtime by the\n\t\t\t\t// server's t_fmt, so that literals keep their original meaning.\n\t\t\t\tstatus.output += content.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tstatus.output += char;\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerControlNode from \"./buildServerControlNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerRootNode from \"./buildServerRootNode\";\nimport buildServerSpecialNode from \"./buildServerSpecialNode\";\nimport buildServerTextNode from \"./buildServerTextNode\";\n\nexport default function buildServerNode(\n\tnode: TemplateNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildServerRootNode(node as RootNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildServerControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildServerComponentNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildServerElementNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildServerTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildServerSpecialNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't output comments!\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport Builder from \"../../utils/Builder\";\nimport { codeRanges } from \"../../utils/codeScanner\";\nimport collectMarkupExpressions from \"../../utils/collectMarkupExpressions\";\nimport markupRendersComponent from \"../../utils/markupRendersComponent\";\nimport buildStyles from \"../client/buildStyles\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$bind: 'import { $bind } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$async: 'import { $async } from \"${folder}\";',\n\t$pending: 'import { $pending } from \"${folder}\";',\n\t$refresh: 'import { $refresh } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$onmount: 'import { $onmount } from \"${folder}\";',\n\t$stream: 'import { $stream } from \"${folder}\";',\n\tfromElement: 'import { fromElement } from \"${folder}\";',\n\tfromServer: 'import { fromServer } from \"${folder}\";',\n\tfromWebSocket: 'import { fromWebSocket } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_attr: 'import { t_attr } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tServerSlotRender: 'import { type ServerSlotRender } from \"${folder}\";',\n};\n\nexport default function buildServerCode(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"ServerSlotRender\");\n\n\t// Build the component and any child components\n\tbuildServerTemplate(template, imports, b, options);\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tconst folder = options?.renderFolder ?? \"@torpor/view/ssr\";\n\t\tconst sortedImports = Array.from(imports)\n\t\t\t.map((imp) => (importsMap[imp] ?? imp).replace(\"${folder}\", folder))\n\t\t\t.sort()\n\t\t\t.reverse();\n\t\tb.prepend(\"\");\n\t\tfor (let imp of sortedImports) {\n\t\t\tb.prepend(imp);\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildServerTemplate(\n\ttemplate: Template,\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Include markup expressions in import detection: `$`-primitives used\n\t// inside markup live in the template, not the script.\n\tfor (const component of template.components) {\n\t\tif (component.markup) script += \"\\n\" + collectMarkupExpressions(component.markup);\n\t\tif (component.error) script += \"\\n\" + collectMarkupExpressions(component.error);\n\t\tif (component.head) script += \"\\n\" + collectMarkupExpressions(component.head);\n\t}\n\n\t// Scan only the code in the script: strings, comments and regex literals\n\t// are stripped, so e.g. `$onmount` inside a sample-code string doesn't\n\t// inject an import that nothing uses\n\tlet scriptCode = codeRanges(script)\n\t\t.map(([start, end]) => script.substring(start, end))\n\t\t.join(\"\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(scriptCode)) imports.add(\"$watch\");\n\tif (/\\$bind\\b/.test(scriptCode)) imports.add(\"$bind\");\n\tif (/\\$cache\\b/.test(scriptCode)) imports.add(\"$cache\");\n\tif (/\\$async\\b/.test(scriptCode)) imports.add(\"$async\");\n\tif (/\\$pending\\b/.test(scriptCode)) imports.add(\"$pending\");\n\tif (/\\$refresh\\b/.test(scriptCode)) imports.add(\"$refresh\");\n\tif (/\\$run\\b/.test(scriptCode)) imports.add(\"$run\");\n\tif (/\\$onmount\\b/.test(scriptCode)) imports.add(\"$onmount\");\n\tif (/\\$stream\\b/.test(scriptCode)) imports.add(\"$stream\");\n\tif (/\\bfromElement\\b/.test(scriptCode)) imports.add(\"fromElement\");\n\tif (/\\bfromServer\\b/.test(scriptCode)) imports.add(\"fromServer\");\n\tif (/\\bfromWebSocket\\b/.test(scriptCode)) imports.add(\"fromWebSocket\");\n\tif (/\\$unwrap\\b/.test(scriptCode)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(scriptCode)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(scriptCode)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tlet params = [\n\t\t\t\tcurrent.params ??\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"_$props?: Record<PropertyKey, any>\"}`,\n\t\t\t\t`${\n\t\t\t\t\tcurrent.contextProps?.length ||\n\t\t\t\t\t(current.markup && markupRendersComponent(current.markup)) ||\n\t\t\t\t\t(current.error && markupRendersComponent(current.error))\n\t\t\t\t\t\t? \"$context\"\n\t\t\t\t\t\t: \"_$context\"\n\t\t\t\t}?: Record<PropertyKey, any>`,\n\t\t\t\t`${current.slotProps?.length ? \"$slots\" : \"_$slots\"}?: Record<string, ServerSlotRender>`,\n\t\t\t];\n\t\t\tb.append(params.join(\",\\n\") + \",\");\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): { body: string; head: string } {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\n\t\t\t// Declare t_head and t_body\n\t\t\tb.append(`let t_body = \"\";`);\n\t\t\tb.append(`let t_head = \"\";`);\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\tif (current.markup) {\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\n\t\t\t\t// An @error block wraps the render in an implicit try/catch so\n\t\t\t\t// that render-time errors render the error content instead\n\t\t\t\tif (current.error) {\n\t\t\t\t\tb.append(`const t_try_body = t_body;`);\n\t\t\t\t\tb.append(`const t_try_head = t_head;`);\n\t\t\t\t\tb.append(\"try {\");\n\t\t\t\t}\n\n\t\t\t\tbuildServerNode(current.markup, status, b);\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @error */\") {\n\t\t\tif (current.markup && current.error) {\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\tb.append(`} catch (${current.errorVar}) {`);\n\t\t\t\tb.append(\"t_body = t_try_body;\");\n\t\t\t\tb.append(\"t_head = t_try_head;\");\n\n\t\t\t\tb.append(\"/* User interface error */\");\n\t\t\t\tbuildServerNode(current.error, status, b);\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\n\t\t\t\tb.append(\"}\");\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\tif (current.head) {\n\t\t\t\t// Build the head tags (title, meta, etc) into the head string, so\n\t\t\t\t// that they can be hoisted into the document's <head> element.\n\t\t\t\t// The tags are built like any other markup (with the scoped\n\t\t\t\t// class name suppressed), only into t_head instead of t_body\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\tinHead: true,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Head */\");\n\n\t\t\t\tbuildServerNode(current.head, status, b);\n\n\t\t\t\tflushOutput(status, b);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\n\t\t\tif (current.style) {\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Style */\");\n\n\t\t\t\t// Replace multiple spaces with a single space\n\t\t\t\tconst styles = buildStyles(current.style, current.style.hash)\n\t\t\t\t\t.replaceAll('\"', '\\\\\"')\n\t\t\t\t\t.replaceAll(/\\s+/g, \" \");\n\t\t\t\tb.append(`t_head += \"<style id='${current.style.hash}'>${styles}</style>\";\\n`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\tb.append(`return { body: t_body, head: t_head };`);\n\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\tb.append(chunk.script);\n\t\t}\n\t}\n}\n","import isSpace from \"../parse/utils/isSpace\";\nimport type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isControlNode from \"./isControlNode\";\nimport isTextNode from \"./isTextNode\";\nimport { NON_RENDERING_OPERATIONS } from \"./nonRenderingOperations\";\n\n/**\n * Tag names whose contents should keep all whitespace untouched, matching\n * native HTML rendering of `pre`/`textarea` and the existing build-time\n * `preserveWhitespace` behavior for `code`.\n */\nconst PRESERVE_TAGS = new Set([\"pre\", \"textarea\", \"code\"]);\n\n/**\n * Container tags whose child layout ignores inter-child whitespace entirely\n * (table layout collapses it). Inside these, whitespace-only text nodes\n * between children are removed rather than collapsed to a single space.\n */\nconst WHITESPACE_INSIGNIFICANT_TAGS = new Set([\n\t\"tr\",\n\t\"tbody\",\n\t\"thead\",\n\t\"tfoot\",\n\t\"colgroup\",\n\t\"table\",\n\t\"ul\",\n\t\"ol\",\n\t\"select\",\n]);\n\ntype ContainerNode = RootNode | ElementNode | ControlNode;\n\n/**\n * Trims and collapses whitespace text nodes in a parsed markup tree,\n * Svelte 5-style:\n *\n * - pure-whitespace text nodes at the start/end of a container are removed\n * - pure-whitespace text nodes between siblings are collapsed to a single space\n * (or removed entirely inside table/list containers where whitespace is\n * insignificant — see WHITESPACE_INSIGNIFICANT_TAGS)\n * - whitespace inside `pre`, `textarea`, and `code` is preserved\n *\n * Whitespace adjacent to non-rendering control nodes (e.g. `@key`, `@const`)\n * is treated as leading/trailing whitespace of the container and removed,\n * because those nodes produce no DOM output — without this rule, every row\n * of `@for { @key = ...; <tr>...</tr> }` would emit a phantom leading\n * whitespace text node.\n *\n * Mixed text nodes (containing non-whitespace content) are left untouched;\n * their internal whitespace continues to be collapsed at build time. The\n * walk mutates the tree in place and is idempotent.\n *\n * @param node The root node of the markup to trim (a component's markup or head)\n */\nexport default function trimWhitespace(node: ContainerNode): void {\n\ttrimChildren(node.children, false, undefined);\n}\n\nfunction trimChildren(\n\tchildren: TemplateNode[],\n\tpreserveAll: boolean,\n\tparentTag: string | undefined,\n): void {\n\t// Recurse depth-first so descendant containers are normalized before we\n\t// reason about siblings at this level\n\tfor (const child of children) {\n\t\tconst grandChildren = getChildren(child);\n\t\tif (grandChildren) {\n\t\t\tconst childTag = getTagName(child);\n\t\t\tconst childPreserve = preserveAll || PRESERVE_TAGS.has(childTag ?? \"\");\n\t\t\ttrimChildren(grandChildren, childPreserve, childTag);\n\t\t}\n\t}\n\n\tif (preserveAll) return;\n\n\t// Inside table/list containers, all inter-child whitespace is\n\t// insignificant — remove it rather than collapsing to a space\n\tif (parentTag !== undefined && WHITESPACE_INSIGNIFICANT_TAGS.has(parentTag)) {\n\t\tfor (let i = children.length - 1; i >= 0; i--) {\n\t\t\tif (isWhitespaceText(children[i])) {\n\t\t\t\tchildren.splice(i, 1);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\t// Compute leading/trailing masks that treat non-rendering control nodes\n\t// (e.g. @key, @const) as invisible, so that whitespace adjacent to them\n\t// is removed as if it were at the container edge. A whitespace text node\n\t// is \"effectively leading\" if no rendering sibling precedes it, and\n\t// \"effectively trailing\" if no rendering sibling follows it.\n\tconst length = children.length;\n\tconst hasRenderingBefore: boolean[] = Array.from({ length });\n\tconst hasRenderingAfter: boolean[] = Array.from({ length });\n\tlet seenBefore = false;\n\tlet seenAfter = false;\n\tfor (let i = 0; i < length; i++) {\n\t\thasRenderingBefore[i] = seenBefore;\n\t\tif (isRenderingSibling(children[i])) seenBefore = true;\n\t\tconst j = length - 1 - i;\n\t\thasRenderingAfter[j] = seenAfter;\n\t\tif (isRenderingSibling(children[j])) seenAfter = true;\n\t}\n\n\t// Remove pure-whitespace nodes at the effectively-leading or\n\t// effectively-trailing edges of the container\n\tfor (let i = length - 1; i >= 0; i--) {\n\t\tif (isWhitespaceText(children[i]) && (!hasRenderingBefore[i] || !hasRenderingAfter[i])) {\n\t\t\tchildren.splice(i, 1);\n\t\t}\n\t}\n\n\t// Collapse remaining pure-whitespace nodes (between rendering siblings) to one space\n\tfor (const child of children) {\n\t\tif (isTextNode(child) && child.content !== \"\" && isSpace(child.content)) {\n\t\t\tchild.content = \" \";\n\t\t}\n\t}\n}\n\n/**\n * Returns true if `node` is a \"rendering sibling\" — i.e. a node that produces\n * visible DOM output and therefore acts as a boundary between leading,\n * inter-sibling, and trailing whitespace. Whitespace text nodes themselves\n * (the subject of the trim) and non-rendering control nodes (e.g. @key,\n * @const) are not rendering siblings.\n */\nfunction isRenderingSibling(node: TemplateNode): boolean {\n\tif (isWhitespaceText(node)) return false;\n\tif (isControlNode(node) && NON_RENDERING_OPERATIONS.has(node.operation)) return false;\n\treturn true;\n}\n\nfunction getChildren(node: TemplateNode): TemplateNode[] | undefined {\n\tif (node.type === \"text\" || node.type === \"comment\") return undefined;\n\treturn (node as ContainerNode).children;\n}\n\nfunction getTagName(node: TemplateNode): string | undefined {\n\tif (node.type === \"element\" || node.type === \"component\" || node.type === \"special\") {\n\t\treturn (node as ElementNode).tagName;\n\t}\n\treturn undefined;\n}\n\nfunction isWhitespaceText(node: TemplateNode): node is TextNode {\n\treturn isTextNode(node) && node.content !== \"\" && isSpace(node.content);\n}\n","import type Template from \"../types/Template\";\nimport buildCode from \"./build/client/buildCode\";\nimport buildStyles from \"./build/client/buildStyles\";\nimport buildServerCode from \"./build/server/buildServerCode\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport type BuildResult from \"./types/BuildResult\";\nimport type SourceMapping from \"./types/SourceMapping\";\nimport trimWhitespace from \"./utils/trimWhitespace\";\n\n/**\n * Builds a component template into code and styles for rendering\n *\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The component's code and styles\n */\nexport default function build(template: Template, options?: BuildOptions): BuildResult {\n\t// Trim whitespace text nodes (Svelte 5-style) unless explicitly disabled.\n\t// The pass mutates the tree in place but is idempotent, so it is safe even\n\t// when build is called twice (client + server) on the same template.\n\tif (!options?.preserveWhitespace) {\n\t\tfor (const component of template.components) {\n\t\t\tif (component.markup) trimWhitespace(component.markup);\n\t\t\tif (component.error) trimWhitespace(component.error);\n\t\t\tif (component.head) trimWhitespace(component.head);\n\t\t}\n\t}\n\n\tlet map: SourceMapping[] = [];\n\tlet code = options?.server\n\t\t? buildServerCode(template, options)\n\t\t: buildCode(template, map, options);\n\tlet styles = template.components\n\t\t.map((c) =>\n\t\t\tc.style ? { style: buildStyles(c.style, c.style.hash), hash: c.style.hash } : undefined,\n\t\t)\n\t\t.filter((c) => c !== undefined);\n\treturn {\n\t\tcode,\n\t\tstyles,\n\t\tmap,\n\t};\n}\n","import type Template from \"../types/Template\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport Builder from \"./utils/Builder\";\n\n/**\n * Builds a component template into a d.ts file\n *\n * @param name The name of the component\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The d.ts file content\n */\nexport default function buildType(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder();\n\n\tb.append(`import { type SlotRender } from \"${options?.renderFolder || \"@torpor/view\"}\";`);\n\n\tfor (let component of template.components) {\n\t\tif (component.exported) {\n\t\t\tb.append(\"\");\n\t\t\tif (component.propsType) {\n\t\t\t\tb.append(component.propsType);\n\t\t\t\tb.append(\"\");\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t${component.documentation ?? \"\"}\n\t\t\t${component.default ? \"declare\" : \"export declare\"} function ${component.name}${\n\t\t\t\tcomponent.typeParams ?? \"\"\n\t\t\t}(\n\t\t\t\t$parent: ParentNode,\n\t\t\t\t$anchor: Node | null,\n\t\t\t\t${component.params || \"$props?: Record<PropertyKey, any>\"},\n\t\t\t\t$context?: Record<PropertyKey, any>,\n\t\t\t\t$slots?: Record<string, SlotRender>,\n\t\t\t): void;\n\t\t`);\n\t\t\tif (component.default) {\n\t\t\t\tb.append(`export default ${component.name};`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n","/**\n * Returns the index of the closing backtick of the template string that\n * starts at `start`.\n *\n * NOTE: For scanning JavaScript expression text, use `codeScanner.ts` instead\n * -- this variant doesn't handle escaped characters or nested templates in\n * interpolations, and is kept only for non-JS contexts (CSS in `@style`\n * blocks) where a simpler scan is wanted.\n */\nexport default function endOfTemplateString(content: string, start: number): number {\n\t// TODO: Recursively skip strings and comments inside the interpolated JS\n\tlet level = 0;\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === \"`\" && content[j - 1] !== \"\\\\\" && level === 0) {\n\t\t\treturn j;\n\t\t} else if (content[j] === \"{\" && (level > 0 || content[j - 1] === \"$\")) {\n\t\t\tlevel += 1;\n\t\t} else if (content[j] === \"}\" && level > 0) {\n\t\t\tlevel -= 1;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import isSpace from \"../parse/utils/isSpace\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"./isTextNode\";\n\nexport default function isSpaceNode(node: TemplateNode): node is TextNode {\n\treturn isTextNode(node) && isSpace(node.content);\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function accept(value: string, status: ParseStatus, advance = true): boolean {\n\tconst check = status.source.substring(status.i, status.i + value.length);\n\tif (check == value) {\n\t\tstatus.i += advance ? value.length : 0;\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\nimport { skipStringOrComment } from \"../utils/codeScanner\";\n\nexport default function parseInlineScript(status: ParseStatus): string {\n\tconst start = status.i;\n\tlet braceCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tconst skipped = skipStringOrComment(status.source, status.i);\n\t\tif (skipped !== -1) {\n\t\t\tstatus.i = skipped;\n\t\t\tcontinue;\n\t\t}\n\t\tif (accept(\"{\", status)) {\n\t\t\tbraceCount += 1;\n\t\t} else if (accept(\"}\", status)) {\n\t\t\tif (braceCount > 0) {\n\t\t\t\tbraceCount -= 1;\n\t\t\t} else {\n\t\t\t\treturn status.source.substring(start, status.i - 1);\n\t\t\t}\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n","/**\n * Trims a char from the start of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the start of the text\n *\n * @returns The text without the char on the start\n */\nexport default function trimStart(text: string, char: string): string {\n\tlet start = 0;\n\twhile (text[start] === char) {\n\t\tstart += 1;\n\t}\n\treturn text.substring(start);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Consumes space characters and advances the current parse position to before\n * the next non-space character\n *\n * @param status The parse status\n *\n * @returns The string of space characters from the current parse position to\n * the next non-space character\n */\nexport default function consumeSpace(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isSpaceChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function addSpaceElement(\n\tparent: ElementNode | ControlNode,\n\tstatus: ParseStatus,\n): void {\n\tconst content = consumeSpace(status);\n\tif (content) {\n\t\tconst previousNode = parent.children[parent.children.length - 1];\n\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\tpreviousNode.content += content;\n\t\t} else {\n\t\t\tconst space: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tparent.children.push(space);\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied string is fully reactive (i.e. starts and ends with braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully reactive\n */\nexport default function isFullyReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.trim().startsWith(\"{\") && text.trim().endsWith(\"}\");\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Adds an error to the parse status\n *\n * @param status The parse status\n * @param message The error message to add\n * @param start (Optional) The start position of the error (defaults to the\n * current parse position)\n */\nexport default function addError(\n\tstatus: ParseStatus,\n\tmessage: string,\n\tstart: number = status.i,\n\tend: number = status.i,\n): void {\n\tlet startLine = 0;\n\tlet lastLineStart = 0;\n\tlet i = 0;\n\tfor (; i < start; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tstartLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet startChar = start - lastLineStart;\n\tlet endLine = startLine;\n\tfor (; i < end; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tendLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet endChar = end - lastLineStart;\n\tstatus.errors.push({\n\t\tmessage,\n\t\tstartIndex: start,\n\t\tstartLine,\n\t\tstartChar,\n\t\tendIndex: end,\n\t\tendLine,\n\t\tendChar,\n\t});\n}\n","/**\n * Checks whether the supplied character is a alpha-numeric\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is alpha-numeric\n */\nexport default function isAlphaNumericChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn (\n\t\t// 0-9\n\t\t(code > 47 && code < 58) ||\n\t\t// A-Z\n\t\t(code > 64 && code < 91) ||\n\t\t// a-z\n\t\t(code > 96 && code < 123)\n\t);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isAlphaNumericChar from \"./isAlphaNumericChar\";\n\n/**\n * Consumes alpha-numeric characters and advances the current parse position to\n * before the next non-alpha character\n *\n * @param status The parse status\n *\n * @returns The string of alpha-numeric characters from the current parse position\n * to the next non-alpha character\n */\nexport default function consumeAlphaNumeric(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isAlphaNumericChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Consumes characters until one of the characters in the supplied string is\n * found. The parse position will be advanced to before the found character\n *\n * @param chars The characters to match\n * @param status The parse status\n *\n * @returns The string of characters from the current parse position to the\n * found character\n */\nexport default function consumeUntil(chars: string, status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (chars.includes(status.source[status.i])) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type Attribute from \"../types/nodes/Attribute\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isFullyReactive from \"../utils/isFullyReactive\";\nimport isReactive from \"../utils/isReactive\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport addError from \"./utils/addError\";\nimport accept from \"./utils/accept\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\n\nexport default function parseTag(status: ParseStatus): ElementNode {\n\taccept(\"<\", status);\n\n\tlet closeTag = accept(\"/\", status);\n\n\tconsumeSpace(status);\n\n\tlet tagStart = status.i + 1;\n\tlet snailed = accept(\"@\", status);\n\tlet tagName = consumeAlphaNumeric(status);\n\tlet tagEnd = status.i;\n\n\tif (snailed) {\n\t\ttagName = \"@\" + tagName;\n\t}\n\tif (closeTag) {\n\t\ttagName = \"/\" + tagName;\n\t}\n\n\tconsumeSpace(status);\n\n\tlet attributes = parseTagAttributes(status);\n\n\tlet selfClosed = false;\n\tif (accept(\"/>\", status)) {\n\t\tselfClosed = true;\n\t\t// Actually, it is kind of convenient to self-close things, and more consistent with\n\t\t// component tags...\n\t\t//if (!voidTags.includes(tagName)) {\n\t\t//\taddError(status, `Self-closed non-void element: ${tagName}`, start);\n\t\t//}\n\t} else {\n\t\taccept(\">\", status);\n\t}\n\n\tif (closeTag) {\n\t\tselfClosed = true;\n\t}\n\n\tlet special = [\"slot\", \"fill\", \"filldef\", \"@component\", \"@element\"].includes(tagName);\n\n\treturn {\n\t\ttype: special ? \"special\" : \"element\",\n\t\ttagName,\n\t\tselfClosed: selfClosed || undefined,\n\t\tclosed: selfClosed || undefined,\n\t\tattributes,\n\t\tchildren: [],\n\t\tspan: { start: tagStart, end: tagEnd },\n\t} satisfies ElementNode;\n}\n\nfunction parseTagAttributes(status: ParseStatus): Attribute[] {\n\tlet attributes: Attribute[] = [];\n\twhile (status.i < status.source.length) {\n\t\tconsumeSpace(status);\n\t\tif (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"/>\", status, false) || accept(\">\", status, false)) {\n\t\t\t// That's the end of the attributes\n\t\t\tbreak;\n\t\t} else if (\n\t\t\taccept(\"<\", status, false) ||\n\t\t\taccept(\"@\", status, false) ||\n\t\t\taccept(\"}\", status, false)\n\t\t) {\n\t\t\t// It's an unclosed tag -- just bail out here\n\t\t\tbreak;\n\t\t} else {\n\t\t\tconst attribute = parseAttribute(status);\n\t\t\tattributes.push(attribute);\n\t\t}\n\t}\n\treturn attributes;\n}\n\nfunction parseAttribute(status: ParseStatus): Attribute {\n\tlet valueStart = status.i;\n\tlet valueEnd = status.i;\n\tlet name = consumeUntil(\"= \\t\\r\\n/>\", status);\n\tlet value: string | undefined = undefined;\n\tlet reactive = false;\n\tlet fullyReactive = false;\n\tconsumeSpace(status);\n\tif (accept(\"=\", status)) {\n\t\tconsumeSpace(status);\n\t\tvalueStart = status.i;\n\t\tvalue = parseAttributeValue(status);\n\t\tvalueEnd = status.i;\n\t\treactive = isReactive(value);\n\t\tfullyReactive = isFullyReactive(value);\n\t\tif (fullyReactive) {\n\t\t\tvalue = value.substring(1, value.length - 1);\n\t\t\tvalueStart++;\n\t\t\tvalueEnd--;\n\t\t}\n\t} else if (name.startsWith(\"{\") && name.endsWith(\"}\")) {\n\t\tvalue = name.substring(1, name.length - 1);\n\t\tvalueStart++;\n\t\tvalueEnd = valueStart + name.length;\n\t\tif (value.startsWith(\"...\")) {\n\t\t\t// It's a spread attribute, just set the name to the value\n\t\t\tname = value;\n\t\t} else {\n\t\t\t// It's a shortcut attribute. It could be e.g. {width} or it could be\n\t\t\t// {$state.width}, but in either case we set the value of the width\n\t\t\t// property\n\t\t\tname = value.split(\".\").at(-1)!;\n\t\t}\n\t\t// Handle definite assignment assertions e.g. {$state.width!}\n\t\tif (name.endsWith(\"!\")) {\n\t\t\tname = name.substring(0, name.length - 1);\n\t\t}\n\t\treactive = fullyReactive = true;\n\t}\n\n\tif (value != null && reactive && value.startsWith(\"...\")) {\n\t\t// Spread attributes aren't supported -- spell the attributes (or\n\t\t// props) out explicitly instead\n\t\taddError(status, `Spread attributes are not supported`, valueStart, valueEnd);\n\t}\n\n\treturn {\n\t\tname,\n\t\tvalue,\n\t\treactive,\n\t\tfullyReactive,\n\t\tspan: { start: valueStart, end: valueEnd },\n\t};\n}\n\nfunction parseAttributeValue(status: ParseStatus): string {\n\tif (accept('\"', status)) {\n\t\tconst value = consumeUntil('\"', status);\n\t\taccept('\"', status);\n\t\treturn `\"${value}\"`;\n\t} else if (accept(\"'\", status)) {\n\t\tconst value = consumeUntil(\"'\", status);\n\t\taccept(\"'\", status);\n\t\treturn `'${value}'`;\n\t} else if (accept(\"{\", status)) {\n\t\tconst value = parseInlineScript(status);\n\t\treturn `{${value}}`;\n\t} else {\n\t\tlet value = consumeUntil(\" \\t\\r\\n>\", status);\n\t\t// Check whether we've landed at /> and if so, rewind\n\t\tif (status.source.substring(status.i - 1, status.i + 1) === \"/>\") {\n\t\t\tvalue = value.substring(0, value.length - 1);\n\t\t\tstatus.i -= 1;\n\t\t}\n\t\treturn value;\n\t}\n}\n","import type SourceSpan from \"../types/SourceSpan\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"../utils/codeScanner\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseText(status: ParseStatus, element: ElementNode): void {\n\t// Add a range for each reactive part of the text so that we can map them\n\t// back when building\n\tlet spans: SourceSpan[] = [];\n\n\t// Text ends at the next element, or at the next control statement, or at\n\t// the end of the render\n\t// But only if the control statement is after a newline, so we don't mess\n\t// with emails etc. This may need more finessing\n\tconst start = status.i;\n\tlet end = -1;\n\tfor (let j = status.i; j < status.source.length; j++) {\n\t\tif (status.source[j] === \"}\") {\n\t\t\t// That's the rendering done\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"{\") {\n\t\t\t// Skip reactive content\n\t\t\tconst reactiveStart = j + 1;\n\t\t\tlet level = 0;\n\t\t\tfor (let k = j; k < status.source.length; k++) {\n\t\t\t\tconst char = status.source[k];\n\t\t\t\tif (char === \"{\") {\n\t\t\t\t\tlevel += 1;\n\t\t\t\t} else if (char === \"}\") {\n\t\t\t\t\tlevel -= 1;\n\t\t\t\t\tif (level === 0) {\n\t\t\t\t\t\tj = k;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Skip strings, template strings, comments and regex literals\n\t\t\t\t\tconst skipped = skipStringOrComment(status.source, k);\n\t\t\t\t\tif (skipped !== -1) {\n\t\t\t\t\t\tk = skipped - 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add the source range\n\t\t\tspans.push({ start: reactiveStart, end: j });\n\t\t} else if (status.source[j] === \"<\") {\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"@\") {\n\t\t\t// Backtrack\n\t\t\tfor (let k = j - 1; k > status.i; k--) {\n\t\t\t\tif (status.source[k] === \"\\n\") {\n\t\t\t\t\tend = j;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (!isSpaceChar(status.source, k)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (end !== -1) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (end !== -1) {\n\t\tconst content = status.source.substring(start, end).trimEnd();\n\t\tconst spaceContent = status.source.substring(start + content.length, end);\n\t\tif (content || spaceContent) {\n\t\t\tconst previousNode = element.children[element.children.length - 1];\n\t\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\t\tpreviousNode.content += content + spaceContent;\n\t\t\t\tpreviousNode.spans.push(...spans);\n\t\t\t\t//previousNode.range.endIndex += content.length + spaceContent.length;\n\t\t\t\t// TODO: end char etc\n\t\t\t} else {\n\t\t\t\tconst text: TextNode = {\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\tcontent: content + spaceContent,\n\t\t\t\t\tspans,\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t}\n\t\t}\n\t\tstatus.i = end;\n\t} else {\n\t\tstatus.i += 1;\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\n\nconst slotRegex = /\\$slot\\b/;\n\n/**\n * Checks whether the $slot variable is read in the nodes' own scope\n *\n * Note that the children of a component node are excluded, because they are\n * passed to the component as fills, which get their own $slot parameter.\n * The component's attributes do belong to this scope.\n *\n * @param nodes The nodes to check\n *\n * @returns True if a $slot variable is read in the nodes' own scope\n */\nexport default function usesSlot(nodes: TemplateNode[]): boolean {\n\tfor (let node of nodes) {\n\t\tif (node.type === \"text\") {\n\t\t\tconst text = node as TextNode;\n\t\t\tif (slotRegex.test(text.content)) return true;\n\t\t} else if (node.type === \"control\") {\n\t\t\tconst control = node as ControlNode;\n\t\t\tif (slotRegex.test(control.statement)) return true;\n\t\t\tif (usesSlot(control.children)) return true;\n\t\t} else if (node.type === \"element\" || node.type === \"special\" || node.type === \"component\") {\n\t\t\tconst element = node as ElementNode;\n\t\t\tfor (let attribute of element.attributes) {\n\t\t\t\tif (slotRegex.test(attribute.name)) return true;\n\t\t\t\tif (attribute.value && slotRegex.test(attribute.value)) return true;\n\t\t\t}\n\t\t\tif (element.type !== \"component\" && usesSlot(element.children)) return true;\n\t\t}\n\t}\n\treturn false;\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isSpaceNode from \"../utils/isSpaceNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\nimport usesSlot from \"./utils/usesSlot\";\n\n/**\n * Moves any child nodes that aren't already in a <fill> node into a default\n * <fill> node\n */\nexport default function slottifyChildNodes(node: ElementNode): void {\n\t// Gather nodes that are not in <fill> nodes, and not the spaces surrounding fill nodes\n\tlet nonFillNodes: TemplateNode[] = [];\n\tfor (let child of node.children) {\n\t\tif (isFillNode(child)) {\n\t\t\tif (nonFillNodes.find((n) => !isSpaceNode(n)) === undefined) {\n\t\t\t\tnonFillNodes = [];\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tnonFillNodes.push(child);\n\t\t}\n\t}\n\tif (nonFillNodes.find((n) => !isSpaceNode(n)) === undefined) {\n\t\tnonFillNodes = [];\n\t}\n\n\t// If we found any non-fill node nodes, move them into a default fill node\n\tif (nonFillNodes.length) {\n\t\tlet defaultFillNode = node.children.find(\n\t\t\t(n) => isFillNode(n) && !n.attributes.find((a) => a.name === \"name\"),\n\t\t) as ElementNode | undefined;\n\t\tif (!defaultFillNode) {\n\t\t\tdefaultFillNode = {\n\t\t\t\ttype: \"special\",\n\t\t\t\ttagName: \"filldef\",\n\t\t\t\tattributes: [],\n\t\t\t\tchildren: nonFillNodes,\n\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\thasSlotProps: usesSlot(nonFillNodes),\n\t\t\t};\n\t\t\tnode.children.unshift(defaultFillNode);\n\t\t}\n\t\tnode.children = node.children.filter((c) => isFillNode(c) || !nonFillNodes.includes(c));\n\t}\n}\n\nfunction isFillNode(n: TemplateNode): n is ElementNode {\n\treturn isSpecialNode(n) && (n.tagName === \"fill\" || n.tagName === \"filldef\");\n}\n","import type CommentNode from \"../types/nodes/CommentNode\";\nimport type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\nimport voidTags from \"../utils/voidTags\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseControl from \"./parseControl\";\nimport parseTag from \"./parseTag\";\nimport parseText from \"./parseText\";\nimport slottifyChildNodes from \"./slottifyChildNodes\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport usesSlot from \"./utils/usesSlot\";\n\nexport default function parseElement(status: ParseStatus): ElementNode {\n\tconst current = status.components.at(-1);\n\tif (!current) throw new Error(\"No component in stack\");\n\n\tconst start = status.i;\n\n\tconst element = parseTag(status);\n\n\tif (element.tagName.startsWith(\"/\")) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${element.tagName.substring(1)}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length,\n\t\t);\n\t\treturn element;\n\t}\n\n\tif (voidTags.includes(element.tagName)) {\n\t\tcheckVoidElement(status, element);\n\t}\n\n\tif (!element.selfClosed && !voidTags.includes(element.tagName)) {\n\t\tstatus.stack.push(element);\n\n\t\t// Get the children\n\t\twhile (status.i < status.source.length) {\n\t\t\taddSpaceElement(element, status);\n\t\t\tif (accept(\"}\", status, false)) {\n\t\t\t\t// That's the rendering done\n\t\t\t\tbreak;\n\t\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t\t// It's a comment, swallow it\n\t\t\t\tconst start = status.i;\n\t\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t\t\tconst text: CommentNode = {\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t\tcommentType: \"html\",\n\t\t\t\t\tcontent: status.source.substring(start, status.i - 3),\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t} else if (accept(\"@//\", status)) {\n\t\t\t\t// Swallow one-line comments\n\t\t\t\t// Swallow one-line comments\n\t\t\t\tconst start = status.i;\n\t\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t\t\tconst text: CommentNode = {\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t\tcommentType: \"line\",\n\t\t\t\t\tcontent: status.source.substring(start, status.i - 1),\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t\t// Swallow block comments\n\t\t\t\t// Swallow block comments\n\t\t\t\tconst start = status.i;\n\t\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t\t\tconst text: CommentNode = {\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t\tcommentType: \"block\",\n\t\t\t\t\tcontent: status.source.substring(start, status.i - 2),\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t} else if (accept(\"</\", status, false)) {\n\t\t\t\t// It's a close tag, so we're done here\n\t\t\t\tif (checkCloseTag(status, element)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t\t// It's a child element\n\t\t\t\tconst child = parseElement(status);\n\t\t\t\telement.children.push(child);\n\t\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t\t// It's a control statement\n\t\t\t\tparseControl(status, element);\n\t\t\t} else {\n\t\t\t\t// It's text content\n\t\t\t\tparseText(status, element);\n\t\t\t}\n\t\t}\n\n\t\tstatus.stack.pop();\n\t}\n\n\t// If this is a component element, add a default <fill> node\n\t// HACK: For now, we just treat all tags starting with a capital as components\n\tif (/[A-Z]/.test(element.tagName[0])) {\n\t\telement.type = \"component\";\n\t\tslottifyChildNodes(element);\n\t}\n\n\tif (isSpecialNode(element)) {\n\t\tif (element.tagName === \"slot\") {\n\t\t\t// If this is a <slot> element, add a <fill> node for its fallback\n\t\t\t// content. Anchors will be created for <slot> nodes and fragments will\n\t\t\t// be created for the <fill> content\n\t\t\tslottifyChildNodes(element);\n\n\t\t\t// Add it to the component's slots collection\n\t\t\tcurrent.slotProps ??= [];\n\t\t\tcurrent.slotProps.push(element.attributes.find((a) => a.name === \"name\")?.name ?? \"default\");\n\t\t} else if (element.tagName === \"fill\" || element.tagName === \"filldef\") {\n\t\t\telement.hasSlotProps = usesSlot(element.children);\n\t\t} else if (element.tagName === \"@component\") {\n\t\t\tconst selfAttribute = element.attributes.find((a) => a.name === \"self\");\n\t\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\t\telement.type = \"component\";\n\t\t\t\tslottifyChildNodes(element);\n\n\t\t\t\tconst selfValue = selfAttribute.value;\n\t\t\t\tconst replace: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [element],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\t\t\t\tconst replaceGroup: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace group\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [replace],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\n\t\t\t\treturn replaceGroup as any;\n\t\t\t} else {\n\t\t\t\taddError(\n\t\t\t\t\tstatus,\n\t\t\t\t\t\"@component element must have a self attribute\",\n\t\t\t\t\tstart,\n\t\t\t\t\tstart + element.tagName.length + 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!element.closed && !voidTags.includes(element.tagName)) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Unclosed non-void element: ${element.tagName}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn element;\n}\n\nfunction checkVoidElement(status: ParseStatus, element: ElementNode) {\n\tlet i = status.i;\n\n\tconsumeSpace(status);\n\tif (accept(\"</\", status)) {\n\t\tconsumeSpace(status);\n\t\tif (accept(element.tagName, status)) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Closed void element: ${element.tagName}`,\n\t\t\t\ti,\n\t\t\t\ti + element.tagName.length + 1,\n\t\t\t);\n\t\t\tconsumeSpace(status);\n\t\t\taccept(\">\", status);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tstatus.i = i;\n}\n\nfunction checkCloseTag(status: ParseStatus, element: ElementNode) {\n\tconst start = status.i;\n\n\taccept(\"</\", status);\n\tconsumeSpace(status);\n\tlet snailed = accept(\"@\", status);\n\tlet closingTagName = consumeAlphaNumeric(status);\n\tif (snailed) {\n\t\tclosingTagName = \"@\" + closingTagName;\n\t}\n\tconsumeSpace(status);\n\taccept(\">\", status);\n\n\tlet found = false;\n\tfor (let i = status.stack.length - 1; i >= 0; i--) {\n\t\tif (closingTagName === status.stack[i].tagName) {\n\t\t\tstatus.stack[i].closed = true;\n\t\t\tfound = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!found) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${closingTagName} (expected ${element.tagName})`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn found;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type OperationType from \"../types/nodes/OperationType\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport { skipStringOrComment } from \"../utils/codeScanner\";\nimport isControlNode from \"../utils/isControlNode\";\nimport trimMatched from \"../utils/trimMatched\";\nimport trimStart from \"../utils/trimStart\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseElement from \"./parseElement\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nconst controlOperations = [\n\t\"@if\",\n\t\"@else\",\n\t\"@for\",\n\t\"@key\",\n\t\"@switch\",\n\t\"@case\",\n\t\"@default\",\n\t\"@await\",\n\t\"@with\",\n\t\"@try\",\n\t\"@catch\",\n\t\"@replace\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nconst standaloneOperations = [\n\t\"@key\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nexport default function parseControl(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n): void {\n\tconst node = parseControlOpen(status);\n\tif (!node) {\n\t\treturn;\n\t}\n\n\t// Some operations don't have children\n\tif (standaloneOperations.includes(node.operation)) {\n\t\twrangleControlNode(node, parentNode, status);\n\t\treturn;\n\t}\n\n\t// Get the children\n\twhile (status.i < status.source.length) {\n\t\taddSpaceElement(node, status);\n\t\tif (accept(\"}\", status)) {\n\t\t\t// It's the end of the control block, so we're done here\n\t\t\tbreak;\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// It's a child element\n\t\t\tconst child = parseElement(status);\n\t\t\tnode.children.push(child);\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// It's a nested control\n\t\t\tparseControl(status, node);\n\t\t} else if (accept(\"case\", status, false) || accept(\"key\", status, false)) {\n\t\t\t// `case` and `key` can be bare in a control block\n\t\t\tparseControl(status, node);\n\t\t} else {\n\t\t\t// Can't have text content in control blocks\n\t\t\tconst char = status.source[status.i];\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Unexpected token in control block: ${char}`,\n\t\t\t\tstatus.i,\n\t\t\t\t// TODO: Should probably go until a boundary\n\t\t\t\tstatus.i + 1,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twrangleControlNode(node, parentNode, status);\n\n\tparseControlBranches(status, parentNode);\n}\n\nfunction parseControlOpen(status: ParseStatus): ControlNode | null {\n\tconst start = status.i;\n\tlet statementStart = start;\n\n\tlet operation = \"\";\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (\n\t\t\t(isSpaceChar(status.source, status.i) && operation !== \"@async\") ||\n\t\t\t(accept(\":\", status) && operation === \"default\") ||\n\t\t\t(accept(\".\", status) && operation === \"@console\") ||\n\t\t\t(accept(\"(\", status, false) && operation === \"@html\")\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\toperation += char;\n\t}\n\n\t// Some operations (else etc) don't start with an @\n\tif (!operation.startsWith(\"@\")) {\n\t\toperation = \"@\" + operation;\n\t} else {\n\t\tstatementStart++;\n\t}\n\n\tlet statement = \"\";\n\tif (controlOperations.includes(operation)) {\n\t\tstatement = parseControlStatement(start, operation, status);\n\n\t\t// Special processing for functions -- read until the closing brace\n\t\tif (operation === \"@function\" || operation === \"@async function\") {\n\t\t\tstatement += ` {${parseInlineScript(status)}}`;\n\t\t\taccept(\"}\", status);\n\t\t}\n\n\t\t// Special processing for replace and html\n\t\tif (operation === \"@replace\" || operation === \"@html\") {\n\t\t\tstatement = trimMatched(statement.substring(statement.indexOf(\"(\")).trim(), \"(\", \")\");\n\t\t}\n\n\t\t// The old `@await (promise) { … } then (v) { … } catch (e) { … }`\n\t\t// control is removed (ASYNC.md §7.7 Stage C). The current `@await` is\n\t\t// the async boundary (formerly `@loading`): statement-less, with an\n\t\t// optional `with { … }` branch for the pending state.\n\t\tif (operation === \"@await\" && /^await\\s*\\(/.test(statement)) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t\"old `@await (expr) { … } then (…) { … }` syntax is removed — use `@await { … } with { … }` with `$async` getters\",\n\t\t\t\tstart,\n\t\t\t\tstatus.i,\n\t\t\t);\n\t\t}\n\t} else {\n\t\t// TODO: Should probably advance until a closing brace or a newline\n\t\taddError(status, `Unknown operation: ${operation}`, status.i, status.i + operation.length);\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"control\",\n\t\toperation: operation as OperationType,\n\t\tstatement,\n\t\tchildren: [],\n\t\tspan: { start: statementStart, end: status.i },\n\t};\n}\n\nfunction parseControlStatement(start: number, operation: string, status: ParseStatus) {\n\tlet parenCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tconst skipped = skipStringOrComment(status.source, status.i);\n\t\tif (skipped !== -1) {\n\t\t\tstatus.i = skipped;\n\t\t\tcontinue;\n\t\t}\n\t\tif (accept(\"(\", status)) {\n\t\t\tparenCount += 1;\n\t\t} else if (accept(\")\", status)) {\n\t\t\tparenCount -= 1;\n\t\t} else if (\n\t\t\taccept(\"{\", status) ||\n\t\t\t(accept(\"\\n\", status) && standaloneOperations.includes(operation))\n\t\t) {\n\t\t\tif (parenCount === 0) {\n\t\t\t\treturn trimStart(status.source.substring(start, status.i - 1).trim(), \"@\");\n\t\t\t}\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n\n/**\n * Groups the control node into the correct parent e.g. if/else into an if group\n * @param node The control node\n * @param parentNode The parent node\n * @param status The parse status, for error reporting\n */\nfunction wrangleControlNode(\n\tnode: ControlNode,\n\tparentNode: RootNode | ElementNode | ControlNode,\n\tstatus: ParseStatus,\n) {\n\t// Group\n\t// * if/else into an if group\n\t// * for into a for group\n\t// * switch into a switch group (cases will have the correct parent)\n\t// * await/with into an await group\n\t// * try/catch into a try group\n\t// * replace into a replace group\n\t// * html into a html group\n\tif (node.operation === \"@if\") {\n\t\tconst ifGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@if group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(ifGroup);\n\t} else if (node.operation === \"@else\") {\n\t\tif (/^else\\s+if/.test(node.statement)) {\n\t\t\tnode.operation = \"@else if\";\n\t\t}\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@if group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@for\") {\n\t\tconst forGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@for group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(forGroup);\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@switch\") {\n\t\tnode.operation = \"@switch group\";\n\t\tparentNode.children.push(node);\n\t} else if (node.operation === \"@await\") {\n\t\tconst awaitGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@await group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(awaitGroup);\n\t} else if (node.operation === \"@with\") {\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@await group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (node.operation === \"@catch\") {\n\t\t// `@catch` attaches only to the nearest `@try group` — and only\n\t\t// once; a second `@catch` on the same group would be silently\n\t\t// dropped by the builders\n\t\tlet attached = false;\n\t\tlet duplicate = false;\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@try group\") {\n\t\t\t\tif (\n\t\t\t\t\tlastChild.children.some((child) => isControlNode(child) && child.operation === \"@catch\")\n\t\t\t\t) {\n\t\t\t\t\tduplicate = true;\n\t\t\t\t} else {\n\t\t\t\t\tlastChild.children.push(node);\n\t\t\t\t\tattached = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!attached) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\tduplicate\n\t\t\t\t\t? \"`@try` cannot have more than one `@catch` block\"\n\t\t\t\t\t: \"`@catch` must follow a `@try` block\",\n\t\t\t\tnode.span.start,\n\t\t\t\tnode.span.end,\n\t\t\t);\n\t\t}\n\t} else if (node.operation === \"@try\") {\n\t\tconst tryGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@try group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(tryGroup);\n\t} else if (node.operation === \"@replace\") {\n\t\tconst replaceGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@replace group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(replaceGroup);\n\t} else if (node.operation === \"@html\") {\n\t\tconst htmlGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@html group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(htmlGroup);\n\t} else {\n\t\tparentNode.children.push(node);\n\t}\n}\n\n/**\n * Parses control branches that don't start with an @ symbol e.g. else or case\n * @param status The parse status\n * @param parentNode The parent node\n */\nfunction parseControlBranches(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n) {\n\t// Look ahead and see if we have another control statement\n\t// NOTE: We could be more strict here (e.g. we could check that an else is\n\t// after an if), but for now we are just leaving it to the JS parser\n\tlet gotAnotherBranch = true;\n\twhile (gotAnotherBranch) {\n\t\tlet start = status.i;\n\t\tstatus.i += 1;\n\t\tconsumeSpace(status);\n\t\tif (\n\t\t\taccept(\"else\", status, false) ||\n\t\t\taccept(\"case\", status, false) ||\n\t\t\taccept(\"default\", status, false) ||\n\t\t\taccept(\"catch\", status, false) ||\n\t\t\taccept(\"with\", status, false)\n\t\t) {\n\t\t\tparseControl(status, parentNode);\n\t\t} else {\n\t\t\tgotAnotherBranch = false;\n\t\t\tstatus.i = start;\n\t\t}\n\t}\n}\n","import type CommentNode from \"../types/nodes/CommentNode\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseControl from \"./parseControl\";\nimport parseElement from \"./parseElement\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseMarkup(status: ParseStatus, source: string): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tparseMarkupInto(status, source, (root) => (current.markup ??= root));\n}\n\n/**\n * Parses markup into a root node, letting callers choose where the resulting\n * RootNode is stored (e.g. a component's `markup` or its `error` block).\n *\n * @param status The parse status\n * @param source The full source code\n * @param setRoot Called with a fresh root node the first time content is\n * parsed; subsequent content is appended to the same node.\n */\nexport function parseMarkupInto(\n\tstatus: ParseStatus,\n\tsource: string,\n\tsetRoot: (root: RootNode) => void,\n): void {\n\tlet root: RootNode | null = null;\n\tconst getRoot = () => (root ??= { type: \"root\", children: [] });\n\n\twhile (status.i < source.length) {\n\t\tif (accept(\"}\", status, false)) {\n\t\t\t// That's the rendering done\n\t\t\treturn;\n\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t// It's a comment, swallow it\n\t\t\tconst start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t\tconst text: CommentNode = {\n\t\t\t\ttype: \"comment\",\n\t\t\t\tcommentType: \"html\",\n\t\t\t\tcontent: status.source.substring(start, status.i - 3),\n\t\t\t};\n\t\t\tsetRoot(getRoot());\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tconst start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t\tconst text: CommentNode = {\n\t\t\t\ttype: \"comment\",\n\t\t\t\tcommentType: \"line\",\n\t\t\t\tcontent: status.source.substring(start, status.i - 1),\n\t\t\t};\n\t\t\tsetRoot(getRoot());\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tconst start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t\tconst text: CommentNode = {\n\t\t\t\ttype: \"comment\",\n\t\t\t\tcommentType: \"block\",\n\t\t\t\tcontent: status.source.substring(start, status.i - 2),\n\t\t\t};\n\t\t\tsetRoot(getRoot());\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (isSpaceChar(status.source, status.i)) {\n\t\t\tsetRoot(getRoot());\n\t\t\tconst space = consumeSpace(status);\n\t\t\tconst text: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent: space,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// Parse the element\n\t\t\tsetRoot(getRoot());\n\t\t\tconst element = parseElement(status);\n\t\t\tgetRoot().children.push(element);\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// Parse the control\n\t\t\tsetRoot(getRoot());\n\t\t\tparseControl(status, getRoot());\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n}\n","// Adapted from https://github.com/sveltejs/svelte\n\nconst returnRegex = /\\r/g;\n\nexport default function hash(input: string): string {\n\tinput = input.replace(returnRegex, \"\");\n\tlet hash = 5381;\n\tlet i = input.length;\n\twhile (i--) {\n\t\thash = ((hash << 5) - hash) ^ input.charCodeAt(i);\n\t}\n\treturn (hash >>> 0).toString(36);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport addError from \"./addError\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string and if not, adds an error to the parse status\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function expect(value: string, status: ParseStatus, advance = true): boolean {\n\tif (status.i < status.source.length) {\n\t\tif (status.source.substring(status.i, status.i + value.length) == value) {\n\t\t\tstatus.i += advance ? value.length : 0;\n\t\t\treturn true;\n\t\t} else {\n\t\t\taddError(status, `Expected ${value}`);\n\t\t}\n\t} else {\n\t\taddError(status, \"Expected token\");\n\t}\n\treturn false;\n}\n","import type AttributeNode from \"../types/styles/AttributeNode\";\nimport type BlockNode from \"../types/styles/BlockNode\";\nimport CommentNode from \"../types/styles/CommentNode\";\nimport type StyleNode from \"../types/styles/StyleNode\";\nimport hash from \"../utils/hash\";\nimport type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\nimport expect from \"./utils/expect\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseStyles(source: string, status: ParseStatus): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tcurrent.style = {\n\t\tglobal: false,\n\t\tchildren: [],\n\t\thash: hash(source),\n\t};\n\n\tconst styleStatus: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\tbraces: [],\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\twhile (styleStatus.i < styleStatus.source.length) {\n\t\tif (isSpaceChar(styleStatus.source, styleStatus.i)) {\n\t\t\tconsumeSpace(styleStatus);\n\t\t} else {\n\t\t\tconst node = parseStyleNode(styleStatus);\n\t\t\tif (node) {\n\t\t\t\tcurrent.style.children.push(node);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.errors = status.errors.concat(styleStatus.errors);\n}\n\nfunction parseStyleNode(status: ParseStatus): StyleNode | undefined {\n\tconst gapBefore = /\\n\\s*\\n\\s*$/.test(status.source.slice(0, status.i));\n\n\tif (accept(\"//\", status, false) || accept(\"/*\", status, false)) {\n\t\treturn parseComment(status, gapBefore);\n\t}\n\n\tconst selector = consumeUntil(\"{\", status).trim();\n\tif (expect(\"{\", status)) {\n\t\tconst block: BlockNode = {\n\t\t\ttype: \"block\",\n\t\t\tselector,\n\t\t\tchildren: [],\n\t\t\tgapBefore,\n\t\t};\n\t\tconsumeSpace(status);\n\t\twhile (status.source[status.i] !== \"}\") {\n\t\t\tif (accept(\"//\", status, false) || accept(\"/*\", status, false)) {\n\t\t\t\t// Comments are parsed but not emitted\n\t\t\t\tblock.children.push(parseComment(status, false));\n\t\t\t} else {\n\t\t\t\t// HACK: Is it an attribute or a child block?\n\t\t\t\tlet nextColon = status.source.indexOf(\":\", status.i);\n\t\t\t\tif (nextColon === -1) nextColon = status.source.length;\n\t\t\t\tlet nextOpenBrace = status.source.indexOf(\"{\", status.i);\n\t\t\t\tif (nextOpenBrace === -1) nextOpenBrace = status.source.length;\n\t\t\t\tif (nextColon < nextOpenBrace) {\n\t\t\t\t\tconst attribute = parseStyleAttribute(status);\n\t\t\t\t\tblock.children.push(attribute);\n\t\t\t\t} else if (nextOpenBrace < nextColon) {\n\t\t\t\t\tconst child = parseStyleNode(status);\n\t\t\t\t\tif (child) {\n\t\t\t\t\t\tblock.children.push(child);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn block;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconsumeSpace(status);\n\t\t}\n\t\taccept(\"}\", status);\n\n\t\treturn block;\n\t}\n}\n\nfunction parseComment(status: ParseStatus, gapBefore: boolean): CommentNode {\n\tconst start = status.i;\n\tif (accept(\"//\", status)) {\n\t\tconst end = status.source.indexOf(\"\\n\", status.i);\n\t\tstatus.i = end === -1 ? status.source.length : end;\n\t} else {\n\t\taccept(\"/*\", status);\n\t\tconst end = status.source.indexOf(\"*/\", status.i);\n\t\tstatus.i = end === -1 ? status.source.length : end + 2;\n\t}\n\tconst comment: CommentNode = {\n\t\ttype: \"comment\",\n\t\tcontent: status.source.substring(start, status.i),\n\t\tgapBefore,\n\t};\n\treturn comment;\n}\n\nfunction parseStyleAttribute(status: ParseStatus): AttributeNode {\n\tconst gapBefore = /\\n\\s*\\n\\s*$/.test(status.source.slice(0, status.i));\n\tconst name = consumeUntil(\":\", status).trim();\n\taccept(\":\", status);\n\tconst value = consumeUntil(\";\", status).trim();\n\taccept(\";\", status);\n\treturn {\n\t\ttype: \"attribute\",\n\t\tname,\n\t\tvalue,\n\t\tgapBefore,\n\t};\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isComponentNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"component\";\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type BlockNode from \"../types/styles/BlockNode\";\nimport isComponentNode from \"../utils/isComponentNode\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isParentNode from \"../utils/isParentNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\n\nexport default function scopeStyles(status: ParseStatus): void {\n\tlet selectors: string[] = [];\n\tfor (let component of status.components) {\n\t\tif (component.style && component.markup) {\n\t\t\tfor (let block of component.style.children) {\n\t\t\t\tif (block.type === \"block\") {\n\t\t\t\t\tcollectStyleSelectors(block as BlockNode, selectors);\n\t\t\t\t}\n\t\t\t}\n\t\t\tscopeStylesOnNode(component.markup, selectors);\n\t\t}\n\t}\n}\n\nfunction scopeStylesOnNode(node: TemplateNode, selectors: string[]) {\n\tif (isElementNode(node) || isComponentNode(node)) {\n\t\tnode.scopeStyles =\n\t\t\tselectors.includes(node.tagName) ||\n\t\t\tnode.attributes.find((a) => {\n\t\t\t\tif (a.name === \"class\" && a.reactive) {\n\t\t\t\t\t// Any reactivity in a class attribute makes it scoped,\n\t\t\t\t\t// because we can't tell what's going on in there\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (a.name === \"id\" && a.value) {\n\t\t\t\t\tif (selectors.includes(`#${trimQuotes(a.value)}`)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t} else if (a.name === \"class\" && a.value) {\n\t\t\t\t\tfor (let classname of trimQuotes(a.value).split(/\\s+/)) {\n\t\t\t\t\t\tif (selectors.includes(`.${classname}`)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}) !== undefined;\n\t}\n\n\tif (isParentNode(node)) {\n\t\tfor (let child of node.children) {\n\t\t\tscopeStylesOnNode(child, selectors);\n\t\t}\n\t}\n}\n\nfunction collectStyleSelectors(block: BlockNode, selectors: string[]) {\n\t// HACK: We should be collecting the actual selectors and then checking\n\t// attributes, parents, children, siblings etc\n\tfor (let s of block.selector.split(/[\\s*,>+~[\\]]/)) {\n\t\tselectors.push(s);\n\t}\n}\n","import type TemplateComponent from \"../../types/TemplateComponent\";\nimport type ParseResult from \"../types/ParseResult\";\nimport collectMarkupExpressions from \"../utils/collectMarkupExpressions\";\nimport { codeRanges, skipStringOrComment } from \"../utils/codeScanner\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isSpaceNode from \"../utils/isSpaceNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport parseMarkup, { parseMarkupInto } from \"./parseMarkup\";\nimport parseStyleElement from \"./parseStyles\";\nimport scopeStyles from \"./scopeStyles\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function parseCode(source: string): ParseResult {\n\tconst status: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\tbraces: [],\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\tfor (status.i; status.i < source.length; status.i++) {\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (status.source[status.i] === \"{\") {\n\t\t\tstatus.level += 1;\n\t\t\t// A brace opened by the main loop is other top-level script (an\n\t\t\t// interface, type or object literal), not a component function\n\t\t\tstatus.braces.push(false);\n\t\t} else if (status.source[status.i] === \"}\") {\n\t\t\tstatus.level -= 1;\n\t\t\t// Only a brace that was opened by a component function ends the\n\t\t\t// component — a closing brace from other top-level script (e.g.\n\t\t\t// an interface between two components) must not emit an end\n\t\t\t// marker, or the build's component/chunk bookkeeping desyncs\n\t\t\tconst fromComponent = status.braces.pop();\n\t\t\tif (status.level === 0 && fromComponent) {\n\t\t\t\tparseComponentEnd(status);\n\t\t\t} else if (status.level < 0) {\n\t\t\t\taddError(status, `Unexpected closing brace`, status.i, status.i + 1);\n\t\t\t\tstatus.level = 0;\n\t\t\t}\n\t\t} else if (accept(\"function\", status)) {\n\t\t\t// If the function name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"const\", status)) {\n\t\t\t// If it's a function and its name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tconst start = status.i;\n\t\t\t\t\tconsumeAlphaNumeric(status);\n\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\tif (accept(\"=\", status)) {\n\t\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\t\tif (accept(\"(\", status, false)) {\n\t\t\t\t\t\t\tstatus.i = start;\n\t\t\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"export\", status)) {\n\t\t\t// If it's an anonymous default export function, parse it as a component\n\t\t\tconst start = status.i;\n\t\t\tif (\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"default\", status) &&\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"(\", status, false)\n\t\t\t) {\n\t\t\t\tparseComponentStart(status);\n\t\t\t} else {\n\t\t\t\tstatus.i = start;\n\t\t\t}\n\t\t} else if (accept(\"@render\", status, false)) {\n\t\t\tparseComponentRender(status);\n\t\t} else if (accept(\"@error\", status, false)) {\n\t\t\tparseComponentError(status);\n\t\t} else if (accept(\"@head\", status, false)) {\n\t\t\tparseComponentHead(status);\n\t\t} else if (accept(\"@style\", status, false)) {\n\t\t\tparseComponentStyle(status);\n\t\t}\n\t}\n\n\tif (status.level > 0) {\n\t\tconst count = status.level;\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Unbalanced braces: missing ${count} closing brace${count === 1 ? \"\" : \"s\"}`,\n\t\t\tsource.length,\n\t\t\tsource.length,\n\t\t);\n\t}\n\n\tstatus.script.push({\n\t\tscript: source.substring(status.marker, source.length),\n\t\tspan: { start: status.marker, end: source.length },\n\t});\n\n\tscopeStyles(status);\n\n\tconst ok = !status.errors.length;\n\tif (!ok) {\n\t\tstatus.errors = status.errors.sort((a, b) => a.startIndex - b.startIndex);\n\t}\n\n\treturn {\n\t\tok,\n\t\terrors: status.errors,\n\t\ttemplate: ok\n\t\t\t? {\n\t\t\t\t\timports: status.imports,\n\t\t\t\t\tscript: status.script,\n\t\t\t\t\tcomponents: status.components,\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n}\n\nfunction parseComponentStart(status: ParseStatus) {\n\tlet source = status.source.substring(status.marker, status.i);\n\tlet exported = /export\\s+(default\\s+)*(function\\s+|const\\s+)*$/.test(source);\n\tlet def = /export\\s+default\\s+(function\\s+|const\\s+)*$/.test(source);\n\tlet isConst = /const\\s+$/.test(source);\n\tlet isAnon = /export default\\s+$/.test(source);\n\n\tlet componentStart = status.i;\n\tlet name = consumeAlphaNumeric(status);\n\n\tif (def && status.components.some((c) => c.default)) {\n\t\taddError(status, `Multiple default exports`, componentStart, componentStart + name.length);\n\t}\n\n\tconst current: TemplateComponent = {\n\t\tstart: componentStart,\n\t\tname,\n\t\texported,\n\t\tdefault: def,\n\t\tscriptStart: status.script.length,\n\t};\n\tstatus.components.push(current);\n\n\t// Look for type parameters, e.g. `function Form<Data = any>(...)`\n\tif (status.source[status.i] === \"<\") {\n\t\tconst typeParamsStart = status.i;\n\t\tlet level = 0;\n\t\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\t\tconst char = status.source[status.i];\n\t\t\tif (char === \"<\") {\n\t\t\t\tlevel += 1;\n\t\t\t} else if (char === \">\") {\n\t\t\t\tlevel -= 1;\n\t\t\t\tif (level === 0) {\n\t\t\t\t\tcurrent.typeParams = status.source.substring(typeParamsStart, status.i + 1);\n\t\t\t\t\tstatus.i += 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Look for /** ... */ documentation comments\n\tlet presource = source.substring(0, status.i).trimEnd();\n\tlet lastNewline = presource.lastIndexOf(\"\\n\");\n\tif (lastNewline !== -1) {\n\t\tpresource = presource.substring(0, lastNewline).trimEnd();\n\t\tif (presource.endsWith(\"*/\")) {\n\t\t\tfor (let i = presource.length; i >= 0; i--) {\n\t\t\t\tif (presource.substring(i, i + 3) === \"/**\") {\n\t\t\t\t\tcurrent.documentation = presource.substring(i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlet start = -1;\n\tlet end = -1;\n\tlet level = 0;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (char === \"(\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t}\n\t\t} else if (char === \")\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, start),\n\t\tspan: { start: status.marker, end: start },\n\t});\n\tstatus.script.push({ script: \"/* @params */\", span: { start, end } });\n\n\tcurrent.params = status.source.substring(start, end);\n\tif (current.params.trim().length === 0) {\n\t\tcurrent.params = undefined;\n\t}\n\n\t// Look for a params type or interface\n\t// Might need to get fancier with this\n\tconst paramsMatch = current.params?.match(/\\$props:\\s*([$A-Za-z0-9]+)/);\n\tif (paramsMatch) {\n\t\tlet propsTypeName = paramsMatch[1];\n\t\tlet propsTypeStart = status.source.search(new RegExp(`interface\\\\s+${propsTypeName}`));\n\t\tif (propsTypeStart === -1) {\n\t\t\tpropsTypeStart = status.source.search(new RegExp(`type\\\\s+${propsTypeName}`));\n\t\t}\n\t\tif (propsTypeStart !== -1) {\n\t\t\tlet bracesStart = status.source.indexOf(\"{\", propsTypeStart);\n\t\t\tif (bracesStart !== -1) {\n\t\t\t\tconst status2: ParseStatus = {\n\t\t\t\t\tsource: status.source,\n\t\t\t\t\ti: bracesStart + 1,\n\t\t\t\t\tmarker: 0,\n\t\t\t\t\tlevel: 0,\n\t\t\t\t\tbraces: [],\n\t\t\t\t\timports: [],\n\t\t\t\t\tscript: [],\n\t\t\t\t\tcomponents: [],\n\t\t\t\t\tstack: [],\n\t\t\t\t\terrors: [],\n\t\t\t\t};\n\t\t\t\tconst propsType = parseInlineScript(status2);\n\t\t\t\tif (propsType) {\n\t\t\t\t\tcurrent.propsType = `${status.source.substring(propsTypeStart, bracesStart)}{${propsType}}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.marker = end;\n\tstatus.i = status.marker;\n\n\taccept(\")\", status);\n\tconsumeSpace(status);\n\n\tif (isConst || isAnon) {\n\t\taccept(\"=>\", status);\n\t\tconsumeSpace(status);\n\t}\n\n\taccept(\"{\", status);\n\tstatus.level += 1;\n\t// The component's own brace — its matching close ends the component\n\tstatus.braces.push(true);\n\n\t// Sneak in a function type\n\tconst postFunctionChunk = {\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t};\n\tif (/\\)\\s+\\{/.test(postFunctionChunk.script)) {\n\t\tpostFunctionChunk.script = \") /* @return_type */ {\";\n\t}\n\tstatus.script.push(postFunctionChunk);\n\n\tstatus.script.push({\n\t\tscript: \"/* @start */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tstatus.marker = status.i;\n\tconst space = consumeSpace(status);\n\tstatus.script.push({\n\t\tscript: space,\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.marker = status.i;\n\tstatus.i -= 1;\n}\n\nfunction parseComponentRender(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.markup) {\n\t\taddError(status, `Multiple @render sections`, status.i, status.i + \"@render\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @render */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\taccept(\"@render\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentError(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.error) {\n\t\taddError(status, `Multiple @error sections`, status.i, status.i + \"@error\".length);\n\t}\n\n\tif (!current.markup) {\n\t\taddError(status, `@error must come after @render`, status.i, status.i + \"@error\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @error */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\taccept(\"@error\", status);\n\tconsumeSpace(status);\n\n\t// Parse the error variable e.g. `@error (err)`\n\tlet errorVar = \"\";\n\tif (accept(\"(\", status)) {\n\t\tlet start = status.i;\n\t\twhile (status.i < status.source.length && status.source[status.i] !== \")\") {\n\t\t\tstatus.i += 1;\n\t\t}\n\t\terrorVar = status.source.substring(start, status.i).trim();\n\t\taccept(\")\", status);\n\t\tconsumeSpace(status);\n\t}\n\tcurrent.errorVar = errorVar || \"err\";\n\n\tif (accept(\"{\", status)) {\n\t\tparseMarkupInto(status, status.source, (root) => (current.error ??= root));\n\t\taccept(\"}\", status);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentHead(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.head) {\n\t\taddError(status, `Multiple @head sections`, status.i, status.i + \"@head\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @head */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// HACK: add a new component, and move its markup into the current\n\t// component's head section after\n\tstatus.components.push({\n\t\tstart: status.i,\n\t});\n\n\taccept(\"@head\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\t// Swap render and markup\n\tconst head = status.components.pop();\n\tcurrent.head = head?.markup;\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentStyle(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.style) {\n\t\taddError(status, `Multiple @style sections`, status.i, status.i + \"@style\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @style */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tlet start = -1;\n\tlet end = status.source.length;\n\tlet level = 0;\n\tlet styleSource = \"\";\n\tfor (; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tconst nextChar = status.source[status.i + 1];\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t// Skip one-line comments\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t// Skip block comments\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 1;\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t// Skip string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfString(char, status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"`\") {\n\t\t\t// Skip interpolated string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfTemplateString(status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"{\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i - 1;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else {\n\t\t\tif (start !== -1) {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.i = start;\n\tparseStyleElement(styleSource.trim(), status);\n\n\tstatus.i = end + 2;\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentEnd(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.script.push({\n\t\tscript: \"/* @end */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// Get all usages of $props.name and $props[\"name\"]\n\t// Get all usages of $context.name and $context[\"name\"]\n\t//\n\t// Only scan what the compiled output will actually reference: script code\n\t// and markup expressions (control statements, reactive attribute values,\n\t// `{...}` interpolations). `codeRanges` identifies the code positions, so\n\t// matches that start inside a string, comment or regex literal are\n\t// ignored — e.g. sample code in a template literal attribute (like the\n\t// docs pages' code samples) doesn't inject a $props param that nothing\n\t// uses. Prose text and static attribute values are never compiled into\n\t// references\n\tconst scriptText = status.script\n\t\t.slice(current.scriptStart ?? status.script.length)\n\t\t.map((chunk) => chunk.script)\n\t\t.join(\"\\n\");\n\tconst markupParts: string[] = [];\n\tif (current.markup) markupParts.push(collectMarkupExpressions(current.markup));\n\tif (current.error) markupParts.push(collectMarkupExpressions(current.error));\n\tif (current.head) markupParts.push(collectMarkupExpressions(current.head));\n\tconst usageSource = scriptText + \"\\n\" + markupParts.join(\"\\n\");\n\tconst usageRanges = codeRanges(usageSource);\n\tcurrent.props = getPropsUsage(usageSource, usageRanges);\n\tcurrent.contextProps = getContextUsage(usageSource, usageRanges);\n\n\t// If the top-level element is <html> and there is whitespace after it,\n\t// delete the whitespace, as that's what browsers seem to do. It may be\n\t// better instead to create whitespace if we don't find it when hydrating...\n\tif (\n\t\tcurrent.markup &&\n\t\tisElementNode(current.markup.children[0]) &&\n\t\tcurrent.markup.children[0].tagName === \"html\" &&\n\t\tisSpaceNode(current.markup.children[0].children[0])\n\t) {\n\t\tcurrent.markup.children.splice(1, 1);\n\t}\n\n\tstatus.marker = status.i;\n}\n\n/**\n * Gets the `$props` names that the compiled output references. The input is\n * the component's code-only text (script plus markup expressions), with\n * `ranges` marking the positions that are code — matches that start inside a\n * string, comment or regex literal are ignored, so mentions inside\n * sample-code strings or prose don't count.\n */\nfunction getPropsUsage(source: string, ranges: [number, number][]): string[] | undefined {\n\tconst props: string[] = [];\n\tfor (let match of source.matchAll(/\\$props\\??\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g)) {\n\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!props.includes(name)) {\n\t\t\tprops.push(name);\n\t\t}\n\t}\n\t// Also check for bare `$props` references, e.g. spreading it into a new\n\t// object with `let props = $props ?? {}`. These don't have a property\n\t// accessor, but still need the `$props` parameter to be declared. A\n\t// following `:` means it's a (re)declaration or type annotation, and a\n\t// following `<` means it's text in markup (e.g. \"<code>$props</code>\"),\n\t// neither of which count\n\tif (!props.length) {\n\t\tfor (let match of source.matchAll(/(?<![\\w$])\\$props(?![\\w])(?!\\s*:)(?!<)/g)) {\n\t\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\t\tprops.push(\"$props\");\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn props.length ? props : undefined;\n}\n\n/**\n * Gets the `$context` names that the compiled output references. The input is\n * the component's code-only text (script plus markup expressions), with\n * `ranges` marking the positions that are code — matches that start inside a\n * string, comment or regex literal are ignored, so mentions inside\n * sample-code strings or prose don't count.\n */\nfunction getContextUsage(source: string, ranges: [number, number][]): string[] | undefined {\n\tconst contextsMatches = source.matchAll(/\\$context\\??\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g);\n\tconst contexts: string[] = [];\n\tfor (let match of contextsMatches) {\n\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!contexts.includes(name)) {\n\t\t\tcontexts.push(name);\n\t\t}\n\t}\n\t// Also check for bare `$context` references, e.g. passing the whole\n\t// context object to a function. These don't have a property accessor,\n\t// but still need the `$context` parameter to be declared. A following\n\t// `:` means it's a (re)declaration or type annotation, and a following\n\t// `<` means it's text in markup (e.g. \"<code>$context</code>\"), neither\n\t// of which count\n\tif (!contexts.length) {\n\t\tfor (let match of source.matchAll(/(?<![\\w$])\\$context(?![\\w])(?!\\s*:)(?!<)/g)) {\n\t\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\t\tcontexts.push(\"$context\");\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn contexts.length ? contexts : undefined;\n}\n\n/**\n * Returns true if `index` falls inside one of the (sorted, non-overlapping)\n * code ranges — i.e. not inside a string, comment or regex literal.\n */\nfunction isInCode(ranges: [number, number][], index: number): boolean {\n\tfor (const [start, end] of ranges) {\n\t\tif (index >= start && index < end) return true;\n\t\tif (index < start) return false;\n\t}\n\treturn false;\n}\n\nfunction consumeScriptComments(status: ParseStatus): boolean {\n\tconst skipped = skipStringOrComment(status.source, status.i);\n\tif (skipped !== -1) {\n\t\tstatus.i = skipped;\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import parseCode from \"./parse/parseCode\";\nimport type ParseResult from \"./types/ParseResult\";\n\n/**\n * Parses source code into a component template\n *\n * @param source The source code\n *\n * @returns A result indicating whether parsing was ok, and if so, containing\n * the component template's parts such as script, markup and styles\n */\nexport default function parse(source: string): ParseResult {\n\treturn parseCode(source);\n}\n"],"mappings":";AAAA,SAAwB,YAAY,MAAc,SAAiB,OAAuB;CACzF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,QAAQ,QAAQ,KAC3C,IAAI,QAAQ,OAAO,QAAQ,QAAQ,IAAI,OAAO,MAC7C,OAAO;CAGT,OAAO,QAAQ;AAChB;;;;;;;;;;;;;;ACSA,MAAM,iCAAiB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;AAQD,SAAgB,oBAAoB,OAAe,OAAuB;CACzE,OAAO,YAAY,OAAO,KAAK;AAChC;;;;;;;AAQA,SAAgB,WAAW,OAAmC;CAC7D,MAAM,SAA6B,CAAC;CACpC,IAAI,YAAY;CAChB,IAAI,IAAI;CACR,OAAO,IAAI,MAAM,QAAQ;EACxB,MAAM,OAAO,YAAY,OAAO,GAAG,QAAQ,SAAS;EACpD,IAAI,SAAS,IAAI;GAChB,IA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QAAQ;CAInD,IAAI,CAAC,SAAS,mBACb,SAAS,cAAc;AAIzB;;;;;AAMA,SAAS,oBAAoB,UAAoD;CAChF,KAAK,MAAM,SAAS,UAAU;EAC7B,IAAI,MAAM,SAAS,WAAW;EAC9B,IAAI,cAAc,KAAK,KAAK,yBAAyB,IAAI,MAAM,SAAS,GAAG;EAC3E,OAAO;CACR;AAED;AAEA,SAAS,oBACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,SACC;CACD,QAAQ,KAAK,MAAb;EACC,KAAK;GACJ,wBACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,OACD;GACA;EAED,KAAK;GACJ,2BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,OACD;GACA;EAED,KAAK;GACJ,6BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,OACD;GACA;EAED,KAAK;GACJ,2BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,OACD;GACA;EAED,KAAK;GACJ,wBACC,UACA,MACA,MACA,QACA,GACA,UACA,WACA,OACD;GACA;EAED,KAAK;GACJ,2BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,OACD;GACA;EAED,KAAK,WAEJ;EAED,SAEC,MAAM,IAAI,MAAM,sBAAsB,KAAK,MAAM;CAEnD;AACD;AAEA,SAAS,wBACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;CACD,KAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,QAAQ,GAC5C,oBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,OACD;AAEF;AAEA,SAAS,2BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;CACD,QAAQ,KAAK,WAAb;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;GAEJ,mCACC,UACA,MACA,M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ACV,KAAK,IAAI,SAAS,OAAO,SAAS,yCAAyC,GAAG;EAC7E,IAAI,CAAC,SAAS,QAAQ,MAAM,KAAM,GAAG;EACrC,MAAM,KAAK,QAAQ;EACnB;CACD;CAED,OAAO,MAAM,SAAS,QAAQ,KAAA;AAC/B;;;;;;;;AASA,SAAS,gBAAgB,QAAgB,QAAkD;CAC1F,MAAM,kBAAkB,OAAO,SAAS,8CAA8C;CACtF,MAAM,WAAqB,CAAC;CAC5B,KAAK,IAAI,SAAS,iBAAiB;EAClC,IAAI,CAAC,SAAS,QAAQ,MAAM,KAAM,GAAG;EACrC,MAAM,OAAO,WAAW,MAAM,MAAM,MAAM,EAAE;EAC5C,IAAI,CAAC,SAAS,SAAS,IAAI,GAC1B,SAAS,KAAK,IAAI;CAEpB;CAOA,IAAI,CAAC,SAAS,QACb,KAAK,IAAI,SAAS,OAAO,SAAS,2CAA2C,GAAG;EAC/E,IAAI,CAAC,SAAS,QAAQ,MAAM,KAAM,GAAG;EACrC,SAAS,KAAK,UAAU;EACxB;CACD;CAED,OAAO,SAAS,SAAS,WAAW,KAAA;AACrC;;;;;AAMA,SAAS,SAAS,QAA4B,OAAwB;CACrE,KAAK,MAAM,CAAC,OAAO,QAAQ,QAAQ;EAClC,IAAI,SAAS,SAAS,QAAQ,KAAK,OAAO;EAC1C,IAAI,QAAQ,OAAO,OAAO;CAC3B;CACA,OAAO;AACR;AAEA,SAAS,sBAAsB,QAA8B;CAC5D,MAAM,UAAU,oBAAoB,OAAO,QAAQ,OAAO,CAAC;CAC3D,IAAI,YAAY,IAAI;EACnB,OAAO,IAAI;EACX,OAAO;CACR;CACA,OAAO;AACR;;;;;;;;;;;ACrmBA,SAAwB,MAAM,QAA6B;CAC1D,OAAO,UAAU,MAAM;AACxB"}
1
+ {"version":3,"file":"compile.mjs","names":["#mapped","#text","#space","isElementLike","maybeAppend","buildElementAttributes","importsMap"],"sources":["../src/compile/utils/endOfString.ts","../src/compile/utils/codeScanner.ts","../src/compile/utils/Builder.ts","../src/compile/utils/isParentNode.ts","../src/compile/utils/collectMarkupExpressions.ts","../src/compile/utils/markupRendersComponent.ts","../src/compile/build/client/addMappedText.ts","../src/compile/build/client/addPopDevBoundary.ts","../src/compile/build/client/addPushDevBoundary.ts","../src/compile/types/comments.ts","../src/compile/utils/isControlNode.ts","../src/compile/utils/isElementNode.ts","../src/compile/utils/nonRenderingOperations.ts","../src/compile/utils/getSingleElementRoot.ts","../src/compile/utils/isReactive.ts","../src/compile/utils/trimQuotes.ts","../src/compile/utils/voidTags.ts","../src/compile/build/client/buildFragmentText.ts","../src/compile/utils/bindingTarget.ts","../src/compile/utils/isSpecialNode.ts","../src/compile/build/utils/nextVarName.ts","../src/compile/build/client/addMappedTextWithOffsets.ts","../src/compile/build/client/buildAddFragment.ts","../src/compile/parse/utils/isSpaceChar.ts","../src/compile/parse/utils/isSpace.ts","../src/compile/utils/isTextNode.ts","../src/compile/build/client/buildFragment.ts","../src/compile/utils/forVarsReadIn.ts","../src/compile/build/client/replaceForVarNames.ts","../src/compile/build/client/buildRun.ts","../src/compile/build/client/getAttributeOffsets.ts","../src/compile/build/client/buildComponentNode.ts","../src/compile/build/client/buildAwaitNode.ts","../src/compile/utils/hasNestedControl.ts","../src/compile/utils/isForBodyLeafSafe.ts","../src/compile/utils/isForBodyNoProxySafe.ts","../src/compile/utils/trimMatched.ts","../src/compile/build/client/buildForNode.ts","../src/compile/build/client/buildHtmlNode.ts","../src/compile/build/client/buildIfNode.ts","../src/compile/build/client/buildReplaceNode.ts","../src/compile/build/client/buildScriptNode.ts","../src/compile/build/client/buildSwitchNode.ts","../src/compile/build/client/buildTryNode.ts","../src/compile/build/client/buildControlNode.ts","../src/compile/utils/trimEnd.ts","../src/compile/build/client/buildMount.ts","../src/compile/build/client/stashRun.ts","../src/compile/build/client/stashRunWithOffsets.ts","../src/compile/build/client/buildElementNode.ts","../src/compile/build/client/buildRootNode.ts","../src/compile/build/client/buildSlotNode.ts","../src/compile/build/client/buildSpecialNode.ts","../src/compile/build/client/buildTextNode.ts","../src/compile/build/client/buildNode.ts","../src/compile/build/client/buildCode.ts","../src/compile/build/client/buildStyles.ts","../src/compile/build/server/flushOutput.ts","../src/compile/build/server/buildServerComponentNode.ts","../src/compile/build/server/buildServerAwaitNode.ts","../src/compile/build/server/buildServerForNode.ts","../src/compile/build/server/buildServerHtmlNode.ts","../src/compile/build/server/buildServerIfNode.ts","../src/compile/build/server/buildServerReplaceNode.ts","../src/compile/build/server/buildServerScriptNode.ts","../src/compile/build/server/buildServerSwitchNode.ts","../src/compile/build/server/buildServerTryNode.ts","../src/compile/build/server/buildServerControlNode.ts","../src/compile/build/server/buildServerElementNode.ts","../src/compile/build/server/buildServerRootNode.ts","../src/compile/build/server/buildServerSlotNode.ts","../src/compile/build/server/buildServerSpecialNode.ts","../src/compile/build/server/buildServerTextNode.ts","../src/compile/build/server/buildServerNode.ts","../src/compile/build/server/buildServerCode.ts","../src/compile/utils/trimWhitespace.ts","../src/compile/build.ts","../src/compile/buildType.ts","../src/compile/utils/endOfTemplateString.ts","../src/compile/utils/isSpaceNode.ts","../src/compile/parse/utils/accept.ts","../src/compile/parse/parseInlineScript.ts","../src/compile/utils/trimStart.ts","../src/compile/parse/utils/consumeSpace.ts","../src/compile/parse/addSpaceElement.ts","../src/compile/utils/isFullyReactive.ts","../src/compile/parse/utils/addError.ts","../src/compile/parse/utils/isAlphaNumericChar.ts","../src/compile/parse/utils/consumeAlphaNumeric.ts","../src/compile/parse/utils/consumeUntil.ts","../src/compile/parse/parseTag.ts","../src/compile/parse/parseText.ts","../src/compile/parse/utils/usesSlot.ts","../src/compile/parse/slottifyChildNodes.ts","../src/compile/parse/parseElement.ts","../src/compile/parse/parseControl.ts","../src/compile/parse/parseMarkup.ts","../src/compile/utils/hash.ts","../src/compile/parse/utils/expect.ts","../src/compile/parse/parseStyles.ts","../src/compile/utils/isComponentNode.ts","../src/compile/parse/scopeStyles.ts","../src/compile/parse/parseCode.ts","../src/compile/parse.ts"],"sourcesContent":["export default function endOfString(char: string, content: string, start: number): number {\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === char && content[j - 1] !== \"\\\\\") {\n\t\t\treturn j;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import endOfString from \"./endOfString\";\n\n/**\n * Shared scanner for skipping over non-code parts of JavaScript expression\n * text: string literals, template literals (including their interpolations),\n * comments, and regex literals. Used everywhere the compiler scans\n * expression text and needs to tell code from literal text.\n *\n * Note: this is for *code* contexts. For torpor template text (where quotes\n * are literal characters and `{...}` are interpolation delimiters), use this\n * only for the *interiors* of `{...}` expressions -- the template level\n * itself has different rules.\n */\n\n// Keywords after which a `/` starts a regex literal, even though the\n// previous character is an identifier character\nconst REGEX_KEYWORDS = new Set([\n\t\"return\",\n\t\"typeof\",\n\t\"instanceof\",\n\t\"in\",\n\t\"of\",\n\t\"new\",\n\t\"delete\",\n\t\"void\",\n\t\"throw\",\n\t\"case\",\n\t\"do\",\n\t\"else\",\n\t\"yield\",\n\t\"await\",\n]);\n\n/**\n * If the character at `start` begins a string literal, a template literal, a\n * comment (line or block), or a regex literal, returns the index just after\n * it. Returns -1 if it doesn't (a `/` that is division, or any other\n * character).\n */\nexport function skipStringOrComment(value: string, start: number): number {\n\treturn skipInRange(value, start);\n}\n\n/**\n * Returns the [start, end) ranges of `value` that are code -- i.e. not the\n * contents of string literals, regex literals, or comments. Template string\n * contents are skipped, except for the contents of `${...}` interpolations,\n * which are code again.\n */\nexport function codeRanges(value: string): [number, number][] {\n\tconst ranges: [number, number][] = [];\n\tlet codeStart = 0;\n\tlet i = 0;\n\twhile (i < value.length) {\n\t\tconst next = skipInRange(value, i, ranges, codeStart);\n\t\tif (next !== -1) {\n\t\t\ti = next;\n\t\t\tcodeStart = i;\n\t\t} else {\n\t\t\ti += 1;\n\t\t}\n\t}\n\tpushRange(ranges, codeStart, value.length);\n\treturn ranges;\n}\n\n/**\n * `skipStringOrComment` with optional collection of the interrupted code\n * range (for `codeRanges`), so there is a single implementation of the scan\n * order.\n */\nfunction skipInRange(\n\tvalue: string,\n\tstart: number,\n\tranges?: [number, number][],\n\tcodeStart?: number,\n): number {\n\tconst char = value[start];\n\tif (char === \"'\" || char === '\"') {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\treturn endOfString(char, value, start) + 1;\n\t}\n\tif (char === \"`\") {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\treturn skipTemplateString(value, start, ranges);\n\t}\n\tif (char === \"/\" && value[start + 1] === \"/\") {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\tconst end = value.indexOf(\"\\n\", start + 2);\n\t\treturn end === -1 ? value.length : end;\n\t}\n\tif (char === \"/\" && value[start + 1] === \"*\") {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\tconst end = value.indexOf(\"*/\", start + 2);\n\t\treturn end === -1 ? value.length : end + 2;\n\t}\n\tif (char === \"/\" && isRegexPosition(value, start)) {\n\t\tif (ranges) pushRange(ranges, codeStart!, start);\n\t\treturn skipRegexLiteral(value, start);\n\t}\n\treturn -1;\n}\n\n/**\n * Skips over a template string, given the index of its opening backtick, and\n * returns the index just after the closing backtick. Handles escaped\n * characters, and scans `${...}` interpolations correctly (nested strings,\n * templates, comments and regexes within them can't desync the scan).\n */\nfunction skipTemplateString(value: string, start: number, ranges?: [number, number][]): number {\n\tlet i = start + 1;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\t\tif (char === \"\\\\\") {\n\t\t\t// Skip escaped characters\n\t\t\ti += 2;\n\t\t} else if (char === \"`\") {\n\t\t\treturn i + 1;\n\t\t} else if (char === \"$\" && value[i + 1] === \"{\") {\n\t\t\ti = endOfInterpolation(value, i + 2, ranges) + 1;\n\t\t} else {\n\t\t\ti += 1;\n\t\t}\n\t}\n\treturn value.length;\n}\n\n/**\n * Skips over the code inside a `${...}` interpolation, given the index just\n * after the `${`, collecting its code ranges when provided. Returns the\n * index of the matching `}`.\n */\nfunction endOfInterpolation(value: string, start: number, ranges?: [number, number][]): number {\n\tlet level = 0;\n\tlet codeStart = start;\n\tlet i = start;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel += 1;\n\t\t\ti += 1;\n\t\t} else if (char === \"}\") {\n\t\t\tif (level === 0) {\n\t\t\t\tpushRange(ranges, codeStart, i);\n\t\t\t\treturn i;\n\t\t\t}\n\t\t\tlevel -= 1;\n\t\t\ti += 1;\n\t\t} else {\n\t\t\tconst next = skipInRange(value, i, ranges, codeStart);\n\t\t\tif (next !== -1) {\n\t\t\t\ti = next;\n\t\t\t\tcodeStart = i;\n\t\t\t} else {\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t}\n\t}\n\tpushRange(ranges, codeStart, value.length);\n\treturn value.length;\n}\n\n/**\n * Decides whether the `/` at `slashIndex` starts a regex literal (rather\n * than being division), by looking at the previous significant character.\n * The standard lexical heuristic -- not a full parse, but correct for\n * real-world code.\n */\nfunction isRegexPosition(value: string, slashIndex: number): boolean {\n\tlet i = slashIndex - 1;\n\twhile (i >= 0) {\n\t\tconst char = value[i];\n\t\tif (char === \" \" || char === \"\\t\" || char === \"\\n\" || char === \"\\r\") {\n\t\t\ti -= 1;\n\t\t} else if (char === \"/\" && value[i - 1] === \"*\") {\n\t\t\t// Step back over a block comment\n\t\t\tconst open = value.lastIndexOf(\"/*\", i - 2);\n\t\t\tif (open === -1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\ti = open - 1;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (i < 0) {\n\t\t// Start of the expression\n\t\treturn true;\n\t}\n\tconst char = value[i];\n\tif (\n\t\tchar === \")\" ||\n\t\tchar === \"]\" ||\n\t\tchar === \"}\" ||\n\t\tchar === '\"' ||\n\t\tchar === \"'\" ||\n\t\tchar === \"`\"\n\t) {\n\t\t// After a completed value -- division\n\t\treturn false;\n\t}\n\tif (/[a-z0-9_$]/i.test(char)) {\n\t\t// After an identifier or number -- division, unless it's a keyword\n\t\t// that can be followed by an expression\n\t\tlet wordStart = i;\n\t\twhile (wordStart >= 0 && /[a-z0-9_$]/i.test(value[wordStart])) {\n\t\t\twordStart -= 1;\n\t\t}\n\t\treturn REGEX_KEYWORDS.has(value.substring(wordStart + 1, i + 1));\n\t}\n\tif (char === \"+\" || char === \"-\") {\n\t\t// `a++ / 2` is division (postfix update); `x + /re/` is a regex\n\t\tif (value[i - 1] === char) {\n\t\t\tconst before = value[i - 2];\n\t\t\treturn !(before && /[a-z0-9_$)\\]]/i.test(before));\n\t\t}\n\t\treturn true;\n\t}\n\t// After any other operator or punctuation -- regex\n\treturn true;\n}\n\n/**\n * Skips over a regex literal, given the index of its opening `/`, and\n * returns the index just after its flags. Returns -1 if the literal is\n * unterminated (in which case the `/` is treated as division).\n */\nfunction skipRegexLiteral(value: string, start: number): number {\n\tlet i = start + 1;\n\tlet inClass = false;\n\twhile (i < value.length) {\n\t\tconst char = value[i];\n\t\tif (char === \"\\\\\") {\n\t\t\ti += 2;\n\t\t} else if (char === \"\\n\") {\n\t\t\t// Unterminated regex -- treat the `/` as division\n\t\t\treturn -1;\n\t\t} else if (char === \"[\") {\n\t\t\tinClass = true;\n\t\t\ti += 1;\n\t\t} else if (char === \"]\") {\n\t\t\tinClass = false;\n\t\t\ti += 1;\n\t\t} else if (char === \"/\" && !inClass) {\n\t\t\t// Skip flags\n\t\t\ti += 1;\n\t\t\twhile (i < value.length && /[a-z]/i.test(value[i])) {\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t\treturn i;\n\t\t} else {\n\t\t\ti += 1;\n\t\t}\n\t}\n\treturn -1;\n}\n\nfunction pushRange(ranges: [number, number][] | undefined, start: number, end: number): void {\n\tif (ranges && end > start) {\n\t\tranges.push([start, end]);\n\t}\n}\n","import { skipStringOrComment } from \"./codeScanner\";\n\nexport default class Builder {\n\t#text = \"\";\n\t#space = 0;\n\t#mapped = false;\n\n\tlineMap: number[] = [];\n\n\tconstructor(mapped?: boolean) {\n\t\tthis.#mapped = mapped === true;\n\t}\n\n\tprepend(text: string): void {\n\t\t// TODO: adjust line map\n\t\tthis.#text = text + \"\\n\" + this.#text;\n\t}\n\n\tappend(text: string): void {\n\t\tif (this.#mapped) {\n\t\t\tthis.lineMap.push(this.#text.length);\n\t\t\tfor (let i = 0; i < text.length; i++) {\n\t\t\t\tif (text[i] === \"\\n\") {\n\t\t\t\t\tthis.lineMap.push(this.#text.length + i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#text += \"\\n\" + text;\n\t\t\treturn;\n\t\t}\n\n\t\tconst start = this.#text.length;\n\n\t\ttext = text.trim();\n\t\tlet i = 0;\n\t\t//let newline = !!text.length && !text.endsWith(\"\\n\");\n\n\t\twhile (i < text.length) {\n\t\t\t// Skip spaces\n\t\t\twhile (text[i] === \" \" || text[i] === \"\\t\") {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (text[i] === \";\") {\n\t\t\t\t// HACK: we just set ; to ignore the line\n\t\t\t\ti++;\n\t\t\t} else if (text[i] === \"\\n\") {\n\t\t\t\tthis.lineMap.push(start + i);\n\t\t\t\tthis.#text += \"\\n\";\n\t\t\t} else {\n\t\t\t\t// Maybe outdent\n\t\t\t\tif (text[i] === \"}\" || text[i] === \")\" || text[i] === \"]\") {\n\t\t\t\t\tthis.#space -= 1;\n\t\t\t\t}\n\n\t\t\t\t// Add indentation\n\t\t\t\tthis.#text += \"\\t\".repeat(Math.max(0, this.#space));\n\t\t\t\t// Add from text until the next newline or the end of text\n\t\t\t\tconst start = i;\n\t\t\t\twhile (i < text.length && text[i] !== \"\\n\") {\n\t\t\t\t\t// Just add backticked text as-is\n\t\t\t\t\tif (text[i] === \"`\") {\n\t\t\t\t\t\ti = skipStringOrComment(text, i) - 1;\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tconst line = text.substring(start, i + 1);\n\n\t\t\t\tif (line.startsWith(\"*\")) {\n\t\t\t\t\t// JSDoc\n\t\t\t\t\tthis.#text += \" \";\n\t\t\t\t}\n\t\t\t\tthis.#text += line;\n\n\t\t\t\t// Maybe indent\n\t\t\t\tif (text[i - 1] === \"{\" || text[i - 1] === \"(\" || text[i - 1] === \"[\") {\n\t\t\t\t\tthis.#space += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t\tif (!this.#text.endsWith(\"\\n\\n\")) {\n\t\t\tthis.#text += \"\\n\";\n\t\t}\n\t}\n\n\ttoString(): string {\n\t\treturn this.#text;\n\t}\n}\n","import type ParentNode from \"../types/nodes/ParentNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isParentNode(node: TemplateNode): node is ParentNode {\n\treturn \"children\" in node;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type ParentNode from \"../types/nodes/ParentNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"./codeScanner\";\nimport isParentNode from \"./isParentNode\";\n\n/**\n * Walks a markup tree and returns every expression string it contains —\n * `@control (...)` statements, reactive attribute values, and `{...}` text\n * interpolations — concatenated. Used for import detection: `$`-primitives\n * used inside markup (e.g. `@if ($pending(() => $state.data))`,\n * `disabled={$pending(...)}`) must be imported, and the script-only scan in\n * `buildCode`/`buildServerCode` doesn't see them.\n *\n * Static attribute values and literal text outside `{...}` are excluded, so a\n * plain string containing e.g. `$pending` does not produce a spurious import.\n */\nexport default function collectMarkupExpressions(root: TemplateNode): string {\n\tlet out = \"\";\n\tconst walk = (node: TemplateNode): void => {\n\t\tif (node.type === \"control\") {\n\t\t\tout += (node as ControlNode).statement + \"\\n\";\n\t\t}\n\t\tif (node.type === \"element\" || node.type === \"component\" || node.type === \"special\") {\n\t\t\tfor (const attribute of (node as ElementNode).attributes) {\n\t\t\t\tif (attribute.reactive && attribute.value !== undefined) {\n\t\t\t\t\tout += attribute.value + \"\\n\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (node.type === \"text\") {\n\t\t\tout += extractInterpolations((node as TextNode).content) + \"\\n\";\n\t\t}\n\t\tif (isParentNode(node)) {\n\t\t\tfor (const child of (node as ParentNode).children) {\n\t\t\t\twalk(child);\n\t\t\t}\n\t\t}\n\t};\n\twalk(root);\n\treturn out;\n}\n\n/**\n * Extracts the `{expr}` interpolation segments from text content (level 0\n * text is prose and is dropped), skipping string literals, template strings,\n * comments and regex literals inside the braces (they're copied into the\n * output verbatim).\n */\nfunction extractInterpolations(content: string): string {\n\tlet out = \"\";\n\tlet level = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tif (char === \"{\") {\n\t\t\tif (level === 0) out += \"\\n\";\n\t\t\tlevel++;\n\t\t\tout += char;\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tout += char;\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(content, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\tout += content.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tout += char;\n\t\t}\n\t}\n\treturn out;\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\n/**\n * Returns true if `markup` renders anything that forwards the component's\n * `$context` parameter: a child component invocation (`<Child />`), a\n * self-recursive `<@component self>`, or a `<slot>` definition (whose\n * generated render call passes `$context` through to the filling parent).\n *\n * `contextProps` only captures *direct* `$context.x` reads in the script, so\n * this is needed to decide whether the `$context` parameter is actually used:\n * every child-component / slot render call passes `$context` positionally\n * (see buildComponentNode / buildSlotNode and their server counterparts),\n * even when the component never names `$context` explicitly.\n *\n * Bias is towards `true`: when uncertain we keep `$context` named, which is\n * always safe at the cost of a missed unused-parameter cleanup.\n */\nexport default function markupRendersComponent(markup: RootNode): boolean {\n\treturn nodeRendersComponent(markup);\n}\n\nfunction nodeRendersComponent(node: TemplateNode): boolean {\n\tif (node.type === \"component\") return true;\n\tif (node.type === \"special\") {\n\t\tconst tagName = (node as ElementNode).tagName;\n\t\tif (tagName === \"@component\" || tagName === \"slot\") return true;\n\t}\n\tconst children = (node as { children?: TemplateNode[] }).children;\n\tif (children) {\n\t\tfor (const child of children) {\n\t\t\tif (nodeRendersComponent(child)) return true;\n\t\t}\n\t}\n\treturn false;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedText(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet start = b.toString().length + preText.length;\n\t\tb.append(preText + text + postText);\n\t\tlet end = start + text.length;\n\t\tstatus.map.push({\n\t\t\tscript: text,\n\t\t\tsource: span,\n\t\t\tcompiled: { start, end },\n\t\t});\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPopDevBoundary(status: BuildStatus, b: Builder): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_pop_dev_bound\");\n\t\tb.append(\"\");\n\t\tb.append(`t_pop_dev_bound();`);\n\t}\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addPushDevBoundary(\n\ttype: \"component\" | \"region\" | \"run\" | \"watch\" | \"control\" | \"branch\",\n\tname: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.dev === true) {\n\t\tstatus.imports.add(\"t_push_dev_bound\");\n\n\t\t// Ensure the name is wrapped with quotes, and internal quotes are escaped\n\t\tconst nameHasQuotes =\n\t\t\t(name.startsWith(\"'\") && name.endsWith(\"'\")) ||\n\t\t\t(name.startsWith('\"') && name.endsWith('\"')) ||\n\t\t\t(name.startsWith(\"`\") && name.endsWith(\"`\"));\n\t\tif (nameHasQuotes) {\n\t\t\tconst quote = name[0];\n\t\t\tname = quote + name.substring(1, name.length - 1).replaceAll(quote, \"\\\\\" + quote) + quote;\n\t\t} else {\n\t\t\tname = `\"${name.replaceAll('\"', '\\\\\"')}\"`;\n\t\t}\n\n\t\tb.append(`t_push_dev_bound(\"${type}\", ${name});`);\n\t\tb.append(\"\");\n\t}\n}\n","const ANCHOR_COMMENT = \"<!>\";\nconst HYDRATION_START_COMMENT = \"<![>\";\nconst HYDRATION_END_COMMENT = \"<!]>\";\nconst HYDRATION_BREAK_COMMENT = \"<!^>\";\n\nexport { ANCHOR_COMMENT, HYDRATION_START_COMMENT, HYDRATION_END_COMMENT, HYDRATION_BREAK_COMMENT };\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isControlNode(node: TemplateNode): node is ControlNode {\n\treturn node.type === \"control\";\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isElementNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\";\n}\n","import type OperationType from \"../types/nodes/OperationType\";\n\n/**\n * Control operations that produce no DOM output within a fragment.\n *\n * Used by both the fragment builder (to find the first child that actually\n * renders) and the whitespace trimmer (so that whitespace adjacent to these\n * nodes is treated as leading/trailing whitespace of the container, rather\n * than as significant inter-sibling whitespace — without this, every row of\n * a `@for { @key = ...; <tr>...</tr> }` would emit a leading whitespace\n * text node, since the whitespace sits between the @key and the <tr>).\n */\nexport const NON_RENDERING_OPERATIONS: Set<OperationType> = new Set<OperationType>([\n\t\"@key\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n]);\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isControlNode from \"./isControlNode\";\nimport isElementNode from \"./isElementNode\";\nimport { NON_RENDERING_OPERATIONS } from \"./nonRenderingOperations\";\n\n/**\n * Returns the single rendering `Element` root child of `children` if the\n * fragment is \"single-root element\" — i.e. it has exactly one child that\n * renders to the DOM, that child is an `Element`, and every other child is a\n * non-rendering control node (`@key`, `@const`, …) or a comment. Returns\n * `undefined` otherwise.\n *\n * When this returns an `Element`, the compiler emits the\n * `t_fragment_el` / `t_root_el` / `t_add_element` codegen path, which clones\n * the cached template's `firstElementChild` directly into the parent and\n * skips the per-instance `DocumentFragment` allocation that `getFragment`\n * produces.\n *\n * Text-root fragments (`{row.label}` standalone inside a `@for` body) are\n * intentionally excluded: their root is a `Text`, not an `Element`, so\n * `template.content.firstElementChild` would be `null`. Multi-root fragments\n * (`<tr>...</tr><tr>...</tr>`) are excluded because no single element\n * represents the whole fragment.\n */\nexport default function getSingleElementRoot(children: TemplateNode[]): ElementNode | undefined {\n\tlet renderingRoot: ElementNode | undefined;\n\tfor (const child of children) {\n\t\tif (child.type === \"comment\") continue;\n\t\tif (isControlNode(child) && NON_RENDERING_OPERATIONS.has(child.operation)) continue;\n\t\tif (renderingRoot) return undefined;\n\t\tif (!isElementNode(child)) return undefined;\n\t\trenderingRoot = child;\n\t}\n\treturn renderingRoot;\n}\n","/**\n * Checks whether the supplied string is fully or partially reactive (i.e. contains braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully or partially reactive\n */\nexport default function isReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.includes(\"{\") && text.includes(\"}\");\n}\n","/**\n * Trims matching quotes from the start and end of the supplied text\n *\n * @param text The text to trim\n *\n * @returns The text without the quotes at the start or the end\n */\nexport default function trimQuotes(text: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (\n\t\t(text[start] === \"'\" && text[end - 1] === \"'\") ||\n\t\t(text[start] === '\"' && text[end - 1] === '\"') ||\n\t\t(text[start] === \"`\" && text[end - 1] === \"`\")\n\t) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","// From https://developer.mozilla.org/en-US/docs/Glossary/Void_element\nconst voidTags: string[] = [\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n];\nexport default voidTags;\n","import { ANCHOR_COMMENT } from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport getSingleElementRoot from \"../../utils/getSingleElementRoot\";\nimport isReactive from \"../../utils/isReactive\";\nimport { NON_RENDERING_OPERATIONS } from \"../../utils/nonRenderingOperations\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport voidTags from \"../../utils/voidTags\";\nimport type BuildStatus from \"./BuildStatus\";\n\n/**\n * Builds the HTML template text for all of the fragments in a component\n */\nexport default function buildFragmentText(\n\tnode: RootNode | ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tconst fragments: Fragment[] = [];\n\tbuildNodeFragmentText(node, status, fragments);\n\n\tif (fragments.length) {\n\t\t// `t_fragments` is only referenced by the `t_fragment` codegen path\n\t\t// (multi-root fragments). Single-root-element fragments take the\n\t\t// `t_fragment_el` path and never touch `t_fragments`, so declaring it\n\t\t// there would leave it unused.\n\t\tif (fragments.some((f) => !f.singleRootElement && f.usesFragmentCache !== false)) {\n\t\t\tb.append(`const t_fragments: DocumentFragment[] = [];`);\n\t\t}\n\t\t// The single-root-element cache stores the cached `firstElementChild`\n\t\t// directly (no DocumentFragment wrapper). Only emitted when at least\n\t\t// one fragment in this component takes the `t_fragment_el` codegen\n\t\t// path; the cost of one extra empty array per component is negligible.\n\t\tif (fragments.some((f) => f.singleRootElement)) {\n\t\t\tb.append(`const t_fragment_els: Element[] = [];`);\n\t\t}\n\t}\n}\n\nfunction buildNodeFragmentText(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment?: Fragment,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootFragmentText(node as RootNode, status, fragments);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlFragmentText(node as ControlNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\t// NOTE: We don't support nested SVG for now\n\t\t\tlet ns = (node as ElementNode).tagName === \"svg\";\n\t\t\tif (ns) status.ns = true;\n\t\t\tbuildElementFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tif (ns) status.ns = false;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tconst content = (node as TextNode).content;\n\t\t\tif (currentFragment) {\n\t\t\t\tcurrentFragment.text += isReactive(content) ? \"#\" : content;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialFragmentText(node as ElementNode, status, fragments, currentFragment!);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildRootFragmentText(node: RootNode, status: BuildStatus, fragments: Fragment[]) {\n\tnode.fragment = {\n\t\tnumber: fragments.length,\n\t\ttext: \"\",\n\t\tns: status.ns,\n\t\teffects: [],\n\t\tevents: [],\n\t\tanimations: [],\n\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t};\n\tfragments.push(node.fragment);\n\tfor (let child of node.children) {\n\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t}\n}\n\nfunction buildControlFragmentText(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@try group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\t// Add a placeholder if it's a branching control node\n\t\t\t//if (!node.singleRooted) {\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\t//}\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// Non-rendering nodes (@const, @key, @function, ...) produce no DOM,\n\t\t\t// so they must not spawn their own fragment. Spawning one here would\n\t\t\t// leave an empty multi-root fragment that forces the `t_fragments`\n\t\t\t// cache to be declared even when every rendering fragment is a\n\t\t\t// single-root element (leaving `t_fragments` unused).\n\t\t\tif (NON_RENDERING_OPERATIONS.has(node.operation)) {\n\t\t\t\tfor (let child of node.children) {\n\t\t\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Add a new fragment if it's a control branch and it has children\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t\t\t\t// `@html` builds its content at runtime from an innerHTML string\n\t\t\t\t// (see buildHtmlNode) and only uses this fragment's `number` for\n\t\t\t\t// naming — it never goes through the `buildFragment` cache path, so\n\t\t\t\t// it must not force an unused `t_fragments` declaration.\n\t\t\t\tusesFragmentCache: node.operation !== \"@html\",\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction buildComponentFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tcurrentFragment.text += ANCHOR_COMMENT;\n\n\t// Add fragments for slots if there are children\n\tif (node.children.length) {\n\t\tnode.fragment = {\n\t\t\tnumber: fragments.length,\n\t\t\ttext: \"\",\n\t\t\tns: status.ns,\n\t\t\teffects: [],\n\t\t\tevents: [],\n\t\t\tanimations: [],\n\t\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t\t};\n\t\tfragments.push(node.fragment);\n\t\tfor (let child of node.children) {\n\t\t\t// TODO: Make sure it's not a fill node\n\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t}\n\t}\n}\n\nfunction buildElementFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tconst tagName = node.tagName === \"@element\" ? \"el\" : node.tagName;\n\tlet needsClass = node.scopeStyles;\n\tcurrentFragment.text += `<${tagName}`;\n\tlet attributesText = node.attributes\n\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t.filter((a) => !(a.name === \"self\" && node.tagName === \"@element\"))\n\t\t.map((a) => {\n\t\t\tif (a.value && a.reactive) {\n\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t// up, especially in the case of data attributes. Otherwise don't set it\n\t\t\t\tif (a.name.startsWith(\"data-\")) {\n\t\t\t\t\treturn `${a.name}=\"\"`;\n\t\t\t\t}\n\t\t\t} else if (a.name === \"class\" && node.scopeStyles) {\n\t\t\t\tneedsClass = false;\n\t\t\t\tlet value = a.value\n\t\t\t\t\t? `\"${trimQuotes(a.value)} torp-${status.styleHash}\"`\n\t\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\t\treturn `${a.name}=${value}`;\n\t\t\t} else {\n\t\t\t\treturn `${a.name}${a.value != null ? `=${a.value}` : \"\"}`;\n\t\t\t}\n\t\t})\n\t\t.filter(Boolean)\n\t\t.join(\" \");\n\tif (attributesText) {\n\t\tcurrentFragment.text += \" \" + attributesText;\n\t}\n\tif (needsClass) {\n\t\tcurrentFragment.text += ` class=\"torp-${status.styleHash}\"`;\n\t}\n\n\tcurrentFragment.text += \">\";\n\n\tif (!voidTags.includes(node.tagName)) {\n\t\tfor (let child of node.children) {\n\t\t\tbuildNodeFragmentText(child, status, fragments, currentFragment);\n\t\t}\n\t\tcurrentFragment.text += `</${tagName}>`;\n\t}\n}\n\nfunction buildSpecialFragmentText(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tfragments: Fragment[],\n\tcurrentFragment: Fragment,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\t// Add an anchor for the slot\n\t\t\tcurrentFragment.text += ANCHOR_COMMENT;\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\t// Add a new fragment for filled slot content\n\t\t\tnode.fragment = {\n\t\t\t\tnumber: fragments.length,\n\t\t\t\ttext: \"\",\n\t\t\t\tns: status.ns,\n\t\t\t\teffects: [],\n\t\t\t\tevents: [],\n\t\t\t\tanimations: [],\n\t\t\t\tsingleRootElement: getSingleElementRoot(node.children) !== undefined,\n\t\t\t};\n\t\t\tfragments.push(node.fragment);\n\t\t\tfor (let child of node.children) {\n\t\t\t\tbuildNodeFragmentText(child, status, fragments, node.fragment);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildElementFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentFragmentText(node, status, fragments, currentFragment);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import { skipStringOrComment } from \"./codeScanner\";\n\n/**\n * Builds the statements that write a component's prop value back to the\n * expression it is bound to (e.g. for `&name={$state.user?.name}`).\n *\n * The bound expression may use optional chaining, which can't be assigned to\n * directly. In that case the write is compiled to a guarded assignment: the\n * prop value is read first (so the write re-runs when the child changes it),\n * the target object is read with `$peek` (so that replacing it doesn't re-run\n * the write with a stale prop value), and the value is written through it\n * when it exists:\n *\n * ```\n * bindingTarget(\"$state.user?.name\", `props[\"name\"]`, \"name\", imports)\n * // => const t_bind_name = props[\"name\"];\n * // const t_target_name = $peek(() => $state.user);\n * // if (t_target_name != null) t_target_name.name = t_bind_name;\n * ```\n *\n * @param value The bound expression\n * @param right The value to assign to it\n * @param name The prop name, used to make the temp variable names unique\n * @param imports The set of runtime imports to add `$peek` to when the\n * expression needs a guarded write\n *\n * @returns The assignment statements\n */\nexport default function bindingTarget(\n\tvalue: string,\n\tright: string,\n\tname: string,\n\timports?: Set<string>,\n): string {\n\t// Find the optional chains in the expression, keeping track of the last\n\t// chain so that the write can be guarded on it\n\tlet lastChainStart = -1;\n\n\tfor (let i = 0; i < value.length; i++) {\n\t\tlet char = value[i];\n\t\tif (char === '\"' || char === \"'\" || char === \"`\" || char === \"/\") {\n\t\t\t// Skip strings, template strings, comments and regex literals\n\t\t\tconst skipped = skipStringOrComment(value, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tif (char === \"?\" && value[i + 1] === \".\" && !/[0-9]/.test(value[i + 2] ?? \"\")) {\n\t\t\t// NOTE: `?.` followed by a digit is a ternary (e.g. `a ?.5 : b`),\n\t\t\t// not an optional chain\n\t\t\tlet next = value[i + 2];\n\t\t\tif (next === \"(\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot bind to \"${value}\": optional calls are not supported in binding expressions`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlastChainStart = i;\n\t\t\tif (next === \"[\") {\n\t\t\t\t// Skip the whole `?.` -- `a?.[key]` becomes `a[key]`\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t\t// Otherwise skip just the `?` -- `a?.name` becomes `a.name`\n\t\t\tcontinue;\n\t\t}\n\t}\n\n\tif (lastChainStart === -1) {\n\t\treturn `${value} = ${right};`;\n\t}\n\n\t// The guard reads the chain up to (but not including) its last link. If\n\t// that isn't nullish, no link in the chain is, so the write is safe --\n\t// optional chaining short-circuits the whole chain when a link is missing\n\tlet guard = value.substring(0, lastChainStart);\n\t// The part after the last `?.` -- `.name` for a property access, `[key]`\n\t// for a computed one\n\tlet next = value[lastChainStart + 2];\n\tif (next !== \"[\" && !/[A-Za-z0-9_$]/.test(next ?? \"\")) {\n\t\t// e.g. a chain nested inside a computed key (`a?.[b?.c]`) splits the\n\t\t// expression in a place that can't be assigned to\n\t\tthrow new Error(`Cannot bind to \"${value}\": unsupported optional chain in binding expression`);\n\t}\n\tlet suffix = value.substring(lastChainStart + (next === \"[\" ? 2 : 1));\n\tlet varSuffix = name.replace(/[^a-zA-Z0-9_$]/g, \"_\");\n\timports?.add(\"$peek\");\n\treturn (\n\t\t`const t_bind_${varSuffix} = ${right};\\n` +\n\t\t`const t_target_${varSuffix} = $peek(() => ${guard});\\n` +\n\t\t`if (t_target_${varSuffix} != null) t_target_${varSuffix}${suffix} = t_bind_${varSuffix};`\n\t);\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isSpecialNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"special\";\n}\n","import type BuildStatus from \"../client/BuildStatus\";\nimport type BuildServerStatus from \"../server/BuildServerStatus\";\n\n/**\n * Makes a supplied variable name (hopefully!) unique by prepending `t_` and\n * appending a sequence number\n *\n * @param name The variable name\n * @param status The build status\n *\n * @returns A unique variable name\n */\nexport default function nextVarName(name: string, status: BuildStatus | BuildServerStatus): string {\n\tif (!status.varNames[name]) {\n\t\tstatus.varNames[name] = 1;\n\t}\n\tlet varName = `t_${name}_${status.varNames[name]}`;\n\tstatus.varNames[name] += 1;\n\treturn varName;\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\n\nexport default function addMappedTextWithOffsets(\n\tpreText: string,\n\ttext: string,\n\tpostText: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tif (status.options.mapped === true) {\n\t\tlet mappedStart = b.toString().length + preText.length;\n\t\tlet functionBody = preText + text + postText;\n\t\tb.append(functionBody);\n\t\tfor (let i = 0; i < spans.length; i++) {\n\t\t\tlet start = mappedStart + offsets[i];\n\t\t\tlet end = start + lengths[i];\n\t\t\tstatus.map.push({\n\t\t\t\tscript: functionBody,\n\t\t\t\tsource: spans[i],\n\t\t\t\tcompiled: { start, end },\n\t\t\t});\n\t\t}\n\t} else {\n\t\tb.append(preText + text + postText);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\n\nexport default function buildAddFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tif (fragment.effects.length > 0) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\t// Union the forVarMask of every stashed effect in this fragment —\n\t\t\t// they all share a single `$run`, so the run's forVarMask is the\n\t\t\t// bitwise OR of its constituents'.\n\t\t\tlet forVarMask: number | undefined;\n\t\t\tfor (let effect of fragment.effects) {\n\t\t\t\tif (effect.forVarMask !== undefined) {\n\t\t\t\t\tif (forVarMask === undefined) forVarMask = 0;\n\t\t\t\t\tforVarMask |= effect.forVarMask;\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet trailing = \"\";\n\t\t\tif (forVarMask !== undefined) {\n\t\t\t\ttrailing = `, undefined, { forVarMask: ${forVarMask} }`;\n\t\t\t}\n\t\t\tb.append(\"$run(() => {\");\n\t\t\tif (status.options.mapped === true) {\n\t\t\t\tfor (let effect of fragment.effects) {\n\t\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.functionBody,\n\t\t\t\t\t\t\"\",\n\t\t\t\t\t\teffect.spans,\n\t\t\t\t\t\teffect.offsets,\n\t\t\t\t\t\teffect.lengths,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tb,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tb.append(fragment.effects.map((e) => e.functionBody).join(\"\\n\"));\n\t\t\t}\n\t\t\tb.append(`}${status.options.dev === true ? `, \"setAttributes\"${trailing}` : trailing});`);\n\t\t}\n\t\tif (fragment.singleRootElement) {\n\t\t\t// Single-root-element fast path: the cloned element is both the\n\t\t\t// fragment and the end node, so `t_add_element(node, parent,\n\t\t\t// before)` replaces `t_add_fragment(fragment, parent, before,\n\t\t\t// endNode)`. Saves the `firstChild` / `lastChild` reads and the\n\t\t\t// `DocumentFragment`-aware branches inside `t_add_fragment`.\n\t\t\tstatus.imports.add(\"t_add_element\");\n\t\t\tb.append(\n\t\t\t\t`t_add_element(${fragment.endVarName ?? fragmentName}, ${parentName}, ${anchorName});`,\n\t\t\t);\n\t\t\tif (fragment.endVarName) {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tb.append(`t_next(${fragment.endVarName});`);\n\t\t\t}\n\t\t} else {\n\t\t\tstatus.imports.add(\"t_add_fragment\");\n\t\t\tlet params = [fragmentName, parentName, anchorName];\n\t\t\tif (fragment.endVarName) {\n\t\t\t\tparams.push(fragment.endVarName);\n\t\t\t}\n\t\t\t// Pass the root node so `addFragment` can restore the active\n\t\t\t// region's `startNode` during hydration. Child component rendering\n\t\t\t// (via `addElement`) overwrites `startNode` before `addFragment`\n\t\t\t// runs; without this, the region's bounds are wrong and slot\n\t\t\t// reuse clears the wrong parent.\n\t\t\tif (fragment.endVarName && fragment.rootVarName) {\n\t\t\t\tparams.push(fragment.rootVarName);\n\t\t\t}\n\t\t\tb.append(`t_add_fragment(${params.join(\", \")});`);\n\t\t\t// TODO: Don't need to do this if the last thing we hydrated was the end node\n\t\t\tif (fragment.endVarName) {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tb.append(`t_next(${fragment.endVarName});`);\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied character is a space\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is a space\n */\nexport default function isSpaceChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn code === 32 || (code >= 9 && code <= 13);\n}\n","import isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Checks whether the supplied string contains only space characters\n *\n * @param text The string to check\n *\n * @returns True if the supplied string contains only space characters\n */\nexport default function isSpace(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tif (!isSpaceChar(text, i)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\n\nexport default function isTextNode(node: TemplateNode): node is TextNode {\n\treturn node.type === \"text\";\n}\n","import isSpace from \"../../parse/utils/isSpace\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport isReactive from \"../../utils/isReactive\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport isTextNode from \"../../utils/isTextNode\";\nimport { NON_RENDERING_OPERATIONS } from \"../../utils/nonRenderingOperations\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildNode from \"./buildNode\";\n\ninterface VariablePath {\n\tparent: VariablePath | null;\n\ttype: string;\n\tchildren: VariablePath[];\n}\n\n/**\n * Builds the variables and code in a fragment\n */\nexport default function buildFragment(\n\tnode: RootNode | ControlNode | ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tif (node.fragment) {\n\t\tconst fragment = node.fragment;\n\t\tconst fragmentName = `t_fragment_${fragment.number}`;\n\t\tif (status.options.useCreateElement === true) {\n\t\t\t// Declarations, then createXxx calls\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tfragmentPath.children.length = 0;\n\t\t\tvarPaths.clear();\n\t\t\tstatus.imports.add(\"t_frg\");\n\t\t\tb.append(`const ${fragmentName} = t_frg([`);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tb.append(`]);`);\n\t\t} else {\n\t\t\t// Text, then declarations\n\t\t\tconst fragmentText = fragment.text.replaceAll(\"`\", \"\\\\`\").replaceAll(/\\s+/g, \" \");\n\t\t\tif (fragment.singleRootElement) {\n\t\t\t\t// Single-root-element fast path: clone the cached template's\n\t\t\t\t// `firstElementChild` directly (skipping the per-instance\n\t\t\t\t// `DocumentFragment` wrapper that `t_fragment` produces).\n\t\t\t\t// Saves one allocation per created list-item / branch render,\n\t\t\t\t// which dominates the cost of bulk-row creates (`run`/`add`/\n\t\t\t\t// `runlots`) in the js-framework-bench.\n\t\t\t\tstatus.imports.add(\"t_fragment_el\");\n\t\t\t\tb.append(\n\t\t\t\t\t`const ${fragmentName} = t_fragment_el($parent.ownerDocument!, t_fragment_els, ${fragment.number}, \\`${fragmentText}\\`${fragment.ns ? \", true\" : \"\"});`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_fragment\");\n\t\t\t\tb.append(\n\t\t\t\t\t`const ${fragmentName} = t_fragment($parent.ownerDocument!, t_fragments, ${fragment.number}, \\`${fragmentText}\\`${fragment.ns ? \", true\" : \"\"});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet fragmentPath = { parent: null, type: \"fragment\", children: [] };\n\t\t\tlet varPaths = new Map<string, string>();\n\t\t\tmaybeAddRootNodeDeclaration(node, fragment, fragmentName, status, b, varPaths);\n\t\t\tdeclareFragmentVars(\n\t\t\t\tnode.fragment,\n\t\t\t\tnode,\n\t\t\t\tfragmentPath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tfalse,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction maybeAddRootNodeDeclaration(\n\tnode: RootNode | ControlNode | ElementNode,\n\tfragment: Fragment,\n\tfragmentName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n) {\n\tif (!node.children.length) return;\n\n\t// Always create a root variable. We need it both for subsequent node\n\t// traversal AND to pass to `t_add_fragment` so it can restore the active\n\t// region's `startNode` during hydration (child component rendering via\n\t// `addElement` overwrites it before `addFragment` runs).\n\tconst rootName = `t_root_${fragment.number}`;\n\tconst firstRendering = firstRenderingChild(node.children);\n\tconst isTextRoot = !!(firstRendering && isTextNode(firstRendering));\n\n\tconst rootFn = fragment.singleRootElement ? \"t_root_el\" : \"t_root\";\n\tstatus.imports.add(rootFn);\n\tconst params = [fragmentName];\n\tif (!fragment.singleRootElement && isTextRoot) {\n\t\tparams.push(\"true\");\n\t}\n\tconst rootPath = `${rootFn}(${params.join(\", \")})`;\n\tb.append(`const ${rootName} = ${rootPath};`);\n\t// Register the root access for shortening so subsequent\n\t// `declareFragmentVars` traversals reuse `rootName` instead of\n\t// re-emitting the (matching) root function call.\n\tvarPaths.set(`${rootFn}(${fragmentName})`, rootName);\n\t// Track the root variable for `t_add_fragment` (only needed for\n\t// multi-root fragments — single-root uses `t_add_element` which already\n\t// sets both start/end correctly).\n\tif (!fragment.singleRootElement) {\n\t\tfragment.rootVarName = rootName;\n\t}\n\n\tprintDebug(rootName, status, b);\n}\n\n/**\n * Returns the first child that actually renders to the DOM, skipping comments\n * and no-output control nodes like @key/@const.\n */\nfunction firstRenderingChild(children: TemplateNode[]): TemplateNode | undefined {\n\tfor (const child of children) {\n\t\tif (child.type === \"comment\") continue;\n\t\tif (isControlNode(child) && NON_RENDERING_OPERATIONS.has(child.operation)) continue;\n\t\treturn child;\n\t}\n\treturn undefined;\n}\n\nfunction declareFragmentVars(\n\tfragment: Fragment,\n\tnode: TemplateNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tdeclareRootFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as RootNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tdeclareControlFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ControlNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tdeclareTextFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as TextNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tdeclareSpecialFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode as ElementNode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't output comments!\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n\nfunction declareRootFragmentVars(\n\tfragment: Fragment,\n\tnode: RootNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n}\n\nfunction declareControlFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tswitch (node.operation) {\n\t\tcase \"@if group\":\n\t\tcase \"@switch group\":\n\t\tcase \"@for group\":\n\t\tcase \"@await group\":\n\t\tcase \"@try group\":\n\t\tcase \"@replace group\":\n\t\tcase \"@html group\": {\n\t\t\tconst operation = node.operation.substring(1).replace(\" group\", \"\");\n\t\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\toperation,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction declareComponentFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tdeclare: boolean,\n) {\n\tdeclareParentAndAnchorFragmentVars(\n\t\tfragment,\n\t\tnode,\n\t\tpath,\n\t\tstatus,\n\t\tb,\n\t\tparentName,\n\t\tanchorName,\n\t\tvarPaths,\n\t\t\"comp\",\n\t\tdeclare,\n\t);\n}\n\nfunction elementTypeName(node: ElementNode) {\n\t// TODO: Etc\n\tswitch (node.tagName.toLowerCase()) {\n\t\tcase \"div\":\n\t\tcase \"span\":\n\t\tcase \"input\":\n\t\tcase \"select\":\n\t\tcase \"option\":\n\t\tcase \"button\":\n\t\tcase \"form\":\n\t\t\treturn `HTML${node.tagName.substring(0, 1).toUpperCase() + node.tagName.substring(1)}Element`;\n\t\tcase \"a\":\n\t\t\treturn \"HTMLAnchorElement\";\n\t\tcase \"img\":\n\t\t\treturn \"HTMLImageElement\";\n\t\tcase \"textarea\":\n\t\t\treturn \"HTMLTextAreaElement\";\n\t\tcase \"svg\":\n\t\t\treturn \"SVGElement\";\n\t\tcase \"line\":\n\t\tcase \"text\":\n\t\tcase \"path\":\n\t\tcase \"rect\":\n\t\t\treturn `SVG${node.tagName.substring(0, 1).toUpperCase() + node.tagName.substring(1)}Element`;\n\t}\n\treturn \"HTMLElement\";\n}\n\nfunction declareElementFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tconst tagName = node.tagName === \"@element\" ? \"element\" : node.tagName;\n\n\tlet elementPath = { parent: path, type: tagName, children: [] };\n\tpath.children.push(elementPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = elementNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(tagName, status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, elementPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tif (node.tagName === \"@element\") {\n\t\t\t\t\tb.append(`let ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.varName} = ${varPath} as ${elementTypeName(node)};`);\n\t\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t\t}\n\n\t\t\t\t// Do &ref first, just in case any other attributes or\n\t\t\t\t// components depend on it being set e.g. if you have a `style`\n\t\t\t\t// attribute that depends on the element's size, or you are\n\t\t\t\t// passing the element to a component as an anchor\n\t\t\t\tconst refAttribute = node.attributes.find((a) => a.name === \"&ref\");\n\t\t\t\tif (refAttribute) {\n\t\t\t\t\tlet { value, fullyReactive } = refAttribute;\n\t\t\t\t\tif (value != null && fullyReactive) {\n\t\t\t\t\t\t// Bind the DOM element to a user-defined variable\n\t\t\t\t\t\tb.append(`${value} = ${node.varName};`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// If there is an immediate child of this element that has this element as its parent,\n\t// we need to assign the element to the parent var\n\t// @ts-ignore\n\tlet childParentName = node.children.find((c) => !!c.parentName)?.parentName;\n\n\tif (!declare) {\n\t\tlet attributes = node.attributes\n\t\t\t.filter((a) => !a.name.startsWith(\"on\"))\n\t\t\t.map((a) => {\n\t\t\t\tif (a.value && a.reactive) {\n\t\t\t\t\t// Adding a placeholder for reactive attributes seems to speed things\n\t\t\t\t\t// up, especially in the case of data attributes\n\t\t\t\t\treturn `\"${a.name}\": \"#\"`;\n\t\t\t\t} else if (a.value) {\n\t\t\t\t\treturn `\"${a.name}\": \"${trimQuotes(a.value) || a.name}\"`;\n\t\t\t\t} else {\n\t\t\t\t\treturn `\"${a.name}\": true\"`;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.join(\", \");\n\n\t\tstatus.imports.add(\"t_elm\");\n\t\tif (declareVariable) {\n\t\t\tb.append(\n\t\t\t\t`(${childParentName ? `${childParentName} = ` : \"\"}${node.varName} = t_elm(\"${node.tagName}\", {${attributes}}, [`,\n\t\t\t);\n\t\t} else if (childParentName) {\n\t\t\tb.append(`(${childParentName} = t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t} else {\n\t\t\tb.append(`t_elm(\"${node.tagName}\", {${attributes}}, [`);\n\t\t}\n\t}\n\n\tfor (let [i, child] of node.children.entries()) {\n\t\tdeclareFragmentVars(\n\t\t\tfragment,\n\t\t\tchild,\n\t\t\telementPath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\ti === node.children.length - 1,\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tif (!declare) {\n\t\tif (declareVariable || childParentName) {\n\t\t\tb.append(\"])),\");\n\t\t} else {\n\t\t\tb.append(\"]),\");\n\t\t}\n\t}\n}\n\nfunction elementNodeNeedsDeclaration(node: ElementNode, topLevel: boolean, lastChild: boolean) {\n\tconst hasReactiveAttribute = node.attributes.some((a) => a.value && a.reactive);\n\tconst isDynamicElement =\n\t\tnode.tagName === \"@element\" && node.attributes.find((a) => a.name === \"self\");\n\treturn hasReactiveAttribute || isDynamicElement || (topLevel && lastChild);\n}\n\nfunction declareTextFragmentVars(\n\tfragment: Fragment,\n\tnode: TextNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\t// HACK: Text nodes get merged together\n\t// Is this because of control nodes like @key and @const??\n\t// TODO: We should do this when building for the server too\n\tconst lastType = path.children[path.children.length - 1]?.type;\n\tif (lastType === \"text\" || lastType === \"space\") {\n\t\treturn;\n\t}\n\n\tlet textPath = { parent: path, type: isSpace(node.content) ? \"space\" : \"text\", children: [] };\n\tpath.children.push(textPath);\n\n\tconst topLevel = !path.parent;\n\tconst declareVariable = textNodeNeedsDeclaration(node, topLevel, lastChild);\n\n\tif (declare) {\n\t\tif (declareVariable) {\n\t\t\tnode.varName = nextVarName(\"text\", status);\n\t\t\tif (topLevel) {\n\t\t\t\tfragment.endVarName = node.varName;\n\t\t\t}\n\t\t\tconst varPath = getFragmentVarPath(fragment, status, node.varName, textPath, varPaths);\n\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\tb.append(`let ${node.varName};`);\n\t\t\t} else {\n\t\t\t\tb.append(`const ${node.varName} = ${varPath};`);\n\t\t\t\tprintDebug(node.varName, status, b);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_txt\");\n\t\tif (declareVariable) {\n\t\t\tb.append(`(${node.varName} = t_txt(\" \")),`);\n\t\t} else {\n\t\t\tb.append(`t_txt(\"${node.content}\"),`);\n\t\t}\n\t}\n}\n\nfunction textNodeNeedsDeclaration(node: TextNode, topLevel: boolean, lastChild: boolean) {\n\treturn isReactive(node.content) || (topLevel && lastChild);\n}\n\nfunction declareSpecialFragmentVars(\n\tfragment: Fragment,\n\tnode: ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tlastChild: boolean,\n\tdeclare: boolean,\n) {\n\tif (node.tagName === \"slot\") {\n\t\tdeclareParentAndAnchorFragmentVars(\n\t\t\tfragment,\n\t\t\tnode,\n\t\t\tpath,\n\t\t\tstatus,\n\t\t\tb,\n\t\t\tparentName,\n\t\t\tanchorName,\n\t\t\tvarPaths,\n\t\t\t\"slot\",\n\t\t\tdeclare,\n\t\t);\n\t}\n\n\tswitch (node.tagName) {\n\t\tcase \"slot\":\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\tfor (let [i, child] of node.children.entries()) {\n\t\t\t\t// Don't build the fill node twice\n\t\t\t\tif (\n\t\t\t\t\tnode.tagName === \"slot\" &&\n\t\t\t\t\tisSpecialNode(child) &&\n\t\t\t\t\t(child.tagName === \"fill\" || child.tagName === \"filldef\")\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdeclareFragmentVars(\n\t\t\t\t\tfragment,\n\t\t\t\t\tchild,\n\t\t\t\t\tpath,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t\tparentName,\n\t\t\t\t\tanchorName,\n\t\t\t\t\tvarPaths,\n\t\t\t\t\ti === node.children.length - 1,\n\t\t\t\t\tdeclare,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tdeclareElementFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tlastChild,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tdeclareComponentFragmentVars(\n\t\t\t\tfragment,\n\t\t\t\tnode,\n\t\t\t\tpath,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t\tparentName,\n\t\t\t\tanchorName,\n\t\t\t\tvarPaths,\n\t\t\t\tdeclare,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n\nfunction declareParentAndAnchorFragmentVars(\n\tfragment: Fragment,\n\tnode: ControlNode | ElementNode,\n\tpath: VariablePath,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\tvarPaths: Map<string, string>,\n\tname: string,\n\tdeclare: boolean,\n) {\n\tconst topLevel = !path.parent;\n\n\t// Declare the parent\n\tif (topLevel) {\n\t\t// If this is a top-level element, then the parent is the fragment\n\t\tnode.parentName = `t_fragment_${fragment.number}`;\n\t} else {\n\t\tconst parentPath = path;\n\t\tconst oldChildren = parentPath.children;\n\t\tparentPath.children = [];\n\t\tconst parentVarPath = getFragmentVarPath(fragment, status, \"?\", parentPath, varPaths);\n\t\tparentPath.children = oldChildren;\n\t\t// TODO: Should do this thing for the last child as well\n\t\tif (varPaths.has(parentVarPath)) {\n\t\t\tnode.parentName = varPaths.get(parentVarPath);\n\t\t} else {\n\t\t\tif (declare) {\n\t\t\t\tnode.parentName = nextVarName(`${name}_parent`, status);\n\t\t\t\tif (status.options.useCreateElement === true) {\n\t\t\t\t\tb.append(`let ${node.parentName} as HTMLElement;`);\n\t\t\t\t} else {\n\t\t\t\t\tb.append(`const ${node.parentName} = ${parentVarPath} as HTMLElement;`);\n\n\t\t\t\t\tprintDebug(node.parentName, status, b);\n\t\t\t\t}\n\t\t\t\tvarPaths.set(parentVarPath, node.parentName);\n\t\t\t} else {\n\t\t\t\t// HACK: For the createElement option, this gets done in the parent\n\t\t\t}\n\t\t}\n\t}\n\n\t// Declare the anchor\n\tif (declare) {\n\t\tconst anchorPath = { parent: path, type: \"#\", children: [] };\n\t\tpath.children.push(anchorPath);\n\n\t\tnode.varName = nextVarName(`${name}_anchor`, status);\n\t\t// A top-level control node or component is the last node in its\n\t\t// fragment (its anchor comment is emitted after the preceding\n\t\t// elements). Track it as the fragment's end node so that region\n\t\t// clearing covers the whole fragment — mirroring what\n\t\t// `declareElementFragmentVars` / `declareTextFragmentVars` do for\n\t\t// element and text children.\n\t\tif (topLevel) {\n\t\t\tfragment.endVarName = node.varName;\n\t\t}\n\t\tconst anchorVarPath = getFragmentVarPath(fragment, status, node.varName, anchorPath, varPaths);\n\t\tif (status.options.useCreateElement === true) {\n\t\t\tb.append(`let ${node.varName};`);\n\t\t} else {\n\t\t\tstatus.imports.add(\"t_anchor\");\n\t\t\tb.append(`let ${node.varName} = t_anchor(${anchorVarPath}) as HTMLElement;`);\n\n\t\t\tprintDebug(node.varName, status, b);\n\t\t}\n\t} else {\n\t\tstatus.imports.add(\"t_cmt\");\n\t\tb.append(`(${node.varName} = t_cmt()),`);\n\t}\n\n\t// Build nodes with anchors immediately, while we have their anchor node,\n\t// rather than at the end of the fragment\n\tbuildNode(node, status, b, parentName, anchorName);\n\tnode.handled = true;\n}\n\nfunction getFragmentVarPath(\n\tfragment: Fragment,\n\tstatus: BuildStatus,\n\tname: string,\n\tpath: VariablePath,\n\tvarPaths: Map<string, string>,\n): string {\n\tlet node = path;\n\twhile (node.parent) {\n\t\tnode = node.parent;\n\t}\n\tlet varName = `t_fragment_${fragment.number}`;\n\t// Single-root-element fragments clone the cached template's\n\t// `firstElementChild` directly, so the root access goes through\n\t// `t_root_el` (which passes the cloned element through in the\n\t// non-hydrating case and walks the hydration cursor when hydrating)\n\t// rather than `t_root` (which reads `fragment.firstChild`).\n\tconst rootFn = fragment.singleRootElement ? \"t_root_el\" : \"t_root\";\n\tlet varPath = getFragmentVarPathPart(node, varName, status, true, rootFn);\n\n\t// Check for parts of the path that have already been run to shorten our\n\t// traversal\n\tfor (let [existingPath, existingName] of varPaths) {\n\t\tif (varPath.includes(existingPath)) {\n\t\t\tvarPath = varPath.replace(existingPath, existingName);\n\t\t}\n\t}\n\n\t// HACK: allow passing in \"?\" to not add the parentVarPath to the existing\n\t// paths\n\tif (name !== \"?\") {\n\t\t// Add the path, so that we can shorten subsequent paths e.g.\n\t\t// const div = t_next(t_child(root));\n\t\t// const p = t_next(t_next(t_next(t_child(root))))\n\t\t// => const p = t_next(t_next(div))\n\t\tvarPaths.set(varPath, name);\n\t\t// Add the name, so that we are always using the last declared name\n\t\tvarPaths.set(name, name);\n\t}\n\n\t// Shorten `t_next(t_next(x))` to `t_skip(x, 2)`\n\twhile (varPath.includes(\"t_next(t_next(\")) {\n\t\tstatus.imports.add(\"t_skip\");\n\t\tconst match = varPath.match(/(t_next\\(){2,}/)![0];\n\t\tconst count = match.length / \"t_next(\".length;\n\t\tconst pos = varPath.indexOf(\"t_next(t_next(\");\n\t\tconst head = varPath.substring(0, pos);\n\t\tlet level = 0;\n\t\tlet end = 0;\n\t\tfor (let i = pos + match.length; i < varPath.length; i++) {\n\t\t\tif (varPath[i] === \"(\") {\n\t\t\t\tlevel++;\n\t\t\t} else if (varPath[i] === \")\") {\n\t\t\t\tif (level === 0) {\n\t\t\t\t\tend = i;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tlevel--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst tail = varPath.substring(end + count);\n\t\tconst param = varPath.substring(pos + match.length, end);\n\t\tvarPath = `${head}t_skip(${param}, ${count})${tail}`;\n\t}\n\n\t// Set t_next_text back to t_next\n\tvarPath = varPath.replaceAll(\"t_next_text\", \"t_next\");\n\n\treturn varPath;\n}\n\nfunction getFragmentVarPathPart(\n\tpath: VariablePath,\n\tvarPath: string,\n\tstatus: BuildStatus,\n\troot = false,\n\trootFn = \"t_root\",\n): string {\n\tif (root) {\n\t\tstatus.imports.add(rootFn);\n\t\tvarPath = `${rootFn}(${varPath})`;\n\t} else {\n\t\tstatus.imports.add(\"t_child\");\n\t\tvarPath = `t_child(${varPath})`;\n\t}\n\tfor (let [i, child] of path.children.entries()) {\n\t\tif (i > 0) {\n\t\t\tif (child.type === \"text\" || child.type === \"space\") {\n\t\t\t\t// HACK: Using t_next_text just stops t_next(node, true) from\n\t\t\t\t// being converted into t_skip\n\t\t\t\tvarPath = `t_next_text(${varPath}, true)`;\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_next\");\n\t\t\t\tvarPath = `t_next(${varPath})`;\n\t\t\t}\n\t\t}\n\n\t\tif (i === path.children.length - 1 && child.children.length) {\n\t\t\t// Nested levels always use `t_child`, never the single-root\n\t\t\t// `t_root_el` — that's only for the top of the path.\n\t\t\tvarPath = getFragmentVarPathPart(child, varPath, status);\n\t\t}\n\t}\n\treturn varPath;\n}\n\nconst debug = false;\nfunction printDebug(varName: string, status: BuildStatus, b: Builder) {\n\tif (debug) {\n\t\tstatus.imports.add(\"t_print\");\n\t\tb.append(`console.log(\"${varName}:\", t_print(${varName}));`);\n\t}\n}\n\n/*\nfunction printPath(path: VariablePath) {\n\tlet parent = path;\n\twhile (parent.parent) {\n\t\tparent = parent.parent;\n\t}\n\tprintPathPart(parent);\n}\n\nfunction printPathPart(path: VariablePath, indent = 0) {\n\tconsole.log(`${\" \".repeat(indent * 2)}${path.type}`);\n\tfor (let child of path.children) {\n\t\tprintPathPart(child, indent + 1);\n\t}\n}\n*/\n","/**\n * Returns a bitmask of the for-loop variables whose substituted paths appear\n * in `expr`. Bit N is set when the Nth for-var (by position in `forVarNames`)\n * is read.\n *\n * After `replaceForVarNames` has run, every reference to a for-var in the\n * body has been rewritten to its data-bag path (e.g. `row` →\n * `t_item_42.data.row`, or `t_item_42.data` for single-var loops). This\n * helper scans the POST-substitution `expr` for those paths and returns a\n * bitmask — used to annotate each effect with `forVarMask` so the keyed-list\n * reconciler's no-proxy force-rerun path (`rerunRegionEffects`) can skip\n * effects that don't depend on the changed for-vars via a single bitwise AND.\n *\n * Conservative by design: a false positive (claiming a dependency that\n * doesn't really exist) just causes an unnecessary re-run, while a false\n * negative would drop a needed update. String literals that happen to\n * contain the substituted path are extremely unlikely and harmless.\n */\nexport default function forVarsReadIn(expr: string, forVarNames: string[][]): number {\n\tlet mask = 0;\n\tfor (let i = 0; i < forVarNames.length; i++) {\n\t\tconst subPath = forVarNames[i][1];\n\t\tif (subPath && expr.includes(subPath)) {\n\t\t\tmask |= 1 << i;\n\t\t}\n\t}\n\treturn mask;\n}\n","import { codeRanges } from \"../../utils/codeScanner\";\nimport type BuildStatus from \"./BuildStatus\";\n\n/**\n * Variables used within a for loop need to be retrieved from the loop data.\n */\nexport default function replaceForVarNames(value: string, status: BuildStatus): string {\n\t// HACK: If a value from a for loop is used in the function body,\n\t// get it from the loop data to trigger an update when it is changed\n\tif (status.forVarNames.length === 0) {\n\t\treturn value;\n\t}\n\n\t// Only rewrite code: the contents of string literals, regex literals and\n\t// comments are left alone, so that e.g. prose inside a template string is\n\t// not mangled. The contents of `${...}` interpolations inside template\n\t// strings are code again.\n\tlet result = \"\";\n\tlet index = 0;\n\tfor (let [start, end] of codeRanges(value)) {\n\t\tresult += value.substring(index, start);\n\t\tresult += replaceVarNames(value.substring(start, end), status);\n\t\tindex = end;\n\t}\n\tresult += value.substring(index);\n\treturn result;\n}\n\nfunction replaceVarNames(code: string, status: BuildStatus): string {\n\tfor (let varName of status.forVarNames) {\n\t\tcode = code.replaceAll(\n\t\t\tnew RegExp(\n\t\t\t\t// The boundary characters are the ones that can legitimately\n\t\t\t\t// precede/follow an identifier reference -- including `?` for\n\t\t\t\t// optional chaining (`item?.name`) and nullish coalescing\n\t\t\t\t// (`fallback ?? item`).\n\t\t\t\t`(^|\\\\s|\\\\(|\\\\[|\\\\{|!|\\\\?|\\\\.\\\\.\\\\.)${varName[0]}($|\\\\s|\\\\.|,|\\\\(|\\\\)|\\\\[|\\\\]|\\\\}|;|\\\\?)`,\n\t\t\t\t\"g\",\n\t\t\t),\n\t\t\t`$1${varName[1]}$2`,\n\t\t);\n\t}\n\treturn code;\n}\n","import Builder from \"../../utils/Builder\";\nimport forVarsReadIn from \"../../utils/forVarsReadIn\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildRun(\n\tfunctionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\taddPushDevBoundary(\"run\", functionName, status, b);\n\n\tlet forVarMask =\n\t\tstatus.forVarNames.length > 0 ? forVarsReadIn(functionBody, status.forVarNames) : undefined;\n\tlet trailing = \"\";\n\tif (status.options.dev === true) {\n\t\ttrailing = `, \"${functionName}\"`;\n\t\tif (forVarMask !== undefined) {\n\t\t\ttrailing += `, { forVarMask: ${forVarMask} }`;\n\t\t}\n\t} else if (forVarMask !== undefined) {\n\t\ttrailing = `, undefined, { forVarMask: ${forVarMask} }`;\n\t}\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(functionBody);\n\tb.append(`}${trailing});`);\n\n\taddPopDevBoundary(status, b);\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport { skipStringOrComment } from \"../../utils/codeScanner\";\nimport trimQuotes from \"../../utils/trimQuotes\";\n\nexport default function getAttributeOffsets(\n\tvalue: string,\n\tspan: SourceSpan,\n): {\n\tnewValue: string;\n\tspans: SourceSpan[];\n\toffsets: number[];\n\tlengths: number[];\n} {\n\t// Build offsets for interpolated values e.g. attribute=\"value {x}\n\t// and {y}\" should have offsets for where the x and y are\n\t// interpolated into the output\n\tvalue = trimQuotes(value);\n\tlet spans: SourceSpan[] = [];\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\n\tlet textContent = \"\";\n\tlet reactiveStart = 0;\n\tlet level = 0;\n\tfor (let i = 0; i < value.length; i++) {\n\t\tconst char = value[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\t//maxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\t//reactiveCount += 1;\n\t\t\t\ttextContent += \"${\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.push({ start: span.start + i + 2, end: -1 });\n\t\t\t\toffsets.push(reactiveStart + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\t// 2 is for the start quote plus the new `$`\n\t\t\t\tspans.at(-1)!.end = span.start + i + 2;\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \"}\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(value, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\t// Copy strings, template strings, comments and regex literals\n\t\t\t\t// into the output as-is\n\t\t\t\ttextContent += value.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += value[i];\n\t}\n\tvalue = `\\`${textContent}\\``;\n\n\treturn {\n\t\tnewValue: value,\n\t\tspans,\n\t\toffsets,\n\t\tlengths,\n\t};\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport bindingTarget from \"../../utils/bindingTarget\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addMappedTextWithOffsets from \"./addMappedTextWithOffsets\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\troot = false,\n): void {\n\tb.append(\"\");\n\tb.append(\"/* @component */\");\n\n\t// TODO: map params to props\n\n\t// Props\n\tconst componentHasProps = node.attributes.length || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// NOTE: The $props object is wrapped in a proxy so that components can\n\t\t// be updated if they refer to a $props.property in e.g. an element's\n\t\t// attribute\n\t\t// TODO: default props etc\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: {\n\t\t\tname: string;\n\t\t\t// Text to be ignored in the mapping e.g. `t_class(`\n\t\t\tpreText?: string;\n\t\t\tvalue: string;\n\t\t\t// Text to be ignored in the mapping e.g. `)`\n\t\t\tpostText?: string;\n\t\t\tspans: SourceSpan[];\n\t\t\toffsets?: number[];\n\t\t\tlengths?: number[];\n\t\t}[] = [];\n\t\tlet runs: string[] = [];\n\t\tlet bindingRuns: string[] = [];\n\n\t\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\t\tif (name === \"self\" && node.tagName === \"@component\") {\n\t\t\t\t// Ignore this special attribute\n\t\t\t} else if (value != null && fullyReactive) {\n\t\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\t\t// It's a bound property\n\t\t\t\t\t// Add two $runs -- one to update the props, and one to update the value\n\t\t\t\t\t// The component author will need to make sure $props.x is updated\n\t\t\t\t\t// TODO: Maybe allow adding a Bindable<T> type to the $props interface??\n\t\t\t\t\t// e.g. Component($props: { text: Bindable<string> })\n\t\t\t\t\tname = name.substring(1);\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t\tbindingRuns.push(bindingTarget(value, `${propsName}[\"${name}\"]`, name, status.imports));\n\t\t\t\t} else if (name === \"class\") {\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tvalue = `[${value}, \"torp-${status.styleHash}\"]`;\n\t\t\t\t\t}\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tspans: [span],\n\t\t\t\t\t});\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null && reactive) {\n\t\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\t\tvalue = newValue;\n\t\t\t\tif (name === \"class\") {\n\t\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\t\tvalue = `[${value}, \"torp-${status.styleHash}\"]`;\n\t\t\t\t\t}\n\t\t\t\t\tprops.push({ name, value, spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else if (name === \"style\") {\n\t\t\t\t\tprops.push({ name, value, spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t} else {\n\t\t\t\t\tprops.push({ name, value, spans, offsets, lengths });\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else if (value != null) {\n\t\t\t\tif (name === \"class\" && node.scopeStyles) {\n\t\t\t\t\tvalue = `\"${trimQuotes(value)} torp-${status.styleHash}\"`;\n\t\t\t\t}\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tvalue,\n\t\t\t\t\t// Set non-reactive props with `as const` so that typescript\n\t\t\t\t\t// won't complain when passing e.g. strings to string unions\n\t\t\t\t\tpostText: \" as const\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tprops.push({\n\t\t\t\t\tname,\n\t\t\t\t\tvalue: \"true\",\n\t\t\t\t\tspans: [span],\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`let ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\tp.preText ??= \"\";\n\t\t\tp.postText ??= \"\";\n\t\t\tif (p.spans.length === 1) {\n\t\t\t\taddMappedText(\n\t\t\t\t\tp.name ? `${p.name}: ` + p.preText : p.preText,\n\t\t\t\t\tvalue,\n\t\t\t\t\tp.postText + \",\",\n\t\t\t\t\tp.spans[0],\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\taddMappedTextWithOffsets(\n\t\t\t\t\tp.name ? `${p.name}: ` + p.preText : p.preText,\n\t\t\t\t\tvalue,\n\t\t\t\t\tp.postText + \",\",\n\t\t\t\t\tp.spans,\n\t\t\t\t\tp.offsets!,\n\t\t\t\t\tp.lengths!,\n\t\t\t\t\tstatus,\n\t\t\t\t\tb,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t\tif (bindingRuns.length) {\n\t\t\tbuildRun(\"setBindings\", replaceForVarNames(bindingRuns.join(\"\\n\"), status), status, b);\n\t\t}\n\n\t\t// PERF: Does this have much of an impact??\n\t\tif (root) {\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t$run(() => ${propsName}[name] = $props[name]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, SlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && (slot.tagName === \"fill\" || slot.tagName === \"filldef\")) {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\t\"$sparent: ParentNode\",\n\t\t\t\t\t\"$sanchor: Node | null\",\n\t\t\t\t\t// NOTE: The $slot param is only declared with its real name\n\t\t\t\t\t// when the fill reads it (hasSlotProps), otherwise it would\n\t\t\t\t\t// be reported as unused\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$slot: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"_$slot?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n// eslint-disable-next-line no-unused-vars\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\t// NOTE: The @ts-ignore suppresses the assignability error from\n\t\t\t\t// the required $slot param, which is not compatible with the\n\t\t\t\t// optional $slot param of the SlotRender type\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\n\t\t\t\tbuildFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tstatus.fragmentStack.push({\n\t\t\t\t\tfragment: slot.fragment,\n\t\t\t\t\tpath: \"\",\n\t\t\t\t});\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildNode(child, status, b, \"$sparent\", \"$sanchor\");\n\t\t\t\t}\n\t\t\t\tstatus.fragmentStack.pop();\n\n\t\t\t\tbuildAddFragment(slot, status, b, \"$sparent\", \"$sanchor\");\n\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Render the component\n\tconst compParentName = node.parentName;\n\tconst compAnchorName = node.varName;\n\tlet renderParams = `${compParentName}, ${compAnchorName}, ${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// TODO: Map the params properly, either by checking for things ourselves,\n\t// or better checking for $props being undefined in components\n\t//addMappedText(\"\", componentName, `(${renderParams});`, node.span, status, b);\n\taddMappedText(\"\", `${componentName}(${renderParams})`, \";\", node.span, status, b);\n\n\tb.append(\"\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\n\nexport default function buildAwaitNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"await_region\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\tconst awaitBranch = branches.find((n) => n.operation === \"@await\");\n\tconst withBranch = branches.find((n) => n.operation === \"@with\");\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_await\");\n\n\tb.append(\"\");\n\tb.append(\"/* @await */\");\n\n\taddPushDevBoundary(\"control\", \"@await\", status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"await\"` : \"\"});\n\t\tt_run_await(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\t// Content branch children\n\tif (awaitBranch !== undefined && awaitBranch.children.length > 0) {\n\t\tbuildFragment(awaitBranch, status, b, parentName, \"t_before\");\n\t\tstatus.fragmentStack.push({ fragment: awaitBranch.fragment, path: \"\" });\n\t\tfor (let child of awaitBranch.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\t\tbuildAddFragment(awaitBranch, status, b, parentName, \"t_before\");\n\t}\n\n\t// Close content callback; open with-branch (or pass null)\n\tif (withBranch !== undefined) {\n\t\tb.append(`}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\t\tif (withBranch.children.length > 0) {\n\t\t\tbuildFragment(withBranch, status, b, parentName, \"t_before\");\n\t\t\tstatus.fragmentStack.push({ fragment: withBranch.fragment, path: \"\" });\n\t\t\tfor (let child of withBranch.children) {\n\t\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t\t}\n\t\t\tstatus.fragmentStack.pop();\n\t\t\tbuildAddFragment(withBranch, status, b, parentName, \"t_before\");\n\t\t}\n\t\tb.append(`}${status.options.dev === true ? `, \"runAwait\"` : \"\"});`);\n\t} else {\n\t\tb.append(`}, null${status.options.dev === true ? `, \"runAwait\"` : \"\"});`);\n\t}\n\n\taddPopDevBoundary(status, b);\n\tb.append(\"\");\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isControlNode from \"./isControlNode\";\nimport { NON_RENDERING_OPERATIONS } from \"./nonRenderingOperations\";\n\n/**\n * Returns true if any descendant of a `@for` body is a control node that\n * creates its own region and effects (`@if`, `@for`, `@await`, `@switch`,\n * `@replace`, `@html`).\n *\n * Operations that produce no DOM and no region (`@key`, `@const`, `@console`,\n * `@debugger`, `@function`) are fine — same category as `@key`. They are\n * descended through, so a real control statement nested under a `@key` (a\n * common shape — `@for` bodies almost always lead with `@key = ...`) is still\n * detected.\n *\n * Extracted from `isForBodyNoProxySafe` so the no-proxy specialization, the\n * leaf-row region-chain specialization (`isForBodyLeafSafe`), and any future\n * pass that needs the same structural predicate can share one source of\n * truth.\n */\nexport default function hasNestedControl(children: TemplateNode[]): boolean {\n\tfor (const child of children) {\n\t\tif (isControlNode(child)) {\n\t\t\tif (!NON_RENDERING_OPERATIONS.has(child.operation)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t// A non-rendering control node (e.g. `@key`) wraps the actual\n\t\t\t// body content; keep descending so we still detect a real\n\t\t\t// control statement nested under it.\n\t\t\tif (hasNestedControl(child.children)) return true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isElementLike(child)) {\n\t\t\tif (hasNestedControl(child.children)) return true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction isElementLike(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\" || node.type === \"component\" || node.type === \"special\";\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport hasNestedControl from \"./hasNestedControl\";\n\n/**\n * Returns true if the body of a `@for` loop contains no nested control\n * statements (`@if`, `@for`, `@await`, `@switch`, `@replace`, `@html`).\n *\n * When true, every effect created by the row template lives directly on the\n * item's own region — never on a descendant region chained off it. The\n * compiler can then emit a \"leaf-row\" `createListItem` that skips the\n * per-item `pushRegion(item)` / `popRegion(oldRegion)` calls: `runListItems`\n * has already pushed the item onto the active region (via\n * `pushRegion(item, true)`) before calling `create()`, and a leaf body never\n * creates descendant regions, so `context.activeRegion` stays put at the item\n * for the whole callback. Saves two function calls per row plus the\n * `devContext.onRegionPushed` / `onRegionPopped` invocations, which on the\n * 10k-row js-framework-bench `runlots` op is 20000 fewer calls per pass.\n *\n * Note: every no-proxy-safe body is also leaf-safe (`isForBodyNoProxySafe`\n * includes `hasNestedControl`), but the converse is not true — a body that\n * writes to a for-var (disqualifying it from no-proxy) can still be leaf-safe\n * and earn this specialization.\n */\nexport default function isForBodyLeafSafe(forBodyChildren: TemplateNode[]): boolean {\n\treturn !hasNestedControl(forBodyChildren);\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport hasNestedControl from \"./hasNestedControl\";\nimport isControlNode from \"./isControlNode\";\nimport isTextNode from \"./isTextNode\";\n\n/**\n * Returns true if the body of a `@for` loop never writes to any of its loop\n * variables (`forVars`) — neither directly (`row = ...`, `row.x = ...`,\n * `row[k] = ...`) nor via compound assignment (`+=`, `++`, etc.) — AND the\n * body contains no nested control statements (`@if`, `@for`, `@await`, …).\n *\n * When both hold, the compiler can emit a \"no-proxy\" `@for` specialization\n * that skips the per-item shallow `$watch` Proxy around the loop variable\n * bag: reads of `data.<forVar>` are plain property accesses (no proxyGet\n * trap), and the compiler-emitted `updateListItem` callback re-runs item\n * effects manually (via `t_rerun_region_effects`) when a forVar's reference\n * actually changes.\n *\n * The \"no nested controls\" constraint keeps the manual effect re-run sound:\n * without it, a nested `@if`'s effects would live on a descendant region\n * chained off the original item, but after keyed reconciliation that chain\n * is orphaned (the live item is a different object), so the re-run walk\n * couldn't find them. With no nested controls every row effect is on the\n * item itself, which is exactly what `t_rerun_region_effects` walks.\n *\n * Detection is intentionally conservative: a regex scan over every\n * expression-like string in the body (text interpolation, attribute values,\n * event handlers, control statements). Anything ambiguous falls back to the\n * proxy path. The for-statement itself (`for (let row of ...)`) is NOT\n * scanned — that's the loop header, not the body — so `for (...; i++)` style\n * loops with `i++` in the header are still eligible.\n */\nexport default function isForBodyNoProxySafe(\n\tforBodyChildren: TemplateNode[],\n\tforVars: string[],\n): boolean {\n\tif (forVars.length === 0) return false;\n\tif (hasNestedControl(forBodyChildren)) return false;\n\n\tconst collected: string[] = [];\n\tfor (const child of forBodyChildren) {\n\t\tcollectExpressionStrings(child, collected);\n\t}\n\n\t// One alternation per for-var; the alternation covers direct / property /\n\t// index writes plus prefix/postfix updates. `=(?![=>])` distinguishes `=`\n\t// from `==` / `===` / `=>`.\n\t//\n\t// The destructuring alternatives (`[forVar] =`, `{forVar} =`,\n\t// `{forVar: ...} =`) all require an `=` *after* the closing bracket /\n\t// brace: without that anchor they'd false-positive on torpor's own text\n\t// interpolation syntax (`<p>{forVar}</p>`) and on regular indexed-read\n\t// expressions (`arr[forVar]`).\n\tfor (const varName of forVars) {\n\t\tconst escaped = varName.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\tconst writePattern = new RegExp(\n\t\t\t// `[forVar] =` or `{forVar} =` or `{forVar: ...} =` — array / object\n\t\t\t// destructuring assignment targets. The trailing `=` is required so\n\t\t\t// we don't match `{forVar}` text interpolations or `arr[forVar]`\n\t\t\t// indexed reads.\n\t\t\t`\\\\[\\\\s*${escaped}\\\\s*\\\\]\\\\s*=(?![=>])|` +\n\t\t\t\t`\\\\{\\\\s*${escaped}\\\\s*(:[^}]+)?\\\\}\\\\s*=(?![=>])|` +\n\t\t\t\t// forVar or forVar.prop or forVar[key], optionally followed by\n\t\t\t\t// an assignment / compound-assignment / update operator\n\t\t\t\t`\\\\b${escaped}(?:\\\\.[a-zA-Z_$][\\\\w$]*|\\\\[[^\\\\]]+\\\\])?\\\\s*(?:=(?![=>])|[+\\\\-*/%&|^]=|\\\\+\\\\+|--)|` +\n\t\t\t\t// prefix ++/--\n\t\t\t\t`(?:\\\\+\\\\+|--)\\\\s*${escaped}\\\\b`,\n\t\t);\n\t\tfor (const text of collected) {\n\t\t\tif (writePattern.test(text)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction isElementLike(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"element\" || node.type === \"component\" || node.type === \"special\";\n}\n\nfunction collectExpressionStrings(node: TemplateNode, out: string[]): void {\n\tif (isTextNode(node)) {\n\t\tout.push(node.content);\n\t\treturn;\n\t}\n\tif (isElementLike(node)) {\n\t\t// Attribute names + values cover static attrs, reactive class/style\n\t\t// bindings, and event handlers (`onclick={() => select(row)}`).\n\t\tfor (const attr of node.attributes) {\n\t\t\tif (attr.value !== undefined) {\n\t\t\t\tif (attr.name.startsWith(\"&\")) {\n\t\t\t\t\t// Two-way bindings (`&value={i}`, `&checked={x}`,\n\t\t\t\t\t// `&group={g}`, `&foo={bar}` on components) emit\n\t\t\t\t\t// `${value} = …` assignment handlers, so the value\n\t\t\t\t\t// expression is a *write* target, not just a read.\n\t\t\t\t\t// Appending ` =` lets the regex flag any for-var that\n\t\t\t\t\t// appears in it as assigned.\n\t\t\t\t\tout.push(`${attr.value} =`);\n\t\t\t\t} else {\n\t\t\t\t\tout.push(attr.value);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fully-reactive attribute spreads / dynamic attribute names are\n\t\t\t// emitted verbatim too — the value carries the expression.\n\t\t\tif (attr.fullyReactive && attr.name !== attr.value) {\n\t\t\t\tout.push(attr.name);\n\t\t\t}\n\t\t}\n\t\tfor (const child of node.children) {\n\t\t\tcollectExpressionStrings(child, out);\n\t\t}\n\t\treturn;\n\t}\n\tif (isControlNode(node)) {\n\t\t// `@key = row.id` is a *read* of `row.id`; we still scan the\n\t\t// statement because the key expression is the most common place a\n\t\t// for-var shows up, and reads are correctly ignored by the regex\n\t\t// (no assignment operator follows). For nested `@if`/`@for`/etc.,\n\t\t// the statement may also read for-vars.\n\t\tout.push(node.statement);\n\t\tfor (const child of node.children) {\n\t\t\tcollectExpressionStrings(child, out);\n\t\t}\n\t}\n}\n","/**\n * Trims chars from the start and end of the supplied text when both the start and end match\n *\n * @param text The text to trim\n *\n * @returns The text without the chars at the start or the end\n */\nexport default function trimMatched(text: string, startChar: string, endChar: string): string {\n\tlet start = 0;\n\tlet end = text.length;\n\twhile (text[start] === startChar && text[end - 1] === endChar) {\n\t\tstart += 1;\n\t\tend -= 1;\n\t}\n\treturn text.substring(start, end);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport isForBodyLeafSafe from \"../../utils/isForBodyLeafSafe\";\nimport isForBodyNoProxySafe from \"../../utils/isForBodyNoProxySafe\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nconst forLoopRegex = /for\\s*\\((.+?);.*?;.*?\\)/;\nconst forLoopVarsRegex = /(?:let\\s+|var\\s+){0,1}([^\\s,;+=]+)(?:\\s*=\\s*[^,;]+){0,1}/g;\nconst forOfRegex = /for\\s*\\(\\s*(?:let\\s*|var\\s*){0,1}(.+?)\\s+(?:of|in).*?\\)/;\n\nexport default function buildForNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst parentName = node.parentName!;\n\tconst anchorName = node.varName ?? \"null\";\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\t// HACK: Need to wrangle the declaration(s) out of the for loop and put them in data\n\t// TODO: Handle destructuring, quotes, comments etc\n\tconst forVarNames: string[] = [];\n\tconst forLoopMatch = node.statement.match(forLoopRegex);\n\tif (forLoopMatch) {\n\t\tconst forVarMatches = forLoopMatch[1].matchAll(forLoopVarsRegex);\n\t\tfor (let match of forVarMatches) {\n\t\t\tforVarNames.push(match[1]);\n\t\t}\n\t} else {\n\t\tconst forOfMatch = node.statement.match(forOfRegex);\n\t\tif (forOfMatch) {\n\t\t\tconst match = forOfMatch[1];\n\t\t\tif (\n\t\t\t\t(match.startsWith(\"{\") && match.endsWith(\"}\")) ||\n\t\t\t\t(match.startsWith(\"[\") && match.endsWith(\"]\"))\n\t\t\t) {\n\t\t\t\tforVarNames.push(\n\t\t\t\t\t...trimMatched(trimMatched(match, \"{\", \"}\"), \"[\", \"]\")\n\t\t\t\t\t\t.split(\",\")\n\t\t\t\t\t\t.map((m) => m.trim()),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tforVarNames.push(match);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst regionName = nextVarName(\"for_region\", status);\n\tconst listItemsName = nextVarName(\"new_items\", status);\n\tconst itemName = nextVarName(\"item\", status);\n\tconst beforeName = nextVarName(\"before\", status);\n\n\t// Get the key node if it's been set\n\tlet keyStatement = \"\";\n\tconst key = node.children.find(\n\t\t(n) => n.type === \"control\" && (n as ControlNode).operation === \"@key\",\n\t) as ControlNode;\n\tif (key !== undefined) {\n\t\tlet matches = key.statement.match(/^(\\s*@*key\\s*=\\s*)(.+?)\\s*;*\\s*$/);\n\t\tif (matches) {\n\t\t\tkey.span.start += matches[1].length;\n\t\t\tkeyStatement = matches[2];\n\t\t}\n\t}\n\n\t// Detect \"no-proxy safe\" @for body: when none of the for-vars are ever\n\t// written inside the body, the per-item data bag doesn't need to be\n\t// wrapped in a shallow `$watch` Proxy. The compiler-emitted updateListItem\n\t// then compares each forVar's reference and re-runs the item's effects\n\t// manually (via t_rerun_region_effects) when one has actually changed.\n\t// Skips a Proxy + ProxyData + signals Map allocation per created row, and\n\t// a proxyGet trap per property read during every row effect run.\n\tconst noWatch = isForBodyNoProxySafe(node.children, forVarNames);\n\tif (noWatch) {\n\t\tstatus.imports.add(\"t_rerun_region_effects\");\n\t}\n\n\t// Single-loop-var specialization of the no-proxy path: when the body\n\t// binds exactly one loop variable, the per-row spec can store it\n\t// directly (`data: row`) instead of wrapping it (`data: { row }`). This\n\t// drops one object allocation per row on EVERY list update — a\n\t// `removeFirst` click on a 1000-row list allocates 999 `{ row }`\n\t// wrappers today, all to be GC'd moments later — and turns the\n\t// `updateListItem` per-field compare into a single reference check. The\n\t// body's loop-var access flips from `item.data.<var>.x` to\n\t// `item.data.x` (the substitution below maps `<var>` → `item.data`\n\t// rather than `item.data.<var>`).\n\tconst singleVar = noWatch && forVarNames.length === 1;\n\n\t// Detect \"leaf-row safe\" @for body: when the body has no nested control\n\t// statements (`@if`/`@for`/`@await`/…), the create callback can skip its\n\t// `pushRegion(item)` / `popRegion(oldRegion)` calls. `runListItems` has\n\t// already pushed the item onto the active region before calling\n\t// `create()`, and a leaf body never creates descendant regions that\n\t// would shift `context.activeRegion` away from the item — so the\n\t// push/pop in the callback is purely redundant. Saves two function calls\n\t// per row plus the `devContext.onRegionPushed`/`onRegionPopped`\n\t// invocations (~20000 calls saved on a 10k-row `runlots`).\n\t//\n\t// Every no-proxy-safe body is also leaf-safe (`isForBodyNoProxySafe`\n\t// gates on the same nested-control check), but the converse is not true\n\t// — a body that writes to a for-var can still be leaf-safe — so this is\n\t// an independent check.\n\tconst leafRow = isForBodyLeafSafe(node.children);\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_list\");\n\tstatus.imports.add(\"ListItemSpec\");\n\n\tb.append(\"\");\n\tb.append(\"/* @for */\");\n\taddPushDevBoundary(\"control\", `@${node.statement}`, status, b);\n\tb.append(`\n\t\tlet ${regionName} = t_region(${status.options.dev === true ? `\"for\"` : \"\"});\n\t\tt_run_list(\n\t\t${regionName},\n\t\t${parentName},\n\t\t${anchorName},\n\t\t${status.options.dev === true ? \"function createNewItems() {\" : \"() => {\"}\n\t\t\tlet ${listItemsName}: ListItemSpec[] = [];`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\t// Push a lightweight {key, data} spec per row. The reconciler reuses old\n\t// ListItems for survivors and only mounts fresh ones for genuinely new\n\t// keys, so a survivor costs only this 2-field allocation per update — no\n\t// full ListItem, no effects migration, no per-row chain re-link. When the\n\t// body is no-proxy safe and binds a single loop var, store it directly\n\t// (`data: row`) rather than wrapping it (`data: { row }`) so we skip the\n\t// per-row wrapper-object allocation entirely.\n\tif (singleVar) {\n\t\tb.append(`${listItemsName}.push({ data: ${forVarNames[0]}, key: `);\n\t} else {\n\t\tb.append(`${listItemsName}.push({ data: { ${forVarNames.join(\", \")} }, key: `);\n\t}\n\tif (key !== undefined) {\n\t\taddMappedText(\"\", `${keyStatement || \"undefined\"}`, \" });\", key.span, status, b);\n\t} else {\n\t\tb.append(`undefined });`);\n\t}\n\tb.append(`}`);\n\tb.append(`return ${listItemsName};`);\n\tb.append(`},\n\t\t${status.options.dev === true ? `function createListItem(${itemName}, ${beforeName}) {` : `(${itemName}, ${beforeName}) => {`}`);\n\n\tlet oldForVarNames = status.forVarNames;\n\t// The bit base for this loop's for-vars in `forVarMask`. Outer for-loops\n\t// (if any) occupy lower bit positions in `status.forVarNames`; this\n\t// loop's vars start at `oldForVarNames.length`. Captured before the body\n\t// is built so `forVarsReadIn` and `t_changed_mask` use the same index\n\t// space.\n\tconst forVarBitBase = oldForVarNames.length;\n\tstatus.forVarNames = [\n\t\t...status.forVarNames,\n\t\t// singleVar stores the loop var directly as `data`, so the body\n\t\t// reads it as `item.data.<x>`; otherwise it's wrapped as\n\t\t// `data: { <var> }` and the body reads `item.data.<var>.<x>`.\n\t\t...(singleVar\n\t\t\t? forVarNames.map((v) => [v, `${itemName}.data`])\n\t\t\t: forVarNames.map((v) => [v, `${itemName}.data.${v}`])),\n\t];\n\tbuildForItem(node, status, b, parentName, beforeName, itemName, leafRow);\n\tstatus.forVarNames = oldForVarNames;\n\n\tb.append(`},\n${status.options.dev === true ? \"function updateListItem(t_old_item, t_new_item) {\" : \"(t_old_item, t_new_item) => {\"}`);\n\tif (noWatch) {\n\t\t// Compare each forVar's reference. Only when one has actually changed\n\t\t// do we copy it across and re-run the item's effects. Unchanged rows\n\t\t// (the common case during a partial `update`) cost only the\n\t\t// reference-equality check — no allocation, no effect re-run.\n\t\t// singleVar collapses this to a single `data` reference check (the\n\t\t// loop var IS the data bag, no per-field walk).\n\t\t//\n\t\t// We OR the changed for-var positions into `t_changed_mask` (a\n\t\t// bitmask). Bit positions are offset by `forVarBitBase` to match\n\t\t// the indices `forVarsReadIn` used when annotating effects (which\n\t\t// iterates over the full `status.forVarNames`, including outer\n\t\t// loops). `t_rerun_region_effects` then uses each effect's\n\t\t// `forVarMask & changedMask` to skip unrelated effects.\n\t\tb.append(`let t_changed_mask = 0;`);\n\t\tif (singleVar) {\n\t\t\tconst bit = 1 << forVarBitBase;\n\t\t\tb.append(\n\t\t\t\t`if (t_old_item.data !== t_new_item.data) {\n\t\t\t\t\tt_old_item.data = t_new_item.data;\n\t\t\t\t\tt_changed_mask = ${bit};\n\t\t\t\t}`,\n\t\t\t);\n\t\t} else {\n\t\t\tfor (let i = 0; i < forVarNames.length; i++) {\n\t\t\t\tconst varName = forVarNames[i];\n\t\t\t\tconst bit = 1 << (forVarBitBase + i);\n\t\t\t\tb.append(\n\t\t\t\t\t`if (t_old_item.data.${varName} !== t_new_item.data.${varName}) {\n\t\t\t\t\t\tt_old_item.data.${varName} = t_new_item.data.${varName};\n\t\t\t\t\t\tt_changed_mask |= ${bit};\n\t\t\t\t\t}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tb.append(`if (t_changed_mask) t_rerun_region_effects(t_old_item, t_changed_mask);`);\n\t} else {\n\t\tfor (let varName of forVarNames) {\n\t\t\tb.append(`t_old_item.data.${varName} = t_new_item.data.${varName};`);\n\t\t}\n\t}\n\tb.append(`}${noWatch ? \",\\ntrue\" : \"\"}\\n);`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildForItem(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tbeforeName: string,\n\titemName: string,\n\tleafRow: boolean,\n) {\n\tconst oldRegionName = nextVarName(\"old_region\", status);\n\n\t// Leaf-row specialization: skip the per-item `pushRegion(item)` /\n\t// `popRegion(oldRegion)` calls. `runListItems` has already pushed the\n\t// item onto the active region (via `pushRegion(item, true)`) before\n\t// calling `create()`, and the leaf body never creates descendant regions\n\t// that would shift `context.activeRegion` away from the item — so the\n\t// push/pop here is purely redundant. The effect created by the body's\n\t// `$run` still lands on the right region (`context.activeRegion.effects`\n\t// === `item.effects`), and the chain bookkeeping in `runListItems`\n\t// (which uses `context.previousRegion` to link siblings) is unaffected.\n\tif (!leafRow) {\n\t\tstatus.imports.add(\"t_push_region\");\n\t\tb.append(`let ${oldRegionName} = t_push_region(${itemName});`);\n\t}\n\n\tbuildFragment(node, status, b, parentName, beforeName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment!,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tif (isControlNode(child) && child.operation === \"@key\") {\n\t\t\tcontinue;\n\t\t}\n\t\tbuildNode(child, status, b, parentName, beforeName);\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, beforeName);\n\n\tif (!leafRow) {\n\t\tstatus.imports.add(\"t_pop_region\");\n\t\tb.append(`t_pop_region(${oldRegionName});`);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildHtmlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst htmlAnchorName = node.varName!;\n\tconst htmlParentName = node.parentName || htmlAnchorName + \".parentNode\";\n\n\t// HACK: I'm not actually sure we need this here (or in @replace, where I copied it from)\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\n\tconst firstNodeVar = nextVarName(\"html_first\", status);\n\tconst lastNodeVar = nextVarName(\"html_last\", status);\n\n\tb.append(\"\");\n\tb.append(`/* @html */`);\n\tb.append(`let ${firstNodeVar}: ChildNode | null = null;`);\n\tb.append(`let ${lastNodeVar}: ChildNode | null = null;`);\n\tb.append(`t_run_control(t_region(), ${htmlAnchorName}, (t_before) => {`);\n\n\t// Read the html expression (for reactivity tracking)\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\n\t// Clear previously rendered content\n\tb.append(`if (${firstNodeVar} !== null && ${lastNodeVar} !== null) {`);\n\tb.append(`let t_node: ChildNode | null = ${lastNodeVar};`);\n\tb.append(`while (t_node !== null && t_node !== ${firstNodeVar}) {`);\n\tb.append(`const t_prev: ChildNode | null = t_node.previousSibling;`);\n\tb.append(`t_node.remove();`);\n\tb.append(`t_node = t_prev;`);\n\tb.append(`}`);\n\tb.append(`if (${firstNodeVar}) ${firstNodeVar}.remove();`);\n\tb.append(`${firstNodeVar} = ${lastNodeVar} = null;`);\n\tb.append(`}`);\n\n\tconst templateName = nextVarName(\"template\", status);\n\tconst fragmentName = `t_fragment_${node.fragment!.number}`;\n\tb.append(`let ${templateName} = document.createElement(\"template\");`);\n\t// TODO: replaceForVarNames is going to throw mapping out\n\tnode.span.start += \"html(\".length;\n\tnode.span.end -= 2;\n\taddMappedText(\n\t\t\"\",\n\t\t`${templateName}.innerHTML = ${replaceForVarNames(node.statement, status)};`,\n\t\t\"\",\n\t\tnode.span,\n\t\tstatus,\n\t\tb,\n\t);\n\tb.append(`let ${fragmentName} = ${templateName}.content.cloneNode(true) as DocumentFragment;`);\n\tb.append(`${firstNodeVar} = ${fragmentName}.firstChild;`);\n\tb.append(`${lastNodeVar} = ${fragmentName}.lastChild;`);\n\n\tbuildAddFragment(node, status, b, htmlParentName, \"t_before\");\n\n\t// During hydration the fragment isn't inserted, so adopt the existing\n\t// server-rendered nodes from the DOM instead\n\tstatus.imports.add(\"t_first_inside\");\n\tb.append(`if (${firstNodeVar} !== null && ${firstNodeVar}.parentNode !== ${htmlParentName}) {`);\n\tb.append(`${lastNodeVar} = ${htmlAnchorName}.previousSibling as ChildNode | null;`);\n\tb.append(`if (${lastNodeVar} !== null) {`);\n\tb.append(`const t_stashed_first = t_first_inside(${htmlAnchorName} as ChildNode);`);\n\t// The first node inside the hydration block is stashed by `t_anchor`\n\t// (`nodeAnchor`) when it strips the hydration markers. Scanning backwards\n\t// is only a fallback, as content can contain whitespace text nodes that\n\t// would truncate the region.\n\tb.append(`if (t_stashed_first !== undefined && t_stashed_first !== null) {`);\n\tb.append(`${firstNodeVar} = t_stashed_first;`);\n\tb.append(`} else {`);\n\tb.append(`${firstNodeVar} = ${lastNodeVar};`);\n\tb.append(`let t_scan: ChildNode | null = ${lastNodeVar};`);\n\tb.append(\n\t\t`while (t_scan !== null && t_scan.previousSibling !== null && t_scan.previousSibling !== ${htmlAnchorName} && (t_scan.previousSibling.nodeType !== 3 || (t_scan.previousSibling.textContent ?? \"\").trim() !== \"\")) {`,\n\t);\n\tb.append(`t_scan = t_scan.previousSibling;`);\n\tb.append(`}`);\n\tb.append(`${firstNodeVar} = t_scan;`);\n\tb.append(`}`);\n\tb.append(`}`);\n\tb.append(`}`);\n\n\tb.append(`}${status.options.dev === true ? ', \"html\"' : \"\"});`);\n\tb.append(\"\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: Are there too many branches for ifs etc?\n\nexport default function buildIfNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"if_region\", status);\n\tconst indexName = nextVarName(\"if_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add an else branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@else\") === -1) {\n\t\tconst elseBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@else\",\n\t\t\tstatement: \"else\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(elseBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @if */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"if\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildIfBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\n\tb.append(`}${status.options.dev === true ? `, \"runIf\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildIfBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"if_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`${indexName} = ${index};`);\n\tb.append(\"}\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\n// TODO: type checking\n\nexport default function buildReplaceNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst replaceAnchorName = node.varName!;\n\tconst replaceParentName = node.parentName || replaceAnchorName + \".parentNode\";\n\tconst replaceRegionName = nextVarName(\"replace_region\", status);\n\n\t// HACK:\n\tnode = node.children[0] as ControlNode;\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(`\n\t/* @replace */\n\tconst ${replaceRegionName} = t_region(${status.options.dev === true ? `\"replace\"` : \"\"});\n\tt_run_control(${replaceRegionName}, ${replaceAnchorName}, (t_before) => {`);\n\n\tbuildReplaceBranch(node, status, b, replaceParentName, replaceRegionName);\n\n\tb.append(`}${status.options.dev === true ? ', \"replace\"' : \"\"});`);\n\tb.append(\"\");\n}\n\nfunction buildReplaceBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n) {\n\tstatus.imports.add(\"t_run_branch\");\n\n\tb.append(`${replaceForVarNames(node.statement, status)};`);\n\tb.append(`if (!t_run_branch(${regionName}, 0, -1)) return;`);\n\n\tb.append(`\n\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"replace_branch\"` : \"\"});\n\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t`);\n\n\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"\",\n\t});\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t}\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\tb.append(\"t_pop_region(t_old_region);\");\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\n\nexport default function buildScriptNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tb.append(`/* ${node.operation} */`);\n\taddMappedText(\"\", `${maybeAppend(node.statement, \";\")}`, \"\", node.span, status, b);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSwitchNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName!;\n\tconst regionName = nextVarName(\"switch_region\", status);\n\tconst indexName = nextVarName(\"switch_index\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\t// Add a default branch if there isn't one, so that the content will be cleared if no branches match\n\tif (branches.findIndex((n) => n.operation === \"@default\") === -1) {\n\t\tconst defaultBranch: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@default\",\n\t\t\tstatement: \"default:\",\n\t\t\tchildren: [],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tbranches.push(defaultBranch);\n\t}\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_control\");\n\tstatus.imports.add(\"t_run_branch\");\n\tstatus.imports.add(\"t_push_region\");\n\tstatus.imports.add(\"t_pop_region\");\n\n\tb.append(\"\");\n\tb.append(\"/* @switch */\");\n\n\taddPushDevBoundary(\"control\", `@${branches[0].statement}`, status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"switch\"` : \"\"});\n\t\tlet ${indexName} = -1;\n\t\tt_run_control(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tlet index = 0;\n\tfor (let branch of branches) {\n\t\tbuildSwitchBranch(branch, status, b, parentName, regionName, indexName, index++);\n\t}\n\tb.append(`\n\t\t}\n\t}${status.options.dev === true ? `, \"runSwitch\"` : \"\"});`);\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildSwitchBranch(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tregionName: string,\n\tindexName: string,\n\tindex: number,\n) {\n\t// TODO: replaceForVarNames is going to throw mapping out\n\taddMappedText(\"\", `${replaceForVarNames(node.statement, status)}`, \" {\", node.span, status, b);\n\n\tb.append(`if (!t_run_branch(${regionName}, ${indexName}, ${index})) return;`);\n\n\tif (node.children.length > 0) {\n\t\tb.append(`\n\t\t\tconst t_new_region = t_region(${status.options.dev === true ? `\"switch_branch\"` : \"\"});\n\t\t\tconst t_old_region = t_push_region(t_new_region, true);\n\t\t`);\n\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\n\t\tb.append(\"t_pop_region(t_old_region);\");\n\t}\n\n\tb.append(`\n\t\t\t${indexName} = ${index};\n\t\t\tbreak;\n\t\t}`);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildTryNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tconst anchorName = node.varName ?? \"null\";\n\tconst parentName = node.parentName || anchorName + \".parentNode\";\n\tconst regionName = nextVarName(\"try_region\", status);\n\n\t// Filter non-control branches (spaces)\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\n\tconst tryBranch = branches.find((n) => n.operation === \"@try\")!;\n\tconst catchBranch = branches.find((n) => n.operation === \"@catch\");\n\n\tstatus.imports.add(\"t_region\");\n\tstatus.imports.add(\"t_run_try\");\n\n\tb.append(\"\");\n\tb.append(\"/* @try */\");\n\n\taddPushDevBoundary(\"control\", \"@try\", status, b);\n\n\tb.append(`\n\t\tconst ${regionName} = t_region(${status.options.dev === true ? `\"try\"` : \"\"});\n\t\tt_run_try(${regionName}, ${anchorName}, (${status.inHead ? \"\" : \"t_before\"}) => {`);\n\n\tbuildTryBranchBody(tryBranch, status, b, parentName);\n\n\t// Close the try callback; open the catch callback (or pass null). The\n\t// catch variable becomes the callback's second parameter\n\tconst catchVar = catchBranch\n\t\t? trimMatched(catchBranch.statement.substring(\"catch\".length).trim(), \"(\", \")\") || \"err\"\n\t\t: null;\n\tif (catchBranch && catchVar) {\n\t\taddMappedText(\n\t\t\t\"},\",\n\t\t\t`(${status.inHead ? \"\" : \"t_before\"}, ${replaceForVarNames(catchVar, status)}) => {`,\n\t\t\t\"\",\n\t\t\tcatchBranch.span,\n\t\t\tstatus,\n\t\t\tb,\n\t\t);\n\t\tbuildTryBranchBody(catchBranch, status, b, parentName);\n\t\tb.append(`}${status.options.dev === true ? `, \"runTry\"` : \"\"});`);\n\t} else {\n\t\t// No catch branch: errors propagate up to the nearest boundary\n\t\tb.append(`}, null${status.options.dev === true ? `, \"runTry\"` : \"\"});`);\n\t}\n\n\taddPopDevBoundary(status, b);\n\n\tb.append(\"\");\n}\n\nfunction buildTryBranchBody(\n\tnode: ControlNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n): void {\n\t// NOTE: no region push here — the branch region is pushed by `runTry`'s\n\t// `renderBranch` (the same shape as `@await` branches), so that the\n\t// branch's node window and effects land on the region that\n\t// `runControlBranch` clears\n\tif (node.children.length > 0) {\n\t\tbuildFragment(node, status, b, parentName, \"t_before\");\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: node.fragment,\n\t\t\tpath: \"\",\n\t\t});\n\t\tfor (let child of node.children) {\n\t\t\tbuildNode(child, status, b, parentName, \"t_before\");\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(node, status, b, parentName, \"t_before\");\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAwaitNode from \"./buildAwaitNode\";\nimport buildForNode from \"./buildForNode\";\nimport buildHtmlNode from \"./buildHtmlNode\";\nimport buildIfNode from \"./buildIfNode\";\nimport buildReplaceNode from \"./buildReplaceNode\";\nimport buildScriptNode from \"./buildScriptNode\";\nimport buildSwitchNode from \"./buildSwitchNode\";\nimport buildTryNode from \"./buildTryNode\";\n\nexport default function buildControlNode(node: ControlNode, status: BuildStatus, b: Builder): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@with\":\n\t\tcase \"@try\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group or @try group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@try group\": {\n\t\t\tbuildTryNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildHtmlNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\":\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tb.append(\"\");\n\t\t\tbuildScriptNode(node, status, b);\n\t\t\tb.append(\"\");\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","/**\n * Trims a char from the end of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the end of the text\n *\n * @returns The text without the char on the end\n */\nexport default function trimEnd(text: string, char: string): string {\n\tlet end = text.length;\n\twhile (text[end - 1] === char) {\n\t\tend -= 1;\n\t}\n\treturn text.substring(0, end);\n}\n","import Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildMount(\n\t// TODO: like in buildRun\n\t_functionName: string,\n\tfunctionBody: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n): void {\n\tfunctionBody = replaceForVarNames(functionBody, status);\n\n\tstatus.imports.add(\"$onmount\");\n\t// Ignore errors if the user hasn't returned a cleanup function\n\tb.append(\"// @ts-ignore\\n$onmount(() => {\");\n\tb.append(functionBody);\n\tb.append(\"});\");\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport forVarsReadIn from \"../../utils/forVarsReadIn\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRun(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n): void {\n\tvalue = replaceForVarNames(value, status);\n\tlet functionBody = functionStart + value + functionEnd;\n\tlet forVarMask =\n\t\tstatus.forVarNames.length > 0 ? forVarsReadIn(value, status.forVarNames) : undefined;\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: [span],\n\t\toffsets: [functionStart.length],\n\t\tlengths: [value.length],\n\t\tforVarMask,\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type Fragment from \"../../types/nodes/Fragment\";\nimport forVarsReadIn from \"../../utils/forVarsReadIn\";\nimport type BuildStatus from \"./BuildStatus\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function stashRunWithOffsets(\n\tfragment: Fragment,\n\tfunctionStart: string,\n\tvalue: string,\n\tfunctionEnd: string,\n\tspans: SourceSpan[],\n\toffsets: number[],\n\tlengths: number[],\n\tstatus: BuildStatus,\n): void {\n\tlet functionBody = functionStart + value + functionEnd;\n\n\tfor (let i = 0; i < offsets.length; i++) {\n\t\toffsets[i] += functionStart.length;\n\t\tconst oldLength = functionBody.length;\n\t\tfunctionBody =\n\t\t\tfunctionBody.substring(0, offsets[i]) +\n\t\t\treplaceForVarNames(functionBody.substring(offsets[i], offsets[i] + lengths[i]), status) +\n\t\t\tfunctionBody.substring(offsets[i] + lengths[i]);\n\t\tconst changedLength = functionBody.length - oldLength;\n\t\tlengths[i] += changedLength;\n\t\tfor (let j = i + 1; j < offsets.length; j++) {\n\t\t\toffsets[j] += changedLength;\n\t\t}\n\t}\n\n\tlet forVarMask =\n\t\tstatus.forVarNames.length > 0 ? forVarsReadIn(functionBody, status.forVarNames) : undefined;\n\n\tfragment.effects.push({\n\t\tfunctionBody,\n\t\tspans: spans,\n\t\toffsets,\n\t\tlengths,\n\t\tforVarMask,\n\t});\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimEnd from \"../../utils/trimEnd\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildMount from \"./buildMount\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport getAttributeOffsets from \"./getAttributeOffsets\";\nimport replaceForVarNames from \"./replaceForVarNames\";\nimport stashRun from \"./stashRun\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildElementNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n): void {\n\tif (status.inHead) {\n\t\tif (node.tagName === \"title\") {\n\t\t\tbuildTitleNode(node, status, b);\n\t\t} else {\n\t\t\tbuildHeadNode(node, status, b);\n\t\t}\n\t\treturn;\n\t}\n\n\tconst svgElement = node.tagName === \"svg\";\n\tconst oldns = status.ns;\n\tif (svgElement) {\n\t\tstatus.ns = true;\n\t}\n\n\tconst varName = node.varName;\n\tif (varName) {\n\t\tif (node.tagName === \"@element\") {\n\t\t\tbuildDynamicElementNode(node, status, b);\n\t\t\treturn;\n\t\t}\n\n\t\tbuildElementAttributes(node, varName, status, b);\n\t}\n\n\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\tstatus.preserveWhitespace = node.tagName === \"code\" || node.tagName === \"pre\";\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, \"null\");\n\t}\n\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\n\tif (svgElement) {\n\t\tstatus.ns = oldns;\n\t}\n}\n\nfunction buildDynamicElementNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\n\tif (selfAttribute && selfAttribute.value) {\n\t\tstatus.imports.add(\"t_dynamic\");\n\t\tlet selfValue = selfAttribute.value;\n\n\t\tif (selfAttribute.fullyReactive) {\n\t\t\t// Swap the tag whenever the expression changes. Emitted BEFORE\n\t\t\t// the attributes below, so the events it stashes (and the\n\t\t\t// reactive attribute runs) apply to the swapped element;\n\t\t\t// t_dynamic copies the current attribute values and event\n\t\t\t// listeners onto the new tag\n\t\t\tstatus.imports.add(\"$run\");\n\t\t\tb.append(\"$run(() => {\");\n\t\t\tb.append(`${node.varName} = t_dynamic(${node.varName}, ${selfValue});`);\n\t\t\tb.append(`}${status.options.dev === true ? `, \"setDynamic\"` : \"\"});`);\n\t\t} else {\n\t\t\t// A static (or interpolated, non-reactive) tag: swap once\n\t\t\tb.append(`${node.varName} = t_dynamic(${node.varName}, ${selfValue});`);\n\t\t}\n\t}\n\n\t// Apply the element's reactive attributes and events —\n\t// buildElementAttributes skips `self` (and &ref) itself. Static\n\t// attributes are already in the fragment's template HTML and are\n\t// carried across tag swaps by t_dynamic's attribute copy\n\tbuildElementAttributes(node, node.varName!, status, b);\n\n\t// Process children with the existing fragment stack (parent's fragment),\n\t// so text content effects are properly stashed and emitted by the parent\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, node.varName!, \"null\");\n\t}\n}\n\nfunction buildTitleNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tlet content = (node.children[0] as TextNode).content || \"\";\n\n\t// Replace all spaces with a single space, both to save space and to remove\n\t// newlines from generated JS strings\n\tcontent = content.replace(/\\s+/g, \" \");\n\n\t// TODO: Should be fancier about this in parse -- e.g. ignore braces in\n\t// quotes, unclosed, etc\n\tlet reactiveStarted = false;\n\tlet reactiveCount = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tif (content[i] === \"{\") {\n\t\t\treactiveStarted = true;\n\t\t} else if (content[i] === \"}\") {\n\t\t\tif (reactiveStarted) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\treactiveStarted = false;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (reactiveCount) {\n\t\tstatus.imports.add(\"t_fmt\");\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\tcontent = `t_fmt(${content.substring(1, content.length - 1)})`;\n\t\t} else {\n\t\t\tcontent = `\\`${content.replaceAll(\"{\", \"${t_fmt(\").replaceAll(\"}\", \")}\")}\\``;\n\t\t}\n\t} else {\n\t\tcontent = `\"${content}\"`;\n\t}\n\n\tstatus.imports.add(\"$run\");\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_old_title = document.title;\n\t\t\tdocument.title = ${content};\n\t\t\treturn () => document.title = t_old_title;\n\t\t}${status.options.dev === true ? `, \"runTitle\"` : \"\"});`);\n}\n\nfunction buildHeadNode(node: ElementNode, status: BuildStatus, b: Builder) {\n\tstatus.imports.add(\"$run\");\n\tstatus.imports.add(\"t_head_element\");\n\t// Look for an existing element to reuse, so that hydrating server rendered\n\t// tags (or revisiting a page with the same tags) doesn't add duplicates\n\t// to the head. The title is handled separately, in buildTitleNode\n\tconst selector = headElementSelector(node);\n\tb.append(\"$run(() => {\");\n\tb.append(`\n\t\t\tconst t_head_el = t_head_element(\"${node.tagName}\", ${JSON.stringify(selector)});`);\n\tfor (let { name, value, span } of node.attributes) {\n\t\tif (value != null) {\n\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\tvalue = replaceForVarNames(value, status);\n\t\t\taddMappedText(`t_attribute(t_head_el, \"${name}\", `, value, \");\", span, status, b);\n\t\t}\n\t}\n\tb.append(`}${status.options.dev === true ? `, \"runHead\"` : \"\"});`);\n}\n\n/**\n * Builds a selector that finds an equivalent element in the head, from the\n * attributes that identify it (e.g. `meta[name=\"description\"]`). Returns an\n * empty string when the element has no identifying attributes, in which case\n * a new element is always created.\n */\nfunction headElementSelector(node: ElementNode): string {\n\tconst identityAttributes = [\"name\", \"property\", \"rel\", \"charset\", \"http-equiv\", \"itemprop\"];\n\tconst parts: string[] = [];\n\tfor (let { name, value, reactive } of node.attributes) {\n\t\tif (!identityAttributes.includes(name) || value == null || reactive) continue;\n\t\tconst attributeValue = trimQuotes(value).replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"');\n\t\tparts.push(`[${name}=\"${attributeValue}\"]`);\n\t}\n\treturn parts.length ? node.tagName + parts.join(\"\") : \"\";\n}\n\nfunction buildElementAttributes(\n\tnode: ElementNode,\n\tvarName: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) throw new Error(\"No fragment on stack\");\n\n\t// TODO: Add an error if any reactive attributes are used non-reactively\n\n\tfor (let { name, value, reactive, fullyReactive, span } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// Ignore this one, it should have been done already, above\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&group\") {\n\t\t\t\tbuildBindGroupAttribute(node, varName, value, status, b);\n\t\t\t} else if (name === \"&value\" || name === \"&checked\") {\n\t\t\t\tbuildBindAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"onmount\") {\n\t\t\t\t// The onmount event is faked by us by creating an $onmount. This\n\t\t\t\t// also means that you can have unmount functionality by\n\t\t\t\t// returning a cleanup function\n\t\t\t\tbuildMount(\"elMount\", `return (${trimEnd(value.trim(), \";\")})(${varName});`, status, b);\n\t\t\t} else if (name.startsWith(\"on\")) {\n\t\t\t\tbuildEventAttribute(varName, name, value, span, status, b);\n\t\t\t} else if (name.startsWith(\"transition\")) {\n\t\t\t\tbuildTransitionAttribute(node, varName, name, value, status, b);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRun(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspan,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRun(fragment, `${varName}.style.cssText += t_style(`, value, \");\", span, status);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRun(fragment, `t_attribute(${varName}, \"${name}\", `, value, \");\", span, status);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\tconst { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);\n\t\t\tvalue = newValue;\n\t\t\tif (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tconst params = [value];\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t}\n\t\t\t\t// SVGs have a different className\n\t\t\t\tconst propName = status.ns ? \"className.baseVal\" : \"className\";\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${status.ns ? \"// @ts-ignore\\n\" : \"\"}${varName}.${propName} = t_class(`,\n\t\t\t\t\tparams.join(\", \"),\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`${varName}.style.cssText += t_style(`,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t} else if (name.includes(\"-\")) {\n\t\t\t\t// Handle data-, aria- etc\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t\t// NOTE: dataset seems to be a tiny bit slower?\n\t\t\t\t//const propName = name.substring(name.indexOf(\"-\"));\n\t\t\t\t//buildRun(\"setDataAttribute\", `${varName}.dataset.${propName} = ${value};`, status, b);\n\t\t\t} else {\n\t\t\t\tstatus.imports.add(\"t_attribute\");\n\t\t\t\tstashRunWithOffsets(\n\t\t\t\t\tfragment,\n\t\t\t\t\t`t_attribute(${varName}, \"${name}\", `,\n\t\t\t\t\tvalue,\n\t\t\t\t\t\");\",\n\t\t\t\t\tspans,\n\t\t\t\t\toffsets,\n\t\t\t\t\tlengths,\n\t\t\t\t\tstatus,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction buildBindGroupAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Only tested this with radio buttons\n\tlet eventName = \"change\";\n\tlet inputValue = node.attributes.find((a) => a.name === \"value\")?.value;\n\tlet set = `${value} == ${inputValue}`;\n\tlet propName = \"checked\";\n\tconst setAttribute = `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => {\n\t\t\tif (e.target.${propName}) ${value} = ${inputValue};\n\t\t});`);\n}\n\nfunction buildBindAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Automatically add an event to bind the value\n\t// TODO: Need to check the element to find out what type of event to add\n\tlet eventName = \"input\";\n\tlet defaultValue = '\"\"';\n\tlet inputValue = \"e.target.value\";\n\tif (node.tagName === \"input\") {\n\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\tcase \"number\": {\n\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\tinputValue = \"Number(e.target.value)\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\tinputValue = \"e.target.checked\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"radio\": {\n\t\t\t\t\teventName = \"change\";\n\t\t\t\t\tinputValue = \"e.target.value\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (node.tagName === \"select\") {\n\t\teventName = \"change\";\n\t\t// <select multiple> binds an array of selected option values\n\t\tlet multipleAttribute = node.attributes.find((a) => a.name === \"multiple\");\n\t\tif (multipleAttribute) {\n\t\t\tbuildRun(\n\t\t\t\t\"setBinding\",\n\t\t\t\t`Array.from(${varName}.options).forEach((opt) => opt.selected = Array.isArray(${value}) && ${value}.includes(opt.value));`,\n\t\t\t\tstatus,\n\t\t\t\tb,\n\t\t\t);\n\t\t\tstatus.imports.add(\"t_event\");\n\t\t\tb.append(\n\t\t\t\t`t_event(${varName}, \"change\", (e) => ${value} = Array.from(e.target.selectedOptions).map((opt) => opt.value));`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t}\n\tlet set = `${value} || ${defaultValue}`;\n\tconst propName = name.substring(1);\n\t// NOTE: The DOM value property is always a string, while the bound state\n\t// may be a number (e.g. with `<input type=\"number\">`), so convert\n\tconst setAttribute =\n\t\tpropName === \"value\"\n\t\t\t? `${varName}.${propName} = String(${set})`\n\t\t\t: `${varName}.${propName} = ${set}`;\n\tbuildRun(\"setBinding\", `${setAttribute};`, status, b);\n\t// TODO: Add a parseInput method that handles NaN etc\n\tstatus.imports.add(\"t_event\");\n\tb.append(`t_event(${varName}, \"${eventName}\", (e) => ${value} = ${inputValue});`);\n}\n\nfunction buildEventAttribute(\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tspan: SourceSpan,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\t// Add an event listener, after the fragment has been added\n\tconst eventName = name.substring(2);\n\tstatus.imports.add(\"t_event\");\n\taddMappedText(`t_event(${varName}, \"${eventName}\", `, value, `);`, span, status, b);\n}\n\nfunction buildTransitionAttribute(\n\tnode: ElementNode,\n\tvarName: string,\n\tname: string,\n\tvalue: string,\n\tstatus: BuildStatus,\n\tb: Builder,\n) {\n\tvalue = replaceForVarNames(value, status);\n\n\tstatus.imports.add(\"t_animate\");\n\n\t// Add an in and out transition, after the fragment has been added\n\t// TODO: Separate these -- you should be able to have multiple,\n\t// unrelated entry and exit transitions?\n\tlet entryVarName = nextVarName(\"trans_in\", status);\n\tlet exitVarName = nextVarName(\"trans_out\", status);\n\n\tif (name === \"transition\") {\n\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\tb.append(`const ${exitVarName} = ${entryVarName};`);\n\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t} else if (name === \"transition-in\") {\n\t\tlet outAttribute = node.attributes.find((a) => a.name === \"transition-out\");\n\t\tif (outAttribute && outAttribute.value && outAttribute.fullyReactive) {\n\t\t\tlet outValue = outAttribute.value;\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`const ${exitVarName} = (${outValue})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName}, ${exitVarName});`);\n\t\t} else {\n\t\t\tb.append(`const ${entryVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, ${entryVarName});`);\n\t\t}\n\t} else if (name === \"transition-out\") {\n\t\tlet inAttribute = node.attributes.find((a) => a.name === \"transition-in\");\n\t\tif (inAttribute) {\n\t\t\t// This has already been handled with transition-in, above\n\t\t\treturn;\n\t\t} else {\n\t\t\tb.append(`const ${exitVarName} = (${value})(${varName});`);\n\t\t\tb.append(`t_animate(${varName}, null, ${entryVarName});`);\n\t\t}\n\t} else {\n\t\t// TODO: Add an error\n\t}\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\n\nexport default function buildRootNode(\n\tnode: RootNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n): void {\n\tbuildFragment(node, status, b, parentName, anchorName);\n\n\tstatus.fragmentStack.push({\n\t\tfragment: node.fragment,\n\t\tpath: \"0:ch/\",\n\t});\n\n\tfor (let child of node.children) {\n\t\tbuildNode(child, status, b, parentName, anchorName, true);\n\t}\n\n\tstatus.fragmentStack.pop();\n\n\tbuildAddFragment(node, status, b, parentName, anchorName);\n}\n","import type SourceSpan from \"../../types/SourceSpan\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport buildAddFragment from \"./buildAddFragment\";\nimport buildFragment from \"./buildFragment\";\nimport buildNode from \"./buildNode\";\nimport buildRun from \"./buildRun\";\nimport replaceForVarNames from \"./replaceForVarNames\";\n\nexport default function buildSlotNode(node: ElementNode, status: BuildStatus, b: Builder): void {\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"slot_props\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tstatus.imports.add(\"$watch\");\n\n\t\t// Gather props, runs and binding runs, and set them all at once\n\t\tlet props: { name: string; value: string; span: SourceSpan }[] = [];\n\t\tlet runs: string[] = [];\n\n\t\tfor (let { name, value, reactive, span } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tprops.push({ name, value, span });\n\t\t\t\tif (reactive) {\n\t\t\t\t\truns.push(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\", span });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props, runs and binding runs that we gathered\n\t\tb.append(`const ${propsName} = $watch({`);\n\t\tfor (let p of props) {\n\t\t\tlet value = replaceForVarNames(p.value, status);\n\t\t\taddMappedText(`${p.name}: `, value, \",\", p.span, status, b);\n\t\t}\n\t\tb.append(\"});\");\n\t\t// TODO: Map these things:\n\t\tif (runs.length) {\n\t\t\tbuildRun(\"setProps\", replaceForVarNames(runs.join(\"\\n\"), status), status, b);\n\t\t}\n\t}\n\n\tconst slotParentName = node.parentName!;\n\tconst slotAnchorName = node.varName!;\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\tlet params = [slotParentName, slotAnchorName, slotHasProps ? propsName : \"undefined\", \"$context\"];\n\tb.append(`$slots[\"${slotName}\"](${params.join(\", \")})`);\n\n\t// TODO: Maybe not if there's only a single space node?\n\tconst fill = node.children.find(\n\t\t(c) => isSpecialNode(c) && (c.tagName === \"fill\" || c.tagName === \"filldef\"),\n\t);\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tbuildFragment(fill, status, b, slotParentName, slotAnchorName);\n\n\t\tstatus.fragmentStack.push({\n\t\t\tfragment: fill.fragment,\n\t\t\tpath: \"0:ch/\",\n\t\t});\n\t\tfor (let child of fill.children) {\n\t\t\tbuildNode(child, status, b, slotParentName, slotAnchorName);\n\t\t}\n\t\tstatus.fragmentStack.pop();\n\n\t\tbuildAddFragment(fill, status, b, slotParentName, slotAnchorName);\n\t}\n\n\tb.append(`}`);\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildSlotNode from \"./buildSlotNode\";\n\nexport default function buildSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\troot = false,\n) {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildElementNode(node, status, b, parentName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildComponentNode(node, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"../../utils/codeScanner\";\nimport type BuildStatus from \"./BuildStatus\";\nimport stashRunWithOffsets from \"./stashRunWithOffsets\";\n\nexport default function buildTextNode(node: TextNode, status: BuildStatus): void {\n\tlet fragment = status.fragmentStack.at(-1)?.fragment;\n\tif (!fragment) return; // probably in @head...\n\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Should we be parsing out the spans here? Like we do with\n\t// attributes? And should we merge this with the attributes logic?\n\tlet textContent = \"\";\n\tlet reactiveCount = 0;\n\tlet reactiveStart = 0;\n\tlet offsets: number[] = [];\n\tlet lengths: number[] = [];\n\tlet level = 0;\n\tlet maxLevel = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tmaxLevel = Math.max(level, maxLevel);\n\t\t\tif (level === 1) {\n\t\t\t\treactiveCount += 1;\n\t\t\t\ttextContent += \"${t_fmt(\";\n\t\t\t\treactiveStart = textContent.length;\n\t\t\t\toffsets.push(reactiveStart);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tlengths.push(textContent.length - reactiveStart);\n\t\t\t\ttextContent += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\ttextContent += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(content, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\t// Copy strings, template strings, comments and regex literals\n\t\t\t\t// into the output as-is\n\t\t\t\ttextContent += content.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\ttextContent += content[i];\n\t}\n\n\t// Only need to build if there is any reactive content, otherwise the plain\n\t// text content will be output in fragment text\n\tif (maxLevel) {\n\t\tlet offsetChange = 0;\n\t\tif (reactiveCount === 1 && content.startsWith(\"{\") && content.endsWith(\"}\")) {\n\t\t\ttextContent = textContent.substring(2, textContent.length - 1);\n\t\t\toffsetChange = -2;\n\t\t} else {\n\t\t\ttextContent = `\\`${textContent}\\``;\n\t\t\toffsetChange = 1;\n\t\t}\n\n\t\tstatus.imports.add(\"t_fmt\");\n\t\toffsets.map((_, i) => (offsets[i] += offsetChange));\n\n\t\tstashRunWithOffsets(\n\t\t\tfragment,\n\t\t\t`${node.varName}.textContent = `,\n\t\t\ttextContent,\n\t\t\t\";\",\n\t\t\tnode.spans,\n\t\t\toffsets,\n\t\t\tlengths,\n\t\t\tstatus,\n\t\t);\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildStatus from \"./BuildStatus\";\nimport buildComponentNode from \"./buildComponentNode\";\nimport buildControlNode from \"./buildControlNode\";\nimport buildElementNode from \"./buildElementNode\";\nimport buildRootNode from \"./buildRootNode\";\nimport buildSpecialNode from \"./buildSpecialNode\";\nimport buildTextNode from \"./buildTextNode\";\n\nexport default function buildNode(\n\tnode: TemplateNode,\n\tstatus: BuildStatus,\n\tb: Builder,\n\tparentName: string,\n\tanchorName: string,\n\troot = false,\n): void {\n\t// Nodes with anchors will have been handled when their containing fragment\n\t// was built so we want to skip them here\n\tif (node.handled) {\n\t\tnode.handled = false;\n\t\treturn;\n\t}\n\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildRootNode(node as RootNode, status, b, parentName, anchorName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildComponentNode(node as ElementNode, status, b, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildElementNode(node as ElementNode, status, b, parentName);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildSpecialNode(node as ElementNode, status, b, parentName, root);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't output comments!\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type TemplateComponent from \"../../../types/TemplateComponent\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport type SourceMapping from \"../../types/SourceMapping\";\nimport Builder from \"../../utils/Builder\";\nimport { codeRanges } from \"../../utils/codeScanner\";\nimport collectMarkupExpressions from \"../../utils/collectMarkupExpressions\";\nimport markupRendersComponent from \"../../utils/markupRendersComponent\";\nimport type BuildStatus from \"./BuildStatus\";\nimport addMappedText from \"./addMappedText\";\nimport addPopDevBoundary from \"./addPopDevBoundary\";\nimport addPushDevBoundary from \"./addPushDevBoundary\";\nimport buildFragmentText from \"./buildFragmentText\";\nimport buildNode from \"./buildNode\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$bind: 'import { $bind } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$async: 'import { $async } from \"${folder}\";',\n\t$pending: 'import { $pending } from \"${folder}\";',\n\t$refresh: 'import { $refresh } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$onmount: 'import { $onmount } from \"${folder}\";',\n\t$stream: 'import { $stream } from \"${folder}\";',\n\tfromElement: 'import { fromElement } from \"${folder}\";',\n\tfromServer: 'import { fromServer } from \"${folder}\";',\n\tfromWebSocket: 'import { fromWebSocket } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_region: 'import { t_region } from \"${folder}\";',\n\tt_push_region: 'import { t_push_region } from \"${folder}\";',\n\tt_pop_region: 'import { t_pop_region } from \"${folder}\";',\n\tt_rerun_region_effects: 'import { t_rerun_region_effects } from \"${folder}\";',\n\tt_run_control: 'import { t_run_control } from \"${folder}\";',\n\tt_run_branch: 'import { t_run_branch } from \"${folder}\";',\n\tt_list_item: 'import { t_list_item } from \"${folder}\";',\n\tt_run_list: 'import { t_run_list } from \"${folder}\";',\n\tt_run_await: 'import { t_run_await } from \"${folder}\";',\n\tt_run_try: 'import { t_run_try } from \"${folder}\";',\n\tt_add_fragment: 'import { t_add_fragment } from \"${folder}\";',\n\tt_add_element: 'import { t_add_element } from \"${folder}\";',\n\tt_apply_props: 'import { t_apply_props } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tt_attribute: 'import { t_attribute } from \"${folder}\";',\n\tt_dynamic: 'import { t_dynamic } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_head_element: 'import { t_head_element } from \"${folder}\";',\n\tt_fragment: 'import { t_fragment } from \"${folder}\";',\n\tt_fragment_el: 'import { t_fragment_el } from \"${folder}\";',\n\tt_event: 'import { t_event } from \"${folder}\";',\n\tt_animate: 'import { t_animate } from \"${folder}\";',\n\tt_root: 'import { t_root } from \"${folder}\";',\n\tt_root_el: 'import { t_root_el } from \"${folder}\";',\n\tt_anchor: 'import { t_anchor } from \"${folder}\";',\n\tt_first_inside: 'import { t_first_inside } from \"${folder}\";',\n\tt_child: 'import { t_child } from \"${folder}\";',\n\tt_next: 'import { t_next } from \"${folder}\";',\n\tt_skip: 'import { t_skip } from \"${folder}\";',\n\tt_frg: 'import { t_frg } from \"${folder}\";',\n\tt_save_hydration: 'import { t_save_hydration } from \"${folder}\";',\n\tt_restore_hydration: 'import { t_restore_hydration } from \"${folder}\";',\n\tt_elm: 'import { t_elm } from \"${folder}\";',\n\tt_txt: 'import { t_txt } from \"${folder}\";',\n\tt_cmt: 'import { t_cmt } from \"${folder}\";',\n\tt_print: 'import { t_print } from \"${folder}\";',\n\tListItem: 'import { type ListItem } from \"${folder}\";',\n\tListItemSpec: 'import { type ListItemSpec } from \"${folder}\";',\n\tSlotRender: 'import { type SlotRender } from \"${folder}\";',\n\t// HACK: this one's a bit different\n\tdevContext: 'import { devContext } from \"${folder}/dev\";',\n\tt_push_dev_bound: 'import { t_push_dev_bound } from \"${folder}/dev\";',\n\tt_pop_dev_bound: 'import { t_pop_dev_bound } from \"${folder}/dev\";',\n};\n\nexport default function buildCode(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\toptions?: BuildOptions,\n): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"SlotRender\");\n\n\t// Build the component\n\tbuildTemplate(template, map, imports, b, options);\n\n\tlet startSize = b.toString().length;\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tconst folder = options?.renderFolder ?? \"@torpor/view\";\n\t\tconst sortedImports = Array.from(imports)\n\t\t\t.map((imp) => (importsMap[imp] ?? imp).replace(\"${folder}\", folder))\n\t\t\t.sort()\n\t\t\t.reverse();\n\t\tb.prepend(\"\");\n\t\tfor (let imp of sortedImports) {\n\t\t\tb.prepend(imp);\n\t\t}\n\t}\n\n\tif (options?.mapped) {\n\t\tlet endSize = b.toString().length;\n\t\tlet diff = endSize - startSize + 1;\n\t\tfor (let m of map) {\n\t\t\tm.compiled.start += diff;\n\t\t\tm.compiled.end += diff;\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildTemplate(\n\ttemplate: Template,\n\tmap: SourceMapping[],\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Include markup expressions in import detection: `$`-primitives used\n\t// inside markup (e.g. `@if ($pending(...))`, `disabled={$pending(...)}`)\n\t// live in the template, not the script.\n\tfor (const component of template.components) {\n\t\tif (component.markup) script += \"\\n\" + collectMarkupExpressions(component.markup);\n\t\tif (component.error) script += \"\\n\" + collectMarkupExpressions(component.error);\n\t\tif (component.head) script += \"\\n\" + collectMarkupExpressions(component.head);\n\t}\n\n\t// Scan only the code in the script: strings, comments and regex literals\n\t// are stripped, so e.g. `$onmount` inside a sample-code string doesn't\n\t// inject an import that nothing uses\n\tlet scriptCode = codeRanges(script)\n\t\t.map(([start, end]) => script.substring(start, end))\n\t\t.join(\"\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(scriptCode)) imports.add(\"$watch\");\n\tif (/\\$bind\\b/.test(scriptCode)) imports.add(\"$bind\");\n\tif (/\\$cache\\b/.test(scriptCode)) imports.add(\"$cache\");\n\tif (/\\$async\\b/.test(scriptCode)) imports.add(\"$async\");\n\tif (/\\$pending\\b/.test(scriptCode)) imports.add(\"$pending\");\n\tif (/\\$refresh\\b/.test(scriptCode)) imports.add(\"$refresh\");\n\tif (/\\$run\\b/.test(scriptCode)) imports.add(\"$run\");\n\tif (/\\$onmount\\b/.test(scriptCode)) imports.add(\"$onmount\");\n\tif (/\\$stream\\b/.test(scriptCode)) imports.add(\"$stream\");\n\tif (/\\bfromElement\\b/.test(scriptCode)) imports.add(\"fromElement\");\n\tif (/\\bfromServer\\b/.test(scriptCode)) imports.add(\"fromServer\");\n\tif (/\\bfromWebSocket\\b/.test(scriptCode)) imports.add(\"fromWebSocket\");\n\tif (/\\$unwrap\\b/.test(scriptCode)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(scriptCode)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(scriptCode)) imports.add(\"$batch\");\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\tlet status: BuildStatus = makeStatus(imports, map, current, options);\n\tlet first = true;\n\n\tfor (let chunk of template.script) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// Reset the status for each new function body\n\t\t\tif (!first) {\n\t\t\t\tstatus = makeStatus(imports, map, current, options);\n\t\t\t}\n\t\t\tfirst = false;\n\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tb.append(`\n\t\t\t\t\t${current.markup ? \"$parent\" : \"_$parent\"}: ParentNode,\n\t\t\t\t\t${current.markup ? \"$anchor\" : \"_$anchor\"}: Node | null,`);\n\t\t\tif (current.params !== undefined) {\n\t\t\t\taddMappedText(\"\", current.params, \",\", chunk.span, status, b);\n\t\t\t} else {\n\t\t\t\tb.append(\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"_$props?: Record<PropertyKey, any>\"},`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t\t${\n\t\t\t\t\tcurrent.contextProps?.length ||\n\t\t\t\t\t(current.markup && markupRendersComponent(current.markup)) ||\n\t\t\t\t\t(current.error && markupRendersComponent(current.error))\n\t\t\t\t\t\t? \"$context\"\n\t\t\t\t\t\t: \"_$context\"\n\t\t\t\t}?: Record<PropertyKey, any>,\n\t\t\t\t${current.slotProps?.length ? \"$slots\" : \"_$slots\"}?: Record<string, SlotRender>,`);\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): void {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Add the component to devContext for display in DevTools\n\t\t\taddPushDevBoundary(\"component\", current.name || \"Anon Component\", status, b);\n\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\tif (current.markup) {\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\n\t\t\t\t// An @error block wraps the render in an error boundary\n\t\t\t\t// (t_run_try), so that BOTH sync render errors and later\n\t\t\t\t// effect re-run errors (routed from triggerEffects) render\n\t\t\t\t// the error content, and a recovery re-render restores the\n\t\t\t\t// normal content. The content builds into $parent/$anchor\n\t\t\t\t// exactly as before — the boundary re-inserts at the same\n\t\t\t\t// position when it switches branches\n\t\t\t\tif (current.error) {\n\t\t\t\t\tstatus.imports.add(\"t_region\");\n\t\t\t\t\tstatus.imports.add(\"t_run_try\");\n\t\t\t\t\tb.append(`const t_error_region = t_region();`);\n\t\t\t\t\tb.append(`t_run_try(t_error_region, $anchor, () => {`);\n\t\t\t\t}\n\n\t\t\t\tbuildFragmentText(current.markup, status, b);\n\t\t\t\tb.append(\"\");\n\t\t\t\tbuildNode(current.markup, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @error */\") {\n\t\t\tif (current.markup && current.error) {\n\t\t\t\tb.append(`}, (_, ${current.errorVar ?? \"err\"}) => {`);\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface error */\");\n\t\t\t\tbuildFragmentText(current.error, status, b);\n\t\t\t\tb.append(\"\");\n\t\t\t\tbuildNode(current.error, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t\tb.append(`}${status.options.dev === true ? ', \"runError\"' : \"\"});`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\tif (current.head) {\n\t\t\t\t// Add the head tags\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Head */\");\n\t\t\t\tstatus.inHead = true;\n\t\t\t\tbuildNode(current.head, status, b, \"$parent\", \"$anchor\", true);\n\t\t\t\tstatus.inHead = false;\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t// No styles in the client\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\taddPopDevBoundary(status, b);\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\taddMappedText(\"\", chunk.script, \"\", chunk.span, status, b);\n\t\t}\n\t}\n}\n\nfunction makeStatus(\n\timports: Set<string>,\n\tmap: SourceMapping[],\n\tcurrent?: TemplateComponent,\n\toptions?: BuildOptions,\n): BuildStatus {\n\treturn {\n\t\timports,\n\t\tprops: current?.props ?? [],\n\t\tcontextProps: current?.contextProps ?? [],\n\t\tslotProps: current?.slotProps ?? [],\n\t\tstyleHash: current?.style?.hash ?? \"\",\n\t\tmap,\n\t\tvarNames: {},\n\t\tfragmentStack: [],\n\t\tforVarNames: [],\n\t\tns: false,\n\t\tpreserveWhitespace: false,\n\t\tinHead: false,\n\t\toptions: options ?? {},\n\t};\n}\n","import type AttributeNode from \"../../types/styles/AttributeNode\";\nimport type BlockNode from \"../../types/styles/BlockNode\";\nimport type Style from \"../../types/styles/Style\";\nimport type StyleNode from \"../../types/styles/StyleNode\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildStyles(style: Style, styleHash: string): string {\n\tconst b = new Builder();\n\n\tfor (let block of style.children) {\n\t\tbuildStyleNode(block, b, styleHash);\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildStyleNode(node: StyleNode, b: Builder, styleHash: string) {\n\tswitch (node.type) {\n\t\tcase \"block\": {\n\t\t\tbuildBlockNode(node as BlockNode, b, styleHash);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"attribute\": {\n\t\t\tbuildAttributeNode(node as AttributeNode, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't include comments\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid style node type: ${node.type}`);\n\t\t}\n\t}\n}\n\nfunction buildBlockNode(block: BlockNode, b: Builder, styleHash: string) {\n\t// TODO: This should probably be done while parsing\n\t// And handle attribute selectors\n\tif (block.selector.startsWith(\"@\")) {\n\t\t// Just output media queries and properties as-is\n\t\tb.append(`${block.selector} {`);\n\t} else {\n\t\tblock.selector = block.selector.replaceAll(/\\s+/g, \" \");\n\t\tlet selectors: string[] = [];\n\t\tlet global = false;\n\t\tlet start = 0;\n\t\tfor (let i = 0; i <= block.selector.length; i++) {\n\t\t\tif (block.selector.substring(i).startsWith(\":global(\")) {\n\t\t\t\ti += \":global\".length;\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = true;\n\t\t\t} else if (global && block.selector[i] === \")\") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t\tglobal = false;\n\t\t\t} else if (\"*,>+~\".includes(block.selector[i])) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tselectors.push(block.selector[i]);\n\t\t\t\tstart = i + 1;\n\t\t\t} else if (i === block.selector.length) {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t} else if (block.selector[i] === \" \") {\n\t\t\t\taddSelector(selectors, block.selector, styleHash, start, i, global);\n\t\t\t\tstart = i + 1;\n\t\t\t}\n\t\t}\n\t\tb.append(`${selectors.join(\" \").replaceAll(\" ,\", \",\")} {`);\n\t}\n\tfor (let child of block.children) {\n\t\tbuildStyleNode(child, b, styleHash);\n\t}\n\tb.append(`}`);\n}\n\nfunction addSelector(\n\tselectors: string[],\n\tselector: string,\n\tstyleHash: string,\n\tstart: number,\n\tend: number,\n\tglobal: boolean,\n) {\n\tif (end > start) {\n\t\tlet s = selector.substring(start, end);\n\t\tif (!global) {\n\t\t\tlet pre = s;\n\t\t\tlet post = \"\";\n\t\t\t// We might need to handle e.g. `:hover` or `::before`\n\t\t\tlet colonPosition = s.indexOf(\":\");\n\t\t\tif (colonPosition !== -1) {\n\t\t\t\tpre = s.substring(0, colonPosition);\n\t\t\t\tpost = s.substring(colonPosition);\n\t\t\t}\n\t\t\ts = `${pre}.torp-${styleHash}${post}`;\n\t\t}\n\t\tselectors.push(s);\n\t}\n}\n\nfunction buildAttributeNode(attribute: AttributeNode, b: Builder) {\n\tb.append(`${attribute.name}: ${attribute.value};`);\n}\n","import type Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\n/**\n * Appends any pending output to the generated code, targeting the body\n * string -- or the head string, when building inside a @head block.\n */\nexport default function flushOutput(status: BuildServerStatus, b: Builder): void {\n\tif (status.output) {\n\t\tb.append(`${status.inHead ? \"t_head\" : \"t_body\"} += \\`${status.output}\\`;`);\n\t\tstatus.output = \"\";\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerComponentNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Props\n\tconst componentHasProps = node.attributes.length; // || root;\n\tconst propsName = componentHasProps ? nextVarName(\"props\", status) : \"undefined\";\n\tif (componentHasProps) {\n\t\t// TODO: defaults etc props\n\n\t\t// Gather props, and set them all at once\n\t\tlet props: { name: string; value: string }[] = [];\n\n\t\tfor (let { name, value } of node.attributes) {\n\t\t\t// No binding on the server\n\t\t\tif (name.startsWith(\"&\")) {\n\t\t\t\tname = name.substring(1);\n\t\t\t}\n\n\t\t\tif (name === \"class\" && value != null) {\n\t\t\t\tif (node.scopeStyles) {\n\t\t\t\t\tvalue = `[${value}, \"torp-${status.styleHash}\"]`;\n\t\t\t\t}\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else if (name === \"style\" && value != null) {\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else if (value != null) {\n\t\t\t\tprops.push({ name, value });\n\t\t\t} else {\n\t\t\t\tprops.push({ name, value: \"true\" });\n\t\t\t}\n\t\t}\n\n\t\t// Set the props that we gathered\n\t\tb.append(`const ${propsName} = {`);\n\t\tfor (let p of props) {\n\t\t\tb.append(p.name ? `${p.name}: ${p.value},` : `${p.value},`);\n\t\t}\n\t\tb.append(\"};\");\n\n\t\t// NOTE: Not sure if this is needed\n\t\t/*\n\t\tif (root) {\n\t\t\tb.append(`\n\t\t\tif ($props) {\n\t\t\t\tconst propNames = [${status.props.map((p) => `'${p}'`).join(\", \")}];\n\t\t\t\tfor (let name of Object.keys($props)) {\n\t\t\t\t\tif (!name.startsWith(\"$\") && !propNames.includes(name)) {\n\t\t\t\t\t\t${propsName}[name] = $props[name];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}`);\n\t\t}\n\t\t*/\n\t}\n\n\t// Slots\n\tconst componentHasSlots = node.children.length;\n\tconst slotsName = componentHasSlots ? nextVarName(\"slots\", status) : \"undefined\";\n\tif (componentHasSlots) {\n\t\tb.append(`const ${slotsName}: Record<string, ServerSlotRender> = {};`);\n\t\tfor (let slot of node.children) {\n\t\t\tif (isSpecialNode(slot) && (slot.tagName === \"fill\" || slot.tagName === \"filldef\")) {\n\t\t\t\tconst nameAttribute = slot.attributes.find((a) => a.name === \"name\");\n\t\t\t\tconst slotName = nameAttribute?.value ? trimQuotes(nameAttribute.value) : \"_\";\n\t\t\t\tconst slotParams = [\n\t\t\t\t\t// NOTE: The $slot param is only declared with its real name\n\t\t\t\t\t// when the fill reads it (hasSlotProps), otherwise it would\n\t\t\t\t\t// be reported as unused\n\t\t\t\t\tslot.hasSlotProps\n\t\t\t\t\t\t? \"$slot: Record<PropertyKey, any>\"\n\t\t\t\t\t\t: \"_$slot?: Record<PropertyKey, any>\",\n\t\t\t\t\t\"// @ts-ignore\\n// eslint-disable-next-line no-unused-vars\\n$context?: Record<PropertyKey, any>\",\n\t\t\t\t];\n\t\t\t\t// NOTE: The @ts-ignore suppresses the assignability error from\n\t\t\t\t// the required $slot param, which is not compatible with the\n\t\t\t\t// optional $slot param of the ServerSlotRender type\n\t\t\t\tb.append(\n\t\t\t\t\t`${slot.hasSlotProps ? \"// @ts-ignore\\n\" : \"\"}${slotsName}[\"${slotName}\"] = async (\\n${slotParams.join(\",\\n\")}\\n) => {`,\n\t\t\t\t);\n\t\t\t\tb.append(`let t_body = \"\";`);\n\n\t\t\t\tfor (let child of slot.children) {\n\t\t\t\t\tbuildServerNode(child, status, b);\n\t\t\t\t}\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\n\t\t\t\tb.append(\"return t_body;\");\n\t\t\t\tb.append(`}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tlet componentName = node.tagName;\n\tif (componentName === \"@component\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\tcomponentName = selfAttribute.value;\n\t\t}\n\t}\n\n\t// Render the component. Components are async functions (they may contain\n\t// a `source: \"server\"` `@await` boundary), so await the result\n\tlet renderParams = `${propsName}, $context`;\n\tif (slotsName !== \"undefined\") {\n\t\trenderParams += `, ${slotsName}`;\n\t}\n\tconst componentResult = nextVarName(\"comp\", status);\n\tb.append(`const ${componentResult} = await ${componentName}(${renderParams});`);\n\tb.append(`${status.inHead ? \"t_head\" : \"t_body\"} += ${componentResult}.body;`);\n\tb.append(`t_head += ${componentResult}.head;`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\n/**\n * Builds an `@await` boundary for the server (ASYNC.md → \"Server rendering\").\n *\n * Rather than inlining the `with` branch (the old shape), the boundary is\n * handed to the `t_await_server` runtime helper: content and `with` branches\n * become closures, and the helper decides at render time whether resolved\n * content can ship (all `source: \"server\"` reads settled) or the `with`\n * branch + client fetch is the honest output. The runtime emits the\n * hydration markers and anchor itself, including the `<!--t-await:...-->`\n * values payload for resolved boundaries.\n */\nexport default function buildServerAwaitNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tflushOutput(status, b);\n\n\tstatus.imports.add(\"t_await_server\");\n\n\tconst id = status.awaitCount++;\n\tconst resultName = nextVarName(\"await\", status);\n\n\tb.append(`const ${resultName} = await t_await_server(\"${id}\", async () => {`);\n\n\t// Content branch: rendered speculatively (to start the server fetches),\n\t// then again once they settle\n\tb.append(`let t_body = \"\";`);\n\tb.append(`let t_head = \"\";`);\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch) && branch.operation === \"@await\") {\n\t\t\tfor (let child of branch.children) {\n\t\t\t\tbuildServerNode(child, status, b);\n\t\t\t}\n\t\t}\n\t}\n\tflushOutput(status, b);\n\tb.append(`return { body: t_body, head: t_head };`);\n\n\t// With branch: rendered on a timeout, on a render pass that doesn't match\n\t// the collect pass, or when no server reads were recorded\n\tb.append(`}, async () => {`);\n\tb.append(`let t_body = \"\";`);\n\tb.append(`let t_head = \"\";`);\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch) && branch.operation === \"@with\") {\n\t\t\tfor (let child of branch.children) {\n\t\t\t\tbuildServerNode(child, status, b);\n\t\t\t}\n\t\t}\n\t}\n\tflushOutput(status, b);\n\tb.append(`return { body: t_body, head: t_head };`);\n\tb.append(`});`);\n\n\tb.append(`${status.inHead ? \"t_head\" : \"t_body\"} += ${resultName}.body;`);\n\tb.append(`t_head += ${resultName}.head;`);\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerForNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the for statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerForBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerForBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerHtmlNode(node: ControlNode, status: BuildServerStatus): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\t// Build the html statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tstatus.output += `\\${${branch.statement}}`;\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerIfNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the if statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerIfBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerIfBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerReplaceNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the replace statement\n\tfor (let branch of node.children) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerReplaceBranch(branch, status, b);\n\t\t}\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerReplaceBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement};`);\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\n\nexport default function buildServerScriptNode(node: ControlNode, b: Builder): void {\n\tb.append(`${maybeAppend(node.statement, \";\")}`);\n}\n\nfunction maybeAppend(text: string, end: string) {\n\tif (!text.endsWith(end)) {\n\t\ttext += end;\n\t}\n\treturn text;\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_BREAK_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerSwitchNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// Build the switch statement\n\tb.append(`${node.statement} {`);\n\tfor (let branch of node.children.filter((c) => isControlNode(c))) {\n\t\tif (isControlNode(branch)) {\n\t\t\tbuildServerSwitchBranch(branch, status, b);\n\t\t}\n\t}\n\tb.append(\"}\");\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerSwitchBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tb.append(`${node.statement} {`);\n\n\t// Separate spaces across boundaries with a careted comment\n\tstatus.output += HYDRATION_BREAK_COMMENT;\n\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n\n\tb.append(\"break;\");\n\tb.append(\"}\");\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport trimMatched from \"../../utils/trimMatched\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerTryNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\tconst branches = node.children.filter((n) => isControlNode(n)) as ControlNode[];\n\tlet tryBranch = branches.find((n) => n.operation === \"@try\");\n\tlet catchBranch = branches.find((n) => n.operation === \"@catch\");\n\n\tif (catchBranch) {\n\t\t// Snapshot t_body and t_head so that any partially-flushed try output\n\t\t// is discarded if the try branch throws — including <head> tags\n\t\t// appended by child components or styles rendered before the throw\n\t\tb.append(`const t_try_body = t_body;`);\n\t\tb.append(`const t_try_head = t_head;`);\n\t\tb.append(\"try {\");\n\t\tif (tryBranch) {\n\t\t\tbuildServerTryBranch(tryBranch, status, b);\n\t\t}\n\n\t\tconst catchVar = trimMatched(catchBranch.statement.substring(\"catch\".length).trim(), \"(\", \")\");\n\t\tb.append(`} catch (${catchVar || \"err\"}) {`);\n\t\tb.append(\"t_body = t_try_body;\");\n\t\tb.append(\"t_head = t_try_head;\");\n\t\tbuildServerTryBranch(catchBranch, status, b);\n\t\tb.append(\"}\");\n\t} else if (tryBranch) {\n\t\tbuildServerTryBranch(tryBranch, status, b);\n\t}\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n\nfunction buildServerTryBranch(node: ControlNode, status: BuildServerStatus, b: Builder) {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n\n\tflushOutput(status, b);\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerAwaitNode from \"./buildServerAwaitNode\";\nimport buildServerForNode from \"./buildServerForNode\";\nimport buildServerHtmlNode from \"./buildServerHtmlNode\";\nimport buildServerIfNode from \"./buildServerIfNode\";\nimport buildServerReplaceNode from \"./buildServerReplaceNode\";\nimport buildServerScriptNode from \"./buildServerScriptNode\";\nimport buildServerSwitchNode from \"./buildServerSwitchNode\";\nimport buildServerTryNode from \"./buildServerTryNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerControlNode(\n\tnode: ControlNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.operation) {\n\t\tcase \"@if group\": {\n\t\t\tbuildServerIfNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@if\":\n\t\tcase \"@else if\":\n\t\tcase \"@else\": {\n\t\t\t// These get handled with @if group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@switch group\": {\n\t\t\tbuildServerSwitchNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@case\":\n\t\tcase \"@default\": {\n\t\t\t// These get handled with @switch, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for group\": {\n\t\t\tbuildServerForNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@for\":\n\t\tcase \"@key\": {\n\t\t\t// These get handled with @for, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await group\": {\n\t\t\tbuildServerAwaitNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@await\":\n\t\tcase \"@with\":\n\t\tcase \"@try\":\n\t\tcase \"@catch\": {\n\t\t\t// These get handled with @await group or @try group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@try group\": {\n\t\t\tbuildServerTryNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace group\": {\n\t\t\tbuildServerReplaceNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@replace\": {\n\t\t\t// This gets handled with @replace group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html group\": {\n\t\t\tbuildServerHtmlNode(node, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@html\": {\n\t\t\t// This gets handled with @html group, above\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@const\": {\n\t\t\tflushOutput(status, b);\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@function\":\n\t\tcase \"@async function\": {\n\t\t\tflushOutput(status, b);\n\t\t\t//b.append(\"/* eslint-disable */\");\n\t\t\tb.append(\"\");\n\t\t\tbuildServerScriptNode(node, b);\n\t\t\tb.append(\"\");\n\t\t\t//b.append(\"/* eslint-enable */\");\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@console\":\n\t\tcase \"@debugger\": {\n\t\t\t// These can't be used on the server\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid operation: ${node.operation}`);\n\t\t}\n\t}\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport voidTags from \"../../utils/voidTags\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerElementNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tlet attributes = buildElementAttributes(node, status);\n\tif (attributes.length) {\n\t\tattributes = \" \" + attributes;\n\t}\n\n\tlet tagName = node.tagName;\n\tif (tagName === \"@element\") {\n\t\tlet selfAttribute = node.attributes.find((a) => a.name === \"self\");\n\t\tif (selfAttribute) {\n\t\t\ttagName = `$\\{${selfAttribute.value}}`;\n\t\t}\n\t}\n\n\t// NOTE: Only void tags can be self-closed in HTML, although we allow it in\n\t// templates and auto-expand it here\n\tstatus.output += `<${tagName}${attributes}>`;\n\tif (!voidTags.includes(tagName)) {\n\t\tconst oldPreserveWhitespace = status.preserveWhitespace;\n\t\tstatus.preserveWhitespace = [\"pre\", \"code\"].includes(tagName);\n\t\tfor (let child of node.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\t\tstatus.preserveWhitespace = oldPreserveWhitespace;\n\t\tstatus.output += `</${tagName}>`;\n\t}\n}\n\nfunction buildElementAttributes(node: ElementNode, status: BuildServerStatus) {\n\t// Elements in a @head block never get the scoped class name\n\tlet needsClass = node.scopeStyles && !status.inHead;\n\tlet attributes: string[] = [];\n\tfor (let { name, value, reactive, fullyReactive } of node.attributes) {\n\t\tif (name === \"self\" && node.tagName === \"@element\") {\n\t\t\t// Ignore this special attribute\n\t\t} else if (name === \"&ref\") {\n\t\t\t// No elements on the server\n\t\t} else if (name.startsWith(\"on\") || name.startsWith(\":on\")) {\n\t\t\t// No events on the server\n\t\t} else if (name.startsWith(\"transition\") && value) {\n\t\t\t// TODO: No animation on the server, but we do need to set the\n\t\t\t// attributes from the first keyframe\n\t\t\t// HACK: use a regex instead maybe?\n\t\t\t//value = value.split(\",\")[0].trim();\n\t\t\t//if (value.startsWith(\"[\")) {\n\t\t\t//\tvalue = value.substring(1);\n\t\t\t//} else {\n\t\t\t//\tvalue = value + \"[0]\";\n\t\t\t//}\n\t\t\t//attributes.push(\n\t\t\t//\t`style=\"\\${Object.entries(${value}).map(([k, v]) => \\`$\\{k}: $\\{v}\\`).join(\"; \")}\"`,\n\t\t\t//);\n\t\t} else if (value != null && fullyReactive) {\n\t\t\tif (name === \"&value\" || name === \"&checked\" || name === \"&group\") {\n\t\t\t\t// <select multiple> doesn't use a value attribute; the client\n\t\t\t\t// sets option.selected during hydration\n\t\t\t\tif (\n\t\t\t\t\tname === \"&value\" &&\n\t\t\t\t\tnode.tagName === \"select\" &&\n\t\t\t\t\tnode.attributes.some((a) => a.name === \"multiple\")\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet defaultValue = \"\";\n\t\t\t\tlet typeAttribute = node.attributes.find((a) => a.name === \"type\");\n\t\t\t\tif (typeAttribute && typeAttribute.value) {\n\t\t\t\t\tswitch (trimQuotes(typeAttribute.value)) {\n\t\t\t\t\t\tcase \"number\": {\n\t\t\t\t\t\t\tdefaultValue = \"0\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"checkbox\": {\n\t\t\t\t\t\t\tdefaultValue = \"false\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!defaultValue) {\n\t\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\t\tvalue = `t_attr(${value})`;\n\t\t\t\t\tdefaultValue = '\"\"';\n\t\t\t\t}\n\t\t\t\tlet valueOrDefault = `${value} || ${defaultValue}`;\n\t\t\t\tconst propName = name.substring(1);\n\t\t\t\tattributes.push(`${propName}=\"\\${${valueOrDefault}}\"`);\n\t\t\t} else if (name === \"class\") {\n\t\t\t\tstatus.imports.add(\"t_class\");\n\t\t\t\tlet params = [value];\n\t\t\t\tif (node.scopeStyles && !status.inHead) {\n\t\t\t\t\tparams.push(`\"torp-${status.styleHash}\"`);\n\t\t\t\t\tneedsClass = false;\n\t\t\t\t}\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// HACK: don't call t_class twice -- maybe there should be a buildServerClasses?\n\t\t\t\tvalue = params.join(\", \");\n\t\t\t\tattributes.push(`\\${t_class(${value}) !== \"\" ? \\`class=\"\\${t_class(${value})}\"\\` : \"\"}`);\n\t\t\t} else if (name === \"style\") {\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// HACK: don't call t_style twice -- maybe there should be a buildServerStyles?\n\t\t\t\tstatus.imports.add(\"t_style\");\n\t\t\t\tattributes.push(`\\${t_style(${value}) !== \"\" ? \\`style=\"\\${t_style(${value})}\"\\` : \"\"}`);\n\t\t\t} else {\n\t\t\t\t// Only set the attribute if the value is truthy\n\t\t\t\t// e.g. `... ${className ? `class=\"${className}\"` : ''} ...`\n\t\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\t\tattributes.push(`\\${${value} ? \\`${name}=\"\\${t_attr(${value})}\"\\` : \"\"}`);\n\t\t\t}\n\t\t} else if (value != null && reactive) {\n\t\t\t// TODO: Match braces, don't replace braces inside code\n\t\t\tstatus.imports.add(\"t_attr\");\n\t\t\tattributes.push(\n\t\t\t\t`${name}=\"${trimQuotes(value).replaceAll(\"{\", \"${t_attr(\").replaceAll(\"}\", \")}\")}\"`,\n\t\t\t);\n\t\t} else if (name === \"class\" && node.scopeStyles && !status.inHead) {\n\t\t\tvalue = value\n\t\t\t\t? `\"${trimQuotes(value)} torp-${status.styleHash}\"`\n\t\t\t\t: `\"torp-${status.styleHash}\"`;\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t\tneedsClass = false;\n\t\t} else if (value != null) {\n\t\t\t// Just set the attribute\n\t\t\t// TODO: Probably check if it's a boolean attribute e.g. disabled\n\t\t\tattributes.push(`${name}=\"${trimQuotes(value).replaceAll('\"', \"&quot;\")}\"`);\n\t\t} else {\n\t\t\tattributes.push(`${name}`);\n\t\t}\n\t}\n\tif (needsClass) {\n\t\tattributes.push(`class=\"torp-${status.styleHash}\"`);\n\t}\n\treturn attributes.join(\" \");\n}\n","import type RootNode from \"../../types/nodes/RootNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\n\nexport default function buildServerRootNode(\n\tnode: RootNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tfor (let child of node.children) {\n\t\tbuildServerNode(child, status, b);\n\t}\n}\n","import {\n\tANCHOR_COMMENT,\n\tHYDRATION_END_COMMENT,\n\tHYDRATION_START_COMMENT,\n} from \"../../types/comments\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport isSpecialNode from \"../../utils/isSpecialNode\";\nimport trimQuotes from \"../../utils/trimQuotes\";\nimport nextVarName from \"../utils/nextVarName\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nexport default function buildServerSlotNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\t// Surround the entire control statement with bracketed comments, so that we\n\t// can skip to the end to set the anchor node when hydrating\n\tstatus.output += HYDRATION_START_COMMENT;\n\n\tflushOutput(status, b);\n\n\t// If there's a slot, build that, otherwise build the default nodes\n\tlet slotName = node.attributes.find((a) => a.name === \"name\")?.value;\n\tslotName = slotName ? trimQuotes(slotName) : \"_\";\n\n\t// Slot props\n\tconst propsName = nextVarName(\"slot_props\", status);\n\tconst slotAttributes = node.attributes.filter((a) => a.name !== \"name\");\n\tconst slotHasProps = slotAttributes.length;\n\tif (slotHasProps) {\n\t\t// TODO: defaults etc props\n\t\tb.append(`const ${propsName}: any = {};`);\n\t\tfor (let { name, value } of slotAttributes) {\n\t\t\tif (value != null) {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = ${value};`);\n\t\t\t} else {\n\t\t\t\tb.append(`${propsName}[\"${name}\"] = true;`);\n\t\t\t}\n\t\t}\n\t}\n\n\tb.append(`if ($slots && $slots[\"${slotName}\"]) {`);\n\t// Slot fills are async (they may contain an @await boundary), so await\n\t// the string they resolve to\n\tb.append(\n\t\t`${status.inHead ? \"t_head\" : \"t_body\"} += await $slots[\"${slotName}\"](${slotHasProps ? propsName : \"undefined\"}, $context);`,\n\t);\n\n\t// TODO: Not if there's only a single space node -- maybe check in parse\n\tconst fill = node.children.find(\n\t\t(c) => isSpecialNode(c) && (c.tagName === \"fill\" || c.tagName === \"filldef\"),\n\t);\n\tif (fill && isSpecialNode(fill) && fill.children.length) {\n\t\tb.append(`} else {`);\n\n\t\tfor (let child of fill.children) {\n\t\t\tbuildServerNode(child, status, b);\n\t\t}\n\n\t\tflushOutput(status, b);\n\t}\n\n\tb.append(`}`);\n\n\t// End the control statement\n\tstatus.output += HYDRATION_END_COMMENT;\n\n\t// Add the anchor node\n\tstatus.output += ANCHOR_COMMENT;\n}\n","import type ElementNode from \"../../types/nodes/ElementNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerSlotNode from \"./buildServerSlotNode\";\n\nexport default function buildServerSpecialNode(\n\tnode: ElementNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.tagName) {\n\t\tcase \"slot\": {\n\t\t\tbuildServerSlotNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"fill\":\n\t\tcase \"filldef\": {\n\t\t\t// HACK:\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@element\": {\n\t\t\tbuildServerElementNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"@component\": {\n\t\t\tbuildServerComponentNode(node, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid special node: ${node.tagName}`);\n\t\t}\n\t}\n}\n","import type TextNode from \"../../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"../../utils/codeScanner\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\n\nexport default function buildServerTextNode(node: TextNode, status: BuildServerStatus): void {\n\tlet content = node.content || \"\";\n\n\tif (!status.preserveWhitespace) {\n\t\t// Replace all spaces with a single space, both to save space and to remove\n\t\t// newlines from generated JS strings\n\t\tcontent = content.replaceAll(/\\s+/g, \" \");\n\t}\n\n\t// TODO: Move all of this logic into parse, for text nodes and attribute values\n\tlet level = 0;\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst char = content[i];\n\t\tif (char === \"{\") {\n\t\t\tlevel++;\n\t\t\tif (level === 1) {\n\t\t\t\tstatus.imports.add(\"t_fmt\");\n\t\t\t\tstatus.output += \"${t_fmt(\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel--;\n\t\t\tif (level === 0) {\n\t\t\t\tstatus.output += \")\";\n\t\t\t}\n\t\t} else if (char === \"`\" && level === 0) {\n\t\t\t// Escape backticks outside of braces, as they will be within a backtick string\n\t\t\tstatus.output += \"\\\\\";\n\t\t} else if (level > 0) {\n\t\t\tconst skipped = skipStringOrComment(content, i);\n\t\t\tif (skipped !== -1) {\n\t\t\t\t// Copy strings, template strings, comments and regex literals\n\t\t\t\t// into the output as-is. HTML escaping is done at runtime by the\n\t\t\t\t// server's t_fmt, so that literals keep their original meaning.\n\t\t\t\tstatus.output += content.substring(i, skipped);\n\t\t\t\ti = skipped - 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tstatus.output += char;\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type RootNode from \"../../types/nodes/RootNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\nimport Builder from \"../../utils/Builder\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerComponentNode from \"./buildServerComponentNode\";\nimport buildServerControlNode from \"./buildServerControlNode\";\nimport buildServerElementNode from \"./buildServerElementNode\";\nimport buildServerRootNode from \"./buildServerRootNode\";\nimport buildServerSpecialNode from \"./buildServerSpecialNode\";\nimport buildServerTextNode from \"./buildServerTextNode\";\n\nexport default function buildServerNode(\n\tnode: TemplateNode,\n\tstatus: BuildServerStatus,\n\tb: Builder,\n): void {\n\tswitch (node.type) {\n\t\tcase \"root\": {\n\t\t\tbuildServerRootNode(node as RootNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"control\": {\n\t\t\tbuildServerControlNode(node as ControlNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"component\": {\n\t\t\tbuildServerComponentNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"element\": {\n\t\t\tbuildServerElementNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"text\": {\n\t\t\tbuildServerTextNode(node as TextNode, status);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"special\": {\n\t\t\tbuildServerSpecialNode(node as ElementNode, status, b);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"comment\": {\n\t\t\t// Don't output comments!\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// eslint-disable-next-line restrict-template-expressions\n\t\t\tthrow new Error(`Invalid node type: ${node.type}`);\n\t\t}\n\t}\n}\n","import type Template from \"../../../types/Template\";\nimport type BuildOptions from \"../../types/BuildOptions\";\nimport type ParentNode from \"../../types/nodes/ParentNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport Builder from \"../../utils/Builder\";\nimport { codeRanges } from \"../../utils/codeScanner\";\nimport collectMarkupExpressions from \"../../utils/collectMarkupExpressions\";\nimport isControlNode from \"../../utils/isControlNode\";\nimport markupRendersComponent from \"../../utils/markupRendersComponent\";\nimport buildStyles from \"../client/buildStyles\";\nimport type BuildServerStatus from \"./BuildServerStatus\";\nimport buildServerNode from \"./buildServerNode\";\nimport flushOutput from \"./flushOutput\";\n\nconst importsMap: Record<string, string> = {\n\t$watch: 'import { $watch } from \"${folder}\";',\n\t$bind: 'import { $bind } from \"${folder}\";',\n\t$cache: 'import { $cache } from \"${folder}\";',\n\t$async: 'import { $async } from \"${folder}\";',\n\t$pending: 'import { $pending } from \"${folder}\";',\n\t$refresh: 'import { $refresh } from \"${folder}\";',\n\t$run: 'import { $run } from \"${folder}\";',\n\t$onmount: 'import { $onmount } from \"${folder}\";',\n\t$stream: 'import { $stream } from \"${folder}\";',\n\tfromElement: 'import { fromElement } from \"${folder}\";',\n\tfromServer: 'import { fromServer } from \"${folder}\";',\n\tfromWebSocket: 'import { fromWebSocket } from \"${folder}\";',\n\t$unwrap: 'import { $unwrap } from \"${folder}\";',\n\t$peek: 'import { $peek } from \"${folder}\";',\n\t$batch: 'import { $batch } from \"${folder}\";',\n\tt_server_flush: 'import { t_server_flush } from \"${folder}\";',\n\tt_await_server: 'import { t_await_server } from \"${folder}\";',\n\tt_fmt: 'import { t_fmt } from \"${folder}\";',\n\tt_attr: 'import { t_attr } from \"${folder}\";',\n\tt_class: 'import { t_class } from \"${folder}\";',\n\tt_style: 'import { t_style } from \"${folder}\";',\n\tServerSlotRender: 'import { type ServerSlotRender } from \"${folder}\";',\n};\n\nexport default function buildServerCode(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder(options?.mapped);\n\n\t// Gather imports as we go so they can be placed at the top\n\tlet imports = new Set<string>();\n\timports.add(\"ServerSlotRender\");\n\n\t// Build the component and any child components\n\tbuildServerTemplate(template, imports, b, options);\n\n\t// Add the gathered imports in alphabetical order\n\tif (imports.size) {\n\t\tconst folder = options?.renderFolder ?? \"@torpor/view/ssr\";\n\t\tconst sortedImports = Array.from(imports)\n\t\t\t.map((imp) => (importsMap[imp] ?? imp).replace(\"${folder}\", folder))\n\t\t\t.sort()\n\t\t\t.reverse();\n\t\tb.prepend(\"\");\n\t\tfor (let imp of sortedImports) {\n\t\t\tb.prepend(imp);\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n\nfunction buildServerTemplate(\n\ttemplate: Template,\n\timports: Set<string>,\n\tb: Builder,\n\toptions?: BuildOptions,\n) {\n\t// TODO: Do this while looping chunks\n\tlet script = template.script.map((s) => s.script).join(\"\\n\");\n\n\t// Include markup expressions in import detection: `$`-primitives used\n\t// inside markup live in the template, not the script.\n\tfor (const component of template.components) {\n\t\tif (component.markup) script += \"\\n\" + collectMarkupExpressions(component.markup);\n\t\tif (component.error) script += \"\\n\" + collectMarkupExpressions(component.error);\n\t\tif (component.head) script += \"\\n\" + collectMarkupExpressions(component.head);\n\t}\n\n\t// Scan only the code in the script: strings, comments and regex literals\n\t// are stripped, so e.g. `$onmount` inside a sample-code string doesn't\n\t// inject an import that nothing uses\n\tlet scriptCode = codeRanges(script)\n\t\t.map(([start, end]) => script.substring(start, end))\n\t\t.join(\"\");\n\n\t// Add default imports\n\tif (/\\$watch\\b/.test(scriptCode)) imports.add(\"$watch\");\n\tif (/\\$bind\\b/.test(scriptCode)) imports.add(\"$bind\");\n\tif (/\\$cache\\b/.test(scriptCode)) imports.add(\"$cache\");\n\tif (/\\$async\\b/.test(scriptCode)) imports.add(\"$async\");\n\tif (/\\$pending\\b/.test(scriptCode)) imports.add(\"$pending\");\n\tif (/\\$refresh\\b/.test(scriptCode)) imports.add(\"$refresh\");\n\tif (/\\$run\\b/.test(scriptCode)) imports.add(\"$run\");\n\tif (/\\$onmount\\b/.test(scriptCode)) imports.add(\"$onmount\");\n\tif (/\\$stream\\b/.test(scriptCode)) imports.add(\"$stream\");\n\tif (/\\bfromElement\\b/.test(scriptCode)) imports.add(\"fromElement\");\n\tif (/\\bfromServer\\b/.test(scriptCode)) imports.add(\"fromServer\");\n\tif (/\\bfromWebSocket\\b/.test(scriptCode)) imports.add(\"fromWebSocket\");\n\tif (/\\$unwrap\\b/.test(scriptCode)) imports.add(\"$unwrap\");\n\tif (/\\$peek\\b/.test(scriptCode)) imports.add(\"$peek\");\n\tif (/\\$batch\\b/.test(scriptCode)) imports.add(\"$batch\");\n\n\t// Server components are async functions, so that a component containing a\n\t// `source: \"server\"` `@await` boundary can await its fetches and its\n\t// children can be awaited wherever they render (ASYNC.md → \"Server rendering\"). Find the\n\t// chunks holding each component's `function` declaration so they can be\n\t// rewritten on the way out, without mutating the shared parse result.\n\tconst asyncChunks = new Set<number>();\n\tfor (let [i, chunk] of template.script.entries()) {\n\t\tif (chunk.script === \"/* @params */\" && i > 0) {\n\t\t\tasyncChunks.add(i - 1);\n\t\t}\n\t}\n\n\tlet currentIndex = 0;\n\tlet current = template.components[0];\n\n\tfor (let [chunkIndex, chunk] of template.script.entries()) {\n\t\tif (chunk.script === \"/* @params */\") {\n\t\t\t// TODO: Support other params, like the user setting $context\n\t\t\tlet params = [\n\t\t\t\tcurrent.params ??\n\t\t\t\t\t`${current.props?.length ? \"$props: Record<PropertyKey, any>\" : \"_$props?: Record<PropertyKey, any>\"}`,\n\t\t\t\t`${\n\t\t\t\t\tcurrent.contextProps?.length ||\n\t\t\t\t\t(current.markup && markupRendersComponent(current.markup)) ||\n\t\t\t\t\t(current.error && markupRendersComponent(current.error))\n\t\t\t\t\t\t? \"$context\"\n\t\t\t\t\t\t: \"_$context\"\n\t\t\t\t}?: Record<PropertyKey, any>`,\n\t\t\t\t`${current.slotProps?.length ? \"$slots\" : \"_$slots\"}?: Record<string, ServerSlotRender>`,\n\t\t\t];\n\t\t\tb.append(params.join(\",\\n\") + \",\");\n\t\t} else if (chunk.script === \") /* @return_type */ {\") {\n\t\t\tb.append(\"): Promise<{ body: string; head: string }> {\");\n\t\t} else if (chunk.script === \"/* @start */\") {\n\t\t\t// Redefine $context so that any newly added properties will only be passed to children\n\t\t\tif (current.contextProps?.length) {\n\t\t\t\tb.append(`$context = Object.assign({}, $context);`);\n\t\t\t}\n\n\t\t\t// A component with an `@await` boundary renders inside a flush,\n\t\t\t// which starts its server fetches without blocking the render and\n\t\t\t// substitutes the resolved boundaries at the end\n\t\t\tconst hasAwait =\n\t\t\t\tcontainsAwaitGroup(current.markup) ||\n\t\t\t\tcontainsAwaitGroup(current.error) ||\n\t\t\t\tcontainsAwaitGroup(current.head);\n\t\t\tif (hasAwait) {\n\t\t\t\timports.add(\"t_server_flush\");\n\t\t\t\tb.append(`return t_server_flush(async () => {`);\n\t\t\t}\n\n\t\t\t// Declare t_head and t_body\n\t\t\tb.append(`let t_body = \"\";`);\n\t\t\tb.append(`let t_head = \"\";`);\n\t\t} else if (chunk.script === \"/* @render */\") {\n\t\t\tif (current.markup) {\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\tawaitCount: 0,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\t// Add the interface\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* User interface */\");\n\n\t\t\t\t// An @error block wraps the render in an implicit try/catch so\n\t\t\t\t// that render-time errors render the error content instead\n\t\t\t\tif (current.error) {\n\t\t\t\t\tb.append(`const t_try_body = t_body;`);\n\t\t\t\t\tb.append(`const t_try_head = t_head;`);\n\t\t\t\t\tb.append(\"try {\");\n\t\t\t\t}\n\n\t\t\t\tbuildServerNode(current.markup, status, b);\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @error */\") {\n\t\t\tif (current.markup && current.error) {\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\tawaitCount: 0,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\tb.append(`} catch (${current.errorVar}) {`);\n\t\t\t\tb.append(\"t_body = t_try_body;\");\n\t\t\t\tb.append(\"t_head = t_try_head;\");\n\n\t\t\t\tb.append(\"/* User interface error */\");\n\t\t\t\tbuildServerNode(current.error, status, b);\n\n\t\t\t\tif (status.output) {\n\t\t\t\t\tb.append(`t_body += \\`${status.output}\\`;`);\n\t\t\t\t\tstatus.output = \"\";\n\t\t\t\t}\n\n\t\t\t\tb.append(\"}\");\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @head */\") {\n\t\t\tif (current.head) {\n\t\t\t\t// Build the head tags (title, meta, etc) into the head string, so\n\t\t\t\t// that they can be hoisted into the document's <head> element.\n\t\t\t\t// The tags are built like any other markup (with the scoped\n\t\t\t\t// class name suppressed), only into t_head instead of t_body\n\t\t\t\tconst status: BuildServerStatus = {\n\t\t\t\t\timports,\n\t\t\t\t\toutput: \"\",\n\t\t\t\t\tstyleHash: current.style?.hash || \"\",\n\t\t\t\t\tvarNames: {},\n\t\t\t\t\tpreserveWhitespace: false,\n\t\t\t\t\tinHead: true,\n\t\t\t\t\tawaitCount: 0,\n\t\t\t\t\toptions,\n\t\t\t\t};\n\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Head */\");\n\n\t\t\t\tbuildServerNode(current.head, status, b);\n\n\t\t\t\tflushOutput(status, b);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @style */\") {\n\t\t\t//let userScript = script.substring(marker, i);\n\t\t\t//if (/[^\\s]/.test(userScript)) {\n\t\t\t//\tuserScript = \"\\n/* eslint-disable */\\n\" + userScript.trim() + \"\\n/* eslint-enable */\";\n\t\t\t//\tb.append(userScript);\n\t\t\t//}\n\n\t\t\tif (current.style) {\n\t\t\t\tb.append(\"\");\n\t\t\t\tb.append(\"/* Style */\");\n\n\t\t\t\t// Replace multiple spaces with a single space\n\t\t\t\tconst styles = buildStyles(current.style, current.style.hash)\n\t\t\t\t\t.replaceAll('\"', '\\\\\"')\n\t\t\t\t\t.replaceAll(/\\s+/g, \" \");\n\t\t\t\tb.append(`t_head += \"<style id='${current.style.hash}'>${styles}</style>\";\\n`);\n\t\t\t}\n\t\t} else if (chunk.script === \"/* @end */\") {\n\t\t\tb.append(`return { body: t_body, head: t_head };`);\n\n\t\t\t// Close the flush opened in @start\n\t\t\tif (\n\t\t\t\tcontainsAwaitGroup(current.markup) ||\n\t\t\t\tcontainsAwaitGroup(current.error) ||\n\t\t\t\tcontainsAwaitGroup(current.head)\n\t\t\t) {\n\t\t\t\tb.append(`});`);\n\t\t\t}\n\n\t\t\tcurrentIndex += 1;\n\t\t\tcurrent = template.components[currentIndex];\n\t\t} else {\n\t\t\t// The component's `function` declaration chunk: make it async. A\n\t\t\t// declaration the user already wrote as `async function` doesn't\n\t\t\t// match (the lookbehind skips it), so it passes through unchanged.\n\t\t\t// The name may carry generic parameters (`function Form<T>(`).\n\t\t\tif (asyncChunks.has(chunkIndex)) {\n\t\t\t\tb.append(\n\t\t\t\t\tchunk.script.replace(\n\t\t\t\t\t\t/(?<!async\\s)function\\s+([A-Za-z_$][\\w$]*)((?:<(?:[^<>]|<[^<>]*>)*>)?)\\s*\\($/,\n\t\t\t\t\t\t\"async function $1$2(\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tb.append(chunk.script);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Whether a markup tree contains an `@await` boundary, so the component's\n * render must be wrapped in a flush.\n */\nfunction containsAwaitGroup(node: TemplateNode | undefined | null): boolean {\n\tif (node === undefined || node === null) {\n\t\treturn false;\n\t}\n\tif (isControlNode(node) && node.operation === \"@await group\") {\n\t\treturn true;\n\t}\n\t// Text and comment nodes have no children; everything else is a ParentNode\n\tif (node.type !== \"text\" && node.type !== \"comment\") {\n\t\tfor (let child of (node as ParentNode).children) {\n\t\t\tif (containsAwaitGroup(child)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n","import isSpace from \"../parse/utils/isSpace\";\nimport type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isControlNode from \"./isControlNode\";\nimport isTextNode from \"./isTextNode\";\nimport { NON_RENDERING_OPERATIONS } from \"./nonRenderingOperations\";\n\n/**\n * Tag names whose contents should keep all whitespace untouched, matching\n * native HTML rendering of `pre`/`textarea` and the existing build-time\n * `preserveWhitespace` behavior for `code`.\n */\nconst PRESERVE_TAGS = new Set([\"pre\", \"textarea\", \"code\"]);\n\n/**\n * Container tags whose child layout ignores inter-child whitespace entirely\n * (table layout collapses it). Inside these, whitespace-only text nodes\n * between children are removed rather than collapsed to a single space.\n */\nconst WHITESPACE_INSIGNIFICANT_TAGS = new Set([\n\t\"tr\",\n\t\"tbody\",\n\t\"thead\",\n\t\"tfoot\",\n\t\"colgroup\",\n\t\"table\",\n\t\"ul\",\n\t\"ol\",\n\t\"select\",\n]);\n\ntype ContainerNode = RootNode | ElementNode | ControlNode;\n\n/**\n * Trims and collapses whitespace text nodes in a parsed markup tree,\n * Svelte 5-style:\n *\n * - pure-whitespace text nodes at the start/end of a container are removed\n * - pure-whitespace text nodes between siblings are collapsed to a single space\n * (or removed entirely inside table/list containers where whitespace is\n * insignificant — see WHITESPACE_INSIGNIFICANT_TAGS)\n * - whitespace inside `pre`, `textarea`, and `code` is preserved\n *\n * Whitespace adjacent to non-rendering control nodes (e.g. `@key`, `@const`)\n * is treated as leading/trailing whitespace of the container and removed,\n * because those nodes produce no DOM output — without this rule, every row\n * of `@for { @key = ...; <tr>...</tr> }` would emit a phantom leading\n * whitespace text node.\n *\n * Mixed text nodes (containing non-whitespace content) are left untouched;\n * their internal whitespace continues to be collapsed at build time. The\n * walk mutates the tree in place and is idempotent.\n *\n * @param node The root node of the markup to trim (a component's markup or head)\n */\nexport default function trimWhitespace(node: ContainerNode): void {\n\ttrimChildren(node.children, false, undefined);\n}\n\nfunction trimChildren(\n\tchildren: TemplateNode[],\n\tpreserveAll: boolean,\n\tparentTag: string | undefined,\n): void {\n\t// Recurse depth-first so descendant containers are normalized before we\n\t// reason about siblings at this level\n\tfor (const child of children) {\n\t\tconst grandChildren = getChildren(child);\n\t\tif (grandChildren) {\n\t\t\tconst childTag = getTagName(child);\n\t\t\tconst childPreserve = preserveAll || PRESERVE_TAGS.has(childTag ?? \"\");\n\t\t\ttrimChildren(grandChildren, childPreserve, childTag);\n\t\t}\n\t}\n\n\tif (preserveAll) return;\n\n\t// Inside table/list containers, all inter-child whitespace is\n\t// insignificant — remove it rather than collapsing to a space\n\tif (parentTag !== undefined && WHITESPACE_INSIGNIFICANT_TAGS.has(parentTag)) {\n\t\tfor (let i = children.length - 1; i >= 0; i--) {\n\t\t\tif (isWhitespaceText(children[i])) {\n\t\t\t\tchildren.splice(i, 1);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\t// Compute leading/trailing masks that treat non-rendering control nodes\n\t// (e.g. @key, @const) as invisible, so that whitespace adjacent to them\n\t// is removed as if it were at the container edge. A whitespace text node\n\t// is \"effectively leading\" if no rendering sibling precedes it, and\n\t// \"effectively trailing\" if no rendering sibling follows it.\n\tconst length = children.length;\n\tconst hasRenderingBefore: boolean[] = Array.from({ length });\n\tconst hasRenderingAfter: boolean[] = Array.from({ length });\n\tlet seenBefore = false;\n\tlet seenAfter = false;\n\tfor (let i = 0; i < length; i++) {\n\t\thasRenderingBefore[i] = seenBefore;\n\t\tif (isRenderingSibling(children[i])) seenBefore = true;\n\t\tconst j = length - 1 - i;\n\t\thasRenderingAfter[j] = seenAfter;\n\t\tif (isRenderingSibling(children[j])) seenAfter = true;\n\t}\n\n\t// Remove pure-whitespace nodes at the effectively-leading or\n\t// effectively-trailing edges of the container\n\tfor (let i = length - 1; i >= 0; i--) {\n\t\tif (isWhitespaceText(children[i]) && (!hasRenderingBefore[i] || !hasRenderingAfter[i])) {\n\t\t\tchildren.splice(i, 1);\n\t\t}\n\t}\n\n\t// Collapse remaining pure-whitespace nodes (between rendering siblings) to one space\n\tfor (const child of children) {\n\t\tif (isTextNode(child) && child.content !== \"\" && isSpace(child.content)) {\n\t\t\tchild.content = \" \";\n\t\t}\n\t}\n}\n\n/**\n * Returns true if `node` is a \"rendering sibling\" — i.e. a node that produces\n * visible DOM output and therefore acts as a boundary between leading,\n * inter-sibling, and trailing whitespace. Whitespace text nodes themselves\n * (the subject of the trim) and non-rendering control nodes (e.g. @key,\n * @const) are not rendering siblings.\n */\nfunction isRenderingSibling(node: TemplateNode): boolean {\n\tif (isWhitespaceText(node)) return false;\n\tif (isControlNode(node) && NON_RENDERING_OPERATIONS.has(node.operation)) return false;\n\treturn true;\n}\n\nfunction getChildren(node: TemplateNode): TemplateNode[] | undefined {\n\tif (node.type === \"text\" || node.type === \"comment\") return undefined;\n\treturn (node as ContainerNode).children;\n}\n\nfunction getTagName(node: TemplateNode): string | undefined {\n\tif (node.type === \"element\" || node.type === \"component\" || node.type === \"special\") {\n\t\treturn (node as ElementNode).tagName;\n\t}\n\treturn undefined;\n}\n\nfunction isWhitespaceText(node: TemplateNode): node is TextNode {\n\treturn isTextNode(node) && node.content !== \"\" && isSpace(node.content);\n}\n","import type Template from \"../types/Template\";\nimport buildCode from \"./build/client/buildCode\";\nimport buildStyles from \"./build/client/buildStyles\";\nimport buildServerCode from \"./build/server/buildServerCode\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport type BuildResult from \"./types/BuildResult\";\nimport type SourceMapping from \"./types/SourceMapping\";\nimport trimWhitespace from \"./utils/trimWhitespace\";\n\n/**\n * Builds a component template into code and styles for rendering\n *\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The component's code and styles\n */\nexport default function build(template: Template, options?: BuildOptions): BuildResult {\n\t// Trim whitespace text nodes (Svelte 5-style) unless explicitly disabled.\n\t// The pass mutates the tree in place but is idempotent, so it is safe even\n\t// when build is called twice (client + server) on the same template.\n\tif (!options?.preserveWhitespace) {\n\t\tfor (const component of template.components) {\n\t\t\tif (component.markup) trimWhitespace(component.markup);\n\t\t\tif (component.error) trimWhitespace(component.error);\n\t\t\tif (component.head) trimWhitespace(component.head);\n\t\t}\n\t}\n\n\tlet map: SourceMapping[] = [];\n\tlet code = options?.server\n\t\t? buildServerCode(template, options)\n\t\t: buildCode(template, map, options);\n\tlet styles = template.components\n\t\t.map((c) =>\n\t\t\tc.style ? { style: buildStyles(c.style, c.style.hash), hash: c.style.hash } : undefined,\n\t\t)\n\t\t.filter((c) => c !== undefined);\n\treturn {\n\t\tcode,\n\t\tstyles,\n\t\tmap,\n\t};\n}\n","import type Template from \"../types/Template\";\nimport type BuildOptions from \"./types/BuildOptions\";\nimport Builder from \"./utils/Builder\";\n\n/**\n * Builds a component template into a d.ts file\n *\n * @param name The name of the component\n * @param template The component template, possibly including script, markup and styles\n *\n * @returns The d.ts file content\n */\nexport default function buildType(template: Template, options?: BuildOptions): string {\n\tlet b = new Builder();\n\n\tb.append(`import { type SlotRender } from \"${options?.renderFolder || \"@torpor/view\"}\";`);\n\n\tfor (let component of template.components) {\n\t\tif (component.exported) {\n\t\t\tb.append(\"\");\n\t\t\tif (component.propsType) {\n\t\t\t\tb.append(component.propsType);\n\t\t\t\tb.append(\"\");\n\t\t\t}\n\t\t\tb.append(`\n\t\t\t${component.documentation ?? \"\"}\n\t\t\t${component.default ? \"declare\" : \"export declare\"} function ${component.name}${\n\t\t\t\tcomponent.typeParams ?? \"\"\n\t\t\t}(\n\t\t\t\t$parent: ParentNode,\n\t\t\t\t$anchor: Node | null,\n\t\t\t\t${component.params || \"$props?: Record<PropertyKey, any>\"},\n\t\t\t\t$context?: Record<PropertyKey, any>,\n\t\t\t\t$slots?: Record<string, SlotRender>,\n\t\t\t): void;\n\t\t`);\n\t\t\tif (component.default) {\n\t\t\t\tb.append(`export default ${component.name};`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn b.toString();\n}\n","/**\n * Returns the index of the closing backtick of the template string that\n * starts at `start`.\n *\n * NOTE: For scanning JavaScript expression text, use `codeScanner.ts` instead\n * -- this variant doesn't handle escaped characters or nested templates in\n * interpolations, and is kept only for non-JS contexts (CSS in `@style`\n * blocks) where a simpler scan is wanted.\n */\nexport default function endOfTemplateString(content: string, start: number): number {\n\t// TODO: Recursively skip strings and comments inside the interpolated JS\n\tlet level = 0;\n\tfor (let j = start + 1; j < content.length; j++) {\n\t\tif (content[j] === \"`\" && content[j - 1] !== \"\\\\\" && level === 0) {\n\t\t\treturn j;\n\t\t} else if (content[j] === \"{\" && (level > 0 || content[j - 1] === \"$\")) {\n\t\t\tlevel += 1;\n\t\t} else if (content[j] === \"}\" && level > 0) {\n\t\t\tlevel -= 1;\n\t\t}\n\t}\n\treturn content.length;\n}\n","import isSpace from \"../parse/utils/isSpace\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"./isTextNode\";\n\nexport default function isSpaceNode(node: TemplateNode): node is TextNode {\n\treturn isTextNode(node) && isSpace(node.content);\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function accept(value: string, status: ParseStatus, advance = true): boolean {\n\tconst check = status.source.substring(status.i, status.i + value.length);\n\tif (check == value) {\n\t\tstatus.i += advance ? value.length : 0;\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\nimport { skipStringOrComment } from \"../utils/codeScanner\";\n\nexport default function parseInlineScript(status: ParseStatus): string {\n\tconst start = status.i;\n\tlet braceCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tconst skipped = skipStringOrComment(status.source, status.i);\n\t\tif (skipped !== -1) {\n\t\t\tstatus.i = skipped;\n\t\t\tcontinue;\n\t\t}\n\t\tif (accept(\"{\", status)) {\n\t\t\tbraceCount += 1;\n\t\t} else if (accept(\"}\", status)) {\n\t\t\tif (braceCount > 0) {\n\t\t\t\tbraceCount -= 1;\n\t\t\t} else {\n\t\t\t\treturn status.source.substring(start, status.i - 1);\n\t\t\t}\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n","/**\n * Trims a char from the start of the supplied text\n *\n * @param text The text to trim\n * @param char The char to remove from the start of the text\n *\n * @returns The text without the char on the start\n */\nexport default function trimStart(text: string, char: string): string {\n\tlet start = 0;\n\twhile (text[start] === char) {\n\t\tstart += 1;\n\t}\n\treturn text.substring(start);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isSpaceChar from \"./isSpaceChar\";\n\n/**\n * Consumes space characters and advances the current parse position to before\n * the next non-space character\n *\n * @param status The parse status\n *\n * @returns The string of space characters from the current parse position to\n * the next non-space character\n */\nexport default function consumeSpace(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isSpaceChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function addSpaceElement(\n\tparent: ElementNode | ControlNode,\n\tstatus: ParseStatus,\n): void {\n\tconst content = consumeSpace(status);\n\tif (content) {\n\t\tconst previousNode = parent.children[parent.children.length - 1];\n\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\tpreviousNode.content += content;\n\t\t} else {\n\t\t\tconst space: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tparent.children.push(space);\n\t\t}\n\t}\n}\n","/**\n * Checks whether the supplied string is fully reactive (i.e. starts and ends with braces)\n *\n * @param text The string to check\n *\n * @returns True if the supplied string is fully reactive\n */\nexport default function isFullyReactive(text: string): boolean {\n\t// TODO: Need to be more fancy (check that braces match, ignore comments and strings etc)\n\treturn text.trim().startsWith(\"{\") && text.trim().endsWith(\"}\");\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Adds an error to the parse status\n *\n * @param status The parse status\n * @param message The error message to add\n * @param start (Optional) The start position of the error (defaults to the\n * current parse position)\n */\nexport default function addError(\n\tstatus: ParseStatus,\n\tmessage: string,\n\tstart: number = status.i,\n\tend: number = status.i,\n): void {\n\tlet startLine = 0;\n\tlet lastLineStart = 0;\n\tlet i = 0;\n\tfor (; i < start; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tstartLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet startChar = start - lastLineStart;\n\tlet endLine = startLine;\n\tfor (; i < end; i++) {\n\t\tif (status.source[i] === \"\\n\") {\n\t\t\tendLine += 1;\n\t\t\tlastLineStart = i + 1;\n\t\t}\n\t}\n\tlet endChar = end - lastLineStart;\n\tstatus.errors.push({\n\t\tmessage,\n\t\tstartIndex: start,\n\t\tstartLine,\n\t\tstartChar,\n\t\tendIndex: end,\n\t\tendLine,\n\t\tendChar,\n\t});\n}\n","/**\n * Checks whether the supplied character is a alpha-numeric\n *\n * @param text The string to check\n * @param index The index of the character in the string\n *\n * @returns True if the supplied character is alpha-numeric\n */\nexport default function isAlphaNumericChar(text: string, index: number): boolean {\n\tlet code = text.charCodeAt(index);\n\treturn (\n\t\t// 0-9\n\t\t(code > 47 && code < 58) ||\n\t\t// A-Z\n\t\t(code > 64 && code < 91) ||\n\t\t// a-z\n\t\t(code > 96 && code < 123)\n\t);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport isAlphaNumericChar from \"./isAlphaNumericChar\";\n\n/**\n * Consumes alpha-numeric characters and advances the current parse position to\n * before the next non-alpha character\n *\n * @param status The parse status\n *\n * @returns The string of alpha-numeric characters from the current parse position\n * to the next non-alpha character\n */\nexport default function consumeAlphaNumeric(status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (!isAlphaNumericChar(status.source, status.i)) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type ParseStatus from \"../ParseStatus\";\n\n/**\n * Consumes characters until one of the characters in the supplied string is\n * found. The parse position will be advanced to before the found character\n *\n * @param chars The characters to match\n * @param status The parse status\n *\n * @returns The string of characters from the current parse position to the\n * found character\n */\nexport default function consumeUntil(chars: string, status: ParseStatus): string {\n\tconst start = status.i;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tif (chars.includes(status.source[status.i])) {\n\t\t\treturn status.source.substring(start, status.i);\n\t\t}\n\t}\n\treturn \"\";\n}\n","import type Attribute from \"../types/nodes/Attribute\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isFullyReactive from \"../utils/isFullyReactive\";\nimport isReactive from \"../utils/isReactive\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport addError from \"./utils/addError\";\nimport accept from \"./utils/accept\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\n\nexport default function parseTag(status: ParseStatus): ElementNode {\n\taccept(\"<\", status);\n\n\tlet closeTag = accept(\"/\", status);\n\n\tconsumeSpace(status);\n\n\tlet tagStart = status.i + 1;\n\tlet snailed = accept(\"@\", status);\n\tlet tagName = consumeAlphaNumeric(status);\n\tlet tagEnd = status.i;\n\n\tif (snailed) {\n\t\ttagName = \"@\" + tagName;\n\t}\n\tif (closeTag) {\n\t\ttagName = \"/\" + tagName;\n\t}\n\n\tconsumeSpace(status);\n\n\tlet attributes = parseTagAttributes(status);\n\n\tlet selfClosed = false;\n\tif (accept(\"/>\", status)) {\n\t\tselfClosed = true;\n\t\t// Actually, it is kind of convenient to self-close things, and more consistent with\n\t\t// component tags...\n\t\t//if (!voidTags.includes(tagName)) {\n\t\t//\taddError(status, `Self-closed non-void element: ${tagName}`, start);\n\t\t//}\n\t} else {\n\t\taccept(\">\", status);\n\t}\n\n\tif (closeTag) {\n\t\tselfClosed = true;\n\t}\n\n\tlet special = [\"slot\", \"fill\", \"filldef\", \"@component\", \"@element\"].includes(tagName);\n\n\treturn {\n\t\ttype: special ? \"special\" : \"element\",\n\t\ttagName,\n\t\tselfClosed: selfClosed || undefined,\n\t\tclosed: selfClosed || undefined,\n\t\tattributes,\n\t\tchildren: [],\n\t\tspan: { start: tagStart, end: tagEnd },\n\t} satisfies ElementNode;\n}\n\nfunction parseTagAttributes(status: ParseStatus): Attribute[] {\n\tlet attributes: Attribute[] = [];\n\twhile (status.i < status.source.length) {\n\t\tconsumeSpace(status);\n\t\tif (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"/>\", status, false) || accept(\">\", status, false)) {\n\t\t\t// That's the end of the attributes\n\t\t\tbreak;\n\t\t} else if (\n\t\t\taccept(\"<\", status, false) ||\n\t\t\taccept(\"@\", status, false) ||\n\t\t\taccept(\"}\", status, false)\n\t\t) {\n\t\t\t// It's an unclosed tag -- just bail out here\n\t\t\tbreak;\n\t\t} else {\n\t\t\tconst attribute = parseAttribute(status);\n\t\t\tattributes.push(attribute);\n\t\t}\n\t}\n\treturn attributes;\n}\n\nfunction parseAttribute(status: ParseStatus): Attribute {\n\tlet valueStart = status.i;\n\tlet valueEnd = status.i;\n\tlet name = consumeUntil(\"= \\t\\r\\n/>\", status);\n\tlet value: string | undefined = undefined;\n\tlet reactive = false;\n\tlet fullyReactive = false;\n\tconsumeSpace(status);\n\tif (accept(\"=\", status)) {\n\t\tconsumeSpace(status);\n\t\tvalueStart = status.i;\n\t\tvalue = parseAttributeValue(status);\n\t\tvalueEnd = status.i;\n\t\treactive = isReactive(value);\n\t\tfullyReactive = isFullyReactive(value);\n\t\tif (fullyReactive) {\n\t\t\tvalue = value.substring(1, value.length - 1);\n\t\t\tvalueStart++;\n\t\t\tvalueEnd--;\n\t\t}\n\t} else if (name.startsWith(\"{\") && name.endsWith(\"}\")) {\n\t\tvalue = name.substring(1, name.length - 1);\n\t\tvalueStart++;\n\t\tvalueEnd = valueStart + name.length;\n\t\tif (value.startsWith(\"...\")) {\n\t\t\t// It's a spread attribute, just set the name to the value\n\t\t\tname = value;\n\t\t} else {\n\t\t\t// It's a shortcut attribute. It could be e.g. {width} or it could be\n\t\t\t// {$state.width}, but in either case we set the value of the width\n\t\t\t// property\n\t\t\tname = value.split(\".\").at(-1)!;\n\t\t}\n\t\t// Handle definite assignment assertions e.g. {$state.width!}\n\t\tif (name.endsWith(\"!\")) {\n\t\t\tname = name.substring(0, name.length - 1);\n\t\t}\n\t\treactive = fullyReactive = true;\n\t}\n\n\tif (value != null && reactive && value.startsWith(\"...\")) {\n\t\t// Spread attributes aren't supported -- spell the attributes (or\n\t\t// props) out explicitly instead\n\t\taddError(status, `Spread attributes are not supported`, valueStart, valueEnd);\n\t}\n\n\treturn {\n\t\tname,\n\t\tvalue,\n\t\treactive,\n\t\tfullyReactive,\n\t\tspan: { start: valueStart, end: valueEnd },\n\t};\n}\n\nfunction parseAttributeValue(status: ParseStatus): string {\n\tif (accept('\"', status)) {\n\t\tconst value = consumeUntil('\"', status);\n\t\taccept('\"', status);\n\t\treturn `\"${value}\"`;\n\t} else if (accept(\"'\", status)) {\n\t\tconst value = consumeUntil(\"'\", status);\n\t\taccept(\"'\", status);\n\t\treturn `'${value}'`;\n\t} else if (accept(\"{\", status)) {\n\t\tconst value = parseInlineScript(status);\n\t\treturn `{${value}}`;\n\t} else {\n\t\tlet value = consumeUntil(\" \\t\\r\\n>\", status);\n\t\t// Check whether we've landed at /> and if so, rewind\n\t\tif (status.source.substring(status.i - 1, status.i + 1) === \"/>\") {\n\t\t\tvalue = value.substring(0, value.length - 1);\n\t\t\tstatus.i -= 1;\n\t\t}\n\t\treturn value;\n\t}\n}\n","import type SourceSpan from \"../types/SourceSpan\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport { skipStringOrComment } from \"../utils/codeScanner\";\nimport isTextNode from \"../utils/isTextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseText(status: ParseStatus, element: ElementNode): void {\n\t// Add a range for each reactive part of the text so that we can map them\n\t// back when building\n\tlet spans: SourceSpan[] = [];\n\n\t// Text ends at the next element, or at the next control statement, or at\n\t// the end of the render\n\t// But only if the control statement is after a newline, so we don't mess\n\t// with emails etc. This may need more finessing\n\tconst start = status.i;\n\tlet end = -1;\n\tfor (let j = status.i; j < status.source.length; j++) {\n\t\tif (status.source[j] === \"}\") {\n\t\t\t// That's the rendering done\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"{\") {\n\t\t\t// Skip reactive content\n\t\t\tconst reactiveStart = j + 1;\n\t\t\tlet level = 0;\n\t\t\tfor (let k = j; k < status.source.length; k++) {\n\t\t\t\tconst char = status.source[k];\n\t\t\t\tif (char === \"{\") {\n\t\t\t\t\tlevel += 1;\n\t\t\t\t} else if (char === \"}\") {\n\t\t\t\t\tlevel -= 1;\n\t\t\t\t\tif (level === 0) {\n\t\t\t\t\t\tj = k;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Skip strings, template strings, comments and regex literals\n\t\t\t\t\tconst skipped = skipStringOrComment(status.source, k);\n\t\t\t\t\tif (skipped !== -1) {\n\t\t\t\t\t\tk = skipped - 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add the source range\n\t\t\tspans.push({ start: reactiveStart, end: j });\n\t\t} else if (status.source[j] === \"<\") {\n\t\t\tend = j;\n\t\t} else if (status.source[j] === \"@\") {\n\t\t\t// Backtrack\n\t\t\tfor (let k = j - 1; k > status.i; k--) {\n\t\t\t\tif (status.source[k] === \"\\n\") {\n\t\t\t\t\tend = j;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (!isSpaceChar(status.source, k)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (end !== -1) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (end !== -1) {\n\t\tconst content = status.source.substring(start, end).trimEnd();\n\t\tconst spaceContent = status.source.substring(start + content.length, end);\n\t\tif (content || spaceContent) {\n\t\t\tconst previousNode = element.children[element.children.length - 1];\n\t\t\tif (previousNode && isTextNode(previousNode)) {\n\t\t\t\tpreviousNode.content += content + spaceContent;\n\t\t\t\tpreviousNode.spans.push(...spans);\n\t\t\t\t//previousNode.range.endIndex += content.length + spaceContent.length;\n\t\t\t\t// TODO: end char etc\n\t\t\t} else {\n\t\t\t\tconst text: TextNode = {\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\tcontent: content + spaceContent,\n\t\t\t\t\tspans,\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t}\n\t\t}\n\t\tstatus.i = end;\n\t} else {\n\t\tstatus.i += 1;\n\t}\n}\n","import type ControlNode from \"../../types/nodes/ControlNode\";\nimport type ElementNode from \"../../types/nodes/ElementNode\";\nimport type TemplateNode from \"../../types/nodes/TemplateNode\";\nimport type TextNode from \"../../types/nodes/TextNode\";\n\nconst slotRegex = /\\$slot\\b/;\n\n/**\n * Checks whether the $slot variable is read in the nodes' own scope\n *\n * Note that the children of a component node are excluded, because they are\n * passed to the component as fills, which get their own $slot parameter.\n * The component's attributes do belong to this scope.\n *\n * @param nodes The nodes to check\n *\n * @returns True if a $slot variable is read in the nodes' own scope\n */\nexport default function usesSlot(nodes: TemplateNode[]): boolean {\n\tfor (let node of nodes) {\n\t\tif (node.type === \"text\") {\n\t\t\tconst text = node as TextNode;\n\t\t\tif (slotRegex.test(text.content)) return true;\n\t\t} else if (node.type === \"control\") {\n\t\t\tconst control = node as ControlNode;\n\t\t\tif (slotRegex.test(control.statement)) return true;\n\t\t\tif (usesSlot(control.children)) return true;\n\t\t} else if (node.type === \"element\" || node.type === \"special\" || node.type === \"component\") {\n\t\t\tconst element = node as ElementNode;\n\t\t\tfor (let attribute of element.attributes) {\n\t\t\t\tif (slotRegex.test(attribute.name)) return true;\n\t\t\t\tif (attribute.value && slotRegex.test(attribute.value)) return true;\n\t\t\t}\n\t\t\tif (element.type !== \"component\" && usesSlot(element.children)) return true;\n\t\t}\n\t}\n\treturn false;\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\nimport isSpaceNode from \"../utils/isSpaceNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\nimport usesSlot from \"./utils/usesSlot\";\n\n/**\n * Moves any child nodes that aren't already in a <fill> node into a default\n * <fill> node\n */\nexport default function slottifyChildNodes(node: ElementNode): void {\n\t// Gather nodes that are not in <fill> nodes, and not the spaces surrounding fill nodes\n\tlet nonFillNodes: TemplateNode[] = [];\n\tfor (let child of node.children) {\n\t\tif (isFillNode(child)) {\n\t\t\tif (nonFillNodes.find((n) => !isSpaceNode(n)) === undefined) {\n\t\t\t\tnonFillNodes = [];\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tnonFillNodes.push(child);\n\t\t}\n\t}\n\tif (nonFillNodes.find((n) => !isSpaceNode(n)) === undefined) {\n\t\tnonFillNodes = [];\n\t}\n\n\t// If we found any non-fill node nodes, move them into a default fill node\n\tif (nonFillNodes.length) {\n\t\tlet defaultFillNode = node.children.find(\n\t\t\t(n) => isFillNode(n) && !n.attributes.find((a) => a.name === \"name\"),\n\t\t) as ElementNode | undefined;\n\t\tif (!defaultFillNode) {\n\t\t\tdefaultFillNode = {\n\t\t\t\ttype: \"special\",\n\t\t\t\ttagName: \"filldef\",\n\t\t\t\tattributes: [],\n\t\t\t\tchildren: nonFillNodes,\n\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\thasSlotProps: usesSlot(nonFillNodes),\n\t\t\t};\n\t\t\tnode.children.unshift(defaultFillNode);\n\t\t}\n\t\tnode.children = node.children.filter((c) => isFillNode(c) || !nonFillNodes.includes(c));\n\t}\n}\n\nfunction isFillNode(n: TemplateNode): n is ElementNode {\n\treturn isSpecialNode(n) && (n.tagName === \"fill\" || n.tagName === \"filldef\");\n}\n","import type CommentNode from \"../types/nodes/CommentNode\";\nimport type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport isSpecialNode from \"../utils/isSpecialNode\";\nimport voidTags from \"../utils/voidTags\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseControl from \"./parseControl\";\nimport parseTag from \"./parseTag\";\nimport parseText from \"./parseText\";\nimport slottifyChildNodes from \"./slottifyChildNodes\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport usesSlot from \"./utils/usesSlot\";\n\nexport default function parseElement(status: ParseStatus): ElementNode {\n\tconst current = status.components.at(-1);\n\tif (!current) throw new Error(\"No component in stack\");\n\n\tconst start = status.i;\n\n\tconst element = parseTag(status);\n\n\tif (element.tagName.startsWith(\"/\")) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${element.tagName.substring(1)}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length,\n\t\t);\n\t\treturn element;\n\t}\n\n\tif (voidTags.includes(element.tagName)) {\n\t\tcheckVoidElement(status, element);\n\t}\n\n\tif (!element.selfClosed && !voidTags.includes(element.tagName)) {\n\t\tstatus.stack.push(element);\n\n\t\t// Get the children\n\t\twhile (status.i < status.source.length) {\n\t\t\taddSpaceElement(element, status);\n\t\t\tif (accept(\"}\", status, false)) {\n\t\t\t\t// That's the rendering done\n\t\t\t\tbreak;\n\t\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t\t// It's a comment, swallow it\n\t\t\t\tconst start = status.i;\n\t\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t\t\tconst text: CommentNode = {\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t\tcommentType: \"html\",\n\t\t\t\t\tcontent: status.source.substring(start, status.i - 3),\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t} else if (accept(\"@//\", status)) {\n\t\t\t\t// Swallow one-line comments\n\t\t\t\t// Swallow one-line comments\n\t\t\t\tconst start = status.i;\n\t\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t\t\tconst text: CommentNode = {\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t\tcommentType: \"line\",\n\t\t\t\t\tcontent: status.source.substring(start, status.i - 1),\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t\t// Swallow block comments\n\t\t\t\t// Swallow block comments\n\t\t\t\tconst start = status.i;\n\t\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t\t\tconst text: CommentNode = {\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t\tcommentType: \"block\",\n\t\t\t\t\tcontent: status.source.substring(start, status.i - 2),\n\t\t\t\t};\n\t\t\t\telement.children.push(text);\n\t\t\t} else if (accept(\"</\", status, false)) {\n\t\t\t\t// It's a close tag, so we're done here\n\t\t\t\tif (checkCloseTag(status, element)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t\t// It's a child element\n\t\t\t\tconst child = parseElement(status);\n\t\t\t\telement.children.push(child);\n\t\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t\t// It's a control statement\n\t\t\t\tparseControl(status, element);\n\t\t\t} else {\n\t\t\t\t// It's text content\n\t\t\t\tparseText(status, element);\n\t\t\t}\n\t\t}\n\n\t\tstatus.stack.pop();\n\t}\n\n\t// If this is a component element, add a default <fill> node\n\t// HACK: For now, we just treat all tags starting with a capital as components\n\tif (/[A-Z]/.test(element.tagName[0])) {\n\t\telement.type = \"component\";\n\t\tslottifyChildNodes(element);\n\t}\n\n\tif (isSpecialNode(element)) {\n\t\tif (element.tagName === \"slot\") {\n\t\t\t// If this is a <slot> element, add a <fill> node for its fallback\n\t\t\t// content. Anchors will be created for <slot> nodes and fragments will\n\t\t\t// be created for the <fill> content\n\t\t\tslottifyChildNodes(element);\n\n\t\t\t// Add it to the component's slots collection\n\t\t\tcurrent.slotProps ??= [];\n\t\t\tcurrent.slotProps.push(element.attributes.find((a) => a.name === \"name\")?.name ?? \"default\");\n\t\t} else if (element.tagName === \"fill\" || element.tagName === \"filldef\") {\n\t\t\telement.hasSlotProps = usesSlot(element.children);\n\t\t} else if (element.tagName === \"@component\") {\n\t\t\tconst selfAttribute = element.attributes.find((a) => a.name === \"self\");\n\t\t\tif (selfAttribute && selfAttribute.value && selfAttribute.fullyReactive) {\n\t\t\t\telement.type = \"component\";\n\t\t\t\tslottifyChildNodes(element);\n\n\t\t\t\tconst selfValue = selfAttribute.value;\n\t\t\t\tconst replace: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [element],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\t\t\t\tconst replaceGroup: ControlNode = {\n\t\t\t\t\ttype: \"control\",\n\t\t\t\t\toperation: \"@replace group\",\n\t\t\t\t\tstatement: selfValue,\n\t\t\t\t\tchildren: [replace],\n\t\t\t\t\tspan: { start: 0, end: 0 },\n\t\t\t\t};\n\n\t\t\t\treturn replaceGroup as any;\n\t\t\t} else {\n\t\t\t\taddError(\n\t\t\t\t\tstatus,\n\t\t\t\t\t\"@component element must have a self attribute\",\n\t\t\t\t\tstart,\n\t\t\t\t\tstart + element.tagName.length + 1,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!element.closed && !voidTags.includes(element.tagName)) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Unclosed non-void element: ${element.tagName}`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn element;\n}\n\nfunction checkVoidElement(status: ParseStatus, element: ElementNode) {\n\tlet i = status.i;\n\n\tconsumeSpace(status);\n\tif (accept(\"</\", status)) {\n\t\tconsumeSpace(status);\n\t\tif (accept(element.tagName, status)) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Closed void element: ${element.tagName}`,\n\t\t\t\ti,\n\t\t\t\ti + element.tagName.length + 1,\n\t\t\t);\n\t\t\tconsumeSpace(status);\n\t\t\taccept(\">\", status);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tstatus.i = i;\n}\n\nfunction checkCloseTag(status: ParseStatus, element: ElementNode) {\n\tconst start = status.i;\n\n\taccept(\"</\", status);\n\tconsumeSpace(status);\n\tlet snailed = accept(\"@\", status);\n\tlet closingTagName = consumeAlphaNumeric(status);\n\tif (snailed) {\n\t\tclosingTagName = \"@\" + closingTagName;\n\t}\n\tconsumeSpace(status);\n\taccept(\">\", status);\n\n\tlet found = false;\n\tfor (let i = status.stack.length - 1; i >= 0; i--) {\n\t\tif (closingTagName === status.stack[i].tagName) {\n\t\t\tstatus.stack[i].closed = true;\n\t\t\tfound = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!found) {\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Non-matching close tag: ${closingTagName} (expected ${element.tagName})`,\n\t\t\tstart,\n\t\t\tstart + element.tagName.length + 1,\n\t\t);\n\t}\n\n\treturn found;\n}\n","import type ControlNode from \"../types/nodes/ControlNode\";\nimport type ElementNode from \"../types/nodes/ElementNode\";\nimport type OperationType from \"../types/nodes/OperationType\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport { skipStringOrComment } from \"../utils/codeScanner\";\nimport isControlNode from \"../utils/isControlNode\";\nimport trimMatched from \"../utils/trimMatched\";\nimport trimStart from \"../utils/trimStart\";\nimport type ParseStatus from \"./ParseStatus\";\nimport addSpaceElement from \"./addSpaceElement\";\nimport parseElement from \"./parseElement\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nconst controlOperations = [\n\t\"@if\",\n\t\"@else\",\n\t\"@for\",\n\t\"@key\",\n\t\"@switch\",\n\t\"@case\",\n\t\"@default\",\n\t\"@await\",\n\t\"@with\",\n\t\"@try\",\n\t\"@catch\",\n\t\"@replace\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nconst standaloneOperations = [\n\t\"@key\",\n\t\"@html\",\n\t\"@const\",\n\t\"@console\",\n\t\"@debugger\",\n\t\"@function\",\n\t\"@async function\",\n];\n\nexport default function parseControl(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n): void {\n\tconst node = parseControlOpen(status);\n\tif (!node) {\n\t\treturn;\n\t}\n\n\t// Some operations don't have children\n\tif (standaloneOperations.includes(node.operation)) {\n\t\twrangleControlNode(node, parentNode, status);\n\t\treturn;\n\t}\n\n\t// Get the children\n\twhile (status.i < status.source.length) {\n\t\taddSpaceElement(node, status);\n\t\tif (accept(\"}\", status)) {\n\t\t\t// It's the end of the control block, so we're done here\n\t\t\tbreak;\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// It's a child element\n\t\t\tconst child = parseElement(status);\n\t\t\tnode.children.push(child);\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// It's a nested control\n\t\t\tparseControl(status, node);\n\t\t} else if (accept(\"case\", status, false) || accept(\"key\", status, false)) {\n\t\t\t// `case` and `key` can be bare in a control block\n\t\t\tparseControl(status, node);\n\t\t} else {\n\t\t\t// Can't have text content in control blocks\n\t\t\tconst char = status.source[status.i];\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t`Unexpected token in control block: ${char}`,\n\t\t\t\tstatus.i,\n\t\t\t\t// TODO: Should probably go until a boundary\n\t\t\t\tstatus.i + 1,\n\t\t\t);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twrangleControlNode(node, parentNode, status);\n\n\tparseControlBranches(status, parentNode);\n}\n\nfunction parseControlOpen(status: ParseStatus): ControlNode | null {\n\tconst start = status.i;\n\tlet statementStart = start;\n\n\tlet operation = \"\";\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (\n\t\t\t(isSpaceChar(status.source, status.i) && operation !== \"@async\") ||\n\t\t\t(accept(\":\", status) && operation === \"default\") ||\n\t\t\t(accept(\".\", status) && operation === \"@console\") ||\n\t\t\t(accept(\"(\", status, false) && operation === \"@html\")\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\toperation += char;\n\t}\n\n\t// Some operations (else etc) don't start with an @\n\tif (!operation.startsWith(\"@\")) {\n\t\toperation = \"@\" + operation;\n\t} else {\n\t\tstatementStart++;\n\t}\n\n\tlet statement = \"\";\n\tif (controlOperations.includes(operation)) {\n\t\tstatement = parseControlStatement(start, operation, status);\n\n\t\t// Special processing for functions -- read until the closing brace\n\t\tif (operation === \"@function\" || operation === \"@async function\") {\n\t\t\tstatement += ` {${parseInlineScript(status)}}`;\n\t\t\taccept(\"}\", status);\n\t\t}\n\n\t\t// Special processing for replace and html\n\t\tif (operation === \"@replace\" || operation === \"@html\") {\n\t\t\tstatement = trimMatched(statement.substring(statement.indexOf(\"(\")).trim(), \"(\", \")\");\n\t\t}\n\n\t\t// The old `@await (promise) { … } then (v) { … } catch (e) { … }`\n\t\t// control is removed (ASYNC.md → \"Roads not taken\"). The current `@await` is\n\t\t// the async boundary (formerly `@loading`): statement-less, with an\n\t\t// optional `with { … }` branch for the pending state.\n\t\tif (operation === \"@await\" && /^await\\s*\\(/.test(statement)) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\t\"old `@await (expr) { … } then (…) { … }` syntax is removed — use `@await { … } with { … }` with `$async` getters\",\n\t\t\t\tstart,\n\t\t\t\tstatus.i,\n\t\t\t);\n\t\t}\n\t} else {\n\t\t// TODO: Should probably advance until a closing brace or a newline\n\t\taddError(status, `Unknown operation: ${operation}`, status.i, status.i + operation.length);\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"control\",\n\t\toperation: operation as OperationType,\n\t\tstatement,\n\t\tchildren: [],\n\t\tspan: { start: statementStart, end: status.i },\n\t};\n}\n\nfunction parseControlStatement(start: number, operation: string, status: ParseStatus) {\n\tlet parenCount = 0;\n\twhile (status.i < status.source.length) {\n\t\tconst skipped = skipStringOrComment(status.source, status.i);\n\t\tif (skipped !== -1) {\n\t\t\tstatus.i = skipped;\n\t\t\tcontinue;\n\t\t}\n\t\tif (accept(\"(\", status)) {\n\t\t\tparenCount += 1;\n\t\t} else if (accept(\")\", status)) {\n\t\t\tparenCount -= 1;\n\t\t} else if (\n\t\t\taccept(\"{\", status) ||\n\t\t\t(accept(\"\\n\", status) && standaloneOperations.includes(operation))\n\t\t) {\n\t\t\tif (parenCount === 0) {\n\t\t\t\treturn trimStart(status.source.substring(start, status.i - 1).trim(), \"@\");\n\t\t\t}\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n\treturn \"\";\n}\n\n/**\n * Groups the control node into the correct parent e.g. if/else into an if group\n * @param node The control node\n * @param parentNode The parent node\n * @param status The parse status, for error reporting\n */\nfunction wrangleControlNode(\n\tnode: ControlNode,\n\tparentNode: RootNode | ElementNode | ControlNode,\n\tstatus: ParseStatus,\n) {\n\t// Group\n\t// * if/else into an if group\n\t// * for into a for group\n\t// * switch into a switch group (cases will have the correct parent)\n\t// * await/with into an await group\n\t// * try/catch into a try group\n\t// * replace into a replace group\n\t// * html into a html group\n\tif (node.operation === \"@if\") {\n\t\tconst ifGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@if group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(ifGroup);\n\t} else if (node.operation === \"@else\") {\n\t\tif (/^else\\s+if/.test(node.statement)) {\n\t\t\tnode.operation = \"@else if\";\n\t\t}\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@if group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@for\") {\n\t\tconst forGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@for group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(forGroup);\n\t}\n\t// @ts-ignore\n\telse if (node.operation === \"@switch\") {\n\t\tnode.operation = \"@switch group\";\n\t\tparentNode.children.push(node);\n\t} else if (node.operation === \"@await\") {\n\t\tconst awaitGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@await group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(awaitGroup);\n\t} else if (node.operation === \"@with\") {\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@await group\") {\n\t\t\t\tlastChild.children.push(node);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else if (node.operation === \"@catch\") {\n\t\t// `@catch` attaches only to the nearest `@try group` — and only\n\t\t// once; a second `@catch` on the same group would be silently\n\t\t// dropped by the builders\n\t\tlet attached = false;\n\t\tlet duplicate = false;\n\t\tfor (let i = parentNode.children.length - 1; i >= 0; i--) {\n\t\t\tconst lastChild = parentNode.children[i];\n\t\t\t// TODO: Break if it's an element, do more checking\n\t\t\tif (isControlNode(lastChild) && lastChild.operation === \"@try group\") {\n\t\t\t\tif (\n\t\t\t\t\tlastChild.children.some((child) => isControlNode(child) && child.operation === \"@catch\")\n\t\t\t\t) {\n\t\t\t\t\tduplicate = true;\n\t\t\t\t} else {\n\t\t\t\t\tlastChild.children.push(node);\n\t\t\t\t\tattached = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!attached) {\n\t\t\taddError(\n\t\t\t\tstatus,\n\t\t\t\tduplicate\n\t\t\t\t\t? \"`@try` cannot have more than one `@catch` block\"\n\t\t\t\t\t: \"`@catch` must follow a `@try` block\",\n\t\t\t\tnode.span.start,\n\t\t\t\tnode.span.end,\n\t\t\t);\n\t\t}\n\t} else if (node.operation === \"@try\") {\n\t\tconst tryGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@try group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(tryGroup);\n\t} else if (node.operation === \"@replace\") {\n\t\tconst replaceGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@replace group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(replaceGroup);\n\t} else if (node.operation === \"@html\") {\n\t\tconst htmlGroup: ControlNode = {\n\t\t\ttype: \"control\",\n\t\t\toperation: \"@html group\",\n\t\t\tstatement: \"\",\n\t\t\tchildren: [node],\n\t\t\tspan: { start: 0, end: 0 },\n\t\t};\n\t\tparentNode.children.push(htmlGroup);\n\t} else {\n\t\tparentNode.children.push(node);\n\t}\n}\n\n/**\n * Parses control branches that don't start with an @ symbol e.g. else or case\n * @param status The parse status\n * @param parentNode The parent node\n */\nfunction parseControlBranches(\n\tstatus: ParseStatus,\n\tparentNode: RootNode | ElementNode | ControlNode,\n) {\n\t// Look ahead and see if we have another control statement\n\t// NOTE: We could be more strict here (e.g. we could check that an else is\n\t// after an if), but for now we are just leaving it to the JS parser\n\tlet gotAnotherBranch = true;\n\twhile (gotAnotherBranch) {\n\t\tlet start = status.i;\n\t\tstatus.i += 1;\n\t\tconsumeSpace(status);\n\t\tif (\n\t\t\taccept(\"else\", status, false) ||\n\t\t\taccept(\"case\", status, false) ||\n\t\t\taccept(\"default\", status, false) ||\n\t\t\taccept(\"catch\", status, false) ||\n\t\t\taccept(\"with\", status, false)\n\t\t) {\n\t\t\tparseControl(status, parentNode);\n\t\t} else {\n\t\t\tgotAnotherBranch = false;\n\t\t\tstatus.i = start;\n\t\t}\n\t}\n}\n","import type CommentNode from \"../types/nodes/CommentNode\";\nimport type RootNode from \"../types/nodes/RootNode\";\nimport type TextNode from \"../types/nodes/TextNode\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseControl from \"./parseControl\";\nimport parseElement from \"./parseElement\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseMarkup(status: ParseStatus, source: string): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tparseMarkupInto(status, source, (root) => (current.markup ??= root));\n}\n\n/**\n * Parses markup into a root node, letting callers choose where the resulting\n * RootNode is stored (e.g. a component's `markup` or its `error` block).\n *\n * @param status The parse status\n * @param source The full source code\n * @param setRoot Called with a fresh root node the first time content is\n * parsed; subsequent content is appended to the same node.\n */\nexport function parseMarkupInto(\n\tstatus: ParseStatus,\n\tsource: string,\n\tsetRoot: (root: RootNode) => void,\n): void {\n\tlet root: RootNode | null = null;\n\tconst getRoot = () => (root ??= { type: \"root\", children: [] });\n\n\twhile (status.i < source.length) {\n\t\tif (accept(\"}\", status, false)) {\n\t\t\t// That's the rendering done\n\t\t\treturn;\n\t\t} else if (accept(\"<!--\", status)) {\n\t\t\t// It's a comment, swallow it\n\t\t\tconst start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"-->\", status.i) + 3;\n\t\t\tconst text: CommentNode = {\n\t\t\t\ttype: \"comment\",\n\t\t\t\tcommentType: \"html\",\n\t\t\t\tcontent: status.source.substring(start, status.i - 3),\n\t\t\t};\n\t\t\tsetRoot(getRoot());\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (accept(\"@//\", status)) {\n\t\t\t// Swallow one-line comments\n\t\t\tconst start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i) + 1;\n\t\t\tconst text: CommentNode = {\n\t\t\t\ttype: \"comment\",\n\t\t\t\tcommentType: \"line\",\n\t\t\t\tcontent: status.source.substring(start, status.i - 1),\n\t\t\t};\n\t\t\tsetRoot(getRoot());\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (accept(\"@/*\", status)) {\n\t\t\t// Swallow block comments\n\t\t\tconst start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 2;\n\t\t\tconst text: CommentNode = {\n\t\t\t\ttype: \"comment\",\n\t\t\t\tcommentType: \"block\",\n\t\t\t\tcontent: status.source.substring(start, status.i - 2),\n\t\t\t};\n\t\t\tsetRoot(getRoot());\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (isSpaceChar(status.source, status.i)) {\n\t\t\tsetRoot(getRoot());\n\t\t\tconst space = consumeSpace(status);\n\t\t\tconst text: TextNode = {\n\t\t\t\ttype: \"text\",\n\t\t\t\tcontent: space,\n\t\t\t\tspans: [],\n\t\t\t};\n\t\t\tgetRoot().children.push(text);\n\t\t} else if (accept(\"<\", status, false)) {\n\t\t\t// Parse the element\n\t\t\tsetRoot(getRoot());\n\t\t\tconst element = parseElement(status);\n\t\t\tgetRoot().children.push(element);\n\t\t} else if (accept(\"@\", status, false)) {\n\t\t\t// Parse the control\n\t\t\tsetRoot(getRoot());\n\t\t\tparseControl(status, getRoot());\n\t\t} else {\n\t\t\tstatus.i += 1;\n\t\t}\n\t}\n}\n","// Adapted from https://github.com/sveltejs/svelte\n\nconst returnRegex = /\\r/g;\n\nexport default function hash(input: string): string {\n\tinput = input.replace(returnRegex, \"\");\n\tlet hash = 5381;\n\tlet i = input.length;\n\twhile (i--) {\n\t\thash = ((hash << 5) - hash) ^ input.charCodeAt(i);\n\t}\n\treturn (hash >>> 0).toString(36);\n}\n","import type ParseStatus from \"../ParseStatus\";\nimport addError from \"./addError\";\n\n/**\n * Checks whether the source at the current parse position matches the supplied\n * string and if not, adds an error to the parse status\n *\n * @param value The string to check\n * @param status The parse status\n * @param advance (Optional) If true, advances the parse position past the\n * checked string (defaults to true)\n *\n * @returns True if the supplied string was found at the current parse position\n */\nexport default function expect(value: string, status: ParseStatus, advance = true): boolean {\n\tif (status.i < status.source.length) {\n\t\tif (status.source.substring(status.i, status.i + value.length) == value) {\n\t\t\tstatus.i += advance ? value.length : 0;\n\t\t\treturn true;\n\t\t} else {\n\t\t\taddError(status, `Expected ${value}`);\n\t\t}\n\t} else {\n\t\taddError(status, \"Expected token\");\n\t}\n\treturn false;\n}\n","import type AttributeNode from \"../types/styles/AttributeNode\";\nimport type BlockNode from \"../types/styles/BlockNode\";\nimport CommentNode from \"../types/styles/CommentNode\";\nimport type StyleNode from \"../types/styles/StyleNode\";\nimport hash from \"../utils/hash\";\nimport type ParseStatus from \"./ParseStatus\";\nimport accept from \"./utils/accept\";\nimport consumeSpace from \"./utils/consumeSpace\";\nimport consumeUntil from \"./utils/consumeUntil\";\nimport expect from \"./utils/expect\";\nimport isSpaceChar from \"./utils/isSpaceChar\";\n\nexport default function parseStyles(source: string, status: ParseStatus): void {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tcurrent.style = {\n\t\tglobal: false,\n\t\tchildren: [],\n\t\thash: hash(source),\n\t};\n\n\tconst styleStatus: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\tbraces: [],\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\twhile (styleStatus.i < styleStatus.source.length) {\n\t\tif (isSpaceChar(styleStatus.source, styleStatus.i)) {\n\t\t\tconsumeSpace(styleStatus);\n\t\t} else {\n\t\t\tconst node = parseStyleNode(styleStatus);\n\t\t\tif (node) {\n\t\t\t\tcurrent.style.children.push(node);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.errors = status.errors.concat(styleStatus.errors);\n}\n\nfunction parseStyleNode(status: ParseStatus): StyleNode | undefined {\n\tconst gapBefore = /\\n\\s*\\n\\s*$/.test(status.source.slice(0, status.i));\n\n\tif (accept(\"//\", status, false) || accept(\"/*\", status, false)) {\n\t\treturn parseComment(status, gapBefore);\n\t}\n\n\tconst selector = consumeUntil(\"{\", status).trim();\n\tif (expect(\"{\", status)) {\n\t\tconst block: BlockNode = {\n\t\t\ttype: \"block\",\n\t\t\tselector,\n\t\t\tchildren: [],\n\t\t\tgapBefore,\n\t\t};\n\t\tconsumeSpace(status);\n\t\twhile (status.source[status.i] !== \"}\") {\n\t\t\tif (accept(\"//\", status, false) || accept(\"/*\", status, false)) {\n\t\t\t\t// Comments are parsed but not emitted\n\t\t\t\tblock.children.push(parseComment(status, false));\n\t\t\t} else {\n\t\t\t\t// HACK: Is it an attribute or a child block?\n\t\t\t\tlet nextColon = status.source.indexOf(\":\", status.i);\n\t\t\t\tif (nextColon === -1) nextColon = status.source.length;\n\t\t\t\tlet nextOpenBrace = status.source.indexOf(\"{\", status.i);\n\t\t\t\tif (nextOpenBrace === -1) nextOpenBrace = status.source.length;\n\t\t\t\tif (nextColon < nextOpenBrace) {\n\t\t\t\t\tconst attribute = parseStyleAttribute(status);\n\t\t\t\t\tblock.children.push(attribute);\n\t\t\t\t} else if (nextOpenBrace < nextColon) {\n\t\t\t\t\tconst child = parseStyleNode(status);\n\t\t\t\t\tif (child) {\n\t\t\t\t\t\tblock.children.push(child);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn block;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconsumeSpace(status);\n\t\t}\n\t\taccept(\"}\", status);\n\n\t\treturn block;\n\t}\n}\n\nfunction parseComment(status: ParseStatus, gapBefore: boolean): CommentNode {\n\tconst start = status.i;\n\tif (accept(\"//\", status)) {\n\t\tconst end = status.source.indexOf(\"\\n\", status.i);\n\t\tstatus.i = end === -1 ? status.source.length : end;\n\t} else {\n\t\taccept(\"/*\", status);\n\t\tconst end = status.source.indexOf(\"*/\", status.i);\n\t\tstatus.i = end === -1 ? status.source.length : end + 2;\n\t}\n\tconst comment: CommentNode = {\n\t\ttype: \"comment\",\n\t\tcontent: status.source.substring(start, status.i),\n\t\tgapBefore,\n\t};\n\treturn comment;\n}\n\nfunction parseStyleAttribute(status: ParseStatus): AttributeNode {\n\tconst gapBefore = /\\n\\s*\\n\\s*$/.test(status.source.slice(0, status.i));\n\tconst name = consumeUntil(\":\", status).trim();\n\taccept(\":\", status);\n\tconst value = consumeUntil(\";\", status).trim();\n\taccept(\";\", status);\n\treturn {\n\t\ttype: \"attribute\",\n\t\tname,\n\t\tvalue,\n\t\tgapBefore,\n\t};\n}\n","import type ElementNode from \"../types/nodes/ElementNode\";\nimport type TemplateNode from \"../types/nodes/TemplateNode\";\n\nexport default function isComponentNode(node: TemplateNode): node is ElementNode {\n\treturn node.type === \"component\";\n}\n","import type TemplateNode from \"../types/nodes/TemplateNode\";\nimport type BlockNode from \"../types/styles/BlockNode\";\nimport isComponentNode from \"../utils/isComponentNode\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isParentNode from \"../utils/isParentNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\n\nexport default function scopeStyles(status: ParseStatus): void {\n\tlet selectors: string[] = [];\n\tfor (let component of status.components) {\n\t\tif (component.style && component.markup) {\n\t\t\tfor (let block of component.style.children) {\n\t\t\t\tif (block.type === \"block\") {\n\t\t\t\t\tcollectStyleSelectors(block as BlockNode, selectors);\n\t\t\t\t}\n\t\t\t}\n\t\t\tscopeStylesOnNode(component.markup, selectors);\n\t\t}\n\t}\n}\n\nfunction scopeStylesOnNode(node: TemplateNode, selectors: string[]) {\n\tif (isElementNode(node) || isComponentNode(node)) {\n\t\tnode.scopeStyles =\n\t\t\tselectors.includes(node.tagName) ||\n\t\t\tnode.attributes.find((a) => {\n\t\t\t\tif (a.name === \"class\" && a.reactive) {\n\t\t\t\t\t// Any reactivity in a class attribute makes it scoped,\n\t\t\t\t\t// because we can't tell what's going on in there\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (a.name === \"id\" && a.value) {\n\t\t\t\t\tif (selectors.includes(`#${trimQuotes(a.value)}`)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t} else if (a.name === \"class\" && a.value) {\n\t\t\t\t\tfor (let classname of trimQuotes(a.value).split(/\\s+/)) {\n\t\t\t\t\t\tif (selectors.includes(`.${classname}`)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}) !== undefined;\n\t}\n\n\tif (isParentNode(node)) {\n\t\tfor (let child of node.children) {\n\t\t\tscopeStylesOnNode(child, selectors);\n\t\t}\n\t}\n}\n\nfunction collectStyleSelectors(block: BlockNode, selectors: string[]) {\n\t// HACK: We should be collecting the actual selectors and then checking\n\t// attributes, parents, children, siblings etc\n\tfor (let s of block.selector.split(/[\\s*,>+~[\\]]/)) {\n\t\tselectors.push(s);\n\t}\n}\n","import type TemplateComponent from \"../../types/TemplateComponent\";\nimport type ParseResult from \"../types/ParseResult\";\nimport collectMarkupExpressions from \"../utils/collectMarkupExpressions\";\nimport { codeRanges, skipStringOrComment } from \"../utils/codeScanner\";\nimport endOfString from \"../utils/endOfString\";\nimport endOfTemplateString from \"../utils/endOfTemplateString\";\nimport isElementNode from \"../utils/isElementNode\";\nimport isSpaceNode from \"../utils/isSpaceNode\";\nimport trimQuotes from \"../utils/trimQuotes\";\nimport type ParseStatus from \"./ParseStatus\";\nimport parseInlineScript from \"./parseInlineScript\";\nimport parseMarkup, { parseMarkupInto } from \"./parseMarkup\";\nimport parseStyleElement from \"./parseStyles\";\nimport scopeStyles from \"./scopeStyles\";\nimport accept from \"./utils/accept\";\nimport addError from \"./utils/addError\";\nimport consumeAlphaNumeric from \"./utils/consumeAlphaNumeric\";\nimport consumeSpace from \"./utils/consumeSpace\";\n\nexport default function parseCode(source: string): ParseResult {\n\tconst status: ParseStatus = {\n\t\tsource,\n\t\ti: 0,\n\t\tmarker: 0,\n\t\tlevel: 0,\n\t\tbraces: [],\n\t\timports: [],\n\t\tscript: [],\n\t\tcomponents: [],\n\t\tstack: [],\n\t\terrors: [],\n\t};\n\n\tfor (status.i; status.i < source.length; status.i++) {\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (status.source[status.i] === \"{\") {\n\t\t\tstatus.level += 1;\n\t\t\t// A brace opened by the main loop is other top-level script (an\n\t\t\t// interface, type or object literal), not a component function\n\t\t\tstatus.braces.push(false);\n\t\t} else if (status.source[status.i] === \"}\") {\n\t\t\tstatus.level -= 1;\n\t\t\t// Only a brace that was opened by a component function ends the\n\t\t\t// component — a closing brace from other top-level script (e.g.\n\t\t\t// an interface between two components) must not emit an end\n\t\t\t// marker, or the build's component/chunk bookkeeping desyncs\n\t\t\tconst fromComponent = status.braces.pop();\n\t\t\tif (status.level === 0 && fromComponent) {\n\t\t\t\tparseComponentEnd(status);\n\t\t\t} else if (status.level < 0) {\n\t\t\t\taddError(status, `Unexpected closing brace`, status.i, status.i + 1);\n\t\t\t\tstatus.level = 0;\n\t\t\t}\n\t\t} else if (accept(\"function\", status)) {\n\t\t\t// If the function name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"const\", status)) {\n\t\t\t// If it's a function and its name starts with a capital, parse it as a component\n\t\t\tif (consumeSpace(status)) {\n\t\t\t\tif (/[A-Z]/.test(source[status.i])) {\n\t\t\t\t\tconst start = status.i;\n\t\t\t\t\tconsumeAlphaNumeric(status);\n\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\tif (accept(\"=\", status)) {\n\t\t\t\t\t\tconsumeSpace(status);\n\t\t\t\t\t\tif (accept(\"(\", status, false)) {\n\t\t\t\t\t\t\tstatus.i = start;\n\t\t\t\t\t\t\tparseComponentStart(status);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Unconsume the last space\n\t\t\t\t\tstatus.i--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (accept(\"export\", status)) {\n\t\t\t// If it's an anonymous default export function, parse it as a component\n\t\t\tconst start = status.i;\n\t\t\tif (\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"default\", status) &&\n\t\t\t\tconsumeSpace(status) &&\n\t\t\t\taccept(\"(\", status, false)\n\t\t\t) {\n\t\t\t\tparseComponentStart(status);\n\t\t\t} else {\n\t\t\t\tstatus.i = start;\n\t\t\t}\n\t\t} else if (accept(\"@render\", status, false)) {\n\t\t\tparseComponentRender(status);\n\t\t} else if (accept(\"@error\", status, false)) {\n\t\t\tparseComponentError(status);\n\t\t} else if (accept(\"@head\", status, false)) {\n\t\t\tparseComponentHead(status);\n\t\t} else if (accept(\"@style\", status, false)) {\n\t\t\tparseComponentStyle(status);\n\t\t}\n\t}\n\n\tif (status.level > 0) {\n\t\tconst count = status.level;\n\t\taddError(\n\t\t\tstatus,\n\t\t\t`Unbalanced braces: missing ${count} closing brace${count === 1 ? \"\" : \"s\"}`,\n\t\t\tsource.length,\n\t\t\tsource.length,\n\t\t);\n\t}\n\n\tstatus.script.push({\n\t\tscript: source.substring(status.marker, source.length),\n\t\tspan: { start: status.marker, end: source.length },\n\t});\n\n\tscopeStyles(status);\n\n\tconst ok = !status.errors.length;\n\tif (!ok) {\n\t\tstatus.errors = status.errors.sort((a, b) => a.startIndex - b.startIndex);\n\t}\n\n\treturn {\n\t\tok,\n\t\terrors: status.errors,\n\t\ttemplate: ok\n\t\t\t? {\n\t\t\t\t\timports: status.imports,\n\t\t\t\t\tscript: status.script,\n\t\t\t\t\tcomponents: status.components,\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n}\n\nfunction parseComponentStart(status: ParseStatus) {\n\tlet source = status.source.substring(status.marker, status.i);\n\tlet exported = /export\\s+(default\\s+)*(function\\s+|const\\s+)*$/.test(source);\n\tlet def = /export\\s+default\\s+(function\\s+|const\\s+)*$/.test(source);\n\tlet isConst = /const\\s+$/.test(source);\n\tlet isAnon = /export default\\s+$/.test(source);\n\n\tlet componentStart = status.i;\n\tlet name = consumeAlphaNumeric(status);\n\n\tif (def && status.components.some((c) => c.default)) {\n\t\taddError(status, `Multiple default exports`, componentStart, componentStart + name.length);\n\t}\n\n\tconst current: TemplateComponent = {\n\t\tstart: componentStart,\n\t\tname,\n\t\texported,\n\t\tdefault: def,\n\t\tscriptStart: status.script.length,\n\t};\n\tstatus.components.push(current);\n\n\t// Look for type parameters, e.g. `function Form<Data = any>(...)`\n\tif (status.source[status.i] === \"<\") {\n\t\tconst typeParamsStart = status.i;\n\t\tlet level = 0;\n\t\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\t\tconst char = status.source[status.i];\n\t\t\tif (char === \"<\") {\n\t\t\t\tlevel += 1;\n\t\t\t} else if (char === \">\") {\n\t\t\t\tlevel -= 1;\n\t\t\t\tif (level === 0) {\n\t\t\t\t\tcurrent.typeParams = status.source.substring(typeParamsStart, status.i + 1);\n\t\t\t\t\tstatus.i += 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Look for /** ... */ documentation comments\n\tlet presource = source.substring(0, status.i).trimEnd();\n\tlet lastNewline = presource.lastIndexOf(\"\\n\");\n\tif (lastNewline !== -1) {\n\t\tpresource = presource.substring(0, lastNewline).trimEnd();\n\t\tif (presource.endsWith(\"*/\")) {\n\t\t\tfor (let i = presource.length; i >= 0; i--) {\n\t\t\t\tif (presource.substring(i, i + 3) === \"/**\") {\n\t\t\t\t\tcurrent.documentation = presource.substring(i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlet start = -1;\n\tlet end = -1;\n\tlet level = 0;\n\tfor (status.i; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tif (consumeScriptComments(status)) {\n\t\t\t// Keep going\n\t\t} else if (char === \"(\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t}\n\t\t} else if (char === \")\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, start),\n\t\tspan: { start: status.marker, end: start },\n\t});\n\tstatus.script.push({ script: \"/* @params */\", span: { start, end } });\n\n\tcurrent.params = status.source.substring(start, end);\n\tif (current.params.trim().length === 0) {\n\t\tcurrent.params = undefined;\n\t}\n\n\t// Look for a params type or interface\n\t// Might need to get fancier with this\n\tconst paramsMatch = current.params?.match(/\\$props:\\s*([$A-Za-z0-9]+)/);\n\tif (paramsMatch) {\n\t\tlet propsTypeName = paramsMatch[1];\n\t\tlet propsTypeStart = status.source.search(new RegExp(`interface\\\\s+${propsTypeName}`));\n\t\tif (propsTypeStart === -1) {\n\t\t\tpropsTypeStart = status.source.search(new RegExp(`type\\\\s+${propsTypeName}`));\n\t\t}\n\t\tif (propsTypeStart !== -1) {\n\t\t\tlet bracesStart = status.source.indexOf(\"{\", propsTypeStart);\n\t\t\tif (bracesStart !== -1) {\n\t\t\t\tconst status2: ParseStatus = {\n\t\t\t\t\tsource: status.source,\n\t\t\t\t\ti: bracesStart + 1,\n\t\t\t\t\tmarker: 0,\n\t\t\t\t\tlevel: 0,\n\t\t\t\t\tbraces: [],\n\t\t\t\t\timports: [],\n\t\t\t\t\tscript: [],\n\t\t\t\t\tcomponents: [],\n\t\t\t\t\tstack: [],\n\t\t\t\t\terrors: [],\n\t\t\t\t};\n\t\t\t\tconst propsType = parseInlineScript(status2);\n\t\t\t\tif (propsType) {\n\t\t\t\t\tcurrent.propsType = `${status.source.substring(propsTypeStart, bracesStart)}{${propsType}}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.marker = end;\n\tstatus.i = status.marker;\n\n\taccept(\")\", status);\n\tconsumeSpace(status);\n\n\tif (isConst || isAnon) {\n\t\taccept(\"=>\", status);\n\t\tconsumeSpace(status);\n\t}\n\n\taccept(\"{\", status);\n\tstatus.level += 1;\n\t// The component's own brace — its matching close ends the component\n\tstatus.braces.push(true);\n\n\t// Sneak in a function type\n\tconst postFunctionChunk = {\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t};\n\tif (/\\)\\s+\\{/.test(postFunctionChunk.script)) {\n\t\tpostFunctionChunk.script = \") /* @return_type */ {\";\n\t}\n\tstatus.script.push(postFunctionChunk);\n\n\tstatus.script.push({\n\t\tscript: \"/* @start */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tstatus.marker = status.i;\n\tconst space = consumeSpace(status);\n\tstatus.script.push({\n\t\tscript: space,\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.marker = status.i;\n\tstatus.i -= 1;\n}\n\nfunction parseComponentRender(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.markup) {\n\t\taddError(status, `Multiple @render sections`, status.i, status.i + \"@render\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @render */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\taccept(\"@render\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentError(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.error) {\n\t\taddError(status, `Multiple @error sections`, status.i, status.i + \"@error\".length);\n\t}\n\n\tif (!current.markup) {\n\t\taddError(status, `@error must come after @render`, status.i, status.i + \"@error\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @error */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\taccept(\"@error\", status);\n\tconsumeSpace(status);\n\n\t// Parse the error variable e.g. `@error (err)`\n\tlet errorVar = \"\";\n\tif (accept(\"(\", status)) {\n\t\tlet start = status.i;\n\t\twhile (status.i < status.source.length && status.source[status.i] !== \")\") {\n\t\t\tstatus.i += 1;\n\t\t}\n\t\terrorVar = status.source.substring(start, status.i).trim();\n\t\taccept(\")\", status);\n\t\tconsumeSpace(status);\n\t}\n\tcurrent.errorVar = errorVar || \"err\";\n\n\tif (accept(\"{\", status)) {\n\t\tparseMarkupInto(status, status.source, (root) => (current.error ??= root));\n\t\taccept(\"}\", status);\n\t}\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentHead(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.head) {\n\t\taddError(status, `Multiple @head sections`, status.i, status.i + \"@head\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @head */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// HACK: add a new component, and move its markup into the current\n\t// component's head section after\n\tstatus.components.push({\n\t\tstart: status.i,\n\t});\n\n\taccept(\"@head\", status);\n\tconsumeSpace(status);\n\tif (accept(\"{\", status)) {\n\t\tparseMarkup(status, status.source);\n\t\taccept(\"}\", status);\n\t}\n\n\t// Swap render and markup\n\tconst head = status.components.pop();\n\tcurrent.head = head?.markup;\n\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentStyle(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tif (current.style) {\n\t\taddError(status, `Multiple @style sections`, status.i, status.i + \"@style\".length);\n\t}\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\tstatus.script.push({\n\t\tscript: \"/* @style */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\tlet start = -1;\n\tlet end = status.source.length;\n\tlet level = 0;\n\tlet styleSource = \"\";\n\tfor (; status.i < status.source.length; status.i++) {\n\t\tconst char = status.source[status.i];\n\t\tconst nextChar = status.source[status.i + 1];\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t// Skip one-line comments\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"\\n\", status.i);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"/\" && nextChar === \"*\") {\n\t\t\t// Skip block comments\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = status.source.indexOf(\"*/\", status.i) + 1;\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\t// Skip string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfString(char, status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"`\") {\n\t\t\t// Skip interpolated string contents\n\t\t\tlet start = status.i;\n\t\t\tstatus.i = endOfTemplateString(status.source, start);\n\t\t\tstyleSource += status.source.substring(start, status.i + 1);\n\t\t} else if (char === \"{\") {\n\t\t\tlevel += 1;\n\t\t\tif (start === -1) {\n\t\t\t\tstart = status.i + 1;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else if (char === \"}\") {\n\t\t\tlevel -= 1;\n\t\t\tif (level === 0) {\n\t\t\t\tend = status.i - 1;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t} else {\n\t\t\tif (start !== -1) {\n\t\t\t\tstyleSource += char;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatus.i = start;\n\tparseStyleElement(styleSource.trim(), status);\n\n\tstatus.i = end + 2;\n\tstatus.marker = status.i;\n}\n\nfunction parseComponentEnd(status: ParseStatus) {\n\tconst current = status.components.at(-1);\n\tif (!current) return;\n\n\tstatus.script.push({\n\t\tscript: status.source.substring(status.marker, status.i),\n\t\tspan: { start: status.marker, end: status.i },\n\t});\n\n\tstatus.script.push({\n\t\tscript: \"/* @end */\",\n\t\tspan: { start: 0, end: 0 },\n\t});\n\n\t// Get all usages of $props.name and $props[\"name\"]\n\t// Get all usages of $context.name and $context[\"name\"]\n\t//\n\t// Only scan what the compiled output will actually reference: script code\n\t// and markup expressions (control statements, reactive attribute values,\n\t// `{...}` interpolations). `codeRanges` identifies the code positions, so\n\t// matches that start inside a string, comment or regex literal are\n\t// ignored — e.g. sample code in a template literal attribute (like the\n\t// docs pages' code samples) doesn't inject a $props param that nothing\n\t// uses. Prose text and static attribute values are never compiled into\n\t// references\n\tconst scriptText = status.script\n\t\t.slice(current.scriptStart ?? status.script.length)\n\t\t.map((chunk) => chunk.script)\n\t\t.join(\"\\n\");\n\tconst markupParts: string[] = [];\n\tif (current.markup) markupParts.push(collectMarkupExpressions(current.markup));\n\tif (current.error) markupParts.push(collectMarkupExpressions(current.error));\n\tif (current.head) markupParts.push(collectMarkupExpressions(current.head));\n\tconst usageSource = scriptText + \"\\n\" + markupParts.join(\"\\n\");\n\tconst usageRanges = codeRanges(usageSource);\n\tcurrent.props = getPropsUsage(usageSource, usageRanges);\n\tcurrent.contextProps = getContextUsage(usageSource, usageRanges);\n\n\t// If the top-level element is <html> and there is whitespace after it,\n\t// delete the whitespace, as that's what browsers seem to do. It may be\n\t// better instead to create whitespace if we don't find it when hydrating...\n\tif (\n\t\tcurrent.markup &&\n\t\tisElementNode(current.markup.children[0]) &&\n\t\tcurrent.markup.children[0].tagName === \"html\" &&\n\t\tisSpaceNode(current.markup.children[0].children[0])\n\t) {\n\t\tcurrent.markup.children.splice(1, 1);\n\t}\n\n\tstatus.marker = status.i;\n}\n\n/**\n * Gets the `$props` names that the compiled output references. The input is\n * the component's code-only text (script plus markup expressions), with\n * `ranges` marking the positions that are code — matches that start inside a\n * string, comment or regex literal are ignored, so mentions inside\n * sample-code strings or prose don't count.\n */\nfunction getPropsUsage(source: string, ranges: [number, number][]): string[] | undefined {\n\tconst props: string[] = [];\n\tfor (let match of source.matchAll(/\\$props\\??\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g)) {\n\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!props.includes(name)) {\n\t\t\tprops.push(name);\n\t\t}\n\t}\n\t// Also check for bare `$props` references, e.g. spreading it into a new\n\t// object with `let props = $props ?? {}`. These don't have a property\n\t// accessor, but still need the `$props` parameter to be declared. A\n\t// following `:` means it's a (re)declaration or type annotation, and a\n\t// following `<` means it's text in markup (e.g. \"<code>$props</code>\"),\n\t// neither of which count\n\tif (!props.length) {\n\t\tfor (let match of source.matchAll(/(?<![\\w$])\\$props(?![\\w])(?!\\s*:)(?!<)/g)) {\n\t\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\t\tprops.push(\"$props\");\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn props.length ? props : undefined;\n}\n\n/**\n * Gets the `$context` names that the compiled output references. The input is\n * the component's code-only text (script plus markup expressions), with\n * `ranges` marking the positions that are code — matches that start inside a\n * string, comment or regex literal are ignored, so mentions inside\n * sample-code strings or prose don't count.\n */\nfunction getContextUsage(source: string, ranges: [number, number][]): string[] | undefined {\n\tconst contextsMatches = source.matchAll(/\\$context\\??\\s*(?:\\.([\\d\\w]+)|\\[([^\\]]+)\\])/g);\n\tconst contexts: string[] = [];\n\tfor (let match of contextsMatches) {\n\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\tconst name = trimQuotes(match[1] || match[2]);\n\t\tif (!contexts.includes(name)) {\n\t\t\tcontexts.push(name);\n\t\t}\n\t}\n\t// Also check for bare `$context` references, e.g. passing the whole\n\t// context object to a function. These don't have a property accessor,\n\t// but still need the `$context` parameter to be declared. A following\n\t// `:` means it's a (re)declaration or type annotation, and a following\n\t// `<` means it's text in markup (e.g. \"<code>$context</code>\"), neither\n\t// of which count\n\tif (!contexts.length) {\n\t\tfor (let match of source.matchAll(/(?<![\\w$])\\$context(?![\\w])(?!\\s*:)(?!<)/g)) {\n\t\t\tif (!isInCode(ranges, match.index!)) continue;\n\t\t\tcontexts.push(\"$context\");\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn contexts.length ? contexts : undefined;\n}\n\n/**\n * Returns true if `index` falls inside one of the (sorted, non-overlapping)\n * code ranges — i.e. not inside a string, comment or regex literal.\n */\nfunction isInCode(ranges: [number, number][], index: number): boolean {\n\tfor (const [start, end] of ranges) {\n\t\tif (index >= start && index < end) return true;\n\t\tif (index < start) return false;\n\t}\n\treturn false;\n}\n\nfunction consumeScriptComments(status: ParseStatus): boolean {\n\tconst skipped = skipStringOrComment(status.source, status.i);\n\tif (skipped !== -1) {\n\t\tstatus.i = skipped;\n\t\treturn true;\n\t}\n\treturn false;\n}\n","import parseCode from \"./parse/parseCode\";\nimport type ParseResult from \"./types/ParseResult\";\n\n/**\n * Parses source code into a component template\n *\n * @param source The source code\n *\n * @returns A result indicating whether parsing was ok, and if so, containing\n * the component template's parts such as script, markup and styles\n */\nexport default function parse(source: string): ParseResult {\n\treturn parseCode(source);\n}\n"],"mappings":";AAAA,SAAwB,YAAY,MAAc,SAAiB,OAAuB;CACzF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,QAAQ,QAAQ,KAC3C,IAAI,QAAQ,OAAO,QAAQ,QAAQ,IAAI,OAAO,MAC7C,OAAO;CAGT,OAAO,QAAQ;AAChB;;;;;;;;;;;;;;ACSA,MAAM,iCAAiB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;AAQD,SAAgB,oBAAoB,OAAe,OAAuB;CACzE,OAAO,YAAY,OAAO,KAAK;AAChC;;;;;;;AAQA,SAAgB,WAAW,OAAmC;CAC7D,MAAM,SAA6B,CAAC;CACpC,IAAI,YAAY;CAChB,IAAI,IAAI;CACR,OAAO,IAAI,MAAM,QAAQ;EACxB,MAAM,OAAO,YAAY,OAAO,GAAG,QAAQ,SAAS;EACpD,IAAI,SAAS,IAAI;GAChB,IAAI;GACJ,YAAY;EACb,OACC,KAAK;CAEP;CACA,UAAU,QAAQ,WAAW,MAAM,MAAM;CACzC,OAAO;AACR;;;;;;AAOA,SAAS,YACR,OACA,OACA,QACA,WACS;CACT,MAAM,OAAO,MAAM;CACnB,IAAI,SAAS,OAAO,SAAS,MAAK;EACjC,IAAI,QAAQ,UAAU,QAAQ,WAAY,KAAK;EAC/C,OAAO,YAAY,MAAM,OAAO,KAAK,IAAI;CAC1C;CACA,IAAI,SAAS,KAAK;EACjB,IAAI,QAAQ,UAAU,QAAQ,WAAY,KAAK;EAC/C,OAAO,mBAAmB,OAAO,OAAO,MAAM;CAC/C;CACA,IAAI,SAAS,OAAO,MAAM,QAAQ,OAAO,KAAK;EAC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A,UACA,OACD;GACA;EAED,KAAK;GACJ,6BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,OACD;GACA;EAED,KAAK;GACJ,2BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,OACD;GACA;EAED,KAAK;GACJ,wBACC,UACA,MACA,MACA,QACA,GACA,UACA,WACA,OACD;GACA;EAED,KAAK;GACJ,2BACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,WACA,OACD;GACA;EAED,KAAK,WAEJ;EAED,SAEC,MAAM,IAAI,MAAM,sBAAsB,KAAK,MAAM;CAEnD;AACD;AAEA,SAAS,wBACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;CACD,KAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,QAAQ,GAC5C,oBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,OACD;AAEF;AAEA,SAAS,2BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;CACD,QAAQ,KAAK,WAAb;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;GAEJ,mCACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UATiB,KAAK,UAAU,UAAU,CAAC,CAAC,CAAC,QAAQ,UAAU,EAUvD,GACR,OACD;GACA;EAED,SACC,KAAK,IAAI,CAAC,GAAG,UAAU,KAAK,SAAS,QAAQ,GAC5C,oBACC,UACA,OACA,MACA,QACA,GACA,YACA,YACA,UACA,MAAM,KAAK,SAAS,SAAS,GAC7B,OACD;CAIH;AACD;AAEA,SAAS,6BACR,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,SACC;CACD,mCACC,UACA,MACA,MACA,QACA,GACA,YACA,YACA,UACA,QACA,OACD;AACD;AAEA,SAAS,gBAAgB,MAAmB;CAE3C,QAAQ,KAAK,QAAQ,YAAY,GAAjC;E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