foldkit-mixins 0.3.0 → 0.5.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 +459 -10
- package/dist/app.d.mts +46 -0
- package/dist/app.d.mts.map +1 -0
- package/dist/app.mjs +45 -0
- package/dist/app.mjs.map +1 -0
- package/dist/core-Bxj0UQDF.mjs +53 -0
- package/dist/core-Bxj0UQDF.mjs.map +1 -0
- package/dist/core-CUw_n1Nd.d.mts +40 -0
- package/dist/core-CUw_n1Nd.d.mts.map +1 -0
- package/dist/defaults.d.mts +31 -0
- package/dist/defaults.d.mts.map +1 -0
- package/dist/defaults.mjs +75 -0
- package/dist/defaults.mjs.map +1 -0
- package/dist/foundations.d.mts +30 -0
- package/dist/foundations.d.mts.map +1 -0
- package/dist/foundations.mjs +71 -0
- package/dist/foundations.mjs.map +1 -0
- package/dist/index.d.mts +137 -536
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +261 -1017
- package/dist/index.mjs.map +1 -1
- package/dist/layers-B31M0tDi.mjs +193 -0
- package/dist/layers-B31M0tDi.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/oklch-BxvCD0oi.d.mts +135 -0
- package/dist/oklch-BxvCD0oi.d.mts.map +1 -0
- package/dist/prose.d.mts +30 -0
- package/dist/prose.d.mts.map +1 -0
- package/dist/prose.mjs +61 -0
- package/dist/prose.mjs.map +1 -0
- package/dist/root-C1u12YMD.mjs +37 -0
- package/dist/root-C1u12YMD.mjs.map +1 -0
- package/dist/root-xyWS6geK.d.mts +25 -0
- package/dist/root-xyWS6geK.d.mts.map +1 -0
- package/dist/slotItem-D6_m6IqP.d.mts +18 -0
- package/dist/slotItem-D6_m6IqP.d.mts.map +1 -0
- package/dist/slotMark-Rdsjb7XI.mjs +135 -0
- package/dist/slotMark-Rdsjb7XI.mjs.map +1 -0
- package/dist/slotView-BtIF2pHo.d.mts +476 -0
- package/dist/slotView-BtIF2pHo.d.mts.map +1 -0
- package/dist/style-CKjLee4e.mjs +1266 -0
- package/dist/style-CKjLee4e.mjs.map +1 -0
- package/dist/style-CtCqaL0l.d.mts +182 -0
- package/dist/style-CtCqaL0l.d.mts.map +1 -0
- package/dist/styleValue-BavTe9MZ.d.mts +72 -0
- package/dist/styleValue-BavTe9MZ.d.mts.map +1 -0
- package/dist/styleValue-_G9jwb17.mjs +248 -0
- package/dist/styleValue-_G9jwb17.mjs.map +1 -0
- package/dist/testing.d.mts +30 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +167 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/theme.d.mts +193 -0
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.mjs +146 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/tokens-BR_qxDR7.d.mts +91 -0
- package/dist/tokens-BR_qxDR7.d.mts.map +1 -0
- package/dist/tokens-DteBJVN-.mjs +117 -0
- package/dist/tokens-DteBJVN-.mjs.map +1 -0
- package/dist/utilities.d.mts +73 -0
- package/dist/utilities.d.mts.map +1 -0
- package/dist/utilities.mjs +90 -0
- package/dist/utilities.mjs.map +1 -0
- package/package.json +59 -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,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,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AO,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":["MetadataToken.nameOf","Capability.extendsCapability","is","MetadataToken.is","make","MetadataToken.make","equals","describe","Capability.extendsCapability","MetadataToken.nameOf","Mixin.dynamic","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","MetadataToken.make"],"sources":["../src/a11y.ts","../src/attr.ts","../src/attributes.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"],"sourcesContent":["/**\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 AriaPressed = make('aria-pressed')\nexport const AriaDisabled = make('aria-disabled')\nexport const Disabled = make('disabled')\nexport const Value = make('value')\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 * `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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,gBAA+B,OAAO,IAAI,4BAA4B;AAOnF,MAAa,WAA4C,SAA8B;CACrF,MAAM,eAAe,OAAO,OAAO,IAAI;CACvC,KAAK,MAAM,QAAQ,OAAO,oBAAoB,IAAI,GAAG;EACnD,MAAM,cAAc,KAAK;EACzB,IAAI,gBAAgB,KAAA,GAAW;EAC/B,OAAO,eAAe,cAAc,MAAM;GACxC,OAAO,OAAO,OAAO,EAAE,GAAG,YAAY,CAAC;GACvC,YAAY;GACZ,cAAc;GACd,UAAU;EACZ,CAAC;CACH;CACA,OAAO,OAAO,YAAY;CAC1B,OAAO,OAAO,OAAO;GAClB,gBAAgB,EAAE,cAAc,KAAA,EAA6B;EAChD;CAChB,CAAC;AACH;AAEA,MAAM,aACJ,OACA,aACY;CACZ,MAAM,eAAeA,OAAqB,QAAQ;CAClD,OAAO,MAAM,MAAK,SAAQA,OAAqB,IAAI,MAAM,YAAY;AACvE;AAEA,MAAM,cACJ,MACA,SACA,MACA,aACoB;CACpB,QAAQ;CACR;CACA,UAAU;CACV;CACA;CACA,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;AAC7C;AAEA,MAAa,YACX,SACA,UACkC;CAClC,MAAM,cAAqC,CAAC;CAC5C,KAAK,MAAM,QAAQ,OAAO,oBAAoB,QAAQ,YAAY,GAAG;EACnE,MAAM,cAAc,QAAQ,aAAa;EACzC,IAAI,gBAAgB,KAAA,GAAW;EAC/B,IAAI,CAAC,OAAO,OAAO,OAAO,IAAI,GAAG;GAC/B,IAAI,YAAY,aAAa,MAAM;GACnC,YAAY,KACV,WACE,qBACA,+BAA+B,KAAK,yCACpC,IACF,CACF;GACA;EACF;EACA,MAAM,OAAO,MAAM;EACnB,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,UAAU,KAAK,SAAS;AACrC,MAAa,YAAY,KAAK,WAAW;;;;;;;;;;;;;;;;;;AChBzC,MAAa,QAAQ,MAAc,UACjC,UAAU,KAAA,IAAY,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,MAAM,QAAQ,UAAU,MAAM,EAAE;;AAGnF,MAAa,OAAO,aAA6B,QAAQ,SAAS;;AAGlE,MAAa,MAAM,GAAG,cAA6C,OAAO,UAAU,KAAK,IAAI,EAAE;;AAG/F,MAAa,SAAS,aAA6B,KAAK;;AAGxD,MAAa,cAAc,aAA6B;;AAGxD,MAAa,WAAW,aAA6B,KAAK;;AAG1D,MAAa,YAAY,aAA6B,KAAK"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { T as DiagnosticError, f as make } from "./styleValue-_G9jwb17.mjs";
|
|
2
|
+
//#region src/cssBlocks.ts
|
|
3
|
+
const withoutComments = (text) => text.replace(/\/\*[\s\S]*?\*\//g, "").trim();
|
|
4
|
+
/** Index just past the string starting at `start`, which holds its quote. */
|
|
5
|
+
const endOfString = (css, start) => {
|
|
6
|
+
const quote = css[start];
|
|
7
|
+
let index = start + 1;
|
|
8
|
+
while (index < css.length && css[index] !== quote) index += css[index] === "\\" ? 2 : 1;
|
|
9
|
+
return index + 1;
|
|
10
|
+
};
|
|
11
|
+
const topLevelBlocks = (css) => {
|
|
12
|
+
const blocks = [];
|
|
13
|
+
let start = 0;
|
|
14
|
+
let depth = 0;
|
|
15
|
+
let bodyAt = -1;
|
|
16
|
+
let index = 0;
|
|
17
|
+
while (index < css.length) {
|
|
18
|
+
const char = css[index];
|
|
19
|
+
if (char === "\"" || char === "'") {
|
|
20
|
+
index = endOfString(css, index);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (char === "/" && css[index + 1] === "*") {
|
|
24
|
+
const end = css.indexOf("*/", index + 2);
|
|
25
|
+
index = end === -1 ? css.length : end + 2;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (char === "{") {
|
|
29
|
+
if (depth === 0) bodyAt = index;
|
|
30
|
+
depth++;
|
|
31
|
+
} else if (char === "}") {
|
|
32
|
+
depth--;
|
|
33
|
+
if (depth === 0) {
|
|
34
|
+
blocks.push({
|
|
35
|
+
prelude: withoutComments(css.slice(start, bodyAt)),
|
|
36
|
+
text: css.slice(start, index + 1)
|
|
37
|
+
});
|
|
38
|
+
start = index + 1;
|
|
39
|
+
}
|
|
40
|
+
} else if (char === ";" && depth === 0) {
|
|
41
|
+
const text = css.slice(start, index + 1);
|
|
42
|
+
blocks.push({
|
|
43
|
+
prelude: withoutComments(text),
|
|
44
|
+
text
|
|
45
|
+
});
|
|
46
|
+
start = index + 1;
|
|
47
|
+
}
|
|
48
|
+
index++;
|
|
49
|
+
}
|
|
50
|
+
const rest = css.slice(start);
|
|
51
|
+
if (withoutComments(rest) !== "") blocks.push({
|
|
52
|
+
prelude: withoutComments(rest),
|
|
53
|
+
text: rest
|
|
54
|
+
});
|
|
55
|
+
return blocks;
|
|
56
|
+
};
|
|
57
|
+
/** `@layer a, b, c;`: an order statement, not a layered rule. */
|
|
58
|
+
const isLayerStatement = (block) => /^@layer\s[^{}]*;$/.test(block.prelude);
|
|
59
|
+
/** The layer a `@layer name{…}` block is in; undefined for any other block. */
|
|
60
|
+
const layerOf = (block) => /^@layer\s+([^\s{},;]+)$/.exec(block.prelude)?.[1];
|
|
61
|
+
/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */
|
|
62
|
+
const isUnordered = (block) => isLayerStatement(block) || /^@(?:-webkit-)?keyframes\s|^@font-face\b|^@property\s/.test(block.prelude);
|
|
63
|
+
/** The names a `@layer a, b, c;` statement declares. */
|
|
64
|
+
const declaredNames = (statement) => statement.replace(/^@layer\s+/, "").replace(/;$/, "").split(",").map((name) => name.trim());
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/layers.ts
|
|
67
|
+
/**
|
|
68
|
+
* Cascade layers as a value. `define` names an order; the result declares
|
|
69
|
+
* it (`declare`) and places a piece in one of its layers (`in`), typed to
|
|
70
|
+
* those names so a misspelled layer is a type error. `standard` is the
|
|
71
|
+
* order a design system built on the `/theme`, `/layout`, `/defaults`, and
|
|
72
|
+
* `/prose` subpaths expects; the pieces those ship are unlayered until a
|
|
73
|
+
* page wraps them, so a different order needs no different generators.
|
|
74
|
+
*/
|
|
75
|
+
const tally = () => ({
|
|
76
|
+
placed: 0,
|
|
77
|
+
kept: /* @__PURE__ */ new Set()
|
|
78
|
+
});
|
|
79
|
+
const placeRule = (name, rule, count) => {
|
|
80
|
+
if (rule.layer !== void 0 && rule.layer !== name) {
|
|
81
|
+
count.kept.add(rule.layer);
|
|
82
|
+
return rule;
|
|
83
|
+
}
|
|
84
|
+
count.placed++;
|
|
85
|
+
return rule.layer === name ? rule : {
|
|
86
|
+
...rule,
|
|
87
|
+
layer: name
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */
|
|
91
|
+
const placeGlobal = (name, css, count) => {
|
|
92
|
+
const out = [];
|
|
93
|
+
let pending = "";
|
|
94
|
+
const flush = () => {
|
|
95
|
+
if (pending !== "") out.push(`@layer ${name}{${pending}}`);
|
|
96
|
+
pending = "";
|
|
97
|
+
};
|
|
98
|
+
for (const block of topLevelBlocks(css)) {
|
|
99
|
+
const layer = layerOf(block);
|
|
100
|
+
if (isLayerStatement(block)) {
|
|
101
|
+
flush();
|
|
102
|
+
out.push(block.text);
|
|
103
|
+
} else if (layer === void 0) {
|
|
104
|
+
pending += block.text;
|
|
105
|
+
count.placed++;
|
|
106
|
+
} else {
|
|
107
|
+
flush();
|
|
108
|
+
out.push(block.text);
|
|
109
|
+
if (layer === name) count.placed++;
|
|
110
|
+
else count.kept.add(layer);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
flush();
|
|
114
|
+
return out.join("");
|
|
115
|
+
};
|
|
116
|
+
const place = (name, piece, count) => Object.freeze({
|
|
117
|
+
...piece,
|
|
118
|
+
...piece.rules === void 0 ? {} : { rules: Object.freeze(piece.rules.map((rule) => placeRule(name, rule, count))) },
|
|
119
|
+
...piece.globalCss === void 0 ? {} : { globalCss: Object.freeze(piece.globalCss.map((css) => placeGlobal(name, css, count))) },
|
|
120
|
+
...piece.conditions === void 0 ? {} : { conditions: Object.freeze(piece.conditions.map((condition) => ({
|
|
121
|
+
predicate: condition.predicate,
|
|
122
|
+
piece: place(name, condition.piece, count)
|
|
123
|
+
}))) },
|
|
124
|
+
...piece.items === void 0 ? {} : { items: Object.freeze(piece.items.map((render) => (item) => place(name, render(item), tally()))) }
|
|
125
|
+
});
|
|
126
|
+
const refuseRelayer = (name, count) => {
|
|
127
|
+
if (count.placed > 0 || count.kept.size === 0) return;
|
|
128
|
+
const layers = [...count.kept];
|
|
129
|
+
throw new DiagnosticError({
|
|
130
|
+
source: "style",
|
|
131
|
+
code: "style:relayered",
|
|
132
|
+
severity: "error",
|
|
133
|
+
message: `Layers.in("${name}", …) was given a piece already in layer ${layers.map((layer) => `"${layer}"`).join(", ")}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,
|
|
134
|
+
details: {
|
|
135
|
+
layer: name,
|
|
136
|
+
kept: layers
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const placeIn = (name, piece) => {
|
|
141
|
+
const count = tally();
|
|
142
|
+
const placed = place(name, piece, count);
|
|
143
|
+
refuseRelayer(name, count);
|
|
144
|
+
return placed;
|
|
145
|
+
};
|
|
146
|
+
const define = (names) => {
|
|
147
|
+
const seen = /* @__PURE__ */ new Set();
|
|
148
|
+
for (const name of names) {
|
|
149
|
+
if (seen.has(name)) throw new DiagnosticError({
|
|
150
|
+
source: "style",
|
|
151
|
+
code: "style:duplicate-layer",
|
|
152
|
+
severity: "error",
|
|
153
|
+
message: `Layers.define names "${name}" twice`
|
|
154
|
+
});
|
|
155
|
+
seen.add(name);
|
|
156
|
+
}
|
|
157
|
+
return Object.freeze({
|
|
158
|
+
names: Object.freeze([...names]),
|
|
159
|
+
declare: make({ globalCss: Object.freeze([`@layer ${names.join(", ")};`]) }),
|
|
160
|
+
in: placeIn,
|
|
161
|
+
layer: (name) => Object.freeze({
|
|
162
|
+
layer: name,
|
|
163
|
+
place: (piece) => place(name, piece, tally())
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* The shipped order. `reset` normalizes; `tokens` holds the scales that do
|
|
169
|
+
* not change per theme; `theme` the knobs and what derives from them, plus
|
|
170
|
+
* scoped overrides; `defaults` element defaults; then a design system's
|
|
171
|
+
* `components`, `layouts` (after components, so a wrapper never beats a
|
|
172
|
+
* component's inner rule), a recipe's `variants`, `utilities`, and the
|
|
173
|
+
* application's `app`, always last.
|
|
174
|
+
*/
|
|
175
|
+
const standard = define([
|
|
176
|
+
"reset",
|
|
177
|
+
"tokens",
|
|
178
|
+
"theme",
|
|
179
|
+
"defaults",
|
|
180
|
+
"components",
|
|
181
|
+
"layouts",
|
|
182
|
+
"variants",
|
|
183
|
+
"utilities",
|
|
184
|
+
"app"
|
|
185
|
+
]);
|
|
186
|
+
const Layers = {
|
|
187
|
+
define,
|
|
188
|
+
standard
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
export { isUnordered as a, declaredNames as i, define as n, layerOf as o, standard as r, topLevelBlocks as s, Layers as t };
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=layers-B31M0tDi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layers-B31M0tDi.mjs","names":[],"sources":["../src/cssBlocks.ts","../src/layers.ts"],"sourcesContent":["/**\n * The top-level blocks of compiled CSS text, and which cascade layer each is\n * in. `Layers.in` reads them to leave an already-layered block where it is,\n * and `Style.stylesheet` to refuse a rule outside the declared order. The\n * text is the compiler's own output or a `Style.global` chunk, so a scanner\n * that respects strings, comments, and brace depth is enough; it is not a\n * CSS parser.\n */\nexport interface Block {\n /** What precedes the body, comments removed: `@layer app`, `.x:hover`, or a whole `@layer a, b;`. */\n readonly prelude: string\n /** The block's full text, as it appeared. */\n readonly text: string\n}\n\nconst withoutComments = (text: string): string => text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim()\n\n/** Index just past the string starting at `start`, which holds its quote. */\nconst endOfString = (css: string, start: number): number => {\n const quote = css[start]\n let index = start + 1\n while (index < css.length && css[index] !== quote) index += css[index] === '\\\\' ? 2 : 1\n return index + 1\n}\n\nexport const topLevelBlocks = (css: string): ReadonlyArray<Block> => {\n const blocks: Array<Block> = []\n let start = 0\n let depth = 0\n let bodyAt = -1\n let index = 0\n while (index < css.length) {\n const char = css[index]\n if (char === '\"' || char === \"'\") {\n index = endOfString(css, index)\n continue\n }\n if (char === '/' && css[index + 1] === '*') {\n const end = css.indexOf('*/', index + 2)\n index = end === -1 ? css.length : end + 2\n continue\n }\n if (char === '{') {\n if (depth === 0) bodyAt = index\n depth++\n } else if (char === '}') {\n depth--\n if (depth === 0) {\n blocks.push({\n prelude: withoutComments(css.slice(start, bodyAt)),\n text: css.slice(start, index + 1),\n })\n start = index + 1\n }\n } else if (char === ';' && depth === 0) {\n const text = css.slice(start, index + 1)\n blocks.push({ prelude: withoutComments(text), text })\n start = index + 1\n }\n index++\n }\n const rest = css.slice(start)\n if (withoutComments(rest) !== '') blocks.push({ prelude: withoutComments(rest), text: rest })\n return blocks\n}\n\n/** `@layer a, b, c;`: an order statement, not a layered rule. */\nexport const isLayerStatement = (block: Block): boolean => /^@layer\\s[^{}]*;$/.test(block.prelude)\n\n/** The layer a `@layer name{…}` block is in; undefined for any other block. */\nexport const layerOf = (block: Block): string | undefined =>\n /^@layer\\s+([^\\s{},;]+)$/.exec(block.prelude)?.[1]\n\n/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */\nexport const isUnordered = (block: Block): boolean =>\n isLayerStatement(block) ||\n /^@(?:-webkit-)?keyframes\\s|^@font-face\\b|^@property\\s/.test(block.prelude)\n\n/** The names a `@layer a, b, c;` statement declares. */\nexport const declaredNames = (statement: string): ReadonlyArray<string> =>\n statement\n .replace(/^@layer\\s+/, '')\n .replace(/;$/, '')\n .split(',')\n .map(name => name.trim())\n","/**\n * Cascade layers as a value. `define` names an order; the result declares\n * it (`declare`) and places a piece in one of its layers (`in`), typed to\n * those names so a misspelled layer is a type error. `standard` is the\n * order a design system built on the `/theme`, `/layout`, `/defaults`, and\n * `/prose` subpaths expects; the pieces those ship are unlayered until a\n * page wraps them, so a different order needs no different generators.\n */\nimport { isLayerStatement, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport type { StyleRule } from './styleRules.js'\nimport { make, type StyleValue } from './styleValue.js'\n\n/**\n * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every\n * piece is placed before it is compiled, so the style a view attaches and the\n * style a sheet ships are the same value with the same classes. A piece\n * already in another layer keeps it and is not refused, because a slot piece\n * that is only a layered layout or recipe is ordinary.\n */\nexport interface Placement<Name extends string = string> {\n readonly layer: Name\n readonly place: (piece: StyleValue) => StyleValue\n}\n\nexport interface Layers<Name extends string> {\n readonly names: ReadonlyArray<Name>\n /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */\n readonly declare: StyleValue\n /**\n * The piece's unlayered rules and global CSS emitted inside `@layer name`,\n * including rules under `whenInput` and per-item pieces. A rule or block\n * already in a layer keeps it, so a design system's layered layout composed\n * into an application style stays in `layouts`. A piece with nothing\n * unlayered but something in another layer is refused with\n * `style:relayered`, since the call would move nothing. A slot style is\n * layered where it is defined, with `layer`, not here: placing a finished\n * style would copy it under new classes that no view attaches.\n */\n readonly in: (name: Name, piece: StyleValue) => StyleValue\n /** The placement `Style.forSlots` takes as its `layer` option. */\n readonly layer: (name: Name) => Placement<Name>\n}\n\n/** What one `in` call placed, and which other layers it left in place. */\ninterface Tally {\n placed: number\n readonly kept: Set<string>\n}\n\nconst tally = (): Tally => ({ placed: 0, kept: new Set() })\n\nconst placeRule = (name: string, rule: StyleRule, count: Tally): StyleRule => {\n if (rule.layer !== undefined && rule.layer !== name) {\n count.kept.add(rule.layer)\n return rule\n }\n count.placed++\n return rule.layer === name ? rule : { ...rule, layer: name }\n}\n\n/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */\nconst placeGlobal = (name: string, css: string, count: Tally): string => {\n const out: Array<string> = []\n let pending = ''\n const flush = (): void => {\n if (pending !== '') out.push(`@layer ${name}{${pending}}`)\n pending = ''\n }\n for (const block of topLevelBlocks(css)) {\n const layer = layerOf(block)\n if (isLayerStatement(block)) {\n flush()\n out.push(block.text)\n } else if (layer === undefined) {\n pending += block.text\n count.placed++\n } else {\n flush()\n out.push(block.text)\n if (layer === name) count.placed++\n else count.kept.add(layer)\n }\n }\n flush()\n return out.join('')\n}\n\nconst place = (name: string, piece: StyleValue, count: Tally): StyleValue =>\n Object.freeze({\n ...piece,\n ...(piece.rules === undefined\n ? {}\n : { rules: Object.freeze(piece.rules.map(rule => placeRule(name, rule, count))) }),\n ...(piece.globalCss === undefined\n ? {}\n : { globalCss: Object.freeze(piece.globalCss.map(css => placeGlobal(name, css, count))) }),\n ...(piece.conditions === undefined\n ? {}\n : {\n conditions: Object.freeze(\n piece.conditions.map(condition => ({\n predicate: condition.predicate,\n piece: place(name, condition.piece, count),\n })),\n ),\n }),\n ...(piece.items === undefined\n ? {}\n : {\n // Rendered per item, after `in` returned: nothing to refuse by then.\n items: Object.freeze(\n piece.items.map(\n render => (item: SlotItem | undefined) => place(name, render(item), tally()),\n ),\n ),\n }),\n })\n\nconst refuseRelayer = (name: string, count: Tally): void => {\n if (count.placed > 0 || count.kept.size === 0) return\n const layers = [...count.kept]\n throw new DiagnosticError({\n source: 'style',\n code: 'style:relayered',\n severity: 'error',\n message: `Layers.in(\"${name}\", …) was given a piece already in layer ${layers.map(layer => `\"${layer}\"`).join(', ')}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,\n details: { layer: name, kept: layers },\n })\n}\n\nconst placeIn = (name: string, piece: StyleValue): StyleValue => {\n const count = tally()\n const placed = place(name, piece, count)\n refuseRelayer(name, count)\n return placed\n}\n\nexport const define = <const Name extends string>(names: ReadonlyArray<Name>): Layers<Name> => {\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:duplicate-layer',\n severity: 'error',\n message: `Layers.define names \"${name}\" twice`,\n })\n }\n seen.add(name)\n }\n return Object.freeze({\n names: Object.freeze([...names]),\n declare: make({ globalCss: Object.freeze([`@layer ${names.join(', ')};`]) }),\n in: placeIn,\n layer: (name: Name): Placement<Name> =>\n Object.freeze({ layer: name, place: (piece: StyleValue) => place(name, piece, tally()) }),\n })\n}\n\n/**\n * The shipped order. `reset` normalizes; `tokens` holds the scales that do\n * not change per theme; `theme` the knobs and what derives from them, plus\n * scoped overrides; `defaults` element defaults; then a design system's\n * `components`, `layouts` (after components, so a wrapper never beats a\n * component's inner rule), a recipe's `variants`, `utilities`, and the\n * application's `app`, always last.\n */\nexport const standard = define([\n 'reset',\n 'tokens',\n 'theme',\n 'defaults',\n 'components',\n 'layouts',\n 'variants',\n 'utilities',\n 'app',\n])\n\nexport const Layers = { define, standard } as const\n"],"mappings":";;AAeA,MAAM,mBAAmB,SAAyB,KAAK,QAAQ,qBAAqB,EAAE,CAAC,CAAC,KAAK;;AAG7F,MAAM,eAAe,KAAa,UAA0B;CAC1D,MAAM,QAAQ,IAAI;CAClB,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,UAAU,IAAI,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,IAAI;CACtF,OAAO,QAAQ;AACjB;AAEA,MAAa,kBAAkB,QAAsC;CACnE,MAAM,SAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,IAAI,SAAS;CACb,IAAI,QAA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