@verajs/renderer 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"vera-renderer-hydrate.min.js","sources":["../src/dev-values.ts","../src/renderer.ts","../src/hydrate.ts"],"sourcesContent":["/**\n * `__DEV__` only: the one home for *\"is this value something an attribute can carry?\"*\n *\n * **Why it is a closed vocabulary and not a predicate.** The first design asked whether a value\n * stringifies meaningfully — `String(v) === '[object Object]'` means it lost its data. Driven\n * through 16 value shapes rather than reasoned about, that broke four ways, and the first is\n * disqualifying: `String()` THROWS on `Object.create(null)`, on `{ toString: null }`, and on any\n * object whose `toString` throws — so a diagnostic would have killed the page for an author using\n * the recommended dictionary idiom. It also passed `[\"a\",\"b\"]` as `\"a,b\"` (one junk class, if that\n * was a `class` binding) and `new Date()` as a timezone-bearing string, which is an SSR/CSR\n * divergence manufactured out of correct-looking code. And it passed `Symbol('s')` while\n * `` `${sym}` `` throws — a guard and its sink disagreeing about a single expression.\n *\n * \"Does it stringify meaningfully\" is an OPEN predicate over an unbounded, environment-dependent\n * space, and open predicates cannot be audited. So the test is inverted and closed: **primitives\n * pass; everything else is reported; anything else that should pass is a named row added on\n * evidence.** The list has exactly one member so far.\n *\n * Credit where it is due: the four breaks were found by the omni engine's session, which drove the\n * shapes rather than arguing about them, and the closed-vocabulary form is theirs.\n */\n\n/**\n * Blessed non-primitives — types whose `toString` IS the value the author means.\n *\n * Tested by brand rather than `instanceof`, which is false across realms: a `URL` built in an\n * iframe is not `instanceof` the parent's `URL`, and a diagnostic that fires on a correct value in\n * one frame and not another is worse than none.\n */\nconst brand = (value: object) => Object.prototype.toString.call(value);\n\n/** One message per element+name+kind, so a value rebuilt every render does not flood the console. */\nlet reported: Set<string> | undefined;\n\n/**\n * Returns the complaint, or `null` when the value is fine. Never throws — the shapes that break a\n * naive guard are exactly the ones worth reporting, so they reach the `object` arm and are named.\n */\nexport const attributeValueComplaint = (tag: string, name: string, value: unknown): string | null => {\n const type = typeof value;\n if (type === 'string' || type === 'number' || type === 'boolean' || type === 'bigint') return null;\n if (type === 'object' && brand(value as object) === '[object URL]') return null;\n\n /**\n * Keyed by BRAND, not by `typeof` — `Date`, `Array` and a plain object are all `'object'`, so a\n * coarser key reported whichever arrived first and silently swallowed the rest. An author who\n * fixed the Date would never have been told about the array.\n */\n const key = `${tag}|${name}|${type === 'object' ? brand(value as object) : type}`;\n reported ??= new Set();\n if (reported.has(key)) return null;\n reported.add(key);\n\n /**\n * A function into an attribute is never what the author meant, but the REASON matters: on a\n * custom element the Lit-era convention is that complex values are set as properties, so\n * `<my-chart formatter={fn}>` is a coherent intention that this sink simply cannot express. The\n * message names the binding that can, rather than blaming the author.\n */\n const said = type === 'function'\n ? `a function, which becomes its own SOURCE TEXT`\n : type === 'symbol'\n ? `a symbol, which every DOM conversion refuses`\n : Array.isArray(value)\n ? `an array, which becomes its members joined by commas`\n : brand(value as object) === '[object Date]'\n ? `a Date, whose text carries the TIMEZONE of whichever side rendered it`\n : `an ${type}, which cannot survive as text`;\n\n /**\n * Returned WITHOUT the `[vera]` prefix, which each call site writes as a literal.\n * `tests/diagnostics-convention.test.mjs` reads the prefix off the call, so a message handed over\n * as a variable is invisible to it — and its answer to that is an allowance list. Taking the\n * allowance would have excused these two calls rather than checked them, which is the\n * reclassification this audit keeps refusing; the literal at the call site is what every other\n * diagnostic in the repo does anyway.\n */\n return (\n `renderer: the attribute \\`${name}\\` on <${tag}> was given ${said}. ` +\n `An attribute value is a string and nothing else.\\n` +\n `If the element is meant to RECEIVE this value, bind a property instead — \\`.${name}=\\${value}\\` ` +\n `— which is how a custom element takes anything that is not text. If it is meant to be read as ` +\n `text, convert it where you know what it means: \\`date.toISOString()\\`, \\`list.join(' ')\\`. ` +\n `A Date in particular serializes with the SERVER's timezone on one side and the browser's on ` +\n `the other, so it will not survive hydration.`\n );\n};\n","/**\n * @verajs/renderer — a ground-up, keyed, template-identity renderer.\n *\n * Replaces the Reef-derived renderer, which flattened every template to an HTML string and\n * re-parsed it on each change — O(whole template) work for a one-row edit, measured at 85 ms for a\n * two-row swap that lit-html does in 3.5 ms.\n *\n * The architecture here is the one that wins that benchmark:\n *\n * 1. A tagged template literal's `strings` array is frozen and IDENTICAL for every call from the\n * same call site, so it is a cache key for the template's static shape. The shape is parsed\n * ONCE into a `<template>` element with markers where the expressions go.\n * 2. Rendering clones that template and binds \"parts\" to the marker positions. Every later render\n * of the same shape only compares and commits the dynamic values — static content is never\n * touched again.\n * 3. Arrays reconcile KEYED (see `keyed()`), with head/tail fast paths and map-based moves, so a\n * reorder moves nodes instead of rebuilding them.\n *\n * Built in, where lit-html requires directive imports: keyed list reconciliation (`keyed`),\n * element refs (element-position expressions), toggled-DOM preservation (`hold`), and a\n * whole-range fast clear — one `textContent = ''` where lit removes thousands of nodes one at a\n * time. Like-for-like (lit-html + repeat + ref + cache: 5 021 B gzip), this file is ~28% smaller.\n *\n * What it deliberately does NOT have, which is why it is smaller than lit-html: no directive\n * protocol, no `noChange`/`nothing` sentinels (in a single-expression attribute, `null`/`undefined`\n * REMOVE the attribute; in a child, they clear it), no sanitizer indirection, no async parts, no\n * dev-mode branches.\n *\n * Known limits, deliberate and shared with lit-html's envelope: no bindings inside comments (the\n * value is consumed and ignored), no dynamic tag names, and nested `<template>` elements' contents\n * are not traversed.\n *\n * CONTRACTS THE SPEED PAYS FOR — these are the trade, documented rather than discovered:\n *\n * - **The renderer owns its container below the mount point.** The whole-range fast clear wipes\n * everything in a parent the part fully owns, including nodes user code appended there by hand\n * (lit-html would preserve them). Same contract as mounting Vue or React into a container.\n * - **Do not call `Node.normalize()` on rendered content.** Child anchors are text nodes, and\n * normalize merges adjacent text — lit-html's comment anchors are immune to this; ours are not.\n * - **A plain string renders as text, never as HTML.** The Reef renderer parsed strings as markup;\n * this one has no innerHTML sink at all (an XSS class removed). The deliberate escape hatch for\n * trusted markup is a property binding: `.innerHTML=${trusted}`.\n * - **Hydration is automatic and markerless.** The first render into a container that already has\n * children adopts them as server output of the same template (statics matched byte-for-byte,\n * anchors installed by splitting live text at known value positions), falling back to a clean\n * render on any mismatch. Requires the initial client render to match server state — same\n * contract as React/Vue hydration.\n * - **No directive protocol.** The template language itself is closed to extension — Vera extends\n * at the framework layer (inserts) and through element refs, not inside the renderer's value\n * handling.\n * - Event handlers are invoked with `this` bound to the ELEMENT (lit binds its host).\n *\n * NAMING NOTE: internal class fields and methods are `_`-prefixed because the production build\n * mangles properties matching /^_[a-z]/ (see defaultRollupConfig). That is what lets this file use\n * full descriptive names while still shipping one-letter properties — locals and top-level names\n * are mangled by default anyway, but property names are not. `_$litType$` and `handleEvent`\n * deliberately do not match the pattern: the first is an interop wire format, the second is called\n * by the DOM itself.\n */\n\nimport { attributeValueComplaint } from './dev-values.js';\n\nexport type TemplateResult = {\n /** 1 = html, 2 = svg, 3 = mathml — the markers core's built-in tags produce. */\n _$litType$?: number;\n strings: TemplateStringsArray;\n values: unknown[];\n /** Set by `keyed()`; drives keyed list reconciliation. */\n key?: unknown;\n};\n\n\n/**\n * Preserves the DOM of templates a child position toggles away from, instead of destroying it —\n * form values, scroll positions and media playback survive the round trip (lit-html calls this\n * `cache`). Stashed DOM is parked in its instance's own fragment and re-adopted on return.\n *\n * ```js\n * html`<div>${hold(editing ? editor() : viewer())}</div>`\n * ```\n *\n * **Anything that is not a template passes straight through.** There is nothing to park for a\n * string, a list, `null` or `false`, and the branch that produces one is the ordinary shape of the\n * expression this wraps — `hold(editing && editor())`, `hold(row ?? null)`. Wrapping those handed\n * the renderer a `{ $h }` carrying a non-template, which reached the held-commit path and threw on\n * `result.strings`: a whole render lost, from a value the same expression renders happily one\n * character to the left. Decided here rather than in the renderer so the hot path pays nothing.\n */\nexport const hold = <T>(result: T): T | { $h: TemplateResult } =>\n result != null && typeof result === 'object' && isTemplateResult(result)\n ? { $h: result as TemplateResult }\n : result;\n\n/**\n * Unique per module load, so user text can never collide with it. Randomness here cannot break\n * template caching — the marker only ever pairs a scan with its own Template construction.\n */\n// eslint-disable-next-line no-bitwise -- >>> 0 is the integer truncation, not arithmetic\nconst MARKER = '$v' + ((Math.random() * 1e9) >>> 0).toString(36) + '$';\n/** `<?xyz>` parses as a bogus comment whose data is `?xyz`. */\nconst MARKER_COMMENT_DATA = '?' + MARKER;\n\nconst doc = document;\nconst comment = (data = '') => doc.createComment(data);\n\n/**\n * One walker for every template construction, re-aimed by assigning `currentNode`. Traversal of a\n * detached fragment cannot escape it — ascent stops at a null parent — and no walk is ever\n * re-entered mid-flight: an inner instantiation only begins after the outer walk has finished\n * collecting its parts.\n */\nconst markerWalker = doc.createTreeWalker(doc, 129 /* ELEMENT | COMMENT */);\n/**\n * Second shared walker for indexing and instantiation. Templates ship with NO marker comments —\n * every child slot's anchor is its primed text node — so instances index over elements and texts.\n * Marker comments exist only transiently during template construction, and are created lazily at\n * runtime only if a slot upgrades from text to template/array content. Sharing the walker saves a\n * TreeWalker allocation per instance, which is 10 000 allocations in a 10 000-row create.\n */\nconst instanceWalker = doc.createTreeWalker(doc, 5 /* ELEMENT | TEXT */);\n\n/**\n * Elements whose children a parser reads as **text**, so a marker written inside one arrives as\n * characters rather than a comment and the binding never becomes a part.\n *\n * `iframe` and `noscript` were missing, and both were measured broken in a browser rather than\n * reasoned about: `html\\`<iframe>${v}</iframe>\\`` painted the literal marker — `<?$v8hpsho$>` — onto\n * the page in **all three engines** and never updated.\n *\n * **`noscript` is the one worth the comment, because the engines disagree.** A template's contents\n * are parsed with the scripting flag *disabled*, which is what decides whether `noscript` is raw\n * text — and Chromium and WebKit parse it as markup there while Firefox parses it as text. So\n * `html\\`<noscript>${v}</noscript>\\`` worked in two engines and painted the marker in the third: an\n * app developed in Chrome shipping the framework's internals onto the page for Firefox users.\n *\n * Listing it here is safe in both parses. Where the marker became a comment the raw-text branch does\n * not trigger, because it looks for the marker in `textContent` and finds none.\n */\nconst RAW_TEXT_TAGS = /^(?:script|style|textarea|title|iframe|noscript)$/i;\n\n/**\n * The void elements, as a regex rather than the `Set` in `@verajs/shared-utils`, and NOT imported\n * from it — measured: an imported `new Set([...])` survives production because neither rollup nor\n * terser can prove the constructor call is side-effect-free, so it sat at module scope costing\n * **62 B gzipped on the base bundle** for a diagnostic production does not even run. A regex\n * literal read only by `warnTagShape` goes when that dead function goes.\n *\n * So this is a second home for a fact `@verajs/shared-utils` owns, kept deliberately and in a\n * different SHAPE because a hot file's byte budget forbids the shared one. That is only acceptable\n * with an enforcer: `tests/markup-grammar-homes.test.mjs` drives this regex and the canonical set\n * against each other, member by member, in both directions.\n */\nconst VOID_TAGS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i;\nconst ATTR_NAME_DELIMITER = /[\\s\"'>=/]/;\n\n/** What an expression position turned out to be. */\nconst CHILD = 0;\nconst ATTRIBUTE = 1;\nconst IGNORED = 2; // value consumed, nothing rendered (bindings inside comments, junk positions)\n\n/**\n * `_tag` is `__DEV__` only and exists for one diagnostic: when the HTML parser DROPS the element a\n * binding was written on, the binding's marker never reaches the parsed tree, and the warning below\n * needs to name the element the author actually wrote rather than only the symptom.\n */\ntype Spec = ({ _type: 0 } | { _type: 1; _name: string } | { _type: 2 }) & { _tag?: string };\n\n/** Scanner states. */\nconst IN_TEXT = 0;\nconst IN_TAG = 1;\nconst IN_QUOTED_VALUE = 2; // a static quoted attribute value (no binding seen yet)\nconst IN_COMMENT = 3;\nconst IN_RAW_TEXT = 4; // inside <script>/<style>/<textarea>/<title>\nconst IN_BOUND_VALUE = 5; // collecting a bound attribute's statics\n\n/**\n * One pass over the template strings, producing parseable HTML with markers plus an ordered spec\n * list. Runs once per template shape, so clarity beats micro-optimisation here.\n *\n * A small state machine rather than tail regexes, because `>` inside quoted attribute values and\n * inside comments must not terminate a tag, and raw-text elements swallow markup.\n */\n/**\n * `__DEV__` only: the two ways a hand-written template describes a tree the parser will not build.\n *\n * `@verajs/jsx` normalises both at compile time, so this is the channel for the BUILDLESS path —\n * which is this framework's baseline, not its fallback, and was the surface left broken when the\n * compiler fix landed. It reaches the browser console on the client and during hydration; a\n * server-only render never runs this scanner, so an SSR page that is never hydrated is not covered.\n *\n * The self-close test is `markup` ending in `/`, which is the same approximation the raw-text\n * branch below already makes: an unquoted attribute value ending in a slash (`<div data-x=a/>`)\n * reads the same way. That is not a false positive in any way that matters — measured, such a tag\n * is an OPEN tag too and swallows what follows it exactly as `<div/>` does, so both the warning and\n * the fix it names are correct for it.\n */\nconst warnTagShape = (tag: string, closing: boolean, selfClosed: boolean) => {\n if (!closing && selfClosed && !VOID_TAGS.test(tag))\n console.warn(\n `[vera] renderer: <${tag}> is left OPEN by this template, so everything after it becomes its ` +\n `child rather than its sibling. HTML has no self-closing syntax outside <svg> and <math> — ` +\n `\\`<${tag} />\\` is an open tag, not an empty element. Write \\`<${tag}></${tag}>\\`. ` +\n `(@verajs/jsx rewrites this for you; a hand-written template has to say it.)`\n );\n else if (closing && VOID_TAGS.test(tag))\n console.warn(\n `[vera] renderer: \\`</${tag}>\\` is read by the parser as ANOTHER <${tag}>, so this template ` +\n `renders two where it describes one. A void element has no end tag — write \\`<${tag}>\\` alone.`\n );\n};\n\nconst scan = (strings: TemplateStringsArray, type = 1) => {\n const specs: Spec[] = [];\n let markup = '';\n let state = IN_TEXT;\n let quote = '';\n let quoteStart = 0; // markup index of the opening quote while IN_QUOTED_VALUE\n let rawTag = ''; // which raw-text element we are inside\n let tagNameStart = 0; // markup index where the current tag's name begins\n let isClosing = false;\n /**\n * `__DEV__` only. Depth of `<svg>`/`<math>` nesting, because foreign content is the one place the\n * parser DOES honour XML self-closing, so neither warning applies inside it. An `svg`/`mathml`\n * template is already inside one, hence the seed from `type`.\n *\n * `<foreignObject>` re-enters HTML content and is deliberately not tracked: suppressing a warning\n * there is a missed warning, while tracking it wrongly would be a wrong one, and a diagnostic\n * that cries wolf is worse than one that stays quiet.\n */\n let foreign = type === 1 ? 0 : 1;\n let attrName = '';\n let statics: string[] = [];\n let pending = ''; // the static chunk currently being collected IN_BOUND_VALUE\n\n /** Backscan an attribute name that ends at `end` (exclusive); '' when malformed. */\n const attrNameBefore = (end: number) => {\n let at = end;\n while (at > 0 && !ATTR_NAME_DELIMITER.test(markup[at - 1])) at--;\n return markup.slice(at, end);\n };\n\n for (let i = 0; i < strings.length; i++) {\n const segment = strings[i];\n let pos = 0;\n while (pos < segment.length) {\n const ch = segment[pos];\n if (state === IN_BOUND_VALUE) {\n if (\n ch === quote ||\n (quote === '' && (ch === ' ' || ch === '\\t' || ch === '\\n' || ch === '\\r' || ch === '>' || ch === '/'))\n ) {\n /**\n * The bound attribute closes. Emit a marker attribute whose VALUE carries the statics\n * joined by the marker — reading them back from the parsed attribute means entities\n * arrive decoded, exactly as a static attribute would.\n */\n statics.push(pending);\n const quoteChar = quote || '\"';\n markup += ` ${specs.length}${MARKER}=${quoteChar}${statics.join(MARKER)}${quoteChar}`;\n specs.push(\n __DEV__\n ? { _type: ATTRIBUTE, _name: attrName, _tag: markup.slice(tagNameStart).match(/^[a-zA-Z][^\\s/>]*/)?.[0] }\n : { _type: ATTRIBUTE, _name: attrName }\n );\n state = IN_TAG;\n if (quote !== '') pos++; // consume the closing quote; unquoted terminators reprocess IN_TAG\n continue;\n }\n pending += ch;\n pos++;\n } else if (state === IN_TEXT) {\n if (ch === '<') {\n if (segment.startsWith('!--', pos + 1)) {\n state = IN_COMMENT;\n markup += '<!--';\n pos += 4;\n continue;\n }\n isClosing = segment[pos + 1] === '/';\n tagNameStart = markup.length + (isClosing ? 2 : 1);\n state = IN_TAG;\n }\n markup += ch;\n pos++;\n } else if (state === IN_TAG) {\n if (ch === '\"' || ch === \"'\") {\n quote = ch;\n quoteStart = markup.length;\n state = IN_QUOTED_VALUE;\n } else if (ch === '>') {\n const tagName = markup.slice(tagNameStart).match(/^[a-zA-Z][^\\s/>]*/)?.[0] ?? '';\n if (__DEV__) {\n const lower = tagName.toLowerCase();\n const selfClosed = markup.endsWith('/');\n if (lower === 'svg' || lower === 'math') foreign += isClosing ? -1 : selfClosed ? 0 : 1;\n else if (foreign < 1) warnTagShape(tagName, isClosing, selfClosed);\n }\n if (!isClosing && RAW_TEXT_TAGS.test(tagName) && !markup.endsWith('/')) {\n rawTag = tagName.toLowerCase();\n state = IN_RAW_TEXT;\n } else {\n state = IN_TEXT;\n }\n }\n markup += ch;\n pos++;\n } else if (state === IN_QUOTED_VALUE) {\n if (ch === quote) state = IN_TAG;\n markup += ch;\n pos++;\n } else if (state === IN_COMMENT) {\n if (ch === '-' && segment.startsWith('->', pos + 1)) {\n markup += '-->';\n pos += 3;\n state = IN_TEXT;\n continue;\n }\n markup += ch;\n pos++;\n } else {\n // IN_RAW_TEXT\n if (\n ch === '<' &&\n segment.slice(pos + 1, pos + 2 + rawTag.length).toLowerCase() === '/' + rawTag &&\n (pos + 2 + rawTag.length >= segment.length || /[\\s/>]/.test(segment[pos + 2 + rawTag.length]))\n ) {\n isClosing = true;\n tagNameStart = markup.length + 2;\n state = IN_TAG;\n }\n markup += ch;\n pos++;\n }\n }\n\n // ── expression boundary ──────────────────────────────────────────────────\n if (i === strings.length - 1) break;\n if (state === IN_TEXT) {\n markup += `<?${MARKER}>`;\n specs.push({ _type: CHILD });\n } else if (state === IN_RAW_TEXT) {\n markup += MARKER; // a text marker; comments cannot be parsed inside raw-text elements\n specs.push({ _type: CHILD });\n } else if (state === IN_COMMENT) {\n specs.push({ _type: IGNORED }); // binding inside a comment: consumed, ignored\n } else if (state === IN_BOUND_VALUE) {\n statics.push(pending); // this attribute spans another expression\n pending = '';\n } else if (state === IN_QUOTED_VALUE) {\n // expression inside a quoted attribute value -> becomes a bound attribute\n const name = markup[quoteStart - 1] === '=' ? attrNameBefore(quoteStart - 1) : '';\n if (name) {\n attrName = name;\n statics = [markup.slice(quoteStart + 1)]; // the static prefix already inside the quotes\n pending = '';\n markup = markup.slice(0, quoteStart - 1 - name.length); // cut `name=\"` back out\n state = IN_BOUND_VALUE;\n } else {\n specs.push({ _type: IGNORED });\n }\n } else {\n // IN_TAG: `name=${x}` unquoted, or an element-position expression\n const name = markup.endsWith('=') ? attrNameBefore(markup.length - 1) : '';\n if (name) {\n attrName = name;\n statics = [''];\n pending = '';\n quote = '';\n markup = markup.slice(0, markup.length - 1 - name.length);\n state = IN_BOUND_VALUE;\n } else {\n /**\n * Element-position expression — an element REF, not a no-op. Marked exactly like a bound\n * attribute ('&' cannot begin a real attribute binding), so no new machinery exists for it.\n */\n if (__DEV__ && (markup.endsWith('<') || markup.endsWith('</'))) {\n /**\n * Except in **tag position**, where it is a mistake with no useful reading. `<${name}>`\n * lands here because the tag has no name yet, and what the parser then makes of a ref on\n * a nameless element is escaped punctuation. Naming the entry that does support it is\n * more use than an element ref nobody asked for.\n */\n console.error(\n `[vera] an expression in tag position (\\`<\\${…}>\\`) is not a dynamic tag name — the ` +\n `template has no element there and the markup around it is rendered as text.\\n` +\n `Runtime tag names live in @verajs/renderer/tag:\\n\\n` +\n ` import { html, tag } from '@verajs/renderer/tag';\\n` +\n ` const heading = tag\\`h1\\`;\\n` +\n ` html\\`<\\${heading}>…</\\${heading}>\\`\\n`\n );\n }\n /**\n * **And in attribute-*name* position, which is the same mistake one step along.**\n *\n * `<b ${name}=\"x\">`, `<b data-${name}=\"1\">` and `<b a${name}b=\"1\">` all land here: the\n * marker is not preceded by `=`, so it reads as an element ref, and the `=\"x\"` after it\n * stays literal markup. The browser's parser then makes `<b =\"x\"=\"\">` of it — attributes\n * nobody wrote, silently.\n *\n * **The server already refuses this**, and said so in its README while the client shipped\n * the garbage. A developer rendering only in a browser saw malformed output with no clue,\n * and adding SSR later turned it into a throw with no obvious connection.\n *\n * Told apart from a real element ref by what follows it: a ref is always followed by\n * whitespace, `>` or `/`. Anything else means the marker landed inside a name.\n */\n const after = strings[i + 1] ?? '';\n if (__DEV__ && after !== '' && !/^[\\s>/]/.test(after)) {\n console.error(\n `[vera] an expression in attribute-name position (\\`<b \\${…}=\"x\">\\`) is not a dynamic ` +\n `attribute name — a marker is not a name, and the parser makes attributes nobody ` +\n `wrote out of what follows it.\\n` +\n `Runtime-named bindings live in @verajs/renderer/spread:\\n\\n` +\n ` import { spread } from '@verajs/renderer/spread';\\n` +\n ` html\\`<b \\${spread({ [name]: 'x' })}>…</b>\\`\\n`\n );\n }\n markup += ` ${specs.length}${MARKER}=\"${MARKER}\"`;\n specs.push({ _type: ATTRIBUTE, _name: '&' });\n }\n }\n }\n return { markup, specs };\n};\n\n/** A part's position and shape inside a Template, resolved to a node index for instantiation. */\ntype TemplatePart = {\n _type: 0 | 1 | 2;\n _index: number;\n _name?: string;\n _statics?: string[];\n /** Whether the template statically writes an attribute of the same name — see `AttrPart._commit`. */\n _present?: boolean;\n _node?: Node; // only during construction, carrying identity between the two passes\n};\n\n/**\n * THE LIGHT-SLOTS SEAM. `@verajs/renderer/slots` registers one of these through core's `wire` on\n * the `'slot'` insert point; the renderer reads it from the registry `connect` was handed — the\n * app's single registry, so a CDN page loading separate bundles still meets ONE seam (the same\n * architecture the `'value'` point rides). All member names are `$`-sigiled: the mangle regex\n * cannot match them, so the contract survives production across bundle boundaries (the child-\n * applier precedent). An app that never wires it pays one registry lookup per template\n * CONSTRUCTION (once per shape) and nothing per render.\n */\n/** The state a taken-over slot hands back; `_$park$` (sigiled, mangle-safe) is called before the\n * instance's DOM is bulk-discarded so the USER'S nodes are rescued first. */\nexport type SlotSeamState = { _$park$?: () => void };\n/** The registered `'slot'` insert is a plain function per wire's contract: take over one cloned\n * `<slot>` for the given root, or decline with null/undefined (native slotting proceeds). */\ntype SlotSeamFn = (slot: Element, root: Node, name: string) => SlotSeamState | null | undefined;\n/**\n * The seam function plus the members it carries for callers that are not committing a slot —\n * sigil-named, so they survive property mangling across bundle boundaries (the child-applier\n * precedent). `_$capture$` lifts a light host's children on its first render; `_$rescue$` puts\n * them back when hydration has to discard the server's markup; `_$server$`/`_$adopt$` belong to\n * SSR and the hydrate entry and are reached off the same object.\n */\ntype SlotSeam = SlotSeamFn & {\n _$capture$?: (host: Element, boundary?: Comment) => void;\n _$rescue$?: (host: Element) => Node[] | null;\n /** A captured node's host-side anchor (the light-region sentinel) — see the upgrade below. */\n _$home$?: (node: Node) => Comment | null;\n};\n/**\n * A recorded `<slot>` position — just its node index in the instance walk. Slot records live\n * BESIDE the parts array, not in it, so `_update` never iterates them and non-slot apps pay\n * nothing per render.\n *\n * The NAME is deliberately not recorded. It used to be, read off the template's static markup,\n * which made `<slot name=${…}>` a slot with no name at all: it registered as a second DEFAULT\n * slot and stole the default content while the real default slot showed its fallback. The name is\n * read from the element at mount instead, which is after its own bindings have committed.\n */\ntype SlotRecord = number;\n\n/**\n * The container of the renderInto call currently committing — how a slot part learns its root\n * (light element vs shadow root) at Instance construction. Commits are synchronous per flush, so\n * one module slot suffices (the `currentInstance` pattern); null outside renderInto (hydration's\n * adoption path constructs elsewhere and the seam stays inert there until it learns adoption).\n */\nlet _slotRoot: Node | null = null;\n\n/** See the slotless branch in `Instance`. Once per host tag, so a list cannot flood a console. */\nconst warnedSlotless = new Set<string>();\nconst warnSlotless = (root: Element) => {\n const tag = root.localName;\n if (warnedSlotless.has(tag)) return;\n warnedSlotless.add(tag);\n console.warn(\n `[vera] renderer: <${tag}> renders a \\`<slot>\\` into LIGHT DOM, but no 'slot' insert is wired — ` +\n `nothing can fill it, so it always shows its fallback, and any content the host is given for ` +\n `it sits beside the component as stray markup instead. Wire it at the app entry, BEFORE anything renders: ` +\n `\\`import { slots } from '@verajs/renderer/slots'; wire([renderer, slots])\\`. Wiring it later ` +\n `does not help a template that has already rendered — a template resolves this once, at ` +\n `construction, and is interned per call site for the life of the page.`\n );\n};\n\n/**\n * `__DEV__` only: the HTML parser dropped an element a binding was written on.\n *\n * Named where it is discovered rather than after the walk, because the SKIP knows exactly which\n * spec went missing — `specs[from]` is the casualty by construction. A post-hoc count can only\n * report the LAST unclaimed spec, which positional pairing makes the wrong element every time, and\n * pointing an author at a tag that rendered correctly is the precise failure this message exists\n * to cure.\n */\n/**\n * **A child binding directly inside `<table>` renders one shape and PARSES as another.**\n *\n * `<table>${rows}</table>` is conforming HTML — `<tbody>` is omissible — and it is the one place a\n * legal template does not survive a round trip through the platform:\n *\n * - CLIENT RENDER inserts the rows with DOM calls, which apply no parser rules: `table > tr`.\n * - The SAME markup PARSED — a server render the browser re-parses, `innerHTML`, a static file —\n * gets the implied section: `table > tbody > tr`.\n *\n * Measured, both shapes, same template. So a stylesheet written `table > tr` matches on one path\n * and not the other, and hydration discards the server's markup for that container and rebuilds it\n * (*\"expected `<tr>` and found `<tbody>`\"*) — silently in production, where this call is folded away.\n *\n * **Why this is a warning and not a repair.** Whatever is emitted, the browser re-parses it, and the\n * parser ALWAYS inserts the section — so the only shape all three paths agree on is one where the\n * section is already in the template. The framework could insert it, but that changes the DOM shape\n * of every existing client-rendered table, across the renderer AND `@verajs/ssr`'s serializer, and\n * rests on the SSR shim agreeing with browsers about implied tags. One word from the author reaches\n * the same fixed point with none of that. Owner's call, recorded rather than assumed.\n *\n * Scoped to `<table>` deliberately: `<tbody>` (from rows) and `<colgroup>` (from `<col>`) are the\n * only implied START tags reachable inside a template fragment, and both are children of `<table>`.\n * The omissible END tags — `</li>`, `</p>`, `</td>`, `</option>` and the rest — insert nothing, so\n * they round-trip correctly and are pinned doing so in `tests/dropped-element-bindings.test.mjs`.\n */\nconst warnImplicitSection = (parent: Element | null) => {\n if (parent?.localName !== 'table') return;\n console.warn(\n '[vera] renderer: a binding sits directly inside <table>, where the HTML parser inserts a ' +\n '<tbody> that a client render does not. The same template then renders as `table > tr` and ' +\n 'parses as `table > tbody > tr`, so `table > tr` selectors match on only one path and ' +\n 'hydration rebuilds this container instead of adopting it. Write the section explicitly — ' +\n '`<table><tbody>${rows}</tbody></table>` — and every path agrees.'\n );\n};\n\nconst warnDroppedBinding = (specs: Spec[], from: number, count: number) => {\n const lost = specs[from];\n const where = lost?._tag\n ? `\\`${lost._type === ATTRIBUTE ? `${lost._name}=` : ''}\\` on <${lost._tag}>`\n : 'a binding';\n console.warn(\n `[vera] renderer: ${where} never reached the parsed tree — the HTML parser DROPPED the element ` +\n `it was written on, because its parent's content model forbids it (\\`<select>\\` takes only ` +\n `options, \\`<form>\\` cannot nest, and so on).\\n` +\n `${count} binding(s) lost. The element is gone from the DOM and its binding does nothing; ` +\n `the bindings AFTER it are unaffected, because each marker carries its own index. ` +\n `(Before that they all shifted onto the wrong elements, which is why this kind of mistake ` +\n `used to surface somewhere you had not edited.)\\n` +\n `Move the element out of its parent, or use one the parent can hold.`\n );\n};\n\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\nclass Template {\n _element: HTMLTemplateElement;\n _parts: TemplatePart[] = [];\n /**\n * Present only when a 'slot' insert was wired at construction and the markup contains slots.\n *\n * `declare`, like the two below: under ES2022 class-field semantics a plain optional field is\n * DEFINED on every instance whether or not it is ever assigned, so a CONDITIONALLY assigned one\n * is weight every template pays for a case most of them do not have.\n *\n * Deliberately not applied to the fields the constructors always assign (`_element`, `_name`,\n * `_statics`, `_start`, `_end`, and the rest). Those need to exist, the saving is the same few\n * bytes, and they sit on the hot classes where changing when a property first appears can move\n * V8's hidden class — which is a measurement, not a tidy-up. If anyone takes that on, measure\n * update throughput before and after, three runs, the way the slot-mount deferral was.\n */\n declare _slots?: SlotRecord[];\n declare _seam?: SlotSeamFn;\n /** `__DEV__` only: this markup has `<slot>` and was built with no seam to hand them to.\n * `declare`, so nothing is emitted — a plain optional field is DEFINED on every instance under\n * ES2022 class-field semantics, which is production weight for a development-only check. */\n declare _slotless?: boolean;\n\n constructor(result: TemplateResult) {\n const type = result._$litType$ ?? 1;\n const { markup, specs } = scan(result.strings, type);\n this._element = doc.createElement('template');\n /** svg/mathml fragments only parse inside their root; wrap, then unwrap below. */\n this._element.innerHTML = type === 2 ? `<svg>${markup}</svg>` : type === 3 ? `<math>${markup}</math>` : markup;\n const content = this._element.content;\n if (type !== 1) {\n const wrapper = content.firstChild!;\n while (wrapper.firstChild) content.insertBefore(wrapper.firstChild, wrapper);\n content.removeChild(wrapper);\n }\n\n /**\n * Pass 1 — DISCOVER over ELEMENT | COMMENT: pair scan specs with parsed nodes in document\n * order (which is expression order), and swap every marker comment for a primed empty text\n * node. The shipped template then contains no comments at all: each clone is three nodes\n * lighter per typical row, and the primed text doubles as both anchor and first-commit target.\n */\n markerWalker.currentNode = content;\n let specIndex = 0;\n let node: Node | null;\n const parts = this._parts;\n const consumeIgnored = () => {\n while (specIndex < specs.length && specs[specIndex]._type === IGNORED) {\n parts.push({ _type: IGNORED, _index: -1 });\n specIndex++;\n }\n };\n consumeIgnored();\n while (specIndex < specs.length && (node = markerWalker.nextNode()) !== null) {\n if (node.nodeType === 1) {\n const element = node as Element;\n if (element.hasAttributes()) {\n for (const attributeName of element.getAttributeNames()) {\n if (attributeName.endsWith(MARKER)) {\n /**\n * **Each marker carries its own spec index in its NAME**, so pairing is addressed\n * rather than positional — and a marker that never arrived is visible the moment the\n * next one does. Both halves matter and neither works alone:\n *\n * - REPAIR: an element the parser drops takes its marker with it. Paired by walk\n * order, that shifted every later binding onto the wrong element, silently —\n * `html\\`<select><div title=${'${a}'}>x</div></select><b title=${'${b}'}>\\`` rendered\n * `<b title=\"a\">`. Consuming the gap keeps every surviving binding on its own\n * element; only the dropped one is lost.\n * - REPORT: the repair would otherwise SILENCE the problem, which is a correct\n * refusal with nothing to tell the author — so the skip is where the warning lives.\n */\n const declared = parseInt(attributeName, 10);\n if (declared > specIndex) {\n if (__DEV__) warnDroppedBinding(specs, specIndex, declared - specIndex);\n do parts.push({ _type: IGNORED, _index: -1 });\n while (++specIndex < declared);\n }\n /**\n * The marker attribute's value carries the statics; the REAL (case-preserved) name\n * comes from the spec — the HTML parser lowercases attribute names, which would\n * corrupt `.someProp`.\n */\n const spec = specs[specIndex++] as { _type: 1; _name: string };\n parts.push({\n _type: ATTRIBUTE,\n _index: -1,\n _name: spec._name,\n _statics: element.getAttribute(attributeName)!.split(MARKER),\n /**\n * Computed here — once per template, ever — so the first commit of a nullish\n * binding knows whether a fresh clone even carries the attribute. It usually does\n * not, and the unconditional removal this feeds cost a real DOM call per element\n * per create: 1,000 no-op `removeAttribute`s on the 1,000-row benchmark. The one\n * case that must still remove — `<b title=\"a\" title=${null}>`, where the parser\n * keeps the first duplicate — is exactly what this reads.\n */\n _present: element.hasAttribute(spec._name),\n _node: element,\n });\n element.removeAttribute(attributeName);\n consumeIgnored();\n }\n }\n }\n if (RAW_TEXT_TAGS.test(element.tagName) && element.textContent!.includes(MARKER)) {\n /**\n * Comments cannot be PARSED inside raw-text elements, but they are legal DOM once\n * created — so the scan left text markers, and here they become real marker comments.\n * The walker visits them next and they pair as ordinary child parts.\n */\n const pieces = element.textContent!.split(MARKER);\n element.textContent = '';\n for (let p = 0; p < pieces.length - 1; p++) {\n if (pieces[p]) element.append(pieces[p]);\n element.append(comment(MARKER_COMMENT_DATA));\n }\n if (pieces[pieces.length - 1]) element.append(pieces[pieces.length - 1]);\n }\n } else if ((node as Comment).data === MARKER_COMMENT_DATA) {\n specIndex++;\n const primedText = doc.createTextNode('');\n node.parentNode!.insertBefore(primedText, node);\n /** Re-aim the walker before removing the node it stands on. */\n markerWalker.currentNode = primedText;\n (node as Comment).remove();\n if (__DEV__) warnImplicitSection(primedText.parentNode as Element | null);\n parts.push({ _type: CHILD, _index: -1, _node: primedText });\n consumeIgnored();\n }\n }\n\n /**\n * **CONSERVATION OF MARKERS — the walk must claim every spec the scan emitted.**\n *\n * The loop above pairs specs with markers in document order. If the HTML parser DROPPED the\n * element a binding was written on, that marker never exists, the loop runs out of nodes early,\n * and `specIndex` stops short — and because pairing is POSITIONAL, every binding after the\n * missing one has already been handed the value of its predecessor. Measured:\n *\n * html`<select><div title=${a}>x</div></select><b title=${b}>after</b>`\n *\n * renders `<b title=\"a\">` — the value written for the `<div>`, on an unrelated element, with\n * no error anywhere. `<form>` inside `<form>` does the same. HTML's parser drops elements its\n * content model forbids, which is correct of it and invisible to everything else here.\n *\n * **This is deliberately not a content-model check.** A table of what may contain what is a\n * closed vocabulary over an open space: it catches what somebody enumerated, needs maintenance\n * as HTML evolves, and would cover the compiler only — while this counts what actually\n * happened, in JSX and hand-written templates alike, for every dropping context including the\n * ones nobody listed. The cost of knowing is one integer comparison the construction already\n * had lying around.\n *\n * The gap it cannot close, named rather than implied: a dropped element carrying NO bindings\n * loses nothing to count. That is harmless to the renderer — nothing shifts — and it is the\n * restructuring class, which `tests/jsx-tree-parity.test.mjs` records instead.\n */\n if (__DEV__ && specIndex < specs.length) {\n /** A casualty at the very END has no later marker to reveal it, so the tail is checked too. */\n warnDroppedBinding(specs, specIndex, specs.length - specIndex);\n }\n\n /** Pass 2 — INDEX over ELEMENT | TEXT, the mask instances walk with. */\n instanceWalker.currentNode = content;\n let nodeIndex = -1;\n let partIndex = 0;\n while (partIndex < parts.length && parts[partIndex]._type === IGNORED) partIndex++;\n while (partIndex < parts.length && (node = instanceWalker.nextNode()) !== null) {\n nodeIndex++;\n while (partIndex < parts.length && parts[partIndex]._node === node) {\n parts[partIndex]._index = nodeIndex;\n partIndex++;\n while (partIndex < parts.length && parts[partIndex]._type === IGNORED) partIndex++;\n }\n }\n for (const part of parts) part._node = undefined;\n\n /**\n * THE SLOT WALK — the whole template-side seam, and it runs only when a 'slot' insert is\n * wired at construction. One dedicated pass discovers `<slot>` elements AND indexes them in\n * the same ELEMENT|TEXT numbering the instance walk uses (Text has no localName, so no\n * nodeType check is needed). Passes 1 and 2 above are byte-identical to their pre-seam\n * selves: an unwired app's construction path is untouched, and its only cost is this one\n * registry lookup per template construction.\n *\n * **Resolved per TEMPLATE, and templates are cached per call site for the life of the page** —\n * so a shape first constructed before `wire([slots])` ran never gains slot support, silently.\n * That is the ordinary insert contract (wire at the app entry, beside the renderer, before\n * anything renders) and it is stated in the slots module's own docs; resolving per INSTANCE\n * instead would move a registry lookup onto the hot path for every app, which is the trade\n * this design refuses.\n */\n const seam = slotSeam();\n /**\n * **Dev-only: remember that this markup HAS slots even when nothing can distribute them.**\n * Without it the two ways of getting the wiring wrong are indistinguishable from a component\n * that simply has no slots — see the warning at the instance's slot mount.\n */\n if (__DEV__ && seam === undefined && markup.includes('<slot')) this._slotless = true;\n if (seam !== undefined) {\n instanceWalker.currentNode = content;\n let index = -1;\n while ((node = instanceWalker.nextNode()) !== null) {\n index++;\n if ((node as Element).localName === 'slot') {\n this._seam = seam;\n (this._slots ??= []).push(index);\n }\n }\n }\n }\n}\n\nconst getTemplate = (result: TemplateResult) => {\n let template = templateCache.get(result.strings);\n if (template === undefined) templateCache.set(result.strings, (template = new Template(result)));\n return template;\n};\n\n/** Anything bound to a live position: commits values[index..], returns the next value index. */\ninterface Part {\n _commit(values: unknown[], index: number): number;\n}\n\nconst IGNORED_PART: Part = { _commit: (_values, index) => index + 1 };\n\n/** Never equal to any user value, so the first commit always runs. */\nconst UNSET = {};\n\n\n/** A fresh markered part: two comments inserted before `ref` in `parent`. */\nconst createMarkeredPart = (parent: Node, ref: Node | null) => {\n const start = comment();\n const end = comment();\n parent.insertBefore(start, ref);\n parent.insertBefore(end, ref);\n return new ChildPart(start, end);\n};\n\n/**\n * Text for an attribute built from several expressions.\n *\n * `` `${value}` `` rather than `String(value)`, and the difference is exactly one case. Both are\n * ToString with hint `'string'` for everything else; `String` alone special-cases a **symbol** and\n * returns its description instead of throwing. Every single-expression binding assigns straight to\n * the DOM and gets WebIDL's `DOMString` conversion, which throws on one — so `title=${symbol}` threw\n * and `title=\"a ${symbol} b\"` quietly rendered `a Symbol(s) b`. The same sigil on the same attribute,\n * disagreeing with itself depending on whether static text sat beside it.\n */\nconst toText = (value: unknown) => (value == null ? '' : `${value}`);\n\n/** Binding kinds, resolved once from the attribute name's first character. */\nconst ATTR = 0; // plain attribute\nconst PROPERTY = 1; // .name\nconst BOOLEAN = 2; // ?name\n/**\n * `!name` — a property written from the *live* DOM rather than from what this binding last wrote.\n *\n * Numbered below `EVENT` deliberately: `kind >= EVENT` is what decides a value is passed raw rather\n * than joined from the statics, and a live binding is a property, so `!title=\"a${x}b\"` has to join\n * like every other one.\n */\nconst LIVE = 3;\nconst EVENT = 4; // @name\n/** A binding that must never write — see the `__proto__` refusal in the constructor. */\nconst REFUSED = -1;\n/**\n * Calls an element ref, and survives one that throws.\n *\n * A ref runs in the middle of committing a template's parts, so an unguarded throw left the commit\n * half applied and unwound the render that triggered it — the component's shadow root ended up\n * **empty and stayed that way**, and every later update threw at the same line. The error was\n * reported, so the only symptom was a component that had silently stopped existing.\n *\n * The same judgement `handleEvent` makes a few lines up: a mistake in code the template was handed\n * is named, not raised from inside the framework at a point where the value's origin is long gone.\n * The prefix goes on our own sentence and the error is passed alongside, so it stays filterable\n * without misattributing someone else's `Error`.\n */\nconst applyRef = (callback: (el: Element | null) => void, element: Element | null) => {\n try {\n callback(element);\n } catch (error) {\n /** The sentence is development's; production keeps the prefix and the error carries the rest. */\n if (__DEV__) console.error('[vera] an element ref threw; the render continued without it.', error);\n else console.error('[vera] ref threw', error);\n }\n};\n\nconst REF = 5; // element-position expression\n\nclass AttrPart implements Part {\n _element: Element;\n _name: string;\n _statics: string[];\n _slots: number; // how many expression values this binding consumes\n _kind: number;\n _isFullValue: boolean; // exactly one expression with no static text around it\n _committed: unknown = UNSET;\n _handler: EventListener | null = null;\n /** `<select>.value`, which cannot be applied where it is written — see `pendingSelects`. */\n _select = false;\n /** The template statically wrote this attribute, so a first nullish commit must still remove. */\n _present: boolean;\n\n constructor(element: Element, name: string, statics: string[], present = false) {\n const first = name[0];\n let kind =\n first === '.'\n ? PROPERTY\n : first === '?'\n ? BOOLEAN\n : first === '@'\n ? EVENT\n : first === '&'\n ? REF\n : first === '!'\n ? LIVE\n : ATTR;\n let realName = kind ? name.slice(1) : name;\n /**\n * **`__proto__` is not a property write, so no property binding may make one.**\n *\n * `element.__proto__ = value` hits `Object.prototype`'s `__proto__` ACCESSOR and replaces the\n * element's prototype, stripping every DOM method it has. `.__proto__=${x}` crashed out of the\n * commit with an unreadable internal error; `!__proto__=${x}` bricked the element silently and\n * the wreckage surfaced in a LATER render, naming the renderer rather than the binding. There\n * is no legitimate use, so unlike `.innerHTML` there is no spelling to point at — the binding\n * is refused and never writes.\n *\n * **The deliberate twin of `refusedSink` in `./spread.ts`**, which refuses the same name for\n * the same reason. The two entries are independent bundles and neither imports the other, so\n * the rule is copied on purpose (the repo's standing note: sigil rules live in both AttrPart\n * and spread, and a fix has to visit every copy). `tests/dangerous-binding-matrix.test.mjs`\n * fails if one of them starts refusing something the other allows.\n */\n if ((kind === PROPERTY || kind === LIVE) && realName === '__proto__') {\n kind = REFUSED;\n if (__DEV__)\n console.warn(\n `[vera] <${element.localName}> binds \\`${name}\\`, which would replace the element's own ` +\n `prototype and destroy it — no property write does this, and no use of it is legitimate. ` +\n `The binding is ignored.`\n );\n }\n /**\n * React muscle-memory, buildless: `onClick=${fn}` ≡ `@click=${fn}`. Strictly `on` + a capital —\n * all-lowercase `onclick` stays a plain attribute (legal inline-handler HTML).\n *\n * `@verajs/renderer/spread` repeats these rules rather than importing them. Sharing them through\n * `@verajs/shared-utils` was tried and reverted: the shared form has to return both the kind and\n * the name, and the tuple it allocates cost this bundle 10 B. Principle #5 allows deliberate\n * duplication where two things can legitimately diverge; here #7 decides it — weight is the\n * product, and core and the renderer are the two packages where that is absolute.\n */\n if (kind === ATTR && first === 'o' && name.charCodeAt(1) === 110 && name.charCodeAt(2) > 64 && name.charCodeAt(2) < 91) {\n kind = EVENT;\n realName = name.slice(2).toLowerCase();\n }\n this._kind = kind;\n this._name = realName;\n this._element = element;\n this._statics = statics;\n this._slots = statics.length - 1;\n this._isFullValue = this._slots === 1 && statics[0] === '' && statics[1] === '';\n /** Resolved once, here, so the commit path costs one boolean rather than two comparisons. */\n this._select = kind === PROPERTY && realName === 'value' && element.localName === 'select';\n this._present = present;\n }\n\n /**\n * Releases an element ref, because the element it named is going away.\n *\n * A ref was told about attachment and never about detachment, so it kept a detached node alive and\n * a component reading `myRef.value` after a subtree was replaced got the old element back. Lit\n * passes `undefined` for the same reason.\n *\n * `null` rather than `undefined`, because `.value` is a store property and `null` reads as\n * \"deliberately nothing\" where `undefined` reads as \"never set\".\n *\n * **Reached when a subtree is rendered away, and deliberately not when a component is removed\n * from the document.** The two are the same event to a reader and not to this renderer: a\n * disconnect here is not a destruction, since moving a node between parents fires one and the\n * component renders again on reconnect. Releasing there would blank every ref for the frame a\n * move takes, and `_committed = UNSET` below means the re-apply could only happen on the next\n * pass. Measured in `tests/renderer-ref-lifetime.test.mjs`, which asserts both halves so the\n * asymmetry is a decision rather than something nobody looked at.\n *\n * A **self-applying** value is\n * skipped: `_$apply$` receives the part and owns its own lifecycle, so telling it about detachment\n * here would be a second protocol contradicting the first.\n */\n _release() {\n const value = this._committed;\n if (typeof value === 'function') applyRef(value as (el: Element | null) => void, null);\n else if (value !== null && typeof value === 'object' && (value as { _$apply$?: unknown })._$apply$ === undefined)\n (value as { value: unknown }).value = null;\n this._committed = UNSET;\n }\n\n /**\n * Stable listener; swapping one function for another never touches the DOM.\n *\n * **It is not registered exactly once, and the difference is load-bearing.** A handler set back to\n * `undefined` or `false` nulls `_handler` *without removing the listener* — inert, because\n * `handleEvent` finds nothing callable — so the next non-null value sees `_handler === null` and\n * calls `addEventListener` again. Measured: `function -> undefined -> function` registers twice.\n *\n * That is harmless only because the listener passed is **`this`, the part object itself**. The\n * platform ignores a repeated `(type, listener, capture)` triple, verified with no framework\n * involved — the same listener object added three times fires once. Pass a fresh closure here\n * instead and dedup stops applying: every toggle through null adds another live listener, silently,\n * and only in components that turn a handler off and on again.\n *\n * `tests/event-binding-fuzz.test.mjs` holds that as an invariant — it counts *fires*, not\n * `addEventListener` calls, and making this listener a closure fails it.\n *\n * **Two shapes, because `addEventListener` takes two.** A function is called with the element as\n * `this`; an object with a `handleEvent` method is invoked through it — the platform's own\n * `EventListenerObject` protocol, which every engine accepts and lit supports. This used to call\n * `.call()` unconditionally, so passing the platform's own listener shape bound successfully and\n * then threw `this._handler.call is not a function` on **every** dispatch.\n *\n * Anything else is inert rather than throwing. A truthy non-function is a mistake, and\n * development names it at the binding (see the `EVENT` branch in `_commit`) — where the mistake\n * still is. Throwing here instead would raise from inside the framework on every user click, at a\n * point where the value's origin is long gone.\n */\n handleEvent(event: Event) {\n const handler = this._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(this._element as never, event);\n else if (typeof (handler as EventListenerObject)?.handleEvent === 'function')\n (handler as EventListenerObject).handleEvent(event);\n }\n\n /**\n * `adopting` is set only by `@verajs/renderer/hydrate`, and only changes what happens to the\n * three form-value properties the server can express in markup — see the branch below.\n */\n _commit(values: unknown[], index: number, adopting?: boolean): number {\n const kind = this._kind;\n /** Refused in the constructor and never writes — it still has to consume its slots. */\n if (kind === REFUSED) return index + this._slots;\n let value: unknown;\n if (this._isFullValue || kind >= EVENT) {\n value = values[index]; // raw and uncoerced — events and refs receive the actual value\n } else {\n const statics = this._statics;\n let joined = statics[0];\n for (let i = 0; i < this._slots; i++) joined += toText(values[index + i]) + statics[i + 1];\n value = joined;\n }\n /**\n * **A live property asks the element, not its own memory.**\n *\n * Every other kind skips a write when the value matches what it last wrote. That is what keeps\n * a field someone has typed into — and it is wrong for a control whose DOM state changes as a\n * *side effect of interacting with a sibling*. Clicking one radio unchecks the others with no\n * event on them, so their bindings still say `true`, still match `_committed`, and never write\n * again: the model and the page diverge and no amount of re-rendering reconciles them. A\n * `<select>`'s options are the same shape.\n *\n * Deliberately narrow. This is not for text inputs — bind those with `.value` and let a\n * person's typing stand. `?hidden` and plain attributes are not offered either: nothing changes\n * them behind the renderer's back, so there is nothing to re-read.\n */\n if (kind === LIVE) {\n this._committed = value;\n /**\n * **Except while adopting.** Hydration reaches a DOM a person may already have used, and the\n * click that checked a radio happened before any handler existed to tell the store about it —\n * so re-asserting the server's choice here would throw the interaction away and nothing would\n * ever put it back. Recorded, not written, exactly as the other form properties are; the\n * first state-driven render after that applies live semantics normally.\n */\n if (!(__HYDRATING__ && adopting)) {\n const liveTarget = this._element as unknown as Record<string, unknown>;\n if (liveTarget[this._name] !== value) liveTarget[this._name] = value;\n }\n return index + this._slots;\n }\n /**\n * **A `<select>`'s value cannot be applied where it is written.**\n *\n * Assigning it selects an option, and at the moment this part commits the options may not exist:\n * parts commit in document order, so a nested `${items.map(…)}` has not run, and an `<option\n * value=${id}>` has not been given its value either. The assignment then matches nothing, and the\n * select falls back to its first option — silently showing the wrong one. Measured: a nested list\n * selected index 0 instead of 1, and dynamic option values selected nothing at all.\n * **lit-html has the same defect, byte for byte** — it was measured there too. React solves it by\n * special-casing `<select value>` and applying it after children mount, which is what this is.\n *\n * Queued rather than dirty-checked, and that is deliberate: the value can be unchanged while the\n * *options* are replaced, which drops the selection just as thoroughly. Re-asserting once per\n * render pass is what keeps it right, and a select carries one binding, so it is one push.\n */\n if (this._select) {\n this._committed = value;\n /** Adoption never re-asserts a form value — the person may have changed it. See below. */\n if (!(__HYDRATING__ && adopting)) (pendingSelects ??= []).push(this._element as HTMLSelectElement, value);\n return index + this._slots;\n }\n if (value !== this._committed) {\n if (kind === ATTR) {\n /**\n * A nullish value removes the attribute — except on the first commit of a template that\n * never statically wrote it, where a fresh clone has nothing to remove. That skip used to\n * be unconditional-removal instead, for the one case that genuinely needs it:\n * `<b title=\"a\" title=${null}>` parses keeping the first duplicate, so the binding —\n * written last, and authoritative on the server too — must clear it. `_present` is that\n * case, read off the parsed template once ever; without it the removal was a real DOM call\n * per nullish binding per element on create — 1,000 no-ops in the 1,000-row benchmark.\n */\n if (value == null) {\n if (this._present || this._committed !== UNSET) this._element.removeAttribute(this._name);\n }\n else {\n /**\n * The same question `@verajs/renderer/spread` asks at its own sink, from the same home —\n * the two are deliberately separate implementations (see spread's header on why), and a\n * diagnostic that lived in only one of them would be the very defect this audit found.\n * `setAttribute` performs the DOMString conversion itself; nothing is stringified here.\n */\n if (__DEV__) {\n const complaint = attributeValueComplaint(this._element.localName, this._name, value);\n if (complaint !== null) console.warn(`[vera] ${complaint}`);\n }\n this._element.setAttribute(this._name, value as string);\n }\n } else if (kind === PROPERTY) {\n const target = this._element as unknown as Record<string, unknown>;\n const name = this._name;\n /**\n * **Adopting a form value: record it, do not write it.**\n *\n * `value`, `checked` and `selected` are exactly the properties `@verajs/ssr` mirrors into\n * markup, so the element already holds what this binding says — *unless a person changed\n * it*, which is the entire reason to server-render: the page is usable before the bundle\n * lands, and the window between the two is where someone types their name, ticks a box or\n * picks an option. Writing the binding then threw that away, silently, on every hydrating\n * page. The part is told it already committed this value, so it stays live and the next\n * genuine state change still applies.\n *\n * Only these three, and only while adopting. A property the server cannot express — any\n * other `.prop` — is not in the DOM yet and must be written.\n */\n if (__HYDRATING__ && adopting && (name === 'value' || name === 'checked' || name === 'selected')) {\n this._committed = value;\n return index + this._slots;\n }\n target[name] = value;\n /**\n * Detection only, and deliberately not repair.\n *\n * A property set on a custom element that has not upgraded yet lands as an own property on\n * the instance. When the definition arrives — lazily imported, code-split, or a module that\n * simply had not run — `customElements.define` upgrades synchronously and the class's field\n * initializers execute. At target ES2022 a field declaration is a `[[Define]]`, so\n * `item?: T` emits `item;` and overwrites the bound value with `undefined`. Nothing throws;\n * it reads as broken reactivity.\n *\n * Repairing it was tried and removed. Re-applying when the slot came back `undefined`\n * covered `item?: T` but not `item = someDefault`, which overwrites with the default and\n * never looks clobbered — so the repair was silently partial, and made the bug intermittent\n * across two spellings of the same mistake. It also cost 74 B in every app while leaving\n * `declare` mandatory anyway, because a property assigned imperatively is unrecoverable:\n * the renderer never saw it, and by the time `init()` runs the value is already gone.\n *\n * So this is `__DEV__`-only and production pays nothing — no check, no message, no\n * `whenDefined` subscription. Lit reached the same place from the other direction and\n * throws (`lit.dev/msg/class-field-shadowing`); a warning suffices here because Vera has no\n * prototype accessors to shadow permanently — the damage is one lost value, not a property\n * that never updates again.\n */\n if (__DEV__) {\n const tag = this._element.localName;\n if (tag.indexOf('-') > 0 && !customElements.get(tag)) {\n customElements.whenDefined(tag).then(() => {\n /**\n * States what was observed rather than diagnosing it. A class field is the usual\n * cause by a wide margin, but a component that assigns the property itself during\n * upgrade produces the same observation, and that is a legitimate — if confusing —\n * thing to do, since the renderer's dirty check will not re-apply the bound value on\n * the next render either.\n */\n if (target[name] !== value)\n console.warn(\n `[vera] renderer: the value bound by \\`.${name}=\\${…}\\` on <${tag}> was replaced ` +\n `while the element upgraded. A class field is the usual cause: at ES2022 ` +\n `\\`${name}?: …\\` emits \\`${name};\\`, which runs during upgrade and overwrites ` +\n `whatever was set beforehand — write it \\`declare ${name}?: …\\` instead, which ` +\n `emits nothing. A plain field also wipes properties assigned imperatively, ` +\n `which cannot be detected at all. Ignore this if the component replaced the ` +\n `value on purpose.`\n );\n });\n }\n }\n } else if (kind === BOOLEAN) {\n /** Unconditional for the same reason: `<b hidden ?hidden=${false}>` must end up not hidden. */\n this._element.toggleAttribute(this._name, !!value);\n } else if (kind === EVENT) {\n /**\n * A listener is the most deferred call a template makes — it is validated when a *user*\n * clicks, which in development may be never. So it is checked where it is written, the same\n * rule the setters took on: the stack at dispatch no longer contains the binding.\n *\n * `false` is deliberately allowed and silent. `@click=${enabled && onClick}` is the ordinary\n * way to bind conditionally and produces exactly that, and it already behaves correctly —\n * `handleEvent` finds nothing callable and does nothing. `true` is not produced by any\n * idiom, so it is named along with strings, numbers and objects that cannot listen.\n */\n if (__DEV__ && value != null && value !== false && typeof value !== 'function' &&\n typeof (value as EventListenerObject)?.handleEvent !== 'function')\n console.warn(\n `[vera] @${this._name} on <${this._element.localName}> was given ${typeof value === 'object' ? 'an object with no handleEvent method' : `a ${typeof value}`}, ` +\n `which cannot listen — the event will do nothing.\\n` +\n `Pass a function, or an object with a handleEvent method. A missing handler is ` +\n `\\`undefined\\` or \\`false\\`, both of which are fine; this is neither.`\n );\n if (this._handler === null && value != null) this._element.addEventListener(this._name, this);\n this._handler = (value as EventListener) ?? null;\n } else if (value != null) {\n /**\n * Element ref: `<input ${myRef} />`. A function is called with the element; an object gets\n * the element assigned to `.value` — which makes core's own `ref()` double as an element\n * ref, reactively. Runs once per distinct value, not once per render.\n */\n notifyOnRemoval = true;\n if (typeof value === 'function') applyRef(value as (el: Element | null) => void, this._element);\n else if (typeof value === 'object') {\n /**\n * A self-applying value: anything that knows what to do with an element applies itself.\n * `@verajs/renderer/spread` is the first, and the whole protocol is this one property\n * read — the implementation lives in that entry, so an app that never spreads pays for\n * the check and nothing else. `_$…$` is exempt from property mangling, like `_$litType$`.\n *\n * Deliberately confined to the element position, which is rare. A protocol in the text,\n * attribute or property commits would sit in the hot path every benchmark measures.\n */\n const self = value as { _$apply$?: (el: Element, part: object) => void; value: unknown };\n /** The part is passed as the ownership key: one element can carry several spreads. */\n if (self._$apply$) self._$apply$(this._element, this);\n else self.value = this._element;\n }\n // any other value type at element position is consumed and ignored\n }\n this._committed = value;\n }\n return index + this._slots;\n }\n}\n\n/**\n * `<select>.value` assignments held until the whole pass has committed — see the note in `_commit`.\n * Flat pairs rather than tuples: one array, no per-entry allocation.\n */\nlet pendingSelects: unknown[] | null = null;\n\nconst flushSelects = () => {\n const queued = pendingSelects;\n if (queued === null) return;\n /** Cleared first: an assignment can run a `change` handler that renders again. */\n pendingSelects = null;\n for (let i = 0; i < queued.length; i += 2)\n (queued[i] as HTMLSelectElement).value = queued[i + 1] as string;\n};\n\nconst SCRATCH = doc.createDocumentFragment();\n\n/**\n * Marks a node as the render root's OWN output — see `ChildPart._insert`. Sigil-named so property\n * mangling cannot rename it: this is read by `@verajs/renderer/slots`, across a bundle boundary,\n * and a module-scoped Symbol would be minted twice on a CDN page (the `@verajs/styles` lesson).\n *\n * A fragment is stamped through to its children, because inserting one moves the children and the\n * fragment itself never enters the document — the observer reports the children.\n *\n * **Defined rather than assigned, so it is NON-ENUMERABLE.** A plain `node._$own$ = true` is an own\n * enumerable property: measured, it then shows up in `Object.keys(element)` — which is `[]` for\n * every other DOM element — and in `for…in`. Invisibility to everything outside the framework is\n * the whole reason this is a property and not a marker or an attribute, and an enumerable one is\n * not invisible. The descriptor is shared, so this allocates nothing per node, and the path is\n * gated on slots being wired, so no app that does not use them ever reaches it.\n */\nconst OWN_DESCRIPTOR: PropertyDescriptor = { value: true, enumerable: false, configurable: true, writable: true };\n/**\n * The stamp is VALUED, and the value is the discriminator (`docs` in the slots module read it):\n *\n * `true` — the render root's own output: never slot content.\n * a ChildPart — light content PLACED by that part from an outer template. The part identity\n * is the ordering group: a grown row belongs after ITS part's other rows, and\n * `<host>${a}${b}</host>` must not interleave a's refill into b's content —\n * which is exactly what happens if the group is the render root, shared by both.\n * absent — an imperative user mutation; the light region orders it by document position.\n *\n * One shared, mutated descriptor: `defineProperty` reads it synchronously, so this allocates\n * nothing per node while keeping the property non-enumerable (see the invisibility note above).\n */\nconst stampOwn = (node: Node, value: true | object = true) => {\n OWN_DESCRIPTOR.value = value;\n if (node.nodeType === 11) {\n for (let child = node.firstChild; child !== null; child = child.nextSibling)\n Object.defineProperty(child, '_$own$', OWN_DESCRIPTOR);\n return;\n }\n Object.defineProperty(node, '_$own$', OWN_DESCRIPTOR);\n};\n\n/** A row is either an element-mode instance or a markered part; both can hold appliers. */\nconst detachItem = (item: Item) => {\n item._instance?._teardown();\n item._part?._detach();\n};\n\n/**\n * A value that names the strategy able to reconcile a list of its kind. `keyed()` in\n * `@verajs/renderer/keyed` is the only producer today; the shape is deliberately open so a\n * virtualizer or an async list can ship as its own module without this file learning about it.\n *\n * `$r` and the three members it calls are exempt from property mangling — they are the only names\n * that cross a bundle boundary, and they are two characters so crossing costs nothing.\n */\nexport type ListStrategy = (\n part: ChildPart,\n values: unknown[],\n items: Item[],\n parent: Node,\n end: Node | null\n) => Item[];\n\nexport type KeyedResult = TemplateResult & { $r?: ListStrategy };\n\n/**\n * A list item is either ELEMENT-MODE — a single-root template instance whose one element IS the\n * item's boundary (`_element`/`_instance`/`_shape` set, `_part` null) — or a general markered\n * ChildPart. Rows are single-root in virtually every real list, and element mode drops both marker\n * comments and both marker inserts per item, which is exactly the per-row overhead a vdom does not\n * pay on create.\n */\ntype Item = {\n $k: unknown;\n _element: Element | null;\n _instance: Instance | null;\n _shape: TemplateStringsArray | null;\n _part: ChildPart | null;\n};\n\nclass Instance {\n _parts: Part[] = [];\n _fragment: DocumentFragment;\n /**\n * **`declare`, so nothing is emitted and no instance carries these unless it uses them.**\n * Under ES2022 class-field semantics a plain `_x?: T` is DEFINED on every instance, undefined or\n * not — measured, two such declarations cost every row of a 200-row list a property apiece and\n * showed up as a few percent off update throughput. Templates without slots now allocate exactly\n * what they did before this feature existed, and the ones with slots take a shape transition\n * once.\n *\n * `_slotStates` — taken-over slot states, parked at teardown.\n * `_pendingSlots` — resolved `<slot>` clones awaiting mount; cleared by the first `_update`.\n */\n declare _slotStates?: SlotSeamState[];\n declare _pendingSlots?: Element[];\n constructor(template: Template) {\n /**\n * `importNode`, not `cloneNode` — the difference is custom-element upgrade, not the document.\n * Template content lives in the inert template document, so `cloneNode` copies stay\n * un-upgraded until insertion; a `.prop` committed in that window lands as an OWN property\n * that permanently shadows a defined class's setter (the setter never fires — every\n * accessor-based element, Lit's included, receives a dead value) and a bound value on a\n * class-field element is clobbered by the field initializer at insert, silently, because the\n * `whenDefined` detector below only watches definitions that arrive LATE. Hydration commits\n * onto server-parsed, already-upgraded elements, so the two render paths disagreed about the\n * same template. `importNode`'s cloning steps upgrade defined elements at clone time — in\n * every engine and in jsdom — which makes the commit order match hydration and the platform.\n * Undefined elements are untouched: nothing can upgrade them, and the pre-upgrade posture\n * (own property, clobber on define, development warning) stands as pinned in\n * `tests/pre-upgrade-property.test.mjs`. Measured cost of losing `cloneNode`: ~2–7% of the\n * raw clone operation across the three engines — nanoseconds per instance.\n */\n this._fragment = doc.importNode(template._element.content, true);\n const templateParts = template._parts;\n /** Shared walker, ELEMENT | TEXT — child anchors are the primed text nodes themselves. */\n instanceWalker.currentNode = this._fragment;\n let nodeIndex = -1;\n let node: Node | null = null;\n for (let i = 0; i < templateParts.length; i++) {\n const templatePart = templateParts[i];\n if (templatePart._type === IGNORED) {\n this._parts.push(IGNORED_PART);\n continue;\n }\n while (nodeIndex < templatePart._index) {\n node = instanceWalker.nextNode();\n nodeIndex++;\n }\n this._parts.push(\n templatePart._type === CHILD\n ? new TextPart(node as Text)\n : new AttrPart(node as Element, templatePart._name!, templatePart._statics!, templatePart._present)\n );\n }\n /**\n * Slot records mount OUTSIDE the parts array — one extra walk from the top, paid only by\n * templates that HAVE slots, only inside a renderInto commit (null root — hydration's\n * adoption path — stays inert), and only when the 'slot' insert answers. Taking over sets\n * `notifyOnRemoval`: `_$park$` must rescue the USER'S nodes before a bulk `_clear` discards\n * the DOM holding them on a branch-away. `_update` never sees any of this.\n */\n if (template._seam !== undefined && _slotRoot !== null) {\n const slotRecords = template._slots!;\n /**\n * RESOLVE every slot element to its clone in ONE walk, and mount them AFTER the first\n * `_update` — see `_mountSlots`. Collect-then-act, because the seam MUTATES the fragment\n * (it lifts each `<slot>` out and drops in anchors) and a walk that interleaved resolution\n * with those mutations would read shifted indices and miss later slots.\n */\n instanceWalker.currentNode = this._fragment;\n nodeIndex = -1;\n const slotNodes: Element[] = [];\n for (let i = 0; i < slotRecords.length; i++) {\n while (nodeIndex < slotRecords[i]) {\n node = instanceWalker.nextNode();\n nodeIndex++;\n }\n slotNodes.push(node as Element);\n }\n this._pendingSlots = slotNodes;\n }\n /** Standalone rather than an `else` branch: `_slotless` is only ever set when there was no\n * seam, so the condition stands alone — and a lone `if (__DEV__ …)` folds away cleanly. */\n if (__DEV__ && template._slotless === true && _slotRoot !== null && _slotRoot.nodeType === 1) {\n /**\n * **A `<slot>` in a LIGHT render that nothing will distribute.** Both ways of arriving here\n * are silent otherwise, and both leave the same confusing picture. Measured, for a host given\n * `<b slot=\"a\">MINE</b>`:\n *\n * <b slot=\"a\">MINE</b><!----><div class=\"box\"><slot name=\"a\">FB</slot></div>\n *\n * — the content is not destroyed, it is stranded ahead of the render while the slot shows its\n * fallback. The message says \"any content the host is given\" rather than asserting the host\n * HAS some: a component that consumes its own children before rendering and also declares\n * slots — `@verajs/ui`'s select is one — warns with nothing stray on the page, and a reader\n * sent looking for markup that is not there concludes the diagnostic is confused.\n *\n * 1. `@verajs/renderer/slots` was never wired at all.\n * 2. It was wired AFTER this template first rendered. Templates are interned per call site\n * for the life of the page and resolve the seam once, at construction — so a component\n * that rendered before the wiring keeps a slotless template forever, and every later use\n * of it fails the same way. Measured: the same `draw()` distributes at a fresh call site\n * and not at this one.\n *\n * A shadow root never reaches here: the platform slots there, which is why this is gated on\n * an element root.\n */\n warnSlotless(_slotRoot as Element);\n }\n }\n\n /**\n * One walk, both jobs: release the element refs in this instance and tell any child applier\n * under it that it is going away.\n *\n * They were two walks over the same array — `_release` for refs, `_detach` for appliers — which\n * is the same tree traversed twice for two answers that arrive at the same moment. Merged, the\n * per-part cost is one `_kind` compare and one `_upgraded` read.\n *\n * Reached only when this instance's template holds a ref, or some applier somewhere declared\n * teardown. An app with neither never runs it: this is the per-node work the bulk removal exists\n * to skip, and the gate is what keeps it out of the path.\n *\n * Through `_upgraded`, not just `_parts`. A child position is instantiated as a `TextPart` and\n * **upgrades** to a `ChildPart` the first time it takes an object — so the part holding a\n * applier is almost never the one in this array, it is the one that array's entry points at.\n * Walking `_parts` alone found nothing at all.\n */\n _teardown() {\n const parts = this._parts;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if ((part as AttrPart)._kind === REF) (part as AttrPart)._release();\n (part as TextPart)._upgraded?._detach();\n }\n /** Taken-over slots park the USER'S nodes before this instance's DOM is discarded. */\n this._slotStates?.forEach((state) => state._$park$?.());\n }\n\n _update(values: unknown[]) {\n let valueIndex = 0;\n const parts = this._parts;\n for (let i = 0; i < parts.length; i++) valueIndex = parts[i]._commit(values, valueIndex);\n if (this._pendingSlots !== undefined) this._mountSlots();\n }\n\n /**\n * **Slots mount after the first `_update`, not during construction, because a `<slot>`'s own\n * bindings are part of its meaning.** `<slot name=${section}>` has no name at all until its\n * `AttrPart` has committed, and mounting first read the static markup and got `''` — the slot\n * registered as a second DEFAULT slot, took the default content, and left the real default slot\n * showing fallback. Committing first also means `@slotchange` and `&ref` are already attached to\n * the element by the time anything is dispatched on it.\n *\n * Once per instance: the fields are cleared here and every later `_update` costs one compare.\n */\n _mountSlots() {\n const slotNodes = this._pendingSlots!;\n this._pendingSlots = undefined;\n /**\n * `_slotRoot` still holds the container: it is set for the whole of one `renderInto` and every\n * instance under it — nested templates included — is constructed and first-updated inside that\n * same synchronous span, so this is the root the constructor saw.\n */\n const root = _slotRoot;\n const seam = slotSeam();\n if (seam === undefined || root === null) return;\n for (let i = 0; i < slotNodes.length; i++) {\n const slot = slotNodes[i];\n const state = seam(slot, root, slot.getAttribute('name') ?? '');\n if (state != null) {\n (this._slotStates ??= []).push(state);\n notifyOnRemoval = true;\n }\n }\n }\n}\n\n/** A single property read — this runs once per list item per render, so it must be minimal. */\nconst isTemplateResult = (value: object): value is TemplateResult =>\n (value as TemplateResult).strings !== undefined;\n\n/**\n * The common case of a child expression is plain text, and the template primes every child slot\n * with a text node — so the steady state is compare-and-assign on `.data`. This part carries only\n * that, upgrading itself to a full ChildPart the first time it sees null, a template, or an array.\n */\nclass TextPart implements Part {\n _text: Text;\n _value: unknown = '';\n _upgraded: ChildPart | null = null;\n\n constructor(text: Text) {\n this._text = text;\n }\n\n _commit(values: unknown[], index: number): number {\n const value = values[index];\n if (this._upgraded !== null) {\n this._upgraded._set(value);\n return index + 1;\n }\n if (value == null || typeof value === 'object') {\n /**\n * Upgrade in place: marker comments come into existence only now, anchored around the text\n * node, and the full part inherits the committed text state and delegates forever.\n *\n * BOTH markers are ours. Borrowing `this._text.nextSibling` as the end instead would hand\n * this part a boundary owned by the NEXT part — and the next part removes that very node\n * when it upgrades and clears its own text. The stale reference then makes `_clear()` walk\n * past the end of the child list. Owning both anchors also makes `_end === null` mean\n * exactly one thing: the root part, which really does own its container.\n */\n const start = comment();\n const end = comment();\n /**\n * **Markers go where the part LIVES, which is not always where its text node is.** In a\n * light host wired for slots, this text node was captured and distributed into the\n * component's tree — planting markers beside it there put them inside the slot's range,\n * the slot's next fill swept them into the holding fragment, and the part spent the rest\n * of the page rendering into detached space (measured: `<host>${text}</host>` toggling\n * through null showed FALLBACK forever). `_$home$` answers with the host's light-region\n * sentinel for a captured node and null for everything else, so every app without light\n * slots takes the second branch untouched.\n */\n const home = slotSeam()?._$home$?.(this._text) ?? null;\n const parent = home !== null ? home.parentNode! : this._text.parentNode!;\n if (home !== null) {\n parent.insertBefore(start, home);\n parent.insertBefore(end, home);\n } else {\n parent.insertBefore(start, this._text);\n parent.insertBefore(end, this._text.nextSibling);\n }\n const part = new ChildPart(start, end);\n part._mode = TEXT;\n part._text = this._text;\n part._value = this._value;\n this._upgraded = part;\n part._set(value);\n return index + 1;\n }\n if (value !== this._value) {\n this._value = value;\n this._text.data = value as string;\n }\n return index + 1;\n }\n}\n\n/**\n * A value at a child position that applies itself — see `ChildPart._set`.\n *\n * `previous` is whatever this applier returned at this part on the last render, which is where a\n * applier keeps its continuity. Returning nothing is fine for one that has none.\n */\nexport type Applier = ((part: { _$commit$(value: unknown): void }, previous: unknown) => unknown) & {\n /**\n * Optional teardown, hung on the **applier** rather than on the value.\n *\n * The applier is already required to be hoisted — a fresh function per render breaks continuity —\n * so it is the one stable object in the protocol and the natural place for a second half. It\n * receives whatever the applier last returned, which is where its state lives.\n */\n _$detach$?: (previous: unknown) => void;\n};\n\n/**\n * A value at a child position the renderer has no built-in answer for. Return `true` to claim it.\n *\n * A handler will also be handed the **operations** it needs to do its job — the shape\n * `'proxy-handler'` uses, where core passes `addCallback` and `runCallbacks` rather than exposing\n * them as members. That object is deliberately *not* here yet: an earlier draft guessed nine\n * methods, nothing used them, they cost 90 B of anticipation, and porting the list algorithm then\n * showed it needs closer to fourteen — including item accessors the guess had no idea about. It\n * gets built in the step that has a caller to shape it.\n *\n * This is how a value *kind* becomes a package rather than a branch: lists, an async value, a\n * portal, a virtualizer. The built-ins below register through it too, so a third party's kind is\n * not second-class to one that shipped in the box.\n */\nexport type ValueHandler = (part: object, value: unknown) => boolean | void;\n\n/**\n * The registry this renderer reads `'value'` handlers from, handed over by {@link renderer}.\n *\n * Not imported. The renderer carries no registry of its own for the same reason the router does\n * not: a production bundle inlines `@verajs/inserts`, so importing it would give this package one\n * registry and core another, and an app would register into whichever it happened to import — the\n * failure `connectInserts` used to repair.\n */\nlet registry: { get(name: 'value' | 'slot'): unknown[] | undefined } | null = null;\n\n/**\n * The ONE lookup for the `'slot'` insert. Three callers want the same thing in the same shape —\n * template construction (are there slots to record?), the first render into a container (capture\n * the host's children), and hydration's rescue (un-distribute before a mismatch discards) — and\n * the seam carries its cross-bundle members as sigil-named keys, which every caller had to spell\n * out again. One accessor, spelled once.\n */\n/**\n * **Whether ANY app on this page wired light slots**, latched the first time the seam answers.\n *\n * The ownership stamp in `_insert`/`$c` exists only for `@verajs/renderer/slots` to read, and its\n * guard has to be free for everyone else — `_slotRoot` is set for every `renderInto`, so without\n * this an app with no slots at all would stamp every top-level node it renders, which for a list\n * at the root is a property write per ROW. One boolean instead, false for the life of a page that\n * never wires them.\n */\nlet slotsWired = false;\nconst slotSeam = (): SlotSeam | undefined => {\n const seam = (registry?.get('slot') as SlotSeam[] | undefined)?.[0];\n if (seam !== undefined) slotsWired = true;\n return seam;\n};\nconst noHandlers: ValueHandler[] = [];\nconst valueHandlers = () => (registry ? ((registry.get('value') as ValueHandler[] | undefined) ?? noHandlers) : noHandlers);\n\n/**\n * Kinds this package still ships. They read from a local list rather than the registry because the\n * renderer cannot register into one it was merely handed — that needs `wire`, which it does not\n * import. The list empties when they move to packages; until then a wired handler is checked first,\n * so a module can pre-empt a built-in exactly as the priority order promises.\n */\nconst builtIns: ValueHandler[] = [];\n\n/**\n * Whether anything in this process has asked to be told when a subtree is removed — an element ref\n * to release, or a child applier that declared `_$detach$`.\n *\n * **One flag for both, and it is process-wide.** Teardown cannot be discovered from the template the\n * way a ref can — a ref is a `&` part the scan sees, while an applier arrives as a *value* and no\n * template shape predicts it — so the coarser gate is the only one that serves both.\n *\n * The finer, per-template gate for refs was measured and dropped: it saved 34 B less than nothing,\n * because the walk it avoided is not the expensive part. With one unrelated ref on the page, a\n * 1 000-row clear walks 1 000 instances and measures 3.98 ms against 4.03 ms with no ref at all —\n * the DOM removal dominates completely. What matters is that an app asking for neither walks\n * **zero**, and that still holds.\n */\nlet notifyOnRemoval = false;\n\n/**\n * The hydrate entry's way to raise the flag. Every CLIENT path that creates removal work sets\n * `notifyOnRemoval` where the work is created (a ref committing, a slot mounting, an applier\n * declaring `_$detach$`) — but hydration ADOPTS its seams through its own walk in `hydrate.ts`,\n * a different module compiled into the same bundle, and a page whose only seams were adopted\n * left the flag down. `_clear` then skipped `_detach` entirely: no `_teardown`, no `_$park$`,\n * and the user's server-adopted slotted content was destroyed on the first branch-away — the\n * exact content-loss class the seam's park exists to prevent, reintroduced one entry over.\n */\nexport const declareRemovalWork = (): void => {\n notifyOnRemoval = true;\n};\n\n/**\n * Dev-only: how many times a part has seen a *different* child applier. See the branch that reads it.\n *\n * `@__PURE__` is load-bearing. Every read sits behind `__DEV__`, but a bare `new WeakMap()` at module\n * scope is a constructor call terser must assume has side effects, so production kept the allocation\n * with its binding dropped — a literal `new WeakMap;` statement building an object nothing could ever\n * reach. The annotation is what lets the dead branch take it along.\n */\nconst _applierSwaps = /* @__PURE__ */ new WeakMap<object, number>();\n\n/** What a ChildPart currently contains. */\nconst EMPTY = 0;\nconst TEXT = 1;\nconst TEMPLATE = 2;\nconst LIST = 3;\nconst NODE = 4;\n\n/**\n * Development-only profiling hook, armed by `@verajs/renderer/profiler`. Null until something\n * arms it, so an unprofiled development render pays one null check per template commit.\n *\n * Every reference sits behind `__DEV__`, which `defineDev()` folds to `false` before terser runs —\n * so the declaration, the constants and every call site are removed from the production bundle.\n * Verified by byte comparison, not assumed.\n */\nconst PROFILE_UPDATE = 0; // same template identity — values committed in place\nconst PROFILE_CREATE = 1; // first template into an empty part\nconst PROFILE_REBUILD = 2; // template identity CHANGED — subtree torn down and rebuilt\nconst PROFILE_FRAME_START = 3;\nconst PROFILE_FRAME_END = 4;\n\ntype ProfileHook = (kind: number, subject: unknown, shape: TemplateStringsArray | null) => void;\nlet _profileHook: ProfileHook | null = null;\n/** @internal */\nconst _setProfileHook = (fn: ProfileHook | null) => {\n _profileHook = fn;\n};\n\nclass ChildPart implements Part {\n _start: Comment;\n /** Exclusive end of this part's range; null means \"to the end of the parent\". */\n _end: Node | null;\n _mode = EMPTY;\n _value: unknown;\n _text: Text | null = null;\n _instance: Instance | null = null;\n /** The committed template's strings identity — the same-template fast path in `_set`. */\n _shape: TemplateStringsArray | null = null;\n _items: Item[] | null = null;\n _keyedList = false;\n /** Held instances by template identity; survives clears so state outlives interim content. */\n _held: Map<TemplateStringsArray, Instance> | null = null;\n /** Whatever the last `_$child$` at this part returned — its continuity across renders. */\n _applierState: unknown = undefined;\n /** Which applier that state belongs to, so two of them at one part cannot read each other's. */\n _applier: unknown = undefined;\n\n constructor(start: Comment, end: Node | null) {\n this._start = start;\n this._end = end;\n }\n\n _commit(values: unknown[], index: number): number {\n this._set(values[index]);\n return index + 1;\n }\n\n /**\n * **A component's own output is STAMPED, so the slot system cannot mistake it for content.**\n *\n * `@verajs/renderer/slots` captures a top-level element carrying a `slot` attribute as the\n * host's content — which a component's own rendered root may legitimately be, when it renders\n * something destined for ITS parent's slot. Measured: with slots wired,\n * `renderInto(html\\`<div slot=\"x\">…</div>\\`, element)` distributed the component's output into\n * its own holding fragment and the component rendered NOTHING, on the first render, with no\n * children involved and nothing thrown.\n *\n * The renderer is the one party that knows: it is inserting at the top level of the container\n * it was asked to render into. `_slotRoot` is that container for the whole of one `renderInto`,\n * so `parent === _slotRoot` is exactly \"this is the component's own output\" and distinguishes it\n * from `<x-card>${value}</x-card>`, where the part's parent is the host but the render root is\n * an ancestor — the user's light content, which must still be captured.\n *\n * Two comparisons on a path that is already touching the DOM, and the stamp is a PROPERTY:\n * invisible to CSS, to serialization and to `children`, unlike any marker or attribute, and it\n * rides on text nodes, which no attribute can. An app without slots wired writes it and nothing\n * ever reads it.\n */\n /**\n * **One property read decides all stamping, and root-part-ness decides the value.**\n *\n * `_$hosted$` is set on the host element itself by `@verajs/renderer/slots` at capture, so\n * \"does anything care about ownership here\" is a single own-property read — no seam call, no\n * registry lookup, and pages that are not captured hosts (every container in most apps) cost\n * exactly that read and write nothing. The mark cannot go stale in the direction that matters:\n * a part's first commit runs in a detached fragment before its host is captured, reads\n * `undefined`, and stamps nothing — and that content is exactly what the initial capture walk\n * lifts anyway. Every later commit sees the mark.\n *\n * The VALUE is structural, not temporal. `_end === null` is true of root parts alone (see\n * `_clear`), and a root part's inserts are by definition the render's own output — a fact that\n * stays true for an applier committing from a microtask hours after `renderInto` returned,\n * where the earlier `parent === _slotRoot` test read null and left ASYNC output unstamped for\n * the flipped capture rule to eat. Everything else inserting into a host is placing content\n * INTO it from outside, stamped with the part — the ordering group.\n */\n _insert(node: Node) {\n const parent = this._start.parentNode!;\n if (slotsWired && (parent as { _$hosted$?: boolean })._$hosted$ === true)\n stampOwn(node, this._end === null ? true : this);\n parent.insertBefore(node, this._end);\n }\n\n /**\n * Tells every child applier under this part that it is going away.\n *\n * Reached only when some applier somewhere declared teardown — see `notifyOnRemoval` — because\n * this is the per-node walk the bulk removal exists to skip. **Every** removal path calls it, not\n * just `_clear`: a keyed row is dropped by moving its nodes to a scratch fragment and an index-mode\n * list shrinks by removing nodes directly, so a version that only hooked `_clear` notified a\n * applier when its container was replaced and stayed silent when its row was deleted — told\n * sometimes, which is a worse contract than never.\n */\n _detach() {\n if (this._applier !== undefined) (this._applier as Applier)._$detach$?.(this._applierState);\n this._instance?._teardown();\n const items = this._items;\n if (items != null) for (let i = 0; i < items.length; i++) detachItem(items[i]);\n }\n\n _clear() {\n /**\n * One gate, two jobs. A template that holds an element ref must release it; a subtree holding a\n * applier that declared teardown must be told. Both are found by the same walk, and an app\n * with neither reads two booleans and walks nothing.\n */\n if (notifyOnRemoval) this._detach();\n const parent = this._start.parentNode!;\n const end = this._end;\n const items = this._items;\n /**\n * **Content that is no longer between the markers.** `@verajs/renderer/slots` distributes a\n * light host's children by MOVING them into the component's tree, so a part rendering those\n * children keeps its markers in the host while its content lives inside the component.\n *\n * Both branches below are wrong for that, and wrong in opposite directions. The walk finds\n * the markers adjacent and removes nothing — the content stays on screen after being cleared\n * (a template swap in a light host showed the OLD template forever). The whole-parent fast\n * path is the dangerous one: it would `textContent = ''` the HOST, component render and all.\n *\n * Every mode knows its content by IDENTITY, which is parent-agnostic and split-proof: items\n * through `$m`, TEXT through `_text`, NODE through `_value`, TEMPLATE through the top-level\n * node array recorded at commit. The one shape that cannot be found this way is a\n * DocumentFragment committed at NODE position (its children scatter and it keeps no record);\n * that falls through to the walk, as before.\n */\n if (this._start.nextSibling === end && this._mode !== EMPTY) {\n if (items !== null) {\n for (const item of items) if (item !== null) this.$m(item, null, SCRATCH);\n SCRATCH.textContent = '';\n } else if (this._mode === TEXT) {\n (this._text as ChildNode | null)?.remove();\n } else if (this._mode === TEMPLATE) {\n if (Array.isArray(this._value)) for (const node of this._value as ChildNode[]) node.remove();\n } else if (this._mode === NODE && typeof (this._value as ChildNode).remove === 'function') {\n (this._value as ChildNode).remove();\n }\n } else /**\n * When this part owns its parent's entire contents, one `textContent = ''` replaces removing\n * every node individually. For a 1 000-row table body that is the difference between ~22 ms\n * (lit-html's per-node teardown) and ~5 ms.\n *\n * A part owns the whole parent when nothing precedes its start AND nothing follows its end —\n * `_end === null` (a root part, which runs to the end by definition) or `_end` is the last\n * child. The second case is the common one and used to miss this path entirely: every list\n * written as `<tbody>${rows}</tbody>` sits inside a template, and since 0.1.2 a nested part\n * always owns an end marker, so `_end === null` alone never held for it.\n *\n * Re-appending both anchors in order restores the part's boundary exactly as it was.\n */\n if (this._start.previousSibling === null && (end === null || end.nextSibling === null)) {\n parent.textContent = '';\n parent.appendChild(this._start);\n if (end !== null) parent.appendChild(end);\n } else {\n let node = this._start.nextSibling;\n /**\n * `node !== null` is a backstop, not an expected exit. Reaching the end of the child list\n * without meeting `_end` means something detached this part's boundary; stopping leaves\n * nodes behind, which beats throwing out of the middle of a render pass.\n */\n while (node !== null && node !== this._end) {\n const next = node.nextSibling;\n parent.removeChild(node);\n node = next;\n }\n }\n this._mode = EMPTY;\n this._text = null;\n this._instance = null;\n this._items = null;\n this._shape = null;\n this._applierState = undefined;\n this._applier = undefined;\n }\n\n /**\n * How a child-position applier renders. Named to survive property mangling — `/^_[a-z]/` is the\n * pattern, and `_$…$` does not match it — because this is the half of the protocol that third\n * parties call.\n */\n _$commit$(value: unknown) {\n /**\n * The applier's own state survives its own rendering. Committing different content usually\n * runs `_clear`, which drops the state so a part that was emptied by *anything else* cannot\n * hand an applier continuity it no longer has — but an applier rendering its own next value\n * has not gone away, and losing continuity there made `until()` fall back to its placeholder on\n * the render after it resolved.\n */\n const applierState = this._applierState;\n const applier = this._applier;\n this._set(value);\n this._applierState = applierState;\n this._applier = applier;\n }\n\n _set(value: unknown) {\n if (value == null) {\n if (this._mode !== EMPTY) this._clear();\n return;\n }\n if (typeof value !== 'object') {\n if (this._mode === TEXT) {\n if (this._value !== value) {\n this._value = value;\n this._text!.data = value as string; // the DOM coerces numbers etc.\n }\n } else {\n if (this._mode !== EMPTY) this._clear();\n this._text = doc.createTextNode(value as string);\n this._insert(this._text);\n this._value = value;\n this._mode = TEXT;\n }\n return;\n }\n const heldResult = (value as { $h?: TemplateResult }).$h;\n if (heldResult !== undefined) {\n this._commitHeld(heldResult);\n return;\n }\n if (isTemplateResult(value)) {\n /**\n * Same-shape fast path on `strings` identity alone — no template-cache lookup. This is the\n * hottest line in a keyed list update: for every row whose shape did not change (all of\n * them, in practice), commit costs one identity compare before touching the values.\n */\n if (this._shape === value.strings) {\n if (__DEV__ && _profileHook) _profileHook(PROFILE_UPDATE, this, value.strings);\n this._instance!._update(value.values);\n return;\n }\n /**\n * Reaching here with a template already committed means the identity changed, so the\n * subtree below is about to be destroyed and rebuilt rather than updated. That is what\n * `?hidden=${…}` over a swapped subtree exists to avoid, and it is otherwise invisible.\n */\n if (__DEV__ && _profileHook) {\n _profileHook(this._mode === TEMPLATE ? PROFILE_REBUILD : PROFILE_CREATE, this, value.strings);\n }\n const template = getTemplate(value);\n if (this._mode !== EMPTY) this._clear();\n const instance = new Instance(template);\n instance._update(value.values);\n /**\n * The instance's top-level nodes, recorded while they are still in the fragment. `_value`\n * is unused in TEMPLATE mode, and this is what lets `_clear` and `hold`'s parking find the\n * content after `@verajs/renderer/slots` has moved it out of the marker range — per node,\n * parent-agnostic, so even content split across two slots comes back. Costs one small array\n * on a path that just built an Instance and cloned a template; same-shape updates never\n * reach here.\n */\n this._value = [...instance._fragment.childNodes];\n this._insert(instance._fragment);\n this._instance = instance;\n this._shape = value.strings;\n this._mode = TEMPLATE;\n return;\n }\n const handlers = valueHandlers();\n for (let i = 0; i < handlers.length; i++) if (handlers[i](this, value)) return;\n for (let i = 0; i < builtIns.length; i++) if (builtIns[i](this, value)) return;\n\n /**\n * **A child-position value that applies itself.** The same idea as `_$apply$` at element\n * position — which is how `@verajs/renderer/spread` ships as a separate package the renderer\n * knows nothing about — at the one other position worth extending.\n *\n * `_$child$(part, previous)` is handed the part and whatever it returned last time at this\n * part, and calls `part._$commit$(value)` to render content. Keeping continuity in the return\n * value rather than in an applier *instance* is what keeps this a protocol rather than a\n * framework: there is no base class, no factory and no lifecycle to learn, and an applier is\n * an object literal.\n *\n * Placed **after** the template check on purpose. A template is overwhelmingly the common\n * object at a child position, and it returns above without ever reading this property — so the\n * check costs the hot path nothing and only arrays, nodes and appliers pay for it. Measured:\n * +22 B gzipped, and no runtime difference distinguishable from noise.\n *\n * There is deliberately no teardown hook. `_clear` bulk-removes DOM and, when the part owns its\n * parent, does `parent.textContent = ''` — the thing that makes clearing a 1 000-row table ~5 ms\n * against lit-html's ~22 ms. Calling teardown on a nested applier would mean walking the part\n * tree on every removal, which is precisely the per-node work that fast path exists to skip. So\n * an applier here can render, and cannot yet be told it has gone away.\n */\n const applyChild = (value as { _$child$?: Applier })._$child$;\n if (applyChild !== undefined) {\n /** `previous` belongs to *this* applier; a different one at the same part starts fresh. */\n const previous = this._applier === applyChild ? this._applierState : undefined;\n /**\n * The un-hoisted applier, named. Writing `_$child$` as an object-literal method makes a new\n * function per render, so the part never recognises it and `previous` is `undefined` forever —\n * the applier silently restarts on every pass. It is the first rule in the README and it\n * fails without a symptom, so development counts the swaps: a genuine applier change at one\n * part happens once or twice, not on every render.\n *\n * The counter is a module-scope `WeakMap` rather than a field, so production carries neither\n * it nor a per-part slot to hold it — but only because it is marked `@__PURE__` at its\n * declaration. Without that it said the same thing and was untrue.\n */\n if (__DEV__ && this._applier !== undefined && this._applier !== applyChild) {\n const swaps = (_applierSwaps.get(this) ?? 0) + 1;\n _applierSwaps.set(this, swaps);\n if (swaps === 3) {\n console.warn(\n `[vera] a child applier changed identity ${swaps} times at one part, so \\`previous\\` ` +\n `is always undefined and it restarts every render.\\n` +\n `Hoist the applier — written as an object-literal method it is a new function per ` +\n `call:\\n\\n` +\n ` function applyThing(part, previous) { … } // once, at module scope\\n` +\n ` const thing = (x) => ({ _$child$: applyThing, x }); // state on the object\\n`\n );\n }\n }\n this._applier = applyChild;\n if (applyChild._$detach$ !== undefined) notifyOnRemoval = true;\n this._applierState = applyChild.call(value, this, previous);\n return;\n }\n if ((value as Node).nodeType !== undefined) {\n /**\n * A DOM node renders as itself — a canvas a charting library owns, a `<template>`'s content,\n * an element built by hand. Placed after the template check and before the list check\n * because `nodeType` is one property read and nothing else that reaches here has one.\n */\n if (this._mode !== NODE || this._value !== value) {\n if (this._mode !== EMPTY) this._clear();\n this._insert(value as Node);\n this._value = value;\n this._mode = NODE;\n }\n return;\n }\n // any other object: render as text\n this._set(String(value));\n }\n\n /** Commits a template while stashing whatever it replaces — see the `hold()` export. */\n _commitHeld(result: TemplateResult) {\n if (this._mode === TEMPLATE && this._shape === result.strings) {\n this._instance!._update(result.values);\n return;\n }\n const held = (this._held ??= new Map());\n if (this._mode === TEMPLATE) {\n /** Park the live nodes back in their instance's own (empty) fragment. When the range is\n * empty but content existed, slots relocated it — the recorded top-level nodes park it\n * from wherever it lives, split slots and holding included. */\n const fragment = this._instance!._fragment;\n if (this._start.nextSibling === this._end && Array.isArray(this._value)) {\n for (const node of this._value as Node[]) fragment.appendChild(node);\n } else {\n let node = this._start.nextSibling;\n while (node !== this._end) {\n const next = node!.nextSibling;\n fragment.appendChild(node!);\n node = next;\n }\n }\n held.set(this._shape!, this._instance!);\n } else if (this._mode !== EMPTY) {\n this._clear();\n }\n const instance = held.get(result.strings) ?? new Instance(getTemplate(result));\n instance._update(result.values);\n this._value = [...instance._fragment.childNodes];\n this._insert(instance._fragment);\n this._instance = instance;\n this._shape = result.strings;\n this._mode = TEMPLATE;\n }\n\n /**\n * Creates one list item. A single-root template instance becomes an element-mode item with no\n * markers at all; anything else gets its own start/end marker pair so moves can never dangle.\n */\n $c(value: unknown, parent: Node, ref: Node | null): Item {\n /** Rows reach the DOM here rather than through `_insert`; same one-read gate, same\n * structural value — a root list's rows are the render's own output, any other part's rows\n * are content it places into the host, stamped with the part as the ordering group. */\n const stamp =\n slotsWired && (parent as { _$hosted$?: boolean })._$hosted$ === true\n ? this._end === null\n ? true\n : this\n : null;\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings !== undefined) {\n const result = value as TemplateResult;\n const template = getTemplate(result);\n const instance = new Instance(template);\n instance._update(result.values);\n const rootNode = instance._fragment.firstChild;\n if (rootNode !== null && rootNode.nodeType === 1 && rootNode.nextSibling === null) {\n if (stamp !== null) stampOwn(rootNode, stamp);\n parent.insertBefore(rootNode, ref);\n return {\n $k: result.key,\n _element: rootNode as Element,\n _instance: instance,\n _shape: result.strings,\n _part: null,\n };\n }\n /** Multi-root template: markered part, content already instantiated. */\n const part = createMarkeredPart(parent, ref);\n part._instance = instance;\n part._shape = result.strings;\n part._mode = TEMPLATE;\n part._value = [...instance._fragment.childNodes];\n if (stamp !== null) stampOwn(instance._fragment, stamp);\n part._start.parentNode!.insertBefore(instance._fragment, part._end);\n return { $k: result.key, _element: null, _instance: null, _shape: null, _part: part };\n }\n const part = createMarkeredPart(parent, ref);\n part._set(value);\n return { $k: (value as TemplateResult)?.key, _element: null, _instance: null, _shape: null, _part: part };\n }\n\n /** Commits a new value into an existing item, demoting element mode if the shape changed. */\n $u(item: Item, value: unknown) {\n if (item._element !== null) {\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings === item._shape) {\n item._instance!._update((value as TemplateResult).values);\n return;\n }\n /** Shape changed: swap the bare element for a markered part in its place. */\n const part = createMarkeredPart(item._element.parentNode!, item._element);\n item._element.remove();\n item._element = null;\n item._instance = null;\n item._shape = null;\n (item._part = part)._set(value);\n return;\n }\n item._part!._set(value);\n }\n\n /** The item's first node — its move/removal handle and the insertion reference before it. */\n $f(item: Item): Node {\n return item._element ?? item._part!._start;\n }\n\n /**\n * Moving and removing an item read `_element` and `_part`, which are mangled — so they stay here\n * rather than travelling with the algorithm that calls them. `$m` and `$d` are the price: two\n * cold methods, exempt from mangling, two characters each.\n */\n $m(item: Item, ref: Node | null, parent: Node = this._start.parentNode!) {\n /**\n * **Already where it is going.** A reorder asks for many positions that are already correct,\n * and re-inserting a node that is in place is not free: it detaches and re-attaches, which\n * blurs focus, restarts a CSS transition and wakes every MutationObserver watching. The\n * relocated path below leans on this — it re-places every item rather than computing which\n * ones moved — but the ordinary two-ended diff gets the same saving.\n *\n * The item's LAST node is the one whose `nextSibling` decides this, and reading `_element` /\n * `_part._end` is why the check lives here rather than travelling with the algorithm.\n */\n const last = item._element ?? item._part!._end!;\n if (last.nextSibling === ref && last.parentNode === parent) return;\n if (item._element !== null) {\n parent.insertBefore(item._element, ref);\n return;\n }\n let node: Node | null = item._part!._start;\n const stop = item._part!._end!.nextSibling;\n while (node !== stop) {\n const next: Node | null = node!.nextSibling;\n parent.insertBefore(node!, ref);\n node = next;\n }\n }\n\n /** Removal is a move into a scratch fragment that is immediately emptied. */\n $d(item: Item) {\n if (notifyOnRemoval) detachItem(item);\n this.$m(item, null, SCRATCH);\n SCRATCH.textContent = '';\n }\n\n _commitList(newValues: unknown[]) {\n if (this._mode !== LIST) {\n if (this._mode !== EMPTY) this._clear();\n this._items = [];\n this._keyedList = false;\n this._mode = LIST;\n }\n const count = newValues.length;\n if (count === 0) {\n if (this._items!.length) {\n this._clear();\n this._items = [];\n this._mode = LIST;\n }\n return;\n }\n const isKeyed = newValues[0] != null && (newValues[0] as KeyedResult).$r !== undefined;\n if (isKeyed !== this._keyedList && this._items!.length) {\n this._clear();\n this._items = [];\n this._mode = LIST;\n }\n this._keyedList = isKeyed;\n const items = this._items!;\n const parent = this._start.parentNode!;\n\n if (items.length === 0) {\n /** Initial fill builds off-document and lands in one insert. */\n const fragment = doc.createDocumentFragment();\n for (let i = 0; i < count; i++) items.push(this.$c(newValues[i], fragment, null));\n this._insert(fragment);\n return;\n }\n\n if (!isKeyed) {\n // index mode: update in place, grow at the end, shrink from the end\n const shared = items.length < count ? items.length : count;\n for (let i = 0; i < shared; i++) this.$u(items[i], newValues[i]);\n if (count > items.length) {\n const fragment = doc.createDocumentFragment();\n for (let i = items.length; i < count; i++) items.push(this.$c(newValues[i], fragment, null));\n this._insert(fragment);\n } else if (count < items.length) {\n if (notifyOnRemoval) for (let i = count; i < items.length; i++) detachItem(items[i]);\n /**\n * **Removed through the items, not by walking the range.** The walk this replaced ran from\n * the first doomed item to the last one's end and called `parent.removeChild` on each node,\n * which assumes every one of them is still a child of `parent`. `@verajs/renderer/slots`\n * moves a light host's children into the component's tree, and the walk then threw\n * `NotFoundError` out of the middle of a render — a plain `<x-card>${rows}</x-card>` losing\n * one row was enough, with no keyed list anywhere in it.\n *\n * `$m` into the scratch fragment is indifferent to where a node currently lives, and the\n * batch is dropped by one clear at the end, so the contiguous-run saving the walk was for\n * is kept.\n */\n for (let i = count; i < items.length; i++) this.$m(items[i], null, SCRATCH);\n SCRATCH.textContent = '';\n items.length = count;\n }\n return;\n }\n\n /**\n * Keyed reconciliation is not here. It lives in `@verajs/renderer/keyed`, and it arrives on\n * the values themselves — `keyed()` stamps each result with the strategy that understands it,\n * so importing the marker is what loads the algorithm. Nothing registers, nothing is wired, and\n * two strategies cannot disagree about a list because the list names its own.\n *\n * The protocol is three cold members (`$c`, `$u`, `$f`) plus a returned array. Everything a\n * strategy would otherwise have to reach for — the mode switch, the empty case, the initial\n * fill — is already done above and passed in.\n */\n this._items = (newValues[0] as KeyedResult).$r!(this, newValues, items, parent, this._end);\n }\n}\n\nconst rootParts = new WeakMap<Node, ChildPart>();\n\n/**\n * Writes a template result into a container. The renderer's imperative draw: no reactivity, no\n * lifecycle, no knowledge of components. Slots into Vera via `wire([renderer])`; core's built-in\n * `html` tag already produces the accepted shape, so no `setHtml` call is required — though\n * lit-html's `html` also works, its results being structurally identical.\n *\n * **It owns its own range and nothing else.** The first call appends a marker and anchors a root\n * part there; later calls with the same container reuse that part and walk only the value slots, so\n * nodes are updated in place rather than rebuilt. Content that was already in the container stays.\n *\n * **Named for the relationship, not the act.** It was `render` until 0.2.0, which collided with\n * core's `render` — a different function, with a different arity, that declares a *reactive*\n * template and commits a component's setup. Both were public and both were documented, so a reader\n * who knew one misread the other. `renderElement` and `renderDom` were considered and rejected: this\n * renders *into* a container, and the container is a `Node` — a shadow root and a fragment are both\n * valid, so \"element\" would be a lie in the type. Argument order is lit-html's on purpose.\n *\n * HYDRATION lives in `@verajs/renderer/hydrate` — a drop-in superset entry whose `renderInto` adopts\n * existing server-rendered children on first render. SSR apps import from there instead of here;\n * this entry carries zero hydration code.\n */\nexport const renderInto = (result: unknown, container: Node) => {\n /**\n * The container is the argument people forget, and forgetting it failed with\n * `Cannot read properties of undefined (reading 'appendChild')` — a message about the internals of\n * a function the caller never named. Everything after this line assumes a node.\n */\n if (__DEV__ && (!container || typeof (container as Node).appendChild !== 'function'))\n throw new TypeError(\n `renderInto: expected a container node as the second argument and received ${String(container)}. ` +\n `It renders *into* something — \\`renderInto(html\\`…\\`, document.body)\\`.`\n );\n if (__DEV__ && _profileHook) _profileHook(PROFILE_FRAME_START, container, null);\n let part = rootParts.get(container);\n if (part === undefined) {\n /**\n * FIRST render into this container. If it is a light element host and a 'slot' insert is\n * wired, capture its children NOW — so slot content provided before its (possibly\n * conditional) `<slot>` mounts is held rather than left visible in the host, matching native\n * \"unassigned light children do not render\". Once per container lifetime; shadow roots\n * (nodeType 11) and fragments are excluded.\n */\n /**\n * **The marker goes in FIRST, and capture is handed it as the light region's boundary.**\n *\n * This part's start marker already delimits where the render's output begins, so the boundary\n * slots needs is a node the renderer was creating anyway — the sentinel it used to append for\n * itself landed immediately before this one, two adjacent comments doing the same job. Passing\n * it removes one comment from every light host and keeps the two in step by construction: they\n * cannot drift apart if they are the same node.\n *\n * Appending before capture is safe and necessary. Safe because a comment is never a slottable,\n * so the children walk steps over it; necessary because capture LIFTS the host's children, and\n * a marker appended afterwards would land in the same place either way — this way slots has it.\n */\n const marker = comment();\n container.appendChild(marker);\n if (container.nodeType === 1) slotSeam()?._$capture$?.(container as Element, marker);\n rootParts.set(container, (part = new ChildPart(marker, null)));\n }\n /**\n * **The flush is in a `finally`, and that is not tidiness.** A render that throws after a\n * `<select>.value` has been queued but before the flush left the queue holding the element — which\n * retains it in module state, and, worse, hands the stranded value to the *next* `renderInto` call.\n * An unrelated component's render then silently changed a select it has nothing to do with.\n * Measured: a failed update left the value to be applied by the following render.\n *\n * Flushing on the way out applies it with its own pass, where it belongs, and leaves nothing\n * behind either way. The error still propagates.\n */\n _slotRoot = container;\n try {\n part._set(result);\n } finally {\n _slotRoot = null;\n flushSelects();\n }\n if (__DEV__ && _profileHook) _profileHook(PROFILE_FRAME_END, container, null);\n};\n\n// ── INTERNAL SURFACE — imported by ./hydrate.ts, never re-exported by src/index.ts ─────────────\n// The public d.ts comes from src/index.ts, and the base bundles tree-shake all of this away, so\n// nothing here reaches consumers of the base entry. The hydrate entry compiles against this exact\n// source into its own self-contained bundle, so mangled property names always agree within it.\n\n/** @internal */\nexport {\n flushSelects,\n getTemplate,\n Template,\n Instance,\n TextPart,\n ChildPart,\n AttrPart,\n IGNORED_PART,\n IGNORED,\n TEMPLATE,\n LIST,\n NODE,\n comment,\n doc,\n toText,\n isTemplateResult,\n instanceWalker,\n rootParts,\n slotSeam,\n _setProfileHook,\n PROFILE_UPDATE,\n PROFILE_CREATE,\n PROFILE_REBUILD,\n PROFILE_FRAME_START,\n PROFILE_FRAME_END,\n};\n/** @internal */\nexport type { Part, Item, TemplatePart };\n\n\n/**\n * Lists, as a registered kind rather than a branch — the built-in going through the same door a\n * package will. Moving it to `@verajs/renderer/lists` is step 5; nothing else has to change when\n * it does, which is what this shape is for.\n */\nbuiltIns.push((part, value) => {\n if (Array.isArray(value)) {\n (part as ChildPart)._commitList(value);\n return true;\n }\n if (value !== null && typeof (value as Iterable<unknown>)[Symbol.iterator] === 'function') {\n (part as ChildPart)._commitList([...(value as Iterable<unknown>)]);\n return true;\n }\n return false;\n});\n\n/**\n * Everything this renderer needs, in one entry: `wire([renderer])`.\n *\n * It registers on the `'render'` chain *and* takes the registry, because a package that both\n * provides a capability and reads one should not cost an app two lines. This replaced\n * `setRenderer`, which existed only because there was no general way to say \"this app has a\n * renderer\" — and which resolved the shadow root at registration, so a renderer wired any other\n * way silently rendered into the light DOM. That resolution lives in core's dispatch now.\n */\n/**\n * A `__DEV__`-only hint for `wire`, so the module and the raw function beside it can share a package\n * without wiring the wrong one being silent.\n *\n * A bare function has no `on`, so `wire` reads it as a connector and hands it the registry. Nothing\n * registers, nothing throws, and the page renders nothing. The marker lets `wire` name the export\n * that was meant. This mattered most when the function was called `render` and the mistake was two\n * characters wide; `renderInto` is harder to confuse, and the guard costs nothing in production.\n *\n * `$module` is deliberately generic — any package exporting a raw function next to a module of a\n * similar name can set it. Production carries neither the property nor the check that reads it.\n */\nif (__DEV__) (renderInto as unknown as { $module?: string }).$module = 'renderer';\n\nexport const renderer = {\n name: '@verajs/renderer',\n on: 'render' as const,\n fn: renderInto as never,\n priority: 50,\n /**\n * Typed against the registry `wire` actually hands over, not a narrower shape that happens to\n * describe the one lookup this makes. A structural `{ get(name: 'value'): … }` is **not**\n * assignable from `Inserts`, so `wire([renderer])` failed to compile in a consumer's project while\n * this repo's own typecheck — which reads sources, not the shipped `.d.ts` — saw nothing.\n */\n connect: (given: { get(name: never): unknown }) => {\n registry = given as { get(name: 'value' | 'slot'): unknown[] | undefined };\n },\n};\n","/**\n * @verajs/renderer/hydrate — markerless adoption of server-rendered DOM.\n *\n * Importing this module (once, anywhere) arms hydration: the renderer's first render into a\n * container that already has children adopts them as server output of the same template. Without\n * this import the renderer never carries adoption code — non-SSR apps pay nothing.\n *\n * The server serializer (@verajs/ssr) emits the SAME static strings the renderer parses into\n * its canonical template, so server DOM and canonical fragment diverge only at value slots — and\n * at adoption time the values are known. Adoption walks both trees in lockstep: statics must\n * match byte-for-byte (else bail), and at each slot the live text is split so the renderer's own\n * anchors (primed texts, marker comments) are installed into the adopted DOM. Server HTML stays\n * free of framework comments; the client repairs its anchors in. Any mismatch clears the\n * container (preserving `<style data-vm-sheet=\"styles\">` tags) and the caller renders fresh — correctness\n * never depends on the server markup.\n *\n * This entry re-exports the public API, so a CDN importmap can point `@verajs/renderer` at the\n * hydrate bundle and nothing else changes.\n */\nimport {\n getTemplate,\n Instance,\n TextPart,\n ChildPart,\n AttrPart,\n IGNORED_PART,\n IGNORED,\n TEMPLATE,\n LIST,\n NODE,\n comment,\n doc,\n toText,\n isTemplateResult,\n instanceWalker,\n rootParts,\n slotSeam,\n renderInto as baseRender,\n renderer as baseRenderer,\n declareRemovalWork,\n} from './renderer.js';\nimport type { Template, Part, Item, TemplateResult, KeyedResult } from './renderer.js';\n\nexport { hold } from './renderer.js';\nexport type { TemplateResult } from './renderer.js';\n\n/** Internal bail signal — never escapes `tryAdopt`. */\nconst MISMATCH = {};\n\n/**\n * Why the last adoption gave up, for the development warning below. Written at every `throw\n * MISMATCH` inside an `if (__DEV__)`, so a production bundle carries neither the strings nor the\n * assignments — the branches fold away with `__DEV__` and the helper goes with them.\n */\nlet why = '';\n\n/** A live node as a person would name it, for that message. */\nconst describe = (node: Node | null) =>\n node === null\n ? 'nothing'\n : node.nodeType === 1\n ? `<${(node as Element).localName}>`\n : node.nodeType === 3\n ? `the text ${JSON.stringify((node as Text).data.slice(0, 30))}`\n : node.nodeType === 8\n ? 'a comment'\n : `a ${node.nodeName} node`;\n\ntype Cursor = { parent: Node; node: Node | null; offset: number };\n\n/** Splits mid-text cursors onto a node boundary and returns the node now at the cursor. */\nconst cursorSplit = (cursor: Cursor): Node | null => {\n if (cursor.offset > 0) {\n cursor.node = (cursor.node as Text).splitText(cursor.offset);\n cursor.offset = 0;\n }\n return cursor.node;\n};\n\n/**\n * **A comment carries no rendered content, so hydration neither matches nor requires one.**\n *\n * `instanceWalker` is `ELEMENT | TEXT`, and the part indices in `_parts` are numbered by that same\n * walker — so a comment in a template's statics is structurally invisible to this walk, and cannot\n * be made visible without renumbering every part the client renderer relies on. The live DOM,\n * however, still has it: `html`<p>a<!-- note -->b</p>`` adopts as text/comment/text where the walk\n * wanted one run of text, and `<p>lead<!-- tail --></p>` leaves a child the walk never asked for.\n * Both read as a disagreement, so **every template containing an HTML comment lost hydration** —\n * the server's markup discarded and re-rendered, for markup the client had itself produced. Nothing\n * failed, because the page is correct either way; that is what the fallback is for, and why this\n * went unnoticed. What it cost was the first paint the server render was paid for.\n *\n * Stepping over them is sound rather than merely convenient: the invisibility is symmetric, so a\n * comment can differ in either direction and neither direction can change what a reader sees. This\n * is only safe because hydration is markerless — the adopted markup carries no framework comments,\n * so there is nothing here whose position is load-bearing.\n *\n * Not folded into `cursorSplit`, which also answers \"where do I insert?\" — moving an insertion point\n * past a comment would put a slot's content on the wrong side of it.\n */\nconst passComments = (cursor: Cursor) => {\n while (cursor.offset === 0 && cursor.node !== null && cursor.node.nodeType === 8) {\n cursor.node = cursor.node.nextSibling;\n }\n};\n\n/** Consumes exactly `text` from the live cursor; anything else is a mismatch. */\nconst expectText = (cursor: Cursor, text: string) => {\n let need = text;\n while (need.length > 0) {\n passComments(cursor);\n const node = cursor.node;\n if (node === null || node.nodeType !== 3) {\n if (__DEV__) why = `expected the text ${JSON.stringify(text)} and found ${describe(node)}`;\n throw MISMATCH;\n }\n const data = (node as Text).data;\n const available = data.length - cursor.offset;\n if (available === 0) {\n cursor.node = node.nextSibling;\n cursor.offset = 0;\n continue;\n }\n const take = available < need.length ? available : need.length;\n if (data.slice(cursor.offset, cursor.offset + take) !== need.slice(0, take)) {\n if (__DEV__)\n why = `expected the text ${JSON.stringify(need.slice(0, take))} and found ${JSON.stringify(data.slice(cursor.offset, cursor.offset + take))}`;\n throw MISMATCH;\n }\n need = need.slice(take);\n cursor.offset += take;\n if (cursor.offset === data.length) {\n cursor.node = node.nextSibling;\n cursor.offset = 0;\n }\n }\n};\n\n/** Claims the value's rendered text as a standalone node (splitting as needed) and returns it. */\nconst claimValueText = (cursor: Cursor, text: string): Text => {\n const at = cursorSplit(cursor);\n if (text === '') {\n /** Nothing was rendered — install a fresh primed anchor at the cursor. */\n const primed = doc.createTextNode('');\n cursor.parent.insertBefore(primed, at);\n return primed;\n }\n if (at === null || at.nodeType !== 3) {\n if (__DEV__) why = `expected a text node holding an interpolated value and found ${describe(at)}`;\n throw MISMATCH;\n }\n const node = at as Text;\n if (node.data.length > text.length) node.splitText(text.length);\n if (node.data !== text) {\n if (__DEV__) why = `an interpolated value reads ${JSON.stringify(text)} here and the markup says ${JSON.stringify(node.data)}`;\n throw MISMATCH;\n }\n cursor.node = node.nextSibling;\n cursor.offset = 0;\n return node;\n};\n\n/** Per-template canonical node list (ELEMENT | TEXT order), cached — adoption of a 100-row list\n * hits the same template 100 times. */\nconst canonicalCache = new WeakMap<Template, Node[]>();\n\nconst canonicalNodes = (template: Template): Node[] => {\n let nodes = canonicalCache.get(template);\n if (nodes === undefined) {\n nodes = [];\n instanceWalker.currentNode = template._element.content;\n let node: Node | null;\n while ((node = instanceWalker.nextNode()) !== null) nodes.push(node);\n canonicalCache.set(template, nodes);\n }\n return nodes;\n};\n\n/** Walk state shared down the adoption recursion of one instance. */\ntype AdoptState = {\n _template: Template;\n _values: unknown[];\n _valueIndex: number;\n _partIndex: number;\n _nodeIndex: number;\n _out: Part[];\n /** Taken-over slot states — parked at teardown, never committed (kept OUT of `_parts`). */\n _slotStates?: import('./renderer.js').SlotSeamState[];\n};\n\n/** The light host being hydrated — every `<slot>` in the render projects it, set once in\n * `tryAdopt` (the render container), null when no slot handler is wired. */\nlet _adoptHost: Element | null = null;\n/** Whether the default slot's assignment has been claimed (the host count is for the first one). */\nlet _defaultTaken = false;\n/**\n * Every slot binding this adoption attempt created. If the attempt BAILS, each is parked — which\n * returns the user's nodes to holding and unregisters the binding. Without it the abandoned\n * bindings stayed registered, so the clean render's own bindings ranked as later duplicates and\n * showed fallback while the user's content sat in the discarded tree: a hydration mismatch\n * silently DESTROYED slotted content, breaking this entry's promise that correctness never\n * depends on the server markup (measured).\n */\nlet _adoptedSlots: { _$park$: () => void }[] = [];\n\n/** How many values a template part consumes — for skipping the unrendered parts inside an\n * assigned slot's fallback subtree. */\nconst partValueCount = (part: { _type: number; _statics?: string[] }): number =>\n part._type === 1 ? (part._statics!.length - 1) : 1;\n\n/**\n * Account for (skip) the parts inside a canonical subtree whose DOM the server did NOT render —\n * an assigned slot's fallback. Advances the walk indices and value cursor without touching DOM,\n * so the parts AFTER the slot still line up. Walks the node's CHILDREN (the fallback), in the\n * same ELEMENT|TEXT order the walker numbers by.\n */\nconst accountSubtree = (node: Node, state: AdoptState) => {\n const parts = state._template._parts;\n for (let child = node.firstChild; child !== null; child = child.nextSibling) {\n if (child.nodeType !== 1 && child.nodeType !== 3) continue;\n state._nodeIndex++;\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n state._valueIndex += partValueCount(parts[state._partIndex]);\n state._partIndex++;\n }\n if (child.nodeType === 1) accountSubtree(child, state);\n }\n};\n\n/**\n * Reconcile a canonical `<slot>` against server-distributed DOM. Named slots take the consecutive\n * cursor nodes carrying `slot=\"name\"`; the default slot takes the host-count nodes\n * (`data-vm-slotted=\"N\"`). Found nodes are wrapped in place as a live binding (identity/state preserved);\n * an unassigned slot adopts its server-rendered fallback children normally. The slots module's\n * `_$adopt$` (off the template's own seam fn) does the registration.\n */\nconst adoptSlotElement = (canonicalSlot: Element, cursor: Cursor, state: AdoptState) => {\n const seamAdopt = (state._template._seam as unknown as {\n _$adopt$: (\n h: Element, n: string, a: Node[] | null, f: Node[], p: Node, b: Node | null, s?: Element\n ) => Part;\n })._$adopt$;\n /**\n * **The slot's OWN bindings, committed onto a per-instance element.** The server unwrapped the\n * `<slot>`, so there is no live element to adopt against — but the template's parts for it are\n * still in the parts array, and skipping them left every value after the slot reading the wrong\n * one. In practice that meant adoption failed and the whole container fell back to a client\n * render: any component whose slot carried `@slotchange`, `&ref` or `name=${…}` could not be\n * server-rendered at all.\n *\n * A shallow clone is the target rather than the canonical node, which is shared by every\n * instance of the template — committing onto that would attach one instance's listeners to all\n * of them. The clone then IS this instance's slot element, exactly as the clone in a client\n * render is, so `@slotchange` and `&ref` mean the same thing in both.\n */\n const ghost = canonicalSlot.cloneNode(false) as Element;\n const parts = state._template._parts;\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n const templatePart = parts[state._partIndex++];\n const attrPart = new AttrPart(ghost, templatePart._name!, templatePart._statics!, templatePart._present);\n state._out.push(attrPart);\n state._valueIndex = attrPart._commit(state._values, state._valueIndex, true);\n drainIgnored(state);\n }\n /** After the commit, so `<slot name=${…}>` is read as the name it actually has. */\n const name = ghost.getAttribute('name') ?? '';\n passComments(cursor);\n const parent = cursor.parent;\n\n /** Collect the server nodes assigned to this slot. */\n const assigned: Node[] = [];\n if (name !== '') {\n let node = cursorSplit(cursor);\n while (node !== null && node.nodeType === 1 && (node as Element).getAttribute('slot') === name) {\n assigned.push(node);\n cursor.node = node.nextSibling;\n node = cursorSplit(cursor);\n }\n } else if (!_defaultTaken) {\n /**\n * `\"offset,count\"` on the slot's own parent — see `SLOTTED_ATTR`. Only the count is needed\n * here (the walk is already standing in the right place); the offset is what lets a FAILED\n * adoption find these same nodes again instead of destroying them.\n *\n * `_defaultTaken` still guards: two default slots sharing a parent would otherwise both read\n * the one mark, and by native semantics only the first receives anything.\n */\n const mark = (parent as Element).getAttribute?.('data-vm-slotted');\n const count = mark === undefined || mark === null ? 0 : Number(mark.slice(mark.indexOf(',') + 1));\n if (count > 0) {\n _defaultTaken = true;\n /**\n * **The mark does not survive the page it delivered.** It describes what the SERVER emitted\n * and is meaningless the moment those nodes are adopted, so leaving it behind would put a\n * framework marker in the user's live DOM permanently — queryable, stylable, and stale.\n * `data-vm-select` sets the precedent: it is stripped before the markup even ships, with\n * a test asserting the mark must not survive.\n */\n (parent as Element).removeAttribute('data-vm-slotted');\n for (let i = 0; i < count; i++) {\n const node = cursorSplit(cursor);\n if (node === null) break;\n assigned.push(node);\n cursor.node = node.nextSibling;\n }\n }\n }\n\n if (assigned.length > 0) {\n /** Assigned: the fallback was NOT rendered, so its parts are accounted (skipped) and its\n * nodes cloned from the canonical template for live re-fallback later. */\n const before = cursor.node;\n const fallback: Node[] = [];\n for (let c = canonicalSlot.firstChild; c !== null; c = c.nextSibling)\n if (c.nodeType === 1 || c.nodeType === 3) fallback.push(c.cloneNode(true));\n accountSubtree(canonicalSlot, state);\n const seam = seamAdopt(_adoptHost!, name, assigned, fallback, parent, before, ghost);\n _adoptedSlots.push(seam as unknown as { _$park$: () => void });\n (state._slotStates ??= []).push(seam as never);\n /** An adopted seam is removal work exactly as a mounted one is — without this, a page whose\n * only seams were adopted never ran `_teardown`, and branch-away destroyed the user's\n * server-adopted content instead of parking it. See `declareRemovalWork`. */\n declareRemovalWork();\n } else {\n /** Unassigned: the server rendered this slot's fallback children — adopt them in lockstep\n * (they ARE the canonical children), then bind them as the shown fallback. */\n const fallbackStart = cursor.node;\n for (let c = canonicalSlot.firstChild; c !== null; c = c.nextSibling)\n if (c.nodeType === 1 || c.nodeType === 3) adoptNode(c, cursor, state);\n /** The fallback nodes now sit between fallbackStart and cursor.node. */\n const fallback: Node[] = [];\n for (let n = fallbackStart; n !== null && n !== cursor.node; n = n.nextSibling) fallback.push(n);\n const seam = seamAdopt(_adoptHost!, name, null, fallback, parent, cursor.node, ghost);\n _adoptedSlots.push(seam as unknown as { _$park$: () => void });\n (state._slotStates ??= []).push(seam as never);\n /** Same as the assigned branch: an unassigned seam still unregisters and re-routes at park. */\n declareRemovalWork();\n }\n};\n\n/** Adopts one canonical node (and, for elements, its subtree) against the live cursor. */\nconst adoptNode = (canonical: Node, cursor: Cursor, state: AdoptState) => {\n state._nodeIndex++;\n const parts = state._template._parts;\n\n if (canonical.nodeType === 3) {\n /** A primed empty text is a child slot; any other text is a static to match. */\n let isSlot = false;\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n isSlot = true;\n state._partIndex++;\n adoptSlot(cursor, state._values[state._valueIndex++], state._out);\n drainIgnored(state);\n }\n if (!isSlot) expectText(cursor, (canonical as Text).data);\n return;\n }\n\n /** A `<slot>` in the canonical template maps to distributed content (or fallback) in the server\n * DOM — reconciled specially — but only when a slot handler was wired at construction. */\n if (state._template._seam !== undefined && (canonical as Element).localName === 'slot') {\n adoptSlotElement(canonical as Element, cursor, state);\n return;\n }\n\n /** Element: same tag, commit its attribute parts live, then descend children in lockstep. */\n passComments(cursor);\n const live = cursorSplit(cursor);\n if (live === null || live.nodeType !== 1) {\n if (__DEV__) why = `expected <${(canonical as Element).localName}> and found ${describe(live)}`;\n throw MISMATCH;\n }\n if ((live as Element).localName !== (canonical as Element).localName) {\n if (__DEV__)\n why = `expected <${(canonical as Element).localName}> and found <${(live as Element).localName}>`;\n throw MISMATCH;\n }\n\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n const templatePart = parts[state._partIndex++];\n const attrPart = new AttrPart(live as Element, templatePart._name!, templatePart._statics!, templatePart._present);\n state._out.push(attrPart);\n /** Attributes re-set (idempotent), listeners attached, refs fired — the server could only\n * mirror form state; the client wires behavior. The `true` marks this as adoption, which is\n * what keeps a form value the reader may already have changed (see `AttrPart._commit`). */\n state._valueIndex = attrPart._commit(state._values, state._valueIndex, true);\n drainIgnored(state);\n }\n\n const inner: Cursor = { parent: live, node: live.firstChild, offset: 0 };\n let child = canonical.firstChild;\n while (child !== null) {\n if (child.nodeType === 1 || child.nodeType === 3) adoptNode(child, inner, state);\n child = child.nextSibling;\n }\n /**\n * The one place the server writes content the template does not describe: a `<textarea>`'s value\n * **is** its content, so `.value=${…}` has nowhere else to go and `@verajs/ssr` puts it there —\n * which is what shows the value to a reader with no JavaScript. The template's own statics say\n * the element is empty, so this read as foreign markup and abandoned adoption for the whole page,\n * silently: the container was cleared and re-rendered, the markup looked right, and everything\n * server rendering is for was gone.\n *\n * **Kept, not cleared.** It is the element's `defaultValue`, and it is also the only thing\n * holding the value: adoption deliberately does not write `.value` (see `AttrPart._commit`), so\n * clearing the content would empty the field it just adopted. A person who typed here before the\n * bundle landed has made the field dirty, and a dirty textarea ignores its content anyway — so\n * their text survives either way, and the server's stays as what `form.reset()` restores.\n *\n * **One of four respects in which a hydrated DOM is not byte-identical to a client-rendered one**,\n * and all four have the same cause: `@verajs/ssr` mirrors `.value`, `.checked` and `.selected` on\n * form elements into markup, because markup is the only way form state reaches the client at all.\n * The client sets those as properties and writes nothing, exactly as a browser does — so the\n * server's copy stays behind after adoption:\n *\n * | binding | hydrated | client-rendered |\n * | --- | --- | --- |\n * | `<input .value=${x}>` | `<input value=\"x\">` | `<input>` |\n * | `<input .checked=${true}>` | `<input checked=\"\">` | `<input>` |\n * | `<option .selected=${true}>` | `<option selected=\"\">` | `<option>` |\n * | `<textarea .value=${x}>` | `<textarea>x</textarea>` | `<textarea></textarea>` |\n *\n * They are defaults rather than state — what `form.reset()` restores — so the *rendered* result is\n * the same and only a reset tells them apart. `tests/hydrate-parity.test.mjs` records the list,\n * because \"the one respect\" was written here when there was one, and a reader comparing a hydrated\n * DOM against a client-rendered one needs to know which differences are meant.\n */\n if (\n inner.node !== null &&\n inner.node.nodeType === 3 &&\n inner.node.nextSibling === null &&\n canonical.firstChild === null &&\n (live as Element).localName === 'textarea'\n ) {\n inner.node = null;\n }\n\n /** Leftover live children the template does not account for = not our markup. */\n passComments(inner);\n if (inner.node !== null && !(inner.node.nodeType === 3 && (inner.node as Text).data === '' && inner.node.nextSibling === null)) {\n if (__DEV__)\n why = `<${(live as Element).localName}> contains ${describe(inner.node)}, which the template does not describe`;\n throw MISMATCH;\n }\n\n cursor.node = live.nextSibling;\n cursor.offset = 0;\n};\n\nconst drainIgnored = (state: AdoptState) => {\n const parts = state._template._parts;\n while (state._partIndex < parts.length && parts[state._partIndex]._type === IGNORED) {\n state._out.push(IGNORED_PART);\n state._valueIndex++;\n state._partIndex++;\n }\n};\n\n/** Adopts one child slot's rendered content, producing the part that will own it. */\nconst adoptSlot = (cursor: Cursor, rawValue: unknown, out: Part[]) => {\n const heldResult = (rawValue as { $h?: TemplateResult } | null)?.$h;\n const value = heldResult !== undefined ? heldResult : rawValue;\n\n /**\n * Anything the client commits as text claims text here — which is every value that is not a\n * template, a node, or an iterable. `String(value)` is what `_set` falls through to, so a `Date`,\n * an object with a `toString`, a `Promise` or a plain object all produce text on the client, and\n * `@verajs/ssr` produces the same text on the server.\n *\n * The object cases used to be a deliberate mismatch, because the server emitted nothing for them\n * and the two could not be reconciled. Once the server started matching the client, the mismatch\n * was the only thing left disagreeing.\n */\n const isText =\n value != null &&\n (typeof value !== 'object' ||\n (!isTemplateResult(value) &&\n (value as Node).nodeType === undefined &&\n typeof (value as Iterable<unknown>)[Symbol.iterator] !== 'function'));\n\n if (isText) {\n /** Claim its text and bind the fast TextPart, committed state included. */\n const textPart = new TextPart(claimValueText(cursor, toText(value)));\n textPart._value = value;\n out.push(textPart);\n return;\n }\n\n /** Structured content gets a markered ChildPart wrapped around whatever it rendered. */\n const start = comment();\n cursor.parent.insertBefore(start, cursorSplit(cursor));\n const part = new ChildPart(start, null);\n\n if (value == null) {\n /** Nothing rendered server-side; the part starts EMPTY. */\n } else if (isTemplateResult(value)) {\n part._instance = adoptInstance(getTemplate(value), value.values, cursor);\n part._shape = value.strings;\n part._mode = TEMPLATE;\n } else if ((value as Node).nodeType !== undefined) {\n /**\n * A DOM node is client-only by construction — the server has no document to have built one, so\n * it rendered nothing here and there is nothing to adopt. Inserting it at the cursor (which has\n * not moved, because no server node was claimed) puts it exactly where the end marker is about\n * to go, and leaves the part in the same state a client-side commit would.\n */\n cursor.parent.insertBefore(value as Node, cursorSplit(cursor));\n part._value = value;\n part._mode = NODE;\n } else {\n /** Everything left is an array or another iterable — text and nodes were handled above. */\n const list: unknown[] = Array.isArray(value) ? value : [...(value as Iterable<unknown>)];\n const items: Item[] = [];\n for (const entry of list) items.push(adoptItem(cursor, entry));\n part._items = items;\n /**\n * The same predicate `_commitList` uses — the presence of a strategy, not of a `key`. Two\n * spellings of \"is this list keyed\" would drift, and disagreeing about one list destroys it:\n * a mode change is what tells the renderer to throw the adopted DOM away and start over.\n */\n part._keyedList = list.length > 0 && (list[0] as KeyedResult)?.$r !== undefined;\n part._mode = LIST;\n }\n\n const end = comment();\n cursor.parent.insertBefore(end, cursorSplit(cursor));\n part._end = end;\n out.push(part);\n};\n\n/** Adopts one list item — element mode for single-root templates, markered otherwise. */\nconst adoptItem = (cursor: Cursor, value: unknown): Item => {\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings !== undefined) {\n const result = value as TemplateResult;\n const template = getTemplate(result);\n const content = template._element.content;\n const root = content.firstChild;\n if (root !== null && root.nodeType === 1 && root.nextSibling === null) {\n const liveRoot = cursorSplit(cursor);\n const instance = adoptInstance(template, result.values, cursor);\n return {\n $k: result.key,\n _element: liveRoot as Element,\n _instance: instance,\n _shape: result.strings,\n _part: null,\n };\n }\n const start = comment();\n cursor.parent.insertBefore(start, cursorSplit(cursor));\n const instance = adoptInstance(template, result.values, cursor);\n const end = comment();\n cursor.parent.insertBefore(end, cursorSplit(cursor));\n const part = new ChildPart(start, end);\n part._instance = instance;\n part._shape = result.strings;\n part._mode = TEMPLATE;\n return { $k: result.key, _element: null, _instance: null, _shape: null, _part: part };\n }\n /** Non-template item: markered part adopting its content like a nested slot. */\n const out: Part[] = [];\n adoptSlot(cursor, value, out);\n return { $k: (value as TemplateResult)?.key, _element: null, _instance: null, _shape: null, _part: out[0] as ChildPart };\n};\n\n/** Builds an Instance whose parts are bound to LIVE nodes, consuming them from the cursor. */\nconst adoptInstance = (template: Template, values: unknown[], cursor: Cursor): Instance => {\n const instance: Instance = Object.create(Instance.prototype);\n instance._parts = [];\n instance._fragment = doc.createDocumentFragment();\n const state: AdoptState = {\n _template: template,\n _values: values,\n _valueIndex: 0,\n _partIndex: 0,\n _nodeIndex: -1,\n _out: instance._parts,\n };\n drainIgnored(state);\n /** Cached walk exists for repeated templates; the recursion itself visits in the same\n * ELEMENT | TEXT document order the instance walker uses. */\n canonicalNodes(template);\n let child = template._element.content.firstChild;\n while (child !== null) {\n if (child.nodeType === 1 || child.nodeType === 3) adoptNode(child, cursor, state);\n child = child.nextSibling;\n }\n drainIgnored(state);\n if (state._partIndex !== template._parts.length) {\n if (__DEV__) why = 'the markup ran out before the template did';\n throw MISMATCH;\n }\n if (state._slotStates !== undefined) instance._slotStates = state._slotStates;\n return instance;\n};\n\n/**\n * Attempts to adopt a container's existing (server-rendered) children for `result`. Returns the\n * root part on success; null on any mismatch, leaving the caller to clean-render. Leading\n * `<style data-vm-sheet=\"styles\">` tags (the SSR style serialization) are skipped and preserved.\n */\nconst tryAdopt = (result: TemplateResult, container: Node): ChildPart | null => {\n /** Only the SSR-serialized style tags are skipped — templates may legitimately start with\n * whitespace or even their own static `<style>`, which must align against the canonical walk. */\n let first = container.firstChild;\n while (first !== null && first.nodeType === 1 && (first as Element).hasAttribute('data-vm-sheet')) {\n first = first.nextSibling;\n }\n if (__DEV__) why = '';\n const start = comment();\n container.insertBefore(start, first);\n /** The container is the light host every slot in this render projects; `_defaultTaken` resets\n * per adoption (the host count is for the first default slot). */\n _adoptHost = container.nodeType === 1 ? (container as Element) : null;\n _defaultTaken = false;\n _adoptedSlots = [];\n try {\n const cursor: Cursor = { parent: container, node: start.nextSibling, offset: 0 };\n const instance = adoptInstance(getTemplate(result), result.values, cursor);\n passComments(cursor);\n if (cursor.node !== null) {\n if (__DEV__) why = `${describe(cursor.node)} follows everything the template describes`;\n throw MISMATCH;\n }\n const part = new ChildPart(start, null);\n part._instance = instance;\n part._shape = result.strings;\n part._mode = TEMPLATE;\n return part;\n } catch (error) {\n if (error !== MISMATCH) throw error;\n /**\n * Undo every slot this attempt adopted BEFORE the container is cleared: parking returns the\n * user's nodes to holding and unregisters the binding, so the clean render that follows\n * redistributes them instead of ranking behind an abandoned binding and showing fallback.\n */\n for (const seam of _adoptedSlots) seam._$park$();\n _adoptedSlots = [];\n start.remove();\n return null;\n }\n};\n\n\n/** Mismatch cleanup lives here, not in the slim renderer: clear all but the SSR style tags. */\nconst clearPreservingStyles = (container: Node) => {\n let node = container.firstChild;\n while (node !== null) {\n /** `nextSibling` already yields `ChildNode | null`; annotating it `Node` widened it and broke\n * the assignment back into `node`, which `firstChild` typed as `ChildNode | null`. */\n const next: ChildNode | null = node.nextSibling;\n if (!(node.nodeType === 1 && (node as Element).hasAttribute('data-vm-sheet'))) container.removeChild(node);\n node = next;\n }\n};\n\n/**\n * The hydrating `render`: a drop-in for the base entry's. The first render into a container that\n * already has children adopts them; any mismatch clears (keeping `<style data-vm-sheet=\"styles\">`) and falls\n * through to a clean base render. After the first render, this IS the base render.\n */\nexport const renderInto = (result: unknown, container: Node) => {\n if (\n !rootParts.has(container) &&\n container.firstChild !== null &&\n result !== null &&\n typeof result === 'object' &&\n isTemplateResult(result as object)\n ) {\n const part = tryAdopt(result as TemplateResult, container);\n if (part !== null) {\n rootParts.set(container, part);\n return;\n }\n /**\n * **Falling back has to say so.** The page is correct either way — that is what the fallback is\n * for — but the server's markup has just been thrown away, which means every byte the server\n * spent rendering it was wasted and the one thing server rendering exists to deliver did not\n * happen. Nothing observable changes, so without this the only symptom is a slower first paint\n * that nobody attributes to anything.\n *\n * The `<textarea>` case a few screens up is the proof: adoption was abandoned *for the whole\n * page* by one element whose content the template did not describe, and the markup still looked\n * right afterwards. It was found by reading the code. React and lit both report a mismatch;\n * this said nothing at all.\n *\n * `__DEV__`-only, and the reason comes from the check that failed, so it names the first place\n * the two renders disagreed rather than announcing that they did.\n *\n * **Scoped to this container, because that is what happened.** This function runs once per\n * container, and a mismatch clears exactly one — measured: three containers, one carrying markup\n * the template does not describe, and the other two adopt their server nodes unchanged while one\n * warning prints. The message used to say \"nothing the server rendered was used\", which reads as\n * a page-wide failure and sends the reader looking for a page-wide cause: a bad doctype, a broken\n * handoff, state that differs everywhere. The truth is narrower and the message already names the\n * element, so the advice can be local.\n *\n * It also said the markup was discarded, full stop; `clearPreservingStyles` keeps\n * `<style data-vm-sheet=\"styles\">`, which is the whole reason that function exists.\n */\n if (__DEV__) {\n /**\n * **\"The page is correct\" is a promise this message must not make blindly.** The bail rescue\n * preserves everything it can PROVE is the user's: content inside `data-vm-slotted` marks,\n * the `data-vm-unassigned` carrier, and elements carrying a `slot` attribute. Real server\n * output always marks its distributed default-slot content, so on genuine deploy skew the\n * rescue is complete and the promise holds — measured, named and unnamed and bare text alike.\n * But a container holding CLIENT-side markup that was never server output has no marks, and\n * its unnamed slottables are structurally indistinguishable from the stale template output\n * being discarded — so they go with it, under a message that said everything was fine. The\n * marks are the discriminator: their total absence is exactly the shape where the promise\n * can fail, so that is when the message changes.\n */\n const unmarked =\n container.nodeType === 1 &&\n (container as Element).querySelector('[data-vm-slotted],[data-vm-unassigned]') === null;\n console.warn(\n `[vera] hydration fell back to a client render: ${why}. This container's server markup was ` +\n `discarded and rebuilt (its SSR <style> is kept), ` +\n (unmarked\n ? `and it carried none of the marks server output carries. If its children were ` +\n `CLIENT-side markup rather than this template's server output, unnamed light-slot ` +\n `content (bare text, elements without a \\`slot\\` attribute) cannot be told apart ` +\n `from the stale markup and was discarded with it — hydrate adopts existing children ` +\n `AS server output; render client-only containers with @verajs/renderer's renderInto ` +\n `instead. `\n : `so the page is correct but the server's work on this part of it was wasted. `) +\n `Other containers on the page hydrate independently and are unaffected. The two renders ` +\n `have to agree exactly — check for markup the template does not describe, or state ` +\n `settled after the server render.`\n );\n }\n /**\n * **Un-distribute before discarding.** A light host's slotted content lives INSIDE the markup\n * about to be thrown away, so clearing destroyed it: the slots fell back and the user's nodes\n * were gone from the page permanently, under a warning that said the page was still correct.\n * The slots module lifts them back out (`_$rescue$`), and re-attaching them as the host's\n * children puts it in exactly the state a first client render starts from — the clean render\n * below captures and redistributes them with no special case anywhere.\n */\n const rescued = container.nodeType === 1 ? slotSeam()?._$rescue$?.(container as Element) : null;\n clearPreservingStyles(container);\n if (rescued !== null && rescued !== undefined) for (const node of rescued) container.appendChild(node);\n }\n baseRender(result, container);\n};\n\n/** Same wire-misuse guard the base entry puts on its raw function — see renderer.ts. */\nif (__DEV__) (renderInto as unknown as { $module?: string }).$module = 'renderer';\n\n/**\n * This entry's `renderer` module, bound to the **hydrating** `renderInto`.\n *\n * It used to be a bare re-export of the base entry's descriptor, whose `fn` is the base,\n * non-adopting render — so the natural `import { renderer } from '@verajs/renderer/hydrate';\n * wire([renderer])` wired a renderer that never hydrated. The page still looked right (a first\n * render into a full container clears it and renders fresh), which made the failure silent: every\n * byte of server work discarded, nothing on screen to say so. The header's promise — point the\n * importmap at this bundle \"and nothing else changes\" — is only true now that the descriptor\n * carries this entry's own function. `connect` and the rest are shared deliberately: they operate\n * on this bundle's copy of the renderer's module state, which both functions read.\n */\nexport const renderer = { ...baseRenderer, fn: renderInto as never };\n"],"names":["hold","result","isTemplateResult","$h","MARKER","Math","random","toString","MARKER_COMMENT_DATA","doc","document","comment","data","createComment","markerWalker","createTreeWalker","instanceWalker","RAW_TEXT_TAGS","ATTR_NAME_DELIMITER","_slotRoot","Set","templateCache","WeakMap","Template","_element","_parts","constructor","type","_$litType$","markup","specs","strings","state","quote","quoteStart","rawTag","tagNameStart","isClosing","attrName","statics","pending","attrNameBefore","end","at","test","slice","i","length","segment","pos","ch","push","quoteChar","join","_type","_name","startsWith","tagName","match","endsWith","toLowerCase","name","scan","this","createElement","innerHTML","content","wrapper","firstChild","insertBefore","removeChild","currentNode","node","specIndex","parts","consumeIgnored","_index","nextNode","nodeType","element","hasAttributes","attributeName","getAttributeNames","declared","parseInt","spec","_statics","getAttribute","split","_present","hasAttribute","_node","removeAttribute","textContent","includes","pieces","p","append","primedText","createTextNode","parentNode","remove","nodeIndex","partIndex","part","undefined","seam","slotSeam","index","localName","_seam","_slots","getTemplate","template","get","set","IGNORED_PART","_commit","_values","UNSET","createMarkeredPart","parent","ref","start","ChildPart","toText","value","applyRef","callback","error","console","AttrPart","_kind","_isFullValue","_committed","_handler","_select","present","first","kind","realName","charCodeAt","_release","_$apply$","handleEvent","event","handler","call","values","adopting","joined","liveTarget","pendingSelects","setAttribute","target","toggleAttribute","addEventListener","notifyOnRemoval","self","SCRATCH","createDocumentFragment","OWN_DESCRIPTOR","enumerable","configurable","writable","stampOwn","Object","defineProperty","child","nextSibling","detachItem","item","_instance","_teardown","_part","_detach","Instance","_fragment","importNode","templateParts","templatePart","TextPart","slotRecords","slotNodes","_pendingSlots","_upgraded","_slotStates","forEach","_$park$","_update","valueIndex","_mountSlots","root","slot","_text","_value","text","_set","home","_$home$","_mode","TEXT","registry","slotsWired","noHandlers","builtIns","declareRemovalWork","_start","_end","_shape","_items","_keyedList","_held","_applierState","_applier","_insert","_$hosted$","_$detach$","items","_clear","$m","Array","isArray","previousSibling","next","appendChild","_$commit$","applierState","applier","heldResult","_commitHeld","instance","childNodes","handlers","applyChild","_$child$","previous","String","held","Map","fragment","$c","stamp","rootNode","$k","key","$u","$f","last","stop","$d","_commitList","newValues","count","isKeyed","$r","shared","rootParts","renderInto","container","marker","_$capture$","queued","flushSelects","Symbol","iterator","renderer","on","fn","priority","connect","given","MISMATCH","cursorSplit","cursor","offset","splitText","passComments","canonicalCache","_adoptHost","_defaultTaken","_adoptedSlots","accountSubtree","_template","_nodeIndex","_partIndex","_valueIndex","adoptNode","canonical","isSlot","adoptSlot","_out","drainIgnored","need","available","take","expectText","canonicalSlot","seamAdopt","_$adopt$","ghost","cloneNode","attrPart","assigned","mark","Number","indexOf","before","fallback","c","fallbackStart","n","adoptSlotElement","live","inner","rawValue","out","textPart","primed","claimValueText","adoptInstance","list","entry","adoptItem","liveRoot","create","prototype","nodes","canonicalNodes","has","tryAdopt","rescued","_$rescue$","clearPreservingStyles","baseRender","baseRenderer"],"mappings":"AAsCO,MCkDMA,EAAWC,GACZ,MAAVA,GAAoC,iBAAXA,GAAuBC,EAAiBD,GAC7D,CAAEE,GAAIF,GACNA,EAOAG,EAAS,MAAyB,IAAhBC,KAAKC,WAAoB,GAAGC,SAAS,IAAM,IAE7DC,EAAsB,IAAMJ,EAE5BK,EAAMC,SACNC,EAAU,CAACC,EAAO,KAAOH,EAAII,cAAcD,GAQ3CE,EAAeL,EAAIM,iBAAiBN,EAAK,KAQzCO,EAAiBP,EAAIM,iBAAiBN,EAAK,GAmB3CQ,EAAgB,qDAehBC,EAAsB,YAyU5B,IAAIC,EAAyB,KAGN,IAAIC,IAA3B,MA8EMC,EAAgB,IAAIC,QAE1B,MAAMC,EACJC,EACAC,EAAyB,GAqBzB,WAAAC,CAAYzB,GACV,MAAM0B,EAAO1B,EAAO2B,YAAc,GAC5BC,OAAEA,EAAMC,MAAEA,GA3XP,CAACC,IACZ,MAAMD,EAAgB,GACtB,IAAID,EAAS,GACTG,EA9CU,EA+CVC,EAAQ,GACRC,EAAa,EACbC,EAAS,GACTC,EAAe,EACfC,GAAY,EAWZC,EAAW,GACXC,EAAoB,GACpBC,EAAU,GAGd,MAAMC,EAAkBC,IACtB,IAAIC,EAAKD,EACT,KAAOC,EAAK,IAAMzB,EAAoB0B,KAAKf,EAAOc,EAAK,KAAKA,IAC5D,OAAOd,EAAOgB,MAAMF,EAAID,EAAI,EAG9B,IAAK,IAAII,EAAI,EAAGA,EAAIf,EAAQg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J,GAqE3B,MAAMmO,EAAiC,IAAvBxE,EAAUrL,SAAiB6B,KAAYiO,YAAYzE,GAAwB,KAE3F,GAjG0B,CAACA,IAC7B,IAAI3L,EAAO2L,EAAU/L,WACrB,KAAgB,OAATI,GAAe,CAGpB,MAAMwJ,EAAyBxJ,EAAKiG,YACZ,IAAlBjG,EAAKM,UAAmBN,EAAiBkB,aAAa,kBAAmByK,EAAU7L,YAAYE,GACrGA,EAAOwJ,CACT,GAwFE6G,CAAsB1E,GAClBwE,QAA2C,IAAK,MAAMnQ,KAAQmQ,EAASxE,EAAUlC,YAAYzJ,EACnG,CACAsQ,EAAW7U,EAAQkQ,EAAU,EAkBlBO,EAAW,IAAKqE,EAAcnE,GAAIV"}
1
+ {"version":3,"file":"vera-renderer-hydrate.min.js","sources":["../src/dev-values.ts","../src/renderer.ts","../src/hydrate.ts"],"sourcesContent":["/**\n * `__DEV__` only: the one home for *\"is this value something an attribute can carry?\"*\n *\n * **Why it is a closed vocabulary and not a predicate.** The first design asked whether a value\n * stringifies meaningfully — `String(v) === '[object Object]'` means it lost its data. Driven\n * through 16 value shapes rather than reasoned about, that broke four ways, and the first is\n * disqualifying: `String()` THROWS on `Object.create(null)`, on `{ toString: null }`, and on any\n * object whose `toString` throws — so a diagnostic would have killed the page for an author using\n * the recommended dictionary idiom. It also passed `[\"a\",\"b\"]` as `\"a,b\"` (one junk class, if that\n * was a `class` binding) and `new Date()` as a timezone-bearing string, which is an SSR/CSR\n * divergence manufactured out of correct-looking code. And it passed `Symbol('s')` while\n * `` `${sym}` `` throws — a guard and its sink disagreeing about a single expression.\n *\n * \"Does it stringify meaningfully\" is an OPEN predicate over an unbounded, environment-dependent\n * space, and open predicates cannot be audited. So the test is inverted and closed: **primitives\n * pass; everything else is reported; anything else that should pass is a named row added on\n * evidence.** The list has exactly one member so far.\n *\n * Credit where it is due: the four breaks were found by the omni engine's session, which drove the\n * shapes rather than arguing about them, and the closed-vocabulary form is theirs.\n */\n\n/**\n * Blessed non-primitives — types whose `toString` IS the value the author means.\n *\n * Tested by brand rather than `instanceof`, which is false across realms: a `URL` built in an\n * iframe is not `instanceof` the parent's `URL`, and a diagnostic that fires on a correct value in\n * one frame and not another is worse than none.\n */\nconst brand = (value: object) => Object.prototype.toString.call(value);\n\n/** One message per element+name+kind, so a value rebuilt every render does not flood the console. */\nlet reported: Set<string> | undefined;\n\n/**\n * Returns the complaint, or `null` when the value is fine. Never throws — the shapes that break a\n * naive guard are exactly the ones worth reporting, so they reach the `object` arm and are named.\n */\nexport const attributeValueComplaint = (tag: string, name: string, value: unknown): string | null => {\n const type = typeof value;\n if (type === 'string' || type === 'number' || type === 'boolean' || type === 'bigint') return null;\n if (type === 'object' && brand(value as object) === '[object URL]') return null;\n\n /**\n * Keyed by BRAND, not by `typeof` — `Date`, `Array` and a plain object are all `'object'`, so a\n * coarser key reported whichever arrived first and silently swallowed the rest. An author who\n * fixed the Date would never have been told about the array.\n */\n const key = `${tag}|${name}|${type === 'object' ? brand(value as object) : type}`;\n reported ??= new Set();\n if (reported.has(key)) return null;\n reported.add(key);\n\n /**\n * A function into an attribute is never what the author meant, but the REASON matters: on a\n * custom element the Lit-era convention is that complex values are set as properties, so\n * `<my-chart formatter={fn}>` is a coherent intention that this sink simply cannot express. The\n * message names the binding that can, rather than blaming the author.\n */\n const said = type === 'function'\n ? `a function, which becomes its own SOURCE TEXT`\n : type === 'symbol'\n ? `a symbol, which every DOM conversion refuses`\n : Array.isArray(value)\n ? `an array, which becomes its members joined by commas`\n : brand(value as object) === '[object Date]'\n ? `a Date, whose text carries the TIMEZONE of whichever side rendered it`\n : `an ${type}, which cannot survive as text`;\n\n /**\n * Returned WITHOUT the `[vera]` prefix, which each call site writes as a literal.\n * `tests/diagnostics-convention.test.mjs` reads the prefix off the call, so a message handed over\n * as a variable is invisible to it — and its answer to that is an allowance list. Taking the\n * allowance would have excused these two calls rather than checked them, which is the\n * reclassification this audit keeps refusing; the literal at the call site is what every other\n * diagnostic in the repo does anyway.\n */\n return (\n `renderer: the attribute \\`${name}\\` on <${tag}> was given ${said}. ` +\n `An attribute value is a string and nothing else.\\n` +\n `If the element is meant to RECEIVE this value, bind a property instead — \\`.${name}=\\${value}\\` ` +\n `— which is how a custom element takes anything that is not text. If it is meant to be read as ` +\n `text, convert it where you know what it means: \\`date.toISOString()\\`, \\`list.join(' ')\\`. ` +\n `A Date in particular serializes with the SERVER's timezone on one side and the browser's on ` +\n `the other, so it will not survive hydration.`\n );\n};\n","/**\n * @verajs/renderer — a ground-up, keyed, template-identity renderer.\n *\n * Replaces the Reef-derived renderer, which flattened every template to an HTML string and\n * re-parsed it on each change — O(whole template) work for a one-row edit, measured at 85 ms for a\n * two-row swap that lit-html does in 3.5 ms.\n *\n * The architecture here is the one that wins that benchmark:\n *\n * 1. A tagged template literal's `strings` array is frozen and IDENTICAL for every call from the\n * same call site, so it is a cache key for the template's static shape. The shape is parsed\n * ONCE into a `<template>` element with markers where the expressions go.\n * 2. Rendering clones that template and binds \"parts\" to the marker positions. Every later render\n * of the same shape only compares and commits the dynamic values — static content is never\n * touched again.\n * 3. Arrays reconcile KEYED (see `keyed()`), with head/tail fast paths and map-based moves, so a\n * reorder moves nodes instead of rebuilding them.\n *\n * Built in, where lit-html requires directive imports: keyed list reconciliation (`keyed`),\n * element refs (element-position expressions), toggled-DOM preservation (`hold`), and a\n * whole-range fast clear — one `textContent = ''` where lit removes thousands of nodes one at a\n * time. Like-for-like (lit-html + repeat + ref + cache: 5 021 B gzip), this file is ~28% smaller.\n *\n * What it deliberately does NOT have, which is why it is smaller than lit-html: no directive\n * protocol, no `noChange`/`nothing` sentinels (in a single-expression attribute, `null`/`undefined`\n * REMOVE the attribute; in a child, they clear it), no sanitizer indirection, no async parts, no\n * dev-mode branches.\n *\n * Known limits, deliberate and shared with lit-html's envelope: no bindings inside comments (the\n * value is consumed and ignored), no dynamic tag names, and nested `<template>` elements' contents\n * are not traversed.\n *\n * CONTRACTS THE SPEED PAYS FOR — these are the trade, documented rather than discovered:\n *\n * - **The renderer owns its container below the mount point.** The whole-range fast clear wipes\n * everything in a parent the part fully owns, including nodes user code appended there by hand\n * (lit-html would preserve them). Same contract as mounting Vue or React into a container.\n * - **Do not call `Node.normalize()` on rendered content.** Child anchors are text nodes, and\n * normalize merges adjacent text — lit-html's comment anchors are immune to this; ours are not.\n * - **A plain string renders as text, never as HTML.** The Reef renderer parsed strings as markup;\n * this one has no innerHTML sink at all (an XSS class removed). The deliberate escape hatch for\n * trusted markup is a property binding: `.innerHTML=${trusted}`.\n * - **Hydration is automatic and markerless.** The first render into a container that already has\n * children adopts them as server output of the same template (statics matched byte-for-byte,\n * anchors installed by splitting live text at known value positions), falling back to a clean\n * render on any mismatch. Requires the initial client render to match server state — same\n * contract as React/Vue hydration.\n * - **No directive protocol.** The template language itself is closed to extension — Vera extends\n * at the framework layer (inserts) and through element refs, not inside the renderer's value\n * handling.\n * - Event handlers are invoked with `this` bound to the ELEMENT (lit binds its host).\n *\n * NAMING NOTE: internal class fields and methods are `_`-prefixed because the production build\n * mangles properties matching /^_[a-z]/ (see defaultRollupConfig). That is what lets this file use\n * full descriptive names while still shipping one-letter properties — locals and top-level names\n * are mangled by default anyway, but property names are not. `_$litType$` and `handleEvent`\n * deliberately do not match the pattern: the first is an interop wire format, the second is called\n * by the DOM itself.\n */\n\nimport { attributeValueComplaint } from './dev-values.js';\n\nimport type { Part, SlotSeamState, TemplateResult } from './types.js';\n\nexport type { Part, SlotSeamState, TemplateResult } from './types.js';\n\n\n/**\n * Preserves the DOM of templates a child position toggles away from, instead of destroying it —\n * form values, scroll positions and media playback survive the round trip (lit-html calls this\n * `cache`). Stashed DOM is parked in its instance's own fragment and re-adopted on return.\n *\n * ```js\n * html`<div>${hold(editing ? editor() : viewer())}</div>`\n * ```\n *\n * **Anything that is not a template passes straight through.** There is nothing to park for a\n * string, a list, `null` or `false`, and the branch that produces one is the ordinary shape of the\n * expression this wraps — `hold(editing && editor())`, `hold(row ?? null)`. Wrapping those handed\n * the renderer a `{ $h }` carrying a non-template, which reached the held-commit path and threw on\n * `result.strings`: a whole render lost, from a value the same expression renders happily one\n * character to the left. Decided here rather than in the renderer so the hot path pays nothing.\n */\nexport const hold = <T>(result: T): T | { $h: TemplateResult } =>\n result != null && typeof result === 'object' && isTemplateResult(result)\n ? { $h: result as TemplateResult }\n : result;\n\n/**\n * Unique per module load, so user text can never collide with it. Randomness here cannot break\n * template caching — the marker only ever pairs a scan with its own Template construction.\n */\n// eslint-disable-next-line no-bitwise -- >>> 0 is the integer truncation, not arithmetic\nconst MARKER = '$v' + ((Math.random() * 1e9) >>> 0).toString(36) + '$';\n/** `<?xyz>` parses as a bogus comment whose data is `?xyz`. */\nconst MARKER_COMMENT_DATA = '?' + MARKER;\n\nconst doc = document;\nconst comment = (data = '') => doc.createComment(data);\n\n/**\n * One walker for every template construction, re-aimed by assigning `currentNode`. Traversal of a\n * detached fragment cannot escape it — ascent stops at a null parent — and no walk is ever\n * re-entered mid-flight: an inner instantiation only begins after the outer walk has finished\n * collecting its parts.\n */\nconst markerWalker = doc.createTreeWalker(doc, 129 /* ELEMENT | COMMENT */);\n/**\n * Second shared walker for indexing and instantiation. Templates ship with NO marker comments —\n * every child slot's anchor is its primed text node — so instances index over elements and texts.\n * Marker comments exist only transiently during template construction, and are created lazily at\n * runtime only if a slot upgrades from text to template/array content. Sharing the walker saves a\n * TreeWalker allocation per instance, which is 10 000 allocations in a 10 000-row create.\n */\nconst instanceWalker = doc.createTreeWalker(doc, 5 /* ELEMENT | TEXT */);\n\n/**\n * Elements whose children a parser reads as **text**, so a marker written inside one arrives as\n * characters rather than a comment and the binding never becomes a part.\n *\n * `iframe` and `noscript` were missing, and both were measured broken in a browser rather than\n * reasoned about: `html\\`<iframe>${v}</iframe>\\`` painted the literal marker — `<?$v8hpsho$>` — onto\n * the page in **all three engines** and never updated.\n *\n * **`noscript` is the one worth the comment, because the engines disagree.** A template's contents\n * are parsed with the scripting flag *disabled*, which is what decides whether `noscript` is raw\n * text — and Chromium and WebKit parse it as markup there while Firefox parses it as text. So\n * `html\\`<noscript>${v}</noscript>\\`` worked in two engines and painted the marker in the third: an\n * app developed in Chrome shipping the framework's internals onto the page for Firefox users.\n *\n * Listing it here is safe in both parses. Where the marker became a comment the raw-text branch does\n * not trigger, because it looks for the marker in `textContent` and finds none.\n */\nconst RAW_TEXT_TAGS = /^(?:script|style|textarea|title|iframe|noscript)$/i;\n\n/**\n * The void elements, as a regex rather than the `Set` in `@verajs/shared-utils`, and NOT imported\n * from it — measured: an imported `new Set([...])` survives production because neither rollup nor\n * terser can prove the constructor call is side-effect-free, so it sat at module scope costing\n * **62 B gzipped on the base bundle** for a diagnostic production does not even run. A regex\n * literal read only by `warnTagShape` goes when that dead function goes.\n *\n * So this is a second home for a fact `@verajs/shared-utils` owns, kept deliberately and in a\n * different SHAPE because a hot file's byte budget forbids the shared one. That is only acceptable\n * with an enforcer: `tests/markup-grammar-homes.test.mjs` drives this regex and the canonical set\n * against each other, member by member, in both directions.\n */\nconst VOID_TAGS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i;\nconst ATTR_NAME_DELIMITER = /[\\s\"'>=/]/;\n\n/** What an expression position turned out to be. */\nconst CHILD = 0;\nconst ATTRIBUTE = 1;\nconst IGNORED = 2; // value consumed, nothing rendered (bindings inside comments, junk positions)\n\n/**\n * `_tag` is `__DEV__` only and exists for one diagnostic: when the HTML parser DROPS the element a\n * binding was written on, the binding's marker never reaches the parsed tree, and the warning below\n * needs to name the element the author actually wrote rather than only the symptom.\n */\ntype Spec = ({ _type: 0 } | { _type: 1; _name: string } | { _type: 2 }) & { _tag?: string };\n\n/** Scanner states. */\nconst IN_TEXT = 0;\nconst IN_TAG = 1;\nconst IN_QUOTED_VALUE = 2; // a static quoted attribute value (no binding seen yet)\nconst IN_COMMENT = 3;\nconst IN_RAW_TEXT = 4; // inside <script>/<style>/<textarea>/<title>\nconst IN_BOUND_VALUE = 5; // collecting a bound attribute's statics\n\n/**\n * One pass over the template strings, producing parseable HTML with markers plus an ordered spec\n * list. Runs once per template shape, so clarity beats micro-optimisation here.\n *\n * A small state machine rather than tail regexes, because `>` inside quoted attribute values and\n * inside comments must not terminate a tag, and raw-text elements swallow markup.\n */\n/**\n * `__DEV__` only: the two ways a hand-written template describes a tree the parser will not build.\n *\n * `@verajs/jsx` normalises both at compile time, so this is the channel for the BUILDLESS path —\n * which is this framework's baseline, not its fallback, and was the surface left broken when the\n * compiler fix landed. It reaches the browser console on the client and during hydration; a\n * server-only render never runs this scanner, so an SSR page that is never hydrated is not covered.\n *\n * The self-close test is `markup` ending in `/`, which is the same approximation the raw-text\n * branch below already makes: an unquoted attribute value ending in a slash (`<div data-x=a/>`)\n * reads the same way. That is not a false positive in any way that matters — measured, such a tag\n * is an OPEN tag too and swallows what follows it exactly as `<div/>` does, so both the warning and\n * the fix it names are correct for it.\n */\nconst warnTagShape = (tag: string, closing: boolean, selfClosed: boolean) => {\n if (!closing && selfClosed && !VOID_TAGS.test(tag))\n console.warn(\n `[vera] renderer: <${tag}> is left OPEN by this template, so everything after it becomes its ` +\n `child rather than its sibling. HTML has no self-closing syntax outside <svg> and <math> — ` +\n `\\`<${tag} />\\` is an open tag, not an empty element. Write \\`<${tag}></${tag}>\\`. ` +\n `(@verajs/jsx rewrites this for you; a hand-written template has to say it.)`\n );\n else if (closing && VOID_TAGS.test(tag))\n console.warn(\n `[vera] renderer: \\`</${tag}>\\` is read by the parser as ANOTHER <${tag}>, so this template ` +\n `renders two where it describes one. A void element has no end tag — write \\`<${tag}>\\` alone.`\n );\n};\n\nconst scan = (strings: TemplateStringsArray, type = 1) => {\n const specs: Spec[] = [];\n let markup = '';\n let state = IN_TEXT;\n let quote = '';\n let quoteStart = 0; // markup index of the opening quote while IN_QUOTED_VALUE\n let rawTag = ''; // which raw-text element we are inside\n let tagNameStart = 0; // markup index where the current tag's name begins\n let isClosing = false;\n /**\n * `__DEV__` only. Depth of `<svg>`/`<math>` nesting, because foreign content is the one place the\n * parser DOES honour XML self-closing, so neither warning applies inside it. An `svg`/`mathml`\n * template is already inside one, hence the seed from `type`.\n *\n * `<foreignObject>` re-enters HTML content and is deliberately not tracked: suppressing a warning\n * there is a missed warning, while tracking it wrongly would be a wrong one, and a diagnostic\n * that cries wolf is worse than one that stays quiet.\n */\n let foreign = type === 1 ? 0 : 1;\n let attrName = '';\n let statics: string[] = [];\n let pending = ''; // the static chunk currently being collected IN_BOUND_VALUE\n\n /** Backscan an attribute name that ends at `end` (exclusive); '' when malformed. */\n const attrNameBefore = (end: number) => {\n let at = end;\n while (at > 0 && !ATTR_NAME_DELIMITER.test(markup[at - 1])) at--;\n return markup.slice(at, end);\n };\n\n for (let i = 0; i < strings.length; i++) {\n const segment = strings[i];\n let pos = 0;\n while (pos < segment.length) {\n const ch = segment[pos];\n if (state === IN_BOUND_VALUE) {\n if (\n ch === quote ||\n (quote === '' && (ch === ' ' || ch === '\\t' || ch === '\\n' || ch === '\\r' || ch === '>' || ch === '/'))\n ) {\n /**\n * The bound attribute closes. Emit a marker attribute whose VALUE carries the statics\n * joined by the marker — reading them back from the parsed attribute means entities\n * arrive decoded, exactly as a static attribute would.\n */\n statics.push(pending);\n const quoteChar = quote || '\"';\n markup += ` ${specs.length}${MARKER}=${quoteChar}${statics.join(MARKER)}${quoteChar}`;\n specs.push(\n __DEV__\n ? { _type: ATTRIBUTE, _name: attrName, _tag: markup.slice(tagNameStart).match(/^[a-zA-Z][^\\s/>]*/)?.[0] }\n : { _type: ATTRIBUTE, _name: attrName }\n );\n state = IN_TAG;\n if (quote !== '') pos++; // consume the closing quote; unquoted terminators reprocess IN_TAG\n continue;\n }\n pending += ch;\n pos++;\n } else if (state === IN_TEXT) {\n if (ch === '<') {\n if (segment.startsWith('!--', pos + 1)) {\n state = IN_COMMENT;\n markup += '<!--';\n pos += 4;\n continue;\n }\n isClosing = segment[pos + 1] === '/';\n tagNameStart = markup.length + (isClosing ? 2 : 1);\n state = IN_TAG;\n }\n markup += ch;\n pos++;\n } else if (state === IN_TAG) {\n if (ch === '\"' || ch === \"'\") {\n quote = ch;\n quoteStart = markup.length;\n state = IN_QUOTED_VALUE;\n } else if (ch === '>') {\n const tagName = markup.slice(tagNameStart).match(/^[a-zA-Z][^\\s/>]*/)?.[0] ?? '';\n if (__DEV__) {\n const lower = tagName.toLowerCase();\n const selfClosed = markup.endsWith('/');\n if (lower === 'svg' || lower === 'math') foreign += isClosing ? -1 : selfClosed ? 0 : 1;\n else if (foreign < 1) warnTagShape(tagName, isClosing, selfClosed);\n }\n if (!isClosing && RAW_TEXT_TAGS.test(tagName) && !markup.endsWith('/')) {\n rawTag = tagName.toLowerCase();\n state = IN_RAW_TEXT;\n } else {\n state = IN_TEXT;\n }\n }\n markup += ch;\n pos++;\n } else if (state === IN_QUOTED_VALUE) {\n if (ch === quote) state = IN_TAG;\n markup += ch;\n pos++;\n } else if (state === IN_COMMENT) {\n if (ch === '-' && segment.startsWith('->', pos + 1)) {\n markup += '-->';\n pos += 3;\n state = IN_TEXT;\n continue;\n }\n markup += ch;\n pos++;\n } else {\n // IN_RAW_TEXT\n if (\n ch === '<' &&\n segment.slice(pos + 1, pos + 2 + rawTag.length).toLowerCase() === '/' + rawTag &&\n (pos + 2 + rawTag.length >= segment.length || /[\\s/>]/.test(segment[pos + 2 + rawTag.length]))\n ) {\n isClosing = true;\n tagNameStart = markup.length + 2;\n state = IN_TAG;\n }\n markup += ch;\n pos++;\n }\n }\n\n // ── expression boundary ──────────────────────────────────────────────────\n if (i === strings.length - 1) break;\n if (state === IN_TEXT) {\n markup += `<?${MARKER}>`;\n specs.push({ _type: CHILD });\n } else if (state === IN_RAW_TEXT) {\n markup += MARKER; // a text marker; comments cannot be parsed inside raw-text elements\n specs.push({ _type: CHILD });\n } else if (state === IN_COMMENT) {\n specs.push({ _type: IGNORED }); // binding inside a comment: consumed, ignored\n } else if (state === IN_BOUND_VALUE) {\n statics.push(pending); // this attribute spans another expression\n pending = '';\n } else if (state === IN_QUOTED_VALUE) {\n // expression inside a quoted attribute value -> becomes a bound attribute\n const name = markup[quoteStart - 1] === '=' ? attrNameBefore(quoteStart - 1) : '';\n if (name) {\n attrName = name;\n statics = [markup.slice(quoteStart + 1)]; // the static prefix already inside the quotes\n pending = '';\n markup = markup.slice(0, quoteStart - 1 - name.length); // cut `name=\"` back out\n state = IN_BOUND_VALUE;\n } else {\n specs.push({ _type: IGNORED });\n }\n } else {\n // IN_TAG: `name=${x}` unquoted, or an element-position expression\n const name = markup.endsWith('=') ? attrNameBefore(markup.length - 1) : '';\n if (name) {\n attrName = name;\n statics = [''];\n pending = '';\n quote = '';\n markup = markup.slice(0, markup.length - 1 - name.length);\n state = IN_BOUND_VALUE;\n } else {\n /**\n * Element-position expression — an element REF, not a no-op. Marked exactly like a bound\n * attribute ('&' cannot begin a real attribute binding), so no new machinery exists for it.\n */\n if (__DEV__ && (markup.endsWith('<') || markup.endsWith('</'))) {\n /**\n * Except in **tag position**, where it is a mistake with no useful reading. `<${name}>`\n * lands here because the tag has no name yet, and what the parser then makes of a ref on\n * a nameless element is escaped punctuation. Naming the entry that does support it is\n * more use than an element ref nobody asked for.\n */\n console.error(\n `[vera] an expression in tag position (\\`<\\${…}>\\`) is not a dynamic tag name — the ` +\n `template has no element there and the markup around it is rendered as text.\\n` +\n `Runtime tag names live in @verajs/renderer/tag:\\n\\n` +\n ` import { html, tag } from '@verajs/renderer/tag';\\n` +\n ` const heading = tag\\`h1\\`;\\n` +\n ` html\\`<\\${heading}>…</\\${heading}>\\`\\n`\n );\n }\n /**\n * **And in attribute-*name* position, which is the same mistake one step along.**\n *\n * `<b ${name}=\"x\">`, `<b data-${name}=\"1\">` and `<b a${name}b=\"1\">` all land here: the\n * marker is not preceded by `=`, so it reads as an element ref, and the `=\"x\"` after it\n * stays literal markup. The browser's parser then makes `<b =\"x\"=\"\">` of it — attributes\n * nobody wrote, silently.\n *\n * **The server already refuses this**, and said so in its README while the client shipped\n * the garbage. A developer rendering only in a browser saw malformed output with no clue,\n * and adding SSR later turned it into a throw with no obvious connection.\n *\n * Told apart from a real element ref by what follows it: a ref is always followed by\n * whitespace, `>` or `/`. Anything else means the marker landed inside a name.\n */\n const after = strings[i + 1] ?? '';\n if (__DEV__ && after !== '' && !/^[\\s>/]/.test(after)) {\n console.error(\n `[vera] an expression in attribute-name position (\\`<b \\${…}=\"x\">\\`) is not a dynamic ` +\n `attribute name — a marker is not a name, and the parser makes attributes nobody ` +\n `wrote out of what follows it.\\n` +\n `Runtime-named bindings live in @verajs/renderer/spread:\\n\\n` +\n ` import { spread } from '@verajs/renderer/spread';\\n` +\n ` html\\`<b \\${spread({ [name]: 'x' })}>…</b>\\`\\n`\n );\n }\n markup += ` ${specs.length}${MARKER}=\"${MARKER}\"`;\n specs.push({ _type: ATTRIBUTE, _name: '&' });\n }\n }\n }\n return { markup, specs };\n};\n\n/** A part's position and shape inside a Template, resolved to a node index for instantiation. */\ntype TemplatePart = {\n _type: 0 | 1 | 2;\n _index: number;\n _name?: string;\n _statics?: string[];\n /** Whether the template statically writes an attribute of the same name — see `AttrPart._commit`. */\n _present?: boolean;\n _node?: Node; // only during construction, carrying identity between the two passes\n};\n\n/**\n * THE LIGHT-SLOTS SEAM. `@verajs/renderer/slots` registers one of these through core's `wire` on\n * the `'slot'` insert point; the renderer reads it from the registry `connect` was handed — the\n * app's single registry, so a CDN page loading separate bundles still meets ONE seam (the same\n * architecture the `'value'` point rides). All member names are `$`-sigiled: the mangle regex\n * cannot match them, so the contract survives production across bundle boundaries (the child-\n * applier precedent). An app that never wires it pays one registry lookup per template\n * CONSTRUCTION (once per shape) and nothing per render.\n */\n/** The registered `'slot'` insert is a plain function per wire's contract: take over one cloned\n * `<slot>` for the given root, or decline with null/undefined (native slotting proceeds). */\ntype SlotSeamFn = (slot: Element, root: Node, name: string) => SlotSeamState | null | undefined;\n/**\n * The seam function plus the members it carries for callers that are not committing a slot —\n * sigil-named, so they survive property mangling across bundle boundaries (the child-applier\n * precedent). `_$capture$` lifts a light host's children on its first render; `_$rescue$` puts\n * them back when hydration has to discard the server's markup; `_$server$`/`_$adopt$` belong to\n * SSR and the hydrate entry and are reached off the same object.\n */\ntype SlotSeam = SlotSeamFn & {\n _$capture$?: (host: Element, boundary?: Comment) => void;\n _$rescue$?: (host: Element) => Node[] | null;\n /** A captured node's host-side anchor (the light-region sentinel) — see the upgrade below. */\n _$home$?: (node: Node) => Comment | null;\n};\n/**\n * A recorded `<slot>` position — just its node index in the instance walk. Slot records live\n * BESIDE the parts array, not in it, so `_update` never iterates them and non-slot apps pay\n * nothing per render.\n *\n * The NAME is deliberately not recorded. It used to be, read off the template's static markup,\n * which made `<slot name=${…}>` a slot with no name at all: it registered as a second DEFAULT\n * slot and stole the default content while the real default slot showed its fallback. The name is\n * read from the element at mount instead, which is after its own bindings have committed.\n */\ntype SlotRecord = number;\n\n/**\n * The container of the renderInto call currently committing — how a slot part learns its root\n * (light element vs shadow root) at Instance construction. Commits are synchronous per flush, so\n * one module slot suffices (the `currentInstance` pattern); null outside renderInto (hydration's\n * adoption path constructs elsewhere and the seam stays inert there until it learns adoption).\n */\nlet _slotRoot: Node | null = null;\n\n/** See the slotless branch in `Instance`. Once per host tag, so a list cannot flood a console. */\nconst warnedSlotless = new Set<string>();\nconst warnSlotless = (root: Element) => {\n const tag = root.localName;\n if (warnedSlotless.has(tag)) return;\n warnedSlotless.add(tag);\n console.warn(\n `[vera] renderer: <${tag}> renders a \\`<slot>\\` into LIGHT DOM, but no 'slot' insert is wired — ` +\n `nothing can fill it, so it always shows its fallback, and any content the host is given for ` +\n `it sits beside the component as stray markup instead. Wire it at the app entry, BEFORE anything renders: ` +\n `\\`import { slots } from '@verajs/renderer/slots'; wire([renderer, slots])\\`. Wiring it later ` +\n `does not help a template that has already rendered — a template resolves this once, at ` +\n `construction, and is interned per call site for the life of the page.`\n );\n};\n\n/**\n * `__DEV__` only: the HTML parser dropped an element a binding was written on.\n *\n * Named where it is discovered rather than after the walk, because the SKIP knows exactly which\n * spec went missing — `specs[from]` is the casualty by construction. A post-hoc count can only\n * report the LAST unclaimed spec, which positional pairing makes the wrong element every time, and\n * pointing an author at a tag that rendered correctly is the precise failure this message exists\n * to cure.\n */\n/**\n * **A child binding directly inside `<table>` renders one shape and PARSES as another.**\n *\n * `<table>${rows}</table>` is conforming HTML — `<tbody>` is omissible — and it is the one place a\n * legal template does not survive a round trip through the platform:\n *\n * - CLIENT RENDER inserts the rows with DOM calls, which apply no parser rules: `table > tr`.\n * - The SAME markup PARSED — a server render the browser re-parses, `innerHTML`, a static file —\n * gets the implied section: `table > tbody > tr`.\n *\n * Measured, both shapes, same template. So a stylesheet written `table > tr` matches on one path\n * and not the other, and hydration discards the server's markup for that container and rebuilds it\n * (*\"expected `<tr>` and found `<tbody>`\"*) — silently in production, where this call is folded away.\n *\n * **Why this is a warning and not a repair.** Whatever is emitted, the browser re-parses it, and the\n * parser ALWAYS inserts the section — so the only shape all three paths agree on is one where the\n * section is already in the template. The framework could insert it, but that changes the DOM shape\n * of every existing client-rendered table, across the renderer AND `@verajs/ssr`'s serializer, and\n * rests on the SSR shim agreeing with browsers about implied tags. One word from the author reaches\n * the same fixed point with none of that. Owner's call, recorded rather than assumed.\n *\n * Scoped to `<table>` deliberately: `<tbody>` (from rows) and `<colgroup>` (from `<col>`) are the\n * only implied START tags reachable inside a template fragment, and both are children of `<table>`.\n * The omissible END tags — `</li>`, `</p>`, `</td>`, `</option>` and the rest — insert nothing, so\n * they round-trip correctly and are pinned doing so in `tests/dropped-element-bindings.test.mjs`.\n */\nconst warnImplicitSection = (parent: Element | null) => {\n if (parent?.localName !== 'table') return;\n console.warn(\n '[vera] renderer: a binding sits directly inside <table>, where the HTML parser inserts a ' +\n '<tbody> that a client render does not. The same template then renders as `table > tr` and ' +\n 'parses as `table > tbody > tr`, so `table > tr` selectors match on only one path and ' +\n 'hydration rebuilds this container instead of adopting it. Write the section explicitly — ' +\n '`<table><tbody>${rows}</tbody></table>` — and every path agrees.'\n );\n};\n\nconst warnDroppedBinding = (specs: Spec[], from: number, count: number) => {\n const lost = specs[from];\n const where = lost?._tag\n ? `\\`${lost._type === ATTRIBUTE ? `${lost._name}=` : ''}\\` on <${lost._tag}>`\n : 'a binding';\n console.warn(\n `[vera] renderer: ${where} never reached the parsed tree — the HTML parser DROPPED the element ` +\n `it was written on, because its parent's content model forbids it (\\`<select>\\` takes only ` +\n `options, \\`<form>\\` cannot nest, and so on).\\n` +\n `${count} binding(s) lost. The element is gone from the DOM and its binding does nothing; ` +\n `the bindings AFTER it are unaffected, because each marker carries its own index. ` +\n `(Before that they all shifted onto the wrong elements, which is why this kind of mistake ` +\n `used to surface somewhere you had not edited.)\\n` +\n `Move the element out of its parent, or use one the parent can hold.`\n );\n};\n\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\nclass Template {\n _element: HTMLTemplateElement;\n _parts: TemplatePart[] = [];\n /**\n * Present only when a 'slot' insert was wired at construction and the markup contains slots.\n *\n * `declare`, like the two below: under ES2022 class-field semantics a plain optional field is\n * DEFINED on every instance whether or not it is ever assigned, so a CONDITIONALLY assigned one\n * is weight every template pays for a case most of them do not have.\n *\n * Deliberately not applied to the fields the constructors always assign (`_element`, `_name`,\n * `_statics`, `_start`, `_end`, and the rest). Those need to exist, the saving is the same few\n * bytes, and they sit on the hot classes where changing when a property first appears can move\n * V8's hidden class — which is a measurement, not a tidy-up. If anyone takes that on, measure\n * update throughput before and after, three runs, the way the slot-mount deferral was.\n */\n declare _slots?: SlotRecord[];\n declare _seam?: SlotSeamFn;\n /** `__DEV__` only: this markup has `<slot>` and was built with no seam to hand them to.\n * `declare`, so nothing is emitted — a plain optional field is DEFINED on every instance under\n * ES2022 class-field semantics, which is production weight for a development-only check. */\n declare _slotless?: boolean;\n\n constructor(result: TemplateResult) {\n const type = result._$litType$ ?? 1;\n const { markup, specs } = scan(result.strings, type);\n this._element = doc.createElement('template');\n /** svg/mathml fragments only parse inside their root; wrap, then unwrap below. */\n this._element.innerHTML = type === 2 ? `<svg>${markup}</svg>` : type === 3 ? `<math>${markup}</math>` : markup;\n const content = this._element.content;\n if (type !== 1) {\n const wrapper = content.firstChild!;\n while (wrapper.firstChild) content.insertBefore(wrapper.firstChild, wrapper);\n content.removeChild(wrapper);\n }\n\n /**\n * Pass 1 — DISCOVER over ELEMENT | COMMENT: pair scan specs with parsed nodes in document\n * order (which is expression order), and swap every marker comment for a primed empty text\n * node. The shipped template then contains no comments at all: each clone is three nodes\n * lighter per typical row, and the primed text doubles as both anchor and first-commit target.\n */\n markerWalker.currentNode = content;\n let specIndex = 0;\n let node: Node | null;\n const parts = this._parts;\n const consumeIgnored = () => {\n while (specIndex < specs.length && specs[specIndex]._type === IGNORED) {\n parts.push({ _type: IGNORED, _index: -1 });\n specIndex++;\n }\n };\n consumeIgnored();\n while (specIndex < specs.length && (node = markerWalker.nextNode()) !== null) {\n if (node.nodeType === 1) {\n const element = node as Element;\n if (element.hasAttributes()) {\n for (const attributeName of element.getAttributeNames()) {\n if (attributeName.endsWith(MARKER)) {\n /**\n * **Each marker carries its own spec index in its NAME**, so pairing is addressed\n * rather than positional — and a marker that never arrived is visible the moment the\n * next one does. Both halves matter and neither works alone:\n *\n * - REPAIR: an element the parser drops takes its marker with it. Paired by walk\n * order, that shifted every later binding onto the wrong element, silently —\n * `html\\`<select><div title=${'${a}'}>x</div></select><b title=${'${b}'}>\\`` rendered\n * `<b title=\"a\">`. Consuming the gap keeps every surviving binding on its own\n * element; only the dropped one is lost.\n * - REPORT: the repair would otherwise SILENCE the problem, which is a correct\n * refusal with nothing to tell the author — so the skip is where the warning lives.\n */\n const declared = parseInt(attributeName, 10);\n if (declared > specIndex) {\n if (__DEV__) warnDroppedBinding(specs, specIndex, declared - specIndex);\n do parts.push({ _type: IGNORED, _index: -1 });\n while (++specIndex < declared);\n }\n /**\n * The marker attribute's value carries the statics; the REAL (case-preserved) name\n * comes from the spec — the HTML parser lowercases attribute names, which would\n * corrupt `.someProp`.\n */\n const spec = specs[specIndex++] as { _type: 1; _name: string };\n parts.push({\n _type: ATTRIBUTE,\n _index: -1,\n _name: spec._name,\n _statics: element.getAttribute(attributeName)!.split(MARKER),\n /**\n * Computed here — once per template, ever — so the first commit of a nullish\n * binding knows whether a fresh clone even carries the attribute. It usually does\n * not, and the unconditional removal this feeds cost a real DOM call per element\n * per create: 1,000 no-op `removeAttribute`s on the 1,000-row benchmark. The one\n * case that must still remove — `<b title=\"a\" title=${null}>`, where the parser\n * keeps the first duplicate — is exactly what this reads.\n */\n _present: element.hasAttribute(spec._name),\n _node: element,\n });\n element.removeAttribute(attributeName);\n consumeIgnored();\n }\n }\n }\n if (RAW_TEXT_TAGS.test(element.tagName) && element.textContent!.includes(MARKER)) {\n /**\n * Comments cannot be PARSED inside raw-text elements, but they are legal DOM once\n * created — so the scan left text markers, and here they become real marker comments.\n * The walker visits them next and they pair as ordinary child parts.\n */\n const pieces = element.textContent!.split(MARKER);\n element.textContent = '';\n for (let p = 0; p < pieces.length - 1; p++) {\n if (pieces[p]) element.append(pieces[p]);\n element.append(comment(MARKER_COMMENT_DATA));\n }\n if (pieces[pieces.length - 1]) element.append(pieces[pieces.length - 1]);\n }\n } else if ((node as Comment).data === MARKER_COMMENT_DATA) {\n specIndex++;\n const primedText = doc.createTextNode('');\n node.parentNode!.insertBefore(primedText, node);\n /** Re-aim the walker before removing the node it stands on. */\n markerWalker.currentNode = primedText;\n (node as Comment).remove();\n if (__DEV__) warnImplicitSection(primedText.parentNode as Element | null);\n parts.push({ _type: CHILD, _index: -1, _node: primedText });\n consumeIgnored();\n }\n }\n\n /**\n * **CONSERVATION OF MARKERS — the walk must claim every spec the scan emitted.**\n *\n * The loop above pairs specs with markers in document order. If the HTML parser DROPPED the\n * element a binding was written on, that marker never exists, the loop runs out of nodes early,\n * and `specIndex` stops short — and because pairing is POSITIONAL, every binding after the\n * missing one has already been handed the value of its predecessor. Measured:\n *\n * html`<select><div title=${a}>x</div></select><b title=${b}>after</b>`\n *\n * renders `<b title=\"a\">` — the value written for the `<div>`, on an unrelated element, with\n * no error anywhere. `<form>` inside `<form>` does the same. HTML's parser drops elements its\n * content model forbids, which is correct of it and invisible to everything else here.\n *\n * **This is deliberately not a content-model check.** A table of what may contain what is a\n * closed vocabulary over an open space: it catches what somebody enumerated, needs maintenance\n * as HTML evolves, and would cover the compiler only — while this counts what actually\n * happened, in JSX and hand-written templates alike, for every dropping context including the\n * ones nobody listed. The cost of knowing is one integer comparison the construction already\n * had lying around.\n *\n * The gap it cannot close, named rather than implied: a dropped element carrying NO bindings\n * loses nothing to count. That is harmless to the renderer — nothing shifts — and it is the\n * restructuring class, which `tests/jsx-tree-parity.test.mjs` records instead.\n */\n if (__DEV__ && specIndex < specs.length) {\n /** A casualty at the very END has no later marker to reveal it, so the tail is checked too. */\n warnDroppedBinding(specs, specIndex, specs.length - specIndex);\n }\n\n /** Pass 2 — INDEX over ELEMENT | TEXT, the mask instances walk with. */\n instanceWalker.currentNode = content;\n let nodeIndex = -1;\n let partIndex = 0;\n while (partIndex < parts.length && parts[partIndex]._type === IGNORED) partIndex++;\n while (partIndex < parts.length && (node = instanceWalker.nextNode()) !== null) {\n nodeIndex++;\n while (partIndex < parts.length && parts[partIndex]._node === node) {\n parts[partIndex]._index = nodeIndex;\n partIndex++;\n while (partIndex < parts.length && parts[partIndex]._type === IGNORED) partIndex++;\n }\n }\n for (const part of parts) part._node = undefined;\n\n /**\n * THE SLOT WALK — the whole template-side seam, and it runs only when a 'slot' insert is\n * wired at construction. One dedicated pass discovers `<slot>` elements AND indexes them in\n * the same ELEMENT|TEXT numbering the instance walk uses (Text has no localName, so no\n * nodeType check is needed). Passes 1 and 2 above are byte-identical to their pre-seam\n * selves: an unwired app's construction path is untouched, and its only cost is this one\n * registry lookup per template construction.\n *\n * **Resolved per TEMPLATE, and templates are cached per call site for the life of the page** —\n * so a shape first constructed before `wire([slots])` ran never gains slot support, silently.\n * That is the ordinary insert contract (wire at the app entry, beside the renderer, before\n * anything renders) and it is stated in the slots module's own docs; resolving per INSTANCE\n * instead would move a registry lookup onto the hot path for every app, which is the trade\n * this design refuses.\n */\n const seam = slotSeam();\n /**\n * **Dev-only: remember that this markup HAS slots even when nothing can distribute them.**\n * Without it the two ways of getting the wiring wrong are indistinguishable from a component\n * that simply has no slots — see the warning at the instance's slot mount.\n */\n if (__DEV__ && seam === undefined && markup.includes('<slot')) this._slotless = true;\n if (seam !== undefined) {\n instanceWalker.currentNode = content;\n let index = -1;\n while ((node = instanceWalker.nextNode()) !== null) {\n index++;\n if ((node as Element).localName === 'slot') {\n this._seam = seam;\n (this._slots ??= []).push(index);\n }\n }\n }\n }\n}\n\nconst getTemplate = (result: TemplateResult) => {\n let template = templateCache.get(result.strings);\n if (template === undefined) templateCache.set(result.strings, (template = new Template(result)));\n return template;\n};\n\n/** Anything bound to a live position: commits values[index..], returns the next value index. */\nconst IGNORED_PART: Part = { _commit: (_values, index) => index + 1 };\n\n/** Never equal to any user value, so the first commit always runs. */\nconst UNSET = {};\n\n\n/** A fresh markered part: two comments inserted before `ref` in `parent`. */\nconst createMarkeredPart = (parent: Node, ref: Node | null) => {\n const start = comment();\n const end = comment();\n parent.insertBefore(start, ref);\n parent.insertBefore(end, ref);\n return new ChildPart(start, end);\n};\n\n/**\n * Text for an attribute built from several expressions.\n *\n * `` `${value}` `` rather than `String(value)`, and the difference is exactly one case. Both are\n * ToString with hint `'string'` for everything else; `String` alone special-cases a **symbol** and\n * returns its description instead of throwing. Every single-expression binding assigns straight to\n * the DOM and gets WebIDL's `DOMString` conversion, which throws on one — so `title=${symbol}` threw\n * and `title=\"a ${symbol} b\"` quietly rendered `a Symbol(s) b`. The same sigil on the same attribute,\n * disagreeing with itself depending on whether static text sat beside it.\n */\nconst toText = (value: unknown) => (value == null ? '' : `${value}`);\n\n/** Binding kinds, resolved once from the attribute name's first character. */\nconst ATTR = 0; // plain attribute\nconst PROPERTY = 1; // .name\nconst BOOLEAN = 2; // ?name\n/**\n * `!name` — a property written from the *live* DOM rather than from what this binding last wrote.\n *\n * Numbered below `EVENT` deliberately: `kind >= EVENT` is what decides a value is passed raw rather\n * than joined from the statics, and a live binding is a property, so `!title=\"a${x}b\"` has to join\n * like every other one.\n */\nconst LIVE = 3;\nconst EVENT = 4; // @name\n/** A binding that must never write — see the `__proto__` refusal in the constructor. */\nconst REFUSED = -1;\n/** `.name` on a custom element nothing receives yet — records into `_$props$`, then becomes\n * `PROPERTY`. A distinct kind keeps the steady-state property path free of any adoption check. */\nconst PROP_ADOPT = 6;\n\n/**\n * The `PROP_ADOPT` commit, kept OUT of `_commit` so that function's size — and the JIT layout of\n * its hot `PROPERTY`/`ATTR` branches — is unchanged from before this feature. `_commit` carries one\n * dispatch line; all of this lives here, off every part's steady state.\n *\n * One question decides everything: **after the write, does anything receive this property?** An\n * accessor anywhere on the chain — the platform's own (`title`, `hidden`), a component's declared\n * one, or the pair core's `init()` defines — means the write just landed in real hands: no record,\n * and the part rejoins `PROPERTY` for good. The walk is one step when the write created an own data\n * property (nobody consumed it) and stops at the first descriptor either way, and it is what keeps\n * a platform property on a lazy tag out of the record — recording `.title` would end with the drain\n * shadowing `HTMLElement.prototype.title` and breaking it.\n *\n * An unreceived write is recorded under the sigiled expando **`_$props$`**, because two arrival\n * orders both need it: on a LAZY tag the value sits as a plain own property that the class's field\n * initializers will overwrite at upgrade (the clobber the `PROPERTY` branch only *detects*), and on\n * an EAGER one the value survives but is indistinguishable from the component's own fields by the\n * time `init()` runs. The record answers both — core's `init()` drains it, re-applying values\n * unconditionally, which repairs BOTH spellings of the clobber (`item;` and `item = default`): it\n * never asks whether a clobber happened, it asserts a bound value outranks a class default, which\n * is what props mean. Element-carried because `./spread.ts` writes the same properties from a\n * separate bundle with no shared registry — the `_$`-sigiled member is the cross-bundle channel,\n * and the recorder there is this one's deliberate twin.\n *\n * Returns the part's NEXT kind: `PROPERTY` once something receives the property or the element is\n * upgraded (its record is final — `init()` drains it in the same tick) or has no realm; `REFUSED`\n * for a getter with no setter, so the binding goes inert instead of the flipped plain write\n * throwing on the next commit; `0` to stay adopting — a dash-named element that never upgrades and\n * never receives keeps recording, so its record stays current rather than staling. The one\n * retention this leaves: a defined non-vera element with a plain data property keeps its FIRST\n * committed values in `_$props$` for its lifetime — bounded, one generation, and the part itself\n * already retains the current generation in `_committed`.\n */\nconst commitAdopt = (element: Element, name: string, value: unknown): number => {\n const el = element as unknown as Record<string, unknown>;\n /**\n * The walk comes BEFORE the write, because what the walk finds decides whether writing is even\n * legal: a SETTER receives the value (and a setter that throws is the component's own error), a\n * GETTER with no setter cannot — the old order assigned first, which in strict mode threw a raw\n * TypeError out of the render for the eager spelling of exactly the case the drain refuses by\n * name for the lazy one. Same contested state, one rule, both arrival orders — and the server's\n * `deliverProperty` applies it too. The dev warning defers to `_$adopt$` where it exists: an\n * initialized component's drain already speaks, and two voices for one binding is noise.\n */\n let carrier: object | null = el;\n while (carrier !== null) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc !== undefined) {\n if (desc.set !== undefined) {\n el[name] = value;\n return PROPERTY;\n }\n if (desc.get !== undefined) {\n /** An initialized component's receiver owns the refusal (and its channel); for anything\n * else this is the only door, so it says so itself. Either way the binding goes INERT —\n * flipping to `PROPERTY` would make the next commit's plain write throw. */\n if (el._$adopt$ !== undefined) (el._$adopt$ as (key: string, value: unknown) => void)(name, value);\n else if (__DEV__)\n console.warn(\n `[vera] renderer: <${element.localName}> declares \\`${name}\\` as a getter with no ` +\n `setter — the value bound by \\`.${name}=\\${…}\\` cannot be delivered and the binding ` +\n `is ignored. Add a setter, or stop binding it.`\n );\n return REFUSED;\n }\n break; // a data property — an own field, or an inherited default: nothing receives it\n }\n carrier = Object.getPrototypeOf(carrier);\n }\n el[name] = value;\n /**\n * An initialized component receives LIVE: `init()` left `_$adopt$` on the element, and a key it\n * has not adopted yet goes through that door — a record here would never be read again, because\n * the drain already ran. This is how a hydrated child gets the props its parent commits after\n * the child settled, and how a spread bag's conditional key arrives reactive on a live element.\n */\n if (el._$adopt$ !== undefined) {\n (el._$adopt$ as (key: string, value: unknown) => void)(name, value);\n return PROPERTY;\n }\n const record = (el._$props$ ??= {}) as Record<string, unknown>;\n const firstRecording = !Object.hasOwn(record, name);\n record[name] = value;\n /**\n * Upgrade is read off the PROTOTYPE, never off `el.constructor`: a spread bag's keys are runtime\n * data, so a bag carrying a key named `constructor` writes an own property that shadows the real\n * one, and a check that reads it would then misjudge every later commit. No property write can\n * move an element's prototype — the one assignment that could, `__proto__`, both twins refuse.\n * The realm comes from the element, as always.\n */\n const win = element.ownerDocument.defaultView as unknown as {\n HTMLElement: { prototype: object };\n customElements: CustomElementRegistry;\n } | null;\n const upgraded = win === null || Object.getPrototypeOf(el) !== win.HTMLElement.prototype;\n /**\n * **The clobber detector, for the element the drain will never reach.** A component that calls\n * `init()` has the record re-applied, so for it the pre-upgrade window is repaired; an element\n * that never drains — a plain custom element with a class field — still loses the bound value to\n * the field initializer at upgrade, exactly as before this feature, and still deserves the\n * warning. Told apart by OWNERSHIP, not by value: after the definition arrives (and, for a\n * connected element, `connectedCallback` and the drain have run synchronously inside `define()`),\n * an own accessor means the drain took the property and there is nothing to report. Identity\n * against the COMMITTED value would lie twice — a drained value reads back through the store's\n * proxy, and a value superseded by a later pre-upgrade commit differs without anything being\n * wrong — so the comparison is against the RECORD, which later recordings keep current, and the\n * subscription is installed once per (element, property), on the first recording. The registry\n * is the element's own realm's. Development only; production carries no check, no message, no\n * `whenDefined` subscription.\n */\n if (__DEV__ && win !== null && !upgraded && firstRecording) {\n const tag = element.localName;\n win.customElements.whenDefined(tag).then(() => {\n /** Ownership is asked of the whole CHAIN: the drain's own accessor, a class's prototype\n * pair the value was handed to, or a get-only surface the drain refused by name — every\n * one means the property has an owner and this closure has nothing left to report. */\n let carrier: object | null = el;\n let owned = false;\n while (carrier !== null) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc !== undefined) {\n owned = desc.get !== undefined || desc.set !== undefined;\n break;\n }\n carrier = Object.getPrototypeOf(carrier);\n }\n if (!owned && el[name] !== record[name])\n console.warn(\n `[vera] renderer: the value bound by \\`.${name}=\\${…}\\` on <${tag}> was replaced ` +\n `while the element upgraded. A class field is the usual cause: at ES2022 ` +\n `\\`${name}?: …\\` emits \\`${name};\\`, which runs during upgrade and overwrites ` +\n `whatever was set beforehand — write it \\`declare ${name}?: …\\` instead, which ` +\n `emits nothing. A component that calls init() adopts bound properties automatically ` +\n `and never sees this; this element did not. Ignore this if the component replaced ` +\n `the value on purpose.`\n );\n });\n }\n return upgraded ? PROPERTY : 0;\n};\n/**\n * Calls an element ref, and survives one that throws.\n *\n * A ref runs in the middle of committing a template's parts, so an unguarded throw left the commit\n * half applied and unwound the render that triggered it — the component's shadow root ended up\n * **empty and stayed that way**, and every later update threw at the same line. The error was\n * reported, so the only symptom was a component that had silently stopped existing.\n *\n * The same judgement `handleEvent` makes a few lines up: a mistake in code the template was handed\n * is named, not raised from inside the framework at a point where the value's origin is long gone.\n * The prefix goes on our own sentence and the error is passed alongside, so it stays filterable\n * without misattributing someone else's `Error`.\n */\nconst applyRef = (callback: (el: Element | null) => void, element: Element | null) => {\n try {\n callback(element);\n } catch (error) {\n /** The sentence is development's; production keeps the prefix and the error carries the rest. */\n if (__DEV__) console.error('[vera] an element ref threw; the render continued without it.', error);\n else console.error('[vera] ref threw', error);\n }\n};\n\nconst REF = 5; // element-position expression\n\nclass AttrPart implements Part {\n _element: Element;\n _name: string;\n _statics: string[];\n _slots: number; // how many expression values this binding consumes\n _kind: number;\n _isFullValue: boolean; // exactly one expression with no static text around it\n _committed: unknown = UNSET;\n _handler: EventListener | null = null;\n /** `<select>.value`, which cannot be applied where it is written — see `pendingSelects`. */\n _select = false;\n /** The template statically wrote this attribute, so a first nullish commit must still remove. */\n _present: boolean;\n\n constructor(element: Element, name: string, statics: string[], present = false) {\n const first = name[0];\n let kind =\n first === '.'\n ? PROPERTY\n : first === '?'\n ? BOOLEAN\n : first === '@'\n ? EVENT\n : first === '&'\n ? REF\n : first === '!'\n ? LIVE\n : ATTR;\n let realName = kind ? name.slice(1) : name;\n /**\n * **`__proto__` is not a property write, so no property binding may make one.**\n *\n * `element.__proto__ = value` hits `Object.prototype`'s `__proto__` ACCESSOR and replaces the\n * element's prototype, stripping every DOM method it has. `.__proto__=${x}` crashed out of the\n * commit with an unreadable internal error; `!__proto__=${x}` bricked the element silently and\n * the wreckage surfaced in a LATER render, naming the renderer rather than the binding. There\n * is no legitimate use, so unlike `.innerHTML` there is no spelling to point at — the binding\n * is refused and never writes.\n *\n * **The deliberate twin of `refusedSink` in `./spread.ts`**, which refuses the same name for\n * the same reason. The two entries are independent bundles and neither imports the other, so\n * the rule is copied on purpose (the repo's standing note: sigil rules live in both AttrPart\n * and spread, and a fix has to visit every copy). `tests/dangerous-binding-matrix.test.mjs`\n * fails if one of them starts refusing something the other allows.\n */\n if ((kind === PROPERTY || kind === LIVE) && realName === '__proto__') {\n kind = REFUSED;\n if (__DEV__)\n console.warn(\n `[vera] <${element.localName}> binds \\`${name}\\`, which would replace the element's own ` +\n `prototype and destroy it — no property write does this, and no use of it is legitimate. ` +\n `The binding is ignored.`\n );\n }\n /**\n * React muscle-memory, buildless: `onClick=${fn}` ≡ `@click=${fn}`. Strictly `on` + a capital —\n * all-lowercase `onclick` stays a plain attribute (legal inline-handler HTML).\n *\n * `@verajs/renderer/spread` repeats these rules rather than importing them. Sharing them through\n * `@verajs/shared-utils` was tried and reverted: the shared form has to return both the kind and\n * the name, and the tuple it allocates cost this bundle 10 B. Principle #5 allows deliberate\n * duplication where two things can legitimately diverge; here #7 decides it — weight is the\n * product, and core and the renderer are the two packages where that is absolute.\n */\n if (kind === ATTR && first === 'o' && name.charCodeAt(1) === 110 && name.charCodeAt(2) > 64 && name.charCodeAt(2) < 91) {\n kind = EVENT;\n realName = name.slice(2).toLowerCase();\n }\n /**\n * **A property write to a custom element starts as `PROP_ADOPT`**, a distinct kind so the\n * steady-state `PROPERTY` commit path stays byte-for-byte unchanged — zero added instruction\n * for every `.value=` on a built-in. Every dash-named element starts here, defined or not,\n * because the record has to exist for BOTH arrival orders: an eager component's first commit\n * lands after upgrade but before `init()` (one commit records, then the part flips), and a\n * lazy one's land before upgrade (the part records until the definition arrives). `commitAdopt`\n * decides which per commit and flips the part back to `PROPERTY` the moment something real\n * receives the property, so the window is one commit for a defined element and the pre-upgrade\n * stretch for a lazy one.\n */\n if (kind === PROPERTY && element.localName.includes('-')) kind = PROP_ADOPT;\n this._kind = kind;\n this._name = realName;\n this._element = element;\n this._statics = statics;\n this._slots = statics.length - 1;\n this._isFullValue = this._slots === 1 && statics[0] === '' && statics[1] === '';\n /** Resolved once, here, so the commit path costs one boolean rather than two comparisons. */\n this._select = kind === PROPERTY && realName === 'value' && element.localName === 'select';\n this._present = present;\n }\n\n /**\n * Releases an element ref, because the element it named is going away.\n *\n * A ref was told about attachment and never about detachment, so it kept a detached node alive and\n * a component reading `myRef.value` after a subtree was replaced got the old element back. Lit\n * passes `undefined` for the same reason.\n *\n * `null` rather than `undefined`, because `.value` is a store property and `null` reads as\n * \"deliberately nothing\" where `undefined` reads as \"never set\".\n *\n * **Reached when a subtree is rendered away, and deliberately not when a component is removed\n * from the document.** The two are the same event to a reader and not to this renderer: a\n * disconnect here is not a destruction, since moving a node between parents fires one and the\n * component renders again on reconnect. Releasing there would blank every ref for the frame a\n * move takes, and `_committed = UNSET` below means the re-apply could only happen on the next\n * pass. Measured in `tests/renderer-ref-lifetime.test.mjs`, which asserts both halves so the\n * asymmetry is a decision rather than something nobody looked at.\n *\n * A **self-applying** value is\n * skipped: `_$apply$` receives the part and owns its own lifecycle, so telling it about detachment\n * here would be a second protocol contradicting the first.\n */\n _release() {\n const value = this._committed;\n if (typeof value === 'function') applyRef(value as (el: Element | null) => void, null);\n else if (value !== null && typeof value === 'object' && (value as { _$apply$?: unknown })._$apply$ === undefined)\n (value as { value: unknown }).value = null;\n this._committed = UNSET;\n }\n\n /**\n * Stable listener; swapping one function for another never touches the DOM.\n *\n * **It is not registered exactly once, and the difference is load-bearing.** A handler set back to\n * `undefined` or `false` nulls `_handler` *without removing the listener* — inert, because\n * `handleEvent` finds nothing callable — so the next non-null value sees `_handler === null` and\n * calls `addEventListener` again. Measured: `function -> undefined -> function` registers twice.\n *\n * That is harmless only because the listener passed is **`this`, the part object itself**. The\n * platform ignores a repeated `(type, listener, capture)` triple, verified with no framework\n * involved — the same listener object added three times fires once. Pass a fresh closure here\n * instead and dedup stops applying: every toggle through null adds another live listener, silently,\n * and only in components that turn a handler off and on again.\n *\n * `tests/event-binding-fuzz.test.mjs` holds that as an invariant — it counts *fires*, not\n * `addEventListener` calls, and making this listener a closure fails it.\n *\n * **Two shapes, because `addEventListener` takes two.** A function is called with the element as\n * `this`; an object with a `handleEvent` method is invoked through it — the platform's own\n * `EventListenerObject` protocol, which every engine accepts and lit supports. This used to call\n * `.call()` unconditionally, so passing the platform's own listener shape bound successfully and\n * then threw `this._handler.call is not a function` on **every** dispatch.\n *\n * Anything else is inert rather than throwing. A truthy non-function is a mistake, and\n * development names it at the binding (see the `EVENT` branch in `_commit`) — where the mistake\n * still is. Throwing here instead would raise from inside the framework on every user click, at a\n * point where the value's origin is long gone.\n */\n handleEvent(event: Event) {\n const handler = this._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(this._element as never, event);\n else if (typeof (handler as EventListenerObject)?.handleEvent === 'function')\n (handler as EventListenerObject).handleEvent(event);\n }\n\n /**\n * `adopting` is set only by `@verajs/renderer/hydrate`, and only changes what happens to the\n * three form-value properties the server can express in markup — see the branch below.\n */\n _commit(values: unknown[], index: number, adopting?: boolean): number {\n const kind = this._kind;\n /** Refused in the constructor and never writes — it still has to consume its slots. */\n if (kind === REFUSED) return index + this._slots;\n let value: unknown;\n if (this._isFullValue || kind >= EVENT) {\n value = values[index]; // raw and uncoerced — events and refs receive the actual value\n } else {\n const statics = this._statics;\n let joined = statics[0];\n for (let i = 0; i < this._slots; i++) joined += toText(values[index + i]) + statics[i + 1];\n value = joined;\n }\n /**\n * **A live property asks the element, not its own memory.**\n *\n * Every other kind skips a write when the value matches what it last wrote. That is what keeps\n * a field someone has typed into — and it is wrong for a control whose DOM state changes as a\n * *side effect of interacting with a sibling*. Clicking one radio unchecks the others with no\n * event on them, so their bindings still say `true`, still match `_committed`, and never write\n * again: the model and the page diverge and no amount of re-rendering reconciles them. A\n * `<select>`'s options are the same shape.\n *\n * Deliberately narrow. This is not for text inputs — bind those with `.value` and let a\n * person's typing stand. `?hidden` and plain attributes are not offered either: nothing changes\n * them behind the renderer's back, so there is nothing to re-read.\n */\n if (kind === LIVE) {\n this._committed = value;\n /**\n * **Except while adopting — on a form control.** Hydration reaches a DOM a person may\n * already have used, and the click that checked a radio happened before any handler existed\n * to tell the store about it — so re-asserting the server's choice here would throw the\n * interaction away and nothing would ever put it back. Recorded, not written, exactly as\n * the other form properties are; the first state-driven render after that applies live\n * semantics normally.\n *\n * **A COMPONENT tag is the exception to the exception**: there is no user-editable carrier\n * behind `!prop` on a component — it is a property delivery spelled with `!` — and the\n * server DELIVERED it to the child's render, so yielding here dropped the one copy the\n * client would ever get and hydration regressed the child's content to its prop-less state.\n * Found by the hydration fixture on its first run. The write is unconditional and routes\n * through the element like any component prop: an accessor receives it, an initialized\n * component adopts it live.\n */\n if (__HYDRATING__ && adopting) {\n /** Routed through `commitAdopt`, not written raw: the child hydrated BEFORE this commit,\n * so only the adoption door re-runs its render. The part stays `LIVE` — the return is\n * deliberately dropped — so live semantics resume on the next state-driven render. */\n if (this._element.localName.includes('-')) commitAdopt(this._element, this._name, value);\n } else {\n const liveTarget = this._element as unknown as Record<string, unknown>;\n if (liveTarget[this._name] !== value) liveTarget[this._name] = value;\n }\n return index + this._slots;\n }\n /**\n * **A `<select>`'s value cannot be applied where it is written.**\n *\n * Assigning it selects an option, and at the moment this part commits the options may not exist:\n * parts commit in document order, so a nested `${items.map(…)}` has not run, and an `<option\n * value=${id}>` has not been given its value either. The assignment then matches nothing, and the\n * select falls back to its first option — silently showing the wrong one. Measured: a nested list\n * selected index 0 instead of 1, and dynamic option values selected nothing at all.\n * **lit-html has the same defect, byte for byte** — it was measured there too. React solves it by\n * special-casing `<select value>` and applying it after children mount, which is what this is.\n *\n * Queued rather than dirty-checked, and that is deliberate: the value can be unchanged while the\n * *options* are replaced, which drops the selection just as thoroughly. Re-asserting once per\n * render pass is what keeps it right, and a select carries one binding, so it is one push.\n */\n if (this._select) {\n this._committed = value;\n /** Adoption never re-asserts a form value — the person may have changed it. See below. */\n if (!(__HYDRATING__ && adopting)) (pendingSelects ??= []).push(this._element as HTMLSelectElement, value);\n return index + this._slots;\n }\n if (value !== this._committed) {\n if (kind === ATTR) {\n /**\n * A nullish value removes the attribute — except on the first commit of a template that\n * never statically wrote it, where a fresh clone has nothing to remove. That skip used to\n * be unconditional-removal instead, for the one case that genuinely needs it:\n * `<b title=\"a\" title=${null}>` parses keeping the first duplicate, so the binding —\n * written last, and authoritative on the server too — must clear it. `_present` is that\n * case, read off the parsed template once ever; without it the removal was a real DOM call\n * per nullish binding per element on create — 1,000 no-ops in the 1,000-row benchmark.\n */\n if (value == null) {\n if (this._present || this._committed !== UNSET) this._element.removeAttribute(this._name);\n }\n else {\n /**\n * The same question `@verajs/renderer/spread` asks at its own sink, from the same home —\n * the two are deliberately separate implementations (see spread's header on why), and a\n * diagnostic that lived in only one of them would be the very defect this audit found.\n * `setAttribute` performs the DOMString conversion itself; nothing is stringified here.\n */\n if (__DEV__) {\n const complaint = attributeValueComplaint(this._element.localName, this._name, value);\n if (complaint !== null) console.warn(`[vera] ${complaint}`);\n }\n this._element.setAttribute(this._name, value as string);\n }\n } else if (kind === PROPERTY) {\n const target = this._element as unknown as Record<string, unknown>;\n const name = this._name;\n /**\n * **Adopting a form value: record it, do not write it.**\n *\n * `value`, `checked` and `selected` are exactly the properties `@verajs/ssr` mirrors into\n * markup, so the element already holds what this binding says — *unless a person changed\n * it*, which is the entire reason to server-render: the page is usable before the bundle\n * lands, and the window between the two is where someone types their name, ticks a box or\n * picks an option. Writing the binding then threw that away, silently, on every hydrating\n * page. The part is told it already committed this value, so it stays live and the next\n * genuine state change still applies.\n *\n * Only these three, and only while adopting. A property the server cannot express — any\n * other `.prop` — is not in the DOM yet and must be written.\n */\n if (__HYDRATING__ && adopting && (name === 'value' || name === 'checked' || name === 'selected')) {\n this._committed = value;\n return index + this._slots;\n }\n /**\n * No un-upgraded custom element can be behind this write: a dash-named property part is\n * born `PROP_ADOPT` and only flips here once something receives the property, so the\n * pre-upgrade window — the clobber, its repair for components, and the `whenDefined`\n * detector for elements that never drain — lives entirely in `commitAdopt` above. History\n * worth keeping: an earlier repair was tried HERE and removed as silently partial (it\n * re-applied on `undefined`, so `item = someDefault` never looked clobbered); the record\n * the drain re-applies unconditionally is what answered that objection.\n */\n target[name] = value;\n } else if (kind === BOOLEAN) {\n /** Unconditional for the same reason: `<b hidden ?hidden=${false}>` must end up not hidden. */\n this._element.toggleAttribute(this._name, !!value);\n } else if (kind === EVENT) {\n /**\n * A listener is the most deferred call a template makes — it is validated when a *user*\n * clicks, which in development may be never. So it is checked where it is written, the same\n * rule the setters took on: the stack at dispatch no longer contains the binding.\n *\n * `false` is deliberately allowed and silent. `@click=${enabled && onClick}` is the ordinary\n * way to bind conditionally and produces exactly that, and it already behaves correctly —\n * `handleEvent` finds nothing callable and does nothing. `true` is not produced by any\n * idiom, so it is named along with strings, numbers and objects that cannot listen.\n */\n if (__DEV__ && value != null && value !== false && typeof value !== 'function' &&\n typeof (value as EventListenerObject)?.handleEvent !== 'function')\n console.warn(\n `[vera] @${this._name} on <${this._element.localName}> was given ${typeof value === 'object' ? 'an object with no handleEvent method' : `a ${typeof value}`}, ` +\n `which cannot listen — the event will do nothing.\\n` +\n `Pass a function, or an object with a handleEvent method. A missing handler is ` +\n `\\`undefined\\` or \\`false\\`, both of which are fine; this is neither.`\n );\n if (this._handler === null && value != null) this._element.addEventListener(this._name, this);\n this._handler = (value as EventListener) ?? null;\n } else if (kind === PROP_ADOPT) {\n const next = commitAdopt(this._element, this._name, value);\n if (next !== 0) this._kind = next;\n } else if (value != null) {\n /**\n * Element ref: `<input ${myRef} />`. A function is called with the element; an object gets\n * the element assigned to `.value` — which makes core's own `ref()` double as an element\n * ref, reactively. Runs once per distinct value, not once per render.\n */\n notifyOnRemoval = true;\n if (typeof value === 'function') applyRef(value as (el: Element | null) => void, this._element);\n else if (typeof value === 'object') {\n /**\n * A self-applying value: anything that knows what to do with an element applies itself.\n * `@verajs/renderer/spread` is the first, and the whole protocol is this one property\n * read — the implementation lives in that entry, so an app that never spreads pays for\n * the check and nothing else. `_$…$` is exempt from property mangling, like `_$litType$`.\n *\n * Deliberately confined to the element position, which is rare. A protocol in the text,\n * attribute or property commits would sit in the hot path every benchmark measures.\n */\n const self = value as { _$apply$?: (el: Element, part: object) => void; value: unknown };\n /** The part is passed as the ownership key: one element can carry several spreads. */\n if (self._$apply$) self._$apply$(this._element, this);\n else self.value = this._element;\n }\n // any other value type at element position is consumed and ignored\n }\n this._committed = value;\n }\n return index + this._slots;\n }\n}\n\n/**\n * `<select>.value` assignments held until the whole pass has committed — see the note in `_commit`.\n * Flat pairs rather than tuples: one array, no per-entry allocation.\n */\nlet pendingSelects: unknown[] | null = null;\n\nconst flushSelects = () => {\n const queued = pendingSelects;\n if (queued === null) return;\n /** Cleared first: an assignment can run a `change` handler that renders again. */\n pendingSelects = null;\n for (let i = 0; i < queued.length; i += 2)\n (queued[i] as HTMLSelectElement).value = queued[i + 1] as string;\n};\n\nconst SCRATCH = doc.createDocumentFragment();\n\n/**\n * Marks a node as the render root's OWN output — see `ChildPart._insert`. Sigil-named so property\n * mangling cannot rename it: this is read by `@verajs/renderer/slots`, across a bundle boundary,\n * and a module-scoped Symbol would be minted twice on a CDN page (the `@verajs/styles` lesson).\n *\n * A fragment is stamped through to its children, because inserting one moves the children and the\n * fragment itself never enters the document — the observer reports the children.\n *\n * **Defined rather than assigned, so it is NON-ENUMERABLE.** A plain `node._$own$ = true` is an own\n * enumerable property: measured, it then shows up in `Object.keys(element)` — which is `[]` for\n * every other DOM element — and in `for…in`. Invisibility to everything outside the framework is\n * the whole reason this is a property and not a marker or an attribute, and an enumerable one is\n * not invisible. The descriptor is shared, so this allocates nothing per node, and the path is\n * gated on slots being wired, so no app that does not use them ever reaches it.\n */\nconst OWN_DESCRIPTOR: PropertyDescriptor = { value: true, enumerable: false, configurable: true, writable: true };\n/**\n * The stamp is VALUED, and the value is the discriminator (`docs` in the slots module read it):\n *\n * `true` — the render root's own output: never slot content.\n * a ChildPart — light content PLACED by that part from an outer template. The part identity\n * is the ordering group: a grown row belongs after ITS part's other rows, and\n * `<host>${a}${b}</host>` must not interleave a's refill into b's content —\n * which is exactly what happens if the group is the render root, shared by both.\n * absent — an imperative user mutation; the light region orders it by document position.\n *\n * One shared, mutated descriptor: `defineProperty` reads it synchronously, so this allocates\n * nothing per node while keeping the property non-enumerable (see the invisibility note above).\n */\nconst stampOwn = (node: Node, value: true | object = true) => {\n OWN_DESCRIPTOR.value = value;\n if (node.nodeType === 11) {\n for (let child = node.firstChild; child !== null; child = child.nextSibling)\n Object.defineProperty(child, '_$own$', OWN_DESCRIPTOR);\n return;\n }\n Object.defineProperty(node, '_$own$', OWN_DESCRIPTOR);\n};\n\n/** A row is either an element-mode instance or a markered part; both can hold appliers. */\nconst detachItem = (item: Item) => {\n item._instance?._teardown();\n item._part?._detach();\n};\n\n/**\n * **These three stay here rather than in `types.ts`, and the reason is structural.**\n *\n * `ListStrategy` names the `ChildPart` class and `Item` names `Instance`, which puts both\n * downstream of this file in the import graph — a `types.ts` that imported them would stop being\n * the graph's root, which is the single property §1 asks of it. `KeyedResult` composes\n * `ListStrategy` and inherits the same position. Restating those classes structurally in\n * `types.ts` to satisfy the letter of the rule would create the twin §1 forbids, so the rule\n * records the limit instead.\n */\n\n/**\n * A value that names the strategy able to reconcile a list of its kind. `keyed()` in\n * `@verajs/renderer/keyed` is the only producer today; the shape is deliberately open so a\n * virtualizer or an async list can ship as its own module without this file learning about it.\n *\n * `$r` and the three members it calls are exempt from property mangling — they are the only names\n * that cross a bundle boundary, and they are two characters so crossing costs nothing.\n */\nexport type ListStrategy = (\n part: ChildPart,\n values: unknown[],\n items: Item[],\n parent: Node,\n end: Node | null\n) => Item[];\n\n/**\n * A `TemplateResult` that `keyed()` has marked, so the child part reconciles it as a list instead\n * of replacing the subtree. `$r` is absent on every ordinary template, which is what keeps the\n * unkeyed path free of any list machinery.\n */\nexport interface KeyedResult extends TemplateResult {\n $r?: ListStrategy;\n}\n\n/**\n * A list item is either ELEMENT-MODE — a single-root template instance whose one element IS the\n * item's boundary (`_element`/`_instance`/`_shape` set, `_part` null) — or a general markered\n * ChildPart. Rows are single-root in virtually every real list, and element mode drops both marker\n * comments and both marker inserts per item, which is exactly the per-row overhead a vdom does not\n * pay on create.\n */\ntype Item = {\n $k: unknown;\n _element: Element | null;\n _instance: Instance | null;\n _shape: TemplateStringsArray | null;\n _part: ChildPart | null;\n};\n\nclass Instance {\n _parts: Part[] = [];\n _fragment: DocumentFragment;\n /**\n * **`declare`, so nothing is emitted and no instance carries these unless it uses them.**\n * Under ES2022 class-field semantics a plain `_x?: T` is DEFINED on every instance, undefined or\n * not — measured, two such declarations cost every row of a 200-row list a property apiece and\n * showed up as a few percent off update throughput. Templates without slots now allocate exactly\n * what they did before this feature existed, and the ones with slots take a shape transition\n * once.\n *\n * `_slotStates` — taken-over slot states, parked at teardown.\n * `_pendingSlots` — resolved `<slot>` clones awaiting mount; cleared by the first `_update`.\n */\n declare _slotStates?: SlotSeamState[];\n declare _pendingSlots?: Element[];\n constructor(template: Template) {\n /**\n * `importNode`, not `cloneNode` — the difference is custom-element upgrade, not the document.\n * Template content lives in the inert template document, so `cloneNode` copies stay\n * un-upgraded until insertion; a `.prop` committed in that window lands as an OWN property\n * that permanently shadows a defined class's setter (the setter never fires — every\n * accessor-based element, Lit's included, receives a dead value) and a bound value on a\n * class-field element is clobbered by the field initializer at insert, silently, because the\n * `whenDefined` detector below only watches definitions that arrive LATE. Hydration commits\n * onto server-parsed, already-upgraded elements, so the two render paths disagreed about the\n * same template. `importNode`'s cloning steps upgrade defined elements at clone time — in\n * every engine and in jsdom — which makes the commit order match hydration and the platform.\n * Undefined elements are untouched: nothing can upgrade them, and the pre-upgrade posture\n * (own property, clobber on define, development warning) stands as pinned in\n * `tests/pre-upgrade-property.test.mjs`. Measured cost of losing `cloneNode`: ~2–7% of the\n * raw clone operation across the three engines — nanoseconds per instance.\n */\n this._fragment = doc.importNode(template._element.content, true);\n const templateParts = template._parts;\n /** Shared walker, ELEMENT | TEXT — child anchors are the primed text nodes themselves. */\n instanceWalker.currentNode = this._fragment;\n let nodeIndex = -1;\n let node: Node | null = null;\n for (let i = 0; i < templateParts.length; i++) {\n const templatePart = templateParts[i];\n if (templatePart._type === IGNORED) {\n this._parts.push(IGNORED_PART);\n continue;\n }\n while (nodeIndex < templatePart._index) {\n node = instanceWalker.nextNode();\n nodeIndex++;\n }\n this._parts.push(\n templatePart._type === CHILD\n ? new TextPart(node as Text)\n : new AttrPart(node as Element, templatePart._name!, templatePart._statics!, templatePart._present)\n );\n }\n /**\n * Slot records mount OUTSIDE the parts array — one extra walk from the top, paid only by\n * templates that HAVE slots, only inside a renderInto commit (null root — hydration's\n * adoption path — stays inert), and only when the 'slot' insert answers. Taking over sets\n * `notifyOnRemoval`: `_$park$` must rescue the USER'S nodes before a bulk `_clear` discards\n * the DOM holding them on a branch-away. `_update` never sees any of this.\n */\n if (template._seam !== undefined && _slotRoot !== null) {\n const slotRecords = template._slots!;\n /**\n * RESOLVE every slot element to its clone in ONE walk, and mount them AFTER the first\n * `_update` — see `_mountSlots`. Collect-then-act, because the seam MUTATES the fragment\n * (it lifts each `<slot>` out and drops in anchors) and a walk that interleaved resolution\n * with those mutations would read shifted indices and miss later slots.\n */\n instanceWalker.currentNode = this._fragment;\n nodeIndex = -1;\n const slotNodes: Element[] = [];\n for (let i = 0; i < slotRecords.length; i++) {\n while (nodeIndex < slotRecords[i]) {\n node = instanceWalker.nextNode();\n nodeIndex++;\n }\n slotNodes.push(node as Element);\n }\n this._pendingSlots = slotNodes;\n }\n /** Standalone rather than an `else` branch: `_slotless` is only ever set when there was no\n * seam, so the condition stands alone — and a lone `if (__DEV__ …)` folds away cleanly. */\n if (__DEV__ && template._slotless === true && _slotRoot !== null && _slotRoot.nodeType === 1) {\n /**\n * **A `<slot>` in a LIGHT render that nothing will distribute.** Both ways of arriving here\n * are silent otherwise, and both leave the same confusing picture. Measured, for a host given\n * `<b slot=\"a\">MINE</b>`:\n *\n * <b slot=\"a\">MINE</b><!----><div class=\"box\"><slot name=\"a\">FB</slot></div>\n *\n * — the content is not destroyed, it is stranded ahead of the render while the slot shows its\n * fallback. The message says \"any content the host is given\" rather than asserting the host\n * HAS some: a component that consumes its own children before rendering and also declares\n * slots — `@verajs/ui`'s select is one — warns with nothing stray on the page, and a reader\n * sent looking for markup that is not there concludes the diagnostic is confused.\n *\n * 1. `@verajs/renderer/slots` was never wired at all.\n * 2. It was wired AFTER this template first rendered. Templates are interned per call site\n * for the life of the page and resolve the seam once, at construction — so a component\n * that rendered before the wiring keeps a slotless template forever, and every later use\n * of it fails the same way. Measured: the same `draw()` distributes at a fresh call site\n * and not at this one.\n *\n * A shadow root never reaches here: the platform slots there, which is why this is gated on\n * an element root.\n */\n warnSlotless(_slotRoot as Element);\n }\n }\n\n /**\n * One walk, both jobs: release the element refs in this instance and tell any child applier\n * under it that it is going away.\n *\n * They were two walks over the same array — `_release` for refs, `_detach` for appliers — which\n * is the same tree traversed twice for two answers that arrive at the same moment. Merged, the\n * per-part cost is one `_kind` compare and one `_upgraded` read.\n *\n * Reached only when this instance's template holds a ref, or some applier somewhere declared\n * teardown. An app with neither never runs it: this is the per-node work the bulk removal exists\n * to skip, and the gate is what keeps it out of the path.\n *\n * Through `_upgraded`, not just `_parts`. A child position is instantiated as a `TextPart` and\n * **upgrades** to a `ChildPart` the first time it takes an object — so the part holding a\n * applier is almost never the one in this array, it is the one that array's entry points at.\n * Walking `_parts` alone found nothing at all.\n */\n _teardown() {\n const parts = this._parts;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if ((part as AttrPart)._kind === REF) (part as AttrPart)._release();\n (part as TextPart)._upgraded?._detach();\n }\n /** Taken-over slots park the USER'S nodes before this instance's DOM is discarded. */\n this._slotStates?.forEach((state) => state._$park$?.());\n }\n\n _update(values: unknown[]) {\n let valueIndex = 0;\n const parts = this._parts;\n for (let i = 0; i < parts.length; i++) valueIndex = parts[i]._commit(values, valueIndex);\n if (this._pendingSlots !== undefined) this._mountSlots();\n }\n\n /**\n * **Slots mount after the first `_update`, not during construction, because a `<slot>`'s own\n * bindings are part of its meaning.** `<slot name=${section}>` has no name at all until its\n * `AttrPart` has committed, and mounting first read the static markup and got `''` — the slot\n * registered as a second DEFAULT slot, took the default content, and left the real default slot\n * showing fallback. Committing first also means `@slotchange` and `&ref` are already attached to\n * the element by the time anything is dispatched on it.\n *\n * Once per instance: the fields are cleared here and every later `_update` costs one compare.\n */\n _mountSlots() {\n const slotNodes = this._pendingSlots!;\n this._pendingSlots = undefined;\n /**\n * `_slotRoot` still holds the container: it is set for the whole of one `renderInto` and every\n * instance under it — nested templates included — is constructed and first-updated inside that\n * same synchronous span, so this is the root the constructor saw.\n */\n const root = _slotRoot;\n const seam = slotSeam();\n if (seam === undefined || root === null) return;\n for (let i = 0; i < slotNodes.length; i++) {\n const slot = slotNodes[i];\n const state = seam(slot, root, slot.getAttribute('name') ?? '');\n if (state != null) {\n (this._slotStates ??= []).push(state);\n notifyOnRemoval = true;\n }\n }\n }\n}\n\n/** A single property read — this runs once per list item per render, so it must be minimal. */\nconst isTemplateResult = (value: object): value is TemplateResult =>\n (value as TemplateResult).strings !== undefined;\n\n/**\n * The common case of a child expression is plain text, and the template primes every child slot\n * with a text node — so the steady state is compare-and-assign on `.data`. This part carries only\n * that, upgrading itself to a full ChildPart the first time it sees null, a template, or an array.\n */\n/**\n * **A boolean in a child position renders the WORD, and almost nobody means that.**\n *\n * `${items.length > 0 && html`…`}` is the ordinary conditional idiom, and when the test is false\n * the whole expression is `false` — which becomes the text `false` on the page. Nothing throws;\n * the value is legitimate; only the intent is wrong. lit-html does the same and this renderer\n * matches it deliberately (anything not nullish renders), so the BEHAVIOUR stays and the mistake\n * is named where it happens instead of being found by looking at the page.\n *\n * `@verajs/jsx` compiles this case away — in JSX a boolean child becomes nothing, React's rule,\n * because that is where React expectations live. **That is the one value semantic on which JSX and\n * a hand-written template differ**, which makes this the warning that meets JSX-shaped code pasted\n * into a template.\n *\n * Called from BOTH child sinks, because a text position is a `TextPart` until something upgrades\n * it and a boolean never triggers that upgrade — putting the check in `ChildPart` alone left it\n * silent for exactly the common case. One function, two call sites, per the standing rule that a\n * deliberate duplication is a fix's second address.\n *\n * Both sinks gate this on the value CHANGING — not merely on reaching a commit — so an unchanged\n * `false` is reported once and not once per render. `ChildPart` needed that stated explicitly: its\n * dirty check sits below, and calling this above it spammed every pass.\n */\nconst warnBooleanChild = (value: unknown): void => {\n if (typeof value !== 'boolean') return;\n console.warn(\n `[vera] renderer: a child position was given \\`${value}\\`, which renders as the word ` +\n `\"${value}\" — the usual cause is \\`\\${cond && …}\\` with a false \\`cond\\`.\\n` +\n `Write \\`\\${cond ? … : null}\\`, or \\`\\${(cond && …) || null}\\`; \\`null\\` and \\`undefined\\` are ` +\n `the values that render nothing. If you meant to display the boolean, say so with ` +\n `\\`\\${String(value)}\\` and this goes quiet.`\n );\n};\n\nclass TextPart implements Part {\n _text: Text;\n _value: unknown = '';\n _upgraded: ChildPart | null = null;\n\n constructor(text: Text) {\n this._text = text;\n }\n\n _commit(values: unknown[], index: number): number {\n const value = values[index];\n if (this._upgraded !== null) {\n this._upgraded._set(value);\n return index + 1;\n }\n if (value == null || typeof value === 'object') {\n /**\n * Upgrade in place: marker comments come into existence only now, anchored around the text\n * node, and the full part inherits the committed text state and delegates forever.\n *\n * BOTH markers are ours. Borrowing `this._text.nextSibling` as the end instead would hand\n * this part a boundary owned by the NEXT part — and the next part removes that very node\n * when it upgrades and clears its own text. The stale reference then makes `_clear()` walk\n * past the end of the child list. Owning both anchors also makes `_end === null` mean\n * exactly one thing: the root part, which really does own its container.\n */\n const start = comment();\n const end = comment();\n /**\n * **Markers go where the part LIVES, which is not always where its text node is.** In a\n * light host wired for slots, this text node was captured and distributed into the\n * component's tree — planting markers beside it there put them inside the slot's range,\n * the slot's next fill swept them into the holding fragment, and the part spent the rest\n * of the page rendering into detached space (measured: `<host>${text}</host>` toggling\n * through null showed FALLBACK forever). `_$home$` answers with the host's light-region\n * sentinel for a captured node and null for everything else, so every app without light\n * slots takes the second branch untouched.\n */\n const home = slotSeam()?._$home$?.(this._text) ?? null;\n const parent = home !== null ? home.parentNode! : this._text.parentNode!;\n if (home !== null) {\n parent.insertBefore(start, home);\n parent.insertBefore(end, home);\n } else {\n parent.insertBefore(start, this._text);\n parent.insertBefore(end, this._text.nextSibling);\n }\n const part = new ChildPart(start, end);\n part._mode = TEXT;\n part._text = this._text;\n part._value = this._value;\n this._upgraded = part;\n part._set(value);\n return index + 1;\n }\n if (value !== this._value) {\n if (__DEV__) warnBooleanChild(value);\n this._value = value;\n this._text.data = value as string;\n }\n return index + 1;\n }\n}\n\n/**\n * A value at a child position that applies itself — see `ChildPart._set`.\n *\n * `previous` is whatever this applier returned at this part on the last render, which is where a\n * applier keeps its continuity. Returning nothing is fine for one that has none.\n */\ntype Applier = ((part: { _$commit$(value: unknown): void }, previous: unknown) => unknown) & {\n /**\n * Optional teardown, hung on the **applier** rather than on the value.\n *\n * The applier is already required to be hoisted — a fresh function per render breaks continuity —\n * so it is the one stable object in the protocol and the natural place for a second half. It\n * receives whatever the applier last returned, which is where its state lives.\n */\n _$detach$?: (previous: unknown) => void;\n};\n\n/**\n * A value at a child position the renderer has no built-in answer for. Return `true` to claim it.\n *\n * A handler will also be handed the **operations** it needs to do its job — the shape\n * `'proxy-handler'` uses, where core passes `addCallback` and `runCallbacks` rather than exposing\n * them as members. That object is deliberately *not* here yet: an earlier draft guessed nine\n * methods, nothing used them, they cost 90 B of anticipation, and porting the list algorithm then\n * showed it needs closer to fourteen — including item accessors the guess had no idea about. It\n * gets built in the step that has a caller to shape it.\n *\n * This is how a value *kind* becomes a package rather than a branch: lists, an async value, a\n * portal, a virtualizer. The built-ins below register through it too, so a third party's kind is\n * not second-class to one that shipped in the box.\n */\ntype ValueHandler = (part: object, value: unknown) => boolean | void;\n\n/**\n * The registry this renderer reads `'value'` handlers from, handed over by {@link renderer}.\n *\n * Not imported. The renderer carries no registry of its own for the same reason the router does\n * not: a production bundle inlines `@verajs/inserts`, so importing it would give this package one\n * registry and core another, and an app would register into whichever it happened to import — the\n * failure `connectInserts` used to repair.\n */\nlet registry: { get(name: 'value' | 'slot'): unknown[] | undefined } | null = null;\n\n/**\n * The ONE lookup for the `'slot'` insert. Three callers want the same thing in the same shape —\n * template construction (are there slots to record?), the first render into a container (capture\n * the host's children), and hydration's rescue (un-distribute before a mismatch discards) — and\n * the seam carries its cross-bundle members as sigil-named keys, which every caller had to spell\n * out again. One accessor, spelled once.\n */\n/**\n * **Whether ANY app on this page wired light slots**, latched the first time the seam answers.\n *\n * The ownership stamp in `_insert`/`$c` exists only for `@verajs/renderer/slots` to read, and its\n * guard has to be free for everyone else — `_slotRoot` is set for every `renderInto`, so without\n * this an app with no slots at all would stamp every top-level node it renders, which for a list\n * at the root is a property write per ROW. One boolean instead, false for the life of a page that\n * never wires them.\n */\nlet slotsWired = false;\nconst slotSeam = (): SlotSeam | undefined => {\n const seam = (registry?.get('slot') as SlotSeam[] | undefined)?.[0];\n if (seam !== undefined) slotsWired = true;\n return seam;\n};\nconst noHandlers: ValueHandler[] = [];\nconst valueHandlers = () => (registry ? ((registry.get('value') as ValueHandler[] | undefined) ?? noHandlers) : noHandlers);\n\n/**\n * Kinds this package still ships. They read from a local list rather than the registry because the\n * renderer cannot register into one it was merely handed — that needs `wire`, which it does not\n * import. The list empties when they move to packages; until then a wired handler is checked first,\n * so a module can pre-empt a built-in exactly as the priority order promises.\n */\nconst builtIns: ValueHandler[] = [];\n\n/**\n * Whether anything in this process has asked to be told when a subtree is removed — an element ref\n * to release, or a child applier that declared `_$detach$`.\n *\n * **One flag for both, and it is process-wide.** Teardown cannot be discovered from the template the\n * way a ref can — a ref is a `&` part the scan sees, while an applier arrives as a *value* and no\n * template shape predicts it — so the coarser gate is the only one that serves both.\n *\n * The finer, per-template gate for refs was measured and dropped: it saved 34 B less than nothing,\n * because the walk it avoided is not the expensive part. With one unrelated ref on the page, a\n * 1 000-row clear walks 1 000 instances and measures 3.98 ms against 4.03 ms with no ref at all —\n * the DOM removal dominates completely. What matters is that an app asking for neither walks\n * **zero**, and that still holds.\n */\nlet notifyOnRemoval = false;\n\n/**\n * The hydrate entry's way to raise the flag. Every CLIENT path that creates removal work sets\n * `notifyOnRemoval` where the work is created (a ref committing, a slot mounting, an applier\n * declaring `_$detach$`) — but hydration ADOPTS its seams through its own walk in `hydrate.ts`,\n * a different module compiled into the same bundle, and a page whose only seams were adopted\n * left the flag down. `_clear` then skipped `_detach` entirely: no `_teardown`, no `_$park$`,\n * and the user's server-adopted slotted content was destroyed on the first branch-away — the\n * exact content-loss class the seam's park exists to prevent, reintroduced one entry over.\n */\nexport const declareRemovalWork = (): void => {\n notifyOnRemoval = true;\n};\n\n/**\n * Dev-only: how many times a part has seen a *different* child applier. See the branch that reads it.\n *\n * `@__PURE__` is load-bearing. Every read sits behind `__DEV__`, but a bare `new WeakMap()` at module\n * scope is a constructor call terser must assume has side effects, so production kept the allocation\n * with its binding dropped — a literal `new WeakMap;` statement building an object nothing could ever\n * reach. The annotation is what lets the dead branch take it along.\n */\nconst _applierSwaps = /* @__PURE__ */ new WeakMap<object, number>();\n\n/** What a ChildPart currently contains. */\nconst EMPTY = 0;\nconst TEXT = 1;\nconst TEMPLATE = 2;\nconst LIST = 3;\nconst NODE = 4;\n\n/**\n * Development-only profiling hook, armed by `@verajs/renderer/profiler`. Null until something\n * arms it, so an unprofiled development render pays one null check per template commit.\n *\n * Every reference sits behind `__DEV__`, which `defineDev()` folds to `false` before terser runs —\n * so the declaration, the constants and every call site are removed from the production bundle.\n * Verified by byte comparison, not assumed.\n */\nconst PROFILE_UPDATE = 0; // same template identity — values committed in place\nconst PROFILE_CREATE = 1; // first template into an empty part\nconst PROFILE_REBUILD = 2; // template identity CHANGED — subtree torn down and rebuilt\nconst PROFILE_FRAME_START = 3;\nconst PROFILE_FRAME_END = 4;\n\ntype ProfileHook = (kind: number, subject: unknown, shape: TemplateStringsArray | null) => void;\nlet _profileHook: ProfileHook | null = null;\n/** @internal */\nconst _setProfileHook = (fn: ProfileHook | null) => {\n _profileHook = fn;\n};\n\nclass ChildPart implements Part {\n _start: Comment;\n /** Exclusive end of this part's range; null means \"to the end of the parent\". */\n _end: Node | null;\n _mode = EMPTY;\n _value: unknown;\n _text: Text | null = null;\n _instance: Instance | null = null;\n /** The committed template's strings identity — the same-template fast path in `_set`. */\n _shape: TemplateStringsArray | null = null;\n _items: Item[] | null = null;\n _keyedList = false;\n /** Held instances by template identity; survives clears so state outlives interim content. */\n _held: Map<TemplateStringsArray, Instance> | null = null;\n /** Whatever the last `_$child$` at this part returned — its continuity across renders. */\n _applierState: unknown = undefined;\n /** Which applier that state belongs to, so two of them at one part cannot read each other's. */\n _applier: unknown = undefined;\n\n constructor(start: Comment, end: Node | null) {\n this._start = start;\n this._end = end;\n }\n\n _commit(values: unknown[], index: number): number {\n this._set(values[index]);\n return index + 1;\n }\n\n /**\n * **A component's own output is STAMPED, so the slot system cannot mistake it for content.**\n *\n * `@verajs/renderer/slots` captures a top-level element carrying a `slot` attribute as the\n * host's content — which a component's own rendered root may legitimately be, when it renders\n * something destined for ITS parent's slot. Measured: with slots wired,\n * `renderInto(html\\`<div slot=\"x\">…</div>\\`, element)` distributed the component's output into\n * its own holding fragment and the component rendered NOTHING, on the first render, with no\n * children involved and nothing thrown.\n *\n * The renderer is the one party that knows: it is inserting at the top level of the container\n * it was asked to render into. `_slotRoot` is that container for the whole of one `renderInto`,\n * so `parent === _slotRoot` is exactly \"this is the component's own output\" and distinguishes it\n * from `<x-card>${value}</x-card>`, where the part's parent is the host but the render root is\n * an ancestor — the user's light content, which must still be captured.\n *\n * Two comparisons on a path that is already touching the DOM, and the stamp is a PROPERTY:\n * invisible to CSS, to serialization and to `children`, unlike any marker or attribute, and it\n * rides on text nodes, which no attribute can. An app without slots wired writes it and nothing\n * ever reads it.\n */\n /**\n * **One property read decides all stamping, and root-part-ness decides the value.**\n *\n * `_$hosted$` is set on the host element itself by `@verajs/renderer/slots` at capture, so\n * \"does anything care about ownership here\" is a single own-property read — no seam call, no\n * registry lookup, and pages that are not captured hosts (every container in most apps) cost\n * exactly that read and write nothing. The mark cannot go stale in the direction that matters:\n * a part's first commit runs in a detached fragment before its host is captured, reads\n * `undefined`, and stamps nothing — and that content is exactly what the initial capture walk\n * lifts anyway. Every later commit sees the mark.\n *\n * The VALUE is structural, not temporal. `_end === null` is true of root parts alone (see\n * `_clear`), and a root part's inserts are by definition the render's own output — a fact that\n * stays true for an applier committing from a microtask hours after `renderInto` returned,\n * where the earlier `parent === _slotRoot` test read null and left ASYNC output unstamped for\n * the flipped capture rule to eat. Everything else inserting into a host is placing content\n * INTO it from outside, stamped with the part — the ordering group.\n */\n _insert(node: Node) {\n const parent = this._start.parentNode!;\n if (slotsWired && (parent as { _$hosted$?: boolean })._$hosted$ === true)\n stampOwn(node, this._end === null ? true : this);\n parent.insertBefore(node, this._end);\n }\n\n /**\n * Tells every child applier under this part that it is going away.\n *\n * Reached only when some applier somewhere declared teardown — see `notifyOnRemoval` — because\n * this is the per-node walk the bulk removal exists to skip. **Every** removal path calls it, not\n * just `_clear`: a keyed row is dropped by moving its nodes to a scratch fragment and an index-mode\n * list shrinks by removing nodes directly, so a version that only hooked `_clear` notified a\n * applier when its container was replaced and stayed silent when its row was deleted — told\n * sometimes, which is a worse contract than never.\n */\n _detach() {\n if (this._applier !== undefined) (this._applier as Applier)._$detach$?.(this._applierState);\n this._instance?._teardown();\n const items = this._items;\n if (items != null) for (let i = 0; i < items.length; i++) detachItem(items[i]);\n }\n\n _clear() {\n /**\n * One gate, two jobs. A template that holds an element ref must release it; a subtree holding a\n * applier that declared teardown must be told. Both are found by the same walk, and an app\n * with neither reads two booleans and walks nothing.\n */\n if (notifyOnRemoval) this._detach();\n const parent = this._start.parentNode!;\n const end = this._end;\n const items = this._items;\n /**\n * **Content that is no longer between the markers.** `@verajs/renderer/slots` distributes a\n * light host's children by MOVING them into the component's tree, so a part rendering those\n * children keeps its markers in the host while its content lives inside the component.\n *\n * Both branches below are wrong for that, and wrong in opposite directions. The walk finds\n * the markers adjacent and removes nothing — the content stays on screen after being cleared\n * (a template swap in a light host showed the OLD template forever). The whole-parent fast\n * path is the dangerous one: it would `textContent = ''` the HOST, component render and all.\n *\n * Every mode knows its content by IDENTITY, which is parent-agnostic and split-proof: items\n * through `$m`, TEXT through `_text`, NODE through `_value`, TEMPLATE through the top-level\n * node array recorded at commit. The one shape that cannot be found this way is a\n * DocumentFragment committed at NODE position (its children scatter and it keeps no record);\n * that falls through to the walk, as before.\n */\n if (this._start.nextSibling === end && this._mode !== EMPTY) {\n if (items !== null) {\n for (const item of items) if (item !== null) this.$m(item, null, SCRATCH);\n SCRATCH.textContent = '';\n } else if (this._mode === TEXT) {\n (this._text as ChildNode | null)?.remove();\n } else if (this._mode === TEMPLATE) {\n if (Array.isArray(this._value)) for (const node of this._value as ChildNode[]) node.remove();\n } else if (this._mode === NODE && typeof (this._value as ChildNode).remove === 'function') {\n (this._value as ChildNode).remove();\n }\n } else /**\n * When this part owns its parent's entire contents, one `textContent = ''` replaces removing\n * every node individually. For a 1 000-row table body that is the difference between ~22 ms\n * (lit-html's per-node teardown) and ~5 ms.\n *\n * A part owns the whole parent when nothing precedes its start AND nothing follows its end —\n * `_end === null` (a root part, which runs to the end by definition) or `_end` is the last\n * child. The second case is the common one and used to miss this path entirely: every list\n * written as `<tbody>${rows}</tbody>` sits inside a template, and since 0.1.2 a nested part\n * always owns an end marker, so `_end === null` alone never held for it.\n *\n * Re-appending both anchors in order restores the part's boundary exactly as it was.\n */\n if (this._start.previousSibling === null && (end === null || end.nextSibling === null)) {\n parent.textContent = '';\n parent.appendChild(this._start);\n if (end !== null) parent.appendChild(end);\n } else {\n let node = this._start.nextSibling;\n /**\n * `node !== null` is a backstop, not an expected exit. Reaching the end of the child list\n * without meeting `_end` means something detached this part's boundary; stopping leaves\n * nodes behind, which beats throwing out of the middle of a render pass.\n */\n while (node !== null && node !== this._end) {\n const next = node.nextSibling;\n parent.removeChild(node);\n node = next;\n }\n }\n this._mode = EMPTY;\n this._text = null;\n this._instance = null;\n this._items = null;\n this._shape = null;\n this._applierState = undefined;\n this._applier = undefined;\n }\n\n /**\n * How a child-position applier renders. Named to survive property mangling — `/^_[a-z]/` is the\n * pattern, and `_$…$` does not match it — because this is the half of the protocol that third\n * parties call.\n */\n _$commit$(value: unknown) {\n /**\n * The applier's own state survives its own rendering. Committing different content usually\n * runs `_clear`, which drops the state so a part that was emptied by *anything else* cannot\n * hand an applier continuity it no longer has — but an applier rendering its own next value\n * has not gone away, and losing continuity there made `until()` fall back to its placeholder on\n * the render after it resolved.\n */\n const applierState = this._applierState;\n const applier = this._applier;\n this._set(value);\n this._applierState = applierState;\n this._applier = applier;\n }\n\n _set(value: unknown) {\n if (value == null) {\n if (this._mode !== EMPTY) this._clear();\n return;\n }\n if (typeof value !== 'object') {\n /**\n * Gated on the value CHANGING, which is the same condition the commit below uses. Called\n * before that check it fired on every render of an unchanged `false` — a channel that\n * repeats is as useless as one that stays silent, and the comment on `warnBooleanChild`\n * claimed this was already true. `_value` holds whatever was last committed here, so a part\n * arriving from a template state differs and reports once.\n */\n if (__DEV__ && this._value !== value) warnBooleanChild(value);\n if (this._mode === TEXT) {\n if (this._value !== value) {\n this._value = value;\n this._text!.data = value as string; // the DOM coerces numbers etc.\n }\n } else {\n if (this._mode !== EMPTY) this._clear();\n this._text = doc.createTextNode(value as string);\n this._insert(this._text);\n this._value = value;\n this._mode = TEXT;\n }\n return;\n }\n const heldResult = (value as { $h?: TemplateResult }).$h;\n if (heldResult !== undefined) {\n this._commitHeld(heldResult);\n return;\n }\n if (isTemplateResult(value)) {\n /**\n * Same-shape fast path on `strings` identity alone — no template-cache lookup. This is the\n * hottest line in a keyed list update: for every row whose shape did not change (all of\n * them, in practice), commit costs one identity compare before touching the values.\n */\n if (this._shape === value.strings) {\n if (__DEV__ && _profileHook) _profileHook(PROFILE_UPDATE, this, value.strings);\n this._instance!._update(value.values);\n return;\n }\n /**\n * Reaching here with a template already committed means the identity changed, so the\n * subtree below is about to be destroyed and rebuilt rather than updated. That is what\n * `?hidden=${…}` over a swapped subtree exists to avoid, and it is otherwise invisible.\n */\n if (__DEV__ && _profileHook) {\n _profileHook(this._mode === TEMPLATE ? PROFILE_REBUILD : PROFILE_CREATE, this, value.strings);\n }\n const template = getTemplate(value);\n if (this._mode !== EMPTY) this._clear();\n const instance = new Instance(template);\n instance._update(value.values);\n /**\n * The instance's top-level nodes, recorded while they are still in the fragment. `_value`\n * is unused in TEMPLATE mode, and this is what lets `_clear` and `hold`'s parking find the\n * content after `@verajs/renderer/slots` has moved it out of the marker range — per node,\n * parent-agnostic, so even content split across two slots comes back. Costs one small array\n * on a path that just built an Instance and cloned a template; same-shape updates never\n * reach here.\n */\n this._value = [...instance._fragment.childNodes];\n this._insert(instance._fragment);\n this._instance = instance;\n this._shape = value.strings;\n this._mode = TEMPLATE;\n return;\n }\n const handlers = valueHandlers();\n for (let i = 0; i < handlers.length; i++) if (handlers[i](this, value)) return;\n for (let i = 0; i < builtIns.length; i++) if (builtIns[i](this, value)) return;\n\n /**\n * **A child-position value that applies itself.** The same idea as `_$apply$` at element\n * position — which is how `@verajs/renderer/spread` ships as a separate package the renderer\n * knows nothing about — at the one other position worth extending.\n *\n * `_$child$(part, previous)` is handed the part and whatever it returned last time at this\n * part, and calls `part._$commit$(value)` to render content. Keeping continuity in the return\n * value rather than in an applier *instance* is what keeps this a protocol rather than a\n * framework: there is no base class, no factory and no lifecycle to learn, and an applier is\n * an object literal.\n *\n * Placed **after** the template check on purpose. A template is overwhelmingly the common\n * object at a child position, and it returns above without ever reading this property — so the\n * check costs the hot path nothing and only arrays, nodes and appliers pay for it. Measured:\n * +22 B gzipped, and no runtime difference distinguishable from noise.\n *\n * There is deliberately no teardown hook. `_clear` bulk-removes DOM and, when the part owns its\n * parent, does `parent.textContent = ''` — the thing that makes clearing a 1 000-row table ~5 ms\n * against lit-html's ~22 ms. Calling teardown on a nested applier would mean walking the part\n * tree on every removal, which is precisely the per-node work that fast path exists to skip. So\n * an applier here can render, and cannot yet be told it has gone away.\n */\n const applyChild = (value as { _$child$?: Applier })._$child$;\n if (applyChild !== undefined) {\n /** `previous` belongs to *this* applier; a different one at the same part starts fresh. */\n const previous = this._applier === applyChild ? this._applierState : undefined;\n /**\n * The un-hoisted applier, named. Writing `_$child$` as an object-literal method makes a new\n * function per render, so the part never recognises it and `previous` is `undefined` forever —\n * the applier silently restarts on every pass. It is the first rule in the README and it\n * fails without a symptom, so development counts the swaps: a genuine applier change at one\n * part happens once or twice, not on every render.\n *\n * The counter is a module-scope `WeakMap` rather than a field, so production carries neither\n * it nor a per-part slot to hold it — but only because it is marked `@__PURE__` at its\n * declaration. Without that it said the same thing and was untrue.\n */\n if (__DEV__ && this._applier !== undefined && this._applier !== applyChild) {\n const swaps = (_applierSwaps.get(this) ?? 0) + 1;\n _applierSwaps.set(this, swaps);\n if (swaps === 3) {\n console.warn(\n `[vera] a child applier changed identity ${swaps} times at one part, so \\`previous\\` ` +\n `is always undefined and it restarts every render.\\n` +\n `Hoist the applier — written as an object-literal method it is a new function per ` +\n `call:\\n\\n` +\n ` function applyThing(part, previous) { … } // once, at module scope\\n` +\n ` const thing = (x) => ({ _$child$: applyThing, x }); // state on the object\\n`\n );\n }\n }\n this._applier = applyChild;\n if (applyChild._$detach$ !== undefined) notifyOnRemoval = true;\n this._applierState = applyChild.call(value, this, previous);\n return;\n }\n if ((value as Node).nodeType !== undefined) {\n /**\n * A DOM node renders as itself — a canvas a charting library owns, a `<template>`'s content,\n * an element built by hand. Placed after the template check and before the list check\n * because `nodeType` is one property read and nothing else that reaches here has one.\n */\n if (this._mode !== NODE || this._value !== value) {\n if (this._mode !== EMPTY) this._clear();\n this._insert(value as Node);\n this._value = value;\n this._mode = NODE;\n }\n return;\n }\n // any other object: render as text\n this._set(String(value));\n }\n\n /** Commits a template while stashing whatever it replaces — see the `hold()` export. */\n _commitHeld(result: TemplateResult) {\n if (this._mode === TEMPLATE && this._shape === result.strings) {\n this._instance!._update(result.values);\n return;\n }\n const held = (this._held ??= new Map());\n if (this._mode === TEMPLATE) {\n /** Park the live nodes back in their instance's own (empty) fragment. When the range is\n * empty but content existed, slots relocated it — the recorded top-level nodes park it\n * from wherever it lives, split slots and holding included. */\n const fragment = this._instance!._fragment;\n if (this._start.nextSibling === this._end && Array.isArray(this._value)) {\n for (const node of this._value as Node[]) fragment.appendChild(node);\n } else {\n let node = this._start.nextSibling;\n while (node !== this._end) {\n const next = node!.nextSibling;\n fragment.appendChild(node!);\n node = next;\n }\n }\n held.set(this._shape!, this._instance!);\n } else if (this._mode !== EMPTY) {\n this._clear();\n }\n const instance = held.get(result.strings) ?? new Instance(getTemplate(result));\n instance._update(result.values);\n this._value = [...instance._fragment.childNodes];\n this._insert(instance._fragment);\n this._instance = instance;\n this._shape = result.strings;\n this._mode = TEMPLATE;\n }\n\n /**\n * Creates one list item. A single-root template instance becomes an element-mode item with no\n * markers at all; anything else gets its own start/end marker pair so moves can never dangle.\n */\n $c(value: unknown, parent: Node, ref: Node | null): Item {\n /** Rows reach the DOM here rather than through `_insert`; same one-read gate, same\n * structural value — a root list's rows are the render's own output, any other part's rows\n * are content it places into the host, stamped with the part as the ordering group. */\n const stamp =\n slotsWired && (parent as { _$hosted$?: boolean })._$hosted$ === true\n ? this._end === null\n ? true\n : this\n : null;\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings !== undefined) {\n const result = value as TemplateResult;\n const template = getTemplate(result);\n const instance = new Instance(template);\n instance._update(result.values);\n const rootNode = instance._fragment.firstChild;\n if (rootNode !== null && rootNode.nodeType === 1 && rootNode.nextSibling === null) {\n if (stamp !== null) stampOwn(rootNode, stamp);\n parent.insertBefore(rootNode, ref);\n return {\n $k: result.key,\n _element: rootNode as Element,\n _instance: instance,\n _shape: result.strings,\n _part: null,\n };\n }\n /** Multi-root template: markered part, content already instantiated. */\n const part = createMarkeredPart(parent, ref);\n part._instance = instance;\n part._shape = result.strings;\n part._mode = TEMPLATE;\n part._value = [...instance._fragment.childNodes];\n if (stamp !== null) stampOwn(instance._fragment, stamp);\n part._start.parentNode!.insertBefore(instance._fragment, part._end);\n return { $k: result.key, _element: null, _instance: null, _shape: null, _part: part };\n }\n const part = createMarkeredPart(parent, ref);\n part._set(value);\n return { $k: (value as TemplateResult)?.key, _element: null, _instance: null, _shape: null, _part: part };\n }\n\n /** Commits a new value into an existing item, demoting element mode if the shape changed. */\n $u(item: Item, value: unknown) {\n if (item._element !== null) {\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings === item._shape) {\n item._instance!._update((value as TemplateResult).values);\n return;\n }\n /** Shape changed: swap the bare element for a markered part in its place. */\n const part = createMarkeredPart(item._element.parentNode!, item._element);\n item._element.remove();\n item._element = null;\n item._instance = null;\n item._shape = null;\n (item._part = part)._set(value);\n return;\n }\n item._part!._set(value);\n }\n\n /** The item's first node — its move/removal handle and the insertion reference before it. */\n $f(item: Item): Node {\n return item._element ?? item._part!._start;\n }\n\n /**\n * Moving and removing an item read `_element` and `_part`, which are mangled — so they stay here\n * rather than travelling with the algorithm that calls them. `$m` and `$d` are the price: two\n * cold methods, exempt from mangling, two characters each.\n */\n $m(item: Item, ref: Node | null, parent: Node = this._start.parentNode!) {\n /**\n * **Already where it is going.** A reorder asks for many positions that are already correct,\n * and re-inserting a node that is in place is not free: it detaches and re-attaches, which\n * blurs focus, restarts a CSS transition and wakes every MutationObserver watching. The\n * relocated path below leans on this — it re-places every item rather than computing which\n * ones moved — but the ordinary two-ended diff gets the same saving.\n *\n * The item's LAST node is the one whose `nextSibling` decides this, and reading `_element` /\n * `_part._end` is why the check lives here rather than travelling with the algorithm.\n */\n const last = item._element ?? item._part!._end!;\n if (last.nextSibling === ref && last.parentNode === parent) return;\n if (item._element !== null) {\n parent.insertBefore(item._element, ref);\n return;\n }\n let node: Node | null = item._part!._start;\n const stop = item._part!._end!.nextSibling;\n while (node !== stop) {\n const next: Node | null = node!.nextSibling;\n parent.insertBefore(node!, ref);\n node = next;\n }\n }\n\n /** Removal is a move into a scratch fragment that is immediately emptied. */\n $d(item: Item) {\n if (notifyOnRemoval) detachItem(item);\n this.$m(item, null, SCRATCH);\n SCRATCH.textContent = '';\n }\n\n _commitList(newValues: unknown[]) {\n if (this._mode !== LIST) {\n if (this._mode !== EMPTY) this._clear();\n this._items = [];\n this._keyedList = false;\n this._mode = LIST;\n }\n const count = newValues.length;\n if (count === 0) {\n if (this._items!.length) {\n this._clear();\n this._items = [];\n this._mode = LIST;\n }\n return;\n }\n const isKeyed = newValues[0] != null && (newValues[0] as KeyedResult).$r !== undefined;\n if (isKeyed !== this._keyedList && this._items!.length) {\n this._clear();\n this._items = [];\n this._mode = LIST;\n }\n this._keyedList = isKeyed;\n const items = this._items!;\n const parent = this._start.parentNode!;\n\n if (items.length === 0) {\n /** Initial fill builds off-document and lands in one insert. */\n const fragment = doc.createDocumentFragment();\n for (let i = 0; i < count; i++) items.push(this.$c(newValues[i], fragment, null));\n this._insert(fragment);\n return;\n }\n\n if (!isKeyed) {\n // index mode: update in place, grow at the end, shrink from the end\n const shared = items.length < count ? items.length : count;\n for (let i = 0; i < shared; i++) this.$u(items[i], newValues[i]);\n if (count > items.length) {\n const fragment = doc.createDocumentFragment();\n for (let i = items.length; i < count; i++) items.push(this.$c(newValues[i], fragment, null));\n this._insert(fragment);\n } else if (count < items.length) {\n if (notifyOnRemoval) for (let i = count; i < items.length; i++) detachItem(items[i]);\n /**\n * **Removed through the items, not by walking the range.** The walk this replaced ran from\n * the first doomed item to the last one's end and called `parent.removeChild` on each node,\n * which assumes every one of them is still a child of `parent`. `@verajs/renderer/slots`\n * moves a light host's children into the component's tree, and the walk then threw\n * `NotFoundError` out of the middle of a render — a plain `<x-card>${rows}</x-card>` losing\n * one row was enough, with no keyed list anywhere in it.\n *\n * `$m` into the scratch fragment is indifferent to where a node currently lives, and the\n * batch is dropped by one clear at the end, so the contiguous-run saving the walk was for\n * is kept.\n */\n for (let i = count; i < items.length; i++) this.$m(items[i], null, SCRATCH);\n SCRATCH.textContent = '';\n items.length = count;\n }\n return;\n }\n\n /**\n * Keyed reconciliation is not here. It lives in `@verajs/renderer/keyed`, and it arrives on\n * the values themselves — `keyed()` stamps each result with the strategy that understands it,\n * so importing the marker is what loads the algorithm. Nothing registers, nothing is wired, and\n * two strategies cannot disagree about a list because the list names its own.\n *\n * The protocol is three cold members (`$c`, `$u`, `$f`) plus a returned array. Everything a\n * strategy would otherwise have to reach for — the mode switch, the empty case, the initial\n * fill — is already done above and passed in.\n */\n this._items = (newValues[0] as KeyedResult).$r!(this, newValues, items, parent, this._end);\n }\n}\n\nconst rootParts = new WeakMap<Node, ChildPart>();\n\n/**\n * Writes a template result into a container. The renderer's imperative draw: no reactivity, no\n * lifecycle, no knowledge of components. Slots into Vera via `wire([renderer])`; core's built-in\n * `html` tag already produces the accepted shape, so no `setHtml` call is required — though\n * lit-html's `html` also works, its results being structurally identical.\n *\n * **It owns its own range and nothing else.** The first call appends a marker and anchors a root\n * part there; later calls with the same container reuse that part and walk only the value slots, so\n * nodes are updated in place rather than rebuilt. Content that was already in the container stays.\n *\n * **Named for the relationship, not the act.** It was `render` until 0.2.0, which collided with\n * core's `render` — a different function, with a different arity, that declares a *reactive*\n * template and commits a component's setup. Both were public and both were documented, so a reader\n * who knew one misread the other. `renderElement` and `renderDom` were considered and rejected: this\n * renders *into* a container, and the container is a `Node` — a shadow root and a fragment are both\n * valid, so \"element\" would be a lie in the type. Argument order is lit-html's on purpose.\n *\n * HYDRATION lives in `@verajs/renderer/hydrate` — a drop-in superset entry whose `renderInto` adopts\n * existing server-rendered children on first render. SSR apps import from there instead of here;\n * this entry carries zero hydration code.\n */\nexport const renderInto = (result: unknown, container: Node) => {\n /**\n * The container is the argument people forget, and forgetting it failed with\n * `Cannot read properties of undefined (reading 'appendChild')` — a message about the internals of\n * a function the caller never named. Everything after this line assumes a node.\n */\n if (__DEV__ && (!container || typeof (container as Node).appendChild !== 'function'))\n throw new TypeError(\n `renderInto: expected a container node as the second argument and received ${String(container)}. ` +\n `It renders *into* something — \\`renderInto(html\\`…\\`, document.body)\\`.`\n );\n if (__DEV__ && _profileHook) _profileHook(PROFILE_FRAME_START, container, null);\n let part = rootParts.get(container);\n if (part === undefined) {\n /**\n * FIRST render into this container. If it is a light element host and a 'slot' insert is\n * wired, capture its children NOW — so slot content provided before its (possibly\n * conditional) `<slot>` mounts is held rather than left visible in the host, matching native\n * \"unassigned light children do not render\". Once per container lifetime; shadow roots\n * (nodeType 11) and fragments are excluded.\n */\n /**\n * **The marker goes in FIRST, and capture is handed it as the light region's boundary.**\n *\n * This part's start marker already delimits where the render's output begins, so the boundary\n * slots needs is a node the renderer was creating anyway — the sentinel it used to append for\n * itself landed immediately before this one, two adjacent comments doing the same job. Passing\n * it removes one comment from every light host and keeps the two in step by construction: they\n * cannot drift apart if they are the same node.\n *\n * Appending before capture is safe and necessary. Safe because a comment is never a slottable,\n * so the children walk steps over it; necessary because capture LIFTS the host's children, and\n * a marker appended afterwards would land in the same place either way — this way slots has it.\n */\n const marker = comment();\n container.appendChild(marker);\n if (container.nodeType === 1) slotSeam()?._$capture$?.(container as Element, marker);\n rootParts.set(container, (part = new ChildPart(marker, null)));\n }\n /**\n * **The flush is in a `finally`, and that is not tidiness.** A render that throws after a\n * `<select>.value` has been queued but before the flush left the queue holding the element — which\n * retains it in module state, and, worse, hands the stranded value to the *next* `renderInto` call.\n * An unrelated component's render then silently changed a select it has nothing to do with.\n * Measured: a failed update left the value to be applied by the following render.\n *\n * Flushing on the way out applies it with its own pass, where it belongs, and leaves nothing\n * behind either way. The error still propagates.\n */\n _slotRoot = container;\n try {\n part._set(result);\n } finally {\n _slotRoot = null;\n flushSelects();\n }\n if (__DEV__ && _profileHook) _profileHook(PROFILE_FRAME_END, container, null);\n};\n\n// ── INTERNAL SURFACE — imported by ./hydrate.ts, never re-exported by src/index.ts ─────────────\n// The public d.ts comes from src/index.ts, and the base bundles tree-shake all of this away, so\n// nothing here reaches consumers of the base entry. The hydrate entry compiles against this exact\n// source into its own self-contained bundle, so mangled property names always agree within it.\n\n/** @internal */\nexport {\n flushSelects,\n getTemplate,\n Template,\n Instance,\n TextPart,\n ChildPart,\n AttrPart,\n IGNORED_PART,\n IGNORED,\n TEMPLATE,\n LIST,\n NODE,\n comment,\n doc,\n toText,\n isTemplateResult,\n instanceWalker,\n rootParts,\n slotSeam,\n _setProfileHook,\n PROFILE_UPDATE,\n PROFILE_CREATE,\n PROFILE_REBUILD,\n PROFILE_FRAME_START,\n PROFILE_FRAME_END,\n};\n/** @internal */\nexport type { Item, TemplatePart };\n\n\n/**\n * Lists, as a registered kind rather than a branch — the built-in going through the same door a\n * package will. Moving it to `@verajs/renderer/lists` is step 5; nothing else has to change when\n * it does, which is what this shape is for.\n */\nbuiltIns.push((part, value) => {\n if (Array.isArray(value)) {\n (part as ChildPart)._commitList(value);\n return true;\n }\n if (value !== null && typeof (value as Iterable<unknown>)[Symbol.iterator] === 'function') {\n (part as ChildPart)._commitList([...(value as Iterable<unknown>)]);\n return true;\n }\n return false;\n});\n\n/**\n * Everything this renderer needs, in one entry: `wire([renderer])`.\n *\n * It registers on the `'render'` chain *and* takes the registry, because a package that both\n * provides a capability and reads one should not cost an app two lines. This replaced\n * `setRenderer`, which existed only because there was no general way to say \"this app has a\n * renderer\" — and which resolved the shadow root at registration, so a renderer wired any other\n * way silently rendered into the light DOM. That resolution lives in core's dispatch now.\n */\n/**\n * A `__DEV__`-only hint for `wire`, so the module and the raw function beside it can share a package\n * without wiring the wrong one being silent.\n *\n * A bare function has no `on`, so `wire` reads it as a connector and hands it the registry. Nothing\n * registers, nothing throws, and the page renders nothing. The marker lets `wire` name the export\n * that was meant. This mattered most when the function was called `render` and the mistake was two\n * characters wide; `renderInto` is harder to confuse, and the guard costs nothing in production.\n *\n * `$module` is deliberately generic — any package exporting a raw function next to a module of a\n * similar name can set it. Production carries neither the property nor the check that reads it.\n */\nif (__DEV__) (renderInto as unknown as { $module?: string }).$module = 'renderer';\n\nexport const renderer = {\n name: '@verajs/renderer',\n on: 'render' as const,\n fn: renderInto as never,\n priority: 50,\n /**\n * Typed against the registry `wire` actually hands over, not a narrower shape that happens to\n * describe the one lookup this makes. A structural `{ get(name: 'value'): … }` is **not**\n * assignable from `Inserts`, so `wire([renderer])` failed to compile in a consumer's project while\n * this repo's own typecheck — which reads sources, not the shipped `.d.ts` — saw nothing.\n */\n connect: (given: { get(name: never): unknown }) => {\n registry = given as { get(name: 'value' | 'slot'): unknown[] | undefined };\n },\n};\n","/**\n * @verajs/renderer/hydrate — markerless adoption of server-rendered DOM.\n *\n * Importing this module (once, anywhere) arms hydration: the renderer's first render into a\n * container that already has children adopts them as server output of the same template. Without\n * this import the renderer never carries adoption code — non-SSR apps pay nothing.\n *\n * The server serializer (@verajs/ssr) emits the SAME static strings the renderer parses into\n * its canonical template, so server DOM and canonical fragment diverge only at value slots — and\n * at adoption time the values are known. Adoption walks both trees in lockstep: statics must\n * match byte-for-byte (else bail), and at each slot the live text is split so the renderer's own\n * anchors (primed texts, marker comments) are installed into the adopted DOM. Server HTML stays\n * free of framework comments; the client repairs its anchors in. Any mismatch clears the\n * container (preserving `<style data-vm-sheet=\"styles\">` tags) and the caller renders fresh — correctness\n * never depends on the server markup.\n *\n * This entry re-exports the public API, so a CDN importmap can point `@verajs/renderer` at the\n * hydrate bundle and nothing else changes.\n */\nimport {\n getTemplate,\n Instance,\n TextPart,\n ChildPart,\n AttrPart,\n IGNORED_PART,\n IGNORED,\n TEMPLATE,\n LIST,\n NODE,\n comment,\n doc,\n toText,\n isTemplateResult,\n instanceWalker,\n rootParts,\n slotSeam,\n renderInto as baseRender,\n renderer as baseRenderer,\n declareRemovalWork,\n} from './renderer.js';\nimport type { Template, Item, KeyedResult } from './renderer.js';\nimport type { Part, TemplateResult } from './types.js';\n\nexport { hold } from './renderer.js';\nexport type { TemplateResult } from './types.js';\n\n/** Internal bail signal — never escapes `tryAdopt`. */\nconst MISMATCH = {};\n\n/**\n * Why the last adoption gave up, for the development warning below. Written at every `throw\n * MISMATCH` inside an `if (__DEV__)`, so a production bundle carries neither the strings nor the\n * assignments — the branches fold away with `__DEV__` and the helper goes with them.\n */\nlet why = '';\n\n/** A live node as a person would name it, for that message. */\nconst describe = (node: Node | null) =>\n node === null\n ? 'nothing'\n : node.nodeType === 1\n ? `<${(node as Element).localName}>`\n : node.nodeType === 3\n ? `the text ${JSON.stringify((node as Text).data.slice(0, 30))}`\n : node.nodeType === 8\n ? 'a comment'\n : `a ${node.nodeName} node`;\n\ntype Cursor = { parent: Node; node: Node | null; offset: number };\n\n/** Splits mid-text cursors onto a node boundary and returns the node now at the cursor. */\nconst cursorSplit = (cursor: Cursor): Node | null => {\n if (cursor.offset > 0) {\n cursor.node = (cursor.node as Text).splitText(cursor.offset);\n cursor.offset = 0;\n }\n return cursor.node;\n};\n\n/**\n * **A comment carries no rendered content, so hydration neither matches nor requires one.**\n *\n * `instanceWalker` is `ELEMENT | TEXT`, and the part indices in `_parts` are numbered by that same\n * walker — so a comment in a template's statics is structurally invisible to this walk, and cannot\n * be made visible without renumbering every part the client renderer relies on. The live DOM,\n * however, still has it: `html`<p>a<!-- note -->b</p>`` adopts as text/comment/text where the walk\n * wanted one run of text, and `<p>lead<!-- tail --></p>` leaves a child the walk never asked for.\n * Both read as a disagreement, so **every template containing an HTML comment lost hydration** —\n * the server's markup discarded and re-rendered, for markup the client had itself produced. Nothing\n * failed, because the page is correct either way; that is what the fallback is for, and why this\n * went unnoticed. What it cost was the first paint the server render was paid for.\n *\n * Stepping over them is sound rather than merely convenient: the invisibility is symmetric, so a\n * comment can differ in either direction and neither direction can change what a reader sees. This\n * is only safe because hydration is markerless — the adopted markup carries no framework comments,\n * so there is nothing here whose position is load-bearing.\n *\n * Not folded into `cursorSplit`, which also answers \"where do I insert?\" — moving an insertion point\n * past a comment would put a slot's content on the wrong side of it.\n */\nconst passComments = (cursor: Cursor) => {\n while (cursor.offset === 0 && cursor.node !== null && cursor.node.nodeType === 8) {\n cursor.node = cursor.node.nextSibling;\n }\n};\n\n/** Consumes exactly `text` from the live cursor; anything else is a mismatch. */\nconst expectText = (cursor: Cursor, text: string) => {\n let need = text;\n while (need.length > 0) {\n passComments(cursor);\n const node = cursor.node;\n if (node === null || node.nodeType !== 3) {\n if (__DEV__) why = `expected the text ${JSON.stringify(text)} and found ${describe(node)}`;\n throw MISMATCH;\n }\n const data = (node as Text).data;\n const available = data.length - cursor.offset;\n if (available === 0) {\n cursor.node = node.nextSibling;\n cursor.offset = 0;\n continue;\n }\n const take = available < need.length ? available : need.length;\n if (data.slice(cursor.offset, cursor.offset + take) !== need.slice(0, take)) {\n if (__DEV__)\n why = `expected the text ${JSON.stringify(need.slice(0, take))} and found ${JSON.stringify(data.slice(cursor.offset, cursor.offset + take))}`;\n throw MISMATCH;\n }\n need = need.slice(take);\n cursor.offset += take;\n if (cursor.offset === data.length) {\n cursor.node = node.nextSibling;\n cursor.offset = 0;\n }\n }\n};\n\n/** Claims the value's rendered text as a standalone node (splitting as needed) and returns it. */\nconst claimValueText = (cursor: Cursor, text: string): Text => {\n const at = cursorSplit(cursor);\n if (text === '') {\n /** Nothing was rendered — install a fresh primed anchor at the cursor. */\n const primed = doc.createTextNode('');\n cursor.parent.insertBefore(primed, at);\n return primed;\n }\n if (at === null || at.nodeType !== 3) {\n if (__DEV__) why = `expected a text node holding an interpolated value and found ${describe(at)}`;\n throw MISMATCH;\n }\n const node = at as Text;\n if (node.data.length > text.length) node.splitText(text.length);\n if (node.data !== text) {\n if (__DEV__) why = `an interpolated value reads ${JSON.stringify(text)} here and the markup says ${JSON.stringify(node.data)}`;\n throw MISMATCH;\n }\n cursor.node = node.nextSibling;\n cursor.offset = 0;\n return node;\n};\n\n/** Per-template canonical node list (ELEMENT | TEXT order), cached — adoption of a 100-row list\n * hits the same template 100 times. */\nconst canonicalCache = new WeakMap<Template, Node[]>();\n\nconst canonicalNodes = (template: Template): Node[] => {\n let nodes = canonicalCache.get(template);\n if (nodes === undefined) {\n nodes = [];\n instanceWalker.currentNode = template._element.content;\n let node: Node | null;\n while ((node = instanceWalker.nextNode()) !== null) nodes.push(node);\n canonicalCache.set(template, nodes);\n }\n return nodes;\n};\n\n/** Walk state shared down the adoption recursion of one instance. */\ntype AdoptState = {\n _template: Template;\n _values: unknown[];\n _valueIndex: number;\n _partIndex: number;\n _nodeIndex: number;\n _out: Part[];\n /** Taken-over slot states — parked at teardown, never committed (kept OUT of `_parts`). */\n _slotStates?: import('./types.js').SlotSeamState[];\n};\n\n/** The light host being hydrated — every `<slot>` in the render projects it, set once in\n * `tryAdopt` (the render container), null when no slot handler is wired. */\nlet _adoptHost: Element | null = null;\n/** Whether the default slot's assignment has been claimed (the host count is for the first one). */\nlet _defaultTaken = false;\n/**\n * Every slot binding this adoption attempt created. If the attempt BAILS, each is parked — which\n * returns the user's nodes to holding and unregisters the binding. Without it the abandoned\n * bindings stayed registered, so the clean render's own bindings ranked as later duplicates and\n * showed fallback while the user's content sat in the discarded tree: a hydration mismatch\n * silently DESTROYED slotted content, breaking this entry's promise that correctness never\n * depends on the server markup (measured).\n */\nlet _adoptedSlots: { _$park$: () => void }[] = [];\n\n/** How many values a template part consumes — for skipping the unrendered parts inside an\n * assigned slot's fallback subtree. */\nconst partValueCount = (part: { _type: number; _statics?: string[] }): number =>\n part._type === 1 ? (part._statics!.length - 1) : 1;\n\n/**\n * Account for (skip) the parts inside a canonical subtree whose DOM the server did NOT render —\n * an assigned slot's fallback. Advances the walk indices and value cursor without touching DOM,\n * so the parts AFTER the slot still line up. Walks the node's CHILDREN (the fallback), in the\n * same ELEMENT|TEXT order the walker numbers by.\n */\nconst accountSubtree = (node: Node, state: AdoptState) => {\n const parts = state._template._parts;\n for (let child = node.firstChild; child !== null; child = child.nextSibling) {\n if (child.nodeType !== 1 && child.nodeType !== 3) continue;\n state._nodeIndex++;\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n state._valueIndex += partValueCount(parts[state._partIndex]);\n state._partIndex++;\n }\n if (child.nodeType === 1) accountSubtree(child, state);\n }\n};\n\n/**\n * Reconcile a canonical `<slot>` against server-distributed DOM. Named slots take the consecutive\n * cursor nodes carrying `slot=\"name\"`; the default slot takes the host-count nodes\n * (`data-vm-slotted=\"N\"`). Found nodes are wrapped in place as a live binding (identity/state preserved);\n * an unassigned slot adopts its server-rendered fallback children normally. The slots module's\n * `_$adopt$` (off the template's own seam fn) does the registration.\n */\nconst adoptSlotElement = (canonicalSlot: Element, cursor: Cursor, state: AdoptState) => {\n const seamAdopt = (state._template._seam as unknown as {\n _$adopt$: (\n h: Element, n: string, a: Node[] | null, f: Node[], p: Node, b: Node | null, s?: Element\n ) => Part;\n })._$adopt$;\n /**\n * **The slot's OWN bindings, committed onto a per-instance element.** The server unwrapped the\n * `<slot>`, so there is no live element to adopt against — but the template's parts for it are\n * still in the parts array, and skipping them left every value after the slot reading the wrong\n * one. In practice that meant adoption failed and the whole container fell back to a client\n * render: any component whose slot carried `@slotchange`, `&ref` or `name=${…}` could not be\n * server-rendered at all.\n *\n * A shallow clone is the target rather than the canonical node, which is shared by every\n * instance of the template — committing onto that would attach one instance's listeners to all\n * of them. The clone then IS this instance's slot element, exactly as the clone in a client\n * render is, so `@slotchange` and `&ref` mean the same thing in both.\n */\n const ghost = canonicalSlot.cloneNode(false) as Element;\n const parts = state._template._parts;\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n const templatePart = parts[state._partIndex++];\n const attrPart = new AttrPart(ghost, templatePart._name!, templatePart._statics!, templatePart._present);\n state._out.push(attrPart);\n state._valueIndex = attrPart._commit(state._values, state._valueIndex, true);\n drainIgnored(state);\n }\n /** After the commit, so `<slot name=${…}>` is read as the name it actually has. */\n const name = ghost.getAttribute('name') ?? '';\n passComments(cursor);\n const parent = cursor.parent;\n\n /** Collect the server nodes assigned to this slot. */\n const assigned: Node[] = [];\n if (name !== '') {\n let node = cursorSplit(cursor);\n while (node !== null && node.nodeType === 1 && (node as Element).getAttribute('slot') === name) {\n assigned.push(node);\n cursor.node = node.nextSibling;\n node = cursorSplit(cursor);\n }\n } else if (!_defaultTaken) {\n /**\n * `\"offset,count\"` on the slot's own parent — see `SLOTTED_ATTR`. Only the count is needed\n * here (the walk is already standing in the right place); the offset is what lets a FAILED\n * adoption find these same nodes again instead of destroying them.\n *\n * `_defaultTaken` still guards: two default slots sharing a parent would otherwise both read\n * the one mark, and by native semantics only the first receives anything.\n */\n const mark = (parent as Element).getAttribute?.('data-vm-slotted');\n const count = mark === undefined || mark === null ? 0 : Number(mark.slice(mark.indexOf(',') + 1));\n if (count > 0) {\n _defaultTaken = true;\n /**\n * **The mark does not survive the page it delivered.** It describes what the SERVER emitted\n * and is meaningless the moment those nodes are adopted, so leaving it behind would put a\n * framework marker in the user's live DOM permanently — queryable, stylable, and stale.\n * `data-vm-select` sets the precedent: it is stripped before the markup even ships, with\n * a test asserting the mark must not survive.\n */\n (parent as Element).removeAttribute('data-vm-slotted');\n for (let i = 0; i < count; i++) {\n const node = cursorSplit(cursor);\n if (node === null) break;\n assigned.push(node);\n cursor.node = node.nextSibling;\n }\n }\n }\n\n if (assigned.length > 0) {\n /** Assigned: the fallback was NOT rendered, so its parts are accounted (skipped) and its\n * nodes cloned from the canonical template for live re-fallback later. */\n const before = cursor.node;\n const fallback: Node[] = [];\n for (let c = canonicalSlot.firstChild; c !== null; c = c.nextSibling)\n if (c.nodeType === 1 || c.nodeType === 3) fallback.push(c.cloneNode(true));\n accountSubtree(canonicalSlot, state);\n const seam = seamAdopt(_adoptHost!, name, assigned, fallback, parent, before, ghost);\n _adoptedSlots.push(seam as unknown as { _$park$: () => void });\n (state._slotStates ??= []).push(seam as never);\n /** An adopted seam is removal work exactly as a mounted one is — without this, a page whose\n * only seams were adopted never ran `_teardown`, and branch-away destroyed the user's\n * server-adopted content instead of parking it. See `declareRemovalWork`. */\n declareRemovalWork();\n } else {\n /** Unassigned: the server rendered this slot's fallback children — adopt them in lockstep\n * (they ARE the canonical children), then bind them as the shown fallback. */\n const fallbackStart = cursor.node;\n for (let c = canonicalSlot.firstChild; c !== null; c = c.nextSibling)\n if (c.nodeType === 1 || c.nodeType === 3) adoptNode(c, cursor, state);\n /** The fallback nodes now sit between fallbackStart and cursor.node. */\n const fallback: Node[] = [];\n for (let n = fallbackStart; n !== null && n !== cursor.node; n = n.nextSibling) fallback.push(n);\n const seam = seamAdopt(_adoptHost!, name, null, fallback, parent, cursor.node, ghost);\n _adoptedSlots.push(seam as unknown as { _$park$: () => void });\n (state._slotStates ??= []).push(seam as never);\n /** Same as the assigned branch: an unassigned seam still unregisters and re-routes at park. */\n declareRemovalWork();\n }\n};\n\n/** Adopts one canonical node (and, for elements, its subtree) against the live cursor. */\nconst adoptNode = (canonical: Node, cursor: Cursor, state: AdoptState) => {\n state._nodeIndex++;\n const parts = state._template._parts;\n\n if (canonical.nodeType === 3) {\n /** A primed empty text is a child slot; any other text is a static to match. */\n let isSlot = false;\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n isSlot = true;\n state._partIndex++;\n adoptSlot(cursor, state._values[state._valueIndex++], state._out);\n drainIgnored(state);\n }\n if (!isSlot) expectText(cursor, (canonical as Text).data);\n return;\n }\n\n /** A `<slot>` in the canonical template maps to distributed content (or fallback) in the server\n * DOM — reconciled specially — but only when a slot handler was wired at construction. */\n if (state._template._seam !== undefined && (canonical as Element).localName === 'slot') {\n adoptSlotElement(canonical as Element, cursor, state);\n return;\n }\n\n /** Element: same tag, commit its attribute parts live, then descend children in lockstep. */\n passComments(cursor);\n const live = cursorSplit(cursor);\n if (live === null || live.nodeType !== 1) {\n if (__DEV__) why = `expected <${(canonical as Element).localName}> and found ${describe(live)}`;\n throw MISMATCH;\n }\n if ((live as Element).localName !== (canonical as Element).localName) {\n if (__DEV__)\n why = `expected <${(canonical as Element).localName}> and found <${(live as Element).localName}>`;\n throw MISMATCH;\n }\n\n while (state._partIndex < parts.length && parts[state._partIndex]._index === state._nodeIndex) {\n const templatePart = parts[state._partIndex++];\n const attrPart = new AttrPart(live as Element, templatePart._name!, templatePart._statics!, templatePart._present);\n state._out.push(attrPart);\n /** Attributes re-set (idempotent), listeners attached, refs fired — the server could only\n * mirror form state; the client wires behavior. The `true` marks this as adoption, which is\n * what keeps a form value the reader may already have changed (see `AttrPart._commit`). */\n state._valueIndex = attrPart._commit(state._values, state._valueIndex, true);\n drainIgnored(state);\n }\n\n const inner: Cursor = { parent: live, node: live.firstChild, offset: 0 };\n let child = canonical.firstChild;\n while (child !== null) {\n if (child.nodeType === 1 || child.nodeType === 3) adoptNode(child, inner, state);\n child = child.nextSibling;\n }\n /**\n * The one place the server writes content the template does not describe: a `<textarea>`'s value\n * **is** its content, so `.value=${…}` has nowhere else to go and `@verajs/ssr` puts it there —\n * which is what shows the value to a reader with no JavaScript. The template's own statics say\n * the element is empty, so this read as foreign markup and abandoned adoption for the whole page,\n * silently: the container was cleared and re-rendered, the markup looked right, and everything\n * server rendering is for was gone.\n *\n * **Kept, not cleared.** It is the element's `defaultValue`, and it is also the only thing\n * holding the value: adoption deliberately does not write `.value` (see `AttrPart._commit`), so\n * clearing the content would empty the field it just adopted. A person who typed here before the\n * bundle landed has made the field dirty, and a dirty textarea ignores its content anyway — so\n * their text survives either way, and the server's stays as what `form.reset()` restores.\n *\n * **One of four respects in which a hydrated DOM is not byte-identical to a client-rendered one**,\n * and all four have the same cause: `@verajs/ssr` mirrors `.value`, `.checked` and `.selected` on\n * form elements into markup, because markup is the only way form state reaches the client at all.\n * The client sets those as properties and writes nothing, exactly as a browser does — so the\n * server's copy stays behind after adoption:\n *\n * | binding | hydrated | client-rendered |\n * | --- | --- | --- |\n * | `<input .value=${x}>` | `<input value=\"x\">` | `<input>` |\n * | `<input .checked=${true}>` | `<input checked=\"\">` | `<input>` |\n * | `<option .selected=${true}>` | `<option selected=\"\">` | `<option>` |\n * | `<textarea .value=${x}>` | `<textarea>x</textarea>` | `<textarea></textarea>` |\n *\n * They are defaults rather than state — what `form.reset()` restores — so the *rendered* result is\n * the same and only a reset tells them apart. `tests/hydrate-parity.test.mjs` records the list,\n * because \"the one respect\" was written here when there was one, and a reader comparing a hydrated\n * DOM against a client-rendered one needs to know which differences are meant.\n */\n if (\n inner.node !== null &&\n inner.node.nodeType === 3 &&\n inner.node.nextSibling === null &&\n canonical.firstChild === null &&\n (live as Element).localName === 'textarea'\n ) {\n inner.node = null;\n }\n\n /** Leftover live children the template does not account for = not our markup. */\n passComments(inner);\n if (inner.node !== null && !(inner.node.nodeType === 3 && (inner.node as Text).data === '' && inner.node.nextSibling === null)) {\n if (__DEV__)\n why = `<${(live as Element).localName}> contains ${describe(inner.node)}, which the template does not describe`;\n throw MISMATCH;\n }\n\n cursor.node = live.nextSibling;\n cursor.offset = 0;\n};\n\nconst drainIgnored = (state: AdoptState) => {\n const parts = state._template._parts;\n while (state._partIndex < parts.length && parts[state._partIndex]._type === IGNORED) {\n state._out.push(IGNORED_PART);\n state._valueIndex++;\n state._partIndex++;\n }\n};\n\n/** Adopts one child slot's rendered content, producing the part that will own it. */\nconst adoptSlot = (cursor: Cursor, rawValue: unknown, out: Part[]) => {\n const heldResult = (rawValue as { $h?: TemplateResult } | null)?.$h;\n const value = heldResult !== undefined ? heldResult : rawValue;\n\n /**\n * Anything the client commits as text claims text here — which is every value that is not a\n * template, a node, or an iterable. `String(value)` is what `_set` falls through to, so a `Date`,\n * an object with a `toString`, a `Promise` or a plain object all produce text on the client, and\n * `@verajs/ssr` produces the same text on the server.\n *\n * The object cases used to be a deliberate mismatch, because the server emitted nothing for them\n * and the two could not be reconciled. Once the server started matching the client, the mismatch\n * was the only thing left disagreeing.\n */\n const isText =\n value != null &&\n (typeof value !== 'object' ||\n (!isTemplateResult(value) &&\n (value as Node).nodeType === undefined &&\n typeof (value as Iterable<unknown>)[Symbol.iterator] !== 'function'));\n\n if (isText) {\n /** Claim its text and bind the fast TextPart, committed state included. */\n const textPart = new TextPart(claimValueText(cursor, toText(value)));\n textPart._value = value;\n out.push(textPart);\n return;\n }\n\n /** Structured content gets a markered ChildPart wrapped around whatever it rendered. */\n const start = comment();\n cursor.parent.insertBefore(start, cursorSplit(cursor));\n const part = new ChildPart(start, null);\n\n if (value == null) {\n /** Nothing rendered server-side; the part starts EMPTY. */\n } else if (isTemplateResult(value)) {\n part._instance = adoptInstance(getTemplate(value), value.values, cursor);\n part._shape = value.strings;\n part._mode = TEMPLATE;\n } else if ((value as Node).nodeType !== undefined) {\n /**\n * A DOM node is client-only by construction — the server has no document to have built one, so\n * it rendered nothing here and there is nothing to adopt. Inserting it at the cursor (which has\n * not moved, because no server node was claimed) puts it exactly where the end marker is about\n * to go, and leaves the part in the same state a client-side commit would.\n */\n cursor.parent.insertBefore(value as Node, cursorSplit(cursor));\n part._value = value;\n part._mode = NODE;\n } else {\n /** Everything left is an array or another iterable — text and nodes were handled above. */\n const list: unknown[] = Array.isArray(value) ? value : [...(value as Iterable<unknown>)];\n const items: Item[] = [];\n for (const entry of list) items.push(adoptItem(cursor, entry));\n part._items = items;\n /**\n * The same predicate `_commitList` uses — the presence of a strategy, not of a `key`. Two\n * spellings of \"is this list keyed\" would drift, and disagreeing about one list destroys it:\n * a mode change is what tells the renderer to throw the adopted DOM away and start over.\n */\n part._keyedList = list.length > 0 && (list[0] as KeyedResult)?.$r !== undefined;\n part._mode = LIST;\n }\n\n const end = comment();\n cursor.parent.insertBefore(end, cursorSplit(cursor));\n part._end = end;\n out.push(part);\n};\n\n/** Adopts one list item — element mode for single-root templates, markered otherwise. */\nconst adoptItem = (cursor: Cursor, value: unknown): Item => {\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings !== undefined) {\n const result = value as TemplateResult;\n const template = getTemplate(result);\n const content = template._element.content;\n const root = content.firstChild;\n if (root !== null && root.nodeType === 1 && root.nextSibling === null) {\n const liveRoot = cursorSplit(cursor);\n const instance = adoptInstance(template, result.values, cursor);\n return {\n $k: result.key,\n _element: liveRoot as Element,\n _instance: instance,\n _shape: result.strings,\n _part: null,\n };\n }\n const start = comment();\n cursor.parent.insertBefore(start, cursorSplit(cursor));\n const instance = adoptInstance(template, result.values, cursor);\n const end = comment();\n cursor.parent.insertBefore(end, cursorSplit(cursor));\n const part = new ChildPart(start, end);\n part._instance = instance;\n part._shape = result.strings;\n part._mode = TEMPLATE;\n return { $k: result.key, _element: null, _instance: null, _shape: null, _part: part };\n }\n /** Non-template item: markered part adopting its content like a nested slot. */\n const out: Part[] = [];\n adoptSlot(cursor, value, out);\n return { $k: (value as TemplateResult)?.key, _element: null, _instance: null, _shape: null, _part: out[0] as ChildPart };\n};\n\n/** Builds an Instance whose parts are bound to LIVE nodes, consuming them from the cursor. */\nconst adoptInstance = (template: Template, values: unknown[], cursor: Cursor): Instance => {\n const instance: Instance = Object.create(Instance.prototype);\n instance._parts = [];\n instance._fragment = doc.createDocumentFragment();\n const state: AdoptState = {\n _template: template,\n _values: values,\n _valueIndex: 0,\n _partIndex: 0,\n _nodeIndex: -1,\n _out: instance._parts,\n };\n drainIgnored(state);\n /** Cached walk exists for repeated templates; the recursion itself visits in the same\n * ELEMENT | TEXT document order the instance walker uses. */\n canonicalNodes(template);\n let child = template._element.content.firstChild;\n while (child !== null) {\n if (child.nodeType === 1 || child.nodeType === 3) adoptNode(child, cursor, state);\n child = child.nextSibling;\n }\n drainIgnored(state);\n if (state._partIndex !== template._parts.length) {\n if (__DEV__) why = 'the markup ran out before the template did';\n throw MISMATCH;\n }\n if (state._slotStates !== undefined) instance._slotStates = state._slotStates;\n return instance;\n};\n\n/**\n * Attempts to adopt a container's existing (server-rendered) children for `result`. Returns the\n * root part on success; null on any mismatch, leaving the caller to clean-render. Leading\n * `<style data-vm-sheet=\"styles\">` tags (the SSR style serialization) are skipped and preserved.\n */\nconst tryAdopt = (result: TemplateResult, container: Node): ChildPart | null => {\n /** Only the SSR-serialized style tags are skipped — templates may legitimately start with\n * whitespace or even their own static `<style>`, which must align against the canonical walk. */\n let first = container.firstChild;\n while (first !== null && first.nodeType === 1 && (first as Element).hasAttribute('data-vm-sheet')) {\n first = first.nextSibling;\n }\n if (__DEV__) why = '';\n const start = comment();\n container.insertBefore(start, first);\n /** The container is the light host every slot in this render projects; `_defaultTaken` resets\n * per adoption (the host count is for the first default slot). */\n _adoptHost = container.nodeType === 1 ? (container as Element) : null;\n _defaultTaken = false;\n _adoptedSlots = [];\n try {\n const cursor: Cursor = { parent: container, node: start.nextSibling, offset: 0 };\n const instance = adoptInstance(getTemplate(result), result.values, cursor);\n passComments(cursor);\n if (cursor.node !== null) {\n if (__DEV__) why = `${describe(cursor.node)} follows everything the template describes`;\n throw MISMATCH;\n }\n const part = new ChildPart(start, null);\n part._instance = instance;\n part._shape = result.strings;\n part._mode = TEMPLATE;\n return part;\n } catch (error) {\n if (error !== MISMATCH) throw error;\n /**\n * Undo every slot this attempt adopted BEFORE the container is cleared: parking returns the\n * user's nodes to holding and unregisters the binding, so the clean render that follows\n * redistributes them instead of ranking behind an abandoned binding and showing fallback.\n */\n for (const seam of _adoptedSlots) seam._$park$();\n _adoptedSlots = [];\n start.remove();\n return null;\n }\n};\n\n\n/** Mismatch cleanup lives here, not in the slim renderer: clear all but the SSR style tags. */\nconst clearPreservingStyles = (container: Node) => {\n let node = container.firstChild;\n while (node !== null) {\n /** `nextSibling` already yields `ChildNode | null`; annotating it `Node` widened it and broke\n * the assignment back into `node`, which `firstChild` typed as `ChildNode | null`. */\n const next: ChildNode | null = node.nextSibling;\n if (!(node.nodeType === 1 && (node as Element).hasAttribute('data-vm-sheet'))) container.removeChild(node);\n node = next;\n }\n};\n\n/**\n * The hydrating `render`: a drop-in for the base entry's. The first render into a container that\n * already has children adopts them; any mismatch clears (keeping `<style data-vm-sheet=\"styles\">`) and falls\n * through to a clean base render. After the first render, this IS the base render.\n */\nexport const renderInto = (result: unknown, container: Node) => {\n if (\n !rootParts.has(container) &&\n container.firstChild !== null &&\n result !== null &&\n typeof result === 'object' &&\n isTemplateResult(result as object)\n ) {\n const part = tryAdopt(result as TemplateResult, container);\n if (part !== null) {\n rootParts.set(container, part);\n return;\n }\n /**\n * **Falling back has to say so.** The page is correct either way — that is what the fallback is\n * for — but the server's markup has just been thrown away, which means every byte the server\n * spent rendering it was wasted and the one thing server rendering exists to deliver did not\n * happen. Nothing observable changes, so without this the only symptom is a slower first paint\n * that nobody attributes to anything.\n *\n * The `<textarea>` case a few screens up is the proof: adoption was abandoned *for the whole\n * page* by one element whose content the template did not describe, and the markup still looked\n * right afterwards. It was found by reading the code. React and lit both report a mismatch;\n * this said nothing at all.\n *\n * `__DEV__`-only, and the reason comes from the check that failed, so it names the first place\n * the two renders disagreed rather than announcing that they did.\n *\n * **Scoped to this container, because that is what happened.** This function runs once per\n * container, and a mismatch clears exactly one — measured: three containers, one carrying markup\n * the template does not describe, and the other two adopt their server nodes unchanged while one\n * warning prints. The message used to say \"nothing the server rendered was used\", which reads as\n * a page-wide failure and sends the reader looking for a page-wide cause: a bad doctype, a broken\n * handoff, state that differs everywhere. The truth is narrower and the message already names the\n * element, so the advice can be local.\n *\n * It also said the markup was discarded, full stop; `clearPreservingStyles` keeps\n * `<style data-vm-sheet=\"styles\">`, which is the whole reason that function exists.\n */\n if (__DEV__) {\n /**\n * **\"The page is correct\" is a promise this message must not make blindly.** The bail rescue\n * preserves everything it can PROVE is the user's: content inside `data-vm-slotted` marks,\n * the `data-vm-unassigned` carrier, and elements carrying a `slot` attribute. Real server\n * output always marks its distributed default-slot content, so on genuine deploy skew the\n * rescue is complete and the promise holds — measured, named and unnamed and bare text alike.\n * But a container holding CLIENT-side markup that was never server output has no marks, and\n * its unnamed slottables are structurally indistinguishable from the stale template output\n * being discarded — so they go with it, under a message that said everything was fine. The\n * marks are the discriminator: their total absence is exactly the shape where the promise\n * can fail, so that is when the message changes.\n */\n const unmarked =\n container.nodeType === 1 &&\n (container as Element).querySelector('[data-vm-slotted],[data-vm-unassigned]') === null;\n console.warn(\n `[vera] hydration fell back to a client render: ${why}. This container's server markup was ` +\n `discarded and rebuilt (its SSR <style> is kept), ` +\n (unmarked\n ? `and it carried none of the marks server output carries. If its children were ` +\n `CLIENT-side markup rather than this template's server output, unnamed light-slot ` +\n `content (bare text, elements without a \\`slot\\` attribute) cannot be told apart ` +\n `from the stale markup and was discarded with it — hydrate adopts existing children ` +\n `AS server output; render client-only containers with @verajs/renderer's renderInto ` +\n `instead. `\n : `so the page is correct but the server's work on this part of it was wasted. `) +\n `Other containers on the page hydrate independently and are unaffected. The two renders ` +\n `have to agree exactly — check for markup the template does not describe, or state ` +\n `settled after the server render.`\n );\n }\n /**\n * **Un-distribute before discarding.** A light host's slotted content lives INSIDE the markup\n * about to be thrown away, so clearing destroyed it: the slots fell back and the user's nodes\n * were gone from the page permanently, under a warning that said the page was still correct.\n * The slots module lifts them back out (`_$rescue$`), and re-attaching them as the host's\n * children puts it in exactly the state a first client render starts from — the clean render\n * below captures and redistributes them with no special case anywhere.\n */\n const rescued = container.nodeType === 1 ? slotSeam()?._$rescue$?.(container as Element) : null;\n clearPreservingStyles(container);\n if (rescued !== null && rescued !== undefined) for (const node of rescued) container.appendChild(node);\n }\n baseRender(result, container);\n};\n\n/** Same wire-misuse guard the base entry puts on its raw function — see renderer.ts. */\nif (__DEV__) (renderInto as unknown as { $module?: string }).$module = 'renderer';\n\n/**\n * This entry's `renderer` module, bound to the **hydrating** `renderInto`.\n *\n * It used to be a bare re-export of the base entry's descriptor, whose `fn` is the base,\n * non-adopting render — so the natural `import { renderer } from '@verajs/renderer/hydrate';\n * wire([renderer])` wired a renderer that never hydrated. The page still looked right (a first\n * render into a full container clears it and renders fresh), which made the failure silent: every\n * byte of server work discarded, nothing on screen to say so. The header's promise — point the\n * importmap at this bundle \"and nothing else changes\" — is only true now that the descriptor\n * carries this entry's own function. `connect` and the rest are shared deliberately: they operate\n * on this bundle's copy of the renderer's module state, which both functions read.\n */\nexport const renderer = { ...baseRenderer, fn: renderInto as never };\n"],"names":["hold","result","isTemplateResult","$h","MARKER","Math","random","toString","MARKER_COMMENT_DATA","doc","document","comment","data","createComment","markerWalker","createTreeWalker","instanceWalker","RAW_TEXT_TAGS","ATTR_NAME_DELIMITER","_slotRoot","Set","templateCache","WeakMap","Template","_element","_parts","constructor","type","_$litType$","markup","specs","strings","state","quote","quoteStart","rawTag","tagNameStart","isClosing","attrName","statics","pending","attrNameBefore","end","at","test","slice","i","length","segment","pos","ch","push","quoteChar","join","_type","_name","startsWith","tagName","match","endsWith","toLowerCase","name","scan","this","createElement","innerHTML","content","wrapper","firstChild","insertBefore","removeChild","currentNode","node","specIndex","parts","consumeIgnored","_index","nextNode","nodeType","element","hasAttributes","attributeName","getAttributeNames","declared","parseInt","spec","_statics","getAttribute","split","_present","hasAttribute","_node","removeAttribute","textContent","includes","pieces","p","append","primedText","createTextNode","parentNode","remove","nodeIndex","partIndex","part","undefined","seam","slotSeam","index","localName","_seam","_slots","getTemplate","template","get","set","IGNORED_PART","_commit","_values","UNSET","createMarkeredPart","parent","ref","start","ChildPart","toText","value","commitAdopt","el","carrier","desc","Object","getOwnPropertyDescriptor","_$adopt$","getPrototypeOf","record","_$props$","hasOwn","win","ownerDocument","defaultView","HTMLElement","prototype","applyRef","callback","error","console","AttrPart","_kind","_isFullValue","_committed","_handler","_select","present","first","kind","realName","charCodeAt","_release","_$apply$","handleEvent","event","handler","call","values","adopting","joined","liveTarget","pendingSelects","setAttribute","target","toggleAttribute","addEventListener","next","notifyOnRemoval","self","SCRATCH","createDocumentFragment","OWN_DESCRIPTOR","enumerable","configurable","writable","stampOwn","defineProperty","child","nextSibling","detachItem","item","_instance","_teardown","_part","_detach","Instance","_fragment","importNode","templateParts","templatePart","TextPart","slotRecords","slotNodes","_pendingSlots","_upgraded","_slotStates","forEach","_$park$","_update","valueIndex","_mountSlots","root","slot","_text","_value","text","_set","home","_$home$","_mode","TEXT","registry","slotsWired","noHandlers","builtIns","declareRemovalWork","_start","_end","_shape","_items","_keyedList","_held","_applierState","_applier","_insert","_$hosted$","_$detach$","items","_clear","$m","Array","isArray","previousSibling","appendChild","_$commit$","applierState","applier","heldResult","_commitHeld","instance","childNodes","handlers","applyChild","_$child$","previous","String","held","Map","fragment","$c","stamp","rootNode","$k","key","$u","$f","last","stop","$d","_commitList","newValues","count","isKeyed","$r","shared","rootParts","renderInto","container","marker","_$capture$","queued","flushSelects","Symbol","iterator","renderer","on","fn","priority","connect","given","MISMATCH","cursorSplit","cursor","offset","splitText","passComments","canonicalCache","_adoptHost","_defaultTaken","_adoptedSlots","accountSubtree","_template","_nodeIndex","_partIndex","_valueIndex","adoptNode","canonical","isSlot","adoptSlot","_out","drainIgnored","need","available","take","expectText","canonicalSlot","seamAdopt","ghost","cloneNode","attrPart","assigned","mark","Number","indexOf","before","fallback","c","fallbackStart","n","adoptSlotElement","live","inner","rawValue","out","textPart","primed","claimValueText","adoptInstance","list","entry","adoptItem","liveRoot","create","nodes","canonicalNodes","has","tryAdopt","rescued","_$rescue$","clearPreservingStyles","baseRender","baseRenderer"],"mappings":"AAsCO,MC6CMA,EAAWC,GACZ,MAAVA,GAAoC,iBAAXA,GAAuBC,EAAiBD,GAC7D,CAAEE,GAAIF,GACNA,EAOAG,EAAS,MAAyB,IAAhBC,KAAKC,WAAoB,GAAGC,SAAS,IAAM,IAE7DC,EAAsB,IAAMJ,EAE5BK,EAAMC,SACNC,EAAU,CAACC,EAAO,KAAOH,EAAII,cAAcD,GAQ3CE,EAAeL,EAAIM,iBAAiBN,EAAK,KAQzCO,EAAiBP,EAAIM,iBAAiBN,EAAK,GA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