@verajs/renderer 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +757 -225
  2. package/dist/development/vera-renderer-elements.d.ts +39 -0
  3. package/dist/development/vera-renderer-elements.d.ts.map +1 -0
  4. package/dist/development/vera-renderer-elements.js +193 -0
  5. package/dist/development/vera-renderer-elements.js.map +1 -0
  6. package/dist/development/vera-renderer-hydrate-slots.d.ts +94 -0
  7. package/dist/development/vera-renderer-hydrate-slots.d.ts.map +1 -0
  8. package/dist/development/vera-renderer-hydrate-slots.js +325 -0
  9. package/dist/development/vera-renderer-hydrate-slots.js.map +1 -0
  10. package/dist/development/vera-renderer-hydration.d.ts +332 -0
  11. package/dist/development/vera-renderer-hydration.d.ts.map +1 -0
  12. package/dist/development/vera-renderer-hydration.js +902 -0
  13. package/dist/development/vera-renderer-hydration.js.map +1 -0
  14. package/dist/development/vera-renderer-keyed.d.ts +25 -8
  15. package/dist/development/vera-renderer-keyed.d.ts.map +1 -1
  16. package/dist/development/vera-renderer-keyed.js +843 -268
  17. package/dist/development/vera-renderer-keyed.js.map +1 -1
  18. package/dist/development/vera-renderer-multi-window.d.ts +5 -0
  19. package/dist/development/vera-renderer-multi-window.d.ts.map +1 -0
  20. package/dist/development/vera-renderer-multi-window.js +40 -0
  21. package/dist/development/vera-renderer-multi-window.js.map +1 -0
  22. package/dist/development/vera-renderer-namespaces.d.ts +64 -0
  23. package/dist/development/vera-renderer-namespaces.d.ts.map +1 -0
  24. package/dist/development/vera-renderer-namespaces.js +94 -0
  25. package/dist/development/vera-renderer-namespaces.js.map +1 -0
  26. package/dist/development/vera-renderer-native-elements.d.ts +13 -0
  27. package/dist/development/vera-renderer-native-elements.d.ts.map +1 -0
  28. package/dist/development/vera-renderer-native-elements.js +231 -0
  29. package/dist/development/vera-renderer-native-elements.js.map +1 -0
  30. package/dist/development/vera-renderer-portal.d.ts +29 -0
  31. package/dist/development/vera-renderer-portal.d.ts.map +1 -0
  32. package/dist/development/vera-renderer-portal.js +167 -0
  33. package/dist/development/vera-renderer-portal.js.map +1 -0
  34. package/dist/development/vera-renderer-profiler.d.ts +48 -96
  35. package/dist/development/vera-renderer-profiler.d.ts.map +1 -1
  36. package/dist/development/vera-renderer-profiler.js +2632 -2142
  37. package/dist/development/vera-renderer-profiler.js.map +1 -1
  38. package/dist/development/vera-renderer-slots.d.ts +88 -92
  39. package/dist/development/vera-renderer-slots.d.ts.map +1 -1
  40. package/dist/development/vera-renderer-slots.js +1834 -1237
  41. package/dist/development/vera-renderer-slots.js.map +1 -1
  42. package/dist/development/vera-renderer-spread.d.ts +7 -41
  43. package/dist/development/vera-renderer-spread.d.ts.map +1 -1
  44. package/dist/development/vera-renderer-spread.js +539 -477
  45. package/dist/development/vera-renderer-spread.js.map +1 -1
  46. package/dist/development/vera-renderer-tag.d.ts +12 -3
  47. package/dist/development/vera-renderer-tag.d.ts.map +1 -1
  48. package/dist/development/vera-renderer-tag.js +671 -513
  49. package/dist/development/vera-renderer-tag.js.map +1 -1
  50. package/dist/development/vera-renderer-until.d.ts +24 -0
  51. package/dist/development/vera-renderer-until.d.ts.map +1 -0
  52. package/dist/development/vera-renderer-until.js +83 -0
  53. package/dist/development/vera-renderer-until.js.map +1 -0
  54. package/dist/development/vera-renderer.d.ts +48 -96
  55. package/dist/development/vera-renderer.d.ts.map +1 -1
  56. package/dist/development/vera-renderer.js +2607 -2104
  57. package/dist/development/vera-renderer.js.map +1 -1
  58. package/dist/vera-renderer-elements.min.js +2 -0
  59. package/dist/vera-renderer-elements.min.js.map +1 -0
  60. package/dist/vera-renderer-hydrate-slots.min.js +2 -0
  61. package/dist/vera-renderer-hydrate-slots.min.js.map +1 -0
  62. package/dist/vera-renderer-hydration.min.js +3 -0
  63. package/dist/vera-renderer-hydration.min.js.map +1 -0
  64. package/dist/vera-renderer-keyed.min.js +1 -1
  65. package/dist/vera-renderer-keyed.min.js.map +1 -1
  66. package/dist/vera-renderer-multi-window.min.js +2 -0
  67. package/dist/vera-renderer-multi-window.min.js.map +1 -0
  68. package/dist/vera-renderer-namespaces.min.js +2 -0
  69. package/dist/vera-renderer-namespaces.min.js.map +1 -0
  70. package/dist/vera-renderer-native-elements.min.js +2 -0
  71. package/dist/vera-renderer-native-elements.min.js.map +1 -0
  72. package/dist/vera-renderer-portal.min.js +2 -0
  73. package/dist/vera-renderer-portal.min.js.map +1 -0
  74. package/dist/vera-renderer-slots.min.js +1 -1
  75. package/dist/vera-renderer-slots.min.js.map +1 -1
  76. package/dist/vera-renderer-spread.min.js +1 -1
  77. package/dist/vera-renderer-spread.min.js.map +1 -1
  78. package/dist/vera-renderer-tag.min.js +1 -1
  79. package/dist/vera-renderer-tag.min.js.map +1 -1
  80. package/dist/vera-renderer-until.min.js +2 -0
  81. package/dist/vera-renderer-until.min.js.map +1 -0
  82. package/dist/vera-renderer.min.js +1 -1
  83. package/dist/vera-renderer.min.js.map +1 -1
  84. package/package.json +52 -9
  85. package/dist/development/vera-renderer-hydrate.d.ts +0 -147
  86. package/dist/development/vera-renderer-hydrate.d.ts.map +0 -1
  87. package/dist/development/vera-renderer-hydrate.js +0 -3136
  88. package/dist/development/vera-renderer-hydrate.js.map +0 -1
  89. package/dist/vera-renderer-hydrate.min.js +0 -2
  90. package/dist/vera-renderer-hydrate.min.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"vera-renderer.min.js","sources":["../src/dev-values.ts","../src/renderer.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"],"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","toggleAttribute","addEventListener","next","el","carrier","desc","Object","getOwnPropertyDescriptor","_$adopt$","getPrototypeOf","record","_$props$","hasOwn","win","ownerDocument","defaultView","HTMLElement","prototype","commitAdopt","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","_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"],"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,GAmB3CQ,EAAgB,qDAehBC,EAAsB,YAsU5B,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,GAxXP,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,EAAQgB,OAAQD,IAAK,CACvC,MAAME,EAAUjB,EAAQe,GACxB,IAAIG,EAAM,EACV,KAAOA,EAAMD,EAAQD,QAAQ,CAC3B,MAAMG,EAAKF,EAAQC,GACnB,GAzEiB,IAyEbjB,EAA0B,CAC5B,GACEkB,IAAOjB,GACI,KAAVA,IAAwB,MAAPiB,GAAqB,OAAPA,GAA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GAAY,IAAK1I,KAC9B,KA4BJ,MAAMyJ,EAAW,CACtB1N,KAAM,mBACN2N,GAAI,SACJC,GAAIV,EACJW,SAAU,GAOVC,QAAUC,IACRnE,EAAWmE,CAA+D"}
