foldkit-mixins 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -10
- package/dist/core-B86QnDhB.d.mts +40 -0
- package/dist/core-B86QnDhB.d.mts.map +1 -0
- package/dist/core-izIY2GSX.mjs +53 -0
- package/dist/core-izIY2GSX.mjs.map +1 -0
- package/dist/defaults.d.mts +27 -0
- package/dist/defaults.d.mts.map +1 -0
- package/dist/defaults.mjs +71 -0
- package/dist/defaults.mjs.map +1 -0
- package/dist/diagnostics-YJ7991-A.mjs +15 -0
- package/dist/diagnostics-YJ7991-A.mjs.map +1 -0
- package/dist/index.d.mts +232 -76
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +486 -229
- package/dist/index.mjs.map +1 -1
- package/dist/layers-CJS5d1i7.mjs +197 -0
- package/dist/layers-CJS5d1i7.mjs.map +1 -0
- package/dist/layers.d.mts +47 -0
- package/dist/layers.d.mts.map +1 -0
- package/dist/layers.mjs +2 -0
- package/dist/layout.d.mts +114 -0
- package/dist/layout.d.mts.map +1 -0
- package/dist/layout.mjs +154 -0
- package/dist/layout.mjs.map +1 -0
- package/dist/prose.d.mts +24 -0
- package/dist/prose.d.mts.map +1 -0
- package/dist/prose.mjs +57 -0
- package/dist/prose.mjs.map +1 -0
- package/dist/styleValue--iQMTcPn.mjs +242 -0
- package/dist/styleValue--iQMTcPn.mjs.map +1 -0
- package/dist/styleValue-C9vAKt7A.d.mts +77 -0
- package/dist/styleValue-C9vAKt7A.d.mts.map +1 -0
- package/dist/theme.d.mts +412 -0
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.mjs +278 -0
- package/dist/theme.mjs.map +1 -0
- package/package.json +32 -7
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["make","is","is","MetadataToken.is","make","MetadataToken.nameOf","MetadataToken.make","describe","MetadataToken.nameOf","Capability.extendsCapability","is","MetadataToken.is","make","MetadataToken.make","equals","describe","ih","make","empty","compose","MetadataToken.nameOf","define","attach","Capability.extendsCapability","MetadataToken.nameOf","forSlots","Mixin.dynamic","attach","SlotView.attach","is","MetadataToken.is","make","MetadataToken.make","describe","is","MetadataToken.is","make","MetadataToken.make","describe","Capability.Base","describe","MetadataToken.nameOf","Slot.is","Slot.make","define","Slot.describe","Capability.extendsCapability","pseudo","media","supports","container","nest","keyframes","Rules.pseudo","Rules.media","Rules.supports","Rules.container","Rules.nest","Rules.keyframes","Rules.className","Rules.css","Mixin.dynamic","SlotView.attach"],"sources":["../src/metadataToken.ts","../src/capability.ts","../src/a11y.ts","../src/attr.ts","../src/attribute.ts","../src/attributes.ts","../src/diagnostics.ts","../src/mixin.ts","../src/pipe.ts","../src/resolver.ts","../src/slotView.ts","../src/behavior.ts","../src/event.ts","../src/requirement.ts","../src/slot.ts","../src/slots.ts","../src/styleRules.ts","../src/style.ts","../src/theme.ts"],"sourcesContent":["/**\n * Ported from `effect-atom-jsx/src/MetadataToken.ts`. Kinded name tokens so\n * Event, Attr, Requirement, and Capability share one witness instead of four\n * ad-hoc brands.\n */\nexport const MetadataTokenTypeId: unique symbol = Symbol.for('foldkit-mixins/MetadataToken')\n\nexport interface MetadataToken<Kind extends string, Name extends string> {\n readonly [MetadataTokenTypeId]: {\n readonly Kind: Kind\n readonly Name: Name\n }\n readonly kind: Kind\n readonly name: Name\n}\n\nexport type Any = MetadataToken<string, string>\n\nexport type NameOf<T> =\n T extends MetadataToken<any, infer Name> ? Name : T extends string ? T : never\n\nexport type KindOf<T> = T extends MetadataToken<infer Kind, any> ? Kind : never\n\nexport type NamesOf<T extends readonly unknown[]> = NameOf<T[number]>\n\nexport const make = <const Kind extends string, const Name extends string>(\n kind: Kind,\n name: Name,\n): MetadataToken<Kind, Name> => {\n if (name === '') {\n throw new Error(`${kind} name must be non-empty`)\n }\n return {\n [MetadataTokenTypeId]: {\n Kind: undefined as unknown as Kind,\n Name: undefined as unknown as Name,\n },\n kind,\n name,\n }\n}\n\nexport const is = (value: unknown): value is Any =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, MetadataTokenTypeId)\n\nexport const nameOf = (value: string | Any): string => (is(value) ? value.name : value)\n","/**\n * Ported from `effect-atom-jsx/src/Element.ts` `Capability`, without Handle\n * objects. Inheritance is metadata: a behavior that needs Interactive can\n * attach to TextInput. Lookups go through a Map so `__proto__` is a legal name.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type CapabilityParent = string | MetadataToken.MetadataToken<'element.capability', string>\n\nexport interface Capability<\n Name extends string = string,\n Extends extends readonly CapabilityParent[] = readonly [],\n> extends MetadataToken.MetadataToken<'element.capability', Name> {\n readonly extends: Extends\n}\n\nexport type Any = Capability<string, readonly CapabilityParent[]>\nexport type NameOf<T> = MetadataToken.NameOf<T>\nexport type NamesOf<T extends readonly unknown[]> = MetadataToken.NamesOf<T>\nexport type ExtendsOf<T> =\n T extends Capability<any, infer Extends> ? MetadataToken.NameOf<Extends[number]> : never\nexport type AssignableNamesOf<T> = T extends string\n ? T\n : T extends Capability<any, infer Extends>\n ? MetadataToken.NameOf<T> | AssignableNamesOf<Extends[number]>\n : MetadataToken.NameOf<T>\n\nexport type Satisfies<Actual, Required extends { readonly name: string }> =\n Required['name'] extends AssignableNamesOf<Actual> ? true : false\n\nconst parentsByName = new Map<string, ReadonlyArray<string>>()\nconst registry = new Map<string, Any>()\n\nexport const is = (value: unknown): value is Any =>\n MetadataToken.is(value) && value.kind === 'element.capability'\n\nexport const make = <\n const Name extends string,\n const Extends extends readonly CapabilityParent[] = readonly [],\n>(\n name: Name,\n options?: { readonly extends?: Extends },\n): Capability<Name, Extends> => {\n if (name === '') {\n throw new Error('Capability name must be non-empty')\n }\n const parents = (options?.extends ?? []) as Extends\n const parentNames = parents.map(parent => MetadataToken.nameOf(parent))\n const existing = registry.get(name)\n if (existing !== undefined) {\n const existingNames = existing.extends.map(parent => MetadataToken.nameOf(parent))\n if (\n existingNames.length === parentNames.length &&\n existingNames.every((parentName, index) => parentName === parentNames[index])\n ) {\n return existing as Capability<Name, Extends>\n }\n throw new Error(`Capability \"${name}\" is already defined with a different extends list`)\n }\n parentsByName.set(name, parentNames)\n const capability: Capability<Name, Extends> = {\n ...MetadataToken.make('element.capability', name),\n extends: Object.freeze([...parents]) as Extends,\n }\n registry.set(name, capability)\n return Object.freeze(capability)\n}\n\n/** True when `value` is `base` or inherits from it. Ported from AF-UI. */\nexport const extendsCapability = (value: string | Any, base: string | Any): boolean => {\n const valueName = MetadataToken.nameOf(value)\n const baseName = MetadataToken.nameOf(base)\n if (valueName === baseName) return true\n const visited = new Set<string>()\n const stack = [...(parentsByName.get(valueName) ?? [])]\n while (stack.length > 0) {\n const current = stack.pop()\n if (current === undefined) continue\n if (current === baseName) return true\n if (visited.has(current)) continue\n visited.add(current)\n stack.push(...(parentsByName.get(current) ?? []))\n }\n return false\n}\n\nexport const satisfies = (actual: string | Any, required: string | Any): boolean =>\n extendsCapability(actual, required)\n\nexport const names = (capability: Any): ReadonlyArray<string> => {\n const seen = new Set<string>()\n const walk = (name: string) => {\n if (seen.has(name)) return\n seen.add(name)\n for (const parent of parentsByName.get(name) ?? []) walk(parent)\n }\n walk(capability.name)\n return [...seen]\n}\n\nexport const describe = (\n capability: Any,\n): { readonly name: string; readonly extends: ReadonlyArray<string> } => ({\n name: capability.name,\n extends: capability.extends.map(parent => MetadataToken.nameOf(parent)),\n})\n\nexport const Base = make('Base')\nexport const Interactive = make('Interactive', { extends: [Base] })\nexport const Container = make('Container', { extends: [Interactive] })\nexport const Focusable = make('Focusable', { extends: [Interactive] })\nexport const TextInput = make('TextInput', { extends: [Focusable] })\nexport const Draggable = make('Draggable', { extends: [Interactive] })\nexport const Collection = make('Collection', { extends: [Base] })\n","/**\n * Structural accessibility validation. A `Pattern` names the Slots a widget\n * must publish, the capabilities those Slots must satisfy, and the events and\n * attributes they must expose. `validate` compares a `Slots` contract against a\n * pattern and reports every mismatch as a `Diagnostic`. It is pure and\n * DOM-independent: it checks the declared contract, not a rendered tree, so it\n * verifies only the contract it is given and does not certify WCAG conformance.\n */\nimport * as Capability from './capability.js'\nimport type { Diagnostic } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport type { Any as AnySlot, AttributeName, EventName, SlotCapability } from './slot.js'\n\nexport type A11yDiagnosticCode =\n | 'a11y:missing-slot'\n | 'a11y:hidden-slot'\n | 'a11y:capability-mismatch'\n | 'a11y:missing-event'\n | 'a11y:missing-attribute'\n\nexport interface A11yDiagnostic extends Diagnostic {\n readonly source: 'a11y'\n readonly code: A11yDiagnosticCode\n}\n\nexport interface SlotRequirement {\n readonly capability?: SlotCapability\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n /** An absent slot is expected, not a diagnostic. A present slot is still checked. */\n readonly optional?: boolean\n}\n\nexport type Requirements = Readonly<Record<string, SlotRequirement>>\n\nexport const PatternTypeId: unique symbol = Symbol.for('foldkit-mixins/A11yPattern')\n\nexport interface Pattern<Spec extends Requirements = Requirements> {\n readonly [PatternTypeId]: { readonly Requirements: Spec }\n readonly requirements: Spec\n}\n\nexport const pattern = <const Spec extends Requirements>(spec: Spec): Pattern<Spec> => {\n const requirements = Object.create(null) as Record<string, SlotRequirement>\n for (const name of Object.getOwnPropertyNames(spec)) {\n const requirement = spec[name]\n if (requirement === undefined) continue\n Object.defineProperty(requirements, name, {\n value: Object.freeze({ ...requirement }),\n enumerable: true,\n configurable: false,\n writable: false,\n })\n }\n Object.freeze(requirements)\n return Object.freeze({\n [PatternTypeId]: { Requirements: undefined as unknown as Spec },\n requirements: requirements as Spec,\n }) as Pattern<Spec>\n}\n\nconst publishes = (\n names: ReadonlyArray<string | MetadataToken.Any>,\n required: string | MetadataToken.Any,\n): boolean => {\n const requiredName = MetadataToken.nameOf(required)\n return names.some(name => MetadataToken.nameOf(name) === requiredName)\n}\n\nconst diagnostic = (\n code: A11yDiagnosticCode,\n message: string,\n slot: string,\n details?: Readonly<Record<string, unknown>>,\n): A11yDiagnostic => ({\n source: 'a11y',\n code,\n severity: 'error',\n message,\n slot,\n ...(details === undefined ? {} : { details }),\n})\n\nexport const validate = (\n pattern: Pattern,\n slots: { readonly [name: string]: AnySlot },\n): ReadonlyArray<A11yDiagnostic> => {\n const diagnostics: Array<A11yDiagnostic> = []\n for (const name of Object.getOwnPropertyNames(pattern.requirements)) {\n const requirement = pattern.requirements[name]\n if (requirement === undefined) continue\n if (!Object.hasOwn(slots, name)) {\n if (requirement.optional === true) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-slot',\n `A11y pattern requires slot \"${name}\", which the contract does not publish`,\n name,\n ),\n )\n continue\n }\n const slot = slots[name]\n if (slot === undefined) continue\n if (slot.hidden) {\n diagnostics.push(\n diagnostic(\n 'a11y:hidden-slot',\n `A11y pattern requires slot \"${name}\", which is hidden`,\n name,\n ),\n )\n continue\n }\n if (\n requirement.capability !== undefined &&\n !Capability.extendsCapability(slot.capability, requirement.capability)\n ) {\n diagnostics.push(\n diagnostic(\n 'a11y:capability-mismatch',\n `A11y pattern requires capability \"${MetadataToken.nameOf(requirement.capability)}\" on slot \"${name}\", which has \"${MetadataToken.nameOf(slot.capability)}\"`,\n name,\n {\n required: MetadataToken.nameOf(requirement.capability),\n actual: MetadataToken.nameOf(slot.capability),\n },\n ),\n )\n }\n for (const event of requirement.events ?? []) {\n const eventName = MetadataToken.nameOf(event)\n if (publishes(slot.events, event)) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-event',\n `A11y pattern requires event \"${eventName}\" on slot \"${name}\", which does not publish it`,\n name,\n { event: eventName },\n ),\n )\n }\n for (const attribute of requirement.attributes ?? []) {\n const attributeName = MetadataToken.nameOf(attribute)\n if (publishes(slot.attributes, attribute)) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-attribute',\n `A11y pattern requires attribute \"${attributeName}\" on slot \"${name}\", which does not publish it`,\n name,\n { attribute: attributeName },\n ),\n )\n }\n }\n return diagnostics\n}\n","/**\n * Slot attribute tokens. Ported from `effect-atom-jsx/src/View.ts` `Attribute`,\n * plus ARIA names the Foldkit plan lists.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type AttrToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.attribute',\n Name\n>\n\nexport const is = (value: unknown): value is AttrToken =>\n MetadataToken.is(value) && value.kind === 'view.attribute'\n\nexport const make = <const Name extends string>(name: Name): AttrToken<Name> =>\n MetadataToken.make('view.attribute', name)\n\nexport const equals = (left: AttrToken, right: AttrToken): boolean => left.name === right.name\n\nexport const describe = (attr: AttrToken): { readonly name: string } => ({\n name: attr.name,\n})\n\nexport const Role = make('role')\nexport const AriaLabel = make('aria-label')\nexport const AriaDescribedby = make('aria-describedby')\nexport const AriaExpanded = make('aria-expanded')\nexport const AriaSelected = make('aria-selected')\nexport const AriaInvalid = make('aria-invalid')\nexport const AriaDisabled = make('aria-disabled')\nexport const Disabled = make('disabled')\nexport const Value = make('value')\n","/**\n * Internal attribute helpers. Foldkit's `isChildAttribute` and the tagged\n * attribute shape are not public, so this module localizes the two casts they\n * require. Probed against foldkit 0.158.2; see docs/design/mixins-DESIGN.md.\n */\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport { inertHtml as ih } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\n\n/** The brand `childAttribute.d.ts` stamps; Foldkit's guard is not exported. */\nconst CHILD_ATTRIBUTE_BRAND = '__childAttribute'\n\nexport const isChildAttribute = (value: unknown): value is ChildAttribute =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, CHILD_ATTRIBUTE_BRAND)\n\ninterface Tagged {\n readonly _tag: string\n}\n\nexport const isTagged = (value: unknown): value is Tagged =>\n typeof value === 'object' &&\n value !== null &&\n Object.hasOwn(value, '_tag') &&\n typeof (value as { readonly _tag?: unknown })._tag === 'string'\n\n/** `Class` carries no Message, so the inert builder is the honest constructor. */\nexport const classAttribute = (value: string): Attribute<never> => ih.Class(value)\n\nexport const styleAttribute = (value: Record<string, string>): Attribute<never> => ih.Style(value)\n\n/**\n * `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing\n * mount is built directly. The shape is the same tagged value `h.OnMount`\n * produces (`{ _tag: 'OnMount', action }`).\n */\nexport const mountAttribute = <Message>(action: MountAction<Message, any>): Attribute<Message> =>\n ({ _tag: 'OnMount', action }) as Attribute<Message>\n","/**\n * Typed reads over a resolved `SlotAttributes` bundle. Foldkit's tagged\n * attribute union narrows on `_tag`, so a lookup by tag returns that variant's\n * own fields (`value`, `message`, `key`, `action`) without a cast.\n */\nimport type { Attribute } from 'foldkit/html'\nimport { isTagged } from './attribute.js'\nimport type { SlotAttributes } from './resolver.js'\n\n/** Every Foldkit attribute tag: `'Class'`, `'OnClick'`, `'DataAttribute'`, … */\nexport type Tag = Attribute<never>['_tag']\n\n/** The attribute variant carrying `T`. */\nexport type Of<Message, T extends Tag> = Extract<Attribute<Message>, { readonly _tag: T }>\n\n/** The tag of one bundle entry; `undefined` for an opaque `ChildAttribute`. */\nexport const tagOf = <Message>(attribute: SlotAttributes<Message>[number]): Tag | undefined =>\n isTagged(attribute) ? attribute._tag : undefined\n\nconst hasTag =\n <Message, T extends Tag>(tag: T) =>\n (attribute: SlotAttributes<Message>[number]): attribute is Of<Message, T> =>\n tagOf(attribute) === tag\n\n/** The first attribute with `tag`, typed as that variant. */\nexport const find = <Message, T extends Tag>(\n attributes: SlotAttributes<Message>,\n tag: T,\n): Of<Message, T> | undefined => attributes.find(hasTag<Message, T>(tag))\n\n/** Every attribute with `tag`, in bundle order. */\nexport const filter = <Message, T extends Tag>(\n attributes: SlotAttributes<Message>,\n tag: T,\n): ReadonlyArray<Of<Message, T>> => attributes.filter(hasTag<Message, T>(tag))\n","/**\n * Structured diagnostics for attachment conflicts. Codes are stable so tests,\n * DevTools, and editor tooling can share them. Resolution failures are\n * programming errors (a definition attaches something a slot does not allow),\n * so `resolve` throws a `DiagnosticError` carrying one.\n */\nexport type DiagnosticCode =\n | 'mixins:unknown-slot'\n | 'mixins:hidden-slot'\n | 'mixins:capability-mismatch'\n | 'mixins:unsupported-event'\n | 'mixins:unsupported-attribute'\n | 'mixins:protected-event'\n | 'mixins:protected-attribute'\n | 'mixins:protected-style-property'\n | 'mixins:event-conflict'\n | 'mixins:attribute-conflict'\n | 'mixins:structural-override'\n | 'mixins:duplicate-mount-name'\n | 'style:conditional-rules-unsupported'\n | 'a11y:missing-slot'\n | 'a11y:hidden-slot'\n | 'a11y:capability-mismatch'\n | 'a11y:missing-event'\n | 'a11y:missing-attribute'\n\nexport interface Diagnostic {\n readonly source: 'mixins' | 'a11y'\n readonly code: DiagnosticCode\n readonly severity: 'error'\n readonly message: string\n readonly slot?: string\n readonly details?: Readonly<Record<string, unknown>>\n}\n\nexport class DiagnosticError extends Error {\n readonly diagnostic: Diagnostic\n\n constructor(diagnostic: Diagnostic) {\n super(diagnostic.message)\n this.name = 'DiagnosticError'\n this.diagnostic = diagnostic\n }\n}\n","/**\n * `Mixin` is the common algebra: a named set of per-slot contributions.\n *\n * `StaticMixin` holds only static contributions, so it stays assignable to any\n * Message universe; Style uses it. `Mixin` may hold deferred contributions and\n * is tied to one Message universe; Behavior uses it. Composition is immutable\n * and keeps the deferred form when either side is deferred.\n */\nimport type {\n Contribution,\n ContributionContext,\n DynamicContribution,\n SlotContribution,\n StaticContribution,\n StaticContributionMap,\n} from './contribution.js'\n\nexport interface Mixin<Message = never> {\n readonly name: string\n readonly contributions: Contribution<Message>\n}\n\nexport interface StaticMixin<Message = never> {\n readonly name: string\n readonly contributions: StaticContributionMap<Message>\n}\n\nexport type AnyMixin = Mixin<any> | StaticMixin<any>\n\n/**\n * A Mixin acceptable in any context of `Message`. `Mixin<never>` is included\n * explicitly because a message-free dynamic Mixin (input-driven Style) does not\n * widen to `Mixin<Message>` — `HtmlBuilder` is invariant in `Message`.\n */\nexport type MixinFor<Message> = Mixin<Message> | StaticMixin<Message> | Mixin<never>\n\nexport const isDynamic = <Message>(\n contribution: SlotContribution<Message>,\n): contribution is DynamicContribution<Message> => typeof contribution === 'function'\n\nexport const evaluate = <Message>(\n contribution: SlotContribution<Message>,\n context: ContributionContext<Message>,\n): StaticContribution<Message> => (isDynamic(contribution) ? contribution(context) : contribution)\n\nconst mergeStatic = <Message>(\n left: StaticContribution<Message>,\n right: StaticContribution<Message>,\n): StaticContribution<Message> => {\n const css = `${left.css ?? ''}${right.css ?? ''}`\n const globalCss = `${left.globalCss ?? ''}${right.globalCss ?? ''}`\n return Object.freeze({\n classes: Object.freeze([...(left.classes ?? []), ...(right.classes ?? [])]),\n style: Object.freeze({ ...(left.style ?? {}), ...(right.style ?? {}) }),\n attributes: Object.freeze([...(left.attributes ?? []), ...(right.attributes ?? [])]),\n mounts: Object.freeze([...(left.mounts ?? []), ...(right.mounts ?? [])]),\n ...(css === '' ? {} : { css }),\n ...(globalCss === '' ? {} : { globalCss }),\n })\n}\n\nconst mergeSlot = <Message>(\n left: SlotContribution<Message>,\n right: SlotContribution<Message>,\n): SlotContribution<Message> => {\n if (!isDynamic(left) && !isDynamic(right)) return mergeStatic(left, right)\n return context => mergeStatic(evaluate(left, context), evaluate(right, context))\n}\n\nexport const make = <Message = never>(\n name: string,\n contributions: StaticContributionMap<Message>,\n): StaticMixin<Message> =>\n Object.freeze({ name, contributions: Object.freeze({ ...contributions }) })\n\nexport const dynamic = <Message = never>(\n name: string,\n contributions: Contribution<Message>,\n): Mixin<Message> => Object.freeze({ name, contributions: Object.freeze({ ...contributions }) })\n\nexport const empty = <Message = never>(): StaticMixin<Message> => make('Empty', {})\n\nexport const compose = <Message = never>(\n ...mixins: ReadonlyArray<MixinFor<Message>>\n): Mixin<Message> => {\n const merged: Record<string, SlotContribution<Message>> = Object.create(null)\n for (const mixin of mixins) {\n for (const [slot, contribution] of Object.entries(mixin.contributions)) {\n if (contribution === undefined) continue\n // A `Mixin<never>` may only contribute message-free data; the cast lets it\n // compose with a message-bearing Mixin under one algebra.\n const normalized = contribution as SlotContribution<Message>\n const existing = merged[slot]\n merged[slot] = existing === undefined ? normalized : mergeSlot(existing, normalized)\n }\n }\n return dynamic(mixins.length === 0 ? 'Empty' : mixins.map(mixin => mixin.name).join('+'), merged)\n}\n\nexport const contributionsFor = <Message>(\n mixin: Mixin<Message> | StaticMixin<Message>,\n slot: string,\n): SlotContribution<Message> | undefined => mixin.contributions[slot]\n","/** Ported from `effect-atom-jsx/src/View.ts` `pipeSelf`. */\nexport const pipeSelf = (self: unknown, fns: ReadonlyArray<(value: any) => any>): unknown =>\n fns.reduce((acc, fn) => fn(acc), self)\n\nexport type Pipeable<Self> = {\n pipe(): Self\n pipe(...fns: ReadonlyArray<(self: Self) => Self>): Self\n pipe<A>(ab: (self: Self) => A): A\n pipe<A, B>(ab: (self: Self) => A, bc: (a: A) => B): B\n pipe<A, B, C>(ab: (self: Self) => A, bc: (a: A) => B, cd: (b: B) => C): C\n}\n","/**\n * The deterministic resolver. `resolve` is pure: it decomposes the base\n * attributes, applies contributions in attachment order, enforces ownership\n * and protection, then emits one canonical `Class`, one `Style`, and at most\n * one `OnMount`. Conflicts throw a `DiagnosticError` before Foldkit could\n * silently chain or replace.\n */\nimport { Stream } from 'effect'\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\nimport {\n classAttribute,\n isChildAttribute,\n isTagged,\n mountAttribute,\n styleAttribute,\n} from './attribute.js'\nimport type { StaticContribution } from './contribution.js'\nimport { DiagnosticError, type Diagnostic, type DiagnosticCode } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport type { SlotProtection } from './slot.js'\n\nexport type SlotAttributes<Message> = ReadonlyArray<Attribute<Message> | ChildAttribute>\n\nexport interface ResolveOptions {\n readonly slot?: string\n readonly protected?: SlotProtection\n}\n\n/** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */\nconst normalizeName = (name: string): string => name.replace(/[^a-z0-9]/gi, '').toLowerCase()\n\n/** Attribute tags are PascalCase (`OnKeyDown`); event tokens are lowercase. */\nconst eventNameOfTag = (tag: string): string =>\n normalizeName(tag.startsWith('On') ? tag.slice(2) : tag)\n\nconst splitClasses = (value: string): ReadonlyArray<string> =>\n value.split(/\\s+/).filter(token => token.length > 0)\n\n/** `Prop`/`Attribute`/`DataAttribute`/`OnCustomEvent` are keyed individually. */\nconst ownershipKey = (tag: string, value: unknown): string => {\n if (typeof value !== 'object' || value === null) return tag\n const record = value as { readonly key?: unknown; readonly name?: unknown }\n switch (tag) {\n case 'Prop':\n case 'Attribute':\n case 'DataAttribute':\n return `${tag}:${String(record.key)}`\n case 'OnCustomEvent':\n return `${tag}:${String(record.name)}`\n default:\n return tag\n }\n}\n\nconst toDiagnostic = (\n code: DiagnosticCode,\n message: string,\n slot: string | undefined,\n details: Readonly<Record<string, unknown>>,\n): Diagnostic => ({\n source: 'mixins',\n code,\n severity: 'error',\n message,\n ...(slot === undefined ? {} : { slot }),\n details,\n})\n\nexport const resolve = <Message>(\n base: SlotAttributes<Message> | undefined,\n contributions: ReadonlyArray<StaticContribution<Message>>,\n options: ResolveOptions = {},\n): SlotAttributes<Message> => {\n const slot = options.slot\n const protection = options.protected\n const protectedEvents = new Set(\n (protection?.events ?? []).map(event => normalizeName(MetadataToken.nameOf(event))),\n )\n const protectedAttributes = new Set(\n (protection?.attributes ?? []).map(attr => normalizeName(MetadataToken.nameOf(attr))),\n )\n const protectedStyle = new Set(protection?.style ?? [])\n\n const classes: Array<string> = []\n const classSeen = new Set<string>()\n const style = new Map<string, string>()\n const mounts: Array<MountAction<Message, any>> = []\n const mountNames = new Map<string, number>()\n const preserved: Array<Attribute<Message> | ChildAttribute> = []\n const added: Array<Attribute<Message> | ChildAttribute> = []\n const ownedEvents = new Map<string, string>()\n const ownedAttributes = new Map<string, string>()\n\n function fail(\n code: DiagnosticCode,\n message: string,\n details: Readonly<Record<string, unknown>>,\n ): never {\n throw new DiagnosticError(toDiagnostic(code, message, slot, details))\n }\n\n const addClass = (token: string): void => {\n if (classSeen.has(token)) return\n classSeen.add(token)\n classes.push(token)\n }\n\n const addMount = (action: MountAction<Message, any>): void => {\n const count = (mountNames.get(action.name) ?? 0) + 1\n mountNames.set(action.name, count)\n if (count > 1) {\n fail('mixins:duplicate-mount-name', `two Mounts are both named \"${action.name}\"`, {\n name: action.name,\n })\n }\n mounts.push(action)\n }\n\n const reserve = (tag: string, value: unknown): void => {\n if (tag === 'OnMount') return\n // `OnCustomEvent` is keyed by its event name, not treated as one native event.\n if (tag.startsWith('On') && tag !== 'OnCustomEvent') {\n ownedEvents.set(eventNameOfTag(tag), tag)\n return\n }\n ownedAttributes.set(ownershipKey(tag, value), tag)\n }\n\n const addBase = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n if (isTagged(inner)) reserve(inner._tag, inner)\n preserved.push(attribute)\n return\n }\n const tag = attribute._tag\n switch (tag) {\n case 'Class':\n for (const token of splitClasses(attribute.value)) addClass(token)\n return\n case 'Style':\n for (const [property, value] of Object.entries(attribute.value)) style.set(property, value)\n return\n case 'OnMount':\n addMount(attribute.action)\n return\n default:\n reserve(tag, attribute)\n preserved.push(attribute)\n }\n }\n\n const applyMixinAttribute = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n if (isTagged(inner)) reserve(inner._tag, inner)\n added.push(attribute)\n return\n }\n const tag = attribute._tag\n switch (tag) {\n case 'Class':\n for (const token of splitClasses(attribute.value)) addClass(token)\n return\n case 'Style':\n for (const [property, value] of Object.entries(attribute.value)) {\n if (protectedStyle.has(property)) {\n fail(\n 'mixins:protected-style-property',\n `slot \"${slot ?? '?'}\" protects style property \"${property}\"`,\n { property },\n )\n }\n style.set(property, value)\n }\n return\n case 'OnMount':\n addMount(attribute.action)\n return\n case 'Key':\n case 'InnerHTML':\n fail(\n 'mixins:structural-override',\n `a Mixin may not contribute \"${tag}\"; it is structural ownership`,\n { tag },\n )\n default:\n if (tag.startsWith('On') && tag !== 'OnCustomEvent') {\n const eventName = eventNameOfTag(tag)\n if (protectedEvents.has(eventName)) {\n fail('mixins:protected-event', `slot \"${slot ?? '?'}\" protects event \"${eventName}\"`, {\n tag,\n event: eventName,\n })\n }\n const owner = ownedEvents.get(eventName)\n if (owner !== undefined) {\n fail(\n 'mixins:event-conflict',\n `two owners for event \"${eventName}\": \"${owner}\" already owns it`,\n { tag, event: eventName, owner },\n )\n }\n ownedEvents.set(eventName, tag)\n } else {\n const key = ownershipKey(tag, attribute)\n if (protectedAttributes.has(normalizeName(tag))) {\n fail(\n 'mixins:protected-attribute',\n `slot \"${slot ?? '?'}\" protects attribute \"${tag}\"`,\n { tag },\n )\n }\n const owner = ownedAttributes.get(key)\n if (owner !== undefined) {\n fail(\n 'mixins:attribute-conflict',\n `two owners for \"${key}\": a ${owner} attribute already occupies it`,\n { tag, key, owner },\n )\n }\n ownedAttributes.set(key, tag)\n }\n added.push(attribute)\n }\n }\n\n for (const attribute of base ?? []) addBase(attribute)\n\n for (const contribution of contributions) {\n for (const token of contribution.classes ?? []) addClass(token)\n for (const [property, value] of Object.entries(contribution.style ?? {})) {\n if (protectedStyle.has(property)) {\n fail(\n 'mixins:protected-style-property',\n `slot \"${slot ?? '?'}\" protects style property \"${property}\"`,\n { property },\n )\n }\n style.set(property, value)\n }\n for (const attribute of contribution.attributes ?? []) applyMixinAttribute(attribute)\n for (const mount of contribution.mounts ?? []) addMount(mount)\n }\n\n const emitted: Array<Attribute<Message> | ChildAttribute> = []\n if (classes.length > 0) emitted.push(classAttribute(classes.join(' ')))\n if (style.size > 0) emitted.push(styleAttribute(Object.fromEntries(style)))\n emitted.push(...preserved, ...added)\n const composed = composeMounts(mounts, slot)\n if (composed !== undefined) emitted.push(composed)\n return emitted\n}\n\nconst composeMounts = <Message>(\n mounts: ReadonlyArray<MountAction<Message, any>>,\n slot: string | undefined,\n): Attribute<Message> | undefined => {\n const first = mounts[0]\n if (first === undefined) return undefined\n if (mounts.length === 1) return mountAttribute(first)\n const name = `Mixins[${slot ?? 'slot'}](${mounts.map(mount => mount.name).join(',')})`\n return mountAttribute({\n name,\n args: {\n slot: slot ?? null,\n actions: mounts.map(mount => ({ name: mount.name, args: mount.args })),\n },\n f: (element, viewStateChanges) =>\n Stream.mergeAll(\n mounts.map(mount => mount.f(element, viewStateChanges)),\n { concurrency: 'unbounded' },\n ),\n })\n}\n","/**\n * `SlotView` is the structural equivalent of a Surface: a pure Foldkit view\n * that publishes typed Slots and lets Mixins attach without forking it. It\n * owns no state and runs no Effects. Attached Mixins are resolved into\n * ordinary Foldkit attributes per slot, using the view's own `h` so Message\n * capability masking is preserved.\n */\nimport { inertHtml, type Html, type HtmlBuilder } from 'foldkit/html'\nimport type { SlotContribution } from './contribution.js'\nimport { evaluate, type AnyMixin, type Mixin, type MixinFor, type StaticMixin } from './mixin.js'\nimport { pipeSelf, type Pipeable } from './pipe.js'\nimport { resolve, type SlotAttributes } from './resolver.js'\nimport type { Any as AnySlot, SlotProtection } from './slot.js'\n\nexport type SlotBuilder<Message> = {\n readonly attrs: (base?: SlotAttributes<Message>) => SlotAttributes<Message>\n}\n\nexport type SlotBuilders<Slots, Message> = {\n readonly [K in keyof Slots]: SlotBuilder<Message>\n}\n\nexport type SlotViewRender<Slots, Input, Message> = (\n input: Input,\n slots: SlotBuilders<Slots, Message>,\n h: HtmlBuilder<Message>,\n) => Html\n\nexport interface SlotView<Slots, Input, Message> extends Pipeable<SlotView<Slots, Input, Message>> {\n (input: Input, h: HtmlBuilder<Message>): Html\n readonly name?: string\n readonly slots: Slots\n readonly mixins: ReadonlyArray<MixinFor<Message>>\n readonly render: SlotViewRender<Slots, Input, Message>\n}\n\n/** Build one `attrs` resolver per published slot, evaluating Mixins lazily. */\nexport const buildersFor = <Slots, Message, Input>(\n slots: Slots,\n mixins: ReadonlyArray<MixinFor<Message>>,\n context: { readonly input: Input; readonly h: HtmlBuilder<Message> },\n): SlotBuilders<Slots, Message> => {\n const source = slots as unknown as Record<string, AnySlot>\n const builders: Record<string, SlotBuilder<Message>> = Object.create(null)\n for (const name of Object.getOwnPropertyNames(source)) {\n const slot = source[name]\n if (slot === undefined) continue\n const protection: SlotProtection = slot.protected\n builders[name] = {\n attrs: (base?: SlotAttributes<Message>) => {\n const contributions = []\n for (const mixin of mixins) {\n const contribution = mixin.contributions[name]\n if (contribution !== undefined) {\n contributions.push(\n evaluate(contribution as SlotContribution<Message>, {\n input: context.input,\n h: context.h,\n }),\n )\n }\n }\n return resolve(base, contributions, { slot: name, protected: protection })\n },\n }\n }\n return builders as SlotBuilders<Slots, Message>\n}\n\nconst makeView = <Slots, Input, Message>(\n name: string | undefined,\n slots: Slots,\n mixins: ReadonlyArray<MixinFor<Message>>,\n render: SlotViewRender<Slots, Input, Message>,\n): SlotView<Slots, Input, Message> => {\n const view = (input: Input, h: HtmlBuilder<Message>): Html =>\n render(input, buildersFor(slots, mixins, { input, h }), h)\n // A function's own `name` is read-only; define it rather than assigning.\n if (name !== undefined) {\n Object.defineProperty(view, 'name', { value: name, configurable: true })\n }\n return Object.assign(view, {\n slots,\n mixins,\n render,\n pipe: (...fns: ReadonlyArray<(self: unknown) => unknown>) => pipeSelf(view, fns),\n }) as unknown as SlotView<Slots, Input, Message>\n}\n\n/**\n * Defines a view over published Slots.\n *\n * `Message` has no anchor but the render callback's builder, so it is inferred\n * from an explicit `h: HtmlBuilder<Message>` annotation on that parameter.\n * Without one it resolves to `unknown`, and the first error appears later and\n * elsewhere — an invariance mismatch at `Style.attach`/`Behavior.attach` that\n * does not name the missing annotation. `forMessages<Message>()` fixes the\n * Message universe up front instead, and leaves `h` contextually typed.\n */\nexport const define = <Slots, Input, Message>(\n slots: Slots,\n render: SlotViewRender<Slots, Input, Message>,\n options?: { readonly name?: string },\n): SlotView<Slots, Input, Message> => makeView(options?.name, slots, [], render)\n\n/**\n * Foldkit's `inertHtml` typed for a Message universe, for rendering a view\n * outside a runtime (tests, demos, static description). `inertHtml` is\n * `HtmlBuilder<never>`, and the builder is invariant in `Message`, so this is\n * the one cast: sound because inert handlers are never dispatched.\n */\nexport const inertBuilder = <Message>(): HtmlBuilder<Message> =>\n inertHtml as unknown as HtmlBuilder<Message>\n\n/** The `SlotView` constructors with `Message` already fixed. */\nexport interface MessageSlotView<Message> {\n readonly define: <Slots, Input>(\n slots: Slots,\n render: SlotViewRender<Slots, Input, Message>,\n options?: { readonly name?: string },\n ) => SlotView<Slots, Input, Message>\n}\n\n/**\n * Binds the view constructors to one Message universe, so the render callback\n * no longer has to annotate `h` to pin it. `Input` is still inferred from the\n * callback's own `input` annotation.\n *\n * @example\n * ```ts\n * const Field = SlotView.forMessages<Message>().define(\n * FieldSlots,\n * (input: FieldInput, slots, h) =>\n * h.input(slots.input.attrs([h.OnInput(value => Message.ChangedValue({ value }))])),\n * )\n * ```\n */\nexport const forMessages = <Message>(): MessageSlotView<Message> => ({ define })\n\n/** A transform on any view, used by Message-free static mixins such as Style. */\nexport type SlotViewTransform = <Slots, Input, Message>(\n view: SlotView<Slots, Input, Message>,\n) => SlotView<Slots, Input, Message>\n\n/** A transform restricted to one Message universe, for Behavior mixins. */\nexport type SlotViewTransformFor<Message> = <Slots, Input>(\n view: SlotView<Slots, Input, Message>,\n) => SlotView<Slots, Input, Message>\n\n/** Attach one Mixin. Returns a new view; the original is unchanged. */\nexport function attach(mixin: StaticMixin<never> | Mixin<never>): SlotViewTransform\nexport function attach<MixinMessage>(mixin: Mixin<MixinMessage>): SlotViewTransformFor<MixinMessage>\nexport function attach(mixin: AnyMixin | Mixin<never>): any {\n return (view: SlotView<any, any, any>) =>\n makeView(view.name, view.slots, [...view.mixins, mixin], view.render)\n}\n","/**\n * `Behavior` is a named set of interaction contributions attached to declared\n * Slots. It owns no state: attributes are built from the view's `input` and `h`\n * while resolving, so the Message universe is the view's. A stateful widget is\n * a Foldkit Submodel; a continuous element listener is a Mount; a network call\n * is Message -> update -> Command.\n */\nimport type { Attribute, ChildAttribute, HtmlBuilder } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\nimport * as Capability from './capability.js'\nimport type { SlotContribution } from './contribution.js'\nimport { DiagnosticError, type DiagnosticCode } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport * as Mixin from './mixin.js'\nimport type { Mixin as MixinValue } from './mixin.js'\nimport type { Any as AnySlot, AttributeName, EventName, HiddenOf, SlotCapability } from './slot.js'\nimport * as SlotView from './slotView.js'\n\nexport interface SlotRequirements {\n readonly capability?: SlotCapability\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n}\n\nexport interface BehaviorSlotOptions<Input, Message> {\n readonly requires?: SlotRequirements\n readonly attributes?: (context: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => ReadonlyArray<Attribute<Message> | ChildAttribute>\n readonly mount?: (input: Input) => MountAction<Message, any>\n}\n\nexport type BehaviorSpec<Slots, Input, Message> = {\n readonly [K in keyof Slots as HiddenOf<Slots[K]> extends true ? never : K]?: BehaviorSlotOptions<\n Input,\n Message\n >\n}\n\nexport interface NamedBehavior<Slots, Input, Message> {\n readonly name?: string\n readonly spec: BehaviorSpec<Slots, Input, Message>\n readonly mixin: MixinValue<Message>\n}\n\n/** Identity helper; `forSlots` supplies the contextual `Input`/`Message`. */\nexport const slot = <Options extends BehaviorSlotOptions<any, any>>(options: Options): Options =>\n options\n\nfunction fail(\n code: DiagnosticCode,\n message: string,\n slotName: string,\n details?: Readonly<Record<string, unknown>>,\n): never {\n throw new DiagnosticError({\n source: 'mixins',\n code,\n severity: 'error',\n message,\n slot: slotName,\n ...(details === undefined ? {} : { details }),\n })\n}\n\nconst validateRequirements = (\n name: string,\n slot: AnySlot,\n requirements: SlotRequirements,\n): void => {\n if (\n requirements.capability !== undefined &&\n !Capability.extendsCapability(slot.capability, requirements.capability)\n ) {\n fail(\n 'mixins:capability-mismatch',\n `Behavior requires capability \"${MetadataToken.nameOf(requirements.capability)}\" on slot \"${name}\", which has \"${MetadataToken.nameOf(slot.capability)}\"`,\n name,\n { required: MetadataToken.nameOf(requirements.capability) },\n )\n }\n for (const event of requirements.events ?? []) {\n const eventName = MetadataToken.nameOf(event)\n if (!slot.events.some(allowed => MetadataToken.nameOf(allowed) === eventName)) {\n fail(\n 'mixins:unsupported-event',\n `Behavior requires event \"${eventName}\" on slot \"${name}\", which does not publish it`,\n name,\n { event: eventName },\n )\n }\n }\n for (const attribute of requirements.attributes ?? []) {\n const attributeName = MetadataToken.nameOf(attribute)\n if (!slot.attributes.some(allowed => MetadataToken.nameOf(allowed) === attributeName)) {\n fail(\n 'mixins:unsupported-attribute',\n `Behavior requires attribute \"${attributeName}\" on slot \"${name}\", which does not publish it`,\n name,\n { attribute: attributeName },\n )\n }\n }\n}\n\nexport const forSlots =\n <Slots>(slots: Slots) =>\n <Input, Message>(\n spec: BehaviorSpec<Slots, Input, Message>,\n options?: { readonly name?: string },\n ): NamedBehavior<Slots, Input, Message> => {\n const source = slots as unknown as Record<string, AnySlot>\n const contributions: Record<string, SlotContribution<Message>> = Object.create(null)\n for (const [name, slotOptions] of Object.entries(\n spec as Record<string, BehaviorSlotOptions<Input, Message> | undefined>,\n )) {\n const target = source[name]\n if (target === undefined) {\n fail('mixins:unknown-slot', `Behavior targets unknown slot \"${name}\"`, name)\n }\n if (target.hidden) {\n fail('mixins:hidden-slot', `Behavior targets hidden slot \"${name}\"`, name)\n }\n if (slotOptions?.requires !== undefined) {\n validateRequirements(name, target, slotOptions.requires)\n }\n const attributes = slotOptions?.attributes\n const mount = slotOptions?.mount\n if (attributes === undefined && mount === undefined) continue\n contributions[name] = context => ({\n ...(attributes === undefined\n ? {}\n : { attributes: attributes({ input: context.input as Input, h: context.h }) }),\n ...(mount === undefined ? {} : { mounts: [mount(context.input as Input)] }),\n })\n }\n return Object.freeze({\n ...(options?.name === undefined ? {} : { name: options.name }),\n spec,\n mixin: Mixin.dynamic<Message>(options?.name ?? 'Behavior', contributions),\n })\n }\n\n/**\n * Attaches a Behavior to a view. The behavior's `Input` becomes the attached\n * view's `Input`: a behavior declared over only the fields it reads is rejected\n * even though those fields are a subset, and one declared over extra fields\n * widens what the view must be called with. Declare `Input` as the view's own\n * input type.\n */\nexport const attach =\n <BehaviorSlots, Message, Input>(behavior: NamedBehavior<BehaviorSlots, Input, Message>) =>\n <ViewSlots>(\n view: SlotView.SlotView<ViewSlots, Input, Message>,\n ): SlotView.SlotView<ViewSlots, Input, Message> =>\n SlotView.attach(behavior.mixin)(view)\n\nexport const Behavior = { slot, forSlots, attach } as const\n","/**\n * Slot event tokens. Ported from `effect-atom-jsx/src/View.ts` `Event`, plus\n * the extra names the Foldkit plan lists.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type EventToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.event',\n Name\n>\n\nexport const is = (value: unknown): value is EventToken =>\n MetadataToken.is(value) && value.kind === 'view.event'\n\nexport const make = <const Name extends string>(name: Name): EventToken<Name> =>\n MetadataToken.make('view.event', name)\n\nexport const equals = (left: EventToken, right: EventToken): boolean => left.name === right.name\n\nexport const describe = (event: EventToken): { readonly name: string } => ({\n name: event.name,\n})\n\nexport const Press = make('press')\nexport const Click = make('click')\nexport const Cancel = make('cancel')\nexport const Input = make('input')\nexport const Change = make('change')\nexport const Focus = make('focus')\nexport const Blur = make('blur')\nexport const KeyDown = make('keydown')\nexport const PointerDown = make('pointerdown')\nexport const PointerUp = make('pointerup')\nexport const Hover = make('hover')\nexport const Submit = make('submit')\n","/**\n * Platform requirement tokens. Ported from `effect-atom-jsx/src/View.ts`\n * `Requirement`.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type RequirementToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.requirement',\n Name\n>\n\nexport const is = (value: unknown): value is RequirementToken =>\n MetadataToken.is(value) && value.kind === 'view.requirement'\n\nexport const make = <const Name extends string>(name: Name): RequirementToken<Name> =>\n MetadataToken.make('view.requirement', name)\n\nexport const describe = (requirement: RequirementToken): { readonly name: string } => ({\n name: requirement.name,\n})\n\nexport const Keyboard = make('keyboard')\nexport const Pointer = make('pointer')\nexport const Clipboard = make('clipboard')\n","/**\n * Slot witnesses. Ported from `effect-atom-jsx/src/View.ts` `Slot`, without\n * Handle binding. A slot is named metadata: capability, allowed events,\n * attributes, platform requirements, hidden, and Foldkit-only `protected`.\n */\nimport type { AttrToken } from './attr.js'\nimport type { Any as AnyCapability } from './capability.js'\nimport * as Capability from './capability.js'\nimport type { EventToken } from './event.js'\nimport * as MetadataToken from './metadataToken.js'\nimport { pipeSelf, type Pipeable } from './pipe.js'\nimport type { RequirementToken } from './requirement.js'\n\nexport const SlotTypeId: unique symbol = Symbol.for('foldkit-mixins/Slot')\nexport type SlotTypeId = typeof SlotTypeId\n\nexport type EventName = string | EventToken\nexport type AttributeName = string | AttrToken\nexport type RequirementName = string | RequirementToken\nexport type SlotCapability = string | AnyCapability\n\nexport interface SlotProtection {\n readonly events: ReadonlyArray<EventName>\n readonly attributes: ReadonlyArray<AttributeName>\n readonly style: ReadonlyArray<string>\n}\n\nexport interface SlotMetadata<Name extends string = string> {\n readonly name: Name\n readonly capability: SlotCapability\n readonly allowedEvents: readonly EventName[]\n readonly allowedAttributes: readonly AttributeName[]\n readonly platformRequirements: readonly RequirementName[]\n readonly hidden: boolean\n readonly protected: SlotProtection\n}\n\nexport interface Slot<\n Name extends string = string,\n C extends SlotCapability = typeof Capability.Base,\n Events extends readonly EventName[] = readonly [],\n Attributes extends readonly AttributeName[] = readonly [],\n Requirements extends readonly RequirementName[] = readonly [],\n Hidden extends boolean = false,\n> extends Pipeable<Slot<Name, C, Events, Attributes, Requirements, Hidden>> {\n readonly [SlotTypeId]: {\n readonly Name: Name\n readonly Capability: C\n readonly Events: Events\n readonly Attributes: Attributes\n readonly Requirements: Requirements\n readonly Hidden: Hidden\n }\n readonly name: Name\n readonly capability: C\n readonly events: Events\n readonly attributes: Attributes\n readonly requirements: Requirements\n readonly hidden: Hidden\n readonly protected: SlotProtection\n readonly metadata: SlotMetadata<Name> & {\n readonly capability: C\n readonly allowedEvents: Events\n readonly allowedAttributes: Attributes\n readonly platformRequirements: Requirements\n readonly hidden: Hidden\n }\n}\n\nexport type Any = Slot<\n string,\n SlotCapability,\n readonly EventName[],\n readonly AttributeName[],\n readonly RequirementName[],\n boolean\n>\n\nexport type UnnamedSlot<\n C extends SlotCapability = SlotCapability,\n Events extends readonly EventName[] = readonly EventName[],\n Attributes extends readonly AttributeName[] = readonly AttributeName[],\n Requirements extends readonly RequirementName[] = readonly RequirementName[],\n Hidden extends boolean = boolean,\n> = Omit<Slot<'', C, Events, Attributes, Requirements, Hidden>, 'name'> & {\n readonly name?: never\n}\n\nexport type NameOf<T> = T extends Slot<infer Name, any, any, any, any, any> ? Name : never\nexport type CapabilityOf<T> =\n T extends Slot<any, infer C, any, any, any, any> ? MetadataToken.NameOf<C> : never\nexport type CapabilityValueOf<T> = T extends Slot<any, infer C, any, any, any, any> ? C : never\nexport type EventsOf<T> =\n T extends Slot<any, any, infer Events, any, any, any> ? MetadataToken.NamesOf<Events> : never\nexport type AttributesOf<T> =\n T extends Slot<any, any, any, infer Attributes, any, any>\n ? MetadataToken.NamesOf<Attributes>\n : never\nexport type HiddenOf<T> = T extends Slot<any, any, any, any, any, infer Hidden> ? Hidden : never\nexport type AssignableCapabilityNamesOf<T> = Capability.AssignableNamesOf<CapabilityValueOf<T>>\nexport type Public<T> = HiddenOf<T> extends true ? never : T\nexport type Hidden<T> = HiddenOf<T> extends true ? T : never\n\nexport const is = (value: unknown): value is Any | UnnamedSlot =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, SlotTypeId)\n\nconst emptyProtection: SlotProtection = Object.freeze({\n events: Object.freeze([]) as ReadonlyArray<EventName>,\n attributes: Object.freeze([]) as ReadonlyArray<AttributeName>,\n style: Object.freeze([]) as ReadonlyArray<string>,\n})\n\nexport interface MakeOptions<\n C extends SlotCapability = SlotCapability,\n Events extends readonly EventName[] = readonly EventName[],\n Attributes extends readonly AttributeName[] = readonly AttributeName[],\n Requirements extends readonly RequirementName[] = readonly RequirementName[],\n Hidden extends boolean = boolean,\n> {\n readonly capability?: C\n readonly events?: Events\n readonly allowedEvents?: Events\n readonly attributes?: Attributes\n readonly allowedAttributes?: Attributes\n readonly requirements?: Requirements\n readonly platformRequirements?: Requirements\n readonly hidden?: Hidden\n readonly protected?: {\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n readonly style?: ReadonlyArray<string>\n }\n}\n\nconst protectionOf = (options: MakeOptions | undefined): SlotProtection => {\n const specified = options?.protected\n if (specified === undefined) return emptyProtection\n return Object.freeze({\n events: Object.freeze([...(specified.events ?? [])]),\n attributes: Object.freeze([...(specified.attributes ?? [])]),\n style: Object.freeze([...(specified.style ?? [])]),\n })\n}\n\nconst createSlot = <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n>(\n name: Name,\n options: MakeOptions<C, Events, Attributes, Requirements, Hidden> | undefined,\n): Slot<Name, C, Events, Attributes, Requirements, Hidden> => {\n const capability = (options?.capability ?? Capability.Base) as C\n const events = (options?.events ?? options?.allowedEvents ?? []) as Events\n const attributes = (options?.attributes ?? options?.allowedAttributes ?? []) as Attributes\n const requirements = (options?.requirements ??\n options?.platformRequirements ??\n []) as Requirements\n const hidden = (options?.hidden ?? false) as Hidden\n const protection = protectionOf(options)\n const metadata = {\n name,\n capability,\n allowedEvents: events,\n allowedAttributes: attributes,\n platformRequirements: requirements,\n hidden,\n protected: protection,\n }\n const out = {\n [SlotTypeId]: {\n Name: undefined as unknown as Name,\n Capability: undefined as unknown as C,\n Events: undefined as unknown as Events,\n Attributes: undefined as unknown as Attributes,\n Requirements: undefined as unknown as Requirements,\n Hidden: undefined as unknown as Hidden,\n },\n name,\n capability,\n events,\n attributes,\n requirements,\n hidden,\n protected: protection,\n metadata,\n } as Slot<Name, C, Events, Attributes, Requirements, Hidden>\n return Object.assign(out, {\n pipe: (...fns: ReadonlyArray<(value: any) => any>) => pipeSelf(out, fns),\n }) as Slot<Name, C, Events, Attributes, Requirements, Hidden>\n}\n\n/** AF-UI form: name is the first argument. */\nexport function make<\n const Name extends string,\n const C extends SlotCapability = typeof Capability.Base,\n const Events extends readonly EventName[] = readonly [],\n const Attributes extends readonly AttributeName[] = readonly [],\n const Requirements extends readonly RequirementName[] = readonly [],\n const Hidden extends boolean = false,\n>(\n name: Name,\n options?: MakeOptions<C, Events, Attributes, Requirements, Hidden>,\n): Slot<Name, C, Events, Attributes, Requirements, Hidden>\n/** Foldkit form: name comes from `Slots.define` keys. */\nexport function make<\n const C extends SlotCapability = typeof Capability.Base,\n const Events extends readonly EventName[] = readonly [],\n const Attributes extends readonly AttributeName[] = readonly [],\n const Requirements extends readonly RequirementName[] = readonly [],\n const Hidden extends boolean = false,\n>(\n options: MakeOptions<C, Events, Attributes, Requirements, Hidden>,\n): UnnamedSlot<C, Events, Attributes, Requirements, Hidden>\nexport function make(\n nameOrOptions: string | MakeOptions,\n options?: MakeOptions,\n): Any | UnnamedSlot {\n if (typeof nameOrOptions === 'string') {\n return createSlot(nameOrOptions, options)\n }\n const unnamed = createSlot('', nameOrOptions)\n const { name: _dropped, ...rest } = unnamed\n return rest as UnnamedSlot\n}\n\n/** Pipeable transform replacing a named slot's capability. */\nexport const capability =\n <const C extends SlotCapability>(capability: C) =>\n <\n Name extends string,\n OldC extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, OldC, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Events, Attributes, Requirements, Hidden> =>\n createSlot(slot.name, {\n capability,\n events: slot.events,\n attributes: slot.attributes,\n requirements: slot.requirements,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform replacing a named slot's allowed events. */\nexport const events =\n <const Next extends readonly EventName[]>(...next: Next) =>\n <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Next, Attributes, Requirements, Hidden> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: next,\n attributes: slot.attributes,\n requirements: slot.requirements,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform replacing a named slot's allowed attributes. */\nexport const attributes =\n <const Next extends readonly AttributeName[]>(...next: Next) =>\n <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Events, Next, Requirements, Hidden> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: slot.events,\n attributes: next,\n requirements: slot.requirements,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform replacing a named slot's platform requirements. */\nexport const requires =\n <const Next extends readonly RequirementName[]>(...next: Next) =>\n <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Events, Attributes, Next, Hidden> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: slot.events,\n attributes: slot.attributes,\n requirements: next,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform marking a named slot hidden from public attachment. */\nexport const hide = <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n>(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n): Slot<Name, C, Events, Attributes, Requirements, true> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: slot.events,\n attributes: slot.attributes,\n requirements: slot.requirements,\n hidden: true,\n protected: slot.protected,\n })\n\nexport const describe = (\n slot: Any | UnnamedSlot,\n): {\n readonly name?: string\n readonly capability: string\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly requirements: ReadonlyArray<string>\n readonly hidden: boolean\n readonly protected: {\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly style: ReadonlyArray<string>\n }\n} => {\n const named = slot.name !== undefined && slot.name !== '' ? { name: slot.name } : {}\n return {\n ...named,\n capability: MetadataToken.nameOf(slot.capability),\n events: slot.events.map(event => MetadataToken.nameOf(event)),\n attributes: slot.attributes.map(attr => MetadataToken.nameOf(attr)),\n requirements: slot.requirements.map(requirement => MetadataToken.nameOf(requirement)),\n hidden: slot.hidden,\n protected: {\n events: slot.protected.events.map(event => MetadataToken.nameOf(event)),\n attributes: slot.protected.attributes.map(attr => MetadataToken.nameOf(attr)),\n style: slot.protected.style,\n },\n }\n}\n","/**\n * Slot contracts. Ported from `effect-atom-jsx/src/View.ts` `Slots.define`,\n * without minting element Handles. Names come from keys. Entries may be\n * `Slot.make({...})` or AF-UI option objects `{ capability, allowedEvents }`.\n */\nimport * as Capability from './capability.js'\nimport * as Slot from './slot.js'\nimport type {\n Any as AnySlot,\n MakeOptions,\n Slot as NamedSlot,\n SlotCapability,\n UnnamedSlot,\n} from './slot.js'\n\nexport const SlotsTypeId: unique symbol = Symbol.for('foldkit-mixins/Slots')\n\nexport type Contract<S extends { readonly [K in keyof S]: UnnamedSlot | MakeOptions }> = {\n readonly [K in keyof S]: S[K] extends UnnamedSlot<\n infer C,\n infer Events,\n infer Attributes,\n infer Requirements,\n infer Hidden\n >\n ? NamedSlot<K & string, C, Events, Attributes, Requirements, Hidden>\n : S[K] extends MakeOptions<\n infer C,\n infer Events,\n infer Attributes,\n infer Requirements,\n infer Hidden\n >\n ? NamedSlot<K & string, C, Events, Attributes, Requirements, Hidden>\n : never\n}\n\nexport type NamesOf<T> = keyof T & string\nexport type PublicNamesOf<T> = {\n readonly [K in keyof T & string]: Slot.HiddenOf<T[K]> extends true ? never : K\n}[keyof T & string]\nexport type HiddenNamesOf<T> = {\n readonly [K in keyof T & string]: Slot.HiddenOf<T[K]> extends true ? K : never\n}[keyof T & string]\nexport type WithCapability<T, C extends SlotCapability> = {\n readonly [\n K in keyof T & string as Capability.NameOf<C> extends Slot.AssignableCapabilityNamesOf<T[K]>\n ? K\n : never\n ]: T[K]\n}\n\nconst toUnnamed = (value: unknown, key: string): UnnamedSlot => {\n if (Slot.is(value)) {\n return value as UnnamedSlot\n }\n if (typeof value === 'object' && value !== null && Object.hasOwn(value, 'capability')) {\n return Slot.make(value as MakeOptions)\n }\n throw new Error(`Slots.define: \"${key}\" is not a Slot or slot options object`)\n}\n\nexport const define = <const S extends { readonly [K in keyof S]: UnnamedSlot | MakeOptions }>(\n spec: S,\n): Contract<S> => {\n const proto = Object.getPrototypeOf(spec)\n if (proto !== Object.prototype && proto !== null) {\n throw new Error(\n 'Slots.define: pass a plain object; quote [\"__proto__\"] to use that as a slot name',\n )\n }\n const contract = Object.create(null) as Record<string, NamedSlot>\n for (const key of Object.getOwnPropertyNames(spec)) {\n const unnamed = toUnnamed((spec as Record<string, unknown>)[key], key)\n Object.defineProperty(contract, key, {\n value: Slot.make(key, {\n capability: unnamed.capability,\n events: unnamed.events,\n attributes: unnamed.attributes,\n requirements: unnamed.requirements,\n hidden: unnamed.hidden,\n protected: unnamed.protected,\n }),\n enumerable: true,\n configurable: false,\n writable: false,\n })\n }\n Object.freeze(contract)\n return contract as unknown as Contract<S>\n}\n\nexport const describe = (contract: {\n readonly [key: string]: AnySlot | UnnamedSlot\n}): {\n readonly slots: Readonly<\n Record<\n string,\n {\n readonly name: string\n readonly capability: string\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly requirements: ReadonlyArray<string>\n readonly hidden: boolean\n readonly protected: {\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly style: ReadonlyArray<string>\n }\n }\n >\n >\n} => {\n const slots: Record<string, ReturnType<typeof Slot.describe> & { readonly name: string }> =\n Object.create(null)\n for (const key of Object.getOwnPropertyNames(contract)) {\n const slot = contract[key]\n if (slot === undefined || !Slot.is(slot)) continue\n const described = Slot.describe(slot)\n slots[key] = {\n ...described,\n name: slot.name !== undefined && slot.name !== '' ? slot.name : key,\n }\n }\n return { slots }\n}\n\nexport const withCapability = <\n T extends { readonly [key: string]: AnySlot },\n C extends SlotCapability,\n>(\n contract: T,\n capability: C,\n): WithCapability<T, C> => {\n const out = Object.create(null) as Record<string, AnySlot>\n for (const key of Object.getOwnPropertyNames(contract)) {\n const slot = contract[key]\n if (slot === undefined || !Slot.is(slot)) continue\n if (Capability.extendsCapability(slot.capability, capability)) {\n out[key] = slot\n }\n }\n return out as WithCapability<T, C>\n}\n","/**\n * Deterministic compilation of rule-based Style. A rule selector is written\n * relative to the generated class with `&` (`&:hover`). The class name is an\n * FNV-1a hash of the canonical rule text, so equal rules share a class and the\n * server and the browser derive the same name. Pure data in, CSS text out: no\n * registry, no DOM, no `Date.now`.\n */\nexport interface StyleRule {\n readonly selector: string\n readonly at?: string\n readonly declarations: Readonly<Record<string, string>>\n}\n\nexport const rule = (\n selector: string,\n declarations: Readonly<Record<string, string>>,\n at?: string,\n): StyleRule =>\n Object.freeze({\n selector,\n declarations: Object.freeze({ ...declarations }),\n ...(at === undefined ? {} : { at }),\n })\n\nexport const pseudo = (suffix: string, declarations: Readonly<Record<string, string>>): StyleRule =>\n rule(`&${suffix}`, declarations)\n\nexport const media = (query: string, declarations: Readonly<Record<string, string>>): StyleRule =>\n rule('&', declarations, `@media ${query}`)\n\nexport const supports = (\n condition: string,\n declarations: Readonly<Record<string, string>>,\n): StyleRule => rule('&', declarations, `@supports ${condition}`)\n\nexport const container = (\n condition: string,\n declarations: Readonly<Record<string, string>>,\n): StyleRule => rule('&', declarations, `@container ${condition}`)\n\n/** A nested selector relative to the class, e.g. `> span` or `[data-open] &`. */\nexport const nest = (selector: string, declarations: Readonly<Record<string, string>>): StyleRule =>\n rule(`& ${selector}`, declarations)\n\n/** `gridTemplateColumns` -> `grid-template-columns`; custom properties pass through. */\nconst kebab = (property: string): string =>\n property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)\n\nconst declarationsText = (declarations: Readonly<Record<string, string>>): string =>\n Object.keys(declarations)\n .sort()\n .map(property => `${kebab(property)}:${declarations[property]}`)\n .join(';')\n\n/** Canonical, declaration-sorted, authored-rule-order text for a rule list. */\nexport const canonical = (rules: ReadonlyArray<StyleRule>): string =>\n rules\n .map(entry => {\n const body = `{${declarationsText(entry.declarations)}}`\n return entry.at === undefined\n ? `${entry.selector}${body}`\n : `${entry.at}{${entry.selector}${body}}`\n })\n .join('')\n\nconst hash = (value: string): string => {\n let state = 2166136261\n for (let index = 0; index < value.length; index++) {\n state ^= value.charCodeAt(index)\n state = Math.imul(state, 16777619)\n }\n return (state >>> 0).toString(36)\n}\n\nexport interface Keyframes {\n readonly name: string\n readonly css: string\n}\n\n/** Deterministic `@keyframes`: step order is authored, declarations sorted. */\nexport const keyframes = (\n frames: Readonly<Record<string, Readonly<Record<string, string>>>>,\n): Keyframes => {\n const body = Object.entries(frames)\n .map(([step, declarations]) => `${step}{${declarationsText(declarations)}}`)\n .join('')\n const name = `kf-${hash(body)}`\n return Object.freeze({ name, css: `@keyframes ${name}{${body}}` })\n}\n\nexport const className = (rules: ReadonlyArray<StyleRule>): string =>\n `style-${hash(canonical(rules))}`\n\nconst selectorFor = (generated: string, selector: string): string =>\n selector.includes('&') ? selector.replace(/&/g, `.${generated}`) : `.${generated} ${selector}`\n\nexport const css = (generated: string, rules: ReadonlyArray<StyleRule>): string =>\n rules\n .map(entry => {\n const body = `{${declarationsText(entry.declarations)}}`\n const selector = `${selectorFor(generated, entry.selector)}${body}`\n return entry.at === undefined ? selector : `${entry.at}{${selector}}`\n })\n .join('')\n","/**\n * `Style` is pure data: class tokens and inline declarations that compile to a\n * `SlotContribution`. It never touches the DOM and never mutates state.\n * `forSlots` validates piece keys against the published contract at definition\n * time, so a typo fails loudly.\n */\nimport type { InputContribution, SlotContribution } from './contribution.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport * as Mixin from './mixin.js'\nimport type { Mixin as MixinValue } from './mixin.js'\nimport type { HiddenOf } from './slot.js'\nimport * as SlotView from './slotView.js'\nimport * as Rules from './styleRules.js'\nimport type { StyleRule } from './styleRules.js'\n\nexport interface StyleValue {\n readonly classes: ReadonlyArray<string>\n readonly style: Readonly<Record<string, string>>\n /** Input-driven pieces resolved at render time; empty for a static style. */\n readonly conditions?: ReadonlyArray<StyleCondition>\n /** Rule-based appearance compiled to a deterministic class plus CSS. */\n readonly rules?: ReadonlyArray<StyleRule>\n /** Class-independent CSS (keyframes, layers, global rules). */\n readonly globalCss?: ReadonlyArray<string>\n}\n\nexport interface StyleCondition {\n readonly predicate: (input: unknown) => boolean\n readonly piece: StyleValue\n}\n\n/** A hidden slot is internal: it is neither styleable nor behavior-targetable. */\nexport type StylePieces<Slots> = {\n readonly [K in keyof Slots as HiddenOf<Slots[K]> extends true ? never : K]?: StyleValue\n}\n\nexport interface NamedStyle<Slots> {\n readonly name?: string\n readonly pieces: StylePieces<Slots>\n readonly mixin: MixinValue<never>\n /** Concatenated rule CSS for every static piece. */\n readonly css: string\n /** Concatenated class-independent CSS (keyframes, layers, global rules). */\n readonly globalCss: string\n /** One entry per generated class, for a deduplicating stylesheet. */\n readonly rules: ReadonlyArray<{ readonly className: string; readonly css: string }>\n /** Class-independent rule chunks, for a deduplicating stylesheet. */\n readonly globalRules: ReadonlyArray<string>\n}\n\nconst tokens = (value: string): ReadonlyArray<string> =>\n value.split(/\\s+/).filter(token => token.length > 0)\n\nexport const empty: StyleValue = Object.freeze({\n classes: Object.freeze([]) as ReadonlyArray<string>,\n style: Object.freeze({}) as Readonly<Record<string, string>>,\n})\n\nexport const classPiece = (value: string): StyleValue =>\n Object.freeze({ classes: Object.freeze(tokens(value)), style: empty.style })\n\nexport const inline = (value: Readonly<Record<string, string>>): StyleValue =>\n Object.freeze({ classes: empty.classes, style: Object.freeze({ ...value }) })\n\n/** Concatenate classes; later inline declarations win per property. */\nexport const compose = (...pieces: ReadonlyArray<StyleValue>): StyleValue => {\n const conditions = pieces.flatMap(piece => piece.conditions ?? [])\n const rules = pieces.flatMap(piece => piece.rules ?? [])\n const globalCss = pieces.flatMap(piece => piece.globalCss ?? [])\n return Object.freeze({\n classes: Object.freeze(pieces.flatMap(piece => piece.classes)),\n style: Object.freeze(Object.assign(Object.create(null), ...pieces.map(piece => piece.style))),\n ...(conditions.length === 0 ? {} : { conditions: Object.freeze(conditions) }),\n ...(rules.length === 0 ? {} : { rules: Object.freeze(rules) }),\n ...(globalCss.length === 0 ? {} : { globalCss: Object.freeze(globalCss) }),\n })\n}\n\n/** A pseudo-class/element rule, e.g. `Style.pseudo(':hover', { color: 'red' })`. */\nexport const pseudo = (\n suffix: string,\n declarations: Readonly<Record<string, string>>,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.pseudo(suffix, declarations)]),\n })\n\n/** An at-rule, e.g. `Style.media('(min-width: 40rem)', { color: 'red' })`. */\nexport const media = (query: string, declarations: Readonly<Record<string, string>>): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.media(query, declarations)]),\n })\n\n/** An at-rule, e.g. `Style.supports('(display: grid)', { display: 'grid' })`. */\nexport const supports = (\n condition: string,\n declarations: Readonly<Record<string, string>>,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.supports(condition, declarations)]),\n })\n\n/** A container query, e.g. `Style.container('(min-width: 30rem)', {...})`. */\nexport const container = (\n condition: string,\n declarations: Readonly<Record<string, string>>,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.container(condition, declarations)]),\n })\n\n/** A nested selector relative to the generated class, e.g. `Style.nest('> span', {...})`. */\nexport const nest = (\n selector: string,\n declarations: Readonly<Record<string, string>>,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.nest(selector, declarations)]),\n })\n\n/**\n * A deterministic `@keyframes` block. Compose `style` where the animation is\n * declared and reference `name` in an `animation` declaration.\n */\nexport const keyframes = (\n frames: Readonly<Record<string, Readonly<Record<string, string>>>>,\n): { readonly name: string; readonly style: StyleValue } => {\n const compiled = Rules.keyframes(frames)\n return Object.freeze({\n name: compiled.name,\n style: Object.freeze({\n classes: empty.classes,\n style: empty.style,\n globalCss: Object.freeze([compiled.css]),\n }),\n })\n}\n\n/** Raw class-independent CSS (a layer, a global rule). Prefer typed helpers. */\nexport const global = (css: string): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n globalCss: Object.freeze([css]),\n })\n\n/** A boolean known at authoring time. */\nexport const when = (condition: boolean, piece: StyleValue): StyleValue =>\n condition ? piece : empty\n\n/** A condition read from the view input at render time. The piece applies when\n * `predicate` returns true for the input the view was rendered with. */\nexport const whenInput = <Input>(\n predicate: (input: Input) => boolean,\n piece: StyleValue,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n conditions: Object.freeze([\n { predicate: (input: unknown) => predicate(input as Input), piece },\n ]),\n })\n\n/** Fold every active condition (recursively) into a condition-free style. */\nconst resolveStyle = (style: StyleValue, input: unknown): StyleValue => {\n const active = (style.conditions ?? [])\n .filter(condition => condition.predicate(input))\n .map(condition => resolveStyle(condition.piece, input))\n return Object.freeze({\n classes: Object.freeze([...style.classes, ...active.flatMap(piece => piece.classes)]),\n style: Object.freeze(\n Object.assign(Object.create(null), style.style, ...active.map(piece => piece.style)),\n ),\n })\n}\n\nconst hasConditionalRules = (style: StyleValue): boolean =>\n (style.conditions ?? []).some(\n condition => (condition.piece.rules ?? []).length > 0 || hasConditionalRules(condition.piece),\n )\n\ninterface CompiledStyle {\n readonly classes: ReadonlyArray<string>\n readonly style: Readonly<Record<string, string>>\n readonly css?: string\n readonly ruleClass?: string\n readonly globalRules?: ReadonlyArray<string>\n}\n\n/** Global CSS is emitted whether or not its condition is active. */\nconst collectGlobalCss = (style: StyleValue): ReadonlyArray<string> => [\n ...(style.globalCss ?? []),\n ...(style.conditions ?? []).flatMap(condition => collectGlobalCss(condition.piece)),\n]\n\n/** A rule-bearing style gets one deterministic class and its CSS text. */\nconst compileStyle = (style: StyleValue): CompiledStyle => {\n const rules = style.rules ?? []\n const globalRules = collectGlobalCss(style)\n const generated = rules.length === 0 ? undefined : Rules.className(rules)\n return {\n classes: generated === undefined ? style.classes : Object.freeze([...style.classes, generated]),\n style: style.style,\n ...(generated === undefined ? {} : { css: Rules.css(generated, rules), ruleClass: generated }),\n ...(globalRules.length === 0 ? {} : { globalRules }),\n }\n}\n\n/** A rule's class is static while a `whenInput` condition is not, so they cannot combine. */\nconst assertRulesSupported = (style: StyleValue): void => {\n if (!hasConditionalRules(style)) return\n throw new DiagnosticError({\n source: 'mixins',\n code: 'style:conditional-rules-unsupported',\n severity: 'error',\n message: 'Style.pseudo/media may not appear inside Style.whenInput',\n })\n}\n\n/**\n * A static style stays static data; a style with input conditions compiles to a\n * message-free `InputContribution`, so it still attaches to any view.\n */\nconst contributionFrom = (style: StyleValue, compiled: CompiledStyle): SlotContribution<never> => {\n const globalCss = compiled.globalRules?.join('')\n const attributes = {\n classes: compiled.classes,\n style: compiled.style,\n ...(compiled.css === undefined ? {} : { css: compiled.css }),\n ...(globalCss === undefined ? {} : { globalCss }),\n }\n if ((style.conditions ?? []).length === 0) return Object.freeze(attributes)\n const contribution: InputContribution<never> = context => {\n const resolved = resolveStyle({ ...style, classes: compiled.classes }, context.input)\n return Object.freeze({\n classes: resolved.classes,\n style: resolved.style,\n ...(compiled.css === undefined ? {} : { css: compiled.css }),\n ...(globalCss === undefined ? {} : { globalCss }),\n })\n }\n return contribution\n}\n\nexport const forSlots =\n <Slots>(slots: Slots) =>\n (pieces: StylePieces<Slots>, options?: { readonly name?: string }): NamedStyle<Slots> => {\n const known = slots as unknown as Record<string, unknown>\n const contributions: Record<string, SlotContribution<never>> = Object.create(null)\n const rules: Array<{ className: string; css: string }> = []\n const globalRules: Array<string> = []\n let css = ''\n let globalCss = ''\n for (const [key, piece] of Object.entries(pieces as Record<string, StyleValue | undefined>)) {\n if (!Object.hasOwn(known, key)) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:unknown-slot',\n severity: 'error',\n message: `Style targets unknown slot \"${key}\"`,\n slot: key,\n })\n }\n if ((known[key] as { readonly hidden?: boolean } | undefined)?.hidden === true) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:hidden-slot',\n severity: 'error',\n message: `Style targets hidden slot \"${key}\"`,\n slot: key,\n })\n }\n if (piece !== undefined) {\n // Rule and global CSS are static even when the contribution is deferred,\n // so compile once, then build the contribution and gather the CSS.\n assertRulesSupported(piece)\n const compiled = compileStyle(piece)\n contributions[key] = contributionFrom(piece, compiled)\n if (compiled.ruleClass !== undefined && compiled.css !== undefined) {\n rules.push({ className: compiled.ruleClass, css: compiled.css })\n css += compiled.css\n }\n if (compiled.globalRules !== undefined) {\n globalRules.push(...compiled.globalRules)\n globalCss += compiled.globalRules.join('')\n }\n }\n }\n return Object.freeze({\n ...(options?.name === undefined ? {} : { name: options.name }),\n pieces,\n mixin: Mixin.dynamic<never>(options?.name ?? 'Style', contributions),\n css,\n globalCss,\n rules: Object.freeze(rules),\n globalRules: Object.freeze(globalRules),\n })\n }\n\n/** Deduplicated global then scoped CSS for one `<style>` block, first seen wins. */\nexport const stylesheet = (\n ...styles: ReadonlyArray<{\n readonly rules: ReadonlyArray<{ readonly className: string; readonly css: string }>\n readonly globalRules: ReadonlyArray<string>\n }>\n): string => {\n const scoped = new Map<string, string>()\n const global = new Set<string>()\n for (const style of styles) {\n for (const rule of style.rules) {\n if (!scoped.has(rule.className)) scoped.set(rule.className, rule.css)\n }\n for (const rule of style.globalRules) global.add(rule)\n }\n return [...global, ...scoped.values()].join('')\n}\n\nexport const attach =\n <Slots>(style: NamedStyle<Slots>) =>\n <ViewSlots, Input, Message>(\n view: SlotView.SlotView<ViewSlots, Input, Message>,\n ): SlotView.SlotView<ViewSlots, Input, Message> =>\n SlotView.attach(style.mixin)(view)\n\nexport type RecipeVariantDef = Readonly<Record<string, StyleValue>>\n\n/** A combination style applied when every `when` entry matches the selection. */\nexport interface RecipeCompound<Variants extends Readonly<Record<string, RecipeVariantDef>>> {\n readonly when: Partial<{ readonly [K in keyof Variants]: keyof Variants[K] & string }>\n readonly style: StyleValue\n}\n\nexport interface RecipeDef<Variants extends Readonly<Record<string, RecipeVariantDef>>> {\n readonly base?: StyleValue\n readonly variants: Variants\n readonly defaults?: { readonly [K in keyof Variants]?: keyof Variants[K] & string }\n readonly compound?: ReadonlyArray<RecipeCompound<Variants>>\n}\n\nexport type AnyRecipeDef = RecipeDef<Record<string, RecipeVariantDef>>\n\nexport type RecipeSelection<D extends AnyRecipeDef> = {\n readonly [K in keyof D['variants']]?: keyof D['variants'][K] & string\n}\n\n/** A recipe is just Style data: base, one piece per selected variant, then any\n * matching compound. `compound.when` is keyed by the recipe's variants, so a\n * typo is a compile error rather than a silently dead combination. */\nexport const recipe =\n <Variants extends Readonly<Record<string, RecipeVariantDef>>>(def: RecipeDef<Variants>) =>\n (selection: RecipeSelection<RecipeDef<Variants>>): StyleValue => {\n const pieces: Array<StyleValue> = []\n if (def.base !== undefined) pieces.push(def.base)\n const effective: Record<string, string> = {}\n for (const [variant, values] of Object.entries(def.variants)) {\n const chosen =\n (selection as Record<string, string | undefined>)[variant] ??\n (def.defaults as Record<string, string | undefined> | undefined)?.[variant]\n if (chosen === undefined) continue\n effective[variant] = chosen\n const piece = (values as Record<string, StyleValue>)[chosen]\n if (piece !== undefined) pieces.push(piece)\n }\n for (const compound of def.compound ?? []) {\n if (Object.entries(compound.when).every(([variant, value]) => effective[variant] === value)) {\n pieces.push(compound.style)\n }\n }\n return compose(...pieces)\n }\n\nexport const Style = {\n class: classPiece,\n inline,\n compose,\n when,\n whenInput,\n pseudo,\n media,\n supports,\n container,\n nest,\n keyframes,\n global,\n empty,\n forSlots,\n attach,\n recipe,\n stylesheet,\n} as const\n","/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport type { StyleValue } from './style.js'\nimport { inline } from './style.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nconst VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\nexport const variable = <T extends ThemeTokens, G extends keyof T & string>(\n _theme: T,\n group: G,\n name: keyof T[G] & string,\n): string => `var(${VAR_PREFIX}-${group}-${name})`\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<string, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\nexport const Theme = { define, variable, variables } as const\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAa,sBAAqC,OAAO,IAAI,8BAA8B;AAoB3F,MAAaA,UACX,MACA,SAC8B;CAC9B,IAAI,SAAS,IACX,MAAM,IAAI,MAAM,GAAG,KAAK,wBAAwB;CAElD,OAAO;GACJ,sBAAsB;GACrB,MAA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AS,KAAK;CAG9B,OAAO,QAAQ,GAAG,MAAM;AAC1B;AAEF,MAAa,QAAQ;CACnB,OAAO;CACP;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;AClYA,MAAM,aAAa;AAEnB,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAEF,MAAa,YACX,QACA,OACA,SACW,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK;AAEhD,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAU;AAAU"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["make","is","is","MetadataToken.is","make","MetadataToken.nameOf","MetadataToken.make","describe","MetadataToken.nameOf","Capability.extendsCapability","is","MetadataToken.is","make","MetadataToken.make","equals","describe","ih","make","MetadataToken.nameOf","define","attach","Capability.extendsCapability","MetadataToken.nameOf","forSlots","Mixin.dynamic","attach","SlotView.attach","behavior","Behavior.forSlots","Behavior.slot","behavior","Behavior.forSlots","Behavior.slot","Capability.Interactive","Capability.Container","behavior","Behavior.forSlots","Behavior.slot","Capability.Interactive","behavior","Behavior.forSlots","Behavior.slot","Capability.Focusable","Behavior.forSlots","Behavior.slot","Capability.Interactive","is","MetadataToken.is","make","MetadataToken.make","describe","is","MetadataToken.is","make","MetadataToken.make","describe","is","Capability.Base","describe","MetadataToken.nameOf","Slot.is","Slot.make","Slot.describe","Capability.extendsCapability","empty","Rules.className","Rules.css","Mixin.dynamic","SlotView.attach","compose","Capability.extendsCapability"],"sources":["../src/metadataToken.ts","../src/capability.ts","../src/a11y.ts","../src/attr.ts","../src/attribute.ts","../src/attributes.ts","../src/mixin.ts","../src/pipe.ts","../src/resolver.ts","../src/slotView.ts","../src/behavior.ts","../src/behaviors/collection.ts","../src/behaviors/disclosure.ts","../src/behaviors/field-association.ts","../src/behaviors/spin-value.ts","../src/behaviors/toggle-state.ts","../src/behaviors/index.ts","../src/event.ts","../src/requirement.ts","../src/selector.ts","../src/slot.ts","../src/slots.ts","../src/style.ts"],"sourcesContent":["/**\n * Ported from `effect-atom-jsx/src/MetadataToken.ts`. Kinded name tokens so\n * Event, Attr, Requirement, and Capability share one witness instead of four\n * ad-hoc brands.\n */\nexport const MetadataTokenTypeId: unique symbol = Symbol.for('foldkit-mixins/MetadataToken')\n\nexport interface MetadataToken<Kind extends string, Name extends string> {\n readonly [MetadataTokenTypeId]: {\n readonly Kind: Kind\n readonly Name: Name\n }\n readonly kind: Kind\n readonly name: Name\n}\n\nexport type Any = MetadataToken<string, string>\n\nexport type NameOf<T> =\n T extends MetadataToken<any, infer Name> ? Name : T extends string ? T : never\n\nexport type KindOf<T> = T extends MetadataToken<infer Kind, any> ? Kind : never\n\nexport type NamesOf<T extends readonly unknown[]> = NameOf<T[number]>\n\nexport const make = <const Kind extends string, const Name extends string>(\n kind: Kind,\n name: Name,\n): MetadataToken<Kind, Name> => {\n if (name === '') {\n throw new Error(`${kind} name must be non-empty`)\n }\n return {\n [MetadataTokenTypeId]: {\n Kind: undefined as unknown as Kind,\n Name: undefined as unknown as Name,\n },\n kind,\n name,\n }\n}\n\nexport const is = (value: unknown): value is Any =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, MetadataTokenTypeId)\n\nexport const nameOf = (value: string | Any): string => (is(value) ? value.name : value)\n","/**\n * Ported from `effect-atom-jsx/src/Element.ts` `Capability`, without Handle\n * objects. Inheritance is metadata: a behavior that needs Interactive can\n * attach to TextInput. Lookups go through a Map so `__proto__` is a legal name.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type CapabilityParent = string | MetadataToken.MetadataToken<'element.capability', string>\n\nexport interface Capability<\n Name extends string = string,\n Extends extends readonly CapabilityParent[] = readonly [],\n> extends MetadataToken.MetadataToken<'element.capability', Name> {\n readonly extends: Extends\n}\n\nexport type Any = Capability<string, readonly CapabilityParent[]>\nexport type NameOf<T> = MetadataToken.NameOf<T>\nexport type NamesOf<T extends readonly unknown[]> = MetadataToken.NamesOf<T>\nexport type ExtendsOf<T> =\n T extends Capability<any, infer Extends> ? MetadataToken.NameOf<Extends[number]> : never\nexport type AssignableNamesOf<T> = T extends string\n ? T\n : T extends Capability<any, infer Extends>\n ? MetadataToken.NameOf<T> | AssignableNamesOf<Extends[number]>\n : MetadataToken.NameOf<T>\n\nexport type Satisfies<Actual, Required extends { readonly name: string }> =\n Required['name'] extends AssignableNamesOf<Actual> ? true : false\n\nconst parentsByName = new Map<string, ReadonlyArray<string>>()\nconst registry = new Map<string, Any>()\n\nexport const is = (value: unknown): value is Any =>\n MetadataToken.is(value) && value.kind === 'element.capability'\n\nexport const make = <\n const Name extends string,\n const Extends extends readonly CapabilityParent[] = readonly [],\n>(\n name: Name,\n options?: { readonly extends?: Extends },\n): Capability<Name, Extends> => {\n if (name === '') {\n throw new Error('Capability name must be non-empty')\n }\n const parents = (options?.extends ?? []) as Extends\n const parentNames = parents.map(parent => MetadataToken.nameOf(parent))\n const existing = registry.get(name)\n if (existing !== undefined) {\n const existingNames = existing.extends.map(parent => MetadataToken.nameOf(parent))\n if (\n existingNames.length === parentNames.length &&\n existingNames.every((parentName, index) => parentName === parentNames[index])\n ) {\n return existing as Capability<Name, Extends>\n }\n throw new Error(`Capability \"${name}\" is already defined with a different extends list`)\n }\n parentsByName.set(name, parentNames)\n const capability: Capability<Name, Extends> = {\n ...MetadataToken.make('element.capability', name),\n extends: Object.freeze([...parents]) as Extends,\n }\n registry.set(name, capability)\n return Object.freeze(capability)\n}\n\n/** True when `value` is `base` or inherits from it. Ported from AF-UI. */\nexport const extendsCapability = (value: string | Any, base: string | Any): boolean => {\n const valueName = MetadataToken.nameOf(value)\n const baseName = MetadataToken.nameOf(base)\n if (valueName === baseName) return true\n const visited = new Set<string>()\n const stack = [...(parentsByName.get(valueName) ?? [])]\n while (stack.length > 0) {\n const current = stack.pop()\n if (current === undefined) continue\n if (current === baseName) return true\n if (visited.has(current)) continue\n visited.add(current)\n stack.push(...(parentsByName.get(current) ?? []))\n }\n return false\n}\n\nexport const satisfies = (actual: string | Any, required: string | Any): boolean =>\n extendsCapability(actual, required)\n\nexport const names = (capability: Any): ReadonlyArray<string> => {\n const seen = new Set<string>()\n const walk = (name: string) => {\n if (seen.has(name)) return\n seen.add(name)\n for (const parent of parentsByName.get(name) ?? []) walk(parent)\n }\n walk(capability.name)\n return [...seen]\n}\n\nexport const describe = (\n capability: Any,\n): { readonly name: string; readonly extends: ReadonlyArray<string> } => ({\n name: capability.name,\n extends: capability.extends.map(parent => MetadataToken.nameOf(parent)),\n})\n\nexport const Base = make('Base')\nexport const Interactive = make('Interactive', { extends: [Base] })\nexport const Container = make('Container', { extends: [Interactive] })\nexport const Focusable = make('Focusable', { extends: [Interactive] })\nexport const TextInput = make('TextInput', { extends: [Focusable] })\nexport const Draggable = make('Draggable', { extends: [Interactive] })\nexport const Collection = make('Collection', { extends: [Base] })\n","/**\n * Structural accessibility validation. A `Pattern` names the Slots a widget\n * must publish, the capabilities those Slots must satisfy, and the events and\n * attributes they must expose. `validate` compares a `Slots` contract against a\n * pattern and reports every mismatch as a `Diagnostic`. It is pure and\n * DOM-independent: it checks the declared contract, not a rendered tree, so it\n * verifies only the contract it is given and does not certify WCAG conformance.\n */\nimport * as Capability from './capability.js'\nimport type { Diagnostic } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport type { Any as AnySlot, AttributeName, EventName, SlotCapability } from './slot.js'\n\nexport type A11yDiagnosticCode =\n | 'a11y:missing-slot'\n | 'a11y:hidden-slot'\n | 'a11y:capability-mismatch'\n | 'a11y:missing-event'\n | 'a11y:missing-attribute'\n\nexport interface A11yDiagnostic extends Diagnostic {\n readonly source: 'a11y'\n readonly code: A11yDiagnosticCode\n}\n\nexport interface SlotRequirement {\n readonly capability?: SlotCapability\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n /** An absent slot is expected, not a diagnostic. A present slot is still checked. */\n readonly optional?: boolean\n}\n\nexport type Requirements = Readonly<Record<string, SlotRequirement>>\n\nexport const PatternTypeId: unique symbol = Symbol.for('foldkit-mixins/A11yPattern')\n\nexport interface Pattern<Spec extends Requirements = Requirements> {\n readonly [PatternTypeId]: { readonly Requirements: Spec }\n readonly requirements: Spec\n}\n\nexport const pattern = <const Spec extends Requirements>(spec: Spec): Pattern<Spec> => {\n const requirements = Object.create(null) as Record<string, SlotRequirement>\n for (const name of Object.getOwnPropertyNames(spec)) {\n const requirement = spec[name]\n if (requirement === undefined) continue\n Object.defineProperty(requirements, name, {\n value: Object.freeze({ ...requirement }),\n enumerable: true,\n configurable: false,\n writable: false,\n })\n }\n Object.freeze(requirements)\n return Object.freeze({\n [PatternTypeId]: { Requirements: undefined as unknown as Spec },\n requirements: requirements as Spec,\n }) as Pattern<Spec>\n}\n\nconst publishes = (\n names: ReadonlyArray<string | MetadataToken.Any>,\n required: string | MetadataToken.Any,\n): boolean => {\n const requiredName = MetadataToken.nameOf(required)\n return names.some(name => MetadataToken.nameOf(name) === requiredName)\n}\n\nconst diagnostic = (\n code: A11yDiagnosticCode,\n message: string,\n slot: string,\n details?: Readonly<Record<string, unknown>>,\n): A11yDiagnostic => ({\n source: 'a11y',\n code,\n severity: 'error',\n message,\n slot,\n ...(details === undefined ? {} : { details }),\n})\n\nexport const validate = (\n pattern: Pattern,\n slots: { readonly [name: string]: AnySlot },\n): ReadonlyArray<A11yDiagnostic> => {\n const diagnostics: Array<A11yDiagnostic> = []\n for (const name of Object.getOwnPropertyNames(pattern.requirements)) {\n const requirement = pattern.requirements[name]\n if (requirement === undefined) continue\n if (!Object.hasOwn(slots, name)) {\n if (requirement.optional === true) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-slot',\n `A11y pattern requires slot \"${name}\", which the contract does not publish`,\n name,\n ),\n )\n continue\n }\n const slot = slots[name]\n if (slot === undefined) continue\n if (slot.hidden) {\n diagnostics.push(\n diagnostic(\n 'a11y:hidden-slot',\n `A11y pattern requires slot \"${name}\", which is hidden`,\n name,\n ),\n )\n continue\n }\n if (\n requirement.capability !== undefined &&\n !Capability.extendsCapability(slot.capability, requirement.capability)\n ) {\n diagnostics.push(\n diagnostic(\n 'a11y:capability-mismatch',\n `A11y pattern requires capability \"${MetadataToken.nameOf(requirement.capability)}\" on slot \"${name}\", which has \"${MetadataToken.nameOf(slot.capability)}\"`,\n name,\n {\n required: MetadataToken.nameOf(requirement.capability),\n actual: MetadataToken.nameOf(slot.capability),\n },\n ),\n )\n }\n for (const event of requirement.events ?? []) {\n const eventName = MetadataToken.nameOf(event)\n if (publishes(slot.events, event)) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-event',\n `A11y pattern requires event \"${eventName}\" on slot \"${name}\", which does not publish it`,\n name,\n { event: eventName },\n ),\n )\n }\n for (const attribute of requirement.attributes ?? []) {\n const attributeName = MetadataToken.nameOf(attribute)\n if (publishes(slot.attributes, attribute)) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-attribute',\n `A11y pattern requires attribute \"${attributeName}\" on slot \"${name}\", which does not publish it`,\n name,\n { attribute: attributeName },\n ),\n )\n }\n }\n return diagnostics\n}\n","/**\n * Slot attribute tokens. Ported from `effect-atom-jsx/src/View.ts` `Attribute`,\n * plus ARIA names the Foldkit plan lists.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type AttrToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.attribute',\n Name\n>\n\nexport const is = (value: unknown): value is AttrToken =>\n MetadataToken.is(value) && value.kind === 'view.attribute'\n\nexport const make = <const Name extends string>(name: Name): AttrToken<Name> =>\n MetadataToken.make('view.attribute', name)\n\nexport const equals = (left: AttrToken, right: AttrToken): boolean => left.name === right.name\n\nexport const describe = (attr: AttrToken): { readonly name: string } => ({\n name: attr.name,\n})\n\nexport const Role = make('role')\nexport const AriaLabel = make('aria-label')\nexport const AriaDescribedby = make('aria-describedby')\nexport const AriaExpanded = make('aria-expanded')\nexport const AriaSelected = make('aria-selected')\nexport const AriaInvalid = make('aria-invalid')\nexport const AriaDisabled = make('aria-disabled')\nexport const Disabled = make('disabled')\nexport const Value = make('value')\n","/**\n * Internal attribute helpers. Foldkit's `isChildAttribute` and the tagged\n * attribute shape are not public, so this module localizes the two casts they\n * require. Probed against foldkit 0.158.2; see docs/design/mixins-DESIGN.md.\n */\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport { inertHtml as ih } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\n\n/** The brand `childAttribute.d.ts` stamps; Foldkit's guard is not exported. */\nconst CHILD_ATTRIBUTE_BRAND = '__childAttribute'\n\nexport const isChildAttribute = (value: unknown): value is ChildAttribute =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, CHILD_ATTRIBUTE_BRAND)\n\ninterface Tagged {\n readonly _tag: string\n}\n\nexport const isTagged = (value: unknown): value is Tagged =>\n typeof value === 'object' &&\n value !== null &&\n Object.hasOwn(value, '_tag') &&\n typeof (value as { readonly _tag?: unknown })._tag === 'string'\n\n/** `Class` carries no Message, so the inert builder is the honest constructor. */\nexport const classAttribute = (value: string): Attribute<never> => ih.Class(value)\n\nexport const styleAttribute = (value: Record<string, string>): Attribute<never> => ih.Style(value)\n\n/**\n * `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing\n * mount is built directly. The shape is the same tagged value `h.OnMount`\n * produces (`{ _tag: 'OnMount', action }`).\n */\nexport const mountAttribute = <Message>(action: MountAction<Message, any>): Attribute<Message> =>\n ({ _tag: 'OnMount', action }) as Attribute<Message>\n","/**\n * Typed reads over a resolved `SlotAttributes` bundle. Foldkit's tagged\n * attribute union narrows on `_tag`, so a lookup by tag returns that variant's\n * own fields (`value`, `message`, `key`, `action`) without a cast.\n */\nimport type { Attribute } from 'foldkit/html'\nimport { isTagged } from './attribute.js'\nimport type { SlotAttributes } from './resolver.js'\n\n/** Every Foldkit attribute tag: `'Class'`, `'OnClick'`, `'DataAttribute'`, … */\nexport type Tag = Attribute<never>['_tag']\n\n/** The attribute variant carrying `T`. */\nexport type Of<Message, T extends Tag> = Extract<Attribute<Message>, { readonly _tag: T }>\n\n/** The tag of one bundle entry; `undefined` for an opaque `ChildAttribute`. */\nexport const tagOf = <Message>(attribute: SlotAttributes<Message>[number]): Tag | undefined =>\n isTagged(attribute) ? attribute._tag : undefined\n\nconst hasTag =\n <Message, T extends Tag>(tag: T) =>\n (attribute: SlotAttributes<Message>[number]): attribute is Of<Message, T> =>\n tagOf(attribute) === tag\n\n/** The first attribute with `tag`, typed as that variant. */\nexport const find = <Message, T extends Tag>(\n attributes: SlotAttributes<Message>,\n tag: T,\n): Of<Message, T> | undefined => attributes.find(hasTag<Message, T>(tag))\n\n/** Every attribute with `tag`, in bundle order. */\nexport const filter = <Message, T extends Tag>(\n attributes: SlotAttributes<Message>,\n tag: T,\n): ReadonlyArray<Of<Message, T>> => attributes.filter(hasTag<Message, T>(tag))\n","/**\n * `Mixin` is the common algebra: a named set of per-slot contributions.\n *\n * `StaticMixin` holds only static contributions, so it stays assignable to any\n * Message universe; Style uses it. `Mixin` may hold deferred contributions and\n * is tied to one Message universe; Behavior uses it. Composition is immutable\n * and keeps the deferred form when either side is deferred.\n */\nimport type {\n Contribution,\n ContributionContext,\n DynamicContribution,\n SlotContribution,\n StaticContribution,\n StaticContributionMap,\n} from './contribution.js'\n\nexport interface Mixin<Message = never> {\n readonly name: string\n readonly contributions: Contribution<Message>\n}\n\nexport interface StaticMixin<Message = never> {\n readonly name: string\n readonly contributions: StaticContributionMap<Message>\n}\n\nexport type AnyMixin = Mixin<any> | StaticMixin<any>\n\n/**\n * A Mixin acceptable in any context of `Message`. `Mixin<never>` is included\n * explicitly because a message-free dynamic Mixin (input-driven Style) does not\n * widen to `Mixin<Message>` — `HtmlBuilder` is invariant in `Message`.\n */\nexport type MixinFor<Message> = Mixin<Message> | StaticMixin<Message> | Mixin<never>\n\nexport const isDynamic = <Message>(\n contribution: SlotContribution<Message>,\n): contribution is DynamicContribution<Message> => typeof contribution === 'function'\n\nexport const evaluate = <Message>(\n contribution: SlotContribution<Message>,\n context: ContributionContext<Message>,\n): StaticContribution<Message> => (isDynamic(contribution) ? contribution(context) : contribution)\n\nconst mergeStatic = <Message>(\n left: StaticContribution<Message>,\n right: StaticContribution<Message>,\n): StaticContribution<Message> => {\n const css = `${left.css ?? ''}${right.css ?? ''}`\n const globalCss = `${left.globalCss ?? ''}${right.globalCss ?? ''}`\n return Object.freeze({\n classes: Object.freeze([...(left.classes ?? []), ...(right.classes ?? [])]),\n style: Object.freeze({ ...(left.style ?? {}), ...(right.style ?? {}) }),\n attributes: Object.freeze([...(left.attributes ?? []), ...(right.attributes ?? [])]),\n mounts: Object.freeze([...(left.mounts ?? []), ...(right.mounts ?? [])]),\n ...(css === '' ? {} : { css }),\n ...(globalCss === '' ? {} : { globalCss }),\n })\n}\n\nconst mergeSlot = <Message>(\n left: SlotContribution<Message>,\n right: SlotContribution<Message>,\n): SlotContribution<Message> => {\n if (!isDynamic(left) && !isDynamic(right)) return mergeStatic(left, right)\n return context => mergeStatic(evaluate(left, context), evaluate(right, context))\n}\n\nexport const make = <Message = never>(\n name: string,\n contributions: StaticContributionMap<Message>,\n): StaticMixin<Message> =>\n Object.freeze({ name, contributions: Object.freeze({ ...contributions }) })\n\nexport const dynamic = <Message = never>(\n name: string,\n contributions: Contribution<Message>,\n): Mixin<Message> => Object.freeze({ name, contributions: Object.freeze({ ...contributions }) })\n\nexport const empty = <Message = never>(): StaticMixin<Message> => make('Empty', {})\n\nexport const compose = <Message = never>(\n ...mixins: ReadonlyArray<MixinFor<Message>>\n): Mixin<Message> => {\n const merged: Record<string, SlotContribution<Message>> = Object.create(null)\n for (const mixin of mixins) {\n for (const [slot, contribution] of Object.entries(mixin.contributions)) {\n if (contribution === undefined) continue\n // A `Mixin<never>` may only contribute message-free data; the cast lets it\n // compose with a message-bearing Mixin under one algebra.\n const normalized = contribution as SlotContribution<Message>\n const existing = merged[slot]\n merged[slot] = existing === undefined ? normalized : mergeSlot(existing, normalized)\n }\n }\n return dynamic(mixins.length === 0 ? 'Empty' : mixins.map(mixin => mixin.name).join('+'), merged)\n}\n\nexport const contributionsFor = <Message>(\n mixin: Mixin<Message> | StaticMixin<Message>,\n slot: string,\n): SlotContribution<Message> | undefined => mixin.contributions[slot]\n","/** Ported from `effect-atom-jsx/src/View.ts` `pipeSelf`. */\nexport const pipeSelf = (self: unknown, fns: ReadonlyArray<(value: any) => any>): unknown =>\n fns.reduce((acc, fn) => fn(acc), self)\n\nexport type Pipeable<Self> = {\n pipe(): Self\n pipe(...fns: ReadonlyArray<(self: Self) => Self>): Self\n pipe<A>(ab: (self: Self) => A): A\n pipe<A, B>(ab: (self: Self) => A, bc: (a: A) => B): B\n pipe<A, B, C>(ab: (self: Self) => A, bc: (a: A) => B, cd: (b: B) => C): C\n}\n","/**\n * The deterministic resolver. `resolve` is pure: it decomposes the base\n * attributes, applies contributions in attachment order, enforces ownership\n * and protection, then emits one canonical `Class`, one `Style`, and at most\n * one `OnMount`. Conflicts throw a `DiagnosticError` before Foldkit could\n * silently chain or replace.\n */\nimport { Stream } from 'effect'\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\nimport {\n classAttribute,\n isChildAttribute,\n isTagged,\n mountAttribute,\n styleAttribute,\n} from './attribute.js'\nimport type { StaticContribution } from './contribution.js'\nimport { DiagnosticError, type Diagnostic, type DiagnosticCode } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport type { SlotProtection } from './slot.js'\n\nexport type SlotAttributes<Message> = ReadonlyArray<Attribute<Message> | ChildAttribute>\n\nexport interface ResolveOptions {\n readonly slot?: string\n readonly protected?: SlotProtection\n}\n\n/** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */\nconst normalizeName = (name: string): string => name.replace(/[^a-z0-9]/gi, '').toLowerCase()\n\n/** Attribute tags are PascalCase (`OnKeyDown`); event tokens are lowercase. */\nconst eventNameOfTag = (tag: string): string =>\n normalizeName(tag.startsWith('On') ? tag.slice(2) : tag)\n\nconst splitClasses = (value: string): ReadonlyArray<string> =>\n value.split(/\\s+/).filter(token => token.length > 0)\n\n/** `Prop`/`Attribute`/`DataAttribute`/`OnCustomEvent` are keyed individually. */\nconst ownershipKey = (tag: string, value: unknown): string => {\n if (typeof value !== 'object' || value === null) return tag\n const record = value as { readonly key?: unknown; readonly name?: unknown }\n switch (tag) {\n case 'Prop':\n case 'Attribute':\n case 'DataAttribute':\n return `${tag}:${String(record.key)}`\n case 'OnCustomEvent':\n return `${tag}:${String(record.name)}`\n default:\n return tag\n }\n}\n\nconst toDiagnostic = (\n code: DiagnosticCode,\n message: string,\n slot: string | undefined,\n details: Readonly<Record<string, unknown>>,\n): Diagnostic => ({\n source: 'mixins',\n code,\n severity: 'error',\n message,\n ...(slot === undefined ? {} : { slot }),\n details,\n})\n\nexport const resolve = <Message>(\n base: SlotAttributes<Message> | undefined,\n contributions: ReadonlyArray<StaticContribution<Message>>,\n options: ResolveOptions = {},\n): SlotAttributes<Message> => {\n const slot = options.slot\n const protection = options.protected\n const protectedEvents = new Set(\n (protection?.events ?? []).map(event => normalizeName(MetadataToken.nameOf(event))),\n )\n const protectedAttributes = new Set(\n (protection?.attributes ?? []).map(attr => normalizeName(MetadataToken.nameOf(attr))),\n )\n const protectedStyle = new Set(protection?.style ?? [])\n\n const classes: Array<string> = []\n const classSeen = new Set<string>()\n const style = new Map<string, string>()\n // Who wrote each inline style property. Style pieces layer over the base and\n // over each other (that is restyling); a Behavior's property has one owner,\n // and a Style piece may not overwrite what a Behavior set.\n const styleOwners = new Map<string, 'base' | 'style' | 'behavior'>()\n const mounts: Array<MountAction<Message, any>> = []\n const mountNames = new Map<string, number>()\n const preserved: Array<Attribute<Message> | ChildAttribute> = []\n const added: Array<Attribute<Message> | ChildAttribute> = []\n const ownedEvents = new Map<string, string>()\n const ownedAttributes = new Map<string, string>()\n\n function fail(\n code: DiagnosticCode,\n message: string,\n details: Readonly<Record<string, unknown>>,\n ): never {\n throw new DiagnosticError(toDiagnostic(code, message, slot, details))\n }\n\n const addClass = (token: string): void => {\n if (classSeen.has(token)) return\n classSeen.add(token)\n classes.push(token)\n }\n\n const writeStyle = (\n property: string,\n value: string,\n writer: 'base' | 'style' | 'behavior',\n ): void => {\n if (writer !== 'base' && protectedStyle.has(property)) {\n fail(\n 'mixins:protected-style-property',\n `slot \"${slot ?? '?'}\" protects style property \"${property}\"`,\n { property },\n )\n }\n const owner = styleOwners.get(property)\n if (\n (writer === 'behavior' && owner !== undefined) ||\n (writer === 'style' && owner === 'behavior')\n ) {\n fail(\n 'mixins:style-property-conflict',\n `two owners for style property \"${property}\": ${owner === 'base' ? 'the view' : owner === 'style' ? 'a Style' : 'a Behavior'} already sets it`,\n { property, owner, writer },\n )\n }\n if (owner === undefined || writer === 'behavior') styleOwners.set(property, writer)\n style.set(property, value)\n }\n\n const addMount = (action: MountAction<Message, any>): void => {\n const count = (mountNames.get(action.name) ?? 0) + 1\n mountNames.set(action.name, count)\n if (count > 1) {\n fail('mixins:duplicate-mount-name', `two Mounts are both named \"${action.name}\"`, {\n name: action.name,\n })\n }\n mounts.push(action)\n }\n\n const reserve = (tag: string, value: unknown): void => {\n if (tag === 'OnMount') return\n // `OnCustomEvent` is keyed by its event name, not treated as one native event.\n if (tag.startsWith('On') && tag !== 'OnCustomEvent') {\n ownedEvents.set(eventNameOfTag(tag), tag)\n return\n }\n ownedAttributes.set(ownershipKey(tag, value), tag)\n }\n\n const addBase = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n if (isTagged(inner)) reserve(inner._tag, inner)\n preserved.push(attribute)\n return\n }\n const tag = attribute._tag\n switch (tag) {\n case 'Class':\n for (const token of splitClasses(attribute.value)) addClass(token)\n return\n case 'Style':\n for (const [property, value] of Object.entries(attribute.value)) {\n writeStyle(property, value, 'base')\n }\n return\n case 'OnMount':\n addMount(attribute.action)\n return\n default:\n reserve(tag, attribute)\n preserved.push(attribute)\n }\n }\n\n const applyMixinAttribute = (attribute: Attribute<Message> | ChildAttribute): void => {\n if (isChildAttribute(attribute)) {\n const inner = (attribute as { readonly attribute?: unknown }).attribute\n if (isTagged(inner)) reserve(inner._tag, inner)\n added.push(attribute)\n return\n }\n const tag = attribute._tag\n switch (tag) {\n case 'Class':\n for (const token of splitClasses(attribute.value)) addClass(token)\n return\n case 'Style':\n // A `Style` attribute inside a contribution's attributes is a Behavior's.\n for (const [property, value] of Object.entries(attribute.value)) {\n writeStyle(property, value, 'behavior')\n }\n return\n case 'OnMount':\n addMount(attribute.action)\n return\n case 'Key':\n case 'InnerHTML':\n fail(\n 'mixins:structural-override',\n `a Mixin may not contribute \"${tag}\"; it is structural ownership`,\n { tag },\n )\n default:\n if (tag.startsWith('On') && tag !== 'OnCustomEvent') {\n const eventName = eventNameOfTag(tag)\n if (protectedEvents.has(eventName)) {\n fail('mixins:protected-event', `slot \"${slot ?? '?'}\" protects event \"${eventName}\"`, {\n tag,\n event: eventName,\n })\n }\n const owner = ownedEvents.get(eventName)\n if (owner !== undefined) {\n fail(\n 'mixins:event-conflict',\n `two owners for event \"${eventName}\": \"${owner}\" already owns it`,\n { tag, event: eventName, owner },\n )\n }\n ownedEvents.set(eventName, tag)\n } else {\n const key = ownershipKey(tag, attribute)\n if (protectedAttributes.has(normalizeName(tag))) {\n fail(\n 'mixins:protected-attribute',\n `slot \"${slot ?? '?'}\" protects attribute \"${tag}\"`,\n { tag },\n )\n }\n const owner = ownedAttributes.get(key)\n if (owner !== undefined) {\n fail(\n 'mixins:attribute-conflict',\n `two owners for \"${key}\": a ${owner} attribute already occupies it`,\n { tag, key, owner },\n )\n }\n ownedAttributes.set(key, tag)\n }\n added.push(attribute)\n }\n }\n\n for (const attribute of base ?? []) addBase(attribute)\n\n for (const contribution of contributions) {\n for (const token of contribution.classes ?? []) addClass(token)\n for (const [property, value] of Object.entries(contribution.style ?? {})) {\n writeStyle(property, value, 'style')\n }\n for (const attribute of contribution.attributes ?? []) applyMixinAttribute(attribute)\n for (const mount of contribution.mounts ?? []) addMount(mount)\n }\n\n const emitted: Array<Attribute<Message> | ChildAttribute> = []\n if (classes.length > 0) emitted.push(classAttribute(classes.join(' ')))\n if (style.size > 0) emitted.push(styleAttribute(Object.fromEntries(style)))\n emitted.push(...preserved, ...added)\n const composed = composeMounts(mounts, slot)\n if (composed !== undefined) emitted.push(composed)\n return emitted\n}\n\nconst composeMounts = <Message>(\n mounts: ReadonlyArray<MountAction<Message, any>>,\n slot: string | undefined,\n): Attribute<Message> | undefined => {\n const first = mounts[0]\n if (first === undefined) return undefined\n if (mounts.length === 1) return mountAttribute(first)\n const name = `Mixins[${slot ?? 'slot'}](${mounts.map(mount => mount.name).join(',')})`\n return mountAttribute({\n name,\n args: {\n slot: slot ?? null,\n actions: mounts.map(mount => ({ name: mount.name, args: mount.args })),\n },\n f: (element, viewStateChanges) =>\n Stream.mergeAll(\n mounts.map(mount => mount.f(element, viewStateChanges)),\n { concurrency: 'unbounded' },\n ),\n })\n}\n","/**\n * `SlotView` is the structural equivalent of a Surface: a pure Foldkit view\n * that publishes typed Slots and lets Mixins attach without forking it. It\n * owns no state and runs no Effects. Attached Mixins are resolved into\n * ordinary Foldkit attributes per slot, using the view's own `h` so Message\n * capability masking is preserved.\n */\nimport { inertHtml, type Html, type HtmlBuilder } from 'foldkit/html'\nimport type { SlotContribution, SlotItem } from './contribution.js'\nimport { evaluate, type AnyMixin, type Mixin, type MixinFor, type StaticMixin } from './mixin.js'\nimport { pipeSelf, type Pipeable } from './pipe.js'\nimport { resolve, type SlotAttributes } from './resolver.js'\nimport type { Any as AnySlot, SlotProtection } from './slot.js'\n\nexport type SlotBuilder<Message> = {\n /**\n * The view's base attributes plus every resolved contribution. Pass `item`\n * when the slot is rendered once per item, so a Behavior can decorate each\n * repetition differently.\n */\n readonly attrs: (base?: SlotAttributes<Message>, item?: SlotItem) => SlotAttributes<Message>\n}\n\nexport type SlotBuilders<Slots, Message> = {\n readonly [K in keyof Slots]: SlotBuilder<Message>\n}\n\nexport type SlotViewRender<Slots, Input, Message> = (\n input: Input,\n slots: SlotBuilders<Slots, Message>,\n h: HtmlBuilder<Message>,\n) => Html\n\nexport interface SlotView<Slots, Input, Message> extends Pipeable<SlotView<Slots, Input, Message>> {\n (input: Input, h: HtmlBuilder<Message>): Html\n readonly name?: string\n readonly slots: Slots\n readonly mixins: ReadonlyArray<MixinFor<Message>>\n readonly render: SlotViewRender<Slots, Input, Message>\n}\n\n/** Build one `attrs` resolver per published slot, evaluating Mixins lazily. */\nexport const buildersFor = <Slots, Message, Input>(\n slots: Slots,\n mixins: ReadonlyArray<MixinFor<Message>>,\n context: { readonly input: Input; readonly h: HtmlBuilder<Message> },\n): SlotBuilders<Slots, Message> => {\n const source = slots as unknown as Record<string, AnySlot>\n const builders: Record<string, SlotBuilder<Message>> = Object.create(null)\n for (const name of Object.getOwnPropertyNames(source)) {\n const slot = source[name]\n if (slot === undefined) continue\n const protection: SlotProtection = slot.protected\n builders[name] = {\n attrs: (base?: SlotAttributes<Message>, item?: SlotItem) => {\n const contributions = []\n for (const mixin of mixins) {\n const contribution = mixin.contributions[name]\n if (contribution !== undefined) {\n contributions.push(\n evaluate(contribution as SlotContribution<Message>, {\n input: context.input,\n h: context.h,\n ...(item === undefined ? {} : { item }),\n }),\n )\n }\n }\n return resolve(base, contributions, { slot: name, protected: protection })\n },\n }\n }\n return builders as SlotBuilders<Slots, Message>\n}\n\nconst makeView = <Slots, Input, Message>(\n name: string | undefined,\n slots: Slots,\n mixins: ReadonlyArray<MixinFor<Message>>,\n render: SlotViewRender<Slots, Input, Message>,\n): SlotView<Slots, Input, Message> => {\n const view = (input: Input, h: HtmlBuilder<Message>): Html =>\n render(input, buildersFor(slots, mixins, { input, h }), h)\n // A function's own `name` is read-only; define it rather than assigning.\n if (name !== undefined) {\n Object.defineProperty(view, 'name', { value: name, configurable: true })\n }\n return Object.assign(view, {\n slots,\n mixins,\n render,\n pipe: (...fns: ReadonlyArray<(self: unknown) => unknown>) => pipeSelf(view, fns),\n }) as unknown as SlotView<Slots, Input, Message>\n}\n\n/**\n * Defines a view over published Slots.\n *\n * `Message` has no anchor but the render callback's builder, so it is inferred\n * from an explicit `h: HtmlBuilder<Message>` annotation on that parameter.\n * Without one it resolves to `unknown`, and the first error appears later and\n * elsewhere — an invariance mismatch at `Style.attach`/`Behavior.attach` that\n * does not name the missing annotation. `forMessages<Message>()` fixes the\n * Message universe up front instead, and leaves `h` contextually typed.\n */\nexport const define = <Slots, Input, Message>(\n slots: Slots,\n render: SlotViewRender<Slots, Input, Message>,\n options?: { readonly name?: string },\n): SlotView<Slots, Input, Message> => makeView(options?.name, slots, [], render)\n\n/**\n * Foldkit's `inertHtml` typed for a Message universe, for rendering a view\n * outside a runtime (tests, demos, static description). `inertHtml` is\n * `HtmlBuilder<never>`, and the builder is invariant in `Message`, so this is\n * the one cast: sound because inert handlers are never dispatched.\n */\nexport const inertBuilder = <Message>(): HtmlBuilder<Message> =>\n inertHtml as unknown as HtmlBuilder<Message>\n\n/** The `SlotView` constructors with `Message` already fixed. */\nexport interface MessageSlotView<Message> {\n readonly define: <Slots, Input>(\n slots: Slots,\n render: SlotViewRender<Slots, Input, Message>,\n options?: { readonly name?: string },\n ) => SlotView<Slots, Input, Message>\n}\n\n/**\n * Binds the view constructors to one Message universe, so the render callback\n * no longer has to annotate `h` to pin it. `Input` is still inferred from the\n * callback's own `input` annotation.\n *\n * @example\n * ```ts\n * const Field = SlotView.forMessages<Message>().define(\n * FieldSlots,\n * (input: FieldInput, slots, h) =>\n * h.input(slots.input.attrs([h.OnInput(value => Message.ChangedValue({ value }))])),\n * )\n * ```\n */\nexport const forMessages = <Message>(): MessageSlotView<Message> => ({ define })\n\n/** A transform on any view, used by Message-free static mixins such as Style. */\nexport type SlotViewTransform = <Slots, Input, Message>(\n view: SlotView<Slots, Input, Message>,\n) => SlotView<Slots, Input, Message>\n\n/** A transform restricted to one Message universe, for Behavior mixins. */\nexport type SlotViewTransformFor<Message> = <Slots, Input>(\n view: SlotView<Slots, Input, Message>,\n) => SlotView<Slots, Input, Message>\n\n/** Attach one Mixin. Returns a new view; the original is unchanged. */\nexport function attach(mixin: StaticMixin<never> | Mixin<never>): SlotViewTransform\nexport function attach<MixinMessage>(mixin: Mixin<MixinMessage>): SlotViewTransformFor<MixinMessage>\nexport function attach(mixin: AnyMixin | Mixin<never>): any {\n return (view: SlotView<any, any, any>) =>\n makeView(view.name, view.slots, [...view.mixins, mixin], view.render)\n}\n","/**\n * `Behavior` is a named set of interaction contributions attached to declared\n * Slots. It owns no state: attributes are built from the view's `input` and `h`\n * while resolving, so the Message universe is the view's. A stateful widget is\n * a Foldkit Submodel; a continuous element listener is a Mount; a network call\n * is Message -> update -> Command.\n */\nimport type { Attribute, ChildAttribute, HtmlBuilder } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\nimport * as Capability from './capability.js'\nimport type { SlotContribution, SlotItem } from './contribution.js'\nimport { DiagnosticError, type DiagnosticCode } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport * as Mixin from './mixin.js'\nimport type { Mixin as MixinValue } from './mixin.js'\nimport type { Any as AnySlot, AttributeName, EventName, HiddenOf, SlotCapability } from './slot.js'\nimport * as SlotView from './slotView.js'\n\nexport interface SlotRequirements {\n readonly capability?: SlotCapability\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n}\n\nexport interface BehaviorSlotOptions<Input, Message> {\n readonly requires?: SlotRequirements\n /**\n * Attributes for one resolution of the slot. `item` is present when the view\n * passed one to `slots.x.attrs(base, item)`, that is, when the slot is\n * rendered once per item.\n */\n readonly attributes?: (context: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n readonly item?: SlotItem\n }) => ReadonlyArray<Attribute<Message> | ChildAttribute>\n readonly mount?: (input: Input, item?: SlotItem) => MountAction<Message, any>\n}\n\nexport type BehaviorSpec<Slots, Input, Message> = {\n readonly [K in keyof Slots as HiddenOf<Slots[K]> extends true ? never : K]?: BehaviorSlotOptions<\n Input,\n Message\n >\n}\n\nexport interface NamedBehavior<Slots, Input, Message> {\n readonly name?: string\n readonly spec: BehaviorSpec<Slots, Input, Message>\n readonly mixin: MixinValue<Message>\n}\n\n/** Identity helper; `forSlots` supplies the contextual `Input`/`Message`. */\nexport const slot = <Options extends BehaviorSlotOptions<any, any>>(options: Options): Options =>\n options\n\nfunction fail(\n code: DiagnosticCode,\n message: string,\n slotName: string,\n details?: Readonly<Record<string, unknown>>,\n): never {\n throw new DiagnosticError({\n source: 'mixins',\n code,\n severity: 'error',\n message,\n slot: slotName,\n ...(details === undefined ? {} : { details }),\n })\n}\n\nconst validateRequirements = (\n name: string,\n slot: AnySlot,\n requirements: SlotRequirements,\n): void => {\n if (\n requirements.capability !== undefined &&\n !Capability.extendsCapability(slot.capability, requirements.capability)\n ) {\n fail(\n 'mixins:capability-mismatch',\n `Behavior requires capability \"${MetadataToken.nameOf(requirements.capability)}\" on slot \"${name}\", which has \"${MetadataToken.nameOf(slot.capability)}\"`,\n name,\n { required: MetadataToken.nameOf(requirements.capability) },\n )\n }\n for (const event of requirements.events ?? []) {\n const eventName = MetadataToken.nameOf(event)\n if (!slot.events.some(allowed => MetadataToken.nameOf(allowed) === eventName)) {\n fail(\n 'mixins:unsupported-event',\n `Behavior requires event \"${eventName}\" on slot \"${name}\", which does not publish it`,\n name,\n { event: eventName },\n )\n }\n }\n for (const attribute of requirements.attributes ?? []) {\n const attributeName = MetadataToken.nameOf(attribute)\n if (!slot.attributes.some(allowed => MetadataToken.nameOf(allowed) === attributeName)) {\n fail(\n 'mixins:unsupported-attribute',\n `Behavior requires attribute \"${attributeName}\" on slot \"${name}\", which does not publish it`,\n name,\n { attribute: attributeName },\n )\n }\n }\n}\n\nexport const forSlots =\n <Slots>(slots: Slots) =>\n <Input, Message>(\n spec: BehaviorSpec<Slots, Input, Message>,\n options?: { readonly name?: string },\n ): NamedBehavior<Slots, Input, Message> => {\n const source = slots as unknown as Record<string, AnySlot>\n const contributions: Record<string, SlotContribution<Message>> = Object.create(null)\n for (const [name, slotOptions] of Object.entries(\n spec as Record<string, BehaviorSlotOptions<Input, Message> | undefined>,\n )) {\n const target = source[name]\n if (target === undefined) {\n fail('mixins:unknown-slot', `Behavior targets unknown slot \"${name}\"`, name)\n }\n if (target.hidden) {\n fail('mixins:hidden-slot', `Behavior targets hidden slot \"${name}\"`, name)\n }\n if (slotOptions?.requires !== undefined) {\n validateRequirements(name, target, slotOptions.requires)\n }\n const attributes = slotOptions?.attributes\n const mount = slotOptions?.mount\n if (attributes === undefined && mount === undefined) continue\n contributions[name] = context => ({\n ...(attributes === undefined\n ? {}\n : {\n attributes: attributes({\n input: context.input as Input,\n h: context.h,\n ...(context.item === undefined ? {} : { item: context.item }),\n }),\n }),\n ...(mount === undefined ? {} : { mounts: [mount(context.input as Input, context.item)] }),\n })\n }\n return Object.freeze({\n ...(options?.name === undefined ? {} : { name: options.name }),\n spec,\n mixin: Mixin.dynamic<Message>(options?.name ?? 'Behavior', contributions),\n })\n }\n\n/**\n * Attaches a Behavior to a view. The behavior's `Input` becomes the attached\n * view's `Input`: a behavior declared over only the fields it reads is rejected\n * even though those fields are a subset, and one declared over extra fields\n * widens what the view must be called with. Declare `Input` as the view's own\n * input type.\n */\nexport const attach =\n <BehaviorSlots, Message, Input>(behavior: NamedBehavior<BehaviorSlots, Input, Message>) =>\n <ViewSlots>(\n view: SlotView.SlotView<ViewSlots, Input, Message>,\n ): SlotView.SlotView<ViewSlots, Input, Message> =>\n SlotView.attach(behavior.mixin)(view)\n\nexport const Behavior = { slot, forSlots, attach } as const\n","/**\n * A collection is the parent's array, described once so a view and the\n * Behaviors on it agree about identity, order, and which items are disabled.\n * Render order is DOM order, so nothing observes the DOM; `of` is pure and the\n * Behavior only writes what the item context says.\n */\nimport type { HtmlBuilder } from 'foldkit/html'\nimport * as Behavior from '../behavior.js'\nimport type { SlotItem } from '../contribution.js'\nimport { DiagnosticError } from '../diagnostics.js'\n\nexport interface Items<T> {\n readonly size: number\n /** In render order; unique. */\n readonly ids: ReadonlyArray<string>\n readonly at: (index: number) => T | undefined\n /** `-1` when no item has the id. */\n readonly indexOf: (id: string) => number\n readonly isDisabled: (index: number) => boolean\n /** Indices of the enabled items, in order. */\n readonly enabled: ReadonlyArray<number>\n /** The item context for `slots.x.attrs(base, item)`. */\n readonly slotItem: (index: number) => SlotItem\n}\n\nexport interface Describe<T> {\n readonly id: (item: T, index: number) => string\n readonly disabled?: (item: T, index: number) => boolean\n}\n\n/** Describes `items` once. Two items with one id are refused, since an id is what\n * `aria-activedescendant`, `aria-controls`, and a keyed row rely on. */\nexport const of = <T>(items: ReadonlyArray<T>, describe: Describe<T>): Items<T> => {\n const ids: Array<string> = []\n const indexById = new Map<string, number>()\n const disabled: Array<boolean> = []\n const enabled: Array<number> = []\n items.forEach((item, index) => {\n const id = describe.id(item, index)\n const seen = indexById.get(id)\n if (seen !== undefined) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:duplicate-item-id',\n severity: 'error',\n message: `Collection items ${seen} and ${index} share the id \"${id}\"`,\n details: { id, indices: [seen, index] },\n })\n }\n indexById.set(id, index)\n ids.push(id)\n const isDisabled = describe.disabled?.(item, index) ?? false\n disabled.push(isDisabled)\n if (!isDisabled) enabled.push(index)\n })\n const size = items.length\n return Object.freeze({\n size,\n ids: Object.freeze(ids),\n at: (index: number) => items[index],\n indexOf: (id: string) => indexById.get(id) ?? -1,\n isDisabled: (index: number) => disabled[index] ?? false,\n enabled: Object.freeze(enabled),\n slotItem: (index: number): SlotItem => ({\n index,\n id: ids[index] ?? String(index),\n count: size,\n }),\n })\n}\n\nexport interface BehaviorOptions<Input, Slots> {\n /** The slot rendered once per item. */\n readonly item: keyof Slots & string\n /** Reads the described items from the view's input. */\n readonly items: (input: Input) => Items<unknown>\n /** Write `aria-posinset` and `aria-setsize` on each item. Default `false`. */\n readonly posInSet?: boolean\n /** Write `id` on each item, from its described id. Default `true`. */\n readonly ids?: boolean\n}\n\n/**\n * Writes each item's identity and position: `id` from the described id,\n * `aria-disabled` for a disabled item, and `aria-posinset` and `aria-setsize`\n * on request. Reads the item context the view passes to `attrs`; with none it\n * contributes nothing, so a slot rendered once is left alone.\n */\nexport const behavior =\n <Slots>(slots: Slots) =>\n <Input, Message>(\n options: BehaviorOptions<Input, Slots>,\n ): Behavior.NamedBehavior<Slots, Input, Message> =>\n Behavior.forSlots(slots)<Input, Message>(\n {\n [options.item]: Behavior.slot({\n attributes: ({\n input,\n h,\n item,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n readonly item?: SlotItem\n }) => {\n if (item === undefined) return []\n const items = options.items(input)\n const id = item.id ?? items.ids[item.index]\n return [\n ...(options.ids === false || id === undefined ? [] : [h.Id(id)]),\n ...(items.isDisabled(item.index) ? [h.AriaDisabled(true)] : []),\n ...(options.posInSet === true\n ? [h.AriaPosinset(item.index + 1), h.AriaSetsize(item.count ?? items.size)]\n : []),\n ]\n },\n }),\n // The spec is keyed by a value (`options.item`), which the mapped\n // BehaviorSpec type cannot express; `forSlots` still checks the key.\n } as unknown as Behavior.BehaviorSpec<Slots, Input, Message>,\n { name: 'Collection' },\n )\n","/**\n * A trigger that shows and hides content: `aria-expanded` and `aria-controls`\n * on the trigger, an `id` and `hidden` on the content. The open flag is the\n * parent's; this only says it in ARIA. The floor is `<details>`, which needs\n * none of this.\n */\nimport type { HtmlBuilder } from 'foldkit/html'\nimport * as Behavior from '../behavior.js'\nimport * as Capability from '../capability.js'\n\nexport interface Options<Input, Slots> {\n readonly trigger: keyof Slots & string\n readonly content: keyof Slots & string\n readonly open: (input: Input) => boolean\n /** The content's id, which `aria-controls` names. */\n readonly id: (input: Input) => string\n}\n\nexport const behavior =\n <Slots>(slots: Slots) =>\n <Input, Message>(options: Options<Input, Slots>): Behavior.NamedBehavior<Slots, Input, Message> =>\n Behavior.forSlots(slots)<Input, Message>(\n {\n [options.trigger]: Behavior.slot({\n requires: { capability: Capability.Interactive },\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => [h.AriaExpanded(options.open(input)), h.AriaControls(options.id(input))],\n }),\n [options.content]: Behavior.slot({\n requires: { capability: Capability.Container },\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => [h.Id(options.id(input)), h.Hidden(!options.open(input))],\n }),\n // Keyed by values the caller chose; `forSlots` checks both keys exist.\n } as unknown as Behavior.BehaviorSpec<Slots, Input, Message>,\n { name: 'Disclosure' },\n )\n","/**\n * Ties a control to its label, description, and error with ids derived from\n * one base id: `<id>`, `<id>-label`, `<id>-description`, `<id>-error`. The\n * control gets `aria-labelledby`, `aria-describedby` (description first,\n * then the error while one shows), `aria-invalid`, and `aria-required`. The\n * ids are derived, not minted, so a resumed page and a test agree on them.\n */\nimport type { HtmlBuilder } from 'foldkit/html'\nimport * as Behavior from '../behavior.js'\nimport * as Capability from '../capability.js'\n\nexport interface Options<Input, Slots> {\n readonly control: keyof Slots & string\n readonly label: keyof Slots & string\n readonly description?: keyof Slots & string\n readonly error?: keyof Slots & string\n readonly id: (input: Input) => string\n /** The error slot is rendered and describes the control. */\n readonly invalid?: (input: Input) => boolean\n readonly required?: (input: Input) => boolean\n}\n\n/** The ids one base id yields, for a view that renders these elements itself. */\nexport const ids = (id: string) => ({\n control: id,\n label: `${id}-label`,\n description: `${id}-description`,\n error: `${id}-error`,\n})\n\nexport const behavior =\n <Slots>(slots: Slots) =>\n <Input, Message>(options: Options<Input, Slots>): Behavior.NamedBehavior<Slots, Input, Message> =>\n Behavior.forSlots(slots)<Input, Message>(\n {\n [options.control]: Behavior.slot({\n requires: { capability: Capability.Interactive },\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => {\n const names = ids(options.id(input))\n const invalid = options.invalid?.(input) === true\n const describedBy = [\n ...(options.description === undefined ? [] : [names.description]),\n ...(options.error !== undefined && invalid ? [names.error] : []),\n ]\n return [\n h.Id(names.control),\n h.AriaLabelledBy(names.label),\n ...(describedBy.length === 0 ? [] : [h.AriaDescribedBy(describedBy.join(' '))]),\n ...(invalid ? [h.AriaInvalid(true)] : []),\n ...(options.required?.(input) === true ? [h.AriaRequired(true)] : []),\n ]\n },\n }),\n [options.label]: Behavior.slot({\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => {\n const names = ids(options.id(input))\n return [h.Id(names.label), h.For(names.control)]\n },\n }),\n ...(options.description === undefined\n ? {}\n : {\n [options.description]: Behavior.slot({\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => [h.Id(ids(options.id(input)).description)],\n }),\n }),\n ...(options.error === undefined\n ? {}\n : {\n [options.error]: Behavior.slot({\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => [h.Id(ids(options.id(input)).error)],\n }),\n }),\n // Keyed by values the caller chose; `forSlots` checks the keys exist.\n } as unknown as Behavior.BehaviorSpec<Slots, Input, Message>,\n { name: 'FieldAssociation' },\n )\n","/**\n * A number stepped by keys: ArrowUp and ArrowDown by `step`, PageUp and\n * PageDown by `page`, Home and End to the bounds, each clamped, each\n * default-prevented. The value is the parent's; a key yields the Message the\n * caller builds from the next value. Writes the spinbutton role and its\n * `aria-value*`. The floor is `<input type=\"number\">`; a press-and-hold\n * repeat and a wheel are not handled, since Foldkit's wheel attribute carries\n * no delta and a repeat is a timer the Model would have to own.\n */\nimport { Option } from 'effect'\nimport type { HtmlBuilder, KeyboardModifiers } from 'foldkit/html'\nimport * as Behavior from '../behavior.js'\nimport * as Capability from '../capability.js'\n\nexport interface Bounds {\n readonly min?: number\n readonly max?: number\n /** Default `1`. */\n readonly step?: number\n /** PageUp and PageDown move by this; default ten steps. */\n readonly page?: number\n}\n\nconst clamp = (value: number, bounds: Bounds): number =>\n Math.min(\n bounds.max ?? Number.POSITIVE_INFINITY,\n Math.max(bounds.min ?? Number.NEGATIVE_INFINITY, value),\n )\n\n/** The value the key moves to, or `undefined` when the key is not a spin key or a chord. */\nexport const spin = (\n value: number,\n key: string,\n modifiers: KeyboardModifiers,\n bounds: Bounds,\n): number | undefined => {\n if (modifiers.ctrlKey || modifiers.altKey || modifiers.metaKey) return undefined\n const step = bounds.step ?? 1\n const page = bounds.page ?? step * 10\n switch (key) {\n case 'ArrowUp':\n return clamp(value + step, bounds)\n case 'ArrowDown':\n return clamp(value - step, bounds)\n case 'PageUp':\n return clamp(value + page, bounds)\n case 'PageDown':\n return clamp(value - page, bounds)\n case 'Home':\n return bounds.min\n case 'End':\n return bounds.max\n default:\n return undefined\n }\n}\n\nexport interface Options<Input, Message, Slots> extends Bounds {\n readonly control: keyof Slots & string\n readonly value: (input: Input) => number\n readonly onChange: (next: number) => Message\n /** For `aria-valuetext`, when the number alone would not read well. */\n readonly text?: (input: Input) => string\n}\n\nexport const behavior =\n <Slots>(slots: Slots) =>\n <Input, Message>(\n options: Options<Input, Message, Slots>,\n ): Behavior.NamedBehavior<Slots, Input, Message> =>\n Behavior.forSlots(slots)<Input, Message>(\n {\n [options.control]: Behavior.slot({\n requires: { capability: Capability.Focusable },\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => {\n const value = options.value(input)\n return [\n h.Role('spinbutton'),\n h.AriaValuenow(value),\n ...(options.min === undefined ? [] : [h.AriaValuemin(options.min)]),\n ...(options.max === undefined ? [] : [h.AriaValuemax(options.max)]),\n ...(options.text === undefined ? [] : [h.AriaValuetext(options.text(input))]),\n h.OnKeyDownPreventDefault((key, modifiers) => {\n const next = spin(value, key, modifiers, options)\n return next === undefined || next === value\n ? Option.none()\n : Option.some(options.onChange(next))\n }),\n ]\n },\n }),\n // Keyed by a value the caller chose; `forSlots` checks the key exists.\n } as unknown as Behavior.BehaviorSpec<Slots, Input, Message>,\n { name: 'SpinValue' },\n )\n","/**\n * A two-state control's state in ARIA: `aria-checked` for a checkbox, switch,\n * radio or option, `aria-pressed` for a toggle button. The state is the\n * parent's. A native checkbox, radio or switch needs none of this; a radio\n * group's exclusivity is a selection, not a toggle.\n */\nimport type { HtmlBuilder } from 'foldkit/html'\nimport * as Behavior from '../behavior.js'\nimport * as Capability from '../capability.js'\n\nexport type State = boolean | 'mixed'\n\nexport interface Options<Input, Slots> {\n readonly control: keyof Slots & string\n readonly state: (input: Input) => State\n /** `'checked'` writes `aria-checked` (checkbox, switch, radio, option);\n * `'pressed'` writes `aria-pressed` (a toggle button). */\n readonly as: 'checked' | 'pressed'\n}\n\nexport const behavior =\n <Slots>(slots: Slots) =>\n <Input, Message>(options: Options<Input, Slots>): Behavior.NamedBehavior<Slots, Input, Message> =>\n Behavior.forSlots(slots)<Input, Message>(\n {\n [options.control]: Behavior.slot({\n requires: { capability: Capability.Interactive },\n attributes: ({\n input,\n h,\n }: {\n readonly input: Input\n readonly h: HtmlBuilder<Message>\n }) => {\n const state = options.state(input)\n return options.as === 'checked'\n ? [h.AriaChecked(state)]\n : [h.AriaPressed(state === 'mixed' ? 'mixed' : state ? 'true' : 'false')]\n },\n }),\n // Keyed by a value the caller chose; `forSlots` checks the key exists.\n } as unknown as Behavior.BehaviorSpec<Slots, Input, Message>,\n { name: 'ToggleState' },\n )\n","/**\n * Ready-made Behaviors that own no state: each is a function of the view's\n * input and item context to attributes. Stateful ones (a roving tab stop, a\n * press, a dismiss layer) live in `foldkit-primitives` as a Bundle plus its\n * Behavior, because they need a Model slice.\n */\nexport * as Collection from './collection.js'\nexport * as Disclosure from './disclosure.js'\nexport * as FieldAssociation from './field-association.js'\nexport * as SpinValue from './spin-value.js'\nexport * as ToggleState from './toggle-state.js'\n","/**\n * Slot event tokens. Ported from `effect-atom-jsx/src/View.ts` `Event`, plus\n * the extra names the Foldkit plan lists.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type EventToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.event',\n Name\n>\n\nexport const is = (value: unknown): value is EventToken =>\n MetadataToken.is(value) && value.kind === 'view.event'\n\nexport const make = <const Name extends string>(name: Name): EventToken<Name> =>\n MetadataToken.make('view.event', name)\n\nexport const equals = (left: EventToken, right: EventToken): boolean => left.name === right.name\n\nexport const describe = (event: EventToken): { readonly name: string } => ({\n name: event.name,\n})\n\nexport const Press = make('press')\nexport const Click = make('click')\nexport const Cancel = make('cancel')\nexport const Input = make('input')\nexport const Change = make('change')\nexport const Focus = make('focus')\nexport const Blur = make('blur')\nexport const KeyDown = make('keydown')\nexport const PointerDown = make('pointerdown')\nexport const PointerUp = make('pointerup')\nexport const Hover = make('hover')\nexport const Submit = make('submit')\n","/**\n * Platform requirement tokens. Ported from `effect-atom-jsx/src/View.ts`\n * `Requirement`.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type RequirementToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.requirement',\n Name\n>\n\nexport const is = (value: unknown): value is RequirementToken =>\n MetadataToken.is(value) && value.kind === 'view.requirement'\n\nexport const make = <const Name extends string>(name: Name): RequirementToken<Name> =>\n MetadataToken.make('view.requirement', name)\n\nexport const describe = (requirement: RequirementToken): { readonly name: string } => ({\n name: requirement.name,\n})\n\nexport const Keyboard = make('keyboard')\nexport const Pointer = make('pointer')\nexport const Clipboard = make('clipboard')\n","/**\n * Typed builders for the selector strings `Style.pseudo` and `Style.nest`\n * take, relative to the generated class (`&`). They exist so a recipe does\n * not hand-type `&:not([aria-disabled=\"true\"])` in every entry.\n */\n\n/** `&[name]` or `&[name=\"value\"]`. */\nexport const attr = (name: string, value?: string): string =>\n value === undefined ? `[${name}]` : `[${name}=\"${value.replace(/[\"\\\\]/g, '\\\\$&')}\"]`\n\n/** `&:not(selector)`, for `Style.pseudo`. */\nexport const not = (selector: string): string => `:not(${selector})`\n\n/** `&:is(a, b)`, for `Style.pseudo`. */\nexport const is = (...selectors: ReadonlyArray<string>): string => `:is(${selectors.join(', ')})`\n\n/** A direct child, for `Style.nest`. */\nexport const child = (selector: string): string => `> ${selector}`\n\n/** Any descendant, for `Style.nest`. */\nexport const descendant = (selector: string): string => selector\n\n/** The next sibling, for `Style.nest`. */\nexport const sibling = (selector: string): string => `+ ${selector}`\n\n/** Any later sibling, for `Style.nest`. */\nexport const siblings = (selector: string): string => `~ ${selector}`\n","/**\n * Slot witnesses. Ported from `effect-atom-jsx/src/View.ts` `Slot`, without\n * Handle binding. A slot is named metadata: capability, allowed events,\n * attributes, platform requirements, hidden, and Foldkit-only `protected`.\n */\nimport type { AttrToken } from './attr.js'\nimport type { Any as AnyCapability } from './capability.js'\nimport * as Capability from './capability.js'\nimport type { EventToken } from './event.js'\nimport * as MetadataToken from './metadataToken.js'\nimport { pipeSelf, type Pipeable } from './pipe.js'\nimport type { RequirementToken } from './requirement.js'\n\nexport const SlotTypeId: unique symbol = Symbol.for('foldkit-mixins/Slot')\nexport type SlotTypeId = typeof SlotTypeId\n\nexport type EventName = string | EventToken\nexport type AttributeName = string | AttrToken\nexport type RequirementName = string | RequirementToken\nexport type SlotCapability = string | AnyCapability\n\nexport interface SlotProtection {\n readonly events: ReadonlyArray<EventName>\n readonly attributes: ReadonlyArray<AttributeName>\n readonly style: ReadonlyArray<string>\n}\n\nexport interface SlotMetadata<Name extends string = string> {\n readonly name: Name\n readonly capability: SlotCapability\n readonly allowedEvents: readonly EventName[]\n readonly allowedAttributes: readonly AttributeName[]\n readonly platformRequirements: readonly RequirementName[]\n readonly hidden: boolean\n readonly protected: SlotProtection\n}\n\nexport interface Slot<\n Name extends string = string,\n C extends SlotCapability = typeof Capability.Base,\n Events extends readonly EventName[] = readonly [],\n Attributes extends readonly AttributeName[] = readonly [],\n Requirements extends readonly RequirementName[] = readonly [],\n Hidden extends boolean = false,\n> extends Pipeable<Slot<Name, C, Events, Attributes, Requirements, Hidden>> {\n readonly [SlotTypeId]: {\n readonly Name: Name\n readonly Capability: C\n readonly Events: Events\n readonly Attributes: Attributes\n readonly Requirements: Requirements\n readonly Hidden: Hidden\n }\n readonly name: Name\n readonly capability: C\n readonly events: Events\n readonly attributes: Attributes\n readonly requirements: Requirements\n readonly hidden: Hidden\n readonly protected: SlotProtection\n readonly metadata: SlotMetadata<Name> & {\n readonly capability: C\n readonly allowedEvents: Events\n readonly allowedAttributes: Attributes\n readonly platformRequirements: Requirements\n readonly hidden: Hidden\n }\n}\n\nexport type Any = Slot<\n string,\n SlotCapability,\n readonly EventName[],\n readonly AttributeName[],\n readonly RequirementName[],\n boolean\n>\n\nexport type UnnamedSlot<\n C extends SlotCapability = SlotCapability,\n Events extends readonly EventName[] = readonly EventName[],\n Attributes extends readonly AttributeName[] = readonly AttributeName[],\n Requirements extends readonly RequirementName[] = readonly RequirementName[],\n Hidden extends boolean = boolean,\n> = Omit<Slot<'', C, Events, Attributes, Requirements, Hidden>, 'name'> & {\n readonly name?: never\n}\n\nexport type NameOf<T> = T extends Slot<infer Name, any, any, any, any, any> ? Name : never\nexport type CapabilityOf<T> =\n T extends Slot<any, infer C, any, any, any, any> ? MetadataToken.NameOf<C> : never\nexport type CapabilityValueOf<T> = T extends Slot<any, infer C, any, any, any, any> ? C : never\nexport type EventsOf<T> =\n T extends Slot<any, any, infer Events, any, any, any> ? MetadataToken.NamesOf<Events> : never\nexport type AttributesOf<T> =\n T extends Slot<any, any, any, infer Attributes, any, any>\n ? MetadataToken.NamesOf<Attributes>\n : never\nexport type HiddenOf<T> = T extends Slot<any, any, any, any, any, infer Hidden> ? Hidden : never\nexport type AssignableCapabilityNamesOf<T> = Capability.AssignableNamesOf<CapabilityValueOf<T>>\nexport type Public<T> = HiddenOf<T> extends true ? never : T\nexport type Hidden<T> = HiddenOf<T> extends true ? T : never\n\nexport const is = (value: unknown): value is Any | UnnamedSlot =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, SlotTypeId)\n\nconst emptyProtection: SlotProtection = Object.freeze({\n events: Object.freeze([]) as ReadonlyArray<EventName>,\n attributes: Object.freeze([]) as ReadonlyArray<AttributeName>,\n style: Object.freeze([]) as ReadonlyArray<string>,\n})\n\nexport interface MakeOptions<\n C extends SlotCapability = SlotCapability,\n Events extends readonly EventName[] = readonly EventName[],\n Attributes extends readonly AttributeName[] = readonly AttributeName[],\n Requirements extends readonly RequirementName[] = readonly RequirementName[],\n Hidden extends boolean = boolean,\n> {\n readonly capability?: C\n readonly events?: Events\n readonly allowedEvents?: Events\n readonly attributes?: Attributes\n readonly allowedAttributes?: Attributes\n readonly requirements?: Requirements\n readonly platformRequirements?: Requirements\n readonly hidden?: Hidden\n readonly protected?: {\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n readonly style?: ReadonlyArray<string>\n }\n}\n\nconst protectionOf = (options: MakeOptions | undefined): SlotProtection => {\n const specified = options?.protected\n if (specified === undefined) return emptyProtection\n return Object.freeze({\n events: Object.freeze([...(specified.events ?? [])]),\n attributes: Object.freeze([...(specified.attributes ?? [])]),\n style: Object.freeze([...(specified.style ?? [])]),\n })\n}\n\nconst createSlot = <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n>(\n name: Name,\n options: MakeOptions<C, Events, Attributes, Requirements, Hidden> | undefined,\n): Slot<Name, C, Events, Attributes, Requirements, Hidden> => {\n const capability = (options?.capability ?? Capability.Base) as C\n const events = (options?.events ?? options?.allowedEvents ?? []) as Events\n const attributes = (options?.attributes ?? options?.allowedAttributes ?? []) as Attributes\n const requirements = (options?.requirements ??\n options?.platformRequirements ??\n []) as Requirements\n const hidden = (options?.hidden ?? false) as Hidden\n const protection = protectionOf(options)\n const metadata = {\n name,\n capability,\n allowedEvents: events,\n allowedAttributes: attributes,\n platformRequirements: requirements,\n hidden,\n protected: protection,\n }\n const out = {\n [SlotTypeId]: {\n Name: undefined as unknown as Name,\n Capability: undefined as unknown as C,\n Events: undefined as unknown as Events,\n Attributes: undefined as unknown as Attributes,\n Requirements: undefined as unknown as Requirements,\n Hidden: undefined as unknown as Hidden,\n },\n name,\n capability,\n events,\n attributes,\n requirements,\n hidden,\n protected: protection,\n metadata,\n } as Slot<Name, C, Events, Attributes, Requirements, Hidden>\n return Object.assign(out, {\n pipe: (...fns: ReadonlyArray<(value: any) => any>) => pipeSelf(out, fns),\n }) as Slot<Name, C, Events, Attributes, Requirements, Hidden>\n}\n\n/** AF-UI form: name is the first argument. */\nexport function make<\n const Name extends string,\n const C extends SlotCapability = typeof Capability.Base,\n const Events extends readonly EventName[] = readonly [],\n const Attributes extends readonly AttributeName[] = readonly [],\n const Requirements extends readonly RequirementName[] = readonly [],\n const Hidden extends boolean = false,\n>(\n name: Name,\n options?: MakeOptions<C, Events, Attributes, Requirements, Hidden>,\n): Slot<Name, C, Events, Attributes, Requirements, Hidden>\n/** Foldkit form: name comes from `Slots.define` keys. */\nexport function make<\n const C extends SlotCapability = typeof Capability.Base,\n const Events extends readonly EventName[] = readonly [],\n const Attributes extends readonly AttributeName[] = readonly [],\n const Requirements extends readonly RequirementName[] = readonly [],\n const Hidden extends boolean = false,\n>(\n options: MakeOptions<C, Events, Attributes, Requirements, Hidden>,\n): UnnamedSlot<C, Events, Attributes, Requirements, Hidden>\nexport function make(\n nameOrOptions: string | MakeOptions,\n options?: MakeOptions,\n): Any | UnnamedSlot {\n if (typeof nameOrOptions === 'string') {\n return createSlot(nameOrOptions, options)\n }\n const unnamed = createSlot('', nameOrOptions)\n const { name: _dropped, ...rest } = unnamed\n return rest as UnnamedSlot\n}\n\n/** Pipeable transform replacing a named slot's capability. */\nexport const capability =\n <const C extends SlotCapability>(capability: C) =>\n <\n Name extends string,\n OldC extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, OldC, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Events, Attributes, Requirements, Hidden> =>\n createSlot(slot.name, {\n capability,\n events: slot.events,\n attributes: slot.attributes,\n requirements: slot.requirements,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform replacing a named slot's allowed events. */\nexport const events =\n <const Next extends readonly EventName[]>(...next: Next) =>\n <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Next, Attributes, Requirements, Hidden> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: next,\n attributes: slot.attributes,\n requirements: slot.requirements,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform replacing a named slot's allowed attributes. */\nexport const attributes =\n <const Next extends readonly AttributeName[]>(...next: Next) =>\n <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Events, Next, Requirements, Hidden> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: slot.events,\n attributes: next,\n requirements: slot.requirements,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform replacing a named slot's platform requirements. */\nexport const requires =\n <const Next extends readonly RequirementName[]>(...next: Next) =>\n <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n >(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n ): Slot<Name, C, Events, Attributes, Next, Hidden> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: slot.events,\n attributes: slot.attributes,\n requirements: next,\n hidden: slot.hidden,\n protected: slot.protected,\n })\n\n/** Pipeable transform marking a named slot hidden from public attachment. */\nexport const hide = <\n Name extends string,\n C extends SlotCapability,\n Events extends readonly EventName[],\n Attributes extends readonly AttributeName[],\n Requirements extends readonly RequirementName[],\n Hidden extends boolean,\n>(\n slot: Slot<Name, C, Events, Attributes, Requirements, Hidden>,\n): Slot<Name, C, Events, Attributes, Requirements, true> =>\n createSlot(slot.name, {\n capability: slot.capability,\n events: slot.events,\n attributes: slot.attributes,\n requirements: slot.requirements,\n hidden: true,\n protected: slot.protected,\n })\n\nexport const describe = (\n slot: Any | UnnamedSlot,\n): {\n readonly name?: string\n readonly capability: string\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly requirements: ReadonlyArray<string>\n readonly hidden: boolean\n readonly protected: {\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly style: ReadonlyArray<string>\n }\n} => {\n const named = slot.name !== undefined && slot.name !== '' ? { name: slot.name } : {}\n return {\n ...named,\n capability: MetadataToken.nameOf(slot.capability),\n events: slot.events.map(event => MetadataToken.nameOf(event)),\n attributes: slot.attributes.map(attr => MetadataToken.nameOf(attr)),\n requirements: slot.requirements.map(requirement => MetadataToken.nameOf(requirement)),\n hidden: slot.hidden,\n protected: {\n events: slot.protected.events.map(event => MetadataToken.nameOf(event)),\n attributes: slot.protected.attributes.map(attr => MetadataToken.nameOf(attr)),\n style: slot.protected.style,\n },\n }\n}\n","/**\n * Slot contracts. Ported from `effect-atom-jsx/src/View.ts` `Slots.define`,\n * without minting element Handles. Names come from keys. Entries may be\n * `Slot.make({...})` or AF-UI option objects `{ capability, allowedEvents }`.\n */\nimport * as Capability from './capability.js'\nimport * as Slot from './slot.js'\nimport type {\n Any as AnySlot,\n MakeOptions,\n Slot as NamedSlot,\n SlotCapability,\n UnnamedSlot,\n} from './slot.js'\n\nexport const SlotsTypeId: unique symbol = Symbol.for('foldkit-mixins/Slots')\n\nexport type Contract<S extends { readonly [K in keyof S]: UnnamedSlot | MakeOptions }> = {\n readonly [K in keyof S]: S[K] extends UnnamedSlot<\n infer C,\n infer Events,\n infer Attributes,\n infer Requirements,\n infer Hidden\n >\n ? NamedSlot<K & string, C, Events, Attributes, Requirements, Hidden>\n : S[K] extends MakeOptions<\n infer C,\n infer Events,\n infer Attributes,\n infer Requirements,\n infer Hidden\n >\n ? NamedSlot<K & string, C, Events, Attributes, Requirements, Hidden>\n : never\n}\n\nexport type NamesOf<T> = keyof T & string\nexport type PublicNamesOf<T> = {\n readonly [K in keyof T & string]: Slot.HiddenOf<T[K]> extends true ? never : K\n}[keyof T & string]\nexport type HiddenNamesOf<T> = {\n readonly [K in keyof T & string]: Slot.HiddenOf<T[K]> extends true ? K : never\n}[keyof T & string]\nexport type WithCapability<T, C extends SlotCapability> = {\n readonly [\n K in keyof T & string as Capability.NameOf<C> extends Slot.AssignableCapabilityNamesOf<T[K]>\n ? K\n : never\n ]: T[K]\n}\n\nconst toUnnamed = (value: unknown, key: string): UnnamedSlot => {\n if (Slot.is(value)) {\n return value as UnnamedSlot\n }\n if (typeof value === 'object' && value !== null && Object.hasOwn(value, 'capability')) {\n return Slot.make(value as MakeOptions)\n }\n throw new Error(`Slots.define: \"${key}\" is not a Slot or slot options object`)\n}\n\nexport const define = <const S extends { readonly [K in keyof S]: UnnamedSlot | MakeOptions }>(\n spec: S,\n): Contract<S> => {\n const proto = Object.getPrototypeOf(spec)\n if (proto !== Object.prototype && proto !== null) {\n throw new Error(\n 'Slots.define: pass a plain object; quote [\"__proto__\"] to use that as a slot name',\n )\n }\n const contract = Object.create(null) as Record<string, NamedSlot>\n for (const key of Object.getOwnPropertyNames(spec)) {\n const unnamed = toUnnamed((spec as Record<string, unknown>)[key], key)\n Object.defineProperty(contract, key, {\n value: Slot.make(key, {\n capability: unnamed.capability,\n events: unnamed.events,\n attributes: unnamed.attributes,\n requirements: unnamed.requirements,\n hidden: unnamed.hidden,\n protected: unnamed.protected,\n }),\n enumerable: true,\n configurable: false,\n writable: false,\n })\n }\n Object.freeze(contract)\n return contract as unknown as Contract<S>\n}\n\nexport const describe = (contract: {\n readonly [key: string]: AnySlot | UnnamedSlot\n}): {\n readonly slots: Readonly<\n Record<\n string,\n {\n readonly name: string\n readonly capability: string\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly requirements: ReadonlyArray<string>\n readonly hidden: boolean\n readonly protected: {\n readonly events: ReadonlyArray<string>\n readonly attributes: ReadonlyArray<string>\n readonly style: ReadonlyArray<string>\n }\n }\n >\n >\n} => {\n const slots: Record<string, ReturnType<typeof Slot.describe> & { readonly name: string }> =\n Object.create(null)\n for (const key of Object.getOwnPropertyNames(contract)) {\n const slot = contract[key]\n if (slot === undefined || !Slot.is(slot)) continue\n const described = Slot.describe(slot)\n slots[key] = {\n ...described,\n name: slot.name !== undefined && slot.name !== '' ? slot.name : key,\n }\n }\n return { slots }\n}\n\nexport const withCapability = <\n T extends { readonly [key: string]: AnySlot },\n C extends SlotCapability,\n>(\n contract: T,\n capability: C,\n): WithCapability<T, C> => {\n const out = Object.create(null) as Record<string, AnySlot>\n for (const key of Object.getOwnPropertyNames(contract)) {\n const slot = contract[key]\n if (slot === undefined || !Slot.is(slot)) continue\n if (Capability.extendsCapability(slot.capability, capability)) {\n out[key] = slot\n }\n }\n return out as WithCapability<T, C>\n}\n","/**\n * `Style` is pure data: class tokens and inline declarations that compile to a\n * `SlotContribution`. It never touches the DOM and never mutates state.\n * `forSlots` validates piece keys against the published contract at definition\n * time, so a typo fails loudly. The builders themselves live in\n * `styleValue.ts`; this module joins them to slots.\n */\nimport * as Capability from './capability.js'\nimport { declaredNames, isUnordered, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport type { InputContribution, SlotContribution } from './contribution.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport * as Mixin from './mixin.js'\nimport type { Mixin as MixinValue } from './mixin.js'\nimport type { Any as AnySlot, HiddenOf } from './slot.js'\nimport type { Placement } from './layers.js'\nimport type { SlotItem } from './slotItem.js'\nimport * as SlotView from './slotView.js'\nimport * as Rules from './styleRules.js'\nimport {\n allowDiscrete,\n classPiece,\n compose,\n container,\n empty,\n enter,\n global,\n grid,\n inline,\n keyframes,\n media,\n nest,\n pseudo,\n responsive,\n self,\n states,\n supports,\n vars,\n viewTransitionName,\n type StyleValue,\n} from './styleValue.js'\n\nexport type { StyleCondition, StyleValue } from './styleValue.js'\n\n/** A hidden slot is internal: it is neither styleable nor behavior-targetable. */\nexport type StylePieces<Slots> = {\n readonly [K in keyof Slots as HiddenOf<Slots[K]> extends true ? never : K]?: StyleValue\n}\n\nexport interface NamedStyle<Slots> {\n readonly name?: string\n readonly pieces: StylePieces<Slots>\n readonly mixin: MixinValue<never>\n /** Concatenated rule CSS for every static piece. */\n readonly css: string\n /** Concatenated class-independent CSS (keyframes, layers, global rules). */\n readonly globalCss: string\n /** One entry per generated class, for a deduplicating stylesheet. */\n readonly rules: ReadonlyArray<{ readonly className: string; readonly css: string }>\n /** Class-independent rule chunks, for a deduplicating stylesheet. */\n readonly globalRules: ReadonlyArray<string>\n}\n\nexport interface StyleOptions {\n readonly name?: string\n /**\n * The layer every piece is placed in before compiling, e.g.\n * `Layers.standard.layer('app')`. A rule already in a layer keeps it.\n */\n readonly layer?: Placement\n}\n\n/** A boolean known at authoring time. */\nexport const when = (condition: boolean, piece: StyleValue): StyleValue =>\n condition ? piece : empty\n\n/** A condition read from the view input at render time. The piece applies when\n * `predicate` returns true for the input the view was rendered with. */\nexport const whenInput = <Input>(\n predicate: (input: Input) => boolean,\n piece: StyleValue,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n conditions: Object.freeze([\n { predicate: (input: unknown) => predicate(input as Input), piece },\n ]),\n })\n\n/**\n * A piece computed from the item the slot is rendered for, when the view\n * passes one to `attrs(base, item)`; nothing for a slot rendered once.\n */\nexport const perItem = (piece: (item: SlotItem) => StyleValue): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n items: Object.freeze([\n (item: SlotItem | undefined) => (item === undefined ? empty : piece(item)),\n ]),\n })\n\n/**\n * A per-item delay for an entrance: writes `--fk-index` and\n * `transition-delay: calc(var(--fk-index) * <step>)` (or `animation-delay`),\n * so a list staggers with no timer. Pass the item to `attrs` for each row.\n */\nexport const stagger = (options: {\n readonly stepMs: number\n readonly property?: 'transitionDelay' | 'animationDelay'\n}): StyleValue =>\n perItem(item =>\n inline({\n '--fk-index': String(item.index),\n [options.property ?? 'transitionDelay']: `calc(var(--fk-index) * ${options.stepMs}ms)`,\n }),\n )\n\n/** Fold every active condition and item piece (recursively) into a plain style. */\nconst resolveStyle = (style: StyleValue, input: unknown, item?: SlotItem): StyleValue => {\n const active = [\n ...(style.conditions ?? [])\n .filter(condition => condition.predicate(input))\n .map(condition => condition.piece),\n ...(style.items ?? []).map(piece => piece(item)),\n ].map(piece => resolveStyle(piece, input, item))\n return Object.freeze({\n classes: Object.freeze([...style.classes, ...active.flatMap(piece => piece.classes)]),\n style: Object.freeze(\n Object.assign(Object.create(null), style.style, ...active.map(piece => piece.style)),\n ),\n })\n}\n\ninterface CompiledStyle {\n readonly classes: ReadonlyArray<string>\n readonly style: Readonly<Record<string, string>>\n readonly css?: string\n readonly ruleClass?: string\n readonly globalRules?: ReadonlyArray<string>\n /** Every class the tree compiled to, with its CSS, static or conditional. */\n readonly compiled: ReadonlyArray<{ readonly className: string; readonly css: string }>\n}\n\n/** Global CSS is emitted whether or not its condition is active. */\nconst collectGlobalCss = (style: StyleValue): ReadonlyArray<string> => [\n ...(style.globalCss ?? []),\n ...(style.conditions ?? []).flatMap(condition => collectGlobalCss(condition.piece)),\n]\n\n/**\n * Compiles every rule-bearing node in the tree to its class: the node's\n * classes gain the generated one, and the CSS is collected. A conditional\n * piece's rules are compiled the same way, so the class is static and only\n * its presence follows the input.\n */\nconst compileTree = (\n style: StyleValue,\n collected: Array<{ readonly className: string; readonly css: string }>,\n): StyleValue => {\n const rules = style.rules ?? []\n const generated = rules.length === 0 ? undefined : Rules.className(rules)\n if (generated !== undefined)\n collected.push({ className: generated, css: Rules.css(generated, rules) })\n const conditions = (style.conditions ?? []).map(condition => ({\n predicate: condition.predicate,\n piece: compileTree(condition.piece, collected),\n }))\n return Object.freeze({\n ...style,\n classes: generated === undefined ? style.classes : Object.freeze([...style.classes, generated]),\n ...(conditions.length === 0 ? {} : { conditions: Object.freeze(conditions) }),\n })\n}\n\n/** A style with every rule in it compiled: the tree with classes, plus the CSS. */\nconst compileStyle = (style: StyleValue): CompiledStyle & { readonly tree: StyleValue } => {\n const collected: Array<{ readonly className: string; readonly css: string }> = []\n const tree = compileTree(style, collected)\n const globalRules = collectGlobalCss(style)\n const first = collected[0]\n return {\n tree,\n classes: tree.classes,\n style: tree.style,\n ...(first === undefined\n ? {}\n : { css: collected.map(entry => entry.css).join(''), ruleClass: first.className }),\n ...(globalRules.length === 0 ? {} : { globalRules }),\n compiled: collected,\n }\n}\n\n/**\n * A static style stays static data; a style with input conditions compiles to a\n * message-free `InputContribution`, so it still attaches to any view.\n */\nconst contributionFrom = (\n style: StyleValue,\n compiled: CompiledStyle & { readonly tree: StyleValue },\n): SlotContribution<never> => {\n const globalCss = compiled.globalRules?.join('')\n const attributes = {\n classes: compiled.classes,\n style: compiled.style,\n ...(compiled.css === undefined ? {} : { css: compiled.css }),\n ...(globalCss === undefined ? {} : { globalCss }),\n }\n if ((style.conditions ?? []).length === 0 && (style.items ?? []).length === 0) {\n return Object.freeze(attributes)\n }\n const contribution: InputContribution<never> = context => {\n const resolved = resolveStyle(compiled.tree, context.input, context.item)\n return Object.freeze({\n classes: resolved.classes,\n style: resolved.style,\n ...(compiled.css === undefined ? {} : { css: compiled.css }),\n ...(globalCss === undefined ? {} : { globalCss }),\n })\n }\n return contribution\n}\n\nexport const forSlots =\n <Slots>(slots: Slots) =>\n (pieces: StylePieces<Slots>, options?: StyleOptions): NamedStyle<Slots> => {\n const known = slots as unknown as Record<string, unknown>\n const contributions: Record<string, SlotContribution<never>> = Object.create(null)\n // What was compiled, so `pieces` recomposed elsewhere keeps the layer too.\n const compiledPieces: Record<string, StyleValue> = {}\n const rules: Array<{ className: string; css: string }> = []\n const globalRules: Array<string> = []\n let css = ''\n let globalCss = ''\n for (const [key, piece] of Object.entries(pieces as Record<string, StyleValue | undefined>)) {\n if (!Object.hasOwn(known, key)) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:unknown-slot',\n severity: 'error',\n message: `Style targets unknown slot \"${key}\"`,\n slot: key,\n })\n }\n if ((known[key] as { readonly hidden?: boolean } | undefined)?.hidden === true) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:hidden-slot',\n severity: 'error',\n message: `Style targets hidden slot \"${key}\"`,\n slot: key,\n })\n }\n if (piece !== undefined) {\n const placed = options?.layer === undefined ? piece : options.layer.place(piece)\n compiledPieces[key] = placed\n // Rule and global CSS are static even when the contribution is deferred,\n // so compile once, then build the contribution and gather the CSS.\n const compiled = compileStyle(placed)\n contributions[key] = contributionFrom(placed, compiled)\n for (const entry of compiled.compiled) {\n rules.push(entry)\n css += entry.css\n }\n if (compiled.globalRules !== undefined) {\n globalRules.push(...compiled.globalRules)\n globalCss += compiled.globalRules.join('')\n }\n }\n }\n return Object.freeze({\n ...(options?.name === undefined ? {} : { name: options.name }),\n pieces: options?.layer === undefined ? pieces : (compiledPieces as StylePieces<Slots>),\n mixin: Mixin.dynamic<never>(options?.name ?? 'Style', contributions),\n css,\n globalCss,\n rules: Object.freeze(rules),\n globalRules: Object.freeze(globalRules),\n })\n }\n\nexport interface StylesheetSource {\n readonly rules: ReadonlyArray<{ readonly className: string; readonly css: string }>\n readonly globalRules: ReadonlyArray<string>\n}\n\nconst isStylesheetSource = (value: StyleValue | StylesheetSource): value is StylesheetSource =>\n 'globalRules' in value\n\nconst LAYER_STATEMENT = /^@layer [^{}]+;$/\n\nconst sourceOf = (style: StyleValue): StylesheetSource => {\n const compiled = compileStyle(style)\n return { rules: compiled.compiled, globalRules: compiled.globalRules ?? [] }\n}\n\n/**\n * An unlayered rule beats every layer, `app` included, so once a sheet\n * declares an order, a rule outside it, or in a layer the order does not\n * name (which would sort after the last one), is a mistake. Keyframes, font\n * faces, and registered properties are not ordered by the cascade and pass.\n */\nconst refuseUnlayered = (\n css: string,\n names: ReadonlyArray<string>,\n where: string,\n className?: string,\n): void => {\n for (const block of topLevelBlocks(css)) {\n if (isUnordered(block)) continue\n const layer = layerOf(block)\n if (layer !== undefined && names.includes(layer)) continue\n throw new DiagnosticError({\n source: 'style',\n code: 'style:unlayered-rule',\n severity: 'error',\n message:\n layer === undefined\n ? `Style.stylesheet declares a layer order, but ${where} has a rule outside it, which would beat every layer; place its piece with L.in(name, …)`\n : `${where} is in layer \"${layer}\", which the declared order (${names.join(', ')}) does not name, so it would sort after \"${names.at(-1)}\"; place it with L.in(name, …)`,\n details: {\n ...(className === undefined ? {} : { className }),\n ...(layer === undefined ? {} : { layer }),\n },\n })\n }\n}\n\n/**\n * One `<style>` block: the `@layer …;` statement first (one order per\n * sheet), then the other global chunks, then the scoped classes, each\n * deduplicated with the first seen winning. A bare `StyleValue` (a theme\n * root, a layered reset, a layout) compiles like a piece of a `NamedStyle`.\n * With an order declared, every rule must sit in one of its layers\n * (`style:unlayered-rule`); without one, unlayered rules are allowed.\n */\nexport const stylesheet = (...styles: ReadonlyArray<StyleValue | StylesheetSource>): string => {\n const scoped = new Map<string, string>()\n const global = new Set<string>()\n let order: string | undefined\n for (const style of styles) {\n const source = isStylesheetSource(style) ? style : sourceOf(style)\n for (const rule of source.rules) {\n if (!scoped.has(rule.className)) scoped.set(rule.className, rule.css)\n }\n for (const rule of source.globalRules) {\n if (!LAYER_STATEMENT.test(rule)) {\n global.add(rule)\n } else if (order === undefined) {\n order = rule\n } else if (order !== rule) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:conflicting-layer-order',\n severity: 'error',\n message: `Style.stylesheet was given two layer orders: \"${order}\" and \"${rule}\"`,\n })\n }\n }\n }\n if (order !== undefined) {\n const names = declaredNames(order)\n for (const chunk of global) refuseUnlayered(chunk, names, `global CSS \"${chunk.slice(0, 60)}\"`)\n for (const [className, css] of scoped) {\n refuseUnlayered(css, names, `class \"${className}\"`, className)\n }\n }\n return [...(order === undefined ? [] : [order]), ...global, ...scoped.values()].join('')\n}\n\nexport const attach =\n <Slots>(style: NamedStyle<Slots>) =>\n <ViewSlots, Input, Message>(\n view: SlotView.SlotView<ViewSlots, Input, Message>,\n ): SlotView.SlotView<ViewSlots, Input, Message> =>\n SlotView.attach(style.mixin)(view)\n\nexport type RecipeVariantDef = Readonly<Record<string, StyleValue>>\n\n/** A combination style applied when every `when` entry matches the selection. */\nexport interface RecipeCompound<Variants extends Readonly<Record<string, RecipeVariantDef>>> {\n readonly when: Partial<{ readonly [K in keyof Variants]: keyof Variants[K] & string }>\n readonly style: StyleValue\n}\n\nexport interface RecipeDef<Variants extends Readonly<Record<string, RecipeVariantDef>>> {\n readonly base?: StyleValue\n readonly variants: Variants\n readonly defaults?: { readonly [K in keyof Variants]?: keyof Variants[K] & string }\n readonly compound?: ReadonlyArray<RecipeCompound<Variants>>\n}\n\nexport type AnyRecipeDef = RecipeDef<Record<string, RecipeVariantDef>>\n\nexport type RecipeSelection<D extends AnyRecipeDef> = {\n readonly [K in keyof D['variants']]?: keyof D['variants'][K] & string\n}\n\n/** A recipe is just Style data: base, one piece per selected variant, then any\n * matching compound. `compound.when` is keyed by the recipe's variants, so a\n * typo is a compile error rather than a silently dead combination. */\nexport const recipe =\n <Variants extends Readonly<Record<string, RecipeVariantDef>>>(def: RecipeDef<Variants>) =>\n (selection: RecipeSelection<RecipeDef<Variants>>): StyleValue => {\n const pieces: Array<StyleValue> = []\n if (def.base !== undefined) pieces.push(def.base)\n const effective: Record<string, string> = {}\n for (const [variant, values] of Object.entries(def.variants)) {\n const chosen =\n (selection as Record<string, string | undefined>)[variant] ??\n (def.defaults as Record<string, string | undefined> | undefined)?.[variant]\n if (chosen === undefined) continue\n effective[variant] = chosen\n const piece = (values as Record<string, StyleValue>)[chosen]\n if (piece !== undefined) pieces.push(piece)\n }\n for (const compound of def.compound ?? []) {\n if (Object.entries(compound.when).every(([variant, value]) => effective[variant] === value)) {\n pieces.push(compound.style)\n }\n }\n return compose(...pieces)\n }\n\nexport type SlotRecipeVariants<Slots> = Readonly<\n Record<string, Readonly<Record<string, StylePieces<Slots>>>>\n>\n\nexport interface SlotRecipeDef<Slots, Variants extends SlotRecipeVariants<Slots>> {\n readonly base?: StylePieces<Slots>\n readonly variants: Variants\n readonly defaults?: { readonly [K in keyof Variants]?: keyof Variants[K] & string }\n readonly compound?: ReadonlyArray<{\n readonly when: Partial<{ readonly [K in keyof Variants]: keyof Variants[K] & string }>\n readonly style: StylePieces<Slots>\n }>\n}\n\n/** A selection; `null` unsets an axis that has a default. */\nexport type SlotRecipeSelection<Variants> = {\n readonly [K in keyof Variants]?: (keyof Variants[K] & string) | null\n}\n\nexport interface SlotRecipePatch<Slots, Variants extends SlotRecipeVariants<Slots>> {\n readonly base?: StylePieces<Slots>\n readonly variants?: {\n readonly [K in keyof Variants]?: { readonly [V in keyof Variants[K]]?: StylePieces<Slots> }\n }\n readonly defaults?: SlotRecipeDef<Slots, Variants>['defaults']\n readonly compound?: SlotRecipeDef<Slots, Variants>['compound']\n}\n\nexport interface SlotRecipe<Slots, Variants extends SlotRecipeVariants<Slots>> {\n (selection?: SlotRecipeSelection<Variants>): StylePieces<Slots>\n readonly def: SlotRecipeDef<Slots, Variants>\n /**\n * The same recipe with `patch` merged in: base pieces compose per slot, a\n * variant's pieces compose over the base recipe's, compounds append,\n * defaults override. A slot the contract lacks is refused at once.\n */\n readonly extend: (patch: SlotRecipePatch<Slots, Variants>) => SlotRecipe<Slots, Variants>\n}\n\nconst mergePieces = <Slots>(\n left: StylePieces<Slots> | undefined,\n right: StylePieces<Slots> | undefined,\n): StylePieces<Slots> => {\n const merged: Record<string, StyleValue> = {}\n for (const source of [left, right]) {\n for (const [slot, piece] of Object.entries((source ?? {}) as Record<string, StyleValue>)) {\n const existing = merged[slot]\n merged[slot] = existing === undefined ? piece : compose(existing, piece)\n }\n }\n return merged as StylePieces<Slots>\n}\n\nconst assertKnownSlots = <Slots>(\n slots: Slots,\n pieces: StylePieces<Slots> | undefined,\n where: string,\n): void => {\n const known = slots as unknown as Record<string, unknown>\n for (const slot of Object.keys((pieces ?? {}) as Record<string, unknown>)) {\n if (!Object.hasOwn(known, slot)) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:unknown-slot',\n severity: 'error',\n message: `Recipe ${where} targets unknown slot \"${slot}\"`,\n slot,\n })\n }\n }\n}\n\n/**\n * A recipe over every slot of a contract: `base` pieces per slot, `variants`\n * per axis and value, `defaults`, and `compound` matches. The result of a\n * selection is a `StylePieces` for `Style.forSlots`. A design system ships\n * the recipe; an application adjusts it with `extend` instead of forking.\n */\nexport const recipeFor =\n <Slots>(slots: Slots) =>\n <Variants extends SlotRecipeVariants<Slots>>(\n def: SlotRecipeDef<Slots, Variants>,\n ): SlotRecipe<Slots, Variants> => {\n assertKnownSlots(slots, def.base, 'base')\n for (const [axis, values] of Object.entries(def.variants)) {\n for (const [value, pieces] of Object.entries(values)) {\n assertKnownSlots(slots, pieces as StylePieces<Slots>, `variants.${axis}.${value}`)\n }\n }\n for (const entry of def.compound ?? []) assertKnownSlots(slots, entry.style, 'compound')\n const select = (selection: SlotRecipeSelection<Variants> = {}): StylePieces<Slots> => {\n let pieces = def.base ?? ({} as StylePieces<Slots>)\n const effective: Record<string, string> = {}\n for (const [axis, values] of Object.entries(def.variants)) {\n const picked = (selection as Record<string, string | null | undefined>)[axis]\n const chosen =\n picked === null\n ? undefined\n : (picked ?? (def.defaults as Record<string, string | undefined> | undefined)?.[axis])\n if (chosen === undefined) continue\n effective[axis] = chosen\n const piece = (values as Record<string, StylePieces<Slots>>)[chosen]\n if (piece !== undefined) pieces = mergePieces(pieces, piece)\n }\n for (const entry of def.compound ?? []) {\n if (Object.entries(entry.when).every(([axis, value]) => effective[axis] === value)) {\n pieces = mergePieces(pieces, entry.style)\n }\n }\n return pieces\n }\n const extend = (patch: SlotRecipePatch<Slots, Variants>): SlotRecipe<Slots, Variants> => {\n const variants: Record<string, Record<string, StylePieces<Slots>>> = {}\n for (const [axis, values] of Object.entries(def.variants)) {\n variants[axis] = { ...(values as Record<string, StylePieces<Slots>>) }\n }\n for (const [axis, values] of Object.entries(patch.variants ?? {})) {\n const target = variants[axis] ?? {}\n for (const [value, pieces] of Object.entries(\n (values ?? {}) as Record<string, StylePieces<Slots>>,\n )) {\n target[value] = mergePieces(target[value], pieces)\n }\n variants[axis] = target\n }\n return recipeFor(slots)({\n base: mergePieces(def.base, patch.base),\n variants: variants as unknown as Variants,\n defaults: { ...def.defaults, ...patch.defaults } as NonNullable<\n SlotRecipeDef<Slots, Variants>['defaults']\n >,\n compound: [...(def.compound ?? []), ...(patch.compound ?? [])],\n })\n }\n return Object.assign(select, { def, extend })\n }\n\n/**\n * One piece for every public slot whose capability satisfies `capability`:\n * a focus ring for every `Focusable`, a disabled treatment for every\n * `Interactive`, in one line.\n */\nexport const forCapability =\n <Slots>(slots: Slots) =>\n (\n capability: string | Capability.Any,\n piece: StyleValue,\n options?: StyleOptions,\n ): NamedStyle<Slots> => {\n const source = slots as unknown as Record<string, AnySlot>\n const pieces: Record<string, StyleValue> = {}\n for (const [name, slot] of Object.entries(source)) {\n if (slot.hidden) continue\n if (Capability.extendsCapability(slot.capability, capability)) pieces[name] = piece\n }\n return forSlots(slots)(pieces as StylePieces<Slots>, options)\n }\n\nexport const Style = {\n class: classPiece,\n inline,\n compose,\n when,\n whenInput,\n pseudo,\n self,\n media,\n supports,\n container,\n nest,\n states,\n responsive,\n vars,\n enter,\n allowDiscrete,\n viewTransitionName,\n grid,\n keyframes,\n global,\n empty,\n perItem,\n stagger,\n forSlots,\n forCapability,\n attach,\n recipe,\n recipeFor,\n stylesheet,\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,MAAa,sBAAqC,OAAO,IAAI,8BAA8B;AAoB3F,MAAaA,UACX,MACA,SAC8B;CAC9B,IAAI,SAAS,IACX,MAAM,IAAI,MAAM,GAAG,KAAK,wBAAwB;CAElD,OAAO;GACJ,sBAAsB;GACrB,MAAM,KAAA;GACN,MAAM,KAAA;EACR;EACA;EACA;CACF;AACF;AAEA,MAAaC,QAAM,UACjB,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,OAAO,mBAAmB;AAEzF,MAAa,UAAU,UAAiCA,KAAG,KAAK,IAAI,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;ACfjF,MAAM,gCAAgB,IAAI,IAAmC;AAC7D,MAAM,2BAAW,IAAI,IAAiB;AAEtC,MAAaC,QAAM,UACjBC,KAAiB,KAAK,KAAK,MAAM,SAAS;AAE5C,MAAaC,UAIX,MACA,YAC8B;CAC9B,IAAI,SAAS,IACX,MAAM,IAAI,MAAM,mCAAmC;CAErD,MAAM,UAAW,SAAS,WAAW,CAAC;CACtC,MAAM,cAAc,QAAQ,KAAI,WAAUC,OAAqB,MAAM,CAAC;CACtE,MAAM,WAAW,SAAS,IAAI,IAAI;CAClC,IAAI,aAAa,KAAA,GAAW;EAC1B,MAAM,gBAAgB,SAAS,QAAQ,KAAI,WAAUA,OAAqB,MAAM,CAAC;EACjF,IACE,cAAc,WAAW,YAAY,UACrC,cAAc,OAAO,YAAY,UAAU,eAAe,YAAY,MAAM,GAE5E,OAAO;EAET,MAAM,IAAI,MAAM,eAAe,KAAK,mDAAmD;CACzF;CACA,cAAc,IAAI,MAAM,W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