{"version":3,"names":["useClock","Animated","props","time","tick","colorField","effect","t","paused","children"],"sources":["animated.tsx"],"sourcesContent":["import type { Accessor, Element as JSXElement } from \"solid-js\";\nimport { useClock } from \"./clock.ts\";\n\n/**\n * A per-frame color field over a region: given a glyph cell's local position\n * `(x, y)` within a `width`×`height` box, return its packed 24-bit fg, or\n * `undefined` to leave the painted color as-is.\n */\nexport type AnimationField = (\n\tx: number,\n\ty: number,\n\twidth: number,\n\theight: number,\n) => number | undefined;\n\n/** What an {@link Effect} is handed each frame to build its field. */\nexport type EffectEnv = {\n\t/** Animation clock (ms since mount). */\n\tt: number;\n\t/** True while the group is paused. */\n\tpaused: boolean;\n};\n\n/**\n * A reusable animation. Called every frame with the current {@link EffectEnv},\n * it returns the {@link AnimationField} sampled for each glyph cell. See\n * `shimmer`, `wave`, and `pulse` in `./effects.ts`.\n */\nexport type Effect = (env: EffectEnv) => AnimationField;\n\nexport type AnimatedProps = {\n\tchildren: JSXElement;\n\t/** The animation to run across the region (e.g. `shimmer(...)`). */\n\teffect: Effect;\n\t/** Clock tick in ms — the animation's temporal resolution. Default 50. */\n\ttick?: number;\n\t/** Freeze the animation (effects fall back to their resting color). */\n\tpaused?: boolean;\n\t/** Share an external clock instead of creating one. */\n\ttime?: Accessor<number>;\n};\n\n/**\n * Runs an {@link Effect} as a paint-time color filter over its children, so the\n * animation sweeps across whatever they paint — text, a spinner glyph, nested\n * boxes — purely by screen position. Children stay plain; nothing needs to be\n * animation-aware:\n *\n * ```tsx\n * <Animated effect={shimmer({ baseColor: \"#666\", highlightColor: \"#fff\" })}>\n *   <Spinner />\n *   <text>{` ${verb}…`}</text>\n * </Animated>\n * ```\n *\n * The named `Shimmer` / `Wave` / `Pulse` wrappers cover the common effects.\n */\nexport function Animated(props: AnimatedProps) {\n\tconst time = props.time ?? useClock(props.tick ?? 50);\n\t// Rebuilds the field each tick; the changed prop re-paints the region.\n\tconst colorField = () =>\n\t\tprops.effect({ t: time(), paused: props.paused ?? false });\n\treturn (\n\t\t<box flexDirection=\"row\" colorField={colorField()}>\n\t\t\t{props.children}\n\t\t</box>\n\t);\n}\n"],"mappings":"AACA,SAASA,QAAQ,QAAQ,YAAY;;AAErC;AACA;AACA;AACA;AACA;;AAQA;;AAQA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAACC,KAAoB,EAAE;EAC9C,MAAMC,IAAI,GAAGD,KAAK,CAACC,IAAI,IAAIH,QAAQ,CAACE,KAAK,CAACE,IAAI,IAAI,EAAE,CAAC;EACrD;EACA,MAAMC,UAAU,GAAGA,CAAA,KAClBH,KAAK,CAACI,MAAM,CAAC;IAAEC,CAAC,EAAEJ,IAAI,CAAC,CAAC;IAAEK,MAAM,EAAEN,KAAK,CAACM,MAAM,IAAI;EAAM,CAAC,CAAC;EAC3D,OACC,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,CAACH,UAAU,CAAC,CAAC,CAAC;AACpD,GAAG,CAACH,KAAK,CAACO,QAAQ;AAClB,EAAE,EAAE,GAAG,CAAC;AAER","ignoreList":[]}