1
+ {"version":3,"file":"vera-renderer.min.js","sources":["../../shared-utils/src/diagnostic.ts","../../shared-utils/src/adopt-property.ts","../../shared-utils/src/markup-grammar.ts","../../shared-utils/src/utils.ts","../src/kinds.ts","../src/renderer.ts"],"sourcesContent":["/**\n * **Where every diagnostic code is explained.** The URL is permanent: a released bundle is immutable, so every version\n * published points here for ever — the domain cannot lapse and `/e/` cannot be reorganized without breaking links in\n * code nobody can edit; the docs site redirects instead. `scripts/sync-diagnostics.mjs` imports this constant, so the\n * pages and the bundles can never disagree about where they are.\n */\nexport const DOCS = 'https://verajs.dev/e/';\n\n/**\n * **What this copy of the framework has already said** (Brian's ruling, 2026-11-12): the ONE memory behind `warnOnce`, `errorOnce`\n * and `hasWarned`, for DEVELOPMENT-ONLY warnings. It replaced the hand-written once-flags every package kept\n * (`saidLists`, `warnedDrop`, per-element WeakSets, per-key Sets: two naming styles, Brian: no names). **A warning that\n * ships to production keeps its memory at its site** (bytes, measured 2026-11-12: the shared memory costs +80–145 B gz\n * per bundle); development-only warnings use warnOnce. Module state by necessity, since \"once\" spans every call on the\n * page. One per BUNDLE COPY, exactly the scope each flag had, because this package is inlined into every bundle.\n * A code, or `code key` for a string key, in a Set. An object key (an element, a setup function) in a WeakMap, so its\n * entry goes with the object. Marked pure, so a bundle that never prints once drops both.\n */\nconst printed = /* @__PURE__ */ new Set<string>();\nconst printedOn = /* @__PURE__ */ new WeakMap<object, Map<string, Set<unknown>>>();\n/**\n * A once's KEY: none (once per page), a string (once per that string), an object (once per that object: an element, a\n * class, a setup function), or the PAIR `[object, value]`, a value key on that object (a store write: the object and its\n * property; a keyed list: the list and the duplicate key, compared as the list compares them, by value, so `1` and `'1'`\n * stay apart). A pair is the only array a key may be.\n */\ntype OnceKey = string | object | readonly [object, unknown];\n/** Where an object key's (code, value) lives: the value set for that code on that object, made on demand. */\nconst valuesOn = (on: object, code: string, make: boolean): Set<unknown> | undefined => {\n let codes = printedOn.get(on);\n if (codes === undefined) {\n if (!make) return undefined;\n printedOn.set(on, (codes = new Map()));\n }\n let values = codes.get(code);\n if (values === undefined && make) codes.set(code, (values = new Set()));\n return values;\n};\n/** The object and value of an object or pair key. */\nconst split = (key: object): readonly [object, unknown] => (Array.isArray(key) ? (key as unknown as readonly [object, unknown]) : [key, undefined]);\n/** Whether (code, key) is new, recording it if so. */\nconst firstTime = (code: string, key?: OnceKey): boolean => {\n if (key === undefined || typeof key === 'string') {\n const entry = key === undefined ? code : `${code} ${key}`;\n if (printed.has(entry)) return false;\n printed.add(entry);\n return true;\n }\n const [on, sub] = split(key);\n const values = valuesOn(on, code, true)!;\n if (values.has(sub)) return false;\n values.add(sub);\n return true;\n};\n\n/**\n * **One shape for every diagnostic the framework prints** — the short line production keeps, the whole sentence\n * development adds — so a package converting its messages writes a table and a call, never its own format.\n *\n * production `[vera] hydration: element: found <i> — https://verajs.dev/e/hydration-fallback`\n * development `[vera] hydration: element: found <i> — fell back to a client render: … (hydration-fallback)`\n *\n * `subject` is the free information — what the code already has at hand, naming the problem area — the same in both\n * builds. `prose` is development only: the package's table entry (`Prose`), called behind `__DEV__` at the call site so\n * the table goes unreferenced in production and rollup drops it whole. Production prints the code inside the link, so\n * the reader is one click from the explanation, which `scripts/sync-diagnostics.mjs` publishes from the same tables.\n *\n * **Every production message is coded** (Brian, 2026-11-11; this supersedes \"convert where smaller\", 2026-10-02):\n * consistency over a few bytes, so no package keeps a hand-written production line beside its table.\n */\n/*\n * The parameter names are deliberately unlike anything a caller holds: terser will not inline a function whose\n * parameter shadows a name at the call site (measured 2026-10-02 — directives passes its own `code`, and a parameter\n * called `code` left `((e,t,n)=>`…`)(0,t,n)` in its bundle, +8 B; renamed, the call folds to the bare template).\n */\n/**\n * **A misused API, named by its function** — the thrown-error twin of `diagnostic()`: `untrack: expected a function …\n * (untrack-not-function)`, function-first because a stack already names the source and the sweep reads that shape. The\n * prose comes from a package's table, behind `__DEV__`, so a development-only guard costs production nothing.\n */\nexport const misuse = (forName: string, withCode: string, andProse?: false | readonly [string, string?]) =>\n __DEV__ && andProse\n ? `${forName}: ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `${forName}: ${DOCS}${withCode}`;\n\n/**\n * **A misused API and what it was misused ABOUT** — `misuse()` with a subject, in `diagnostic()`'s ` — ` separator:\n * `parseFrontmatter: line 3 — https://verajs.dev/e/cms-frontmatter-unsupported`. The subject is the free information\n * (a line, a URL and its status) and prints in both builds. A sibling rather than an optional parameter on `misuse()`,\n * because `misuse()` is inlined into every bundle that throws and a conditional subject would tax all of them for a\n * shape few need; a sibling is tree-shaken where unused.\n */\nexport const misuseAbout = (forName: string, aboutSubject: string, withCode: string, andProse?: false | readonly [string, string?]) =>\n __DEV__ && andProse\n ? `${forName}: ${aboutSubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `${forName}: ${aboutSubject} — ${DOCS}${withCode}`;\n\nexport const diagnostic = (\n inArea: string,\n bySubject: string,\n withCode: string,\n andProse?: false | readonly [string, string?]\n) =>\n /** `__DEV__` HERE as well as at the call: production folds this to the one-line form, branch and all. */\n __DEV__ && andProse\n ? `[vera] ${inArea}: ${bySubject} — ${andProse[0]}${andProse[1] ? ` ${andProse[1]}` : ''} (${withCode})`\n : `[vera] ${inArea}: ${bySubject} — ${DOCS}${withCode}`;\n\n/**\n * **Text from outside — a file path, a YAML key, a URL, an error's message — quoted before it reaches a line.** A log is a\n * pipeline, and such text can be shaped by an author or a request: a newline in it forges a line, an ESC sequence hides\n * one (log injection). `JSON.stringify` escapes both; cut to 80 characters so one value cannot fill the log. @verajs/ssr\n * keeps a twin (it cannot import this), held equal by tests/ssr-coded-diagnostics.\n */\n/**\n * `max` caps the length (80 by default); `Infinity` keeps the whole text for a value worth reading in full — a site\n * owner's own path — which is still ESCAPED: truncation and escaping are separate jobs, and a path is not free of control\n * characters just because its owner wrote it (2026-10-09).\n */\nexport const quoted = (text: string, max = 80): string => JSON.stringify(text.length > max ? `${text.slice(0, max)}…` : text);\n\n/**\n * **The errors a package constructs, marked as its own** — so a wrapper that reports an inner refusal (cms's\n * `generateManifest` around a frontmatter line) carries it as it is: already formatted, its outside text already\n * quoted. Anything else is foreign, and quoted. Identity, never a shape test: a message can imitate ours, an identity\n * cannot. @verajs/ssr keeps a twin (it cannot import this).\n */\nconst ours = /* @__PURE__ */ new WeakSet<object>();\nexport const own = <E extends Error>(error: E): E => {\n ours.add(error);\n return error;\n};\nexport const isOwn = (error: unknown): boolean => typeof error === 'object' && error !== null && ours.has(error);\n\n/**\n * **Whether this copy has already said `code` (for `key`)**: for a GUARD only, where deciding to warn costs work worth\n * skipping once the warning is out (development's whole-tree walk for unwired directive attributes, an event-name\n * guess over every property of an element). A site that only prints calls `warnOnce`. Asks, never records.\n */\nexport const hasWarned = (code: string, key?: OnceKey): boolean => {\n if (key === undefined || typeof key === 'string') return printed.has(key === undefined ? code : `${code} ${key}`);\n const [on, sub] = split(key);\n return valuesOn(on, code, false)?.has(sub) === true;\n};\n\ntype Detail = false | readonly [string, string?] | (() => readonly [string, string?] | undefined);\n/**\n * The printer behind both, on one level. `andDetail` is `diagnostic()`'s prose, or a function returning it where building\n * the sentence costs something: it is called only the first time. `...andMore` rides beside the line behind '%s' (an\n * element, a thrown error), never inside it, so text from outside cannot forge a line. The console method is read at the\n * call, so a test that replaces `console.warn` sees it.\n */\nconst sayOnce =\n (level: 'warn' | 'error') =>\n (inArea: string, bySubject: string, withCode: string, andDetail?: Detail, forKey?: OnceKey, ...andMore: unknown[]): void => {\n if (!firstTime(withCode, forKey)) return;\n const line = diagnostic(inArea, bySubject, withCode, typeof andDetail === 'function' ? andDetail() : andDetail);\n if (andMore.length) console[level]('%s', line, ...andMore);\n else console[level](line);\n };\n/**\n * **A diagnostic said once per page** (per key, where one is given: a string, or an object such as the element it is\n * about): `diagnostic()`'s arguments, then the key, then what rides beside the line. Coded in production exactly as\n * `diagnostic()` is, because it IS `diagnostic()`. `errorOnce` is its twin on `console.error`, for a refusal a page should\n * not miss.\n */\nexport const warnOnce = /* @__PURE__ */ sayOnce('warn');\nexport const errorOnce = /* @__PURE__ */ sayOnce('error');\n","import type { PropertyHost } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * **Delivering a bound property to a custom element that may not receive it yet** — the one home of the\n * rule `@verajs/renderer` (a `.prop` template binding) and `@verajs/renderer/spread` (a `.prop` bag key)\n * both apply. They ship as separate bundles that cannot import each other, so this package, inlined into\n * each, is where the rule lives once; before, each carried a full copy and a fix had to visit both.\n *\n * Returns where the binding stands after this write:\n * - `0` — still adopting: nothing received the value, so it was recorded in the element-carried\n * `_$props$`, which core's `init()` drains over whatever the class's field initializers wrote at\n * upgrade. Call again on the next write.\n * - `1` — received (a setter anywhere on the chain, an initialized component's `_$adopt$`, or an element\n * that is already upgraded): later writes are plain property writes.\n * - `2` — refused: a getter with no setter, where the plain write would throw. Later writes do nothing.\n *\n * `_$props$` and `_$adopt$` are `$`-named because they cross bundle boundaries (renderer, spread, core)\n * and must survive property mangling.\n *\n * **`_$adopt$` is a BRAND, not just a slot:** present means \"core has initialized this component\", which is what routes\n * a delivery to the live accessor (`1`) instead of the `_$props$` record. Do not move it to a class's PROTOTYPE\n * (2026-10-10): every instance would carry it BEFORE `init`, and a delivery to an upgraded-but-uninitialized element\n * would be adopted into a store that does not exist yet. It is ONE shared function written onto each element at `init`,\n * called with the element as `this` (`adopt.call(element, …)`) — 2026-10-11: the closure it replaced was free in\n * optimized code (measured) but cost Chrome's interpreted first render one allocation per component.\n */\n\n/** Development only: getter-only names already reported, per element — a `!name` re-asserts on every render. */\nlet refused: WeakMap<PropertyHost, Set<string>> | undefined;\n\nexport const adoptProperty = (element: PropertyHost, name: string, value: unknown): 0 | 1 | 2 => {\n /**\n * **`__proto__` is refused HERE, at the receiver** (2026-11-10): `element.__proto__ = v` replaces the element's\n * prototype, and an own `__proto__` key reaches a bag through `JSON.parse`. This is the choke point every delivery\n * passes; the renderer's template binding and spread's bag key refuse it first, with a development warning naming\n * where it was written (their second addresses: renderer.ts `proto-binding`, spread.ts refusal 3).\n */\n if (name === '__proto__') return 2;\n const adopt = element._$adopt$ as ((key: string, value: unknown) => void) | undefined;\n /** The walk comes first: what it finds decides whether writing is even legal. */\n for (let carrier: object | null = element; carrier !== null; carrier = Object.getPrototypeOf(carrier)) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc === undefined) continue;\n if (desc.set !== undefined) {\n element[name] = value;\n return 1;\n }\n if (desc.get !== undefined) {\n if (adopt !== undefined) adopt.call(element, name, value);\n else if (__DEV__) {\n const names = (refused ??= new WeakMap()).get(element) ?? new Set<string>();\n refused.set(element, names);\n if (!names.has(name)) {\n names.add(name);\n console.warn(diagnostic('renderer', `<${element.localName}>`, 'getter-only-prop', __DEV__ && SHARED.getterOnlyProp(name)));\n }\n }\n return 2;\n }\n break; // a data property: an own field, or an inherited default — nothing receives it\n }\n element[name] = value;\n if (adopt !== undefined) {\n adopt.call(element, name, value);\n return 1;\n }\n const record = (element._$props$ ??= {}) as Record<string, unknown>;\n const first = __DEV__ && !Object.hasOwn(record, name);\n record[name] = value;\n /** Upgrade is read off the PROTOTYPE — a bag key named `constructor` can shadow `el.constructor`. The realm is the element's. */\n const view = element.ownerDocument.defaultView as unknown as {\n HTMLElement: { prototype: object };\n customElements: CustomElementRegistry;\n } | null;\n const upgraded = view === null || Object.getPrototypeOf(element) !== view.HTMLElement.prototype;\n /** Development only: an element that never drains still loses the value at upgrade — told apart by ownership. */\n if (__DEV__ && view !== null && !upgraded && first) {\n const tag = element.localName;\n view.customElements.whenDefined(tag).then(() => {\n let owned = false;\n for (let carrier: object | null = element; carrier !== null; carrier = Object.getPrototypeOf(carrier)) {\n const desc = Object.getOwnPropertyDescriptor(carrier, name);\n if (desc === undefined) continue;\n owned = desc.get !== undefined || desc.set !== undefined;\n break;\n }\n if (!owned && element[name] !== record[name])\n console.warn(diagnostic('renderer', `<${tag}>`, 'upgrade-clobber', __DEV__ && SHARED.upgradeClobber(name)));\n });\n }\n return upgraded ? 1 : 0;\n};\n","import { misuse } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n/**\n * HTML's own element grammar — the facts about tags that every package emitting or reading markup\n * has to agree on.\n *\n * These are not this framework's rules; they are the parser's, and a package that guesses at them\n * produces markup whose *parse* differs from what its author wrote. That failure is silent by\n * nature: nothing throws, the page renders, and the DOM simply has a different shape than the\n * source said. See `VOID_ELEMENTS` below for the two measured instances.\n *\n * **Never `exec` a shared `/g` regex in a loop whose body can re-enter it** (a nested render, a recursive compose or\n * serialize, a callback): the inner use resets `lastIndex`, and the outer loop restarts or skips. Setting `lastIndex`\n * before every `exec` is not enough. Measured 2026-11-17: the static tier's composer re-entered its marker regex through\n * a nested template and composed forever; split once, or use a fresh regex per walk.\n *\n * **Why here.** These sets had grown copies in `@verajs/ssr`, `@verajs/cms` and (as a regex) the\n * renderer, all agreeing by luck rather than by construction. This file is the one source for\n * every package that can take a build-time import — `@verajs/shared-utils` is private and inlined,\n * so importing it costs a consumer nothing at runtime and adds no published dependency.\n *\n * **`@verajs/ssr` cannot import it** and keeps its own copies: that package publishes its `src`\n * with no dependencies at all, so an import of a package that is never published would break the\n * published tarball. The same constraint already forced a twin of `escapeStyleText` there. A copy\n * is acceptable; a copy nothing checks is not, so `tests/markup-grammar-homes.test.mjs` drives\n * every copy against this file source-to-source rather than trusting they get edited together.\n *\n * **A consumer may keep a different SHAPE for the same fact** where a hot path needs one — the\n * renderer matches raw-text tags with a case-insensitive regex rather than lowercasing a string to\n * probe a `Set`. The rule is agreement, not representation, and the homes test asserts agreement\n * across whatever shape each home uses.\n */\n\n/**\n * Elements with no end tag, and therefore no children.\n *\n * Both directions of getting this wrong are silent, and both were live in this repo until the\n * audit of 2026-09-12 measured them:\n *\n * - **A non-void element written self-closing swallows what follows it.** HTML has no\n * self-closing syntax outside foreign content, so `<div/><span>after</span>` parses as\n * `<div><span>after</span></div>` — the sibling becomes a child. Every JSX toolchain treats\n * `<div/>` as an empty element, which is exactly why authors write it.\n * - **A void element written with an end tag is duplicated.** A parser reads `</br>` as *another*\n * `<br>`, so `<br></br>` renders two line breaks where the author wrote one.\n *\n * Inside `<svg>` and `<math>` the parser switches to foreign content, where XML self-closing *is*\n * honored — so neither rule applies there, and a consumer that checks must know where it is.\n */\nexport const VOID_ELEMENTS = new Set([\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\n 'link', 'meta', 'param', 'source', 'track', 'wbr',\n]);\n\n/**\n * Elements a parser reads the children of as text rather than as markup.\n *\n * Two pieces of measured lore travel with this list and are the reason it is not read off a spec:\n *\n * - `iframe` and `noscript` were once absent from the SSR copy, which built a tree no browser\n * builds — `<noscript><img src=\"x\"></noscript>` produced an element, so\n * `querySelectorAll('noscript img')` answered 1 where every engine answers 0.\n * - `noscript` is raw text only when scripting is ENABLED. Fragment parsing disables it, and\n * Chromium and WebKit then parse the content as markup while Firefox parses it as text — so a\n * binding inside `<noscript>` worked in two engines and painted the renderer's internal marker\n * onto the page in the third. Listing it is safe in both parses.\n *\n * jsdom is not the oracle for either: it parses with scripting disabled and agrees with the old,\n * wrong list.\n */\nexport const RAW_TEXT_ELEMENTS = new Set(['style', 'script', 'textarea', 'title', 'iframe', 'noscript']);\n\n/**\n * The hyphenated names SVG and MathML already define, which the custom-elements spec reserves — so a\n * dash in one of these does NOT make it a custom element.\n *\n * Measured, the one that matters: JSX treats a dash-named tag as a custom element and compiles its\n * attributes to PROPERTIES, which turned `<annotation-xml encoding=\"text/html\">` into\n * `.encoding=${…}`. The HTML parser decides that element is an integration point from the\n * ATTRIBUTE on its start tag, so HTML content inside was moved out of the `<math>` entirely, and a\n * custom element there was built MathML-namespaced and never upgraded — silent on the server and\n * the client alike. That is also the exact spelling the renderer's own warning recommends.\n */\nexport const RESERVED_ELEMENT_NAMES = new Set([\n 'annotation-xml', 'color-profile', 'font-face', 'font-face-src',\n 'font-face-uri', 'font-face-format', 'font-face-name', 'missing-glyph',\n]);\n\n/**\n * **A custom element, by its name:** a dash, except the eight names SVG and MathML already own (above). One\n * definition for every package that asks — `@verajs/jsx` compiles such a tag's attributes to properties, and\n * `@verajs/renderer/slots` captures such a host's children. (The renderer's own property paths ask a narrower\n * question, the bare dash, on its hot path; a reserved name never carries a property binding.)\n */\nexport const isCustomElementName = (tag: string): boolean =>\n tag.includes('-') && !RESERVED_ELEMENT_NAMES.has(tag.toLowerCase());\n\n/**\n * A URL whose scheme a browser reads as `javascript:` — navigating to one runs it, so a BOUND value\n * that parses this way is code arriving as data, never a link.\n *\n * Matched the way the URL Standard's parser reads a scheme, because that is the only reading that\n * matters: leading C0 controls and spaces are stripped, ASCII tab, LF and CR are removed anywhere, and\n * the scheme is case-insensitive. A check that only lowercases is bypassed by `\" jAvA\\tscript:\"`,\n * which every engine navigates to. React's blocking pattern is the same rule.\n *\n * `@verajs/ssr` keeps a twin (it cannot import this package), held to this one by\n * `tests/url-sinks.test.mjs`, so a server never emits a link the client refuses.\n */\n// eslint-disable-next-line no-control-regex\nexport const SCRIPT_URL = /^[\\u0000- ]*j[\\t\\n\\r]*a[\\t\\n\\r]*v[\\t\\n\\r]*a[\\t\\n\\r]*s[\\t\\n\\r]*c[\\t\\n\\r]*r[\\t\\n\\r]*i[\\t\\n\\r]*p[\\t\\n\\r]*t[\\t\\n\\r]*:/i;\n\n/**\n * **Every bound name whose value is checked for a `javascript:` URL — and how.** One test answers both.\n *\n * Captured, checked from the start: the attributes (and their reflecting properties) whose value a browser\n * NAVIGATES to or loads as a document — links and areas (`href`, SVG's `xlink:href`), forms (`action`,\n * `formaction`), frames (`src`), and `<object data>`. `src` is matched on every element — refusing one on an `<img>`\n * costs nothing, since an image never runs it. Resource-only attributes (`poster`, `srcset`) are fetched, never run,\n * so they are not listed.\n *\n * Not captured, checked ITEM BY ITEM (`SCRIPT_URL_ITEM`): an SVG animation's values — `to`, `from`, `by`, `values`.\n * `<animate attributeName=\"href\" to=\"javascript:…\">` (or `<set>`, or `values`) writes its value onto the link it\n * animates, and clicking the link then RUNS it: measured 2026-09-30 in Chromium, Firefox and WebKit, through `href`\n * and `xlink:href` alike. Refused on EVERY element and whatever `attributeName` says, because `attributeName` can\n * itself be bound or spread, a server spread has no element to ask, and no legitimate value of any attribute by these\n * names starts with `javascript:` (a component's `to`, a router link's, is a URL too). **Only these names are checked\n * item by item**: an unanchored test scans the whole value for `;`, which on a bound `src` holding a data URI costs\n * ~0.45 ms per MB per update in Chromium and Firefox (measured 2026-09-30), where the anchored `SCRIPT_URL` stops at\n * the first character.\n *\n * Case-insensitive, because property spellings (`formAction`) and attribute spellings meet here. `@verajs/ssr` keeps\n * a twin, held to this one by `tests/url-sinks.test.mjs`.\n */\nexport const URL_SINK = /^(?:(href|src|action|formaction|xlink:href|data)|to|from|by|values)$/i;\n\n/**\n * `SCRIPT_URL` at the start of the value OR of any `;`-separated item of it — an animation's `values` list\n * (`\"#a;javascript:…\"`) applies every item in turn. Only for an animation's values (`URL_SINK`'s uncaptured names): a `;` inside an `href` is a path\n * character, and `/p;javascript:x` is a working link, never a script. Written out rather than derived from\n * `SCRIPT_URL`: the repeated text costs less gzipped than the code that would build it.\n */\n// eslint-disable-next-line no-control-regex\nexport const SCRIPT_URL_ITEM = /(?:^|;)[\\u0000- ]*j[\\t\\n\\r]*a[\\t\\n\\r]*v[\\t\\n\\r]*a[\\t\\n\\r]*s[\\t\\n\\r]*c[\\t\\n\\r]*r[\\t\\n\\r]*i[\\t\\n\\r]*p[\\t\\n\\r]*t[\\t\\n\\r]*:/i;\n\n/**\n * **An inline event-handler attribute** — `on` and a letter, any case (`onclick`, `onLoad`, `onbeforeinput`): its\n * value is run as CODE, so a BOUND one is code arriving as data, refused by the template scanner, `spread` and the\n * server alike (a static `onclick=\"save()\"` is the author's own and untouched). Broad on purpose — it also refuses a\n * bound `once=`/`online=` attribute; the precise rule would need the platform's list of handler names. `@verajs/ssr`\n * keeps a twin, held to this one by `tests/inline-handlers.test.mjs`.\n */\nexport const INLINE_HANDLER = /^on./i;\n\n/**\n * **A `<script>` that is a JSON data block, by its `type`** (Brian, 2026-11-17): the only script a value may enter (state\n * handoff, JSON-LD); every other script hole is refused (`script-hole`), since a value there is code — run on a page the\n * server rendered. \"The type ends in `json`\" never names a script that runs — measured on Chromium, Firefox and WebKit,\n * parameters included (`text/javascript; x=json` is inert), as the spec reads a type (a JavaScript MIME essence match on\n * the whole string); `type=\"\"` and a `language` attribute alone do run, and end in no `json`.\n */\nexport const JSON_BLOCK = /json\\s*$/i;\n\n/**\n * Whether a script START TAG, as written, opens a JSON data block: its attributes read IN ORDER (so a `type=` inside\n * another attribute's quoted value is never taken for the type), the first `type` as the parser keeps it, and that value\n * holding no `&` (a character reference is refused rather than decoded — a decoder slightly off would make the server\n * and the client disagree) and ending in `json` (`JSON_BLOCK`). Every side applies it to the start tag that OPENED the\n * script a hole sits in — recorded where the scanner enters raw text, never found by searching back (a `<script…>`\n * inside a script's own text is no start tag). `@verajs/ssr` holds a twin, held equal by a test.\n */\nexport const dataBlock = (openTag: string) => {\n for (const [, name, double, single, bare] of openTag.slice(7).matchAll(/[\\s/]*([^\\s\"'>/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]*)))?/g))\n if (name!.toLowerCase() === 'type') {\n const type = double ?? single ?? bare ?? '';\n return !type.includes('&') && JSON_BLOCK.test(type);\n }\n return false;\n};\n\n/**\n * **A raw-text element's composed text, unable to end its element** — the rule every side writes, byte for byte (the\n * server's `styleHole` and JSON rule, the renderer, hydration's comparison, lite, static): in a style each `</style`\n * (any case) as `<\\/style` (the same CSS), in a JSON data block every `<` as `\\u003c` (the same JSON). A style's or a\n * JSON block's text is serialized VERBATIM (BROWSER-LEDGER), so written as composed, a value became markup once the page\n * was saved from the DOM and parsed again. Applied to the COMPOSED text: a closer can form across a hole. Idempotent —\n * neither form leaves what it replaces.\n */\nexport const closedRawText = (text: string, json: boolean) =>\n json ? text.replace(/</g, '\\\\u003c') : text.replace(/<\\/(style)/gi, '<\\\\/$1');\n\n/**\n * **A value as inert text in ANY position** — every ASCII non-word character as a character reference (`<` `&#60;`,\n * a space `&#32;`, `=` `&#61;`), everything else as it is: the encoding `@verajs/static` writes every value with, and the\n * renderer writes a never-shown element's values with. Read as raw text it holds no `<`; read as markup it decodes to\n * the same characters and cannot end a tag, a quoted or unquoted attribute value, or the element.\n */\nexport const encodeText = (text: string) => text.replace(/[^\\w\\u0080-\\uffff]/g, (c) => `&#${c.charCodeAt(0)};`);\n\n/**\n * **The properties that replace an element's whole content** — a binding to one owns the element's children, so it\n * cannot share the element with content of its own (markup, or a child binding the write would strand: a later commit\n * into it then throws on a missing parent). Development refuses the pair in the template scanner and in `spread` alike.\n */\nexport const CONTENT_PROPERTY = /^(?:textContent|innerHTML|innerText|outerHTML|outerText)$/;\n/**\n * Whether an element has content of its own that a content-replacing write would strand or lose: a child that is not\n * whitespace-only text (formatting whitespace loses nothing), or — `$content`, set in development by the renderer — a\n * child binding that owns the element whole and leaves no node behind until it commits. The element-specific `.text`\n * setters (`<a>`, `<option>`, `<title>`, `<script>`) are deliberately not in the list: a custom element's own `text`\n * prop is common, and would be refused for nothing.\n */\nexport const ownsContent = (element: Element): boolean => {\n if ((element as Element & { $content?: boolean }).$content === true) return true;\n for (let node = element.firstChild; node !== null; node = node.nextSibling)\n /**\n * An EMPTY text node is a child binding's anchor, not formatting: formatting whitespace is never empty. And\n * formatting is HTML's whitespace, `[ \\t\\n\\f\\r]` — not JS's `trim()`, which would let an `&nbsp;` be overwritten.\n */\n if (node.nodeType !== 3 || (node as Text).data === '' || /[^ \\t\\n\\f\\r]/.test((node as Text).data)) return true;\n return false;\n};\n/** `side` is the module the user wired — `renderer` for a template, `spread` for a spread. */\nexport const contentClash = (side: string, tag: string, name: string): never => {\n throw new Error(misuse(side, 'content-clash', __DEV__ && SHARED.contentClash(tag, name, side === 'spread' ? `<${tag} \\${spread({ '.${name}': … })}></${tag}>` : `<${tag} .${name}=\\${…}></${tag}>`)));\n};\n\n/**\n * **An expression in TAG-name position** (`<${x}>`, `</${x}>`, `<my-${x}>`) without `@verajs/renderer/tag`: no\n * element can be made from it — the parser reads a tag name before any value exists. Refused by the client in\n * development and by the server in every build, with one message. The tag entry splices a tag VALUE into the\n * statics before the renderer sees it, so only a non-tag ever reaches here.\n */\nexport const TAG_NAME_HOLE = /<\\/?[^\\s>]*$/;\nexport const tagHole = (side: string): never => {\n throw new Error(misuse(side, 'tag-hole', __DEV__ && SHARED.tagHole()));\n};\n","import type { HandlerHolder, Untracked } from './types.js';\nimport { diagnostic } from './diagnostic.js';\nimport * as SHARED from './diagnostics.js';\n\n/**\n * Get an object's type.\n *\n * @param obj The object\n * @return The type\n */\nexport const getType = (obj: unknown) => Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\n\n/**\n * Weak collections need their per-key dependencies stored weakly, or tracking `weakMap.get(obj)`\n * holds `obj` and defeats the whole point of the type. Checked by type string rather than\n * `instanceof`, which fails across realms (iframes, `vm`).\n */\n/**\n * A WeakMap or WeakSet (or WeakRef) — read from `Symbol.toStringTag`, the tag `Object.prototype.toString` itself reads, so\n * the answer is the same (another realm's collections included) without building and lower-casing a string on every first\n * tracked read of every object.\n */\nexport const isWeakCollection = (item: unknown) => {\n const tag = (item as { [Symbol.toStringTag]?: unknown } | null)?.[Symbol.toStringTag];\n return typeof tag === 'string' && (tag[0] === 'W' || tag[0] === 'w');\n};\n\n/**\n * Remove a trailing slash from an url if its not root url (`/`).\n *\n * @param str String to remove trailing slash from\n */\nexport const stripTrailingSlash = (str: string) => (str !== '/' && str.endsWith('/') ? str.slice(0, -1) : str);\n\n/**\n * **Reports an error nothing else handled, the way the platform reports one.** `reportError` fires\n * the window's `error` event — what `window.onerror`, error trackers and test runners listen for —\n * without unwinding the caller, so one failing hook or ref never stops its siblings. A bare\n * `console.error` reached none of those: a component could stop updating while every page-error\n * listener stayed silent. Off-browser (Node has no `reportError`) the console is all there is.\n * `line` is the framework's own line, printed beside the error — a CODED one (2026-10-09):\n * each caller passes `'[vera] <code>'` in production and its table's `diagnostic()` sentence in development, both\n * literal codes at the call site, so the static checks read them. The subject is fixed wording too (`a hook`, `an\n * element ref`), never a tag name: this line is the console's FORMAT (no `'%s'`, which measured +2–3 B on the renderer\n * bundles), so nothing from outside may reach it — the element goes to the `'error'` handlers instead. Production prints it only where the platform has no\n * `reportError` (Node); in a browser, `reportError` alone reports.\n *\n * Shared by core (a hook threw) and the renderer (a ref threw) so the fallback is one rule.\n */\nexport const reportUncaught = (error: unknown, line: string) => {\n if (typeof reportError !== 'function') console.error(line, error);\n else {\n if (__DEV__) console.error(line, error);\n reportError(error);\n }\n};\n\n/**\n * **Reports what user code a render called threw — to the app's `'error'` chain, else as uncaught.** One rule for\n * every callback the framework runs on the user's behalf and survives: a hook (core), an element ref, and an element\n * claim's `create`/`mount`/`unmount` (the renderer). The caller catches at the call site and carries on, so one\n * failing callback never stops its siblings or leaves a commit half applied. `element` is the component the error\n * belongs to, handed to each handler. Every throw is reported — nothing is deduped, as a hook's never was.\n * **Core keeps a deliberate twin** (`reportHookError`, the same rule as a `forEach`): routed through here it measured\n * +11 B gzip on `vera.min.js` (2026-10-09). A change to the rule changes both.\n */\nexport const reportTo = (handlers: readonly unknown[] | undefined, error: unknown, element: Element | undefined, line: string) => {\n if (handlers?.length) for (const handler of handlers) (handler as (error: unknown, element?: Element) => void)(error, element);\n else reportUncaught(error, line);\n};\n\n/** The component a render root belongs to: a shadow root's host, or a light root itself. */\nexport const hostOf = (root: Node | null | undefined): Element | undefined =>\n root == null ? undefined : root.nodeType === 11 ? (root as ShadowRoot).host : (root as Element);\n\n/** `fn(a, b, c)`, tracked as the caller is — the stand-in for core's `untracked` when no core was wired. */\nexport const call: Untracked = (fn, a, b, c) => fn(a!, b!, c!);\n\n/**\n * **Runs a bound handler, and its callers run it UNTRACKED**: the renderer's template `@event` and spread's event key,\n * each through `untracked(dispatch, holder, event)` (2026-10-09). An effect that fires an event synchronously\n * (`el.click()`, `focus()`, `dispatchEvent`) runs the handler INSIDE itself, and the handler's reads subscribed the\n * effect: a handler doing `state.n++` made the effect re-run on every click, a self-feeding loop held to one round per\n * frame, forever (measured). A handler's reads are event-time decisions, never a hook's inputs. The directives engine's\n * delegated `listen` makes the same choice its own way. A function is called with the element as `this`; an object\n * through its `handleEvent`. One function for both callers (Brian's size-audit ruling, 2026-11-13): it was two\n * identical copies, so a fix had two addresses; each bundle still inlines its own.\n */\nexport const dispatch = (holder: HandlerHolder, event: Event) => {\n const handler = holder._handler as EventListener | EventListenerObject | null;\n if (typeof handler === 'function') handler.call(holder._element as never, event);\n else if (typeof handler?.handleEvent === 'function') handler.handleEvent(event);\n};\n\n/**\n * **Whether a property binding is a `<select>`'s SELECTION** — `value` or `selectedIndex` — which the renderer and\n * `spread` both treat as live: re-asserted every render and compared against the live value (as `!value` is), because\n * a select's options can be replaced under an unchanged value, which drops the selection. One rule, asked once per\n * binding by both, so a template and a spread key cannot disagree about it.\n *\n * In development it names the one shape it cannot serve: on a `<select multiple>` both properties read and set a\n * SINGLE selection, so a selection the user adds is kept rather than controlled. Always writing there was measured\n * 2–3% slower on every table with a select per row, to serve an API that does not fit — hence a warning, not a cost.\n */\nexport const isSelection = (element: Element, name: unknown) => {\n if ((name !== 'value' && name !== 'selectedIndex') || element.localName !== 'select') return false;\n return true;\n};\n\n/**\n * Development: the one shape a selection binding cannot serve, named by the module the user wired (`side`). Called only\n * behind `__DEV__` at each call site, so production keeps `isSelection` exactly as small as it was (a `side` argument on\n * it measured +1 B, a default +9 B on vera-renderer.min.js — 2026-10-09).\n */\nexport const saySelectMultiple = (element: Element, name: unknown, side: string) => {\n if (element.hasAttribute('multiple'))\n console.warn(diagnostic(side, '<select multiple>', 'select-multiple', __DEV__ && SHARED.selectMultiple(String(name))));\n};\n\n/**\n * `target[key]`, as a function — how a component's GETTER is read through `untracked`. Not `Reflect.get`: `untracked`\n * passes three arguments, and `Reflect.get`'s third is the RECEIVER — `undefined` there runs the getter with no `this`.\n */\nexport const read = (target: object, key: string) => (target as Record<string, unknown>)[key];\n\n/**\n * **What a thrown value says, whatever was thrown — and it never throws itself.** A caught value comes from author\n * code (a `resolve` option, a motion tick or vocabulary function), and JavaScript can throw anything: `null`, an object\n * with no prototype (`String()` finds no `toString`), one whose `toString` or `message` getter throws, a Proxy whose\n * traps throw. Formatting it naively replaced the real failure with an unrelated TypeError from inside the framework.\n * Anything unreadable becomes a fixed phrase; `Object.prototype.toString` is no fallback, since it reads\n * `Symbol.toStringTag` through a Proxy's trap too.\n *\n * **A deliberate duplicate of `thrownMessage` in `packages/ssr/src/vera/escaping.ts` — fix both copies.** `@verajs/ssr`\n * is compiled per file with no bundling, so it cannot import this private, unpublished package at run time;\n * `tests/thrown-message-copies.test.mjs` runs one table of thrown values against both, so they cannot drift.\n */\nexport const thrownMessage = (error: unknown): string => {\n try {\n if (error instanceof Error) return String(error.message);\n const message = (error as { message?: unknown } | null)?.message;\n return typeof message === 'string' ? message : String(error);\n } catch {\n return '[unprintable value thrown]';\n }\n};\n\n/** `data-tone` → `dataTone`: the prop an observed attribute arrives as, in every package that defines components (`@verajs/core`'s `define`, its checks, `@verajs/lite`). */\nexport const camel = (name: string) => name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n","/**\n * **The renderer's binding kinds and child-part modes** — numbers both `renderer.ts` and the separately bundled\n * `hydration.ts` read, from ONE source (each bundle inlines them; they are literals in the output). A change here\n * changes the hand-off's protocol: bump `$V` in `renderer.ts`.\n */\n/** A binding's kind, resolved once per template. */\nexport const IGNORED = 0; // consumed, nothing rendered: inside a comment, the later values of a multi-part attribute\nexport const CHILD = 1; // anchored on a primed empty text node the template carries\nexport const SOLE = 2; // its element's only content: no anchor in the template, the first commit writes `textContent`\nexport const ATTR = 3;\nexport const PROPERTY = 4;\nexport const BOOLEAN = 5;\n/** `EVENT` through `ADOPT` hold a `Slot` record in their node slot — one range test, in `instantiate` and `commit`. */\nexport const EVENT = 6;\n/** An element-position expression: a ref, or a value that applies itself (`_$apply$`). */\nexport const REF = 7;\n/** An element-position expression ON a `<select>`: a value applying itself there (a spread) waits for `flush`. */\nexport const SELECT_REF = 8;\n/** `.name` on a custom element — see `adoptProperty` in shared-utils. */\nexport const ADOPT = 9;\n/**\n * Kinds from here on re-assert on EVERY render, so the update loop never skips them as unchanged:\n * `!name` writes from the live DOM's point of view (a sibling radio's click unchecks this one with no\n * event on it), and a `<select>`'s selection is re-applied after its options exist — see `flush`.\n */\nexport const LIVE = 10;\n/** A `<select>`'s selection — `value` or `selectedIndex` (`isSelection`) — written when the pass ends: see `flush`. */\nexport const SELECT = 11;\n/** `!name` on a custom element: compared against the LIVE value — read through `untracked`, it is the component's getter. */\nexport const LIVE_CUSTOM = 12;\n/** A binding that must never write — and, from here on, the kinds `commit` handles before anything is computed. */\nexport const REFUSED = 13;\n/** A `<select>`'s `selectedIndex` — the rare spelling of its selection, queued as `SELECT` is (see `flush`). */\nexport const SELECT_INDEX = 14;\n/**\n * **An HTML `<style>`'s or JSON data block's whole text** — ONE binding (the element's first value; the others are\n * consumed, as a multi-part attribute's are) composes the statics and values and writes the element's text when it\n * changed. Its text is serialized VERBATIM (BROWSER-LEDGER), so it is written unable to end its element, as the server\n * writes it: in a style each `</style` as `<\\/style`, in a JSON block every `<` as `\\u003c` — on the COMPOSED text, since\n * a closer can form across a hole. Committed in `commit`'s cold branch: the hot text line is untouched.\n */\nexport const RAW_STYLE = 15;\nexport const RAW_JSON = 16;\n/**\n * **An element whose content is never shown** (`<iframe>`, `<noscript>`, `<xmp>`, `<noembed>`, `<noframes>`,\n * `<plaintext>`): its statics and its values composed as text, each VALUE fully encoded (every ASCII non-word character\n * as a character reference), so a page saved from the DOM and parsed again — with scripting on (raw text) or off\n * (markup) — holds no value that can end the element or add an attribute.\n */\nexport const RAW_ENCODED = 17;\n\n\n/** A child part's mode: what its range currently holds. */\nexport const EMPTY = 0;\nexport const TEXT = 1;\nexport const TEMPLATE = 2;\nexport const LIST = 3;\nexport const NODE = 4;\n\n/**\n * **The hydration hand-off's positions** — the renderer sets `$H` to an array at `connect`, and `hydration.ts` reads\n * it by these. An array, not an object of named fields: the names cost every app bytes (−35 B gzipped measured,\n * 2026-10-02), and these constants inline to literals in both bundles. The first two are FROZEN across protocols — a\n * hydration from another release reads the protocol at 0 and, on a mismatch, can still install its clearing hook at 1.\n * Any other change here is a protocol change: bump `PROTOCOL`.\n */\n/**\n * **The protocol of this package's first-party seams** — the renderer's hand-off (`$H`, at `HANDOFF_PROTOCOL`) and slots'\n * capture (`_$capture$`), both read by hydration. One number for both: the three ship in one package, and a change to\n * either seam bumps it. A hydration that meets another number declines (the page renders fresh) and says so.\n */\nexport const PROTOCOL = 2;\n/** The protocol number — FROZEN at 0. */\nexport const HANDOFF_PROTOCOL = 0;\n/** The first-render hook's setter — FROZEN at 1. */\nexport const HANDOFF_ADOPTER = 1;\nexport const HANDOFF_GET_TEMPLATE = 2;\nexport const HANDOFF_CHILD_PART = 3;\nexport const HANDOFF_INSTANCE = 4;\nexport const HANDOFF_SLOT = 5;\nexport const HANDOFF_UNSET = 6;\nexport const HANDOFF_UPGRADED = 7;\nexport const HANDOFF_COMMIT = 8;\nexport const HANDOFF_COMMIT_AS = 9;\nexport const HANDOFF_HOOK_UP = 10;\nexport const HANDOFF_RESOLVE = 11;\nexport const HANDOFF_ROOTS = 12;\nexport const HANDOFF_TO_TEXT = 13;\nexport const HANDOFF_REMOVAL_WORK = 14;\n","/**\n * @verajs/renderer — a template-identity renderer.\n *\n * A tagged template's `strings` array is interned per call site, so it keys a parsed `<template>`.\n * An instance clones it and binds the expression positions; every later render of the same shape\n * commits only the values that changed. Lists reconcile by index here, by key through\n * `@verajs/renderer/keyed`.\n *\n * Contracts the speed pays for:\n * - The renderer owns its container below the mount point: a part that owns a whole parent clears it\n * with one `textContent = ''`.\n * - Do not `normalize()` rendered content — child anchors are text nodes.\n * - A string renders as text, never as markup. There is no `innerHTML` sink.\n *\n * Internal members are `_`-prefixed because the production build mangles `/^_[a-z]/`. `$`-named\n * members cross bundle boundaries (keyed, spread, slots) and survive mangling by not matching it.\n */\n\nimport {\n adoptProperty,\n call,\n CONTENT_PROPERTY,\n contentClash,\n ownsContent,\n TAG_NAME_HOLE,\n tagHole,\n INLINE_HANDLER,\n isSelection,\n saySelectMultiple,\n read,\n reportTo,\n hostOf,\n SCRIPT_URL,\n SCRIPT_URL_ITEM,\n URL_SINK,\n dataBlock,\n JSON_BLOCK,\n closedRawText,\n encodeText,\n diagnostic,\n dispatch,\n hasWarned,\n checkForeign,\n landing,\n misuse,\n SHARED,\n warnOnce,\n} from '@verajs/shared-utils';\nimport { attributeValueKind, eventKey, eventNameGuess } from './dev-values.js';\nimport { PROSE } from './renderer-diagnostics.js';\nimport type { Untracked, PropertyHost } from '@verajs/shared-utils';\n\nimport type { InstanceHook, TemplateResult } from './types.js';\nimport { PROTOCOL, IGNORED, CHILD, SOLE, ATTR, PROPERTY, BOOLEAN, EVENT, REF, SELECT_REF, ADOPT, LIVE, SELECT, LIVE_CUSTOM, REFUSED, SELECT_INDEX, RAW_STYLE, RAW_JSON, RAW_ENCODED, EMPTY, TEXT, TEMPLATE, LIST, NODE } from './kinds.js';\n\nexport type { TemplateResult } from './types.js';\n\n/**\n * The marker the one parse per template writes into each hole — into an attribute name (`0\\uFFFF`), a bogus\n * comment (`<?\\uFFFF0>`) and raw text (`\\uFFFF0\\uFFFF`). U+FFFF is a Unicode noncharacter: real text never contains\n * it, so an author's statics cannot collide with it, and the HTML preprocessor keeps it (a parse error, never a\n * rewrite) — in every engine, `tests/browser/template-marker.test.js`. Data never reaches the parsed string at all:\n * values are committed through the DOM, and the one path that builds strings at runtime (`tag`) refuses any name\n * outside `[a-zA-Z0-9._-]`. Fixed rather than random, so the parse is deterministic.\n */\nconst MARKER = '\\uFFFF';\n/** Every marker as a nested `<template>` serializes it: an addressed attribute, a child comment, a raw-text pair. */\nconst INERT_MARKERS = / \\d+\\uFFFF(?:=\"[^\"]*\")?|<!--\\?\\uFFFF\\d+-->|\\uFFFF\\d+\\uFFFF/g;\n\nconst doc = document;\nconst comment = () => doc.createComment('');\n\n/**\n * The scanner — one regex per state, each finding the next thing that matters (lit-html's design). It\n * decides only what each expression position IS; the browser's parser builds the tree. Every marker\n * carries its binding's index, so pairing is ADDRESSED: an element the parser drops takes only its own\n * binding with it and never shifts a later value onto another element (a security property —\n * `tests/dropped-element-bindings.test.mjs`).\n */\n/** `<!-->` and `<!--->` are not opened at all: they close themselves (the tokenizer's abrupt close), so they stay text. */\nconst TEXT_END = /<(?:(!--(?!-?>)|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\n/**\n * A comment ends at `-->` or `--!>` — read as a comment past either, a value after one was dropped while the browser\n * rendered it. The abrupt `<!-->`/`<!--->` never open one (`TEXT_END`'s lookahead; a lookBEHIND would not even parse\n * in an older Safari).\n */\nconst COMMENT_END = /--!?>/g;\nconst COMMENT2_END = />/g;\n/** `>`, or whitespace then an attribute name (with `=` and the start of its value), or the string's end. */\nconst TAG_END = />|[ \\t\\n\\f\\r](?:([^\\s\"'>=/]+)([ \\t\\n\\f\\r]*=[ \\t\\n\\f\\r]*(?:[^ \\t\\n\\f\\r\"'`<>=]|(\"|')|))|$)/g;\nconst DOUBLE_QUOTE_END = /\"/g;\n\n\n/**\n * **An expression inside an attribute NAME is refused in development** (`<p data-${k}=\"1\">`, `<b ${name}=\"x\">`,\n * `<p ${k}-x>`): the parser sees the marker before the value exists, so no position can hold it, and the server\n * refuses the same template in every build. Development only, by Brian's call (2026-09-30): a template is fixed\n * source, so its first render in development finds it, and production pays nothing (the check cost 101 B). A name known only at runtime is a one-key spread, which applies the\n * refusals a runtime name needs (handlers, `srcdoc`, URL values); development shows the rewrite. A hole is in a name\n * when, inside a tag and outside a value, a name character touches it on either side — never a ref (whitespace or\n * `>`/`/>` around it) and never the TAG name (`<${tag}>`, the tag entry's).\n */\n/** A name character ends the static, after a space or quote since the tag's `<` — so never a TAG-name hole (`<my-${x}`). */\nconst NAME_BEFORE = /[\\s\"'][^\\s<>]*[^\\s\"'>=/<]$/;\nconst NAME_AFTER = /^(?:[^\\s\"'>=/]|[ \\t\\n\\f\\r]*=)/;\nconst nameHole = (before: string, after: string): never => {\n const prefix = /[^\\s\"'>=/]*$/.exec(before)![0];\n const suffix = /^[^\\s\"'>=/]*/.exec(after)![0];\n const value = /^[ \\t\\n\\f\\r]*=[ \\t\\n\\f\\r]*(?:\"([^\"]*)(\"?)|'([^']*)('?)|([^\\s>]*))/.exec(after.slice(suffix.length));\n /** The value as spread takes it: a closed static is that string, an open one (or none written) is a binding. */\n const given =\n value === null ? \"''\" : value[2] === '\"' ? JSON.stringify(value[1]) : value[4] === \"'\" ? JSON.stringify(value[3]) : value[5] ? JSON.stringify(value[5]) : '…';\n throw new Error(misuse('renderer', 'name-expression', __DEV__ && SHARED.nameExpression(`${prefix}\\${…}${suffix}`, given)));\n};\nconst SINGLE_QUOTE_END = /'/g;\n/**\n * Elements whose content the parser reads as TEXT, so a comment marker cannot live there: the scan\n * writes a text marker and construction turns it into an anchor. `noscript` because Firefox parses it\n * as raw text in a template while Chromium and WebKit do not — listed, it is right in both.\n */\nconst RAW_TEXT_TAGS = /^(?:script|style|textarea|title|iframe|noscript|xmp|noembed|noframes|plaintext)$/i;\n/**\n * The HTML elements whose content is never shown — their holes render as encoded text (`RAW_ENCODED`). `tagName` is\n * upper case exactly for an HTML element. (`xmp` shows its text, as text: encoded, a value reads the same.)\n */\nconst NEVER_SHOWN = /^(?:IFRAME|NOSCRIPT|XMP|NOEMBED|NOFRAMES|PLAINTEXT)$/;\n/**\n * The 14 void elements — a start tag with no content and no end tag. Read only by the development tag-shape pass\n * (`<div />` is an open tag; `</br>` is another `<br>`), so production drops it. A regex rather than shared-utils'\n * Set, as `RAW_TEXT_TAGS` is: an imported `new Set` measured 62 B in production.\n */\nconst VOID_TAGS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr|param)$/i;\n\n/** A binding slot's value before its first commit — never equal to a user value. */\nconst UNSET = {};\n/** The value slot of a child binding whose node slot holds a `ChildPart`. */\nconst UPGRADED = {};\n\n/**\n * A template's bindings are indexed by VALUE position: a multi-part attribute sits at its first value\n * and the positions of its other values are `IGNORED`, so the commit loop needs no bookkeeping.\n */\n/**\n * **Tag-shape mistakes, development only** — a self-closed non-void element (`<div />` is an OPEN tag: what follows\n * becomes its child) and an end tag on a void one (`</br>` is ANOTHER `<br>`), in HTML content only (`<svg>`/`<math>`\n * keep self-closing). A separate pass over ALL the statics, the last one too — the production scan never reads it,\n * and a template with no expressions is never scanned — and it only READS: a development-only counter once changed\n * the SCAN, so development and production parsed one template differently.\n */\nconst SHAPE = /<!--(?:-?>|[\\s\\S]*?(?:--!?>|$))|<(\\/?)([a-zA-Z][^\\s/>]*)((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/g;\nconst tagShape = (strings: TemplateStringsArray, type: number): [string, string][] | undefined => {\n const markup = strings.join('');\n /** Where each binding sits in `markup`, so a refusal can ask whether one falls inside an element's content. */\n const holes: number[] = [];\n for (let i = 0, at = 0; i < strings.length - 1; i++) holes.push((at += strings[i].length));\n const bound = (from: number, to: number) => holes.some((at) => at >= from && at <= to);\n let foreign = type === 1 ? 0 : 1;\n /** `[code, tag]` — printed through the table by `sayShape` when the template first renders. */\n let found: [string, string][] | undefined;\n SHAPE.lastIndex = 0;\n for (let m: RegExpExecArray | null; (m = SHAPE.exec(markup)) !== null; ) {\n if (m[2] === undefined) continue;\n const tag = m[2].toLowerCase();\n const closing = m[1] === '/';\n const selfClosed = !closing && m[3].trimEnd().endsWith('/');\n if (tag === 'svg' || tag === 'math') {\n if (closing) foreign--;\n else if (!selfClosed) foreign++;\n continue;\n }\n if (!closing && RAW_TEXT_TAGS.test(tag)) {\n const end = markup.toLowerCase().indexOf(`</${tag}`, SHAPE.lastIndex);\n const stop = end === -1 ? markup.length : end;\n /**\n * A shape that silently loses a binding, refused: inside `<svg>`/`<math>` a `<title>` or `<style>` is a foreign\n * element whose content the browser reads as MARKUP, while the renderer reads it as raw text and rebuilds that\n * text around its bindings — destroying any element inside it.\n */\n if (foreign > 0 && RAW_TEXT_TAGS.test(tag) && bound(SHAPE.lastIndex, stop) && /<[a-zA-Z]/.test(markup.slice(SHAPE.lastIndex, stop)))\n throw new Error(misuse('renderer', 'foreign-raw-text', __DEV__ && PROSE['foreign-raw-text'](tag)));\n SHAPE.lastIndex = stop;\n }\n if (foreign > 0) continue;\n if (selfClosed && !VOID_TAGS.test(tag))\n (found ??= []).push(['self-closed-tag', tag]);\n else if (closing && VOID_TAGS.test(tag))\n (found ??= []).push(['void-end-tag', tag]);\n }\n return found;\n};\n/**\n * Said at the template's FIRST instance, not at construction: `namespaces` constructs an HTML build of a template it\n * then only ever instantiates in SVG, and that build's shape is not a mistake anyone wrote.\n */\n/**\n * **A `<slot>` rendered into LIGHT DOM that nothing will distribute** — slots not wired, or wired after this template\n * was built. Said once per host tag and case; a shadow root is never warned about, the platform slots there.\n */\nconst saySlotless = () => {\n const host = renderRoot;\n if (host === null || host.nodeType !== 1) return;\n const tag = (host as Element).localName;\n /** Slots wired = its protocol entry (`_$capture$`, set at wire); `_$done$` is installed only at slots' first need. */\n const late = (registry as { _$capture$?: unknown } | null)?._$capture$ !== undefined;\n /** Late: the same fact core says at wire time (`late-template-module`), seen here at the host it bit. Once per tag. */\n if (late) warnOnce('renderer', `<${tag}>`, 'late-template-module', __DEV__ && (() => SHARED.lateTemplateModule()), tag);\n else warnOnce('renderer', `<${tag}>`, 'slots-unwired', __DEV__ && (() => PROSE['slots-unwired']()), tag);\n};\nexport const sayShape = (template: Template) => {\n const shape = template._shape;\n if (shape !== undefined) {\n template._shape = undefined;\n /** Each code written out, so the manifest (`diagnostics-tables`) reads every raise from the source. */\n for (const [code, tag] of shape)\n if (code === 'self-closed-tag') console.warn(diagnostic('renderer', `<${tag}>`, 'self-closed-tag', __DEV__ && PROSE['self-closed-tag'](tag)));\n else console.warn(diagnostic('renderer', `<${tag}>`, 'void-end-tag', __DEV__ && PROSE['void-end-tag'](tag)));\n }\n};\n\nclass Template {\n /** What an instance clones: the single root element, or the whole content fragment. */\n $R: Node;\n /** No element in it can be custom — see `instantiate`. */\n _plain = true;\n $K: number[];\n $N: string[];\n /** The statics around a bound attribute's values; `null` for one full-value expression. */\n $J: (string[] | null)[];\n /** Child-index hops from `$R` to each binding's node. */\n $P: number[][] = [];\n /** The template statically writes the attribute too, so a first nullish commit must still remove it. */\n _present: boolean[];\n /**\n * Per binding, whether it names a URL a browser navigates to (a `javascript:` value is refused, see `SCRIPT_URL`):\n * 0 not one; 1 converted once, and that string checked and written; 2 a custom element's property — strings only.\n */\n $L: number[];\n /**\n * **An extension marked this template** (`'template'` insert): namespaces' resolver, an instance hook. False for\n * every template of an app that wires none — ONE read per instance created, never a per-row cost otherwise.\n */\n $X = false;\n /** Namespaces' resolver: which template to build at a position, given its parent. */\n declare _$at$?: (parent: Node) => Template;\n /** The namespace this template was parsed in, for a resolver asked about a detached fragment. */\n declare _$ns$?: string | null;\n /** The instance hook — elements (and slots): claim at creation, mount at the render's end, unmount at teardown. */\n declare _$inst$?: InstanceHook;\n /** Development only: tag-shape mistakes found at construction, said at the template's FIRST instance (`sayShape`). */\n declare _shape?: [string, string][];\n /**\n * Development only: element positions on an element a SOLE binding owns — see `ownsContent`. Marked per instance in\n * `instantiate`; hydration needs no mark, because the server's output carries the content or its empty anchor.\n */\n declare _owned?: number[];\n /** Development only: the template holds a `<slot>` and was built while light-DOM slots was not wired (`saySlotless`). */\n declare _slotless?: boolean;\n\n constructor(result: TemplateResult) {\n const strings = result.strings;\n const count = strings.length - 1;\n const kinds = (this.$K = new Array(count).fill(IGNORED));\n const names = (this.$N = new Array(count).fill(''));\n const statics = (this.$J = new Array(count).fill(null));\n const present = (this._present = new Array(count).fill(false));\n const urls = (this.$L = new Array(count).fill(0));\n const nodes: (Node | null)[] = new Array(count).fill(null);\n /**\n * Development bookkeeping for a binding whose marker never arrives: the tag it was written in, whether it is an\n * element position (a ref has no name), and which bindings sat in a nested `<template>`'s inert content — so a\n * DROPPED element is told apart from inert markup. Read only; production never builds them.\n */\n let tags: string[] | undefined;\n let refs: boolean[] | undefined;\n let inert: Set<number> | undefined;\n if (__DEV__) {\n tags = [];\n refs = [];\n inert = new Set();\n this._shape = tagShape(strings, result._$litType$ ?? 1);\n }\n\n // ── scan ──\n let markup = '';\n let regex = TEXT_END;\n let rawEnd: RegExp | undefined;\n /**\n * Where the start tag of the raw-text element being opened begins (its string, its offset), its name, and, once its\n * `>` enters raw text, that start tag as written — in every build, since a script hole is refused in every build (`MARKER` where a hole sat in it) — the tag that OPENED\n * the raw text a hole sits in, never one found by searching back (a `<script…>` inside a script's text is no tag).\n */\n let rawOpen: [number, number] | undefined;\n let rawName = '';\n let rawTag = '';\n /** The previous binding opened an UNQUOTED value, so a string that matches nothing continues it (`a=${x}${y}`). */\n let open: boolean = false;\n /** Development also scans the LAST static, so a template that ends inside a tag is refused (below); production does not. */\n for (let i = 0; __DEV__ ? i <= count : i < count; i++) {\n const s = strings[i];\n if (__DEV__ && i > 0) tags![i] = tags![i - 1];\n /** Where this string's bound attribute name ends (≥ 0), -1 for none, -2 for an element position. */\n let nameEnd = -1;\n let continues: boolean = open;\n let name = '';\n let at = 0;\n let match: RegExpExecArray | null;\n while (at < s.length) {\n regex.lastIndex = at;\n if ((match = regex.exec(s)) === null) break;\n at = regex.lastIndex;\n if (regex === TEXT_END) {\n if (match[1] === '!--') regex = COMMENT_END;\n else if (match[1] !== undefined) regex = COMMENT2_END;\n else {\n if (match[2] !== undefined && RAW_TEXT_TAGS.test(match[2])) {\n /**\n * The end tag needs the tokenizer's boundary after its name (whitespace, `/`, `>`): `</stylex>` ends\n * nothing. Or the string's end: `</style${x}` is a tag-name position (refused in development).\n * `<plaintext>` never ends: everything after it is its text, as the parser reads it.\n */\n rawEnd = /^plaintext$/i.test(match[2]) ? /(?!)/g : new RegExp(`</${match[2]}(?=[\\\\t\\\\n\\\\f\\\\r />]|$)`, 'gi');\n if (__DEV__) {\n rawOpen = [i, match.index];\n rawName = match[2].toLowerCase();\n }\n }\n if (__DEV__) tags![i] = match[2] ?? '';\n regex = TAG_END;\n }\n } else if (regex === TAG_END) {\n continues = false;\n if (match[0] === '>') {\n regex = rawEnd ?? TEXT_END;\n nameEnd = -1;\n if (__DEV__ && rawOpen !== undefined) {\n const [from, offset] = rawOpen;\n rawTag =\n from === i ? s.slice(offset, at)\n : strings[from]!.slice(offset) + MARKER + strings.slice(from + 1, i).map((t) => t + MARKER).join('') + s.slice(0, at);\n rawOpen = undefined;\n }\n } else if (match[1] === undefined) nameEnd = -2;\n else {\n name = match[1];\n nameEnd = at - match[2].length;\n regex = match[3] === undefined ? TAG_END : match[3] === '\"' ? DOUBLE_QUOTE_END : SINGLE_QUOTE_END;\n }\n } else if (regex === DOUBLE_QUOTE_END || regex === SINGLE_QUOTE_END) {\n regex = TAG_END;\n /** A value that closes with nothing after it before the expression: the expression is an element position. */\n nameEnd = -2;\n } else if (regex === COMMENT_END || regex === COMMENT2_END) regex = TEXT_END;\n else {\n regex = TAG_END;\n rawEnd = undefined;\n }\n }\n /**\n * A template that ends INSIDE a tag (`<b title=\"${x}`) renders nothing of it: the parser drops an unfinished tag\n * whole. Refused, as the server refuses it in every build — there, left open, the tag swallowed the markup after\n * the template into its attributes.\n */\n if (__DEV__ && i === count) {\n if (regex !== TEXT_END && regex !== rawEnd && regex !== COMMENT_END && regex !== COMMENT2_END)\n throw new Error(misuse('renderer', 'unfinished-tag', __DEV__ && SHARED.unfinishedTag()));\n break;\n }\n /**\n * Development: a script hole is refused unless the script is a JSON data block, judged exactly as the server judges\n * it (`dataBlock`, on the start tag as written that opened it). PRODUCTION refuses the same holes after the parse,\n * below — cheaper (+35 B against +261 B for this scan's tracking), reading the type the parser decoded.\n */\n if (__DEV__ && regex === rawEnd && rawName === 'script' && (!dataBlock(rawTag) || rawTag.includes(MARKER)))\n throw new Error(misuse('renderer', 'script-hole', __DEV__ && PROSE['script-hole']()));\n if (regex === TEXT_END) {\n markup += `${s}<?${MARKER}${i}>`;\n kinds[i] = CHILD;\n } else if (regex === rawEnd) {\n markup += `${s}${MARKER}${i}${MARKER}`;\n kinds[i] = CHILD;\n } else if (regex === COMMENT_END || regex === COMMENT2_END) markup += s;\n else if (nameEnd >= 0) {\n /** The attribute is renamed to its binding's address; the value keeps its statics, split by the marker. */\n names[i] = name;\n markup += `${s.slice(0, nameEnd - name.length)}${i}${MARKER}${s.slice(nameEnd)}${MARKER}`;\n /** An unquoted value followed by `/>` would absorb the slash. */\n if (regex === TAG_END && strings[i + 1].startsWith('/>')) markup += ' ';\n } else if (nameEnd === -2) {\n if (__DEV__ && NAME_AFTER.test(strings[i + 1])) nameHole(s, strings[i + 1]);\n if (__DEV__) refs![i] = true;\n markup += `${s} ${i}${MARKER}`;\n }\n else if (continues || regex !== TAG_END) markup += s + MARKER; // another value of the attribute a previous binding opened\n /**\n * A tag-name position (`<${x}>`, `</${x}>`, `<my-${x}>` — no whitespace since the `<`): refused in development.\n * Production keeps no marker, consumes the value and stays aligned.\n */\n else {\n if (__DEV__ && TAG_NAME_HOLE.test(s)) tagHole('renderer');\n /** Nothing before it at all (`${ref}${n}=\"x\"`): only what follows can say it is a name. */\n if (__DEV__ && (NAME_BEFORE.test(s) || (s === '' && NAME_AFTER.test(strings[i + 1])))) nameHole(s, strings[i + 1]);\n markup += s;\n }\n open = regex === TAG_END && (nameEnd >= 0 || continues);\n }\n markup += strings[count];\n\n // ── parse, then one walk ──\n const type = result._$litType$ ?? 1;\n const element = doc.createElement('template');\n /** svg/mathml fragments only parse inside their root: wrap, then unwrap. */\n element.innerHTML = type === 2 ? `<svg>${markup}</svg>` : type === 3 ? `<math>${markup}</math>` : markup;\n const content = element.content;\n /**\n * Unwrapped by removing the wrapper and keeping EVERYTHING the parser made: an HTML element in foreign content\n * (`<div>` inside `<svg>`) breaks out, and the parser places it AFTER the wrapper — keeping only the wrapper's\n * children dropped it, and everything it held, silently.\n */\n if (type !== 1) (content.firstChild as Element).replaceWith(...content.firstChild!.childNodes);\n const walker = doc.createTreeWalker(content, 129 /* ELEMENT | COMMENT */);\n let node: Node | null;\n while ((node = walker.nextNode()) !== null) {\n if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (!data.startsWith('?' + MARKER)) continue;\n const anchor = doc.createTextNode('');\n (node as Comment).replaceWith(anchor);\n walker.currentNode = anchor;\n nodes[+data.slice(MARKER.length + 1)] = anchor;\n continue;\n }\n const el = node as Element;\n /**\n * A nested `<template>`'s content is inert markup the walk never enters, so its bindings can never be\n * reached — they are ignored, as the server ignores them. Their markers are scrubbed from its markup,\n * every depth at once, or they would sit in the live page.\n */\n if (el.localName === 'template') {\n const held = (el as HTMLTemplateElement).innerHTML;\n if (__DEV__) for (const m of held.matchAll(/(\\d+)\\uFFFF|\\uFFFF(\\d+)/g)) inert!.add(+(m[1] ?? m[2]));\n (el as HTMLTemplateElement).innerHTML = held.replace(INERT_MARKERS, '');\n }\n if (el.localName.includes('-') || el.hasAttribute('is')) this._plain = false;\n for (const attribute of el.getAttributeNames()) {\n if (!attribute.endsWith(MARKER)) continue;\n const i = parseInt(attribute, 10);\n const value = el.getAttribute(attribute)!.split(MARKER);\n el.removeAttribute(attribute);\n nodes[i] = el;\n const written = names[i];\n const first = written[0];\n /** An element position (`<p ${ref}>`) arrives with no value; `&=${ref}` is its explicit spelling. */\n if (value.length === 1 || first === '&') {\n /** Decided here, once: `localName` is a DOM accessor, too dear to read on every commit. */\n kinds[i] = el.localName === 'select' ? SELECT_REF : REF;\n continue;\n }\n let kind =\n first === '.' ? PROPERTY : first === '?' ? BOOLEAN : first === '@' ? EVENT : first === '!' ? LIVE : ATTR;\n /** The parser lowercases attribute names; the scan kept the author's case (`.someProp`). */\n let real = kind === ATTR ? written : written.slice(1);\n /** React muscle memory, buildless: `onClick=${fn}` is `@click`. Strictly `on` + a capital — `onclick` stays an attribute. */\n if (kind === ATTR && /^on[A-Z]/.test(written)) {\n kind = EVENT;\n real = written.slice(2).toLowerCase();\n }\n /**\n * A `<select>`'s selection is re-asserted every render and compared against the LIVE value (as `!value` is):\n * its options can be replaced under an unchanged value, which drops the selection. It is written when the\n * pass ends, once its options exist — see `flush`.\n */\n if ((kind === PROPERTY || kind === LIVE) && isSelection(el, real)) {\n if (__DEV__) saySelectMultiple(el, real, 'renderer');\n kind = real === 'value' ? SELECT : SELECT_INDEX;\n }\n /**\n * `el.__proto__ = v` is not a property write: it replaces the element's prototype and destroys it.\n * No use is legitimate, so the binding is refused — the deliberate twin of spread's `refusedSink`\n * (`tests/dangerous-binding-matrix.test.mjs` holds the two together).\n */\n if ((kind === PROPERTY || kind === LIVE) && real === '__proto__') {\n kind = REFUSED;\n if (__DEV__)\n console.warn(diagnostic('renderer', `<${el.localName}>`, 'proto-binding', __DEV__ && SHARED.protoBinding(written)));\n } else if (kind === ATTR && real.toLowerCase() === 'srcdoc') {\n /** A bound `srcdoc` ATTRIBUTE renders its value as an HTML document: markup injection by construction. */\n kind = REFUSED;\n if (__DEV__)\n console.warn(diagnostic('renderer', `<${el.localName}>`, 'srcdoc-attribute', __DEV__ && SHARED.srcdocAttribute('.srcdoc=${…}')));\n } else if (kind === ATTR && INLINE_HANDLER.test(real)) {\n /** A bound inline handler runs its value as code: refused, as spread and the server refuse it. */\n kind = REFUSED;\n if (__DEV__)\n console.warn(\n diagnostic('renderer', `<${el.localName}>`, 'handler-attribute',\n __DEV__ && SHARED.handlerAttribute(real, `\\`@${real.slice(2).toLowerCase()}=\\${…}\\` (or \\`on${real[2].toUpperCase()}${real.slice(3)}=\\${…}\\`)`))\n );\n } else if (kind === PROPERTY && el.localName.includes('-')) kind = ADOPT;\n else if (kind === LIVE && el.localName.includes('-')) kind = LIVE_CUSTOM;\n /**\n * A property that REPLACES an element's content (`.textContent`, `.innerHTML`…) on an element that also has\n * content of its own — markup, or a child binding whose anchor is in it: the write strands the binding, and a\n * later commit into it throws on a missing parent. Cannot work as written, so development throws.\n */\n if (__DEV__ && kind !== ATTR && kind !== EVENT && kind !== BOOLEAN && CONTENT_PROPERTY.test(real) && ownsContent(el))\n contentClash('renderer', el.localName, real);\n kinds[i] = kind;\n names[i] = real;\n statics[i] = value.length === 2 && value[0] === '' && value[1] === '' ? null : value;\n present[i] = kind === ATTR && el.hasAttribute(real);\n /**\n * A custom element's `src` or `data` PROPERTY is its own business — often an object (`.data=${rows}`) —\n * so only a string is checked there (1), and nothing else is converted; everywhere else the value is converted\n * once (2) — and an animation's value (`to`, `values`…) is checked item by item (3).\n */\n const sink = URL_SINK.exec(real);\n urls[i] =\n kind === REFUSED || kind === BOOLEAN || kind === EVENT || sink === null\n ? 0\n : kind !== ATTR && el.localName.includes('-')\n ? 1\n : sink[1]\n ? 2\n : 3;\n }\n /**\n * A raw-text element's markers arrived as characters: rebuild its content with anchors in their place. A\n * never-shown element is read as its MARKUP when the parser built elements in it (Chromium and WebKit parse a\n * template's `<noscript>` as markup, so a value written in an attribute there sits in a real attribute) and as\n * its text otherwise — the same source either way, written back as text.\n */\n const source = RAW_TEXT_TAGS.test(el.localName) ? (NEVER_SHOWN.test(el.tagName) && el.firstElementChild !== null ? el.innerHTML : el.textContent!) : '';\n if (source.includes(MARKER)) {\n /**\n * **A script hole is refused in EVERY build unless the script is an HTML JSON data block** (Brian, 2026-11-18).\n * A template's HTML script never runs on the live page, but a page saved from the DOM and served again (an\n * editor's publish) runs it; an SVG `<script>` from a template runs in Chromium and WebKit (BROWSER-LEDGER), so\n * it is refused even with a JSON type. `tagName` is upper case exactly for an HTML element (in an HTML document).\n * The type is read as the parser decoded it, so `application&#47;json` passes here where the server (and the\n * development scan, above) refuses it: a genuine JSON block, which never runs — the one recorded difference. A\n * script carrying any binding of its own (`nodes` holds it: `?type`, `.type`, a spread) is refused too: it could\n * change the type after this judged it, and a saved page would carry the value as code.\n */\n if (el.tagName === 'script' || (el.tagName === 'SCRIPT' && (!JSON_BLOCK.test(el.getAttribute('type') ?? '') || nodes.includes(el))))\n throw new Error(misuse('renderer', 'script-hole', __DEV__ && PROSE['script-hole']()));\n const pieces = source.split(MARKER);\n el.textContent = '';\n /**\n * An HTML style, JSON block (the script check above let only that script through) or never-shown element: its first\n * value owns the element's whole text (`RAW_*`), its statics the even pieces; the values after it are consumed.\n */\n const raw = el.tagName === 'STYLE' ? RAW_STYLE : el.tagName === 'SCRIPT' ? RAW_JSON : NEVER_SHOWN.test(el.tagName) ? RAW_ENCODED : 0;\n if (raw !== 0) {\n const first = +pieces[1]!;\n nodes[first] = el;\n kinds[first] = raw;\n /** One value and no static text (`<style>${css}</style>`): no statics, so an unchanged value returns at once. */\n statics[first] = pieces.length === 3 && pieces[0] === '' && pieces[2] === '' ? null : pieces.filter((_, p) => p % 2 === 0);\n for (let p = 3; p < pieces.length; p += 2) kinds[+pieces[p]!] = IGNORED;\n continue;\n }\n for (let p = 0; p < pieces.length; p++) {\n if (p % 2 === 0) {\n if (pieces[p]) el.append(pieces[p]);\n } else el.append((nodes[+pieces[p]] = doc.createTextNode('')));\n }\n }\n }\n\n /**\n * A child binding that is its element's only content needs no anchor in the template — except inside\n * a raw-text element, whose content is never markup. Then each binding's path from the root.\n */\n const first = content.firstChild;\n const root = (this.$R = first !== null && first.nodeType === 1 && first.nextSibling === null ? first : content);\n for (let i = 0; i < count; i++) {\n let at = nodes[i];\n if (at === null) {\n if (__DEV__ && (kinds[i] === CHILD || names[i] !== '' || refs![i])) {\n if (inert!.has(i))\n console.warn(diagnostic('renderer', 'a nested <template>', 'inert-binding', __DEV__ && PROSE['inert-binding'](String(i))));\n /** A run of consecutive casualties is one dropped element: said once, naming the first. */\n else if (i === 0 || nodes[i - 1] !== null || inert!.has(i - 1) || !(kinds[i - 1] === CHILD || names[i - 1] !== '' || refs![i - 1])) {\n let lost = 1;\n while (i + lost < count && nodes[i + lost] === null && !inert!.has(i + lost)) lost++;\n const where = tags![i] ? `\\`${names[i] !== '' ? `${names[i]}=` : refs![i] ? '&=' : ''}\\` on <${tags![i]}>` : 'a binding';\n console.warn(diagnostic('renderer', 'a dropped element', 'dropped-binding', __DEV__ && PROSE['dropped-binding'](where, String(lost))));\n }\n }\n kinds[i] = IGNORED;\n } else if (kinds[i] === CHILD) {\n const parent = at!.parentNode!;\n if (__DEV__ && (parent as Element).localName === 'table')\n console.warn(diagnostic('renderer', '<table>', 'table-binding', __DEV__ && PROSE['table-binding']()));\n /**\n * Only on a PLAIN element (no dash, no `is`): a light-DOM component renders into its own children, and the part\n * this position may become owns its element's whole content — so there it keeps its anchor, bounded by markers.\n */\n const host = parent as Element;\n if (\n parent.nodeType === 1 &&\n parent.childNodes.length === 1 &&\n !RAW_TEXT_TAGS.test(host.localName) &&\n !host.localName.includes('-') &&\n !host.hasAttribute('is')\n ) {\n parent.removeChild(at!);\n nodes[i] = at = parent;\n kinds[i] = SOLE;\n }\n }\n const path: number[] = [];\n for (; at != null && at !== root; at = at.parentNode) {\n let index = 0;\n for (let sibling = at.previousSibling; sibling !== null; sibling = sibling.previousSibling) index++;\n path.unshift(index);\n }\n this.$P.push(path);\n }\n /**\n * Development: an element position (a spread) on an element whose whole content is a SOLE binding — the content is\n * invisible until that binding commits, so the spread's content-property check is told by a mark per instance.\n */\n if (__DEV__) {\n for (let i = 0; i < count; i++)\n if ((kinds[i] === REF || kinds[i] === SELECT_REF) && nodes.some((n, j) => kinds[j] === SOLE && n === nodes[i]))\n (this._owned ??= []).push(i);\n }\n /**\n * **The `'template'` insert** — asked once, as each template is built (cold): a hook may set `_$at$`/`_$inst$`.\n * A module wired AFTER a template was built never hears about it; development says so at `wire` (core reads the\n * mark below).\n */\n if (__DEV__ && registry !== null) (registry as unknown as { $b?: boolean }).$b = true;\n const hooks = registry?.get('template') as TemplateHook[] | undefined;\n /**\n * **Marked by what the hooks LEFT, never by their existing**: a resolver (`_$at$`), an instance hook (`_$inst$`), or a\n * variant's namespace (`_$ns$` — its instances must set the create scope, or a position at their top level cannot\n * be resolved). The fields are the truth, so the mark cannot disagree with them, and the public `'template'` insert\n * keeps its contract (a hook returns nothing). Marking whenever a hook merely existed put every template of an app\n * wiring `elements` — every slots app — on the marked instance path, claimed or not.\n */\n if (hooks !== undefined) for (let i = 0; i < hooks.length; i++) hooks[i](this, result, readScope, root);\n this.$X = !!(this._$at$ || this._$inst$ || this._$ns$);\n /** Light-DOM slots claims a `<slot>` as the template is built — so a template built before it is wired never will. */\n if (__DEV__ && (root as ParentNode).querySelector?.('slot') && (registry as { _$capture$?: unknown } | null)?._$capture$ === undefined)\n this._slotless = true;\n }\n}\n\n/** A `'template'` insert: called once as each template is built. */\ntype TemplateHook = (template: Template, result: TemplateResult, readScope: () => unknown, root: Node) => void;\n\n/**\n * **The create scope**: the template whose instance is being built, while its first update runs — how a resolver\n * answers for a position whose parent is still the instance's detached FRAGMENT (a fragment-rooted template's top\n * level). Set only by a marked template's instantiation.\n */\nlet scope: unknown = null;\nconst readScope = () => scope;\n\n/** The template to build at a position — the same one, unless an extension resolves it by `parent` (namespaces). */\nconst resolved = (template: Template, parent: Node) => (template._$at$ !== undefined ? template._$at$(parent) : template);\n\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n/**\n * **Only a tagged template literal is a template.** Detection is by shape (`strings`), so a value from `JSON.parse` —\n * a request body, an API field an attacker can turn into an object — that looked like a template was rendered as\n * MARKUP. A literal's strings array owns `raw`, which JSON cannot give an array (and an object owning one is not an\n * array): the check Lit makes. It runs here, on the cache's miss, which a forged array always is, so a cached\n * template pays nothing. A forgery is the text any object renders as, `[object Object]` — one shared template, never\n * cached under the forger's own `strings` (a WeakMap throws on a primitive key) — and never a throw: the value is\n * attacker-controlled, and a throw would hand over the subtree.\n */\nlet forged: Template | undefined;\nconst getTemplate = (result: TemplateResult) => {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n const strings = result.strings;\n if (!(Array.isArray(strings) && Object.hasOwn(strings, 'raw'))) {\n if (__DEV__) console.warn(diagnostic('renderer', 'a child value', 'forged-template', __DEV__ && SHARED.forgedTemplate()));\n return (forged ??= new Template({ strings: [`${{}}`] } as unknown as TemplateResult));\n }\n templateCache.set(strings, (template = new Template(result)));\n }\n return template;\n};\n\n/** `${value}` rather than `String(value)`: a symbol throws here as it does at every other sink. */\nconst toText = (value: unknown) => (value == null ? '' : `${value}`);\n\n/**\n * **A value in a `<style>`, JSON block or never-shown element, as text** — the server's rule: nothing for `null`/`undefined`, a list its items'\n * text (nested lists flattened by the same rule), a template refused, anything else `String`. Cold: reached only when\n * such a text changes. One function, nothing single-use beside it (the minifier would paste it in as an IIFE).\n */\nconst textOf = (value: unknown): string => {\n if (Array.isArray(value)) {\n let text = '';\n for (let i = 0; i < value.length; i++) text += textOf(value[i]);\n return text;\n }\n /** A tagged literal's template (strings owning `raw`; a JSON-shaped forgery is not one) is refused, as the server refuses it. */\n const strings = typeof value === 'object' && value !== null ? (value as TemplateResult).strings : undefined;\n if (Array.isArray(strings) && Object.hasOwn(strings, 'raw'))\n throw new Error(misuse('renderer', 'template-in-text', __DEV__ && SHARED.templateInText()));\n return toText(value);\n};\n\n/**\n * **A template placed in an HTML `<title>` or `<textarea>` is said, in development only** (Brian, 2026-11-18). Its elements\n * are never shown there (the element shows its text), and a page saved from the DOM reads them back as text. Nothing\n * unsafe happens, so production carries nothing: the renderer places it, as it always has. (The server refuses it —\n * `ssr-template-in-text` — because there a template's markup could END the element; an SVG `title` is markup.)\n */\nconst TEXT_ONLY = /^(?:TITLE|TEXTAREA)$/;\n/** Said once per element name — a list of templates in one `<textarea>` speaks once, not per item. */\nconst sayTemplateInText = (host: Node) =>\n warnOnce('renderer', `<${(host as Element).localName}>`, 'template-in-text', __DEV__ && (() => SHARED.templateInText()), (host as Element).localName);\n\n/**\n * The record an `@event`, element-position or custom-element `.prop` binding holds in its node slot.\n * For an event it is the LISTENER — a stable object, so swapping handlers never touches the DOM and a\n * re-add through `null` is deduped by the platform; for a ref it is the key an `_$apply$` value keeps\n * its ownership by; for `.prop` on a custom element, `_state` is where adoption stands (`adoptProperty`:\n * 0 still adopting, 1 received, 2 refused).\n */\nclass Slot {\n _element: Element;\n _handler: unknown = null;\n _state = 0;\n constructor(element: Element) {\n this._element = element;\n }\n /** Runs the handler UNTRACKED — see shared-utils' `dispatch`. */\n handleEvent(event: Event) {\n untracked(dispatch, this, event);\n }\n}\n\n/**\n * Calls an element ref, and survives one that throws — it runs mid-commit, and an unguarded throw left\n * the render half applied. Reported where a hook's error is: the app's `'error'` chain, handed the\n * component being rendered, else `reportError`.\n */\nconst applyRef = (callback: (element: Element | null) => void, element: Element | null) => {\n try {\n callback(element);\n } catch (error) {\n reportTo(registry?.get('error'), error, hostOf(renderRoot), __DEV__ ? diagnostic('renderer', 'an element ref', 'ref-threw', __DEV__ && PROSE['ref-threw']()) : '[vera] ref-threw');\n }\n};\n\n/**\n * A rendered template. Its bindings live in ONE array of `[node, committed value]` pairs rather than a\n * part object each — a row allocates the instance and that array, nothing else. The instance is also\n * its own list item: `$k` is the key a keyed list reads.\n */\nclass Instance {\n $k: unknown = undefined;\n /**\n * The result last committed into this instance as a list item, recorded ONLY for a result marked `_$same$` (what\n * `each` stamps). Always-on, the skip changed two contracts (a live `!value` binding re-syncing after typing; a result\n * mutated in place re-rendering), so it is opt-in: an unmarked result never takes it (2026-10-18).\n */\n $j: unknown = undefined;\n _template: Template;\n /** The strings this instance was built from — the same-shape identity. */\n _strings: TemplateStringsArray;\n /** The cloned root: the element for a single-root template, else the (soon emptied) fragment. */\n $R: Node;\n _bindings: unknown[];\n constructor(template: Template, strings: TemplateStringsArray, root: Node, bindings: unknown[]) {\n this._template = template;\n this._strings = strings;\n this.$R = root;\n this._bindings = bindings;\n }\n}\n\n/**\n * Builds an instance and commits its first values.\n *\n * **The clone.** Creating an element in a document WITH a custom-element registry costs a definition\n * lookup per element; the template's inert document has none. So a template that cannot contain a\n * custom element is cloned with `cloneNode` — its nodes adopt into the page on insertion — and one that\n * can is imported into `owner`, which upgrades defined elements at clone time in the owner's own\n * registry, so a `.prop` commit reaches the class's setter rather than shadowing it. A container in another\n * window is never the `owner`: its registry does not define this realm's components (Firefox and WebKit leave them\n * un-upgraded there), so `commitAs` hands this renderer's own document instead.\n *\n * **Every node is located before anything commits.** The paths index the pristine clone; an upgrading\n * child position inserts markers and content, which would shift the siblings a later path counts.\n */\nconst instantiate = (template: Template, result: TemplateResult, owner: Document): Instance => {\n if (__DEV__) sayShape(template);\n if (__DEV__ && template._slotless) saySlotless();\n const source = template.$R;\n const root = template._plain && owner === doc ? source.cloneNode(true) : owner.importNode(source, true);\n const kinds = template.$K;\n const paths = template.$P;\n const marked = template.$X;\n /** A marked template's instance keeps its hook's state in ONE slot after its bindings — the hook's own object. */\n const bindings = new Array(kinds.length * 2 + (marked ? 1 : 0));\n for (let i = 0; i < kinds.length; i++) {\n const kind = kinds[i];\n if (kind === IGNORED) continue;\n let node = root;\n const path = paths[i];\n for (let step = 0; step < path.length; step++) {\n node = node.firstChild!;\n for (let hops = path[step]; hops > 0; hops--) node = node.nextSibling!;\n }\n bindings[i * 2] = kind >= EVENT && kind <= ADOPT ? new Slot(node as Element) : node;\n bindings[i * 2 + 1] = kind === CHILD ? '' : UNSET;\n }\n if (__DEV__ && template._owned !== undefined)\n for (const i of template._owned) ((bindings[i * 2] as Slot)._element as Element & { $content?: boolean }).$content = true;\n const instance = new Instance(template, result.strings, root, bindings);\n if (marked) {\n hookUp(instance, root, false);\n const outer = scope;\n scope = template;\n update(instance, result.values);\n scope = outer;\n } else update(instance, result.values);\n return instance;\n};\n\n/**\n * **An instance of a marked template meets its instance hook** — before its first update (claims see the inert\n * clone), with its mount queued for when the render that created it finishes. Arms removal work, so an instance\n * discarded before then is walked at teardown and never mounts. Also how hydration hooks an adopted instance.\n */\nexport const hookUp = (instance: Instance, root: Node | readonly Element[], adopted: boolean) => {\n const hook = instance._template._$inst$;\n if (hook === undefined) return;\n /** The hook's own state — what to mount, and later what to unmount — or nothing to take part. */\n const state = hook.$c(root, renderRoot, adopted);\n if (state === undefined) return;\n instance._bindings[instance._template.$K.length * 2] = state;\n /** Mounted by the ref flush: a record whose second half is not a slot number is a mount. */\n (pendingRefs ??= []).push(hook, state);\n notifyOnRemoval = true;\n};\n\n/**\n * Commits new values into an instance of the same shape. An unchanged single-value binding — nearly\n * every binding of nearly every row on a list update — is skipped here, before any call.\n */\nconst update = (instance: Instance, values: unknown[]) => {\n const template = instance._template;\n const kinds = template.$K;\n const statics = template.$J;\n const bindings = instance._bindings;\n for (let i = 0; i < kinds.length; i++) {\n const kind = kinds[i];\n if (kind !== IGNORED && (kind >= LIVE || statics[i] !== null || values[i] !== bindings[i * 2 + 1]))\n commit(template, bindings, i, kind, values);\n }\n};\n\n/** Commits the binding at value position `i`. */\n/**\n * **A boolean at a child position renders as the WORD** — `${cond && …}` with a false `cond` shows \"false\". Said in\n * development on each CHANGE to a boolean (the dirty check already skips a repeat), so a binding that keeps\n * producing `false` speaks once, and one that flips to `true` speaks again.\n */\nconst warnBooleanChild = (value: boolean) =>\n console.warn(diagnostic('renderer', 'a child position', 'boolean-child', __DEV__ && PROSE['boolean-child'](String(value))));\n\n/**\n * **Content in the wrong namespace does not render**: development names it at each insert (shared-utils'\n * `checkForeign`, which `@verajs/lite` says too); this renderer's other way to the right namespace is the namespaces\n * module, so it is the renderer's `retag` sentence.\n */\nconst RETAG =\n ` — or wire @verajs/renderer/namespaces, which parses a template where it lands (compiled JSX ` +\n `wires it itself). A template built before it was wired keeps the namespace it was first built in`;\n\n/**\n * **The profiler's hook** (`@verajs/renderer/profiler`, a development-only entry): told of each same-shape update, each\n * first template, each REBUILD (the template identity changed, so the subtree is torn down) and each `renderInto`\n * frame. Every call site is `if (__DEV__ && profileHook !== null)`, so production carries neither the hook nor a call.\n */\ntype ProfileHook = (kind: number, subject: unknown, shape: TemplateStringsArray | null) => void;\nconst PROFILE_UPDATE = 0;\nconst PROFILE_CREATE = 1;\nconst PROFILE_REBUILD = 2;\nconst PROFILE_FRAME_START = 3;\nconst PROFILE_FRAME_END = 4;\nlet profileHook: ProfileHook | null = null;\nconst setProfileHook = (hook: ProfileHook | null) => {\n profileHook = hook;\n};\n\n/** How many times a part's child applier changed identity — development only; `@__PURE__` keeps it out of production. */\nconst applierSwaps = /* @__PURE__ */ new WeakMap<object, number>();\n\n/** `commit`'s scratch for a component's `_$raw$` — module-level, so the read stays one expression. */\nlet raw: Record<string, unknown> | undefined;\nconst commit = (template: Template, bindings: unknown[], i: number, kind: number, values: unknown[]) => {\n const slot = i * 2;\n const committed = bindings[slot + 1];\n const node = bindings[slot];\n if (kind <= SOLE) {\n const value = values[i];\n if (committed === UPGRADED) (node as ChildPart).$p(value);\n else if (value == null || typeof value === 'object') {\n /** A template, list, node or nothing: the position becomes a full part, anchored where its text was. */\n let part: ChildPart;\n if (kind === SOLE) {\n /** Its plain element's whole content is this binding's: the element is the range, and no comment is added. */\n part = new ChildPart(null, null);\n if (committed === UNSET) part.$w = node as Element;\n else {\n part.$w = (node as Text).parentNode;\n part.$o = TEXT;\n part.$l = node as Text;\n part.$v = committed;\n }\n } else {\n part = markered((node as Text).parentNode!, node as Text);\n (node as Text).parentNode!.insertBefore(node as Text, part.$e);\n part.$o = TEXT;\n part.$l = node as Text;\n part.$v = committed;\n }\n bindings[slot] = part;\n bindings[slot + 1] = UPGRADED;\n part.$p(value);\n } else if (value !== committed) {\n if (__DEV__ && typeof value === 'boolean') warnBooleanChild(value);\n if (committed === UNSET) {\n /** SOLE's first text: created holding its value. `''` creates no node, so that one is appended. */\n if (value === '') (node as Element).append('');\n else (node as Element).textContent = value as string;\n bindings[slot] = (node as Element).firstChild;\n } else (node as Text).data = value as string;\n bindings[slot + 1] = value;\n }\n return;\n }\n /**\n * One test for the kinds decided before anything is computed — the same one comparison `REFUSED` alone cost. A\n * `selectedIndex` has no statics and no URL: queued, as a select's value is. (Hydration never commits a selection:\n * the server marked the option, and whatever the user chose before the script arrived stands.)\n *\n * A style's or JSON block's text (`RAW_STYLE`/`RAW_JSON`): composed, compared with the text last composed, and only\n * when it changed escaped and written whole — the server's bytes (`@verajs/ssr`'s `styleHole` and JSON rule).\n */\n if (kind >= REFUSED) {\n if (kind === SELECT_INDEX) {\n bindings[slot + 1] = values[i];\n (pendingSelects ??= []).push(LATER, [node, values[i]]);\n } else if (kind !== REFUSED) {\n const parts = template.$J[i];\n let text: string;\n /**\n * Every render reaches here (these kinds sit past `LIVE`), so an unchanged text returns before any write: a lone\n * value by identity, as a plain text hole is skipped; statics and values by the composed text.\n */\n if (parts === null) {\n if (values[i] === committed) return;\n text = textOf((bindings[slot + 1] = values[i]));\n if (kind === RAW_ENCODED) text = encodeText(text);\n } else {\n text = parts[0]!;\n for (let p = 1; p < parts.length; p++) text += (kind === RAW_ENCODED ? encodeText(textOf(values[i + p - 1])) : textOf(values[i + p - 1])) + parts[p];\n if (text === committed) return;\n bindings[slot + 1] = text;\n }\n (node as Element).textContent = kind === RAW_ENCODED ? text : /*@__NOINLINE__*/ closedRawText(text, kind === RAW_JSON);\n }\n return;\n }\n const parts = template.$J[i];\n let value = values[i];\n if (parts !== null && kind !== EVENT && kind !== REF) {\n value = parts[0];\n for (let p = 1; p < parts.length; p++) value += toText(values[i + p - 1]) + parts[p];\n }\n const name = template.$N[i];\n const element = (kind >= EVENT && kind <= ADOPT ? (node as Slot)._element : node) as PropertyHost;\n /**\n * A `javascript:` URL bound where a browser navigates is code arriving as data: refused, and the\n * attribute removed, on the JOINED value (so `href=\"java${x}\"` is caught too). Statics are the author's\n * and never checked alone; only bindings the template marked as URL-bearing pay for the test.\n *\n * **Converted ONCE, and the string checked is the string written.** Testing the value and then handing it\n * to `setAttribute` converted it twice, so an object whose `toString` answered differently each time\n * passed the check as `https:` and was written as `javascript:`.\n */\n const url = template.$L[i];\n if (url > 1 && value != null && typeof value !== 'string') value = `${value}`;\n if (url !== 0 && typeof value === 'string' && (url === 3 ? SCRIPT_URL_ITEM : SCRIPT_URL).test(value)) {\n if (__DEV__ && value !== committed)\n console.warn(diagnostic('renderer', `<${element.localName}>`, 'script-url', __DEV__ && SHARED.scriptUrl(name)));\n bindings[slot + 1] = value;\n element.removeAttribute(name);\n return;\n }\n /** The kinds that re-assert every render sit from `LIVE` up (`REFUSED` returned above): ONE test routes them all. */\n if (kind >= LIVE) {\n if (kind === SELECT) (pendingSelects ??= []).push(element, value);\n /**\n * A COMPONENT is compared against its CURRENT value and RECEIVES a difference — through `adoptProperty`, as `.name`\n * does — or a running one never hears it: a plain write landed beside its render, which went on showing the old\n * value (released through 0.2.x). The current value of a name it received is the RAW one its store holds (core's\n * `_$raw$`): through the accessor it cost a store read every render and handed an object back as its proxy, never\n * `===` the object bound, so it was delivered again every render; any other name is read through `untracked`.\n * **Inline, not a shared helper — and spread's `!name` key has the same lines (keep them equal):** a call here cost\n * WebKit +3–4% on an unchanged `!name` (5 sessions, 0 faster), inlined −1.1% (5/5 faster than before the fix).\n */\n else if (\n (kind === LIVE\n ? element[name]\n : (raw = element._$raw$ as Record<string, unknown> | undefined) !== undefined && name in raw\n ? raw[name]\n : untracked(read, element, name)) !== value\n ) {\n if (kind === LIVE) element[name] = value;\n else adoptProperty(element, name, value);\n }\n } else if (value === committed) return;\n bindings[slot + 1] = value;\n if (kind === ATTR) {\n /**\n * A value that is not text becomes something nobody meant — a function's source, an array joined by commas, a\n * Date in the machine's timezone. Asked of the RAW value: a URL-bearing name was converted above. Said once per\n * element, name and kind of value (`dev-values`), so fixing one mistake never hides the next.\n */\n if (__DEV__ && value != null) {\n const kind = attributeValueKind(element.localName, name, parts === null ? values[i] : value);\n if (kind !== null) console.warn(diagnostic('renderer', `<${element.localName}>`, 'attribute-value', __DEV__ && SHARED.attributeValue(name, kind, `.${name}=\\${value}`)));\n }\n if (value != null) element.setAttribute(name, value as string);\n /** A fresh clone carries no attribute to remove unless the template itself wrote one. */\n else if (committed !== UNSET || template._present[i]) element.removeAttribute(name);\n } else if (kind === PROPERTY) element[name] = value;\n else if (kind === BOOLEAN) element.toggleAttribute(name, !!value);\n else if (kind === EVENT) {\n const listener = node as Slot;\n if (__DEV__ && value != null && value !== false) {\n /** Something that cannot listen does nothing, silently — `false`/`undefined` are the deliberate \"no handler\". */\n if (typeof value !== 'function' && typeof (value as EventListenerObject).handleEvent !== 'function')\n console.warn(diagnostic('renderer', `<${element.localName}>`, 'not-a-listener', __DEV__ && SHARED.notAListener(name, typeof value)));\n /** A misspelled event name (`@clik`), asked at the first attachment, once per tag and name. */\n if (listener._handler === null) {\n const best = eventNameGuess(element, name);\n if (best !== null)\n warnOnce('renderer', `<${element.localName}>`, 'event-name-typo', __DEV__ && (() => PROSE['event-name-typo'](name, element.localName, best)), eventKey(element, name));\n }\n }\n /** Registered once, as the listener OBJECT: the platform dedupes it, so toggling through null never stacks. */\n if (listener._handler === null && value != null) element.addEventListener(name, listener);\n listener._handler = value ?? null;\n } else if (kind === ADOPT) {\n const adopting = node as Slot;\n if (adopting._state === 1) element[name] = value;\n else if (adopting._state === 0) adopting._state = adoptProperty(element, name, value);\n } else if (kind === REF || kind === SELECT_REF) {\n /**\n * The ref this binding held was handed its element (it is not still queued), and it is being replaced or\n * removed: it is told now, before its successor is handed the element after the pass.\n */\n if (committed !== UNSET && (node as Slot)._state === 0) release(committed);\n if (value == null) return;\n notifyOnRemoval = true;\n /**\n * A value with `_$apply$` applies itself NOW, mid-commit, keyed by this binding — spread delivers\n * properties through it, and they must arrive before the element is inserted and upgraded.\n */\n /** A FUNCTION, not merely present: parsed JSON can carry the key, never a function — data stays data. */\n if (typeof (value as { _$apply$?: unknown })._$apply$ === 'function') {\n /** On a `<select>` it may set the selection (a spread's `.value`), so it waits for the options too — see `flush`. */\n if (kind === SELECT_REF) (pendingSelects ??= []).push(LATER, [value, element, node]);\n else (value as Applies)._$apply$(element, node as Slot, untracked);\n }\n /**\n * A ref — a function, or an object taking `.value` (core's `ref()`) — is handed its element once the pass's\n * DOM exists: inserted, upgraded, in its own document. Queued at most once per pass (`_state`), and the\n * flush reads whatever the binding holds THEN, so a ref replaced, removed or torn down in the meantime is\n * never handed a stale element.\n */\n else if ((typeof value === 'function' || typeof value === 'object') && (node as Slot)._state === 0) {\n (node as Slot)._state = 1;\n (pendingRefs ??= []).push(bindings, slot);\n }\n }\n};\n\n/**\n * Tells what an instance holds that it is going away: a ref is released (`null`, so a component reading\n * it after a subtree was replaced does not get a detached element back), and a child position that\n * became a part passes the news down. Reached only when `notifyOnRemoval` is set.\n */\nconst teardown = (instance: Instance) => {\n const kinds = instance._template.$K;\n const bindings = instance._bindings;\n /** An instance hook is told, with its state: it unmounts what it mounted, and one not yet mounted never mounts. */\n if (instance._template.$X) {\n const at = kinds.length * 2;\n const state = bindings[at];\n if (state !== undefined) {\n bindings[at] = undefined;\n instance._template._$inst$!.$q(state);\n }\n }\n for (let i = 0; i < kinds.length; i++) {\n const value = bindings[i * 2 + 1];\n if (kinds[i] === REF || kinds[i] === SELECT_REF) {\n /** A ref still queued was never handed its element, so it is not told it is gone. */\n if ((bindings[i * 2] as Slot)._state !== 1) release(value);\n bindings[i * 2 + 1] = UNSET;\n } else if (value === UPGRADED) (bindings[i * 2] as ChildPart)._destroy();\n }\n};\n/** A list item is going away for good. */\nconst detachItem = (item: Item) => (item instanceof ChildPart ? item._destroy() : teardown(item));\n\n/**\n * Tells a ref its element is no longer its: a function is called with `null`, an object's `.value` becomes\n * `null` (core's `ref()` — \"deliberately nothing\"). A value with `_$apply$` owns its own lifecycle.\n */\nconst release = (value: unknown) => {\n if (typeof value === 'function') applyRef(value as (element: Element | null) => void, null);\n else if (value !== null && typeof value === 'object' && value !== UNSET && (value as { _$apply$?: unknown })._$apply$ === undefined)\n (value as { value: unknown }).value = null;\n};\n\n/** A single property read — it runs once per list item per render. */\nconst isTemplateResult = (value: object): value is TemplateResult =>\n (value as TemplateResult).strings !== undefined;\n\n/** What a ChildPart holds. */\n\n\n/** Removal is a move into this fragment, then one clear. */\nconst SCRATCH = doc.createDocumentFragment();\n\n/**\n * Internals the hydrate entry adopts through. The base entry (`index.ts`) re-exports none of them, so its bundle\n * tree-shakes them away; the hydrate bundle inlines this module and reaches them.\n */\nexport {\n setProfileHook,\n PROFILE_UPDATE,\n PROFILE_CREATE,\n PROFILE_REBUILD,\n PROFILE_FRAME_START,\n PROFILE_FRAME_END,\n getTemplate,\n resolved,\n Instance,\n ChildPart,\n Slot,\n comment,\n toText,\n isTemplateResult,\n rootParts,\n registry,\n renderRoot,\n UNSET,\n UPGRADED,\n IGNORED,\n CHILD,\n SOLE,\n EVENT,\n ADOPT,\n TEXT,\n TEMPLATE,\n LIST,\n NODE,\n PROPERTY,\n LIVE,\n};\nexport type { Template };\n\n/** A list item: an instance of a single-root template (its element is its whole range), or a markered part. */\nexport type Item = Instance | ChildPart;\n\n/**\n * A value that names the strategy able to reconcile a list of its kind — `keyed()` is the producer.\n * It lives here rather than in `types.ts` because it names `ChildPart`, a runtime class of this file.\n */\nexport type ListStrategy = (part: ChildPart, values: unknown[], items: Item[], parent: Node, end: Node | null) => Item[];\n\n/** A `TemplateResult` that `keyed()` marked with its strategy. */\nexport interface KeyedResult extends TemplateResult {\n $r?: ListStrategy;\n}\n\n/**\n * A child position that holds anything but plain text: a template, a list, a node, or nothing — or\n * text it took over from an upgraded binding. It owns the range between two comment markers\n * — the root part's too, so content before and after a render stays — or, for a SOLE position, its element's whole\n * content (`$w`, no markers at all).\n *\n * **The ownership invariant — whoever writes an element's content owns it, and owns its verification.** Two cases:\n * a PLAIN element whose whole content is one binding belongs to that binding (the part is its range, and hydration\n * adopts it with no markers); a CUSTOM element's children belong to the component (a binding inside it keeps its\n * markers, and hydration compares them only when the template itself writes content inside the tag). Slots\n * inherit both.\n */\nclass ChildPart {\n $s: Comment | null;\n $e: Node | null;\n /** The element this part owns entirely (a SOLE position), or `null` for a part between markers. */\n $w: Node | null = null;\n $o = EMPTY;\n $v: unknown = undefined;\n $l: Text | null = null;\n $n: Instance | null = null;\n $i: Item[] | null = null;\n /** The key a keyed list reads when this part is one of its items. */\n $k: unknown = undefined;\n /** Instances `hold()` parked here, by template identity — they outlive interim content. */\n _held: Map<TemplateStringsArray, Instance> | null = null;\n /** Whatever the last `_$child$` applier returned here (its continuity), and which applier that was. */\n $z: unknown = undefined;\n $a: unknown = undefined;\n /** Released: its component was removed, and every user value it held dropped (see `releaseRoot`). */\n $x = false;\n /** The container whose render attached the applier — a later `_$commit$` runs as a render of it. */\n declare $R?: Node | null;\n\n constructor(start: Comment | null, end: Node | null) {\n this.$s = start;\n this.$e = end;\n }\n\n _insert(node: Node) {\n const placed = __DEV__ ? landing(node) : undefined;\n (this.$w ?? this.$s!.parentNode!).insertBefore(node, this.$e);\n if (__DEV__) checkForeign('renderer', this.$w ?? this.$s!.parentNode!, placed!, RETAG);\n }\n\n /**\n * Tells the CURRENT content that it is going away — the part itself stays, so what `hold()` parked here stays\n * parked and can still come back. Reached only when `notifyOnRemoval` is set.\n */\n _detach() {\n if (this.$a !== undefined) (this.$a as Applier)._$detach$?.(this.$z);\n if (this.$n !== null) teardown(this.$n);\n const items = this.$i;\n if (items !== null) for (let i = 0; i < items.length; i++) detachItem(items[i]);\n }\n\n /** The part itself is going away: its current content, and everything `hold()` parked here (then collectable). */\n _destroy() {\n this._detach();\n const held = this._held;\n if (held !== null) {\n for (const instance of held.values()) teardown(instance);\n this._held = null;\n }\n }\n\n _clear() {\n if (notifyOnRemoval) this._detach();\n const owner = this.$w;\n const start = this.$s;\n const end = this.$e;\n /** Owning the parent's whole content, one `textContent = ''` replaces a removal per node. */\n if (owner !== null) {\n if (__DEV__ && ownedRoots!.has(owner)) checkDropped(owner);\n owner.textContent = '';\n }\n else if (start!.previousSibling === null && end!.nextSibling === null) {\n const parent = start!.parentNode!;\n parent.textContent = '';\n parent.appendChild(start!);\n parent.appendChild(end!);\n } else {\n const parent = start!.parentNode!;\n let node = start!.nextSibling;\n /** `node !== null` is a backstop: a detached boundary leaves nodes behind rather than throwing mid-render. */\n while (node !== null && node !== end) {\n const next = node.nextSibling;\n parent.removeChild(node);\n node = next;\n }\n }\n this.$o = EMPTY;\n this.$l = null;\n this.$n = null;\n this.$i = null;\n this.$z = undefined;\n this.$a = undefined;\n }\n\n /**\n * How a `_$child$` applier renders — `_$`-named so it survives mangling, because third parties call\n * it. Its own state survives its own commit. A commit that arrives outside its container's render (an\n * applier resolving later) runs as a render of that container, while it still contains the part.\n */\n _$commit$(value: unknown) {\n const applierState = this.$z;\n const applier = this.$a;\n if (renderRoot !== this.$R || renderRoot === null)\n commitAs(this.$R != null && this.$R.contains(this.$w ?? this.$s) ? this.$R : null, this, value, this.$R ?? null);\n else this.$p(value);\n this.$z = applierState;\n this.$a = applier;\n }\n\n $p(value: unknown) {\n if (value == null) {\n if (this.$o !== EMPTY) this._clear();\n return;\n }\n if (typeof value !== 'object') {\n if (__DEV__ && typeof value === 'boolean' && (this.$o !== TEXT || this.$v !== value)) warnBooleanChild(value);\n if (this.$o === TEXT) {\n if (this.$v !== value) this.$l!.data = value as string;\n } else {\n if (this.$o !== EMPTY) this._clear();\n this._insert((this.$l = doc.createTextNode(value as string)));\n this.$o = TEXT;\n }\n this.$v = value;\n return;\n }\n /** `hold()` wraps a template as `{ $h }`: the one it replaces is parked by template identity, not destroyed. */\n const held = (value as { $h?: TemplateResult }).$h;\n if (held !== undefined || isTemplateResult(value)) {\n const result = held ?? (value as TemplateResult);\n /** The hottest line of a list update: same strings, commit the values and nothing else. */\n if (this.$o === TEMPLATE && this.$n!._strings === result.strings) {\n if (__DEV__ && profileHook !== null) profileHook(PROFILE_UPDATE, this, result.strings);\n update(this.$n!, result.values);\n return;\n }\n if (__DEV__ && profileHook !== null) profileHook(this.$o === TEMPLATE ? PROFILE_REBUILD : PROFILE_CREATE, this, result.strings);\n let instance: Instance | undefined;\n if (held !== undefined) {\n const parked = (this._held ??= new Map());\n if (this.$o === TEMPLATE) {\n const current = this.$n!;\n const root = current.$R;\n /** A fragment root takes its nodes back; an element root IS the range. */\n if (root.nodeType === 11) {\n let node = this.$w !== null ? this.$w.firstChild : this.$s!.nextSibling;\n while (node !== this.$e) {\n const next = node!.nextSibling;\n root.appendChild(node!);\n node = next;\n }\n } else root.parentNode?.removeChild(root);\n /**\n * Off the page now: slots watches what a parked branch's slots hold (`_$parked$`, off-chain like `_$done$`), told\n * WHOSE render parked it — the branch has left that host's subtree, where its one registration cannot see it.\n */\n (registry as { _$parked$?: (root: Node, owner: Node | null) => void } | null)?._$parked$?.(root, renderRoot);\n parked.set(current._strings, current);\n this.$o = EMPTY;\n }\n /** The map holds exactly what is PARKED: an instance coming back leaves it, so a later clear cannot strand it there. */\n instance = parked.get(result.strings);\n if (instance !== undefined) parked.delete(result.strings);\n }\n if (this.$o !== EMPTY) this._clear();\n if (instance === undefined) {\n if (__DEV__ && TEXT_ONLY.test(((this.$w ?? this.$s!.parentNode!) as Element).tagName)) sayTemplateInText(this.$w ?? this.$s!.parentNode!);\n let template = getTemplate(result);\n if (template.$X) template = resolved(template, this.$w ?? this.$s!.parentNode!);\n instance = instantiate(template, result, passDoc);\n this._insert(instance.$R);\n } else {\n /** Inserted first, then updated, as every update is: its nodes are live when its values commit. */\n this._insert(instance.$R);\n update(instance, result.values);\n }\n this.$n = instance;\n this.$o = TEMPLATE;\n return;\n }\n /** A value kind a module handles (`'value'` insert) — how a kind becomes a package, not a branch here. */\n const handlers = registry?.get('value') as ValueHandler[] | undefined;\n if (handlers !== undefined) for (let i = 0; i < handlers.length; i++) if (handlers[i](this, value)) return;\n if (Array.isArray(value)) return this._commitList(value);\n /**\n * Any other iterable is a list — but a node is placed, not iterated (a `<select>`, a `<form>`). Hydration's\n * `adoptObject` decides the same with its own lines: `tests/renderer-list-twins.test.mjs` keeps the two equal.\n */\n if (typeof (value as Iterable<unknown>)[Symbol.iterator] === 'function' && (value as Node).nodeType === undefined)\n return this._commitList([...(value as Iterable<unknown>)]);\n /**\n * A value that applies itself at a child position: `_$child$(part, previous)` renders through\n * `part._$commit$` and returns its continuity, handed back next time — to THIS applier only.\n */\n const applyChild = (value as { _$child$?: Applier })._$child$;\n if (applyChild !== undefined) {\n const previous = this.$a === applyChild ? this.$z : undefined;\n /**\n * An applier written as an object-literal method is a new function every call, so `previous` is always\n * undefined and it restarts every render. Said on the third swap at one part — once or twice is a real change.\n */\n if (__DEV__ && this.$a !== undefined && this.$a !== applyChild) {\n const swaps = (applierSwaps.get(this) ?? 0) + 1;\n applierSwaps.set(this, swaps);\n if (swaps === 3)\n console.warn(diagnostic('renderer', 'a child applier', 'applier-identity', __DEV__ && PROSE['applier-identity'](String(swaps))));\n }\n this.$a = applyChild;\n this.$R = renderRoot;\n if (applyChild._$detach$ !== undefined) notifyOnRemoval = true;\n this.$z = applyChild.call(value, this, previous);\n return;\n }\n if ((value as Node).nodeType !== undefined) {\n if (this.$o !== NODE || this.$v !== value) {\n if (this.$o !== EMPTY) this._clear();\n this._insert(value as Node);\n this.$v = value;\n this.$o = NODE;\n }\n return;\n }\n this.$p(String(value));\n }\n\n /** Creates one list item before `ref`. */\n $c(value: unknown, parent: Node, ref: Node | null): Item {\n if (value !== null && typeof value === 'object' && isTemplateResult(value)) {\n if (__DEV__ && TEXT_ONLY.test((parent as Element).tagName)) sayTemplateInText(parent);\n let template = getTemplate(value);\n if (template.$X) template = resolved(template, parent);\n if (template.$R.nodeType === 1) {\n const instance = instantiate(template, value, passDoc);\n into(parent, ref).insertBefore(instance.$R, ref);\n if (__DEV__) checkForeign('renderer', parent, [instance.$R], RETAG);\n instance.$k = value.key;\n /** Only a result marked `_$same$` (the keyed module marks its rows') records its identity. */\n if ((value as { _$same$?: unknown })._$same$ === 1) instance.$j = value;\n return instance;\n }\n }\n const part = markered(parent, ref);\n part.$p(value);\n part.$k = (value as TemplateResult | null)?.key;\n return part;\n }\n\n /** Commits `value` into an item; returns the item now standing there (an instance whose shape changed becomes a part). */\n $u(item: Item, value: unknown): Item {\n /**\n * The very result committed last time, and marked `_$same$`: nothing to do. Asked FIRST: it is the\n * common case of a keyed list's unchanged rows, and a part never records one (`$j` stays undefined).\n */\n if (value === (item as { $j?: unknown }).$j && value !== undefined) return item;\n if (item instanceof ChildPart) {\n item.$p(value);\n return item;\n }\n if (value !== null && typeof value === 'object' && (value as TemplateResult).strings === item._strings) {\n update(item, (value as TemplateResult).values);\n if ((value as { _$same$?: unknown })._$same$ === 1) item.$j = value;\n else if (item.$j !== undefined) item.$j = undefined;\n return item;\n }\n const element = item.$R as Element;\n const part = markered(element.parentNode!, element);\n /** The row's shape changed: the instance is gone for good, so what it holds is told. */\n if (notifyOnRemoval) teardown(item);\n /** `removeChild`, never `remove()`: the element may be a light slot, whose own `remove()` is the user's (slots). */\n element.parentNode?.removeChild(element);\n part.$k = item.$k;\n part.$p(value);\n return part;\n }\n\n /** The item's first node — its move handle and the insertion reference before it. */\n $f(item: Item): Node {\n return item instanceof ChildPart ? item.$s! : item.$R;\n }\n\n /** Moves an item before `ref`. */\n $m(item: Item, ref: Node | null, parent: Node = this.$w ?? this.$s!.parentNode!) {\n const at = into(parent, ref);\n if (!(item instanceof ChildPart)) {\n at.insertBefore(item.$R, ref);\n return;\n }\n let node: Node | null = item.$s!;\n const stop = item.$e!.nextSibling;\n while (node !== stop) {\n const next: Node | null = node!.nextSibling;\n at.insertBefore(node!, ref);\n node = next;\n }\n }\n\n /** Removes an item. */\n $d(item: Item) {\n if (notifyOnRemoval) detachItem(item);\n this.$m(item, null, SCRATCH);\n SCRATCH.textContent = '';\n }\n\n _commitList(values: unknown[]) {\n const count = values.length;\n /**\n * A keyed list names its own strategy (`keyed()` stamps `$r`). Keyed and index items are the same\n * kind of item — an unkeyed one carries `$k === undefined`, which a keyed pass treats as not found —\n * so a list can change between the two without being rebuilt.\n */\n const strategy = count ? (values[0] as KeyedResult | null)?.$r : undefined;\n if (this.$o !== LIST) {\n if (this.$o !== EMPTY) this._clear();\n this.$i = [];\n this.$o = LIST;\n }\n const items = this.$i!;\n if (count === 0) {\n if (items.length) {\n this._clear();\n this.$i = [];\n this.$o = LIST;\n }\n return;\n }\n const parent = this.$w ?? this.$s!.parentNode!;\n const end = this.$e;\n if (strategy !== undefined) {\n this.$i = strategy(this, values, items, parent, end);\n return;\n }\n /** Index mode: update in place, grow at the end, shrink from the end. Rows go straight into the parent. */\n const shared = items.length < count ? items.length : count;\n for (let i = 0; i < shared; i++) items[i] = this.$u(items[i], values[i]);\n for (let i = items.length; i < count; i++) items.push(this.$c(values[i], parent, end));\n if (count < items.length) {\n if (notifyOnRemoval) for (let i = count; i < items.length; i++) detachItem(items[i]);\n for (let i = count; i < items.length; i++) this.$m(items[i], null, SCRATCH);\n SCRATCH.textContent = '';\n items.length = count;\n }\n }\n}\n\n/** A value at a child position a module claims — the `'value'` insert. Return `true` to take it. */\ntype ValueHandler = (part: object, value: unknown) => boolean | void;\n/** An element-position value that applies itself — a spread. */\ntype Applies = { _$apply$: (element: Element, key: object, run: Untracked, adopting?: boolean) => void };\n\n/** A child-position applier: renders through `part._$commit$`, keeps continuity in its return value. */\ntype Applier = ((part: { _$commit$(value: unknown): void }, previous: unknown) => unknown) & {\n /** Told, with its last state, when its position goes away. */\n _$detach$?: (previous: unknown) => void;\n};\n\n/**\n * The registry `renderer.connect` was handed — the app's own, so a CDN page with separate bundles still\n * meets one `'value'`/`'error'` chain. Never imported: a production bundle inlines `@verajs/inserts`.\n */\nlet registry: { get(name: string): unknown[] | undefined } | null = null;\n\n/**\n * Core's `untracked`, taken off that registry at `connect` (`call` without core): what the renderer runs someone\n * else's code through during a render — a ref, and a component's getter it reads on the parent's behalf — so that\n * code's reads subscribe nothing. What the renderer reads ITSELF stays tracked: a store array handed to a template\n * is walked here, and that walk is what subscribes the parent to its length and items.\n */\nlet untracked: Untracked = call;\n\n/** The container of the `renderInto` in progress — a ref's error names its component through it. */\nlet renderRoot: Node | null = null;\n\n/**\n * Whether anything asked to be told when a subtree goes away: a ref to release, an applier with\n * `_$detach$`. Process-wide — an app with neither walks nothing, and a clear stays one `textContent = ''`.\n */\nlet notifyOnRemoval = false;\n\n/** Something adopted must be told when it goes away — an applier with `_$detach$` that hydration adopts. */\nexport const needRemovalWork = () => {\n notifyOnRemoval = true;\n};\n\n\n/**\n * Refs held until the pass's DOM exists, as flat `(bindings, slot)` pairs: each is handed its element once that\n * element is inserted, upgraded and in its own document. A render flushes only what it queued, so a nested render\n * cannot apply its caller's early. Refs run in commit order, which is document PRE-order — `<div ${a}>${child}</div><p\n * ${b}>` runs a, then the child's refs, then b — not all parents first.\n */\nlet pendingRefs: unknown[] | null = null;\n/**\n * **A `<select>`'s selection is written when the pass ends**, once its options exist. In document order a binding ON\n * the select comes before the options inside it, so a selection written in place — `.value`, `!value`,\n * `.selectedIndex`, or a spread's key — found no options and fell back to the first. Every source of options is\n * content inside the select (a list, a nested template, a keyed list: the content model allows only `<option>`,\n * `<optgroup>` and `<hr>`), so all of it exists when the pass ends. Options a user's code appends later are out of\n * scope.\n *\n * Flat PAIRS, one queue, in commit order. The common record is `(select, value)` for a `value` binding — compared\n * against the live value and written only on a difference (the write resets every option). The rare ones are\n * `(LATER, [select, index])` for `selectedIndex` and `(LATER, [applier, element, slot])` for a value applying itself\n * on a select, a spread. Flushed first, so a ref on the select sees its selection. A render flushes only what it\n * queued, however it ends, so nothing it held can land on a later, unrelated render.\n *\n * The shape is measured, on a table with a bound select per row: committing\n * each instance's selects after its own bindings, 2–4% slower; deferring the whole binding to a second commit,\n * 8–13%; records of three with the name in them, 3–6%. Pairs whose common case is exactly `(select, value)` tie.\n */\nconst LATER = {};\nlet pendingSelects: unknown[] | null = null;\nconst flush = (selectsFrom: number, refsFrom: number) => {\n const selects = pendingSelects;\n if (selects !== null && selects.length > selectsFrom) {\n const mine = selects.splice(selectsFrom);\n if (selects.length === 0) pendingSelects = null;\n for (let i = 0; i < mine.length; i += 2) {\n const a = mine[i];\n const b = mine[i + 1];\n if (a === LATER) {\n const r = b as unknown[];\n /** Read and written BY NAME: a computed `select[name]` on a DOM accessor measured 5% slower. */\n if (r.length === 2) {\n if ((r[0] as HTMLSelectElement).selectedIndex !== r[1]) (r[0] as HTMLSelectElement).selectedIndex = r[1] as number;\n } else (r[0] as Applies)._$apply$(r[1] as Element, r[2] as Slot, untracked);\n } else if ((a as HTMLSelectElement).value !== b) (a as HTMLSelectElement).value = b as string;\n }\n }\n /** Taken off first: a ref can render again. */\n const refs = pendingRefs;\n if (refs === null || refs.length <= refsFrom) return;\n const mine = refs.splice(refsFrom);\n if (refs.length === 0) pendingRefs = null;\n /** A ref is someone else's code: what it reads must not subscribe the render that handed it the element. */\n untracked(applyRefs, mine);\n};\n\n/**\n * Refs, and instance mounts, in commit order — once the pass's DOM exists, so a claim sees the finished tree. (A\n * claim that RELOCATES a node — elements', slots' — may run after refs inside it, so such a ref saw its element before\n * the move: the same element, but pre-claim geometry. Measure in a mount, or after the render, not in a ref.)\n */\nconst applyRefs = (mine: unknown[]) => {\n for (let i = 0; i < mine.length; i += 2) {\n const bindings = mine[i] as unknown[];\n const at = mine[i + 1] as number;\n if (typeof at !== 'number') {\n (mine[i] as InstanceHook).$m(at);\n continue;\n }\n const record = bindings[at] as Slot;\n const value = bindings[at + 1];\n record._state = 0;\n if (typeof value === 'function') applyRef(value as (element: Element | null) => void, record._element);\n else if (value !== null && typeof value === 'object' && value !== UNSET) (value as { value: unknown }).value = record._element;\n }\n};\n\n/**\n * The document the pass renders into — the container's own (a popped-out window's, an iframe's), so every\n * instance is built in its realm. Read off the container once per pass, never off a node that may still sit\n * in the inert template document.\n */\nlet passDoc: Document = doc;\n\n/**\n * Preserves the DOM of a template a position toggles away from, instead of destroying it — form values\n * and media state survive the round trip. Anything that is not a template passes straight through, so\n * `hold(editing && editor())` is fine.\n *\n * ```js\n * html`<div>${hold(editing ? editor() : viewer())}</div>`\n * ```\n */\nexport const hold = <T>(result: T): T | { $h: TemplateResult } =>\n result != null && typeof result === 'object' && isTemplateResult(result) ? { $h: result as TemplateResult } : result;\n\n/**\n * **Where an insert before `ref` goes** — the parent given, unless light-DOM slots moved `ref` (it marks what it moves,\n * `_$slotted$`, sigiled so both bundles read it): then `ref`'s own, which is where the light child now lives. A node\n * anything ELSE moved is not followed — the insert throws as it always has, rather than land in a stranger's container.\n */\nconst into = (parent: Node, ref: Node | null): Node =>\n ref !== null && (ref as { _$slotted$?: boolean })._$slotted$ ? ref.parentNode! : parent;\n\n/** A fresh part whose two markers sit before `ref` in `parent`. */\nconst markered = (parent: Node, ref: Node | null) => {\n const end = comment();\n const part = new ChildPart(comment(), end);\n const at = into(parent, ref);\n at.insertBefore(part.$s!, ref);\n at.insertBefore(end, ref);\n return part;\n};\n\n/**\n * Commits `value` into `part` as a render of `root`: the root and its document are set and restored (a render\n * can run inside another's commit), and the work this pass queued is flushed however it ends — before the\n * restore, so a ref's error still names its own component and a ref that renders renders into this document.\n * `home` is where the document comes from when `root` is not the render being attributed: the container an\n * applier was attached under, even after the part has moved out of it (a parked `hold` fragment belongs to the\n * inert template document, and must never become the document a render builds in).\n */\nconst commitAs = (root: Node | null, part: ChildPart, value: unknown, home: Node | null = root) => {\n const outer = renderRoot;\n const outerDoc = passDoc;\n const selectsMark = pendingSelects?.length ?? 0;\n const refsMark = pendingRefs?.length ?? 0;\n const outerScope = scope;\n scope = null;\n renderRoot = root;\n /** A document's own `ownerDocument` is null — so a document container is its own. */\n if (home !== null) {\n const owner = home.ownerDocument ?? (home as Document);\n /**\n * **Content builds in the realm of the element it renders into** (2026-10-22). A component of THIS realm moved\n * into a pop-out or an iframe keeps building here: made through that window's document, its children would be looked\n * up in THAT window's registry — Chromium upgrades them anyway, Firefox and WebKit leave them inert; cloned through\n * this renderer's own document they upgrade at the clone on all three and keep their class once inserted there\n * (adoption; BROWSER-LEDGER 2026-10-22). An element of the OTHER realm — a plain container that window made, or a\n * component its own registry defined — builds in its own document, with that window's classes\n * (`tests/browser/realm.test.js`). Checked only for a container in another window (\"not ours, and has a window\" — a\n * document with a window is that window's only one); a windowless document (a server's, a template's) is used as is.\n */\n passDoc =\n owner !== doc && owner.defaultView !== null && ((root as ShadowRoot | null)?.host ?? root) instanceof (doc.defaultView as typeof globalThis).HTMLElement\n ? doc\n : owner;\n }\n /** Development: a commit into an owned root is that root's own work (see `strays`). */\n const marking = __DEV__ && root !== null && ownedRoots!.has(root) && !rendering!.has(root);\n if (marking) {\n sweepStrays();\n rendering!.add(root!);\n }\n try {\n part.$p(value);\n } finally {\n flush(selectsMark, refsMark);\n if (marking) {\n sweepStrays();\n rendering!.delete(root!);\n }\n renderRoot = outer;\n passDoc = outerDoc;\n scope = outerScope;\n }\n};\n\n\n/**\n * **Each root's part, kept ON the root** — under this renderer copy's own `Symbol` (2026-10-17). It was a WeakMap keyed\n * by DOM nodes, and that cost every component's creation and removal in both engines' collectors: fresh-browser races\n * of shadow components put it at ~11% in Firefox and ~9% in Chrome (Firefox's sweep and mark phases, per entry). A field\n * is an ordinary property, freed with its root. **A Symbol, never a string:** a page can hold two renderer copies (a CDN\n * bundle beside an app's, two versions), and a string-named field — lit's `_$litPart$` — would hand one copy the\n * other's part; per-copy, each sees only its own, as with the WeakMap. Root → part → root is a DOM↔JS cycle only\n * Firefox's cycle collector frees, so a released root's part lets go of its root (`releaseRoot`).\n */\nconst PART = Symbol();\ntype Rooted = Node & { [PART]?: ChildPart };\nconst rootParts = {\n get: (node: Node) => (node as Rooted)[PART],\n set: (node: Node, part: ChildPart) => {\n (node as Rooted)[PART] = part;\n },\n};\n\n/**\n * **A root the template OWNS** (`foreignNodes: 'drop'`, 2026-10-16: shadow component roots). Core's render hook\n * says so with its third argument — a container handed to `renderInto` directly never does — and it is taken only for a\n * SHADOW root EMPTY at its first render: a declarative (server) root and one holding styles' text fallback are not empty,\n * and keep their markers. No marker comments: the part owns the root's whole content (`$w`, as a sole binding owns its\n * element), so a template change clears it with one `textContent = ''` — foreign nodes included — and an ordinary\n * re-render touches nothing it did not render. Where new content lands relative to a foreign node is not promised.\n */\nconst owned = (container: Node) => {\n const part = new ChildPart(null, null);\n part.$w = container;\n if (__DEV__) watchOwned(container);\n return part;\n};\n\n/**\n * **Development: what an owned root's clear drops.** Nodes the RENDER placed are its own; anything placed while no render\n * of that root was running is foreign. One observer (built from the first owned root's own window) watches every owned\n * root's direct children; its records are sorted at each commit's start and end — so whatever arrives between renders is\n * foreign, and whatever a render inserts is not — and once more at a clear, which then names a foreign node it is about to\n * remove. Production keeps none of it: the clear is the same in both builds, only the line is development's.\n * **Best-effort across windows:** ONE observer serves every window, so a root that moves to another window stays on the\n * observer that sweeps it (one per window would sweep the new window's while the records sat in the old one's, and call\n * the root's own renders foreign). Should the window it was built from go away and take the observer with it, the\n * warning goes quiet; what a clear removes never depends on it.\n */\nconst strays = __DEV__ ? new WeakSet<Node>() : null;\nconst ownedRoots = __DEV__ ? new WeakSet<Node>() : null;\nconst rendering = __DEV__ ? new Set<Node>() : null;\nlet strayWatch: MutationObserver | null | undefined;\nconst sortStrays = (records: MutationRecord[]) => {\n for (const record of records) {\n const own = rendering!.has(record.target);\n for (const node of record.addedNodes)\n if (own) strays!.delete(node);\n else strays!.add(node);\n }\n};\nconst sweepStrays = () => {\n if (strayWatch) sortStrays(strayWatch.takeRecords());\n};\nconst watchOwned = (container: Node) => {\n ownedRoots!.add(container);\n if (strayWatch === undefined) {\n const View = (container.ownerDocument?.defaultView as (typeof globalThis) | null | undefined)?.MutationObserver;\n strayWatch = View ? new View(sortStrays) : null;\n }\n strayWatch?.observe(container, { childList: true });\n};\n/** Development: whether a clear is dropping a node the template did not make, said once per page. */\nconst checkDropped = (owner: Node) => {\n sweepStrays();\n if (hasWarned('foreign-dropped')) return;\n for (let node = owner.firstChild; node !== null; node = node.nextSibling)\n if (strays!.has(node)) {\n const host = (owner as ShadowRoot).host;\n warnOnce('renderer', host ? `<${host.localName}>` : 'renderInto', 'foreign-dropped', __DEV__ && (() => PROSE['foreign-dropped'](describe(node))));\n return;\n }\n};\n/** Development: a node named in the drop warning — its tag, or its kind. */\nconst describe = (node: Node) => (node.nodeType === 1 ? `<${(node as Element).localName}>` : node.nodeType === 3 ? 'a text node' : 'a comment');\n\n/** `hydration`'s adoption, installed through the hand-off (`$Y`): true when it adopted the container. */\nlet adopt: ((result: unknown, container: Node) => boolean) | undefined;\n\n/**\n * The container is the argument people forget, and forgetting it failed with `Cannot read properties of undefined`\n * — a message about the internals of a function the caller never named. Development only; the hydrate entry calls\n * it too, since it reads the container before it reaches the base render.\n */\nexport const expectContainer = (container: unknown) => {\n if (!container || typeof (container as Node).appendChild !== 'function')\n throw new TypeError(misuse('renderInto', 'no-container', __DEV__ && PROSE['no-container'](String(container))));\n};\n\n/**\n * Writes a template result into a container — the renderer's imperative draw: no reactivity, no\n * lifecycle. The first call appends two markers and anchors a root part between them; later calls reuse it\n * and commit only the values. Content already in the container stays, and so does content other code adds\n * after it — the render owns its range, never the container. lit-html's argument order. The third argument, `owns`, is\n * core's: its render hook passes a component's `foreignNodes: 'drop'` with every render, and a shadow root that is empty\n * at its first render is then the template's whole (`owned`). A direct call is a container's, and keeps its markers.\n */\n/**\n * **A removed component's root part, RELEASED** (2026-10-11). Core's teardown calls `$x(container)` (the\n * registry sigil this renderer publishes at connect): every user value the part's tree holds is dropped — each event\n * `Slot`'s handler, each binding's committed value, nested parts, keyed items, `hold()`-parked instances — so the\n * removed DOM keeps no path back into the component's JS (its handlers close over the whole setup scope, and the DOM's\n * own listener lists hold the Slots). That cycle was Firefox's CYCLE collector's to free: with host-capturing handlers,\n * 20 s of CC on a churn page against vanilla `addEventListener`'s 1 s. The DOM itself is LEFT as it is (code holding a\n * removed element still sees its content); the stripped part stays in `rootParts`, flagged, so a RE-ADD finds it,\n * clears its range and renders fresh — never a second copy, and never taken for a server page by hydration.\n */\nconst releaseItem = (item: Item): void => {\n if (item instanceof ChildPart) {\n if (item.$n !== null) releaseItem(item.$n);\n const items = item.$i;\n if (items !== null) for (let i = 0; i < items.length; i++) releaseItem(items[i]!);\n item._held?.forEach(releaseItem);\n item.$v = item.$z = item.$a = undefined;\n item.$n = null;\n item.$i = null;\n item._held = null;\n return;\n }\n const bindings = item._bindings;\n for (let i = 0; i < bindings.length; i += 2) {\n const target = bindings[i];\n if (target instanceof Slot) target._handler = null;\n else if (target instanceof ChildPart) releaseItem(target);\n bindings[i + 1] = undefined;\n }\n};\n/**\n * Called with the removed ELEMENT: a light component's part is keyed by the element itself (a hit); a shadow one's by its\n * root. The part STAYS in `rootParts`, stripped and flagged (`$x`) — no map work per removal; a re-add finds the flag.\n */\nconst releaseRoot = (element: Node) => {\n const part = rootParts.get(element) ?? rootParts.get((element as Element).shadowRoot ?? element);\n if (part === undefined || part.$x) return;\n releaseItem(part);\n part.$x = true;\n /**\n * An OWNED root's part lets go of its root, so the removed root and its part are no cycle for Firefox's cycle collector\n * (−113 ms of incremental CC on a churn page, 2026-10-17); `reviveRoot` gives it back. A markered part keeps its two\n * markers: a re-add clears between them.\n */\n if (part.$s === null) part.$w = part.$l = part.$R = null;\n};\n/**\n * **A released component is coming back** — core calls `$y(element)` as a re-init starts, BEFORE its `'init'` inserts:\n * an OWNED released root is cleared now, so what those inserts put in the root (styles' `<style>` fallback in a window that\n * cannot adopt the sheet) is never in the way of the clear. An owned root has no markers to bound it, so this is the\n * only moment its own content and theirs are told apart without holding a node (a part holding the removed root's\n * nodes cost Firefox's churn 2.3%, 2026-10-16). The first render then draws into an empty part.\n */\nconst reviveRoot = (element: Node) => {\n const container = rootParts.get(element) !== undefined ? element : (element as Element).shadowRoot ?? element;\n const part = rootParts.get(container);\n /**\n * OWNED roots only (no markers): a markered root's own clear stops at its marker, so it waits for the next render as it\n * always did — and a re-init that renders nothing (`init(this)` with no setup, its content drawn by someone else) keeps it.\n */\n if (part === undefined || !part.$x || part.$s !== null) return;\n part.$w = container;\n part.$x = false;\n part._clear();\n};\n\nexport const renderInto = (result: unknown, container: Node, owns?: boolean) => {\n if (__DEV__) expectContainer(container);\n if (__DEV__ && profileHook !== null) profileHook(PROFILE_FRAME_START, container, null);\n let part = rootParts.get(container);\n /** A RE-ADDED component: its released part's old range is cleared, and it renders fresh into it. */\n if (part?.$x) {\n /** An owned part let go of its root at the release; it is this container. */\n if (part.$s === null) part.$w = container;\n part.$x = false;\n part._clear();\n }\n /**\n * A container's FIRST render, with something already in it: `hydration` (when wired) may adopt that as server output\n * of this template — then it is committed, and the render is done. Asked only on a first render, never on the hot\n * path; without hydration it is one undefined read.\n */\n if (part === undefined && adopt !== undefined && container.firstChild !== null && adopt(result, container))\n part = rootParts.get(container)!;\n else {\n if (part === undefined) {\n /**\n * Nothing adopts: whatever recognizes server markup is told before this render would append beside it (light slots)\n * — only a container that HAS something in it; an empty one (every plain component's first render) holds no\n * server markup, and asking it cost Firefox a call per component (2026-10-17 profile).\n */\n if (adopt === undefined && container.firstChild !== null) (registry as { _$unadopted$?: (container: Node) => void } | null)?._$unadopted$?.(container);\n rootParts.set(container, (part = owns === true && container.nodeType === 11 && container.firstChild === null ? owned(container) : markered(container, null)));\n }\n commitAs(container, part, result);\n }\n /**\n * **A render has finished** — said to whatever asked (light-DOM slots, which re-distributes what this render did to\n * a host's light children before anything reads them, and at a container's first render takes what was there before\n * the render's own range — `start` — as its light children). Off-chain and sigiled, like `$t`: not an extension point.\n */\n (registry as { _$done$?: (container: Node, start: Node) => void } | null)?._$done$?.(container, part.$s!);\n if (__DEV__ && profileHook !== null) profileHook(PROFILE_FRAME_END, container, null);\n};\n\n/**\n * Marks the raw function so `wire(renderInto)` — wiring the draw instead of the module — is caught by name in\n * development: the inserts registry reads `$module` and says `did you mean \\`renderer\\``. Production carries neither.\n */\nif (__DEV__) (renderInto as unknown as { $module?: string }).$module = 'renderer';\n\n/** Everything this renderer needs, in one entry: `wire([renderer])`. */\n/** The renderer's connect: core's registry, its untracked primitive, and the hydration hand-off. */\nconst connectTo = (given: { get(name: never): unknown }) => {\n /**\n * **One renderer serves one core** (2026-10-21). Two apps sharing one renderer bundle (two cores, the\n * micro-frontend shape) leave it following the LAST core's seams — `untracked` among them — so the first app's\n * tracking silently breaks. It stays last-wins, and says so once in EVERY build — production as a short line with\n * the code's docs link (the hazard exists ONLY in production: development's core copies share one registry). The same registry wired again\n * (`wire([renderer({ shadow })])` after `wire([renderer])`) is not a second core.\n */\n if (registry !== null && registry !== given) {\n console.warn(__DEV__ ? diagnostic('renderer', 'renderer', 'renderer-two-cores', __DEV__ && PROSE['renderer-two-cores']()) : '[vera] renderer-two-cores');\n }\n registry = given as { get(name: string): unknown[] | undefined };\n untracked = (given as { $t?: Untracked }).$t ?? call;\n /**\n * Development: \"the full renderer is connected\" (Brian's ruling, 2026-11-12). Automatic lists (`lists`) commit their rows through\n * this renderer's 'value' insert; wired beside only a bare render descriptor (`{ on: 'render', fn: renderInto }`),\n * which never connects, each row's change re-renders its parent instead, and core's `mapped` says so once.\n */\n if (__DEV__) (given as { $rn?: true }).$rn = true;\n /** Defined up front, so every render's `_$done$` read is a HIT on a page without slots — not a miss down the Map's chain. */\n (given as { _$done$?: unknown })._$done$ ??= undefined;\n /** The release core's teardown calls with a removed component (see `releaseRoot`). */\n (given as { $x?: (container: Node) => void }).$x = releaseRoot;\n /** …and the revival core's re-init calls before its `'init'` inserts (see `reviveRoot`). */\n (given as { $y?: (container: Node) => void }).$y = reviveRoot;\n /**\n * **The hydration hand-off** — the one door `hydration` reaches this renderer's internals through (a separately\n * bundled module cannot import them, and production mangles their names): only values the renderer already holds,\n * so it pulls no code in. An ARRAY, read by the `HANDOFF_*` positions in `kinds.ts` (names would cost every app\n * bytes). Position 0 is its protocol number; on a mismatch hydration declines and the page renders fresh, with a\n * warning. Positions 0 and 1 are FROZEN — the same in every protocol — so a mismatched hydration can still clear\n * server markup.\n */\n (given as { $H?: unknown }).$H = [\n PROTOCOL, // HANDOFF_PROTOCOL\n (fn: typeof adopt) => (adopt = fn), // HANDOFF_ADOPTER\n getTemplate, // HANDOFF_GET_TEMPLATE\n ChildPart, // HANDOFF_CHILD_PART\n Instance, // HANDOFF_INSTANCE\n Slot, // HANDOFF_SLOT\n UNSET, // HANDOFF_UNSET\n UPGRADED, // HANDOFF_UPGRADED\n commit, // HANDOFF_COMMIT\n commitAs, // HANDOFF_COMMIT_AS\n hookUp, // HANDOFF_HOOK_UP\n resolved, // HANDOFF_RESOLVE\n rootParts, // HANDOFF_ROOTS\n toText, // HANDOFF_TO_TEXT\n needRemovalWork, // HANDOFF_REMOVAL_WORK\n ];\n};\n\n/**\n * Whether this process is a SERVER: `@verajs/ssr` sets this public flag at import. Read ONCE, as this module loads — a\n * server always imports ssr first, because this module reads `document` as it loads and only ssr's DOM provides one.\n */\nconst onServer = (globalThis as { __veraSsrShimmed?: boolean }).__veraSsrShimmed === true;\n\ntype Registry = { get(name: never): unknown; $S?: unknown; $F?: unknown };\n/**\n * What a consumer's TypeScript sees — the shape `wire` accepts (`Wireable`, structurally: this package imports no\n * types from `@verajs/inserts`): a DESCRIPTOR, `on: 'render'`, callable with options to give `[renderer, a connector]`.\n * On a server `on` is in fact `undefined` (decided at load, below) — a runtime decision the type does not carry, as\n * the previous `on: 'render' | undefined` did: that matched neither a descriptor nor a connector, so `wire([renderer])`\n * stopped compiling in a consumer's project (tests/consumer, 2026-10-10).\n */\ntype RendererModule = ((options?: { shadow?: 'open' | 'closed' | false | ShadowRootInit; foreignNodes?: 'preserve' | 'drop' }) => readonly [RendererModule, (registry: Registry) => void]) & {\n readonly on: 'render';\n fn: never;\n priority: number;\n connect: (given: Registry) => void;\n};\n\n/**\n * **`renderer` is a DUAL** — `wire([renderer])` as it always was, or `wire([renderer({ shadow: 'open' })])` to set the\n * app's default root: every component whose own `shadow` option says nothing gets it (core's `init` reads it after the\n * component's own and before light DOM). `renderer({ foreignNodes: 'preserve' })` is the same for `foreignNodes`, and sets\n * COMPONENT roots only — a container handed to `renderInto` (`document.body`, `#app`) always keeps foreign nodes. Called, it returns `[renderer, a connector setting the default]` — `wire`\n * takes nested arrays — so the module is one function with its descriptor fields on it, and nothing is made per call\n * but that connector.\n *\n * **On a server it declines its render insert** (Brian's (b′), 2026-10-10): `@verajs/ssr` renders with its own renderer,\n * and a client one wired in shared app code used to DISPLACE it, breaking every server render. There `on` is undefined,\n * which makes `wire` hand this function the registry as a CONNECTOR: it still CONNECTS — the registry, `untracked`, the\n * hydration hand-off: a process that loaded ssr may install a client DOM and call renderInto directly (tests/spread-ssr\n * does) — and only the render INSERT is declined, so one shared `wire([renderer({ shadow })])` carries the same default\n * to both sides. Development says so once per process.\n */\nexport const renderer = Object.assign(\n (given?: { shadow?: unknown } | Registry) => {\n if ((given as Registry | undefined)?.get) {\n connectTo(given as Registry);\n /** Development: the decline is said once per process. */\n if (__DEV__) warnOnce('renderer', 'wire([renderer])', 'renderer-on-server', __DEV__ && (() => PROSE['renderer-on-server']()));\n return;\n }\n if (__DEV__ && given != null && typeof given !== 'object') {\n console.warn(diagnostic('renderer', 'renderer()', 'renderer-options', __DEV__ && PROSE['renderer-options'](typeof given === 'string' ? `'${given}'` : String(given))));\n return [renderer];\n }\n if (__DEV__)\n for (const key in given as object)\n if (key !== 'shadow' && key !== 'foreignNodes')\n console.warn(diagnostic('renderer', 'renderer()', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'foreignNodes, shadow')));\n const shadow = (given as { shadow?: unknown } | undefined)?.shadow;\n const foreignNodes = (given as { foreignNodes?: unknown } | undefined)?.foreignNodes;\n return [\n renderer,\n (registry: Registry) => {\n if (shadow !== undefined) registry.$S = shadow;\n if (foreignNodes !== undefined) registry.$F = foreignNodes;\n },\n ];\n },\n { on: onServer ? undefined : ('render' as const), fn: renderInto as never, priority: 50, connect: connectTo }\n) as unknown as RendererModule;\n/** Development: the name the collision warning reports (`wire`'s name bookkeeping is development-only). */\nif (__DEV__) Object.defineProperty(renderer, 'name', { value: '@verajs/renderer' });\n\n/**\n * Development: `renderInto` is the draw, not the module — `wire([renderInto])` would be taken as a connector and\n * register nothing, silently. `wire` reads this mark and names `renderer` instead. Production carries\n * neither.\n */\nif (__DEV__) (renderInto as unknown as { $module?: string }).$module = 'renderer';\n"],"names":["misuse","forName","withCode","andProse","adoptProperty","element","name","value","adopt","_$adopt$","carrier","Object","getPrototypeOf","desc","getOwnPropertyDescriptor","undefined","set","get","call","_$props$","view","ownerDocument","defaultView","HTMLElement","prototype","SCRIPT_URL","URL_SINK","SCRIPT_URL_ITEM","INLINE_HANDLER","JSON_BLOCK","closedRawText","text","json","replace","encodeText","c","charCodeAt","fn","a","b","dispatch","holder","event","handler","_handler","_element","handleEvent","isSelection","localName","read","target","key","LIVE","MARKER","INERT_MARKERS","doc","document","comment","createComment","TEXT_END","COMMENT_END","COMMENT2_END","TAG_END","DOUBLE_QUOTE_END","SINGLE_QUOTE_END","RAW_TEXT_TAGS","NEVER_SHOWN","UNSET","UPGRADED","Template","$R","_plain","$K","$N","$J","$P","_present","$L","$X","constructor","result","strings","count","length","kinds","this","Array","fill","names","statics","present","urls","nodes","rawEnd","markup","regex","open","i","s","match","nameEnd","continues","at","lastIndex","exec","test","RegExp","slice","startsWith","type","_$litType$","createElement","innerHTML","content","firstChild","replaceWith","childNodes","walker","createTreeWalker","node","nextNode","nodeType","data","anchor","createTextNode","currentNode","el","includes","hasAttribute","attribute","getAttributeNames","endsWith","parseInt","getAttribute","split","removeAttribute","written","first","kind","real","toLowerCase","sink","source","tagName","firstElementChild","textContent","Error","pieces","raw","filter","_","p","append","root","nextSibling","parent","parentNode","host","removeChild","path","index","sibling","previousSibling","unshift","push","hooks","registry","readScope","_$at$","_$inst$","_$ns$","scope","resolved","template","templateCache","WeakMap","forged","getTemplate","isArray","hasOwn","toText","textOf","Slot","_state","untracked","applyRef","callback","error","handlers","line","reportError","console","reportUncaught","reportTo","renderRoot","Instance","$k","$j","_template","_strings","_bindings","bindings","instantiate","owner","cloneNode","importNode","paths","marked","step","hops","instance","hookUp","outer","update","values","adopted","hook","state","$c","pendingRefs","notifyOnRemoval","commit","slot","committed","$p","part","ChildPart","$w","$o","$l","$v","markered","insertBefore","$e","pendingSelects","LATER","parts","url","_$raw$","setAttribute","toggleAttribute","listener","addEventListener","adopting","release","_$apply$","teardown","$q","_destroy","detachItem","item","isTemplateResult","SCRATCH","createDocumentFragment","$s","$n","$i","_held","$z","$a","$x","start","end","_insert","_detach","_$detach$","items","held","_clear","appendChild","next","_$commit$","applierState","applier","commitAs","contains","$h","parked","Map","current","_$parked$","delete","passDoc","_commitList","Symbol","iterator","applyChild","_$child$","previous","String","ref","into","_$same$","$u","$f","$m","stop","$d","strategy","$r","shared","needRemovalWork","applyRefs","mine","record","hold","_$slotted$","home","outerDoc","selectsMark","refsMark","outerScope","selectsFrom","refsFrom","selects","splice","r","selectedIndex","refs","flush","PART","rootParts","releaseItem","forEach","releaseRoot","shadowRoot","reviveRoot","container","renderInto","owns","_$unadopted$","owned","_$done$","connectTo","given","warn","$t","$y","$H","onServer","globalThis","__veraSsrShimmed","renderer","assign","shadow","foreignNodes","$S","$F","on","priority","connect"],"mappings":"AAMO,MA0EMA,EAAS,CAACC,EAAiBC,EAAkBC,IAGpD,GAAGF,2BAAmBC,ICnDfE,EAAgB,CAACC,EAAuBC,EAAcC,KAOjE,GAAa,cAATD,EAAsB,OAAO,EACjC,MAAME,EAAQH,EAAQI,SAEtB,IAAK,IAAIC,EAAyBL,EAAqB,OAAZK,EAAkBA,EAAUC,OAAOC,eAAeF,GAAU,CACrG,MAAMG,EAAOF,OAAOG,yBAAyBJ,EAASJ,GACtD,QAAaS,IAATF,EAAJ,CACA,QAAiBE,IAAbF,EAAKG,IAEP,OADAX,EAAQC,GAAQC,EACT,EAET,QAAiBQ,IAAbF,EAAKI,IAUP,YATcF,IAAVP,GAAqBA,EAAMU,KAAKb,EAASC,EAAMC,GAS5C,EAET,KAjBwB,CAkB1B,CAEA,GADAF,EAAQC,GAAQC,OACFQ,IAAVP,EAEF,OADAA,EAAMU,KAAKb,EAASC,EAAMC,GACnB,GAEOF,EAAQc,WAAa,IAE9Bb,GAAQC,EAEf,MAAMa,EAAOf,EAAQgB,cAAcC,YAoBnC,OAhB0B,OAATF,GAAiBT,OAAOC,eAAeP,KAAae,EAAKG,YAAYC,UAgBpE,EA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