@lucidkiln/core 1.0.0 → 1.2.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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["MAX_DEPTH","listOf","withHint","NOTHING","emitters","lookup","isBlank","checkValue","lookup","checkValue","IDENTIFIER"],"sources":["../src/analyzer.ts","../src/builtins/formatters.ts","../src/builtins/filters.ts","../src/checker.ts","../src/runtime/cache.ts","../src/runtime/islands.ts","../src/runtime/macros.ts","../src/compiler/combinators.ts","../src/compiler/effects.ts","../src/compiler/compiler.ts","../src/compiler/precompiled.ts","../src/compiler/codegen.ts","../src/html/data.ts","../src/html/options.ts","../src/html/tags.ts","../src/html/nesting.ts","../src/html/scanner.ts","../src/html/index.ts","../src/runtime/stream.ts","../src/environment.ts","../src/manifest.ts","../src/typegen.ts"],"sourcesContent":["import type { Diagnostic } from \"./errors.js\";\nimport { resolveTemplateName } from \"./names.js\";\nimport type {\n\tArgument,\n\tExpression,\n\tPropType,\n\tStatement,\n} from \"./parser/ast.js\";\nimport type { CompiledTemplate, Scope } from \"./runtime/types.js\";\nimport type { Position, Span } from \"./source.js\";\n\nexport type TemplateReference = {\n\tkind: \"extends\" | \"include\" | \"component\" | \"island\" | \"import\";\n\t/** Resolved name, or `null` when the name is computed at render time. */\n\tname: string | null;\n\tstart: Position;\n\tend: Position;\n};\n\nexport type AnalysedProp = {\n\tname: string;\n\trequired: boolean;\n\ttype: PropType[] | null;\n};\n\nexport type Analysis = {\n\tdiagnostics: Diagnostic[];\n\t/** Variables the template reads from its context, excluding globals, props and locals. */\n\tvariables: string[];\n\t/** `type` lists the members of the prop's type, or is `null` when the prop is untyped. */\n\tprops: AnalysedProp[];\n\t/** The name of the rest prop, as in `...attributes`, or null. With one, the template accepts any variable. */\n\trest: string | null;\n\t/** Variables set at the top level. A layout sees those its child template sets. */\n\tsets: string[];\n\tfunctions: string[];\n\tfilters: string[];\n\ttests: string[];\n\ttemplates: TemplateReference[];\n\tblocks: string[];\n\tmacros: string[];\n};\n\n/** Where variables are first read without a guard, by name: from the context, and inside macros. See `analyzeTemplate`. */\nexport type Reads = {\n\tcontext: Map<string, Span>;\n\tmacros: Map<string, Span>;\n};\n\nconst MAX_DEPTH = 1000;\n\n/** The statement lists nested inside a statement. */\nexport const childStatements = (node: Statement): Statement[][] => {\n\tswitch (node.type) {\n\t\tcase \"If\":\n\t\t\treturn [\n\t\t\t\t...node.branches.map((branch) => branch.body),\n\t\t\t\tnode.alternate ?? [],\n\t\t\t];\n\t\tcase \"For\":\n\t\t\treturn [node.body, node.alternate ?? []];\n\t\tcase \"Component\":\n\t\t\treturn [node.body, ...node.fills.map((fill) => fill.body)];\n\t\tcase \"Island\":\n\t\tcase \"SetBlock\":\n\t\tcase \"Block\":\n\t\tcase \"Slot\":\n\t\tcase \"Macro\":\n\t\tcase \"Add\":\n\t\tcase \"Cache\":\n\t\tcase \"With\":\n\t\tcase \"Apply\":\n\t\tcase \"Autoescape\":\n\t\t\treturn [node.body];\n\t\tdefault:\n\t\t\treturn [];\n\t}\n};\n\n/**\n * Walks a compiled template's syntax tree and reports what it uses.\n *\n * When `reads` is given, it collects where each variable in `variables` is first read without a guard such as `??`, `?.`, `default` or `is defined`, and where a macro first reads a name that is neither its parameter nor a global. Strict mode fails on those reads when the variable is missing.\n */\nexport const analyzeTemplate = (\n\ttemplate: CompiledTemplate,\n\tglobals: Scope,\n\treads?: Reads,\n): Analysis => {\n\tconst source = template.source;\n\tconst variables = new Set<string>();\n\tconst functions = new Set<string>();\n\tconst filters = new Set<string>();\n\tconst tests = new Set<string>();\n\tconst templates: TemplateReference[] = [];\n\tconst blocks: string[] = [];\n\tconst props: AnalysedProp[] = [];\n\tlet rest: string | null = null;\n\tconst macroNames = new Set(template.macros.keys());\n\tconst importedNames = new Set<string>();\n\tconst importAliases = new Set<string>();\n\n\tconst reference = (\n\t\tkind: TemplateReference[\"kind\"],\n\t\tname: Expression | string,\n\t\tspan: Span,\n\t) => {\n\t\tlet resolved: string | null = null;\n\t\tconst literal =\n\t\t\ttypeof name === \"string\"\n\t\t\t\t? name\n\t\t\t\t: name.type === \"Literal\"\n\t\t\t\t\t? name.value\n\t\t\t\t\t: null;\n\t\tif (typeof literal === \"string\") {\n\t\t\ttry {\n\t\t\t\tresolved = resolveTemplateName(literal, template.name);\n\t\t\t} catch {\n\t\t\t\tresolved = null;\n\t\t\t}\n\t\t}\n\t\ttemplates.push({\n\t\t\tkind,\n\t\t\tname: resolved,\n\t\t\tstart: source.position(span.start),\n\t\t\tend: source.position(span.end),\n\t\t});\n\t};\n\n\t// Scopes of declared names, innermost last. `null` marks where an isolated scope, such as a macro's, begins. Names\n\t// outside it can't be seen.\n\tconst scopes: (Set<string> | null)[] = [new Set()];\n\tconst declared = (name: string) => {\n\t\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\t\tconst scope = scopes[i];\n\t\t\tif (scope === null) break;\n\t\t\tif (scope?.has(name)) return true;\n\t\t}\n\t\treturn name in globals;\n\t};\n\tconst declare = (name: string) => {\n\t\tif (!declared(name)) scopes[scopes.length - 1]?.add(name);\n\t};\n\tconst withScope = (\n\t\tnames: Iterable<string>,\n\t\twork: () => void,\n\t\tisolated = false,\n\t) => {\n\t\tif (isolated) scopes.push(null);\n\t\tscopes.push(new Set(names));\n\t\twork();\n\t\tscopes.pop();\n\t\tif (isolated) scopes.pop();\n\t};\n\n\tconst visitArguments = (args: Argument[]) => {\n\t\tfor (const arg of args) expression(arg.value);\n\t};\n\n\t// Expressions deeper than the compiler accepts were already reported, so stop there instead of overflowing the stack.\n\tlet depth = 0;\n\tconst expression = (node: Expression): void => {\n\t\tif (depth >= MAX_DEPTH) return;\n\t\tdepth++;\n\t\ttry {\n\t\t\tvisitExpression(node);\n\t\t} finally {\n\t\t\tdepth--;\n\t\t}\n\t};\n\n\t// A guarded expression, such as the left of `??`, is null rather than an error when its variable is missing.\n\tconst guarded = (node: Expression): void => {\n\t\tif (node.type === \"Name\") read(node.name, node.span, true);\n\t\telse if (node.type === \"Member\") {\n\t\t\tguarded(node.object);\n\t\t\tif (node.property.type !== \"Literal\") expression(node.property);\n\t\t} else if (node.type === \"OptionalChain\") guarded(node.expression);\n\t\telse expression(node);\n\t};\n\n\t// A template that outputs slots, or extends a layout that may, gets a `slots` hash.\n\tif (template.slotNames.length > 0 || template.parent) scopes[0]?.add(\"slots\");\n\n\tconst read = (name: string, span: Span, isGuarded: boolean) => {\n\t\tif (declared(name) || importAliases.has(name) || importedNames.has(name)) {\n\t\t\treturn;\n\t\t}\n\t\t// Inside a macro, a missing name is never one from the context.\n\t\tconst inMacro = scopes.includes(null);\n\t\tif (!inMacro) variables.add(name);\n\t\tconst found = inMacro ? reads?.macros : reads?.context;\n\t\tif (found && !isGuarded && !found.has(name)) found.set(name, span);\n\t};\n\n\tconst visitExpression = (node: Expression): void => {\n\t\tswitch (node.type) {\n\t\t\tcase \"Literal\":\n\t\t\tcase \"Invalid\":\n\t\t\t\treturn;\n\t\t\tcase \"Name\":\n\t\t\t\tread(node.name, node.span, false);\n\t\t\t\treturn;\n\t\t\tcase \"Interpolation\":\n\t\t\t\tnode.parts.forEach(expression);\n\t\t\t\treturn;\n\t\t\tcase \"Array\":\n\t\t\t\tfor (const element of node.elements) {\n\t\t\t\t\texpression(element.type === \"Spread\" ? element.value : element);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"Hash\":\n\t\t\t\tfor (const entry of node.entries) {\n\t\t\t\t\tif (entry.type === \"Property\" && entry.key.type !== \"Literal\") {\n\t\t\t\t\t\texpression(entry.key);\n\t\t\t\t\t}\n\t\t\t\t\texpression(entry.value);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"Unary\":\n\t\t\t\texpression(node.operand);\n\t\t\t\treturn;\n\t\t\tcase \"Binary\":\n\t\t\t\tif (node.operator === \"??\") guarded(node.left);\n\t\t\t\telse expression(node.left);\n\t\t\t\texpression(node.right);\n\t\t\t\treturn;\n\t\t\tcase \"Conditional\":\n\t\t\t\texpression(node.test);\n\t\t\t\texpression(node.consequent);\n\t\t\t\tif (node.alternate) expression(node.alternate);\n\t\t\t\treturn;\n\t\t\tcase \"Member\":\n\t\t\t\texpression(node.object);\n\t\t\t\tif (node.property.type !== \"Literal\") expression(node.property);\n\t\t\t\treturn;\n\t\t\tcase \"OptionalChain\":\n\t\t\t\tguarded(node.expression);\n\t\t\t\treturn;\n\t\t\tcase \"Call\": {\n\t\t\t\tconst callee = node.callee;\n\t\t\t\tif (callee.type === \"Name\") {\n\t\t\t\t\tconst name = callee.name;\n\t\t\t\t\tif (\n\t\t\t\t\t\tname !== \"parent\" &&\n\t\t\t\t\t\tname !== \"block\" &&\n\t\t\t\t\t\t!macroNames.has(name) &&\n\t\t\t\t\t\t!importedNames.has(name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfunctions.add(name);\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\t!(\n\t\t\t\t\t\tcallee.type === \"Member\" &&\n\t\t\t\t\t\tcallee.object.type === \"Name\" &&\n\t\t\t\t\t\timportAliases.has(callee.object.name)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\texpression(callee);\n\t\t\t\t}\n\t\t\t\tvisitArguments(node.args);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"Filter\":\n\t\t\t\tfilters.add(node.name);\n\t\t\t\tif (node.name === \"default\") guarded(node.input);\n\t\t\t\telse expression(node.input);\n\t\t\t\tvisitArguments(node.args);\n\t\t\t\treturn;\n\t\t\tcase \"Test\":\n\t\t\t\ttests.add(node.name);\n\t\t\t\tif (node.name === \"defined\") guarded(node.input);\n\t\t\t\telse expression(node.input);\n\t\t\t\tvisitArguments(node.args);\n\t\t\t\treturn;\n\t\t\tcase \"Arrow\":\n\t\t\t\twithScope(node.params, () => expression(node.body));\n\t\t\t\treturn;\n\t\t}\n\t};\n\n\tconst statements = (list: Statement[]) => {\n\t\tfor (const node of list) statement(node);\n\t};\n\n\tconst statement = (node: Statement): void => {\n\t\tswitch (node.type) {\n\t\t\tcase \"Text\":\n\t\t\t\treturn;\n\t\t\tcase \"Output\":\n\t\t\t\texpression(node.expression);\n\t\t\t\treturn;\n\t\t\tcase \"If\":\n\t\t\t\tfor (const branch of node.branches) {\n\t\t\t\t\texpression(branch.test);\n\t\t\t\t\tstatements(branch.body);\n\t\t\t\t}\n\t\t\t\tif (node.alternate) statements(node.alternate);\n\t\t\t\treturn;\n\t\t\tcase \"For\":\n\t\t\t\texpression(node.iterable);\n\t\t\t\twithScope(\n\t\t\t\t\tnode.keyName\n\t\t\t\t\t\t? [node.valueName, node.keyName, \"loop\"]\n\t\t\t\t\t\t: [node.valueName, \"loop\"],\n\t\t\t\t\t() => statements(node.body),\n\t\t\t\t);\n\t\t\t\tif (node.alternate) statements(node.alternate);\n\t\t\t\treturn;\n\t\t\tcase \"Set\":\n\t\t\t\texpression(node.value);\n\t\t\t\tdeclare(node.name);\n\t\t\t\treturn;\n\t\t\tcase \"SetBlock\":\n\t\t\t\tstatements(node.body);\n\t\t\t\tdeclare(node.name);\n\t\t\t\treturn;\n\t\t\tcase \"Props\":\n\t\t\t\tfor (const prop of node.props) {\n\t\t\t\t\tif (prop.default) expression(prop.default);\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname: prop.name,\n\t\t\t\t\t\trequired: prop.default === null,\n\t\t\t\t\t\ttype: prop.type,\n\t\t\t\t\t});\n\t\t\t\t\tdeclare(prop.name);\n\t\t\t\t}\n\t\t\t\tif (node.rest !== null) {\n\t\t\t\t\trest = node.rest;\n\t\t\t\t\tdeclare(node.rest);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"Extends\":\n\t\t\t\texpression(node.template);\n\t\t\t\treference(\"extends\", node.template, node.span);\n\t\t\t\treturn;\n\t\t\tcase \"Block\":\n\t\t\t\tblocks.push(node.name);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Include\":\n\t\t\t\texpression(node.template);\n\t\t\t\tif (node.with) expression(node.with);\n\t\t\t\treference(\"include\", node.template, node.span);\n\t\t\t\treturn;\n\t\t\tcase \"Component\":\n\t\t\t\texpression(node.template);\n\t\t\t\tif (node.with) expression(node.with);\n\t\t\t\treference(\"component\", node.template, node.span);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\tfor (const fill of node.fills)\n\t\t\t\t\twithScope([], () => statements(fill.body));\n\t\t\t\treturn;\n\t\t\tcase \"Island\":\n\t\t\t\texpression(node.template);\n\t\t\t\tif (node.with) expression(node.with);\n\t\t\t\treference(\"island\", node.template, node.span);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Slot\":\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Macro\":\n\t\t\t\twithScope(\n\t\t\t\t\tnode.params.map((param) => param.name),\n\t\t\t\t\t() => {\n\t\t\t\t\t\tfor (const param of node.params)\n\t\t\t\t\t\t\tif (param.default) expression(param.default);\n\t\t\t\t\t\tstatements(node.body);\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"Import\":\n\t\t\tcase \"FromImport\":\n\t\t\t\treturn;\n\t\t\tcase \"With\": {\n\t\t\t\texpression(node.value);\n\t\t\t\tconst names =\n\t\t\t\t\tnode.value.type === \"Hash\"\n\t\t\t\t\t\t? node.value.entries.flatMap((entry) =>\n\t\t\t\t\t\t\t\tentry.type === \"Property\" &&\n\t\t\t\t\t\t\t\tentry.key.type === \"Literal\" &&\n\t\t\t\t\t\t\t\ttypeof entry.key.value === \"string\"\n\t\t\t\t\t\t\t\t\t? [entry.key.value]\n\t\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: [];\n\t\t\t\twithScope(names, () => statements(node.body));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"Add\":\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Cache\":\n\t\t\t\texpression(node.key);\n\t\t\t\tif (node.seconds) expression(node.seconds);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Apply\":\n\t\t\t\tfor (const filter of node.filters) {\n\t\t\t\t\tfilters.add(filter.name);\n\t\t\t\t\tvisitArguments(filter.args);\n\t\t\t\t}\n\t\t\t\tstatements(node.body);\n\t\t\t\treturn;\n\t\t\tcase \"Autoescape\":\n\t\t\t\tstatements(node.body);\n\t\t\t\treturn;\n\t\t}\n\t};\n\n\t// Imports are hoisted, so record them before walking.\n\t// Imports can sit anywhere in the template. Only statements hold them, so expressions are not searched.\n\tconst collectImports = (list: Statement[]): void => {\n\t\tfor (const node of list) {\n\t\t\tif (node.type === \"Import\") {\n\t\t\t\timportAliases.add(node.alias);\n\t\t\t\treference(\"import\", node.template, node.span);\n\t\t\t} else if (node.type === \"FromImport\") {\n\t\t\t\tfor (const entry of node.names) importedNames.add(entry.alias);\n\t\t\t\treference(\"import\", node.template, node.span);\n\t\t\t}\n\t\t\tfor (const children of childStatements(node)) collectImports(children);\n\t\t}\n\t};\n\tcollectImports(template.ast.body);\n\n\t// A child template's top-level `set` statements run before its layout, so blocks see them wherever they are written.\n\tif (template.parent) {\n\t\tfor (const node of template.ast.body) {\n\t\t\tif (node.type === \"Set\" || node.type === \"SetBlock\") declare(node.name);\n\t\t}\n\t}\n\tstatements(template.ast.body);\n\n\treturn {\n\t\tdiagnostics: template.diagnostics,\n\t\tvariables: [...variables],\n\t\tprops,\n\t\trest,\n\t\tsets: template.ast.body.flatMap((node) =>\n\t\t\tnode.type === \"Set\" || node.type === \"SetBlock\" ? [node.name] : [],\n\t\t),\n\t\tfunctions: [...functions],\n\t\tfilters: [...filters],\n\t\ttests: [...tests],\n\t\ttemplates,\n\t\tblocks,\n\t\tmacros: [...macroNames],\n\t};\n};\n","/*\n * Formatting numbers and dates as `Intl` does, faster.\n *\n * An `Intl` formatter takes a few hundred nanoseconds a call, which adds up on a page of prices and dates. For the usual\n * settings, the pattern a formatter follows can be read from its own output once: the text around the digits, the\n * separators and how digits group, or for dates the order of the fields and the names of months and weekdays. Each value\n * then only needs string work.\n *\n * A pattern is only used once it formats a set of samples exactly as the formatter does. Settings it can't follow, and\n * values outside the range it handles, go to the formatter itself, so the output is always the formatter's.\n */\n\n/** Formats a number or a time in milliseconds since the epoch. */\nexport type Format = (value: number) => string;\n\n// Numbers\n\ntype NumberPattern = {\n\treadonly prefix: string;\n\treadonly suffix: string;\n\treadonly negativePrefix: string;\n\treadonly negativeSuffix: string;\n\treadonly decimal: string;\n\treadonly group: string;\n\t/** Digits in the group next to the decimal point, and in each group before it. */\n\treadonly primary: number;\n\treadonly secondary: number;\n\t/** Integer digits a number needs before it is grouped. */\n\treadonly grouping: number;\n\treadonly minimumFraction: number;\n\treadonly maximumFraction: number;\n};\n\n/** The parts of a formatted number around its digits. */\ntype NumberParts = {\n\tprefix: string;\n\tsuffix: string;\n\tintegers: string[];\n\tgroup: string;\n\tdecimal: string;\n};\n\nconst DIGIT_PARTS = new Set([\"integer\", \"group\", \"decimal\", \"fraction\"]);\n\nconst readNumber = (\n\tintl: Intl.NumberFormat,\n\tvalue: number,\n): NumberParts | null => {\n\tconst parts = intl.formatToParts(value);\n\tconst first = parts.findIndex((part) => part.type === \"integer\");\n\tif (first === -1) return null;\n\tlet last = first;\n\tfor (let i = first; i < parts.length; i++) {\n\t\tif (DIGIT_PARTS.has((parts[i] as Intl.NumberFormatPart).type)) last = i;\n\t}\n\tconst result: NumberParts = {\n\t\tprefix: \"\",\n\t\tsuffix: \"\",\n\t\tintegers: [],\n\t\tgroup: \"\",\n\t\tdecimal: \"\",\n\t};\n\tfor (let i = 0; i < parts.length; i++) {\n\t\tconst { type, value: text } = parts[i] as Intl.NumberFormatPart;\n\t\tif (i < first) result.prefix += text;\n\t\telse if (i > last) result.suffix += text;\n\t\telse if (type === \"integer\") result.integers.push(text);\n\t\telse if (type === \"group\") result.group = text;\n\t\telse if (type === \"decimal\") result.decimal = text;\n\t\telse if (type !== \"fraction\") return null;\n\t}\n\treturn result;\n};\n\nconst readNumberPattern = (intl: Intl.NumberFormat): NumberPattern | null => {\n\tconst options = intl.resolvedOptions() as unknown as Record<string, unknown>;\n\tif (\n\t\toptions.numberingSystem !== \"latn\" ||\n\t\toptions.notation !== \"standard\" ||\n\t\t(options.style !== \"decimal\" && options.style !== \"currency\") ||\n\t\t(options.currencyDisplay !== undefined &&\n\t\t\toptions.currencyDisplay !== \"symbol\" &&\n\t\t\toptions.currencyDisplay !== \"narrowSymbol\" &&\n\t\t\toptions.currencyDisplay !== \"code\") ||\n\t\t(options.currencySign !== undefined &&\n\t\t\toptions.currencySign !== \"standard\") ||\n\t\toptions.signDisplay !== \"auto\" ||\n\t\toptions.roundingMode !== \"halfExpand\" ||\n\t\toptions.roundingIncrement !== 1 ||\n\t\toptions.roundingPriority !== \"auto\" ||\n\t\toptions.trailingZeroDisplay !== \"auto\" ||\n\t\toptions.minimumIntegerDigits !== 1 ||\n\t\toptions.minimumSignificantDigits !== undefined ||\n\t\toptions.maximumSignificantDigits !== undefined ||\n\t\ttypeof options.minimumFractionDigits !== \"number\" ||\n\t\ttypeof options.maximumFractionDigits !== \"number\"\n\t) {\n\t\treturn null;\n\t}\n\tconst positive = readNumber(intl, 123456789012.5);\n\tconst negative = readNumber(intl, -123456789012.5);\n\tif (positive === null || negative === null) return null;\n\tconst sizes = positive.integers.map((digits) => digits.length);\n\tconst primary = sizes.at(-1) as number;\n\tconst secondary = sizes.length > 2 ? (sizes.at(-2) as number) : primary;\n\tlet grouping = Infinity;\n\tif (sizes.length > 1) {\n\t\tif ((readNumber(intl, 10 ** primary)?.integers.length ?? 0) > 1) {\n\t\t\tgrouping = primary + 1;\n\t\t} else if (\n\t\t\t(readNumber(intl, 10 ** (primary + 1))?.integers.length ?? 0) > 1\n\t\t) {\n\t\t\tgrouping = primary + 2;\n\t\t} else return null;\n\t}\n\treturn {\n\t\tprefix: positive.prefix,\n\t\tsuffix: positive.suffix,\n\t\tnegativePrefix: negative.prefix,\n\t\tnegativeSuffix: negative.suffix,\n\t\tdecimal: positive.decimal,\n\t\tgroup: positive.group,\n\t\tprimary,\n\t\tsecondary,\n\t\tgrouping,\n\t\tminimumFraction: options.minimumFractionDigits as number,\n\t\tmaximumFraction: options.maximumFractionDigits as number,\n\t};\n};\n\n/** Adds one to the last digit of a string of digits. */\nconst increment = (digits: string): string => {\n\tlet i = digits.length - 1;\n\twhile (i >= 0 && digits.charCodeAt(i) === 57) i--;\n\tif (i < 0) return `1${\"0\".repeat(digits.length)}`;\n\treturn (\n\t\tdigits.slice(0, i) +\n\t\tString.fromCharCode(digits.charCodeAt(i) + 1) +\n\t\t\"0\".repeat(digits.length - i - 1)\n\t);\n};\n\n/**\n * Formats with a number pattern, or returns null for values it doesn't handle. `Intl` rounds the shortest decimal\n * that reads back as the number, half away from zero, which is what `String` gives here: `1.005` rounds to `1.01`.\n */\nconst formatNumber = (pattern: NumberPattern, value: number): string | null => {\n\tif (!(value > -1e15 && value < 1e15)) return null;\n\tconst negative = value < 0 || Object.is(value, -0);\n\tconst magnitude = negative ? -value : value;\n\tif (magnitude !== 0 && magnitude < 1e-6) return null;\n\tconst text = String(magnitude);\n\tconst dot = text.indexOf(\".\");\n\tlet integer = dot === -1 ? text : text.slice(0, dot);\n\tlet fraction = dot === -1 ? \"\" : text.slice(dot + 1);\n\tconst { minimumFraction, maximumFraction } = pattern;\n\tif (fraction.length > maximumFraction) {\n\t\tconst up = fraction.charCodeAt(maximumFraction) >= 53;\n\t\tfraction = fraction.slice(0, maximumFraction);\n\t\tif (up) {\n\t\t\tconst digits = increment(integer + fraction);\n\t\t\tinteger = digits.slice(0, digits.length - maximumFraction);\n\t\t\tfraction = digits.slice(digits.length - maximumFraction);\n\t\t}\n\t}\n\tlet end = fraction.length;\n\twhile (end > minimumFraction && fraction.charCodeAt(end - 1) === 48) end--;\n\tif (end < fraction.length) fraction = fraction.slice(0, end);\n\twhile (fraction.length < minimumFraction) fraction += \"0\";\n\tif (integer.length >= pattern.grouping) {\n\t\tconst { primary, secondary, group } = pattern;\n\t\tlet grouped = integer.slice(-primary);\n\t\tlet rest = integer.slice(0, -primary);\n\t\twhile (rest.length > secondary) {\n\t\t\tgrouped = rest.slice(-secondary) + group + grouped;\n\t\t\trest = rest.slice(0, -secondary);\n\t\t}\n\t\tinteger = rest + group + grouped;\n\t}\n\tconst digits =\n\t\tfraction === \"\" ? integer : integer + pattern.decimal + fraction;\n\treturn negative\n\t\t? pattern.negativePrefix + digits + pattern.negativeSuffix\n\t\t: pattern.prefix + digits + pattern.suffix;\n};\n\n/** Numbers a number pattern must format as its formatter does: rounding, grouping, signs and sizes. */\nconst NUMBER_SAMPLES = [\n\t0,\n\t-0,\n\t1,\n\t-1,\n\t0.5,\n\t1.5,\n\t2.5,\n\t-2.5,\n\t0.125,\n\t0.375,\n\t1.005,\n\t2.675,\n\t9.995,\n\t99.995,\n\t999.995,\n\t1.45,\n\t0.05,\n\t0.0049,\n\t0.00051,\n\t0.000001,\n\t7,\n\t12,\n\t123,\n\t999,\n\t1000,\n\t1234,\n\t9999,\n\t10000,\n\t12345,\n\t99999,\n\t123456,\n\t1234567,\n\t12345678.9,\n\t123456789.123,\n\t9999999.995,\n\t0.1 + 0.2,\n\t314159.26535,\n\t-1234.5678,\n\t-0.001,\n\t1e10 + 0.5,\n\t1e14 + 0.25,\n\t123456789012345,\n\t5.5555555,\n\t1 / 3,\n\t2 / 3,\n\t1e-6,\n\t42.000001,\n];\n\n/** A function that formats numbers as `intl` does, without calling it when its settings allow. */\nexport const numberFormat = (intl: Intl.NumberFormat): Format => {\n\tconst format: Format = (value) => intl.format(value);\n\tconst pattern = readNumberPattern(intl);\n\tif (pattern === null) return format;\n\tconst fast: Format = (value) => formatNumber(pattern, value) ?? format(value);\n\tfor (const sample of NUMBER_SAMPLES) {\n\t\tif (fast(sample) !== format(sample)) return format;\n\t}\n\treturn fast;\n};\n\n// Dates\n\n/** One field or literal of a date pattern. */\ntype DatePart =\n\t| { kind: \"text\"; text: string }\n\t| { kind: \"year\"; twoDigit: boolean }\n\t| { kind: \"month\"; names: readonly string[] | null; twoDigit: boolean }\n\t| { kind: \"day\"; twoDigit: boolean }\n\t| { kind: \"weekday\"; names: readonly string[] }\n\t| { kind: \"hour\"; twoDigit: boolean; twelve: boolean }\n\t| { kind: \"minute\"; twoDigit: boolean }\n\t| { kind: \"second\"; twoDigit: boolean }\n\t| { kind: \"dayPeriod\"; names: readonly [string, string] };\n\nconst DAY = 86_400_000;\n\n/** Times a date pattern handles, the years 1000 to 9999. Others go to the formatter. */\nconst EARLIEST = Date.UTC(1000, 0, 1);\nconst LATEST = Date.UTC(9999, 11, 31, 23, 59, 59, 999);\n\n/** A sample time: 5 March 2026, 13:07:09 UTC, a Thursday. */\nconst SAMPLE = Date.UTC(2026, 2, 5, 13, 7, 9);\n\nconst partOf = (\n\tintl: Intl.DateTimeFormat,\n\ttime: number,\n\ttype: Intl.DateTimeFormatPartTypes,\n): string | null =>\n\tintl.formatToParts(time).find((part) => part.type === type)?.value ?? null;\n\nconst readDatePattern = (\n\tintl: Intl.DateTimeFormat,\n): readonly DatePart[] | null => {\n\tconst options = intl.resolvedOptions() as unknown as Record<string, unknown>;\n\tif (\n\t\toptions.calendar !== \"gregory\" ||\n\t\toptions.numberingSystem !== \"latn\" ||\n\t\toptions.timeZone !== \"UTC\" ||\n\t\toptions.dayPeriod !== undefined ||\n\t\toptions.era !== undefined ||\n\t\toptions.fractionalSecondDigits !== undefined ||\n\t\t(options.hourCycle !== undefined &&\n\t\t\toptions.hourCycle !== \"h23\" &&\n\t\t\toptions.hourCycle !== \"h12\")\n\t) {\n\t\treturn null;\n\t}\n\tconst parts: DatePart[] = [];\n\tfor (const { type, value } of intl.formatToParts(SAMPLE)) {\n\t\tswitch (type) {\n\t\t\tcase \"literal\":\n\t\t\tcase \"timeZoneName\":\n\t\t\t\tparts.push({ kind: \"text\", text: value });\n\t\t\t\tbreak;\n\t\t\tcase \"year\":\n\t\t\t\tif (value !== \"2026\" && value !== \"26\") return null;\n\t\t\t\tparts.push({ kind: \"year\", twoDigit: value === \"26\" });\n\t\t\t\tbreak;\n\t\t\tcase \"month\": {\n\t\t\t\tif (value === \"3\" || value === \"03\") {\n\t\t\t\t\tparts.push({ kind: \"month\", names: null, twoDigit: value === \"03\" });\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (let month = 0; month < 12; month++) {\n\t\t\t\t\tconst name = partOf(intl, Date.UTC(2026, month, 5), \"month\");\n\t\t\t\t\tif (name === null) return null;\n\t\t\t\t\tnames.push(name);\n\t\t\t\t}\n\t\t\t\tparts.push({ kind: \"month\", names, twoDigit: false });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"day\":\n\t\t\t\tif (value !== \"5\" && value !== \"05\") return null;\n\t\t\t\tparts.push({ kind: \"day\", twoDigit: value === \"05\" });\n\t\t\t\tbreak;\n\t\t\tcase \"weekday\": {\n\t\t\t\t// 1 March 2026 is a Sunday, so day k of March is weekday k - 1.\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (let day = 1; day <= 7; day++) {\n\t\t\t\t\tconst name = partOf(intl, Date.UTC(2026, 2, day), \"weekday\");\n\t\t\t\t\tif (name === null) return null;\n\t\t\t\t\tnames.push(name);\n\t\t\t\t}\n\t\t\t\tparts.push({ kind: \"weekday\", names });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"hour\": {\n\t\t\t\tconst twelve = options.hourCycle === \"h12\";\n\t\t\t\tconst early = partOf(intl, Date.UTC(2026, 2, 5, 5), \"hour\");\n\t\t\t\tif (early !== \"5\" && early !== \"05\") return null;\n\t\t\t\tparts.push({ kind: \"hour\", twoDigit: early === \"05\", twelve });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"minute\":\n\t\t\t\tif (value !== \"7\" && value !== \"07\") return null;\n\t\t\t\tparts.push({ kind: \"minute\", twoDigit: value === \"07\" });\n\t\t\t\tbreak;\n\t\t\tcase \"second\":\n\t\t\t\tif (value !== \"9\" && value !== \"09\") return null;\n\t\t\t\tparts.push({ kind: \"second\", twoDigit: value === \"09\" });\n\t\t\t\tbreak;\n\t\t\tcase \"dayPeriod\": {\n\t\t\t\tconst am = partOf(intl, Date.UTC(2026, 2, 5, 1), \"dayPeriod\");\n\t\t\t\tconst pm = partOf(intl, Date.UTC(2026, 2, 5, 13), \"dayPeriod\");\n\t\t\t\tif (am === null || pm === null) return null;\n\t\t\t\tparts.push({ kind: \"dayPeriod\", names: [am, pm] });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\treturn parts;\n};\n\nconst pad = (value: number, twoDigit: boolean): string =>\n\ttwoDigit && value < 10 ? `0${value}` : String(value);\n\n/** Formats a time with a date pattern, working out the UTC date the way `Date` does without making one. */\nconst formatDate = (\n\tparts: readonly DatePart[],\n\tvalue: number,\n): string | null => {\n\tif (!(value >= EARLIEST && value <= LATEST)) return null;\n\tconst time = Math.trunc(value);\n\tconst days = Math.floor(time / DAY);\n\tconst ms = time - days * DAY;\n\t// Civil date from days since 1970-01-01, after Howard Hinnant's `civil_from_days`.\n\tconst shifted = days + 719_468;\n\tconst era = Math.floor(shifted / 146_097);\n\tconst dayOfEra = shifted - era * 146_097;\n\tconst yearOfEra = Math.floor(\n\t\t(dayOfEra -\n\t\t\tMath.floor(dayOfEra / 1460) +\n\t\t\tMath.floor(dayOfEra / 36_524) -\n\t\t\tMath.floor(dayOfEra / 146_096)) /\n\t\t\t365,\n\t);\n\tconst dayOfYear =\n\t\tdayOfEra -\n\t\t(365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n\tconst shiftedMonth = Math.floor((5 * dayOfYear + 2) / 153);\n\tconst day = dayOfYear - Math.floor((153 * shiftedMonth + 2) / 5) + 1;\n\tconst month = shiftedMonth < 10 ? shiftedMonth + 3 : shiftedMonth - 9;\n\tconst year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\t// 1970-01-01 was a Thursday.\n\tconst weekday = (((days + 4) % 7) + 7) % 7;\n\tconst hour = Math.floor(ms / 3_600_000);\n\tconst minute = Math.floor(ms / 60_000) % 60;\n\tconst second = Math.floor(ms / 1000) % 60;\n\tlet text = \"\";\n\tfor (const part of parts) {\n\t\tswitch (part.kind) {\n\t\t\tcase \"text\":\n\t\t\t\ttext += part.text;\n\t\t\t\tbreak;\n\t\t\tcase \"year\":\n\t\t\t\ttext += part.twoDigit ? pad(year % 100, true) : String(year);\n\t\t\t\tbreak;\n\t\t\tcase \"month\":\n\t\t\t\ttext +=\n\t\t\t\t\tpart.names === null\n\t\t\t\t\t\t? pad(month, part.twoDigit)\n\t\t\t\t\t\t: (part.names[month - 1] as string);\n\t\t\t\tbreak;\n\t\t\tcase \"day\":\n\t\t\t\ttext += pad(day, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"weekday\":\n\t\t\t\ttext += part.names[weekday] as string;\n\t\t\t\tbreak;\n\t\t\tcase \"hour\":\n\t\t\t\ttext += pad(part.twelve ? hour % 12 || 12 : hour, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"minute\":\n\t\t\t\ttext += pad(minute, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"second\":\n\t\t\t\ttext += pad(second, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"dayPeriod\":\n\t\t\t\ttext += part.names[hour < 12 ? 0 : 1];\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn text;\n};\n\n/** Times a date pattern must format as its formatter does: every month and weekday, hours, leap days and centuries. */\nconst dateSamples = (): number[] => {\n\tconst samples: number[] = [EARLIEST, LATEST, 0, -1];\n\tfor (let month = 0; month < 12; month++) {\n\t\tfor (const day of [1, 9, 10, 28]) {\n\t\t\tsamples.push(Date.UTC(2026, month, day, (month * 2) % 24, day, month));\n\t\t}\n\t}\n\tfor (let hour = 0; hour < 24; hour++) {\n\t\tsamples.push(Date.UTC(1999, 11, 31, hour, 59, 59, 999));\n\t}\n\tfor (const year of [1000, 1600, 1900, 1969, 2000, 2024, 2100, 9999]) {\n\t\tsamples.push(Date.UTC(year, 1, 28), Date.UTC(year, 2, 1, 12));\n\t}\n\tsamples.push(Date.UTC(2024, 1, 29, 0, 0, 1));\n\treturn samples;\n};\n\nconst DATE_SAMPLES = dateSamples();\n\n/** A function that formats times as `intl` does, without calling it when its settings allow. */\nexport const dateFormat = (intl: Intl.DateTimeFormat): Format => {\n\tconst format: Format = (value) => intl.format(value);\n\tconst parts = readDatePattern(intl);\n\tif (parts === null) return format;\n\tconst fast: Format = (value) => formatDate(parts, value) ?? format(value);\n\tfor (const sample of DATE_SAMPLES) {\n\t\tif (fast(sample) !== format(sample)) return format;\n\t}\n\treturn fast;\n};\n","import { issue } from \"../errors.js\";\nimport { escapeHtml, escapeUrl } from \"../runtime/escape.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport {\n\tall,\n\tcheckLength,\n\tconsume,\n\thold,\n\tisPromise,\n\tsilence,\n\tunhold,\n} from \"../runtime/render.js\";\nimport type { CallableEntry, Run } from \"../runtime/types.js\";\nimport {\n\tBLOCKED_NAMES,\n\tcompare,\n\tFORMATTERS,\n\ttype FormatterCells,\n\thashKeys,\n\tisHashLike,\n\tisPlainObject,\n\tsetOwn,\n\ttoNumber,\n\ttoStr,\n\ttoStringArgument,\n\tvalueLabel,\n\ttruthy,\n\ttypeName,\n\tunwrap,\n} from \"../runtime/values.js\";\nimport { dateFormat, type Format, numberFormat } from \"./formatters.js\";\nimport {\n\tcheckDepth,\n\tentriesOf,\n\tfromPieces,\n\tfunctionArgument,\n\tinsertedPiece,\n\tintegerArgument,\n\tisHtmlStrategy,\n\tKept,\n\tlistOf,\n\tmapContents,\n\tmarkupText,\n\ttype Pieces,\n\treadProperty,\n\tscanHtml,\n\ttoPieces,\n\ttoTime,\n\ttoPlainData,\n} from \"./helpers.js\";\n\ntype BuiltinEntry = Extract<CallableEntry, { kind: \"builtin\" }>;\n\nconst define = (\n\tcall: BuiltinEntry[\"call\"],\n\tparams: readonly string[] = [],\n\toptions = false,\n): BuiltinEntry => ({ kind: \"builtin\", call, params, options });\n\n/** Counts code points without allocating an array. A surrogate without its partner counts as one, as `split` does. */\nconst codePointLength = (text: string): number => {\n\tlet count = 0;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\tif (code >= 0xd800 && code <= 0xdbff) {\n\t\t\tconst next = text.charCodeAt(i + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) i++;\n\t\t}\n\t\tcount++;\n\t}\n\treturn count;\n};\n\nconst SURROGATE = /[\\uD800-\\uDFFF]/;\n\n/** The UTF-16 index just after the first `count` code points, or the text's length when it has fewer. */\nconst codePointOffset = (text: string, count: number): number => {\n\tlet index = 0;\n\tfor (let n = 0; n < count && index < text.length; n++) {\n\t\tconst code = text.charCodeAt(index);\n\t\tconst next = text.charCodeAt(index + 1);\n\t\tindex +=\n\t\t\tcode >= 0xd800 && code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff\n\t\t\t\t? 2\n\t\t\t\t: 1;\n\t}\n\treturn index;\n};\n\n/** Splits text into code points, which is how string filters count characters. */\n// oxlint-disable-next-line typescript/no-misused-spread -- code points are the documented unit, not graphemes\nconst codePoints = (text: string): string[] => [...text];\n\nconst trimCharacters = (\n\ttext: string,\n\tcharacters: string,\n\tside: string,\n): string => {\n\tconst set = new Set(characters);\n\tconst chars = codePoints(text);\n\tlet start = 0;\n\tlet end = chars.length;\n\tif (side !== \"end\")\n\t\twhile (start < end && set.has(chars[start] as string)) start++;\n\tif (side !== \"start\")\n\t\twhile (end > start && set.has(chars[end - 1] as string)) end--;\n\treturn chars.slice(start, end).join(\"\");\n};\n\n/** Refuses a string a filter would build longer than `maxOutputLength`, before it builds it. */\nconst refuseLength = (run: Run, length: number, what: string): void => {\n\tif (length > run.state.maxSize) {\n\t\tissue(\n\t\t\t\"limit-output\",\n\t\t\t`\"${what}\" would build a string longer than the output limit of ${run.state.maxSize}`,\n\t\t);\n\t}\n};\n\n/**\n * Runs a string filter over markup's text. Tags, comments and entities stay as they are, and the result is markup of\n * the same strategy, so it isn't escaped again.\n */\nconst changeMarkup = (\n\trun: Run,\n\tmarkup: Markup,\n\tchange: (pieces: Pieces) => Pieces,\n): Markup => {\n\tcheckLength(run, markup.value);\n\treturn fromPieces(run, change(toPieces(markup)), markup.strategy);\n};\n\nconst mapText = (pieces: Pieces, change: (text: string) => string): Pieces =>\n\tpieces.map((piece) => (typeof piece === \"string\" ? change(piece) : piece));\n\n/** Joins the pieces of plain text, which never holds kept pieces. */\nconst joinText = (pieces: Pieces): string =>\n\tpieces\n\t\t.map((piece) => (typeof piece === \"string\" ? piece : piece.html))\n\t\t.join(\"\");\n\nconst upperFirst = (text: string): string => {\n\tconst head = String.fromCodePoint(text.codePointAt(0) as number);\n\treturn head.toUpperCase() + text.slice(head.length);\n};\n\n/** Upper-cases the first character of the text and lower-cases the rest. */\nconst capitalizeText = (text: string): string => {\n\tconst first = text.codePointAt(0);\n\tif (first === undefined) return \"\";\n\tconst head = String.fromCodePoint(first);\n\treturn head.toUpperCase() + text.slice(head.length).toLowerCase();\n};\n\n/** `capitalizeText` over pieces: the first character of the first text that has one. */\nconst capitalizePieces = (pieces: Pieces): Pieces => {\n\tlet first = true;\n\treturn mapText(pieces, (text) => {\n\t\tif (!first || text === \"\") return text.toLowerCase();\n\t\tfirst = false;\n\t\treturn capitalizeText(text);\n\t});\n};\n\n/** Letters, marks, digits and apostrophes, so neither a combining accent nor the apostrophe in \"o'neil\" starts a word. */\nconst WORD = /[\\p{L}\\p{M}\\p{N}'’]+/gu;\nconst STARTS_WITH_LETTER = /^\\p{L}/u;\nconst ENDS_IN_WORD = /[\\p{L}\\p{M}\\p{N}'’]$/u;\n\n/** Starts each word with an upper-case letter and lower-cases the rest. The first word only when `boundary` is true. */\nconst titleText = (text: string, boundary: boolean): string =>\n\ttext\n\t\t.toLowerCase()\n\t\t.replace(WORD, (word, offset: number) =>\n\t\t\t(offset > 0 || boundary) && STARTS_WITH_LETTER.test(word)\n\t\t\t\t? upperFirst(word)\n\t\t\t\t: word,\n\t\t);\n\n/** `titleText` over pieces. Tags don't end a word, but kept entities do. */\nconst titlePieces = (pieces: Pieces): Pieces => {\n\tlet boundary = true;\n\treturn pieces.map((piece) => {\n\t\tif (typeof piece !== \"string\") {\n\t\t\tif (!piece.html.startsWith(\"<\")) boundary = true;\n\t\t\treturn piece;\n\t\t}\n\t\tconst text = titleText(piece, boundary);\n\t\tboundary = !ENDS_IN_WORD.test(piece);\n\t\treturn text;\n\t});\n};\n\n/** Trims the text at each end of the pieces, stopping at a kept piece such as a tag. */\nconst trimPieces = (\n\tpieces: Pieces,\n\tside: string,\n\ttrimText: (text: string, side: \"start\" | \"end\") => string,\n): Pieces => {\n\tconst result = [...pieces];\n\tif (side !== \"end\") {\n\t\tfor (let i = 0; i < result.length; i++) {\n\t\t\tconst piece = result[i];\n\t\t\tif (typeof piece !== \"string\") break;\n\t\t\tresult[i] = trimText(piece, \"start\");\n\t\t\tif (result[i] !== \"\") break;\n\t\t}\n\t}\n\tif (side !== \"start\") {\n\t\tfor (let i = result.length - 1; i >= 0; i--) {\n\t\t\tconst piece = result[i];\n\t\t\tif (typeof piece !== \"string\") break;\n\t\t\tresult[i] = trimText(piece, \"end\");\n\t\t\tif (result[i] !== \"\") break;\n\t\t}\n\t}\n\treturn result;\n};\n\n/** Text a filter inserts: plain text, or markup kept as it is. */\ntype Insert = string | Kept;\n\nconst insertLength = (insert: Insert): number =>\n\ttypeof insert === \"string\" ? insert.length : insert.html.length;\n\n/**\n * Replaces several strings at once, preferring the longest match at each position. Candidates are looked up by their\n * first character, and the characters compared are charged against `maxSteps`, 256 to a step. The result is checked\n * against `maxOutputLength` as it grows, before it is joined.\n */\nconst replacePairs = (\n\trun: Run,\n\ttext: string,\n\tpairs: [string, Insert][],\n): Pieces => {\n\tconst byFirst = new Map<string, [string, Insert][]>();\n\tfor (const pair of pairs) {\n\t\tconst first = pair[0][0];\n\t\tif (first === undefined) continue;\n\t\tconst list = byFirst.get(first);\n\t\tif (list) list.push(pair);\n\t\telse byFirst.set(first, [pair]);\n\t}\n\tfor (const list of byFirst.values()) {\n\t\tlist.sort((a, b) => b[0].length - a[0].length);\n\t}\n\tconst pieces: Pieces = [];\n\tlet start = 0;\n\tlet i = 0;\n\tlet length = 0;\n\tlet compared = 0;\n\twhile (i < text.length) {\n\t\tconst candidates = byFirst.get(text[i] as string);\n\t\tlet match: [string, Insert] | undefined;\n\t\tif (candidates) {\n\t\t\tfor (const pair of candidates) {\n\t\t\t\tcompared += pair[0].length;\n\t\t\t\tif (text.startsWith(pair[0], i)) {\n\t\t\t\t\tmatch = pair;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (compared >= 256) {\n\t\t\t\tconsume(run, compared >> 8);\n\t\t\t\tcompared &= 255;\n\t\t\t}\n\t\t}\n\t\tif (!match) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tlength += i - start + insertLength(match[1]);\n\t\trefuseLength(run, length, \"replace\");\n\t\tif (i > start) pieces.push(text.slice(start, i));\n\t\tpieces.push(match[1]);\n\t\ti += match[0].length;\n\t\tstart = i;\n\t}\n\trefuseLength(run, length + text.length - start, \"replace\");\n\tif (start < text.length) pieces.push(text.slice(start));\n\treturn pieces;\n};\n\n/** Elements that have no closing tag. */\nconst VOID_ELEMENTS = new Set([\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\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\nconst TAG_NAME = /^<(\\/?)([a-zA-Z][^\\s/>]*)/;\n\n/**\n * Cuts markup's text after `max` characters, counting a kept entity as one, and adds `ending`. The tags still open at\n * the cut are closed, so the HTML stays balanced.\n */\nconst truncatePieces = (\n\tpieces: Pieces,\n\tmax: number,\n\tending: Insert,\n): Pieces => {\n\tconst result: Pieces = [];\n\tconst open: string[] = [];\n\tlet remaining = max;\n\tfor (const piece of pieces) {\n\t\tif (typeof piece !== \"string\" && piece.html.startsWith(\"<\")) {\n\t\t\tresult.push(piece);\n\t\t\tconst [, closing, name] = TAG_NAME.exec(piece.html) ?? [];\n\t\t\tconst tag = name?.toLowerCase();\n\t\t\tif (tag === undefined || VOID_ELEMENTS.has(tag)) continue;\n\t\t\tif (closing) {\n\t\t\t\tconst index = open.lastIndexOf(tag);\n\t\t\t\tif (index !== -1) open.length = index;\n\t\t\t} else if (!piece.html.endsWith(\"/>\")) open.push(tag);\n\t\t\tcontinue;\n\t\t}\n\t\tconst length = typeof piece === \"string\" ? codePointLength(piece) : 1;\n\t\tif (length <= remaining) {\n\t\t\tresult.push(piece);\n\t\t\tremaining -= length;\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof piece === \"string\" && remaining > 0) {\n\t\t\tresult.push(piece.slice(0, codePointOffset(piece, remaining)));\n\t\t}\n\t\tconst last = result[result.length - 1];\n\t\tif (typeof last === \"string\") result[result.length - 1] = last.trimEnd();\n\t\tresult.push(ending);\n\t\tfor (let i = open.length - 1; i >= 0; i--) {\n\t\t\tresult.push(new Kept(`</${open[i] as string}>`));\n\t\t}\n\t\treturn result;\n\t}\n\treturn result;\n};\n\nconst roundNumber = (\n\tvalue: number,\n\tprecision: number,\n\tmethod: string,\n): number => {\n\tif (method !== \"common\" && method !== \"ceil\" && method !== \"floor\") {\n\t\treturn issue(\n\t\t\t\"invalid-argument\",\n\t\t\t`\"round\" method must be \"common\", \"ceil\" or \"floor\", but got \"${method}\"`,\n\t\t);\n\t}\n\tconst shift = (number: number, exponent: number) => {\n\t\tconst [mantissa, power = \"0\"] = String(number).split(\"e\");\n\t\treturn Number(`${mantissa}e${Number(power) + exponent}`);\n\t};\n\tconst scaled = shift(\n\t\tmethod === \"common\" ? Math.abs(value) : value,\n\t\tprecision,\n\t);\n\t// Infinity, NaN and numbers with fewer decimal places than `precision` can hold are already rounded.\n\tif (!Number.isFinite(scaled)) return value;\n\tconst rounded = shift(\n\t\tmethod === \"ceil\"\n\t\t\t? Math.ceil(scaled)\n\t\t\t: method === \"floor\"\n\t\t\t\t? Math.floor(scaled)\n\t\t\t\t: Math.round(scaled),\n\t\t-precision,\n\t);\n\treturn method === \"common\" && value < 0 ? -rounded : rounded;\n};\n\n/**\n * Builds `urlEncode`'s query string from a hash. Each list and hash is charged against `maxSteps` before it is read,\n * and the text stops at `maxOutputLength` before each part is encoded, so a value that shares one object in many\n * places can't make unlimited work.\n */\nconst queryString = (run: Run, hash: object): string => {\n\tconst parts: string[] = [];\n\tconst seen = new Set<object>();\n\tlet length = 0;\n\tconst add = (value: object, prefix: string | null, depth: number) => {\n\t\tcheckDepth(depth, \"urlEncode\");\n\t\tconst { values, keys } = entriesOf(run, value, \"urlEncode\");\n\t\tseen.add(value);\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tconst item = values[i];\n\t\t\tif (item === null || item === undefined) continue;\n\t\t\tconst key =\n\t\t\t\tprefix === null ? String(keys[i]) : `${prefix}[${String(keys[i])}]`;\n\t\t\tif (\n\t\t\t\tArray.isArray(item) ||\n\t\t\t\tisPlainObject(item) ||\n\t\t\t\titem instanceof Map ||\n\t\t\t\titem instanceof Set\n\t\t\t) {\n\t\t\t\tif (seen.has(item)) {\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t\t'\"urlEncode\" cannot encode a value that contains itself',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tadd(item, key, depth + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst text = toStr(item);\n\t\t\t// Encoding never makes text shorter, so check before encoding, and again after.\n\t\t\trefuseLength(run, length + key.length + text.length, \"urlEncode\");\n\t\t\tconst part = `${escapeUrl(key)}=${escapeUrl(text)}`;\n\t\t\tlength += part.length + 1;\n\t\t\trefuseLength(run, length - 1, \"urlEncode\");\n\t\t\tparts.push(part);\n\t\t}\n\t\tseen.delete(value);\n\t};\n\tadd(hash, null, 1);\n\treturn parts.join(\"&\");\n};\n\nconst formatterCache = new Map<string, Formatter>();\n\n/** Longer cache keys aren't cached, so templates can't fill the cache with large strings. */\nconst MAX_FORMATTER_KEY = 512;\n\nconst NUMBER_OPTIONS = new Set([\n\t\"localeMatcher\",\n\t\"style\",\n\t\"currency\",\n\t\"currencyDisplay\",\n\t\"currencySign\",\n\t\"unit\",\n\t\"unitDisplay\",\n\t\"minimumIntegerDigits\",\n\t\"minimumFractionDigits\",\n\t\"maximumFractionDigits\",\n\t\"minimumSignificantDigits\",\n\t\"maximumSignificantDigits\",\n\t\"roundingPriority\",\n\t\"roundingIncrement\",\n\t\"roundingMode\",\n\t\"trailingZeroDisplay\",\n\t\"notation\",\n\t\"compactDisplay\",\n\t\"useGrouping\",\n\t\"signDisplay\",\n\t\"numberingSystem\",\n]);\n\n/** `plural` options configure both its plural rules and the number `#` becomes. */\nconst PLURAL_OPTIONS = new Set([...NUMBER_OPTIONS, \"type\"]);\n\n/** Date options that choose what to show. Without one, `formatDate` uses `dateStyle: \"medium\"`. */\nconst DATE_STYLE_OPTIONS = new Set([\n\t\"dateStyle\",\n\t\"timeStyle\",\n\t\"weekday\",\n\t\"era\",\n\t\"year\",\n\t\"month\",\n\t\"day\",\n\t\"dayPeriod\",\n\t\"hour\",\n\t\"minute\",\n\t\"second\",\n\t\"fractionalSecondDigits\",\n\t\"timeZoneName\",\n]);\n\nconst DATE_OPTIONS = new Set([\n\t...DATE_STYLE_OPTIONS,\n\t\"localeMatcher\",\n\t\"calendar\",\n\t\"numberingSystem\",\n\t\"hour12\",\n\t\"hourCycle\",\n\t\"timeZone\",\n\t\"formatMatcher\",\n]);\n\n/** Keys of frozen options hashes, which the compiler builds once for literal named arguments. */\nconst optionsKeys = new WeakMap<object, string>();\n\n/**\n * The part of a formatter's cache key its options make. Option names must be ones `Intl` knows, from `names`. Option\n * values must be strings, markup, numbers, booleans or null: `JSON.stringify` and `Intl` would call methods such as\n * `toJSON` and `toString` on anything else.\n */\nconst optionsKey = (\n\toptions: Record<string, unknown>,\n\tnames: ReadonlySet<string>,\n): string => {\n\tconst frozen = Object.isFrozen(options);\n\tlet key = frozen ? optionsKeys.get(options) : undefined;\n\tif (key !== undefined) return key;\n\tkey = \"\";\n\tfor (const name of hashKeys(options)) {\n\t\tif (name === \"locale\") continue;\n\t\tif (!names.has(name)) {\n\t\t\treturn issue(\"invalid-argument\", `Unknown formatting option \"${name}\"`);\n\t\t}\n\t\tconst value = unwrap(options[name]);\n\t\tif (\n\t\t\t(typeof value === \"object\" && value !== null) ||\n\t\t\ttypeof value === \"function\"\n\t\t) {\n\t\t\treturn issue(\n\t\t\t\t\"type-error\",\n\t\t\t\t`Formatting option \"${name}\" must be a string, number or boolean, but got ${valueLabel(value)}`,\n\t\t\t);\n\t\t}\n\t\tkey += `|${name}=${JSON.stringify(value)}`;\n\t}\n\tif (frozen) optionsKeys.set(options, key);\n\treturn key;\n};\n\ntype Formatter = Format | Intl.PluralRules;\n\n/** Formatters that calls without options last resolved to. */\nconst NO_OPTIONS: FormatterCells = {};\n\n/**\n * Splits `locale` out of filter options and caches the formatter by its settings. `names` are the options allowed, and\n * `defaults` gives the settings the options are merged over.\n *\n * Calls without options, or with a hash of literals such as `formatNumber(style: \"currency\")`'s, which\n * `literalOptions` gives a place for it, first try the formatter they used last, so a filter called in a loop skips\n * building the cache key.\n */\nconst cachedFormatter = <T extends Formatter>(\n\tkind: \"number\" | \"date\" | \"plural\",\n\trun: Run,\n\toptions: unknown,\n\tnames: ReadonlySet<string>,\n\tdefaults: (options: Record<string, unknown>) => Record<string, unknown>,\n\tcreate: (locale: string, options: Record<string, unknown>) => T,\n): T => {\n\tconst { state } = run;\n\tconst cells =\n\t\toptions === undefined || options === null\n\t\t\t? NO_OPTIONS\n\t\t\t: typeof options === \"object\"\n\t\t\t\t? (options as { [FORMATTERS]?: FormatterCells })[FORMATTERS]\n\t\t\t\t: undefined;\n\tconst recent = cells?.[kind];\n\tif (\n\t\trecent &&\n\t\trecent.locale === state.locale &&\n\t\trecent.timeZone === state.timeZone\n\t) {\n\t\treturn recent.formatter as T;\n\t}\n\tif (options !== undefined && options !== null && !isPlainObject(options)) {\n\t\treturn issue(\n\t\t\t\"type-error\",\n\t\t\t`Formatting options must be a hash, but got a ${typeName(options)}`,\n\t\t);\n\t}\n\tconst given = (options ?? {}) as Record<string, unknown>;\n\tconst locale = given.locale === undefined ? run.state.locale : given.locale;\n\tif (typeof locale !== \"string\") {\n\t\treturn issue(\"type-error\", '\"locale\" must be a string');\n\t}\n\t// The key lists defaults then options in order, which fixes the merged settings, without building them on a hit.\n\tconst base = defaults(given);\n\tlet key = `${kind}|${locale}`;\n\tfor (const name in base) key += `|${name}=${JSON.stringify(base[name])}`;\n\tkey += optionsKey(given, names);\n\tconst cacheable = key.length <= MAX_FORMATTER_KEY;\n\tlet formatter = cacheable\n\t\t? (formatterCache.get(key) as T | undefined)\n\t\t: undefined;\n\tif (!formatter) {\n\t\tconst settings = { ...base };\n\t\tfor (const name of hashKeys(given)) {\n\t\t\tif (name !== \"locale\") setOwn(settings, name, unwrap(given[name]));\n\t\t}\n\t\tformatter = create(locale, settings);\n\t\tif (cacheable) {\n\t\t\tif (formatterCache.size > 500) formatterCache.clear();\n\t\t\tformatterCache.set(key, formatter);\n\t\t}\n\t}\n\tif (cells) {\n\t\tcells[kind] = {\n\t\t\tlocale: state.locale,\n\t\t\ttimeZone: state.timeZone,\n\t\t\tformatter,\n\t\t};\n\t}\n\treturn formatter;\n};\n\n/** Calls a template callback for each item, then gathers the results, waiting only if one was a promise. */\nconst mapEntries = (\n\trun: Run,\n\tvalue: unknown,\n\tcallback: unknown,\n\twhat: string,\n\tgather: (\n\t\tresults: unknown[],\n\t\tvalues: unknown[],\n\t\tkeys: unknown[],\n\t\tisHash: boolean,\n\t) => unknown,\n): unknown => {\n\tconst fn = functionArgument(callback, what);\n\tconst { values, keys, isHash } = entriesOf(run, value, what);\n\tconst results: unknown[] = [];\n\ttry {\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tresults.push(fn(values[i], keys[i]));\n\t\t}\n\t} catch (error) {\n\t\t// Earlier callbacks may have started async work. Stop their rejections being reported as unhandled.\n\t\tfor (const result of results) silence(result);\n\t\tthrow error;\n\t}\n\tif (results.some(isPromise)) {\n\t\treturn all(results).then((resolved) =>\n\t\t\thold(gather(resolved, values, keys, isHash)),\n\t\t);\n\t}\n\treturn gather(results, values, keys, isHash);\n};\n\nconst buildCollection = (\n\tisHash: boolean,\n\tkeys: unknown[],\n\titems: unknown[],\n): unknown[] | Record<string, unknown> => {\n\tif (!isHash) return items;\n\tconst result: Record<string, unknown> = {};\n\titems.forEach((item, index) => {\n\t\tsetOwn(result, String(keys[index]), item);\n\t});\n\treturn result;\n};\n\nconst syncResult = (value: unknown, what: string): unknown => {\n\tif (isPromise(value)) {\n\t\tvalue.catch(() => {});\n\t\treturn issue(\n\t\t\t\"invalid-argument\",\n\t\t\t`\"${what}\" callbacks must not wait for async data`,\n\t\t);\n\t}\n\treturn value;\n};\n\n/**\n * Removes HTML tags and comments. Where a `<` would end up before a letter once a tag after it is removed, it is\n * dropped too, so removing tags can't make new ones.\n */\nconst stripTags = (html: string): string => {\n\tconst parts: string[] = [];\n\tscanHtml(\n\t\thtml,\n\t\t(text) => {\n\t\t\tconst last = parts.length - 1;\n\t\t\tconst previous = parts[last];\n\t\t\tif (previous?.endsWith(\"<\") && /^[a-zA-Z!?/]/.test(text)) {\n\t\t\t\tparts[last] = previous.slice(0, -1);\n\t\t\t}\n\t\t\tparts.push(text);\n\t\t},\n\t\t() => {},\n\t);\n\treturn parts.join(\"\");\n};\n\n/** `sort`'s order: natural order without `by`, by a key with a one-parameter arrow, or with a comparator. */\nconst sortBy = <T>(\n\titems: T[],\n\tread: (item: T) => unknown,\n\tby: unknown,\n): T[] => {\n\tif (by === undefined || by === null) {\n\t\treturn items.sort((a, b) => compare(read(a), read(b)));\n\t}\n\tconst fn = functionArgument(by, \"sort\");\n\tif (fn.length >= 2) {\n\t\treturn items.sort((a, b) => {\n\t\t\tconst result = syncResult(fn(read(a), read(b)), \"sort\");\n\t\t\treturn typeof result === \"number\"\n\t\t\t\t? result\n\t\t\t\t: issue(\"type-error\", '\"sort\" comparator must return a number');\n\t\t});\n\t}\n\tconst keyed = items.map((item) => ({\n\t\titem,\n\t\tkey: syncResult(fn(read(item)), \"sort\"),\n\t}));\n\tkeyed.sort((a, b) => compare(a.key, b.key));\n\treturn keyed.map((entry) => entry.item);\n};\n\nconst allStrings = (items: unknown[]): items is string[] => {\n\tfor (let i = 0; i < items.length; i++) {\n\t\tif (typeof items[i] !== \"string\") return false;\n\t}\n\treturn true;\n};\n\n/**\n * Sorts strings by UTF-16 code units, as the default sort does, which skips calling `compare`. Short lists, such as a\n * post's tags, sort in place by insertion, which keeps the same order and is faster for them.\n */\nconst sortStrings = (items: string[]): string[] => {\n\tif (items.length > 16) return items.sort();\n\tfor (let i = 1; i < items.length; i++) {\n\t\tconst item = items[i] as string;\n\t\tlet j = i - 1;\n\t\twhile (j >= 0 && (items[j] as string) > item) {\n\t\t\titems[j + 1] = items[j] as string;\n\t\t\tj--;\n\t\t}\n\t\titems[j + 1] = item;\n\t}\n\treturn items;\n};\n\n/** A hash of keys and values in the order given. A `Map`, so keys that look like numbers keep their place too. */\nconst orderedHash = (\n\tkeys: unknown[],\n\tvalues: unknown[],\n): Map<string, unknown> =>\n\tnew Map(keys.map((key, index) => [String(key), values[index]]));\n\n// Case changes for markup's text.\nconst toUpper = (text: string): string => text.toUpperCase();\nconst toLower = (text: string): string => text.toLowerCase();\nconst upperPieces = (pieces: Pieces): Pieces => mapText(pieces, toUpper);\nconst lowerPieces = (pieces: Pieces): Pieces => mapText(pieces, toLower);\n\n/** Escapes characters that could end a `<script>` element or break JavaScript, inside JSON strings. */\nconst escapeJson = (json: string): string =>\n\tjson.replace(\n\t\t/[<>&\\u2028\\u2029]/g,\n\t\t(char) => `\\\\u${char.charCodeAt(0).toString(16).padStart(4, \"0\")}`,\n\t);\n\nexport const builtinFilters: Record<string, BuiltinEntry> = {\n\t// Changing case makes text at most three times longer, and changing it again doesn't add more, so these leave the\n\t// output limit to whatever prints the result. A check here would cost the commonest filters a fifth of their speed.\n\tupper: define((run, value) =>\n\t\ttypeof value === \"string\"\n\t\t\t? value.toUpperCase()\n\t\t\t: value instanceof Markup\n\t\t\t\t? changeMarkup(run, value, upperPieces)\n\t\t\t\t: toStringArgument(value, '\"upper\"').toUpperCase(),\n\t),\n\tlower: define((run, value) =>\n\t\ttypeof value === \"string\"\n\t\t\t? value.toLowerCase()\n\t\t\t: value instanceof Markup\n\t\t\t\t? changeMarkup(run, value, lowerPieces)\n\t\t\t\t: toStringArgument(value, '\"lower\"').toLowerCase(),\n\t),\n\tcapitalize: define((run, value) =>\n\t\ttypeof value !== \"string\" && value instanceof Markup\n\t\t\t? changeMarkup(run, value, capitalizePieces)\n\t\t\t: capitalizeText(toStringArgument(value, '\"capitalize\"')),\n\t),\n\ttitle: define((run, value) =>\n\t\tvalue instanceof Markup\n\t\t\t? changeMarkup(run, value, titlePieces)\n\t\t\t: titleText(toStringArgument(value, '\"title\"'), true),\n\t),\n\ttrim: define(\n\t\t(run, value, characters, side = \"both\") => {\n\t\t\tif (side !== \"both\" && side !== \"start\" && side !== \"end\") {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t`\"trim\" side must be \"both\", \"start\" or \"end\", but got ${valueLabel(side)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst set =\n\t\t\t\tcharacters === undefined || characters === null\n\t\t\t\t\t? null\n\t\t\t\t\t: toStringArgument(characters, '\"trim\"');\n\t\t\tif (typeof value !== \"string\" && value instanceof Markup) {\n\t\t\t\tconst trimText = (text: string, end: \"start\" | \"end\") =>\n\t\t\t\t\tset !== null\n\t\t\t\t\t\t? trimCharacters(text, set, end)\n\t\t\t\t\t\t: end === \"start\"\n\t\t\t\t\t\t\t? text.trimStart()\n\t\t\t\t\t\t\t: text.trimEnd();\n\t\t\t\treturn changeMarkup(run, value, (pieces) =>\n\t\t\t\t\ttrimPieces(pieces, side, trimText),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst text = toStringArgument(value, '\"trim\"');\n\t\t\tif (set !== null) return trimCharacters(text, set, side);\n\t\t\treturn side === \"start\"\n\t\t\t\t? text.trimStart()\n\t\t\t\t: side === \"end\"\n\t\t\t\t\t? text.trimEnd()\n\t\t\t\t\t: text.trim();\n\t\t},\n\t\t[\"characters\", \"side\"],\n\t),\n\treplace: define(\n\t\t(run, value, search, replacement) => {\n\t\t\tconst isPairs = isPlainObject(search) || search instanceof Map;\n\t\t\tif (value instanceof Markup) {\n\t\t\t\tconst { strategy } = value;\n\t\t\t\tconst pairs: [string, Insert][] = [];\n\t\t\t\tif (isPairs) {\n\t\t\t\t\tconst { values, keys } = entriesOf(run, search, \"replace\");\n\t\t\t\t\tkeys.forEach((key, index) => {\n\t\t\t\t\t\tpairs.push([\n\t\t\t\t\t\t\tString(key),\n\t\t\t\t\t\t\tinsertedPiece(values[index], strategy, '\"replace\"'),\n\t\t\t\t\t\t]);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tpairs.push([\n\t\t\t\t\t\tsearch instanceof Markup\n\t\t\t\t\t\t\t? markupText(search)\n\t\t\t\t\t\t\t: toStringArgument(search, '\"replace\"'),\n\t\t\t\t\t\tinsertedPiece(replacement, strategy, '\"replace\"'),\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t\treturn changeMarkup(run, value, (pieces) =>\n\t\t\t\t\tpieces.flatMap((piece) =>\n\t\t\t\t\t\ttypeof piece === \"string\"\n\t\t\t\t\t\t\t? replacePairs(run, piece, pairs)\n\t\t\t\t\t\t\t: [piece],\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst text = toStringArgument(value, '\"replace\"');\n\t\t\tif (isPairs) {\n\t\t\t\tconst { values, keys } = entriesOf(run, search, \"replace\");\n\t\t\t\treturn joinText(\n\t\t\t\t\treplacePairs(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\tkeys.map((key, index) => [String(key), toStr(values[index])]),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst needle = toStringArgument(search, '\"replace\"');\n\t\t\tif (needle === \"\") return text;\n\t\t\tconst parts = text.split(needle);\n\t\t\tconst glue = toStringArgument(replacement, '\"replace\"');\n\t\t\t// Each match swaps the needle for the replacement.\n\t\t\trefuseLength(\n\t\t\t\trun,\n\t\t\t\ttext.length + (parts.length - 1) * (glue.length - needle.length),\n\t\t\t\t\"replace\",\n\t\t\t);\n\t\t\treturn parts.join(glue);\n\t\t},\n\t\t[\"search\", \"replacement\"],\n\t),\n\tsplit: define(\n\t\t(run, value, separator, limit) => {\n\t\t\tconst text = toStringArgument(value, '\"split\"');\n\t\t\tconst glue = toStringArgument(separator, '\"split\"');\n\t\t\tconst parts = glue === \"\" ? codePoints(text) : text.split(glue);\n\t\t\tconsume(run, parts.length);\n\t\t\tif (limit === undefined || limit === null) return parts;\n\t\t\treturn parts.slice(\n\t\t\t\t0,\n\t\t\t\tMath.max(0, integerArgument(limit, '\"split\" limit')),\n\t\t\t);\n\t\t},\n\t\t[\"separator\", \"limit\"],\n\t),\n\ttruncate: define(\n\t\t(run, value, length, ellipsis = \"…\") => {\n\t\t\tconst max = integerArgument(length, '\"truncate\" length');\n\t\t\tif (value instanceof Markup) {\n\t\t\t\tconst ending = insertedPiece(ellipsis, value.strategy, '\"truncate\"');\n\t\t\t\treturn changeMarkup(run, value, (pieces) =>\n\t\t\t\t\ttruncatePieces(pieces, max, ending),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst text = toStringArgument(value, '\"truncate\"');\n\t\t\tif (text.length <= max) return text;\n\t\t\tconst end = SURROGATE.test(text)\n\t\t\t\t? codePointOffset(text, max)\n\t\t\t\t: Math.max(0, max);\n\t\t\tif (max >= 0 && end === text.length) return text;\n\t\t\t// The ending can be any string, even the text itself, so the result can be longer than the text.\n\t\t\treturn checkLength(\n\t\t\t\trun,\n\t\t\t\ttext.slice(0, end).trimEnd() + toStringArgument(ellipsis, '\"truncate\"'),\n\t\t\t);\n\t\t},\n\t\t[\"length\", \"ellipsis\"],\n\t),\n\tstripTags: define((run, value) => {\n\t\tif (!(value instanceof Markup)) {\n\t\t\treturn stripTags(toStringArgument(value, '\"stripTags\"'));\n\t\t}\n\t\t// HTML markup's text stays escaped. Other markup's text is decoded, stripped and escaped again.\n\t\treturn isHtmlStrategy(value.strategy)\n\t\t\t? new Markup(stripTags(value.value), value.strategy)\n\t\t\t: fromPieces(run, [stripTags(markupText(value))], value.strategy);\n\t}),\n\tnl2br: define((run, value) => {\n\t\t// Markup made for any strategy is also safe in HTML.\n\t\tconst html =\n\t\t\tvalue instanceof Markup\n\t\t\t\t? value.value\n\t\t\t\t: escapeHtml(checkLength(run, toStr(value)));\n\t\tlet breaks = 0;\n\t\tfor (let i = 0; i < html.length; i++) {\n\t\t\tconst code = html.charCodeAt(i);\n\t\t\tif (code === 10 || (code === 13 && html.charCodeAt(i + 1) !== 10)) {\n\t\t\t\tbreaks++;\n\t\t\t}\n\t\t}\n\t\trefuseLength(run, html.length + breaks * 4, \"nl2br\");\n\t\treturn new Markup(html.replace(/\\r\\n|\\n|\\r/g, \"<br>$&\"), \"html\");\n\t}),\n\turlEncode: define((run, value) => {\n\t\t// Encoding again makes text three times longer each time, so it stops at the output limit.\n\t\tif (typeof value === \"string\") return escapeUrl(value, run.state.maxSize);\n\t\tconst target = unwrap(value);\n\t\tif (isPlainObject(target) || target instanceof Map) {\n\t\t\treturn queryString(run, target);\n\t\t}\n\t\treturn escapeUrl(toStr(target), run.state.maxSize);\n\t}),\n\tjson: define(\n\t\t(run, value, indent) => {\n\t\t\tif (\n\t\t\t\tindent !== undefined &&\n\t\t\t\tindent !== null &&\n\t\t\t\ttypeof indent !== \"number\" &&\n\t\t\t\ttypeof indent !== \"string\"\n\t\t\t) {\n\t\t\t\treturn issue(\"type-error\", '\"json\" indent must be a number or string');\n\t\t\t}\n\t\t\t// `JSON.stringify` indents by at most 10 characters.\n\t\t\tconst width =\n\t\t\t\ttypeof indent === \"number\"\n\t\t\t\t\t? Math.max(0, Math.min(10, Math.floor(indent)))\n\t\t\t\t\t: typeof indent === \"string\"\n\t\t\t\t\t\t? Math.min(10, indent.length)\n\t\t\t\t\t\t: 0;\n\t\t\tconst data = toPlainData(\n\t\t\t\tvalue,\n\t\t\t\t() =>\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t\t'\"json\" cannot serialise a value that contains itself',\n\t\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\twhat: \"json\",\n\t\t\t\t\tcharge: (count) => consume(run, count),\n\t\t\t\t\tmaxLength: run.state.maxSize,\n\t\t\t\t\tindent: width,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn checkLength(\n\t\t\t\trun,\n\t\t\t\tescapeJson(JSON.stringify(data ?? null, null, indent ?? undefined)),\n\t\t\t);\n\t\t},\n\t\t[\"indent\"],\n\t),\n\tlength: define((run, value) => {\n\t\tif (value === null || value === undefined) return 0;\n\t\tif (typeof value === \"string\") return codePointLength(value);\n\t\tif (value instanceof Markup) return codePointLength(value.value);\n\t\tif (Array.isArray(value)) return value.length;\n\t\tif (value instanceof Set) return value.size;\n\t\t// Counts the entries templates can read, which is what loops see.\n\t\tif (isPlainObject(value)) {\n\t\t\tconst count = hashKeys(value).length;\n\t\t\tconsume(run, count);\n\t\t\treturn count;\n\t\t}\n\t\tif (value instanceof Map) {\n\t\t\tconsume(run, value.size);\n\t\t\treturn mapContents(value).keys.length;\n\t\t}\n\t\tif (typeof value === \"object\" && Symbol.iterator in value) {\n\t\t\treturn entriesOf(run, value, \"length\").values.length;\n\t\t}\n\t\treturn issue(\"type-error\", `\"length\" cannot measure a ${typeName(value)}`);\n\t}),\n\tfirst: define((run, value) => {\n\t\tif (Array.isArray(value)) return value[0] ?? null;\n\t\tconst target = unwrap(value);\n\t\tif (typeof target === \"string\") {\n\t\t\tconst code = target.codePointAt(0);\n\t\t\treturn code === undefined ? null : String.fromCodePoint(code);\n\t\t}\n\t\t// A hash stops at its first key that templates can read.\n\t\tif (isPlainObject(target)) {\n\t\t\tfor (const key in target) {\n\t\t\t\tif (Object.hasOwn(target, key) && !BLOCKED_NAMES.has(key)) {\n\t\t\t\t\treturn target[key] ?? null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tif (target instanceof Map) {\n\t\t\tfor (const [key, item] of target) {\n\t\t\t\tif (typeof key !== \"string\" || !BLOCKED_NAMES.has(key)) {\n\t\t\t\t\treturn item ?? null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn listOf(run, target, \"first\")[0] ?? null;\n\t}),\n\tlast: define((run, value) => {\n\t\tconst target = unwrap(value);\n\t\tif (typeof target === \"string\") return codePoints(target).pop() ?? null;\n\t\tconst items = listOf(run, target, \"last\");\n\t\treturn items[items.length - 1] ?? null;\n\t}),\n\tslice: define(\n\t\t(run, value, start, end) => {\n\t\t\tconst from = integerArgument(start, '\"slice\" start');\n\t\t\tconst to =\n\t\t\t\tend === undefined || end === null\n\t\t\t\t\t? undefined\n\t\t\t\t\t: integerArgument(end, '\"slice\" end');\n\t\t\tconst target = unwrap(value);\n\t\t\tif (typeof target === \"string\")\n\t\t\t\treturn codePoints(target).slice(from, to).join(\"\");\n\t\t\tif (isHashLike(target)) {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"type-error\",\n\t\t\t\t\t'\"slice\" needs an array or string, but got a hash',\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst result = listOf(run, target, \"slice\").slice(from, to);\n\t\t\tconsume(run, result.length);\n\t\t\treturn result;\n\t\t},\n\t\t[\"start\", \"end\"],\n\t),\n\tjoin: define(\n\t\t(run, value, glue = \"\", lastGlue) => {\n\t\t\t// An array with a string glue joins without copying, in the same order of checks.\n\t\t\tif (\n\t\t\t\tArray.isArray(value) &&\n\t\t\t\ttypeof glue === \"string\" &&\n\t\t\t\t(lastGlue === undefined || lastGlue === null)\n\t\t\t) {\n\t\t\t\tconsume(run, value.length);\n\t\t\t\tlet text = \"\";\n\t\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\t\tconst item: unknown = value[i];\n\t\t\t\t\tconst piece = typeof item === \"string\" ? item : toStr(item);\n\t\t\t\t\trefuseLength(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\ttext.length + piece.length + (i > 0 ? glue.length : 0),\n\t\t\t\t\t\t\"join\",\n\t\t\t\t\t);\n\t\t\t\t\tif (i > 0) text += glue;\n\t\t\t\t\ttext += piece;\n\t\t\t\t}\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tconst items = entriesOf(run, value, \"join\").values.map((item) =>\n\t\t\t\ttoStr(item),\n\t\t\t);\n\t\t\tconst separator = toStringArgument(glue, '\"join\"');\n\t\t\tconst last =\n\t\t\t\tlastGlue === undefined || lastGlue === null || items.length < 2\n\t\t\t\t\t? separator\n\t\t\t\t\t: toStringArgument(lastGlue, '\"join\"');\n\t\t\tlet length =\n\t\t\t\titems.length < 2\n\t\t\t\t\t? 0\n\t\t\t\t\t: (items.length - 2) * separator.length + last.length;\n\t\t\tfor (const item of items) length += item.length;\n\t\t\trefuseLength(run, length, \"join\");\n\t\t\tif (last === separator) return items.join(separator);\n\t\t\tconst final = items.pop() as string;\n\t\t\treturn `${items.join(separator)}${last}${final}`;\n\t\t},\n\t\t[\"glue\", \"lastGlue\"],\n\t),\n\tkeys: define((run, value) => entriesOf(run, value, \"keys\").keys),\n\tmerge: define((run, value, ...others) => {\n\t\tconst all = [value, ...others].filter(\n\t\t\t(item) => item !== null && item !== undefined,\n\t\t);\n\t\tif (all.length === 0) return [];\n\t\tif (all.every((item) => Array.isArray(item) || item instanceof Set)) {\n\t\t\t// Charge for every item before building, so repeated merging cannot exhaust memory.\n\t\t\tconsume(\n\t\t\t\trun,\n\t\t\t\tall.reduce<number>(\n\t\t\t\t\t(total, item) =>\n\t\t\t\t\t\ttotal +\n\t\t\t\t\t\t(Array.isArray(item) ? item.length : (item as Set<unknown>).size),\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst result: unknown[] = [];\n\t\t\tfor (const item of all) {\n\t\t\t\tfor (const entry of item as Iterable<unknown>) result.push(entry);\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\tif (all.every((item) => isPlainObject(item) || item instanceof Map)) {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tfor (const item of all) {\n\t\t\t\tconst { values, keys } = entriesOf(run, item, \"merge\");\n\t\t\t\tkeys.forEach((key, index) => {\n\t\t\t\t\tsetOwn(result, String(key), values[index]);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn issue(\n\t\t\t\"type-error\",\n\t\t\t'\"merge\" needs all arrays or all hashes, not a mix',\n\t\t);\n\t}),\n\treverse: define((run, value) => {\n\t\tconst target = unwrap(value);\n\t\tif (typeof target === \"string\")\n\t\t\treturn codePoints(target).reverse().join(\"\");\n\t\tif (isHashLike(target)) {\n\t\t\tconst { values, keys } = entriesOf(run, target, \"reverse\");\n\t\t\treturn orderedHash([...keys].reverse(), [...values].reverse());\n\t\t}\n\t\tconst items = listOf(run, target, \"reverse\");\n\t\tconsume(run, items.length);\n\t\treturn [...items].reverse();\n\t}),\n\tsort: define(\n\t\t(run, value, by) => {\n\t\t\tif (!Array.isArray(value) && isHashLike(value)) {\n\t\t\t\tconst { values, keys } = entriesOf(run, value, \"sort\");\n\t\t\t\tconst sorted = sortBy(\n\t\t\t\t\tkeys.map((key, index) => ({ key, item: values[index] })),\n\t\t\t\t\t(entry) => entry.item,\n\t\t\t\t\tby,\n\t\t\t\t);\n\t\t\t\treturn orderedHash(\n\t\t\t\t\tsorted.map((entry) => entry.key),\n\t\t\t\t\tsorted.map((entry) => entry.item),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst items = [...listOf(run, value, \"sort\")];\n\t\t\tconsume(run, items.length);\n\t\t\tif ((by === undefined || by === null) && allStrings(items)) {\n\t\t\t\treturn sortStrings(items);\n\t\t\t}\n\t\t\treturn sortBy(items, (item) => item, by);\n\t\t},\n\t\t[\"by\"],\n\t),\n\tmap: define(\n\t\t(run, value, callback) =>\n\t\t\tmapEntries(\n\t\t\t\trun,\n\t\t\t\tvalue,\n\t\t\t\tcallback,\n\t\t\t\t\"map\",\n\t\t\t\t(results, _values, keys, isHash) =>\n\t\t\t\t\tbuildCollection(isHash, keys, results),\n\t\t\t),\n\t\t[\"callback\"],\n\t),\n\tfilter: define(\n\t\t(run, value, callback) =>\n\t\t\tmapEntries(\n\t\t\t\trun,\n\t\t\t\tvalue,\n\t\t\t\tcallback,\n\t\t\t\t\"filter\",\n\t\t\t\t(results, values, keys, isHash) => {\n\t\t\t\t\tconst keptKeys: unknown[] = [];\n\t\t\t\t\tconst kept: unknown[] = [];\n\t\t\t\t\tresults.forEach((result, index) => {\n\t\t\t\t\t\tif (truthy(result)) {\n\t\t\t\t\t\t\tkept.push(values[index]);\n\t\t\t\t\t\t\tkeptKeys.push(keys[index]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn buildCollection(isHash, keptKeys, kept);\n\t\t\t\t},\n\t\t\t),\n\t\t[\"callback\"],\n\t),\n\treduce: define(\n\t\t(run, value, callback, initial = null) => {\n\t\t\tconst fn = functionArgument(callback, \"reduce\");\n\t\t\tconst { values, keys } = entriesOf(run, value, \"reduce\");\n\t\t\tconst from = (index: number, carry: unknown): unknown => {\n\t\t\t\tlet current = carry;\n\t\t\t\tfor (let i = index; i < values.length; i++) {\n\t\t\t\t\tconst result = fn(current, values[i], keys[i]);\n\t\t\t\t\tif (isPromise(result)) {\n\t\t\t\t\t\treturn result.then((resolved) =>\n\t\t\t\t\t\t\thold(from(i + 1, unhold(resolved))),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcurrent = result;\n\t\t\t\t}\n\t\t\t\treturn current;\n\t\t\t};\n\t\t\treturn from(0, initial);\n\t\t},\n\t\t[\"callback\", \"initial\"],\n\t),\n\tfind: define(\n\t\t(run, value, callback) => {\n\t\t\tconst fn = functionArgument(callback, \"find\");\n\t\t\tconst { values, keys } = entriesOf(run, value, \"find\");\n\t\t\tconst from = (index: number): unknown => {\n\t\t\t\tfor (let i = index; i < values.length; i++) {\n\t\t\t\t\tconst result = fn(values[i], keys[i]);\n\t\t\t\t\tif (isPromise(result)) {\n\t\t\t\t\t\treturn result.then((resolved) =>\n\t\t\t\t\t\t\thold(\n\t\t\t\t\t\t\t\ttruthy(unhold(resolved)) ? (values[i] ?? null) : from(i + 1),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (truthy(result)) return values[i] ?? null;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t};\n\t\t\treturn from(0);\n\t\t},\n\t\t[\"callback\"],\n\t),\n\tcolumn: define(\n\t\t(run, value, name) => {\n\t\t\tconst key = unwrap(name);\n\t\t\tif (typeof key !== \"string\" && typeof key !== \"number\") {\n\t\t\t\treturn issue(\"type-error\", '\"column\" needs a property name');\n\t\t\t}\n\t\t\tconst items = listOf(run, value, \"column\");\n\t\t\tconsume(run, items.length);\n\t\t\treturn items.map((item) => readProperty(item, key));\n\t\t},\n\t\t[\"name\"],\n\t),\n\tbatch: define(\n\t\t(run, value, size, fill) => {\n\t\t\tconst count = integerArgument(size, '\"batch\" size');\n\t\t\tif (count < 1)\n\t\t\t\treturn issue(\"invalid-argument\", '\"batch\" size must be at least 1');\n\t\t\tconst items = listOf(run, value, \"batch\");\n\t\t\tconst groupCount = Math.ceil(items.length / count);\n\t\t\t// Padding can create far more items than went in, so charge for the output size.\n\t\t\tconsume(run, fill === undefined ? items.length : groupCount * count);\n\t\t\tconst groups: unknown[][] = [];\n\t\t\tfor (let i = 0; i < items.length; i += count) {\n\t\t\t\tgroups.push(items.slice(i, i + count));\n\t\t\t}\n\t\t\tconst last = groups[groups.length - 1];\n\t\t\tif (last && fill !== undefined) {\n\t\t\t\twhile (last.length < count) last.push(fill);\n\t\t\t}\n\t\t\treturn groups;\n\t\t},\n\t\t[\"size\", \"fill\"],\n\t),\n\tabs: define((_run, value) => Math.abs(toNumber(value, \"abs\"))),\n\tround: define(\n\t\t(_run, value, precision = 0, method = \"common\") =>\n\t\t\troundNumber(\n\t\t\t\ttoNumber(value, \"round\"),\n\t\t\t\tintegerArgument(precision, '\"round\" precision'),\n\t\t\t\ttoStringArgument(method, '\"round\" method'),\n\t\t\t),\n\t\t[\"precision\", \"method\"],\n\t),\n\tformatNumber: define(\n\t\t(run, value, options) => {\n\t\t\tconst formatter = cachedFormatter(\n\t\t\t\t\"number\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tNUMBER_OPTIONS,\n\t\t\t\t() => ({}),\n\t\t\t\t(locale, settings) =>\n\t\t\t\t\tnumberFormat(new Intl.NumberFormat(locale, settings)),\n\t\t\t);\n\t\t\tif (value === null || value === undefined) return \"\";\n\t\t\treturn formatter(toNumber(value, \"formatNumber\"));\n\t\t},\n\t\t[],\n\t\ttrue,\n\t),\n\tplural: define(\n\t\t(run, value, one, other, zero, two, few, many, options) => {\n\t\t\tconst rules = cachedFormatter(\n\t\t\t\t\"plural\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tPLURAL_OPTIONS,\n\t\t\t\t() => ({}),\n\t\t\t\t(locale, settings) => new Intl.PluralRules(locale, settings),\n\t\t\t);\n\t\t\tif (value === null || value === undefined) return \"\";\n\t\t\tconst count = toNumber(value, \"plural\");\n\t\t\tif (other === null || other === undefined) {\n\t\t\t\treturn issue(\"invalid-argument\", '\"plural\" needs an \"other\" form');\n\t\t\t}\n\t\t\tconst forms = { zero, one, two, few, many, other };\n\t\t\tconst form = toStringArgument(\n\t\t\t\tforms[rules.select(count)] ?? other,\n\t\t\t\t'\"plural\"',\n\t\t\t);\n\t\t\tif (!form.includes(\"#\")) return form;\n\t\t\tconst formatter = cachedFormatter(\n\t\t\t\t\"number\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tPLURAL_OPTIONS,\n\t\t\t\t() => ({}),\n\t\t\t\t(locale, settings) =>\n\t\t\t\t\tnumberFormat(new Intl.NumberFormat(locale, settings)),\n\t\t\t);\n\t\t\tconst number = formatter(count);\n\t\t\tconst parts = form.split(\"#\");\n\t\t\trefuseLength(\n\t\t\t\trun,\n\t\t\t\tform.length + (parts.length - 1) * (number.length - 1),\n\t\t\t\t\"plural\",\n\t\t\t);\n\t\t\treturn parts.join(number);\n\t\t},\n\t\t[\"one\", \"other\", \"zero\", \"two\", \"few\", \"many\"],\n\t\ttrue,\n\t),\n\tformatDate: define(\n\t\t(run, value, options) => {\n\t\t\tconst formatter = cachedFormatter(\n\t\t\t\t\"date\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tDATE_OPTIONS,\n\t\t\t\t(settings) => ({\n\t\t\t\t\ttimeZone: run.state.timeZone,\n\t\t\t\t\t...(Object.keys(settings).some((key) => DATE_STYLE_OPTIONS.has(key))\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { dateStyle: \"medium\" }),\n\t\t\t\t}),\n\t\t\t\t(locale, resolved) =>\n\t\t\t\t\tdateFormat(new Intl.DateTimeFormat(locale, resolved)),\n\t\t\t);\n\t\t\tif (value === null || value === undefined) return \"\";\n\t\t\treturn formatter(toTime(value, '\"formatDate\"'));\n\t\t},\n\t\t[],\n\t\ttrue,\n\t),\n};\n","import { analyzeTemplate, childStatements, type Reads } from \"./analyzer.js\";\nimport { createDiagnostic, type Diagnostic } from \"./errors.js\";\nimport { resolveTemplateName } from \"./names.js\";\nimport type { Expression, HashEntry, Statement } from \"./parser/ast.js\";\nimport type {\n\tCompiledTemplate,\n\tEnvironmentCore,\n\tScope,\n} from \"./runtime/types.js\";\nimport { describeType, describeValue, matchesType } from \"./runtime/values.js\";\nimport type { Span } from \"./source.js\";\nimport { suggest } from \"./suggest.js\";\n\ntype Property = Extract<HashEntry, { type: \"Property\" }>;\ntype PropsNode = Extract<Statement, { type: \"Props\" }>;\n\n/** A template's `props` tag, or null when it has none. */\nconst propsOf = (template: CompiledTemplate): PropsNode | null => {\n\tfor (const node of template.ast.body) {\n\t\tif (node.type === \"Props\") return node;\n\t}\n\treturn null;\n};\n\n/** Variables a template sets at its top level. A child template's run before its layout. */\nconst setsOf = (template: CompiledTemplate): string[] =>\n\ttemplate.ast.body.flatMap((node) =>\n\t\tnode.type === \"Set\" || node.type === \"SetBlock\" ? [node.name] : [],\n\t);\n\n/** The resolved name of a template written as a plain string, or null when it is built at render time. */\nconst literalName = (expression: Expression, from: string): string | null => {\n\tif (expression.type !== \"Literal\" || typeof expression.value !== \"string\") {\n\t\treturn null;\n\t}\n\ttry {\n\t\treturn resolveTemplateName(expression.value, from);\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/** The keys a `with` passes, by name. Null when they can't be known, such as `with data` or a spread. */\nconst passedKeys = (\n\texpression: Expression | null,\n): Map<string, Property> | null => {\n\tconst keys = new Map<string, Property>();\n\tif (expression === null) return keys;\n\tif (expression.type !== \"Hash\") return null;\n\tfor (const entry of expression.entries) {\n\t\tif (\n\t\t\tentry.type !== \"Property\" ||\n\t\t\tentry.key.type !== \"Literal\" ||\n\t\t\ttypeof entry.key.value !== \"string\"\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tkeys.set(entry.key.value, entry);\n\t}\n\treturn keys;\n};\n\nconst withHint = (message: string, hint: string | undefined) =>\n\thint ? `${message}. ${hint}` : message;\n\n/**\n * Checks a template against the templates it names, for `check`. Never renders.\n *\n * - Reports templates that don't exist.\n * - In strict mode, compares `include` and `component` calls, and a page's layouts, with the `props` they declare.\n * - In strict mode, warns about variables a template with `props` reads without declaring.\n */\nexport const checkReferences = async (\n\tenv: EnvironmentCore & { readonly globals: Scope },\n\ttemplate: CompiledTemplate,\n): Promise<Diagnostic[]> => {\n\tconst diagnostics: Diagnostic[] = [];\n\tconst report = (\n\t\tcode: string,\n\t\tmessage: string,\n\t\tspan: Span,\n\t\tseverity: Diagnostic[\"severity\"] = \"error\",\n\t) => {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic(template.source, code, message, span, severity),\n\t\t);\n\t};\n\tconst ownProps = propsOf(template);\n\n\t/** Loads a named template, reporting it when it doesn't exist. */\n\tconst use = async (name: string, span: Span, optional = false) => {\n\t\tconst used = await env.load(name);\n\t\tif (!used && !optional) {\n\t\t\treport(\"missing-template\", `Template \"${name}\" was not found`, span);\n\t\t}\n\t\treturn used;\n\t};\n\n\tconst call = async (\n\t\tnode: Extract<Statement, { type: \"Include\" | \"Component\" | \"Island\" }>,\n\t) => {\n\t\tconst name = literalName(node.template, template.name);\n\t\tif (!name) return;\n\t\tconst used = await use(\n\t\t\tname,\n\t\t\tnode.template.span,\n\t\t\tnode.type === \"Include\" && node.ignoreMissing,\n\t\t);\n\t\tif (!used || used.hasErrors || !env.strict) return;\n\t\tconst tag = propsOf(used);\n\t\tconst passed = passedKeys(node.with);\n\t\tif (!tag || !passed) return;\n\n\t\tconst props = tag.props;\n\t\tconst declared = props.map((prop) => prop.name);\n\t\tfor (const [key, entry] of passed) {\n\t\t\t// A rest prop accepts any key.\n\t\t\tif (tag.rest !== null || key === \"slots\" || declared.includes(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treport(\n\t\t\t\t\"unknown-prop\",\n\t\t\t\twithHint(\n\t\t\t\t\t`\"${key}\" was passed to ${name}, which does not declare it in \"props\"`,\n\t\t\t\t\tsuggest(key, declared),\n\t\t\t\t),\n\t\t\t\tentry.key.span,\n\t\t\t);\n\t\t}\n\t\tfor (const prop of props) {\n\t\t\tconst value = passed.get(prop.name)?.value;\n\t\t\tif (!value) {\n\t\t\t\tif (!prop.default) {\n\t\t\t\t\treport(\n\t\t\t\t\t\t\"missing-prop\",\n\t\t\t\t\t\t`Required prop \"${prop.name}\" was not passed to ${name}`,\n\t\t\t\t\t\tnode.template.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Null uses the default, which the template's own check covers.\n\t\t\tif (\n\t\t\t\t!prop.type ||\n\t\t\t\tvalue.type !== \"Literal\" ||\n\t\t\t\t(value.value === null && prop.default)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!matchesType(value.value, prop.type, env.types)) {\n\t\t\t\treport(\n\t\t\t\t\t\"prop-type\",\n\t\t\t\t\t`Prop \"${prop.name}\" of ${name} must be ${describeType(prop.type)}, but got ${describeValue(value.value, prop.type)}`,\n\t\t\t\t\tvalue.span,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\t// A page with `props` accepts only those, so its layouts can only get props it declares or sets. With a rest prop\n\t// it accepts anything, so they can get any prop.\n\tconst layouts = async (node: Extract<Statement, { type: \"Extends\" }>) => {\n\t\tlet name = literalName(node.template, template.name);\n\t\tif (!name) return;\n\t\tlet layout = await use(name, node.template.span);\n\t\tif (!ownProps || ownProps.rest !== null || !env.strict) return;\n\t\tconst provided = new Set([\n\t\t\t...ownProps.props.map((prop) => prop.name),\n\t\t\t...setsOf(template),\n\t\t]);\n\t\tconst seen = new Set([template.name]);\n\t\twhile (layout && !layout.hasErrors && !seen.has(layout.name)) {\n\t\t\tseen.add(layout.name);\n\t\t\tfor (const prop of propsOf(layout)?.props ?? []) {\n\t\t\t\tif (!prop.default && !provided.has(prop.name)) {\n\t\t\t\t\treport(\n\t\t\t\t\t\t\"missing-prop\",\n\t\t\t\t\t\t`${name} needs prop \"${prop.name}\", which ${template.name} does not declare in \"props\" or set`,\n\t\t\t\t\t\tnode.template.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprovided.add(prop.name);\n\t\t\t}\n\t\t\tfor (const set of setsOf(layout)) provided.add(set);\n\t\t\tconst parent = layout.ast.body.find((child) => child.type === \"Extends\");\n\t\t\tname = parent ? literalName(parent.template, layout.name) : null;\n\t\t\tlayout = name ? await env.load(name) : null;\n\t\t}\n\t};\n\n\tconst visit = async (list: Statement[]): Promise<void> => {\n\t\tfor (const node of list) {\n\t\t\tif (\n\t\t\t\tnode.type === \"Include\" ||\n\t\t\t\tnode.type === \"Component\" ||\n\t\t\t\tnode.type === \"Island\"\n\t\t\t) {\n\t\t\t\tawait call(node);\n\t\t\t} else if (node.type === \"Extends\") await layouts(node);\n\t\t\tfor (const children of childStatements(node)) await visit(children);\n\t\t}\n\t};\n\n\tfor (const imported of template.imports)\n\t\tawait use(imported.name, imported.span);\n\tawait visit(template.ast.body);\n\n\tif (ownProps && env.strict) {\n\t\tconst reads: Reads = { context: new Map(), macros: new Map() };\n\t\tanalyzeTemplate(template, env.globals, reads);\n\t\tconst declared = ownProps.props.map((prop) => prop.name);\n\t\tfor (const [name, span] of reads.context) {\n\t\t\treport(\n\t\t\t\t\"undeclared-variable\",\n\t\t\t\twithHint(\n\t\t\t\t\t`\"${name}\" is not a prop, a global or a variable set in this template`,\n\t\t\t\t\tsuggest(name, declared),\n\t\t\t\t),\n\t\t\t\tspan,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t}\n\t\t// A macro only sees its parameters and globals.\n\t\tfor (const [name, span] of reads.macros) {\n\t\t\treport(\n\t\t\t\t\"undeclared-variable\",\n\t\t\t\t`\"${name}\" is not a parameter of its macro or a global`,\n\t\t\t\tspan,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t}\n\t}\n\treturn diagnostics;\n};\n","import type { IslandEntry, JsonValue } from \"./islands.js\";\nimport type { Addition } from \"./outlets.js\";\nimport { isPlainObject } from \"./values.js\";\n\n/*\n * The value the `cache` tag gives a store to save. It is Kiln's own string, so what a saved copy holds can change\n * without stores changing: the HTML, what the section added to outlets, the islands it deferred, and whether it holds\n * the `<kiln-island>` script. A value from another version of the format reads as missing, so the section renders\n * again and the copy is replaced.\n */\n\nconst VERSION = 2;\n\nexport type Saved = {\n\thtml: string;\n\tadditions: Addition[];\n\tislands: IslandEntry[];\n\tislandScript: boolean;\n};\n\n/** Makes the value a store saves. */\nexport const packSaved = ({\n\thtml,\n\tadditions,\n\tislands,\n\tislandScript,\n}: Saved): string =>\n\tJSON.stringify({\n\t\tv: VERSION,\n\t\thtml,\n\t\tadd: additions.map((addition) => [\n\t\t\taddition.outlet,\n\t\t\taddition.html,\n\t\t\taddition.once,\n\t\t]),\n\t\tisl: islands.map((island) => [island.template, island.props]),\n\t\tscr: islandScript,\n\t});\n\n/** Reads a value a store returned, or returns null when it isn't one `packSaved` made. */\nexport const unpackSaved = (value: string): Saved | null => {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(value);\n\t} catch {\n\t\treturn null;\n\t}\n\tif (typeof parsed !== \"object\" || parsed === null) return null;\n\tconst { v, html, add, isl, scr } = parsed as Record<string, unknown>;\n\tif (\n\t\tv !== VERSION ||\n\t\ttypeof html !== \"string\" ||\n\t\t!Array.isArray(add) ||\n\t\t!Array.isArray(isl) ||\n\t\ttypeof scr !== \"boolean\"\n\t) {\n\t\treturn null;\n\t}\n\tconst additions: Addition[] = [];\n\tfor (const item of add) {\n\t\tif (!Array.isArray(item)) return null;\n\t\tconst [outlet, text, once] = item as unknown[];\n\t\tif (\n\t\t\ttypeof outlet !== \"string\" ||\n\t\t\ttypeof text !== \"string\" ||\n\t\t\t(once !== null && typeof once !== \"string\")\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tadditions.push({ outlet, html: text, once });\n\t}\n\tconst islands: IslandEntry[] = [];\n\tfor (const item of isl) {\n\t\tif (!Array.isArray(item)) return null;\n\t\tconst [template, props] = item as unknown[];\n\t\tif (typeof template !== \"string\" || !isPlainObject(props)) return null;\n\t\t// Parsed JSON holds only JSON values.\n\t\tislands.push({ template, props: props as Record<string, JsonValue> });\n\t}\n\treturn { html, additions, islands, islandScript: scr };\n};\n","import type { Span } from \"../source.js\";\nimport { BLOCKED_NAMES } from \"./exposure.js\";\nimport { Markup } from \"./markup.js\";\nimport { closeOutlets, takeOutput } from \"./outlets.js\";\nimport {\n\taddSlotFlags,\n\tconsumeAt,\n\tfail,\n\tmarkCaller,\n\trenderTemplate,\n} from \"./render.js\";\nimport { childScope } from \"./scope.js\";\nimport {\n\ttype CompiledTemplate,\n\temptyOut,\n\tRenderState,\n\ttype Run,\n} from \"./types.js\";\nimport { isPlainObject, typeName } from \"./values.js\";\n\n/*\n * Server islands.\n *\n * An island renders in place unless the render has an `islands` option. Either way the island writes a `<kiln-island>`\n * element holding its fallback:\n *\n * - `deferIslands(…)` records its template and props in the manifest under an id made from both. The host serves each\n * id by rendering the manifest entry with `render`, and the element fetches that HTML.\n * - `streamIslands()` renders the island on its own while the page carries on, and `renderStream` sends its HTML after\n * the page, in a `<template>` followed by a `<kiln-island fill>` that moves it into place.\n */\n\n/** A value that survives JSON unchanged, which is what island props must be. */\nexport type JsonValue =\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| JsonValue[]\n\t| { [key: string]: JsonValue };\n\n/** One deferred island: the template to render and the props to render it with. */\nexport type IslandEntry = {\n\ttemplate: string;\n\tprops: Record<string, JsonValue>;\n};\n\n/** Every island deferred in a build, by id. Hosts save it as JSON and look ids up in it. */\nexport type IslandManifest = Record<string, IslandEntry>;\n\n/** The `islands` render option for static builds. Make it with `deferIslands`, and pass it to every render in a build. */\nexport type DeferredIslands = {\n\treadonly mode: \"defer\";\n\t/** The text before each island's id in its `src`, such as `\"/_islands/\"`. */\n\treadonly url: string;\n\t/** Whether Kiln writes the `<kiln-island>` script before the first island of each render. */\n\treadonly script: boolean;\n\t/** Every island deferred so far, by id. */\n\treadonly manifest: IslandManifest;\n};\n\n/**\n * Defers `island` tags in the renders it is passed to, recording each island in `manifest`.\n *\n * ```ts\n * const islands = deferIslands({ url: \"/_islands/\" });\n * const html = await kiln.render(\"pages/product\", { product }, { islands });\n * await writeFile(\"build/islands.json\", JSON.stringify(islands.manifest));\n * ```\n */\nexport const deferIslands = ({\n\turl,\n\tscript = true,\n}: {\n\turl: string;\n\tscript?: boolean;\n}): DeferredIslands => {\n\tif (typeof url !== \"string\") {\n\t\tthrow new TypeError(\"deferIslands needs a url\");\n\t}\n\treturn { mode: \"defer\", url, script, manifest: {} };\n};\n\n/** The `islands` render option for `renderStream`. Make it with `streamIslands`. */\nexport type StreamedIslands = {\n\treadonly mode: \"stream\";\n\t/** Whether Kiln writes the `<kiln-island>` script before the first island of each render. */\n\treadonly script: boolean;\n};\n\n/**\n * Streams `island` tags in `renderStream`: the page is sent with each island's fallback, and each island's HTML follows\n * when it is ready. `render` and `renderBlock` can't stream, so they render islands in place.\n *\n * ```ts\n * const stream = await kiln.renderStream(\"pages/product\", { product }, { islands: streamIslands() });\n * ```\n */\nexport const streamIslands = ({\n\tscript = true,\n}: {\n\tscript?: boolean;\n} = {}): StreamedIslands => ({ mode: \"stream\", script });\n\n/** How a render treats `island` tags, when it doesn't render them in place. */\nexport type IslandMode = DeferredIslands | StreamedIslands;\n\n/**\n * The source of the script that defines `<kiln-island>`. Serve it as a file when a Content Security Policy blocks\n * inline scripts, with `script: false`.\n *\n * - A deferred island's element fetches its `src`, and replaces itself with the response when it succeeds and is HTML.\n * - A streamed island's HTML arrives in a `<template>`, followed by `<kiln-island fill=\"n\">`, which moves it in place of\n * `<kiln-island stream=\"n\">` once the template is parsed.\n *\n * Otherwise the fallback stays. Kept short and plain, since it is written into pages.\n */\nexport const islandScript =\n\t'customElements.get(\"kiln-island\")||customElements.define(\"kiln-island\",class extends HTMLElement{connectedCallback(){if(this.k)return;this.k=1;this.style.display=\"contents\";const p=h=>document.createRange().createContextualFragment(h),f=this.getAttribute(\"fill\"),s=this.getAttribute(\"src\");if(f){const t=this.previousElementSibling,e=document.querySelector(`kiln-island[stream=\"${f}\"]`);if(e&&t&&t.localName==\"template\")e.replaceWith(p(t.innerHTML)),t.remove();this.remove()}else if(s)fetch(s).then(r=>r.ok&&/^text\\\\/html/.test(r.headers.get(\"content-type\"))?r.text():null).then(h=>{if(h!=null)this.replaceWith(p(h))},()=>{})}});';\n\n/**\n * Copies an island's props as JSON values, or fails naming the first value that isn't one. Hashes may be maps, and\n * become plain objects.\n */\nexport const islandProps = (\n\trun: Run,\n\tspan: Span,\n\tvalue: unknown,\n): Record<string, JsonValue> => {\n\tconst seen = new Set<object>();\n\tconst invalid = (path: string, problem: string) =>\n\t\tfail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"type-error\",\n\t\t\t`\"island\" props must be JSON values: null, booleans, numbers, strings, lists and hashes, but ${path === \"\" ? \"they are\" : `\"${path}\" is`} ${problem}`,\n\t\t);\n\t// Each list and hash is charged before it is copied, so props that share one object in many places can't make\n\t// unlimited work.\n\tconst charge = (count: number) => consumeAt(run, span, count);\n\tconst copyHash = (\n\t\thash: Record<string, unknown> | Map<unknown, unknown>,\n\t\tpath: string,\n\t): Record<string, JsonValue> => {\n\t\tconst result: Record<string, JsonValue> = {};\n\t\tconst entries = hash instanceof Map ? [...hash] : Object.entries(hash);\n\t\tcharge(entries.length);\n\t\tfor (const [key, item] of entries) {\n\t\t\tif (typeof key !== \"string\") {\n\t\t\t\tthrow invalid(path, \"a hash with a key that isn't a string\");\n\t\t\t}\n\t\t\tif (BLOCKED_NAMES.has(key)) continue;\n\t\t\tresult[key] = copy(item, path === \"\" ? key : `${path}.${key}`);\n\t\t}\n\t\treturn result;\n\t};\n\tconst copy = (item: unknown, path: string): JsonValue => {\n\t\tif (item === null || item === undefined) return null;\n\t\tif (typeof item === \"string\" || typeof item === \"boolean\") return item;\n\t\tif (typeof item === \"number\") {\n\t\t\tif (Number.isFinite(item)) return item;\n\t\t\tthrow invalid(path, String(item));\n\t\t}\n\t\tif (item instanceof Markup) {\n\t\t\tthrow invalid(\n\t\t\t\tpath,\n\t\t\t\t\"markup. Pass the data, and build the markup in the island\",\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!Array.isArray(item) &&\n\t\t\t!(item instanceof Map) &&\n\t\t\t!isPlainObject(item)\n\t\t) {\n\t\t\tthrow invalid(path, `a ${typeName(item)}`);\n\t\t}\n\t\tif (seen.has(item)) throw invalid(path, \"a value that contains itself\");\n\t\tseen.add(item);\n\t\tif (Array.isArray(item)) charge(item.length);\n\t\tconst result = Array.isArray(item)\n\t\t\t? item.map((entry, index) => copy(entry, `${path}[${index}]`))\n\t\t\t: copyHash(item, path);\n\t\tseen.delete(item);\n\t\treturn result;\n\t};\n\tif (value === null || value === undefined) return {};\n\tif (!(value instanceof Map) && !isPlainObject(value)) {\n\t\tthrow invalid(\"\", `a ${typeName(value)}, not a hash`);\n\t}\n\treturn copyHash(value, \"\");\n};\n\n/** A 64-bit hash of `text` as 16 hex digits: two 32-bit multiply-xor lanes, mixed together at the end. */\nconst hashId = (text: string): string => {\n\tlet a = 0x811c9dc5;\n\tlet b = 0x9e3779b9;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\ta = Math.imul(a ^ code, 0x01000193);\n\t\tb = Math.imul(b ^ code, 0x5bd1e995);\n\t}\n\ta = Math.imul(a ^ (b >>> 15), 0x85ebca6b);\n\tb = Math.imul(b ^ (a >>> 13), 0xc2b2ae35);\n\ta ^= b >>> 16;\n\tb ^= a >>> 16;\n\treturn (\n\t\t(a >>> 0).toString(16).padStart(8, \"0\") +\n\t\t(b >>> 0).toString(16).padStart(8, \"0\")\n\t);\n};\n\n/**\n * Records an island in the manifest and returns its id. The id comes from the template and props, so it is the same\n * on every page and in every build, and a page cached from an earlier build never asks for a different island.\n */\nexport const recordIsland = (\n\trun: Run,\n\tspan: Span,\n\tislands: DeferredIslands,\n\ttemplate: string,\n\tprops: Record<string, JsonValue>,\n): string => {\n\tconst key = JSON.stringify([template, props]);\n\tconst id = hashId(key);\n\tconst { manifest } = islands;\n\tconst existing = Object.hasOwn(manifest, id) ? manifest[id] : undefined;\n\tif (existing === undefined) manifest[id] = { template, props };\n\telse if (JSON.stringify([existing.template, existing.props]) !== key) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"island-collision\",\n\t\t\t`Two different islands have the id \"${id}\". Change one island's props slightly`,\n\t\t);\n\t}\n\t// A cached section saves the islands it deferred.\n\trun.capture?.section?.deferred.push(id);\n\treturn id;\n};\n\n/**\n * Starts rendering a streamed island on its own, with a render state of its own and the page's state, locale and\n * limits, as the host would render a deferred one. Returns its HTML wrapped to fill `<kiln-island stream=\"n\">`.\n *\n * The island's steps count against the page's, and its depth starts at the island tag's, so streaming does no more\n * work than rendering the island in place.\n */\nexport const streamIsland = (\n\trun: Run,\n\tspan: Span,\n\ttemplate: CompiledTemplate,\n\tprops: Record<string, JsonValue>,\n\tn: number,\n): Promise<string> => {\n\tconst page = run.state;\n\tconst state = new RenderState(\n\t\tpage.env,\n\t\tpage.globals,\n\t\tpage.maxSteps,\n\t\tpage.maxSize,\n\t\tpage.maxDepth,\n\t\tpage.locale,\n\t\tpage.timeZone,\n\t\tpage.userState,\n\t\tpage.signal,\n\t);\n\t// Islands run alongside the page and each other, so they share its counter rather than copying it.\n\tObject.defineProperty(state, \"steps\", {\n\t\tget: () => page.steps,\n\t\tset: (steps: number) => {\n\t\t\tpage.steps = steps;\n\t\t},\n\t});\n\tconst scope = childScope(page.globals);\n\tconst passed = Object.keys(props);\n\tfor (const key of passed) scope[key] = props[key] ?? null;\n\taddSlotFlags(scope, template, null);\n\tconst out = emptyOut();\n\tstate.root = out;\n\treturn Promise.resolve()\n\t\t.then(() =>\n\t\t\trenderTemplate(\n\t\t\t\tstate,\n\t\t\t\ttemplate,\n\t\t\t\tscope,\n\t\t\t\tout,\n\t\t\t\trun.depth + 1,\n\t\t\t\tnull,\n\t\t\t\tpassed,\n\t\t\t\tnull,\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t),\n\t\t)\n\t\t.then(\n\t\t\t() => {\n\t\t\t\t// The signal may have been aborted while the island's last call was pending.\n\t\t\t\tif (state.signal?.aborted) {\n\t\t\t\t\tthrow fail(run, span, \"aborted\", \"Render was aborted\");\n\t\t\t\t}\n\t\t\t\tcloseOutlets(state);\n\t\t\t\treturn `<template>${takeOutput(state, out.s)}</template><kiln-island fill=\"${n}\"></kiln-island>`;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t},\n\t\t);\n};\n\nexport const ISLAND_CLOSING = \"</kiln-island>\";\n\nexport const ISLAND_SCRIPT = `<script>${islandScript}</script>`;\n","import type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport { Markup } from \"./markup.js\";\nimport {\n\tafter,\n\tfail,\n\timportsFor,\n\tisPromise,\n\tstep,\n\tunhold,\n\twithCaller,\n} from \"./render.js\";\nimport { childScope } from \"./scope.js\";\nimport {\n\ttype CompiledMacro,\n\temptyOut,\n\tendCapture,\n\tRun,\n\tstartCapture,\n} from \"./types.js\";\n\n/**\n * Calls a macro: binds arguments to parameters in a scope that holds only globals, renders the body and returns it as markup.\n */\nexport const callMacro = (\n\trun: Run,\n\tspan: Span,\n\tmacro: CompiledMacro,\n\tpositional: readonly unknown[],\n\tnamed: Readonly<Record<string, unknown>> | null,\n): Markup | Promise<Markup> => {\n\tstep(run, span);\n\tconst state = run.state;\n\tif (run.depth + 1 > state.maxDepth) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-depth\",\n\t\t\t`Render stopped after nesting ${state.maxDepth} templates, macros or layouts deep`,\n\t\t);\n\t}\n\n\tconst params = macro.params;\n\tif (positional.length > params.length) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"too-many-arguments\",\n\t\t\t`Macro \"${macro.name}\" takes ${params.length} ${params.length === 1 ? \"argument\" : \"arguments\"}, but got ${positional.length}`,\n\t\t);\n\t}\n\tif (named) {\n\t\tfor (const key of Object.keys(named)) {\n\t\t\tconst index = params.findIndex((param) => param.name === key);\n\t\t\tif (index !== -1 && index < positional.length) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"duplicate-argument\",\n\t\t\t\t\t`Macro \"${macro.name}\" got \"${key}\" both by position and by name`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (index === -1) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"unknown-argument\",\n\t\t\t\t\t`Macro \"${macro.name}\" has no parameter \"${key}\"`,\n\t\t\t\t\tsuggest(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tparams.map((param) => param.name),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// A capture of its own, since a macro can render alongside other expressions while promises are pending.\n\tconst capture = startCapture(run);\n\tconst macroRun = new Run(\n\t\tstate,\n\t\tmacro.template,\n\t\trun.depth + 1,\n\t\tnull,\n\t\tnull,\n\t\tcapture,\n\t\trun.blockDepth,\n\t);\n\tconst scope = childScope(state.globals);\n\n\tconst bind = (index: number): void | Promise<void> => {\n\t\tfor (let i = index; i < params.length; i++) {\n\t\t\tconst param = params[i] as CompiledMacro[\"params\"][number];\n\t\t\tlet value: unknown =\n\t\t\t\ti < positional.length\n\t\t\t\t\t? positional[i]\n\t\t\t\t\t: named && Object.hasOwn(named, param.name)\n\t\t\t\t\t\t? named[param.name]\n\t\t\t\t\t\t: undefined;\n\t\t\tif ((value === undefined || value === null) && param.default) {\n\t\t\t\tvalue = param.default.ev(macroRun, scope);\n\t\t\t\tif (param.default.async && isPromise(value)) {\n\t\t\t\t\treturn value.then((resolved) => {\n\t\t\t\t\t\tscope[param.name] = unhold(resolved) ?? null;\n\t\t\t\t\t\treturn bind(i + 1);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tscope[param.name] = value ?? null;\n\t\t}\n\t};\n\n\treturn after(importsFor(macroRun, macro.template), (imports) => {\n\t\tmacroRun.imports = imports;\n\t\treturn after(bind(0), () => {\n\t\t\tconst out = emptyOut();\n\t\t\tconst render = () =>\n\t\t\t\tafter(macro.body(macroRun, scope, out), () => {\n\t\t\t\t\tendCapture(run, capture);\n\t\t\t\t\treturn new Markup(out.s, macro.strategy || \"html\");\n\t\t\t\t});\n\t\t\t// A macro from another template records where it was called.\n\t\t\treturn macro.template === run.template\n\t\t\t\t? render()\n\t\t\t\t: withCaller(run, span, render);\n\t\t});\n\t});\n};\n","import {\n\tall,\n\thold,\n\tholdData,\n\tisPromise,\n\tsilence,\n\tunhold,\n} from \"../runtime/render.js\";\nimport type { Compiled, Run, Scope } from \"../runtime/types.js\";\n\n/*\n * Only a compiled expression marked `async` may return a promise to wait for. Any other promise is a value from your\n * data, which is never waited for, so it is held when it has to pass through a promise. See `holdData`.\n */\n\n/** A compiled literal. */\nexport const constant = (value: unknown): Compiled => ({\n\tev: () => value,\n\tasync: false,\n\tconstant: { value },\n});\n\n/**\n * Compiles `f(a)`. The sync version never checks for promises, so expressions without async calls stay fast.\n *\n * `async` says whether `f` itself may return a promise. If it does, a value from your data that `f` returns as it is\n * must go through `passData`.\n */\nexport const map1 = (\n\ta: Compiled,\n\tf: (value: unknown, run: Run, scope: Scope) => unknown,\n\tasync = false,\n): Compiled => {\n\tconst ev = a.ev;\n\tif (!a.async) {\n\t\treturn { ev: (run, scope) => f(ev(run, scope), run, scope), async };\n\t}\n\tconst keep = async ? hold : holdData;\n\treturn {\n\t\tev: (run, scope) => {\n\t\t\tconst value = ev(run, scope);\n\t\t\treturn isPromise(value)\n\t\t\t\t? value.then((resolved) => keep(f(unhold(resolved), run, scope)))\n\t\t\t\t: f(value, run, scope);\n\t\t},\n\t\tasync: true,\n\t};\n};\n\n/** Compiles `f(a, b)`. Both sides start before either is awaited. */\nexport const map2 = (\n\ta: Compiled,\n\tb: Compiled,\n\tf: (left: unknown, right: unknown, run: Run, scope: Scope) => unknown,\n\tasync = false,\n): Compiled => {\n\tconst left = a.ev;\n\tconst right = b.ev;\n\tif (!a.async && !b.async) {\n\t\treturn {\n\t\t\tev: (run, scope) => f(left(run, scope), right(run, scope), run, scope),\n\t\t\tasync,\n\t\t};\n\t}\n\tconst leftAsync = a.async;\n\tconst rightAsync = b.async;\n\tconst keep = async ? hold : holdData;\n\treturn {\n\t\tev: (run, scope) => {\n\t\t\tconst l = left(run, scope);\n\t\t\tlet r: unknown;\n\t\t\ttry {\n\t\t\t\tr = right(run, scope);\n\t\t\t} catch (error) {\n\t\t\t\tif (leftAsync) silence(l);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif ((leftAsync && isPromise(l)) || (rightAsync && isPromise(r))) {\n\t\t\t\treturn all([\n\t\t\t\t\tleftAsync ? l : holdData(l),\n\t\t\t\t\trightAsync ? r : holdData(r),\n\t\t\t\t]).then(([lv, rv]) => keep(f(lv, rv, run, scope)));\n\t\t\t}\n\t\t\treturn f(l, r, run, scope);\n\t\t},\n\t\tasync: true,\n\t};\n};\n\n/** Evaluates a list of expressions in order. Returns a promise only if one that may wait returned one. */\nexport const evalAll = (\n\tlist: readonly Compiled[],\n): ((run: Run, scope: Scope) => unknown[] | Promise<unknown[]>) => {\n\tconst evs = list.map((item) => item.ev);\n\tconst count = evs.length;\n\tif (count === 0) return () => [];\n\tif (!list.some((item) => item.async)) {\n\t\treturn (run, scope) => {\n\t\t\t// oxlint-disable-next-line unicorn/no-new-array -- preallocates a known length on the hot path\n\t\t\tconst values = new Array<unknown>(count);\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tvalues[i] = (evs[i] as Compiled[\"ev\"])(run, scope);\n\t\t\t}\n\t\t\treturn values;\n\t\t};\n\t}\n\tconst asyncAt = list.map((item) => item.async);\n\treturn (run, scope) => {\n\t\t// oxlint-disable-next-line unicorn/no-new-array -- preallocates a known length on the hot path\n\t\tconst values = new Array<unknown>(count);\n\t\tlet pending = false;\n\t\ttry {\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tconst value = (evs[i] as Compiled[\"ev\"])(run, scope);\n\t\t\t\tvalues[i] = value;\n\t\t\t\tif (asyncAt[i] && isPromise(value)) pending = true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (let i = 0; i < count; i++) if (asyncAt[i]) silence(values[i]);\n\t\t\tthrow error;\n\t\t}\n\t\tif (!pending) return values;\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tif (!asyncAt[i]) values[i] = holdData(values[i]);\n\t\t}\n\t\treturn all(values);\n\t};\n};\n","import type { Statement } from \"../parser/ast.js\";\nimport type { Plan } from \"../runtime/ahead.js\";\nimport type { EnvironmentCore } from \"../runtime/types.js\";\n\n/**\n * What statements may do to the variables around them, and whether they may wait for a promise, found from their\n * syntax. Kiln uses it to start the statements after one that waits straight away, when they don't depend on it; see\n * `runtime/ahead.ts`.\n */\nexport type Effects = {\n\t/** Variables the statements may read, or null when they may read any, as content from elsewhere may. */\n\treadonly reads: ReadonlySet<string> | null;\n\t/** Variables the statements set themselves. */\n\treadonly sets: ReadonlySet<string>;\n\t/**\n\t * They place content from elsewhere: a block, whose content may come from another template, `block()`, `parent()`\n\t * or a slot, whose content comes from the caller. It reads any variable, and when it sets variables itself, it may\n\t * set any that exists. See `contentSets`.\n\t */\n\treadonly elsewhere: boolean;\n\t/** Whether the statements may wait for a promise. */\n\treadonly waits: boolean;\n};\n\n/** Tags that load another template or call your code, so they may wait. */\nconst LOADS = new Set([\n\t\"Include\",\n\t\"Component\",\n\t\"Island\",\n\t\"Slot\",\n\t\"Block\",\n\t\"Cache\",\n\t\"Extends\",\n]);\n\n/** The effects of statements, at any depth. Macros and imports do nothing where they stand. */\nexport const effectsOf = (\n\tstatements: readonly Statement[],\n\tenv: EnvironmentCore,\n): Effects => {\n\tconst reads = new Set<string>();\n\tconst sets = new Set<string>();\n\tlet elsewhere = false;\n\tlet waits = false;\n\t// Iterative, because long expression chains can be thousands of levels deep.\n\tconst stack: object[] = [statements];\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop() as object;\n\t\tif (Array.isArray(current)) {\n\t\t\tfor (const item of current as unknown[]) {\n\t\t\t\tif (typeof item === \"object\" && item !== null) stack.push(item);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst node = current as Record<string, unknown> & { type?: string };\n\t\tswitch (node.type) {\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Import\":\n\t\t\tcase \"FromImport\":\n\t\t\t\tcontinue;\n\t\t\tcase \"Name\":\n\t\t\t\treads.add(node.name as string);\n\t\t\t\tbreak;\n\t\t\tcase \"Set\":\n\t\t\tcase \"SetBlock\":\n\t\t\t\tsets.add(node.name as string);\n\t\t\t\tbreak;\n\t\t\tcase \"Props\": {\n\t\t\t\tfor (const prop of node.props as { name: string }[])\n\t\t\t\t\tsets.add(prop.name);\n\t\t\t\tif (node.rest !== null) sets.add(node.rest as string);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Block\":\n\t\t\tcase \"Slot\":\n\t\t\t\telsewhere = true;\n\t\t\t\tbreak;\n\t\t\tcase \"Call\": {\n\t\t\t\tconst callee = node.callee as { type: string; name?: string };\n\t\t\t\tif (callee.type !== \"Name\") waits = true;\n\t\t\t\telse if (callee.name === \"block\" || callee.name === \"parent\") {\n\t\t\t\t\telsewhere = true;\n\t\t\t\t\twaits = true;\n\t\t\t\t} else if (\n\t\t\t\t\tenv.functions.get(callee.name as string)?.kind !== \"builtin\"\n\t\t\t\t) {\n\t\t\t\t\t// One of your functions, or a macro.\n\t\t\t\t\twaits = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Filter\":\n\t\t\t\tif (env.filters.get(node.name as string)?.kind === \"host\") waits = true;\n\t\t\t\tbreak;\n\t\t\tcase \"Test\":\n\t\t\t\tif (env.tests.get(node.name as string)?.kind === \"host\") waits = true;\n\t\t\t\tbreak;\n\t\t\tcase \"Apply\":\n\t\t\t\tfor (const filter of node.filters as { name: string }[]) {\n\t\t\t\t\tif (env.filters.get(filter.name)?.kind === \"host\") waits = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tif (node.type !== undefined && LOADS.has(node.type)) waits = true;\n\t\tfor (const key in node) {\n\t\t\tif (key === \"span\" || key === \"nameSpan\") continue;\n\t\t\tconst value = node[key];\n\t\t\tif (typeof value === \"object\" && value !== null) stack.push(value);\n\t\t}\n\t}\n\treturn { reads: elsewhere ? null : reads, sets, elsewhere, waits };\n};\n\n/**\n * Whether variables `sets` may set touch `names`. Null stands for any variable: content from elsewhere may read any,\n * and may set any.\n */\nconst touches = (\n\tsets: ReadonlySet<string> | null,\n\tnames: ReadonlySet<string> | null,\n): boolean => {\n\tif (sets === null) return names === null || names.size > 0;\n\tif (sets.size === 0) return false;\n\tif (names === null) return true;\n\tfor (const name of sets) if (names.has(name)) return true;\n\treturn false;\n};\n\n/**\n * Whether two parts can run in either order: neither sets a variable the other reads or sets. With `strict`, content\n * from elsewhere counts as setting any variable.\n */\nexport const independent = (\n\ta: Effects,\n\tb: Effects,\n\tstrict: boolean,\n): boolean => {\n\tconst aSets = strict && a.elsewhere ? null : a.sets;\n\tconst bSets = strict && b.elsewhere ? null : b.sets;\n\treturn (\n\t\t!touches(aSets, b.reads) &&\n\t\t!touches(aSets, bSets) &&\n\t\t!touches(bSets, a.reads)\n\t);\n};\n\n/** Parts a waiting part looks past for ones that can start early. Compiling stays linear in long lists. */\nconst MAX_REACH = 256;\n\n/** Parts a waiting part may hold back to let the ones after them start early. */\nconst MAX_GROUP = 64;\n\nconst merge = (a: Effects, b: Effects): Effects => ({\n\treads:\n\t\ta.reads === null || b.reads === null\n\t\t\t? null\n\t\t\t: new Set([...a.reads, ...b.reads]),\n\tsets: new Set([...a.sets, ...b.sets]),\n\telsewhere: a.elsewhere || b.elsewhere,\n\twaits: a.waits || b.waits,\n});\n\n/**\n * The plan for a list of parts, from each part's effects. See `Plan`. With `strict`, content from elsewhere counts as\n * setting any variable, for renders where it may; see `contentSets`. For a part that waits, the parts held back are\n * the fewest that leave a part that waits among the independent parts after them: holding back one part more can only\n * help when a later part depends on it.\n */\nexport const planOf = (effects: readonly Effects[], strict: boolean): Plan => {\n\tconst after: number[] = [];\n\tconst reach: number[] = [];\n\teffects.forEach((part, index) => {\n\t\tafter.push(index);\n\t\treach.push(index);\n\t\tif (!part.waits) return;\n\t\tconst last = Math.min(effects.length - 1, index + MAX_REACH);\n\t\tconst most = Math.min(last - 1, index + MAX_GROUP);\n\t\tlet waiting = part;\n\t\tfor (let group = index; group <= most; group++) {\n\t\t\tif (group > index) waiting = merge(waiting, effects[group] as Effects);\n\t\t\tlet end = group;\n\t\t\tlet waits = false;\n\t\t\tfor (let next = group + 1; next <= last; next++) {\n\t\t\t\tconst ahead = effects[next] as Effects;\n\t\t\t\tif (!independent(waiting, ahead, strict)) break;\n\t\t\t\tend = next;\n\t\t\t\tif (ahead.waits) waits = true;\n\t\t\t}\n\t\t\tif (waits) {\n\t\t\t\tafter[index] = group;\n\t\t\t\treach[index] = end;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Everything after is independent, and none of it waits, so holding more back gains nothing.\n\t\t\tif (end === last) return;\n\t\t}\n\t});\n\treturn { after, reach };\n};\n","import {\n\tcreateDiagnostic,\n\ttype Diagnostic,\n\tKilnSyntaxError,\n} from \"../errors.js\";\nimport { resolveTemplateName } from \"../names.js\";\nimport {\n\ttype Argument,\n\tDEFAULT_SLOT,\n\tESCAPE_STRATEGIES,\n\ttype EscapeStrategy,\n\ttype Expression,\n\ttype FilterCall,\n\ttype HashEntry,\n\ttype PropType,\n\ttype Statement,\n\ttype TemplateNode,\n} from \"../parser/ast.js\";\nimport { parse } from \"../parser/parser.js\";\nimport { getAttr, getMethod, readableNames } from \"../runtime/access.js\";\nimport {\n\tatFront,\n\tcontentSets,\n\tisRoot,\n\tpassesAhead,\n\tpassesFrom,\n\trunSequence,\n\ttype Sequence,\n} from \"../runtime/ahead.js\";\nimport { packSaved, unpackSaved } from \"../runtime/cache.js\";\nimport { escapeHtml, escapeWith } from \"../runtime/escape.js\";\nimport {\n\tISLAND_CLOSING,\n\tISLAND_SCRIPT,\n\ttype IslandMode,\n\tislandProps,\n\ttype JsonValue,\n\trecordIsland,\n\tstreamIsland,\n} from \"../runtime/islands.js\";\nimport { callMacro } from \"../runtime/macros.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport {\n\tcontains,\n\toperatorFunction,\n\trangeOperator,\n} from \"../runtime/operators.js\";\nimport {\n\tadditionsIn,\n\tcheckLate,\n\tcloseOutlets,\n\tOUTLET_INDENT,\n\trecordAddition,\n} from \"../runtime/outlets.js\";\nimport {\n\tafter,\n\tall,\n\tcheckLength,\n\tconsume,\n\tembed,\n\tfail,\n\tholdData,\n\ttype IndentedText,\n\tindentedText,\n\tindentText,\n\tisPromise,\n\tloadTemplate,\n\tlocate,\n\tlocating,\n\tmarkCaller,\n\tendPlace,\n\tpassData,\n\tsilence,\n\tstartPlace,\n\tstep,\n\tunhold,\n\twithCaller,\n\twrite,\n} from \"../runtime/render.js\";\nimport {\n\tchildScope,\n\tlookup,\n\townerOf,\n\tsectionCopy,\n\tsectionScope,\n\tvariableNames,\n} from \"../runtime/scope.js\";\nimport {\n\ttype BlockDef,\n\ttype Builtin,\n\tblockScope,\n\ttype Capture,\n\ttype CallableEntry,\n\ttype Compiled,\n\ttype CompiledMacro,\n\ttype CompiledTemplate,\n\ttype EnvironmentCore,\n\temptyOut,\n\tendCapture,\n\ttype Ev,\n\tfillScope,\n\ttype Out,\n\ttype PathStep,\n\ttype Run,\n\ttype Scope,\n\ttype SlotFill,\n\ttype Stmt,\n\tstartCapture,\n} from \"../runtime/types.js\";\nimport {\n\tBLOCKED_NAMES,\n\tdescribeType,\n\tdescribeValue,\n\thashKeys,\n\tisEmpty,\n\tisPlainObject,\n\tmapKeys,\n\tliteralOptions,\n\tMISSING,\n\tmatchesType,\n\tsetOwn,\n\ttemplateFunctions,\n\ttoNumber,\n\ttoStr,\n\ttruthy,\n\ttypeName,\n\tvalueLabel,\n} from \"../runtime/values.js\";\nimport { Source, type Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport { constant, evalAll, map1, map2 } from \"./combinators.js\";\nimport { type Effects, effectsOf, independent, planOf } from \"./effects.js\";\n\n/** Marks a short-circuited optional chain while it is being evaluated. */\nexport const SHORT: unique symbol = Symbol(\"kiln.short\");\n/** Scope key holding the captured body of an `apply` tag. Templates cannot name symbols. */\nconst CAPTURED: unique symbol = Symbol(\"kiln.captured\");\n\nconst NOOP: Stmt = () => {};\nconst NOTHING = (): void => {};\n\n/** JavaScript engines overflow the stack well before 100,000 arguments, so spreads into calls stop here. */\nconst MAX_ARGUMENTS = 10_000;\n\n/** Deepest expression the compiler accepts. Each level costs a few stack frames when compiling and rendering. */\nconst MAX_EXPRESSION_DEPTH = 1000;\n\nconst PROTO_KEY_MESSAGE = '\"__proto__\" cannot be used as a key';\n\nconst BUILTIN_CALLS = new Set([\"parent\", \"block\"]);\n\ntype ArgumentShape = { kind: Argument[\"type\"]; name: string };\n\ntype CompiledArguments = {\n\t/** Each argument, in order. */\n\tcompiled: Compiled[];\n\t/** Each argument's expression, in order. */\n\tevs: Ev[];\n\tvalues: (run: Run, scope: Scope) => unknown[] | Promise<unknown[]>;\n\tshapes: ArgumentShape[];\n\tasync: boolean;\n\tarrowAsync: boolean;\n};\n\n/**\n * Runs of statements a precompiled template generated, by the offset where each run's first statement starts. Each\n * replaces the statements from there to the one ending at `end`. See `precompiled.ts`.\n */\nexport type GeneratedRuns = ReadonlyMap<number, { end: number; run: Stmt }>;\n\n/**\n * Parses and compiles template source into closures. Problems are collected in `diagnostics`; the template renders\n * only when there are none. `generated` holds a precompiled template's generated statements.\n */\nexport const compileTemplate = (\n\tenv: EnvironmentCore,\n\tname: string,\n\ttext: string,\n\tgenerated?: GeneratedRuns,\n): CompiledTemplate => {\n\tconst source = new Source(name, text);\n\tconst { ast, problems } = parse(text, {\n\t\tisTest: (test) => env.tests.has(test),\n\t});\n\tconst diagnostics = problems.map((problem) =>\n\t\tcreateDiagnostic(source, problem.code, problem.message, problem.span),\n\t);\n\treturn new Compiler(env, source, ast, diagnostics, generated).compile();\n};\n\nconst makeEmitter =\n\t(strategy: EscapeStrategy | false) =>\n\t(value: unknown): string => {\n\t\tif (typeof value === \"string\") {\n\t\t\treturn strategy ? escapeWith(value, strategy) : value;\n\t\t}\n\t\tif (typeof value === \"number\") {\n\t\t\tconst text = String(value);\n\t\t\treturn strategy && strategy !== \"html\"\n\t\t\t\t? escapeWith(text, strategy)\n\t\t\t\t: text;\n\t\t}\n\t\tif (value instanceof Markup) {\n\t\t\t// Every strategy's output is also safe in HTML, so HTML output accepts any markup.\n\t\t\treturn !strategy || strategy === \"html\" || value.strategy === strategy\n\t\t\t\t? value.value\n\t\t\t\t: escapeWith(value.value, strategy);\n\t\t}\n\t\tconst text = toStr(value);\n\t\treturn strategy ? escapeWith(text, strategy) : text;\n\t};\n\nconst emitters = new Map<EscapeStrategy | false, (value: unknown) => string>();\n\n/** Prints a value with an escaping strategy, or none. One function per strategy, shared. */\nexport const emitter = (\n\tstrategy: EscapeStrategy | false,\n): ((value: unknown) => string) => {\n\tlet emit = emitters.get(strategy);\n\tif (!emit) {\n\t\temit = makeEmitter(strategy);\n\t\temitters.set(strategy, emit);\n\t}\n\treturn emit;\n};\n\n/** Text, or an output whose expression never waits, in a run that `printParts` prints. */\ntype Part =\n\t| { text: string; lines: readonly number[] | undefined; span: Span }\n\t| {\n\t\t\ttext: null;\n\t\t\tcompiled: Compiled;\n\t\t\tstrategy: EscapeStrategy | false;\n\t\t\tspan: Span;\n\t };\n\n/** How `printParts` evaluates an output: a variable and literal keys, a choice of two literals, or anything else. */\ntype Read = \"path\" | \"choice\" | \"other\";\n\n/**\n * Prints a run of text and outputs into one string, then writes it to the buffer once. Each output still counts a\n * step before it is evaluated, so limits stop the render at the same output.\n *\n * The commonest outputs are evaluated in place rather than through their compiled closures: variables with literal\n * keys, such as `{{ post.title }}`, read own properties of plain objects directly, and choices between two literals,\n * such as `{{ active ? \"on\" : \"off\" }}`, print text emitted when compiling. Anything unusual, such as a missing\n * variable, falls back to the full expression, so results and errors are the same.\n */\nconst printParts = (list: Part[]): Stmt => {\n\t// Neighbouring text, such as text around a tag that compiled to nothing, joins into one part.\n\tconst parts: Part[] = [];\n\tfor (const part of list) {\n\t\tconst last = parts.at(-1);\n\t\tif (part.text !== null && last && last.text !== null) {\n\t\t\tconst offset = last.text.length;\n\t\t\tconst lines = part.lines\n\t\t\t\t? [...(last.lines ?? []), ...part.lines.map((start) => start + offset)]\n\t\t\t\t: last.lines;\n\t\t\tparts[parts.length - 1] = {\n\t\t\t\ttext: last.text + part.text,\n\t\t\t\tlines,\n\t\t\t\tspan: { start: last.span.start, end: part.span.end },\n\t\t\t};\n\t\t} else parts.push(part);\n\t}\n\tconst first = parts[0] as Part;\n\tconst span = {\n\t\tstart: first.span.start,\n\t\tend: (parts.at(-1) as Part).span.end,\n\t};\n\tif (parts.length === 1 && first.text !== null) {\n\t\tconst text = first.text;\n\t\tif (!first.lines) {\n\t\t\treturn (run, _scope, out) => {\n\t\t\t\twrite(run, out, text, span);\n\t\t\t};\n\t\t}\n\t\tconst entry = indentedText(text, first.lines);\n\t\treturn (run, _scope, out) => {\n\t\t\tconst indent = out.indent;\n\t\t\twrite(\n\t\t\t\trun,\n\t\t\t\tout,\n\t\t\t\tindent === \"\" ? text : indentText(entry, indent, out.inline),\n\t\t\t\tspan,\n\t\t\t);\n\t\t};\n\t}\n\n\tconst count = parts.length;\n\tconst texts: (string | null)[] = [];\n\t// Text with line starts, which take the indentation of where it is inserted.\n\tconst indented: (IndentedText | null)[] = [];\n\tconst reads: Read[] = [];\n\tconst evs: (Ev | null)[] = [];\n\tconst emits: (((value: unknown) => string) | null)[] = [];\n\tconst html: boolean[] = [];\n\tconst roots: (string | null)[] = [];\n\tconst paths: PathStep[][] = [];\n\tconst choices: [string, string][] = [];\n\tconst tests: (Ev | null)[] = [];\n\tconst spans: Span[] = [];\n\tfor (const part of parts) {\n\t\tconst output = part.text === null ? part : null;\n\t\tconst compiled = output?.compiled;\n\t\tconst emit = output ? emitter(output.strategy) : null;\n\t\tconst path = compiled?.path;\n\t\tconst root = compiled?.variable ?? path?.root.variable ?? null;\n\t\tconst choice = compiled?.choice ? emitChoice(compiled.choice, emit) : null;\n\t\ttexts.push(part.text);\n\t\tindented.push(\n\t\t\tpart.text !== null && part.lines\n\t\t\t\t? indentedText(part.text, part.lines)\n\t\t\t\t: null,\n\t\t);\n\t\treads.push(root !== null ? \"path\" : choice ? \"choice\" : \"other\");\n\t\tevs.push(compiled?.ev ?? null);\n\t\temits.push(emit);\n\t\thtml.push(output?.strategy === \"html\");\n\t\troots.push(root);\n\t\tpaths.push(path ? path.steps : NO_STEPS);\n\t\tchoices.push(choice ?? NO_CHOICE);\n\t\ttests.push(compiled?.choice?.test ?? null);\n\t\tspans.push(part.span);\n\t}\n\n\treturn (run, scope, out) => {\n\t\tconst indent = out.indent;\n\t\tlet text = \"\";\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst part = texts[i];\n\t\t\tif (part !== null) {\n\t\t\t\tconst entry = indented[i];\n\t\t\t\ttext +=\n\t\t\t\t\tindent === \"\" || !entry\n\t\t\t\t\t\t? part\n\t\t\t\t\t\t: entry.indent === indent && !out.inline\n\t\t\t\t\t\t\t? entry.indented\n\t\t\t\t\t\t\t: indentText(entry, indent, text === \"\" && out.inline);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst at = spans[i] as Span;\n\t\t\tstep(run, at);\n\t\t\tconst kind = reads[i];\n\t\t\tif (kind === \"choice\") {\n\t\t\t\tconst [yes, no] = choices[i] as [string, string];\n\t\t\t\ttext += truthy((tests[i] as Ev)(run, scope)) ? yes : no;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet value: unknown;\n\t\t\tif (kind === \"path\") {\n\t\t\t\tvalue = lookup(scope, roots[i] as string);\n\t\t\t\tif (value === undefined || typeof value === \"function\") {\n\t\t\t\t\tvalue = (evs[i] as Ev)(run, scope);\n\t\t\t\t} else {\n\t\t\t\t\tvalue = readKeys(run, value, paths[i] as PathStep[]);\n\t\t\t\t}\n\t\t\t} else value = (evs[i] as Ev)(run, scope);\n\t\t\tif (typeof value === \"string\" && html[i]) {\n\t\t\t\ttext += escapeHtml(value);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\ttext += (emits[i] as (value: unknown) => string)(value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, at, error);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Values can be long, so stop at the output limit before they make a string too long for JavaScript.\n\t\t\tif (text.length > run.state.maxSize) write(run, out, text, at);\n\t\t}\n\t\twrite(run, out, text, span);\n\t};\n};\n\nconst NO_STEPS: PathStep[] = [];\nconst NO_CHOICE: [string, string] = [\"\", \"\"];\n\n/** Emits both branches of a choice when compiling, or returns null when emitting one fails, so it fails at render. */\nconst emitChoice = (\n\tchoice: NonNullable<Compiled[\"choice\"]>,\n\temit: ((value: unknown) => string) | null,\n): [string, string] | null => {\n\tif (!emit) return null;\n\ttry {\n\t\treturn [emit(choice.yes), emit(choice.no)];\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/**\n * Reads literal keys one after another. Own properties of plain objects are read inline, and everything else goes\n * through each step's full `read`, so the result is the same as reading one key at a time.\n */\nconst readKeys = (\n\trun: Run,\n\ttarget: unknown,\n\tsteps: readonly PathStep[],\n): unknown => {\n\tlet value = target;\n\tlet i = 0;\n\ttry {\n\t\tfor (; i < steps.length; i++) {\n\t\t\tconst step = steps[i] as PathStep;\n\t\t\tconst name = step.name;\n\t\t\tif (name !== null && typeof value === \"object\" && value !== null) {\n\t\t\t\tconst proto = Object.getPrototypeOf(value);\n\t\t\t\tif (proto === Object.prototype || proto === null) {\n\t\t\t\t\tconst item = (value as Record<string, unknown>)[name];\n\t\t\t\t\tif (\n\t\t\t\t\t\titem !== undefined &&\n\t\t\t\t\t\ttypeof item !== \"function\" &&\n\t\t\t\t\t\tObject.hasOwn(value, name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tvalue = item;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tvalue = step.read(run, value);\n\t\t}\n\t} catch (error) {\n\t\t// A getter in your data threw. Errors from the full reads are located already.\n\t\tconst step = steps[i] as PathStep;\n\t\tthrow locate(run, step.span, error, readingLabel(step.name ?? \"\"));\n\t}\n\treturn value;\n};\n\nconst isBlank = (statement: Statement) =>\n\tstatement.type === \"Text\" && statement.value.trim() === \"\";\n\n/** Whether statements may set a variable, at any depth. */\nexport const setsVariables = (statements: readonly Statement[]): boolean =>\n\tcontainsNode(\n\t\tstatements,\n\t\t(record) => record.type === \"Set\" || record.type === \"SetBlock\",\n\t);\n\n/**\n * Whether statements may set a variable, themselves or through content from elsewhere they place: a block, `block()`,\n * `parent()` or a slot. For a component's fills, whose content may then set any variable around the component.\n */\nexport const mayWrite = (statements: readonly Statement[]): boolean =>\n\tcontainsNode(\n\t\tstatements,\n\t\t(record) =>\n\t\t\trecord.type === \"Set\" ||\n\t\t\trecord.type === \"SetBlock\" ||\n\t\t\trecord.type === \"Block\" ||\n\t\t\trecord.type === \"Slot\" ||\n\t\t\t(record.type === \"Call\" &&\n\t\t\t\t(record.callee as { type?: string }).type === \"Name\" &&\n\t\t\t\tBUILTIN_CALLS.has((record.callee as { name: string }).name)),\n\t);\n\n/** Checks whether any node under `node` matches. */\nexport const containsNode = (\n\tnode: unknown,\n\tmatches: (record: Record<string, unknown>) => boolean,\n): boolean => {\n\t// Iterative, because long expression chains can be thousands of levels deep.\n\t// Only objects go on the stack: strings, numbers and spans hold no nodes.\n\tconst stack: object[] =\n\t\ttypeof node === \"object\" && node !== null ? [node] : [];\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop() as object;\n\t\tif (Array.isArray(current)) {\n\t\t\tfor (const item of current as unknown[]) {\n\t\t\t\tif (typeof item === \"object\" && item !== null) stack.push(item);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst record = current as Record<string, unknown>;\n\t\tif (matches(record)) return true;\n\t\tfor (const key in record) {\n\t\t\tif (key === \"span\" || key === \"nameSpan\") continue;\n\t\t\tconst value = record[key];\n\t\t\tif (typeof value === \"object\" && value !== null) stack.push(value);\n\t\t}\n\t}\n\treturn false;\n};\n\n/**\n * What a loop body does, found in one walk. `readsLoop`: it may read `loop`, so loops only build the `loop` hash when\n * needed. Blocks, `block()` and `parent()` count too, because another template's block can read the loop it is\n * placed in. `keepsScope`: it has\n * `set` or arrow functions, which can keep or change an iteration's scope.\n */\nconst scanLoopBody = (\n\tbody: Statement[],\n): { readsLoop: boolean; keepsScope: boolean } => {\n\tlet readsLoop = false;\n\tlet keepsScope = false;\n\tcontainsNode(body, (record) => {\n\t\tif (\n\t\t\t(record.type === \"Name\" && record.name === \"loop\") ||\n\t\t\trecord.type === \"Block\" ||\n\t\t\t(record.type === \"Call\" &&\n\t\t\t\t(record.callee as { type?: string; name?: string }).type === \"Name\" &&\n\t\t\t\t[\"block\", \"parent\"].includes(\n\t\t\t\t\t(record.callee as { name?: string }).name ?? \"\",\n\t\t\t\t))\n\t\t) {\n\t\t\treadsLoop = true;\n\t\t} else if (\n\t\t\trecord.type === \"Set\" ||\n\t\t\trecord.type === \"SetBlock\" ||\n\t\t\trecord.type === \"Arrow\"\n\t\t) {\n\t\t\tkeepsScope = true;\n\t\t}\n\t\treturn readsLoop && keepsScope;\n\t});\n\treturn { readsLoop, keepsScope };\n};\n\nclass Compiler {\n\treadonly #env: EnvironmentCore;\n\treadonly #source: Source;\n\treadonly #ast: TemplateNode;\n\treadonly #diagnostics: Diagnostic[];\n\treadonly #template: CompiledTemplate;\n\n\t#strategy: EscapeStrategy | false;\n\t/** The block being compiled, for `parent()`. */\n\t#blockName: string | null = null;\n\t#inMacro = false;\n\t#expressionDepth = 0;\n\treadonly #importAliases = new Map<string, number>();\n\treadonly #fromImports = new Map<string, { slot: number; name: string }>();\n\treadonly #generated: GeneratedRuns | undefined;\n\n\tconstructor(\n\t\tenv: EnvironmentCore,\n\t\tsource: Source,\n\t\tast: TemplateNode,\n\t\tdiagnostics: Diagnostic[],\n\t\tgenerated: GeneratedRuns | undefined,\n\t) {\n\t\tthis.#env = env;\n\t\tthis.#generated = generated;\n\t\tthis.#source = source;\n\t\tthis.#ast = ast;\n\t\tthis.#diagnostics = diagnostics;\n\t\tthis.#strategy = env.autoescape;\n\t\tconst template: CompiledTemplate = {\n\t\t\tname: source.name,\n\t\t\tsource,\n\t\t\tast,\n\t\t\tdiagnostics,\n\t\t\thasErrors: false,\n\t\t\tsyntaxError: () => new KilnSyntaxError(diagnostics, source),\n\t\t\tbody: NOOP,\n\t\t\tprops: null,\n\t\t\tparent: null,\n\t\t\tparentSpan: { start: 0, end: 0 },\n\t\t\tblocks: new Map(),\n\t\t\tblockList: undefined,\n\t\t\tmacros: new Map(),\n\t\t\timports: [],\n\t\t\tresolved: new Map(),\n\t\t\tkeyed: undefined,\n\t\t\tslotNames: [],\n\t\t\tplain: false,\n\t\t\ttop: null,\n\t\t\tearly: null,\n\t\t};\n\t\tthis.#template = template;\n\t}\n\n\tcompile(): CompiledTemplate {\n\t\tconst template = this.#template;\n\t\tconst body = this.#ast.body;\n\n\t\tthis.#collectNames(body);\n\t\tthis.#collectMacros(body);\n\n\t\tconst first = body.find((statement) => !isBlank(statement));\n\t\tconst extendsNode = first?.type === \"Extends\" ? first : null;\n\t\tthis.#checkPlacement(body, extendsNode !== null);\n\n\t\tif (extendsNode) {\n\t\t\ttemplate.parent = this.#expr(extendsNode.template);\n\t\t\ttemplate.parentSpan = extendsNode.span;\n\t\t\tconst statements: Stmt[] = [];\n\t\t\tconst ranges: number[] = [];\n\t\t\tbody.forEach((statement, index) => {\n\t\t\t\tif (\n\t\t\t\t\tstatement.type === \"Set\" ||\n\t\t\t\t\tstatement.type === \"SetBlock\" ||\n\t\t\t\t\tstatement.type === \"Props\"\n\t\t\t\t) {\n\t\t\t\t\tstatements.push(this.#statement(statement));\n\t\t\t\t\tranges.push(index, index + 1);\n\t\t\t\t} else if (statement.type === \"Block\") {\n\t\t\t\t\tthis.#defineBlock(statement);\n\t\t\t\t}\n\t\t\t});\n\t\t\ttemplate.body = this.#sequence(statements, body, ranges, true);\n\t\t\ttemplate.early = this.#early(body, extendsNode);\n\t\t} else {\n\t\t\ttemplate.body = this.#body(body, true);\n\t\t}\n\n\t\t// Lexer, parser and compiler problems are found in separate passes. Report them in source order.\n\t\tthis.#diagnostics.sort((a, b) => a.start.offset - b.start.offset);\n\t\ttemplate.hasErrors = this.#diagnostics.some((d) => d.severity === \"error\");\n\t\ttemplate.plain =\n\t\t\ttemplate.parent === null &&\n\t\t\ttemplate.blocks.size === 0 &&\n\t\t\ttemplate.imports.length === 0;\n\t\treturn template;\n\t}\n\n\t/**\n\t * What a page's top-level statements read and set, so its layout can start while they wait, or null when the name\n\t * of the layout depends on them. Found the first time they wait.\n\t */\n\t#early(body: Statement[], extendsNode: Statement): () => Effects | null {\n\t\tconst env = this.#env;\n\t\tlet found: Effects | null | undefined;\n\t\treturn () => {\n\t\t\tif (found === undefined) {\n\t\t\t\tconst top = effectsOf(\n\t\t\t\t\tbody.filter(\n\t\t\t\t\t\t(statement) =>\n\t\t\t\t\t\t\tstatement.type === \"Set\" ||\n\t\t\t\t\t\t\tstatement.type === \"SetBlock\" ||\n\t\t\t\t\t\t\tstatement.type === \"Props\",\n\t\t\t\t\t),\n\t\t\t\t\tenv,\n\t\t\t\t);\n\t\t\t\tfound = independent(top, effectsOf([extendsNode], env), false)\n\t\t\t\t\t? top\n\t\t\t\t\t: null;\n\t\t\t}\n\t\t\treturn found;\n\t\t};\n\t}\n\n\t// Diagnostics\n\n\t#error(code: string, message: string, span: Span): void {\n\t\tthis.#diagnostics.push(createDiagnostic(this.#source, code, message, span));\n\t}\n\n\t/** `__proto__` keys would hand host code an object that changes its own prototype when merged. */\n\t#protoKey(span: Span): void {\n\t\tthis.#error(\"invalid-key\", PROTO_KEY_MESSAGE, span);\n\t}\n\n\t/** A compiled expression for code that can never run, because compiling it reported an error. */\n\t#broken(): Compiled {\n\t\treturn constant(null);\n\t}\n\n\t// Pre-passes\n\n\t#walkStatements(\n\t\tstatements: Statement[],\n\t\tvisit: (statement: Statement) => void,\n\t): void {\n\t\tfor (const statement of statements) {\n\t\t\tvisit(statement);\n\t\t\tswitch (statement.type) {\n\t\t\t\tcase \"If\":\n\t\t\t\t\tfor (const branch of statement.branches) {\n\t\t\t\t\t\tthis.#walkStatements(branch.body, visit);\n\t\t\t\t\t}\n\t\t\t\t\tif (statement.alternate)\n\t\t\t\t\t\tthis.#walkStatements(statement.alternate, visit);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"For\":\n\t\t\t\t\tthis.#walkStatements(statement.body, visit);\n\t\t\t\t\tif (statement.alternate)\n\t\t\t\t\t\tthis.#walkStatements(statement.alternate, visit);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Component\":\n\t\t\t\t\tthis.#walkStatements(statement.body, visit);\n\t\t\t\t\tfor (const fill of statement.fills)\n\t\t\t\t\t\tthis.#walkStatements(fill.body, visit);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Island\":\n\t\t\t\tcase \"SetBlock\":\n\t\t\t\tcase \"Block\":\n\t\t\t\tcase \"Slot\":\n\t\t\t\tcase \"Macro\":\n\t\t\t\tcase \"Add\":\n\t\t\t\tcase \"Cache\":\n\t\t\t\tcase \"With\":\n\t\t\t\tcase \"Apply\":\n\t\t\t\tcase \"Autoescape\":\n\t\t\t\t\tthis.#walkStatements(statement.body, visit);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Collects what is visible everywhere in the file before compiling anything, in one walk: imports, slot names,\n\t * and block names, which must be unique.\n\t */\n\t#collectNames(body: Statement[]): void {\n\t\tconst template = this.#template;\n\t\tconst slotNames = new Set<string>();\n\t\tconst blockNames = new Set<string>();\n\t\tconst addImport = (name: string, span: Span): number => {\n\t\t\tlet resolved = name;\n\t\t\ttry {\n\t\t\t\tresolved = resolveTemplateName(name, template.name);\n\t\t\t} catch (error) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"invalid-template-name\",\n\t\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\ttemplate.imports.push({ name: resolved, span });\n\t\t\treturn template.imports.length - 1;\n\t\t};\n\n\t\tthis.#walkStatements(body, (statement) => {\n\t\t\tif (statement.type === \"Slot\") slotNames.add(statement.name);\n\t\t\telse if (statement.type === \"Block\") {\n\t\t\t\tif (blockNames.has(statement.name)) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"duplicate-block\",\n\t\t\t\t\t\t`Block \"${statement.name}\" is defined more than once`,\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tblockNames.add(statement.name);\n\t\t\t} else if (statement.type === \"Import\") {\n\t\t\t\tif (\n\t\t\t\t\tthis.#env.functions.has(statement.alias) ||\n\t\t\t\t\tBUILTIN_CALLS.has(statement.alias)\n\t\t\t\t) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t\t`Import alias \"${statement.alias}\" has the same name as a function. Choose another alias`,\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (this.#importAliases.has(statement.alias)) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"duplicate-import\",\n\t\t\t\t\t\t`\"${statement.alias}\" is imported more than once`,\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.#importAliases.set(\n\t\t\t\t\tstatement.alias,\n\t\t\t\t\taddImport(statement.template, statement.span),\n\t\t\t\t);\n\t\t\t} else if (statement.type === \"FromImport\") {\n\t\t\t\tconst slot = addImport(statement.template, statement.span);\n\t\t\t\tfor (const entry of statement.names) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.#env.functions.has(entry.alias) ||\n\t\t\t\t\t\tBUILTIN_CALLS.has(entry.alias)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t\t\t`Imported macro \"${entry.alias}\" has the same name as a function. Import it with \"as\" and another name`,\n\t\t\t\t\t\t\tentry.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.#fromImports.has(entry.alias)) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"duplicate-import\",\n\t\t\t\t\t\t\t`\"${entry.alias}\" is imported more than once`,\n\t\t\t\t\t\t\tentry.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthis.#fromImports.set(entry.alias, { slot, name: entry.name });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\ttemplate.slotNames = [...slotNames];\n\t}\n\n\t#collectMacros(body: Statement[]): void {\n\t\tconst macros = this.#template.macros;\n\t\tconst placeholders: {\n\t\t\tstatement: Extract<Statement, { type: \"Macro\" }>;\n\t\t\tmacro: CompiledMacro;\n\t\t}[] = [];\n\t\tfor (const statement of body) {\n\t\t\tif (statement.type !== \"Macro\" || statement.name === \"\") continue;\n\t\t\tif (macros.has(statement.name)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"duplicate-macro\",\n\t\t\t\t\t`Macro \"${statement.name}\" is defined more than once`,\n\t\t\t\t\tstatement.span,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.#env.functions.has(statement.name) ||\n\t\t\t\tBUILTIN_CALLS.has(statement.name)\n\t\t\t) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t`Macro \"${statement.name}\" has the same name as a function. Rename the macro`,\n\t\t\t\t\tstatement.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.#fromImports.has(statement.name)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t`Macro \"${statement.name}\" has the same name as an imported macro`,\n\t\t\t\t\tstatement.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst macro: CompiledMacro = {\n\t\t\t\tname: statement.name,\n\t\t\t\tparams: [],\n\t\t\t\tbody: NOOP,\n\t\t\t\tstrategy: this.#env.autoescape,\n\t\t\t\ttemplate: this.#template,\n\t\t\t};\n\t\t\tmacros.set(statement.name, macro);\n\t\t\tplaceholders.push({ statement, macro });\n\t\t}\n\n\t\t// Compile bodies after every name is known, so macros can call each other in any order.\n\t\tfor (const { statement, macro } of placeholders) {\n\t\t\tconst saved = { block: this.#blockName, inMacro: this.#inMacro };\n\t\t\tthis.#blockName = null;\n\t\t\tthis.#inMacro = true;\n\t\t\tmacro.params = statement.params.map((param) => ({\n\t\t\t\tname: param.name,\n\t\t\t\tdefault: param.default ? this.#expr(param.default) : null,\n\t\t\t}));\n\t\t\tmacro.body = this.#body(statement.body);\n\t\t\tthis.#blockName = saved.block;\n\t\t\tthis.#inMacro = saved.inMacro;\n\t\t}\n\t}\n\n\t/** Checks where tags may appear: `extends` first, child templates' top level, `props` and macros. */\n\t#checkPlacement(body: Statement[], isChild: boolean): void {\n\t\tlet seenContent = false;\n\t\tlet seenProps = false;\n\t\tlet onlyBlankBefore = true;\n\t\tfor (const statement of body) {\n\t\t\tconst isFirst = onlyBlankBefore;\n\t\t\tif (!isBlank(statement)) onlyBlankBefore = false;\n\t\t\tswitch (statement.type) {\n\t\t\t\tcase \"Extends\":\n\t\t\t\t\tif (!isFirst) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"extends-not-first\",\n\t\t\t\t\t\t\t'\"extends\" must be the first tag in the template',\n\t\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Props\":\n\t\t\t\t\tif (seenProps) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"duplicate-props\",\n\t\t\t\t\t\t\t'A template can only have one \"props\" tag',\n\t\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (seenContent) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"props-not-first\",\n\t\t\t\t\t\t\t'\"props\" must come before any content',\n\t\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tseenProps = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Text\":\n\t\t\t\t\tif (!isBlank(statement)) seenContent = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Set\":\n\t\t\t\tcase \"SetBlock\":\n\t\t\t\tcase \"Import\":\n\t\t\t\tcase \"FromImport\":\n\t\t\t\tcase \"Macro\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tseenContent = true;\n\t\t\t}\n\n\t\t\tif (isChild) {\n\t\t\t\tconst allowed =\n\t\t\t\t\tstatement.type === \"Extends\" ||\n\t\t\t\t\tstatement.type === \"Block\" ||\n\t\t\t\t\tstatement.type === \"Set\" ||\n\t\t\t\t\tstatement.type === \"SetBlock\" ||\n\t\t\t\t\tstatement.type === \"Props\" ||\n\t\t\t\t\tstatement.type === \"Import\" ||\n\t\t\t\t\tstatement.type === \"FromImport\" ||\n\t\t\t\t\tstatement.type === \"Macro\" ||\n\t\t\t\t\tisBlank(statement);\n\t\t\t\tif (!allowed) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"invalid-child-content\",\n\t\t\t\t\t\t'A template that uses \"extends\" can only contain blocks, \"set\", \"props\", \"import\", \"from\" and \"macro\" at its top level',\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst checkNested = (\n\t\t\tstatements: Statement[],\n\t\t\tdepth: number,\n\t\t\tinMacro: boolean,\n\t\t) => {\n\t\t\tfor (const statement of statements) {\n\t\t\t\tif (depth > 0 && statement.type === \"Macro\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"invalid-macro-placement\",\n\t\t\t\t\t\t\"Macros must be defined at the top level of a template\",\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (depth > 0 && statement.type === \"Extends\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"extends-not-first\",\n\t\t\t\t\t\t'\"extends\" must be the first tag in the template',\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (depth > 0 && statement.type === \"Props\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"props-not-first\",\n\t\t\t\t\t\t'\"props\" must be at the top level of a template',\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (inMacro && statement.type === \"Block\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"invalid-block-placement\",\n\t\t\t\t\t\t\"Blocks cannot be defined inside macros\",\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst nestedMacro = inMacro || statement.type === \"Macro\";\n\t\t\t\tthis.#walkChildren(statement, (children) =>\n\t\t\t\t\tcheckNested(children, depth + 1, nestedMacro),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tcheckNested(body, 0, false);\n\t}\n\n\t#walkChildren(\n\t\tstatement: Statement,\n\t\tvisit: (children: Statement[]) => void,\n\t): void {\n\t\tswitch (statement.type) {\n\t\t\tcase \"If\":\n\t\t\t\tfor (const branch of statement.branches) visit(branch.body);\n\t\t\t\tif (statement.alternate) visit(statement.alternate);\n\t\t\t\tbreak;\n\t\t\tcase \"For\":\n\t\t\t\tvisit(statement.body);\n\t\t\t\tif (statement.alternate) visit(statement.alternate);\n\t\t\t\tbreak;\n\t\t\tcase \"Component\":\n\t\t\t\tvisit(statement.body);\n\t\t\t\tfor (const fill of statement.fills) visit(fill.body);\n\t\t\t\tbreak;\n\t\t\tcase \"Island\":\n\t\t\tcase \"SetBlock\":\n\t\t\tcase \"Block\":\n\t\t\tcase \"Slot\":\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Add\":\n\t\t\tcase \"Cache\":\n\t\t\tcase \"With\":\n\t\t\tcase \"Apply\":\n\t\t\tcase \"Autoescape\":\n\t\t\t\tvisit(statement.body);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Statements\n\n\t/**\n\t * Statements in order. Statement `i` compiled from `source[ranges[2i]]` up to `source[ranges[2i + 1]]`, which\n\t * decide what may start early while it waits; see `runSequence`. They are only read the first time one waits. With\n\t * `top`, the sequence is the template's top level, kept so a page's top-level statements can gate it; see `Gate`.\n\t */\n\t#sequence(\n\t\tstatements: Stmt[],\n\t\tsource: readonly Statement[],\n\t\tranges: readonly number[],\n\t\ttop = false,\n\t): Stmt {\n\t\tconst list: Stmt[] = [];\n\t\tconst kept: number[] = [];\n\t\tstatements.forEach((statement, index) => {\n\t\t\tif (statement === NOOP) return;\n\t\t\tlist.push(statement);\n\t\t\tkept.push(ranges[2 * index] as number, ranges[2 * index + 1] as number);\n\t\t});\n\t\tif (list.length === 0) return NOOP;\n\t\tif (list.length === 1 && !top) return list[0] as Stmt;\n\t\tconst env = this.#env;\n\t\t// Effects and plans are only found the first time a statement waits. The strict plans are for renders whose\n\t\t// blocks or fills set variables; see `contentSets`. The gated plans count every statement as one that waits.\n\t\tlet effects: Effects[] | null = null;\n\t\tlet spans: Span[] = [];\n\t\tlet elsewhere = false;\n\t\tconst plans: (ReturnType<Sequence[\"plan\"]> | undefined)[] = [];\n\t\tconst effectsFor = (): Effects[] => {\n\t\t\tif (effects === null) {\n\t\t\t\tconst groups = list.map((_, i) =>\n\t\t\t\t\tsource.slice(kept[2 * i] as number, kept[2 * i + 1] as number),\n\t\t\t\t);\n\t\t\t\teffects = groups.map((group) => effectsOf(group, env));\n\t\t\t\tspans = groups.map((group) => ({\n\t\t\t\t\tstart: (group[0] as Statement).span.start,\n\t\t\t\t\tend: (group.at(-1) as Statement).span.end,\n\t\t\t\t}));\n\t\t\t\telsewhere = effects.some((part) => part.elsewhere);\n\t\t\t}\n\t\t\treturn effects;\n\t\t};\n\t\tconst sequence: Sequence = {\n\t\t\tstatements: list,\n\t\t\tplan: (run, gated) => {\n\t\t\t\tconst found = effectsFor();\n\t\t\t\tconst strict = elsewhere && contentSets(run);\n\t\t\t\tconst key = (strict ? 1 : 0) + (gated ? 2 : 0);\n\t\t\t\treturn (plans[key] ??= {\n\t\t\t\t\t...planOf(\n\t\t\t\t\t\tgated ? found.map((part) => ({ ...part, waits: true })) : found,\n\t\t\t\t\t\tstrict,\n\t\t\t\t\t),\n\t\t\t\t\tspans,\n\t\t\t\t});\n\t\t\t},\n\t\t\tclear: (run, index, other) =>\n\t\t\t\tindependent(effectsFor()[index] as Effects, other, contentSets(run)),\n\t\t};\n\t\tif (top) this.#template.top = sequence;\n\t\tif (list.length === 1) return list[0] as Stmt;\n\t\tconst last = list.length - 1;\n\t\treturn (run, scope, out) =>\n\t\t\trunSequence(sequence, 0, last, run, scope, out, null);\n\t}\n\n\t/**\n\t * Compiles statements in order. Runs of text and outputs that never wait become one statement, see `printParts`.\n\t * With `top`, they are the template's top level; see `#sequence`.\n\t */\n\t#body(statements: Statement[], top = false): Stmt {\n\t\tconst compiled: Stmt[] = [];\n\t\t// The statements each compiled statement covers, as start and end indexes into `statements`.\n\t\tconst ranges: number[] = [];\n\t\tlet parts: Part[] = [];\n\t\tlet partsStart = 0;\n\t\tconst flush = (end: number) => {\n\t\t\tif (parts.length > 0) {\n\t\t\t\tcompiled.push(printParts(parts));\n\t\t\t\tranges.push(partsStart, end);\n\t\t\t}\n\t\t\tparts = [];\n\t\t};\n\t\tfor (let i = 0; i < statements.length; i++) {\n\t\t\tconst statement = statements[i] as Statement;\n\t\t\tconst generated = this.#generated?.get(statement.span.start);\n\t\t\tif (generated) {\n\t\t\t\tconst last = statements.findIndex(\n\t\t\t\t\t(item, index) => index >= i && item.span.end === generated.end,\n\t\t\t\t);\n\t\t\t\tif (last !== -1) {\n\t\t\t\t\tflush(i);\n\t\t\t\t\tcompiled.push(generated.run);\n\t\t\t\t\tranges.push(i, last + 1);\n\t\t\t\t\tthis.#defineCovered(statements.slice(i, last + 1));\n\t\t\t\t\ti = last;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (statement.type === \"Text\") {\n\t\t\t\tif (parts.length === 0) partsStart = i;\n\t\t\t\tparts.push({\n\t\t\t\t\ttext: statement.value,\n\t\t\t\t\tlines: statement.lines,\n\t\t\t\t\tspan: statement.span,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (statement.type === \"Output\") {\n\t\t\t\tconst expression = this.#expr(statement.expression);\n\t\t\t\tif (!expression.async) {\n\t\t\t\t\tif (parts.length === 0) partsStart = i;\n\t\t\t\t\tparts.push({\n\t\t\t\t\t\ttext: null,\n\t\t\t\t\t\tcompiled: expression,\n\t\t\t\t\t\tstrategy: this.#strategy,\n\t\t\t\t\t\tspan: statement.span,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tflush(i);\n\t\t\t\tcompiled.push(this.#output(expression, statement.span));\n\t\t\t\tranges.push(i, i + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tflush(i);\n\t\t\tcompiled.push(this.#statement(statement));\n\t\t\tranges.push(i, i + 1);\n\t\t}\n\t\tflush(statements.length);\n\t\treturn this.#sequence(compiled, statements, ranges, top);\n\t}\n\n\t/**\n\t * Blocks and `props` inside a generated run still need their definitions, which the closure compiler keeps: the\n\t * generated code only places blocks, and `renderBlock` runs `props` on its own.\n\t */\n\t#defineCovered(statements: Statement[]): void {\n\t\tfor (const statement of statements) {\n\t\t\tif (statement.type === \"Block\") this.#defineBlock(statement);\n\t\t\telse if (statement.type === \"Props\") this.#props(statement);\n\t\t\telse if (statement.type === \"Autoescape\") {\n\t\t\t\tconst saved = this.#strategy;\n\t\t\t\tthis.#strategy = statement.strategy;\n\t\t\t\tthis.#defineCovered(statement.body);\n\t\t\t\tthis.#strategy = saved;\n\t\t\t} else {\n\t\t\t\tthis.#walkChildren(statement, (children) =>\n\t\t\t\t\tthis.#defineCovered(children),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t#statement(node: Statement): Stmt {\n\t\tswitch (node.type) {\n\t\t\tcase \"Text\":\n\t\t\tcase \"Output\":\n\t\t\t\treturn this.#body([node]);\n\t\t\tcase \"If\":\n\t\t\t\treturn this.#if(node);\n\t\t\tcase \"For\":\n\t\t\t\treturn this.#for(node);\n\t\t\tcase \"Set\":\n\t\t\t\treturn this.#set(node.name, this.#expr(node.value), node.span);\n\t\t\tcase \"SetBlock\":\n\t\t\t\treturn this.#setBlock(node);\n\t\t\tcase \"Props\":\n\t\t\t\treturn this.#props(node);\n\t\t\tcase \"Extends\":\n\t\t\t\t// Handled by `compile`. A misplaced `extends` was already reported.\n\t\t\t\treturn NOOP;\n\t\t\tcase \"Block\":\n\t\t\t\treturn this.#blockStatement(node);\n\t\t\tcase \"Include\":\n\t\t\t\treturn this.#include(node);\n\t\t\tcase \"Component\":\n\t\t\t\treturn this.#component(node);\n\t\t\tcase \"Island\":\n\t\t\t\treturn this.#island(node);\n\t\t\tcase \"Slot\":\n\t\t\t\treturn this.#slot(node);\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Import\":\n\t\t\tcase \"FromImport\":\n\t\t\t\treturn NOOP;\n\t\t\tcase \"With\":\n\t\t\t\treturn this.#with(node);\n\t\t\tcase \"Cache\":\n\t\t\t\treturn this.#cache(node);\n\t\t\tcase \"Outlet\":\n\t\t\t\treturn this.#outlet(node);\n\t\t\tcase \"Flush\":\n\t\t\t\treturn this.#flush(node);\n\t\t\tcase \"Add\":\n\t\t\t\treturn this.#add(node);\n\t\t\tcase \"Apply\":\n\t\t\t\treturn this.#apply(node);\n\t\t\tcase \"Autoescape\": {\n\t\t\t\tconst saved = this.#strategy;\n\t\t\t\tthis.#strategy = node.strategy;\n\t\t\t\tconst body = this.#body(node.body);\n\t\t\t\tthis.#strategy = saved;\n\t\t\t\treturn body;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** An output whose expression may wait for a promise. Outputs that never wait are printed by `printParts`. */\n\t#output(compiled: Compiled, span: Span): Stmt {\n\t\tconst ev = compiled.ev;\n\t\tconst emit = emitter(this.#strategy);\n\t\tconst print = (run: Run, out: Out, value: unknown) => {\n\t\t\tlet text: string;\n\t\t\ttry {\n\t\t\t\ttext = emit(value);\n\t\t\t} catch (error) {\n\t\t\t\tthrow locate(run, span, error);\n\t\t\t}\n\t\t\twrite(run, out, text, span);\n\t\t};\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst value = ev(run, scope);\n\t\t\tif (isPromise(value)) {\n\t\t\t\treturn value.then((resolved) => print(run, out, unhold(resolved)));\n\t\t\t}\n\t\t\tprint(run, out, value);\n\t\t};\n\t}\n\n\t#if(node: Extract<Statement, { type: \"If\" }>): Stmt {\n\t\tconst branches = node.branches.map((branch) => {\n\t\t\tconst test = this.#expr(branch.test);\n\t\t\treturn {\n\t\t\t\ttest: test.ev,\n\t\t\t\tasync: test.async,\n\t\t\t\tbody: this.#body(branch.body),\n\t\t\t};\n\t\t});\n\t\tconst alternate = node.alternate ? this.#body(node.alternate) : null;\n\t\tconst span = node.span;\n\n\t\tconst from = (\n\t\t\tindex: number,\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t): void | Promise<void> => {\n\t\t\tfor (let i = index; i < branches.length; i++) {\n\t\t\t\tconst branch = branches[i] as (typeof branches)[number];\n\t\t\t\tconst value = branch.test(run, scope);\n\t\t\t\tif (branch.async && isPromise(value)) {\n\t\t\t\t\treturn value.then((resolved) =>\n\t\t\t\t\t\ttruthy(unhold(resolved))\n\t\t\t\t\t\t\t? branch.body(run, scope, out)\n\t\t\t\t\t\t\t: from(i + 1, run, scope, out),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (truthy(value)) return branch.body(run, scope, out);\n\t\t\t}\n\t\t\treturn alternate?.(run, scope, out);\n\t\t};\n\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn from(0, run, scope, out);\n\t\t};\n\t}\n\n\t#for(node: Extract<Statement, { type: \"For\" }>): Stmt {\n\t\tconst iterable = this.#expr(node.iterable);\n\t\tconst body = this.#body(node.body);\n\t\tconst alternate = node.alternate ? this.#body(node.alternate) : null;\n\t\tconst { keyName, valueName, span } = node;\n\t\tconst { readsLoop: usesLoop, keepsScope } = scanLoopBody(node.body);\n\t\t// Without `set` or arrow functions nothing can keep or change an iteration's scope, so one object serves every\n\t\t// iteration.\n\t\tconst shared = !keepsScope;\n\t\t// What the body sets, found the first time a pass waits. See `passesAhead`.\n\t\tlet effects: { sets: readonly string[]; elsewhere: boolean } | null = null;\n\t\tconst env = this.#env;\n\n\t\t/**\n\t\t * Runs passes `index` to `end`. When a pass waits, the passes after it run as `passesFrom` runs them: ahead of\n\t\t * it when they may. `ahead` is whether they may, found the first time a pass waits, and `indent` is the\n\t\t * output's indentation when the loop started.\n\t\t */\n\t\tconst iterate = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t\tvalues: readonly unknown[],\n\t\t\tkeys: readonly unknown[] | null,\n\t\t\tindex: number,\n\t\t\tend: number,\n\t\t\treused: Scope | null,\n\t\t\tindent: string,\n\t\t\tahead: boolean | null,\n\t\t): void | Promise<void> => {\n\t\t\tconst length = values.length;\n\t\t\tfor (let i = index; i < end; i++) {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst inner = reused ?? childScope(scope);\n\t\t\t\tconst inline = out.inline;\n\t\t\t\tinner[valueName] = values[i] ?? null;\n\t\t\t\tif (keyName !== null) inner[keyName] = keys ? (keys[i] ?? null) : i;\n\t\t\t\tif (usesLoop) {\n\t\t\t\t\t// A literal, so every `loop` hash shares one shape. Templates only read its own properties.\n\t\t\t\t\tinner.loop = {\n\t\t\t\t\t\tindex: i + 1,\n\t\t\t\t\t\tindex0: i,\n\t\t\t\t\t\trevIndex: length - i,\n\t\t\t\t\t\trevIndex0: length - i - 1,\n\t\t\t\t\t\tfirst: i === 0,\n\t\t\t\t\t\tlast: i === length - 1,\n\t\t\t\t\t\tlength,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst result = body(run, inner, out);\n\t\t\t\tif (result === undefined) continue;\n\t\t\t\tif (i + 1 >= end) return result;\n\t\t\t\tif (effects === null) {\n\t\t\t\t\tconst found = effectsOf(node.body, env);\n\t\t\t\t\teffects = { sets: [...found.sets], elsewhere: found.elsewhere };\n\t\t\t\t}\n\t\t\t\tconst may = (ahead ??= passesAhead(\n\t\t\t\t\trun,\n\t\t\t\t\tscope,\n\t\t\t\t\teffects.sets,\n\t\t\t\t\teffects.elsewhere,\n\t\t\t\t));\n\t\t\t\t// Each pass after it gets a scope of its own, since the waiting pass still uses this one.\n\t\t\t\treturn passesFrom(\n\t\t\t\t\trun,\n\t\t\t\t\tout,\n\t\t\t\t\tresult,\n\t\t\t\t\tinline,\n\t\t\t\t\ti + 1,\n\t\t\t\t\tend,\n\t\t\t\t\tindent,\n\t\t\t\t\t(aheadRun, aheadOut, at) =>\n\t\t\t\t\t\titerate(\n\t\t\t\t\t\t\taheadRun,\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\taheadOut,\n\t\t\t\t\t\t\tvalues,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tat,\n\t\t\t\t\t\t\tat + 1,\n\t\t\t\t\t\t\tshared ? childScope(scope) : null,\n\t\t\t\t\t\t\tindent,\n\t\t\t\t\t\t\tmay,\n\t\t\t\t\t\t),\n\t\t\t\t\tspan,\n\t\t\t\t\tmay,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst start = (run: Run, scope: Scope, out: Out, value: unknown) => {\n\t\t\tconst { values, keys } = loopItems(run, span, value, keyName !== null);\n\t\t\tif (values.length === 0) return alternate?.(run, scope, out);\n\t\t\tconst reused = shared ? childScope(scope) : null;\n\t\t\treturn iterate(\n\t\t\t\trun,\n\t\t\t\tscope,\n\t\t\t\tout,\n\t\t\t\tvalues,\n\t\t\t\tkeys,\n\t\t\t\t0,\n\t\t\t\tvalues.length,\n\t\t\t\treused,\n\t\t\t\tout.indent,\n\t\t\t\tnull,\n\t\t\t);\n\t\t};\n\n\t\tconst ev = iterable.ev;\n\t\tif (!iterable.async) {\n\t\t\treturn (run, scope, out) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn start(run, scope, out, ev(run, scope));\n\t\t\t};\n\t\t}\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst value = ev(run, scope);\n\t\t\tif (isPromise(value)) {\n\t\t\t\treturn value.then((resolved) =>\n\t\t\t\t\tstart(run, scope, out, unhold(resolved)),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn start(run, scope, out, value);\n\t\t};\n\t}\n\n\t/** `set`. Only a value that may wait is waited for: a promise in your data is a value like any other. */\n\t#set(name: string, value: Compiled, span: Span): Stmt {\n\t\tconst ev = value.ev;\n\t\tif (!value.async) {\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tassign(run, scope, name, ev(run, scope), span);\n\t\t\t};\n\t\t}\n\t\treturn (run, scope) => {\n\t\t\tstep(run, span);\n\t\t\tconst result = ev(run, scope);\n\t\t\tif (isPromise(result)) {\n\t\t\t\treturn result.then((resolved) => {\n\t\t\t\t\tassign(run, scope, name, unhold(resolved), span);\n\t\t\t\t});\n\t\t\t}\n\t\t\tassign(run, scope, name, result, span);\n\t\t};\n\t}\n\n\t#setBlock(node: Extract<Statement, { type: \"SetBlock\" }>): Stmt {\n\t\tconst body = this.#body(node.body);\n\t\tconst strategy = this.#strategy || \"html\";\n\t\tconst { name, span } = node;\n\t\treturn (run, scope) => {\n\t\t\tstep(run, span);\n\t\t\tconst out = emptyOut();\n\t\t\tconst result = body(run, scope, out);\n\t\t\tconst finish = () =>\n\t\t\t\tassign(run, scope, name, new Markup(out.s, strategy), span);\n\t\t\tif (result !== undefined) return result.then(finish);\n\t\t\tfinish();\n\t\t};\n\t}\n\n\t#props(node: Extract<Statement, { type: \"Props\" }>): Stmt {\n\t\tconst types = this.#env.types;\n\t\tconst props = node.props.map((prop) => {\n\t\t\tif (prop.type) this.#checkTypeNames(prop.type, prop.span);\n\t\t\tconst compiled = prop.default ? this.#expr(prop.default) : null;\n\t\t\tif (\n\t\t\t\tprop.type &&\n\t\t\t\tprop.default &&\n\t\t\t\tcompiled?.constant &&\n\t\t\t\t!matchesType(compiled.constant.value, prop.type, types)\n\t\t\t) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"prop-type\",\n\t\t\t\t\t`The default for \"${prop.name}\" is ${describeValue(compiled.constant.value, prop.type)}, which is not ${describeType(prop.type)}`,\n\t\t\t\t\tprop.default.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { name: prop.name, type: prop.type, default: compiled };\n\t\t});\n\t\tconst declared = new Set(props.map((prop) => prop.name));\n\t\tconst strict = this.#env.strict;\n\t\tconst span = node.span;\n\t\tconst templateName = this.#template.name;\n\t\t// Types are only checked in strict mode. Lenient mode passes values through.\n\t\tconst typed = strict\n\t\t\t? props.flatMap(({ name, type }) => (type ? [{ name, type }] : []))\n\t\t\t: [];\n\n\t\tconst checkTypes = (run: Run, scope: Scope): void => {\n\t\t\tfor (const { name, type } of typed) {\n\t\t\t\tconst value = scope[name];\n\t\t\t\tif (!matchesType(value, type, types)) {\n\t\t\t\t\tthrow fail(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\"prop-type\",\n\t\t\t\t\t\t`Prop \"${name}\" of ${templateName} must be ${describeType(type)}, but got ${describeValue(value, type)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst fill = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tindex: number,\n\t\t): void | Promise<void> => {\n\t\t\tfor (let i = index; i < props.length; i++) {\n\t\t\t\tconst prop = props[i] as (typeof props)[number];\n\t\t\t\tconst has = Object.hasOwn(scope, prop.name);\n\t\t\t\tconst current = has ? scope[prop.name] : undefined;\n\t\t\t\tif (current !== undefined && current !== null) continue;\n\t\t\t\tif (prop.default) {\n\t\t\t\t\tconst value = prop.default.ev(run, scope);\n\t\t\t\t\tif (prop.default.async && isPromise(value)) {\n\t\t\t\t\t\treturn value.then((resolved) => {\n\t\t\t\t\t\t\tscope[prop.name] = unhold(resolved) ?? null;\n\t\t\t\t\t\t\treturn fill(run, scope, i + 1);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tscope[prop.name] = value ?? null;\n\t\t\t\t} else if (!has) {\n\t\t\t\t\tif (strict) {\n\t\t\t\t\t\tthrow fail(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\"missing-prop\",\n\t\t\t\t\t\t\t`Required prop \"${prop.name}\" was not passed to ${templateName}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tscope[prop.name] = null;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst rest = node.rest;\n\t\t// The variables passed but not declared, in the order they were passed. A layout's run has no `passed`.\n\t\tconst collect = (run: Run, scope: Scope): Record<string, unknown> => {\n\t\t\tconst extra: Record<string, unknown> = {};\n\t\t\tfor (const key of run.passed ?? []) {\n\t\t\t\tif (!declared.has(key) && key !== \"slots\") extra[key] = scope[key];\n\t\t\t}\n\t\t\treturn extra;\n\t\t};\n\n\t\tconst apply: Stmt = (run, scope) => {\n\t\t\tif (rest !== null) scope[rest] = collect(run, scope);\n\t\t\telse if (strict && run.passed) {\n\t\t\t\tfor (const key of run.passed) {\n\t\t\t\t\tif (!declared.has(key) && key !== \"slots\") {\n\t\t\t\t\t\tthrow fail(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\"unknown-prop\",\n\t\t\t\t\t\t\t`\"${key}\" was passed to ${templateName}, which does not declare it in \"props\"`,\n\t\t\t\t\t\t\tsuggest(key, declared),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typed.length === 0) return fill(run, scope, 0);\n\t\t\treturn after(fill(run, scope, 0), () => checkTypes(run, scope));\n\t\t};\n\t\t// `props` is only valid at the top level, once, so this is the template's own.\n\t\tthis.#template.props = apply;\n\t\treturn apply;\n\t}\n\n\t/** Reports host type names, such as `Post`, that the environment has no check for. */\n\t#checkTypeNames(type: readonly PropType[], span: Span): void {\n\t\tfor (const member of type) {\n\t\t\tif (typeof member === \"string\" || \"literal\" in member) continue;\n\t\t\tif (\"list\" in member) this.#checkTypeNames(member.list, span);\n\t\t\telse if (\"shape\" in member) {\n\t\t\t\tfor (const key of member.shape) this.#checkTypeNames(key.type, span);\n\t\t\t} else if (!this.#env.types.has(member.named)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"unknown-type\",\n\t\t\t\t\t`Unknown type \"${member.named}\". Register it with the \"types\" option`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t#defineBlock(node: Extract<Statement, { type: \"Block\" }>): void {\n\t\tconst saved = this.#blockName;\n\t\tthis.#blockName = node.name;\n\t\tconst def: BlockDef = {\n\t\t\tbody: this.#body(node.body),\n\t\t\tstrategy: this.#strategy,\n\t\t\tsets: setsVariables(node.body),\n\t\t};\n\t\tthis.#blockName = saved;\n\t\tthis.#template.blocks.set(node.name, def);\n\t}\n\n\t#blockStatement(node: Extract<Statement, { type: \"Block\" }>): Stmt {\n\t\tthis.#defineBlock(node);\n\t\tconst { name, span, indent } = node;\n\t\treturn (run, scope, out) => {\n\t\t\tconst entry = run.blocks.get(name)?.[0];\n\t\t\tif (!entry) return;\n\t\t\t// The block renders in the capture it is placed in, such as a cached section.\n\t\t\tconst render = () =>\n\t\t\t\tentry.def.body(\n\t\t\t\t\tentry.run.within(run.capture, run.blockDepth),\n\t\t\t\t\tblockScope(entry.def, scope),\n\t\t\t\t\tout,\n\t\t\t\t);\n\t\t\t// A block defined in another template records where it was placed.\n\t\t\tconst own = entry.run.template === run.template;\n\t\t\tif (indent === \"\") {\n\t\t\t\treturn own ? render() : withCaller(run, span, render);\n\t\t\t}\n\t\t\tconst saved = out.indent;\n\t\t\tconst inline = out.inline;\n\t\t\tstartPlace(out, indent);\n\t\t\treturn endPlace(\n\t\t\t\tout,\n\t\t\t\tsaved,\n\t\t\t\tinline,\n\t\t\t\town ? render() : withCaller(run, span, render),\n\t\t\t);\n\t\t};\n\t}\n\n\t#include(node: Extract<Statement, { type: \"Include\" }>): Stmt {\n\t\tconst { ignoreMissing, span, indent } = node;\n\t\treturn this.#embedding(\n\t\t\tnode.template,\n\t\t\tnode.with,\n\t\t\tspan,\n\t\t\t(run, out, name, variables) => {\n\t\t\t\tif (indent === \"\") {\n\t\t\t\t\treturn embed(run, out, span, name, variables, null, ignoreMissing);\n\t\t\t\t}\n\t\t\t\tconst saved = out.indent;\n\t\t\t\tconst inline = out.inline;\n\t\t\t\tstartPlace(out, indent);\n\t\t\t\treturn endPlace(\n\t\t\t\t\tout,\n\t\t\t\t\tsaved,\n\t\t\t\t\tinline,\n\t\t\t\t\tembed(run, out, span, name, variables, null, ignoreMissing),\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t}\n\n\t#component(node: Extract<Statement, { type: \"Component\" }>): Stmt {\n\t\tconst { span, indent } = node;\n\t\tconst fills = node.fills.map((fill) => ({\n\t\t\tname: fill.name,\n\t\t\tbody: this.#body(fill.body),\n\t\t\tsets: mayWrite(fill.body),\n\t\t}));\n\t\tconst hasDefault = node.body.some((statement) => !isBlank(statement));\n\t\tif (hasDefault) {\n\t\t\tif (fills.some((fill) => fill.name === DEFAULT_SLOT)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"duplicate-fill\",\n\t\t\t\t\t'The default slot is filled both by \"fill\" and by content outside it',\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfills.push({\n\t\t\t\tname: DEFAULT_SLOT,\n\t\t\t\tbody: this.#body(node.body),\n\t\t\t\tsets: mayWrite(node.body),\n\t\t\t});\n\t\t}\n\t\treturn this.#embedding(\n\t\t\tnode.template,\n\t\t\tnode.with,\n\t\t\tspan,\n\t\t\t(run, out, name, variables, callerScope) => {\n\t\t\t\tconst slots = new Map<string, SlotFill>();\n\t\t\t\tfor (const fill of fills) {\n\t\t\t\t\tslots.set(fill.name, {\n\t\t\t\t\t\tbody: fill.body,\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tscope: callerScope,\n\t\t\t\t\t\tsets: fill.sets,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (indent === \"\") {\n\t\t\t\t\treturn embed(run, out, span, name, variables, slots, false);\n\t\t\t\t}\n\t\t\t\tconst saved = out.indent;\n\t\t\t\tconst inline = out.inline;\n\t\t\t\tstartPlace(out, indent);\n\t\t\t\treturn endPlace(\n\t\t\t\t\tout,\n\t\t\t\t\tsaved,\n\t\t\t\t\tinline,\n\t\t\t\t\tembed(run, out, span, name, variables, slots, false),\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * `island`: renders its template in place, like a component without content, unless the render defers or streams\n\t * islands. Then it writes a `<kiln-island>` element around the fallback, standing on lines of its own where the tags\n\t * do. A deferred island is recorded in the manifest, and a streamed one starts rendering on its own.\n\t */\n\t#island(node: Extract<Statement, { type: \"Island\" }>): Stmt {\n\t\tconst { span, indent, closing } = node;\n\t\tconst fallback = this.#body(node.body);\n\t\tconst element = (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tscope: Scope,\n\t\t\tislands: IslandMode,\n\t\t\tattribute: string,\n\t\t): void | Promise<void> => {\n\t\t\tconst state = run.state;\n\t\t\tlet opening = `<kiln-island ${attribute}>`;\n\t\t\tif (islands.script && !state.islandScript) {\n\t\t\t\topening = ISLAND_SCRIPT + opening;\n\t\t\t\t// A capture may never be output, so an island in one brings its own script.\n\t\t\t\tif (isRoot(state, out)) state.islandScript = true;\n\t\t\t}\n\t\t\tconst lead = (at: string) => (out.inline ? \"\" : out.indent) + at;\n\t\t\twrite(\n\t\t\t\trun,\n\t\t\t\tout,\n\t\t\t\tindent === undefined\n\t\t\t\t\t? opening\n\t\t\t\t\t: `${lead(indent)}${opening}${closing?.indent === null ? \"\" : \"\\n\"}`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t\treturn after(fallback(run, childScope(scope), out), () => {\n\t\t\t\tif (!closing) return write(run, out, ISLAND_CLOSING, span);\n\t\t\t\tconst start = closing.indent === null ? \"\" : lead(closing.indent);\n\t\t\t\tconst end = closing.newline ? \"\\n\" : \"\";\n\t\t\t\treturn write(run, out, `${start}${ISLAND_CLOSING}${end}`, span);\n\t\t\t});\n\t\t};\n\t\tconst render = (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tscope: Scope,\n\t\t\tislands: IslandMode,\n\t\t\ttemplate: CompiledTemplate,\n\t\t\tprops: Record<string, JsonValue>,\n\t\t): void | Promise<void> => {\n\t\t\tif (islands.mode === \"defer\") {\n\t\t\t\tconst id = recordIsland(run, span, islands, template.name, props);\n\t\t\t\treturn element(\n\t\t\t\t\trun,\n\t\t\t\t\tout,\n\t\t\t\t\tscope,\n\t\t\t\t\tislands,\n\t\t\t\t\t`src=\"${escapeHtml(islands.url + id)}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst state = run.state;\n\t\t\tconst streamed = (state.streamed ??= []);\n\t\t\tconst n = streamed.length + 1;\n\t\t\tconst html = streamIsland(run, span, template, props, n);\n\t\t\tsilence(html);\n\t\t\tstreamed.push(html);\n\t\t\treturn element(run, out, scope, islands, `stream=\"${n}\"`);\n\t\t};\n\t\tconst place = (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tname: unknown,\n\t\t\tvariables: unknown,\n\t\t\tscope: Scope,\n\t\t): void | Promise<void> => {\n\t\t\tconst props = islandProps(run, span, variables);\n\t\t\tconst state = run.state;\n\t\t\tconst islands = state.islands;\n\t\t\t// Only `renderStream` streams, and only output that is sure to be sent once.\n\t\t\tconst away =\n\t\t\t\tislands !== null &&\n\t\t\t\t(islands.mode === \"defer\" ||\n\t\t\t\t\t(state.stream !== null &&\n\t\t\t\t\t\tisRoot(state, out) &&\n\t\t\t\t\t\t!run.capture?.section));\n\t\t\tif (away) {\n\t\t\t\treturn after(loadTemplate(run, name, span), (template) =>\n\t\t\t\t\ttemplate\n\t\t\t\t\t\t? render(run, out, scope, islands, template, props)\n\t\t\t\t\t\t: undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (indent === \"\") {\n\t\t\t\treturn embed(run, out, span, name, props, null, false);\n\t\t\t}\n\t\t\tconst saved = out.indent;\n\t\t\tconst inline = out.inline;\n\t\t\tstartPlace(out, indent);\n\t\t\treturn endPlace(\n\t\t\t\tout,\n\t\t\t\tsaved,\n\t\t\t\tinline,\n\t\t\t\tembed(run, out, span, name, props, null, false),\n\t\t\t);\n\t\t};\n\t\treturn this.#embedding(\n\t\t\tnode.template,\n\t\t\tnode.with,\n\t\t\tspan,\n\t\t\t(run, out, name, variables, scope) =>\n\t\t\t\t// Which island brings the script, and the order streamed islands are numbered in, follow the page, so an\n\t\t\t\t// island running ahead waits for the parts before it.\n\t\t\t\trun.state.islands === null\n\t\t\t\t\t? place(run, out, name, variables, scope)\n\t\t\t\t\t: atFront(run, () => place(run, out, name, variables, scope)),\n\t\t);\n\t}\n\n\t/**\n\t * Evaluates an include's or component's template name and `with` value, then renders it with `render`. Both are\n\t * evaluated before either is waited for.\n\t */\n\t#embedding(\n\t\ttemplateNode: Expression,\n\t\twithNode: Expression | null,\n\t\tspan: Span,\n\t\trender: (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tname: unknown,\n\t\t\tvariables: unknown,\n\t\t\tscope: Scope,\n\t\t) => void | Promise<void>,\n\t): Stmt {\n\t\tconst template = this.#expr(templateNode);\n\t\tconst withValue = withNode ? this.#expr(withNode) : constant(null);\n\t\tif (!template.async && !withValue.async) {\n\t\t\tconst name = template.ev;\n\t\t\tconst variables = withValue.ev;\n\t\t\treturn (run, scope, out) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn render(run, out, name(run, scope), variables(run, scope), scope);\n\t\t\t};\n\t\t}\n\t\tconst values = evalAll([template, withValue]);\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn after(values(run, scope), ([name, variables]) =>\n\t\t\t\trender(run, out, name, variables, scope),\n\t\t\t);\n\t\t};\n\t}\n\n\t#slot(node: Extract<Statement, { type: \"Slot\" }>): Stmt {\n\t\tconst fallback = this.#body(node.body);\n\t\tconst { name, span, indent } = node;\n\t\tconst render = (run: Run, scope: Scope, out: Out) => {\n\t\t\tconst fill = run.slots?.get(name);\n\t\t\tif (!fill) return fallback(run, childScope(scope), out);\n\t\t\ttry {\n\t\t\t\t// The fill renders in the capture the slot is in, such as a cached section.\n\t\t\t\tconst result = fill.body(\n\t\t\t\t\tfill.run.within(run.capture, run.blockDepth),\n\t\t\t\t\tfillScope(fill, run),\n\t\t\t\t\tout,\n\t\t\t\t);\n\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t}\n\t\t};\n\t\tif (indent === \"\") return render;\n\t\treturn (run, scope, out) => {\n\t\t\tconst saved = out.indent;\n\t\t\tconst inline = out.inline;\n\t\t\tstartPlace(out, indent);\n\t\t\treturn endPlace(out, saved, inline, render(run, scope, out));\n\t\t};\n\t}\n\n\t#with(node: Extract<Statement, { type: \"With\" }>): Stmt {\n\t\tconst value = this.#expr(node.value);\n\t\tconst body = this.#body(node.body);\n\t\tconst span = node.span;\n\t\tconst enter = (run: Run, scope: Scope, out: Out, variables: unknown) => {\n\t\t\tconst inner = childScope(scope);\n\t\t\tif (isPlainObject(variables)) {\n\t\t\t\tfor (const key of hashKeys(variables))\n\t\t\t\t\tinner[key] = variables[key] ?? null;\n\t\t\t} else if (variables instanceof Map) {\n\t\t\t\tfor (const key of mapKeys(variables)) {\n\t\t\t\t\tinner[key] = variables.get(key) ?? null;\n\t\t\t\t}\n\t\t\t} else if (variables !== null && variables !== undefined) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"type-error\",\n\t\t\t\t\t`\"with\" needs a hash, but got a ${typeName(variables)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn body(run, inner, out);\n\t\t};\n\t\tconst ev = value.ev;\n\t\tif (!value.async) {\n\t\t\treturn (run, scope, out) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn enter(run, scope, out, ev(run, scope));\n\t\t\t};\n\t\t}\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn after(ev(run, scope), (variables) =>\n\t\t\t\tenter(run, scope, out, variables),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * `cache`: outputs the copy the environment's store saved under the key, or renders the body, outputs it and saves\n\t * it. The key and `for` are checked even without a store, so mistakes show up before a store is added.\n\t */\n\t#cache(node: Extract<Statement, { type: \"Cache\" }>): Stmt {\n\t\tconst key = this.#expr(node.key);\n\t\tconst seconds = node.seconds ? this.#expr(node.seconds) : null;\n\t\tconst body = this.#body(node.body);\n\t\tconst span = node.span;\n\t\tconst first = node.body[0];\n\t\tconst last = node.body.at(-1);\n\t\t// The section's content and escaping, so editing either gives the tag new keys, and tags with the same key in\n\t\t// one template only share copies when their content is the same.\n\t\tconst content = shortHash(\n\t\t\t`${this.#strategy}|${first && last ? this.#source.text.slice(first.span.start, last.span.end) : \"\"}`,\n\t\t);\n\t\tconst templateName = `${this.#template.name}|${content}`;\n\n\t\tconst part = (run: Run, value: unknown) => {\n\t\t\tif (value === null || value === undefined) return null;\n\t\t\tif (\n\t\t\t\ttypeof value === \"string\" ||\n\t\t\t\ttypeof value === \"number\" ||\n\t\t\t\ttypeof value === \"boolean\"\n\t\t\t) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (value instanceof Date && !Number.isNaN(value.getTime())) {\n\t\t\t\treturn value.toISOString();\n\t\t\t}\n\t\t\tif (value instanceof Markup) return value.value;\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"type-error\",\n\t\t\t\t`\"cache\" keys are made of strings, numbers, booleans, dates and null, but got a ${typeName(value)}`,\n\t\t\t);\n\t\t};\n\t\t// The template, the section's content, locale and time zone are part of every key, since the output depends on\n\t\t// them. So is how islands render, when they are deferred. Streamed islands render in place inside the section. So\n\t\t// is the indentation the section is placed at, which its lines are saved with.\n\t\tconst fullKey = (run: Run, out: Out, value: unknown) => {\n\t\t\tconst parts = Array.isArray(value)\n\t\t\t\t? value.map((item) => part(run, item))\n\t\t\t\t: [part(run, value)];\n\t\t\tconst { locale, timeZone, islands } = run.state;\n\t\t\tlet key = `${JSON.stringify(run.state.env.cacheNamespace)}|${templateName}|${locale}|${timeZone}|${JSON.stringify(parts)}`;\n\t\t\tif (out.indent !== \"\") {\n\t\t\t\tkey += `|indent|${JSON.stringify([out.indent, out.inline])}`;\n\t\t\t}\n\t\t\treturn islands?.mode === \"defer\"\n\t\t\t\t? `${key}|islands|${JSON.stringify([islands.url, islands.script])}`\n\t\t\t\t: key;\n\t\t};\n\t\tconst lifetime = (run: Run, value: unknown) => {\n\t\t\tif (value === null || value === undefined) return null;\n\t\t\tif (typeof value !== \"number\" || !(value > 0) || value === Infinity) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t`\"cache\" needs a number of seconds above 0 after \"for\", but got ${typeof value === \"number\" ? value : `a ${typeName(value)}`}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn value;\n\t\t};\n\n\t\tconst save = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t\tkeyValue: unknown,\n\t\t\tsecondsValue: unknown,\n\t\t): void | Promise<void> => {\n\t\t\tconst name = fullKey(run, out, keyValue);\n\t\t\tconst time = lifetime(run, secondsValue);\n\t\t\tconst state = run.state;\n\t\t\tconst store = state.env.cache;\n\t\t\t// The body writes straight to `out`, so its indentation is the same as without the cache.\n\t\t\t// The body sets variables in a section scope, so setting one never changes a variable outside. See `assign`.\n\t\t\t// It renders in a capture of its own, which keeps what it adds to outlets and the islands it defers.\n\t\t\tconst fresh = (): Capture | Promise<Capture> => {\n\t\t\t\tconst inner = sectionScope(scope);\n\t\t\t\tconst capture = startCapture(run, { scope: inner, deferred: [] });\n\t\t\t\treturn after(body(run.within(capture), inner, out), () => {\n\t\t\t\t\tendCapture(run, capture);\n\t\t\t\t\treturn capture;\n\t\t\t\t});\n\t\t\t};\n\t\t\tif (!store) return after(fresh(), NOTHING);\n\t\t\tconst found = locating(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t() => store.get({ key: name }),\n\t\t\t\t\"The cache store\",\n\t\t\t);\n\t\t\treturn after(found, (value) => {\n\t\t\t\tconst saved = typeof value === \"string\" ? unpackSaved(value) : null;\n\t\t\t\tif (saved) {\n\t\t\t\t\tconst replay = (front: boolean) => {\n\t\t\t\t\t\tconst islands = state.islands;\n\t\t\t\t\t\tif (islands?.mode === \"defer\" && saved.islands.length > 0) {\n\t\t\t\t\t\t\t// The copy holds the island script only if it was the first in its render to need it.\n\t\t\t\t\t\t\tif (saved.islandScript) {\n\t\t\t\t\t\t\t\tif (isRoot(state, out)) state.islandScript = true;\n\t\t\t\t\t\t\t} else if (islands.script && !state.islandScript) {\n\t\t\t\t\t\t\t\twrite(run, out, ISLAND_SCRIPT, span);\n\t\t\t\t\t\t\t\tif (isRoot(state, out)) state.islandScript = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (const island of saved.islands) {\n\t\t\t\t\t\t\t\trecordIsland(run, span, islands, island.template, island.props);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\twrite(run, out, saved.html, span);\n\t\t\t\t\t\tfor (const addition of saved.additions) {\n\t\t\t\t\t\t\trecordAddition(run, span, addition, front);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// A copy that adds a `once` tag not added yet waits for the parts before it, as `add to` does.\n\t\t\t\t\tif (\n\t\t\t\t\t\trun.capture?.behind &&\n\t\t\t\t\t\tsaved.additions.some(\n\t\t\t\t\t\t\t(addition) =>\n\t\t\t\t\t\t\t\taddition.once !== null &&\n\t\t\t\t\t\t\t\tstate.once?.has(addition.once) !== true,\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn atFront(run, () => replay(true));\n\t\t\t\t\t}\n\t\t\t\t\treplay(false);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst start = out.s.length;\n\t\t\t\tconst hadScript = state.islandScript;\n\t\t\t\treturn after(fresh(), (capture) => {\n\t\t\t\t\tconst manifest =\n\t\t\t\t\t\tstate.islands?.mode === \"defer\" ? state.islands.manifest : null;\n\t\t\t\t\tconst value = packSaved({\n\t\t\t\t\t\thtml: out.s.slice(start),\n\t\t\t\t\t\tadditions: additionsIn(capture.additions ?? []),\n\t\t\t\t\t\tislands: manifest\n\t\t\t\t\t\t\t? (capture.section?.deferred ?? []).flatMap(\n\t\t\t\t\t\t\t\t\t(id) => manifest[id] ?? [],\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\tislandScript: !hadScript && state.islandScript,\n\t\t\t\t\t});\n\t\t\t\t\treturn locating(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t() => store.set({ key: name, value, seconds: time }),\n\t\t\t\t\t\t\"The cache store\",\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\n\t\t// Whether a section holds the island script depends on the islands before it in the page, so with deferred\n\t\t// islands a section running ahead waits for the parts before it.\n\t\tconst render = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t\tkeyValue: unknown,\n\t\t\tsecondsValue: unknown,\n\t\t): void | Promise<void> =>\n\t\t\trun.state.islands?.mode === \"defer\"\n\t\t\t\t? atFront(run, () => save(run, scope, out, keyValue, secondsValue))\n\t\t\t\t: save(run, scope, out, keyValue, secondsValue);\n\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst keyValue = key.ev(run, scope);\n\t\t\tlet secondsValue: unknown = null;\n\t\t\ttry {\n\t\t\t\tif (seconds) secondsValue = seconds.ev(run, scope);\n\t\t\t} catch (error) {\n\t\t\t\tsilence(keyValue);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t(key.async && isPromise(keyValue)) ||\n\t\t\t\t(seconds?.async && isPromise(secondsValue))\n\t\t\t) {\n\t\t\t\treturn all([\n\t\t\t\t\tkey.async ? keyValue : holdData(keyValue),\n\t\t\t\t\tseconds?.async ? secondsValue : holdData(secondsValue),\n\t\t\t\t]).then(([k, t]) => render(run, scope, out, k, t));\n\t\t\t}\n\t\t\treturn render(run, scope, out, keyValue, secondsValue);\n\t\t};\n\t}\n\n\t/**\n\t * `outlet`: marks where its content goes in the render's output. The content is put in place when the render ends,\n\t * so the outlet must write to that output, not to a capture or a cached section.\n\t */\n\t#outlet(node: Extract<Statement, { type: \"Outlet\" }>): Stmt {\n\t\tconst { name, span, indent } = node;\n\t\tconst mark = (run: Run, out: Out) => {\n\t\t\tconst state = run.state;\n\t\t\tif (!isRoot(state, out) || run.capture?.section) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"misplaced-outlet\",\n\t\t\t\t\t`Outlet \"${name}\" can't be inside \"cache\", \"set\", \"apply\" or a macro`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tstate.outlets ??= new Map();\n\t\t\tif (state.outlets.has(name)) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"duplicate-outlet\",\n\t\t\t\t\t`Outlet \"${name}\" is used more than once in this render`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Without `indent` the tag shares its line, as `startPlace` treats it.\n\t\t\tstate.outlets.set(name, {\n\t\t\t\tout,\n\t\t\t\toffset: out.s.length,\n\t\t\t\tindent: indent === undefined ? out.indent : out.indent + indent,\n\t\t\t\tinline: indent === undefined,\n\t\t\t\tcontent: null,\n\t\t\t});\n\t\t};\n\t\t// Outlets are marked in the order of the page, so one running ahead waits for the parts before it.\n\t\treturn (run, _scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn atFront(run, () => mark(run, out));\n\t\t};\n\t}\n\n\t/**\n\t * `flush`: closes the outlets reached so far, so a streamed render can send its output up to here. It closes them\n\t * in `render` too, so a template behaves the same either way.\n\t */\n\t#flush(node: Extract<Statement, { type: \"Flush\" }>): Stmt {\n\t\tconst { span } = node;\n\t\tconst close = (run: Run, out: Out) => {\n\t\t\tconst state = run.state;\n\t\t\tif (!isRoot(state, out) || run.capture?.section) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"misplaced-flush\",\n\t\t\t\t\t`\"flush\" can't be inside \"cache\", \"set\", \"apply\", \"add to\" or a macro`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcloseOutlets(state);\n\t\t\tcheckLate(state);\n\t\t\tstate.stream?.flush();\n\t\t};\n\t\t// The outlets close with what the parts before the flush added, so one running ahead waits for them.\n\t\treturn (run, _scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn atFront(run, () => close(run, out));\n\t\t};\n\t}\n\n\t/**\n\t * `add to`: renders its content and records it for the outlet. The content takes the outlet's indentation when the\n\t * outlet has been reached. A `once` tag that already added doesn't render again, but is still recorded, so a cached\n\t * section saves it.\n\t */\n\t#add(node: Extract<Statement, { type: \"Add\" }>): Stmt {\n\t\tconst body = this.#body(node.body);\n\t\tconst { outlet, span } = node;\n\t\tconst once = node.once ? `${this.#template.name}:${span.start}` : null;\n\t\tconst add = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tfront: boolean,\n\t\t): void | Promise<void> => {\n\t\t\tconst first = once === null ? undefined : run.state.once?.get(once);\n\t\t\tif (first !== undefined) {\n\t\t\t\trecordAddition(run, span, { outlet, html: first, once }, front);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst capture: Out = {\n\t\t\t\ts: \"\",\n\t\t\t\tindent: OUTLET_INDENT,\n\t\t\t\tinline: false,\n\t\t\t\tahead: null,\n\t\t\t};\n\t\t\treturn after(body(run, childScope(scope), capture), () =>\n\t\t\t\trecordAddition(run, span, { outlet, html: capture.s, once }, front),\n\t\t\t);\n\t\t};\n\t\treturn (run, scope) => {\n\t\t\tstep(run, span);\n\t\t\t// Whether a `once` tag is the first follows the page, so one running ahead that hasn't been added yet\n\t\t\t// waits for the parts before it, and then knows.\n\t\t\tif (\n\t\t\t\tonce !== null &&\n\t\t\t\trun.capture?.behind &&\n\t\t\t\trun.state.once?.has(once) !== true\n\t\t\t) {\n\t\t\t\treturn atFront(run, () => add(run, scope, true));\n\t\t\t}\n\t\t\treturn add(run, scope, false);\n\t\t};\n\t}\n\n\t#apply(node: Extract<Statement, { type: \"Apply\" }>): Stmt {\n\t\tconst body = this.#body(node.body);\n\t\tconst strategy = this.#strategy;\n\t\tconst input: Compiled = {\n\t\t\tev: (_run, scope) => scope[CAPTURED],\n\t\t\tasync: false,\n\t\t};\n\t\tlet chain = input;\n\t\tfor (const filter of node.filters) {\n\t\t\tchain = this.#filterCall(filter, chain);\n\t\t}\n\t\tconst result = chain.ev;\n\t\tconst span = node.span;\n\t\t// The result is printed like `{{ }}` output: markup as it is, and anything else, such as a plain string from a\n\t\t// host filter, escaped.\n\t\tconst print = emitter(this.#strategy);\n\t\tconst emit = (run: Run, out: Out, value: unknown) => {\n\t\t\tlet text: string;\n\t\t\ttry {\n\t\t\t\ttext = print(value);\n\t\t\t} catch (error) {\n\t\t\t\tthrow locate(run, span, error);\n\t\t\t}\n\t\t\twrite(run, out, text, span);\n\t\t};\n\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst captured = emptyOut();\n\t\t\treturn after(body(run, scope, captured), () => {\n\t\t\t\tconst inner = childScope(scope);\n\t\t\t\t// The body was escaped as it rendered, so filters get it as markup. Without autoescape, it is plain text.\n\t\t\t\tinner[CAPTURED] = strategy\n\t\t\t\t\t? new Markup(captured.s, strategy)\n\t\t\t\t\t: captured.s;\n\t\t\t\tconst value = result(run, inner);\n\t\t\t\treturn chain.async\n\t\t\t\t\t? after(value, (resolved) => emit(run, out, resolved))\n\t\t\t\t\t: emit(run, out, value);\n\t\t\t});\n\t\t};\n\t}\n\n\t// Expressions\n\n\t#expr(node: Expression, guard = false): Compiled {\n\t\t// Long operator or filter chains nest deeply without parentheses, so guard compile and render recursion here.\n\t\tif (++this.#expressionDepth > MAX_EXPRESSION_DEPTH) {\n\t\t\tthis.#expressionDepth = 0;\n\t\t\tthis.#error(\n\t\t\t\t\"too-deep\",\n\t\t\t\t`Expression is nested more than ${MAX_EXPRESSION_DEPTH} levels deep`,\n\t\t\t\tnode.span,\n\t\t\t);\n\t\t\treturn this.#broken();\n\t\t}\n\t\ttry {\n\t\t\treturn this.#compileExpression(node, guard);\n\t\t} finally {\n\t\t\tif (this.#expressionDepth > 0) this.#expressionDepth--;\n\t\t}\n\t}\n\n\t#compileExpression(node: Expression, guard: boolean): Compiled {\n\t\tswitch (node.type) {\n\t\t\tcase \"Literal\":\n\t\t\t\treturn constant(node.value);\n\t\t\tcase \"Invalid\":\n\t\t\t\treturn this.#broken();\n\t\t\tcase \"Name\":\n\t\t\t\treturn this.#name(node.name, node.span, guard);\n\t\t\tcase \"Interpolation\":\n\t\t\t\treturn this.#interpolation(node.parts, node.span);\n\t\t\tcase \"Array\":\n\t\t\t\treturn this.#array(node);\n\t\t\tcase \"Hash\":\n\t\t\t\treturn this.#hash(node);\n\t\t\tcase \"Unary\":\n\t\t\t\treturn this.#unary(node);\n\t\t\tcase \"Binary\":\n\t\t\t\treturn this.#binary(node);\n\t\t\tcase \"Conditional\":\n\t\t\t\treturn this.#conditional(node);\n\t\t\tcase \"Member\":\n\t\t\t\treturn this.#member(node, guard);\n\t\t\tcase \"OptionalChain\": {\n\t\t\t\t// `?.` guards its whole chain, so missing variables and properties in it become null.\n\t\t\t\tconst inner = this.#expr(node.expression, true);\n\t\t\t\treturn map1(inner, (value) =>\n\t\t\t\t\tvalue === SHORT || value === MISSING\n\t\t\t\t\t\t? guard\n\t\t\t\t\t\t\t? MISSING\n\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t: value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase \"Call\":\n\t\t\t\treturn this.#call(node, guard);\n\t\t\tcase \"Filter\":\n\t\t\t\treturn this.#filter(node);\n\t\t\tcase \"Test\":\n\t\t\t\treturn this.#test(node);\n\t\t\tcase \"Arrow\":\n\t\t\t\treturn this.#arrow(node);\n\t\t}\n\t}\n\n\t#name(name: string, span: Span, guard: boolean): Compiled {\n\t\tif (guard) {\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tconst value = lookup(scope, name);\n\t\t\t\t\treturn value === undefined\n\t\t\t\t\t\t? MISSING\n\t\t\t\t\t\t: checkValue(run, span, value, name);\n\t\t\t\t},\n\t\t\t\tasync: false,\n\t\t\t};\n\t\t}\n\t\tif (this.#env.strict) {\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tconst value = lookup(scope, name);\n\t\t\t\t\tif (value === undefined) {\n\t\t\t\t\t\tthrow undefinedVariable(run, span, name, scope);\n\t\t\t\t\t}\n\t\t\t\t\treturn typeof value === \"function\"\n\t\t\t\t\t\t? checkValue(run, span, value, name)\n\t\t\t\t\t\t: value;\n\t\t\t\t},\n\t\t\t\tasync: false,\n\t\t\t\tvariable: name,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tconst value = lookup(scope, name);\n\t\t\t\tif (value === undefined) return null;\n\t\t\t\treturn typeof value === \"function\"\n\t\t\t\t\t? checkValue(run, span, value, name)\n\t\t\t\t\t: value;\n\t\t\t},\n\t\t\tasync: false,\n\t\t\tvariable: name,\n\t\t};\n\t}\n\n\t#interpolation(parts: Expression[], span: Span): Compiled {\n\t\tconst compiled = parts.map((part) => this.#expr(part));\n\t\tconst values = evalAll(compiled);\n\t\tconst join = (run: Run, list: unknown[]) => {\n\t\t\tlet result = \"\";\n\t\t\tfor (const value of list) {\n\t\t\t\tif (typeof value === \"string\") result += value;\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresult += toStr(value);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn locating(run, span, () => checkLength(run, result));\n\t\t};\n\t\tconst async = compiled.some((part) => part.async);\n\t\treturn {\n\t\t\tev: async\n\t\t\t\t? (run, scope) => after(values(run, scope), (list) => join(run, list))\n\t\t\t\t: (run, scope) => join(run, values(run, scope) as unknown[]),\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#array(node: Extract<Expression, { type: \"Array\" }>): Compiled {\n\t\tconst spreads = node.elements.map((element) => element.type === \"Spread\");\n\t\tconst compiled = node.elements.map((element) =>\n\t\t\telement.type === \"Spread\"\n\t\t\t\t? this.#expr(element.value)\n\t\t\t\t: this.#expr(element),\n\t\t);\n\t\tconst values = evalAll(compiled);\n\t\tconst hasSpread = spreads.includes(true);\n\t\tconst span = node.span;\n\t\tconst build = (run: Run, list: unknown[]): unknown[] => {\n\t\t\tif (!hasSpread) return list;\n\t\t\tconst result: unknown[] = [];\n\t\t\tfor (let i = 0; i < list.length; i++) {\n\t\t\t\tif (spreads[i]) {\n\t\t\t\t\tfor (const item of spreadItems(run, span, list[i])) result.push(item);\n\t\t\t\t} else result.push(list[i]);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst async = compiled.some((item) => item.async);\n\t\treturn {\n\t\t\tev: async\n\t\t\t\t? (run, scope) => after(values(run, scope), (list) => build(run, list))\n\t\t\t\t: (run, scope) => build(run, values(run, scope) as unknown[]),\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#hash(node: Extract<Expression, { type: \"Hash\" }>): Compiled {\n\t\ttype Entry = { spread: true } | { spread: false; key: string | null };\n\t\tconst entries: Entry[] = [];\n\t\tconst compiled: Compiled[] = [];\n\t\tfor (const entry of node.entries) {\n\t\t\tif (entry.type === \"Spread\") {\n\t\t\t\tentries.push({ spread: true });\n\t\t\t\tcompiled.push(this.#expr(entry.value));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = entry.key;\n\t\t\tif (key.type === \"Literal\") {\n\t\t\t\tif (key.value === \"__proto__\") this.#protoKey(key.span);\n\t\t\t\tentries.push({ spread: false, key: String(key.value) });\n\t\t\t} else {\n\t\t\t\tentries.push({ spread: false, key: null });\n\t\t\t\tcompiled.push(this.#expr(key));\n\t\t\t}\n\t\t\tcompiled.push(this.#expr(entry.value));\n\t\t}\n\t\tconst values = evalAll(compiled);\n\t\tconst span = node.span;\n\n\t\tconst build = (run: Run, list: unknown[]) => {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tlet index = 0;\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (entry.spread) {\n\t\t\t\t\tcopyHash(run, span, result, list[index++]);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet key = entry.key;\n\t\t\t\tif (key === null) {\n\t\t\t\t\tconst raw = list[index++];\n\t\t\t\t\t// Markup is a string with a safety mark, so it can name a key.\n\t\t\t\t\tconst computed = raw instanceof Markup ? raw.value : raw;\n\t\t\t\t\tif (typeof computed !== \"string\" && typeof computed !== \"number\") {\n\t\t\t\t\t\tthrow fail(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\"type-error\",\n\t\t\t\t\t\t\t`Hash keys must be strings or numbers, but got a ${typeName(computed)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tkey = String(computed);\n\t\t\t\t\tif (key === \"__proto__\") {\n\t\t\t\t\t\tthrow fail(run, span, \"invalid-key\", PROTO_KEY_MESSAGE);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetOwn(result, key, list[index++]);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst async = compiled.some((item) => item.async);\n\t\treturn {\n\t\t\tev: async\n\t\t\t\t? (run, scope) => after(values(run, scope), (list) => build(run, list))\n\t\t\t\t: (run, scope) => build(run, values(run, scope) as unknown[]),\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#unary(node: Extract<Expression, { type: \"Unary\" }>): Compiled {\n\t\tconst operand = this.#expr(node.operand);\n\t\tconst span = node.span;\n\t\tswitch (node.operator) {\n\t\t\tcase \"not\":\n\t\t\t\treturn map1(operand, (value) => !truthy(value));\n\t\t\tcase \"-\":\n\t\t\t\treturn map1(operand, (value, run) =>\n\t\t\t\t\ttypeof value === \"number\"\n\t\t\t\t\t\t? -value\n\t\t\t\t\t\t: -locating(run, span, () => toNumber(value, \"-\")),\n\t\t\t\t);\n\t\t\tcase \"+\":\n\t\t\t\treturn map1(operand, (value, run) =>\n\t\t\t\t\ttypeof value === \"number\"\n\t\t\t\t\t\t? value\n\t\t\t\t\t\t: locating(run, span, () => toNumber(value, \"+\")),\n\t\t\t\t);\n\t\t}\n\t}\n\n\t#binary(node: Extract<Expression, { type: \"Binary\" }>): Compiled {\n\t\tconst { operator, span } = node;\n\n\t\tif (\n\t\t\toperator === \"and\" ||\n\t\t\toperator === \"or\" ||\n\t\t\toperator === \"??\" ||\n\t\t\toperator === \"?:\"\n\t\t) {\n\t\t\tconst left = this.#expr(node.left, operator === \"??\");\n\t\t\tconst right = this.#expr(node.right);\n\t\t\tconst rightEv = right.ev;\n\t\t\tconst test = right.async\n\t\t\t\t? (run: Run, scope: Scope) =>\n\t\t\t\t\t\tafter(rightEv(run, scope), (resolved) => truthy(resolved))\n\t\t\t\t: (run: Run, scope: Scope) => truthy(rightEv(run, scope));\n\t\t\t// When the right side may wait, the left value is returned through `passData`, see `map1`.\n\t\t\tconst keep = right.async ? passData : (value: unknown) => value;\n\t\t\tconst decide = (value: unknown, run: Run, scope: Scope): unknown => {\n\t\t\t\tswitch (operator) {\n\t\t\t\t\tcase \"and\":\n\t\t\t\t\t\treturn truthy(value) ? test(run, scope) : false;\n\t\t\t\t\tcase \"or\":\n\t\t\t\t\t\treturn truthy(value) ? true : test(run, scope);\n\t\t\t\t\tcase \"??\":\n\t\t\t\t\t\treturn value === MISSING || value === null || value === undefined\n\t\t\t\t\t\t\t? right.ev(run, scope)\n\t\t\t\t\t\t\t: keep(value);\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn truthy(value) ? keep(value) : right.ev(run, scope);\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn map1(left, decide, right.async);\n\t\t}\n\n\t\tconst left = this.#expr(node.left);\n\t\tconst right = this.#expr(node.right);\n\n\t\tif (operator === \"..\") {\n\t\t\treturn map2(left, right, (a, b, run) =>\n\t\t\t\tlocating(run, span, () => {\n\t\t\t\t\tconst items = rangeOperator(a, b, run.state.maxSteps);\n\t\t\t\t\tconsume(run, items.length);\n\t\t\t\t\treturn items;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (operator === \"in\" || operator === \"not in\") {\n\t\t\tconst negate = operator === \"not in\";\n\t\t\treturn map2(left, right, (a, b, run) =>\n\t\t\t\tlocating(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t() => contains(a, b, (count) => consume(run, count)) !== negate,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst apply = operatorFunction(operator);\n\t\tconst joins = operator === \"~\";\n\t\treturn map2(left, right, (a, b, run) => {\n\t\t\ttry {\n\t\t\t\tconst result = apply(a, b);\n\t\t\t\treturn joins ? checkLength(run, result as string) : result;\n\t\t\t} catch (error) {\n\t\t\t\tthrow locate(run, span, error);\n\t\t\t}\n\t\t});\n\t}\n\n\t#conditional(node: Extract<Expression, { type: \"Conditional\" }>): Compiled {\n\t\tconst test = this.#expr(node.test);\n\t\tconst consequent = this.#expr(node.consequent);\n\t\tconst alternate = node.alternate\n\t\t\t? this.#expr(node.alternate)\n\t\t\t: constant(null);\n\t\tconst async = consequent.async || alternate.async;\n\t\t// When one branch may wait, the other's value is returned through `passData`, see `map1`.\n\t\tconst branch = (compiled: Compiled): Ev =>\n\t\t\tasync && !compiled.async\n\t\t\t\t? (run, scope) => passData(compiled.ev(run, scope))\n\t\t\t\t: compiled.ev;\n\t\tconst yes = branch(consequent);\n\t\tconst no = branch(alternate);\n\t\tconst compiled = map1(\n\t\t\ttest,\n\t\t\t(value, run, scope) => (truthy(value) ? yes(run, scope) : no(run, scope)),\n\t\t\tasync,\n\t\t);\n\t\tif (!test.async && consequent.constant && alternate.constant) {\n\t\t\tcompiled.choice = {\n\t\t\t\ttest: test.ev,\n\t\t\t\tyes: consequent.constant.value,\n\t\t\t\tno: alternate.constant.value,\n\t\t\t};\n\t\t}\n\t\treturn compiled;\n\t}\n\n\t#member(\n\t\tnode: Extract<Expression, { type: \"Member\" }>,\n\t\tguard: boolean,\n\t): Compiled {\n\t\tconst object = this.#expr(node.object, guard);\n\t\tconst { optional, span } = node;\n\t\tconst read = (run: Run, target: unknown, key: unknown): unknown =>\n\t\t\treadMember(run, span, target, key, optional, guard);\n\n\t\tconst property = node.property;\n\t\tif (property.type !== \"Literal\") {\n\t\t\t// The key waits for the object, as a chain that stops at a `?.` leaves it unevaluated.\n\t\t\tconst key = this.#expr(property);\n\t\t\tconst keyEv = key.ev;\n\t\t\tconst stops = chainStops(optional);\n\t\t\treturn map1(\n\t\t\t\tobject,\n\t\t\t\tkey.async\n\t\t\t\t\t? (target, run, scope) =>\n\t\t\t\t\t\t\tstops(target)\n\t\t\t\t\t\t\t\t? SHORT\n\t\t\t\t\t\t\t\t: after(keyEv(run, scope), (name) =>\n\t\t\t\t\t\t\t\t\t\tpassData(read(run, target, name)),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t: (target, run, scope) =>\n\t\t\t\t\t\t\tstops(target) ? SHORT : read(run, target, keyEv(run, scope)),\n\t\t\t\tkey.async,\n\t\t\t);\n\t\t}\n\t\tconst key = property.value;\n\t\tconst access: PathStep = {\n\t\t\tname: typeof key === \"string\" && !BLOCKED_NAMES.has(key) ? key : null,\n\t\t\tread: (run, target) => read(run, target, key),\n\t\t\tspan,\n\t\t};\n\t\tif (object.async)\n\t\t\treturn map1(object, (target, run) => access.read(run, target));\n\t\t// `a.b.c` reads every key in one closure, so a long path costs one call.\n\t\tconst inner = object.path;\n\t\treturn inner\n\t\t\t? pathRead(inner.root, [...inner.steps, access])\n\t\t\t: pathRead(object, [access]);\n\t}\n\n\t#arrow(node: Extract<Expression, { type: \"Arrow\" }>): Compiled {\n\t\tconst body = this.#expr(node.body);\n\t\tconst { params, span } = node;\n\t\tconst ev = body.ev;\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tconst call = (...args: unknown[]) => {\n\t\t\t\t\tstep(run, span);\n\t\t\t\t\tconst inner = childScope(scope);\n\t\t\t\t\tfor (let i = 0; i < params.length; i++) {\n\t\t\t\t\t\tinner[params[i] as string] = args[i] ?? null;\n\t\t\t\t\t}\n\t\t\t\t\treturn ev(run, inner);\n\t\t\t\t};\n\t\t\t\t// Your functions get a promise only from a body that waits, resolving to the value itself, or to it held\n\t\t\t\t// when it has a `then` member, which a promise resolving to it would call. See `holdData`.\n\t\t\t\tconst waits = body.async;\n\t\t\t\tconst fn = (...args: unknown[]) => {\n\t\t\t\t\tconst result = call(...args);\n\t\t\t\t\treturn waits && result instanceof Promise\n\t\t\t\t\t\t? result.then((value) => holdData(unhold(value)))\n\t\t\t\t\t\t: result;\n\t\t\t\t};\n\t\t\t\t// Lets filters such as `sort` tell a key selector from a comparator.\n\t\t\t\tObject.defineProperty(call, \"length\", { value: params.length });\n\t\t\t\tObject.defineProperty(fn, \"length\", { value: params.length });\n\t\t\t\ttemplateFunctions.set(fn, call);\n\t\t\t\treturn fn;\n\t\t\t},\n\t\t\tasync: false,\n\t\t\tarrowAsync: body.async,\n\t\t};\n\t}\n\n\t/**\n\t * Compiles call arguments. Named arguments become one trailing hash; spreads expand arrays.\n\t *\n\t * A `null` entry is a parameter the call skipped, passed as `undefined` so the parameter's default applies.\n\t */\n\t#arguments(\n\t\targs: (Argument | null)[],\n\t\t/** Position of a built-in's options hash, which is built once when its keys and values are literals. */\n\t\toptionsAt = -1,\n\t): CompiledArguments {\n\t\tfor (const arg of args) {\n\t\t\tif (arg?.type === \"Named\" && arg.name === \"__proto__\")\n\t\t\t\tthis.#protoKey(arg.span);\n\t\t}\n\t\tconst compiled = args.map((arg, index) => {\n\t\t\tif (!arg) return constant(undefined);\n\t\t\tconst value = this.#expr(arg.value);\n\t\t\treturn index === optionsAt ? (literalHash(arg.value) ?? value) : value;\n\t\t});\n\t\treturn {\n\t\t\tcompiled,\n\t\t\tevs: compiled.map((item) => item.ev),\n\t\t\tvalues: evalAll(compiled),\n\t\t\tshapes: args.map((arg) => ({\n\t\t\t\tkind: arg ? arg.type : \"Positional\",\n\t\t\t\tname: arg?.type === \"Named\" ? arg.name : \"\",\n\t\t\t})),\n\t\t\tasync: compiled.some((item) => item.async),\n\t\t\tarrowAsync: compiled.some((item) => item.arrowAsync === true),\n\t\t};\n\t}\n\n\t#call(node: Extract<Expression, { type: \"Call\" }>, guard: boolean): Compiled {\n\t\tconst callee = node.callee;\n\t\tif (callee.type === \"Name\") {\n\t\t\tconst name = callee.name;\n\t\t\tif (name === \"parent\") return this.#parentCall(node);\n\t\t\tif (name === \"block\") return this.#blockCall(node);\n\n\t\t\tconst local = this.#template.macros.get(name);\n\t\t\tif (local) {\n\t\t\t\tconst macros = this.#template.macros;\n\t\t\t\treturn this.#macroCall(node, () => macros.get(name), `Macro \"${name}\"`);\n\t\t\t}\n\t\t\tconst imported = this.#fromImports.get(name);\n\t\t\tif (imported) {\n\t\t\t\treturn this.#macroCall(\n\t\t\t\t\tnode,\n\t\t\t\t\t(run) => run.imports[imported.slot]?.macros.get(imported.name),\n\t\t\t\t\t`Macro \"${imported.name}\" from ${this.#template.imports[imported.slot]?.name}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst entry = this.#env.functions.get(name);\n\t\t\tif (!entry) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"unknown-function\",\n\t\t\t\t\t`Unknown function \"${name}\"`,\n\t\t\t\t\tcallee.span,\n\t\t\t\t);\n\t\t\t\treturn this.#broken();\n\t\t\t}\n\t\t\treturn this.#callable(\n\t\t\t\tentry,\n\t\t\t\t`Function \"${name}\"`,\n\t\t\t\tnull,\n\t\t\t\tnode.args,\n\t\t\t\tnode.span,\n\t\t\t);\n\t\t}\n\n\t\tif (callee.type === \"Member\") {\n\t\t\tconst object = callee.object;\n\t\t\tconst property = callee.property;\n\t\t\tif (\n\t\t\t\tobject.type === \"Name\" &&\n\t\t\t\tproperty.type === \"Literal\" &&\n\t\t\t\ttypeof property.value === \"string\" &&\n\t\t\t\tthis.#importAliases.has(object.name)\n\t\t\t) {\n\t\t\t\tconst slot = this.#importAliases.get(object.name) as number;\n\t\t\t\tconst macroName = property.value;\n\t\t\t\treturn this.#macroCall(\n\t\t\t\t\tnode,\n\t\t\t\t\t(run) => run.imports[slot]?.macros.get(macroName),\n\t\t\t\t\t`Macro \"${macroName}\" from ${this.#template.imports[slot]?.name}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.#methodCall(node, callee, guard);\n\t\t}\n\n\t\tthis.#error(\"invalid-call\", \"This value cannot be called\", node.span);\n\t\treturn this.#broken();\n\t}\n\n\t#macroCall(\n\t\tnode: Extract<Expression, { type: \"Call\" }>,\n\t\tresolve: (run: Run) => CompiledMacro | undefined,\n\t\tlabel: string,\n\t): Compiled {\n\t\tconst positional: Compiled[] = [];\n\t\tconst namedNames: string[] = [];\n\t\tconst named: Compiled[] = [];\n\t\tfor (const arg of node.args) {\n\t\t\tif (arg.type === \"Named\") {\n\t\t\t\tnamedNames.push(arg.name);\n\t\t\t\tnamed.push(this.#expr(arg.value));\n\t\t\t} else if (arg.type === \"Spread\") {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"invalid-spread\",\n\t\t\t\t\t\"Spread arguments cannot be passed to macros\",\n\t\t\t\t\targ.span,\n\t\t\t\t);\n\t\t\t} else positional.push(this.#expr(arg.value));\n\t\t}\n\t\tconst values = evalAll([...positional, ...named]);\n\t\tconst count = positional.length;\n\t\tconst span = node.span;\n\n\t\tconst invoke = (run: Run, list: unknown[]) => {\n\t\t\tconst macro = resolve(run);\n\t\t\tif (!macro) {\n\t\t\t\tthrow fail(run, span, \"unknown-macro\", `${label} does not exist`);\n\t\t\t}\n\t\t\tlet namedValues: Record<string, unknown> | null = null;\n\t\t\tif (namedNames.length > 0) {\n\t\t\t\tnamedValues = {};\n\t\t\t\tfor (let i = 0; i < namedNames.length; i++) {\n\t\t\t\t\tsetOwn(namedValues, namedNames[i] as string, list[count + i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn callMacro(run, span, macro, list.slice(0, count), namedValues);\n\t\t};\n\n\t\treturn {\n\t\t\tev: (run, scope) =>\n\t\t\t\tafter(values(run, scope), (list) => invoke(run, list)),\n\t\t\tasync: true,\n\t\t};\n\t}\n\n\t/** A method call. With `guard`, as in a `?.` chain, a missing or null object makes the call missing too. */\n\t#methodCall(\n\t\tnode: Extract<Expression, { type: \"Call\" }>,\n\t\tcallee: Extract<Expression, { type: \"Member\" }>,\n\t\tguard: boolean,\n\t): Compiled {\n\t\tconst object = this.#expr(callee.object, guard);\n\t\tconst property = callee.property;\n\t\tconst key =\n\t\t\tproperty.type === \"Literal\"\n\t\t\t\t? constant(property.value)\n\t\t\t\t: this.#expr(property);\n\t\tconst args = this.#arguments(node.args);\n\t\tconst span = node.span;\n\t\tconst optional = callee.optional;\n\t\tconst stops = chainStops(optional);\n\n\t\tconst invoke = (\n\t\t\trun: Run,\n\t\t\ttarget: unknown,\n\t\t\tname: unknown,\n\t\t\tlist: unknown[],\n\t\t) => {\n\t\t\tif (target === SHORT) return SHORT;\n\t\t\tif (target === null || target === undefined) {\n\t\t\t\tif (optional) return SHORT;\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"null-access\",\n\t\t\t\t\t`Cannot call ${valueLabel(name)} on null`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst method =\n\t\t\t\ttypeof name === \"string\" ? getMethod(target, name) : undefined;\n\t\t\tif (!method) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"method-not-exposed\",\n\t\t\t\t\t`${valueLabel(name)} is not a method that ${typeName(target)} exposes`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst built = buildArguments(run, span, args.shapes, list);\n\t\t\treturn locating(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t() => method.apply(target, built),\n\t\t\t\t`Method \"${String(name)}\"`,\n\t\t\t);\n\t\t};\n\n\t\tconst call = (run: Run, scope: Scope, target: unknown, name: unknown) => {\n\t\t\tstep(run, span);\n\t\t\treturn after(args.values(run, scope), (list) =>\n\t\t\t\tinvoke(run, target, name, list),\n\t\t\t);\n\t\t};\n\t\t// The name and arguments wait for the object, as a chain that stops at a `?.` leaves them unevaluated.\n\t\tconst keyEv = key.ev;\n\t\tconst named = (run: Run, scope: Scope, target: unknown) => {\n\t\t\tif (stops(target)) return SHORT;\n\t\t\tif (\n\t\t\t\tguard &&\n\t\t\t\t(target === null || target === undefined || target === MISSING)\n\t\t\t) {\n\t\t\t\treturn MISSING;\n\t\t\t}\n\t\t\tconst name = keyEv(run, scope);\n\t\t\treturn key.async\n\t\t\t\t? after(name, (resolved) => call(run, scope, target, resolved))\n\t\t\t\t: call(run, scope, target, name);\n\t\t};\n\t\tconst objectEv = object.ev;\n\t\treturn {\n\t\t\tev: object.async\n\t\t\t\t? (run, scope) =>\n\t\t\t\t\t\tafter(objectEv(run, scope), (target) => named(run, scope, target))\n\t\t\t\t: (run, scope) => named(run, scope, objectEv(run, scope)),\n\t\t\tasync: true,\n\t\t};\n\t}\n\n\t/** Compiles a call to a built-in or host function, filter or test. `input` is the filtered or tested value. */\n\t#callable(\n\t\tentry: CallableEntry,\n\t\tlabel: string,\n\t\tinput: Compiled | null,\n\t\targNodes: Argument[],\n\t\tspan: Span,\n\t): Compiled {\n\t\tconst args =\n\t\t\tentry.kind === \"builtin\"\n\t\t\t\t? this.#arguments(\n\t\t\t\t\t\tplaceArguments(entry, argNodes, label, (code, message, at) =>\n\t\t\t\t\t\t\tthis.#error(code, message, at),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tentry.options ? (entry.params?.length ?? 0) : -1,\n\t\t\t\t\t)\n\t\t\t\t: this.#arguments(argNodes);\n\t\t// The input and arguments all start before any is waited for.\n\t\tconst withInput = input ? evalAll([input, ...args.compiled]) : null;\n\t\tconst inputAsync = input?.async ?? false;\n\t\tconst shapes = args.shapes;\n\t\tconst valuesOf = args.values;\n\t\t// Only positional arguments: the evaluated list is already what the callable receives.\n\t\tconst plain =\n\t\t\tshapes.length <= MAX_ARGUMENTS &&\n\t\t\tshapes.every((shape) => shape.kind === \"Positional\");\n\n\t\tconst resultAsync = entry.kind === \"host\" || args.arrowAsync;\n\t\tconst async = resultAsync || args.async || inputAsync;\n\t\t// A built-in that runs no arrow function that waits never returns a promise to wait for, so when the call may\n\t\t// wait for its arguments, a value from your data it returns goes through `passData`. See `map1`.\n\t\tconst keep = async && !resultAsync ? passData : (value: unknown) => value;\n\n\t\tconst invoke = (\n\t\t\trun: Run,\n\t\t\tfirst: unknown,\n\t\t\thasInput: boolean,\n\t\t\tlist: unknown[],\n\t\t) => {\n\t\t\tconst built = plain ? list : buildArguments(run, span, shapes, list);\n\t\t\tif (entry.kind === \"builtin\") {\n\t\t\t\tconst call = entry.call;\n\t\t\t\treturn keep(\n\t\t\t\t\thasInput\n\t\t\t\t\t\t? locating(run, span, () => call(run, first, ...built))\n\t\t\t\t\t\t: locating(run, span, () => call(run, ...built)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (hasInput) built.unshift(first);\n\t\t\tconst call = entry.call;\n\t\t\tif (entry.render) {\n\t\t\t\treturn locating(run, span, () => call(run.info, ...built), label);\n\t\t\t}\n\t\t\treturn locating(run, span, () => call(...built), label);\n\t\t};\n\n\t\tif (entry.kind === \"builtin\" && plain && !async) {\n\t\t\tconst evs = input ? [input.ev, ...args.evs] : args.evs;\n\t\t\tconst direct = directCall(entry.call, evs, span);\n\t\t\tif (direct) return { ev: direct, async: false };\n\t\t}\n\n\t\tif (!input) {\n\t\t\tif (!args.async) {\n\t\t\t\treturn {\n\t\t\t\t\tev: (run, scope) => {\n\t\t\t\t\t\tstep(run, span);\n\t\t\t\t\t\treturn invoke(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tvaluesOf(run, scope) as unknown[],\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tasync,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tstep(run, span);\n\t\t\t\t\treturn after(valuesOf(run, scope), (list) =>\n\t\t\t\t\t\tinvoke(run, undefined, false, list),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tasync,\n\t\t\t};\n\t\t}\n\n\t\tconst inputEv = input.ev;\n\t\tif (!args.async && !inputAsync) {\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tstep(run, span);\n\t\t\t\t\treturn invoke(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tinputEv(run, scope),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tvaluesOf(run, scope) as unknown[],\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tasync,\n\t\t\t};\n\t\t}\n\t\tconst values = withInput as NonNullable<typeof withInput>;\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn after(values(run, scope), (list) =>\n\t\t\t\t\tinvoke(run, list[0], true, list.slice(1)),\n\t\t\t\t);\n\t\t\t},\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#filter(node: Extract<Expression, { type: \"Filter\" }>): Compiled {\n\t\tconst input = this.#expr(node.input, node.name === \"default\");\n\t\treturn this.#filterCall(node, input);\n\t}\n\n\t#filterCall(\n\t\tnode: FilterCall | Extract<Expression, { type: \"Filter\" }>,\n\t\tinput: Compiled,\n\t): Compiled {\n\t\tconst { name, args, span } = node;\n\t\tconst strategy = this.#strategy || \"html\";\n\n\t\tif (name === \"default\") {\n\t\t\tconst fallback = args[0] ? this.#expr(args[0].value) : constant(\"\");\n\t\t\tconst keep = fallback.async ? passData : (value: unknown) => value;\n\t\t\treturn map1(\n\t\t\t\tinput,\n\t\t\t\t(value, run, scope) =>\n\t\t\t\t\tvalue === MISSING || isEmpty(value)\n\t\t\t\t\t\t? fallback.ev(run, scope)\n\t\t\t\t\t\t: keep(value),\n\t\t\t\tfallback.async,\n\t\t\t);\n\t\t}\n\t\tif (name === \"raw\") {\n\t\t\treturn map1(input, (value, run) => {\n\t\t\t\tif (value instanceof Markup) {\n\t\t\t\t\treturn value.strategy === strategy\n\t\t\t\t\t\t? value\n\t\t\t\t\t\t: new Markup(value.value, strategy);\n\t\t\t\t}\n\t\t\t\treturn new Markup(\n\t\t\t\t\tlocating(run, span, () => toStr(value)),\n\t\t\t\t\tstrategy,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tif (name === \"escape\") {\n\t\t\tconst strategyArg = args[0]\n\t\t\t\t? this.#expr(args[0].value)\n\t\t\t\t: constant(\"html\");\n\t\t\tconst known = strategyArg.constant;\n\t\t\tif (known && !ESCAPE_STRATEGIES.includes(known.value as EscapeStrategy)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"unknown-strategy\",\n\t\t\t\t\t`Unknown escaping strategy \"${String(known.value)}\"`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn map2(input, strategyArg, (value, target, run) => {\n\t\t\t\tif (!ESCAPE_STRATEGIES.includes(target as EscapeStrategy)) {\n\t\t\t\t\tthrow fail(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\"unknown-strategy\",\n\t\t\t\t\t\t`Unknown escaping strategy ${valueLabel(target)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst chosen = target as EscapeStrategy;\n\t\t\t\tif (value instanceof Markup && value.strategy === chosen) return value;\n\t\t\t\tconst text = locating(run, span, () => toStr(value));\n\t\t\t\t// Escaping can make text several times longer, so it stops at the output limit.\n\t\t\t\treturn new Markup(\n\t\t\t\t\tlocating(run, span, () =>\n\t\t\t\t\t\tescapeWith(text, chosen, run.state.maxSize),\n\t\t\t\t\t),\n\t\t\t\t\tchosen,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\tconst entry = this.#env.filters.get(name);\n\t\tif (!entry) {\n\t\t\tthis.#error(\n\t\t\t\t\"unknown-filter\",\n\t\t\t\t`Unknown filter \"${name}\"`,\n\t\t\t\t\"nameSpan\" in node ? node.nameSpan : span,\n\t\t\t);\n\t\t\treturn this.#broken();\n\t\t}\n\t\treturn this.#callable(entry, `Filter \"${name}\"`, input, args, span);\n\t}\n\n\t#test(node: Extract<Expression, { type: \"Test\" }>): Compiled {\n\t\tconst { name, negated, span } = node;\n\n\t\tif (name === \"defined\") {\n\t\t\tconst input = node.input;\n\t\t\tif (\n\t\t\t\tinput.type === \"Call\" &&\n\t\t\t\tinput.callee.type === \"Name\" &&\n\t\t\t\tinput.callee.name === \"block\"\n\t\t\t) {\n\t\t\t\tconst blockName = input.args[0]\n\t\t\t\t\t? this.#expr(input.args[0].value)\n\t\t\t\t\t: constant(null);\n\t\t\t\treturn map1(blockName, (value, run) => {\n\t\t\t\t\tconst exists = typeof value === \"string\" && run.blocks.has(value);\n\t\t\t\t\treturn negated ? !exists : exists;\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn map1(this.#expr(input, true), (value) =>\n\t\t\t\tnegated ? value === MISSING : value !== MISSING,\n\t\t\t);\n\t\t}\n\n\t\tconst entry = this.#env.tests.get(name);\n\t\tif (!entry) {\n\t\t\tthis.#error(\"unknown-test\", `Unknown test \"${name}\"`, node.nameSpan);\n\t\t\treturn this.#broken();\n\t\t}\n\t\tconst compiled = this.#callable(\n\t\t\tentry,\n\t\t\t`Test \"${name}\"`,\n\t\t\tthis.#expr(node.input),\n\t\t\tnode.args,\n\t\t\tspan,\n\t\t);\n\t\treturn map1(compiled, (value) =>\n\t\t\tnegated ? !truthy(value) : truthy(value),\n\t\t);\n\t}\n\n\t#parentCall(node: Extract<Expression, { type: \"Call\" }>): Compiled {\n\t\tconst blockName = this.#blockName;\n\t\tif (blockName === null) {\n\t\t\tthis.#error(\n\t\t\t\t\"parent-outside-block\",\n\t\t\t\t'\"parent()\" can only be used inside a block',\n\t\t\t\tnode.span,\n\t\t\t);\n\t\t\treturn this.#broken();\n\t\t}\n\t\tconst span = node.span;\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tconst list = run.blocks.get(blockName);\n\t\t\t\t// The entry for this template's block. A block can render in a capture, with a run of its own.\n\t\t\t\tconst index = list\n\t\t\t\t\t? list.findIndex((entry) => entry.run.template === run.template)\n\t\t\t\t\t: -1;\n\t\t\t\tconst next = list?.[index + 1];\n\t\t\t\tif (!next) {\n\t\t\t\t\tthrow fail(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\"missing-parent-block\",\n\t\t\t\t\t\t`Block \"${blockName}\" has no parent block`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn renderBlockEntry(run, span, next, scope);\n\t\t\t},\n\t\t\tasync: true,\n\t\t};\n\t}\n\n\t#blockCall(node: Extract<Expression, { type: \"Call\" }>): Compiled {\n\t\tconst name = node.args[0] ? this.#expr(node.args[0].value) : constant(null);\n\t\tconst span = node.span;\n\t\tconst place = (run: Run, scope: Scope, value: unknown) => {\n\t\t\tconst entry =\n\t\t\t\ttypeof value === \"string\" ? run.blocks.get(value)?.[0] : undefined;\n\t\t\tif (!entry) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"unknown-block\",\n\t\t\t\t\t`Block ${valueLabel(value)} does not exist`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn renderBlockEntry(run, span, entry, scope);\n\t\t};\n\t\tconst ev = name.ev;\n\t\treturn {\n\t\t\tev: name.async\n\t\t\t\t? (run, scope) =>\n\t\t\t\t\t\tafter(ev(run, scope), (value) => place(run, scope, value))\n\t\t\t\t: (run, scope) => place(run, scope, ev(run, scope)),\n\t\t\tasync: true,\n\t\t};\n\t}\n}\n\n/** Renders a block into markup, for `parent()` and `block()`. */\nconst renderBlockEntry = (\n\trun: Run,\n\tspan: Span,\n\tentry: { def: BlockDef; run: Run },\n\tscope: Scope,\n): Markup | Promise<Markup> => {\n\tconst state = run.state;\n\t// `block()` can call itself, so count its nesting against `maxDepth`.\n\tconst depth = run.blockDepth + 1;\n\tif (depth > state.maxDepth) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-depth\",\n\t\t\t`Render stopped after nesting ${state.maxDepth} blocks deep`,\n\t\t);\n\t}\n\tconst out = emptyOut();\n\t// A capture of its own, since the block can render alongside other expressions.\n\tconst capture = startCapture(run);\n\tconst blockRun = entry.run.within(capture, depth);\n\tconst result = withCaller(run, span, () =>\n\t\tentry.def.body(blockRun, blockScope(entry.def, scope), out),\n\t);\n\treturn after(result, () => {\n\t\tendCapture(run, capture);\n\t\treturn new Markup(out.s, entry.def.strategy || \"html\");\n\t});\n};\n\n/**\n * Reads one property the way templates may, for `a.b` and `a[b]`. `optional` is set for `?.`, and `guard` where a\n * missing value is allowed, such as the input of `default`; see `MISSING` and `SHORT`.\n */\nexport const readMember = (\n\trun: Run,\n\tspan: Span,\n\ttarget: unknown,\n\trawKey: unknown,\n\toptional: boolean,\n\tguard: boolean,\n): unknown => {\n\tif (target === SHORT) return SHORT;\n\t// Markup is a string with a safety mark, so it can name a property.\n\tconst key = rawKey instanceof Markup ? rawKey.value : rawKey;\n\tconst strict = run.state.env.strict;\n\tif (target === null || target === undefined || target === MISSING) {\n\t\tif (optional) return SHORT;\n\t\tif (guard) return MISSING;\n\t\tif (strict) {\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"null-access\",\n\t\t\t\t`Cannot read ${valueLabel(key)} of null`,\n\t\t\t\t'Use \"?.\" to allow null.',\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n\tif (typeof key !== \"string\" && typeof key !== \"number\") {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"type-error\",\n\t\t\t`Property names must be strings or numbers, but got a ${typeName(key)}`,\n\t\t);\n\t}\n\tlet value: unknown;\n\ttry {\n\t\tvalue = getAttr(target, key);\n\t} catch (error) {\n\t\tthrow locate(run, span, error, readingLabel(key));\n\t}\n\tif (value === MISSING) {\n\t\tif (guard) return MISSING;\n\t\tif (strict) throw missingProperty(run, span, target, key);\n\t\treturn null;\n\t}\n\tif (value === undefined) return null;\n\tif (typeof value === \"function\")\n\t\treturn checkValue(run, span, value, String(key));\n\treturn value;\n};\n\n/** Reads literal keys one after another, such as `post.author.name`, in one closure. See `readKeys`. */\nconst pathRead = (root: Compiled, steps: PathStep[]): Compiled => {\n\tconst ev = root.ev;\n\treturn {\n\t\tev: (run, scope) => readKeys(run, ev(run, scope), steps),\n\t\tasync: false,\n\t\tpath: { root, steps },\n\t};\n};\n\n/** Names a property read for an error that one of your getters or lookup methods threw. */\nexport const readingLabel = (key: string | number): string =>\n\t`Reading \"${key}\"`;\n\n/** `set`: assigns where the variable already exists, or declares it in the current scope. */\nexport const assign = (\n\trun: Run,\n\tscope: Scope,\n\tname: string,\n\tvalue: unknown,\n\tspan: Span,\n): void => {\n\tlet owner = ownerOf(scope, name);\n\tif (owner === run.state.globals) {\n\t\tthrow fail(run, span, \"assign-global\", `Cannot assign to global \"${name}\"`);\n\t}\n\tif (owner !== null && run.capture?.section) {\n\t\towner = sectionCopy(scope, owner);\n\t}\n\t(owner ?? scope)[name] = value ?? null;\n};\n\nexport const checkValue = (\n\trun: Run,\n\tspan: Span,\n\tvalue: unknown,\n\tname: string,\n): unknown => {\n\tif (typeof value === \"function\") {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"function-value\",\n\t\t\t`\"${name}\" is a function, and functions in data cannot be used in templates`,\n\t\t\t\"Register it as a function instead, or expose it as a method.\",\n\t\t);\n\t}\n\treturn value;\n};\n\nexport const undefinedVariable = (\n\trun: Run,\n\tspan: Span,\n\tname: string,\n\tscope: Scope,\n) => {\n\treturn fail(\n\t\trun,\n\t\tspan,\n\t\t\"undefined-variable\",\n\t\t`Unknown variable \"${name}\"`,\n\t\tsuggest(name, variableNames(scope)),\n\t);\n};\n\nconst missingProperty = (\n\trun: Run,\n\tspan: Span,\n\ttarget: unknown,\n\tkey: string | number,\n) => {\n\tif (typeof target === \"string\" || target instanceof Markup) {\n\t\treturn fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-property\",\n\t\t\t`Strings have no property \"${key}\"`,\n\t\t\tkey === \"length\" ? 'Use the \"length\" filter.' : \"Use a filter instead.\",\n\t\t);\n\t}\n\tif (Array.isArray(target)) {\n\t\treturn fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-property\",\n\t\t\ttypeof key === \"number\" || /^\\d+$/.test(key)\n\t\t\t\t? `Index ${key} does not exist. The array has ${target.length} ${target.length === 1 ? \"item\" : \"items\"}`\n\t\t\t\t: `Arrays have no property \"${key}\"`,\n\t\t);\n\t}\n\tif (BLOCKED_NAMES.has(String(key))) {\n\t\treturn fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-property\",\n\t\t\t`\"${key}\" can never be read in templates`,\n\t\t);\n\t}\n\treturn fail(\n\t\trun,\n\t\tspan,\n\t\t\"missing-property\",\n\t\t`Property \"${key}\" does not exist on this ${typeName(target)}`,\n\t\tsuggest(String(key), readableNames(target)),\n\t);\n};\n\n/** Whether a chain stops before a member: at an earlier `?.` that stopped, or at this one when its object is null. */\nconst chainStops =\n\t(optional: boolean) =>\n\t(target: unknown): boolean =>\n\t\ttarget === SHORT ||\n\t\t(optional &&\n\t\t\t(target === null || target === undefined || target === MISSING));\n\n/** The items a spread copies, charged against `maxSteps` before they are copied. */\nconst spreadItems = (run: Run, span: Span, value: unknown): unknown[] => {\n\tif (Array.isArray(value)) {\n\t\tlocating(run, span, () => consume(run, value.length));\n\t\treturn value;\n\t}\n\tif (value instanceof Set) {\n\t\tlocating(run, span, () => consume(run, value.size));\n\t\treturn [...value];\n\t}\n\tif (value === null || value === undefined) return [];\n\tthrow fail(\n\t\trun,\n\t\tspan,\n\t\t\"type-error\",\n\t\t`Only arrays and sets can be spread here, but got a ${typeName(value)}`,\n\t);\n};\n\n/** Copies a spread hash's entries, charged against `maxSteps` first. */\nconst copyHash = (\n\trun: Run,\n\tspan: Span,\n\ttarget: Record<string, unknown>,\n\tvalue: unknown,\n) => {\n\tif (value === null || value === undefined) return;\n\tif (isPlainObject(value)) {\n\t\tconst keys = hashKeys(value);\n\t\tlocating(run, span, () => consume(run, keys.length));\n\t\tfor (const key of keys) setOwn(target, key, value[key]);\n\t\treturn;\n\t}\n\tif (value instanceof Map) {\n\t\tconst keys = mapKeys(value);\n\t\tlocating(run, span, () => consume(run, keys.length));\n\t\tfor (const key of keys) setOwn(target, key, value.get(key));\n\t\treturn;\n\t}\n\tthrow fail(\n\t\trun,\n\t\tspan,\n\t\t\"type-error\",\n\t\t`Only hashes can be spread into a hash, but got a ${typeName(value)}`,\n\t);\n};\n\n/**\n * A built-in's options hash of literal keys and values, such as `formatNumber(style: \"currency\")`'s, built once and\n * frozen. The formatting filters cache their work by its identity.\n */\nconst literalHash = (node: Expression): Compiled | null => {\n\tif (node.type !== \"Hash\") return null;\n\tconst result: Record<string, unknown> = {};\n\tfor (const entry of node.entries) {\n\t\tif (entry.type !== \"Property\" || entry.key.type !== \"Literal\") return null;\n\t\tif (entry.value.type !== \"Literal\") return null;\n\t\tsetOwn(result, String(entry.key.value), entry.value.value);\n\t}\n\treturn constant(literalOptions(result));\n};\n\n/**\n * Calls a built-in that never waits with up to four arguments, the filtered or tested value first, without building\n * an argument list. Returns null for more arguments. Matches `locating` for a call that returns no promise.\n */\nconst directCall = (call: Builtin, evs: Ev[], span: Span): Ev | null => {\n\tconst [a, b, c, d] = evs as (Ev | undefined)[];\n\tswitch (evs.length) {\n\t\tcase 0:\n\t\t\treturn (run) => {\n\t\t\t\tstep(run, span);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\tcase 1: {\n\t\t\tconst first = a as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tcase 2: {\n\t\t\tconst first = a as Ev;\n\t\t\tconst second = b as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\tconst y = second(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x, y);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tcase 3: {\n\t\t\tconst first = a as Ev;\n\t\t\tconst second = b as Ev;\n\t\t\tconst third = c as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\tconst y = second(run, scope);\n\t\t\t\tconst z = third(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x, y, z);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tcase 4: {\n\t\t\tconst first = a as Ev;\n\t\t\tconst second = b as Ev;\n\t\t\tconst third = c as Ev;\n\t\t\tconst fourth = d as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\tconst y = second(run, scope);\n\t\t\t\tconst z = third(run, scope);\n\t\t\t\tconst w = fourth(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x, y, z, w);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\n/**\n * Moves named arguments of a built-in into their parameter positions, so `round(precision: 2)` works. Unknown names go into a trailing options hash when the built-in takes one. Problems go to `report`.\n */\nexport const placeArguments = (\n\tentry: Extract<CallableEntry, { kind: \"builtin\" }>,\n\targs: Argument[],\n\tlabel: string,\n\treport: (code: string, message: string, span: Span) => void,\n): (Argument | null)[] => {\n\tif (!args.some((arg) => arg.type === \"Named\")) return args;\n\tconst named = args.filter((arg) => arg.type === \"Named\");\n\tif (args.some((arg) => arg.type === \"Spread\")) {\n\t\treport(\n\t\t\t\"invalid-spread\",\n\t\t\t`${label} cannot take named and spread arguments together`,\n\t\t\t(named[0] as Argument).span,\n\t\t);\n\t\treturn args;\n\t}\n\n\tconst params = entry.params ?? [];\n\tconst slots: (Argument | null)[] = args.filter(\n\t\t(arg) => arg.type === \"Positional\",\n\t);\n\tconst options: HashEntry[] = [];\n\tfor (const arg of named) {\n\t\tif (arg.type !== \"Named\") continue;\n\t\tconst index = params.indexOf(arg.name);\n\t\tif (index >= 0) {\n\t\t\tif (slots[index]) {\n\t\t\t\treport(\n\t\t\t\t\t\"duplicate-argument\",\n\t\t\t\t\t`${label} got \"${arg.name}\" more than once`,\n\t\t\t\t\targ.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\twhile (slots.length < index) slots.push(null);\n\t\t\tslots[index] = { type: \"Positional\", value: arg.value, span: arg.span };\n\t\t} else if (entry.options) {\n\t\t\toptions.push({\n\t\t\t\ttype: \"Property\",\n\t\t\t\tkey: { type: \"Literal\", value: arg.name, span: arg.span },\n\t\t\t\tvalue: arg.value,\n\t\t\t\tspan: arg.span,\n\t\t\t});\n\t\t} else {\n\t\t\treport(\n\t\t\t\t\"unknown-argument\",\n\t\t\t\tparams.length === 0\n\t\t\t\t\t? `${label} takes no named arguments`\n\t\t\t\t\t: `${label} has no parameter \"${arg.name}\"`,\n\t\t\t\targ.span,\n\t\t\t);\n\t\t}\n\t}\n\tif (options.length > 0) {\n\t\tconst index = params.length;\n\t\tif (slots[index]) {\n\t\t\treport(\n\t\t\t\t\"duplicate-argument\",\n\t\t\t\t`${label} got options both as a hash and as named arguments`,\n\t\t\t\t(options[0] as HashEntry).span,\n\t\t\t);\n\t\t}\n\t\twhile (slots.length < index) slots.push(null);\n\t\tconst first = options[0] as HashEntry;\n\t\tconst last = options[options.length - 1] as HashEntry;\n\t\tconst span = { start: first.span.start, end: last.span.end };\n\t\tslots[index] = {\n\t\t\ttype: \"Positional\",\n\t\t\tvalue: { type: \"Hash\", entries: options, span },\n\t\t\tspan,\n\t\t};\n\t}\n\tfor (let i = 0; i < slots.length; i++) slots[i] ??= null;\n\treturn slots;\n};\n\n/** Turns evaluated arguments into the list a function receives: spreads expanded, named arguments as one trailing hash. */\nconst buildArguments = (\n\trun: Run,\n\tspan: Span,\n\tshapes: readonly ArgumentShape[],\n\tvalues: readonly unknown[],\n): unknown[] => {\n\tconst result: unknown[] = [];\n\tlet named: Record<string, unknown> | null = null;\n\tfor (let i = 0; i < shapes.length; i++) {\n\t\tconst shape = shapes[i] as ArgumentShape;\n\t\tconst value = values[i];\n\t\tif (shape.kind === \"Positional\") result.push(value);\n\t\telse if (shape.kind === \"Spread\")\n\t\t\tfor (const item of spreadItems(run, span, value)) result.push(item);\n\t\telse {\n\t\t\tnamed ??= {};\n\t\t\tsetOwn(named, shape.name, value);\n\t\t}\n\t}\n\tif (named) result.push(named);\n\tif (result.length > MAX_ARGUMENTS) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"too-many-arguments\",\n\t\t\t`A call can take at most ${MAX_ARGUMENTS} arguments, but got ${result.length}`,\n\t\t\t\"Pass the array itself instead of spreading it.\",\n\t\t);\n\t}\n\treturn result;\n};\n\n/** A short, fast hash of text as up to 7 base-36 digits: 32-bit FNV-1a. Not for anything that must be secret. */\nconst shortHash = (text: string): string => {\n\tlet hash = 0x811c9dc5;\n\tfor (let i = 0; i < text.length; i++) {\n\t\thash = Math.imul(hash ^ text.charCodeAt(i), 0x01000193);\n\t}\n\treturn (hash >>> 0).toString(36);\n};\n\n/** Normalises a `for` loop's value into parallel arrays of values and keys. */\nexport const loopItems = (\n\trun: Run,\n\tspan: Span,\n\tvalue: unknown,\n\twantKeys: boolean,\n): { values: readonly unknown[]; keys: readonly unknown[] | null } => {\n\tif (value === null || value === undefined) return { values: [], keys: null };\n\tif (Array.isArray(value)) return { values: value, keys: null };\n\tif (isPlainObject(value)) {\n\t\tconst keys = hashKeys(value);\n\t\treturn { values: keys.map((key) => value[key]), keys };\n\t}\n\tif (value instanceof Map) {\n\t\tif (wantKeys) {\n\t\t\tconst keys = mapKeys(value);\n\t\t\treturn { values: keys.map((key) => value.get(key)), keys };\n\t\t}\n\t\t// Without keys, the value of every entry whatever its key, except those under blocked names.\n\t\tconst values: unknown[] = [];\n\t\tfor (const [key, item] of value) {\n\t\t\tif (typeof key !== \"string\" || !BLOCKED_NAMES.has(key)) values.push(item);\n\t\t}\n\t\treturn { values, keys: null };\n\t}\n\tif (typeof value === \"string\" || value instanceof Markup) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"not-iterable\",\n\t\t\t\"Cannot loop over a string\",\n\t\t\t'Use \"split\" first.',\n\t\t);\n\t}\n\tif (\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] ===\n\t\t\t\"function\"\n\t) {\n\t\tconst values: unknown[] = [];\n\t\tconst limit = run.state.maxSteps;\n\t\tfor (const item of value as Iterable<unknown>) {\n\t\t\tvalues.push(item);\n\t\t\tif (values.length > limit) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"limit-steps\",\n\t\t\t\t\t\"Iterable has more items than the step limit\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn { values, keys: null };\n\t}\n\tif (\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { [Symbol.asyncIterator]?: unknown })[\n\t\t\tSymbol.asyncIterator\n\t\t] === \"function\"\n\t) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"not-iterable\",\n\t\t\t\"Cannot loop over an async iterable, because Kiln doesn't wait for one\",\n\t\t\t\"Collect its items into an array in your function first.\",\n\t\t);\n\t}\n\tthrow fail(\n\t\trun,\n\t\tspan,\n\t\t\"not-iterable\",\n\t\t`Cannot loop over a ${typeName(value)}`,\n\t);\n};\n","import { KilnRenderError } from \"../errors.js\";\nimport type { EscapeStrategy } from \"../parser/ast.js\";\nimport {\n\tcontentSets,\n\tmayRunAhead,\n\ttype Pass,\n\tpassesAhead,\n\tpassesFrom,\n\trunAhead,\n} from \"../runtime/ahead.js\";\nimport { escapeHtml, escapeWith } from \"../runtime/escape.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport {\n\tcontains,\n\toperatorFunction,\n\trangeOperator,\n} from \"../runtime/operators.js\";\nimport {\n\tcheckLength,\n\tconsume,\n\tembed,\n\tembedKeyed,\n\tembedScope,\n\tfail,\n\tindentedText,\n\tindentText,\n\tlocate,\n\tendPlace,\n\tmarkCaller,\n\tstartPlace,\n\tstep,\n\tunhold,\n\twrite,\n} from \"../runtime/render.js\";\nimport { childScope, lookup, type Scope } from \"../runtime/scope.js\";\nimport {\n\tblockScope,\n\ttype Builtin,\n\ttype CompiledTemplate,\n\ttype EnvironmentCore,\n\tfillScope,\n\ttype Out,\n\ttype Run,\n\ttype SlotFill,\n\ttype Stmt,\n} from \"../runtime/types.js\";\nimport {\n\tequals,\n\tisEmpty,\n\tliteralOptions,\n\tMISSING,\n\ttoNumber,\n\ttoStr,\n\ttruthy,\n} from \"../runtime/values.js\";\nimport type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport {\n\tassign,\n\tcheckValue,\n\tcompileTemplate,\n\temitter,\n\ttype GeneratedRuns,\n\tloopItems,\n\treadingLabel,\n\treadMember,\n\tSHORT,\n\tundefinedVariable,\n} from \"./compiler.js\";\n\n/** Changes whenever generated code or the runtime it calls changes shape, so old modules fail loudly. */\nexport const PRECOMPILED_VERSION = 4;\n\n/**\n * A template compiled to JavaScript at build time, the default export of a module `precompile` wrote. Loaders return\n * it in place of the template's source.\n */\nexport type PrecompiledTemplate = {\n\t/** The version of the generated code. */\n\treadonly kiln: number;\n\t/** The `autoescape` option the template was compiled with. */\n\treadonly autoescape: EscapeStrategy | false;\n\t/** The template's source. Kiln still compiles it, for everything the generated code leaves out. */\n\treadonly source: string;\n\t/** Creates the generated statements, given Kiln's runtime. Only Kiln calls it. */\n\treadonly create: (runtime: never) => unknown;\n};\n\n/** Generated statements: where each run of statements starts and ends in the source, and the code that replaces it. */\ntype GeneratedList = readonly (readonly [\n\tstart: number,\n\tend: number,\n\trun: Stmt,\n])[];\n\n/** Checks for a precompiled module's default export, as opposed to template source. */\nexport const isPrecompiled = (value: unknown): value is PrecompiledTemplate =>\n\ttypeof value === \"object\" &&\n\tvalue !== null &&\n\t\"kiln\" in value &&\n\t\"create\" in value;\n\nconst mismatch = (name: string, detail: string): KilnRenderError =>\n\tnew KilnRenderError(\n\t\t\"precompiled-mismatch\",\n\t\t`Precompiled template \"${name}\" ${detail}. Precompile it again`,\n\t\tname,\n\t);\n\n/** Compiles a precompiled template: its source, with the generated statements in place of the ones they cover. */\nexport const compilePrecompiled = (\n\tenv: EnvironmentCore,\n\tname: string,\n\ttemplate: PrecompiledTemplate,\n): CompiledTemplate => {\n\tif (template.kiln !== PRECOMPILED_VERSION) {\n\t\tthrow mismatch(name, \"was made by another version of Kiln\");\n\t}\n\tif (template.autoescape !== env.autoescape) {\n\t\tthrow mismatch(name, 'was compiled with another \"autoescape\" option');\n\t}\n\tconst runs = new Map<number, { end: number; run: Stmt }>();\n\tconst create = template.create as (\n\t\truntime: PrecompiledRuntime,\n\t) => GeneratedList;\n\tfor (const [start, end, run] of create(runtimeFor(env, name))) {\n\t\truns.set(start, { end, run });\n\t}\n\treturn compileTemplate(env, name, template.source, runs as GeneratedRuns);\n};\n\n/**\n * What generated code calls. Every rule templates follow, such as how properties are read and values printed, lives\n * here or in the closure compiler, so both run the same code.\n */\nexport type PrecompiledRuntime = typeof runtime &\n\tReturnType<typeof builtinsFor>;\n\n// Built-ins are looked up per template, so a mismatch names the template.\nconst runtimeFor = (\n\tenv: EnvironmentCore,\n\tname: string,\n): PrecompiledRuntime => ({\n\t...runtime,\n\t...builtinsFor(env, name),\n});\n\nconst builtinsFor = (env: EnvironmentCore, template: string) => {\n\tconst builtin = (\n\t\tkind: \"filter\" | \"test\" | \"function\",\n\t\tentries: EnvironmentCore[\"filters\"],\n\t\tname: string,\n\t): Builtin => {\n\t\tconst entry = entries.get(name);\n\t\tif (entry?.kind !== \"builtin\") {\n\t\t\tthrow mismatch(\n\t\t\t\ttemplate,\n\t\t\t\t`uses the built-in ${kind} \"${name}\", which this environment ${entry ? \"replaces\" : \"does not have\"}`,\n\t\t\t);\n\t\t}\n\t\treturn entry.call;\n\t};\n\treturn {\n\t\tfilter: (name: string) => builtin(\"filter\", env.filters, name),\n\t\ttest: (name: string) => builtin(\"test\", env.tests, name),\n\t\tfn: (name: string) => builtin(\"function\", env.functions, name),\n\t\t/** One of your functions or filters, with the label its errors use. */\n\t\thost: (kind: \"function\" | \"filter\", name: string): HostCall => {\n\t\t\tconst entry = (kind === \"filter\" ? env.filters : env.functions).get(name);\n\t\t\tif (entry?.kind !== \"host\") {\n\t\t\t\tthrow mismatch(\n\t\t\t\t\ttemplate,\n\t\t\t\t\t`uses your ${kind} \"${name}\", which this environment ${entry ? \"has as a built-in\" : \"does not have\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcall: entry.call,\n\t\t\t\trender: entry.render,\n\t\t\t\tlabel: `${kind === \"filter\" ? \"Filter\" : \"Function\"} \"${name}\"`,\n\t\t\t};\n\t\t},\n\t};\n};\n\nconst joinOperator = operatorFunction(\"~\");\n\n/**\n * Runs generated code that may wait: waits for each promise it yields, and sends back the result, or throws the\n * rejection in at the `yield`, where generated code locates it.\n */\nconst drive = (\n\titerator: Iterator<unknown, void, unknown>,\n\tvalue?: unknown,\n): void | Promise<void> => resume(iterator, iterator.next(value));\n\nconst resume = (\n\titerator: Iterator<unknown, void, unknown>,\n\tresult: IteratorResult<unknown, void>,\n): void | Promise<void> => {\n\tif (result.done) return;\n\treturn (result.value as Promise<unknown>).then(\n\t\t(resolved) => resume(iterator, iterator.next(unhold(resolved))),\n\t\t(error: unknown) =>\n\t\t\tresume(\n\t\t\t\titerator,\n\t\t\t\t(iterator.throw as (error: unknown) => IteratorResult<unknown, void>)(\n\t\t\t\t\terror,\n\t\t\t\t),\n\t\t\t),\n\t);\n};\n\nconst NOTHING = (): void => {};\n\n/** What a generated loop that pauses inside a pass calls once the pass is done, after `startAhead`. */\ntype Joining = {\n\t/** The pass is done: joins the passes that ran ahead. */\n\tjoin: () => Promise<void>;\n\t/** The pass failed: lets the passes ahead finish, and waits for them without failing. */\n\tfail: (error: unknown) => Promise<void>;\n};\n\n/** The names a `props` tag declares, and the last frozen list of passed names found to fit them. */\ntype DeclaredProps = {\n\tnames: ReadonlySet<string>;\n\taccepted: readonly string[] | null;\n};\n\n/** One of your functions or filters, as generated code calls it. */\ntype HostCall = {\n\tcall: (...args: unknown[]) => unknown;\n\t/** Made with `withRender`, so it receives `RenderInfo` first. */\n\trender: boolean;\n\tlabel: string;\n};\n\nconst emitters = {\n\thtml: emitter(\"html\"),\n\tattr: emitter(\"attr\"),\n\tjs: emitter(\"js\"),\n\tcss: emitter(\"css\"),\n\turl: emitter(\"url\"),\n\tnone: emitter(false),\n};\n\n/** The helpers generated code calls. Built-ins are added per template by `runtimeFor`. */\nconst runtime = {\n\tMISSING,\n\tSHORT,\n\tobjectPrototype: Object.prototype,\n\tgetPrototypeOf: Object.getPrototypeOf,\n\thasOwn: Object.hasOwn,\n\tstep,\n\t/** Stops a render that counted more steps than `maxSteps`, as `step` does. */\n\tstepLimit: (run: Run, span: Span): never => {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-steps\",\n\t\t\t`Render stopped after ${run.state.maxSteps} steps`,\n\t\t);\n\t},\n\t/** Refuses a range longer than the step limit, as `range` does. */\n\trangeLimit: (run: Run, span: Span, length: number): never => {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-steps\",\n\t\t\t`Range of ${length} items is larger than the step limit`,\n\t\t);\n\t},\n\t/** Stops a render whose abort signal fired, as `step` does. */\n\taborted: (run: Run, span: Span): never => {\n\t\tthrow fail(run, span, \"aborted\", \"Render was aborted\");\n\t},\n\twrite,\n\tdrive,\n\tunhold,\n\t/**\n\t * Continues a generated run after a statement that returned a promise, `pending`: the rest of the run starts at\n\t * once, ahead of it, when it may, or else once the statement is done. `inline` is `out.inline` from where the\n\t * function started. See `runAhead`.\n\t */\n\trestAhead: (\n\t\trun: Run,\n\t\tout: Out,\n\t\tpending: Promise<void>,\n\t\tinline: boolean,\n\t\tindent: string,\n\t\trest: (run: Run, out: Out) => void | Promise<void>,\n\t\tspan: Span,\n\t): Promise<void> =>\n\t\tmayRunAhead(run.state, inline)\n\t\t\t? runAhead(run, out, pending, indent, rest, span)\n\t\t\t: pending.then(() => rest(run, out)),\n\tcontentSets,\n\t/**\n\t * Continues a generated loop after a pass that returned a promise, `pending`: passes `from` to `to` run one at a\n\t * time with `pass`, ahead of it when they may, see `passesAhead`. `sets` are the variables the loop's body sets,\n\t * and `elsewhere` whether it places content from elsewhere.\n\t */\n\tpassAhead: (\n\t\trun: Run,\n\t\tscope: Scope,\n\t\tout: Out,\n\t\tpending: Promise<void>,\n\t\tinline: boolean,\n\t\tindent: string,\n\t\tsets: readonly string[],\n\t\telsewhere: boolean,\n\t\tfrom: number,\n\t\tto: number,\n\t\tpass: Pass,\n\t\tspan: Span,\n\t): Promise<void> =>\n\t\tpassesFrom(\n\t\t\trun,\n\t\t\tout,\n\t\t\tpending,\n\t\t\tinline,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tindent,\n\t\t\tpass,\n\t\t\tspan,\n\t\t\tpassesAhead(run, scope, sets, elsewhere),\n\t\t),\n\t/**\n\t * For a generated loop that pauses inside a pass: starts passes `from` to `to` ahead of it when they may, and returns\n\t * what the loop calls once the pass is done. Returns null when they may not, and the loop carries on as usual.\n\t */\n\tstartAhead: (\n\t\trun: Run,\n\t\tscope: Scope,\n\t\tout: Out,\n\t\tinline: boolean,\n\t\tindent: string,\n\t\tsets: readonly string[],\n\t\telsewhere: boolean,\n\t\tfrom: number,\n\t\tto: number,\n\t\tpass: Pass,\n\t\tspan: Span,\n\t): Joining | null => {\n\t\tif (\n\t\t\t!mayRunAhead(run.state, inline) ||\n\t\t\t!passesAhead(run, scope, sets, elsewhere)\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tlet done = NOTHING;\n\t\tlet failed: (error: unknown) => void = NOTHING;\n\t\tconst pending = new Promise<void>((resolve, reject) => {\n\t\t\tdone = resolve;\n\t\t\tfailed = reject;\n\t\t});\n\t\tconst joined = passesFrom(\n\t\t\trun,\n\t\t\tout,\n\t\t\tpending,\n\t\t\tfalse,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tindent,\n\t\t\tpass,\n\t\t\tspan,\n\t\t\ttrue,\n\t\t);\n\t\treturn {\n\t\t\tjoin: () => {\n\t\t\t\tdone();\n\t\t\t\treturn joined;\n\t\t\t},\n\t\t\tfail: (error) => {\n\t\t\t\tfailed(error);\n\t\t\t\treturn joined.then(NOTHING, NOTHING);\n\t\t\t},\n\t\t};\n\t},\n\tstartPlace,\n\tendPlace,\n\tindentText,\n\tindentedText,\n\tembed,\n\tembedScope,\n\tembedKeyed,\n\tchildScope,\n\ttruthy,\n\tisEmpty,\n\tequals,\n\tescapeHtml,\n\treadMember,\n\tloopItems,\n\tcheckValue,\n\tassign,\n\t/**\n\t * Calls one of your functions or filters as the closures do. Errors it throws are located here, and a promise it\n\t * returns is located where generated code waits for it, with `hostError`. A thenable becomes a promise, and a\n\t * promise tells a streamed render it is waiting.\n\t */\n\tcallHost: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\thost: HostCall,\n\t\targs: unknown[],\n\t): unknown => {\n\t\tlet value: unknown;\n\t\ttry {\n\t\t\tvalue = host.render ? host.call(run.info, ...args) : host.call(...args);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error, host.label);\n\t\t}\n\t\tif (value instanceof Promise) {\n\t\t\trun.state.stream?.wait();\n\t\t\treturn value;\n\t\t}\n\t\tif (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\ttypeof (value as { then?: unknown }).then === \"function\"\n\t\t) {\n\t\t\trun.state.stream?.wait();\n\t\t\treturn Promise.resolve(value);\n\t\t}\n\t\treturn value;\n\t},\n\t/**\n\t * Whether a block that `placeBlock` placed may have set a variable. Any version of any block may run inside it,\n\t * through `parent()` and `block()`, so this is whether any of them sets one. Templates define few blocks.\n\t */\n\tblockSets: (run: Run): boolean => {\n\t\tfor (const entries of run.blocks.values()) {\n\t\t\tfor (const entry of entries) if (entry.def.sets) return true;\n\t\t}\n\t\treturn false;\n\t},\n\t/**\n\t * Locates an error thrown in generated code at the last property it read inline, where a getter in your data can\n\t * throw. Every other error is located already.\n\t */\n\treadError: (\n\t\trun: Run,\n\t\tat: readonly [Span, string] | null,\n\t\terror: unknown,\n\t): unknown =>\n\t\tat === null ? error : locate(run, at[0], error, readingLabel(at[1])),\n\t/** Locates the rejection of a promise one of your functions or filters returned. */\n\thostError: (run: Run, span: Span, host: HostCall, error: unknown) =>\n\t\tlocate(run, span, error, host.label),\n\t/** Whether a value is a plain object, whose own properties templates may read directly. */\n\tplain: (value: unknown): boolean => {\n\t\tif (typeof value !== \"object\" || value === null) return false;\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\treturn proto === Object.prototype || proto === null;\n\t},\n\toperator: operatorFunction,\n\toptions: literalOptions,\n\t/** Spans from a flat list of start and end offsets. */\n\tspans: (offsets: readonly number[]): Span[] => {\n\t\tconst spans: Span[] = [];\n\t\tfor (let i = 0; i < offsets.length; i += 2) {\n\t\t\tspans.push({\n\t\t\t\tstart: offsets[i] as number,\n\t\t\t\tend: offsets[i + 1] as number,\n\t\t\t});\n\t\t}\n\t\treturn spans;\n\t},\n\t/** A variable from outside the generated code. Missing variables fail in strict mode and read as null otherwise. */\n\tname: (run: Run, span: Span, scope: Scope, name: string): unknown => {\n\t\tconst value = lookup(scope, name);\n\t\tif (value === undefined) {\n\t\t\tif (run.state.env.strict) {\n\t\t\t\tthrow undefinedVariable(run, span, name, scope);\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn typeof value === \"function\"\n\t\t\t? checkValue(run, span, value, name)\n\t\t\t: value;\n\t},\n\t/** A variable where a missing one is allowed, such as the input of `default`. */\n\tguardedName: (run: Run, span: Span, scope: Scope, name: string): unknown => {\n\t\tconst value = lookup(scope, name);\n\t\treturn value === undefined ? MISSING : checkValue(run, span, value, name);\n\t},\n\t/** Prints a value with an escaping strategy, or none. */\n\tprint: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tvalue: unknown,\n\t\tstrategy: keyof typeof emitters,\n\t): string => {\n\t\ttry {\n\t\t\treturn emitters[strategy](value);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall0: (run: Run, span: Span, fn: Builtin): unknown => {\n\t\ttry {\n\t\t\treturn fn(run);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall1: (run: Run, span: Span, fn: Builtin, a: unknown): unknown => {\n\t\ttry {\n\t\t\treturn fn(run, a);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall2: (run: Run, span: Span, fn: Builtin, a: unknown, b: unknown) => {\n\t\ttry {\n\t\t\treturn fn(run, a, b);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall3: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tfn: Builtin,\n\t\ta: unknown,\n\t\tb: unknown,\n\t\tc: unknown,\n\t): unknown => {\n\t\ttry {\n\t\t\treturn fn(run, a, b, c);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall4: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tfn: Builtin,\n\t\ta: unknown,\n\t\tb: unknown,\n\t\tc: unknown,\n\t\td: unknown,\n\t): unknown => {\n\t\ttry {\n\t\t\treturn fn(run, a, b, c, d);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** A binary operator without short-circuit behaviour. */\n\tbinary: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tapply: (left: unknown, right: unknown) => unknown,\n\t\tleft: unknown,\n\t\tright: unknown,\n\t): unknown => {\n\t\ttry {\n\t\t\treturn apply(left, right);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** `in`, which charges for the items it searches. */\n\tcontains: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tneedle: unknown,\n\t\thaystack: unknown,\n\t): boolean => {\n\t\ttry {\n\t\t\treturn contains(needle, haystack, (count) => consume(run, count));\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** `~`, whose result may not be longer than the output limit. */\n\tconcat: (run: Run, span: Span, left: unknown, right: unknown): string => {\n\t\ttry {\n\t\t\treturn checkLength(run, joinOperator(left, right) as string);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\trange: (run: Run, span: Span, left: unknown, right: unknown): number[] => {\n\t\ttry {\n\t\t\tconst items = rangeOperator(left, right, run.state.maxSteps);\n\t\t\tconsume(run, items.length);\n\t\t\treturn items;\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** Unary `-` and `+` on a value that is not a number, which fails. */\n\ttoNumber: (run: Run, span: Span, value: unknown, operator: string) => {\n\t\ttry {\n\t\t\treturn toNumber(value, operator);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** One part of an interpolated string. */\n\tstr: (run: Run, span: Span, value: unknown): string => {\n\t\tif (typeof value === \"string\") return value;\n\t\ttry {\n\t\t\treturn toStr(value);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** An interpolated string, which may not be longer than the output limit. */\n\tjoined: (run: Run, span: Span, text: string): string => {\n\t\ttry {\n\t\t\treturn checkLength(run, text);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** The `raw` filter. */\n\traw: (run: Run, span: Span, value: unknown, strategy: EscapeStrategy) => {\n\t\tif (value instanceof Markup) {\n\t\t\treturn value.strategy === strategy\n\t\t\t\t? value\n\t\t\t\t: new Markup(value.value, strategy);\n\t\t}\n\t\treturn new Markup(runtime.str(run, span, value), strategy);\n\t},\n\t/** The `escape` filter, with a strategy known to be valid. Stops once the escaped text passes the output limit. */\n\tescape: (run: Run, span: Span, value: unknown, strategy: EscapeStrategy) => {\n\t\tif (value instanceof Markup && value.strategy === strategy) return value;\n\t\tconst text = runtime.str(run, span, value);\n\t\ttry {\n\t\t\treturn new Markup(\n\t\t\t\tescapeWith(text, strategy, run.state.maxSize),\n\t\t\t\tstrategy,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** Renders a component's fill for a slot, recording the slot's location on errors. */\n\tfillSlot: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tfill: SlotFill,\n\t\tout: Out,\n\t): void | Promise<void> => {\n\t\ttry {\n\t\t\t// The fill renders in the capture the slot is in, such as a cached section.\n\t\t\tconst result = fill.body(\n\t\t\t\tfill.run.within(run.capture, run.blockDepth),\n\t\t\t\tfillScope(fill, run),\n\t\t\t\tout,\n\t\t\t);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow markCaller(run, span, error);\n\t\t}\n\t},\n\t/** Places a block: the most derived definition, which may come from a child template. */\n\tplaceBlock: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tname: string,\n\t\tscope: Scope,\n\t\tout: Out,\n\t): void | Promise<void> => {\n\t\tconst entry = run.blocks.get(name)?.[0];\n\t\tif (!entry) return;\n\t\t// The block renders in the capture it is placed in, such as a cached section.\n\t\tconst blockRun = entry.run.within(run.capture, run.blockDepth);\n\t\tif (entry.run.template === run.template) {\n\t\t\treturn entry.def.body(blockRun, blockScope(entry.def, scope), out);\n\t\t}\n\t\t// A block defined in another template records where it was placed.\n\t\ttry {\n\t\t\tconst result = entry.def.body(\n\t\t\t\tblockRun,\n\t\t\t\tblockScope(entry.def, scope),\n\t\t\t\tout,\n\t\t\t);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow markCaller(run, span, error);\n\t\t}\n\t},\n\t/**\n\t * In strict mode, fails when the caller passed a variable `props` doesn't declare. Callers that make the scope\n\t * themselves pass the same frozen list each time, so the last list that passed is remembered.\n\t */\n\tcheckPassed: (run: Run, span: Span, declared: DeclaredProps) => {\n\t\tconst passed = run.passed;\n\t\tif (passed === null || passed === declared.accepted) return;\n\t\tif (!run.state.env.strict) return;\n\t\tfor (let i = 0; i < passed.length; i++) {\n\t\t\tconst key = passed[i] as string;\n\t\t\tif (!declared.names.has(key) && key !== \"slots\") {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"unknown-prop\",\n\t\t\t\t\t`\"${key}\" was passed to ${run.template.name}, which does not declare it in \"props\"`,\n\t\t\t\t\tsuggest(key, declared.names),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (Object.isFrozen(passed)) declared.accepted = passed;\n\t},\n\t/** The names a `props` tag declares, for `checkPassed`. */\n\tdeclared: (names: string[]): DeclaredProps => ({\n\t\tnames: new Set(names),\n\t\taccepted: null,\n\t}),\n\t/** A required prop the caller didn't pass: fails in strict mode, and is null otherwise. */\n\tmissingProp: (run: Run, span: Span, name: string): null => {\n\t\tif (run.state.env.strict) {\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"missing-prop\",\n\t\t\t\t`Required prop \"${name}\" was not passed to ${run.template.name}`,\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t},\n\t/** The `loop` hash, for templates that use it whole. */\n\tloop: (index: number, length: number) => ({\n\t\tindex: index + 1,\n\t\tindex0: index,\n\t\trevIndex: length - index,\n\t\trevIndex0: length - index - 1,\n\t\tfirst: index === 0,\n\t\tlast: index === length - 1,\n\t\tlength,\n\t}),\n};\n","import {\n\ttype Argument,\n\tDEFAULT_SLOT,\n\tESCAPE_STRATEGIES,\n\ttype EscapeStrategy,\n\ttype Expression,\n\ttype Statement,\n\ttype TemplateNode,\n} from \"../parser/ast.js\";\nimport type { EnvironmentCore } from \"../runtime/types.js\";\nimport { BLOCKED_NAMES } from \"../runtime/values.js\";\nimport type { Span } from \"../source.js\";\nimport {\n\tcontainsNode,\n\temitter,\n\tmayWrite,\n\tplaceArguments,\n\tsetsVariables,\n} from \"./compiler.js\";\nimport { effectsOf, planOf } from \"./effects.js\";\nimport { PRECOMPILED_VERSION } from \"./precompiled.js\";\n\n/**\n * Generates JavaScript for a template that compiled without problems, for `precompile`.\n *\n * Runs of statements become functions: text, outputs, `if`, `for`, `set`, `autoescape`, untyped `props` without a\n * rest prop, includes, components, slots and block placements, with expressions that use variables, literals,\n * operators and built-in functions, filters and tests. Your own functions and filters, which may return promises, are generated when a call\n * is a whole `set` value, loop or output. Code that may wait continues in another function, or pauses as a generator,\n * only when a promise comes back; see `#function`. Everything else, such as macros and arrow functions, is left to\n * the closure compiler, which compiles the template's source as usual and puts the generated functions in place of\n * the runs they cover.\n *\n * Generated code calls the helpers in `precompiled.ts` for every rule templates follow, so it behaves as the closures\n * do. Nothing from the template reaches the generated source except through `JSON.stringify`, a strict identifier\n * check or a number, so a template cannot inject code.\n */\nexport const generateModule = (\n\tenv: EnvironmentCore,\n\tast: TemplateNode,\n\tsource: string,\n): string => new Generator(env, ast).module(source);\n\n/** Thrown for anything the generator leaves to the closure compiler. */\nclass Unsupported extends Error {}\n\nconst unsupported = (): never => {\n\tthrow new Unsupported();\n};\n\n/**\n * What a name means inside generated code: a JavaScript local, or a loop's `loop` hash. A local has a flag for\n * whether it holds a plain object, set once when it is bound, so reading its properties skips that check.\n */\ntype Binding =\n\t| { kind: \"value\"; js: string; plain: string }\n\t| { kind: \"loop\"; index: string; length: string };\n\n/** A variable from outside generated code, looked up once, and whether it is a plain object. */\ntype Cached = { value: string; plain: string };\n\ntype Context = {\n\tbindings: ReadonlyMap<string, Binding>;\n\tstrategy: EscapeStrategy | false;\n\t/** Inside a generated loop, whose variables are JavaScript locals rather than scope variables. */\n\tinLoop: boolean;\n\t/** At the top level of a run, where a wait can end the function and continue in the next. See `#function`. */\n\ttop: boolean;\n\t/**\n\t * At the top level of a loop function's pass, where a call to your function can end the function too, and the\n\t * pass continue with its value in the next. See `#loopFunction`.\n\t */\n\tpass: boolean;\n\t/** The JavaScript name of the scope variables are looked up and set in: the function's, or a loop pass's. */\n\tscope: string;\n};\n\n/** One generated function: a run, or a component's fill. */\ntype FunctionState = {\n\t/** Temporaries it declares. */\n\ttemps: number;\n\t/**\n\t * Variables from outside generated code, each looked up once. Code that may change a variable, such as `set`, a\n\t * block or a component's fills, forgets the lookups it may have changed.\n\t */\n\tvariables: Map<string, Cached>;\n\t/** Plain-object flags of variables that property reads use. Only these are set; see `PLAIN`. */\n\tplainUsed: Set<string>;\n\t/** It may wait for a promise. */\n\twaits: boolean;\n\t/** It may wait somewhere other than at the end of a top-level statement, such as in a loop, so it is a generator. */\n\twaitsInside: boolean;\n\t/** Waits it has somewhere a run can't continue from, such as inside an `if`. See `#list`. */\n\tinner: number;\n\t/** Top-level waits that start the rest of the run ahead of them. See `#list`. */\n\taheadWaits: number;\n\t/**\n\t * It reads properties inline, where a getter in your data may throw. Each read puts its place in `at`, so the\n\t * function can locate the error; see `#guard`.\n\t */\n\treads: boolean;\n};\n\nconst newFunction = (): FunctionState => ({\n\ttemps: 0,\n\tvariables: new Map(),\n\tplainUsed: new Set(),\n\twaits: false,\n\twaitsInside: false,\n\tinner: 0,\n\taheadWaits: 0,\n\treads: false,\n});\n\n/**\n * Stands for a wait in generated lines until `#function` knows whether it yields or continues in a new function.\n *\n * Markers use control characters because `JSON.stringify` escapes them, so text from a template never contains one.\n */\nconst WAIT = \"\\u0000wait \";\n\n// oxlint-disable-next-line no-control-regex -- matches the marker, see `WAIT`\nconst WAIT_LINE = /^(\\t*)\\u0000wait (t\\d+)( ahead| guarded)?$/;\n\n/**\n * Stands for waiting for a call to one of your functions at the top of a loop function's pass, `\\u0000value t S X`:\n * the call's result, its span and the function. When the result is a promise, the pass continues in another function\n * with its value. See `#loopFunction`.\n */\nconst VALUE = \"\\u0000value \";\n\n// oxlint-disable-next-line no-control-regex -- matches the marker, see `WAIT`\nconst VALUE_LINE = /^(\\t*)\\u0000value (t\\d+) (S\\[\\d+\\]) (X\\d+)$/;\n\n/** Marks a wait whose statement lets the rest of the run start ahead of it, in `WAIT` lines. See `#list`. */\nconst AHEAD = \" ahead\";\n\n/** Marks a wait that lets the rest of the run start ahead of it unless the render's blocks or fills set variables. */\nconst GUARDED = \" guarded\";\n\n/**\n * Stands for starting the passes after the current one, where a loop that pauses inside its passes is about to wait.\n * `#loopGenerator` writes it out, and other functions drop it.\n */\nconst FORK = \"\\u0003fork\";\n\n/**\n * Stands for setting a variable's plain-object flag, `\\u0001flag:value\\u0001`, until `#function` knows whether any\n * property read uses the flag. It becomes `, flag = plain(value)` or nothing.\n */\n// oxlint-disable-next-line no-control-regex -- matches the marker, see `WAIT`\nconst PLAIN = /\\u0001(f\\d+):([\\w$]+)\\u0001/g;\n\n/**\n * Stands for forgetting every variable lookup, until the function's lookups are all known: in a loop, a lookup made\n * later in the pass is cached by the next pass too. `#function` writes it out.\n */\nconst FORGET_ALL = \"\\u0002forget\";\n\nconst setPlain = (flag: string, value: string) =>\n\t`\\u0001${flag}:${value}\\u0001`;\n\n/** The helpers generated code takes from the runtime. See `precompiled.ts`. */\nconst HELPERS = [\n\t\"MISSING\",\n\t\"SHORT\",\n\t\"objectPrototype\",\n\t\"getPrototypeOf\",\n\t\"hasOwn\",\n\t\"step\",\n\t\"stepLimit\",\n\t\"rangeLimit\",\n\t\"aborted\",\n\t\"write\",\n\t\"drive\",\n\t\"unhold\",\n\t\"restAhead\",\n\t\"contentSets\",\n\t\"passAhead\",\n\t\"startAhead\",\n\t\"startPlace\",\n\t\"endPlace\",\n\t\"indentText\",\n\t\"indentedText\",\n\t\"truthy\",\n\t\"isEmpty\",\n\t\"equals\",\n\t\"escapeHtml\",\n\t\"readMember\",\n\t\"loopItems\",\n\t\"checkValue\",\n\t\"plain\",\n\t\"name\",\n\t\"guardedName\",\n\t\"print\",\n\t\"call0\",\n\t\"call1\",\n\t\"call2\",\n\t\"call3\",\n\t\"call4\",\n\t\"binary\",\n\t\"contains\",\n\t\"concat\",\n\t\"range\",\n\t\"toNumber\",\n\t\"str\",\n\t\"joined\",\n\t\"raw\",\n\t\"escape\",\n\t\"loop\",\n\t\"embed\",\n\t\"embedScope\",\n\t\"embedKeyed\",\n\t\"assign\",\n\t\"callHost\",\n\t\"hostError\",\n\t\"childScope\",\n\t\"fillSlot\",\n\t\"placeBlock\",\n\t\"checkPassed\",\n\t\"missingProp\",\n\t\"readError\",\n\t\"blockSets\",\n];\n\n/** Fields of the `loop` hash, as JavaScript over the loop's index and length. */\nconst LOOP_FIELDS: Record<string, (index: string, length: string) => string> = {\n\tindex: (i) => `(${i} + 1)`,\n\tindex0: (i) => i,\n\trevIndex: (i, n) => `(${n} - ${i})`,\n\trevIndex0: (i, n) => `(${n} - ${i} - 1)`,\n\tfirst: (i) => `(${i} === 0)`,\n\tlast: (i, n) => `(${i} === ${n} - 1)`,\n\tlength: (_i, n) => n,\n};\n\n/** Operators with a JavaScript equivalent when both sides are numbers. */\nconst NUMBER_OPERATORS = new Set([\n\t\"<\",\n\t\">\",\n\t\"<=\",\n\t\">=\",\n\t\"+\",\n\t\"-\",\n\t\"*\",\n\t\"/\",\n\t\"%\",\n]);\n\n/** Names of a generated loop's locals. */\ntype LoopNames = {\n\tid: number;\n\tspan: string;\n\t/** For a loop whose body uses `set`: the scope each pass makes, as the closures do, and the scope it is made in. */\n\tscope: string | null;\n\touter: string;\n\t/** Variables the body sets, whose lookups each pass forgets. */\n\tsets: string[];\n\tvalues: string;\n\tlength: string;\n\tkeys: string;\n\tindex: string;\n\tvalue: string;\n\tkey: string;\n\thasKeys: boolean;\n};\n\n/** The ends of a range of integer literals, such as `1..5` or `-2..2`, or null for any other expression. */\nconst literalRange = (\n\tnode: Expression,\n): { from: number; to: number } | null => {\n\tif (node.type !== \"Binary\" || node.operator !== \"..\") return null;\n\tconst integer = (side: Expression): number | null => {\n\t\tif (side.type === \"Literal\") {\n\t\t\treturn Number.isInteger(side.value) ? (side.value as number) : null;\n\t\t}\n\t\tif (\n\t\t\tside.type === \"Unary\" &&\n\t\t\tside.operator === \"-\" &&\n\t\t\tside.operand.type === \"Literal\" &&\n\t\t\tNumber.isInteger(side.operand.value)\n\t\t) {\n\t\t\treturn -(side.operand.value as number);\n\t\t}\n\t\treturn null;\n\t};\n\tconst from = integer(node.left);\n\tconst to = integer(node.right);\n\treturn from === null || to === null ? null : { from, to };\n};\n\n/** A call to one of your functions or filters. See `#isHostCall`. */\ntype HostCallNode =\n\t| (Extract<Expression, { type: \"Call\" }> & {\n\t\t\tcallee: Extract<Expression, { type: \"Name\" }>;\n\t })\n\t| Extract<Expression, { type: \"Filter\" }>;\n\n/** An include's or component's template name in generated code. See `#target`. */\ntype TemplateTarget =\n\t| { kind: \"value\"; js: string }\n\t| {\n\t\t\tkind: \"keyed\";\n\t\t\tprefix: string;\n\t\t\tkey: string;\n\t\t\tjoined: string;\n\t\t\tnameSpan: string;\n\t };\n\n/** A `with` value whose keys are known, or none, so generated code makes the template's scope itself. */\nconst isKnownWith = (node: Expression | null): boolean =>\n\tnode === null ||\n\t(node.type === \"Hash\" &&\n\t\tnode.entries.every(\n\t\t\t(entry) =>\n\t\t\t\tentry.type === \"Property\" &&\n\t\t\t\tentry.key.type === \"Literal\" &&\n\t\t\t\t!BLOCKED_NAMES.has(String(entry.key.value)),\n\t\t));\n\n/** Names that `set` statements set, directly or inside other statements. */\nconst setsIn = (\n\tstatements: Statement[],\n\tnames = new Set<string>(),\n): Set<string> => {\n\tfor (const statement of statements) {\n\t\tif (statement.type === \"Set\") names.add(statement.name);\n\t\telse if (statement.type === \"If\") {\n\t\t\tfor (const branch of statement.branches) setsIn(branch.body, names);\n\t\t\tsetsIn(statement.alternate ?? [], names);\n\t\t} else if (statement.type === \"For\") {\n\t\t\tsetsIn(statement.body, names);\n\t\t\tsetsIn(statement.alternate ?? [], names);\n\t\t} else if (statement.type === \"Autoescape\" || statement.type === \"Slot\") {\n\t\t\tsetsIn(statement.body, names);\n\t\t}\n\t}\n\treturn names;\n};\n\n/** Characters of text a loop gathers before writing them out. */\nconst FLUSH_AT = 4096;\n\n/** Longest `else if` chain written as one. Longer chains become a flat labelled block. */\nconst MAX_ELSE_IF = 16;\n\n/** Deepest expression the generator writes. Deeper ones stay with the closure compiler. */\nconst MAX_DEPTH = 100;\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\n/** A literal as JavaScript. */\nconst literal = (value: unknown): string => {\n\tif (value === null) return \"null\";\n\tif (typeof value === \"string\") return JSON.stringify(value);\n\tif (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n\tif (typeof value === \"number\" && Number.isFinite(value)) {\n\t\treturn Object.is(value, -0) ? \"-0\" : String(value);\n\t}\n\treturn unsupported();\n};\n\nconst BOOLEAN_OPERATORS = new Set([\n\t\"and\",\n\t\"or\",\n\t\"==\",\n\t\"!=\",\n\t\"<\",\n\t\">\",\n\t\"<=\",\n\t\">=\",\n\t\"in\",\n\t\"not in\",\n\t\"starts with\",\n\t\"ends with\",\n]);\n\n/** Whether generated code for an expression is always a JavaScript boolean. */\nconst isBoolean = (node: Expression, context: Context): boolean => {\n\tswitch (node.type) {\n\t\tcase \"Literal\":\n\t\t\treturn typeof node.value === \"boolean\";\n\t\tcase \"Binary\":\n\t\t\treturn BOOLEAN_OPERATORS.has(node.operator);\n\t\tcase \"Unary\":\n\t\t\treturn node.operator === \"not\";\n\t\tcase \"Test\":\n\t\t\treturn true;\n\t\tcase \"Member\":\n\t\t\treturn (\n\t\t\t\tnode.object.type === \"Name\" &&\n\t\t\t\tcontext.bindings.get(node.object.name)?.kind === \"loop\" &&\n\t\t\t\tnode.property.type === \"Literal\" &&\n\t\t\t\t(node.property.value === \"first\" || node.property.value === \"last\")\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n/**\n * Whether a local holds a plain object, written out where it is used rather than calling `plain`, so V8 can turn the\n * prototype check into a field load for the few shapes each place sees. `q` is a scratch local every function has.\n */\nconst isPlainCode = (value: string): string =>\n\t`(typeof ${value} === \"object\" && ${value} !== null && ((q = getPrototypeOf(${value})) === objectPrototype || q === null))`;\n\n/** Reading a known key, as `.key` when it is an identifier. */\nconst access = (key: string): string =>\n\tIDENTIFIER.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;\n\nconst isBlank = (statement: Statement) =>\n\tstatement.type === \"Text\" && statement.value.trim() === \"\";\n\nconst indent = (lines: string[]): string[] => lines.map((line) => `\\t${line}`);\n\n/** Lines without `FORK` markers, for functions that never start passes ahead. */\nconst dropForks = (lines: string[]): string[] =>\n\tlines.filter((line) => line.trim() !== FORK);\n\nclass Generator {\n\treadonly #env: EnvironmentCore;\n\treadonly #ast: TemplateNode;\n\t/** Names that call macros rather than functions: local macros and macros imported by name. */\n\treadonly #macros = new Set<string>();\n\t/** Start and end offsets of every span generated code refers to, flattened. */\n\treadonly #spans: number[] = [];\n\treadonly #spanIndex = new Map<string, number>();\n\t/** Declarations made once when the module is loaded, such as built-ins and frozen option hashes. */\n\treadonly #constants: string[] = [];\n\treadonly #constantNames = new Map<string, string>();\n\treadonly #runs: string[] = [];\n\t/** Generator functions for runs that may wait, declared once in `create`. */\n\treadonly #declarations: string[] = [];\n\t#generators = 0;\n\t/** Lists the closure compiler compiles itself, such as the bodies of blocks a run places, searched for runs later. */\n\treadonly #pending: [Statement[], EscapeStrategy | false][] = [];\n\t/** The function being generated. */\n\t#fn = newFunction();\n\t/** Plain-object flags of loop variables that generated code reads, so loops only set the ones used. */\n\treadonly #plainUsed = new Set<string>();\n\t/** Loops so far, for local names unique in the module, so a fill's loops never hide the loop around it. */\n\t#loops = 0;\n\t#depth = 0;\n\t/**\n\t * Whether the top-level statement being generated lets the rest of the run start while it waits: `AHEAD`, or\n\t * `GUARDED` when only for renders whose blocks and fills set nothing. See `#list`.\n\t */\n\t#forkable: typeof AHEAD | typeof GUARDED | null = null;\n\n\tconstructor(env: EnvironmentCore, ast: TemplateNode) {\n\t\tthis.#env = env;\n\t\tthis.#ast = ast;\n\t\tfor (const statement of ast.body) {\n\t\t\tif (statement.type === \"Macro\") this.#macros.add(statement.name);\n\t\t\tif (statement.type === \"FromImport\") {\n\t\t\t\tfor (const entry of statement.names) this.#macros.add(entry.alias);\n\t\t\t}\n\t\t}\n\t}\n\n\tmodule(source: string): string {\n\t\t// A child template's top level only defines blocks, so only the lists inside it run.\n\t\tconst child = this.#ast.body.some(\n\t\t\t(statement) => statement.type === \"Extends\",\n\t\t);\n\t\tthis.#list(this.#ast.body, this.#env.autoescape, child, true);\n\t\tfor (let next = this.#pending.shift(); next; next = this.#pending.shift()) {\n\t\t\tthis.#list(next[0], next[1], false);\n\t\t}\n\t\treturn [\n\t\t\t\"// Precompiled by Kiln. Don't edit this file: precompile the template again.\",\n\t\t\t\"export default {\",\n\t\t\t`\\tkiln: ${PRECOMPILED_VERSION},`,\n\t\t\t`\\tautoescape: ${JSON.stringify(this.#env.autoescape)},`,\n\t\t\t`\\tsource: ${JSON.stringify(source)},`,\n\t\t\t\"\\tcreate(rt) {\",\n\t\t\t`\\t\\tconst { ${HELPERS.join(\", \")} } = rt;`,\n\t\t\t`\\t\\tconst S = rt.spans([${this.#spans.join(\", \")}]);`,\n\t\t\t...this.#constants.map((line) => `\\t\\t${line}`),\n\t\t\t...this.#declarations.map((line) => `\\t\\t${line}`),\n\t\t\t\"\\t\\treturn [\",\n\t\t\t...this.#runs,\n\t\t\t\"\\t\\t];\",\n\t\t\t\"\\t},\",\n\t\t\t\"};\",\n\t\t\t\"\",\n\t\t].join(\"\\n\");\n\t}\n\n\t// Runs\n\n\t/**\n\t * Finds runs of statements to generate in a list. A statement that can't be generated stays with the closure\n\t * compiler, and the lists inside it are searched in turn. With `searchOnly`, only the lists inside are searched.\n\t * `top` is set for the template's top level.\n\t */\n\t#list(\n\t\tlist: Statement[],\n\t\tstrategy: EscapeStrategy | false,\n\t\tsearchOnly: boolean,\n\t\ttop = false,\n\t): void {\n\t\tconst context: Context = {\n\t\t\tbindings: new Map(),\n\t\t\tstrategy,\n\t\t\tinLoop: false,\n\t\t\ttop: true,\n\t\t\tpass: false,\n\t\t\tscope: \"scope\",\n\t\t};\n\t\t// Which statements may start while each waits, as the closures find it. See `planOf`. Runs are cut by the plan\n\t\t// for renders whose blocks and fills set nothing, and the closures pick a plan for each render.\n\t\tconst effects = searchOnly\n\t\t\t? []\n\t\t\t: list.map((statement) => effectsOf([statement], this.#env));\n\t\tconst plan = planOf(effects, false);\n\t\tconst strict = planOf(effects, true);\n\t\t// Statements a run must end at, so the closures' sequence can start the statements after them early.\n\t\tconst stops: number[] = [];\n\t\t// A layout's blocks get runs of their own. While the page's top-level statements wait, a block waits for them,\n\t\t// and the runs between blocks can start; see `Gate`.\n\t\tif (top) {\n\t\t\tlist.forEach((statement, index) => {\n\t\t\t\tif (statement.type === \"Block\") stops.push(index - 1, index);\n\t\t\t});\n\t\t}\n\t\tconst stopFrom = (index: number) =>\n\t\t\tMath.min(list.length - 1, ...stops.filter((stop) => stop >= index));\n\t\tlet i = 0;\n\t\twhile (i < list.length) {\n\t\t\tif (searchOnly) {\n\t\t\t\tthis.#children(list[i] as Statement, strategy);\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#fn = newFunction();\n\t\t\tlet groups: string[][] = [];\n\t\t\tlet end = i;\n\t\t\tlet work = false;\n\t\t\tlet last = stopFrom(i);\n\t\t\twhile (end < list.length) {\n\t\t\t\t// Text alone goes on into the next run, rather than leave a run with nothing to do before it.\n\t\t\t\tif (end > last) {\n\t\t\t\t\tif (work) break;\n\t\t\t\t\tlast = stopFrom(end);\n\t\t\t\t}\n\t\t\t\tconst statement = list[end] as Statement;\n\t\t\t\tconst after = plan.after[end] as number;\n\t\t\t\tconst reach = plan.reach[end] as number;\n\t\t\t\tconst forkable = reach > after;\n\t\t\t\t// A wait in a run's chain of functions can only start the rest of the run, which must not depend on it.\n\t\t\t\t// When blocks or fills that set variables would change that, it checks when it waits.\n\t\t\t\tconst chained = forkable && after === end;\n\t\t\t\tconst { inner, aheadWaits } = this.#fn;\n\t\t\t\tconst restore = this.#snapshot();\n\t\t\t\tthis.#forkable = !chained\n\t\t\t\t\t? null\n\t\t\t\t\t: strict.after[end] === end && (strict.reach[end] as number) >= reach\n\t\t\t\t\t\t? AHEAD\n\t\t\t\t\t\t: GUARDED;\n\t\t\t\tconst generated = this.#attempt(() =>\n\t\t\t\t\tthis.#statement(statement, context),\n\t\t\t\t);\n\t\t\t\tthis.#forkable = null;\n\t\t\t\tif (!generated) break;\n\t\t\t\tconst waitsInside = this.#fn.inner > inner;\n\t\t\t\t// A run that waits inside a statement is a generator, which can't start the rest of the run while it\n\t\t\t\t// waits, and a chain can't run statements that depend on a wait before the ones that start early. Then\n\t\t\t\t// the statement gets a run of its own, and so do the statements that depend on it and the ones that start\n\t\t\t\t// early, so the closures' sequence can start them. A statement that waits inside after a wait that\n\t\t\t\t// starts the rest of the run ahead gets a run of its own too, so the chain stays a chain.\n\t\t\t\tconst own = forkable && (waitsInside || !chained || this.#fn.inner > 0);\n\t\t\t\tif (own || (waitsInside && aheadWaits > 0)) {\n\t\t\t\t\tif (end > i && work) {\n\t\t\t\t\t\trestore();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tgroups.push(generated);\n\t\t\t\t\twork = true;\n\t\t\t\t\tend++;\n\t\t\t\t\tif (forkable) stops.push(after, reach);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tgroups.push(generated);\n\t\t\t\tif (statement.type !== \"Text\") work = true;\n\t\t\t\tend++;\n\t\t\t\t// A wait that starts the rest of the run ahead needs all of it within its reach.\n\t\t\t\tif (chained) last = Math.min(last, reach);\n\t\t\t}\n\t\t\tif (end === i) {\n\t\t\t\tthis.#children(list[i] as Statement, strategy);\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (work) {\n\t\t\t\tgroups = this.#parts(list.slice(i, end), groups);\n\t\t\t\tconst first = (list[i] as Statement).span;\n\t\t\t\tconst last = (list[end - 1] as Statement).span;\n\t\t\t\tconst span = this.#span({ start: first.start, end: last.end });\n\t\t\t\tthis.#runs.push(\n\t\t\t\t\t`\\t\\t\\t[${first.start}, ${last.end}, ${this.#function(groups, span, false)}],`,\n\t\t\t\t);\n\t\t\t}\n\t\t\ti = end;\n\t\t}\n\t}\n\n\t/**\n\t * Writes the current function from its top-level statements' lines. Text is gathered in `s`, and written before\n\t * anything that writes to `out` itself, and at the end.\n\t *\n\t * A function that never waits is a plain function. A run whose waits all end top-level statements, such as an\n\t * include, is split after each into functions that call the next, so it only makes a callback when a promise comes\n\t * back. Anything else that may wait, such as an include in a loop, is a generator that `drive` runs.\n\t */\n\t#function(groups: string[][], span: string, nested: boolean): string {\n\t\tconst fn = this.#fn;\n\t\tgroups = groups.map((lines) =>\n\t\t\tthis.#forgetLines(this.#setFlags(dropForks(lines))),\n\t\t);\n\t\t// Steps are counted in a local, and `state.steps` kept up to date wherever other code may read or count them.\n\t\tconst start = this.#start(span);\n\t\tconst end = [\"state.steps = steps;\", `write(run, out, s, ${span});`];\n\t\tconst wrap = (lines: string[]) =>\n\t\t\tindent(lines).map((line) => `\\t\\t\\t${line}`);\n\n\t\tif (!fn.waits) {\n\t\t\tconst body = wrap([...start, ...this.#guard([...groups.flat(), ...end])]);\n\t\t\treturn `(run, scope, out) => {\\n${body.join(\"\\n\")}\\n\\t\\t\\t}`;\n\t\t}\n\n\t\tif (!fn.waitsInside && !nested) {\n\t\t\tconst segments: string[][] = [[]];\n\t\t\tfor (const group of groups) {\n\t\t\t\t(segments.at(-1) as string[]).push(...group);\n\t\t\t\tif (group.some((line) => WAIT_LINE.test(line))) segments.push([]);\n\t\t\t}\n\t\t\tconst base = `R${this.#generators++}`;\n\t\t\tsegments.forEach((lines, index) => {\n\t\t\t\tconst next = `${base}_${index + 1}(run, scope, out)`;\n\t\t\t\t// A wait that lets the rest of the run start ahead runs it in another buffer while it waits.\n\t\t\t\tconst body = lines.map((line) =>\n\t\t\t\t\tline.replace(\n\t\t\t\t\t\tWAIT_LINE,\n\t\t\t\t\t\t(_, tabs: string, result: string, ahead?: string) => {\n\t\t\t\t\t\t\tconst then = `${result}.then(() => ${next})`;\n\t\t\t\t\t\t\tconst rest = `restAhead(run, out, ${result}, inl, ind, (run, out) => ${next}, ${span})`;\n\t\t\t\t\t\t\treturn `${tabs}if (${result} !== undefined) return ${\n\t\t\t\t\t\t\t\tahead === AHEAD\n\t\t\t\t\t\t\t\t\t? rest\n\t\t\t\t\t\t\t\t\t: ahead === GUARDED\n\t\t\t\t\t\t\t\t\t\t? `contentSets(run) ? ${then} : ${rest}`\n\t\t\t\t\t\t\t\t\t\t: then\n\t\t\t\t\t\t\t};`;\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\t// Each function writes its own text, such as a slot's fallback, before the next takes over.\n\t\t\t\tconst last = index === segments.length - 1;\n\t\t\t\tthis.#declarations.push(\n\t\t\t\t\t`function ${base}_${index}(run, scope, out) {`,\n\t\t\t\t\t...indent([\n\t\t\t\t\t\t...start,\n\t\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t\t...body,\n\t\t\t\t\t\t\t...end,\n\t\t\t\t\t\t\t...(last ? [] : [`return ${next};`]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\t\"}\",\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn `${base}_0`;\n\t\t}\n\n\t\tconst body = wrap([\n\t\t\t...start,\n\t\t\t...this.#guard([...groups.flat(), ...end]),\n\t\t]).map((line) =>\n\t\t\tline.replace(\n\t\t\t\tWAIT_LINE,\n\t\t\t\t(_, tabs: string, result: string) =>\n\t\t\t\t\t`${tabs}if (${result} !== undefined) yield ${result};`,\n\t\t\t),\n\t\t);\n\t\t// A run's generator is declared once. A fill's is made where the component is, to read the loops around it.\n\t\tif (!nested) {\n\t\t\tconst generator = `G${this.#generators++}`;\n\t\t\tthis.#declarations.push(\n\t\t\t\t`function* ${generator}(run, scope, out) {`,\n\t\t\t\t...body.map((line) => line.slice(2)),\n\t\t\t\t\"}\",\n\t\t\t);\n\t\t\treturn `(run, scope, out) => drive(${generator}(run, scope, out))`;\n\t\t}\n\t\treturn `(run, scope, out) => drive((function* () {\\n${body.join(\"\\n\")}\\n\\t\\t\\t})())`;\n\t}\n\n\t/** Wraps a function's statements so an error a getter in your data throws is located at the read; see `reads`. */\n\t#guard(lines: string[]): string[] {\n\t\tif (!this.#fn.reads) return lines;\n\t\treturn [\n\t\t\t\"try {\",\n\t\t\t...indent(lines),\n\t\t\t\"} catch (error) {\",\n\t\t\t\"\\tthrow readError(run, at, error);\",\n\t\t\t\"}\",\n\t\t];\n\t}\n\n\t/** Sets the plain-object flags the current function's property reads use. See `PLAIN`. */\n\t#setFlags(lines: string[]): string[] {\n\t\tconst used = this.#fn.plainUsed;\n\t\treturn lines.map((line) =>\n\t\t\tline.replace(PLAIN, (_, flag: string, value: string) =>\n\t\t\t\tused.has(flag) ? `, ${flag} = ${isPlainCode(value)}` : \"\",\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * Declarations at the start of a generated function: steps are counted in a local, see `#function`, and `b` marks\n\t * where the current run of text and outputs starts in `s`, see `#parts`. Checks the abort signal too, since a\n\t * function may continue a run after a wait.\n\t */\n\t#start(span: string): string[] {\n\t\tconst fn = this.#fn;\n\t\tconst declared = [\n\t\t\t...Array.from({ length: fn.temps }, (_, i) => `t${i}`),\n\t\t\t...[...fn.variables.values()].flatMap(({ value, plain }) =>\n\t\t\t\tfn.plainUsed.has(plain) ? [value, plain] : [value],\n\t\t\t),\n\t\t];\n\t\treturn [\n\t\t\t\"const state = run.state;\",\n\t\t\t\"const maxSteps = state.maxSteps;\",\n\t\t\t\"const maxSize = state.maxSize;\",\n\t\t\t\"let steps = state.steps;\",\n\t\t\t\"const signal = state.signal;\",\n\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t\t\"const ind = out.indent;\",\n\t\t\t\"const inl = out.inline;\",\n\t\t\t'let s = \"\";',\n\t\t\t`let ${[\"q\", \"b\", ...declared].join(\", \")};`,\n\t\t\t...(fn.reads ? [\"let at = null;\"] : []),\n\t\t];\n\t}\n\n\t/** Generates a statement, or returns null and forgets anything it added when the statement can't be generated. */\n\t#attempt(generate: () => string[]): string[] | null {\n\t\tconst restore = this.#snapshot();\n\t\ttry {\n\t\t\treturn generate();\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Unsupported)) throw error;\n\t\t\trestore();\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Returns a function that forgets everything generated since, such as constants and queued lists. */\n\t#snapshot(): () => void {\n\t\tconst constants = this.#constants.length;\n\t\tconst names = [...this.#constantNames.keys()];\n\t\tconst pending = this.#pending.length;\n\t\tconst declarations = this.#declarations.length;\n\t\tconst fn = this.#fn;\n\t\tconst saved = {\n\t\t\t...fn,\n\t\t\tvariables: new Map(fn.variables),\n\t\t\tplainUsed: new Set(fn.plainUsed),\n\t\t};\n\t\treturn () => {\n\t\t\tthis.#constants.length = constants;\n\t\t\tfor (const key of this.#constantNames.keys()) {\n\t\t\t\tif (!names.includes(key)) this.#constantNames.delete(key);\n\t\t\t}\n\t\t\tthis.#pending.length = pending;\n\t\t\tthis.#declarations.length = declarations;\n\t\t\tthis.#fn = saved;\n\t\t};\n\t}\n\n\t#children(statement: Statement, strategy: EscapeStrategy | false): void {\n\t\tswitch (statement.type) {\n\t\t\tcase \"If\":\n\t\t\t\tfor (const branch of statement.branches) {\n\t\t\t\t\tthis.#list(branch.body, strategy, false);\n\t\t\t\t}\n\t\t\t\tif (statement.alternate) {\n\t\t\t\t\tthis.#list(statement.alternate, strategy, false);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"For\":\n\t\t\t\tthis.#list(statement.body, strategy, false);\n\t\t\t\tif (statement.alternate) {\n\t\t\t\t\tthis.#list(statement.alternate, strategy, false);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"Component\":\n\t\t\t\tthis.#list(statement.body, strategy, false);\n\t\t\t\tfor (const fill of statement.fills) {\n\t\t\t\t\tthis.#list(fill.body, strategy, false);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"Autoescape\":\n\t\t\t\tthis.#list(statement.body, statement.strategy, false);\n\t\t\t\tbreak;\n\t\t\tcase \"SetBlock\":\n\t\t\tcase \"Block\":\n\t\t\tcase \"Slot\":\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Add\":\n\t\t\tcase \"Cache\":\n\t\t\tcase \"Island\":\n\t\t\tcase \"With\":\n\t\t\tcase \"Apply\":\n\t\t\t\tthis.#list(statement.body, strategy, false);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Names for constants and temporaries\n\n\t#span(span: Span): string {\n\t\tconst key = `${span.start}:${span.end}`;\n\t\tlet index = this.#spanIndex.get(key);\n\t\tif (index === undefined) {\n\t\t\tindex = this.#spanIndex.size;\n\t\t\tthis.#spanIndex.set(key, index);\n\t\t\tthis.#spans.push(span.start, span.end);\n\t\t}\n\t\treturn `S[${index}]`;\n\t}\n\n\t/** A value made once when the module loads, such as a built-in filter. */\n\t#constant(key: string, prefix: string, value: string): string {\n\t\tlet name = this.#constantNames.get(key);\n\t\tif (name === undefined) {\n\t\t\tname = `${prefix}${this.#constantNames.size}`;\n\t\t\tthis.#constantNames.set(key, name);\n\t\t\tthis.#constants.push(`const ${name} = ${value};`);\n\t\t}\n\t\treturn name;\n\t}\n\n\t#temp(): string {\n\t\treturn `t${this.#fn.temps++}`;\n\t}\n\n\t/** Counts one step, as `step` does. */\n\t#step(span: string): string {\n\t\treturn `++steps > maxSteps && stepLimit(run, ${span})`;\n\t}\n\n\t/**\n\t * Counts a step and checks the abort signal, as `step` does: in loops, so a long render stops soon after an abort,\n\t * and before calls to your functions and filters.\n\t */\n\t#checkedStep(span: string): string {\n\t\treturn `${this.#step(span)}; signal !== undefined && signal.aborted && aborted(run, ${span});`;\n\t}\n\n\t/** Calls something that may read or count steps, with `state.steps` up to date around it. */\n\t#counted(call: string): string {\n\t\tconst result = this.#temp();\n\t\treturn `(state.steps = steps, ${result} = ${call}, steps = state.steps, ${result})`;\n\t}\n\n\t/**\n\t * Writes the text so far, runs something that writes to `out` and may return a promise, and waits for it. `top`\n\t * is set when the wait ends a top-level statement. A wait that continues in a new function is checked for an abort\n\t * by `#start`, and one in a generator after it resumes.\n\t */\n\t#wait(span: string, call: string, top: boolean): string[] {\n\t\tthis.#fn.waits = true;\n\t\tif (!top) {\n\t\t\tthis.#fn.waitsInside = true;\n\t\t\tthis.#fn.inner++;\n\t\t}\n\t\tconst result = this.#temp();\n\t\tconst ahead = top ? this.#forkable : null;\n\t\tif (ahead !== null) this.#fn.aheadWaits++;\n\t\treturn [\n\t\t\t`write(run, out, s, ${span});`,\n\t\t\t's = \"\";',\n\t\t\t\"state.steps = steps;\",\n\t\t\t`${result} = ${call};`,\n\t\t\t`${WAIT}${result}${ahead ?? \"\"}`,\n\t\t\t\"steps = state.steps;\",\n\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t];\n\t}\n\n\t/** A function for a list of statements inside the current one, such as a component's fill. */\n\t#nested(list: Statement[], at: Span, context: Context): string {\n\t\tconst outer = this.#fn;\n\t\tthis.#fn = newFunction();\n\t\ttry {\n\t\t\t// A fill runs in a scope of its own, made from the caller's when the slot renders it.\n\t\t\tconst lines = this.#body(list, { ...context, scope: \"scope\" });\n\t\t\treturn this.#function([lines], this.#span(at), true);\n\t\t} finally {\n\t\t\tthis.#fn = outer;\n\t\t}\n\t}\n\n\t// Statements\n\n\t#statement(statement: Statement, context: Context): string[] {\n\t\tswitch (statement.type) {\n\t\t\tcase \"Text\":\n\t\t\t\treturn [this.#text(statement)];\n\t\t\tcase \"Output\":\n\t\t\t\treturn this.#output(statement.expression, statement.span, context);\n\t\t\tcase \"If\":\n\t\t\t\treturn this.#if(statement, context);\n\t\t\tcase \"For\":\n\t\t\t\treturn this.#for(statement, context);\n\t\t\tcase \"Autoescape\":\n\t\t\t\treturn this.#body(statement.body, {\n\t\t\t\t\t...context,\n\t\t\t\t\tstrategy: statement.strategy,\n\t\t\t\t});\n\t\t\tcase \"Props\":\n\t\t\t\treturn this.#props(statement, context);\n\t\t\tcase \"Set\":\n\t\t\t\treturn this.#set(statement, context);\n\t\t\tcase \"Include\":\n\t\t\t\treturn this.#include(statement, context);\n\t\t\tcase \"Component\":\n\t\t\t\treturn this.#component(statement, context);\n\t\t\tcase \"Slot\":\n\t\t\t\treturn this.#slot(statement, context);\n\t\t\tcase \"Block\":\n\t\t\t\treturn this.#block(statement, context);\n\t\t\tdefault:\n\t\t\t\treturn unsupported();\n\t\t}\n\t}\n\n\t/** Text, with its lines indented to where it is inserted. See `indentText`. */\n\t#text(statement: Extract<Statement, { type: \"Text\" }>): string {\n\t\tconst text = JSON.stringify(statement.value);\n\t\tif (!statement.lines) return `s += ${text};`;\n\t\tconst lines = JSON.stringify(statement.lines);\n\t\tconst entry = this.#constant(\n\t\t\t`text:${statement.span.start}:${statement.span.end}`,\n\t\t\t\"T\",\n\t\t\t`indentedText(${text}, ${lines})`,\n\t\t);\n\t\t// The text indented last time is read here, so the usual case makes no call.\n\t\treturn `s += ind === \"\" ? ${text} : ${entry}.indent === ind && !out.inline ? ${entry}.indented : indentText(${entry}, ind, s === \"\" && out.inline);`;\n\t}\n\n\t/**\n\t * Inserts content at the indentation of the tag that inserts it, with `startPlace` and `endPlace`. Tags at the start\n\t * of a line need nothing. Saved values go in temporaries rather than a closure, so the function's locals stay fast.\n\t */\n\t#place(at: string | undefined, call: string): string {\n\t\tif (at === \"\") return call;\n\t\tconst [saved, inline] = [this.#temp(), this.#temp()];\n\t\treturn `(${saved} = out.indent, ${inline} = out.inline, startPlace(out, ${this.#at(at)}), endPlace(out, ${saved}, ${inline}, ${call}))`;\n\t}\n\n\t#at(at: string | undefined): string {\n\t\treturn at === undefined ? \"undefined\" : JSON.stringify(at);\n\t}\n\n\t/** Statements inside another, such as a loop's body. */\n\t#body(list: Statement[], context: Context): string[] {\n\t\tconst inner = { ...context, top: false, pass: false };\n\t\treturn this.#parts(\n\t\t\tlist,\n\t\t\tlist.map((statement) => this.#statement(statement, inner)),\n\t\t).flat();\n\t}\n\n\t/**\n\t * Checks the output limit where the closures do, given a list's statements and their lines. The closures print each\n\t * run of text and outputs as one string, see `printParts`: an output fails when that string alone is too long, and\n\t * the run fails when writing it makes the output too long, located at its start. Generated code gathers text in\n\t * `s` for longer, so it marks where each run starts in `b`, and checks the whole output after each run.\n\t */\n\t#parts(list: Statement[], groups: string[][]): string[][] {\n\t\tconst isPart = (statement: Statement) =>\n\t\t\tstatement.type === \"Text\" ||\n\t\t\t(statement.type === \"Output\" && !this.#isHostCall(statement.expression));\n\t\tconst result: string[][] = [];\n\t\tlet i = 0;\n\t\twhile (i < list.length) {\n\t\t\tif (!isPart(list[i] as Statement)) {\n\t\t\t\tresult.push(groups[i] as string[]);\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet end = i;\n\t\t\twhile (end < list.length && isPart(list[end] as Statement)) end++;\n\t\t\tconst run = groups.slice(i, end);\n\t\t\t// Only outputs read where the run starts.\n\t\t\tif (list.slice(i, end).some((statement) => statement.type === \"Output\")) {\n\t\t\t\trun[0] = [\"b = s.length;\", ...(run[0] as string[])];\n\t\t\t}\n\t\t\tconst at = this.#span((list[i] as Statement).span);\n\t\t\tconst last = run.length - 1;\n\t\t\trun[last] = [\n\t\t\t\t...(run[last] as string[]),\n\t\t\t\t`if (out.s.length + s.length > maxSize) write(run, out, s, ${at});`,\n\t\t\t];\n\t\t\tresult.push(...run);\n\t\t\ti = end;\n\t\t}\n\t\treturn result;\n\t}\n\n\t#output(expression: Expression, at: Span, context: Context): string[] {\n\t\tconst span = this.#span(at);\n\t\tconst step = `${this.#step(span)};`;\n\t\tconst emit = emitter(context.strategy);\n\t\tconst emitted = (value: unknown): string => {\n\t\t\ttry {\n\t\t\t\treturn JSON.stringify(emit(value));\n\t\t\t} catch {\n\t\t\t\t// Fails when rendering, so the closures report it.\n\t\t\t\treturn unsupported();\n\t\t\t}\n\t\t};\n\t\t// Values can be long, so stop at the output limit before they make a string too long for JavaScript. An output in\n\t\t// a run of text and outputs checks the run's text, and a call to one of your functions, which the closures write\n\t\t// on its own, checks the whole output. See `#parts`.\n\t\tconst limit = this.#isHostCall(expression)\n\t\t\t? `if (out.s.length + s.length > maxSize) write(run, out, s, ${span});`\n\t\t\t: `if (s.length - b > maxSize) write(run, out, s, ${span});`;\n\t\tif (expression.type === \"Literal\") {\n\t\t\treturn [step, `s += ${emitted(expression.value)};`, limit];\n\t\t}\n\t\t// A choice between two literals prints text emitted now.\n\t\tif (expression.type === \"Conditional\") {\n\t\t\tconst { consequent, alternate } = expression;\n\t\t\tif (\n\t\t\t\tconsequent.type === \"Literal\" &&\n\t\t\t\t(alternate === null || alternate.type === \"Literal\")\n\t\t\t) {\n\t\t\t\tconst yes = emitted(consequent.value);\n\t\t\t\tconst no = emitted(alternate ? alternate.value : null);\n\t\t\t\tconst test = this.#condition(expression.test, context);\n\t\t\t\treturn [step, `s += ${test} ? ${yes} : ${no};`];\n\t\t\t}\n\t\t}\n\t\tconst value = this.#temp();\n\t\tconst code = this.#value(expression, context, value);\n\t\tconst strategy = context.strategy;\n\t\t// Strings and numbers print in place. Numbers need no escaping in HTML.\n\t\tconst print =\n\t\t\tstrategy === \"html\"\n\t\t\t\t? `typeof ${value} === \"string\" ? escapeHtml(${value}) : typeof ${value} === \"number\" ? String(${value}) : print(run, ${span}, ${value}, \"html\")`\n\t\t\t\t: strategy === false\n\t\t\t\t\t? `typeof ${value} === \"string\" ? ${value} : typeof ${value} === \"number\" ? String(${value}) : print(run, ${span}, ${value}, \"none\")`\n\t\t\t\t\t: `print(run, ${span}, ${value}, ${JSON.stringify(strategy)})`;\n\t\treturn [step, ...code, `s += ${print};`, limit];\n\t}\n\n\t/**\n\t * Branches test in order, and the first that holds runs. JavaScript nests `else if`, so long chains become a flat\n\t * labelled block that its parser can read without recursing once per branch.\n\t */\n\t#if(\n\t\tstatement: Extract<Statement, { type: \"If\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst lines = [`${this.#step(this.#span(statement.span))};`];\n\t\tconst branches = statement.branches.map((branch) => ({\n\t\t\ttest: this.#condition(branch.test, context),\n\t\t\tbody: indent(this.#body(branch.body, context)),\n\t\t}));\n\t\tconst alternate = statement.alternate\n\t\t\t? indent(this.#body(statement.alternate, context))\n\t\t\t: null;\n\t\tif (branches.length <= MAX_ELSE_IF) {\n\t\t\tbranches.forEach(({ test, body }, index) => {\n\t\t\t\tlines.push(`${index === 0 ? \"if\" : \"} else if\"} (${test}) {`, ...body);\n\t\t\t});\n\t\t\tif (alternate) lines.push(\"} else {\", ...alternate);\n\t\t\tlines.push(\"}\");\n\t\t\treturn lines;\n\t\t}\n\t\tconst label = `if${this.#loops++}`;\n\t\tlines.push(`${label}: {`);\n\t\tfor (const { test, body } of branches) {\n\t\t\tlines.push(\n\t\t\t\t`\\tif (${test}) {`,\n\t\t\t\t...indent(body),\n\t\t\t\t`\\t\\tbreak ${label};`,\n\t\t\t\t\"\\t}\",\n\t\t\t);\n\t\t}\n\t\tif (alternate) lines.push(...alternate);\n\t\tlines.push(\"}\");\n\t\treturn lines;\n\t}\n\n\t/**\n\t * A loop. Its variables become JavaScript locals, since nothing in generated code can change them, and `loop.index`\n\t * and the rest read the loop's counter. Text is written whenever a pass leaves more than `FLUSH_AT` characters, so\n\t * the output limit still stops a long loop early.\n\t */\n\t#for(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst id = this.#loops++;\n\t\tconst iterable = this.#temp();\n\t\tconst [items, values, length, keys, index, value, key] = [\n\t\t\t\"items\",\n\t\t\t\"values\",\n\t\t\t\"n\",\n\t\t\t\"keys\",\n\t\t\t\"i\",\n\t\t\t\"v\",\n\t\t\t\"k\",\n\t\t].map((name) => `${name}${id}`) as [\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t];\n\t\tconst bindings = new Map(context.bindings);\n\t\tbindings.set(statement.valueName, {\n\t\t\tkind: \"value\",\n\t\t\tjs: value,\n\t\t\tplain: `p${value}`,\n\t\t});\n\t\tif (statement.keyName !== null) {\n\t\t\tbindings.set(statement.keyName, {\n\t\t\t\tkind: \"value\",\n\t\t\t\tjs: key,\n\t\t\t\tplain: `p${key}`,\n\t\t\t});\n\t\t}\n\t\tbindings.set(\"loop\", { kind: \"loop\", index, length });\n\t\tconst hasKeys = statement.keyName !== null;\n\t\tconst sets = [...setsIn(statement.body)];\n\t\tconst scoped = sets.length > 0 ? `sc${id}` : null;\n\t\tconst loop: LoopNames = {\n\t\t\tid,\n\t\t\tspan,\n\t\t\tscope: scoped,\n\t\t\touter: context.scope,\n\t\t\tsets,\n\t\t\tvalues,\n\t\t\tlength,\n\t\t\tkeys,\n\t\t\tindex,\n\t\t\tvalue,\n\t\t\tkey,\n\t\t\thasKeys,\n\t\t};\n\t\tconst passContext = {\n\t\t\t...context,\n\t\t\tbindings,\n\t\t\tscope: scoped ?? context.scope,\n\t\t};\n\t\tconst looped =\n\t\t\tcontext.top &&\n\t\t\t!context.inLoop &&\n\t\t\teffectsOf(statement.body, this.#env).waits\n\t\t\t\t? this.#loopFunction(statement, passContext, loop)\n\t\t\t\t: null;\n\t\tconst range = looped ? null : literalRange(statement.iterable);\n\t\tconst paused =\n\t\t\tlooped || range\n\t\t\t\t? null\n\t\t\t\t: this.#loopGenerator(statement, passContext, loop);\n\t\tconst body =\n\t\t\tlooped || paused\n\t\t\t\t? []\n\t\t\t\t: this.#body(statement.body, { ...passContext, inLoop: true });\n\t\tconst alternate = statement.alternate\n\t\t\t? this.#body(statement.alternate, context)\n\t\t\t: [];\n\t\tif (range) {\n\t\t\treturn this.#rangeLoop(statement, context, loop, range, body, alternate);\n\t\t}\n\t\tconst passes = looped\n\t\t\t? this.#wait(\n\t\t\t\t\tspan,\n\t\t\t\t\t`${looped}(run, ${context.scope}, out, ${values}, ${length}, 0, ${length}${hasKeys ? `, ${keys}` : \"\"})`,\n\t\t\t\t\tcontext.top,\n\t\t\t\t)\n\t\t\t: paused\n\t\t\t\t? [\n\t\t\t\t\t\t...paused,\n\t\t\t\t\t\t...this.#wait(\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t`drive(LG${id}(run, out, 0, ${length}))`,\n\t\t\t\t\t\t\tcontext.top,\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t: [\n\t\t\t\t\t\t`for (let ${index} = 0; ${index} < ${length}; ${index}++) {`,\n\t\t\t\t\t\t...indent(this.#pass(loop, true)),\n\t\t\t\t\t\t...indent(body),\n\t\t\t\t\t\t`\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t\t\t\t`\\t\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t'\\t\\ts = \"\";',\n\t\t\t\t\t\t\"\\t}\",\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t];\n\t\treturn [\n\t\t\tthis.#checkedStep(span),\n\t\t\t...this.#value(statement.iterable, context, iterable),\n\t\t\t// Arrays, the usual case, need no conversion unless the loop wants keys.\n\t\t\t...(hasKeys\n\t\t\t\t? [\n\t\t\t\t\t\t`const ${items} = loopItems(run, ${span}, ${iterable}, true);`,\n\t\t\t\t\t\t`const ${values} = ${items}.values;`,\n\t\t\t\t\t]\n\t\t\t\t: [\n\t\t\t\t\t\t`const ${values} = Array.isArray(${iterable}) ? ${iterable} : loopItems(run, ${span}, ${iterable}, false).values;`,\n\t\t\t\t\t]),\n\t\t\t`const ${length} = ${values}.length;`,\n\t\t\t`if (${length} === 0) {`,\n\t\t\t...indent(alternate),\n\t\t\t\"} else {\",\n\t\t\t...(hasKeys ? [`\\tconst ${keys} = ${items}.keys;`] : []),\n\t\t\t...indent(passes),\n\t\t\t\"}\",\n\t\t\t// Variables the body set may live outside the loop, so later lookups start again.\n\t\t\t...sets.flatMap((name) => this.#forget(name)),\n\t\t];\n\t}\n\n\t/**\n\t * A loop over a range of integer literals, such as `1..5`, counts instead of making the array. It charges the\n\t * range's steps and checks its length as `range` does.\n\t */\n\t#rangeLoop(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t\tloop: LoopNames,\n\t\trange: { from: number; to: number },\n\t\tbody: string[],\n\t\talternate: string[],\n\t): string[] {\n\t\tconst node = statement.iterable as Extract<Expression, { type: \"Binary\" }>;\n\t\tconst rangeSpan = this.#span(node.span);\n\t\tconst count = Math.abs(range.to - range.from) + 1;\n\t\tconst direction = range.to < range.from ? \"-\" : \"+\";\n\t\tconst { span, length, index, value, key, hasKeys } = loop;\n\t\treturn [\n\t\t\tthis.#checkedStep(span),\n\t\t\t`const ${length} = ${count};`,\n\t\t\t`if (${length} > maxSteps) rangeLimit(run, ${rangeSpan}, ${length});`,\n\t\t\t`if ((steps += ${length}) > maxSteps) stepLimit(run, ${rangeSpan});`,\n\t\t\t...(alternate.length > 0\n\t\t\t\t? [`if (${length} === 0) {`, ...indent(alternate), \"}\"]\n\t\t\t\t: []),\n\t\t\t`for (let ${index} = 0; ${index} < ${length}; ${index}++) {`,\n\t\t\t`\\t${this.#checkedStep(span)}`,\n\t\t\t...(loop.scope\n\t\t\t\t? [\n\t\t\t\t\t\t`\\tconst ${loop.scope} = childScope(${loop.outer});`,\n\t\t\t\t\t\t...indent(loop.sets.flatMap((name) => this.#forget(name))),\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t`\\tconst ${value} = ${range.from} ${direction} ${index};`,\n\t\t\t...(this.#plainUsed.has(`p${value}`)\n\t\t\t\t? [`\\tconst p${value} = false;`]\n\t\t\t\t: []),\n\t\t\t...(hasKeys ? [`\\tconst ${key} = ${index};`] : []),\n\t\t\t...(hasKeys && this.#plainUsed.has(`p${key}`)\n\t\t\t\t? [`\\tconst p${key} = false;`]\n\t\t\t\t: []),\n\t\t\t...indent(body),\n\t\t\t`\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t`\\t\\twrite(run, out, s, ${span});`,\n\t\t\t'\\t\\ts = \"\";',\n\t\t\t\"\\t}\",\n\t\t\t\"}\",\n\t\t\t...loop.sets.flatMap((name) => this.#forget(name)),\n\t\t];\n\t}\n\n\t/**\n\t * The start of a loop pass: counts a step and makes the pass's scope, unless continuing one, which is passed its\n\t * scope, and binds the loop's variables.\n\t */\n\t#pass(loop: LoopNames, starts: boolean): string[] {\n\t\tconst { span, values, index, value, key, keys, hasKeys } = loop;\n\t\tconst proto = `q${loop.id}`;\n\t\treturn [\n\t\t\t...(starts ? [this.#checkedStep(span)] : []),\n\t\t\t...(loop.scope && starts\n\t\t\t\t? [\n\t\t\t\t\t\t`const ${loop.scope} = childScope(${loop.outer});`,\n\t\t\t\t\t\t...loop.sets.flatMap((name) => this.#forget(name)),\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t`const ${value} = ${values}[${index}] ?? null;`,\n\t\t\t...(this.#plainUsed.has(`p${value}`)\n\t\t\t\t? [\n\t\t\t\t\t\t`let ${proto};`,\n\t\t\t\t\t\t`const p${value} = typeof ${value} === \"object\" && ${value} !== null && ((${proto} = getPrototypeOf(${value})) === objectPrototype || ${proto} === null);`,\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t...(hasKeys\n\t\t\t\t? [`const ${key} = ${keys} ? (${keys}[${index}] ?? null) : ${index};`]\n\t\t\t\t: []),\n\t\t\t...(hasKeys && this.#plainUsed.has(`p${key}`)\n\t\t\t\t? [`const p${key} = ${isPlainCode(key)};`]\n\t\t\t\t: []),\n\t\t];\n\t}\n\n\t/**\n\t * A loop at the top of a run whose passes may wait, such as one that includes a template, as plain functions\n\t * rather than a generator, which V8 runs more slowly. The loop is a function of its items and the index to start\n\t * at. A pass that gets a promise continues in a function for the rest of that pass, and `passAhead` calls the loop\n\t * for the next index: at once, ahead of the pass, when it may. Returns the loop function's name, or null when a pass\n\t * may wait somewhere a function can't continue from, such as in a nested loop.\n\t */\n\t#loopFunction(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t\tloop: LoopNames,\n\t): string | null {\n\t\tconst outer = this.#fn;\n\t\tconst restore = this.#snapshot();\n\t\tthis.#fn = newFunction();\n\t\ttry {\n\t\t\tconst inner: Context = {\n\t\t\t\t...context,\n\t\t\t\tinLoop: true,\n\t\t\t\ttop: true,\n\t\t\t\tpass: true,\n\t\t\t};\n\t\t\tconst generated = this.#parts(\n\t\t\t\tstatement.body,\n\t\t\t\tstatement.body.map((child) => this.#statement(child, inner)),\n\t\t\t);\n\t\t\tif (!this.#fn.waits || this.#fn.waitsInside) {\n\t\t\t\trestore();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Flags are set once every statement is generated, so every lookup of a variable sets the flag a later read\n\t\t\t// uses. A lookup that skipped it would leave the flag of an earlier value, which may not be a plain object.\n\t\t\tconst groups = generated.map((lines) => this.#setFlags(lines));\n\t\t\t// A pass is split after each statement that waits, and after each call to your function, whose value the\n\t\t\t// next function takes: `values[k]` names the local it goes in for segment k.\n\t\t\tconst segments: string[][] = [[]];\n\t\t\tconst values: (string | null)[] = [null];\n\t\t\tfor (const group of groups) {\n\t\t\t\tfor (const line of group) {\n\t\t\t\t\t(segments.at(-1) as string[]).push(line);\n\t\t\t\t\tconst value = VALUE_LINE.exec(line);\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tsegments.push([]);\n\t\t\t\t\t\tvalues.push(value[2] as string);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (group.some((line) => WAIT_LINE.test(line))) {\n\t\t\t\t\tsegments.push([]);\n\t\t\t\t\tvalues.push(null);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst name = `L${this.#generators++}`;\n\t\t\tconst keys = loop.hasKeys ? `, ${loop.keys}` : \"\";\n\t\t\t// The loop function runs passes up to `stop`; each function after a wait finishes one pass.\n\t\t\tconst params = `run, scope, out, ${loop.values}, ${loop.length}, ${loop.index}, stop${keys}`;\n\t\t\t// A pass continues in the scope it started, so variables it set before waiting are still there.\n\t\t\tconst passScope = loop.scope ? `, ${loop.scope}` : \"\";\n\t\t\tconst partParams = `run, scope, out, ${loop.values}, ${loop.length}, ${loop.index}${keys}${passScope}`;\n\t\t\tconst call = (part: number, value?: string) =>\n\t\t\t\t`${name}_${part}(${partParams}${value === undefined ? \"\" : `, ${value}`})`;\n\t\t\tconst one = `(run, out, j) => ${name}(run, scope, out, ${loop.values}, ${loop.length}, j, j + 1${keys})`;\n\t\t\tconst { sets, elsewhere } = this.#setsOf(statement);\n\t\t\t// Each wait continues the pass in the function for the segments after it. The first wait in a pass, in the\n\t\t\t// loop function, also starts the passes after it, ahead of it when they may. See `passAhead`.\n\t\t\tconst handOff = (from: number, tabs: string, rest: string) =>\n\t\t\t\tfrom === 0\n\t\t\t\t\t? `${tabs}return ${loop.index} + 1 < stop ? passAhead(run, scope, out, ${rest}, inl, ind, ${sets}, ${elsewhere}, ${loop.index} + 1, stop, ${one}, ${loop.span}) : ${rest};`\n\t\t\t\t\t: `${tabs}return ${rest};`;\n\t\t\tconst continued = (from: number) =>\n\t\t\t\tsegments.slice(from).flatMap((lines, offset) =>\n\t\t\t\t\tthis.#forgetLines(lines).flatMap((line) => {\n\t\t\t\t\t\tconst next = from + offset + 1;\n\t\t\t\t\t\tconst value = VALUE_LINE.exec(line);\n\t\t\t\t\t\tif (value) {\n\t\t\t\t\t\t\tconst [, tabs, result, span, fn] = value as unknown as string[];\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\t`${tabs}if (${result} instanceof Promise) {`,\n\t\t\t\t\t\t\t\t// The text so far goes out first, so a streamed render can send it while this waits.\n\t\t\t\t\t\t\t\t`${tabs}\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t\t\thandOff(\n\t\t\t\t\t\t\t\t\tfrom,\n\t\t\t\t\t\t\t\t\t`${tabs}\\t`,\n\t\t\t\t\t\t\t\t\t`${result}.then((w) => ${call(next, \"unhold(w)\")}, (error) => { throw hostError(run, ${span}, ${fn}, error); })`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t`${tabs}}`,\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst wait = WAIT_LINE.exec(line);\n\t\t\t\t\t\tif (!wait) return [line];\n\t\t\t\t\t\tconst [, tabs, result] = wait as unknown as string[];\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t`${tabs}if (${result} !== undefined) {`,\n\t\t\t\t\t\t\thandOff(from, `${tabs}\\t`, `${result}.then(() => ${call(next)})`),\n\t\t\t\t\t\t\t`${tabs}}`,\n\t\t\t\t\t\t];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\tconst start = this.#start(loop.span);\n\t\t\tconst end = [\"state.steps = steps;\", `write(run, out, s, ${loop.span});`];\n\t\t\tthis.#declarations.push(\n\t\t\t\t`function ${name}(${params}) {`,\n\t\t\t\t...indent([\n\t\t\t\t\t...start,\n\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t`for (; ${loop.index} < stop; ${loop.index}++) {`,\n\t\t\t\t\t\t...indent(this.#pass(loop, true)),\n\t\t\t\t\t\t...indent(continued(0)),\n\t\t\t\t\t\t`\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t\t\t\t`\\t\\twrite(run, out, s, ${loop.span});`,\n\t\t\t\t\t\t'\\t\\ts = \"\";',\n\t\t\t\t\t\t\"\\t}\",\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t...end,\n\t\t\t\t\t]),\n\t\t\t\t]),\n\t\t\t\t\"}\",\n\t\t\t);\n\t\t\tfor (let part = 1; part < segments.length; part++) {\n\t\t\t\tconst value = values[part] ?? null;\n\t\t\t\tthis.#declarations.push(\n\t\t\t\t\t`function ${name}_${part}(${partParams}${value === null ? \"\" : \", w\"}) {`,\n\t\t\t\t\t...indent([\n\t\t\t\t\t\t...start,\n\t\t\t\t\t\t...(value === null ? [] : [`${value} = w;`]),\n\t\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t\t...this.#pass(loop, false),\n\t\t\t\t\t\t\t...continued(part),\n\t\t\t\t\t\t\t...end,\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\t\"}\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn name;\n\t\t} finally {\n\t\t\tthis.#fn = outer;\n\t\t}\n\t}\n\n\t/**\n\t * The variables a loop's body sets, as a frozen list made once, and whether it places content from elsewhere, for\n\t * `passesAhead`.\n\t */\n\t#setsOf(statement: Extract<Statement, { type: \"For\" }>): {\n\t\tsets: string;\n\t\telsewhere: boolean;\n\t} {\n\t\tconst effects = effectsOf(statement.body, this.#env);\n\t\tconst names = [...effects.sets];\n\t\tconst sets = this.#constant(\n\t\t\t`sets:${JSON.stringify(names)}`,\n\t\t\t\"N\",\n\t\t\t`Object.freeze(${JSON.stringify(names)})`,\n\t\t);\n\t\treturn { sets, elsewhere: effects.elsewhere };\n\t}\n\n\t/**\n\t * A loop whose passes may pause anywhere, such as at a call to one of your functions, as a generator of its own over\n\t * the index to start at. It is declared where the loop is, so it reads the locals around it, such as the loops\n\t * outside. When a pass pauses, the passes after it start at once in another run of the generator, when they may;\n\t * see `startAhead`. The loop then stops after that pass and waits for them. Returns the generator's lines, or null\n\t * when no pass waits.\n\t */\n\t#loopGenerator(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t\tloop: LoopNames,\n\t): string[] | null {\n\t\tif (!effectsOf(statement.body, this.#env).waits) return null;\n\t\tconst outer = this.#fn;\n\t\tconst restore = this.#snapshot();\n\t\tthis.#fn = newFunction();\n\t\ttry {\n\t\t\tconst lines = this.#body(statement.body, { ...context, inLoop: true });\n\t\t\tif (!this.#fn.waits) {\n\t\t\t\trestore();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst name = `LG${loop.id}`;\n\t\t\tconst ahead = `a${loop.id}`;\n\t\t\tconst { index, span } = loop;\n\t\t\t// Only the first run of the generator starts passes ahead. The ones it starts run one pass each.\n\t\t\tconst { sets, elsewhere } = this.#setsOf(statement);\n\t\t\tconst fork = `if (${ahead} === null && ${index} + 1 < stop) ${ahead} = startAhead(run, ${loop.outer}, out, inl, ind, ${sets}, ${elsewhere}, ${index} + 1, stop, (run, out, j) => drive(${name}(run, out, j, j + 1)), ${span});`;\n\t\t\tconst body = this.#forgetLines(this.#setFlags(lines)).flatMap((line) => {\n\t\t\t\tif (line.trim() === FORK) return [line.replace(FORK, fork)];\n\t\t\t\tconst wait = WAIT_LINE.exec(line);\n\t\t\t\tif (!wait) return [line];\n\t\t\t\tconst [, tabs, result] = wait as unknown as [string, string, string];\n\t\t\t\treturn [\n\t\t\t\t\t`${tabs}if (${result} !== undefined) {`,\n\t\t\t\t\t`${tabs}\\t${fork}`,\n\t\t\t\t\t`${tabs}\\tyield ${result};`,\n\t\t\t\t\t`${tabs}}`,\n\t\t\t\t];\n\t\t\t});\n\t\t\tconst pass = this.#pass(loop, true);\n\t\t\tconst reads = this.#fn.reads;\n\t\t\treturn [\n\t\t\t\t`const ${name} = function* (run, out, ${index}, stop) {`,\n\t\t\t\t...indent([\n\t\t\t\t\t...this.#start(span),\n\t\t\t\t\t`let ${ahead} = null;`,\n\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t\"try {\",\n\t\t\t\t\t\t`\\tfor (; ${index} < stop; ${index}++) {`,\n\t\t\t\t\t\t...indent(indent([...pass, ...body])),\n\t\t\t\t\t\t`\\t\\tif (${ahead} !== null) break;`,\n\t\t\t\t\t\t`\\t\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t\t\t\t`\\t\\t\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t'\\t\\t\\ts = \"\";',\n\t\t\t\t\t\t\"\\t\\t}\",\n\t\t\t\t\t\t\"\\t}\",\n\t\t\t\t\t\t\"} catch (error) {\",\n\t\t\t\t\t\t`\\tif (${ahead} !== null) yield ${ahead}.fail(error);`,\n\t\t\t\t\t\t\"\\tthrow error;\",\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t`if (${ahead} !== null) {`,\n\t\t\t\t\t\t`\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t'\\ts = \"\";',\n\t\t\t\t\t\t\"\\tstate.steps = steps;\",\n\t\t\t\t\t\t// The passes ahead locate their own errors.\n\t\t\t\t\t\t...(reads ? [\"\\tat = null;\"] : []),\n\t\t\t\t\t\t`\\tyield ${ahead}.join();`,\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t\"state.steps = steps;\",\n\t\t\t\t\t\t`write(run, out, s, ${span});`,\n\t\t\t\t\t]),\n\t\t\t\t]),\n\t\t\t\t\"};\",\n\t\t\t];\n\t\t} finally {\n\t\t\tthis.#fn = outer;\n\t\t}\n\t}\n\n\t/**\n\t * `set`, through the closures' `assign`, so it finds the variable's scope as they do. Loop variables are locals in\n\t * generated code, so setting one stays with the closures.\n\t */\n\t#set(\n\t\tstatement: Extract<Statement, { type: \"Set\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tif (context.bindings.has(statement.name)) return unsupported();\n\t\tconst span = this.#span(statement.span);\n\t\tconst value = this.#temp();\n\t\treturn [\n\t\t\t`${this.#step(span)};`,\n\t\t\t...this.#value(statement.value, context, value),\n\t\t\t`assign(run, ${context.scope}, ${JSON.stringify(statement.name)}, ${value}, ${span});`,\n\t\t\t...this.#forget(statement.name),\n\t\t];\n\t}\n\n\t/** Forgets every variable lookup, after code that may set any variable, so later lookups start again. */\n\t#forgetAll(): string[] {\n\t\treturn [FORGET_ALL];\n\t}\n\n\t/** Writes out `FORGET_ALL`, once the current function's lookups are all known. */\n\t#forgetLines(lines: string[]): string[] {\n\t\tconst forget = [...this.#fn.variables.values()]\n\t\t\t.map(({ value }) => `${value} = undefined;`)\n\t\t\t.join(\" \");\n\t\treturn lines.map((line) =>\n\t\t\tline.endsWith(FORGET_ALL)\n\t\t\t\t? line.slice(0, -FORGET_ALL.length) + forget\n\t\t\t\t: line,\n\t\t);\n\t}\n\n\t/** Forgets lookups of a variable that `set` may have changed. */\n\t#forget(name: string): string[] {\n\t\treturn [\"plain\", \"guarded\"].flatMap((kind) => {\n\t\t\tconst cached = this.#fn.variables.get(`${kind}:${name}`);\n\t\t\treturn cached ? [`${cached.value} = undefined;`] : [];\n\t\t});\n\t}\n\n\t/**\n\t * Lines that put an expression's value in `target`. A call to one of your functions or filters may return a\n\t * promise, so it can only be the whole expression, and the function waits for it as a generator.\n\t */\n\t#value(node: Expression, context: Context, target: string): string[] {\n\t\treturn (\n\t\t\tthis.#hostCall(node, context, target) ?? [\n\t\t\t\t`${target} = ${this.#expr(node, context, false)};`,\n\t\t\t]\n\t\t);\n\t}\n\n\t/** Whether an expression is a call to one of your functions or filters, which `#hostCall` generates. */\n\t#isHostCall(node: Expression): node is HostCallNode {\n\t\tif (node.type === \"Call\") {\n\t\t\tconst callee = node.callee;\n\t\t\treturn (\n\t\t\t\tcallee.type === \"Name\" &&\n\t\t\t\t!this.#macros.has(callee.name) &&\n\t\t\t\tthis.#env.functions.get(callee.name)?.kind === \"host\"\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\tnode.type === \"Filter\" &&\n\t\t\tthis.#env.filters.get(node.name)?.kind === \"host\"\n\t\t);\n\t}\n\n\t#hostCall(\n\t\tnode: Expression,\n\t\tcontext: Context,\n\t\ttarget: string,\n\t): string[] | null {\n\t\tif (!this.#isHostCall(node)) return null;\n\t\tconst kind = node.type === \"Filter\" ? \"filter\" : \"function\";\n\t\tconst name = node.type === \"Filter\" ? node.name : node.callee.name;\n\t\tconst input = node.type === \"Filter\" ? node.input : null;\n\t\tconst args = node.args;\n\t\tif (args.some((arg) => arg.type !== \"Positional\")) return unsupported();\n\t\tconst fn = this.#constant(\n\t\t\t`host:${kind}:${name}`,\n\t\t\t\"X\",\n\t\t\t`rt.host(${JSON.stringify(kind)}, ${JSON.stringify(name)})`,\n\t\t);\n\t\tconst span = this.#span(node.span);\n\t\tconst values = [\n\t\t\t...(input ? [this.#expr(input, context, false)] : []),\n\t\t\t...args.map((arg) => this.#expr(arg.value, context, false)),\n\t\t];\n\t\tthis.#fn.waits = true;\n\t\tif (context.pass) {\n\t\t\treturn [\n\t\t\t\tthis.#checkedStep(span),\n\t\t\t\t\"state.steps = steps;\",\n\t\t\t\t`${target} = callHost(run, ${span}, ${fn}, [${values.join(\", \")}]);`,\n\t\t\t\t`${VALUE}${target} ${span} ${fn}`,\n\t\t\t\t\"steps = state.steps;\",\n\t\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t\t];\n\t\t}\n\t\tthis.#fn.waitsInside = true;\n\t\tthis.#fn.inner++;\n\t\treturn [\n\t\t\t// An abort, perhaps from a getter in your data, stops the render before your function is called, as `step` does.\n\t\t\tthis.#checkedStep(span),\n\t\t\t\"state.steps = steps;\",\n\t\t\t`${target} = callHost(run, ${span}, ${fn}, [${values.join(\", \")}]);`,\n\t\t\t`if (${target} instanceof Promise) {`,\n\t\t\t// The text so far goes out first, so a streamed render can send it while this waits.\n\t\t\t`\\twrite(run, out, s, ${span});`,\n\t\t\t'\\ts = \"\";',\n\t\t\t`\\t${FORK}`,\n\t\t\t\"\\ttry {\",\n\t\t\t`\\t\\t${target} = yield ${target};`,\n\t\t\t\"\\t} catch (error) {\",\n\t\t\t`\\t\\tthrow hostError(run, ${span}, ${fn}, error);`,\n\t\t\t\"\\t}\",\n\t\t\t\"}\",\n\t\t\t\"steps = state.steps;\",\n\t\t\t// Your function may have aborted the render, as the next step would notice in a template rendered from source.\n\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t];\n\t}\n\n\t/**\n\t * `props` without types: checks no undeclared names were passed in strict mode, then fills in defaults and nulls.\n\t * Typed props and rest props stay with the closures.\n\t */\n\t#props(\n\t\tstatement: Extract<Statement, { type: \"Props\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tif (statement.rest || statement.props.some((prop) => prop.type)) {\n\t\t\treturn unsupported();\n\t\t}\n\t\tconst span = this.#span(statement.span);\n\t\tconst names = statement.props.map((prop) => prop.name);\n\t\tconst declared = this.#constant(\n\t\t\t`props:${JSON.stringify(names)}`,\n\t\t\t\"P\",\n\t\t\t`rt.declared(${JSON.stringify(names)})`,\n\t\t);\n\t\tconst lines = [`checkPassed(run, ${span}, ${declared});`];\n\t\tfor (const prop of statement.props) {\n\t\t\tconst key = JSON.stringify(prop.name);\n\t\t\tconst has = this.#temp();\n\t\t\tconst current = this.#temp();\n\t\t\tconst fill = prop.default\n\t\t\t\t? `scope[${key}] = (${this.#expr(prop.default, context, false)}) ?? null;`\n\t\t\t\t: `if (!${has}) scope[${key}] = missingProp(run, ${span}, ${key});`;\n\t\t\t// The prop is now set in this scope, so it seeds the lookup later reads use, unless it holds a function,\n\t\t\t// which a read must refuse. A default may have looked the prop up before it was set.\n\t\t\tconst cached = this.#cached(prop.name, false);\n\t\t\tconst guarded = this.#fn.variables.get(`guarded:${prop.name}`);\n\t\t\tlines.push(\n\t\t\t\t`${has} = hasOwn(scope, ${key});`,\n\t\t\t\t`${current} = ${has} ? scope[${key}] : undefined;`,\n\t\t\t\t`if (${current} === undefined || ${current} === null) {`,\n\t\t\t\t`\\t${fill}`,\n\t\t\t\t`\\t${current} = scope[${key}];`,\n\t\t\t\t\"}\",\n\t\t\t\t`${cached.value} = typeof ${current} === \"function\" ? undefined : ${current}${setPlain(cached.plain, current)};`,\n\t\t\t\t...(guarded ? [`${guarded.value} = undefined;`] : []),\n\t\t\t);\n\t\t}\n\t\treturn lines;\n\t}\n\n\t#include(\n\t\tstatement: Extract<Statement, { type: \"Include\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst target = this.#target(statement.template, statement.with, context);\n\t\tconst variables = this.#variables(statement.with, context);\n\t\treturn [\n\t\t\t`${this.#step(span)};`,\n\t\t\t...target.lines,\n\t\t\t...variables.lines,\n\t\t\t...variables.charge(span),\n\t\t\t...this.#wait(\n\t\t\t\tspan,\n\t\t\t\tthis.#place(\n\t\t\t\t\tstatement.indent,\n\t\t\t\t\tvariables.embed(span, target.name, \"null\", statement.ignoreMissing),\n\t\t\t\t),\n\t\t\t\tcontext.top,\n\t\t\t),\n\t\t];\n\t}\n\n\t/**\n\t * An include's or component's template name. `\"prefix\" ~ key`, with a known `with` hash, keeps the key apart, so\n\t * `embedKeyed` can find the template without building the name; a key that isn't a string is joined as usual.\n\t */\n\t#target(\n\t\tnode: Expression,\n\t\twithNode: Expression | null,\n\t\tcontext: Context,\n\t): { lines: string[]; name: TemplateTarget } {\n\t\tif (\n\t\t\tisKnownWith(withNode) &&\n\t\t\tnode.type === \"Binary\" &&\n\t\t\tnode.operator === \"~\" &&\n\t\t\tnode.left.type === \"Literal\" &&\n\t\t\ttypeof node.left.value === \"string\"\n\t\t) {\n\t\t\tconst prefix = node.left.value;\n\t\t\tconst key = this.#temp();\n\t\t\tconst joined = this.#temp();\n\t\t\tconst nameSpan = this.#span(node.span);\n\t\t\treturn {\n\t\t\t\tlines: [\n\t\t\t\t\t`${key} = ${this.#expr(node.right, context, false)};`,\n\t\t\t\t\t`${joined} = typeof ${key} === \"string\" ? null : concat(run, ${nameSpan}, ${JSON.stringify(prefix)}, ${key});`,\n\t\t\t\t],\n\t\t\t\tname: { kind: \"keyed\", prefix, key, joined, nameSpan },\n\t\t\t};\n\t\t}\n\t\tconst js = this.#temp();\n\t\treturn {\n\t\t\tlines: [`${js} = ${this.#expr(node, context, false)};`],\n\t\t\tname: { kind: \"value\", js },\n\t\t};\n\t}\n\n\t/**\n\t * An include's or component's `with` value. A hash of known keys, or none, becomes the template's scope here, so\n\t * no hash is made and copied, and each name passed counts a step, as `embed` counts them; anything else is passed\n\t * to `embed`, which checks, counts and copies it.\n\t */\n\t#variables(\n\t\tnode: Expression | null,\n\t\tcontext: Context,\n\t): {\n\t\tlines: string[];\n\t\t/** Lines that count the steps for the names passed, at the tag. */\n\t\tcharge: (span: string) => string[];\n\t\tembed: (\n\t\t\tspan: string,\n\t\t\tname: TemplateTarget,\n\t\t\tslots: string,\n\t\t\tignoreMissing: boolean,\n\t\t) => string;\n\t} {\n\t\tif (node !== null && !isKnownWith(node)) {\n\t\t\tconst value = this.#temp();\n\t\t\treturn {\n\t\t\t\tlines: [`${value} = ${this.#expr(node, context, false)};`],\n\t\t\t\tcharge: () => [],\n\t\t\t\tembed: (span, name, slots, ignoreMissing) =>\n\t\t\t\t\t`embed(run, out, ${span}, ${(name as { js: string }).js}, ${value}, ${slots}, ${ignoreMissing})`,\n\t\t\t};\n\t\t}\n\t\tconst scope = this.#temp();\n\t\tconst lines = [`${scope} = childScope(state.globals);`];\n\t\t// The names passed, in the order a hash holds its keys, as `embed` lists them: whole numbers first.\n\t\tconst order: Record<string, true> = Object.create(null);\n\t\tfor (const entry of node?.type === \"Hash\" ? node.entries : []) {\n\t\t\tif (entry.type !== \"Property\") return unsupported();\n\t\t\tconst key = String((entry.key as { value: unknown }).value);\n\t\t\torder[key] = true;\n\t\t\tlines.push(\n\t\t\t\t`${scope}[${JSON.stringify(key)}] = (${this.#expr(entry.value, context, false)}) ?? null;`,\n\t\t\t);\n\t\t}\n\t\tconst keys = Object.keys(order);\n\t\tconst passed = this.#constant(\n\t\t\t`passed:${JSON.stringify(keys)}`,\n\t\t\t\"P\",\n\t\t\t`Object.freeze(${JSON.stringify(keys)})`,\n\t\t);\n\t\treturn {\n\t\t\tlines,\n\t\t\tcharge: (span) =>\n\t\t\t\tkeys.length === 0\n\t\t\t\t\t? []\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t`if ((steps += ${keys.length}) > maxSteps) stepLimit(run, ${span});`,\n\t\t\t\t\t\t],\n\t\t\tembed: (span, name, slots, ignoreMissing) => {\n\t\t\t\tconst rest = `${scope}, ${passed}, ${slots}, ${ignoreMissing})`;\n\t\t\t\treturn name.kind === \"keyed\"\n\t\t\t\t\t? `(${name.joined} === null ? embedKeyed(run, out, ${span}, ${JSON.stringify(name.prefix)}, ${name.key}, ${name.nameSpan}, ${rest} : embedScope(run, out, ${span}, ${name.joined}, ${rest})`\n\t\t\t\t\t: `embedScope(run, out, ${span}, ${name.js}, ${rest}`;\n\t\t\t},\n\t\t};\n\t}\n\n\t/** A component. Its fills become functions here, so they can read the loops around them. */\n\t#component(\n\t\tstatement: Extract<Statement, { type: \"Component\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst fills = statement.fills.map((fill) => ({\n\t\t\tname: fill.name,\n\t\t\tbody: fill.body,\n\t\t}));\n\t\tif (statement.body.some((child) => !isBlank(child))) {\n\t\t\tfills.push({ name: DEFAULT_SLOT, body: statement.body });\n\t\t}\n\t\tconst slots = this.#temp();\n\t\tconst target = this.#target(statement.template, statement.with, context);\n\t\tconst variables = this.#variables(statement.with, context);\n\t\treturn [\n\t\t\t`${this.#step(span)};`,\n\t\t\t...target.lines,\n\t\t\t...variables.lines,\n\t\t\t`${slots} = new Map();`,\n\t\t\t...fills.map(\n\t\t\t\t(fill) =>\n\t\t\t\t\t`${slots}.set(${JSON.stringify(fill.name)}, { body: ${this.#nested(fill.body, statement.span, context)}, run, scope: ${context.scope}, sets: ${mayWrite(fill.body)} });`,\n\t\t\t),\n\t\t\t...variables.charge(span),\n\t\t\t...this.#wait(\n\t\t\t\tspan,\n\t\t\t\tthis.#place(\n\t\t\t\t\tstatement.indent,\n\t\t\t\t\tvariables.embed(span, target.name, slots, false),\n\t\t\t\t),\n\t\t\t\tcontext.top,\n\t\t\t),\n\t\t\t// Fills render in this scope, and may set variables in it, as may a block they place.\n\t\t\t...(fills.some((fill) => setsVariables(fill.body))\n\t\t\t\t? this.#forgetAll()\n\t\t\t\t: fills.some((fill) =>\n\t\t\t\t\t\t\tcontainsNode(fill.body, (record) => record.type === \"Block\"),\n\t\t\t\t\t )\n\t\t\t\t\t? this.#afterBlocks()\n\t\t\t\t\t: []),\n\t\t];\n\t}\n\n\t/** A slot: the caller's fill, or the fallback. */\n\t#slot(\n\t\tstatement: Extract<Statement, { type: \"Slot\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst fill = this.#temp();\n\t\tconst at = statement.indent;\n\t\t// The fallback renders in a scope of its own, so variables it declares stay inside it.\n\t\tconst sets = [...setsIn(statement.body)];\n\t\tconst scope = sets.length > 0 ? this.#temp() : context.scope;\n\t\tlet fallback = this.#body(statement.body, { ...context, scope });\n\t\tif (sets.length > 0) {\n\t\t\tfallback = [\n\t\t\t\t`${scope} = childScope(${context.scope});`,\n\t\t\t\t...fallback,\n\t\t\t\t...sets.flatMap((name) => this.#forget(name)),\n\t\t\t];\n\t\t}\n\t\tif (at !== \"\" && !statement.body.every(isBlank)) {\n\t\t\t// The fallback's text reads a new `ind`, inside a block of its own.\n\t\t\tconst [saved, inline] = [this.#temp(), this.#temp()];\n\t\t\tfallback = [\n\t\t\t\t`${saved} = out.indent;`,\n\t\t\t\t`${inline} = out.inline;`,\n\t\t\t\t`startPlace(out, ${this.#at(at)});`,\n\t\t\t\t\"{\",\n\t\t\t\t...indent([\"const ind = out.indent;\", ...fallback]),\n\t\t\t\t\"}\",\n\t\t\t\t`out.indent = ${saved};`,\n\t\t\t\t`if (out.inline) out.inline = ${inline};`,\n\t\t\t];\n\t\t}\n\t\treturn [\n\t\t\t`${fill} = run.slots === null ? undefined : run.slots.get(${JSON.stringify(statement.name)});`,\n\t\t\t`if (${fill} !== undefined) {`,\n\t\t\t...indent(\n\t\t\t\tthis.#wait(\n\t\t\t\t\tspan,\n\t\t\t\t\tthis.#place(at, `fillSlot(run, ${span}, ${fill}, out)`),\n\t\t\t\t\tcontext.top,\n\t\t\t\t),\n\t\t\t),\n\t\t\t\"} else {\",\n\t\t\t...indent(fallback),\n\t\t\t\"}\",\n\t\t];\n\t}\n\n\t/**\n\t * Places a block. The closure compiler keeps the block's definition, so its body is searched for runs separately.\n\t * Blocks inside generated loops stay with the closures, since a block can read the loop it is placed in.\n\t */\n\t#block(\n\t\tstatement: Extract<Statement, { type: \"Block\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tif (context.inLoop) return unsupported();\n\t\tthis.#pending.push([statement.body, context.strategy]);\n\t\tconst span = this.#span(statement.span);\n\t\treturn [\n\t\t\t...this.#wait(\n\t\t\t\tspan,\n\t\t\t\tthis.#place(\n\t\t\t\t\tstatement.indent,\n\t\t\t\t\t`placeBlock(run, ${span}, ${JSON.stringify(statement.name)}, ${context.scope}, out)`,\n\t\t\t\t),\n\t\t\t\tcontext.top,\n\t\t\t),\n\t\t\t...this.#afterBlocks(),\n\t\t];\n\t}\n\n\t/** Forgets every variable lookup after a block is placed when the block, perhaps a child template's version, may set any variable. */\n\t#afterBlocks(): string[] {\n\t\treturn [\"if (blockSets(run)) {\", ...indent(this.#forgetAll()), \"}\"];\n\t}\n\n\t// Expressions\n\n\t/** Writes an expression. `guard` is set where a missing variable or property is allowed; see `MISSING`. */\n\t#expr(node: Expression, context: Context, guard: boolean): string {\n\t\tif (++this.#depth > MAX_DEPTH) return unsupported();\n\t\ttry {\n\t\t\treturn this.#expression(node, context, guard);\n\t\t} finally {\n\t\t\tthis.#depth--;\n\t\t}\n\t}\n\n\t#expression(node: Expression, context: Context, guard: boolean): string {\n\t\tswitch (node.type) {\n\t\t\tcase \"Literal\":\n\t\t\t\treturn literal(node.value);\n\t\t\tcase \"Name\":\n\t\t\t\treturn this.#name(node.name, node.span, context, guard);\n\t\t\tcase \"Member\":\n\t\t\t\treturn this.#member(node, context, guard);\n\t\t\tcase \"OptionalChain\": {\n\t\t\t\tconst value = this.#temp();\n\t\t\t\tconst inner = this.#expr(node.expression, context, true);\n\t\t\t\treturn `(${value} = ${inner}, ${value} === SHORT || ${value} === MISSING ? ${guard ? \"MISSING\" : \"null\"} : ${value})`;\n\t\t\t}\n\t\t\tcase \"Unary\":\n\t\t\t\treturn this.#unary(node, context);\n\t\t\tcase \"Binary\":\n\t\t\t\treturn this.#binary(node, context);\n\t\t\tcase \"Conditional\": {\n\t\t\t\tconst test = this.#condition(node.test, context);\n\t\t\t\tconst yes = this.#expr(node.consequent, context, false);\n\t\t\t\tconst no = node.alternate\n\t\t\t\t\t? this.#expr(node.alternate, context, false)\n\t\t\t\t\t: \"null\";\n\t\t\t\treturn `(${test} ? ${yes} : ${no})`;\n\t\t\t}\n\t\t\tcase \"Filter\":\n\t\t\t\treturn this.#filter(node, context);\n\t\t\tcase \"Test\":\n\t\t\t\treturn this.#test(node, context);\n\t\t\tcase \"Call\":\n\t\t\t\treturn this.#call(node, context);\n\t\t\tcase \"Array\":\n\t\t\t\treturn `[${node.elements\n\t\t\t\t\t.map((element) =>\n\t\t\t\t\t\telement.type === \"Spread\"\n\t\t\t\t\t\t\t? unsupported()\n\t\t\t\t\t\t\t: this.#expr(element, context, false),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\", \")}]`;\n\t\t\tcase \"Hash\":\n\t\t\t\treturn `{ ${node.entries\n\t\t\t\t\t.map((entry) => {\n\t\t\t\t\t\tif (entry.type === \"Spread\" || entry.key.type !== \"Literal\") {\n\t\t\t\t\t\t\treturn unsupported();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst key = String(entry.key.value);\n\t\t\t\t\t\tif (key === \"__proto__\") return unsupported();\n\t\t\t\t\t\treturn `${JSON.stringify(key)}: ${this.#expr(entry.value, context, false)}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\", \")} }`;\n\t\t\tcase \"Interpolation\": {\n\t\t\t\tconst span = this.#span(node.span);\n\t\t\t\tconst parts = node.parts.map((part) => {\n\t\t\t\t\tconst value = this.#temp();\n\t\t\t\t\treturn { value, code: this.#expr(part, context, false) };\n\t\t\t\t});\n\t\t\t\tconst assigned = parts.map(({ value, code }) => `${value} = ${code}`);\n\t\t\t\tconst joined = parts\n\t\t\t\t\t.map(({ value }) => `str(run, ${span}, ${value})`)\n\t\t\t\t\t.join(\" + \");\n\t\t\t\treturn `(${[...assigned, `joined(run, ${span}, ${joined || '\"\"'})`].join(\", \")})`;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn unsupported();\n\t\t}\n\t}\n\n\t#name(name: string, at: Span, context: Context, guard: boolean): string {\n\t\tconst binding = context.bindings.get(name);\n\t\tconst span = this.#span(at);\n\t\tif (binding?.kind === \"value\") {\n\t\t\tconst js = binding.js;\n\t\t\treturn `(typeof ${js} === \"function\" ? checkValue(run, ${span}, ${js}, ${JSON.stringify(name)}) : ${js})`;\n\t\t}\n\t\tif (binding?.kind === \"loop\") {\n\t\t\treturn `loop(${binding.index}, ${binding.length})`;\n\t\t}\n\t\t// A missing variable still fails where it is first used, as nothing is stored until a lookup succeeds.\n\t\tconst { value, plain } = this.#cached(name, guard);\n\t\treturn `(${value} !== undefined ? ${value} : (${value} = ${guard ? \"guardedName\" : \"name\"}(run, ${span}, ${context.scope}, ${JSON.stringify(name)})${setPlain(plain, value)}, ${value}))`;\n\t}\n\n\t#cached(name: string, guard: boolean): Cached {\n\t\tconst key = `${guard ? \"guarded\" : \"plain\"}:${name}`;\n\t\tlet cached = this.#fn.variables.get(key);\n\t\tif (cached === undefined) {\n\t\t\tconst index = this.#fn.variables.size;\n\t\t\tcached = { value: `${guard ? \"g\" : \"c\"}${index}`, plain: `f${index}` };\n\t\t\tthis.#fn.variables.set(key, cached);\n\t\t}\n\t\treturn cached;\n\t}\n\n\t#member(\n\t\tnode: Extract<Expression, { type: \"Member\" }>,\n\t\tcontext: Context,\n\t\tguard: boolean,\n\t): string {\n\t\tconst span = this.#span(node.span);\n\t\tconst { object, property, optional } = node;\n\t\tconst flags = `${optional}, ${guard}`;\n\t\tif (property.type !== \"Literal\") {\n\t\t\tconst value = this.#temp();\n\t\t\tconst target = this.#expr(object, context, guard);\n\t\t\tconst key = this.#expr(property, context, false);\n\t\t\t// A chain that stops at a `?.` leaves the key unevaluated.\n\t\t\tconst stops = optional\n\t\t\t\t? `${value} === SHORT || ${value} === MISSING || ${value} === null || ${value} === undefined`\n\t\t\t\t: `${value} === SHORT`;\n\t\t\treturn `(${value} = ${target}, ${stops} ? SHORT : readMember(run, ${span}, ${value}, ${key}, ${flags}))`;\n\t\t}\n\t\tconst key = property.value;\n\t\t// `loop.index` and the rest read the loop's counter.\n\t\tif (object.type === \"Name\" && typeof key === \"string\") {\n\t\t\tconst binding = context.bindings.get(object.name);\n\t\t\tconst field = LOOP_FIELDS[key];\n\t\t\tif (\n\t\t\t\tbinding?.kind === \"loop\" &&\n\t\t\t\tfield &&\n\t\t\t\tObject.hasOwn(LOOP_FIELDS, key)\n\t\t\t) {\n\t\t\t\treturn field(binding.index, binding.length);\n\t\t\t}\n\t\t}\n\t\tif (typeof key !== \"string\" || BLOCKED_NAMES.has(key)) {\n\t\t\tconst target = this.#expr(object, context, guard);\n\t\t\treturn `readMember(run, ${span}, ${target}, ${literal(key)}, ${flags})`;\n\t\t}\n\t\t// Own properties of plain objects are read inline, through a property access V8 caches for this one place. A value\n\t\t// can only be inherited if it is the one `Object.prototype` holds, so only then is the property checked to be own.\n\t\tconst value = this.#temp();\n\t\tconst item = this.#temp();\n\t\tconst read = access(key);\n\t\tconst known = this.#plainObject(object, context, guard, value);\n\t\tconst site = this.#constant(\n\t\t\t`read:${span}:${key}`,\n\t\t\t\"P\",\n\t\t\t`[${span}, ${JSON.stringify(key)}]`,\n\t\t);\n\t\tthis.#fn.reads = true;\n\t\t// The object is read first, since reading it may set `at` for its own property.\n\t\treturn [\n\t\t\t`(${known.target}, at = ${site}, ${known.plain}`,\n\t\t\t`&& (${item} = ${value}${read}) !== undefined && typeof ${item} !== \"function\"`,\n\t\t\t`&& (${item} !== objectPrototype${read} || hasOwn(${value}, ${JSON.stringify(key)}))`,\n\t\t\t`? ${item} : readMember(run, ${span}, ${known.slow}, ${JSON.stringify(key)}, ${flags}))`,\n\t\t].join(\" \");\n\t}\n\n\t/**\n\t * The object a property is read from, put in `value`, and a check that it is a plain object. Variables already\n\t * know: a loop variable is checked once per pass, and a variable from outside once per run. `slow` is the object\n\t * for `readMember`, checked as a variable would be when it is a loop variable holding a function.\n\t */\n\t#plainObject(\n\t\tobject: Expression,\n\t\tcontext: Context,\n\t\tguard: boolean,\n\t\tvalue: string,\n\t): { target: string; plain: string; slow: string } {\n\t\tif (object.type === \"Name\") {\n\t\t\tconst binding = context.bindings.get(object.name);\n\t\t\tif (binding?.kind === \"value\") {\n\t\t\t\tthis.#plainUsed.add(binding.plain);\n\t\t\t\tconst span = this.#span(object.span);\n\t\t\t\treturn {\n\t\t\t\t\ttarget: `${value} = ${binding.js}`,\n\t\t\t\t\tplain: binding.plain,\n\t\t\t\t\tslow: `(typeof ${value} === \"function\" ? checkValue(run, ${span}, ${value}, ${JSON.stringify(object.name)}) : ${value})`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (binding === undefined) {\n\t\t\t\tconst target = this.#name(object.name, object.span, context, guard);\n\t\t\t\tconst { plain } = this.#cached(object.name, guard);\n\t\t\t\tthis.#fn.plainUsed.add(plain);\n\t\t\t\treturn { target: `${value} = ${target}`, plain, slow: value };\n\t\t\t}\n\t\t}\n\t\tconst target = this.#expr(object, context, guard);\n\t\treturn {\n\t\t\ttarget: `${value} = ${target}`,\n\t\t\tplain: isPlainCode(value),\n\t\t\tslow: value,\n\t\t};\n\t}\n\n\t/** An expression as a JavaScript boolean, without `truthy` when it is one already, such as a comparison. */\n\t#condition(node: Expression, context: Context): string {\n\t\tconst code = this.#expr(node, context, false);\n\t\treturn isBoolean(node, context) ? code : `truthy(${code})`;\n\t}\n\n\t#unary(\n\t\tnode: Extract<Expression, { type: \"Unary\" }>,\n\t\tcontext: Context,\n\t): string {\n\t\tif (node.operator === \"not\")\n\t\t\treturn `!${this.#condition(node.operand, context)}`;\n\t\tconst operand = this.#expr(node.operand, context, false);\n\t\tconst span = this.#span(node.span);\n\t\tconst value = this.#temp();\n\t\tconst number = `toNumber(run, ${span}, ${value}, ${JSON.stringify(node.operator)})`;\n\t\treturn node.operator === \"-\"\n\t\t\t? `(${value} = ${operand}, typeof ${value} === \"number\" ? -${value} : -${number})`\n\t\t\t: `(${value} = ${operand}, typeof ${value} === \"number\" ? ${value} : ${number})`;\n\t}\n\n\t#binary(\n\t\tnode: Extract<Expression, { type: \"Binary\" }>,\n\t\tcontext: Context,\n\t): string {\n\t\tconst { operator } = node;\n\t\tswitch (operator) {\n\t\t\tcase \"and\":\n\t\t\t\treturn `(${this.#condition(node.left, context)} ? ${this.#condition(node.right, context)} : false)`;\n\t\t\tcase \"or\":\n\t\t\t\treturn `(${this.#condition(node.left, context)} ? true : ${this.#condition(node.right, context)})`;\n\t\t\tcase \"??\": {\n\t\t\t\tconst value = this.#temp();\n\t\t\t\tconst left = this.#expr(node.left, context, true);\n\t\t\t\tconst right = this.#expr(node.right, context, false);\n\t\t\t\treturn `(${value} = ${left}, ${value} === MISSING || ${value} === null || ${value} === undefined ? ${right} : ${value})`;\n\t\t\t}\n\t\t\tcase \"?:\": {\n\t\t\t\tconst value = this.#temp();\n\t\t\t\tconst left = this.#expr(node.left, context, false);\n\t\t\t\tconst right = this.#expr(node.right, context, false);\n\t\t\t\treturn `(${value} = ${left}, truthy(${value}) ? ${value} : ${right})`;\n\t\t\t}\n\t\t}\n\t\tconst span = this.#span(node.span);\n\t\tconst left = this.#expr(node.left, context, false);\n\t\tconst right = this.#expr(node.right, context, false);\n\t\tswitch (operator) {\n\t\t\tcase \"..\":\n\t\t\t\treturn this.#counted(`range(run, ${span}, ${left}, ${right})`);\n\t\t\tcase \"~\": {\n\t\t\t\t// Two strings join here when the result fits the output limit; anything else goes to `concat`.\n\t\t\t\tconst a = this.#temp();\n\t\t\t\tconst b = this.#temp();\n\t\t\t\treturn `(${a} = ${left}, ${b} = ${right}, typeof ${a} === \"string\" && typeof ${b} === \"string\" && ${a}.length + ${b}.length <= maxSize ? ${a} + ${b} : concat(run, ${span}, ${a}, ${b}))`;\n\t\t\t}\n\t\t\tcase \"==\":\n\t\t\t\treturn `equals(${left}, ${right})`;\n\t\t\tcase \"!=\":\n\t\t\t\treturn `!equals(${left}, ${right})`;\n\t\t\tcase \"in\":\n\t\t\t\treturn this.#counted(`contains(run, ${span}, ${left}, ${right})`);\n\t\t\tcase \"not in\":\n\t\t\t\treturn `!${this.#counted(`contains(run, ${span}, ${left}, ${right})`)}`;\n\t\t}\n\t\tconst apply = this.#constant(\n\t\t\t`operator:${operator}`,\n\t\t\t\"O\",\n\t\t\t`rt.operator(${JSON.stringify(operator)})`,\n\t\t);\n\t\tif (!NUMBER_OPERATORS.has(operator)) {\n\t\t\treturn `binary(run, ${span}, ${apply}, ${left}, ${right})`;\n\t\t}\n\t\tconst a = this.#temp();\n\t\tconst b = this.#temp();\n\t\treturn `(${a} = ${left}, ${b} = ${right}, typeof ${a} === \"number\" && typeof ${b} === \"number\" ? ${a} ${operator} ${b} : binary(run, ${span}, ${apply}, ${a}, ${b}))`;\n\t}\n\n\t#filter(\n\t\tnode: Extract<Expression, { type: \"Filter\" }>,\n\t\tcontext: Context,\n\t): string {\n\t\tconst { name, args } = node;\n\t\tconst span = this.#span(node.span);\n\t\tconst strategy = context.strategy || \"html\";\n\t\tif (name === \"default\") {\n\t\t\tconst value = this.#temp();\n\t\t\tconst input = this.#expr(node.input, context, true);\n\t\t\tconst fallback = args[0]\n\t\t\t\t? this.#expr(args[0].value, context, false)\n\t\t\t\t: '\"\"';\n\t\t\treturn `(${value} = ${input}, ${value} === MISSING || isEmpty(${value}) ? ${fallback} : ${value})`;\n\t\t}\n\t\tconst input = this.#expr(node.input, context, false);\n\t\tif (name === \"raw\") {\n\t\t\treturn `raw(run, ${span}, ${input}, ${JSON.stringify(strategy)})`;\n\t\t}\n\t\tif (name === \"escape\") {\n\t\t\tconst chosen = args[0] ? args[0].value : null;\n\t\t\tconst target =\n\t\t\t\tchosen === null\n\t\t\t\t\t? \"html\"\n\t\t\t\t\t: chosen.type === \"Literal\" &&\n\t\t\t\t\t\t ESCAPE_STRATEGIES.includes(chosen.value as EscapeStrategy)\n\t\t\t\t\t\t? (chosen.value as EscapeStrategy)\n\t\t\t\t\t\t: unsupported();\n\t\t\treturn `escape(run, ${span}, ${input}, ${JSON.stringify(target)})`;\n\t\t}\n\t\tconst call = this.#builtin(\"filter\", name, args);\n\t\treturn this.#invoke(span, call.fn, [\n\t\t\tinput,\n\t\t\t...this.#arguments(call, context),\n\t\t]);\n\t}\n\n\t#test(node: Extract<Expression, { type: \"Test\" }>, context: Context): string {\n\t\tconst { name, negated, input } = node;\n\t\tif (name === \"defined\") {\n\t\t\tif (\n\t\t\t\tinput.type === \"Call\" &&\n\t\t\t\tinput.callee.type === \"Name\" &&\n\t\t\t\tinput.callee.name === \"block\"\n\t\t\t) {\n\t\t\t\treturn unsupported();\n\t\t\t}\n\t\t\tconst value = this.#expr(input, context, true);\n\t\t\treturn `(${value} ${negated ? \"===\" : \"!==\"} MISSING)`;\n\t\t}\n\t\tconst span = this.#span(node.span);\n\t\tconst call = this.#builtin(\"test\", name, node.args);\n\t\t// `odd` and `even` never fail and count no steps of their own, so they are written out, after the call's step.\n\t\t// The built-in is still looked up, so a module loaded where `odd` is something else fails as usual.\n\t\tif ((name === \"odd\" || name === \"even\") && node.args.length === 0) {\n\t\t\tconst value = this.#temp();\n\t\t\tconst test =\n\t\t\t\tname === \"even\"\n\t\t\t\t\t? `${value} % 2 === 0`\n\t\t\t\t\t: `(${value} % 2 === 1 || ${value} % 2 === -1)`;\n\t\t\treturn `(${this.#step(span)}, ${value} = ${this.#expr(input, context, false)}, ${negated ? \"!\" : \"\"}(typeof ${value} === \"number\" && ${test}))`;\n\t\t}\n\t\tconst value = this.#invoke(span, call.fn, [\n\t\t\tthis.#expr(input, context, false),\n\t\t\t...this.#arguments(call, context),\n\t\t]);\n\t\treturn `${negated ? \"!\" : \"\"}truthy(${value})`;\n\t}\n\n\t#call(node: Extract<Expression, { type: \"Call\" }>, context: Context): string {\n\t\tconst callee = node.callee;\n\t\tif (\n\t\t\tcallee.type !== \"Name\" ||\n\t\t\tcallee.name === \"parent\" ||\n\t\t\tcallee.name === \"block\" ||\n\t\t\tthis.#macros.has(callee.name)\n\t\t) {\n\t\t\treturn unsupported();\n\t\t}\n\t\tconst span = this.#span(node.span);\n\t\tconst call = this.#builtin(\"function\", callee.name, node.args);\n\t\treturn this.#invoke(span, call.fn, this.#arguments(call, context));\n\t}\n\n\t/** A built-in, with its arguments in parameter order. Host functions may return promises, so they stay with the closures. */\n\t#builtin(\n\t\tkind: \"filter\" | \"test\" | \"function\",\n\t\tname: string,\n\t\targs: Argument[],\n\t): { fn: string; args: (Argument | null)[]; options: number } {\n\t\tconst entries =\n\t\t\tkind === \"filter\"\n\t\t\t\t? this.#env.filters\n\t\t\t\t: kind === \"test\"\n\t\t\t\t\t? this.#env.tests\n\t\t\t\t\t: this.#env.functions;\n\t\tconst entry = entries.get(name);\n\t\tif (entry?.kind !== \"builtin\") return unsupported();\n\t\tconst placed = placeArguments(entry, args, name, unsupported);\n\t\tif (placed.some((arg) => arg?.type === \"Spread\")) return unsupported();\n\t\tconst lookup = kind === \"function\" ? \"fn\" : kind;\n\t\tconst fn = this.#constant(\n\t\t\t`${kind}:${name}`,\n\t\t\tkind === \"filter\" ? \"F\" : kind === \"test\" ? \"T\" : \"B\",\n\t\t\t`rt.${lookup}(${JSON.stringify(name)})`,\n\t\t);\n\t\treturn {\n\t\t\tfn,\n\t\t\targs: placed,\n\t\t\toptions: entry.options ? (entry.params?.length ?? 0) : -1,\n\t\t};\n\t}\n\n\t/** Arguments in order. A built-in's options hash of literals is made once, frozen, so formatters can cache by it. */\n\t#arguments(\n\t\tcall: { args: (Argument | null)[]; options: number },\n\t\tcontext: Context,\n\t): string[] {\n\t\treturn call.args.map((arg, index) => {\n\t\t\tif (!arg) return \"undefined\";\n\t\t\tconst value = arg.value;\n\t\t\tif (index === call.options && value.type === \"Hash\") {\n\t\t\t\tconst frozen = this.#frozenHash(value);\n\t\t\t\tif (frozen) return frozen;\n\t\t\t}\n\t\t\treturn this.#expr(value, context, false);\n\t\t});\n\t}\n\n\t#frozenHash(node: Extract<Expression, { type: \"Hash\" }>): string | null {\n\t\tconst entries: string[] = [];\n\t\tfor (const entry of node.entries) {\n\t\t\tif (entry.type !== \"Property\" || entry.key.type !== \"Literal\")\n\t\t\t\treturn null;\n\t\t\tif (entry.value.type !== \"Literal\") return null;\n\t\t\tconst key = String(entry.key.value);\n\t\t\tif (key === \"__proto__\") return null;\n\t\t\tentries.push(`${JSON.stringify(key)}: ${literal(entry.value.value)}`);\n\t\t}\n\t\tconst code = `rt.options({ ${entries.join(\", \")} })`;\n\t\treturn this.#constant(`hash:${code}`, \"H\", code);\n\t}\n\n\t/** Counts a step, then calls a built-in with errors located at `span`, as `directCall` does. */\n\t#invoke(span: string, fn: string, args: string[]): string {\n\t\tif (args.length > 4) return unsupported();\n\t\treturn `(${this.#step(span)}, ${this.#counted(`call${args.length}(run, ${span}, ${fn}${args.map((arg) => `, ${arg}`).join(\"\")})`)})`;\n\t}\n}\n","/** Obsolete elements in the HTML standard, by what to use instead. */\nexport const OBSOLETE = new Map(\n\tObject.entries({\n\t\t\"Use <abbr> instead\": [\"acronym\"],\n\t\t\"Use <object> or <embed> instead\": [\"applet\"],\n\t\t\"Use CSS instead\": [\n\t\t\t\"basefont\",\n\t\t\t\"big\",\n\t\t\t\"blink\",\n\t\t\t\"center\",\n\t\t\t\"font\",\n\t\t\t\"marquee\",\n\t\t\t\"multicol\",\n\t\t\t\"nobr\",\n\t\t\t\"spacer\",\n\t\t],\n\t\t\"Use <audio> instead\": [\"bgsound\"],\n\t\t\"Use <ul> instead\": [\"dir\"],\n\t\t\"Use <iframe>, or a layout with CSS, instead\": [\n\t\t\t\"frame\",\n\t\t\t\"frameset\",\n\t\t\t\"noframes\",\n\t\t],\n\t\t\"Use a form with a text field instead\": [\"isindex\"],\n\t\t\"Use the Web Crypto API instead\": [\"keygen\"],\n\t\t\"Use <pre> and <code> instead\": [\"listing\", \"plaintext\", \"xmp\"],\n\t\t\"Use a <button> inside <menu> instead\": [\"menuitem\"],\n\t\t\"Remove it\": [\"nextid\"],\n\t\t\"Use fallback content inside <object> instead\": [\"noembed\"],\n\t\t\"Use attributes on <object> instead\": [\"param\"],\n\t\t\"Use <ruby> with <rt> instead\": [\"rb\", \"rtc\"],\n\t\t\"Use <s>, or <del> for removed text, instead\": [\"strike\"],\n\t\t\"Use <code>, <kbd> or <samp> instead\": [\"tt\"],\n\t}).flatMap(([advice, names]) => names.map((name) => [name, advice] as const)),\n);\n\n/** States and properties from WAI-ARIA 1.2, plus those the 1.3 draft adds. */\nexport const ARIA_ATTRIBUTES = new Set(\n\t[\n\t\t\"activedescendant\",\n\t\t\"atomic\",\n\t\t\"autocomplete\",\n\t\t\"braillelabel\",\n\t\t\"brailleroledescription\",\n\t\t\"busy\",\n\t\t\"checked\",\n\t\t\"colcount\",\n\t\t\"colindex\",\n\t\t\"colindextext\",\n\t\t\"colspan\",\n\t\t\"controls\",\n\t\t\"current\",\n\t\t\"describedby\",\n\t\t\"description\",\n\t\t\"details\",\n\t\t\"disabled\",\n\t\t\"dropeffect\",\n\t\t\"errormessage\",\n\t\t\"expanded\",\n\t\t\"flowto\",\n\t\t\"grabbed\",\n\t\t\"haspopup\",\n\t\t\"hidden\",\n\t\t\"invalid\",\n\t\t\"keyshortcuts\",\n\t\t\"label\",\n\t\t\"labelledby\",\n\t\t\"level\",\n\t\t\"live\",\n\t\t\"modal\",\n\t\t\"multiline\",\n\t\t\"multiselectable\",\n\t\t\"orientation\",\n\t\t\"owns\",\n\t\t\"placeholder\",\n\t\t\"posinset\",\n\t\t\"pressed\",\n\t\t\"readonly\",\n\t\t\"relevant\",\n\t\t\"required\",\n\t\t\"roledescription\",\n\t\t\"rowcount\",\n\t\t\"rowindex\",\n\t\t\"rowindextext\",\n\t\t\"rowspan\",\n\t\t\"selected\",\n\t\t\"setsize\",\n\t\t\"sort\",\n\t\t\"valuemax\",\n\t\t\"valuemin\",\n\t\t\"valuenow\",\n\t\t\"valuetext\",\n\t].map((name) => `aria-${name}`),\n);\n\n/** Roles from WAI-ARIA 1.2, plus those the 1.3 draft adds. */\nexport const ROLES = new Set([\n\t\"alert\",\n\t\"alertdialog\",\n\t\"application\",\n\t\"article\",\n\t\"banner\",\n\t\"blockquote\",\n\t\"button\",\n\t\"caption\",\n\t\"cell\",\n\t\"checkbox\",\n\t\"code\",\n\t\"columnheader\",\n\t\"combobox\",\n\t\"comment\",\n\t\"complementary\",\n\t\"contentinfo\",\n\t\"definition\",\n\t\"deletion\",\n\t\"dialog\",\n\t\"directory\",\n\t\"document\",\n\t\"emphasis\",\n\t\"feed\",\n\t\"figure\",\n\t\"form\",\n\t\"generic\",\n\t\"grid\",\n\t\"gridcell\",\n\t\"group\",\n\t\"heading\",\n\t\"image\",\n\t\"img\",\n\t\"insertion\",\n\t\"link\",\n\t\"list\",\n\t\"listbox\",\n\t\"listitem\",\n\t\"log\",\n\t\"main\",\n\t\"mark\",\n\t\"marquee\",\n\t\"math\",\n\t\"menu\",\n\t\"menubar\",\n\t\"menuitem\",\n\t\"menuitemcheckbox\",\n\t\"menuitemradio\",\n\t\"meter\",\n\t\"navigation\",\n\t\"none\",\n\t\"note\",\n\t\"option\",\n\t\"paragraph\",\n\t\"presentation\",\n\t\"progressbar\",\n\t\"radio\",\n\t\"radiogroup\",\n\t\"region\",\n\t\"row\",\n\t\"rowgroup\",\n\t\"rowheader\",\n\t\"scrollbar\",\n\t\"search\",\n\t\"searchbox\",\n\t\"sectionfooter\",\n\t\"sectionheader\",\n\t\"separator\",\n\t\"slider\",\n\t\"spinbutton\",\n\t\"status\",\n\t\"strong\",\n\t\"subscript\",\n\t\"suggestion\",\n\t\"superscript\",\n\t\"switch\",\n\t\"tab\",\n\t\"table\",\n\t\"tablist\",\n\t\"tabpanel\",\n\t\"term\",\n\t\"textbox\",\n\t\"time\",\n\t\"timer\",\n\t\"toolbar\",\n\t\"tooltip\",\n\t\"tree\",\n\t\"treegrid\",\n\t\"treeitem\",\n]);\n\n/** Roles that only organise the ARIA spec. Pages must not use them. */\nexport const ABSTRACT_ROLES = new Set([\n\t\"command\",\n\t\"composite\",\n\t\"input\",\n\t\"landmark\",\n\t\"range\",\n\t\"roletype\",\n\t\"section\",\n\t\"sectionhead\",\n\t\"select\",\n\t\"structure\",\n\t\"widget\",\n\t\"window\",\n]);\n\n/** Elements whose content is text, so tags inside them aren't elements. */\nexport const RAW_TEXT = new Set([\n\t\"script\",\n\t\"style\",\n\t\"textarea\",\n\t\"title\",\n\t\"xmp\",\n\t\"iframe\",\n\t\"noembed\",\n\t\"noframes\",\n\t\"plaintext\",\n]);\n\n/** Elements whose content follows SVG or MathML rules instead of HTML's. */\nexport const FOREIGN = new Set([\"svg\", \"math\"]);\n\n/** Elements with no content or end tag. */\nexport const VOID = new Set([\n\t\"area\",\n\t\"base\",\n\t\"basefont\",\n\t\"bgsound\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"frame\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"keygen\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\n/** What each obsolete attribute is replaced by, by element. Attributes missing from an element's list use CSS. */\nconst CSS = \"Use CSS instead\";\nconst REMOVE = \"Remove it\";\nconst USE_ID = \"Use id instead\";\nconst presentational = (...names: string[]) =>\n\tObject.fromEntries(names.map((name) => [name, CSS]));\nconst cellAttributes = presentational(\n\t\"align\",\n\t\"bgcolor\",\n\t\"char\",\n\t\"charoff\",\n\t\"height\",\n\t\"nowrap\",\n\t\"valign\",\n\t\"width\",\n);\nconst rowGroupAttributes = presentational(\"align\", \"char\", \"charoff\", \"valign\");\n\nexport const OBSOLETE_ATTRIBUTES: Record<string, Record<string, string>> = {\n\ta: {\n\t\tcharset: REMOVE,\n\t\tcoords: \"Use <area> instead\",\n\t\tmethods: REMOVE,\n\t\tname: USE_ID,\n\t\trev: \"Use rel instead\",\n\t\tshape: \"Use <area> instead\",\n\t\turn: REMOVE,\n\t},\n\tarea: { nohref: \"Leave out href instead\", type: REMOVE },\n\tbody: presentational(\n\t\t\"alink\",\n\t\t\"background\",\n\t\t\"bgcolor\",\n\t\t\"bottommargin\",\n\t\t\"leftmargin\",\n\t\t\"link\",\n\t\t\"marginbottom\",\n\t\t\"marginheight\",\n\t\t\"marginleft\",\n\t\t\"marginright\",\n\t\t\"margintop\",\n\t\t\"marginwidth\",\n\t\t\"rightmargin\",\n\t\t\"text\",\n\t\t\"topmargin\",\n\t\t\"vlink\",\n\t),\n\tbr: presentational(\"clear\"),\n\tcaption: presentational(\"align\"),\n\tcol: presentational(\"align\", \"char\", \"charoff\", \"valign\", \"width\"),\n\tdiv: presentational(\"align\"),\n\tdl: presentational(\"compact\"),\n\tembed: { ...presentational(\"align\", \"hspace\", \"vspace\"), name: USE_ID },\n\thead: { profile: REMOVE },\n\thr: presentational(\"align\", \"color\", \"noshade\", \"size\", \"width\"),\n\thtml: { manifest: \"Use a service worker instead\", version: REMOVE },\n\t...Object.fromEntries(\n\t\t[\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"legend\", \"p\"].map((name) => [\n\t\t\tname,\n\t\t\tpresentational(\"align\"),\n\t\t]),\n\t),\n\tiframe: {\n\t\t...presentational(\n\t\t\t\"align\",\n\t\t\t\"allowtransparency\",\n\t\t\t\"frameborder\",\n\t\t\t\"framespacing\",\n\t\t\t\"hspace\",\n\t\t\t\"marginheight\",\n\t\t\t\"marginwidth\",\n\t\t\t\"scrolling\",\n\t\t\t\"vspace\",\n\t\t),\n\t\tlongdesc: \"Link to the description instead\",\n\t},\n\timg: {\n\t\t...presentational(\"align\", \"border\", \"hspace\", \"vspace\"),\n\t\tlongdesc: \"Link to the description instead\",\n\t\tlowsrc: \"Use srcset instead\",\n\t\tname: USE_ID,\n\t},\n\tinput: {\n\t\t...presentational(\"align\", \"hspace\", \"vspace\"),\n\t\tismap: \"Use <img> for image maps instead\",\n\t\tusemap: \"Use <img> for image maps instead\",\n\t},\n\tli: presentational(\"type\"),\n\tlink: { charset: REMOVE, rev: \"Use rel instead\", target: REMOVE },\n\tmenu: presentational(\"compact\"),\n\tmeta: { scheme: REMOVE },\n\tobject: {\n\t\t...presentational(\"align\", \"border\", \"hspace\", \"vspace\"),\n\t\tarchive: \"Use data and type instead\",\n\t\tclassid: \"Use data and type instead\",\n\t\tcode: \"Use data and type instead\",\n\t\tcodebase: \"Use data and type instead\",\n\t\tcodetype: \"Use data and type instead\",\n\t\tdeclare: REMOVE,\n\t\tstandby: REMOVE,\n\t},\n\tol: presentational(\"compact\"),\n\toption: { name: USE_ID },\n\tpre: presentational(\"width\"),\n\tscript: {\n\t\tcharset: REMOVE,\n\t\tevent: REMOVE,\n\t\tfor: REMOVE,\n\t\tlanguage: REMOVE,\n\t},\n\ttable: {\n\t\t...presentational(\n\t\t\t\"align\",\n\t\t\t\"bgcolor\",\n\t\t\t\"border\",\n\t\t\t\"cellpadding\",\n\t\t\t\"cellspacing\",\n\t\t\t\"frame\",\n\t\t\t\"rules\",\n\t\t\t\"width\",\n\t\t),\n\t\tsummary: \"Use <caption> instead\",\n\t},\n\ttbody: rowGroupAttributes,\n\tthead: rowGroupAttributes,\n\ttfoot: rowGroupAttributes,\n\ttr: { ...rowGroupAttributes, bgcolor: CSS },\n\ttd: {\n\t\t...cellAttributes,\n\t\tabbr: \"Use <th> with abbr instead\",\n\t\taxis: \"Use scope on <th> instead\",\n\t\tscope: \"Use <th> instead\",\n\t},\n\tth: { ...cellAttributes, axis: \"Use scope instead\" },\n\tul: presentational(\"compact\", \"type\"),\n};\n\n/**\n * The keywords an attribute accepts. `on` lists the elements it applies to, or is `*` for any element. `tokens` takes a\n * list of keywords separated by spaces. `other` accepts values that aren't keywords, such as `target` names.\n */\nexport type AttributeValues = {\n\ton: readonly string[] | \"*\";\n\tvalues: readonly string[];\n\tcaseSensitive?: true;\n\ttokens?: true;\n\tother?: (value: string) => boolean;\n};\n\nconst FORM_METHODS = [\"get\", \"post\", \"dialog\"];\nconst ENCTYPES = [\n\t\"application/x-www-form-urlencoded\",\n\t\"multipart/form-data\",\n\t\"text/plain\",\n];\nconst TARGETS = [\"_blank\", \"_parent\", \"_self\", \"_top\", \"_unfencedTop\"];\n/** A target that isn't a keyword is a name, and names can't start with `_`. */\nconst targetName = (value: string) => !value.startsWith(\"_\");\n\nexport const ATTRIBUTE_VALUES: Record<string, readonly AttributeValues[]> = {\n\ttype: [\n\t\t{\n\t\t\ton: [\"input\"],\n\t\t\tvalues: [\n\t\t\t\t\"button\",\n\t\t\t\t\"checkbox\",\n\t\t\t\t\"color\",\n\t\t\t\t\"date\",\n\t\t\t\t\"datetime-local\",\n\t\t\t\t\"email\",\n\t\t\t\t\"file\",\n\t\t\t\t\"hidden\",\n\t\t\t\t\"image\",\n\t\t\t\t\"month\",\n\t\t\t\t\"number\",\n\t\t\t\t\"password\",\n\t\t\t\t\"radio\",\n\t\t\t\t\"range\",\n\t\t\t\t\"reset\",\n\t\t\t\t\"search\",\n\t\t\t\t\"submit\",\n\t\t\t\t\"tel\",\n\t\t\t\t\"text\",\n\t\t\t\t\"time\",\n\t\t\t\t\"url\",\n\t\t\t\t\"week\",\n\t\t\t],\n\t\t},\n\t\t{ on: [\"button\"], values: [\"button\", \"reset\", \"submit\"] },\n\t\t{ on: [\"ol\"], values: [\"1\", \"a\", \"A\", \"i\", \"I\"], caseSensitive: true },\n\t],\n\tmethod: [{ on: [\"form\"], values: FORM_METHODS }],\n\tformmethod: [{ on: [\"button\", \"input\"], values: FORM_METHODS }],\n\tenctype: [{ on: [\"form\"], values: ENCTYPES }],\n\tformenctype: [{ on: [\"button\", \"input\"], values: ENCTYPES }],\n\tautocomplete: [{ on: [\"form\"], values: [\"on\", \"off\"] }],\n\tloading: [{ on: [\"img\", \"iframe\"], values: [\"eager\", \"lazy\"] }],\n\tdecoding: [{ on: [\"img\"], values: [\"async\", \"auto\", \"sync\"] }],\n\tfetchpriority: [\n\t\t{\n\t\t\ton: [\"img\", \"iframe\", \"link\", \"script\"],\n\t\t\tvalues: [\"auto\", \"high\", \"low\"],\n\t\t},\n\t],\n\tcrossorigin: [\n\t\t{\n\t\t\ton: [\"audio\", \"img\", \"link\", \"script\", \"video\"],\n\t\t\tvalues: [\"\", \"anonymous\", \"use-credentials\"],\n\t\t},\n\t],\n\treferrerpolicy: [\n\t\t{\n\t\t\ton: [\"a\", \"area\", \"iframe\", \"img\", \"link\", \"script\"],\n\t\t\tvalues: [\n\t\t\t\t\"\",\n\t\t\t\t\"no-referrer\",\n\t\t\t\t\"no-referrer-when-downgrade\",\n\t\t\t\t\"origin\",\n\t\t\t\t\"origin-when-cross-origin\",\n\t\t\t\t\"same-origin\",\n\t\t\t\t\"strict-origin\",\n\t\t\t\t\"strict-origin-when-cross-origin\",\n\t\t\t\t\"unsafe-url\",\n\t\t\t],\n\t\t},\n\t],\n\ttarget: [\n\t\t{ on: [\"a\", \"area\", \"base\", \"form\"], values: TARGETS, other: targetName },\n\t],\n\tformtarget: [{ on: [\"button\", \"input\"], values: TARGETS, other: targetName }],\n\tpreload: [\n\t\t{ on: [\"audio\", \"video\"], values: [\"\", \"auto\", \"metadata\", \"none\"] },\n\t],\n\tscope: [{ on: [\"th\"], values: [\"col\", \"colgroup\", \"row\", \"rowgroup\"] }],\n\tkind: [\n\t\t{\n\t\t\ton: [\"track\"],\n\t\t\tvalues: [\"captions\", \"chapters\", \"descriptions\", \"metadata\", \"subtitles\"],\n\t\t},\n\t],\n\twrap: [{ on: [\"textarea\"], values: [\"hard\", \"soft\"] }],\n\tshape: [{ on: [\"area\"], values: [\"circle\", \"default\", \"poly\", \"rect\"] }],\n\tcapture: [{ on: [\"input\"], values: [\"environment\", \"user\"] }],\n\tsandbox: [\n\t\t{\n\t\t\ton: [\"iframe\"],\n\t\t\ttokens: true,\n\t\t\tvalues: [\n\t\t\t\t\"allow-downloads\",\n\t\t\t\t\"allow-forms\",\n\t\t\t\t\"allow-modals\",\n\t\t\t\t\"allow-orientation-lock\",\n\t\t\t\t\"allow-pointer-lock\",\n\t\t\t\t\"allow-popups\",\n\t\t\t\t\"allow-popups-to-escape-sandbox\",\n\t\t\t\t\"allow-presentation\",\n\t\t\t\t\"allow-same-origin\",\n\t\t\t\t\"allow-scripts\",\n\t\t\t\t\"allow-storage-access-by-user-activation\",\n\t\t\t\t\"allow-top-navigation\",\n\t\t\t\t\"allow-top-navigation-by-user-activation\",\n\t\t\t\t\"allow-top-navigation-to-custom-protocols\",\n\t\t\t],\n\t\t},\n\t],\n\tblocking: [\n\t\t{ on: [\"link\", \"script\", \"style\"], tokens: true, values: [\"render\"] },\n\t],\n\tpopovertargetaction: [\n\t\t{ on: [\"button\", \"input\"], values: [\"hide\", \"show\", \"toggle\"] },\n\t],\n\tcommand: [\n\t\t{\n\t\t\ton: [\"button\"],\n\t\t\tvalues: [\n\t\t\t\t\"close\",\n\t\t\t\t\"hide-popover\",\n\t\t\t\t\"request-close\",\n\t\t\t\t\"show-modal\",\n\t\t\t\t\"show-popover\",\n\t\t\t\t\"toggle-popover\",\n\t\t\t],\n\t\t\tother: (value) => value.startsWith(\"--\"),\n\t\t},\n\t],\n\tshadowrootmode: [{ on: [\"template\"], values: [\"closed\", \"open\"] }],\n\tdir: [{ on: \"*\", values: [\"auto\", \"ltr\", \"rtl\"] }],\n\thidden: [{ on: \"*\", values: [\"\", \"hidden\", \"until-found\"] }],\n\tcontenteditable: [\n\t\t{ on: \"*\", values: [\"\", \"false\", \"plaintext-only\", \"true\"] },\n\t],\n\tdraggable: [{ on: \"*\", values: [\"false\", \"true\"] }],\n\tspellcheck: [{ on: \"*\", values: [\"\", \"false\", \"true\"] }],\n\ttranslate: [{ on: \"*\", values: [\"\", \"no\", \"yes\"] }],\n\tautocapitalize: [\n\t\t{\n\t\t\ton: \"*\",\n\t\t\tvalues: [\"characters\", \"none\", \"off\", \"on\", \"sentences\", \"words\"],\n\t\t},\n\t],\n\tinputmode: [\n\t\t{\n\t\t\ton: \"*\",\n\t\t\tvalues: [\n\t\t\t\t\"decimal\",\n\t\t\t\t\"email\",\n\t\t\t\t\"none\",\n\t\t\t\t\"numeric\",\n\t\t\t\t\"search\",\n\t\t\t\t\"tel\",\n\t\t\t\t\"text\",\n\t\t\t\t\"url\",\n\t\t\t],\n\t\t},\n\t],\n\tenterkeyhint: [\n\t\t{\n\t\t\ton: \"*\",\n\t\t\tvalues: [\"done\", \"enter\", \"go\", \"next\", \"previous\", \"search\", \"send\"],\n\t\t},\n\t],\n\tpopover: [{ on: \"*\", values: [\"\", \"auto\", \"hint\", \"manual\"] }],\n};\n\n/** Boolean attributes, which are on whenever they are present, by the elements that have them. `*` is any element. */\nexport const BOOLEAN_ATTRIBUTES: Record<string, readonly string[] | \"*\"> = {\n\tallowfullscreen: [\"iframe\"],\n\tasync: [\"script\"],\n\tautofocus: \"*\",\n\tautoplay: [\"audio\", \"video\"],\n\tchecked: [\"input\"],\n\tcontrols: [\"audio\", \"video\"],\n\tdefault: [\"track\"],\n\tdefer: [\"script\"],\n\tdisabled: [\n\t\t\"button\",\n\t\t\"fieldset\",\n\t\t\"input\",\n\t\t\"link\",\n\t\t\"optgroup\",\n\t\t\"option\",\n\t\t\"select\",\n\t\t\"textarea\",\n\t],\n\tformnovalidate: [\"button\", \"input\"],\n\tinert: \"*\",\n\tismap: [\"img\"],\n\titemscope: \"*\",\n\tloop: [\"audio\", \"video\"],\n\tmultiple: [\"input\", \"select\"],\n\tmuted: [\"audio\", \"video\"],\n\tnomodule: [\"script\"],\n\tnovalidate: [\"form\"],\n\topen: [\"details\", \"dialog\"],\n\tplaysinline: [\"video\"],\n\treadonly: [\"input\", \"textarea\"],\n\trequired: [\"input\", \"select\", \"textarea\"],\n\treversed: [\"ol\"],\n\tselected: [\"option\"],\n\tshadowrootclonable: [\"template\"],\n\tshadowrootdelegatesfocus: [\"template\"],\n\tshadowrootserializable: [\"template\"],\n};\n\n/** Roles elements always have, whatever their attributes. Lists are left out; see the docs on `html-redundant-role`. */\nexport const IMPLICIT_ROLES: Record<string, string> = {\n\tarticle: \"article\",\n\taside: \"complementary\",\n\tblockquote: \"blockquote\",\n\tbutton: \"button\",\n\tcaption: \"caption\",\n\tcode: \"code\",\n\tdatalist: \"listbox\",\n\tdel: \"deletion\",\n\tdetails: \"group\",\n\tdfn: \"term\",\n\tdialog: \"dialog\",\n\tem: \"emphasis\",\n\tfieldset: \"group\",\n\tfigure: \"figure\",\n\th1: \"heading\",\n\th2: \"heading\",\n\th3: \"heading\",\n\th4: \"heading\",\n\th5: \"heading\",\n\th6: \"heading\",\n\thr: \"separator\",\n\thtml: \"document\",\n\tins: \"insertion\",\n\tmain: \"main\",\n\tmeter: \"meter\",\n\tnav: \"navigation\",\n\toptgroup: \"group\",\n\toption: \"option\",\n\toutput: \"status\",\n\tp: \"paragraph\",\n\tprogress: \"progressbar\",\n\tsearch: \"search\",\n\tstrong: \"strong\",\n\tsub: \"subscript\",\n\tsup: \"superscript\",\n\ttable: \"table\",\n\ttbody: \"rowgroup\",\n\ttextarea: \"textbox\",\n\ttfoot: \"rowgroup\",\n\tthead: \"rowgroup\",\n\ttime: \"time\",\n\ttr: \"row\",\n};\n\n/** The roles `<input>` has for each `type`, when the role doesn't depend on other attributes. */\nexport const INPUT_ROLES: Record<string, string> = {\n\tbutton: \"button\",\n\tcheckbox: \"checkbox\",\n\timage: \"button\",\n\tnumber: \"spinbutton\",\n\tradio: \"radio\",\n\trange: \"slider\",\n\treset: \"button\",\n\tsubmit: \"button\",\n};\n\nexport const HEADINGS = new Set([\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"]);\n\n/** Elements that aren't phrasing content. Starting one ends an open `<p>`. */\nexport const FLOW = new Set([\n\t\"address\",\n\t\"article\",\n\t\"aside\",\n\t\"blockquote\",\n\t\"center\",\n\t\"dd\",\n\t\"details\",\n\t\"dialog\",\n\t\"dir\",\n\t\"div\",\n\t\"dl\",\n\t\"dt\",\n\t\"fieldset\",\n\t\"figcaption\",\n\t\"figure\",\n\t\"footer\",\n\t\"form\",\n\t...HEADINGS,\n\t\"header\",\n\t\"hgroup\",\n\t\"hr\",\n\t\"li\",\n\t\"listing\",\n\t\"main\",\n\t\"menu\",\n\t\"nav\",\n\t\"ol\",\n\t\"p\",\n\t\"plaintext\",\n\t\"pre\",\n\t\"search\",\n\t\"section\",\n\t\"summary\",\n\t\"table\",\n\t\"ul\",\n\t\"xmp\",\n]);\n\n/** Elements that only hold phrasing content: text and inline elements. `<p>` is left out, since the browser ends it. */\nexport const PHRASING_ONLY = new Set([\n\t\"abbr\",\n\t\"b\",\n\t\"bdi\",\n\t\"bdo\",\n\t\"button\",\n\t\"cite\",\n\t\"code\",\n\t\"data\",\n\t\"dfn\",\n\t\"em\",\n\t...HEADINGS,\n\t\"i\",\n\t\"kbd\",\n\t\"label\",\n\t\"legend\",\n\t\"mark\",\n\t\"meter\",\n\t\"output\",\n\t\"pre\",\n\t\"progress\",\n\t\"q\",\n\t\"rp\",\n\t\"rt\",\n\t\"ruby\",\n\t\"s\",\n\t\"samp\",\n\t\"small\",\n\t\"span\",\n\t\"strong\",\n\t\"sub\",\n\t\"summary\",\n\t\"sup\",\n\t\"time\",\n\t\"u\",\n\t\"var\",\n]);\n\n/** Elements that take the content model of their parent, so their parent decides what they may hold. */\nexport const TRANSPARENT = new Set([\n\t\"a\",\n\t\"audio\",\n\t\"canvas\",\n\t\"del\",\n\t\"ins\",\n\t\"map\",\n\t\"noscript\",\n\t\"object\",\n\t\"slot\",\n\t\"video\",\n]);\n\nconst SCRIPT_SUPPORTING = [\"script\", \"template\"];\nconst TABLE_PARTS = [\n\t\"caption\",\n\t\"colgroup\",\n\t\"col\",\n\t\"thead\",\n\t\"tbody\",\n\t\"tfoot\",\n\t\"tr\",\n];\n\n/** Elements that only hold certain children. */\nexport const ONLY_CHILDREN: Record<string, readonly string[]> = {\n\tul: [\"li\", ...SCRIPT_SUPPORTING],\n\tol: [\"li\", ...SCRIPT_SUPPORTING],\n\tmenu: [\"li\", ...SCRIPT_SUPPORTING],\n\tdl: [\"dt\", \"dd\", \"div\", ...SCRIPT_SUPPORTING],\n\ttable: [...TABLE_PARTS, ...SCRIPT_SUPPORTING],\n\tthead: [\"tr\", ...SCRIPT_SUPPORTING],\n\ttbody: [\"tr\", ...SCRIPT_SUPPORTING],\n\ttfoot: [\"tr\", ...SCRIPT_SUPPORTING],\n\ttr: [\"td\", \"th\", ...SCRIPT_SUPPORTING],\n\tcolgroup: [\"col\", \"template\"],\n\tpicture: [\"source\", \"img\", ...SCRIPT_SUPPORTING],\n\thgroup: [\"p\", ...HEADINGS, ...SCRIPT_SUPPORTING],\n};\n\n/** What `<head>` holds. Anything else ends it, since `</head>` can be left out. */\nexport const METADATA = new Set([\n\t\"base\",\n\t\"link\",\n\t\"meta\",\n\t\"noscript\",\n\t\"script\",\n\t\"style\",\n\t\"template\",\n\t\"title\",\n]);\n\n/** Elements that must sit directly inside certain parents. */\nexport const REQUIRED_PARENTS: Record<string, readonly string[]> = {\n\tli: [\"ul\", \"ol\", \"menu\"],\n\tdt: [\"dl\", \"div\"],\n\tdd: [\"dl\", \"div\"],\n\ttr: [\"table\", \"thead\", \"tbody\", \"tfoot\"],\n\ttd: [\"tr\"],\n\tth: [\"tr\"],\n\tthead: [\"table\"],\n\ttbody: [\"table\"],\n\ttfoot: [\"table\"],\n\tcaption: [\"table\"],\n\tcolgroup: [\"table\"],\n\tcol: [\"colgroup\", \"table\"],\n\tsummary: [\"details\"],\n\tlegend: [\"fieldset\", \"optgroup\"],\n\tfigcaption: [\"figure\"],\n\tsource: [\"picture\", \"audio\", \"video\"],\n\ttrack: [\"audio\", \"video\"],\n\trt: [\"ruby\"],\n\trp: [\"ruby\"],\n};\n\n/** Elements that must be the first child of their parent. */\nexport const FIRST_CHILD: Record<string, string> = {\n\tsummary: \"details\",\n\tlegend: \"fieldset\",\n};\n\n/** Where `<main>` may go, besides custom elements. */\nexport const MAIN_PARENTS = new Set([\n\t\"html\",\n\t\"body\",\n\t\"div\",\n\t\"form\",\n\t\"template\",\n]);\n\n/**\n * The \"special\" elements of the HTML parser, which stop it looking further for an `<li>`, `<dd>` or `<dt>` to end.\n * `address`, `div` and `p` are left out, as the parser looks past them.\n */\nexport const SPECIAL = new Set([\n\t\"applet\",\n\t\"area\",\n\t\"article\",\n\t\"aside\",\n\t\"base\",\n\t\"basefont\",\n\t\"bgsound\",\n\t\"blockquote\",\n\t\"body\",\n\t\"br\",\n\t\"button\",\n\t\"caption\",\n\t\"center\",\n\t\"col\",\n\t\"colgroup\",\n\t\"dd\",\n\t\"details\",\n\t\"dir\",\n\t\"dl\",\n\t\"dt\",\n\t\"embed\",\n\t\"fieldset\",\n\t\"figcaption\",\n\t\"figure\",\n\t\"footer\",\n\t\"form\",\n\t\"frame\",\n\t\"frameset\",\n\t...HEADINGS,\n\t\"head\",\n\t\"header\",\n\t\"hgroup\",\n\t\"hr\",\n\t\"html\",\n\t\"iframe\",\n\t\"img\",\n\t\"input\",\n\t\"keygen\",\n\t\"li\",\n\t\"link\",\n\t\"listing\",\n\t\"main\",\n\t\"marquee\",\n\t\"menu\",\n\t\"meta\",\n\t\"nav\",\n\t\"noembed\",\n\t\"noframes\",\n\t\"noscript\",\n\t\"object\",\n\t\"ol\",\n\t\"param\",\n\t\"plaintext\",\n\t\"pre\",\n\t\"script\",\n\t\"search\",\n\t\"section\",\n\t\"select\",\n\t\"source\",\n\t\"style\",\n\t\"summary\",\n\t\"table\",\n\t\"tbody\",\n\t\"td\",\n\t\"template\",\n\t\"textarea\",\n\t\"tfoot\",\n\t\"th\",\n\t\"thead\",\n\t\"title\",\n\t\"tr\",\n\t\"track\",\n\t\"ul\",\n\t\"wbr\",\n\t\"xmp\",\n]);\n\n/** Elements that end the search for an open `<p>` or `<button>`: the parser's \"button scope\". */\nexport const BUTTON_SCOPE = new Set([\n\t\"applet\",\n\t\"button\",\n\t\"caption\",\n\t\"html\",\n\t\"marquee\",\n\t\"object\",\n\t\"table\",\n\t\"td\",\n\t\"template\",\n\t\"th\",\n]);\n","import { isPlainObject } from \"../runtime/values.js\";\nimport type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\n\nexport const HTML_CHECKS = [\n\t\"html-obsolete-element\",\n\t\"html-obsolete-attribute\",\n\t\"html-attribute-value\",\n\t\"html-img-alt\",\n\t\"html-button-type\",\n\t\"html-lang\",\n\t\"html-iframe-title\",\n\t\"html-viewport-zoom\",\n\t\"html-tabindex\",\n\t\"html-aria-attribute\",\n\t\"html-role\",\n\t\"html-redundant-role\",\n\t\"html-aria-hidden-focusable\",\n\t\"html-heading-order\",\n\t\"html-nested-interactive\",\n\t\"html-permitted-content\",\n] as const;\n\nexport type HtmlCheck = (typeof HTML_CHECKS)[number];\nexport type HtmlCheckLevel = \"off\" | \"warning\" | \"error\";\n/** The `htmlChecks` option: every rule on or off, or a level for some rules. Rules left out are warnings. */\nexport type HtmlChecks = boolean | Partial<Record<HtmlCheck, HtmlCheckLevel>>;\nexport type HtmlCheckLevels = Readonly<Record<HtmlCheck, HtmlCheckLevel>>;\n\nconst LEVELS: readonly unknown[] = [\"off\", \"warning\", \"error\"];\n\nconst isHtmlCheck = (code: string): code is HtmlCheck =>\n\t(HTML_CHECKS as readonly string[]).includes(code);\n\nconst isLevel = (level: unknown): level is HtmlCheckLevel =>\n\tLEVELS.includes(level);\n\nconst allAt = (level: HtmlCheckLevel): Record<HtmlCheck, HtmlCheckLevel> => {\n\tconst levels = {} as Record<HtmlCheck, HtmlCheckLevel>;\n\tfor (const code of HTML_CHECKS) levels[code] = level;\n\treturn levels;\n};\n\n/** Validates the `htmlChecks` option and gives every rule its level. Throws a `TypeError` for an invalid option. */\nexport const resolveHtmlChecks = (\n\toption: HtmlChecks | undefined,\n): HtmlCheckLevels => {\n\tif (option === undefined || option === true) return allAt(\"warning\");\n\tif (option === false) return allAt(\"off\");\n\tif (!isPlainObject(option)) {\n\t\tthrow new TypeError(\n\t\t\t\"htmlChecks must be true, false or an object of rule levels\",\n\t\t);\n\t}\n\tconst levels = allAt(\"warning\");\n\tfor (const [code, level] of Object.entries(option)) {\n\t\tif (!isHtmlCheck(code)) {\n\t\t\tthrow new TypeError(\n\t\t\t\twithHint(`Unknown HTML check \"${code}\"`, suggest(code, HTML_CHECKS)),\n\t\t\t);\n\t\t}\n\t\tif (!isLevel(level)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`HTML check \"${code}\" must be \"off\", \"warning\" or \"error\"`,\n\t\t\t);\n\t\t}\n\t\tlevels[code] = level;\n\t}\n\treturn levels;\n};\n\n/** The shortest `htmlChecks` option that gives these levels, for `kiln.json`. */\nexport const htmlChecksOption = (levels: HtmlCheckLevels): HtmlChecks => {\n\tconst changed: Partial<Record<HtmlCheck, HtmlCheckLevel>> = {};\n\tfor (const code of HTML_CHECKS) {\n\t\tif (levels[code] !== \"warning\") changed[code] = levels[code];\n\t}\n\tconst codes = Object.keys(changed);\n\tif (codes.length === 0) return true;\n\tif (\n\t\tcodes.length === HTML_CHECKS.length &&\n\t\tHTML_CHECKS.every((code) => levels[code] === \"off\")\n\t) {\n\t\treturn false;\n\t}\n\treturn changed;\n};\n\n/** Reports a problem a rule found. Rules turned off report nothing. */\nexport type Report = (code: HtmlCheck, message: string, span: Span) => void;\n\n/** Adds a \"Did you mean\" hint to a message, when there is one. */\nexport const withHint = (message: string, hint: string | undefined) =>\n\thint ? `${message}. ${hint}` : message;\n","import { suggest } from \"../suggest.js\";\nimport {\n\tABSTRACT_ROLES,\n\tARIA_ATTRIBUTES,\n\tATTRIBUTE_VALUES,\n\tBOOLEAN_ATTRIBUTES,\n\tIMPLICIT_ROLES,\n\tINPUT_ROLES,\n\tOBSOLETE,\n\tOBSOLETE_ATTRIBUTES,\n\tROLES,\n} from \"./data.js\";\nimport { type Report, withHint } from \"./options.js\";\nimport type { Attribute, StartTag } from \"./scanner.js\";\n\nconst TABINDEX = /^[\\t\\n\\f\\r ]*([+-]?)(\\d+)/;\nconst TOKENS = /[^\\t\\n\\f\\r ]+/g;\n/** Values that suggest the author meant a boolean attribute to be off. */\nconst OFF = new Set([\"false\", \"0\", \"no\", \"off\"]);\n\n/** A written-out `tabindex` as a number, or null when there is none or it isn't a number. */\nexport const tabindexOf = (tag: StartTag): number | null => {\n\tconst value = tag.attributes.find((a) => a.name === \"tabindex\")?.value;\n\tconst match =\n\t\tvalue === undefined || value === null ? null : TABINDEX.exec(value);\n\treturn match ? Number(`${match[1]}${match[2]}`) : null;\n};\n\n/** The written-out value of an attribute, in lower case. Undefined when it's missing, null when built at render time. */\nexport const valueOf = (tag: StartTag, name: string) => {\n\tconst attribute = tag.attributes.find((a) => a.name === name);\n\tif (!attribute) return undefined;\n\treturn attribute.value === null ? null : attribute.value.toLowerCase();\n};\n\nconst appliesTo = (on: readonly string[] | \"*\", tag: string) =>\n\ton === \"*\" || on.includes(tag);\n\n/** Whether people can tab to an element, judging by what Kiln can see. Null when it can't tell. */\nconst focusable = (tag: StartTag): boolean | null => {\n\tconst tabindex = tabindexOf(tag);\n\tif (tag.attributes.some((a) => a.name === \"tabindex\")) {\n\t\treturn tabindex === null ? null : tabindex >= 0;\n\t}\n\tconst has = (name: string) => tag.attributes.some((a) => a.name === name);\n\tswitch (tag.name) {\n\t\tcase \"a\":\n\t\tcase \"area\":\n\t\t\treturn has(\"href\");\n\t\tcase \"button\":\n\t\tcase \"select\":\n\t\tcase \"textarea\":\n\t\t\treturn !has(\"disabled\");\n\t\tcase \"input\":\n\t\t\treturn !has(\"disabled\") && valueOf(tag, \"type\") !== \"hidden\";\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n/** The role an element always has, or null when it has none or it depends on what Kiln can't see. */\nconst implicitRole = (tag: StartTag): string | null => {\n\tif (tag.name === \"a\" || tag.name === \"area\") {\n\t\treturn tag.attributes.some((a) => a.name === \"href\") ? \"link\" : null;\n\t}\n\tif (tag.name === \"input\") {\n\t\tconst type = valueOf(tag, \"type\");\n\t\treturn type ? (INPUT_ROLES[type] ?? null) : null;\n\t}\n\treturn IMPLICIT_ROLES[tag.name] ?? null;\n};\n\nconst checkValue = (tag: StartTag, attribute: Attribute, report: Report) => {\n\tconst value = attribute.value;\n\tif (value === null) return;\n\tconst custom = tag.name.includes(\"-\");\n\n\tfor (const rule of ATTRIBUTE_VALUES[attribute.name] ?? []) {\n\t\tif (!appliesTo(rule.on, tag.name) || (custom && rule.on !== \"*\")) continue;\n\t\tconst words = rule.tokens\n\t\t\t? Array.from(value.matchAll(TOKENS), (m) => ({\n\t\t\t\t\tword: m[0],\n\t\t\t\t\tstart: attribute.valueStart + m.index,\n\t\t\t\t}))\n\t\t\t: [{ word: value, start: attribute.valueStart }];\n\t\tfor (const { word, start } of words) {\n\t\t\tconst known = rule.caseSensitive\n\t\t\t\t? rule.values.includes(word)\n\t\t\t\t: rule.values.some((v) => v.toLowerCase() === word.toLowerCase());\n\t\t\tif (known || rule.other?.(word)) continue;\n\t\t\treport(\n\t\t\t\t\"html-attribute-value\",\n\t\t\t\twithHint(\n\t\t\t\t\t`${attribute.name}=\"${word}\" isn't valid on <${tag.name}>`,\n\t\t\t\t\tsuggest(\n\t\t\t\t\t\tword,\n\t\t\t\t\t\trule.values.filter((v) => v !== \"\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tword === \"\" ? attribute.span : { start, end: start + word.length },\n\t\t\t);\n\t\t}\n\t\tbreak;\n\t}\n\n\tconst boolean = BOOLEAN_ATTRIBUTES[attribute.name];\n\tif (\n\t\tboolean &&\n\t\t!custom &&\n\t\tappliesTo(boolean, tag.name) &&\n\t\tOFF.has(value.toLowerCase())\n\t) {\n\t\treport(\n\t\t\t\"html-attribute-value\",\n\t\t\t`${attribute.name}=\"${value}\" still turns ${attribute.name} on, since any value does. Leave the attribute out to turn it off`,\n\t\t\tattribute.span,\n\t\t);\n\t}\n\n\tif (attribute.name === \"lang\" && value !== \"\") {\n\t\ttry {\n\t\t\tIntl.getCanonicalLocales(value);\n\t\t} catch {\n\t\t\tlet fix: string | undefined;\n\t\t\ttry {\n\t\t\t\tfix = Intl.getCanonicalLocales(value.trim().replaceAll(\"_\", \"-\"))[0];\n\t\t\t} catch {\n\t\t\t\t// No close tag to suggest.\n\t\t\t}\n\t\t\treport(\n\t\t\t\t\"html-lang\",\n\t\t\t\tfix\n\t\t\t\t\t? `\"${value}\" is not a valid language tag. Use \"${fix}\"`\n\t\t\t\t\t: `\"${value}\" is not a valid language tag, such as \"en\" or \"en-GB\"`,\n\t\t\t\tattribute.span,\n\t\t\t);\n\t\t}\n\t}\n};\n\n/** The `user-scalable` and `maximum-scale` settings in a viewport's `content`. */\nconst viewportSettings = (content: string) =>\n\tnew Map(\n\t\tArray.from(\n\t\t\tcontent.matchAll(/([a-z-]+)\\s*=\\s*([^\\s,;]+)/gi),\n\t\t\t(m) => [(m[1] ?? \"\").toLowerCase(), (m[2] ?? \"\").toLowerCase()] as const,\n\t\t),\n\t);\n\n/** Checks one start tag with the rules that need only that tag. */\nexport const checkTag = (tag: StartTag, report: Report): void => {\n\tconst has = (name: string) =>\n\t\ttag.attributes.some((attribute) => attribute.name === name);\n\n\tconst obsolete = OBSOLETE.get(tag.name);\n\tif (obsolete) {\n\t\treport(\n\t\t\t\"html-obsolete-element\",\n\t\t\t`<${tag.name}> is obsolete. ${obsolete}`,\n\t\t\ttag.span,\n\t\t);\n\t}\n\tif (tag.complete) {\n\t\tif (tag.name === \"img\" && !has(\"alt\")) {\n\t\t\treport(\n\t\t\t\t\"html-img-alt\",\n\t\t\t\t'<img> has no alt attribute. Use alt=\"\" if the image is decorative',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (tag.name === \"button\" && !has(\"type\")) {\n\t\t\treport(\n\t\t\t\t\"html-button-type\",\n\t\t\t\t'<button> has no type attribute, so it submits any form it is in. Add type=\"button\" or type=\"submit\"',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (tag.name === \"html\" && !has(\"lang\")) {\n\t\t\treport(\n\t\t\t\t\"html-lang\",\n\t\t\t\t'<html> has no lang attribute. Add one, such as lang=\"en\"',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (tag.name === \"iframe\" && !has(\"title\")) {\n\t\t\treport(\n\t\t\t\t\"html-iframe-title\",\n\t\t\t\t'<iframe> has no title attribute. Add one that says what it holds, such as title=\"Map of our office\"',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (valueOf(tag, \"aria-hidden\") === \"true\" && focusable(tag)) {\n\t\t\treport(\n\t\t\t\t\"html-aria-hidden-focusable\",\n\t\t\t\t`<${tag.name}> has aria-hidden=\"true\", but people can still tab to it. Remove aria-hidden, or take the element out of the tab order`,\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst obsoleteAttributes = OBSOLETE_ATTRIBUTES[tag.name];\n\tfor (const attribute of tag.attributes) {\n\t\tconst replacement = obsoleteAttributes?.[attribute.name];\n\t\tif (replacement) {\n\t\t\treport(\n\t\t\t\t\"html-obsolete-attribute\",\n\t\t\t\t`The ${attribute.name} attribute on <${tag.name}> is obsolete. ${replacement}`,\n\t\t\t\tattribute.nameSpan,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tattribute.name.startsWith(\"aria-\") &&\n\t\t\t!ARIA_ATTRIBUTES.has(attribute.name)\n\t\t) {\n\t\t\treport(\n\t\t\t\t\"html-aria-attribute\",\n\t\t\t\twithHint(\n\t\t\t\t\t`\"${attribute.name}\" is not an ARIA attribute`,\n\t\t\t\t\tsuggest(attribute.name, ARIA_ATTRIBUTES),\n\t\t\t\t),\n\t\t\t\tattribute.nameSpan,\n\t\t\t);\n\t\t}\n\t\tif (attribute.value === null) continue;\n\t\tcheckValue(tag, attribute, report);\n\t\tif (attribute.name === \"tabindex\") {\n\t\t\tconst tabindex = tabindexOf(tag);\n\t\t\tif (tabindex !== null && tabindex > 0) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-tabindex\",\n\t\t\t\t\t`tabindex=\"${attribute.value}\" puts this element ahead of the rest of the page when tabbing. Use 0, or -1 to focus it only from script`,\n\t\t\t\t\tattribute.span,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (attribute.name === \"role\") {\n\t\t\tcheckRole(tag, attribute, attribute.value, report);\n\t\t}\n\t\tif (\n\t\t\tattribute.name === \"content\" &&\n\t\t\ttag.name === \"meta\" &&\n\t\t\tvalueOf(tag, \"name\") === \"viewport\"\n\t\t) {\n\t\t\tconst settings = viewportSettings(attribute.value);\n\t\t\tconst scalable = settings.get(\"user-scalable\");\n\t\t\tconst maximum = Number.parseFloat(settings.get(\"maximum-scale\") ?? \"\");\n\t\t\tif (scalable === \"no\" || scalable === \"0\") {\n\t\t\t\treport(\n\t\t\t\t\t\"html-viewport-zoom\",\n\t\t\t\t\t`user-scalable=${scalable} stops people zooming in to read. Remove it`,\n\t\t\t\t\tattribute.span,\n\t\t\t\t);\n\t\t\t} else if (maximum < 2) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-viewport-zoom\",\n\t\t\t\t\t`maximum-scale=${settings.get(\"maximum-scale\")} stops people zooming in to read. Remove it, or use 2 or more`,\n\t\t\t\t\tattribute.span,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst checkRole = (\n\ttag: StartTag,\n\tattribute: Attribute,\n\tvalue: string,\n\treport: Report,\n) => {\n\tconst roles = Array.from(value.matchAll(TOKENS));\n\tconst implicit = implicitRole(tag);\n\tif (\n\t\timplicit &&\n\t\troles.length === 1 &&\n\t\troles[0]?.[0].toLowerCase() === implicit\n\t) {\n\t\treport(\n\t\t\t\"html-redundant-role\",\n\t\t\t`<${tag.name}> already has the ${implicit} role. Remove role=\"${value}\"`,\n\t\t\tattribute.span,\n\t\t);\n\t}\n\tfor (const match of roles) {\n\t\tconst role = match[0].toLowerCase();\n\t\t// DPUB-ARIA and Graphics-ARIA roles.\n\t\tif (\n\t\t\tROLES.has(role) ||\n\t\t\trole.startsWith(\"doc-\") ||\n\t\t\trole.startsWith(\"graphics-\")\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst start = attribute.valueStart + match.index;\n\t\tconst span = { start, end: start + role.length };\n\t\tif (ABSTRACT_ROLES.has(role)) {\n\t\t\treport(\n\t\t\t\t\"html-role\",\n\t\t\t\t`\"${role}\" is an abstract ARIA role, which pages must not use`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else {\n\t\t\treport(\n\t\t\t\t\"html-role\",\n\t\t\t\twithHint(`\"${role}\" is not an ARIA role`, suggest(role, ROLES)),\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t}\n};\n","import type { Statement } from \"../parser/ast.js\";\nimport type { CompiledTemplate } from \"../runtime/types.js\";\nimport {\n\tBUTTON_SCOPE,\n\tFIRST_CHILD,\n\tFLOW,\n\tFOREIGN,\n\tHEADINGS,\n\tMAIN_PARENTS,\n\tMETADATA,\n\tONLY_CHILDREN,\n\tPHRASING_ONLY,\n\tRAW_TEXT,\n\tREQUIRED_PARENTS,\n\tSPECIAL,\n\tTRANSPARENT,\n\tVOID,\n} from \"./data.js\";\nimport type { Report } from \"./options.js\";\nimport type { StartTag, Tag } from \"./scanner.js\";\nimport { valueOf } from \"./tags.js\";\n\n/**\n * An open element. An empty name marks where Kiln doesn't know what is open: the bottom of the list, since a\n * template's content could end up anywhere, and wherever `if` branches left different elements open.\n */\ntype Entry = { name: string; children: number };\n\n/**\n * What is known at one point in a template: the open elements, innermost last, and the last heading's level.\n * `endedParagraph` is the block that last ended an open `<p>`, such as the `<div>` in `<p>Text<div>`. That is valid\n * HTML, unless a `</p>` follows, which shows the paragraph was meant to hold the block.\n */\ntype State = {\n\topen: Entry[];\n\theading: number | null;\n\tendedParagraph: StartTag | null;\n};\n\nconst UNKNOWN = \"\";\n\n/** Elements that stop the parser looking for an open `<a>` to end. */\nconst FORMATTING_MARKERS = new Set([\n\t\"applet\",\n\t\"caption\",\n\t\"marquee\",\n\t\"object\",\n\t\"td\",\n\t\"template\",\n\t\"th\",\n]);\n\nconst fresh = (): State => ({\n\topen: [{ name: UNKNOWN, children: 0 }],\n\theading: null,\n\tendedParagraph: null,\n});\n\nconst copy = (state: State): State => ({\n\topen: state.open.map((entry) => ({ ...entry })),\n\theading: state.heading,\n\tendedParagraph: state.endedParagraph,\n});\n\nconst levelOf = (name: string) =>\n\tHEADINGS.has(name) ? Number(name.slice(1)) : null;\n\n/** Lists names as `<a>`, `<a> and <b>`, or `<a>, <b> and <c>`. */\nconst listOf = (names: readonly string[], joiner: \"and\" | \"or\") => {\n\tconst tags = names.map((name) => `<${name}>`);\n\treturn tags.length < 2\n\t\t? tags.join(\"\")\n\t\t: `${tags.slice(0, -1).join(\", \")} ${joiner} ${tags.at(-1)}`;\n};\n\n/** Whether an element is interactive content, which `<a>` and `<button>` can't hold. Null when Kiln can't tell. */\nconst interactive = (tag: StartTag): boolean | null => {\n\tconst has = (name: string) => tag.attributes.some((a) => a.name === name);\n\tif (has(\"tabindex\")) return true;\n\tswitch (tag.name) {\n\t\tcase \"a\":\n\t\t\treturn has(\"href\") || (tag.complete ? false : null);\n\t\tcase \"button\":\n\t\tcase \"details\":\n\t\tcase \"embed\":\n\t\tcase \"iframe\":\n\t\tcase \"label\":\n\t\tcase \"select\":\n\t\tcase \"textarea\":\n\t\t\treturn true;\n\t\tcase \"input\": {\n\t\t\tconst type = valueOf(tag, \"type\");\n\t\t\tif (type === undefined) return tag.complete ? true : null;\n\t\t\treturn type === null ? null : type !== \"hidden\";\n\t\t}\n\t\tcase \"audio\":\n\t\tcase \"video\":\n\t\t\treturn has(\"controls\") || (tag.complete ? false : null);\n\t\tcase \"img\":\n\t\t\treturn has(\"usemap\") || (tag.complete ? false : null);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n/**\n * Checks how a template's elements nest, and the order of its headings. It follows the template's tags, branches and\n * loops, and the HTML parser's rules for end tags that can be left out, but never what other templates render.\n */\nexport const checkNesting = (\n\ttemplate: CompiledTemplate,\n\ttags: readonly Tag[],\n\treport: Report,\n): void => {\n\tconst layoutChild = template.ast.body.some((node) => node.type === \"Extends\");\n\n\tconst startOf = (tag: Tag) =>\n\t\ttag.type === \"start\" ? tag.span.start : tag.start;\n\t/** The index of the first tag at or after `offset`. */\n\tconst firstTag = (offset: number) => {\n\t\tlet low = 0;\n\t\tlet high = tags.length;\n\t\twhile (low < high) {\n\t\t\tconst middle = (low + high) >> 1;\n\t\t\tif (startOf(tags[middle] as Tag) < offset) low = middle + 1;\n\t\t\telse high = middle;\n\t\t}\n\t\treturn low;\n\t};\n\t/** Whether `offset` is inside a tag, such as an output in `class=\"{{ x }}\"`, rather than between elements. */\n\tconst insideTag = (offset: number) => {\n\t\tconst before = tags[firstTag(offset) - 1];\n\t\treturn before !== undefined && offset < before.end;\n\t};\n\n\t/** Combines the states that branches end in. What they disagree on becomes unknown. */\n\tconst merge = (state: State, ends: State[]) => {\n\t\tconst [first, ...rest] = ends as [State, ...State[]];\n\t\tlet shared = first.open.length;\n\t\tfor (const end of rest) {\n\t\t\tlet same = 0;\n\t\t\twhile (\n\t\t\t\tsame < Math.min(shared, end.open.length) &&\n\t\t\t\tend.open[same]?.name === first.open[same]?.name\n\t\t\t) {\n\t\t\t\tsame++;\n\t\t\t}\n\t\t\tshared = same;\n\t\t}\n\t\tconst agree =\n\t\t\tends.every((end) => end.open.length === shared) &&\n\t\t\tfirst.open.length === shared;\n\t\tstate.open = first.open.slice(0, shared);\n\t\tif (!agree) state.open.push({ name: UNKNOWN, children: 0 });\n\t\tstate.heading = ends.every((end) => end.heading === first.heading)\n\t\t\t? first.heading\n\t\t\t: null;\n\t\tstate.endedParagraph = ends.every(\n\t\t\t(end) => end.endedParagraph === first.endedParagraph,\n\t\t)\n\t\t\t? first.endedParagraph\n\t\t\t: null;\n\t};\n\n\t/** Content Kiln can't see, such as an include or an output. It may hold headings unless its parent can't. */\n\tconst hole = (state: State, mayHoldHeadings: boolean) => {\n\t\tconst top = state.open.at(-1) as Entry;\n\t\ttop.children++;\n\t\tif (mayHoldHeadings) state.heading = null;\n\t};\n\n\t/** The nearest open element that decides what may go here: transparent elements such as `<a>` pass it to their parent. */\n\tconst container = (state: State) => {\n\t\tfor (let i = state.open.length - 1; i >= 0; i--) {\n\t\t\tconst entry = state.open[i] as Entry;\n\t\t\tif (!TRANSPARENT.has(entry.name)) return entry;\n\t\t}\n\t\treturn state.open[0] as Entry;\n\t};\n\n\tconst popThrough = (state: State, index: number) => {\n\t\tstate.open.length = index;\n\t};\n\n\t/** The index of the innermost open element matching `names`, looking no further than an element in `stop`. */\n\tconst findOpen = (\n\t\tstate: State,\n\t\tnames: ReadonlySet<string> | readonly string[],\n\t\tstop: (name: string) => boolean,\n\t) => {\n\t\tconst has = (name: string) =>\n\t\t\t\"has\" in names ? names.has(name) : names.includes(name);\n\t\tfor (let i = state.open.length - 1; i > 0; i--) {\n\t\t\tconst name = (state.open[i] as Entry).name;\n\t\t\tif (has(name)) return i;\n\t\t\tif (name === UNKNOWN || stop(name)) return -1;\n\t\t}\n\t\treturn -1;\n\t};\n\n\t/** Ends open elements the way the HTML parser does when `name` starts, for end tags that can be left out. */\n\tconst impliedEnds = (state: State, name: string) => {\n\t\tconst close = (names: readonly string[], stop: readonly string[]) => {\n\t\t\tconst index = findOpen(state, names, (open) => stop.includes(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t};\n\t\tconst tableStops = [\"table\", \"template\", \"html\"];\n\t\tif (state.open.at(-1)?.name === \"head\" && !METADATA.has(name)) {\n\t\t\tstate.open.pop();\n\t\t}\n\t\tif (name === \"li\") {\n\t\t\tconst index = findOpen(state, [\"li\"], (open) => SPECIAL.has(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t} else if (name === \"dd\" || name === \"dt\") {\n\t\t\tconst index = findOpen(state, [\"dd\", \"dt\"], (open) => SPECIAL.has(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t} else if (name === \"td\" || name === \"th\") {\n\t\t\tclose([\"td\", \"th\"], [\"tr\", ...tableStops]);\n\t\t} else if (name === \"tr\") {\n\t\t\tclose([\"td\", \"th\"], [\"tr\", ...tableStops]);\n\t\t\tclose([\"tr\"], [\"thead\", \"tbody\", \"tfoot\", ...tableStops]);\n\t\t} else if (\n\t\t\t[\"thead\", \"tbody\", \"tfoot\", \"caption\", \"colgroup\"].includes(name)\n\t\t) {\n\t\t\tclose([\"td\", \"th\"], [\"tr\", ...tableStops]);\n\t\t\tclose([\"tr\"], [\"thead\", \"tbody\", \"tfoot\", ...tableStops]);\n\t\t\tclose([\"thead\", \"tbody\", \"tfoot\"], tableStops);\n\t\t} else if (name === \"option\" || name === \"optgroup\") {\n\t\t\tif (state.open.at(-1)?.name === \"option\") state.open.pop();\n\t\t\tif (name === \"optgroup\" && state.open.at(-1)?.name === \"optgroup\") {\n\t\t\t\tstate.open.pop();\n\t\t\t}\n\t\t} else if (name === \"rt\" || name === \"rp\") {\n\t\t\tconst top = state.open.at(-1)?.name;\n\t\t\tif (top === \"rt\" || top === \"rp\") state.open.pop();\n\t\t}\n\t};\n\n\t/** Open ancestors that Kiln knows of, innermost first, up to the nearest `<template>`. */\n\tconst ancestors = function* (state: State) {\n\t\tfor (let i = state.open.length - 1; i > 0; i--) {\n\t\t\tconst name = (state.open[i] as Entry).name;\n\t\t\tif (name === \"template\") return;\n\t\t\tif (name !== UNKNOWN) yield name;\n\t\t}\n\t};\n\n\tconst start = (tag: StartTag, state: State) => {\n\t\tconst { name, span } = tag;\n\t\timpliedEnds(state, name);\n\n\t\t// The parser ends an open link or button before another, and ignores a form inside a form.\n\t\tif (name === \"a\" || name === \"button\") {\n\t\t\tconst index = findOpen(state, [name], (open) =>\n\t\t\t\tname === \"a\" ? FORMATTING_MARKERS.has(open) : BUTTON_SCOPE.has(open),\n\t\t\t);\n\t\t\tif (index > 0) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-nested-interactive\",\n\t\t\t\t\t`<${name}> can't be inside another <${name}>, so the browser ends the first one here`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t\tpopThrough(state, index);\n\t\t\t}\n\t\t}\n\t\tif (name === \"form\" && [...ancestors(state)].includes(\"form\")) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\"<form> can't be inside another <form>, so the browser ignores it\",\n\t\t\t\tspan,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (FLOW.has(name)) {\n\t\t\tconst index = findOpen(state, [\"p\"], (open) => BUTTON_SCOPE.has(open));\n\t\t\tif (index > 0) {\n\t\t\t\tpopThrough(state, index);\n\t\t\t\tstate.endedParagraph = name === \"p\" ? null : tag;\n\t\t\t}\n\t\t}\n\t\tif (name === \"p\") state.endedParagraph = null;\n\n\t\tconst parent = state.open.at(-1) as Entry;\n\t\tconst holder = container(state);\n\t\tconst headingAllowed =\n\t\t\tHEADINGS.has(name) &&\n\t\t\t(holder.name === \"summary\" || holder.name === \"legend\");\n\t\tif (FLOW.has(name) && PHRASING_ONLY.has(holder.name) && !headingAllowed) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> can't be inside <${holder.name}>, which only holds text and inline elements`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (ONLY_CHILDREN[parent.name]?.includes(name) === false) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> can't be inside <${parent.name}>, which only holds ${listOf(ONLY_CHILDREN[parent.name] ?? [], \"and\")}`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (\n\t\t\tparent.name !== UNKNOWN &&\n\t\t\tparent.name !== \"template\" &&\n\t\t\tREQUIRED_PARENTS[name]?.includes(parent.name) === false\n\t\t) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> must be inside ${listOf(REQUIRED_PARENTS[name] ?? [], \"or\")}`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (FIRST_CHILD[name] === parent.name && parent.children > 0) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> must be the first child of <${parent.name}>`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t\t// A heading inside a heading: the parser ends the outer one.\n\t\tif (HEADINGS.has(name) && HEADINGS.has(parent.name)) state.open.pop();\n\n\t\tconst above = [...ancestors(state)];\n\t\tconst isInteractive = interactive(tag);\n\t\tconst holderOfInteractive = above.find(\n\t\t\t(open) => open === \"a\" || open === \"button\",\n\t\t);\n\t\tif (isInteractive && holderOfInteractive) {\n\t\t\treport(\n\t\t\t\t\"html-nested-interactive\",\n\t\t\t\t`<${name}> can't be inside <${holderOfInteractive}>, since interactive elements can't hold each other`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (name === \"label\" && above.includes(\"label\")) {\n\t\t\treport(\n\t\t\t\t\"html-nested-interactive\",\n\t\t\t\t\"<label> can't be inside another <label>\",\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t\tif (name === \"header\" || name === \"footer\") {\n\t\t\tconst outer = above.find(\n\t\t\t\t(open) => open === \"header\" || open === \"footer\",\n\t\t\t);\n\t\t\tif (outer) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\t`<${name}> can't be inside <${outer}>`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (name === \"main\") {\n\t\t\tconst wrong = above.find(\n\t\t\t\t(open) => !MAIN_PARENTS.has(open) && !open.includes(\"-\"),\n\t\t\t);\n\t\t\tif (wrong) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\t`<main> can't be inside <${wrong}>. It belongs in <body>, a <div> or a <form>`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst level = levelOf(name);\n\t\tif (level !== null) {\n\t\t\tif (state.heading !== null && level > state.heading + 1) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-heading-order\",\n\t\t\t\t\t`<${name}> skips a level after <h${state.heading}>. Use <h${state.heading + 1}>`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\tstate.heading = level;\n\t\t}\n\n\t\t(state.open.at(-1) as Entry).children++;\n\t\tconst leaf = VOID.has(name) || RAW_TEXT.has(name) || FOREIGN.has(name);\n\t\tif (!leaf) state.open.push({ name, children: 0 });\n\t};\n\n\tconst end = (name: string, state: State) => {\n\t\tif (name === \"p\") {\n\t\t\tconst index = findOpen(state, [\"p\"], (open) => BUTTON_SCOPE.has(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t\telse if (state.endedParagraph) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\t`<${state.endedParagraph.name}> can't be inside <p>, so the browser ends the paragraph before it`,\n\t\t\t\t\tstate.endedParagraph.span,\n\t\t\t\t);\n\t\t\t\tstate.endedParagraph = null;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// Any heading's end tag ends the open heading, whatever its level.\n\t\tconst names = HEADINGS.has(name) ? HEADINGS : [name];\n\t\tfor (let i = state.open.length - 1; i > 0; i--) {\n\t\t\tconst open = (state.open[i] as Entry).name;\n\t\t\tif (\"has\" in names ? names.has(open) : names.includes(open)) {\n\t\t\t\tpopThrough(state, i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\t/** Walks a body that renders somewhere else, such as a macro, so its parent is unknown. */\n\tconst elsewhere = (body: Statement[]) => walk(body, fresh());\n\n\t/** Walks a body that renders in place, or may be replaced, such as a layout's block. */\n\tconst replaceable = (body: Statement[], state: State) => {\n\t\tconst before = copy(state);\n\t\tconst after = copy(state);\n\t\twalk(body, after);\n\t\tmerge(state, [before, after]);\n\t\thole(state, true);\n\t};\n\n\tconst walk = (list: Statement[], state: State): void => {\n\t\tfor (const node of list) {\n\t\t\tif (node.type !== \"Text\" && insideTag(node.span.start)) continue;\n\t\t\tswitch (node.type) {\n\t\t\t\tcase \"Text\":\n\t\t\t\t\tfor (\n\t\t\t\t\t\tlet i = firstTag(node.span.start);\n\t\t\t\t\t\ti < tags.length && startOf(tags[i] as Tag) < node.span.end;\n\t\t\t\t\t\ti++\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst tag = tags[i] as Tag;\n\t\t\t\t\t\tif (tag.type === \"start\") start(tag, state);\n\t\t\t\t\t\telse end(tag.name, state);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Output\": {\n\t\t\t\t\t// Phrasing elements and `<p>` can't hold headings, so an output inside one can't add any.\n\t\t\t\t\tconst holder = container(state).name;\n\t\t\t\t\thole(state, !PHRASING_ONLY.has(holder) && holder !== \"p\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Include\":\n\t\t\t\t\thole(state, true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Component\":\n\t\t\t\t\telsewhere(node.body);\n\t\t\t\t\tfor (const fill of node.fills) elsewhere(fill.body);\n\t\t\t\t\thole(state, true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Island\":\n\t\t\t\t\telsewhere(node.body);\n\t\t\t\t\thole(state, true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"If\":\n\t\t\t\tcase \"For\": {\n\t\t\t\t\tconst bodies =\n\t\t\t\t\t\tnode.type === \"If\"\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t...node.branches.map((branch) => branch.body),\n\t\t\t\t\t\t\t\t\tnode.alternate ?? [],\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: [node.body, node.alternate ?? []];\n\t\t\t\t\tconst ends = bodies.map((body) => {\n\t\t\t\t\t\tconst branch = copy(state);\n\t\t\t\t\t\twalk(body, branch);\n\t\t\t\t\t\treturn branch;\n\t\t\t\t\t});\n\t\t\t\t\tmerge(state, ends);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Block\":\n\t\t\t\t\tif (layoutChild) elsewhere(node.body);\n\t\t\t\t\telse replaceable(node.body, state);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Slot\":\n\t\t\t\t\treplaceable(node.body, state);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"With\":\n\t\t\t\tcase \"Cache\":\n\t\t\t\tcase \"Autoescape\":\n\t\t\t\t\twalk(node.body, state);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Macro\":\n\t\t\t\tcase \"SetBlock\":\n\t\t\t\tcase \"Add\":\n\t\t\t\tcase \"Apply\":\n\t\t\t\t\telsewhere(node.body);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\twalk(template.ast.body, fresh());\n};\n","import { scanParts } from \"../lexer/lexer.js\";\nimport type { Span } from \"../source.js\";\nimport { FOREIGN, RAW_TEXT } from \"./data.js\";\n\nexport type Attribute = {\n\tname: string;\n\t/** From the start of the name to the end of the value. */\n\tspan: Span;\n\tnameSpan: Span;\n\t/** The written-out value, or null when it has none or is built at render time. */\n\tvalue: string | null;\n\t/** Where `value` starts in the source. */\n\tvalueStart: number;\n};\n\nexport type StartTag = {\n\ttype: \"start\";\n\tname: string;\n\t/** From `<` to the end of the name. */\n\tspan: Span;\n\t/** Just past the tag's `>`. */\n\tend: number;\n\tattributes: Attribute[];\n\t/** False when a tag or output among the attributes may add more, as `attrs(...)` does. */\n\tcomplete: boolean;\n\tselfClosing: boolean;\n};\n\nexport type EndTag = { type: \"end\"; name: string; start: number; end: number };\n\nexport type Tag = StartTag | EndTag;\n\n/** What each character of the source is, besides Kiln tags, which are 0: template text, an output such as `{{ x }}`, or a comment. */\nconst TEXT = 1;\nconst OUTPUT = 2;\nconst COMMENT = 3;\n\n/** Marks each character of the source as `TEXT`, `OUTPUT` or `COMMENT`, leaving Kiln tags and verbatim content at 0. */\nconst sourceMask = (source: string): Uint8Array => {\n\tconst mask = new Uint8Array(source.length);\n\tlet verbatim = false;\n\tfor (const part of scanParts(source).parts) {\n\t\tif (part.kind === \"text\" && !verbatim) {\n\t\t\tmask.fill(TEXT, part.start, part.end);\n\t\t} else if (part.kind === \"output\") {\n\t\t\tmask.fill(OUTPUT, part.start, part.end);\n\t\t} else if (part.kind === \"comment\") {\n\t\t\tmask.fill(COMMENT, part.start, part.end);\n\t\t}\n\t\tverbatim =\n\t\t\tpart.kind === \"tag\" &&\n\t\t\tpart.tokens.length === 3 &&\n\t\t\tpart.tokens[1]?.value === \"verbatim\";\n\t}\n\treturn mask;\n};\n\n/**\n * A template's source with every Kiln tag, output and comment, and verbatim content, replaced by spaces. Line breaks\n * stay, so offsets, lines and columns match the source. For HTML tools that should only see the markup.\n */\nexport const templateText = (source: string): string => {\n\tconst mask = sourceMask(source);\n\tlet text = \"\";\n\tlet start = 0;\n\tfor (let at = 0; at <= source.length; at++) {\n\t\tif (at < source.length && mask[at] === TEXT) continue;\n\t\ttext += source.slice(start, at);\n\t\tif (at < source.length) {\n\t\t\tconst char = source[at];\n\t\t\ttext += char === \"\\n\" || char === \"\\r\" ? char : \" \";\n\t\t}\n\t\tstart = at + 1;\n\t}\n\treturn text;\n};\n\nconst isSpace = (char: string | undefined) =>\n\tchar === \" \" ||\n\tchar === \"\\t\" ||\n\tchar === \"\\n\" ||\n\tchar === \"\\r\" ||\n\tchar === \"\\f\";\n\n/**\n * Reads the HTML tags in a template's text. Kiln syntax and outputs are holes whose content is unknown. It only reads\n * tags, never a tree of elements, so HTML split across `if` branches or templates never confuses it.\n */\nclass Scanner {\n\t#pos = 0;\n\n\tconstructor(\n\t\treadonly source: string,\n\t\treadonly mask: Uint8Array,\n\t) {}\n\n\t#text(at: number) {\n\t\treturn this.mask[at] === TEXT;\n\t}\n\n\t#output(at: number) {\n\t\treturn this.mask[at] === OUTPUT;\n\t}\n\n\t/** The character at `at` when it is template text, or undefined at a hole or the end. */\n\t#char(at: number): string | undefined {\n\t\treturn this.#text(at) ? this.source[at] : undefined;\n\t}\n\n\t#atHole() {\n\t\treturn this.#pos < this.source.length && !this.#text(this.#pos);\n\t}\n\n\t#skipHole() {\n\t\twhile (this.#atHole() && this.mask[this.#pos] !== COMMENT) this.#pos++;\n\t}\n\n\t#skipSpace() {\n\t\twhile (isSpace(this.#char(this.#pos))) this.#pos++;\n\t}\n\n\t/** Moves past the next `needle` written in the text, or to the end. */\n\t#skipPast(needle: string) {\n\t\twhile (this.#pos < this.source.length) {\n\t\t\tif (this.#matches(this.#pos, needle)) {\n\t\t\t\tthis.#pos += needle.length;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.#pos++;\n\t\t}\n\t}\n\n\t/** Whether `needle`, in lower case, is written in the text at `at`, in any case. */\n\t#matches(at: number, needle: string) {\n\t\tfor (let i = 0; i < needle.length; i++) {\n\t\t\tif (this.#char(at + i)?.toLowerCase() !== needle[i]) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Whether the first text is an XML declaration, as in a feed or a sitemap. */\n\tstartsWithXml(): boolean {\n\t\tfor (let at = 0; at < this.source.length; at++) {\n\t\t\tconst char = this.#char(at);\n\t\t\tif (char === undefined || isSpace(char) || char === \"\") continue;\n\t\t\treturn this.#matches(at, \"<?xml\");\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Reads characters up to whitespace, `/`, `>`, `stop` or a hole. */\n\t#word(stop?: string): string {\n\t\tconst start = this.#pos;\n\t\tfor (;;) {\n\t\t\tconst char = this.#char(this.#pos);\n\t\t\tif (\n\t\t\t\tchar === undefined ||\n\t\t\t\tisSpace(char) ||\n\t\t\t\tchar === \"/\" ||\n\t\t\t\tchar === \">\" ||\n\t\t\t\tchar === stop\n\t\t\t) {\n\t\t\t\treturn this.source.slice(start, this.#pos);\n\t\t\t}\n\t\t\tthis.#pos++;\n\t\t}\n\t}\n\n\t/** Moves past a raw text element's content, to its end tag. */\n\tskipRawText(name: string) {\n\t\twhile (this.#pos < this.source.length) {\n\t\t\tif (this.#matches(this.#pos, `</${name}`)) {\n\t\t\t\tconst after = this.#char(this.#pos + name.length + 2);\n\t\t\t\tif (\n\t\t\t\t\tafter === undefined ||\n\t\t\t\t\tisSpace(after) ||\n\t\t\t\t\tafter === \"/\" ||\n\t\t\t\t\tafter === \">\"\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#pos++;\n\t\t}\n\t}\n\n\t/** The next start or end tag, or null at the end of the source. Skips comments, doctypes and other text. */\n\tnext(): StartTag | EndTag | null {\n\t\twhile (this.#pos < this.source.length) {\n\t\t\tif (this.#char(this.#pos) !== \"<\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst next = this.#char(this.#pos + 1);\n\t\t\tif (this.#matches(this.#pos, \"<!--\")) {\n\t\t\t\tthis.#pos += 4;\n\t\t\t\tthis.#skipPast(\"-->\");\n\t\t\t} else if (next === \"!\" || next === \"?\") {\n\t\t\t\tthis.#skipPast(\">\");\n\t\t\t} else if (next === \"/\") {\n\t\t\t\tconst start = this.#pos;\n\t\t\t\tthis.#pos += 2;\n\t\t\t\tconst name = this.#word().toLowerCase();\n\t\t\t\tthis.#skipPast(\">\");\n\t\t\t\tif (name) return { type: \"end\", name, start, end: this.#pos };\n\t\t\t} else if (next !== undefined && /[a-z]/i.test(next)) {\n\t\t\t\treturn this.#startTag();\n\t\t\t} else {\n\t\t\t\tthis.#pos++;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t#startTag(): StartTag {\n\t\tconst start = this.#pos;\n\t\tthis.#pos++;\n\t\tconst name = this.#word().toLowerCase();\n\t\tconst tag: StartTag = {\n\t\t\ttype: \"start\",\n\t\t\tname,\n\t\t\tspan: { start, end: this.#pos },\n\t\t\tend: this.source.length,\n\t\t\tattributes: [],\n\t\t\tcomplete: true,\n\t\t\tselfClosing: false,\n\t\t};\n\t\twhile (this.#pos < this.source.length) {\n\t\t\t// A comment adds nothing, but a tag or output may add attributes.\n\t\t\tif (this.mask[this.#pos] === COMMENT) {\n\t\t\t\tthis.#pos++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (this.#atHole()) {\n\t\t\t\tthis.#skipHole();\n\t\t\t\ttag.complete = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst char = this.#char(this.#pos);\n\t\t\tif (char === \">\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\ttag.end = this.#pos;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (isSpace(char)) {\n\t\t\t\tthis.#pos++;\n\t\t\t} else if (char === \"/\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\tif (this.#char(this.#pos) === \">\") tag.selfClosing = true;\n\t\t\t} else {\n\t\t\t\tconst attribute = this.#attribute();\n\t\t\t\tif (attribute) tag.attributes.push(attribute);\n\t\t\t\telse tag.complete = false;\n\t\t\t}\n\t\t}\n\t\treturn tag;\n\t}\n\n\t/** Reads one attribute, or returns null when its name is built at render time. */\n\t#attribute(): Attribute | null {\n\t\tconst start = this.#pos;\n\t\t// A name touching an output, such as `aria-{{ x }}`, is only partly known.\n\t\tlet known = !this.#output(start - 1);\n\t\tthis.#pos++;\n\t\tthis.#word(\"=\");\n\t\twhile (this.#output(this.#pos)) {\n\t\t\tknown = false;\n\t\t\twhile (this.#output(this.#pos)) this.#pos++;\n\t\t\tthis.#word(\"=\");\n\t\t}\n\t\tconst nameSpan = { start, end: this.#pos };\n\t\tconst name = this.source.slice(start, this.#pos).toLowerCase();\n\n\t\tlet value: string | null = null;\n\t\tlet valueStart = this.#pos;\n\t\tconst beforeEquals = this.#pos;\n\t\tthis.#skipSpace();\n\t\tif (this.#char(this.#pos) === \"=\") {\n\t\t\tthis.#pos++;\n\t\t\tthis.#skipSpace();\n\t\t\tconst quote = this.#char(this.#pos);\n\t\t\tif (quote === '\"' || quote === \"'\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\tvalueStart = this.#pos;\n\t\t\t\tlet written = true;\n\t\t\t\twhile (\n\t\t\t\t\tthis.#pos < this.source.length &&\n\t\t\t\t\tthis.#char(this.#pos) !== quote\n\t\t\t\t) {\n\t\t\t\t\tif (this.#atHole()) written = false;\n\t\t\t\t\tthis.#pos++;\n\t\t\t\t}\n\t\t\t\tif (written) value = this.source.slice(valueStart, this.#pos);\n\t\t\t\tthis.#pos++;\n\t\t\t} else {\n\t\t\t\tvalueStart = this.#pos;\n\t\t\t\tlet written = true;\n\t\t\t\tfor (;;) {\n\t\t\t\t\tif (this.mask[this.#pos] === COMMENT) break;\n\t\t\t\t\tif (this.#atHole()) {\n\t\t\t\t\t\twritten = false;\n\t\t\t\t\t\tthis.#skipHole();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst char = this.#char(this.#pos);\n\t\t\t\t\tif (char === undefined || isSpace(char) || char === \">\") break;\n\t\t\t\t\tthis.#pos++;\n\t\t\t\t}\n\t\t\t\tif (written) value = this.source.slice(valueStart, this.#pos);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.#pos = beforeEquals;\n\t\t}\n\t\tif (!known) return null;\n\t\treturn {\n\t\t\tname,\n\t\t\tspan: { start, end: Math.min(this.#pos, this.source.length) },\n\t\t\tnameSpan,\n\t\t\tvalue,\n\t\t\tvalueStart,\n\t\t};\n\t}\n}\n\n/**\n * The HTML start and end tags written in a template's text, in source order. Leaves out what is inside `<svg>`,\n * `<math>` and elements whose content is text, such as `<script>`, and the end tags of `<svg>` and `<math>`. Returns\n * nothing for a template that starts with an XML declaration, such as a feed.\n */\nexport const scanTags = (source: string): Tag[] => {\n\tconst scanner = new Scanner(source, sourceMask(source));\n\tif (scanner.startsWithXml()) return [];\n\tconst tags: Tag[] = [];\n\t/** The open `svg` or `math` element, and how many of the same name are open inside it. */\n\tlet foreign: { name: string; depth: number } | null = null;\n\n\tfor (let tag = scanner.next(); tag; tag = scanner.next()) {\n\t\tif (foreign) {\n\t\t\tif (tag.name !== foreign.name) continue;\n\t\t\tif (tag.type === \"end\") {\n\t\t\t\tif (--foreign.depth === 0) foreign = null;\n\t\t\t} else if (!tag.selfClosing) foreign.depth++;\n\t\t\tcontinue;\n\t\t}\n\t\ttags.push(tag);\n\t\tif (tag.type === \"end\") continue;\n\t\t// The HTML parser ignores `/>` here, so `<script />` still holds text up to `</script>`.\n\t\tif (RAW_TEXT.has(tag.name)) scanner.skipRawText(tag.name);\n\t\telse if (FOREIGN.has(tag.name) && !tag.selfClosing) {\n\t\t\tforeign = { name: tag.name, depth: 1 };\n\t\t}\n\t}\n\treturn tags;\n};\n","import { createDiagnostic, type Diagnostic } from \"../errors.js\";\nimport type { CompiledTemplate } from \"../runtime/types.js\";\nimport type { Span } from \"../source.js\";\nimport { checkNesting } from \"./nesting.js\";\nimport {\n\tHTML_CHECKS,\n\ttype HtmlCheck,\n\ttype HtmlCheckLevels,\n} from \"./options.js\";\nimport { scanTags } from \"./scanner.js\";\nimport { checkTag } from \"./tags.js\";\n\nexport {\n\ttype HtmlCheck,\n\ttype HtmlCheckLevel,\n\ttype HtmlCheckLevels,\n\ttype HtmlChecks,\n\thtmlChecksOption,\n\tresolveHtmlChecks,\n} from \"./options.js\";\nexport { templateText } from \"./scanner.js\";\n\n/** Checks the HTML written in a template against the rules `levels` turns on. Never renders. */\nexport const checkHtml = (\n\ttemplate: CompiledTemplate,\n\tlevels: HtmlCheckLevels,\n): Diagnostic[] => {\n\tconst diagnostics: Diagnostic[] = [];\n\tif (HTML_CHECKS.every((code) => levels[code] === \"off\")) return diagnostics;\n\tconst report = (code: HtmlCheck, message: string, span: Span) => {\n\t\tconst level = levels[code];\n\t\tif (level === \"off\") return;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic(template.source, code, message, span, level),\n\t\t);\n\t};\n\n\tconst tags = scanTags(template.source.text);\n\tfor (const tag of tags) if (tag.type === \"start\") checkTag(tag, report);\n\tcheckNesting(template, tags, report);\n\treturn diagnostics;\n};\n","import { closeOutlets, takeOutput } from \"./outlets.js\";\nimport type { Out, RenderState } from \"./types.js\";\n\n/**\n * Sends a streamed render's output as it becomes final, for `renderStream`.\n *\n * Host code that returns a promise calls `wait`. The send happens once the render is really waiting, after the\n * microtasks already queued, so promises that settle at once share one send instead of making many small ones.\n */\nexport class RenderStream {\n\t#timer: ReturnType<typeof setTimeout> | null = null;\n\n\tconstructor(\n\t\treadonly state: RenderState,\n\t\treadonly root: Out,\n\t\t/** Sends a part of the page. Must not throw, since it runs from a timer. */\n\t\treadonly send: (text: string) => void,\n\t) {}\n\n\t/** The render is about to wait for host code. */\n\twait(): void {\n\t\tthis.#timer ??= setTimeout(() => {\n\t\t\tthis.#timer = null;\n\t\t\tthis.flush();\n\t\t}, 0);\n\t}\n\n\t/** Sends the output that is final so far. */\n\tflush(): void {\n\t\tconst text = takeOutput(this.state, this.root.s);\n\t\tif (text !== \"\") this.send(text);\n\t}\n\n\t/** Sends the rest of the output, once the render has finished. */\n\tend(): void {\n\t\tthis.stop();\n\t\tcloseOutlets(this.state);\n\t\tthis.flush();\n\t}\n\n\t/** Cancels a pending send. */\n\tstop(): void {\n\t\tif (this.#timer === null) return;\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = null;\n\t}\n}\n","import { type Analysis, analyzeTemplate } from \"./analyzer.js\";\nimport { builtinFilters } from \"./builtins/filters.js\";\nimport { builtinFunctions, builtinTests } from \"./builtins/functions.js\";\nimport { checkReferences } from \"./checker.js\";\nimport { generateModule } from \"./compiler/codegen.js\";\nimport { compileTemplate } from \"./compiler/compiler.js\";\nimport {\n\tcompilePrecompiled,\n\tisPrecompiled,\n\ttype PrecompiledTemplate,\n} from \"./compiler/precompiled.js\";\nimport {\n\ttype Diagnostic,\n\tKilnIssue,\n\tKilnRenderError,\n\tKilnSyntaxError,\n} from \"./errors.js\";\nimport {\n\tcheckHtml,\n\ttype HtmlCheckLevels,\n\ttype HtmlChecks,\n\tresolveHtmlChecks,\n} from \"./html/index.js\";\nimport { resolveTemplateName } from \"./names.js\";\nimport type { EscapeStrategy } from \"./parser/ast.js\";\nimport { ESCAPE_STRATEGIES } from \"./parser/ast.js\";\nimport type { IslandMode } from \"./runtime/islands.js\";\nimport { closeOutlets, takeOutput } from \"./runtime/outlets.js\";\nimport {\n\taddSlotFlags,\n\tisPromise,\n\trenderTemplate,\n\tsilence,\n} from \"./runtime/render.js\";\nimport { childScope } from \"./runtime/scope.js\";\nimport { RenderStream } from \"./runtime/stream.js\";\nimport {\n\ttype AbortSignalLike,\n\ttype CallableEntry,\n\ttype CompiledTemplate,\n\ttype EnvironmentCore,\n\ttype KilnCache,\n\temptyOut,\n\ttype Out,\n\ttype RenderInfo,\n\tRenderState,\n\ttype Scope,\n\ttype TypeCheck,\n} from \"./runtime/types.js\";\nimport { hashKeys, isPlainObject, typeName } from \"./runtime/values.js\";\n\nexport type { RenderInfo };\n\n/**\n * Where templates come from. Kiln calls `load` once per resolved name that exists, until `invalidate`, and remembers\n * a limited number of missing names.\n */\nexport type Loader = {\n\t/**\n\t * Returns the source for a resolved name, such as `pages/page.kiln`, or a precompiled module's default export, or\n\t * `null` if it does not exist. May return a promise or another thenable.\n\t */\n\tload(\n\t\tname: string,\n\t):\n\t\t| string\n\t\t| PrecompiledTemplate\n\t\t| null\n\t\t| PromiseLike<string | PrecompiledTemplate | null>;\n\t/** Returns every resolved name the loader holds. Rendering never calls it; tools such as `generateTypes` do. */\n\tlist?(): string[] | Promise<string[]>;\n};\n\n/**\n * TypeScript types for host prop types, such as `Post`. Empty until the host adds to it:\n *\n * ```ts\n * declare module \"@lucidkiln/core\" {\n * \tinterface KilnTypes { Post: PostView }\n * }\n * ```\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnTypes {}\n\n/**\n * Project-wide template defaults, keyed by name without `.kiln`. An explicit schema on `createKiln` replaces these.\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnTemplates {}\n\n/** The template and host-type maps for one environment. `generateTypes` writes a schema for each template root. */\nexport type KilnSchema = {\n\ttemplates: Record<string, { context: object; blocks: string }>;\n\ttypes: object;\n};\n\ntype DefaultSchema = {\n\ttemplates: { [Name in keyof KilnTemplates]: KilnTemplates[Name] };\n\ttypes: KilnTypes;\n};\n\n/** The `types` option: a type guard for each host type, plus any other checks. */\nexport type TypeChecks<Types extends object = KilnTypes> = {\n\t[Name in keyof Types]: (value: unknown) => value is Types[Name];\n} & Record<string, TypeCheck>;\n\n/** A template name. Known names complete in editors, and any other string is accepted. */\n// oxlint-disable-next-line typescript/no-redundant-type-constituents -- known names may be empty before types are generated\nexport type TemplateName<Templates extends object = KilnTemplates> =\n\t| (keyof Templates & string)\n\t| (string & {});\n\ntype TemplateEntry<Name extends string, Templates extends object> = (\n\tName extends `${infer Base}.kiln` ? Base : Name\n) extends infer Key\n\t? Key extends keyof Templates\n\t\t? Templates[Key]\n\t\t: undefined\n\t: undefined;\n\n/** The data `render` takes for a template. Any data for a name its template map doesn't list. */\nexport type TemplateContext<\n\tName extends string,\n\tTemplates extends object = KilnTemplates,\n> =\n\tTemplateEntry<Name, Templates> extends { context: infer Context }\n\t\t? Context\n\t\t: Record<string, unknown>;\n\n/** The block names `renderBlock` takes for a template. Any name for a template its map doesn't list. */\nexport type TemplateBlock<\n\tName extends string,\n\tTemplates extends object = KilnTemplates,\n> =\n\tTemplateEntry<Name, Templates> extends { blocks: infer Block }\n\t\t? Block\n\t\t: string;\n\nconst renderAware: unique symbol = Symbol(\"kiln.renderAware\");\n\n/** A host function that receives `RenderInfo` before its arguments. Create it with `withRender`. */\nexport type RenderAware<State> = {\n\treadonly [renderAware]: true;\n\treadonly call: (render: RenderInfo<State>, ...args: never) => unknown;\n};\n\n/** A function, filter or test a host registers. Parameter types are the host's to declare. */\nexport type KilnCallable<State = undefined> =\n\t| ((...args: never) => unknown)\n\t| RenderAware<State>;\n\nexport type Limits = {\n\t/** Characters of output, counted as string length. */\n\tmaxOutputLength: number;\n\t/** Tags, outputs, loop iterations and calls executed. */\n\tmaxSteps: number;\n\t/** Nested includes, components, macro calls and layouts. */\n\tmaxDepth: number;\n};\n\nexport type KilnOptions<\n\tState = undefined,\n\tSchema extends KilnSchema = DefaultSchema,\n> = {\n\tloader: Loader;\n\tfunctions?: Record<string, KilnCallable<State>>;\n\tfilters?: Record<string, KilnCallable<State>>;\n\ttests?: Record<string, KilnCallable<State>>;\n\tglobals?: Record<string, unknown>;\n\t/** Undefined variables and missing properties are errors. Default `true`. */\n\tstrict?: boolean;\n\t/** Default escaping strategy for `{{ }}`. Default `\"html\"`. */\n\tautoescape?: EscapeStrategy | false;\n\t/** Default `Intl` locale. Default `\"en\"`. */\n\tlocale?: string;\n\t/** Default time zone for `formatDate`. Default `\"UTC\"`. */\n\ttimeZone?: string;\n\t/** Enables `dump`. Default `false`. */\n\tdebug?: boolean;\n\t/** Where the `cache` tag saves output, such as `memoryCache()`. Without it, the tag renders every time. */\n\tcache?: KilnCache;\n\t/** App and build identity added to fragment cache keys. Default `\"\"`. */\n\tcacheNamespace?: string;\n\tlimits?: Partial<Limits>;\n\t/** Which HTML rules `check` reports, and at what level. Default `true`, every rule as a warning. */\n\thtmlChecks?: HtmlChecks;\n} & (keyof Schema[\"types\"] extends never\n\t? { types?: TypeChecks<Schema[\"types\"]> }\n\t: { types: TypeChecks<Schema[\"types\"]> });\n\ntype BaseRenderOptions = {\n\tlocale?: string;\n\ttimeZone?: string;\n\t/** Stops the render when aborted. A real `AbortSignal` works. */\n\tsignal?: AbortSignalLike;\n\t/**\n\t * Defers `island` tags with `deferIslands`, or streams them with `streamIslands` in `renderStream`. Without it,\n\t * islands render in place.\n\t */\n\tislands?: IslandMode;\n};\n\n/** `state` is required when the environment was created with a `State` type. */\nexport type RenderOptions<State = undefined> = BaseRenderOptions &\n\t(undefined extends State ? { state?: State } : { state: State });\n\n/** The data and options after a template name: the data is optional when every key is, and the options when `State` allows it. */\ntype RenderArguments<Context, State> = [\n\t// oxlint-disable-next-line typescript/no-empty-object-type -- `{}` is the data with no keys\n\t...({} extends Context ? [context?: Context] : [context: Context]),\n\t...(undefined extends State\n\t\t? [options?: RenderOptions<State>]\n\t\t: [options: RenderOptions<State>]),\n];\n\nexport type Kiln<\n\tState = undefined,\n\tSchema extends KilnSchema = DefaultSchema,\n> = {\n\t/** Renders a template. Rejects with `KilnSyntaxError` or `KilnRenderError`. */\n\trender<Name extends TemplateName<Schema[\"templates\"]>>(\n\t\tname: Name,\n\t\t...args: RenderArguments<TemplateContext<Name, Schema[\"templates\"]>, State>\n\t): Promise<string>;\n\t/**\n\t * Renders one block of a template, such as a fragment for an htmx or fetch request. Child templates' top-level statements run first, as in `render`.\n\t */\n\trenderBlock<Name extends TemplateName<Schema[\"templates\"]>>(\n\t\tname: Name,\n\t\tblock: TemplateBlock<Name, Schema[\"templates\"]>,\n\t\t...args: RenderArguments<TemplateContext<Name, Schema[\"templates\"]>, State>\n\t): Promise<string>;\n\t/**\n\t * Renders a template as a stream of UTF-8 bytes, sending each part as soon as it is final. Resolves once the first\n\t * part is ready, or rejects as `render` would when the render fails before then. A later failure errors the stream.\n\t */\n\trenderStream<Name extends TemplateName<Schema[\"templates\"]>>(\n\t\tname: Name,\n\t\t...args: RenderArguments<TemplateContext<Name, Schema[\"templates\"]>, State>\n\t): Promise<ReadableStream<Uint8Array>>;\n\t/** Parses and checks a template without rendering it. Pass `source` to check unsaved text. */\n\tcheck(name: string, source?: string): Promise<Diagnostic[]>;\n\t/** Reports what a template uses: variables, props, functions, filters, tests, templates, blocks and macros. */\n\tanalyze(name: string, source?: string): Promise<Analysis>;\n\t/**\n\t * Compiles a template to the source of a JavaScript module, at build time. Loaders return the module's default\n\t * export in place of the source. Rejects with `KilnSyntaxError` when the template has problems.\n\t */\n\tprecompile(name: string, source?: string): Promise<string>;\n\t/** Drops one compiled template, or all of them, from the cache. */\n\tinvalidate(name?: string): void;\n};\n\n/**\n * Wraps a host function so it receives request-specific `RenderInfo` first, including the `state` passed to `render`.\n *\n * ```ts\n * document: withRender((render, collection: string) => fetchDocument(collection, render.state.locale))\n * ```\n */\nexport const withRender = <State, Args extends unknown[], Result>(\n\tfn: (render: RenderInfo<State>, ...args: Args) => Result,\n): RenderAware<State> => ({\n\t[renderAware]: true,\n\tcall: fn as unknown as RenderAware<State>[\"call\"],\n});\n\nconst DEFAULT_LIMITS: Limits = {\n\tmaxOutputLength: 5_000_000,\n\tmaxSteps: 1_000_000,\n\tmaxDepth: 64,\n};\n\n/** The default limits with the host's on top. A limit left out or `undefined` keeps its default. */\nconst checkLimits = (limits: Partial<Limits> | undefined): Limits => {\n\tconst result = { ...DEFAULT_LIMITS };\n\tif (limits === undefined) return result;\n\tfor (const key of Object.keys(DEFAULT_LIMITS) as (keyof Limits)[]) {\n\t\tconst value: unknown = limits[key];\n\t\tif (value === undefined) continue;\n\t\tif (typeof value !== \"number\" || !(value > 0)) {\n\t\t\tthrow new TypeError(`limits.${key} must be a number above 0`);\n\t\t}\n\t\tresult[key] = value;\n\t}\n\treturn result;\n};\n\n/** How many missing template names an environment remembers, so it doesn't ask its loader again on every render. */\nconst MAX_MISSING = 1000;\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n\ttypeof value === \"object\" &&\n\tvalue !== null &&\n\ttypeof (value as { then?: unknown }).then === \"function\";\n\n/** Resolves a name passed to the API, failing with a `KilnRenderError` for an invalid one. */\nconst resolveName = (name: string): string => {\n\tif (typeof name !== \"string\") {\n\t\tthrow new TypeError(\n\t\t\t`Template name must be a string, but got a ${typeName(name)}`,\n\t\t);\n\t}\n\ttry {\n\t\treturn resolveTemplateName(name);\n\t} catch (error) {\n\t\tif (!(error instanceof KilnIssue)) throw error;\n\t\tthrow new KilnRenderError(error.code, error.message, name);\n\t}\n};\n\nconst NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst TYPE_NAME = /^[A-Z][A-Za-z0-9_]*$/;\nconst TEST_NAME = /^[A-Za-z_][A-Za-z0-9_]*( [A-Za-z_][A-Za-z0-9_]*)?$/;\nconst RESERVED = {\n\tfunction: new Set([\"parent\", \"block\"]),\n\tfilter: new Set([\"default\", \"raw\", \"escape\"]),\n\ttest: new Set([\"defined\"]),\n};\n\nconst builtinMaps = new WeakMap<\n\tRecord<string, CallableEntry>,\n\tReadonlyMap<string, CallableEntry>\n>();\n\n/** Built-ins of one kind as a map, made once and shared by environments that add none of their own. */\nconst builtinMap = (\n\tbuiltins: Record<string, CallableEntry>,\n): ReadonlyMap<string, CallableEntry> => {\n\tlet map = builtinMaps.get(builtins);\n\tif (!map) {\n\t\tmap = new Map(Object.entries(builtins));\n\t\tbuiltinMaps.set(builtins, map);\n\t}\n\treturn map;\n};\n\nconst registry = <State>(\n\tkind: \"function\" | \"filter\" | \"test\",\n\tbuiltins: Record<string, CallableEntry>,\n\thost: Record<string, KilnCallable<State>> | undefined,\n): ReadonlyMap<string, CallableEntry> => {\n\tconst shared = builtinMap(builtins);\n\tif (!host || Object.keys(host).length === 0) return shared;\n\tconst entries = new Map(shared);\n\tfor (const [name, value] of Object.entries(host)) {\n\t\tif (!(kind === \"test\" ? TEST_NAME : NAME).test(name)) {\n\t\t\tthrow new TypeError(`\"${name}\" is not a valid ${kind} name`);\n\t\t}\n\t\tif (RESERVED[kind].has(name)) {\n\t\t\tthrow new TypeError(`\"${name}\" is a reserved ${kind} name`);\n\t\t}\n\t\tif (typeof value === \"function\") {\n\t\t\tentries.set(name, {\n\t\t\t\tkind: \"host\",\n\t\t\t\tname,\n\t\t\t\tcall: value as (...args: unknown[]) => unknown,\n\t\t\t\trender: false,\n\t\t\t});\n\t\t} else if (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\trenderAware in value\n\t\t) {\n\t\t\tentries.set(name, {\n\t\t\t\tkind: \"host\",\n\t\t\t\tname,\n\t\t\t\tcall: value.call as (...args: unknown[]) => unknown,\n\t\t\t\trender: true,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new TypeError(`${kind} \"${name}\" must be a function`);\n\t\t}\n\t}\n\treturn entries;\n};\n\nclass Environment<State, Schema extends KilnSchema> implements EnvironmentCore {\n\treadonly strict: boolean;\n\treadonly debug: boolean;\n\treadonly autoescape: EscapeStrategy | false;\n\treadonly functions: ReadonlyMap<string, CallableEntry>;\n\treadonly filters: ReadonlyMap<string, CallableEntry>;\n\treadonly tests: ReadonlyMap<string, CallableEntry>;\n\treadonly types: Map<string, TypeCheck>;\n\treadonly globals: Scope;\n\treadonly limits: Limits;\n\treadonly locale: string;\n\treadonly timeZone: string;\n\treadonly cache: KilnCache | null;\n\treadonly cacheNamespace: string;\n\treadonly htmlChecks: HtmlCheckLevels;\n\treadonly #loader: Loader;\n\treadonly #cache = new Map<\n\t\tstring,\n\t\tCompiledTemplate | Promise<CompiledTemplate | null>\n\t>();\n\t/** Names the loader didn't find. Names may come from requests, so only a limited number are remembered. */\n\treadonly #missing = new Set<string>();\n\t/** Names passed to `render`, resolved. */\n\treadonly #names = new Map<string, string>();\n\tgeneration = 0;\n\n\tconstructor(options: KilnOptions<State, Schema>) {\n\t\tif (typeof options.loader?.load !== \"function\") {\n\t\t\tthrow new TypeError(\"createKiln needs a loader with a load(name) method\");\n\t\t}\n\t\tif (\n\t\t\toptions.autoescape !== undefined &&\n\t\t\toptions.autoescape !== false &&\n\t\t\t!ESCAPE_STRATEGIES.includes(options.autoescape)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Unknown escaping strategy \"${String(options.autoescape)}\"`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\toptions.cache !== undefined &&\n\t\t\t(typeof options.cache?.get !== \"function\" ||\n\t\t\t\ttypeof options.cache.set !== \"function\")\n\t\t) {\n\t\t\tthrow new TypeError(\"createKiln needs a cache with get and set methods\");\n\t\t}\n\t\tif (\n\t\t\toptions.cacheNamespace !== undefined &&\n\t\t\ttypeof options.cacheNamespace !== \"string\"\n\t\t) {\n\t\t\tthrow new TypeError(\"cacheNamespace must be a string\");\n\t\t}\n\t\tthis.#loader = options.loader;\n\t\tthis.cache = options.cache ?? null;\n\t\tthis.cacheNamespace = options.cacheNamespace ?? \"\";\n\t\tthis.strict = options.strict ?? true;\n\t\tthis.debug = options.debug ?? false;\n\t\tthis.autoescape = options.autoescape ?? \"html\";\n\t\tthis.locale = options.locale ?? \"en\";\n\t\tthis.timeZone = options.timeZone ?? \"UTC\";\n\t\tthis.limits = checkLimits(options.limits);\n\t\tthis.htmlChecks = resolveHtmlChecks(options.htmlChecks);\n\t\tthis.functions = registry(\"function\", builtinFunctions, options.functions);\n\t\tthis.filters = registry(\"filter\", builtinFilters, options.filters);\n\t\tthis.tests = registry(\"test\", builtinTests, options.tests);\n\t\tthis.types = new Map();\n\t\tfor (const [name, check] of Object.entries<TypeCheck>(\n\t\t\toptions.types ?? {},\n\t\t)) {\n\t\t\tif (!TYPE_NAME.test(name)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`\"${name}\" is not a valid type name. Type names start with a capital letter`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (typeof check !== \"function\") {\n\t\t\t\tthrow new TypeError(`type \"${name}\" must be a function`);\n\t\t\t}\n\t\t\tthis.types.set(name, check);\n\t\t}\n\n\t\tconst globals = childScope(null);\n\t\tconst provided = options.globals ?? {};\n\t\tif (!isPlainObject(provided))\n\t\t\tthrow new TypeError(\"globals must be a plain object\");\n\t\tfor (const key of hashKeys(provided)) globals[key] = provided[key] ?? null;\n\t\tthis.globals = globals;\n\t}\n\n\tload(\n\t\tname: string,\n\t): CompiledTemplate | null | Promise<CompiledTemplate | null> {\n\t\tconst cached = this.#cache.get(name);\n\t\tif (cached !== undefined) return cached;\n\t\tif (this.#missing.has(name)) return null;\n\n\t\tconst compile = (source: string | PrecompiledTemplate | null) => {\n\t\t\tif (source === null) return null;\n\t\t\tif (typeof source === \"string\") {\n\t\t\t\treturn compileTemplate(this, name, source);\n\t\t\t}\n\t\t\tif (isPrecompiled(source)) return compilePrecompiled(this, name, source);\n\t\t\tthrow new TypeError(\n\t\t\t\t`Loader returned a ${typeName(source)} for \"${name}\", not a string, a precompiled template or null`,\n\t\t\t);\n\t\t};\n\t\tconst keep = (template: CompiledTemplate | null) => {\n\t\t\tif (template !== null) this.#cache.set(name, template);\n\t\t\telse {\n\t\t\t\tif (this.#missing.size >= MAX_MISSING) this.#missing.clear();\n\t\t\t\tthis.#missing.add(name);\n\t\t\t}\n\t\t};\n\n\t\tconst result = this.#loader.load(name);\n\t\t// A loader may return a thenable, such as a promise from another realm.\n\t\tconst loaded = isThenable(result) ? Promise.resolve(result) : result;\n\t\tif (loaded instanceof Promise) {\n\t\t\t// An invalidate while this load is in flight replaces or drops the\n\t\t\t// entry, so only touch the cache if it still holds this load. A load\n\t\t\t// or compile that fails is forgotten, so the next render tries again.\n\t\t\tconst pending: Promise<CompiledTemplate | null> = loaded\n\t\t\t\t.then(compile)\n\t\t\t\t.then(\n\t\t\t\t\t(template) => {\n\t\t\t\t\t\tif (this.#cache.get(name) === pending) {\n\t\t\t\t\t\t\tthis.#cache.delete(name);\n\t\t\t\t\t\t\tkeep(template);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn template;\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tif (this.#cache.get(name) === pending) this.#cache.delete(name);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\tthis.#cache.set(name, pending);\n\t\t\treturn pending;\n\t\t}\n\t\tconst template = compile(loaded);\n\t\tkeep(template);\n\t\treturn template;\n\t}\n\n\tinvalidate(name?: string): void {\n\t\tif (name === undefined) {\n\t\t\tthis.#cache.clear();\n\t\t\tthis.#missing.clear();\n\t\t} else {\n\t\t\tconst resolved = resolveName(name);\n\t\t\tthis.#cache.delete(resolved);\n\t\t\tthis.#missing.delete(resolved);\n\t\t}\n\t\tthis.generation++;\n\t}\n\n\t/** Compiles unsaved source, or loads the template, for `check` and `analyze`. */\n\tasync compileFor(\n\t\tname: string,\n\t\tsource?: string,\n\t): Promise<CompiledTemplate | null> {\n\t\tconst resolved = resolveName(name);\n\t\tif (source !== undefined) return compileTemplate(this, resolved, source);\n\t\treturn await this.load(resolved);\n\t}\n\n\t/** Renders a template, or only one of its blocks when `block` is given. */\n\tasync render(\n\t\tname: string,\n\t\tcontext: Record<string, unknown> = {},\n\t\toptions: BaseRenderOptions & { state?: State } = {},\n\t\tblock?: string,\n\t): Promise<string> {\n\t\tlet render = this.#prepare(name, context, options);\n\t\tif (isPromise(render)) render = await render;\n\t\tconst result = this.#run(render, block);\n\t\tif (result !== undefined) {\n\t\t\tawait untilAborted(result, render.state.signal, render.resolved);\n\t\t}\n\t\tconst { state, out } = render;\n\t\t// The signal may have been aborted while the last call was pending, after the render's last check.\n\t\tif (state.signal?.aborted) throw aborted(render.resolved);\n\t\tcloseOutlets(state);\n\t\tconst output = takeOutput(state, out.s);\n\t\tif (output.length > state.maxSize) throw tooLong(render);\n\t\treturn output;\n\t}\n\n\t/**\n\t * Renders a template as a stream, sending its output as it becomes final. Resolves once the first part is ready,\n\t * or rejects when the render fails before then. A later failure errors the stream.\n\t */\n\tasync renderStream(\n\t\tname: string,\n\t\tcontext: Record<string, unknown> = {},\n\t\toptions: BaseRenderOptions & { state?: State } = {},\n\t): Promise<ReadableStream<Uint8Array>> {\n\t\tlet render = this.#prepare(name, context, options);\n\t\tif (isPromise(render)) render = await render;\n\t\tconst { state, out } = render;\n\t\tconst encoder = new TextEncoder();\n\t\tlet controller!: ReadableStreamDefaultController<Uint8Array>;\n\t\tlet cancelled = false;\n\t\tconst stream = new ReadableStream<Uint8Array>({\n\t\t\tstart: (c) => {\n\t\t\t\tcontroller = c;\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tcancelled = true;\n\t\t\t},\n\t\t});\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet opened = false;\n\t\t\tlet failed = false;\n\t\t\tlet length = 0;\n\t\t\tconst open = () => {\n\t\t\t\tif (opened) return;\n\t\t\t\topened = true;\n\t\t\t\tresolve(stream);\n\t\t\t};\n\t\t\tconst failWith = (error: unknown) => {\n\t\t\t\tif (failed) return;\n\t\t\t\tfailed = true;\n\t\t\t\toutput.stop();\n\t\t\t\tstate.signal?.removeEventListener?.(\"abort\", stop);\n\t\t\t\tif (!opened) reject(error);\n\t\t\t\telse if (!cancelled) controller.error(error);\n\t\t\t};\n\t\t\t// An abort ends the stream at once, even while the page or an island waits for your code. The render\n\t\t\t// stops at its next step.\n\t\t\tconst stop = () => failWith(aborted(render.resolved));\n\t\t\tstate.signal?.addEventListener?.(\"abort\", stop);\n\t\t\t// The first half of a character split across two sends, held back so each part encodes to valid UTF-8.\n\t\t\tlet held = \"\";\n\t\t\tconst send = (text: string) => {\n\t\t\t\tif (failed) return;\n\t\t\t\tlength += text.length;\n\t\t\t\tif (length > state.maxSize) return failWith(tooLong(render));\n\t\t\t\ttext = held + text;\n\t\t\t\theld = \"\";\n\t\t\t\tconst last = text.charCodeAt(text.length - 1);\n\t\t\t\tif (last >= 0xd800 && last <= 0xdbff) {\n\t\t\t\t\theld = text.slice(-1);\n\t\t\t\t\ttext = text.slice(0, -1);\n\t\t\t\t}\n\t\t\t\tif (!cancelled && text !== \"\") {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(text));\n\t\t\t\t}\n\t\t\t\topen();\n\t\t\t};\n\t\t\tconst output = new RenderStream(state, out, send);\n\t\t\tstate.stream = output;\n\t\t\tconst close = () => {\n\t\t\t\tstate.signal?.removeEventListener?.(\"abort\", stop);\n\t\t\t\tif (failed || cancelled) return;\n\t\t\t\tif (held !== \"\") controller.enqueue(encoder.encode(held));\n\t\t\t\tcontroller.close();\n\t\t\t};\n\t\t\t// Streamed islands follow the page, each as soon as it is ready.\n\t\t\tconst finish = () => {\n\t\t\t\tif (state.signal?.aborted) return failWith(aborted(render.resolved));\n\t\t\t\toutput.end();\n\t\t\t\tif (failed) return;\n\t\t\t\topen();\n\t\t\t\tconst islands = state.streamed;\n\t\t\t\tif (islands === null) return close();\n\t\t\t\tlet left = islands.length;\n\t\t\t\tfor (const island of islands) {\n\t\t\t\t\tisland.then((html) => {\n\t\t\t\t\t\tsend(html);\n\t\t\t\t\t\tif (--left === 0) close();\n\t\t\t\t\t}, failWith);\n\t\t\t\t}\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst result = this.#run(render);\n\t\t\t\tif (result === undefined) finish();\n\t\t\t\telse result.then(finish, failWith);\n\t\t\t} catch (error) {\n\t\t\t\tfailWith(error);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Finds the template and makes the state, scope and output for one render. */\n\t#prepare(\n\t\tname: string,\n\t\tcontext: Record<string, unknown>,\n\t\toptions: BaseRenderOptions & { state?: State },\n\t): Prepared | Promise<Prepared> {\n\t\tlet resolved = this.#names.get(name);\n\t\tif (resolved === undefined) {\n\t\t\tresolved = resolveName(name);\n\t\t\t// Names may come from requests, so the cache can't grow without limit.\n\t\t\tif (this.#names.size >= 1000) this.#names.clear();\n\t\t\tthis.#names.set(name, resolved);\n\t\t}\n\t\tlet template: ReturnType<typeof this.load>;\n\t\ttry {\n\t\t\ttemplate = this.load(resolved);\n\t\t} catch (error) {\n\t\t\tthrow loaderError(resolved, error);\n\t\t}\n\t\tif (isPromise(template)) {\n\t\t\tconst path = resolved;\n\t\t\treturn untilAborted(\n\t\t\t\ttemplate.then(\n\t\t\t\t\t(loaded) => this.#prepared(path, loaded, context, options),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tthrow loaderError(path, error);\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t\toptions.signal,\n\t\t\t\tpath,\n\t\t\t);\n\t\t}\n\t\treturn this.#prepared(resolved, template, context, options);\n\t}\n\n\t#prepared(\n\t\tresolved: string,\n\t\ttemplate: CompiledTemplate | null,\n\t\tcontext: Record<string, unknown>,\n\t\toptions: BaseRenderOptions & { state?: State },\n\t): Prepared {\n\t\tif (!template) {\n\t\t\tthrow new KilnRenderError(\n\t\t\t\t\"missing-template\",\n\t\t\t\t`Template \"${resolved}\" was not found`,\n\t\t\t\tresolved,\n\t\t\t);\n\t\t}\n\t\tif (template.hasErrors) throw template.syntaxError();\n\t\tif (!isPlainObject(context)) {\n\t\t\tthrow new TypeError(\"render context must be a plain object\");\n\t\t}\n\n\t\tconst state = new RenderState(\n\t\t\tthis,\n\t\t\tthis.globals,\n\t\t\tthis.limits.maxSteps,\n\t\t\tthis.limits.maxOutputLength,\n\t\t\tthis.limits.maxDepth,\n\t\t\toptions.locale ?? this.locale,\n\t\t\toptions.timeZone ?? this.timeZone,\n\t\t\toptions.state,\n\t\t\toptions.signal,\n\t\t);\n\t\tif (options.signal?.aborted) throw aborted(resolved);\n\n\t\tconst scope = childScope(this.globals);\n\t\tconst passed = hashKeys(context);\n\t\tfor (const key of passed) scope[key] = context[key] ?? null;\n\t\taddSlotFlags(scope, template, null);\n\n\t\tstate.islands = options.islands ?? null;\n\t\tconst out = emptyOut();\n\t\tstate.root = out;\n\t\treturn { resolved, template, state, scope, passed, out };\n\t}\n\n\t#run(render: Prepared, block?: string): void | Promise<void> {\n\t\tconst { template } = render;\n\t\treturn renderTemplate(\n\t\t\trender.state,\n\t\t\ttemplate,\n\t\t\trender.scope,\n\t\t\trender.out,\n\t\t\t0,\n\t\t\tnull,\n\t\t\trender.passed,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\ttemplate.parentSpan,\n\t\t\tblock,\n\t\t);\n\t}\n}\n\n/** One render, ready to run. */\ntype Prepared = {\n\tresolved: string;\n\ttemplate: CompiledTemplate;\n\tstate: RenderState;\n\tscope: Scope;\n\tpassed: readonly string[];\n\tout: Out;\n};\n\nconst aborted = (resolved: string) =>\n\tnew KilnRenderError(\"aborted\", \"Render was aborted\", resolved);\n\n/**\n * Waits for `work`, or rejects as soon as `signal` aborts, when the signal can say so, as a real `AbortSignal` can.\n * The render itself stops at its next step, once the call it waits for settles.\n */\nconst untilAborted = <T>(\n\twork: Promise<T>,\n\tsignal: AbortSignalLike | undefined,\n\tresolved: string,\n): Promise<T> => {\n\tif (signal?.addEventListener === undefined) return work;\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst stop = () => {\n\t\t\tsilence(work);\n\t\t\treject(aborted(resolved));\n\t\t};\n\t\tif (signal.aborted) return stop();\n\t\tsignal.addEventListener?.(\"abort\", stop);\n\t\twork\n\t\t\t.finally(() => signal.removeEventListener?.(\"abort\", stop))\n\t\t\t.then(resolve, reject);\n\t});\n};\n\n/** A loader's error for the template a render asked for, as an include would report it. Kiln errors pass through. */\nconst loaderError = (resolved: string, error: unknown): unknown =>\n\terror instanceof KilnRenderError || error instanceof KilnSyntaxError\n\t\t? error\n\t\t: new KilnRenderError(\n\t\t\t\t\"host-error\",\n\t\t\t\t`The template loader threw an error: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\tresolved,\n\t\t\t\tundefined,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\nconst tooLong = ({ resolved, state }: Prepared) =>\n\tnew KilnRenderError(\n\t\t\"limit-output\",\n\t\t`Render stopped after ${state.maxSize} characters of output`,\n\t\tresolved,\n\t);\n\n/**\n * Creates a Kiln environment: the loader, functions, filters, tests, globals and options every render uses.\n *\n * ```ts\n * const kiln = createKiln({ loader: memoryLoader({ \"page.kiln\": \"<h1>{{ title }}</h1>\" }) });\n * const html = await kiln.render(\"page\", { title: \"Home\" });\n * ```\n */\nexport const createKiln = <\n\tState = undefined,\n\tSchema extends KilnSchema = DefaultSchema,\n>(\n\toptions: KilnOptions<State, Schema>,\n): Kiln<State, Schema> => {\n\tconst env = new Environment<State, Schema>(options);\n\tconst kiln = createApi(env);\n\tenvironments.set(kiln, env);\n\treturn kiln;\n};\n\ntype ToolingEnvironment = EnvironmentCore & {\n\treadonly globals: Scope;\n\treadonly htmlChecks: HtmlCheckLevels;\n};\n\n/** The environment behind each object `createKiln` returns, for tools such as `generateManifest`. */\nconst environments = new WeakMap<object, ToolingEnvironment>();\n\n/** The environment behind a Kiln object. Throws for an object `createKiln` didn't make. */\nexport const environmentOf = (kiln: object): ToolingEnvironment => {\n\tconst env = environments.get(kiln);\n\tif (!env) throw new TypeError(\"Expected an environment made by createKiln\");\n\treturn env;\n};\n\nconst createApi = <State, Schema extends KilnSchema>(\n\tenv: Environment<State, Schema>,\n): Kiln<State, Schema> => {\n\ttype Options = BaseRenderOptions & { state?: State };\n\t// The typed signatures only narrow what callers may pass, so these take the plain shapes.\n\tconst render = (\n\t\tname: string,\n\t\tcontext?: Record<string, unknown>,\n\t\trenderOptions?: Options,\n\t) => env.render(name, context, renderOptions ?? {});\n\tconst renderBlock = (\n\t\tname: string,\n\t\tblock: string,\n\t\tcontext?: Record<string, unknown>,\n\t\trenderOptions?: Options,\n\t) => {\n\t\tif (typeof block !== \"string\") {\n\t\t\tthrow new TypeError(\"renderBlock needs a block name\");\n\t\t}\n\t\treturn env.render(name, context, renderOptions ?? {}, block);\n\t};\n\tconst renderStream = (\n\t\tname: string,\n\t\tcontext?: Record<string, unknown>,\n\t\trenderOptions?: Options,\n\t) => env.renderStream(name, context, renderOptions ?? {});\n\treturn {\n\t\trender: render as unknown as Kiln<State, Schema>[\"render\"],\n\t\trenderBlock: renderBlock as unknown as Kiln<State, Schema>[\"renderBlock\"],\n\t\trenderStream: renderStream as unknown as Kiln<\n\t\t\tState,\n\t\t\tSchema\n\t\t>[\"renderStream\"],\n\t\tcheck: async (name, source) => {\n\t\t\tconst template = await env.compileFor(name, source);\n\t\t\tif (!template) {\n\t\t\t\tconst position = { offset: 0, line: 1, column: 1 };\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"missing-template\",\n\t\t\t\t\t\tmessage: `Template \"${resolveTemplateName(name)}\" was not found`,\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\ttemplate: resolveTemplateName(name),\n\t\t\t\t\t\tstart: position,\n\t\t\t\t\t\tend: position,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\tconst references = await checkReferences(env, template);\n\t\t\tconst html = checkHtml(template, env.htmlChecks);\n\t\t\treturn [...template.diagnostics, ...references, ...html].sort(\n\t\t\t\t(a, b) => a.start.offset - b.start.offset,\n\t\t\t);\n\t\t},\n\t\tanalyze: async (name, source) => {\n\t\t\tconst template = await env.compileFor(name, source);\n\t\t\tif (!template) {\n\t\t\t\tthrow new KilnRenderError(\n\t\t\t\t\t\"missing-template\",\n\t\t\t\t\t`Template \"${resolveTemplateName(name)}\" was not found`,\n\t\t\t\t\tresolveTemplateName(name),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn analyzeTemplate(template, env.globals);\n\t\t},\n\t\tprecompile: async (name, source) => {\n\t\t\tconst template = await env.compileFor(name, source);\n\t\t\tif (!template) {\n\t\t\t\tthrow new KilnRenderError(\n\t\t\t\t\t\"missing-template\",\n\t\t\t\t\t`Template \"${resolveTemplateName(name)}\" was not found`,\n\t\t\t\t\tresolveTemplateName(name),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (template.hasErrors) throw template.syntaxError();\n\t\t\treturn generateModule(env, template.ast, template.source.text);\n\t\t},\n\t\tinvalidate: (name) => env.invalidate(name),\n\t};\n};\n\n/**\n * A loader for templates held in memory, keyed by name. Keys without an extension get `.kiln`. Each template is its\n * source or a precompiled module's default export.\n *\n * Works on every runtime, including Cloudflare Workers.\n */\nexport const memoryLoader = (\n\ttemplates:\n\t\t| Record<string, string | PrecompiledTemplate>\n\t\t| Map<string, string | PrecompiledTemplate>,\n): Omit<Loader, \"list\"> & { list(): string[] } => {\n\tconst map = new Map<string, string | PrecompiledTemplate>();\n\tconst entries =\n\t\ttemplates instanceof Map ? templates : Object.entries(templates);\n\tfor (const [name, source] of entries) {\n\t\tmap.set(resolveTemplateName(name), source);\n\t}\n\treturn { load: (name) => map.get(name) ?? null, list: () => [...map.keys()] };\n};\n\n/**\n * A store for the `cache` tag that keeps output in memory, for a long-running server. Holds up to `max` copies, 1,000\n * by default, and drops the oldest first.\n *\n * ```ts\n * const kiln = createKiln({ loader, cache: memoryCache() });\n * ```\n */\nexport const memoryCache = ({ max = 1000 }: { max?: number } = {}) => {\n\tconst entries = new Map<string, { value: string; expires: number }>();\n\t// `satisfies` keeps the synchronous types, so callers can use the store without awaiting.\n\treturn {\n\t\tget: ({ key }) => {\n\t\t\tconst entry = entries.get(key);\n\t\t\tif (!entry) return null;\n\t\t\tif (entry.expires > Date.now()) return entry.value;\n\t\t\tentries.delete(key);\n\t\t\treturn null;\n\t\t},\n\t\tset: ({ key, value, seconds }) => {\n\t\t\t// Deleting first moves the key to the end, so the oldest copy is always first.\n\t\t\tentries.delete(key);\n\t\t\tentries.set(key, {\n\t\t\t\tvalue,\n\t\t\t\texpires: seconds === null ? Infinity : Date.now() + seconds * 1000,\n\t\t\t});\n\t\t\tconst oldest = entries.keys().next();\n\t\t\tif (entries.size > max && !oldest.done) entries.delete(oldest.value);\n\t\t},\n\t} satisfies KilnCache;\n};\n","import { environmentOf, type Kiln, type KilnSchema } from \"./environment.js\";\nimport { type HtmlChecks, htmlChecksOption } from \"./html/index.js\";\nimport { variableNames } from \"./runtime/scope.js\";\nimport type { CallableEntry } from \"./runtime/types.js\";\n\n/** The contents of `kiln.json`, which tells the language server about a project. See the editor support docs. */\nexport type KilnManifest = {\n\t/** The folder template names are relative to, from the folder holding `kiln.json`. */\n\troot: string;\n\tstrict: boolean;\n\tfunctions: string[];\n\tfilters: string[];\n\ttests: string[];\n\tglobals: string[];\n\ttypes: string[];\n\thtmlChecks: HtmlChecks;\n};\n\nconst hostNames = (registry: ReadonlyMap<string, CallableEntry>) =>\n\t[...registry]\n\t\t.filter(([, entry]) => entry.kind === \"host\")\n\t\t.map(([name]) => name)\n\t\t.sort();\n\n/**\n * Writes `kiln.json` for an environment: the names of its functions, filters, tests, globals and prop types, and its HTML check levels, so editors can check templates without running your code. `root` is the template folder, relative to where you write the file.\n *\n * ```ts\n * await writeFile(\"kiln.json\", generateManifest(kiln, { root: \"src/templates\" }));\n * ```\n */\nexport const generateManifest = <State, Schema extends KilnSchema>(\n\tkiln: Kiln<State, Schema>,\n\toptions: { root: string },\n): string => {\n\tconst env = environmentOf(kiln);\n\tconst manifest: KilnManifest = {\n\t\troot: options.root,\n\t\tstrict: env.strict,\n\t\tfunctions: hostNames(env.functions),\n\t\tfilters: hostNames(env.filters),\n\t\ttests: hostNames(env.tests),\n\t\tglobals: variableNames(env.globals).sort(),\n\t\ttypes: [...env.types.keys()].sort(),\n\t\thtmlChecks: htmlChecksOption(env.htmlChecks),\n\t};\n\treturn `${JSON.stringify(manifest, null, \"\\t\")}\\n`;\n};\n","import type { AnalysedProp, Analysis } from \"./analyzer.js\";\nimport type { Kiln } from \"./environment.js\";\nimport { KilnRenderError } from \"./errors.js\";\nimport { resolveTemplateName, TEMPLATE_EXTENSION } from \"./names.js\";\nimport type { PropType, TypeName } from \"./parser/ast.js\";\n\nconst BUILTIN_TYPES: Record<TypeName, string> = {\n\tnull: \"null\",\n\tboolean: \"boolean\",\n\tnumber: \"number\",\n\tstring: \"string | Markup\",\n\tarray: \"readonly unknown[]\",\n\thash: \"Readonly<Record<string, unknown>> | ReadonlyMap<string, unknown>\",\n\tset: \"ReadonlySet<unknown>\",\n\tdate: \"Date\",\n\tmarkup: \"Markup\",\n\tobject: \"object\",\n};\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst key = (name: string) =>\n\tIDENTIFIER.test(name) ? name : JSON.stringify(name);\n\n/** Writes a Kiln prop type as TypeScript. Host types read the schema's type map through `Named`. */\nconst tsType = (type: readonly PropType[] | null): string => {\n\tif (type === null) return \"unknown\";\n\tif (type.length === 0) return \"never\";\n\treturn type.map(tsMember).join(\" | \");\n};\n\nconst tsMember = (member: PropType): string => {\n\tif (typeof member === \"string\") return BUILTIN_TYPES[member];\n\tif (\"literal\" in member) return JSON.stringify(member.literal);\n\tif (\"named\" in member) return `Named<Types, ${JSON.stringify(member.named)}>`;\n\tif (\"list\" in member) {\n\t\tconst inner = tsType(member.list);\n\t\t// `|` and `readonly` bind more loosely than `[]`, so unions and nested lists need brackets.\n\t\treturn inner.includes(\" | \") || inner.startsWith(\"readonly \")\n\t\t\t? `readonly (${inner})[]`\n\t\t\t: `readonly ${inner}[]`;\n\t}\n\tif (member.shape.length === 0) return \"object\";\n\tconst keys = member.shape.map(\n\t\t(entry) =>\n\t\t\t`${key(entry.name)}${entry.optional ? \"?\" : \"\"}: ${tsType(entry.type)}`,\n\t);\n\treturn `{ ${keys.join(\"; \")} }`;\n};\n\n/** A prop as an object type member. A default makes it optional, and null then picks the default. */\nconst field = (prop: AnalysedProp, optional: boolean) =>\n\toptional\n\t\t? `${key(prop.name)}?: ${prop.type ? `${tsType(prop.type)} | null` : \"unknown\"}`\n\t\t: `${key(prop.name)}: ${tsType(prop.type)}`;\n\nconst objectType = (fields: string[], indent: string) =>\n\tfields.length === 0\n\t\t? \"{}\"\n\t\t: `{\\n${fields.map((line) => `${indent}\\t${line};`).join(\"\\n\")}\\n${indent}}`;\n\n/**\n * Writes a module exporting `Schema`, describing each template's data and blocks from their `props`. Pass it as the\n * second type argument to `createKiln` so each environment has its own template and host-type maps.\n *\n * Pass the names of the templates to describe, such as a loader's `list()`. The result is the file's contents; write it wherever your `tsconfig.json` includes.\n *\n * ```ts\n * await writeFile(\"src/kiln.d.ts\", await generateTypes(kiln, await loader.list()));\n * ```\n */\nexport const generateTypes = async (\n\tkiln: Pick<Kiln, \"analyze\">,\n\tnames: Iterable<string>,\n): Promise<string> => {\n\tconst analyses = new Map<string, Promise<Analysis | null>>();\n\tconst analyse = (name: string) => {\n\t\tlet analysis = analyses.get(name);\n\t\tif (!analysis) {\n\t\t\tanalysis = kiln.analyze(name).catch((error: unknown) => {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof KilnRenderError &&\n\t\t\t\t\terror.code === \"missing-template\"\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t\tanalyses.set(name, analysis);\n\t\t}\n\t\treturn analysis;\n\t};\n\n\t/** The layouts a template extends, nearest first. `complete` is false when one is built at render time or missing. */\n\tconst layoutsOf = async (analysis: Analysis) => {\n\t\tconst layouts: Analysis[] = [];\n\t\tconst seen = new Set<string>();\n\t\tlet current = analysis;\n\t\tfor (;;) {\n\t\t\tconst parent = current.templates.find((ref) => ref.kind === \"extends\");\n\t\t\tif (!parent) return { layouts, complete: true };\n\t\t\tif (!parent.name || seen.has(parent.name))\n\t\t\t\treturn { layouts, complete: false };\n\t\t\tseen.add(parent.name);\n\t\t\tconst layout = await analyse(parent.name);\n\t\t\tif (!layout) return { layouts, complete: false };\n\t\t\tlayouts.push(layout);\n\t\t\tcurrent = layout;\n\t\t}\n\t};\n\n\tconst entries: string[] = [];\n\tlet usesMarkup = false;\n\tlet usesNamed = false;\n\tconst resolved = [\n\t\t...new Set([...names].map((name) => resolveTemplateName(name))),\n\t].sort();\n\tfor (const name of resolved) {\n\t\tconst analysis = await analyse(name);\n\t\tif (!analysis) continue;\n\t\tconst { layouts, complete } = await layoutsOf(analysis);\n\n\t\t/** Its layouts' props that the page doesn't declare or set itself, which it must pass on. */\n\t\tconst layoutFields = () => {\n\t\t\tconst provided = new Set([\n\t\t\t\t...analysis.props.map((prop) => prop.name),\n\t\t\t\t...analysis.sets,\n\t\t\t]);\n\t\t\tconst fields: string[] = [];\n\t\t\tfor (const layout of layouts) {\n\t\t\t\tfor (const prop of layout.props) {\n\t\t\t\t\tif (!provided.has(prop.name))\n\t\t\t\t\t\tfields.push(field(prop, !prop.required));\n\t\t\t\t\tprovided.add(prop.name);\n\t\t\t\t}\n\t\t\t\tfor (const set of layout.sets) provided.add(set);\n\t\t\t}\n\t\t\treturn fields;\n\t\t};\n\n\t\tlet context: string;\n\t\tif (analysis.rest !== null) {\n\t\t\t// A rest prop accepts any other key, so the layouts can get their props too.\n\t\t\tconst fields = [\n\t\t\t\t...analysis.props.map((prop) => field(prop, !prop.required)),\n\t\t\t\t...layoutFields(),\n\t\t\t\t\"[key: string]: unknown\",\n\t\t\t];\n\t\t\tcontext = objectType(fields, \"\\t\\t\\t\");\n\t\t} else if (analysis.props.length > 0) {\n\t\t\t// Strict mode rejects anything a template with `props` doesn't declare.\n\t\t\tconst fields = analysis.props.map((prop) => field(prop, !prop.required));\n\t\t\tcontext = objectType(fields, \"\\t\\t\\t\");\n\t\t} else {\n\t\t\t// Without `props`, a page takes any data, plus its layouts' props.\n\t\t\tconst fields = layoutFields();\n\t\t\tcontext =\n\t\t\t\tfields.length === 0\n\t\t\t\t\t? \"Record<string, unknown>\"\n\t\t\t\t\t: `${objectType(fields, \"\\t\\t\\t\")} & Record<string, unknown>`;\n\t\t}\n\n\t\tconst blockNames = new Set([analysis, ...layouts].flatMap((a) => a.blocks));\n\t\tconst blocks = !complete\n\t\t\t? \"string\"\n\t\t\t: blockNames.size === 0\n\t\t\t\t? \"never\"\n\t\t\t\t: [...blockNames].map((block) => JSON.stringify(block)).join(\" | \");\n\n\t\tusesMarkup ||= context.includes(\"Markup\");\n\t\tusesNamed ||= context.includes(\"Named<\");\n\t\tconst templateKey = name.endsWith(TEMPLATE_EXTENSION)\n\t\t\t? name.slice(0, -TEMPLATE_EXTENSION.length)\n\t\t\t: name;\n\t\tentries.push(\n\t\t\t`\\t\\t${JSON.stringify(templateKey)}: {\\n\\t\\t\\tcontext: ${context};\\n\\t\\t\\tblocks: ${blocks};\\n\\t\\t};`,\n\t\t);\n\t}\n\n\treturn [\n\t\t\"// Generated by Kiln's generateTypes. Do not edit.\",\n\t\t...(usesMarkup ? ['import type { Markup } from \"@lucidkiln/core\";\\n'] : []),\n\t\t...(usesNamed\n\t\t\t? [\n\t\t\t\t\t\"type Named<Types, Name extends string> = Name extends keyof Types ? Types[Name] : unknown;\\n\",\n\t\t\t\t]\n\t\t\t: []),\n\t\t\"export interface Schema<Types extends object = object> {\",\n\t\t\"\\ttypes: Types;\",\n\t\tentries.length > 0\n\t\t\t? `\\ttemplates: {\\n${entries.join(\"\\n\")}\\n\\t};`\n\t\t\t: \"\\ttemplates: {};\",\n\t\t\"}\",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A;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,iCAAiB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,2BAAW,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,0BAAU,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC;;AAG9C,MAAa,uBAAO,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,kBAAkB,GAAG,UAC1B,OAAO,YAAY,MAAM,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AACpD,MAAM,iBAAiB,eACtB,SACA,WACA,QACA,WACA,UACA,UACA,UACA,OACD;AACA,MAAM,qBAAqB,eAAe,SAAS,QAAQ,WAAW,QAAQ;AAE9E,MAAa,sBAA8D;CAC1E,GAAG;EACF,SAAS;EACT,QAAQ;EACR,SAAS;EACT,MAAM;EACN,KAAK;EACL,OAAO;EACP,KAAK;CACN;CACA,MAAM;EAAE,QAAQ;EAA0B,MAAM;CAAO;CACvD,MAAM,eACL,SACA,cACA,WACA,gBACA,cACA,QACA,gBACA,gBACA,cACA,eACA,aACA,eACA,eACA,QACA,aACA,OACD;CAC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I;CACJ,MAAM;CACN,KAAK;CACL,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,GAAG;CACH,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,KAAK;CACL,KAAK;CACL,OAAO;CACP,OAAO;CACP,UAAU;CACV,OAAO;CACP,OAAO;CACP,MAAM;CACN,IAAI;AACL;;AAGA,MAAa,cAAsC;CAClD,QAAQ;CACR,UAAU;CACV,OAAO;CACP,QAAQ;CACR,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;AACT;AAEA,MAAa,2BAAW,IAAI,IAAI;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,CAAC;;AAGpE,MAAa,uBAAO,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,gCAAgB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,8BAAc,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,MAAM,oBAAoB,CAAC,UAAU,UAAU;AAC/C,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAGA,MAAa,gBAAmD;CAC/D,IAAI,CAAC,MAAM,GAAG,iBAAiB;CAC/B,IAAI,CAAC,MAAM,GAAG,iBAAiB;CAC/B,MAAM,CAAC,MAAM,GAAG,iBAAiB;CACjC,IAAI;EAAC;E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ACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,+BAAe,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;AC75BD,MAAa,cAAc;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAQA,MAAM,SAA6B;CAAC;CAAO;CAAW;AAAO;AAE7D,MAAM,eAAe,SACnB,YAAkC,SAAS,IAAI;AAEjD,MAAM,WAAW,UAChB,OAAO,SAAS,KAAK;AAEtB,MAAM,SAAS,UAA6D;CAC3E,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,QAAQ,aAAa,OAAO,QAAQ;CAC/C,OAAO;AACR;;AAGA,MAAa,qBACZ,WACqB;CACrB,IAAI,WAAW,KAAA,KAAa,WAAW,MAAM,OAAO,MAAM,SAAS;CACnE,IAAI,WAAW,OAAO,OAAO,MAAM,KAAK;CACxC,IAAI,CAAC,cAAc,MAAM,GACxB,MAAM,IAAI,UACT,4DACD;CAED,MAAM,SAAS,MAAM,SAAS;CAC9B,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,GAAG;EACnD,IAAI,CAAC,YAAY,IAAI,GACpB,MAAM,IAAI,UACT,SAAS,uBAAuB,KAAK,IAAI,QAAQ,MAAM,WAAW,CAAC,CACpE;EAED,IAAI,CAAC,QAAQ,KAAK,GACjB,MAAM,IAAI,UACT,eAAe,KAAK,sCACrB;EAED,OAAO,QAAQ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CAAC,CAAC,CAAC,KAAK,KAAK;EAEpE,eAAe,QAAQ,SAAS,QAAQ;EACxC,cAAc,QAAQ,SAAS,QAAQ;EACvC,MAAM,cAAc,KAAK,SAAA,OAA2B,IACjD,KAAK,MAAM,GAAG,CAAC,mBAAmB,MAAM,IACxC;EACH,QAAQ,KACP,OAAO,KAAK,UAAU,WAAW,EAAE,sBAAsB,QAAQ,mBAAmB,OAAO,UAC5F;CACD;CAEA,OAAO;EACN;EACA,GAAI,aAAa,CAAC,oDAAkD,IAAI,CAAC;EACzE,GAAI,YACD,CACA,8FACD,IACC,CAAC;EACJ;EACA;EACA,QAAQ,SAAS,IACd,mBAAmB,QAAQ,KAAK,IAAI,EAAE,UACtC;EACH;EACA;CACD,CAAC,CAAC,KAAK,IAAI;AACZ"}
1
+ {"version":3,"file":"index.js","names":["MAX_DEPTH","listOf","withHint","NOTHING","emitters","lookup","isBlank","checkValue","lookup","checkValue","IDENTIFIER"],"sources":["../src/analyzer.ts","../src/builtins/formatters.ts","../src/builtins/filters.ts","../src/checker.ts","../src/runtime/cache.ts","../src/runtime/islands.ts","../src/runtime/macros.ts","../src/compiler/combinators.ts","../src/compiler/effects.ts","../src/compiler/compiler.ts","../src/compiler/precompiled.ts","../src/compiler/codegen.ts","../src/html/data.ts","../src/html/options.ts","../src/html/tags.ts","../src/html/nesting.ts","../src/html/scanner.ts","../src/html/index.ts","../src/runtime/stream.ts","../src/environment.ts","../src/manifest.ts","../src/typegen.ts"],"sourcesContent":["import type { Diagnostic } from \"./errors.js\";\nimport { resolveTemplateName } from \"./names.js\";\nimport type {\n\tArgument,\n\tExpression,\n\tPropType,\n\tStatement,\n} from \"./parser/ast.js\";\nimport type { CompiledTemplate, Scope } from \"./runtime/types.js\";\nimport type { Position, Span } from \"./source.js\";\n\nexport type TemplateReference = {\n\tkind: \"extends\" | \"include\" | \"component\" | \"island\" | \"import\";\n\t/** Resolved name, or `null` when the name is computed at render time. */\n\tname: string | null;\n\tstart: Position;\n\tend: Position;\n};\n\nexport type AnalysedProp = {\n\tname: string;\n\trequired: boolean;\n\ttype: PropType[] | null;\n};\n\nexport type Analysis = {\n\tdiagnostics: Diagnostic[];\n\t/** Variables the template reads from its context, excluding globals, props and locals. */\n\tvariables: string[];\n\t/** `type` lists the members of the prop's type, or is `null` when the prop is untyped. */\n\tprops: AnalysedProp[];\n\t/** The name of the rest prop, as in `...attributes`, or null. With one, the template accepts any variable. */\n\trest: string | null;\n\t/** Variables set at the top level. A layout sees those its child template sets. */\n\tsets: string[];\n\tfunctions: string[];\n\tfilters: string[];\n\ttests: string[];\n\ttemplates: TemplateReference[];\n\tblocks: string[];\n\tmacros: string[];\n};\n\n/** Where variables are first read without a guard, by name: from the context, and inside macros. See `analyzeTemplate`. */\nexport type Reads = {\n\tcontext: Map<string, Span>;\n\tmacros: Map<string, Span>;\n};\n\nconst MAX_DEPTH = 1000;\n\n/** The statement lists nested inside a statement. */\nexport const childStatements = (node: Statement): Statement[][] => {\n\tswitch (node.type) {\n\t\tcase \"If\":\n\t\t\treturn [\n\t\t\t\t...node.branches.map((branch) => branch.body),\n\t\t\t\tnode.alternate ?? [],\n\t\t\t];\n\t\tcase \"For\":\n\t\t\treturn [node.body, node.alternate ?? []];\n\t\tcase \"Component\":\n\t\t\treturn [node.body, ...node.fills.map((fill) => fill.body)];\n\t\tcase \"Island\":\n\t\tcase \"SetBlock\":\n\t\tcase \"Block\":\n\t\tcase \"Slot\":\n\t\tcase \"Macro\":\n\t\tcase \"Add\":\n\t\tcase \"Cache\":\n\t\tcase \"With\":\n\t\tcase \"Apply\":\n\t\tcase \"Autoescape\":\n\t\t\treturn [node.body];\n\t\tdefault:\n\t\t\treturn [];\n\t}\n};\n\n/**\n * Walks a compiled template's syntax tree and reports what it uses.\n *\n * When `reads` is given, it collects where each variable in `variables` is first read without a guard such as `??`, `?.`, `default` or `is defined`, and where a macro first reads a name that is neither its parameter nor a global. Strict mode fails on those reads when the variable is missing.\n */\nexport const analyzeTemplate = (\n\ttemplate: CompiledTemplate,\n\tglobals: Scope,\n\treads?: Reads,\n): Analysis => {\n\tconst source = template.source;\n\tconst variables = new Set<string>();\n\tconst functions = new Set<string>();\n\tconst filters = new Set<string>();\n\tconst tests = new Set<string>();\n\tconst templates: TemplateReference[] = [];\n\tconst blocks: string[] = [];\n\tconst props: AnalysedProp[] = [];\n\tlet rest: string | null = null;\n\tconst macroNames = new Set(template.macros.keys());\n\tconst importedNames = new Set<string>();\n\tconst importAliases = new Set<string>();\n\n\tconst reference = (\n\t\tkind: TemplateReference[\"kind\"],\n\t\tname: Expression | string,\n\t\tspan: Span,\n\t) => {\n\t\tlet resolved: string | null = null;\n\t\tconst literal =\n\t\t\ttypeof name === \"string\"\n\t\t\t\t? name\n\t\t\t\t: name.type === \"Literal\"\n\t\t\t\t\t? name.value\n\t\t\t\t\t: null;\n\t\tif (typeof literal === \"string\") {\n\t\t\ttry {\n\t\t\t\tresolved = resolveTemplateName(literal, template.name);\n\t\t\t} catch {\n\t\t\t\tresolved = null;\n\t\t\t}\n\t\t}\n\t\ttemplates.push({\n\t\t\tkind,\n\t\t\tname: resolved,\n\t\t\tstart: source.position(span.start),\n\t\t\tend: source.position(span.end),\n\t\t});\n\t};\n\n\t// Scopes of declared names, innermost last. `null` marks where an isolated scope, such as a macro's, begins. Names\n\t// outside it can't be seen.\n\tconst scopes: (Set<string> | null)[] = [new Set()];\n\tconst declared = (name: string) => {\n\t\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\t\tconst scope = scopes[i];\n\t\t\tif (scope === null) break;\n\t\t\tif (scope?.has(name)) return true;\n\t\t}\n\t\treturn name in globals;\n\t};\n\tconst declare = (name: string) => {\n\t\tif (!declared(name)) scopes[scopes.length - 1]?.add(name);\n\t};\n\tconst withScope = (\n\t\tnames: Iterable<string>,\n\t\twork: () => void,\n\t\tisolated = false,\n\t) => {\n\t\tif (isolated) scopes.push(null);\n\t\tscopes.push(new Set(names));\n\t\twork();\n\t\tscopes.pop();\n\t\tif (isolated) scopes.pop();\n\t};\n\n\tconst visitArguments = (args: Argument[]) => {\n\t\tfor (const arg of args) expression(arg.value);\n\t};\n\n\t// Expressions deeper than the compiler accepts were already reported, so stop there instead of overflowing the stack.\n\tlet depth = 0;\n\tconst expression = (node: Expression): void => {\n\t\tif (depth >= MAX_DEPTH) return;\n\t\tdepth++;\n\t\ttry {\n\t\t\tvisitExpression(node);\n\t\t} finally {\n\t\t\tdepth--;\n\t\t}\n\t};\n\n\t// A guarded expression, such as the left of `??`, is null rather than an error when its variable is missing.\n\tconst guarded = (node: Expression): void => {\n\t\tif (node.type === \"Name\") read(node.name, node.span, true);\n\t\telse if (node.type === \"Member\") {\n\t\t\tguarded(node.object);\n\t\t\tif (node.property.type !== \"Literal\") expression(node.property);\n\t\t} else if (node.type === \"OptionalChain\") guarded(node.expression);\n\t\telse expression(node);\n\t};\n\n\t// A template that outputs slots, or extends a layout that may, gets a `slots` hash.\n\tif (template.slotNames.length > 0 || template.parent) scopes[0]?.add(\"slots\");\n\n\tconst read = (name: string, span: Span, isGuarded: boolean) => {\n\t\tif (declared(name) || importAliases.has(name) || importedNames.has(name)) {\n\t\t\treturn;\n\t\t}\n\t\t// Inside a macro, a missing name is never one from the context.\n\t\tconst inMacro = scopes.includes(null);\n\t\tif (!inMacro) variables.add(name);\n\t\tconst found = inMacro ? reads?.macros : reads?.context;\n\t\tif (found && !isGuarded && !found.has(name)) found.set(name, span);\n\t};\n\n\tconst visitExpression = (node: Expression): void => {\n\t\tswitch (node.type) {\n\t\t\tcase \"Literal\":\n\t\t\tcase \"Invalid\":\n\t\t\t\treturn;\n\t\t\tcase \"Name\":\n\t\t\t\tread(node.name, node.span, false);\n\t\t\t\treturn;\n\t\t\tcase \"Interpolation\":\n\t\t\t\tnode.parts.forEach(expression);\n\t\t\t\treturn;\n\t\t\tcase \"Array\":\n\t\t\t\tfor (const element of node.elements) {\n\t\t\t\t\texpression(element.type === \"Spread\" ? element.value : element);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"Hash\":\n\t\t\t\tfor (const entry of node.entries) {\n\t\t\t\t\tif (entry.type === \"Property\" && entry.key.type !== \"Literal\") {\n\t\t\t\t\t\texpression(entry.key);\n\t\t\t\t\t}\n\t\t\t\t\texpression(entry.value);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"Unary\":\n\t\t\t\texpression(node.operand);\n\t\t\t\treturn;\n\t\t\tcase \"Binary\":\n\t\t\t\tif (node.operator === \"??\") guarded(node.left);\n\t\t\t\telse expression(node.left);\n\t\t\t\texpression(node.right);\n\t\t\t\treturn;\n\t\t\tcase \"Conditional\":\n\t\t\t\texpression(node.test);\n\t\t\t\texpression(node.consequent);\n\t\t\t\tif (node.alternate) expression(node.alternate);\n\t\t\t\treturn;\n\t\t\tcase \"Member\":\n\t\t\t\texpression(node.object);\n\t\t\t\tif (node.property.type !== \"Literal\") expression(node.property);\n\t\t\t\treturn;\n\t\t\tcase \"OptionalChain\":\n\t\t\t\tguarded(node.expression);\n\t\t\t\treturn;\n\t\t\tcase \"Call\": {\n\t\t\t\tconst callee = node.callee;\n\t\t\t\tif (callee.type === \"Name\") {\n\t\t\t\t\tconst name = callee.name;\n\t\t\t\t\tif (\n\t\t\t\t\t\tname !== \"parent\" &&\n\t\t\t\t\t\tname !== \"block\" &&\n\t\t\t\t\t\t!macroNames.has(name) &&\n\t\t\t\t\t\t!importedNames.has(name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfunctions.add(name);\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\t!(\n\t\t\t\t\t\tcallee.type === \"Member\" &&\n\t\t\t\t\t\tcallee.object.type === \"Name\" &&\n\t\t\t\t\t\timportAliases.has(callee.object.name)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\texpression(callee);\n\t\t\t\t}\n\t\t\t\tvisitArguments(node.args);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"Filter\":\n\t\t\t\tfilters.add(node.name);\n\t\t\t\tif (node.name === \"default\") guarded(node.input);\n\t\t\t\telse expression(node.input);\n\t\t\t\tvisitArguments(node.args);\n\t\t\t\treturn;\n\t\t\tcase \"Test\":\n\t\t\t\ttests.add(node.name);\n\t\t\t\tif (node.name === \"defined\") guarded(node.input);\n\t\t\t\telse expression(node.input);\n\t\t\t\tvisitArguments(node.args);\n\t\t\t\treturn;\n\t\t\tcase \"Arrow\":\n\t\t\t\twithScope(node.params, () => expression(node.body));\n\t\t\t\treturn;\n\t\t}\n\t};\n\n\tconst statements = (list: Statement[]) => {\n\t\tfor (const node of list) statement(node);\n\t};\n\n\tconst statement = (node: Statement): void => {\n\t\tswitch (node.type) {\n\t\t\tcase \"Text\":\n\t\t\t\treturn;\n\t\t\tcase \"Output\":\n\t\t\t\texpression(node.expression);\n\t\t\t\treturn;\n\t\t\tcase \"If\":\n\t\t\t\tfor (const branch of node.branches) {\n\t\t\t\t\texpression(branch.test);\n\t\t\t\t\tstatements(branch.body);\n\t\t\t\t}\n\t\t\t\tif (node.alternate) statements(node.alternate);\n\t\t\t\treturn;\n\t\t\tcase \"For\":\n\t\t\t\texpression(node.iterable);\n\t\t\t\twithScope(\n\t\t\t\t\tnode.keyName\n\t\t\t\t\t\t? [node.valueName, node.keyName, \"loop\"]\n\t\t\t\t\t\t: [node.valueName, \"loop\"],\n\t\t\t\t\t() => statements(node.body),\n\t\t\t\t);\n\t\t\t\tif (node.alternate) statements(node.alternate);\n\t\t\t\treturn;\n\t\t\tcase \"Set\":\n\t\t\t\texpression(node.value);\n\t\t\t\tdeclare(node.name);\n\t\t\t\treturn;\n\t\t\tcase \"SetBlock\":\n\t\t\t\tstatements(node.body);\n\t\t\t\tdeclare(node.name);\n\t\t\t\treturn;\n\t\t\tcase \"Props\":\n\t\t\t\tfor (const prop of node.props) {\n\t\t\t\t\tif (prop.default) expression(prop.default);\n\t\t\t\t\tprops.push({\n\t\t\t\t\t\tname: prop.name,\n\t\t\t\t\t\trequired: prop.default === null,\n\t\t\t\t\t\ttype: prop.type,\n\t\t\t\t\t});\n\t\t\t\t\tdeclare(prop.name);\n\t\t\t\t}\n\t\t\t\tif (node.rest !== null) {\n\t\t\t\t\trest = node.rest;\n\t\t\t\t\tdeclare(node.rest);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase \"Extends\":\n\t\t\t\texpression(node.template);\n\t\t\t\treference(\"extends\", node.template, node.span);\n\t\t\t\treturn;\n\t\t\tcase \"Block\":\n\t\t\t\tblocks.push(node.name);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Include\":\n\t\t\t\texpression(node.template);\n\t\t\t\tif (node.with) expression(node.with);\n\t\t\t\treference(\"include\", node.template, node.span);\n\t\t\t\treturn;\n\t\t\tcase \"Component\":\n\t\t\t\texpression(node.template);\n\t\t\t\tif (node.with) expression(node.with);\n\t\t\t\treference(\"component\", node.template, node.span);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\tfor (const fill of node.fills)\n\t\t\t\t\twithScope([], () => statements(fill.body));\n\t\t\t\treturn;\n\t\t\tcase \"Island\":\n\t\t\t\texpression(node.template);\n\t\t\t\tif (node.with) expression(node.with);\n\t\t\t\treference(\"island\", node.template, node.span);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Slot\":\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Macro\":\n\t\t\t\twithScope(\n\t\t\t\t\tnode.params.map((param) => param.name),\n\t\t\t\t\t() => {\n\t\t\t\t\t\tfor (const param of node.params)\n\t\t\t\t\t\t\tif (param.default) expression(param.default);\n\t\t\t\t\t\tstatements(node.body);\n\t\t\t\t\t},\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"Import\":\n\t\t\tcase \"FromImport\":\n\t\t\t\treturn;\n\t\t\tcase \"With\": {\n\t\t\t\texpression(node.value);\n\t\t\t\tconst names =\n\t\t\t\t\tnode.value.type === \"Hash\"\n\t\t\t\t\t\t? node.value.entries.flatMap((entry) =>\n\t\t\t\t\t\t\t\tentry.type === \"Property\" &&\n\t\t\t\t\t\t\t\tentry.key.type === \"Literal\" &&\n\t\t\t\t\t\t\t\ttypeof entry.key.value === \"string\"\n\t\t\t\t\t\t\t\t\t? [entry.key.value]\n\t\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: [];\n\t\t\t\twithScope(names, () => statements(node.body));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"Add\":\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Cache\":\n\t\t\t\texpression(node.key);\n\t\t\t\tif (node.seconds) expression(node.seconds);\n\t\t\t\twithScope([], () => statements(node.body));\n\t\t\t\treturn;\n\t\t\tcase \"Apply\":\n\t\t\t\tfor (const filter of node.filters) {\n\t\t\t\t\tfilters.add(filter.name);\n\t\t\t\t\tvisitArguments(filter.args);\n\t\t\t\t}\n\t\t\t\tstatements(node.body);\n\t\t\t\treturn;\n\t\t\tcase \"Autoescape\":\n\t\t\t\tstatements(node.body);\n\t\t\t\treturn;\n\t\t}\n\t};\n\n\t// Imports are hoisted, so record them before walking.\n\t// Imports can sit anywhere in the template. Only statements hold them, so expressions are not searched.\n\tconst collectImports = (list: Statement[]): void => {\n\t\tfor (const node of list) {\n\t\t\tif (node.type === \"Import\") {\n\t\t\t\timportAliases.add(node.alias);\n\t\t\t\treference(\"import\", node.template, node.span);\n\t\t\t} else if (node.type === \"FromImport\") {\n\t\t\t\tfor (const entry of node.names) importedNames.add(entry.alias);\n\t\t\t\treference(\"import\", node.template, node.span);\n\t\t\t}\n\t\t\tfor (const children of childStatements(node)) collectImports(children);\n\t\t}\n\t};\n\tcollectImports(template.ast.body);\n\n\t// A child template's top-level `set` statements run before its layout, so blocks see them wherever they are written.\n\tif (template.parent) {\n\t\tfor (const node of template.ast.body) {\n\t\t\tif (node.type === \"Set\" || node.type === \"SetBlock\") declare(node.name);\n\t\t}\n\t}\n\tstatements(template.ast.body);\n\n\treturn {\n\t\tdiagnostics: template.diagnostics,\n\t\tvariables: [...variables],\n\t\tprops,\n\t\trest,\n\t\tsets: template.ast.body.flatMap((node) =>\n\t\t\tnode.type === \"Set\" || node.type === \"SetBlock\" ? [node.name] : [],\n\t\t),\n\t\tfunctions: [...functions],\n\t\tfilters: [...filters],\n\t\ttests: [...tests],\n\t\ttemplates,\n\t\tblocks,\n\t\tmacros: [...macroNames],\n\t};\n};\n","/*\n * Formatting numbers and dates as `Intl` does, faster.\n *\n * An `Intl` formatter takes a few hundred nanoseconds a call, which adds up on a page of prices and dates. For the usual\n * settings, the pattern a formatter follows can be read from its own output once: the text around the digits, the\n * separators and how digits group, or for dates the order of the fields and the names of months and weekdays. Each value\n * then only needs string work.\n *\n * A pattern is only used once it formats a set of samples exactly as the formatter does. Settings it can't follow, and\n * values outside the range it handles, go to the formatter itself, so the output is always the formatter's.\n */\n\n/** Formats a number or a time in milliseconds since the epoch. */\nexport type Format = (value: number) => string;\n\n// Numbers\n\ntype NumberPattern = {\n\treadonly prefix: string;\n\treadonly suffix: string;\n\treadonly negativePrefix: string;\n\treadonly negativeSuffix: string;\n\treadonly decimal: string;\n\treadonly group: string;\n\t/** Digits in the group next to the decimal point, and in each group before it. */\n\treadonly primary: number;\n\treadonly secondary: number;\n\t/** Integer digits a number needs before it is grouped. */\n\treadonly grouping: number;\n\treadonly minimumFraction: number;\n\treadonly maximumFraction: number;\n};\n\n/** The parts of a formatted number around its digits. */\ntype NumberParts = {\n\tprefix: string;\n\tsuffix: string;\n\tintegers: string[];\n\tgroup: string;\n\tdecimal: string;\n};\n\nconst DIGIT_PARTS = new Set([\"integer\", \"group\", \"decimal\", \"fraction\"]);\n\nconst readNumber = (\n\tintl: Intl.NumberFormat,\n\tvalue: number,\n): NumberParts | null => {\n\tconst parts = intl.formatToParts(value);\n\tconst first = parts.findIndex((part) => part.type === \"integer\");\n\tif (first === -1) return null;\n\tlet last = first;\n\tfor (let i = first; i < parts.length; i++) {\n\t\tif (DIGIT_PARTS.has((parts[i] as Intl.NumberFormatPart).type)) last = i;\n\t}\n\tconst result: NumberParts = {\n\t\tprefix: \"\",\n\t\tsuffix: \"\",\n\t\tintegers: [],\n\t\tgroup: \"\",\n\t\tdecimal: \"\",\n\t};\n\tfor (let i = 0; i < parts.length; i++) {\n\t\tconst { type, value: text } = parts[i] as Intl.NumberFormatPart;\n\t\tif (i < first) result.prefix += text;\n\t\telse if (i > last) result.suffix += text;\n\t\telse if (type === \"integer\") result.integers.push(text);\n\t\telse if (type === \"group\") result.group = text;\n\t\telse if (type === \"decimal\") result.decimal = text;\n\t\telse if (type !== \"fraction\") return null;\n\t}\n\treturn result;\n};\n\nconst readNumberPattern = (intl: Intl.NumberFormat): NumberPattern | null => {\n\tconst options = intl.resolvedOptions() as unknown as Record<string, unknown>;\n\tif (\n\t\toptions.numberingSystem !== \"latn\" ||\n\t\toptions.notation !== \"standard\" ||\n\t\t(options.style !== \"decimal\" && options.style !== \"currency\") ||\n\t\t(options.currencyDisplay !== undefined &&\n\t\t\toptions.currencyDisplay !== \"symbol\" &&\n\t\t\toptions.currencyDisplay !== \"narrowSymbol\" &&\n\t\t\toptions.currencyDisplay !== \"code\") ||\n\t\t(options.currencySign !== undefined &&\n\t\t\toptions.currencySign !== \"standard\") ||\n\t\toptions.signDisplay !== \"auto\" ||\n\t\toptions.roundingMode !== \"halfExpand\" ||\n\t\toptions.roundingIncrement !== 1 ||\n\t\toptions.roundingPriority !== \"auto\" ||\n\t\toptions.trailingZeroDisplay !== \"auto\" ||\n\t\toptions.minimumIntegerDigits !== 1 ||\n\t\toptions.minimumSignificantDigits !== undefined ||\n\t\toptions.maximumSignificantDigits !== undefined ||\n\t\ttypeof options.minimumFractionDigits !== \"number\" ||\n\t\ttypeof options.maximumFractionDigits !== \"number\"\n\t) {\n\t\treturn null;\n\t}\n\tconst positive = readNumber(intl, 123456789012.5);\n\tconst negative = readNumber(intl, -123456789012.5);\n\tif (positive === null || negative === null) return null;\n\tconst sizes = positive.integers.map((digits) => digits.length);\n\tconst primary = sizes.at(-1) as number;\n\tconst secondary = sizes.length > 2 ? (sizes.at(-2) as number) : primary;\n\tlet grouping = Infinity;\n\tif (sizes.length > 1) {\n\t\tif ((readNumber(intl, 10 ** primary)?.integers.length ?? 0) > 1) {\n\t\t\tgrouping = primary + 1;\n\t\t} else if (\n\t\t\t(readNumber(intl, 10 ** (primary + 1))?.integers.length ?? 0) > 1\n\t\t) {\n\t\t\tgrouping = primary + 2;\n\t\t} else return null;\n\t}\n\treturn {\n\t\tprefix: positive.prefix,\n\t\tsuffix: positive.suffix,\n\t\tnegativePrefix: negative.prefix,\n\t\tnegativeSuffix: negative.suffix,\n\t\tdecimal: positive.decimal,\n\t\tgroup: positive.group,\n\t\tprimary,\n\t\tsecondary,\n\t\tgrouping,\n\t\tminimumFraction: options.minimumFractionDigits as number,\n\t\tmaximumFraction: options.maximumFractionDigits as number,\n\t};\n};\n\n/** Adds one to the last digit of a string of digits. */\nconst increment = (digits: string): string => {\n\tlet i = digits.length - 1;\n\twhile (i >= 0 && digits.charCodeAt(i) === 57) i--;\n\tif (i < 0) return `1${\"0\".repeat(digits.length)}`;\n\treturn (\n\t\tdigits.slice(0, i) +\n\t\tString.fromCharCode(digits.charCodeAt(i) + 1) +\n\t\t\"0\".repeat(digits.length - i - 1)\n\t);\n};\n\n/**\n * Formats with a number pattern, or returns null for values it doesn't handle. `Intl` rounds the shortest decimal\n * that reads back as the number, half away from zero, which is what `String` gives here: `1.005` rounds to `1.01`.\n */\nconst formatNumber = (pattern: NumberPattern, value: number): string | null => {\n\tif (!(value > -1e15 && value < 1e15)) return null;\n\tconst negative = value < 0 || Object.is(value, -0);\n\tconst magnitude = negative ? -value : value;\n\tif (magnitude !== 0 && magnitude < 1e-6) return null;\n\tconst text = String(magnitude);\n\tconst dot = text.indexOf(\".\");\n\tlet integer = dot === -1 ? text : text.slice(0, dot);\n\tlet fraction = dot === -1 ? \"\" : text.slice(dot + 1);\n\tconst { minimumFraction, maximumFraction } = pattern;\n\tif (fraction.length > maximumFraction) {\n\t\tconst up = fraction.charCodeAt(maximumFraction) >= 53;\n\t\tfraction = fraction.slice(0, maximumFraction);\n\t\tif (up) {\n\t\t\tconst digits = increment(integer + fraction);\n\t\t\tinteger = digits.slice(0, digits.length - maximumFraction);\n\t\t\tfraction = digits.slice(digits.length - maximumFraction);\n\t\t}\n\t}\n\tlet end = fraction.length;\n\twhile (end > minimumFraction && fraction.charCodeAt(end - 1) === 48) end--;\n\tif (end < fraction.length) fraction = fraction.slice(0, end);\n\twhile (fraction.length < minimumFraction) fraction += \"0\";\n\tif (integer.length >= pattern.grouping) {\n\t\tconst { primary, secondary, group } = pattern;\n\t\tlet grouped = integer.slice(-primary);\n\t\tlet rest = integer.slice(0, -primary);\n\t\twhile (rest.length > secondary) {\n\t\t\tgrouped = rest.slice(-secondary) + group + grouped;\n\t\t\trest = rest.slice(0, -secondary);\n\t\t}\n\t\tinteger = rest + group + grouped;\n\t}\n\tconst digits =\n\t\tfraction === \"\" ? integer : integer + pattern.decimal + fraction;\n\treturn negative\n\t\t? pattern.negativePrefix + digits + pattern.negativeSuffix\n\t\t: pattern.prefix + digits + pattern.suffix;\n};\n\n/** Numbers a number pattern must format as its formatter does: rounding, grouping, signs and sizes. */\nconst NUMBER_SAMPLES = [\n\t0,\n\t-0,\n\t1,\n\t-1,\n\t0.5,\n\t1.5,\n\t2.5,\n\t-2.5,\n\t0.125,\n\t0.375,\n\t1.005,\n\t2.675,\n\t9.995,\n\t99.995,\n\t999.995,\n\t1.45,\n\t0.05,\n\t0.0049,\n\t0.00051,\n\t0.000001,\n\t7,\n\t12,\n\t123,\n\t999,\n\t1000,\n\t1234,\n\t9999,\n\t10000,\n\t12345,\n\t99999,\n\t123456,\n\t1234567,\n\t12345678.9,\n\t123456789.123,\n\t9999999.995,\n\t0.1 + 0.2,\n\t314159.26535,\n\t-1234.5678,\n\t-0.001,\n\t1e10 + 0.5,\n\t1e14 + 0.25,\n\t123456789012345,\n\t5.5555555,\n\t1 / 3,\n\t2 / 3,\n\t1e-6,\n\t42.000001,\n];\n\n/** A function that formats numbers as `intl` does, without calling it when its settings allow. */\nexport const numberFormat = (intl: Intl.NumberFormat): Format => {\n\tconst format: Format = (value) => intl.format(value);\n\tconst pattern = readNumberPattern(intl);\n\tif (pattern === null) return format;\n\tconst fast: Format = (value) => formatNumber(pattern, value) ?? format(value);\n\tfor (const sample of NUMBER_SAMPLES) {\n\t\tif (fast(sample) !== format(sample)) return format;\n\t}\n\treturn fast;\n};\n\n// Dates\n\n/** One field or literal of a date pattern. */\ntype DatePart =\n\t| { kind: \"text\"; text: string }\n\t| { kind: \"year\"; twoDigit: boolean }\n\t| { kind: \"month\"; names: readonly string[] | null; twoDigit: boolean }\n\t| { kind: \"day\"; twoDigit: boolean }\n\t| { kind: \"weekday\"; names: readonly string[] }\n\t| { kind: \"hour\"; twoDigit: boolean; twelve: boolean }\n\t| { kind: \"minute\"; twoDigit: boolean }\n\t| { kind: \"second\"; twoDigit: boolean }\n\t| { kind: \"dayPeriod\"; names: readonly [string, string] };\n\nconst DAY = 86_400_000;\n\n/** Times a date pattern handles, the years 1000 to 9999. Others go to the formatter. */\nconst EARLIEST = Date.UTC(1000, 0, 1);\nconst LATEST = Date.UTC(9999, 11, 31, 23, 59, 59, 999);\n\n/** A sample time: 5 March 2026, 13:07:09 UTC, a Thursday. */\nconst SAMPLE = Date.UTC(2026, 2, 5, 13, 7, 9);\n\nconst partOf = (\n\tintl: Intl.DateTimeFormat,\n\ttime: number,\n\ttype: Intl.DateTimeFormatPartTypes,\n): string | null =>\n\tintl.formatToParts(time).find((part) => part.type === type)?.value ?? null;\n\nconst readDatePattern = (\n\tintl: Intl.DateTimeFormat,\n): readonly DatePart[] | null => {\n\tconst options = intl.resolvedOptions() as unknown as Record<string, unknown>;\n\tif (\n\t\toptions.calendar !== \"gregory\" ||\n\t\toptions.numberingSystem !== \"latn\" ||\n\t\toptions.timeZone !== \"UTC\" ||\n\t\toptions.dayPeriod !== undefined ||\n\t\toptions.era !== undefined ||\n\t\toptions.fractionalSecondDigits !== undefined ||\n\t\t(options.hourCycle !== undefined &&\n\t\t\toptions.hourCycle !== \"h23\" &&\n\t\t\toptions.hourCycle !== \"h12\")\n\t) {\n\t\treturn null;\n\t}\n\tconst parts: DatePart[] = [];\n\tfor (const { type, value } of intl.formatToParts(SAMPLE)) {\n\t\tswitch (type) {\n\t\t\tcase \"literal\":\n\t\t\tcase \"timeZoneName\":\n\t\t\t\tparts.push({ kind: \"text\", text: value });\n\t\t\t\tbreak;\n\t\t\tcase \"year\":\n\t\t\t\tif (value !== \"2026\" && value !== \"26\") return null;\n\t\t\t\tparts.push({ kind: \"year\", twoDigit: value === \"26\" });\n\t\t\t\tbreak;\n\t\t\tcase \"month\": {\n\t\t\t\tif (value === \"3\" || value === \"03\") {\n\t\t\t\t\tparts.push({ kind: \"month\", names: null, twoDigit: value === \"03\" });\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (let month = 0; month < 12; month++) {\n\t\t\t\t\tconst name = partOf(intl, Date.UTC(2026, month, 5), \"month\");\n\t\t\t\t\tif (name === null) return null;\n\t\t\t\t\tnames.push(name);\n\t\t\t\t}\n\t\t\t\tparts.push({ kind: \"month\", names, twoDigit: false });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"day\":\n\t\t\t\tif (value !== \"5\" && value !== \"05\") return null;\n\t\t\t\tparts.push({ kind: \"day\", twoDigit: value === \"05\" });\n\t\t\t\tbreak;\n\t\t\tcase \"weekday\": {\n\t\t\t\t// 1 March 2026 is a Sunday, so day k of March is weekday k - 1.\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (let day = 1; day <= 7; day++) {\n\t\t\t\t\tconst name = partOf(intl, Date.UTC(2026, 2, day), \"weekday\");\n\t\t\t\t\tif (name === null) return null;\n\t\t\t\t\tnames.push(name);\n\t\t\t\t}\n\t\t\t\tparts.push({ kind: \"weekday\", names });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"hour\": {\n\t\t\t\tconst twelve = options.hourCycle === \"h12\";\n\t\t\t\tconst early = partOf(intl, Date.UTC(2026, 2, 5, 5), \"hour\");\n\t\t\t\tif (early !== \"5\" && early !== \"05\") return null;\n\t\t\t\tparts.push({ kind: \"hour\", twoDigit: early === \"05\", twelve });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"minute\":\n\t\t\t\tif (value !== \"7\" && value !== \"07\") return null;\n\t\t\t\tparts.push({ kind: \"minute\", twoDigit: value === \"07\" });\n\t\t\t\tbreak;\n\t\t\tcase \"second\":\n\t\t\t\tif (value !== \"9\" && value !== \"09\") return null;\n\t\t\t\tparts.push({ kind: \"second\", twoDigit: value === \"09\" });\n\t\t\t\tbreak;\n\t\t\tcase \"dayPeriod\": {\n\t\t\t\tconst am = partOf(intl, Date.UTC(2026, 2, 5, 1), \"dayPeriod\");\n\t\t\t\tconst pm = partOf(intl, Date.UTC(2026, 2, 5, 13), \"dayPeriod\");\n\t\t\t\tif (am === null || pm === null) return null;\n\t\t\t\tparts.push({ kind: \"dayPeriod\", names: [am, pm] });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\treturn parts;\n};\n\nconst pad = (value: number, twoDigit: boolean): string =>\n\ttwoDigit && value < 10 ? `0${value}` : String(value);\n\n/** Formats a time with a date pattern, working out the UTC date the way `Date` does without making one. */\nconst formatDate = (\n\tparts: readonly DatePart[],\n\tvalue: number,\n): string | null => {\n\tif (!(value >= EARLIEST && value <= LATEST)) return null;\n\tconst time = Math.trunc(value);\n\tconst days = Math.floor(time / DAY);\n\tconst ms = time - days * DAY;\n\t// Civil date from days since 1970-01-01, after Howard Hinnant's `civil_from_days`.\n\tconst shifted = days + 719_468;\n\tconst era = Math.floor(shifted / 146_097);\n\tconst dayOfEra = shifted - era * 146_097;\n\tconst yearOfEra = Math.floor(\n\t\t(dayOfEra -\n\t\t\tMath.floor(dayOfEra / 1460) +\n\t\t\tMath.floor(dayOfEra / 36_524) -\n\t\t\tMath.floor(dayOfEra / 146_096)) /\n\t\t\t365,\n\t);\n\tconst dayOfYear =\n\t\tdayOfEra -\n\t\t(365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n\tconst shiftedMonth = Math.floor((5 * dayOfYear + 2) / 153);\n\tconst day = dayOfYear - Math.floor((153 * shiftedMonth + 2) / 5) + 1;\n\tconst month = shiftedMonth < 10 ? shiftedMonth + 3 : shiftedMonth - 9;\n\tconst year = yearOfEra + era * 400 + (month <= 2 ? 1 : 0);\n\t// 1970-01-01 was a Thursday.\n\tconst weekday = (((days + 4) % 7) + 7) % 7;\n\tconst hour = Math.floor(ms / 3_600_000);\n\tconst minute = Math.floor(ms / 60_000) % 60;\n\tconst second = Math.floor(ms / 1000) % 60;\n\tlet text = \"\";\n\tfor (const part of parts) {\n\t\tswitch (part.kind) {\n\t\t\tcase \"text\":\n\t\t\t\ttext += part.text;\n\t\t\t\tbreak;\n\t\t\tcase \"year\":\n\t\t\t\ttext += part.twoDigit ? pad(year % 100, true) : String(year);\n\t\t\t\tbreak;\n\t\t\tcase \"month\":\n\t\t\t\ttext +=\n\t\t\t\t\tpart.names === null\n\t\t\t\t\t\t? pad(month, part.twoDigit)\n\t\t\t\t\t\t: (part.names[month - 1] as string);\n\t\t\t\tbreak;\n\t\t\tcase \"day\":\n\t\t\t\ttext += pad(day, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"weekday\":\n\t\t\t\ttext += part.names[weekday] as string;\n\t\t\t\tbreak;\n\t\t\tcase \"hour\":\n\t\t\t\ttext += pad(part.twelve ? hour % 12 || 12 : hour, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"minute\":\n\t\t\t\ttext += pad(minute, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"second\":\n\t\t\t\ttext += pad(second, part.twoDigit);\n\t\t\t\tbreak;\n\t\t\tcase \"dayPeriod\":\n\t\t\t\ttext += part.names[hour < 12 ? 0 : 1];\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn text;\n};\n\n/** Times a date pattern must format as its formatter does: every month and weekday, hours, leap days and centuries. */\nconst dateSamples = (): number[] => {\n\tconst samples: number[] = [EARLIEST, LATEST, 0, -1];\n\tfor (let month = 0; month < 12; month++) {\n\t\tfor (const day of [1, 9, 10, 28]) {\n\t\t\tsamples.push(Date.UTC(2026, month, day, (month * 2) % 24, day, month));\n\t\t}\n\t}\n\tfor (let hour = 0; hour < 24; hour++) {\n\t\tsamples.push(Date.UTC(1999, 11, 31, hour, 59, 59, 999));\n\t}\n\tfor (const year of [1000, 1600, 1900, 1969, 2000, 2024, 2100, 9999]) {\n\t\tsamples.push(Date.UTC(year, 1, 28), Date.UTC(year, 2, 1, 12));\n\t}\n\tsamples.push(Date.UTC(2024, 1, 29, 0, 0, 1));\n\treturn samples;\n};\n\nconst DATE_SAMPLES = dateSamples();\n\n/** A function that formats times as `intl` does, without calling it when its settings allow. */\nexport const dateFormat = (intl: Intl.DateTimeFormat): Format => {\n\tconst format: Format = (value) => intl.format(value);\n\tconst parts = readDatePattern(intl);\n\tif (parts === null) return format;\n\tconst fast: Format = (value) => formatDate(parts, value) ?? format(value);\n\tfor (const sample of DATE_SAMPLES) {\n\t\tif (fast(sample) !== format(sample)) return format;\n\t}\n\treturn fast;\n};\n","import { issue } from \"../errors.js\";\nimport { escapeHtml, escapeUrl } from \"../runtime/escape.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport {\n\tall,\n\tcheckLength,\n\tconsume,\n\thold,\n\tisPromise,\n\tsilence,\n\tunhold,\n} from \"../runtime/render.js\";\nimport type { CallableEntry, Run } from \"../runtime/types.js\";\nimport {\n\tBLOCKED_NAMES,\n\tcompare,\n\tFORMATTERS,\n\ttype FormatterCells,\n\thashKeys,\n\tisHashLike,\n\tisPlainObject,\n\tsetOwn,\n\ttoNumber,\n\ttoStr,\n\ttoStringArgument,\n\tvalueLabel,\n\ttruthy,\n\ttypeName,\n\tunwrap,\n} from \"../runtime/values.js\";\nimport { dateFormat, type Format, numberFormat } from \"./formatters.js\";\nimport {\n\tcheckDepth,\n\tentriesOf,\n\tfromPieces,\n\tfunctionArgument,\n\tinsertedPiece,\n\tintegerArgument,\n\tisHtmlStrategy,\n\tKept,\n\tlistOf,\n\tmapContents,\n\tmarkupText,\n\ttype Pieces,\n\treadProperty,\n\tscanHtml,\n\ttoPieces,\n\ttoTime,\n\ttoPlainData,\n} from \"./helpers.js\";\n\ntype BuiltinEntry = Extract<CallableEntry, { kind: \"builtin\" }>;\n\nconst define = (\n\tcall: BuiltinEntry[\"call\"],\n\tparams: readonly string[] = [],\n\toptions = false,\n): BuiltinEntry => ({ kind: \"builtin\", call, params, options });\n\n/** Counts code points without allocating an array. A surrogate without its partner counts as one, as `split` does. */\nconst codePointLength = (text: string): number => {\n\tlet count = 0;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\tif (code >= 0xd800 && code <= 0xdbff) {\n\t\t\tconst next = text.charCodeAt(i + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) i++;\n\t\t}\n\t\tcount++;\n\t}\n\treturn count;\n};\n\nconst SURROGATE = /[\\uD800-\\uDFFF]/;\n\n/** The UTF-16 index just after the first `count` code points, or the text's length when it has fewer. */\nconst codePointOffset = (text: string, count: number): number => {\n\tlet index = 0;\n\tfor (let n = 0; n < count && index < text.length; n++) {\n\t\tconst code = text.charCodeAt(index);\n\t\tconst next = text.charCodeAt(index + 1);\n\t\tindex +=\n\t\t\tcode >= 0xd800 && code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff\n\t\t\t\t? 2\n\t\t\t\t: 1;\n\t}\n\treturn index;\n};\n\n/** Splits text into code points, which is how string filters count characters. */\n// oxlint-disable-next-line typescript/no-misused-spread -- code points are the documented unit, not graphemes\nconst codePoints = (text: string): string[] => [...text];\n\nconst trimCharacters = (\n\ttext: string,\n\tcharacters: string,\n\tside: string,\n): string => {\n\tconst set = new Set(characters);\n\tconst chars = codePoints(text);\n\tlet start = 0;\n\tlet end = chars.length;\n\tif (side !== \"end\")\n\t\twhile (start < end && set.has(chars[start] as string)) start++;\n\tif (side !== \"start\")\n\t\twhile (end > start && set.has(chars[end - 1] as string)) end--;\n\treturn chars.slice(start, end).join(\"\");\n};\n\n/** Refuses a string a filter would build longer than `maxOutputLength`, before it builds it. */\nconst refuseLength = (run: Run, length: number, what: string): void => {\n\tif (length > run.state.maxSize) {\n\t\tissue(\n\t\t\t\"limit-output\",\n\t\t\t`\"${what}\" would build a string longer than the output limit of ${run.state.maxSize}`,\n\t\t);\n\t}\n};\n\n/**\n * Runs a string filter over markup's text. Tags, comments and entities stay as they are, and the result is markup of\n * the same strategy, so it isn't escaped again.\n */\nconst changeMarkup = (\n\trun: Run,\n\tmarkup: Markup,\n\tchange: (pieces: Pieces) => Pieces,\n): Markup => {\n\tcheckLength(run, markup.value);\n\treturn fromPieces(run, change(toPieces(markup)), markup.strategy);\n};\n\nconst mapText = (pieces: Pieces, change: (text: string) => string): Pieces =>\n\tpieces.map((piece) => (typeof piece === \"string\" ? change(piece) : piece));\n\n/** Joins the pieces of plain text, which never holds kept pieces. */\nconst joinText = (pieces: Pieces): string =>\n\tpieces\n\t\t.map((piece) => (typeof piece === \"string\" ? piece : piece.html))\n\t\t.join(\"\");\n\nconst upperFirst = (text: string): string => {\n\tconst head = String.fromCodePoint(text.codePointAt(0) as number);\n\treturn head.toUpperCase() + text.slice(head.length);\n};\n\n/** Upper-cases the first character of the text and lower-cases the rest. */\nconst capitalizeText = (text: string): string => {\n\tconst first = text.codePointAt(0);\n\tif (first === undefined) return \"\";\n\tconst head = String.fromCodePoint(first);\n\treturn head.toUpperCase() + text.slice(head.length).toLowerCase();\n};\n\n/** `capitalizeText` over pieces: the first character of the first text that has one. */\nconst capitalizePieces = (pieces: Pieces): Pieces => {\n\tlet first = true;\n\treturn mapText(pieces, (text) => {\n\t\tif (!first || text === \"\") return text.toLowerCase();\n\t\tfirst = false;\n\t\treturn capitalizeText(text);\n\t});\n};\n\n/** Letters, marks, digits and apostrophes, so neither a combining accent nor the apostrophe in \"o'neil\" starts a word. */\nconst WORD = /[\\p{L}\\p{M}\\p{N}'’]+/gu;\nconst STARTS_WITH_LETTER = /^\\p{L}/u;\nconst ENDS_IN_WORD = /[\\p{L}\\p{M}\\p{N}'’]$/u;\n\n/** Starts each word with an upper-case letter and lower-cases the rest. The first word only when `boundary` is true. */\nconst titleText = (text: string, boundary: boolean): string =>\n\ttext\n\t\t.toLowerCase()\n\t\t.replace(WORD, (word, offset: number) =>\n\t\t\t(offset > 0 || boundary) && STARTS_WITH_LETTER.test(word)\n\t\t\t\t? upperFirst(word)\n\t\t\t\t: word,\n\t\t);\n\n/** `titleText` over pieces. Tags don't end a word, but kept entities do. */\nconst titlePieces = (pieces: Pieces): Pieces => {\n\tlet boundary = true;\n\treturn pieces.map((piece) => {\n\t\tif (typeof piece !== \"string\") {\n\t\t\tif (!piece.html.startsWith(\"<\")) boundary = true;\n\t\t\treturn piece;\n\t\t}\n\t\tconst text = titleText(piece, boundary);\n\t\tboundary = !ENDS_IN_WORD.test(piece);\n\t\treturn text;\n\t});\n};\n\n/** Trims the text at each end of the pieces, stopping at a kept piece such as a tag. */\nconst trimPieces = (\n\tpieces: Pieces,\n\tside: string,\n\ttrimText: (text: string, side: \"start\" | \"end\") => string,\n): Pieces => {\n\tconst result = [...pieces];\n\tif (side !== \"end\") {\n\t\tfor (let i = 0; i < result.length; i++) {\n\t\t\tconst piece = result[i];\n\t\t\tif (typeof piece !== \"string\") break;\n\t\t\tresult[i] = trimText(piece, \"start\");\n\t\t\tif (result[i] !== \"\") break;\n\t\t}\n\t}\n\tif (side !== \"start\") {\n\t\tfor (let i = result.length - 1; i >= 0; i--) {\n\t\t\tconst piece = result[i];\n\t\t\tif (typeof piece !== \"string\") break;\n\t\t\tresult[i] = trimText(piece, \"end\");\n\t\t\tif (result[i] !== \"\") break;\n\t\t}\n\t}\n\treturn result;\n};\n\n/** Text a filter inserts: plain text, or markup kept as it is. */\ntype Insert = string | Kept;\n\nconst insertLength = (insert: Insert): number =>\n\ttypeof insert === \"string\" ? insert.length : insert.html.length;\n\n/**\n * Replaces several strings at once, preferring the longest match at each position. Candidates are looked up by their\n * first character, and the characters compared are charged against `maxSteps`, 256 to a step. The result is checked\n * against `maxOutputLength` as it grows, before it is joined.\n */\nconst replacePairs = (\n\trun: Run,\n\ttext: string,\n\tpairs: [string, Insert][],\n): Pieces => {\n\tconst byFirst = new Map<string, [string, Insert][]>();\n\tfor (const pair of pairs) {\n\t\tconst first = pair[0][0];\n\t\tif (first === undefined) continue;\n\t\tconst list = byFirst.get(first);\n\t\tif (list) list.push(pair);\n\t\telse byFirst.set(first, [pair]);\n\t}\n\tfor (const list of byFirst.values()) {\n\t\tlist.sort((a, b) => b[0].length - a[0].length);\n\t}\n\tconst pieces: Pieces = [];\n\tlet start = 0;\n\tlet i = 0;\n\tlet length = 0;\n\tlet compared = 0;\n\twhile (i < text.length) {\n\t\tconst candidates = byFirst.get(text[i] as string);\n\t\tlet match: [string, Insert] | undefined;\n\t\tif (candidates) {\n\t\t\tfor (const pair of candidates) {\n\t\t\t\tcompared += pair[0].length;\n\t\t\t\tif (text.startsWith(pair[0], i)) {\n\t\t\t\t\tmatch = pair;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (compared >= 256) {\n\t\t\t\tconsume(run, compared >> 8);\n\t\t\t\tcompared &= 255;\n\t\t\t}\n\t\t}\n\t\tif (!match) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tlength += i - start + insertLength(match[1]);\n\t\trefuseLength(run, length, \"replace\");\n\t\tif (i > start) pieces.push(text.slice(start, i));\n\t\tpieces.push(match[1]);\n\t\ti += match[0].length;\n\t\tstart = i;\n\t}\n\trefuseLength(run, length + text.length - start, \"replace\");\n\tif (start < text.length) pieces.push(text.slice(start));\n\treturn pieces;\n};\n\n/** Elements that have no closing tag. */\nconst VOID_ELEMENTS = new Set([\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\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\nconst TAG_NAME = /^<(\\/?)([a-zA-Z][^\\s/>]*)/;\n\n/**\n * Cuts markup's text after `max` characters, counting a kept entity as one, and adds `ending`. The tags still open at\n * the cut are closed, so the HTML stays balanced.\n */\nconst truncatePieces = (\n\tpieces: Pieces,\n\tmax: number,\n\tending: Insert,\n): Pieces => {\n\tconst result: Pieces = [];\n\tconst open: string[] = [];\n\tlet remaining = max;\n\tfor (const piece of pieces) {\n\t\tif (typeof piece !== \"string\" && piece.html.startsWith(\"<\")) {\n\t\t\tresult.push(piece);\n\t\t\tconst [, closing, name] = TAG_NAME.exec(piece.html) ?? [];\n\t\t\tconst tag = name?.toLowerCase();\n\t\t\tif (tag === undefined || VOID_ELEMENTS.has(tag)) continue;\n\t\t\tif (closing) {\n\t\t\t\tconst index = open.lastIndexOf(tag);\n\t\t\t\tif (index !== -1) open.length = index;\n\t\t\t} else if (!piece.html.endsWith(\"/>\")) open.push(tag);\n\t\t\tcontinue;\n\t\t}\n\t\tconst length = typeof piece === \"string\" ? codePointLength(piece) : 1;\n\t\tif (length <= remaining) {\n\t\t\tresult.push(piece);\n\t\t\tremaining -= length;\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof piece === \"string\" && remaining > 0) {\n\t\t\tresult.push(piece.slice(0, codePointOffset(piece, remaining)));\n\t\t}\n\t\tconst last = result[result.length - 1];\n\t\tif (typeof last === \"string\") result[result.length - 1] = last.trimEnd();\n\t\tresult.push(ending);\n\t\tfor (let i = open.length - 1; i >= 0; i--) {\n\t\t\tresult.push(new Kept(`</${open[i] as string}>`));\n\t\t}\n\t\treturn result;\n\t}\n\treturn result;\n};\n\nconst roundNumber = (\n\tvalue: number,\n\tprecision: number,\n\tmethod: string,\n): number => {\n\tif (method !== \"common\" && method !== \"ceil\" && method !== \"floor\") {\n\t\treturn issue(\n\t\t\t\"invalid-argument\",\n\t\t\t`\"round\" method must be \"common\", \"ceil\" or \"floor\", but got \"${method}\"`,\n\t\t);\n\t}\n\tconst shift = (number: number, exponent: number) => {\n\t\tconst [mantissa, power = \"0\"] = String(number).split(\"e\");\n\t\treturn Number(`${mantissa}e${Number(power) + exponent}`);\n\t};\n\tconst scaled = shift(\n\t\tmethod === \"common\" ? Math.abs(value) : value,\n\t\tprecision,\n\t);\n\t// Infinity, NaN and numbers with fewer decimal places than `precision` can hold are already rounded.\n\tif (!Number.isFinite(scaled)) return value;\n\tconst rounded = shift(\n\t\tmethod === \"ceil\"\n\t\t\t? Math.ceil(scaled)\n\t\t\t: method === \"floor\"\n\t\t\t\t? Math.floor(scaled)\n\t\t\t\t: Math.round(scaled),\n\t\t-precision,\n\t);\n\treturn method === \"common\" && value < 0 ? -rounded : rounded;\n};\n\n/**\n * Builds `urlEncode`'s query string from a hash. Each list and hash is charged against `maxSteps` before it is read,\n * and the text stops at `maxOutputLength` before each part is encoded, so a value that shares one object in many\n * places can't make unlimited work.\n */\nconst queryString = (run: Run, hash: object): string => {\n\tconst parts: string[] = [];\n\tconst seen = new Set<object>();\n\tlet length = 0;\n\tconst add = (value: object, prefix: string | null, depth: number) => {\n\t\tcheckDepth(depth, \"urlEncode\");\n\t\tconst { values, keys } = entriesOf(run, value, \"urlEncode\");\n\t\tseen.add(value);\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tconst item = values[i];\n\t\t\tif (item === null || item === undefined) continue;\n\t\t\tconst key =\n\t\t\t\tprefix === null ? String(keys[i]) : `${prefix}[${String(keys[i])}]`;\n\t\t\tif (\n\t\t\t\tArray.isArray(item) ||\n\t\t\t\tisPlainObject(item) ||\n\t\t\t\titem instanceof Map ||\n\t\t\t\titem instanceof Set\n\t\t\t) {\n\t\t\t\tif (seen.has(item)) {\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t\t'\"urlEncode\" cannot encode a value that contains itself',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tadd(item, key, depth + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst text = toStr(item);\n\t\t\t// Encoding never makes text shorter, so check before encoding, and again after.\n\t\t\trefuseLength(run, length + key.length + text.length, \"urlEncode\");\n\t\t\tconst part = `${escapeUrl(key)}=${escapeUrl(text)}`;\n\t\t\tlength += part.length + 1;\n\t\t\trefuseLength(run, length - 1, \"urlEncode\");\n\t\t\tparts.push(part);\n\t\t}\n\t\tseen.delete(value);\n\t};\n\tadd(hash, null, 1);\n\treturn parts.join(\"&\");\n};\n\nconst formatterCache = new Map<string, Formatter>();\n\n/** Longer cache keys aren't cached, so templates can't fill the cache with large strings. */\nconst MAX_FORMATTER_KEY = 512;\n\nconst NUMBER_OPTIONS = new Set([\n\t\"localeMatcher\",\n\t\"style\",\n\t\"currency\",\n\t\"currencyDisplay\",\n\t\"currencySign\",\n\t\"unit\",\n\t\"unitDisplay\",\n\t\"minimumIntegerDigits\",\n\t\"minimumFractionDigits\",\n\t\"maximumFractionDigits\",\n\t\"minimumSignificantDigits\",\n\t\"maximumSignificantDigits\",\n\t\"roundingPriority\",\n\t\"roundingIncrement\",\n\t\"roundingMode\",\n\t\"trailingZeroDisplay\",\n\t\"notation\",\n\t\"compactDisplay\",\n\t\"useGrouping\",\n\t\"signDisplay\",\n\t\"numberingSystem\",\n]);\n\n/** `plural` options configure both its plural rules and the number `#` becomes. */\nconst PLURAL_OPTIONS = new Set([...NUMBER_OPTIONS, \"type\"]);\n\n/** Date options that choose what to show. Without one, `formatDate` uses `dateStyle: \"medium\"`. */\nconst DATE_STYLE_OPTIONS = new Set([\n\t\"dateStyle\",\n\t\"timeStyle\",\n\t\"weekday\",\n\t\"era\",\n\t\"year\",\n\t\"month\",\n\t\"day\",\n\t\"dayPeriod\",\n\t\"hour\",\n\t\"minute\",\n\t\"second\",\n\t\"fractionalSecondDigits\",\n\t\"timeZoneName\",\n]);\n\nconst DATE_OPTIONS = new Set([\n\t...DATE_STYLE_OPTIONS,\n\t\"localeMatcher\",\n\t\"calendar\",\n\t\"numberingSystem\",\n\t\"hour12\",\n\t\"hourCycle\",\n\t\"timeZone\",\n\t\"formatMatcher\",\n]);\n\n/** Keys of frozen options hashes, which the compiler builds once for literal named arguments. */\nconst optionsKeys = new WeakMap<object, string>();\n\n/**\n * The part of a formatter's cache key its options make. Option names must be ones `Intl` knows, from `names`. Option\n * values must be strings, markup, numbers, booleans or null: `JSON.stringify` and `Intl` would call methods such as\n * `toJSON` and `toString` on anything else.\n */\nconst optionsKey = (\n\toptions: Record<string, unknown>,\n\tnames: ReadonlySet<string>,\n): string => {\n\tconst frozen = Object.isFrozen(options);\n\tlet key = frozen ? optionsKeys.get(options) : undefined;\n\tif (key !== undefined) return key;\n\tkey = \"\";\n\tfor (const name of hashKeys(options)) {\n\t\tif (name === \"locale\") continue;\n\t\tif (!names.has(name)) {\n\t\t\treturn issue(\"invalid-argument\", `Unknown formatting option \"${name}\"`);\n\t\t}\n\t\tconst value = unwrap(options[name]);\n\t\tif (\n\t\t\t(typeof value === \"object\" && value !== null) ||\n\t\t\ttypeof value === \"function\"\n\t\t) {\n\t\t\treturn issue(\n\t\t\t\t\"type-error\",\n\t\t\t\t`Formatting option \"${name}\" must be a string, number or boolean, but got ${valueLabel(value)}`,\n\t\t\t);\n\t\t}\n\t\tkey += `|${name}=${JSON.stringify(value)}`;\n\t}\n\tif (frozen) optionsKeys.set(options, key);\n\treturn key;\n};\n\ntype Formatter = Format | Intl.PluralRules;\n\n/** Formatters that calls without options last resolved to. */\nconst NO_OPTIONS: FormatterCells = {};\n\n/**\n * Splits `locale` out of filter options and caches the formatter by its settings. `names` are the options allowed, and\n * `defaults` gives the settings the options are merged over.\n *\n * Calls without options, or with a hash of literals such as `formatNumber(style: \"currency\")`'s, which\n * `literalOptions` gives a place for it, first try the formatter they used last, so a filter called in a loop skips\n * building the cache key.\n */\nconst cachedFormatter = <T extends Formatter>(\n\tkind: \"number\" | \"date\" | \"plural\",\n\trun: Run,\n\toptions: unknown,\n\tnames: ReadonlySet<string>,\n\tdefaults: (options: Record<string, unknown>) => Record<string, unknown>,\n\tcreate: (locale: string, options: Record<string, unknown>) => T,\n): T => {\n\tconst { state } = run;\n\tconst cells =\n\t\toptions === undefined || options === null\n\t\t\t? NO_OPTIONS\n\t\t\t: typeof options === \"object\"\n\t\t\t\t? (options as { [FORMATTERS]?: FormatterCells })[FORMATTERS]\n\t\t\t\t: undefined;\n\tconst recent = cells?.[kind];\n\tif (\n\t\trecent &&\n\t\trecent.locale === state.locale &&\n\t\trecent.timeZone === state.timeZone\n\t) {\n\t\treturn recent.formatter as T;\n\t}\n\tif (options !== undefined && options !== null && !isPlainObject(options)) {\n\t\treturn issue(\n\t\t\t\"type-error\",\n\t\t\t`Formatting options must be a hash, but got a ${typeName(options)}`,\n\t\t);\n\t}\n\tconst given = (options ?? {}) as Record<string, unknown>;\n\tconst locale = given.locale === undefined ? run.state.locale : given.locale;\n\tif (typeof locale !== \"string\") {\n\t\treturn issue(\"type-error\", '\"locale\" must be a string');\n\t}\n\t// The key lists defaults then options in order, which fixes the merged settings, without building them on a hit.\n\tconst base = defaults(given);\n\tlet key = `${kind}|${locale}`;\n\tfor (const name in base) key += `|${name}=${JSON.stringify(base[name])}`;\n\tkey += optionsKey(given, names);\n\tconst cacheable = key.length <= MAX_FORMATTER_KEY;\n\tlet formatter = cacheable\n\t\t? (formatterCache.get(key) as T | undefined)\n\t\t: undefined;\n\tif (!formatter) {\n\t\tconst settings = { ...base };\n\t\tfor (const name of hashKeys(given)) {\n\t\t\tif (name !== \"locale\") setOwn(settings, name, unwrap(given[name]));\n\t\t}\n\t\tformatter = create(locale, settings);\n\t\tif (cacheable) {\n\t\t\tif (formatterCache.size > 500) formatterCache.clear();\n\t\t\tformatterCache.set(key, formatter);\n\t\t}\n\t}\n\tif (cells) {\n\t\tcells[kind] = {\n\t\t\tlocale: state.locale,\n\t\t\ttimeZone: state.timeZone,\n\t\t\tformatter,\n\t\t};\n\t}\n\treturn formatter;\n};\n\n/** Calls a template callback for each item, then gathers the results, waiting only if one was a promise. */\nconst mapEntries = (\n\trun: Run,\n\tvalue: unknown,\n\tcallback: unknown,\n\twhat: string,\n\tgather: (\n\t\tresults: unknown[],\n\t\tvalues: unknown[],\n\t\tkeys: unknown[],\n\t\tisHash: boolean,\n\t) => unknown,\n): unknown => {\n\tconst fn = functionArgument(callback, what);\n\tconst { values, keys, isHash } = entriesOf(run, value, what);\n\tconst results: unknown[] = [];\n\ttry {\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tresults.push(fn(values[i], keys[i]));\n\t\t}\n\t} catch (error) {\n\t\t// Earlier callbacks may have started async work. Stop their rejections being reported as unhandled.\n\t\tfor (const result of results) silence(result);\n\t\tthrow error;\n\t}\n\tif (results.some(isPromise)) {\n\t\treturn all(results).then((resolved) =>\n\t\t\thold(gather(resolved, values, keys, isHash)),\n\t\t);\n\t}\n\treturn gather(results, values, keys, isHash);\n};\n\nconst buildCollection = (\n\tisHash: boolean,\n\tkeys: unknown[],\n\titems: unknown[],\n): unknown[] | Record<string, unknown> => {\n\tif (!isHash) return items;\n\tconst result: Record<string, unknown> = {};\n\titems.forEach((item, index) => {\n\t\tsetOwn(result, String(keys[index]), item);\n\t});\n\treturn result;\n};\n\nconst syncResult = (value: unknown, what: string): unknown => {\n\tif (isPromise(value)) {\n\t\tvalue.catch(() => {});\n\t\treturn issue(\n\t\t\t\"invalid-argument\",\n\t\t\t`\"${what}\" callbacks must not wait for async data`,\n\t\t);\n\t}\n\treturn value;\n};\n\n/**\n * Removes HTML tags and comments. Where a `<` would end up before a letter once a tag after it is removed, it is\n * dropped too, so removing tags can't make new ones.\n */\nconst stripTags = (html: string): string => {\n\tconst parts: string[] = [];\n\tscanHtml(\n\t\thtml,\n\t\t(text) => {\n\t\t\tconst last = parts.length - 1;\n\t\t\tconst previous = parts[last];\n\t\t\tif (previous?.endsWith(\"<\") && /^[a-zA-Z!?/]/.test(text)) {\n\t\t\t\tparts[last] = previous.slice(0, -1);\n\t\t\t}\n\t\t\tparts.push(text);\n\t\t},\n\t\t() => {},\n\t);\n\treturn parts.join(\"\");\n};\n\n/** `sort`'s order: natural order without `by`, by a key with a one-parameter arrow, or with a comparator. */\nconst sortBy = <T>(\n\titems: T[],\n\tread: (item: T) => unknown,\n\tby: unknown,\n): T[] => {\n\tif (by === undefined || by === null) {\n\t\treturn items.sort((a, b) => compare(read(a), read(b)));\n\t}\n\tconst fn = functionArgument(by, \"sort\");\n\tif (fn.length >= 2) {\n\t\treturn items.sort((a, b) => {\n\t\t\tconst result = syncResult(fn(read(a), read(b)), \"sort\");\n\t\t\treturn typeof result === \"number\"\n\t\t\t\t? result\n\t\t\t\t: issue(\"type-error\", '\"sort\" comparator must return a number');\n\t\t});\n\t}\n\tconst keyed = items.map((item) => ({\n\t\titem,\n\t\tkey: syncResult(fn(read(item)), \"sort\"),\n\t}));\n\tkeyed.sort((a, b) => compare(a.key, b.key));\n\treturn keyed.map((entry) => entry.item);\n};\n\nconst allStrings = (items: unknown[]): items is string[] => {\n\tfor (let i = 0; i < items.length; i++) {\n\t\tif (typeof items[i] !== \"string\") return false;\n\t}\n\treturn true;\n};\n\n/**\n * Sorts strings by UTF-16 code units, as the default sort does, which skips calling `compare`. Short lists, such as a\n * post's tags, sort in place by insertion, which keeps the same order and is faster for them.\n */\nconst sortStrings = (items: string[]): string[] => {\n\tif (items.length > 16) return items.sort();\n\tfor (let i = 1; i < items.length; i++) {\n\t\tconst item = items[i] as string;\n\t\tlet j = i - 1;\n\t\twhile (j >= 0 && (items[j] as string) > item) {\n\t\t\titems[j + 1] = items[j] as string;\n\t\t\tj--;\n\t\t}\n\t\titems[j + 1] = item;\n\t}\n\treturn items;\n};\n\n/** A hash of keys and values in the order given. A `Map`, so keys that look like numbers keep their place too. */\nconst orderedHash = (\n\tkeys: unknown[],\n\tvalues: unknown[],\n): Map<string, unknown> =>\n\tnew Map(keys.map((key, index) => [String(key), values[index]]));\n\n// Case changes for markup's text.\nconst toUpper = (text: string): string => text.toUpperCase();\nconst toLower = (text: string): string => text.toLowerCase();\nconst upperPieces = (pieces: Pieces): Pieces => mapText(pieces, toUpper);\nconst lowerPieces = (pieces: Pieces): Pieces => mapText(pieces, toLower);\n\n/** Escapes characters that could end a `<script>` element or break JavaScript, inside JSON strings. */\nconst escapeJson = (json: string): string =>\n\tjson.replace(\n\t\t/[<>&\\u2028\\u2029]/g,\n\t\t(char) => `\\\\u${char.charCodeAt(0).toString(16).padStart(4, \"0\")}`,\n\t);\n\nexport const builtinFilters: Record<string, BuiltinEntry> = {\n\t// Changing case makes text at most three times longer, and changing it again doesn't add more, so these leave the\n\t// output limit to whatever prints the result. A check here would cost the commonest filters a fifth of their speed.\n\tupper: define((run, value) =>\n\t\ttypeof value === \"string\"\n\t\t\t? value.toUpperCase()\n\t\t\t: value instanceof Markup\n\t\t\t\t? changeMarkup(run, value, upperPieces)\n\t\t\t\t: toStringArgument(value, '\"upper\"').toUpperCase(),\n\t),\n\tlower: define((run, value) =>\n\t\ttypeof value === \"string\"\n\t\t\t? value.toLowerCase()\n\t\t\t: value instanceof Markup\n\t\t\t\t? changeMarkup(run, value, lowerPieces)\n\t\t\t\t: toStringArgument(value, '\"lower\"').toLowerCase(),\n\t),\n\tcapitalize: define((run, value) =>\n\t\ttypeof value !== \"string\" && value instanceof Markup\n\t\t\t? changeMarkup(run, value, capitalizePieces)\n\t\t\t: capitalizeText(toStringArgument(value, '\"capitalize\"')),\n\t),\n\ttitle: define((run, value) =>\n\t\tvalue instanceof Markup\n\t\t\t? changeMarkup(run, value, titlePieces)\n\t\t\t: titleText(toStringArgument(value, '\"title\"'), true),\n\t),\n\ttrim: define(\n\t\t(run, value, characters, side = \"both\") => {\n\t\t\tif (side !== \"both\" && side !== \"start\" && side !== \"end\") {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t`\"trim\" side must be \"both\", \"start\" or \"end\", but got ${valueLabel(side)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst set =\n\t\t\t\tcharacters === undefined || characters === null\n\t\t\t\t\t? null\n\t\t\t\t\t: toStringArgument(characters, '\"trim\"');\n\t\t\tif (typeof value !== \"string\" && value instanceof Markup) {\n\t\t\t\tconst trimText = (text: string, end: \"start\" | \"end\") =>\n\t\t\t\t\tset !== null\n\t\t\t\t\t\t? trimCharacters(text, set, end)\n\t\t\t\t\t\t: end === \"start\"\n\t\t\t\t\t\t\t? text.trimStart()\n\t\t\t\t\t\t\t: text.trimEnd();\n\t\t\t\treturn changeMarkup(run, value, (pieces) =>\n\t\t\t\t\ttrimPieces(pieces, side, trimText),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst text = toStringArgument(value, '\"trim\"');\n\t\t\tif (set !== null) return trimCharacters(text, set, side);\n\t\t\treturn side === \"start\"\n\t\t\t\t? text.trimStart()\n\t\t\t\t: side === \"end\"\n\t\t\t\t\t? text.trimEnd()\n\t\t\t\t\t: text.trim();\n\t\t},\n\t\t[\"characters\", \"side\"],\n\t),\n\treplace: define(\n\t\t(run, value, search, replacement) => {\n\t\t\tconst isPairs = isPlainObject(search) || search instanceof Map;\n\t\t\tif (value instanceof Markup) {\n\t\t\t\tconst { strategy } = value;\n\t\t\t\tconst pairs: [string, Insert][] = [];\n\t\t\t\tif (isPairs) {\n\t\t\t\t\tconst { values, keys } = entriesOf(run, search, \"replace\");\n\t\t\t\t\tkeys.forEach((key, index) => {\n\t\t\t\t\t\tpairs.push([\n\t\t\t\t\t\t\tString(key),\n\t\t\t\t\t\t\tinsertedPiece(values[index], strategy, '\"replace\"'),\n\t\t\t\t\t\t]);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tpairs.push([\n\t\t\t\t\t\tsearch instanceof Markup\n\t\t\t\t\t\t\t? markupText(search)\n\t\t\t\t\t\t\t: toStringArgument(search, '\"replace\"'),\n\t\t\t\t\t\tinsertedPiece(replacement, strategy, '\"replace\"'),\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t\treturn changeMarkup(run, value, (pieces) =>\n\t\t\t\t\tpieces.flatMap((piece) =>\n\t\t\t\t\t\ttypeof piece === \"string\"\n\t\t\t\t\t\t\t? replacePairs(run, piece, pairs)\n\t\t\t\t\t\t\t: [piece],\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst text = toStringArgument(value, '\"replace\"');\n\t\t\tif (isPairs) {\n\t\t\t\tconst { values, keys } = entriesOf(run, search, \"replace\");\n\t\t\t\treturn joinText(\n\t\t\t\t\treplacePairs(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\tkeys.map((key, index) => [String(key), toStr(values[index])]),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst needle = toStringArgument(search, '\"replace\"');\n\t\t\tif (needle === \"\") return text;\n\t\t\tconst parts = text.split(needle);\n\t\t\tconst glue = toStringArgument(replacement, '\"replace\"');\n\t\t\t// Each match swaps the needle for the replacement.\n\t\t\trefuseLength(\n\t\t\t\trun,\n\t\t\t\ttext.length + (parts.length - 1) * (glue.length - needle.length),\n\t\t\t\t\"replace\",\n\t\t\t);\n\t\t\treturn parts.join(glue);\n\t\t},\n\t\t[\"search\", \"replacement\"],\n\t),\n\tsplit: define(\n\t\t(run, value, separator, limit) => {\n\t\t\tconst text = toStringArgument(value, '\"split\"');\n\t\t\tconst glue = toStringArgument(separator, '\"split\"');\n\t\t\tconst parts = glue === \"\" ? codePoints(text) : text.split(glue);\n\t\t\tconsume(run, parts.length);\n\t\t\tif (limit === undefined || limit === null) return parts;\n\t\t\treturn parts.slice(\n\t\t\t\t0,\n\t\t\t\tMath.max(0, integerArgument(limit, '\"split\" limit')),\n\t\t\t);\n\t\t},\n\t\t[\"separator\", \"limit\"],\n\t),\n\ttruncate: define(\n\t\t(run, value, length, ellipsis = \"…\") => {\n\t\t\tconst max = integerArgument(length, '\"truncate\" length');\n\t\t\tif (value instanceof Markup) {\n\t\t\t\tconst ending = insertedPiece(ellipsis, value.strategy, '\"truncate\"');\n\t\t\t\treturn changeMarkup(run, value, (pieces) =>\n\t\t\t\t\ttruncatePieces(pieces, max, ending),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst text = toStringArgument(value, '\"truncate\"');\n\t\t\tif (text.length <= max) return text;\n\t\t\tconst end = SURROGATE.test(text)\n\t\t\t\t? codePointOffset(text, max)\n\t\t\t\t: Math.max(0, max);\n\t\t\tif (max >= 0 && end === text.length) return text;\n\t\t\t// The ending can be any string, even the text itself, so the result can be longer than the text.\n\t\t\treturn checkLength(\n\t\t\t\trun,\n\t\t\t\ttext.slice(0, end).trimEnd() + toStringArgument(ellipsis, '\"truncate\"'),\n\t\t\t);\n\t\t},\n\t\t[\"length\", \"ellipsis\"],\n\t),\n\tstripTags: define((run, value) => {\n\t\tif (!(value instanceof Markup)) {\n\t\t\treturn stripTags(toStringArgument(value, '\"stripTags\"'));\n\t\t}\n\t\t// HTML markup's text stays escaped. Other markup's text is decoded, stripped and escaped again.\n\t\treturn isHtmlStrategy(value.strategy)\n\t\t\t? new Markup(stripTags(value.value), value.strategy)\n\t\t\t: fromPieces(run, [stripTags(markupText(value))], value.strategy);\n\t}),\n\tnl2br: define((run, value) => {\n\t\t// Markup made for any strategy is also safe in HTML.\n\t\tconst html =\n\t\t\tvalue instanceof Markup\n\t\t\t\t? value.value\n\t\t\t\t: escapeHtml(checkLength(run, toStr(value)));\n\t\tlet breaks = 0;\n\t\tfor (let i = 0; i < html.length; i++) {\n\t\t\tconst code = html.charCodeAt(i);\n\t\t\tif (code === 10 || (code === 13 && html.charCodeAt(i + 1) !== 10)) {\n\t\t\t\tbreaks++;\n\t\t\t}\n\t\t}\n\t\trefuseLength(run, html.length + breaks * 4, \"nl2br\");\n\t\treturn new Markup(html.replace(/\\r\\n|\\n|\\r/g, \"<br>$&\"), \"html\");\n\t}),\n\turlEncode: define((run, value) => {\n\t\t// Encoding again makes text three times longer each time, so it stops at the output limit.\n\t\tif (typeof value === \"string\") return escapeUrl(value, run.state.maxSize);\n\t\tconst target = unwrap(value);\n\t\tif (isPlainObject(target) || target instanceof Map) {\n\t\t\treturn queryString(run, target);\n\t\t}\n\t\treturn escapeUrl(toStr(target), run.state.maxSize);\n\t}),\n\tjson: define(\n\t\t(run, value, indent) => {\n\t\t\tif (\n\t\t\t\tindent !== undefined &&\n\t\t\t\tindent !== null &&\n\t\t\t\ttypeof indent !== \"number\" &&\n\t\t\t\ttypeof indent !== \"string\"\n\t\t\t) {\n\t\t\t\treturn issue(\"type-error\", '\"json\" indent must be a number or string');\n\t\t\t}\n\t\t\t// `JSON.stringify` indents by at most 10 characters.\n\t\t\tconst width =\n\t\t\t\ttypeof indent === \"number\"\n\t\t\t\t\t? Math.max(0, Math.min(10, Math.floor(indent)))\n\t\t\t\t\t: typeof indent === \"string\"\n\t\t\t\t\t\t? Math.min(10, indent.length)\n\t\t\t\t\t\t: 0;\n\t\t\tconst data = toPlainData(\n\t\t\t\tvalue,\n\t\t\t\t() =>\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t\t'\"json\" cannot serialise a value that contains itself',\n\t\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\twhat: \"json\",\n\t\t\t\t\tcharge: (count) => consume(run, count),\n\t\t\t\t\tmaxLength: run.state.maxSize,\n\t\t\t\t\tindent: width,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn checkLength(\n\t\t\t\trun,\n\t\t\t\tescapeJson(JSON.stringify(data ?? null, null, indent ?? undefined)),\n\t\t\t);\n\t\t},\n\t\t[\"indent\"],\n\t),\n\tlength: define((run, value) => {\n\t\tif (value === null || value === undefined) return 0;\n\t\tif (typeof value === \"string\") return codePointLength(value);\n\t\tif (value instanceof Markup) return codePointLength(value.value);\n\t\tif (Array.isArray(value)) return value.length;\n\t\tif (value instanceof Set) return value.size;\n\t\t// Counts the entries templates can read, which is what loops see.\n\t\tif (isPlainObject(value)) {\n\t\t\tconst count = hashKeys(value).length;\n\t\t\tconsume(run, count);\n\t\t\treturn count;\n\t\t}\n\t\tif (value instanceof Map) {\n\t\t\tconsume(run, value.size);\n\t\t\treturn mapContents(value).keys.length;\n\t\t}\n\t\tif (typeof value === \"object\" && Symbol.iterator in value) {\n\t\t\treturn entriesOf(run, value, \"length\").values.length;\n\t\t}\n\t\treturn issue(\"type-error\", `\"length\" cannot measure a ${typeName(value)}`);\n\t}),\n\tfirst: define((run, value) => {\n\t\tif (Array.isArray(value)) return value[0] ?? null;\n\t\tconst target = unwrap(value);\n\t\tif (typeof target === \"string\") {\n\t\t\tconst code = target.codePointAt(0);\n\t\t\treturn code === undefined ? null : String.fromCodePoint(code);\n\t\t}\n\t\t// A hash stops at its first key that templates can read.\n\t\tif (isPlainObject(target)) {\n\t\t\tfor (const key in target) {\n\t\t\t\tif (Object.hasOwn(target, key) && !BLOCKED_NAMES.has(key)) {\n\t\t\t\t\treturn target[key] ?? null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\tif (target instanceof Map) {\n\t\t\tfor (const [key, item] of target) {\n\t\t\t\tif (typeof key !== \"string\" || !BLOCKED_NAMES.has(key)) {\n\t\t\t\t\treturn item ?? null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn listOf(run, target, \"first\")[0] ?? null;\n\t}),\n\tlast: define((run, value) => {\n\t\tconst target = unwrap(value);\n\t\tif (typeof target === \"string\") return codePoints(target).pop() ?? null;\n\t\tconst items = listOf(run, target, \"last\");\n\t\treturn items[items.length - 1] ?? null;\n\t}),\n\tslice: define(\n\t\t(run, value, start, end) => {\n\t\t\tconst from = integerArgument(start, '\"slice\" start');\n\t\t\tconst to =\n\t\t\t\tend === undefined || end === null\n\t\t\t\t\t? undefined\n\t\t\t\t\t: integerArgument(end, '\"slice\" end');\n\t\t\tconst target = unwrap(value);\n\t\t\tif (typeof target === \"string\")\n\t\t\t\treturn codePoints(target).slice(from, to).join(\"\");\n\t\t\tif (isHashLike(target)) {\n\t\t\t\treturn issue(\n\t\t\t\t\t\"type-error\",\n\t\t\t\t\t'\"slice\" needs an array or string, but got a hash',\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst result = listOf(run, target, \"slice\").slice(from, to);\n\t\t\tconsume(run, result.length);\n\t\t\treturn result;\n\t\t},\n\t\t[\"start\", \"end\"],\n\t),\n\tjoin: define(\n\t\t(run, value, glue = \"\", lastGlue) => {\n\t\t\t// An array with a string glue joins without copying, in the same order of checks.\n\t\t\tif (\n\t\t\t\tArray.isArray(value) &&\n\t\t\t\ttypeof glue === \"string\" &&\n\t\t\t\t(lastGlue === undefined || lastGlue === null)\n\t\t\t) {\n\t\t\t\tconsume(run, value.length);\n\t\t\t\tlet text = \"\";\n\t\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\t\tconst item: unknown = value[i];\n\t\t\t\t\tconst piece = typeof item === \"string\" ? item : toStr(item);\n\t\t\t\t\trefuseLength(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\ttext.length + piece.length + (i > 0 ? glue.length : 0),\n\t\t\t\t\t\t\"join\",\n\t\t\t\t\t);\n\t\t\t\t\tif (i > 0) text += glue;\n\t\t\t\t\ttext += piece;\n\t\t\t\t}\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tconst items = entriesOf(run, value, \"join\").values.map((item) =>\n\t\t\t\ttoStr(item),\n\t\t\t);\n\t\t\tconst separator = toStringArgument(glue, '\"join\"');\n\t\t\tconst last =\n\t\t\t\tlastGlue === undefined || lastGlue === null || items.length < 2\n\t\t\t\t\t? separator\n\t\t\t\t\t: toStringArgument(lastGlue, '\"join\"');\n\t\t\tlet length =\n\t\t\t\titems.length < 2\n\t\t\t\t\t? 0\n\t\t\t\t\t: (items.length - 2) * separator.length + last.length;\n\t\t\tfor (const item of items) length += item.length;\n\t\t\trefuseLength(run, length, \"join\");\n\t\t\tif (last === separator) return items.join(separator);\n\t\t\tconst final = items.pop() as string;\n\t\t\treturn `${items.join(separator)}${last}${final}`;\n\t\t},\n\t\t[\"glue\", \"lastGlue\"],\n\t),\n\tkeys: define((run, value) => entriesOf(run, value, \"keys\").keys),\n\tmerge: define((run, value, ...others) => {\n\t\tconst all = [value, ...others].filter(\n\t\t\t(item) => item !== null && item !== undefined,\n\t\t);\n\t\tif (all.length === 0) return [];\n\t\tif (all.every((item) => Array.isArray(item) || item instanceof Set)) {\n\t\t\t// Charge for every item before building, so repeated merging cannot exhaust memory.\n\t\t\tconsume(\n\t\t\t\trun,\n\t\t\t\tall.reduce<number>(\n\t\t\t\t\t(total, item) =>\n\t\t\t\t\t\ttotal +\n\t\t\t\t\t\t(Array.isArray(item) ? item.length : (item as Set<unknown>).size),\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst result: unknown[] = [];\n\t\t\tfor (const item of all) {\n\t\t\t\tfor (const entry of item as Iterable<unknown>) result.push(entry);\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\tif (all.every((item) => isPlainObject(item) || item instanceof Map)) {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tfor (const item of all) {\n\t\t\t\tconst { values, keys } = entriesOf(run, item, \"merge\");\n\t\t\t\tkeys.forEach((key, index) => {\n\t\t\t\t\tsetOwn(result, String(key), values[index]);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn issue(\n\t\t\t\"type-error\",\n\t\t\t'\"merge\" needs all arrays or all hashes, not a mix',\n\t\t);\n\t}),\n\treverse: define((run, value) => {\n\t\tconst target = unwrap(value);\n\t\tif (typeof target === \"string\")\n\t\t\treturn codePoints(target).reverse().join(\"\");\n\t\tif (isHashLike(target)) {\n\t\t\tconst { values, keys } = entriesOf(run, target, \"reverse\");\n\t\t\treturn orderedHash([...keys].reverse(), [...values].reverse());\n\t\t}\n\t\tconst items = listOf(run, target, \"reverse\");\n\t\tconsume(run, items.length);\n\t\treturn [...items].reverse();\n\t}),\n\tsort: define(\n\t\t(run, value, by) => {\n\t\t\tif (!Array.isArray(value) && isHashLike(value)) {\n\t\t\t\tconst { values, keys } = entriesOf(run, value, \"sort\");\n\t\t\t\tconst sorted = sortBy(\n\t\t\t\t\tkeys.map((key, index) => ({ key, item: values[index] })),\n\t\t\t\t\t(entry) => entry.item,\n\t\t\t\t\tby,\n\t\t\t\t);\n\t\t\t\treturn orderedHash(\n\t\t\t\t\tsorted.map((entry) => entry.key),\n\t\t\t\t\tsorted.map((entry) => entry.item),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst items = [...listOf(run, value, \"sort\")];\n\t\t\tconsume(run, items.length);\n\t\t\tif ((by === undefined || by === null) && allStrings(items)) {\n\t\t\t\treturn sortStrings(items);\n\t\t\t}\n\t\t\treturn sortBy(items, (item) => item, by);\n\t\t},\n\t\t[\"by\"],\n\t),\n\tmap: define(\n\t\t(run, value, callback) =>\n\t\t\tmapEntries(\n\t\t\t\trun,\n\t\t\t\tvalue,\n\t\t\t\tcallback,\n\t\t\t\t\"map\",\n\t\t\t\t(results, _values, keys, isHash) =>\n\t\t\t\t\tbuildCollection(isHash, keys, results),\n\t\t\t),\n\t\t[\"callback\"],\n\t),\n\tfilter: define(\n\t\t(run, value, callback) =>\n\t\t\tmapEntries(\n\t\t\t\trun,\n\t\t\t\tvalue,\n\t\t\t\tcallback,\n\t\t\t\t\"filter\",\n\t\t\t\t(results, values, keys, isHash) => {\n\t\t\t\t\tconst keptKeys: unknown[] = [];\n\t\t\t\t\tconst kept: unknown[] = [];\n\t\t\t\t\tresults.forEach((result, index) => {\n\t\t\t\t\t\tif (truthy(result)) {\n\t\t\t\t\t\t\tkept.push(values[index]);\n\t\t\t\t\t\t\tkeptKeys.push(keys[index]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn buildCollection(isHash, keptKeys, kept);\n\t\t\t\t},\n\t\t\t),\n\t\t[\"callback\"],\n\t),\n\treduce: define(\n\t\t(run, value, callback, initial = null) => {\n\t\t\tconst fn = functionArgument(callback, \"reduce\");\n\t\t\tconst { values, keys } = entriesOf(run, value, \"reduce\");\n\t\t\tconst from = (index: number, carry: unknown): unknown => {\n\t\t\t\tlet current = carry;\n\t\t\t\tfor (let i = index; i < values.length; i++) {\n\t\t\t\t\tconst result = fn(current, values[i], keys[i]);\n\t\t\t\t\tif (isPromise(result)) {\n\t\t\t\t\t\treturn result.then((resolved) =>\n\t\t\t\t\t\t\thold(from(i + 1, unhold(resolved))),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcurrent = result;\n\t\t\t\t}\n\t\t\t\treturn current;\n\t\t\t};\n\t\t\treturn from(0, initial);\n\t\t},\n\t\t[\"callback\", \"initial\"],\n\t),\n\tfind: define(\n\t\t(run, value, callback) => {\n\t\t\tconst fn = functionArgument(callback, \"find\");\n\t\t\tconst { values, keys } = entriesOf(run, value, \"find\");\n\t\t\tconst from = (index: number): unknown => {\n\t\t\t\tfor (let i = index; i < values.length; i++) {\n\t\t\t\t\tconst result = fn(values[i], keys[i]);\n\t\t\t\t\tif (isPromise(result)) {\n\t\t\t\t\t\treturn result.then((resolved) =>\n\t\t\t\t\t\t\thold(\n\t\t\t\t\t\t\t\ttruthy(unhold(resolved)) ? (values[i] ?? null) : from(i + 1),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (truthy(result)) return values[i] ?? null;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t};\n\t\t\treturn from(0);\n\t\t},\n\t\t[\"callback\"],\n\t),\n\tcolumn: define(\n\t\t(run, value, name) => {\n\t\t\tconst key = unwrap(name);\n\t\t\tif (typeof key !== \"string\" && typeof key !== \"number\") {\n\t\t\t\treturn issue(\"type-error\", '\"column\" needs a property name');\n\t\t\t}\n\t\t\tconst items = listOf(run, value, \"column\");\n\t\t\tconsume(run, items.length);\n\t\t\treturn items.map((item) => readProperty(item, key));\n\t\t},\n\t\t[\"name\"],\n\t),\n\tbatch: define(\n\t\t(run, value, size, fill) => {\n\t\t\tconst count = integerArgument(size, '\"batch\" size');\n\t\t\tif (count < 1)\n\t\t\t\treturn issue(\"invalid-argument\", '\"batch\" size must be at least 1');\n\t\t\tconst items = listOf(run, value, \"batch\");\n\t\t\tconst groupCount = Math.ceil(items.length / count);\n\t\t\t// Padding can create far more items than went in, so charge for the output size.\n\t\t\tconsume(run, fill === undefined ? items.length : groupCount * count);\n\t\t\tconst groups: unknown[][] = [];\n\t\t\tfor (let i = 0; i < items.length; i += count) {\n\t\t\t\tgroups.push(items.slice(i, i + count));\n\t\t\t}\n\t\t\tconst last = groups[groups.length - 1];\n\t\t\tif (last && fill !== undefined) {\n\t\t\t\twhile (last.length < count) last.push(fill);\n\t\t\t}\n\t\t\treturn groups;\n\t\t},\n\t\t[\"size\", \"fill\"],\n\t),\n\tabs: define((_run, value) => Math.abs(toNumber(value, \"abs\"))),\n\tround: define(\n\t\t(_run, value, precision = 0, method = \"common\") =>\n\t\t\troundNumber(\n\t\t\t\ttoNumber(value, \"round\"),\n\t\t\t\tintegerArgument(precision, '\"round\" precision'),\n\t\t\t\ttoStringArgument(method, '\"round\" method'),\n\t\t\t),\n\t\t[\"precision\", \"method\"],\n\t),\n\tformatNumber: define(\n\t\t(run, value, options) => {\n\t\t\tconst formatter = cachedFormatter(\n\t\t\t\t\"number\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tNUMBER_OPTIONS,\n\t\t\t\t() => ({}),\n\t\t\t\t(locale, settings) =>\n\t\t\t\t\tnumberFormat(new Intl.NumberFormat(locale, settings)),\n\t\t\t);\n\t\t\tif (value === null || value === undefined) return \"\";\n\t\t\treturn formatter(toNumber(value, \"formatNumber\"));\n\t\t},\n\t\t[],\n\t\ttrue,\n\t),\n\tplural: define(\n\t\t(run, value, one, other, zero, two, few, many, options) => {\n\t\t\tconst rules = cachedFormatter(\n\t\t\t\t\"plural\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tPLURAL_OPTIONS,\n\t\t\t\t() => ({}),\n\t\t\t\t(locale, settings) => new Intl.PluralRules(locale, settings),\n\t\t\t);\n\t\t\tif (value === null || value === undefined) return \"\";\n\t\t\tconst count = toNumber(value, \"plural\");\n\t\t\tif (other === null || other === undefined) {\n\t\t\t\treturn issue(\"invalid-argument\", '\"plural\" needs an \"other\" form');\n\t\t\t}\n\t\t\tconst forms = { zero, one, two, few, many, other };\n\t\t\tconst form = toStringArgument(\n\t\t\t\tforms[rules.select(count)] ?? other,\n\t\t\t\t'\"plural\"',\n\t\t\t);\n\t\t\tif (!form.includes(\"#\")) return form;\n\t\t\tconst formatter = cachedFormatter(\n\t\t\t\t\"number\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tPLURAL_OPTIONS,\n\t\t\t\t() => ({}),\n\t\t\t\t(locale, settings) =>\n\t\t\t\t\tnumberFormat(new Intl.NumberFormat(locale, settings)),\n\t\t\t);\n\t\t\tconst number = formatter(count);\n\t\t\tconst parts = form.split(\"#\");\n\t\t\trefuseLength(\n\t\t\t\trun,\n\t\t\t\tform.length + (parts.length - 1) * (number.length - 1),\n\t\t\t\t\"plural\",\n\t\t\t);\n\t\t\treturn parts.join(number);\n\t\t},\n\t\t[\"one\", \"other\", \"zero\", \"two\", \"few\", \"many\"],\n\t\ttrue,\n\t),\n\tformatDate: define(\n\t\t(run, value, options) => {\n\t\t\tconst formatter = cachedFormatter(\n\t\t\t\t\"date\",\n\t\t\t\trun,\n\t\t\t\toptions,\n\t\t\t\tDATE_OPTIONS,\n\t\t\t\t(settings) => ({\n\t\t\t\t\ttimeZone: run.state.timeZone,\n\t\t\t\t\t...(Object.keys(settings).some((key) => DATE_STYLE_OPTIONS.has(key))\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { dateStyle: \"medium\" }),\n\t\t\t\t}),\n\t\t\t\t(locale, resolved) =>\n\t\t\t\t\tdateFormat(new Intl.DateTimeFormat(locale, resolved)),\n\t\t\t);\n\t\t\tif (value === null || value === undefined) return \"\";\n\t\t\treturn formatter(toTime(value, '\"formatDate\"'));\n\t\t},\n\t\t[],\n\t\ttrue,\n\t),\n};\n","import { analyzeTemplate, childStatements, type Reads } from \"./analyzer.js\";\nimport { createDiagnostic, type Diagnostic } from \"./errors.js\";\nimport { resolveTemplateName } from \"./names.js\";\nimport type { Expression, HashEntry, Statement } from \"./parser/ast.js\";\nimport type {\n\tCompiledTemplate,\n\tEnvironmentCore,\n\tScope,\n} from \"./runtime/types.js\";\nimport { describeType, describeValue, matchesType } from \"./runtime/values.js\";\nimport type { Span } from \"./source.js\";\nimport { suggest } from \"./suggest.js\";\n\ntype Property = Extract<HashEntry, { type: \"Property\" }>;\ntype PropsNode = Extract<Statement, { type: \"Props\" }>;\n\n/** A template's `props` tag, or null when it has none. */\nconst propsOf = (template: CompiledTemplate): PropsNode | null => {\n\tfor (const node of template.ast.body) {\n\t\tif (node.type === \"Props\") return node;\n\t}\n\treturn null;\n};\n\n/** Variables a template sets at its top level. A child template's run before its layout. */\nconst setsOf = (template: CompiledTemplate): string[] =>\n\ttemplate.ast.body.flatMap((node) =>\n\t\tnode.type === \"Set\" || node.type === \"SetBlock\" ? [node.name] : [],\n\t);\n\n/** The resolved name of a template written as a plain string, or null when it is built at render time. */\nconst literalName = (expression: Expression, from: string): string | null => {\n\tif (expression.type !== \"Literal\" || typeof expression.value !== \"string\") {\n\t\treturn null;\n\t}\n\ttry {\n\t\treturn resolveTemplateName(expression.value, from);\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/** The keys a `with` passes, by name. Null when they can't be known, such as `with data` or a spread. */\nconst passedKeys = (\n\texpression: Expression | null,\n): Map<string, Property> | null => {\n\tconst keys = new Map<string, Property>();\n\tif (expression === null) return keys;\n\tif (expression.type !== \"Hash\") return null;\n\tfor (const entry of expression.entries) {\n\t\tif (\n\t\t\tentry.type !== \"Property\" ||\n\t\t\tentry.key.type !== \"Literal\" ||\n\t\t\ttypeof entry.key.value !== \"string\"\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tkeys.set(entry.key.value, entry);\n\t}\n\treturn keys;\n};\n\nconst withHint = (message: string, hint: string | undefined) =>\n\thint ? `${message}. ${hint}` : message;\n\n/**\n * Checks a template against the templates it names, for `check`. Never renders.\n *\n * - Reports templates that don't exist.\n * - In strict mode, compares `include` and `component` calls, and a page's layouts, with the `props` they declare.\n * - In strict mode, warns about variables a template with `props` reads without declaring.\n */\nexport const checkReferences = async (\n\tenv: EnvironmentCore & { readonly globals: Scope },\n\ttemplate: CompiledTemplate,\n): Promise<Diagnostic[]> => {\n\tconst diagnostics: Diagnostic[] = [];\n\tconst report = (\n\t\tcode: string,\n\t\tmessage: string,\n\t\tspan: Span,\n\t\tseverity: Diagnostic[\"severity\"] = \"error\",\n\t) => {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic(template.source, code, message, span, severity),\n\t\t);\n\t};\n\tconst ownProps = propsOf(template);\n\n\t/** Loads a named template, reporting it when it doesn't exist. */\n\tconst use = async (name: string, span: Span, optional = false) => {\n\t\tconst used = await env.load(name);\n\t\tif (!used && !optional) {\n\t\t\treport(\"missing-template\", `Template \"${name}\" was not found`, span);\n\t\t}\n\t\treturn used;\n\t};\n\n\tconst call = async (\n\t\tnode: Extract<Statement, { type: \"Include\" | \"Component\" | \"Island\" }>,\n\t) => {\n\t\tconst name = literalName(node.template, template.name);\n\t\tif (!name) return;\n\t\tconst used = await use(\n\t\t\tname,\n\t\t\tnode.template.span,\n\t\t\tnode.type === \"Include\" && node.ignoreMissing,\n\t\t);\n\t\tif (!used || used.hasErrors || !env.strict) return;\n\t\tconst tag = propsOf(used);\n\t\tconst passed = passedKeys(node.with);\n\t\tif (!tag || !passed) return;\n\n\t\tconst props = tag.props;\n\t\tconst declared = props.map((prop) => prop.name);\n\t\tfor (const [key, entry] of passed) {\n\t\t\t// A rest prop accepts any key.\n\t\t\tif (tag.rest !== null || key === \"slots\" || declared.includes(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treport(\n\t\t\t\t\"unknown-prop\",\n\t\t\t\twithHint(\n\t\t\t\t\t`\"${key}\" was passed to ${name}, which does not declare it in \"props\"`,\n\t\t\t\t\tsuggest(key, declared),\n\t\t\t\t),\n\t\t\t\tentry.key.span,\n\t\t\t);\n\t\t}\n\t\tfor (const prop of props) {\n\t\t\tconst value = passed.get(prop.name)?.value;\n\t\t\tif (!value) {\n\t\t\t\tif (!prop.default) {\n\t\t\t\t\treport(\n\t\t\t\t\t\t\"missing-prop\",\n\t\t\t\t\t\t`Required prop \"${prop.name}\" was not passed to ${name}`,\n\t\t\t\t\t\tnode.template.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Null uses the default, which the template's own check covers.\n\t\t\tif (\n\t\t\t\t!prop.type ||\n\t\t\t\tvalue.type !== \"Literal\" ||\n\t\t\t\t(value.value === null && prop.default)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!matchesType(value.value, prop.type, env.types)) {\n\t\t\t\treport(\n\t\t\t\t\t\"prop-type\",\n\t\t\t\t\t`Prop \"${prop.name}\" of ${name} must be ${describeType(prop.type)}, but got ${describeValue(value.value, prop.type)}`,\n\t\t\t\t\tvalue.span,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n\n\t// A page with `props` accepts only those, so its layouts can only get props it declares or sets. With a rest prop\n\t// it accepts anything, so they can get any prop.\n\tconst layouts = async (node: Extract<Statement, { type: \"Extends\" }>) => {\n\t\tlet name = literalName(node.template, template.name);\n\t\tif (!name) return;\n\t\tlet layout = await use(name, node.template.span);\n\t\tif (!ownProps || ownProps.rest !== null || !env.strict) return;\n\t\tconst provided = new Set([\n\t\t\t...ownProps.props.map((prop) => prop.name),\n\t\t\t...setsOf(template),\n\t\t]);\n\t\tconst seen = new Set([template.name]);\n\t\twhile (layout && !layout.hasErrors && !seen.has(layout.name)) {\n\t\t\tseen.add(layout.name);\n\t\t\tfor (const prop of propsOf(layout)?.props ?? []) {\n\t\t\t\tif (!prop.default && !provided.has(prop.name)) {\n\t\t\t\t\treport(\n\t\t\t\t\t\t\"missing-prop\",\n\t\t\t\t\t\t`${name} needs prop \"${prop.name}\", which ${template.name} does not declare in \"props\" or set`,\n\t\t\t\t\t\tnode.template.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprovided.add(prop.name);\n\t\t\t}\n\t\t\tfor (const set of setsOf(layout)) provided.add(set);\n\t\t\tconst parent = layout.ast.body.find((child) => child.type === \"Extends\");\n\t\t\tname = parent ? literalName(parent.template, layout.name) : null;\n\t\t\tlayout = name ? await env.load(name) : null;\n\t\t}\n\t};\n\n\tconst visit = async (list: Statement[]): Promise<void> => {\n\t\tfor (const node of list) {\n\t\t\tif (\n\t\t\t\tnode.type === \"Include\" ||\n\t\t\t\tnode.type === \"Component\" ||\n\t\t\t\tnode.type === \"Island\"\n\t\t\t) {\n\t\t\t\tawait call(node);\n\t\t\t} else if (node.type === \"Extends\") await layouts(node);\n\t\t\tfor (const children of childStatements(node)) await visit(children);\n\t\t}\n\t};\n\n\tfor (const imported of template.imports)\n\t\tawait use(imported.name, imported.span);\n\tawait visit(template.ast.body);\n\n\tif (ownProps && env.strict) {\n\t\tconst reads: Reads = { context: new Map(), macros: new Map() };\n\t\tanalyzeTemplate(template, env.globals, reads);\n\t\tconst declared = ownProps.props.map((prop) => prop.name);\n\t\tfor (const [name, span] of reads.context) {\n\t\t\treport(\n\t\t\t\t\"undeclared-variable\",\n\t\t\t\twithHint(\n\t\t\t\t\t`\"${name}\" is not a prop, a global or a variable set in this template`,\n\t\t\t\t\tsuggest(name, declared),\n\t\t\t\t),\n\t\t\t\tspan,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t}\n\t\t// A macro only sees its parameters and globals.\n\t\tfor (const [name, span] of reads.macros) {\n\t\t\treport(\n\t\t\t\t\"undeclared-variable\",\n\t\t\t\t`\"${name}\" is not a parameter of its macro or a global`,\n\t\t\t\tspan,\n\t\t\t\t\"warning\",\n\t\t\t);\n\t\t}\n\t}\n\treturn diagnostics;\n};\n","import type { IslandEntry, JsonValue } from \"./islands.js\";\nimport type { Addition } from \"./outlets.js\";\nimport { isPlainObject } from \"./values.js\";\n\n/*\n * The value the `cache` tag gives a store to save. It is Kiln's own string, so what a saved copy holds can change\n * without stores changing: the HTML, what the section added to outlets, the islands it deferred, and whether it holds\n * the `<kiln-island>` script. A value from another version of the format reads as missing, so the section renders\n * again and the copy is replaced.\n */\n\nconst VERSION = 3;\n\nexport type Saved = {\n\thtml: string;\n\tadditions: Addition[];\n\tislands: IslandEntry[];\n\tislandScript: boolean;\n\t/** The section's tags, which a section around it gets when it uses this copy. */\n\ttags: string[];\n};\n\n/** Makes the value a store saves. */\nexport const packSaved = ({\n\thtml,\n\tadditions,\n\tislands,\n\tislandScript,\n\ttags,\n}: Saved): string =>\n\tJSON.stringify({\n\t\tv: VERSION,\n\t\thtml,\n\t\tadd: additions.map((addition) => [\n\t\t\taddition.outlet,\n\t\t\taddition.html,\n\t\t\taddition.once,\n\t\t]),\n\t\tisl: islands.map((island) => [island.template, island.props]),\n\t\tscr: islandScript,\n\t\ttag: tags,\n\t});\n\n/** Reads a value a store returned, or returns null when it isn't one `packSaved` made. */\nexport const unpackSaved = (value: string): Saved | null => {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(value);\n\t} catch {\n\t\treturn null;\n\t}\n\tif (typeof parsed !== \"object\" || parsed === null) return null;\n\tconst { v, html, add, isl, scr, tag } = parsed as Record<string, unknown>;\n\tif (\n\t\tv !== VERSION ||\n\t\ttypeof html !== \"string\" ||\n\t\t!Array.isArray(add) ||\n\t\t!Array.isArray(isl) ||\n\t\ttypeof scr !== \"boolean\" ||\n\t\t!Array.isArray(tag) ||\n\t\ttag.some((item) => typeof item !== \"string\")\n\t) {\n\t\treturn null;\n\t}\n\tconst additions: Addition[] = [];\n\tfor (const item of add) {\n\t\tif (!Array.isArray(item)) return null;\n\t\tconst [outlet, text, once] = item as unknown[];\n\t\tif (\n\t\t\ttypeof outlet !== \"string\" ||\n\t\t\ttypeof text !== \"string\" ||\n\t\t\t(once !== null && typeof once !== \"string\")\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tadditions.push({ outlet, html: text, once });\n\t}\n\tconst islands: IslandEntry[] = [];\n\tfor (const item of isl) {\n\t\tif (!Array.isArray(item)) return null;\n\t\tconst [template, props] = item as unknown[];\n\t\tif (typeof template !== \"string\" || !isPlainObject(props)) return null;\n\t\t// Parsed JSON holds only JSON values.\n\t\tislands.push({ template, props: props as Record<string, JsonValue> });\n\t}\n\treturn {\n\t\thtml,\n\t\tadditions,\n\t\tislands,\n\t\tislandScript: scr,\n\t\ttags: tag as string[],\n\t};\n};\n","import type { Span } from \"../source.js\";\nimport { BLOCKED_NAMES } from \"./exposure.js\";\nimport { Markup } from \"./markup.js\";\nimport { closeOutlets, takeOutput } from \"./outlets.js\";\nimport {\n\taddSlotFlags,\n\tconsumeAt,\n\tfail,\n\tmarkCaller,\n\trenderTemplate,\n} from \"./render.js\";\nimport { childScope } from \"./scope.js\";\nimport {\n\ttype CompiledTemplate,\n\temptyOut,\n\tRenderState,\n\ttype Run,\n} from \"./types.js\";\nimport { isPlainObject, typeName } from \"./values.js\";\n\n/*\n * Server islands.\n *\n * An island renders in place unless the render has an `islands` option. Either way the island writes a `<kiln-island>`\n * element holding its fallback:\n *\n * - `deferIslands(…)` records its template and props in the manifest under an id made from both. The host serves each\n * id by rendering the manifest entry with `render`, and the element fetches that HTML.\n * - `streamIslands()` renders the island on its own while the page carries on, and `renderStream` sends its HTML after\n * the page, in a `<template>` followed by a `<kiln-island fill>` that moves it into place.\n */\n\n/** A value that survives JSON unchanged, which is what island props must be. */\nexport type JsonValue =\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| JsonValue[]\n\t| { [key: string]: JsonValue };\n\n/** One deferred island: the template to render and the props to render it with. */\nexport type IslandEntry = {\n\ttemplate: string;\n\tprops: Record<string, JsonValue>;\n};\n\n/** Every island deferred in a build, by id. Hosts save it as JSON and look ids up in it. */\nexport type IslandManifest = Record<string, IslandEntry>;\n\n/** The `islands` render option for static builds. Make it with `deferIslands`, and pass it to every render in a build. */\nexport type DeferredIslands = {\n\treadonly mode: \"defer\";\n\t/** The text before each island's id in its `src`, such as `\"/_islands/\"`. */\n\treadonly url: string;\n\t/** Whether Kiln writes the `<kiln-island>` script before the first island of each render. */\n\treadonly script: boolean;\n\t/** Every island deferred so far, by id. */\n\treadonly manifest: IslandManifest;\n};\n\n/**\n * Defers `island` tags in the renders it is passed to, recording each island in `manifest`.\n *\n * ```ts\n * const islands = deferIslands({ url: \"/_islands/\" });\n * const html = await kiln.render(\"pages/product\", { product }, { islands });\n * await writeFile(\"build/islands.json\", JSON.stringify(islands.manifest));\n * ```\n */\nexport const deferIslands = ({\n\turl,\n\tscript = true,\n}: {\n\turl: string;\n\tscript?: boolean;\n}): DeferredIslands => {\n\tif (typeof url !== \"string\") {\n\t\tthrow new TypeError(\"deferIslands needs a url\");\n\t}\n\treturn { mode: \"defer\", url, script, manifest: {} };\n};\n\n/** The `islands` render option for `renderStream`. Make it with `streamIslands`. */\nexport type StreamedIslands = {\n\treadonly mode: \"stream\";\n\t/** Whether Kiln writes the `<kiln-island>` script before the first island of each render. */\n\treadonly script: boolean;\n};\n\n/**\n * Streams `island` tags in `renderStream`: the page is sent with each island's fallback, and each island's HTML follows\n * when it is ready. `render` and `renderBlock` can't stream, so they render islands in place.\n *\n * ```ts\n * const stream = await kiln.renderStream(\"pages/product\", { product }, { islands: streamIslands() });\n * ```\n */\nexport const streamIslands = ({\n\tscript = true,\n}: {\n\tscript?: boolean;\n} = {}): StreamedIslands => ({ mode: \"stream\", script });\n\n/** How a render treats `island` tags, when it doesn't render them in place. */\nexport type IslandMode = DeferredIslands | StreamedIslands;\n\n/**\n * The source of the script that defines `<kiln-island>`. Serve it as a file when a Content Security Policy blocks\n * inline scripts, with `script: false`.\n *\n * - A deferred island's element fetches its `src`, and replaces itself with the response when it succeeds and is HTML.\n * - A streamed island's HTML arrives in a `<template>`, followed by `<kiln-island fill=\"n\">`, which moves it in place of\n * `<kiln-island stream=\"n\">` once the template is parsed.\n *\n * Otherwise the fallback stays. Kept short and plain, since it is written into pages.\n */\nexport const islandScript =\n\t'customElements.get(\"kiln-island\")||customElements.define(\"kiln-island\",class extends HTMLElement{connectedCallback(){if(this.k)return;this.k=1;this.style.display=\"contents\";const p=h=>document.createRange().createContextualFragment(h),f=this.getAttribute(\"fill\"),s=this.getAttribute(\"src\");if(f){const t=this.previousElementSibling,e=document.querySelector(`kiln-island[stream=\"${f}\"]`);if(e&&t&&t.localName==\"template\")e.replaceWith(p(t.innerHTML)),t.remove();this.remove()}else if(s)fetch(s).then(r=>r.ok&&/^text\\\\/html/.test(r.headers.get(\"content-type\"))?r.text():null).then(h=>{if(h!=null)this.replaceWith(p(h))},()=>{})}});';\n\n/**\n * Copies an island's props as JSON values, or fails naming the first value that isn't one. Hashes may be maps, and\n * become plain objects.\n */\nexport const islandProps = (\n\trun: Run,\n\tspan: Span,\n\tvalue: unknown,\n): Record<string, JsonValue> => {\n\tconst seen = new Set<object>();\n\tconst invalid = (path: string, problem: string) =>\n\t\tfail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"type-error\",\n\t\t\t`\"island\" props must be JSON values: null, booleans, numbers, strings, lists and hashes, but ${path === \"\" ? \"they are\" : `\"${path}\" is`} ${problem}`,\n\t\t);\n\t// Each list and hash is charged before it is copied, so props that share one object in many places can't make\n\t// unlimited work.\n\tconst charge = (count: number) => consumeAt(run, span, count);\n\tconst copyHash = (\n\t\thash: Record<string, unknown> | Map<unknown, unknown>,\n\t\tpath: string,\n\t): Record<string, JsonValue> => {\n\t\tconst result: Record<string, JsonValue> = {};\n\t\tconst entries = hash instanceof Map ? [...hash] : Object.entries(hash);\n\t\tcharge(entries.length);\n\t\tfor (const [key, item] of entries) {\n\t\t\tif (typeof key !== \"string\") {\n\t\t\t\tthrow invalid(path, \"a hash with a key that isn't a string\");\n\t\t\t}\n\t\t\tif (BLOCKED_NAMES.has(key)) continue;\n\t\t\tresult[key] = copy(item, path === \"\" ? key : `${path}.${key}`);\n\t\t}\n\t\treturn result;\n\t};\n\tconst copy = (item: unknown, path: string): JsonValue => {\n\t\tif (item === null || item === undefined) return null;\n\t\tif (typeof item === \"string\" || typeof item === \"boolean\") return item;\n\t\tif (typeof item === \"number\") {\n\t\t\tif (Number.isFinite(item)) return item;\n\t\t\tthrow invalid(path, String(item));\n\t\t}\n\t\tif (item instanceof Markup) {\n\t\t\tthrow invalid(\n\t\t\t\tpath,\n\t\t\t\t\"markup. Pass the data, and build the markup in the island\",\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!Array.isArray(item) &&\n\t\t\t!(item instanceof Map) &&\n\t\t\t!isPlainObject(item)\n\t\t) {\n\t\t\tthrow invalid(path, `a ${typeName(item)}`);\n\t\t}\n\t\tif (seen.has(item)) throw invalid(path, \"a value that contains itself\");\n\t\tseen.add(item);\n\t\tif (Array.isArray(item)) charge(item.length);\n\t\tconst result = Array.isArray(item)\n\t\t\t? item.map((entry, index) => copy(entry, `${path}[${index}]`))\n\t\t\t: copyHash(item, path);\n\t\tseen.delete(item);\n\t\treturn result;\n\t};\n\tif (value === null || value === undefined) return {};\n\tif (!(value instanceof Map) && !isPlainObject(value)) {\n\t\tthrow invalid(\"\", `a ${typeName(value)}, not a hash`);\n\t}\n\treturn copyHash(value, \"\");\n};\n\n/** A 64-bit hash of `text` as 16 hex digits: two 32-bit multiply-xor lanes, mixed together at the end. */\nconst hashId = (text: string): string => {\n\tlet a = 0x811c9dc5;\n\tlet b = 0x9e3779b9;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\ta = Math.imul(a ^ code, 0x01000193);\n\t\tb = Math.imul(b ^ code, 0x5bd1e995);\n\t}\n\ta = Math.imul(a ^ (b >>> 15), 0x85ebca6b);\n\tb = Math.imul(b ^ (a >>> 13), 0xc2b2ae35);\n\ta ^= b >>> 16;\n\tb ^= a >>> 16;\n\treturn (\n\t\t(a >>> 0).toString(16).padStart(8, \"0\") +\n\t\t(b >>> 0).toString(16).padStart(8, \"0\")\n\t);\n};\n\n/**\n * Records an island in the manifest and returns its id. The id comes from the template and props, so it is the same\n * on every page and in every build, and a page cached from an earlier build never asks for a different island.\n */\nexport const recordIsland = (\n\trun: Run,\n\tspan: Span,\n\tislands: DeferredIslands,\n\ttemplate: string,\n\tprops: Record<string, JsonValue>,\n): string => {\n\tconst key = JSON.stringify([template, props]);\n\tconst id = hashId(key);\n\tconst { manifest } = islands;\n\tconst existing = Object.hasOwn(manifest, id) ? manifest[id] : undefined;\n\tif (existing === undefined) manifest[id] = { template, props };\n\telse if (JSON.stringify([existing.template, existing.props]) !== key) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"island-collision\",\n\t\t\t`Two different islands have the id \"${id}\". Change one island's props slightly`,\n\t\t);\n\t}\n\t// A cached section saves the islands it deferred.\n\trun.capture?.section?.deferred.push(id);\n\treturn id;\n};\n\n/**\n * Starts rendering a streamed island on its own, with a render state of its own and the page's state, locale and\n * limits, as the host would render a deferred one. Returns its HTML wrapped to fill `<kiln-island stream=\"n\">`.\n *\n * The island's steps count against the page's, and its depth starts at the island tag's, so streaming does no more\n * work than rendering the island in place.\n */\nexport const streamIsland = (\n\trun: Run,\n\tspan: Span,\n\ttemplate: CompiledTemplate,\n\tprops: Record<string, JsonValue>,\n\tn: number,\n): Promise<string> => {\n\tconst page = run.state;\n\tconst state = new RenderState(\n\t\tpage.env,\n\t\tpage.globals,\n\t\tpage.maxSteps,\n\t\tpage.maxSize,\n\t\tpage.maxDepth,\n\t\tpage.locale,\n\t\tpage.timeZone,\n\t\tpage.userState,\n\t\tpage.signal,\n\t);\n\t// Islands run alongside the page and each other, so they share its counter rather than copying it.\n\tObject.defineProperty(state, \"steps\", {\n\t\tget: () => page.steps,\n\t\tset: (steps: number) => {\n\t\t\tpage.steps = steps;\n\t\t},\n\t});\n\tconst scope = childScope(page.globals);\n\tconst passed = Object.keys(props);\n\tfor (const key of passed) scope[key] = props[key] ?? null;\n\taddSlotFlags(scope, template, null);\n\tconst out = emptyOut();\n\tstate.root = out;\n\treturn Promise.resolve()\n\t\t.then(() =>\n\t\t\trenderTemplate(\n\t\t\t\tstate,\n\t\t\t\ttemplate,\n\t\t\t\tscope,\n\t\t\t\tout,\n\t\t\t\trun.depth + 1,\n\t\t\t\tnull,\n\t\t\t\tpassed,\n\t\t\t\tnull,\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t),\n\t\t)\n\t\t.then(\n\t\t\t() => {\n\t\t\t\t// The signal may have been aborted while the island's last call was pending.\n\t\t\t\tif (state.signal?.aborted) {\n\t\t\t\t\tthrow fail(run, span, \"aborted\", \"Render was aborted\");\n\t\t\t\t}\n\t\t\t\tcloseOutlets(state);\n\t\t\t\treturn `<template>${takeOutput(state, out.s)}</template><kiln-island fill=\"${n}\"></kiln-island>`;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t},\n\t\t);\n};\n\nexport const ISLAND_CLOSING = \"</kiln-island>\";\n\nexport const ISLAND_SCRIPT = `<script>${islandScript}</script>`;\n","import type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport { Markup } from \"./markup.js\";\nimport {\n\tafter,\n\tfail,\n\timportsFor,\n\tisPromise,\n\tstep,\n\tunhold,\n\twithCaller,\n} from \"./render.js\";\nimport { childScope } from \"./scope.js\";\nimport {\n\ttype CompiledMacro,\n\temptyOut,\n\tendCapture,\n\tRun,\n\tstartCapture,\n} from \"./types.js\";\n\n/**\n * Calls a macro: binds arguments to parameters in a scope that holds only globals, renders the body and returns it as markup.\n */\nexport const callMacro = (\n\trun: Run,\n\tspan: Span,\n\tmacro: CompiledMacro,\n\tpositional: readonly unknown[],\n\tnamed: Readonly<Record<string, unknown>> | null,\n): Markup | Promise<Markup> => {\n\tstep(run, span);\n\tconst state = run.state;\n\tif (run.depth + 1 > state.maxDepth) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-depth\",\n\t\t\t`Render stopped after nesting ${state.maxDepth} templates, macros or layouts deep`,\n\t\t);\n\t}\n\n\tconst params = macro.params;\n\tif (positional.length > params.length) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"too-many-arguments\",\n\t\t\t`Macro \"${macro.name}\" takes ${params.length} ${params.length === 1 ? \"argument\" : \"arguments\"}, but got ${positional.length}`,\n\t\t);\n\t}\n\tif (named) {\n\t\tfor (const key of Object.keys(named)) {\n\t\t\tconst index = params.findIndex((param) => param.name === key);\n\t\t\tif (index !== -1 && index < positional.length) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"duplicate-argument\",\n\t\t\t\t\t`Macro \"${macro.name}\" got \"${key}\" both by position and by name`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (index === -1) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"unknown-argument\",\n\t\t\t\t\t`Macro \"${macro.name}\" has no parameter \"${key}\"`,\n\t\t\t\t\tsuggest(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tparams.map((param) => param.name),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// A capture of its own, since a macro can render alongside other expressions while promises are pending.\n\tconst capture = startCapture(run);\n\tconst macroRun = new Run(\n\t\tstate,\n\t\tmacro.template,\n\t\trun.depth + 1,\n\t\tnull,\n\t\tnull,\n\t\tcapture,\n\t\trun.blockDepth,\n\t);\n\tconst scope = childScope(state.globals);\n\n\tconst bind = (index: number): void | Promise<void> => {\n\t\tfor (let i = index; i < params.length; i++) {\n\t\t\tconst param = params[i] as CompiledMacro[\"params\"][number];\n\t\t\tlet value: unknown =\n\t\t\t\ti < positional.length\n\t\t\t\t\t? positional[i]\n\t\t\t\t\t: named && Object.hasOwn(named, param.name)\n\t\t\t\t\t\t? named[param.name]\n\t\t\t\t\t\t: undefined;\n\t\t\tif ((value === undefined || value === null) && param.default) {\n\t\t\t\tvalue = param.default.ev(macroRun, scope);\n\t\t\t\tif (param.default.async && isPromise(value)) {\n\t\t\t\t\treturn value.then((resolved) => {\n\t\t\t\t\t\tscope[param.name] = unhold(resolved) ?? null;\n\t\t\t\t\t\treturn bind(i + 1);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tscope[param.name] = value ?? null;\n\t\t}\n\t};\n\n\treturn after(importsFor(macroRun, macro.template), (imports) => {\n\t\tmacroRun.imports = imports;\n\t\treturn after(bind(0), () => {\n\t\t\tconst out = emptyOut();\n\t\t\tconst render = () =>\n\t\t\t\tafter(macro.body(macroRun, scope, out), () => {\n\t\t\t\t\tendCapture(run, capture);\n\t\t\t\t\treturn new Markup(out.s, macro.strategy || \"html\");\n\t\t\t\t});\n\t\t\t// A macro from another template records where it was called.\n\t\t\treturn macro.template === run.template\n\t\t\t\t? render()\n\t\t\t\t: withCaller(run, span, render);\n\t\t});\n\t});\n};\n","import {\n\tall,\n\thold,\n\tholdData,\n\tisPromise,\n\tsilence,\n\tunhold,\n} from \"../runtime/render.js\";\nimport type { Compiled, Run, Scope } from \"../runtime/types.js\";\n\n/*\n * Only a compiled expression marked `async` may return a promise to wait for. Any other promise is a value from your\n * data, which is never waited for, so it is held when it has to pass through a promise. See `holdData`.\n */\n\n/** A compiled literal. */\nexport const constant = (value: unknown): Compiled => ({\n\tev: () => value,\n\tasync: false,\n\tconstant: { value },\n});\n\n/**\n * Compiles `f(a)`. The sync version never checks for promises, so expressions without async calls stay fast.\n *\n * `async` says whether `f` itself may return a promise. If it does, a value from your data that `f` returns as it is\n * must go through `passData`.\n */\nexport const map1 = (\n\ta: Compiled,\n\tf: (value: unknown, run: Run, scope: Scope) => unknown,\n\tasync = false,\n): Compiled => {\n\tconst ev = a.ev;\n\tif (!a.async) {\n\t\treturn { ev: (run, scope) => f(ev(run, scope), run, scope), async };\n\t}\n\tconst keep = async ? hold : holdData;\n\treturn {\n\t\tev: (run, scope) => {\n\t\t\tconst value = ev(run, scope);\n\t\t\treturn isPromise(value)\n\t\t\t\t? value.then((resolved) => keep(f(unhold(resolved), run, scope)))\n\t\t\t\t: f(value, run, scope);\n\t\t},\n\t\tasync: true,\n\t};\n};\n\n/** Compiles `f(a, b)`. Both sides start before either is awaited. */\nexport const map2 = (\n\ta: Compiled,\n\tb: Compiled,\n\tf: (left: unknown, right: unknown, run: Run, scope: Scope) => unknown,\n\tasync = false,\n): Compiled => {\n\tconst left = a.ev;\n\tconst right = b.ev;\n\tif (!a.async && !b.async) {\n\t\treturn {\n\t\t\tev: (run, scope) => f(left(run, scope), right(run, scope), run, scope),\n\t\t\tasync,\n\t\t};\n\t}\n\tconst leftAsync = a.async;\n\tconst rightAsync = b.async;\n\tconst keep = async ? hold : holdData;\n\treturn {\n\t\tev: (run, scope) => {\n\t\t\tconst l = left(run, scope);\n\t\t\tlet r: unknown;\n\t\t\ttry {\n\t\t\t\tr = right(run, scope);\n\t\t\t} catch (error) {\n\t\t\t\tif (leftAsync) silence(l);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif ((leftAsync && isPromise(l)) || (rightAsync && isPromise(r))) {\n\t\t\t\treturn all([\n\t\t\t\t\tleftAsync ? l : holdData(l),\n\t\t\t\t\trightAsync ? r : holdData(r),\n\t\t\t\t]).then(([lv, rv]) => keep(f(lv, rv, run, scope)));\n\t\t\t}\n\t\t\treturn f(l, r, run, scope);\n\t\t},\n\t\tasync: true,\n\t};\n};\n\n/** Evaluates a list of expressions in order. Returns a promise only if one that may wait returned one. */\nexport const evalAll = (\n\tlist: readonly Compiled[],\n): ((run: Run, scope: Scope) => unknown[] | Promise<unknown[]>) => {\n\tconst evs = list.map((item) => item.ev);\n\tconst count = evs.length;\n\tif (count === 0) return () => [];\n\tif (!list.some((item) => item.async)) {\n\t\treturn (run, scope) => {\n\t\t\t// oxlint-disable-next-line unicorn/no-new-array -- preallocates a known length on the hot path\n\t\t\tconst values = new Array<unknown>(count);\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tvalues[i] = (evs[i] as Compiled[\"ev\"])(run, scope);\n\t\t\t}\n\t\t\treturn values;\n\t\t};\n\t}\n\tconst asyncAt = list.map((item) => item.async);\n\treturn (run, scope) => {\n\t\t// oxlint-disable-next-line unicorn/no-new-array -- preallocates a known length on the hot path\n\t\tconst values = new Array<unknown>(count);\n\t\tlet pending = false;\n\t\ttry {\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tconst value = (evs[i] as Compiled[\"ev\"])(run, scope);\n\t\t\t\tvalues[i] = value;\n\t\t\t\tif (asyncAt[i] && isPromise(value)) pending = true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (let i = 0; i < count; i++) if (asyncAt[i]) silence(values[i]);\n\t\t\tthrow error;\n\t\t}\n\t\tif (!pending) return values;\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tif (!asyncAt[i]) values[i] = holdData(values[i]);\n\t\t}\n\t\treturn all(values);\n\t};\n};\n","import type { Statement } from \"../parser/ast.js\";\nimport type { Plan } from \"../runtime/ahead.js\";\nimport type { EnvironmentCore } from \"../runtime/types.js\";\n\n/**\n * What statements may do to the variables around them, and whether they may wait for a promise, found from their\n * syntax. Kiln uses it to start the statements after one that waits straight away, when they don't depend on it; see\n * `runtime/ahead.ts`.\n */\nexport type Effects = {\n\t/** Variables the statements may read, or null when they may read any, as content from elsewhere may. */\n\treadonly reads: ReadonlySet<string> | null;\n\t/** Variables the statements set themselves. */\n\treadonly sets: ReadonlySet<string>;\n\t/**\n\t * They place content from elsewhere: a block, whose content may come from another template, `block()`, `parent()`\n\t * or a slot, whose content comes from the caller. It reads any variable, and when it sets variables itself, it may\n\t * set any that exists. See `contentSets`.\n\t */\n\treadonly elsewhere: boolean;\n\t/** Whether the statements may wait for a promise. */\n\treadonly waits: boolean;\n};\n\n/** Tags that load another template or call your code, so they may wait. */\nconst LOADS = new Set([\n\t\"Include\",\n\t\"Component\",\n\t\"Island\",\n\t\"Slot\",\n\t\"Block\",\n\t\"Cache\",\n\t\"Extends\",\n]);\n\n/** The effects of statements, at any depth. Macros and imports do nothing where they stand. */\nexport const effectsOf = (\n\tstatements: readonly Statement[],\n\tenv: EnvironmentCore,\n): Effects => {\n\tconst reads = new Set<string>();\n\tconst sets = new Set<string>();\n\tlet elsewhere = false;\n\tlet waits = false;\n\t// Iterative, because long expression chains can be thousands of levels deep.\n\tconst stack: object[] = [statements];\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop() as object;\n\t\tif (Array.isArray(current)) {\n\t\t\tfor (const item of current as unknown[]) {\n\t\t\t\tif (typeof item === \"object\" && item !== null) stack.push(item);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst node = current as Record<string, unknown> & { type?: string };\n\t\tswitch (node.type) {\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Import\":\n\t\t\tcase \"FromImport\":\n\t\t\t\tcontinue;\n\t\t\tcase \"Name\":\n\t\t\t\treads.add(node.name as string);\n\t\t\t\tbreak;\n\t\t\tcase \"Set\":\n\t\t\tcase \"SetBlock\":\n\t\t\t\tsets.add(node.name as string);\n\t\t\t\tbreak;\n\t\t\tcase \"Props\": {\n\t\t\t\tfor (const prop of node.props as { name: string }[])\n\t\t\t\t\tsets.add(prop.name);\n\t\t\t\tif (node.rest !== null) sets.add(node.rest as string);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Block\":\n\t\t\tcase \"Slot\":\n\t\t\t\telsewhere = true;\n\t\t\t\tbreak;\n\t\t\tcase \"Call\": {\n\t\t\t\tconst callee = node.callee as { type: string; name?: string };\n\t\t\t\tif (callee.type !== \"Name\") waits = true;\n\t\t\t\telse if (callee.name === \"block\" || callee.name === \"parent\") {\n\t\t\t\t\telsewhere = true;\n\t\t\t\t\twaits = true;\n\t\t\t\t} else if (\n\t\t\t\t\tenv.functions.get(callee.name as string)?.kind !== \"builtin\"\n\t\t\t\t) {\n\t\t\t\t\t// One of your functions, or a macro.\n\t\t\t\t\twaits = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"Filter\":\n\t\t\t\tif (env.filters.get(node.name as string)?.kind === \"host\") waits = true;\n\t\t\t\tbreak;\n\t\t\tcase \"Test\":\n\t\t\t\tif (env.tests.get(node.name as string)?.kind === \"host\") waits = true;\n\t\t\t\tbreak;\n\t\t\tcase \"Apply\":\n\t\t\t\tfor (const filter of node.filters as { name: string }[]) {\n\t\t\t\t\tif (env.filters.get(filter.name)?.kind === \"host\") waits = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tif (node.type !== undefined && LOADS.has(node.type)) waits = true;\n\t\tfor (const key in node) {\n\t\t\tif (key === \"span\" || key === \"nameSpan\") continue;\n\t\t\tconst value = node[key];\n\t\t\tif (typeof value === \"object\" && value !== null) stack.push(value);\n\t\t}\n\t}\n\treturn { reads: elsewhere ? null : reads, sets, elsewhere, waits };\n};\n\n/**\n * Whether variables `sets` may set touch `names`. Null stands for any variable: content from elsewhere may read any,\n * and may set any.\n */\nconst touches = (\n\tsets: ReadonlySet<string> | null,\n\tnames: ReadonlySet<string> | null,\n): boolean => {\n\tif (sets === null) return names === null || names.size > 0;\n\tif (sets.size === 0) return false;\n\tif (names === null) return true;\n\tfor (const name of sets) if (names.has(name)) return true;\n\treturn false;\n};\n\n/**\n * Whether two parts can run in either order: neither sets a variable the other reads or sets. With `strict`, content\n * from elsewhere counts as setting any variable.\n */\nexport const independent = (\n\ta: Effects,\n\tb: Effects,\n\tstrict: boolean,\n): boolean => {\n\tconst aSets = strict && a.elsewhere ? null : a.sets;\n\tconst bSets = strict && b.elsewhere ? null : b.sets;\n\treturn (\n\t\t!touches(aSets, b.reads) &&\n\t\t!touches(aSets, bSets) &&\n\t\t!touches(bSets, a.reads)\n\t);\n};\n\n/** Parts a waiting part looks past for ones that can start early. Compiling stays linear in long lists. */\nconst MAX_REACH = 256;\n\n/** Parts a waiting part may hold back to let the ones after them start early. */\nconst MAX_GROUP = 64;\n\nconst merge = (a: Effects, b: Effects): Effects => ({\n\treads:\n\t\ta.reads === null || b.reads === null\n\t\t\t? null\n\t\t\t: new Set([...a.reads, ...b.reads]),\n\tsets: new Set([...a.sets, ...b.sets]),\n\telsewhere: a.elsewhere || b.elsewhere,\n\twaits: a.waits || b.waits,\n});\n\n/**\n * The plan for a list of parts, from each part's effects. See `Plan`. With `strict`, content from elsewhere counts as\n * setting any variable, for renders where it may; see `contentSets`. For a part that waits, the parts held back are\n * the fewest that leave a part that waits among the independent parts after them: holding back one part more can only\n * help when a later part depends on it.\n */\nexport const planOf = (effects: readonly Effects[], strict: boolean): Plan => {\n\tconst after: number[] = [];\n\tconst reach: number[] = [];\n\teffects.forEach((part, index) => {\n\t\tafter.push(index);\n\t\treach.push(index);\n\t\tif (!part.waits) return;\n\t\tconst last = Math.min(effects.length - 1, index + MAX_REACH);\n\t\tconst most = Math.min(last - 1, index + MAX_GROUP);\n\t\tlet waiting = part;\n\t\tfor (let group = index; group <= most; group++) {\n\t\t\tif (group > index) waiting = merge(waiting, effects[group] as Effects);\n\t\t\tlet end = group;\n\t\t\tlet waits = false;\n\t\t\tfor (let next = group + 1; next <= last; next++) {\n\t\t\t\tconst ahead = effects[next] as Effects;\n\t\t\t\tif (!independent(waiting, ahead, strict)) break;\n\t\t\t\tend = next;\n\t\t\t\tif (ahead.waits) waits = true;\n\t\t\t}\n\t\t\tif (waits) {\n\t\t\t\tafter[index] = group;\n\t\t\t\treach[index] = end;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Everything after is independent, and none of it waits, so holding more back gains nothing.\n\t\t\tif (end === last) return;\n\t\t}\n\t});\n\treturn { after, reach };\n};\n","import {\n\tcreateDiagnostic,\n\ttype Diagnostic,\n\tKilnSyntaxError,\n} from \"../errors.js\";\nimport { resolveTemplateName } from \"../names.js\";\nimport {\n\ttype Argument,\n\tDEFAULT_SLOT,\n\tESCAPE_STRATEGIES,\n\ttype EscapeStrategy,\n\ttype Expression,\n\ttype FilterCall,\n\ttype HashEntry,\n\ttype PropType,\n\ttype Statement,\n\ttype TemplateNode,\n} from \"../parser/ast.js\";\nimport { parse } from \"../parser/parser.js\";\nimport { getAttr, getMethod, readableNames } from \"../runtime/access.js\";\nimport {\n\tatFront,\n\tcontentSets,\n\tisRoot,\n\tpassesAhead,\n\tpassesFrom,\n\trunSequence,\n\ttype Sequence,\n} from \"../runtime/ahead.js\";\nimport { packSaved, unpackSaved } from \"../runtime/cache.js\";\nimport { escapeHtml, escapeWith } from \"../runtime/escape.js\";\nimport {\n\tISLAND_CLOSING,\n\tISLAND_SCRIPT,\n\ttype IslandMode,\n\tislandProps,\n\ttype JsonValue,\n\trecordIsland,\n\tstreamIsland,\n} from \"../runtime/islands.js\";\nimport { callMacro } from \"../runtime/macros.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport {\n\tcontains,\n\toperatorFunction,\n\trangeOperator,\n} from \"../runtime/operators.js\";\nimport {\n\tadditionsIn,\n\tcheckLate,\n\tcloseOutlets,\n\trecordAddition,\n} from \"../runtime/outlets.js\";\nimport {\n\tafter,\n\tall,\n\tcheckLength,\n\tconsume,\n\tembed,\n\tfail,\n\tholdData,\n\tisPromise,\n\tloadTemplate,\n\tlocate,\n\tlocating,\n\tmarkCaller,\n\tpassData,\n\tsilence,\n\tstep,\n\tunhold,\n\twithCaller,\n\twrite,\n} from \"../runtime/render.js\";\nimport {\n\tchildScope,\n\tlookup,\n\townerOf,\n\tsectionCopy,\n\tsectionScope,\n\tvariableNames,\n} from \"../runtime/scope.js\";\nimport {\n\ttype BlockDef,\n\ttype Builtin,\n\tblockScope,\n\ttype Capture,\n\ttype CallableEntry,\n\ttype Compiled,\n\ttype CompiledMacro,\n\ttype CompiledTemplate,\n\ttype EnvironmentCore,\n\temptyOut,\n\tendCapture,\n\ttype Ev,\n\tfillScope,\n\ttype Out,\n\ttype PathStep,\n\ttype Run,\n\ttype Scope,\n\ttype SlotFill,\n\ttype Stmt,\n\tstartCapture,\n} from \"../runtime/types.js\";\nimport {\n\tBLOCKED_NAMES,\n\tdescribeType,\n\tdescribeValue,\n\thashKeys,\n\tisEmpty,\n\tisPlainObject,\n\tmapKeys,\n\tliteralOptions,\n\tMISSING,\n\tmatchesType,\n\tsetOwn,\n\ttemplateFunctions,\n\ttoNumber,\n\ttoStr,\n\ttruthy,\n\ttypeName,\n\tvalueLabel,\n} from \"../runtime/values.js\";\nimport { Source, type Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport { constant, evalAll, map1, map2 } from \"./combinators.js\";\nimport { type Effects, effectsOf, independent, planOf } from \"./effects.js\";\n\n/** Marks a short-circuited optional chain while it is being evaluated. */\nexport const SHORT: unique symbol = Symbol(\"kiln.short\");\n/** Scope key holding the captured body of an `apply` tag. Templates cannot name symbols. */\nconst CAPTURED: unique symbol = Symbol(\"kiln.captured\");\n\nconst NOOP: Stmt = () => {};\nconst NOTHING = (): void => {};\n\n/** JavaScript engines overflow the stack well before 100,000 arguments, so spreads into calls stop here. */\nconst MAX_ARGUMENTS = 10_000;\n\n/** Deepest expression the compiler accepts. Each level costs a few stack frames when compiling and rendering. */\nconst MAX_EXPRESSION_DEPTH = 1000;\n\nconst PROTO_KEY_MESSAGE = '\"__proto__\" cannot be used as a key';\n\nconst BUILTIN_CALLS = new Set([\"parent\", \"block\"]);\n\ntype ArgumentShape = { kind: Argument[\"type\"]; name: string };\n\ntype CompiledArguments = {\n\t/** Each argument, in order. */\n\tcompiled: Compiled[];\n\t/** Each argument's expression, in order. */\n\tevs: Ev[];\n\tvalues: (run: Run, scope: Scope) => unknown[] | Promise<unknown[]>;\n\tshapes: ArgumentShape[];\n\tasync: boolean;\n\tarrowAsync: boolean;\n};\n\n/**\n * Runs of statements a precompiled template generated, by the offset where each run's first statement starts. Each\n * replaces the statements from there to the one ending at `end`. See `precompiled.ts`.\n */\nexport type GeneratedRuns = ReadonlyMap<number, { end: number; run: Stmt }>;\n\n/**\n * Parses and compiles template source into closures. Problems are collected in `diagnostics`; the template renders\n * only when there are none. `generated` holds a precompiled template's generated statements.\n */\nexport const compileTemplate = (\n\tenv: EnvironmentCore,\n\tname: string,\n\ttext: string,\n\tgenerated?: GeneratedRuns,\n): CompiledTemplate => {\n\tconst source = new Source(name, text);\n\tconst { ast, problems } = parse(text, {\n\t\tisTest: (test) => env.tests.has(test),\n\t});\n\tconst diagnostics = problems.map((problem) =>\n\t\tcreateDiagnostic(source, problem.code, problem.message, problem.span),\n\t);\n\treturn new Compiler(env, source, ast, diagnostics, generated).compile();\n};\n\nconst makeEmitter =\n\t(strategy: EscapeStrategy | false) =>\n\t(value: unknown): string => {\n\t\tif (typeof value === \"string\") {\n\t\t\treturn strategy ? escapeWith(value, strategy) : value;\n\t\t}\n\t\tif (typeof value === \"number\") {\n\t\t\tconst text = String(value);\n\t\t\treturn strategy && strategy !== \"html\"\n\t\t\t\t? escapeWith(text, strategy)\n\t\t\t\t: text;\n\t\t}\n\t\tif (value instanceof Markup) {\n\t\t\t// Every strategy's output is also safe in HTML, so HTML output accepts any markup.\n\t\t\treturn !strategy || strategy === \"html\" || value.strategy === strategy\n\t\t\t\t? value.value\n\t\t\t\t: escapeWith(value.value, strategy);\n\t\t}\n\t\tconst text = toStr(value);\n\t\treturn strategy ? escapeWith(text, strategy) : text;\n\t};\n\nconst emitters = new Map<EscapeStrategy | false, (value: unknown) => string>();\n\n/** Prints a value with an escaping strategy, or none. One function per strategy, shared. */\nexport const emitter = (\n\tstrategy: EscapeStrategy | false,\n): ((value: unknown) => string) => {\n\tlet emit = emitters.get(strategy);\n\tif (!emit) {\n\t\temit = makeEmitter(strategy);\n\t\temitters.set(strategy, emit);\n\t}\n\treturn emit;\n};\n\n/** Text, or an output whose expression never waits, in a run that `printParts` prints. */\ntype Part =\n\t| { text: string; span: Span }\n\t| {\n\t\t\ttext: null;\n\t\t\tcompiled: Compiled;\n\t\t\tstrategy: EscapeStrategy | false;\n\t\t\tspan: Span;\n\t };\n\n/** How `printParts` evaluates an output: a variable and literal keys, a choice of two literals, or anything else. */\ntype Read = \"path\" | \"choice\" | \"other\";\n\n/**\n * Prints a run of text and outputs into one string, then writes it to the buffer once. Each output still counts a\n * step before it is evaluated, so limits stop the render at the same output.\n *\n * The commonest outputs are evaluated in place rather than through their compiled closures: variables with literal\n * keys, such as `{{ post.title }}`, read own properties of plain objects directly, and choices between two literals,\n * such as `{{ active ? \"on\" : \"off\" }}`, print text emitted when compiling. Anything unusual, such as a missing\n * variable, falls back to the full expression, so results and errors are the same.\n */\nconst printParts = (list: Part[]): Stmt => {\n\t// Neighbouring text, such as text around a tag that compiled to nothing, joins into one part.\n\tconst parts: Part[] = [];\n\tfor (const part of list) {\n\t\tconst last = parts.at(-1);\n\t\tif (part.text !== null && last && last.text !== null) {\n\t\t\tparts[parts.length - 1] = {\n\t\t\t\ttext: last.text + part.text,\n\t\t\t\tspan: { start: last.span.start, end: part.span.end },\n\t\t\t};\n\t\t} else parts.push(part);\n\t}\n\tconst first = parts[0] as Part;\n\tconst span = {\n\t\tstart: first.span.start,\n\t\tend: (parts.at(-1) as Part).span.end,\n\t};\n\tif (parts.length === 1 && first.text !== null) {\n\t\tconst text = first.text;\n\t\treturn (run, _scope, out) => {\n\t\t\twrite(run, out, text, span);\n\t\t};\n\t}\n\n\tconst count = parts.length;\n\tconst texts: (string | null)[] = [];\n\tconst reads: Read[] = [];\n\tconst evs: (Ev | null)[] = [];\n\tconst emits: (((value: unknown) => string) | null)[] = [];\n\tconst html: boolean[] = [];\n\tconst roots: (string | null)[] = [];\n\tconst paths: PathStep[][] = [];\n\tconst choices: [string, string][] = [];\n\tconst tests: (Ev | null)[] = [];\n\tconst spans: Span[] = [];\n\tfor (const part of parts) {\n\t\tconst output = part.text === null ? part : null;\n\t\tconst compiled = output?.compiled;\n\t\tconst emit = output ? emitter(output.strategy) : null;\n\t\tconst path = compiled?.path;\n\t\tconst root = compiled?.variable ?? path?.root.variable ?? null;\n\t\tconst choice = compiled?.choice ? emitChoice(compiled.choice, emit) : null;\n\t\ttexts.push(part.text);\n\t\treads.push(root !== null ? \"path\" : choice ? \"choice\" : \"other\");\n\t\tevs.push(compiled?.ev ?? null);\n\t\temits.push(emit);\n\t\thtml.push(output?.strategy === \"html\");\n\t\troots.push(root);\n\t\tpaths.push(path ? path.steps : NO_STEPS);\n\t\tchoices.push(choice ?? NO_CHOICE);\n\t\ttests.push(compiled?.choice?.test ?? null);\n\t\tspans.push(part.span);\n\t}\n\n\treturn (run, scope, out) => {\n\t\tlet text = \"\";\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tconst part = texts[i];\n\t\t\tif (part !== null) {\n\t\t\t\ttext += part;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst at = spans[i] as Span;\n\t\t\tstep(run, at);\n\t\t\tconst kind = reads[i];\n\t\t\tif (kind === \"choice\") {\n\t\t\t\tconst [yes, no] = choices[i] as [string, string];\n\t\t\t\ttext += truthy((tests[i] as Ev)(run, scope)) ? yes : no;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet value: unknown;\n\t\t\tif (kind === \"path\") {\n\t\t\t\tvalue = lookup(scope, roots[i] as string);\n\t\t\t\tif (value === undefined || typeof value === \"function\") {\n\t\t\t\t\tvalue = (evs[i] as Ev)(run, scope);\n\t\t\t\t} else {\n\t\t\t\t\tvalue = readKeys(run, value, paths[i] as PathStep[]);\n\t\t\t\t}\n\t\t\t} else value = (evs[i] as Ev)(run, scope);\n\t\t\tif (typeof value === \"string\" && html[i]) {\n\t\t\t\ttext += escapeHtml(value);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\ttext += (emits[i] as (value: unknown) => string)(value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, at, error);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Values can be long, so stop at the output limit before they make a string too long for JavaScript.\n\t\t\tif (text.length > run.state.maxSize) write(run, out, text, at);\n\t\t}\n\t\twrite(run, out, text, span);\n\t};\n};\n\nconst NO_STEPS: PathStep[] = [];\nconst NO_CHOICE: [string, string] = [\"\", \"\"];\n\n/** Emits both branches of a choice when compiling, or returns null when emitting one fails, so it fails at render. */\nconst emitChoice = (\n\tchoice: NonNullable<Compiled[\"choice\"]>,\n\temit: ((value: unknown) => string) | null,\n): [string, string] | null => {\n\tif (!emit) return null;\n\ttry {\n\t\treturn [emit(choice.yes), emit(choice.no)];\n\t} catch {\n\t\treturn null;\n\t}\n};\n\n/**\n * Reads literal keys one after another. Own properties of plain objects are read inline, and everything else goes\n * through each step's full `read`, so the result is the same as reading one key at a time.\n */\nconst readKeys = (\n\trun: Run,\n\ttarget: unknown,\n\tsteps: readonly PathStep[],\n): unknown => {\n\tlet value = target;\n\tlet i = 0;\n\ttry {\n\t\tfor (; i < steps.length; i++) {\n\t\t\tconst step = steps[i] as PathStep;\n\t\t\tconst name = step.name;\n\t\t\tif (name !== null && typeof value === \"object\" && value !== null) {\n\t\t\t\tconst proto = Object.getPrototypeOf(value);\n\t\t\t\tif (proto === Object.prototype || proto === null) {\n\t\t\t\t\tconst item = (value as Record<string, unknown>)[name];\n\t\t\t\t\tif (\n\t\t\t\t\t\titem !== undefined &&\n\t\t\t\t\t\ttypeof item !== \"function\" &&\n\t\t\t\t\t\tObject.hasOwn(value, name)\n\t\t\t\t\t) {\n\t\t\t\t\t\tvalue = item;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tvalue = step.read(run, value);\n\t\t}\n\t} catch (error) {\n\t\t// A getter in your data threw. Errors from the full reads are located already.\n\t\tconst step = steps[i] as PathStep;\n\t\tthrow locate(run, step.span, error, readingLabel(step.name ?? \"\"));\n\t}\n\treturn value;\n};\n\nconst isBlank = (statement: Statement) =>\n\tstatement.type === \"Text\" && statement.value.trim() === \"\";\n\n/** Whether statements may set a variable, at any depth. */\nexport const setsVariables = (statements: readonly Statement[]): boolean =>\n\tcontainsNode(\n\t\tstatements,\n\t\t(record) => record.type === \"Set\" || record.type === \"SetBlock\",\n\t);\n\n/**\n * Whether statements may set a variable, themselves or through content from elsewhere they place: a block, `block()`,\n * `parent()` or a slot. For a component's fills, whose content may then set any variable around the component.\n */\nexport const mayWrite = (statements: readonly Statement[]): boolean =>\n\tcontainsNode(\n\t\tstatements,\n\t\t(record) =>\n\t\t\trecord.type === \"Set\" ||\n\t\t\trecord.type === \"SetBlock\" ||\n\t\t\trecord.type === \"Block\" ||\n\t\t\trecord.type === \"Slot\" ||\n\t\t\t(record.type === \"Call\" &&\n\t\t\t\t(record.callee as { type?: string }).type === \"Name\" &&\n\t\t\t\tBUILTIN_CALLS.has((record.callee as { name: string }).name)),\n\t);\n\n/** Checks whether any node under `node` matches. */\nexport const containsNode = (\n\tnode: unknown,\n\tmatches: (record: Record<string, unknown>) => boolean,\n): boolean => {\n\t// Iterative, because long expression chains can be thousands of levels deep.\n\t// Only objects go on the stack: strings, numbers and spans hold no nodes.\n\tconst stack: object[] =\n\t\ttypeof node === \"object\" && node !== null ? [node] : [];\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop() as object;\n\t\tif (Array.isArray(current)) {\n\t\t\tfor (const item of current as unknown[]) {\n\t\t\t\tif (typeof item === \"object\" && item !== null) stack.push(item);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst record = current as Record<string, unknown>;\n\t\tif (matches(record)) return true;\n\t\tfor (const key in record) {\n\t\t\tif (key === \"span\" || key === \"nameSpan\") continue;\n\t\t\tconst value = record[key];\n\t\t\tif (typeof value === \"object\" && value !== null) stack.push(value);\n\t\t}\n\t}\n\treturn false;\n};\n\n/**\n * What a loop body does, found in one walk. `readsLoop`: it may read `loop`, so loops only build the `loop` hash when\n * needed. Blocks, `block()` and `parent()` count too, because another template's block can read the loop it is\n * placed in. `keepsScope`: it has\n * `set` or arrow functions, which can keep or change an iteration's scope.\n */\nconst scanLoopBody = (\n\tbody: Statement[],\n): { readsLoop: boolean; keepsScope: boolean } => {\n\tlet readsLoop = false;\n\tlet keepsScope = false;\n\tcontainsNode(body, (record) => {\n\t\tif (\n\t\t\t(record.type === \"Name\" && record.name === \"loop\") ||\n\t\t\trecord.type === \"Block\" ||\n\t\t\t(record.type === \"Call\" &&\n\t\t\t\t(record.callee as { type?: string; name?: string }).type === \"Name\" &&\n\t\t\t\t[\"block\", \"parent\"].includes(\n\t\t\t\t\t(record.callee as { name?: string }).name ?? \"\",\n\t\t\t\t))\n\t\t) {\n\t\t\treadsLoop = true;\n\t\t} else if (\n\t\t\trecord.type === \"Set\" ||\n\t\t\trecord.type === \"SetBlock\" ||\n\t\t\trecord.type === \"Arrow\"\n\t\t) {\n\t\t\tkeepsScope = true;\n\t\t}\n\t\treturn readsLoop && keepsScope;\n\t});\n\treturn { readsLoop, keepsScope };\n};\n\nclass Compiler {\n\treadonly #env: EnvironmentCore;\n\treadonly #source: Source;\n\treadonly #ast: TemplateNode;\n\treadonly #diagnostics: Diagnostic[];\n\treadonly #template: CompiledTemplate;\n\n\t#strategy: EscapeStrategy | false;\n\t/** The block being compiled, for `parent()`. */\n\t#blockName: string | null = null;\n\t#inMacro = false;\n\t#expressionDepth = 0;\n\treadonly #importAliases = new Map<string, number>();\n\treadonly #fromImports = new Map<string, { slot: number; name: string }>();\n\treadonly #generated: GeneratedRuns | undefined;\n\n\tconstructor(\n\t\tenv: EnvironmentCore,\n\t\tsource: Source,\n\t\tast: TemplateNode,\n\t\tdiagnostics: Diagnostic[],\n\t\tgenerated: GeneratedRuns | undefined,\n\t) {\n\t\tthis.#env = env;\n\t\tthis.#generated = generated;\n\t\tthis.#source = source;\n\t\tthis.#ast = ast;\n\t\tthis.#diagnostics = diagnostics;\n\t\tthis.#strategy = env.autoescape;\n\t\tconst template: CompiledTemplate = {\n\t\t\tname: source.name,\n\t\t\tsource,\n\t\t\tast,\n\t\t\tdiagnostics,\n\t\t\thasErrors: false,\n\t\t\tsyntaxError: () => new KilnSyntaxError(diagnostics, source),\n\t\t\tbody: NOOP,\n\t\t\tprops: null,\n\t\t\tparent: null,\n\t\t\tparentSpan: { start: 0, end: 0 },\n\t\t\tblocks: new Map(),\n\t\t\tblockList: undefined,\n\t\t\tmacros: new Map(),\n\t\t\timports: [],\n\t\t\tresolved: new Map(),\n\t\t\tkeyed: undefined,\n\t\t\tslotNames: [],\n\t\t\tplain: false,\n\t\t\ttop: null,\n\t\t\tearly: null,\n\t\t};\n\t\tthis.#template = template;\n\t}\n\n\tcompile(): CompiledTemplate {\n\t\tconst template = this.#template;\n\t\tconst body = this.#ast.body;\n\n\t\tthis.#collectNames(body);\n\t\tthis.#collectMacros(body);\n\n\t\tconst first = body.find((statement) => !isBlank(statement));\n\t\tconst extendsNode = first?.type === \"Extends\" ? first : null;\n\t\tthis.#checkPlacement(body, extendsNode !== null);\n\n\t\tif (extendsNode) {\n\t\t\ttemplate.parent = this.#expr(extendsNode.template);\n\t\t\ttemplate.parentSpan = extendsNode.span;\n\t\t\tconst statements: Stmt[] = [];\n\t\t\tconst ranges: number[] = [];\n\t\t\tbody.forEach((statement, index) => {\n\t\t\t\tif (\n\t\t\t\t\tstatement.type === \"Set\" ||\n\t\t\t\t\tstatement.type === \"SetBlock\" ||\n\t\t\t\t\tstatement.type === \"Props\"\n\t\t\t\t) {\n\t\t\t\t\tstatements.push(this.#statement(statement));\n\t\t\t\t\tranges.push(index, index + 1);\n\t\t\t\t} else if (statement.type === \"Block\") {\n\t\t\t\t\tthis.#defineBlock(statement);\n\t\t\t\t}\n\t\t\t});\n\t\t\ttemplate.body = this.#sequence(statements, body, ranges, true);\n\t\t\ttemplate.early = this.#early(body, extendsNode);\n\t\t} else {\n\t\t\ttemplate.body = this.#body(body, true);\n\t\t}\n\n\t\t// Lexer, parser and compiler problems are found in separate passes. Report them in source order.\n\t\tthis.#diagnostics.sort((a, b) => a.start.offset - b.start.offset);\n\t\ttemplate.hasErrors = this.#diagnostics.some((d) => d.severity === \"error\");\n\t\ttemplate.plain =\n\t\t\ttemplate.parent === null &&\n\t\t\ttemplate.blocks.size === 0 &&\n\t\t\ttemplate.imports.length === 0;\n\t\treturn template;\n\t}\n\n\t/**\n\t * What a page's top-level statements read and set, so its layout can start while they wait, or null when the name\n\t * of the layout depends on them. Found the first time they wait.\n\t */\n\t#early(body: Statement[], extendsNode: Statement): () => Effects | null {\n\t\tconst env = this.#env;\n\t\tlet found: Effects | null | undefined;\n\t\treturn () => {\n\t\t\tif (found === undefined) {\n\t\t\t\tconst top = effectsOf(\n\t\t\t\t\tbody.filter(\n\t\t\t\t\t\t(statement) =>\n\t\t\t\t\t\t\tstatement.type === \"Set\" ||\n\t\t\t\t\t\t\tstatement.type === \"SetBlock\" ||\n\t\t\t\t\t\t\tstatement.type === \"Props\",\n\t\t\t\t\t),\n\t\t\t\t\tenv,\n\t\t\t\t);\n\t\t\t\tfound = independent(top, effectsOf([extendsNode], env), false)\n\t\t\t\t\t? top\n\t\t\t\t\t: null;\n\t\t\t}\n\t\t\treturn found;\n\t\t};\n\t}\n\n\t// Diagnostics\n\n\t#error(code: string, message: string, span: Span): void {\n\t\tthis.#diagnostics.push(createDiagnostic(this.#source, code, message, span));\n\t}\n\n\t/** `__proto__` keys would hand host code an object that changes its own prototype when merged. */\n\t#protoKey(span: Span): void {\n\t\tthis.#error(\"invalid-key\", PROTO_KEY_MESSAGE, span);\n\t}\n\n\t/** A compiled expression for code that can never run, because compiling it reported an error. */\n\t#broken(): Compiled {\n\t\treturn constant(null);\n\t}\n\n\t// Pre-passes\n\n\t#walkStatements(\n\t\tstatements: Statement[],\n\t\tvisit: (statement: Statement) => void,\n\t): void {\n\t\tfor (const statement of statements) {\n\t\t\tvisit(statement);\n\t\t\tswitch (statement.type) {\n\t\t\t\tcase \"If\":\n\t\t\t\t\tfor (const branch of statement.branches) {\n\t\t\t\t\t\tthis.#walkStatements(branch.body, visit);\n\t\t\t\t\t}\n\t\t\t\t\tif (statement.alternate)\n\t\t\t\t\t\tthis.#walkStatements(statement.alternate, visit);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"For\":\n\t\t\t\t\tthis.#walkStatements(statement.body, visit);\n\t\t\t\t\tif (statement.alternate)\n\t\t\t\t\t\tthis.#walkStatements(statement.alternate, visit);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Component\":\n\t\t\t\t\tthis.#walkStatements(statement.body, visit);\n\t\t\t\t\tfor (const fill of statement.fills)\n\t\t\t\t\t\tthis.#walkStatements(fill.body, visit);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Island\":\n\t\t\t\tcase \"SetBlock\":\n\t\t\t\tcase \"Block\":\n\t\t\t\tcase \"Slot\":\n\t\t\t\tcase \"Macro\":\n\t\t\t\tcase \"Add\":\n\t\t\t\tcase \"Cache\":\n\t\t\t\tcase \"With\":\n\t\t\t\tcase \"Apply\":\n\t\t\t\tcase \"Autoescape\":\n\t\t\t\t\tthis.#walkStatements(statement.body, visit);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Collects what is visible everywhere in the file before compiling anything, in one walk: imports, slot names,\n\t * and block names, which must be unique.\n\t */\n\t#collectNames(body: Statement[]): void {\n\t\tconst template = this.#template;\n\t\tconst slotNames = new Set<string>();\n\t\tconst blockNames = new Set<string>();\n\t\tconst addImport = (name: string, span: Span): number => {\n\t\t\tlet resolved = name;\n\t\t\ttry {\n\t\t\t\tresolved = resolveTemplateName(name, template.name);\n\t\t\t} catch (error) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"invalid-template-name\",\n\t\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\ttemplate.imports.push({ name: resolved, span });\n\t\t\treturn template.imports.length - 1;\n\t\t};\n\n\t\tthis.#walkStatements(body, (statement) => {\n\t\t\tif (statement.type === \"Slot\") slotNames.add(statement.name);\n\t\t\telse if (statement.type === \"Block\") {\n\t\t\t\tif (blockNames.has(statement.name)) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"duplicate-block\",\n\t\t\t\t\t\t`Block \"${statement.name}\" is defined more than once`,\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tblockNames.add(statement.name);\n\t\t\t} else if (statement.type === \"Import\") {\n\t\t\t\tif (\n\t\t\t\t\tthis.#env.functions.has(statement.alias) ||\n\t\t\t\t\tBUILTIN_CALLS.has(statement.alias)\n\t\t\t\t) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t\t`Import alias \"${statement.alias}\" has the same name as a function. Choose another alias`,\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (this.#importAliases.has(statement.alias)) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"duplicate-import\",\n\t\t\t\t\t\t`\"${statement.alias}\" is imported more than once`,\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthis.#importAliases.set(\n\t\t\t\t\tstatement.alias,\n\t\t\t\t\taddImport(statement.template, statement.span),\n\t\t\t\t);\n\t\t\t} else if (statement.type === \"FromImport\") {\n\t\t\t\tconst slot = addImport(statement.template, statement.span);\n\t\t\t\tfor (const entry of statement.names) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.#env.functions.has(entry.alias) ||\n\t\t\t\t\t\tBUILTIN_CALLS.has(entry.alias)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t\t\t`Imported macro \"${entry.alias}\" has the same name as a function. Import it with \"as\" and another name`,\n\t\t\t\t\t\t\tentry.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.#fromImports.has(entry.alias)) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"duplicate-import\",\n\t\t\t\t\t\t\t`\"${entry.alias}\" is imported more than once`,\n\t\t\t\t\t\t\tentry.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthis.#fromImports.set(entry.alias, { slot, name: entry.name });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\ttemplate.slotNames = [...slotNames];\n\t}\n\n\t#collectMacros(body: Statement[]): void {\n\t\tconst macros = this.#template.macros;\n\t\tconst placeholders: {\n\t\t\tstatement: Extract<Statement, { type: \"Macro\" }>;\n\t\t\tmacro: CompiledMacro;\n\t\t}[] = [];\n\t\tfor (const statement of body) {\n\t\t\tif (statement.type !== \"Macro\" || statement.name === \"\") continue;\n\t\t\tif (macros.has(statement.name)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"duplicate-macro\",\n\t\t\t\t\t`Macro \"${statement.name}\" is defined more than once`,\n\t\t\t\t\tstatement.span,\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.#env.functions.has(statement.name) ||\n\t\t\t\tBUILTIN_CALLS.has(statement.name)\n\t\t\t) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t`Macro \"${statement.name}\" has the same name as a function. Rename the macro`,\n\t\t\t\t\tstatement.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.#fromImports.has(statement.name)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"macro-conflict\",\n\t\t\t\t\t`Macro \"${statement.name}\" has the same name as an imported macro`,\n\t\t\t\t\tstatement.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst macro: CompiledMacro = {\n\t\t\t\tname: statement.name,\n\t\t\t\tparams: [],\n\t\t\t\tbody: NOOP,\n\t\t\t\tstrategy: this.#env.autoescape,\n\t\t\t\ttemplate: this.#template,\n\t\t\t};\n\t\t\tmacros.set(statement.name, macro);\n\t\t\tplaceholders.push({ statement, macro });\n\t\t}\n\n\t\t// Compile bodies after every name is known, so macros can call each other in any order.\n\t\tfor (const { statement, macro } of placeholders) {\n\t\t\tconst saved = { block: this.#blockName, inMacro: this.#inMacro };\n\t\t\tthis.#blockName = null;\n\t\t\tthis.#inMacro = true;\n\t\t\tmacro.params = statement.params.map((param) => ({\n\t\t\t\tname: param.name,\n\t\t\t\tdefault: param.default ? this.#expr(param.default) : null,\n\t\t\t}));\n\t\t\tmacro.body = this.#body(statement.body);\n\t\t\tthis.#blockName = saved.block;\n\t\t\tthis.#inMacro = saved.inMacro;\n\t\t}\n\t}\n\n\t/** Checks where tags may appear: `extends` first, child templates' top level, `props` and macros. */\n\t#checkPlacement(body: Statement[], isChild: boolean): void {\n\t\tlet seenContent = false;\n\t\tlet seenProps = false;\n\t\tlet onlyBlankBefore = true;\n\t\tfor (const statement of body) {\n\t\t\tconst isFirst = onlyBlankBefore;\n\t\t\tif (!isBlank(statement)) onlyBlankBefore = false;\n\t\t\tswitch (statement.type) {\n\t\t\t\tcase \"Extends\":\n\t\t\t\t\tif (!isFirst) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"extends-not-first\",\n\t\t\t\t\t\t\t'\"extends\" must be the first tag in the template',\n\t\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Props\":\n\t\t\t\t\tif (seenProps) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"duplicate-props\",\n\t\t\t\t\t\t\t'A template can only have one \"props\" tag',\n\t\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (seenContent) {\n\t\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\t\"props-not-first\",\n\t\t\t\t\t\t\t'\"props\" must come before any content',\n\t\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tseenProps = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Text\":\n\t\t\t\t\tif (!isBlank(statement)) seenContent = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Set\":\n\t\t\t\tcase \"SetBlock\":\n\t\t\t\tcase \"Import\":\n\t\t\t\tcase \"FromImport\":\n\t\t\t\tcase \"Macro\":\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tseenContent = true;\n\t\t\t}\n\n\t\t\tif (isChild) {\n\t\t\t\tconst allowed =\n\t\t\t\t\tstatement.type === \"Extends\" ||\n\t\t\t\t\tstatement.type === \"Block\" ||\n\t\t\t\t\tstatement.type === \"Set\" ||\n\t\t\t\t\tstatement.type === \"SetBlock\" ||\n\t\t\t\t\tstatement.type === \"Props\" ||\n\t\t\t\t\tstatement.type === \"Import\" ||\n\t\t\t\t\tstatement.type === \"FromImport\" ||\n\t\t\t\t\tstatement.type === \"Macro\" ||\n\t\t\t\t\tisBlank(statement);\n\t\t\t\tif (!allowed) {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"invalid-child-content\",\n\t\t\t\t\t\t'A template that uses \"extends\" can only contain blocks, \"set\", \"props\", \"import\", \"from\" and \"macro\" at its top level',\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst checkNested = (\n\t\t\tstatements: Statement[],\n\t\t\tdepth: number,\n\t\t\tinMacro: boolean,\n\t\t) => {\n\t\t\tfor (const statement of statements) {\n\t\t\t\tif (depth > 0 && statement.type === \"Macro\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"invalid-macro-placement\",\n\t\t\t\t\t\t\"Macros must be defined at the top level of a template\",\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (depth > 0 && statement.type === \"Extends\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"extends-not-first\",\n\t\t\t\t\t\t'\"extends\" must be the first tag in the template',\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (depth > 0 && statement.type === \"Props\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"props-not-first\",\n\t\t\t\t\t\t'\"props\" must be at the top level of a template',\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (inMacro && statement.type === \"Block\") {\n\t\t\t\t\tthis.#error(\n\t\t\t\t\t\t\"invalid-block-placement\",\n\t\t\t\t\t\t\"Blocks cannot be defined inside macros\",\n\t\t\t\t\t\tstatement.span,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst nestedMacro = inMacro || statement.type === \"Macro\";\n\t\t\t\tthis.#walkChildren(statement, (children) =>\n\t\t\t\t\tcheckNested(children, depth + 1, nestedMacro),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tcheckNested(body, 0, false);\n\t}\n\n\t#walkChildren(\n\t\tstatement: Statement,\n\t\tvisit: (children: Statement[]) => void,\n\t): void {\n\t\tswitch (statement.type) {\n\t\t\tcase \"If\":\n\t\t\t\tfor (const branch of statement.branches) visit(branch.body);\n\t\t\t\tif (statement.alternate) visit(statement.alternate);\n\t\t\t\tbreak;\n\t\t\tcase \"For\":\n\t\t\t\tvisit(statement.body);\n\t\t\t\tif (statement.alternate) visit(statement.alternate);\n\t\t\t\tbreak;\n\t\t\tcase \"Component\":\n\t\t\t\tvisit(statement.body);\n\t\t\t\tfor (const fill of statement.fills) visit(fill.body);\n\t\t\t\tbreak;\n\t\t\tcase \"Island\":\n\t\t\tcase \"SetBlock\":\n\t\t\tcase \"Block\":\n\t\t\tcase \"Slot\":\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Add\":\n\t\t\tcase \"Cache\":\n\t\t\tcase \"With\":\n\t\t\tcase \"Apply\":\n\t\t\tcase \"Autoescape\":\n\t\t\t\tvisit(statement.body);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Statements\n\n\t/**\n\t * Statements in order. Statement `i` compiled from `source[ranges[2i]]` up to `source[ranges[2i + 1]]`, which\n\t * decide what may start early while it waits; see `runSequence`. They are only read the first time one waits. With\n\t * `top`, the sequence is the template's top level, kept so a page's top-level statements can gate it; see `Gate`.\n\t */\n\t#sequence(\n\t\tstatements: Stmt[],\n\t\tsource: readonly Statement[],\n\t\tranges: readonly number[],\n\t\ttop = false,\n\t): Stmt {\n\t\tconst list: Stmt[] = [];\n\t\tconst kept: number[] = [];\n\t\tstatements.forEach((statement, index) => {\n\t\t\tif (statement === NOOP) return;\n\t\t\tlist.push(statement);\n\t\t\tkept.push(ranges[2 * index] as number, ranges[2 * index + 1] as number);\n\t\t});\n\t\tif (list.length === 0) return NOOP;\n\t\tif (list.length === 1 && !top) return list[0] as Stmt;\n\t\tconst env = this.#env;\n\t\t// Effects and plans are only found the first time a statement waits. The strict plans are for renders whose\n\t\t// blocks or fills set variables; see `contentSets`. The gated plans count every statement as one that waits.\n\t\tlet effects: Effects[] | null = null;\n\t\tlet spans: Span[] = [];\n\t\tlet elsewhere = false;\n\t\tconst plans: (ReturnType<Sequence[\"plan\"]> | undefined)[] = [];\n\t\tconst effectsFor = (): Effects[] => {\n\t\t\tif (effects === null) {\n\t\t\t\tconst groups = list.map((_, i) =>\n\t\t\t\t\tsource.slice(kept[2 * i] as number, kept[2 * i + 1] as number),\n\t\t\t\t);\n\t\t\t\teffects = groups.map((group) => effectsOf(group, env));\n\t\t\t\tspans = groups.map((group) => ({\n\t\t\t\t\tstart: (group[0] as Statement).span.start,\n\t\t\t\t\tend: (group.at(-1) as Statement).span.end,\n\t\t\t\t}));\n\t\t\t\telsewhere = effects.some((part) => part.elsewhere);\n\t\t\t}\n\t\t\treturn effects;\n\t\t};\n\t\tconst sequence: Sequence = {\n\t\t\tstatements: list,\n\t\t\tplan: (run, gated) => {\n\t\t\t\tconst found = effectsFor();\n\t\t\t\tconst strict = elsewhere && contentSets(run);\n\t\t\t\tconst key = (strict ? 1 : 0) + (gated ? 2 : 0);\n\t\t\t\treturn (plans[key] ??= {\n\t\t\t\t\t...planOf(\n\t\t\t\t\t\tgated ? found.map((part) => ({ ...part, waits: true })) : found,\n\t\t\t\t\t\tstrict,\n\t\t\t\t\t),\n\t\t\t\t\tspans,\n\t\t\t\t});\n\t\t\t},\n\t\t\tclear: (run, index, other) =>\n\t\t\t\tindependent(effectsFor()[index] as Effects, other, contentSets(run)),\n\t\t};\n\t\tif (top) this.#template.top = sequence;\n\t\tif (list.length === 1) return list[0] as Stmt;\n\t\tconst last = list.length - 1;\n\t\treturn (run, scope, out) =>\n\t\t\trunSequence(sequence, 0, last, run, scope, out, null);\n\t}\n\n\t/**\n\t * Compiles statements in order. Runs of text and outputs that never wait become one statement, see `printParts`.\n\t * With `top`, they are the template's top level; see `#sequence`.\n\t */\n\t#body(statements: Statement[], top = false): Stmt {\n\t\tconst compiled: Stmt[] = [];\n\t\t// The statements each compiled statement covers, as start and end indexes into `statements`.\n\t\tconst ranges: number[] = [];\n\t\tlet parts: Part[] = [];\n\t\tlet partsStart = 0;\n\t\tconst flush = (end: number) => {\n\t\t\tif (parts.length > 0) {\n\t\t\t\tcompiled.push(printParts(parts));\n\t\t\t\tranges.push(partsStart, end);\n\t\t\t}\n\t\t\tparts = [];\n\t\t};\n\t\tfor (let i = 0; i < statements.length; i++) {\n\t\t\tconst statement = statements[i] as Statement;\n\t\t\tconst generated = this.#generated?.get(statement.span.start);\n\t\t\tif (generated) {\n\t\t\t\tconst last = statements.findIndex(\n\t\t\t\t\t(item, index) => index >= i && item.span.end === generated.end,\n\t\t\t\t);\n\t\t\t\tif (last !== -1) {\n\t\t\t\t\tflush(i);\n\t\t\t\t\tcompiled.push(generated.run);\n\t\t\t\t\tranges.push(i, last + 1);\n\t\t\t\t\tthis.#defineCovered(statements.slice(i, last + 1));\n\t\t\t\t\ti = last;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (statement.type === \"Text\") {\n\t\t\t\tif (parts.length === 0) partsStart = i;\n\t\t\t\tparts.push({ text: statement.value, span: statement.span });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (statement.type === \"Output\") {\n\t\t\t\tconst expression = this.#expr(statement.expression);\n\t\t\t\tif (!expression.async) {\n\t\t\t\t\tif (parts.length === 0) partsStart = i;\n\t\t\t\t\tparts.push({\n\t\t\t\t\t\ttext: null,\n\t\t\t\t\t\tcompiled: expression,\n\t\t\t\t\t\tstrategy: this.#strategy,\n\t\t\t\t\t\tspan: statement.span,\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tflush(i);\n\t\t\t\tcompiled.push(this.#output(expression, statement.span));\n\t\t\t\tranges.push(i, i + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tflush(i);\n\t\t\tcompiled.push(this.#statement(statement));\n\t\t\tranges.push(i, i + 1);\n\t\t}\n\t\tflush(statements.length);\n\t\treturn this.#sequence(compiled, statements, ranges, top);\n\t}\n\n\t/**\n\t * Blocks and `props` inside a generated run still need their definitions, which the closure compiler keeps: the\n\t * generated code only places blocks, and `renderBlock` runs `props` on its own.\n\t */\n\t#defineCovered(statements: Statement[]): void {\n\t\tfor (const statement of statements) {\n\t\t\tif (statement.type === \"Block\") this.#defineBlock(statement);\n\t\t\telse if (statement.type === \"Props\") this.#props(statement);\n\t\t\telse if (statement.type === \"Autoescape\") {\n\t\t\t\tconst saved = this.#strategy;\n\t\t\t\tthis.#strategy = statement.strategy;\n\t\t\t\tthis.#defineCovered(statement.body);\n\t\t\t\tthis.#strategy = saved;\n\t\t\t} else {\n\t\t\t\tthis.#walkChildren(statement, (children) =>\n\t\t\t\t\tthis.#defineCovered(children),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t#statement(node: Statement): Stmt {\n\t\tswitch (node.type) {\n\t\t\tcase \"Text\":\n\t\t\tcase \"Output\":\n\t\t\t\treturn this.#body([node]);\n\t\t\tcase \"If\":\n\t\t\t\treturn this.#if(node);\n\t\t\tcase \"For\":\n\t\t\t\treturn this.#for(node);\n\t\t\tcase \"Set\":\n\t\t\t\treturn this.#set(node.name, this.#expr(node.value), node.span);\n\t\t\tcase \"SetBlock\":\n\t\t\t\treturn this.#setBlock(node);\n\t\t\tcase \"Props\":\n\t\t\t\treturn this.#props(node);\n\t\t\tcase \"Extends\":\n\t\t\t\t// Handled by `compile`. A misplaced `extends` was already reported.\n\t\t\t\treturn NOOP;\n\t\t\tcase \"Block\":\n\t\t\t\treturn this.#blockStatement(node);\n\t\t\tcase \"Include\":\n\t\t\t\treturn this.#include(node);\n\t\t\tcase \"Component\":\n\t\t\t\treturn this.#component(node);\n\t\t\tcase \"Island\":\n\t\t\t\treturn this.#island(node);\n\t\t\tcase \"Slot\":\n\t\t\t\treturn this.#slot(node);\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Import\":\n\t\t\tcase \"FromImport\":\n\t\t\t\treturn NOOP;\n\t\t\tcase \"With\":\n\t\t\t\treturn this.#with(node);\n\t\t\tcase \"Cache\":\n\t\t\t\treturn this.#cache(node);\n\t\t\tcase \"Outlet\":\n\t\t\t\treturn this.#outlet(node);\n\t\t\tcase \"Flush\":\n\t\t\t\treturn this.#flush(node);\n\t\t\tcase \"Add\":\n\t\t\t\treturn this.#add(node);\n\t\t\tcase \"Apply\":\n\t\t\t\treturn this.#apply(node);\n\t\t\tcase \"Autoescape\": {\n\t\t\t\tconst saved = this.#strategy;\n\t\t\t\tthis.#strategy = node.strategy;\n\t\t\t\tconst body = this.#body(node.body);\n\t\t\t\tthis.#strategy = saved;\n\t\t\t\treturn body;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** An output whose expression may wait for a promise. Outputs that never wait are printed by `printParts`. */\n\t#output(compiled: Compiled, span: Span): Stmt {\n\t\tconst ev = compiled.ev;\n\t\tconst emit = emitter(this.#strategy);\n\t\tconst print = (run: Run, out: Out, value: unknown) => {\n\t\t\tlet text: string;\n\t\t\ttry {\n\t\t\t\ttext = emit(value);\n\t\t\t} catch (error) {\n\t\t\t\tthrow locate(run, span, error);\n\t\t\t}\n\t\t\twrite(run, out, text, span);\n\t\t};\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst value = ev(run, scope);\n\t\t\tif (isPromise(value)) {\n\t\t\t\treturn value.then((resolved) => print(run, out, unhold(resolved)));\n\t\t\t}\n\t\t\tprint(run, out, value);\n\t\t};\n\t}\n\n\t#if(node: Extract<Statement, { type: \"If\" }>): Stmt {\n\t\tconst branches = node.branches.map((branch) => {\n\t\t\tconst test = this.#expr(branch.test);\n\t\t\treturn {\n\t\t\t\ttest: test.ev,\n\t\t\t\tasync: test.async,\n\t\t\t\tbody: this.#body(branch.body),\n\t\t\t};\n\t\t});\n\t\tconst alternate = node.alternate ? this.#body(node.alternate) : null;\n\t\tconst span = node.span;\n\n\t\tconst from = (\n\t\t\tindex: number,\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t): void | Promise<void> => {\n\t\t\tfor (let i = index; i < branches.length; i++) {\n\t\t\t\tconst branch = branches[i] as (typeof branches)[number];\n\t\t\t\tconst value = branch.test(run, scope);\n\t\t\t\tif (branch.async && isPromise(value)) {\n\t\t\t\t\treturn value.then((resolved) =>\n\t\t\t\t\t\ttruthy(unhold(resolved))\n\t\t\t\t\t\t\t? branch.body(run, scope, out)\n\t\t\t\t\t\t\t: from(i + 1, run, scope, out),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (truthy(value)) return branch.body(run, scope, out);\n\t\t\t}\n\t\t\treturn alternate?.(run, scope, out);\n\t\t};\n\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn from(0, run, scope, out);\n\t\t};\n\t}\n\n\t#for(node: Extract<Statement, { type: \"For\" }>): Stmt {\n\t\tconst iterable = this.#expr(node.iterable);\n\t\tconst body = this.#body(node.body);\n\t\tconst alternate = node.alternate ? this.#body(node.alternate) : null;\n\t\tconst { keyName, valueName, span } = node;\n\t\tconst { readsLoop: usesLoop, keepsScope } = scanLoopBody(node.body);\n\t\t// Without `set` or arrow functions nothing can keep or change an iteration's scope, so one object serves every\n\t\t// iteration.\n\t\tconst shared = !keepsScope;\n\t\t// What the body sets, found the first time a pass waits. See `passesAhead`.\n\t\tlet effects: { sets: readonly string[]; elsewhere: boolean } | null = null;\n\t\tconst env = this.#env;\n\n\t\t/**\n\t\t * Runs passes `index` to `end`. When a pass waits, the passes after it run as `passesFrom` runs them: ahead of\n\t\t * it when they may. `ahead` is whether they may, found the first time a pass waits.\n\t\t */\n\t\tconst iterate = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t\tvalues: readonly unknown[],\n\t\t\tkeys: readonly unknown[] | null,\n\t\t\tindex: number,\n\t\t\tend: number,\n\t\t\treused: Scope | null,\n\t\t\tahead: boolean | null,\n\t\t): void | Promise<void> => {\n\t\t\tconst length = values.length;\n\t\t\tfor (let i = index; i < end; i++) {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst inner = reused ?? childScope(scope);\n\t\t\t\tinner[valueName] = values[i] ?? null;\n\t\t\t\tif (keyName !== null) inner[keyName] = keys ? (keys[i] ?? null) : i;\n\t\t\t\tif (usesLoop) {\n\t\t\t\t\t// A literal, so every `loop` hash shares one shape. Templates only read its own properties.\n\t\t\t\t\tinner.loop = {\n\t\t\t\t\t\tindex: i + 1,\n\t\t\t\t\t\tindex0: i,\n\t\t\t\t\t\trevIndex: length - i,\n\t\t\t\t\t\trevIndex0: length - i - 1,\n\t\t\t\t\t\tfirst: i === 0,\n\t\t\t\t\t\tlast: i === length - 1,\n\t\t\t\t\t\tlength,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tconst result = body(run, inner, out);\n\t\t\t\tif (result === undefined) continue;\n\t\t\t\tif (i + 1 >= end) return result;\n\t\t\t\tif (effects === null) {\n\t\t\t\t\tconst found = effectsOf(node.body, env);\n\t\t\t\t\teffects = { sets: [...found.sets], elsewhere: found.elsewhere };\n\t\t\t\t}\n\t\t\t\tconst may = (ahead ??= passesAhead(\n\t\t\t\t\trun,\n\t\t\t\t\tscope,\n\t\t\t\t\teffects.sets,\n\t\t\t\t\teffects.elsewhere,\n\t\t\t\t));\n\t\t\t\t// Each pass after it gets a scope of its own, since the waiting pass still uses this one.\n\t\t\t\treturn passesFrom(\n\t\t\t\t\trun,\n\t\t\t\t\tout,\n\t\t\t\t\tresult,\n\t\t\t\t\ti + 1,\n\t\t\t\t\tend,\n\t\t\t\t\t(aheadRun, aheadOut, at) =>\n\t\t\t\t\t\titerate(\n\t\t\t\t\t\t\taheadRun,\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\taheadOut,\n\t\t\t\t\t\t\tvalues,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tat,\n\t\t\t\t\t\t\tat + 1,\n\t\t\t\t\t\t\tshared ? childScope(scope) : null,\n\t\t\t\t\t\t\tmay,\n\t\t\t\t\t\t),\n\t\t\t\t\tspan,\n\t\t\t\t\tmay,\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst start = (run: Run, scope: Scope, out: Out, value: unknown) => {\n\t\t\tconst { values, keys } = loopItems(run, span, value, keyName !== null);\n\t\t\tif (values.length === 0) return alternate?.(run, scope, out);\n\t\t\tconst reused = shared ? childScope(scope) : null;\n\t\t\treturn iterate(\n\t\t\t\trun,\n\t\t\t\tscope,\n\t\t\t\tout,\n\t\t\t\tvalues,\n\t\t\t\tkeys,\n\t\t\t\t0,\n\t\t\t\tvalues.length,\n\t\t\t\treused,\n\t\t\t\tnull,\n\t\t\t);\n\t\t};\n\n\t\tconst ev = iterable.ev;\n\t\tif (!iterable.async) {\n\t\t\treturn (run, scope, out) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn start(run, scope, out, ev(run, scope));\n\t\t\t};\n\t\t}\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst value = ev(run, scope);\n\t\t\tif (isPromise(value)) {\n\t\t\t\treturn value.then((resolved) =>\n\t\t\t\t\tstart(run, scope, out, unhold(resolved)),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn start(run, scope, out, value);\n\t\t};\n\t}\n\n\t/** `set`. Only a value that may wait is waited for: a promise in your data is a value like any other. */\n\t#set(name: string, value: Compiled, span: Span): Stmt {\n\t\tconst ev = value.ev;\n\t\tif (!value.async) {\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tassign(run, scope, name, ev(run, scope), span);\n\t\t\t};\n\t\t}\n\t\treturn (run, scope) => {\n\t\t\tstep(run, span);\n\t\t\tconst result = ev(run, scope);\n\t\t\tif (isPromise(result)) {\n\t\t\t\treturn result.then((resolved) => {\n\t\t\t\t\tassign(run, scope, name, unhold(resolved), span);\n\t\t\t\t});\n\t\t\t}\n\t\t\tassign(run, scope, name, result, span);\n\t\t};\n\t}\n\n\t#setBlock(node: Extract<Statement, { type: \"SetBlock\" }>): Stmt {\n\t\tconst body = this.#body(node.body);\n\t\tconst strategy = this.#strategy || \"html\";\n\t\tconst { name, span } = node;\n\t\treturn (run, scope) => {\n\t\t\tstep(run, span);\n\t\t\tconst out = emptyOut();\n\t\t\tconst result = body(run, scope, out);\n\t\t\tconst finish = () =>\n\t\t\t\tassign(run, scope, name, new Markup(out.s, strategy), span);\n\t\t\tif (result !== undefined) return result.then(finish);\n\t\t\tfinish();\n\t\t};\n\t}\n\n\t#props(node: Extract<Statement, { type: \"Props\" }>): Stmt {\n\t\tconst types = this.#env.types;\n\t\tconst props = node.props.map((prop) => {\n\t\t\tif (prop.type) this.#checkTypeNames(prop.type, prop.span);\n\t\t\tconst compiled = prop.default ? this.#expr(prop.default) : null;\n\t\t\tif (\n\t\t\t\tprop.type &&\n\t\t\t\tprop.default &&\n\t\t\t\tcompiled?.constant &&\n\t\t\t\t!matchesType(compiled.constant.value, prop.type, types)\n\t\t\t) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"prop-type\",\n\t\t\t\t\t`The default for \"${prop.name}\" is ${describeValue(compiled.constant.value, prop.type)}, which is not ${describeType(prop.type)}`,\n\t\t\t\t\tprop.default.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { name: prop.name, type: prop.type, default: compiled };\n\t\t});\n\t\tconst declared = new Set(props.map((prop) => prop.name));\n\t\tconst strict = this.#env.strict;\n\t\tconst span = node.span;\n\t\tconst templateName = this.#template.name;\n\t\t// Types are only checked in strict mode. Lenient mode passes values through.\n\t\tconst typed = strict\n\t\t\t? props.flatMap(({ name, type }) => (type ? [{ name, type }] : []))\n\t\t\t: [];\n\n\t\tconst checkTypes = (run: Run, scope: Scope): void => {\n\t\t\tfor (const { name, type } of typed) {\n\t\t\t\tconst value = scope[name];\n\t\t\t\tif (!matchesType(value, type, types)) {\n\t\t\t\t\tthrow fail(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\"prop-type\",\n\t\t\t\t\t\t`Prop \"${name}\" of ${templateName} must be ${describeType(type)}, but got ${describeValue(value, type)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst fill = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tindex: number,\n\t\t): void | Promise<void> => {\n\t\t\tfor (let i = index; i < props.length; i++) {\n\t\t\t\tconst prop = props[i] as (typeof props)[number];\n\t\t\t\tconst has = Object.hasOwn(scope, prop.name);\n\t\t\t\tconst current = has ? scope[prop.name] : undefined;\n\t\t\t\tif (current !== undefined && current !== null) continue;\n\t\t\t\tif (prop.default) {\n\t\t\t\t\tconst value = prop.default.ev(run, scope);\n\t\t\t\t\tif (prop.default.async && isPromise(value)) {\n\t\t\t\t\t\treturn value.then((resolved) => {\n\t\t\t\t\t\t\tscope[prop.name] = unhold(resolved) ?? null;\n\t\t\t\t\t\t\treturn fill(run, scope, i + 1);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tscope[prop.name] = value ?? null;\n\t\t\t\t} else if (!has) {\n\t\t\t\t\tif (strict) {\n\t\t\t\t\t\tthrow fail(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\"missing-prop\",\n\t\t\t\t\t\t\t`Required prop \"${prop.name}\" was not passed to ${templateName}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tscope[prop.name] = null;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tconst rest = node.rest;\n\t\t// The variables passed but not declared, in the order they were passed. A layout's run has no `passed`.\n\t\tconst collect = (run: Run, scope: Scope): Record<string, unknown> => {\n\t\t\tconst extra: Record<string, unknown> = {};\n\t\t\tfor (const key of run.passed ?? []) {\n\t\t\t\tif (!declared.has(key) && key !== \"slots\") extra[key] = scope[key];\n\t\t\t}\n\t\t\treturn extra;\n\t\t};\n\n\t\tconst apply: Stmt = (run, scope) => {\n\t\t\tif (rest !== null) scope[rest] = collect(run, scope);\n\t\t\telse if (strict && run.passed) {\n\t\t\t\tfor (const key of run.passed) {\n\t\t\t\t\tif (!declared.has(key) && key !== \"slots\") {\n\t\t\t\t\t\tthrow fail(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\"unknown-prop\",\n\t\t\t\t\t\t\t`\"${key}\" was passed to ${templateName}, which does not declare it in \"props\"`,\n\t\t\t\t\t\t\tsuggest(key, declared),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typed.length === 0) return fill(run, scope, 0);\n\t\t\treturn after(fill(run, scope, 0), () => checkTypes(run, scope));\n\t\t};\n\t\t// `props` is only valid at the top level, once, so this is the template's own.\n\t\tthis.#template.props = apply;\n\t\treturn apply;\n\t}\n\n\t/** Reports host type names, such as `Post`, that the environment has no check for. */\n\t#checkTypeNames(type: readonly PropType[], span: Span): void {\n\t\tfor (const member of type) {\n\t\t\tif (typeof member === \"string\" || \"literal\" in member) continue;\n\t\t\tif (\"list\" in member) this.#checkTypeNames(member.list, span);\n\t\t\telse if (\"shape\" in member) {\n\t\t\t\tfor (const key of member.shape) this.#checkTypeNames(key.type, span);\n\t\t\t} else if (!this.#env.types.has(member.named)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"unknown-type\",\n\t\t\t\t\t`Unknown type \"${member.named}\". Register it with the \"types\" option`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t#defineBlock(node: Extract<Statement, { type: \"Block\" }>): void {\n\t\tconst saved = this.#blockName;\n\t\tthis.#blockName = node.name;\n\t\tconst def: BlockDef = {\n\t\t\tbody: this.#body(node.body),\n\t\t\tstrategy: this.#strategy,\n\t\t\tsets: setsVariables(node.body),\n\t\t};\n\t\tthis.#blockName = saved;\n\t\tthis.#template.blocks.set(node.name, def);\n\t}\n\n\t#blockStatement(node: Extract<Statement, { type: \"Block\" }>): Stmt {\n\t\tthis.#defineBlock(node);\n\t\tconst { name, span } = node;\n\t\treturn (run, scope, out) => {\n\t\t\tconst entry = run.blocks.get(name)?.[0];\n\t\t\tif (!entry) return;\n\t\t\t// The block renders in the capture it is placed in, such as a cached section.\n\t\t\tconst render = () =>\n\t\t\t\tentry.def.body(\n\t\t\t\t\tentry.run.within(run.capture, run.blockDepth),\n\t\t\t\t\tblockScope(entry.def, scope),\n\t\t\t\t\tout,\n\t\t\t\t);\n\t\t\t// A block defined in another template records where it was placed.\n\t\t\treturn entry.run.template === run.template\n\t\t\t\t? render()\n\t\t\t\t: withCaller(run, span, render);\n\t\t};\n\t}\n\n\t#include(node: Extract<Statement, { type: \"Include\" }>): Stmt {\n\t\tconst { ignoreMissing, span } = node;\n\t\treturn this.#embedding(\n\t\t\tnode.template,\n\t\t\tnode.with,\n\t\t\tspan,\n\t\t\t(run, out, name, variables) =>\n\t\t\t\tembed(run, out, span, name, variables, null, ignoreMissing),\n\t\t);\n\t}\n\n\t#component(node: Extract<Statement, { type: \"Component\" }>): Stmt {\n\t\tconst { span } = node;\n\t\tconst fills = node.fills.map((fill) => ({\n\t\t\tname: fill.name,\n\t\t\tbody: this.#body(fill.body),\n\t\t\tsets: mayWrite(fill.body),\n\t\t}));\n\t\tconst hasDefault = node.body.some((statement) => !isBlank(statement));\n\t\tif (hasDefault) {\n\t\t\tif (fills.some((fill) => fill.name === DEFAULT_SLOT)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"duplicate-fill\",\n\t\t\t\t\t'The default slot is filled both by \"fill\" and by content outside it',\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\tfills.push({\n\t\t\t\tname: DEFAULT_SLOT,\n\t\t\t\tbody: this.#body(node.body),\n\t\t\t\tsets: mayWrite(node.body),\n\t\t\t});\n\t\t}\n\t\treturn this.#embedding(\n\t\t\tnode.template,\n\t\t\tnode.with,\n\t\t\tspan,\n\t\t\t(run, out, name, variables, callerScope) => {\n\t\t\t\tconst slots = new Map<string, SlotFill>();\n\t\t\t\tfor (const fill of fills) {\n\t\t\t\t\tslots.set(fill.name, {\n\t\t\t\t\t\tbody: fill.body,\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tscope: callerScope,\n\t\t\t\t\t\tsets: fill.sets,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn embed(run, out, span, name, variables, slots, false);\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * `island`: renders its template in place, like a component without content, unless the render defers or streams\n\t * islands. Then it writes a `<kiln-island>` element around the fallback, standing on lines of its own where the tags\n\t * do. A deferred island is recorded in the manifest, and a streamed one starts rendering on its own.\n\t */\n\t#island(node: Extract<Statement, { type: \"Island\" }>): Stmt {\n\t\tconst { span, indent, closing } = node;\n\t\tconst fallback = this.#body(node.body);\n\t\tconst element = (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tscope: Scope,\n\t\t\tislands: IslandMode,\n\t\t\tattribute: string,\n\t\t): void | Promise<void> => {\n\t\t\tconst state = run.state;\n\t\t\tlet opening = `<kiln-island ${attribute}>`;\n\t\t\tif (islands.script && !state.islandScript) {\n\t\t\t\topening = ISLAND_SCRIPT + opening;\n\t\t\t\t// A capture may never be output, so an island in one brings its own script.\n\t\t\t\tif (isRoot(state, out)) state.islandScript = true;\n\t\t\t}\n\t\t\twrite(\n\t\t\t\trun,\n\t\t\t\tout,\n\t\t\t\tindent === undefined\n\t\t\t\t\t? opening\n\t\t\t\t\t: `${indent}${opening}${closing?.indent === null ? \"\" : \"\\n\"}`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t\treturn after(fallback(run, childScope(scope), out), () => {\n\t\t\t\tif (!closing) return write(run, out, ISLAND_CLOSING, span);\n\t\t\t\tconst start = closing.indent ?? \"\";\n\t\t\t\tconst end = closing.newline ? \"\\n\" : \"\";\n\t\t\t\treturn write(run, out, `${start}${ISLAND_CLOSING}${end}`, span);\n\t\t\t});\n\t\t};\n\t\tconst render = (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tscope: Scope,\n\t\t\tislands: IslandMode,\n\t\t\ttemplate: CompiledTemplate,\n\t\t\tprops: Record<string, JsonValue>,\n\t\t): void | Promise<void> => {\n\t\t\tif (islands.mode === \"defer\") {\n\t\t\t\tconst id = recordIsland(run, span, islands, template.name, props);\n\t\t\t\treturn element(\n\t\t\t\t\trun,\n\t\t\t\t\tout,\n\t\t\t\t\tscope,\n\t\t\t\t\tislands,\n\t\t\t\t\t`src=\"${escapeHtml(islands.url + id)}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst state = run.state;\n\t\t\tconst streamed = (state.streamed ??= []);\n\t\t\tconst n = streamed.length + 1;\n\t\t\tconst html = streamIsland(run, span, template, props, n);\n\t\t\tsilence(html);\n\t\t\tstreamed.push(html);\n\t\t\treturn element(run, out, scope, islands, `stream=\"${n}\"`);\n\t\t};\n\t\tconst place = (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tname: unknown,\n\t\t\tvariables: unknown,\n\t\t\tscope: Scope,\n\t\t): void | Promise<void> => {\n\t\t\tconst props = islandProps(run, span, variables);\n\t\t\tconst state = run.state;\n\t\t\tconst islands = state.islands;\n\t\t\t// Only `renderStream` streams, and only output that is sure to be sent once.\n\t\t\tconst away =\n\t\t\t\tislands !== null &&\n\t\t\t\t(islands.mode === \"defer\" ||\n\t\t\t\t\t(state.stream !== null &&\n\t\t\t\t\t\tisRoot(state, out) &&\n\t\t\t\t\t\t!run.capture?.section));\n\t\t\tif (away) {\n\t\t\t\treturn after(loadTemplate(run, name, span), (template) =>\n\t\t\t\t\ttemplate\n\t\t\t\t\t\t? render(run, out, scope, islands, template, props)\n\t\t\t\t\t\t: undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn embed(run, out, span, name, props, null, false);\n\t\t};\n\t\treturn this.#embedding(\n\t\t\tnode.template,\n\t\t\tnode.with,\n\t\t\tspan,\n\t\t\t(run, out, name, variables, scope) =>\n\t\t\t\t// Which island brings the script, and the order streamed islands are numbered in, follow the page, so an\n\t\t\t\t// island running ahead waits for the parts before it.\n\t\t\t\trun.state.islands === null\n\t\t\t\t\t? place(run, out, name, variables, scope)\n\t\t\t\t\t: atFront(run, () => place(run, out, name, variables, scope)),\n\t\t);\n\t}\n\n\t/**\n\t * Evaluates an include's or component's template name and `with` value, then renders it with `render`. Both are\n\t * evaluated before either is waited for.\n\t */\n\t#embedding(\n\t\ttemplateNode: Expression,\n\t\twithNode: Expression | null,\n\t\tspan: Span,\n\t\trender: (\n\t\t\trun: Run,\n\t\t\tout: Out,\n\t\t\tname: unknown,\n\t\t\tvariables: unknown,\n\t\t\tscope: Scope,\n\t\t) => void | Promise<void>,\n\t): Stmt {\n\t\tconst template = this.#expr(templateNode);\n\t\tconst withValue = withNode ? this.#expr(withNode) : constant(null);\n\t\tif (!template.async && !withValue.async) {\n\t\t\tconst name = template.ev;\n\t\t\tconst variables = withValue.ev;\n\t\t\treturn (run, scope, out) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn render(run, out, name(run, scope), variables(run, scope), scope);\n\t\t\t};\n\t\t}\n\t\tconst values = evalAll([template, withValue]);\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn after(values(run, scope), ([name, variables]) =>\n\t\t\t\trender(run, out, name, variables, scope),\n\t\t\t);\n\t\t};\n\t}\n\n\t#slot(node: Extract<Statement, { type: \"Slot\" }>): Stmt {\n\t\tconst fallback = this.#body(node.body);\n\t\tconst { name, span } = node;\n\t\treturn (run, scope, out) => {\n\t\t\tconst fill = run.slots?.get(name);\n\t\t\tif (!fill) return fallback(run, childScope(scope), out);\n\t\t\ttry {\n\t\t\t\t// The fill renders in the capture the slot is in, such as a cached section.\n\t\t\t\tconst result = fill.body(\n\t\t\t\t\tfill.run.within(run.capture, run.blockDepth),\n\t\t\t\t\tfillScope(fill, run),\n\t\t\t\t\tout,\n\t\t\t\t);\n\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t}\n\t\t};\n\t}\n\n\t#with(node: Extract<Statement, { type: \"With\" }>): Stmt {\n\t\tconst value = this.#expr(node.value);\n\t\tconst body = this.#body(node.body);\n\t\tconst span = node.span;\n\t\tconst enter = (run: Run, scope: Scope, out: Out, variables: unknown) => {\n\t\t\tconst inner = childScope(scope);\n\t\t\tif (isPlainObject(variables)) {\n\t\t\t\tfor (const key of hashKeys(variables))\n\t\t\t\t\tinner[key] = variables[key] ?? null;\n\t\t\t} else if (variables instanceof Map) {\n\t\t\t\tfor (const key of mapKeys(variables)) {\n\t\t\t\t\tinner[key] = variables.get(key) ?? null;\n\t\t\t\t}\n\t\t\t} else if (variables !== null && variables !== undefined) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"type-error\",\n\t\t\t\t\t`\"with\" needs a hash, but got a ${typeName(variables)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn body(run, inner, out);\n\t\t};\n\t\tconst ev = value.ev;\n\t\tif (!value.async) {\n\t\t\treturn (run, scope, out) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn enter(run, scope, out, ev(run, scope));\n\t\t\t};\n\t\t}\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn after(ev(run, scope), (variables) =>\n\t\t\t\tenter(run, scope, out, variables),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * `cache`: outputs the copy the environment's store saved under the key, or renders the body, outputs it and saves\n\t * it. The key and `for` are checked even without a store, so mistakes show up before a store is added.\n\t */\n\t#cache(node: Extract<Statement, { type: \"Cache\" }>): Stmt {\n\t\tconst key = this.#expr(node.key);\n\t\tconst seconds = node.seconds ? this.#expr(node.seconds) : null;\n\t\tconst body = this.#body(node.body);\n\t\tconst span = node.span;\n\t\tconst first = node.body[0];\n\t\tconst last = node.body.at(-1);\n\t\t// The section's content and escaping, so editing either gives the tag new keys, and tags with the same key in\n\t\t// one template only share copies when their content is the same.\n\t\tconst content = shortHash(\n\t\t\t`${this.#strategy}|${first && last ? this.#source.text.slice(first.span.start, last.span.end) : \"\"}`,\n\t\t);\n\t\tconst templateName = `${this.#template.name}|${content}`;\n\n\t\tconst part = (run: Run, value: unknown) => {\n\t\t\tif (value === null || value === undefined) return null;\n\t\t\tif (\n\t\t\t\ttypeof value === \"string\" ||\n\t\t\t\ttypeof value === \"number\" ||\n\t\t\t\ttypeof value === \"boolean\"\n\t\t\t) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (value instanceof Date && !Number.isNaN(value.getTime())) {\n\t\t\t\treturn value.toISOString();\n\t\t\t}\n\t\t\tif (value instanceof Markup) return value.value;\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"type-error\",\n\t\t\t\t`\"cache\" keys are made of strings, numbers, booleans, dates and null, but got a ${typeName(value)}`,\n\t\t\t);\n\t\t};\n\t\t// The template, the section's content, locale and time zone are part of every key, since the output depends on\n\t\t// them. So is how islands render, when they are deferred. Streamed islands render in place inside the section.\n\t\tconst fullKey = (run: Run, value: unknown) => {\n\t\t\tconst parts = Array.isArray(value)\n\t\t\t\t? value.map((item) => part(run, item))\n\t\t\t\t: [part(run, value)];\n\t\t\tconst { locale, timeZone, islands } = run.state;\n\t\t\tconst key = `${JSON.stringify(run.state.env.cacheNamespace)}|${templateName}|${locale}|${timeZone}|${JSON.stringify(parts)}`;\n\t\t\treturn islands?.mode === \"defer\"\n\t\t\t\t? `${key}|islands|${JSON.stringify([islands.url, islands.script])}`\n\t\t\t\t: key;\n\t\t};\n\t\tconst lifetime = (run: Run, value: unknown) => {\n\t\t\tif (value === null || value === undefined) return null;\n\t\t\tif (typeof value !== \"number\" || !(value > 0) || value === Infinity) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"invalid-argument\",\n\t\t\t\t\t`\"cache\" needs a number of seconds above 0 after \"for\", but got ${typeof value === \"number\" ? value : `a ${typeName(value)}`}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn value;\n\t\t};\n\n\t\tconst save = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t\tkeyValue: unknown,\n\t\t\tsecondsValue: unknown,\n\t\t): void | Promise<void> => {\n\t\t\tconst name = fullKey(run, keyValue);\n\t\t\tconst time = lifetime(run, secondsValue);\n\t\t\tconst state = run.state;\n\t\t\tconst store = state.env.cache;\n\t\t\t// The body sets variables in a section scope, so setting one never changes a variable outside. See `assign`.\n\t\t\t// It renders in a capture of its own, which keeps what it adds to outlets and the islands it defers.\n\t\t\tconst fresh = (): Capture | Promise<Capture> => {\n\t\t\t\tconst inner = sectionScope(scope);\n\t\t\t\tconst capture = startCapture(run, {\n\t\t\t\t\tscope: inner,\n\t\t\t\t\tdeferred: [],\n\t\t\t\t\ttags: new Set(),\n\t\t\t\t});\n\t\t\t\treturn after(body(run.within(capture), inner, out), () => {\n\t\t\t\t\tendCapture(run, capture);\n\t\t\t\t\treturn capture;\n\t\t\t\t});\n\t\t\t};\n\t\t\tif (!store) return after(fresh(), NOTHING);\n\t\t\tconst found = locating(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t() => store.get({ key: name }),\n\t\t\t\t\"The cache store\",\n\t\t\t);\n\t\t\treturn after(found, (value) => {\n\t\t\t\tconst saved = typeof value === \"string\" ? unpackSaved(value) : null;\n\t\t\t\tif (saved) {\n\t\t\t\t\t// The sections around this one depend on what it does.\n\t\t\t\t\tconst around = run.capture?.section;\n\t\t\t\t\tif (around) for (const tag of saved.tags) around.tags.add(tag);\n\t\t\t\t\tconst replay = (front: boolean) => {\n\t\t\t\t\t\tconst islands = state.islands;\n\t\t\t\t\t\tif (islands?.mode === \"defer\" && saved.islands.length > 0) {\n\t\t\t\t\t\t\t// The copy holds the island script only if it was the first in its render to need it.\n\t\t\t\t\t\t\tif (saved.islandScript) {\n\t\t\t\t\t\t\t\tif (isRoot(state, out)) state.islandScript = true;\n\t\t\t\t\t\t\t} else if (islands.script && !state.islandScript) {\n\t\t\t\t\t\t\t\twrite(run, out, ISLAND_SCRIPT, span);\n\t\t\t\t\t\t\t\tif (isRoot(state, out)) state.islandScript = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (const island of saved.islands) {\n\t\t\t\t\t\t\t\trecordIsland(run, span, islands, island.template, island.props);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\twrite(run, out, saved.html, span);\n\t\t\t\t\t\tfor (const addition of saved.additions) {\n\t\t\t\t\t\t\trecordAddition(run, span, addition, front);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// A copy that adds a `once` tag not added yet waits for the parts before it, as `add to` does.\n\t\t\t\t\tif (\n\t\t\t\t\t\trun.capture?.behind &&\n\t\t\t\t\t\tsaved.additions.some(\n\t\t\t\t\t\t\t(addition) =>\n\t\t\t\t\t\t\t\taddition.once !== null &&\n\t\t\t\t\t\t\t\tstate.once?.has(addition.once) !== true,\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn atFront(run, () => replay(true));\n\t\t\t\t\t}\n\t\t\t\t\treplay(false);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst start = out.s.length;\n\t\t\t\tconst hadScript = state.islandScript;\n\t\t\t\treturn after(fresh(), (capture) => {\n\t\t\t\t\tconst tags = [...(capture.section?.tags ?? [])].sort();\n\t\t\t\t\tconst manifest =\n\t\t\t\t\t\tstate.islands?.mode === \"defer\" ? state.islands.manifest : null;\n\t\t\t\t\tconst value = packSaved({\n\t\t\t\t\t\thtml: out.s.slice(start),\n\t\t\t\t\t\tadditions: additionsIn(capture.additions ?? []),\n\t\t\t\t\t\tislands: manifest\n\t\t\t\t\t\t\t? (capture.section?.deferred ?? []).flatMap(\n\t\t\t\t\t\t\t\t\t(id) => manifest[id] ?? [],\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\tislandScript: !hadScript && state.islandScript,\n\t\t\t\t\t\ttags,\n\t\t\t\t\t});\n\t\t\t\t\treturn locating(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t() => store.set({ key: name, value, seconds: time, tags }),\n\t\t\t\t\t\t\"The cache store\",\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\n\t\t// Whether a section holds the island script depends on the islands before it in the page, so with deferred\n\t\t// islands a section running ahead waits for the parts before it.\n\t\tconst render = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tout: Out,\n\t\t\tkeyValue: unknown,\n\t\t\tsecondsValue: unknown,\n\t\t): void | Promise<void> =>\n\t\t\trun.state.islands?.mode === \"defer\"\n\t\t\t\t? atFront(run, () => save(run, scope, out, keyValue, secondsValue))\n\t\t\t\t: save(run, scope, out, keyValue, secondsValue);\n\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst keyValue = key.ev(run, scope);\n\t\t\tlet secondsValue: unknown = null;\n\t\t\ttry {\n\t\t\t\tif (seconds) secondsValue = seconds.ev(run, scope);\n\t\t\t} catch (error) {\n\t\t\t\tsilence(keyValue);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t(key.async && isPromise(keyValue)) ||\n\t\t\t\t(seconds?.async && isPromise(secondsValue))\n\t\t\t) {\n\t\t\t\treturn all([\n\t\t\t\t\tkey.async ? keyValue : holdData(keyValue),\n\t\t\t\t\tseconds?.async ? secondsValue : holdData(secondsValue),\n\t\t\t\t]).then(([k, t]) => render(run, scope, out, k, t));\n\t\t\t}\n\t\t\treturn render(run, scope, out, keyValue, secondsValue);\n\t\t};\n\t}\n\n\t/**\n\t * `outlet`: marks where its content goes in the render's output. The content is put in place when the render ends,\n\t * so the outlet must write to that output, not to a capture or a cached section.\n\t */\n\t#outlet(node: Extract<Statement, { type: \"Outlet\" }>): Stmt {\n\t\tconst { name, span } = node;\n\t\tconst mark = (run: Run, out: Out) => {\n\t\t\tconst state = run.state;\n\t\t\tif (!isRoot(state, out) || run.capture?.section) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"misplaced-outlet\",\n\t\t\t\t\t`Outlet \"${name}\" can't be inside \"cache\", \"set\", \"apply\" or a macro`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tstate.outlets ??= new Map();\n\t\t\tif (state.outlets.has(name)) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"duplicate-outlet\",\n\t\t\t\t\t`Outlet \"${name}\" is used more than once in this render`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tstate.outlets.set(name, { out, offset: out.s.length, content: null });\n\t\t};\n\t\t// Outlets are marked in the order of the page, so one running ahead waits for the parts before it.\n\t\treturn (run, _scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn atFront(run, () => mark(run, out));\n\t\t};\n\t}\n\n\t/**\n\t * `flush`: closes the outlets reached so far, so a streamed render can send its output up to here. It closes them\n\t * in `render` too, so a template behaves the same either way.\n\t */\n\t#flush(node: Extract<Statement, { type: \"Flush\" }>): Stmt {\n\t\tconst { span } = node;\n\t\tconst close = (run: Run, out: Out) => {\n\t\t\tconst state = run.state;\n\t\t\tif (!isRoot(state, out) || run.capture?.section) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"misplaced-flush\",\n\t\t\t\t\t`\"flush\" can't be inside \"cache\", \"set\", \"apply\", \"add to\" or a macro`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcloseOutlets(state);\n\t\t\tcheckLate(state);\n\t\t\tstate.stream?.flush();\n\t\t};\n\t\t// The outlets close with what the parts before the flush added, so one running ahead waits for them.\n\t\treturn (run, _scope, out) => {\n\t\t\tstep(run, span);\n\t\t\treturn atFront(run, () => close(run, out));\n\t\t};\n\t}\n\n\t/**\n\t * `add to`: renders its content and records it for the outlet. A `once` tag that already added doesn't render again,\n\t * but is still recorded, so a cached section saves it.\n\t */\n\t#add(node: Extract<Statement, { type: \"Add\" }>): Stmt {\n\t\tconst body = this.#body(node.body);\n\t\tconst { outlet, span } = node;\n\t\tconst once = node.once ? `${this.#template.name}:${span.start}` : null;\n\t\tconst add = (\n\t\t\trun: Run,\n\t\t\tscope: Scope,\n\t\t\tfront: boolean,\n\t\t): void | Promise<void> => {\n\t\t\tconst first = once === null ? undefined : run.state.once?.get(once);\n\t\t\tif (first !== undefined) {\n\t\t\t\trecordAddition(run, span, { outlet, html: first, once }, front);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst capture = emptyOut();\n\t\t\treturn after(body(run, childScope(scope), capture), () =>\n\t\t\t\trecordAddition(run, span, { outlet, html: capture.s, once }, front),\n\t\t\t);\n\t\t};\n\t\treturn (run, scope) => {\n\t\t\tstep(run, span);\n\t\t\t// Whether a `once` tag is the first follows the page, so one running ahead that hasn't been added yet\n\t\t\t// waits for the parts before it, and then knows.\n\t\t\tif (\n\t\t\t\tonce !== null &&\n\t\t\t\trun.capture?.behind &&\n\t\t\t\trun.state.once?.has(once) !== true\n\t\t\t) {\n\t\t\t\treturn atFront(run, () => add(run, scope, true));\n\t\t\t}\n\t\t\treturn add(run, scope, false);\n\t\t};\n\t}\n\n\t#apply(node: Extract<Statement, { type: \"Apply\" }>): Stmt {\n\t\tconst body = this.#body(node.body);\n\t\tconst strategy = this.#strategy;\n\t\tconst input: Compiled = {\n\t\t\tev: (_run, scope) => scope[CAPTURED],\n\t\t\tasync: false,\n\t\t};\n\t\tlet chain = input;\n\t\tfor (const filter of node.filters) {\n\t\t\tchain = this.#filterCall(filter, chain);\n\t\t}\n\t\tconst result = chain.ev;\n\t\tconst span = node.span;\n\t\t// The result is printed like `{{ }}` output: markup as it is, and anything else, such as a plain string from a\n\t\t// host filter, escaped.\n\t\tconst print = emitter(this.#strategy);\n\t\tconst emit = (run: Run, out: Out, value: unknown) => {\n\t\t\tlet text: string;\n\t\t\ttry {\n\t\t\t\ttext = print(value);\n\t\t\t} catch (error) {\n\t\t\t\tthrow locate(run, span, error);\n\t\t\t}\n\t\t\twrite(run, out, text, span);\n\t\t};\n\n\t\treturn (run, scope, out) => {\n\t\t\tstep(run, span);\n\t\t\tconst captured = emptyOut();\n\t\t\treturn after(body(run, scope, captured), () => {\n\t\t\t\tconst inner = childScope(scope);\n\t\t\t\t// The body was escaped as it rendered, so filters get it as markup. Without autoescape, it is plain text.\n\t\t\t\tinner[CAPTURED] = strategy\n\t\t\t\t\t? new Markup(captured.s, strategy)\n\t\t\t\t\t: captured.s;\n\t\t\t\tconst value = result(run, inner);\n\t\t\t\treturn chain.async\n\t\t\t\t\t? after(value, (resolved) => emit(run, out, resolved))\n\t\t\t\t\t: emit(run, out, value);\n\t\t\t});\n\t\t};\n\t}\n\n\t// Expressions\n\n\t#expr(node: Expression, guard = false): Compiled {\n\t\t// Long operator or filter chains nest deeply without parentheses, so guard compile and render recursion here.\n\t\tif (++this.#expressionDepth > MAX_EXPRESSION_DEPTH) {\n\t\t\tthis.#expressionDepth = 0;\n\t\t\tthis.#error(\n\t\t\t\t\"too-deep\",\n\t\t\t\t`Expression is nested more than ${MAX_EXPRESSION_DEPTH} levels deep`,\n\t\t\t\tnode.span,\n\t\t\t);\n\t\t\treturn this.#broken();\n\t\t}\n\t\ttry {\n\t\t\treturn this.#compileExpression(node, guard);\n\t\t} finally {\n\t\t\tif (this.#expressionDepth > 0) this.#expressionDepth--;\n\t\t}\n\t}\n\n\t#compileExpression(node: Expression, guard: boolean): Compiled {\n\t\tswitch (node.type) {\n\t\t\tcase \"Literal\":\n\t\t\t\treturn constant(node.value);\n\t\t\tcase \"Invalid\":\n\t\t\t\treturn this.#broken();\n\t\t\tcase \"Name\":\n\t\t\t\treturn this.#name(node.name, node.span, guard);\n\t\t\tcase \"Interpolation\":\n\t\t\t\treturn this.#interpolation(node.parts, node.span);\n\t\t\tcase \"Array\":\n\t\t\t\treturn this.#array(node);\n\t\t\tcase \"Hash\":\n\t\t\t\treturn this.#hash(node);\n\t\t\tcase \"Unary\":\n\t\t\t\treturn this.#unary(node);\n\t\t\tcase \"Binary\":\n\t\t\t\treturn this.#binary(node);\n\t\t\tcase \"Conditional\":\n\t\t\t\treturn this.#conditional(node);\n\t\t\tcase \"Member\":\n\t\t\t\treturn this.#member(node, guard);\n\t\t\tcase \"OptionalChain\": {\n\t\t\t\t// `?.` guards its whole chain, so missing variables and properties in it become null.\n\t\t\t\tconst inner = this.#expr(node.expression, true);\n\t\t\t\treturn map1(inner, (value) =>\n\t\t\t\t\tvalue === SHORT || value === MISSING\n\t\t\t\t\t\t? guard\n\t\t\t\t\t\t\t? MISSING\n\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t: value,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase \"Call\":\n\t\t\t\treturn this.#call(node, guard);\n\t\t\tcase \"Filter\":\n\t\t\t\treturn this.#filter(node);\n\t\t\tcase \"Test\":\n\t\t\t\treturn this.#test(node);\n\t\t\tcase \"Arrow\":\n\t\t\t\treturn this.#arrow(node);\n\t\t}\n\t}\n\n\t#name(name: string, span: Span, guard: boolean): Compiled {\n\t\tif (guard) {\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tconst value = lookup(scope, name);\n\t\t\t\t\treturn value === undefined\n\t\t\t\t\t\t? MISSING\n\t\t\t\t\t\t: checkValue(run, span, value, name);\n\t\t\t\t},\n\t\t\t\tasync: false,\n\t\t\t};\n\t\t}\n\t\tif (this.#env.strict) {\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tconst value = lookup(scope, name);\n\t\t\t\t\tif (value === undefined) {\n\t\t\t\t\t\tthrow undefinedVariable(run, span, name, scope);\n\t\t\t\t\t}\n\t\t\t\t\treturn typeof value === \"function\"\n\t\t\t\t\t\t? checkValue(run, span, value, name)\n\t\t\t\t\t\t: value;\n\t\t\t\t},\n\t\t\t\tasync: false,\n\t\t\t\tvariable: name,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tconst value = lookup(scope, name);\n\t\t\t\tif (value === undefined) return null;\n\t\t\t\treturn typeof value === \"function\"\n\t\t\t\t\t? checkValue(run, span, value, name)\n\t\t\t\t\t: value;\n\t\t\t},\n\t\t\tasync: false,\n\t\t\tvariable: name,\n\t\t};\n\t}\n\n\t#interpolation(parts: Expression[], span: Span): Compiled {\n\t\tconst compiled = parts.map((part) => this.#expr(part));\n\t\tconst values = evalAll(compiled);\n\t\tconst join = (run: Run, list: unknown[]) => {\n\t\t\tlet result = \"\";\n\t\t\tfor (const value of list) {\n\t\t\t\tif (typeof value === \"string\") result += value;\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresult += toStr(value);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn locating(run, span, () => checkLength(run, result));\n\t\t};\n\t\tconst async = compiled.some((part) => part.async);\n\t\treturn {\n\t\t\tev: async\n\t\t\t\t? (run, scope) => after(values(run, scope), (list) => join(run, list))\n\t\t\t\t: (run, scope) => join(run, values(run, scope) as unknown[]),\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#array(node: Extract<Expression, { type: \"Array\" }>): Compiled {\n\t\tconst spreads = node.elements.map((element) => element.type === \"Spread\");\n\t\tconst compiled = node.elements.map((element) =>\n\t\t\telement.type === \"Spread\"\n\t\t\t\t? this.#expr(element.value)\n\t\t\t\t: this.#expr(element),\n\t\t);\n\t\tconst values = evalAll(compiled);\n\t\tconst hasSpread = spreads.includes(true);\n\t\tconst span = node.span;\n\t\tconst build = (run: Run, list: unknown[]): unknown[] => {\n\t\t\tif (!hasSpread) return list;\n\t\t\tconst result: unknown[] = [];\n\t\t\tfor (let i = 0; i < list.length; i++) {\n\t\t\t\tif (spreads[i]) {\n\t\t\t\t\tfor (const item of spreadItems(run, span, list[i])) result.push(item);\n\t\t\t\t} else result.push(list[i]);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst async = compiled.some((item) => item.async);\n\t\treturn {\n\t\t\tev: async\n\t\t\t\t? (run, scope) => after(values(run, scope), (list) => build(run, list))\n\t\t\t\t: (run, scope) => build(run, values(run, scope) as unknown[]),\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#hash(node: Extract<Expression, { type: \"Hash\" }>): Compiled {\n\t\ttype Entry = { spread: true } | { spread: false; key: string | null };\n\t\tconst entries: Entry[] = [];\n\t\tconst compiled: Compiled[] = [];\n\t\tfor (const entry of node.entries) {\n\t\t\tif (entry.type === \"Spread\") {\n\t\t\t\tentries.push({ spread: true });\n\t\t\t\tcompiled.push(this.#expr(entry.value));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst key = entry.key;\n\t\t\tif (key.type === \"Literal\") {\n\t\t\t\tif (key.value === \"__proto__\") this.#protoKey(key.span);\n\t\t\t\tentries.push({ spread: false, key: String(key.value) });\n\t\t\t} else {\n\t\t\t\tentries.push({ spread: false, key: null });\n\t\t\t\tcompiled.push(this.#expr(key));\n\t\t\t}\n\t\t\tcompiled.push(this.#expr(entry.value));\n\t\t}\n\t\tconst values = evalAll(compiled);\n\t\tconst span = node.span;\n\n\t\tconst build = (run: Run, list: unknown[]) => {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tlet index = 0;\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (entry.spread) {\n\t\t\t\t\tcopyHash(run, span, result, list[index++]);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet key = entry.key;\n\t\t\t\tif (key === null) {\n\t\t\t\t\tconst raw = list[index++];\n\t\t\t\t\t// Markup is a string with a safety mark, so it can name a key.\n\t\t\t\t\tconst computed = raw instanceof Markup ? raw.value : raw;\n\t\t\t\t\tif (typeof computed !== \"string\" && typeof computed !== \"number\") {\n\t\t\t\t\t\tthrow fail(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t\"type-error\",\n\t\t\t\t\t\t\t`Hash keys must be strings or numbers, but got a ${typeName(computed)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tkey = String(computed);\n\t\t\t\t\tif (key === \"__proto__\") {\n\t\t\t\t\t\tthrow fail(run, span, \"invalid-key\", PROTO_KEY_MESSAGE);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetOwn(result, key, list[index++]);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst async = compiled.some((item) => item.async);\n\t\treturn {\n\t\t\tev: async\n\t\t\t\t? (run, scope) => after(values(run, scope), (list) => build(run, list))\n\t\t\t\t: (run, scope) => build(run, values(run, scope) as unknown[]),\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#unary(node: Extract<Expression, { type: \"Unary\" }>): Compiled {\n\t\tconst operand = this.#expr(node.operand);\n\t\tconst span = node.span;\n\t\tswitch (node.operator) {\n\t\t\tcase \"not\":\n\t\t\t\treturn map1(operand, (value) => !truthy(value));\n\t\t\tcase \"-\":\n\t\t\t\treturn map1(operand, (value, run) =>\n\t\t\t\t\ttypeof value === \"number\"\n\t\t\t\t\t\t? -value\n\t\t\t\t\t\t: -locating(run, span, () => toNumber(value, \"-\")),\n\t\t\t\t);\n\t\t\tcase \"+\":\n\t\t\t\treturn map1(operand, (value, run) =>\n\t\t\t\t\ttypeof value === \"number\"\n\t\t\t\t\t\t? value\n\t\t\t\t\t\t: locating(run, span, () => toNumber(value, \"+\")),\n\t\t\t\t);\n\t\t}\n\t}\n\n\t#binary(node: Extract<Expression, { type: \"Binary\" }>): Compiled {\n\t\tconst { operator, span } = node;\n\n\t\tif (\n\t\t\toperator === \"and\" ||\n\t\t\toperator === \"or\" ||\n\t\t\toperator === \"??\" ||\n\t\t\toperator === \"?:\"\n\t\t) {\n\t\t\tconst left = this.#expr(node.left, operator === \"??\");\n\t\t\tconst right = this.#expr(node.right);\n\t\t\tconst rightEv = right.ev;\n\t\t\tconst test = right.async\n\t\t\t\t? (run: Run, scope: Scope) =>\n\t\t\t\t\t\tafter(rightEv(run, scope), (resolved) => truthy(resolved))\n\t\t\t\t: (run: Run, scope: Scope) => truthy(rightEv(run, scope));\n\t\t\t// When the right side may wait, the left value is returned through `passData`, see `map1`.\n\t\t\tconst keep = right.async ? passData : (value: unknown) => value;\n\t\t\tconst decide = (value: unknown, run: Run, scope: Scope): unknown => {\n\t\t\t\tswitch (operator) {\n\t\t\t\t\tcase \"and\":\n\t\t\t\t\t\treturn truthy(value) ? test(run, scope) : false;\n\t\t\t\t\tcase \"or\":\n\t\t\t\t\t\treturn truthy(value) ? true : test(run, scope);\n\t\t\t\t\tcase \"??\":\n\t\t\t\t\t\treturn value === MISSING || value === null || value === undefined\n\t\t\t\t\t\t\t? right.ev(run, scope)\n\t\t\t\t\t\t\t: keep(value);\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn truthy(value) ? keep(value) : right.ev(run, scope);\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn map1(left, decide, right.async);\n\t\t}\n\n\t\tconst left = this.#expr(node.left);\n\t\tconst right = this.#expr(node.right);\n\n\t\tif (operator === \"..\") {\n\t\t\treturn map2(left, right, (a, b, run) =>\n\t\t\t\tlocating(run, span, () => {\n\t\t\t\t\tconst items = rangeOperator(a, b, run.state.maxSteps);\n\t\t\t\t\tconsume(run, items.length);\n\t\t\t\t\treturn items;\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (operator === \"in\" || operator === \"not in\") {\n\t\t\tconst negate = operator === \"not in\";\n\t\t\treturn map2(left, right, (a, b, run) =>\n\t\t\t\tlocating(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t() => contains(a, b, (count) => consume(run, count)) !== negate,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst apply = operatorFunction(operator);\n\t\tconst joins = operator === \"~\";\n\t\treturn map2(left, right, (a, b, run) => {\n\t\t\ttry {\n\t\t\t\tconst result = apply(a, b);\n\t\t\t\treturn joins ? checkLength(run, result as string) : result;\n\t\t\t} catch (error) {\n\t\t\t\tthrow locate(run, span, error);\n\t\t\t}\n\t\t});\n\t}\n\n\t#conditional(node: Extract<Expression, { type: \"Conditional\" }>): Compiled {\n\t\tconst test = this.#expr(node.test);\n\t\tconst consequent = this.#expr(node.consequent);\n\t\tconst alternate = node.alternate\n\t\t\t? this.#expr(node.alternate)\n\t\t\t: constant(null);\n\t\tconst async = consequent.async || alternate.async;\n\t\t// When one branch may wait, the other's value is returned through `passData`, see `map1`.\n\t\tconst branch = (compiled: Compiled): Ev =>\n\t\t\tasync && !compiled.async\n\t\t\t\t? (run, scope) => passData(compiled.ev(run, scope))\n\t\t\t\t: compiled.ev;\n\t\tconst yes = branch(consequent);\n\t\tconst no = branch(alternate);\n\t\tconst compiled = map1(\n\t\t\ttest,\n\t\t\t(value, run, scope) => (truthy(value) ? yes(run, scope) : no(run, scope)),\n\t\t\tasync,\n\t\t);\n\t\tif (!test.async && consequent.constant && alternate.constant) {\n\t\t\tcompiled.choice = {\n\t\t\t\ttest: test.ev,\n\t\t\t\tyes: consequent.constant.value,\n\t\t\t\tno: alternate.constant.value,\n\t\t\t};\n\t\t}\n\t\treturn compiled;\n\t}\n\n\t#member(\n\t\tnode: Extract<Expression, { type: \"Member\" }>,\n\t\tguard: boolean,\n\t): Compiled {\n\t\tconst object = this.#expr(node.object, guard);\n\t\tconst { optional, span } = node;\n\t\tconst read = (run: Run, target: unknown, key: unknown): unknown =>\n\t\t\treadMember(run, span, target, key, optional, guard);\n\n\t\tconst property = node.property;\n\t\tif (property.type !== \"Literal\") {\n\t\t\t// The key waits for the object, as a chain that stops at a `?.` leaves it unevaluated.\n\t\t\tconst key = this.#expr(property);\n\t\t\tconst keyEv = key.ev;\n\t\t\tconst stops = chainStops(optional);\n\t\t\treturn map1(\n\t\t\t\tobject,\n\t\t\t\tkey.async\n\t\t\t\t\t? (target, run, scope) =>\n\t\t\t\t\t\t\tstops(target)\n\t\t\t\t\t\t\t\t? SHORT\n\t\t\t\t\t\t\t\t: after(keyEv(run, scope), (name) =>\n\t\t\t\t\t\t\t\t\t\tpassData(read(run, target, name)),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t: (target, run, scope) =>\n\t\t\t\t\t\t\tstops(target) ? SHORT : read(run, target, keyEv(run, scope)),\n\t\t\t\tkey.async,\n\t\t\t);\n\t\t}\n\t\tconst key = property.value;\n\t\tconst access: PathStep = {\n\t\t\tname: typeof key === \"string\" && !BLOCKED_NAMES.has(key) ? key : null,\n\t\t\tread: (run, target) => read(run, target, key),\n\t\t\tspan,\n\t\t};\n\t\tif (object.async)\n\t\t\treturn map1(object, (target, run) => access.read(run, target));\n\t\t// `a.b.c` reads every key in one closure, so a long path costs one call.\n\t\tconst inner = object.path;\n\t\treturn inner\n\t\t\t? pathRead(inner.root, [...inner.steps, access])\n\t\t\t: pathRead(object, [access]);\n\t}\n\n\t#arrow(node: Extract<Expression, { type: \"Arrow\" }>): Compiled {\n\t\tconst body = this.#expr(node.body);\n\t\tconst { params, span } = node;\n\t\tconst ev = body.ev;\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tconst call = (...args: unknown[]) => {\n\t\t\t\t\tstep(run, span);\n\t\t\t\t\tconst inner = childScope(scope);\n\t\t\t\t\tfor (let i = 0; i < params.length; i++) {\n\t\t\t\t\t\tinner[params[i] as string] = args[i] ?? null;\n\t\t\t\t\t}\n\t\t\t\t\treturn ev(run, inner);\n\t\t\t\t};\n\t\t\t\t// Your functions get a promise only from a body that waits, resolving to the value itself, or to it held\n\t\t\t\t// when it has a `then` member, which a promise resolving to it would call. See `holdData`.\n\t\t\t\tconst waits = body.async;\n\t\t\t\tconst fn = (...args: unknown[]) => {\n\t\t\t\t\tconst result = call(...args);\n\t\t\t\t\treturn waits && result instanceof Promise\n\t\t\t\t\t\t? result.then((value) => holdData(unhold(value)))\n\t\t\t\t\t\t: result;\n\t\t\t\t};\n\t\t\t\t// Lets filters such as `sort` tell a key selector from a comparator.\n\t\t\t\tObject.defineProperty(call, \"length\", { value: params.length });\n\t\t\t\tObject.defineProperty(fn, \"length\", { value: params.length });\n\t\t\t\ttemplateFunctions.set(fn, call);\n\t\t\t\treturn fn;\n\t\t\t},\n\t\t\tasync: false,\n\t\t\tarrowAsync: body.async,\n\t\t};\n\t}\n\n\t/**\n\t * Compiles call arguments. Named arguments become one trailing hash; spreads expand arrays.\n\t *\n\t * A `null` entry is a parameter the call skipped, passed as `undefined` so the parameter's default applies.\n\t */\n\t#arguments(\n\t\targs: (Argument | null)[],\n\t\t/** Position of a built-in's options hash, which is built once when its keys and values are literals. */\n\t\toptionsAt = -1,\n\t): CompiledArguments {\n\t\tfor (const arg of args) {\n\t\t\tif (arg?.type === \"Named\" && arg.name === \"__proto__\")\n\t\t\t\tthis.#protoKey(arg.span);\n\t\t}\n\t\tconst compiled = args.map((arg, index) => {\n\t\t\tif (!arg) return constant(undefined);\n\t\t\tconst value = this.#expr(arg.value);\n\t\t\treturn index === optionsAt ? (literalHash(arg.value) ?? value) : value;\n\t\t});\n\t\treturn {\n\t\t\tcompiled,\n\t\t\tevs: compiled.map((item) => item.ev),\n\t\t\tvalues: evalAll(compiled),\n\t\t\tshapes: args.map((arg) => ({\n\t\t\t\tkind: arg ? arg.type : \"Positional\",\n\t\t\t\tname: arg?.type === \"Named\" ? arg.name : \"\",\n\t\t\t})),\n\t\t\tasync: compiled.some((item) => item.async),\n\t\t\tarrowAsync: compiled.some((item) => item.arrowAsync === true),\n\t\t};\n\t}\n\n\t#call(node: Extract<Expression, { type: \"Call\" }>, guard: boolean): Compiled {\n\t\tconst callee = node.callee;\n\t\tif (callee.type === \"Name\") {\n\t\t\tconst name = callee.name;\n\t\t\tif (name === \"parent\") return this.#parentCall(node);\n\t\t\tif (name === \"block\") return this.#blockCall(node);\n\n\t\t\tconst local = this.#template.macros.get(name);\n\t\t\tif (local) {\n\t\t\t\tconst macros = this.#template.macros;\n\t\t\t\treturn this.#macroCall(node, () => macros.get(name), `Macro \"${name}\"`);\n\t\t\t}\n\t\t\tconst imported = this.#fromImports.get(name);\n\t\t\tif (imported) {\n\t\t\t\treturn this.#macroCall(\n\t\t\t\t\tnode,\n\t\t\t\t\t(run) => run.imports[imported.slot]?.macros.get(imported.name),\n\t\t\t\t\t`Macro \"${imported.name}\" from ${this.#template.imports[imported.slot]?.name}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst entry = this.#env.functions.get(name);\n\t\t\tif (!entry) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"unknown-function\",\n\t\t\t\t\t`Unknown function \"${name}\"`,\n\t\t\t\t\tcallee.span,\n\t\t\t\t);\n\t\t\t\treturn this.#broken();\n\t\t\t}\n\t\t\treturn this.#callable(\n\t\t\t\tentry,\n\t\t\t\t`Function \"${name}\"`,\n\t\t\t\tnull,\n\t\t\t\tnode.args,\n\t\t\t\tnode.span,\n\t\t\t);\n\t\t}\n\n\t\tif (callee.type === \"Member\") {\n\t\t\tconst object = callee.object;\n\t\t\tconst property = callee.property;\n\t\t\tif (\n\t\t\t\tobject.type === \"Name\" &&\n\t\t\t\tproperty.type === \"Literal\" &&\n\t\t\t\ttypeof property.value === \"string\" &&\n\t\t\t\tthis.#importAliases.has(object.name)\n\t\t\t) {\n\t\t\t\tconst slot = this.#importAliases.get(object.name) as number;\n\t\t\t\tconst macroName = property.value;\n\t\t\t\treturn this.#macroCall(\n\t\t\t\t\tnode,\n\t\t\t\t\t(run) => run.imports[slot]?.macros.get(macroName),\n\t\t\t\t\t`Macro \"${macroName}\" from ${this.#template.imports[slot]?.name}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.#methodCall(node, callee, guard);\n\t\t}\n\n\t\tthis.#error(\"invalid-call\", \"This value cannot be called\", node.span);\n\t\treturn this.#broken();\n\t}\n\n\t#macroCall(\n\t\tnode: Extract<Expression, { type: \"Call\" }>,\n\t\tresolve: (run: Run) => CompiledMacro | undefined,\n\t\tlabel: string,\n\t): Compiled {\n\t\tconst positional: Compiled[] = [];\n\t\tconst namedNames: string[] = [];\n\t\tconst named: Compiled[] = [];\n\t\tfor (const arg of node.args) {\n\t\t\tif (arg.type === \"Named\") {\n\t\t\t\tnamedNames.push(arg.name);\n\t\t\t\tnamed.push(this.#expr(arg.value));\n\t\t\t} else if (arg.type === \"Spread\") {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"invalid-spread\",\n\t\t\t\t\t\"Spread arguments cannot be passed to macros\",\n\t\t\t\t\targ.span,\n\t\t\t\t);\n\t\t\t} else positional.push(this.#expr(arg.value));\n\t\t}\n\t\tconst values = evalAll([...positional, ...named]);\n\t\tconst count = positional.length;\n\t\tconst span = node.span;\n\n\t\tconst invoke = (run: Run, list: unknown[]) => {\n\t\t\tconst macro = resolve(run);\n\t\t\tif (!macro) {\n\t\t\t\tthrow fail(run, span, \"unknown-macro\", `${label} does not exist`);\n\t\t\t}\n\t\t\tlet namedValues: Record<string, unknown> | null = null;\n\t\t\tif (namedNames.length > 0) {\n\t\t\t\tnamedValues = {};\n\t\t\t\tfor (let i = 0; i < namedNames.length; i++) {\n\t\t\t\t\tsetOwn(namedValues, namedNames[i] as string, list[count + i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn callMacro(run, span, macro, list.slice(0, count), namedValues);\n\t\t};\n\n\t\treturn {\n\t\t\tev: (run, scope) =>\n\t\t\t\tafter(values(run, scope), (list) => invoke(run, list)),\n\t\t\tasync: true,\n\t\t};\n\t}\n\n\t/** A method call. With `guard`, as in a `?.` chain, a missing or null object makes the call missing too. */\n\t#methodCall(\n\t\tnode: Extract<Expression, { type: \"Call\" }>,\n\t\tcallee: Extract<Expression, { type: \"Member\" }>,\n\t\tguard: boolean,\n\t): Compiled {\n\t\tconst object = this.#expr(callee.object, guard);\n\t\tconst property = callee.property;\n\t\tconst key =\n\t\t\tproperty.type === \"Literal\"\n\t\t\t\t? constant(property.value)\n\t\t\t\t: this.#expr(property);\n\t\tconst args = this.#arguments(node.args);\n\t\tconst span = node.span;\n\t\tconst optional = callee.optional;\n\t\tconst stops = chainStops(optional);\n\n\t\tconst invoke = (\n\t\t\trun: Run,\n\t\t\ttarget: unknown,\n\t\t\tname: unknown,\n\t\t\tlist: unknown[],\n\t\t) => {\n\t\t\tif (target === SHORT) return SHORT;\n\t\t\tif (target === null || target === undefined) {\n\t\t\t\tif (optional) return SHORT;\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"null-access\",\n\t\t\t\t\t`Cannot call ${valueLabel(name)} on null`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst method =\n\t\t\t\ttypeof name === \"string\" ? getMethod(target, name) : undefined;\n\t\t\tif (!method) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"method-not-exposed\",\n\t\t\t\t\t`${valueLabel(name)} is not a method that ${typeName(target)} exposes`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst built = buildArguments(run, span, args.shapes, list);\n\t\t\treturn locating(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t() => method.apply(target, built),\n\t\t\t\t`Method \"${String(name)}\"`,\n\t\t\t);\n\t\t};\n\n\t\tconst call = (run: Run, scope: Scope, target: unknown, name: unknown) => {\n\t\t\tstep(run, span);\n\t\t\treturn after(args.values(run, scope), (list) =>\n\t\t\t\tinvoke(run, target, name, list),\n\t\t\t);\n\t\t};\n\t\t// The name and arguments wait for the object, as a chain that stops at a `?.` leaves them unevaluated.\n\t\tconst keyEv = key.ev;\n\t\tconst named = (run: Run, scope: Scope, target: unknown) => {\n\t\t\tif (stops(target)) return SHORT;\n\t\t\tif (\n\t\t\t\tguard &&\n\t\t\t\t(target === null || target === undefined || target === MISSING)\n\t\t\t) {\n\t\t\t\treturn MISSING;\n\t\t\t}\n\t\t\tconst name = keyEv(run, scope);\n\t\t\treturn key.async\n\t\t\t\t? after(name, (resolved) => call(run, scope, target, resolved))\n\t\t\t\t: call(run, scope, target, name);\n\t\t};\n\t\tconst objectEv = object.ev;\n\t\treturn {\n\t\t\tev: object.async\n\t\t\t\t? (run, scope) =>\n\t\t\t\t\t\tafter(objectEv(run, scope), (target) => named(run, scope, target))\n\t\t\t\t: (run, scope) => named(run, scope, objectEv(run, scope)),\n\t\t\tasync: true,\n\t\t};\n\t}\n\n\t/** Compiles a call to a built-in or host function, filter or test. `input` is the filtered or tested value. */\n\t#callable(\n\t\tentry: CallableEntry,\n\t\tlabel: string,\n\t\tinput: Compiled | null,\n\t\targNodes: Argument[],\n\t\tspan: Span,\n\t): Compiled {\n\t\tconst args =\n\t\t\tentry.kind === \"builtin\"\n\t\t\t\t? this.#arguments(\n\t\t\t\t\t\tplaceArguments(entry, argNodes, label, (code, message, at) =>\n\t\t\t\t\t\t\tthis.#error(code, message, at),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tentry.options ? (entry.params?.length ?? 0) : -1,\n\t\t\t\t\t)\n\t\t\t\t: this.#arguments(argNodes);\n\t\t// The input and arguments all start before any is waited for.\n\t\tconst withInput = input ? evalAll([input, ...args.compiled]) : null;\n\t\tconst inputAsync = input?.async ?? false;\n\t\tconst shapes = args.shapes;\n\t\tconst valuesOf = args.values;\n\t\t// Only positional arguments: the evaluated list is already what the callable receives.\n\t\tconst plain =\n\t\t\tshapes.length <= MAX_ARGUMENTS &&\n\t\t\tshapes.every((shape) => shape.kind === \"Positional\");\n\n\t\tconst resultAsync = entry.kind === \"host\" || args.arrowAsync;\n\t\tconst async = resultAsync || args.async || inputAsync;\n\t\t// A built-in that runs no arrow function that waits never returns a promise to wait for, so when the call may\n\t\t// wait for its arguments, a value from your data it returns goes through `passData`. See `map1`.\n\t\tconst keep = async && !resultAsync ? passData : (value: unknown) => value;\n\n\t\tconst invoke = (\n\t\t\trun: Run,\n\t\t\tfirst: unknown,\n\t\t\thasInput: boolean,\n\t\t\tlist: unknown[],\n\t\t) => {\n\t\t\tconst built = plain ? list : buildArguments(run, span, shapes, list);\n\t\t\tif (entry.kind === \"builtin\") {\n\t\t\t\tconst call = entry.call;\n\t\t\t\treturn keep(\n\t\t\t\t\thasInput\n\t\t\t\t\t\t? locating(run, span, () => call(run, first, ...built))\n\t\t\t\t\t\t: locating(run, span, () => call(run, ...built)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (hasInput) built.unshift(first);\n\t\t\tconst call = entry.call;\n\t\t\tif (entry.render) {\n\t\t\t\treturn locating(run, span, () => call(run.info, ...built), label);\n\t\t\t}\n\t\t\treturn locating(run, span, () => call(...built), label);\n\t\t};\n\n\t\tif (entry.kind === \"builtin\" && plain && !async) {\n\t\t\tconst evs = input ? [input.ev, ...args.evs] : args.evs;\n\t\t\tconst direct = directCall(entry.call, evs, span);\n\t\t\tif (direct) return { ev: direct, async: false };\n\t\t}\n\n\t\tif (!input) {\n\t\t\tif (!args.async) {\n\t\t\t\treturn {\n\t\t\t\t\tev: (run, scope) => {\n\t\t\t\t\t\tstep(run, span);\n\t\t\t\t\t\treturn invoke(\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tvaluesOf(run, scope) as unknown[],\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tasync,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tstep(run, span);\n\t\t\t\t\treturn after(valuesOf(run, scope), (list) =>\n\t\t\t\t\t\tinvoke(run, undefined, false, list),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tasync,\n\t\t\t};\n\t\t}\n\n\t\tconst inputEv = input.ev;\n\t\tif (!args.async && !inputAsync) {\n\t\t\treturn {\n\t\t\t\tev: (run, scope) => {\n\t\t\t\t\tstep(run, span);\n\t\t\t\t\treturn invoke(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tinputEv(run, scope),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tvaluesOf(run, scope) as unknown[],\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tasync,\n\t\t\t};\n\t\t}\n\t\tconst values = withInput as NonNullable<typeof withInput>;\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\treturn after(values(run, scope), (list) =>\n\t\t\t\t\tinvoke(run, list[0], true, list.slice(1)),\n\t\t\t\t);\n\t\t\t},\n\t\t\tasync,\n\t\t};\n\t}\n\n\t#filter(node: Extract<Expression, { type: \"Filter\" }>): Compiled {\n\t\tconst input = this.#expr(node.input, node.name === \"default\");\n\t\treturn this.#filterCall(node, input);\n\t}\n\n\t#filterCall(\n\t\tnode: FilterCall | Extract<Expression, { type: \"Filter\" }>,\n\t\tinput: Compiled,\n\t): Compiled {\n\t\tconst { name, args, span } = node;\n\t\tconst strategy = this.#strategy || \"html\";\n\n\t\tif (name === \"default\") {\n\t\t\tconst fallback = args[0] ? this.#expr(args[0].value) : constant(\"\");\n\t\t\tconst keep = fallback.async ? passData : (value: unknown) => value;\n\t\t\treturn map1(\n\t\t\t\tinput,\n\t\t\t\t(value, run, scope) =>\n\t\t\t\t\tvalue === MISSING || isEmpty(value)\n\t\t\t\t\t\t? fallback.ev(run, scope)\n\t\t\t\t\t\t: keep(value),\n\t\t\t\tfallback.async,\n\t\t\t);\n\t\t}\n\t\tif (name === \"raw\") {\n\t\t\treturn map1(input, (value, run) => {\n\t\t\t\tif (value instanceof Markup) {\n\t\t\t\t\treturn value.strategy === strategy\n\t\t\t\t\t\t? value\n\t\t\t\t\t\t: new Markup(value.value, strategy);\n\t\t\t\t}\n\t\t\t\treturn new Markup(\n\t\t\t\t\tlocating(run, span, () => toStr(value)),\n\t\t\t\t\tstrategy,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tif (name === \"escape\") {\n\t\t\tconst strategyArg = args[0]\n\t\t\t\t? this.#expr(args[0].value)\n\t\t\t\t: constant(\"html\");\n\t\t\tconst known = strategyArg.constant;\n\t\t\tif (known && !ESCAPE_STRATEGIES.includes(known.value as EscapeStrategy)) {\n\t\t\t\tthis.#error(\n\t\t\t\t\t\"unknown-strategy\",\n\t\t\t\t\t`Unknown escaping strategy \"${String(known.value)}\"`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn map2(input, strategyArg, (value, target, run) => {\n\t\t\t\tif (!ESCAPE_STRATEGIES.includes(target as EscapeStrategy)) {\n\t\t\t\t\tthrow fail(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\"unknown-strategy\",\n\t\t\t\t\t\t`Unknown escaping strategy ${valueLabel(target)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst chosen = target as EscapeStrategy;\n\t\t\t\tif (value instanceof Markup && value.strategy === chosen) return value;\n\t\t\t\tconst text = locating(run, span, () => toStr(value));\n\t\t\t\t// Escaping can make text several times longer, so it stops at the output limit.\n\t\t\t\treturn new Markup(\n\t\t\t\t\tlocating(run, span, () =>\n\t\t\t\t\t\tescapeWith(text, chosen, run.state.maxSize),\n\t\t\t\t\t),\n\t\t\t\t\tchosen,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\tconst entry = this.#env.filters.get(name);\n\t\tif (!entry) {\n\t\t\tthis.#error(\n\t\t\t\t\"unknown-filter\",\n\t\t\t\t`Unknown filter \"${name}\"`,\n\t\t\t\t\"nameSpan\" in node ? node.nameSpan : span,\n\t\t\t);\n\t\t\treturn this.#broken();\n\t\t}\n\t\treturn this.#callable(entry, `Filter \"${name}\"`, input, args, span);\n\t}\n\n\t#test(node: Extract<Expression, { type: \"Test\" }>): Compiled {\n\t\tconst { name, negated, span } = node;\n\n\t\tif (name === \"defined\") {\n\t\t\tconst input = node.input;\n\t\t\tif (\n\t\t\t\tinput.type === \"Call\" &&\n\t\t\t\tinput.callee.type === \"Name\" &&\n\t\t\t\tinput.callee.name === \"block\"\n\t\t\t) {\n\t\t\t\tconst blockName = input.args[0]\n\t\t\t\t\t? this.#expr(input.args[0].value)\n\t\t\t\t\t: constant(null);\n\t\t\t\treturn map1(blockName, (value, run) => {\n\t\t\t\t\tconst exists = typeof value === \"string\" && run.blocks.has(value);\n\t\t\t\t\treturn negated ? !exists : exists;\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn map1(this.#expr(input, true), (value) =>\n\t\t\t\tnegated ? value === MISSING : value !== MISSING,\n\t\t\t);\n\t\t}\n\n\t\tconst entry = this.#env.tests.get(name);\n\t\tif (!entry) {\n\t\t\tthis.#error(\"unknown-test\", `Unknown test \"${name}\"`, node.nameSpan);\n\t\t\treturn this.#broken();\n\t\t}\n\t\tconst compiled = this.#callable(\n\t\t\tentry,\n\t\t\t`Test \"${name}\"`,\n\t\t\tthis.#expr(node.input),\n\t\t\tnode.args,\n\t\t\tspan,\n\t\t);\n\t\treturn map1(compiled, (value) =>\n\t\t\tnegated ? !truthy(value) : truthy(value),\n\t\t);\n\t}\n\n\t#parentCall(node: Extract<Expression, { type: \"Call\" }>): Compiled {\n\t\tconst blockName = this.#blockName;\n\t\tif (blockName === null) {\n\t\t\tthis.#error(\n\t\t\t\t\"parent-outside-block\",\n\t\t\t\t'\"parent()\" can only be used inside a block',\n\t\t\t\tnode.span,\n\t\t\t);\n\t\t\treturn this.#broken();\n\t\t}\n\t\tconst span = node.span;\n\t\treturn {\n\t\t\tev: (run, scope) => {\n\t\t\t\tconst list = run.blocks.get(blockName);\n\t\t\t\t// The entry for this template's block. A block can render in a capture, with a run of its own.\n\t\t\t\tconst index = list\n\t\t\t\t\t? list.findIndex((entry) => entry.run.template === run.template)\n\t\t\t\t\t: -1;\n\t\t\t\tconst next = list?.[index + 1];\n\t\t\t\tif (!next) {\n\t\t\t\t\tthrow fail(\n\t\t\t\t\t\trun,\n\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\"missing-parent-block\",\n\t\t\t\t\t\t`Block \"${blockName}\" has no parent block`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn renderBlockEntry(run, span, next, scope);\n\t\t\t},\n\t\t\tasync: true,\n\t\t};\n\t}\n\n\t#blockCall(node: Extract<Expression, { type: \"Call\" }>): Compiled {\n\t\tconst name = node.args[0] ? this.#expr(node.args[0].value) : constant(null);\n\t\tconst span = node.span;\n\t\tconst place = (run: Run, scope: Scope, value: unknown) => {\n\t\t\tconst entry =\n\t\t\t\ttypeof value === \"string\" ? run.blocks.get(value)?.[0] : undefined;\n\t\t\tif (!entry) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"unknown-block\",\n\t\t\t\t\t`Block ${valueLabel(value)} does not exist`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn renderBlockEntry(run, span, entry, scope);\n\t\t};\n\t\tconst ev = name.ev;\n\t\treturn {\n\t\t\tev: name.async\n\t\t\t\t? (run, scope) =>\n\t\t\t\t\t\tafter(ev(run, scope), (value) => place(run, scope, value))\n\t\t\t\t: (run, scope) => place(run, scope, ev(run, scope)),\n\t\t\tasync: true,\n\t\t};\n\t}\n}\n\n/** Renders a block into markup, for `parent()` and `block()`. */\nconst renderBlockEntry = (\n\trun: Run,\n\tspan: Span,\n\tentry: { def: BlockDef; run: Run },\n\tscope: Scope,\n): Markup | Promise<Markup> => {\n\tconst state = run.state;\n\t// `block()` can call itself, so count its nesting against `maxDepth`.\n\tconst depth = run.blockDepth + 1;\n\tif (depth > state.maxDepth) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-depth\",\n\t\t\t`Render stopped after nesting ${state.maxDepth} blocks deep`,\n\t\t);\n\t}\n\tconst out = emptyOut();\n\t// A capture of its own, since the block can render alongside other expressions.\n\tconst capture = startCapture(run);\n\tconst blockRun = entry.run.within(capture, depth);\n\tconst result = withCaller(run, span, () =>\n\t\tentry.def.body(blockRun, blockScope(entry.def, scope), out),\n\t);\n\treturn after(result, () => {\n\t\tendCapture(run, capture);\n\t\treturn new Markup(out.s, entry.def.strategy || \"html\");\n\t});\n};\n\n/**\n * Reads one property the way templates may, for `a.b` and `a[b]`. `optional` is set for `?.`, and `guard` where a\n * missing value is allowed, such as the input of `default`; see `MISSING` and `SHORT`.\n */\nexport const readMember = (\n\trun: Run,\n\tspan: Span,\n\ttarget: unknown,\n\trawKey: unknown,\n\toptional: boolean,\n\tguard: boolean,\n): unknown => {\n\tif (target === SHORT) return SHORT;\n\t// Markup is a string with a safety mark, so it can name a property.\n\tconst key = rawKey instanceof Markup ? rawKey.value : rawKey;\n\tconst strict = run.state.env.strict;\n\tif (target === null || target === undefined || target === MISSING) {\n\t\tif (optional) return SHORT;\n\t\tif (guard) return MISSING;\n\t\tif (strict) {\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"null-access\",\n\t\t\t\t`Cannot read ${valueLabel(key)} of null`,\n\t\t\t\t'Use \"?.\" to allow null.',\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t}\n\tif (typeof key !== \"string\" && typeof key !== \"number\") {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"type-error\",\n\t\t\t`Property names must be strings or numbers, but got a ${typeName(key)}`,\n\t\t);\n\t}\n\tlet value: unknown;\n\ttry {\n\t\tvalue = getAttr(target, key);\n\t} catch (error) {\n\t\tthrow locate(run, span, error, readingLabel(key));\n\t}\n\tif (value === MISSING) {\n\t\tif (guard) return MISSING;\n\t\tif (strict) throw missingProperty(run, span, target, key);\n\t\treturn null;\n\t}\n\tif (value === undefined) return null;\n\tif (typeof value === \"function\")\n\t\treturn checkValue(run, span, value, String(key));\n\treturn value;\n};\n\n/** Reads literal keys one after another, such as `post.author.name`, in one closure. See `readKeys`. */\nconst pathRead = (root: Compiled, steps: PathStep[]): Compiled => {\n\tconst ev = root.ev;\n\treturn {\n\t\tev: (run, scope) => readKeys(run, ev(run, scope), steps),\n\t\tasync: false,\n\t\tpath: { root, steps },\n\t};\n};\n\n/** Names a property read for an error that one of your getters or lookup methods threw. */\nexport const readingLabel = (key: string | number): string =>\n\t`Reading \"${key}\"`;\n\n/** `set`: assigns where the variable already exists, or declares it in the current scope. */\nexport const assign = (\n\trun: Run,\n\tscope: Scope,\n\tname: string,\n\tvalue: unknown,\n\tspan: Span,\n): void => {\n\tlet owner = ownerOf(scope, name);\n\tif (owner === run.state.globals) {\n\t\tthrow fail(run, span, \"assign-global\", `Cannot assign to global \"${name}\"`);\n\t}\n\tif (owner !== null && run.capture?.section) {\n\t\towner = sectionCopy(scope, owner);\n\t}\n\t(owner ?? scope)[name] = value ?? null;\n};\n\nexport const checkValue = (\n\trun: Run,\n\tspan: Span,\n\tvalue: unknown,\n\tname: string,\n): unknown => {\n\tif (typeof value === \"function\") {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"function-value\",\n\t\t\t`\"${name}\" is a function, and functions in data cannot be used in templates`,\n\t\t\t\"Register it as a function instead, or expose it as a method.\",\n\t\t);\n\t}\n\treturn value;\n};\n\nexport const undefinedVariable = (\n\trun: Run,\n\tspan: Span,\n\tname: string,\n\tscope: Scope,\n) => {\n\treturn fail(\n\t\trun,\n\t\tspan,\n\t\t\"undefined-variable\",\n\t\t`Unknown variable \"${name}\"`,\n\t\tsuggest(name, variableNames(scope)),\n\t);\n};\n\nconst missingProperty = (\n\trun: Run,\n\tspan: Span,\n\ttarget: unknown,\n\tkey: string | number,\n) => {\n\tif (typeof target === \"string\" || target instanceof Markup) {\n\t\treturn fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-property\",\n\t\t\t`Strings have no property \"${key}\"`,\n\t\t\tkey === \"length\" ? 'Use the \"length\" filter.' : \"Use a filter instead.\",\n\t\t);\n\t}\n\tif (Array.isArray(target)) {\n\t\treturn fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-property\",\n\t\t\ttypeof key === \"number\" || /^\\d+$/.test(key)\n\t\t\t\t? `Index ${key} does not exist. The array has ${target.length} ${target.length === 1 ? \"item\" : \"items\"}`\n\t\t\t\t: `Arrays have no property \"${key}\"`,\n\t\t);\n\t}\n\tif (BLOCKED_NAMES.has(String(key))) {\n\t\treturn fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"missing-property\",\n\t\t\t`\"${key}\" can never be read in templates`,\n\t\t);\n\t}\n\treturn fail(\n\t\trun,\n\t\tspan,\n\t\t\"missing-property\",\n\t\t`Property \"${key}\" does not exist on this ${typeName(target)}`,\n\t\tsuggest(String(key), readableNames(target)),\n\t);\n};\n\n/** Whether a chain stops before a member: at an earlier `?.` that stopped, or at this one when its object is null. */\nconst chainStops =\n\t(optional: boolean) =>\n\t(target: unknown): boolean =>\n\t\ttarget === SHORT ||\n\t\t(optional &&\n\t\t\t(target === null || target === undefined || target === MISSING));\n\n/** The items a spread copies, charged against `maxSteps` before they are copied. */\nconst spreadItems = (run: Run, span: Span, value: unknown): unknown[] => {\n\tif (Array.isArray(value)) {\n\t\tlocating(run, span, () => consume(run, value.length));\n\t\treturn value;\n\t}\n\tif (value instanceof Set) {\n\t\tlocating(run, span, () => consume(run, value.size));\n\t\treturn [...value];\n\t}\n\tif (value === null || value === undefined) return [];\n\tthrow fail(\n\t\trun,\n\t\tspan,\n\t\t\"type-error\",\n\t\t`Only arrays and sets can be spread here, but got a ${typeName(value)}`,\n\t);\n};\n\n/** Copies a spread hash's entries, charged against `maxSteps` first. */\nconst copyHash = (\n\trun: Run,\n\tspan: Span,\n\ttarget: Record<string, unknown>,\n\tvalue: unknown,\n) => {\n\tif (value === null || value === undefined) return;\n\tif (isPlainObject(value)) {\n\t\tconst keys = hashKeys(value);\n\t\tlocating(run, span, () => consume(run, keys.length));\n\t\tfor (const key of keys) setOwn(target, key, value[key]);\n\t\treturn;\n\t}\n\tif (value instanceof Map) {\n\t\tconst keys = mapKeys(value);\n\t\tlocating(run, span, () => consume(run, keys.length));\n\t\tfor (const key of keys) setOwn(target, key, value.get(key));\n\t\treturn;\n\t}\n\tthrow fail(\n\t\trun,\n\t\tspan,\n\t\t\"type-error\",\n\t\t`Only hashes can be spread into a hash, but got a ${typeName(value)}`,\n\t);\n};\n\n/**\n * A built-in's options hash of literal keys and values, such as `formatNumber(style: \"currency\")`'s, built once and\n * frozen. The formatting filters cache their work by its identity.\n */\nconst literalHash = (node: Expression): Compiled | null => {\n\tif (node.type !== \"Hash\") return null;\n\tconst result: Record<string, unknown> = {};\n\tfor (const entry of node.entries) {\n\t\tif (entry.type !== \"Property\" || entry.key.type !== \"Literal\") return null;\n\t\tif (entry.value.type !== \"Literal\") return null;\n\t\tsetOwn(result, String(entry.key.value), entry.value.value);\n\t}\n\treturn constant(literalOptions(result));\n};\n\n/**\n * Calls a built-in that never waits with up to four arguments, the filtered or tested value first, without building\n * an argument list. Returns null for more arguments. Matches `locating` for a call that returns no promise.\n */\nconst directCall = (call: Builtin, evs: Ev[], span: Span): Ev | null => {\n\tconst [a, b, c, d] = evs as (Ev | undefined)[];\n\tswitch (evs.length) {\n\t\tcase 0:\n\t\t\treturn (run) => {\n\t\t\t\tstep(run, span);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\tcase 1: {\n\t\t\tconst first = a as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tcase 2: {\n\t\t\tconst first = a as Ev;\n\t\t\tconst second = b as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\tconst y = second(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x, y);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tcase 3: {\n\t\t\tconst first = a as Ev;\n\t\t\tconst second = b as Ev;\n\t\t\tconst third = c as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\tconst y = second(run, scope);\n\t\t\t\tconst z = third(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x, y, z);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tcase 4: {\n\t\t\tconst first = a as Ev;\n\t\t\tconst second = b as Ev;\n\t\t\tconst third = c as Ev;\n\t\t\tconst fourth = d as Ev;\n\t\t\treturn (run, scope) => {\n\t\t\t\tstep(run, span);\n\t\t\t\tconst x = first(run, scope);\n\t\t\t\tconst y = second(run, scope);\n\t\t\t\tconst z = third(run, scope);\n\t\t\t\tconst w = fourth(run, scope);\n\t\t\t\ttry {\n\t\t\t\t\treturn call(run, x, y, z, w);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow locate(run, span, error);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\n/**\n * Moves named arguments of a built-in into their parameter positions, so `round(precision: 2)` works. Unknown names go into a trailing options hash when the built-in takes one. Problems go to `report`.\n */\nexport const placeArguments = (\n\tentry: Extract<CallableEntry, { kind: \"builtin\" }>,\n\targs: Argument[],\n\tlabel: string,\n\treport: (code: string, message: string, span: Span) => void,\n): (Argument | null)[] => {\n\tif (!args.some((arg) => arg.type === \"Named\")) return args;\n\tconst named = args.filter((arg) => arg.type === \"Named\");\n\tif (args.some((arg) => arg.type === \"Spread\")) {\n\t\treport(\n\t\t\t\"invalid-spread\",\n\t\t\t`${label} cannot take named and spread arguments together`,\n\t\t\t(named[0] as Argument).span,\n\t\t);\n\t\treturn args;\n\t}\n\n\tconst params = entry.params ?? [];\n\tconst slots: (Argument | null)[] = args.filter(\n\t\t(arg) => arg.type === \"Positional\",\n\t);\n\tconst options: HashEntry[] = [];\n\tfor (const arg of named) {\n\t\tif (arg.type !== \"Named\") continue;\n\t\tconst index = params.indexOf(arg.name);\n\t\tif (index >= 0) {\n\t\t\tif (slots[index]) {\n\t\t\t\treport(\n\t\t\t\t\t\"duplicate-argument\",\n\t\t\t\t\t`${label} got \"${arg.name}\" more than once`,\n\t\t\t\t\targ.span,\n\t\t\t\t);\n\t\t\t}\n\t\t\twhile (slots.length < index) slots.push(null);\n\t\t\tslots[index] = { type: \"Positional\", value: arg.value, span: arg.span };\n\t\t} else if (entry.options) {\n\t\t\toptions.push({\n\t\t\t\ttype: \"Property\",\n\t\t\t\tkey: { type: \"Literal\", value: arg.name, span: arg.span },\n\t\t\t\tvalue: arg.value,\n\t\t\t\tspan: arg.span,\n\t\t\t});\n\t\t} else {\n\t\t\treport(\n\t\t\t\t\"unknown-argument\",\n\t\t\t\tparams.length === 0\n\t\t\t\t\t? `${label} takes no named arguments`\n\t\t\t\t\t: `${label} has no parameter \"${arg.name}\"`,\n\t\t\t\targ.span,\n\t\t\t);\n\t\t}\n\t}\n\tif (options.length > 0) {\n\t\tconst index = params.length;\n\t\tif (slots[index]) {\n\t\t\treport(\n\t\t\t\t\"duplicate-argument\",\n\t\t\t\t`${label} got options both as a hash and as named arguments`,\n\t\t\t\t(options[0] as HashEntry).span,\n\t\t\t);\n\t\t}\n\t\twhile (slots.length < index) slots.push(null);\n\t\tconst first = options[0] as HashEntry;\n\t\tconst last = options[options.length - 1] as HashEntry;\n\t\tconst span = { start: first.span.start, end: last.span.end };\n\t\tslots[index] = {\n\t\t\ttype: \"Positional\",\n\t\t\tvalue: { type: \"Hash\", entries: options, span },\n\t\t\tspan,\n\t\t};\n\t}\n\tfor (let i = 0; i < slots.length; i++) slots[i] ??= null;\n\treturn slots;\n};\n\n/** Turns evaluated arguments into the list a function receives: spreads expanded, named arguments as one trailing hash. */\nconst buildArguments = (\n\trun: Run,\n\tspan: Span,\n\tshapes: readonly ArgumentShape[],\n\tvalues: readonly unknown[],\n): unknown[] => {\n\tconst result: unknown[] = [];\n\tlet named: Record<string, unknown> | null = null;\n\tfor (let i = 0; i < shapes.length; i++) {\n\t\tconst shape = shapes[i] as ArgumentShape;\n\t\tconst value = values[i];\n\t\tif (shape.kind === \"Positional\") result.push(value);\n\t\telse if (shape.kind === \"Spread\")\n\t\t\tfor (const item of spreadItems(run, span, value)) result.push(item);\n\t\telse {\n\t\t\tnamed ??= {};\n\t\t\tsetOwn(named, shape.name, value);\n\t\t}\n\t}\n\tif (named) result.push(named);\n\tif (result.length > MAX_ARGUMENTS) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"too-many-arguments\",\n\t\t\t`A call can take at most ${MAX_ARGUMENTS} arguments, but got ${result.length}`,\n\t\t\t\"Pass the array itself instead of spreading it.\",\n\t\t);\n\t}\n\treturn result;\n};\n\n/** A short, fast hash of text as up to 7 base-36 digits: 32-bit FNV-1a. Not for anything that must be secret. */\nconst shortHash = (text: string): string => {\n\tlet hash = 0x811c9dc5;\n\tfor (let i = 0; i < text.length; i++) {\n\t\thash = Math.imul(hash ^ text.charCodeAt(i), 0x01000193);\n\t}\n\treturn (hash >>> 0).toString(36);\n};\n\n/** Normalises a `for` loop's value into parallel arrays of values and keys. */\nexport const loopItems = (\n\trun: Run,\n\tspan: Span,\n\tvalue: unknown,\n\twantKeys: boolean,\n): { values: readonly unknown[]; keys: readonly unknown[] | null } => {\n\tif (value === null || value === undefined) return { values: [], keys: null };\n\tif (Array.isArray(value)) return { values: value, keys: null };\n\tif (isPlainObject(value)) {\n\t\tconst keys = hashKeys(value);\n\t\treturn { values: keys.map((key) => value[key]), keys };\n\t}\n\tif (value instanceof Map) {\n\t\tif (wantKeys) {\n\t\t\tconst keys = mapKeys(value);\n\t\t\treturn { values: keys.map((key) => value.get(key)), keys };\n\t\t}\n\t\t// Without keys, the value of every entry whatever its key, except those under blocked names.\n\t\tconst values: unknown[] = [];\n\t\tfor (const [key, item] of value) {\n\t\t\tif (typeof key !== \"string\" || !BLOCKED_NAMES.has(key)) values.push(item);\n\t\t}\n\t\treturn { values, keys: null };\n\t}\n\tif (typeof value === \"string\" || value instanceof Markup) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"not-iterable\",\n\t\t\t\"Cannot loop over a string\",\n\t\t\t'Use \"split\" first.',\n\t\t);\n\t}\n\tif (\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { [Symbol.iterator]?: unknown })[Symbol.iterator] ===\n\t\t\t\"function\"\n\t) {\n\t\tconst values: unknown[] = [];\n\t\tconst limit = run.state.maxSteps;\n\t\tfor (const item of value as Iterable<unknown>) {\n\t\t\tvalues.push(item);\n\t\t\tif (values.length > limit) {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"limit-steps\",\n\t\t\t\t\t\"Iterable has more items than the step limit\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn { values, keys: null };\n\t}\n\tif (\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { [Symbol.asyncIterator]?: unknown })[\n\t\t\tSymbol.asyncIterator\n\t\t] === \"function\"\n\t) {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"not-iterable\",\n\t\t\t\"Cannot loop over an async iterable, because Kiln doesn't wait for one\",\n\t\t\t\"Collect its items into an array in your function first.\",\n\t\t);\n\t}\n\tthrow fail(\n\t\trun,\n\t\tspan,\n\t\t\"not-iterable\",\n\t\t`Cannot loop over a ${typeName(value)}`,\n\t);\n};\n","import { KilnRenderError } from \"../errors.js\";\nimport type { EscapeStrategy } from \"../parser/ast.js\";\nimport {\n\tcontentSets,\n\tmayRunAhead,\n\ttype Pass,\n\tpassesAhead,\n\tpassesFrom,\n\trunAhead,\n} from \"../runtime/ahead.js\";\nimport { escapeHtml, escapeWith } from \"../runtime/escape.js\";\nimport { Markup } from \"../runtime/markup.js\";\nimport {\n\tcontains,\n\toperatorFunction,\n\trangeOperator,\n} from \"../runtime/operators.js\";\nimport {\n\tcheckLength,\n\tconsume,\n\tembed,\n\tembedKeyed,\n\tembedScope,\n\tfail,\n\tlocate,\n\tmarkCaller,\n\tstep,\n\tunhold,\n\twrite,\n} from \"../runtime/render.js\";\nimport { childScope, lookup, type Scope } from \"../runtime/scope.js\";\nimport {\n\tblockScope,\n\ttype Builtin,\n\ttype CompiledTemplate,\n\ttype EnvironmentCore,\n\tfillScope,\n\ttype Out,\n\ttype Run,\n\ttype SlotFill,\n\ttype Stmt,\n} from \"../runtime/types.js\";\nimport {\n\tequals,\n\tisEmpty,\n\tliteralOptions,\n\tMISSING,\n\ttoNumber,\n\ttoStr,\n\ttruthy,\n} from \"../runtime/values.js\";\nimport type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\nimport {\n\tassign,\n\tcheckValue,\n\tcompileTemplate,\n\temitter,\n\ttype GeneratedRuns,\n\tloopItems,\n\treadingLabel,\n\treadMember,\n\tSHORT,\n\tundefinedVariable,\n} from \"./compiler.js\";\n\n/** Changes whenever generated code or the runtime it calls changes shape, so old modules fail loudly. */\nexport const PRECOMPILED_VERSION = 5;\n\n/**\n * A template compiled to JavaScript at build time, the default export of a module `precompile` wrote. Loaders return\n * it in place of the template's source.\n */\nexport type PrecompiledTemplate = {\n\t/** The version of the generated code. */\n\treadonly kiln: number;\n\t/** The `autoescape` option the template was compiled with. */\n\treadonly autoescape: EscapeStrategy | false;\n\t/** The template's source. Kiln still compiles it, for everything the generated code leaves out. */\n\treadonly source: string;\n\t/** Creates the generated statements, given Kiln's runtime. Only Kiln calls it. */\n\treadonly create: (runtime: never) => unknown;\n};\n\n/** Generated statements: where each run of statements starts and ends in the source, and the code that replaces it. */\ntype GeneratedList = readonly (readonly [\n\tstart: number,\n\tend: number,\n\trun: Stmt,\n])[];\n\n/** Checks for a precompiled module's default export, as opposed to template source. */\nexport const isPrecompiled = (value: unknown): value is PrecompiledTemplate =>\n\ttypeof value === \"object\" &&\n\tvalue !== null &&\n\t\"kiln\" in value &&\n\t\"create\" in value;\n\nconst mismatch = (name: string, detail: string): KilnRenderError =>\n\tnew KilnRenderError(\n\t\t\"precompiled-mismatch\",\n\t\t`Precompiled template \"${name}\" ${detail}. Precompile it again`,\n\t\tname,\n\t);\n\n/** Compiles a precompiled template: its source, with the generated statements in place of the ones they cover. */\nexport const compilePrecompiled = (\n\tenv: EnvironmentCore,\n\tname: string,\n\ttemplate: PrecompiledTemplate,\n): CompiledTemplate => {\n\tif (template.kiln !== PRECOMPILED_VERSION) {\n\t\tthrow mismatch(name, \"was made by another version of Kiln\");\n\t}\n\tif (template.autoescape !== env.autoescape) {\n\t\tthrow mismatch(name, 'was compiled with another \"autoescape\" option');\n\t}\n\tconst runs = new Map<number, { end: number; run: Stmt }>();\n\tconst create = template.create as (\n\t\truntime: PrecompiledRuntime,\n\t) => GeneratedList;\n\tfor (const [start, end, run] of create(runtimeFor(env, name))) {\n\t\truns.set(start, { end, run });\n\t}\n\treturn compileTemplate(env, name, template.source, runs as GeneratedRuns);\n};\n\n/**\n * What generated code calls. Every rule templates follow, such as how properties are read and values printed, lives\n * here or in the closure compiler, so both run the same code.\n */\nexport type PrecompiledRuntime = typeof runtime &\n\tReturnType<typeof builtinsFor>;\n\n// Built-ins are looked up per template, so a mismatch names the template.\nconst runtimeFor = (\n\tenv: EnvironmentCore,\n\tname: string,\n): PrecompiledRuntime => ({\n\t...runtime,\n\t...builtinsFor(env, name),\n});\n\nconst builtinsFor = (env: EnvironmentCore, template: string) => {\n\tconst builtin = (\n\t\tkind: \"filter\" | \"test\" | \"function\",\n\t\tentries: EnvironmentCore[\"filters\"],\n\t\tname: string,\n\t): Builtin => {\n\t\tconst entry = entries.get(name);\n\t\tif (entry?.kind !== \"builtin\") {\n\t\t\tthrow mismatch(\n\t\t\t\ttemplate,\n\t\t\t\t`uses the built-in ${kind} \"${name}\", which this environment ${entry ? \"replaces\" : \"does not have\"}`,\n\t\t\t);\n\t\t}\n\t\treturn entry.call;\n\t};\n\treturn {\n\t\tfilter: (name: string) => builtin(\"filter\", env.filters, name),\n\t\ttest: (name: string) => builtin(\"test\", env.tests, name),\n\t\tfn: (name: string) => builtin(\"function\", env.functions, name),\n\t\t/** One of your functions or filters, with the label its errors use. */\n\t\thost: (kind: \"function\" | \"filter\", name: string): HostCall => {\n\t\t\tconst entry = (kind === \"filter\" ? env.filters : env.functions).get(name);\n\t\t\tif (entry?.kind !== \"host\") {\n\t\t\t\tthrow mismatch(\n\t\t\t\t\ttemplate,\n\t\t\t\t\t`uses your ${kind} \"${name}\", which this environment ${entry ? \"has as a built-in\" : \"does not have\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcall: entry.call,\n\t\t\t\trender: entry.render,\n\t\t\t\tlabel: `${kind === \"filter\" ? \"Filter\" : \"Function\"} \"${name}\"`,\n\t\t\t};\n\t\t},\n\t};\n};\n\nconst joinOperator = operatorFunction(\"~\");\n\n/**\n * Runs generated code that may wait: waits for each promise it yields, and sends back the result, or throws the\n * rejection in at the `yield`, where generated code locates it.\n */\nconst drive = (\n\titerator: Iterator<unknown, void, unknown>,\n\tvalue?: unknown,\n): void | Promise<void> => resume(iterator, iterator.next(value));\n\nconst resume = (\n\titerator: Iterator<unknown, void, unknown>,\n\tresult: IteratorResult<unknown, void>,\n): void | Promise<void> => {\n\tif (result.done) return;\n\treturn (result.value as Promise<unknown>).then(\n\t\t(resolved) => resume(iterator, iterator.next(unhold(resolved))),\n\t\t(error: unknown) =>\n\t\t\tresume(\n\t\t\t\titerator,\n\t\t\t\t(iterator.throw as (error: unknown) => IteratorResult<unknown, void>)(\n\t\t\t\t\terror,\n\t\t\t\t),\n\t\t\t),\n\t);\n};\n\nconst NOTHING = (): void => {};\n\n/** What a generated loop that pauses inside a pass calls once the pass is done, after `startAhead`. */\ntype Joining = {\n\t/** The pass is done: joins the passes that ran ahead. */\n\tjoin: () => Promise<void>;\n\t/** The pass failed: lets the passes ahead finish, and waits for them without failing. */\n\tfail: (error: unknown) => Promise<void>;\n};\n\n/** The names a `props` tag declares, and the last frozen list of passed names found to fit them. */\ntype DeclaredProps = {\n\tnames: ReadonlySet<string>;\n\taccepted: readonly string[] | null;\n};\n\n/** One of your functions or filters, as generated code calls it. */\ntype HostCall = {\n\tcall: (...args: unknown[]) => unknown;\n\t/** Made with `withRender`, so it receives `RenderInfo` first. */\n\trender: boolean;\n\tlabel: string;\n};\n\nconst emitters = {\n\thtml: emitter(\"html\"),\n\tattr: emitter(\"attr\"),\n\tjs: emitter(\"js\"),\n\tcss: emitter(\"css\"),\n\turl: emitter(\"url\"),\n\tnone: emitter(false),\n};\n\n/** The helpers generated code calls. Built-ins are added per template by `runtimeFor`. */\nconst runtime = {\n\tMISSING,\n\tSHORT,\n\tobjectPrototype: Object.prototype,\n\tgetPrototypeOf: Object.getPrototypeOf,\n\thasOwn: Object.hasOwn,\n\tstep,\n\t/** Stops a render that counted more steps than `maxSteps`, as `step` does. */\n\tstepLimit: (run: Run, span: Span): never => {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-steps\",\n\t\t\t`Render stopped after ${run.state.maxSteps} steps`,\n\t\t);\n\t},\n\t/** Refuses a range longer than the step limit, as `range` does. */\n\trangeLimit: (run: Run, span: Span, length: number): never => {\n\t\tthrow fail(\n\t\t\trun,\n\t\t\tspan,\n\t\t\t\"limit-steps\",\n\t\t\t`Range of ${length} items is larger than the step limit`,\n\t\t);\n\t},\n\t/** Stops a render whose abort signal fired, as `step` does. */\n\taborted: (run: Run, span: Span): never => {\n\t\tthrow fail(run, span, \"aborted\", \"Render was aborted\");\n\t},\n\twrite,\n\tdrive,\n\tunhold,\n\t/**\n\t * Continues a generated run after a statement that returned a promise, `pending`: the rest of the run starts at\n\t * once, ahead of it, when it may, or else once the statement is done. See `runAhead`.\n\t */\n\trestAhead: (\n\t\trun: Run,\n\t\tout: Out,\n\t\tpending: Promise<void>,\n\t\trest: (run: Run, out: Out) => void | Promise<void>,\n\t\tspan: Span,\n\t): Promise<void> =>\n\t\tmayRunAhead(run.state)\n\t\t\t? runAhead(run, out, pending, rest, span)\n\t\t\t: pending.then(() => rest(run, out)),\n\tcontentSets,\n\t/**\n\t * Continues a generated loop after a pass that returned a promise, `pending`: passes `from` to `to` run one at a\n\t * time with `pass`, ahead of it when they may, see `passesAhead`. `sets` are the variables the loop's body sets,\n\t * and `elsewhere` whether it places content from elsewhere.\n\t */\n\tpassAhead: (\n\t\trun: Run,\n\t\tscope: Scope,\n\t\tout: Out,\n\t\tpending: Promise<void>,\n\t\tsets: readonly string[],\n\t\telsewhere: boolean,\n\t\tfrom: number,\n\t\tto: number,\n\t\tpass: Pass,\n\t\tspan: Span,\n\t): Promise<void> =>\n\t\tpassesFrom(\n\t\t\trun,\n\t\t\tout,\n\t\t\tpending,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tpass,\n\t\t\tspan,\n\t\t\tpassesAhead(run, scope, sets, elsewhere),\n\t\t),\n\t/**\n\t * For a generated loop that pauses inside a pass: starts passes `from` to `to` ahead of it when they may, and returns\n\t * what the loop calls once the pass is done. Returns null when they may not, and the loop carries on as usual.\n\t */\n\tstartAhead: (\n\t\trun: Run,\n\t\tscope: Scope,\n\t\tout: Out,\n\t\tsets: readonly string[],\n\t\telsewhere: boolean,\n\t\tfrom: number,\n\t\tto: number,\n\t\tpass: Pass,\n\t\tspan: Span,\n\t): Joining | null => {\n\t\tif (!mayRunAhead(run.state) || !passesAhead(run, scope, sets, elsewhere)) {\n\t\t\treturn null;\n\t\t}\n\t\tlet done = NOTHING;\n\t\tlet failed: (error: unknown) => void = NOTHING;\n\t\tconst pending = new Promise<void>((resolve, reject) => {\n\t\t\tdone = resolve;\n\t\t\tfailed = reject;\n\t\t});\n\t\tconst joined = passesFrom(run, out, pending, from, to, pass, span, true);\n\t\treturn {\n\t\t\tjoin: () => {\n\t\t\t\tdone();\n\t\t\t\treturn joined;\n\t\t\t},\n\t\t\tfail: (error) => {\n\t\t\t\tfailed(error);\n\t\t\t\treturn joined.then(NOTHING, NOTHING);\n\t\t\t},\n\t\t};\n\t},\n\tembed,\n\tembedScope,\n\tembedKeyed,\n\tchildScope,\n\ttruthy,\n\tisEmpty,\n\tequals,\n\tescapeHtml,\n\treadMember,\n\tloopItems,\n\tcheckValue,\n\tassign,\n\t/**\n\t * Calls one of your functions or filters as the closures do. Errors it throws are located here, and a promise it\n\t * returns is located where generated code waits for it, with `hostError`. A thenable becomes a promise, and a\n\t * promise tells a streamed render it is waiting.\n\t */\n\tcallHost: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\thost: HostCall,\n\t\targs: unknown[],\n\t): unknown => {\n\t\tlet value: unknown;\n\t\ttry {\n\t\t\tvalue = host.render ? host.call(run.info, ...args) : host.call(...args);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error, host.label);\n\t\t}\n\t\tif (value instanceof Promise) {\n\t\t\trun.state.stream?.wait();\n\t\t\treturn value;\n\t\t}\n\t\tif (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\ttypeof (value as { then?: unknown }).then === \"function\"\n\t\t) {\n\t\t\trun.state.stream?.wait();\n\t\t\treturn Promise.resolve(value);\n\t\t}\n\t\treturn value;\n\t},\n\t/**\n\t * Whether a block that `placeBlock` placed may have set a variable. Any version of any block may run inside it,\n\t * through `parent()` and `block()`, so this is whether any of them sets one. Templates define few blocks.\n\t */\n\tblockSets: (run: Run): boolean => {\n\t\tfor (const entries of run.blocks.values()) {\n\t\t\tfor (const entry of entries) if (entry.def.sets) return true;\n\t\t}\n\t\treturn false;\n\t},\n\t/**\n\t * Locates an error thrown in generated code at the last property it read inline, where a getter in your data can\n\t * throw. Every other error is located already.\n\t */\n\treadError: (\n\t\trun: Run,\n\t\tat: readonly [Span, string] | null,\n\t\terror: unknown,\n\t): unknown =>\n\t\tat === null ? error : locate(run, at[0], error, readingLabel(at[1])),\n\t/** Locates the rejection of a promise one of your functions or filters returned. */\n\thostError: (run: Run, span: Span, host: HostCall, error: unknown) =>\n\t\tlocate(run, span, error, host.label),\n\t/** Whether a value is a plain object, whose own properties templates may read directly. */\n\tplain: (value: unknown): boolean => {\n\t\tif (typeof value !== \"object\" || value === null) return false;\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\treturn proto === Object.prototype || proto === null;\n\t},\n\toperator: operatorFunction,\n\toptions: literalOptions,\n\t/** Spans from a flat list of start and end offsets. */\n\tspans: (offsets: readonly number[]): Span[] => {\n\t\tconst spans: Span[] = [];\n\t\tfor (let i = 0; i < offsets.length; i += 2) {\n\t\t\tspans.push({\n\t\t\t\tstart: offsets[i] as number,\n\t\t\t\tend: offsets[i + 1] as number,\n\t\t\t});\n\t\t}\n\t\treturn spans;\n\t},\n\t/** A variable from outside the generated code. Missing variables fail in strict mode and read as null otherwise. */\n\tname: (run: Run, span: Span, scope: Scope, name: string): unknown => {\n\t\tconst value = lookup(scope, name);\n\t\tif (value === undefined) {\n\t\t\tif (run.state.env.strict) {\n\t\t\t\tthrow undefinedVariable(run, span, name, scope);\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn typeof value === \"function\"\n\t\t\t? checkValue(run, span, value, name)\n\t\t\t: value;\n\t},\n\t/** A variable where a missing one is allowed, such as the input of `default`. */\n\tguardedName: (run: Run, span: Span, scope: Scope, name: string): unknown => {\n\t\tconst value = lookup(scope, name);\n\t\treturn value === undefined ? MISSING : checkValue(run, span, value, name);\n\t},\n\t/** Prints a value with an escaping strategy, or none. */\n\tprint: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tvalue: unknown,\n\t\tstrategy: keyof typeof emitters,\n\t): string => {\n\t\ttry {\n\t\t\treturn emitters[strategy](value);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall0: (run: Run, span: Span, fn: Builtin): unknown => {\n\t\ttry {\n\t\t\treturn fn(run);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall1: (run: Run, span: Span, fn: Builtin, a: unknown): unknown => {\n\t\ttry {\n\t\t\treturn fn(run, a);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall2: (run: Run, span: Span, fn: Builtin, a: unknown, b: unknown) => {\n\t\ttry {\n\t\t\treturn fn(run, a, b);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall3: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tfn: Builtin,\n\t\ta: unknown,\n\t\tb: unknown,\n\t\tc: unknown,\n\t): unknown => {\n\t\ttry {\n\t\t\treturn fn(run, a, b, c);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\tcall4: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tfn: Builtin,\n\t\ta: unknown,\n\t\tb: unknown,\n\t\tc: unknown,\n\t\td: unknown,\n\t): unknown => {\n\t\ttry {\n\t\t\treturn fn(run, a, b, c, d);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** A binary operator without short-circuit behaviour. */\n\tbinary: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tapply: (left: unknown, right: unknown) => unknown,\n\t\tleft: unknown,\n\t\tright: unknown,\n\t): unknown => {\n\t\ttry {\n\t\t\treturn apply(left, right);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** `in`, which charges for the items it searches. */\n\tcontains: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tneedle: unknown,\n\t\thaystack: unknown,\n\t): boolean => {\n\t\ttry {\n\t\t\treturn contains(needle, haystack, (count) => consume(run, count));\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** `~`, whose result may not be longer than the output limit. */\n\tconcat: (run: Run, span: Span, left: unknown, right: unknown): string => {\n\t\ttry {\n\t\t\treturn checkLength(run, joinOperator(left, right) as string);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\trange: (run: Run, span: Span, left: unknown, right: unknown): number[] => {\n\t\ttry {\n\t\t\tconst items = rangeOperator(left, right, run.state.maxSteps);\n\t\t\tconsume(run, items.length);\n\t\t\treturn items;\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** Unary `-` and `+` on a value that is not a number, which fails. */\n\ttoNumber: (run: Run, span: Span, value: unknown, operator: string) => {\n\t\ttry {\n\t\t\treturn toNumber(value, operator);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** One part of an interpolated string. */\n\tstr: (run: Run, span: Span, value: unknown): string => {\n\t\tif (typeof value === \"string\") return value;\n\t\ttry {\n\t\t\treturn toStr(value);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** An interpolated string, which may not be longer than the output limit. */\n\tjoined: (run: Run, span: Span, text: string): string => {\n\t\ttry {\n\t\t\treturn checkLength(run, text);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** The `raw` filter. */\n\traw: (run: Run, span: Span, value: unknown, strategy: EscapeStrategy) => {\n\t\tif (value instanceof Markup) {\n\t\t\treturn value.strategy === strategy\n\t\t\t\t? value\n\t\t\t\t: new Markup(value.value, strategy);\n\t\t}\n\t\treturn new Markup(runtime.str(run, span, value), strategy);\n\t},\n\t/** The `escape` filter, with a strategy known to be valid. Stops once the escaped text passes the output limit. */\n\tescape: (run: Run, span: Span, value: unknown, strategy: EscapeStrategy) => {\n\t\tif (value instanceof Markup && value.strategy === strategy) return value;\n\t\tconst text = runtime.str(run, span, value);\n\t\ttry {\n\t\t\treturn new Markup(\n\t\t\t\tescapeWith(text, strategy, run.state.maxSize),\n\t\t\t\tstrategy,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow locate(run, span, error);\n\t\t}\n\t},\n\t/** Renders a component's fill for a slot, recording the slot's location on errors. */\n\tfillSlot: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tfill: SlotFill,\n\t\tout: Out,\n\t): void | Promise<void> => {\n\t\ttry {\n\t\t\t// The fill renders in the capture the slot is in, such as a cached section.\n\t\t\tconst result = fill.body(\n\t\t\t\tfill.run.within(run.capture, run.blockDepth),\n\t\t\t\tfillScope(fill, run),\n\t\t\t\tout,\n\t\t\t);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow markCaller(run, span, error);\n\t\t}\n\t},\n\t/** Places a block: the most derived definition, which may come from a child template. */\n\tplaceBlock: (\n\t\trun: Run,\n\t\tspan: Span,\n\t\tname: string,\n\t\tscope: Scope,\n\t\tout: Out,\n\t): void | Promise<void> => {\n\t\tconst entry = run.blocks.get(name)?.[0];\n\t\tif (!entry) return;\n\t\t// The block renders in the capture it is placed in, such as a cached section.\n\t\tconst blockRun = entry.run.within(run.capture, run.blockDepth);\n\t\tif (entry.run.template === run.template) {\n\t\t\treturn entry.def.body(blockRun, blockScope(entry.def, scope), out);\n\t\t}\n\t\t// A block defined in another template records where it was placed.\n\t\ttry {\n\t\t\tconst result = entry.def.body(\n\t\t\t\tblockRun,\n\t\t\t\tblockScope(entry.def, scope),\n\t\t\t\tout,\n\t\t\t);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn result.catch((error: unknown) => {\n\t\t\t\t\tthrow markCaller(run, span, error);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow markCaller(run, span, error);\n\t\t}\n\t},\n\t/**\n\t * In strict mode, fails when the caller passed a variable `props` doesn't declare. Callers that make the scope\n\t * themselves pass the same frozen list each time, so the last list that passed is remembered.\n\t */\n\tcheckPassed: (run: Run, span: Span, declared: DeclaredProps) => {\n\t\tconst passed = run.passed;\n\t\tif (passed === null || passed === declared.accepted) return;\n\t\tif (!run.state.env.strict) return;\n\t\tfor (let i = 0; i < passed.length; i++) {\n\t\t\tconst key = passed[i] as string;\n\t\t\tif (!declared.names.has(key) && key !== \"slots\") {\n\t\t\t\tthrow fail(\n\t\t\t\t\trun,\n\t\t\t\t\tspan,\n\t\t\t\t\t\"unknown-prop\",\n\t\t\t\t\t`\"${key}\" was passed to ${run.template.name}, which does not declare it in \"props\"`,\n\t\t\t\t\tsuggest(key, declared.names),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (Object.isFrozen(passed)) declared.accepted = passed;\n\t},\n\t/** The names a `props` tag declares, for `checkPassed`. */\n\tdeclared: (names: string[]): DeclaredProps => ({\n\t\tnames: new Set(names),\n\t\taccepted: null,\n\t}),\n\t/** A required prop the caller didn't pass: fails in strict mode, and is null otherwise. */\n\tmissingProp: (run: Run, span: Span, name: string): null => {\n\t\tif (run.state.env.strict) {\n\t\t\tthrow fail(\n\t\t\t\trun,\n\t\t\t\tspan,\n\t\t\t\t\"missing-prop\",\n\t\t\t\t`Required prop \"${name}\" was not passed to ${run.template.name}`,\n\t\t\t);\n\t\t}\n\t\treturn null;\n\t},\n\t/** The `loop` hash, for templates that use it whole. */\n\tloop: (index: number, length: number) => ({\n\t\tindex: index + 1,\n\t\tindex0: index,\n\t\trevIndex: length - index,\n\t\trevIndex0: length - index - 1,\n\t\tfirst: index === 0,\n\t\tlast: index === length - 1,\n\t\tlength,\n\t}),\n};\n","import {\n\ttype Argument,\n\tDEFAULT_SLOT,\n\tESCAPE_STRATEGIES,\n\ttype EscapeStrategy,\n\ttype Expression,\n\ttype Statement,\n\ttype TemplateNode,\n} from \"../parser/ast.js\";\nimport type { EnvironmentCore } from \"../runtime/types.js\";\nimport { BLOCKED_NAMES } from \"../runtime/values.js\";\nimport type { Span } from \"../source.js\";\nimport {\n\tcontainsNode,\n\temitter,\n\tmayWrite,\n\tplaceArguments,\n\tsetsVariables,\n} from \"./compiler.js\";\nimport { effectsOf, planOf } from \"./effects.js\";\nimport { PRECOMPILED_VERSION } from \"./precompiled.js\";\n\n/**\n * Generates JavaScript for a template that compiled without problems, for `precompile`.\n *\n * Runs of statements become functions: text, outputs, `if`, `for`, `set`, `autoescape`, untyped `props` without a\n * rest prop, includes, components, slots and block placements, with expressions that use variables, literals,\n * operators and built-in functions, filters and tests. Your own functions and filters, which may return promises, are generated when a call\n * is a whole `set` value, loop or output. Code that may wait continues in another function, or pauses as a generator,\n * only when a promise comes back; see `#function`. Everything else, such as macros and arrow functions, is left to\n * the closure compiler, which compiles the template's source as usual and puts the generated functions in place of\n * the runs they cover.\n *\n * Generated code calls the helpers in `precompiled.ts` for every rule templates follow, so it behaves as the closures\n * do. Nothing from the template reaches the generated source except through `JSON.stringify`, a strict identifier\n * check or a number, so a template cannot inject code.\n */\nexport const generateModule = (\n\tenv: EnvironmentCore,\n\tast: TemplateNode,\n\tsource: string,\n): string => new Generator(env, ast).module(source);\n\n/** Thrown for anything the generator leaves to the closure compiler. */\nclass Unsupported extends Error {}\n\nconst unsupported = (): never => {\n\tthrow new Unsupported();\n};\n\n/**\n * What a name means inside generated code: a JavaScript local, or a loop's `loop` hash. A local has a flag for\n * whether it holds a plain object, set once when it is bound, so reading its properties skips that check.\n */\ntype Binding =\n\t| { kind: \"value\"; js: string; plain: string }\n\t| { kind: \"loop\"; index: string; length: string };\n\n/** A variable from outside generated code, looked up once, and whether it is a plain object. */\ntype Cached = { value: string; plain: string };\n\ntype Context = {\n\tbindings: ReadonlyMap<string, Binding>;\n\tstrategy: EscapeStrategy | false;\n\t/** Inside a generated loop, whose variables are JavaScript locals rather than scope variables. */\n\tinLoop: boolean;\n\t/** At the top level of a run, where a wait can end the function and continue in the next. See `#function`. */\n\ttop: boolean;\n\t/**\n\t * At the top level of a loop function's pass, where a call to your function can end the function too, and the\n\t * pass continue with its value in the next. See `#loopFunction`.\n\t */\n\tpass: boolean;\n\t/** The JavaScript name of the scope variables are looked up and set in: the function's, or a loop pass's. */\n\tscope: string;\n};\n\n/** One generated function: a run, or a component's fill. */\ntype FunctionState = {\n\t/** Temporaries it declares. */\n\ttemps: number;\n\t/**\n\t * Variables from outside generated code, each looked up once. Code that may change a variable, such as `set`, a\n\t * block or a component's fills, forgets the lookups it may have changed.\n\t */\n\tvariables: Map<string, Cached>;\n\t/** Plain-object flags of variables that property reads use. Only these are set; see `PLAIN`. */\n\tplainUsed: Set<string>;\n\t/** It may wait for a promise. */\n\twaits: boolean;\n\t/** It may wait somewhere other than at the end of a top-level statement, such as in a loop, so it is a generator. */\n\twaitsInside: boolean;\n\t/** Waits it has somewhere a run can't continue from, such as inside an `if`. See `#list`. */\n\tinner: number;\n\t/** Top-level waits that start the rest of the run ahead of them. See `#list`. */\n\taheadWaits: number;\n\t/**\n\t * It reads properties inline, where a getter in your data may throw. Each read puts its place in `at`, so the\n\t * function can locate the error; see `#guard`.\n\t */\n\treads: boolean;\n};\n\nconst newFunction = (): FunctionState => ({\n\ttemps: 0,\n\tvariables: new Map(),\n\tplainUsed: new Set(),\n\twaits: false,\n\twaitsInside: false,\n\tinner: 0,\n\taheadWaits: 0,\n\treads: false,\n});\n\n/**\n * Stands for a wait in generated lines until `#function` knows whether it yields or continues in a new function.\n *\n * Markers use control characters because `JSON.stringify` escapes them, so text from a template never contains one.\n */\nconst WAIT = \"\\u0000wait \";\n\n// oxlint-disable-next-line no-control-regex -- matches the marker, see `WAIT`\nconst WAIT_LINE = /^(\\t*)\\u0000wait (t\\d+)( ahead| guarded)?$/;\n\n/**\n * Stands for waiting for a call to one of your functions at the top of a loop function's pass, `\\u0000value t S X`:\n * the call's result, its span and the function. When the result is a promise, the pass continues in another function\n * with its value. See `#loopFunction`.\n */\nconst VALUE = \"\\u0000value \";\n\n// oxlint-disable-next-line no-control-regex -- matches the marker, see `WAIT`\nconst VALUE_LINE = /^(\\t*)\\u0000value (t\\d+) (S\\[\\d+\\]) (X\\d+)$/;\n\n/** Marks a wait whose statement lets the rest of the run start ahead of it, in `WAIT` lines. See `#list`. */\nconst AHEAD = \" ahead\";\n\n/** Marks a wait that lets the rest of the run start ahead of it unless the render's blocks or fills set variables. */\nconst GUARDED = \" guarded\";\n\n/**\n * Stands for starting the passes after the current one, where a loop that pauses inside its passes is about to wait.\n * `#loopGenerator` writes it out, and other functions drop it.\n */\nconst FORK = \"\\u0003fork\";\n\n/**\n * Stands for setting a variable's plain-object flag, `\\u0001flag:value\\u0001`, until `#function` knows whether any\n * property read uses the flag. It becomes `, flag = plain(value)` or nothing.\n */\n// oxlint-disable-next-line no-control-regex -- matches the marker, see `WAIT`\nconst PLAIN = /\\u0001(f\\d+):([\\w$]+)\\u0001/g;\n\n/**\n * Stands for forgetting every variable lookup, until the function's lookups are all known: in a loop, a lookup made\n * later in the pass is cached by the next pass too. `#function` writes it out.\n */\nconst FORGET_ALL = \"\\u0002forget\";\n\nconst setPlain = (flag: string, value: string) =>\n\t`\\u0001${flag}:${value}\\u0001`;\n\n/** The helpers generated code takes from the runtime. See `precompiled.ts`. */\nconst HELPERS = [\n\t\"MISSING\",\n\t\"SHORT\",\n\t\"objectPrototype\",\n\t\"getPrototypeOf\",\n\t\"hasOwn\",\n\t\"step\",\n\t\"stepLimit\",\n\t\"rangeLimit\",\n\t\"aborted\",\n\t\"write\",\n\t\"drive\",\n\t\"unhold\",\n\t\"restAhead\",\n\t\"contentSets\",\n\t\"passAhead\",\n\t\"startAhead\",\n\t\"truthy\",\n\t\"isEmpty\",\n\t\"equals\",\n\t\"escapeHtml\",\n\t\"readMember\",\n\t\"loopItems\",\n\t\"checkValue\",\n\t\"plain\",\n\t\"name\",\n\t\"guardedName\",\n\t\"print\",\n\t\"call0\",\n\t\"call1\",\n\t\"call2\",\n\t\"call3\",\n\t\"call4\",\n\t\"binary\",\n\t\"contains\",\n\t\"concat\",\n\t\"range\",\n\t\"toNumber\",\n\t\"str\",\n\t\"joined\",\n\t\"raw\",\n\t\"escape\",\n\t\"loop\",\n\t\"embed\",\n\t\"embedScope\",\n\t\"embedKeyed\",\n\t\"assign\",\n\t\"callHost\",\n\t\"hostError\",\n\t\"childScope\",\n\t\"fillSlot\",\n\t\"placeBlock\",\n\t\"checkPassed\",\n\t\"missingProp\",\n\t\"readError\",\n\t\"blockSets\",\n];\n\n/** Fields of the `loop` hash, as JavaScript over the loop's index and length. */\nconst LOOP_FIELDS: Record<string, (index: string, length: string) => string> = {\n\tindex: (i) => `(${i} + 1)`,\n\tindex0: (i) => i,\n\trevIndex: (i, n) => `(${n} - ${i})`,\n\trevIndex0: (i, n) => `(${n} - ${i} - 1)`,\n\tfirst: (i) => `(${i} === 0)`,\n\tlast: (i, n) => `(${i} === ${n} - 1)`,\n\tlength: (_i, n) => n,\n};\n\n/** Operators with a JavaScript equivalent when both sides are numbers. */\nconst NUMBER_OPERATORS = new Set([\n\t\"<\",\n\t\">\",\n\t\"<=\",\n\t\">=\",\n\t\"+\",\n\t\"-\",\n\t\"*\",\n\t\"/\",\n\t\"%\",\n]);\n\n/** Names of a generated loop's locals. */\ntype LoopNames = {\n\tid: number;\n\tspan: string;\n\t/** For a loop whose body uses `set`: the scope each pass makes, as the closures do, and the scope it is made in. */\n\tscope: string | null;\n\touter: string;\n\t/** Variables the body sets, whose lookups each pass forgets. */\n\tsets: string[];\n\tvalues: string;\n\tlength: string;\n\tkeys: string;\n\tindex: string;\n\tvalue: string;\n\tkey: string;\n\thasKeys: boolean;\n};\n\n/** The ends of a range of integer literals, such as `1..5` or `-2..2`, or null for any other expression. */\nconst literalRange = (\n\tnode: Expression,\n): { from: number; to: number } | null => {\n\tif (node.type !== \"Binary\" || node.operator !== \"..\") return null;\n\tconst integer = (side: Expression): number | null => {\n\t\tif (side.type === \"Literal\") {\n\t\t\treturn Number.isInteger(side.value) ? (side.value as number) : null;\n\t\t}\n\t\tif (\n\t\t\tside.type === \"Unary\" &&\n\t\t\tside.operator === \"-\" &&\n\t\t\tside.operand.type === \"Literal\" &&\n\t\t\tNumber.isInteger(side.operand.value)\n\t\t) {\n\t\t\treturn -(side.operand.value as number);\n\t\t}\n\t\treturn null;\n\t};\n\tconst from = integer(node.left);\n\tconst to = integer(node.right);\n\treturn from === null || to === null ? null : { from, to };\n};\n\n/** A call to one of your functions or filters. See `#isHostCall`. */\ntype HostCallNode =\n\t| (Extract<Expression, { type: \"Call\" }> & {\n\t\t\tcallee: Extract<Expression, { type: \"Name\" }>;\n\t })\n\t| Extract<Expression, { type: \"Filter\" }>;\n\n/** An include's or component's template name in generated code. See `#target`. */\ntype TemplateTarget =\n\t| { kind: \"value\"; js: string }\n\t| {\n\t\t\tkind: \"keyed\";\n\t\t\tprefix: string;\n\t\t\tkey: string;\n\t\t\tjoined: string;\n\t\t\tnameSpan: string;\n\t };\n\n/** A `with` value whose keys are known, or none, so generated code makes the template's scope itself. */\nconst isKnownWith = (node: Expression | null): boolean =>\n\tnode === null ||\n\t(node.type === \"Hash\" &&\n\t\tnode.entries.every(\n\t\t\t(entry) =>\n\t\t\t\tentry.type === \"Property\" &&\n\t\t\t\tentry.key.type === \"Literal\" &&\n\t\t\t\t!BLOCKED_NAMES.has(String(entry.key.value)),\n\t\t));\n\n/** Names that `set` statements set, directly or inside other statements. */\nconst setsIn = (\n\tstatements: Statement[],\n\tnames = new Set<string>(),\n): Set<string> => {\n\tfor (const statement of statements) {\n\t\tif (statement.type === \"Set\") names.add(statement.name);\n\t\telse if (statement.type === \"If\") {\n\t\t\tfor (const branch of statement.branches) setsIn(branch.body, names);\n\t\t\tsetsIn(statement.alternate ?? [], names);\n\t\t} else if (statement.type === \"For\") {\n\t\t\tsetsIn(statement.body, names);\n\t\t\tsetsIn(statement.alternate ?? [], names);\n\t\t} else if (statement.type === \"Autoescape\" || statement.type === \"Slot\") {\n\t\t\tsetsIn(statement.body, names);\n\t\t}\n\t}\n\treturn names;\n};\n\n/** Characters of text a loop gathers before writing them out. */\nconst FLUSH_AT = 4096;\n\n/** Longest `else if` chain written as one. Longer chains become a flat labelled block. */\nconst MAX_ELSE_IF = 16;\n\n/** Deepest expression the generator writes. Deeper ones stay with the closure compiler. */\nconst MAX_DEPTH = 100;\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\n/** A literal as JavaScript. */\nconst literal = (value: unknown): string => {\n\tif (value === null) return \"null\";\n\tif (typeof value === \"string\") return JSON.stringify(value);\n\tif (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n\tif (typeof value === \"number\" && Number.isFinite(value)) {\n\t\treturn Object.is(value, -0) ? \"-0\" : String(value);\n\t}\n\treturn unsupported();\n};\n\nconst BOOLEAN_OPERATORS = new Set([\n\t\"and\",\n\t\"or\",\n\t\"==\",\n\t\"!=\",\n\t\"<\",\n\t\">\",\n\t\"<=\",\n\t\">=\",\n\t\"in\",\n\t\"not in\",\n\t\"starts with\",\n\t\"ends with\",\n]);\n\n/** Whether generated code for an expression is always a JavaScript boolean. */\nconst isBoolean = (node: Expression, context: Context): boolean => {\n\tswitch (node.type) {\n\t\tcase \"Literal\":\n\t\t\treturn typeof node.value === \"boolean\";\n\t\tcase \"Binary\":\n\t\t\treturn BOOLEAN_OPERATORS.has(node.operator);\n\t\tcase \"Unary\":\n\t\t\treturn node.operator === \"not\";\n\t\tcase \"Test\":\n\t\t\treturn true;\n\t\tcase \"Member\":\n\t\t\treturn (\n\t\t\t\tnode.object.type === \"Name\" &&\n\t\t\t\tcontext.bindings.get(node.object.name)?.kind === \"loop\" &&\n\t\t\t\tnode.property.type === \"Literal\" &&\n\t\t\t\t(node.property.value === \"first\" || node.property.value === \"last\")\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n/**\n * Whether a local holds a plain object, written out where it is used rather than calling `plain`, so V8 can turn the\n * prototype check into a field load for the few shapes each place sees. `q` is a scratch local every function has.\n */\nconst isPlainCode = (value: string): string =>\n\t`(typeof ${value} === \"object\" && ${value} !== null && ((q = getPrototypeOf(${value})) === objectPrototype || q === null))`;\n\n/** Reading a known key, as `.key` when it is an identifier. */\nconst access = (key: string): string =>\n\tIDENTIFIER.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;\n\nconst isBlank = (statement: Statement) =>\n\tstatement.type === \"Text\" && statement.value.trim() === \"\";\n\nconst indent = (lines: string[]): string[] => lines.map((line) => `\\t${line}`);\n\n/** Lines without `FORK` markers, for functions that never start passes ahead. */\nconst dropForks = (lines: string[]): string[] =>\n\tlines.filter((line) => line.trim() !== FORK);\n\nclass Generator {\n\treadonly #env: EnvironmentCore;\n\treadonly #ast: TemplateNode;\n\t/** Names that call macros rather than functions: local macros and macros imported by name. */\n\treadonly #macros = new Set<string>();\n\t/** Start and end offsets of every span generated code refers to, flattened. */\n\treadonly #spans: number[] = [];\n\treadonly #spanIndex = new Map<string, number>();\n\t/** Declarations made once when the module is loaded, such as built-ins and frozen option hashes. */\n\treadonly #constants: string[] = [];\n\treadonly #constantNames = new Map<string, string>();\n\treadonly #runs: string[] = [];\n\t/** Generator functions for runs that may wait, declared once in `create`. */\n\treadonly #declarations: string[] = [];\n\t#generators = 0;\n\t/** Lists the closure compiler compiles itself, such as the bodies of blocks a run places, searched for runs later. */\n\treadonly #pending: [Statement[], EscapeStrategy | false][] = [];\n\t/** The function being generated. */\n\t#fn = newFunction();\n\t/** Plain-object flags of loop variables that generated code reads, so loops only set the ones used. */\n\treadonly #plainUsed = new Set<string>();\n\t/** Loops so far, for local names unique in the module, so a fill's loops never hide the loop around it. */\n\t#loops = 0;\n\t#depth = 0;\n\t/**\n\t * Whether the top-level statement being generated lets the rest of the run start while it waits: `AHEAD`, or\n\t * `GUARDED` when only for renders whose blocks and fills set nothing. See `#list`.\n\t */\n\t#forkable: typeof AHEAD | typeof GUARDED | null = null;\n\n\tconstructor(env: EnvironmentCore, ast: TemplateNode) {\n\t\tthis.#env = env;\n\t\tthis.#ast = ast;\n\t\tfor (const statement of ast.body) {\n\t\t\tif (statement.type === \"Macro\") this.#macros.add(statement.name);\n\t\t\tif (statement.type === \"FromImport\") {\n\t\t\t\tfor (const entry of statement.names) this.#macros.add(entry.alias);\n\t\t\t}\n\t\t}\n\t}\n\n\tmodule(source: string): string {\n\t\t// A child template's top level only defines blocks, so only the lists inside it run.\n\t\tconst child = this.#ast.body.some(\n\t\t\t(statement) => statement.type === \"Extends\",\n\t\t);\n\t\tthis.#list(this.#ast.body, this.#env.autoescape, child, true);\n\t\tfor (let next = this.#pending.shift(); next; next = this.#pending.shift()) {\n\t\t\tthis.#list(next[0], next[1], false);\n\t\t}\n\t\treturn [\n\t\t\t\"// Precompiled by Kiln. Don't edit this file: precompile the template again.\",\n\t\t\t\"export default {\",\n\t\t\t`\\tkiln: ${PRECOMPILED_VERSION},`,\n\t\t\t`\\tautoescape: ${JSON.stringify(this.#env.autoescape)},`,\n\t\t\t`\\tsource: ${JSON.stringify(source)},`,\n\t\t\t\"\\tcreate(rt) {\",\n\t\t\t`\\t\\tconst { ${HELPERS.join(\", \")} } = rt;`,\n\t\t\t`\\t\\tconst S = rt.spans([${this.#spans.join(\", \")}]);`,\n\t\t\t...this.#constants.map((line) => `\\t\\t${line}`),\n\t\t\t...this.#declarations.map((line) => `\\t\\t${line}`),\n\t\t\t\"\\t\\treturn [\",\n\t\t\t...this.#runs,\n\t\t\t\"\\t\\t];\",\n\t\t\t\"\\t},\",\n\t\t\t\"};\",\n\t\t\t\"\",\n\t\t].join(\"\\n\");\n\t}\n\n\t// Runs\n\n\t/**\n\t * Finds runs of statements to generate in a list. A statement that can't be generated stays with the closure\n\t * compiler, and the lists inside it are searched in turn. With `searchOnly`, only the lists inside are searched.\n\t * `top` is set for the template's top level.\n\t */\n\t#list(\n\t\tlist: Statement[],\n\t\tstrategy: EscapeStrategy | false,\n\t\tsearchOnly: boolean,\n\t\ttop = false,\n\t): void {\n\t\tconst context: Context = {\n\t\t\tbindings: new Map(),\n\t\t\tstrategy,\n\t\t\tinLoop: false,\n\t\t\ttop: true,\n\t\t\tpass: false,\n\t\t\tscope: \"scope\",\n\t\t};\n\t\t// Which statements may start while each waits, as the closures find it. See `planOf`. Runs are cut by the plan\n\t\t// for renders whose blocks and fills set nothing, and the closures pick a plan for each render.\n\t\tconst effects = searchOnly\n\t\t\t? []\n\t\t\t: list.map((statement) => effectsOf([statement], this.#env));\n\t\tconst plan = planOf(effects, false);\n\t\tconst strict = planOf(effects, true);\n\t\t// Statements a run must end at, so the closures' sequence can start the statements after them early.\n\t\tconst stops: number[] = [];\n\t\t// A layout's blocks get runs of their own. While the page's top-level statements wait, a block waits for them,\n\t\t// and the runs between blocks can start; see `Gate`.\n\t\tif (top) {\n\t\t\tlist.forEach((statement, index) => {\n\t\t\t\tif (statement.type === \"Block\") stops.push(index - 1, index);\n\t\t\t});\n\t\t}\n\t\tconst stopFrom = (index: number) =>\n\t\t\tMath.min(list.length - 1, ...stops.filter((stop) => stop >= index));\n\t\tlet i = 0;\n\t\twhile (i < list.length) {\n\t\t\tif (searchOnly) {\n\t\t\t\tthis.#children(list[i] as Statement, strategy);\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#fn = newFunction();\n\t\t\tlet groups: string[][] = [];\n\t\t\tlet end = i;\n\t\t\tlet work = false;\n\t\t\tlet last = stopFrom(i);\n\t\t\twhile (end < list.length) {\n\t\t\t\t// Text alone goes on into the next run, rather than leave a run with nothing to do before it.\n\t\t\t\tif (end > last) {\n\t\t\t\t\tif (work) break;\n\t\t\t\t\tlast = stopFrom(end);\n\t\t\t\t}\n\t\t\t\tconst statement = list[end] as Statement;\n\t\t\t\tconst after = plan.after[end] as number;\n\t\t\t\tconst reach = plan.reach[end] as number;\n\t\t\t\tconst forkable = reach > after;\n\t\t\t\t// A wait in a run's chain of functions can only start the rest of the run, which must not depend on it.\n\t\t\t\t// When blocks or fills that set variables would change that, it checks when it waits.\n\t\t\t\tconst chained = forkable && after === end;\n\t\t\t\tconst { inner, aheadWaits } = this.#fn;\n\t\t\t\tconst restore = this.#snapshot();\n\t\t\t\tthis.#forkable = !chained\n\t\t\t\t\t? null\n\t\t\t\t\t: strict.after[end] === end && (strict.reach[end] as number) >= reach\n\t\t\t\t\t\t? AHEAD\n\t\t\t\t\t\t: GUARDED;\n\t\t\t\tconst generated = this.#attempt(() =>\n\t\t\t\t\tthis.#statement(statement, context),\n\t\t\t\t);\n\t\t\t\tthis.#forkable = null;\n\t\t\t\tif (!generated) break;\n\t\t\t\tconst waitsInside = this.#fn.inner > inner;\n\t\t\t\t// A run that waits inside a statement is a generator, which can't start the rest of the run while it\n\t\t\t\t// waits, and a chain can't run statements that depend on a wait before the ones that start early. Then\n\t\t\t\t// the statement gets a run of its own, and so do the statements that depend on it and the ones that start\n\t\t\t\t// early, so the closures' sequence can start them. A statement that waits inside after a wait that\n\t\t\t\t// starts the rest of the run ahead gets a run of its own too, so the chain stays a chain.\n\t\t\t\tconst own = forkable && (waitsInside || !chained || this.#fn.inner > 0);\n\t\t\t\tif (own || (waitsInside && aheadWaits > 0)) {\n\t\t\t\t\tif (end > i && work) {\n\t\t\t\t\t\trestore();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tgroups.push(generated);\n\t\t\t\t\twork = true;\n\t\t\t\t\tend++;\n\t\t\t\t\tif (forkable) stops.push(after, reach);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tgroups.push(generated);\n\t\t\t\tif (statement.type !== \"Text\") work = true;\n\t\t\t\tend++;\n\t\t\t\t// A wait that starts the rest of the run ahead needs all of it within its reach.\n\t\t\t\tif (chained) last = Math.min(last, reach);\n\t\t\t}\n\t\t\tif (end === i) {\n\t\t\t\tthis.#children(list[i] as Statement, strategy);\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (work) {\n\t\t\t\tgroups = this.#parts(list.slice(i, end), groups);\n\t\t\t\tconst first = (list[i] as Statement).span;\n\t\t\t\tconst last = (list[end - 1] as Statement).span;\n\t\t\t\tconst span = this.#span({ start: first.start, end: last.end });\n\t\t\t\tthis.#runs.push(\n\t\t\t\t\t`\\t\\t\\t[${first.start}, ${last.end}, ${this.#function(groups, span, false)}],`,\n\t\t\t\t);\n\t\t\t}\n\t\t\ti = end;\n\t\t}\n\t}\n\n\t/**\n\t * Writes the current function from its top-level statements' lines. Text is gathered in `s`, and written before\n\t * anything that writes to `out` itself, and at the end.\n\t *\n\t * A function that never waits is a plain function. A run whose waits all end top-level statements, such as an\n\t * include, is split after each into functions that call the next, so it only makes a callback when a promise comes\n\t * back. Anything else that may wait, such as an include in a loop, is a generator that `drive` runs.\n\t */\n\t#function(groups: string[][], span: string, nested: boolean): string {\n\t\tconst fn = this.#fn;\n\t\tgroups = groups.map((lines) =>\n\t\t\tthis.#forgetLines(this.#setFlags(dropForks(lines))),\n\t\t);\n\t\t// Steps are counted in a local, and `state.steps` kept up to date wherever other code may read or count them.\n\t\tconst start = this.#start(span);\n\t\tconst end = [\"state.steps = steps;\", `write(run, out, s, ${span});`];\n\t\tconst wrap = (lines: string[]) =>\n\t\t\tindent(lines).map((line) => `\\t\\t\\t${line}`);\n\n\t\tif (!fn.waits) {\n\t\t\tconst body = wrap([...start, ...this.#guard([...groups.flat(), ...end])]);\n\t\t\treturn `(run, scope, out) => {\\n${body.join(\"\\n\")}\\n\\t\\t\\t}`;\n\t\t}\n\n\t\tif (!fn.waitsInside && !nested) {\n\t\t\tconst segments: string[][] = [[]];\n\t\t\tfor (const group of groups) {\n\t\t\t\t(segments.at(-1) as string[]).push(...group);\n\t\t\t\tif (group.some((line) => WAIT_LINE.test(line))) segments.push([]);\n\t\t\t}\n\t\t\tconst base = `R${this.#generators++}`;\n\t\t\tsegments.forEach((lines, index) => {\n\t\t\t\tconst next = `${base}_${index + 1}(run, scope, out)`;\n\t\t\t\t// A wait that lets the rest of the run start ahead runs it in another buffer while it waits.\n\t\t\t\tconst body = lines.map((line) =>\n\t\t\t\t\tline.replace(\n\t\t\t\t\t\tWAIT_LINE,\n\t\t\t\t\t\t(_, tabs: string, result: string, ahead?: string) => {\n\t\t\t\t\t\t\tconst then = `${result}.then(() => ${next})`;\n\t\t\t\t\t\t\tconst rest = `restAhead(run, out, ${result}, (run, out) => ${next}, ${span})`;\n\t\t\t\t\t\t\treturn `${tabs}if (${result} !== undefined) return ${\n\t\t\t\t\t\t\t\tahead === AHEAD\n\t\t\t\t\t\t\t\t\t? rest\n\t\t\t\t\t\t\t\t\t: ahead === GUARDED\n\t\t\t\t\t\t\t\t\t\t? `contentSets(run) ? ${then} : ${rest}`\n\t\t\t\t\t\t\t\t\t\t: then\n\t\t\t\t\t\t\t};`;\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\t// Each function writes its own text, such as a slot's fallback, before the next takes over.\n\t\t\t\tconst last = index === segments.length - 1;\n\t\t\t\tthis.#declarations.push(\n\t\t\t\t\t`function ${base}_${index}(run, scope, out) {`,\n\t\t\t\t\t...indent([\n\t\t\t\t\t\t...start,\n\t\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t\t...body,\n\t\t\t\t\t\t\t...end,\n\t\t\t\t\t\t\t...(last ? [] : [`return ${next};`]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\t\"}\",\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn `${base}_0`;\n\t\t}\n\n\t\tconst body = wrap([\n\t\t\t...start,\n\t\t\t...this.#guard([...groups.flat(), ...end]),\n\t\t]).map((line) =>\n\t\t\tline.replace(\n\t\t\t\tWAIT_LINE,\n\t\t\t\t(_, tabs: string, result: string) =>\n\t\t\t\t\t`${tabs}if (${result} !== undefined) yield ${result};`,\n\t\t\t),\n\t\t);\n\t\t// A run's generator is declared once. A fill's is made where the component is, to read the loops around it.\n\t\tif (!nested) {\n\t\t\tconst generator = `G${this.#generators++}`;\n\t\t\tthis.#declarations.push(\n\t\t\t\t`function* ${generator}(run, scope, out) {`,\n\t\t\t\t...body.map((line) => line.slice(2)),\n\t\t\t\t\"}\",\n\t\t\t);\n\t\t\treturn `(run, scope, out) => drive(${generator}(run, scope, out))`;\n\t\t}\n\t\treturn `(run, scope, out) => drive((function* () {\\n${body.join(\"\\n\")}\\n\\t\\t\\t})())`;\n\t}\n\n\t/** Wraps a function's statements so an error a getter in your data throws is located at the read; see `reads`. */\n\t#guard(lines: string[]): string[] {\n\t\tif (!this.#fn.reads) return lines;\n\t\treturn [\n\t\t\t\"try {\",\n\t\t\t...indent(lines),\n\t\t\t\"} catch (error) {\",\n\t\t\t\"\\tthrow readError(run, at, error);\",\n\t\t\t\"}\",\n\t\t];\n\t}\n\n\t/** Sets the plain-object flags the current function's property reads use. See `PLAIN`. */\n\t#setFlags(lines: string[]): string[] {\n\t\tconst used = this.#fn.plainUsed;\n\t\treturn lines.map((line) =>\n\t\t\tline.replace(PLAIN, (_, flag: string, value: string) =>\n\t\t\t\tused.has(flag) ? `, ${flag} = ${isPlainCode(value)}` : \"\",\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * Declarations at the start of a generated function: steps are counted in a local, see `#function`, and `b` marks\n\t * where the current run of text and outputs starts in `s`, see `#parts`. Checks the abort signal too, since a\n\t * function may continue a run after a wait.\n\t */\n\t#start(span: string): string[] {\n\t\tconst fn = this.#fn;\n\t\tconst declared = [\n\t\t\t...Array.from({ length: fn.temps }, (_, i) => `t${i}`),\n\t\t\t...[...fn.variables.values()].flatMap(({ value, plain }) =>\n\t\t\t\tfn.plainUsed.has(plain) ? [value, plain] : [value],\n\t\t\t),\n\t\t];\n\t\treturn [\n\t\t\t\"const state = run.state;\",\n\t\t\t\"const maxSteps = state.maxSteps;\",\n\t\t\t\"const maxSize = state.maxSize;\",\n\t\t\t\"let steps = state.steps;\",\n\t\t\t\"const signal = state.signal;\",\n\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t\t'let s = \"\";',\n\t\t\t`let ${[\"q\", \"b\", ...declared].join(\", \")};`,\n\t\t\t...(fn.reads ? [\"let at = null;\"] : []),\n\t\t];\n\t}\n\n\t/** Generates a statement, or returns null and forgets anything it added when the statement can't be generated. */\n\t#attempt(generate: () => string[]): string[] | null {\n\t\tconst restore = this.#snapshot();\n\t\ttry {\n\t\t\treturn generate();\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Unsupported)) throw error;\n\t\t\trestore();\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Returns a function that forgets everything generated since, such as constants and queued lists. */\n\t#snapshot(): () => void {\n\t\tconst constants = this.#constants.length;\n\t\tconst names = [...this.#constantNames.keys()];\n\t\tconst pending = this.#pending.length;\n\t\tconst declarations = this.#declarations.length;\n\t\tconst fn = this.#fn;\n\t\tconst saved = {\n\t\t\t...fn,\n\t\t\tvariables: new Map(fn.variables),\n\t\t\tplainUsed: new Set(fn.plainUsed),\n\t\t};\n\t\treturn () => {\n\t\t\tthis.#constants.length = constants;\n\t\t\tfor (const key of this.#constantNames.keys()) {\n\t\t\t\tif (!names.includes(key)) this.#constantNames.delete(key);\n\t\t\t}\n\t\t\tthis.#pending.length = pending;\n\t\t\tthis.#declarations.length = declarations;\n\t\t\tthis.#fn = saved;\n\t\t};\n\t}\n\n\t#children(statement: Statement, strategy: EscapeStrategy | false): void {\n\t\tswitch (statement.type) {\n\t\t\tcase \"If\":\n\t\t\t\tfor (const branch of statement.branches) {\n\t\t\t\t\tthis.#list(branch.body, strategy, false);\n\t\t\t\t}\n\t\t\t\tif (statement.alternate) {\n\t\t\t\t\tthis.#list(statement.alternate, strategy, false);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"For\":\n\t\t\t\tthis.#list(statement.body, strategy, false);\n\t\t\t\tif (statement.alternate) {\n\t\t\t\t\tthis.#list(statement.alternate, strategy, false);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"Component\":\n\t\t\t\tthis.#list(statement.body, strategy, false);\n\t\t\t\tfor (const fill of statement.fills) {\n\t\t\t\t\tthis.#list(fill.body, strategy, false);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"Autoescape\":\n\t\t\t\tthis.#list(statement.body, statement.strategy, false);\n\t\t\t\tbreak;\n\t\t\tcase \"SetBlock\":\n\t\t\tcase \"Block\":\n\t\t\tcase \"Slot\":\n\t\t\tcase \"Macro\":\n\t\t\tcase \"Add\":\n\t\t\tcase \"Cache\":\n\t\t\tcase \"Island\":\n\t\t\tcase \"With\":\n\t\t\tcase \"Apply\":\n\t\t\t\tthis.#list(statement.body, strategy, false);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Names for constants and temporaries\n\n\t#span(span: Span): string {\n\t\tconst key = `${span.start}:${span.end}`;\n\t\tlet index = this.#spanIndex.get(key);\n\t\tif (index === undefined) {\n\t\t\tindex = this.#spanIndex.size;\n\t\t\tthis.#spanIndex.set(key, index);\n\t\t\tthis.#spans.push(span.start, span.end);\n\t\t}\n\t\treturn `S[${index}]`;\n\t}\n\n\t/** A value made once when the module loads, such as a built-in filter. */\n\t#constant(key: string, prefix: string, value: string): string {\n\t\tlet name = this.#constantNames.get(key);\n\t\tif (name === undefined) {\n\t\t\tname = `${prefix}${this.#constantNames.size}`;\n\t\t\tthis.#constantNames.set(key, name);\n\t\t\tthis.#constants.push(`const ${name} = ${value};`);\n\t\t}\n\t\treturn name;\n\t}\n\n\t#temp(): string {\n\t\treturn `t${this.#fn.temps++}`;\n\t}\n\n\t/** Counts one step, as `step` does. */\n\t#step(span: string): string {\n\t\treturn `++steps > maxSteps && stepLimit(run, ${span})`;\n\t}\n\n\t/**\n\t * Counts a step and checks the abort signal, as `step` does: in loops, so a long render stops soon after an abort,\n\t * and before calls to your functions and filters.\n\t */\n\t#checkedStep(span: string): string {\n\t\treturn `${this.#step(span)}; signal !== undefined && signal.aborted && aborted(run, ${span});`;\n\t}\n\n\t/** Calls something that may read or count steps, with `state.steps` up to date around it. */\n\t#counted(call: string): string {\n\t\tconst result = this.#temp();\n\t\treturn `(state.steps = steps, ${result} = ${call}, steps = state.steps, ${result})`;\n\t}\n\n\t/**\n\t * Writes the text so far, runs something that writes to `out` and may return a promise, and waits for it. `top`\n\t * is set when the wait ends a top-level statement. A wait that continues in a new function is checked for an abort\n\t * by `#start`, and one in a generator after it resumes.\n\t */\n\t#wait(span: string, call: string, top: boolean): string[] {\n\t\tthis.#fn.waits = true;\n\t\tif (!top) {\n\t\t\tthis.#fn.waitsInside = true;\n\t\t\tthis.#fn.inner++;\n\t\t}\n\t\tconst result = this.#temp();\n\t\tconst ahead = top ? this.#forkable : null;\n\t\tif (ahead !== null) this.#fn.aheadWaits++;\n\t\treturn [\n\t\t\t`write(run, out, s, ${span});`,\n\t\t\t's = \"\";',\n\t\t\t\"state.steps = steps;\",\n\t\t\t`${result} = ${call};`,\n\t\t\t`${WAIT}${result}${ahead ?? \"\"}`,\n\t\t\t\"steps = state.steps;\",\n\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t];\n\t}\n\n\t/** A function for a list of statements inside the current one, such as a component's fill. */\n\t#nested(list: Statement[], at: Span, context: Context): string {\n\t\tconst outer = this.#fn;\n\t\tthis.#fn = newFunction();\n\t\ttry {\n\t\t\t// A fill runs in a scope of its own, made from the caller's when the slot renders it.\n\t\t\tconst lines = this.#body(list, { ...context, scope: \"scope\" });\n\t\t\treturn this.#function([lines], this.#span(at), true);\n\t\t} finally {\n\t\t\tthis.#fn = outer;\n\t\t}\n\t}\n\n\t// Statements\n\n\t#statement(statement: Statement, context: Context): string[] {\n\t\tswitch (statement.type) {\n\t\t\tcase \"Text\":\n\t\t\t\treturn [`s += ${JSON.stringify(statement.value)};`];\n\t\t\tcase \"Output\":\n\t\t\t\treturn this.#output(statement.expression, statement.span, context);\n\t\t\tcase \"If\":\n\t\t\t\treturn this.#if(statement, context);\n\t\t\tcase \"For\":\n\t\t\t\treturn this.#for(statement, context);\n\t\t\tcase \"Autoescape\":\n\t\t\t\treturn this.#body(statement.body, {\n\t\t\t\t\t...context,\n\t\t\t\t\tstrategy: statement.strategy,\n\t\t\t\t});\n\t\t\tcase \"Props\":\n\t\t\t\treturn this.#props(statement, context);\n\t\t\tcase \"Set\":\n\t\t\t\treturn this.#set(statement, context);\n\t\t\tcase \"Include\":\n\t\t\t\treturn this.#include(statement, context);\n\t\t\tcase \"Component\":\n\t\t\t\treturn this.#component(statement, context);\n\t\t\tcase \"Slot\":\n\t\t\t\treturn this.#slot(statement, context);\n\t\t\tcase \"Block\":\n\t\t\t\treturn this.#block(statement, context);\n\t\t\tdefault:\n\t\t\t\treturn unsupported();\n\t\t}\n\t}\n\n\t/** Statements inside another, such as a loop's body. */\n\t#body(list: Statement[], context: Context): string[] {\n\t\tconst inner = { ...context, top: false, pass: false };\n\t\treturn this.#parts(\n\t\t\tlist,\n\t\t\tlist.map((statement) => this.#statement(statement, inner)),\n\t\t).flat();\n\t}\n\n\t/**\n\t * Checks the output limit where the closures do, given a list's statements and their lines. The closures print each\n\t * run of text and outputs as one string, see `printParts`: an output fails when that string alone is too long, and\n\t * the run fails when writing it makes the output too long, located at its start. Generated code gathers text in\n\t * `s` for longer, so it marks where each run starts in `b`, and checks the whole output after each run.\n\t */\n\t#parts(list: Statement[], groups: string[][]): string[][] {\n\t\tconst isPart = (statement: Statement) =>\n\t\t\tstatement.type === \"Text\" ||\n\t\t\t(statement.type === \"Output\" && !this.#isHostCall(statement.expression));\n\t\tconst result: string[][] = [];\n\t\tlet i = 0;\n\t\twhile (i < list.length) {\n\t\t\tif (!isPart(list[i] as Statement)) {\n\t\t\t\tresult.push(groups[i] as string[]);\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet end = i;\n\t\t\twhile (end < list.length && isPart(list[end] as Statement)) end++;\n\t\t\tconst run = groups.slice(i, end);\n\t\t\t// Only outputs read where the run starts.\n\t\t\tif (list.slice(i, end).some((statement) => statement.type === \"Output\")) {\n\t\t\t\trun[0] = [\"b = s.length;\", ...(run[0] as string[])];\n\t\t\t}\n\t\t\tconst at = this.#span((list[i] as Statement).span);\n\t\t\tconst last = run.length - 1;\n\t\t\trun[last] = [\n\t\t\t\t...(run[last] as string[]),\n\t\t\t\t`if (out.s.length + s.length > maxSize) write(run, out, s, ${at});`,\n\t\t\t];\n\t\t\tresult.push(...run);\n\t\t\ti = end;\n\t\t}\n\t\treturn result;\n\t}\n\n\t#output(expression: Expression, at: Span, context: Context): string[] {\n\t\tconst span = this.#span(at);\n\t\tconst step = `${this.#step(span)};`;\n\t\tconst emit = emitter(context.strategy);\n\t\tconst emitted = (value: unknown): string => {\n\t\t\ttry {\n\t\t\t\treturn JSON.stringify(emit(value));\n\t\t\t} catch {\n\t\t\t\t// Fails when rendering, so the closures report it.\n\t\t\t\treturn unsupported();\n\t\t\t}\n\t\t};\n\t\t// Values can be long, so stop at the output limit before they make a string too long for JavaScript. An output in\n\t\t// a run of text and outputs checks the run's text, and a call to one of your functions, which the closures write\n\t\t// on its own, checks the whole output. See `#parts`.\n\t\tconst limit = this.#isHostCall(expression)\n\t\t\t? `if (out.s.length + s.length > maxSize) write(run, out, s, ${span});`\n\t\t\t: `if (s.length - b > maxSize) write(run, out, s, ${span});`;\n\t\tif (expression.type === \"Literal\") {\n\t\t\treturn [step, `s += ${emitted(expression.value)};`, limit];\n\t\t}\n\t\t// A choice between two literals prints text emitted now.\n\t\tif (expression.type === \"Conditional\") {\n\t\t\tconst { consequent, alternate } = expression;\n\t\t\tif (\n\t\t\t\tconsequent.type === \"Literal\" &&\n\t\t\t\t(alternate === null || alternate.type === \"Literal\")\n\t\t\t) {\n\t\t\t\tconst yes = emitted(consequent.value);\n\t\t\t\tconst no = emitted(alternate ? alternate.value : null);\n\t\t\t\tconst test = this.#condition(expression.test, context);\n\t\t\t\treturn [step, `s += ${test} ? ${yes} : ${no};`];\n\t\t\t}\n\t\t}\n\t\tconst value = this.#temp();\n\t\tconst code = this.#value(expression, context, value);\n\t\tconst strategy = context.strategy;\n\t\t// Strings and numbers print in place. Numbers need no escaping in HTML.\n\t\tconst print =\n\t\t\tstrategy === \"html\"\n\t\t\t\t? `typeof ${value} === \"string\" ? escapeHtml(${value}) : typeof ${value} === \"number\" ? String(${value}) : print(run, ${span}, ${value}, \"html\")`\n\t\t\t\t: strategy === false\n\t\t\t\t\t? `typeof ${value} === \"string\" ? ${value} : typeof ${value} === \"number\" ? String(${value}) : print(run, ${span}, ${value}, \"none\")`\n\t\t\t\t\t: `print(run, ${span}, ${value}, ${JSON.stringify(strategy)})`;\n\t\treturn [step, ...code, `s += ${print};`, limit];\n\t}\n\n\t/**\n\t * Branches test in order, and the first that holds runs. JavaScript nests `else if`, so long chains become a flat\n\t * labelled block that its parser can read without recursing once per branch.\n\t */\n\t#if(\n\t\tstatement: Extract<Statement, { type: \"If\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst lines = [`${this.#step(this.#span(statement.span))};`];\n\t\tconst branches = statement.branches.map((branch) => ({\n\t\t\ttest: this.#condition(branch.test, context),\n\t\t\tbody: indent(this.#body(branch.body, context)),\n\t\t}));\n\t\tconst alternate = statement.alternate\n\t\t\t? indent(this.#body(statement.alternate, context))\n\t\t\t: null;\n\t\tif (branches.length <= MAX_ELSE_IF) {\n\t\t\tbranches.forEach(({ test, body }, index) => {\n\t\t\t\tlines.push(`${index === 0 ? \"if\" : \"} else if\"} (${test}) {`, ...body);\n\t\t\t});\n\t\t\tif (alternate) lines.push(\"} else {\", ...alternate);\n\t\t\tlines.push(\"}\");\n\t\t\treturn lines;\n\t\t}\n\t\tconst label = `if${this.#loops++}`;\n\t\tlines.push(`${label}: {`);\n\t\tfor (const { test, body } of branches) {\n\t\t\tlines.push(\n\t\t\t\t`\\tif (${test}) {`,\n\t\t\t\t...indent(body),\n\t\t\t\t`\\t\\tbreak ${label};`,\n\t\t\t\t\"\\t}\",\n\t\t\t);\n\t\t}\n\t\tif (alternate) lines.push(...alternate);\n\t\tlines.push(\"}\");\n\t\treturn lines;\n\t}\n\n\t/**\n\t * A loop. Its variables become JavaScript locals, since nothing in generated code can change them, and `loop.index`\n\t * and the rest read the loop's counter. Text is written whenever a pass leaves more than `FLUSH_AT` characters, so\n\t * the output limit still stops a long loop early.\n\t */\n\t#for(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst id = this.#loops++;\n\t\tconst iterable = this.#temp();\n\t\tconst [items, values, length, keys, index, value, key] = [\n\t\t\t\"items\",\n\t\t\t\"values\",\n\t\t\t\"n\",\n\t\t\t\"keys\",\n\t\t\t\"i\",\n\t\t\t\"v\",\n\t\t\t\"k\",\n\t\t].map((name) => `${name}${id}`) as [\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t\tstring,\n\t\t];\n\t\tconst bindings = new Map(context.bindings);\n\t\tbindings.set(statement.valueName, {\n\t\t\tkind: \"value\",\n\t\t\tjs: value,\n\t\t\tplain: `p${value}`,\n\t\t});\n\t\tif (statement.keyName !== null) {\n\t\t\tbindings.set(statement.keyName, {\n\t\t\t\tkind: \"value\",\n\t\t\t\tjs: key,\n\t\t\t\tplain: `p${key}`,\n\t\t\t});\n\t\t}\n\t\tbindings.set(\"loop\", { kind: \"loop\", index, length });\n\t\tconst hasKeys = statement.keyName !== null;\n\t\tconst sets = [...setsIn(statement.body)];\n\t\tconst scoped = sets.length > 0 ? `sc${id}` : null;\n\t\tconst loop: LoopNames = {\n\t\t\tid,\n\t\t\tspan,\n\t\t\tscope: scoped,\n\t\t\touter: context.scope,\n\t\t\tsets,\n\t\t\tvalues,\n\t\t\tlength,\n\t\t\tkeys,\n\t\t\tindex,\n\t\t\tvalue,\n\t\t\tkey,\n\t\t\thasKeys,\n\t\t};\n\t\tconst passContext = {\n\t\t\t...context,\n\t\t\tbindings,\n\t\t\tscope: scoped ?? context.scope,\n\t\t};\n\t\tconst looped =\n\t\t\tcontext.top &&\n\t\t\t!context.inLoop &&\n\t\t\teffectsOf(statement.body, this.#env).waits\n\t\t\t\t? this.#loopFunction(statement, passContext, loop)\n\t\t\t\t: null;\n\t\tconst range = looped ? null : literalRange(statement.iterable);\n\t\tconst paused =\n\t\t\tlooped || range\n\t\t\t\t? null\n\t\t\t\t: this.#loopGenerator(statement, passContext, loop);\n\t\tconst body =\n\t\t\tlooped || paused\n\t\t\t\t? []\n\t\t\t\t: this.#body(statement.body, { ...passContext, inLoop: true });\n\t\tconst alternate = statement.alternate\n\t\t\t? this.#body(statement.alternate, context)\n\t\t\t: [];\n\t\tif (range) {\n\t\t\treturn this.#rangeLoop(statement, context, loop, range, body, alternate);\n\t\t}\n\t\tconst passes = looped\n\t\t\t? this.#wait(\n\t\t\t\t\tspan,\n\t\t\t\t\t`${looped}(run, ${context.scope}, out, ${values}, ${length}, 0, ${length}${hasKeys ? `, ${keys}` : \"\"})`,\n\t\t\t\t\tcontext.top,\n\t\t\t\t)\n\t\t\t: paused\n\t\t\t\t? [\n\t\t\t\t\t\t...paused,\n\t\t\t\t\t\t...this.#wait(\n\t\t\t\t\t\t\tspan,\n\t\t\t\t\t\t\t`drive(LG${id}(run, out, 0, ${length}))`,\n\t\t\t\t\t\t\tcontext.top,\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t: [\n\t\t\t\t\t\t`for (let ${index} = 0; ${index} < ${length}; ${index}++) {`,\n\t\t\t\t\t\t...indent(this.#pass(loop, true)),\n\t\t\t\t\t\t...indent(body),\n\t\t\t\t\t\t`\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t\t\t\t`\\t\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t'\\t\\ts = \"\";',\n\t\t\t\t\t\t\"\\t}\",\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t];\n\t\treturn [\n\t\t\tthis.#checkedStep(span),\n\t\t\t...this.#value(statement.iterable, context, iterable),\n\t\t\t// Arrays, the usual case, need no conversion unless the loop wants keys.\n\t\t\t...(hasKeys\n\t\t\t\t? [\n\t\t\t\t\t\t`const ${items} = loopItems(run, ${span}, ${iterable}, true);`,\n\t\t\t\t\t\t`const ${values} = ${items}.values;`,\n\t\t\t\t\t]\n\t\t\t\t: [\n\t\t\t\t\t\t`const ${values} = Array.isArray(${iterable}) ? ${iterable} : loopItems(run, ${span}, ${iterable}, false).values;`,\n\t\t\t\t\t]),\n\t\t\t`const ${length} = ${values}.length;`,\n\t\t\t`if (${length} === 0) {`,\n\t\t\t...indent(alternate),\n\t\t\t\"} else {\",\n\t\t\t...(hasKeys ? [`\\tconst ${keys} = ${items}.keys;`] : []),\n\t\t\t...indent(passes),\n\t\t\t\"}\",\n\t\t\t// Variables the body set may live outside the loop, so later lookups start again.\n\t\t\t...sets.flatMap((name) => this.#forget(name)),\n\t\t];\n\t}\n\n\t/**\n\t * A loop over a range of integer literals, such as `1..5`, counts instead of making the array. It charges the\n\t * range's steps and checks its length as `range` does.\n\t */\n\t#rangeLoop(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t\tloop: LoopNames,\n\t\trange: { from: number; to: number },\n\t\tbody: string[],\n\t\talternate: string[],\n\t): string[] {\n\t\tconst node = statement.iterable as Extract<Expression, { type: \"Binary\" }>;\n\t\tconst rangeSpan = this.#span(node.span);\n\t\tconst count = Math.abs(range.to - range.from) + 1;\n\t\tconst direction = range.to < range.from ? \"-\" : \"+\";\n\t\tconst { span, length, index, value, key, hasKeys } = loop;\n\t\treturn [\n\t\t\tthis.#checkedStep(span),\n\t\t\t`const ${length} = ${count};`,\n\t\t\t`if (${length} > maxSteps) rangeLimit(run, ${rangeSpan}, ${length});`,\n\t\t\t`if ((steps += ${length}) > maxSteps) stepLimit(run, ${rangeSpan});`,\n\t\t\t...(alternate.length > 0\n\t\t\t\t? [`if (${length} === 0) {`, ...indent(alternate), \"}\"]\n\t\t\t\t: []),\n\t\t\t`for (let ${index} = 0; ${index} < ${length}; ${index}++) {`,\n\t\t\t`\\t${this.#checkedStep(span)}`,\n\t\t\t...(loop.scope\n\t\t\t\t? [\n\t\t\t\t\t\t`\\tconst ${loop.scope} = childScope(${loop.outer});`,\n\t\t\t\t\t\t...indent(loop.sets.flatMap((name) => this.#forget(name))),\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t`\\tconst ${value} = ${range.from} ${direction} ${index};`,\n\t\t\t...(this.#plainUsed.has(`p${value}`)\n\t\t\t\t? [`\\tconst p${value} = false;`]\n\t\t\t\t: []),\n\t\t\t...(hasKeys ? [`\\tconst ${key} = ${index};`] : []),\n\t\t\t...(hasKeys && this.#plainUsed.has(`p${key}`)\n\t\t\t\t? [`\\tconst p${key} = false;`]\n\t\t\t\t: []),\n\t\t\t...indent(body),\n\t\t\t`\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t`\\t\\twrite(run, out, s, ${span});`,\n\t\t\t'\\t\\ts = \"\";',\n\t\t\t\"\\t}\",\n\t\t\t\"}\",\n\t\t\t...loop.sets.flatMap((name) => this.#forget(name)),\n\t\t];\n\t}\n\n\t/**\n\t * The start of a loop pass: counts a step and makes the pass's scope, unless continuing one, which is passed its\n\t * scope, and binds the loop's variables.\n\t */\n\t#pass(loop: LoopNames, starts: boolean): string[] {\n\t\tconst { span, values, index, value, key, keys, hasKeys } = loop;\n\t\tconst proto = `q${loop.id}`;\n\t\treturn [\n\t\t\t...(starts ? [this.#checkedStep(span)] : []),\n\t\t\t...(loop.scope && starts\n\t\t\t\t? [\n\t\t\t\t\t\t`const ${loop.scope} = childScope(${loop.outer});`,\n\t\t\t\t\t\t...loop.sets.flatMap((name) => this.#forget(name)),\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t`const ${value} = ${values}[${index}] ?? null;`,\n\t\t\t...(this.#plainUsed.has(`p${value}`)\n\t\t\t\t? [\n\t\t\t\t\t\t`let ${proto};`,\n\t\t\t\t\t\t`const p${value} = typeof ${value} === \"object\" && ${value} !== null && ((${proto} = getPrototypeOf(${value})) === objectPrototype || ${proto} === null);`,\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t...(hasKeys\n\t\t\t\t? [`const ${key} = ${keys} ? (${keys}[${index}] ?? null) : ${index};`]\n\t\t\t\t: []),\n\t\t\t...(hasKeys && this.#plainUsed.has(`p${key}`)\n\t\t\t\t? [`const p${key} = ${isPlainCode(key)};`]\n\t\t\t\t: []),\n\t\t];\n\t}\n\n\t/**\n\t * A loop at the top of a run whose passes may wait, such as one that includes a template, as plain functions\n\t * rather than a generator, which V8 runs more slowly. The loop is a function of its items and the index to start\n\t * at. A pass that gets a promise continues in a function for the rest of that pass, and `passAhead` calls the loop\n\t * for the next index: at once, ahead of the pass, when it may. Returns the loop function's name, or null when a pass\n\t * may wait somewhere a function can't continue from, such as in a nested loop.\n\t */\n\t#loopFunction(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t\tloop: LoopNames,\n\t): string | null {\n\t\tconst outer = this.#fn;\n\t\tconst restore = this.#snapshot();\n\t\tthis.#fn = newFunction();\n\t\ttry {\n\t\t\tconst inner: Context = {\n\t\t\t\t...context,\n\t\t\t\tinLoop: true,\n\t\t\t\ttop: true,\n\t\t\t\tpass: true,\n\t\t\t};\n\t\t\tconst generated = this.#parts(\n\t\t\t\tstatement.body,\n\t\t\t\tstatement.body.map((child) => this.#statement(child, inner)),\n\t\t\t);\n\t\t\tif (!this.#fn.waits || this.#fn.waitsInside) {\n\t\t\t\trestore();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Flags are set once every statement is generated, so every lookup of a variable sets the flag a later read\n\t\t\t// uses. A lookup that skipped it would leave the flag of an earlier value, which may not be a plain object.\n\t\t\tconst groups = generated.map((lines) => this.#setFlags(lines));\n\t\t\t// A pass is split after each statement that waits, and after each call to your function, whose value the\n\t\t\t// next function takes: `values[k]` names the local it goes in for segment k.\n\t\t\tconst segments: string[][] = [[]];\n\t\t\tconst values: (string | null)[] = [null];\n\t\t\tfor (const group of groups) {\n\t\t\t\tfor (const line of group) {\n\t\t\t\t\t(segments.at(-1) as string[]).push(line);\n\t\t\t\t\tconst value = VALUE_LINE.exec(line);\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tsegments.push([]);\n\t\t\t\t\t\tvalues.push(value[2] as string);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (group.some((line) => WAIT_LINE.test(line))) {\n\t\t\t\t\tsegments.push([]);\n\t\t\t\t\tvalues.push(null);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst name = `L${this.#generators++}`;\n\t\t\tconst keys = loop.hasKeys ? `, ${loop.keys}` : \"\";\n\t\t\t// The loop function runs passes up to `stop`; each function after a wait finishes one pass.\n\t\t\tconst params = `run, scope, out, ${loop.values}, ${loop.length}, ${loop.index}, stop${keys}`;\n\t\t\t// A pass continues in the scope it started, so variables it set before waiting are still there.\n\t\t\tconst passScope = loop.scope ? `, ${loop.scope}` : \"\";\n\t\t\tconst partParams = `run, scope, out, ${loop.values}, ${loop.length}, ${loop.index}${keys}${passScope}`;\n\t\t\tconst call = (part: number, value?: string) =>\n\t\t\t\t`${name}_${part}(${partParams}${value === undefined ? \"\" : `, ${value}`})`;\n\t\t\tconst one = `(run, out, j) => ${name}(run, scope, out, ${loop.values}, ${loop.length}, j, j + 1${keys})`;\n\t\t\tconst { sets, elsewhere } = this.#setsOf(statement);\n\t\t\t// Each wait continues the pass in the function for the segments after it. The first wait in a pass, in the\n\t\t\t// loop function, also starts the passes after it, ahead of it when they may. See `passAhead`.\n\t\t\tconst handOff = (from: number, tabs: string, rest: string) =>\n\t\t\t\tfrom === 0\n\t\t\t\t\t? `${tabs}return ${loop.index} + 1 < stop ? passAhead(run, scope, out, ${rest}, ${sets}, ${elsewhere}, ${loop.index} + 1, stop, ${one}, ${loop.span}) : ${rest};`\n\t\t\t\t\t: `${tabs}return ${rest};`;\n\t\t\tconst continued = (from: number) =>\n\t\t\t\tsegments.slice(from).flatMap((lines, offset) =>\n\t\t\t\t\tthis.#forgetLines(lines).flatMap((line) => {\n\t\t\t\t\t\tconst next = from + offset + 1;\n\t\t\t\t\t\tconst value = VALUE_LINE.exec(line);\n\t\t\t\t\t\tif (value) {\n\t\t\t\t\t\t\tconst [, tabs, result, span, fn] = value as unknown as string[];\n\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\t`${tabs}if (${result} instanceof Promise) {`,\n\t\t\t\t\t\t\t\t// The text so far goes out first, so a streamed render can send it while this waits.\n\t\t\t\t\t\t\t\t`${tabs}\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t\t\thandOff(\n\t\t\t\t\t\t\t\t\tfrom,\n\t\t\t\t\t\t\t\t\t`${tabs}\\t`,\n\t\t\t\t\t\t\t\t\t`${result}.then((w) => ${call(next, \"unhold(w)\")}, (error) => { throw hostError(run, ${span}, ${fn}, error); })`,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t`${tabs}}`,\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst wait = WAIT_LINE.exec(line);\n\t\t\t\t\t\tif (!wait) return [line];\n\t\t\t\t\t\tconst [, tabs, result] = wait as unknown as string[];\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t`${tabs}if (${result} !== undefined) {`,\n\t\t\t\t\t\t\thandOff(from, `${tabs}\\t`, `${result}.then(() => ${call(next)})`),\n\t\t\t\t\t\t\t`${tabs}}`,\n\t\t\t\t\t\t];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\tconst start = this.#start(loop.span);\n\t\t\tconst end = [\"state.steps = steps;\", `write(run, out, s, ${loop.span});`];\n\t\t\tthis.#declarations.push(\n\t\t\t\t`function ${name}(${params}) {`,\n\t\t\t\t...indent([\n\t\t\t\t\t...start,\n\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t`for (; ${loop.index} < stop; ${loop.index}++) {`,\n\t\t\t\t\t\t...indent(this.#pass(loop, true)),\n\t\t\t\t\t\t...indent(continued(0)),\n\t\t\t\t\t\t`\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t\t\t\t`\\t\\twrite(run, out, s, ${loop.span});`,\n\t\t\t\t\t\t'\\t\\ts = \"\";',\n\t\t\t\t\t\t\"\\t}\",\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t...end,\n\t\t\t\t\t]),\n\t\t\t\t]),\n\t\t\t\t\"}\",\n\t\t\t);\n\t\t\tfor (let part = 1; part < segments.length; part++) {\n\t\t\t\tconst value = values[part] ?? null;\n\t\t\t\tthis.#declarations.push(\n\t\t\t\t\t`function ${name}_${part}(${partParams}${value === null ? \"\" : \", w\"}) {`,\n\t\t\t\t\t...indent([\n\t\t\t\t\t\t...start,\n\t\t\t\t\t\t...(value === null ? [] : [`${value} = w;`]),\n\t\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t\t...this.#pass(loop, false),\n\t\t\t\t\t\t\t...continued(part),\n\t\t\t\t\t\t\t...end,\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\t\"}\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn name;\n\t\t} finally {\n\t\t\tthis.#fn = outer;\n\t\t}\n\t}\n\n\t/**\n\t * The variables a loop's body sets, as a frozen list made once, and whether it places content from elsewhere, for\n\t * `passesAhead`.\n\t */\n\t#setsOf(statement: Extract<Statement, { type: \"For\" }>): {\n\t\tsets: string;\n\t\telsewhere: boolean;\n\t} {\n\t\tconst effects = effectsOf(statement.body, this.#env);\n\t\tconst names = [...effects.sets];\n\t\tconst sets = this.#constant(\n\t\t\t`sets:${JSON.stringify(names)}`,\n\t\t\t\"N\",\n\t\t\t`Object.freeze(${JSON.stringify(names)})`,\n\t\t);\n\t\treturn { sets, elsewhere: effects.elsewhere };\n\t}\n\n\t/**\n\t * A loop whose passes may pause anywhere, such as at a call to one of your functions, as a generator of its own over\n\t * the index to start at. It is declared where the loop is, so it reads the locals around it, such as the loops\n\t * outside. When a pass pauses, the passes after it start at once in another run of the generator, when they may;\n\t * see `startAhead`. The loop then stops after that pass and waits for them. Returns the generator's lines, or null\n\t * when no pass waits.\n\t */\n\t#loopGenerator(\n\t\tstatement: Extract<Statement, { type: \"For\" }>,\n\t\tcontext: Context,\n\t\tloop: LoopNames,\n\t): string[] | null {\n\t\tif (!effectsOf(statement.body, this.#env).waits) return null;\n\t\tconst outer = this.#fn;\n\t\tconst restore = this.#snapshot();\n\t\tthis.#fn = newFunction();\n\t\ttry {\n\t\t\tconst lines = this.#body(statement.body, { ...context, inLoop: true });\n\t\t\tif (!this.#fn.waits) {\n\t\t\t\trestore();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst name = `LG${loop.id}`;\n\t\t\tconst ahead = `a${loop.id}`;\n\t\t\tconst { index, span } = loop;\n\t\t\t// Only the first run of the generator starts passes ahead. The ones it starts run one pass each.\n\t\t\tconst { sets, elsewhere } = this.#setsOf(statement);\n\t\t\tconst fork = `if (${ahead} === null && ${index} + 1 < stop) ${ahead} = startAhead(run, ${loop.outer}, out, ${sets}, ${elsewhere}, ${index} + 1, stop, (run, out, j) => drive(${name}(run, out, j, j + 1)), ${span});`;\n\t\t\tconst body = this.#forgetLines(this.#setFlags(lines)).flatMap((line) => {\n\t\t\t\tif (line.trim() === FORK) return [line.replace(FORK, fork)];\n\t\t\t\tconst wait = WAIT_LINE.exec(line);\n\t\t\t\tif (!wait) return [line];\n\t\t\t\tconst [, tabs, result] = wait as unknown as [string, string, string];\n\t\t\t\treturn [\n\t\t\t\t\t`${tabs}if (${result} !== undefined) {`,\n\t\t\t\t\t`${tabs}\\t${fork}`,\n\t\t\t\t\t`${tabs}\\tyield ${result};`,\n\t\t\t\t\t`${tabs}}`,\n\t\t\t\t];\n\t\t\t});\n\t\t\tconst pass = this.#pass(loop, true);\n\t\t\tconst reads = this.#fn.reads;\n\t\t\treturn [\n\t\t\t\t`const ${name} = function* (run, out, ${index}, stop) {`,\n\t\t\t\t...indent([\n\t\t\t\t\t...this.#start(span),\n\t\t\t\t\t`let ${ahead} = null;`,\n\t\t\t\t\t...this.#guard([\n\t\t\t\t\t\t\"try {\",\n\t\t\t\t\t\t`\\tfor (; ${index} < stop; ${index}++) {`,\n\t\t\t\t\t\t...indent(indent([...pass, ...body])),\n\t\t\t\t\t\t`\\t\\tif (${ahead} !== null) break;`,\n\t\t\t\t\t\t`\\t\\tif (s.length > ${FLUSH_AT}) {`,\n\t\t\t\t\t\t`\\t\\t\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t'\\t\\t\\ts = \"\";',\n\t\t\t\t\t\t\"\\t\\t}\",\n\t\t\t\t\t\t\"\\t}\",\n\t\t\t\t\t\t\"} catch (error) {\",\n\t\t\t\t\t\t`\\tif (${ahead} !== null) yield ${ahead}.fail(error);`,\n\t\t\t\t\t\t\"\\tthrow error;\",\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t`if (${ahead} !== null) {`,\n\t\t\t\t\t\t`\\twrite(run, out, s, ${span});`,\n\t\t\t\t\t\t'\\ts = \"\";',\n\t\t\t\t\t\t\"\\tstate.steps = steps;\",\n\t\t\t\t\t\t// The passes ahead locate their own errors.\n\t\t\t\t\t\t...(reads ? [\"\\tat = null;\"] : []),\n\t\t\t\t\t\t`\\tyield ${ahead}.join();`,\n\t\t\t\t\t\t\"}\",\n\t\t\t\t\t\t\"state.steps = steps;\",\n\t\t\t\t\t\t`write(run, out, s, ${span});`,\n\t\t\t\t\t]),\n\t\t\t\t]),\n\t\t\t\t\"};\",\n\t\t\t];\n\t\t} finally {\n\t\t\tthis.#fn = outer;\n\t\t}\n\t}\n\n\t/**\n\t * `set`, through the closures' `assign`, so it finds the variable's scope as they do. Loop variables are locals in\n\t * generated code, so setting one stays with the closures.\n\t */\n\t#set(\n\t\tstatement: Extract<Statement, { type: \"Set\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tif (context.bindings.has(statement.name)) return unsupported();\n\t\tconst span = this.#span(statement.span);\n\t\tconst value = this.#temp();\n\t\treturn [\n\t\t\t`${this.#step(span)};`,\n\t\t\t...this.#value(statement.value, context, value),\n\t\t\t`assign(run, ${context.scope}, ${JSON.stringify(statement.name)}, ${value}, ${span});`,\n\t\t\t...this.#forget(statement.name),\n\t\t];\n\t}\n\n\t/** Forgets every variable lookup, after code that may set any variable, so later lookups start again. */\n\t#forgetAll(): string[] {\n\t\treturn [FORGET_ALL];\n\t}\n\n\t/** Writes out `FORGET_ALL`, once the current function's lookups are all known. */\n\t#forgetLines(lines: string[]): string[] {\n\t\tconst forget = [...this.#fn.variables.values()]\n\t\t\t.map(({ value }) => `${value} = undefined;`)\n\t\t\t.join(\" \");\n\t\treturn lines.map((line) =>\n\t\t\tline.endsWith(FORGET_ALL)\n\t\t\t\t? line.slice(0, -FORGET_ALL.length) + forget\n\t\t\t\t: line,\n\t\t);\n\t}\n\n\t/** Forgets lookups of a variable that `set` may have changed. */\n\t#forget(name: string): string[] {\n\t\treturn [\"plain\", \"guarded\"].flatMap((kind) => {\n\t\t\tconst cached = this.#fn.variables.get(`${kind}:${name}`);\n\t\t\treturn cached ? [`${cached.value} = undefined;`] : [];\n\t\t});\n\t}\n\n\t/**\n\t * Lines that put an expression's value in `target`. A call to one of your functions or filters may return a\n\t * promise, so it can only be the whole expression, and the function waits for it as a generator.\n\t */\n\t#value(node: Expression, context: Context, target: string): string[] {\n\t\treturn (\n\t\t\tthis.#hostCall(node, context, target) ?? [\n\t\t\t\t`${target} = ${this.#expr(node, context, false)};`,\n\t\t\t]\n\t\t);\n\t}\n\n\t/** Whether an expression is a call to one of your functions or filters, which `#hostCall` generates. */\n\t#isHostCall(node: Expression): node is HostCallNode {\n\t\tif (node.type === \"Call\") {\n\t\t\tconst callee = node.callee;\n\t\t\treturn (\n\t\t\t\tcallee.type === \"Name\" &&\n\t\t\t\t!this.#macros.has(callee.name) &&\n\t\t\t\tthis.#env.functions.get(callee.name)?.kind === \"host\"\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\tnode.type === \"Filter\" &&\n\t\t\tthis.#env.filters.get(node.name)?.kind === \"host\"\n\t\t);\n\t}\n\n\t#hostCall(\n\t\tnode: Expression,\n\t\tcontext: Context,\n\t\ttarget: string,\n\t): string[] | null {\n\t\tif (!this.#isHostCall(node)) return null;\n\t\tconst kind = node.type === \"Filter\" ? \"filter\" : \"function\";\n\t\tconst name = node.type === \"Filter\" ? node.name : node.callee.name;\n\t\tconst input = node.type === \"Filter\" ? node.input : null;\n\t\tconst args = node.args;\n\t\tif (args.some((arg) => arg.type !== \"Positional\")) return unsupported();\n\t\tconst fn = this.#constant(\n\t\t\t`host:${kind}:${name}`,\n\t\t\t\"X\",\n\t\t\t`rt.host(${JSON.stringify(kind)}, ${JSON.stringify(name)})`,\n\t\t);\n\t\tconst span = this.#span(node.span);\n\t\tconst values = [\n\t\t\t...(input ? [this.#expr(input, context, false)] : []),\n\t\t\t...args.map((arg) => this.#expr(arg.value, context, false)),\n\t\t];\n\t\tthis.#fn.waits = true;\n\t\tif (context.pass) {\n\t\t\treturn [\n\t\t\t\tthis.#checkedStep(span),\n\t\t\t\t\"state.steps = steps;\",\n\t\t\t\t`${target} = callHost(run, ${span}, ${fn}, [${values.join(\", \")}]);`,\n\t\t\t\t`${VALUE}${target} ${span} ${fn}`,\n\t\t\t\t\"steps = state.steps;\",\n\t\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t\t];\n\t\t}\n\t\tthis.#fn.waitsInside = true;\n\t\tthis.#fn.inner++;\n\t\treturn [\n\t\t\t// An abort, perhaps from a getter in your data, stops the render before your function is called, as `step` does.\n\t\t\tthis.#checkedStep(span),\n\t\t\t\"state.steps = steps;\",\n\t\t\t`${target} = callHost(run, ${span}, ${fn}, [${values.join(\", \")}]);`,\n\t\t\t`if (${target} instanceof Promise) {`,\n\t\t\t// The text so far goes out first, so a streamed render can send it while this waits.\n\t\t\t`\\twrite(run, out, s, ${span});`,\n\t\t\t'\\ts = \"\";',\n\t\t\t`\\t${FORK}`,\n\t\t\t\"\\ttry {\",\n\t\t\t`\\t\\t${target} = yield ${target};`,\n\t\t\t\"\\t} catch (error) {\",\n\t\t\t`\\t\\tthrow hostError(run, ${span}, ${fn}, error);`,\n\t\t\t\"\\t}\",\n\t\t\t\"}\",\n\t\t\t\"steps = state.steps;\",\n\t\t\t// Your function may have aborted the render, as the next step would notice in a template rendered from source.\n\t\t\t`signal !== undefined && signal.aborted && aborted(run, ${span});`,\n\t\t];\n\t}\n\n\t/**\n\t * `props` without types: checks no undeclared names were passed in strict mode, then fills in defaults and nulls.\n\t * Typed props and rest props stay with the closures.\n\t */\n\t#props(\n\t\tstatement: Extract<Statement, { type: \"Props\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tif (statement.rest || statement.props.some((prop) => prop.type)) {\n\t\t\treturn unsupported();\n\t\t}\n\t\tconst span = this.#span(statement.span);\n\t\tconst names = statement.props.map((prop) => prop.name);\n\t\tconst declared = this.#constant(\n\t\t\t`props:${JSON.stringify(names)}`,\n\t\t\t\"P\",\n\t\t\t`rt.declared(${JSON.stringify(names)})`,\n\t\t);\n\t\tconst lines = [`checkPassed(run, ${span}, ${declared});`];\n\t\tfor (const prop of statement.props) {\n\t\t\tconst key = JSON.stringify(prop.name);\n\t\t\tconst has = this.#temp();\n\t\t\tconst current = this.#temp();\n\t\t\tconst fill = prop.default\n\t\t\t\t? `scope[${key}] = (${this.#expr(prop.default, context, false)}) ?? null;`\n\t\t\t\t: `if (!${has}) scope[${key}] = missingProp(run, ${span}, ${key});`;\n\t\t\t// The prop is now set in this scope, so it seeds the lookup later reads use, unless it holds a function,\n\t\t\t// which a read must refuse. A default may have looked the prop up before it was set.\n\t\t\tconst cached = this.#cached(prop.name, false);\n\t\t\tconst guarded = this.#fn.variables.get(`guarded:${prop.name}`);\n\t\t\tlines.push(\n\t\t\t\t`${has} = hasOwn(scope, ${key});`,\n\t\t\t\t`${current} = ${has} ? scope[${key}] : undefined;`,\n\t\t\t\t`if (${current} === undefined || ${current} === null) {`,\n\t\t\t\t`\\t${fill}`,\n\t\t\t\t`\\t${current} = scope[${key}];`,\n\t\t\t\t\"}\",\n\t\t\t\t`${cached.value} = typeof ${current} === \"function\" ? undefined : ${current}${setPlain(cached.plain, current)};`,\n\t\t\t\t...(guarded ? [`${guarded.value} = undefined;`] : []),\n\t\t\t);\n\t\t}\n\t\treturn lines;\n\t}\n\n\t#include(\n\t\tstatement: Extract<Statement, { type: \"Include\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst target = this.#target(statement.template, statement.with, context);\n\t\tconst variables = this.#variables(statement.with, context);\n\t\treturn [\n\t\t\t`${this.#step(span)};`,\n\t\t\t...target.lines,\n\t\t\t...variables.lines,\n\t\t\t...variables.charge(span),\n\t\t\t...this.#wait(\n\t\t\t\tspan,\n\t\t\t\tvariables.embed(span, target.name, \"null\", statement.ignoreMissing),\n\t\t\t\tcontext.top,\n\t\t\t),\n\t\t];\n\t}\n\n\t/**\n\t * An include's or component's template name. `\"prefix\" ~ key`, with a known `with` hash, keeps the key apart, so\n\t * `embedKeyed` can find the template without building the name; a key that isn't a string is joined as usual.\n\t */\n\t#target(\n\t\tnode: Expression,\n\t\twithNode: Expression | null,\n\t\tcontext: Context,\n\t): { lines: string[]; name: TemplateTarget } {\n\t\tif (\n\t\t\tisKnownWith(withNode) &&\n\t\t\tnode.type === \"Binary\" &&\n\t\t\tnode.operator === \"~\" &&\n\t\t\tnode.left.type === \"Literal\" &&\n\t\t\ttypeof node.left.value === \"string\"\n\t\t) {\n\t\t\tconst prefix = node.left.value;\n\t\t\tconst key = this.#temp();\n\t\t\tconst joined = this.#temp();\n\t\t\tconst nameSpan = this.#span(node.span);\n\t\t\treturn {\n\t\t\t\tlines: [\n\t\t\t\t\t`${key} = ${this.#expr(node.right, context, false)};`,\n\t\t\t\t\t`${joined} = typeof ${key} === \"string\" ? null : concat(run, ${nameSpan}, ${JSON.stringify(prefix)}, ${key});`,\n\t\t\t\t],\n\t\t\t\tname: { kind: \"keyed\", prefix, key, joined, nameSpan },\n\t\t\t};\n\t\t}\n\t\tconst js = this.#temp();\n\t\treturn {\n\t\t\tlines: [`${js} = ${this.#expr(node, context, false)};`],\n\t\t\tname: { kind: \"value\", js },\n\t\t};\n\t}\n\n\t/**\n\t * An include's or component's `with` value. A hash of known keys, or none, becomes the template's scope here, so\n\t * no hash is made and copied, and each name passed counts a step, as `embed` counts them; anything else is passed\n\t * to `embed`, which checks, counts and copies it.\n\t */\n\t#variables(\n\t\tnode: Expression | null,\n\t\tcontext: Context,\n\t): {\n\t\tlines: string[];\n\t\t/** Lines that count the steps for the names passed, at the tag. */\n\t\tcharge: (span: string) => string[];\n\t\tembed: (\n\t\t\tspan: string,\n\t\t\tname: TemplateTarget,\n\t\t\tslots: string,\n\t\t\tignoreMissing: boolean,\n\t\t) => string;\n\t} {\n\t\tif (node !== null && !isKnownWith(node)) {\n\t\t\tconst value = this.#temp();\n\t\t\treturn {\n\t\t\t\tlines: [`${value} = ${this.#expr(node, context, false)};`],\n\t\t\t\tcharge: () => [],\n\t\t\t\tembed: (span, name, slots, ignoreMissing) =>\n\t\t\t\t\t`embed(run, out, ${span}, ${(name as { js: string }).js}, ${value}, ${slots}, ${ignoreMissing})`,\n\t\t\t};\n\t\t}\n\t\tconst scope = this.#temp();\n\t\tconst lines = [`${scope} = childScope(state.globals);`];\n\t\t// The names passed, in the order a hash holds its keys, as `embed` lists them: whole numbers first.\n\t\tconst order: Record<string, true> = Object.create(null);\n\t\tfor (const entry of node?.type === \"Hash\" ? node.entries : []) {\n\t\t\tif (entry.type !== \"Property\") return unsupported();\n\t\t\tconst key = String((entry.key as { value: unknown }).value);\n\t\t\torder[key] = true;\n\t\t\tlines.push(\n\t\t\t\t`${scope}[${JSON.stringify(key)}] = (${this.#expr(entry.value, context, false)}) ?? null;`,\n\t\t\t);\n\t\t}\n\t\tconst keys = Object.keys(order);\n\t\tconst passed = this.#constant(\n\t\t\t`passed:${JSON.stringify(keys)}`,\n\t\t\t\"P\",\n\t\t\t`Object.freeze(${JSON.stringify(keys)})`,\n\t\t);\n\t\treturn {\n\t\t\tlines,\n\t\t\tcharge: (span) =>\n\t\t\t\tkeys.length === 0\n\t\t\t\t\t? []\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t`if ((steps += ${keys.length}) > maxSteps) stepLimit(run, ${span});`,\n\t\t\t\t\t\t],\n\t\t\tembed: (span, name, slots, ignoreMissing) => {\n\t\t\t\tconst rest = `${scope}, ${passed}, ${slots}, ${ignoreMissing})`;\n\t\t\t\treturn name.kind === \"keyed\"\n\t\t\t\t\t? `(${name.joined} === null ? embedKeyed(run, out, ${span}, ${JSON.stringify(name.prefix)}, ${name.key}, ${name.nameSpan}, ${rest} : embedScope(run, out, ${span}, ${name.joined}, ${rest})`\n\t\t\t\t\t: `embedScope(run, out, ${span}, ${name.js}, ${rest}`;\n\t\t\t},\n\t\t};\n\t}\n\n\t/** A component. Its fills become functions here, so they can read the loops around them. */\n\t#component(\n\t\tstatement: Extract<Statement, { type: \"Component\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst fills = statement.fills.map((fill) => ({\n\t\t\tname: fill.name,\n\t\t\tbody: fill.body,\n\t\t}));\n\t\tif (statement.body.some((child) => !isBlank(child))) {\n\t\t\tfills.push({ name: DEFAULT_SLOT, body: statement.body });\n\t\t}\n\t\tconst slots = this.#temp();\n\t\tconst target = this.#target(statement.template, statement.with, context);\n\t\tconst variables = this.#variables(statement.with, context);\n\t\treturn [\n\t\t\t`${this.#step(span)};`,\n\t\t\t...target.lines,\n\t\t\t...variables.lines,\n\t\t\t`${slots} = new Map();`,\n\t\t\t...fills.map(\n\t\t\t\t(fill) =>\n\t\t\t\t\t`${slots}.set(${JSON.stringify(fill.name)}, { body: ${this.#nested(fill.body, statement.span, context)}, run, scope: ${context.scope}, sets: ${mayWrite(fill.body)} });`,\n\t\t\t),\n\t\t\t...variables.charge(span),\n\t\t\t...this.#wait(\n\t\t\t\tspan,\n\t\t\t\tvariables.embed(span, target.name, slots, false),\n\t\t\t\tcontext.top,\n\t\t\t),\n\t\t\t// Fills render in this scope, and may set variables in it, as may a block they place.\n\t\t\t...(fills.some((fill) => setsVariables(fill.body))\n\t\t\t\t? this.#forgetAll()\n\t\t\t\t: fills.some((fill) =>\n\t\t\t\t\t\t\tcontainsNode(fill.body, (record) => record.type === \"Block\"),\n\t\t\t\t\t )\n\t\t\t\t\t? this.#afterBlocks()\n\t\t\t\t\t: []),\n\t\t];\n\t}\n\n\t/** A slot: the caller's fill, or the fallback. */\n\t#slot(\n\t\tstatement: Extract<Statement, { type: \"Slot\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tconst span = this.#span(statement.span);\n\t\tconst fill = this.#temp();\n\t\t// The fallback renders in a scope of its own, so variables it declares stay inside it.\n\t\tconst sets = [...setsIn(statement.body)];\n\t\tconst scope = sets.length > 0 ? this.#temp() : context.scope;\n\t\tlet fallback = this.#body(statement.body, { ...context, scope });\n\t\tif (sets.length > 0) {\n\t\t\tfallback = [\n\t\t\t\t`${scope} = childScope(${context.scope});`,\n\t\t\t\t...fallback,\n\t\t\t\t...sets.flatMap((name) => this.#forget(name)),\n\t\t\t];\n\t\t}\n\t\treturn [\n\t\t\t`${fill} = run.slots === null ? undefined : run.slots.get(${JSON.stringify(statement.name)});`,\n\t\t\t`if (${fill} !== undefined) {`,\n\t\t\t...indent(\n\t\t\t\tthis.#wait(span, `fillSlot(run, ${span}, ${fill}, out)`, context.top),\n\t\t\t),\n\t\t\t\"} else {\",\n\t\t\t...indent(fallback),\n\t\t\t\"}\",\n\t\t];\n\t}\n\n\t/**\n\t * Places a block. The closure compiler keeps the block's definition, so its body is searched for runs separately.\n\t * Blocks inside generated loops stay with the closures, since a block can read the loop it is placed in.\n\t */\n\t#block(\n\t\tstatement: Extract<Statement, { type: \"Block\" }>,\n\t\tcontext: Context,\n\t): string[] {\n\t\tif (context.inLoop) return unsupported();\n\t\tthis.#pending.push([statement.body, context.strategy]);\n\t\tconst span = this.#span(statement.span);\n\t\treturn [\n\t\t\t...this.#wait(\n\t\t\t\tspan,\n\t\t\t\t`placeBlock(run, ${span}, ${JSON.stringify(statement.name)}, ${context.scope}, out)`,\n\t\t\t\tcontext.top,\n\t\t\t),\n\t\t\t...this.#afterBlocks(),\n\t\t];\n\t}\n\n\t/** Forgets every variable lookup after a block is placed when the block, perhaps a child template's version, may set any variable. */\n\t#afterBlocks(): string[] {\n\t\treturn [\"if (blockSets(run)) {\", ...indent(this.#forgetAll()), \"}\"];\n\t}\n\n\t// Expressions\n\n\t/** Writes an expression. `guard` is set where a missing variable or property is allowed; see `MISSING`. */\n\t#expr(node: Expression, context: Context, guard: boolean): string {\n\t\tif (++this.#depth > MAX_DEPTH) return unsupported();\n\t\ttry {\n\t\t\treturn this.#expression(node, context, guard);\n\t\t} finally {\n\t\t\tthis.#depth--;\n\t\t}\n\t}\n\n\t#expression(node: Expression, context: Context, guard: boolean): string {\n\t\tswitch (node.type) {\n\t\t\tcase \"Literal\":\n\t\t\t\treturn literal(node.value);\n\t\t\tcase \"Name\":\n\t\t\t\treturn this.#name(node.name, node.span, context, guard);\n\t\t\tcase \"Member\":\n\t\t\t\treturn this.#member(node, context, guard);\n\t\t\tcase \"OptionalChain\": {\n\t\t\t\tconst value = this.#temp();\n\t\t\t\tconst inner = this.#expr(node.expression, context, true);\n\t\t\t\treturn `(${value} = ${inner}, ${value} === SHORT || ${value} === MISSING ? ${guard ? \"MISSING\" : \"null\"} : ${value})`;\n\t\t\t}\n\t\t\tcase \"Unary\":\n\t\t\t\treturn this.#unary(node, context);\n\t\t\tcase \"Binary\":\n\t\t\t\treturn this.#binary(node, context);\n\t\t\tcase \"Conditional\": {\n\t\t\t\tconst test = this.#condition(node.test, context);\n\t\t\t\tconst yes = this.#expr(node.consequent, context, false);\n\t\t\t\tconst no = node.alternate\n\t\t\t\t\t? this.#expr(node.alternate, context, false)\n\t\t\t\t\t: \"null\";\n\t\t\t\treturn `(${test} ? ${yes} : ${no})`;\n\t\t\t}\n\t\t\tcase \"Filter\":\n\t\t\t\treturn this.#filter(node, context);\n\t\t\tcase \"Test\":\n\t\t\t\treturn this.#test(node, context);\n\t\t\tcase \"Call\":\n\t\t\t\treturn this.#call(node, context);\n\t\t\tcase \"Array\":\n\t\t\t\treturn `[${node.elements\n\t\t\t\t\t.map((element) =>\n\t\t\t\t\t\telement.type === \"Spread\"\n\t\t\t\t\t\t\t? unsupported()\n\t\t\t\t\t\t\t: this.#expr(element, context, false),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\", \")}]`;\n\t\t\tcase \"Hash\":\n\t\t\t\treturn `{ ${node.entries\n\t\t\t\t\t.map((entry) => {\n\t\t\t\t\t\tif (entry.type === \"Spread\" || entry.key.type !== \"Literal\") {\n\t\t\t\t\t\t\treturn unsupported();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst key = String(entry.key.value);\n\t\t\t\t\t\tif (key === \"__proto__\") return unsupported();\n\t\t\t\t\t\treturn `${JSON.stringify(key)}: ${this.#expr(entry.value, context, false)}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\", \")} }`;\n\t\t\tcase \"Interpolation\": {\n\t\t\t\tconst span = this.#span(node.span);\n\t\t\t\tconst parts = node.parts.map((part) => {\n\t\t\t\t\tconst value = this.#temp();\n\t\t\t\t\treturn { value, code: this.#expr(part, context, false) };\n\t\t\t\t});\n\t\t\t\tconst assigned = parts.map(({ value, code }) => `${value} = ${code}`);\n\t\t\t\tconst joined = parts\n\t\t\t\t\t.map(({ value }) => `str(run, ${span}, ${value})`)\n\t\t\t\t\t.join(\" + \");\n\t\t\t\treturn `(${[...assigned, `joined(run, ${span}, ${joined || '\"\"'})`].join(\", \")})`;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn unsupported();\n\t\t}\n\t}\n\n\t#name(name: string, at: Span, context: Context, guard: boolean): string {\n\t\tconst binding = context.bindings.get(name);\n\t\tconst span = this.#span(at);\n\t\tif (binding?.kind === \"value\") {\n\t\t\tconst js = binding.js;\n\t\t\treturn `(typeof ${js} === \"function\" ? checkValue(run, ${span}, ${js}, ${JSON.stringify(name)}) : ${js})`;\n\t\t}\n\t\tif (binding?.kind === \"loop\") {\n\t\t\treturn `loop(${binding.index}, ${binding.length})`;\n\t\t}\n\t\t// A missing variable still fails where it is first used, as nothing is stored until a lookup succeeds.\n\t\tconst { value, plain } = this.#cached(name, guard);\n\t\treturn `(${value} !== undefined ? ${value} : (${value} = ${guard ? \"guardedName\" : \"name\"}(run, ${span}, ${context.scope}, ${JSON.stringify(name)})${setPlain(plain, value)}, ${value}))`;\n\t}\n\n\t#cached(name: string, guard: boolean): Cached {\n\t\tconst key = `${guard ? \"guarded\" : \"plain\"}:${name}`;\n\t\tlet cached = this.#fn.variables.get(key);\n\t\tif (cached === undefined) {\n\t\t\tconst index = this.#fn.variables.size;\n\t\t\tcached = { value: `${guard ? \"g\" : \"c\"}${index}`, plain: `f${index}` };\n\t\t\tthis.#fn.variables.set(key, cached);\n\t\t}\n\t\treturn cached;\n\t}\n\n\t#member(\n\t\tnode: Extract<Expression, { type: \"Member\" }>,\n\t\tcontext: Context,\n\t\tguard: boolean,\n\t): string {\n\t\tconst span = this.#span(node.span);\n\t\tconst { object, property, optional } = node;\n\t\tconst flags = `${optional}, ${guard}`;\n\t\tif (property.type !== \"Literal\") {\n\t\t\tconst value = this.#temp();\n\t\t\tconst target = this.#expr(object, context, guard);\n\t\t\tconst key = this.#expr(property, context, false);\n\t\t\t// A chain that stops at a `?.` leaves the key unevaluated.\n\t\t\tconst stops = optional\n\t\t\t\t? `${value} === SHORT || ${value} === MISSING || ${value} === null || ${value} === undefined`\n\t\t\t\t: `${value} === SHORT`;\n\t\t\treturn `(${value} = ${target}, ${stops} ? SHORT : readMember(run, ${span}, ${value}, ${key}, ${flags}))`;\n\t\t}\n\t\tconst key = property.value;\n\t\t// `loop.index` and the rest read the loop's counter.\n\t\tif (object.type === \"Name\" && typeof key === \"string\") {\n\t\t\tconst binding = context.bindings.get(object.name);\n\t\t\tconst field = LOOP_FIELDS[key];\n\t\t\tif (\n\t\t\t\tbinding?.kind === \"loop\" &&\n\t\t\t\tfield &&\n\t\t\t\tObject.hasOwn(LOOP_FIELDS, key)\n\t\t\t) {\n\t\t\t\treturn field(binding.index, binding.length);\n\t\t\t}\n\t\t}\n\t\tif (typeof key !== \"string\" || BLOCKED_NAMES.has(key)) {\n\t\t\tconst target = this.#expr(object, context, guard);\n\t\t\treturn `readMember(run, ${span}, ${target}, ${literal(key)}, ${flags})`;\n\t\t}\n\t\t// Own properties of plain objects are read inline, through a property access V8 caches for this one place. A value\n\t\t// can only be inherited if it is the one `Object.prototype` holds, so only then is the property checked to be own.\n\t\tconst value = this.#temp();\n\t\tconst item = this.#temp();\n\t\tconst read = access(key);\n\t\tconst known = this.#plainObject(object, context, guard, value);\n\t\tconst site = this.#constant(\n\t\t\t`read:${span}:${key}`,\n\t\t\t\"P\",\n\t\t\t`[${span}, ${JSON.stringify(key)}]`,\n\t\t);\n\t\tthis.#fn.reads = true;\n\t\t// The object is read first, since reading it may set `at` for its own property.\n\t\treturn [\n\t\t\t`(${known.target}, at = ${site}, ${known.plain}`,\n\t\t\t`&& (${item} = ${value}${read}) !== undefined && typeof ${item} !== \"function\"`,\n\t\t\t`&& (${item} !== objectPrototype${read} || hasOwn(${value}, ${JSON.stringify(key)}))`,\n\t\t\t`? ${item} : readMember(run, ${span}, ${known.slow}, ${JSON.stringify(key)}, ${flags}))`,\n\t\t].join(\" \");\n\t}\n\n\t/**\n\t * The object a property is read from, put in `value`, and a check that it is a plain object. Variables already\n\t * know: a loop variable is checked once per pass, and a variable from outside once per run. `slow` is the object\n\t * for `readMember`, checked as a variable would be when it is a loop variable holding a function.\n\t */\n\t#plainObject(\n\t\tobject: Expression,\n\t\tcontext: Context,\n\t\tguard: boolean,\n\t\tvalue: string,\n\t): { target: string; plain: string; slow: string } {\n\t\tif (object.type === \"Name\") {\n\t\t\tconst binding = context.bindings.get(object.name);\n\t\t\tif (binding?.kind === \"value\") {\n\t\t\t\tthis.#plainUsed.add(binding.plain);\n\t\t\t\tconst span = this.#span(object.span);\n\t\t\t\treturn {\n\t\t\t\t\ttarget: `${value} = ${binding.js}`,\n\t\t\t\t\tplain: binding.plain,\n\t\t\t\t\tslow: `(typeof ${value} === \"function\" ? checkValue(run, ${span}, ${value}, ${JSON.stringify(object.name)}) : ${value})`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (binding === undefined) {\n\t\t\t\tconst target = this.#name(object.name, object.span, context, guard);\n\t\t\t\tconst { plain } = this.#cached(object.name, guard);\n\t\t\t\tthis.#fn.plainUsed.add(plain);\n\t\t\t\treturn { target: `${value} = ${target}`, plain, slow: value };\n\t\t\t}\n\t\t}\n\t\tconst target = this.#expr(object, context, guard);\n\t\treturn {\n\t\t\ttarget: `${value} = ${target}`,\n\t\t\tplain: isPlainCode(value),\n\t\t\tslow: value,\n\t\t};\n\t}\n\n\t/** An expression as a JavaScript boolean, without `truthy` when it is one already, such as a comparison. */\n\t#condition(node: Expression, context: Context): string {\n\t\tconst code = this.#expr(node, context, false);\n\t\treturn isBoolean(node, context) ? code : `truthy(${code})`;\n\t}\n\n\t#unary(\n\t\tnode: Extract<Expression, { type: \"Unary\" }>,\n\t\tcontext: Context,\n\t): string {\n\t\tif (node.operator === \"not\")\n\t\t\treturn `!${this.#condition(node.operand, context)}`;\n\t\tconst operand = this.#expr(node.operand, context, false);\n\t\tconst span = this.#span(node.span);\n\t\tconst value = this.#temp();\n\t\tconst number = `toNumber(run, ${span}, ${value}, ${JSON.stringify(node.operator)})`;\n\t\treturn node.operator === \"-\"\n\t\t\t? `(${value} = ${operand}, typeof ${value} === \"number\" ? -${value} : -${number})`\n\t\t\t: `(${value} = ${operand}, typeof ${value} === \"number\" ? ${value} : ${number})`;\n\t}\n\n\t#binary(\n\t\tnode: Extract<Expression, { type: \"Binary\" }>,\n\t\tcontext: Context,\n\t): string {\n\t\tconst { operator } = node;\n\t\tswitch (operator) {\n\t\t\tcase \"and\":\n\t\t\t\treturn `(${this.#condition(node.left, context)} ? ${this.#condition(node.right, context)} : false)`;\n\t\t\tcase \"or\":\n\t\t\t\treturn `(${this.#condition(node.left, context)} ? true : ${this.#condition(node.right, context)})`;\n\t\t\tcase \"??\": {\n\t\t\t\tconst value = this.#temp();\n\t\t\t\tconst left = this.#expr(node.left, context, true);\n\t\t\t\tconst right = this.#expr(node.right, context, false);\n\t\t\t\treturn `(${value} = ${left}, ${value} === MISSING || ${value} === null || ${value} === undefined ? ${right} : ${value})`;\n\t\t\t}\n\t\t\tcase \"?:\": {\n\t\t\t\tconst value = this.#temp();\n\t\t\t\tconst left = this.#expr(node.left, context, false);\n\t\t\t\tconst right = this.#expr(node.right, context, false);\n\t\t\t\treturn `(${value} = ${left}, truthy(${value}) ? ${value} : ${right})`;\n\t\t\t}\n\t\t}\n\t\tconst span = this.#span(node.span);\n\t\tconst left = this.#expr(node.left, context, false);\n\t\tconst right = this.#expr(node.right, context, false);\n\t\tswitch (operator) {\n\t\t\tcase \"..\":\n\t\t\t\treturn this.#counted(`range(run, ${span}, ${left}, ${right})`);\n\t\t\tcase \"~\": {\n\t\t\t\t// Two strings join here when the result fits the output limit; anything else goes to `concat`.\n\t\t\t\tconst a = this.#temp();\n\t\t\t\tconst b = this.#temp();\n\t\t\t\treturn `(${a} = ${left}, ${b} = ${right}, typeof ${a} === \"string\" && typeof ${b} === \"string\" && ${a}.length + ${b}.length <= maxSize ? ${a} + ${b} : concat(run, ${span}, ${a}, ${b}))`;\n\t\t\t}\n\t\t\tcase \"==\":\n\t\t\t\treturn `equals(${left}, ${right})`;\n\t\t\tcase \"!=\":\n\t\t\t\treturn `!equals(${left}, ${right})`;\n\t\t\tcase \"in\":\n\t\t\t\treturn this.#counted(`contains(run, ${span}, ${left}, ${right})`);\n\t\t\tcase \"not in\":\n\t\t\t\treturn `!${this.#counted(`contains(run, ${span}, ${left}, ${right})`)}`;\n\t\t}\n\t\tconst apply = this.#constant(\n\t\t\t`operator:${operator}`,\n\t\t\t\"O\",\n\t\t\t`rt.operator(${JSON.stringify(operator)})`,\n\t\t);\n\t\tif (!NUMBER_OPERATORS.has(operator)) {\n\t\t\treturn `binary(run, ${span}, ${apply}, ${left}, ${right})`;\n\t\t}\n\t\tconst a = this.#temp();\n\t\tconst b = this.#temp();\n\t\treturn `(${a} = ${left}, ${b} = ${right}, typeof ${a} === \"number\" && typeof ${b} === \"number\" ? ${a} ${operator} ${b} : binary(run, ${span}, ${apply}, ${a}, ${b}))`;\n\t}\n\n\t#filter(\n\t\tnode: Extract<Expression, { type: \"Filter\" }>,\n\t\tcontext: Context,\n\t): string {\n\t\tconst { name, args } = node;\n\t\tconst span = this.#span(node.span);\n\t\tconst strategy = context.strategy || \"html\";\n\t\tif (name === \"default\") {\n\t\t\tconst value = this.#temp();\n\t\t\tconst input = this.#expr(node.input, context, true);\n\t\t\tconst fallback = args[0]\n\t\t\t\t? this.#expr(args[0].value, context, false)\n\t\t\t\t: '\"\"';\n\t\t\treturn `(${value} = ${input}, ${value} === MISSING || isEmpty(${value}) ? ${fallback} : ${value})`;\n\t\t}\n\t\tconst input = this.#expr(node.input, context, false);\n\t\tif (name === \"raw\") {\n\t\t\treturn `raw(run, ${span}, ${input}, ${JSON.stringify(strategy)})`;\n\t\t}\n\t\tif (name === \"escape\") {\n\t\t\tconst chosen = args[0] ? args[0].value : null;\n\t\t\tconst target =\n\t\t\t\tchosen === null\n\t\t\t\t\t? \"html\"\n\t\t\t\t\t: chosen.type === \"Literal\" &&\n\t\t\t\t\t\t ESCAPE_STRATEGIES.includes(chosen.value as EscapeStrategy)\n\t\t\t\t\t\t? (chosen.value as EscapeStrategy)\n\t\t\t\t\t\t: unsupported();\n\t\t\treturn `escape(run, ${span}, ${input}, ${JSON.stringify(target)})`;\n\t\t}\n\t\tconst call = this.#builtin(\"filter\", name, args);\n\t\treturn this.#invoke(span, call.fn, [\n\t\t\tinput,\n\t\t\t...this.#arguments(call, context),\n\t\t]);\n\t}\n\n\t#test(node: Extract<Expression, { type: \"Test\" }>, context: Context): string {\n\t\tconst { name, negated, input } = node;\n\t\tif (name === \"defined\") {\n\t\t\tif (\n\t\t\t\tinput.type === \"Call\" &&\n\t\t\t\tinput.callee.type === \"Name\" &&\n\t\t\t\tinput.callee.name === \"block\"\n\t\t\t) {\n\t\t\t\treturn unsupported();\n\t\t\t}\n\t\t\tconst value = this.#expr(input, context, true);\n\t\t\treturn `(${value} ${negated ? \"===\" : \"!==\"} MISSING)`;\n\t\t}\n\t\tconst span = this.#span(node.span);\n\t\tconst call = this.#builtin(\"test\", name, node.args);\n\t\t// `odd` and `even` never fail and count no steps of their own, so they are written out, after the call's step.\n\t\t// The built-in is still looked up, so a module loaded where `odd` is something else fails as usual.\n\t\tif ((name === \"odd\" || name === \"even\") && node.args.length === 0) {\n\t\t\tconst value = this.#temp();\n\t\t\tconst test =\n\t\t\t\tname === \"even\"\n\t\t\t\t\t? `${value} % 2 === 0`\n\t\t\t\t\t: `(${value} % 2 === 1 || ${value} % 2 === -1)`;\n\t\t\treturn `(${this.#step(span)}, ${value} = ${this.#expr(input, context, false)}, ${negated ? \"!\" : \"\"}(typeof ${value} === \"number\" && ${test}))`;\n\t\t}\n\t\tconst value = this.#invoke(span, call.fn, [\n\t\t\tthis.#expr(input, context, false),\n\t\t\t...this.#arguments(call, context),\n\t\t]);\n\t\treturn `${negated ? \"!\" : \"\"}truthy(${value})`;\n\t}\n\n\t#call(node: Extract<Expression, { type: \"Call\" }>, context: Context): string {\n\t\tconst callee = node.callee;\n\t\tif (\n\t\t\tcallee.type !== \"Name\" ||\n\t\t\tcallee.name === \"parent\" ||\n\t\t\tcallee.name === \"block\" ||\n\t\t\tthis.#macros.has(callee.name)\n\t\t) {\n\t\t\treturn unsupported();\n\t\t}\n\t\tconst span = this.#span(node.span);\n\t\tconst call = this.#builtin(\"function\", callee.name, node.args);\n\t\treturn this.#invoke(span, call.fn, this.#arguments(call, context));\n\t}\n\n\t/** A built-in, with its arguments in parameter order. Host functions may return promises, so they stay with the closures. */\n\t#builtin(\n\t\tkind: \"filter\" | \"test\" | \"function\",\n\t\tname: string,\n\t\targs: Argument[],\n\t): { fn: string; args: (Argument | null)[]; options: number } {\n\t\tconst entries =\n\t\t\tkind === \"filter\"\n\t\t\t\t? this.#env.filters\n\t\t\t\t: kind === \"test\"\n\t\t\t\t\t? this.#env.tests\n\t\t\t\t\t: this.#env.functions;\n\t\tconst entry = entries.get(name);\n\t\tif (entry?.kind !== \"builtin\") return unsupported();\n\t\tconst placed = placeArguments(entry, args, name, unsupported);\n\t\tif (placed.some((arg) => arg?.type === \"Spread\")) return unsupported();\n\t\tconst lookup = kind === \"function\" ? \"fn\" : kind;\n\t\tconst fn = this.#constant(\n\t\t\t`${kind}:${name}`,\n\t\t\tkind === \"filter\" ? \"F\" : kind === \"test\" ? \"T\" : \"B\",\n\t\t\t`rt.${lookup}(${JSON.stringify(name)})`,\n\t\t);\n\t\treturn {\n\t\t\tfn,\n\t\t\targs: placed,\n\t\t\toptions: entry.options ? (entry.params?.length ?? 0) : -1,\n\t\t};\n\t}\n\n\t/** Arguments in order. A built-in's options hash of literals is made once, frozen, so formatters can cache by it. */\n\t#arguments(\n\t\tcall: { args: (Argument | null)[]; options: number },\n\t\tcontext: Context,\n\t): string[] {\n\t\treturn call.args.map((arg, index) => {\n\t\t\tif (!arg) return \"undefined\";\n\t\t\tconst value = arg.value;\n\t\t\tif (index === call.options && value.type === \"Hash\") {\n\t\t\t\tconst frozen = this.#frozenHash(value);\n\t\t\t\tif (frozen) return frozen;\n\t\t\t}\n\t\t\treturn this.#expr(value, context, false);\n\t\t});\n\t}\n\n\t#frozenHash(node: Extract<Expression, { type: \"Hash\" }>): string | null {\n\t\tconst entries: string[] = [];\n\t\tfor (const entry of node.entries) {\n\t\t\tif (entry.type !== \"Property\" || entry.key.type !== \"Literal\")\n\t\t\t\treturn null;\n\t\t\tif (entry.value.type !== \"Literal\") return null;\n\t\t\tconst key = String(entry.key.value);\n\t\t\tif (key === \"__proto__\") return null;\n\t\t\tentries.push(`${JSON.stringify(key)}: ${literal(entry.value.value)}`);\n\t\t}\n\t\tconst code = `rt.options({ ${entries.join(\", \")} })`;\n\t\treturn this.#constant(`hash:${code}`, \"H\", code);\n\t}\n\n\t/** Counts a step, then calls a built-in with errors located at `span`, as `directCall` does. */\n\t#invoke(span: string, fn: string, args: string[]): string {\n\t\tif (args.length > 4) return unsupported();\n\t\treturn `(${this.#step(span)}, ${this.#counted(`call${args.length}(run, ${span}, ${fn}${args.map((arg) => `, ${arg}`).join(\"\")})`)})`;\n\t}\n}\n","/** Obsolete elements in the HTML standard, by what to use instead. */\nexport const OBSOLETE = new Map(\n\tObject.entries({\n\t\t\"Use <abbr> instead\": [\"acronym\"],\n\t\t\"Use <object> or <embed> instead\": [\"applet\"],\n\t\t\"Use CSS instead\": [\n\t\t\t\"basefont\",\n\t\t\t\"big\",\n\t\t\t\"blink\",\n\t\t\t\"center\",\n\t\t\t\"font\",\n\t\t\t\"marquee\",\n\t\t\t\"multicol\",\n\t\t\t\"nobr\",\n\t\t\t\"spacer\",\n\t\t],\n\t\t\"Use <audio> instead\": [\"bgsound\"],\n\t\t\"Use <ul> instead\": [\"dir\"],\n\t\t\"Use <iframe>, or a layout with CSS, instead\": [\n\t\t\t\"frame\",\n\t\t\t\"frameset\",\n\t\t\t\"noframes\",\n\t\t],\n\t\t\"Use a form with a text field instead\": [\"isindex\"],\n\t\t\"Use the Web Crypto API instead\": [\"keygen\"],\n\t\t\"Use <pre> and <code> instead\": [\"listing\", \"plaintext\", \"xmp\"],\n\t\t\"Use a <button> inside <menu> instead\": [\"menuitem\"],\n\t\t\"Remove it\": [\"nextid\"],\n\t\t\"Use fallback content inside <object> instead\": [\"noembed\"],\n\t\t\"Use attributes on <object> instead\": [\"param\"],\n\t\t\"Use <ruby> with <rt> instead\": [\"rb\", \"rtc\"],\n\t\t\"Use <s>, or <del> for removed text, instead\": [\"strike\"],\n\t\t\"Use <code>, <kbd> or <samp> instead\": [\"tt\"],\n\t}).flatMap(([advice, names]) => names.map((name) => [name, advice] as const)),\n);\n\n/** States and properties from WAI-ARIA 1.2, plus those the 1.3 draft adds. */\nexport const ARIA_ATTRIBUTES = new Set(\n\t[\n\t\t\"activedescendant\",\n\t\t\"atomic\",\n\t\t\"autocomplete\",\n\t\t\"braillelabel\",\n\t\t\"brailleroledescription\",\n\t\t\"busy\",\n\t\t\"checked\",\n\t\t\"colcount\",\n\t\t\"colindex\",\n\t\t\"colindextext\",\n\t\t\"colspan\",\n\t\t\"controls\",\n\t\t\"current\",\n\t\t\"describedby\",\n\t\t\"description\",\n\t\t\"details\",\n\t\t\"disabled\",\n\t\t\"dropeffect\",\n\t\t\"errormessage\",\n\t\t\"expanded\",\n\t\t\"flowto\",\n\t\t\"grabbed\",\n\t\t\"haspopup\",\n\t\t\"hidden\",\n\t\t\"invalid\",\n\t\t\"keyshortcuts\",\n\t\t\"label\",\n\t\t\"labelledby\",\n\t\t\"level\",\n\t\t\"live\",\n\t\t\"modal\",\n\t\t\"multiline\",\n\t\t\"multiselectable\",\n\t\t\"orientation\",\n\t\t\"owns\",\n\t\t\"placeholder\",\n\t\t\"posinset\",\n\t\t\"pressed\",\n\t\t\"readonly\",\n\t\t\"relevant\",\n\t\t\"required\",\n\t\t\"roledescription\",\n\t\t\"rowcount\",\n\t\t\"rowindex\",\n\t\t\"rowindextext\",\n\t\t\"rowspan\",\n\t\t\"selected\",\n\t\t\"setsize\",\n\t\t\"sort\",\n\t\t\"valuemax\",\n\t\t\"valuemin\",\n\t\t\"valuenow\",\n\t\t\"valuetext\",\n\t].map((name) => `aria-${name}`),\n);\n\n/** Roles from WAI-ARIA 1.2, plus those the 1.3 draft adds. */\nexport const ROLES = new Set([\n\t\"alert\",\n\t\"alertdialog\",\n\t\"application\",\n\t\"article\",\n\t\"banner\",\n\t\"blockquote\",\n\t\"button\",\n\t\"caption\",\n\t\"cell\",\n\t\"checkbox\",\n\t\"code\",\n\t\"columnheader\",\n\t\"combobox\",\n\t\"comment\",\n\t\"complementary\",\n\t\"contentinfo\",\n\t\"definition\",\n\t\"deletion\",\n\t\"dialog\",\n\t\"directory\",\n\t\"document\",\n\t\"emphasis\",\n\t\"feed\",\n\t\"figure\",\n\t\"form\",\n\t\"generic\",\n\t\"grid\",\n\t\"gridcell\",\n\t\"group\",\n\t\"heading\",\n\t\"image\",\n\t\"img\",\n\t\"insertion\",\n\t\"link\",\n\t\"list\",\n\t\"listbox\",\n\t\"listitem\",\n\t\"log\",\n\t\"main\",\n\t\"mark\",\n\t\"marquee\",\n\t\"math\",\n\t\"menu\",\n\t\"menubar\",\n\t\"menuitem\",\n\t\"menuitemcheckbox\",\n\t\"menuitemradio\",\n\t\"meter\",\n\t\"navigation\",\n\t\"none\",\n\t\"note\",\n\t\"option\",\n\t\"paragraph\",\n\t\"presentation\",\n\t\"progressbar\",\n\t\"radio\",\n\t\"radiogroup\",\n\t\"region\",\n\t\"row\",\n\t\"rowgroup\",\n\t\"rowheader\",\n\t\"scrollbar\",\n\t\"search\",\n\t\"searchbox\",\n\t\"sectionfooter\",\n\t\"sectionheader\",\n\t\"separator\",\n\t\"slider\",\n\t\"spinbutton\",\n\t\"status\",\n\t\"strong\",\n\t\"subscript\",\n\t\"suggestion\",\n\t\"superscript\",\n\t\"switch\",\n\t\"tab\",\n\t\"table\",\n\t\"tablist\",\n\t\"tabpanel\",\n\t\"term\",\n\t\"textbox\",\n\t\"time\",\n\t\"timer\",\n\t\"toolbar\",\n\t\"tooltip\",\n\t\"tree\",\n\t\"treegrid\",\n\t\"treeitem\",\n]);\n\n/** Roles that only organise the ARIA spec. Pages must not use them. */\nexport const ABSTRACT_ROLES = new Set([\n\t\"command\",\n\t\"composite\",\n\t\"input\",\n\t\"landmark\",\n\t\"range\",\n\t\"roletype\",\n\t\"section\",\n\t\"sectionhead\",\n\t\"select\",\n\t\"structure\",\n\t\"widget\",\n\t\"window\",\n]);\n\n/** Elements whose content is text, so tags inside them aren't elements. */\nexport const RAW_TEXT = new Set([\n\t\"script\",\n\t\"style\",\n\t\"textarea\",\n\t\"title\",\n\t\"xmp\",\n\t\"iframe\",\n\t\"noembed\",\n\t\"noframes\",\n\t\"plaintext\",\n]);\n\n/** Elements whose content follows SVG or MathML rules instead of HTML's. */\nexport const FOREIGN = new Set([\"svg\", \"math\"]);\n\n/** Elements with no content or end tag. */\nexport const VOID = new Set([\n\t\"area\",\n\t\"base\",\n\t\"basefont\",\n\t\"bgsound\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"frame\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"keygen\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\n/** What each obsolete attribute is replaced by, by element. Attributes missing from an element's list use CSS. */\nconst CSS = \"Use CSS instead\";\nconst REMOVE = \"Remove it\";\nconst USE_ID = \"Use id instead\";\nconst presentational = (...names: string[]) =>\n\tObject.fromEntries(names.map((name) => [name, CSS]));\nconst cellAttributes = presentational(\n\t\"align\",\n\t\"bgcolor\",\n\t\"char\",\n\t\"charoff\",\n\t\"height\",\n\t\"nowrap\",\n\t\"valign\",\n\t\"width\",\n);\nconst rowGroupAttributes = presentational(\"align\", \"char\", \"charoff\", \"valign\");\n\nexport const OBSOLETE_ATTRIBUTES: Record<string, Record<string, string>> = {\n\ta: {\n\t\tcharset: REMOVE,\n\t\tcoords: \"Use <area> instead\",\n\t\tmethods: REMOVE,\n\t\tname: USE_ID,\n\t\trev: \"Use rel instead\",\n\t\tshape: \"Use <area> instead\",\n\t\turn: REMOVE,\n\t},\n\tarea: { nohref: \"Leave out href instead\", type: REMOVE },\n\tbody: presentational(\n\t\t\"alink\",\n\t\t\"background\",\n\t\t\"bgcolor\",\n\t\t\"bottommargin\",\n\t\t\"leftmargin\",\n\t\t\"link\",\n\t\t\"marginbottom\",\n\t\t\"marginheight\",\n\t\t\"marginleft\",\n\t\t\"marginright\",\n\t\t\"margintop\",\n\t\t\"marginwidth\",\n\t\t\"rightmargin\",\n\t\t\"text\",\n\t\t\"topmargin\",\n\t\t\"vlink\",\n\t),\n\tbr: presentational(\"clear\"),\n\tcaption: presentational(\"align\"),\n\tcol: presentational(\"align\", \"char\", \"charoff\", \"valign\", \"width\"),\n\tdiv: presentational(\"align\"),\n\tdl: presentational(\"compact\"),\n\tembed: { ...presentational(\"align\", \"hspace\", \"vspace\"), name: USE_ID },\n\thead: { profile: REMOVE },\n\thr: presentational(\"align\", \"color\", \"noshade\", \"size\", \"width\"),\n\thtml: { manifest: \"Use a service worker instead\", version: REMOVE },\n\t...Object.fromEntries(\n\t\t[\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"legend\", \"p\"].map((name) => [\n\t\t\tname,\n\t\t\tpresentational(\"align\"),\n\t\t]),\n\t),\n\tiframe: {\n\t\t...presentational(\n\t\t\t\"align\",\n\t\t\t\"allowtransparency\",\n\t\t\t\"frameborder\",\n\t\t\t\"framespacing\",\n\t\t\t\"hspace\",\n\t\t\t\"marginheight\",\n\t\t\t\"marginwidth\",\n\t\t\t\"scrolling\",\n\t\t\t\"vspace\",\n\t\t),\n\t\tlongdesc: \"Link to the description instead\",\n\t},\n\timg: {\n\t\t...presentational(\"align\", \"border\", \"hspace\", \"vspace\"),\n\t\tlongdesc: \"Link to the description instead\",\n\t\tlowsrc: \"Use srcset instead\",\n\t\tname: USE_ID,\n\t},\n\tinput: {\n\t\t...presentational(\"align\", \"hspace\", \"vspace\"),\n\t\tismap: \"Use <img> for image maps instead\",\n\t\tusemap: \"Use <img> for image maps instead\",\n\t},\n\tli: presentational(\"type\"),\n\tlink: { charset: REMOVE, rev: \"Use rel instead\", target: REMOVE },\n\tmenu: presentational(\"compact\"),\n\tmeta: { scheme: REMOVE },\n\tobject: {\n\t\t...presentational(\"align\", \"border\", \"hspace\", \"vspace\"),\n\t\tarchive: \"Use data and type instead\",\n\t\tclassid: \"Use data and type instead\",\n\t\tcode: \"Use data and type instead\",\n\t\tcodebase: \"Use data and type instead\",\n\t\tcodetype: \"Use data and type instead\",\n\t\tdeclare: REMOVE,\n\t\tstandby: REMOVE,\n\t},\n\tol: presentational(\"compact\"),\n\toption: { name: USE_ID },\n\tpre: presentational(\"width\"),\n\tscript: {\n\t\tcharset: REMOVE,\n\t\tevent: REMOVE,\n\t\tfor: REMOVE,\n\t\tlanguage: REMOVE,\n\t},\n\ttable: {\n\t\t...presentational(\n\t\t\t\"align\",\n\t\t\t\"bgcolor\",\n\t\t\t\"border\",\n\t\t\t\"cellpadding\",\n\t\t\t\"cellspacing\",\n\t\t\t\"frame\",\n\t\t\t\"rules\",\n\t\t\t\"width\",\n\t\t),\n\t\tsummary: \"Use <caption> instead\",\n\t},\n\ttbody: rowGroupAttributes,\n\tthead: rowGroupAttributes,\n\ttfoot: rowGroupAttributes,\n\ttr: { ...rowGroupAttributes, bgcolor: CSS },\n\ttd: {\n\t\t...cellAttributes,\n\t\tabbr: \"Use <th> with abbr instead\",\n\t\taxis: \"Use scope on <th> instead\",\n\t\tscope: \"Use <th> instead\",\n\t},\n\tth: { ...cellAttributes, axis: \"Use scope instead\" },\n\tul: presentational(\"compact\", \"type\"),\n};\n\n/**\n * The keywords an attribute accepts. `on` lists the elements it applies to, or is `*` for any element. `tokens` takes a\n * list of keywords separated by spaces. `other` accepts values that aren't keywords, such as `target` names.\n */\nexport type AttributeValues = {\n\ton: readonly string[] | \"*\";\n\tvalues: readonly string[];\n\tcaseSensitive?: true;\n\ttokens?: true;\n\tother?: (value: string) => boolean;\n};\n\nconst FORM_METHODS = [\"get\", \"post\", \"dialog\"];\nconst ENCTYPES = [\n\t\"application/x-www-form-urlencoded\",\n\t\"multipart/form-data\",\n\t\"text/plain\",\n];\nconst TARGETS = [\"_blank\", \"_parent\", \"_self\", \"_top\", \"_unfencedTop\"];\n/** A target that isn't a keyword is a name, and names can't start with `_`. */\nconst targetName = (value: string) => !value.startsWith(\"_\");\n\nexport const ATTRIBUTE_VALUES: Record<string, readonly AttributeValues[]> = {\n\ttype: [\n\t\t{\n\t\t\ton: [\"input\"],\n\t\t\tvalues: [\n\t\t\t\t\"button\",\n\t\t\t\t\"checkbox\",\n\t\t\t\t\"color\",\n\t\t\t\t\"date\",\n\t\t\t\t\"datetime-local\",\n\t\t\t\t\"email\",\n\t\t\t\t\"file\",\n\t\t\t\t\"hidden\",\n\t\t\t\t\"image\",\n\t\t\t\t\"month\",\n\t\t\t\t\"number\",\n\t\t\t\t\"password\",\n\t\t\t\t\"radio\",\n\t\t\t\t\"range\",\n\t\t\t\t\"reset\",\n\t\t\t\t\"search\",\n\t\t\t\t\"submit\",\n\t\t\t\t\"tel\",\n\t\t\t\t\"text\",\n\t\t\t\t\"time\",\n\t\t\t\t\"url\",\n\t\t\t\t\"week\",\n\t\t\t],\n\t\t},\n\t\t{ on: [\"button\"], values: [\"button\", \"reset\", \"submit\"] },\n\t\t{ on: [\"ol\"], values: [\"1\", \"a\", \"A\", \"i\", \"I\"], caseSensitive: true },\n\t],\n\tmethod: [{ on: [\"form\"], values: FORM_METHODS }],\n\tformmethod: [{ on: [\"button\", \"input\"], values: FORM_METHODS }],\n\tenctype: [{ on: [\"form\"], values: ENCTYPES }],\n\tformenctype: [{ on: [\"button\", \"input\"], values: ENCTYPES }],\n\tautocomplete: [{ on: [\"form\"], values: [\"on\", \"off\"] }],\n\tloading: [{ on: [\"img\", \"iframe\"], values: [\"eager\", \"lazy\"] }],\n\tdecoding: [{ on: [\"img\"], values: [\"async\", \"auto\", \"sync\"] }],\n\tfetchpriority: [\n\t\t{\n\t\t\ton: [\"img\", \"iframe\", \"link\", \"script\"],\n\t\t\tvalues: [\"auto\", \"high\", \"low\"],\n\t\t},\n\t],\n\tcrossorigin: [\n\t\t{\n\t\t\ton: [\"audio\", \"img\", \"link\", \"script\", \"video\"],\n\t\t\tvalues: [\"\", \"anonymous\", \"use-credentials\"],\n\t\t},\n\t],\n\treferrerpolicy: [\n\t\t{\n\t\t\ton: [\"a\", \"area\", \"iframe\", \"img\", \"link\", \"script\"],\n\t\t\tvalues: [\n\t\t\t\t\"\",\n\t\t\t\t\"no-referrer\",\n\t\t\t\t\"no-referrer-when-downgrade\",\n\t\t\t\t\"origin\",\n\t\t\t\t\"origin-when-cross-origin\",\n\t\t\t\t\"same-origin\",\n\t\t\t\t\"strict-origin\",\n\t\t\t\t\"strict-origin-when-cross-origin\",\n\t\t\t\t\"unsafe-url\",\n\t\t\t],\n\t\t},\n\t],\n\ttarget: [\n\t\t{ on: [\"a\", \"area\", \"base\", \"form\"], values: TARGETS, other: targetName },\n\t],\n\tformtarget: [{ on: [\"button\", \"input\"], values: TARGETS, other: targetName }],\n\tpreload: [\n\t\t{ on: [\"audio\", \"video\"], values: [\"\", \"auto\", \"metadata\", \"none\"] },\n\t],\n\tscope: [{ on: [\"th\"], values: [\"col\", \"colgroup\", \"row\", \"rowgroup\"] }],\n\tkind: [\n\t\t{\n\t\t\ton: [\"track\"],\n\t\t\tvalues: [\"captions\", \"chapters\", \"descriptions\", \"metadata\", \"subtitles\"],\n\t\t},\n\t],\n\twrap: [{ on: [\"textarea\"], values: [\"hard\", \"soft\"] }],\n\tshape: [{ on: [\"area\"], values: [\"circle\", \"default\", \"poly\", \"rect\"] }],\n\tcapture: [{ on: [\"input\"], values: [\"environment\", \"user\"] }],\n\tsandbox: [\n\t\t{\n\t\t\ton: [\"iframe\"],\n\t\t\ttokens: true,\n\t\t\tvalues: [\n\t\t\t\t\"allow-downloads\",\n\t\t\t\t\"allow-forms\",\n\t\t\t\t\"allow-modals\",\n\t\t\t\t\"allow-orientation-lock\",\n\t\t\t\t\"allow-pointer-lock\",\n\t\t\t\t\"allow-popups\",\n\t\t\t\t\"allow-popups-to-escape-sandbox\",\n\t\t\t\t\"allow-presentation\",\n\t\t\t\t\"allow-same-origin\",\n\t\t\t\t\"allow-scripts\",\n\t\t\t\t\"allow-storage-access-by-user-activation\",\n\t\t\t\t\"allow-top-navigation\",\n\t\t\t\t\"allow-top-navigation-by-user-activation\",\n\t\t\t\t\"allow-top-navigation-to-custom-protocols\",\n\t\t\t],\n\t\t},\n\t],\n\tblocking: [\n\t\t{ on: [\"link\", \"script\", \"style\"], tokens: true, values: [\"render\"] },\n\t],\n\tpopovertargetaction: [\n\t\t{ on: [\"button\", \"input\"], values: [\"hide\", \"show\", \"toggle\"] },\n\t],\n\tcommand: [\n\t\t{\n\t\t\ton: [\"button\"],\n\t\t\tvalues: [\n\t\t\t\t\"close\",\n\t\t\t\t\"hide-popover\",\n\t\t\t\t\"request-close\",\n\t\t\t\t\"show-modal\",\n\t\t\t\t\"show-popover\",\n\t\t\t\t\"toggle-popover\",\n\t\t\t],\n\t\t\tother: (value) => value.startsWith(\"--\"),\n\t\t},\n\t],\n\tshadowrootmode: [{ on: [\"template\"], values: [\"closed\", \"open\"] }],\n\tdir: [{ on: \"*\", values: [\"auto\", \"ltr\", \"rtl\"] }],\n\thidden: [{ on: \"*\", values: [\"\", \"hidden\", \"until-found\"] }],\n\tcontenteditable: [\n\t\t{ on: \"*\", values: [\"\", \"false\", \"plaintext-only\", \"true\"] },\n\t],\n\tdraggable: [{ on: \"*\", values: [\"false\", \"true\"] }],\n\tspellcheck: [{ on: \"*\", values: [\"\", \"false\", \"true\"] }],\n\ttranslate: [{ on: \"*\", values: [\"\", \"no\", \"yes\"] }],\n\tautocapitalize: [\n\t\t{\n\t\t\ton: \"*\",\n\t\t\tvalues: [\"characters\", \"none\", \"off\", \"on\", \"sentences\", \"words\"],\n\t\t},\n\t],\n\tinputmode: [\n\t\t{\n\t\t\ton: \"*\",\n\t\t\tvalues: [\n\t\t\t\t\"decimal\",\n\t\t\t\t\"email\",\n\t\t\t\t\"none\",\n\t\t\t\t\"numeric\",\n\t\t\t\t\"search\",\n\t\t\t\t\"tel\",\n\t\t\t\t\"text\",\n\t\t\t\t\"url\",\n\t\t\t],\n\t\t},\n\t],\n\tenterkeyhint: [\n\t\t{\n\t\t\ton: \"*\",\n\t\t\tvalues: [\"done\", \"enter\", \"go\", \"next\", \"previous\", \"search\", \"send\"],\n\t\t},\n\t],\n\tpopover: [{ on: \"*\", values: [\"\", \"auto\", \"hint\", \"manual\"] }],\n};\n\n/** Boolean attributes, which are on whenever they are present, by the elements that have them. `*` is any element. */\nexport const BOOLEAN_ATTRIBUTES: Record<string, readonly string[] | \"*\"> = {\n\tallowfullscreen: [\"iframe\"],\n\tasync: [\"script\"],\n\tautofocus: \"*\",\n\tautoplay: [\"audio\", \"video\"],\n\tchecked: [\"input\"],\n\tcontrols: [\"audio\", \"video\"],\n\tdefault: [\"track\"],\n\tdefer: [\"script\"],\n\tdisabled: [\n\t\t\"button\",\n\t\t\"fieldset\",\n\t\t\"input\",\n\t\t\"link\",\n\t\t\"optgroup\",\n\t\t\"option\",\n\t\t\"select\",\n\t\t\"textarea\",\n\t],\n\tformnovalidate: [\"button\", \"input\"],\n\tinert: \"*\",\n\tismap: [\"img\"],\n\titemscope: \"*\",\n\tloop: [\"audio\", \"video\"],\n\tmultiple: [\"input\", \"select\"],\n\tmuted: [\"audio\", \"video\"],\n\tnomodule: [\"script\"],\n\tnovalidate: [\"form\"],\n\topen: [\"details\", \"dialog\"],\n\tplaysinline: [\"video\"],\n\treadonly: [\"input\", \"textarea\"],\n\trequired: [\"input\", \"select\", \"textarea\"],\n\treversed: [\"ol\"],\n\tselected: [\"option\"],\n\tshadowrootclonable: [\"template\"],\n\tshadowrootdelegatesfocus: [\"template\"],\n\tshadowrootserializable: [\"template\"],\n};\n\n/** Roles elements always have, whatever their attributes. Lists are left out; see the docs on `html-redundant-role`. */\nexport const IMPLICIT_ROLES: Record<string, string> = {\n\tarticle: \"article\",\n\taside: \"complementary\",\n\tblockquote: \"blockquote\",\n\tbutton: \"button\",\n\tcaption: \"caption\",\n\tcode: \"code\",\n\tdatalist: \"listbox\",\n\tdel: \"deletion\",\n\tdetails: \"group\",\n\tdfn: \"term\",\n\tdialog: \"dialog\",\n\tem: \"emphasis\",\n\tfieldset: \"group\",\n\tfigure: \"figure\",\n\th1: \"heading\",\n\th2: \"heading\",\n\th3: \"heading\",\n\th4: \"heading\",\n\th5: \"heading\",\n\th6: \"heading\",\n\thr: \"separator\",\n\thtml: \"document\",\n\tins: \"insertion\",\n\tmain: \"main\",\n\tmeter: \"meter\",\n\tnav: \"navigation\",\n\toptgroup: \"group\",\n\toption: \"option\",\n\toutput: \"status\",\n\tp: \"paragraph\",\n\tprogress: \"progressbar\",\n\tsearch: \"search\",\n\tstrong: \"strong\",\n\tsub: \"subscript\",\n\tsup: \"superscript\",\n\ttable: \"table\",\n\ttbody: \"rowgroup\",\n\ttextarea: \"textbox\",\n\ttfoot: \"rowgroup\",\n\tthead: \"rowgroup\",\n\ttime: \"time\",\n\ttr: \"row\",\n};\n\n/** The roles `<input>` has for each `type`, when the role doesn't depend on other attributes. */\nexport const INPUT_ROLES: Record<string, string> = {\n\tbutton: \"button\",\n\tcheckbox: \"checkbox\",\n\timage: \"button\",\n\tnumber: \"spinbutton\",\n\tradio: \"radio\",\n\trange: \"slider\",\n\treset: \"button\",\n\tsubmit: \"button\",\n};\n\nexport const HEADINGS = new Set([\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"]);\n\n/** Elements that aren't phrasing content. Starting one ends an open `<p>`. */\nexport const FLOW = new Set([\n\t\"address\",\n\t\"article\",\n\t\"aside\",\n\t\"blockquote\",\n\t\"center\",\n\t\"dd\",\n\t\"details\",\n\t\"dialog\",\n\t\"dir\",\n\t\"div\",\n\t\"dl\",\n\t\"dt\",\n\t\"fieldset\",\n\t\"figcaption\",\n\t\"figure\",\n\t\"footer\",\n\t\"form\",\n\t...HEADINGS,\n\t\"header\",\n\t\"hgroup\",\n\t\"hr\",\n\t\"li\",\n\t\"listing\",\n\t\"main\",\n\t\"menu\",\n\t\"nav\",\n\t\"ol\",\n\t\"p\",\n\t\"plaintext\",\n\t\"pre\",\n\t\"search\",\n\t\"section\",\n\t\"summary\",\n\t\"table\",\n\t\"ul\",\n\t\"xmp\",\n]);\n\n/** Elements that only hold phrasing content: text and inline elements. `<p>` is left out, since the browser ends it. */\nexport const PHRASING_ONLY = new Set([\n\t\"abbr\",\n\t\"b\",\n\t\"bdi\",\n\t\"bdo\",\n\t\"button\",\n\t\"cite\",\n\t\"code\",\n\t\"data\",\n\t\"dfn\",\n\t\"em\",\n\t...HEADINGS,\n\t\"i\",\n\t\"kbd\",\n\t\"label\",\n\t\"legend\",\n\t\"mark\",\n\t\"meter\",\n\t\"output\",\n\t\"pre\",\n\t\"progress\",\n\t\"q\",\n\t\"rp\",\n\t\"rt\",\n\t\"ruby\",\n\t\"s\",\n\t\"samp\",\n\t\"small\",\n\t\"span\",\n\t\"strong\",\n\t\"sub\",\n\t\"summary\",\n\t\"sup\",\n\t\"time\",\n\t\"u\",\n\t\"var\",\n]);\n\n/** Elements that take the content model of their parent, so their parent decides what they may hold. */\nexport const TRANSPARENT = new Set([\n\t\"a\",\n\t\"audio\",\n\t\"canvas\",\n\t\"del\",\n\t\"ins\",\n\t\"map\",\n\t\"noscript\",\n\t\"object\",\n\t\"slot\",\n\t\"video\",\n]);\n\nconst SCRIPT_SUPPORTING = [\"script\", \"template\"];\nconst TABLE_PARTS = [\n\t\"caption\",\n\t\"colgroup\",\n\t\"col\",\n\t\"thead\",\n\t\"tbody\",\n\t\"tfoot\",\n\t\"tr\",\n];\n\n/** Elements that only hold certain children. */\nexport const ONLY_CHILDREN: Record<string, readonly string[]> = {\n\tul: [\"li\", ...SCRIPT_SUPPORTING],\n\tol: [\"li\", ...SCRIPT_SUPPORTING],\n\tmenu: [\"li\", ...SCRIPT_SUPPORTING],\n\tdl: [\"dt\", \"dd\", \"div\", ...SCRIPT_SUPPORTING],\n\ttable: [...TABLE_PARTS, ...SCRIPT_SUPPORTING],\n\tthead: [\"tr\", ...SCRIPT_SUPPORTING],\n\ttbody: [\"tr\", ...SCRIPT_SUPPORTING],\n\ttfoot: [\"tr\", ...SCRIPT_SUPPORTING],\n\ttr: [\"td\", \"th\", ...SCRIPT_SUPPORTING],\n\tcolgroup: [\"col\", \"template\"],\n\tpicture: [\"source\", \"img\", ...SCRIPT_SUPPORTING],\n\thgroup: [\"p\", ...HEADINGS, ...SCRIPT_SUPPORTING],\n};\n\n/** What `<head>` holds. Anything else ends it, since `</head>` can be left out. */\nexport const METADATA = new Set([\n\t\"base\",\n\t\"link\",\n\t\"meta\",\n\t\"noscript\",\n\t\"script\",\n\t\"style\",\n\t\"template\",\n\t\"title\",\n]);\n\n/** Elements that must sit directly inside certain parents. */\nexport const REQUIRED_PARENTS: Record<string, readonly string[]> = {\n\tli: [\"ul\", \"ol\", \"menu\"],\n\tdt: [\"dl\", \"div\"],\n\tdd: [\"dl\", \"div\"],\n\ttr: [\"table\", \"thead\", \"tbody\", \"tfoot\"],\n\ttd: [\"tr\"],\n\tth: [\"tr\"],\n\tthead: [\"table\"],\n\ttbody: [\"table\"],\n\ttfoot: [\"table\"],\n\tcaption: [\"table\"],\n\tcolgroup: [\"table\"],\n\tcol: [\"colgroup\", \"table\"],\n\tsummary: [\"details\"],\n\tlegend: [\"fieldset\", \"optgroup\"],\n\tfigcaption: [\"figure\"],\n\tsource: [\"picture\", \"audio\", \"video\"],\n\ttrack: [\"audio\", \"video\"],\n\trt: [\"ruby\"],\n\trp: [\"ruby\"],\n};\n\n/** Elements that must be the first child of their parent. */\nexport const FIRST_CHILD: Record<string, string> = {\n\tsummary: \"details\",\n\tlegend: \"fieldset\",\n};\n\n/** Where `<main>` may go, besides custom elements. */\nexport const MAIN_PARENTS = new Set([\n\t\"html\",\n\t\"body\",\n\t\"div\",\n\t\"form\",\n\t\"template\",\n]);\n\n/**\n * The \"special\" elements of the HTML parser, which stop it looking further for an `<li>`, `<dd>` or `<dt>` to end.\n * `address`, `div` and `p` are left out, as the parser looks past them.\n */\nexport const SPECIAL = new Set([\n\t\"applet\",\n\t\"area\",\n\t\"article\",\n\t\"aside\",\n\t\"base\",\n\t\"basefont\",\n\t\"bgsound\",\n\t\"blockquote\",\n\t\"body\",\n\t\"br\",\n\t\"button\",\n\t\"caption\",\n\t\"center\",\n\t\"col\",\n\t\"colgroup\",\n\t\"dd\",\n\t\"details\",\n\t\"dir\",\n\t\"dl\",\n\t\"dt\",\n\t\"embed\",\n\t\"fieldset\",\n\t\"figcaption\",\n\t\"figure\",\n\t\"footer\",\n\t\"form\",\n\t\"frame\",\n\t\"frameset\",\n\t...HEADINGS,\n\t\"head\",\n\t\"header\",\n\t\"hgroup\",\n\t\"hr\",\n\t\"html\",\n\t\"iframe\",\n\t\"img\",\n\t\"input\",\n\t\"keygen\",\n\t\"li\",\n\t\"link\",\n\t\"listing\",\n\t\"main\",\n\t\"marquee\",\n\t\"menu\",\n\t\"meta\",\n\t\"nav\",\n\t\"noembed\",\n\t\"noframes\",\n\t\"noscript\",\n\t\"object\",\n\t\"ol\",\n\t\"param\",\n\t\"plaintext\",\n\t\"pre\",\n\t\"script\",\n\t\"search\",\n\t\"section\",\n\t\"select\",\n\t\"source\",\n\t\"style\",\n\t\"summary\",\n\t\"table\",\n\t\"tbody\",\n\t\"td\",\n\t\"template\",\n\t\"textarea\",\n\t\"tfoot\",\n\t\"th\",\n\t\"thead\",\n\t\"title\",\n\t\"tr\",\n\t\"track\",\n\t\"ul\",\n\t\"wbr\",\n\t\"xmp\",\n]);\n\n/** Elements that end the search for an open `<p>` or `<button>`: the parser's \"button scope\". */\nexport const BUTTON_SCOPE = new Set([\n\t\"applet\",\n\t\"button\",\n\t\"caption\",\n\t\"html\",\n\t\"marquee\",\n\t\"object\",\n\t\"table\",\n\t\"td\",\n\t\"template\",\n\t\"th\",\n]);\n","import { isPlainObject } from \"../runtime/values.js\";\nimport type { Span } from \"../source.js\";\nimport { suggest } from \"../suggest.js\";\n\nexport const HTML_CHECKS = [\n\t\"html-obsolete-element\",\n\t\"html-obsolete-attribute\",\n\t\"html-attribute-value\",\n\t\"html-img-alt\",\n\t\"html-button-type\",\n\t\"html-lang\",\n\t\"html-iframe-title\",\n\t\"html-viewport-zoom\",\n\t\"html-tabindex\",\n\t\"html-aria-attribute\",\n\t\"html-role\",\n\t\"html-redundant-role\",\n\t\"html-aria-hidden-focusable\",\n\t\"html-heading-order\",\n\t\"html-nested-interactive\",\n\t\"html-permitted-content\",\n] as const;\n\nexport type HtmlCheck = (typeof HTML_CHECKS)[number];\nexport type HtmlCheckLevel = \"off\" | \"warning\" | \"error\";\n/** The `htmlChecks` option: every rule on or off, or a level for some rules. Rules left out are warnings. */\nexport type HtmlChecks = boolean | Partial<Record<HtmlCheck, HtmlCheckLevel>>;\nexport type HtmlCheckLevels = Readonly<Record<HtmlCheck, HtmlCheckLevel>>;\n\nconst LEVELS: readonly unknown[] = [\"off\", \"warning\", \"error\"];\n\nconst isHtmlCheck = (code: string): code is HtmlCheck =>\n\t(HTML_CHECKS as readonly string[]).includes(code);\n\nconst isLevel = (level: unknown): level is HtmlCheckLevel =>\n\tLEVELS.includes(level);\n\nconst allAt = (level: HtmlCheckLevel): Record<HtmlCheck, HtmlCheckLevel> => {\n\tconst levels = {} as Record<HtmlCheck, HtmlCheckLevel>;\n\tfor (const code of HTML_CHECKS) levels[code] = level;\n\treturn levels;\n};\n\n/** Validates the `htmlChecks` option and gives every rule its level. Throws a `TypeError` for an invalid option. */\nexport const resolveHtmlChecks = (\n\toption: HtmlChecks | undefined,\n): HtmlCheckLevels => {\n\tif (option === undefined || option === true) return allAt(\"warning\");\n\tif (option === false) return allAt(\"off\");\n\tif (!isPlainObject(option)) {\n\t\tthrow new TypeError(\n\t\t\t\"htmlChecks must be true, false or an object of rule levels\",\n\t\t);\n\t}\n\tconst levels = allAt(\"warning\");\n\tfor (const [code, level] of Object.entries(option)) {\n\t\tif (!isHtmlCheck(code)) {\n\t\t\tthrow new TypeError(\n\t\t\t\twithHint(`Unknown HTML check \"${code}\"`, suggest(code, HTML_CHECKS)),\n\t\t\t);\n\t\t}\n\t\tif (!isLevel(level)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`HTML check \"${code}\" must be \"off\", \"warning\" or \"error\"`,\n\t\t\t);\n\t\t}\n\t\tlevels[code] = level;\n\t}\n\treturn levels;\n};\n\n/** The shortest `htmlChecks` option that gives these levels, for `kiln.json`. */\nexport const htmlChecksOption = (levels: HtmlCheckLevels): HtmlChecks => {\n\tconst changed: Partial<Record<HtmlCheck, HtmlCheckLevel>> = {};\n\tfor (const code of HTML_CHECKS) {\n\t\tif (levels[code] !== \"warning\") changed[code] = levels[code];\n\t}\n\tconst codes = Object.keys(changed);\n\tif (codes.length === 0) return true;\n\tif (\n\t\tcodes.length === HTML_CHECKS.length &&\n\t\tHTML_CHECKS.every((code) => levels[code] === \"off\")\n\t) {\n\t\treturn false;\n\t}\n\treturn changed;\n};\n\n/** Reports a problem a rule found. Rules turned off report nothing. */\nexport type Report = (code: HtmlCheck, message: string, span: Span) => void;\n\n/** Adds a \"Did you mean\" hint to a message, when there is one. */\nexport const withHint = (message: string, hint: string | undefined) =>\n\thint ? `${message}. ${hint}` : message;\n","import { suggest } from \"../suggest.js\";\nimport {\n\tABSTRACT_ROLES,\n\tARIA_ATTRIBUTES,\n\tATTRIBUTE_VALUES,\n\tBOOLEAN_ATTRIBUTES,\n\tIMPLICIT_ROLES,\n\tINPUT_ROLES,\n\tOBSOLETE,\n\tOBSOLETE_ATTRIBUTES,\n\tROLES,\n} from \"./data.js\";\nimport { type Report, withHint } from \"./options.js\";\nimport type { Attribute, StartTag } from \"./scanner.js\";\n\nconst TABINDEX = /^[\\t\\n\\f\\r ]*([+-]?)(\\d+)/;\nconst TOKENS = /[^\\t\\n\\f\\r ]+/g;\n/** Values that suggest the author meant a boolean attribute to be off. */\nconst OFF = new Set([\"false\", \"0\", \"no\", \"off\"]);\n\n/** A written-out `tabindex` as a number, or null when there is none or it isn't a number. */\nexport const tabindexOf = (tag: StartTag): number | null => {\n\tconst value = tag.attributes.find((a) => a.name === \"tabindex\")?.value;\n\tconst match =\n\t\tvalue === undefined || value === null ? null : TABINDEX.exec(value);\n\treturn match ? Number(`${match[1]}${match[2]}`) : null;\n};\n\n/** The written-out value of an attribute, in lower case. Undefined when it's missing, null when built at render time. */\nexport const valueOf = (tag: StartTag, name: string) => {\n\tconst attribute = tag.attributes.find((a) => a.name === name);\n\tif (!attribute) return undefined;\n\treturn attribute.value === null ? null : attribute.value.toLowerCase();\n};\n\nconst appliesTo = (on: readonly string[] | \"*\", tag: string) =>\n\ton === \"*\" || on.includes(tag);\n\n/** Whether people can tab to an element, judging by what Kiln can see. Null when it can't tell. */\nconst focusable = (tag: StartTag): boolean | null => {\n\tconst tabindex = tabindexOf(tag);\n\tif (tag.attributes.some((a) => a.name === \"tabindex\")) {\n\t\treturn tabindex === null ? null : tabindex >= 0;\n\t}\n\tconst has = (name: string) => tag.attributes.some((a) => a.name === name);\n\tswitch (tag.name) {\n\t\tcase \"a\":\n\t\tcase \"area\":\n\t\t\treturn has(\"href\");\n\t\tcase \"button\":\n\t\tcase \"select\":\n\t\tcase \"textarea\":\n\t\t\treturn !has(\"disabled\");\n\t\tcase \"input\":\n\t\t\treturn !has(\"disabled\") && valueOf(tag, \"type\") !== \"hidden\";\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n/** The role an element always has, or null when it has none or it depends on what Kiln can't see. */\nconst implicitRole = (tag: StartTag): string | null => {\n\tif (tag.name === \"a\" || tag.name === \"area\") {\n\t\treturn tag.attributes.some((a) => a.name === \"href\") ? \"link\" : null;\n\t}\n\tif (tag.name === \"input\") {\n\t\tconst type = valueOf(tag, \"type\");\n\t\treturn type ? (INPUT_ROLES[type] ?? null) : null;\n\t}\n\treturn IMPLICIT_ROLES[tag.name] ?? null;\n};\n\nconst checkValue = (tag: StartTag, attribute: Attribute, report: Report) => {\n\tconst value = attribute.value;\n\tif (value === null) return;\n\tconst custom = tag.name.includes(\"-\");\n\n\tfor (const rule of ATTRIBUTE_VALUES[attribute.name] ?? []) {\n\t\tif (!appliesTo(rule.on, tag.name) || (custom && rule.on !== \"*\")) continue;\n\t\tconst words = rule.tokens\n\t\t\t? Array.from(value.matchAll(TOKENS), (m) => ({\n\t\t\t\t\tword: m[0],\n\t\t\t\t\tstart: attribute.valueStart + m.index,\n\t\t\t\t}))\n\t\t\t: [{ word: value, start: attribute.valueStart }];\n\t\tfor (const { word, start } of words) {\n\t\t\tconst known = rule.caseSensitive\n\t\t\t\t? rule.values.includes(word)\n\t\t\t\t: rule.values.some((v) => v.toLowerCase() === word.toLowerCase());\n\t\t\tif (known || rule.other?.(word)) continue;\n\t\t\treport(\n\t\t\t\t\"html-attribute-value\",\n\t\t\t\twithHint(\n\t\t\t\t\t`${attribute.name}=\"${word}\" isn't valid on <${tag.name}>`,\n\t\t\t\t\tsuggest(\n\t\t\t\t\t\tword,\n\t\t\t\t\t\trule.values.filter((v) => v !== \"\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tword === \"\" ? attribute.span : { start, end: start + word.length },\n\t\t\t);\n\t\t}\n\t\tbreak;\n\t}\n\n\tconst boolean = BOOLEAN_ATTRIBUTES[attribute.name];\n\tif (\n\t\tboolean &&\n\t\t!custom &&\n\t\tappliesTo(boolean, tag.name) &&\n\t\tOFF.has(value.toLowerCase())\n\t) {\n\t\treport(\n\t\t\t\"html-attribute-value\",\n\t\t\t`${attribute.name}=\"${value}\" still turns ${attribute.name} on, since any value does. Leave the attribute out to turn it off`,\n\t\t\tattribute.span,\n\t\t);\n\t}\n\n\tif (attribute.name === \"lang\" && value !== \"\") {\n\t\ttry {\n\t\t\tIntl.getCanonicalLocales(value);\n\t\t} catch {\n\t\t\tlet fix: string | undefined;\n\t\t\ttry {\n\t\t\t\tfix = Intl.getCanonicalLocales(value.trim().replaceAll(\"_\", \"-\"))[0];\n\t\t\t} catch {\n\t\t\t\t// No close tag to suggest.\n\t\t\t}\n\t\t\treport(\n\t\t\t\t\"html-lang\",\n\t\t\t\tfix\n\t\t\t\t\t? `\"${value}\" is not a valid language tag. Use \"${fix}\"`\n\t\t\t\t\t: `\"${value}\" is not a valid language tag, such as \"en\" or \"en-GB\"`,\n\t\t\t\tattribute.span,\n\t\t\t);\n\t\t}\n\t}\n};\n\n/** The `user-scalable` and `maximum-scale` settings in a viewport's `content`. */\nconst viewportSettings = (content: string) =>\n\tnew Map(\n\t\tArray.from(\n\t\t\tcontent.matchAll(/([a-z-]+)\\s*=\\s*([^\\s,;]+)/gi),\n\t\t\t(m) => [(m[1] ?? \"\").toLowerCase(), (m[2] ?? \"\").toLowerCase()] as const,\n\t\t),\n\t);\n\n/** Checks one start tag with the rules that need only that tag. */\nexport const checkTag = (tag: StartTag, report: Report): void => {\n\tconst has = (name: string) =>\n\t\ttag.attributes.some((attribute) => attribute.name === name);\n\n\tconst obsolete = OBSOLETE.get(tag.name);\n\tif (obsolete) {\n\t\treport(\n\t\t\t\"html-obsolete-element\",\n\t\t\t`<${tag.name}> is obsolete. ${obsolete}`,\n\t\t\ttag.span,\n\t\t);\n\t}\n\tif (tag.complete) {\n\t\tif (tag.name === \"img\" && !has(\"alt\")) {\n\t\t\treport(\n\t\t\t\t\"html-img-alt\",\n\t\t\t\t'<img> has no alt attribute. Use alt=\"\" if the image is decorative',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (tag.name === \"button\" && !has(\"type\")) {\n\t\t\treport(\n\t\t\t\t\"html-button-type\",\n\t\t\t\t'<button> has no type attribute, so it submits any form it is in. Add type=\"button\" or type=\"submit\"',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (tag.name === \"html\" && !has(\"lang\")) {\n\t\t\treport(\n\t\t\t\t\"html-lang\",\n\t\t\t\t'<html> has no lang attribute. Add one, such as lang=\"en\"',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (tag.name === \"iframe\" && !has(\"title\")) {\n\t\t\treport(\n\t\t\t\t\"html-iframe-title\",\n\t\t\t\t'<iframe> has no title attribute. Add one that says what it holds, such as title=\"Map of our office\"',\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t\tif (valueOf(tag, \"aria-hidden\") === \"true\" && focusable(tag)) {\n\t\t\treport(\n\t\t\t\t\"html-aria-hidden-focusable\",\n\t\t\t\t`<${tag.name}> has aria-hidden=\"true\", but people can still tab to it. Remove aria-hidden, or take the element out of the tab order`,\n\t\t\t\ttag.span,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst obsoleteAttributes = OBSOLETE_ATTRIBUTES[tag.name];\n\tfor (const attribute of tag.attributes) {\n\t\tconst replacement = obsoleteAttributes?.[attribute.name];\n\t\tif (replacement) {\n\t\t\treport(\n\t\t\t\t\"html-obsolete-attribute\",\n\t\t\t\t`The ${attribute.name} attribute on <${tag.name}> is obsolete. ${replacement}`,\n\t\t\t\tattribute.nameSpan,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tattribute.name.startsWith(\"aria-\") &&\n\t\t\t!ARIA_ATTRIBUTES.has(attribute.name)\n\t\t) {\n\t\t\treport(\n\t\t\t\t\"html-aria-attribute\",\n\t\t\t\twithHint(\n\t\t\t\t\t`\"${attribute.name}\" is not an ARIA attribute`,\n\t\t\t\t\tsuggest(attribute.name, ARIA_ATTRIBUTES),\n\t\t\t\t),\n\t\t\t\tattribute.nameSpan,\n\t\t\t);\n\t\t}\n\t\tif (attribute.value === null) continue;\n\t\tcheckValue(tag, attribute, report);\n\t\tif (attribute.name === \"tabindex\") {\n\t\t\tconst tabindex = tabindexOf(tag);\n\t\t\tif (tabindex !== null && tabindex > 0) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-tabindex\",\n\t\t\t\t\t`tabindex=\"${attribute.value}\" puts this element ahead of the rest of the page when tabbing. Use 0, or -1 to focus it only from script`,\n\t\t\t\t\tattribute.span,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (attribute.name === \"role\") {\n\t\t\tcheckRole(tag, attribute, attribute.value, report);\n\t\t}\n\t\tif (\n\t\t\tattribute.name === \"content\" &&\n\t\t\ttag.name === \"meta\" &&\n\t\t\tvalueOf(tag, \"name\") === \"viewport\"\n\t\t) {\n\t\t\tconst settings = viewportSettings(attribute.value);\n\t\t\tconst scalable = settings.get(\"user-scalable\");\n\t\t\tconst maximum = Number.parseFloat(settings.get(\"maximum-scale\") ?? \"\");\n\t\t\tif (scalable === \"no\" || scalable === \"0\") {\n\t\t\t\treport(\n\t\t\t\t\t\"html-viewport-zoom\",\n\t\t\t\t\t`user-scalable=${scalable} stops people zooming in to read. Remove it`,\n\t\t\t\t\tattribute.span,\n\t\t\t\t);\n\t\t\t} else if (maximum < 2) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-viewport-zoom\",\n\t\t\t\t\t`maximum-scale=${settings.get(\"maximum-scale\")} stops people zooming in to read. Remove it, or use 2 or more`,\n\t\t\t\t\tattribute.span,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst checkRole = (\n\ttag: StartTag,\n\tattribute: Attribute,\n\tvalue: string,\n\treport: Report,\n) => {\n\tconst roles = Array.from(value.matchAll(TOKENS));\n\tconst implicit = implicitRole(tag);\n\tif (\n\t\timplicit &&\n\t\troles.length === 1 &&\n\t\troles[0]?.[0].toLowerCase() === implicit\n\t) {\n\t\treport(\n\t\t\t\"html-redundant-role\",\n\t\t\t`<${tag.name}> already has the ${implicit} role. Remove role=\"${value}\"`,\n\t\t\tattribute.span,\n\t\t);\n\t}\n\tfor (const match of roles) {\n\t\tconst role = match[0].toLowerCase();\n\t\t// DPUB-ARIA and Graphics-ARIA roles.\n\t\tif (\n\t\t\tROLES.has(role) ||\n\t\t\trole.startsWith(\"doc-\") ||\n\t\t\trole.startsWith(\"graphics-\")\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst start = attribute.valueStart + match.index;\n\t\tconst span = { start, end: start + role.length };\n\t\tif (ABSTRACT_ROLES.has(role)) {\n\t\t\treport(\n\t\t\t\t\"html-role\",\n\t\t\t\t`\"${role}\" is an abstract ARIA role, which pages must not use`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else {\n\t\t\treport(\n\t\t\t\t\"html-role\",\n\t\t\t\twithHint(`\"${role}\" is not an ARIA role`, suggest(role, ROLES)),\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t}\n};\n","import type { Statement } from \"../parser/ast.js\";\nimport type { CompiledTemplate } from \"../runtime/types.js\";\nimport {\n\tBUTTON_SCOPE,\n\tFIRST_CHILD,\n\tFLOW,\n\tFOREIGN,\n\tHEADINGS,\n\tMAIN_PARENTS,\n\tMETADATA,\n\tONLY_CHILDREN,\n\tPHRASING_ONLY,\n\tRAW_TEXT,\n\tREQUIRED_PARENTS,\n\tSPECIAL,\n\tTRANSPARENT,\n\tVOID,\n} from \"./data.js\";\nimport type { Report } from \"./options.js\";\nimport type { StartTag, Tag } from \"./scanner.js\";\nimport { valueOf } from \"./tags.js\";\n\n/**\n * An open element. An empty name marks where Kiln doesn't know what is open: the bottom of the list, since a\n * template's content could end up anywhere, and wherever `if` branches left different elements open.\n */\ntype Entry = { name: string; children: number };\n\n/**\n * What is known at one point in a template: the open elements, innermost last, and the last heading's level.\n * `endedParagraph` is the block that last ended an open `<p>`, such as the `<div>` in `<p>Text<div>`. That is valid\n * HTML, unless a `</p>` follows, which shows the paragraph was meant to hold the block.\n */\ntype State = {\n\topen: Entry[];\n\theading: number | null;\n\tendedParagraph: StartTag | null;\n};\n\nconst UNKNOWN = \"\";\n\n/** Elements that stop the parser looking for an open `<a>` to end. */\nconst FORMATTING_MARKERS = new Set([\n\t\"applet\",\n\t\"caption\",\n\t\"marquee\",\n\t\"object\",\n\t\"td\",\n\t\"template\",\n\t\"th\",\n]);\n\nconst fresh = (): State => ({\n\topen: [{ name: UNKNOWN, children: 0 }],\n\theading: null,\n\tendedParagraph: null,\n});\n\nconst copy = (state: State): State => ({\n\topen: state.open.map((entry) => ({ ...entry })),\n\theading: state.heading,\n\tendedParagraph: state.endedParagraph,\n});\n\nconst levelOf = (name: string) =>\n\tHEADINGS.has(name) ? Number(name.slice(1)) : null;\n\n/** Lists names as `<a>`, `<a> and <b>`, or `<a>, <b> and <c>`. */\nconst listOf = (names: readonly string[], joiner: \"and\" | \"or\") => {\n\tconst tags = names.map((name) => `<${name}>`);\n\treturn tags.length < 2\n\t\t? tags.join(\"\")\n\t\t: `${tags.slice(0, -1).join(\", \")} ${joiner} ${tags.at(-1)}`;\n};\n\n/** Whether an element is interactive content, which `<a>` and `<button>` can't hold. Null when Kiln can't tell. */\nconst interactive = (tag: StartTag): boolean | null => {\n\tconst has = (name: string) => tag.attributes.some((a) => a.name === name);\n\tif (has(\"tabindex\")) return true;\n\tswitch (tag.name) {\n\t\tcase \"a\":\n\t\t\treturn has(\"href\") || (tag.complete ? false : null);\n\t\tcase \"button\":\n\t\tcase \"details\":\n\t\tcase \"embed\":\n\t\tcase \"iframe\":\n\t\tcase \"label\":\n\t\tcase \"select\":\n\t\tcase \"textarea\":\n\t\t\treturn true;\n\t\tcase \"input\": {\n\t\t\tconst type = valueOf(tag, \"type\");\n\t\t\tif (type === undefined) return tag.complete ? true : null;\n\t\t\treturn type === null ? null : type !== \"hidden\";\n\t\t}\n\t\tcase \"audio\":\n\t\tcase \"video\":\n\t\t\treturn has(\"controls\") || (tag.complete ? false : null);\n\t\tcase \"img\":\n\t\t\treturn has(\"usemap\") || (tag.complete ? false : null);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n};\n\n/**\n * Checks how a template's elements nest, and the order of its headings. It follows the template's tags, branches and\n * loops, and the HTML parser's rules for end tags that can be left out, but never what other templates render.\n */\nexport const checkNesting = (\n\ttemplate: CompiledTemplate,\n\ttags: readonly Tag[],\n\treport: Report,\n): void => {\n\tconst layoutChild = template.ast.body.some((node) => node.type === \"Extends\");\n\n\tconst startOf = (tag: Tag) =>\n\t\ttag.type === \"start\" ? tag.span.start : tag.start;\n\t/** The index of the first tag at or after `offset`. */\n\tconst firstTag = (offset: number) => {\n\t\tlet low = 0;\n\t\tlet high = tags.length;\n\t\twhile (low < high) {\n\t\t\tconst middle = (low + high) >> 1;\n\t\t\tif (startOf(tags[middle] as Tag) < offset) low = middle + 1;\n\t\t\telse high = middle;\n\t\t}\n\t\treturn low;\n\t};\n\t/** Whether `offset` is inside a tag, such as an output in `class=\"{{ x }}\"`, rather than between elements. */\n\tconst insideTag = (offset: number) => {\n\t\tconst before = tags[firstTag(offset) - 1];\n\t\treturn before !== undefined && offset < before.end;\n\t};\n\n\t/** Combines the states that branches end in. What they disagree on becomes unknown. */\n\tconst merge = (state: State, ends: State[]) => {\n\t\tconst [first, ...rest] = ends as [State, ...State[]];\n\t\tlet shared = first.open.length;\n\t\tfor (const end of rest) {\n\t\t\tlet same = 0;\n\t\t\twhile (\n\t\t\t\tsame < Math.min(shared, end.open.length) &&\n\t\t\t\tend.open[same]?.name === first.open[same]?.name\n\t\t\t) {\n\t\t\t\tsame++;\n\t\t\t}\n\t\t\tshared = same;\n\t\t}\n\t\tconst agree =\n\t\t\tends.every((end) => end.open.length === shared) &&\n\t\t\tfirst.open.length === shared;\n\t\tstate.open = first.open.slice(0, shared);\n\t\tif (!agree) state.open.push({ name: UNKNOWN, children: 0 });\n\t\tstate.heading = ends.every((end) => end.heading === first.heading)\n\t\t\t? first.heading\n\t\t\t: null;\n\t\tstate.endedParagraph = ends.every(\n\t\t\t(end) => end.endedParagraph === first.endedParagraph,\n\t\t)\n\t\t\t? first.endedParagraph\n\t\t\t: null;\n\t};\n\n\t/** Content Kiln can't see, such as an include or an output. It may hold headings unless its parent can't. */\n\tconst hole = (state: State, mayHoldHeadings: boolean) => {\n\t\tconst top = state.open.at(-1) as Entry;\n\t\ttop.children++;\n\t\tif (mayHoldHeadings) state.heading = null;\n\t};\n\n\t/** The nearest open element that decides what may go here: transparent elements such as `<a>` pass it to their parent. */\n\tconst container = (state: State) => {\n\t\tfor (let i = state.open.length - 1; i >= 0; i--) {\n\t\t\tconst entry = state.open[i] as Entry;\n\t\t\tif (!TRANSPARENT.has(entry.name)) return entry;\n\t\t}\n\t\treturn state.open[0] as Entry;\n\t};\n\n\tconst popThrough = (state: State, index: number) => {\n\t\tstate.open.length = index;\n\t};\n\n\t/** The index of the innermost open element matching `names`, looking no further than an element in `stop`. */\n\tconst findOpen = (\n\t\tstate: State,\n\t\tnames: ReadonlySet<string> | readonly string[],\n\t\tstop: (name: string) => boolean,\n\t) => {\n\t\tconst has = (name: string) =>\n\t\t\t\"has\" in names ? names.has(name) : names.includes(name);\n\t\tfor (let i = state.open.length - 1; i > 0; i--) {\n\t\t\tconst name = (state.open[i] as Entry).name;\n\t\t\tif (has(name)) return i;\n\t\t\tif (name === UNKNOWN || stop(name)) return -1;\n\t\t}\n\t\treturn -1;\n\t};\n\n\t/** Ends open elements the way the HTML parser does when `name` starts, for end tags that can be left out. */\n\tconst impliedEnds = (state: State, name: string) => {\n\t\tconst close = (names: readonly string[], stop: readonly string[]) => {\n\t\t\tconst index = findOpen(state, names, (open) => stop.includes(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t};\n\t\tconst tableStops = [\"table\", \"template\", \"html\"];\n\t\tif (state.open.at(-1)?.name === \"head\" && !METADATA.has(name)) {\n\t\t\tstate.open.pop();\n\t\t}\n\t\tif (name === \"li\") {\n\t\t\tconst index = findOpen(state, [\"li\"], (open) => SPECIAL.has(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t} else if (name === \"dd\" || name === \"dt\") {\n\t\t\tconst index = findOpen(state, [\"dd\", \"dt\"], (open) => SPECIAL.has(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t} else if (name === \"td\" || name === \"th\") {\n\t\t\tclose([\"td\", \"th\"], [\"tr\", ...tableStops]);\n\t\t} else if (name === \"tr\") {\n\t\t\tclose([\"td\", \"th\"], [\"tr\", ...tableStops]);\n\t\t\tclose([\"tr\"], [\"thead\", \"tbody\", \"tfoot\", ...tableStops]);\n\t\t} else if (\n\t\t\t[\"thead\", \"tbody\", \"tfoot\", \"caption\", \"colgroup\"].includes(name)\n\t\t) {\n\t\t\tclose([\"td\", \"th\"], [\"tr\", ...tableStops]);\n\t\t\tclose([\"tr\"], [\"thead\", \"tbody\", \"tfoot\", ...tableStops]);\n\t\t\tclose([\"thead\", \"tbody\", \"tfoot\"], tableStops);\n\t\t} else if (name === \"option\" || name === \"optgroup\") {\n\t\t\tif (state.open.at(-1)?.name === \"option\") state.open.pop();\n\t\t\tif (name === \"optgroup\" && state.open.at(-1)?.name === \"optgroup\") {\n\t\t\t\tstate.open.pop();\n\t\t\t}\n\t\t} else if (name === \"rt\" || name === \"rp\") {\n\t\t\tconst top = state.open.at(-1)?.name;\n\t\t\tif (top === \"rt\" || top === \"rp\") state.open.pop();\n\t\t}\n\t};\n\n\t/** Open ancestors that Kiln knows of, innermost first, up to the nearest `<template>`. */\n\tconst ancestors = function* (state: State) {\n\t\tfor (let i = state.open.length - 1; i > 0; i--) {\n\t\t\tconst name = (state.open[i] as Entry).name;\n\t\t\tif (name === \"template\") return;\n\t\t\tif (name !== UNKNOWN) yield name;\n\t\t}\n\t};\n\n\tconst start = (tag: StartTag, state: State) => {\n\t\tconst { name, span } = tag;\n\t\timpliedEnds(state, name);\n\n\t\t// The parser ends an open link or button before another, and ignores a form inside a form.\n\t\tif (name === \"a\" || name === \"button\") {\n\t\t\tconst index = findOpen(state, [name], (open) =>\n\t\t\t\tname === \"a\" ? FORMATTING_MARKERS.has(open) : BUTTON_SCOPE.has(open),\n\t\t\t);\n\t\t\tif (index > 0) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-nested-interactive\",\n\t\t\t\t\t`<${name}> can't be inside another <${name}>, so the browser ends the first one here`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t\tpopThrough(state, index);\n\t\t\t}\n\t\t}\n\t\tif (name === \"form\" && [...ancestors(state)].includes(\"form\")) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\"<form> can't be inside another <form>, so the browser ignores it\",\n\t\t\t\tspan,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (FLOW.has(name)) {\n\t\t\tconst index = findOpen(state, [\"p\"], (open) => BUTTON_SCOPE.has(open));\n\t\t\tif (index > 0) {\n\t\t\t\tpopThrough(state, index);\n\t\t\t\tstate.endedParagraph = name === \"p\" ? null : tag;\n\t\t\t}\n\t\t}\n\t\tif (name === \"p\") state.endedParagraph = null;\n\n\t\tconst parent = state.open.at(-1) as Entry;\n\t\tconst holder = container(state);\n\t\tconst headingAllowed =\n\t\t\tHEADINGS.has(name) &&\n\t\t\t(holder.name === \"summary\" || holder.name === \"legend\");\n\t\tif (FLOW.has(name) && PHRASING_ONLY.has(holder.name) && !headingAllowed) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> can't be inside <${holder.name}>, which only holds text and inline elements`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (ONLY_CHILDREN[parent.name]?.includes(name) === false) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> can't be inside <${parent.name}>, which only holds ${listOf(ONLY_CHILDREN[parent.name] ?? [], \"and\")}`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (\n\t\t\tparent.name !== UNKNOWN &&\n\t\t\tparent.name !== \"template\" &&\n\t\t\tREQUIRED_PARENTS[name]?.includes(parent.name) === false\n\t\t) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> must be inside ${listOf(REQUIRED_PARENTS[name] ?? [], \"or\")}`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (FIRST_CHILD[name] === parent.name && parent.children > 0) {\n\t\t\treport(\n\t\t\t\t\"html-permitted-content\",\n\t\t\t\t`<${name}> must be the first child of <${parent.name}>`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t\t// A heading inside a heading: the parser ends the outer one.\n\t\tif (HEADINGS.has(name) && HEADINGS.has(parent.name)) state.open.pop();\n\n\t\tconst above = [...ancestors(state)];\n\t\tconst isInteractive = interactive(tag);\n\t\tconst holderOfInteractive = above.find(\n\t\t\t(open) => open === \"a\" || open === \"button\",\n\t\t);\n\t\tif (isInteractive && holderOfInteractive) {\n\t\t\treport(\n\t\t\t\t\"html-nested-interactive\",\n\t\t\t\t`<${name}> can't be inside <${holderOfInteractive}>, since interactive elements can't hold each other`,\n\t\t\t\tspan,\n\t\t\t);\n\t\t} else if (name === \"label\" && above.includes(\"label\")) {\n\t\t\treport(\n\t\t\t\t\"html-nested-interactive\",\n\t\t\t\t\"<label> can't be inside another <label>\",\n\t\t\t\tspan,\n\t\t\t);\n\t\t}\n\t\tif (name === \"header\" || name === \"footer\") {\n\t\t\tconst outer = above.find(\n\t\t\t\t(open) => open === \"header\" || open === \"footer\",\n\t\t\t);\n\t\t\tif (outer) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\t`<${name}> can't be inside <${outer}>`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (name === \"main\") {\n\t\t\tconst wrong = above.find(\n\t\t\t\t(open) => !MAIN_PARENTS.has(open) && !open.includes(\"-\"),\n\t\t\t);\n\t\t\tif (wrong) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\t`<main> can't be inside <${wrong}>. It belongs in <body>, a <div> or a <form>`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst level = levelOf(name);\n\t\tif (level !== null) {\n\t\t\tif (state.heading !== null && level > state.heading + 1) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-heading-order\",\n\t\t\t\t\t`<${name}> skips a level after <h${state.heading}>. Use <h${state.heading + 1}>`,\n\t\t\t\t\tspan,\n\t\t\t\t);\n\t\t\t}\n\t\t\tstate.heading = level;\n\t\t}\n\n\t\t(state.open.at(-1) as Entry).children++;\n\t\tconst leaf = VOID.has(name) || RAW_TEXT.has(name) || FOREIGN.has(name);\n\t\tif (!leaf) state.open.push({ name, children: 0 });\n\t};\n\n\tconst end = (name: string, state: State) => {\n\t\tif (name === \"p\") {\n\t\t\tconst index = findOpen(state, [\"p\"], (open) => BUTTON_SCOPE.has(open));\n\t\t\tif (index > 0) popThrough(state, index);\n\t\t\telse if (state.endedParagraph) {\n\t\t\t\treport(\n\t\t\t\t\t\"html-permitted-content\",\n\t\t\t\t\t`<${state.endedParagraph.name}> can't be inside <p>, so the browser ends the paragraph before it`,\n\t\t\t\t\tstate.endedParagraph.span,\n\t\t\t\t);\n\t\t\t\tstate.endedParagraph = null;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// Any heading's end tag ends the open heading, whatever its level.\n\t\tconst names = HEADINGS.has(name) ? HEADINGS : [name];\n\t\tfor (let i = state.open.length - 1; i > 0; i--) {\n\t\t\tconst open = (state.open[i] as Entry).name;\n\t\t\tif (\"has\" in names ? names.has(open) : names.includes(open)) {\n\t\t\t\tpopThrough(state, i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\t/** Walks a body that renders somewhere else, such as a macro, so its parent is unknown. */\n\tconst elsewhere = (body: Statement[]) => walk(body, fresh());\n\n\t/** Walks a body that renders in place, or may be replaced, such as a layout's block. */\n\tconst replaceable = (body: Statement[], state: State) => {\n\t\tconst before = copy(state);\n\t\tconst after = copy(state);\n\t\twalk(body, after);\n\t\tmerge(state, [before, after]);\n\t\thole(state, true);\n\t};\n\n\tconst walk = (list: Statement[], state: State): void => {\n\t\tfor (const node of list) {\n\t\t\tif (node.type !== \"Text\" && insideTag(node.span.start)) continue;\n\t\t\tswitch (node.type) {\n\t\t\t\tcase \"Text\":\n\t\t\t\t\tfor (\n\t\t\t\t\t\tlet i = firstTag(node.span.start);\n\t\t\t\t\t\ti < tags.length && startOf(tags[i] as Tag) < node.span.end;\n\t\t\t\t\t\ti++\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst tag = tags[i] as Tag;\n\t\t\t\t\t\tif (tag.type === \"start\") start(tag, state);\n\t\t\t\t\t\telse end(tag.name, state);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Output\": {\n\t\t\t\t\t// Phrasing elements and `<p>` can't hold headings, so an output inside one can't add any.\n\t\t\t\t\tconst holder = container(state).name;\n\t\t\t\t\thole(state, !PHRASING_ONLY.has(holder) && holder !== \"p\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Include\":\n\t\t\t\t\thole(state, true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Component\":\n\t\t\t\t\telsewhere(node.body);\n\t\t\t\t\tfor (const fill of node.fills) elsewhere(fill.body);\n\t\t\t\t\thole(state, true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Island\":\n\t\t\t\t\telsewhere(node.body);\n\t\t\t\t\thole(state, true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"If\":\n\t\t\t\tcase \"For\": {\n\t\t\t\t\tconst bodies =\n\t\t\t\t\t\tnode.type === \"If\"\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t...node.branches.map((branch) => branch.body),\n\t\t\t\t\t\t\t\t\tnode.alternate ?? [],\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: [node.body, node.alternate ?? []];\n\t\t\t\t\tconst ends = bodies.map((body) => {\n\t\t\t\t\t\tconst branch = copy(state);\n\t\t\t\t\t\twalk(body, branch);\n\t\t\t\t\t\treturn branch;\n\t\t\t\t\t});\n\t\t\t\t\tmerge(state, ends);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"Block\":\n\t\t\t\t\tif (layoutChild) elsewhere(node.body);\n\t\t\t\t\telse replaceable(node.body, state);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Slot\":\n\t\t\t\t\treplaceable(node.body, state);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"With\":\n\t\t\t\tcase \"Cache\":\n\t\t\t\tcase \"Autoescape\":\n\t\t\t\t\twalk(node.body, state);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"Macro\":\n\t\t\t\tcase \"SetBlock\":\n\t\t\t\tcase \"Add\":\n\t\t\t\tcase \"Apply\":\n\t\t\t\t\telsewhere(node.body);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\twalk(template.ast.body, fresh());\n};\n","import { scanParts } from \"../lexer/lexer.js\";\nimport type { Span } from \"../source.js\";\nimport { FOREIGN, RAW_TEXT } from \"./data.js\";\n\nexport type Attribute = {\n\tname: string;\n\t/** From the start of the name to the end of the value. */\n\tspan: Span;\n\tnameSpan: Span;\n\t/** The written-out value, or null when it has none or is built at render time. */\n\tvalue: string | null;\n\t/** Where `value` starts in the source. */\n\tvalueStart: number;\n};\n\nexport type StartTag = {\n\ttype: \"start\";\n\tname: string;\n\t/** From `<` to the end of the name. */\n\tspan: Span;\n\t/** Just past the tag's `>`. */\n\tend: number;\n\tattributes: Attribute[];\n\t/** False when a tag or output among the attributes may add more, as `attrs(...)` does. */\n\tcomplete: boolean;\n\tselfClosing: boolean;\n};\n\nexport type EndTag = { type: \"end\"; name: string; start: number; end: number };\n\nexport type Tag = StartTag | EndTag;\n\n/** What each character of the source is, besides Kiln tags, which are 0: template text, an output such as `{{ x }}`, or a comment. */\nconst TEXT = 1;\nconst OUTPUT = 2;\nconst COMMENT = 3;\n\n/** Marks each character of the source as `TEXT`, `OUTPUT` or `COMMENT`, leaving Kiln tags and verbatim content at 0. */\nconst sourceMask = (source: string): Uint8Array => {\n\tconst mask = new Uint8Array(source.length);\n\tlet verbatim = false;\n\tfor (const part of scanParts(source).parts) {\n\t\tif (part.kind === \"text\" && !verbatim) {\n\t\t\tmask.fill(TEXT, part.start, part.end);\n\t\t} else if (part.kind === \"output\") {\n\t\t\tmask.fill(OUTPUT, part.start, part.end);\n\t\t} else if (part.kind === \"comment\") {\n\t\t\tmask.fill(COMMENT, part.start, part.end);\n\t\t}\n\t\tverbatim =\n\t\t\tpart.kind === \"tag\" &&\n\t\t\tpart.tokens.length === 3 &&\n\t\t\tpart.tokens[1]?.value === \"verbatim\";\n\t}\n\treturn mask;\n};\n\n/**\n * A template's source with every Kiln tag, output and comment, and verbatim content, replaced by spaces. Line breaks\n * stay, so offsets, lines and columns match the source. For HTML tools that should only see the markup.\n */\nexport const templateText = (source: string): string => {\n\tconst mask = sourceMask(source);\n\tlet text = \"\";\n\tlet start = 0;\n\tfor (let at = 0; at <= source.length; at++) {\n\t\tif (at < source.length && mask[at] === TEXT) continue;\n\t\ttext += source.slice(start, at);\n\t\tif (at < source.length) {\n\t\t\tconst char = source[at];\n\t\t\ttext += char === \"\\n\" || char === \"\\r\" ? char : \" \";\n\t\t}\n\t\tstart = at + 1;\n\t}\n\treturn text;\n};\n\nconst isSpace = (char: string | undefined) =>\n\tchar === \" \" ||\n\tchar === \"\\t\" ||\n\tchar === \"\\n\" ||\n\tchar === \"\\r\" ||\n\tchar === \"\\f\";\n\n/**\n * Reads the HTML tags in a template's text. Kiln syntax and outputs are holes whose content is unknown. It only reads\n * tags, never a tree of elements, so HTML split across `if` branches or templates never confuses it.\n */\nclass Scanner {\n\t#pos = 0;\n\n\tconstructor(\n\t\treadonly source: string,\n\t\treadonly mask: Uint8Array,\n\t) {}\n\n\t#text(at: number) {\n\t\treturn this.mask[at] === TEXT;\n\t}\n\n\t#output(at: number) {\n\t\treturn this.mask[at] === OUTPUT;\n\t}\n\n\t/** The character at `at` when it is template text, or undefined at a hole or the end. */\n\t#char(at: number): string | undefined {\n\t\treturn this.#text(at) ? this.source[at] : undefined;\n\t}\n\n\t#atHole() {\n\t\treturn this.#pos < this.source.length && !this.#text(this.#pos);\n\t}\n\n\t#skipHole() {\n\t\twhile (this.#atHole() && this.mask[this.#pos] !== COMMENT) this.#pos++;\n\t}\n\n\t#skipSpace() {\n\t\twhile (isSpace(this.#char(this.#pos))) this.#pos++;\n\t}\n\n\t/** Moves past the next `needle` written in the text, or to the end. */\n\t#skipPast(needle: string) {\n\t\twhile (this.#pos < this.source.length) {\n\t\t\tif (this.#matches(this.#pos, needle)) {\n\t\t\t\tthis.#pos += needle.length;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.#pos++;\n\t\t}\n\t}\n\n\t/** Whether `needle`, in lower case, is written in the text at `at`, in any case. */\n\t#matches(at: number, needle: string) {\n\t\tfor (let i = 0; i < needle.length; i++) {\n\t\t\tif (this.#char(at + i)?.toLowerCase() !== needle[i]) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Whether the first text is an XML declaration, as in a feed or a sitemap. */\n\tstartsWithXml(): boolean {\n\t\tfor (let at = 0; at < this.source.length; at++) {\n\t\t\tconst char = this.#char(at);\n\t\t\tif (char === undefined || isSpace(char) || char === \"\") continue;\n\t\t\treturn this.#matches(at, \"<?xml\");\n\t\t}\n\t\treturn false;\n\t}\n\n\t/** Reads characters up to whitespace, `/`, `>`, `stop` or a hole. */\n\t#word(stop?: string): string {\n\t\tconst start = this.#pos;\n\t\tfor (;;) {\n\t\t\tconst char = this.#char(this.#pos);\n\t\t\tif (\n\t\t\t\tchar === undefined ||\n\t\t\t\tisSpace(char) ||\n\t\t\t\tchar === \"/\" ||\n\t\t\t\tchar === \">\" ||\n\t\t\t\tchar === stop\n\t\t\t) {\n\t\t\t\treturn this.source.slice(start, this.#pos);\n\t\t\t}\n\t\t\tthis.#pos++;\n\t\t}\n\t}\n\n\t/** Moves past a raw text element's content, to its end tag. */\n\tskipRawText(name: string) {\n\t\twhile (this.#pos < this.source.length) {\n\t\t\tif (this.#matches(this.#pos, `</${name}`)) {\n\t\t\t\tconst after = this.#char(this.#pos + name.length + 2);\n\t\t\t\tif (\n\t\t\t\t\tafter === undefined ||\n\t\t\t\t\tisSpace(after) ||\n\t\t\t\t\tafter === \"/\" ||\n\t\t\t\t\tafter === \">\"\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.#pos++;\n\t\t}\n\t}\n\n\t/** The next start or end tag, or null at the end of the source. Skips comments, doctypes and other text. */\n\tnext(): StartTag | EndTag | null {\n\t\twhile (this.#pos < this.source.length) {\n\t\t\tif (this.#char(this.#pos) !== \"<\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst next = this.#char(this.#pos + 1);\n\t\t\tif (this.#matches(this.#pos, \"<!--\")) {\n\t\t\t\tthis.#pos += 4;\n\t\t\t\tthis.#skipPast(\"-->\");\n\t\t\t} else if (next === \"!\" || next === \"?\") {\n\t\t\t\tthis.#skipPast(\">\");\n\t\t\t} else if (next === \"/\") {\n\t\t\t\tconst start = this.#pos;\n\t\t\t\tthis.#pos += 2;\n\t\t\t\tconst name = this.#word().toLowerCase();\n\t\t\t\tthis.#skipPast(\">\");\n\t\t\t\tif (name) return { type: \"end\", name, start, end: this.#pos };\n\t\t\t} else if (next !== undefined && /[a-z]/i.test(next)) {\n\t\t\t\treturn this.#startTag();\n\t\t\t} else {\n\t\t\t\tthis.#pos++;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t#startTag(): StartTag {\n\t\tconst start = this.#pos;\n\t\tthis.#pos++;\n\t\tconst name = this.#word().toLowerCase();\n\t\tconst tag: StartTag = {\n\t\t\ttype: \"start\",\n\t\t\tname,\n\t\t\tspan: { start, end: this.#pos },\n\t\t\tend: this.source.length,\n\t\t\tattributes: [],\n\t\t\tcomplete: true,\n\t\t\tselfClosing: false,\n\t\t};\n\t\twhile (this.#pos < this.source.length) {\n\t\t\t// A comment adds nothing, but a tag or output may add attributes.\n\t\t\tif (this.mask[this.#pos] === COMMENT) {\n\t\t\t\tthis.#pos++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (this.#atHole()) {\n\t\t\t\tthis.#skipHole();\n\t\t\t\ttag.complete = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst char = this.#char(this.#pos);\n\t\t\tif (char === \">\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\ttag.end = this.#pos;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (isSpace(char)) {\n\t\t\t\tthis.#pos++;\n\t\t\t} else if (char === \"/\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\tif (this.#char(this.#pos) === \">\") tag.selfClosing = true;\n\t\t\t} else {\n\t\t\t\tconst attribute = this.#attribute();\n\t\t\t\tif (attribute) tag.attributes.push(attribute);\n\t\t\t\telse tag.complete = false;\n\t\t\t}\n\t\t}\n\t\treturn tag;\n\t}\n\n\t/** Reads one attribute, or returns null when its name is built at render time. */\n\t#attribute(): Attribute | null {\n\t\tconst start = this.#pos;\n\t\t// A name touching an output, such as `aria-{{ x }}`, is only partly known.\n\t\tlet known = !this.#output(start - 1);\n\t\tthis.#pos++;\n\t\tthis.#word(\"=\");\n\t\twhile (this.#output(this.#pos)) {\n\t\t\tknown = false;\n\t\t\twhile (this.#output(this.#pos)) this.#pos++;\n\t\t\tthis.#word(\"=\");\n\t\t}\n\t\tconst nameSpan = { start, end: this.#pos };\n\t\tconst name = this.source.slice(start, this.#pos).toLowerCase();\n\n\t\tlet value: string | null = null;\n\t\tlet valueStart = this.#pos;\n\t\tconst beforeEquals = this.#pos;\n\t\tthis.#skipSpace();\n\t\tif (this.#char(this.#pos) === \"=\") {\n\t\t\tthis.#pos++;\n\t\t\tthis.#skipSpace();\n\t\t\tconst quote = this.#char(this.#pos);\n\t\t\tif (quote === '\"' || quote === \"'\") {\n\t\t\t\tthis.#pos++;\n\t\t\t\tvalueStart = this.#pos;\n\t\t\t\tlet written = true;\n\t\t\t\twhile (\n\t\t\t\t\tthis.#pos < this.source.length &&\n\t\t\t\t\tthis.#char(this.#pos) !== quote\n\t\t\t\t) {\n\t\t\t\t\tif (this.#atHole()) written = false;\n\t\t\t\t\tthis.#pos++;\n\t\t\t\t}\n\t\t\t\tif (written) value = this.source.slice(valueStart, this.#pos);\n\t\t\t\tthis.#pos++;\n\t\t\t} else {\n\t\t\t\tvalueStart = this.#pos;\n\t\t\t\tlet written = true;\n\t\t\t\tfor (;;) {\n\t\t\t\t\tif (this.mask[this.#pos] === COMMENT) break;\n\t\t\t\t\tif (this.#atHole()) {\n\t\t\t\t\t\twritten = false;\n\t\t\t\t\t\tthis.#skipHole();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst char = this.#char(this.#pos);\n\t\t\t\t\tif (char === undefined || isSpace(char) || char === \">\") break;\n\t\t\t\t\tthis.#pos++;\n\t\t\t\t}\n\t\t\t\tif (written) value = this.source.slice(valueStart, this.#pos);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.#pos = beforeEquals;\n\t\t}\n\t\tif (!known) return null;\n\t\treturn {\n\t\t\tname,\n\t\t\tspan: { start, end: Math.min(this.#pos, this.source.length) },\n\t\t\tnameSpan,\n\t\t\tvalue,\n\t\t\tvalueStart,\n\t\t};\n\t}\n}\n\n/**\n * The HTML start and end tags written in a template's text, in source order. Leaves out what is inside `<svg>`,\n * `<math>` and elements whose content is text, such as `<script>`, and the end tags of `<svg>` and `<math>`. Returns\n * nothing for a template that starts with an XML declaration, such as a feed.\n */\nexport const scanTags = (source: string): Tag[] => {\n\tconst scanner = new Scanner(source, sourceMask(source));\n\tif (scanner.startsWithXml()) return [];\n\tconst tags: Tag[] = [];\n\t/** The open `svg` or `math` element, and how many of the same name are open inside it. */\n\tlet foreign: { name: string; depth: number } | null = null;\n\n\tfor (let tag = scanner.next(); tag; tag = scanner.next()) {\n\t\tif (foreign) {\n\t\t\tif (tag.name !== foreign.name) continue;\n\t\t\tif (tag.type === \"end\") {\n\t\t\t\tif (--foreign.depth === 0) foreign = null;\n\t\t\t} else if (!tag.selfClosing) foreign.depth++;\n\t\t\tcontinue;\n\t\t}\n\t\ttags.push(tag);\n\t\tif (tag.type === \"end\") continue;\n\t\t// The HTML parser ignores `/>` here, so `<script />` still holds text up to `</script>`.\n\t\tif (RAW_TEXT.has(tag.name)) scanner.skipRawText(tag.name);\n\t\telse if (FOREIGN.has(tag.name) && !tag.selfClosing) {\n\t\t\tforeign = { name: tag.name, depth: 1 };\n\t\t}\n\t}\n\treturn tags;\n};\n","import { createDiagnostic, type Diagnostic } from \"../errors.js\";\nimport type { CompiledTemplate } from \"../runtime/types.js\";\nimport type { Span } from \"../source.js\";\nimport { checkNesting } from \"./nesting.js\";\nimport {\n\tHTML_CHECKS,\n\ttype HtmlCheck,\n\ttype HtmlCheckLevels,\n} from \"./options.js\";\nimport { scanTags } from \"./scanner.js\";\nimport { checkTag } from \"./tags.js\";\n\nexport {\n\ttype HtmlCheck,\n\ttype HtmlCheckLevel,\n\ttype HtmlCheckLevels,\n\ttype HtmlChecks,\n\thtmlChecksOption,\n\tresolveHtmlChecks,\n} from \"./options.js\";\nexport { templateText } from \"./scanner.js\";\n\n/** Checks the HTML written in a template against the rules `levels` turns on. Never renders. */\nexport const checkHtml = (\n\ttemplate: CompiledTemplate,\n\tlevels: HtmlCheckLevels,\n): Diagnostic[] => {\n\tconst diagnostics: Diagnostic[] = [];\n\tif (HTML_CHECKS.every((code) => levels[code] === \"off\")) return diagnostics;\n\tconst report = (code: HtmlCheck, message: string, span: Span) => {\n\t\tconst level = levels[code];\n\t\tif (level === \"off\") return;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic(template.source, code, message, span, level),\n\t\t);\n\t};\n\n\tconst tags = scanTags(template.source.text);\n\tfor (const tag of tags) if (tag.type === \"start\") checkTag(tag, report);\n\tcheckNesting(template, tags, report);\n\treturn diagnostics;\n};\n","import { closeOutlets, takeOutput } from \"./outlets.js\";\nimport type { Out, RenderState } from \"./types.js\";\n\n/**\n * Sends a streamed render's output as it becomes final, for `renderStream`.\n *\n * Host code that returns a promise calls `wait`. The send happens once the render is really waiting, after the\n * microtasks already queued, so promises that settle at once share one send instead of making many small ones.\n */\nexport class RenderStream {\n\t#timer: ReturnType<typeof setTimeout> | null = null;\n\n\tconstructor(\n\t\treadonly state: RenderState,\n\t\treadonly root: Out,\n\t\t/** Sends a part of the page. Must not throw, since it runs from a timer. */\n\t\treadonly send: (text: string) => void,\n\t) {}\n\n\t/** The render is about to wait for host code. */\n\twait(): void {\n\t\tthis.#timer ??= setTimeout(() => {\n\t\t\tthis.#timer = null;\n\t\t\tthis.flush();\n\t\t}, 0);\n\t}\n\n\t/** Sends the output that is final so far. */\n\tflush(): void {\n\t\tconst text = takeOutput(this.state, this.root.s);\n\t\tif (text !== \"\") this.send(text);\n\t}\n\n\t/** Sends the rest of the output, once the render has finished. */\n\tend(): void {\n\t\tthis.stop();\n\t\tcloseOutlets(this.state);\n\t\tthis.flush();\n\t}\n\n\t/** Cancels a pending send. */\n\tstop(): void {\n\t\tif (this.#timer === null) return;\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = null;\n\t}\n}\n","import { type Analysis, analyzeTemplate } from \"./analyzer.js\";\nimport { builtinFilters } from \"./builtins/filters.js\";\nimport { builtinFunctions, builtinTests } from \"./builtins/functions.js\";\nimport { checkReferences } from \"./checker.js\";\nimport { generateModule } from \"./compiler/codegen.js\";\nimport { compileTemplate } from \"./compiler/compiler.js\";\nimport {\n\tcompilePrecompiled,\n\tisPrecompiled,\n\ttype PrecompiledTemplate,\n} from \"./compiler/precompiled.js\";\nimport {\n\ttype Diagnostic,\n\tKilnIssue,\n\tKilnRenderError,\n\tKilnSyntaxError,\n} from \"./errors.js\";\nimport {\n\tcheckHtml,\n\ttype HtmlCheckLevels,\n\ttype HtmlChecks,\n\tresolveHtmlChecks,\n} from \"./html/index.js\";\nimport { resolveTemplateName } from \"./names.js\";\nimport type { EscapeStrategy } from \"./parser/ast.js\";\nimport { ESCAPE_STRATEGIES } from \"./parser/ast.js\";\nimport type { IslandMode } from \"./runtime/islands.js\";\nimport { closeOutlets, takeOutput } from \"./runtime/outlets.js\";\nimport {\n\taddSlotFlags,\n\tisPromise,\n\trenderTemplate,\n\tsilence,\n} from \"./runtime/render.js\";\nimport { childScope } from \"./runtime/scope.js\";\nimport { RenderStream } from \"./runtime/stream.js\";\nimport {\n\ttype AbortSignalLike,\n\ttype CallableEntry,\n\ttype CompiledTemplate,\n\ttype EnvironmentCore,\n\ttype KilnCache,\n\temptyOut,\n\ttype Out,\n\ttype RenderInfo,\n\tRenderState,\n\ttype Scope,\n\ttype TypeCheck,\n} from \"./runtime/types.js\";\nimport { hashKeys, isPlainObject, typeName } from \"./runtime/values.js\";\n\nexport type { RenderInfo };\n\n/**\n * Where templates come from. Kiln calls `load` once per resolved name that exists, until `invalidate`, and remembers\n * a limited number of missing names.\n */\nexport type Loader = {\n\t/**\n\t * Returns the source for a resolved name, such as `pages/page.kiln`, or a precompiled module's default export, or\n\t * `null` if it does not exist. May return a promise or another thenable.\n\t */\n\tload(\n\t\tname: string,\n\t):\n\t\t| string\n\t\t| PrecompiledTemplate\n\t\t| null\n\t\t| PromiseLike<string | PrecompiledTemplate | null>;\n\t/** Returns every resolved name the loader holds. Rendering never calls it; tools such as `generateTypes` do. */\n\tlist?(): string[] | Promise<string[]>;\n};\n\n/**\n * TypeScript types for host prop types, such as `Post`. Empty until the host adds to it:\n *\n * ```ts\n * declare module \"@lucidkiln/core\" {\n * \tinterface KilnTypes { Post: PostView }\n * }\n * ```\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnTypes {}\n\n/**\n * TypeScript types for the functions a project registers, which editors read to show types and complete properties.\n * Empty until the host adds to it. `createKiln` doesn't check it against what you register.\n *\n * ```ts\n * type Functions = typeof functions;\n * declare module \"@lucidkiln/core\" {\n * \tinterface KilnFunctions extends Functions {}\n * }\n * ```\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnFunctions {}\n\n/** Like `KilnFunctions`, for filters. A filter's first argument is the value before the `|`. */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnFilters {}\n\n/** Like `KilnFunctions`, for tests. */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnTests {}\n\n/** Like `KilnFunctions`, for globals. */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnGlobals {}\n\n/**\n * Project-wide template defaults, keyed by name without `.kiln`. An explicit schema on `createKiln` replaces these.\n */\n// oxlint-disable-next-line typescript/no-empty-interface, typescript/no-empty-object-type -- filled in by declaration merging\nexport interface KilnTemplates {}\n\n/** The template and host-type maps for one environment. `generateTypes` writes a schema for each template root. */\nexport type KilnSchema = {\n\ttemplates: Record<string, { context: object; blocks: string }>;\n\ttypes: object;\n};\n\ntype DefaultSchema = {\n\ttemplates: { [Name in keyof KilnTemplates]: KilnTemplates[Name] };\n\ttypes: KilnTypes;\n};\n\n/** The `types` option: a type guard for each host type, plus any other checks. */\nexport type TypeChecks<Types extends object = KilnTypes> = {\n\t[Name in keyof Types]: (value: unknown) => value is Types[Name];\n} & Record<string, TypeCheck>;\n\n/** A template name. Known names complete in editors, and any other string is accepted. */\n// oxlint-disable-next-line typescript/no-redundant-type-constituents -- known names may be empty before types are generated\nexport type TemplateName<Templates extends object = KilnTemplates> =\n\t| (keyof Templates & string)\n\t| (string & {});\n\ntype TemplateEntry<Name extends string, Templates extends object> = (\n\tName extends `${infer Base}.kiln` ? Base : Name\n) extends infer Key\n\t? Key extends keyof Templates\n\t\t? Templates[Key]\n\t\t: undefined\n\t: undefined;\n\n/** The data `render` takes for a template. Any data for a name its template map doesn't list. */\nexport type TemplateContext<\n\tName extends string,\n\tTemplates extends object = KilnTemplates,\n> =\n\tTemplateEntry<Name, Templates> extends { context: infer Context }\n\t\t? Context\n\t\t: Record<string, unknown>;\n\n/** The block names `renderBlock` takes for a template. Any name for a template its map doesn't list. */\nexport type TemplateBlock<\n\tName extends string,\n\tTemplates extends object = KilnTemplates,\n> =\n\tTemplateEntry<Name, Templates> extends { blocks: infer Block }\n\t\t? Block\n\t\t: string;\n\nconst renderAware: unique symbol = Symbol(\"kiln.renderAware\");\n\n/**\n * Any function that takes `RenderInfo` first. Written as a method so `render` can declare any state, while a `render`\n * without a type gets `RenderInfo<unknown>`, or the environment's state inside `createKiln`.\n */\ntype RenderCall = {\n\tcall(render: RenderInfo<unknown>, ...args: never): unknown;\n}[\"call\"];\n\n/**\n * A host function that receives `RenderInfo` before its arguments. Create it with `withRender`. `Call` is the function's\n * own type, type parameters included, so editors can show it and work out what each call returns.\n */\nexport type RenderAware<Call extends RenderCall = RenderCall> = {\n\treadonly [renderAware]: true;\n\treadonly call: Call;\n};\n\n/** A function, filter or test a host registers. Parameter types are the host's to declare. */\nexport type KilnCallable<State = undefined> =\n\t| ((...args: never) => unknown)\n\t| RenderAware<(render: RenderInfo<State>, ...args: never) => unknown>;\n\nexport type Limits = {\n\t/** Characters of output, counted as string length. */\n\tmaxOutputLength: number;\n\t/** Tags, outputs, loop iterations and calls executed. */\n\tmaxSteps: number;\n\t/** Nested includes, components, macro calls and layouts. */\n\tmaxDepth: number;\n};\n\nexport type KilnOptions<\n\tState = undefined,\n\tSchema extends KilnSchema = DefaultSchema,\n> = {\n\tloader: Loader;\n\tfunctions?: Record<string, KilnCallable<State>>;\n\tfilters?: Record<string, KilnCallable<State>>;\n\ttests?: Record<string, KilnCallable<State>>;\n\tglobals?: Record<string, unknown>;\n\t/** Undefined variables and missing properties are errors. Default `true`. */\n\tstrict?: boolean;\n\t/** Default escaping strategy for `{{ }}`. Default `\"html\"`. */\n\tautoescape?: EscapeStrategy | false;\n\t/** Default `Intl` locale. Default `\"en\"`. */\n\tlocale?: string;\n\t/** Default time zone for `formatDate`. Default `\"UTC\"`. */\n\ttimeZone?: string;\n\t/** Enables `dump`. Default `false`. */\n\tdebug?: boolean;\n\t/** Where the `cache` tag saves output, such as `memoryCache()`. Without it, the tag renders every time. */\n\tcache?: KilnCache;\n\t/** App and build identity added to fragment cache keys. Default `\"\"`. */\n\tcacheNamespace?: string;\n\tlimits?: Partial<Limits>;\n\t/** Which HTML rules `check` reports, and at what level. Default `true`, every rule as a warning. */\n\thtmlChecks?: HtmlChecks;\n} & (keyof Schema[\"types\"] extends never\n\t? { types?: TypeChecks<Schema[\"types\"]> }\n\t: { types: TypeChecks<Schema[\"types\"]> });\n\ntype BaseRenderOptions = {\n\tlocale?: string;\n\ttimeZone?: string;\n\t/** Stops the render when aborted. A real `AbortSignal` works. */\n\tsignal?: AbortSignalLike;\n\t/**\n\t * Defers `island` tags with `deferIslands`, or streams them with `streamIslands` in `renderStream`. Without it,\n\t * islands render in place.\n\t */\n\tislands?: IslandMode;\n};\n\n/** `state` is required when the environment was created with a `State` type. */\nexport type RenderOptions<State = undefined> = BaseRenderOptions &\n\t(undefined extends State ? { state?: State } : { state: State });\n\n/** The data and options after a template name: the data is optional when every key is, and the options when `State` allows it. */\ntype RenderArguments<Context, State> = [\n\t// oxlint-disable-next-line typescript/no-empty-object-type -- `{}` is the data with no keys\n\t...({} extends Context ? [context?: Context] : [context: Context]),\n\t...(undefined extends State\n\t\t? [options?: RenderOptions<State>]\n\t\t: [options: RenderOptions<State>]),\n];\n\nexport type Kiln<\n\tState = undefined,\n\tSchema extends KilnSchema = DefaultSchema,\n> = {\n\t/** Renders a template. Rejects with `KilnSyntaxError` or `KilnRenderError`. */\n\trender<Name extends TemplateName<Schema[\"templates\"]>>(\n\t\tname: Name,\n\t\t...args: RenderArguments<TemplateContext<Name, Schema[\"templates\"]>, State>\n\t): Promise<string>;\n\t/**\n\t * Renders one block of a template, such as a fragment for an htmx or fetch request. Child templates' top-level statements run first, as in `render`.\n\t */\n\trenderBlock<Name extends TemplateName<Schema[\"templates\"]>>(\n\t\tname: Name,\n\t\tblock: TemplateBlock<Name, Schema[\"templates\"]>,\n\t\t...args: RenderArguments<TemplateContext<Name, Schema[\"templates\"]>, State>\n\t): Promise<string>;\n\t/**\n\t * Renders a template as a stream of UTF-8 bytes, sending each part as soon as it is final. Resolves once the first\n\t * part is ready, or rejects as `render` would when the render fails before then. A later failure errors the stream.\n\t */\n\trenderStream<Name extends TemplateName<Schema[\"templates\"]>>(\n\t\tname: Name,\n\t\t...args: RenderArguments<TemplateContext<Name, Schema[\"templates\"]>, State>\n\t): Promise<ReadableStream<Uint8Array>>;\n\t/** Parses and checks a template without rendering it. Pass `source` to check unsaved text. */\n\tcheck(name: string, source?: string): Promise<Diagnostic[]>;\n\t/** Reports what a template uses: variables, props, functions, filters, tests, templates, blocks and macros. */\n\tanalyze(name: string, source?: string): Promise<Analysis>;\n\t/**\n\t * Compiles a template to the source of a JavaScript module, at build time. Loaders return the module's default\n\t * export in place of the source. Rejects with `KilnSyntaxError` when the template has problems.\n\t */\n\tprecompile(name: string, source?: string): Promise<string>;\n\t/** Drops one compiled template, or all of them, from the cache. */\n\tinvalidate(name?: string): void;\n};\n\n/**\n * Wraps a host function so it receives request-specific `RenderInfo` first, including the `state` passed to `render`.\n *\n * ```ts\n * document: withRender((render, collection: string) => fetchDocument(collection, render.state.locale))\n * ```\n */\nexport const withRender = <Call extends RenderCall>(\n\tfn: Call,\n): RenderAware<Call> => ({\n\t[renderAware]: true,\n\tcall: fn,\n});\n\nconst DEFAULT_LIMITS: Limits = {\n\tmaxOutputLength: 5_000_000,\n\tmaxSteps: 1_000_000,\n\tmaxDepth: 64,\n};\n\n/** The default limits with the host's on top. A limit left out or `undefined` keeps its default. */\nconst checkLimits = (limits: Partial<Limits> | undefined): Limits => {\n\tconst result = { ...DEFAULT_LIMITS };\n\tif (limits === undefined) return result;\n\tfor (const key of Object.keys(DEFAULT_LIMITS) as (keyof Limits)[]) {\n\t\tconst value: unknown = limits[key];\n\t\tif (value === undefined) continue;\n\t\tif (typeof value !== \"number\" || !(value > 0)) {\n\t\t\tthrow new TypeError(`limits.${key} must be a number above 0`);\n\t\t}\n\t\tresult[key] = value;\n\t}\n\treturn result;\n};\n\n/** How many missing template names an environment remembers, so it doesn't ask its loader again on every render. */\nconst MAX_MISSING = 1000;\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n\ttypeof value === \"object\" &&\n\tvalue !== null &&\n\ttypeof (value as { then?: unknown }).then === \"function\";\n\n/** Resolves a name passed to the API, failing with a `KilnRenderError` for an invalid one. */\nconst resolveName = (name: string): string => {\n\tif (typeof name !== \"string\") {\n\t\tthrow new TypeError(\n\t\t\t`Template name must be a string, but got a ${typeName(name)}`,\n\t\t);\n\t}\n\ttry {\n\t\treturn resolveTemplateName(name);\n\t} catch (error) {\n\t\tif (!(error instanceof KilnIssue)) throw error;\n\t\tthrow new KilnRenderError(error.code, error.message, name);\n\t}\n};\n\nconst NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst TYPE_NAME = /^[A-Z][A-Za-z0-9_]*$/;\nconst TEST_NAME = /^[A-Za-z_][A-Za-z0-9_]*( [A-Za-z_][A-Za-z0-9_]*)?$/;\nconst RESERVED = {\n\tfunction: new Set([\"parent\", \"block\"]),\n\tfilter: new Set([\"default\", \"raw\", \"escape\"]),\n\ttest: new Set([\"defined\"]),\n};\n\nconst builtinMaps = new WeakMap<\n\tRecord<string, CallableEntry>,\n\tReadonlyMap<string, CallableEntry>\n>();\n\n/** Built-ins of one kind as a map, made once and shared by environments that add none of their own. */\nconst builtinMap = (\n\tbuiltins: Record<string, CallableEntry>,\n): ReadonlyMap<string, CallableEntry> => {\n\tlet map = builtinMaps.get(builtins);\n\tif (!map) {\n\t\tmap = new Map(Object.entries(builtins));\n\t\tbuiltinMaps.set(builtins, map);\n\t}\n\treturn map;\n};\n\nconst registry = <State>(\n\tkind: \"function\" | \"filter\" | \"test\",\n\tbuiltins: Record<string, CallableEntry>,\n\thost: Record<string, KilnCallable<State>> | undefined,\n): ReadonlyMap<string, CallableEntry> => {\n\tconst shared = builtinMap(builtins);\n\tif (!host || Object.keys(host).length === 0) return shared;\n\tconst entries = new Map(shared);\n\tfor (const [name, value] of Object.entries(host)) {\n\t\tif (!(kind === \"test\" ? TEST_NAME : NAME).test(name)) {\n\t\t\tthrow new TypeError(`\"${name}\" is not a valid ${kind} name`);\n\t\t}\n\t\tif (RESERVED[kind].has(name)) {\n\t\t\tthrow new TypeError(`\"${name}\" is a reserved ${kind} name`);\n\t\t}\n\t\tif (typeof value === \"function\") {\n\t\t\tentries.set(name, {\n\t\t\t\tkind: \"host\",\n\t\t\t\tname,\n\t\t\t\tcall: value as (...args: unknown[]) => unknown,\n\t\t\t\trender: false,\n\t\t\t});\n\t\t} else if (\n\t\t\ttypeof value === \"object\" &&\n\t\t\tvalue !== null &&\n\t\t\trenderAware in value\n\t\t) {\n\t\t\tentries.set(name, {\n\t\t\t\tkind: \"host\",\n\t\t\t\tname,\n\t\t\t\tcall: value.call as (...args: unknown[]) => unknown,\n\t\t\t\trender: true,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new TypeError(`${kind} \"${name}\" must be a function`);\n\t\t}\n\t}\n\treturn entries;\n};\n\nclass Environment<State, Schema extends KilnSchema> implements EnvironmentCore {\n\treadonly strict: boolean;\n\treadonly debug: boolean;\n\treadonly autoescape: EscapeStrategy | false;\n\treadonly functions: ReadonlyMap<string, CallableEntry>;\n\treadonly filters: ReadonlyMap<string, CallableEntry>;\n\treadonly tests: ReadonlyMap<string, CallableEntry>;\n\treadonly types: Map<string, TypeCheck>;\n\treadonly globals: Scope;\n\treadonly limits: Limits;\n\treadonly locale: string;\n\treadonly timeZone: string;\n\treadonly cache: KilnCache | null;\n\treadonly cacheNamespace: string;\n\treadonly htmlChecks: HtmlCheckLevels;\n\treadonly #loader: Loader;\n\treadonly #cache = new Map<\n\t\tstring,\n\t\tCompiledTemplate | Promise<CompiledTemplate | null>\n\t>();\n\t/** Names the loader didn't find. Names may come from requests, so only a limited number are remembered. */\n\treadonly #missing = new Set<string>();\n\t/** Names passed to `render`, resolved. */\n\treadonly #names = new Map<string, string>();\n\tgeneration = 0;\n\n\tconstructor(options: KilnOptions<State, Schema>) {\n\t\tif (typeof options.loader?.load !== \"function\") {\n\t\t\tthrow new TypeError(\"createKiln needs a loader with a load(name) method\");\n\t\t}\n\t\tif (\n\t\t\toptions.autoescape !== undefined &&\n\t\t\toptions.autoescape !== false &&\n\t\t\t!ESCAPE_STRATEGIES.includes(options.autoescape)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Unknown escaping strategy \"${String(options.autoescape)}\"`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\toptions.cache !== undefined &&\n\t\t\t(typeof options.cache?.get !== \"function\" ||\n\t\t\t\ttypeof options.cache.set !== \"function\")\n\t\t) {\n\t\t\tthrow new TypeError(\"createKiln needs a cache with get and set methods\");\n\t\t}\n\t\tif (\n\t\t\toptions.cacheNamespace !== undefined &&\n\t\t\ttypeof options.cacheNamespace !== \"string\"\n\t\t) {\n\t\t\tthrow new TypeError(\"cacheNamespace must be a string\");\n\t\t}\n\t\tthis.#loader = options.loader;\n\t\tthis.cache = options.cache ?? null;\n\t\tthis.cacheNamespace = options.cacheNamespace ?? \"\";\n\t\tthis.strict = options.strict ?? true;\n\t\tthis.debug = options.debug ?? false;\n\t\tthis.autoescape = options.autoescape ?? \"html\";\n\t\tthis.locale = options.locale ?? \"en\";\n\t\tthis.timeZone = options.timeZone ?? \"UTC\";\n\t\tthis.limits = checkLimits(options.limits);\n\t\tthis.htmlChecks = resolveHtmlChecks(options.htmlChecks);\n\t\tthis.functions = registry(\"function\", builtinFunctions, options.functions);\n\t\tthis.filters = registry(\"filter\", builtinFilters, options.filters);\n\t\tthis.tests = registry(\"test\", builtinTests, options.tests);\n\t\tthis.types = new Map();\n\t\tfor (const [name, check] of Object.entries<TypeCheck>(\n\t\t\toptions.types ?? {},\n\t\t)) {\n\t\t\tif (!TYPE_NAME.test(name)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`\"${name}\" is not a valid type name. Type names start with a capital letter`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (typeof check !== \"function\") {\n\t\t\t\tthrow new TypeError(`type \"${name}\" must be a function`);\n\t\t\t}\n\t\t\tthis.types.set(name, check);\n\t\t}\n\n\t\tconst globals = childScope(null);\n\t\tconst provided = options.globals ?? {};\n\t\tif (!isPlainObject(provided))\n\t\t\tthrow new TypeError(\"globals must be a plain object\");\n\t\tfor (const key of hashKeys(provided)) globals[key] = provided[key] ?? null;\n\t\tthis.globals = globals;\n\t}\n\n\tload(\n\t\tname: string,\n\t): CompiledTemplate | null | Promise<CompiledTemplate | null> {\n\t\tconst cached = this.#cache.get(name);\n\t\tif (cached !== undefined) return cached;\n\t\tif (this.#missing.has(name)) return null;\n\n\t\tconst compile = (source: string | PrecompiledTemplate | null) => {\n\t\t\tif (source === null) return null;\n\t\t\tif (typeof source === \"string\") {\n\t\t\t\treturn compileTemplate(this, name, source);\n\t\t\t}\n\t\t\tif (isPrecompiled(source)) return compilePrecompiled(this, name, source);\n\t\t\tthrow new TypeError(\n\t\t\t\t`Loader returned a ${typeName(source)} for \"${name}\", not a string, a precompiled template or null`,\n\t\t\t);\n\t\t};\n\t\tconst keep = (template: CompiledTemplate | null) => {\n\t\t\tif (template !== null) this.#cache.set(name, template);\n\t\t\telse {\n\t\t\t\tif (this.#missing.size >= MAX_MISSING) this.#missing.clear();\n\t\t\t\tthis.#missing.add(name);\n\t\t\t}\n\t\t};\n\n\t\tconst result = this.#loader.load(name);\n\t\t// A loader may return a thenable, such as a promise from another realm.\n\t\tconst loaded = isThenable(result) ? Promise.resolve(result) : result;\n\t\tif (loaded instanceof Promise) {\n\t\t\t// An invalidate while this load is in flight replaces or drops the\n\t\t\t// entry, so only touch the cache if it still holds this load. A load\n\t\t\t// or compile that fails is forgotten, so the next render tries again.\n\t\t\tconst pending: Promise<CompiledTemplate | null> = loaded\n\t\t\t\t.then(compile)\n\t\t\t\t.then(\n\t\t\t\t\t(template) => {\n\t\t\t\t\t\tif (this.#cache.get(name) === pending) {\n\t\t\t\t\t\t\tthis.#cache.delete(name);\n\t\t\t\t\t\t\tkeep(template);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn template;\n\t\t\t\t\t},\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tif (this.#cache.get(name) === pending) this.#cache.delete(name);\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\tthis.#cache.set(name, pending);\n\t\t\treturn pending;\n\t\t}\n\t\tconst template = compile(loaded);\n\t\tkeep(template);\n\t\treturn template;\n\t}\n\n\tinvalidate(name?: string): void {\n\t\tif (name === undefined) {\n\t\t\tthis.#cache.clear();\n\t\t\tthis.#missing.clear();\n\t\t} else {\n\t\t\tconst resolved = resolveName(name);\n\t\t\tthis.#cache.delete(resolved);\n\t\t\tthis.#missing.delete(resolved);\n\t\t}\n\t\tthis.generation++;\n\t}\n\n\t/** Compiles unsaved source, or loads the template, for `check` and `analyze`. */\n\tasync compileFor(\n\t\tname: string,\n\t\tsource?: string,\n\t): Promise<CompiledTemplate | null> {\n\t\tconst resolved = resolveName(name);\n\t\tif (source !== undefined) return compileTemplate(this, resolved, source);\n\t\treturn await this.load(resolved);\n\t}\n\n\t/** Renders a template, or only one of its blocks when `block` is given. */\n\tasync render(\n\t\tname: string,\n\t\tcontext: Record<string, unknown> = {},\n\t\toptions: BaseRenderOptions & { state?: State } = {},\n\t\tblock?: string,\n\t): Promise<string> {\n\t\tlet render = this.#prepare(name, context, options);\n\t\tif (isPromise(render)) render = await render;\n\t\tconst result = this.#run(render, block);\n\t\tif (result !== undefined) {\n\t\t\tawait untilAborted(result, render.state.signal, render.resolved);\n\t\t}\n\t\tconst { state, out } = render;\n\t\t// The signal may have been aborted while the last call was pending, after the render's last check.\n\t\tif (state.signal?.aborted) throw aborted(render.resolved);\n\t\tcloseOutlets(state);\n\t\tconst output = takeOutput(state, out.s);\n\t\tif (output.length > state.maxSize) throw tooLong(render);\n\t\treturn output;\n\t}\n\n\t/**\n\t * Renders a template as a stream, sending its output as it becomes final. Resolves once the first part is ready,\n\t * or rejects when the render fails before then. A later failure errors the stream.\n\t */\n\tasync renderStream(\n\t\tname: string,\n\t\tcontext: Record<string, unknown> = {},\n\t\toptions: BaseRenderOptions & { state?: State } = {},\n\t): Promise<ReadableStream<Uint8Array>> {\n\t\tlet render = this.#prepare(name, context, options);\n\t\tif (isPromise(render)) render = await render;\n\t\tconst { state, out } = render;\n\t\tconst encoder = new TextEncoder();\n\t\tlet controller!: ReadableStreamDefaultController<Uint8Array>;\n\t\tlet cancelled = false;\n\t\tconst stream = new ReadableStream<Uint8Array>({\n\t\t\tstart: (c) => {\n\t\t\t\tcontroller = c;\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tcancelled = true;\n\t\t\t},\n\t\t});\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet opened = false;\n\t\t\tlet failed = false;\n\t\t\tlet length = 0;\n\t\t\tconst open = () => {\n\t\t\t\tif (opened) return;\n\t\t\t\topened = true;\n\t\t\t\tresolve(stream);\n\t\t\t};\n\t\t\tconst failWith = (error: unknown) => {\n\t\t\t\tif (failed) return;\n\t\t\t\tfailed = true;\n\t\t\t\toutput.stop();\n\t\t\t\tstate.signal?.removeEventListener?.(\"abort\", stop);\n\t\t\t\tif (!opened) reject(error);\n\t\t\t\telse if (!cancelled) controller.error(error);\n\t\t\t};\n\t\t\t// An abort ends the stream at once, even while the page or an island waits for your code. The render\n\t\t\t// stops at its next step.\n\t\t\tconst stop = () => failWith(aborted(render.resolved));\n\t\t\tstate.signal?.addEventListener?.(\"abort\", stop);\n\t\t\t// The first half of a character split across two sends, held back so each part encodes to valid UTF-8.\n\t\t\tlet held = \"\";\n\t\t\tconst send = (text: string) => {\n\t\t\t\tif (failed) return;\n\t\t\t\tlength += text.length;\n\t\t\t\tif (length > state.maxSize) return failWith(tooLong(render));\n\t\t\t\ttext = held + text;\n\t\t\t\theld = \"\";\n\t\t\t\tconst last = text.charCodeAt(text.length - 1);\n\t\t\t\tif (last >= 0xd800 && last <= 0xdbff) {\n\t\t\t\t\theld = text.slice(-1);\n\t\t\t\t\ttext = text.slice(0, -1);\n\t\t\t\t}\n\t\t\t\tif (!cancelled && text !== \"\") {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(text));\n\t\t\t\t}\n\t\t\t\topen();\n\t\t\t};\n\t\t\tconst output = new RenderStream(state, out, send);\n\t\t\tstate.stream = output;\n\t\t\tconst close = () => {\n\t\t\t\tstate.signal?.removeEventListener?.(\"abort\", stop);\n\t\t\t\tif (failed || cancelled) return;\n\t\t\t\tif (held !== \"\") controller.enqueue(encoder.encode(held));\n\t\t\t\tcontroller.close();\n\t\t\t};\n\t\t\t// Streamed islands follow the page, each as soon as it is ready.\n\t\t\tconst finish = () => {\n\t\t\t\tif (state.signal?.aborted) return failWith(aborted(render.resolved));\n\t\t\t\toutput.end();\n\t\t\t\tif (failed) return;\n\t\t\t\topen();\n\t\t\t\tconst islands = state.streamed;\n\t\t\t\tif (islands === null) return close();\n\t\t\t\tlet left = islands.length;\n\t\t\t\tfor (const island of islands) {\n\t\t\t\t\tisland.then((html) => {\n\t\t\t\t\t\tsend(html);\n\t\t\t\t\t\tif (--left === 0) close();\n\t\t\t\t\t}, failWith);\n\t\t\t\t}\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tconst result = this.#run(render);\n\t\t\t\tif (result === undefined) finish();\n\t\t\t\telse result.then(finish, failWith);\n\t\t\t} catch (error) {\n\t\t\t\tfailWith(error);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Finds the template and makes the state, scope and output for one render. */\n\t#prepare(\n\t\tname: string,\n\t\tcontext: Record<string, unknown>,\n\t\toptions: BaseRenderOptions & { state?: State },\n\t): Prepared | Promise<Prepared> {\n\t\tlet resolved = this.#names.get(name);\n\t\tif (resolved === undefined) {\n\t\t\tresolved = resolveName(name);\n\t\t\t// Names may come from requests, so the cache can't grow without limit.\n\t\t\tif (this.#names.size >= 1000) this.#names.clear();\n\t\t\tthis.#names.set(name, resolved);\n\t\t}\n\t\tlet template: ReturnType<typeof this.load>;\n\t\ttry {\n\t\t\ttemplate = this.load(resolved);\n\t\t} catch (error) {\n\t\t\tthrow loaderError(resolved, error);\n\t\t}\n\t\tif (isPromise(template)) {\n\t\t\tconst path = resolved;\n\t\t\treturn untilAborted(\n\t\t\t\ttemplate.then(\n\t\t\t\t\t(loaded) => this.#prepared(path, loaded, context, options),\n\t\t\t\t\t(error: unknown) => {\n\t\t\t\t\t\tthrow loaderError(path, error);\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t\toptions.signal,\n\t\t\t\tpath,\n\t\t\t);\n\t\t}\n\t\treturn this.#prepared(resolved, template, context, options);\n\t}\n\n\t#prepared(\n\t\tresolved: string,\n\t\ttemplate: CompiledTemplate | null,\n\t\tcontext: Record<string, unknown>,\n\t\toptions: BaseRenderOptions & { state?: State },\n\t): Prepared {\n\t\tif (!template) {\n\t\t\tthrow new KilnRenderError(\n\t\t\t\t\"missing-template\",\n\t\t\t\t`Template \"${resolved}\" was not found`,\n\t\t\t\tresolved,\n\t\t\t);\n\t\t}\n\t\tif (template.hasErrors) throw template.syntaxError();\n\t\tif (!isPlainObject(context)) {\n\t\t\tthrow new TypeError(\"render context must be a plain object\");\n\t\t}\n\n\t\tconst state = new RenderState(\n\t\t\tthis,\n\t\t\tthis.globals,\n\t\t\tthis.limits.maxSteps,\n\t\t\tthis.limits.maxOutputLength,\n\t\t\tthis.limits.maxDepth,\n\t\t\toptions.locale ?? this.locale,\n\t\t\toptions.timeZone ?? this.timeZone,\n\t\t\toptions.state,\n\t\t\toptions.signal,\n\t\t);\n\t\tif (options.signal?.aborted) throw aborted(resolved);\n\n\t\tconst scope = childScope(this.globals);\n\t\tconst passed = hashKeys(context);\n\t\tfor (const key of passed) scope[key] = context[key] ?? null;\n\t\taddSlotFlags(scope, template, null);\n\n\t\tstate.islands = options.islands ?? null;\n\t\tconst out = emptyOut();\n\t\tstate.root = out;\n\t\treturn { resolved, template, state, scope, passed, out };\n\t}\n\n\t#run(render: Prepared, block?: string): void | Promise<void> {\n\t\tconst { template } = render;\n\t\treturn renderTemplate(\n\t\t\trender.state,\n\t\t\ttemplate,\n\t\t\trender.scope,\n\t\t\trender.out,\n\t\t\t0,\n\t\t\tnull,\n\t\t\trender.passed,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\ttemplate.parentSpan,\n\t\t\tblock,\n\t\t);\n\t}\n}\n\n/** One render, ready to run. */\ntype Prepared = {\n\tresolved: string;\n\ttemplate: CompiledTemplate;\n\tstate: RenderState;\n\tscope: Scope;\n\tpassed: readonly string[];\n\tout: Out;\n};\n\nconst aborted = (resolved: string) =>\n\tnew KilnRenderError(\"aborted\", \"Render was aborted\", resolved);\n\n/**\n * Waits for `work`, or rejects as soon as `signal` aborts, when the signal can say so, as a real `AbortSignal` can.\n * The render itself stops at its next step, once the call it waits for settles.\n */\nconst untilAborted = <T>(\n\twork: Promise<T>,\n\tsignal: AbortSignalLike | undefined,\n\tresolved: string,\n): Promise<T> => {\n\tif (signal?.addEventListener === undefined) return work;\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst stop = () => {\n\t\t\tsilence(work);\n\t\t\treject(aborted(resolved));\n\t\t};\n\t\tif (signal.aborted) return stop();\n\t\tsignal.addEventListener?.(\"abort\", stop);\n\t\twork\n\t\t\t.finally(() => signal.removeEventListener?.(\"abort\", stop))\n\t\t\t.then(resolve, reject);\n\t});\n};\n\n/** A loader's error for the template a render asked for, as an include would report it. Kiln errors pass through. */\nconst loaderError = (resolved: string, error: unknown): unknown =>\n\terror instanceof KilnRenderError || error instanceof KilnSyntaxError\n\t\t? error\n\t\t: new KilnRenderError(\n\t\t\t\t\"host-error\",\n\t\t\t\t`The template loader threw an error: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\tresolved,\n\t\t\t\tundefined,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\nconst tooLong = ({ resolved, state }: Prepared) =>\n\tnew KilnRenderError(\n\t\t\"limit-output\",\n\t\t`Render stopped after ${state.maxSize} characters of output`,\n\t\tresolved,\n\t);\n\n/**\n * Creates a Kiln environment: the loader, functions, filters, tests, globals and options every render uses.\n *\n * ```ts\n * const kiln = createKiln({ loader: memoryLoader({ \"page.kiln\": \"<h1>{{ title }}</h1>\" }) });\n * const html = await kiln.render(\"page\", { title: \"Home\" });\n * ```\n */\nexport const createKiln = <\n\tState = undefined,\n\tSchema extends KilnSchema = DefaultSchema,\n>(\n\toptions: KilnOptions<State, Schema>,\n): Kiln<State, Schema> => {\n\tconst env = new Environment<State, Schema>(options);\n\tconst kiln = createApi(env);\n\tenvironments.set(kiln, env);\n\treturn kiln;\n};\n\ntype ToolingEnvironment = EnvironmentCore & {\n\treadonly globals: Scope;\n\treadonly htmlChecks: HtmlCheckLevels;\n};\n\n/** The environment behind each object `createKiln` returns, for tools such as `generateManifest`. */\nconst environments = new WeakMap<object, ToolingEnvironment>();\n\n/** The environment behind a Kiln object. Throws for an object `createKiln` didn't make. */\nexport const environmentOf = (kiln: object): ToolingEnvironment => {\n\tconst env = environments.get(kiln);\n\tif (!env) throw new TypeError(\"Expected an environment made by createKiln\");\n\treturn env;\n};\n\nconst createApi = <State, Schema extends KilnSchema>(\n\tenv: Environment<State, Schema>,\n): Kiln<State, Schema> => {\n\ttype Options = BaseRenderOptions & { state?: State };\n\t// The typed signatures only narrow what callers may pass, so these take the plain shapes.\n\tconst render = (\n\t\tname: string,\n\t\tcontext?: Record<string, unknown>,\n\t\trenderOptions?: Options,\n\t) => env.render(name, context, renderOptions ?? {});\n\tconst renderBlock = (\n\t\tname: string,\n\t\tblock: string,\n\t\tcontext?: Record<string, unknown>,\n\t\trenderOptions?: Options,\n\t) => {\n\t\tif (typeof block !== \"string\") {\n\t\t\tthrow new TypeError(\"renderBlock needs a block name\");\n\t\t}\n\t\treturn env.render(name, context, renderOptions ?? {}, block);\n\t};\n\tconst renderStream = (\n\t\tname: string,\n\t\tcontext?: Record<string, unknown>,\n\t\trenderOptions?: Options,\n\t) => env.renderStream(name, context, renderOptions ?? {});\n\treturn {\n\t\trender: render as unknown as Kiln<State, Schema>[\"render\"],\n\t\trenderBlock: renderBlock as unknown as Kiln<State, Schema>[\"renderBlock\"],\n\t\trenderStream: renderStream as unknown as Kiln<\n\t\t\tState,\n\t\t\tSchema\n\t\t>[\"renderStream\"],\n\t\tcheck: async (name, source) => {\n\t\t\tconst template = await env.compileFor(name, source);\n\t\t\tif (!template) {\n\t\t\t\tconst position = { offset: 0, line: 1, column: 1 };\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"missing-template\",\n\t\t\t\t\t\tmessage: `Template \"${resolveTemplateName(name)}\" was not found`,\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\ttemplate: resolveTemplateName(name),\n\t\t\t\t\t\tstart: position,\n\t\t\t\t\t\tend: position,\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}\n\t\t\tconst references = await checkReferences(env, template);\n\t\t\tconst html = checkHtml(template, env.htmlChecks);\n\t\t\treturn [...template.diagnostics, ...references, ...html].sort(\n\t\t\t\t(a, b) => a.start.offset - b.start.offset,\n\t\t\t);\n\t\t},\n\t\tanalyze: async (name, source) => {\n\t\t\tconst template = await env.compileFor(name, source);\n\t\t\tif (!template) {\n\t\t\t\tthrow new KilnRenderError(\n\t\t\t\t\t\"missing-template\",\n\t\t\t\t\t`Template \"${resolveTemplateName(name)}\" was not found`,\n\t\t\t\t\tresolveTemplateName(name),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn analyzeTemplate(template, env.globals);\n\t\t},\n\t\tprecompile: async (name, source) => {\n\t\t\tconst template = await env.compileFor(name, source);\n\t\t\tif (!template) {\n\t\t\t\tthrow new KilnRenderError(\n\t\t\t\t\t\"missing-template\",\n\t\t\t\t\t`Template \"${resolveTemplateName(name)}\" was not found`,\n\t\t\t\t\tresolveTemplateName(name),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (template.hasErrors) throw template.syntaxError();\n\t\t\treturn generateModule(env, template.ast, template.source.text);\n\t\t},\n\t\tinvalidate: (name) => env.invalidate(name),\n\t};\n};\n\n/**\n * A loader for templates held in memory, keyed by name. Keys without an extension get `.kiln`. Each template is its\n * source or a precompiled module's default export.\n *\n * Works on every runtime, including Cloudflare Workers.\n */\nexport const memoryLoader = (\n\ttemplates:\n\t\t| Record<string, string | PrecompiledTemplate>\n\t\t| Map<string, string | PrecompiledTemplate>,\n): Omit<Loader, \"list\"> & { list(): string[] } => {\n\tconst map = new Map<string, string | PrecompiledTemplate>();\n\tconst entries =\n\t\ttemplates instanceof Map ? templates : Object.entries(templates);\n\tfor (const [name, source] of entries) {\n\t\tmap.set(resolveTemplateName(name), source);\n\t}\n\treturn { load: (name) => map.get(name) ?? null, list: () => [...map.keys()] };\n};\n\n/**\n * A store for the `cache` tag that keeps output in memory, for a long-running server. Holds up to `max` copies, 1,000\n * by default, and drops the oldest first. `clear` removes every copy, or those with any of the tags passed.\n *\n * ```ts\n * const kiln = createKiln({ loader, cache: memoryCache() });\n * ```\n */\nexport const memoryCache = ({ max = 1000 }: { max?: number } = {}) => {\n\tconst entries = new Map<\n\t\tstring,\n\t\t{ value: string; expires: number; tags: string[] }\n\t>();\n\t// `satisfies` keeps the synchronous types, so callers can use the store without awaiting.\n\treturn {\n\t\tget: ({ key }) => {\n\t\t\tconst entry = entries.get(key);\n\t\t\tif (!entry) return null;\n\t\t\tif (entry.expires > Date.now()) return entry.value;\n\t\t\tentries.delete(key);\n\t\t\treturn null;\n\t\t},\n\t\tset: ({ key, value, seconds, tags }) => {\n\t\t\t// Deleting first moves the key to the end, so the oldest copy is always first.\n\t\t\tentries.delete(key);\n\t\t\tentries.set(key, {\n\t\t\t\tvalue,\n\t\t\t\texpires: seconds === null ? Infinity : Date.now() + seconds * 1000,\n\t\t\t\ttags,\n\t\t\t});\n\t\t\tconst oldest = entries.keys().next();\n\t\t\tif (entries.size > max && !oldest.done) entries.delete(oldest.value);\n\t\t},\n\t\t/** Removes every copy, or with `tags`, the copies that have any of them. */\n\t\tclear: ({ tags }: { tags?: readonly string[] } = {}) => {\n\t\t\tif (!tags) return entries.clear();\n\t\t\tfor (const [key, entry] of entries) {\n\t\t\t\tif (entry.tags.some((tag) => tags.includes(tag))) entries.delete(key);\n\t\t\t}\n\t\t},\n\t} satisfies KilnCache & {\n\t\tclear(options?: { tags?: readonly string[] }): void;\n\t};\n};\n","import { environmentOf, type Kiln, type KilnSchema } from \"./environment.js\";\nimport { type HtmlChecks, htmlChecksOption } from \"./html/index.js\";\nimport { variableNames } from \"./runtime/scope.js\";\nimport type { CallableEntry } from \"./runtime/types.js\";\n\n/** The contents of `kiln.json`, which tells the language server about a project. See the editor support docs. */\nexport type KilnManifest = {\n\t/** The folder template names are relative to, from the folder holding `kiln.json`. */\n\troot: string;\n\tstrict: boolean;\n\tfunctions: string[];\n\tfilters: string[];\n\ttests: string[];\n\tglobals: string[];\n\ttypes: string[];\n\thtmlChecks: HtmlChecks;\n};\n\nconst hostNames = (registry: ReadonlyMap<string, CallableEntry>) =>\n\t[...registry]\n\t\t.filter(([, entry]) => entry.kind === \"host\")\n\t\t.map(([name]) => name)\n\t\t.sort();\n\n/**\n * Writes `kiln.json` for an environment: the names of its functions, filters, tests, globals and prop types, and its HTML check levels, so editors can check templates without running your code. `root` is the template folder, relative to where you write the file.\n *\n * ```ts\n * await writeFile(\"kiln.json\", generateManifest(kiln, { root: \"src/templates\" }));\n * ```\n */\nexport const generateManifest = <State, Schema extends KilnSchema>(\n\tkiln: Kiln<State, Schema>,\n\toptions: { root: string },\n): string => {\n\tconst env = environmentOf(kiln);\n\tconst manifest: KilnManifest = {\n\t\troot: options.root,\n\t\tstrict: env.strict,\n\t\tfunctions: hostNames(env.functions),\n\t\tfilters: hostNames(env.filters),\n\t\ttests: hostNames(env.tests),\n\t\tglobals: variableNames(env.globals).sort(),\n\t\ttypes: [...env.types.keys()].sort(),\n\t\thtmlChecks: htmlChecksOption(env.htmlChecks),\n\t};\n\treturn `${JSON.stringify(manifest, null, \"\\t\")}\\n`;\n};\n","import type { AnalysedProp, Analysis } from \"./analyzer.js\";\nimport type { Kiln } from \"./environment.js\";\nimport { KilnRenderError } from \"./errors.js\";\nimport { resolveTemplateName, TEMPLATE_EXTENSION } from \"./names.js\";\nimport type { PropType, TypeName } from \"./parser/ast.js\";\n\nconst BUILTIN_TYPES: Record<TypeName, string> = {\n\tnull: \"null\",\n\tboolean: \"boolean\",\n\tnumber: \"number\",\n\tstring: \"string | Markup\",\n\tarray: \"readonly unknown[]\",\n\thash: \"Readonly<Record<string, unknown>> | ReadonlyMap<string, unknown>\",\n\tset: \"ReadonlySet<unknown>\",\n\tdate: \"Date\",\n\tmarkup: \"Markup\",\n\tobject: \"object\",\n};\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst key = (name: string) =>\n\tIDENTIFIER.test(name) ? name : JSON.stringify(name);\n\n/** Writes a Kiln prop type as TypeScript. Host types read the schema's type map through `Named`. */\nconst tsType = (type: readonly PropType[] | null): string => {\n\tif (type === null) return \"unknown\";\n\tif (type.length === 0) return \"never\";\n\treturn type.map(tsMember).join(\" | \");\n};\n\nconst tsMember = (member: PropType): string => {\n\tif (typeof member === \"string\") return BUILTIN_TYPES[member];\n\tif (\"literal\" in member) return JSON.stringify(member.literal);\n\tif (\"named\" in member) return `Named<Types, ${JSON.stringify(member.named)}>`;\n\tif (\"list\" in member) {\n\t\tconst inner = tsType(member.list);\n\t\t// `|` and `readonly` bind more loosely than `[]`, so unions and nested lists need brackets.\n\t\treturn inner.includes(\" | \") || inner.startsWith(\"readonly \")\n\t\t\t? `readonly (${inner})[]`\n\t\t\t: `readonly ${inner}[]`;\n\t}\n\tif (member.shape.length === 0) return \"object\";\n\tconst keys = member.shape.map(\n\t\t(entry) =>\n\t\t\t`${key(entry.name)}${entry.optional ? \"?\" : \"\"}: ${tsType(entry.type)}`,\n\t);\n\treturn `{ ${keys.join(\"; \")} }`;\n};\n\n/** A prop as an object type member. A default makes it optional, and null then picks the default. */\nconst field = (prop: AnalysedProp, optional: boolean) =>\n\toptional\n\t\t? `${key(prop.name)}?: ${prop.type ? `${tsType(prop.type)} | null` : \"unknown\"}`\n\t\t: `${key(prop.name)}: ${tsType(prop.type)}`;\n\nconst objectType = (fields: string[], indent: string) =>\n\tfields.length === 0\n\t\t? \"{}\"\n\t\t: `{\\n${fields.map((line) => `${indent}\\t${line};`).join(\"\\n\")}\\n${indent}}`;\n\n/**\n * Writes a module exporting `Schema`, describing each template's data and blocks from their `props`. Pass it as the\n * second type argument to `createKiln` so each environment has its own template and host-type maps.\n *\n * Pass the names of the templates to describe, such as a loader's `list()`. The result is the file's contents; write it wherever your `tsconfig.json` includes.\n *\n * ```ts\n * await writeFile(\"src/kiln.d.ts\", await generateTypes(kiln, await loader.list()));\n * ```\n */\nexport const generateTypes = async (\n\tkiln: Pick<Kiln, \"analyze\">,\n\tnames: Iterable<string>,\n): Promise<string> => {\n\tconst analyses = new Map<string, Promise<Analysis | null>>();\n\tconst analyse = (name: string) => {\n\t\tlet analysis = analyses.get(name);\n\t\tif (!analysis) {\n\t\t\tanalysis = kiln.analyze(name).catch((error: unknown) => {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof KilnRenderError &&\n\t\t\t\t\terror.code === \"missing-template\"\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t\tanalyses.set(name, analysis);\n\t\t}\n\t\treturn analysis;\n\t};\n\n\t/** The layouts a template extends, nearest first. `complete` is false when one is built at render time or missing. */\n\tconst layoutsOf = async (analysis: Analysis) => {\n\t\tconst layouts: Analysis[] = [];\n\t\tconst seen = new Set<string>();\n\t\tlet current = analysis;\n\t\tfor (;;) {\n\t\t\tconst parent = current.templates.find((ref) => ref.kind === \"extends\");\n\t\t\tif (!parent) return { layouts, complete: true };\n\t\t\tif (!parent.name || seen.has(parent.name))\n\t\t\t\treturn { layouts, complete: false };\n\t\t\tseen.add(parent.name);\n\t\t\tconst layout = await analyse(parent.name);\n\t\t\tif (!layout) return { layouts, complete: false };\n\t\t\tlayouts.push(layout);\n\t\t\tcurrent = layout;\n\t\t}\n\t};\n\n\tconst entries: string[] = [];\n\tlet usesMarkup = false;\n\tlet usesNamed = false;\n\tconst resolved = [\n\t\t...new Set([...names].map((name) => resolveTemplateName(name))),\n\t].sort();\n\tfor (const name of resolved) {\n\t\tconst analysis = await analyse(name);\n\t\tif (!analysis) continue;\n\t\tconst { layouts, complete } = await layoutsOf(analysis);\n\n\t\t/** Its layouts' props that the page doesn't declare or set itself, which it must pass on. */\n\t\tconst layoutFields = () => {\n\t\t\tconst provided = new Set([\n\t\t\t\t...analysis.props.map((prop) => prop.name),\n\t\t\t\t...analysis.sets,\n\t\t\t]);\n\t\t\tconst fields: string[] = [];\n\t\t\tfor (const layout of layouts) {\n\t\t\t\tfor (const prop of layout.props) {\n\t\t\t\t\tif (!provided.has(prop.name))\n\t\t\t\t\t\tfields.push(field(prop, !prop.required));\n\t\t\t\t\tprovided.add(prop.name);\n\t\t\t\t}\n\t\t\t\tfor (const set of layout.sets) provided.add(set);\n\t\t\t}\n\t\t\treturn fields;\n\t\t};\n\n\t\tlet context: string;\n\t\tif (analysis.rest !== null) {\n\t\t\t// A rest prop accepts any other key, so the layouts can get their props too.\n\t\t\tconst fields = [\n\t\t\t\t...analysis.props.map((prop) => field(prop, !prop.required)),\n\t\t\t\t...layoutFields(),\n\t\t\t\t\"[key: string]: unknown\",\n\t\t\t];\n\t\t\tcontext = objectType(fields, \"\\t\\t\\t\");\n\t\t} else if (analysis.props.length > 0) {\n\t\t\t// Strict mode rejects anything a template with `props` doesn't declare.\n\t\t\tconst fields = analysis.props.map((prop) => field(prop, !prop.required));\n\t\t\tcontext = objectType(fields, \"\\t\\t\\t\");\n\t\t} else {\n\t\t\t// Without `props`, a page takes any data, plus its layouts' props.\n\t\t\tconst fields = layoutFields();\n\t\t\tcontext =\n\t\t\t\tfields.length === 0\n\t\t\t\t\t? \"Record<string, unknown>\"\n\t\t\t\t\t: `${objectType(fields, \"\\t\\t\\t\")} & Record<string, unknown>`;\n\t\t}\n\n\t\tconst blockNames = new Set([analysis, ...layouts].flatMap((a) => a.blocks));\n\t\tconst blocks = !complete\n\t\t\t? \"string\"\n\t\t\t: blockNames.size === 0\n\t\t\t\t? \"never\"\n\t\t\t\t: [...blockNames].map((block) => JSON.stringify(block)).join(\" | \");\n\n\t\tusesMarkup ||= context.includes(\"Markup\");\n\t\tusesNamed ||= context.includes(\"Named<\");\n\t\tconst templateKey = name.endsWith(TEMPLATE_EXTENSION)\n\t\t\t? name.slice(0, -TEMPLATE_EXTENSION.length)\n\t\t\t: name;\n\t\tentries.push(\n\t\t\t`\\t\\t${JSON.stringify(templateKey)}: {\\n\\t\\t\\tcontext: ${context};\\n\\t\\t\\tblocks: ${blocks};\\n\\t\\t};`,\n\t\t);\n\t}\n\n\treturn [\n\t\t\"// Generated by Kiln's generateTypes. Do not edit.\",\n\t\t...(usesMarkup ? ['import type { Markup } from \"@lucidkiln/core\";\\n'] : []),\n\t\t...(usesNamed\n\t\t\t? [\n\t\t\t\t\t\"type Named<Types, Name extends string> = Name extends keyof Types ? Types[Name] : unknown;\\n\",\n\t\t\t\t]\n\t\t\t: []),\n\t\t\"export interface Schema<Types extends object = object> {\",\n\t\t\"\\ttypes: Types;\",\n\t\tentries.length > 0\n\t\t\t? `\\ttemplates: {\\n${entries.join(\"\\n\")}\\n\\t};`\n\t\t\t: \"\\ttemplates: {};\",\n\t\t\"}\",\n\t\t\"\",\n\t].join(\"\\n\");\n};\n"],"mappings":";;;AAiDA,MAAMA,cAAY;;AAGlB,MAAa,mBAAmB,SAAmC;CAClE,QAAQ,KAAK,MAAb;EACC,KAAK,MACJ,OAAO,CACN,GAAG,KAAK,SAAS,KAAK,WAAW,OAAO,IAAI,GAC5C,KAAK,aAAa,CAAC,CACpB;EACD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AAC,MAAM,MAAM,CAAU,CAAC,CAC7E;;AAGA,MAAa,kBAAkB,IAAI,IAClC;CACC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC,CAAC,KAAK,SAAS,QAAQ,MAAM,CAC/B;;AAGA,MAAa,wBAAQ,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,iCAAiB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,2BAAW,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,0BAAU,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC;;AAG9C,MAAa,uBAAO,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAG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O,CAAC,OAAO;CACf,SAAS,CAAC,OAAO;CACjB,UAAU,CAAC,OAAO;CAClB,KAAK,CAAC,YAAY,OAAO;CACzB,SAAS,CAAC,SAAS;CACnB,QAAQ,CAAC,YAAY,UAAU;CAC/B,YAAY,CAAC,QAAQ;CACrB,QAAQ;EAAC;EAAW;EAAS;CAAO;CACpC,OAAO,CAAC,SAAS,OAAO;CACxB,IAAI,CAAC,MAAM;CACX,IAAI,CAAC,MAAM;AACZ;;AAGA,MAAa,cAAsC;CAClD,SAAS;CACT,QAAQ;AACT;;AAGA,MAAa,+BAAe,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;AAMD,MAAa,0BAAU,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAa,+BAAe,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;AC75BD,MAAa,cAAc;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAQA,MAAM,SAA6B;CAAC;CAAO;CAAW;AAAO;AAE7D,MAAM,eAAe,SACnB,YAAkC,SAAS,IAAI;AAEjD,MAAM,WAAW,UAChB,OAAO,SAAS,KAAK;AAEtB,MAAM,SAAS,UAA6D;CAC3E,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,QAAQ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