@verajs/renderer 0.3.0 → 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.
- package/README.md +52 -6
- package/dist/development/vera-renderer-elements.js.map +1 -1
- package/dist/development/vera-renderer-hydrate-slots.js +1 -1
- package/dist/development/vera-renderer-hydrate-slots.js.map +1 -1
- package/dist/development/vera-renderer-hydration.d.ts.map +1 -1
- package/dist/development/vera-renderer-hydration.js +42 -4
- package/dist/development/vera-renderer-hydration.js.map +1 -1
- package/dist/development/vera-renderer-portal.js +1 -1
- package/dist/development/vera-renderer-portal.js.map +1 -1
- package/dist/development/vera-renderer-profiler.d.ts.map +1 -1
- package/dist/development/vera-renderer-profiler.js +304 -97
- package/dist/development/vera-renderer-profiler.js.map +1 -1
- package/dist/development/vera-renderer-slots.js +1 -1
- package/dist/development/vera-renderer-slots.js.map +1 -1
- package/dist/development/vera-renderer-spread.js.map +1 -1
- package/dist/development/vera-renderer-tag.js.map +1 -1
- package/dist/development/vera-renderer.d.ts.map +1 -1
- package/dist/development/vera-renderer.js +304 -97
- package/dist/development/vera-renderer.js.map +1 -1
- package/dist/vera-renderer-elements.min.js.map +1 -1
- package/dist/vera-renderer-hydrate-slots.min.js +1 -1
- package/dist/vera-renderer-hydrate-slots.min.js.map +1 -1
- package/dist/vera-renderer-hydration.min.js +1 -1
- package/dist/vera-renderer-hydration.min.js.map +1 -1
- package/dist/vera-renderer-portal.min.js +1 -1
- package/dist/vera-renderer-portal.min.js.map +1 -1
- package/dist/vera-renderer-slots.min.js +1 -1
- package/dist/vera-renderer-slots.min.js.map +1 -1
- package/dist/vera-renderer-spread.min.js.map +1 -1
- package/dist/vera-renderer-tag.min.js.map +1 -1
- package/dist/vera-renderer.min.js +1 -1
- package/dist/vera-renderer.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vera-renderer-slots.min.js","sources":["../../shared-utils/src/diagnostic.ts","../../shared-utils/src/markup-grammar.ts","../src/elements.ts","../../shared-utils/src/utils.ts","../src/slots.ts","../src/kinds.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 { 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 * **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 * **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 ` ` 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","/**\n * **`@verajs/renderer/elements` — attach behavior to elements in templates.**\n *\n * ```js\n * const autofocus = { mount: (element) => element.focus() };\n * wire([renderer, elements, { on: 'element', fn: (el) => (el.hasAttribute('autofocus') ? autofocus : undefined) }]);\n * ```\n *\n * Every `'element'` claimant is asked about each element of a template ONCE, as the template is BUILT — on its\n * canonical content, so a tag and its static attributes are real and no binding is ever applied (a hydrated first\n * instance, whose elements are the server's with bound values in them, changes nothing). The answers are two flat\n * lists shared by every instance: element positions in document pre-order, and their behaviors. A template nobody\n * claimed anything in gets no instance hook at all. Each instance finds its claimed elements with one short walk to\n * those positions; once the render that created it has finished, each behavior's `mount` runs, and what it returns is\n * handed to `unmount` at teardown. Nothing runs per update.\n *\n * Built on the renderer's `'template'` insert and instance hook (`InstanceHook`); it imports nothing — the registry\n * arrives through its connector. An app that does not wire it pays nothing.\n */\nimport type { ElementBehavior, InstanceHook } from './types.js';\nimport { diagnostic, hostOf, reportTo } from '@verajs/shared-utils';\nimport { PROSE } from './elements-diagnostics.js';\n\ntype Claim = (element: Element) => ElementBehavior | undefined;\n\nlet registered: Map<string, unknown[]> | null = null;\n\n/**\n * **A claim's callbacks follow the ref rule** (Brian, 2026-10-09): user code a render calls is caught AT ITS CALL SITE\n * — so a template with no claims runs exactly the path it did — reported to the app's `'error'` chain with the\n * component it belongs to (else as uncaught), and the render, the other claims and the teardown carry on. A mid-commit\n * throw once left a component's root empty for good; `mount` propagating aborted every later claim's mount.\n */\nconst report = (error: unknown, root: Node | null, line: string) => reportTo(registered?.get('error'), error, hostOf(root), line);\n\n/**\n * **The next element of an instance in document pre-order, never leaving it.** A root is a fragment, or — for a\n * single-root template — its one element, which is then position 0. Bounded by the root rather than by the tree it\n * sits in, because a hydrated instance is already in the page.\n */\nconst firstIn = (root: Node): Element | null => (root.nodeType === 1 ? (root as Element) : (root as ParentNode).firstElementChild);\nconst nextIn = (node: Element, root: Node): Element | null => {\n if (node.firstElementChild !== null) return node.firstElementChild;\n for (let at: Element | null = node; at !== null && at !== root; at = at.parentElement)\n if (at.nextElementSibling !== null) return at.nextElementSibling;\n return null;\n};\n\n/**\n * One instance's claims until it mounts — its claimed elements and their behaviors, interleaved, where it rendered,\n * whether it was adopted — and then only what `unmount` needs. **The elements are released at mount**: per-instance\n * state that keeps DOM references past the moment it needs them costs every operation on the page (measured: ~7% on\n * select and swap of a table whose every row was claimed, operations that never touch it).\n */\ntype State = { f: (Element | ElementBehavior)[] | null; r: Node | null; a: boolean; k: unknown[] | undefined; d: boolean };\n\n/** The instance hook for one template, from the positions and behaviors its claimants answered. */\nconst hookFor = (positions: number[], behaviors: ElementBehavior[]): InstanceHook => ({\n $c: (instance, root, adopted) => {\n const found: (Element | ElementBehavior)[] = [];\n /**\n * ADOPTED, the instance arrives as its elements in template order (hydration pairs them): its live root already\n * holds what its nested parts rendered, so counting there would land on the wrong element.\n */\n const listed = Array.isArray(instance);\n let node = listed ? null : firstIn(instance as Node);\n let at = 0;\n for (let k = 0; k < positions.length; k++) {\n if (listed) node = (instance as readonly Element[])[positions[k]];\n else for (; at < positions[k]; at++) node = nextIn(node!, instance as Node);\n /**\n * At creation — before the first update, and before the instance is connected anywhere. A claim whose `create`\n * throws is reported and DROPPED for this instance (it never mounts or unmounts, being half made); the element\n * stays as the template built it — a claim inserts nothing — and every other claim carries on. The ref rule.\n */\n try {\n behaviors[k].create?.(node!, adopted);\n } catch (error) {\n report(error, root, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('create', 'the render continued without it')) : '[vera] claim-threw');\n continue;\n }\n found.push(node!, behaviors[k]);\n }\n return { f: found, r: root, a: adopted, k: undefined, d: false } as State;\n },\n $m: (given) => {\n const state = given as State;\n /** Torn down before its render finished: it never mounts. */\n if (state.d) return;\n const found = state.f!;\n const context = { root: state.r, adopted: state.a };\n state.f = null;\n for (let i = 0; i < found.length; i += 2) {\n const behavior = found[i + 1] as ElementBehavior;\n let value;\n try {\n value = behavior.mount?.(found[i] as Element, context);\n } catch (error) {\n report(error, state.r, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('mount', 'the others still mounted')) : '[vera] claim-threw');\n continue;\n }\n if (value !== undefined && behavior.unmount !== undefined) (state.k ??= []).push(found[i], behavior, value);\n }\n },\n $q: (given) => {\n const state = given as State;\n state.d = true;\n const kept = state.k;\n if (kept !== undefined)\n for (let i = 0; i < kept.length; i += 3)\n try {\n (kept[i + 1] as ElementBehavior).unmount!(kept[i + 2], kept[i] as Element);\n } catch (error) {\n report(error, state.r, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('unmount', 'the rest of the teardown ran')) : '[vera] claim-threw');\n }\n },\n});\n\n/**\n * Asks the claimants about the template's canonical content, once, as it is built — and gives it an instance hook\n * only if something was claimed. The content is READ, never changed (see the `'template'` insert's contract).\n */\nconst claimTemplate = (built: object, _result: unknown, _readScope: unknown, root: Node) => {\n const claims = registered?.get('element') as Claim[] | undefined;\n if (claims === undefined || claims.length === 0) return;\n const template = built as { _$inst$?: InstanceHook };\n if (__DEV__ && template._$inst$ !== undefined)\n console.warn(diagnostic('elements', 'template', 'elements-hook-replaced', __DEV__ && PROSE['elements-hook-replaced']()));\n const positions: number[] = [];\n const behaviors: ElementBehavior[] = [];\n let at = 0;\n for (let node = firstIn(root); node !== null; node = nextIn(node, root), at++)\n for (let i = 0; i < claims.length; i++) {\n const behavior = claims[i](node);\n if (behavior !== undefined) {\n positions.push(at);\n behaviors.push(behavior);\n }\n }\n if (positions.length > 0) template._$inst$ = hookFor(positions, behaviors);\n};\n\n/** Wire it as `wire([renderer, elements, …claims])`. A bare module: it has no options. */\nexport const elements = [\n (registry: Map<string, unknown[]>) => {\n registered = registry;\n },\n { name: '@verajs/renderer/elements', on: 'template' as const, fn: claimTemplate, priority: 10 },\n];\n\nexport type { ElementBehavior } from './types.js';\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 * **`@verajs/renderer/slots` — `<slot>` in a light-DOM component.** `wire([renderer, slots])`.\n *\n * A component that renders into its own element (no shadow root) gets the platform's slot assignment for the\n * children the page gave it: each light child goes to the first `<slot>` of its `slot` name (the default slot for\n * text and unnamed elements), a slot with nothing assigned shows its own content (the fallback), and comments are\n * never assigned.\n *\n * **The renderer knows nothing of it.** A host's light children are divided into UNITS: each static child alone, and\n * each run a binding of the page's template wrote (its markers and everything between them) whole. A unit moves as\n * one piece — never split — so every write the renderer later makes inside it lands where the unit now is, and the\n * renderer's own range stays contiguous. While a `<slot>` has content, the element steps out of the page and its\n * content stands in its place, between this module's two comments; with none, the element is back, showing its\n * fallback. What the page's template later does inside a unit is seen by a `MutationObserver` and re-distributed —\n * synchronously after every component render (core's `'render'` insert), and at the latest by the next microtask.\n */\nimport { diagnostic, isCustomElementName, SHARED, warnOnce } from '@verajs/shared-utils';\nimport { PROSE } from './slots-diagnostics.js';\nimport { elements } from './elements.js';\nimport { PROTOCOL } from './kinds.js';\n\n/** A slot's assignment name: an element's `slot` attribute, `''` for text; a comment is never slottable. */\nconst slotNameOf = (node: Node): string | null =>\n node.nodeType === 3 ? '' : node.nodeType === 1 ? ((node as Element).getAttribute('slot') ?? '') : null;\n\n/**\n * A light unit: a static child the page wrote (`a === z`), which moves as itself; or a RUN one of its template's\n * bindings writes, between this module's own two comments, which never leaves holding — the renderer walks it there,\n * contiguous, and each node of it a slot takes leaves a STAND-IN comment at its place. Every light node goes to the\n * slot its own `slot` names, exactly as the platform assigns.\n */\ntype Unit = { a: Node; z: Node };\n/** One `<slot>` of a light host: while it has content, `rs`/`re` stand in its place and the element is out. */\ntype Rec = { slot: Kept; light: Light; rs: Comment | null; re: Comment | null; shown: Node[]; queued: boolean };\n/** `_$region$`: a filled slot's region handed over before it mounts — by hydration, the server's two markers. */\ntype Kept = HTMLSlotElement & { $rec?: Rec; _$region$?: [Comment, Comment] };\n\n/** A host's light children, by unit, in the order the page wrote them, and its slots. */\n/**\n * `wait`: captured by a template that placed runs into this host during hydration, before the host's own slots exist —\n * nothing distributes until the first of them mounts, so the nodes stay exactly where the server put them.\n */\ntype Light = { host: Element; units: Unit[]; holding?: HTMLElement; recs: Rec[]; dirty: boolean; fresh: boolean; late: boolean; wait: boolean; obs?: MutationObserver; ex?: boolean; hw?: boolean; ho?: boolean; cw?: boolean; hh?: boolean };\n\n/**\n * **Unassigned content stays CONNECTED, as under native slots** — it waits in `<ins hidden data-vm-unassigned>`, the\n * host's first child, rather than out of the page: a component in it keeps running, and assigning or unassigning it is a\n * one-op connected move, which core keeps alive. The container is in the host exactly while it holds a light node —\n * runs' markers and stand-ins are comments, which need no connection — so a host with nothing unassigned has no extra\n * child, and the server, which knows only nodes, emits the same element in the same place.\n *\n * **Why `<ins>`** (Brian, 2026-10-08), measured in all three engines: a standard element, so it is valid HTML and\n * `:defined` (the carrier was `<vm-unassigned>`, a dashed name nothing defined, which discovery loaders tried to import\n * and \"wait until everything is defined\" checks waited on forever); its content model is TRANSPARENT, so it is valid\n * around whatever it holds (a `<span>` holding a `<section>` is not); and it parses inside a `<p>` where a `<div>` would\n * close the paragraph and eject the host's content. It is known by its attribute: a user's own `<ins>` is light content\n * like any other.\n */\nconst UNASSIGNED = 'data-vm-unassigned';\n/** Into the page before a light node moves in, so the move is connected → connected. */\nconst park = (light: Light) => {\n const holding = holdingOf(light);\n if (holding.parentNode !== light.host) light.host.insertBefore(holding, light.host.firstChild);\n watchHolding(light);\n return holding;\n};\n/**\n * At the end of every pass: in the page exactly while it holds a light node — out once only comments remain, and IN if\n * the renderer wrote a new node straight into a run waiting here while it was out (that node's first connection).\n */\nconst unpark = (light: Light) => {\n const holding = light.holding;\n if (holding === undefined) return;\n for (let node = holding.firstChild; node !== null; node = node.nextSibling) if (node.nodeType !== 8) return void park(light);\n holding.remove();\n};\n\n/**\n * **Each host's light, kept ON the host** — under this module copy's own `Symbol` (2026-10-17, candidate B): every\n * component's render end asks whether its container has a light (`_$done$`), and for one that does not — a plain\n * component — that is now a missing-property read, never a WeakMap lookup. Only a host that gets a light carries the\n * field; host → light → host is a DOM↔JS cycle, so `release` clears it. The same get/has/set/delete surface as the\n * WeakMap it replaces, so hydrate-slots, handed it through the protocol, is unchanged.\n */\nconst LIGHT = Symbol();\ntype Lit = Element & { [LIGHT]?: Light };\nconst HOSTS = {\n get: (host: Element) => (host as Lit)[LIGHT],\n has: (host: Element) => (host as Lit)[LIGHT] !== undefined,\n set: (host: Element, light: Light) => {\n (host as Lit)[LIGHT] = light;\n },\n delete: (host: Element) => {\n (host as Lit)[LIGHT] = undefined;\n },\n};\n/** The static children an outer template gave a host, recorded when its instance was created (see `hostBehavior`). */\nconst STATICS = new WeakMap<Element, Set<Node>>();\n/** A run's node in a slot, and the comment holding its place in the run — both ways. */\nconst STAND = new WeakMap<Node, Comment>();\nconst REAL = new WeakMap<Node, Node>();\n/** The slot a light node was placed in (`null`: holding). */\nconst PLACED = new WeakMap<Node, Rec | null>();\n/**\n * A light node CAPTURED WHERE IT STANDS — outside the host, in a slot's region (the server put it there) — before that\n * slot has mounted: where it is, it stays. Slots mount one at a time, and a node waiting for a later one would otherwise\n * read as taken away (see `isWhere`).\n */\nconst ADOPTED = {} as Rec;\n\n/** The host's light children in the order the page wrote them — a run read through its stand-ins. */\nconst lightOf = (light: Light): Node[] => {\n const out: Node[] = [];\n for (const unit of light.units) {\n if (unit.a === unit.z) out.push(unit.a);\n else for (let node = unit.a.nextSibling; node !== null && node !== unit.z; node = node.nextSibling) out.push(REAL.get(node) ?? node);\n }\n return out;\n};\n/** A stand-in is dropped: its node is no longer in a slot (back at its place, or gone). */\nconst unstand = (node: Node) => {\n const stand = STAND.get(node);\n if (stand === undefined) return;\n STAND.delete(node);\n REAL.delete(stand);\n stand.remove();\n};\n\n/**\n * **Where a light node physically is.** A `<slot>` can itself be a light child of another host — slot FORWARDING — and\n * while it has content it is out of the page, its content standing in its place between its two comments: that range is\n * where the node is, and moving the node moves the range.\n */\nconst firstOf = (node: Node): Node => (node as Kept).$rec?.rs ?? node;\nconst lastOf = (node: Node): Node => (node as Kept).$rec?.re ?? node;\n/** A light node moved before `ref` in `parent` — the whole range of a forwarded slot that is out of the page. */\nconst move = (parent: Node, node: Node, ref: Node | null) => {\n const last = lastOf(node);\n for (let at: Node | null = firstOf(node); at !== null; ) {\n const next: Node | null = at === last ? null : at.nextSibling;\n parent.insertBefore(at, ref);\n at = next;\n }\n};\n\n/** A run's node that sits in a slot, its place in the run held by a comment before `ref` in `parent` — both ways. */\nconst standIn = (node: Node, parent: Node, ref: Node | null) => {\n const stand = node.ownerDocument!.createComment('');\n parent.insertBefore(stand, ref);\n STAND.set(node, stand);\n REAL.set(stand, node);\n};\n\n/** A light node back to holding: a run's node to its place in the run (where its stand-in is), any other to the end. */\nconst toHolding = (light: Light, node: Node) => {\n const stand = STAND.get(node);\n if (stand !== undefined) {\n move(park(light), node, stand);\n unstand(node);\n PLACED.delete(node);\n } else {\n move(park(light), node, light.holding!.lastChild);\n PLACED.set(node, null);\n }\n};\n\n/* ── tree order, through slots that are out of the page ────────────────────────────────────────── */\n\n/**\n * The positions that decide a slot's tree order: its own (its element, or the comment standing in its place), and,\n * while it sits inside another slot's element that is OUT of the page (a displaced fallback), that slot's position\n * first. `null` when the chain ends outside the host — a slot parked away by `hold`, which takes part in nothing.\n */\nconst chain = (rec: Rec): Node[] | null => {\n const out: Node[] = [];\n let node: Node = rec.rs ?? rec.slot;\n for (;;) {\n out.unshift(node);\n if (rec.light.host.contains(node)) return out;\n let root: Node = node;\n while (root.parentNode !== null) root = root.parentNode;\n const outer = (root as Kept).$rec;\n if (outer === undefined || outer.rs === null) return null;\n node = outer.rs;\n }\n};\n/** Whether `b` comes after `a` in tree order — the platform's `DOCUMENT_POSITION_FOLLOWING` bit. */\n// eslint-disable-next-line no-bitwise -- compareDocumentPosition answers in the platform's own bitmask\nconst follows = (a: Node, b: Node) => (a.compareDocumentPosition(b) & 4) !== 0;\nconst before = (x: Node[], y: Node[]) => {\n for (let i = 0; i < x.length && i < y.length; i++)\n if (x[i] !== y[i]) return follows(x[i], y[i]);\n return x.length < y.length;\n};\n\n/* ── distribution ──────────────────────────────────────────────────────────────────────────────── */\n\n/**\n * **A filled slot's region is bounded by two comments, spelled the same on both sides.** The client creates them here;\n * the server writes exactly them (`@verajs/ssr`), so a server-rendered host and a client-distributed one are the\n * same DOM down to comment data, and hydration ADOPTS the server's instead of creating its own. Measured 2026-10-07:\n * that end state hydrates faster than any marking that makes the client split text and create markers (Chrome −11%,\n * Firefox −37%, WebKit −9% on a worst case), and it needs no counting, so nothing depends on how the browser decodes\n * text. The data carries no slot name or index: pairing is positional, and a name could close the comment.\n */\nconst RANGE_START = '[';\nconst RANGE_END = ']';\n\nconst region = (rec: Rec) => {\n if (rec.rs !== null) return;\n const doc = rec.slot.ownerDocument;\n const parent = rec.slot.parentNode!;\n rec.rs = doc.createComment(RANGE_START);\n rec.re = doc.createComment(RANGE_END);\n parent.insertBefore(rec.rs, rec.slot);\n parent.insertBefore(rec.re, rec.slot);\n /** `removeChild`, never `remove()`: a kept slot's own `remove()` is the USER's (it unregions first, `removeSlot`). */\n parent.removeChild(rec.slot);\n watch(parent, rec.light);\n};\nconst unregion = (rec: Rec) => {\n if (rec.rs === null) return;\n rec.rs.parentNode?.insertBefore(rec.slot, rec.rs);\n rec.rs.remove();\n rec.re!.remove();\n rec.rs = rec.re = null;\n};\n/** What a slot shows goes back to holding, and the slot back in its place: every way a slot leaves runs this. */\nconst unplace = (rec: Rec) => {\n for (const node of lightOf(rec.light)) if (PLACED.get(node) === rec) toHolding(rec.light, node);\n unregion(rec);\n};\n/** The slot leaves its host's list of slots. */\nconst unlist = (rec: Rec) => rec.light.recs.splice(rec.light.recs.indexOf(rec), 1);\n\n/** `slotchange`, as the platform fires it: once per slot per change, after the change, on the slot element. */\nconst changed = (rec: Rec) => {\n if (rec.queued) return;\n rec.queued = true;\n queueMicrotask(() => {\n rec.queued = false;\n rec.slot.dispatchEvent(new (rec.slot.ownerDocument.defaultView!.Event)('slotchange', { bubbles: true, composed: false }));\n });\n};\n\n/**\n * Whether a node is in this host's holding or one of its slots' regions — or where the server put it (`ADOPTED`), which\n * holds until its slot mounts, as `isWhere` holds a static: a slot mounting first must not read the run's node in a\n * later slot's served region, not yet registered, as taken.\n */\nconst inLight = (node: Node, light: Light): boolean => {\n if (PLACED.get(node) === ADOPTED) return true;\n const parent = node.parentNode;\n if (parent === null) return false;\n if (parent === light.holding) return true;\n for (const rec of light.recs) if (rec.re !== null && rec.re.parentNode === parent) return true;\n return false;\n};\n/** Whether a light node is still where this module put it — false once something else took it (the user's adoption stands). */\nconst isWhere = (node: Node, light: Light): boolean => {\n const rec = PLACED.get(node);\n if (rec === ADOPTED) return true;\n const parent = firstOf(node).parentNode;\n if (rec === undefined) return parent === light.holding;\n /** `PLACED` is shared by every host: a node another host has placed is not this one's, wherever it sits. */\n return rec === null ? parent === light.holding : rec.light === light && parent !== null && parent === rec.re?.parentNode;\n};\n\n/**\n * **Every light node to its slot, in light order** — the whole decision, recomputed. A node something else took away\n * is forgotten first; then each name's first slot in tree order wins, its nodes go between its comments (a run's node\n * leaving a stand-in at its place), a slot left with nothing shows its fallback, and the rest wait in holding.\n */\n/**\n * A distribution in progress can render (a slotted component moved is reconnected, and renders): the render's end asks\n * for another, which waits for this one to finish and then runs.\n */\nlet busy = false;\nconst distribute = (light: Light) => {\n if (busy) {\n /**\n * Unreached outside the work set in every suite (18 hits, all already marked — a first connection is a fresh capture);\n * kept because the invariant requires a dirty light in work, and redundancy here is not proven. Unlike `settleIn`'s\n * mark (removed: its only caller marks first), this one is equivalent by observation only.\n */\n mark(light);\n return;\n }\n busy = true;\n try {\n do place(light);\n while (light.dirty);\n } finally {\n busy = false;\n }\n};\nconst place = (light: Light) => {\n light.dirty = false;\n /**\n * **THE INVARIANT: a slotted node moves in ONE DOM operation, connected → connected.** Core tells a move from a removal\n * by `isConnected` at `disconnectedCallback` (the platform runs it after the operation), so one `insertBefore` from\n * where the node is to where it goes keeps a slotted component alive; a hop through holding (a fragment) is a real\n * disconnect, and the component is torn down and set up again. `tests/core-keep-alive.test.mjs` pins it.\n *\n * **Captured and not yet distributed: placed straight from the host.** A node a slot takes moves host → slot in ONE\n * operation, which the platform — and core — see as a move, not a removal (`isConnected` stays true through it): a\n * slotted component is not torn down and set up again. Only what no slot takes, and a run's own markers, go to holding.\n */\n const fresh = light.fresh;\n /**\n * Parked only when the render ENDS (`ending`): its slots have all mounted by then, so a node no slot took really has\n * none. Parked earlier — at the first slot's mount — a node for a later slot would hop host → holding → slot, two\n * operations, and be torn down and set up again on the way.\n */\n /**\n * **What clears `fresh`: only a render that ENDS** (`_$done$`, after the commit). A first render that THROWS out of\n * `renderInto` skips it, and the host stays fresh — its captured children still where the page put them, its runs\n * still in the host — until a render completes. That is consistent, not stale: a failed commit mounts no slot (mounts\n * run at a render's end), so no region exists for `inRun` to misread, and a user's edit meanwhile is an ordinary\n * host record (`adopt`). Pinned in `tests/renderer-slots.test.mjs`.\n */\n if (ending) light.fresh = false;\n const host = light.host;\n /** Re-read, never a copy: holding is built at its first use (`holdingOf`), possibly during this pass. */\n const home = (node: Node) => firstOf(node).parentNode === light.holding || (fresh && firstOf(node).parentNode === host);\n light.units = light.units.filter((unit) => (unit.a === unit.z ? isWhere(unit.a, light) || (fresh && firstOf(unit.a).parentNode === host) : home(unit.a) && home(unit.z)));\n for (const unit of light.units)\n if (unit.a !== unit.z)\n for (let node = unit.a.nextSibling; node !== null && node !== unit.z; node = node.nextSibling) {\n const real = REAL.get(node);\n /** The renderer moves a run's nodes between this host's slots (beside a neighbor it follows); only leaving them all is a theft. */\n if (real !== undefined && !inLight(real, light)) {\n PLACED.delete(real);\n unstand(real);\n }\n }\n const live: { rec: Rec; at: Node[] }[] = [];\n /** A slot parked away (by `hold`) takes part in nothing — and what it shows waits with it, untouched. */\n const parked = new Set<Rec>();\n for (const rec of light.recs) {\n const at = chain(rec);\n if (at !== null) live.push({ rec, at });\n else parked.add(rec);\n }\n live.sort((x, y) => (before(x.at, y.at) ? -1 : 1));\n const winner = new Map<string, Rec>();\n for (const { rec } of live) {\n const name = rec.slot.getAttribute('name') ?? '';\n if (!winner.has(name)) winner.set(name, rec);\n }\n const nodes = lightOf(light);\n /** A static child moves as itself; only a node of a binding's RUN leaves a stand-in at its place. */\n const statics = new Set<Node>();\n for (const unit of light.units) if (unit.a === unit.z) statics.add(unit.a);\n const wanted = new Map<Rec, Node[]>();\n const taken = new Set<Node>();\n for (const node of nodes) {\n const name = slotNameOf(node);\n const rec = name === null ? undefined : winner.get(name);\n if (rec === undefined) continue;\n let list = wanted.get(rec);\n if (list === undefined) wanted.set(rec, (list = []));\n list.push(node);\n taken.add(node);\n }\n for (const { rec } of live) {\n const mine = wanted.get(rec) ?? [];\n if (mine.length > 0) {\n region(rec);\n const parent = rec.re!.parentNode!;\n /** Only what is out of place moves: a move disconnects and reconnects a component, re-running its lifecycle. */\n let previous: Node = rec.rs!;\n for (const node of mine) {\n const first = firstOf(node);\n if (first.parentNode === parent && first.previousSibling === previous) {\n previous = lastOf(node);\n continue;\n }\n /** A run's node, still at its place in holding: a stand-in takes the place before it leaves. */\n if (!statics.has(node) && home(node) && !STAND.has(node)) standIn(node, first.parentNode!, first);\n move(parent, node, previous.nextSibling);\n /** Marked as moved by slots: the renderer follows it here when it inserts beside it (see `into`). */\n (node as Node & { _$slotted$?: boolean })._$slotted$ = true;\n PLACED.set(node, rec);\n previous = lastOf(node);\n }\n }\n if (mine.length !== rec.shown.length || mine.some((node, i) => node !== rec.shown[i])) {\n rec.shown = mine;\n changed(rec);\n }\n }\n for (const node of nodes) {\n if (taken.has(node)) continue;\n const rec = PLACED.get(node);\n if (rec !== undefined && rec !== null && parked.has(rec)) continue;\n /** Adopted and waiting for its slot, which mounts later in the same render: it stays where the server put it. */\n if (rec === ADOPTED && !ending) continue;\n if (STAND.has(node) || (rec !== undefined && rec !== null) || (ending && statics.has(node) && node.parentNode === host)) toHolding(light, node);\n }\n /** A run captured in the host goes to holding now — its markers, stand-ins and unassigned nodes; its slotted nodes left in one move each. */\n if (fresh && ending)\n for (const unit of light.units)\n if (unit.a !== unit.z && unit.a.parentNode === host) {\n const run: Node[] = [];\n for (let node: Node | null = unit.a; node !== null; node = node.nextSibling) {\n run.push(node);\n if (node === unit.z) break;\n }\n const holding = holdingOf(light);\n for (const node of run) (node.nodeType === 8 ? holding : park(light)).insertBefore(node, holding.lastChild);\n watchHolding(light);\n }\n for (const { rec } of live) if (!wanted.has(rec)) unregion(rec);\n unpark(light);\n};\n\n/* ── the observer: what the page's templates (and the user) do afterwards ─────────────────────── */\n\n/**\n * **An observer per light** — never one shared by every host: Gecko's `observe()` is linear in what that observer\n * already watches, removed nodes included, through collections (2000 observes 4 → 45 ms over ten batches on one observer,\n * flat on a fresh one, flat on Chromium and WebKit), so a shared one made every new light host slower in Firefox without\n * end (2000 hosts: 262 → 9305 ms over eight renders that replaced them; flat now). A light's observer goes with it.\n *\n * From THIS module's own realm, which cannot close while its code runs — a MutationObserver watches nodes of another\n * document (measured on Chromium, Firefox and WebKit). Taking it from a host's window went deaf with that window: a\n * light host in an iframe or a popped-out window, closed later (`tests/browser/slots-realm.test.js`). The host's window\n * is the fallback only where this realm has no observer at all.\n */\nconst observerOf = (light: Light): MutationObserver => {\n const Observer = globalThis.MutationObserver ?? (light.host.ownerDocument.defaultView as typeof globalThis).MutationObserver;\n /**\n * Bound to their light (2026-10-17): a record can only reach a light through what THAT light registered, so it arrives\n * already knowing whose it is — no node → lights lookup, and no per-node bookkeeping (a WeakMap entry and a Set for every\n * watched node were ~164 ms of Chrome's slots creation at 10 000 hosts).\n */\n const handle = (records: MutationRecord[]) => {\n note(light, records);\n flush();\n };\n /**\n * ONE per light (2026-10-17; probe P3 vs P2: ~1 point of creation in each engine): its registrations are on distinct nodes —\n * the host's subtree for childList, each light element and slot for its attributes, holding and a fallback's region\n * parent for childList — so none replaces another's options, except a node both a light element and a slot (`own`).\n */\n return (light.obs ??= new Observer(handle));\n};\n/**\n * **A `hold()`-parked branch, watched while it is parked** — a slot's region in it is out of its host's subtree, where\n * the host's own attribute registration cannot see a node in it renamed (`slot=`): re-routed now, as native slots would.\n * One observer for every parked root (the renderer's `_$parked$`), registering the same root again when it parks again.\n */\nlet parkedObserver: MutationObserver | undefined;\n/** Each parked branch's owner — the container whose render parked it (a WeakMap on the parked root: parking is rare). */\nconst PARKED = new WeakMap<Node, Node>();\nconst parkedHandle = (records: MutationRecord[]) => {\n noteParked(records);\n flush();\n};\n/**\n * A light's pending records. A light in the work set (`all` false) is not asked while it has no childList registration\n * (its first render): its renames stay with the callback, and `takeRecords()` on every host every pass was ~114 ms of\n * Chrome's slots creation at 10 000 hosts (2026-10-17).\n */\nconst take = (light: Light, all = true): MutationRecord[] =>\n light.obs === undefined || (!all && light.ho !== true && light.cw !== true) ? [] : light.obs.takeRecords();\n/**\n * **This module's own moves, dropped** — what was pending before them was read at the start of the same pass. Nothing to\n * drop while the light has no childList registration (see `take`). A move never changes an attribute, so a rename found\n * here is someone else's (a moved element's `connectedCallback`): it marks its light and is followed after this pass.\n */\nconst drop = (light: Light) => {\n if (light.obs === undefined || (light.ho !== true && light.cw !== true)) return;\n for (const record of light.obs.takeRecords())\n if (record.type === 'attributes') {\n mark((record.target as Kept).$rec?.light ?? light);\n queueMicrotask(flush);\n }\n};\n/** A render is ending (the renderer's `_$done$`): captured children no slot took are parked now, not before. */\nlet ending = false;\n/** Records of this module's own moves, taken and dropped once it is done — they are not news. */\n/** How many nodes this batch has put ahead of everything, per host — so a batch's front insertions keep their order. */\nlet lead = new WeakMap<Light, number>();\n/** Whether THIS light watches `node` — its holding, a region's parent, one of its slots, or its host as a region parent. */\nconst watchedBy = (light: Light, node: Node) =>\n node === light.holding ||\n (node === light.host && light.hw === true) ||\n (node as Kept).$rec?.light === light ||\n light.recs.some((rec) => rec.re !== null && rec.re.parentNode === node);\n/**\n * The top of `node`'s tree as slots sees it: a FILLED slot has stepped out of the page, so from it the walk continues at\n * its region (where it stands in the page) — a slot in another slot's fallback is still the host's, though detached.\n */\nconst topOf = (node: Node) => {\n let at = node;\n for (;;) {\n const rec: Rec | undefined = (at as Kept).$rec;\n const up: Node | null = rec !== undefined && rec.rs !== null && rec.slot === at ? rec.rs : at.parentNode;\n if (up === null) return at;\n at = up;\n }\n};\n/** A slot the user removed: unmounted as the template's own teardown does, inside a flush (its records then dropped). */\n/** Whether `node` is the host's, walking through filled slots to where their regions stand. */\nconst insideHost = (node: Node, host: Element) => {\n for (let at: Node | null = node; at !== null; ) {\n if (at === host) return true;\n const rec: Rec | undefined = (at as Kept).$rec;\n at = rec !== undefined && rec.rs !== null && rec.slot === at ? rec.rs : at.parentNode;\n }\n return false;\n};\nconst handRemoved = (rec: Rec) => {\n unlist(rec);\n unplace(rec);\n mark(rec.light);\n};\n/**\n * A FILLED slot is not in the page (its region stands in its place), so its own `remove()` / `replaceWith()` cannot reach\n * what it shows: these put its content back to holding and the slot back in place first, then do what was asked — the\n * host's observer then finds it gone (`handRemoved`). ONE function each, shared by every slot (`this`, no closure).\n */\nfunction removeSlot(this: Kept) {\n const rec = this.$rec;\n if (rec !== undefined && rec.rs !== null) unplace(rec);\n (this.ownerDocument.defaultView as typeof globalThis).Element.prototype.remove.call(this);\n}\nfunction replaceSlot(this: Kept, ...nodes: (Node | string)[]) {\n const rec = this.$rec;\n if (rec !== undefined && rec.rs !== null) unplace(rec);\n (this.ownerDocument.defaultView as typeof globalThis).Element.prototype.replaceWith.apply(this, nodes);\n}\n/**\n * **A `<slot>` inserted BY HAND** (KNOWN fix, 2026-10-18): claimed as the template's own are, through `slotBehavior.mount`,\n * once the flush that found it is done (the mount flushes its light itself). Only a slot the component's template tree\n * holds counts: one inside the host's LIGHT content is light DOM, as natively it is no slot of this host.\n */\nlet claims: [HTMLSlotElement, Light][] = [];\n/**\n * Claimed in a MICROTASK, never inside the flush that found them: a template's own slot is found by the flush its own\n * `mount` begins with, BEFORE that mount gives it its record — claimed then, it was mounted twice (renderer-slots'\n * three-level chain). A microtask later every mount in progress has finished, and a template slot carries its record\n * (set once, never cleared), so only a slot no template made is claimed — a microtask later, the hand-edit rule.\n */\nlet claimQueued = false;\nconst findSlots = (light: Light, node: Node) => {\n if (node.nodeType !== 1) return;\n const element = node as Element;\n if (element.localName === 'slot') {\n if ((element as Kept).$rec === undefined) claims.push([element as HTMLSlotElement, light]);\n return;\n }\n /** Descendants only when there are any: the template's own small writes (a swapped `<i>`) stay one property read. */\n if (element.firstElementChild === null) return;\n const found = element.getElementsByTagName('slot');\n for (let i = 0; i < found.length; i++) if ((found[i] as Kept).$rec === undefined) claims.push([found[i] as HTMLSlotElement, light]);\n};\n/** Whether `slot` sits in the component's own tree — not inside a light node this module placed or holds. */\nconst ofTemplate = (slot: Node, light: Light) => {\n for (let at = slot.parentNode; at !== null; at = at.parentNode) {\n if (at === light.host) return true;\n if (at === light.holding || PLACED.has(at)) return false;\n }\n return false;\n};\nconst claimInserted = () => {\n claimQueued = false;\n const pending = claims;\n claims = [];\n for (const [slot, light] of pending)\n if ((slot as Kept).$rec === undefined && HOSTS.get(light.host) === light && ofTemplate(slot, light)) slotBehavior.mount(slot, { root: light.host });\n};\n/** The batch's added nodes, looked through for a hand-inserted slot — a pass of its own, so `note` stays small. */\nconst scanAdded = (light: Light, records: MutationRecord[]) => {\n for (const record of records) {\n if (record.type !== 'childList') continue;\n /** Read once: `addedNodes` is a DOM getter. */\n const added = record.addedNodes;\n for (let i = 0, n = added.length; i < n; i++) findSlots(light, added[i]);\n }\n};\nconst note = (light: Light, records: MutationRecord[]) => {\n /** Only a component observed from its first render ('eager') follows a `<slot>` inserted by hand — a lazy one pays nothing. */\n if (light.ex === true) scanAdded(light, records);\n lead = new WeakMap();\n let removed = false;\n for (const record of records) {\n const target: Node = record.target;\n if (record.removedNodes.length > 0) removed = true;\n /** An attribute record names the element: a slot's own name, or a node under something this light watches. */\n if (record.type === 'attributes') {\n const rec = (target as Kept).$rec;\n if (rec !== undefined) {\n mark(rec.light);\n continue;\n }\n /** A light node's own `slot=` — acted on only while it is still THIS light's (a registration stays on a node that left). */\n if (inLight(target, light) || target.parentNode === light.host) mark(light);\n continue;\n }\n /**\n * A watched node's children — holding, a region's parent, a slot — replayed into the runs (the host too, when a region\n * sits directly in it). Any other target in the host's subtree is the component's own template writing: not slotting.\n */\n if (target === light.host ? light.hw === true : watchedBy(light, target)) {\n mark(light);\n replay(light, record);\n }\n /** A host's own children: an addition outside its render's range is a new light child. */\n if (target === light.host) {\n /**\n * Until its first render ends, a run still sits IN the host — so what the renderer takes from it there (a node a slot\n * already took, through its stand-in) is read back as it is in holding. Missed, the stand-in went and its node stayed\n * in the slot: a commit during the host's own render left the old content beside the new.\n *\n * **Why the REMOVED half is the whole of it** — the invariant: while the run is physically in the host, every node the\n * renderer ADDS here lands exactly where the run is, between its own markers, so it is already in place and\n * `lightOf` reads it there (nothing to move; replaying it as a run neighbor would move the render's own markers);\n * every change inside a slot's region — a row added beside a node a slot took (`into` follows `_$slotted$` there),\n * or removed from it — is recorded on that region's parent, which is watched, and replayed in full (into the run\n * where it is — the host, while fresh: see `replay`). What a host\n * record alone can carry is a REMOVED stand-in: the one change that leaves state behind (its node, still in a slot).\n * Additions here are otherwise the render's own or a new light child (`adopt`).\n */\n if (light.fresh) unrun(light, record);\n for (const node of record.addedNodes) adopt(light, node);\n }\n }\n /**\n * **A `<slot>` removed BY HAND** (KNOWN fix, 2026-10-18) — it, or its region, left the host with something the user\n * removed (the slot, its parent, an ancestor). The template's own teardown unmounts a slot before removing it, and a\n * `hold()`-parked one stays registered, so whatever is gone from the host otherwise was removed by hand: unmounted like\n * the template's, its content back to holding, as natively it is unassigned. Checked once per batch that removed\n * anything, over this light's slots.\n */\n if (removed) for (let i = light.recs.length - 1; i >= 0; i--) {\n const rec = light.recs[i];\n const anchor = rec.rs ?? rec.slot;\n if (!insideHost(anchor, light.host) && !PARKED.has(topOf(anchor))) handRemoved(rec);\n }\n};\n/**\n * A `hold()`-parked branch's renames (`parkedObserver`, one for every parked root): routed by the node's own marks — a\n * slot's light, a placed node's slot's light, or the host it sits in — since no per-node watcher list exists any more.\n */\nconst noteParked = (records: MutationRecord[]) => {\n for (const record of records) {\n /**\n * A write into a parked branch (an applier resolving into it, the outer template committing there): it has left its\n * host's subtree, so it is replayed for the host whose render parked it — and only while it is still out (restored, the\n * host's own registration sees it, and replaying it twice would place it twice).\n */\n if (record.type === 'childList') {\n let top: Node = record.target;\n while (top.parentNode !== null) top = top.parentNode;\n const owner = PARKED.get(top);\n const light = owner === undefined ? undefined : HOSTS.get(owner as Element);\n if (light !== undefined && !light.host.contains(record.target) && watchedBy(light, record.target)) {\n mark(light);\n replay(light, record);\n }\n continue;\n }\n for (let node: Node | null = record.target; node !== null; node = node.parentNode) {\n const own = (node as Kept).$rec ?? PLACED.get(node);\n if (own) {\n mark(own.light);\n break;\n }\n const light = HOSTS.get(node as Element);\n if (light !== undefined) {\n mark(light);\n break;\n }\n }\n }\n};\n/**\n * **The lights that need work** — dirty, or fresh until their first render ends, never one waiting for its own slots\n * (`wait`): the only ones `flush` visits. A set of EVERY light ever seen held each removed host for good (a leak) and\n * made every flush walk them all — hydrating 2000 light hosts slowed 72 → 365 ms over ten renders that replaced them.\n * A light leaves once it is clean, or clean and disconnected (a first render that threw stays fresh); it comes back\n * through `mark`, or its own render's end (`_$done$`).\n */\nconst work = new Set<Light>();\n/** The one way a light asks to be distributed. */\nconst mark = (light: Light) => {\n light.dirty = true;\n if (!light.wait) work.add(light);\n};\n/**\n * **Applies what is pending, now** — after every component render, and before any read of the assignment. It reads the\n * records of the lights it can name: its `context` (the light being read, mounted into, or rendered), every light whose\n * element the finished render's `root` created (`FED` — an outer template changing a component's children is\n * distributed by the end of that render), the work set, and the parked branches. Any other light's records arrive at the\n * microtask, through its own observer: a light host changed DIRECTLY by the page's code is redistributed by the next\n * microtask, or at once when its slotted content is read through the slots API (`tests/slots-sync-reads.test.mjs`).\n */\nconst flush = (context?: Light, root?: Node) => {\n if (busy) return;\n const near: Light[] = [];\n if (context !== undefined) near.push(context);\n const fed = root === undefined ? undefined : FED.get(root);\n if (fed !== undefined) {\n /** A plain loop, no closure: an arrow capturing `root` would tax every call of this function (CLAUDE.md, V8). */\n const kept: WeakRef<Element>[] = [];\n const rooted = root!.isConnected;\n for (let i = 0; i < fed.length; i++) {\n const element = fed[i].deref();\n if (element === undefined) continue;\n /**\n * A host that LEFT a connected root is dropped now, not at a collection: a churned list re-filtered an array growing\n * with every removed row until GC (2026-10-18). Put back by hand it is still followed — by its own observer from its\n * first slot (a microtask later; a slots-API read flushes it at once), or by its first slot's reconcile. A render\n * into a DETACHED root keeps every entry (nothing of it is connected). A host moved by hand to another, connected\n * root stays here, distributed at this root's renders too: bounded and harmless.\n */\n if (!element.isConnected && rooted) continue;\n kept.push(fed[i]);\n const light = HOSTS.get(element);\n if (light !== undefined) near.push(light);\n }\n FED.set(root!, kept);\n }\n /** Each light's records, read by that light (they arrive knowing whose they are), then the parked branches'. */\n for (const light of near) note(light, take(light));\n /**\n * The work set's NAME records stay with their callback: distribution reads `slot=` from the DOM as it is, so a rename is\n * only a trigger — and a light being READ (`near`: the slots API, a mount, its own render) takes them now, so a read\n * right after a rename is current (tests/slots-sync-reads.test.mjs). ChildList records are taken in order, always.\n */\n for (const light of work) note(light, take(light, false));\n if (parkedObserver !== undefined) noteParked(parkedObserver.takeRecords());\n for (const light of work) {\n if (light.dirty || (ending && light.fresh)) {\n distribute(light);\n drop(light);\n }\n if (!light.dirty && (!light.fresh || !light.host.isConnected)) work.delete(light);\n }\n /** What this module just moved, recorded on the lights it read: not news. */\n for (const light of near) drop(light);\n if (claims.length > 0 && !claimQueued) {\n claimQueued = true;\n queueMicrotask(claimInserted);\n }\n};\n/** Whether `node` sits outside the host's subtree registration — detached, or inside a slot (which steps out with its content). */\nconst outside = (node: Node, host: Element) => {\n for (let at: Node | null = node; at !== host; at = at.parentNode) if (at === null || (at as Kept).$rec !== undefined) return true;\n return false;\n};\nconst watch = (node: Node, light: Light) => {\n /** The host's own subtree registration covers it; a region directly in the host also gets the region's handling. */\n if (node === light.host) {\n light.hw = true;\n return;\n }\n const observer = observerOf(light);\n /**\n * A slot: its own name only. A slot with content steps OUT of the page, so this is how a rename reaches it there; a\n * nested slot in its fallback is claimed and registered on its own. Re-registering replaces the options, so a node that\n * is also this light's light element keeps `slot=` too (the union; `own`).\n */\n if ((node as Kept).$rec !== undefined) {\n observer.observe(node, { attributes: true, attributeFilter: mineAlready(node) ? ['slot', 'name'] : ['name'] });\n return;\n }\n /** Holding (out of the page while empty) and a region's parent inside a slot's fallback (out with that slot): on themselves. */\n if (node === light.holding || outside(node, light.host)) {\n light.cw = true;\n observer.observe(node, { childList: true });\n }\n};\n/** A light element's own `slot=` — registered when its light is first observed (`register`) and on every arrival after (`adopt`, `replay`, `settleIn`). */\nconst OWN = Symbol();\nconst mineAlready = (node: Node) => (node as Node & { [OWN]?: boolean })[OWN] === true;\nconst own = (light: Light, node: Node) => {\n /** Not before the light is observed (`register`, at its first slot), which registers every light element it has then. */\n if (node.nodeType !== 1 || light.ho !== true) return;\n (node as Node & { [OWN]?: boolean })[OWN] = true;\n observerOf(light).observe(node, { attributes: true, attributeFilter: (node as Kept).$rec !== undefined ? ['slot', 'name'] : ['slot'] });\n};\n\n/**\n * A node added to a host after its render: a light unit, appended in light order — unless it is the render's own. The\n * render's range runs from the host's first comment to its last that is not one of this module's units (captured\n * light children not yet distributed sit before it); comments are never slottable, so none is adopted.\n */\nconst adopt = (light: Light, node: Node) => {\n if (node.nodeType === 8 || node.parentNode !== light.host || node === light.holding) return;\n const ours = new Set<Node>();\n for (const unit of light.units) ours.add(unit.a).add(unit.z);\n if (ours.has(node)) return;\n let first: Node | null = null;\n let last: Node | null = null;\n for (const child of light.host.childNodes)\n if (child.nodeType === 8 && !ours.has(child)) {\n first ??= child;\n last = child;\n }\n if (first !== null && first !== last && follows(first, node) && follows(node, last!))\n return;\n /** Before the render's range is ahead of everything distributed away; after it, behind. Read before it moves. */\n const ahead = first !== null && follows(node, first);\n park(light).insertBefore(node, light.holding!.lastChild);\n PLACED.set(node, null);\n own(light, node);\n if (ahead) {\n const at = lead.get(light) ?? 0;\n light.units.splice(at, 0, { a: node, z: node });\n lead.set(light, at + 1);\n } else light.units.push({ a: node, z: node });\n mark(light);\n};\n\n/** Which unit a light node is in — its own, or (a run's node in a slot) the run its stand-in sits in. */\nconst unitIndexOf = (light: Light, node: Node): number => {\n const stand = STAND.get(node);\n if (stand === undefined) return light.units.findIndex((unit) => unit.a === node);\n return light.units.findIndex(\n (unit) => unit.a !== unit.z && follows(unit.a, stand) && follows(stand, unit.z)\n );\n};\n\n/**\n * A node the USER put inside a slot's region — `slotted.before(node)`, `after()`: a light unit of its own, at that\n * place in light order. (No `mark`: only `replay` reaches here, for a record `note` has already marked the light for.)\n */\nconst settleIn = (light: Light, node: Node) => {\n const parent = node.parentNode;\n if (parent === null || node.nodeType === 8) return;\n for (const rec of light.recs) {\n if (rec.re === null || rec.re.parentNode !== parent) continue;\n if (!follows(rec.rs!, node) || !follows(node, rec.re)) continue;\n let at = -1;\n for (let next = node.nextSibling; next !== null && next !== rec.re && at < 0; next = next.nextSibling) at = unitIndexOf(light, next);\n if (at < 0) light.units.push({ a: node, z: node });\n else light.units.splice(at, 0, { a: node, z: node });\n PLACED.set(node, rec);\n own(light, node);\n return;\n }\n};\n\n/**\n * **What the renderer wrote, read back into the runs.** A run's node in a slot is still the renderer's: an insert\n * before it (a new row), markers around it (a text becoming a template), its move or removal all happen where the\n * node now is. Each lands in the run at the place its neighbor's stand-in holds, so the run stays the renderer's\n * whole range; what has no such neighbor is the user's own edit.\n */\n/**\n * **What the renderer took away from a run, read back** — the removed half of `replay`: a stand-in it removed takes its\n * node with it (cleared with its run) or into the fragment `hold` parked it in; a run's node it removed from a slot drops\n * its place. Called on its own for a host's own records while its first render runs, when a run still sits in the host.\n */\nconst unrun = (light: Light, record: MutationRecord) => {\n /** A reader: nothing can be in a holding not yet built, so `undefined` compares false. */\n const holding = light.holding;\n for (const node of record.removedNodes) {\n const real = REAL.get(node);\n if (real !== undefined) {\n /**\n * A stand-in the renderer took: cleared with its run (its node goes too), or parked by `hold` in a fragment (its\n * node joins it). One the renderer MOVED — beside a node of the run that sits in a slot — is still the run's; its\n * addition, below, puts it back at its new place.\n */\n const parent = node.parentNode;\n if (parent === holding || (parent !== null && parent.nodeType !== 11)) continue;\n if (parent === null) real.parentNode?.removeChild(real);\n else parent.insertBefore(real, node);\n PLACED.delete(real);\n unstand(real);\n } else if (STAND.has(node) && node.parentNode === null) {\n /** A run's node the renderer removed from its slot (a row deleted): its place goes too. */\n PLACED.delete(node);\n unstand(node);\n }\n }\n};\n\nconst replay = (light: Light, record: MutationRecord) => {\n /** A writer (runs move into holding below): built before it is captured. */\n const holding = holdingOf(light);\n unrun(light, record);\n for (const node of record.addedNodes) {\n if (node.parentNode !== record.target) continue;\n if (record.target === holding) {\n /** Back in holding (the renderer moved it before a marker there): its own place now, not its stand-in's. */\n if (STAND.has(node)) {\n PLACED.delete(node);\n unstand(node);\n }\n /** A run's node written straight into holding (a row the outer template inserted) is a light node from now on. */\n own(light, node);\n continue;\n }\n if (PLACED.get(node) !== undefined && !STAND.has(node)) continue;\n const next = record.nextSibling;\n const previous = record.previousSibling;\n /** Where the runs are: holding — and, until the host's first render ends, the host, where a fresh run still sits. */\n const inRun = (node: Node) => node.parentNode === holding || (light.fresh && node.parentNode === light.host);\n const ahead = next === null ? undefined : (STAND.get(next) ?? (inRun(next) ? next : undefined));\n const behind = previous === null ? undefined : (STAND.get(previous) ?? (inRun(previous) ? previous : undefined));\n if (ahead === undefined && behind === undefined) {\n settleIn(light, node);\n continue;\n }\n const place = ahead ?? behind!.nextSibling;\n /**\n * A run's node moved within the page: its place in the run moves. New to the run: it joins it, at that place — in\n * whatever holds the run: holding, or (until its host's first render ends) the HOST itself, where a fresh run still\n * sits. Inserted into holding regardless, a node new to a fresh run threw there and was left in the slot unrecorded.\n */\n const stand = STAND.get(node);\n const run = place === null ? holding : place.parentNode!;\n (run === holding && stand === undefined ? park(light) : run).insertBefore(stand ?? node, place);\n own(light, node);\n }\n};\n\n/** A captured host that turned out to have a shadow root: its children go back, in light order, for the platform. */\nconst release = (light: Light) => {\n for (const unit of light.units) {\n if (unit.a === unit.z) {\n move(light.host, unit.a, null);\n continue;\n }\n for (let node = unit.a.nextSibling; node !== null && node !== unit.z; ) {\n const next = node.nextSibling;\n light.host.appendChild(REAL.get(node) ?? node);\n node = next;\n }\n }\n light.holding?.remove();\n HOSTS.delete(light.host);\n work.delete(light);\n /**\n * Its observer goes with it. Bound to its light, it would otherwise keep handling the host's records as this light's\n * — adopting the platform's own light children into a holding that no longer exists (renderer-slots' native-sequence\n * row, 2026-10-17). Before the binding, a released light's records were simply not found and dropped.\n */\n light.obs?.disconnect();\n light.obs = undefined;\n};\n\n\n/* ── capture ───────────────────────────────────────────────────────────────────────────────────── */\n\n/**\n * **A light's childList registrations, once its first render has ENDED** (observer redesign, 2026-10-17).\n * ONE over the host's subtree — its own children and every region and slot inside it: what native slotting reacts to,\n * wherever it sits, so a region's parent needs no registration of its own — and its holding (out of the page while empty).\n * Not before: the first render's own writes would make a record each for nothing (`reconcile` covers that window).\n * Attribute changes are registered per NODE (`own`, a slot's `name` in `watch`): one subtree attribute registration made\n * Firefox check every attribute write inside the host (−17.7% of light-slots creation).\n */\nconst register = (light: Light) => {\n if (light.ho === true) return;\n light.ho = true;\n observerOf(light).observe(light.host, { childList: true, subtree: true });\n for (const node of lightOf(light)) own(light, node);\n /**\n * A light with a RUN (a part an outer template writes into, for as long as the host lives) has its holding watched\n * from now — the run moves there, and is written into there, even while holding holds nothing else. One with static\n * light children only is watched once something is parked (`park`), or never.\n */\n if (\n /** `hydrate-slots` writes runs straight into holding and relies on it being watched (hydrate-slots.ts, \"holding is watched\"). */\n (wired as { _$hydrateSlots$?: unknown } | undefined)?._$hydrateSlots$ !== undefined ||\n light.units.some((unit) => unit.a !== unit.z) ||\n (light.holding?.childNodes.length ?? 0) > 2\n )\n watchHolding(light);\n};\n/**\n * **Holding, watched once anything lives in it** — a run's markers and stand-ins, or a parked node — since the outer\n * template keeps writing into a run there, in or out of the page. An empty holding (every light node took a slot) is\n * never written into, so it costs no registration (2026-10-17).\n */\nconst watchHolding = (light: Light) => {\n if (light.ho !== true || light.hh === true) return;\n light.hh = true;\n watch(holdingOf(light), light);\n};\n/**\n * **What changed while a light was not yet observed — its first render** — read off the DOM once, at that render's end\n * (3c): who made the change does not matter, the renderer or user code (a child's `connectedCallback`, a\n * directive). A stand-in gone takes its node with it, as `unrun` does for a removal record; a host child nothing knows\n * of is a light child added meanwhile (`adopt`) — unless it is the render's own (between its markers: `adopt` checks the\n * range), one of the captured units, or a member of a captured run.\n */\nconst reconcile = (light: Light) => {\n for (const rec of light.recs)\n for (const node of [...rec.shown]) {\n const stand = STAND.get(node);\n if (stand === undefined) continue;\n if (node.parentNode === null) {\n PLACED.delete(node);\n unstand(node);\n continue;\n }\n const parent = stand.parentNode;\n if (parent === null) node.parentNode.removeChild(node);\n else if (parent.nodeType === 11) parent.insertBefore(node, stand);\n else continue;\n PLACED.delete(node);\n unstand(node);\n }\n /**\n * A node written INTO a slot's region meanwhile — a keyed row inserted beside a slotted neighbor follows it there\n * (`into`) — is handed to `replay` as the record it would have been: its parent, itself, its neighbors now.\n */\n for (const rec of light.recs) {\n if (rec.rs === null || rec.re === null) continue;\n for (let node = rec.rs.nextSibling; node !== null && node !== rec.re; ) {\n const next = node.nextSibling;\n if (!PLACED.has(node) && node.nodeType !== 8)\n replay(light, { type: 'childList', target: rec.re.parentNode!, addedNodes: [node] as unknown as NodeList, removedNodes: [] as unknown as NodeList, previousSibling: node.previousSibling, nextSibling: node.nextSibling } as unknown as MutationRecord);\n node = next;\n }\n }\n const host = light.host;\n /** The render's range, once: its first and last comment that is not a captured unit's (as `adopt` reads it). */\n const ours = new Set<Node>();\n for (const unit of light.units) ours.add(unit.a).add(unit.z);\n let first: Node | null = null;\n let last: Node | null = null;\n for (let child = host.firstChild; child !== null; child = child.nextSibling)\n if (child.nodeType === 8 && !ours.has(child)) {\n first ??= child;\n last = child;\n }\n const ranged = first !== null && first !== last;\n for (const child of [...host.childNodes]) {\n if (child.nodeType === 8 || child === light.holding || ours.has(child) || PLACED.has(child)) continue;\n if (ranged && follows(first!, child) && follows(child, last!)) continue;\n if (light.units.some((unit) => unit.a !== unit.z && follows(unit.a, child) && follows(child, unit.z))) continue;\n adopt(light, child);\n }\n};\n/** A host's light record, new: its holding (bracketed by two comments, so `lastChild` is always an anchor), watched. */\n/**\n * **`node.assignedSlot`, answered for light slots** (Brian, 2026-10-18: race it). The platform's getter knows only shadow\n * roots; ONE getter replaces it on the prototypes that define it (the Slottable mixin: `Element`, `Text`), per window,\n * at that window's first light host. It answers from `PLACED` — what distribution already records, so nothing is written\n * per node — for a node this copy placed in a slot's region, and otherwise defers to the getter it replaced (native, or\n * another copy's), so shadow-DOM nodes and other copies answer as before. Never on a server: no window with these\n * prototypes, nothing installed.\n */\nconst PATCHED = Symbol();\nconst answerAssigned = (win: typeof globalThis) => {\n const marked = win as unknown as { [PATCHED]?: true };\n if (marked[PATCHED] === true) return;\n marked[PATCHED] = true;\n for (const proto of [win.Element?.prototype, win.Text?.prototype]) {\n const before = proto === undefined ? undefined : Object.getOwnPropertyDescriptor(proto, 'assignedSlot');\n const native = before?.get;\n /** Where the platform puts no getter of its own, nothing is defined there (development says so): never a fresh property. */\n if (native === undefined) {\n if (__DEV__ && proto !== undefined) console.warn(diagnostic('slots', 'assignedSlot', 'assigned-slot-unpatched', __DEV__ && PROSE['assigned-slot-unpatched'](proto === win.Text?.prototype ? 'Text' : 'Element')));\n continue;\n }\n Object.defineProperty(proto, 'assignedSlot', {\n configurable: true,\n enumerable: before!.enumerable,\n get(this: Node) {\n const rec = PLACED.get(this);\n return rec !== undefined && rec !== null && rec !== ADOPTED ? (rec as Rec).slot : native.call(this);\n },\n });\n }\n};\n/**\n * **Holding, built at its FIRST use** (2026-10-18): a host whose light children are all assigned never needs it, and\n * building it for every host was ~82 ms of Chrome's slotted creation at 10 000 hosts. Every WRITER goes through here;\n * readers compare against `light.holding`, which is simply `undefined` until then — nothing can be in it.\n */\nconst dress = (holding: HTMLElement) => {\n const doc = holding.ownerDocument;\n holding.setAttribute('hidden', '');\n holding.setAttribute(UNASSIGNED, '');\n /**\n * `hidden` is only the UA's `display: none`, and any author rule that sets `display` beats it — a reset, a design\n * system's `:where(*)`, a `[hidden]` override — and unassigned content would RENDER. An inline `!important` beats every\n * author stylesheet; written through CSSOM, which a strict CSP does not block (served markup carries `hidden` only).\n */\n holding.style.setProperty('display', 'none', 'important');\n holding.insertBefore(doc.createComment(''), holding.firstChild);\n holding.append(doc.createComment(''));\n return holding;\n};\nconst holdingOf = (light: Light): HTMLElement => (light.holding ??= dress(light.host.ownerDocument.createElement('ins')));\n/**\n * The capture hydration is handed: hydrate-slots writes a served host's runs straight into holding (and reads its\n * anchors), so a light captured through the protocol has its holding built at once — a client-only light builds it lazily.\n */\n/** The lights hydration reads: each with its holding built (it reads the anchors), whichever capture made it. */\nconst SERVED_HOSTS = {\n get: (host: Element) => {\n const light = HOSTS.get(host);\n if (light !== undefined) holdingOf(light);\n return light;\n },\n has: (host: Element) => HOSTS.has(host),\n};\nconst captureServed: typeof capture = (...args) => {\n const light = capture(...args);\n holdingOf(light);\n return light;\n};\nconst lightFor = (host: Element, late: boolean, carrier: HTMLElement | null = null): Light => {\n const doc = host.ownerDocument;\n const win = doc.defaultView as typeof globalThis | null;\n if (win !== null) answerAssigned(win);\n arm();\n /** The server's carrier, adopted at once; otherwise holding is built at its first use (`holdingOf`). */\n const light: Light = { host, units: [], holding: carrier === null ? undefined : dress(carrier), recs: [], dirty: false, fresh: false, late, wait: false };\n HOSTS.set(host, light);\n return light;\n};\n\n/**\n * **Capture**, at `init` — before the host's first render, when everything it holds is the page's. Each static child\n * is a unit; each run between statics (what the page's template bound there) is one unit, wrapped in this module's\n * two comments so its extent survives whatever the renderer writes inside it.\n *\n * `nodes` and `carrier` are hydration's (`_$capture$`): a served host's light children in light order, wherever the server\n * distributed them, and the server's unassigned container, which becomes the holding. A node captured in a slot's region\n * stays there (`ADOPTED`) — distribution then moves only what is out of place, so the server's placement decides at most\n * WHETHER a node moves, never where it ends up.\n */\nconst capture = (host: Element, before: Node | null = null, nodes: Node[] = [...host.childNodes], carrier: HTMLElement | null = null, wait = false): Light => {\n let light = HOSTS.get(host);\n /** A slot of a custom element `init` never saw mounted first: its light content arrives now, at the render's end. */\n if (light !== undefined && !light.late) return light;\n const doc = host.ownerDocument;\n light ??= lightFor(host, false, carrier);\n light.late = false;\n const statics = STATICS.get(host);\n let run: Node[] | null = null;\n /**\n * Recorded, not moved: the children stay where the page put them — in the host, as they would under a shadow root —\n * until the host's first render finishes, which distributes them (the ones no slot takes, invisibly to holding).\n */\n const close = () => {\n if (run === null) return;\n const a = doc.createComment('');\n const z = doc.createComment('');\n host.insertBefore(a, run[0]);\n host.insertBefore(z, run[run.length - 1].nextSibling);\n light!.units.push({ a, z });\n run = null;\n };\n for (const child of nodes) {\n /** At a first render's end, only what precedes the render's own range is light content. */\n if (child === before) break;\n const parent = child.parentNode;\n if (parent !== host) PLACED.set(child, parent === light.holding ? null : ADOPTED);\n own(light, child);\n if (statics === undefined || statics.has(child)) {\n close();\n light.units.push({ a: child, z: child });\n } else (run ??= []).push(child);\n }\n close();\n /**\n * `wait`: captured by a template that placed content into this host (hydration), not by the host — nothing is\n * distributed until the host's own slots mount, so a host never defined keeps its nodes where they stand.\n */\n if (wait) light.wait = true;\n else {\n light.fresh = true;\n mark(light);\n }\n return light;\n};\n\n/**\n * **A dashed element in a template is told it was created** — before the page's template commits into it — so the\n * children it has then are exactly its statics: a binding position is still the empty text the template parsed it\n * as. Recorded by node; `init` capture reads it.\n */\n/**\n * **Which elements each render root's templates created** — so that root's render end reads their lights' records too:\n * a host whose light children an OUTER template changed is distributed by the end of that render, synchronously, though\n * it has an observer of its own (Gecko's `observe()` is linear in its observer's registrations, so none is shared).\n * Weak both ways: a root or an element gone takes its entries with it, and a dead ref is dropped by the read itself.\n */\nconst FED = new WeakMap<Node, WeakRef<Element>[]>();\n/**\n * Only for a dashed element its TEMPLATE gives children (slot-discovery decides once per template, at preparation): no\n * outer template can write into one it gives none, so there is nothing to record — an app's list of `<x-row></x-row>`\n * paid a child scan and a Set per row at create, and a WeakRef per row in its root's `FED` at mount, which that root's\n * every render then filtered (wiring slots made such a list ~9× slower to create, 2026-10-17).\n */\nconst hostBehavior = {\n mount: (element: Element, { root }: { root: Node | null }) => {\n if (root === null) return;\n let fed = FED.get(root);\n if (fed === undefined) {\n arm();\n FED.set(root, (fed = []));\n }\n fed.push(new WeakRef(element));\n },\n create: (element: Element, adopted: boolean) => {\n if (adopted) return;\n const statics = new Set<Node>();\n let hole = false;\n for (const child of [...element.childNodes]) {\n const placeholder = child.nodeType === 3 && (child as Text).data === '';\n /**\n * Two bindings written back to back (`${a}${b}`) have nothing static between them, so their runs would join into\n * one unit: a comment of this module's goes between them — every binding is its own unit.\n */\n if (placeholder && hole) {\n const between = element.ownerDocument.createComment('');\n element.insertBefore(between, child);\n statics.add(between);\n }\n if (!placeholder) statics.add(child);\n hole = placeholder;\n }\n STATICS.set(element, statics);\n },\n};\n\n/* ── the slot element ──────────────────────────────────────────────────────────────────────────── */\n\n/**\n * The `<slot>` element's own answers, from the live assignment (a slot outside a shadow tree answers nothing). With\n * `flatten`, an unassigned slot answers its fallback's slottables, a nested slot through itself.\n */\nconst assigned = (rec: Rec, elementsOnly: boolean, flatten = false): Node[] => {\n flush(rec.light);\n const out = rec.shown.filter((node) => !elementsOnly || node.nodeType === 1);\n /** The fallback is read only when NOTHING is assigned — assigned text with no element still answers [] for elements. */\n if (rec.shown.length > 0 || !flatten) return out;\n for (const node of rec.slot.childNodes) {\n const nested = (node as Kept).$rec;\n if (nested !== undefined) out.push(...assigned(nested, elementsOnly, true));\n else if (node.nodeType === 1 && (node as Element).localName === 'slot') continue;\n else if (node.nodeType === 1 || (!elementsOnly && node.nodeType === 3)) out.push(node);\n }\n /** A nested slot whose content stands in its place is read where it stands. */\n return out;\n};\n\nconst slotBehavior = {\n mount: (slot: Element, context: { root: Node | null }) => {\n const root = context.root;\n /**\n * A shadow root distributes natively; only a light host (an element rendered into) is this module's. A host\n * captured at `init` that then rendered into a shadow root of its own gets its children back, for the platform.\n */\n if (root !== null && root.nodeType === 11) {\n const owner = HOSTS.get((root as ShadowRoot).host);\n if (owner !== undefined && owner.recs.length === 0) release(owner);\n }\n if (root === null || root.nodeType !== 1) return undefined;\n if (__DEV__) {\n const inert = [...slot.attributes].map((attribute) => attribute.name).filter((name) => name !== 'name');\n if (inert.length > 0)\n console.warn(\n diagnostic('slots', `<${(root as Element).localName}>`, 'slot-attributes',\n __DEV__ && PROSE['slot-attributes'](`<slot${slot.hasAttribute('name') ? ` name=\"${slot.getAttribute('name')}\"` : ''}>`, inert.map((name) => `\\`${name}\\``).join(', ')))\n );\n }\n /** A host `init` never saw has no captured children: what it holds now is its own render, never light content. */\n /** Its own light's records first: what the user did to it this task is noted before this module's moves, which are dropped. */\n flush(HOSTS.get(root as Element));\n const light = HOSTS.get(root as Element) ?? lightFor(root as Element, isCustomElementName((root as Element).localName));\n const kept = slot as Kept;\n const rec: Rec = { slot: kept, light, rs: null, re: null, shown: [], queued: false };\n kept.$rec = rec;\n /** A region handed over (hydration: the server's two markers) IS this slot's region, and what is between them stays. */\n const served = kept._$region$;\n if (served !== undefined) {\n kept._$region$ = undefined;\n [rec.rs, rec.re] = served;\n for (let node = rec.rs.nextSibling!; node !== rec.re; node = node.nextSibling!) {\n PLACED.set(node, rec);\n (node as Node & { _$slotted$?: boolean })._$slotted$ = true;\n }\n watch(rec.re.parentNode!, light);\n }\n kept.assignedNodes = (options?: AssignedNodesOptions) => assigned(rec, false, options?.flatten);\n kept.remove = removeSlot;\n kept.replaceWith = replaceSlot;\n kept.assignedElements = (options?: AssignedNodesOptions) => assigned(rec, true, options?.flatten) as Element[];\n light.recs.push(rec);\n light.wait = false;\n watch(kept, light);\n distribute(light);\n drop(light);\n /**\n * Its FIRST slot, after its first render — in a later render of its own, or in ANOTHER container's (an applier\n * committing there, which never reaches this host's `_$done$`): once that render is over — a microtask, which no\n * render is ever halfway through — read what changed while it was unobserved, and observe it from then. Inside its\n * first render, its own `_$done$` does both.\n */\n if (!light.fresh && light.ho !== true)\n queueMicrotask(() => {\n if (light.ho === true || HOSTS.get(light.host) !== light) return;\n reconcile(light);\n flush(light);\n register(light);\n });\n return rec;\n },\n /** Torn down: its content goes back to holding first, and the element back in its place, before the renderer removes it. */\n unmount: (rec: Rec) => {\n flush(rec.light);\n unlist(rec);\n unplace(rec);\n distribute(rec.light);\n drop(rec.light);\n },\n};\n\n/**\n * **The render-end hook, installed at the first thing that needs it** (2026-10-18): until then the renderer's\n * `_$done$` read finds `undefined` and every render ends without calling slots — a page that wired slots but has nothing\n * slotted yet pays nothing per render. Armed by the first light (`lightFor`), the first host a template feeds (FED), the\n * first park, and the first render of a dashed element that already holds something (`unadopted`, the renderer-alone path,\n * which captures at render end).\n */\nlet done: ((container: Node, start: Node) => void) | undefined;\nlet doneOn: { _$done$?: unknown } | undefined;\nconst arm = () => {\n if (doneOn !== undefined && doneOn._$done$ !== done) doneOn._$done$ = done;\n};\n/**\n * **A served light host whose first render nothing adopts** — the renderer asks (`_$unadopted$`) before that render\n * would APPEND beside the server's markup: two copies, the server's dead. The server states every host it renders while\n * slots is wired (`data-vm-light`): stated EMPTY (`N:`), the host holds nothing of the page's, so the server's render\n * is cleared (its SSR stylesheets kept) and the client renders fresh — working, without the server's head start; stated\n * with light content, that content cannot be told from the server's render without `hydrateSlots`, so the host stands\n * as served and the coded error names what to wire. Development warns once per page.\n */\nconst unadopted = (container: Node) => {\n if (container.nodeType === 1 && isCustomElementName((container as Element).localName)) arm();\n /** Asked only for a container with something in it (the renderer skips an empty one: no server markup to append beside). */\n const spec = container.nodeType === 1 ? (container as Element).getAttribute(LIGHT_ATTR) : null;\n if (spec === null) return;\n if (!spec.endsWith(':'))\n /**\n * A WIRING state, not a misused argument, so the diagnostic shape (`[vera] slots: <host> — …`), not `misuse()`'s.\n * Production keeps its own short line, which already carries the code: the code-and-link shape measured +18 B on\n * vera-renderer-slots.min.js (Brian's byte rule, 2026-10-09 — a production message converts only where its bundle\n * is not larger). Development's text is the table's.\n */\n throw new Error(\n __DEV__\n ? diagnostic('slots', `<${(container as Element).localName}>`, 'hydration-unwired', __DEV__ && PROSE['hydration-unwired'](\"this light host, holding the page's content, stands as served\"))\n : '[vera] hydration-unwired'\n );\n for (let node = container.firstChild; node !== null; ) {\n const next: ChildNode | null = node.nextSibling;\n if (node.nodeType !== 1 || !(node as Element).hasAttribute('data-vm-sheet')) container.removeChild(node);\n node = next;\n }\n (container as Element).removeAttribute(LIGHT_ATTR);\n if (__DEV__)\n warnOnce('slots', 'the page', 'hydration-unwired', __DEV__ && (() => PROSE['hydration-unwired']('its components re-render on the client instead of adopting the server markup')));\n};\n\n/** A light host's children in light order, as its record holds them — what a template placing content into it adopts. */\nconst lightNodes = (host: Element): Node[] | null => {\n const light = HOSTS.get(host);\n if (light === undefined) return null;\n flush(light);\n return lightOf(light);\n};\n\n/** The slotted nodes a light host shows in its slot of `name` — or a shadow host's, from the platform. */\nexport const slotted = (host: Element, name = ''): Node[] => {\n const light = HOSTS.get(host);\n if (light !== undefined) {\n flush(light);\n for (const rec of light.recs) if ((rec.slot.getAttribute('name') ?? '') === name && rec.shown.length > 0) return [...rec.shown];\n /** Unassigned, a node still belongs to the host: it waits in holding for a slot of its name. */\n return lightOf(light).filter((node) => slotNameOf(node) === name);\n }\n /**\n * Core's `_$r$` first: a CLOSED root is null through `shadowRoot`, and core keeps the root it attached under that\n * sigiled name in both modes (`@verajs/styles` reads it the same way); no mangling regex matches a sigil.\n * Names are compared, never put in a selector — a quote in one would throw.\n */\n const root = (host as unknown as Record<string, ShadowRoot | null | undefined>)['_$r$'] ?? host.shadowRoot;\n const slot = [...(root?.querySelectorAll('slot') ?? [])].find((s) => (s.getAttribute('name') ?? '') === name);\n return slot === undefined ? [] : slot.assignedNodes();\n};\n\nconst LIGHT_ATTR = 'data-vm-light';\n\n/**\n * Whether hydration is wired — it marks the registry (`_$hydrating$`) when it installs, which may be before or after this\n * module: a served host (`data-vm-light`) is then captured by the adoption, never by `init`'s capture.\n */\nlet wired: { _$hydrating$?: boolean } | null = null;\n\n/**\n * **The `'slot'` insert: a marker** — `@verajs/ssr` distributes light hosts on the server exactly while it is wired. The\n * client claims each `<slot>` through `'element'`, so the function is never called here.\n */\nconst serve = { name: '@verajs/renderer/slots', on: 'slot' as const, fn: () => null, priority: 50 };\n\n/** Discovery: `<slot>` elements and dashed hosts claimed in templates, through `elements`. */\n/**\n * **`observeSlots: 'lazy' | 'eager'`** (paired as HTML's `loading` pairs them) — a component's own option\n * (`init({ host, observeSlots: 'eager' }, …)`, `define({ tag, observeSlots })`), else the app's default\n * (`slots({ observeSlots: 'eager' })`), else `'lazy'`; resolved ONCE here and kept on the light.\n * - `'lazy'`: observed from its first `<slot>` or light child, and a component with neither gets nothing at all (wiring\n * slots made plain components 2.1–2.7× slower to create when every one was captured and observed). Fully correct for\n * everything a template renders.\n * - `'eager'`: captured and observed from its first render, so a child appended by hand before any slot renders is\n * hidden and a `<slot>` inserted by hand is seen — what native shadow DOM does for every host, at an observer per\n * component.\n */\n/**\n * Development: `observeSlots` is `'lazy'` or `'eager'`; anything else reads as `'lazy'` — the BUILT-IN default, even where\n * the app's default is `'eager'`, as core does for `foreignNodes` — and says so.\n */\nconst checkObserve = (subject: string, value: unknown) => {\n if (value !== undefined && value !== 'lazy' && value !== 'eager')\n console.warn(diagnostic('slots', subject, 'observe-slots-option', __DEV__ && PROSE['observe-slots-option'](typeof value === 'string' ? `'${value}'` : String(value))));\n};\nconst captureAtInit = (element: Element, options: object | undefined) => {\n const own = (options as { observeSlots?: unknown } | undefined)?.observeSlots;\n if (__DEV__) checkObserve(`<${element.localName}>`, own);\n const eager = (own !== undefined ? own : (wired as { _$observeSlots$?: unknown } | undefined)?._$observeSlots$) === 'eager';\n /** Nothing to hide and nothing expected (the cheap tests first — they settle every plain component). */\n if (element.firstChild === null && !eager) return;\n /**\n * A SHADOW host distributes natively: core attaches its root before this insert runs and keeps it under the\n * unmangled `_root` (a closed root is null through `shadowRoot`), quoted so this bundle's mangling leaves it alone.\n */\n if ((element as unknown as Record<string, unknown>)['_$r$'] != null || element.shadowRoot !== null) return;\n /** A SERVER host waits: whether its marks are trusted is the following render's to decide (`read`, under adoption). */\n if (isCustomElementName(element.localName) && !HOSTS.has(element) && !(wired?._$hydrating$ === true && element.hasAttribute(LIGHT_ATTR))) {\n const light = capture(element);\n if (eager) light.ex = true;\n }\n};\n/** Development: the option key this hook reads, so core's unknown-option check accepts it (`$keys` sits on the FUNCTION). */\nif (__DEV__) Object.assign(captureAtInit, { $keys: ['observeSlots'], $module: '@verajs/renderer/slots' });\n\nexport const slotDiscovery = [\n elements,\n /**\n * **Capture at `init`** — core's insert point, before the component's first render, when everything a CUSTOM element\n * (a dash, not a reserved SVG/MathML name) holds is the page's: its light content, captured even if its `<slot>`\n * arrives later. Once per host: a reconnect finds it captured and its render untouched.\n */\n {\n name: '@verajs/renderer/slots-capture',\n on: 'init' as const,\n fn: captureAtInit,\n priority: 10,\n },\n {\n name: '@verajs/renderer/slot-discovery',\n on: 'element' as const,\n fn: (el: Element) =>\n el.localName === 'slot' ? slotBehavior : el.firstChild !== null && isCustomElementName(el.localName) ? hostBehavior : undefined,\n priority: 10,\n },\n /**\n * **After every render** — the renderer says when one finishes (`_$done$`, off-chain like `$t`), and what it did to a\n * light host's children is distributed before anything reads them.\n */\n (registry: Map<string, unknown[]>) => {\n /** Hydration's seam — off-chain like `_$done$`, stamped with this package's seam protocol: capture a served host. */\n wired = registry as unknown as { _$hydrating$?: boolean };\n (registry as unknown as { _$capture$?: unknown })._$capture$ = [PROTOCOL, captureServed, lightNodes, SERVED_HOSTS, standIn, PLACED, ADOPTED];\n (registry as unknown as { _$unadopted$?: (container: Node) => void })._$unadopted$ = unadopted;\n (registry as unknown as { _$parked$?: (root: Node, owner: Node | null) => void })._$parked$ = (root, owner) => {\n arm();\n if (owner !== null) PARKED.set(root, owner);\n (parkedObserver ??= new (globalThis.MutationObserver ?? (root.ownerDocument!.defaultView as typeof globalThis).MutationObserver)(parkedHandle)).observe(root, {\n attributes: true,\n attributeFilter: ['slot'],\n childList: true,\n subtree: true,\n });\n };\n /** Development only: how many lights wait for work — 0 once every rendered host is distributed (a retention pin). */\n if (__DEV__) (registry as unknown as { _$slotsWork$?: () => number })._$slotsWork$ = () => work.size;\n /** Development only: how many hosts a root's renders have fed, as recorded — bounded by its live rows (a growth pin). */\n if (__DEV__) (registry as unknown as { _$slotsFed$?: (root: Node) => number })._$slotsFed$ = (root) => FED.get(root)?.length ?? 0;\n doneOn = registry as unknown as { _$done$?: unknown };\n done = (container: Node, start: Node) => {\n /**\n * A CUSTOM element rendered into that `init` never captured (the renderer used on its own, without core): what it\n * held before its first render's range is its light content — Brian's ruling 4, custom elements by their name.\n */\n let own = HOSTS.get(container as Element);\n if (container.nodeType === 1 && (own?.late ?? container.firstChild !== start) && (container as Element).shadowRoot === null && isCustomElementName((container as Element).localName)) {\n capture(container as Element, start);\n own = HOSTS.get(container as Element);\n }\n /**\n * Nothing of this module's here — no light, nothing waiting, no host this render fed, nothing parked: the render of\n * every component that needs no slotting ends here (a full `flush` per render was most of what wiring slots still\n * cost a plain component in Firefox).\n */\n if (own === undefined && work.size === 0 && parkedObserver === undefined && FED.get(container) === undefined) return;\n /** Its own render ended: a fresh light that left the work set (disconnected meanwhile) is distributed now. */\n if (own?.fresh && !own.wait) work.add(own);\n /**\n * Unobserved until it has a slot: what changed meanwhile is read once — at its first render's end, and at the end of\n * the render that mounted its first slot — before the distribution below. A light with no slot shows nothing, so\n * nothing about it needs following until then.\n */\n const slotted = own !== undefined && own.recs.length > 0;\n if (own !== undefined && own.ho !== true && (own.fresh || slotted)) reconcile(own);\n ending = true;\n try {\n flush(own, container);\n } finally {\n ending = false;\n }\n /** Observed from here on — after this module's own moves above, which then make no records. */\n if (own !== undefined && own.ho !== true && (slotted || own.ex === true)) register(own);\n };\n /** A page whose components never needed slotting keeps `_$done$` undefined: their renders never call into slots. */\n },\n];\n\nconst parts = [slotDiscovery, serve];\n/** What `wire` hands a connector: the registry (told apart from options by its `get`) and `wire` itself. */\ntype Registry = { get(name: never): unknown };\ntype Wire = (item: never) => void;\ntype ObserveSlots = 'lazy' | 'eager';\ntype SlotsOptions = { observeSlots?: ObserveSlots };\ntype SlotsConnector = (registry: Registry, wire: Wire) => void;\n/** Two call signatures: as `wire` calls it (bare), and as an app calls it (with options) — both a module to `wire`. */\ntype SlotsModule = { (options?: SlotsOptions): SlotsConnector; (registry: Registry, wire: Wire): void };\n/**\n * **`slots` is a DUAL** — `wire([renderer, slots])`, or `wire([renderer, slots({ observeSlots: 'eager' })])` to make\n * observing from the first render every light component's default (a component's own `observeSlots` wins either way). Bare, `wire` hands it the\n * registry and `wire` itself, and it wires its parts; called, it returns a connector doing the same and writing the\n * default on that registry — two cores on one page keep their own.\n */\n/**\n * A `wire` that hands a connector only the registry — a core older than this module, or code calling connectors itself —\n * can wire nothing of slots: said, in both builds, rather than leaving every slot quietly undistributed.\n */\nconst tooOld = () => {\n throw new Error(__DEV__ ? diagnostic('slots', 'wire([slots])', 'slots-wire-too-old', __DEV__ && PROSE['slots-wire-too-old']()) : '[vera] slots-wire-too-old');\n};\nexport const slots = ((given?: SlotsOptions | Registry, w?: (item: unknown) => void): SlotsConnector | undefined => {\n /** Told apart by the REGISTRY (its `get`), as the module rule says — never by whether a second argument came. */\n if (typeof (given as Registry | undefined)?.get === 'function') {\n if (typeof w !== 'function') tooOld();\n w!(parts);\n return undefined;\n }\n const options = given as SlotsOptions | undefined;\n if (__DEV__) {\n for (const key in options) if (key !== 'observeSlots') console.warn(diagnostic('slots', 'slots()', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'observeSlots')));\n checkObserve('slots()', options?.observeSlots);\n }\n const observe = options?.observeSlots;\n return (registry, wire) => {\n if (typeof wire !== 'function') tooOld();\n (wire as (item: unknown) => void)(parts);\n if (observe !== undefined) (registry as unknown as { _$observeSlots$?: unknown })._$observeSlots$ = observe;\n };\n}) as SlotsModule;\n\n/** Its option's type, where slots is imported: `init({ host, observeSlots: 'eager' }, …)` (core's `VeraInitOptions`). */\ndeclare global {\n // eslint-disable-next-line no-restricted-syntax -- merging IS the point: slots adds its key to core's options\n interface VeraInitOptions {\n observeSlots?: 'lazy' | 'eager';\n }\n}\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\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 = 1;\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"],"names":["RESERVED_ELEMENT_NAMES","Set","isCustomElementName","tag","includes","has","toLowerCase","registered","report","error","root","line","handlers","element","length","handler","reportError","console","reportUncaught","reportTo","get","undefined","nodeType","host","hostOf","firstIn","firstElementChild","nextIn","node","at","parentElement","nextElementSibling","elements","registry","name","on","fn","built","_result","_readScope","claims","template","positions","behaviors","i","behavior","push","_$inst$","$c","instance","adopted","found","listed","Array","isArray","k","create","f","r","a","d","$m","given","state","context","value","mount","unmount","$q","kept","hookFor","priority","slotNameOf","getAttribute","park","light","holding","holdingOf","parentNode","insertBefore","firstChild","watchHolding","LIGHT","Symbol","HOSTS","STATICS","WeakMap","STAND","REAL","PLACED","ADOPTED","lightOf","out","unit","units","z","nextSibling","unstand","stand","delete","remove","firstOf","$rec","rs","lastOf","re","move","parent","ref","last","next","standIn","ownerDocument","createComment","set","toHolding","lastChild","chain","rec","slot","unshift","contains","outer","follows","b","compareDocumentPosition","region","doc","removeChild","watch","unregion","unplace","unlist","recs","splice","indexOf","changed","queued","queueMicrotask","dispatchEvent","defaultView","bubbles","composed","inLight","busy","distribute","mark","place","dirty","fresh","ending","home","filter","isWhere","real","live","parked","add","sort","x","y","before","winner","Map","nodes","statics","wanted","taken","list","mine","previous","first","previousSibling","_$slotted$","shown","some","run","unpark","observerOf","Observer","globalThis","MutationObserver","obs","records","note","flush","parkedObserver","PARKED","parkedHandle","noteParked","take","all","ho","cw","takeRecords","drop","record","type","target","lead","watchedBy","hw","topOf","up","insideHost","handRemoved","removeSlot","this","Element","prototype","call","replaceSlot","replaceWith","apply","claimQueued","findSlots","localName","getElementsByTagName","ofTemplate","claimInserted","pending","slotBehavior","ex","added","addedNodes","n","scanAdded","removed","removedNodes","replay","unrun","adopt","anchor","own","top","owner","work","wait","near","fed","FED","rooted","isConnected","deref","observer","outside","observe","childList","attributes","attributeFilter","mineAlready","OWN","ours","child","childNodes","ahead","unitIndexOf","findIndex","settleIn","inRun","behind","register","subtree","wired","_$hydrateSlots$","hh","reconcile","ranged","PATCHED","answerAssigned","win","proto","Text","Object","getOwnPropertyDescriptor","native","defineProperty","configurable","enumerable","dress","setAttribute","style","setProperty","append","createElement","SERVED_HOSTS","captureServed","args","capture","lightFor","late","carrier","arm","close","hostBehavior","WeakRef","hole","placeholder","data","between","assigned","elementsOnly","flatten","nested","appendChild","disconnect","release","served","_$region$","assignedNodes","options","assignedElements","done","doneOn","_$done$","unadopted","container","spec","LIGHT_ATTR","endsWith","Error","hasAttribute","removeAttribute","lightNodes","slotted","shadowRoot","querySelectorAll","find","s","slotDiscovery","observeSlots","eager","_$observeSlots$","_$hydrating$","el","_$capture$","_$unadopted$","_$parked$","start","size","parts","tooOld","slots","w","wire"],"mappings":"AAMO,MCwEMA,EAAyB,IAAIC,IAAI,CAC5C,iBAAkB,gBAAiB,YAAa,gBAChD,gBAAiB,mBAAoB,iBAAkB,kBAS5CC,EAAuBC,GAClCA,EAAIC,SAAS,OAASJ,EAAuBK,IAAIF,EAAIG,eCjEvD,IAAIC,EAA4C,KAQhD,MAAMC,EAAS,CAACC,EAAgBC,EAAmBC,ICiC3B,EAACC,EAA0CH,EAAgBI,EAA8BF,KAC/G,GAAIC,GAAUE,OAAQ,IAAK,MAAMC,KAAWH,EAAWG,EAAwDN,EAAOI,OAlB1F,EAACJ,EAAgBE,KAClB,mBAAhBK,YAA4BC,QAAQR,MAAME,EAAMF,GAGzDO,YAAYP,EACd,EAcKS,CAAeT,EAAOE,EAAK,EDnCkCQ,CAASZ,GAAYa,IAAI,SAAUX,ECuCjF,CAACC,GACb,MAARA,OAAeW,EAA8B,KAAlBX,EAAKY,SAAmBZ,EAAoBa,KAAQb,EDxC6Bc,CAAOd,GAAOC,GAOtHc,EAAWf,GAAkD,IAAlBA,EAAKY,SAAkBZ,EAAoBA,EAAoBgB,kBAC1GC,EAAS,CAACC,EAAelB,KAC7B,GAA+B,OAA3BkB,EAAKF,kBAA4B,OAAOE,EAAKF,kBACjD,IAAK,IAAIG,EAAqBD,EAAa,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iBC,GAAI,IAAM,KAAMmC,SAAU,KA+IzF8Q,GAAS,KACb,MAAM,IAAIrB,MAAuH,4BAA4B,EAElJsB,GAAK,CAAKxR,EAAiCyR,KAEtD,GAAoD,mBAAxCzR,GAAgC1C,IAG1C,MAFiB,mBAANmU,GAAkBF,UAC7BE,EAAGH,IAGL,MAAM9B,EAAUxP,EAKVwL,EAAUgE,GAASoB,aACzB,MAAO,CAACzS,EAAUuT,KACI,mBAATA,GAAqBH,KAC/BG,EAAiCJ,SAClB/T,IAAZiO,IAAwBrN,EAAsD2S,gBAAkBtF,EAAO,CAE9G"}
|
|
1
|
+
{"version":3,"file":"vera-renderer-slots.min.js","sources":["../../shared-utils/src/diagnostic.ts","../../shared-utils/src/markup-grammar.ts","../src/elements.ts","../../shared-utils/src/utils.ts","../src/slots.ts","../src/kinds.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 { 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 (`<` `<`,\n * a space ` `, `=` `=`), 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 ` ` 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","/**\n * **`@verajs/renderer/elements` — attach behavior to elements in templates.**\n *\n * ```js\n * const autofocus = { mount: (element) => element.focus() };\n * wire([renderer, elements, { on: 'element', fn: (el) => (el.hasAttribute('autofocus') ? autofocus : undefined) }]);\n * ```\n *\n * Every `'element'` claimant is asked about each element of a template ONCE, as the template is BUILT — on its\n * canonical content, so a tag and its static attributes are real and no binding is ever applied (a hydrated first\n * instance, whose elements are the server's with bound values in them, changes nothing). The answers are two flat\n * lists shared by every instance: element positions in document pre-order, and their behaviors. A template nobody\n * claimed anything in gets no instance hook at all. Each instance finds its claimed elements with one short walk to\n * those positions; once the render that created it has finished, each behavior's `mount` runs, and what it returns is\n * handed to `unmount` at teardown. Nothing runs per update.\n *\n * Built on the renderer's `'template'` insert and instance hook (`InstanceHook`); it imports nothing — the registry\n * arrives through its connector. An app that does not wire it pays nothing.\n */\nimport type { ElementBehavior, InstanceHook } from './types.js';\nimport { diagnostic, hostOf, reportTo } from '@verajs/shared-utils';\nimport { PROSE } from './elements-diagnostics.js';\n\ntype Claim = (element: Element) => ElementBehavior | undefined;\n\nlet registered: Map<string, unknown[]> | null = null;\n\n/**\n * **A claim's callbacks follow the ref rule** (Brian, 2026-10-09): user code a render calls is caught AT ITS CALL SITE\n * — so a template with no claims runs exactly the path it did — reported to the app's `'error'` chain with the\n * component it belongs to (else as uncaught), and the render, the other claims and the teardown carry on. A mid-commit\n * throw once left a component's root empty for good; `mount` propagating aborted every later claim's mount.\n */\nconst report = (error: unknown, root: Node | null, line: string) => reportTo(registered?.get('error'), error, hostOf(root), line);\n\n/**\n * **The next element of an instance in document pre-order, never leaving it.** A root is a fragment, or — for a\n * single-root template — its one element, which is then position 0. Bounded by the root rather than by the tree it\n * sits in, because a hydrated instance is already in the page.\n */\nconst firstIn = (root: Node): Element | null => (root.nodeType === 1 ? (root as Element) : (root as ParentNode).firstElementChild);\nconst nextIn = (node: Element, root: Node): Element | null => {\n if (node.firstElementChild !== null) return node.firstElementChild;\n for (let at: Element | null = node; at !== null && at !== root; at = at.parentElement)\n if (at.nextElementSibling !== null) return at.nextElementSibling;\n return null;\n};\n\n/**\n * One instance's claims until it mounts — its claimed elements and their behaviors, interleaved, where it rendered,\n * whether it was adopted — and then only what `unmount` needs. **The elements are released at mount**: per-instance\n * state that keeps DOM references past the moment it needs them costs every operation on the page (measured: ~7% on\n * select and swap of a table whose every row was claimed, operations that never touch it).\n */\ntype State = { f: (Element | ElementBehavior)[] | null; r: Node | null; a: boolean; k: unknown[] | undefined; d: boolean };\n\n/** The instance hook for one template, from the positions and behaviors its claimants answered. */\nconst hookFor = (positions: number[], behaviors: ElementBehavior[]): InstanceHook => ({\n $c: (instance, root, adopted) => {\n const found: (Element | ElementBehavior)[] = [];\n /**\n * ADOPTED, the instance arrives as its elements in template order (hydration pairs them): its live root already\n * holds what its nested parts rendered, so counting there would land on the wrong element.\n */\n const listed = Array.isArray(instance);\n let node = listed ? null : firstIn(instance as Node);\n let at = 0;\n for (let k = 0; k < positions.length; k++) {\n if (listed) node = (instance as readonly Element[])[positions[k]];\n else for (; at < positions[k]; at++) node = nextIn(node!, instance as Node);\n /**\n * At creation — before the first update, and before the instance is connected anywhere. A claim whose `create`\n * throws is reported and DROPPED for this instance (it never mounts or unmounts, being half made); the element\n * stays as the template built it — a claim inserts nothing — and every other claim carries on. The ref rule.\n */\n try {\n behaviors[k].create?.(node!, adopted);\n } catch (error) {\n report(error, root, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('create', 'the render continued without it')) : '[vera] claim-threw');\n continue;\n }\n found.push(node!, behaviors[k]);\n }\n return { f: found, r: root, a: adopted, k: undefined, d: false } as State;\n },\n $m: (given) => {\n const state = given as State;\n /** Torn down before its render finished: it never mounts. */\n if (state.d) return;\n const found = state.f!;\n const context = { root: state.r, adopted: state.a };\n state.f = null;\n for (let i = 0; i < found.length; i += 2) {\n const behavior = found[i + 1] as ElementBehavior;\n let value;\n try {\n value = behavior.mount?.(found[i] as Element, context);\n } catch (error) {\n report(error, state.r, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('mount', 'the others still mounted')) : '[vera] claim-threw');\n continue;\n }\n if (value !== undefined && behavior.unmount !== undefined) (state.k ??= []).push(found[i], behavior, value);\n }\n },\n $q: (given) => {\n const state = given as State;\n state.d = true;\n const kept = state.k;\n if (kept !== undefined)\n for (let i = 0; i < kept.length; i += 3)\n try {\n (kept[i + 1] as ElementBehavior).unmount!(kept[i + 2], kept[i] as Element);\n } catch (error) {\n report(error, state.r, __DEV__ ? diagnostic('elements', 'an element claim', 'claim-threw', __DEV__ && PROSE['claim-threw']('unmount', 'the rest of the teardown ran')) : '[vera] claim-threw');\n }\n },\n});\n\n/**\n * Asks the claimants about the template's canonical content, once, as it is built — and gives it an instance hook\n * only if something was claimed. The content is READ, never changed (see the `'template'` insert's contract).\n */\nconst claimTemplate = (built: object, _result: unknown, _readScope: unknown, root: Node) => {\n const claims = registered?.get('element') as Claim[] | undefined;\n if (claims === undefined || claims.length === 0) return;\n const template = built as { _$inst$?: InstanceHook };\n if (__DEV__ && template._$inst$ !== undefined)\n console.warn(diagnostic('elements', 'template', 'elements-hook-replaced', __DEV__ && PROSE['elements-hook-replaced']()));\n const positions: number[] = [];\n const behaviors: ElementBehavior[] = [];\n let at = 0;\n for (let node = firstIn(root); node !== null; node = nextIn(node, root), at++)\n for (let i = 0; i < claims.length; i++) {\n const behavior = claims[i](node);\n if (behavior !== undefined) {\n positions.push(at);\n behaviors.push(behavior);\n }\n }\n if (positions.length > 0) template._$inst$ = hookFor(positions, behaviors);\n};\n\n/** Wire it as `wire([renderer, elements, …claims])`. A bare module: it has no options. */\nexport const elements = [\n (registry: Map<string, unknown[]>) => {\n registered = registry;\n },\n { name: '@verajs/renderer/elements', on: 'template' as const, fn: claimTemplate, priority: 10 },\n];\n\nexport type { ElementBehavior } from './types.js';\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 * **`@verajs/renderer/slots` — `<slot>` in a light-DOM component.** `wire([renderer, slots])`.\n *\n * A component that renders into its own element (no shadow root) gets the platform's slot assignment for the\n * children the page gave it: each light child goes to the first `<slot>` of its `slot` name (the default slot for\n * text and unnamed elements), a slot with nothing assigned shows its own content (the fallback), and comments are\n * never assigned.\n *\n * **The renderer knows nothing of it.** A host's light children are divided into UNITS: each static child alone, and\n * each run a binding of the page's template wrote (its markers and everything between them) whole. A unit moves as\n * one piece — never split — so every write the renderer later makes inside it lands where the unit now is, and the\n * renderer's own range stays contiguous. While a `<slot>` has content, the element steps out of the page and its\n * content stands in its place, between this module's two comments; with none, the element is back, showing its\n * fallback. What the page's template later does inside a unit is seen by a `MutationObserver` and re-distributed —\n * synchronously after every component render (core's `'render'` insert), and at the latest by the next microtask.\n */\nimport { diagnostic, isCustomElementName, SHARED, warnOnce } from '@verajs/shared-utils';\nimport { PROSE } from './slots-diagnostics.js';\nimport { elements } from './elements.js';\nimport { PROTOCOL } from './kinds.js';\n\n/** A slot's assignment name: an element's `slot` attribute, `''` for text; a comment is never slottable. */\nconst slotNameOf = (node: Node): string | null =>\n node.nodeType === 3 ? '' : node.nodeType === 1 ? ((node as Element).getAttribute('slot') ?? '') : null;\n\n/**\n * A light unit: a static child the page wrote (`a === z`), which moves as itself; or a RUN one of its template's\n * bindings writes, between this module's own two comments, which never leaves holding — the renderer walks it there,\n * contiguous, and each node of it a slot takes leaves a STAND-IN comment at its place. Every light node goes to the\n * slot its own `slot` names, exactly as the platform assigns.\n */\ntype Unit = { a: Node; z: Node };\n/** One `<slot>` of a light host: while it has content, `rs`/`re` stand in its place and the element is out. */\ntype Rec = { slot: Kept; light: Light; rs: Comment | null; re: Comment | null; shown: Node[]; queued: boolean };\n/** `_$region$`: a filled slot's region handed over before it mounts — by hydration, the server's two markers. */\ntype Kept = HTMLSlotElement & { $rec?: Rec; _$region$?: [Comment, Comment] };\n\n/** A host's light children, by unit, in the order the page wrote them, and its slots. */\n/**\n * `wait`: captured by a template that placed runs into this host during hydration, before the host's own slots exist —\n * nothing distributes until the first of them mounts, so the nodes stay exactly where the server put them.\n */\ntype Light = { host: Element; units: Unit[]; holding?: HTMLElement; recs: Rec[]; dirty: boolean; fresh: boolean; late: boolean; wait: boolean; obs?: MutationObserver; ex?: boolean; hw?: boolean; ho?: boolean; cw?: boolean; hh?: boolean };\n\n/**\n * **Unassigned content stays CONNECTED, as under native slots** — it waits in `<ins hidden data-vm-unassigned>`, the\n * host's first child, rather than out of the page: a component in it keeps running, and assigning or unassigning it is a\n * one-op connected move, which core keeps alive. The container is in the host exactly while it holds a light node —\n * runs' markers and stand-ins are comments, which need no connection — so a host with nothing unassigned has no extra\n * child, and the server, which knows only nodes, emits the same element in the same place.\n *\n * **Why `<ins>`** (Brian, 2026-10-08), measured in all three engines: a standard element, so it is valid HTML and\n * `:defined` (the carrier was `<vm-unassigned>`, a dashed name nothing defined, which discovery loaders tried to import\n * and \"wait until everything is defined\" checks waited on forever); its content model is TRANSPARENT, so it is valid\n * around whatever it holds (a `<span>` holding a `<section>` is not); and it parses inside a `<p>` where a `<div>` would\n * close the paragraph and eject the host's content. It is known by its attribute: a user's own `<ins>` is light content\n * like any other.\n */\nconst UNASSIGNED = 'data-vm-unassigned';\n/** Into the page before a light node moves in, so the move is connected → connected. */\nconst park = (light: Light) => {\n const holding = holdingOf(light);\n if (holding.parentNode !== light.host) light.host.insertBefore(holding, light.host.firstChild);\n watchHolding(light);\n return holding;\n};\n/**\n * At the end of every pass: in the page exactly while it holds a light node — out once only comments remain, and IN if\n * the renderer wrote a new node straight into a run waiting here while it was out (that node's first connection).\n */\nconst unpark = (light: Light) => {\n const holding = light.holding;\n if (holding === undefined) return;\n for (let node = holding.firstChild; node !== null; node = node.nextSibling) if (node.nodeType !== 8) return void park(light);\n holding.remove();\n};\n\n/**\n * **Each host's light, kept ON the host** — under this module copy's own `Symbol` (2026-10-17, candidate B): every\n * component's render end asks whether its container has a light (`_$done$`), and for one that does not — a plain\n * component — that is now a missing-property read, never a WeakMap lookup. Only a host that gets a light carries the\n * field; host → light → host is a DOM↔JS cycle, so `release` clears it. The same get/has/set/delete surface as the\n * WeakMap it replaces, so hydrate-slots, handed it through the protocol, is unchanged.\n */\nconst LIGHT = Symbol();\ntype Lit = Element & { [LIGHT]?: Light };\nconst HOSTS = {\n get: (host: Element) => (host as Lit)[LIGHT],\n has: (host: Element) => (host as Lit)[LIGHT] !== undefined,\n set: (host: Element, light: Light) => {\n (host as Lit)[LIGHT] = light;\n },\n delete: (host: Element) => {\n (host as Lit)[LIGHT] = undefined;\n },\n};\n/** The static children an outer template gave a host, recorded when its instance was created (see `hostBehavior`). */\nconst STATICS = new WeakMap<Element, Set<Node>>();\n/** A run's node in a slot, and the comment holding its place in the run — both ways. */\nconst STAND = new WeakMap<Node, Comment>();\nconst REAL = new WeakMap<Node, Node>();\n/** The slot a light node was placed in (`null`: holding). */\nconst PLACED = new WeakMap<Node, Rec | null>();\n/**\n * A light node CAPTURED WHERE IT STANDS — outside the host, in a slot's region (the server put it there) — before that\n * slot has mounted: where it is, it stays. Slots mount one at a time, and a node waiting for a later one would otherwise\n * read as taken away (see `isWhere`).\n */\nconst ADOPTED = {} as Rec;\n\n/** The host's light children in the order the page wrote them — a run read through its stand-ins. */\nconst lightOf = (light: Light): Node[] => {\n const out: Node[] = [];\n for (const unit of light.units) {\n if (unit.a === unit.z) out.push(unit.a);\n else for (let node = unit.a.nextSibling; node !== null && node !== unit.z; node = node.nextSibling) out.push(REAL.get(node) ?? node);\n }\n return out;\n};\n/** A stand-in is dropped: its node is no longer in a slot (back at its place, or gone). */\nconst unstand = (node: Node) => {\n const stand = STAND.get(node);\n if (stand === undefined) return;\n STAND.delete(node);\n REAL.delete(stand);\n stand.remove();\n};\n\n/**\n * **Where a light node physically is.** A `<slot>` can itself be a light child of another host — slot FORWARDING — and\n * while it has content it is out of the page, its content standing in its place between its two comments: that range is\n * where the node is, and moving the node moves the range.\n */\nconst firstOf = (node: Node): Node => (node as Kept).$rec?.rs ?? node;\nconst lastOf = (node: Node): Node => (node as Kept).$rec?.re ?? node;\n/** A light node moved before `ref` in `parent` — the whole range of a forwarded slot that is out of the page. */\nconst move = (parent: Node, node: Node, ref: Node | null) => {\n const last = lastOf(node);\n for (let at: Node | null = firstOf(node); at !== null; ) {\n const next: Node | null = at === last ? null : at.nextSibling;\n parent.insertBefore(at, ref);\n at = next;\n }\n};\n\n/** A run's node that sits in a slot, its place in the run held by a comment before `ref` in `parent` — both ways. */\nconst standIn = (node: Node, parent: Node, ref: Node | null) => {\n const stand = node.ownerDocument!.createComment('');\n parent.insertBefore(stand, ref);\n STAND.set(node, stand);\n REAL.set(stand, node);\n};\n\n/** A light node back to holding: a run's node to its place in the run (where its stand-in is), any other to the end. */\nconst toHolding = (light: Light, node: Node) => {\n const stand = STAND.get(node);\n if (stand !== undefined) {\n move(park(light), node, stand);\n unstand(node);\n PLACED.delete(node);\n } else {\n move(park(light), node, light.holding!.lastChild);\n PLACED.set(node, null);\n }\n};\n\n/* ── tree order, through slots that are out of the page ────────────────────────────────────────── */\n\n/**\n * The positions that decide a slot's tree order: its own (its element, or the comment standing in its place), and,\n * while it sits inside another slot's element that is OUT of the page (a displaced fallback), that slot's position\n * first. `null` when the chain ends outside the host — a slot parked away by `hold`, which takes part in nothing.\n */\nconst chain = (rec: Rec): Node[] | null => {\n const out: Node[] = [];\n let node: Node = rec.rs ?? rec.slot;\n for (;;) {\n out.unshift(node);\n if (rec.light.host.contains(node)) return out;\n let root: Node = node;\n while (root.parentNode !== null) root = root.parentNode;\n const outer = (root as Kept).$rec;\n if (outer === undefined || outer.rs === null) return null;\n node = outer.rs;\n }\n};\n/** Whether `b` comes after `a` in tree order — the platform's `DOCUMENT_POSITION_FOLLOWING` bit. */\n// eslint-disable-next-line no-bitwise -- compareDocumentPosition answers in the platform's own bitmask\nconst follows = (a: Node, b: Node) => (a.compareDocumentPosition(b) & 4) !== 0;\nconst before = (x: Node[], y: Node[]) => {\n for (let i = 0; i < x.length && i < y.length; i++)\n if (x[i] !== y[i]) return follows(x[i], y[i]);\n return x.length < y.length;\n};\n\n/* ── distribution ──────────────────────────────────────────────────────────────────────────────── */\n\n/**\n * **A filled slot's region is bounded by two comments, spelled the same on both sides.** The client creates them here;\n * the server writes exactly them (`@verajs/ssr`), so a server-rendered host and a client-distributed one are the\n * same DOM down to comment data, and hydration ADOPTS the server's instead of creating its own. Measured 2026-10-07:\n * that end state hydrates faster than any marking that makes the client split text and create markers (Chrome −11%,\n * Firefox −37%, WebKit −9% on a worst case), and it needs no counting, so nothing depends on how the browser decodes\n * text. The data carries no slot name or index: pairing is positional, and a name could close the comment.\n */\nconst RANGE_START = '[';\nconst RANGE_END = ']';\n\nconst region = (rec: Rec) => {\n if (rec.rs !== null) return;\n const doc = rec.slot.ownerDocument;\n const parent = rec.slot.parentNode!;\n rec.rs = doc.createComment(RANGE_START);\n rec.re = doc.createComment(RANGE_END);\n parent.insertBefore(rec.rs, rec.slot);\n parent.insertBefore(rec.re, rec.slot);\n /** `removeChild`, never `remove()`: a kept slot's own `remove()` is the USER's (it unregions first, `removeSlot`). */\n parent.removeChild(rec.slot);\n watch(parent, rec.light);\n};\nconst unregion = (rec: Rec) => {\n if (rec.rs === null) return;\n rec.rs.parentNode?.insertBefore(rec.slot, rec.rs);\n rec.rs.remove();\n rec.re!.remove();\n rec.rs = rec.re = null;\n};\n/** What a slot shows goes back to holding, and the slot back in its place: every way a slot leaves runs this. */\nconst unplace = (rec: Rec) => {\n for (const node of lightOf(rec.light)) if (PLACED.get(node) === rec) toHolding(rec.light, node);\n unregion(rec);\n};\n/** The slot leaves its host's list of slots. */\nconst unlist = (rec: Rec) => rec.light.recs.splice(rec.light.recs.indexOf(rec), 1);\n\n/** `slotchange`, as the platform fires it: once per slot per change, after the change, on the slot element. */\nconst changed = (rec: Rec) => {\n if (rec.queued) return;\n rec.queued = true;\n queueMicrotask(() => {\n rec.queued = false;\n rec.slot.dispatchEvent(new (rec.slot.ownerDocument.defaultView!.Event)('slotchange', { bubbles: true, composed: false }));\n });\n};\n\n/**\n * Whether a node is in this host's holding or one of its slots' regions — or where the server put it (`ADOPTED`), which\n * holds until its slot mounts, as `isWhere` holds a static: a slot mounting first must not read the run's node in a\n * later slot's served region, not yet registered, as taken.\n */\nconst inLight = (node: Node, light: Light): boolean => {\n if (PLACED.get(node) === ADOPTED) return true;\n const parent = node.parentNode;\n if (parent === null) return false;\n if (parent === light.holding) return true;\n for (const rec of light.recs) if (rec.re !== null && rec.re.parentNode === parent) return true;\n return false;\n};\n/** Whether a light node is still where this module put it — false once something else took it (the user's adoption stands). */\nconst isWhere = (node: Node, light: Light): boolean => {\n const rec = PLACED.get(node);\n if (rec === ADOPTED) return true;\n const parent = firstOf(node).parentNode;\n if (rec === undefined) return parent === light.holding;\n /** `PLACED` is shared by every host: a node another host has placed is not this one's, wherever it sits. */\n return rec === null ? parent === light.holding : rec.light === light && parent !== null && parent === rec.re?.parentNode;\n};\n\n/**\n * **Every light node to its slot, in light order** — the whole decision, recomputed. A node something else took away\n * is forgotten first; then each name's first slot in tree order wins, its nodes go between its comments (a run's node\n * leaving a stand-in at its place), a slot left with nothing shows its fallback, and the rest wait in holding.\n */\n/**\n * A distribution in progress can render (a slotted component moved is reconnected, and renders): the render's end asks\n * for another, which waits for this one to finish and then runs.\n */\nlet busy = false;\nconst distribute = (light: Light) => {\n if (busy) {\n /**\n * Unreached outside the work set in every suite (18 hits, all already marked — a first connection is a fresh capture);\n * kept because the invariant requires a dirty light in work, and redundancy here is not proven. Unlike `settleIn`'s\n * mark (removed: its only caller marks first), this one is equivalent by observation only.\n */\n mark(light);\n return;\n }\n busy = true;\n try {\n do place(light);\n while (light.dirty);\n } finally {\n busy = false;\n }\n};\nconst place = (light: Light) => {\n light.dirty = false;\n /**\n * **THE INVARIANT: a slotted node moves in ONE DOM operation, connected → connected.** Core tells a move from a removal\n * by `isConnected` at `disconnectedCallback` (the platform runs it after the operation), so one `insertBefore` from\n * where the node is to where it goes keeps a slotted component alive; a hop through holding (a fragment) is a real\n * disconnect, and the component is torn down and set up again. `tests/core-keep-alive.test.mjs` pins it.\n *\n * **Captured and not yet distributed: placed straight from the host.** A node a slot takes moves host → slot in ONE\n * operation, which the platform — and core — see as a move, not a removal (`isConnected` stays true through it): a\n * slotted component is not torn down and set up again. Only what no slot takes, and a run's own markers, go to holding.\n */\n const fresh = light.fresh;\n /**\n * Parked only when the render ENDS (`ending`): its slots have all mounted by then, so a node no slot took really has\n * none. Parked earlier — at the first slot's mount — a node for a later slot would hop host → holding → slot, two\n * operations, and be torn down and set up again on the way.\n */\n /**\n * **What clears `fresh`: only a render that ENDS** (`_$done$`, after the commit). A first render that THROWS out of\n * `renderInto` skips it, and the host stays fresh — its captured children still where the page put them, its runs\n * still in the host — until a render completes. That is consistent, not stale: a failed commit mounts no slot (mounts\n * run at a render's end), so no region exists for `inRun` to misread, and a user's edit meanwhile is an ordinary\n * host record (`adopt`). Pinned in `tests/renderer-slots.test.mjs`.\n */\n if (ending) light.fresh = false;\n const host = light.host;\n /** Re-read, never a copy: holding is built at its first use (`holdingOf`), possibly during this pass. */\n const home = (node: Node) => firstOf(node).parentNode === light.holding || (fresh && firstOf(node).parentNode === host);\n light.units = light.units.filter((unit) => (unit.a === unit.z ? isWhere(unit.a, light) || (fresh && firstOf(unit.a).parentNode === host) : home(unit.a) && home(unit.z)));\n for (const unit of light.units)\n if (unit.a !== unit.z)\n for (let node = unit.a.nextSibling; node !== null && node !== unit.z; node = node.nextSibling) {\n const real = REAL.get(node);\n /** The renderer moves a run's nodes between this host's slots (beside a neighbor it follows); only leaving them all is a theft. */\n if (real !== undefined && !inLight(real, light)) {\n PLACED.delete(real);\n unstand(real);\n }\n }\n const live: { rec: Rec; at: Node[] }[] = [];\n /** A slot parked away (by `hold`) takes part in nothing — and what it shows waits with it, untouched. */\n const parked = new Set<Rec>();\n for (const rec of light.recs) {\n const at = chain(rec);\n if (at !== null) live.push({ rec, at });\n else parked.add(rec);\n }\n live.sort((x, y) => (before(x.at, y.at) ? -1 : 1));\n const winner = new Map<string, Rec>();\n for (const { rec } of live) {\n const name = rec.slot.getAttribute('name') ?? '';\n if (!winner.has(name)) winner.set(name, rec);\n }\n const nodes = lightOf(light);\n /** A static child moves as itself; only a node of a binding's RUN leaves a stand-in at its place. */\n const statics = new Set<Node>();\n for (const unit of light.units) if (unit.a === unit.z) statics.add(unit.a);\n const wanted = new Map<Rec, Node[]>();\n const taken = new Set<Node>();\n for (const node of nodes) {\n const name = slotNameOf(node);\n const rec = name === null ? undefined : winner.get(name);\n if (rec === undefined) continue;\n let list = wanted.get(rec);\n if (list === undefined) wanted.set(rec, (list = []));\n list.push(node);\n taken.add(node);\n }\n for (const { rec } of live) {\n const mine = wanted.get(rec) ?? [];\n if (mine.length > 0) {\n region(rec);\n const parent = rec.re!.parentNode!;\n /** Only what is out of place moves: a move disconnects and reconnects a component, re-running its lifecycle. */\n let previous: Node = rec.rs!;\n for (const node of mine) {\n const first = firstOf(node);\n if (first.parentNode === parent && first.previousSibling === previous) {\n previous = lastOf(node);\n continue;\n }\n /** A run's node, still at its place in holding: a stand-in takes the place before it leaves. */\n if (!statics.has(node) && home(node) && !STAND.has(node)) standIn(node, first.parentNode!, first);\n move(parent, node, previous.nextSibling);\n /** Marked as moved by slots: the renderer follows it here when it inserts beside it (see `into`). */\n (node as Node & { _$slotted$?: boolean })._$slotted$ = true;\n PLACED.set(node, rec);\n previous = lastOf(node);\n }\n }\n if (mine.length !== rec.shown.length || mine.some((node, i) => node !== rec.shown[i])) {\n rec.shown = mine;\n changed(rec);\n }\n }\n for (const node of nodes) {\n if (taken.has(node)) continue;\n const rec = PLACED.get(node);\n if (rec !== undefined && rec !== null && parked.has(rec)) continue;\n /** Adopted and waiting for its slot, which mounts later in the same render: it stays where the server put it. */\n if (rec === ADOPTED && !ending) continue;\n if (STAND.has(node) || (rec !== undefined && rec !== null) || (ending && statics.has(node) && node.parentNode === host)) toHolding(light, node);\n }\n /** A run captured in the host goes to holding now — its markers, stand-ins and unassigned nodes; its slotted nodes left in one move each. */\n if (fresh && ending)\n for (const unit of light.units)\n if (unit.a !== unit.z && unit.a.parentNode === host) {\n const run: Node[] = [];\n for (let node: Node | null = unit.a; node !== null; node = node.nextSibling) {\n run.push(node);\n if (node === unit.z) break;\n }\n const holding = holdingOf(light);\n for (const node of run) (node.nodeType === 8 ? holding : park(light)).insertBefore(node, holding.lastChild);\n watchHolding(light);\n }\n for (const { rec } of live) if (!wanted.has(rec)) unregion(rec);\n unpark(light);\n};\n\n/* ── the observer: what the page's templates (and the user) do afterwards ─────────────────────── */\n\n/**\n * **An observer per light** — never one shared by every host: Gecko's `observe()` is linear in what that observer\n * already watches, removed nodes included, through collections (2000 observes 4 → 45 ms over ten batches on one observer,\n * flat on a fresh one, flat on Chromium and WebKit), so a shared one made every new light host slower in Firefox without\n * end (2000 hosts: 262 → 9305 ms over eight renders that replaced them; flat now). A light's observer goes with it.\n *\n * From THIS module's own realm, which cannot close while its code runs — a MutationObserver watches nodes of another\n * document (measured on Chromium, Firefox and WebKit). Taking it from a host's window went deaf with that window: a\n * light host in an iframe or a popped-out window, closed later (`tests/browser/slots-realm.test.js`). The host's window\n * is the fallback only where this realm has no observer at all.\n */\nconst observerOf = (light: Light): MutationObserver => {\n const Observer = globalThis.MutationObserver ?? (light.host.ownerDocument.defaultView as typeof globalThis).MutationObserver;\n /**\n * Bound to their light (2026-10-17): a record can only reach a light through what THAT light registered, so it arrives\n * already knowing whose it is — no node → lights lookup, and no per-node bookkeeping (a WeakMap entry and a Set for every\n * watched node were ~164 ms of Chrome's slots creation at 10 000 hosts).\n */\n const handle = (records: MutationRecord[]) => {\n note(light, records);\n flush();\n };\n /**\n * ONE per light (2026-10-17; probe P3 vs P2: ~1 point of creation in each engine): its registrations are on distinct nodes —\n * the host's subtree for childList, each light element and slot for its attributes, holding and a fallback's region\n * parent for childList — so none replaces another's options, except a node both a light element and a slot (`own`).\n */\n return (light.obs ??= new Observer(handle));\n};\n/**\n * **A `hold()`-parked branch, watched while it is parked** — a slot's region in it is out of its host's subtree, where\n * the host's own attribute registration cannot see a node in it renamed (`slot=`): re-routed now, as native slots would.\n * One observer for every parked root (the renderer's `_$parked$`), registering the same root again when it parks again.\n */\nlet parkedObserver: MutationObserver | undefined;\n/** Each parked branch's owner — the container whose render parked it (a WeakMap on the parked root: parking is rare). */\nconst PARKED = new WeakMap<Node, Node>();\nconst parkedHandle = (records: MutationRecord[]) => {\n noteParked(records);\n flush();\n};\n/**\n * A light's pending records. A light in the work set (`all` false) is not asked while it has no childList registration\n * (its first render): its renames stay with the callback, and `takeRecords()` on every host every pass was ~114 ms of\n * Chrome's slots creation at 10 000 hosts (2026-10-17).\n */\nconst take = (light: Light, all = true): MutationRecord[] =>\n light.obs === undefined || (!all && light.ho !== true && light.cw !== true) ? [] : light.obs.takeRecords();\n/**\n * **This module's own moves, dropped** — what was pending before them was read at the start of the same pass. Nothing to\n * drop while the light has no childList registration (see `take`). A move never changes an attribute, so a rename found\n * here is someone else's (a moved element's `connectedCallback`): it marks its light and is followed after this pass.\n */\nconst drop = (light: Light) => {\n if (light.obs === undefined || (light.ho !== true && light.cw !== true)) return;\n for (const record of light.obs.takeRecords())\n if (record.type === 'attributes') {\n mark((record.target as Kept).$rec?.light ?? light);\n queueMicrotask(flush);\n }\n};\n/** A render is ending (the renderer's `_$done$`): captured children no slot took are parked now, not before. */\nlet ending = false;\n/** Records of this module's own moves, taken and dropped once it is done — they are not news. */\n/** How many nodes this batch has put ahead of everything, per host — so a batch's front insertions keep their order. */\nlet lead = new WeakMap<Light, number>();\n/** Whether THIS light watches `node` — its holding, a region's parent, one of its slots, or its host as a region parent. */\nconst watchedBy = (light: Light, node: Node) =>\n node === light.holding ||\n (node === light.host && light.hw === true) ||\n (node as Kept).$rec?.light === light ||\n light.recs.some((rec) => rec.re !== null && rec.re.parentNode === node);\n/**\n * The top of `node`'s tree as slots sees it: a FILLED slot has stepped out of the page, so from it the walk continues at\n * its region (where it stands in the page) — a slot in another slot's fallback is still the host's, though detached.\n */\nconst topOf = (node: Node) => {\n let at = node;\n for (;;) {\n const rec: Rec | undefined = (at as Kept).$rec;\n const up: Node | null = rec !== undefined && rec.rs !== null && rec.slot === at ? rec.rs : at.parentNode;\n if (up === null) return at;\n at = up;\n }\n};\n/** A slot the user removed: unmounted as the template's own teardown does, inside a flush (its records then dropped). */\n/** Whether `node` is the host's, walking through filled slots to where their regions stand. */\nconst insideHost = (node: Node, host: Element) => {\n for (let at: Node | null = node; at !== null; ) {\n if (at === host) return true;\n const rec: Rec | undefined = (at as Kept).$rec;\n at = rec !== undefined && rec.rs !== null && rec.slot === at ? rec.rs : at.parentNode;\n }\n return false;\n};\nconst handRemoved = (rec: Rec) => {\n unlist(rec);\n unplace(rec);\n mark(rec.light);\n};\n/**\n * A FILLED slot is not in the page (its region stands in its place), so its own `remove()` / `replaceWith()` cannot reach\n * what it shows: these put its content back to holding and the slot back in place first, then do what was asked — the\n * host's observer then finds it gone (`handRemoved`). ONE function each, shared by every slot (`this`, no closure).\n */\nfunction removeSlot(this: Kept) {\n const rec = this.$rec;\n if (rec !== undefined && rec.rs !== null) unplace(rec);\n (this.ownerDocument.defaultView as typeof globalThis).Element.prototype.remove.call(this);\n}\nfunction replaceSlot(this: Kept, ...nodes: (Node | string)[]) {\n const rec = this.$rec;\n if (rec !== undefined && rec.rs !== null) unplace(rec);\n (this.ownerDocument.defaultView as typeof globalThis).Element.prototype.replaceWith.apply(this, nodes);\n}\n/**\n * **A `<slot>` inserted BY HAND** (KNOWN fix, 2026-10-18): claimed as the template's own are, through `slotBehavior.mount`,\n * once the flush that found it is done (the mount flushes its light itself). Only a slot the component's template tree\n * holds counts: one inside the host's LIGHT content is light DOM, as natively it is no slot of this host.\n */\nlet claims: [HTMLSlotElement, Light][] = [];\n/**\n * Claimed in a MICROTASK, never inside the flush that found them: a template's own slot is found by the flush its own\n * `mount` begins with, BEFORE that mount gives it its record — claimed then, it was mounted twice (renderer-slots'\n * three-level chain). A microtask later every mount in progress has finished, and a template slot carries its record\n * (set once, never cleared), so only a slot no template made is claimed — a microtask later, the hand-edit rule.\n */\nlet claimQueued = false;\nconst findSlots = (light: Light, node: Node) => {\n if (node.nodeType !== 1) return;\n const element = node as Element;\n if (element.localName === 'slot') {\n if ((element as Kept).$rec === undefined) claims.push([element as HTMLSlotElement, light]);\n return;\n }\n /** Descendants only when there are any: the template's own small writes (a swapped `<i>`) stay one property read. */\n if (element.firstElementChild === null) return;\n const found = element.getElementsByTagName('slot');\n for (let i = 0; i < found.length; i++) if ((found[i] as Kept).$rec === undefined) claims.push([found[i] as HTMLSlotElement, light]);\n};\n/** Whether `slot` sits in the component's own tree — not inside a light node this module placed or holds. */\nconst ofTemplate = (slot: Node, light: Light) => {\n for (let at = slot.parentNode; at !== null; at = at.parentNode) {\n if (at === light.host) return true;\n if (at === light.holding || PLACED.has(at)) return false;\n }\n return false;\n};\nconst claimInserted = () => {\n claimQueued = false;\n const pending = claims;\n claims = [];\n for (const [slot, light] of pending)\n if ((slot as Kept).$rec === undefined && HOSTS.get(light.host) === light && ofTemplate(slot, light)) slotBehavior.mount(slot, { root: light.host });\n};\n/** The batch's added nodes, looked through for a hand-inserted slot — a pass of its own, so `note` stays small. */\nconst scanAdded = (light: Light, records: MutationRecord[]) => {\n for (const record of records) {\n if (record.type !== 'childList') continue;\n /** Read once: `addedNodes` is a DOM getter. */\n const added = record.addedNodes;\n for (let i = 0, n = added.length; i < n; i++) findSlots(light, added[i]);\n }\n};\nconst note = (light: Light, records: MutationRecord[]) => {\n /** Only a component observed from its first render ('eager') follows a `<slot>` inserted by hand — a lazy one pays nothing. */\n if (light.ex === true) scanAdded(light, records);\n lead = new WeakMap();\n let removed = false;\n for (const record of records) {\n const target: Node = record.target;\n if (record.removedNodes.length > 0) removed = true;\n /** An attribute record names the element: a slot's own name, or a node under something this light watches. */\n if (record.type === 'attributes') {\n const rec = (target as Kept).$rec;\n if (rec !== undefined) {\n mark(rec.light);\n continue;\n }\n /** A light node's own `slot=` — acted on only while it is still THIS light's (a registration stays on a node that left). */\n if (inLight(target, light) || target.parentNode === light.host) mark(light);\n continue;\n }\n /**\n * A watched node's children — holding, a region's parent, a slot — replayed into the runs (the host too, when a region\n * sits directly in it). Any other target in the host's subtree is the component's own template writing: not slotting.\n */\n if (target === light.host ? light.hw === true : watchedBy(light, target)) {\n mark(light);\n replay(light, record);\n }\n /** A host's own children: an addition outside its render's range is a new light child. */\n if (target === light.host) {\n /**\n * Until its first render ends, a run still sits IN the host — so what the renderer takes from it there (a node a slot\n * already took, through its stand-in) is read back as it is in holding. Missed, the stand-in went and its node stayed\n * in the slot: a commit during the host's own render left the old content beside the new.\n *\n * **Why the REMOVED half is the whole of it** — the invariant: while the run is physically in the host, every node the\n * renderer ADDS here lands exactly where the run is, between its own markers, so it is already in place and\n * `lightOf` reads it there (nothing to move; replaying it as a run neighbor would move the render's own markers);\n * every change inside a slot's region — a row added beside a node a slot took (`into` follows `_$slotted$` there),\n * or removed from it — is recorded on that region's parent, which is watched, and replayed in full (into the run\n * where it is — the host, while fresh: see `replay`). What a host\n * record alone can carry is a REMOVED stand-in: the one change that leaves state behind (its node, still in a slot).\n * Additions here are otherwise the render's own or a new light child (`adopt`).\n */\n if (light.fresh) unrun(light, record);\n for (const node of record.addedNodes) adopt(light, node);\n }\n }\n /**\n * **A `<slot>` removed BY HAND** (KNOWN fix, 2026-10-18) — it, or its region, left the host with something the user\n * removed (the slot, its parent, an ancestor). The template's own teardown unmounts a slot before removing it, and a\n * `hold()`-parked one stays registered, so whatever is gone from the host otherwise was removed by hand: unmounted like\n * the template's, its content back to holding, as natively it is unassigned. Checked once per batch that removed\n * anything, over this light's slots.\n */\n if (removed) for (let i = light.recs.length - 1; i >= 0; i--) {\n const rec = light.recs[i];\n const anchor = rec.rs ?? rec.slot;\n if (!insideHost(anchor, light.host) && !PARKED.has(topOf(anchor))) handRemoved(rec);\n }\n};\n/**\n * A `hold()`-parked branch's renames (`parkedObserver`, one for every parked root): routed by the node's own marks — a\n * slot's light, a placed node's slot's light, or the host it sits in — since no per-node watcher list exists any more.\n */\nconst noteParked = (records: MutationRecord[]) => {\n for (const record of records) {\n /**\n * A write into a parked branch (an applier resolving into it, the outer template committing there): it has left its\n * host's subtree, so it is replayed for the host whose render parked it — and only while it is still out (restored, the\n * host's own registration sees it, and replaying it twice would place it twice).\n */\n if (record.type === 'childList') {\n let top: Node = record.target;\n while (top.parentNode !== null) top = top.parentNode;\n const owner = PARKED.get(top);\n const light = owner === undefined ? undefined : HOSTS.get(owner as Element);\n if (light !== undefined && !light.host.contains(record.target) && watchedBy(light, record.target)) {\n mark(light);\n replay(light, record);\n }\n continue;\n }\n for (let node: Node | null = record.target; node !== null; node = node.parentNode) {\n const own = (node as Kept).$rec ?? PLACED.get(node);\n if (own) {\n mark(own.light);\n break;\n }\n const light = HOSTS.get(node as Element);\n if (light !== undefined) {\n mark(light);\n break;\n }\n }\n }\n};\n/**\n * **The lights that need work** — dirty, or fresh until their first render ends, never one waiting for its own slots\n * (`wait`): the only ones `flush` visits. A set of EVERY light ever seen held each removed host for good (a leak) and\n * made every flush walk them all — hydrating 2000 light hosts slowed 72 → 365 ms over ten renders that replaced them.\n * A light leaves once it is clean, or clean and disconnected (a first render that threw stays fresh); it comes back\n * through `mark`, or its own render's end (`_$done$`).\n */\nconst work = new Set<Light>();\n/** The one way a light asks to be distributed. */\nconst mark = (light: Light) => {\n light.dirty = true;\n if (!light.wait) work.add(light);\n};\n/**\n * **Applies what is pending, now** — after every component render, and before any read of the assignment. It reads the\n * records of the lights it can name: its `context` (the light being read, mounted into, or rendered), every light whose\n * element the finished render's `root` created (`FED` — an outer template changing a component's children is\n * distributed by the end of that render), the work set, and the parked branches. Any other light's records arrive at the\n * microtask, through its own observer: a light host changed DIRECTLY by the page's code is redistributed by the next\n * microtask, or at once when its slotted content is read through the slots API (`tests/slots-sync-reads.test.mjs`).\n */\nconst flush = (context?: Light, root?: Node) => {\n if (busy) return;\n const near: Light[] = [];\n if (context !== undefined) near.push(context);\n const fed = root === undefined ? undefined : FED.get(root);\n if (fed !== undefined) {\n /** A plain loop, no closure: an arrow capturing `root` would tax every call of this function (CLAUDE.md, V8). */\n const kept: WeakRef<Element>[] = [];\n const rooted = root!.isConnected;\n for (let i = 0; i < fed.length; i++) {\n const element = fed[i].deref();\n if (element === undefined) continue;\n /**\n * A host that LEFT a connected root is dropped now, not at a collection: a churned list re-filtered an array growing\n * with every removed row until GC (2026-10-18). Put back by hand it is still followed — by its own observer from its\n * first slot (a microtask later; a slots-API read flushes it at once), or by its first slot's reconcile. A render\n * into a DETACHED root keeps every entry (nothing of it is connected). A host moved by hand to another, connected\n * root stays here, distributed at this root's renders too: bounded and harmless.\n */\n if (!element.isConnected && rooted) continue;\n kept.push(fed[i]);\n const light = HOSTS.get(element);\n if (light !== undefined) near.push(light);\n }\n FED.set(root!, kept);\n }\n /** Each light's records, read by that light (they arrive knowing whose they are), then the parked branches'. */\n for (const light of near) note(light, take(light));\n /**\n * The work set's NAME records stay with their callback: distribution reads `slot=` from the DOM as it is, so a rename is\n * only a trigger — and a light being READ (`near`: the slots API, a mount, its own render) takes them now, so a read\n * right after a rename is current (tests/slots-sync-reads.test.mjs). ChildList records are taken in order, always.\n */\n for (const light of work) note(light, take(light, false));\n if (parkedObserver !== undefined) noteParked(parkedObserver.takeRecords());\n for (const light of work) {\n if (light.dirty || (ending && light.fresh)) {\n distribute(light);\n drop(light);\n }\n if (!light.dirty && (!light.fresh || !light.host.isConnected)) work.delete(light);\n }\n /** What this module just moved, recorded on the lights it read: not news. */\n for (const light of near) drop(light);\n if (claims.length > 0 && !claimQueued) {\n claimQueued = true;\n queueMicrotask(claimInserted);\n }\n};\n/** Whether `node` sits outside the host's subtree registration — detached, or inside a slot (which steps out with its content). */\nconst outside = (node: Node, host: Element) => {\n for (let at: Node | null = node; at !== host; at = at.parentNode) if (at === null || (at as Kept).$rec !== undefined) return true;\n return false;\n};\nconst watch = (node: Node, light: Light) => {\n /** The host's own subtree registration covers it; a region directly in the host also gets the region's handling. */\n if (node === light.host) {\n light.hw = true;\n return;\n }\n const observer = observerOf(light);\n /**\n * A slot: its own name only. A slot with content steps OUT of the page, so this is how a rename reaches it there; a\n * nested slot in its fallback is claimed and registered on its own. Re-registering replaces the options, so a node that\n * is also this light's light element keeps `slot=` too (the union; `own`).\n */\n if ((node as Kept).$rec !== undefined) {\n observer.observe(node, { attributes: true, attributeFilter: mineAlready(node) ? ['slot', 'name'] : ['name'] });\n return;\n }\n /** Holding (out of the page while empty) and a region's parent inside a slot's fallback (out with that slot): on themselves. */\n if (node === light.holding || outside(node, light.host)) {\n light.cw = true;\n observer.observe(node, { childList: true });\n }\n};\n/** A light element's own `slot=` — registered when its light is first observed (`register`) and on every arrival after (`adopt`, `replay`, `settleIn`). */\nconst OWN = Symbol();\nconst mineAlready = (node: Node) => (node as Node & { [OWN]?: boolean })[OWN] === true;\nconst own = (light: Light, node: Node) => {\n /** Not before the light is observed (`register`, at its first slot), which registers every light element it has then. */\n if (node.nodeType !== 1 || light.ho !== true) return;\n (node as Node & { [OWN]?: boolean })[OWN] = true;\n observerOf(light).observe(node, { attributes: true, attributeFilter: (node as Kept).$rec !== undefined ? ['slot', 'name'] : ['slot'] });\n};\n\n/**\n * A node added to a host after its render: a light unit, appended in light order — unless it is the render's own. The\n * render's range runs from the host's first comment to its last that is not one of this module's units (captured\n * light children not yet distributed sit before it); comments are never slottable, so none is adopted.\n */\nconst adopt = (light: Light, node: Node) => {\n if (node.nodeType === 8 || node.parentNode !== light.host || node === light.holding) return;\n const ours = new Set<Node>();\n for (const unit of light.units) ours.add(unit.a).add(unit.z);\n if (ours.has(node)) return;\n let first: Node | null = null;\n let last: Node | null = null;\n for (const child of light.host.childNodes)\n if (child.nodeType === 8 && !ours.has(child)) {\n first ??= child;\n last = child;\n }\n if (first !== null && first !== last && follows(first, node) && follows(node, last!))\n return;\n /** Before the render's range is ahead of everything distributed away; after it, behind. Read before it moves. */\n const ahead = first !== null && follows(node, first);\n park(light).insertBefore(node, light.holding!.lastChild);\n PLACED.set(node, null);\n own(light, node);\n if (ahead) {\n const at = lead.get(light) ?? 0;\n light.units.splice(at, 0, { a: node, z: node });\n lead.set(light, at + 1);\n } else light.units.push({ a: node, z: node });\n mark(light);\n};\n\n/** Which unit a light node is in — its own, or (a run's node in a slot) the run its stand-in sits in. */\nconst unitIndexOf = (light: Light, node: Node): number => {\n const stand = STAND.get(node);\n if (stand === undefined) return light.units.findIndex((unit) => unit.a === node);\n return light.units.findIndex(\n (unit) => unit.a !== unit.z && follows(unit.a, stand) && follows(stand, unit.z)\n );\n};\n\n/**\n * A node the USER put inside a slot's region — `slotted.before(node)`, `after()`: a light unit of its own, at that\n * place in light order. (No `mark`: only `replay` reaches here, for a record `note` has already marked the light for.)\n */\nconst settleIn = (light: Light, node: Node) => {\n const parent = node.parentNode;\n if (parent === null || node.nodeType === 8) return;\n for (const rec of light.recs) {\n if (rec.re === null || rec.re.parentNode !== parent) continue;\n if (!follows(rec.rs!, node) || !follows(node, rec.re)) continue;\n let at = -1;\n for (let next = node.nextSibling; next !== null && next !== rec.re && at < 0; next = next.nextSibling) at = unitIndexOf(light, next);\n if (at < 0) light.units.push({ a: node, z: node });\n else light.units.splice(at, 0, { a: node, z: node });\n PLACED.set(node, rec);\n own(light, node);\n return;\n }\n};\n\n/**\n * **What the renderer wrote, read back into the runs.** A run's node in a slot is still the renderer's: an insert\n * before it (a new row), markers around it (a text becoming a template), its move or removal all happen where the\n * node now is. Each lands in the run at the place its neighbor's stand-in holds, so the run stays the renderer's\n * whole range; what has no such neighbor is the user's own edit.\n */\n/**\n * **What the renderer took away from a run, read back** — the removed half of `replay`: a stand-in it removed takes its\n * node with it (cleared with its run) or into the fragment `hold` parked it in; a run's node it removed from a slot drops\n * its place. Called on its own for a host's own records while its first render runs, when a run still sits in the host.\n */\nconst unrun = (light: Light, record: MutationRecord) => {\n /** A reader: nothing can be in a holding not yet built, so `undefined` compares false. */\n const holding = light.holding;\n for (const node of record.removedNodes) {\n const real = REAL.get(node);\n if (real !== undefined) {\n /**\n * A stand-in the renderer took: cleared with its run (its node goes too), or parked by `hold` in a fragment (its\n * node joins it). One the renderer MOVED — beside a node of the run that sits in a slot — is still the run's; its\n * addition, below, puts it back at its new place.\n */\n const parent = node.parentNode;\n if (parent === holding || (parent !== null && parent.nodeType !== 11)) continue;\n if (parent === null) real.parentNode?.removeChild(real);\n else parent.insertBefore(real, node);\n PLACED.delete(real);\n unstand(real);\n } else if (STAND.has(node) && node.parentNode === null) {\n /** A run's node the renderer removed from its slot (a row deleted): its place goes too. */\n PLACED.delete(node);\n unstand(node);\n }\n }\n};\n\nconst replay = (light: Light, record: MutationRecord) => {\n /** A writer (runs move into holding below): built before it is captured. */\n const holding = holdingOf(light);\n unrun(light, record);\n for (const node of record.addedNodes) {\n if (node.parentNode !== record.target) continue;\n if (record.target === holding) {\n /** Back in holding (the renderer moved it before a marker there): its own place now, not its stand-in's. */\n if (STAND.has(node)) {\n PLACED.delete(node);\n unstand(node);\n }\n /** A run's node written straight into holding (a row the outer template inserted) is a light node from now on. */\n own(light, node);\n continue;\n }\n if (PLACED.get(node) !== undefined && !STAND.has(node)) continue;\n const next = record.nextSibling;\n const previous = record.previousSibling;\n /** Where the runs are: holding — and, until the host's first render ends, the host, where a fresh run still sits. */\n const inRun = (node: Node) => node.parentNode === holding || (light.fresh && node.parentNode === light.host);\n const ahead = next === null ? undefined : (STAND.get(next) ?? (inRun(next) ? next : undefined));\n const behind = previous === null ? undefined : (STAND.get(previous) ?? (inRun(previous) ? previous : undefined));\n if (ahead === undefined && behind === undefined) {\n settleIn(light, node);\n continue;\n }\n const place = ahead ?? behind!.nextSibling;\n /**\n * A run's node moved within the page: its place in the run moves. New to the run: it joins it, at that place — in\n * whatever holds the run: holding, or (until its host's first render ends) the HOST itself, where a fresh run still\n * sits. Inserted into holding regardless, a node new to a fresh run threw there and was left in the slot unrecorded.\n */\n const stand = STAND.get(node);\n const run = place === null ? holding : place.parentNode!;\n (run === holding && stand === undefined ? park(light) : run).insertBefore(stand ?? node, place);\n own(light, node);\n }\n};\n\n/** A captured host that turned out to have a shadow root: its children go back, in light order, for the platform. */\nconst release = (light: Light) => {\n for (const unit of light.units) {\n if (unit.a === unit.z) {\n move(light.host, unit.a, null);\n continue;\n }\n for (let node = unit.a.nextSibling; node !== null && node !== unit.z; ) {\n const next = node.nextSibling;\n light.host.appendChild(REAL.get(node) ?? node);\n node = next;\n }\n }\n light.holding?.remove();\n HOSTS.delete(light.host);\n work.delete(light);\n /**\n * Its observer goes with it. Bound to its light, it would otherwise keep handling the host's records as this light's\n * — adopting the platform's own light children into a holding that no longer exists (renderer-slots' native-sequence\n * row, 2026-10-17). Before the binding, a released light's records were simply not found and dropped.\n */\n light.obs?.disconnect();\n light.obs = undefined;\n};\n\n\n/* ── capture ───────────────────────────────────────────────────────────────────────────────────── */\n\n/**\n * **A light's childList registrations, once its first render has ENDED** (observer redesign, 2026-10-17).\n * ONE over the host's subtree — its own children and every region and slot inside it: what native slotting reacts to,\n * wherever it sits, so a region's parent needs no registration of its own — and its holding (out of the page while empty).\n * Not before: the first render's own writes would make a record each for nothing (`reconcile` covers that window).\n * Attribute changes are registered per NODE (`own`, a slot's `name` in `watch`): one subtree attribute registration made\n * Firefox check every attribute write inside the host (−17.7% of light-slots creation).\n */\nconst register = (light: Light) => {\n if (light.ho === true) return;\n light.ho = true;\n observerOf(light).observe(light.host, { childList: true, subtree: true });\n for (const node of lightOf(light)) own(light, node);\n /**\n * A light with a RUN (a part an outer template writes into, for as long as the host lives) has its holding watched\n * from now — the run moves there, and is written into there, even while holding holds nothing else. One with static\n * light children only is watched once something is parked (`park`), or never.\n */\n if (\n /** `hydrate-slots` writes runs straight into holding and relies on it being watched (hydrate-slots.ts, \"holding is watched\"). */\n (wired as { _$hydrateSlots$?: unknown } | undefined)?._$hydrateSlots$ !== undefined ||\n light.units.some((unit) => unit.a !== unit.z) ||\n (light.holding?.childNodes.length ?? 0) > 2\n )\n watchHolding(light);\n};\n/**\n * **Holding, watched once anything lives in it** — a run's markers and stand-ins, or a parked node — since the outer\n * template keeps writing into a run there, in or out of the page. An empty holding (every light node took a slot) is\n * never written into, so it costs no registration (2026-10-17).\n */\nconst watchHolding = (light: Light) => {\n if (light.ho !== true || light.hh === true) return;\n light.hh = true;\n watch(holdingOf(light), light);\n};\n/**\n * **What changed while a light was not yet observed — its first render** — read off the DOM once, at that render's end\n * (3c): who made the change does not matter, the renderer or user code (a child's `connectedCallback`, a\n * directive). A stand-in gone takes its node with it, as `unrun` does for a removal record; a host child nothing knows\n * of is a light child added meanwhile (`adopt`) — unless it is the render's own (between its markers: `adopt` checks the\n * range), one of the captured units, or a member of a captured run.\n */\nconst reconcile = (light: Light) => {\n for (const rec of light.recs)\n for (const node of [...rec.shown]) {\n const stand = STAND.get(node);\n if (stand === undefined) continue;\n if (node.parentNode === null) {\n PLACED.delete(node);\n unstand(node);\n continue;\n }\n const parent = stand.parentNode;\n if (parent === null) node.parentNode.removeChild(node);\n else if (parent.nodeType === 11) parent.insertBefore(node, stand);\n else continue;\n PLACED.delete(node);\n unstand(node);\n }\n /**\n * A node written INTO a slot's region meanwhile — a keyed row inserted beside a slotted neighbor follows it there\n * (`into`) — is handed to `replay` as the record it would have been: its parent, itself, its neighbors now.\n */\n for (const rec of light.recs) {\n if (rec.rs === null || rec.re === null) continue;\n for (let node = rec.rs.nextSibling; node !== null && node !== rec.re; ) {\n const next = node.nextSibling;\n if (!PLACED.has(node) && node.nodeType !== 8)\n replay(light, { type: 'childList', target: rec.re.parentNode!, addedNodes: [node] as unknown as NodeList, removedNodes: [] as unknown as NodeList, previousSibling: node.previousSibling, nextSibling: node.nextSibling } as unknown as MutationRecord);\n node = next;\n }\n }\n const host = light.host;\n /** The render's range, once: its first and last comment that is not a captured unit's (as `adopt` reads it). */\n const ours = new Set<Node>();\n for (const unit of light.units) ours.add(unit.a).add(unit.z);\n let first: Node | null = null;\n let last: Node | null = null;\n for (let child = host.firstChild; child !== null; child = child.nextSibling)\n if (child.nodeType === 8 && !ours.has(child)) {\n first ??= child;\n last = child;\n }\n const ranged = first !== null && first !== last;\n for (const child of [...host.childNodes]) {\n if (child.nodeType === 8 || child === light.holding || ours.has(child) || PLACED.has(child)) continue;\n if (ranged && follows(first!, child) && follows(child, last!)) continue;\n if (light.units.some((unit) => unit.a !== unit.z && follows(unit.a, child) && follows(child, unit.z))) continue;\n adopt(light, child);\n }\n};\n/** A host's light record, new: its holding (bracketed by two comments, so `lastChild` is always an anchor), watched. */\n/**\n * **`node.assignedSlot`, answered for light slots** (Brian, 2026-10-18: race it). The platform's getter knows only shadow\n * roots; ONE getter replaces it on the prototypes that define it (the Slottable mixin: `Element`, `Text`), per window,\n * at that window's first light host. It answers from `PLACED` — what distribution already records, so nothing is written\n * per node — for a node this copy placed in a slot's region, and otherwise defers to the getter it replaced (native, or\n * another copy's), so shadow-DOM nodes and other copies answer as before. Never on a server: no window with these\n * prototypes, nothing installed.\n */\nconst PATCHED = Symbol();\nconst answerAssigned = (win: typeof globalThis) => {\n const marked = win as unknown as { [PATCHED]?: true };\n if (marked[PATCHED] === true) return;\n marked[PATCHED] = true;\n for (const proto of [win.Element?.prototype, win.Text?.prototype]) {\n const before = proto === undefined ? undefined : Object.getOwnPropertyDescriptor(proto, 'assignedSlot');\n const native = before?.get;\n /** Where the platform puts no getter of its own, nothing is defined there (development says so): never a fresh property. */\n if (native === undefined) {\n if (__DEV__ && proto !== undefined) console.warn(diagnostic('slots', 'assignedSlot', 'assigned-slot-unpatched', __DEV__ && PROSE['assigned-slot-unpatched'](proto === win.Text?.prototype ? 'Text' : 'Element')));\n continue;\n }\n Object.defineProperty(proto, 'assignedSlot', {\n configurable: true,\n enumerable: before!.enumerable,\n get(this: Node) {\n const rec = PLACED.get(this);\n return rec !== undefined && rec !== null && rec !== ADOPTED ? (rec as Rec).slot : native.call(this);\n },\n });\n }\n};\n/**\n * **Holding, built at its FIRST use** (2026-10-18): a host whose light children are all assigned never needs it, and\n * building it for every host was ~82 ms of Chrome's slotted creation at 10 000 hosts. Every WRITER goes through here;\n * readers compare against `light.holding`, which is simply `undefined` until then — nothing can be in it.\n */\nconst dress = (holding: HTMLElement) => {\n const doc = holding.ownerDocument;\n holding.setAttribute('hidden', '');\n holding.setAttribute(UNASSIGNED, '');\n /**\n * `hidden` is only the UA's `display: none`, and any author rule that sets `display` beats it — a reset, a design\n * system's `:where(*)`, a `[hidden]` override — and unassigned content would RENDER. An inline `!important` beats every\n * author stylesheet; written through CSSOM, which a strict CSP does not block (served markup carries `hidden` only).\n */\n holding.style.setProperty('display', 'none', 'important');\n holding.insertBefore(doc.createComment(''), holding.firstChild);\n holding.append(doc.createComment(''));\n return holding;\n};\nconst holdingOf = (light: Light): HTMLElement => (light.holding ??= dress(light.host.ownerDocument.createElement('ins')));\n/**\n * The capture hydration is handed: hydrate-slots writes a served host's runs straight into holding (and reads its\n * anchors), so a light captured through the protocol has its holding built at once — a client-only light builds it lazily.\n */\n/** The lights hydration reads: each with its holding built (it reads the anchors), whichever capture made it. */\nconst SERVED_HOSTS = {\n get: (host: Element) => {\n const light = HOSTS.get(host);\n if (light !== undefined) holdingOf(light);\n return light;\n },\n has: (host: Element) => HOSTS.has(host),\n};\nconst captureServed: typeof capture = (...args) => {\n const light = capture(...args);\n holdingOf(light);\n return light;\n};\nconst lightFor = (host: Element, late: boolean, carrier: HTMLElement | null = null): Light => {\n const doc = host.ownerDocument;\n const win = doc.defaultView as typeof globalThis | null;\n if (win !== null) answerAssigned(win);\n arm();\n /** The server's carrier, adopted at once; otherwise holding is built at its first use (`holdingOf`). */\n const light: Light = { host, units: [], holding: carrier === null ? undefined : dress(carrier), recs: [], dirty: false, fresh: false, late, wait: false };\n HOSTS.set(host, light);\n return light;\n};\n\n/**\n * **Capture**, at `init` — before the host's first render, when everything it holds is the page's. Each static child\n * is a unit; each run between statics (what the page's template bound there) is one unit, wrapped in this module's\n * two comments so its extent survives whatever the renderer writes inside it.\n *\n * `nodes` and `carrier` are hydration's (`_$capture$`): a served host's light children in light order, wherever the server\n * distributed them, and the server's unassigned container, which becomes the holding. A node captured in a slot's region\n * stays there (`ADOPTED`) — distribution then moves only what is out of place, so the server's placement decides at most\n * WHETHER a node moves, never where it ends up.\n */\nconst capture = (host: Element, before: Node | null = null, nodes: Node[] = [...host.childNodes], carrier: HTMLElement | null = null, wait = false): Light => {\n let light = HOSTS.get(host);\n /** A slot of a custom element `init` never saw mounted first: its light content arrives now, at the render's end. */\n if (light !== undefined && !light.late) return light;\n const doc = host.ownerDocument;\n light ??= lightFor(host, false, carrier);\n light.late = false;\n const statics = STATICS.get(host);\n let run: Node[] | null = null;\n /**\n * Recorded, not moved: the children stay where the page put them — in the host, as they would under a shadow root —\n * until the host's first render finishes, which distributes them (the ones no slot takes, invisibly to holding).\n */\n const close = () => {\n if (run === null) return;\n const a = doc.createComment('');\n const z = doc.createComment('');\n host.insertBefore(a, run[0]);\n host.insertBefore(z, run[run.length - 1].nextSibling);\n light!.units.push({ a, z });\n run = null;\n };\n for (const child of nodes) {\n /** At a first render's end, only what precedes the render's own range is light content. */\n if (child === before) break;\n const parent = child.parentNode;\n if (parent !== host) PLACED.set(child, parent === light.holding ? null : ADOPTED);\n own(light, child);\n if (statics === undefined || statics.has(child)) {\n close();\n light.units.push({ a: child, z: child });\n } else (run ??= []).push(child);\n }\n close();\n /**\n * `wait`: captured by a template that placed content into this host (hydration), not by the host — nothing is\n * distributed until the host's own slots mount, so a host never defined keeps its nodes where they stand.\n */\n if (wait) light.wait = true;\n else {\n light.fresh = true;\n mark(light);\n }\n return light;\n};\n\n/**\n * **A dashed element in a template is told it was created** — before the page's template commits into it — so the\n * children it has then are exactly its statics: a binding position is still the empty text the template parsed it\n * as. Recorded by node; `init` capture reads it.\n */\n/**\n * **Which elements each render root's templates created** — so that root's render end reads their lights' records too:\n * a host whose light children an OUTER template changed is distributed by the end of that render, synchronously, though\n * it has an observer of its own (Gecko's `observe()` is linear in its observer's registrations, so none is shared).\n * Weak both ways: a root or an element gone takes its entries with it, and a dead ref is dropped by the read itself.\n */\nconst FED = new WeakMap<Node, WeakRef<Element>[]>();\n/**\n * Only for a dashed element its TEMPLATE gives children (slot-discovery decides once per template, at preparation): no\n * outer template can write into one it gives none, so there is nothing to record — an app's list of `<x-row></x-row>`\n * paid a child scan and a Set per row at create, and a WeakRef per row in its root's `FED` at mount, which that root's\n * every render then filtered (wiring slots made such a list ~9× slower to create, 2026-10-17).\n */\nconst hostBehavior = {\n mount: (element: Element, { root }: { root: Node | null }) => {\n if (root === null) return;\n let fed = FED.get(root);\n if (fed === undefined) {\n arm();\n FED.set(root, (fed = []));\n }\n fed.push(new WeakRef(element));\n },\n create: (element: Element, adopted: boolean) => {\n if (adopted) return;\n const statics = new Set<Node>();\n let hole = false;\n for (const child of [...element.childNodes]) {\n const placeholder = child.nodeType === 3 && (child as Text).data === '';\n /**\n * Two bindings written back to back (`${a}${b}`) have nothing static between them, so their runs would join into\n * one unit: a comment of this module's goes between them — every binding is its own unit.\n */\n if (placeholder && hole) {\n const between = element.ownerDocument.createComment('');\n element.insertBefore(between, child);\n statics.add(between);\n }\n if (!placeholder) statics.add(child);\n hole = placeholder;\n }\n STATICS.set(element, statics);\n },\n};\n\n/* ── the slot element ──────────────────────────────────────────────────────────────────────────── */\n\n/**\n * The `<slot>` element's own answers, from the live assignment (a slot outside a shadow tree answers nothing). With\n * `flatten`, an unassigned slot answers its fallback's slottables, a nested slot through itself.\n */\nconst assigned = (rec: Rec, elementsOnly: boolean, flatten = false): Node[] => {\n flush(rec.light);\n const out = rec.shown.filter((node) => !elementsOnly || node.nodeType === 1);\n /** The fallback is read only when NOTHING is assigned — assigned text with no element still answers [] for elements. */\n if (rec.shown.length > 0 || !flatten) return out;\n for (const node of rec.slot.childNodes) {\n const nested = (node as Kept).$rec;\n if (nested !== undefined) out.push(...assigned(nested, elementsOnly, true));\n else if (node.nodeType === 1 && (node as Element).localName === 'slot') continue;\n else if (node.nodeType === 1 || (!elementsOnly && node.nodeType === 3)) out.push(node);\n }\n /** A nested slot whose content stands in its place is read where it stands. */\n return out;\n};\n\nconst slotBehavior = {\n mount: (slot: Element, context: { root: Node | null }) => {\n const root = context.root;\n /**\n * A shadow root distributes natively; only a light host (an element rendered into) is this module's. A host\n * captured at `init` that then rendered into a shadow root of its own gets its children back, for the platform.\n */\n if (root !== null && root.nodeType === 11) {\n const owner = HOSTS.get((root as ShadowRoot).host);\n if (owner !== undefined && owner.recs.length === 0) release(owner);\n }\n if (root === null || root.nodeType !== 1) return undefined;\n if (__DEV__) {\n const inert = [...slot.attributes].map((attribute) => attribute.name).filter((name) => name !== 'name');\n if (inert.length > 0)\n console.warn(\n diagnostic('slots', `<${(root as Element).localName}>`, 'slot-attributes',\n __DEV__ && PROSE['slot-attributes'](`<slot${slot.hasAttribute('name') ? ` name=\"${slot.getAttribute('name')}\"` : ''}>`, inert.map((name) => `\\`${name}\\``).join(', ')))\n );\n }\n /** A host `init` never saw has no captured children: what it holds now is its own render, never light content. */\n /** Its own light's records first: what the user did to it this task is noted before this module's moves, which are dropped. */\n flush(HOSTS.get(root as Element));\n const light = HOSTS.get(root as Element) ?? lightFor(root as Element, isCustomElementName((root as Element).localName));\n const kept = slot as Kept;\n const rec: Rec = { slot: kept, light, rs: null, re: null, shown: [], queued: false };\n kept.$rec = rec;\n /** A region handed over (hydration: the server's two markers) IS this slot's region, and what is between them stays. */\n const served = kept._$region$;\n if (served !== undefined) {\n kept._$region$ = undefined;\n [rec.rs, rec.re] = served;\n for (let node = rec.rs.nextSibling!; node !== rec.re; node = node.nextSibling!) {\n PLACED.set(node, rec);\n (node as Node & { _$slotted$?: boolean })._$slotted$ = true;\n }\n watch(rec.re.parentNode!, light);\n }\n kept.assignedNodes = (options?: AssignedNodesOptions) => assigned(rec, false, options?.flatten);\n kept.remove = removeSlot;\n kept.replaceWith = replaceSlot;\n kept.assignedElements = (options?: AssignedNodesOptions) => assigned(rec, true, options?.flatten) as Element[];\n light.recs.push(rec);\n light.wait = false;\n watch(kept, light);\n distribute(light);\n drop(light);\n /**\n * Its FIRST slot, after its first render — in a later render of its own, or in ANOTHER container's (an applier\n * committing there, which never reaches this host's `_$done$`): once that render is over — a microtask, which no\n * render is ever halfway through — read what changed while it was unobserved, and observe it from then. Inside its\n * first render, its own `_$done$` does both.\n */\n if (!light.fresh && light.ho !== true)\n queueMicrotask(() => {\n if (light.ho === true || HOSTS.get(light.host) !== light) return;\n reconcile(light);\n flush(light);\n register(light);\n });\n return rec;\n },\n /** Torn down: its content goes back to holding first, and the element back in its place, before the renderer removes it. */\n unmount: (rec: Rec) => {\n flush(rec.light);\n unlist(rec);\n unplace(rec);\n distribute(rec.light);\n drop(rec.light);\n },\n};\n\n/**\n * **The render-end hook, installed at the first thing that needs it** (2026-10-18): until then the renderer's\n * `_$done$` read finds `undefined` and every render ends without calling slots — a page that wired slots but has nothing\n * slotted yet pays nothing per render. Armed by the first light (`lightFor`), the first host a template feeds (FED), the\n * first park, and the first render of a dashed element that already holds something (`unadopted`, the renderer-alone path,\n * which captures at render end).\n */\nlet done: ((container: Node, start: Node) => void) | undefined;\nlet doneOn: { _$done$?: unknown } | undefined;\nconst arm = () => {\n if (doneOn !== undefined && doneOn._$done$ !== done) doneOn._$done$ = done;\n};\n/**\n * **A served light host whose first render nothing adopts** — the renderer asks (`_$unadopted$`) before that render\n * would APPEND beside the server's markup: two copies, the server's dead. The server states every host it renders while\n * slots is wired (`data-vm-light`): stated EMPTY (`N:`), the host holds nothing of the page's, so the server's render\n * is cleared (its SSR stylesheets kept) and the client renders fresh — working, without the server's head start; stated\n * with light content, that content cannot be told from the server's render without `hydrateSlots`, so the host stands\n * as served and the coded error names what to wire. Development warns once per page.\n */\nconst unadopted = (container: Node) => {\n if (container.nodeType === 1 && isCustomElementName((container as Element).localName)) arm();\n /** Asked only for a container with something in it (the renderer skips an empty one: no server markup to append beside). */\n const spec = container.nodeType === 1 ? (container as Element).getAttribute(LIGHT_ATTR) : null;\n if (spec === null) return;\n if (!spec.endsWith(':'))\n /**\n * A WIRING state, not a misused argument, so the diagnostic shape (`[vera] slots: <host> — …`), not `misuse()`'s.\n * Production keeps its own short line, which already carries the code: the code-and-link shape measured +18 B on\n * vera-renderer-slots.min.js (Brian's byte rule, 2026-10-09 — a production message converts only where its bundle\n * is not larger). Development's text is the table's.\n */\n throw new Error(\n __DEV__\n ? diagnostic('slots', `<${(container as Element).localName}>`, 'hydration-unwired', __DEV__ && PROSE['hydration-unwired'](\"this light host, holding the page's content, stands as served\"))\n : '[vera] hydration-unwired'\n );\n for (let node = container.firstChild; node !== null; ) {\n const next: ChildNode | null = node.nextSibling;\n if (node.nodeType !== 1 || !(node as Element).hasAttribute('data-vm-sheet')) container.removeChild(node);\n node = next;\n }\n (container as Element).removeAttribute(LIGHT_ATTR);\n if (__DEV__)\n warnOnce('slots', 'the page', 'hydration-unwired', __DEV__ && (() => PROSE['hydration-unwired']('its components re-render on the client instead of adopting the server markup')));\n};\n\n/** A light host's children in light order, as its record holds them — what a template placing content into it adopts. */\nconst lightNodes = (host: Element): Node[] | null => {\n const light = HOSTS.get(host);\n if (light === undefined) return null;\n flush(light);\n return lightOf(light);\n};\n\n/** The slotted nodes a light host shows in its slot of `name` — or a shadow host's, from the platform. */\nexport const slotted = (host: Element, name = ''): Node[] => {\n const light = HOSTS.get(host);\n if (light !== undefined) {\n flush(light);\n for (const rec of light.recs) if ((rec.slot.getAttribute('name') ?? '') === name && rec.shown.length > 0) return [...rec.shown];\n /** Unassigned, a node still belongs to the host: it waits in holding for a slot of its name. */\n return lightOf(light).filter((node) => slotNameOf(node) === name);\n }\n /**\n * Core's `_$r$` first: a CLOSED root is null through `shadowRoot`, and core keeps the root it attached under that\n * sigiled name in both modes (`@verajs/styles` reads it the same way); no mangling regex matches a sigil.\n * Names are compared, never put in a selector — a quote in one would throw.\n */\n const root = (host as unknown as Record<string, ShadowRoot | null | undefined>)['_$r$'] ?? host.shadowRoot;\n const slot = [...(root?.querySelectorAll('slot') ?? [])].find((s) => (s.getAttribute('name') ?? '') === name);\n return slot === undefined ? [] : slot.assignedNodes();\n};\n\nconst LIGHT_ATTR = 'data-vm-light';\n\n/**\n * Whether hydration is wired — it marks the registry (`_$hydrating$`) when it installs, which may be before or after this\n * module: a served host (`data-vm-light`) is then captured by the adoption, never by `init`'s capture.\n */\nlet wired: { _$hydrating$?: boolean } | null = null;\n\n/**\n * **The `'slot'` insert: a marker** — `@verajs/ssr` distributes light hosts on the server exactly while it is wired. The\n * client claims each `<slot>` through `'element'`, so the function is never called here.\n */\nconst serve = { name: '@verajs/renderer/slots', on: 'slot' as const, fn: () => null, priority: 50 };\n\n/** Discovery: `<slot>` elements and dashed hosts claimed in templates, through `elements`. */\n/**\n * **`observeSlots: 'lazy' | 'eager'`** (paired as HTML's `loading` pairs them) — a component's own option\n * (`init({ host, observeSlots: 'eager' }, …)`, `define({ tag, observeSlots })`), else the app's default\n * (`slots({ observeSlots: 'eager' })`), else `'lazy'`; resolved ONCE here and kept on the light.\n * - `'lazy'`: observed from its first `<slot>` or light child, and a component with neither gets nothing at all (wiring\n * slots made plain components 2.1–2.7× slower to create when every one was captured and observed). Fully correct for\n * everything a template renders.\n * - `'eager'`: captured and observed from its first render, so a child appended by hand before any slot renders is\n * hidden and a `<slot>` inserted by hand is seen — what native shadow DOM does for every host, at an observer per\n * component.\n */\n/**\n * Development: `observeSlots` is `'lazy'` or `'eager'`; anything else reads as `'lazy'` — the BUILT-IN default, even where\n * the app's default is `'eager'`, as core does for `foreignNodes` — and says so.\n */\nconst checkObserve = (subject: string, value: unknown) => {\n if (value !== undefined && value !== 'lazy' && value !== 'eager')\n console.warn(diagnostic('slots', subject, 'observe-slots-option', __DEV__ && PROSE['observe-slots-option'](typeof value === 'string' ? `'${value}'` : String(value))));\n};\nconst captureAtInit = (element: Element, options: object | undefined) => {\n const own = (options as { observeSlots?: unknown } | undefined)?.observeSlots;\n if (__DEV__) checkObserve(`<${element.localName}>`, own);\n const eager = (own !== undefined ? own : (wired as { _$observeSlots$?: unknown } | undefined)?._$observeSlots$) === 'eager';\n /** Nothing to hide and nothing expected (the cheap tests first — they settle every plain component). */\n if (element.firstChild === null && !eager) return;\n /**\n * A SHADOW host distributes natively: core attaches its root before this insert runs and keeps it under the\n * unmangled `_root` (a closed root is null through `shadowRoot`), quoted so this bundle's mangling leaves it alone.\n */\n if ((element as unknown as Record<string, unknown>)['_$r$'] != null || element.shadowRoot !== null) return;\n /** A SERVER host waits: whether its marks are trusted is the following render's to decide (`read`, under adoption). */\n if (isCustomElementName(element.localName) && !HOSTS.has(element) && !(wired?._$hydrating$ === true && element.hasAttribute(LIGHT_ATTR))) {\n const light = capture(element);\n if (eager) light.ex = true;\n }\n};\n/** Development: the option key this hook reads, so core's unknown-option check accepts it (`$keys` sits on the FUNCTION). */\nif (__DEV__) Object.assign(captureAtInit, { $keys: ['observeSlots'], $module: '@verajs/renderer/slots' });\n\nexport const slotDiscovery = [\n elements,\n /**\n * **Capture at `init`** — core's insert point, before the component's first render, when everything a CUSTOM element\n * (a dash, not a reserved SVG/MathML name) holds is the page's: its light content, captured even if its `<slot>`\n * arrives later. Once per host: a reconnect finds it captured and its render untouched.\n */\n {\n name: '@verajs/renderer/slots-capture',\n on: 'init' as const,\n fn: captureAtInit,\n priority: 10,\n },\n {\n name: '@verajs/renderer/slot-discovery',\n on: 'element' as const,\n fn: (el: Element) =>\n el.localName === 'slot' ? slotBehavior : el.firstChild !== null && isCustomElementName(el.localName) ? hostBehavior : undefined,\n priority: 10,\n },\n /**\n * **After every render** — the renderer says when one finishes (`_$done$`, off-chain like `$t`), and what it did to a\n * light host's children is distributed before anything reads them.\n */\n (registry: Map<string, unknown[]>) => {\n /** Hydration's seam — off-chain like `_$done$`, stamped with this package's seam protocol: capture a served host. */\n wired = registry as unknown as { _$hydrating$?: boolean };\n (registry as unknown as { _$capture$?: unknown })._$capture$ = [PROTOCOL, captureServed, lightNodes, SERVED_HOSTS, standIn, PLACED, ADOPTED];\n (registry as unknown as { _$unadopted$?: (container: Node) => void })._$unadopted$ = unadopted;\n (registry as unknown as { _$parked$?: (root: Node, owner: Node | null) => void })._$parked$ = (root, owner) => {\n arm();\n if (owner !== null) PARKED.set(root, owner);\n (parkedObserver ??= new (globalThis.MutationObserver ?? (root.ownerDocument!.defaultView as typeof globalThis).MutationObserver)(parkedHandle)).observe(root, {\n attributes: true,\n attributeFilter: ['slot'],\n childList: true,\n subtree: true,\n });\n };\n /** Development only: how many lights wait for work — 0 once every rendered host is distributed (a retention pin). */\n if (__DEV__) (registry as unknown as { _$slotsWork$?: () => number })._$slotsWork$ = () => work.size;\n /** Development only: how many hosts a root's renders have fed, as recorded — bounded by its live rows (a growth pin). */\n if (__DEV__) (registry as unknown as { _$slotsFed$?: (root: Node) => number })._$slotsFed$ = (root) => FED.get(root)?.length ?? 0;\n doneOn = registry as unknown as { _$done$?: unknown };\n done = (container: Node, start: Node) => {\n /**\n * A CUSTOM element rendered into that `init` never captured (the renderer used on its own, without core): what it\n * held before its first render's range is its light content — Brian's ruling 4, custom elements by their name.\n */\n let own = HOSTS.get(container as Element);\n if (container.nodeType === 1 && (own?.late ?? container.firstChild !== start) && (container as Element).shadowRoot === null && isCustomElementName((container as Element).localName)) {\n capture(container as Element, start);\n own = HOSTS.get(container as Element);\n }\n /**\n * Nothing of this module's here — no light, nothing waiting, no host this render fed, nothing parked: the render of\n * every component that needs no slotting ends here (a full `flush` per render was most of what wiring slots still\n * cost a plain component in Firefox).\n */\n if (own === undefined && work.size === 0 && parkedObserver === undefined && FED.get(container) === undefined) return;\n /** Its own render ended: a fresh light that left the work set (disconnected meanwhile) is distributed now. */\n if (own?.fresh && !own.wait) work.add(own);\n /**\n * Unobserved until it has a slot: what changed meanwhile is read once — at its first render's end, and at the end of\n * the render that mounted its first slot — before the distribution below. A light with no slot shows nothing, so\n * nothing about it needs following until then.\n */\n const slotted = own !== undefined && own.recs.length > 0;\n if (own !== undefined && own.ho !== true && (own.fresh || slotted)) reconcile(own);\n ending = true;\n try {\n flush(own, container);\n } finally {\n ending = false;\n }\n /** Observed from here on — after this module's own moves above, which then make no records. */\n if (own !== undefined && own.ho !== true && (slotted || own.ex === true)) register(own);\n };\n /** A page whose components never needed slotting keeps `_$done$` undefined: their renders never call into slots. */\n },\n];\n\nconst parts = [slotDiscovery, serve];\n/** What `wire` hands a connector: the registry (told apart from options by its `get`) and `wire` itself. */\ntype Registry = { get(name: never): unknown };\ntype Wire = (item: never) => void;\ntype ObserveSlots = 'lazy' | 'eager';\ntype SlotsOptions = { observeSlots?: ObserveSlots };\ntype SlotsConnector = (registry: Registry, wire: Wire) => void;\n/** Two call signatures: as `wire` calls it (bare), and as an app calls it (with options) — both a module to `wire`. */\ntype SlotsModule = { (options?: SlotsOptions): SlotsConnector; (registry: Registry, wire: Wire): void };\n/**\n * **`slots` is a DUAL** — `wire([renderer, slots])`, or `wire([renderer, slots({ observeSlots: 'eager' })])` to make\n * observing from the first render every light component's default (a component's own `observeSlots` wins either way). Bare, `wire` hands it the\n * registry and `wire` itself, and it wires its parts; called, it returns a connector doing the same and writing the\n * default on that registry — two cores on one page keep their own.\n */\n/**\n * A `wire` that hands a connector only the registry — a core older than this module, or code calling connectors itself —\n * can wire nothing of slots: said, in both builds, rather than leaving every slot quietly undistributed.\n */\nconst tooOld = () => {\n throw new Error(__DEV__ ? diagnostic('slots', 'wire([slots])', 'slots-wire-too-old', __DEV__ && PROSE['slots-wire-too-old']()) : '[vera] slots-wire-too-old');\n};\nexport const slots = ((given?: SlotsOptions | Registry, w?: (item: unknown) => void): SlotsConnector | undefined => {\n /** Told apart by the REGISTRY (its `get`), as the module rule says — never by whether a second argument came. */\n if (typeof (given as Registry | undefined)?.get === 'function') {\n if (typeof w !== 'function') tooOld();\n w!(parts);\n return undefined;\n }\n const options = given as SlotsOptions | undefined;\n if (__DEV__) {\n for (const key in options) if (key !== 'observeSlots') console.warn(diagnostic('slots', 'slots()', 'unknown-option', __DEV__ && SHARED.unknownOption(key, 'observeSlots')));\n checkObserve('slots()', options?.observeSlots);\n }\n const observe = options?.observeSlots;\n return (registry, wire) => {\n if (typeof wire !== 'function') tooOld();\n (wire as (item: unknown) => void)(parts);\n if (observe !== undefined) (registry as unknown as { _$observeSlots$?: unknown })._$observeSlots$ = observe;\n };\n}) as SlotsModule;\n\n/** Its option's type, where slots is imported: `init({ host, observeSlots: 'eager' }, …)` (core's `VeraInitOptions`). */\ndeclare global {\n // eslint-disable-next-line no-restricted-syntax -- merging IS the point: slots adds its key to core's options\n interface VeraInitOptions {\n observeSlots?: 'lazy' | 'eager';\n }\n}\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"],"names":["RESERVED_ELEMENT_NAMES","Set","isCustomElementName","tag","includes","has","toLowerCase","registered","report","error","root","line","handlers","element","length","handler","reportError","console","reportUncaught","reportTo","get","undefined","nodeType","host","hostOf","firstIn","firstElementChild","nextIn","node","at","parentElement","nextElementSibling","elements","registry","name","on","fn","built","_result","_readScope","claims","template","positions","behaviors","i","behavior","push","_$inst$","$c","instance","adopted","found","listed","Array","isArray","k","create","f","r","a","d","$m","given","state","context","value","mount","unmount","$q","kept","hookFor","priority","slotNameOf","getAttribute","park","light","holding","holdingOf","parentNode","insertBefore","firstChild","watchHolding","LIGHT","Symbol","HOSTS","STATICS","WeakMap","STAND","REAL","PLACED","ADOPTED","lightOf","out","unit","units","z","nextSibling","unstand","stand","delete","remove","firstOf","$rec","rs","lastOf","re","move","parent","ref","last","next","standIn","ownerDocument","createComment","set","toHolding","lastChild","chain","rec","slot","unshift","contains","outer","follows","b","compareDocumentPosition","region","doc","removeChild","watch","unregion","unplace","unlist","recs","splice","indexOf","changed","queued","queueMicrotask","dispatchEvent","defaultView","bubbles","composed","inLight","busy","distribute","mark","place","dirty","fresh","ending","home","filter","isWhere","real","live","parked","add","sort","x","y","before","winner","Map","nodes","statics","wanted","taken","list","mine","previous","first","previousSibling","_$slotted$","shown","some","run","unpark","observerOf","Observer","globalThis","MutationObserver","obs","records","note","flush","parkedObserver","PARKED","parkedHandle","noteParked","take","all","ho","cw","takeRecords","drop","record","type","target","lead","watchedBy","hw","topOf","up","insideHost","handRemoved","removeSlot","this","Element","prototype","call","replaceSlot","replaceWith","apply","claimQueued","findSlots","localName","getElementsByTagName","ofTemplate","claimInserted","pending","slotBehavior","ex","added","addedNodes","n","scanAdded","removed","removedNodes","replay","unrun","adopt","anchor","own","top","owner","work","wait","near","fed","FED","rooted","isConnected","deref","observer","outside","observe","childList","attributes","attributeFilter","mineAlready","OWN","ours","child","childNodes","ahead","unitIndexOf","findIndex","settleIn","inRun","behind","register","subtree","wired","_$hydrateSlots$","hh","reconcile","ranged","PATCHED","answerAssigned","win","proto","Text","Object","getOwnPropertyDescriptor","native","defineProperty","configurable","enumerable","dress","setAttribute","style","setProperty","append","createElement","SERVED_HOSTS","captureServed","args","capture","lightFor","late","carrier","arm","close","hostBehavior","WeakRef","hole","placeholder","data","between","assigned","elementsOnly","flatten","nested","appendChild","disconnect","release","served","_$region$","assignedNodes","options","assignedElements","done","doneOn","_$done$","unadopted","container","spec","LIGHT_ATTR","endsWith","Error","hasAttribute","removeAttribute","lightNodes","slotted","shadowRoot","querySelectorAll","find","s","slotDiscovery","observeSlots","eager","_$observeSlots$","_$hydrating$","el","_$capture$","_$unadopted$","_$parked$","start","size","parts","tooOld","slots","w","wire"],"mappings":"AAMO,MC6EMA,EAAyB,IAAIC,IAAI,CAC5C,iBAAkB,gBAAiB,YAAa,gBAChD,gBAAiB,mBAAoB,iBAAkB,kBAS5CC,EAAuBC,GAClCA,EAAIC,SAAS,OAASJ,EAAuBK,IAAIF,EAAIG,eCtEvD,IAAIC,EAA4C,KAQhD,MAAMC,EAAS,CAACC,EAAgBC,EAAmBC,ICiC3B,EAACC,EAA0CH,EAAgBI,EAA8BF,KAC/G,GAAIC,GAAUE,OAAQ,IAAK,MAAMC,KAAWH,EAAWG,EAAwDN,EAAOI,OAlB1F,EAACJ,EAAgBE,KAClB,mBAAhBK,YAA4BC,QAAQR,MAAME,EAAMF,GAGzDO,YAAYP,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