{"version":3,"names":["useClock","SPINNER_GLYPHS","sparkle","process","platform","line","dots","circle","DEFAULT_BASE","Spinner","props","time","clockRef","frames","glyphs","interval","glyphInterval","glyph","f","Math","floor","length","color"],"sources":["spinner.tsx"],"sourcesContent":["import type { ColorInput } from \"bun\";\nimport type { Accessor } from \"solid-js\";\nimport { useClock } from \"../animation/clock.ts\";\n\n/**\n * Named glyph-frame presets for {@link Spinner}. Each is the literal sequence\n * of frames cycled in order; pass one to the `glyphs` prop, or supply your own\n * `readonly string[]`.\n *\n * - `sparkle` — the default: a sparkle that grows then shrinks for a smooth\n *   bounce (uses `*` instead of `✳` off macOS for wider font coverage).\n * - `line` — the classic `-\\|/` ASCII spinner.\n * - `dots` — a braille spinner (`⠋⠙⠹…`).\n * - `circle` — a rotating quarter-filled circle (`◐◓◑◒`).\n */\nexport const SPINNER_GLYPHS = {\n\tsparkle:\n\t\tprocess.platform === \"darwin\"\n\t\t\t? ([\"·\", \"✢\", \"✳\", \"✶\", \"✻\", \"✽\", \"✻\", \"✶\", \"✳\", \"✢\"] as const)\n\t\t\t: ([\"·\", \"✢\", \"*\", \"✶\", \"✻\", \"✽\", \"✻\", \"✶\", \"*\", \"✢\"] as const),\n\tline: [\"-\", \"\\\\\", \"|\", \"/\"] as const,\n\tdots: [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"] as const,\n\tcircle: [\"◐\", \"◓\", \"◑\", \"◒\"] as const,\n} satisfies Record<string, readonly string[]>;\n\nconst DEFAULT_BASE = 0x58a6ff; // #58a6ff blue\n\nexport type SpinnerProps = {\n\t/**\n\t * Glyph frames cycled in order. Pass a {@link SPINNER_GLYPHS} preset or your\n\t * own `readonly string[]`. Default {@link SPINNER_GLYPHS.sparkle}.\n\t */\n\tglyphs?: readonly string[];\n\t/** Milliseconds per glyph frame. Default 120. */\n\tglyphInterval?: number;\n\t/**\n\t * Glyph color. Inside an `Animated`/`Shimmer`/… region the group's paint\n\t * filter recolors the glyph instead. Default blue (#58a6ff).\n\t */\n\tcolor?: ColorInput;\n\t/** Expose the internal clock for external consumers (e.g. useStalled). */\n\tclockRef?: (time: Accessor<number>) => void;\n};\n\n/**\n * A bare animated spinner glyph — just the bouncing glyph in `color`. It needs\n * no animation awareness: dropped inside an `Animated`/`Shimmer`/`Wave`/`Pulse`\n * region, the group's paint filter recolors the glyph along with the text\n * beside it, so an effect sweeps across the spinner and its label as one.\n *\n * Stateful coloring (e.g. fading toward red as a stream stalls) belongs to the\n * caller, not here — wrap the spinner in a `Shimmer`/`Animated` whose colors\n * animate (see the `stream-spinner` demo), and the paint filter recolors the\n * glyph along with everything else in the region.\n */\nexport function Spinner(props: SpinnerProps) {\n\tconst time = useClock(50);\n\tif (props.clockRef) props.clockRef(time);\n\n\tconst frames = () => props.glyphs ?? SPINNER_GLYPHS.sparkle;\n\tconst interval = () => props.glyphInterval ?? 120;\n\tconst glyph = () => {\n\t\tconst f = frames();\n\t\treturn f[Math.floor(time() / interval()) % f.length] ?? f[0];\n\t};\n\n\treturn (\n\t\t<text bold color={props.color ?? DEFAULT_BASE}>\n\t\t\t{glyph()}\n\t\t</text>\n\t);\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,uBAAuB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAG;EAC7BC,OAAO,EACNC,OAAO,CAACC,QAAQ,KAAK,QAAQ,GACzB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAClD,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAW;EACjEC,IAAI,EAAE,CAAC,GAAG,EAAE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