@faqir-ui/core 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn.json +35 -35
- package/dist/faqir-core.js +528 -333
- package/dist/faqir-core.min.js +3 -3
- package/dist/faqir-core.min.js.map +3 -3
- package/dist/faqir-core.mjs +532 -482
- package/dist/faqir.aurora.css +1486 -1036
- package/dist/faqir.brutalist.css +1486 -1036
- package/dist/faqir.candy.css +1486 -1036
- package/dist/faqir.clinical.css +1486 -1036
- package/dist/faqir.contrast.css +1486 -1036
- package/dist/faqir.default.css +1486 -1036
- package/dist/faqir.document-serif.css +1486 -1036
- package/dist/faqir.document.css +1486 -1036
- package/dist/faqir.editorial-document.css +1486 -1036
- package/dist/faqir.editorial.css +1486 -1036
- package/dist/faqir.fintech.css +1486 -1036
- package/dist/faqir.glass.css +1486 -1036
- package/dist/faqir.ink-document.css +1486 -1036
- package/dist/faqir.ink.css +1486 -1036
- package/dist/faqir.luxe.css +1486 -1036
- package/dist/faqir.midnight.css +1486 -1036
- package/dist/faqir.neo.css +1486 -1036
- package/dist/faqir.neumorph.css +1486 -1036
- package/dist/faqir.nordic.css +1486 -1036
- package/dist/faqir.organic.css +1486 -1036
- package/dist/faqir.paper.css +1486 -1036
- package/dist/faqir.slate.css +1486 -1036
- package/dist/faqir.soft.css +1486 -1036
- package/dist/faqir.sunset.css +1486 -1036
- package/dist/faqir.swiss-document.css +1486 -1036
- package/dist/faqir.swiss.css +1486 -1036
- package/dist/faqir.terminal.css +1486 -1036
- package/dist/plugins/faqir-mask.js +1 -2
- package/dist/plugins/faqir-rules.js +1 -1
- package/dist/sri.json +33 -33
- package/faqir-core.d.ts +18 -3
- package/package.json +1 -1
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../registry/core/faqir-core.js", "../src/cdn-entry.js"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// ============================================================================\n// registry/core/faqir-core.js\n//\n// GENERATED FILE — DO NOT EDIT BY HAND.\n// Assembled by scripts/build-core.mjs (task 0.3-03) from:\n// engine: src/core-src/engine.js\n// core helper: registry/core/menu-navigation.js\n// controllers: 29 recipe factories → accordion, alert-dialog, barcode, calendar, carousel, combobox, command-palette, context-menu, date-picker, dialog, drawer, dropdown, file-upload, input-otp, menubar, pagination, popover, qr-code, select-custom, sheet, sidebar, slider, table, tabs, tag-input, toast, toggle-group, tooltip, tree-view\n//\n// PRODUCTION BUILD — dev-only diagnostics stripped at assembly time.\n// Load faqir-core.dev.js instead while developing for full warnings.\n// Regenerate with: bun run build:core\n// Package version: 1.1.0\n// ============================================================================\n\n/**\n * Faqir Core — the running version is `Faqir.version` (stamped at build time).\n * Alpine-style reactivity for the Faqir UI component system.\n * Zero dependencies. CDN-ready. Agent-native.\n *\n * Usage:\n * <script src=\"faqir-core.js\"></script>\n * — or —\n * <script src=\"faqir-core.js\" type=\"module\"></script>\n * — or —\n * import Faqir from './faqir-core.js'\n */\n(function(global, factory) {\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n define(factory);\n } else {\n var Faqir = factory();\n global.Faqir = Faqir;\n if (typeof globalThis !== 'undefined') globalThis.Faqir = Faqir;\n }\n})(typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : this, function() {\n 'use strict';\n\n // ═══════════════════════════════════════════════════════\n // Section 0: Dev-build seam [task 0.7-12]\n // ═══════════════════════════════════════════════════════\n //\n // `faqir-core.js` (production) and `faqir-core.dev.js` are assembled from THIS\n // one source by scripts/build-core.mjs. Three markers decide what each build\n // keeps:\n //\n // the WHOLE LINE is dropped for production.\n // // @faqir:dev-start … end — the same, for a multi-line region.\n // // @faqir:dev-diagnostics — replaced by src/core-src/dev-diagnostics.js\n // in the dev build, dropped in production.\n //\n // Every dev-only message string therefore lives in dev-diagnostics.js and\n // never reaches the production file (proved by tests/build/dev-build.test.ts).\n //\n // `devHooks` is the only seam: null in production, an object of reporters in\n // the dev build. Call sites read `if (devHooks)` on a dev-marked line, so\n // production carries neither the guard nor the message.\n var devHooks = null;\n\n // ═══════════════════════════════════════════════════════\n // Section 1: Reactive Engine\n // ═══════════════════════════════════════════════════════\n\n let currentEffect = null;\n const effectStack = [];\n let batchDepth = 0;\n const pendingEffects = new Set();\n let flushScheduled = false;\n\n const reactiveMap = new WeakMap();\n const ARRAY_MUTATORS = new Set(['push', 'pop', 'splice', 'shift', 'unshift', 'sort', 'reverse']);\n\n function reactive(obj) {\n if (obj.__isReactive) return obj;\n if (reactiveMap.has(obj)) return reactiveMap.get(obj);\n\n const deps = Object.create(null);\n\n const proxy = new Proxy(obj, {\n get(target, key, receiver) {\n if (key === '__isReactive') return true;\n if (key === '__deps') return deps;\n if (key === '__target') return target;\n\n if (currentEffect && typeof key === 'string') {\n if (!deps[key]) deps[key] = new Set();\n deps[key].add(currentEffect);\n currentEffect._deps.add(deps[key]);\n }\n\n const value = Reflect.get(target, key, receiver);\n\n // Intercept array mutation methods to trigger 'length' deps,\n // since internal length updates bypass the setter's change check.\n if (Array.isArray(target) && typeof value === 'function' && ARRAY_MUTATORS.has(key)) {\n return function() {\n const result = value.apply(target, arguments);\n if (deps['length']) {\n for (const eff of deps['length']) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n return result;\n };\n }\n\n // Deep reactivity: wrap nested arrays and plain objects so that\n // mutations like array.push() / array.splice() trigger effects.\n if (value !== null && typeof value === 'object'\n && !value.__isReactive\n && (Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype)) {\n return reactive(value);\n }\n\n return value;\n },\n\n set(target, key, value, receiver) {\n const oldValue = target[key];\n const result = Reflect.set(target, key, value, receiver);\n\n if (oldValue !== value && deps[key]) {\n for (const eff of deps[key]) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n\n return result;\n }\n });\n\n reactiveMap.set(obj, proxy);\n return proxy;\n }\n\n function effect(fn) {\n const execute = () => {\n cleanup(execute);\n\n currentEffect = execute;\n effectStack.push(execute);\n\n try {\n fn();\n } finally {\n effectStack.pop();\n currentEffect = effectStack[effectStack.length - 1] || null;\n }\n };\n\n execute._deps = new Set();\n execute();\n\n return () => cleanup(execute);\n }\n\n function cleanup(execute) {\n for (const depSet of execute._deps) {\n depSet.delete(execute);\n }\n execute._deps.clear();\n }\n\n function scheduleFlush() {\n if (batchDepth > 0) return;\n if (flushScheduled) return;\n flushScheduled = true;\n queueMicrotask(flushEffects);\n }\n\n function flushEffects() {\n flushScheduled = false;\n var iterations = 0;\n while (pendingEffects.size > 0) {\n // Effects that keep re-triggering each other (a writes b, b writes a)\n // would loop forever. The cap stops that, but dropping work silently\n // hides the bug, so it is reported in every build.\n if (++iterations > 100) {\n console.warn('[Faqir] Effect loop: dropped ' + pendingEffects.size + ' effect(s) after 100 flushes; effects keep re-triggering each other');\n pendingEffects.clear();\n break;\n }\n var effects = [...pendingEffects];\n pendingEffects.clear();\n for (var i = 0; i < effects.length; i++) {\n try {\n effects[i]();\n } catch (e) {\n console.warn('[Faqir] Effect error:', e);\n }\n }\n }\n }\n\n function batch(fn) {\n batchDepth++;\n try {\n fn();\n } finally {\n batchDepth--;\n if (batchDepth === 0) {\n flushEffects();\n }\n }\n }\n\n function untrack(fn) {\n const prev = currentEffect;\n currentEffect = null;\n try {\n return fn();\n } finally {\n currentEffect = prev;\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 2: Expression Evaluator\n // ═══════════════════════════════════════════════════════\n\n const expressionCache = new Map();\n\n function evaluate(expression, scope, el) {\n try {\n const fn = compileExpression(expression);\n return fn.call(scope, scope, el);\n } catch (e) {\n console.warn('[Faqir] Expression error: \"' + expression + '\"', e);\n return undefined;\n }\n }\n\n function evaluateAssignment(expression, scope, el) {\n try {\n const fn = compileStatement(expression);\n fn.call(scope, scope, el);\n } catch (e) {\n console.warn('[Faqir] Statement error: \"' + expression + '\"', e);\n }\n }\n\n // Write a value into a scope property WITHOUT putting the value into source.\n //\n // l-model used to build \"prop = '\" + value + \"'\" and compile it, which meant\n // (a) anything typed into an input was executed as JavaScript, (b) a backslash\n // or newline silently corrupted or broke the write, and (c) every distinct\n // value compiled and permanently cached its own Function. Passing the value\n // through a reserved scope slot — the same trick handleOn uses for $event —\n // fixes all three: one compiled statement per binding, and user data is never\n // parsed as code.\n function writeModel(prop, value, scope, el) {\n scope.$modelValue = value;\n try {\n evaluateAssignment(prop + ' = $modelValue', scope, el);\n } finally {\n delete scope.$modelValue;\n }\n }\n\n function compileExpression(expr) {\n var key = 'expr:' + expr;\n if (expressionCache.has(key)) return expressionCache.get(key);\n\n var fn = new Function(\n '$scope', '$el',\n 'with($scope) { return (' + expr + ') }'\n );\n expressionCache.set(key, fn);\n return fn;\n }\n\n function compileStatement(expr) {\n var key = 'stmt:' + expr;\n if (expressionCache.has(key)) return expressionCache.get(key);\n\n var fn = new Function(\n '$scope', '$el',\n 'with($scope) { ' + expr + ' }'\n );\n expressionCache.set(key, fn);\n return fn;\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 3: Directive System\n // ═══════════════════════════════════════════════════════\n\n // --- Shared state ---\n var scopeCounter = 0;\n var dataRegistry = new Map();\n var customDirectives = new Map();\n var globalStores = {};\n\n // --- 3.0 Declared vocabulary [task 1.0R-03] ---\n //\n // The engine's public surface, declared once, in comments only — the minifier\n // drops them, so this costs zero shipped bytes. `src/generator/skill.ts` reads\n // these lines into `.claude/skills/faqir-creator/references/directives.md`, so\n // the reference an agent is sent to is not a transcription: add a line here\n // and the row appears. `tests/generator/skill.test.ts` greps this file for\n // every `l-…` and `$…` name it mentions and fails on any the engine\n // implements without a line below — which is why something that is NOT public\n // vocabulary (the evaluator's own `$scope` binding) is declared `internal`\n // with its reason rather than left out.\n //\n // Fields are ` | `-separated; never use `|` inside one.\n // @ui:directive <attribute> | <shorthand> | <placement> | <example> | <what it does>\n // @ui:modifier <attribute> <.modifier> | <what it does>\n // @ui:magic $<name> | <where it resolves> | <what it is>\n //\n // The three lists that already exist as code — PRIORITY (§3.2), KEY_MAP\n // (§3.9) and MOTION_PRESETS (§3.14) — are read from the code itself, not\n // repeated here.\n //\n // @ui:directive l-data | — | any element, which becomes the scope root | l-data=\"{ count: 0 }\" | Declares a reactive scope from an object literal, or from a name registered with `Faqir.data()`. `data-prop-*` attributes are JSON-parsed and merged over it. Descendants share the scope until the next `l-data`.\n // @ui:directive l-init | — | a scope root, beside `l-data` | l-init=\"load()\" | Runs once, after the scope exists and its `l-source` bindings are injected.\n // @ui:directive l-source:<name> | — | a scope root, beside `l-data` | l-source:tasks=\"/api/tasks\" | Binds a REST collection into the scope as `<name>`, `<name>Loading`, `<name>Error` and the `$<name>` CRUD controller. See below.\n // @ui:directive l-text | — | any element | l-text=\"count\" | Writes the value to `textContent`; `null` and `undefined` write an empty string.\n // @ui:directive l-html | — | any element | l-html=\"body\" | Writes the value to `innerHTML`, unsanitized — never pass user input. The dev engine reports every use.\n // @ui:directive l-bind:<attr> | :<attr> | any element | :disabled=\"loading\" | Binds one attribute. `class` and `style` take a string, an array or an object; boolean attributes are added or removed; `null`, `undefined` and `false` remove the attribute.\n // @ui:directive l-on:<event> | @<event> | any element | @click=\"count++\" | Adds a listener for `<event>`. Inside the expression `$event` is the DOM event.\n // @ui:directive l-model | — | an input, textarea or select, or `[data-ui=\"switch\"]` | l-model=\"name\" | Two-way binding. A checkbox bound to an array is a checkbox group; radios bind by value; `<select multiple>` is not handled. The modifiers below apply to the text-like branch (input, textarea, number) only.\n // @ui:directive l-show | — | any element | l-show=\"open\" | Toggles `display: none`, leaving the element in the DOM. Runs `l-transition` on each flip.\n // @ui:directive l-if | — | a `<template>` element | <template l-if=\"open\"> | Inserts and removes the template's content. Removal tears the subtree down: cleanups run and in-flight `l-source` requests abort.\n // @ui:directive l-for | — | a `<template>` element | <template l-for=\"(task, i) in tasks\"> | Repeats the template's content once per item, with the item and index names bound in a child scope.\n // @ui:directive l-key | — | the same `<template>` as `l-for` | l-key=\"task.id\" | The reconciliation key. Without it items are matched by position, so a reorder re-renders rather than moves; the dev engine reports that case.\n // @ui:directive l-ref | — | any element | l-ref=\"field\" | Registers the element on the scope's `$refs` under that name.\n // @ui:directive l-effect | — | any element | l-effect=\"document.title = title\" | Runs the expression immediately, then again whenever a value it read changes.\n // @ui:directive l-cloak | — | any element | l-cloak | Removed from every element once the tree is initialized. Pair with `[l-cloak] { display: none }` to hide markup before it binds.\n // @ui:directive l-transition | — | an `l-show` element, or a top-level element inside a `<template l-if>` | l-transition=\"slide-up\" | Names the motion preset for that element's enter/leave cycle. The engine only stamps `data-motion`; the CSS animates.\n // @ui:directive l-teleport | — | any element | l-teleport=\"body\" | Moves the element into the first element matching the value, which is a plain CSS selector rather than an expression.\n //\n // @ui:modifier l-model .number | Casts the input value with `parseFloat` (`0` when it does not parse).\n // @ui:modifier l-model .trim | Trims the input value before assigning.\n // @ui:modifier l-model .lazy | Binds on `change` instead of `input`.\n // @ui:modifier l-model .debounce | Debounces the write by 300ms. Fixed — unlike `l-on`, this one reads no time.\n // @ui:modifier l-on .prevent | `preventDefault()` before the expression runs.\n // @ui:modifier l-on .stop | `stopPropagation()` before the expression runs.\n // @ui:modifier l-on .self | Ignores the event unless `event.target` is the element itself.\n // @ui:modifier l-on .once | Listener option `once` — removed after it fires.\n // @ui:modifier l-on .capture | Listener option `capture`.\n // @ui:modifier l-on .passive | Listener option `passive`.\n // @ui:modifier l-on .window | Listens on `window` instead of the element.\n // @ui:modifier l-on .document | Listens on `document` instead of the element.\n // @ui:modifier l-on .debounce | Debounces the handler, 250ms by default. A custom time is part of the same modifier — `.debounce500ms`, `.debounce2s`. A dotted `.debounce.500ms` is TWO modifiers and the time is ignored.\n // @ui:modifier l-on .throttle | Throttles the handler, 250ms by default. Takes a time the same way — `.throttle1s`.\n // @ui:modifier l-source .lazy | Skips the load on init — the collection stays empty until `$<name>.load()`.\n // @ui:modifier l-source .optimistic | Applies create/update/remove to the local array first and rolls back if the request fails.\n // @ui:modifier l-source .poll | Re-loads on an interval, 30000ms by default. Takes the interval: `.poll.5000`.\n // @ui:modifier l-source .key | Names the identity property, `id` by default: `.key.uuid`.\n //\n // @ui:magic $el | every expression | The scope ROOT — the element carrying `l-data`, not the element the expression is written on. Every magic that walks the DOM starts from here.\n // @ui:magic $refs | every expression | The scope's `l-ref` elements, keyed by name. Cleared entry by entry as elements are destroyed.\n // @ui:magic $store | every expression | Every store registered with `Faqir.store()`.\n // @ui:magic $state | every expression | `data-state` of the `[data-ui]` closest to the scope root. Writable — assigning sets the attribute — and reads re-run when a controller changes it.\n // @ui:magic $variant | every expression | `data-variant` of the same `[data-ui]`, writable and observed the same way.\n // @ui:magic $ui | every expression | The controller API of that same `[data-ui]` — `$ui.open()`. Also callable, to reach ANOTHER component's controller by CSS selector: `$ui('#detail-drawer').open()`, which returns `null` when nothing matches or the match has no controller.\n // @ui:magic $dispatch | every expression | `$dispatch('name', detail)` fires a bubbling, composed `CustomEvent` from the scope root.\n // @ui:magic $nextTick | every expression | `$nextTick(fn)` queues `fn` as a microtask, so it runs after the effects a mutation queued have flushed and the DOM is updated.\n // @ui:magic $watch | every expression | `$watch('key', function (value, old) { … })` — returns a disposer.\n // @ui:magic $id | every expression | `$id('label')` returns `faqir-<scope>-label`, stable for the scope and unique across scopes.\n // @ui:magic $event | `l-on` expressions only | The DOM event being handled. Set for the duration of the handler and deleted again after it, so it reads as `undefined` anywhere else.\n // @ui:magic $scope | internal | the evaluator compiles every expression to `with($scope) { … }`, so the name runs through the engine source as that compiled function's own parameter. Page code never writes it.\n // @ui:magic $modelValue | internal | `l-model`'s transport slot. The value a control produces is placed here and the assignment compiles to `prop = $modelValue`, so what the user typed is never spliced into source and never reaches the compiler. Set for the duration of one write and deleted after it; page code never sees it.\n //\n // --- 3.1 Attribute Parsing ---\n\n function parseDirectives(el) {\n var directives = [];\n\n for (var i = 0; i < el.attributes.length; i++) {\n var attr = el.attributes[i];\n var name = attr.name;\n var directive = null;\n\n if (name.startsWith('l-')) {\n if (name.startsWith('l-bind:')) {\n var rest = name.slice(7);\n var parts = rest.split('.');\n directive = {\n type: 'bind',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else if (name.startsWith('l-on:')) {\n var rest = name.slice(5);\n var parts = rest.split('.');\n directive = {\n type: 'on',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else if (name.startsWith('l-source:')) {\n var rest = name.slice(9);\n var parts = rest.split('.');\n directive = {\n type: 'source',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else {\n var rest = name.slice(2);\n var parts = rest.split('.');\n directive = {\n type: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n }\n } else if (name.startsWith(':')) {\n var rest = name.slice(1);\n var parts = rest.split('.');\n directive = {\n type: 'bind',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else if (name.startsWith('@')) {\n var rest = name.slice(1);\n var parts = rest.split('.');\n directive = {\n type: 'on',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n }\n\n if (directive) directives.push(directive);\n }\n\n return directives;\n }\n\n // --- 3.2 Directive Priority ---\n\n var PRIORITY = {\n 'data': 1,\n 'source': 1,\n 'for': 2,\n 'if': 3,\n 'bind': 10,\n 'on': 10,\n 'text': 10,\n 'html': 10,\n 'model': 10,\n 'show': 10,\n 'transition': 10,\n 'ref': 10,\n 'init': 20,\n 'effect': 20,\n 'cloak': 100,\n 'teleport': 100\n };\n\n // --- 3.3 DOM Tree Walker ---\n\n // Directives `initScope` has already consumed by the time `initTree` gets to\n // apply the rest. Everything else written on a scope root has to be applied\n // HERE: `walkChildren` visits descendants only, so a directive on the root\n // element itself is seen by nobody else. Until 1.0 only plugin directives were\n // run here, which made `l-effect`, `l-on`, `l-text`, `l-show`, `l-bind`,\n // `l-model` and `l-ref` inert — with no error — on the one element the docs\n // point authors at (\"a scope root, beside `l-data`\"). [W2-1]\n var ROOT_CONSUMED = { data: 1, source: 1, init: 1 };\n\n function initTree(root, parentScope) {\n var scope = initScope(root, parentScope);\n\n var rootDirectives = parseDirectives(root);\n rootDirectives.sort(function(a, b) {\n return (PRIORITY[a.type] || 10) - (PRIORITY[b.type] || 10);\n });\n for (var i = 0; i < rootDirectives.length; i++) {\n var rootDir = rootDirectives[i];\n if (ROOT_CONSUMED[rootDir.type]) continue;\n // `l-if` / `l-for` claim the element they sit on and re-render it from a\n // template. A scope root is not a template slot — it is the thing the\n // structural directive would have to destroy — so they stay the parent\n // walk's business and are skipped rather than applied to `root` itself.\n if (rootDir.type === 'if' || rootDir.type === 'for') continue;\n applyDirective(root, rootDir, scope);\n }\n\n walkChildren(root, scope);\n }\n\n function walkChildren(el, scope) {\n var children = [].slice.call(el.children);\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n\n // Skip elements already initialized by l-for or l-if\n if (child.__faqirScope && !child.hasAttribute('l-data')) {\n continue;\n }\n\n // Only l-data creates a new scope boundary.\n // data-ui elements inherit the parent scope so directives\n // inside Faqir components can access the enclosing reactive data.\n if (child.hasAttribute('l-data')) {\n initTree(child, scope);\n continue;\n }\n\n processElement(child, scope);\n // Skip walkChildren if structural directive (l-if/l-for) removed the element\n if (child.parentNode) {\n walkChildren(child, scope);\n }\n }\n }\n\n // Directives that live OUTSIDE every scope root.\n //\n // Bootstrap only ever walked out from `[l-data]` / `[data-ui]` elements, so an\n // attribute on anything else was parsed by nobody. The canonical `l-validate`\n // markup — `<form l-validate>` wrapping a `[data-ui=\"field-group\"]`, straight\n // out of the plugin's own documentation — has no `l-data` anywhere, which is\n // why the plugin looked \"completely inert\": it was registered, the attribute\n // was on the form, and no code path ever reached the form to apply it. Same\n // for a bare `@click` or `l-text` on a page that never declared a scope.\n //\n // This sweep binds them against the implicit document scope. It stops at any\n // element that already owns a scope — that subtree was walked from its own\n // root — so it visits only the parts of the page nothing else claimed. [W2-1]\n function walkUnscoped(el, scope) {\n var children = [].slice.call(el.children);\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n // `__faqirStray` is this sweep's equivalent of `__faqirScope`: stray\n // elements never get a scope of their own, so without a mark a second\n // `Faqir.start()` re-bound every one of them and each `@click` fired\n // twice. The subtree was walked with it the first time, so skipping the\n // element skips the subtree too. [W3-1]\n if (child.__faqirScope || child.__faqirStray) continue;\n child.__faqirStray = true;\n processElement(child, scope);\n if (child.parentNode) walkUnscoped(child, scope);\n }\n }\n\n // The scope those stray directives evaluate against: empty data, magics rooted\n // at `<body>`. Created once, on first use, so a page with no stray directive\n // pays nothing for it.\n var strayScope = null;\n function getStrayScope() {\n if (!strayScope) {\n if (!document.body.__scopeId) document.body.__scopeId = ++scopeCounter;\n if (!document.body.__faqirCleanups) document.body.__faqirCleanups = [];\n // Deliberately NOT stored as `document.body.__faqirScope`: `findParentScope`\n // would then answer \"yes, scoped\" for every element on the page and the\n // MutationObserver would stop giving standalone `[data-ui]` islands their\n // own scope.\n strayScope = createScopeWithMagics({}, document.body, document.body);\n }\n return strayScope;\n }\n\n function processElement(el, scope) {\n var directives = parseDirectives(el);\n if (directives.length === 0) return;\n\n directives.sort(function(a, b) {\n return (PRIORITY[a.type] || 10) - (PRIORITY[b.type] || 10);\n });\n\n // Structural directives take over the element — and both anchor a comment\n // where the element stands, so an element that no longer stands anywhere has\n // nothing to do. A `<template l-for>` is replaced by its own anchor the first\n // time it renders, and the MutationObserver is handed that detached template\n // one microtask later. [W2-1]\n for (var i = 0; i < directives.length; i++) {\n if (directives[i].type === 'if') {\n if (el.parentNode) handleIf(el, directives[i], scope);\n return;\n }\n if (directives[i].type === 'for') {\n if (el.parentNode) handleFor(el, directives[i], scope);\n return;\n }\n }\n\n for (var i = 0; i < directives.length; i++) {\n applyDirective(el, directives[i], scope);\n }\n }\n\n // --- 3.4 l-data / Scope Initialization ---\n\n function initScope(root, parentScope) {\n var expr = root.getAttribute('l-data');\n var userData = {};\n\n if (expr) {\n if (dataRegistry.has(expr)) {\n userData = dataRegistry.get(expr)();\n } else if (expr.trim()) {\n userData = evaluate(expr, parentScope || {}, root) || {};\n }\n }\n\n var propData = readProps(root);\n Object.assign(userData, propData);\n\n var scopeId = ++scopeCounter;\n var scope = createScopeWithMagics(userData, root, root);\n root.__faqirScope = scope;\n root.__scopeId = scopeId;\n root.__faqirCleanups = [];\n\n // A data source spread into `l-data` can own timers, sockets or in-flight\n // requests, and until 1.0 nothing gave it a way to be told the scope had\n // gone: `apiSource()`'s `setInterval` poll and its `fetch` calls simply\n // outlived the element, which on an SPA route change means one live poller\n // per page the user ever visited. Any own `__faqirTeardown` function on the\n // scope data is run on teardown — namespaced so no ordinary data key can be\n // mistaken for one. [W3-1]\n if (typeof userData.__faqirTeardown === 'function') {\n var sourceTeardown = userData.__faqirTeardown;\n addCleanup(root, function() { sourceTeardown(); });\n }\n\n // Set up bidirectional bridge for $state/$variant\n setupStateBridge(root, scope);\n\n // Process l-source directives (inject data + controller into scope)\n processSourceDirectives(root, scope);\n\n var initExpr = root.getAttribute('l-init');\n if (initExpr) {\n evaluateAssignment(initExpr, scope, root);\n }\n\n return scope;\n }\n\n function readProps(el) {\n var props = {};\n for (var i = 0; i < el.attributes.length; i++) {\n var attr = el.attributes[i];\n if (attr.name.startsWith('data-prop-')) {\n var key = attr.name.slice(10).replace(/-([a-z])/g, function(_, c) { return c.toUpperCase(); });\n try {\n props[key] = JSON.parse(attr.value);\n } catch (e) {\n props[key] = attr.value;\n }\n }\n }\n return props;\n }\n\n function createScopeWithMagics(data, el, root) {\n var magics = Object.create(null);\n\n Object.defineProperties(magics, {\n $el: { get: function() { return el; }, enumerable: false },\n $refs: { get: function() { return getScopeRefs(root); }, enumerable: false },\n $store: { get: function() { return globalStores; }, enumerable: false },\n $state: {\n get: function() { return closestUI(el) ? closestUI(el).dataset.state : undefined; },\n set: function(v) { var ui = closestUI(el); if (ui) ui.dataset.state = v; },\n enumerable: false\n },\n $variant: {\n get: function() { return closestUI(el) ? closestUI(el).dataset.variant : undefined; },\n set: function(v) { var ui = closestUI(el); if (ui) ui.dataset.variant = v; },\n enumerable: false\n },\n $ui: { get: function() { return uiHandle(el); }, enumerable: false },\n $dispatch: {\n value: function(event, detail) {\n return el.dispatchEvent(\n new CustomEvent(event, { detail: detail, bubbles: true, composed: true })\n );\n },\n enumerable: false\n },\n $nextTick: {\n value: function(fn) { return queueMicrotask(fn || function() {}); },\n enumerable: false\n },\n $watch: {\n value: function(key, cb) {\n var dispose = watchProperty(scope, key, cb);\n // `$watch` handed its disposer back and nothing ever held one, so a\n // watcher created in `l-init` — the documented place to create one —\n // outlived every teardown and kept firing against a dead scope.\n // Registering it here makes `Faqir.destroy()` stop it; the return\n // value still works for callers that dispose by hand. [W3-1]\n addCleanup(root, dispose);\n return dispose;\n },\n enumerable: false\n },\n $id: {\n value: function(name) { return 'faqir-' + root.__scopeId + '-' + name; },\n enumerable: false\n }\n });\n\n // Plugins register a magic without reaching into scope internals. Resolve\n // it lazily so the callback receives the final reactive scope, not the\n // pre-proxy target that exists while this object is being assembled.\n customMagics.forEach(function(callback, name) {\n var key = '$' + name;\n if (Object.prototype.hasOwnProperty.call(magics, key)) return;\n Object.defineProperty(magics, key, {\n get: function() { return callback(el, scope); },\n enumerable: false\n });\n });\n\n // Use defineProperties instead of Object.assign to preserve getters/setters\n // (Object.assign invokes getters and copies the result as a static value).\n var target = Object.create(magics);\n var descriptors = Object.getOwnPropertyDescriptors(data);\n Object.defineProperties(target, descriptors);\n\n var scope = reactive(target);\n return scope;\n }\n\n function watchProperty(scope, key, cb) {\n var oldValue = scope[key];\n var dispose = effect(function() {\n var newValue = scope[key];\n if (newValue !== oldValue) {\n var prev = oldValue;\n oldValue = newValue;\n cb(newValue, prev);\n }\n });\n return dispose;\n }\n\n // --- Scope utilities ---\n\n function getScopeRefs(root) {\n return root.__faqirRefs || {};\n }\n\n function findScopeRoot(el) {\n var node = el;\n while (node) {\n if (node.__faqirScope) return node;\n node = node.parentElement;\n }\n return el;\n }\n\n // The nearest ancestor (inclusive) that OWNS a cleanup list.\n //\n // A different question from `findScopeRoot`, and the reason four disposers\n // went missing. Cleanup ownership follows the `__faqirCleanups` array —\n // stamped by `initScope`, `handleIf`, `handleFor` and `handleTeleport` —\n // rather than the scope object, because the two do not always sit on the same\n // element: `l-teleport` moves a subtree out of its scope root, so every\n // directive bound underneath it resolved to no owner at all and its disposer\n // was dropped on the floor. [W3-1]\n function findCleanupRoot(el) {\n var node = el;\n while (node) {\n if (node.__faqirCleanups) return node;\n node = node.parentNode;\n }\n return null;\n }\n\n /**\n * Register `cleanupFn` against the element that owns `el`'s teardown.\n *\n * `owner` is the escape hatch for the detached case. `l-if` and `l-for` insert\n * an anchor comment and then `el.remove()` their own `<template>`, so by the\n * time the list effect is registered `el` has no parent, resolves to no owner,\n * and the disposer is discarded — `Faqir.destroy()` could not stop a list that\n * went on re-rendering into the live document after teardown, contradicting\n * what `faqir-core.d.ts` promises. Callers that detach capture the owner\n * BEFORE they do and pass it here. [W3-1]\n */\n function addCleanup(el, cleanupFn, owner) {\n var root = owner || findCleanupRoot(el);\n if (root && root.__faqirCleanups) {\n root.__faqirCleanups.push(cleanupFn);\n }\n }\n\n // Run one node's cleanups exactly once. The list is emptied BEFORE it runs, so\n // a cleanup that tears down its own subtree re-entrantly finds nothing left to\n // do rather than disposing everything twice. One failing disposer must not\n // strand the ones behind it — teardown is the path where a half-finished job\n // is the leak.\n function runCleanups(node) {\n var list = node.__faqirCleanups;\n if (!list || list.length === 0) return;\n node.__faqirCleanups = [];\n for (var i = 0; i < list.length; i++) {\n try {\n list[i]();\n } catch (e) {\n console.error('[Faqir] a cleanup threw during teardown', node, e);\n }\n }\n }\n\n /**\n * Tear down `el` and everything under it.\n *\n * Walks CHILD NODES, not `querySelectorAll('*')`. `l-if` and `l-for` own their\n * subtree through an anchor COMMENT — that is the node their list effect's\n * disposer is registered on — and an element-only walk cannot see a comment,\n * so `Faqir.destroy()` left both structural directives running: the effect\n * stayed subscribed and went on re-rendering into a document nothing was\n * supposed to be driving any more. [W3-1]\n */\n function destroyScope(el) {\n if (!el) return;\n runCleanups(el);\n var child = el.firstChild;\n while (child) {\n // Read the sibling first: a cleanup is allowed to remove its own node.\n var next = child.nextSibling;\n destroyScope(child);\n child = next;\n }\n }\n\n // --- 3.5 l-source Directive ---\n\n function processSourceDirectives(root, scope) {\n for (var i = 0; i < root.attributes.length; i++) {\n var attr = root.attributes[i];\n if (!attr.name.startsWith('l-source:')) continue;\n\n var rest = attr.name.slice(9);\n var parts = rest.split('.');\n var sourceName = parts[0];\n var modifiers = parts.slice(1);\n var endpoint = attr.value;\n\n var opts = parseSourceModifiers(modifiers);\n setupSource(scope, root, sourceName, endpoint, opts);\n }\n }\n\n function parseSourceModifiers(modifiers) {\n var opts = { lazy: false, optimistic: false, idKey: 'id', pollInterval: 0 };\n\n for (var i = 0; i < modifiers.length; i++) {\n var mod = modifiers[i];\n if (mod === 'lazy') {\n opts.lazy = true;\n } else if (mod === 'optimistic') {\n opts.optimistic = true;\n } else if (mod === 'poll') {\n // Next modifier may be the interval in ms\n var next = modifiers[i + 1];\n if (next && /^\\d+$/.test(next)) {\n opts.pollInterval = parseInt(next, 10);\n i++; // skip the number\n } else {\n opts.pollInterval = 30000; // default 30s\n }\n } else if (mod === 'key') {\n // Next modifier is the key name\n var next = modifiers[i + 1];\n if (next && !/^\\d+$/.test(next)) {\n opts.idKey = next;\n i++; // skip the key name\n }\n }\n }\n\n return opts;\n }\n\n function setupSource(scope, root, name, endpoint, opts) {\n var pollTimer = null;\n var idKey = opts.idKey;\n var isOptimistic = opts.optimistic;\n\n // ── 0.3-08 request lifecycle ────────────────────────────────────────────\n // `destroyed` is latched true when the owning scope is torn down (an l-if\n // toggle or keyed l-for removal runs the cleanup registered below). Once\n // latched it (a) blocks new requests from starting and (b) gates every\n // async write-back so a fetch that resolves into a dead scope is a no-op.\n // `inflight` holds the AbortController of every live request so teardown\n // can cancel the actual network work, not just ignore its result.\n // `loadSeq`/`currentLoadAc` sequence read requests: a newer load() aborts\n // the previous one and only the LATEST call is allowed to land — so a slow\n // stale response can no longer clobber a fresh one (D2).\n var destroyed = false;\n var inflight = new Set();\n var loadSeq = 0;\n var currentLoadAc = null;\n var HAS_ABORT = typeof AbortController !== 'undefined';\n\n function beginRequest() {\n var ac = HAS_ABORT ? new AbortController() : null;\n if (ac) inflight.add(ac);\n return ac;\n }\n function endRequest(ac) {\n if (ac) inflight.delete(ac);\n }\n function signalOf(ac) {\n return ac ? ac.signal : undefined;\n }\n // Where a row is NOW — `row` by identity, else the row whose idKey is `id`.\n // Never an index saved before the request: an interleaved load()/remove()\n // shifts or replaces the list, and a stale index writes over a real row.\n function locate(id, row) {\n var items = scope[name];\n for (var i = 0; i < items.length; i++) {\n if (row ? items[i] === row : items[i] && items[i][idKey] === id) return i;\n }\n return -1;\n }\n\n // Inject reactive data properties into scope\n scope[name] = [];\n scope[name + 'Loading'] = false;\n scope[name + 'Error'] = null;\n\n // CRUD controller\n var ctrl = {\n load: function() {\n if (destroyed) return Promise.resolve();\n var mySeq = ++loadSeq;\n // Supersede the previous in-flight read: abort it so its network\n // request is cancelled; the seq guard below discards any late result.\n if (currentLoadAc) { try { currentLoadAc.abort(); } catch (e) {} }\n var ac = beginRequest();\n currentLoadAc = ac;\n scope[name + 'Loading'] = true;\n scope[name + 'Error'] = null;\n return fetch(endpoint, { signal: signalOf(ac) })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n return res.json();\n })\n .then(function(data) {\n if (destroyed || mySeq !== loadSeq) return;\n scope[name] = Array.isArray(data) ? data : [data];\n })\n .catch(function(e) {\n if (destroyed || mySeq !== loadSeq) return;\n scope[name + 'Error'] = e.message;\n })\n .then(function() {\n endRequest(ac);\n if (currentLoadAc === ac) currentLoadAc = null;\n if (destroyed || mySeq !== loadSeq) return;\n scope[name + 'Loading'] = false;\n });\n },\n\n create: function(payload) {\n if (destroyed) return Promise.resolve(null);\n scope[name + 'Error'] = null;\n var temp = null;\n\n if (isOptimistic) {\n scope[name].push(Object.assign({}, payload, { _pending: true }));\n // Read back through the list: that is the handle `locate` compares.\n temp = scope[name][scope[name].length - 1];\n }\n\n var ac = beginRequest();\n return fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n signal: signalOf(ac)\n })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n return res.json();\n })\n .then(function(created) {\n endRequest(ac);\n if (destroyed) return null;\n var at = temp ? locate(null, temp) : -1;\n if (at >= 0) {\n scope[name][at] = created;\n } else if (!temp || !created || created[idKey] == null || locate(created[idKey]) < 0) {\n // The temp row is gone when a load() replaced the list meanwhile;\n // that list may already hold the created row.\n scope[name].push(created);\n }\n return created;\n })\n .catch(function(e) {\n endRequest(ac);\n if (destroyed) return null;\n scope[name + 'Error'] = e.message;\n var at = temp ? locate(null, temp) : -1;\n if (at >= 0) scope[name].splice(at, 1);\n return null;\n });\n },\n\n update: function(id, payload) {\n if (destroyed) return Promise.resolve(null);\n scope[name + 'Error'] = null;\n var items = scope[name];\n var idx = locate(id);\n var snapshot = null;\n\n if (isOptimistic && idx >= 0) {\n snapshot = Object.assign({}, items[idx]);\n Object.assign(items[idx], payload);\n }\n\n var ac = beginRequest();\n return fetch(endpoint + '/' + encodeURIComponent(id), {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n signal: signalOf(ac)\n })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n return res.json();\n })\n .then(function(updated) {\n endRequest(ac);\n if (destroyed) return null;\n var at = locate(id);\n if (at >= 0) scope[name][at] = updated;\n return updated;\n })\n .catch(function(e) {\n endRequest(ac);\n if (destroyed) return null;\n scope[name + 'Error'] = e.message;\n var at = snapshot ? locate(id) : -1;\n if (at >= 0) scope[name][at] = snapshot;\n return null;\n });\n },\n\n remove: function(id) {\n if (destroyed) return Promise.resolve();\n scope[name + 'Error'] = null;\n var items = scope[name];\n var idx = locate(id);\n var snapshot = null;\n\n if (isOptimistic && idx >= 0) {\n snapshot = items[idx];\n items.splice(idx, 1);\n }\n\n var ac = beginRequest();\n return fetch(endpoint + '/' + encodeURIComponent(id), { method: 'DELETE', signal: signalOf(ac) })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n endRequest(ac);\n if (destroyed) return;\n var at = isOptimistic ? -1 : locate(id);\n if (at >= 0) scope[name].splice(at, 1);\n })\n .catch(function(e) {\n endRequest(ac);\n if (destroyed) return;\n scope[name + 'Error'] = e.message;\n // `idx` is only a position hint here; skip if a reload restored it.\n if (snapshot && locate(id) < 0) {\n scope[name].splice(idx, 0, snapshot);\n }\n });\n },\n\n refresh: function() { return ctrl.load(); },\n\n startPolling: function(interval) {\n ctrl.stopPolling();\n if (destroyed) return;\n var ms = interval || opts.pollInterval || 30000;\n pollTimer = setInterval(function() { ctrl.load(); }, ms);\n },\n\n stopPolling: function() {\n if (pollTimer) {\n clearInterval(pollTimer);\n pollTimer = null;\n }\n }\n };\n\n // Inject controller as $<name>\n scope['$' + name] = ctrl;\n\n // Auto-load unless .lazy\n if (!opts.lazy) {\n ctrl.load();\n }\n\n // Auto-poll if .poll modifier present\n if (opts.pollInterval > 0) {\n ctrl.startPolling();\n }\n\n // Teardown on scope destruction: stop polling, latch `destroyed` so no new\n // work starts or writes back, and abort every in-flight request — no fetch\n // or timer outlives the scope that owns it (D3).\n addCleanup(root, function() {\n destroyed = true;\n ctrl.stopPolling();\n inflight.forEach(function(ac) { try { ac.abort(); } catch (e) {} });\n inflight.clear();\n });\n }\n\n // --- 3.6 Directive Dispatch ---\n\n function applyDirective(el, dir, scope) {\n switch (dir.type) {\n case 'bind': return handleBind(el, dir, scope);\n case 'on': return handleOn(el, dir, scope);\n case 'text': return handleText(el, dir, scope);\n case 'html': return handleHtml(el, dir, scope);\n case 'model': return handleModel(el, dir, scope);\n case 'show': return handleShow(el, dir, scope);\n case 'ref': return handleRef(el, dir, scope);\n case 'init': return handleInit(el, dir, scope);\n case 'effect': return handleEffect(el, dir, scope);\n case 'source': return; // Handled by initScope → processSourceDirectives\n // Uncloak as soon as the element is bound. Bootstrap's sweep still runs\n // (it catches elements no directive walk reaches), and so does the\n // MutationObserver's — but content rendered by `l-if`/`l-for` is bound\n // here, before it is ever inserted, so it never needs either. [W3-1]\n case 'cloak': el.removeAttribute('l-cloak'); return;\n case 'teleport': return handleTeleport(el, dir, scope);\n case 'transition': return; // Handled by l-show and l-if\n default:\n if (customDirectives.has(dir.type)) {\n var cleanupFn = customDirectives.get(dir.type)(el, dir, scope);\n if (typeof cleanupFn === 'function') addCleanup(el, cleanupFn);\n }\n }\n }\n\n // --- 3.6 l-text ---\n\n function handleText(el, dir, scope) {\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n el.textContent = value == null ? '' : String(value);\n });\n addCleanup(el, cl);\n }\n\n // --- 3.7 l-html ---\n\n function handleHtml(el, dir, scope) {\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n el.innerHTML = value == null ? '' : String(value);\n });\n addCleanup(el, cl);\n }\n\n // --- 3.8 l-bind / :attr ---\n\n var BOOLEAN_ATTRS = new Set([\n 'disabled', 'hidden', 'checked', 'readonly', 'required', 'selected',\n 'autofocus', 'autoplay', 'controls', 'loop', 'muted', 'multiple',\n 'open', 'novalidate', 'formnovalidate', 'inert'\n ]);\n\n function handleBind(el, dir, scope) {\n var attrName = dir.arg;\n\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n\n if (attrName === 'class') {\n applyClassBinding(el, value);\n } else if (attrName === 'style') {\n applyStyleBinding(el, value);\n } else if (BOOLEAN_ATTRS.has(attrName)) {\n if (value) {\n el.setAttribute(attrName, '');\n } else {\n el.removeAttribute(attrName);\n }\n } else {\n if (value === null || value === undefined || value === false) {\n el.removeAttribute(attrName);\n } else {\n el.setAttribute(attrName, String(value));\n }\n }\n });\n\n addCleanup(el, cl);\n }\n\n function applyClassBinding(el, value) {\n if (typeof value === 'string') {\n el.className = value;\n } else if (Array.isArray(value)) {\n el.className = value.filter(Boolean).join(' ');\n } else if (typeof value === 'object' && value !== null) {\n for (var cls in value) {\n if (value.hasOwnProperty(cls)) {\n el.classList.toggle(cls, !!value[cls]);\n }\n }\n }\n }\n\n function applyStyleBinding(el, value) {\n if (typeof value === 'string') {\n el.style.cssText = value;\n } else if (typeof value === 'object' && value !== null) {\n for (var prop in value) {\n if (value.hasOwnProperty(prop)) {\n var cssProp = prop.replace(/[A-Z]/g, function(m) { return '-' + m.toLowerCase(); });\n var val = value[prop];\n if (val === null || val === undefined || val === false) {\n el.style.removeProperty(cssProp);\n } else {\n el.style.setProperty(cssProp, String(val));\n }\n }\n }\n }\n }\n\n // --- 3.9 l-on / @event ---\n\n var KEY_MAP = {\n 'enter': 'Enter', 'escape': 'Escape', 'esc': 'Escape',\n 'tab': 'Tab', 'space': ' ', 'delete': 'Delete', 'backspace': 'Backspace',\n 'up': 'ArrowUp', 'down': 'ArrowDown', 'left': 'ArrowLeft', 'right': 'ArrowRight',\n 'arrow-up': 'ArrowUp', 'arrow-down': 'ArrowDown',\n 'arrow-left': 'ArrowLeft', 'arrow-right': 'ArrowRight',\n 'home': 'Home', 'end': 'End', 'page-up': 'PageUp', 'page-down': 'PageDown'\n };\n\n function debounce(fn, ms) {\n var timer;\n return function() {\n var self = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function() { fn.apply(self, args); }, ms);\n };\n }\n\n function throttle(fn, ms) {\n var last = 0;\n return function() {\n var now = Date.now();\n if (now - last >= ms) {\n last = now;\n fn.apply(this, arguments);\n }\n };\n }\n\n function parseTimeMod(mod) {\n var match = mod.match(/(\\d+)(ms|s)?/);\n if (!match) return null;\n var value = parseInt(match[1], 10);\n return match[2] === 's' ? value * 1000 : value;\n }\n\n function handleOn(el, dir, scope) {\n var eventName = dir.arg;\n var modifiers = new Set(dir.modifiers);\n\n var target = el;\n if (modifiers.has('window')) target = window;\n else if (modifiers.has('document')) target = document;\n\n var wrapFn = null;\n for (var m = 0; m < dir.modifiers.length; m++) {\n var mod = dir.modifiers[m];\n if (mod.startsWith('debounce')) {\n var ms = parseTimeMod(mod) || 250;\n wrapFn = function(fn) { return debounce(fn, ms); };\n } else if (mod.startsWith('throttle')) {\n var ms = parseTimeMod(mod) || 250;\n wrapFn = function(fn) { return throttle(fn, ms); };\n }\n }\n\n var isKey = eventName === 'keydown' || eventName === 'keyup' || eventName === 'keypress';\n var keyTarget = null;\n if (isKey) {\n for (var m = 0; m < dir.modifiers.length; m++) {\n if (KEY_MAP[dir.modifiers[m]]) {\n keyTarget = KEY_MAP[dir.modifiers[m]];\n break;\n }\n }\n }\n\n var handler = function(e) {\n if (modifiers.has('prevent')) e.preventDefault();\n if (modifiers.has('stop')) e.stopPropagation();\n if (modifiers.has('self') && e.target !== el) return;\n\n if (keyTarget && e.key !== keyTarget) return;\n\n scope.$event = e;\n try {\n evaluateAssignment(dir.expression, scope, el);\n } finally {\n delete scope.$event;\n }\n };\n\n if (wrapFn) handler = wrapFn(handler);\n\n var options = {};\n if (modifiers.has('once')) options.once = true;\n if (modifiers.has('capture')) options.capture = true;\n if (modifiers.has('passive')) options.passive = true;\n\n target.addEventListener(eventName, handler, options);\n addCleanup(el, function() { target.removeEventListener(eventName, handler, options); });\n }\n\n // --- 3.10 l-ref ---\n\n function handleRef(el, dir, scope) {\n var name = dir.expression;\n var root = findScopeRoot(el);\n if (!root.__faqirRefs) root.__faqirRefs = {};\n root.__faqirRefs[name] = el;\n\n addCleanup(el, function() {\n if (root.__faqirRefs && root.__faqirRefs[name] === el) {\n delete root.__faqirRefs[name];\n }\n });\n }\n\n // --- 3.11 l-init ---\n\n function handleInit(el, dir, scope) {\n evaluateAssignment(dir.expression, scope, el);\n }\n\n // --- 3.12 l-effect ---\n\n function handleEffect(el, dir, scope) {\n var cl = effect(function() {\n evaluateAssignment(dir.expression, scope, el);\n });\n addCleanup(el, cl);\n }\n\n // --- 3.13 l-cloak ---\n\n function injectCloakStyle() {\n // Once per document. A second `Faqir.start()` used to append another\n // identical <style> to <head>, and nothing ever removed either. [W3-1]\n if (document.querySelector('style[data-faqir-cloak]')) return;\n var style = document.createElement('style');\n style.setAttribute('data-faqir-cloak', '');\n style.textContent = '[l-cloak] { display: none !important; }';\n document.head.appendChild(style);\n }\n\n /**\n * Strip `l-cloak` from `within` and everything under it (the whole document\n * when called with nothing).\n *\n * The sweep used to run exactly once, at the end of bootstrap, against a\n * document-wide selector. Anything inserted afterwards — an `l-if` branch, an\n * `l-for` row, a fragment an application appended — kept the attribute, and\n * the injected `[l-cloak] { display: none !important }` rule then hid it\n * permanently: content that had bound correctly and could never be seen. The\n * MutationObserver runs this over every node it is handed. [W3-1]\n */\n function removeCloaks(within) {\n var host = within || document;\n if (host.nodeType === 1 && host.hasAttribute('l-cloak')) {\n host.removeAttribute('l-cloak');\n }\n var els = host.querySelectorAll ? host.querySelectorAll('[l-cloak]') : [];\n for (var i = 0; i < els.length; i++) {\n els[i].removeAttribute('l-cloak');\n }\n }\n\n // --- 3.14 l-transition helpers (Transitions 2.0 — attribute-visible) [0.4-11 · §A4] ---\n //\n // The whole lifecycle is driven through ONE attribute, `data-motion`:\n // show: data-motion=\"enter\" → \"enter-active\" → (cleared)\n // hide: data-motion=\"leave\" → \"leave-active\" → (cleared, then removed)\n // registry/base/motion-presets.css styles each stage from motion tokens, so\n // transitions are auditable straight from the DOM. There are NO per-stage CSS\n // classes anywhere — state lives in an attribute and CSS reacts.\n\n // Named presets shipped by motion-presets.css. Unknown names still animate\n // (the attribute is stamped) but have no styling, so we warn to catch typos.\n var MOTION_PRESETS = { fade: 1, 'slide-up': 1, scale: 1 };\n\n function prefersReducedMotion() {\n return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n // Largest value in a computed CSS time list (\"0.2s, 150ms\" | \"0s\" | \"\"), in ms.\n function maxCssTimeMs(list) {\n var max = 0;\n (list || '').split(',').forEach(function(s) {\n var n = parseFloat(s);\n if (!isNaN(n)) max = Math.max(max, s.indexOf('ms') >= 0 ? n : n * 1000);\n });\n return max;\n }\n\n // How long to wait before force-completing a stage: the element's real\n // transition/animation duration + delay plus a small buffer. transitionend\n // wins when a transition actually runs; the timeout still settles us when the\n // property does not change, no preset CSS is loaded, or the event is missed.\n function motionTimeoutMs(el) {\n var s = getComputedStyle(el);\n return Math.max(\n maxCssTimeMs(s.transitionDuration) + maxCssTimeMs(s.transitionDelay),\n maxCssTimeMs(s.animationDuration) + maxCssTimeMs(s.animationDelay)\n ) + 50;\n }\n\n // Drive one enter/leave cycle purely through `data-motion` — no per-stage\n // classes. `phase` is 'enter' | 'leave'; `done` fires once the active stage\n // ends (transitionend/animationend) or the timeout fallback fires. The\n // attribute is always cleared on completion — no residue.\n function runMotion(el, phase, done) {\n done = done || function() {};\n\n // Call off a cycle still in flight on this element before starting a new\n // one. A toggle that arrives before the previous cycle completed used to\n // leave the old cycle's finisher armed, and it would then fire *into* the\n // new one: clearing the new `data-motion` mid-flight (so the element jumps\n // instead of animating), and — when the stale cycle was a leave — running\n // its `done`, which sets `display: none` on an element the new enter had\n // just made visible. One cancel handle per element, cleared on completion.\n if (el.__faqirMotion) el.__faqirMotion();\n el.__faqirMotion = null;\n\n if (prefersReducedMotion()) {\n el.removeAttribute('data-motion');\n done();\n return;\n }\n\n var preset = el.getAttribute('l-transition') || 'fade';\n if (!MOTION_PRESETS[preset]) {\n console.warn('[Faqir] l-transition: unknown preset \"' + preset +\n '\" — expected one of: fade, slide-up, scale');\n }\n\n el.setAttribute('data-motion', phase); // from-state (no transition yet)\n el.offsetHeight; // force reflow so the from-state commits\n\n var raf = typeof requestAnimationFrame === 'function'\n ? requestAnimationFrame\n : function(cb) { return setTimeout(cb, 16); };\n\n // Cancelled between the from-state and the rAF: the next cycle has already\n // stamped its own from-state, so this one must not stamp its active stage.\n var cancelled = false;\n el.__faqirMotion = function() { cancelled = true; };\n\n raf(function() {\n if (cancelled) return;\n el.setAttribute('data-motion', phase + '-active'); // to-state + transition\n\n var finished = false;\n var timer = null;\n function teardown() {\n clearTimeout(timer);\n el.removeEventListener('transitionend', onEnd);\n el.removeEventListener('animationend', onEnd);\n }\n function finish() {\n if (finished || cancelled) return;\n finished = true;\n teardown();\n el.__faqirMotion = null;\n el.removeAttribute('data-motion');\n done();\n }\n function onEnd(e) {\n if (e.target === el) finish(); // ignore transitions bubbling from children\n }\n\n el.addEventListener('transitionend', onEnd);\n el.addEventListener('animationend', onEnd);\n timer = setTimeout(finish, motionTimeoutMs(el));\n el.__faqirMotion = function() { cancelled = true; teardown(); };\n });\n }\n\n function runEnterTransition(el) {\n runMotion(el, 'enter');\n }\n\n function runLeaveTransition(el, done) {\n runMotion(el, 'leave', done);\n }\n\n // --- 3.15 l-model ---\n\n function handleModel(el, dir, scope) {\n var prop = dir.expression;\n var modifiers = new Set(dir.modifiers);\n\n // Every branch below binds a DOM listener, and not one of them ever removed\n // it: the effect disposer was registered, the `addEventListener` was not.\n // So `Faqir.destroy()` left five live listeners writing user input back into\n // a scope nothing was supposed to be driving any more — for the life of the\n // page, on every `l-model` the page had ever mounted. One helper, so a sixth\n // branch cannot forget. [W3-1]\n function bind(eventName, handler) {\n el.addEventListener(eventName, handler);\n addCleanup(el, function() { el.removeEventListener(eventName, handler); });\n }\n\n var tag = el.tagName.toLowerCase();\n var type = el.getAttribute('type');\n var isFaqirSwitch = el.hasAttribute('data-ui') && el.dataset.ui === 'switch';\n\n if (isFaqirSwitch) {\n var cl = effect(function() {\n var value = evaluate(prop, scope, el);\n el.checked = !!value;\n el.dataset.state = value ? 'on' : 'off';\n el.setAttribute('aria-checked', value ? 'true' : 'false');\n });\n bind('change', function() {\n writeModel(prop, el.checked, scope, el);\n });\n addCleanup(el, cl);\n\n } else if (tag === 'input' && type === 'checkbox') {\n var cl = effect(function() {\n var current = evaluate(prop, scope, el);\n if (Array.isArray(current)) {\n el.checked = current.indexOf(el.value) >= 0;\n } else {\n el.checked = !!current;\n }\n });\n bind('change', function() {\n var current = evaluate(prop, scope, el);\n if (Array.isArray(current)) {\n var arr = current.slice();\n var idx = arr.indexOf(el.value);\n if (el.checked && idx < 0) arr.push(el.value);\n else if (!el.checked && idx >= 0) arr.splice(idx, 1);\n writeModel(prop, arr, scope, el);\n } else {\n writeModel(prop, el.checked, scope, el);\n }\n });\n addCleanup(el, cl);\n\n } else if (tag === 'input' && type === 'radio') {\n var cl = effect(function() {\n el.checked = evaluate(prop, scope, el) === el.value;\n });\n bind('change', function() {\n if (el.checked) {\n writeModel(prop, el.value, scope, el);\n }\n });\n addCleanup(el, cl);\n\n } else if (tag === 'select') {\n var cl = effect(function() {\n el.value = evaluate(prop, scope, el) || '';\n });\n bind('change', function() {\n writeModel(prop, el.value, scope, el);\n });\n addCleanup(el, cl);\n\n } else {\n // text input, textarea, number input, etc.\n var eventName = modifiers.has('lazy') ? 'change' : 'input';\n\n var cl = effect(function() {\n var value = evaluate(prop, scope, el);\n if (el.value !== String(value != null ? value : '')) {\n el.value = value != null ? value : '';\n }\n });\n\n var inputHandler = function() {\n // Trim first: `.number.trim` must not call trim() on the parsed number.\n var value = el.value;\n if (modifiers.has('trim')) value = value.trim();\n if (modifiers.has('number')) value = parseFloat(value) || 0;\n writeModel(prop, value, scope, el);\n };\n\n if (modifiers.has('debounce')) {\n inputHandler = debounce(inputHandler, 300);\n }\n\n bind(eventName, inputHandler);\n addCleanup(el, cl);\n }\n }\n\n // --- 3.16 l-show ---\n\n function handleShow(el, dir, scope) {\n var originalDisplay = el.style.display === 'none' ? '' : el.style.display;\n\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n\n if (value) {\n el.style.display = originalDisplay;\n if (el.hasAttribute('l-transition')) {\n runEnterTransition(el);\n }\n } else {\n if (el.hasAttribute('l-transition')) {\n runLeaveTransition(el, function() {\n el.style.display = 'none';\n });\n } else {\n el.style.display = 'none';\n }\n }\n });\n\n addCleanup(el, cl);\n }\n\n // --- 3.17 l-if ---\n\n function handleIf(el, dir, scope) {\n if (el.tagName !== 'TEMPLATE') {\n console.warn('[Faqir] l-if must be used on a <template> element');\n return;\n }\n\n var anchor = document.createComment('l-if');\n el.parentNode.insertBefore(anchor, el);\n el.remove();\n\n // The anchor owns this directive's teardown.\n //\n // `el` is detached one line above, so `addCleanup(el, …)` resolved to no\n // owner and the disposer was discarded — `Faqir.destroy()` could not stop\n // an `l-if` at all. The anchor stands exactly where the template stood, so\n // it is inside the subtree `destroyScope` walks, and it survives every\n // toggle. [W3-1]\n anchor.__faqirCleanups = [];\n\n // EVERY node the template renders, not only the elements. Filtering to\n // `nodeType === 1` left text and comment nodes in the document on each\n // hide, so ten toggles of a two-element template left 34 child nodes where\n // 2 were expected — and each cycle added more. [W3-1]\n var insertedNodes = [];\n\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n\n if (value) {\n if (insertedNodes.length === 0) {\n var fragment = el.content.cloneNode(true);\n var nodes = [].slice.call(fragment.childNodes);\n\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].nodeType !== 1) continue;\n\n // A cloned top node carrying `l-data` is a scope root in its own\n // right. `processElement` has no `case 'data'` — nothing there\n // creates a scope — so the node was stamped with the ENCLOSING\n // scope, its literal never evaluated, and `processSourceDirectives`\n // never ran: `l-source` inside an `l-if` issued zero fetches.\n // `initTree` is the one path that builds a scope. [W3-1]\n if (nodes[i].hasAttribute('l-data')) {\n initTree(nodes[i], scope);\n continue;\n }\n\n // Mark as initialized (mirrors handleFor) so a later\n // walkChildren pass over an ancestor doesn't re-process these\n // nodes — re-processing would re-bind handlers and evaluate\n // expressions outside the scope they were rendered with.\n nodes[i].__faqirScope = scope;\n nodes[i].__faqirCleanups = nodes[i].__faqirCleanups || [];\n processElement(nodes[i], scope);\n // A top-level structural directive replaces the node with its own\n // anchor; there is then nothing left to walk into.\n if (nodes[i].parentNode) walkChildren(nodes[i], scope);\n }\n\n // Re-read the fragment rather than trusting the pre-processing\n // snapshot: a top-level `l-if`/`l-for` inside this template has by now\n // swapped its own <template> for an anchor plus rendered content, so\n // `nodes` describes something that no longer exists. (Same reason\n // `handleFor.createEntry` re-captures.)\n insertedNodes = [].slice.call(fragment.childNodes);\n anchor.parentNode.insertBefore(fragment, anchor.nextSibling);\n\n for (var i = 0; i < insertedNodes.length; i++) {\n if (insertedNodes[i].nodeType === 1 && insertedNodes[i].hasAttribute('l-transition')) {\n runEnterTransition(insertedNodes[i]);\n }\n }\n }\n } else {\n for (var i = 0; i < insertedNodes.length; i++) {\n var node = insertedNodes[i];\n if (node.nodeType === 1 && node.hasAttribute('l-transition')) {\n (function(n) {\n runLeaveTransition(n, function() {\n n.remove();\n });\n })(node);\n } else {\n node.remove();\n }\n destroyScope(node);\n }\n insertedNodes = [];\n }\n });\n\n addCleanup(el, cl, anchor);\n }\n\n // --- 3.18 l-for ---\n\n // Reactive, parent-delegating scope for a single l-for item. The item/index\n // slots are reactive so keyed reuse updates them with one property write\n // (no re-processing); every other read/write passes through to the parent\n // scope so mutations there still trigger reactivity.\n function createForItemScope(own, parentScope) {\n var deps = Object.create(null);\n return new Proxy(own, {\n get: function(target, key) {\n if (key === '__isReactive') return true;\n if (key === '__target') return target;\n if (key === '__deps') return parentScope.__deps;\n if (key in target) {\n if (currentEffect && typeof key === 'string') {\n if (!deps[key]) deps[key] = new Set();\n deps[key].add(currentEffect);\n currentEffect._deps.add(deps[key]);\n }\n var value = target[key];\n if (value !== null && typeof value === 'object' && !value.__isReactive\n && (Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype)) {\n return reactive(value);\n }\n return value;\n }\n return parentScope[key];\n },\n set: function(target, key, value) {\n if (key in target) {\n var old = target[key];\n if (old !== value) {\n target[key] = value;\n if (deps[key]) {\n for (var eff of deps[key]) pendingEffects.add(eff);\n scheduleFlush();\n }\n }\n return true;\n }\n parentScope[key] = value;\n return true;\n },\n has: function(target, key) {\n return (key in target) || (key in parentScope);\n }\n });\n }\n\n // Longest increasing subsequence of old positions (0 = freshly created entry,\n // skipped). Returns the indices of `arr` already in order — the nodes that\n // stay put across a reorder, so only the rest move. O(n log n). [0.3-06 · §A1]\n function getSequence(arr) {\n var p = arr.slice();\n var result = [0];\n var i, j, u, v, c;\n for (i = 0; i < arr.length; i++) {\n var n = arr[i];\n if (n !== 0) {\n j = result[result.length - 1];\n if (arr[j] < n) { p[i] = j; result.push(i); continue; }\n u = 0; v = result.length - 1;\n while (u < v) { c = (u + v) >> 1; if (arr[result[c]] < n) u = c + 1; else v = c; }\n if (n < arr[result[u]]) { if (u > 0) p[i] = result[u - 1]; result[u] = i; }\n }\n }\n u = result.length; v = result[u - 1];\n while (u-- > 0) { result[u] = v; v = p[v]; }\n return result;\n }\n\n // True when `b` is a non-identity permutation of `a` (same items, new order).\n // Drives the dev hint for unkeyed lists that reorder. [task 0.3-06 · §A1]\n // Dev-build only — production never detects the reorder. [task 0.7-12]\n\n function handleFor(el, dir, scope) {\n if (el.tagName !== 'TEMPLATE') {\n console.warn('[Faqir] l-for must be used on a <template> element');\n return;\n }\n\n var match = dir.expression.match(\n /^\\s*(?:\\(?\\s*(\\w+)\\s*(?:,\\s*(\\w+))?\\s*\\)?\\s+in\\s+)?(.+)\\s*$/\n );\n\n if (!match) {\n console.warn('[Faqir] Invalid l-for expression: \"' + dir.expression + '\"');\n return;\n }\n\n var itemName = match[1] || 'item';\n var indexName = match[2] || 'index';\n var listExpr = match[3];\n var keyExpr = el.getAttribute('l-key');\n\n var anchor = document.createComment('l-for');\n el.parentNode.insertBefore(anchor, el);\n el.remove();\n\n // Same as `l-if`: the template is detached above, so the anchor — which\n // stands where it stood and is reachable from `destroyScope` — is what owns\n // the list effect's disposer. Registering it against the detached template\n // dropped it, and a destroyed scope went on rendering rows. [W3-1]\n anchor.__faqirCleanups = [];\n\n // Reconciliation key for an item. Falls back to its position when there is\n // no l-key. Untracked so key reads never subscribe the list effect to\n // individual item properties.\n function keyFor(item, i) {\n if (!keyExpr) return i;\n var ctx = Object.create(null);\n ctx[itemName] = item;\n ctx[indexName] = i;\n var proxy = new Proxy(ctx, {\n has: function(t, k) { return (k in t) || (k in scope); },\n get: function(t, k) { return (k in t) ? t[k] : scope[k]; }\n });\n return untrack(function() { return evaluate(keyExpr, proxy, el); });\n }\n\n // Build one item's nodes + reactive scope from the template.\n function createEntry(item, i, key) {\n var clone = el.content.cloneNode(true);\n var nodes = [].slice.call(clone.childNodes);\n var own = Object.create(null);\n own[itemName] = item;\n own[indexName] = i;\n var childScope = createForItemScope(own, scope);\n for (var j = 0; j < nodes.length; j++) {\n if (nodes[j].nodeType !== 1) continue;\n // A row whose top node declares `l-data` is a scope root: build it with\n // `initTree` (which evaluates the literal and reads `l-source`) instead\n // of stamping it with the row scope and leaving both inert. [W3-1]\n if (nodes[j].hasAttribute('l-data')) {\n initTree(nodes[j], childScope);\n continue;\n }\n nodes[j].__faqirScope = childScope;\n nodes[j].__faqirCleanups = [];\n processElement(nodes[j], childScope);\n if (nodes[j].parentNode) walkChildren(nodes[j], childScope);\n }\n // Re-capture the fragment's children: a top-level structural directive\n // (l-if / nested l-for) replaces its <template> with an anchor comment\n // plus rendered content INSIDE the fragment. The pre-processing `nodes`\n // snapshot would re-insert the detached template and orphan the anchor,\n // so the entry must own what the fragment actually holds now.\n return { key: key, scope: childScope, nodes: [].slice.call(clone.childNodes) };\n }\n\n var currentEntries = [];\n\n var cl = effect(function() {\n var list = evaluate(listExpr, scope, el);\n var items = Array.isArray(list) ? list :\n typeof list === 'number' ? Array.from({ length: list }, function(_, i) { return i + 1; }) :\n [];\n\n // Dev-build hint: an unkeyed list reconciles by position, so reordering it\n // rebinds per-row DOM state to the wrong items. Once per list; keyed lists\n // never reach here. Production neither warns nor snapshots the list.\n\n // old key -> entries holding it, in order, consumed as matched; the\n // leftovers are stale. A list rather than one entry because keys can\n // repeat: a Map of single entries overwrote the first row of a duplicate\n // pair, which then was neither reused nor removed and leaked a row per\n // render. source[i] = reused entry's old position + 1, or 0 for a fresh\n // entry (the getSequence sentinel).\n var oldMap = new Map();\n for (var i = 0; i < currentEntries.length; i++) {\n var k = currentEntries[i].key;\n if (oldMap.has(k)) oldMap.get(k).push(currentEntries[i]);\n else oldMap.set(k, [currentEntries[i]]);\n }\n\n var n = items.length;\n var newEntries = new Array(n);\n var source = new Array(n);\n for (var i = 0; i < n; i++) {\n var key = keyFor(items[i], i);\n var olds = oldMap.get(key);\n var entry = olds && olds.shift();\n if (entry !== undefined) {\n // Reuse in place: one write per slot, re-renders only on change.\n entry.scope[itemName] = items[i];\n entry.scope[indexName] = i;\n source[i] = entry.__i + 1;\n } else {\n entry = createEntry(items[i], i, key);\n source[i] = 0;\n }\n newEntries[i] = entry;\n }\n\n // Remove stale entries first so the DOM holds only reused nodes.\n oldMap.forEach(function(olds) {\n for (var e = 0; e < olds.length; e++) {\n for (var j = 0; j < olds[e].nodes.length; j++) {\n destroyScope(olds[e].nodes[j]);\n olds[e].nodes[j].remove();\n }\n }\n });\n\n // Place back-to-front, inserting before `anchor` (the trailing marker).\n // Entries in the longest increasing subsequence of old positions are\n // already ordered and never move; the rest insert before their placed\n // successor — the minimum number of DOM moves.\n var seq = getSequence(source);\n var sj = seq.length - 1;\n var nextNode = anchor;\n for (var i = n - 1; i >= 0; i--) {\n var entry = newEntries[i];\n if (source[i] === 0 || sj < 0 || i !== seq[sj]) {\n for (var j = 0; j < entry.nodes.length; j++) {\n anchor.parentNode.insertBefore(entry.nodes[j], nextNode);\n }\n } else {\n sj--;\n }\n entry.__i = i;\n nextNode = entry.nodes[0];\n }\n\n currentEntries = newEntries;\n });\n\n addCleanup(el, cl, anchor);\n }\n\n // --- 3.19 l-teleport ---\n\n function handleTeleport(el, dir, scope) {\n // Teleporting moves the element OUT of its scope root's subtree, so from\n // here on `findCleanupRoot` walking up from anything inside it lands\n // somewhere else entirely — every disposer bound below a teleport was\n // dropped, and `destroyScope` on the scope root could never have reached\n // the nodes anyway. Two moves fix both halves: the subtree owns its own\n // cleanup list from now on, and the scope that WROTE the teleport keeps a\n // handle that tears that list down. [W3-1]\n var owner = el.parentNode ? findCleanupRoot(el.parentNode) : null;\n if (!el.__faqirCleanups) el.__faqirCleanups = [];\n\n // The teleported subtree belongs to the scope that wrote the directive, but\n // it now sits somewhere the scope-root sweep will never look — so the\n // unscoped sweep would find it \"unclaimed\" and bind every directive under it\n // a SECOND time, against the document scope, where the expressions do not\n // resolve. Claiming it here is what tells that sweep to walk past. [W3-1]\n el.__faqirStray = true;\n\n var cl = effect(function() {\n var target = document.querySelector(dir.expression);\n if (target && el.parentNode !== target) {\n target.appendChild(el);\n }\n });\n addCleanup(el, cl);\n\n if (owner && owner !== el) {\n addCleanup(el, function() {\n destroyScope(el);\n el.remove();\n }, owner);\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 4-5: Faqir Bridge ($state, $variant, $ui)\n // ═══════════════════════════════════════════════════════\n\n function closestUI(el) {\n if (!el) return null;\n if (el.hasAttribute && el.hasAttribute('data-ui')) return el;\n return el.closest ? el.closest('[data-ui]') : null;\n }\n\n function getControllerApi(uiEl) {\n if (!uiEl) return null;\n var keys = Object.keys(uiEl);\n for (var i = 0; i < keys.length; i++) {\n if (keys[i].startsWith('_faqir')) {\n return uiEl[keys[i]];\n }\n }\n return null;\n }\n\n /**\n * `$ui`, in both of its forms. [W2-6]\n *\n * `$ui.open()` — unchanged: the controller of the `[data-ui]` this expression\n * sits inside. That is the only thing `$ui` could ever reach, and it is why\n * opening a detail drawer from a table row — the most common admin pattern\n * there is — had no expression that could say it. The page had to invent a\n * global store and an `l-effect` handshake to carry \"the user clicked row 7\"\n * across two components that were both right there in the DOM.\n *\n * `$ui('#detail-drawer').open()` — the same controller API, for a component\n * named by a CSS selector. Any selector: an id is the useful case, but\n * `$ui('[data-ui=\"drawer\"]')` resolves the first drawer on the page just as\n * well. The selector may match the `[data-ui]` element itself or anything\n * inside it; either way the nearest enclosing component's controller answers.\n *\n * Returns `null` when nothing matches or the match has no controller, so\n * `$ui('#gone')?.open()` is the safe form and a typo cannot throw.\n */\n function resolveUi(target) {\n var node = typeof target === 'string' ? document.querySelector(target) : target;\n return node ? getControllerApi(closestUI(node)) : null;\n }\n\n function uiHandle(el) {\n var local = getControllerApi(closestUI(el));\n // A callable, with the local controller's own methods hung off it so both\n // forms read from one name. The methods are closures over their controller's\n // state, never `this`-bound, so carrying the reference is enough.\n var handle = function(target) { return resolveUi(target); };\n if (local) for (var key in local) handle[key] = local[key];\n return handle;\n }\n\n function setupStateBridge(root, scope) {\n var uiEl = root.hasAttribute('data-ui') ? root : (root.closest ? root.closest('[data-ui]') : null);\n if (!uiEl) return;\n\n var observer = new MutationObserver(function(mutations) {\n for (var i = 0; i < mutations.length; i++) {\n var attr = mutations[i].attributeName;\n if (attr === 'data-state' || attr === 'data-variant') {\n triggerStateDeps(scope);\n }\n }\n });\n\n observer.observe(uiEl, {\n attributes: true,\n attributeFilter: ['data-state', 'data-variant']\n });\n\n addCleanup(root, function() { observer.disconnect(); });\n }\n\n function triggerStateDeps(scope) {\n var deps = scope.__deps;\n if (!deps) return;\n if (deps['$state']) {\n for (var eff of deps['$state']) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n if (deps['$variant']) {\n for (var eff of deps['$variant']) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 6: Core Utilities\n // ═══════════════════════════════════════════════════════\n\n // --- From dom.js ---\n var $ = function(selector, scope) { return (scope || document).querySelector(selector); };\n var $$ = function(selector, scope) { return [].slice.call((scope || document).querySelectorAll(selector)); };\n\n function create(tag, attrs) {\n var el = document.createElement(tag);\n if (attrs) {\n var keys = Object.keys(attrs);\n for (var i = 0; i < keys.length; i++) {\n el.setAttribute(keys[i], attrs[keys[i]]);\n }\n }\n for (var j = 2; j < arguments.length; j++) {\n var child = arguments[j];\n el.append(typeof child === 'string' ? document.createTextNode(child) : child);\n }\n return el;\n }\n\n // --- From events.js ---\n function delegate(root, event, selector, handler) {\n function listener(e) {\n var target = e.target.closest(selector);\n if (target && root.contains(target)) handler(e, target);\n }\n root.addEventListener(event, listener);\n return function() { root.removeEventListener(event, listener); };\n }\n\n function once(el, event, handler) {\n function listener(e) { cleanupOnce(); handler(e); }\n function cleanupOnce() { el.removeEventListener(event, listener); }\n el.addEventListener(event, listener);\n return cleanupOnce;\n }\n\n function onOutsideClick(el, handler) {\n function listener(e) { if (!el.contains(e.target)) handler(e); }\n document.addEventListener('pointerdown', listener);\n return function() { document.removeEventListener('pointerdown', listener); };\n }\n\n // --- From focus.js ---\n var FOCUSABLE = [\n 'a[href]:not([tabindex=\"-1\"])',\n 'button:not([disabled]):not([tabindex=\"-1\"])',\n 'input:not([disabled]):not([tabindex=\"-1\"])',\n 'select:not([disabled]):not([tabindex=\"-1\"])',\n 'textarea:not([disabled]):not([tabindex=\"-1\"])',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(',');\n\n function getFocusableElements(container) {\n return [].slice.call(container.querySelectorAll(FOCUSABLE)).filter(function(el) {\n return !el.closest('[hidden]') && el.offsetParent !== null;\n });\n }\n\n function focusFirst(container) {\n var els = getFocusableElements(container);\n if (els.length > 0) { els[0].focus(); return true; }\n return false;\n }\n\n function trapFocus(container) {\n function onKeyDown(e) {\n if (e.key !== 'Tab') return;\n var focusable = getFocusableElements(container);\n if (focusable.length === 0) return;\n var first = focusable[0], last = focusable[focusable.length - 1];\n if (e.shiftKey) {\n if (document.activeElement === first) { e.preventDefault(); last.focus(); }\n } else {\n if (document.activeElement === last) { e.preventDefault(); first.focus(); }\n }\n }\n container.addEventListener('keydown', onKeyDown);\n return function() { container.removeEventListener('keydown', onKeyDown); };\n }\n\n // --- From motion.js (prefersReducedMotion already defined in Section 3.14) ---\n function waitForTransition(el) {\n if (prefersReducedMotion()) return Promise.resolve();\n var style = getComputedStyle(el);\n var hasDuration = parseFloat(style.transitionDuration) > 0 ||\n (style.animationName !== 'none' && parseFloat(style.animationDuration) > 0);\n if (!hasDuration) return Promise.resolve();\n return new Promise(function(resolve) {\n function done(e) {\n if (e.target !== el) return;\n el.removeEventListener('transitionend', done);\n el.removeEventListener('animationend', done);\n resolve();\n }\n el.addEventListener('transitionend', done);\n el.addEventListener('animationend', done);\n });\n }\n\n // The four events an exit can end with, in one list: bound and unbound\n // together, so neither half can drift from the other.\n var EXIT_EVENTS = ['transitionend', 'transitioncancel', 'animationend', 'animationcancel'];\n\n // Largest number in a comma-separated CSS time list, in ms (\"0.3s, 150ms\" → 300).\n function longestTimeMs(value) {\n var parts = String(value == null ? '' : value).split(',');\n var max = 0;\n for (var i = 0; i < parts.length; i++) {\n var raw = parts[i].trim();\n var n = parseFloat(raw);\n if (isNaN(n)) continue;\n if (raw.indexOf('ms') === -1) n *= 1000;\n if (n > max) max = n;\n }\n return max;\n }\n\n // An upper bound on how long `el`'s motion can run: the longest transition or\n // animation plus the longest delay. Deliberately an over-estimate — it sizes a\n // fallback timer, and a fallback that fires early is worse than one that fires\n // late.\n function longestMotionMs(style) {\n var transition = longestTimeMs(style.transitionDuration) + longestTimeMs(style.transitionDelay);\n var animation = longestTimeMs(style.animationDuration) + longestTimeMs(style.animationDelay);\n return transition > animation ? transition : animation;\n }\n\n /**\n * Run `done` once `el` has finished its exit motion — the single place every\n * \"closing → closed\" controller waits.\n *\n * `transitionend` BUBBLES. A panel that contains a button — every dialog,\n * drawer and sheet in the registry ships one, and the drawer manifest marks\n * the close button `required` — receives that button's own `background`\n * transitionend the instant a pointer lands on it. A one-shot listener spends\n * itself on that event and the panel's own `transform` transitionend, when it\n * arrives, finds nobody listening. The drawer therefore never finalised\n * `closing → closed` through the one control it tells you not to remove: the\n * overlay stayed up, `body` stayed at `overflow: hidden`, the page was dead.\n *\n * So four rules, all of them load-bearing:\n * • only `el`'s OWN motion counts (`e.target === el`) — descendants bubble;\n * • only `property`, when one is named — sibling properties on the same\n * element finish at their own times;\n * • `transitioncancel` / `animationcancel` count as over — an interrupted\n * transition never sends `transitionend` at all;\n * • a timer sized from the computed duration runs `done` even if no event\n * ever arrives (backgrounded tab, `display` change mid-flight).\n *\n * `done` runs at most once — synchronously and immediately when there is no\n * motion to wait for. Returns a canceller for a re-entrant open. [W2-1]\n */\n function whenExitDone(el, property, done) {\n var settled = false;\n var timer = null;\n\n function unbind() {\n if (timer !== null) { clearTimeout(timer); timer = null; }\n for (var i = 0; i < EXIT_EVENTS.length; i++) el.removeEventListener(EXIT_EVENTS[i], onMotionEvent);\n }\n\n function settle() {\n if (settled) return;\n settled = true;\n unbind();\n done();\n }\n\n function onMotionEvent(e) {\n if (e.target !== el) return;\n if (property && e.propertyName && e.propertyName !== property) return;\n settle();\n }\n\n var ms = 0;\n try {\n ms = longestMotionMs(getComputedStyle(el));\n } catch (err) {\n // No computed style (a bare test DOM) — treat it as \"no motion\".\n }\n\n if (!(ms > 0)) { settle(); return function() {}; }\n\n for (var i = 0; i < EXIT_EVENTS.length; i++) el.addEventListener(EXIT_EVENTS[i], onMotionEvent);\n // A couple of frames of slack before the fallback takes over from the event.\n timer = setTimeout(settle, ms + 50);\n\n return function cancelExitWait() {\n if (settled) return;\n settled = true;\n unbind();\n };\n }\n\n // --- From utils.js (debounce/throttle already defined in Section 3.9) ---\n var uidCounter = 0;\n function uid(prefix) { return (prefix || 'faqir') + '-' + (++uidCounter); }\n function clamp(value, min, max) { return Math.min(Math.max(value, min), max); }\n\n // Shared menu navigation is injected from registry/core/menu-navigation.js.\n // Keeping the module as the authored source lets standalone recipe imports\n // and the assembled browser runtime execute the exact same implementation.\n // ── shared menu navigation ── (registry/core/menu-navigation.js)\n // @ui:core menu-navigation\n // @ui:provides createMenuNavigation\n\n const MENU_ITEM_SELECTOR =\n '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\n const MENU_OWNER_SELECTOR = '[role=\"menu\"], [role=\"menubar\"]';\n\n /**\n * Shared keyboard and focus navigation for menus and menubars.\n *\n * The helper deliberately owns movement only. Controllers remain responsible\n * for opening/closing popups and reflecting component state.\n *\n * @param {Element} container element carrying role=menu or role=menubar\n * @param {object} [options]\n * @param {\"vertical\"|\"horizontal\"} [options.orientation=\"vertical\"]\n * @param {boolean} [options.roving=false] maintain one tabindex=0 item\n * @param {(item: Element, event: KeyboardEvent) => void} [options.onActivate]\n * @param {(event: KeyboardEvent) => void} [options.onEscape]\n * @param {(event: KeyboardEvent) => void} [options.onTab]\n */\n function createMenuNavigation(container, options = {}) {\n const horizontal = options.orientation === \"horizontal\";\n const roving = options.roving === true;\n const forwardKey = horizontal ? \"ArrowRight\" : \"ArrowDown\";\n const backwardKey = horizontal ? \"ArrowLeft\" : \"ArrowUp\";\n\n function candidates() {\n return [...container.querySelectorAll(MENU_ITEM_SELECTOR)].filter(\n (item) => item.closest(MENU_OWNER_SELECTOR) === container,\n );\n }\n\n // Native disabled controls cannot receive focus. aria-disabled menuitems stay\n // in the arrow sequence per the WAI-ARIA menu pattern; activation is blocked\n // separately below.\n function items() {\n return candidates().filter((item) => !item.disabled);\n }\n\n function current() {\n const all = items();\n const active = document.activeElement;\n if (all.includes(active)) return active;\n return roving ? all.find((item) => item.tabIndex === 0) || null : null;\n }\n\n function sync(preferred) {\n if (!roving) return preferred || current();\n\n const all = items();\n let active = all.includes(preferred) ? preferred : null;\n if (!active && all.includes(document.activeElement)) active = document.activeElement;\n if (!active) active = all.find((item) => item.tabIndex === 0) || all[0] || null;\n\n for (const item of candidates()) item.tabIndex = item === active ? 0 : -1;\n return active;\n }\n\n function focus(index) {\n const all = items();\n if (all.length === 0) return null;\n\n const item = all[((index % all.length) + all.length) % all.length];\n sync(item);\n item.focus();\n return item;\n }\n\n function currentIndex() {\n return items().indexOf(current());\n }\n\n function focusFirst() {\n return focus(0);\n }\n\n function focusLast() {\n return focus(items().length - 1);\n }\n\n function focusNext() {\n const index = currentIndex();\n return focus(index < 0 ? 0 : index + 1);\n }\n\n function focusPrevious() {\n const index = currentIndex();\n return focus(index < 0 ? items().length - 1 : index - 1);\n }\n\n function eventItem(event) {\n const item = event.target.closest?.(MENU_ITEM_SELECTOR);\n if (item?.closest(MENU_OWNER_SELECTOR) === container) return item;\n return event.target === container ? current() : null;\n }\n\n function onKeyDown(event) {\n // Nested menu events bubble through their parent menubar. Only the nearest\n // menu/menubar owns a menuitem's key handling. Escape and Tab still belong\n // to an empty menu, including legacy markup where the container lacks a role.\n const owner = event.target.closest?.(MENU_OWNER_SELECTOR);\n if (owner ? owner !== container : event.target !== container) return;\n\n if (event.key === \"Escape\" && options.onEscape) {\n event.preventDefault();\n // Escape DISMISSES ONE THING. Without stopping it here the same keystroke\n // reached every ancestor overlay: closing a dropdown inside a dialog\n // closed the dialog too, and with it whatever the user had typed. The\n // callback opts out by returning `false` — its way of saying \"this\n // Escape was not mine\", so it still reaches whatever encloses us. [W3-2]\n const handled = options.onEscape(event);\n if (handled !== false) event.stopPropagation();\n return;\n }\n if (event.key === \"Tab\" && options.onTab) {\n options.onTab(event);\n return;\n }\n\n const targetItem = eventItem(event);\n if (!targetItem) return;\n\n if (event.key === forwardKey) {\n event.preventDefault();\n focusNext();\n return;\n }\n if (event.key === backwardKey) {\n event.preventDefault();\n focusPrevious();\n return;\n }\n if (event.key === \"Home\") {\n event.preventDefault();\n focusFirst();\n return;\n }\n if (event.key === \"End\") {\n event.preventDefault();\n focusLast();\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (targetItem.getAttribute(\"aria-disabled\") !== \"true\") {\n if (options.onActivate) options.onActivate(targetItem, event);\n else targetItem.click();\n }\n }\n }\n\n function onFocusIn(event) {\n const item = eventItem(event);\n if (item) sync(item);\n }\n\n container.addEventListener(\"keydown\", onKeyDown);\n if (roving) container.addEventListener(\"focusin\", onFocusIn);\n sync();\n\n function destroy() {\n container.removeEventListener(\"keydown\", onKeyDown);\n if (roving) container.removeEventListener(\"focusin\", onFocusIn);\n }\n\n return {\n items,\n current,\n sync,\n focus,\n focusFirst,\n focusLast,\n focusNext,\n focusPrevious,\n destroy,\n };\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 7: Recipe Controllers\n // ═══════════════════════════════════════════════════════\n\n var controllerRegistry = {};\n\n // Recipe controller factories are assembled here by scripts/build-core.mjs\n // from registry/recipes/<name>/<name>.js. Do NOT hand-edit the generated\n // registry/core/faqir-core.js — edit the recipe files (or this engine\n // source) and run `bun run build:core`. See CONTRIBUTING.md.\n // ── accordion ── (registry/recipes/accordion/accordion.js)\n var createAccordion = controllerRegistry[\"accordion\"] = (function() {\n// @ui:controller accordion\n// @ui:provides toggle expand collapse expandAll collapseAll destroy\n\nfunction createAccordion(root) {\n // Prevent double-init\n if (root._faqirAccordion) return root._faqirAccordion;\n\n const getItems = () => [...root.querySelectorAll(\"[data-part='item']\")];\n const isSingle = () => root.dataset.variant === \"single\";\n\n function expand(index) {\n const items = getItems();\n if (index < 0 || index >= items.length) return;\n\n // In single mode, collapse all others first\n if (isSingle()) {\n items.forEach((item, i) => {\n if (i !== index) collapseItem(item);\n });\n }\n\n expandItem(items[index]);\n }\n\n function collapse(index) {\n const items = getItems();\n if (index < 0 || index >= items.length) return;\n collapseItem(items[index]);\n }\n\n function toggle(index) {\n const items = getItems();\n if (index < 0 || index >= items.length) return;\n\n if (items[index].dataset.state === \"expanded\") {\n collapse(index);\n } else {\n expand(index);\n }\n }\n\n function expandAll() {\n const items = getItems();\n items.forEach((item) => expandItem(item));\n }\n\n function collapseAll() {\n const items = getItems();\n items.forEach((item) => collapseItem(item));\n }\n\n function expandItem(item) {\n item.dataset.state = \"expanded\";\n const trigger = item.querySelector(\"[data-part='trigger']\");\n const content = item.querySelector(\"[data-part='content']\");\n if (trigger) trigger.setAttribute(\"aria-expanded\", \"true\");\n if (content) content.hidden = false;\n }\n\n function collapseItem(item) {\n item.dataset.state = \"collapsed\";\n const trigger = item.querySelector(\"[data-part='trigger']\");\n const content = item.querySelector(\"[data-part='content']\");\n if (trigger) trigger.setAttribute(\"aria-expanded\", \"false\");\n if (content) content.hidden = true;\n }\n\n function onTriggerClick(e) {\n const trigger = e.target.closest(\"[data-part='trigger']\");\n if (!trigger) return;\n const item = trigger.closest(\"[data-part='item']\");\n if (!item) return;\n const items = getItems();\n const index = items.indexOf(item);\n if (index >= 0) toggle(index);\n }\n\n function onKeyDown(e) {\n if (e.key === \"Enter\" || e.key === \" \") {\n const trigger = e.target.closest(\"[data-part='trigger']\");\n if (trigger) {\n e.preventDefault();\n const item = trigger.closest(\"[data-part='item']\");\n if (!item) return;\n const items = getItems();\n const index = items.indexOf(item);\n if (index >= 0) toggle(index);\n }\n }\n }\n\n root.addEventListener(\"click\", onTriggerClick);\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n root.removeEventListener(\"click\", onTriggerClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirAccordion;\n }\n\n const api = { toggle, expand, collapse, expandAll, collapseAll, destroy };\n root._faqirAccordion = api;\n return api;\n}\n return createAccordion;\n })();\n\n // ── alert-dialog ── (registry/recipes/alert-dialog/alert-dialog.js)\n var createAlertDialog = controllerRegistry[\"alert-dialog\"] = (function() {\n// @ui:controller alert-dialog\n// @ui:provides open close toggle destroy\n\n/**\n * alert-dialog reuses the `dialog` controller wholesale — there is no forked or\n * duplicated controller here. An alert dialog IS a dialog whose panel carries\n * `role=\"alertdialog\"`; the shared controller in ../dialog/dialog.js reads that\n * role and switches on the WAI-ARIA alertdialog behaviours (no overlay-dismiss,\n * focus the least-destructive action, guarded Escape, confirm/cancel events).\n * This factory only exists so the recipe is discoverable under its own\n * `data-ui=\"alert-dialog\"` name and auto-registers from the built core.\n */\nfunction createAlertDialog(root) {\n // Resolve the shared dialog factory in both worlds this controller runs in:\n // • as an ES module (behaviour tests, `faqir add`): the `import` above binds\n // `createDialog` directly.\n // • inlined into the built registry/core/faqir-core.js: scripts/build-core.mjs\n // strips the import, but every recipe factory is registered on the engine's\n // private `controllerRegistry`, so pick `dialog` up from there.\n // `typeof` is used because a bare reference to a stripped/undeclared binding\n // would throw — `typeof` on an unknown identifier is the one safe probe.\n const dialogFactory =\n (typeof createDialog === \"function\" && createDialog) ||\n (typeof controllerRegistry !== \"undefined\" && controllerRegistry[\"dialog\"]);\n\n if (typeof dialogFactory !== \"function\") {\n throw new Error(\"alert-dialog requires the dialog controller to be available\");\n }\n return dialogFactory(root);\n}\n return createAlertDialog;\n })();\n\n // ── barcode ── (registry/recipes/barcode/barcode.js)\n var createBarcode = controllerRegistry[\"barcode\"] = (function() {\n// @ui:controller barcode\n// @ui:provides render update destroy\n\n/**\n * Code 128-B encoder and SVG renderer.\n *\n * Code set B covers printable ASCII (U+0020–U+007E), which keeps the public\n * contract predictable while supporting document identifiers, URLs, and\n * ordinary business text. The generated symbol includes a modulo-103 check\n * character, the stop pattern, and ten-module quiet zones on both sides.\n */\n\nconst CODE128_PATTERNS = Object.freeze([\n \"212222\", \"222122\", \"222221\", \"121223\", \"121322\", \"131222\",\n \"122213\", \"122312\", \"132212\", \"221213\", \"221312\", \"231212\",\n \"112232\", \"122132\", \"122231\", \"113222\", \"123122\", \"123221\",\n \"223211\", \"221132\", \"221231\", \"213212\", \"223112\", \"312131\",\n \"311222\", \"321122\", \"321221\", \"312212\", \"322112\", \"322211\",\n \"212123\", \"212321\", \"232121\", \"111323\", \"131123\", \"131321\",\n \"112313\", \"132113\", \"132311\", \"211313\", \"231113\", \"231311\",\n \"112133\", \"112331\", \"132131\", \"113123\", \"113321\", \"133121\",\n \"313121\", \"211331\", \"231131\", \"213113\", \"213311\", \"213131\",\n \"311123\", \"311321\", \"331121\", \"312113\", \"312311\", \"332111\",\n \"314111\", \"221411\", \"431111\", \"111224\", \"111422\", \"121124\",\n \"121421\", \"141122\", \"141221\", \"112214\", \"112412\", \"122114\",\n \"122411\", \"142112\", \"142211\", \"241211\", \"221114\", \"413111\",\n \"241112\", \"134111\", \"111242\", \"121142\", \"121241\", \"114212\",\n \"124112\", \"124211\", \"411212\", \"421112\", \"421211\", \"212141\",\n \"214121\", \"412121\", \"111143\", \"111341\", \"131141\", \"114113\",\n \"114311\", \"411113\", \"411311\", \"113141\", \"114131\", \"311141\",\n \"411131\", \"211412\", \"211214\", \"211232\", \"2331112\",\n]);\n\nconst START_B = 104;\nconst STOP = 106;\nconst QUIET_ZONE = 10;\nconst BAR_HEIGHT = 50;\n\nfunction encodeCode128B(value) {\n if (!value) throw new Error(\"value is empty\");\n\n const data = [];\n let inputIndex = 0;\n for (const character of value) {\n const codePoint = character.codePointAt(0);\n if (codePoint < 32 || codePoint > 126) {\n const printable = JSON.stringify(character);\n throw new Error(\n `unsupported character ${printable} at index ${inputIndex}; Code 128-B accepts printable ASCII only`,\n );\n }\n data.push(codePoint - 32);\n inputIndex += character.length;\n }\n\n let weighted = START_B;\n for (let i = 0; i < data.length; i++) weighted += data[i] * (i + 1);\n const checksum = weighted % 103;\n const codewords = [START_B, ...data, checksum, STOP];\n const pattern = codewords.map((value) => CODE128_PATTERNS[value]).join(\"\");\n\n return { checksum, codewords, pattern };\n}\n\nfunction patternToSVG(encoded) {\n const patternWidth = [...encoded.pattern].reduce((sum, width) => sum + Number(width), 0);\n const totalWidth = patternWidth + QUIET_ZONE * 2;\n\n let x = QUIET_ZONE;\n let isBar = true;\n let pathData = \"\";\n for (const digit of encoded.pattern) {\n const width = Number(digit);\n if (isBar) pathData += `M${x},0h${width}v${BAR_HEIGHT}h-${width}z`;\n x += width;\n isBar = !isBar;\n }\n\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"viewBox\", `0 0 ${totalWidth} ${BAR_HEIGHT}`);\n svg.setAttribute(\"width\", String(totalWidth));\n svg.setAttribute(\"height\", String(BAR_HEIGHT));\n svg.setAttribute(\"preserveAspectRatio\", \"xMidYMid meet\");\n svg.setAttribute(\"shape-rendering\", \"crispEdges\");\n svg.setAttribute(\"data-part\", \"svg\");\n svg.setAttribute(\"data-checksum\", String(encoded.checksum));\n svg.setAttribute(\"data-pattern\", encoded.pattern);\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"focusable\", \"false\");\n\n const background = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n background.setAttribute(\"width\", String(totalWidth));\n background.setAttribute(\"height\", String(BAR_HEIGHT));\n background.setAttribute(\"fill\", \"var(--color-bg, #fff)\");\n svg.appendChild(background);\n\n const bars = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n bars.setAttribute(\"d\", pathData);\n bars.setAttribute(\"fill\", \"var(--color-fg, #000)\");\n svg.appendChild(bars);\n\n return svg;\n}\n\nfunction createBarcode(root) {\n if (root._faqirBarcode) return root._faqirBarcode;\n\n function removeGeneratedSVG() {\n const svg = root.querySelector(\":scope > [data-part='svg']\");\n if (svg) svg.remove();\n }\n\n function render() {\n removeGeneratedSVG();\n const value = root.getAttribute(\"data-value\") || \"\";\n\n if (!value) {\n root.dataset.state = \"empty\";\n return;\n }\n\n try {\n const svg = patternToSVG(encodeCode128B(value));\n const caption = root.querySelector(\":scope > [data-part='caption']\");\n if (caption) root.insertBefore(svg, caption);\n else root.appendChild(svg);\n root.dataset.state = \"ready\";\n } catch (error) {\n root.dataset.state = \"error\";\n const message = error instanceof Error ? error.message : String(error);\n console.warn(`[barcode] Failed to encode: ${message}`);\n }\n }\n\n function update(newValue) {\n if (newValue !== undefined) root.setAttribute(\"data-value\", newValue);\n render();\n }\n\n const observer = new MutationObserver((mutations) => {\n if (mutations.some((mutation) => mutation.attributeName === \"data-value\")) render();\n });\n observer.observe(root, { attributes: true, attributeFilter: [\"data-value\"] });\n\n function destroy() {\n observer.disconnect();\n removeGeneratedSVG();\n if ([\"empty\", \"ready\", \"error\"].includes(root.dataset.state)) delete root.dataset.state;\n delete root._faqirBarcode;\n }\n\n const api = { render, update, destroy };\n root._faqirBarcode = api;\n render();\n return api;\n}\n return createBarcode;\n })();\n\n // ── calendar ── (registry/recipes/calendar/calendar.js)\n var createCalendar = controllerRegistry[\"calendar\"] = (function() {\n// @ui:controller calendar\n// @ui:provides getValue setValue clear navigate selectDate focusDate setMin setMax setDisabledDates destroy\n\nconst MONTH_NAMES = [\n \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\",\n];\n\nconst DAY_NAMES = [\n \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\",\n];\n\nfunction parseISO(str) {\n if (!str) return null;\n const d = new Date(str + \"T00:00:00\");\n return isNaN(d.getTime()) ? null : d;\n}\n\nfunction createCalendar(root) {\n // Prevent double-init\n if (root._faqirCalendar) return root._faqirCalendar;\n\n const navPrev = root.querySelector(\"[data-part='nav-prev']\");\n const navNext = root.querySelector(\"[data-part='nav-next']\");\n const monthLabel = root.querySelector(\"[data-part='month-label']\");\n const gridBody = root.querySelector(\"[data-part='grid-body']\");\n\n // `grid-body` is the one part every render writes into: without it the first\n // `render()` throws on `gridBody.innerHTML`, taking the date-picker that\n // wraps it down with it. The optional parts (nav, month label) are already\n // guarded individually. [W3-2]\n if (!gridBody) {\n console.warn(\n \"[Faqir] calendar needs [data-part='grid-body'] to render into. \" +\n \"Component left inert.\",\n root\n );\n const inert = {\n getValue: () => null,\n setValue() {},\n clear() {},\n navigate() {},\n selectDate() {},\n focusDate() {},\n setMin() {},\n setMax() {},\n setDisabledDates() {},\n destroy() {},\n };\n root._faqirCalendar = inert;\n return inert;\n }\n\n const today = new Date();\n const mode = root.dataset.mode === \"range\" ? \"range\" : \"single\";\n\n let minDate = parseISO(root.dataset.min);\n let maxDate = parseISO(root.dataset.max);\n let disabledDates = parseDateList(root.dataset.disabledDates);\n\n let selectedDate = null;\n let rangeStart = null;\n let rangeEnd = null;\n if (root.dataset.value) {\n if (mode === \"range\") {\n const parts = root.dataset.value.split(\",\");\n rangeStart = parseISO(parts[0] && parts[0].trim());\n rangeEnd = parseISO(parts[1] && parts[1].trim());\n } else {\n selectedDate = parseISO(root.dataset.value);\n }\n }\n\n const initialView = selectedDate || rangeStart || today;\n let viewMonth = initialView.getMonth();\n let viewYear = initialView.getFullYear();\n let focusedDate = null;\n\n function parseDateList(str) {\n const set = new Set();\n if (str) {\n for (const token of str.split(/[\\s,]+/)) {\n if (parseISO(token)) set.add(token);\n }\n }\n return set;\n }\n\n function formatDate(date) {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n }\n\n function formatAriaLabel(date) {\n return `${DAY_NAMES[date.getDay()]}, ${MONTH_NAMES[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n }\n\n function isSameDay(a, b) {\n if (!a || !b) return false;\n return (\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n }\n\n function isToday(date) {\n return isSameDay(date, today);\n }\n\n function isDisabled(date) {\n if (minDate && date.getTime() < minDate.getTime()) return true;\n if (maxDate && date.getTime() > maxDate.getTime()) return true;\n return disabledDates.has(formatDate(date));\n }\n\n function clampToRange(date) {\n if (minDate && date.getTime() < minDate.getTime()) return new Date(minDate);\n if (maxDate && date.getTime() > maxDate.getTime()) return new Date(maxDate);\n return date;\n }\n\n function buildGrid() {\n // First day of the displayed month\n const firstDay = new Date(viewYear, viewMonth, 1);\n const startDow = firstDay.getDay(); // 0=Sun\n\n // Last day of the displayed month\n const lastDay = new Date(viewYear, viewMonth + 1, 0);\n const totalDays = lastDay.getDate();\n\n // Previous month trailing days\n const prevMonthLast = new Date(viewYear, viewMonth, 0);\n const prevMonthDays = prevMonthLast.getDate();\n\n // Update label\n if (monthLabel) monthLabel.textContent = `${MONTH_NAMES[viewMonth]} ${viewYear}`;\n\n // A whole adjacent month out of bounds means its nav button is a dead end\n if (navPrev) navPrev.disabled = !!(minDate && prevMonthLast.getTime() < minDate.getTime());\n if (navNext) navNext.disabled = !!(maxDate && new Date(viewYear, viewMonth + 1, 1).getTime() > maxDate.getTime());\n\n // Clear existing\n gridBody.innerHTML = \"\";\n\n let dayCount = 1;\n let nextMonthDay = 1;\n const totalCells = Math.ceil((startDow + totalDays) / 7) * 7;\n let row = null;\n\n for (let i = 0; i < totalCells; i++) {\n // Start a new row every 7 cells\n if (i % 7 === 0) {\n row = document.createElement(\"tr\");\n gridBody.appendChild(row);\n }\n\n const td = document.createElement(\"td\");\n const btn = document.createElement(\"button\");\n btn.setAttribute(\"data-part\", \"day\");\n btn.type = \"button\";\n\n let date;\n let isOutside = false;\n\n if (i < startDow) {\n // Previous month\n const day = prevMonthDays - startDow + 1 + i;\n date = new Date(viewYear, viewMonth - 1, day);\n btn.textContent = day;\n isOutside = true;\n } else if (dayCount <= totalDays) {\n // Current month\n date = new Date(viewYear, viewMonth, dayCount);\n btn.textContent = dayCount;\n dayCount++;\n } else {\n // Next month\n date = new Date(viewYear, viewMonth + 1, nextMonthDay);\n btn.textContent = nextMonthDay;\n nextMonthDay++;\n isOutside = true;\n }\n\n btn.dataset.date = formatDate(date);\n btn.setAttribute(\"aria-label\", formatAriaLabel(date));\n\n if (isOutside) {\n btn.dataset.outside = \"true\";\n }\n\n if (isToday(date)) {\n btn.dataset.today = \"true\";\n }\n\n if (isDisabled(date)) {\n // aria-disabled (not the native attribute) keeps the cell reachable by\n // the roving tabindex while blocking selection\n btn.setAttribute(\"aria-disabled\", \"true\");\n btn.dataset.disabled = \"true\";\n }\n\n if (mode === \"range\") {\n if (isSameDay(date, rangeStart)) {\n btn.dataset.state = \"range-start\";\n btn.setAttribute(\"aria-selected\", \"true\");\n } else if (isSameDay(date, rangeEnd)) {\n btn.dataset.state = \"range-end\";\n btn.setAttribute(\"aria-selected\", \"true\");\n } else if (\n rangeStart && rangeEnd &&\n date.getTime() > rangeStart.getTime() &&\n date.getTime() < rangeEnd.getTime()\n ) {\n btn.dataset.state = \"in-range\";\n }\n } else if (isSameDay(date, selectedDate)) {\n btn.setAttribute(\"aria-selected\", \"true\");\n }\n\n if (isSameDay(date, focusedDate)) {\n btn.tabIndex = 0;\n } else {\n btn.tabIndex = -1;\n }\n\n td.appendChild(btn);\n row.appendChild(td);\n }\n\n // If no focused date set, make the selected or first-of-month focusable\n if (!focusedDate) {\n const anchor = mode === \"range\" ? rangeStart : selectedDate;\n const defaultFocusDate = anchor &&\n anchor.getMonth() === viewMonth && anchor.getFullYear() === viewYear\n ? anchor\n : new Date(viewYear, viewMonth, 1);\n const defaultBtn = gridBody.querySelector(\n `[data-date=\"${formatDate(defaultFocusDate)}\"]`\n );\n if (defaultBtn) defaultBtn.tabIndex = 0;\n }\n }\n\n function dayButton(date) {\n return gridBody.querySelector(`[data-date=\"${formatDate(date)}\"]`);\n }\n\n function focusDate(date) {\n const target = clampToRange(new Date(date));\n focusedDate = target;\n\n if (target.getMonth() !== viewMonth || target.getFullYear() !== viewYear) {\n viewMonth = target.getMonth();\n viewYear = target.getFullYear();\n buildGrid();\n } else {\n // Update roving tabindex in the current grid\n gridBody.querySelectorAll(\"[data-part='day']\").forEach((btn) => {\n btn.tabIndex = -1;\n });\n const btn = dayButton(target);\n if (btn) btn.tabIndex = 0;\n }\n\n const btn = dayButton(target);\n if (btn) btn.focus();\n }\n\n function moveFocus(days) {\n if (!focusedDate) return;\n const next = new Date(focusedDate);\n next.setDate(next.getDate() + days);\n focusDate(next);\n }\n\n /** Move focus ±N months (PageUp/Down), clamping the day to the target month's length. */\n function moveFocusMonths(months) {\n if (!focusedDate) return;\n const target = new Date(focusedDate.getFullYear(), focusedDate.getMonth() + months, 1);\n const daysInTarget = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();\n target.setDate(Math.min(focusedDate.getDate(), daysInTarget));\n focusDate(target);\n }\n\n function selectDate(date) {\n const chosen = new Date(date);\n if (isDisabled(chosen)) return;\n\n // buildGrid() replaces the focused button — restore focus before emitting,\n // so change listeners (e.g. date-picker closing the popup) keep the final\n // word on where focus lands.\n const hadFocus = root.contains(document.activeElement);\n focusedDate = chosen;\n\n let detail = null;\n\n if (mode === \"range\") {\n if (!rangeStart || rangeEnd || chosen.getTime() < rangeStart.getTime()) {\n // First click, restart after a complete range, or backwards pick\n rangeStart = chosen;\n rangeEnd = null;\n } else {\n rangeEnd = chosen;\n detail = {\n start: formatDate(rangeStart),\n end: formatDate(rangeEnd),\n startObj: new Date(rangeStart),\n endObj: new Date(rangeEnd),\n };\n }\n } else {\n selectedDate = chosen;\n detail = { date: formatDate(selectedDate), dateObj: new Date(selectedDate) };\n }\n\n buildGrid();\n\n if (hadFocus) {\n const btn = dayButton(chosen);\n if (btn) btn.focus();\n }\n\n if (detail) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:calendar-change\", { detail, bubbles: true })\n );\n }\n }\n\n function getValue() {\n if (mode === \"range\") {\n return {\n start: rangeStart ? formatDate(rangeStart) : null,\n end: rangeEnd ? formatDate(rangeEnd) : null,\n };\n }\n return selectedDate ? formatDate(selectedDate) : null;\n }\n\n /** Silent set — updates selection and view without emitting a change event. */\n function setValue(value) {\n if (mode === \"range\") {\n const parts = String(value).split(\",\");\n const start = parseISO(parts[0] && parts[0].trim());\n const end = parseISO(parts[1] && parts[1].trim());\n if (!start) return;\n rangeStart = start;\n rangeEnd = end && end.getTime() >= start.getTime() ? end : null;\n viewMonth = start.getMonth();\n viewYear = start.getFullYear();\n buildGrid();\n return;\n }\n\n const parsed = parseISO(value);\n if (!parsed) return;\n selectedDate = parsed;\n viewMonth = parsed.getMonth();\n viewYear = parsed.getFullYear();\n buildGrid();\n }\n\n function clear() {\n selectedDate = null;\n rangeStart = null;\n rangeEnd = null;\n buildGrid();\n }\n\n function navigate(month, year) {\n viewMonth = month;\n viewYear = year;\n focusedDate = new Date(viewYear, viewMonth, 1);\n buildGrid();\n\n const btn = dayButton(focusedDate);\n if (btn) btn.focus();\n }\n\n function setMin(value) {\n minDate = parseISO(value);\n buildGrid();\n }\n\n function setMax(value) {\n maxDate = parseISO(value);\n buildGrid();\n }\n\n function setDisabledDates(list) {\n disabledDates = parseDateList(Array.isArray(list) ? list.join(\",\") : list);\n buildGrid();\n }\n\n /** Show an adjacent month without moving DOM focus (nav-button clicks). */\n function shiftView(delta) {\n viewMonth += delta;\n if (viewMonth < 0) {\n viewMonth = 11;\n viewYear--;\n } else if (viewMonth > 11) {\n viewMonth = 0;\n viewYear++;\n }\n focusedDate = clampToRange(new Date(viewYear, viewMonth, 1));\n buildGrid();\n }\n\n function onPrevClick() {\n shiftView(-1);\n }\n\n function onNextClick() {\n shiftView(1);\n }\n\n function onGridClick(e) {\n const dayBtn = e.target.closest(\"[data-part='day']\");\n if (dayBtn && dayBtn.dataset.date && dayBtn.getAttribute(\"aria-disabled\") !== \"true\") {\n selectDate(parseISO(dayBtn.dataset.date));\n }\n }\n\n function onKeyDown(e) {\n // Grid navigation only applies while a day cell has focus\n const dayBtn = e.target.closest ? e.target.closest(\"[data-part='day']\") : null;\n if (!dayBtn) return;\n\n if (dayBtn.dataset.date && !isSameDay(focusedDate, parseISO(dayBtn.dataset.date))) {\n focusedDate = parseISO(dayBtn.dataset.date);\n }\n\n switch (e.key) {\n case \"ArrowLeft\":\n e.preventDefault();\n moveFocus(-1);\n break;\n case \"ArrowRight\":\n e.preventDefault();\n moveFocus(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n moveFocus(-7);\n break;\n case \"ArrowDown\":\n e.preventDefault();\n moveFocus(7);\n break;\n case \"Home\":\n e.preventDefault();\n if (focusedDate) moveFocus(-focusedDate.getDay());\n break;\n case \"End\":\n e.preventDefault();\n if (focusedDate) moveFocus(6 - focusedDate.getDay());\n break;\n case \"PageUp\":\n e.preventDefault();\n if (e.shiftKey) {\n moveFocusMonths(-12);\n } else {\n moveFocusMonths(-1);\n }\n break;\n case \"PageDown\":\n e.preventDefault();\n if (e.shiftKey) {\n moveFocusMonths(12);\n } else {\n moveFocusMonths(1);\n }\n break;\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (focusedDate) selectDate(focusedDate);\n break;\n }\n }\n\n navPrev?.addEventListener(\"click\", onPrevClick);\n navNext?.addEventListener(\"click\", onNextClick);\n gridBody?.addEventListener(\"click\", onGridClick);\n root.addEventListener(\"keydown\", onKeyDown);\n\n buildGrid();\n\n function destroy() {\n navPrev?.removeEventListener(\"click\", onPrevClick);\n navNext?.removeEventListener(\"click\", onNextClick);\n gridBody?.removeEventListener(\"click\", onGridClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirCalendar;\n }\n\n const api = {\n getValue,\n setValue,\n clear,\n navigate,\n selectDate,\n focusDate,\n setMin,\n setMax,\n setDisabledDates,\n destroy,\n };\n root._faqirCalendar = api;\n return api;\n}\n return createCalendar;\n })();\n\n // ── carousel ── (registry/recipes/carousel/carousel.js)\n var createCarousel = controllerRegistry[\"carousel\"] = (function() {\n// @ui:controller carousel\n// @ui:provides next prev goTo getIndex getCount destroy\n\n/**\n * carousel — a CSS scroll-snap strip with a deliberately tiny enhancement layer.\n *\n * CSS owns the sliding: `[data-part=\"viewport\"]` scrolls on the inline axis with\n * `scroll-snap-type: inline mandatory`, and each `[data-part=\"slide\"]` is a snap\n * target. That means the component is fully usable with this file absent —\n * swipe, wheel and (the viewport is `tabindex=\"0\"`) the arrow keys all work.\n *\n * So the controller owns ONLY what CSS cannot:\n *\n * • prev/next buttons and dots — inert markup that ships `hidden` and is\n * un-hidden here, so a reader without JS never sees a dead control;\n * • current-slide tracking by scroll math (no IntersectionObserver: one\n * rAF-throttled `getBoundingClientRect` pass answers \"which snap point are\n * we on?\" exactly, and works identically for programmatic and user scrolls);\n * • the boundary contract — \"stop\" by default (the end button is `disabled`),\n * \"loop\" when the root carries `data-loop`;\n * • the `[data-part=\"status\"]` live region (\"Slide 2 of 3\");\n * • reduced motion — an explicit `behavior: \"instant\"` (which beats the CSS\n * `scroll-behavior: smooth`) rather than an animated scroll.\n *\n * Scrolling always goes through the PHYSICAL delta `slide.left - viewport.left`\n * added to `scrollLeft`, which is correct in both LTR and RTL (where `scrollLeft`\n * runs negative). Only the \"which slide is current?\" comparison is\n * direction-aware, since the snap edge is `inline-start`.\n */\nfunction createCarousel(root) {\n // Prevent double-init.\n if (root._faqirCarousel) return root._faqirCarousel;\n\n const viewport = root.querySelector(\"[data-part='viewport']\");\n if (!viewport) return null;\n\n const loop = root.hasAttribute(\"data-loop\");\n const slides = () => [...viewport.querySelectorAll(\"[data-part='slide']\")];\n const dots = () => [...root.querySelectorAll(\"[data-part='dot']\")];\n const prevBtn = root.querySelector(\"[data-part='prev']\");\n const nextBtn = root.querySelector(\"[data-part='next']\");\n const status = root.querySelector(\"[data-part='status']\");\n const enhanced = [...root.querySelectorAll(\"[data-part='controls'], [data-part='dots']\")];\n\n let index = 0;\n\n // ── environment probes (read live, so preference changes are honored) ───────\n const reducedMotion = () =>\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n !!window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n const isRtl = () => {\n const cs = typeof getComputedStyle === \"function\" ? getComputedStyle(root) : null;\n return (cs && cs.direction) === \"rtl\";\n };\n\n const rectOf = (el) =>\n el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, right: 0 };\n\n /**\n * Per-slide geometry, measured against the viewport:\n * `delta` — physical px to add to `scrollLeft` to bring the slide into view.\n * `edge` — signed distance on the snap (inline-start) edge; the slide whose\n * |edge| is smallest is the current one.\n */\n function metrics() {\n const v = rectOf(viewport);\n const rtl = isRtl();\n return slides().map((s) => {\n const r = rectOf(s);\n return { delta: r.left - v.left, edge: rtl ? r.right - v.right : r.left - v.left };\n });\n }\n\n function nearestIndex() {\n let best = 0;\n let bestDistance = Infinity;\n metrics().forEach((m, i) => {\n const d = Math.abs(m.edge);\n if (d < bestDistance) {\n bestDistance = d;\n best = i;\n }\n });\n return best;\n }\n\n /** Apply the boundary contract: wrap when `data-loop`, otherwise clamp. */\n function resolve(i, count) {\n if (!count) return 0;\n return loop ? ((i % count) + count) % count : Math.min(Math.max(i, 0), count - 1);\n }\n\n // ── reflection ──────────────────────────────────────────────────────────────\n function sync() {\n const count = slides().length;\n dots().forEach((d, i) => {\n const on = i === index;\n d.dataset.state = on ? \"active\" : \"inactive\";\n if (on) d.setAttribute(\"aria-current\", \"true\");\n else d.removeAttribute(\"aria-current\");\n });\n if (prevBtn) prevBtn.disabled = !loop && index <= 0;\n if (nextBtn) nextBtn.disabled = !loop && index >= count - 1;\n if (status) status.textContent = count ? `Slide ${index + 1} of ${count}` : \"\";\n }\n\n function setIndex(i) {\n if (i === index) return;\n index = i;\n sync();\n root.dispatchEvent(\n new CustomEvent(\"faqir:change\", {\n bubbles: true,\n detail: { index, count: slides().length },\n }),\n );\n }\n\n // ── navigation ──────────────────────────────────────────────────────────────\n function goTo(i) {\n const list = slides();\n if (!list.length) return;\n const target = resolve(i, list.length);\n const m = metrics()[target];\n const left = (viewport.scrollLeft || 0) + (m ? m.delta : 0);\n const behavior = reducedMotion() ? \"instant\" : \"smooth\";\n if (typeof viewport.scrollTo === \"function\") viewport.scrollTo({ left, behavior });\n else viewport.scrollLeft = left;\n setIndex(target);\n }\n\n const next = () => goTo(index + 1);\n const prev = () => goTo(index - 1);\n\n // ── events ──────────────────────────────────────────────────────────────────\n function onClick(e) {\n const btn = e.target.closest && e.target.closest(\"[data-part]\");\n if (!btn || !root.contains(btn)) return;\n const part = btn.dataset.part;\n if (part === \"next\") next();\n else if (part === \"prev\") prev();\n else if (part === \"dot\") goTo(dots().indexOf(btn));\n }\n\n // One rAF-throttled measurement per scroll burst keeps tracking cheap.\n const schedule =\n typeof requestAnimationFrame === \"function\"\n ? requestAnimationFrame\n : (fn) => setTimeout(fn, 16);\n let ticking = false;\n function onScroll() {\n if (ticking) return;\n ticking = true;\n schedule(() => {\n ticking = false;\n setIndex(nearestIndex());\n });\n }\n\n // Enhance: the JS-only controls become visible now that JS is here.\n enhanced.forEach((el) => {\n el.hidden = false;\n });\n\n root.addEventListener(\"click\", onClick);\n viewport.addEventListener(\"scroll\", onScroll);\n sync();\n\n function destroy() {\n root.removeEventListener(\"click\", onClick);\n viewport.removeEventListener(\"scroll\", onScroll);\n // Back to the no-JS baseline: the inert controls hide again.\n enhanced.forEach((el) => {\n el.hidden = true;\n });\n delete root._faqirCarousel;\n }\n\n const api = { goTo, next, prev, getIndex: () => index, getCount: () => slides().length, destroy };\n root._faqirCarousel = api;\n return api;\n}\n return createCarousel;\n })();\n\n // ── combobox ── (registry/recipes/combobox/combobox.js)\n var createCombobox = controllerRegistry[\"combobox\"] = (function() {\n// @ui:controller combobox\n// @ui:provides open close filter selectOption getValue setValue destroy\n\nfunction createCombobox(root) {\n // Prevent double-init\n if (root._faqirCombobox) return root._faqirCombobox;\n\n const input = root.querySelector(\"[data-part='input']\");\n const listbox = root.querySelector(\"[data-part='listbox']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const options = () =>\n [...root.querySelectorAll(\"[data-part='option']\")];\n\n let highlightedIndex = -1;\n let outsideClickCleanup = null;\n let selectedValue = \"\";\n\n /**\n * `aria-activedescendant` — the half of the combobox pattern that was declared\n * and never implemented. [W3-4]\n *\n * The markup publishes `role=\"combobox\"` and `aria-autocomplete=\"list\"`, which\n * is the APG contract: as the user arrows through the list, the combobox must\n * name the active option so a screen reader announces it. Highlighting was\n * tracked in `data-highlighted` alone and the options carried no `id`, so\n * there was nothing to point at and nothing was ever announced — the widget\n * claimed a pattern it did not implement. The axe gate structurally cannot see\n * this: it evaluates static DOM, and the defect exists only mid-navigation.\n *\n * Ids are minted on demand so authored ids are respected and generated markup\n * needs none.\n */\n function optionId(opt) {\n if (!opt.id) opt.id = uid(\"faqir-option\");\n return opt.id;\n }\n\n function setActiveDescendant(opt) {\n if (opt) input.setAttribute(\"aria-activedescendant\", optionId(opt));\n else input.removeAttribute(\"aria-activedescendant\");\n }\n\n function open() {\n root.dataset.state = \"open\";\n listbox.hidden = false;\n input.setAttribute(\"aria-expanded\", \"true\");\n\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n function close() {\n root.dataset.state = \"closed\";\n listbox.hidden = true;\n input.setAttribute(\"aria-expanded\", \"false\");\n clearHighlight();\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function clearHighlight() {\n const allOptions = options();\n allOptions.forEach((opt) => {\n opt.removeAttribute(\"data-highlighted\");\n opt.setAttribute(\"aria-selected\", \"false\");\n });\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function highlightOption(index) {\n const allOptions = visibleOptions();\n if (allOptions.length === 0) return;\n\n // Clamp index\n if (index < 0) index = allOptions.length - 1;\n if (index >= allOptions.length) index = 0;\n\n // Clear previous\n options().forEach((opt) => {\n opt.removeAttribute(\"data-highlighted\");\n opt.setAttribute(\"aria-selected\", \"false\");\n });\n\n allOptions[index].setAttribute(\"data-highlighted\", \"\");\n allOptions[index].setAttribute(\"aria-selected\", \"true\");\n allOptions[index].scrollIntoView({ block: \"nearest\" });\n setActiveDescendant(allOptions[index]);\n highlightedIndex = index;\n }\n\n function visibleOptions() {\n return options().filter((opt) => !opt.hasAttribute(\"data-hidden\"));\n }\n\n function filter(query) {\n const allOptions = options();\n const lowerQuery = query.toLowerCase();\n let visibleCount = 0;\n\n allOptions.forEach((opt) => {\n const text = opt.textContent.toLowerCase();\n if (text.includes(lowerQuery)) {\n opt.removeAttribute(\"data-hidden\");\n visibleCount++;\n } else {\n opt.setAttribute(\"data-hidden\", \"\");\n }\n });\n\n // Show/hide empty state\n if (emptyEl) {\n emptyEl.hidden = visibleCount > 0;\n }\n\n clearHighlight();\n\n return visibleCount;\n }\n\n function selectOption(index) {\n const visible = visibleOptions();\n if (index < 0 || index >= visible.length) return;\n\n const opt = visible[index];\n selectedValue = opt.textContent.trim();\n input.value = selectedValue;\n\n // Mark as selected\n options().forEach((o) => o.setAttribute(\"aria-selected\", \"false\"));\n opt.setAttribute(\"aria-selected\", \"true\");\n\n close();\n }\n\n function getValue() {\n return selectedValue;\n }\n\n function setValue(val) {\n selectedValue = val;\n input.value = val;\n }\n\n // ── Event Handlers ──\n\n function onInput() {\n const query = input.value;\n if (root.dataset.state !== \"open\") {\n open();\n }\n filter(query);\n }\n\n function onInputFocus() {\n if (root.dataset.state !== \"open\") {\n open();\n }\n }\n\n function onInputKeyDown(e) {\n const visible = visibleOptions();\n\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (root.dataset.state !== \"open\") open();\n highlightOption(highlightedIndex + 1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (root.dataset.state !== \"open\") open();\n highlightOption(highlightedIndex - 1);\n break;\n case \"Enter\":\n e.preventDefault();\n if (highlightedIndex >= 0 && highlightedIndex < visible.length) {\n selectOption(highlightedIndex);\n }\n break;\n case \"Escape\":\n // Only ours while the list is open; a closed combobox lets Escape reach\n // the dialog it sits in rather than swallowing it. [W3-2]\n if (root.dataset.state === \"open\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n }\n break;\n case \"Home\":\n if (root.dataset.state === \"open\" && visible.length > 0) {\n e.preventDefault();\n highlightOption(0);\n }\n break;\n case \"End\":\n if (root.dataset.state === \"open\" && visible.length > 0) {\n e.preventDefault();\n highlightOption(visible.length - 1);\n }\n break;\n }\n }\n\n function onListboxClick(e) {\n const opt = e.target.closest(\"[data-part='option']\");\n if (!opt) return;\n\n const visible = visibleOptions();\n const index = visible.indexOf(opt);\n if (index >= 0) {\n selectOption(index);\n }\n }\n\n input?.addEventListener(\"input\", onInput);\n input?.addEventListener(\"focus\", onInputFocus);\n input?.addEventListener(\"keydown\", onInputKeyDown);\n listbox?.addEventListener(\"click\", onListboxClick);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close();\n input?.removeEventListener(\"input\", onInput);\n input?.removeEventListener(\"focus\", onInputFocus);\n input?.removeEventListener(\"keydown\", onInputKeyDown);\n listbox?.removeEventListener(\"click\", onListboxClick);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirCombobox;\n }\n\n const api = { open, close, filter, selectOption, getValue, setValue, destroy };\n root._faqirCombobox = api;\n return api;\n}\n return createCombobox;\n })();\n\n // ── command-palette ── (registry/recipes/command-palette/command-palette.js)\n var createCommandPalette = controllerRegistry[\"command-palette\"] = (function() {\n// @ui:controller command-palette\n// @ui:provides open close filter selectItem registerCommand destroy\n\nfunction createCommandPalette(root) {\n // Prevent double-init\n if (root._faqirCommandPalette) return root._faqirCommandPalette;\n\n const overlay = root.querySelector(\"[data-part='overlay']\");\n const panel = root.querySelector(\"[data-part='panel']\");\n const searchInput = root.querySelector(\"[data-part='search']\");\n const list = root.querySelector(\"[data-part='list']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const items = () =>\n [...root.querySelectorAll(\"[data-part='item']\")];\n const groups = () =>\n [...root.querySelectorAll(\"[data-part='group']\")];\n\n let highlightedIndex = -1;\n let focusCleanup = null;\n let previouslyFocused = null;\n const registeredCommands = [];\n\n function open() {\n previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n\n // Reset search and highlights\n searchInput.value = \"\";\n filter(\"\");\n clearHighlight();\n\n focusCleanup = trapFocus(panel);\n searchInput.focus();\n }\n\n /**\n * Everything `close()` does EXCEPT moving focus.\n *\n * `destroy()` used to leave an open overlay standing with nothing listening —\n * a dead widget the user cannot dismiss. Closing it on teardown is the fix\n * (`context-menu` is the model), but teardown must not also yank focus\n * somewhere: on an SPA route change the element it would restore to is\n * usually on its way out of the document. [W3-2]\n */\n function dismiss() {\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n // A closed palette must not still name an active item: `aria-activedescendant`\n // pointing into a hidden list is a reference a reader can follow to nothing. [W3-4]\n clearHighlight();\n\n if (focusCleanup) {\n focusCleanup();\n focusCleanup = null;\n }\n }\n\n function close() {\n dismiss();\n previouslyFocused?.focus();\n }\n\n /**\n * `aria-activedescendant` — the declared half of the combobox pattern. [W3-4]\n *\n * The search field publishes `role=\"combobox\"` and `aria-autocomplete=\"list\"`,\n * which obliges it to name the active item as the user arrows through the\n * results. Highlighting lived in `data-highlighted` alone and the items had no\n * `id`, so a screen-reader user heard nothing move. The axe gate cannot see\n * this — it reads static DOM, and the defect exists only mid-navigation.\n */\n function itemId(item) {\n if (!item.id) item.id = uid(\"faqir-command\");\n return item.id;\n }\n\n function setActiveDescendant(item) {\n if (!searchInput) return;\n if (item) searchInput.setAttribute(\"aria-activedescendant\", itemId(item));\n else searchInput.removeAttribute(\"aria-activedescendant\");\n }\n\n function clearHighlight() {\n items().forEach((item) => {\n item.removeAttribute(\"data-highlighted\");\n item.setAttribute(\"aria-selected\", \"false\");\n });\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function visibleItems() {\n return items().filter((item) => !item.hasAttribute(\"data-hidden\"));\n }\n\n function highlightItem(index) {\n const visible = visibleItems();\n if (visible.length === 0) return;\n\n // Clamp index\n if (index < 0) index = visible.length - 1;\n if (index >= visible.length) index = 0;\n\n // Clear previous\n items().forEach((item) => {\n item.removeAttribute(\"data-highlighted\");\n item.setAttribute(\"aria-selected\", \"false\");\n });\n\n visible[index].setAttribute(\"data-highlighted\", \"\");\n visible[index].setAttribute(\"aria-selected\", \"true\");\n visible[index].scrollIntoView({ block: \"nearest\" });\n setActiveDescendant(visible[index]);\n highlightedIndex = index;\n }\n\n function filter(query) {\n const allItems = items();\n const allGroups = groups();\n const lowerQuery = query.toLowerCase();\n let totalVisible = 0;\n\n // Track visible items per group\n const groupVisibility = new Map();\n allGroups.forEach((g) => groupVisibility.set(g, 0));\n\n allItems.forEach((item) => {\n const label = item.querySelector(\"[data-part='item-label']\");\n const text = (label || item).textContent.toLowerCase();\n\n if (text.includes(lowerQuery)) {\n item.removeAttribute(\"data-hidden\");\n totalVisible++;\n // Find parent group\n const parentGroup = item.closest(\"[data-part='group']\");\n if (parentGroup && groupVisibility.has(parentGroup)) {\n groupVisibility.set(parentGroup, groupVisibility.get(parentGroup) + 1);\n }\n } else {\n item.setAttribute(\"data-hidden\", \"\");\n }\n });\n\n // Hide groups with no visible items\n allGroups.forEach((group) => {\n if (groupVisibility.get(group) === 0) {\n group.setAttribute(\"data-hidden\", \"\");\n } else {\n group.removeAttribute(\"data-hidden\");\n }\n });\n\n // Show/hide empty state\n if (emptyEl) {\n emptyEl.hidden = totalVisible > 0;\n }\n\n clearHighlight();\n\n return totalVisible;\n }\n\n function selectItem(index) {\n const visible = visibleItems();\n if (index < 0 || index >= visible.length) return;\n\n const item = visible[index];\n\n // Fire a custom event for the application to handle\n const event = new CustomEvent(\"command-select\", {\n bubbles: true,\n detail: {\n item,\n label: item.querySelector(\"[data-part='item-label']\")?.textContent || item.textContent\n }\n });\n root.dispatchEvent(event);\n\n // Check registered commands\n const label = (item.querySelector(\"[data-part='item-label']\") || item).textContent.trim();\n const cmd = registeredCommands.find((c) => c.label === label);\n if (cmd?.action) cmd.action();\n\n close();\n }\n\n function registerCommand(cmd) {\n registeredCommands.push(cmd);\n }\n\n // ── Event Handlers ──\n\n function onSearchInput() {\n filter(searchInput.value);\n }\n\n function onSearchKeyDown(e) {\n const visible = visibleItems();\n\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n highlightItem(highlightedIndex + 1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n highlightItem(highlightedIndex - 1);\n break;\n case \"Enter\":\n e.preventDefault();\n if (highlightedIndex >= 0 && highlightedIndex < visible.length) {\n selectItem(highlightedIndex);\n }\n break;\n case \"Escape\":\n // The palette is an overlay in its own right: dismissing it must not\n // also dismiss whatever it was opened over. [W3-2]\n if (root.dataset.state === \"open\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n }\n break;\n case \"Home\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightItem(0);\n }\n break;\n case \"End\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightItem(visible.length - 1);\n }\n break;\n }\n }\n\n function onOverlayClick() {\n close();\n }\n\n function onItemClick(e) {\n const item = e.target.closest(\"[data-part='item']\");\n if (!item) return;\n\n const visible = visibleItems();\n const index = visible.indexOf(item);\n if (index >= 0) {\n selectItem(index);\n }\n }\n\n function onGlobalKeyDown(e) {\n if ((e.metaKey || e.ctrlKey) && e.key === \"k\") {\n e.preventDefault();\n if (root.dataset.state === \"open\") {\n close();\n } else {\n open();\n }\n }\n }\n\n searchInput?.addEventListener(\"input\", onSearchInput);\n searchInput?.addEventListener(\"keydown\", onSearchKeyDown);\n overlay?.addEventListener(\"click\", onOverlayClick);\n list?.addEventListener(\"click\", onItemClick);\n document.addEventListener(\"keydown\", onGlobalKeyDown);\n\n function destroy() {\n dismiss();\n searchInput?.removeEventListener(\"input\", onSearchInput);\n searchInput?.removeEventListener(\"keydown\", onSearchKeyDown);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n list?.removeEventListener(\"click\", onItemClick);\n document.removeEventListener(\"keydown\", onGlobalKeyDown);\n if (focusCleanup) focusCleanup();\n delete root._faqirCommandPalette;\n }\n\n const api = { open, close, filter, selectItem, registerCommand, destroy };\n root._faqirCommandPalette = api;\n return api;\n}\n return createCommandPalette;\n })();\n\n // ── context-menu ── (registry/recipes/context-menu/context-menu.js)\n var createContextMenu = controllerRegistry[\"context-menu\"] = (function() {\n// @ui:controller context-menu\n// @ui:provides open close destroy\n\nfunction createContextMenu(root) {\n if (root._faqirContextMenu) return root._faqirContextMenu;\n\n const target = root.querySelector(\"[data-part='target']\");\n const menu = root.querySelector(\"[data-part='menu']\");\n\n // Same as `dropdown`: a missing part must name itself rather than throwing a\n // TypeError out of `createMenuNavigation(null)`. [W3-2]\n if (!target || !menu) {\n console.warn(\n \"[Faqir] context-menu needs [data-part='target'] and [data-part='menu'] — \" +\n `missing ${[!target && \"target\", !menu && \"menu\"].filter(Boolean).join(\" and \")}. ` +\n \"Component left inert.\",\n root\n );\n const inert = { open() {}, close() {}, destroy() {} };\n root._faqirContextMenu = inert;\n return inert;\n }\n\n let outsideClickCleanup = null;\n\n function clearOutsideClick() {\n if (!outsideClickCleanup) return;\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n\n function close(options = {}) {\n const { restoreFocus = true } = options;\n\n root.dataset.state = \"closed\";\n menu.hidden = true;\n target.setAttribute(\"aria-expanded\", \"false\");\n clearOutsideClick();\n\n if (restoreFocus && target.isConnected) target.focus();\n }\n\n const navigation = createMenuNavigation(menu, {\n onEscape() {\n close({ restoreFocus: true });\n },\n onTab() {\n close({ restoreFocus: false });\n },\n });\n\n function open(x = 0, y = 0) {\n clearOutsideClick();\n\n menu.style.left = `${x}px`;\n menu.style.top = `${y}px`;\n menu.hidden = false;\n root.dataset.state = \"open\";\n target.setAttribute(\"aria-expanded\", \"true\");\n\n navigation.focusFirst();\n\n outsideClickCleanup = onOutsideClick(menu, () => {\n close({ restoreFocus: false });\n });\n }\n\n function onContextMenu(event) {\n event.preventDefault();\n open(event.clientX, event.clientY);\n }\n\n function onTargetKeyDown(event) {\n const isContextMenuKey = event.key === \"ContextMenu\";\n const isShiftF10 = event.key === \"F10\" && event.shiftKey;\n if (!isContextMenuKey && !isShiftF10) return;\n\n event.preventDefault();\n const rect = target.getBoundingClientRect();\n open(rect.left, rect.bottom);\n }\n\n function onMenuClick(event) {\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !menu.contains(item)) return;\n\n if (item.disabled || item.getAttribute(\"aria-disabled\") === \"true\") {\n event.preventDefault();\n return;\n }\n\n close({ restoreFocus: true });\n }\n\n target?.addEventListener(\"contextmenu\", onContextMenu);\n target?.addEventListener(\"keydown\", onTargetKeyDown);\n menu?.addEventListener(\"click\", onMenuClick);\n\n function destroy() {\n target?.removeEventListener(\"contextmenu\", onContextMenu);\n target?.removeEventListener(\"keydown\", onTargetKeyDown);\n menu?.removeEventListener(\"click\", onMenuClick);\n navigation.destroy();\n clearOutsideClick();\n\n root.dataset.state = \"closed\";\n menu.hidden = true;\n target.setAttribute(\"aria-expanded\", \"false\");\n delete root._faqirContextMenu;\n }\n\n const api = { open, close, destroy };\n root._faqirContextMenu = api;\n return api;\n}\n return createContextMenu;\n })();\n\n // ── date-picker ── (registry/recipes/date-picker/date-picker.js)\n var createDatePicker = controllerRegistry[\"date-picker\"] = (function() {\n// @ui:controller date-picker\n// @ui:provides open close getValue setValue navigate selectDate destroy\n\nconst MONTH_NAMES = [\n \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\",\n];\n\nfunction createDatePicker(root) {\n // Prevent double-init\n if (root._faqirDatePicker) return root._faqirDatePicker;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const input = root.querySelector(\"[data-part='input']\");\n const popup = root.querySelector(\"[data-part='calendar']\");\n\n // The month grid is the standalone `calendar` recipe. Canonical markup nests\n // [data-ui=\"calendar\"] inside the popup; legacy flat markup (grid parts\n // directly inside the popup) still works — the popup itself then acts as the\n // calendar root.\n const calendarRoot = root.querySelector(\"[data-ui='calendar']\") || popup;\n\n // `input` carries the value and the aria-expanded state, `popup` is what\n // opens; either one missing made every open()/close() throw. `trigger` is\n // optional — an input-only date picker opens from the field. [W3-2]\n if (!input || !popup) {\n console.warn(\n \"[Faqir] date-picker needs [data-part='input'] and [data-part='calendar'] — \" +\n `missing ${[!input && \"input\", !popup && \"calendar\"].filter(Boolean).join(\" and \")}. ` +\n \"Component left inert.\",\n root\n );\n const inert = {\n open() {},\n close() {},\n getValue: () => null,\n setValue() {},\n navigate() {},\n selectDate() {},\n destroy() {},\n };\n root._faqirDatePicker = inert;\n return inert;\n }\n const calendar = createCalendar(calendarRoot);\n\n const today = new Date();\n let outsideClickCleanup = null;\n\n function formatDisplay(date) {\n return `${MONTH_NAMES[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n }\n\n function syncInput(dateStr, dateObj) {\n input.value = formatDisplay(dateObj);\n input.dataset.value = dateStr;\n }\n\n function open() {\n root.dataset.state = \"open\";\n popup.hidden = false;\n input.setAttribute(\"aria-expanded\", \"true\");\n\n // Focus the selected day, or the first of the current month\n const value = calendar.getValue();\n const target = value\n ? new Date(value + \"T00:00:00\")\n : new Date(today.getFullYear(), today.getMonth(), 1);\n calendar.focusDate(target);\n\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n function close() {\n root.dataset.state = \"closed\";\n popup.hidden = true;\n input.setAttribute(\"aria-expanded\", \"false\");\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function selectDate(date) {\n // Delegates to the calendar; input update, close and the faqir:date-change\n // re-emit all happen in onCalendarChange.\n calendar.selectDate(date);\n }\n\n function getValue() {\n return calendar.getValue();\n }\n\n function setValue(dateStr) {\n const parsed = new Date(dateStr + \"T00:00:00\");\n if (!isNaN(parsed.getTime())) {\n calendar.setValue(dateStr);\n syncInput(dateStr, parsed);\n }\n }\n\n function navigate(month, year) {\n calendar.navigate(month, year);\n }\n\n // Event: calendar selection committed\n function onCalendarChange(e) {\n if (!e.detail || !e.detail.date) return;\n syncInput(e.detail.date, e.detail.dateObj);\n close();\n input.focus();\n\n root.dispatchEvent(\n new CustomEvent(\"faqir:date-change\", {\n detail: { date: e.detail.date, dateObj: e.detail.dateObj },\n bubbles: true,\n })\n );\n }\n\n // Event: trigger/input click\n function onTriggerClick() {\n if (root.dataset.state === \"open\") {\n close();\n } else {\n open();\n }\n }\n\n // Event: escape on root (bubbles up from the calendar grid too)\n function onRootKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.preventDefault();\n // Closing the calendar popup is the whole action — a date picker inside a\n // dialog must not take the dialog down with it. [W3-2]\n e.stopPropagation();\n close();\n input.focus();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n root.addEventListener(\"faqir:calendar-change\", onCalendarChange);\n root.addEventListener(\"keydown\", onRootKeyDown);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close();\n trigger?.removeEventListener(\"click\", onTriggerClick);\n root.removeEventListener(\"faqir:calendar-change\", onCalendarChange);\n root.removeEventListener(\"keydown\", onRootKeyDown);\n if (outsideClickCleanup) outsideClickCleanup();\n calendar.destroy();\n delete root._faqirDatePicker;\n }\n\n const api = { open, close, getValue, setValue, navigate, selectDate, destroy };\n root._faqirDatePicker = api;\n return api;\n}\n return createDatePicker;\n })();\n\n // ── dialog ── (registry/recipes/dialog/dialog.js)\n var createDialog = controllerRegistry[\"dialog\"] = (function() {\n// @ui:controller dialog\n// @ui:provides open close toggle destroy\n\n/**\n * Shared modal-dialog controller.\n *\n * It drives both the `dialog` recipe and the `alert-dialog` recipe — the two are\n * one controller, distinguished only by the panel's ARIA role. When the panel\n * declares `role=\"alertdialog\"` the controller switches to the WAI-ARIA\n * alertdialog contract:\n * - the overlay backdrop does NOT dismiss (only an explicit choice closes it);\n * - focus lands on the least-destructive action (cancel/close), not the panel;\n * - Escape still closes by default, but a `data-confirm-required` root traps it\n * so the user must pick confirm or cancel;\n * - the footer's `[data-part=\"confirm\"]` / `[data-part=\"cancel\"]` actions emit\n * cancelable `faqir:confirm` / `faqir:cancel` events (a prevented confirm\n * keeps the dialog open for async work).\n * A plain `role=\"dialog\"` panel behaves exactly as before.\n */\nfunction createDialog(root) {\n // Prevent double-init\n if (root._faqirDialog) return root._faqirDialog;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const overlay = root.querySelector(\"[data-part='overlay']\");\n const panel = root.querySelector(\"[data-part='panel']\");\n const closeButtons = root.querySelectorAll(\"[data-part='close']\");\n const confirmButtons = root.querySelectorAll(\"[data-part='confirm']\");\n const cancelButtons = root.querySelectorAll(\"[data-part='cancel']\");\n\n // The role is the seam between `dialog` and `alert-dialog` — read it from the\n // markup so a single controller serves both recipes.\n const isAlert = !!panel && panel.getAttribute(\"role\") === \"alertdialog\";\n\n let focusCleanup = null;\n let previouslyFocused = null;\n\n /** A confirm-required alertdialog traps Escape/overlay until an action is taken. */\n function confirmRequired() {\n return isAlert && root.hasAttribute(\"data-confirm-required\");\n }\n\n /** Emit a cancelable, bubbling `faqir:<type>` event; returns the event. */\n function emit(type, detail) {\n const event = new CustomEvent(\"faqir:\" + type, {\n bubbles: true,\n cancelable: true,\n detail: detail || {},\n });\n root.dispatchEvent(event);\n return event;\n }\n\n /** On open, focus the least-destructive action for an alert, else the panel. */\n function focusInitial() {\n if (isAlert) {\n const target =\n root.querySelector(\"[data-part='cancel']\") ||\n root.querySelector(\"[data-part='close']\") ||\n panel;\n target?.focus?.();\n } else {\n panel?.focus?.();\n }\n }\n\n // Cancels an in-flight \"closing\" wait when the dialog is re-opened mid-exit.\n let cancelExitWait = null;\n\n function open() {\n // A second open() (trigger plus an external trigger, say) must not stack\n // another focus trap or overwrite the focus to restore on close.\n if (root.dataset.state === \"open\" && focusCleanup) return;\n cancelExitWait?.();\n cancelExitWait = null;\n // Re-opened mid-exit: the trap and the focus to restore are still live.\n if (!focusCleanup) previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n if (!focusCleanup) focusCleanup = trapFocus(panel);\n focusInitial();\n }\n\n function close() {\n // Already gone, or already animating out — a second click (confirm then\n // close, say) must not start a second wait on top of the one in flight.\n if (root.dataset.state === \"closed\" || root.dataset.state === \"closing\") return;\n\n root.dataset.state = \"closing\";\n\n const onEnd = () => {\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n previouslyFocused?.focus();\n };\n\n // The panel's own exit motion. A footer button's `background` transitionend\n // bubbles here the instant the pointer touches it, and used to eat the\n // one-shot listener — snapping the panel away mid-animation at best, and at\n // worst leaving it up. No property filter: the panel's exit is an\n // `animation` in some themes and a `transition` in others. See\n // `whenExitDone`. [W2-1]\n cancelExitWait = whenExitDone(panel, null, onEnd);\n }\n\n /**\n * Tear the overlay down NOW — no exit animation, no focus restore.\n *\n * `destroy()` unbound every listener and left the panel and its backdrop\n * exactly where they were: a full-page block whose close button, Escape key\n * and overlay click had all just stopped working, with no way out. An SPA\n * route change destroys controllers and does precisely this. The model is\n * `context-menu`, which has always closed itself on teardown. [W3-2]\n */\n function dismiss() {\n cancelExitWait?.();\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n if (overlay) overlay.hidden = true;\n if (panel) panel.hidden = true;\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event listeners\n function onTriggerClick() {\n open();\n }\n function onOverlayClick() {\n close();\n }\n // In alert mode, dismissing without confirming is a cancel; the plain dialog\n // just closes.\n function onCloseClick() {\n if (isAlert) emit(\"cancel\", { reason: \"close\" });\n close();\n }\n function onCancelClick() {\n emit(\"cancel\", { reason: \"cancel\" });\n close();\n }\n function onConfirmClick() {\n const variant =\n panel?.getAttribute(\"data-variant\") ||\n root.getAttribute(\"data-variant\") ||\n \"default\";\n const event = emit(\"confirm\", { variant });\n // A handler may keep the dialog open (e.g. to await a destructive request)\n // by calling preventDefault() on the confirm event.\n if (!event.defaultPrevented) close();\n }\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n // WAI-ARIA allows Escape to close an alertdialog, but a confirm-required\n // variant traps it so the user must make an explicit choice.\n if (confirmRequired()) {\n e.stopPropagation();\n return;\n }\n e.stopPropagation();\n if (isAlert) emit(\"cancel\", { reason: \"escape\" });\n close();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n // An alertdialog must not dismiss on overlay click — only an explicit choice\n // closes it — so the overlay handler is bound for plain dialogs only.\n if (!isAlert) overlay?.addEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) => btn.addEventListener(\"click\", onCloseClick));\n confirmButtons.forEach((btn) => btn.addEventListener(\"click\", onConfirmClick));\n cancelButtons.forEach((btn) => btn.addEventListener(\"click\", onCancelClick));\n root.addEventListener(\"keydown\", onKeyDown);\n\n // Support external triggers: any element with [data-open=\"{dialog-id}\"]\n const externalTriggers = root.id\n ? document.querySelectorAll(`[data-open=\"${root.id}\"]`)\n : [];\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.addEventListener(\"click\", onTriggerClick)\n );\n }\n\n function destroy() {\n trigger?.removeEventListener(\"click\", onTriggerClick);\n if (!isAlert) overlay?.removeEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCloseClick)\n );\n confirmButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onConfirmClick)\n );\n cancelButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCancelClick)\n );\n root.removeEventListener(\"keydown\", onKeyDown);\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.removeEventListener(\"click\", onTriggerClick)\n );\n }\n dismiss();\n delete root._faqirDialog;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirDialog = api;\n return api;\n}\n return createDialog;\n })();\n\n // ── drawer ── (registry/recipes/drawer/drawer.js)\n var createDrawer = controllerRegistry[\"drawer\"] = (function() {\n// @ui:controller drawer\n// @ui:provides open close toggle destroy\n\nfunction createDrawer(root) {\n // Prevent double-init\n if (root._faqirDrawer) return root._faqirDrawer;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const overlay = root.querySelector(\"[data-part='overlay']\");\n const panel = root.querySelector(\"[data-part='panel']\");\n const closeButtons = root.querySelectorAll(\"[data-part='close']\");\n\n let focusCleanup = null;\n let previouslyFocused = null;\n let prevBodyOverflow = null;\n\n // Scroll lock: an open modal drawer freezes the page behind it. The guard makes\n // lock/unlock idempotent so overlapping open/close sequences (or a double\n // open) can never leave the body stuck at `overflow: hidden`.\n function lockScroll() {\n if (prevBodyOverflow !== null) return;\n prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n function unlockScroll() {\n if (prevBodyOverflow === null) return;\n document.body.style.overflow = prevBodyOverflow;\n prevBodyOverflow = null;\n }\n\n // Cancels an in-flight \"closing\" wait when the drawer is re-opened mid-slide.\n let cancelExitWait = null;\n\n function open() {\n cancelExitWait?.();\n cancelExitWait = null;\n previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n lockScroll();\n focusCleanup = trapFocus(panel);\n panel.focus?.();\n }\n\n function close() {\n // Already gone, or already sliding out — a second click must not start a\n // second wait on top of the one in flight.\n if (root.dataset.state === \"closed\" || root.dataset.state === \"closing\") return;\n\n root.dataset.state = \"closing\";\n\n const onEnd = () => {\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n previouslyFocused?.focus();\n };\n\n // The panel's OWN `transform` — not the close button's `background`, which\n // bubbles up to the panel the moment the pointer touches it and used to eat\n // the one-shot listener, stranding the drawer at \"closing\" with the overlay\n // still covering the page. See `whenExitDone`. [W2-1]\n cancelExitWait = whenExitDone(panel, \"transform\", onEnd);\n }\n\n /**\n * Tear the overlay down NOW — no exit animation, no focus restore.\n *\n * `destroy()` unbound every listener and left the panel and its backdrop\n * exactly where they were: a full-page block whose close button, Escape key\n * and overlay click had all just stopped working, with no way out. An SPA\n * route change destroys controllers and does precisely this. The model is\n * `context-menu`, which has always closed itself on teardown. [W3-2]\n */\n function dismiss() {\n cancelExitWait?.();\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n if (overlay) overlay.hidden = true;\n if (panel) panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event listeners\n function onTriggerClick() {\n open();\n }\n\n function onOverlayClick() {\n close();\n }\n\n function onCloseClick() {\n close();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.stopPropagation();\n close();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n overlay?.addEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) => btn.addEventListener(\"click\", onCloseClick));\n root.addEventListener(\"keydown\", onKeyDown);\n\n // Support external triggers: any element with [data-open=\"{drawer-id}\"]\n const externalTriggers = root.id\n ? document.querySelectorAll(`[data-open=\"${root.id}\"]`)\n : [];\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.addEventListener(\"click\", onTriggerClick)\n );\n }\n\n function destroy() {\n trigger?.removeEventListener(\"click\", onTriggerClick);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCloseClick)\n );\n root.removeEventListener(\"keydown\", onKeyDown);\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.removeEventListener(\"click\", onTriggerClick)\n );\n }\n dismiss();\n delete root._faqirDrawer;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirDrawer = api;\n return api;\n}\n return createDrawer;\n })();\n\n // ── dropdown ── (registry/recipes/dropdown/dropdown.js)\n var createDropdown = controllerRegistry[\"dropdown\"] = (function() {\n// @ui:controller dropdown\n// @ui:provides open close toggle destroy\n\nfunction createDropdown(root) {\n // Prevent double-init\n if (root._faqirDropdown) return root._faqirDropdown;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const menu = root.querySelector(\"[data-part='menu']\");\n\n // Incomplete markup — a wrapper emitted without one of its parts, which is\n // what a generator interrupted mid-component produces — used to throw a\n // TypeError out of the first dereference below. The engine contains that now\n // (the component fails, the page survives), but \"Cannot read properties of\n // null\" is a poor way to say which part is missing. Say it, and hand back an\n // inert API so `$ui.open()` is a no-op rather than a second crash. [W3-2]\n if (!trigger || !menu) {\n console.warn(\n \"[Faqir] dropdown needs [data-part='trigger'] and [data-part='menu'] — \" +\n `missing ${[!trigger && \"trigger\", !menu && \"menu\"].filter(Boolean).join(\" and \")}. ` +\n \"Component left inert.\",\n root\n );\n const inert = { open() {}, close() {}, toggle() {}, destroy() {} };\n root._faqirDropdown = inert;\n return inert;\n }\n\n let outsideClickCleanup = null;\n\n const navigation = createMenuNavigation(menu, {\n onEscape() {\n close();\n },\n onTab() {\n close({ restoreFocus: false });\n },\n });\n\n function open(options = {}) {\n const focus = options.focus || \"first\";\n root.dataset.state = \"open\";\n menu.hidden = false;\n trigger.setAttribute(\"aria-expanded\", \"true\");\n\n if (focus === \"last\") navigation.focusLast();\n else navigation.focusFirst();\n\n // Close on outside click\n if (outsideClickCleanup) outsideClickCleanup();\n outsideClickCleanup = onOutsideClick(root, () => close({ restoreFocus: false }));\n }\n\n function close(options = {}) {\n const restoreFocus = options.restoreFocus !== false;\n root.dataset.state = \"closed\";\n menu.hidden = true;\n trigger.setAttribute(\"aria-expanded\", \"false\");\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n\n if (restoreFocus) trigger.focus();\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n function onTriggerClick() {\n toggle();\n }\n\n function onTriggerKeyDown(e) {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (root.dataset.state !== \"open\") open({ focus: e.key === \"ArrowUp\" ? \"last\" : \"first\" });\n else if (e.key === \"ArrowUp\") navigation.focusLast();\n else navigation.focusFirst();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n trigger?.addEventListener(\"keydown\", onTriggerKeyDown);\n\n // Delegate item clicks\n function onMenuClick(e) {\n const item = e.target.closest(\"[data-part='item']\");\n if (\n item &&\n item.closest('[role=\"menu\"]') === menu &&\n !item.disabled &&\n item.getAttribute(\"aria-disabled\") !== \"true\"\n ) close();\n }\n menu?.addEventListener(\"click\", onMenuClick);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close({ restoreFocus: false });\n trigger?.removeEventListener(\"click\", onTriggerClick);\n trigger?.removeEventListener(\"keydown\", onTriggerKeyDown);\n menu?.removeEventListener(\"click\", onMenuClick);\n navigation.destroy();\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirDropdown;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirDropdown = api;\n return api;\n}\n return createDropdown;\n })();\n\n // ── file-upload ── (registry/recipes/file-upload/file-upload.js)\n var createFileUpload = controllerRegistry[\"file-upload\"] = (function() {\n// @ui:controller file-upload\n// @ui:provides getFiles open remove clear destroy\n\n/**\n * Drag-and-drop file collection with a native file-input fallback.\n *\n * The controller only validates and retains local File objects. Application\n * code owns every upload operation through the bubbling events documented in\n * the manifest.\n */\nfunction createFileUpload(root) {\n if (root._faqirFileUpload) return root._faqirFileUpload;\n\n let dropzone = root.querySelector(\"[data-part='dropzone']\");\n if (!dropzone) {\n dropzone = document.createElement(\"label\");\n dropzone.setAttribute(\"data-part\", \"dropzone\");\n root.prepend(dropzone);\n }\n\n let input = root.querySelector(\"[data-part='input']\");\n if (!input) {\n input = document.createElement(\"input\");\n input.setAttribute(\"data-part\", \"input\");\n dropzone.prepend(input);\n }\n input.setAttribute(\"type\", \"file\");\n\n let description = root.querySelector(\"[data-part='description']\");\n if (description) {\n if (!description.id) description.id = uid(\"faqir-file-upload-help\");\n if (!input.hasAttribute(\"aria-describedby\")) {\n input.setAttribute(\"aria-describedby\", description.id);\n }\n }\n\n if (dropzone.tagName === \"LABEL\" && !dropzone.contains(input)) {\n if (!input.id) input.id = uid(\"faqir-file-upload-input\");\n dropzone.htmlFor = input.id;\n }\n\n let list = root.querySelector(\"[data-part='list']\");\n if (!list) {\n list = document.createElement(\"ul\");\n list.setAttribute(\"data-part\", \"list\");\n list.setAttribute(\"aria-label\", \"Selected files\");\n root.appendChild(list);\n }\n\n let status = root.querySelector(\"[data-part='status']\");\n if (!status) {\n status = document.createElement(\"span\");\n status.setAttribute(\"data-part\", \"status\");\n status.setAttribute(\"role\", \"status\");\n status.setAttribute(\"aria-live\", \"polite\");\n root.appendChild(status);\n }\n\n if (root.hasAttribute(\"data-disabled\")) input.disabled = true;\n\n let selected = [];\n let dragging = false;\n let fileByRow = new WeakMap();\n\n function isDisabled() {\n return root.hasAttribute(\"data-disabled\") || input.disabled;\n }\n\n function toFileList(files) {\n const transfer = new DataTransfer();\n for (const file of files) transfer.items.add(file);\n const list = transfer.files;\n if (list instanceof FileList) return list;\n\n // Happy DOM currently returns File[] from DataTransfer.files. Preserve the\n // browser contract in that harness without changing the real-browser path.\n try {\n const fallback = new FileList();\n fallback.push(...files);\n return fallback;\n } catch {\n return list;\n }\n }\n\n function syncState() {\n root.dataset.state = dragging\n ? \"dragging\"\n : selected.length > 0\n ? \"has-files\"\n : \"idle\";\n }\n\n function syncInput() {\n try {\n input.files = toFileList(selected);\n } catch {\n // Some browsers intentionally expose FileList as read-only. The event\n // payload and controller's retained list remain authoritative.\n }\n }\n\n function formatSize(bytes) {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.ceil(bytes / 1024)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n }\n\n function render() {\n fileByRow = new WeakMap();\n list.replaceChildren();\n\n if (selected.length === 0) {\n const empty = document.createElement(\"li\");\n empty.setAttribute(\"data-part\", \"empty\");\n empty.textContent = \"No files selected\";\n list.appendChild(empty);\n syncState();\n return;\n }\n\n for (const file of selected) {\n const row = document.createElement(\"li\");\n row.setAttribute(\"data-part\", \"file\");\n fileByRow.set(row, file);\n\n const details = document.createElement(\"span\");\n details.setAttribute(\"data-part\", \"details\");\n\n const name = document.createElement(\"span\");\n name.setAttribute(\"data-part\", \"name\");\n name.textContent = file.name;\n\n const metadata = document.createElement(\"span\");\n metadata.setAttribute(\"data-part\", \"metadata\");\n metadata.textContent = `${file.type || \"Unknown type\"} · ${formatSize(file.size)}`;\n\n const remove = document.createElement(\"button\");\n remove.setAttribute(\"data-part\", \"remove\");\n remove.setAttribute(\"type\", \"button\");\n remove.setAttribute(\"aria-label\", `Remove ${file.name}`);\n remove.textContent = \"Remove\";\n remove.disabled = isDisabled();\n\n details.append(name, metadata);\n row.append(details, remove);\n list.appendChild(row);\n }\n syncState();\n }\n\n function emit(type, detail) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }),\n );\n }\n\n function acceptTokens() {\n return input.accept\n .split(\",\")\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean);\n }\n\n function matchesAccept(file) {\n const tokens = acceptTokens();\n if (tokens.length === 0) return true;\n\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (token.endsWith(\"/*\")) {\n return type.startsWith(token.slice(0, -1));\n }\n return type === token;\n });\n }\n\n function maxSize() {\n const raw = root.getAttribute(\"data-max-size\");\n if (raw == null || raw.trim() === \"\") return null;\n const value = Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : null;\n }\n\n function rejectionReason(file) {\n if (!matchesAccept(file)) return \"accept\";\n const limit = maxSize();\n if (limit != null && file.size > limit) return \"max-size\";\n return null;\n }\n\n function rejectionMessage(file, reason) {\n if (reason === \"max-size\") return `${file.name} exceeds the maximum file size.`;\n return `${file.name} is not an accepted file type.`;\n }\n\n function addFiles(fileList, source) {\n if (isDisabled()) return toFileList([]);\n\n const accepted = [];\n const limit = maxSize();\n for (const file of Array.from(fileList || [])) {\n const reason = rejectionReason(file);\n if (reason) {\n status.textContent = rejectionMessage(file, reason);\n emit(\"file-reject\", {\n file,\n reason,\n accept: input.accept,\n maxSize: limit,\n source,\n });\n } else {\n accepted.push(file);\n }\n }\n\n selected.push(...accepted);\n syncInput();\n render();\n\n const files = toFileList(accepted);\n emit(\"files\", {\n files,\n allFiles: toFileList(selected),\n source,\n });\n return files;\n }\n\n function remove(target) {\n const index = typeof target === \"number\"\n ? target\n : selected.indexOf(target);\n if (index < 0 || index >= selected.length || isDisabled()) return false;\n\n const [file] = selected.splice(index, 1);\n syncInput();\n render();\n status.textContent = `${file.name} removed.`;\n emit(\"file-remove\", {\n file,\n index,\n files: toFileList(selected),\n });\n return true;\n }\n\n function clear() {\n if (isDisabled()) return false;\n while (selected.length > 0) remove(0);\n return true;\n }\n\n function getFiles() {\n return toFileList(selected);\n }\n\n function open() {\n if (!isDisabled()) input.click();\n }\n\n function onDragEnter(event) {\n event.preventDefault();\n if (isDisabled()) return;\n dragging = true;\n syncState();\n }\n\n function onDragOver(event) {\n event.preventDefault();\n if (isDisabled()) return;\n dragging = true;\n if (event.dataTransfer) {\n try {\n event.dataTransfer.dropEffect = \"copy\";\n } catch {\n /* read-only in some DOM implementations */\n }\n }\n syncState();\n }\n\n function onDragLeave(event) {\n const next = event.relatedTarget;\n if (next && root.contains(next)) return;\n dragging = false;\n syncState();\n }\n\n function onDrop(event) {\n event.preventDefault();\n dragging = false;\n if (isDisabled()) {\n syncState();\n return;\n }\n addFiles(event.dataTransfer?.files, \"drop\");\n }\n\n function onChange() {\n addFiles(input.files, \"input\");\n }\n\n function onClick(event) {\n const removeButton = event.target?.closest?.(\"[data-part='remove']\");\n if (\n !removeButton ||\n removeButton.closest(\"[data-ui='file-upload']\") !== root\n ) return;\n const row = removeButton.closest(\"[data-part='file']\");\n const file = row && fileByRow.get(row);\n if (file) remove(file);\n }\n\n dropzone.addEventListener(\"dragenter\", onDragEnter);\n dropzone.addEventListener(\"dragover\", onDragOver);\n dropzone.addEventListener(\"dragleave\", onDragLeave);\n dropzone.addEventListener(\"drop\", onDrop);\n input.addEventListener(\"change\", onChange);\n root.addEventListener(\"click\", onClick);\n\n render();\n\n const api = {\n getFiles,\n open,\n remove,\n clear,\n destroy() {\n dropzone.removeEventListener(\"dragenter\", onDragEnter);\n dropzone.removeEventListener(\"dragover\", onDragOver);\n dropzone.removeEventListener(\"dragleave\", onDragLeave);\n dropzone.removeEventListener(\"drop\", onDrop);\n input.removeEventListener(\"change\", onChange);\n root.removeEventListener(\"click\", onClick);\n dragging = false;\n syncState();\n delete root._faqirFileUpload;\n },\n };\n\n root._faqirFileUpload = api;\n return api;\n}\n return createFileUpload;\n })();\n\n // ── input-otp ── (registry/recipes/input-otp/input-otp.js)\n var createInputOTP = controllerRegistry[\"input-otp\"] = (function() {\n// @ui:controller input-otp\n// @ui:provides getValue setValue clear focus destroy\n\n/**\n * input-otp — segmented one-time-code entry.\n *\n * ── Approach: ONE real input, N presentational segments ─────────────────────\n * The widget is a single, real `<input data-part=\"input\">` stretched over a row\n * of decorative `[data-part=\"segment\"]` boxes. The input is transparent (text,\n * caret and background) and sits on top, so every keystroke, paste, selection,\n * IME composition and — crucially — mobile SMS autofill goes through native form\n * machinery. The segments are `aria-hidden` and merely mirror the input's value.\n *\n * Why not one `<input>` per segment? Because the single-input design wins on the\n * exact axes this recipe is judged on:\n *\n * • Paste — the browser inserts pasted text at the caret for free; we only have\n * to strip characters that don't fit the mode. N separate inputs would each\n * have to re-split and redistribute a paste by hand, and browsers deliver a\n * multi-character paste inconsistently across split fields.\n * • Screen readers — one labelled field announces as \"One-time code, edit text\"\n * instead of N adjacent \"1 of 6 … 2 of 6\" edit boxes, which is far less\n * confusing. WAI has no dedicated OTP pattern; an OTP field IS a text input,\n * so we keep it a text input and give it a name + autocomplete.\n * • Mobile autofill — iOS/Android surface the SMS code for `inputmode` +\n * `autocomplete=\"one-time-code\"` on a SINGLE field; across N fields only the\n * first is offered the value and the rest are never populated.\n *\n * ── What the controller owns ────────────────────────────────────────────────\n * Runtime state only. It never fetches, never routes, never touches classes. It\n * reflects the input's value onto the segments (`data-filled`), marks the caret\n * segment (`data-active` / `data-caret`), and sets `data-state=\"complete\"` on the\n * root when full. Typing/backspace/paste are handled explicitly so behaviour is\n * identical across browsers (and unit-testable without native text editing), while\n * a catch-all `input` listener still absorbs autofill / IME that arrives whole.\n *\n * Events (bubbling): `faqir:change` on every value change (`detail.value`), and\n * `faqir:complete` exactly once per completion — fired on the not-full → full\n * transition, re-armed only after the value drops below full again.\n *\n * When the real input also carries `l-mask=\"999999\"`, the optional faqir-mask\n * plugin owns edit normalization and emits `faqir:mask`; this controller mirrors\n * the event's raw value into its segments. Without the plugin, the self-contained\n * keyboard/paste path below remains the byte-for-byte behavioral fallback.\n */\nfunction createInputOTP(root) {\n // Idempotent: a second init returns the existing API.\n if (root._faqirInputOTP) return root._faqirInputOTP;\n\n const N = clampInt(root.getAttribute(\"data-length\"), 6, 1, 12);\n const mode = root.getAttribute(\"data-mode\") === \"alphanumeric\" ? \"alphanumeric\" : \"numeric\";\n\n // ── Resolve / normalize the real input ─────────────────────────────────────\n let input = root.querySelector(\"[data-part='input']\");\n if (!input) {\n input = document.createElement(\"input\");\n input.setAttribute(\"data-part\", \"input\");\n input.setAttribute(\"type\", \"text\");\n root.insertBefore(input, root.firstChild);\n }\n input.setAttribute(\"maxlength\", String(N));\n try {\n input.maxLength = N;\n } catch {\n /* some environments make maxLength read-only on detached nodes — attribute suffices */\n }\n // Mobile-friendly defaults — authors may override in markup.\n if (!input.getAttribute(\"inputmode\")) {\n input.setAttribute(\"inputmode\", mode === \"numeric\" ? \"numeric\" : \"text\");\n }\n if (!input.getAttribute(\"autocomplete\")) input.setAttribute(\"autocomplete\", \"one-time-code\");\n if (!input.hasAttribute(\"aria-label\") && !input.hasAttribute(\"aria-labelledby\")) {\n input.setAttribute(\"aria-label\", \"One-time code\");\n }\n input.setAttribute(\"autocapitalize\", \"off\");\n input.setAttribute(\"autocorrect\", \"off\");\n input.setAttribute(\"spellcheck\", \"false\");\n if (mode === \"numeric\" && !input.hasAttribute(\"pattern\")) input.setAttribute(\"pattern\", \"[0-9]*\");\n if (isDisabled()) input.disabled = true;\n\n // ── Resolve / normalize the segment row ────────────────────────────────────\n let container = root.querySelector(\"[data-part='segments']\");\n if (!container) {\n container = document.createElement(\"div\");\n container.setAttribute(\"data-part\", \"segments\");\n root.appendChild(container);\n }\n // Segments are decorative — the real input is the accessible control.\n container.setAttribute(\"aria-hidden\", \"true\");\n\n let segments = [...container.querySelectorAll(\"[data-part='segment']\")];\n if (segments.length !== N) {\n // data-length is authoritative: rebuild the row to match it exactly.\n container.textContent = \"\";\n segments = [];\n for (let i = 0; i < N; i++) {\n const seg = document.createElement(\"div\");\n seg.setAttribute(\"data-part\", \"segment\");\n container.appendChild(seg);\n segments.push(seg);\n }\n }\n\n // ── Value plumbing ──────────────────────────────────────────────────────────\n let focused = false;\n let wasComplete = false;\n let lastValue = \"\";\n\n function isDisabled() {\n return root.hasAttribute(\"data-disabled\");\n }\n\n function charOk(ch) {\n return mode === \"alphanumeric\" ? /[a-z0-9]/i.test(ch) : /[0-9]/.test(ch);\n }\n\n /** Keep only mode-legal characters (no length cap — callers cap to N). */\n function filter(str) {\n let out = \"\";\n for (const ch of String(str == null ? \"\" : str)) if (charOk(ch)) out += ch;\n return out;\n }\n\n /** Optional faqir-mask bridge installed by the l-mask plugin. */\n function maskApi() {\n return input._faqirMask && typeof input._faqirMask.getRaw === \"function\"\n ? input._faqirMask\n : null;\n }\n\n function currentValue() {\n const mask = maskApi();\n return mask ? mask.getRaw() : input.value;\n }\n\n /** Paint segments + caret from the input's current value. No events. */\n function refresh() {\n const val = currentValue();\n for (let i = 0; i < N; i++) {\n const ch = val[i];\n const seg = segments[i];\n if (ch != null) {\n seg.textContent = ch;\n seg.setAttribute(\"data-filled\", \"\");\n } else {\n seg.textContent = \"\";\n seg.removeAttribute(\"data-filled\");\n }\n }\n if (val.length === N) root.setAttribute(\"data-state\", \"complete\");\n else root.removeAttribute(\"data-state\");\n updateActive();\n }\n\n /** Mark the caret segment (collapsed) or the selected span (range). */\n function updateActive() {\n for (const seg of segments) {\n seg.removeAttribute(\"data-active\");\n seg.removeAttribute(\"data-caret\");\n }\n if (!focused || isDisabled()) return;\n\n const len = input.value.length;\n let start = input.selectionStart;\n let end = input.selectionEnd;\n if (start == null) start = len;\n if (end == null) end = start;\n\n if (start !== end) {\n for (let i = start; i < end && i < N; i++) segments[i]?.setAttribute(\"data-active\", \"\");\n return;\n }\n const idx = Math.min(start, N - 1);\n const seg = segments[idx];\n if (!seg) return;\n seg.setAttribute(\"data-active\", \"\");\n // Blink a caret only in the next-to-fill empty slot — the crisp OTP look.\n if (start === len && len < N) seg.setAttribute(\"data-caret\", \"\");\n }\n\n function emit(type, detail) {\n root.dispatchEvent(new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }));\n }\n\n /** Repaint, then fire change / complete based on the transition. */\n function syncAndEmit() {\n refresh();\n const val = currentValue();\n if (val !== lastValue) {\n lastValue = val;\n emit(\"change\", { value: val });\n }\n const complete = val.length === N;\n if (complete && !wasComplete) {\n wasComplete = true;\n emit(\"complete\", { value: val });\n } else if (!complete) {\n wasComplete = false;\n }\n }\n\n /** The single write seam: set value + caret, then sync/emit. */\n function commit(next, caret) {\n const mask = maskApi();\n if (mask && typeof mask.setRaw === \"function\") {\n mask.setRaw(next, caret == null ? next.length : caret, true);\n return;\n }\n input.value = next;\n const c = caret == null ? next.length : Math.max(0, Math.min(caret, next.length));\n try {\n input.setSelectionRange(c, c);\n } catch {\n /* selection API unavailable on this input type/env — value is still correct */\n }\n syncAndEmit();\n }\n\n /** Insert mode-legal text at the caret, replacing any selection, capped at N. */\n function insertText(text) {\n const clean = filter(text);\n if (!clean) return;\n const val = input.value;\n let start = input.selectionStart;\n let end = input.selectionEnd;\n if (start == null) start = val.length;\n if (end == null) end = start;\n const next = (val.slice(0, start) + clean + val.slice(end)).slice(0, N);\n commit(next, start + clean.length);\n }\n\n function setCaret(pos) {\n const c = Math.max(0, Math.min(pos, input.value.length));\n try {\n input.setSelectionRange(c, c);\n } catch {\n /* ignore */\n }\n updateActive();\n }\n\n // ── Keyboard: explicit, deterministic editing ──────────────────────────────\n function onKeyDown(e) {\n if (isDisabled()) return;\n // Copy / paste / select-all / undo — let the browser + paste handler run.\n if (e.metaKey || e.ctrlKey || e.altKey) return;\n\n focused = true;\n const val = input.value;\n let start = input.selectionStart;\n let end = input.selectionEnd;\n if (start == null) start = val.length;\n if (end == null) end = start;\n\n // faqir-mask consumes the browser's beforeinput/paste path and reports its\n // raw result through faqir:mask. Leave text edits to it; keep only explicit\n // caret navigation here. The standalone fallback below remains unchanged.\n if (maskApi() && (e.key === \"Backspace\" || e.key === \"Delete\" || e.key.length === 1)) {\n return;\n }\n\n switch (e.key) {\n case \"Backspace\":\n e.preventDefault();\n if (start !== end) commit(val.slice(0, start) + val.slice(end), start);\n else if (start > 0) commit(val.slice(0, start - 1) + val.slice(start), start - 1);\n else updateActive();\n return;\n case \"Delete\":\n e.preventDefault();\n if (start !== end) commit(val.slice(0, start) + val.slice(end), start);\n else commit(val.slice(0, start) + val.slice(start + 1), start);\n return;\n case \"ArrowLeft\":\n e.preventDefault();\n // Collapsed caret steps left; a selection collapses to its start.\n setCaret(start === end ? start - 1 : start);\n return;\n case \"ArrowRight\":\n e.preventDefault();\n // Collapsed caret steps right; a selection collapses to its end.\n setCaret(start === end ? end + 1 : end);\n return;\n case \"Home\":\n e.preventDefault();\n setCaret(0);\n return;\n case \"End\":\n e.preventDefault();\n setCaret(val.length);\n return;\n default:\n // A single printable character — insert it (invalid chars are dropped).\n if (e.key.length === 1) {\n e.preventDefault();\n insertText(e.key);\n }\n // Everything else (Tab, Shift, arrows with modifiers, F-keys) passes through.\n }\n }\n\n // ── Paste: native cursor semantics, we only sanitize ───────────────────────\n function onPaste(e) {\n if (isDisabled()) return;\n e.preventDefault();\n focused = true;\n const data = e.clipboardData || (typeof window !== \"undefined\" && window.clipboardData);\n const text = data && typeof data.getData === \"function\" ? data.getData(\"text\") : \"\";\n insertText(text);\n }\n\n // ── Catch-all: autofill / IME / anything not intercepted above ─────────────\n function onInput() {\n if (isDisabled()) return;\n focused = true;\n const clean = filter(input.value).slice(0, N);\n if (clean !== input.value) {\n const pos = Math.min(input.selectionStart == null ? clean.length : input.selectionStart, clean.length);\n commit(clean, pos);\n } else {\n syncAndEmit();\n }\n }\n\n function onMask() {\n if (isDisabled()) return;\n focused = typeof document === \"undefined\" || document.activeElement === input;\n syncAndEmit();\n }\n\n function onFocus() {\n focused = true;\n // Predictable caret: land on the next-to-fill slot unless mid-editing.\n if (input.selectionStart === input.selectionEnd) setCaret(input.value.length);\n else updateActive();\n }\n function onBlur() {\n focused = false;\n updateActive();\n }\n function onClick() {\n focused = true;\n // Segments are pointer-events:none, so the click already hit the input;\n // snap the caret to the end for a consistent active segment.\n setCaret(input.value.length);\n }\n function onSelectionChange() {\n if (typeof document !== \"undefined\" && document.activeElement === input) updateActive();\n }\n\n input.addEventListener(\"keydown\", onKeyDown);\n input.addEventListener(\"paste\", onPaste);\n input.addEventListener(\"input\", onInput);\n input.addEventListener(\"faqir:mask\", onMask);\n input.addEventListener(\"focus\", onFocus);\n input.addEventListener(\"blur\", onBlur);\n input.addEventListener(\"click\", onClick);\n if (typeof document !== \"undefined\") document.addEventListener(\"selectionchange\", onSelectionChange);\n\n // ── Seed from data-value / existing input value, silently (no events) ───────\n {\n const seed = filter(input.value || root.getAttribute(\"data-value\") || \"\").slice(0, N);\n input.value = seed;\n lastValue = seed;\n wasComplete = seed.length === N;\n refresh();\n }\n\n // ── Public API ──────────────────────────────────────────────────────────────\n function getValue() {\n return currentValue();\n }\n /** Programmatic set — silent (does not fire change/complete). */\n function setValue(str) {\n const clean = filter(str).slice(0, N);\n const mask = maskApi();\n if (mask && typeof mask.setRaw === \"function\") mask.setRaw(clean, clean.length, false);\n else input.value = clean;\n lastValue = clean;\n wasComplete = clean.length === N;\n refresh();\n }\n function clear() {\n setValue(\"\");\n }\n function focus() {\n try {\n input.focus();\n } catch {\n /* ignore */\n }\n }\n\n function destroy() {\n input.removeEventListener(\"keydown\", onKeyDown);\n input.removeEventListener(\"paste\", onPaste);\n input.removeEventListener(\"input\", onInput);\n input.removeEventListener(\"faqir:mask\", onMask);\n input.removeEventListener(\"focus\", onFocus);\n input.removeEventListener(\"blur\", onBlur);\n input.removeEventListener(\"click\", onClick);\n if (typeof document !== \"undefined\") document.removeEventListener(\"selectionchange\", onSelectionChange);\n delete root._faqirInputOTP;\n }\n\n const api = { getValue, setValue, clear, focus, destroy };\n root._faqirInputOTP = api;\n return api;\n}\n\n// Parse an integer attribute, clamped to [lo, hi], with a fallback.\nfunction clampInt(raw, fallback, lo, hi) {\n const n = parseInt(raw, 10);\n if (!Number.isFinite(n)) return fallback;\n return Math.max(lo, Math.min(hi, n));\n}\n return createInputOTP;\n })();\n\n // ── menubar ── (registry/recipes/menubar/menubar.js)\n var createMenubar = controllerRegistry[\"menubar\"] = (function() {\n// @ui:controller menubar\n// @ui:provides open close destroy\n\nfunction createMenubar(root) {\n if (root._faqirMenubar) return root._faqirMenubar;\n\n const submenus = [...root.querySelectorAll(\"[data-part='submenu'][role='menu']\")]\n .filter((menu) => menu.closest(\"[data-ui='menubar']\") === root);\n const submenuNavigations = new Map();\n\n let topNavigation;\n\n function ownerOf(item) {\n return item?.closest(\"[role='menu'], [role='menubar']\");\n }\n\n function topItems() {\n return topNavigation?.items() ?? [];\n }\n\n function submenuFor(item) {\n const controls = item?.getAttribute(\"aria-controls\");\n if (controls) {\n const controlled = submenus.find((menu) => menu.id === controls);\n if (controlled) return controlled;\n }\n\n const sibling = item?.nextElementSibling;\n return sibling?.matches(\"[data-part='submenu'][role='menu']\")\n ? sibling\n : null;\n }\n\n function parentFor(menu) {\n return topItems().find((item) => submenuFor(item) === menu) ?? null;\n }\n\n function isAriaDisabled(item) {\n return item?.getAttribute(\"aria-disabled\") === \"true\";\n }\n\n function collapseAll() {\n let previousParent = null;\n\n for (const menu of submenus) {\n const parent = parentFor(menu);\n if (!menu.hidden && parent) previousParent = parent;\n menu.hidden = true;\n parent?.setAttribute(\"aria-expanded\", \"false\");\n }\n\n root.dataset.state = \"closed\";\n return previousParent;\n }\n\n function openFor(item, focus = \"first\") {\n const menu = submenuFor(item);\n if (!menu || isAriaDisabled(item)) return false;\n\n collapseAll();\n topNavigation.sync(item);\n menu.hidden = false;\n item.setAttribute(\"aria-expanded\", \"true\");\n root.dataset.state = \"open\";\n\n const navigation = submenuNavigations.get(menu);\n if (focus === \"last\") navigation?.focusLast();\n else if (focus === \"first\") navigation?.focusFirst();\n else item.focus();\n\n return true;\n }\n\n function open(index = 0, focus = \"first\") {\n const allItems = topItems();\n const item = typeof index === \"number\" ? allItems[index] : index;\n return item ? openFor(item, focus) : false;\n }\n\n function close(restoreFocus = true) {\n const parent = collapseAll();\n if (restoreFocus && parent) {\n topNavigation.sync(parent);\n parent.focus();\n }\n }\n\n function activateTopItem(item) {\n if (submenuFor(item)) {\n openFor(item, \"first\");\n return;\n }\n\n item.click();\n }\n\n const authoredTopItems = [...root.querySelectorAll(\"[role='menuitem']\")]\n .filter((item) => ownerOf(item) === root);\n const preferredTopItem =\n authoredTopItems.find(\n (item) => item.getAttribute(\"tabindex\") === \"0\" && !isAriaDisabled(item),\n ) ??\n authoredTopItems.find((item) => !isAriaDisabled(item)) ??\n authoredTopItems[0];\n\n topNavigation = createMenuNavigation(root, {\n orientation: \"horizontal\",\n roving: true,\n onActivate: activateTopItem,\n onEscape() {\n // The menubar itself is never hidden, so it receives Escape even with\n // every submenu collapsed. Nothing to dismiss means the keystroke is not\n // ours, and swallowing it would trap the user in whatever encloses the\n // menubar. [W3-2]\n if (root.dataset.state !== \"open\") return false;\n close(false);\n },\n onTab() {\n close(false);\n },\n });\n topNavigation.sync(preferredTopItem);\n\n for (const menu of submenus) {\n const navigation = createMenuNavigation(menu, {\n onEscape() {\n const parent = parentFor(menu);\n collapseAll();\n if (parent) {\n topNavigation.sync(parent);\n parent.focus();\n }\n },\n onTab() {\n collapseAll();\n },\n });\n submenuNavigations.set(menu, navigation);\n navigation.items().forEach((item) => {\n item.tabIndex = -1;\n });\n }\n\n // A menubar is persistent; only its popup submenus have open/closed state.\n collapseAll();\n\n function moveAcrossMenubar(menu, direction) {\n const parent = parentFor(menu);\n if (!parent) return;\n\n collapseAll();\n topNavigation.sync(parent);\n const nextItem = direction > 0\n ? topNavigation.focusNext()\n : topNavigation.focusPrevious();\n\n if (nextItem && submenuFor(nextItem) && !isAriaDisabled(nextItem)) {\n openFor(nextItem, \"parent\");\n }\n }\n\n function onKeyDown(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[role='menuitem']\");\n if (!item || !root.contains(item)) return;\n\n const owner = ownerOf(item);\n if (owner === root) {\n if ((event.key === \"ArrowDown\" || event.key === \"ArrowUp\") && submenuFor(item)) {\n if (isAriaDisabled(item)) return;\n event.preventDefault();\n openFor(item, event.key === \"ArrowUp\" ? \"last\" : \"first\");\n return;\n }\n\n // The shared horizontal navigation has already moved focus by the time\n // this listener runs. In open-menu mode, switch the visible submenu too.\n if (\n root.dataset.state === \"open\" &&\n (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\")\n ) {\n const nextItem = topNavigation.current();\n collapseAll();\n if (nextItem && submenuFor(nextItem) && !isAriaDisabled(nextItem)) {\n openFor(nextItem, \"parent\");\n }\n }\n return;\n }\n\n if (!submenus.includes(owner)) return;\n if (event.key === \"ArrowRight\" || event.key === \"ArrowLeft\") {\n event.preventDefault();\n moveAcrossMenubar(owner, event.key === \"ArrowRight\" ? 1 : -1);\n }\n }\n\n function onClick(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[role='menuitem']\");\n if (!item || !root.contains(item)) return;\n\n if (isAriaDisabled(item)) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n const owner = ownerOf(item);\n if (owner === root) {\n topNavigation.sync(item);\n item.focus();\n const menu = submenuFor(item);\n\n if (!menu) {\n collapseAll();\n return;\n }\n\n event.preventDefault();\n if (!menu.hidden) close(false);\n else openFor(item, \"parent\");\n return;\n }\n\n if (submenus.includes(owner)) {\n const parent = parentFor(owner);\n collapseAll();\n if (parent) {\n topNavigation.sync(parent);\n parent.focus();\n }\n }\n }\n\n root.addEventListener(\"keydown\", onKeyDown);\n root.addEventListener(\"click\", onClick, true);\n\n function destroy() {\n root.removeEventListener(\"keydown\", onKeyDown);\n root.removeEventListener(\"click\", onClick, true);\n topNavigation.destroy();\n submenuNavigations.forEach((navigation) => navigation.destroy());\n submenuNavigations.clear();\n delete root._faqirMenubar;\n }\n\n const api = { open, close, destroy };\n root._faqirMenubar = api;\n return api;\n}\n return createMenubar;\n })();\n\n // ── pagination ── (registry/recipes/pagination/pagination.js)\n var createPagination = controllerRegistry[\"pagination\"] = (function() {\n// @ui:controller pagination\n// @ui:provides setPage getPage setTotal render destroy\n\nfunction createPagination(root) {\n // Prevent double-init\n if (root._faqirPagination) return root._faqirPagination;\n\n const nav = root.querySelector(\"[data-part='nav']\");\n const prevBtn = root.querySelector(\"[data-part='prev']\");\n const nextBtn = root.querySelector(\"[data-part='next']\");\n\n let currentPage = 1;\n let totalPages = 1;\n\n // Initialize from existing DOM\n const activeBtn = root.querySelector(\"[data-part='page'][data-state='active']\");\n if (activeBtn) {\n currentPage = parseInt(activeBtn.dataset.page, 10) || 1;\n }\n\n const allPageBtns = root.querySelectorAll(\"[data-part='page']\");\n if (allPageBtns.length > 0) {\n const lastBtn = allPageBtns[allPageBtns.length - 1];\n totalPages = parseInt(lastBtn.dataset.page, 10) || 1;\n }\n\n function getPageButtons() {\n return [...root.querySelectorAll(\"[data-part='page']\")];\n }\n\n function updateActiveState() {\n getPageButtons().forEach((btn) => {\n const page = parseInt(btn.dataset.page, 10);\n if (page === currentPage) {\n btn.dataset.state = \"active\";\n btn.setAttribute(\"aria-current\", \"page\");\n } else {\n delete btn.dataset.state;\n btn.removeAttribute(\"aria-current\");\n }\n });\n\n // Update prev/next disabled state\n if (prevBtn) {\n prevBtn.disabled = currentPage <= 1;\n }\n if (nextBtn) {\n nextBtn.disabled = currentPage >= totalPages;\n }\n }\n\n function emitPageChange() {\n root.dispatchEvent(\n new CustomEvent(\"faqir:page-change\", {\n detail: { page: currentPage },\n bubbles: true,\n })\n );\n }\n\n function setPage(n) {\n const page = Math.max(1, Math.min(n, totalPages));\n if (page === currentPage) return;\n currentPage = page;\n updateActiveState();\n emitPageChange();\n }\n\n function getPage() {\n return currentPage;\n }\n\n function setTotal(n) {\n totalPages = Math.max(1, n);\n if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n updateActiveState();\n }\n\n // Rebuild the numbered page buttons + ellipses from the windowing math for the\n // given (current, total). Prev/next are preserved; only [data-part='page'] and\n // [data-part='ellipsis'] nodes are replaced. Does not emit page-change — it is\n // a render, not a user action. Clicks keep working via nav's delegated handler.\n function render(current, total) {\n if (!nav) return;\n totalPages = Math.max(1, Math.floor(total) || 1);\n currentPage = Math.max(1, Math.min(Math.floor(current) || 1, totalPages));\n\n nav\n .querySelectorAll(\"[data-part='page'], [data-part='ellipsis']\")\n .forEach((el) => el.remove());\n\n const frag = root.ownerDocument.createDocumentFragment();\n for (const item of paginationWindow(currentPage, totalPages)) {\n if (item === \"ellipsis\") {\n const span = root.ownerDocument.createElement(\"span\");\n span.setAttribute(\"data-part\", \"ellipsis\");\n span.textContent = \"…\";\n frag.appendChild(span);\n } else {\n const btn = root.ownerDocument.createElement(\"button\");\n btn.setAttribute(\"data-part\", \"page\");\n btn.dataset.page = String(item);\n btn.textContent = String(item);\n frag.appendChild(btn);\n }\n }\n\n if (nextBtn && nextBtn.parentNode === nav) {\n nav.insertBefore(frag, nextBtn);\n } else {\n nav.appendChild(frag);\n }\n\n updateActiveState();\n }\n\n // Event: click on page button\n function onNavClick(e) {\n const pageBtn = e.target.closest(\"[data-part='page']\");\n if (pageBtn) {\n const page = parseInt(pageBtn.dataset.page, 10);\n if (!isNaN(page)) {\n setPage(page);\n }\n return;\n }\n }\n\n function onPrevClick() {\n if (currentPage > 1) {\n setPage(currentPage - 1);\n }\n }\n\n function onNextClick() {\n if (currentPage < totalPages) {\n setPage(currentPage + 1);\n }\n }\n\n nav?.addEventListener(\"click\", onNavClick);\n prevBtn?.addEventListener(\"click\", onPrevClick);\n nextBtn?.addEventListener(\"click\", onNextClick);\n\n // Initialize disabled states\n updateActiveState();\n\n function destroy() {\n nav?.removeEventListener(\"click\", onNavClick);\n prevBtn?.removeEventListener(\"click\", onPrevClick);\n nextBtn?.removeEventListener(\"click\", onNextClick);\n delete root._faqirPagination;\n }\n\n const api = { setPage, getPage, setTotal, render, destroy };\n root._faqirPagination = api;\n return api;\n}\n\n/**\n * Pure windowing math: given the current page and total page count, return the\n * ordered list of items to display — page numbers interleaved with `\"ellipsis\"`\n * tokens where a run of pages is collapsed. A gap of exactly one page is never\n * collapsed to an ellipsis (the single page is shown instead), matching the\n * common MUI/APG pagination pattern.\n *\n * @param {number} currentPage 1-based active page (clamped into range).\n * @param {number} totalPages Total page count (>= 0; 0 → []).\n * @param {object} [options]\n * @param {number} [options.siblingCount=1] Pages shown either side of current.\n * @param {number} [options.boundaryCount=1] Pages pinned at each end.\n * @returns {Array<number|\"ellipsis\">}\n */\nfunction paginationWindow(currentPage, totalPages, options = {}) {\n const siblingCount = Math.max(0, Math.floor(options.siblingCount ?? 1));\n const boundaryCount = Math.max(0, Math.floor(options.boundaryCount ?? 1));\n\n const total = Math.max(0, Math.floor(totalPages) || 0);\n if (total <= 0) return [];\n const current = Math.min(Math.max(1, Math.floor(currentPage) || 1), total);\n\n const range = (start, end) => {\n const out = [];\n for (let i = start; i <= end; i++) out.push(i);\n return out;\n };\n\n const startPages = range(1, Math.min(boundaryCount, total));\n const endPages = range(Math.max(total - boundaryCount + 1, boundaryCount + 1), total);\n\n const siblingsStart = Math.max(\n Math.min(current - siblingCount, total - boundaryCount - siblingCount * 2 - 1),\n boundaryCount + 2\n );\n const siblingsEnd = Math.min(\n Math.max(current + siblingCount, boundaryCount + siblingCount * 2 + 2),\n endPages.length > 0 ? endPages[0] - 2 : total - 1\n );\n\n return [\n ...startPages,\n ...(siblingsStart > boundaryCount + 2\n ? [\"ellipsis\"]\n : boundaryCount + 1 < total - boundaryCount\n ? [boundaryCount + 1]\n : []),\n ...range(siblingsStart, siblingsEnd),\n ...(siblingsEnd < total - boundaryCount - 1\n ? [\"ellipsis\"]\n : total - boundaryCount > boundaryCount\n ? [total - boundaryCount]\n : []),\n ...endPages,\n ];\n}\n return createPagination;\n })();\n\n // ── popover ── (registry/recipes/popover/popover.js)\n var createPopover = controllerRegistry[\"popover\"] = (function() {\n// @ui:controller popover\n// @ui:provides open close toggle destroy\n\nfunction createPopover(root) {\n // Prevent double-init\n if (root._faqirPopover) return root._faqirPopover;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const content = root.querySelector(\"[data-part='content']\");\n const closeBtn = root.querySelector(\"[data-part='close']\");\n\n let outsideClickCleanup = null;\n\n function open() {\n root.dataset.state = \"open\";\n content.hidden = false;\n trigger.setAttribute(\"aria-expanded\", \"true\");\n\n // Close on outside click\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n function close() {\n root.dataset.state = \"closed\";\n content.hidden = true;\n trigger.setAttribute(\"aria-expanded\", \"false\");\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event: trigger click toggles\n function onTriggerClick() {\n toggle();\n }\n\n // Event: close button\n function onCloseClick(e) {\n e.stopPropagation();\n close();\n }\n\n // Event: escape closes\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.preventDefault();\n // Dismissing this popover consumes the keystroke — an enclosing dialog or\n // drawer must not close on the same Escape. [W3-2]\n e.stopPropagation();\n close();\n trigger.focus();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n closeBtn?.addEventListener(\"click\", onCloseClick);\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close();\n trigger?.removeEventListener(\"click\", onTriggerClick);\n closeBtn?.removeEventListener(\"click\", onCloseClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirPopover;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirPopover = api;\n return api;\n}\n return createPopover;\n })();\n\n // ── qr-code ── (registry/recipes/qr-code/qr-code.js)\n var createQRCode = controllerRegistry[\"qr-code\"] = (function() {\n// @ui:controller qr-code\n// @ui:provides render update destroy\n\n/**\n * Minimal QR Code encoder (byte mode, versions 1–10).\n * Produces a boolean matrix suitable for SVG rendering.\n * Covers most practical use-cases (URLs, short text up to ~170 chars at ECL-M).\n */\n\n// ── GF(256) arithmetic for Reed-Solomon ──\n\nconst EXP = new Uint8Array(256);\nconst LOG = new Uint8Array(256);\n(() => {\n let v = 1;\n for (let i = 0; i < 255; i++) {\n EXP[i] = v;\n LOG[v] = i;\n v = (v << 1) ^ (v & 128 ? 0x11d : 0);\n }\n EXP[255] = EXP[0];\n})();\n\nfunction gfMul(a, b) {\n return a === 0 || b === 0 ? 0 : EXP[(LOG[a] + LOG[b]) % 255];\n}\n\nfunction rsGenPoly(n) {\n let poly = [1];\n for (let i = 0; i < n; i++) {\n const next = new Array(poly.length + 1).fill(0);\n for (let j = 0; j < poly.length; j++) {\n next[j] ^= poly[j];\n next[j + 1] ^= gfMul(poly[j], EXP[i]);\n }\n poly = next;\n }\n return poly;\n}\n\nfunction rsEncode(data, ecLen) {\n const gen = rsGenPoly(ecLen);\n const msg = new Array(data.length + ecLen).fill(0);\n data.forEach((v, i) => (msg[i] = v));\n for (let i = 0; i < data.length; i++) {\n const coef = msg[i];\n if (coef !== 0) {\n for (let j = 0; j < gen.length; j++) {\n msg[i + j] ^= gfMul(gen[j], coef);\n }\n }\n }\n return msg.slice(data.length);\n}\n\n// ── QR constants ──\n\nconst ECL_MAP = { L: 0, M: 1, Q: 2, H: 3 };\n\n// [version][ecl] → { totalBytes, ecPerBlock, blocks }\nconst VERSION_TABLE = [\n null, // index 0 unused\n // v1\n [{ dc: 19, ec: 7, b: 1 }, { dc: 16, ec: 10, b: 1 }, { dc: 13, ec: 13, b: 1 }, { dc: 9, ec: 17, b: 1 }],\n // v2\n [{ dc: 34, ec: 10, b: 1 }, { dc: 28, ec: 16, b: 1 }, { dc: 22, ec: 22, b: 1 }, { dc: 16, ec: 28, b: 1 }],\n // v3\n [{ dc: 55, ec: 15, b: 1 }, { dc: 44, ec: 26, b: 1 }, { dc: 34, ec: 18, b: 2 }, { dc: 26, ec: 22, b: 2 }],\n // v4\n [{ dc: 80, ec: 20, b: 1 }, { dc: 64, ec: 18, b: 2 }, { dc: 48, ec: 26, b: 2 }, { dc: 36, ec: 16, b: 4 }],\n // v5\n [{ dc: 108, ec: 26, b: 1 }, { dc: 86, ec: 24, b: 2 }, { dc: 62, ec: 18, b: 4 }, { dc: 46, ec: 22, b: 4 }],\n // v6\n [{ dc: 136, ec: 18, b: 2 }, { dc: 108, ec: 16, b: 4 }, { dc: 76, ec: 24, b: 4 }, { dc: 60, ec: 28, b: 4 }],\n // v7\n [{ dc: 156, ec: 20, b: 2 }, { dc: 124, ec: 18, b: 4 }, { dc: 88, ec: 18, b: 6 }, { dc: 66, ec: 26, b: 5 }],\n // v8\n [{ dc: 194, ec: 24, b: 2 }, { dc: 154, ec: 22, b: 4 }, { dc: 110, ec: 22, b: 6 }, { dc: 86, ec: 26, b: 6 }],\n // v9\n [{ dc: 232, ec: 30, b: 2 }, { dc: 182, ec: 22, b: 5 }, { dc: 132, ec: 20, b: 8 }, { dc: 98, ec: 24, b: 8 }],\n // v10\n [{ dc: 274, ec: 18, b: 4 }, { dc: 216, ec: 26, b: 5 }, { dc: 154, ec: 24, b: 8 }, { dc: 119, ec: 28, b: 8 }],\n];\n\nconst ALIGNMENT_POSITIONS = [\n null, [], [6, 18], [6, 22], [6, 26], [6, 30],\n [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50],\n];\n\nfunction selectVersion(dataLen, ecl) {\n const eclIdx = ECL_MAP[ecl] ?? 1;\n for (let v = 1; v <= 10; v++) {\n const info = VERSION_TABLE[v][eclIdx];\n if (dataLen <= info.dc) return v;\n }\n return -1;\n}\n\n// ── Matrix operations ──\n\nfunction createMatrix(size) {\n return Array.from({ length: size }, () => new Uint8Array(size));\n}\n\nfunction setModule(matrix, row, col, val, reserved) {\n const s = matrix.length;\n if (row >= 0 && row < s && col >= 0 && col < s) {\n matrix[row][col] = val;\n if (reserved) reserved[row][col] = 1;\n }\n}\n\nfunction placeFinderPattern(matrix, reserved, row, col) {\n for (let r = -1; r <= 7; r++) {\n for (let c = -1; c <= 7; c++) {\n const val =\n (r >= 0 && r <= 6 && (c === 0 || c === 6)) ||\n (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||\n (r >= 2 && r <= 4 && c >= 2 && c <= 4)\n ? 1\n : 0;\n setModule(matrix, row + r, col + c, val, reserved);\n }\n }\n}\n\nfunction placeAlignmentPattern(matrix, reserved, row, col) {\n for (let r = -2; r <= 2; r++) {\n for (let c = -2; c <= 2; c++) {\n const val =\n Math.abs(r) === 2 || Math.abs(c) === 2 || (r === 0 && c === 0) ? 1 : 0;\n setModule(matrix, row + r, col + c, val, reserved);\n }\n }\n}\n\nfunction placeTimingPatterns(matrix, reserved) {\n const s = matrix.length;\n for (let i = 8; i < s - 8; i++) {\n const val = i % 2 === 0 ? 1 : 0;\n setModule(matrix, 6, i, val, reserved);\n setModule(matrix, i, 6, val, reserved);\n }\n}\n\nfunction reserveFormatArea(matrix, reserved) {\n const s = matrix.length;\n for (let i = 0; i < 8; i++) {\n setModule(reserved, 8, i, 1);\n setModule(reserved, 8, s - 1 - i, 1);\n setModule(reserved, i, 8, 1);\n setModule(reserved, s - 1 - i, 8, 1);\n }\n setModule(reserved, 8, 8, 1);\n setModule(matrix, s - 8, 8, 1, reserved); // dark module\n}\n\nfunction placeData(matrix, reserved, bits) {\n const s = matrix.length;\n let bitIdx = 0;\n let upward = true;\n for (let col = s - 1; col >= 1; col -= 2) {\n if (col === 6) col = 5; // skip timing column\n const rows = upward\n ? Array.from({ length: s }, (_, i) => s - 1 - i)\n : Array.from({ length: s }, (_, i) => i);\n for (const row of rows) {\n for (let c = 0; c < 2; c++) {\n const cc = col - c;\n if (reserved[row][cc]) continue;\n matrix[row][cc] = bitIdx < bits.length ? bits[bitIdx++] : 0;\n }\n }\n upward = !upward;\n }\n}\n\nfunction applyMask(matrix, reserved, maskId) {\n const s = matrix.length;\n const fns = [\n (r, c) => (r + c) % 2 === 0,\n (r) => r % 2 === 0,\n (_, c) => c % 3 === 0,\n (r, c) => (r + c) % 3 === 0,\n (r, c) => (Math.floor(r / 2) + Math.floor(c / 3)) % 2 === 0,\n (r, c) => ((r * c) % 2) + ((r * c) % 3) === 0,\n (r, c) => (((r * c) % 2) + ((r * c) % 3)) % 2 === 0,\n (r, c) => (((r + c) % 2) + ((r * c) % 3)) % 2 === 0,\n ];\n const fn = fns[maskId];\n for (let r = 0; r < s; r++) {\n for (let c = 0; c < s; c++) {\n if (!reserved[r][c] && fn(r, c)) {\n matrix[r][c] ^= 1;\n }\n }\n }\n}\n\nfunction placeFormatInfo(matrix, ecl, maskId) {\n const s = matrix.length;\n const eclBits = [1, 0, 3, 2][ECL_MAP[ecl] ?? 1];\n let data = (eclBits << 3) | maskId;\n let rem = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >> 9) * 0x537);\n const bits = ((data << 10) | rem) ^ 0x5412;\n\n for (let i = 0; i < 15; i++) {\n const bit = (bits >> (14 - i)) & 1;\n // Around top-left finder\n if (i < 6) matrix[8][i] = bit;\n else if (i === 6) matrix[8][7] = bit;\n else if (i === 7) matrix[8][8] = bit;\n else if (i === 8) matrix[7][8] = bit;\n else matrix[14 - i][8] = bit;\n // Around other finders\n if (i < 8) matrix[s - 1 - i][8] = bit;\n else matrix[8][s - 15 + i] = bit;\n }\n}\n\n// ── Penalty scoring (simplified) ──\n\nfunction penalty(matrix) {\n const s = matrix.length;\n let score = 0;\n // Rule 1: runs of same color\n for (let r = 0; r < s; r++) {\n let count = 1;\n for (let c = 1; c < s; c++) {\n if (matrix[r][c] === matrix[r][c - 1]) {\n count++;\n if (count === 5) score += 3;\n else if (count > 5) score++;\n } else count = 1;\n }\n }\n for (let c = 0; c < s; c++) {\n let count = 1;\n for (let r = 1; r < s; r++) {\n if (matrix[r][c] === matrix[r - 1][c]) {\n count++;\n if (count === 5) score += 3;\n else if (count > 5) score++;\n } else count = 1;\n }\n }\n return score;\n}\n\n// ── Encode ──\n\nfunction encodeQR(text, ecl = \"M\") {\n const data = new TextEncoder().encode(text);\n const version = selectVersion(data.length, ecl);\n if (version < 0) throw new Error(\"Data too long for QR versions 1–10\");\n\n const eclIdx = ECL_MAP[ecl] ?? 1;\n const info = VERSION_TABLE[version][eclIdx];\n const size = version * 4 + 17;\n\n // Build data codewords\n const codewords = [];\n // Mode indicator: byte mode = 0100\n // Character count (8 bits for v1-9, 16 bits for v10+)\n const ccBits = version <= 9 ? 8 : 16;\n let bitBuf = 0;\n let bitCount = 0;\n\n function pushBits(val, len) {\n for (let i = len - 1; i >= 0; i--) {\n bitBuf = (bitBuf << 1) | ((val >> i) & 1);\n bitCount++;\n if (bitCount === 8) {\n codewords.push(bitBuf);\n bitBuf = 0;\n bitCount = 0;\n }\n }\n }\n\n pushBits(0b0100, 4); // byte mode\n pushBits(data.length, ccBits);\n data.forEach((b) => pushBits(b, 8));\n pushBits(0, 4); // terminator (up to 4 bits)\n\n // Pad to byte boundary\n if (bitCount > 0) pushBits(0, 8 - bitCount);\n\n // Pad to capacity\n while (codewords.length < info.dc) {\n codewords.push(0xec);\n if (codewords.length < info.dc) codewords.push(0x11);\n }\n\n // Split into blocks and compute EC\n const blocks = [];\n const ecBlocks = [];\n const ecPerBlock = info.ec / info.b;\n const dcPerBlock = Math.floor(info.dc / info.b);\n const remainder = info.dc % info.b;\n let offset = 0;\n\n for (let i = 0; i < info.b; i++) {\n const blockDc = dcPerBlock + (i >= info.b - remainder ? 1 : 0);\n const blockData = codewords.slice(offset, offset + blockDc);\n offset += blockDc;\n blocks.push(blockData);\n ecBlocks.push(rsEncode(blockData, ecPerBlock));\n }\n\n // Interleave\n const interleaved = [];\n const maxDc = Math.max(...blocks.map((b) => b.length));\n for (let i = 0; i < maxDc; i++) {\n for (const block of blocks) {\n if (i < block.length) interleaved.push(block[i]);\n }\n }\n for (let i = 0; i < ecPerBlock; i++) {\n for (const ec of ecBlocks) {\n if (i < ec.length) interleaved.push(ec[i]);\n }\n }\n\n // Convert to bit array\n const bits = [];\n interleaved.forEach((byte) => {\n for (let i = 7; i >= 0; i--) bits.push((byte >> i) & 1);\n });\n\n // Build matrix\n const matrix = createMatrix(size);\n const reserved = createMatrix(size);\n\n placeFinderPattern(matrix, reserved, 0, 0);\n placeFinderPattern(matrix, reserved, 0, size - 7);\n placeFinderPattern(matrix, reserved, size - 7, 0);\n\n const alignPos = ALIGNMENT_POSITIONS[version] || [];\n for (const r of alignPos) {\n for (const c of alignPos) {\n if (reserved[r]?.[c]) continue;\n placeAlignmentPattern(matrix, reserved, r, c);\n }\n }\n\n placeTimingPatterns(matrix, reserved);\n reserveFormatArea(matrix, reserved);\n\n // Try all masks, pick lowest penalty\n let bestMask = 0;\n let bestScore = Infinity;\n for (let m = 0; m < 8; m++) {\n const test = matrix.map((row) => new Uint8Array(row));\n placeData(test, reserved, bits);\n applyMask(test, reserved, m);\n placeFormatInfo(test, ecl, m);\n const s = penalty(test);\n if (s < bestScore) {\n bestScore = s;\n bestMask = m;\n }\n }\n\n placeData(matrix, reserved, bits);\n applyMask(matrix, reserved, bestMask);\n placeFormatInfo(matrix, ecl, bestMask);\n\n return matrix;\n}\n\n// ── SVG renderer ──\n\nfunction matrixToSVG(matrix) {\n const size = matrix.length;\n const quiet = 2; // quiet zone modules\n const total = size + quiet * 2;\n\n let paths = \"\";\n for (let r = 0; r < size; r++) {\n for (let c = 0; c < size; c++) {\n if (matrix[r][c]) {\n paths += `M${c + quiet},${r + quiet}h1v1h-1z`;\n }\n }\n }\n\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"viewBox\", `0 0 ${total} ${total}`);\n svg.setAttribute(\"shape-rendering\", \"crispEdges\");\n svg.setAttribute(\"data-part\", \"svg\");\n\n // Background\n const bg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n bg.setAttribute(\"width\", total);\n bg.setAttribute(\"height\", total);\n bg.setAttribute(\"fill\", \"var(--color-bg, #fff)\");\n svg.appendChild(bg);\n\n // QR modules\n const path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n path.setAttribute(\"d\", paths);\n path.setAttribute(\"fill\", \"var(--color-fg, #000)\");\n svg.appendChild(path);\n\n return svg;\n}\n\n// ── Controller ──\n\nfunction createQRCode(root) {\n if (root._faqirQR) return root._faqirQR;\n\n function render() {\n const value = root.getAttribute(\"data-value\") || \"\";\n const ecl = root.getAttribute(\"data-ecl\") || \"M\";\n\n // Remove old SVG\n const old = root.querySelector(\"[data-part='svg']\");\n if (old) old.remove();\n\n if (!value) return;\n\n try {\n const matrix = encodeQR(value, ecl);\n const svg = matrixToSVG(matrix);\n // Insert before caption if present\n const caption = root.querySelector(\"[data-part='caption']\");\n if (caption) {\n root.insertBefore(svg, caption);\n } else {\n root.appendChild(svg);\n }\n } catch (e) {\n console.warn(`[qr-code] Failed to encode: ${e.message}`);\n }\n }\n\n function update(newValue, newEcl) {\n if (newValue !== undefined) root.setAttribute(\"data-value\", newValue);\n if (newEcl !== undefined) root.setAttribute(\"data-ecl\", newEcl);\n render();\n }\n\n // Observe attribute changes\n const observer = new MutationObserver((mutations) => {\n for (const m of mutations) {\n if (m.attributeName === \"data-value\" || m.attributeName === \"data-ecl\") {\n render();\n break;\n }\n }\n });\n observer.observe(root, { attributes: true });\n\n function destroy() {\n observer.disconnect();\n const svg = root.querySelector(\"[data-part='svg']\");\n if (svg) svg.remove();\n delete root._faqirQR;\n }\n\n // Initial render\n render();\n\n const api = { render, update, destroy };\n root._faqirQR = api;\n return api;\n}\n return createQRCode;\n })();\n\n // ── select-custom ── (registry/recipes/select-custom/select-custom.js)\n var createSelectCustom = controllerRegistry[\"select-custom\"] = (function() {\n// @ui:controller select-custom\n// @ui:provides open close toggle select getValue destroy\n\nfunction createSelectCustom(root) {\n // Prevent double-init\n if (root._faqirSelectCustom) return root._faqirSelectCustom;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const valueEl = root.querySelector(\"[data-part='value']\");\n const listbox = root.querySelector(\"[data-part='listbox']\");\n const searchInput = root.querySelector(\"[data-part='search']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const options = () =>\n [...root.querySelectorAll(\"[data-part='option']\")];\n\n let highlightedIndex = -1;\n let outsideClickCleanup = null;\n let selectedValue = \"\";\n const placeholderText = valueEl?.textContent || \"\";\n\n /**\n * `aria-activedescendant` — the half of the combobox pattern that was declared\n * and never implemented. [W3-4]\n *\n * The trigger publishes `role=\"combobox\"`, which is the APG contract: as the\n * user arrows through the listbox, the combobox must name the active option so\n * a screen reader announces it. Highlighting lived in `data-highlighted`\n * alone and the options carried no `id`, so there was nothing to point at and\n * nothing was ever announced. The axe gate structurally cannot see this — it\n * evaluates static DOM, and the defect exists only mid-navigation.\n *\n * The owner is whichever element holds the combobox role: the search field\n * when the listbox has one (that is where focus is), otherwise the trigger.\n */\n const activeOwner = () => searchInput || trigger;\n\n function optionId(opt) {\n if (!opt.id) opt.id = uid(\"faqir-option\");\n return opt.id;\n }\n\n function setActiveDescendant(opt) {\n const owner = activeOwner();\n if (!owner) return;\n if (opt) owner.setAttribute(\"aria-activedescendant\", optionId(opt));\n else owner.removeAttribute(\"aria-activedescendant\");\n }\n\n /**\n * The hidden input that makes this a form control. [W3-4 · 0.4-28]\n *\n * `select-custom` is sold as a replacement for `<select>`, and a `<select>`\n * submits. This one rendered a `<div>` listbox and kept its value in a\n * closure, so a form containing it POSTed without the field at all — silently,\n * because a missing field looks exactly like an empty one on the server. The\n * input is created only when the markup does not already carry one, and only\n * when the component names itself, so nothing is invented for a component with\n * no name to submit under.\n */\n function ensureValueInput() {\n let el = root.querySelector(\"[data-part='input']\");\n if (el) return el;\n const name = root.dataset.name || root.getAttribute(\"name\");\n if (!name) return null;\n el = document.createElement(\"input\");\n el.type = \"hidden\";\n el.setAttribute(\"data-part\", \"input\");\n el.name = name;\n root.appendChild(el);\n return el;\n }\n\n const valueInput = ensureValueInput();\n\n function open() {\n root.dataset.state = \"open\";\n listbox.hidden = false;\n trigger.setAttribute(\"aria-expanded\", \"true\");\n\n // Reset search if present\n if (searchInput) {\n searchInput.value = \"\";\n filterOptions(\"\");\n searchInput.focus();\n }\n\n clearHighlight();\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n /**\n * Everything `close()` does EXCEPT moving focus.\n *\n * `destroy()` used to leave an open overlay standing with nothing listening —\n * a dead widget the user cannot dismiss. Closing it on teardown is the fix\n * (`context-menu` is the model), but teardown must not also yank focus\n * somewhere: on an SPA route change the element it would restore to is\n * usually on its way out of the document. [W3-2]\n */\n function dismiss() {\n root.dataset.state = \"closed\";\n listbox.hidden = true;\n trigger.setAttribute(\"aria-expanded\", \"false\");\n clearHighlight();\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function close() {\n dismiss();\n trigger.focus();\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n function clearHighlight() {\n options().forEach((opt) => {\n opt.removeAttribute(\"data-highlighted\");\n });\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function visibleOptions() {\n return options().filter((opt) => !opt.hasAttribute(\"data-hidden\"));\n }\n\n function highlightOption(index) {\n const visible = visibleOptions();\n if (visible.length === 0) return;\n\n // Clamp index\n if (index < 0) index = visible.length - 1;\n if (index >= visible.length) index = 0;\n\n // Clear previous\n options().forEach((opt) => opt.removeAttribute(\"data-highlighted\"));\n\n visible[index].setAttribute(\"data-highlighted\", \"\");\n visible[index].scrollIntoView({ block: \"nearest\" });\n setActiveDescendant(visible[index]);\n highlightedIndex = index;\n }\n\n function filterOptions(query) {\n const allOptions = options();\n const lowerQuery = query.toLowerCase();\n let visibleCount = 0;\n\n allOptions.forEach((opt) => {\n const text = opt.textContent.toLowerCase();\n if (text.includes(lowerQuery)) {\n opt.removeAttribute(\"data-hidden\");\n visibleCount++;\n } else {\n opt.setAttribute(\"data-hidden\", \"\");\n }\n });\n\n // Show/hide empty state\n if (emptyEl) {\n emptyEl.hidden = visibleCount > 0;\n }\n\n clearHighlight();\n return visibleCount;\n }\n\n function select(value) {\n const allOptions = options();\n let targetOption = null;\n\n // Find option by data-value attribute\n allOptions.forEach((opt) => {\n if (opt.dataset.value === value) {\n targetOption = opt;\n }\n });\n\n if (!targetOption) {\n // Fallback: find by text content\n allOptions.forEach((opt) => {\n if (opt.textContent.trim() === value) {\n targetOption = opt;\n }\n });\n }\n\n if (!targetOption) return;\n\n // Deselect all\n allOptions.forEach((opt) => opt.setAttribute(\"aria-selected\", \"false\"));\n\n // Select target\n targetOption.setAttribute(\"aria-selected\", \"true\");\n selectedValue = targetOption.dataset.value || targetOption.textContent.trim();\n\n // Update displayed value\n if (valueEl) {\n valueEl.textContent = targetOption.textContent.trim();\n valueEl.removeAttribute(\"data-placeholder\");\n }\n\n // …and the value a form actually submits. [W3-4 · 0.4-28]\n if (valueInput) valueInput.value = selectedValue;\n\n // Dispatch change event\n const event = new CustomEvent(\"select-change\", {\n bubbles: true,\n detail: {\n value: selectedValue,\n label: targetOption.textContent.trim()\n }\n });\n root.dispatchEvent(event);\n\n close();\n }\n\n function getValue() {\n return selectedValue;\n }\n\n // ── Event Handlers ──\n\n function onTriggerClick() {\n toggle();\n }\n\n function onTriggerKeyDown(e) {\n switch (e.key) {\n case \"ArrowDown\":\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (root.dataset.state !== \"open\") {\n open();\n }\n break;\n case \"Escape\":\n if (root.dataset.state === \"open\") {\n e.preventDefault();\n // Closing the listbox is the whole action — the form around it, and\n // everything the user has typed into it, stays. [W3-2]\n e.stopPropagation();\n close();\n }\n break;\n }\n }\n\n function onListboxKeyDown(e) {\n const visible = visibleOptions();\n\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n highlightOption(highlightedIndex + 1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n highlightOption(highlightedIndex - 1);\n break;\n case \"Enter\":\n e.preventDefault();\n if (highlightedIndex >= 0 && highlightedIndex < visible.length) {\n const opt = visible[highlightedIndex];\n select(opt.dataset.value || opt.textContent.trim());\n }\n break;\n case \"Escape\":\n e.preventDefault();\n // Reached only while the listbox is open, so this Escape is always ours.\n e.stopPropagation();\n close();\n break;\n case \"Home\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightOption(0);\n }\n break;\n case \"End\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightOption(visible.length - 1);\n }\n break;\n }\n }\n\n function onOptionClick(e) {\n const opt = e.target.closest(\"[data-part='option']\");\n if (!opt) return;\n select(opt.dataset.value || opt.textContent.trim());\n }\n\n function onSearchInput() {\n if (searchInput) {\n filterOptions(searchInput.value);\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n trigger?.addEventListener(\"keydown\", onTriggerKeyDown);\n listbox?.addEventListener(\"keydown\", onListboxKeyDown);\n listbox?.addEventListener(\"click\", onOptionClick);\n searchInput?.addEventListener(\"input\", onSearchInput);\n\n function destroy() {\n dismiss();\n trigger?.removeEventListener(\"click\", onTriggerClick);\n trigger?.removeEventListener(\"keydown\", onTriggerKeyDown);\n listbox?.removeEventListener(\"keydown\", onListboxKeyDown);\n listbox?.removeEventListener(\"click\", onOptionClick);\n searchInput?.removeEventListener(\"input\", onSearchInput);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirSelectCustom;\n }\n\n const api = { open, close, toggle, select, getValue, destroy };\n root._faqirSelectCustom = api;\n return api;\n}\n return createSelectCustom;\n })();\n\n // ── sheet ── (registry/recipes/sheet/sheet.js)\n var createSheet = controllerRegistry[\"sheet\"] = (function() {\n// @ui:controller sheet\n// @ui:provides open close toggle destroy\n\nfunction createSheet(root) {\n // Prevent double-init\n if (root._faqirSheet) return root._faqirSheet;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const overlay = root.querySelector(\"[data-part='overlay']\");\n const panel = root.querySelector(\"[data-part='panel']\");\n const closeButtons = root.querySelectorAll(\"[data-part='close']\");\n\n let focusCleanup = null;\n let previouslyFocused = null;\n let prevBodyOverflow = null;\n\n // Scroll lock: an open modal sheet freezes the page behind it. The guard makes\n // lock/unlock idempotent so overlapping open/close sequences (or a double\n // open) can never leave the body stuck at `overflow: hidden`.\n function lockScroll() {\n if (prevBodyOverflow !== null) return;\n prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n function unlockScroll() {\n if (prevBodyOverflow === null) return;\n document.body.style.overflow = prevBodyOverflow;\n prevBodyOverflow = null;\n }\n\n // Cancels an in-flight \"closing\" wait when the sheet is re-opened mid-slide.\n let cancelExitWait = null;\n\n function open() {\n cancelExitWait?.();\n cancelExitWait = null;\n previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n lockScroll();\n focusCleanup = trapFocus(panel);\n panel.focus?.();\n }\n\n function close() {\n // Already gone, or already sliding out — a second click must not start a\n // second wait on top of the one in flight.\n if (root.dataset.state === \"closed\" || root.dataset.state === \"closing\") return;\n\n root.dataset.state = \"closing\";\n\n const onEnd = () => {\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n previouslyFocused?.focus();\n };\n\n // The panel's OWN `transform` — not a close button's `background`, which\n // bubbles up to the panel the moment the pointer touches it and used to eat\n // the one-shot listener, stranding the sheet at \"closing\" with the overlay\n // still covering the page. See `whenExitDone`. [W2-1]\n cancelExitWait = whenExitDone(panel, \"transform\", onEnd);\n }\n\n /**\n * Tear the overlay down NOW — no exit animation, no focus restore.\n *\n * `destroy()` unbound every listener and left the panel and its backdrop\n * exactly where they were: a full-page block whose close button, Escape key\n * and overlay click had all just stopped working, with no way out. An SPA\n * route change destroys controllers and does precisely this. The model is\n * `context-menu`, which has always closed itself on teardown. [W3-2]\n */\n function dismiss() {\n cancelExitWait?.();\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n if (overlay) overlay.hidden = true;\n if (panel) panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event listeners\n function onTriggerClick() {\n open();\n }\n\n function onOverlayClick() {\n close();\n }\n\n function onCloseClick() {\n close();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.stopPropagation();\n close();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n overlay?.addEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) => btn.addEventListener(\"click\", onCloseClick));\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n trigger?.removeEventListener(\"click\", onTriggerClick);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCloseClick)\n );\n root.removeEventListener(\"keydown\", onKeyDown);\n dismiss();\n delete root._faqirSheet;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirSheet = api;\n return api;\n}\n return createSheet;\n })();\n\n // ── sidebar ── (registry/recipes/sidebar/sidebar.js)\n var createSidebar = controllerRegistry[\"sidebar\"] = (function() {\n// @ui:controller sidebar\n// @ui:provides toggle expand collapse open close isMobile getState destroy\n\n/**\n * sidebar — a collapsible application sidebar with three modes:\n *\n * • expanded — desktop, full-width with labels (default)\n * • rail — desktop, icons-only\n * • drawer — mobile, an off-canvas overlay panel (closed ↔ open)\n *\n * The single source of truth is `data-state` on the root; its value is one of\n * `expanded`, `rail`, `drawer` (mobile, closed) or `drawer-open` (mobile, open).\n * Agents can set the initial state declaratively — the controller reconciles it\n * with the current breakpoint on init.\n *\n * A `matchMedia` query (default `(max-width: 768px)`, overridable with\n * `data-breakpoint`) decides desktop vs mobile. `toggle()` is breakpoint-aware:\n * expanded ↔ rail on desktop, open ↔ close on mobile. The desktop preference\n * (expanded/rail) persists across a trip through the mobile breakpoint, so\n * resizing back to desktop restores what the user last chose.\n *\n * The mobile drawer is a proper modal surface: focus is trapped in the panel,\n * Escape and an overlay click close it, body scroll is locked while open, and\n * focus returns to whatever opened it. When the drawer is closed on mobile the\n * panel is `inert` + `aria-hidden`, so its links never sit in the tab order\n * off-screen. Every toggle button's `aria-expanded` tracks the live state.\n */\nfunction createSidebar(root) {\n // Prevent double-init.\n if (root._faqirSidebar) return root._faqirSidebar;\n\n const overlay = root.querySelector(\"[data-part='overlay']\");\n const panel = root.querySelector(\"[data-part='panel']\") || root;\n\n // Toggle buttons: any `[data-part='trigger']` inside the sidebar, plus external\n // triggers in the app shell that point at this sidebar by id. Both call toggle().\n const internalTriggers = [...root.querySelectorAll(\"[data-part='trigger']\")];\n const externalTriggers = root.id\n ? [...document.querySelectorAll(`[data-sidebar-toggle=\"${root.id}\"]`)]\n : [];\n const triggers = [...internalTriggers, ...externalTriggers];\n\n // Persistent desktop preference (expanded ↔ rail) and mobile open flag, both\n // seeded from the declared data-state so the initial render is intent-preserving.\n const declared = root.dataset.state || \"expanded\";\n let desktopState = declared === \"rail\" ? \"rail\" : \"expanded\";\n let drawerOpen = declared === \"drawer-open\";\n\n // Responsive breakpoint. `data-breakpoint` is a max-width in px (default 768).\n const bp = (() => {\n const n = parseInt(root.dataset.breakpoint || \"\", 10);\n return Number.isFinite(n) && n > 0 ? n : 768;\n })();\n const query = `(max-width: ${bp}px)`;\n const mql =\n typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(query)\n : null;\n\n function isMobile() {\n return mql ? !!mql.matches : false;\n }\n\n // Modal bookkeeping for the mobile drawer.\n let focusCleanup = null;\n let previouslyFocused = null;\n let prevBodyOverflow = null;\n\n function lockScroll() {\n if (prevBodyOverflow !== null) return;\n prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n function unlockScroll() {\n if (prevBodyOverflow === null) return;\n document.body.style.overflow = prevBodyOverflow;\n prevBodyOverflow = null;\n }\n function releaseFocusTrap() {\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function getState() {\n return root.dataset.state || \"\";\n }\n\n /**\n * Reconcile every reflected attribute with the current model + breakpoint.\n * Pure DOM writes — never dispatches an event, so it is safe to call on init.\n */\n function render() {\n const mobile = isMobile();\n const state = mobile ? (drawerOpen ? \"drawer-open\" : \"drawer\") : desktopState;\n root.dataset.state = state;\n\n // Overlay only exists as a hit-target when the drawer is open.\n if (overlay) overlay.hidden = state !== \"drawer-open\";\n\n // Closed mobile drawer: keep the off-screen panel out of the tab order and\n // the a11y tree. Any other state is a live, interactive surface.\n if (panel && panel !== root) {\n if (state === \"drawer\") {\n panel.setAttribute(\"inert\", \"\");\n panel.setAttribute(\"aria-hidden\", \"true\");\n } else {\n panel.removeAttribute(\"inert\");\n panel.removeAttribute(\"aria-hidden\");\n }\n }\n\n // aria-expanded reflects \"is the sidebar showing its content?\": labels on\n // desktop, an open drawer on mobile.\n const expanded = mobile ? drawerOpen : desktopState === \"expanded\";\n for (const t of triggers) t.setAttribute(\"aria-expanded\", String(expanded));\n }\n\n // ── Mobile drawer open/close ───────────────────────────────────────────────\n function open() {\n if (drawerOpen) return;\n previouslyFocused = document.activeElement;\n drawerOpen = true;\n render();\n lockScroll();\n focusCleanup = trapFocus(panel);\n if (!focusFirst(panel)) panel.focus?.();\n }\n\n function close() {\n if (!drawerOpen) return;\n drawerOpen = false;\n render();\n unlockScroll();\n releaseFocusTrap();\n previouslyFocused?.focus?.();\n previouslyFocused = null;\n }\n\n // ── Desktop expand/collapse ────────────────────────────────────────────────\n function expand() {\n desktopState = \"expanded\";\n render();\n }\n function collapse() {\n desktopState = \"rail\";\n render();\n }\n\n // ── Breakpoint-aware toggle ────────────────────────────────────────────────\n function toggle() {\n if (isMobile()) {\n drawerOpen ? close() : open();\n } else {\n desktopState === \"expanded\" ? collapse() : expand();\n }\n }\n\n // When the viewport crosses the breakpoint, tear down any live drawer modality\n // (a drawer left open as the window widens must not keep the scroll lock or the\n // focus trap) and re-render into the mode the new breakpoint calls for.\n function onMediaChange() {\n if (!isMobile() && drawerOpen) {\n drawerOpen = false;\n unlockScroll();\n releaseFocusTrap();\n previouslyFocused = null;\n }\n render();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && isMobile() && drawerOpen) {\n e.stopPropagation();\n close();\n }\n }\n\n function onTriggerClick(e) {\n e.preventDefault();\n toggle();\n }\n\n function onOverlayClick() {\n close();\n }\n\n for (const t of triggers) t.addEventListener(\"click\", onTriggerClick);\n overlay?.addEventListener(\"click\", onOverlayClick);\n root.addEventListener(\"keydown\", onKeyDown);\n if (mql) {\n if (typeof mql.addEventListener === \"function\") mql.addEventListener(\"change\", onMediaChange);\n else if (typeof mql.addListener === \"function\") mql.addListener(onMediaChange);\n }\n\n // Paint the reconciled initial state (no event).\n render();\n\n function destroy() {\n // A destroyed sidebar left mid-drawer is a dead overlay: the scrim still\n // covers the page, and its trigger, Escape and overlay click have all just\n // stopped working. Collapse the drawer first, without restoring focus —\n // teardown must not yank focus to an element on its way out. [W3-2]\n if (drawerOpen) {\n drawerOpen = false;\n render();\n }\n previouslyFocused = null;\n for (const t of triggers) t.removeEventListener(\"click\", onTriggerClick);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n if (mql) {\n if (typeof mql.removeEventListener === \"function\") mql.removeEventListener(\"change\", onMediaChange);\n else if (typeof mql.removeListener === \"function\") mql.removeListener(onMediaChange);\n }\n unlockScroll();\n releaseFocusTrap();\n delete root._faqirSidebar;\n }\n\n const api = { toggle, expand, collapse, open, close, isMobile, getState, destroy };\n root._faqirSidebar = api;\n return api;\n}\n return createSidebar;\n })();\n\n // ── slider ── (registry/recipes/slider/slider.js)\n var createSlider = controllerRegistry[\"slider\"] = (function() {\n// @ui:controller slider\n// @ui:provides setValue getValue getValues setFormatter destroy\n\n/**\n * slider — single-thumb and range (two-thumb) slider.\n *\n * Modes are inferred from the DOM, never from a flag: two-or-more\n * `[data-part=\"thumb\"]` elements ⇒ range mode. Each thumb is an independent\n * `role=\"slider\"` widget with its own keyboard handling and ARIA value state.\n *\n * The controller owns only runtime state: it writes `aria-valuemin/max/now`\n * (and `aria-valuetext`, via a formatter hook), positions thumbs through the\n * `--pos` custom property, reflects the filled span through `--slider-start` /\n * `--slider-end` on the root, and toggles `data-state=\"dragging\"` on the active\n * thumb. All value arithmetic lives in the pure, exported helpers below\n * (`valueFromPointer`, `snapToStep`, `percentOf`) so it is unit-testable without\n * a DOM.\n */\nfunction createSlider(root) {\n // Prevent double-init.\n if (root._faqirSlider) return root._faqirSlider;\n\n const track = root.querySelector(\"[data-part='track']\");\n const thumbs = [...root.querySelectorAll(\"[data-part='thumb']\")];\n const isRange = thumbs.length >= 2;\n const last = thumbs.length - 1;\n\n const min = numAttr(root, \"min\", 0);\n const max = numAttr(root, \"max\", 100);\n const step = (() => {\n const s = numAttr(root, \"step\", 1);\n return s > 0 ? s : 1;\n })();\n // PageUp/PageDown jump: an explicit data-page-step, else ten normal steps.\n const bigStep = (() => {\n const p = numAttr(root, \"pageStep\", NaN);\n return Number.isFinite(p) && p > 0 ? p : step * 10;\n })();\n\n // aria-valuetext hook: a formatter set via setFormatter() wins; otherwise a\n // declarative `data-value-suffix` (e.g. \"%\") produces \"<value><suffix>\".\n let formatter = null;\n const suffix = root.dataset.valueSuffix || \"\";\n\n // Ensure every thumb is a proper, focusable slider even if the author omitted\n // the role/tabindex — screen-reader-correct ARIA must not depend on hand markup.\n thumbs.forEach((thumb) => {\n if (!thumb.hasAttribute(\"role\")) thumb.setAttribute(\"role\", \"slider\");\n if (!thumb.hasAttribute(\"tabindex\")) {\n thumb.setAttribute(\"tabindex\", isDisabled() ? \"-1\" : \"0\");\n }\n });\n\n // Seed values: prefer an existing aria-valuenow, then the i-th data-value\n // token, then a sensible default (first thumb → min, last → max).\n const dataVals = (root.dataset.value || \"\")\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n .map(Number);\n\n let values = thumbs.map((thumb, i) => {\n const now = thumb.getAttribute(\"aria-valuenow\");\n if (now !== null && now !== \"\" && Number.isFinite(Number(now))) return Number(now);\n if (i < dataVals.length && Number.isFinite(dataVals[i])) return dataVals[i];\n return i === 0 ? min : max;\n });\n // Normalize in order so range clamping sees already-normalized lower neighbours.\n thumbs.forEach((_, i) => {\n values[i] = clampForThumb(i, snapToStep(values[i], min, max, step));\n });\n\n function isDisabled() {\n return root.hasAttribute(\"data-disabled\");\n }\n\n // Clamp a candidate value to the global bounds and, in range mode, to the\n // adjacent thumbs — this is what stops the two thumbs from crossing.\n function clampForThumb(index, value) {\n let lo = min;\n let hi = max;\n if (isRange) {\n if (index > 0) lo = values[index - 1];\n if (index < last) hi = values[index + 1];\n }\n return Math.min(Math.max(value, lo), hi);\n }\n\n function boundsFor(index) {\n const lo = isRange && index > 0 ? values[index - 1] : min;\n const hi = isRange && index < last ? values[index + 1] : max;\n return { lo, hi };\n }\n\n function textFor(value, index) {\n if (typeof formatter === \"function\") return formatter(value, index);\n if (suffix) return `${value}${suffix}`;\n return null;\n }\n\n function renderThumb(index) {\n const thumb = thumbs[index];\n const value = values[index];\n const { lo, hi } = boundsFor(index);\n thumb.setAttribute(\"aria-valuemin\", String(lo));\n thumb.setAttribute(\"aria-valuemax\", String(hi));\n thumb.setAttribute(\"aria-valuenow\", String(value));\n const text = textFor(value, index);\n if (text != null) thumb.setAttribute(\"aria-valuetext\", text);\n else thumb.removeAttribute(\"aria-valuetext\");\n thumb.style.setProperty(\"--pos\", `${percentOf(value, min, max)}%`);\n }\n\n function renderRange() {\n const startPct = isRange ? percentOf(values[0], min, max) : 0;\n const endPct = percentOf(values[isRange ? last : 0], min, max);\n root.style.setProperty(\"--slider-start\", `${startPct}%`);\n root.style.setProperty(\"--slider-end\", `${endPct}%`);\n }\n\n function render() {\n thumbs.forEach((_, i) => renderThumb(i));\n renderRange();\n }\n\n function emitChange(index) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:change\", {\n bubbles: true,\n detail: { index, value: values[index], values: values.slice() },\n }),\n );\n }\n\n // The single mutation seam: snap → clamp (non-crossing) → render → notify.\n function applyValue(index, rawValue, opts) {\n if (index < 0 || index >= thumbs.length) return;\n const next = clampForThumb(index, snapToStep(rawValue, min, max, step));\n const changed = next !== values[index];\n values[index] = next;\n render();\n if (changed && !(opts && opts.silent)) emitChange(index);\n }\n\n function nearestThumb(value) {\n let best = 0;\n let bestDist = Infinity;\n for (let i = 0; i < values.length; i++) {\n const d = Math.abs(values[i] - value);\n if (d < bestDist) {\n bestDist = d;\n best = i;\n }\n }\n return best;\n }\n\n // ── RTL ──────────────────────────────────────────────────────────────────\n // getComputedStyle is authoritative in a browser; fall back to the dir\n // attribute for detached nodes / happy-dom where computed direction is unset.\n function isRTL() {\n if (root.closest('[dir=\"rtl\"]')) return true;\n if (typeof getComputedStyle === \"function\") {\n try {\n return getComputedStyle(root).direction === \"rtl\";\n } catch {\n /* jsdom/happy-dom on a detached node — ignore */\n }\n }\n return false;\n }\n\n // ── Keyboard ─────────────────────────────────────────────────────────────\n function onKeyDown(e) {\n if (isDisabled()) return;\n const thumb = e.target.closest(\"[data-part='thumb']\");\n if (!thumb || !root.contains(thumb)) return;\n const index = thumbs.indexOf(thumb);\n if (index < 0) return;\n\n const rtl = isRTL();\n const cur = values[index];\n let next;\n switch (e.key) {\n case \"ArrowUp\":\n next = cur + step;\n break;\n case \"ArrowDown\":\n next = cur - step;\n break;\n case \"ArrowRight\":\n next = cur + (rtl ? -step : step);\n break;\n case \"ArrowLeft\":\n next = cur + (rtl ? step : -step);\n break;\n case \"PageUp\":\n next = cur + bigStep;\n break;\n case \"PageDown\":\n next = cur - bigStep;\n break;\n case \"Home\":\n next = min; // clampForThumb pins it to the lower neighbour in range mode\n break;\n case \"End\":\n next = max;\n break;\n default:\n return;\n }\n e.preventDefault();\n applyValue(index, next);\n }\n\n // ── Pointer dragging ─────────────────────────────────────────────────────\n let drag = null; // { index }\n const docHandlers = [];\n\n function beginDrag(index) {\n drag = { index };\n thumbs[index].dataset.state = \"dragging\";\n const move = (ev) => onDragMove(ev);\n const end = () => endDrag();\n document.addEventListener(\"pointermove\", move);\n document.addEventListener(\"pointerup\", end);\n document.addEventListener(\"pointercancel\", end);\n docHandlers.push([\"pointermove\", move], [\"pointerup\", end], [\"pointercancel\", end]);\n }\n\n function onDragMove(ev) {\n if (!drag || !track) return;\n const value = valueFromPointer(ev.clientX, track.getBoundingClientRect(), {\n min,\n max,\n step,\n rtl: isRTL(),\n });\n applyValue(drag.index, value);\n }\n\n function endDrag() {\n if (!drag) return;\n thumbs[drag.index].removeAttribute(\"data-state\");\n for (const [type, fn] of docHandlers) document.removeEventListener(type, fn);\n docHandlers.length = 0;\n drag = null;\n }\n\n function onPointerDown(e) {\n if (isDisabled()) return;\n if (typeof e.button === \"number\" && e.button !== 0) return; // primary button only\n\n const thumb = e.target.closest(\"[data-part='thumb']\");\n if (thumb && root.contains(thumb)) {\n e.preventDefault();\n const index = thumbs.indexOf(thumb);\n thumb.focus();\n beginDrag(index);\n return;\n }\n\n // A press anywhere on the track jumps the nearest thumb to that point and\n // starts dragging it — the standard \"click-to-set\" affordance.\n if (track && (e.target === track || track.contains(e.target))) {\n e.preventDefault();\n const value = valueFromPointer(e.clientX, track.getBoundingClientRect(), {\n min,\n max,\n step,\n rtl: isRTL(),\n });\n const index = nearestThumb(value);\n applyValue(index, value);\n if (thumbs[index]) thumbs[index].focus();\n beginDrag(index);\n }\n }\n\n root.addEventListener(\"keydown\", onKeyDown);\n root.addEventListener(\"pointerdown\", onPointerDown);\n\n // Paint initial positions/ARIA without firing a spurious change event.\n render();\n\n // ── Public API ───────────────────────────────────────────────────────────\n function setValue(index, value) {\n applyValue(index, value);\n }\n function getValue() {\n return isRange ? values.slice() : values[0];\n }\n function getValues() {\n return values.slice();\n }\n function setFormatter(fn) {\n formatter = typeof fn === \"function\" ? fn : null;\n render();\n }\n\n function destroy() {\n root.removeEventListener(\"keydown\", onKeyDown);\n root.removeEventListener(\"pointerdown\", onPointerDown);\n endDrag();\n delete root._faqirSlider;\n }\n\n const api = { setValue, getValue, getValues, setFormatter, destroy };\n root._faqirSlider = api;\n return api;\n}\n\n// ── Pure value math (no DOM) — unit-tested in isolation ──────────────────────\n\n/** Decimal places implied by a step (so 0.1 + 0.2 doesn't leak float dust). */\nfunction stepDecimals(step) {\n const str = String(step);\n const dot = str.indexOf(\".\");\n return dot === -1 ? 0 : str.length - dot - 1;\n}\n\n/**\n * Snap a raw value onto the nearest step from `min`, clamped to `[min, max]`.\n * @returns {number}\n */\nfunction snapToStep(value, min, max, step) {\n const s = step > 0 ? step : 1;\n const steps = Math.round((value - min) / s);\n const snapped = Math.min(Math.max(min + steps * s, min), max);\n return Number(snapped.toFixed(stepDecimals(s)));\n}\n\n/** Value → percent along the track (0–100), clamped. */\nfunction percentOf(value, min, max) {\n if (max === min) return 0;\n const p = ((value - min) / (max - min)) * 100;\n return Math.min(Math.max(p, 0), 100);\n}\n\n/**\n * Map a pointer x-coordinate to a slider value. Pure: no DOM access — the caller\n * supplies the track rect. Handles RTL by inverting the fraction, so the same\n * arithmetic serves both writing directions.\n *\n * @param {number} clientX pointer x in client coordinates\n * @param {{left:number, width:number}} rect track bounding rect\n * @param {{min:number, max:number, step:number, rtl?:boolean}} opts\n * @returns {number} snapped, clamped value\n */\nfunction valueFromPointer(clientX, rect, opts) {\n const { min, max, step } = opts;\n const width = rect.width;\n if (!(width > 0)) return min;\n let fraction = (clientX - rect.left) / width;\n fraction = Math.min(Math.max(fraction, 0), 1);\n if (opts.rtl) fraction = 1 - fraction;\n return snapToStep(min + fraction * (max - min), min, max, step);\n}\n\n// Read a numeric data-* attribute (dataset key), falling back when absent/NaN.\nfunction numAttr(el, key, fallback) {\n const raw = el.dataset[key];\n if (raw == null || raw === \"\") return fallback;\n const n = Number(raw);\n return Number.isFinite(n) ? n : fallback;\n}\n return createSlider;\n })();\n\n // ── table ── (registry/recipes/table/table.js)\n var createTable = controllerRegistry[\"table\"] = (function() {\n// @ui:controller table\n// @ui:provides sort sortBy clearSort selectRow selectAll deselectAll getSelected getSelectedData setFilter setColumnFilter clearFilters toggleGroup toggleRow toggleDetail expandAll collapseAll startEdit commitEdit cancelEdit moveRow moveColumn hideColumn showColumn toggleColumn setColumnWidth exportCsv getData getState setState refresh destroy\n\n/**\n * Advanced data table controller.\n *\n * Everything beyond the base contract (sort / select) is opt-in through data\n * attributes on the root, so a plain table pays for nothing:\n *\n * data-multi-sort shift+click accumulates secondary sorts\n * data-sort-cycle=\"tristate\" third header click restores original order\n * data-selectable[=\"single|multi\"] row click (de)selects; default multi\n * data-editable inline cell editing (dblclick / Enter / F2)\n * data-tree tree table driven by tr[data-level] depths\n * data-groupable group-header rows collapse/expand their section\n * data-reorderable drag rows via [data-part=\"drag-handle\"] (+ arrows)\n * data-col-reorderable drag column headers to rearrange columns\n * data-resizable column resize handles on headers\n * data-sticky-header / data-sticky-footer sticky thead/tfoot in a scroll root\n * data-navigable roving-focus grid keyboard navigation (implied by data-editable)\n * data-responsive=\"stack\" stacked card layout under the container breakpoint\n * data-persist=\"key\" persist sort/filter/width/visibility to localStorage\n * data-locale / data-currency / data-negatives=\"red|parens|both\" Intl formatting\n *\n * Column headers (th) may carry: data-sortable, data-type, data-format,\n * data-align, data-editable, data-readonly, data-pin=\"start|end\",\n * data-hide-below=\"sm|md|lg\", data-key, data-min-width, data-max-width.\n * Cells (td) may carry: data-value (raw), data-sort-value, data-format,\n * data-align, data-editable, data-readonly, data-aggregate=\"sum|avg|min|max|count\",\n * data-col (explicit column for aggregate cells with colspan).\n *\n * Runtime state the controller manages: data-selected, data-collapsed,\n * data-filtered, data-editing, data-dragging, data-drop-target/-pos,\n * data-col-hidden, data-negative, data-stripe, data-resized, aria-sort,\n * aria-expanded, aria-level plus the --table-level / --table-pin-offset /\n * --table-thead-h\n * private custom properties.\n *\n * Events (CustomEvent, bubbling): faqir:sort, faqir:selection-change,\n * faqir:filter, faqir:edit-start, faqir:cell-edit, faqir:edit-cancel,\n * faqir:row-reorder, faqir:col-reorder, faqir:col-resize, faqir:group-toggle,\n * faqir:tree-toggle, faqir:row-expand, faqir:col-visibility.\n */\nfunction createTable(root) {\n // Prevent double-init\n if (root._faqirTable) return root._faqirTable;\n\n const table = root.querySelector(\"[data-part='table']\");\n const thead = root.querySelector(\"[data-part='thead']\");\n const tbody = root.querySelector(\"[data-part='tbody']\");\n const tfoot = root.querySelector(\"[data-part='tfoot']\");\n const headerCheckbox = thead?.querySelector(\"[data-part='checkbox']\");\n\n // ── Options (read once from the root's opt-in attributes) ──\n const opts = {\n multiSort: root.hasAttribute(\"data-multi-sort\"),\n sortCycle: root.getAttribute(\"data-sort-cycle\") || \"toggle\",\n editable: root.hasAttribute(\"data-editable\"),\n tree: root.hasAttribute(\"data-tree\"),\n groupable: root.hasAttribute(\"data-groupable\"),\n reorderable: root.hasAttribute(\"data-reorderable\"),\n colReorderable: root.hasAttribute(\"data-col-reorderable\"),\n resizable: root.hasAttribute(\"data-resizable\"),\n selectable: root.getAttribute(\"data-selectable\"), // null | \"\" | \"single\" | \"multi\"\n navigable: root.hasAttribute(\"data-navigable\") || root.hasAttribute(\"data-editable\"),\n responsive: root.getAttribute(\"data-responsive\") || \"\",\n persistKey: root.getAttribute(\"data-persist\") || \"\",\n locale: root.getAttribute(\"data-locale\") || document.documentElement.lang || undefined,\n currency: root.getAttribute(\"data-currency\") || \"USD\",\n negatives: root.getAttribute(\"data-negatives\") || \"\",\n };\n const accounting = opts.negatives === \"parens\" || opts.negatives === \"both\";\n const isRTL = (root.closest(\"[dir]\")?.getAttribute(\"dir\") || \"\").toLowerCase() === \"rtl\";\n\n // ── Internal state ──\n let sorts = []; // [{ index, dir: \"ascending\"|\"descending\" }]\n let hasSorted = false;\n let globalFilter = \"\";\n const columnFilters = new Map(); // colIndex -> string | (raw, cell, row) => boolean\n let lastSelectedIndex = -1;\n let editing = null; // { cell, row, input, oldText, oldValue, colIndex, type }\n let activeCell = null; // roving-tabindex focus target\n let drag = null; // active pointer drag (rows / columns / resize)\n let suppressClickUntil = 0;\n let muted = false; // silences emit() during setState/expandAll\n let observer = null;\n let observerPaused = 0;\n let refreshQueued = false;\n const timers = new Set();\n const cleanups = [];\n const colTypeCache = new Map();\n const originalIndex = new WeakMap();\n let originSeq = 0;\n\n const collator = new Intl.Collator(opts.locale, { numeric: true, sensitivity: \"base\" });\n\n // ── Tiny helpers ──\n const toggleAttr = (el, name, on) => (on ? el.setAttribute(name, \"\") : el.removeAttribute(name));\n const later = (fn, ms) => {\n const t = setTimeout(() => {\n timers.delete(t);\n fn();\n }, ms);\n timers.add(t);\n return t;\n };\n const on = (target, ev, fn, o) => {\n target.addEventListener(ev, fn, o);\n cleanups.push(() => target.removeEventListener(ev, fn, o));\n };\n\n function emit(type, detail) {\n if (muted) return;\n root.dispatchEvent(new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }));\n }\n function mutedRun(fn) {\n const was = muted;\n muted = true;\n try {\n fn();\n } finally {\n muted = was;\n }\n }\n\n // ── Row / cell access ──\n const rowsIn = (section, part = \"tr\") =>\n section ? [...section.children].filter((r) => r.getAttribute(\"data-part\") === part) : [];\n const bodyRows = () => rowsIn(tbody);\n const groupHeaders = () => rowsIn(tbody, \"group-header\");\n const cellsOf = (row) =>\n [...row.children].filter((c) => {\n const p = c.getAttribute(\"data-part\");\n return p === \"td\" || p === \"th\";\n });\n const detailOf = (row) => {\n const n = row.nextElementSibling;\n return n && n.getAttribute(\"data-part\") === \"detail-row\" ? n : null;\n };\n const isRowVisible = (r) =>\n !r.hasAttribute(\"data-collapsed\") && !r.hasAttribute(\"data-filtered\") && !r.hasAttribute(\"hidden\");\n const visibleBodyRows = () => bodyRows().filter(isRowVisible);\n\n function headerRowEl() {\n const trs = rowsIn(thead).filter((r) =>\n cellsOf(r).some((c) => c.getAttribute(\"data-part\") === \"th\")\n );\n return trs[trs.length - 1] || null; // leaf row of (possibly grouped) headers\n }\n const headerCells = () => (headerRowEl() ? cellsOf(headerRowEl()) : []);\n const columnCount = () => headerCells().length;\n const filterRowEl = () => (thead ? rowsIn(thead, \"filter-row\")[0] || null : null);\n const sortableHeaders = () => headerCells().filter((th) => th.hasAttribute(\"data-sortable\"));\n\n function headerText(i) {\n const th = headerCells()[i];\n if (!th) return \"\";\n const clone = th.cloneNode(true);\n for (const junk of clone.querySelectorAll(\"[data-part='resize-handle'],[data-part='checkbox'],input,button\")) {\n junk.remove();\n }\n return (clone.textContent || \"\").trim();\n }\n\n /** Every row that has one cell per column (skips colspan rows like group headers). */\n function fullWidthRows() {\n const n = columnCount();\n const out = [];\n const fr = filterRowEl();\n if (headerRowEl()) out.push(headerRowEl());\n if (fr) out.push(fr);\n for (const r of [...bodyRows(), ...rowsIn(tfoot)]) out.push(r);\n return out.filter((r) => cellsOf(r).length === n);\n }\n function forEachColumnCell(i, fn) {\n for (const row of fullWidthRows()) {\n const cell = cellsOf(row)[i];\n if (cell) fn(cell, row);\n }\n }\n\n // ── Value parsing ──\n const NBSP = /[\\u00a0\\u202f]/g;\n /** Numeric parse tolerant of currency symbols, thousands separators, and accounting parens. */\n function parseNumeric(str) {\n if (str == null) return NaN;\n let s = String(str).replace(NBSP, \" \").trim();\n if (!s) return NaN;\n let negative = false;\n const paren = s.match(/^\\((.*)\\)$/);\n if (paren) {\n negative = true;\n s = paren[1];\n }\n s = s.replace(/[^0-9.,-]/g, \"\");\n if (!s) return NaN;\n const lastComma = s.lastIndexOf(\",\");\n const lastDot = s.lastIndexOf(\".\");\n if (lastComma >= 0 && lastDot >= 0) {\n // Rightmost separator is the decimal mark; the other groups thousands.\n s = lastComma > lastDot ? s.replace(/\\./g, \"\").replace(\",\", \".\") : s.replace(/,/g, \"\");\n } else if (lastComma >= 0) {\n const parts = s.split(\",\");\n s = parts.length === 2 && parts[1].length >= 1 && parts[1].length <= 2\n ? s.replace(\",\", \".\") // \"0,5\" → decimal comma\n : s.replace(/,/g, \"\"); // \"1,234,567\" → thousands\n } else if ((s.match(/\\./g) || []).length > 1) {\n s = s.replace(/\\./g, \"\"); // \"1.234.567\" → dot-grouped thousands\n }\n const n = parseFloat(s);\n return isNaN(n) ? NaN : negative ? -n : n;\n }\n\n const ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(?:[T ]|$)/;\n /** Timestamp for ISO dates and dd/mm/yyyy (or dd.mm.yyyy) strings; NaN otherwise. */\n function parseDateValue(str) {\n const s = String(str == null ? \"\" : str).trim();\n if (!s) return NaN;\n if (ISO_DATE.test(s)) {\n const t = Date.parse(s.length === 10 ? s + \"T00:00:00Z\" : s);\n return isNaN(t) ? NaN : t;\n }\n const m = s.match(/^(\\d{1,2})[/.](\\d{1,2})[/.](\\d{4})$/);\n if (m) return Date.UTC(+m[3], +m[2] - 1, +m[1]);\n return NaN;\n }\n\n const cellRaw = (cell) =>\n cell.hasAttribute(\"data-value\")\n ? cell.getAttribute(\"data-value\")\n : (cell.textContent || \"\").trim();\n const sortRaw = (cell) =>\n cell.hasAttribute(\"data-sort-value\") ? cell.getAttribute(\"data-sort-value\") : cellRaw(cell);\n\n const NUMERIC_TYPES = { number: 1, currency: 1, percent: 1 };\n const isNumericType = (t) => !!NUMERIC_TYPES[t];\n\n /** Column type: explicit th data-type / data-format, else sniffed from cells. */\n function columnType(i) {\n if (colTypeCache.has(i)) return colTypeCache.get(i);\n let type = \"\";\n const th = headerCells()[i];\n type = th?.getAttribute(\"data-type\") || th?.getAttribute(\"data-format\") || \"\";\n if (!type) {\n let sawAny = false;\n let allNum = true;\n let allDate = true;\n for (const row of bodyRows().slice(0, 25)) {\n const cell = cellsOf(row)[i];\n if (!cell) continue;\n const cf = cell.getAttribute(\"data-format\");\n if (cf) {\n type = cf;\n break;\n }\n const raw = sortRaw(cell);\n if (!raw) continue;\n sawAny = true;\n if (isNaN(parseDateValue(raw))) allDate = false;\n if (isNaN(parseNumeric(raw))) allNum = false;\n if (!allNum && !allDate) break;\n }\n if (!type) type = sawAny && allDate ? \"date\" : sawAny && allNum ? \"number\" : \"text\";\n }\n colTypeCache.set(i, type);\n return type;\n }\n\n // ── Intl formatting ──\n function formatValue(n, fmt) {\n try {\n if (fmt === \"currency\") {\n return new Intl.NumberFormat(opts.locale, {\n style: \"currency\",\n currency: opts.currency,\n currencySign: accounting ? \"accounting\" : \"standard\",\n }).format(n);\n }\n if (fmt === \"percent\") {\n return new Intl.NumberFormat(opts.locale, {\n style: \"percent\",\n maximumFractionDigits: 2,\n }).format(n / 100);\n }\n if (fmt === \"number\") {\n return new Intl.NumberFormat(opts.locale, { maximumFractionDigits: 2 }).format(n);\n }\n } catch {\n /* unknown locale/currency — fall through to raw */\n }\n return String(n);\n }\n\n function applyNegativeFlag(cell) {\n const fmt = cell.getAttribute(\"data-format\");\n if (!fmt || !isNumericType(fmt)) return;\n const n = parseNumeric(cellRaw(cell));\n toggleAttr(cell, \"data-negative\", !isNaN(n) && n < 0);\n }\n\n /** Cells carrying both data-value and data-format render through Intl; text-only cells are never rewritten. */\n function formatCell(cell) {\n if (cell.hasAttribute(\"data-editing\")) return;\n const fmt = cell.getAttribute(\"data-format\");\n if (!fmt) return;\n if (cell.hasAttribute(\"data-value\")) {\n const raw = cell.getAttribute(\"data-value\");\n if (fmt === \"date\") {\n const t = parseDateValue(raw);\n if (!isNaN(t)) cell.textContent = new Date(t).toLocaleDateString(opts.locale);\n } else if (isNumericType(fmt)) {\n const n = parseNumeric(raw);\n if (!isNaN(n)) cell.textContent = formatValue(n, fmt);\n }\n }\n applyNegativeFlag(cell);\n }\n\n function applyFormats() {\n for (const row of [...bodyRows(), ...rowsIn(tfoot)]) {\n for (const cell of cellsOf(row)) formatCell(cell);\n }\n }\n\n // ── Tree helpers ──\n const levelOf = (r) => {\n const v = parseInt(r.getAttribute(\"data-level\") || \"0\", 10);\n return isNaN(v) ? 0 : v;\n };\n /** Descendant data rows of a tree row (detail rows excluded; group headers terminate). */\n function subtreeRows(row) {\n const out = [];\n const lvl = levelOf(row);\n let n = row.nextElementSibling;\n while (n) {\n const p = n.getAttribute(\"data-part\");\n if (p === \"group-header\") break;\n if (p === \"tr\") {\n if (levelOf(n) <= lvl) break;\n out.push(n);\n }\n n = n.nextElementSibling;\n }\n return out;\n }\n const childrenOf = (row) => subtreeRows(row).filter((r) => levelOf(r) === levelOf(row) + 1);\n function parentOf(row) {\n const lvl = levelOf(row);\n if (lvl <= 0) return null;\n let n = row.previousElementSibling;\n while (n) {\n if (n.getAttribute(\"data-part\") === \"tr\" && levelOf(n) < lvl) return n;\n n = n.previousElementSibling;\n }\n return null;\n }\n function ancestorsOf(row) {\n const out = [];\n let p = parentOf(row);\n while (p) {\n out.push(p);\n p = parentOf(p);\n }\n return out;\n }\n const isTreeParent = (row) => opts.tree && childrenOf(row).length > 0;\n\n // ── Group helpers ──\n /** Every tbody row (data + detail) between a group header and the next one. */\n function groupMembers(gh) {\n const out = [];\n let n = gh.nextElementSibling;\n while (n && n.getAttribute(\"data-part\") !== \"group-header\") {\n const p = n.getAttribute(\"data-part\");\n if (p === \"tr\" || p === \"detail-row\") out.push(n);\n n = n.nextElementSibling;\n }\n return out;\n }\n\n // ── MutationObserver (auto-refresh when rows are added/removed externally) ──\n function pauseObserver(fn) {\n observerPaused++;\n try {\n fn();\n } finally {\n observer?.takeRecords();\n observerPaused--;\n }\n }\n function queueRefresh() {\n if (refreshQueued) return;\n refreshQueued = true;\n const raf = typeof requestAnimationFrame === \"function\" ? requestAnimationFrame : (f) => setTimeout(f, 0);\n raf(() => {\n refreshQueued = false;\n if (root._faqirTable) refresh();\n });\n }\n\n // ── Sorting ──\n function compareCells(a, b, type) {\n const ra = a ? sortRaw(a) : \"\";\n const rb = b ? sortRaw(b) : \"\";\n if (ra === rb) return 0;\n if (!ra) return 1; // empties last (flipped by direction like everything else)\n if (!rb) return -1;\n if (type === \"date\") {\n const na = parseDateValue(ra);\n const nb = parseDateValue(rb);\n if (!isNaN(na) && !isNaN(nb)) return na - nb;\n }\n const na = parseNumeric(ra);\n const nb = parseNumeric(rb);\n if (!isNaN(na) && !isNaN(nb) && type !== \"text\") return na - nb;\n return collator.compare(ra, rb);\n }\n\n function rememberOrder() {\n for (const r of bodyRows()) if (!originalIndex.has(r)) originalIndex.set(r, originSeq++);\n }\n\n function rowComparator() {\n if (!sorts.length) {\n return (a, b) => (originalIndex.get(a) || 0) - (originalIndex.get(b) || 0);\n }\n const specs = sorts.map((s) => ({ ...s, type: columnType(s.index) }));\n return (a, b) => {\n for (const s of specs) {\n const v = compareCells(cellsOf(a)[s.index], cellsOf(b)[s.index], s.type);\n if (v) return s.dir === \"ascending\" ? v : -v;\n }\n return (originalIndex.get(a) || 0) - (originalIndex.get(b) || 0);\n };\n }\n\n function buildForest(rows) {\n const forest = [];\n const stack = [];\n for (const row of rows) {\n const node = { row, children: [] };\n const level = levelOf(row);\n while (stack.length && levelOf(stack[stack.length - 1].row) >= level) stack.pop();\n (stack.length ? stack[stack.length - 1].children : forest).push(node);\n stack.push(node);\n }\n return forest;\n }\n function sortForest(forest, cmp) {\n forest.sort((a, b) => cmp(a.row, b.row));\n for (const n of forest) sortForest(n.children, cmp);\n }\n function flattenForest(forest, out) {\n for (const n of forest) {\n out.push(n.row);\n flattenForest(n.children, out);\n }\n return out;\n }\n\n /** tbody structure as segments delimited by group headers. */\n function segments() {\n const segs = [];\n let cur = { header: null, rows: [] };\n for (const child of tbody ? [...tbody.children] : []) {\n const part = child.getAttribute(\"data-part\");\n if (part === \"group-header\") {\n if (cur.header || cur.rows.length) segs.push(cur);\n cur = { header: child, rows: [] };\n } else if (part === \"tr\") {\n cur.rows.push(child);\n }\n }\n if (cur.header || cur.rows.length) segs.push(cur);\n return segs;\n }\n\n function updateSortIndicators() {\n for (const th of sortableHeaders()) {\n th.setAttribute(\"aria-sort\", \"none\");\n th.removeAttribute(\"data-sort-order\");\n }\n sorts.forEach((s, i) => {\n const th = headerCells()[s.index];\n if (th?.hasAttribute(\"data-sortable\")) {\n th.setAttribute(\"aria-sort\", s.dir);\n if (sorts.length > 1) th.setAttribute(\"data-sort-order\", String(i + 1));\n }\n });\n }\n\n function applySorts() {\n if (!tbody || bodyRows().length === 0) return;\n if (!sorts.length && !hasSorted) return; // nothing to do yet\n hasSorted = true;\n rememberOrder();\n updateSortIndicators();\n\n const details = new Map();\n for (const r of bodyRows()) details.set(r, detailOf(r));\n const cmp = rowComparator();\n\n const order = [];\n for (const seg of segments()) {\n if (seg.header) order.push(seg.header);\n let rows;\n if (opts.tree) {\n const forest = buildForest(seg.rows);\n sortForest(forest, cmp);\n rows = flattenForest(forest, []);\n } else {\n rows = seg.rows.slice().sort(cmp);\n }\n for (const r of rows) {\n order.push(r);\n const d = details.get(r);\n if (d) order.push(d);\n }\n }\n const emptyRow = rowsIn(tbody, \"empty\")[0];\n pauseObserver(() => {\n for (const node of order) tbody.appendChild(node);\n if (emptyRow) tbody.appendChild(emptyRow);\n });\n refreshStripes();\n }\n\n /** Legacy API: sort one column with an explicit direction. */\n function sort(columnIndex, direction) {\n if (!tbody || bodyRows().length === 0) return;\n sorts = [{ index: columnIndex, dir: direction }];\n applySorts();\n emit(\"sort\", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });\n scheduleStateSave();\n }\n\n /** Multi-sort API: sortBy([{ column, direction }...]). */\n function sortBy(specs) {\n if (!tbody || bodyRows().length === 0) return;\n sorts = (specs || [])\n .map((s) => ({\n index: s.column != null ? s.column : s.index,\n dir: s.direction || s.dir || \"ascending\",\n }))\n .filter((s) => Number.isInteger(s.index) && s.index >= 0 && s.index < columnCount());\n applySorts();\n emit(\"sort\", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });\n scheduleStateSave();\n }\n\n function clearSort() {\n if (!sorts.length) return;\n sorts = [];\n applySorts();\n emit(\"sort\", { sorts: [] });\n scheduleStateSave();\n }\n\n function handleSortRequest(idx, additive) {\n const existing = sorts.find((s) => s.index === idx);\n let dir = \"ascending\";\n if (existing) {\n if (existing.dir === \"ascending\") dir = \"descending\";\n else dir = opts.sortCycle === \"tristate\" ? null : \"ascending\";\n }\n if (additive && opts.multiSort) {\n if (dir === null) sorts = sorts.filter((s) => s.index !== idx);\n else if (existing) existing.dir = dir;\n else sorts.push({ index: idx, dir });\n } else {\n sorts = dir === null ? [] : [{ index: idx, dir }];\n }\n applySorts();\n emit(\"sort\", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });\n scheduleStateSave();\n }\n\n // ── Selection ──\n function setRowSelected(row, selected) {\n toggleAttr(row, \"data-selected\", selected);\n const checkbox = row.querySelector(\"[data-part='checkbox']\");\n if (checkbox) checkbox.checked = !!selected;\n }\n\n function selectRow(index) {\n const rows = bodyRows();\n if (index < 0 || index >= rows.length) return;\n const row = rows[index];\n setRowSelected(row, !row.hasAttribute(\"data-selected\"));\n lastSelectedIndex = index;\n updateHeaderCheckbox();\n emit(\"selection-change\", { selected: getSelected() });\n }\n\n function selectAll() {\n const filtered = !!globalFilter || columnFilters.size > 0;\n for (const row of bodyRows()) {\n if (filtered && row.hasAttribute(\"data-filtered\")) continue;\n setRowSelected(row, true);\n }\n updateHeaderCheckbox();\n emit(\"selection-change\", { selected: getSelected() });\n }\n\n function deselectAll() {\n for (const row of bodyRows()) setRowSelected(row, false);\n lastSelectedIndex = -1;\n updateHeaderCheckbox();\n emit(\"selection-change\", { selected: getSelected() });\n }\n\n function getSelected() {\n return bodyRows()\n .map((row, index) => ({ row, index }))\n .filter(({ row }) => row.hasAttribute(\"data-selected\"))\n .map(({ index }) => index);\n }\n\n function selectRange(fromIndex, toIndex) {\n const start = Math.min(fromIndex, toIndex);\n const end = Math.max(fromIndex, toIndex);\n const rows = bodyRows();\n for (let i = start; i <= end; i++) {\n if (i >= 0 && i < rows.length && isRowVisible(rows[i])) setRowSelected(rows[i], true);\n }\n updateHeaderCheckbox();\n }\n\n function updateHeaderCheckbox() {\n if (!headerCheckbox) return;\n const rows = visibleBodyRows();\n const selected = rows.filter((r) => r.hasAttribute(\"data-selected\"));\n if (selected.length === 0) {\n headerCheckbox.checked = false;\n headerCheckbox.indeterminate = false;\n } else if (selected.length === rows.length) {\n headerCheckbox.checked = true;\n headerCheckbox.indeterminate = false;\n } else {\n headerCheckbox.checked = false;\n headerCheckbox.indeterminate = true;\n }\n }\n\n // ── Filtering ──\n function matchQuery(cell, query, type) {\n const q = String(query).trim();\n if (!q) return true;\n if (!cell) return false;\n if (isNumericType(type) || type === \"date\") {\n const val = type === \"date\" ? parseDateValue(cellRaw(cell)) : parseNumeric(cellRaw(cell));\n const parseQ = (s) => (type === \"date\" ? parseDateValue(s) : parseNumeric(s));\n const range = q.match(/^(.+?)\\.\\.(.+)$/);\n if (range) {\n const a = parseQ(range[1]);\n const b = parseQ(range[2]);\n return !isNaN(val) && !isNaN(a) && !isNaN(b) && val >= a && val <= b;\n }\n const op = q.match(/^(>=|<=|!=|=|>|<)\\s*(.+)$/);\n if (op) {\n const b = parseQ(op[2]);\n if (isNaN(b) || isNaN(val)) return false;\n switch (op[1]) {\n case \">\": return val > b;\n case \">=\": return val >= b;\n case \"<\": return val < b;\n case \"<=\": return val <= b;\n case \"=\": return val === b;\n case \"!=\": return val !== b;\n }\n }\n }\n return (cell.textContent || \"\").toLowerCase().includes(q.toLowerCase());\n }\n\n function rowMatches(row) {\n const cells = cellsOf(row);\n if (globalFilter) {\n const hay = cells\n .map((c) => (c.textContent || \"\") + \" \" + (c.getAttribute(\"data-value\") || \"\"))\n .join(\" \")\n .toLowerCase();\n if (!hay.includes(globalFilter.toLowerCase())) return false;\n }\n for (const [idx, f] of columnFilters) {\n const cell = cells[idx];\n if (typeof f === \"function\") {\n if (!f(cell ? cellRaw(cell) : \"\", cell, row)) return false;\n } else if (!matchQuery(cell, f, columnType(idx))) {\n return false;\n }\n }\n return true;\n }\n\n function updateEmptyRow(visibleCount) {\n const emptyRow = tbody ? rowsIn(tbody, \"empty\")[0] : null;\n if (emptyRow) toggleAttr(emptyRow, \"hidden\", visibleCount > 0);\n }\n\n function applyFilters() {\n if (!tbody) return;\n const rows = bodyRows();\n const active = !!globalFilter || columnFilters.size > 0;\n const matched = new Set();\n if (active) {\n for (const r of rows) if (rowMatches(r)) matched.add(r);\n if (opts.tree) {\n // A matching row keeps its ancestor path visible.\n for (const r of [...matched]) for (const a of ancestorsOf(r)) matched.add(a);\n }\n }\n let visible = 0;\n for (const r of rows) {\n const show = !active || matched.has(r);\n toggleAttr(r, \"data-filtered\", !show);\n const d = detailOf(r);\n if (d) toggleAttr(d, \"data-filtered\", !show);\n if (show && isRowVisible(r)) visible++;\n }\n for (const gh of groupHeaders()) {\n const any = groupMembers(gh).some(\n (m) => m.getAttribute(\"data-part\") === \"tr\" && !m.hasAttribute(\"data-filtered\")\n );\n toggleAttr(gh, \"data-filtered\", active && !any);\n }\n updateEmptyRow(visible);\n refreshStripes();\n updateHeaderCheckbox();\n computeAggregates();\n emit(\"filter\", { query: globalFilter, visible, total: rows.length });\n scheduleStateSave();\n }\n\n function setFilter(query) {\n globalFilter = String(query == null ? \"\" : query);\n applyFilters();\n }\n function setColumnFilter(colIndex, query) {\n if (query == null || query === \"\") columnFilters.delete(colIndex);\n else columnFilters.set(colIndex, query);\n applyFilters();\n }\n function clearFilters() {\n globalFilter = \"\";\n columnFilters.clear();\n syncFilterInputs();\n applyFilters();\n }\n function syncFilterInputs() {\n const g = root.querySelector(\"[data-part='filter']\");\n if (g && g.value !== globalFilter) g.value = globalFilter;\n const fr = filterRowEl();\n if (!fr) return;\n cellsOf(fr).forEach((cell, i) => {\n const input = cell.querySelector(\"[data-part='filter-input']\");\n if (!input) return;\n const val = columnFilters.get(i);\n input.value = typeof val === \"string\" ? val : \"\";\n });\n }\n\n // ── Collapse / expand (groups, tree, detail rows) ──\n function toggleGroup(ghOrIndex, force) {\n const gh = typeof ghOrIndex === \"number\" ? groupHeaders()[ghOrIndex] : ghOrIndex;\n if (!gh) return;\n const collapsed = gh.getAttribute(\"data-state\") === \"collapsed\";\n const expand = force !== undefined ? !!force : collapsed;\n gh.setAttribute(\"data-state\", expand ? \"expanded\" : \"collapsed\");\n gh.querySelector(\"[data-part='expander']\")?.setAttribute(\"aria-expanded\", String(expand));\n for (const m of groupMembers(gh)) toggleAttr(m, \"data-collapsed\", !expand);\n refreshStripes();\n updateHeaderCheckbox();\n emit(\"group-toggle\", { group: gh, expanded: expand });\n }\n\n function revealChildren(row) {\n for (const c of childrenOf(row)) {\n c.removeAttribute(\"data-collapsed\");\n detailOf(c)?.removeAttribute(\"data-collapsed\");\n if (isTreeParent(c) && c.getAttribute(\"aria-expanded\") !== \"false\") revealChildren(c);\n }\n }\n\n function toggleRow(rowOrIndex, force) {\n const row = typeof rowOrIndex === \"number\" ? bodyRows()[rowOrIndex] : rowOrIndex;\n if (!row || !isTreeParent(row)) return;\n const expanded = row.getAttribute(\"aria-expanded\") !== \"false\";\n const expand = force !== undefined ? !!force : !expanded;\n row.setAttribute(\"aria-expanded\", String(expand));\n row.querySelector(\"[data-part='expander']\")?.setAttribute(\"aria-expanded\", String(expand));\n if (expand) {\n revealChildren(row);\n } else {\n for (const d of subtreeRows(row)) {\n d.setAttribute(\"data-collapsed\", \"\");\n detailOf(d)?.setAttribute(\"data-collapsed\", \"\");\n }\n }\n refreshStripes();\n updateHeaderCheckbox();\n emit(\"tree-toggle\", { row, expanded: expand });\n }\n\n /** Master/detail: show or hide a row's [data-part='detail-row'] via the hidden attribute. */\n function toggleDetail(rowOrIndex, force) {\n const row = typeof rowOrIndex === \"number\" ? bodyRows()[rowOrIndex] : rowOrIndex;\n const detail = row && detailOf(row);\n if (!detail) return;\n const expand = force !== undefined ? !!force : detail.hasAttribute(\"hidden\");\n toggleAttr(detail, \"hidden\", !expand);\n row.querySelector(\"[data-part='row-toggle']\")?.setAttribute(\"aria-expanded\", String(expand));\n emit(\"row-expand\", { row, detail, expanded: expand });\n }\n\n function expandAll() {\n mutedRun(() => {\n for (const gh of groupHeaders()) toggleGroup(gh, true);\n if (opts.tree) for (const r of bodyRows()) if (isTreeParent(r)) toggleRow(r, true);\n });\n refreshStripes();\n }\n function collapseAll() {\n mutedRun(() => {\n for (const gh of groupHeaders()) toggleGroup(gh, false);\n if (opts.tree) for (const r of bodyRows()) if (isTreeParent(r)) toggleRow(r, false);\n });\n refreshStripes();\n }\n\n // ── Aggregates (tfoot, group headers, tree parents) ──\n function writeAggregate(cell, rows, ownIndex) {\n const fn = cell.getAttribute(\"data-aggregate\");\n const col = cell.hasAttribute(\"data-col\")\n ? parseInt(cell.getAttribute(\"data-col\"), 10)\n : ownIndex != null\n ? ownIndex\n : cellsOf(cell.parentElement).indexOf(cell);\n const values = [];\n for (const r of rows) {\n const c = cellsOf(r)[col];\n if (!c) continue;\n const n = parseNumeric(cellRaw(c));\n if (!isNaN(n)) values.push(n);\n }\n let out = null;\n switch (fn) {\n case \"count\": out = rows.length; break;\n case \"sum\": out = values.reduce((a, b) => a + b, 0); break;\n case \"avg\": out = values.length ? values.reduce((a, b) => a + b, 0) / values.length : null; break;\n case \"min\": out = values.length ? Math.min(...values) : null; break;\n case \"max\": out = values.length ? Math.max(...values) : null; break;\n default: return;\n }\n if (out == null) {\n cell.textContent = \"\";\n cell.removeAttribute(\"data-value\");\n return;\n }\n cell.setAttribute(\"data-value\", String(out));\n const fmt =\n fn === \"count\"\n ? cell.getAttribute(\"data-format\")\n : cell.getAttribute(\"data-format\") || headerCells()[col]?.getAttribute(\"data-format\") || \"number\";\n cell.textContent = fmt ? formatValue(out, fmt) : String(out);\n applyNegativeFlag(cell);\n }\n\n function computeAggregates() {\n const visRows = bodyRows().filter((r) => !r.hasAttribute(\"data-filtered\"));\n for (const row of rowsIn(tfoot)) {\n for (const cell of cellsOf(row)) {\n if (cell.hasAttribute(\"data-aggregate\")) writeAggregate(cell, visRows);\n }\n }\n for (const gh of groupHeaders()) {\n const members = groupMembers(gh).filter(\n (r) => r.getAttribute(\"data-part\") === \"tr\" && !r.hasAttribute(\"data-filtered\")\n );\n for (const cell of cellsOf(gh)) {\n if (cell.hasAttribute(\"data-aggregate\")) writeAggregate(cell, members);\n }\n }\n if (opts.tree) {\n for (const row of bodyRows()) {\n const cells = cellsOf(row);\n const aggCells = cells.filter((c) => c.hasAttribute(\"data-aggregate\"));\n if (!aggCells.length) continue;\n const desc = subtreeRows(row).filter((r) => !r.hasAttribute(\"data-filtered\"));\n if (!desc.length) continue; // leaf with a stray data-aggregate: leave authored value\n for (const cell of aggCells) writeAggregate(cell, desc, cells.indexOf(cell));\n }\n }\n }\n\n // ── Striping (JS-managed so hidden rows never break the pattern) ──\n function refreshStripes() {\n if (!(root.getAttribute(\"data-variant\") || \"\").includes(\"striped\")) return;\n let i = 0;\n for (const r of bodyRows()) {\n if (!isRowVisible(r)) {\n r.removeAttribute(\"data-stripe\");\n continue;\n }\n r.setAttribute(\"data-stripe\", i % 2 ? \"even\" : \"odd\");\n i++;\n }\n }\n\n // ── Inline editing ──\n function isCellEditable(cell) {\n if (!cell || cell.getAttribute(\"data-part\") !== \"td\") return false;\n if (cell.hasAttribute(\"data-readonly\")) return false;\n if (cell.hasAttribute(\"data-editable\")) return true;\n if (!opts.editable) return false;\n const row = cell.parentElement;\n if (!row || row.getAttribute(\"data-part\") !== \"tr\" || !tbody?.contains(row)) return false;\n if (cell.querySelector(\"input,button,select,a,textarea\")) return false;\n const idx = cellsOf(row).indexOf(cell);\n const th = headerCells()[idx];\n if (th?.hasAttribute(\"data-readonly\")) return false;\n const marked = headerCells().filter((h) => h.hasAttribute(\"data-editable\"));\n return marked.length ? !!th?.hasAttribute(\"data-editable\") : true;\n }\n\n function cellFormatOf(cell, colIndex) {\n return cell.getAttribute(\"data-format\") || headerCells()[colIndex]?.getAttribute(\"data-format\") || \"\";\n }\n\n function startEdit(a, b) {\n let cell = null;\n if (a instanceof Element) cell = a;\n else {\n const row = bodyRows()[a];\n if (row) cell = cellsOf(row)[b] || null;\n }\n if (!cell || !isCellEditable(cell)) return false;\n if (editing) {\n if (editing.cell === cell) return true;\n if (!commitEdit()) cancelEdit();\n }\n const row = cell.parentElement;\n const colIndex = cellsOf(row).indexOf(cell);\n const type = columnType(colIndex);\n const oldText = (cell.textContent || \"\").trim();\n const oldValue = cell.getAttribute(\"data-value\");\n const input = document.createElement(\"input\");\n input.type = \"text\";\n input.setAttribute(\"data-part\", \"cell-input\");\n if (isNumericType(type)) input.inputMode = \"decimal\";\n input.setAttribute(\"aria-label\", \"Edit \" + (headerText(colIndex) || \"cell\"));\n input.value = oldValue != null ? oldValue : oldText;\n editing = { cell, row, input, oldText, oldValue, colIndex, type };\n cell.setAttribute(\"data-editing\", \"\");\n cell.textContent = \"\";\n cell.appendChild(input);\n input.addEventListener(\"keydown\", onEditorKeydown);\n input.addEventListener(\"blur\", onEditorBlur);\n input.focus();\n try {\n input.select();\n } catch {\n /* select() unsupported in some environments */\n }\n emit(\"edit-start\", { cell, row, rowIndex: bodyRows().indexOf(row), colIndex, value: input.value });\n return true;\n }\n\n function finishEditor(newText, newValue) {\n const { cell, oldValue } = editing;\n const numeric = isNumericType(editing.type) || isNumericType(cellFormatOf(cell, editing.colIndex));\n editing = null;\n cell.removeAttribute(\"data-editing\");\n cell.textContent = newText;\n if (newValue != null && (oldValue != null || numeric)) cell.setAttribute(\"data-value\", newValue);\n applyNegativeFlag(cell);\n }\n\n function commitEdit(focusBack) {\n if (!editing) return false;\n const { cell, row, input, oldText, oldValue, colIndex } = editing;\n const fmt = cellFormatOf(cell, colIndex);\n const numeric = isNumericType(editing.type) || isNumericType(fmt);\n const rawInput = input.value;\n let newValue = null;\n let newText = rawInput.trim();\n if (numeric && newText !== \"\") {\n const n = parseNumeric(rawInput);\n if (isNaN(n)) {\n input.setAttribute(\"data-invalid\", \"\");\n input.focus();\n return false;\n }\n newValue = String(n);\n newText = isNumericType(fmt) ? formatValue(n, fmt) : newText;\n } else if (numeric) {\n newValue = \"\";\n }\n const before = oldValue != null ? oldValue : oldText;\n const after = newValue != null ? newValue : newText;\n finishEditor(newText, newValue);\n computeAggregates();\n if (String(before) !== String(after)) {\n emit(\"cell-edit\", {\n cell,\n row,\n rowIndex: bodyRows().indexOf(row),\n colIndex,\n oldValue: before,\n value: after,\n text: newText,\n });\n }\n if (focusBack && opts.navigable) focusCell(cell);\n return true;\n }\n\n function cancelEdit(focusBack) {\n if (!editing) return false;\n const { cell, row, oldText, oldValue, colIndex } = editing;\n finishEditor(oldText, oldValue);\n formatCell(cell);\n emit(\"edit-cancel\", { cell, row, rowIndex: bodyRows().indexOf(row), colIndex });\n if (focusBack && opts.navigable) focusCell(cell);\n return true;\n }\n\n function nextEditableCell(cell, dir) {\n const row = cell.parentElement;\n const rows = visibleBodyRows();\n let r = rows.indexOf(row);\n if (r < 0) return null;\n let c = cellsOf(row).indexOf(cell) + dir;\n while (r >= 0 && r < rows.length) {\n const cells = cellsOf(rows[r]);\n while (c >= 0 && c < cells.length) {\n if (isCellEditable(cells[c])) return cells[c];\n c += dir;\n }\n r += dir;\n if (r >= 0 && r < rows.length) c = dir > 0 ? 0 : cellsOf(rows[r]).length - 1;\n }\n return null;\n }\n\n function onEditorKeydown(e) {\n if (!editing) return;\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n commitEdit(true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n cancelEdit(true);\n } else if (e.key === \"Tab\") {\n e.preventDefault();\n e.stopPropagation();\n const from = editing.cell;\n if (commitEdit()) {\n const next = nextEditableCell(from, e.shiftKey ? -1 : 1);\n if (next) startEdit(next);\n }\n } else {\n e.target.removeAttribute(\"data-invalid\");\n e.stopPropagation(); // keep grid navigation away from typing\n }\n }\n function onEditorBlur(e) {\n if (!editing || editing.input !== e.target) return;\n if (!commitEdit()) cancelEdit();\n }\n\n // ── Column operations ──\n const remapIndex = (i, from, to) =>\n i === from ? to : from < to ? (i > from && i <= to ? i - 1 : i) : i >= to && i < from ? i + 1 : i;\n\n function moveColumn(from, to) {\n const n = columnCount();\n if (from === to || from < 0 || to < 0 || from >= n || to >= n) return;\n pauseObserver(() => {\n for (const row of fullWidthRows()) {\n const cells = cellsOf(row);\n const cell = cells[from];\n const target = cells[to];\n if (!cell || !target) continue;\n if (from < to) target.after(cell);\n else target.before(cell);\n }\n });\n sorts = sorts.map((s) => ({ ...s, index: remapIndex(s.index, from, to) }));\n const remapped = new Map();\n for (const [i, f] of columnFilters) remapped.set(remapIndex(i, from, to), f);\n columnFilters.clear();\n for (const [i, f] of remapped) columnFilters.set(i, f);\n colTypeCache.clear();\n refreshPins();\n emit(\"col-reorder\", { from, to });\n scheduleStateSave();\n }\n\n function setColumnHidden(i, hidden) {\n const th = headerCells()[i];\n if (!th) return;\n forEachColumnCell(i, (cell) => toggleAttr(cell, \"data-col-hidden\", hidden));\n refreshPins();\n emit(\"col-visibility\", { column: i, hidden: !!hidden });\n scheduleStateSave();\n }\n const hideColumn = (i) => setColumnHidden(i, true);\n const showColumn = (i) => setColumnHidden(i, false);\n function toggleColumn(i, force) {\n const th = headerCells()[i];\n if (!th) return;\n const hidden = th.hasAttribute(\"data-col-hidden\");\n setColumnHidden(i, force !== undefined ? !force : !hidden);\n }\n\n function columnBounds(th) {\n const min = parseFloat(th.getAttribute(\"data-min-width\")) || 40;\n const max = parseFloat(th.getAttribute(\"data-max-width\")) || Infinity;\n return { min, max };\n }\n\n function setColumnWidth(i, width) {\n const th = headerCells()[i];\n if (!th) return;\n const { min, max } = columnBounds(th);\n const w = Math.max(min, Math.min(max, width));\n th.style.width = w + \"px\";\n root.setAttribute(\"data-resized\", \"\");\n refreshPins();\n emit(\"col-resize\", { column: i, width: w });\n scheduleStateSave();\n }\n\n // ── Pinned (sticky) columns ──\n const widthOf = (th) => th.offsetWidth || parseFloat(th.style.width) || 0;\n\n function refreshPins() {\n const hcs = headerCells();\n const startPins = [];\n const endPins = [];\n hcs.forEach((th, i) => {\n if (th.hasAttribute(\"data-col-hidden\")) return;\n const p = th.getAttribute(\"data-pin\");\n if (p === \"start\") startPins.push(i);\n else if (p === \"end\") endPins.push(i);\n });\n if (!startPins.length && !endPins.length) return;\n const setPin = (i, side, offset, isEdge) => {\n forEachColumnCell(i, (cell) => {\n cell.setAttribute(\"data-pin\", side);\n cell.style.setProperty(\"--table-pin-offset\", offset + \"px\");\n toggleAttr(cell, \"data-pin-edge\", isEdge);\n });\n };\n let acc = 0;\n startPins.forEach((i, k) => {\n setPin(i, \"start\", acc, k === startPins.length - 1);\n acc += widthOf(hcs[i]);\n });\n acc = 0;\n [...endPins].reverse().forEach((i, k) => {\n setPin(i, \"end\", acc, k === endPins.length - 1);\n acc += widthOf(hcs[i]);\n });\n }\n\n // ── Row moving (API + drag & drop) ──\n /** The DOM block a data row drags with: the row, its detail row, and (tree) its subtree. */\n function rowBlock(row) {\n const block = [row];\n const d = detailOf(row);\n if (d) block.push(d);\n if (opts.tree) {\n for (const sub of subtreeRows(row)) {\n block.push(sub);\n const sd = detailOf(sub);\n if (sd) block.push(sd);\n }\n }\n return block;\n }\n\n function performRowMove(row, targetRow, pos) {\n if (!row || !targetRow || row === targetRow) return false;\n const block = rowBlock(row);\n if (block.includes(targetRow)) return false;\n if (opts.tree && parentOf(targetRow) !== parentOf(row)) return false; // siblings only\n const anchor =\n pos === \"after\" ? rowBlock(targetRow)[rowBlock(targetRow).length - 1].nextElementSibling : targetRow;\n pauseObserver(() => {\n for (const node of block) tbody.insertBefore(node, anchor);\n });\n refreshStripes();\n computeAggregates();\n return true;\n }\n\n function moveRow(from, to) {\n const rows = bodyRows();\n if (from === to || from < 0 || to < 0 || from >= rows.length || to >= rows.length) return false;\n const moved = performRowMove(rows[from], rows[to], from < to ? \"after\" : \"before\");\n if (moved) emit(\"row-reorder\", { from, to, row: rows[from] });\n return moved;\n }\n\n // ── Drag & drop (rows, columns, resize) — pointer-based ──\n function clearDropMarkers() {\n for (const el of root.querySelectorAll(\"[data-drop-target]\")) {\n el.removeAttribute(\"data-drop-target\");\n el.removeAttribute(\"data-drop-pos\");\n }\n }\n\n function elementAt(e) {\n if (document.elementFromPoint) {\n try {\n return document.elementFromPoint(e.clientX, e.clientY);\n } catch {\n return null;\n }\n }\n return null;\n }\n\n function resolveRowAt(e) {\n let row = elementAt(e)?.closest?.(\"[data-part='tr']\");\n if (!row) row = e.target?.closest?.(\"[data-part='tr']\");\n return row && tbody?.contains(row) ? row : null;\n }\n\n function dropPos(e, el) {\n const rect = el.getBoundingClientRect?.();\n if (!rect || !rect.height) return \"after\";\n return e.clientY < rect.top + rect.height / 2 ? \"before\" : \"after\";\n }\n function dropPosX(e, el) {\n const rect = el.getBoundingClientRect?.();\n if (!rect || !rect.width) return \"after\";\n const before = e.clientX < rect.left + rect.width / 2;\n return before !== isRTL ? \"before\" : \"after\";\n }\n\n function bindDocDrag() {\n document.addEventListener(\"pointermove\", onDocPointerMove);\n document.addEventListener(\"pointerup\", onDocPointerUp);\n document.addEventListener(\"keydown\", onDragKeydown, true);\n }\n function unbindDocDrag() {\n document.removeEventListener(\"pointermove\", onDocPointerMove);\n document.removeEventListener(\"pointerup\", onDocPointerUp);\n document.removeEventListener(\"keydown\", onDragKeydown, true);\n }\n cleanups.push(unbindDocDrag);\n\n function cancelDrag() {\n if (!drag) return;\n if (drag.kind === \"row\") drag.row.removeAttribute(\"data-dragging\");\n if (drag.kind === \"col\") drag.th.removeAttribute(\"data-dragging\");\n clearDropMarkers();\n drag = null;\n unbindDocDrag();\n }\n function onDragKeydown(e) {\n if (e.key === \"Escape\") cancelDrag();\n }\n\n function onPointerDown(e) {\n if (e.button !== undefined && e.button !== 0) return;\n const handle = e.target.closest(\"[data-part='drag-handle']\");\n if (handle && opts.reorderable) {\n const row = handle.closest(\"[data-part='tr']\");\n if (row && tbody?.contains(row)) {\n drag = { kind: \"row\", row, startY: e.clientY || 0, active: false };\n bindDocDrag();\n e.preventDefault();\n }\n return;\n }\n const rh = e.target.closest(\"[data-part='resize-handle']\");\n if (rh && opts.resizable) {\n const th = rh.closest(\"[data-part='th']\");\n const idx = headerCells().indexOf(th);\n if (idx >= 0) {\n drag = { kind: \"resize\", th, index: idx, startX: e.clientX || 0, startW: widthOf(th) };\n bindDocDrag();\n e.preventDefault();\n }\n return;\n }\n if (opts.colReorderable) {\n const th = e.target.closest(\"[data-part='th']\");\n if (\n th &&\n headerRowEl()?.contains(th) &&\n !e.target.closest(\"input,button,select,textarea,[data-part='resize-handle']\")\n ) {\n drag = { kind: \"col\", th, startX: e.clientX || 0, active: false };\n bindDocDrag();\n // no preventDefault: a motionless press must still become a sort click\n }\n }\n }\n\n function onDocPointerMove(e) {\n if (!drag) return;\n if (drag.kind === \"resize\") {\n const dx = ((e.clientX || 0) - drag.startX) * (isRTL ? -1 : 1);\n const { min, max } = columnBounds(drag.th);\n const w = Math.max(min, Math.min(max, drag.startW + dx));\n drag.th.style.width = w + \"px\";\n drag.width = w;\n root.setAttribute(\"data-resized\", \"\");\n return;\n }\n if (drag.kind === \"row\") {\n if (!drag.active && Math.abs((e.clientY || 0) - drag.startY) > 3) {\n drag.active = true;\n drag.row.setAttribute(\"data-dragging\", \"\");\n }\n if (!drag.active) return;\n clearDropMarkers();\n const target = resolveRowAt(e);\n if (!target || target === drag.row || rowBlock(drag.row).includes(target)) return;\n if (opts.tree && parentOf(target) !== parentOf(drag.row)) return; // siblings only\n target.setAttribute(\"data-drop-target\", \"\");\n target.setAttribute(\"data-drop-pos\", dropPos(e, target));\n return;\n }\n if (drag.kind === \"col\") {\n if (!drag.active && Math.abs((e.clientX || 0) - drag.startX) > 4) {\n drag.active = true;\n drag.th.setAttribute(\"data-dragging\", \"\");\n }\n if (!drag.active) return;\n clearDropMarkers();\n let th = elementAt(e)?.closest?.(\"[data-part='th']\");\n if (!th) th = e.target?.closest?.(\"[data-part='th']\");\n if (!th || th === drag.th || !headerRowEl()?.contains(th)) return;\n th.setAttribute(\"data-drop-target\", \"\");\n th.setAttribute(\"data-drop-pos\", dropPosX(e, th));\n }\n }\n\n function onDocPointerUp() {\n if (!drag) return;\n const d = drag;\n drag = null;\n unbindDocDrag();\n if (d.kind === \"resize\") {\n if (d.width != null) {\n refreshPins();\n emit(\"col-resize\", { column: d.index, width: d.width });\n scheduleStateSave();\n }\n return;\n }\n if (d.kind === \"row\") {\n const target = root.querySelector(\"[data-part='tr'][data-drop-target]\");\n d.row.removeAttribute(\"data-dragging\");\n if (d.active) suppressClickUntil = Date.now() + 100;\n if (target) {\n const pos = target.getAttribute(\"data-drop-pos\") || \"after\";\n const rows = bodyRows();\n const from = rows.indexOf(d.row);\n clearDropMarkers();\n if (performRowMove(d.row, target, pos)) {\n emit(\"row-reorder\", { from, to: bodyRows().indexOf(d.row), row: d.row });\n }\n }\n clearDropMarkers();\n return;\n }\n if (d.kind === \"col\") {\n const target = thead?.querySelector(\"[data-part='th'][data-drop-target]\");\n d.th.removeAttribute(\"data-dragging\");\n if (d.active) suppressClickUntil = Date.now() + 100;\n if (target) {\n const pos = target.getAttribute(\"data-drop-pos\") || \"after\";\n const hcs = headerCells();\n const from = hcs.indexOf(d.th);\n let to = hcs.indexOf(target);\n if (pos === \"after\" && from > to) to += 1;\n if (pos === \"before\" && from < to) to -= 1;\n clearDropMarkers();\n moveColumn(from, to);\n }\n clearDropMarkers();\n }\n }\n\n // ── CSV export / data extraction ──\n function csvColumns(includeHidden) {\n const cols = [];\n headerCells().forEach((th, i) => {\n if (!includeHidden && th.hasAttribute(\"data-col-hidden\")) return;\n if (th.hasAttribute(\"data-csv-skip\")) return;\n if (th.querySelector(\"[data-part='checkbox']\")) return;\n cols.push(i);\n });\n return cols;\n }\n\n function exportCsv(o = {}) {\n const all = o.all === true;\n const sep = o.separator || \",\";\n const cols = csvColumns(all);\n const esc = (s) => {\n s = String(s == null ? \"\" : s);\n return /[\",;\\n]/.test(s) || s.includes(sep) ? '\"' + s.replace(/\"/g, '\"\"') + '\"' : s;\n };\n const lines = [cols.map((i) => esc(headerText(i))).join(sep)];\n for (const row of bodyRows()) {\n if (!all && row.hasAttribute(\"data-filtered\")) continue;\n const cells = cellsOf(row);\n lines.push(\n cols\n .map((i) => {\n const c = cells[i];\n return esc(c ? cellRaw(c) : \"\");\n })\n .join(sep)\n );\n }\n const csv = lines.join(\"\\n\");\n if (o.filename && typeof Blob !== \"undefined\" && typeof URL !== \"undefined\" && URL.createObjectURL) {\n try {\n const blob = new Blob([\"\\ufeff\" + csv], { type: \"text/csv;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = o.filename;\n a.click();\n URL.revokeObjectURL(url);\n } catch {\n /* download unavailable (headless) — the string is still returned */\n }\n }\n return csv;\n }\n\n function rowData(row) {\n const cells = cellsOf(row);\n const out = {};\n headerCells().forEach((th, i) => {\n if (th.querySelector(\"[data-part='checkbox']\")) return;\n const key = th.getAttribute(\"data-key\") || headerText(i) || \"col\" + i;\n const c = cells[i];\n out[key] = c ? cellRaw(c) : \"\";\n });\n if (row.hasAttribute(\"data-row-id\")) out._id = row.getAttribute(\"data-row-id\");\n return out;\n }\n const getData = (o = {}) =>\n bodyRows()\n .filter((r) => o.all === true || !r.hasAttribute(\"data-filtered\"))\n .map(rowData);\n const getSelectedData = () => bodyRows().filter((r) => r.hasAttribute(\"data-selected\")).map(rowData);\n\n // ── State persistence ──\n function getState() {\n return {\n sorts: sorts.map((s) => ({ ...s })),\n filter: globalFilter,\n columnFilters: [...columnFilters].filter(([, v]) => typeof v === \"string\"),\n widths: headerCells().map((th) => th.style.width || null),\n hidden: headerCells().map((th) => th.hasAttribute(\"data-col-hidden\")),\n };\n }\n\n function setState(state) {\n if (!state || typeof state !== \"object\") return;\n mutedRun(() => {\n if (Array.isArray(state.widths)) {\n state.widths.forEach((w, i) => {\n if (w) setColumnWidth(i, parseFloat(w));\n });\n }\n if (Array.isArray(state.hidden)) {\n state.hidden.forEach((h, i) => setColumnHidden(i, !!h));\n }\n let filterDirty = false;\n if (Array.isArray(state.columnFilters)) {\n columnFilters.clear();\n for (const [i, v] of state.columnFilters) {\n if (typeof v === \"string\" && v) columnFilters.set(+i, v);\n }\n filterDirty = true;\n }\n if (typeof state.filter === \"string\") {\n globalFilter = state.filter;\n filterDirty = true;\n }\n if (filterDirty) {\n syncFilterInputs();\n applyFilters();\n }\n if (Array.isArray(state.sorts) && state.sorts.length) {\n sorts = state.sorts\n .map((s) => ({ index: s.index != null ? s.index : s.column, dir: s.dir || s.direction || \"ascending\" }))\n .filter((s) => Number.isInteger(s.index) && s.index >= 0 && s.index < columnCount());\n applySorts();\n }\n });\n }\n\n let saveTimer = null;\n function scheduleStateSave() {\n if (!opts.persistKey || muted) return;\n clearTimeout(saveTimer);\n saveTimer = later(() => {\n try {\n localStorage.setItem(\"faqir-table:\" + opts.persistKey, JSON.stringify(getState()));\n } catch {\n /* storage unavailable */\n }\n }, 150);\n }\n function restoreState() {\n if (!opts.persistKey) return;\n try {\n const raw = localStorage.getItem(\"faqir-table:\" + opts.persistKey);\n if (raw) setState(JSON.parse(raw));\n } catch {\n /* corrupt state is discarded */\n }\n }\n\n // ── Structural setup (run at init and on refresh) ──\n function mirrorColumnAttrs() {\n const hcs = headerCells();\n const n = hcs.length;\n if (!n) return;\n for (const row of [...bodyRows(), ...rowsIn(tfoot)]) {\n const cells = cellsOf(row);\n if (cells.length !== n) continue;\n hcs.forEach((th, i) => {\n for (const attr of [\"data-align\", \"data-format\", \"data-hide-below\"]) {\n const v = th.getAttribute(attr);\n if (v && !cells[i].hasAttribute(attr)) cells[i].setAttribute(attr, v);\n }\n });\n }\n }\n\n function treeCellOf(row) {\n return (\n cellsOf(row).find(\n (c) => !c.querySelector(\"[data-part='checkbox'],[data-part='drag-handle']\")\n ) || cellsOf(row)[0]\n );\n }\n\n function injectExpander(cell, isParent) {\n let existing = cell.querySelector(\"[data-part='expander']\");\n if (existing) {\n // A leaf placeholder must become a real button when the row gains children (and vice versa).\n const isButton = existing.tagName === \"BUTTON\";\n if (isParent === isButton) return existing;\n existing.remove();\n existing = null;\n }\n let el;\n if (isParent) {\n el = document.createElement(\"button\");\n el.type = \"button\";\n el.setAttribute(\"data-part\", \"expander\");\n el.setAttribute(\"aria-label\", \"Toggle\");\n } else {\n el = document.createElement(\"span\");\n el.setAttribute(\"data-part\", \"expander\");\n el.setAttribute(\"data-leaf\", \"\");\n el.setAttribute(\"aria-hidden\", \"true\");\n }\n cell.insertBefore(el, cell.firstChild);\n return el;\n }\n\n function setupTree() {\n if (!opts.tree || !tbody) return;\n table?.setAttribute(\"role\", \"treegrid\");\n for (const row of bodyRows()) {\n const level = levelOf(row);\n row.setAttribute(\"aria-level\", String(level + 1));\n const cell = treeCellOf(row);\n if (!cell) continue;\n cell.setAttribute(\"data-tree-cell\", \"\");\n cell.style.setProperty(\"--table-level\", String(level));\n const parent = isTreeParent(row);\n const expander = injectExpander(cell, parent);\n if (parent) {\n if (!row.hasAttribute(\"aria-expanded\")) row.setAttribute(\"aria-expanded\", \"true\");\n expander.setAttribute(\"aria-expanded\", row.getAttribute(\"aria-expanded\"));\n if (row.getAttribute(\"aria-expanded\") === \"false\") {\n for (const d of subtreeRows(row)) {\n d.setAttribute(\"data-collapsed\", \"\");\n detailOf(d)?.setAttribute(\"data-collapsed\", \"\");\n }\n }\n } else {\n row.removeAttribute(\"aria-expanded\");\n }\n }\n }\n\n function setupGroups() {\n if (!opts.groupable || !tbody) return;\n for (const gh of groupHeaders()) {\n const cell = cellsOf(gh)[0];\n if (!cell) continue;\n const expander = injectExpander(cell, true);\n if (!gh.hasAttribute(\"data-state\")) gh.setAttribute(\"data-state\", \"expanded\");\n const expanded = gh.getAttribute(\"data-state\") !== \"collapsed\";\n expander.setAttribute(\"aria-expanded\", String(expanded));\n if (!expanded) for (const m of groupMembers(gh)) m.setAttribute(\"data-collapsed\", \"\");\n }\n }\n\n function setupDetails() {\n if (!tbody) return;\n for (const row of bodyRows()) {\n const toggle = row.querySelector(\"[data-part='row-toggle']\");\n const detail = detailOf(row);\n if (!toggle || !detail) continue;\n if (toggle.getAttribute(\"aria-expanded\") === \"false\") detail.setAttribute(\"hidden\", \"\");\n else toggle.setAttribute(\"aria-expanded\", String(!detail.hasAttribute(\"hidden\")));\n }\n }\n\n function setupLabels() {\n if (opts.responsive !== \"stack\") return;\n const n = columnCount();\n for (const row of [...bodyRows(), ...rowsIn(tfoot)]) {\n const cells = cellsOf(row);\n if (cells.length !== n) continue;\n cells.forEach((cell, i) => {\n if (!cell.hasAttribute(\"data-label\")) cell.setAttribute(\"data-label\", headerText(i));\n });\n }\n }\n\n function injectResizeHandles() {\n if (!opts.resizable) return;\n headerCells().forEach((th) => {\n if (th.hasAttribute(\"data-no-resize\")) return;\n if (th.querySelector(\"[data-part='resize-handle']\")) return;\n const handle = document.createElement(\"span\");\n handle.setAttribute(\"data-part\", \"resize-handle\");\n handle.setAttribute(\"aria-hidden\", \"true\");\n th.appendChild(handle);\n });\n }\n\n // ── Keyboard navigation (roving tabindex grid) ──\n function navMatrix() {\n const rows = [];\n const hr = headerRowEl();\n if (hr) rows.push(hr);\n for (const child of tbody ? [...tbody.children] : []) {\n const p = child.getAttribute(\"data-part\");\n if ((p === \"tr\" || p === \"group-header\") && isRowVisible(child)) rows.push(child);\n }\n for (const r of rowsIn(tfoot)) rows.push(r);\n return rows;\n }\n\n function setupNavigability() {\n if (opts.navigable) {\n let first = null;\n for (const row of navMatrix()) {\n for (const cell of cellsOf(row)) {\n if (cell.hasAttribute(\"data-col-hidden\")) continue;\n if (!first && !activeCell) first = cell;\n cell.setAttribute(\"tabindex\", cell === (activeCell || first) ? \"0\" : \"-1\");\n }\n }\n if (!activeCell) activeCell = first;\n } else {\n // Sortable headers must stay keyboard-operable even without grid navigation.\n for (const th of sortableHeaders()) th.setAttribute(\"tabindex\", \"0\");\n }\n }\n\n function focusCell(cell) {\n if (!cell) return;\n if (activeCell && activeCell !== cell) activeCell.setAttribute(\"tabindex\", \"-1\");\n activeCell = cell;\n cell.setAttribute(\"tabindex\", \"0\");\n try {\n cell.focus();\n } catch {\n /* unfocusable */\n }\n }\n\n function moveFocus(rowDelta, colDelta, edge) {\n const cell = activeCell;\n if (!cell) return;\n const row = cell.parentElement;\n const rows = navMatrix();\n let r = rows.indexOf(row);\n if (r < 0) return;\n let cells = cellsOf(row);\n let c = cells.indexOf(cell);\n if (edge === \"rowStart\") c = 0;\n else if (edge === \"rowEnd\") c = cells.length - 1;\n else if (edge === \"gridStart\") {\n r = 0;\n c = 0;\n } else if (edge === \"gridEnd\") {\n r = rows.length - 1;\n c = cellsOf(rows[r]).length - 1;\n } else {\n r = Math.max(0, Math.min(rows.length - 1, r + rowDelta));\n cells = cellsOf(rows[r]);\n c = Math.max(0, Math.min(cells.length - 1, c + colDelta));\n }\n cells = cellsOf(rows[r]);\n let target = cells[Math.min(c, cells.length - 1)];\n // Skip hidden columns in the direction of travel.\n let guard = cells.length;\n while (target && target.hasAttribute(\"data-col-hidden\") && guard--) {\n const i = cells.indexOf(target) + (colDelta < 0 ? -1 : 1);\n target = cells[i];\n }\n if (target) focusCell(target);\n }\n\n function onFocusIn(e) {\n if (!opts.navigable) return;\n const cell = e.target.closest(\"[data-part='td'],[data-part='th']\");\n if (!cell || cell === activeCell || !root.contains(cell)) return;\n if (e.target !== cell) return; // focus landed on inner control, not the cell\n if (activeCell) activeCell.setAttribute(\"tabindex\", \"-1\");\n activeCell = cell;\n cell.setAttribute(\"tabindex\", \"0\");\n }\n\n // ── Event handlers ──\n function onHeaderClick(e) {\n if (Date.now() < suppressClickUntil) return;\n if (e.target.closest(\"[data-part='resize-handle'],[data-part='checkbox'],[data-part='filter-input'],input,button,select,textarea\")) {\n return;\n }\n const th = e.target.closest(\"[data-part='th'][data-sortable]\");\n if (!th) return;\n const columnIndex = headerCells().indexOf(th);\n if (columnIndex < 0) return;\n handleSortRequest(columnIndex, e.shiftKey);\n }\n\n function onHeaderCheckboxChange() {\n if (headerCheckbox.checked) selectAll();\n else deselectAll();\n }\n\n function onRowCheckboxChange(e) {\n const checkbox = e.target.closest(\"[data-part='checkbox']\");\n if (!checkbox || checkbox === headerCheckbox) return;\n const row = checkbox.closest(\"[data-part='tr']\");\n if (!row || !tbody?.contains(row)) return;\n const rows = bodyRows();\n const index = rows.indexOf(row);\n if (index < 0) return;\n if (e.shiftKey && lastSelectedIndex >= 0) {\n e.preventDefault();\n selectRange(lastSelectedIndex, index);\n emit(\"selection-change\", { selected: getSelected() });\n return;\n }\n toggleAttr(row, \"data-selected\", checkbox.checked);\n lastSelectedIndex = index;\n updateHeaderCheckbox();\n emit(\"selection-change\", { selected: getSelected() });\n }\n\n function onRootClick(e) {\n if (Date.now() < suppressClickUntil) return;\n const expander = e.target.closest(\"[data-part='expander']\");\n if (expander && !expander.hasAttribute(\"data-leaf\") && root.contains(expander)) {\n const gh = expander.closest(\"[data-part='group-header']\");\n if (gh && tbody?.contains(gh)) {\n toggleGroup(gh);\n return;\n }\n const treeRow = expander.closest(\"[data-part='tr']\");\n if (treeRow && tbody?.contains(treeRow)) {\n toggleRow(treeRow);\n return;\n }\n }\n const rowToggle = e.target.closest(\"[data-part='row-toggle']\");\n if (rowToggle && root.contains(rowToggle)) {\n const r = rowToggle.closest(\"[data-part='tr']\");\n if (r && tbody?.contains(r)) toggleDetail(r);\n return;\n }\n if (opts.groupable) {\n const gh = e.target.closest(\"[data-part='group-header']\");\n if (gh && tbody?.contains(gh) && !e.target.closest(\"a,button,input,select,textarea\")) {\n toggleGroup(gh);\n return;\n }\n }\n if (e.target.closest(\"[data-part='checkbox']\")) return;\n const row = e.target.closest(\"[data-part='tr']\");\n if (!row || !tbody?.contains(row)) return;\n if (e.target.closest(\"a,button,input,select,textarea\") || editing) return;\n const rows = bodyRows();\n const index = rows.indexOf(row);\n if (index < 0) return;\n if (e.shiftKey && lastSelectedIndex >= 0) {\n selectRange(lastSelectedIndex, index);\n emit(\"selection-change\", { selected: getSelected() });\n return;\n }\n if (opts.selectable != null) {\n if (opts.selectable === \"single\") {\n const wasSelected = row.hasAttribute(\"data-selected\");\n for (const r of rows) setRowSelected(r, false);\n setRowSelected(row, !wasSelected);\n } else {\n setRowSelected(row, !row.hasAttribute(\"data-selected\"));\n }\n lastSelectedIndex = index;\n updateHeaderCheckbox();\n emit(\"selection-change\", { selected: getSelected() });\n }\n }\n\n function onDblClick(e) {\n const cell = e.target.closest(\"[data-part='td']\");\n if (cell && tbody?.contains(cell) && isCellEditable(cell)) startEdit(cell);\n }\n\n const filterTimers = new Map();\n function onFilterInput(e) {\n const t = e.target;\n if (!t || !t.matches) return;\n if (t.matches(\"[data-part='filter']\")) {\n clearTimeout(filterTimers.get(\"global\"));\n filterTimers.set(\n \"global\",\n later(() => setFilter(t.value), 120)\n );\n return;\n }\n if (t.matches(\"[data-part='filter-input']\")) {\n const fr = filterRowEl();\n const cell = t.closest(\"[data-part='td'],[data-part='th']\");\n if (!fr || !cell) return;\n const col = cellsOf(fr).indexOf(cell);\n if (col < 0) return;\n clearTimeout(filterTimers.get(col));\n filterTimers.set(\n col,\n later(() => setColumnFilter(col, t.value), 120)\n );\n }\n }\n\n function onKeydown(e) {\n if (editing) return; // the editor's own keydown handler owns these keys\n const target = e.target;\n\n // Drag handle: arrow keys move the row among its siblings (subtrees stay attached).\n const handle = target.closest?.(\"[data-part='drag-handle']\");\n if (handle && opts.reorderable && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n const row = handle.closest(\"[data-part='tr']\");\n if (row && tbody?.contains(row)) {\n e.preventDefault();\n const down = e.key === \"ArrowDown\";\n const siblings = opts.tree\n ? bodyRows().filter((r) => parentOf(r) === parentOf(row))\n : bodyRows();\n const sibling = siblings[siblings.indexOf(row) + (down ? 1 : -1)];\n if (sibling) {\n const from = bodyRows().indexOf(row);\n if (performRowMove(row, sibling, down ? \"after\" : \"before\")) {\n emit(\"row-reorder\", { from, to: bodyRows().indexOf(row), row });\n }\n }\n }\n return;\n }\n\n // Never hijack typing or native control activation (buttons own Enter/Space via click).\n if (target.closest?.(\"input,select,textarea,button,a\")) return;\n\n const cell = target.closest?.(\"[data-part='td'],[data-part='th']\");\n const inHeader = cell && thead?.contains(cell);\n\n // Sortable header keyboard activation.\n if (inHeader && (e.key === \"Enter\" || e.key === \" \") && cell.hasAttribute(\"data-sortable\")) {\n e.preventDefault();\n const idx = headerCells().indexOf(cell);\n if (idx >= 0) handleSortRequest(idx, e.shiftKey);\n return;\n }\n\n // Header column ops (navigable focus on th).\n if (inHeader && e.altKey && (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\")) {\n if (opts.colReorderable) {\n e.preventDefault();\n const idx = headerCells().indexOf(cell);\n const delta = (e.key === \"ArrowRight\") !== isRTL ? 1 : -1;\n moveColumn(idx, idx + delta);\n return;\n }\n }\n if (inHeader && e.ctrlKey && e.shiftKey && (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\")) {\n if (opts.resizable) {\n e.preventDefault();\n const idx = headerCells().indexOf(cell);\n const delta = (e.key === \"ArrowRight\") !== isRTL ? 16 : -16;\n setColumnWidth(idx, widthOf(cell) + delta);\n return;\n }\n }\n\n if (!opts.navigable || !cell || !root.contains(cell)) return;\n\n // Select-all.\n if ((e.ctrlKey || e.metaKey) && (e.key === \"a\" || e.key === \"A\")) {\n if (opts.selectable != null || headerCheckbox) {\n e.preventDefault();\n selectAll();\n }\n return;\n }\n\n switch (e.key) {\n case \"ArrowUp\":\n e.preventDefault();\n moveFocus(-1, 0);\n return;\n case \"ArrowDown\":\n e.preventDefault();\n moveFocus(1, 0);\n return;\n case \"ArrowLeft\":\n e.preventDefault();\n moveFocus(0, isRTL ? 1 : -1);\n return;\n case \"ArrowRight\":\n e.preventDefault();\n moveFocus(0, isRTL ? -1 : 1);\n return;\n case \"Home\":\n e.preventDefault();\n moveFocus(0, 0, e.ctrlKey ? \"gridStart\" : \"rowStart\");\n return;\n case \"End\":\n e.preventDefault();\n moveFocus(0, 0, e.ctrlKey ? \"gridEnd\" : \"rowEnd\");\n return;\n case \"PageUp\":\n e.preventDefault();\n moveFocus(-10, 0);\n return;\n case \"PageDown\":\n e.preventDefault();\n moveFocus(10, 0);\n return;\n case \"Enter\":\n case \"F2\": {\n const row = cell.parentElement;\n if (row.getAttribute(\"data-part\") === \"group-header\") {\n e.preventDefault();\n toggleGroup(row);\n return;\n }\n if (isTreeParent(row) && !isCellEditable(cell)) {\n e.preventDefault();\n toggleRow(row);\n return;\n }\n if (isCellEditable(cell)) {\n e.preventDefault();\n startEdit(cell);\n }\n return;\n }\n case \" \": {\n const row = cell.parentElement;\n if (row.getAttribute(\"data-part\") === \"group-header\") {\n e.preventDefault();\n toggleGroup(row);\n return;\n }\n if (opts.selectable != null || row.querySelector(\"[data-part='checkbox']\")) {\n const index = bodyRows().indexOf(row);\n if (index >= 0) {\n e.preventDefault();\n selectRow(index);\n }\n }\n return;\n }\n }\n }\n\n // ── Sticky + responsive measurements ──\n // The breakpoint canon (src/utils/breakpoints.ts, task 0.8-01) in px, the unit\n // clientWidth speaks. It is a literal here and not an import because the build\n // inlines every controller into one UMD closure and strips its import lines\n // (scripts/build-core.mjs) — so the equality is enforced from the outside\n // instead: tests/responsive-canon.test.ts parses this very object out of the\n // shipped controller and compares it to BREAKPOINTS, and would fail on any\n // edit that made the engine a second source of truth. `sm` was 480 in 1.x —\n // its own ladder, half a tier below the canon; the CSS ceilings it paired with\n // are now min-width floors.\n const STACK_BREAKPOINTS = { sm: 640, md: 768, lg: 1024 };\n function stackBreakpoint() {\n const v = root.getAttribute(\"data-stack-below\") || \"md\";\n return STACK_BREAKPOINTS[v] || parseFloat(v) || STACK_BREAKPOINTS.md;\n }\n /** Below the breakpoint, stack mode re-renders rows as labelled cards (CSS keys off data-stacked). */\n function updateStackMode() {\n if (opts.responsive !== \"stack\") return;\n const width = root.clientWidth || root.getBoundingClientRect?.().width || 0;\n if (!width) return; // headless environment — leave any authored data-stacked alone\n toggleAttr(root, \"data-stacked\", width < stackBreakpoint());\n }\n\n function measureSticky() {\n const needsHeaderVar =\n root.hasAttribute(\"data-sticky-header\") || !!tbody?.querySelector(\"[data-part='tr'][data-pin='top']\");\n if (needsHeaderVar && thead && thead.offsetHeight) {\n root.style.setProperty(\"--table-thead-h\", thead.offsetHeight + \"px\");\n }\n refreshPins();\n updateStackMode();\n }\n\n // ── Refresh (full structural rescan; safe to call after external DOM changes) ──\n function refresh() {\n colTypeCache.clear();\n rememberOrder();\n mirrorColumnAttrs();\n setupTree();\n setupGroups();\n setupDetails();\n injectResizeHandles();\n applyFormats();\n setupLabels();\n setupNavigability();\n computeAggregates();\n if (globalFilter || columnFilters.size) {\n mutedRun(applyFilters);\n } else {\n updateEmptyRow(visibleBodyRows().length);\n }\n refreshPins();\n refreshStripes();\n updateHeaderCheckbox();\n }\n\n // ── Lifecycle ──\n function destroy() {\n cancelDrag();\n if (editing) cancelEdit();\n for (const fn of cleanups) fn();\n cleanups.length = 0;\n observer?.disconnect();\n observer = null;\n for (const t of timers) clearTimeout(t);\n timers.clear();\n clearTimeout(saveTimer);\n delete root._faqirTable;\n }\n\n // ── Wire up ──\n if (thead) on(thead, \"click\", onHeaderClick);\n if (headerCheckbox) on(headerCheckbox, \"change\", onHeaderCheckboxChange);\n if (tbody) on(tbody, \"change\", onRowCheckboxChange);\n on(root, \"click\", onRootClick);\n on(root, \"dblclick\", onDblClick);\n on(root, \"keydown\", onKeydown);\n on(root, \"input\", onFilterInput);\n on(root, \"pointerdown\", onPointerDown);\n on(root, \"focusin\", onFocusIn);\n if (typeof window !== \"undefined\") {\n let resizeTimer = null;\n const onWinResize = () => {\n clearTimeout(resizeTimer);\n resizeTimer = later(measureSticky, 150);\n };\n on(window, \"resize\", onWinResize);\n }\n if (typeof MutationObserver !== \"undefined\" && tbody) {\n observer = new MutationObserver(() => {\n if (!observerPaused) queueRefresh();\n });\n observer.observe(tbody, { childList: true });\n }\n if (typeof ResizeObserver !== \"undefined\") {\n let sizeTimer = null;\n const ro = new ResizeObserver(() => {\n clearTimeout(sizeTimer);\n sizeTimer = later(measureSticky, 100);\n });\n ro.observe(root);\n cleanups.push(() => ro.disconnect());\n }\n\n refresh();\n restoreState();\n if (typeof requestAnimationFrame === \"function\") requestAnimationFrame(measureSticky);\n\n const api = {\n // legacy surface (unchanged)\n sort,\n selectRow,\n selectAll,\n deselectAll,\n getSelected,\n destroy,\n // sorting\n sortBy,\n clearSort,\n // filtering\n setFilter,\n setColumnFilter,\n clearFilters,\n // grouping / tree / detail\n toggleGroup,\n toggleRow,\n toggleDetail,\n expandAll,\n collapseAll,\n // editing\n startEdit,\n commitEdit,\n cancelEdit,\n // structure\n moveRow,\n moveColumn,\n hideColumn,\n showColumn,\n toggleColumn,\n setColumnWidth,\n // data\n exportCsv,\n getData,\n getSelectedData,\n // state\n getState,\n setState,\n refresh,\n };\n root._faqirTable = api;\n return api;\n}\n return createTable;\n })();\n\n // ── tabs ── (registry/recipes/tabs/tabs.js)\n var createTabs = controllerRegistry[\"tabs\"] = (function() {\n// @ui:controller tabs\n// @ui:provides activate destroy\n\nfunction createTabs(root) {\n // Prevent double-init\n if (root._faqirTabs) return root._faqirTabs;\n\n const list = root.querySelector(\"[data-part='list']\");\n const triggers = () => [...root.querySelectorAll(\"[data-part='trigger']\")];\n const panels = () => [...root.querySelectorAll(\"[data-part='panel']\")];\n\n function activate(index) {\n const allTriggers = triggers();\n const allPanels = panels();\n\n if (index < 0 || index >= allTriggers.length) return;\n\n // Deactivate all\n allTriggers.forEach((trigger, i) => {\n trigger.setAttribute(\"aria-selected\", \"false\");\n trigger.setAttribute(\"tabindex\", \"-1\");\n if (allPanels[i]) allPanels[i].hidden = true;\n });\n\n // Activate target\n allTriggers[index].setAttribute(\"aria-selected\", \"true\");\n allTriggers[index].removeAttribute(\"tabindex\");\n if (allPanels[index]) allPanels[index].hidden = false;\n }\n\n function getActiveIndex() {\n return triggers().findIndex(\n (t) => t.getAttribute(\"aria-selected\") === \"true\"\n );\n }\n\n function onTriggerClick(e) {\n const trigger = e.target.closest(\"[data-part='trigger']\");\n if (!trigger) return;\n const index = triggers().indexOf(trigger);\n if (index >= 0) {\n activate(index);\n trigger.focus();\n }\n }\n\n function onKeyDown(e) {\n const allTriggers = triggers();\n const current = getActiveIndex();\n let next = -1;\n\n switch (e.key) {\n case \"ArrowRight\":\n next = (current + 1) % allTriggers.length;\n break;\n case \"ArrowLeft\":\n next = (current - 1 + allTriggers.length) % allTriggers.length;\n break;\n case \"Home\":\n next = 0;\n break;\n case \"End\":\n next = allTriggers.length - 1;\n break;\n default:\n return;\n }\n\n e.preventDefault();\n activate(next);\n allTriggers[next].focus();\n }\n\n list?.addEventListener(\"click\", onTriggerClick);\n list?.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n list?.removeEventListener(\"click\", onTriggerClick);\n list?.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirTabs;\n }\n\n const api = { activate, getActiveIndex, destroy };\n root._faqirTabs = api;\n return api;\n}\n return createTabs;\n })();\n\n // ── tag-input ── (registry/recipes/tag-input/tag-input.js)\n var createTagInput = controllerRegistry[\"tag-input\"] = (function() {\n// @ui:controller tag-input\n// @ui:provides getValue setValue addTag removeTag clear destroy\n\n/**\n * tag-input — a multi-value text input that composes two existing recipes:\n *\n * • CHIP (primitive) for each committed value — the tags are real\n * `data-ui=\"chip\"` elements, so they inherit chip.css verbatim (no\n * duplicated styling) including the dismiss button.\n * • COMBOBOX behaviour for the optional suggestions listbox — filter-as-you-\n * type, Arrow/Enter selection, an empty state — mirroring the combobox\n * recipe's listbox contract.\n *\n * Interaction contract:\n * • Type + Enter commits the trimmed draft as a tag (unless it duplicates an\n * existing tag and duplicates are disallowed, the default).\n * • Backspace on an empty input removes the last tag.\n * • The chip dismiss button (or the removeTag API) removes a specific tag.\n * • With a suggestions listbox present, typing filters it; ArrowDown/ArrowUp\n * highlight; Enter/click commits the highlighted/clicked suggestion.\n *\n * Value exposure:\n * • getValue() returns the live tag array; setValue(arr) rebuilds the chips.\n * • Every mutation dispatches `faqir:change` (detail.value = the array) and\n * mirrors the array as JSON onto the hidden `[data-part=\"value\"]` input,\n * firing a native `input` event so `l-model` on that input stays in sync\n * (parse it for the array; getValue()/the event carry the array directly).\n */\nfunction createTagInput(root) {\n // Prevent double-init.\n if (root._faqirTagInput) return root._faqirTagInput;\n\n const taglist = root.querySelector(\"[data-part='taglist']\");\n const input = root.querySelector(\"[data-part='input']\");\n const listbox = root.querySelector(\"[data-part='listbox']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const valueEl = root.querySelector(\"[data-part='value']\");\n const allowDuplicates = root.hasAttribute(\"data-allow-duplicates\");\n\n const options = () =>\n listbox ? [...listbox.querySelectorAll(\"[data-part='option']\")] : [];\n const visibleOptions = () => options().filter((o) => !o.hasAttribute(\"data-hidden\"));\n\n let values = [];\n let highlightedIndex = -1;\n let outsideClickCleanup = null;\n\n // ── Chip rendering (reuses the chip primitive markup) ────────────────────────\n function makeChip(value) {\n const chip = document.createElement(\"span\");\n chip.dataset.ui = \"chip\";\n chip.dataset.part = \"tag\";\n\n const label = document.createElement(\"span\");\n label.dataset.part = \"label\";\n label.textContent = value;\n\n const dismiss = document.createElement(\"button\");\n dismiss.dataset.part = \"dismiss\";\n dismiss.type = \"button\";\n dismiss.setAttribute(\"aria-label\", `Remove ${value}`);\n dismiss.textContent = \"×\";\n\n chip.append(label, dismiss);\n return chip;\n }\n\n function readInitialTags() {\n if (!taglist) return [];\n return [...taglist.querySelectorAll(\"[data-part='tag'] [data-part='label']\")].map(\n (l) => l.textContent.trim(),\n );\n }\n\n function isDuplicate(value) {\n const needle = value.toLowerCase();\n return values.some((v) => v.toLowerCase() === needle);\n }\n\n // ── value sync ───────────────────────────────────────────────────────────────\n function syncValueSeam() {\n if (!valueEl) return;\n const next = JSON.stringify(values);\n if (valueEl.value !== next) {\n valueEl.value = next;\n valueEl.dispatchEvent(new Event(\"input\", { bubbles: true }));\n }\n }\n\n function emit(name, detail) {\n root.dispatchEvent(new CustomEvent(name, { bubbles: true, detail }));\n }\n\n function commitMutation(extraDetail) {\n syncValueSeam();\n emit(\"faqir:change\", { value: values.slice(), ...extraDetail });\n }\n\n // ── add / remove ─────────────────────────────────────────────────────────────\n function addTag(raw) {\n const value = String(raw == null ? \"\" : raw).trim();\n if (!value) return false;\n if (!allowDuplicates && isDuplicate(value)) return false;\n\n values.push(value);\n if (taglist) {\n const chip = makeChip(value);\n if (input && input.parentNode === taglist) {\n taglist.insertBefore(chip, input);\n } else {\n taglist.appendChild(chip);\n }\n }\n commitMutation({ added: value });\n return true;\n }\n\n function removeTag(value) {\n const index = values.findIndex((v) => v === value);\n if (index < 0) return false;\n values.splice(index, 1);\n if (taglist) {\n const chip = [...taglist.querySelectorAll(\"[data-part='tag']\")].find(\n (c) => c.querySelector(\"[data-part='label']\")?.textContent.trim() === value,\n );\n chip?.remove();\n }\n commitMutation({ removed: value });\n return true;\n }\n\n function removeLast() {\n if (!values.length) return false;\n return removeTag(values[values.length - 1]);\n }\n\n function clear() {\n if (!values.length) return;\n values = [];\n if (taglist) {\n taglist.querySelectorAll(\"[data-part='tag']\").forEach((c) => c.remove());\n }\n commitMutation({ cleared: true });\n }\n\n function getValue() {\n return values.slice();\n }\n\n function setValue(next) {\n const arr = Array.isArray(next) ? next : [];\n // Rebuild chips from scratch to mirror the requested value exactly.\n if (taglist) {\n taglist.querySelectorAll(\"[data-part='tag']\").forEach((c) => c.remove());\n }\n values = [];\n for (const v of arr) {\n const value = String(v).trim();\n if (!value) continue;\n if (!allowDuplicates && isDuplicate(value)) continue;\n values.push(value);\n if (taglist) {\n const chip = makeChip(value);\n if (input && input.parentNode === taglist) taglist.insertBefore(chip, input);\n else taglist.appendChild(chip);\n }\n }\n commitMutation({ set: true });\n }\n\n // ── suggestions listbox (combobox behaviour) ─────────────────────────────────\n function openList() {\n if (!listbox) return;\n root.dataset.state = \"open\";\n listbox.hidden = false;\n input?.setAttribute(\"aria-expanded\", \"true\");\n outsideClickCleanup = onOutsideClick(root, closeList);\n }\n\n function closeList() {\n if (!listbox) return;\n root.dataset.state = \"closed\";\n listbox.hidden = true;\n input?.setAttribute(\"aria-expanded\", \"false\");\n clearHighlight();\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n /**\n * `aria-activedescendant`, for the same reason as `combobox`: the field\n * publishes `role=\"combobox\"` + `aria-autocomplete=\"list\"`, so it owes the\n * reader the name of the active suggestion. [W3-4]\n */\n function optionId(opt) {\n if (!opt.id) opt.id = uid(\"faqir-suggestion\");\n return opt.id;\n }\n\n function setActiveDescendant(opt) {\n if (!input) return;\n if (opt) input.setAttribute(\"aria-activedescendant\", optionId(opt));\n else input.removeAttribute(\"aria-activedescendant\");\n }\n\n function clearHighlight() {\n options().forEach((o) => o.removeAttribute(\"data-highlighted\"));\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function highlight(index) {\n const vis = visibleOptions();\n if (!vis.length) return;\n if (index < 0) index = vis.length - 1;\n if (index >= vis.length) index = 0;\n options().forEach((o) => o.removeAttribute(\"data-highlighted\"));\n vis[index].setAttribute(\"data-highlighted\", \"\");\n vis[index].scrollIntoView?.({ block: \"nearest\" });\n setActiveDescendant(vis[index]);\n highlightedIndex = index;\n }\n\n function filterSuggestions(query) {\n const q = query.toLowerCase();\n let count = 0;\n options().forEach((o) => {\n const text = o.textContent.toLowerCase();\n const alreadyChosen = !allowDuplicates && isDuplicate(o.textContent.trim());\n if (text.includes(q) && !alreadyChosen) {\n o.removeAttribute(\"data-hidden\");\n count++;\n } else {\n o.setAttribute(\"data-hidden\", \"\");\n }\n });\n if (emptyEl) emptyEl.hidden = count > 0;\n clearHighlight();\n return count;\n }\n\n // ── event handlers ───────────────────────────────────────────────────────────\n function onInput() {\n if (!listbox) return;\n if (root.dataset.state !== \"open\") openList();\n filterSuggestions(input.value);\n }\n\n function onInputKeyDown(e) {\n switch (e.key) {\n case \"Enter\": {\n e.preventDefault();\n const vis = visibleOptions();\n if (listbox && highlightedIndex >= 0 && highlightedIndex < vis.length) {\n if (addTag(vis[highlightedIndex].textContent.trim())) {\n input.value = \"\";\n filterSuggestions(\"\");\n }\n } else if (input.value.trim()) {\n if (addTag(input.value)) {\n input.value = \"\";\n if (listbox) filterSuggestions(\"\");\n }\n }\n break;\n }\n case \"Backspace\":\n if (input.value === \"\") {\n e.preventDefault();\n removeLast();\n if (listbox) filterSuggestions(\"\");\n }\n break;\n case \"ArrowDown\":\n if (listbox) {\n e.preventDefault();\n if (root.dataset.state !== \"open\") openList();\n highlight(highlightedIndex + 1);\n }\n break;\n case \"ArrowUp\":\n if (listbox) {\n e.preventDefault();\n if (root.dataset.state !== \"open\") openList();\n highlight(highlightedIndex - 1);\n }\n break;\n case \"Escape\":\n if (listbox && root.dataset.state === \"open\") {\n e.preventDefault();\n // The suggestion list is what closes; the form around it stays. [W3-2]\n e.stopPropagation();\n closeList();\n }\n break;\n }\n }\n\n function onTaglistClick(e) {\n const dismiss = e.target.closest(\"[data-part='dismiss']\");\n if (!dismiss) return;\n const chip = dismiss.closest(\"[data-part='tag']\");\n const value = chip?.querySelector(\"[data-part='label']\")?.textContent.trim();\n if (value != null) {\n removeTag(value);\n input?.focus();\n }\n }\n\n function onListboxClick(e) {\n const opt = e.target.closest(\"[data-part='option']\");\n if (!opt || opt.hasAttribute(\"data-hidden\")) return;\n if (addTag(opt.textContent.trim())) {\n if (input) input.value = \"\";\n filterSuggestions(\"\");\n input?.focus();\n }\n }\n\n // ── wire up ──────────────────────────────────────────────────────────────────\n values = readInitialTags();\n syncValueSeam();\n\n input?.addEventListener(\"input\", onInput);\n input?.addEventListener(\"keydown\", onInputKeyDown);\n taglist?.addEventListener(\"click\", onTaglistClick);\n listbox?.addEventListener(\"click\", onListboxClick);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n closeList();\n input?.removeEventListener(\"input\", onInput);\n input?.removeEventListener(\"keydown\", onInputKeyDown);\n taglist?.removeEventListener(\"click\", onTaglistClick);\n listbox?.removeEventListener(\"click\", onListboxClick);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirTagInput;\n }\n\n const api = { getValue, setValue, addTag, removeTag, clear, destroy };\n root._faqirTagInput = api;\n return api;\n}\n return createTagInput;\n })();\n\n // ── toast ── (registry/recipes/toast/toast.js)\n var createToastContainer = controllerRegistry[\"toast\"] = (function() {\n// @ui:controller toast\n// @ui:provides add dismiss dismissAll destroy\n\nfunction createToastContainer(root) {\n // Prevent double-init\n if (root._faqirToast) return root._faqirToast;\n\n const toasts = new Map();\n\n /**\n * Add a new toast to the container.\n *\n * `message`, `icon` and `actionLabel` are TEXT. They are written with\n * `textContent`, never `innerHTML`, because the overwhelmingly common call is\n * `add({ message: err.message })` or a message built from a name the server\n * echoed back — values the caller did not author. Markup in any of them is\n * inert, exactly as it is in `l-text` (see `docs/security.md` §4).\n *\n * `iconHtml` is the explicit opt-in for markup — an inline `<svg>` glyph is\n * the reason it exists. It is assigned to `innerHTML` verbatim and is\n * therefore an `l-html`-class surface: never pass a value you did not author.\n * When both are given, `iconHtml` wins.\n *\n * @param {Object} options\n * @param {string} options.message - Toast message text (escaped)\n * @param {string} [options.tone=\"default\"] - default|success|error|warning\n * @param {string} [options.icon] - Icon TEXT (a glyph such as \"★\"); escaped\n * @param {string} [options.iconHtml] - Icon markup, written unescaped. Author-supplied only.\n * @param {string} [options.actionLabel] - Action button label (escaped)\n * @param {Function} [options.onAction] - Action button callback\n * @param {number} [options.duration=5000] - Auto-dismiss delay in ms (0 to disable)\n * @returns {string} toast id\n */\n function add(options = {}) {\n const {\n message = \"\",\n tone = \"default\",\n icon = \"\",\n iconHtml = \"\",\n actionLabel = \"\",\n onAction = null,\n duration = 5000,\n } = options;\n\n const id = uid(\"toast\");\n const el = document.createElement(\"div\");\n el.dataset.part = \"toast\";\n el.dataset.variant = tone;\n el.dataset.state = \"entering\";\n el.setAttribute(\"role\", \"status\");\n el.setAttribute(\"aria-live\", \"polite\");\n\n // Build inner content as NODES, not as a concatenated string. The same\n // pattern as file-upload.js and tag-input.js, and for the same reason:\n // every value below may come from outside the page's author.\n if (icon || iconHtml) {\n const iconEl = document.createElement(\"span\");\n iconEl.dataset.part = \"icon\";\n iconEl.setAttribute(\"aria-hidden\", \"true\");\n // Opt-in markup wins over the escaped text form; see the doc comment.\n if (iconHtml) iconEl.innerHTML = iconHtml;\n else iconEl.textContent = icon;\n el.appendChild(iconEl);\n }\n\n const messageEl = document.createElement(\"span\");\n messageEl.dataset.part = \"message\";\n messageEl.textContent = message;\n el.appendChild(messageEl);\n\n if (actionLabel) {\n const action = document.createElement(\"button\");\n action.dataset.part = \"action\";\n action.textContent = actionLabel;\n el.appendChild(action);\n }\n\n const close = document.createElement(\"button\");\n close.dataset.part = \"close\";\n close.setAttribute(\"aria-label\", \"Dismiss notification\");\n close.textContent = \"\\u2715\"; // ✕ — was `✕` in the old innerHTML string\n el.appendChild(close);\n\n root.appendChild(el);\n\n // Transition from entering to visible on next frame\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (el.dataset.state === \"entering\") {\n el.dataset.state = \"visible\";\n }\n });\n });\n\n register(el, id, { onAction, duration });\n\n return id;\n }\n\n /**\n * Bring one toast element under the controller: wire its close and action\n * buttons, start its auto-dismiss timer, and record it so `dismiss` can find\n * it. Shared by `add()` and by the adoption of authored toasts on init.\n */\n function register(el, id, { onAction = null, duration = 0 } = {}) {\n el.dataset.toastId = id;\n\n const closeBtn = el.querySelector(\"[data-part='close']\");\n const onCloseClick = () => dismiss(id);\n closeBtn?.addEventListener(\"click\", onCloseClick);\n\n const actionBtn = el.querySelector(\"[data-part='action']\");\n const onActionClick = () => {\n if (onAction) onAction();\n dismiss(id);\n };\n if (actionBtn) {\n actionBtn.addEventListener(\"click\", onActionClick);\n }\n\n let timer = null;\n if (duration > 0) {\n timer = setTimeout(() => dismiss(id), duration);\n }\n\n toasts.set(id, {\n el,\n timer,\n closeBtn,\n onCloseClick,\n actionBtn,\n onActionClick,\n });\n\n return id;\n }\n\n /**\n * Dismiss a toast by id with exit animation.\n * @param {string} id\n */\n function dismiss(id) {\n const entry = toasts.get(id);\n // Already exiting (close clicked while the timer fires, say): one exit wait.\n if (!entry || entry.cancelExitWait) return;\n\n const { el, timer, closeBtn, onCloseClick, actionBtn, onActionClick } = entry;\n\n if (timer) clearTimeout(timer);\n\n // Start exit animation\n el.dataset.state = \"exiting\";\n\n const onEnd = () => {\n closeBtn?.removeEventListener(\"click\", onCloseClick);\n if (actionBtn) actionBtn.removeEventListener(\"click\", onActionClick);\n el.remove();\n toasts.delete(id);\n };\n\n // The toast's own exit motion. Its close button and action button both\n // transition `background` on hover, and those events bubble up to the toast\n // element — a one-shot listener spent itself on the first of them and the\n // toast was ripped out mid-slide, or (when no further event came) left in\n // the stack forever. See `whenExitDone`. [W2-1]\n entry.cancelExitWait = whenExitDone(el, null, onEnd);\n }\n\n /**\n * Dismiss all toasts.\n */\n function dismissAll() {\n const ids = [...toasts.keys()];\n ids.forEach((id) => dismiss(id));\n }\n\n function destroy() {\n // Clear all toasts immediately without animation\n for (const [id, entry] of toasts) {\n if (entry.timer) clearTimeout(entry.timer);\n if (entry.cancelExitWait) entry.cancelExitWait();\n entry.closeBtn?.removeEventListener(\"click\", entry.onCloseClick);\n if (entry.actionBtn) entry.actionBtn.removeEventListener(\"click\", entry.onActionClick);\n entry.el.remove();\n }\n toasts.clear();\n delete root._faqirToast;\n }\n\n // Adopt the toasts already in the markup.\n //\n // `add()` used to be the only way into the registry, so a toast written by\n // hand — the reference page's own stack, the manifest template, anything an\n // agent copies out of the docs — had a close button that was wired to\n // nothing. It looked right, it was in the a11y tree, it did nothing at all\n // when clicked, and nothing anywhere said so. [W2-1]\n for (const el of root.querySelectorAll(\"[data-part='toast']\")) {\n if (el.dataset.toastId) continue;\n register(el, uid(\"toast\"));\n }\n\n const api = { add, dismiss, dismissAll, destroy };\n root._faqirToast = api;\n return api;\n}\n return createToastContainer;\n })();\n\n // ── toggle-group ── (registry/recipes/toggle-group/toggle-group.js)\n var createToggleGroup = controllerRegistry[\"toggle-group\"] = (function() {\n// @ui:controller toggle-group\n// @ui:provides getValue setValue toggle destroy\n\n/**\n * toggle-group — a single- or multi-select group of toggle buttons built on\n * NATIVE form controls so `l-model` works with zero engine changes:\n *\n * • single mode → `[data-part=\"control\"]` are `<input type=\"radio\">`; the\n * committed value is the checked radio's `value` (a string). `l-model` on\n * the radios two-way-binds a string through the engine's native radio path.\n * • multi mode → the controls are `<input type=\"checkbox\">`; the value is the\n * array of checked `value`s. `l-model` binds an array through the engine's\n * native checkbox-array path.\n *\n * The visible \"buttons\" are the `[data-part=\"item\"]` labels; the native input\n * is visually hidden (see the CSS) but remains the accessible, focusable\n * control, so the ARIA is the real radio/checkbox semantics of the platform.\n *\n * The controller owns only what CSS and the platform cannot: **roving\n * tabindex** (Arrow/Home/End move a single tab-stop across the group, with\n * focus-follows-selection in single mode per the radiogroup convention),\n * keyboard toggling that is synthetic-event-safe (Space/Enter), single-mode\n * exclusivity when the controls are used standalone (no `l-model`), the\n * `[data-state]` styling hook, and a `faqir:change` notification.\n *\n * Every state mutation funnels through a native `change` event on the affected\n * input, so the engine's `l-model` listener and this controller stay in lockstep.\n */\nfunction createToggleGroup(root) {\n // Prevent double-init.\n if (root._faqirToggleGroup) return root._faqirToggleGroup;\n\n const mode = root.dataset.mode === \"multi\" ? \"multi\" : \"single\";\n const controls = () => [...root.querySelectorAll(\"[data-part='control']\")];\n const enabled = () => controls().filter((el) => !el.disabled);\n\n // ── value ──────────────────────────────────────────────────────────────────\n function getValue() {\n const checked = controls()\n .filter((el) => el.checked)\n .map((el) => el.value);\n return mode === \"multi\" ? checked : (checked.length ? checked[0] : null);\n }\n\n function setValue(val) {\n const cs = controls();\n if (mode === \"multi\") {\n const set = new Set(Array.isArray(val) ? val : val == null ? [] : [val]);\n cs.forEach((el) => {\n el.checked = set.has(el.value);\n });\n } else {\n cs.forEach((el) => {\n el.checked = el.value === val;\n });\n }\n syncState();\n }\n\n // ── state reflection + roving tabindex ───────────────────────────────────────\n function checkedIndex() {\n return controls().findIndex((el) => el.checked);\n }\n\n function tabStopIndex() {\n // The tab-stop follows the checked control; falling back to the first\n // enabled one so the group is always reachable by Tab.\n const checked = checkedIndex();\n if (checked >= 0 && !controls()[checked].disabled) return checked;\n const first = controls().findIndex((el) => !el.disabled);\n return first >= 0 ? first : 0;\n }\n\n function syncState() {\n const stop = tabStopIndex();\n controls().forEach((el, i) => {\n el.tabIndex = i === stop ? 0 : -1;\n const item = el.closest(\"[data-part='item']\") || el;\n item.dataset.state = el.checked ? \"on\" : \"off\";\n });\n }\n\n function emitChange() {\n root.dispatchEvent(\n new CustomEvent(\"faqir:change\", {\n bubbles: true,\n detail: { value: getValue(), mode },\n }),\n );\n }\n\n // The single mutation seam: enforce single-mode exclusivity (needed when the\n // group is used without l-model), reflect state, then notify.\n function onChange(e) {\n const el = e.target.closest(\"[data-part='control']\");\n if (!el || !root.contains(el)) return;\n if (mode === \"single\" && el.checked) {\n controls().forEach((o) => {\n if (o !== el) o.checked = false;\n });\n }\n syncState();\n emitChange();\n }\n\n // ── keyboard ─────────────────────────────────────────────────────────────────\n function moveFocus(fromIndex, delta) {\n const list = enabled();\n if (!list.length) return;\n const all = controls();\n // Map the absolute index onto the enabled subset, then step.\n let pos = list.indexOf(all[fromIndex]);\n if (pos < 0) pos = 0;\n const next = ((pos + delta) % list.length + list.length) % list.length;\n focusControl(all.indexOf(list[next]));\n }\n\n function focusControl(index) {\n const cs = controls();\n const el = cs[index];\n if (!el) return;\n cs.forEach((o, i) => {\n o.tabIndex = i === index ? 0 : -1;\n });\n el.focus();\n // radiogroup convention: in single mode, moving focus selects.\n if (mode === \"single\") select(el);\n }\n\n function jumpFocus(edge) {\n const list = enabled();\n if (!list.length) return;\n focusControl(controls().indexOf(edge === \"first\" ? list[0] : list[list.length - 1]));\n }\n\n // Toggle/select via a dispatched native change, so l-model and onChange run.\n function select(el) {\n if (el.disabled) return;\n if (mode === \"multi\") {\n el.checked = !el.checked;\n } else {\n el.checked = true;\n }\n el.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n function onKeyDown(e) {\n const cs = controls();\n const active = cs.indexOf(document.activeElement);\n const from = active >= 0 ? active : tabStopIndex();\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n e.preventDefault();\n moveFocus(from, 1);\n break;\n case \"ArrowLeft\":\n case \"ArrowUp\":\n e.preventDefault();\n moveFocus(from, -1);\n break;\n case \"Home\":\n e.preventDefault();\n jumpFocus(\"first\");\n break;\n case \"End\":\n e.preventDefault();\n jumpFocus(\"last\");\n break;\n case \" \":\n case \"Enter\":\n // Drive the toggle ourselves so synthetic events (tests) behave like\n // real ones and l-model always sees a change event.\n if (active >= 0) {\n e.preventDefault();\n select(cs[active]);\n }\n break;\n }\n }\n\n // Public toggle by value (imperative API).\n function toggle(value) {\n const el = controls().find((c) => c.value === value);\n if (el) select(el);\n }\n\n root.addEventListener(\"change\", onChange);\n root.addEventListener(\"keydown\", onKeyDown);\n syncState();\n\n function destroy() {\n root.removeEventListener(\"change\", onChange);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirToggleGroup;\n }\n\n const api = { getValue, setValue, toggle, destroy };\n root._faqirToggleGroup = api;\n return api;\n}\n return createToggleGroup;\n })();\n\n // ── tooltip ── (registry/recipes/tooltip/tooltip.js)\n var createTooltip = controllerRegistry[\"tooltip\"] = (function() {\n// @ui:controller tooltip\n// @ui:provides show hide destroy\n\nfunction createTooltip(root) {\n // Prevent double-init\n if (root._faqirTooltip) return root._faqirTooltip;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const content = root.querySelector(\"[data-part='content']\");\n\n let showTimer = null;\n let hideTimer = null;\n\n function show() {\n clearTimeout(hideTimer);\n hideTimer = null;\n root.dataset.state = \"visible\";\n content.hidden = false;\n }\n\n function hide() {\n clearTimeout(showTimer);\n showTimer = null;\n root.dataset.state = \"hidden\";\n content.hidden = true;\n }\n\n function scheduleShow() {\n clearTimeout(hideTimer);\n hideTimer = null;\n showTimer = setTimeout(show, 200);\n }\n\n function scheduleHide() {\n clearTimeout(showTimer);\n showTimer = null;\n hideTimer = setTimeout(hide, 100);\n }\n\n function onMouseEnter() {\n scheduleShow();\n }\n\n function onMouseLeave() {\n scheduleHide();\n }\n\n function onFocusIn() {\n scheduleShow();\n }\n\n function onFocusOut() {\n scheduleHide();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"visible\") {\n e.stopPropagation();\n hide();\n }\n }\n\n trigger?.addEventListener(\"mouseenter\", onMouseEnter);\n trigger?.addEventListener(\"mouseleave\", onMouseLeave);\n trigger?.addEventListener(\"focusin\", onFocusIn);\n trigger?.addEventListener(\"focusout\", onFocusOut);\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n hide();\n clearTimeout(showTimer);\n clearTimeout(hideTimer);\n trigger?.removeEventListener(\"mouseenter\", onMouseEnter);\n trigger?.removeEventListener(\"mouseleave\", onMouseLeave);\n trigger?.removeEventListener(\"focusin\", onFocusIn);\n trigger?.removeEventListener(\"focusout\", onFocusOut);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirTooltip;\n }\n\n const api = { show, hide, destroy };\n root._faqirTooltip = api;\n return api;\n}\n return createTooltip;\n })();\n\n // ── tree-view ── (registry/recipes/tree-view/tree-view.js)\n var createTreeView = controllerRegistry[\"tree-view\"] = (function() {\n// @ui:controller tree-view\n// @ui:provides select expand collapse toggle refresh getSelected destroy\n\n/**\n * Single-select WAI-ARIA tree view with roving DOM focus.\n *\n * Item queries are deliberately live. A tree root can be initialized before\n * keyed l-for templates render their nodes, and later reconciliations can move,\n * insert, or remove whole branches without recreating the controller.\n */\nfunction createTreeView(root) {\n if (root._faqirTreeView) {\n root._faqirTreeView.refresh();\n return root._faqirTreeView;\n }\n\n let currentItem = null;\n let selectedItem = null;\n let typeahead = \"\";\n let typeaheadTimer = null;\n\n function belongsToTree(element) {\n return element?.closest(\"[data-ui='tree-view']\") === root;\n }\n\n function items() {\n return [...root.querySelectorAll(\"[data-part='item']\")]\n .filter(belongsToTree);\n }\n\n function groups() {\n return [...root.querySelectorAll(\"[data-part='group']\")]\n .filter(belongsToTree);\n }\n\n function directItems(container) {\n return [...container.children]\n .filter((child) => child.matches(\"[data-part='item']\") && belongsToTree(child));\n }\n\n function directGroup(item) {\n return [...item.children].find(\n (child) => child.matches(\"[data-part='group']\") && belongsToTree(child),\n ) ?? null;\n }\n\n function parentItem(item) {\n const group = item.parentElement?.closest(\"[data-part='group']\");\n if (!group || !belongsToTree(group)) return null;\n const parent = group.parentElement;\n return parent?.matches(\"[data-part='item']\") && belongsToTree(parent)\n ? parent\n : null;\n }\n\n function isDisabled(item) {\n return item?.getAttribute(\"aria-disabled\") === \"true\";\n }\n\n function isLazy(item) {\n return item?.hasAttribute(\"data-lazy\") && item.dataset.lazy !== \"false\";\n }\n\n function isExpandable(item) {\n return Boolean(\n item &&\n (directGroup(item) || item.hasAttribute(\"aria-expanded\") || isLazy(item)),\n );\n }\n\n function isVisible(item) {\n if (!item || item.hidden || !belongsToTree(item)) return false;\n\n let ancestor = item.parentElement;\n while (ancestor && ancestor !== root) {\n if (ancestor.hidden) return false;\n if (ancestor.matches(\"[data-part='group']\")) {\n const parent = ancestor.parentElement;\n if (\n parent?.matches(\"[data-part='item']\") &&\n parent.getAttribute(\"aria-expanded\") !== \"true\"\n ) {\n return false;\n }\n }\n ancestor = ancestor.parentElement;\n }\n return true;\n }\n\n function visibleItems() {\n return items().filter((item) => isVisible(item) && !isDisabled(item));\n }\n\n function syncParentState(item) {\n if (item.hasAttribute(\"aria-expanded\")) {\n item.dataset.state = item.getAttribute(\"aria-expanded\") === \"true\"\n ? \"expanded\"\n : \"collapsed\";\n } else if (\n item.dataset.state === \"expanded\" ||\n item.dataset.state === \"collapsed\"\n ) {\n item.removeAttribute(\"data-state\");\n }\n }\n\n function normalizeBranch(container, level) {\n const siblings = directItems(container);\n const setSize = String(siblings.length);\n\n siblings.forEach((item, index) => {\n item.setAttribute(\"role\", \"treeitem\");\n item.setAttribute(\"aria-level\", String(level));\n item.setAttribute(\"aria-setsize\", setSize);\n item.setAttribute(\"aria-posinset\", String(index + 1));\n\n const group = directGroup(item);\n if (group) {\n group.setAttribute(\"role\", \"group\");\n const expanded = item.hasAttribute(\"aria-expanded\")\n ? item.getAttribute(\"aria-expanded\") === \"true\"\n : !group.hidden;\n item.setAttribute(\"aria-expanded\", String(expanded));\n group.hidden = !expanded;\n syncParentState(item);\n normalizeBranch(group, level + 1);\n } else if (isLazy(item) || item.hasAttribute(\"aria-expanded\")) {\n if (!item.hasAttribute(\"aria-expanded\")) {\n item.setAttribute(\"aria-expanded\", \"false\");\n }\n syncParentState(item);\n } else {\n item.removeAttribute(\"aria-expanded\");\n syncParentState(item);\n }\n });\n }\n\n function refresh() {\n root.setAttribute(\"role\", \"tree\");\n root.setAttribute(\"aria-multiselectable\", \"false\");\n\n const before = items();\n const authoredTabStop = before.find(\n (item) => item.tabIndex === 0 && !isDisabled(item),\n ) ?? null;\n\n groups().forEach((group) => group.setAttribute(\"role\", \"group\"));\n normalizeBranch(root, 1);\n\n const allItems = items();\n const selected = allItems.filter(\n (item) => !isDisabled(item) && item.getAttribute(\"aria-selected\") === \"true\",\n );\n const keepSelected = selected.includes(selectedItem)\n ? selectedItem\n : selected[0] ?? null;\n\n for (const item of allItems) {\n if (isDisabled(item)) {\n item.removeAttribute(\"aria-selected\");\n } else {\n item.setAttribute(\"aria-selected\", item === keepSelected ? \"true\" : \"false\");\n }\n }\n selectedItem = keepSelected;\n\n const active = document.activeElement?.closest?.(\"[data-part='item']\");\n const candidates = [currentItem, active, selectedItem, authoredTabStop];\n currentItem = candidates.find(\n (item) => allItems.includes(item) && isVisible(item) && !isDisabled(item),\n ) ?? visibleItems()[0] ?? null;\n\n for (const item of allItems) {\n item.tabIndex = item === currentItem ? 0 : -1;\n }\n\n root.dataset.state = selectedItem ? \"selected\" : \"idle\";\n return allItems;\n }\n\n function resolveItem(target) {\n const allItems = items();\n if (target?.matches?.(\"[data-part='item']\")) {\n return allItems.includes(target) ? target : null;\n }\n if (typeof target === \"number\") return allItems[target] ?? null;\n if (typeof target === \"string\") {\n return allItems.find(\n (item) => item.dataset.value === target || item.id === target,\n ) ?? null;\n }\n return null;\n }\n\n function itemLabel(item) {\n const label = item.querySelector(\"[data-part='label']\");\n if (label) {\n const readable = label.cloneNode(true);\n readable.querySelectorAll(\"[aria-hidden='true']\").forEach((node) => node.remove());\n return readable.textContent.trim();\n }\n return (item.dataset.value ?? item.id ?? \"\").trim();\n }\n\n function itemValue(item) {\n return item.dataset.value || item.id || itemLabel(item);\n }\n\n function emit(type, detail) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }),\n );\n }\n\n function focusItem(target) {\n const item = resolveItem(target);\n if (!item || isDisabled(item) || !isVisible(item)) return false;\n\n currentItem = item;\n for (const candidate of items()) {\n candidate.tabIndex = candidate === item ? 0 : -1;\n }\n item.focus();\n item.scrollIntoView?.({ block: \"nearest\" });\n return true;\n }\n\n function select(target) {\n refresh();\n const item = resolveItem(target);\n if (!item || isDisabled(item)) return false;\n\n const previousItem = selectedItem;\n for (const candidate of items()) {\n if (!isDisabled(candidate)) {\n candidate.setAttribute(\"aria-selected\", candidate === item ? \"true\" : \"false\");\n }\n }\n\n selectedItem = item;\n currentItem = item;\n for (const candidate of items()) {\n candidate.tabIndex = candidate === item ? 0 : -1;\n }\n root.dataset.state = \"selected\";\n\n emit(\"select\", {\n item,\n value: itemValue(item),\n label: itemLabel(item),\n previousItem,\n previousValue: previousItem ? itemValue(previousItem) : null,\n });\n return true;\n }\n\n function setExpanded(target, expanded) {\n refresh();\n const item = resolveItem(target);\n if (!item || isDisabled(item) || !isExpandable(item)) return false;\n\n const next = Boolean(expanded);\n const changed = item.getAttribute(\"aria-expanded\") !== String(next);\n item.setAttribute(\"aria-expanded\", String(next));\n const group = directGroup(item);\n if (group) group.hidden = !next;\n syncParentState(item);\n refresh();\n\n if (changed) {\n emit(\"expand\", {\n item,\n value: itemValue(item),\n label: itemLabel(item),\n expanded: next,\n lazy: isLazy(item) && !group,\n });\n }\n return true;\n }\n\n function expand(target) {\n return setExpanded(target, true);\n }\n\n function collapse(target) {\n return setExpanded(target, false);\n }\n\n function toggle(target) {\n refresh();\n const item = resolveItem(target);\n if (!item || !isExpandable(item)) return false;\n return setExpanded(item, item.getAttribute(\"aria-expanded\") !== \"true\");\n }\n\n function getSelected() {\n refresh();\n return selectedItem;\n }\n\n function move(item, delta) {\n const visible = visibleItems();\n const index = visible.indexOf(item);\n if (index === -1) return false;\n const nextIndex = Math.min(Math.max(index + delta, 0), visible.length - 1);\n return nextIndex === index ? false : focusItem(visible[nextIndex]);\n }\n\n function enabledParent(item) {\n let parent = parentItem(item);\n while (parent && isDisabled(parent)) parent = parentItem(parent);\n return parent;\n }\n\n function handleTypeahead(item, key) {\n typeahead += key.toLocaleLowerCase();\n if (typeaheadTimer) clearTimeout(typeaheadTimer);\n typeaheadTimer = setTimeout(() => {\n typeahead = \"\";\n typeaheadTimer = null;\n }, 500);\n\n const query = [...typeahead].every((character) => character === typeahead[0])\n ? typeahead[0]\n : typeahead;\n const visible = visibleItems();\n if (visible.length === 0) return false;\n const start = Math.max(visible.indexOf(item), -1);\n\n for (let offset = 1; offset <= visible.length; offset++) {\n const candidate = visible[(start + offset) % visible.length];\n if (itemLabel(candidate).toLocaleLowerCase().startsWith(query)) {\n return focusItem(candidate);\n }\n }\n return false;\n }\n\n function onKeyDown(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !belongsToTree(item) || isDisabled(item)) return;\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n move(item, 1);\n break;\n case \"ArrowUp\":\n event.preventDefault();\n move(item, -1);\n break;\n case \"Home\": {\n event.preventDefault();\n const first = visibleItems()[0];\n if (first) focusItem(first);\n break;\n }\n case \"End\": {\n event.preventDefault();\n const visible = visibleItems();\n if (visible.length > 0) focusItem(visible[visible.length - 1]);\n break;\n }\n case \"ArrowRight\": {\n event.preventDefault();\n if (!isExpandable(item)) break;\n if (item.getAttribute(\"aria-expanded\") !== \"true\") {\n expand(item);\n break;\n }\n const child = directGroup(item)\n ? directItems(directGroup(item)).find((candidate) => !isDisabled(candidate))\n : null;\n if (child) focusItem(child);\n break;\n }\n case \"ArrowLeft\": {\n event.preventDefault();\n if (isExpandable(item) && item.getAttribute(\"aria-expanded\") === \"true\") {\n collapse(item);\n break;\n }\n const parent = enabledParent(item);\n if (parent) focusItem(parent);\n break;\n }\n case \"Enter\":\n case \" \":\n event.preventDefault();\n select(item);\n break;\n case \"*\": {\n event.preventDefault();\n const container = item.parentElement;\n if (!container) break;\n for (const sibling of directItems(container)) {\n if (!isDisabled(sibling) && isExpandable(sibling)) expand(sibling);\n }\n break;\n }\n default:\n if (\n event.key.length === 1 &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n ) {\n if (handleTypeahead(item, event.key)) event.preventDefault();\n }\n }\n }\n\n function onClick(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !belongsToTree(item)) return;\n if (isDisabled(item)) {\n event.preventDefault();\n return;\n }\n\n focusItem(item);\n const togglePart = event.target.closest(\"[data-part='toggle']\");\n if (togglePart && togglePart.closest(\"[data-part='item']\") === item) {\n event.preventDefault();\n toggle(item);\n } else {\n select(item);\n }\n }\n\n function onFocusIn(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !belongsToTree(item) || isDisabled(item)) return;\n\n currentItem = item;\n for (const candidate of items()) {\n candidate.tabIndex = candidate === item ? 0 : -1;\n }\n }\n\n root.addEventListener(\"keydown\", onKeyDown);\n root.addEventListener(\"click\", onClick);\n root.addEventListener(\"focusin\", onFocusIn);\n\n function onMutation() {\n refresh();\n }\n\n const observer = new MutationObserver(onMutation);\n observer.observe(root, { childList: true, subtree: true });\n\n function destroy() {\n root.removeEventListener(\"keydown\", onKeyDown);\n root.removeEventListener(\"click\", onClick);\n root.removeEventListener(\"focusin\", onFocusIn);\n observer.disconnect();\n if (typeaheadTimer) clearTimeout(typeaheadTimer);\n delete root._faqirTreeView;\n }\n\n const api = {\n select,\n expand,\n collapse,\n toggle,\n refresh,\n getSelected,\n destroy,\n };\n root._faqirTreeView = api;\n refresh();\n return api;\n}\n return createTreeView;\n })();\n\n // ═══════════════════════════════════════════════════════\n // Section 8: Global API\n // ═══════════════════════════════════════════════════════\n\n var customMagics = new Map();\n\n function findParentScope(el) {\n var parent = el.parentElement;\n while (parent) {\n if (parent.__faqirScope) return parent.__faqirScope;\n parent = parent.parentElement;\n }\n return null;\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 8.5: Inspection & Devtools [task 0.7-12]\n // ═══════════════════════════════════════════════════════\n //\n // `Faqir.inspect(el)` answers \"what is Faqir doing to this element?\" in one\n // plain object. It ships in BOTH builds — it is the documented surface an\n // agent (or the `faqir dev` overlay) reads, not a debug-only extra. The same\n // functions hang off `window.__FAQIR_DEVTOOLS__`; see docs/devtools.md for the\n // stable shape.\n\n // Depth cap for scope snapshots — deeper values collapse to a marker rather\n // than walking an unbounded object graph.\n var SNAPSHOT_MAX_DEPTH = 4;\n\n /** One value, deep-copied into something plain, finite and printable. */\n function snapshotValue(value, stack, depth) {\n if (typeof value === 'function') {\n return '[Function' + (value.name ? ' ' + value.name : '') + ']';\n }\n if (value === null || typeof value !== 'object') return value;\n if (value.nodeType === 1 && value.tagName) {\n return '[Element <' + value.tagName.toLowerCase() + '>]';\n }\n if (value instanceof Date) return value.toISOString();\n if (stack.indexOf(value) !== -1) return '[Circular]';\n if (depth >= SNAPSHOT_MAX_DEPTH) return '[Depth]';\n\n stack.push(value);\n var out;\n if (Array.isArray(value)) {\n out = [];\n for (var i = 0; i < value.length; i++) out.push(snapshotValue(value[i], stack, depth + 1));\n } else {\n out = {};\n var keys = Object.keys(value);\n for (var k = 0; k < keys.length; k++) {\n out[keys[k]] = snapshotValue(value[keys[k]], stack, depth + 1);\n }\n }\n stack.pop();\n return out;\n }\n\n /**\n * Plain snapshot of a scope's DATA. Magics ($el, $refs, $store, …) are\n * non-enumerable by construction, so they never appear — a snapshot is what\n * the author put in `l-data` plus `data-prop-*`, as it stands right now.\n * Reading happens outside any effect, so it registers no dependencies.\n */\n function snapshotScope(scope) {\n if (!scope) return null;\n var out = {};\n var keys = Object.keys(scope);\n for (var i = 0; i < keys.length; i++) {\n // `__`-prefixed keys are engine plumbing (`__faqirTeardown`), not data an\n // agent inspecting the page should have to reason about.\n if (keys[i].slice(0, 2) === '__') continue;\n out[keys[i]] = snapshotValue(scope[keys[i]], [], 0);\n }\n return out;\n }\n\n /** Short human label for an element: `div#cart[data-ui=\"card\"]`. */\n function describeElement(el) {\n if (!el) return null;\n var label = el.tagName ? el.tagName.toLowerCase() : String(el);\n if (el.id) label += '#' + el.id;\n var ui = el.getAttribute ? el.getAttribute('data-ui') : null;\n if (ui) label += '[data-ui=\"' + ui + '\"]';\n var part = el.getAttribute ? el.getAttribute('data-part') : null;\n if (part) label += '[data-part=\"' + part + '\"]';\n return label;\n }\n\n /** The nearest ancestor-or-self carrying a live scope, or null. */\n function ownScopeRoot(el) {\n for (var node = el; node; node = node.parentElement) {\n if (node.__faqirScope) return node;\n }\n return null;\n }\n\n /** The five protocol attributes as they read from `el` / its `[data-ui]`. */\n function protocolState(el, uiEl) {\n var attr = function(node, name) {\n return node && node.getAttribute ? node.getAttribute(name) : null;\n };\n return {\n ui: attr(uiEl, 'data-ui'),\n part: attr(el, 'data-part'),\n variant: attr(uiEl, 'data-variant'),\n size: attr(uiEl, 'data-size'),\n state: attr(uiEl, 'data-state')\n };\n }\n\n /**\n * Everything Faqir knows about one element. [task 0.7-12 · §A6]\n *\n * @param {Element|string} target element, or a selector resolved against document\n * @returns {null|{\n * el: Element,\n * scopeRoot: Element|null,\n * scopeId: number|null,\n * scope: object|null,\n * directives: {type,arg,expression,modifiers,raw}[],\n * controller: {ui,el,api,methods}|null,\n * state: {ui,part,variant,size,state}\n * }}\n */\n function inspect(target) {\n var el = target;\n if (typeof target === 'string') {\n el = typeof document !== 'undefined' ? document.querySelector(target) : null;\n }\n if (!el || el.nodeType !== 1) return null;\n\n var root = ownScopeRoot(el);\n var uiEl = closestUI(el);\n var api = uiEl ? getControllerApi(uiEl) : null;\n\n var directives = parseDirectives(el).map(function(d) {\n return {\n type: d.type,\n arg: d.arg == null ? null : d.arg,\n expression: d.expression,\n modifiers: d.modifiers ? d.modifiers.slice() : [],\n raw: d.raw\n };\n });\n\n return {\n el: el,\n scopeRoot: root,\n scopeId: root && root.__scopeId != null ? root.__scopeId : null,\n scope: root ? snapshotScope(root.__faqirScope) : null,\n directives: directives,\n controller: uiEl && api\n ? {\n ui: uiEl.getAttribute('data-ui'),\n el: uiEl,\n api: api,\n methods: Object.keys(api).filter(function(k) {\n return typeof api[k] === 'function';\n }).sort()\n }\n : null,\n state: protocolState(el, uiEl)\n };\n }\n\n /**\n * `window.__FAQIR_DEVTOOLS__` — the stable handle agents and the `faqir dev`\n * overlay read. Keys never change shape between builds; only `dev` flips.\n */\n var devtools = {\n /** Handle schema version. Bumped only on a breaking shape change. */\n version: 1,\n /** true in `faqir-core.dev.js`, false in the production engine. */\n dev: false,\n /** The Faqir global itself (assigned once the public API is built). */\n faqir: null,\n inspect: inspect,\n /**\n * Declared scope roots in document order: elements with `l-data` (or a\n * standalone `[data-ui]`) that carry a live scope. Per-item scopes made by\n * `l-for`/`l-if` are reachable with `inspect()` on any node inside them.\n */\n scopes: function(within) {\n var host = within || (typeof document !== 'undefined' ? document : null);\n if (!host) return [];\n var els = [].slice.call(host.querySelectorAll('[l-data], [data-ui]'));\n var out = [];\n for (var i = 0; i < els.length; i++) {\n if (!els[i].__faqirScope) continue;\n out.push({\n el: els[i],\n id: els[i].__scopeId != null ? els[i].__scopeId : null,\n label: describeElement(els[i]),\n scope: snapshotScope(els[i].__faqirScope)\n });\n }\n return out;\n },\n /** Every mounted component, with its protocol attributes and its parts. */\n components: function(within) {\n var host = within || (typeof document !== 'undefined' ? document : null);\n if (!host) return [];\n var els = [].slice.call(host.querySelectorAll('[data-ui]'));\n var out = [];\n for (var i = 0; i < els.length; i++) {\n var el = els[i];\n var partEls = [].slice.call(el.querySelectorAll('[data-part]'));\n var parts = [];\n for (var p = 0; p < partEls.length; p++) {\n if (partEls[p].closest('[data-ui]') !== el) continue;\n var name = partEls[p].getAttribute('data-part');\n if (parts.indexOf(name) === -1) parts.push(name);\n }\n out.push({\n el: el,\n label: describeElement(el),\n ui: el.getAttribute('data-ui'),\n variant: el.getAttribute('data-variant'),\n size: el.getAttribute('data-size'),\n state: el.getAttribute('data-state'),\n parts: parts.sort(),\n controller: !!getControllerApi(el)\n });\n }\n return out;\n },\n /** Snapshot of every `Faqir.store()` registered on the page. */\n stores: function() {\n var out = {};\n var names = Object.keys(globalStores);\n for (var i = 0; i < names.length; i++) {\n out[names[i]] = snapshotValue(globalStores[names[i]], [], 0);\n }\n return out;\n },\n /**\n * Diagnostics recorded so far, oldest first. Always an array: the\n * production engine records nothing, so it is always empty there.\n */\n warnings: function() { return devHooks ? devHooks.warnings() : []; },\n /**\n * Record one diagnostic on a plugin's behalf. The dev build prints it and\n * keeps it in `warnings()` (deduped like every other); production does\n * nothing and answers `false`. A plugin is a separate file with no reach\n * into this seam's other side, so without it a plugin can only be silent\n * or noisy in a shipped page — and \"silent\" is what the contract forbids.\n * [1.1B-03]\n */\n report: function(message, el) {\n return false;\n }\n };\n\n\n\n // ═══════════════════════════════════════════════════════\n // Section 9: Bootstrap & Auto-init\n // ═══════════════════════════════════════════════════════\n\n // Mount one controller, containing any failure to that component.\n //\n // Controllers are invoked in a bare loop during bootstrap. A controller that\n // throws — the usual cause is markup missing a part it queries for, which an\n // agent generating HTML produces routinely — used to abort bootstrap entirely:\n // no scopes, no directives, no Faqir global, every unrelated island on the page\n // left blank. One incomplete component must break that component and nothing\n // else, and the failure has to be visible rather than silent.\n function initController(name, el) {\n try {\n controllerRegistry[name](el);\n } catch (err) {\n console.error('[Faqir] Controller \"' + name + '\" failed to initialize', el, err);\n }\n }\n\n // The document's one MutationObserver, or null before the first bootstrap,\n // and the <body> it is currently watching.\n var mutationObserver = null;\n var observedBody = null;\n\n function bootstrap() {\n injectCloakStyle();\n\n // Auto-init controllers for all [data-ui] elements\n var names = Object.keys(controllerRegistry);\n for (var n = 0; n < names.length; n++) {\n var els = document.querySelectorAll('[data-ui=\"' + names[n] + '\"]');\n for (var e = 0; e < els.length; e++) {\n initController(names[n], els[e]);\n }\n }\n\n // Find all scope roots.\n // l-data elements always create a scope.\n // data-ui elements only create a scope when standalone (no l-data ancestor).\n var roots = document.querySelectorAll('[l-data], [data-ui]');\n var processed = new Set();\n\n for (var r = 0; r < roots.length; r++) {\n var rootEl = roots[r];\n if (processed.has(rootEl)) continue;\n\n // Already initialized — by an earlier `Faqir.start()`, or by the\n // MutationObserver. Re-running `initTree` over it would build a second\n // scope and apply every directive on top of the first: `start()` twice\n // meant every `@click` handler fired twice, every `l-effect` ran twice\n // and every `l-source` fetched twice. Markup added since the last call\n // still has no scope, so it is still picked up — which is the only reason\n // to call `start()` again. [W3-1]\n if (rootEl.__faqirScope) {\n processed.add(rootEl);\n var seen = rootEl.querySelectorAll('[l-data]');\n for (var sd = 0; sd < seen.length; sd++) processed.add(seen[sd]);\n continue;\n }\n\n // Skip if nested inside an unprocessed ancestor l-data scope\n var ancestor = rootEl.parentElement;\n var skipThis = false;\n while (ancestor) {\n if (ancestor.hasAttribute('l-data') && !processed.has(ancestor)) {\n skipThis = true;\n break;\n }\n ancestor = ancestor.parentElement;\n }\n\n // data-ui elements without l-data only need a scope if they are standalone\n // (not inside any l-data). If inside an l-data, they inherit that scope via walkChildren.\n if (!skipThis && !rootEl.hasAttribute('l-data') && rootEl.hasAttribute('data-ui')) {\n // Check if this data-ui is inside a processed l-data scope — if so, skip\n var lDataAncestor = rootEl.parentElement;\n while (lDataAncestor) {\n if (lDataAncestor.hasAttribute('l-data') && processed.has(lDataAncestor)) {\n skipThis = true;\n break;\n }\n lDataAncestor = lDataAncestor.parentElement;\n }\n }\n\n if (!skipThis) {\n initTree(rootEl, null);\n var descendants = rootEl.querySelectorAll('[l-data]');\n for (var d = 0; d < descendants.length; d++) processed.add(descendants[d]);\n processed.add(rootEl);\n }\n }\n\n // Everything the scope-root pass did not claim. [W2-1]\n walkUnscoped(document.body, getStrayScope());\n\n // Second controller sweep: structural directives (l-for / l-if) may have\n // rendered recipe markup synchronously during the initTree pass above —\n // after the first sweep ran and before the MutationObserver below starts.\n // Controllers are double-init guarded, so re-invoking is a no-op for\n // elements initialized by the first sweep.\n for (var n2 = 0; n2 < names.length; n2++) {\n var els2 = document.querySelectorAll('[data-ui=\"' + names[n2] + '\"]');\n for (var e2 = 0; e2 < els2.length; e2++) {\n initController(names[n2], els2[e2]);\n }\n }\n\n removeCloaks();\n\n // MutationObserver for dynamically added elements. ONE per document: a\n // second `Faqir.start()` used to install another, and every observer then\n // initialized every added node again — the same handler running twice per\n // insertion, which is how one `Faqir.start()` too many double-fired\n // everything on the page. Re-observed only if `document.body` itself was\n // replaced, which is what a test harness swapping bodies does. [W3-1]\n if (mutationObserver && observedBody === document.body) return;\n if (mutationObserver) {\n observedBody = document.body;\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n return;\n }\n observedBody = document.body;\n\n mutationObserver = new MutationObserver(function(mutations) {\n for (var i = 0; i < mutations.length; i++) {\n var addedNodes = mutations[i].addedNodes;\n for (var j = 0; j < addedNodes.length; j++) {\n var node = addedNodes[j];\n if (node.nodeType !== 1) continue;\n\n // Content that arrives after bootstrap has already bound by the time\n // it is here; leaving `l-cloak` on it means the injected rule hides\n // it forever. [W3-1]\n removeCloaks(node);\n\n var uiName = node.getAttribute ? node.getAttribute('data-ui') : null;\n if (uiName && controllerRegistry[uiName]) {\n initController(uiName, node);\n }\n\n // Already initialized — by `Faqir.start()` / `Faqir.initTree()` in the\n // same task that inserted it (the record is only delivered on the\n // next microtask), or by the l-for / l-if render that stamped it.\n // Re-running `initTree` would build a second scope and bind every\n // directive twice — the same guard `bootstrap` applies. [1.1A-23]\n if (node.__faqirScope) {\n // fall through to the descendant sweep below\n } else if (node.hasAttribute && node.hasAttribute('l-data')) {\n initTree(node, findParentScope(node));\n } else if (node.hasAttribute && node.hasAttribute('data-ui') && !findParentScope(node)) {\n // Standalone data-ui (no parent scope) — create its own scope\n initTree(node, null);\n }\n\n if (node.querySelectorAll) {\n var cNames = Object.keys(controllerRegistry);\n for (var cn = 0; cn < cNames.length; cn++) {\n var cEls = node.querySelectorAll('[data-ui=\"' + cNames[cn] + '\"]');\n for (var ce = 0; ce < cEls.length; ce++) initController(cNames[cn], cEls[ce]);\n }\n var scopeEls = node.querySelectorAll('[l-data]');\n for (var se = 0; se < scopeEls.length; se++) {\n if (!scopeEls[se].__faqirScope) {\n initTree(scopeEls[se], findParentScope(scopeEls[se]));\n }\n }\n }\n\n // Directives on a node dropped in outside every scope root — the same\n // blind spot bootstrap's sweep closes, for nodes that arrive later.\n //\n // `isConnected` matters: a mutation record is delivered as a microtask,\n // by which time the node it reports may already have been consumed —\n // `l-for` and `l-if` replace their own `<template>` with an anchor, and\n // that template arrives here detached.\n if (node.isConnected !== false && !node.__faqirScope && !findParentScope(node)) {\n var strayHost = getStrayScope();\n processElement(node, strayHost);\n if (node.parentNode) walkUnscoped(node, strayHost);\n }\n }\n }\n });\n\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n }\n\n // Auto-start logic\n var currentScript = typeof document !== 'undefined' ? document.currentScript : null;\n var isManual = currentScript && currentScript.hasAttribute('data-manual');\n\n if (!isManual && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', bootstrap);\n } else {\n bootstrap();\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Public API\n // ═══════════════════════════════════════════════════════\n\n var Faqir = {\n // @faqir:version — `scripts/build-core.mjs` rewrites this literal from the\n // root package.json at assembly time. It drifted three minor versions the\n // one time it was hand-maintained (0.1.0 in a package versioned 0.2.4), so\n // the built artifact is now the only place the number is authoritative and\n // the build fails if this marker goes missing.\n version: '1.1.0', // @faqir:version\n reactive: reactive,\n effect: effect,\n batch: batch,\n untrack: untrack,\n evaluate: evaluate,\n evaluateAssignment: evaluateAssignment,\n nextTick: function(fn) { return queueMicrotask(fn || function() {}); },\n data: function(name, factory) { dataRegistry.set(name, factory); },\n store: function(name, obj) { globalStores[name] = reactive(obj); },\n directive: function(name, handler) { customDirectives.set(name, handler); },\n magic: function(name, callback) { customMagics.set(name, callback); },\n plugin: function(fn) { fn(Faqir); },\n controller: function(name, factory) { controllerRegistry[name] = factory; },\n start: bootstrap,\n initTree: initTree,\n // Snapshot of Faqir's view of one element — scope, directives, controller,\n // protocol attributes. [0.7-12]\n inspect: inspect,\n // The same object installed at window.__FAQIR_DEVTOOLS__. Exposed here too\n // so code holding a specific engine instance (a bundler import, a test\n // loading one build) reaches ITS handle rather than whichever engine\n // touched the global last. [0.7-12]\n devtools: devtools,\n // Run the cleanups registered on `el` and its descendants (l-source abort +\n // poll teardown, effect disposers, …). Structural directives call this\n // automatically on l-if hide / keyed l-for removal; exposed for imperative\n // teardown of a subtree. [0.3-08]\n destroy: destroyScope\n };\n\n // The devtools handle is installed on every page that loads either build —\n // agents read it without knowing how Faqir was bundled. [0.7-12]\n devtools.faqir = Faqir;\n if (typeof window !== 'undefined') {\n window.__FAQIR_DEVTOOLS__ = devtools;\n }\n\n return Faqir;\n});\n",
|
|
5
|
+
"// ============================================================================\n// registry/core/faqir-core.js\n//\n// GENERATED FILE — DO NOT EDIT BY HAND.\n// Assembled by scripts/build-core.mjs (task 0.3-03) from:\n// engine: src/core-src/engine.js\n// core helper: registry/core/menu-navigation.js\n// controllers: 29 recipe factories → accordion, alert-dialog, barcode, calendar, carousel, combobox, command-palette, context-menu, date-picker, dialog, drawer, dropdown, file-upload, input-otp, menubar, pagination, popover, qr-code, select-custom, sheet, sidebar, slider, table, tabs, tag-input, toast, toggle-group, tooltip, tree-view\n//\n// PRODUCTION BUILD — dev-only diagnostics stripped at assembly time.\n// Load faqir-core.dev.js instead while developing for full warnings.\n// Regenerate with: bun run build:core\n// Package version: 1.1.2\n// ============================================================================\n\n/**\n * Faqir Core — the running version is `Faqir.version` (stamped at build time).\n * Alpine-style reactivity for the Faqir UI component system.\n * Zero dependencies. CDN-ready. Agent-native.\n *\n * Usage:\n * <script src=\"faqir-core.js\"></script>\n * — or —\n * <script src=\"faqir-core.js\" type=\"module\"></script>\n * — or —\n * import Faqir from './faqir-core.js'\n */\n(function(global, factory) {\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n define(factory);\n } else {\n var Faqir = factory();\n global.Faqir = Faqir;\n if (typeof globalThis !== 'undefined') globalThis.Faqir = Faqir;\n }\n})(typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : this, function() {\n 'use strict';\n\n // ═══════════════════════════════════════════════════════\n // Section 0: Dev-build seam [task 0.7-12]\n // ═══════════════════════════════════════════════════════\n //\n // `faqir-core.js` (production) and `faqir-core.dev.js` are assembled from THIS\n // one source by scripts/build-core.mjs. Three markers decide what each build\n // keeps:\n //\n // the WHOLE LINE is dropped for production.\n // // @faqir:dev-start … end — the same, for a multi-line region.\n // // @faqir:dev-diagnostics — replaced by src/core-src/dev-diagnostics.js\n // in the dev build, dropped in production.\n //\n // Every dev-only message string therefore lives in dev-diagnostics.js and\n // never reaches the production file (proved by tests/build/dev-build.test.ts).\n //\n // `devHooks` is the only seam: null in production, an object of reporters in\n // the dev build. Call sites read `if (devHooks)` on a dev-marked line, so\n // production carries neither the guard nor the message.\n var devHooks = null;\n\n // ═══════════════════════════════════════════════════════\n // Section 1: Reactive Engine\n // ═══════════════════════════════════════════════════════\n\n let currentEffect = null;\n const effectStack = [];\n let batchDepth = 0;\n const pendingEffects = new Set();\n let flushScheduled = false;\n\n const reactiveMap = new WeakMap();\n const ARRAY_MUTATORS = new Set(['push', 'pop', 'splice', 'shift', 'unshift', 'sort', 'reverse']);\n\n function reactive(obj) {\n if (obj.__isReactive) return obj;\n if (reactiveMap.has(obj)) return reactiveMap.get(obj);\n\n const deps = Object.create(null);\n\n const proxy = new Proxy(obj, {\n get(target, key, receiver) {\n if (key === '__isReactive') return true;\n if (key === '__deps') return deps;\n if (key === '__target') return target;\n\n if (currentEffect && typeof key === 'string') {\n if (!deps[key]) deps[key] = new Set();\n deps[key].add(currentEffect);\n currentEffect._deps.add(deps[key]);\n }\n\n const value = Reflect.get(target, key, receiver);\n\n // Intercept array mutation methods to trigger 'length' deps,\n // since internal length updates bypass the setter's change check.\n if (Array.isArray(target) && typeof value === 'function' && ARRAY_MUTATORS.has(key)) {\n return function() {\n const result = value.apply(target, arguments);\n if (deps['length']) {\n for (const eff of deps['length']) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n return result;\n };\n }\n\n // Deep reactivity: wrap nested arrays and plain objects so that\n // mutations like array.push() / array.splice() trigger effects.\n if (value !== null && typeof value === 'object'\n && !value.__isReactive\n && (Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype)) {\n return reactive(value);\n }\n\n return value;\n },\n\n set(target, key, value, receiver) {\n const oldValue = target[key];\n const result = Reflect.set(target, key, value, receiver);\n\n if (oldValue !== value && deps[key]) {\n for (const eff of deps[key]) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n\n return result;\n }\n });\n\n reactiveMap.set(obj, proxy);\n return proxy;\n }\n\n function effect(fn) {\n const execute = () => {\n cleanup(execute);\n\n currentEffect = execute;\n effectStack.push(execute);\n\n try {\n fn();\n } finally {\n effectStack.pop();\n currentEffect = effectStack[effectStack.length - 1] || null;\n }\n };\n\n execute._deps = new Set();\n execute();\n\n return () => cleanup(execute);\n }\n\n function cleanup(execute) {\n for (const depSet of execute._deps) {\n depSet.delete(execute);\n }\n execute._deps.clear();\n }\n\n function scheduleFlush() {\n if (batchDepth > 0) return;\n if (flushScheduled) return;\n flushScheduled = true;\n queueMicrotask(flushEffects);\n }\n\n function flushEffects() {\n flushScheduled = false;\n var iterations = 0;\n while (pendingEffects.size > 0) {\n // Effects that keep re-triggering each other (a writes b, b writes a)\n // would loop forever. The cap stops that, but dropping work silently\n // hides the bug, so it is reported in every build.\n if (++iterations > 100) {\n console.warn('[Faqir] Effect loop: dropped ' + pendingEffects.size + ' effect(s) after 100 flushes; effects keep re-triggering each other');\n pendingEffects.clear();\n break;\n }\n var effects = [...pendingEffects];\n pendingEffects.clear();\n for (var i = 0; i < effects.length; i++) {\n try {\n effects[i]();\n } catch (e) {\n console.warn('[Faqir] Effect error:', e);\n }\n }\n }\n }\n\n function batch(fn) {\n batchDepth++;\n try {\n fn();\n } finally {\n batchDepth--;\n if (batchDepth === 0) {\n flushEffects();\n }\n }\n }\n\n function untrack(fn) {\n const prev = currentEffect;\n currentEffect = null;\n try {\n return fn();\n } finally {\n currentEffect = prev;\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 2: Expression Evaluator\n // ═══════════════════════════════════════════════════════\n\n const expressionCache = new Map();\n\n function evaluate(expression, scope, el) {\n try {\n const fn = compileExpression(expression);\n return fn.call(scope, scope, el, el);\n } catch (e) {\n console.warn('[Faqir] Expression error: \"' + expression + '\"', e);\n return undefined;\n }\n }\n\n function evaluateAssignment(expression, scope, el) {\n try {\n const fn = compileStatement(expression);\n fn.call(scope, scope, el, el);\n } catch (e) {\n console.warn('[Faqir] Statement error: \"' + expression + '\"', e);\n }\n }\n\n // Write a value into a scope property WITHOUT putting the value into source.\n //\n // l-model used to build \"prop = '\" + value + \"'\" and compile it, which meant\n // (a) anything typed into an input was executed as JavaScript, (b) a backslash\n // or newline silently corrupted or broke the write, and (c) every distinct\n // value compiled and permanently cached its own Function. Passing the value\n // through a reserved scope slot — the same trick handleOn uses for $event —\n // fixes all three: one compiled statement per binding, and user data is never\n // parsed as code.\n function writeModel(prop, value, scope, el) {\n scope.$modelValue = value;\n try {\n evaluateAssignment(prop + ' = $modelValue', scope, el);\n } finally {\n delete scope.$modelValue;\n }\n }\n\n // `$el` and `$this` are both the element the directive is written on. Inside\n // `with($scope)` the scope's own `$el` magic (the root) wins, so `$el` only\n // reaches this parameter where nothing shadows it: a top-level `l-data`,\n // evaluated against `{}`. `$this` is never a scope key, so it always reaches\n // it. [1.1F-06]\n function compileExpression(expr) {\n var key = 'expr:' + expr;\n if (expressionCache.has(key)) return expressionCache.get(key);\n\n var fn = new Function(\n '$scope', '$el', '$this',\n 'with($scope) { return (' + expr + ') }'\n );\n expressionCache.set(key, fn);\n return fn;\n }\n\n function compileStatement(expr) {\n var key = 'stmt:' + expr;\n if (expressionCache.has(key)) return expressionCache.get(key);\n\n var fn = new Function(\n '$scope', '$el', '$this',\n 'with($scope) { ' + expr + ' }'\n );\n expressionCache.set(key, fn);\n return fn;\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 3: Directive System\n // ═══════════════════════════════════════════════════════\n\n // --- Shared state ---\n var scopeCounter = 0;\n var dataRegistry = new Map();\n var customDirectives = new Map();\n var globalStores = {};\n\n // --- 3.0 Declared vocabulary [task 1.0R-03] ---\n //\n // The engine's public surface, declared once, in comments only — the minifier\n // drops them, so this costs zero shipped bytes. `src/generator/skill.ts` reads\n // these lines into `.claude/skills/faqir-creator/references/directives.md`, so\n // the reference an agent is sent to is not a transcription: add a line here\n // and the row appears. `tests/generator/skill.test.ts` greps this file for\n // every `l-…` and `$…` name it mentions and fails on any the engine\n // implements without a line below — which is why something that is NOT public\n // vocabulary (the evaluator's own `$scope` binding) is declared `internal`\n // with its reason rather than left out.\n //\n // Fields are ` | `-separated; never use `|` inside one.\n // @ui:directive <attribute> | <shorthand> | <placement> | <example> | <what it does>\n // @ui:modifier <attribute> <.modifier> | <what it does>\n // @ui:magic $<name> | <where it resolves> | <what it is>\n //\n // The three lists that already exist as code — PRIORITY (§3.2), KEY_MAP\n // (§3.9) and MOTION_PRESETS (§3.14) — are read from the code itself, not\n // repeated here.\n //\n // @ui:directive l-data | — | any element, which becomes the scope root | l-data=\"{ count: 0 }\" | Declares a reactive scope from an object literal, or from a name registered with `Faqir.data()`. `data-prop-*` attributes are JSON-parsed and merged over it. Descendants share the scope until the next `l-data`. Its methods are bound to the scope, so `this` is the component even when an `l-for` row calls them; a function assigned later is not bound.\n // @ui:directive l-init | — | a scope root, beside `l-data` | l-init=\"load()\" | Runs once, after the scope exists and its `l-source` bindings are injected, with the subtree's controllers already started. In `l-if` / `l-for` content it runs after insertion: bindings, insert, controllers, then `l-init` / first `l-effect`.\n // @ui:directive l-source:<name> | — | a scope root, beside `l-data` | l-source:tasks=\"/api/tasks\" | Binds a REST collection into the scope as `<name>`, `<name>Loading`, `<name>Error` and the `$<name>` CRUD controller. See below.\n // @ui:directive l-text | — | any element | l-text=\"count\" | Writes the value to `textContent`; `null` and `undefined` write an empty string.\n // @ui:directive l-html | — | any element | l-html=\"body\" | Writes the value to `innerHTML`, unsanitized — never pass user input. The dev engine reports every use.\n // @ui:directive l-bind:<attr> | :<attr> | any element | :disabled=\"loading\" | Binds one attribute. `class` and `style` take a string, an array or an object and merge with what is there: each run removes only what its previous run set, so static markup, `l-show` and controllers keep theirs. Boolean attributes are added or removed; `null`, `undefined` and `false` remove the attribute.\n // @ui:directive l-on:<event> | @<event> | any element | @click=\"count++\" | Adds a listener for `<event>`. Inside the expression `$event` is the DOM event.\n // @ui:directive l-model | — | an input, textarea or select, or `[data-ui=\"switch\"]` | l-model=\"name\" | Two-way binding. A checkbox bound to an array is a checkbox group; radios bind by value; `<select multiple>` is not handled. The modifiers below apply to the text-like branch (input, textarea, number) only.\n // @ui:directive l-show | — | any element | l-show=\"open\" | Toggles `display: none`, leaving the element in the DOM. Runs `l-transition` on each flip.\n // @ui:directive l-if | — | a `<template>` element | <template l-if=\"open\"> | Inserts and removes the template's content. Removal tears the subtree down: cleanups run and in-flight `l-source` requests abort.\n // @ui:directive l-for | — | a `<template>` element | <template l-for=\"(task, i) in tasks\"> | Repeats the template's content once per item, with the item and index names bound in a child scope.\n // @ui:directive l-key | — | the same `<template>` as `l-for` | l-key=\"task.id\" | The reconciliation key. Without it items are matched by position, so a reorder re-renders rather than moves; the dev engine reports that case.\n // @ui:directive l-ref | — | any element | l-ref=\"field\" | Registers the element on the scope's `$refs` under that name — also from inside `l-if`, `l-for` and `l-teleport`, where the scope is the enclosing one. In an `l-for` the last row rendered wins, and the ref is cleared when that row goes. Effects that read it re-run when it appears or goes.\n // @ui:directive l-effect | — | any element | l-effect=\"document.title = title\" | Runs the expression immediately, then again whenever a value it read changes.\n // @ui:directive l-cloak | — | any element | l-cloak | Removed from every element once the tree is initialized. Faqir's CSS (`base/reset.css`) hides `[l-cloak]` until then; the engine injects no style, so a page without that CSS needs its own `[l-cloak] { display: none }` rule.\n // @ui:directive l-transition | — | an `l-show` element, or a top-level element inside a `<template l-if>` | l-transition=\"slide-up\" | Names the motion preset for that element's enter/leave cycle. The engine only stamps `data-motion`; the CSS animates.\n // @ui:directive l-teleport | — | any element | l-teleport=\"body\" | Moves the element into the first element matching the value, which is a plain CSS selector rather than an expression.\n //\n // @ui:modifier l-model .number | Casts the input value with `parseFloat` (`0` when it does not parse).\n // @ui:modifier l-model .trim | Trims the input value before assigning.\n // @ui:modifier l-model .lazy | Binds on `change` instead of `input`.\n // @ui:modifier l-model .debounce | Debounces the write by 300ms. Fixed — unlike `l-on`, this one reads no time.\n // @ui:modifier l-on .prevent | `preventDefault()` before the expression runs.\n // @ui:modifier l-on .stop | `stopPropagation()` before the expression runs.\n // @ui:modifier l-on .self | Ignores the event unless `event.target` is the element itself.\n // @ui:modifier l-on .once | Listener option `once` — removed after it fires.\n // @ui:modifier l-on .capture | Listener option `capture`.\n // @ui:modifier l-on .passive | Listener option `passive`.\n // @ui:modifier l-on .window | Listens on `window` instead of the element.\n // @ui:modifier l-on .document | Listens on `document` instead of the element.\n // @ui:modifier l-on .debounce | Debounces the handler, 250ms by default. A custom time is part of the same modifier — `.debounce500ms`, `.debounce2s`. A dotted `.debounce.500ms` is TWO modifiers and the time is ignored.\n // @ui:modifier l-on .throttle | Throttles the handler, 250ms by default. Takes a time the same way — `.throttle1s`.\n // @ui:modifier l-source .lazy | Skips the load on init — the collection stays empty until `$<name>.load()`.\n // @ui:modifier l-source .optimistic | Applies create/update/remove to the local array first and rolls back if the request fails.\n // @ui:modifier l-source .poll | Re-loads on an interval, 30000ms by default. Takes the interval: `.poll.5000`.\n // @ui:modifier l-source .key | Names the identity property, `id` by default: `.key.uuid`.\n //\n // @ui:magic $el | every expression | The scope ROOT — the element carrying `l-data`, not the element the expression is written on. Every magic that walks the DOM starts from here.\n // @ui:magic $this | every expression | The element the directive is written on — the `<input>` carrying `l-init`, the button carrying `@click`. In `l-data` and a root's `l-init` it is the root; in `l-for`'s list and `l-key` expressions, the `<template>`. Not a scope key, so `Faqir.magic()` cannot shadow it.\n // @ui:magic $refs | every expression | The scope's `l-ref` elements, keyed by name. Cleared entry by entry as elements are destroyed.\n // @ui:magic $store | every expression | Every store registered with `Faqir.store()`.\n // @ui:magic $state | every expression | `data-state` of the `[data-ui]` closest to the scope root. Writable — assigning sets the attribute — and reads re-run when a controller changes it.\n // @ui:magic $variant | every expression | `data-variant` of the same `[data-ui]`, writable and observed the same way.\n // @ui:magic $ui | every expression | The controller API of that same `[data-ui]` — `$ui.open()`. Also callable, to reach ANOTHER component's controller by CSS selector: `$ui('#detail-drawer').open()`, which returns `null` when nothing matches or the match has no controller.\n // @ui:magic $dispatch | every expression | `$dispatch('name', detail)` fires a bubbling, composed `CustomEvent` from the scope root.\n // @ui:magic $nextTick | every expression | `$nextTick(fn)` queues `fn` as a microtask, so it runs after the effects a mutation queued have flushed and the DOM is updated.\n // @ui:magic $watch | every expression | `$watch('key', function (value, old) { … })` — returns a disposer.\n // @ui:magic $id | every expression | `$id('label')` returns `faqir-<scope>-label`, stable for the scope and unique across scopes.\n // @ui:magic $event | `l-on` expressions only | The DOM event being handled. Set for the duration of the handler and deleted again after it, so it reads as `undefined` anywhere else.\n // @ui:magic $scope | internal | the evaluator compiles every expression to `with($scope) { … }`, so the name runs through the engine source as that compiled function's own parameter. Page code never writes it.\n // @ui:magic $modelValue | internal | `l-model`'s transport slot. The value a control produces is placed here and the assignment compiles to `prop = $modelValue`, so what the user typed is never spliced into source and never reaches the compiler. Set for the duration of one write and deleted after it; page code never sees it.\n //\n // --- 3.1 Attribute Parsing ---\n\n function parseDirectives(el) {\n var directives = [];\n\n for (var i = 0; i < el.attributes.length; i++) {\n var attr = el.attributes[i];\n var name = attr.name;\n var directive = null;\n\n if (name.startsWith('l-')) {\n if (name.startsWith('l-bind:')) {\n var rest = name.slice(7);\n var parts = rest.split('.');\n directive = {\n type: 'bind',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else if (name.startsWith('l-on:')) {\n var rest = name.slice(5);\n var parts = rest.split('.');\n directive = {\n type: 'on',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else if (name.startsWith('l-source:')) {\n var rest = name.slice(9);\n var parts = rest.split('.');\n directive = {\n type: 'source',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else {\n var rest = name.slice(2);\n var parts = rest.split('.');\n directive = {\n type: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n }\n } else if (name.startsWith(':')) {\n var rest = name.slice(1);\n var parts = rest.split('.');\n directive = {\n type: 'bind',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n } else if (name.startsWith('@')) {\n var rest = name.slice(1);\n var parts = rest.split('.');\n directive = {\n type: 'on',\n arg: parts[0],\n expression: attr.value,\n modifiers: parts.slice(1),\n raw: name\n };\n }\n\n if (directive) directives.push(directive);\n }\n\n return directives;\n }\n\n // --- 3.2 Directive Priority ---\n\n var PRIORITY = {\n 'data': 1,\n 'source': 1,\n 'for': 2,\n 'if': 3,\n 'bind': 10,\n 'on': 10,\n 'text': 10,\n 'html': 10,\n 'model': 10,\n 'show': 10,\n 'transition': 10,\n 'ref': 10,\n 'init': 20,\n 'effect': 20,\n 'cloak': 100,\n 'teleport': 100\n };\n\n // --- 3.3 DOM Tree Walker ---\n\n // Directives `initScope` has already consumed by the time `initTree` gets to\n // apply the rest. Everything else written on a scope root has to be applied\n // HERE: `walkChildren` visits descendants only, so a directive on the root\n // element itself is seen by nobody else. Until 1.0 only plugin directives were\n // run here, which made `l-effect`, `l-on`, `l-text`, `l-show`, `l-bind`,\n // `l-model` and `l-ref` inert — with no error — on the one element the docs\n // point authors at (\"a scope root, beside `l-data`\"). [W2-1]\n var ROOT_CONSUMED = { data: 1, source: 1, init: 1 };\n\n // `l-init` and each `l-effect`'s first run, held back while a structural\n // render builds content that is not in the document yet. [1.1F-03]\n var pendingInits = null;\n\n function runInit(fn) {\n if (pendingInits) pendingInits.push(fn); else fn();\n }\n\n // `l-if` / `l-for` content ran its `l-init` and its effects' first pass while\n // still detached — before insertion, and before any controller inside it had\n // started — so `$ui('#x')` there was null, and an effect that read nothing\n // reactive never ran again. `render` binds and inserts, and returns the nodes\n // it inserted; their controllers start next, and only then does the held work\n // run: bindings → insertion → controllers → `l-init` / `l-effect`. A render\n // nested inside another (an `l-if` in an `l-for` row) joins the outer one,\n // which alone knows when the content is attached. Controllers are not started\n // on content that is still detached. Untracked, so nothing the held work reads\n // subscribes the structural effect that rendered it. [1.1F-03]\n function renderThenInit(render) {\n if (pendingInits) return render();\n var queue = pendingInits = [];\n var nodes;\n try { nodes = render(); } finally { pendingInits = null; }\n untrack(function() {\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].nodeType === 1 && nodes[i].isConnected) startControllers(nodes[i]);\n }\n for (var q = 0; q < queue.length; q++) queue[q]();\n });\n }\n\n function initTree(root, parentScope) {\n var scope = initScope(root, parentScope);\n\n var rootDirectives = parseDirectives(root);\n rootDirectives.sort(function(a, b) {\n return (PRIORITY[a.type] || 10) - (PRIORITY[b.type] || 10);\n });\n for (var i = 0; i < rootDirectives.length; i++) {\n var rootDir = rootDirectives[i];\n if (ROOT_CONSUMED[rootDir.type]) continue;\n // `l-if` / `l-for` claim the element they sit on and re-render it from a\n // template. A scope root is not a template slot — it is the thing the\n // structural directive would have to destroy — so they stay the parent\n // walk's business and are skipped rather than applied to `root` itself.\n if (rootDir.type === 'if' || rootDir.type === 'for') continue;\n applyDirective(root, rootDir, scope);\n }\n\n walkChildren(root, scope);\n }\n\n function walkChildren(el, scope) {\n var children = [].slice.call(el.children);\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n\n // Skip elements already initialized by l-for or l-if\n if (child.__faqirScope && !child.hasAttribute('l-data')) {\n continue;\n }\n\n // Only l-data creates a new scope boundary.\n // data-ui elements inherit the parent scope so directives\n // inside Faqir components can access the enclosing reactive data.\n if (child.hasAttribute('l-data')) {\n initTree(child, scope);\n continue;\n }\n\n processElement(child, scope);\n // Skip walkChildren if structural directive (l-if/l-for) removed the element\n if (child.parentNode) {\n walkChildren(child, scope);\n }\n }\n }\n\n // Directives that live OUTSIDE every scope root.\n //\n // Bootstrap only ever walked out from `[l-data]` / `[data-ui]` elements, so an\n // attribute on anything else was parsed by nobody. The canonical `l-validate`\n // markup — `<form l-validate>` wrapping a `[data-ui=\"field-group\"]`, straight\n // out of the plugin's own documentation — has no `l-data` anywhere, which is\n // why the plugin looked \"completely inert\": it was registered, the attribute\n // was on the form, and no code path ever reached the form to apply it. Same\n // for a bare `@click` or `l-text` on a page that never declared a scope.\n //\n // This sweep binds them against the implicit document scope. It stops at any\n // element that already owns a scope — that subtree was walked from its own\n // root — so it visits only the parts of the page nothing else claimed. [W2-1]\n function walkUnscoped(el, scope) {\n var children = [].slice.call(el.children);\n for (var i = 0; i < children.length; i++) {\n var child = children[i];\n // `__faqirStray` is this sweep's equivalent of `__faqirScope`: stray\n // elements never get a scope of their own, so without a mark a second\n // `Faqir.start()` re-bound every one of them and each `@click` fired\n // twice. The subtree was walked with it the first time, so skipping the\n // element skips the subtree too. [W3-1]\n if (child.__faqirScope || child.__faqirStray) continue;\n child.__faqirStray = true;\n processElement(child, scope);\n if (child.parentNode) walkUnscoped(child, scope);\n }\n }\n\n // The scope those stray directives evaluate against: empty data, magics rooted\n // at `<body>`. Created once, on first use, so a page with no stray directive\n // pays nothing for it.\n var strayScope = null;\n\n // The element a scope's `$refs` live on, keyed by the scope object. Not\n // `findScopeRoot`: `__faqirScope` also marks \"already initialised\", so an\n // `l-if` clone or an `l-for` row carries it too, and a ref resolved by walking\n // up landed on the clone while `$refs` read the real root — invisible. A\n // teleported element has left the root's subtree, and a stray element has no\n // stamped ancestor at all. A WeakMap rather than a scope property, because a\n // read through the reactive scope inside a structural effect would subscribe\n // it. [1.1F-01]\n var scopeRoots = new WeakMap();\n\n function getStrayScope() {\n if (!strayScope) {\n if (!document.body.__scopeId) document.body.__scopeId = ++scopeCounter;\n if (!document.body.__faqirCleanups) document.body.__faqirCleanups = [];\n // Deliberately NOT stored as `document.body.__faqirScope`: `findParentScope`\n // would then answer \"yes, scoped\" for every element on the page and the\n // MutationObserver would stop giving standalone `[data-ui]` islands their\n // own scope.\n strayScope = createScopeWithMagics({}, document.body, document.body);\n scopeRoots.set(strayScope, document.body);\n }\n return strayScope;\n }\n\n function processElement(el, scope) {\n var directives = parseDirectives(el);\n if (directives.length === 0) return;\n\n directives.sort(function(a, b) {\n return (PRIORITY[a.type] || 10) - (PRIORITY[b.type] || 10);\n });\n\n // Structural directives take over the element — and both anchor a comment\n // where the element stands, so an element that no longer stands anywhere has\n // nothing to do. A `<template l-for>` is replaced by its own anchor the first\n // time it renders, and the MutationObserver is handed that detached template\n // one microtask later. [W2-1]\n for (var i = 0; i < directives.length; i++) {\n if (directives[i].type === 'if') {\n if (el.parentNode) handleIf(el, directives[i], scope);\n return;\n }\n if (directives[i].type === 'for') {\n if (el.parentNode) handleFor(el, directives[i], scope);\n return;\n }\n }\n\n for (var i = 0; i < directives.length; i++) {\n applyDirective(el, directives[i], scope);\n }\n }\n\n // --- 3.4 l-data / Scope Initialization ---\n\n function initScope(root, parentScope) {\n var expr = root.getAttribute('l-data');\n var userData = {};\n\n if (expr) {\n if (dataRegistry.has(expr)) {\n userData = dataRegistry.get(expr)();\n } else if (expr.trim()) {\n userData = evaluate(expr, parentScope || {}, root) || {};\n }\n }\n\n var propData = readProps(root);\n Object.assign(userData, propData);\n\n var scopeId = ++scopeCounter;\n var scope = createScopeWithMagics(userData, root, root);\n scopeRoots.set(scope, root);\n root.__faqirScope = scope;\n root.__scopeId = scopeId;\n root.__faqirCleanups = [];\n\n // A data source spread into `l-data` can own timers, sockets or in-flight\n // requests, and until 1.0 nothing gave it a way to be told the scope had\n // gone: `apiSource()`'s `setInterval` poll and its `fetch` calls simply\n // outlived the element, which on an SPA route change means one live poller\n // per page the user ever visited. Any own `__faqirTeardown` function on the\n // scope data is run on teardown — namespaced so no ordinary data key can be\n // mistaken for one. [W3-1]\n if (typeof userData.__faqirTeardown === 'function') {\n var sourceTeardown = userData.__faqirTeardown;\n addCleanup(root, function() { sourceTeardown(); });\n }\n\n // Set up bidirectional bridge for $state/$variant\n setupStateBridge(root, scope);\n\n // Process l-source directives (inject data + controller into scope)\n processSourceDirectives(root, scope);\n\n var initExpr = root.getAttribute('l-init');\n if (initExpr) {\n runInit(function() { evaluateAssignment(initExpr, scope, root); });\n }\n\n return scope;\n }\n\n function readProps(el) {\n var props = {};\n for (var i = 0; i < el.attributes.length; i++) {\n var attr = el.attributes[i];\n if (attr.name.startsWith('data-prop-')) {\n var key = attr.name.slice(10).replace(/-([a-z])/g, function(_, c) { return c.toUpperCase(); });\n try {\n props[key] = JSON.parse(attr.value);\n } catch (e) {\n props[key] = attr.value;\n }\n }\n }\n return props;\n }\n\n function createScopeWithMagics(data, el, root) {\n var magics = Object.create(null);\n\n Object.defineProperties(magics, {\n $el: { get: function() { return el; }, enumerable: false },\n $refs: { get: function() { return getScopeRefs(root); }, enumerable: false },\n $store: { get: function() { return globalStores; }, enumerable: false },\n $state: {\n get: function() { return closestUI(el) ? closestUI(el).dataset.state : undefined; },\n set: function(v) { var ui = closestUI(el); if (ui) ui.dataset.state = v; },\n enumerable: false\n },\n $variant: {\n get: function() { return closestUI(el) ? closestUI(el).dataset.variant : undefined; },\n set: function(v) { var ui = closestUI(el); if (ui) ui.dataset.variant = v; },\n enumerable: false\n },\n $ui: { get: function() { return uiHandle(el); }, enumerable: false },\n $dispatch: {\n value: function(event, detail) {\n return el.dispatchEvent(\n new CustomEvent(event, { detail: detail, bubbles: true, composed: true })\n );\n },\n enumerable: false\n },\n $nextTick: {\n value: function(fn) { return queueMicrotask(fn || function() {}); },\n enumerable: false\n },\n $watch: {\n value: function(key, cb) {\n var dispose = watchProperty(scope, key, cb);\n // `$watch` handed its disposer back and nothing ever held one, so a\n // watcher created in `l-init` — the documented place to create one —\n // outlived every teardown and kept firing against a dead scope.\n // Registering it here makes `Faqir.destroy()` stop it; the return\n // value still works for callers that dispose by hand. [W3-1]\n addCleanup(root, dispose);\n return dispose;\n },\n enumerable: false\n },\n $id: {\n value: function(name) { return 'faqir-' + root.__scopeId + '-' + name; },\n enumerable: false\n }\n });\n\n // Plugins register a magic without reaching into scope internals. Resolve\n // it lazily so the callback receives the final reactive scope, not the\n // pre-proxy target that exists while this object is being assembled.\n customMagics.forEach(function(callback, name) {\n var key = '$' + name;\n if (Object.prototype.hasOwnProperty.call(magics, key)) return;\n Object.defineProperty(magics, key, {\n get: function() { return callback(el, scope); },\n enumerable: false\n });\n });\n\n // Use defineProperties instead of Object.assign to preserve getters/setters\n // (Object.assign invokes getters and copies the result as a static value).\n var target = Object.create(magics);\n var descriptors = Object.getOwnPropertyDescriptors(data);\n Object.defineProperties(target, descriptors);\n\n var scope = reactive(target);\n // A bare call `pick()` inside `with(rowScope)` gets the l-for row scope as\n // `this`, and that scope owns the loop variable and index: `this.item = x`\n // wrote the row instead of the component. Bind each own method to the\n // scope. Getters keep their receiver; functions assigned later stay\n // unbound. Written to the target, so nothing is triggered. [1.1F-05]\n for (var k in descriptors) {\n var d = descriptors[k];\n if (d.writable && typeof d.value === 'function') target[k] = d.value.bind(scope);\n }\n return scope;\n }\n\n function watchProperty(scope, key, cb) {\n var oldValue = scope[key];\n var dispose = effect(function() {\n var newValue = scope[key];\n if (newValue !== oldValue) {\n var prev = oldValue;\n oldValue = newValue;\n cb(newValue, prev);\n }\n });\n return dispose;\n }\n\n // --- Scope utilities ---\n\n // Created on first read, so an effect that reads a ref before it exists\n // subscribes to the same object `handleRef` later writes through.\n function getScopeRefs(root) {\n return root.__faqirRefs || (root.__faqirRefs = {});\n }\n\n function findScopeRoot(el) {\n var node = el;\n while (node) {\n if (node.__faqirScope) return node;\n node = node.parentElement;\n }\n return el;\n }\n\n // The nearest ancestor (inclusive) that OWNS a cleanup list.\n //\n // A different question from `findScopeRoot`, and the reason four disposers\n // went missing. Cleanup ownership follows the `__faqirCleanups` array —\n // stamped by `initScope`, `handleIf`, `handleFor` and `handleTeleport` —\n // rather than the scope object, because the two do not always sit on the same\n // element: `l-teleport` moves a subtree out of its scope root, so every\n // directive bound underneath it resolved to no owner at all and its disposer\n // was dropped on the floor. [W3-1]\n function findCleanupRoot(el) {\n var node = el;\n while (node) {\n if (node.__faqirCleanups) return node;\n node = node.parentNode;\n }\n return null;\n }\n\n /**\n * Register `cleanupFn` against the element that owns `el`'s teardown.\n *\n * `owner` is the escape hatch for the detached case. `l-if` and `l-for` insert\n * an anchor comment and then `el.remove()` their own `<template>`, so by the\n * time the list effect is registered `el` has no parent, resolves to no owner,\n * and the disposer is discarded — `Faqir.destroy()` could not stop a list that\n * went on re-rendering into the live document after teardown, contradicting\n * what `faqir-core.d.ts` promises. Callers that detach capture the owner\n * BEFORE they do and pass it here. [W3-1]\n */\n function addCleanup(el, cleanupFn, owner) {\n var root = owner || findCleanupRoot(el);\n if (root && root.__faqirCleanups) {\n root.__faqirCleanups.push(cleanupFn);\n }\n }\n\n // Run one node's cleanups exactly once. The list is emptied BEFORE it runs, so\n // a cleanup that tears down its own subtree re-entrantly finds nothing left to\n // do rather than disposing everything twice. One failing disposer must not\n // strand the ones behind it — teardown is the path where a half-finished job\n // is the leak.\n function runCleanups(node) {\n var list = node.__faqirCleanups;\n if (!list || list.length === 0) return;\n node.__faqirCleanups = [];\n for (var i = 0; i < list.length; i++) {\n try {\n list[i]();\n } catch (e) {\n console.error('[Faqir] a cleanup threw during teardown', node, e);\n }\n }\n }\n\n /**\n * Tear down `el` and everything under it.\n *\n * Walks CHILD NODES, not `querySelectorAll('*')`. `l-if` and `l-for` own their\n * subtree through an anchor COMMENT — that is the node their list effect's\n * disposer is registered on — and an element-only walk cannot see a comment,\n * so `Faqir.destroy()` left both structural directives running: the effect\n * stayed subscribed and went on re-rendering into a document nothing was\n * supposed to be driving any more. [W3-1]\n */\n function destroyScope(el) {\n if (!el) return;\n runCleanups(el);\n var child = el.firstChild;\n while (child) {\n // Read the sibling first: a cleanup is allowed to remove its own node.\n var next = child.nextSibling;\n destroyScope(child);\n child = next;\n }\n }\n\n // --- 3.5 l-source Directive ---\n\n function processSourceDirectives(root, scope) {\n for (var i = 0; i < root.attributes.length; i++) {\n var attr = root.attributes[i];\n if (!attr.name.startsWith('l-source:')) continue;\n\n var rest = attr.name.slice(9);\n var parts = rest.split('.');\n var sourceName = parts[0];\n var modifiers = parts.slice(1);\n var endpoint = attr.value;\n\n var opts = parseSourceModifiers(modifiers);\n setupSource(scope, root, sourceName, endpoint, opts);\n }\n }\n\n function parseSourceModifiers(modifiers) {\n var opts = { lazy: false, optimistic: false, idKey: 'id', pollInterval: 0 };\n\n for (var i = 0; i < modifiers.length; i++) {\n var mod = modifiers[i];\n if (mod === 'lazy') {\n opts.lazy = true;\n } else if (mod === 'optimistic') {\n opts.optimistic = true;\n } else if (mod === 'poll') {\n // Next modifier may be the interval in ms\n var next = modifiers[i + 1];\n if (next && /^\\d+$/.test(next)) {\n opts.pollInterval = parseInt(next, 10);\n i++; // skip the number\n } else {\n opts.pollInterval = 30000; // default 30s\n }\n } else if (mod === 'key') {\n // Next modifier is the key name\n var next = modifiers[i + 1];\n if (next && !/^\\d+$/.test(next)) {\n opts.idKey = next;\n i++; // skip the key name\n }\n }\n }\n\n return opts;\n }\n\n function setupSource(scope, root, name, endpoint, opts) {\n var pollTimer = null;\n var idKey = opts.idKey;\n var isOptimistic = opts.optimistic;\n\n // ── 0.3-08 request lifecycle ────────────────────────────────────────────\n // `destroyed` is latched true when the owning scope is torn down (an l-if\n // toggle or keyed l-for removal runs the cleanup registered below). Once\n // latched it (a) blocks new requests from starting and (b) gates every\n // async write-back so a fetch that resolves into a dead scope is a no-op.\n // `inflight` holds the AbortController of every live request so teardown\n // can cancel the actual network work, not just ignore its result.\n // `loadSeq`/`currentLoadAc` sequence read requests: a newer load() aborts\n // the previous one and only the LATEST call is allowed to land — so a slow\n // stale response can no longer clobber a fresh one (D2).\n var destroyed = false;\n var inflight = new Set();\n var loadSeq = 0;\n var currentLoadAc = null;\n var HAS_ABORT = typeof AbortController !== 'undefined';\n\n function beginRequest() {\n var ac = HAS_ABORT ? new AbortController() : null;\n if (ac) inflight.add(ac);\n return ac;\n }\n function endRequest(ac) {\n if (ac) inflight.delete(ac);\n }\n function signalOf(ac) {\n return ac ? ac.signal : undefined;\n }\n // Where a row is NOW — `row` by identity, else the row whose idKey is `id`.\n // Never an index saved before the request: an interleaved load()/remove()\n // shifts or replaces the list, and a stale index writes over a real row.\n function locate(id, row) {\n var items = scope[name];\n for (var i = 0; i < items.length; i++) {\n if (row ? items[i] === row : items[i] && items[i][idKey] === id) return i;\n }\n return -1;\n }\n\n // Inject reactive data properties into scope\n scope[name] = [];\n scope[name + 'Loading'] = false;\n scope[name + 'Error'] = null;\n\n // CRUD controller\n var ctrl = {\n load: function() {\n if (destroyed) return Promise.resolve();\n var mySeq = ++loadSeq;\n // Supersede the previous in-flight read: abort it so its network\n // request is cancelled; the seq guard below discards any late result.\n if (currentLoadAc) { try { currentLoadAc.abort(); } catch (e) {} }\n var ac = beginRequest();\n currentLoadAc = ac;\n scope[name + 'Loading'] = true;\n scope[name + 'Error'] = null;\n return fetch(endpoint, { signal: signalOf(ac) })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n return res.json();\n })\n .then(function(data) {\n if (destroyed || mySeq !== loadSeq) return;\n scope[name] = Array.isArray(data) ? data : [data];\n })\n .catch(function(e) {\n if (destroyed || mySeq !== loadSeq) return;\n scope[name + 'Error'] = e.message;\n })\n .then(function() {\n endRequest(ac);\n if (currentLoadAc === ac) currentLoadAc = null;\n if (destroyed || mySeq !== loadSeq) return;\n scope[name + 'Loading'] = false;\n });\n },\n\n create: function(payload) {\n if (destroyed) return Promise.resolve(null);\n scope[name + 'Error'] = null;\n var temp = null;\n\n if (isOptimistic) {\n scope[name].push(Object.assign({}, payload, { _pending: true }));\n // Read back through the list: that is the handle `locate` compares.\n temp = scope[name][scope[name].length - 1];\n }\n\n var ac = beginRequest();\n return fetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n signal: signalOf(ac)\n })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n return res.json();\n })\n .then(function(created) {\n endRequest(ac);\n if (destroyed) return null;\n var at = temp ? locate(null, temp) : -1;\n if (at >= 0) {\n scope[name][at] = created;\n } else if (!temp || !created || created[idKey] == null || locate(created[idKey]) < 0) {\n // The temp row is gone when a load() replaced the list meanwhile;\n // that list may already hold the created row.\n scope[name].push(created);\n }\n return created;\n })\n .catch(function(e) {\n endRequest(ac);\n if (destroyed) return null;\n scope[name + 'Error'] = e.message;\n var at = temp ? locate(null, temp) : -1;\n if (at >= 0) scope[name].splice(at, 1);\n return null;\n });\n },\n\n update: function(id, payload) {\n if (destroyed) return Promise.resolve(null);\n scope[name + 'Error'] = null;\n var items = scope[name];\n var idx = locate(id);\n var snapshot = null;\n\n if (isOptimistic && idx >= 0) {\n snapshot = Object.assign({}, items[idx]);\n Object.assign(items[idx], payload);\n }\n\n var ac = beginRequest();\n return fetch(endpoint + '/' + encodeURIComponent(id), {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n signal: signalOf(ac)\n })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n return res.json();\n })\n .then(function(updated) {\n endRequest(ac);\n if (destroyed) return null;\n var at = locate(id);\n if (at >= 0) scope[name][at] = updated;\n return updated;\n })\n .catch(function(e) {\n endRequest(ac);\n if (destroyed) return null;\n scope[name + 'Error'] = e.message;\n var at = snapshot ? locate(id) : -1;\n if (at >= 0) scope[name][at] = snapshot;\n return null;\n });\n },\n\n remove: function(id) {\n if (destroyed) return Promise.resolve();\n scope[name + 'Error'] = null;\n var items = scope[name];\n var idx = locate(id);\n var snapshot = null;\n\n if (isOptimistic && idx >= 0) {\n snapshot = items[idx];\n items.splice(idx, 1);\n }\n\n var ac = beginRequest();\n return fetch(endpoint + '/' + encodeURIComponent(id), { method: 'DELETE', signal: signalOf(ac) })\n .then(function(res) {\n if (!res.ok) throw new Error(res.status + ' ' + res.statusText);\n endRequest(ac);\n if (destroyed) return;\n var at = isOptimistic ? -1 : locate(id);\n if (at >= 0) scope[name].splice(at, 1);\n })\n .catch(function(e) {\n endRequest(ac);\n if (destroyed) return;\n scope[name + 'Error'] = e.message;\n // `idx` is only a position hint here; skip if a reload restored it.\n if (snapshot && locate(id) < 0) {\n scope[name].splice(idx, 0, snapshot);\n }\n });\n },\n\n refresh: function() { return ctrl.load(); },\n\n startPolling: function(interval) {\n ctrl.stopPolling();\n if (destroyed) return;\n var ms = interval || opts.pollInterval || 30000;\n pollTimer = setInterval(function() { ctrl.load(); }, ms);\n },\n\n stopPolling: function() {\n if (pollTimer) {\n clearInterval(pollTimer);\n pollTimer = null;\n }\n }\n };\n\n // Inject controller as $<name>\n scope['$' + name] = ctrl;\n\n // Auto-load unless .lazy\n if (!opts.lazy) {\n ctrl.load();\n }\n\n // Auto-poll if .poll modifier present\n if (opts.pollInterval > 0) {\n ctrl.startPolling();\n }\n\n // Teardown on scope destruction: stop polling, latch `destroyed` so no new\n // work starts or writes back, and abort every in-flight request — no fetch\n // or timer outlives the scope that owns it (D3).\n addCleanup(root, function() {\n destroyed = true;\n ctrl.stopPolling();\n inflight.forEach(function(ac) { try { ac.abort(); } catch (e) {} });\n inflight.clear();\n });\n }\n\n // --- 3.6 Directive Dispatch ---\n\n function applyDirective(el, dir, scope) {\n switch (dir.type) {\n case 'bind': return handleBind(el, dir, scope);\n case 'on': return handleOn(el, dir, scope);\n case 'text': return handleText(el, dir, scope);\n case 'html': return handleHtml(el, dir, scope);\n case 'model': return handleModel(el, dir, scope);\n case 'show': return handleShow(el, dir, scope);\n case 'ref': return handleRef(el, dir, scope);\n case 'init': return handleInit(el, dir, scope);\n case 'effect': return handleEffect(el, dir, scope);\n case 'source': return; // Handled by initScope → processSourceDirectives\n // Uncloak as soon as the element is bound. Bootstrap's sweep still runs\n // (it catches elements no directive walk reaches), and so does the\n // MutationObserver's — but content rendered by `l-if`/`l-for` is bound\n // here, before it is ever inserted, so it never needs either. [W3-1]\n case 'cloak': el.removeAttribute('l-cloak'); return;\n case 'teleport': return handleTeleport(el, dir, scope);\n case 'transition': return; // Handled by l-show and l-if\n default:\n if (customDirectives.has(dir.type)) {\n var cleanupFn = customDirectives.get(dir.type)(el, dir, scope);\n if (typeof cleanupFn === 'function') addCleanup(el, cleanupFn);\n }\n }\n }\n\n // --- 3.6 l-text ---\n\n function handleText(el, dir, scope) {\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n el.textContent = value == null ? '' : String(value);\n });\n addCleanup(el, cl);\n }\n\n // --- 3.7 l-html ---\n\n function handleHtml(el, dir, scope) {\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n el.innerHTML = value == null ? '' : String(value);\n });\n addCleanup(el, cl);\n }\n\n // --- 3.8 l-bind / :attr ---\n\n var BOOLEAN_ATTRS = new Set([\n 'disabled', 'hidden', 'checked', 'readonly', 'required', 'selected',\n 'autofocus', 'autoplay', 'controls', 'loop', 'muted', 'multiple',\n 'open', 'novalidate', 'formnovalidate', 'inert'\n ]);\n\n // Properties whose live state stops following the attribute once the user\n // has touched the control (the \"dirty\" flag), so an attribute-only write\n // leaves a stale control. `muted` and `indeterminate` have no attribute at all.\n var PROPS = new Set(['checked', 'selected', 'muted', 'indeterminate', 'value']);\n\n // Write a DOM property only when it differs. `checked`/`selected` writes\n // notify with a bubbling `faqir:model` — never a native `change`, which would\n // re-enter l-model's own listener and fire user `@change` handlers on a\n // store-driven write.\n function writeProp(el, name, value) {\n if (!(name in el) || el[name] === value) return;\n el[name] = value;\n if (name === 'checked' || name === 'selected') {\n el.dispatchEvent(new CustomEvent('faqir:model', { bubbles: true }));\n }\n }\n\n function handleBind(el, dir, scope) {\n var attrName = dir.arg;\n // What this binding's last run set on `class`/`style`. Both merge: a run\n // applies its own classes/declarations and removes only the ones its\n // previous run set and this one dropped, so static markup, `l-show` and\n // controller writes survive a re-run. [1.1F-04]\n var prev = {};\n\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n\n if (attrName === 'class') {\n prev = applyClassBinding(el, value, prev);\n } else if (attrName === 'style') {\n prev = applyStyleBinding(el, value, prev);\n } else if (BOOLEAN_ATTRS.has(attrName)) {\n if (value) {\n el.setAttribute(attrName, '');\n } else {\n el.removeAttribute(attrName);\n }\n } else {\n if (value === null || value === undefined || value === false) {\n el.removeAttribute(attrName);\n } else {\n el.setAttribute(attrName, String(value));\n }\n }\n if (PROPS.has(attrName)) {\n writeProp(el, attrName, attrName === 'value'\n ? (value == null || value === false ? '' : String(value))\n : !!value);\n }\n });\n\n addCleanup(el, cl);\n }\n\n // A `:class` value as { class: on }. Strings and arrays turn classes on; an\n // object entry sets its own, so a falsy one removes a class markup set.\n function classMap(v, out, on) {\n if (typeof v === 'string') {\n v.split(/\\s+/).forEach(function(c) { if (c) out[c] = on; });\n } else if (Array.isArray(v)) {\n v.forEach(function(x) { if (x) classMap(x, out, true); });\n } else if (v && typeof v === 'object') {\n for (var k in v) classMap(k, out, !!v[k]);\n }\n return out;\n }\n\n function applyClassBinding(el, value, prev) {\n var next = classMap(value, {}, true), c;\n for (c in prev) if (prev[c] && !(c in next)) el.classList.remove(c);\n for (c in next) el.classList.toggle(c, next[c]);\n return next;\n }\n\n // A `:style` value as { property: [value, priority] }, or null to remove it.\n // A string is parsed by a detached element's CSSOM, which handles custom\n // properties, `!important`, shorthands and `;` inside `url()`.\n var styleScratch;\n function styleMap(v, out) {\n if (typeof v === 'string') {\n var s = (styleScratch || (styleScratch = document.createElement('div'))).style;\n s.cssText = v;\n for (var i = 0; i < s.length; i++) {\n out[s[i]] = [s.getPropertyValue(s[i]), s.getPropertyPriority(s[i])];\n }\n } else if (Array.isArray(v)) {\n v.forEach(function(x) { styleMap(x, out); });\n } else if (v && typeof v === 'object') {\n for (var k in v) {\n out[/^--/.test(k) ? k : k.replace(/[A-Z]/g, '-$&').toLowerCase()] =\n v[k] == null || v[k] === false ? null : [String(v[k]), ''];\n }\n }\n return out;\n }\n\n function applyStyleBinding(el, value, prev) {\n var next = styleMap(value, {}), p;\n for (p in prev) if (prev[p] && !(p in next)) el.style.removeProperty(p);\n for (p in next) {\n if (next[p]) el.style.setProperty(p, next[p][0], next[p][1]);\n else el.style.removeProperty(p);\n }\n return next;\n }\n\n // --- 3.9 l-on / @event ---\n\n var KEY_MAP = {\n 'enter': 'Enter', 'escape': 'Escape', 'esc': 'Escape',\n 'tab': 'Tab', 'space': ' ', 'delete': 'Delete', 'backspace': 'Backspace',\n 'up': 'ArrowUp', 'down': 'ArrowDown', 'left': 'ArrowLeft', 'right': 'ArrowRight',\n 'arrow-up': 'ArrowUp', 'arrow-down': 'ArrowDown',\n 'arrow-left': 'ArrowLeft', 'arrow-right': 'ArrowRight',\n 'home': 'Home', 'end': 'End', 'page-up': 'PageUp', 'page-down': 'PageDown'\n };\n\n function debounce(fn, ms) {\n var timer;\n return function() {\n var self = this, args = arguments;\n clearTimeout(timer);\n timer = setTimeout(function() { fn.apply(self, args); }, ms);\n };\n }\n\n function throttle(fn, ms) {\n var last = 0;\n return function() {\n var now = Date.now();\n if (now - last >= ms) {\n last = now;\n fn.apply(this, arguments);\n }\n };\n }\n\n function parseTimeMod(mod) {\n var match = mod.match(/(\\d+)(ms|s)?/);\n if (!match) return null;\n var value = parseInt(match[1], 10);\n return match[2] === 's' ? value * 1000 : value;\n }\n\n function handleOn(el, dir, scope) {\n var eventName = dir.arg;\n var modifiers = new Set(dir.modifiers);\n\n var target = el;\n if (modifiers.has('window')) target = window;\n else if (modifiers.has('document')) target = document;\n\n var wrapFn = null;\n for (var m = 0; m < dir.modifiers.length; m++) {\n var mod = dir.modifiers[m];\n if (mod.startsWith('debounce')) {\n var ms = parseTimeMod(mod) || 250;\n wrapFn = function(fn) { return debounce(fn, ms); };\n } else if (mod.startsWith('throttle')) {\n var ms = parseTimeMod(mod) || 250;\n wrapFn = function(fn) { return throttle(fn, ms); };\n }\n }\n\n var isKey = eventName === 'keydown' || eventName === 'keyup' || eventName === 'keypress';\n var keyTarget = null;\n if (isKey) {\n for (var m = 0; m < dir.modifiers.length; m++) {\n if (KEY_MAP[dir.modifiers[m]]) {\n keyTarget = KEY_MAP[dir.modifiers[m]];\n break;\n }\n }\n }\n\n var handler = function(e) {\n if (modifiers.has('prevent')) e.preventDefault();\n if (modifiers.has('stop')) e.stopPropagation();\n if (modifiers.has('self') && e.target !== el) return;\n\n if (keyTarget && e.key !== keyTarget) return;\n\n scope.$event = e;\n try {\n evaluateAssignment(dir.expression, scope, el);\n } finally {\n delete scope.$event;\n }\n };\n\n if (wrapFn) handler = wrapFn(handler);\n\n var options = {};\n if (modifiers.has('once')) options.once = true;\n if (modifiers.has('capture')) options.capture = true;\n if (modifiers.has('passive')) options.passive = true;\n\n target.addEventListener(eventName, handler, options);\n addCleanup(el, function() { target.removeEventListener(eventName, handler, options); });\n }\n\n // --- 3.10 l-ref ---\n\n function handleRef(el, dir, scope) {\n var name = dir.expression;\n // Written through the reactive proxy, so an effect that read `$refs.name`\n // re-runs when the ref appears or goes. [1.1F-01]\n var refs = reactive(getScopeRefs(scopeRoots.get(scope) || findScopeRoot(el)));\n refs[name] = el;\n\n addCleanup(el, function() {\n // `__target`: a tracked read here would subscribe whichever structural\n // effect is tearing this element down.\n if (refs.__target[name] === el) {\n refs[name] = undefined;\n delete refs.__target[name];\n }\n });\n }\n\n // --- 3.11 l-init ---\n\n function handleInit(el, dir, scope) {\n runInit(function() { evaluateAssignment(dir.expression, scope, el); });\n }\n\n // --- 3.12 l-effect ---\n\n function handleEffect(el, dir, scope) {\n runInit(function() {\n addCleanup(el, effect(function() {\n evaluateAssignment(dir.expression, scope, el);\n }));\n });\n }\n\n // --- 3.13 l-cloak ---\n //\n // The engine injects no stylesheet. The `[l-cloak]` rule ships in\n // `base/reset.css` (so in every bundle); the injected copy it used to append\n // at boot was redundant, and the only inline style a CSP had to allow. [1.1F-07]\n\n /**\n * Strip `l-cloak` from `within` and everything under it (the whole document\n * when called with nothing).\n *\n * The sweep used to run exactly once, at the end of bootstrap, against a\n * document-wide selector. Anything inserted afterwards — an `l-if` branch, an\n * `l-for` row, a fragment an application appended — kept the attribute, and\n * the `[l-cloak] { display: none !important }` rule then hid it\n * permanently: content that had bound correctly and could never be seen. The\n * MutationObserver runs this over every node it is handed. [W3-1]\n */\n function removeCloaks(within) {\n var host = within || document;\n if (host.nodeType === 1 && host.hasAttribute('l-cloak')) {\n host.removeAttribute('l-cloak');\n }\n var els = host.querySelectorAll ? host.querySelectorAll('[l-cloak]') : [];\n for (var i = 0; i < els.length; i++) {\n els[i].removeAttribute('l-cloak');\n }\n }\n\n // --- 3.14 l-transition helpers (Transitions 2.0 — attribute-visible) [0.4-11 · §A4] ---\n //\n // The whole lifecycle is driven through ONE attribute, `data-motion`:\n // show: data-motion=\"enter\" → \"enter-active\" → (cleared)\n // hide: data-motion=\"leave\" → \"leave-active\" → (cleared, then removed)\n // registry/base/motion-presets.css styles each stage from motion tokens, so\n // transitions are auditable straight from the DOM. There are NO per-stage CSS\n // classes anywhere — state lives in an attribute and CSS reacts.\n\n // Named presets shipped by motion-presets.css. Unknown names still animate\n // (the attribute is stamped) but have no styling, so we warn to catch typos.\n var MOTION_PRESETS = { fade: 1, 'slide-up': 1, scale: 1 };\n\n function prefersReducedMotion() {\n return window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n // Largest value in a computed CSS time list (\"0.2s, 150ms\" | \"0s\" | \"\"), in ms.\n function maxCssTimeMs(list) {\n var max = 0;\n (list || '').split(',').forEach(function(s) {\n var n = parseFloat(s);\n if (!isNaN(n)) max = Math.max(max, s.indexOf('ms') >= 0 ? n : n * 1000);\n });\n return max;\n }\n\n // How long to wait before force-completing a stage: the element's real\n // transition/animation duration + delay plus a small buffer. transitionend\n // wins when a transition actually runs; the timeout still settles us when the\n // property does not change, no preset CSS is loaded, or the event is missed.\n function motionTimeoutMs(el) {\n var s = getComputedStyle(el);\n return Math.max(\n maxCssTimeMs(s.transitionDuration) + maxCssTimeMs(s.transitionDelay),\n maxCssTimeMs(s.animationDuration) + maxCssTimeMs(s.animationDelay)\n ) + 50;\n }\n\n // Drive one enter/leave cycle purely through `data-motion` — no per-stage\n // classes. `phase` is 'enter' | 'leave'; `done` fires once the active stage\n // ends (transitionend/animationend) or the timeout fallback fires. The\n // attribute is always cleared on completion — no residue.\n function runMotion(el, phase, done) {\n done = done || function() {};\n\n // Call off a cycle still in flight on this element before starting a new\n // one. A toggle that arrives before the previous cycle completed used to\n // leave the old cycle's finisher armed, and it would then fire *into* the\n // new one: clearing the new `data-motion` mid-flight (so the element jumps\n // instead of animating), and — when the stale cycle was a leave — running\n // its `done`, which sets `display: none` on an element the new enter had\n // just made visible. One cancel handle per element, cleared on completion.\n if (el.__faqirMotion) el.__faqirMotion();\n el.__faqirMotion = null;\n\n if (prefersReducedMotion()) {\n el.removeAttribute('data-motion');\n done();\n return;\n }\n\n var preset = el.getAttribute('l-transition') || 'fade';\n if (!MOTION_PRESETS[preset]) {\n console.warn('[Faqir] l-transition: unknown preset \"' + preset +\n '\" — expected one of: fade, slide-up, scale');\n }\n\n el.setAttribute('data-motion', phase); // from-state (no transition yet)\n el.offsetHeight; // force reflow so the from-state commits\n\n var raf = typeof requestAnimationFrame === 'function'\n ? requestAnimationFrame\n : function(cb) { return setTimeout(cb, 16); };\n\n // Cancelled between the from-state and the rAF: the next cycle has already\n // stamped its own from-state, so this one must not stamp its active stage.\n var cancelled = false;\n el.__faqirMotion = function() { cancelled = true; };\n\n raf(function() {\n if (cancelled) return;\n el.setAttribute('data-motion', phase + '-active'); // to-state + transition\n\n var finished = false;\n var timer = null;\n function teardown() {\n clearTimeout(timer);\n el.removeEventListener('transitionend', onEnd);\n el.removeEventListener('animationend', onEnd);\n }\n function finish() {\n if (finished || cancelled) return;\n finished = true;\n teardown();\n el.__faqirMotion = null;\n el.removeAttribute('data-motion');\n done();\n }\n function onEnd(e) {\n if (e.target === el) finish(); // ignore transitions bubbling from children\n }\n\n el.addEventListener('transitionend', onEnd);\n el.addEventListener('animationend', onEnd);\n timer = setTimeout(finish, motionTimeoutMs(el));\n el.__faqirMotion = function() { cancelled = true; teardown(); };\n });\n }\n\n function runEnterTransition(el) {\n runMotion(el, 'enter');\n }\n\n function runLeaveTransition(el, done) {\n runMotion(el, 'leave', done);\n }\n\n // --- 3.15 l-model ---\n\n function handleModel(el, dir, scope) {\n var prop = dir.expression;\n var modifiers = new Set(dir.modifiers);\n\n // Every branch below binds a DOM listener, and not one of them ever removed\n // it: the effect disposer was registered, the `addEventListener` was not.\n // So `Faqir.destroy()` left five live listeners writing user input back into\n // a scope nothing was supposed to be driving any more — for the life of the\n // page, on every `l-model` the page had ever mounted. One helper, so a sixth\n // branch cannot forget. [W3-1]\n function bind(eventName, handler) {\n el.addEventListener(eventName, handler);\n addCleanup(el, function() { el.removeEventListener(eventName, handler); });\n }\n\n var tag = el.tagName.toLowerCase();\n var type = el.getAttribute('type');\n var isFaqirSwitch = el.hasAttribute('data-ui') && el.dataset.ui === 'switch';\n\n if (isFaqirSwitch) {\n var cl = effect(function() {\n var value = evaluate(prop, scope, el);\n writeProp(el, 'checked', !!value);\n el.dataset.state = value ? 'on' : 'off';\n el.setAttribute('aria-checked', value ? 'true' : 'false');\n });\n bind('change', function() {\n writeModel(prop, el.checked, scope, el);\n });\n addCleanup(el, cl);\n\n } else if (tag === 'input' && type === 'checkbox') {\n var cl = effect(function() {\n var current = evaluate(prop, scope, el);\n writeProp(el, 'checked', Array.isArray(current)\n ? current.indexOf(el.value) >= 0\n : !!current);\n });\n bind('change', function() {\n var current = evaluate(prop, scope, el);\n if (Array.isArray(current)) {\n var arr = current.slice();\n var idx = arr.indexOf(el.value);\n if (el.checked && idx < 0) arr.push(el.value);\n else if (!el.checked && idx >= 0) arr.splice(idx, 1);\n writeModel(prop, arr, scope, el);\n } else {\n writeModel(prop, el.checked, scope, el);\n }\n });\n addCleanup(el, cl);\n\n } else if (tag === 'input' && type === 'radio') {\n var cl = effect(function() {\n writeProp(el, 'checked', evaluate(prop, scope, el) === el.value);\n });\n bind('change', function() {\n if (el.checked) {\n writeModel(prop, el.value, scope, el);\n }\n });\n addCleanup(el, cl);\n\n } else if (tag === 'select') {\n var cl = effect(function() {\n writeProp(el, 'value', evaluate(prop, scope, el) || '');\n });\n bind('change', function() {\n writeModel(prop, el.value, scope, el);\n });\n addCleanup(el, cl);\n\n } else {\n // text input, textarea, number input, etc.\n var eventName = modifiers.has('lazy') ? 'change' : 'input';\n\n var cl = effect(function() {\n var value = evaluate(prop, scope, el);\n if (el.value !== String(value != null ? value : '')) {\n el.value = value != null ? value : '';\n }\n });\n\n var inputHandler = function() {\n // Trim first: `.number.trim` must not call trim() on the parsed number.\n var value = el.value;\n if (modifiers.has('trim')) value = value.trim();\n if (modifiers.has('number')) value = parseFloat(value) || 0;\n writeModel(prop, value, scope, el);\n };\n\n if (modifiers.has('debounce')) {\n inputHandler = debounce(inputHandler, 300);\n }\n\n bind(eventName, inputHandler);\n addCleanup(el, cl);\n }\n }\n\n // --- 3.16 l-show ---\n\n function handleShow(el, dir, scope) {\n var originalDisplay = el.style.display === 'none' ? '' : el.style.display;\n\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n\n if (value) {\n el.style.display = originalDisplay;\n if (el.hasAttribute('l-transition')) {\n runEnterTransition(el);\n }\n } else {\n if (el.hasAttribute('l-transition')) {\n runLeaveTransition(el, function() {\n el.style.display = 'none';\n });\n } else {\n el.style.display = 'none';\n }\n }\n });\n\n addCleanup(el, cl);\n }\n\n // --- 3.17 l-if ---\n\n function handleIf(el, dir, scope) {\n if (el.tagName !== 'TEMPLATE') {\n console.warn('[Faqir] l-if must be used on a <template> element');\n return;\n }\n\n var anchor = document.createComment('l-if');\n el.parentNode.insertBefore(anchor, el);\n el.remove();\n\n // The anchor owns this directive's teardown.\n //\n // `el` is detached one line above, so `addCleanup(el, …)` resolved to no\n // owner and the disposer was discarded — `Faqir.destroy()` could not stop\n // an `l-if` at all. The anchor stands exactly where the template stood, so\n // it is inside the subtree `destroyScope` walks, and it survives every\n // toggle. [W3-1]\n anchor.__faqirCleanups = [];\n\n // EVERY node the template renders, not only the elements. Filtering to\n // `nodeType === 1` left text and comment nodes in the document on each\n // hide, so ten toggles of a two-element template left 34 child nodes where\n // 2 were expected — and each cycle added more. [W3-1]\n var insertedNodes = [];\n\n var cl = effect(function() {\n var value = evaluate(dir.expression, scope, el);\n\n if (value) {\n if (insertedNodes.length === 0) renderThenInit(function() {\n var fragment = el.content.cloneNode(true);\n var nodes = [].slice.call(fragment.childNodes);\n\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].nodeType !== 1) continue;\n\n // A cloned top node carrying `l-data` is a scope root in its own\n // right. `processElement` has no `case 'data'` — nothing there\n // creates a scope — so the node was stamped with the ENCLOSING\n // scope, its literal never evaluated, and `processSourceDirectives`\n // never ran: `l-source` inside an `l-if` issued zero fetches.\n // `initTree` is the one path that builds a scope. [W3-1]\n if (nodes[i].hasAttribute('l-data')) {\n initTree(nodes[i], scope);\n continue;\n }\n\n // Mark as initialized (mirrors handleFor) so a later\n // walkChildren pass over an ancestor doesn't re-process these\n // nodes — re-processing would re-bind handlers and evaluate\n // expressions outside the scope they were rendered with.\n nodes[i].__faqirScope = scope;\n nodes[i].__faqirCleanups = nodes[i].__faqirCleanups || [];\n processElement(nodes[i], scope);\n // A top-level structural directive replaces the node with its own\n // anchor; there is then nothing left to walk into.\n if (nodes[i].parentNode) walkChildren(nodes[i], scope);\n }\n\n // Re-read the fragment rather than trusting the pre-processing\n // snapshot: a top-level `l-if`/`l-for` inside this template has by now\n // swapped its own <template> for an anchor plus rendered content, so\n // `nodes` describes something that no longer exists. (Same reason\n // `handleFor.createEntry` re-captures.)\n insertedNodes = [].slice.call(fragment.childNodes);\n anchor.parentNode.insertBefore(fragment, anchor.nextSibling);\n\n for (var i = 0; i < insertedNodes.length; i++) {\n if (insertedNodes[i].nodeType === 1 && insertedNodes[i].hasAttribute('l-transition')) {\n runEnterTransition(insertedNodes[i]);\n }\n }\n return insertedNodes;\n });\n } else {\n for (var i = 0; i < insertedNodes.length; i++) {\n var node = insertedNodes[i];\n if (node.nodeType === 1 && node.hasAttribute('l-transition')) {\n (function(n) {\n runLeaveTransition(n, function() {\n n.remove();\n });\n })(node);\n } else {\n node.remove();\n }\n destroyScope(node);\n }\n insertedNodes = [];\n }\n });\n\n addCleanup(el, cl, anchor);\n }\n\n // --- 3.18 l-for ---\n\n // Reactive, parent-delegating scope for a single l-for item. The item/index\n // slots are reactive so keyed reuse updates them with one property write\n // (no re-processing); every other read/write passes through to the parent\n // scope so mutations there still trigger reactivity.\n function createForItemScope(own, parentScope) {\n var deps = Object.create(null);\n return new Proxy(own, {\n get: function(target, key) {\n if (key === '__isReactive') return true;\n if (key === '__target') return target;\n if (key === '__deps') return parentScope.__deps;\n if (key in target) {\n if (currentEffect && typeof key === 'string') {\n if (!deps[key]) deps[key] = new Set();\n deps[key].add(currentEffect);\n currentEffect._deps.add(deps[key]);\n }\n var value = target[key];\n if (value !== null && typeof value === 'object' && !value.__isReactive\n && (Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype)) {\n return reactive(value);\n }\n return value;\n }\n return parentScope[key];\n },\n set: function(target, key, value) {\n if (key in target) {\n var old = target[key];\n if (old !== value) {\n target[key] = value;\n if (deps[key]) {\n for (var eff of deps[key]) pendingEffects.add(eff);\n scheduleFlush();\n }\n }\n return true;\n }\n parentScope[key] = value;\n return true;\n },\n has: function(target, key) {\n return (key in target) || (key in parentScope);\n }\n });\n }\n\n // Longest increasing subsequence of old positions (0 = freshly created entry,\n // skipped). Returns the indices of `arr` already in order — the nodes that\n // stay put across a reorder, so only the rest move. O(n log n). [0.3-06 · §A1]\n function getSequence(arr) {\n var p = arr.slice();\n var result = [0];\n var i, j, u, v, c;\n for (i = 0; i < arr.length; i++) {\n var n = arr[i];\n if (n !== 0) {\n j = result[result.length - 1];\n if (arr[j] < n) { p[i] = j; result.push(i); continue; }\n u = 0; v = result.length - 1;\n while (u < v) { c = (u + v) >> 1; if (arr[result[c]] < n) u = c + 1; else v = c; }\n if (n < arr[result[u]]) { if (u > 0) p[i] = result[u - 1]; result[u] = i; }\n }\n }\n u = result.length; v = result[u - 1];\n while (u-- > 0) { result[u] = v; v = p[v]; }\n return result;\n }\n\n // True when `b` is a non-identity permutation of `a` (same items, new order).\n // Drives the dev hint for unkeyed lists that reorder. [task 0.3-06 · §A1]\n // Dev-build only — production never detects the reorder. [task 0.7-12]\n\n function handleFor(el, dir, scope) {\n if (el.tagName !== 'TEMPLATE') {\n console.warn('[Faqir] l-for must be used on a <template> element');\n return;\n }\n\n var match = dir.expression.match(\n /^\\s*(?:\\(?\\s*(\\w+)\\s*(?:,\\s*(\\w+))?\\s*\\)?\\s+in\\s+)?(.+)\\s*$/\n );\n\n if (!match) {\n console.warn('[Faqir] Invalid l-for expression: \"' + dir.expression + '\"');\n return;\n }\n\n var itemName = match[1] || 'item';\n var indexName = match[2] || 'index';\n var listExpr = match[3];\n var keyExpr = el.getAttribute('l-key');\n // Dev hint: a loop variable that shadows a name the scope already has. Only\n // names the author wrote; `in` reads no reactive dependency. [1.1F-05]\n\n var anchor = document.createComment('l-for');\n el.parentNode.insertBefore(anchor, el);\n el.remove();\n\n // Same as `l-if`: the template is detached above, so the anchor — which\n // stands where it stood and is reachable from `destroyScope` — is what owns\n // the list effect's disposer. Registering it against the detached template\n // dropped it, and a destroyed scope went on rendering rows. [W3-1]\n anchor.__faqirCleanups = [];\n\n // Reconciliation key for an item. Falls back to its position when there is\n // no l-key. Untracked so key reads never subscribe the list effect to\n // individual item properties.\n function keyFor(item, i) {\n if (!keyExpr) return i;\n var ctx = Object.create(null);\n ctx[itemName] = item;\n ctx[indexName] = i;\n var proxy = new Proxy(ctx, {\n has: function(t, k) { return (k in t) || (k in scope); },\n get: function(t, k) { return (k in t) ? t[k] : scope[k]; }\n });\n return untrack(function() { return evaluate(keyExpr, proxy, el); });\n }\n\n // Build one item's nodes + reactive scope from the template.\n function createEntry(item, i, key) {\n var clone = el.content.cloneNode(true);\n var nodes = [].slice.call(clone.childNodes);\n var own = Object.create(null);\n own[itemName] = item;\n own[indexName] = i;\n var childScope = createForItemScope(own, scope);\n scopeRoots.set(childScope, scopeRoots.get(scope));\n for (var j = 0; j < nodes.length; j++) {\n if (nodes[j].nodeType !== 1) continue;\n // A row whose top node declares `l-data` is a scope root: build it with\n // `initTree` (which evaluates the literal and reads `l-source`) instead\n // of stamping it with the row scope and leaving both inert. [W3-1]\n if (nodes[j].hasAttribute('l-data')) {\n initTree(nodes[j], childScope);\n continue;\n }\n nodes[j].__faqirScope = childScope;\n nodes[j].__faqirCleanups = [];\n processElement(nodes[j], childScope);\n if (nodes[j].parentNode) walkChildren(nodes[j], childScope);\n }\n // Re-capture the fragment's children: a top-level structural directive\n // (l-if / nested l-for) replaces its <template> with an anchor comment\n // plus rendered content INSIDE the fragment. The pre-processing `nodes`\n // snapshot would re-insert the detached template and orphan the anchor,\n // so the entry must own what the fragment actually holds now.\n return { key: key, scope: childScope, nodes: [].slice.call(clone.childNodes) };\n }\n\n var currentEntries = [];\n\n // One reconciliation. Returns the rows it built, for `renderThenInit` to\n // start their controllers and run their held inits. [1.1F-03]\n function renderList() {\n var list = evaluate(listExpr, scope, el);\n var items = Array.isArray(list) ? list :\n typeof list === 'number' ? Array.from({ length: list }, function(_, i) { return i + 1; }) :\n [];\n\n // Dev-build hint: an unkeyed list reconciles by position, so reordering it\n // rebinds per-row DOM state to the wrong items. Once per list; keyed lists\n // never reach here. Production neither warns nor snapshots the list.\n\n // old key -> entries holding it, in order, consumed as matched; the\n // leftovers are stale. A list rather than one entry because keys can\n // repeat: a Map of single entries overwrote the first row of a duplicate\n // pair, which then was neither reused nor removed and leaked a row per\n // render. source[i] = reused entry's old position + 1, or 0 for a fresh\n // entry (the getSequence sentinel).\n var oldMap = new Map();\n for (var i = 0; i < currentEntries.length; i++) {\n var k = currentEntries[i].key;\n if (oldMap.has(k)) oldMap.get(k).push(currentEntries[i]);\n else oldMap.set(k, [currentEntries[i]]);\n }\n\n var n = items.length;\n var newEntries = new Array(n);\n var source = new Array(n);\n for (var i = 0; i < n; i++) {\n var key = keyFor(items[i], i);\n var olds = oldMap.get(key);\n var entry = olds && olds.shift();\n if (entry !== undefined) {\n // Reuse in place: one write per slot, re-renders only on change.\n entry.scope[itemName] = items[i];\n entry.scope[indexName] = i;\n source[i] = entry.__i + 1;\n } else {\n entry = createEntry(items[i], i, key);\n source[i] = 0;\n }\n newEntries[i] = entry;\n }\n\n // Remove stale entries first so the DOM holds only reused nodes.\n oldMap.forEach(function(olds) {\n for (var e = 0; e < olds.length; e++) {\n for (var j = 0; j < olds[e].nodes.length; j++) {\n destroyScope(olds[e].nodes[j]);\n olds[e].nodes[j].remove();\n }\n }\n });\n\n // Place back-to-front, inserting before `anchor` (the trailing marker).\n // Entries in the longest increasing subsequence of old positions are\n // already ordered and never move; the rest insert before their placed\n // successor — the minimum number of DOM moves.\n var seq = getSequence(source);\n var sj = seq.length - 1;\n var nextNode = anchor;\n for (var i = n - 1; i >= 0; i--) {\n var entry = newEntries[i];\n if (source[i] === 0 || sj < 0 || i !== seq[sj]) {\n for (var j = 0; j < entry.nodes.length; j++) {\n anchor.parentNode.insertBefore(entry.nodes[j], nextNode);\n }\n } else {\n sj--;\n }\n entry.__i = i;\n nextNode = entry.nodes[0];\n }\n\n currentEntries = newEntries;\n var fresh = [];\n for (var i = 0; i < n; i++) if (!source[i]) fresh.push.apply(fresh, newEntries[i].nodes);\n return fresh;\n }\n\n var cl = effect(function() { renderThenInit(renderList); });\n\n addCleanup(el, cl, anchor);\n }\n\n // --- 3.19 l-teleport ---\n\n function handleTeleport(el, dir, scope) {\n // Teleporting moves the element OUT of its scope root's subtree, so from\n // here on `findCleanupRoot` walking up from anything inside it lands\n // somewhere else entirely — every disposer bound below a teleport was\n // dropped, and `destroyScope` on the scope root could never have reached\n // the nodes anyway. Two moves fix both halves: the subtree owns its own\n // cleanup list from now on, and the scope that WROTE the teleport keeps a\n // handle that tears that list down. [W3-1]\n var owner = el.parentNode ? findCleanupRoot(el.parentNode) : null;\n if (!el.__faqirCleanups) el.__faqirCleanups = [];\n\n // The teleported subtree belongs to the scope that wrote the directive, but\n // it now sits somewhere the scope-root sweep will never look — so the\n // unscoped sweep would find it \"unclaimed\" and bind every directive under it\n // a SECOND time, against the document scope, where the expressions do not\n // resolve. Claiming it here is what tells that sweep to walk past. [W3-1]\n el.__faqirStray = true;\n\n var cl = effect(function() {\n var target = document.querySelector(dir.expression);\n if (target && el.parentNode !== target) {\n target.appendChild(el);\n }\n });\n addCleanup(el, cl);\n\n if (owner && owner !== el) {\n addCleanup(el, function() {\n destroyScope(el);\n el.remove();\n }, owner);\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 4-5: Faqir Bridge ($state, $variant, $ui)\n // ═══════════════════════════════════════════════════════\n\n function closestUI(el) {\n if (!el) return null;\n if (el.hasAttribute && el.hasAttribute('data-ui')) return el;\n return el.closest ? el.closest('[data-ui]') : null;\n }\n\n function getControllerApi(uiEl) {\n if (!uiEl) return null;\n var keys = Object.keys(uiEl);\n for (var i = 0; i < keys.length; i++) {\n if (keys[i].startsWith('_faqir')) {\n return uiEl[keys[i]];\n }\n }\n return null;\n }\n\n /**\n * `$ui`, in both of its forms. [W2-6]\n *\n * `$ui.open()` — unchanged: the controller of the `[data-ui]` this expression\n * sits inside. That is the only thing `$ui` could ever reach, and it is why\n * opening a detail drawer from a table row — the most common admin pattern\n * there is — had no expression that could say it. The page had to invent a\n * global store and an `l-effect` handshake to carry \"the user clicked row 7\"\n * across two components that were both right there in the DOM.\n *\n * `$ui('#detail-drawer').open()` — the same controller API, for a component\n * named by a CSS selector. Any selector: an id is the useful case, but\n * `$ui('[data-ui=\"drawer\"]')` resolves the first drawer on the page just as\n * well. The selector may match the `[data-ui]` element itself or anything\n * inside it; either way the nearest enclosing component's controller answers.\n *\n * Returns `null` when nothing matches or the match has no controller, so\n * `$ui('#gone')?.open()` is the safe form and a typo cannot throw.\n */\n function resolveUi(target) {\n var node = typeof target === 'string' ? document.querySelector(target) : target;\n return node ? getControllerApi(closestUI(node)) : null;\n }\n\n function uiHandle(el) {\n var local = getControllerApi(closestUI(el));\n // A callable, with the local controller's own methods hung off it so both\n // forms read from one name. The methods are closures over their controller's\n // state, never `this`-bound, so carrying the reference is enough.\n var handle = function(target) { return resolveUi(target); };\n if (local) for (var key in local) handle[key] = local[key];\n return handle;\n }\n\n function setupStateBridge(root, scope) {\n var uiEl = root.hasAttribute('data-ui') ? root : (root.closest ? root.closest('[data-ui]') : null);\n if (!uiEl) return;\n\n var observer = new MutationObserver(function(mutations) {\n for (var i = 0; i < mutations.length; i++) {\n var attr = mutations[i].attributeName;\n if (attr === 'data-state' || attr === 'data-variant') {\n triggerStateDeps(scope);\n }\n }\n });\n\n observer.observe(uiEl, {\n attributes: true,\n attributeFilter: ['data-state', 'data-variant']\n });\n\n addCleanup(root, function() { observer.disconnect(); });\n }\n\n function triggerStateDeps(scope) {\n var deps = scope.__deps;\n if (!deps) return;\n if (deps['$state']) {\n for (var eff of deps['$state']) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n if (deps['$variant']) {\n for (var eff of deps['$variant']) {\n pendingEffects.add(eff);\n }\n scheduleFlush();\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 6: Core Utilities\n // ═══════════════════════════════════════════════════════\n\n // --- From dom.js ---\n var $$ = function(selector, scope) { return [].slice.call((scope || document).querySelectorAll(selector)); };\n\n // A part's owner is its nearest [data-ui] above it that is not a layout\n // primitive, starting from the parent since a part may carry data-ui itself.\n // Same selector as registry/core/dom.js `owns`.\n var OWNER = '[data-ui]:not([data-ui=stack],[data-ui=cluster],[data-ui=grid],[data-ui=container],[data-ui=surface],[data-ui=switcher],[data-ui=aspect-ratio])';\n\n function ownParts(root, part) {\n return $$(\"[data-part='\" + part + \"']\", root).filter(function(el) {\n return el.parentElement.closest(OWNER) === root;\n });\n }\n\n // --- From events.js ---\n function onOutsideClick(el, handler) {\n function listener(e) { if (!el.contains(e.target)) handler(e); }\n document.addEventListener('pointerdown', listener);\n return function() { document.removeEventListener('pointerdown', listener); };\n }\n\n // --- From focus.js ---\n var FOCUSABLE = [\n 'a[href]:not([tabindex=\"-1\"])',\n 'button:not([disabled]):not([tabindex=\"-1\"])',\n 'input:not([disabled]):not([tabindex=\"-1\"])',\n 'select:not([disabled]):not([tabindex=\"-1\"])',\n 'textarea:not([disabled]):not([tabindex=\"-1\"])',\n '[tabindex]:not([tabindex=\"-1\"])'\n ].join(',');\n\n function getFocusableElements(container) {\n return [].slice.call(container.querySelectorAll(FOCUSABLE)).filter(function(el) {\n return !el.closest('[hidden]') && el.offsetParent !== null;\n });\n }\n\n function focusFirst(container) {\n var els = getFocusableElements(container);\n if (els.length > 0) { els[0].focus(); return true; }\n return false;\n }\n\n function trapFocus(container) {\n function onKeyDown(e) {\n if (e.key !== 'Tab') return;\n var focusable = getFocusableElements(container);\n if (focusable.length === 0) return;\n var first = focusable[0], last = focusable[focusable.length - 1];\n if (e.shiftKey) {\n if (document.activeElement === first) { e.preventDefault(); last.focus(); }\n } else {\n if (document.activeElement === last) { e.preventDefault(); first.focus(); }\n }\n }\n container.addEventListener('keydown', onKeyDown);\n return function() { container.removeEventListener('keydown', onKeyDown); };\n }\n\n // Back to the opener once an overlay has closed, unless focus moved on while\n // it closed (`active` was read before the panel hid) or the opener is gone.\n function returnFocus(root, target, active) {\n if ((!active || active === document.body || root.contains(active)) &&\n target && target.isConnected && !target.closest('[hidden]')) target.focus();\n }\n\n // --- From motion.js (prefersReducedMotion already defined in Section 3.14) ---\n // The four events an exit can end with, in one list: bound and unbound\n // together, so neither half can drift from the other.\n var EXIT_EVENTS = ['transitionend', 'transitioncancel', 'animationend', 'animationcancel'];\n\n // Largest number in a comma-separated CSS time list, in ms (\"0.3s, 150ms\" → 300).\n function longestTimeMs(value) {\n var parts = String(value == null ? '' : value).split(',');\n var max = 0;\n for (var i = 0; i < parts.length; i++) {\n var raw = parts[i].trim();\n var n = parseFloat(raw);\n if (isNaN(n)) continue;\n if (raw.indexOf('ms') === -1) n *= 1000;\n if (n > max) max = n;\n }\n return max;\n }\n\n // An upper bound on how long `el`'s motion can run: the longest transition or\n // animation plus the longest delay. Deliberately an over-estimate — it sizes a\n // fallback timer, and a fallback that fires early is worse than one that fires\n // late.\n function longestMotionMs(style) {\n var transition = longestTimeMs(style.transitionDuration) + longestTimeMs(style.transitionDelay);\n var animation = longestTimeMs(style.animationDuration) + longestTimeMs(style.animationDelay);\n return transition > animation ? transition : animation;\n }\n\n /**\n * Run `done` once `el` has finished its exit motion — the single place every\n * \"closing → closed\" controller waits.\n *\n * `transitionend` BUBBLES. A panel that contains a button — every dialog,\n * drawer and sheet in the registry ships one, and the drawer manifest marks\n * the close button `required` — receives that button's own `background`\n * transitionend the instant a pointer lands on it. A one-shot listener spends\n * itself on that event and the panel's own `transform` transitionend, when it\n * arrives, finds nobody listening. The drawer therefore never finalised\n * `closing → closed` through the one control it tells you not to remove: the\n * overlay stayed up, `body` stayed at `overflow: hidden`, the page was dead.\n *\n * So four rules, all of them load-bearing:\n * • only `el`'s OWN motion counts (`e.target === el`) — descendants bubble;\n * • only `property`, when one is named — sibling properties on the same\n * element finish at their own times;\n * • `transitioncancel` / `animationcancel` count as over — an interrupted\n * transition never sends `transitionend` at all;\n * • a timer sized from the computed duration runs `done` even if no event\n * ever arrives (backgrounded tab, `display` change mid-flight).\n *\n * `done` runs at most once — synchronously and immediately when there is no\n * motion to wait for. Returns a canceller for a re-entrant open. [W2-1]\n */\n function whenExitDone(el, property, done) {\n var settled = false;\n var timer = null;\n\n function unbind() {\n if (timer !== null) { clearTimeout(timer); timer = null; }\n for (var i = 0; i < EXIT_EVENTS.length; i++) el.removeEventListener(EXIT_EVENTS[i], onMotionEvent);\n }\n\n function settle() {\n if (settled) return;\n settled = true;\n unbind();\n done();\n }\n\n function onMotionEvent(e) {\n if (e.target !== el) return;\n if (property && e.propertyName && e.propertyName !== property) return;\n settle();\n }\n\n var ms = 0;\n try {\n ms = longestMotionMs(getComputedStyle(el));\n } catch (err) {\n // No computed style (a bare test DOM) — treat it as \"no motion\".\n }\n\n if (!(ms > 0)) { settle(); return function() {}; }\n\n for (var i = 0; i < EXIT_EVENTS.length; i++) el.addEventListener(EXIT_EVENTS[i], onMotionEvent);\n // A couple of frames of slack before the fallback takes over from the event.\n timer = setTimeout(settle, ms + 50);\n\n return function cancelExitWait() {\n if (settled) return;\n settled = true;\n unbind();\n };\n }\n\n // --- From utils.js (debounce/throttle already defined in Section 3.9) ---\n var uidCounter = 0;\n function uid(prefix) { return (prefix || 'faqir') + '-' + (++uidCounter); }\n function clamp(value, min, max) { return Math.min(Math.max(value, min), max); }\n\n // Shared menu navigation is injected from registry/core/menu-navigation.js.\n // Keeping the module as the authored source lets standalone recipe imports\n // and the assembled browser runtime execute the exact same implementation.\n // ── shared menu navigation ── (registry/core/menu-navigation.js)\n // @ui:core menu-navigation\n // @ui:provides createMenuNavigation\n\n const MENU_ITEM_SELECTOR =\n '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\n const MENU_OWNER_SELECTOR = '[role=\"menu\"], [role=\"menubar\"]';\n\n /**\n * Shared keyboard and focus navigation for menus and menubars.\n *\n * The helper deliberately owns movement only. Controllers remain responsible\n * for opening/closing popups and reflecting component state.\n *\n * @param {Element} container element carrying role=menu or role=menubar\n * @param {object} [options]\n * @param {\"vertical\"|\"horizontal\"} [options.orientation=\"vertical\"]\n * @param {boolean} [options.roving=false] maintain one tabindex=0 item\n * @param {(item: Element, event: KeyboardEvent) => void} [options.onActivate]\n * @param {(event: KeyboardEvent) => void} [options.onEscape]\n * @param {(event: KeyboardEvent) => void} [options.onTab]\n */\n function createMenuNavigation(container, options = {}) {\n const horizontal = options.orientation === \"horizontal\";\n const roving = options.roving === true;\n const forwardKey = horizontal ? \"ArrowRight\" : \"ArrowDown\";\n const backwardKey = horizontal ? \"ArrowLeft\" : \"ArrowUp\";\n\n function candidates() {\n return [...container.querySelectorAll(MENU_ITEM_SELECTOR)].filter(\n (item) => item.closest(MENU_OWNER_SELECTOR) === container,\n );\n }\n\n // Native disabled controls cannot receive focus. aria-disabled menuitems stay\n // in the arrow sequence per the WAI-ARIA menu pattern; activation is blocked\n // separately below.\n function items() {\n return candidates().filter((item) => !item.disabled);\n }\n\n function current() {\n const all = items();\n const active = document.activeElement;\n if (all.includes(active)) return active;\n return roving ? all.find((item) => item.tabIndex === 0) || null : null;\n }\n\n function sync(preferred) {\n if (!roving) return preferred || current();\n\n const all = items();\n let active = all.includes(preferred) ? preferred : null;\n if (!active && all.includes(document.activeElement)) active = document.activeElement;\n if (!active) active = all.find((item) => item.tabIndex === 0) || all[0] || null;\n\n for (const item of candidates()) item.tabIndex = item === active ? 0 : -1;\n return active;\n }\n\n function focus(index) {\n const all = items();\n if (all.length === 0) return null;\n\n const item = all[((index % all.length) + all.length) % all.length];\n sync(item);\n item.focus();\n return item;\n }\n\n function currentIndex() {\n return items().indexOf(current());\n }\n\n function focusFirst() {\n return focus(0);\n }\n\n function focusLast() {\n return focus(items().length - 1);\n }\n\n function focusNext() {\n const index = currentIndex();\n return focus(index < 0 ? 0 : index + 1);\n }\n\n function focusPrevious() {\n const index = currentIndex();\n return focus(index < 0 ? items().length - 1 : index - 1);\n }\n\n function eventItem(event) {\n const item = event.target.closest?.(MENU_ITEM_SELECTOR);\n if (item?.closest(MENU_OWNER_SELECTOR) === container) return item;\n return event.target === container ? current() : null;\n }\n\n function onKeyDown(event) {\n // Nested menu events bubble through their parent menubar. Only the nearest\n // menu/menubar owns a menuitem's key handling. Escape and Tab still belong\n // to an empty menu, including legacy markup where the container lacks a role.\n const owner = event.target.closest?.(MENU_OWNER_SELECTOR);\n if (owner ? owner !== container : event.target !== container) return;\n\n if (event.key === \"Escape\" && options.onEscape) {\n event.preventDefault();\n // Escape DISMISSES ONE THING. Without stopping it here the same keystroke\n // reached every ancestor overlay: closing a dropdown inside a dialog\n // closed the dialog too, and with it whatever the user had typed. The\n // callback opts out by returning `false` — its way of saying \"this\n // Escape was not mine\", so it still reaches whatever encloses us. [W3-2]\n const handled = options.onEscape(event);\n if (handled !== false) event.stopPropagation();\n return;\n }\n if (event.key === \"Tab\" && options.onTab) {\n options.onTab(event);\n return;\n }\n\n const targetItem = eventItem(event);\n if (!targetItem) return;\n\n if (event.key === forwardKey) {\n event.preventDefault();\n focusNext();\n return;\n }\n if (event.key === backwardKey) {\n event.preventDefault();\n focusPrevious();\n return;\n }\n if (event.key === \"Home\") {\n event.preventDefault();\n focusFirst();\n return;\n }\n if (event.key === \"End\") {\n event.preventDefault();\n focusLast();\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (targetItem.getAttribute(\"aria-disabled\") !== \"true\") {\n if (options.onActivate) options.onActivate(targetItem, event);\n else targetItem.click();\n }\n }\n }\n\n function onFocusIn(event) {\n const item = eventItem(event);\n if (item) sync(item);\n }\n\n container.addEventListener(\"keydown\", onKeyDown);\n if (roving) container.addEventListener(\"focusin\", onFocusIn);\n sync();\n\n function destroy() {\n container.removeEventListener(\"keydown\", onKeyDown);\n if (roving) container.removeEventListener(\"focusin\", onFocusIn);\n }\n\n return {\n items,\n current,\n sync,\n focus,\n focusFirst,\n focusLast,\n focusNext,\n focusPrevious,\n destroy,\n };\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 7: Recipe Controllers\n // ═══════════════════════════════════════════════════════\n\n var controllerRegistry = {};\n\n // Recipe controller factories are assembled here by scripts/build-core.mjs\n // from registry/recipes/<name>/<name>.js. Do NOT hand-edit the generated\n // registry/core/faqir-core.js — edit the recipe files (or this engine\n // source) and run `bun run build:core`. See CONTRIBUTING.md.\n // ── accordion ── (registry/recipes/accordion/accordion.js)\n var createAccordion = controllerRegistry[\"accordion\"] = (function() {\n// @ui:controller accordion\n// @ui:provides toggle expand collapse expandAll collapseAll destroy\n\nfunction createAccordion(root) {\n // Prevent double-init\n if (root._faqirAccordion) return root._faqirAccordion;\n\n // Direct children only: a nested accordion's items are its own.\n const getItems = () => [...root.querySelectorAll(\":scope > [data-part='item']\")];\n const isSingle = () => root.dataset.variant === \"single\";\n\n function expand(index) {\n const items = getItems();\n if (index < 0 || index >= items.length) return;\n\n // In single mode, collapse all others first\n if (isSingle()) {\n items.forEach((item, i) => {\n if (i !== index) collapseItem(item);\n });\n }\n\n expandItem(items[index]);\n }\n\n function collapse(index) {\n const items = getItems();\n if (index < 0 || index >= items.length) return;\n collapseItem(items[index]);\n }\n\n function toggle(index) {\n const items = getItems();\n if (index < 0 || index >= items.length) return;\n\n if (items[index].dataset.state === \"expanded\") {\n collapse(index);\n } else {\n expand(index);\n }\n }\n\n function expandAll() {\n const items = getItems();\n items.forEach((item) => expandItem(item));\n }\n\n function collapseAll() {\n const items = getItems();\n items.forEach((item) => collapseItem(item));\n }\n\n function expandItem(item) {\n item.dataset.state = \"expanded\";\n const trigger = item.querySelector(\"[data-part='trigger']\");\n const content = item.querySelector(\"[data-part='content']\");\n if (trigger) trigger.setAttribute(\"aria-expanded\", \"true\");\n if (content) content.hidden = false;\n }\n\n function collapseItem(item) {\n item.dataset.state = \"collapsed\";\n const trigger = item.querySelector(\"[data-part='trigger']\");\n const content = item.querySelector(\"[data-part='content']\");\n if (trigger) trigger.setAttribute(\"aria-expanded\", \"false\");\n if (content) content.hidden = true;\n }\n\n /**\n * The index of the item whose own trigger `e` came from, or -1. A trigger of\n * a component nested in the content (a dropdown, another accordion) is not\n * the item's: an item's own trigger is the first one in it, since it comes\n * before the content.\n */\n function triggerIndex(e) {\n const trigger = e.target.closest(\"[data-part='trigger']\");\n const item = trigger?.closest(\"[data-part='item']\");\n if (!item || item.querySelector(\"[data-part='trigger']\") !== trigger) return -1;\n return getItems().indexOf(item);\n }\n\n function onTriggerClick(e) {\n const index = triggerIndex(e);\n if (index >= 0) toggle(index);\n }\n\n function onKeyDown(e) {\n if (e.key === \"Enter\" || e.key === \" \") {\n const index = triggerIndex(e);\n if (index >= 0) {\n e.preventDefault();\n toggle(index);\n }\n }\n }\n\n root.addEventListener(\"click\", onTriggerClick);\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n root.removeEventListener(\"click\", onTriggerClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirAccordion;\n }\n\n const api = { toggle, expand, collapse, expandAll, collapseAll, destroy };\n root._faqirAccordion = api;\n return api;\n}\n return createAccordion;\n })();\n\n // ── alert-dialog ── (registry/recipes/alert-dialog/alert-dialog.js)\n var createAlertDialog = controllerRegistry[\"alert-dialog\"] = (function() {\n// @ui:controller alert-dialog\n// @ui:provides open close toggle destroy\n\n/**\n * alert-dialog reuses the `dialog` controller wholesale — there is no forked or\n * duplicated controller here. An alert dialog IS a dialog whose panel carries\n * `role=\"alertdialog\"`; the shared controller in ../dialog/dialog.js reads that\n * role and switches on the WAI-ARIA alertdialog behaviours (no overlay-dismiss,\n * focus the least-destructive action, guarded Escape, confirm/cancel events).\n * This factory only exists so the recipe is discoverable under its own\n * `data-ui=\"alert-dialog\"` name and auto-registers from the built core.\n */\nfunction createAlertDialog(root) {\n // Resolve the shared dialog factory in both worlds this controller runs in:\n // • as an ES module (behaviour tests, `faqir add`): the `import` above binds\n // `createDialog` directly.\n // • inlined into the built registry/core/faqir-core.js: scripts/build-core.mjs\n // strips the import, but every recipe factory is registered on the engine's\n // private `controllerRegistry`, so pick `dialog` up from there.\n // `typeof` is used because a bare reference to a stripped/undeclared binding\n // would throw — `typeof` on an unknown identifier is the one safe probe.\n const dialogFactory =\n (typeof createDialog === \"function\" && createDialog) ||\n (typeof controllerRegistry !== \"undefined\" && controllerRegistry[\"dialog\"]);\n\n if (typeof dialogFactory !== \"function\") {\n throw new Error(\"alert-dialog requires the dialog controller to be available\");\n }\n return dialogFactory(root);\n}\n return createAlertDialog;\n })();\n\n // ── barcode ── (registry/recipes/barcode/barcode.js)\n var createBarcode = controllerRegistry[\"barcode\"] = (function() {\n// @ui:controller barcode\n// @ui:provides render update destroy\n\n/**\n * Code 128-B encoder and SVG renderer.\n *\n * Code set B covers printable ASCII (U+0020–U+007E), which keeps the public\n * contract predictable while supporting document identifiers, URLs, and\n * ordinary business text. The generated symbol includes a modulo-103 check\n * character, the stop pattern, and ten-module quiet zones on both sides.\n */\n\nconst CODE128_PATTERNS = Object.freeze([\n \"212222\", \"222122\", \"222221\", \"121223\", \"121322\", \"131222\",\n \"122213\", \"122312\", \"132212\", \"221213\", \"221312\", \"231212\",\n \"112232\", \"122132\", \"122231\", \"113222\", \"123122\", \"123221\",\n \"223211\", \"221132\", \"221231\", \"213212\", \"223112\", \"312131\",\n \"311222\", \"321122\", \"321221\", \"312212\", \"322112\", \"322211\",\n \"212123\", \"212321\", \"232121\", \"111323\", \"131123\", \"131321\",\n \"112313\", \"132113\", \"132311\", \"211313\", \"231113\", \"231311\",\n \"112133\", \"112331\", \"132131\", \"113123\", \"113321\", \"133121\",\n \"313121\", \"211331\", \"231131\", \"213113\", \"213311\", \"213131\",\n \"311123\", \"311321\", \"331121\", \"312113\", \"312311\", \"332111\",\n \"314111\", \"221411\", \"431111\", \"111224\", \"111422\", \"121124\",\n \"121421\", \"141122\", \"141221\", \"112214\", \"112412\", \"122114\",\n \"122411\", \"142112\", \"142211\", \"241211\", \"221114\", \"413111\",\n \"241112\", \"134111\", \"111242\", \"121142\", \"121241\", \"114212\",\n \"124112\", \"124211\", \"411212\", \"421112\", \"421211\", \"212141\",\n \"214121\", \"412121\", \"111143\", \"111341\", \"131141\", \"114113\",\n \"114311\", \"411113\", \"411311\", \"113141\", \"114131\", \"311141\",\n \"411131\", \"211412\", \"211214\", \"211232\", \"2331112\",\n]);\n\nconst START_B = 104;\nconst STOP = 106;\nconst QUIET_ZONE = 10;\nconst BAR_HEIGHT = 50;\n\nfunction encodeCode128B(value) {\n if (!value) throw new Error(\"value is empty\");\n\n const data = [];\n let inputIndex = 0;\n for (const character of value) {\n const codePoint = character.codePointAt(0);\n if (codePoint < 32 || codePoint > 126) {\n const printable = JSON.stringify(character);\n throw new Error(\n `unsupported character ${printable} at index ${inputIndex}; Code 128-B accepts printable ASCII only`,\n );\n }\n data.push(codePoint - 32);\n inputIndex += character.length;\n }\n\n let weighted = START_B;\n for (let i = 0; i < data.length; i++) weighted += data[i] * (i + 1);\n const checksum = weighted % 103;\n const codewords = [START_B, ...data, checksum, STOP];\n const pattern = codewords.map((value) => CODE128_PATTERNS[value]).join(\"\");\n\n return { checksum, codewords, pattern };\n}\n\nfunction patternToSVG(encoded) {\n const patternWidth = [...encoded.pattern].reduce((sum, width) => sum + Number(width), 0);\n const totalWidth = patternWidth + QUIET_ZONE * 2;\n\n let x = QUIET_ZONE;\n let isBar = true;\n let pathData = \"\";\n for (const digit of encoded.pattern) {\n const width = Number(digit);\n if (isBar) pathData += `M${x},0h${width}v${BAR_HEIGHT}h-${width}z`;\n x += width;\n isBar = !isBar;\n }\n\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"viewBox\", `0 0 ${totalWidth} ${BAR_HEIGHT}`);\n svg.setAttribute(\"width\", String(totalWidth));\n svg.setAttribute(\"height\", String(BAR_HEIGHT));\n svg.setAttribute(\"preserveAspectRatio\", \"xMidYMid meet\");\n svg.setAttribute(\"shape-rendering\", \"crispEdges\");\n svg.setAttribute(\"data-part\", \"svg\");\n svg.setAttribute(\"data-checksum\", String(encoded.checksum));\n svg.setAttribute(\"data-pattern\", encoded.pattern);\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"focusable\", \"false\");\n\n const background = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n background.setAttribute(\"width\", String(totalWidth));\n background.setAttribute(\"height\", String(BAR_HEIGHT));\n background.setAttribute(\"fill\", \"var(--color-bg, #fff)\");\n svg.appendChild(background);\n\n const bars = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n bars.setAttribute(\"d\", pathData);\n bars.setAttribute(\"fill\", \"var(--color-fg, #000)\");\n svg.appendChild(bars);\n\n return svg;\n}\n\nfunction createBarcode(root) {\n if (root._faqirBarcode) return root._faqirBarcode;\n\n function removeGeneratedSVG() {\n const svg = root.querySelector(\":scope > [data-part='svg']\");\n if (svg) svg.remove();\n }\n\n function render() {\n removeGeneratedSVG();\n const value = root.getAttribute(\"data-value\") || \"\";\n\n if (!value) {\n root.dataset.state = \"empty\";\n return;\n }\n\n try {\n const svg = patternToSVG(encodeCode128B(value));\n const caption = root.querySelector(\":scope > [data-part='caption']\");\n if (caption) root.insertBefore(svg, caption);\n else root.appendChild(svg);\n root.dataset.state = \"ready\";\n } catch (error) {\n root.dataset.state = \"error\";\n const message = error instanceof Error ? error.message : String(error);\n console.warn(`[barcode] Failed to encode: ${message}`);\n }\n }\n\n function update(newValue) {\n if (newValue !== undefined) root.setAttribute(\"data-value\", newValue);\n render();\n }\n\n const observer = new MutationObserver((mutations) => {\n if (mutations.some((mutation) => mutation.attributeName === \"data-value\")) render();\n });\n observer.observe(root, { attributes: true, attributeFilter: [\"data-value\"] });\n\n function destroy() {\n observer.disconnect();\n removeGeneratedSVG();\n if ([\"empty\", \"ready\", \"error\"].includes(root.dataset.state)) delete root.dataset.state;\n delete root._faqirBarcode;\n }\n\n const api = { render, update, destroy };\n root._faqirBarcode = api;\n render();\n return api;\n}\n return createBarcode;\n })();\n\n // ── calendar ── (registry/recipes/calendar/calendar.js)\n var createCalendar = controllerRegistry[\"calendar\"] = (function() {\n// @ui:controller calendar\n// @ui:provides getValue setValue clear navigate selectDate focusDate setMin setMax setDisabledDates destroy\n\nconst MONTH_NAMES = [\n \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\",\n];\n\nconst DAY_NAMES = [\n \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\",\n];\n\nfunction parseISO(str) {\n if (!str) return null;\n const d = new Date(str + \"T00:00:00\");\n return isNaN(d.getTime()) ? null : d;\n}\n\nfunction createCalendar(root) {\n // Prevent double-init\n if (root._faqirCalendar) return root._faqirCalendar;\n\n const navPrev = root.querySelector(\"[data-part='nav-prev']\");\n const navNext = root.querySelector(\"[data-part='nav-next']\");\n const monthLabel = root.querySelector(\"[data-part='month-label']\");\n const gridBody = root.querySelector(\"[data-part='grid-body']\");\n\n // `grid-body` is the one part every render writes into: without it the first\n // `render()` throws on `gridBody.innerHTML`, taking the date-picker that\n // wraps it down with it. The optional parts (nav, month label) are already\n // guarded individually. [W3-2]\n if (!gridBody) {\n console.warn(\n \"[Faqir] calendar needs [data-part='grid-body'] to render into. \" +\n \"Component left inert.\",\n root\n );\n const inert = {\n getValue: () => null,\n setValue() {},\n clear() {},\n navigate() {},\n selectDate() {},\n focusDate() {},\n setMin() {},\n setMax() {},\n setDisabledDates() {},\n destroy() {},\n };\n root._faqirCalendar = inert;\n return inert;\n }\n\n const today = new Date();\n const mode = root.dataset.mode === \"range\" ? \"range\" : \"single\";\n\n let minDate = parseISO(root.dataset.min);\n let maxDate = parseISO(root.dataset.max);\n let disabledDates = parseDateList(root.dataset.disabledDates);\n\n let selectedDate = null;\n let rangeStart = null;\n let rangeEnd = null;\n if (root.dataset.value) {\n if (mode === \"range\") {\n const parts = root.dataset.value.split(\",\");\n rangeStart = parseISO(parts[0] && parts[0].trim());\n rangeEnd = parseISO(parts[1] && parts[1].trim());\n } else {\n selectedDate = parseISO(root.dataset.value);\n }\n }\n\n const initialView = selectedDate || rangeStart || today;\n let viewMonth = initialView.getMonth();\n let viewYear = initialView.getFullYear();\n let focusedDate = null;\n\n function parseDateList(str) {\n const set = new Set();\n if (str) {\n for (const token of str.split(/[\\s,]+/)) {\n if (parseISO(token)) set.add(token);\n }\n }\n return set;\n }\n\n function formatDate(date) {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n }\n\n function formatAriaLabel(date) {\n return `${DAY_NAMES[date.getDay()]}, ${MONTH_NAMES[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n }\n\n function isSameDay(a, b) {\n if (!a || !b) return false;\n return (\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n }\n\n function isToday(date) {\n return isSameDay(date, today);\n }\n\n function isDisabled(date) {\n if (minDate && date.getTime() < minDate.getTime()) return true;\n if (maxDate && date.getTime() > maxDate.getTime()) return true;\n return disabledDates.has(formatDate(date));\n }\n\n function clampToRange(date) {\n if (minDate && date.getTime() < minDate.getTime()) return new Date(minDate);\n if (maxDate && date.getTime() > maxDate.getTime()) return new Date(maxDate);\n return date;\n }\n\n function buildGrid() {\n // First day of the displayed month\n const firstDay = new Date(viewYear, viewMonth, 1);\n const startDow = firstDay.getDay(); // 0=Sun\n\n // Last day of the displayed month\n const lastDay = new Date(viewYear, viewMonth + 1, 0);\n const totalDays = lastDay.getDate();\n\n // Previous month trailing days\n const prevMonthLast = new Date(viewYear, viewMonth, 0);\n const prevMonthDays = prevMonthLast.getDate();\n\n // Update label\n if (monthLabel) monthLabel.textContent = `${MONTH_NAMES[viewMonth]} ${viewYear}`;\n\n // A whole adjacent month out of bounds means its nav button is a dead end\n if (navPrev) navPrev.disabled = !!(minDate && prevMonthLast.getTime() < minDate.getTime());\n if (navNext) navNext.disabled = !!(maxDate && new Date(viewYear, viewMonth + 1, 1).getTime() > maxDate.getTime());\n\n // Clear existing\n gridBody.innerHTML = \"\";\n\n let dayCount = 1;\n let nextMonthDay = 1;\n const totalCells = Math.ceil((startDow + totalDays) / 7) * 7;\n let row = null;\n\n for (let i = 0; i < totalCells; i++) {\n // Start a new row every 7 cells\n if (i % 7 === 0) {\n row = document.createElement(\"tr\");\n gridBody.appendChild(row);\n }\n\n const td = document.createElement(\"td\");\n const btn = document.createElement(\"button\");\n btn.setAttribute(\"data-part\", \"day\");\n btn.type = \"button\";\n\n let date;\n let isOutside = false;\n\n if (i < startDow) {\n // Previous month\n const day = prevMonthDays - startDow + 1 + i;\n date = new Date(viewYear, viewMonth - 1, day);\n btn.textContent = day;\n isOutside = true;\n } else if (dayCount <= totalDays) {\n // Current month\n date = new Date(viewYear, viewMonth, dayCount);\n btn.textContent = dayCount;\n dayCount++;\n } else {\n // Next month\n date = new Date(viewYear, viewMonth + 1, nextMonthDay);\n btn.textContent = nextMonthDay;\n nextMonthDay++;\n isOutside = true;\n }\n\n btn.dataset.date = formatDate(date);\n btn.setAttribute(\"aria-label\", formatAriaLabel(date));\n\n if (isOutside) {\n btn.dataset.outside = \"true\";\n }\n\n if (isToday(date)) {\n btn.dataset.today = \"true\";\n }\n\n if (isDisabled(date)) {\n // aria-disabled (not the native attribute) keeps the cell reachable by\n // the roving tabindex while blocking selection\n btn.setAttribute(\"aria-disabled\", \"true\");\n btn.dataset.disabled = \"true\";\n }\n\n if (mode === \"range\") {\n if (isSameDay(date, rangeStart)) {\n btn.dataset.state = \"range-start\";\n btn.setAttribute(\"aria-selected\", \"true\");\n } else if (isSameDay(date, rangeEnd)) {\n btn.dataset.state = \"range-end\";\n btn.setAttribute(\"aria-selected\", \"true\");\n } else if (\n rangeStart && rangeEnd &&\n date.getTime() > rangeStart.getTime() &&\n date.getTime() < rangeEnd.getTime()\n ) {\n btn.dataset.state = \"in-range\";\n }\n } else if (isSameDay(date, selectedDate)) {\n btn.setAttribute(\"aria-selected\", \"true\");\n }\n\n if (isSameDay(date, focusedDate)) {\n btn.tabIndex = 0;\n } else {\n btn.tabIndex = -1;\n }\n\n td.appendChild(btn);\n row.appendChild(td);\n }\n\n // If no focused date set, make the selected or first-of-month focusable\n if (!focusedDate) {\n const anchor = mode === \"range\" ? rangeStart : selectedDate;\n const defaultFocusDate = anchor &&\n anchor.getMonth() === viewMonth && anchor.getFullYear() === viewYear\n ? anchor\n : new Date(viewYear, viewMonth, 1);\n const defaultBtn = gridBody.querySelector(\n `[data-date=\"${formatDate(defaultFocusDate)}\"]`\n );\n if (defaultBtn) defaultBtn.tabIndex = 0;\n }\n }\n\n function dayButton(date) {\n return gridBody.querySelector(`[data-date=\"${formatDate(date)}\"]`);\n }\n\n function focusDate(date) {\n const target = clampToRange(new Date(date));\n focusedDate = target;\n\n if (target.getMonth() !== viewMonth || target.getFullYear() !== viewYear) {\n viewMonth = target.getMonth();\n viewYear = target.getFullYear();\n buildGrid();\n } else {\n // Update roving tabindex in the current grid\n gridBody.querySelectorAll(\"[data-part='day']\").forEach((btn) => {\n btn.tabIndex = -1;\n });\n const btn = dayButton(target);\n if (btn) btn.tabIndex = 0;\n }\n\n const btn = dayButton(target);\n if (btn) btn.focus();\n }\n\n function moveFocus(days) {\n if (!focusedDate) return;\n const next = new Date(focusedDate);\n next.setDate(next.getDate() + days);\n focusDate(next);\n }\n\n /** Move focus ±N months (PageUp/Down), clamping the day to the target month's length. */\n function moveFocusMonths(months) {\n if (!focusedDate) return;\n const target = new Date(focusedDate.getFullYear(), focusedDate.getMonth() + months, 1);\n const daysInTarget = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();\n target.setDate(Math.min(focusedDate.getDate(), daysInTarget));\n focusDate(target);\n }\n\n function selectDate(date) {\n const chosen = new Date(date);\n if (isDisabled(chosen)) return;\n\n // buildGrid() replaces the focused button — restore focus before emitting,\n // so change listeners (e.g. date-picker closing the popup) keep the final\n // word on where focus lands.\n const hadFocus = root.contains(document.activeElement);\n focusedDate = chosen;\n\n let detail = null;\n\n if (mode === \"range\") {\n if (!rangeStart || rangeEnd || chosen.getTime() < rangeStart.getTime()) {\n // First click, restart after a complete range, or backwards pick\n rangeStart = chosen;\n rangeEnd = null;\n } else {\n rangeEnd = chosen;\n detail = {\n start: formatDate(rangeStart),\n end: formatDate(rangeEnd),\n startObj: new Date(rangeStart),\n endObj: new Date(rangeEnd),\n };\n }\n } else {\n selectedDate = chosen;\n detail = { date: formatDate(selectedDate), dateObj: new Date(selectedDate) };\n }\n\n buildGrid();\n\n if (hadFocus) {\n const btn = dayButton(chosen);\n if (btn) btn.focus();\n }\n\n if (detail) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:calendar-change\", { detail, bubbles: true })\n );\n }\n }\n\n function getValue() {\n if (mode === \"range\") {\n return {\n start: rangeStart ? formatDate(rangeStart) : null,\n end: rangeEnd ? formatDate(rangeEnd) : null,\n };\n }\n return selectedDate ? formatDate(selectedDate) : null;\n }\n\n /** Silent set — updates selection and view without emitting a change event. */\n function setValue(value) {\n if (mode === \"range\") {\n const parts = String(value).split(\",\");\n const start = parseISO(parts[0] && parts[0].trim());\n const end = parseISO(parts[1] && parts[1].trim());\n if (!start) return;\n rangeStart = start;\n rangeEnd = end && end.getTime() >= start.getTime() ? end : null;\n viewMonth = start.getMonth();\n viewYear = start.getFullYear();\n buildGrid();\n return;\n }\n\n const parsed = parseISO(value);\n if (!parsed) return;\n selectedDate = parsed;\n viewMonth = parsed.getMonth();\n viewYear = parsed.getFullYear();\n buildGrid();\n }\n\n function clear() {\n selectedDate = null;\n rangeStart = null;\n rangeEnd = null;\n buildGrid();\n }\n\n function navigate(month, year) {\n viewMonth = month;\n viewYear = year;\n focusedDate = new Date(viewYear, viewMonth, 1);\n buildGrid();\n\n const btn = dayButton(focusedDate);\n if (btn) btn.focus();\n }\n\n function setMin(value) {\n minDate = parseISO(value);\n buildGrid();\n }\n\n function setMax(value) {\n maxDate = parseISO(value);\n buildGrid();\n }\n\n function setDisabledDates(list) {\n disabledDates = parseDateList(Array.isArray(list) ? list.join(\",\") : list);\n buildGrid();\n }\n\n /** Show an adjacent month without moving DOM focus (nav-button clicks). */\n function shiftView(delta) {\n viewMonth += delta;\n if (viewMonth < 0) {\n viewMonth = 11;\n viewYear--;\n } else if (viewMonth > 11) {\n viewMonth = 0;\n viewYear++;\n }\n focusedDate = clampToRange(new Date(viewYear, viewMonth, 1));\n buildGrid();\n }\n\n function onPrevClick() {\n shiftView(-1);\n }\n\n function onNextClick() {\n shiftView(1);\n }\n\n function onGridClick(e) {\n const dayBtn = e.target.closest(\"[data-part='day']\");\n if (dayBtn && dayBtn.dataset.date && dayBtn.getAttribute(\"aria-disabled\") !== \"true\") {\n selectDate(parseISO(dayBtn.dataset.date));\n }\n }\n\n function onKeyDown(e) {\n // Grid navigation only applies while a day cell has focus\n const dayBtn = e.target.closest ? e.target.closest(\"[data-part='day']\") : null;\n if (!dayBtn) return;\n\n if (dayBtn.dataset.date && !isSameDay(focusedDate, parseISO(dayBtn.dataset.date))) {\n focusedDate = parseISO(dayBtn.dataset.date);\n }\n\n switch (e.key) {\n case \"ArrowLeft\":\n e.preventDefault();\n moveFocus(-1);\n break;\n case \"ArrowRight\":\n e.preventDefault();\n moveFocus(1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n moveFocus(-7);\n break;\n case \"ArrowDown\":\n e.preventDefault();\n moveFocus(7);\n break;\n case \"Home\":\n e.preventDefault();\n if (focusedDate) moveFocus(-focusedDate.getDay());\n break;\n case \"End\":\n e.preventDefault();\n if (focusedDate) moveFocus(6 - focusedDate.getDay());\n break;\n case \"PageUp\":\n e.preventDefault();\n if (e.shiftKey) {\n moveFocusMonths(-12);\n } else {\n moveFocusMonths(-1);\n }\n break;\n case \"PageDown\":\n e.preventDefault();\n if (e.shiftKey) {\n moveFocusMonths(12);\n } else {\n moveFocusMonths(1);\n }\n break;\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (focusedDate) selectDate(focusedDate);\n break;\n }\n }\n\n navPrev?.addEventListener(\"click\", onPrevClick);\n navNext?.addEventListener(\"click\", onNextClick);\n gridBody?.addEventListener(\"click\", onGridClick);\n root.addEventListener(\"keydown\", onKeyDown);\n\n buildGrid();\n\n function destroy() {\n navPrev?.removeEventListener(\"click\", onPrevClick);\n navNext?.removeEventListener(\"click\", onNextClick);\n gridBody?.removeEventListener(\"click\", onGridClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirCalendar;\n }\n\n const api = {\n getValue,\n setValue,\n clear,\n navigate,\n selectDate,\n focusDate,\n setMin,\n setMax,\n setDisabledDates,\n destroy,\n };\n root._faqirCalendar = api;\n return api;\n}\n return createCalendar;\n })();\n\n // ── carousel ── (registry/recipes/carousel/carousel.js)\n var createCarousel = controllerRegistry[\"carousel\"] = (function() {\n// @ui:controller carousel\n// @ui:provides next prev goTo getIndex getCount destroy\n\n/**\n * carousel — a CSS scroll-snap strip with a deliberately tiny enhancement layer.\n *\n * CSS owns the sliding: `[data-part=\"viewport\"]` scrolls on the inline axis with\n * `scroll-snap-type: inline mandatory`, and each `[data-part=\"slide\"]` is a snap\n * target. That means the component is fully usable with this file absent —\n * swipe, wheel and (the viewport is `tabindex=\"0\"`) the arrow keys all work.\n *\n * So the controller owns ONLY what CSS cannot:\n *\n * • prev/next buttons and dots — inert markup that ships `hidden` and is\n * un-hidden here, so a reader without JS never sees a dead control;\n * • current-slide tracking by scroll math (no IntersectionObserver: one\n * rAF-throttled `getBoundingClientRect` pass answers \"which snap point are\n * we on?\" exactly, and works identically for programmatic and user scrolls);\n * • the boundary contract — \"stop\" by default (the end button is `disabled`),\n * \"loop\" when the root carries `data-loop`;\n * • the `[data-part=\"status\"]` live region (\"Slide 2 of 3\");\n * • reduced motion — an explicit `behavior: \"instant\"` (which beats the CSS\n * `scroll-behavior: smooth`) rather than an animated scroll.\n *\n * Scrolling always goes through the PHYSICAL delta `slide.left - viewport.left`\n * added to `scrollLeft`, which is correct in both LTR and RTL (where `scrollLeft`\n * runs negative). Only the \"which slide is current?\" comparison is\n * direction-aware, since the snap edge is `inline-start`.\n */\nfunction createCarousel(root) {\n // Prevent double-init.\n if (root._faqirCarousel) return root._faqirCarousel;\n\n const viewport = root.querySelector(\"[data-part='viewport']\");\n if (!viewport) return null;\n\n const loop = root.hasAttribute(\"data-loop\");\n // A carousel nested in a slide brings its own slides, buttons and dots:\n // slides are the viewport's children, the rest go through the owner guard.\n const slides = () => [...viewport.querySelectorAll(\":scope > [data-part='slide']\")];\n const dots = () => ownParts(root, \"dot\");\n const [prevBtn] = ownParts(root, \"prev\");\n const [nextBtn] = ownParts(root, \"next\");\n const [status] = ownParts(root, \"status\");\n const enhanced = [...ownParts(root, \"controls\"), ...ownParts(root, \"dots\")];\n\n let index = 0;\n\n // ── environment probes (read live, so preference changes are honored) ───────\n const reducedMotion = () =>\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n !!window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n const isRtl = () => {\n const cs = typeof getComputedStyle === \"function\" ? getComputedStyle(root) : null;\n return (cs && cs.direction) === \"rtl\";\n };\n\n const rectOf = (el) =>\n el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, right: 0 };\n\n /**\n * Per-slide geometry, measured against the viewport:\n * `delta` — physical px to add to `scrollLeft` to bring the slide into view.\n * `edge` — signed distance on the snap (inline-start) edge; the slide whose\n * |edge| is smallest is the current one.\n */\n function metrics() {\n const v = rectOf(viewport);\n const rtl = isRtl();\n return slides().map((s) => {\n const r = rectOf(s);\n return { delta: r.left - v.left, edge: rtl ? r.right - v.right : r.left - v.left };\n });\n }\n\n function nearestIndex() {\n let best = 0;\n let bestDistance = Infinity;\n metrics().forEach((m, i) => {\n const d = Math.abs(m.edge);\n if (d < bestDistance) {\n bestDistance = d;\n best = i;\n }\n });\n return best;\n }\n\n /** Apply the boundary contract: wrap when `data-loop`, otherwise clamp. */\n function resolve(i, count) {\n if (!count) return 0;\n return loop ? ((i % count) + count) % count : Math.min(Math.max(i, 0), count - 1);\n }\n\n // ── reflection ──────────────────────────────────────────────────────────────\n function sync() {\n const count = slides().length;\n dots().forEach((d, i) => {\n const on = i === index;\n d.dataset.state = on ? \"active\" : \"inactive\";\n if (on) d.setAttribute(\"aria-current\", \"true\");\n else d.removeAttribute(\"aria-current\");\n });\n if (prevBtn) prevBtn.disabled = !loop && index <= 0;\n if (nextBtn) nextBtn.disabled = !loop && index >= count - 1;\n if (status) status.textContent = count ? `Slide ${index + 1} of ${count}` : \"\";\n }\n\n function setIndex(i) {\n if (i === index) return;\n index = i;\n sync();\n root.dispatchEvent(\n new CustomEvent(\"faqir:change\", {\n bubbles: true,\n detail: { index, count: slides().length },\n }),\n );\n }\n\n // ── navigation ──────────────────────────────────────────────────────────────\n function goTo(i) {\n const list = slides();\n if (!list.length) return;\n const target = resolve(i, list.length);\n const m = metrics()[target];\n const left = (viewport.scrollLeft || 0) + (m ? m.delta : 0);\n const behavior = reducedMotion() ? \"instant\" : \"smooth\";\n if (typeof viewport.scrollTo === \"function\") viewport.scrollTo({ left, behavior });\n else viewport.scrollLeft = left;\n setIndex(target);\n }\n\n const next = () => goTo(index + 1);\n const prev = () => goTo(index - 1);\n\n // ── events ──────────────────────────────────────────────────────────────────\n function onClick(e) {\n // Matched by identity, so a nested carousel's buttons are not these. A\n // missing button is `undefined`, never equal to a `null` miss here.\n const btn = e.target.closest(\"[data-part]\");\n const dot = dots().indexOf(btn);\n if (btn === nextBtn) next();\n else if (btn === prevBtn) prev();\n else if (dot >= 0) goTo(dot);\n }\n\n // One rAF-throttled measurement per scroll burst keeps tracking cheap.\n const schedule =\n typeof requestAnimationFrame === \"function\"\n ? requestAnimationFrame\n : (fn) => setTimeout(fn, 16);\n let ticking = false;\n function onScroll() {\n if (ticking) return;\n ticking = true;\n schedule(() => {\n ticking = false;\n setIndex(nearestIndex());\n });\n }\n\n // Enhance: the JS-only controls become visible now that JS is here.\n enhanced.forEach((el) => {\n el.hidden = false;\n });\n\n root.addEventListener(\"click\", onClick);\n viewport.addEventListener(\"scroll\", onScroll);\n sync();\n\n function destroy() {\n root.removeEventListener(\"click\", onClick);\n viewport.removeEventListener(\"scroll\", onScroll);\n // Back to the no-JS baseline: the inert controls hide again.\n enhanced.forEach((el) => {\n el.hidden = true;\n });\n delete root._faqirCarousel;\n }\n\n const api = { goTo, next, prev, getIndex: () => index, getCount: () => slides().length, destroy };\n root._faqirCarousel = api;\n return api;\n}\n return createCarousel;\n })();\n\n // ── combobox ── (registry/recipes/combobox/combobox.js)\n var createCombobox = controllerRegistry[\"combobox\"] = (function() {\n// @ui:controller combobox\n// @ui:provides open close filter selectOption getValue setValue destroy\n\nfunction createCombobox(root) {\n // Prevent double-init\n if (root._faqirCombobox) return root._faqirCombobox;\n\n const input = root.querySelector(\"[data-part='input']\");\n const listbox = root.querySelector(\"[data-part='listbox']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const options = () =>\n [...root.querySelectorAll(\"[data-part='option']\")];\n\n let highlightedIndex = -1;\n let outsideClickCleanup = null;\n let selectedValue = \"\";\n\n /**\n * `aria-activedescendant` — the half of the combobox pattern that was declared\n * and never implemented. [W3-4]\n *\n * The markup publishes `role=\"combobox\"` and `aria-autocomplete=\"list\"`, which\n * is the APG contract: as the user arrows through the list, the combobox must\n * name the active option so a screen reader announces it. Highlighting was\n * tracked in `data-highlighted` alone and the options carried no `id`, so\n * there was nothing to point at and nothing was ever announced — the widget\n * claimed a pattern it did not implement. The axe gate structurally cannot see\n * this: it evaluates static DOM, and the defect exists only mid-navigation.\n *\n * Ids are minted on demand so authored ids are respected and generated markup\n * needs none.\n */\n function optionId(opt) {\n if (!opt.id) opt.id = uid(\"faqir-option\");\n return opt.id;\n }\n\n function setActiveDescendant(opt) {\n if (opt) input.setAttribute(\"aria-activedescendant\", optionId(opt));\n else input.removeAttribute(\"aria-activedescendant\");\n }\n\n function open() {\n root.dataset.state = \"open\";\n listbox.hidden = false;\n input.setAttribute(\"aria-expanded\", \"true\");\n\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n function close() {\n root.dataset.state = \"closed\";\n listbox.hidden = true;\n input.setAttribute(\"aria-expanded\", \"false\");\n clearHighlight();\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function clearHighlight() {\n const allOptions = options();\n allOptions.forEach((opt) => {\n opt.removeAttribute(\"data-highlighted\");\n opt.setAttribute(\"aria-selected\", \"false\");\n });\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function highlightOption(index) {\n const allOptions = visibleOptions();\n if (allOptions.length === 0) return;\n\n // Clamp index\n if (index < 0) index = allOptions.length - 1;\n if (index >= allOptions.length) index = 0;\n\n // Clear previous\n options().forEach((opt) => {\n opt.removeAttribute(\"data-highlighted\");\n opt.setAttribute(\"aria-selected\", \"false\");\n });\n\n allOptions[index].setAttribute(\"data-highlighted\", \"\");\n allOptions[index].setAttribute(\"aria-selected\", \"true\");\n allOptions[index].scrollIntoView({ block: \"nearest\" });\n setActiveDescendant(allOptions[index]);\n highlightedIndex = index;\n }\n\n function visibleOptions() {\n return options().filter((opt) => !opt.hasAttribute(\"data-hidden\"));\n }\n\n function filter(query) {\n const allOptions = options();\n const lowerQuery = query.toLowerCase();\n let visibleCount = 0;\n\n allOptions.forEach((opt) => {\n const text = opt.textContent.toLowerCase();\n if (text.includes(lowerQuery)) {\n opt.removeAttribute(\"data-hidden\");\n visibleCount++;\n } else {\n opt.setAttribute(\"data-hidden\", \"\");\n }\n });\n\n // Show/hide empty state\n if (emptyEl) {\n emptyEl.hidden = visibleCount > 0;\n }\n\n clearHighlight();\n\n return visibleCount;\n }\n\n function selectOption(index) {\n const visible = visibleOptions();\n if (index < 0 || index >= visible.length) return;\n\n const opt = visible[index];\n selectedValue = opt.textContent.trim();\n input.value = selectedValue;\n\n // Mark as selected\n options().forEach((o) => o.setAttribute(\"aria-selected\", \"false\"));\n opt.setAttribute(\"aria-selected\", \"true\");\n\n close();\n }\n\n function getValue() {\n return selectedValue;\n }\n\n function setValue(val) {\n selectedValue = val;\n input.value = val;\n }\n\n // ── Event Handlers ──\n\n function onInput() {\n const query = input.value;\n if (root.dataset.state !== \"open\") {\n open();\n }\n filter(query);\n }\n\n function onInputFocus() {\n if (root.dataset.state !== \"open\") {\n open();\n }\n }\n\n function onInputKeyDown(e) {\n const visible = visibleOptions();\n\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n if (root.dataset.state !== \"open\") open();\n highlightOption(highlightedIndex + 1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n if (root.dataset.state !== \"open\") open();\n highlightOption(highlightedIndex - 1);\n break;\n case \"Enter\":\n e.preventDefault();\n if (highlightedIndex >= 0 && highlightedIndex < visible.length) {\n selectOption(highlightedIndex);\n }\n break;\n case \"Escape\":\n // Only ours while the list is open; a closed combobox lets Escape reach\n // the dialog it sits in rather than swallowing it. [W3-2]\n if (root.dataset.state === \"open\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n }\n break;\n case \"Home\":\n if (root.dataset.state === \"open\" && visible.length > 0) {\n e.preventDefault();\n highlightOption(0);\n }\n break;\n case \"End\":\n if (root.dataset.state === \"open\" && visible.length > 0) {\n e.preventDefault();\n highlightOption(visible.length - 1);\n }\n break;\n }\n }\n\n function onListboxClick(e) {\n const opt = e.target.closest(\"[data-part='option']\");\n if (!opt) return;\n\n const visible = visibleOptions();\n const index = visible.indexOf(opt);\n if (index >= 0) {\n selectOption(index);\n }\n }\n\n input?.addEventListener(\"input\", onInput);\n input?.addEventListener(\"focus\", onInputFocus);\n input?.addEventListener(\"keydown\", onInputKeyDown);\n listbox?.addEventListener(\"click\", onListboxClick);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close();\n input?.removeEventListener(\"input\", onInput);\n input?.removeEventListener(\"focus\", onInputFocus);\n input?.removeEventListener(\"keydown\", onInputKeyDown);\n listbox?.removeEventListener(\"click\", onListboxClick);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirCombobox;\n }\n\n const api = { open, close, filter, selectOption, getValue, setValue, destroy };\n root._faqirCombobox = api;\n return api;\n}\n return createCombobox;\n })();\n\n // ── command-palette ── (registry/recipes/command-palette/command-palette.js)\n var createCommandPalette = controllerRegistry[\"command-palette\"] = (function() {\n// @ui:controller command-palette\n// @ui:provides open close filter selectItem registerCommand destroy\n\nfunction createCommandPalette(root) {\n // Prevent double-init\n if (root._faqirCommandPalette) return root._faqirCommandPalette;\n\n const overlay = root.querySelector(\"[data-part='overlay']\");\n const panel = root.querySelector(\"[data-part='panel']\");\n const searchInput = root.querySelector(\"[data-part='search']\");\n const list = root.querySelector(\"[data-part='list']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const items = () =>\n [...root.querySelectorAll(\"[data-part='item']\")];\n const groups = () =>\n [...root.querySelectorAll(\"[data-part='group']\")];\n\n let highlightedIndex = -1;\n let focusCleanup = null;\n let previouslyFocused = null;\n const registeredCommands = [];\n\n function open() {\n previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n\n // Reset search and highlights\n searchInput.value = \"\";\n filter(\"\");\n clearHighlight();\n\n focusCleanup = trapFocus(panel);\n searchInput.focus();\n }\n\n /**\n * Everything `close()` does EXCEPT moving focus.\n *\n * `destroy()` used to leave an open overlay standing with nothing listening —\n * a dead widget the user cannot dismiss. Closing it on teardown is the fix\n * (`context-menu` is the model), but teardown must not also yank focus\n * somewhere: on an SPA route change the element it would restore to is\n * usually on its way out of the document. [W3-2]\n */\n function dismiss() {\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n // A closed palette must not still name an active item: `aria-activedescendant`\n // pointing into a hidden list is a reference a reader can follow to nothing. [W3-4]\n clearHighlight();\n\n if (focusCleanup) {\n focusCleanup();\n focusCleanup = null;\n }\n }\n\n function close() {\n const active = document.activeElement;\n dismiss();\n // The opener may have left with another overlay — the downstream palette\n // was opened from inside a dialog that closed underneath it.\n returnFocus(root, previouslyFocused, active);\n }\n\n /**\n * `aria-activedescendant` — the declared half of the combobox pattern. [W3-4]\n *\n * The search field publishes `role=\"combobox\"` and `aria-autocomplete=\"list\"`,\n * which obliges it to name the active item as the user arrows through the\n * results. Highlighting lived in `data-highlighted` alone and the items had no\n * `id`, so a screen-reader user heard nothing move. The axe gate cannot see\n * this — it reads static DOM, and the defect exists only mid-navigation.\n */\n function itemId(item) {\n if (!item.id) item.id = uid(\"faqir-command\");\n return item.id;\n }\n\n function setActiveDescendant(item) {\n if (!searchInput) return;\n if (item) searchInput.setAttribute(\"aria-activedescendant\", itemId(item));\n else searchInput.removeAttribute(\"aria-activedescendant\");\n }\n\n function clearHighlight() {\n items().forEach((item) => {\n item.removeAttribute(\"data-highlighted\");\n item.setAttribute(\"aria-selected\", \"false\");\n });\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function visibleItems() {\n return items().filter((item) => !item.hasAttribute(\"data-hidden\"));\n }\n\n function highlightItem(index) {\n const visible = visibleItems();\n if (visible.length === 0) return;\n\n // Clamp index\n if (index < 0) index = visible.length - 1;\n if (index >= visible.length) index = 0;\n\n // Clear previous\n items().forEach((item) => {\n item.removeAttribute(\"data-highlighted\");\n item.setAttribute(\"aria-selected\", \"false\");\n });\n\n visible[index].setAttribute(\"data-highlighted\", \"\");\n visible[index].setAttribute(\"aria-selected\", \"true\");\n visible[index].scrollIntoView({ block: \"nearest\" });\n setActiveDescendant(visible[index]);\n highlightedIndex = index;\n }\n\n function filter(query) {\n const allItems = items();\n const allGroups = groups();\n const lowerQuery = query.toLowerCase();\n let totalVisible = 0;\n\n // Track visible items per group\n const groupVisibility = new Map();\n allGroups.forEach((g) => groupVisibility.set(g, 0));\n\n allItems.forEach((item) => {\n const label = item.querySelector(\"[data-part='item-label']\");\n const text = (label || item).textContent.toLowerCase();\n\n if (text.includes(lowerQuery)) {\n item.removeAttribute(\"data-hidden\");\n totalVisible++;\n // Find parent group\n const parentGroup = item.closest(\"[data-part='group']\");\n if (parentGroup && groupVisibility.has(parentGroup)) {\n groupVisibility.set(parentGroup, groupVisibility.get(parentGroup) + 1);\n }\n } else {\n item.setAttribute(\"data-hidden\", \"\");\n }\n });\n\n // Hide groups with no visible items\n allGroups.forEach((group) => {\n if (groupVisibility.get(group) === 0) {\n group.setAttribute(\"data-hidden\", \"\");\n } else {\n group.removeAttribute(\"data-hidden\");\n }\n });\n\n // Show/hide empty state\n if (emptyEl) {\n emptyEl.hidden = totalVisible > 0;\n }\n\n clearHighlight();\n\n return totalVisible;\n }\n\n function selectItem(index) {\n const visible = visibleItems();\n if (index < 0 || index >= visible.length) return;\n\n const item = visible[index];\n\n // Fire a custom event for the application to handle\n const event = new CustomEvent(\"command-select\", {\n bubbles: true,\n detail: {\n item,\n label: item.querySelector(\"[data-part='item-label']\")?.textContent || item.textContent\n }\n });\n root.dispatchEvent(event);\n\n // Check registered commands\n const label = (item.querySelector(\"[data-part='item-label']\") || item).textContent.trim();\n const cmd = registeredCommands.find((c) => c.label === label);\n if (cmd?.action) cmd.action();\n\n close();\n }\n\n function registerCommand(cmd) {\n registeredCommands.push(cmd);\n }\n\n // ── Event Handlers ──\n\n function onSearchInput() {\n filter(searchInput.value);\n }\n\n function onSearchKeyDown(e) {\n const visible = visibleItems();\n\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n highlightItem(highlightedIndex + 1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n highlightItem(highlightedIndex - 1);\n break;\n case \"Enter\":\n e.preventDefault();\n if (highlightedIndex >= 0 && highlightedIndex < visible.length) {\n selectItem(highlightedIndex);\n }\n break;\n case \"Escape\":\n // The palette is an overlay in its own right: dismissing it must not\n // also dismiss whatever it was opened over. [W3-2]\n if (root.dataset.state === \"open\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n }\n break;\n case \"Home\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightItem(0);\n }\n break;\n case \"End\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightItem(visible.length - 1);\n }\n break;\n }\n }\n\n function onOverlayClick() {\n close();\n }\n\n function onItemClick(e) {\n const item = e.target.closest(\"[data-part='item']\");\n if (!item) return;\n\n const visible = visibleItems();\n const index = visible.indexOf(item);\n if (index >= 0) {\n selectItem(index);\n }\n }\n\n /**\n * Cmd/Ctrl+K — one owner per press.\n *\n * Every instance listens on `document`, so a page with three palettes used to\n * open three stacked focus traps. The first instance to act prevents default\n * and every later one (or one an app handler pre-empted) stands down;\n * `data-no-shortcut` opts an instance out entirely, read live, and a palette\n * whose root has left the document without `destroy()` (an SPA route change)\n * no longer claims the press from the live one. The key is\n * matched case-insensitively (Caps Lock sends \"K\"), falling back to the\n * physical key on a non-Latin layout; Shift is left alone because Cmd+Shift+K\n * is a browser and app chord of its own.\n */\n function onGlobalKeyDown(e) {\n if (e.defaultPrevented || !root.isConnected || root.hasAttribute(\"data-no-shortcut\")) return;\n if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey || e.repeat || e.isComposing) return;\n const k = (e.key || \"\").toLowerCase();\n if (k !== \"k\" && (/^[a-z]$/.test(k) || e.code !== \"KeyK\")) return;\n e.preventDefault();\n if (root.dataset.state === \"open\") {\n close();\n } else {\n open();\n }\n }\n\n searchInput?.addEventListener(\"input\", onSearchInput);\n searchInput?.addEventListener(\"keydown\", onSearchKeyDown);\n overlay?.addEventListener(\"click\", onOverlayClick);\n list?.addEventListener(\"click\", onItemClick);\n document.addEventListener(\"keydown\", onGlobalKeyDown);\n\n function destroy() {\n dismiss();\n searchInput?.removeEventListener(\"input\", onSearchInput);\n searchInput?.removeEventListener(\"keydown\", onSearchKeyDown);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n list?.removeEventListener(\"click\", onItemClick);\n document.removeEventListener(\"keydown\", onGlobalKeyDown);\n if (focusCleanup) focusCleanup();\n delete root._faqirCommandPalette;\n }\n\n const api = { open, close, filter, selectItem, registerCommand, destroy };\n root._faqirCommandPalette = api;\n return api;\n}\n return createCommandPalette;\n })();\n\n // ── context-menu ── (registry/recipes/context-menu/context-menu.js)\n var createContextMenu = controllerRegistry[\"context-menu\"] = (function() {\n// @ui:controller context-menu\n// @ui:provides open close destroy\n\nfunction createContextMenu(root) {\n if (root._faqirContextMenu) return root._faqirContextMenu;\n\n // Matched by owner: a dropdown inside the target has a `menu` part too, and\n // it comes first in document order.\n const [target] = ownParts(root, \"target\");\n const [menu] = ownParts(root, \"menu\");\n\n // Same as `dropdown`: a missing part must name itself rather than throwing a\n // TypeError out of `createMenuNavigation(null)`. [W3-2]\n if (!target || !menu) {\n console.warn(\n \"[Faqir] context-menu needs [data-part='target'] and [data-part='menu'] — \" +\n `missing ${[!target && \"target\", !menu && \"menu\"].filter(Boolean).join(\" and \")}. ` +\n \"Component left inert.\",\n root\n );\n const inert = { open() {}, close() {}, destroy() {} };\n root._faqirContextMenu = inert;\n return inert;\n }\n\n let outsideClickCleanup = null;\n\n function clearOutsideClick() {\n if (!outsideClickCleanup) return;\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n\n function close(options = {}) {\n const { restoreFocus = true } = options;\n\n root.dataset.state = \"closed\";\n menu.hidden = true;\n target.setAttribute(\"aria-expanded\", \"false\");\n clearOutsideClick();\n\n if (restoreFocus && target.isConnected) target.focus();\n }\n\n const navigation = createMenuNavigation(menu, {\n onEscape() {\n close({ restoreFocus: true });\n },\n onTab() {\n close({ restoreFocus: false });\n },\n });\n\n function open(x = 0, y = 0) {\n clearOutsideClick();\n\n menu.style.left = `${x}px`;\n menu.style.top = `${y}px`;\n menu.hidden = false;\n root.dataset.state = \"open\";\n target.setAttribute(\"aria-expanded\", \"true\");\n\n navigation.focusFirst();\n\n outsideClickCleanup = onOutsideClick(menu, () => {\n close({ restoreFocus: false });\n });\n }\n\n function onContextMenu(event) {\n event.preventDefault();\n open(event.clientX, event.clientY);\n }\n\n function onTargetKeyDown(event) {\n const isContextMenuKey = event.key === \"ContextMenu\";\n const isShiftF10 = event.key === \"F10\" && event.shiftKey;\n if (!isContextMenuKey && !isShiftF10) return;\n\n event.preventDefault();\n const rect = target.getBoundingClientRect();\n open(rect.left, rect.bottom);\n }\n\n function onMenuClick(event) {\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !menu.contains(item)) return;\n\n if (item.disabled || item.getAttribute(\"aria-disabled\") === \"true\") {\n event.preventDefault();\n return;\n }\n\n close({ restoreFocus: true });\n }\n\n target?.addEventListener(\"contextmenu\", onContextMenu);\n target?.addEventListener(\"keydown\", onTargetKeyDown);\n menu?.addEventListener(\"click\", onMenuClick);\n\n function destroy() {\n target?.removeEventListener(\"contextmenu\", onContextMenu);\n target?.removeEventListener(\"keydown\", onTargetKeyDown);\n menu?.removeEventListener(\"click\", onMenuClick);\n navigation.destroy();\n clearOutsideClick();\n\n root.dataset.state = \"closed\";\n menu.hidden = true;\n target.setAttribute(\"aria-expanded\", \"false\");\n delete root._faqirContextMenu;\n }\n\n const api = { open, close, destroy };\n root._faqirContextMenu = api;\n return api;\n}\n return createContextMenu;\n })();\n\n // ── date-picker ── (registry/recipes/date-picker/date-picker.js)\n var createDatePicker = controllerRegistry[\"date-picker\"] = (function() {\n// @ui:controller date-picker\n// @ui:provides open close getValue setValue navigate selectDate destroy\n\nconst MONTH_NAMES = [\n \"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\",\n];\n\nfunction createDatePicker(root) {\n // Prevent double-init\n if (root._faqirDatePicker) return root._faqirDatePicker;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const input = root.querySelector(\"[data-part='input']\");\n const popup = root.querySelector(\"[data-part='calendar']\");\n\n // The month grid is the standalone `calendar` recipe. Canonical markup nests\n // [data-ui=\"calendar\"] inside the popup; legacy flat markup (grid parts\n // directly inside the popup) still works — the popup itself then acts as the\n // calendar root.\n const calendarRoot = root.querySelector(\"[data-ui='calendar']\") || popup;\n\n // `input` carries the value and the aria-expanded state, `popup` is what\n // opens; either one missing made every open()/close() throw. `trigger` is\n // optional — an input-only date picker opens from the field. [W3-2]\n if (!input || !popup) {\n console.warn(\n \"[Faqir] date-picker needs [data-part='input'] and [data-part='calendar'] — \" +\n `missing ${[!input && \"input\", !popup && \"calendar\"].filter(Boolean).join(\" and \")}. ` +\n \"Component left inert.\",\n root\n );\n const inert = {\n open() {},\n close() {},\n getValue: () => null,\n setValue() {},\n navigate() {},\n selectDate() {},\n destroy() {},\n };\n root._faqirDatePicker = inert;\n return inert;\n }\n const calendar = createCalendar(calendarRoot);\n\n const today = new Date();\n let outsideClickCleanup = null;\n\n function formatDisplay(date) {\n return `${MONTH_NAMES[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n }\n\n function syncInput(dateStr, dateObj) {\n input.value = formatDisplay(dateObj);\n input.dataset.value = dateStr;\n }\n\n function open() {\n root.dataset.state = \"open\";\n popup.hidden = false;\n input.setAttribute(\"aria-expanded\", \"true\");\n\n // Focus the selected day, or the first of the current month\n const value = calendar.getValue();\n const target = value\n ? new Date(value + \"T00:00:00\")\n : new Date(today.getFullYear(), today.getMonth(), 1);\n calendar.focusDate(target);\n\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n function close() {\n root.dataset.state = \"closed\";\n popup.hidden = true;\n input.setAttribute(\"aria-expanded\", \"false\");\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function selectDate(date) {\n // Delegates to the calendar; input update, close and the faqir:date-change\n // re-emit all happen in onCalendarChange.\n calendar.selectDate(date);\n }\n\n function getValue() {\n return calendar.getValue();\n }\n\n function setValue(dateStr) {\n const parsed = new Date(dateStr + \"T00:00:00\");\n if (!isNaN(parsed.getTime())) {\n calendar.setValue(dateStr);\n syncInput(dateStr, parsed);\n }\n }\n\n function navigate(month, year) {\n calendar.navigate(month, year);\n }\n\n // Event: calendar selection committed\n function onCalendarChange(e) {\n if (!e.detail || !e.detail.date) return;\n syncInput(e.detail.date, e.detail.dateObj);\n close();\n input.focus();\n\n root.dispatchEvent(\n new CustomEvent(\"faqir:date-change\", {\n detail: { date: e.detail.date, dateObj: e.detail.dateObj },\n bubbles: true,\n })\n );\n }\n\n // Event: trigger/input click\n function onTriggerClick() {\n if (root.dataset.state === \"open\") {\n close();\n } else {\n open();\n }\n }\n\n // Event: escape on root (bubbles up from the calendar grid too)\n function onRootKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.preventDefault();\n // Closing the calendar popup is the whole action — a date picker inside a\n // dialog must not take the dialog down with it. [W3-2]\n e.stopPropagation();\n close();\n input.focus();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n root.addEventListener(\"faqir:calendar-change\", onCalendarChange);\n root.addEventListener(\"keydown\", onRootKeyDown);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close();\n trigger?.removeEventListener(\"click\", onTriggerClick);\n root.removeEventListener(\"faqir:calendar-change\", onCalendarChange);\n root.removeEventListener(\"keydown\", onRootKeyDown);\n if (outsideClickCleanup) outsideClickCleanup();\n calendar.destroy();\n delete root._faqirDatePicker;\n }\n\n const api = { open, close, getValue, setValue, navigate, selectDate, destroy };\n root._faqirDatePicker = api;\n return api;\n}\n return createDatePicker;\n })();\n\n // ── dialog ── (registry/recipes/dialog/dialog.js)\n var createDialog = controllerRegistry[\"dialog\"] = (function() {\n// @ui:controller dialog\n// @ui:provides open close toggle destroy\n\n/**\n * Shared modal-dialog controller.\n *\n * It drives both the `dialog` recipe and the `alert-dialog` recipe — the two are\n * one controller, distinguished only by the panel's ARIA role. When the panel\n * declares `role=\"alertdialog\"` the controller switches to the WAI-ARIA\n * alertdialog contract:\n * - the overlay backdrop does NOT dismiss (only an explicit choice closes it);\n * - focus lands on the least-destructive action (cancel/close), not the panel;\n * - Escape still closes by default, but a `data-confirm-required` root traps it\n * so the user must pick confirm or cancel;\n * - the footer's `[data-part=\"confirm\"]` / `[data-part=\"cancel\"]` actions emit\n * cancelable `faqir:confirm` / `faqir:cancel` events (a prevented confirm\n * keeps the dialog open for async work).\n * A plain `role=\"dialog\"` panel behaves exactly as before.\n */\nfunction createDialog(root) {\n // Prevent double-init\n if (root._faqirDialog) return root._faqirDialog;\n\n // Overlay and panel are direct children. Trigger and actions may be wrapped\n // in layout primitives, so they are matched by owner: a popover's close\n // button inside the panel belongs to the popover and must not close this.\n const [trigger] = ownParts(root, \"trigger\");\n const overlay = root.querySelector(\":scope > [data-part='overlay']\");\n const panel = root.querySelector(\":scope > [data-part='panel']\");\n const closeButtons = ownParts(root, \"close\");\n const confirmButtons = ownParts(root, \"confirm\");\n const cancelButtons = ownParts(root, \"cancel\");\n\n // The role is the seam between `dialog` and `alert-dialog` — read it from the\n // markup so a single controller serves both recipes.\n const isAlert = !!panel && panel.getAttribute(\"role\") === \"alertdialog\";\n\n // `panel.focus()` on open does nothing without a tabindex: focus stayed on\n // `body`, out of reach of the trap and the root's Escape listener.\n if (panel && !panel.hasAttribute(\"tabindex\")) panel.setAttribute(\"tabindex\", \"-1\");\n\n let focusCleanup = null;\n let previouslyFocused = null;\n\n /** A confirm-required alertdialog traps Escape/overlay until an action is taken. */\n function confirmRequired() {\n return isAlert && root.hasAttribute(\"data-confirm-required\");\n }\n\n /** Emit a cancelable, bubbling `faqir:<type>` event; returns the event. */\n function emit(type, detail) {\n const event = new CustomEvent(\"faqir:\" + type, {\n bubbles: true,\n cancelable: true,\n detail: detail || {},\n });\n root.dispatchEvent(event);\n return event;\n }\n\n /** On open, focus the least-destructive action for an alert, else the panel. */\n function focusInitial() {\n if (isAlert) {\n const target = cancelButtons[0] || closeButtons[0] || panel;\n target?.focus?.();\n } else {\n panel?.focus?.();\n }\n }\n\n // Cancels an in-flight \"closing\" wait when the dialog is re-opened mid-exit.\n let cancelExitWait = null;\n\n function open() {\n // A second open() (trigger plus an external trigger, say) must not stack\n // another focus trap or overwrite the focus to restore on close.\n if (root.dataset.state === \"open\" && focusCleanup) return;\n cancelExitWait?.();\n cancelExitWait = null;\n // Re-opened mid-exit: the trap and the focus to restore are still live.\n if (!focusCleanup) previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n if (!focusCleanup) focusCleanup = trapFocus(panel);\n focusInitial();\n }\n\n function close() {\n // Already gone, or already animating out — a second click (confirm then\n // close, say) must not start a second wait on top of the one in flight.\n if (root.dataset.state === \"closed\" || root.dataset.state === \"closing\") return;\n\n root.dataset.state = \"closing\";\n\n const onEnd = () => {\n cancelExitWait = null;\n const active = document.activeElement;\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n returnFocus(root, previouslyFocused, active);\n };\n\n // The panel's own exit motion. A footer button's `background` transitionend\n // bubbles here the instant the pointer touches it, and used to eat the\n // one-shot listener — snapping the panel away mid-animation at best, and at\n // worst leaving it up. No property filter: the panel's exit is an\n // `animation` in some themes and a `transition` in others. See\n // `whenExitDone`. [W2-1]\n cancelExitWait = whenExitDone(panel, null, onEnd);\n }\n\n /**\n * Tear the overlay down NOW — no exit animation, no focus restore.\n *\n * `destroy()` unbound every listener and left the panel and its backdrop\n * exactly where they were: a full-page block whose close button, Escape key\n * and overlay click had all just stopped working, with no way out. An SPA\n * route change destroys controllers and does precisely this. The model is\n * `context-menu`, which has always closed itself on teardown. [W3-2]\n */\n function dismiss() {\n cancelExitWait?.();\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n if (overlay) overlay.hidden = true;\n if (panel) panel.hidden = true;\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event listeners\n function onTriggerClick() {\n open();\n }\n function onOverlayClick() {\n close();\n }\n // In alert mode, dismissing without confirming is a cancel; the plain dialog\n // just closes.\n function onCloseClick() {\n if (isAlert) emit(\"cancel\", { reason: \"close\" });\n close();\n }\n function onCancelClick() {\n emit(\"cancel\", { reason: \"cancel\" });\n close();\n }\n function onConfirmClick() {\n const variant =\n panel?.getAttribute(\"data-variant\") ||\n root.getAttribute(\"data-variant\") ||\n \"default\";\n const event = emit(\"confirm\", { variant });\n // A handler may keep the dialog open (e.g. to await a destructive request)\n // by calling preventDefault() on the confirm event.\n if (!event.defaultPrevented) close();\n }\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n // WAI-ARIA allows Escape to close an alertdialog, but a confirm-required\n // variant traps it so the user must make an explicit choice.\n if (confirmRequired()) {\n e.stopPropagation();\n return;\n }\n e.stopPropagation();\n if (isAlert) emit(\"cancel\", { reason: \"escape\" });\n close();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n // An alertdialog must not dismiss on overlay click — only an explicit choice\n // closes it — so the overlay handler is bound for plain dialogs only.\n if (!isAlert) overlay?.addEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) => btn.addEventListener(\"click\", onCloseClick));\n confirmButtons.forEach((btn) => btn.addEventListener(\"click\", onConfirmClick));\n cancelButtons.forEach((btn) => btn.addEventListener(\"click\", onCancelClick));\n root.addEventListener(\"keydown\", onKeyDown);\n\n // Support external triggers: any element with [data-open=\"{dialog-id}\"]\n const externalTriggers = root.id\n ? document.querySelectorAll(`[data-open=\"${root.id}\"]`)\n : [];\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.addEventListener(\"click\", onTriggerClick)\n );\n }\n\n function destroy() {\n trigger?.removeEventListener(\"click\", onTriggerClick);\n if (!isAlert) overlay?.removeEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCloseClick)\n );\n confirmButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onConfirmClick)\n );\n cancelButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCancelClick)\n );\n root.removeEventListener(\"keydown\", onKeyDown);\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.removeEventListener(\"click\", onTriggerClick)\n );\n }\n dismiss();\n delete root._faqirDialog;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirDialog = api;\n return api;\n}\n return createDialog;\n })();\n\n // ── drawer ── (registry/recipes/drawer/drawer.js)\n var createDrawer = controllerRegistry[\"drawer\"] = (function() {\n// @ui:controller drawer\n// @ui:provides open close toggle destroy\n\nfunction createDrawer(root) {\n // Prevent double-init\n if (root._faqirDrawer) return root._faqirDrawer;\n\n // Overlay and panel are direct children; trigger and close buttons are\n // matched by owner, so a nested component's close leaves this one alone.\n const [trigger] = ownParts(root, \"trigger\");\n const overlay = root.querySelector(\":scope > [data-part='overlay']\");\n const panel = root.querySelector(\":scope > [data-part='panel']\");\n const closeButtons = ownParts(root, \"close\");\n\n // `panel.focus()` on open does nothing without a tabindex: focus stayed on\n // `body`, out of reach of the trap and the root's Escape listener.\n if (panel && !panel.hasAttribute(\"tabindex\")) panel.setAttribute(\"tabindex\", \"-1\");\n\n let focusCleanup = null;\n let previouslyFocused = null;\n let prevBodyOverflow = null;\n\n // Scroll lock: an open modal drawer freezes the page behind it. The guard makes\n // lock/unlock idempotent so overlapping open/close sequences (or a double\n // open) can never leave the body stuck at `overflow: hidden`.\n function lockScroll() {\n if (prevBodyOverflow !== null) return;\n prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n function unlockScroll() {\n if (prevBodyOverflow === null) return;\n document.body.style.overflow = prevBodyOverflow;\n prevBodyOverflow = null;\n }\n\n // Cancels an in-flight \"closing\" wait when the drawer is re-opened mid-slide.\n let cancelExitWait = null;\n\n function open() {\n cancelExitWait?.();\n cancelExitWait = null;\n previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n lockScroll();\n focusCleanup = trapFocus(panel);\n panel.focus?.();\n }\n\n function close() {\n // Already gone, or already sliding out — a second click must not start a\n // second wait on top of the one in flight.\n if (root.dataset.state === \"closed\" || root.dataset.state === \"closing\") return;\n\n root.dataset.state = \"closing\";\n\n const onEnd = () => {\n cancelExitWait = null;\n const active = document.activeElement;\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n returnFocus(root, previouslyFocused, active);\n };\n\n // The panel's OWN `transform` — not the close button's `background`, which\n // bubbles up to the panel the moment the pointer touches it and used to eat\n // the one-shot listener, stranding the drawer at \"closing\" with the overlay\n // still covering the page. See `whenExitDone`. [W2-1]\n cancelExitWait = whenExitDone(panel, \"transform\", onEnd);\n }\n\n /**\n * Tear the overlay down NOW — no exit animation, no focus restore.\n *\n * `destroy()` unbound every listener and left the panel and its backdrop\n * exactly where they were: a full-page block whose close button, Escape key\n * and overlay click had all just stopped working, with no way out. An SPA\n * route change destroys controllers and does precisely this. The model is\n * `context-menu`, which has always closed itself on teardown. [W3-2]\n */\n function dismiss() {\n cancelExitWait?.();\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n if (overlay) overlay.hidden = true;\n if (panel) panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event listeners\n function onTriggerClick() {\n open();\n }\n\n function onOverlayClick() {\n close();\n }\n\n function onCloseClick() {\n close();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.stopPropagation();\n close();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n overlay?.addEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) => btn.addEventListener(\"click\", onCloseClick));\n root.addEventListener(\"keydown\", onKeyDown);\n\n // Support external triggers: any element with [data-open=\"{drawer-id}\"]\n const externalTriggers = root.id\n ? document.querySelectorAll(`[data-open=\"${root.id}\"]`)\n : [];\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.addEventListener(\"click\", onTriggerClick)\n );\n }\n\n function destroy() {\n trigger?.removeEventListener(\"click\", onTriggerClick);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCloseClick)\n );\n root.removeEventListener(\"keydown\", onKeyDown);\n if (externalTriggers.length) {\n externalTriggers.forEach((el) =>\n el.removeEventListener(\"click\", onTriggerClick)\n );\n }\n dismiss();\n delete root._faqirDrawer;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirDrawer = api;\n return api;\n}\n return createDrawer;\n })();\n\n // ── dropdown ── (registry/recipes/dropdown/dropdown.js)\n var createDropdown = controllerRegistry[\"dropdown\"] = (function() {\n// @ui:controller dropdown\n// @ui:provides open close toggle destroy\n\nfunction createDropdown(root) {\n // Prevent double-init\n if (root._faqirDropdown) return root._faqirDropdown;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const menu = root.querySelector(\"[data-part='menu']\");\n\n // Incomplete markup — a wrapper emitted without one of its parts, which is\n // what a generator interrupted mid-component produces — used to throw a\n // TypeError out of the first dereference below. The engine contains that now\n // (the component fails, the page survives), but \"Cannot read properties of\n // null\" is a poor way to say which part is missing. Say it, and hand back an\n // inert API so `$ui.open()` is a no-op rather than a second crash. [W3-2]\n if (!trigger || !menu) {\n console.warn(\n \"[Faqir] dropdown needs [data-part='trigger'] and [data-part='menu'] — \" +\n `missing ${[!trigger && \"trigger\", !menu && \"menu\"].filter(Boolean).join(\" and \")}. ` +\n \"Component left inert.\",\n root\n );\n const inert = { open() {}, close() {}, toggle() {}, destroy() {} };\n root._faqirDropdown = inert;\n return inert;\n }\n\n let outsideClickCleanup = null;\n\n const navigation = createMenuNavigation(menu, {\n onEscape() {\n close();\n },\n onTab() {\n close({ restoreFocus: false });\n },\n });\n\n function open(options = {}) {\n const focus = options.focus || \"first\";\n root.dataset.state = \"open\";\n menu.hidden = false;\n trigger.setAttribute(\"aria-expanded\", \"true\");\n\n if (focus === \"last\") navigation.focusLast();\n else navigation.focusFirst();\n\n // Close on outside click\n if (outsideClickCleanup) outsideClickCleanup();\n outsideClickCleanup = onOutsideClick(root, () => close({ restoreFocus: false }));\n }\n\n function close(options = {}) {\n const restoreFocus = options.restoreFocus !== false;\n root.dataset.state = \"closed\";\n menu.hidden = true;\n trigger.setAttribute(\"aria-expanded\", \"false\");\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n\n if (restoreFocus) trigger.focus();\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n function onTriggerClick() {\n toggle();\n }\n\n function onTriggerKeyDown(e) {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (root.dataset.state !== \"open\") open({ focus: e.key === \"ArrowUp\" ? \"last\" : \"first\" });\n else if (e.key === \"ArrowUp\") navigation.focusLast();\n else navigation.focusFirst();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n trigger?.addEventListener(\"keydown\", onTriggerKeyDown);\n\n // Delegate item clicks\n function onMenuClick(e) {\n const item = e.target.closest(\"[data-part='item']\");\n if (\n item &&\n item.closest('[role=\"menu\"]') === menu &&\n !item.disabled &&\n item.getAttribute(\"aria-disabled\") !== \"true\"\n ) close();\n }\n menu?.addEventListener(\"click\", onMenuClick);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close({ restoreFocus: false });\n trigger?.removeEventListener(\"click\", onTriggerClick);\n trigger?.removeEventListener(\"keydown\", onTriggerKeyDown);\n menu?.removeEventListener(\"click\", onMenuClick);\n navigation.destroy();\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirDropdown;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirDropdown = api;\n return api;\n}\n return createDropdown;\n })();\n\n // ── file-upload ── (registry/recipes/file-upload/file-upload.js)\n var createFileUpload = controllerRegistry[\"file-upload\"] = (function() {\n// @ui:controller file-upload\n// @ui:provides getFiles open remove clear destroy\n\n/**\n * Drag-and-drop file collection with a native file-input fallback.\n *\n * The controller only validates and retains local File objects. Application\n * code owns every upload operation through the bubbling events documented in\n * the manifest.\n */\nfunction createFileUpload(root) {\n if (root._faqirFileUpload) return root._faqirFileUpload;\n\n let dropzone = root.querySelector(\"[data-part='dropzone']\");\n if (!dropzone) {\n dropzone = document.createElement(\"label\");\n dropzone.setAttribute(\"data-part\", \"dropzone\");\n root.prepend(dropzone);\n }\n\n let input = root.querySelector(\"[data-part='input']\");\n if (!input) {\n input = document.createElement(\"input\");\n input.setAttribute(\"data-part\", \"input\");\n dropzone.prepend(input);\n }\n input.setAttribute(\"type\", \"file\");\n\n let description = root.querySelector(\"[data-part='description']\");\n if (description) {\n if (!description.id) description.id = uid(\"faqir-file-upload-help\");\n if (!input.hasAttribute(\"aria-describedby\")) {\n input.setAttribute(\"aria-describedby\", description.id);\n }\n }\n\n if (dropzone.tagName === \"LABEL\" && !dropzone.contains(input)) {\n if (!input.id) input.id = uid(\"faqir-file-upload-input\");\n dropzone.htmlFor = input.id;\n }\n\n let list = root.querySelector(\"[data-part='list']\");\n if (!list) {\n list = document.createElement(\"ul\");\n list.setAttribute(\"data-part\", \"list\");\n list.setAttribute(\"aria-label\", \"Selected files\");\n root.appendChild(list);\n }\n\n let status = root.querySelector(\"[data-part='status']\");\n if (!status) {\n status = document.createElement(\"span\");\n status.setAttribute(\"data-part\", \"status\");\n status.setAttribute(\"role\", \"status\");\n status.setAttribute(\"aria-live\", \"polite\");\n root.appendChild(status);\n }\n\n if (root.hasAttribute(\"data-disabled\")) input.disabled = true;\n\n let selected = [];\n let dragging = false;\n let fileByRow = new WeakMap();\n\n function isDisabled() {\n return root.hasAttribute(\"data-disabled\") || input.disabled;\n }\n\n function toFileList(files) {\n const transfer = new DataTransfer();\n for (const file of files) transfer.items.add(file);\n const list = transfer.files;\n if (list instanceof FileList) return list;\n\n // Happy DOM currently returns File[] from DataTransfer.files. Preserve the\n // browser contract in that harness without changing the real-browser path.\n try {\n const fallback = new FileList();\n fallback.push(...files);\n return fallback;\n } catch {\n return list;\n }\n }\n\n function syncState() {\n root.dataset.state = dragging\n ? \"dragging\"\n : selected.length > 0\n ? \"has-files\"\n : \"idle\";\n }\n\n function syncInput() {\n try {\n input.files = toFileList(selected);\n } catch {\n // Some browsers intentionally expose FileList as read-only. The event\n // payload and controller's retained list remain authoritative.\n }\n }\n\n function formatSize(bytes) {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.ceil(bytes / 1024)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n }\n\n function render() {\n fileByRow = new WeakMap();\n list.replaceChildren();\n\n if (selected.length === 0) {\n const empty = document.createElement(\"li\");\n empty.setAttribute(\"data-part\", \"empty\");\n empty.textContent = \"No files selected\";\n list.appendChild(empty);\n syncState();\n return;\n }\n\n for (const file of selected) {\n const row = document.createElement(\"li\");\n row.setAttribute(\"data-part\", \"file\");\n fileByRow.set(row, file);\n\n const details = document.createElement(\"span\");\n details.setAttribute(\"data-part\", \"details\");\n\n const name = document.createElement(\"span\");\n name.setAttribute(\"data-part\", \"name\");\n name.textContent = file.name;\n\n const metadata = document.createElement(\"span\");\n metadata.setAttribute(\"data-part\", \"metadata\");\n metadata.textContent = `${file.type || \"Unknown type\"} · ${formatSize(file.size)}`;\n\n const remove = document.createElement(\"button\");\n remove.setAttribute(\"data-part\", \"remove\");\n remove.setAttribute(\"type\", \"button\");\n remove.setAttribute(\"aria-label\", `Remove ${file.name}`);\n remove.textContent = \"Remove\";\n remove.disabled = isDisabled();\n\n details.append(name, metadata);\n row.append(details, remove);\n list.appendChild(row);\n }\n syncState();\n }\n\n function emit(type, detail) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }),\n );\n }\n\n function acceptTokens() {\n return input.accept\n .split(\",\")\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean);\n }\n\n function matchesAccept(file) {\n const tokens = acceptTokens();\n if (tokens.length === 0) return true;\n\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (token.endsWith(\"/*\")) {\n return type.startsWith(token.slice(0, -1));\n }\n return type === token;\n });\n }\n\n function maxSize() {\n const raw = root.getAttribute(\"data-max-size\");\n if (raw == null || raw.trim() === \"\") return null;\n const value = Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : null;\n }\n\n function rejectionReason(file) {\n if (!matchesAccept(file)) return \"accept\";\n const limit = maxSize();\n if (limit != null && file.size > limit) return \"max-size\";\n return null;\n }\n\n function rejectionMessage(file, reason) {\n if (reason === \"max-size\") return `${file.name} exceeds the maximum file size.`;\n return `${file.name} is not an accepted file type.`;\n }\n\n function addFiles(fileList, source) {\n if (isDisabled()) return toFileList([]);\n\n const accepted = [];\n const limit = maxSize();\n for (const file of Array.from(fileList || [])) {\n const reason = rejectionReason(file);\n if (reason) {\n status.textContent = rejectionMessage(file, reason);\n emit(\"file-reject\", {\n file,\n reason,\n accept: input.accept,\n maxSize: limit,\n source,\n });\n } else {\n accepted.push(file);\n }\n }\n\n selected.push(...accepted);\n syncInput();\n render();\n\n const files = toFileList(accepted);\n emit(\"files\", {\n files,\n allFiles: toFileList(selected),\n source,\n });\n return files;\n }\n\n function remove(target) {\n const index = typeof target === \"number\"\n ? target\n : selected.indexOf(target);\n if (index < 0 || index >= selected.length || isDisabled()) return false;\n\n const [file] = selected.splice(index, 1);\n syncInput();\n render();\n status.textContent = `${file.name} removed.`;\n emit(\"file-remove\", {\n file,\n index,\n files: toFileList(selected),\n });\n return true;\n }\n\n function clear() {\n if (isDisabled()) return false;\n while (selected.length > 0) remove(0);\n return true;\n }\n\n function getFiles() {\n return toFileList(selected);\n }\n\n function open() {\n if (!isDisabled()) input.click();\n }\n\n function onDragEnter(event) {\n event.preventDefault();\n if (isDisabled()) return;\n dragging = true;\n syncState();\n }\n\n function onDragOver(event) {\n event.preventDefault();\n if (isDisabled()) return;\n dragging = true;\n if (event.dataTransfer) {\n try {\n event.dataTransfer.dropEffect = \"copy\";\n } catch {\n /* read-only in some DOM implementations */\n }\n }\n syncState();\n }\n\n function onDragLeave(event) {\n const next = event.relatedTarget;\n if (next && root.contains(next)) return;\n dragging = false;\n syncState();\n }\n\n function onDrop(event) {\n event.preventDefault();\n dragging = false;\n if (isDisabled()) {\n syncState();\n return;\n }\n addFiles(event.dataTransfer?.files, \"drop\");\n }\n\n function onChange() {\n addFiles(input.files, \"input\");\n }\n\n function onClick(event) {\n const removeButton = event.target?.closest?.(\"[data-part='remove']\");\n if (\n !removeButton ||\n removeButton.closest(\"[data-ui='file-upload']\") !== root\n ) return;\n const row = removeButton.closest(\"[data-part='file']\");\n const file = row && fileByRow.get(row);\n if (file) remove(file);\n }\n\n dropzone.addEventListener(\"dragenter\", onDragEnter);\n dropzone.addEventListener(\"dragover\", onDragOver);\n dropzone.addEventListener(\"dragleave\", onDragLeave);\n dropzone.addEventListener(\"drop\", onDrop);\n input.addEventListener(\"change\", onChange);\n root.addEventListener(\"click\", onClick);\n\n render();\n\n const api = {\n getFiles,\n open,\n remove,\n clear,\n destroy() {\n dropzone.removeEventListener(\"dragenter\", onDragEnter);\n dropzone.removeEventListener(\"dragover\", onDragOver);\n dropzone.removeEventListener(\"dragleave\", onDragLeave);\n dropzone.removeEventListener(\"drop\", onDrop);\n input.removeEventListener(\"change\", onChange);\n root.removeEventListener(\"click\", onClick);\n dragging = false;\n syncState();\n delete root._faqirFileUpload;\n },\n };\n\n root._faqirFileUpload = api;\n return api;\n}\n return createFileUpload;\n })();\n\n // ── input-otp ── (registry/recipes/input-otp/input-otp.js)\n var createInputOTP = controllerRegistry[\"input-otp\"] = (function() {\n// @ui:controller input-otp\n// @ui:provides getValue setValue clear focus destroy\n\n/**\n * input-otp — segmented one-time-code entry.\n *\n * ── Approach: ONE real input, N presentational segments ─────────────────────\n * The widget is a single, real `<input data-part=\"input\">` stretched over a row\n * of decorative `[data-part=\"segment\"]` boxes. The input is transparent (text,\n * caret and background) and sits on top, so every keystroke, paste, selection,\n * IME composition and — crucially — mobile SMS autofill goes through native form\n * machinery. The segments are `aria-hidden` and merely mirror the input's value.\n *\n * Why not one `<input>` per segment? Because the single-input design wins on the\n * exact axes this recipe is judged on:\n *\n * • Paste — the browser inserts pasted text at the caret for free; we only have\n * to strip characters that don't fit the mode. N separate inputs would each\n * have to re-split and redistribute a paste by hand, and browsers deliver a\n * multi-character paste inconsistently across split fields.\n * • Screen readers — one labelled field announces as \"One-time code, edit text\"\n * instead of N adjacent \"1 of 6 … 2 of 6\" edit boxes, which is far less\n * confusing. WAI has no dedicated OTP pattern; an OTP field IS a text input,\n * so we keep it a text input and give it a name + autocomplete.\n * • Mobile autofill — iOS/Android surface the SMS code for `inputmode` +\n * `autocomplete=\"one-time-code\"` on a SINGLE field; across N fields only the\n * first is offered the value and the rest are never populated.\n *\n * ── What the controller owns ────────────────────────────────────────────────\n * Runtime state only. It never fetches, never routes, never touches classes. It\n * reflects the input's value onto the segments (`data-filled`), marks the caret\n * segment (`data-active` / `data-caret`), and sets `data-state=\"complete\"` on the\n * root when full. Typing/backspace/paste are handled explicitly so behaviour is\n * identical across browsers (and unit-testable without native text editing), while\n * a catch-all `input` listener still absorbs autofill / IME that arrives whole.\n *\n * Events (bubbling): `faqir:change` on every value change (`detail.value`), and\n * `faqir:complete` exactly once per completion — fired on the not-full → full\n * transition, re-armed only after the value drops below full again.\n *\n * When the real input also carries `l-mask=\"999999\"`, the optional faqir-mask\n * plugin owns edit normalization and emits `faqir:mask`; this controller mirrors\n * the event's raw value into its segments. Without the plugin, the self-contained\n * keyboard/paste path below remains the byte-for-byte behavioral fallback.\n */\nfunction createInputOTP(root) {\n // Idempotent: a second init returns the existing API.\n if (root._faqirInputOTP) return root._faqirInputOTP;\n\n const N = clampInt(root.getAttribute(\"data-length\"), 6, 1, 12);\n const mode = root.getAttribute(\"data-mode\") === \"alphanumeric\" ? \"alphanumeric\" : \"numeric\";\n\n // ── Resolve / normalize the real input ─────────────────────────────────────\n let input = root.querySelector(\"[data-part='input']\");\n if (!input) {\n input = document.createElement(\"input\");\n input.setAttribute(\"data-part\", \"input\");\n input.setAttribute(\"type\", \"text\");\n root.insertBefore(input, root.firstChild);\n }\n input.setAttribute(\"maxlength\", String(N));\n try {\n input.maxLength = N;\n } catch {\n /* some environments make maxLength read-only on detached nodes — attribute suffices */\n }\n // Mobile-friendly defaults — authors may override in markup.\n if (!input.getAttribute(\"inputmode\")) {\n input.setAttribute(\"inputmode\", mode === \"numeric\" ? \"numeric\" : \"text\");\n }\n if (!input.getAttribute(\"autocomplete\")) input.setAttribute(\"autocomplete\", \"one-time-code\");\n if (!input.hasAttribute(\"aria-label\") && !input.hasAttribute(\"aria-labelledby\")) {\n input.setAttribute(\"aria-label\", \"One-time code\");\n }\n input.setAttribute(\"autocapitalize\", \"off\");\n input.setAttribute(\"autocorrect\", \"off\");\n input.setAttribute(\"spellcheck\", \"false\");\n if (mode === \"numeric\" && !input.hasAttribute(\"pattern\")) input.setAttribute(\"pattern\", \"[0-9]*\");\n if (isDisabled()) input.disabled = true;\n\n // ── Resolve / normalize the segment row ────────────────────────────────────\n let container = root.querySelector(\"[data-part='segments']\");\n if (!container) {\n container = document.createElement(\"div\");\n container.setAttribute(\"data-part\", \"segments\");\n root.appendChild(container);\n }\n // Segments are decorative — the real input is the accessible control.\n container.setAttribute(\"aria-hidden\", \"true\");\n\n let segments = [...container.querySelectorAll(\"[data-part='segment']\")];\n if (segments.length !== N) {\n // data-length is authoritative: rebuild the row to match it exactly.\n container.textContent = \"\";\n segments = [];\n for (let i = 0; i < N; i++) {\n const seg = document.createElement(\"div\");\n seg.setAttribute(\"data-part\", \"segment\");\n container.appendChild(seg);\n segments.push(seg);\n }\n }\n\n // ── Value plumbing ──────────────────────────────────────────────────────────\n let focused = false;\n let wasComplete = false;\n let lastValue = \"\";\n\n function isDisabled() {\n return root.hasAttribute(\"data-disabled\");\n }\n\n function charOk(ch) {\n return mode === \"alphanumeric\" ? /[a-z0-9]/i.test(ch) : /[0-9]/.test(ch);\n }\n\n /** Keep only mode-legal characters (no length cap — callers cap to N). */\n function filter(str) {\n let out = \"\";\n for (const ch of String(str == null ? \"\" : str)) if (charOk(ch)) out += ch;\n return out;\n }\n\n /** Optional faqir-mask bridge installed by the l-mask plugin. */\n function maskApi() {\n return input._faqirMask && typeof input._faqirMask.getRaw === \"function\"\n ? input._faqirMask\n : null;\n }\n\n function currentValue() {\n const mask = maskApi();\n return mask ? mask.getRaw() : input.value;\n }\n\n /** Paint segments + caret from the input's current value. No events. */\n function refresh() {\n const val = currentValue();\n for (let i = 0; i < N; i++) {\n const ch = val[i];\n const seg = segments[i];\n if (ch != null) {\n seg.textContent = ch;\n seg.setAttribute(\"data-filled\", \"\");\n } else {\n seg.textContent = \"\";\n seg.removeAttribute(\"data-filled\");\n }\n }\n if (val.length === N) root.setAttribute(\"data-state\", \"complete\");\n else root.removeAttribute(\"data-state\");\n updateActive();\n }\n\n /** Mark the caret segment (collapsed) or the selected span (range). */\n function updateActive() {\n for (const seg of segments) {\n seg.removeAttribute(\"data-active\");\n seg.removeAttribute(\"data-caret\");\n }\n if (!focused || isDisabled()) return;\n\n const len = input.value.length;\n let start = input.selectionStart;\n let end = input.selectionEnd;\n if (start == null) start = len;\n if (end == null) end = start;\n\n if (start !== end) {\n for (let i = start; i < end && i < N; i++) segments[i]?.setAttribute(\"data-active\", \"\");\n return;\n }\n const idx = Math.min(start, N - 1);\n const seg = segments[idx];\n if (!seg) return;\n seg.setAttribute(\"data-active\", \"\");\n // Blink a caret only in the next-to-fill empty slot — the crisp OTP look.\n if (start === len && len < N) seg.setAttribute(\"data-caret\", \"\");\n }\n\n function emit(type, detail) {\n root.dispatchEvent(new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }));\n }\n\n /** Repaint, then fire change / complete based on the transition. */\n function syncAndEmit() {\n refresh();\n const val = currentValue();\n if (val !== lastValue) {\n lastValue = val;\n emit(\"change\", { value: val });\n }\n const complete = val.length === N;\n if (complete && !wasComplete) {\n wasComplete = true;\n emit(\"complete\", { value: val });\n } else if (!complete) {\n wasComplete = false;\n }\n }\n\n /** The single write seam: set value + caret, then sync/emit. */\n function commit(next, caret) {\n const mask = maskApi();\n if (mask && typeof mask.setRaw === \"function\") {\n mask.setRaw(next, caret == null ? next.length : caret, true);\n return;\n }\n input.value = next;\n const c = caret == null ? next.length : Math.max(0, Math.min(caret, next.length));\n try {\n input.setSelectionRange(c, c);\n } catch {\n /* selection API unavailable on this input type/env — value is still correct */\n }\n syncAndEmit();\n }\n\n /** Insert mode-legal text at the caret, replacing any selection, capped at N. */\n function insertText(text) {\n const clean = filter(text);\n if (!clean) return;\n const val = input.value;\n let start = input.selectionStart;\n let end = input.selectionEnd;\n if (start == null) start = val.length;\n if (end == null) end = start;\n const next = (val.slice(0, start) + clean + val.slice(end)).slice(0, N);\n commit(next, start + clean.length);\n }\n\n function setCaret(pos) {\n const c = Math.max(0, Math.min(pos, input.value.length));\n try {\n input.setSelectionRange(c, c);\n } catch {\n /* ignore */\n }\n updateActive();\n }\n\n // ── Keyboard: explicit, deterministic editing ──────────────────────────────\n function onKeyDown(e) {\n if (isDisabled()) return;\n // Copy / paste / select-all / undo — let the browser + paste handler run.\n if (e.metaKey || e.ctrlKey || e.altKey) return;\n\n focused = true;\n const val = input.value;\n let start = input.selectionStart;\n let end = input.selectionEnd;\n if (start == null) start = val.length;\n if (end == null) end = start;\n\n // faqir-mask consumes the browser's beforeinput/paste path and reports its\n // raw result through faqir:mask. Leave text edits to it; keep only explicit\n // caret navigation here. The standalone fallback below remains unchanged.\n if (maskApi() && (e.key === \"Backspace\" || e.key === \"Delete\" || e.key.length === 1)) {\n return;\n }\n\n switch (e.key) {\n case \"Backspace\":\n e.preventDefault();\n if (start !== end) commit(val.slice(0, start) + val.slice(end), start);\n else if (start > 0) commit(val.slice(0, start - 1) + val.slice(start), start - 1);\n else updateActive();\n return;\n case \"Delete\":\n e.preventDefault();\n if (start !== end) commit(val.slice(0, start) + val.slice(end), start);\n else commit(val.slice(0, start) + val.slice(start + 1), start);\n return;\n case \"ArrowLeft\":\n e.preventDefault();\n // Collapsed caret steps left; a selection collapses to its start.\n setCaret(start === end ? start - 1 : start);\n return;\n case \"ArrowRight\":\n e.preventDefault();\n // Collapsed caret steps right; a selection collapses to its end.\n setCaret(start === end ? end + 1 : end);\n return;\n case \"Home\":\n e.preventDefault();\n setCaret(0);\n return;\n case \"End\":\n e.preventDefault();\n setCaret(val.length);\n return;\n default:\n // A single printable character — insert it (invalid chars are dropped).\n if (e.key.length === 1) {\n e.preventDefault();\n insertText(e.key);\n }\n // Everything else (Tab, Shift, arrows with modifiers, F-keys) passes through.\n }\n }\n\n // ── Paste: native cursor semantics, we only sanitize ───────────────────────\n function onPaste(e) {\n if (isDisabled()) return;\n e.preventDefault();\n focused = true;\n const data = e.clipboardData || (typeof window !== \"undefined\" && window.clipboardData);\n const text = data && typeof data.getData === \"function\" ? data.getData(\"text\") : \"\";\n insertText(text);\n }\n\n // ── Catch-all: autofill / IME / anything not intercepted above ─────────────\n function onInput() {\n if (isDisabled()) return;\n focused = true;\n const clean = filter(input.value).slice(0, N);\n if (clean !== input.value) {\n const pos = Math.min(input.selectionStart == null ? clean.length : input.selectionStart, clean.length);\n commit(clean, pos);\n } else {\n syncAndEmit();\n }\n }\n\n function onMask() {\n if (isDisabled()) return;\n focused = typeof document === \"undefined\" || document.activeElement === input;\n syncAndEmit();\n }\n\n function onFocus() {\n focused = true;\n // Predictable caret: land on the next-to-fill slot unless mid-editing.\n if (input.selectionStart === input.selectionEnd) setCaret(input.value.length);\n else updateActive();\n }\n function onBlur() {\n focused = false;\n updateActive();\n }\n function onClick() {\n focused = true;\n // Segments are pointer-events:none, so the click already hit the input;\n // snap the caret to the end for a consistent active segment.\n setCaret(input.value.length);\n }\n function onSelectionChange() {\n if (typeof document !== \"undefined\" && document.activeElement === input) updateActive();\n }\n\n input.addEventListener(\"keydown\", onKeyDown);\n input.addEventListener(\"paste\", onPaste);\n input.addEventListener(\"input\", onInput);\n input.addEventListener(\"faqir:mask\", onMask);\n input.addEventListener(\"focus\", onFocus);\n input.addEventListener(\"blur\", onBlur);\n input.addEventListener(\"click\", onClick);\n if (typeof document !== \"undefined\") document.addEventListener(\"selectionchange\", onSelectionChange);\n\n // ── Seed from data-value / existing input value, silently (no events) ───────\n {\n const seed = filter(input.value || root.getAttribute(\"data-value\") || \"\").slice(0, N);\n input.value = seed;\n lastValue = seed;\n wasComplete = seed.length === N;\n refresh();\n }\n\n // ── Public API ──────────────────────────────────────────────────────────────\n function getValue() {\n return currentValue();\n }\n /** Programmatic set — silent (does not fire change/complete). */\n function setValue(str) {\n const clean = filter(str).slice(0, N);\n const mask = maskApi();\n if (mask && typeof mask.setRaw === \"function\") mask.setRaw(clean, clean.length, false);\n else input.value = clean;\n lastValue = clean;\n wasComplete = clean.length === N;\n refresh();\n }\n function clear() {\n setValue(\"\");\n }\n function focus() {\n try {\n input.focus();\n } catch {\n /* ignore */\n }\n }\n\n function destroy() {\n input.removeEventListener(\"keydown\", onKeyDown);\n input.removeEventListener(\"paste\", onPaste);\n input.removeEventListener(\"input\", onInput);\n input.removeEventListener(\"faqir:mask\", onMask);\n input.removeEventListener(\"focus\", onFocus);\n input.removeEventListener(\"blur\", onBlur);\n input.removeEventListener(\"click\", onClick);\n if (typeof document !== \"undefined\") document.removeEventListener(\"selectionchange\", onSelectionChange);\n delete root._faqirInputOTP;\n }\n\n const api = { getValue, setValue, clear, focus, destroy };\n root._faqirInputOTP = api;\n return api;\n}\n\n// Parse an integer attribute, clamped to [lo, hi], with a fallback.\nfunction clampInt(raw, fallback, lo, hi) {\n const n = parseInt(raw, 10);\n if (!Number.isFinite(n)) return fallback;\n return Math.max(lo, Math.min(hi, n));\n}\n return createInputOTP;\n })();\n\n // ── menubar ── (registry/recipes/menubar/menubar.js)\n var createMenubar = controllerRegistry[\"menubar\"] = (function() {\n// @ui:controller menubar\n// @ui:provides open close destroy\n\nfunction createMenubar(root) {\n if (root._faqirMenubar) return root._faqirMenubar;\n\n const submenus = [...root.querySelectorAll(\"[data-part='submenu'][role='menu']\")]\n .filter((menu) => menu.closest(\"[data-ui='menubar']\") === root);\n const submenuNavigations = new Map();\n\n let topNavigation;\n\n function ownerOf(item) {\n return item?.closest(\"[role='menu'], [role='menubar']\");\n }\n\n function topItems() {\n return topNavigation?.items() ?? [];\n }\n\n function submenuFor(item) {\n const controls = item?.getAttribute(\"aria-controls\");\n if (controls) {\n const controlled = submenus.find((menu) => menu.id === controls);\n if (controlled) return controlled;\n }\n\n const sibling = item?.nextElementSibling;\n return sibling?.matches(\"[data-part='submenu'][role='menu']\")\n ? sibling\n : null;\n }\n\n function parentFor(menu) {\n return topItems().find((item) => submenuFor(item) === menu) ?? null;\n }\n\n function isAriaDisabled(item) {\n return item?.getAttribute(\"aria-disabled\") === \"true\";\n }\n\n function collapseAll() {\n let previousParent = null;\n\n for (const menu of submenus) {\n const parent = parentFor(menu);\n if (!menu.hidden && parent) previousParent = parent;\n menu.hidden = true;\n parent?.setAttribute(\"aria-expanded\", \"false\");\n }\n\n root.dataset.state = \"closed\";\n return previousParent;\n }\n\n function openFor(item, focus = \"first\") {\n const menu = submenuFor(item);\n if (!menu || isAriaDisabled(item)) return false;\n\n collapseAll();\n topNavigation.sync(item);\n menu.hidden = false;\n item.setAttribute(\"aria-expanded\", \"true\");\n root.dataset.state = \"open\";\n\n const navigation = submenuNavigations.get(menu);\n if (focus === \"last\") navigation?.focusLast();\n else if (focus === \"first\") navigation?.focusFirst();\n else item.focus();\n\n return true;\n }\n\n function open(index = 0, focus = \"first\") {\n const allItems = topItems();\n const item = typeof index === \"number\" ? allItems[index] : index;\n return item ? openFor(item, focus) : false;\n }\n\n function close(restoreFocus = true) {\n const parent = collapseAll();\n if (restoreFocus && parent) {\n topNavigation.sync(parent);\n parent.focus();\n }\n }\n\n function activateTopItem(item) {\n if (submenuFor(item)) {\n openFor(item, \"first\");\n return;\n }\n\n item.click();\n }\n\n const authoredTopItems = [...root.querySelectorAll(\"[role='menuitem']\")]\n .filter((item) => ownerOf(item) === root);\n const preferredTopItem =\n authoredTopItems.find(\n (item) => item.getAttribute(\"tabindex\") === \"0\" && !isAriaDisabled(item),\n ) ??\n authoredTopItems.find((item) => !isAriaDisabled(item)) ??\n authoredTopItems[0];\n\n topNavigation = createMenuNavigation(root, {\n orientation: \"horizontal\",\n roving: true,\n onActivate: activateTopItem,\n onEscape() {\n // The menubar itself is never hidden, so it receives Escape even with\n // every submenu collapsed. Nothing to dismiss means the keystroke is not\n // ours, and swallowing it would trap the user in whatever encloses the\n // menubar. [W3-2]\n if (root.dataset.state !== \"open\") return false;\n close(false);\n },\n onTab() {\n close(false);\n },\n });\n topNavigation.sync(preferredTopItem);\n\n for (const menu of submenus) {\n const navigation = createMenuNavigation(menu, {\n onEscape() {\n const parent = parentFor(menu);\n collapseAll();\n if (parent) {\n topNavigation.sync(parent);\n parent.focus();\n }\n },\n onTab() {\n collapseAll();\n },\n });\n submenuNavigations.set(menu, navigation);\n navigation.items().forEach((item) => {\n item.tabIndex = -1;\n });\n }\n\n // A menubar is persistent; only its popup submenus have open/closed state.\n collapseAll();\n\n function moveAcrossMenubar(menu, direction) {\n const parent = parentFor(menu);\n if (!parent) return;\n\n collapseAll();\n topNavigation.sync(parent);\n const nextItem = direction > 0\n ? topNavigation.focusNext()\n : topNavigation.focusPrevious();\n\n if (nextItem && submenuFor(nextItem) && !isAriaDisabled(nextItem)) {\n openFor(nextItem, \"parent\");\n }\n }\n\n function onKeyDown(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[role='menuitem']\");\n if (!item || !root.contains(item)) return;\n\n const owner = ownerOf(item);\n if (owner === root) {\n if ((event.key === \"ArrowDown\" || event.key === \"ArrowUp\") && submenuFor(item)) {\n if (isAriaDisabled(item)) return;\n event.preventDefault();\n openFor(item, event.key === \"ArrowUp\" ? \"last\" : \"first\");\n return;\n }\n\n // The shared horizontal navigation has already moved focus by the time\n // this listener runs. In open-menu mode, switch the visible submenu too.\n if (\n root.dataset.state === \"open\" &&\n (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\")\n ) {\n const nextItem = topNavigation.current();\n collapseAll();\n if (nextItem && submenuFor(nextItem) && !isAriaDisabled(nextItem)) {\n openFor(nextItem, \"parent\");\n }\n }\n return;\n }\n\n if (!submenus.includes(owner)) return;\n if (event.key === \"ArrowRight\" || event.key === \"ArrowLeft\") {\n event.preventDefault();\n moveAcrossMenubar(owner, event.key === \"ArrowRight\" ? 1 : -1);\n }\n }\n\n function onClick(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[role='menuitem']\");\n if (!item || !root.contains(item)) return;\n\n if (isAriaDisabled(item)) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n const owner = ownerOf(item);\n if (owner === root) {\n topNavigation.sync(item);\n item.focus();\n const menu = submenuFor(item);\n\n if (!menu) {\n collapseAll();\n return;\n }\n\n event.preventDefault();\n if (!menu.hidden) close(false);\n else openFor(item, \"parent\");\n return;\n }\n\n if (submenus.includes(owner)) {\n const parent = parentFor(owner);\n collapseAll();\n if (parent) {\n topNavigation.sync(parent);\n parent.focus();\n }\n }\n }\n\n root.addEventListener(\"keydown\", onKeyDown);\n root.addEventListener(\"click\", onClick, true);\n\n function destroy() {\n root.removeEventListener(\"keydown\", onKeyDown);\n root.removeEventListener(\"click\", onClick, true);\n topNavigation.destroy();\n submenuNavigations.forEach((navigation) => navigation.destroy());\n submenuNavigations.clear();\n delete root._faqirMenubar;\n }\n\n const api = { open, close, destroy };\n root._faqirMenubar = api;\n return api;\n}\n return createMenubar;\n })();\n\n // ── pagination ── (registry/recipes/pagination/pagination.js)\n var createPagination = controllerRegistry[\"pagination\"] = (function() {\n// @ui:controller pagination\n// @ui:provides setPage getPage setTotal render destroy\n\nfunction createPagination(root) {\n // Prevent double-init\n if (root._faqirPagination) return root._faqirPagination;\n\n const nav = root.querySelector(\"[data-part='nav']\");\n const prevBtn = root.querySelector(\"[data-part='prev']\");\n const nextBtn = root.querySelector(\"[data-part='next']\");\n\n let currentPage = 1;\n let totalPages = 1;\n\n // Initialize from existing DOM\n const activeBtn = root.querySelector(\"[data-part='page'][data-state='active']\");\n if (activeBtn) {\n currentPage = parseInt(activeBtn.dataset.page, 10) || 1;\n }\n\n const allPageBtns = root.querySelectorAll(\"[data-part='page']\");\n if (allPageBtns.length > 0) {\n const lastBtn = allPageBtns[allPageBtns.length - 1];\n totalPages = parseInt(lastBtn.dataset.page, 10) || 1;\n }\n\n function getPageButtons() {\n return [...root.querySelectorAll(\"[data-part='page']\")];\n }\n\n function updateActiveState() {\n getPageButtons().forEach((btn) => {\n const page = parseInt(btn.dataset.page, 10);\n if (page === currentPage) {\n btn.dataset.state = \"active\";\n btn.setAttribute(\"aria-current\", \"page\");\n } else {\n delete btn.dataset.state;\n btn.removeAttribute(\"aria-current\");\n }\n });\n\n // Update prev/next disabled state\n if (prevBtn) {\n prevBtn.disabled = currentPage <= 1;\n }\n if (nextBtn) {\n nextBtn.disabled = currentPage >= totalPages;\n }\n }\n\n function emitPageChange() {\n root.dispatchEvent(\n new CustomEvent(\"faqir:page-change\", {\n detail: { page: currentPage },\n bubbles: true,\n })\n );\n }\n\n function setPage(n) {\n const page = Math.max(1, Math.min(n, totalPages));\n if (page === currentPage) return;\n currentPage = page;\n updateActiveState();\n emitPageChange();\n }\n\n function getPage() {\n return currentPage;\n }\n\n function setTotal(n) {\n totalPages = Math.max(1, n);\n if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n updateActiveState();\n }\n\n // Rebuild the numbered page buttons + ellipses from the windowing math for the\n // given (current, total). Prev/next are preserved; only [data-part='page'] and\n // [data-part='ellipsis'] nodes are replaced. Does not emit page-change — it is\n // a render, not a user action. Clicks keep working via nav's delegated handler.\n function render(current, total) {\n if (!nav) return;\n totalPages = Math.max(1, Math.floor(total) || 1);\n currentPage = Math.max(1, Math.min(Math.floor(current) || 1, totalPages));\n\n nav\n .querySelectorAll(\"[data-part='page'], [data-part='ellipsis']\")\n .forEach((el) => el.remove());\n\n const frag = root.ownerDocument.createDocumentFragment();\n for (const item of paginationWindow(currentPage, totalPages)) {\n if (item === \"ellipsis\") {\n const span = root.ownerDocument.createElement(\"span\");\n span.setAttribute(\"data-part\", \"ellipsis\");\n span.textContent = \"…\";\n frag.appendChild(span);\n } else {\n const btn = root.ownerDocument.createElement(\"button\");\n btn.setAttribute(\"data-part\", \"page\");\n btn.dataset.page = String(item);\n btn.textContent = String(item);\n frag.appendChild(btn);\n }\n }\n\n if (nextBtn && nextBtn.parentNode === nav) {\n nav.insertBefore(frag, nextBtn);\n } else {\n nav.appendChild(frag);\n }\n\n updateActiveState();\n }\n\n // Event: click on page button\n function onNavClick(e) {\n const pageBtn = e.target.closest(\"[data-part='page']\");\n if (pageBtn) {\n const page = parseInt(pageBtn.dataset.page, 10);\n if (!isNaN(page)) {\n setPage(page);\n }\n return;\n }\n }\n\n function onPrevClick() {\n if (currentPage > 1) {\n setPage(currentPage - 1);\n }\n }\n\n function onNextClick() {\n if (currentPage < totalPages) {\n setPage(currentPage + 1);\n }\n }\n\n nav?.addEventListener(\"click\", onNavClick);\n prevBtn?.addEventListener(\"click\", onPrevClick);\n nextBtn?.addEventListener(\"click\", onNextClick);\n\n // Initialize disabled states\n updateActiveState();\n\n function destroy() {\n nav?.removeEventListener(\"click\", onNavClick);\n prevBtn?.removeEventListener(\"click\", onPrevClick);\n nextBtn?.removeEventListener(\"click\", onNextClick);\n delete root._faqirPagination;\n }\n\n const api = { setPage, getPage, setTotal, render, destroy };\n root._faqirPagination = api;\n return api;\n}\n\n/**\n * Pure windowing math: given the current page and total page count, return the\n * ordered list of items to display — page numbers interleaved with `\"ellipsis\"`\n * tokens where a run of pages is collapsed. A gap of exactly one page is never\n * collapsed to an ellipsis (the single page is shown instead), matching the\n * common MUI/APG pagination pattern.\n *\n * @param {number} currentPage 1-based active page (clamped into range).\n * @param {number} totalPages Total page count (>= 0; 0 → []).\n * @param {object} [options]\n * @param {number} [options.siblingCount=1] Pages shown either side of current.\n * @param {number} [options.boundaryCount=1] Pages pinned at each end.\n * @returns {Array<number|\"ellipsis\">}\n */\nfunction paginationWindow(currentPage, totalPages, options = {}) {\n const siblingCount = Math.max(0, Math.floor(options.siblingCount ?? 1));\n const boundaryCount = Math.max(0, Math.floor(options.boundaryCount ?? 1));\n\n const total = Math.max(0, Math.floor(totalPages) || 0);\n if (total <= 0) return [];\n const current = Math.min(Math.max(1, Math.floor(currentPage) || 1), total);\n\n const range = (start, end) => {\n const out = [];\n for (let i = start; i <= end; i++) out.push(i);\n return out;\n };\n\n const startPages = range(1, Math.min(boundaryCount, total));\n const endPages = range(Math.max(total - boundaryCount + 1, boundaryCount + 1), total);\n\n const siblingsStart = Math.max(\n Math.min(current - siblingCount, total - boundaryCount - siblingCount * 2 - 1),\n boundaryCount + 2\n );\n const siblingsEnd = Math.min(\n Math.max(current + siblingCount, boundaryCount + siblingCount * 2 + 2),\n endPages.length > 0 ? endPages[0] - 2 : total - 1\n );\n\n return [\n ...startPages,\n ...(siblingsStart > boundaryCount + 2\n ? [\"ellipsis\"]\n : boundaryCount + 1 < total - boundaryCount\n ? [boundaryCount + 1]\n : []),\n ...range(siblingsStart, siblingsEnd),\n ...(siblingsEnd < total - boundaryCount - 1\n ? [\"ellipsis\"]\n : total - boundaryCount > boundaryCount\n ? [total - boundaryCount]\n : []),\n ...endPages,\n ];\n}\n return createPagination;\n })();\n\n // ── popover ── (registry/recipes/popover/popover.js)\n var createPopover = controllerRegistry[\"popover\"] = (function() {\n// @ui:controller popover\n// @ui:provides open close toggle destroy\n\nfunction createPopover(root) {\n // Prevent double-init\n if (root._faqirPopover) return root._faqirPopover;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const content = root.querySelector(\"[data-part='content']\");\n // Not a close button belonging to a dialog or popover inside the content.\n const [closeBtn] = ownParts(root, \"close\");\n\n let outsideClickCleanup = null;\n\n function open() {\n root.dataset.state = \"open\";\n content.hidden = false;\n trigger.setAttribute(\"aria-expanded\", \"true\");\n\n // Close on outside click\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n function close() {\n root.dataset.state = \"closed\";\n content.hidden = true;\n trigger.setAttribute(\"aria-expanded\", \"false\");\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event: trigger click toggles\n function onTriggerClick() {\n toggle();\n }\n\n // Event: close button\n function onCloseClick(e) {\n e.stopPropagation();\n close();\n }\n\n // Event: escape closes\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.preventDefault();\n // Dismissing this popover consumes the keystroke — an enclosing dialog or\n // drawer must not close on the same Escape. [W3-2]\n e.stopPropagation();\n close();\n trigger.focus();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n closeBtn?.addEventListener(\"click\", onCloseClick);\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n close();\n trigger?.removeEventListener(\"click\", onTriggerClick);\n closeBtn?.removeEventListener(\"click\", onCloseClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirPopover;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirPopover = api;\n return api;\n}\n return createPopover;\n })();\n\n // ── qr-code ── (registry/recipes/qr-code/qr-code.js)\n var createQRCode = controllerRegistry[\"qr-code\"] = (function() {\n// @ui:controller qr-code\n// @ui:provides render update destroy\n\n/**\n * Minimal QR Code encoder (byte mode, versions 1–10).\n * Produces a boolean matrix suitable for SVG rendering.\n * Covers most practical use-cases (URLs, short text up to ~170 chars at ECL-M).\n */\n\n// ── GF(256) arithmetic for Reed-Solomon ──\n\nconst EXP = new Uint8Array(256);\nconst LOG = new Uint8Array(256);\n(() => {\n let v = 1;\n for (let i = 0; i < 255; i++) {\n EXP[i] = v;\n LOG[v] = i;\n v = (v << 1) ^ (v & 128 ? 0x11d : 0);\n }\n EXP[255] = EXP[0];\n})();\n\nfunction gfMul(a, b) {\n return a === 0 || b === 0 ? 0 : EXP[(LOG[a] + LOG[b]) % 255];\n}\n\nfunction rsGenPoly(n) {\n let poly = [1];\n for (let i = 0; i < n; i++) {\n const next = new Array(poly.length + 1).fill(0);\n for (let j = 0; j < poly.length; j++) {\n next[j] ^= poly[j];\n next[j + 1] ^= gfMul(poly[j], EXP[i]);\n }\n poly = next;\n }\n return poly;\n}\n\nfunction rsEncode(data, ecLen) {\n const gen = rsGenPoly(ecLen);\n const msg = new Array(data.length + ecLen).fill(0);\n data.forEach((v, i) => (msg[i] = v));\n for (let i = 0; i < data.length; i++) {\n const coef = msg[i];\n if (coef !== 0) {\n for (let j = 0; j < gen.length; j++) {\n msg[i + j] ^= gfMul(gen[j], coef);\n }\n }\n }\n return msg.slice(data.length);\n}\n\n// ── QR constants ──\n\nconst ECL_MAP = { L: 0, M: 1, Q: 2, H: 3 };\n\n// [version][ecl] → { totalBytes, ecPerBlock, blocks }\nconst VERSION_TABLE = [\n null, // index 0 unused\n // v1\n [{ dc: 19, ec: 7, b: 1 }, { dc: 16, ec: 10, b: 1 }, { dc: 13, ec: 13, b: 1 }, { dc: 9, ec: 17, b: 1 }],\n // v2\n [{ dc: 34, ec: 10, b: 1 }, { dc: 28, ec: 16, b: 1 }, { dc: 22, ec: 22, b: 1 }, { dc: 16, ec: 28, b: 1 }],\n // v3\n [{ dc: 55, ec: 15, b: 1 }, { dc: 44, ec: 26, b: 1 }, { dc: 34, ec: 18, b: 2 }, { dc: 26, ec: 22, b: 2 }],\n // v4\n [{ dc: 80, ec: 20, b: 1 }, { dc: 64, ec: 18, b: 2 }, { dc: 48, ec: 26, b: 2 }, { dc: 36, ec: 16, b: 4 }],\n // v5\n [{ dc: 108, ec: 26, b: 1 }, { dc: 86, ec: 24, b: 2 }, { dc: 62, ec: 18, b: 4 }, { dc: 46, ec: 22, b: 4 }],\n // v6\n [{ dc: 136, ec: 18, b: 2 }, { dc: 108, ec: 16, b: 4 }, { dc: 76, ec: 24, b: 4 }, { dc: 60, ec: 28, b: 4 }],\n // v7\n [{ dc: 156, ec: 20, b: 2 }, { dc: 124, ec: 18, b: 4 }, { dc: 88, ec: 18, b: 6 }, { dc: 66, ec: 26, b: 5 }],\n // v8\n [{ dc: 194, ec: 24, b: 2 }, { dc: 154, ec: 22, b: 4 }, { dc: 110, ec: 22, b: 6 }, { dc: 86, ec: 26, b: 6 }],\n // v9\n [{ dc: 232, ec: 30, b: 2 }, { dc: 182, ec: 22, b: 5 }, { dc: 132, ec: 20, b: 8 }, { dc: 98, ec: 24, b: 8 }],\n // v10\n [{ dc: 274, ec: 18, b: 4 }, { dc: 216, ec: 26, b: 5 }, { dc: 154, ec: 24, b: 8 }, { dc: 119, ec: 28, b: 8 }],\n];\n\nconst ALIGNMENT_POSITIONS = [\n null, [], [6, 18], [6, 22], [6, 26], [6, 30],\n [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50],\n];\n\nfunction selectVersion(dataLen, ecl) {\n const eclIdx = ECL_MAP[ecl] ?? 1;\n for (let v = 1; v <= 10; v++) {\n const info = VERSION_TABLE[v][eclIdx];\n if (dataLen <= info.dc) return v;\n }\n return -1;\n}\n\n// ── Matrix operations ──\n\nfunction createMatrix(size) {\n return Array.from({ length: size }, () => new Uint8Array(size));\n}\n\nfunction setModule(matrix, row, col, val, reserved) {\n const s = matrix.length;\n if (row >= 0 && row < s && col >= 0 && col < s) {\n matrix[row][col] = val;\n if (reserved) reserved[row][col] = 1;\n }\n}\n\nfunction placeFinderPattern(matrix, reserved, row, col) {\n for (let r = -1; r <= 7; r++) {\n for (let c = -1; c <= 7; c++) {\n const val =\n (r >= 0 && r <= 6 && (c === 0 || c === 6)) ||\n (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||\n (r >= 2 && r <= 4 && c >= 2 && c <= 4)\n ? 1\n : 0;\n setModule(matrix, row + r, col + c, val, reserved);\n }\n }\n}\n\nfunction placeAlignmentPattern(matrix, reserved, row, col) {\n for (let r = -2; r <= 2; r++) {\n for (let c = -2; c <= 2; c++) {\n const val =\n Math.abs(r) === 2 || Math.abs(c) === 2 || (r === 0 && c === 0) ? 1 : 0;\n setModule(matrix, row + r, col + c, val, reserved);\n }\n }\n}\n\nfunction placeTimingPatterns(matrix, reserved) {\n const s = matrix.length;\n for (let i = 8; i < s - 8; i++) {\n const val = i % 2 === 0 ? 1 : 0;\n setModule(matrix, 6, i, val, reserved);\n setModule(matrix, i, 6, val, reserved);\n }\n}\n\nfunction reserveFormatArea(matrix, reserved) {\n const s = matrix.length;\n for (let i = 0; i < 8; i++) {\n setModule(reserved, 8, i, 1);\n setModule(reserved, 8, s - 1 - i, 1);\n setModule(reserved, i, 8, 1);\n setModule(reserved, s - 1 - i, 8, 1);\n }\n setModule(reserved, 8, 8, 1);\n setModule(matrix, s - 8, 8, 1, reserved); // dark module\n}\n\nfunction placeData(matrix, reserved, bits) {\n const s = matrix.length;\n let bitIdx = 0;\n let upward = true;\n for (let col = s - 1; col >= 1; col -= 2) {\n if (col === 6) col = 5; // skip timing column\n const rows = upward\n ? Array.from({ length: s }, (_, i) => s - 1 - i)\n : Array.from({ length: s }, (_, i) => i);\n for (const row of rows) {\n for (let c = 0; c < 2; c++) {\n const cc = col - c;\n if (reserved[row][cc]) continue;\n matrix[row][cc] = bitIdx < bits.length ? bits[bitIdx++] : 0;\n }\n }\n upward = !upward;\n }\n}\n\nfunction applyMask(matrix, reserved, maskId) {\n const s = matrix.length;\n const fns = [\n (r, c) => (r + c) % 2 === 0,\n (r) => r % 2 === 0,\n (_, c) => c % 3 === 0,\n (r, c) => (r + c) % 3 === 0,\n (r, c) => (Math.floor(r / 2) + Math.floor(c / 3)) % 2 === 0,\n (r, c) => ((r * c) % 2) + ((r * c) % 3) === 0,\n (r, c) => (((r * c) % 2) + ((r * c) % 3)) % 2 === 0,\n (r, c) => (((r + c) % 2) + ((r * c) % 3)) % 2 === 0,\n ];\n const fn = fns[maskId];\n for (let r = 0; r < s; r++) {\n for (let c = 0; c < s; c++) {\n if (!reserved[r][c] && fn(r, c)) {\n matrix[r][c] ^= 1;\n }\n }\n }\n}\n\nfunction placeFormatInfo(matrix, ecl, maskId) {\n const s = matrix.length;\n const eclBits = [1, 0, 3, 2][ECL_MAP[ecl] ?? 1];\n let data = (eclBits << 3) | maskId;\n let rem = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >> 9) * 0x537);\n const bits = ((data << 10) | rem) ^ 0x5412;\n\n for (let i = 0; i < 15; i++) {\n const bit = (bits >> (14 - i)) & 1;\n // Around top-left finder\n if (i < 6) matrix[8][i] = bit;\n else if (i === 6) matrix[8][7] = bit;\n else if (i === 7) matrix[8][8] = bit;\n else if (i === 8) matrix[7][8] = bit;\n else matrix[14 - i][8] = bit;\n // Around other finders\n if (i < 8) matrix[s - 1 - i][8] = bit;\n else matrix[8][s - 15 + i] = bit;\n }\n}\n\n// ── Penalty scoring (simplified) ──\n\nfunction penalty(matrix) {\n const s = matrix.length;\n let score = 0;\n // Rule 1: runs of same color\n for (let r = 0; r < s; r++) {\n let count = 1;\n for (let c = 1; c < s; c++) {\n if (matrix[r][c] === matrix[r][c - 1]) {\n count++;\n if (count === 5) score += 3;\n else if (count > 5) score++;\n } else count = 1;\n }\n }\n for (let c = 0; c < s; c++) {\n let count = 1;\n for (let r = 1; r < s; r++) {\n if (matrix[r][c] === matrix[r - 1][c]) {\n count++;\n if (count === 5) score += 3;\n else if (count > 5) score++;\n } else count = 1;\n }\n }\n return score;\n}\n\n// ── Encode ──\n\nfunction encodeQR(text, ecl = \"M\") {\n const data = new TextEncoder().encode(text);\n const version = selectVersion(data.length, ecl);\n if (version < 0) throw new Error(\"Data too long for QR versions 1–10\");\n\n const eclIdx = ECL_MAP[ecl] ?? 1;\n const info = VERSION_TABLE[version][eclIdx];\n const size = version * 4 + 17;\n\n // Build data codewords\n const codewords = [];\n // Mode indicator: byte mode = 0100\n // Character count (8 bits for v1-9, 16 bits for v10+)\n const ccBits = version <= 9 ? 8 : 16;\n let bitBuf = 0;\n let bitCount = 0;\n\n function pushBits(val, len) {\n for (let i = len - 1; i >= 0; i--) {\n bitBuf = (bitBuf << 1) | ((val >> i) & 1);\n bitCount++;\n if (bitCount === 8) {\n codewords.push(bitBuf);\n bitBuf = 0;\n bitCount = 0;\n }\n }\n }\n\n pushBits(0b0100, 4); // byte mode\n pushBits(data.length, ccBits);\n data.forEach((b) => pushBits(b, 8));\n pushBits(0, 4); // terminator (up to 4 bits)\n\n // Pad to byte boundary\n if (bitCount > 0) pushBits(0, 8 - bitCount);\n\n // Pad to capacity\n while (codewords.length < info.dc) {\n codewords.push(0xec);\n if (codewords.length < info.dc) codewords.push(0x11);\n }\n\n // Split into blocks and compute EC\n const blocks = [];\n const ecBlocks = [];\n const ecPerBlock = info.ec / info.b;\n const dcPerBlock = Math.floor(info.dc / info.b);\n const remainder = info.dc % info.b;\n let offset = 0;\n\n for (let i = 0; i < info.b; i++) {\n const blockDc = dcPerBlock + (i >= info.b - remainder ? 1 : 0);\n const blockData = codewords.slice(offset, offset + blockDc);\n offset += blockDc;\n blocks.push(blockData);\n ecBlocks.push(rsEncode(blockData, ecPerBlock));\n }\n\n // Interleave\n const interleaved = [];\n const maxDc = Math.max(...blocks.map((b) => b.length));\n for (let i = 0; i < maxDc; i++) {\n for (const block of blocks) {\n if (i < block.length) interleaved.push(block[i]);\n }\n }\n for (let i = 0; i < ecPerBlock; i++) {\n for (const ec of ecBlocks) {\n if (i < ec.length) interleaved.push(ec[i]);\n }\n }\n\n // Convert to bit array\n const bits = [];\n interleaved.forEach((byte) => {\n for (let i = 7; i >= 0; i--) bits.push((byte >> i) & 1);\n });\n\n // Build matrix\n const matrix = createMatrix(size);\n const reserved = createMatrix(size);\n\n placeFinderPattern(matrix, reserved, 0, 0);\n placeFinderPattern(matrix, reserved, 0, size - 7);\n placeFinderPattern(matrix, reserved, size - 7, 0);\n\n const alignPos = ALIGNMENT_POSITIONS[version] || [];\n for (const r of alignPos) {\n for (const c of alignPos) {\n if (reserved[r]?.[c]) continue;\n placeAlignmentPattern(matrix, reserved, r, c);\n }\n }\n\n placeTimingPatterns(matrix, reserved);\n reserveFormatArea(matrix, reserved);\n\n // Try all masks, pick lowest penalty\n let bestMask = 0;\n let bestScore = Infinity;\n for (let m = 0; m < 8; m++) {\n const test = matrix.map((row) => new Uint8Array(row));\n placeData(test, reserved, bits);\n applyMask(test, reserved, m);\n placeFormatInfo(test, ecl, m);\n const s = penalty(test);\n if (s < bestScore) {\n bestScore = s;\n bestMask = m;\n }\n }\n\n placeData(matrix, reserved, bits);\n applyMask(matrix, reserved, bestMask);\n placeFormatInfo(matrix, ecl, bestMask);\n\n return matrix;\n}\n\n// ── SVG renderer ──\n\nfunction matrixToSVG(matrix) {\n const size = matrix.length;\n const quiet = 2; // quiet zone modules\n const total = size + quiet * 2;\n\n let paths = \"\";\n for (let r = 0; r < size; r++) {\n for (let c = 0; c < size; c++) {\n if (matrix[r][c]) {\n paths += `M${c + quiet},${r + quiet}h1v1h-1z`;\n }\n }\n }\n\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"viewBox\", `0 0 ${total} ${total}`);\n svg.setAttribute(\"shape-rendering\", \"crispEdges\");\n svg.setAttribute(\"data-part\", \"svg\");\n\n // Background\n const bg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"rect\");\n bg.setAttribute(\"width\", total);\n bg.setAttribute(\"height\", total);\n bg.setAttribute(\"fill\", \"var(--color-bg, #fff)\");\n svg.appendChild(bg);\n\n // QR modules\n const path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n path.setAttribute(\"d\", paths);\n path.setAttribute(\"fill\", \"var(--color-fg, #000)\");\n svg.appendChild(path);\n\n return svg;\n}\n\n// ── Controller ──\n\nfunction createQRCode(root) {\n if (root._faqirQR) return root._faqirQR;\n\n function render() {\n const value = root.getAttribute(\"data-value\") || \"\";\n const ecl = root.getAttribute(\"data-ecl\") || \"M\";\n\n // Remove old SVG\n const old = root.querySelector(\"[data-part='svg']\");\n if (old) old.remove();\n\n if (!value) return;\n\n try {\n const matrix = encodeQR(value, ecl);\n const svg = matrixToSVG(matrix);\n // Insert before caption if present\n const caption = root.querySelector(\"[data-part='caption']\");\n if (caption) {\n root.insertBefore(svg, caption);\n } else {\n root.appendChild(svg);\n }\n } catch (e) {\n console.warn(`[qr-code] Failed to encode: ${e.message}`);\n }\n }\n\n function update(newValue, newEcl) {\n if (newValue !== undefined) root.setAttribute(\"data-value\", newValue);\n if (newEcl !== undefined) root.setAttribute(\"data-ecl\", newEcl);\n render();\n }\n\n // Observe attribute changes\n const observer = new MutationObserver((mutations) => {\n for (const m of mutations) {\n if (m.attributeName === \"data-value\" || m.attributeName === \"data-ecl\") {\n render();\n break;\n }\n }\n });\n observer.observe(root, { attributes: true });\n\n function destroy() {\n observer.disconnect();\n const svg = root.querySelector(\"[data-part='svg']\");\n if (svg) svg.remove();\n delete root._faqirQR;\n }\n\n // Initial render\n render();\n\n const api = { render, update, destroy };\n root._faqirQR = api;\n return api;\n}\n return createQRCode;\n })();\n\n // ── select-custom ── (registry/recipes/select-custom/select-custom.js)\n var createSelectCustom = controllerRegistry[\"select-custom\"] = (function() {\n// @ui:controller select-custom\n// @ui:provides open close toggle select getValue destroy\n\nfunction createSelectCustom(root) {\n // Prevent double-init\n if (root._faqirSelectCustom) return root._faqirSelectCustom;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n const valueEl = root.querySelector(\"[data-part='value']\");\n const listbox = root.querySelector(\"[data-part='listbox']\");\n const searchInput = root.querySelector(\"[data-part='search']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const options = () =>\n [...root.querySelectorAll(\"[data-part='option']\")];\n\n let highlightedIndex = -1;\n let outsideClickCleanup = null;\n let selectedValue = \"\";\n const placeholderText = valueEl?.textContent || \"\";\n\n /**\n * `aria-activedescendant` — the half of the combobox pattern that was declared\n * and never implemented. [W3-4]\n *\n * The trigger publishes `role=\"combobox\"`, which is the APG contract: as the\n * user arrows through the listbox, the combobox must name the active option so\n * a screen reader announces it. Highlighting lived in `data-highlighted`\n * alone and the options carried no `id`, so there was nothing to point at and\n * nothing was ever announced. The axe gate structurally cannot see this — it\n * evaluates static DOM, and the defect exists only mid-navigation.\n *\n * The owner is whichever element holds the combobox role: the search field\n * when the listbox has one (that is where focus is), otherwise the trigger.\n */\n const activeOwner = () => searchInput || trigger;\n\n function optionId(opt) {\n if (!opt.id) opt.id = uid(\"faqir-option\");\n return opt.id;\n }\n\n function setActiveDescendant(opt) {\n const owner = activeOwner();\n if (!owner) return;\n if (opt) owner.setAttribute(\"aria-activedescendant\", optionId(opt));\n else owner.removeAttribute(\"aria-activedescendant\");\n }\n\n /**\n * The hidden input that makes this a form control. [W3-4 · 0.4-28]\n *\n * `select-custom` is sold as a replacement for `<select>`, and a `<select>`\n * submits. This one rendered a `<div>` listbox and kept its value in a\n * closure, so a form containing it POSTed without the field at all — silently,\n * because a missing field looks exactly like an empty one on the server. The\n * input is created only when the markup does not already carry one, and only\n * when the component names itself, so nothing is invented for a component with\n * no name to submit under.\n */\n function ensureValueInput() {\n let el = root.querySelector(\"[data-part='input']\");\n if (el) return el;\n const name = root.dataset.name || root.getAttribute(\"name\");\n if (!name) return null;\n el = document.createElement(\"input\");\n el.type = \"hidden\";\n el.setAttribute(\"data-part\", \"input\");\n el.name = name;\n root.appendChild(el);\n return el;\n }\n\n const valueInput = ensureValueInput();\n\n function open() {\n root.dataset.state = \"open\";\n listbox.hidden = false;\n trigger.setAttribute(\"aria-expanded\", \"true\");\n\n // Reset search if present\n if (searchInput) {\n searchInput.value = \"\";\n filterOptions(\"\");\n searchInput.focus();\n }\n\n clearHighlight();\n outsideClickCleanup = onOutsideClick(root, close);\n }\n\n /**\n * Everything `close()` does EXCEPT moving focus.\n *\n * `destroy()` used to leave an open overlay standing with nothing listening —\n * a dead widget the user cannot dismiss. Closing it on teardown is the fix\n * (`context-menu` is the model), but teardown must not also yank focus\n * somewhere: on an SPA route change the element it would restore to is\n * usually on its way out of the document. [W3-2]\n */\n function dismiss() {\n root.dataset.state = \"closed\";\n listbox.hidden = true;\n trigger.setAttribute(\"aria-expanded\", \"false\");\n clearHighlight();\n\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n function close() {\n dismiss();\n trigger.focus();\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n function clearHighlight() {\n options().forEach((opt) => {\n opt.removeAttribute(\"data-highlighted\");\n });\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function visibleOptions() {\n return options().filter((opt) => !opt.hasAttribute(\"data-hidden\"));\n }\n\n function highlightOption(index) {\n const visible = visibleOptions();\n if (visible.length === 0) return;\n\n // Clamp index\n if (index < 0) index = visible.length - 1;\n if (index >= visible.length) index = 0;\n\n // Clear previous\n options().forEach((opt) => opt.removeAttribute(\"data-highlighted\"));\n\n visible[index].setAttribute(\"data-highlighted\", \"\");\n visible[index].scrollIntoView({ block: \"nearest\" });\n setActiveDescendant(visible[index]);\n highlightedIndex = index;\n }\n\n function filterOptions(query) {\n const allOptions = options();\n const lowerQuery = query.toLowerCase();\n let visibleCount = 0;\n\n allOptions.forEach((opt) => {\n const text = opt.textContent.toLowerCase();\n if (text.includes(lowerQuery)) {\n opt.removeAttribute(\"data-hidden\");\n visibleCount++;\n } else {\n opt.setAttribute(\"data-hidden\", \"\");\n }\n });\n\n // Show/hide empty state\n if (emptyEl) {\n emptyEl.hidden = visibleCount > 0;\n }\n\n clearHighlight();\n return visibleCount;\n }\n\n function select(value) {\n const allOptions = options();\n let targetOption = null;\n\n // Find option by data-value attribute\n allOptions.forEach((opt) => {\n if (opt.dataset.value === value) {\n targetOption = opt;\n }\n });\n\n if (!targetOption) {\n // Fallback: find by text content\n allOptions.forEach((opt) => {\n if (opt.textContent.trim() === value) {\n targetOption = opt;\n }\n });\n }\n\n if (!targetOption) return;\n\n // Deselect all\n allOptions.forEach((opt) => opt.setAttribute(\"aria-selected\", \"false\"));\n\n // Select target\n targetOption.setAttribute(\"aria-selected\", \"true\");\n selectedValue = targetOption.dataset.value || targetOption.textContent.trim();\n\n // Update displayed value\n if (valueEl) {\n valueEl.textContent = targetOption.textContent.trim();\n valueEl.removeAttribute(\"data-placeholder\");\n }\n\n // …and the value a form actually submits. [W3-4 · 0.4-28]\n if (valueInput) valueInput.value = selectedValue;\n\n // Dispatch change event\n const event = new CustomEvent(\"select-change\", {\n bubbles: true,\n detail: {\n value: selectedValue,\n label: targetOption.textContent.trim()\n }\n });\n root.dispatchEvent(event);\n\n close();\n }\n\n function getValue() {\n return selectedValue;\n }\n\n // ── Event Handlers ──\n\n function onTriggerClick() {\n toggle();\n }\n\n function onTriggerKeyDown(e) {\n switch (e.key) {\n case \"ArrowDown\":\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (root.dataset.state !== \"open\") {\n open();\n }\n break;\n case \"Escape\":\n if (root.dataset.state === \"open\") {\n e.preventDefault();\n // Closing the listbox is the whole action — the form around it, and\n // everything the user has typed into it, stays. [W3-2]\n e.stopPropagation();\n close();\n }\n break;\n }\n }\n\n function onListboxKeyDown(e) {\n const visible = visibleOptions();\n\n switch (e.key) {\n case \"ArrowDown\":\n e.preventDefault();\n highlightOption(highlightedIndex + 1);\n break;\n case \"ArrowUp\":\n e.preventDefault();\n highlightOption(highlightedIndex - 1);\n break;\n case \"Enter\":\n e.preventDefault();\n if (highlightedIndex >= 0 && highlightedIndex < visible.length) {\n const opt = visible[highlightedIndex];\n select(opt.dataset.value || opt.textContent.trim());\n }\n break;\n case \"Escape\":\n e.preventDefault();\n // Reached only while the listbox is open, so this Escape is always ours.\n e.stopPropagation();\n close();\n break;\n case \"Home\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightOption(0);\n }\n break;\n case \"End\":\n if (visible.length > 0) {\n e.preventDefault();\n highlightOption(visible.length - 1);\n }\n break;\n }\n }\n\n function onOptionClick(e) {\n const opt = e.target.closest(\"[data-part='option']\");\n if (!opt) return;\n select(opt.dataset.value || opt.textContent.trim());\n }\n\n function onSearchInput() {\n if (searchInput) {\n filterOptions(searchInput.value);\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n trigger?.addEventListener(\"keydown\", onTriggerKeyDown);\n listbox?.addEventListener(\"keydown\", onListboxKeyDown);\n listbox?.addEventListener(\"click\", onOptionClick);\n searchInput?.addEventListener(\"input\", onSearchInput);\n\n function destroy() {\n dismiss();\n trigger?.removeEventListener(\"click\", onTriggerClick);\n trigger?.removeEventListener(\"keydown\", onTriggerKeyDown);\n listbox?.removeEventListener(\"keydown\", onListboxKeyDown);\n listbox?.removeEventListener(\"click\", onOptionClick);\n searchInput?.removeEventListener(\"input\", onSearchInput);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirSelectCustom;\n }\n\n const api = { open, close, toggle, select, getValue, destroy };\n root._faqirSelectCustom = api;\n return api;\n}\n return createSelectCustom;\n })();\n\n // ── sheet ── (registry/recipes/sheet/sheet.js)\n var createSheet = controllerRegistry[\"sheet\"] = (function() {\n// @ui:controller sheet\n// @ui:provides open close toggle destroy\n\nfunction createSheet(root) {\n // Prevent double-init\n if (root._faqirSheet) return root._faqirSheet;\n\n // Overlay and panel are direct children; trigger and close buttons are\n // matched by owner, so a nested component's close leaves this one alone.\n const [trigger] = ownParts(root, \"trigger\");\n const overlay = root.querySelector(\":scope > [data-part='overlay']\");\n const panel = root.querySelector(\":scope > [data-part='panel']\");\n const closeButtons = ownParts(root, \"close\");\n\n // `panel.focus()` on open does nothing without a tabindex: focus stayed on\n // `body`, out of reach of the trap and the root's Escape listener.\n if (panel && !panel.hasAttribute(\"tabindex\")) panel.setAttribute(\"tabindex\", \"-1\");\n\n let focusCleanup = null;\n let previouslyFocused = null;\n let prevBodyOverflow = null;\n\n // Scroll lock: an open modal sheet freezes the page behind it. The guard makes\n // lock/unlock idempotent so overlapping open/close sequences (or a double\n // open) can never leave the body stuck at `overflow: hidden`.\n function lockScroll() {\n if (prevBodyOverflow !== null) return;\n prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n function unlockScroll() {\n if (prevBodyOverflow === null) return;\n document.body.style.overflow = prevBodyOverflow;\n prevBodyOverflow = null;\n }\n\n // Cancels an in-flight \"closing\" wait when the sheet is re-opened mid-slide.\n let cancelExitWait = null;\n\n function open() {\n cancelExitWait?.();\n cancelExitWait = null;\n previouslyFocused = document.activeElement;\n root.dataset.state = \"open\";\n overlay.hidden = false;\n panel.hidden = false;\n lockScroll();\n focusCleanup = trapFocus(panel);\n panel.focus?.();\n }\n\n function close() {\n // Already gone, or already sliding out — a second click must not start a\n // second wait on top of the one in flight.\n if (root.dataset.state === \"closed\" || root.dataset.state === \"closing\") return;\n\n root.dataset.state = \"closing\";\n\n const onEnd = () => {\n cancelExitWait = null;\n const active = document.activeElement;\n root.dataset.state = \"closed\";\n overlay.hidden = true;\n panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n returnFocus(root, previouslyFocused, active);\n };\n\n // The panel's OWN `transform` — not a close button's `background`, which\n // bubbles up to the panel the moment the pointer touches it and used to eat\n // the one-shot listener, stranding the sheet at \"closing\" with the overlay\n // still covering the page. See `whenExitDone`. [W2-1]\n cancelExitWait = whenExitDone(panel, \"transform\", onEnd);\n }\n\n /**\n * Tear the overlay down NOW — no exit animation, no focus restore.\n *\n * `destroy()` unbound every listener and left the panel and its backdrop\n * exactly where they were: a full-page block whose close button, Escape key\n * and overlay click had all just stopped working, with no way out. An SPA\n * route change destroys controllers and does precisely this. The model is\n * `context-menu`, which has always closed itself on teardown. [W3-2]\n */\n function dismiss() {\n cancelExitWait?.();\n cancelExitWait = null;\n root.dataset.state = \"closed\";\n if (overlay) overlay.hidden = true;\n if (panel) panel.hidden = true;\n unlockScroll();\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function toggle() {\n root.dataset.state === \"open\" ? close() : open();\n }\n\n // Event listeners\n function onTriggerClick() {\n open();\n }\n\n function onOverlayClick() {\n close();\n }\n\n function onCloseClick() {\n close();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"open\") {\n e.stopPropagation();\n close();\n }\n }\n\n trigger?.addEventListener(\"click\", onTriggerClick);\n overlay?.addEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) => btn.addEventListener(\"click\", onCloseClick));\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n trigger?.removeEventListener(\"click\", onTriggerClick);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n closeButtons.forEach((btn) =>\n btn.removeEventListener(\"click\", onCloseClick)\n );\n root.removeEventListener(\"keydown\", onKeyDown);\n dismiss();\n delete root._faqirSheet;\n }\n\n const api = { open, close, toggle, destroy };\n root._faqirSheet = api;\n return api;\n}\n return createSheet;\n })();\n\n // ── sidebar ── (registry/recipes/sidebar/sidebar.js)\n var createSidebar = controllerRegistry[\"sidebar\"] = (function() {\n// @ui:controller sidebar\n// @ui:provides toggle expand collapse open close isMobile getState destroy\n\n/**\n * sidebar — a collapsible application sidebar with three modes:\n *\n * • expanded — desktop, full-width with labels (default)\n * • rail — desktop, icons-only\n * • drawer — mobile, an off-canvas overlay panel (closed ↔ open)\n *\n * The single source of truth is `data-state` on the root; its value is one of\n * `expanded`, `rail`, `drawer` (mobile, closed) or `drawer-open` (mobile, open).\n * Agents can set the initial state declaratively — the controller reconciles it\n * with the current breakpoint on init.\n *\n * A `matchMedia` query (default `(max-width: 768px)`, overridable with\n * `data-breakpoint`) decides desktop vs mobile. `toggle()` is breakpoint-aware:\n * expanded ↔ rail on desktop, open ↔ close on mobile. The desktop preference\n * (expanded/rail) persists across a trip through the mobile breakpoint, so\n * resizing back to desktop restores what the user last chose.\n *\n * The mobile drawer is a proper modal surface: focus is trapped in the panel,\n * Escape and an overlay click close it, body scroll is locked while open, and\n * focus returns to whatever opened it. When the drawer is closed on mobile the\n * panel is `inert` + `aria-hidden`, so its links never sit in the tab order\n * off-screen. Every toggle button's `aria-expanded` tracks the live state.\n */\nfunction createSidebar(root) {\n // Prevent double-init.\n if (root._faqirSidebar) return root._faqirSidebar;\n\n const overlay = root.querySelector(\":scope > [data-part='overlay']\");\n const panel = root.querySelector(\":scope > [data-part='panel']\") || root;\n\n // Toggle buttons: the sidebar's own `[data-part='trigger']`s, plus external\n // triggers in the app shell that point at this sidebar by id. Both call\n // toggle(). A dropdown's trigger in the footer belongs to the dropdown: it\n // used to have its aria-expanded forced and its click rail the sidebar.\n const internalTriggers = ownParts(root, \"trigger\");\n const externalTriggers = root.id\n ? [...document.querySelectorAll(`[data-sidebar-toggle=\"${root.id}\"]`)]\n : [];\n const triggers = [...internalTriggers, ...externalTriggers];\n\n // Persistent desktop preference (expanded ↔ rail) and mobile open flag, both\n // seeded from the declared data-state so the initial render is intent-preserving.\n const declared = root.dataset.state || \"expanded\";\n let desktopState = declared === \"rail\" ? \"rail\" : \"expanded\";\n let drawerOpen = declared === \"drawer-open\";\n\n // Responsive breakpoint. `data-breakpoint` is a max-width in px (default 768).\n const bp = (() => {\n const n = parseInt(root.dataset.breakpoint || \"\", 10);\n return Number.isFinite(n) && n > 0 ? n : 768;\n })();\n const query = `(max-width: ${bp}px)`;\n const mql =\n typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(query)\n : null;\n\n function isMobile() {\n return mql ? !!mql.matches : false;\n }\n\n // Modal bookkeeping for the mobile drawer.\n let focusCleanup = null;\n let previouslyFocused = null;\n let prevBodyOverflow = null;\n\n function lockScroll() {\n if (prevBodyOverflow !== null) return;\n prevBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n }\n function unlockScroll() {\n if (prevBodyOverflow === null) return;\n document.body.style.overflow = prevBodyOverflow;\n prevBodyOverflow = null;\n }\n function releaseFocusTrap() {\n if (focusCleanup) focusCleanup();\n focusCleanup = null;\n }\n\n function getState() {\n return root.dataset.state || \"\";\n }\n\n /**\n * Reconcile every reflected attribute with the current model + breakpoint.\n * Pure DOM writes — never dispatches an event, so it is safe to call on init.\n */\n function render() {\n const mobile = isMobile();\n const state = mobile ? (drawerOpen ? \"drawer-open\" : \"drawer\") : desktopState;\n root.dataset.state = state;\n\n // Overlay only exists as a hit-target when the drawer is open.\n if (overlay) overlay.hidden = state !== \"drawer-open\";\n\n // Closed mobile drawer: keep the off-screen panel out of the tab order and\n // the a11y tree. Any other state is a live, interactive surface.\n if (panel && panel !== root) {\n if (state === \"drawer\") {\n panel.setAttribute(\"inert\", \"\");\n panel.setAttribute(\"aria-hidden\", \"true\");\n } else {\n panel.removeAttribute(\"inert\");\n panel.removeAttribute(\"aria-hidden\");\n }\n }\n\n // aria-expanded reflects \"is the sidebar showing its content?\": labels on\n // desktop, an open drawer on mobile.\n const expanded = mobile ? drawerOpen : desktopState === \"expanded\";\n for (const t of triggers) t.setAttribute(\"aria-expanded\", String(expanded));\n }\n\n // ── Mobile drawer open/close ───────────────────────────────────────────────\n function open() {\n if (drawerOpen) return;\n previouslyFocused = document.activeElement;\n drawerOpen = true;\n render();\n lockScroll();\n focusCleanup = trapFocus(panel);\n if (!focusFirst(panel)) panel.focus?.();\n }\n\n function close() {\n if (!drawerOpen) return;\n drawerOpen = false;\n render();\n unlockScroll();\n releaseFocusTrap();\n previouslyFocused?.focus?.();\n previouslyFocused = null;\n }\n\n // ── Desktop expand/collapse ────────────────────────────────────────────────\n function expand() {\n desktopState = \"expanded\";\n render();\n }\n function collapse() {\n desktopState = \"rail\";\n render();\n }\n\n // ── Breakpoint-aware toggle ────────────────────────────────────────────────\n function toggle() {\n if (isMobile()) {\n drawerOpen ? close() : open();\n } else {\n desktopState === \"expanded\" ? collapse() : expand();\n }\n }\n\n // When the viewport crosses the breakpoint, tear down any live drawer modality\n // (a drawer left open as the window widens must not keep the scroll lock or the\n // focus trap) and re-render into the mode the new breakpoint calls for.\n function onMediaChange() {\n if (!isMobile() && drawerOpen) {\n drawerOpen = false;\n unlockScroll();\n releaseFocusTrap();\n previouslyFocused = null;\n }\n render();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && isMobile() && drawerOpen) {\n e.stopPropagation();\n close();\n }\n }\n\n function onTriggerClick(e) {\n e.preventDefault();\n toggle();\n }\n\n function onOverlayClick() {\n close();\n }\n\n for (const t of triggers) t.addEventListener(\"click\", onTriggerClick);\n overlay?.addEventListener(\"click\", onOverlayClick);\n root.addEventListener(\"keydown\", onKeyDown);\n if (mql) {\n if (typeof mql.addEventListener === \"function\") mql.addEventListener(\"change\", onMediaChange);\n else if (typeof mql.addListener === \"function\") mql.addListener(onMediaChange);\n }\n\n // Paint the reconciled initial state (no event).\n render();\n\n function destroy() {\n // A destroyed sidebar left mid-drawer is a dead overlay: the scrim still\n // covers the page, and its trigger, Escape and overlay click have all just\n // stopped working. Collapse the drawer first, without restoring focus —\n // teardown must not yank focus to an element on its way out. [W3-2]\n if (drawerOpen) {\n drawerOpen = false;\n render();\n }\n previouslyFocused = null;\n for (const t of triggers) t.removeEventListener(\"click\", onTriggerClick);\n overlay?.removeEventListener(\"click\", onOverlayClick);\n root.removeEventListener(\"keydown\", onKeyDown);\n if (mql) {\n if (typeof mql.removeEventListener === \"function\") mql.removeEventListener(\"change\", onMediaChange);\n else if (typeof mql.removeListener === \"function\") mql.removeListener(onMediaChange);\n }\n unlockScroll();\n releaseFocusTrap();\n delete root._faqirSidebar;\n }\n\n const api = { toggle, expand, collapse, open, close, isMobile, getState, destroy };\n root._faqirSidebar = api;\n return api;\n}\n return createSidebar;\n })();\n\n // ── slider ── (registry/recipes/slider/slider.js)\n var createSlider = controllerRegistry[\"slider\"] = (function() {\n// @ui:controller slider\n// @ui:provides setValue getValue getValues setFormatter destroy\n\n/**\n * slider — single-thumb and range (two-thumb) slider.\n *\n * Modes are inferred from the DOM, never from a flag: two-or-more\n * `[data-part=\"thumb\"]` elements ⇒ range mode. Each thumb is an independent\n * `role=\"slider\"` widget with its own keyboard handling and ARIA value state.\n *\n * The controller owns only runtime state: it writes `aria-valuemin/max/now`\n * (and `aria-valuetext`, via a formatter hook), positions thumbs through the\n * `--pos` custom property, reflects the filled span through `--slider-start` /\n * `--slider-end` on the root, and toggles `data-state=\"dragging\"` on the active\n * thumb. All value arithmetic lives in the pure, exported helpers below\n * (`valueFromPointer`, `snapToStep`, `percentOf`) so it is unit-testable without\n * a DOM.\n */\nfunction createSlider(root) {\n // Prevent double-init.\n if (root._faqirSlider) return root._faqirSlider;\n\n const track = root.querySelector(\"[data-part='track']\");\n const thumbs = [...root.querySelectorAll(\"[data-part='thumb']\")];\n const isRange = thumbs.length >= 2;\n const last = thumbs.length - 1;\n\n const min = numAttr(root, \"min\", 0);\n const max = numAttr(root, \"max\", 100);\n const step = (() => {\n const s = numAttr(root, \"step\", 1);\n return s > 0 ? s : 1;\n })();\n // PageUp/PageDown jump: an explicit data-page-step, else ten normal steps.\n const bigStep = (() => {\n const p = numAttr(root, \"pageStep\", NaN);\n return Number.isFinite(p) && p > 0 ? p : step * 10;\n })();\n\n // aria-valuetext hook: a formatter set via setFormatter() wins; otherwise a\n // declarative `data-value-suffix` (e.g. \"%\") produces \"<value><suffix>\".\n let formatter = null;\n const suffix = root.dataset.valueSuffix || \"\";\n\n // Ensure every thumb is a proper, focusable slider even if the author omitted\n // the role/tabindex — screen-reader-correct ARIA must not depend on hand markup.\n thumbs.forEach((thumb) => {\n if (!thumb.hasAttribute(\"role\")) thumb.setAttribute(\"role\", \"slider\");\n if (!thumb.hasAttribute(\"tabindex\")) {\n thumb.setAttribute(\"tabindex\", isDisabled() ? \"-1\" : \"0\");\n }\n });\n\n // Seed values: prefer an existing aria-valuenow, then the i-th data-value\n // token, then a sensible default (first thumb → min, last → max).\n const dataVals = (root.dataset.value || \"\")\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s !== \"\")\n .map(Number);\n\n let values = thumbs.map((thumb, i) => {\n const now = thumb.getAttribute(\"aria-valuenow\");\n if (now !== null && now !== \"\" && Number.isFinite(Number(now))) return Number(now);\n if (i < dataVals.length && Number.isFinite(dataVals[i])) return dataVals[i];\n return i === 0 ? min : max;\n });\n // Normalize in order so range clamping sees already-normalized lower neighbours.\n thumbs.forEach((_, i) => {\n values[i] = clampForThumb(i, snapToStep(values[i], min, max, step));\n });\n\n function isDisabled() {\n return root.hasAttribute(\"data-disabled\");\n }\n\n // Clamp a candidate value to the global bounds and, in range mode, to the\n // adjacent thumbs — this is what stops the two thumbs from crossing.\n function clampForThumb(index, value) {\n let lo = min;\n let hi = max;\n if (isRange) {\n if (index > 0) lo = values[index - 1];\n if (index < last) hi = values[index + 1];\n }\n return Math.min(Math.max(value, lo), hi);\n }\n\n function boundsFor(index) {\n const lo = isRange && index > 0 ? values[index - 1] : min;\n const hi = isRange && index < last ? values[index + 1] : max;\n return { lo, hi };\n }\n\n function textFor(value, index) {\n if (typeof formatter === \"function\") return formatter(value, index);\n if (suffix) return `${value}${suffix}`;\n return null;\n }\n\n function renderThumb(index) {\n const thumb = thumbs[index];\n const value = values[index];\n const { lo, hi } = boundsFor(index);\n thumb.setAttribute(\"aria-valuemin\", String(lo));\n thumb.setAttribute(\"aria-valuemax\", String(hi));\n thumb.setAttribute(\"aria-valuenow\", String(value));\n const text = textFor(value, index);\n if (text != null) thumb.setAttribute(\"aria-valuetext\", text);\n else thumb.removeAttribute(\"aria-valuetext\");\n thumb.style.setProperty(\"--pos\", `${percentOf(value, min, max)}%`);\n }\n\n function renderRange() {\n const startPct = isRange ? percentOf(values[0], min, max) : 0;\n const endPct = percentOf(values[isRange ? last : 0], min, max);\n root.style.setProperty(\"--slider-start\", `${startPct}%`);\n root.style.setProperty(\"--slider-end\", `${endPct}%`);\n }\n\n function render() {\n thumbs.forEach((_, i) => renderThumb(i));\n renderRange();\n }\n\n function emitChange(index) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:change\", {\n bubbles: true,\n detail: { index, value: values[index], values: values.slice() },\n }),\n );\n }\n\n // The single mutation seam: snap → clamp (non-crossing) → render → notify.\n function applyValue(index, rawValue, opts) {\n if (index < 0 || index >= thumbs.length) return;\n const next = clampForThumb(index, snapToStep(rawValue, min, max, step));\n const changed = next !== values[index];\n values[index] = next;\n render();\n if (changed && !(opts && opts.silent)) emitChange(index);\n }\n\n function nearestThumb(value) {\n let best = 0;\n let bestDist = Infinity;\n for (let i = 0; i < values.length; i++) {\n const d = Math.abs(values[i] - value);\n if (d < bestDist) {\n bestDist = d;\n best = i;\n }\n }\n return best;\n }\n\n // ── RTL ──────────────────────────────────────────────────────────────────\n // getComputedStyle is authoritative in a browser; fall back to the dir\n // attribute for detached nodes / happy-dom where computed direction is unset.\n function isRTL() {\n if (root.closest('[dir=\"rtl\"]')) return true;\n if (typeof getComputedStyle === \"function\") {\n try {\n return getComputedStyle(root).direction === \"rtl\";\n } catch {\n /* jsdom/happy-dom on a detached node — ignore */\n }\n }\n return false;\n }\n\n // ── Keyboard ─────────────────────────────────────────────────────────────\n function onKeyDown(e) {\n if (isDisabled()) return;\n const thumb = e.target.closest(\"[data-part='thumb']\");\n if (!thumb || !root.contains(thumb)) return;\n const index = thumbs.indexOf(thumb);\n if (index < 0) return;\n\n const rtl = isRTL();\n const cur = values[index];\n let next;\n switch (e.key) {\n case \"ArrowUp\":\n next = cur + step;\n break;\n case \"ArrowDown\":\n next = cur - step;\n break;\n case \"ArrowRight\":\n next = cur + (rtl ? -step : step);\n break;\n case \"ArrowLeft\":\n next = cur + (rtl ? step : -step);\n break;\n case \"PageUp\":\n next = cur + bigStep;\n break;\n case \"PageDown\":\n next = cur - bigStep;\n break;\n case \"Home\":\n next = min; // clampForThumb pins it to the lower neighbour in range mode\n break;\n case \"End\":\n next = max;\n break;\n default:\n return;\n }\n e.preventDefault();\n applyValue(index, next);\n }\n\n // ── Pointer dragging ─────────────────────────────────────────────────────\n let drag = null; // { index }\n const docHandlers = [];\n\n function beginDrag(index) {\n drag = { index };\n thumbs[index].dataset.state = \"dragging\";\n const move = (ev) => onDragMove(ev);\n const end = () => endDrag();\n document.addEventListener(\"pointermove\", move);\n document.addEventListener(\"pointerup\", end);\n document.addEventListener(\"pointercancel\", end);\n docHandlers.push([\"pointermove\", move], [\"pointerup\", end], [\"pointercancel\", end]);\n }\n\n function onDragMove(ev) {\n if (!drag || !track) return;\n const value = valueFromPointer(ev.clientX, track.getBoundingClientRect(), {\n min,\n max,\n step,\n rtl: isRTL(),\n });\n applyValue(drag.index, value);\n }\n\n function endDrag() {\n if (!drag) return;\n thumbs[drag.index].removeAttribute(\"data-state\");\n for (const [type, fn] of docHandlers) document.removeEventListener(type, fn);\n docHandlers.length = 0;\n drag = null;\n }\n\n function onPointerDown(e) {\n if (isDisabled()) return;\n if (typeof e.button === \"number\" && e.button !== 0) return; // primary button only\n\n const thumb = e.target.closest(\"[data-part='thumb']\");\n if (thumb && root.contains(thumb)) {\n e.preventDefault();\n const index = thumbs.indexOf(thumb);\n thumb.focus();\n beginDrag(index);\n return;\n }\n\n // A press anywhere on the track jumps the nearest thumb to that point and\n // starts dragging it — the standard \"click-to-set\" affordance.\n if (track && (e.target === track || track.contains(e.target))) {\n e.preventDefault();\n const value = valueFromPointer(e.clientX, track.getBoundingClientRect(), {\n min,\n max,\n step,\n rtl: isRTL(),\n });\n const index = nearestThumb(value);\n applyValue(index, value);\n if (thumbs[index]) thumbs[index].focus();\n beginDrag(index);\n }\n }\n\n root.addEventListener(\"keydown\", onKeyDown);\n root.addEventListener(\"pointerdown\", onPointerDown);\n\n // Paint initial positions/ARIA without firing a spurious change event.\n render();\n\n // ── Public API ───────────────────────────────────────────────────────────\n function setValue(index, value) {\n applyValue(index, value);\n }\n function getValue() {\n return isRange ? values.slice() : values[0];\n }\n function getValues() {\n return values.slice();\n }\n function setFormatter(fn) {\n formatter = typeof fn === \"function\" ? fn : null;\n render();\n }\n\n function destroy() {\n root.removeEventListener(\"keydown\", onKeyDown);\n root.removeEventListener(\"pointerdown\", onPointerDown);\n endDrag();\n delete root._faqirSlider;\n }\n\n const api = { setValue, getValue, getValues, setFormatter, destroy };\n root._faqirSlider = api;\n return api;\n}\n\n// ── Pure value math (no DOM) — unit-tested in isolation ──────────────────────\n\n/** Decimal places implied by a step (so 0.1 + 0.2 doesn't leak float dust). */\nfunction stepDecimals(step) {\n const str = String(step);\n const dot = str.indexOf(\".\");\n return dot === -1 ? 0 : str.length - dot - 1;\n}\n\n/**\n * Snap a raw value onto the nearest step from `min`, clamped to `[min, max]`.\n * @returns {number}\n */\nfunction snapToStep(value, min, max, step) {\n const s = step > 0 ? step : 1;\n const steps = Math.round((value - min) / s);\n const snapped = Math.min(Math.max(min + steps * s, min), max);\n return Number(snapped.toFixed(stepDecimals(s)));\n}\n\n/** Value → percent along the track (0–100), clamped. */\nfunction percentOf(value, min, max) {\n if (max === min) return 0;\n const p = ((value - min) / (max - min)) * 100;\n return Math.min(Math.max(p, 0), 100);\n}\n\n/**\n * Map a pointer x-coordinate to a slider value. Pure: no DOM access — the caller\n * supplies the track rect. Handles RTL by inverting the fraction, so the same\n * arithmetic serves both writing directions.\n *\n * @param {number} clientX pointer x in client coordinates\n * @param {{left:number, width:number}} rect track bounding rect\n * @param {{min:number, max:number, step:number, rtl?:boolean}} opts\n * @returns {number} snapped, clamped value\n */\nfunction valueFromPointer(clientX, rect, opts) {\n const { min, max, step } = opts;\n const width = rect.width;\n if (!(width > 0)) return min;\n let fraction = (clientX - rect.left) / width;\n fraction = Math.min(Math.max(fraction, 0), 1);\n if (opts.rtl) fraction = 1 - fraction;\n return snapToStep(min + fraction * (max - min), min, max, step);\n}\n\n// Read a numeric data-* attribute (dataset key), falling back when absent/NaN.\nfunction numAttr(el, key, fallback) {\n const raw = el.dataset[key];\n if (raw == null || raw === \"\") return fallback;\n const n = Number(raw);\n return Number.isFinite(n) ? n : fallback;\n}\n return createSlider;\n })();\n\n // ── table ── (registry/recipes/table/table.js)\n var createTable = controllerRegistry[\"table\"] = (function() {\n// @ui:controller table\n// @ui:provides sort sortBy clearSort selectRow selectAll deselectAll getSelected getSelectedData setFilter setColumnFilter clearFilters toggleGroup toggleRow toggleDetail expandAll collapseAll startEdit commitEdit cancelEdit moveRow moveColumn hideColumn showColumn toggleColumn setColumnWidth exportCsv getData getState setState refresh destroy\n\n/**\n * Advanced data table controller.\n *\n * Everything beyond the base contract (sort / select) is opt-in through data\n * attributes on the root, so a plain table pays for nothing:\n *\n * data-multi-sort shift+click accumulates secondary sorts\n * data-sort-cycle=\"tristate\" third header click restores original order\n * data-selectable[=\"single|multi\"] row click (de)selects; default multi\n * data-editable inline cell editing (dblclick / Enter / F2)\n * data-tree tree table driven by tr[data-level] depths\n * data-groupable group-header rows collapse/expand their section\n * data-reorderable drag rows via [data-part=\"drag-handle\"] (+ arrows)\n * data-col-reorderable drag column headers to rearrange columns\n * data-resizable column resize handles on headers\n * data-sticky-header / data-sticky-footer sticky thead/tfoot in a scroll root\n * data-navigable roving-focus grid keyboard navigation (implied by data-editable)\n * data-responsive=\"stack\" stacked card layout under the container breakpoint\n * data-persist=\"key\" persist sort/filter/width/visibility to localStorage\n * data-locale / data-currency / data-negatives=\"red|parens|both\" Intl formatting\n *\n * Column headers (th) may carry: data-sortable, data-type, data-format,\n * data-align, data-editable, data-readonly, data-pin=\"start|end\",\n * data-hide-below=\"sm|md|lg\", data-key, data-min-width, data-max-width.\n * Cells (td) may carry: data-value (raw), data-sort-value, data-format,\n * data-align, data-editable, data-readonly, data-aggregate=\"sum|avg|min|max|count\",\n * data-col (explicit column for aggregate cells with colspan).\n *\n * Runtime state the controller manages: data-selected, data-collapsed,\n * data-filtered, data-editing, data-dragging, data-drop-target/-pos,\n * data-col-hidden, data-negative, data-stripe, data-resized, aria-sort,\n * aria-expanded, aria-level plus the --table-level / --table-pin-offset /\n * --table-thead-h\n * private custom properties.\n *\n * Events (CustomEvent, bubbling): faqir:sort, faqir:selection-change,\n * faqir:filter, faqir:edit-start, faqir:cell-edit, faqir:edit-cancel,\n * faqir:row-reorder, faqir:col-reorder, faqir:col-resize, faqir:group-toggle,\n * faqir:tree-toggle, faqir:row-expand, faqir:col-visibility.\n */\nfunction createTable(root) {\n // Prevent double-init\n if (root._faqirTable) return root._faqirTable;\n\n // A table nested in a detail row keeps its own parts and events: `tbody`\n // contains it, so every deep lookup and delegated handler checks `mine`.\n const mine = (el) => el.closest(\"[data-ui='table']\") === root;\n const table = root.querySelector(\"[data-part='table']\");\n const thead = root.querySelector(\"[data-part='thead']\");\n const tbody = root.querySelector(\"[data-part='tbody']\");\n const tfoot = [...root.querySelectorAll(\"[data-part='tfoot']\")].find(mine);\n const headerCheckbox = thead?.querySelector(\"[data-part='checkbox']\");\n\n // ── Options (read once from the root's opt-in attributes) ──\n const opts = {\n multiSort: root.hasAttribute(\"data-multi-sort\"),\n sortCycle: root.getAttribute(\"data-sort-cycle\") || \"toggle\",\n editable: root.hasAttribute(\"data-editable\"),\n tree: root.hasAttribute(\"data-tree\"),\n groupable: root.hasAttribute(\"data-groupable\"),\n reorderable: root.hasAttribute(\"data-reorderable\"),\n colReorderable: root.hasAttribute(\"data-col-reorderable\"),\n resizable: root.hasAttribute(\"data-resizable\"),\n selectable: root.getAttribute(\"data-selectable\"), // null | \"\" | \"single\" | \"multi\"\n navigable: root.hasAttribute(\"data-navigable\") || root.hasAttribute(\"data-editable\"),\n responsive: root.getAttribute(\"data-responsive\") || \"\",\n persistKey: root.getAttribute(\"data-persist\") || \"\",\n locale: root.getAttribute(\"data-locale\") || document.documentElement.lang || undefined,\n currency: root.getAttribute(\"data-currency\") || \"USD\",\n negatives: root.getAttribute(\"data-negatives\") || \"\",\n };\n const accounting = opts.negatives === \"parens\" || opts.negatives === \"both\";\n const isRTL = (root.closest(\"[dir]\")?.getAttribute(\"dir\") || \"\").toLowerCase() === \"rtl\";\n\n // ── Internal state ──\n let sorts = []; // [{ index, dir: \"ascending\"|\"descending\" }]\n let hasSorted = false;\n let globalFilter = \"\";\n const columnFilters = new Map(); // colIndex -> string | (raw, cell, row) => boolean\n let lastSelectedIndex = -1;\n let editing = null; // { cell, row, input, oldText, oldValue, colIndex, type }\n let activeCell = null; // roving-tabindex focus target\n let drag = null; // active pointer drag (rows / columns / resize)\n let suppressClickUntil = 0;\n let muted = false; // silences emit() during setState/expandAll\n let observer = null;\n let observerPaused = 0;\n let refreshQueued = false;\n const timers = new Set();\n const cleanups = [];\n const colTypeCache = new Map();\n const originalIndex = new WeakMap();\n let originSeq = 0;\n\n const collator = new Intl.Collator(opts.locale, { numeric: true, sensitivity: \"base\" });\n\n // ── Tiny helpers ──\n const toggleAttr = (el, name, on) => (on ? el.setAttribute(name, \"\") : el.removeAttribute(name));\n const later = (fn, ms) => {\n const t = setTimeout(() => {\n timers.delete(t);\n fn();\n }, ms);\n timers.add(t);\n return t;\n };\n const on = (target, ev, fn, o) => {\n target.addEventListener(ev, fn, o);\n cleanups.push(() => target.removeEventListener(ev, fn, o));\n };\n\n function emit(type, detail) {\n if (muted) return;\n root.dispatchEvent(new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }));\n }\n function mutedRun(fn) {\n const was = muted;\n muted = true;\n try {\n fn();\n } finally {\n muted = was;\n }\n }\n\n // ── Row / cell access ──\n const rowsIn = (section, part = \"tr\") =>\n section ? [...section.children].filter((r) => r.getAttribute(\"data-part\") === part) : [];\n const bodyRows = () => rowsIn(tbody);\n const groupHeaders = () => rowsIn(tbody, \"group-header\");\n const cellsOf = (row) =>\n [...row.children].filter((c) => {\n const p = c.getAttribute(\"data-part\");\n return p === \"td\" || p === \"th\";\n });\n const detailOf = (row) => {\n const n = row.nextElementSibling;\n return n && n.getAttribute(\"data-part\") === \"detail-row\" ? n : null;\n };\n const isRowVisible = (r) =>\n !r.hasAttribute(\"data-collapsed\") && !r.hasAttribute(\"data-filtered\") && !r.hasAttribute(\"hidden\");\n const visibleBodyRows = () => bodyRows().filter(isRowVisible);\n\n function headerRowEl() {\n const trs = rowsIn(thead).filter((r) =>\n cellsOf(r).some((c) => c.getAttribute(\"data-part\") === \"th\")\n );\n return trs[trs.length - 1] || null; // leaf row of (possibly grouped) headers\n }\n const headerCells = () => (headerRowEl() ? cellsOf(headerRowEl()) : []);\n const columnCount = () => headerCells().length;\n const filterRowEl = () => (thead ? rowsIn(thead, \"filter-row\")[0] || null : null);\n const sortableHeaders = () => headerCells().filter((th) => th.hasAttribute(\"data-sortable\"));\n\n function headerText(i) {\n const th = headerCells()[i];\n if (!th) return \"\";\n const clone = th.cloneNode(true);\n for (const junk of clone.querySelectorAll(\"[data-part='resize-handle'],[data-part='checkbox'],input,button\")) {\n junk.remove();\n }\n return (clone.textContent || \"\").trim();\n }\n\n /** Every row that has one cell per column (skips colspan rows like group headers). */\n function fullWidthRows() {\n const n = columnCount();\n const out = [];\n const fr = filterRowEl();\n if (headerRowEl()) out.push(headerRowEl());\n if (fr) out.push(fr);\n for (const r of [...bodyRows(), ...rowsIn(tfoot)]) out.push(r);\n return out.filter((r) => cellsOf(r).length === n);\n }\n function forEachColumnCell(i, fn) {\n for (const row of fullWidthRows()) {\n const cell = cellsOf(row)[i];\n if (cell) fn(cell, row);\n }\n }\n\n // ── Value parsing ──\n const NBSP = /[\\u00a0\\u202f]/g;\n /** Numeric parse tolerant of currency symbols, thousands separators, and accounting parens. */\n function parseNumeric(str) {\n if (str == null) return NaN;\n let s = String(str).replace(NBSP, \" \").trim();\n if (!s) return NaN;\n let negative = false;\n const paren = s.match(/^\\((.*)\\)$/);\n if (paren) {\n negative = true;\n s = paren[1];\n }\n s = s.replace(/[^0-9.,-]/g, \"\");\n if (!s) return NaN;\n const lastComma = s.lastIndexOf(\",\");\n const lastDot = s.lastIndexOf(\".\");\n if (lastComma >= 0 && lastDot >= 0) {\n // Rightmost separator is the decimal mark; the other groups thousands.\n s = lastComma > lastDot ? s.replace(/\\./g, \"\").replace(\",\", \".\") : s.replace(/,/g, \"\");\n } else if (lastComma >= 0) {\n const parts = s.split(\",\");\n s = parts.length === 2 && parts[1].length >= 1 && parts[1].length <= 2\n ? s.replace(\",\", \".\") // \"0,5\" → decimal comma\n : s.replace(/,/g, \"\"); // \"1,234,567\" → thousands\n } else if ((s.match(/\\./g) || []).length > 1) {\n s = s.replace(/\\./g, \"\"); // \"1.234.567\" → dot-grouped thousands\n }\n const n = parseFloat(s);\n return isNaN(n) ? NaN : negative ? -n : n;\n }\n\n const ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(?:[T ]|$)/;\n /** Timestamp for ISO dates and dd/mm/yyyy (or dd.mm.yyyy) strings; NaN otherwise. */\n function parseDateValue(str) {\n const s = String(str == null ? \"\" : str).trim();\n if (!s) return NaN;\n if (ISO_DATE.test(s)) {\n const t = Date.parse(s.length === 10 ? s + \"T00:00:00Z\" : s);\n return isNaN(t) ? NaN : t;\n }\n const m = s.match(/^(\\d{1,2})[/.](\\d{1,2})[/.](\\d{4})$/);\n if (m) return Date.UTC(+m[3], +m[2] - 1, +m[1]);\n return NaN;\n }\n\n const cellRaw = (cell) =>\n cell.hasAttribute(\"data-value\")\n ? cell.getAttribute(\"data-value\")\n : (cell.textContent || \"\").trim();\n const sortRaw = (cell) =>\n cell.hasAttribute(\"data-sort-value\") ? cell.getAttribute(\"data-sort-value\") : cellRaw(cell);\n\n const NUMERIC_TYPES = { number: 1, currency: 1, percent: 1 };\n const isNumericType = (t) => !!NUMERIC_TYPES[t];\n\n /** Column type: explicit th data-type / data-format, else sniffed from cells. */\n function columnType(i) {\n if (colTypeCache.has(i)) return colTypeCache.get(i);\n let type = \"\";\n const th = headerCells()[i];\n type = th?.getAttribute(\"data-type\") || th?.getAttribute(\"data-format\") || \"\";\n if (!type) {\n let sawAny = false;\n let allNum = true;\n let allDate = true;\n for (const row of bodyRows().slice(0, 25)) {\n const cell = cellsOf(row)[i];\n if (!cell) continue;\n const cf = cell.getAttribute(\"data-format\");\n if (cf) {\n type = cf;\n break;\n }\n const raw = sortRaw(cell);\n if (!raw) continue;\n sawAny = true;\n if (isNaN(parseDateValue(raw))) allDate = false;\n if (isNaN(parseNumeric(raw))) allNum = false;\n if (!allNum && !allDate) break;\n }\n if (!type) type = sawAny && allDate ? \"date\" : sawAny && allNum ? \"number\" : \"text\";\n }\n colTypeCache.set(i, type);\n return type;\n }\n\n // ── Intl formatting ──\n function formatValue(n, fmt) {\n const o =\n fmt === \"currency\"\n ? { style: fmt, currency: opts.currency, currencySign: accounting ? \"accounting\" : \"standard\" }\n : fmt === \"percent\"\n ? { style: fmt, maximumFractionDigits: 2 }\n : fmt === \"number\" && { maximumFractionDigits: 2 };\n try {\n if (o) return new Intl.NumberFormat(opts.locale, o).format(fmt === \"percent\" ? n / 100 : n);\n } catch {\n /* unknown locale/currency — fall through to raw */\n }\n return String(n);\n }\n\n function applyNegativeFlag(cell) {\n const fmt = cell.getAttribute(\"data-format\");\n if (!fmt || !isNumericType(fmt)) return;\n const n = parseNumeric(cellRaw(cell));\n toggleAttr(cell, \"data-negative\", !isNaN(n) && n < 0);\n }\n\n /** Cells carrying both data-value and data-format render through Intl; text-only cells are never rewritten. */\n function formatCell(cell) {\n if (cell.hasAttribute(\"data-editing\")) return;\n const fmt = cell.getAttribute(\"data-format\");\n if (!fmt) return;\n if (cell.hasAttribute(\"data-value\")) {\n const raw = cell.getAttribute(\"data-value\");\n if (fmt === \"date\") {\n const t = parseDateValue(raw);\n if (!isNaN(t)) cell.textContent = new Date(t).toLocaleDateString(opts.locale);\n } else if (isNumericType(fmt)) {\n const n = parseNumeric(raw);\n if (!isNaN(n)) cell.textContent = formatValue(n, fmt);\n }\n }\n applyNegativeFlag(cell);\n }\n\n function applyFormats() {\n for (const row of [...bodyRows(), ...rowsIn(tfoot)]) {\n for (const cell of cellsOf(row)) formatCell(cell);\n }\n }\n\n // ── Tree helpers ──\n const levelOf = (r) => {\n const v = parseInt(r.getAttribute(\"data-level\") || \"0\", 10);\n return isNaN(v) ? 0 : v;\n };\n /** Descendant data rows of a tree row (detail rows excluded; group headers terminate). */\n function subtreeRows(row) {\n const out = [];\n const lvl = levelOf(row);\n let n = row.nextElementSibling;\n while (n) {\n const p = n.getAttribute(\"data-part\");\n if (p === \"group-header\") break;\n if (p === \"tr\") {\n if (levelOf(n) <= lvl) break;\n out.push(n);\n }\n n = n.nextElementSibling;\n }\n return out;\n }\n const childrenOf = (row) => subtreeRows(row).filter((r) => levelOf(r) === levelOf(row) + 1);\n function parentOf(row) {\n const lvl = levelOf(row);\n if (lvl <= 0) return null;\n let n = row.previousElementSibling;\n while (n) {\n if (n.getAttribute(\"data-part\") === \"tr\" && levelOf(n) < lvl) return n;\n n = n.previousElementSibling;\n }\n return null;\n }\n function ancestorsOf(row) {\n const out = [];\n let p = parentOf(row);\n while (p) {\n out.push(p);\n p = parentOf(p);\n }\n return out;\n }\n const isTreeParent = (row) => opts.tree && childrenOf(row).length > 0;\n\n // ── Group helpers ──\n /** Every tbody row (data + detail) between a group header and the next one. */\n function groupMembers(gh) {\n const out = [];\n let n = gh.nextElementSibling;\n while (n && n.getAttribute(\"data-part\") !== \"group-header\") {\n const p = n.getAttribute(\"data-part\");\n if (p === \"tr\" || p === \"detail-row\") out.push(n);\n n = n.nextElementSibling;\n }\n return out;\n }\n\n // ── MutationObserver (auto-refresh when rows are added/removed externally) ──\n function pauseObserver(fn) {\n observerPaused++;\n try {\n fn();\n } finally {\n observer?.takeRecords();\n observerPaused--;\n }\n }\n function queueRefresh() {\n if (refreshQueued) return;\n refreshQueued = true;\n const raf = typeof requestAnimationFrame === \"function\" ? requestAnimationFrame : (f) => setTimeout(f, 0);\n raf(() => {\n refreshQueued = false;\n if (root._faqirTable) refresh();\n });\n }\n\n // ── Sorting ──\n function compareCells(a, b, type) {\n const ra = a ? sortRaw(a) : \"\";\n const rb = b ? sortRaw(b) : \"\";\n if (ra === rb) return 0;\n if (!ra) return 1; // empties last (flipped by direction like everything else)\n if (!rb) return -1;\n if (type === \"date\") {\n const na = parseDateValue(ra);\n const nb = parseDateValue(rb);\n if (!isNaN(na) && !isNaN(nb)) return na - nb;\n }\n const na = parseNumeric(ra);\n const nb = parseNumeric(rb);\n if (!isNaN(na) && !isNaN(nb) && type !== \"text\") return na - nb;\n return collator.compare(ra, rb);\n }\n\n function rememberOrder() {\n for (const r of bodyRows()) if (!originalIndex.has(r)) originalIndex.set(r, originSeq++);\n }\n\n function rowComparator() {\n if (!sorts.length) {\n return (a, b) => (originalIndex.get(a) || 0) - (originalIndex.get(b) || 0);\n }\n const specs = sorts.map((s) => ({ ...s, type: columnType(s.index) }));\n return (a, b) => {\n for (const s of specs) {\n const v = compareCells(cellsOf(a)[s.index], cellsOf(b)[s.index], s.type);\n if (v) return s.dir === \"ascending\" ? v : -v;\n }\n return (originalIndex.get(a) || 0) - (originalIndex.get(b) || 0);\n };\n }\n\n function buildForest(rows) {\n const forest = [];\n const stack = [];\n for (const row of rows) {\n const node = { row, children: [] };\n const level = levelOf(row);\n while (stack.length && levelOf(stack[stack.length - 1].row) >= level) stack.pop();\n (stack.length ? stack[stack.length - 1].children : forest).push(node);\n stack.push(node);\n }\n return forest;\n }\n function sortForest(forest, cmp) {\n forest.sort((a, b) => cmp(a.row, b.row));\n for (const n of forest) sortForest(n.children, cmp);\n }\n function flattenForest(forest, out) {\n for (const n of forest) {\n out.push(n.row);\n flattenForest(n.children, out);\n }\n return out;\n }\n\n /** tbody structure as segments delimited by group headers. */\n function segments() {\n const segs = [];\n let cur = { header: null, rows: [] };\n for (const child of tbody ? [...tbody.children] : []) {\n const part = child.getAttribute(\"data-part\");\n if (part === \"group-header\") {\n if (cur.header || cur.rows.length) segs.push(cur);\n cur = { header: child, rows: [] };\n } else if (part === \"tr\") {\n cur.rows.push(child);\n }\n }\n if (cur.header || cur.rows.length) segs.push(cur);\n return segs;\n }\n\n function updateSortIndicators() {\n for (const th of sortableHeaders()) {\n th.setAttribute(\"aria-sort\", \"none\");\n th.removeAttribute(\"data-sort-order\");\n }\n sorts.forEach((s, i) => {\n const th = headerCells()[s.index];\n if (th?.hasAttribute(\"data-sortable\")) {\n th.setAttribute(\"aria-sort\", s.dir);\n if (sorts.length > 1) th.setAttribute(\"data-sort-order\", String(i + 1));\n }\n });\n }\n\n function applySorts() {\n if (!tbody || bodyRows().length === 0) return;\n if (!sorts.length && !hasSorted) return; // nothing to do yet\n hasSorted = true;\n rememberOrder();\n updateSortIndicators();\n\n const details = new Map();\n for (const r of bodyRows()) details.set(r, detailOf(r));\n const cmp = rowComparator();\n\n const order = [];\n for (const seg of segments()) {\n if (seg.header) order.push(seg.header);\n let rows;\n if (opts.tree) {\n const forest = buildForest(seg.rows);\n sortForest(forest, cmp);\n rows = flattenForest(forest, []);\n } else {\n rows = seg.rows.slice().sort(cmp);\n }\n for (const r of rows) {\n order.push(r);\n const d = details.get(r);\n if (d) order.push(d);\n }\n }\n const emptyRow = rowsIn(tbody, \"empty\")[0];\n pauseObserver(() => {\n for (const node of order) tbody.appendChild(node);\n if (emptyRow) tbody.appendChild(emptyRow);\n });\n refreshStripes();\n }\n\n function sortChanged() {\n applySorts();\n emit(\"sort\", { sorts: sorts.map((s) => ({ column: s.index, direction: s.dir })) });\n scheduleStateSave();\n }\n\n /** Legacy API: sort one column with an explicit direction. */\n function sort(columnIndex, direction) {\n if (!tbody || bodyRows().length === 0) return;\n sorts = [{ index: columnIndex, dir: direction }];\n sortChanged();\n }\n\n /** Multi-sort API: sortBy([{ column, direction }...]). */\n function sortBy(specs) {\n if (!tbody || bodyRows().length === 0) return;\n sorts = (specs || [])\n .map((s) => ({\n index: s.column != null ? s.column : s.index,\n dir: s.direction || s.dir || \"ascending\",\n }))\n .filter((s) => Number.isInteger(s.index) && s.index >= 0 && s.index < columnCount());\n sortChanged();\n }\n\n function clearSort() {\n if (!sorts.length) return;\n sorts = [];\n sortChanged();\n }\n\n function handleSortRequest(idx, additive) {\n const existing = sorts.find((s) => s.index === idx);\n let dir = \"ascending\";\n if (existing) {\n if (existing.dir === \"ascending\") dir = \"descending\";\n else dir = opts.sortCycle === \"tristate\" ? null : \"ascending\";\n }\n if (additive && opts.multiSort) {\n if (dir === null) sorts = sorts.filter((s) => s.index !== idx);\n else if (existing) existing.dir = dir;\n else sorts.push({ index: idx, dir });\n } else {\n sorts = dir === null ? [] : [{ index: idx, dir }];\n }\n sortChanged();\n }\n\n // ── Selection ──\n function setRowSelected(row, selected) {\n toggleAttr(row, \"data-selected\", selected);\n const checkbox = row.querySelector(\"[data-part='checkbox']\");\n if (checkbox) checkbox.checked = !!selected;\n }\n\n function selectRow(index) {\n const rows = bodyRows();\n if (index < 0 || index >= rows.length) return;\n const row = rows[index];\n setRowSelected(row, !row.hasAttribute(\"data-selected\"));\n lastSelectedIndex = index;\n selectionChanged();\n }\n\n function selectAll() {\n const filtered = !!globalFilter || columnFilters.size > 0;\n for (const row of bodyRows()) {\n if (filtered && row.hasAttribute(\"data-filtered\")) continue;\n setRowSelected(row, true);\n }\n selectionChanged();\n }\n\n function deselectAll() {\n for (const row of bodyRows()) setRowSelected(row, false);\n lastSelectedIndex = -1;\n selectionChanged();\n }\n\n function getSelected() {\n return bodyRows()\n .map((row, index) => ({ row, index }))\n .filter(({ row }) => row.hasAttribute(\"data-selected\"))\n .map(({ index }) => index);\n }\n\n function selectRange(fromIndex, toIndex) {\n const start = Math.min(fromIndex, toIndex);\n const end = Math.max(fromIndex, toIndex);\n const rows = bodyRows();\n for (let i = start; i <= end; i++) {\n if (i >= 0 && i < rows.length && isRowVisible(rows[i])) setRowSelected(rows[i], true);\n }\n }\n\n function selectionChanged() {\n updateHeaderCheckbox();\n emit(\"selection-change\", { selected: getSelected() });\n }\n\n function updateHeaderCheckbox() {\n if (!headerCheckbox) return;\n const rows = visibleBodyRows();\n const n = rows.filter((r) => r.hasAttribute(\"data-selected\")).length;\n headerCheckbox.checked = n > 0 && n === rows.length;\n headerCheckbox.indeterminate = n > 0 && n < rows.length;\n }\n\n // ── Filtering ──\n function matchQuery(cell, query, type) {\n const q = String(query).trim();\n if (!q) return true;\n if (!cell) return false;\n if (isNumericType(type) || type === \"date\") {\n const val = type === \"date\" ? parseDateValue(cellRaw(cell)) : parseNumeric(cellRaw(cell));\n const parseQ = (s) => (type === \"date\" ? parseDateValue(s) : parseNumeric(s));\n const range = q.match(/^(.+?)\\.\\.(.+)$/);\n if (range) {\n const a = parseQ(range[1]);\n const b = parseQ(range[2]);\n return !isNaN(val) && !isNaN(a) && !isNaN(b) && val >= a && val <= b;\n }\n const op = q.match(/^(>=|<=|!=|=|>|<)\\s*(.+)$/);\n if (op) {\n const b = parseQ(op[2]);\n if (isNaN(b) || isNaN(val)) return false;\n switch (op[1]) {\n case \">\": return val > b;\n case \">=\": return val >= b;\n case \"<\": return val < b;\n case \"<=\": return val <= b;\n case \"=\": return val === b;\n case \"!=\": return val !== b;\n }\n }\n }\n return (cell.textContent || \"\").toLowerCase().includes(q.toLowerCase());\n }\n\n function rowMatches(row) {\n const cells = cellsOf(row);\n if (globalFilter) {\n const hay = cells\n .map((c) => (c.textContent || \"\") + \" \" + (c.getAttribute(\"data-value\") || \"\"))\n .join(\" \")\n .toLowerCase();\n if (!hay.includes(globalFilter.toLowerCase())) return false;\n }\n for (const [idx, f] of columnFilters) {\n const cell = cells[idx];\n if (typeof f === \"function\") {\n if (!f(cell ? cellRaw(cell) : \"\", cell, row)) return false;\n } else if (!matchQuery(cell, f, columnType(idx))) {\n return false;\n }\n }\n return true;\n }\n\n function updateEmptyRow(visibleCount) {\n const emptyRow = tbody ? rowsIn(tbody, \"empty\")[0] : null;\n if (emptyRow) toggleAttr(emptyRow, \"hidden\", visibleCount > 0);\n }\n\n function applyFilters() {\n if (!tbody) return;\n const rows = bodyRows();\n const active = !!globalFilter || columnFilters.size > 0;\n const matched = new Set();\n if (active) {\n for (const r of rows) if (rowMatches(r)) matched.add(r);\n if (opts.tree) {\n // A matching row keeps its ancestor path visible.\n for (const r of [...matched]) for (const a of ancestorsOf(r)) matched.add(a);\n }\n }\n let visible = 0;\n for (const r of rows) {\n const show = !active || matched.has(r);\n toggleAttr(r, \"data-filtered\", !show);\n const d = detailOf(r);\n if (d) toggleAttr(d, \"data-filtered\", !show);\n if (show && isRowVisible(r)) visible++;\n }\n for (const gh of groupHeaders()) {\n const any = groupMembers(gh).some(\n (m) => m.getAttribute(\"data-part\") === \"tr\" && !m.hasAttribute(\"data-filtered\")\n );\n toggleAttr(gh, \"data-filtered\", active && !any);\n }\n updateEmptyRow(visible);\n refreshStripes();\n updateHeaderCheckbox();\n computeAggregates();\n setupNavigability();\n emit(\"filter\", { query: globalFilter, visible, total: rows.length });\n scheduleStateSave();\n }\n\n function setFilter(query) {\n globalFilter = String(query == null ? \"\" : query);\n applyFilters();\n }\n function setColumnFilter(colIndex, query) {\n if (query == null || query === \"\") columnFilters.delete(colIndex);\n else columnFilters.set(colIndex, query);\n applyFilters();\n }\n function clearFilters() {\n globalFilter = \"\";\n columnFilters.clear();\n syncFilterInputs();\n applyFilters();\n }\n function syncFilterInputs() {\n const g = [...root.querySelectorAll(\"[data-part='filter']\")].find(mine);\n if (g && g.value !== globalFilter) g.value = globalFilter;\n const fr = filterRowEl();\n if (!fr) return;\n cellsOf(fr).forEach((cell, i) => {\n const input = cell.querySelector(\"[data-part='filter-input']\");\n if (!input) return;\n const val = columnFilters.get(i);\n input.value = typeof val === \"string\" ? val : \"\";\n });\n }\n\n // ── Collapse / expand (groups, tree, detail rows) ──\n function toggleGroup(ghOrIndex, force) {\n const gh = typeof ghOrIndex === \"number\" ? groupHeaders()[ghOrIndex] : ghOrIndex;\n if (!gh) return;\n const collapsed = gh.getAttribute(\"data-state\") === \"collapsed\";\n const expand = force !== undefined ? !!force : collapsed;\n gh.setAttribute(\"data-state\", expand ? \"expanded\" : \"collapsed\");\n gh.querySelector(\"[data-part='expander']\")?.setAttribute(\"aria-expanded\", String(expand));\n for (const m of groupMembers(gh)) toggleAttr(m, \"data-collapsed\", !expand);\n refreshStripes();\n updateHeaderCheckbox();\n setupNavigability();\n emit(\"group-toggle\", { group: gh, expanded: expand });\n }\n\n function revealChildren(row) {\n for (const c of childrenOf(row)) {\n c.removeAttribute(\"data-collapsed\");\n detailOf(c)?.removeAttribute(\"data-collapsed\");\n if (isTreeParent(c) && c.getAttribute(\"aria-expanded\") !== \"false\") revealChildren(c);\n }\n }\n\n function toggleRow(rowOrIndex, force) {\n const row = typeof rowOrIndex === \"number\" ? bodyRows()[rowOrIndex] : rowOrIndex;\n if (!row || !isTreeParent(row)) return;\n const expanded = row.getAttribute(\"aria-expanded\") !== \"false\";\n const expand = force !== undefined ? !!force : !expanded;\n row.setAttribute(\"aria-expanded\", String(expand));\n row.querySelector(\"[data-part='expander']\")?.setAttribute(\"aria-expanded\", String(expand));\n if (expand) {\n revealChildren(row);\n } else {\n for (const d of subtreeRows(row)) {\n d.setAttribute(\"data-collapsed\", \"\");\n detailOf(d)?.setAttribute(\"data-collapsed\", \"\");\n }\n }\n refreshStripes();\n updateHeaderCheckbox();\n setupNavigability();\n emit(\"tree-toggle\", { row, expanded: expand });\n }\n\n /** Master/detail: show or hide a row's [data-part='detail-row'] via the hidden attribute. */\n function toggleDetail(rowOrIndex, force) {\n const row = typeof rowOrIndex === \"number\" ? bodyRows()[rowOrIndex] : rowOrIndex;\n const detail = row && detailOf(row);\n if (!detail) return;\n const expand = force !== undefined ? !!force : detail.hasAttribute(\"hidden\");\n toggleAttr(detail, \"hidden\", !expand);\n row.querySelector(\"[data-part='row-toggle']\")?.setAttribute(\"aria-expanded\", String(expand));\n emit(\"row-expand\", { row, detail, expanded: expand });\n }\n\n function setAllExpanded(expand) {\n mutedRun(() => {\n for (const gh of groupHeaders()) toggleGroup(gh, expand);\n if (opts.tree) for (const r of bodyRows()) if (isTreeParent(r)) toggleRow(r, expand);\n });\n refreshStripes();\n }\n const expandAll = () => setAllExpanded(true);\n const collapseAll = () => setAllExpanded(false);\n\n // ── Aggregates (tfoot, group headers, tree parents) ──\n function writeAggregate(cell, rows, ownIndex) {\n const fn = cell.getAttribute(\"data-aggregate\");\n const col = cell.hasAttribute(\"data-col\")\n ? parseInt(cell.getAttribute(\"data-col\"), 10)\n : ownIndex != null\n ? ownIndex\n : cellsOf(cell.parentElement).indexOf(cell);\n const values = [];\n for (const r of rows) {\n const c = cellsOf(r)[col];\n if (!c) continue;\n const n = parseNumeric(cellRaw(c));\n if (!isNaN(n)) values.push(n);\n }\n let out = null;\n switch (fn) {\n case \"count\": out = rows.length; break;\n case \"sum\": out = values.reduce((a, b) => a + b, 0); break;\n case \"avg\": out = values.length ? values.reduce((a, b) => a + b, 0) / values.length : null; break;\n case \"min\": out = values.length ? Math.min(...values) : null; break;\n case \"max\": out = values.length ? Math.max(...values) : null; break;\n default: return;\n }\n if (out == null) {\n cell.textContent = \"\";\n cell.removeAttribute(\"data-value\");\n return;\n }\n cell.setAttribute(\"data-value\", String(out));\n const fmt =\n fn === \"count\"\n ? cell.getAttribute(\"data-format\")\n : cellFormatOf(cell, col) || \"number\";\n cell.textContent = fmt ? formatValue(out, fmt) : String(out);\n applyNegativeFlag(cell);\n }\n\n function computeAggregates() {\n const visRows = bodyRows().filter((r) => !r.hasAttribute(\"data-filtered\"));\n for (const row of rowsIn(tfoot)) {\n for (const cell of cellsOf(row)) {\n if (cell.hasAttribute(\"data-aggregate\")) writeAggregate(cell, visRows);\n }\n }\n for (const gh of groupHeaders()) {\n const members = groupMembers(gh).filter(\n (r) => r.getAttribute(\"data-part\") === \"tr\" && !r.hasAttribute(\"data-filtered\")\n );\n for (const cell of cellsOf(gh)) {\n if (cell.hasAttribute(\"data-aggregate\")) writeAggregate(cell, members);\n }\n }\n if (opts.tree) {\n for (const row of bodyRows()) {\n const cells = cellsOf(row);\n const aggCells = cells.filter((c) => c.hasAttribute(\"data-aggregate\"));\n if (!aggCells.length) continue;\n const desc = subtreeRows(row).filter((r) => !r.hasAttribute(\"data-filtered\"));\n if (!desc.length) continue; // leaf with a stray data-aggregate: leave authored value\n for (const cell of aggCells) writeAggregate(cell, desc, cells.indexOf(cell));\n }\n }\n }\n\n // ── Striping (JS-managed so hidden rows never break the pattern) ──\n function refreshStripes() {\n if (!(root.getAttribute(\"data-variant\") || \"\").includes(\"striped\")) return;\n let i = 0;\n for (const r of bodyRows()) {\n if (!isRowVisible(r)) {\n r.removeAttribute(\"data-stripe\");\n continue;\n }\n r.setAttribute(\"data-stripe\", i % 2 ? \"even\" : \"odd\");\n i++;\n }\n }\n\n // ── Inline editing ──\n function isCellEditable(cell) {\n if (!cell || cell.getAttribute(\"data-part\") !== \"td\") return false;\n if (cell.hasAttribute(\"data-readonly\")) return false;\n if (cell.hasAttribute(\"data-editable\")) return true;\n if (!opts.editable) return false;\n const row = cell.parentElement;\n if (!row || row.getAttribute(\"data-part\") !== \"tr\" || !tbody?.contains(row)) return false;\n if (cell.querySelector(\"input,button,select,a,textarea\")) return false;\n const idx = cellsOf(row).indexOf(cell);\n const th = headerCells()[idx];\n if (th?.hasAttribute(\"data-readonly\")) return false;\n const marked = headerCells().filter((h) => h.hasAttribute(\"data-editable\"));\n return marked.length ? !!th?.hasAttribute(\"data-editable\") : true;\n }\n\n function cellFormatOf(cell, colIndex) {\n return cell.getAttribute(\"data-format\") || headerCells()[colIndex]?.getAttribute(\"data-format\") || \"\";\n }\n\n function startEdit(a, b) {\n let cell = null;\n if (a instanceof Element) cell = a;\n else {\n const row = bodyRows()[a];\n if (row) cell = cellsOf(row)[b] || null;\n }\n if (!cell || !isCellEditable(cell)) return false;\n if (editing) {\n if (editing.cell === cell) return true;\n if (!commitEdit()) cancelEdit();\n }\n const row = cell.parentElement;\n const colIndex = cellsOf(row).indexOf(cell);\n const type = columnType(colIndex);\n const oldText = (cell.textContent || \"\").trim();\n const oldValue = cell.getAttribute(\"data-value\");\n const input = document.createElement(\"input\");\n input.type = \"text\";\n input.setAttribute(\"data-part\", \"cell-input\");\n if (isNumericType(type)) input.inputMode = \"decimal\";\n input.setAttribute(\"aria-label\", \"Edit \" + (headerText(colIndex) || \"cell\"));\n input.value = oldValue != null ? oldValue : oldText;\n editing = { cell, row, input, oldText, oldValue, colIndex, type };\n cell.setAttribute(\"data-editing\", \"\");\n cell.textContent = \"\";\n cell.appendChild(input);\n input.addEventListener(\"keydown\", onEditorKeydown);\n input.addEventListener(\"blur\", onEditorBlur);\n input.focus();\n try {\n input.select();\n } catch {\n /* select() unsupported in some environments */\n }\n emit(\"edit-start\", { cell, row, rowIndex: bodyRows().indexOf(row), colIndex, value: input.value });\n return true;\n }\n\n function finishEditor(newText, newValue) {\n const { cell, oldValue } = editing;\n const numeric = isNumericType(editing.type) || isNumericType(cellFormatOf(cell, editing.colIndex));\n editing = null;\n cell.removeAttribute(\"data-editing\");\n cell.textContent = newText;\n if (newValue != null && (oldValue != null || numeric)) cell.setAttribute(\"data-value\", newValue);\n applyNegativeFlag(cell);\n }\n\n function commitEdit(focusBack) {\n if (!editing) return false;\n const { cell, row, input, oldText, oldValue, colIndex } = editing;\n const fmt = cellFormatOf(cell, colIndex);\n const numeric = isNumericType(editing.type) || isNumericType(fmt);\n const rawInput = input.value;\n let newValue = null;\n let newText = rawInput.trim();\n if (numeric && newText !== \"\") {\n const n = parseNumeric(rawInput);\n if (isNaN(n)) {\n input.setAttribute(\"data-invalid\", \"\");\n input.focus();\n return false;\n }\n newValue = String(n);\n newText = isNumericType(fmt) ? formatValue(n, fmt) : newText;\n } else if (numeric) {\n newValue = \"\";\n }\n const before = oldValue != null ? oldValue : oldText;\n const after = newValue != null ? newValue : newText;\n finishEditor(newText, newValue);\n computeAggregates();\n if (String(before) !== String(after)) {\n emit(\"cell-edit\", {\n cell,\n row,\n rowIndex: bodyRows().indexOf(row),\n colIndex,\n oldValue: before,\n value: after,\n text: newText,\n });\n }\n if (focusBack && opts.navigable) focusCell(cell);\n return true;\n }\n\n function cancelEdit(focusBack) {\n if (!editing) return false;\n const { cell, row, oldText, oldValue, colIndex } = editing;\n finishEditor(oldText, oldValue);\n formatCell(cell);\n emit(\"edit-cancel\", { cell, row, rowIndex: bodyRows().indexOf(row), colIndex });\n if (focusBack && opts.navigable) focusCell(cell);\n return true;\n }\n\n function nextEditableCell(cell, dir) {\n const row = cell.parentElement;\n const rows = visibleBodyRows();\n let r = rows.indexOf(row);\n if (r < 0) return null;\n let c = cellsOf(row).indexOf(cell) + dir;\n while (r >= 0 && r < rows.length) {\n const cells = cellsOf(rows[r]);\n while (c >= 0 && c < cells.length) {\n if (isCellEditable(cells[c])) return cells[c];\n c += dir;\n }\n r += dir;\n if (r >= 0 && r < rows.length) c = dir > 0 ? 0 : cellsOf(rows[r]).length - 1;\n }\n return null;\n }\n\n function onEditorKeydown(e) {\n if (!editing) return;\n e.stopPropagation(); // keep grid navigation away from typing\n if (e.key === \"Enter\") {\n e.preventDefault();\n commitEdit(true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n cancelEdit(true);\n } else if (e.key === \"Tab\") {\n e.preventDefault();\n const from = editing.cell;\n if (commitEdit()) {\n const next = nextEditableCell(from, e.shiftKey ? -1 : 1);\n if (next) startEdit(next);\n }\n } else {\n e.target.removeAttribute(\"data-invalid\");\n }\n }\n function onEditorBlur(e) {\n if (!editing || editing.input !== e.target) return;\n if (!commitEdit()) cancelEdit();\n }\n\n // ── Column operations ──\n const remapIndex = (i, from, to) =>\n i === from ? to : from < to ? (i > from && i <= to ? i - 1 : i) : i >= to && i < from ? i + 1 : i;\n\n function moveColumn(from, to) {\n const n = columnCount();\n if (from === to || from < 0 || to < 0 || from >= n || to >= n) return;\n pauseObserver(() => {\n for (const row of fullWidthRows()) {\n const cells = cellsOf(row);\n const cell = cells[from];\n const target = cells[to];\n if (!cell || !target) continue;\n if (from < to) target.after(cell);\n else target.before(cell);\n }\n });\n sorts = sorts.map((s) => ({ ...s, index: remapIndex(s.index, from, to) }));\n const remapped = new Map();\n for (const [i, f] of columnFilters) remapped.set(remapIndex(i, from, to), f);\n columnFilters.clear();\n for (const [i, f] of remapped) columnFilters.set(i, f);\n colTypeCache.clear();\n refreshPins();\n emit(\"col-reorder\", { from, to });\n scheduleStateSave();\n }\n\n function setColumnHidden(i, hidden) {\n const th = headerCells()[i];\n if (!th) return;\n forEachColumnCell(i, (cell) => toggleAttr(cell, \"data-col-hidden\", hidden));\n refreshPins();\n setupNavigability();\n emit(\"col-visibility\", { column: i, hidden: !!hidden });\n scheduleStateSave();\n }\n const hideColumn = (i) => setColumnHidden(i, true);\n const showColumn = (i) => setColumnHidden(i, false);\n function toggleColumn(i, force) {\n const th = headerCells()[i];\n if (!th) return;\n const hidden = th.hasAttribute(\"data-col-hidden\");\n setColumnHidden(i, force !== undefined ? !force : !hidden);\n }\n\n function columnBounds(th) {\n const min = parseFloat(th.getAttribute(\"data-min-width\")) || 40;\n const max = parseFloat(th.getAttribute(\"data-max-width\")) || Infinity;\n return { min, max };\n }\n\n function setColumnWidth(i, width) {\n const th = headerCells()[i];\n if (!th) return;\n const { min, max } = columnBounds(th);\n const w = Math.max(min, Math.min(max, width));\n th.style.width = w + \"px\";\n root.setAttribute(\"data-resized\", \"\");\n refreshPins();\n emit(\"col-resize\", { column: i, width: w });\n scheduleStateSave();\n }\n\n // ── Pinned (sticky) columns ──\n const widthOf = (th) => th.offsetWidth || parseFloat(th.style.width) || 0;\n\n function refreshPins() {\n const hcs = headerCells();\n const startPins = [];\n const endPins = [];\n hcs.forEach((th, i) => {\n if (th.hasAttribute(\"data-col-hidden\")) return;\n const p = th.getAttribute(\"data-pin\");\n if (p === \"start\") startPins.push(i);\n else if (p === \"end\") endPins.push(i);\n });\n if (!startPins.length && !endPins.length) return;\n const setPin = (i, side, offset, isEdge) => {\n forEachColumnCell(i, (cell) => {\n cell.setAttribute(\"data-pin\", side);\n cell.style.setProperty(\"--table-pin-offset\", offset + \"px\");\n toggleAttr(cell, \"data-pin-edge\", isEdge);\n });\n };\n let acc = 0;\n startPins.forEach((i, k) => {\n setPin(i, \"start\", acc, k === startPins.length - 1);\n acc += widthOf(hcs[i]);\n });\n acc = 0;\n [...endPins].reverse().forEach((i, k) => {\n setPin(i, \"end\", acc, k === endPins.length - 1);\n acc += widthOf(hcs[i]);\n });\n }\n\n // ── Row moving (API + drag & drop) ──\n /** The DOM block a data row drags with: the row, its detail row, and (tree) its subtree. */\n function rowBlock(row) {\n const block = [row];\n const d = detailOf(row);\n if (d) block.push(d);\n if (opts.tree) {\n for (const sub of subtreeRows(row)) {\n block.push(sub);\n const sd = detailOf(sub);\n if (sd) block.push(sd);\n }\n }\n return block;\n }\n\n function performRowMove(row, targetRow, pos) {\n if (!row || !targetRow || row === targetRow) return false;\n const block = rowBlock(row);\n if (block.includes(targetRow)) return false;\n if (opts.tree && parentOf(targetRow) !== parentOf(row)) return false; // siblings only\n const anchor =\n pos === \"after\" ? rowBlock(targetRow)[rowBlock(targetRow).length - 1].nextElementSibling : targetRow;\n pauseObserver(() => {\n for (const node of block) tbody.insertBefore(node, anchor);\n });\n refreshStripes();\n computeAggregates();\n return true;\n }\n\n function moveRow(from, to) {\n const rows = bodyRows();\n if (from === to || from < 0 || to < 0 || from >= rows.length || to >= rows.length) return false;\n const moved = performRowMove(rows[from], rows[to], from < to ? \"after\" : \"before\");\n if (moved) emit(\"row-reorder\", { from, to, row: rows[from] });\n return moved;\n }\n\n // ── Drag & drop (rows, columns, resize) — pointer-based ──\n function clearDropMarkers() {\n for (const el of root.querySelectorAll(\"[data-drop-target]\")) {\n el.removeAttribute(\"data-drop-target\");\n el.removeAttribute(\"data-drop-pos\");\n }\n }\n\n function elementAt(e) {\n try {\n return document.elementFromPoint(e.clientX, e.clientY);\n } catch {\n return null; // elementFromPoint missing or throwing (headless)\n }\n }\n\n function resolveRowAt(e) {\n let row = elementAt(e)?.closest?.(\"[data-part='tr']\");\n if (!row) row = e.target?.closest?.(\"[data-part='tr']\");\n return row && tbody?.contains(row) ? row : null;\n }\n\n /** \"before\"/\"after\" the pointer's half of el: vertical for rows, horizontal (RTL-aware) for columns. */\n function dropPos(e, el, horizontal) {\n const rect = el.getBoundingClientRect?.();\n const size = rect && (horizontal ? rect.width : rect.height);\n if (!size) return \"after\";\n const before = horizontal ? e.clientX < rect.left + size / 2 !== isRTL : e.clientY < rect.top + size / 2;\n return before ? \"before\" : \"after\";\n }\n\n function bindDocDrag() {\n document.addEventListener(\"pointermove\", onDocPointerMove);\n document.addEventListener(\"pointerup\", onDocPointerUp);\n document.addEventListener(\"keydown\", onDragKeydown, true);\n }\n function unbindDocDrag() {\n document.removeEventListener(\"pointermove\", onDocPointerMove);\n document.removeEventListener(\"pointerup\", onDocPointerUp);\n document.removeEventListener(\"keydown\", onDragKeydown, true);\n }\n cleanups.push(unbindDocDrag);\n\n function cancelDrag() {\n if (!drag) return;\n if (drag.kind === \"row\") drag.row.removeAttribute(\"data-dragging\");\n if (drag.kind === \"col\") drag.th.removeAttribute(\"data-dragging\");\n clearDropMarkers();\n drag = null;\n unbindDocDrag();\n }\n function onDragKeydown(e) {\n if (e.key === \"Escape\") cancelDrag();\n }\n\n function onPointerDown(e) {\n if (e.button !== undefined && e.button !== 0) return;\n const handle = e.target.closest(\"[data-part='drag-handle']\");\n if (handle && opts.reorderable) {\n const row = handle.closest(\"[data-part='tr']\");\n if (row && tbody?.contains(row)) {\n drag = { kind: \"row\", row, startY: e.clientY || 0, active: false };\n bindDocDrag();\n e.preventDefault();\n }\n return;\n }\n const rh = e.target.closest(\"[data-part='resize-handle']\");\n if (rh && opts.resizable) {\n const th = rh.closest(\"[data-part='th']\");\n const idx = headerCells().indexOf(th);\n if (idx >= 0) {\n drag = { kind: \"resize\", th, index: idx, startX: e.clientX || 0, startW: widthOf(th) };\n bindDocDrag();\n e.preventDefault();\n }\n return;\n }\n if (opts.colReorderable) {\n const th = e.target.closest(\"[data-part='th']\");\n if (\n th &&\n headerRowEl()?.contains(th) &&\n !e.target.closest(\"input,button,select,textarea,[data-part='resize-handle']\")\n ) {\n drag = { kind: \"col\", th, startX: e.clientX || 0, active: false };\n bindDocDrag();\n // no preventDefault: a motionless press must still become a sort click\n }\n }\n }\n\n function onDocPointerMove(e) {\n if (!drag) return;\n if (drag.kind === \"resize\") {\n const dx = ((e.clientX || 0) - drag.startX) * (isRTL ? -1 : 1);\n const { min, max } = columnBounds(drag.th);\n const w = Math.max(min, Math.min(max, drag.startW + dx));\n drag.th.style.width = w + \"px\";\n drag.width = w;\n root.setAttribute(\"data-resized\", \"\");\n return;\n }\n if (drag.kind === \"row\") {\n if (!drag.active && Math.abs((e.clientY || 0) - drag.startY) > 3) {\n drag.active = true;\n drag.row.setAttribute(\"data-dragging\", \"\");\n }\n if (!drag.active) return;\n clearDropMarkers();\n const target = resolveRowAt(e);\n if (!target || target === drag.row || rowBlock(drag.row).includes(target)) return;\n if (opts.tree && parentOf(target) !== parentOf(drag.row)) return; // siblings only\n target.setAttribute(\"data-drop-target\", \"\");\n target.setAttribute(\"data-drop-pos\", dropPos(e, target));\n return;\n }\n if (drag.kind === \"col\") {\n if (!drag.active && Math.abs((e.clientX || 0) - drag.startX) > 4) {\n drag.active = true;\n drag.th.setAttribute(\"data-dragging\", \"\");\n }\n if (!drag.active) return;\n clearDropMarkers();\n let th = elementAt(e)?.closest?.(\"[data-part='th']\");\n if (!th) th = e.target?.closest?.(\"[data-part='th']\");\n if (!th || th === drag.th || !headerRowEl()?.contains(th)) return;\n th.setAttribute(\"data-drop-target\", \"\");\n th.setAttribute(\"data-drop-pos\", dropPos(e, th, true));\n }\n }\n\n function onDocPointerUp() {\n if (!drag) return;\n const d = drag;\n drag = null;\n unbindDocDrag();\n if (d.kind === \"resize\") {\n if (d.width != null) {\n refreshPins();\n emit(\"col-resize\", { column: d.index, width: d.width });\n scheduleStateSave();\n }\n return;\n }\n if (d.kind === \"row\") {\n const target = root.querySelector(\"[data-part='tr'][data-drop-target]\");\n d.row.removeAttribute(\"data-dragging\");\n if (d.active) suppressClickUntil = Date.now() + 100;\n if (target) {\n const pos = target.getAttribute(\"data-drop-pos\") || \"after\";\n const rows = bodyRows();\n const from = rows.indexOf(d.row);\n clearDropMarkers();\n if (performRowMove(d.row, target, pos)) {\n emit(\"row-reorder\", { from, to: bodyRows().indexOf(d.row), row: d.row });\n }\n }\n clearDropMarkers();\n return;\n }\n if (d.kind === \"col\") {\n const target = thead?.querySelector(\"[data-part='th'][data-drop-target]\");\n d.th.removeAttribute(\"data-dragging\");\n if (d.active) suppressClickUntil = Date.now() + 100;\n if (target) {\n const pos = target.getAttribute(\"data-drop-pos\") || \"after\";\n const hcs = headerCells();\n const from = hcs.indexOf(d.th);\n let to = hcs.indexOf(target);\n if (pos === \"after\" && from > to) to += 1;\n if (pos === \"before\" && from < to) to -= 1;\n clearDropMarkers();\n moveColumn(from, to);\n }\n clearDropMarkers();\n }\n }\n\n // ── CSV export / data extraction ──\n function csvColumns(includeHidden) {\n const cols = [];\n headerCells().forEach((th, i) => {\n if (!includeHidden && th.hasAttribute(\"data-col-hidden\")) return;\n if (th.hasAttribute(\"data-csv-skip\")) return;\n if (th.querySelector(\"[data-part='checkbox']\")) return;\n cols.push(i);\n });\n return cols;\n }\n\n function exportCsv(o = {}) {\n const all = o.all === true;\n const sep = o.separator || \",\";\n const cols = csvColumns(all);\n const esc = (s) => {\n s = String(s == null ? \"\" : s);\n return /[\",;\\n]/.test(s) || s.includes(sep) ? '\"' + s.replace(/\"/g, '\"\"') + '\"' : s;\n };\n const lines = [cols.map((i) => esc(headerText(i))).join(sep)];\n for (const row of bodyRows()) {\n if (!all && row.hasAttribute(\"data-filtered\")) continue;\n const cells = cellsOf(row);\n lines.push(\n cols\n .map((i) => {\n const c = cells[i];\n return esc(c ? cellRaw(c) : \"\");\n })\n .join(sep)\n );\n }\n const csv = lines.join(\"\\n\");\n if (o.filename && typeof Blob !== \"undefined\" && typeof URL !== \"undefined\" && URL.createObjectURL) {\n try {\n const blob = new Blob([\"\\ufeff\" + csv], { type: \"text/csv;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = o.filename;\n a.click();\n URL.revokeObjectURL(url);\n } catch {\n /* download unavailable (headless) — the string is still returned */\n }\n }\n return csv;\n }\n\n function rowData(row) {\n const cells = cellsOf(row);\n const out = {};\n headerCells().forEach((th, i) => {\n if (th.querySelector(\"[data-part='checkbox']\")) return;\n const key = th.getAttribute(\"data-key\") || headerText(i) || \"col\" + i;\n const c = cells[i];\n out[key] = c ? cellRaw(c) : \"\";\n });\n if (row.hasAttribute(\"data-row-id\")) out._id = row.getAttribute(\"data-row-id\");\n return out;\n }\n const getData = (o = {}) =>\n bodyRows()\n .filter((r) => o.all === true || !r.hasAttribute(\"data-filtered\"))\n .map(rowData);\n const getSelectedData = () => bodyRows().filter((r) => r.hasAttribute(\"data-selected\")).map(rowData);\n\n // ── State persistence ──\n function getState() {\n return {\n sorts: sorts.map((s) => ({ ...s })),\n filter: globalFilter,\n columnFilters: [...columnFilters].filter(([, v]) => typeof v === \"string\"),\n widths: headerCells().map((th) => th.style.width || null),\n hidden: headerCells().map((th) => th.hasAttribute(\"data-col-hidden\")),\n };\n }\n\n function setState(state) {\n if (!state || typeof state !== \"object\") return;\n mutedRun(() => {\n if (Array.isArray(state.widths)) {\n state.widths.forEach((w, i) => {\n if (w) setColumnWidth(i, parseFloat(w));\n });\n }\n if (Array.isArray(state.hidden)) {\n state.hidden.forEach((h, i) => setColumnHidden(i, !!h));\n }\n let filterDirty = false;\n if (Array.isArray(state.columnFilters)) {\n columnFilters.clear();\n for (const [i, v] of state.columnFilters) {\n if (typeof v === \"string\" && v) columnFilters.set(+i, v);\n }\n filterDirty = true;\n }\n if (typeof state.filter === \"string\") {\n globalFilter = state.filter;\n filterDirty = true;\n }\n if (filterDirty) {\n syncFilterInputs();\n applyFilters();\n }\n if (Array.isArray(state.sorts) && state.sorts.length) {\n sorts = state.sorts\n .map((s) => ({ index: s.index != null ? s.index : s.column, dir: s.dir || s.direction || \"ascending\" }))\n .filter((s) => Number.isInteger(s.index) && s.index >= 0 && s.index < columnCount());\n applySorts();\n }\n });\n }\n\n let saveTimer = null;\n function scheduleStateSave() {\n if (!opts.persistKey || muted) return;\n clearTimeout(saveTimer);\n saveTimer = later(() => {\n try {\n localStorage.setItem(\"faqir-table:\" + opts.persistKey, JSON.stringify(getState()));\n } catch {\n /* storage unavailable */\n }\n }, 150);\n }\n function restoreState() {\n if (!opts.persistKey) return;\n try {\n const raw = localStorage.getItem(\"faqir-table:\" + opts.persistKey);\n if (raw) setState(JSON.parse(raw));\n } catch {\n /* corrupt state is discarded */\n }\n }\n\n // ── Structural setup (run at init and on refresh) ──\n function mirrorColumnAttrs() {\n const hcs = headerCells();\n const n = hcs.length;\n if (!n) return;\n for (const row of [...bodyRows(), ...rowsIn(tfoot)]) {\n const cells = cellsOf(row);\n if (cells.length !== n) continue;\n hcs.forEach((th, i) => {\n for (const attr of [\"data-align\", \"data-format\", \"data-hide-below\"]) {\n const v = th.getAttribute(attr);\n if (v && !cells[i].hasAttribute(attr)) cells[i].setAttribute(attr, v);\n }\n });\n }\n }\n\n function treeCellOf(row) {\n return (\n cellsOf(row).find(\n (c) => !c.querySelector(\"[data-part='checkbox'],[data-part='drag-handle']\")\n ) || cellsOf(row)[0]\n );\n }\n\n function injectExpander(cell, isParent) {\n let existing = cell.querySelector(\"[data-part='expander']\");\n if (existing) {\n // A leaf placeholder must become a real button when the row gains children (and vice versa).\n const isButton = existing.tagName === \"BUTTON\";\n if (isParent === isButton) return existing;\n existing.remove();\n existing = null;\n }\n const el = document.createElement(isParent ? \"button\" : \"span\");\n if (isParent) el.type = \"button\";\n el.setAttribute(\"data-part\", \"expander\");\n if (isParent) el.setAttribute(\"aria-label\", \"Toggle\");\n else {\n el.setAttribute(\"data-leaf\", \"\");\n el.setAttribute(\"aria-hidden\", \"true\");\n }\n cell.insertBefore(el, cell.firstChild);\n return el;\n }\n\n function setupTree() {\n if (!opts.tree || !tbody) return;\n table?.setAttribute(\"role\", \"treegrid\");\n for (const row of bodyRows()) {\n const level = levelOf(row);\n row.setAttribute(\"aria-level\", String(level + 1));\n const cell = treeCellOf(row);\n if (!cell) continue;\n cell.setAttribute(\"data-tree-cell\", \"\");\n cell.style.setProperty(\"--table-level\", String(level));\n const parent = isTreeParent(row);\n const expander = injectExpander(cell, parent);\n if (parent) {\n if (!row.hasAttribute(\"aria-expanded\")) row.setAttribute(\"aria-expanded\", \"true\");\n expander.setAttribute(\"aria-expanded\", row.getAttribute(\"aria-expanded\"));\n if (row.getAttribute(\"aria-expanded\") === \"false\") {\n for (const d of subtreeRows(row)) {\n d.setAttribute(\"data-collapsed\", \"\");\n detailOf(d)?.setAttribute(\"data-collapsed\", \"\");\n }\n }\n } else {\n row.removeAttribute(\"aria-expanded\");\n }\n }\n }\n\n function setupGroups() {\n if (!opts.groupable || !tbody) return;\n for (const gh of groupHeaders()) {\n const cell = cellsOf(gh)[0];\n if (!cell) continue;\n const expander = injectExpander(cell, true);\n if (!gh.hasAttribute(\"data-state\")) gh.setAttribute(\"data-state\", \"expanded\");\n const expanded = gh.getAttribute(\"data-state\") !== \"collapsed\";\n expander.setAttribute(\"aria-expanded\", String(expanded));\n if (!expanded) for (const m of groupMembers(gh)) m.setAttribute(\"data-collapsed\", \"\");\n }\n }\n\n function setupDetails() {\n if (!tbody) return;\n for (const row of bodyRows()) {\n const toggle = row.querySelector(\"[data-part='row-toggle']\");\n const detail = detailOf(row);\n if (!toggle || !detail) continue;\n if (toggle.getAttribute(\"aria-expanded\") === \"false\") detail.setAttribute(\"hidden\", \"\");\n else toggle.setAttribute(\"aria-expanded\", String(!detail.hasAttribute(\"hidden\")));\n }\n }\n\n function setupLabels() {\n if (opts.responsive !== \"stack\") return;\n const n = columnCount();\n for (const row of [...bodyRows(), ...rowsIn(tfoot)]) {\n const cells = cellsOf(row);\n if (cells.length !== n) continue;\n cells.forEach((cell, i) => {\n if (!cell.hasAttribute(\"data-label\")) cell.setAttribute(\"data-label\", headerText(i));\n });\n }\n }\n\n function injectResizeHandles() {\n if (!opts.resizable) return;\n headerCells().forEach((th) => {\n if (th.hasAttribute(\"data-no-resize\")) return;\n if (th.querySelector(\"[data-part='resize-handle']\")) return;\n const handle = document.createElement(\"span\");\n handle.setAttribute(\"data-part\", \"resize-handle\");\n handle.setAttribute(\"aria-hidden\", \"true\");\n th.appendChild(handle);\n });\n }\n\n // ── Keyboard navigation (roving tabindex grid) ──\n function navMatrix() {\n const rows = [];\n const hr = headerRowEl();\n if (hr) rows.push(hr);\n for (const child of tbody ? [...tbody.children] : []) {\n const p = child.getAttribute(\"data-part\");\n if ((p === \"tr\" || p === \"group-header\") && isRowVisible(child)) rows.push(child);\n }\n for (const r of rowsIn(tfoot)) rows.push(r);\n return rows;\n }\n\n // APG grid: links, buttons and fields inside a navigable grid's cells leave the\n // Tab order (Enter/F2 reaches them, Escape comes back). The table's own controls\n // stay focusable. destroy() puts the original tabindex back.\n const demoted = new WeakMap();\n const cellControls = (cell) =>\n [...cell.querySelectorAll(\"input,select,textarea,button,a[href],[tabindex]\")].filter(\n (el) => mine(el) && !el.closest(\"[data-part='checkbox'],[data-part='drag-handle'],[data-part='expander'],[data-part='row-toggle']\")\n );\n\n // Re-run after anything that can take the Tab stop away (refresh, filter,\n // collapse, column hide): only the Tab stop moves, never focus.\n function setupNavigability() {\n if (opts.navigable) {\n const rows = navMatrix();\n // A stale stop — its row removed, filtered or collapsed, or its column hidden —\n // is dropped so the first visible cell takes over.\n if (activeCell && (!rows.includes(activeCell.parentElement) || activeCell.hasAttribute(\"data-col-hidden\"))) {\n activeCell.setAttribute(\"tabindex\", \"-1\");\n activeCell = null;\n }\n let first = null;\n for (const row of rows) {\n for (const cell of cellsOf(row)) {\n if (!first && !activeCell && !cell.hasAttribute(\"data-col-hidden\")) first = cell;\n cell.setAttribute(\"tabindex\", cell === (activeCell || first) ? \"0\" : \"-1\");\n for (const el of cellControls(cell)) {\n if (!demoted.has(el)) demoted.set(el, el.getAttribute(\"tabindex\"));\n el.setAttribute(\"tabindex\", \"-1\");\n }\n }\n }\n if (!activeCell) activeCell = first;\n } else {\n // Sortable headers must stay keyboard-operable even without grid navigation.\n for (const th of sortableHeaders()) th.setAttribute(\"tabindex\", \"0\");\n }\n }\n\n function focusCell(cell) {\n if (!cell) return;\n if (activeCell && activeCell !== cell) activeCell.setAttribute(\"tabindex\", \"-1\");\n activeCell = cell;\n cell.setAttribute(\"tabindex\", \"0\");\n cell.focus();\n }\n\n function moveFocus(rowDelta, colDelta, edge) {\n const cell = activeCell;\n if (!cell) return;\n const row = cell.parentElement;\n const rows = navMatrix();\n let r = rows.indexOf(row);\n if (r < 0) return;\n let cells = cellsOf(row);\n let c = cells.indexOf(cell);\n if (edge === \"rowStart\") c = 0;\n else if (edge === \"rowEnd\") c = cells.length - 1;\n else if (edge === \"gridStart\") {\n r = 0;\n c = 0;\n } else if (edge === \"gridEnd\") {\n r = rows.length - 1;\n c = cellsOf(rows[r]).length - 1;\n } else {\n r = Math.max(0, Math.min(rows.length - 1, r + rowDelta));\n cells = cellsOf(rows[r]);\n c = Math.max(0, Math.min(cells.length - 1, c + colDelta));\n }\n cells = cellsOf(rows[r]);\n let target = cells[Math.min(c, cells.length - 1)];\n // Skip hidden columns in the direction of travel.\n let guard = cells.length;\n while (target && target.hasAttribute(\"data-col-hidden\") && guard--) {\n const i = cells.indexOf(target) + (colDelta < 0 ? -1 : 1);\n target = cells[i];\n }\n if (target) focusCell(target);\n }\n\n function onFocusIn(e) {\n if (!opts.navigable) return;\n const cell = e.target.closest(\"[data-part='td'],[data-part='th']\");\n if (!cell || cell === activeCell || !root.contains(cell)) return;\n if (e.target !== cell && !demoted.has(e.target)) return; // the table's own control, not the cell\n if (activeCell) activeCell.setAttribute(\"tabindex\", \"-1\");\n activeCell = cell;\n cell.setAttribute(\"tabindex\", \"0\");\n }\n\n // ── Event handlers ──\n function onHeaderClick(e) {\n if (Date.now() < suppressClickUntil) return;\n if (e.target.closest(\"[data-part='resize-handle'],[data-part='checkbox'],[data-part='filter-input'],input,button,select,textarea\")) {\n return;\n }\n const th = e.target.closest(\"[data-part='th'][data-sortable]\");\n if (!th) return;\n const columnIndex = headerCells().indexOf(th);\n if (columnIndex < 0) return;\n handleSortRequest(columnIndex, e.shiftKey);\n }\n\n function onHeaderCheckboxChange() {\n if (headerCheckbox.checked) selectAll();\n else deselectAll();\n }\n\n function onRowCheckboxChange(e) {\n const checkbox = e.target.closest(\"[data-part='checkbox']\");\n if (!checkbox || checkbox === headerCheckbox) return;\n const row = checkbox.closest(\"[data-part='tr']\");\n if (!row || !tbody?.contains(row)) return;\n const rows = bodyRows();\n const index = rows.indexOf(row);\n if (index < 0) return;\n if (e.shiftKey && lastSelectedIndex >= 0) {\n e.preventDefault();\n selectRange(lastSelectedIndex, index);\n selectionChanged();\n return;\n }\n toggleAttr(row, \"data-selected\", checkbox.checked);\n lastSelectedIndex = index;\n selectionChanged();\n }\n\n function onRootClick(e) {\n if (Date.now() < suppressClickUntil) return;\n const expander = e.target.closest(\"[data-part='expander']\");\n if (expander && !expander.hasAttribute(\"data-leaf\") && root.contains(expander)) {\n const gh = expander.closest(\"[data-part='group-header']\");\n if (gh && tbody?.contains(gh)) {\n toggleGroup(gh);\n return;\n }\n const treeRow = expander.closest(\"[data-part='tr']\");\n if (treeRow && tbody?.contains(treeRow)) {\n toggleRow(treeRow);\n return;\n }\n }\n const rowToggle = e.target.closest(\"[data-part='row-toggle']\");\n if (rowToggle && root.contains(rowToggle)) {\n const r = rowToggle.closest(\"[data-part='tr']\");\n if (r && tbody?.contains(r)) toggleDetail(r);\n return;\n }\n if (opts.groupable) {\n const gh = e.target.closest(\"[data-part='group-header']\");\n if (gh && tbody?.contains(gh) && !e.target.closest(\"a,button,input,select,textarea\")) {\n toggleGroup(gh);\n return;\n }\n }\n if (e.target.closest(\"[data-part='checkbox']\")) return;\n const row = e.target.closest(\"[data-part='tr']\");\n if (!row || !tbody?.contains(row)) return;\n if (e.target.closest(\"a,button,input,select,textarea\") || editing) return;\n const rows = bodyRows();\n const index = rows.indexOf(row);\n if (index < 0) return;\n if (e.shiftKey && lastSelectedIndex >= 0) {\n selectRange(lastSelectedIndex, index);\n selectionChanged();\n return;\n }\n if (opts.selectable != null) {\n if (opts.selectable === \"single\") {\n const wasSelected = row.hasAttribute(\"data-selected\");\n for (const r of rows) setRowSelected(r, false);\n setRowSelected(row, !wasSelected);\n } else {\n setRowSelected(row, !row.hasAttribute(\"data-selected\"));\n }\n lastSelectedIndex = index;\n selectionChanged();\n }\n }\n\n function onDblClick(e) {\n const cell = e.target.closest(\"[data-part='td']\");\n if (cell && tbody?.contains(cell) && isCellEditable(cell)) startEdit(cell);\n }\n\n const filterTimers = new Map();\n function onFilterInput(e) {\n const t = e.target;\n if (!t || !t.matches) return;\n if (t.matches(\"[data-part='filter']\")) {\n clearTimeout(filterTimers.get(\"global\"));\n filterTimers.set(\n \"global\",\n later(() => setFilter(t.value), 120)\n );\n return;\n }\n if (t.matches(\"[data-part='filter-input']\")) {\n const fr = filterRowEl();\n const cell = t.closest(\"[data-part='td'],[data-part='th']\");\n if (!fr || !cell) return;\n const col = cellsOf(fr).indexOf(cell);\n if (col < 0) return;\n clearTimeout(filterTimers.get(col));\n filterTimers.set(\n col,\n later(() => setColumnFilter(col, t.value), 120)\n );\n }\n }\n\n function onKeydown(e) {\n if (editing) return; // the editor's own keydown handler owns these keys\n const target = e.target;\n\n // Drag handle: arrow keys move the row among its siblings (subtrees stay attached).\n const handle = target.closest?.(\"[data-part='drag-handle']\");\n if (handle && opts.reorderable && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n const row = handle.closest(\"[data-part='tr']\");\n if (row && tbody?.contains(row)) {\n e.preventDefault();\n const down = e.key === \"ArrowDown\";\n const siblings = opts.tree\n ? bodyRows().filter((r) => parentOf(r) === parentOf(row))\n : bodyRows();\n const sibling = siblings[siblings.indexOf(row) + (down ? 1 : -1)];\n if (sibling) {\n const from = bodyRows().indexOf(row);\n if (performRowMove(row, sibling, down ? \"after\" : \"before\")) {\n emit(\"row-reorder\", { from, to: bodyRows().indexOf(row), row });\n }\n }\n }\n return;\n }\n\n const cell = target.closest?.(\"[data-part='td'],[data-part='th']\");\n\n // Escape in a cell's control returns to the cell.\n if (e.key === \"Escape\" && demoted.has(target)) {\n e.preventDefault();\n focusCell(cell);\n return;\n }\n\n // Never hijack typing or native control activation (buttons own Enter/Space via click).\n if (target.closest?.(\"input,select,textarea,button,a\")) return;\n\n const inHeader = cell && thead?.contains(cell);\n\n // Sortable header keyboard activation.\n if (inHeader && (e.key === \"Enter\" || e.key === \" \") && cell.hasAttribute(\"data-sortable\")) {\n e.preventDefault();\n const idx = headerCells().indexOf(cell);\n if (idx >= 0) handleSortRequest(idx, e.shiftKey);\n return;\n }\n\n // Header column ops (navigable focus on th).\n if (inHeader && e.altKey && (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\")) {\n if (opts.colReorderable) {\n e.preventDefault();\n const idx = headerCells().indexOf(cell);\n const delta = (e.key === \"ArrowRight\") !== isRTL ? 1 : -1;\n moveColumn(idx, idx + delta);\n return;\n }\n }\n if (inHeader && e.ctrlKey && e.shiftKey && (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\")) {\n if (opts.resizable) {\n e.preventDefault();\n const idx = headerCells().indexOf(cell);\n const delta = (e.key === \"ArrowRight\") !== isRTL ? 16 : -16;\n setColumnWidth(idx, widthOf(cell) + delta);\n return;\n }\n }\n\n if (!opts.navigable || !cell || !root.contains(cell)) return;\n\n // Select-all.\n if ((e.ctrlKey || e.metaKey) && (e.key === \"a\" || e.key === \"A\")) {\n if (opts.selectable != null || headerCheckbox) {\n e.preventDefault();\n selectAll();\n }\n return;\n }\n\n switch (e.key) {\n case \"ArrowUp\":\n e.preventDefault();\n moveFocus(-1, 0);\n return;\n case \"ArrowDown\":\n e.preventDefault();\n moveFocus(1, 0);\n return;\n case \"ArrowLeft\":\n e.preventDefault();\n moveFocus(0, isRTL ? 1 : -1);\n return;\n case \"ArrowRight\":\n e.preventDefault();\n moveFocus(0, isRTL ? -1 : 1);\n return;\n case \"Home\":\n e.preventDefault();\n moveFocus(0, 0, e.ctrlKey ? \"gridStart\" : \"rowStart\");\n return;\n case \"End\":\n e.preventDefault();\n moveFocus(0, 0, e.ctrlKey ? \"gridEnd\" : \"rowEnd\");\n return;\n case \"PageUp\":\n e.preventDefault();\n moveFocus(-10, 0);\n return;\n case \"PageDown\":\n e.preventDefault();\n moveFocus(10, 0);\n return;\n case \"Enter\":\n case \"F2\": {\n const row = cell.parentElement;\n if (row.getAttribute(\"data-part\") === \"group-header\") {\n e.preventDefault();\n toggleGroup(row);\n return;\n }\n if (isTreeParent(row) && !isCellEditable(cell)) {\n e.preventDefault();\n toggleRow(row);\n return;\n }\n if (isCellEditable(cell)) {\n e.preventDefault();\n startEdit(cell);\n return;\n }\n const ctl = cellControls(cell)[0];\n if (ctl) {\n e.preventDefault();\n ctl.focus();\n }\n return;\n }\n case \" \": {\n const row = cell.parentElement;\n if (row.getAttribute(\"data-part\") === \"group-header\") {\n e.preventDefault();\n toggleGroup(row);\n return;\n }\n if (opts.selectable != null || row.querySelector(\"[data-part='checkbox']\")) {\n const index = bodyRows().indexOf(row);\n if (index >= 0) {\n e.preventDefault();\n selectRow(index);\n }\n }\n return;\n }\n }\n }\n\n // ── Sticky + responsive measurements ──\n // The breakpoint canon (src/utils/breakpoints.ts, task 0.8-01) in px, the unit\n // clientWidth speaks. It is a literal here and not an import because the build\n // inlines every controller into one UMD closure and strips its import lines\n // (scripts/build-core.mjs) — so the equality is enforced from the outside\n // instead: tests/responsive-canon.test.ts parses this very object out of the\n // shipped controller and compares it to BREAKPOINTS, and would fail on any\n // edit that made the engine a second source of truth. `sm` was 480 in 1.x —\n // its own ladder, half a tier below the canon; the CSS ceilings it paired with\n // are now min-width floors.\n const STACK_BREAKPOINTS = { sm: 640, md: 768, lg: 1024 };\n function stackBreakpoint() {\n const v = root.getAttribute(\"data-stack-below\") || \"md\";\n return STACK_BREAKPOINTS[v] || parseFloat(v) || STACK_BREAKPOINTS.md;\n }\n /** Below the breakpoint, stack mode re-renders rows as labelled cards (CSS keys off data-stacked). */\n function updateStackMode() {\n if (opts.responsive !== \"stack\") return;\n const width = root.clientWidth || root.getBoundingClientRect?.().width || 0;\n if (!width) return; // headless environment — leave any authored data-stacked alone\n toggleAttr(root, \"data-stacked\", width < stackBreakpoint());\n }\n\n function measureSticky() {\n const needsHeaderVar =\n root.hasAttribute(\"data-sticky-header\") || bodyRows().some((r) => r.dataset.pin === \"top\");\n if (needsHeaderVar && thead && thead.offsetHeight) {\n root.style.setProperty(\"--table-thead-h\", thead.offsetHeight + \"px\");\n }\n refreshPins();\n updateStackMode();\n }\n\n // ── Refresh (full structural rescan; safe to call after external DOM changes) ──\n function refresh() {\n colTypeCache.clear();\n rememberOrder();\n mirrorColumnAttrs();\n setupTree();\n setupGroups();\n setupDetails();\n injectResizeHandles();\n applyFormats();\n setupLabels();\n setupNavigability();\n computeAggregates();\n if (globalFilter || columnFilters.size) {\n mutedRun(applyFilters);\n } else {\n updateEmptyRow(visibleBodyRows().length);\n }\n refreshPins();\n refreshStripes();\n updateHeaderCheckbox();\n }\n\n // ── Lifecycle ──\n function destroy() {\n cancelDrag();\n if (editing) cancelEdit();\n for (const fn of cleanups) fn();\n cleanups.length = 0;\n observer?.disconnect();\n observer = null;\n for (const el of root.querySelectorAll(\"[tabindex]\")) {\n if (demoted.has(el)) {\n const t = demoted.get(el);\n t == null ? el.removeAttribute(\"tabindex\") : el.setAttribute(\"tabindex\", t);\n }\n }\n for (const t of timers) clearTimeout(t);\n timers.clear();\n clearTimeout(saveTimer);\n delete root._faqirTable;\n }\n\n // ── Wire up ──\n if (thead) on(thead, \"click\", onHeaderClick);\n if (headerCheckbox) on(headerCheckbox, \"change\", onHeaderCheckboxChange);\n const onOwn = (target, ev, fn) => on(target, ev, (e) => mine(e.target) && fn(e));\n if (tbody) onOwn(tbody, \"change\", onRowCheckboxChange);\n onOwn(root, \"click\", onRootClick);\n onOwn(root, \"dblclick\", onDblClick);\n onOwn(root, \"keydown\", onKeydown);\n onOwn(root, \"input\", onFilterInput);\n onOwn(root, \"pointerdown\", onPointerDown);\n onOwn(root, \"focusin\", onFocusIn);\n if (typeof window !== \"undefined\") {\n let resizeTimer = null;\n const onWinResize = () => {\n clearTimeout(resizeTimer);\n resizeTimer = later(measureSticky, 150);\n };\n on(window, \"resize\", onWinResize);\n }\n if (typeof MutationObserver !== \"undefined\" && tbody) {\n observer = new MutationObserver(() => {\n if (!observerPaused) queueRefresh();\n });\n observer.observe(tbody, { childList: true });\n }\n if (typeof ResizeObserver !== \"undefined\") {\n let sizeTimer = null;\n const ro = new ResizeObserver(() => {\n clearTimeout(sizeTimer);\n sizeTimer = later(measureSticky, 100);\n });\n ro.observe(root);\n cleanups.push(() => ro.disconnect());\n }\n\n refresh();\n restoreState();\n if (typeof requestAnimationFrame === \"function\") requestAnimationFrame(measureSticky);\n\n const api = {\n // legacy surface (unchanged)\n sort,\n selectRow,\n selectAll,\n deselectAll,\n getSelected,\n destroy,\n // sorting\n sortBy,\n clearSort,\n // filtering\n setFilter,\n setColumnFilter,\n clearFilters,\n // grouping / tree / detail\n toggleGroup,\n toggleRow,\n toggleDetail,\n expandAll,\n collapseAll,\n // editing\n startEdit,\n commitEdit,\n cancelEdit,\n // structure\n moveRow,\n moveColumn,\n hideColumn,\n showColumn,\n toggleColumn,\n setColumnWidth,\n // data\n exportCsv,\n getData,\n getSelectedData,\n // state\n getState,\n setState,\n refresh,\n };\n root._faqirTable = api;\n return api;\n}\n return createTable;\n })();\n\n // ── tabs ── (registry/recipes/tabs/tabs.js)\n var createTabs = controllerRegistry[\"tabs\"] = (function() {\n// @ui:controller tabs\n// @ui:provides activate destroy\n\nfunction createTabs(root) {\n // Prevent double-init\n if (root._faqirTabs) return root._faqirTabs;\n\n // Direct children only: a component nested in a panel (a collapsible's\n // summary, another tabs) has parts of the same names, and a deep query took\n // them for this component's tabs and shifted the trigger↔panel pairing.\n const list = root.querySelector(\":scope > [data-part='list']\");\n const triggers = () => [\n ...root.querySelectorAll(\":scope > [data-part='list'] > [data-part='trigger']\"),\n ];\n const panels = () => [...root.querySelectorAll(\":scope > [data-part='panel']\")];\n\n function activate(index) {\n const allTriggers = triggers();\n const allPanels = panels();\n\n if (index < 0 || index >= allTriggers.length) return;\n\n // Deactivate all\n allTriggers.forEach((trigger, i) => {\n trigger.setAttribute(\"aria-selected\", \"false\");\n trigger.setAttribute(\"tabindex\", \"-1\");\n if (allPanels[i]) allPanels[i].hidden = true;\n });\n\n // Activate target\n allTriggers[index].setAttribute(\"aria-selected\", \"true\");\n allTriggers[index].removeAttribute(\"tabindex\");\n if (allPanels[index]) allPanels[index].hidden = false;\n }\n\n function getActiveIndex() {\n return triggers().findIndex(\n (t) => t.getAttribute(\"aria-selected\") === \"true\"\n );\n }\n\n function onTriggerClick(e) {\n const trigger = e.target.closest(\"[data-part='trigger']\");\n if (!trigger) return;\n const index = triggers().indexOf(trigger);\n if (index >= 0) {\n activate(index);\n trigger.focus();\n }\n }\n\n function onKeyDown(e) {\n const allTriggers = triggers();\n const current = getActiveIndex();\n let next = -1;\n\n switch (e.key) {\n case \"ArrowRight\":\n next = (current + 1) % allTriggers.length;\n break;\n case \"ArrowLeft\":\n next = (current - 1 + allTriggers.length) % allTriggers.length;\n break;\n case \"Home\":\n next = 0;\n break;\n case \"End\":\n next = allTriggers.length - 1;\n break;\n default:\n return;\n }\n\n e.preventDefault();\n activate(next);\n allTriggers[next].focus();\n }\n\n list?.addEventListener(\"click\", onTriggerClick);\n list?.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n list?.removeEventListener(\"click\", onTriggerClick);\n list?.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirTabs;\n }\n\n const api = { activate, getActiveIndex, destroy };\n root._faqirTabs = api;\n return api;\n}\n return createTabs;\n })();\n\n // ── tag-input ── (registry/recipes/tag-input/tag-input.js)\n var createTagInput = controllerRegistry[\"tag-input\"] = (function() {\n// @ui:controller tag-input\n// @ui:provides getValue setValue addTag removeTag clear destroy\n\n/**\n * tag-input — a multi-value text input that composes two existing recipes:\n *\n * • CHIP (primitive) for each committed value — the tags are real\n * `data-ui=\"chip\"` elements, so they inherit chip.css verbatim (no\n * duplicated styling) including the dismiss button.\n * • COMBOBOX behaviour for the optional suggestions listbox — filter-as-you-\n * type, Arrow/Enter selection, an empty state — mirroring the combobox\n * recipe's listbox contract.\n *\n * Interaction contract:\n * • Type + Enter commits the trimmed draft as a tag (unless it duplicates an\n * existing tag and duplicates are disallowed, the default).\n * • Backspace on an empty input removes the last tag.\n * • The chip dismiss button (or the removeTag API) removes a specific tag.\n * • With a suggestions listbox present, typing filters it; ArrowDown/ArrowUp\n * highlight; Enter/click commits the highlighted/clicked suggestion.\n *\n * Value exposure:\n * • getValue() returns the live tag array; setValue(arr) rebuilds the chips.\n * • Every mutation dispatches `faqir:change` (detail.value = the array) and\n * mirrors the array as JSON onto the hidden `[data-part=\"value\"]` input,\n * firing a native `input` event so `l-model` on that input stays in sync\n * (parse it for the array; getValue()/the event carry the array directly).\n */\nfunction createTagInput(root) {\n // Prevent double-init.\n if (root._faqirTagInput) return root._faqirTagInput;\n\n const taglist = root.querySelector(\"[data-part='taglist']\");\n const input = root.querySelector(\"[data-part='input']\");\n const listbox = root.querySelector(\"[data-part='listbox']\");\n const emptyEl = root.querySelector(\"[data-part='empty']\");\n const valueEl = root.querySelector(\"[data-part='value']\");\n const allowDuplicates = root.hasAttribute(\"data-allow-duplicates\");\n\n const options = () =>\n listbox ? [...listbox.querySelectorAll(\"[data-part='option']\")] : [];\n const visibleOptions = () => options().filter((o) => !o.hasAttribute(\"data-hidden\"));\n\n let values = [];\n let highlightedIndex = -1;\n let outsideClickCleanup = null;\n\n // ── Chip rendering (reuses the chip primitive markup) ────────────────────────\n function makeChip(value) {\n const chip = document.createElement(\"span\");\n chip.dataset.ui = \"chip\";\n chip.dataset.part = \"tag\";\n\n const label = document.createElement(\"span\");\n label.dataset.part = \"label\";\n label.textContent = value;\n\n const dismiss = document.createElement(\"button\");\n dismiss.dataset.part = \"dismiss\";\n dismiss.type = \"button\";\n dismiss.setAttribute(\"aria-label\", `Remove ${value}`);\n dismiss.textContent = \"×\";\n\n chip.append(label, dismiss);\n return chip;\n }\n\n function readInitialTags() {\n if (!taglist) return [];\n return [...taglist.querySelectorAll(\"[data-part='tag'] [data-part='label']\")].map(\n (l) => l.textContent.trim(),\n );\n }\n\n function isDuplicate(value) {\n const needle = value.toLowerCase();\n return values.some((v) => v.toLowerCase() === needle);\n }\n\n // ── value sync ───────────────────────────────────────────────────────────────\n function syncValueSeam() {\n if (!valueEl) return;\n const next = JSON.stringify(values);\n if (valueEl.value !== next) {\n valueEl.value = next;\n valueEl.dispatchEvent(new Event(\"input\", { bubbles: true }));\n }\n }\n\n function emit(name, detail) {\n root.dispatchEvent(new CustomEvent(name, { bubbles: true, detail }));\n }\n\n function commitMutation(extraDetail) {\n syncValueSeam();\n emit(\"faqir:change\", { value: values.slice(), ...extraDetail });\n }\n\n // ── add / remove ─────────────────────────────────────────────────────────────\n function addTag(raw) {\n const value = String(raw == null ? \"\" : raw).trim();\n if (!value) return false;\n if (!allowDuplicates && isDuplicate(value)) return false;\n\n values.push(value);\n if (taglist) {\n const chip = makeChip(value);\n if (input && input.parentNode === taglist) {\n taglist.insertBefore(chip, input);\n } else {\n taglist.appendChild(chip);\n }\n }\n commitMutation({ added: value });\n return true;\n }\n\n function removeTag(value) {\n const index = values.findIndex((v) => v === value);\n if (index < 0) return false;\n values.splice(index, 1);\n if (taglist) {\n const chip = [...taglist.querySelectorAll(\"[data-part='tag']\")].find(\n (c) => c.querySelector(\"[data-part='label']\")?.textContent.trim() === value,\n );\n chip?.remove();\n }\n commitMutation({ removed: value });\n return true;\n }\n\n function removeLast() {\n if (!values.length) return false;\n return removeTag(values[values.length - 1]);\n }\n\n function clear() {\n if (!values.length) return;\n values = [];\n if (taglist) {\n taglist.querySelectorAll(\"[data-part='tag']\").forEach((c) => c.remove());\n }\n commitMutation({ cleared: true });\n }\n\n function getValue() {\n return values.slice();\n }\n\n function setValue(next) {\n const arr = Array.isArray(next) ? next : [];\n // Rebuild chips from scratch to mirror the requested value exactly.\n if (taglist) {\n taglist.querySelectorAll(\"[data-part='tag']\").forEach((c) => c.remove());\n }\n values = [];\n for (const v of arr) {\n const value = String(v).trim();\n if (!value) continue;\n if (!allowDuplicates && isDuplicate(value)) continue;\n values.push(value);\n if (taglist) {\n const chip = makeChip(value);\n if (input && input.parentNode === taglist) taglist.insertBefore(chip, input);\n else taglist.appendChild(chip);\n }\n }\n commitMutation({ set: true });\n }\n\n // ── suggestions listbox (combobox behaviour) ─────────────────────────────────\n function openList() {\n if (!listbox) return;\n root.dataset.state = \"open\";\n listbox.hidden = false;\n input?.setAttribute(\"aria-expanded\", \"true\");\n outsideClickCleanup = onOutsideClick(root, closeList);\n }\n\n function closeList() {\n if (!listbox) return;\n root.dataset.state = \"closed\";\n listbox.hidden = true;\n input?.setAttribute(\"aria-expanded\", \"false\");\n clearHighlight();\n if (outsideClickCleanup) {\n outsideClickCleanup();\n outsideClickCleanup = null;\n }\n }\n\n /**\n * `aria-activedescendant`, for the same reason as `combobox`: the field\n * publishes `role=\"combobox\"` + `aria-autocomplete=\"list\"`, so it owes the\n * reader the name of the active suggestion. [W3-4]\n */\n function optionId(opt) {\n if (!opt.id) opt.id = uid(\"faqir-suggestion\");\n return opt.id;\n }\n\n function setActiveDescendant(opt) {\n if (!input) return;\n if (opt) input.setAttribute(\"aria-activedescendant\", optionId(opt));\n else input.removeAttribute(\"aria-activedescendant\");\n }\n\n function clearHighlight() {\n options().forEach((o) => o.removeAttribute(\"data-highlighted\"));\n setActiveDescendant(null);\n highlightedIndex = -1;\n }\n\n function highlight(index) {\n const vis = visibleOptions();\n if (!vis.length) return;\n if (index < 0) index = vis.length - 1;\n if (index >= vis.length) index = 0;\n options().forEach((o) => o.removeAttribute(\"data-highlighted\"));\n vis[index].setAttribute(\"data-highlighted\", \"\");\n vis[index].scrollIntoView?.({ block: \"nearest\" });\n setActiveDescendant(vis[index]);\n highlightedIndex = index;\n }\n\n function filterSuggestions(query) {\n const q = query.toLowerCase();\n let count = 0;\n options().forEach((o) => {\n const text = o.textContent.toLowerCase();\n const alreadyChosen = !allowDuplicates && isDuplicate(o.textContent.trim());\n if (text.includes(q) && !alreadyChosen) {\n o.removeAttribute(\"data-hidden\");\n count++;\n } else {\n o.setAttribute(\"data-hidden\", \"\");\n }\n });\n if (emptyEl) emptyEl.hidden = count > 0;\n clearHighlight();\n return count;\n }\n\n // ── event handlers ───────────────────────────────────────────────────────────\n function onInput() {\n if (!listbox) return;\n if (root.dataset.state !== \"open\") openList();\n filterSuggestions(input.value);\n }\n\n function onInputKeyDown(e) {\n switch (e.key) {\n case \"Enter\": {\n e.preventDefault();\n const vis = visibleOptions();\n if (listbox && highlightedIndex >= 0 && highlightedIndex < vis.length) {\n if (addTag(vis[highlightedIndex].textContent.trim())) {\n input.value = \"\";\n filterSuggestions(\"\");\n }\n } else if (input.value.trim()) {\n if (addTag(input.value)) {\n input.value = \"\";\n if (listbox) filterSuggestions(\"\");\n }\n }\n break;\n }\n case \"Backspace\":\n if (input.value === \"\") {\n e.preventDefault();\n removeLast();\n if (listbox) filterSuggestions(\"\");\n }\n break;\n case \"ArrowDown\":\n if (listbox) {\n e.preventDefault();\n if (root.dataset.state !== \"open\") openList();\n highlight(highlightedIndex + 1);\n }\n break;\n case \"ArrowUp\":\n if (listbox) {\n e.preventDefault();\n if (root.dataset.state !== \"open\") openList();\n highlight(highlightedIndex - 1);\n }\n break;\n case \"Escape\":\n if (listbox && root.dataset.state === \"open\") {\n e.preventDefault();\n // The suggestion list is what closes; the form around it stays. [W3-2]\n e.stopPropagation();\n closeList();\n }\n break;\n }\n }\n\n function onTaglistClick(e) {\n const dismiss = e.target.closest(\"[data-part='dismiss']\");\n if (!dismiss) return;\n const chip = dismiss.closest(\"[data-part='tag']\");\n const value = chip?.querySelector(\"[data-part='label']\")?.textContent.trim();\n if (value != null) {\n removeTag(value);\n input?.focus();\n }\n }\n\n function onListboxClick(e) {\n const opt = e.target.closest(\"[data-part='option']\");\n if (!opt || opt.hasAttribute(\"data-hidden\")) return;\n if (addTag(opt.textContent.trim())) {\n if (input) input.value = \"\";\n filterSuggestions(\"\");\n input?.focus();\n }\n }\n\n // ── wire up ──────────────────────────────────────────────────────────────────\n values = readInitialTags();\n syncValueSeam();\n\n input?.addEventListener(\"input\", onInput);\n input?.addEventListener(\"keydown\", onInputKeyDown);\n taglist?.addEventListener(\"click\", onTaglistClick);\n listbox?.addEventListener(\"click\", onListboxClick);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n closeList();\n input?.removeEventListener(\"input\", onInput);\n input?.removeEventListener(\"keydown\", onInputKeyDown);\n taglist?.removeEventListener(\"click\", onTaglistClick);\n listbox?.removeEventListener(\"click\", onListboxClick);\n if (outsideClickCleanup) outsideClickCleanup();\n delete root._faqirTagInput;\n }\n\n const api = { getValue, setValue, addTag, removeTag, clear, destroy };\n root._faqirTagInput = api;\n return api;\n}\n return createTagInput;\n })();\n\n // ── toast ── (registry/recipes/toast/toast.js)\n var createToastContainer = controllerRegistry[\"toast\"] = (function() {\n// @ui:controller toast\n// @ui:provides add dismiss dismissAll destroy\n\nfunction createToastContainer(root) {\n // Prevent double-init\n if (root._faqirToast) return root._faqirToast;\n\n const toasts = new Map();\n\n /**\n * Add a new toast to the container.\n *\n * `message`, `icon` and `actionLabel` are TEXT. They are written with\n * `textContent`, never `innerHTML`, because the overwhelmingly common call is\n * `add({ message: err.message })` or a message built from a name the server\n * echoed back — values the caller did not author. Markup in any of them is\n * inert, exactly as it is in `l-text` (see `docs/security.md` §4).\n *\n * `iconHtml` is the explicit opt-in for markup — an inline `<svg>` glyph is\n * the reason it exists. It is assigned to `innerHTML` verbatim and is\n * therefore an `l-html`-class surface: never pass a value you did not author.\n * When both are given, `iconHtml` wins.\n *\n * @param {Object} options\n * @param {string} options.message - Toast message text (escaped)\n * @param {string} [options.tone=\"default\"] - default|success|error|warning\n * @param {string} [options.icon] - Icon TEXT (a glyph such as \"★\"); escaped\n * @param {string} [options.iconHtml] - Icon markup, written unescaped. Author-supplied only.\n * @param {string} [options.actionLabel] - Action button label (escaped)\n * @param {Function} [options.onAction] - Action button callback\n * @param {number} [options.duration=5000] - Auto-dismiss delay in ms (0 to disable)\n * @returns {string} toast id\n */\n function add(options = {}) {\n const {\n message = \"\",\n tone = \"default\",\n icon = \"\",\n iconHtml = \"\",\n actionLabel = \"\",\n onAction = null,\n duration = 5000,\n } = options;\n\n const id = uid(\"toast\");\n const el = document.createElement(\"div\");\n el.dataset.part = \"toast\";\n el.dataset.variant = tone;\n el.dataset.state = \"entering\";\n el.setAttribute(\"role\", \"status\");\n el.setAttribute(\"aria-live\", \"polite\");\n\n // Build inner content as NODES, not as a concatenated string. The same\n // pattern as file-upload.js and tag-input.js, and for the same reason:\n // every value below may come from outside the page's author.\n if (icon || iconHtml) {\n const iconEl = document.createElement(\"span\");\n iconEl.dataset.part = \"icon\";\n iconEl.setAttribute(\"aria-hidden\", \"true\");\n // Opt-in markup wins over the escaped text form; see the doc comment.\n if (iconHtml) iconEl.innerHTML = iconHtml;\n else iconEl.textContent = icon;\n el.appendChild(iconEl);\n }\n\n const messageEl = document.createElement(\"span\");\n messageEl.dataset.part = \"message\";\n messageEl.textContent = message;\n el.appendChild(messageEl);\n\n if (actionLabel) {\n const action = document.createElement(\"button\");\n action.dataset.part = \"action\";\n action.textContent = actionLabel;\n el.appendChild(action);\n }\n\n const close = document.createElement(\"button\");\n close.dataset.part = \"close\";\n close.setAttribute(\"aria-label\", \"Dismiss notification\");\n close.textContent = \"\\u2715\"; // ✕ — was `✕` in the old innerHTML string\n el.appendChild(close);\n\n root.appendChild(el);\n\n // Transition from entering to visible on next frame\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (el.dataset.state === \"entering\") {\n el.dataset.state = \"visible\";\n }\n });\n });\n\n register(el, id, { onAction, duration });\n\n return id;\n }\n\n /**\n * Bring one toast element under the controller: wire its close and action\n * buttons, start its auto-dismiss timer, and record it so `dismiss` can find\n * it. Shared by `add()` and by the adoption of authored toasts on init.\n */\n function register(el, id, { onAction = null, duration = 0 } = {}) {\n el.dataset.toastId = id;\n\n const closeBtn = el.querySelector(\"[data-part='close']\");\n const onCloseClick = () => dismiss(id);\n closeBtn?.addEventListener(\"click\", onCloseClick);\n\n const actionBtn = el.querySelector(\"[data-part='action']\");\n const onActionClick = () => {\n if (onAction) onAction();\n dismiss(id);\n };\n if (actionBtn) {\n actionBtn.addEventListener(\"click\", onActionClick);\n }\n\n let timer = null;\n if (duration > 0) {\n timer = setTimeout(() => dismiss(id), duration);\n }\n\n toasts.set(id, {\n el,\n timer,\n closeBtn,\n onCloseClick,\n actionBtn,\n onActionClick,\n });\n\n return id;\n }\n\n /**\n * Dismiss a toast by id with exit animation.\n * @param {string} id\n */\n function dismiss(id) {\n const entry = toasts.get(id);\n // Already exiting (close clicked while the timer fires, say): one exit wait.\n if (!entry || entry.cancelExitWait) return;\n\n const { el, timer, closeBtn, onCloseClick, actionBtn, onActionClick } = entry;\n\n if (timer) clearTimeout(timer);\n\n // Start exit animation\n el.dataset.state = \"exiting\";\n\n const onEnd = () => {\n closeBtn?.removeEventListener(\"click\", onCloseClick);\n if (actionBtn) actionBtn.removeEventListener(\"click\", onActionClick);\n el.remove();\n toasts.delete(id);\n };\n\n // The toast's own exit motion. Its close button and action button both\n // transition `background` on hover, and those events bubble up to the toast\n // element — a one-shot listener spent itself on the first of them and the\n // toast was ripped out mid-slide, or (when no further event came) left in\n // the stack forever. See `whenExitDone`. [W2-1]\n entry.cancelExitWait = whenExitDone(el, null, onEnd);\n }\n\n /**\n * Dismiss all toasts.\n */\n function dismissAll() {\n const ids = [...toasts.keys()];\n ids.forEach((id) => dismiss(id));\n }\n\n function destroy() {\n // Clear all toasts immediately without animation\n for (const [id, entry] of toasts) {\n if (entry.timer) clearTimeout(entry.timer);\n if (entry.cancelExitWait) entry.cancelExitWait();\n entry.closeBtn?.removeEventListener(\"click\", entry.onCloseClick);\n if (entry.actionBtn) entry.actionBtn.removeEventListener(\"click\", entry.onActionClick);\n entry.el.remove();\n }\n toasts.clear();\n delete root._faqirToast;\n }\n\n // Adopt the toasts already in the markup.\n //\n // `add()` used to be the only way into the registry, so a toast written by\n // hand — the reference page's own stack, the manifest template, anything an\n // agent copies out of the docs — had a close button that was wired to\n // nothing. It looked right, it was in the a11y tree, it did nothing at all\n // when clicked, and nothing anywhere said so. [W2-1]\n for (const el of root.querySelectorAll(\"[data-part='toast']\")) {\n if (el.dataset.toastId) continue;\n register(el, uid(\"toast\"));\n }\n\n const api = { add, dismiss, dismissAll, destroy };\n root._faqirToast = api;\n return api;\n}\n return createToastContainer;\n })();\n\n // ── toggle-group ── (registry/recipes/toggle-group/toggle-group.js)\n var createToggleGroup = controllerRegistry[\"toggle-group\"] = (function() {\n// @ui:controller toggle-group\n// @ui:provides getValue setValue toggle destroy\n\n/**\n * toggle-group — a single- or multi-select group of toggle buttons built on\n * NATIVE form controls so `l-model` works with zero engine changes:\n *\n * • single mode → `[data-part=\"control\"]` are `<input type=\"radio\">`; the\n * committed value is the checked radio's `value` (a string). `l-model` on\n * the radios two-way-binds a string through the engine's native radio path.\n * • multi mode → the controls are `<input type=\"checkbox\">`; the value is the\n * array of checked `value`s. `l-model` binds an array through the engine's\n * native checkbox-array path.\n *\n * The visible \"buttons\" are the `[data-part=\"item\"]` labels; the native input\n * is visually hidden (see the CSS) but remains the accessible, focusable\n * control, so the ARIA is the real radio/checkbox semantics of the platform.\n *\n * The controller owns only what CSS and the platform cannot: **roving\n * tabindex** (Arrow/Home/End move a single tab-stop across the group, with\n * focus-follows-selection in single mode per the radiogroup convention),\n * keyboard toggling that is synthetic-event-safe (Space/Enter), single-mode\n * exclusivity when the controls are used standalone (no `l-model`), the\n * `[data-state]` styling hook, and a `faqir:change` notification.\n *\n * Every user mutation funnels through a native `change` event on the affected\n * input, so the engine's `l-model` listener and this controller stay in lockstep.\n * Store-driven `l-model` writes arrive as the engine's `faqir:model` event (and\n * a form `reset`); both re-sync state without a `faqir:change`. A plain script\n * write (`input.checked = x`) is silent and is not observed — use `setValue()`.\n */\nfunction createToggleGroup(root) {\n // Prevent double-init.\n if (root._faqirToggleGroup) return root._faqirToggleGroup;\n\n const mode = root.dataset.mode === \"multi\" ? \"multi\" : \"single\";\n const controls = () => [...root.querySelectorAll(\"[data-part='control']\")];\n const enabled = () => controls().filter((el) => !el.disabled);\n\n // ── value ──────────────────────────────────────────────────────────────────\n function getValue() {\n const checked = controls()\n .filter((el) => el.checked)\n .map((el) => el.value);\n return mode === \"multi\" ? checked : (checked.length ? checked[0] : null);\n }\n\n function setValue(val) {\n const cs = controls();\n if (mode === \"multi\") {\n const set = new Set(Array.isArray(val) ? val : val == null ? [] : [val]);\n cs.forEach((el) => {\n el.checked = set.has(el.value);\n });\n } else {\n cs.forEach((el) => {\n el.checked = el.value === val;\n });\n }\n syncState();\n }\n\n // ── state reflection + roving tabindex ───────────────────────────────────────\n function checkedIndex() {\n return controls().findIndex((el) => el.checked);\n }\n\n function tabStopIndex() {\n // The tab-stop follows the checked control; falling back to the first\n // enabled one so the group is always reachable by Tab.\n const checked = checkedIndex();\n if (checked >= 0 && !controls()[checked].disabled) return checked;\n const first = controls().findIndex((el) => !el.disabled);\n return first >= 0 ? first : 0;\n }\n\n function syncState() {\n const stop = tabStopIndex();\n controls().forEach((el, i) => {\n el.tabIndex = i === stop ? 0 : -1;\n const item = el.closest(\"[data-part='item']\") || el;\n item.dataset.state = el.checked ? \"on\" : \"off\";\n });\n }\n\n function emitChange() {\n root.dispatchEvent(\n new CustomEvent(\"faqir:change\", {\n bubbles: true,\n detail: { value: getValue(), mode },\n }),\n );\n }\n\n // The single mutation seam: enforce single-mode exclusivity (needed when the\n // group is used without l-model), reflect state, then notify.\n function onChange(e) {\n const el = e.target.closest(\"[data-part='control']\");\n if (!el || !root.contains(el)) return;\n if (mode === \"single\" && el.checked) {\n controls().forEach((o) => {\n if (o !== el) o.checked = false;\n });\n }\n syncState();\n emitChange();\n }\n\n // ── keyboard ─────────────────────────────────────────────────────────────────\n function moveFocus(fromIndex, delta) {\n const list = enabled();\n if (!list.length) return;\n const all = controls();\n // Map the absolute index onto the enabled subset, then step.\n let pos = list.indexOf(all[fromIndex]);\n if (pos < 0) pos = 0;\n const next = ((pos + delta) % list.length + list.length) % list.length;\n focusControl(all.indexOf(list[next]));\n }\n\n function focusControl(index) {\n const cs = controls();\n const el = cs[index];\n if (!el) return;\n cs.forEach((o, i) => {\n o.tabIndex = i === index ? 0 : -1;\n });\n el.focus();\n // radiogroup convention: in single mode, moving focus selects.\n if (mode === \"single\") select(el);\n }\n\n function jumpFocus(edge) {\n const list = enabled();\n if (!list.length) return;\n focusControl(controls().indexOf(edge === \"first\" ? list[0] : list[list.length - 1]));\n }\n\n // Toggle/select via a dispatched native change, so l-model and onChange run.\n function select(el) {\n if (el.disabled) return;\n if (mode === \"multi\") {\n el.checked = !el.checked;\n } else {\n el.checked = true;\n }\n el.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n function onKeyDown(e) {\n const cs = controls();\n const active = cs.indexOf(document.activeElement);\n const from = active >= 0 ? active : tabStopIndex();\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n e.preventDefault();\n moveFocus(from, 1);\n break;\n case \"ArrowLeft\":\n case \"ArrowUp\":\n e.preventDefault();\n moveFocus(from, -1);\n break;\n case \"Home\":\n e.preventDefault();\n jumpFocus(\"first\");\n break;\n case \"End\":\n e.preventDefault();\n jumpFocus(\"last\");\n break;\n case \" \":\n case \"Enter\":\n // Drive the toggle ourselves so synthetic events (tests) behave like\n // real ones and l-model always sees a change event.\n if (active >= 0) {\n e.preventDefault();\n select(cs[active]);\n }\n break;\n }\n }\n\n // Public toggle by value (imperative API).\n function toggle(value) {\n const el = controls().find((c) => c.value === value);\n if (el) select(el);\n }\n\n // A store-driven `l-model` write sets `.checked` silently and announces it\n // with `faqir:model`; follow it without re-emitting `faqir:change` (the user\n // did not act). A form reset restores defaults silently the same way.\n const form = root.closest(\"form\");\n const onReset = () => setTimeout(syncState, 0);\n\n root.addEventListener(\"change\", onChange);\n root.addEventListener(\"faqir:model\", syncState);\n root.addEventListener(\"keydown\", onKeyDown);\n if (form) form.addEventListener(\"reset\", onReset);\n syncState();\n\n function destroy() {\n root.removeEventListener(\"change\", onChange);\n root.removeEventListener(\"faqir:model\", syncState);\n root.removeEventListener(\"keydown\", onKeyDown);\n if (form) form.removeEventListener(\"reset\", onReset);\n delete root._faqirToggleGroup;\n }\n\n const api = { getValue, setValue, toggle, destroy };\n root._faqirToggleGroup = api;\n return api;\n}\n return createToggleGroup;\n })();\n\n // ── tooltip ── (registry/recipes/tooltip/tooltip.js)\n var createTooltip = controllerRegistry[\"tooltip\"] = (function() {\n// @ui:controller tooltip\n// @ui:provides show hide destroy\n\nfunction createTooltip(root) {\n // Prevent double-init\n if (root._faqirTooltip) return root._faqirTooltip;\n\n const trigger = root.querySelector(\"[data-part='trigger']\");\n // Not the content of a collapsible or popover used as the trigger.\n const [content] = ownParts(root, \"content\");\n\n let showTimer = null;\n let hideTimer = null;\n\n function show() {\n clearTimeout(hideTimer);\n hideTimer = null;\n root.dataset.state = \"visible\";\n content.hidden = false;\n }\n\n function hide() {\n clearTimeout(showTimer);\n showTimer = null;\n root.dataset.state = \"hidden\";\n content.hidden = true;\n }\n\n function scheduleShow() {\n clearTimeout(hideTimer);\n hideTimer = null;\n showTimer = setTimeout(show, 200);\n }\n\n function scheduleHide() {\n clearTimeout(showTimer);\n showTimer = null;\n hideTimer = setTimeout(hide, 100);\n }\n\n function onMouseEnter() {\n scheduleShow();\n }\n\n function onMouseLeave() {\n scheduleHide();\n }\n\n function onFocusIn() {\n scheduleShow();\n }\n\n function onFocusOut() {\n scheduleHide();\n }\n\n function onKeyDown(e) {\n if (e.key === \"Escape\" && root.dataset.state === \"visible\") {\n e.stopPropagation();\n hide();\n }\n }\n\n trigger?.addEventListener(\"mouseenter\", onMouseEnter);\n trigger?.addEventListener(\"mouseleave\", onMouseLeave);\n trigger?.addEventListener(\"focusin\", onFocusIn);\n trigger?.addEventListener(\"focusout\", onFocusOut);\n root.addEventListener(\"keydown\", onKeyDown);\n\n function destroy() {\n // Leaving a destroyed overlay open leaves a dead one: nothing is listening\n // any more, so its close button, Escape and overlay click all do nothing.\n // `context-menu` is the model — it has always closed itself here. [W3-2]\n hide();\n clearTimeout(showTimer);\n clearTimeout(hideTimer);\n trigger?.removeEventListener(\"mouseenter\", onMouseEnter);\n trigger?.removeEventListener(\"mouseleave\", onMouseLeave);\n trigger?.removeEventListener(\"focusin\", onFocusIn);\n trigger?.removeEventListener(\"focusout\", onFocusOut);\n root.removeEventListener(\"keydown\", onKeyDown);\n delete root._faqirTooltip;\n }\n\n const api = { show, hide, destroy };\n root._faqirTooltip = api;\n return api;\n}\n return createTooltip;\n })();\n\n // ── tree-view ── (registry/recipes/tree-view/tree-view.js)\n var createTreeView = controllerRegistry[\"tree-view\"] = (function() {\n// @ui:controller tree-view\n// @ui:provides select expand collapse toggle refresh getSelected destroy\n\n/**\n * Single-select WAI-ARIA tree view with roving DOM focus.\n *\n * Item queries are deliberately live. A tree root can be initialized before\n * keyed l-for templates render their nodes, and later reconciliations can move,\n * insert, or remove whole branches without recreating the controller.\n */\nfunction createTreeView(root) {\n if (root._faqirTreeView) {\n root._faqirTreeView.refresh();\n return root._faqirTreeView;\n }\n\n let currentItem = null;\n let selectedItem = null;\n let typeahead = \"\";\n let typeaheadTimer = null;\n\n function belongsToTree(element) {\n return element?.closest(\"[data-ui='tree-view']\") === root;\n }\n\n function items() {\n return [...root.querySelectorAll(\"[data-part='item']\")]\n .filter(belongsToTree);\n }\n\n function groups() {\n return [...root.querySelectorAll(\"[data-part='group']\")]\n .filter(belongsToTree);\n }\n\n function directItems(container) {\n return [...container.children]\n .filter((child) => child.matches(\"[data-part='item']\") && belongsToTree(child));\n }\n\n function directGroup(item) {\n return [...item.children].find(\n (child) => child.matches(\"[data-part='group']\") && belongsToTree(child),\n ) ?? null;\n }\n\n function parentItem(item) {\n const group = item.parentElement?.closest(\"[data-part='group']\");\n if (!group || !belongsToTree(group)) return null;\n const parent = group.parentElement;\n return parent?.matches(\"[data-part='item']\") && belongsToTree(parent)\n ? parent\n : null;\n }\n\n function isDisabled(item) {\n return item?.getAttribute(\"aria-disabled\") === \"true\";\n }\n\n function isLazy(item) {\n return item?.hasAttribute(\"data-lazy\") && item.dataset.lazy !== \"false\";\n }\n\n function isExpandable(item) {\n return Boolean(\n item &&\n (directGroup(item) || item.hasAttribute(\"aria-expanded\") || isLazy(item)),\n );\n }\n\n function isVisible(item) {\n if (!item || item.hidden || !belongsToTree(item)) return false;\n\n let ancestor = item.parentElement;\n while (ancestor && ancestor !== root) {\n if (ancestor.hidden) return false;\n if (ancestor.matches(\"[data-part='group']\")) {\n const parent = ancestor.parentElement;\n if (\n parent?.matches(\"[data-part='item']\") &&\n parent.getAttribute(\"aria-expanded\") !== \"true\"\n ) {\n return false;\n }\n }\n ancestor = ancestor.parentElement;\n }\n return true;\n }\n\n function visibleItems() {\n return items().filter((item) => isVisible(item) && !isDisabled(item));\n }\n\n function syncParentState(item) {\n if (item.hasAttribute(\"aria-expanded\")) {\n item.dataset.state = item.getAttribute(\"aria-expanded\") === \"true\"\n ? \"expanded\"\n : \"collapsed\";\n } else if (\n item.dataset.state === \"expanded\" ||\n item.dataset.state === \"collapsed\"\n ) {\n item.removeAttribute(\"data-state\");\n }\n }\n\n function normalizeBranch(container, level) {\n const siblings = directItems(container);\n const setSize = String(siblings.length);\n\n siblings.forEach((item, index) => {\n item.setAttribute(\"role\", \"treeitem\");\n item.setAttribute(\"aria-level\", String(level));\n item.setAttribute(\"aria-setsize\", setSize);\n item.setAttribute(\"aria-posinset\", String(index + 1));\n\n const group = directGroup(item);\n if (group) {\n group.setAttribute(\"role\", \"group\");\n const expanded = item.hasAttribute(\"aria-expanded\")\n ? item.getAttribute(\"aria-expanded\") === \"true\"\n : !group.hidden;\n item.setAttribute(\"aria-expanded\", String(expanded));\n group.hidden = !expanded;\n syncParentState(item);\n normalizeBranch(group, level + 1);\n } else if (isLazy(item) || item.hasAttribute(\"aria-expanded\")) {\n if (!item.hasAttribute(\"aria-expanded\")) {\n item.setAttribute(\"aria-expanded\", \"false\");\n }\n syncParentState(item);\n } else {\n item.removeAttribute(\"aria-expanded\");\n syncParentState(item);\n }\n });\n }\n\n function refresh() {\n root.setAttribute(\"role\", \"tree\");\n root.setAttribute(\"aria-multiselectable\", \"false\");\n\n const before = items();\n const authoredTabStop = before.find(\n (item) => item.tabIndex === 0 && !isDisabled(item),\n ) ?? null;\n\n groups().forEach((group) => group.setAttribute(\"role\", \"group\"));\n normalizeBranch(root, 1);\n\n const allItems = items();\n const selected = allItems.filter(\n (item) => !isDisabled(item) && item.getAttribute(\"aria-selected\") === \"true\",\n );\n const keepSelected = selected.includes(selectedItem)\n ? selectedItem\n : selected[0] ?? null;\n\n for (const item of allItems) {\n if (isDisabled(item)) {\n item.removeAttribute(\"aria-selected\");\n } else {\n item.setAttribute(\"aria-selected\", item === keepSelected ? \"true\" : \"false\");\n }\n }\n selectedItem = keepSelected;\n\n const active = document.activeElement?.closest?.(\"[data-part='item']\");\n const candidates = [currentItem, active, selectedItem, authoredTabStop];\n currentItem = candidates.find(\n (item) => allItems.includes(item) && isVisible(item) && !isDisabled(item),\n ) ?? visibleItems()[0] ?? null;\n\n for (const item of allItems) {\n item.tabIndex = item === currentItem ? 0 : -1;\n }\n\n root.dataset.state = selectedItem ? \"selected\" : \"idle\";\n return allItems;\n }\n\n function resolveItem(target) {\n const allItems = items();\n if (target?.matches?.(\"[data-part='item']\")) {\n return allItems.includes(target) ? target : null;\n }\n if (typeof target === \"number\") return allItems[target] ?? null;\n if (typeof target === \"string\") {\n return allItems.find(\n (item) => item.dataset.value === target || item.id === target,\n ) ?? null;\n }\n return null;\n }\n\n function itemLabel(item) {\n const label = item.querySelector(\"[data-part='label']\");\n if (label) {\n const readable = label.cloneNode(true);\n readable.querySelectorAll(\"[aria-hidden='true']\").forEach((node) => node.remove());\n return readable.textContent.trim();\n }\n return (item.dataset.value ?? item.id ?? \"\").trim();\n }\n\n function itemValue(item) {\n return item.dataset.value || item.id || itemLabel(item);\n }\n\n function emit(type, detail) {\n root.dispatchEvent(\n new CustomEvent(\"faqir:\" + type, { bubbles: true, detail }),\n );\n }\n\n function focusItem(target) {\n const item = resolveItem(target);\n if (!item || isDisabled(item) || !isVisible(item)) return false;\n\n currentItem = item;\n for (const candidate of items()) {\n candidate.tabIndex = candidate === item ? 0 : -1;\n }\n item.focus();\n item.scrollIntoView?.({ block: \"nearest\" });\n return true;\n }\n\n function select(target) {\n refresh();\n const item = resolveItem(target);\n if (!item || isDisabled(item)) return false;\n\n const previousItem = selectedItem;\n for (const candidate of items()) {\n if (!isDisabled(candidate)) {\n candidate.setAttribute(\"aria-selected\", candidate === item ? \"true\" : \"false\");\n }\n }\n\n selectedItem = item;\n currentItem = item;\n for (const candidate of items()) {\n candidate.tabIndex = candidate === item ? 0 : -1;\n }\n root.dataset.state = \"selected\";\n\n emit(\"select\", {\n item,\n value: itemValue(item),\n label: itemLabel(item),\n previousItem,\n previousValue: previousItem ? itemValue(previousItem) : null,\n });\n return true;\n }\n\n function setExpanded(target, expanded) {\n refresh();\n const item = resolveItem(target);\n if (!item || isDisabled(item) || !isExpandable(item)) return false;\n\n const next = Boolean(expanded);\n const changed = item.getAttribute(\"aria-expanded\") !== String(next);\n item.setAttribute(\"aria-expanded\", String(next));\n const group = directGroup(item);\n if (group) group.hidden = !next;\n syncParentState(item);\n refresh();\n\n if (changed) {\n emit(\"expand\", {\n item,\n value: itemValue(item),\n label: itemLabel(item),\n expanded: next,\n lazy: isLazy(item) && !group,\n });\n }\n return true;\n }\n\n function expand(target) {\n return setExpanded(target, true);\n }\n\n function collapse(target) {\n return setExpanded(target, false);\n }\n\n function toggle(target) {\n refresh();\n const item = resolveItem(target);\n if (!item || !isExpandable(item)) return false;\n return setExpanded(item, item.getAttribute(\"aria-expanded\") !== \"true\");\n }\n\n function getSelected() {\n refresh();\n return selectedItem;\n }\n\n function move(item, delta) {\n const visible = visibleItems();\n const index = visible.indexOf(item);\n if (index === -1) return false;\n const nextIndex = Math.min(Math.max(index + delta, 0), visible.length - 1);\n return nextIndex === index ? false : focusItem(visible[nextIndex]);\n }\n\n function enabledParent(item) {\n let parent = parentItem(item);\n while (parent && isDisabled(parent)) parent = parentItem(parent);\n return parent;\n }\n\n function handleTypeahead(item, key) {\n typeahead += key.toLocaleLowerCase();\n if (typeaheadTimer) clearTimeout(typeaheadTimer);\n typeaheadTimer = setTimeout(() => {\n typeahead = \"\";\n typeaheadTimer = null;\n }, 500);\n\n const query = [...typeahead].every((character) => character === typeahead[0])\n ? typeahead[0]\n : typeahead;\n const visible = visibleItems();\n if (visible.length === 0) return false;\n const start = Math.max(visible.indexOf(item), -1);\n\n for (let offset = 1; offset <= visible.length; offset++) {\n const candidate = visible[(start + offset) % visible.length];\n if (itemLabel(candidate).toLocaleLowerCase().startsWith(query)) {\n return focusItem(candidate);\n }\n }\n return false;\n }\n\n function onKeyDown(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !belongsToTree(item) || isDisabled(item)) return;\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n move(item, 1);\n break;\n case \"ArrowUp\":\n event.preventDefault();\n move(item, -1);\n break;\n case \"Home\": {\n event.preventDefault();\n const first = visibleItems()[0];\n if (first) focusItem(first);\n break;\n }\n case \"End\": {\n event.preventDefault();\n const visible = visibleItems();\n if (visible.length > 0) focusItem(visible[visible.length - 1]);\n break;\n }\n case \"ArrowRight\": {\n event.preventDefault();\n if (!isExpandable(item)) break;\n if (item.getAttribute(\"aria-expanded\") !== \"true\") {\n expand(item);\n break;\n }\n const child = directGroup(item)\n ? directItems(directGroup(item)).find((candidate) => !isDisabled(candidate))\n : null;\n if (child) focusItem(child);\n break;\n }\n case \"ArrowLeft\": {\n event.preventDefault();\n if (isExpandable(item) && item.getAttribute(\"aria-expanded\") === \"true\") {\n collapse(item);\n break;\n }\n const parent = enabledParent(item);\n if (parent) focusItem(parent);\n break;\n }\n case \"Enter\":\n case \" \":\n event.preventDefault();\n select(item);\n break;\n case \"*\": {\n event.preventDefault();\n const container = item.parentElement;\n if (!container) break;\n for (const sibling of directItems(container)) {\n if (!isDisabled(sibling) && isExpandable(sibling)) expand(sibling);\n }\n break;\n }\n default:\n if (\n event.key.length === 1 &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n ) {\n if (handleTypeahead(item, event.key)) event.preventDefault();\n }\n }\n }\n\n function onClick(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !belongsToTree(item)) return;\n if (isDisabled(item)) {\n event.preventDefault();\n return;\n }\n\n focusItem(item);\n const togglePart = event.target.closest(\"[data-part='toggle']\");\n if (togglePart && togglePart.closest(\"[data-part='item']\") === item) {\n event.preventDefault();\n toggle(item);\n } else {\n select(item);\n }\n }\n\n function onFocusIn(event) {\n if (!(event.target instanceof Element)) return;\n const item = event.target.closest(\"[data-part='item']\");\n if (!item || !belongsToTree(item) || isDisabled(item)) return;\n\n currentItem = item;\n for (const candidate of items()) {\n candidate.tabIndex = candidate === item ? 0 : -1;\n }\n }\n\n root.addEventListener(\"keydown\", onKeyDown);\n root.addEventListener(\"click\", onClick);\n root.addEventListener(\"focusin\", onFocusIn);\n\n function onMutation() {\n refresh();\n }\n\n const observer = new MutationObserver(onMutation);\n observer.observe(root, { childList: true, subtree: true });\n\n function destroy() {\n root.removeEventListener(\"keydown\", onKeyDown);\n root.removeEventListener(\"click\", onClick);\n root.removeEventListener(\"focusin\", onFocusIn);\n observer.disconnect();\n if (typeaheadTimer) clearTimeout(typeaheadTimer);\n delete root._faqirTreeView;\n }\n\n const api = {\n select,\n expand,\n collapse,\n toggle,\n refresh,\n getSelected,\n destroy,\n };\n root._faqirTreeView = api;\n refresh();\n return api;\n}\n return createTreeView;\n })();\n\n // ═══════════════════════════════════════════════════════\n // Section 8: Global API\n // ═══════════════════════════════════════════════════════\n\n var customMagics = new Map();\n\n function findParentScope(el) {\n var parent = el.parentElement;\n while (parent) {\n if (parent.__faqirScope) return parent.__faqirScope;\n parent = parent.parentElement;\n }\n return null;\n }\n\n // ═══════════════════════════════════════════════════════\n // Section 8.5: Inspection & Devtools [task 0.7-12]\n // ═══════════════════════════════════════════════════════\n //\n // `Faqir.inspect(el)` answers \"what is Faqir doing to this element?\" in one\n // plain object. It ships in BOTH builds — it is the documented surface an\n // agent (or the `faqir dev` overlay) reads, not a debug-only extra. The same\n // functions hang off `window.__FAQIR_DEVTOOLS__`; see docs/devtools.md for the\n // stable shape.\n\n // Depth cap for scope snapshots — deeper values collapse to a marker rather\n // than walking an unbounded object graph.\n var SNAPSHOT_MAX_DEPTH = 4;\n\n /** One value, deep-copied into something plain, finite and printable. */\n function snapshotValue(value, stack, depth) {\n if (typeof value === 'function') {\n // Scope methods are bound [1.1F-05]; report the name the author wrote.\n var name = String(value.name || '').replace(/^bound /, '');\n return '[Function' + (name ? ' ' + name : '') + ']';\n }\n if (value === null || typeof value !== 'object') return value;\n if (value.nodeType === 1 && value.tagName) {\n return '[Element <' + value.tagName.toLowerCase() + '>]';\n }\n if (value instanceof Date) return value.toISOString();\n if (stack.indexOf(value) !== -1) return '[Circular]';\n if (depth >= SNAPSHOT_MAX_DEPTH) return '[Depth]';\n\n stack.push(value);\n var out;\n if (Array.isArray(value)) {\n out = [];\n for (var i = 0; i < value.length; i++) out.push(snapshotValue(value[i], stack, depth + 1));\n } else {\n out = {};\n var keys = Object.keys(value);\n for (var k = 0; k < keys.length; k++) {\n out[keys[k]] = snapshotValue(value[keys[k]], stack, depth + 1);\n }\n }\n stack.pop();\n return out;\n }\n\n /**\n * Plain snapshot of a scope's DATA. Magics ($el, $refs, $store, …) are\n * non-enumerable by construction, so they never appear — a snapshot is what\n * the author put in `l-data` plus `data-prop-*`, as it stands right now.\n * Reading happens outside any effect, so it registers no dependencies.\n */\n function snapshotScope(scope) {\n if (!scope) return null;\n var out = {};\n var keys = Object.keys(scope);\n for (var i = 0; i < keys.length; i++) {\n // `__`-prefixed keys are engine plumbing (`__faqirTeardown`), not data an\n // agent inspecting the page should have to reason about.\n if (keys[i].slice(0, 2) === '__') continue;\n out[keys[i]] = snapshotValue(scope[keys[i]], [], 0);\n }\n return out;\n }\n\n /** Short human label for an element: `div#cart[data-ui=\"card\"]`. */\n function describeElement(el) {\n if (!el) return null;\n var label = el.tagName ? el.tagName.toLowerCase() : String(el);\n if (el.id) label += '#' + el.id;\n var ui = el.getAttribute ? el.getAttribute('data-ui') : null;\n if (ui) label += '[data-ui=\"' + ui + '\"]';\n var part = el.getAttribute ? el.getAttribute('data-part') : null;\n if (part) label += '[data-part=\"' + part + '\"]';\n return label;\n }\n\n /** The nearest ancestor-or-self carrying a live scope, or null. */\n function ownScopeRoot(el) {\n for (var node = el; node; node = node.parentElement) {\n if (node.__faqirScope) return node;\n }\n return null;\n }\n\n /** The five protocol attributes as they read from `el` / its `[data-ui]`. */\n function protocolState(el, uiEl) {\n var attr = function(node, name) {\n return node && node.getAttribute ? node.getAttribute(name) : null;\n };\n return {\n ui: attr(uiEl, 'data-ui'),\n part: attr(el, 'data-part'),\n variant: attr(uiEl, 'data-variant'),\n size: attr(uiEl, 'data-size'),\n state: attr(uiEl, 'data-state')\n };\n }\n\n /**\n * Everything Faqir knows about one element. [task 0.7-12 · §A6]\n *\n * @param {Element|string} target element, or a selector resolved against document\n * @returns {null|{\n * el: Element,\n * scopeRoot: Element|null,\n * scopeId: number|null,\n * scope: object|null,\n * directives: {type,arg,expression,modifiers,raw}[],\n * controller: {ui,el,api,methods}|null,\n * state: {ui,part,variant,size,state}\n * }}\n */\n function inspect(target) {\n var el = target;\n if (typeof target === 'string') {\n el = typeof document !== 'undefined' ? document.querySelector(target) : null;\n }\n if (!el || el.nodeType !== 1) return null;\n\n var root = ownScopeRoot(el);\n var uiEl = closestUI(el);\n var api = uiEl ? getControllerApi(uiEl) : null;\n\n var directives = parseDirectives(el).map(function(d) {\n return {\n type: d.type,\n arg: d.arg == null ? null : d.arg,\n expression: d.expression,\n modifiers: d.modifiers ? d.modifiers.slice() : [],\n raw: d.raw\n };\n });\n\n return {\n el: el,\n scopeRoot: root,\n scopeId: root && root.__scopeId != null ? root.__scopeId : null,\n scope: root ? snapshotScope(root.__faqirScope) : null,\n directives: directives,\n controller: uiEl && api\n ? {\n ui: uiEl.getAttribute('data-ui'),\n el: uiEl,\n api: api,\n methods: Object.keys(api).filter(function(k) {\n return typeof api[k] === 'function';\n }).sort()\n }\n : null,\n state: protocolState(el, uiEl)\n };\n }\n\n /**\n * `window.__FAQIR_DEVTOOLS__` — the stable handle agents and the `faqir dev`\n * overlay read. Keys never change shape between builds; only `dev` flips.\n */\n var devtools = {\n /** Handle schema version. Bumped only on a breaking shape change. */\n version: 1,\n /** true in `faqir-core.dev.js`, false in the production engine. */\n dev: false,\n /** The Faqir global itself (assigned once the public API is built). */\n faqir: null,\n inspect: inspect,\n /**\n * Declared scope roots in document order: elements with `l-data` (or a\n * standalone `[data-ui]`) that carry a live scope. Per-item scopes made by\n * `l-for`/`l-if` are reachable with `inspect()` on any node inside them.\n */\n scopes: function(within) {\n var host = within || (typeof document !== 'undefined' ? document : null);\n if (!host) return [];\n var els = [].slice.call(host.querySelectorAll('[l-data], [data-ui]'));\n var out = [];\n for (var i = 0; i < els.length; i++) {\n if (!els[i].__faqirScope) continue;\n out.push({\n el: els[i],\n id: els[i].__scopeId != null ? els[i].__scopeId : null,\n label: describeElement(els[i]),\n scope: snapshotScope(els[i].__faqirScope)\n });\n }\n return out;\n },\n /** Every mounted component, with its protocol attributes and its parts. */\n components: function(within) {\n var host = within || (typeof document !== 'undefined' ? document : null);\n if (!host) return [];\n var els = [].slice.call(host.querySelectorAll('[data-ui]'));\n var out = [];\n for (var i = 0; i < els.length; i++) {\n var el = els[i];\n var partEls = [].slice.call(el.querySelectorAll('[data-part]'));\n var parts = [];\n for (var p = 0; p < partEls.length; p++) {\n if (partEls[p].closest('[data-ui]') !== el) continue;\n var name = partEls[p].getAttribute('data-part');\n if (parts.indexOf(name) === -1) parts.push(name);\n }\n out.push({\n el: el,\n label: describeElement(el),\n ui: el.getAttribute('data-ui'),\n variant: el.getAttribute('data-variant'),\n size: el.getAttribute('data-size'),\n state: el.getAttribute('data-state'),\n parts: parts.sort(),\n controller: !!getControllerApi(el)\n });\n }\n return out;\n },\n /** Snapshot of every `Faqir.store()` registered on the page. */\n stores: function() {\n var out = {};\n var names = Object.keys(globalStores);\n for (var i = 0; i < names.length; i++) {\n out[names[i]] = snapshotValue(globalStores[names[i]], [], 0);\n }\n return out;\n },\n /**\n * Diagnostics recorded so far, oldest first. Always an array: the\n * production engine records nothing, so it is always empty there.\n */\n warnings: function() { return devHooks ? devHooks.warnings() : []; },\n /**\n * Record one diagnostic on a plugin's behalf. The dev build prints it and\n * keeps it in `warnings()` (deduped like every other); production does\n * nothing and answers `false`. A plugin is a separate file with no reach\n * into this seam's other side, so without it a plugin can only be silent\n * or noisy in a shipped page — and \"silent\" is what the contract forbids.\n * [1.1B-03]\n */\n report: function(message, el) {\n return false;\n }\n };\n\n\n\n // ═══════════════════════════════════════════════════════\n // Section 9: Bootstrap & Auto-init\n // ═══════════════════════════════════════════════════════\n\n // Mount one controller, containing any failure to that component.\n //\n // Controllers are invoked in a bare loop during bootstrap. A controller that\n // throws — the usual cause is markup missing a part it queries for, which an\n // agent generating HTML produces routinely — used to abort bootstrap entirely:\n // no scopes, no directives, no Faqir global, every unrelated island on the page\n // left blank. One incomplete component must break that component and nothing\n // else, and the failure has to be visible rather than silent.\n function initController(name, el) {\n try {\n controllerRegistry[name](el);\n } catch (err) {\n console.error('[Faqir] Controller \"' + name + '\" failed to initialize', el, err);\n }\n }\n\n // Every controller inside `root` (a document or an element), `root` included.\n // Controllers are double-init guarded, so a second call is a no-op.\n function startControllers(root) {\n var own = root.getAttribute && root.getAttribute('data-ui');\n if (own && controllerRegistry[own]) initController(own, root);\n var names = Object.keys(controllerRegistry);\n for (var n = 0; n < names.length; n++) {\n var els = root.querySelectorAll('[data-ui=\"' + names[n] + '\"]');\n for (var e = 0; e < els.length; e++) initController(names[n], els[e]);\n }\n }\n\n // `Faqir.initTree` — the same order bootstrap uses: a connected subtree's\n // controllers start first, so its `l-init` / first `l-effect` reach them\n // through `$ui`. A detached subtree's controllers wait for the\n // MutationObserver, as before. [1.1F-03]\n function publicInitTree(root, parentScope) {\n if (root.isConnected) startControllers(root);\n initTree(root, parentScope);\n }\n\n // The document's one MutationObserver, or null before the first bootstrap,\n // and the <body> it is currently watching.\n var mutationObserver = null;\n var observedBody = null;\n\n function bootstrap() {\n // Auto-init controllers for all [data-ui] elements\n startControllers(document);\n\n // Find all scope roots.\n // l-data elements always create a scope.\n // data-ui elements only create a scope when standalone (no l-data ancestor).\n var roots = document.querySelectorAll('[l-data], [data-ui]');\n var processed = new Set();\n\n for (var r = 0; r < roots.length; r++) {\n var rootEl = roots[r];\n if (processed.has(rootEl)) continue;\n\n // Already initialized — by an earlier `Faqir.start()`, or by the\n // MutationObserver. Re-running `initTree` over it would build a second\n // scope and apply every directive on top of the first: `start()` twice\n // meant every `@click` handler fired twice, every `l-effect` ran twice\n // and every `l-source` fetched twice. Markup added since the last call\n // still has no scope, so it is still picked up — which is the only reason\n // to call `start()` again. [W3-1]\n if (rootEl.__faqirScope) {\n processed.add(rootEl);\n var seen = rootEl.querySelectorAll('[l-data], [data-ui]');\n for (var sd = 0; sd < seen.length; sd++) processed.add(seen[sd]);\n continue;\n }\n\n // Skip if nested inside an unprocessed ancestor l-data scope\n var ancestor = rootEl.parentElement;\n var skipThis = false;\n while (ancestor) {\n if (ancestor.hasAttribute('l-data') && !processed.has(ancestor)) {\n skipThis = true;\n break;\n }\n ancestor = ancestor.parentElement;\n }\n\n // data-ui elements without l-data only need a scope if they are standalone\n // (not inside any l-data). If inside an l-data, they inherit that scope via walkChildren.\n if (!skipThis && !rootEl.hasAttribute('l-data') && rootEl.hasAttribute('data-ui')) {\n // Check if this data-ui is inside a processed l-data scope — if so, skip\n var lDataAncestor = rootEl.parentElement;\n while (lDataAncestor) {\n if (lDataAncestor.hasAttribute('l-data') && processed.has(lDataAncestor)) {\n skipThis = true;\n break;\n }\n lDataAncestor = lDataAncestor.parentElement;\n }\n }\n\n if (!skipThis) {\n initTree(rootEl, null);\n // `initTree` walked the whole subtree, so every root candidate inside it\n // — nested `[l-data]` scopes AND nested `[data-ui]` components — is\n // bound already. Claiming only the `[l-data]` ones left a `[data-ui]`\n // inside a standalone `[data-ui]` looking standalone too: it became a\n // root of its own and re-bound its subtree, so a button four components\n // deep fired its `@click` four times.\n var descendants = rootEl.querySelectorAll('[l-data], [data-ui]');\n for (var d = 0; d < descendants.length; d++) processed.add(descendants[d]);\n processed.add(rootEl);\n }\n }\n\n // Everything the scope-root pass did not claim. [W2-1]\n walkUnscoped(document.body, getStrayScope());\n\n // Second controller sweep: structural directives (l-for / l-if) may have\n // rendered recipe markup synchronously during the initTree pass above —\n // after the first sweep ran and before the MutationObserver below starts.\n // Controllers are double-init guarded, so re-invoking is a no-op for\n // elements initialized by the first sweep.\n startControllers(document);\n\n removeCloaks();\n\n // MutationObserver for dynamically added elements. ONE per document: a\n // second `Faqir.start()` used to install another, and every observer then\n // initialized every added node again — the same handler running twice per\n // insertion, which is how one `Faqir.start()` too many double-fired\n // everything on the page. Re-observed only if `document.body` itself was\n // replaced, which is what a test harness swapping bodies does. [W3-1]\n if (mutationObserver && observedBody === document.body) return;\n if (mutationObserver) {\n observedBody = document.body;\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n return;\n }\n observedBody = document.body;\n\n mutationObserver = new MutationObserver(function(mutations) {\n for (var i = 0; i < mutations.length; i++) {\n var addedNodes = mutations[i].addedNodes;\n for (var j = 0; j < addedNodes.length; j++) {\n var node = addedNodes[j];\n if (node.nodeType !== 1) continue;\n\n // Content that arrives after bootstrap has already bound by the time\n // it is here; leaving `l-cloak` on it means the cloak rule hides it\n // forever. [W3-1]\n removeCloaks(node);\n\n // Controllers first — the node's own and every one inside it — so\n // the `l-init` / first `l-effect` that `initTree` runs below reach\n // them through `$ui`. They used to start after it. [1.1F-03]\n startControllers(node);\n\n // Already initialized — by `Faqir.start()` / `Faqir.initTree()` in the\n // same task that inserted it (the record is only delivered on the\n // next microtask), or by the l-for / l-if render that stamped it.\n // Re-running `initTree` would build a second scope and bind every\n // directive twice — the same guard `bootstrap` applies. [1.1A-23]\n if (node.__faqirScope) {\n // fall through to the descendant sweep below\n } else if (node.hasAttribute && node.hasAttribute('l-data')) {\n initTree(node, findParentScope(node));\n } else if (node.hasAttribute && node.hasAttribute('data-ui') && !findParentScope(node)) {\n // Standalone data-ui (no parent scope) — create its own scope\n initTree(node, null);\n }\n\n if (node.querySelectorAll) {\n var scopeEls = node.querySelectorAll('[l-data]');\n for (var se = 0; se < scopeEls.length; se++) {\n if (!scopeEls[se].__faqirScope) {\n initTree(scopeEls[se], findParentScope(scopeEls[se]));\n }\n }\n }\n\n // Directives on a node dropped in outside every scope root — the same\n // blind spot bootstrap's sweep closes, for nodes that arrive later.\n //\n // `isConnected` matters: a mutation record is delivered as a microtask,\n // by which time the node it reports may already have been consumed —\n // `l-for` and `l-if` replace their own `<template>` with an anchor, and\n // that template arrives here detached.\n if (node.isConnected !== false && !node.__faqirScope && !findParentScope(node)) {\n var strayHost = getStrayScope();\n processElement(node, strayHost);\n if (node.parentNode) walkUnscoped(node, strayHost);\n }\n }\n }\n });\n\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n }\n\n // Auto-start logic\n //\n // `data-manual` opts out. A classic script is its own `currentScript`; a\n // module (or anything a bundler emitted) has none, so there the attribute is\n // honoured on the page's module `<script>` instead.\n var currentScript = typeof document !== 'undefined' ? document.currentScript : null;\n var isManual = currentScript\n ? currentScript.hasAttribute('data-manual')\n : typeof document !== 'undefined' && !!document.querySelector('script[type=\"module\"][data-manual]');\n\n // Once the document is parsed — always true for a module, a `defer` script\n // or a bundler import — booting right here ran before the importing code\n // got past its `import`, so every `Faqir.data()` / `Faqir.directive()` it\n // registered next was never seen. The boot waits one task instead: long\n // enough for the rest of the module graph and any `import().then(...)`, and\n // `DOMContentLoaded` still wins if it has not fired yet. `bootstrap` is\n // re-entry safe, so an explicit `Faqir.start()` before then costs nothing.\n var autoStarted = false;\n function autoStart() {\n if (autoStarted) return;\n autoStarted = true;\n bootstrap();\n }\n\n if (!isManual && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', autoStart);\n } else {\n if (document.readyState === 'interactive') document.addEventListener('DOMContentLoaded', autoStart);\n setTimeout(autoStart, 0);\n }\n }\n\n // ═══════════════════════════════════════════════════════\n // Public API\n // ═══════════════════════════════════════════════════════\n\n var Faqir = {\n // @faqir:version — `scripts/build-core.mjs` rewrites this literal from the\n // root package.json at assembly time. It drifted three minor versions the\n // one time it was hand-maintained (0.1.0 in a package versioned 0.2.4), so\n // the built artifact is now the only place the number is authoritative and\n // the build fails if this marker goes missing.\n version: '1.1.2', // @faqir:version\n reactive: reactive,\n effect: effect,\n batch: batch,\n untrack: untrack,\n evaluate: evaluate,\n evaluateAssignment: evaluateAssignment,\n nextTick: function(fn) { return queueMicrotask(fn || function() {}); },\n data: function(name, factory) { dataRegistry.set(name, factory); },\n store: function(name, obj) { globalStores[name] = reactive(obj); },\n directive: function(name, handler) { customDirectives.set(name, handler); },\n magic: function(name, callback) {\n if (name === 'this') throw new Error('[Faqir] \"this\" is reserved: $this is the directive element');\n customMagics.set(name, callback);\n },\n plugin: function(fn) { fn(Faqir); },\n controller: function(name, factory) { controllerRegistry[name] = factory; },\n start: bootstrap,\n initTree: publicInitTree,\n // Snapshot of Faqir's view of one element — scope, directives, controller,\n // protocol attributes. [0.7-12]\n inspect: inspect,\n // The same object installed at window.__FAQIR_DEVTOOLS__. Exposed here too\n // so code holding a specific engine instance (a bundler import, a test\n // loading one build) reaches ITS handle rather than whichever engine\n // touched the global last. [0.7-12]\n devtools: devtools,\n // Run the cleanups registered on `el` and its descendants (l-source abort +\n // poll teardown, effect disposers, …). Structural directives call this\n // automatically on l-if hide / keyed l-for removal; exposed for imperative\n // teardown of a subtree. [0.3-08]\n destroy: destroyScope\n };\n\n // The devtools handle is installed on every page that loads either build —\n // agents read it without knowing how Faqir was bundled. [0.7-12]\n devtools.faqir = Faqir;\n if (typeof window !== 'undefined') {\n window.__FAQIR_DEVTOOLS__ = devtools;\n }\n\n return Faqir;\n});\n",
|
|
6
6
|
"// CDN classic-script entry for `@faqir-ui/core`.\n//\n// `scripts/build-core-package.mjs` bundles this file with `--format=iife`, so a\n// plain `<script src=\"faqir-core.min.js\">` (no `type=\"module\"`) executes the\n// engine and assigns it to `window.Faqir` — the two-tag CDN story (§10.3).\n//\n// The unminified `dist/faqir-core.js` is the canonical UMD build and remains the\n// entry for `import`/`require`; this wrapper exists only to give the minified\n// classic-script artifact a global.\nimport Faqir from \"../../../registry/core/faqir-core.js\";\n\n(typeof globalThis !== \"undefined\" ? globalThis : typeof self !== \"undefined\" ? self : this).Faqir =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