{"version":3,"file":"index.cjs","sources":["../src/dom/bind-template.ts","../src/dom/filter.ts","../src/compose/composition.ts","../src/compose/stagger-delay.ts","../src/a11y/media-query.ts","../src/compose/responsive.ts","../src/compose/region.ts"],"sourcesContent":["import type { Scheduler } from '../scheduler/scheduler'\nimport type { Animatable } from '../value/animatable'\nimport { formatChannelNumber, type ChannelMeta } from '../value/value-type'\nimport { bindProperty, type FormatSource } from './bind-property'\n\n/** A live scalar slot: a bare Animatable, or anything exposing one (e.g. follow()). */\nexport type TemplateSource = Animatable | { readonly value: Animatable }\n\n/** A template interpolation: a live source, or a constant folded into the surrounding literal. */\nexport type TemplateSlot = TemplateSource | number | string\n\n/** The tag's return: the live sources in slot order plus a pure string-splice. Owns no physics, DOM, or subscription. */\nexport interface StyleTemplate {\n  readonly sources: readonly Animatable[]\n  format(parts: readonly string[]): string\n}\n\nexport interface BindTemplateOptions {\n  scheduler?: Scheduler\n  /** Decimals kept per numeric slot in the tagged form (default 4, matching the complex value type). */\n  precision?: number\n}\n\n/** The function form spreads RAW numbers (the author rounds), so `precision` does not apply there. */\ntype FunctionFormOptions = Pick<BindTemplateOptions, 'scheduler'>\n\n/** Map a sources tuple to a same-length tuple of plain numbers, so the function formatter is arity- and order-safe. */\ntype NumbersOf<S extends readonly unknown[]> = { -readonly [K in keyof S]: number }\n\n// A bare Animatable has .get; a follow()-style wrapper exposes .value (an Animatable);\n// a number/string is a constant -> null. The discriminator is unambiguous.\nconst asAnimatable = (slot: TemplateSlot): Animatable | null => {\n  if (typeof slot !== 'object' || slot === null) return null\n  if (typeof (slot as { get?: unknown }).get === 'function') return slot as Animatable\n  const inner = (slot as { value?: unknown }).value\n  if (inner !== null && typeof inner === 'object' && typeof (inner as { get?: unknown }).get === 'function') {\n    return inner as Animatable\n  }\n  return null\n}\n\n/**\n * Tagged template: compose live scalar sources (an `animatable`, a `follow()`, a\n * scroll/pointer spring) and constants into one reactive CSS string. The literal\n * chunks carry the units and CSS punctuation; the interpolations are the live\n * values. Pure and SSR-inert - it builds in-memory data, touches no DOM, and can\n * be bound later via bindTemplate().\n */\nexport function template(strings: TemplateStringsArray, ...slots: readonly TemplateSlot[]): StyleTemplate {\n  const sources: Animatable[] = []\n  const literals: string[] = [strings[0] ?? '']\n  for (let i = 0; i < slots.length; i++) {\n    const tail = strings[i + 1] ?? ''\n    const source = asAnimatable(slots[i]!)\n    if (source !== null) {\n      sources.push(source)\n      literals.push(tail)\n    } else {\n      // A constant: fold it into the preceding literal so it never subscribes.\n      literals[literals.length - 1] += String(slots[i]) + tail\n    }\n  }\n  return {\n    sources,\n    format(parts) {\n      let out = literals[0] ?? ''\n      for (let i = 0; i < parts.length; i++) out += parts[i]! + (literals[i + 1] ?? '')\n      return out\n    },\n  }\n}\n\n// Subscribe one listener to each UNIQUE source (a source used in two slots\n// subscribes once); return a single combined unsubscribe.\nconst fanIn = (sources: readonly Animatable[], listener: () => void): (() => void) => {\n  const offs: Array<() => void> = []\n  for (const source of new Set(sources)) offs.push(source.on('change', listener))\n  return () => {\n    for (const off of offs) off()\n  }\n}\n\n/**\n * Bind a composed CSS string to one element property, driven each frame by N live\n * sources. Writes to ANY property including a `--custom` one, through the same\n * render-phase binder as animate(): one flush per frame, byte-deduped (idle-quiet\n * at rest), synchronous at bind time. Returns a disposer that tears down every\n * source subscription and any pending write - drop it into `region.add(...)`.\n * A read-only projection: it never disposes its sources (the caller owns those).\n *\n * Tag form (headline): `bindTemplate(el, 'filter', template`blur(${b}px)`)`.\n * Function form (escape hatch): `bindTemplate(el, 'transform', [x, y], (px, py) => ...)`.\n */\nexport function bindTemplate(\n  element: HTMLElement,\n  property: string,\n  styleTemplate: StyleTemplate,\n  options?: BindTemplateOptions,\n): () => void\nexport function bindTemplate<const S extends readonly TemplateSource[]>(\n  element: HTMLElement,\n  property: string,\n  sources: S,\n  format: (...values: NumbersOf<S>) => string,\n  options?: FunctionFormOptions,\n): () => void\nexport function bindTemplate(\n  element: HTMLElement,\n  property: string,\n  a: StyleTemplate | readonly TemplateSource[],\n  b?: BindTemplateOptions | ((...values: number[]) => string),\n  c?: BindTemplateOptions,\n): () => void {\n  let source: FormatSource\n  let options: BindTemplateOptions\n\n  if (Array.isArray(a)) {\n    // Function form: raw numbers spread into the author's formatter.\n    const format = b as (...values: number[]) => string\n    options = c ?? {}\n    const sources = (a as readonly TemplateSource[]).map(asAnimatable).filter((s): s is Animatable => s !== null)\n    const scratch = new Array<number>(sources.length)\n    source = {\n      format() {\n        for (let i = 0; i < sources.length; i++) scratch[i] = sources[i]!.get()\n        return format(...scratch)\n      },\n      onChange: (listener) => fanIn(sources, listener),\n    }\n  } else {\n    // Tag form: engine-consistent rounded slots spliced into the template.\n    const tpl = a as StyleTemplate\n    options = (b as BindTemplateOptions | undefined) ?? {}\n    const meta: ChannelMeta = { precision: options.precision ?? 4 }\n    const sources = tpl.sources\n    const scratch = new Array<string>(sources.length)\n    source = {\n      format() {\n        for (let i = 0; i < sources.length; i++) scratch[i] = formatChannelNumber(sources[i]!.get(), meta)\n        return tpl.format(scratch)\n      },\n      onChange: (listener) => fanIn(sources, listener),\n    }\n  }\n\n  const binding = bindProperty(\n    element,\n    property,\n    source,\n    options.scheduler !== undefined ? { scheduler: options.scheduler } : {},\n  )\n  return () => binding.dispose()\n}\n","/**\n * A typed builder for the CSS `filter` property. Each field maps to a filter\n * function; absent fields are omitted. Numbers take their natural unit (blur in\n * px, hueRotate in deg), the rest are plain multipliers/fractions. `dropShadow`\n * is a verbatim shadow string (`'0 2px 6px rgba(0,0,0,.4)'`).\n *\n * The functions are emitted in a FIXED canonical order, so two `filter()` results\n * with the same set of fields always share a function list - which is exactly what\n * the value engine needs to interpolate them channel-for-channel. Animate the\n * string like any other property: `animate(el, { filter: filter({ blur: 8 }) })`.\n */\nexport interface FilterSpec {\n  /** Gaussian blur radius, px. */\n  blur?: number\n  /** Brightness multiplier (1 = unchanged, 0 = black). */\n  brightness?: number\n  /** Contrast multiplier (1 = unchanged). */\n  contrast?: number\n  /** Grayscale fraction, 0..1. */\n  grayscale?: number\n  /** Hue rotation, deg. */\n  hueRotate?: number\n  /** Invert fraction, 0..1. */\n  invert?: number\n  /** Opacity multiplier, 0..1 (distinct from the element's own opacity). */\n  opacity?: number\n  /** Saturation multiplier (1 = unchanged, 0 = grayscale). */\n  saturate?: number\n  /** Sepia fraction, 0..1. */\n  sepia?: number\n  /** A drop-shadow value verbatim, e.g. `'0 2px 6px rgba(0,0,0,.4)'`. */\n  dropShadow?: string\n}\n\n// Canonical order + how each field renders. Fixed so any two results are interpolable.\nconst FILTER_FUNCTIONS: ReadonlyArray<readonly [keyof FilterSpec, (value: never) => string]> = [\n  ['blur', (v: number) => `blur(${v}px)`],\n  ['brightness', (v: number) => `brightness(${v})`],\n  ['contrast', (v: number) => `contrast(${v})`],\n  ['grayscale', (v: number) => `grayscale(${v})`],\n  ['hueRotate', (v: number) => `hue-rotate(${v}deg)`],\n  ['invert', (v: number) => `invert(${v})`],\n  ['opacity', (v: number) => `opacity(${v})`],\n  ['saturate', (v: number) => `saturate(${v})`],\n  ['sepia', (v: number) => `sepia(${v})`],\n  ['dropShadow', (v: string) => `drop-shadow(${v})`],\n] as unknown as ReadonlyArray<readonly [keyof FilterSpec, (value: never) => string]>\n\n/** Build a CSS `filter` string from a typed spec, in canonical function order. Empty spec -> `'none'`. */\nexport function filter(spec: FilterSpec): string {\n  const parts: string[] = []\n  for (const [key, render] of FILTER_FUNCTIONS) {\n    const value = spec[key]\n    if (value !== undefined) parts.push(render(value as never))\n  }\n  return parts.length > 0 ? parts.join(' ') : 'none'\n}\n","import type { Scheduler } from '../scheduler/scheduler'\nimport { getSharedScheduler } from '../scheduler/shared'\nimport type { AnimationHandle } from '../value/animatable'\nimport { thenFinished } from '../value/thenable'\n// Type-only: erased at build, so it does NOT pull the stagger-delay math (which\n// imports resolveEasing) into the primitives size graph that probes `stagger`.\nimport type { DelayFn } from './stagger-delay'\nimport { waitFrames } from './wait'\n\n/** A deferred animation: called when its turn comes. */\nexport type AnimationStep = () => AnimationHandle\n\nexport interface StaggerOptions {\n  scheduler?: Scheduler\n}\n\n/**\n * Starts `animation` on each item, item i delayed by its schedule.\n * The third argument is either a flat per-index spacing (item i delayed by\n * i * delayMs, the original linear behavior) or a `DelayFn` from `staggerDelay()`\n * for an expressive wave (origin, 2D grid, axis, easing). The returned handle\n * aggregates them: `finished` resolves when every item has rested; `stop` cancels\n * pending starts and freezes running items.\n */\nexport function stagger<T>(\n  items: readonly T[],\n  animation: (item: T, index: number) => AnimationHandle,\n  delay: number | DelayFn = 0,\n  options: StaggerOptions = {},\n): AnimationHandle {\n  const scheduler = options.scheduler ?? getSharedScheduler()\n  let stopped = false\n  let remaining = items.length\n  let resolveFinished = () => {}\n  const finished =\n    items.length === 0\n      ? Promise.resolve()\n      : new Promise<void>((resolve) => {\n          resolveFinished = resolve\n        })\n  const cancelWaits: Array<() => void> = []\n  const started: AnimationHandle[] = []\n\n  const complete = () => {\n    remaining -= 1\n    if (remaining === 0) resolveFinished()\n  }\n  const start = (item: T, index: number) => {\n    if (stopped) return\n    const handle = animation(item, index)\n    started.push(handle)\n    void handle.finished.then(complete)\n  }\n\n  const delayFn: DelayFn = typeof delay === 'function' ? delay : (index) => delay * index\n  items.forEach((item, index) => {\n    const d = delayFn(index, items.length)\n    if (d <= 0) start(item, index)\n    else cancelWaits.push(waitFrames(d, scheduler, () => start(item, index)))\n  })\n\n  return {\n    finished,\n    then: thenFinished(finished),\n    stop: () => {\n      if (stopped) return\n      stopped = true\n      for (const cancel of cancelWaits) cancel()\n      for (const handle of started) handle.stop()\n      resolveFinished()\n    },\n  }\n}\n\n/**\n * Runs steps one after another, each starting when the previous one rests.\n * `stop` freezes the current step and cancels the remaining ones.\n * `finished` resolves at the end (or on stop) - never rejects.\n *\n * The low-level ordered-handle primitive. For fluent, interruptible authoring\n * (verbs, overlap, pause/timeScale) use `sequence()` from `@underlying/core/playback`.\n */\nexport function chain(steps: readonly AnimationStep[]): AnimationHandle {\n  let stopped = false\n  let current: AnimationHandle | null = null\n  let resolveFinished = () => {}\n  const finished = new Promise<void>((resolve) => {\n    resolveFinished = resolve\n  })\n\n  void (async () => {\n    for (const step of steps) {\n      if (stopped) return\n      current = step()\n      await current.finished\n    }\n    resolveFinished()\n  })()\n\n  return {\n    finished,\n    then: thenFinished(finished),\n    stop: () => {\n      if (stopped) return\n      stopped = true\n      current?.stop()\n      resolveFinished()\n    },\n  }\n}\n","import { resolveEasing, type EasingInput } from '../physics/easing-registry'\n\n/**\n * A delay schedule: given an item's index and the total count, return its start\n * delay in ms. The shape stagger() and animate()'s `delay` option both consume.\n */\nexport type DelayFn = (index: number, total: number) => number\n\n/** Where the wave begins. A number is a specific index (1D) or cell index (grid). */\nexport type StaggerOrigin = number | 'start' | 'end' | 'center' | 'edges' | 'random'\n\n/** Restrict a grid wave to one axis (default: the diagonal Euclidean ripple). */\nexport type StaggerAxis = 'x' | 'y'\n\nexport interface StaggerGrid {\n  readonly cols: number\n  /** Defaults to ceil(total / cols). */\n  readonly rows?: number\n}\n\nexport interface StaggerDelayOptions {\n  /** ms between adjacent items in the wave (default 0 - no wave). */\n  each?: number\n  /** Wave origin (default 'start'). */\n  from?: StaggerOrigin\n  /** A flat lead-in added to every delay, ms (default 0). */\n  start?: number\n  /** 2D propagation by cell distance; rows defaults to ceil(total / cols). */\n  grid?: StaggerGrid\n  /** Restrict a grid wave to one axis (grid only; ignored without a grid). */\n  axis?: StaggerAxis\n  /** Redistribute the normalized distance through an easing (default linear/identity). */\n  ease?: EasingInput\n  /** Deterministic 'random': a fixed default (1) is stable across reloads and tests. */\n  seed?: number\n}\n\n// A small seeded PRNG so 'random' is deterministic: the same seed yields the\n// same permutation across reloads, HMR, and two calls in a test.\nconst mulberry32 = (seed: number): (() => number) => {\n  let a = seed >>> 0\n  return () => {\n    a = (a + 0x6d2b79f5) | 0\n    let t = Math.imul(a ^ (a >>> 15), 1 | a)\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n  }\n}\n\n// A seeded permutation rank: each index lands at a stable random position in\n// [0, total). argsort the indices by a per-index random float.\nconst randomRanks = (total: number, seed: number): number[] => {\n  const rng = mulberry32(seed)\n  const order = Array.from({ length: total }, (_, i) => ({ i, r: rng() }))\n  order.sort((a, b) => a.r - b.r)\n  const ranks = new Array<number>(total)\n  order.forEach((entry, position) => {\n    ranks[entry.i] = position\n  })\n  return ranks\n}\n\nconst rank1d = (i: number, last: number, from: Exclude<StaggerOrigin, 'random'>): number => {\n  if (from === 'start') return i\n  if (from === 'end') return last - i\n  if (from === 'center') return Math.abs(i - last / 2)\n  if (from === 'edges') return Math.min(i, last - i)\n  // A specific index, clamped into range so an out-of-bounds origin still has an item at delay 0.\n  return Math.abs(i - Math.min(Math.max(from, 0), last))\n}\n\nconst gridOriginCell = (\n  from: Exclude<StaggerOrigin, 'random' | 'edges'>,\n  lastX: number,\n  lastY: number,\n  cols: number,\n): { x: number; y: number } => {\n  if (from === 'start') return { x: 0, y: 0 }\n  if (from === 'end') return { x: lastX, y: lastY }\n  if (from === 'center') return { x: lastX / 2, y: lastY / 2 }\n  // A specific cell index, clamped into the grid.\n  const cell = Math.min(Math.max(from, 0), lastX + lastY * cols)\n  return { x: Math.min(cell % cols, lastX), y: Math.min(Math.floor(cell / cols), lastY) }\n}\n\nconst gridRanks = (total: number, grid: StaggerGrid, from: Exclude<StaggerOrigin, 'random'>, axis: StaggerAxis | undefined): number[] => {\n  // A non-positive column count has no valid geometry: fall back to a flat (no-wave) schedule.\n  if (!(grid.cols >= 1)) return new Array<number>(total).fill(0)\n  const cols = grid.cols\n  const rows = grid.rows !== undefined && grid.rows >= 1 ? grid.rows : Math.ceil(total / cols)\n  const lastX = cols - 1\n  const lastY = rows - 1\n  const ranks = new Array<number>(total)\n  if (from === 'edges') {\n    // Ripple inward from every edge: distance to the nearest edge.\n    for (let i = 0; i < total; i++) {\n      const cx = i % cols\n      const cy = Math.floor(i / cols)\n      const ex = Math.min(cx, lastX - cx)\n      const ey = Math.min(cy, lastY - cy)\n      ranks[i] = axis === 'x' ? ex : axis === 'y' ? ey : Math.min(ex, ey)\n    }\n    return ranks\n  }\n  const origin = gridOriginCell(from, lastX, lastY, cols)\n  for (let i = 0; i < total; i++) {\n    const dx = Math.abs((i % cols) - origin.x)\n    const dy = Math.abs(Math.floor(i / cols) - origin.y)\n    ranks[i] = axis === 'x' ? dx : axis === 'y' ? dy : Math.hypot(dx, dy)\n  }\n  return ranks\n}\n\nconst computeRanks = (total: number, options: StaggerDelayOptions): number[] => {\n  const from = options.from ?? 'start'\n  if (from === 'random') return randomRanks(total, options.seed ?? 1)\n  if (options.grid !== undefined) return gridRanks(total, options.grid, from, options.axis)\n  const last = total - 1\n  const ranks = new Array<number>(total)\n  for (let i = 0; i < total; i++) ranks[i] = rank1d(i, last, from)\n  return ranks\n}\n\n/**\n * Build a delay schedule for a staggered set. The normalized distance of each\n * item from the wave origin is run through `ease` and scaled by `each`, so:\n *\n *   delay(i) = start + ease(rank(i) / maxRank) * (maxRank * each)\n *\n * With defaults (just `each`, from 'start', identity ease, no grid) this is\n * exactly `each * i` - byte-identical to the original linear stagger. Choose the\n * origin (start/end/center/edges/random/a specific index), propagate across a 2D\n * grid by cell distance, restrict to an axis, and redistribute with an easing.\n * Pure: no DOM, no globals. The per-total rank computation is memoized so a\n * single staggered call computes it once.\n */\nexport function staggerDelay(options: StaggerDelayOptions = {}): DelayFn {\n  const each = options.each ?? 0\n  const start = options.start ?? 0\n  const ease = options.ease !== undefined ? resolveEasing(options.ease) : null\n\n  let cache: { total: number; ranks: number[]; max: number } | null = null\n  const ranksFor = (total: number): { ranks: number[]; max: number } => {\n    if (cache !== null && cache.total === total) return cache\n    const ranks = computeRanks(total, options)\n    let max = 0\n    for (const rank of ranks) if (rank > max) max = rank\n    cache = { total, ranks, max }\n    return cache\n  }\n\n  return (index, total) => {\n    if (total <= 1 || each === 0) return start\n    const { ranks, max } = ranksFor(total)\n    const rank = ranks[index] ?? 0\n    const t = max === 0 ? 0 : rank / max\n    const eased = ease !== null ? ease(t) : t\n    return start + eased * (max * each)\n  }\n}\n\n/** The eager array form: every item's delay up front. One builder reused per item. */\nexport function staggerDelays(total: number, options: StaggerDelayOptions = {}): number[] {\n  const fn = staggerDelay(options)\n  return Array.from({ length: total }, (_, i) => fn(i, total))\n}\n","/**\n * Watch a media query, lazy and SSR-safe: browser globals are touched only on\n * call, never at import. The current match is emitted SYNCHRONOUSLY on subscribe\n * (so a setup keyed to it applies on mount), then again on every change. Returns\n * an unsubscribe. Generalizes the reduced-motion listener to any query. Internal:\n * not exported from the package entry.\n */\nexport function watchMedia(query: string, onChange: (matches: boolean) => void): () => void {\n  if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => {}\n  const mql = window.matchMedia(query)\n  onChange(mql.matches)\n  const handler = (event: MediaQueryListEvent): void => onChange(event.matches)\n  mql.addEventListener('change', handler)\n  return () => mql.removeEventListener('change', handler)\n}\n","import { watchMedia } from '../a11y/media-query'\nimport { onReducedMotionChange, prefersReducedMotion } from '../a11y/reduced-motion'\n\n/** Runs when the query starts matching; an optional returned teardown runs when it stops. */\nexport type ResponsiveSetup = (context: { matches: boolean }) => void | (() => void)\n\n/**\n * Run `setup` whenever `query` starts matching, and its returned teardown when it\n * stops. A string is any media query - '(prefers-reduced-motion: reduce)' is just\n * a query. The `{ reducedMotion }` form reuses the reduced-motion source, so it\n * honors the app-level override too. Returns an unsubscribe that runs any live\n * teardown and stops listening.\n *\n * SSR-safe and client-only: with no matchMedia the setup never runs server-side -\n * it runs on mount when the query matches, never with a guessed server value.\n */\nexport function responsive(query: string | { reducedMotion: boolean }, setup: ResponsiveSetup): () => void {\n  let active = false\n  let teardown: (() => void) | null = null\n\n  const apply = (matches: boolean): void => {\n    if (matches && !active) {\n      active = true\n      const result = setup({ matches: true })\n      teardown = typeof result === 'function' ? result : null\n    } else if (!matches && active) {\n      active = false\n      const run = teardown\n      teardown = null\n      run?.()\n    }\n  }\n\n  const dispose = (): void => {\n    if (!active) return\n    active = false\n    const run = teardown\n    teardown = null\n    run?.()\n  }\n\n  if (typeof query === 'string') {\n    const stop = watchMedia(query, apply)\n    return () => {\n      stop()\n      dispose()\n    }\n  }\n\n  // reducedMotion form: reuse the reduced-motion source (override-aware), so it\n  // is not a second matcher and respects setReducedMotionOverride. Client-only,\n  // like the string form: do not apply the initial state server-side (where\n  // prefersReducedMotion() is a no-DOM default), or a reduced-motion-OFF setup\n  // would run during SSR. The listener subscription is harmless server-side.\n  const want = query.reducedMotion\n  if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {\n    apply(prefersReducedMotion() === want)\n  }\n  const off = onReducedMotionChange((reduced) => apply(reduced === want))\n  return () => {\n    off()\n    dispose()\n  }\n}\n","import {\n  animate as animateImpl,\n  releaseStyle,\n  setStyle as setStyleImpl,\n  type AnimateOptions,\n  type AnimateTargets,\n  type AnimationTarget,\n} from '../dom/animate'\nimport { resolveTargets, type AnimatableElement } from '../dom/resolve-target'\nimport type { AnimationHandle } from '../value/animatable'\nimport { stagger as staggerImpl, type StaggerOptions } from './composition'\nimport { responsive as responsiveImpl, type ResponsiveSetup } from './responsive'\nimport type { DelayFn } from './stagger-delay'\n\n/**\n * A teardown boundary: everything created through it is collected, and a single\n * `revert()` undoes it all - stops the animations, removes the media listeners,\n * runs the registered disposers (LIFO), and releases the inline styles back to\n * computed. Named `region` (not `scope`) to avoid the `AnimateOptions.scope`\n * callback-receiver field. This is the mount/unmount seam a framework adapter\n * sits on. Collection is EXPLICIT (call the region's methods) - never ambient,\n * so it cannot silently miss or capture an unrelated animation.\n */\nexport interface Region {\n  /** Scope-bound animate(): auto-stopped and its elements released on revert. */\n  animate(target: AnimationTarget, targets: AnimateTargets, options?: AnimateOptions): AnimationHandle\n  /** Scope-bound stagger(): the aggregate is auto-stopped on revert. */\n  /**\n   * Scope-bound stagger(): the aggregate is auto-stopped on revert. Note: styles\n   * set INSIDE the item animations are NOT released (the items are opaque) - use\n   * region.animate() per item if you need the styles reverted to computed.\n   */\n  stagger<T>(\n    items: readonly T[],\n    animation: (item: T, index: number) => AnimationHandle,\n    delay?: number | DelayFn,\n    options?: StaggerOptions,\n  ): AnimationHandle\n  /** Scope-bound responsive(): its unsubscribe is auto-run on revert. */\n  responsive(query: string | { reducedMotion: boolean }, setup: ResponsiveSetup): () => void\n  /** Scope-bound setStyle(): the touched element is released on revert. */\n  setStyle(...args: Parameters<typeof setStyleImpl>): void\n  /** Register any disposer (a gesture/interactive handle's dispose, a raw cleanup). Returns it unchanged. */\n  add<T extends () => void>(cleanup: T): T\n  /** Register an externally created handle so its stop() runs on revert. Returns it unchanged. */\n  track(handle: AnimationHandle): AnimationHandle\n  /** Tear everything down, LIFO, then release touched styles. Idempotent. */\n  revert(): void\n}\n\n/**\n * Create a teardown boundary. Pass a `setup` to wire everything up inline; the\n * region is returned either way. `revert()` is the single undo.\n */\n// One throwing disposer must not abort the rest of the teardown - report and continue.\nconst safely = (fn: () => void): void => {\n  try {\n    fn()\n  } catch (error) {\n    console.error('[underlying] region teardown threw', error)\n  }\n}\n\nexport function region(setup?: (region: Region) => void): Region {\n  const disposers: Array<() => void> = []\n  const touched = new Set<AnimatableElement>()\n  let reverted = false\n\n  const instance: Region = {\n    animate(target, targets, options) {\n      // Resolve once: add the resolved elements to `touched` AND hand the concrete\n      // list to animate() (an element array re-resolves without a second query).\n      const elements = resolveTargets(target)\n      for (const element of elements) touched.add(element)\n      const handle = animateImpl(elements, targets, options)\n      disposers.push(() => handle.stop())\n      return handle\n    },\n    stagger(items, animation, delay, options) {\n      const handle = staggerImpl(items, animation, delay, options)\n      disposers.push(() => handle.stop())\n      return handle\n    },\n    responsive(query, responsiveSetup) {\n      const off = responsiveImpl(query, responsiveSetup)\n      disposers.push(off)\n      return off\n    },\n    setStyle(...args) {\n      touched.add(args[0])\n      setStyleImpl(...args)\n    },\n    add(cleanup) {\n      disposers.push(cleanup)\n      return cleanup\n    },\n    track(handle) {\n      disposers.push(() => handle.stop())\n      return handle\n    },\n    revert() {\n      if (reverted) return\n      reverted = true\n      for (let i = disposers.length - 1; i >= 0; i--) safely(disposers[i]!)\n      disposers.length = 0\n      for (const element of touched) safely(() => releaseStyle(element))\n      touched.clear()\n    },\n  }\n\n  if (setup !== undefined) setup(instance)\n  return instance\n}\n"],"names":["asAnimatable","slot","inner","template","strings","slots","sources","literals","i","tail","source","parts","out","fanIn","listener","offs","off","bindTemplate","element","property","a","b","c","options","format","s","scratch","tpl","meta","formatChannelNumber","binding","bindProperty","FILTER_FUNCTIONS","v","filter","spec","key","render","value","stagger","items","animation","delay","scheduler","getSharedScheduler","stopped","remaining","resolveFinished","finished","resolve","cancelWaits","started","complete","start","item","index","handle","delayFn","d","waitFrames","thenFinished","cancel","chain","steps","current","step","mulberry32","seed","t","randomRanks","total","rng","order","_","ranks","entry","position","rank1d","last","from","gridOriginCell","lastX","lastY","cols","cell","gridRanks","grid","axis","rows","cx","cy","ex","ey","origin","dx","dy","computeRanks","staggerDelay","each","ease","resolveEasing","cache","ranksFor","max","rank","eased","staggerDelays","fn","watchMedia","query","onChange","mql","handler","event","responsive","setup","active","teardown","apply","matches","result","run","dispose","stop","want","prefersReducedMotion","onReducedMotionChange","reduced","safely","error","region","disposers","touched","reverted","instance","target","targets","elements","resolveTargets","animateImpl","staggerImpl","responsiveSetup","responsiveImpl","args","setStyleImpl","cleanup","releaseStyle"],"mappings":"0HA+BMA,EAAgBC,GAA0C,CAC9D,GAAI,OAAOA,GAAS,UAAYA,IAAS,KAAM,OAAO,KACtD,GAAI,OAAQA,EAA2B,KAAQ,WAAY,OAAOA,EAClE,MAAMC,EAASD,EAA6B,MAC5C,OAAIC,IAAU,MAAQ,OAAOA,GAAU,UAAY,OAAQA,EAA4B,KAAQ,WACtFA,EAEF,IACT,EASO,SAASC,EAASC,KAAkCC,EAA+C,CACxG,MAAMC,EAAwB,CAAA,EACxBC,EAAqB,CAACH,EAAQ,CAAC,GAAK,EAAE,EAC5C,QAASI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