{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cavemio-onboarding-checklist",
  "title": "Onboarding checklist",
  "description": "The first five things, ticked off in place: a ring that fills, checks that draw, and a finish worth seeing.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/onboarding-checklist.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { NumberRoll } from \"./number-roll\";\nimport { TextMorph } from \"./text-morph\";\n\n/* ─────────────────────────────────────────────────────────\n * ONBOARDING CHECKLIST: the first five things, ticked off\n *\n *   next       the first open task is open in place: what it is,\n *              why it matters and the one button that does it\n *   doing      its button spins while your action runs, then a\n *              check draws itself on the row, a strike draws\n *              through the label and the next task opens\n *   progress   a ring fills and \"2 of 5\" rolls with every tick\n *   pick       open any task by its row, done or not\n *   folded     the whole card folds to its header (ring and\n *              count) and opens again\n *   done       the list folds away, the ring fills and becomes a\n *              check with a small burst, and the title morphs to\n *              \"You're all set\"\n *\n * Drive it from your data (done per task) or let it keep its own.\n * ───────────────────────────────────────────────────────── */\n\nexport interface OnboardingTask {\n  id: string;\n  title: string;\n  description?: string;\n  /** The one button that does the task. Return a promise to show progress; it's ticked off when it resolves. */\n  action?: {\n    label: string;\n    /** Shown while a promise runs, e.g. \"Connecting\". */ pendingLabel?: string;\n    onClick?: () => void | Promise<unknown>;\n    href?: string;\n  };\n  /** Controlled: whether it's done. Leave out to let the checklist track it. */\n  done?: boolean;\n}\n\nexport interface OnboardingChecklistProps extends React.HTMLAttributes<HTMLDivElement> {\n  tasks: OnboardingTask[];\n  title?: string;\n  doneTitle?: string;\n  doneDescription?: string;\n  /** Called when a task is ticked off (its action resolved). */\n  onTaskComplete?: (id: string) => void;\n  /** Called with \"Hide\" once everything is done. */\n  onDismiss?: () => void;\n  defaultCollapsed?: boolean;\n}\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst THROW = \"cubic-bezier(0.34,1.36,0.64,1)\";\nconst FOCUS =\n  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Icons trade places through a blur: the old one shrinks away as the new one grows in. */\nconst swap = (on: boolean, reduced: boolean): React.CSSProperties => ({\n  opacity: on ? 1 : 0,\n  transform: on ? \"none\" : \"scale(0.6)\",\n  filter: on ? \"none\" : \"blur(3px)\",\n  transition: reduced\n    ? \"none\"\n    : `opacity 240ms ${EASE}, transform 360ms ${EASE}, filter 240ms ${EASE}`,\n});\n\nfunction Check({\n  drawn,\n  reduced,\n  width = 2,\n  delay = 80,\n}: {\n  drawn: boolean;\n  reduced: boolean;\n  width?: number;\n  delay?: number;\n}) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" className=\"size-full\">\n      <path\n        d=\"M4.2 8.4 6.8 11 11.8 5.4\"\n        stroke=\"currentColor\"\n        strokeWidth={width}\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        pathLength={1}\n        strokeDasharray={1}\n        style={{\n          strokeDashoffset: drawn ? 0 : 1,\n          transition:\n            drawn && !reduced\n              ? `stroke-dashoffset 380ms ${EASE} ${delay}ms`\n              : \"none\",\n        }}\n      />\n    </svg>\n  );\n}\n\n/** The ring that fills with progress, and becomes a check with a small burst when it's full. */\nfunction Ring({\n  value,\n  complete,\n  reduced,\n}: {\n  value: number;\n  complete: boolean;\n  reduced: boolean;\n}) {\n  const c = 2 * Math.PI * 9;\n  const burstRef = React.useRef<HTMLSpanElement>(null);\n  const first = React.useRef(true);\n  React.useEffect(() => {\n    if (first.current) {\n      first.current = false;\n      return;\n    }\n    if (!complete || reduced) return;\n    const dots = burstRef.current?.children;\n    if (!dots) return;\n    Array.from(dots).forEach((dot, i) => {\n      const angle = (i / dots.length) * Math.PI * 2;\n      const dist = 20 + (i % 2) * 6;\n      (dot as HTMLElement).animate(\n        [\n          { transform: \"translate(0,0) scale(1)\", opacity: 0 },\n          { opacity: 1, offset: 0.2 },\n          {\n            transform: `translate(${Math.cos(angle) * dist}px, ${Math.sin(angle) * dist}px) scale(0.4)`,\n            opacity: 0,\n          },\n        ],\n        { duration: 700, easing: EASE, delay: 260 },\n      );\n    });\n  }, [complete, reduced]);\n  return (\n    <span\n      aria-hidden=\"true\"\n      className=\"relative flex size-6 shrink-0 items-center justify-center\"\n    >\n      <svg\n        viewBox=\"0 0 24 24\"\n        className=\"absolute inset-0 size-full -rotate-90\"\n      >\n        <circle\n          cx=\"12\"\n          cy=\"12\"\n          r=\"9\"\n          fill=\"none\"\n          strokeWidth=\"2\"\n          className=\"stroke-border\"\n        />\n        <circle\n          cx=\"12\"\n          cy=\"12\"\n          r=\"9\"\n          fill=\"none\"\n          strokeWidth=\"2\"\n          strokeLinecap=\"round\"\n          strokeDasharray={c}\n          className=\"stroke-primary\"\n          style={{\n            strokeDashoffset: c * (1 - value),\n            transition: reduced ? \"none\" : `stroke-dashoffset 640ms ${EASE}`,\n          }}\n        />\n      </svg>\n      <span\n        className=\"absolute inset-0 rounded-full bg-primary text-primary-foreground\"\n        style={{\n          transform: complete ? \"none\" : \"scale(0.4)\",\n          opacity: complete ? 1 : 0,\n          transition: reduced\n            ? \"none\"\n            : `transform 460ms ${THROW} 180ms, opacity 260ms ${EASE} 180ms`,\n        }}\n      >\n        <span className=\"absolute inset-[5px]\">\n          <Check drawn={complete} reduced={reduced} width={2.4} delay={360} />\n        </span>\n      </span>\n      <span\n        ref={burstRef}\n        className=\"pointer-events-none absolute inset-0 flex items-center justify-center\"\n      >\n        {Array.from({ length: 10 }, (_, i) => (\n          <span\n            key={i}\n            className=\"absolute size-1 rounded-full bg-primary opacity-0\"\n          />\n        ))}\n      </span>\n    </span>\n  );\n}\n\nexport function OnboardingChecklist({\n  tasks,\n  title = \"Get started\",\n  doneTitle = \"You’re all set\",\n  doneDescription = \"Everything’s in place. Here’s to the first busy Saturday.\",\n  onTaskComplete,\n  onDismiss,\n  defaultCollapsed = false,\n  className = \"\",\n  ...props\n}: OnboardingChecklistProps) {\n  const reduced = useReducedMotion();\n  const id = React.useId();\n  const [own, setOwn] = React.useState<Set<string>>(() => new Set());\n  const [running, setRunning] = React.useState<string | null>(null);\n  const [collapsed, setCollapsed] = React.useState(defaultCollapsed);\n  const isDone = (t: OnboardingTask) => t.done ?? own.has(t.id);\n  const firstOpen = tasks.find((t) => !isDone(t))?.id ?? null;\n  const [picked, setPicked] = React.useState<string | null>(null);\n  const openId = picked ?? firstOpen;\n  const count = tasks.filter(isDone).length;\n  const complete = count === tasks.length && tasks.length > 0;\n\n  // When the open task gets done, the next open one takes over (unless someone picked a row since).\n  const lastFirst = React.useRef(firstOpen);\n  React.useEffect(() => {\n    if (lastFirst.current !== firstOpen) {\n      lastFirst.current = firstOpen;\n      setPicked(null);\n    }\n  }, [firstOpen]);\n\n  const run = async (task: OnboardingTask) => {\n    if (!task.action || running) return;\n    const result = task.action.onClick?.();\n    if (task.action.href && !task.action.onClick) {\n      window.location.assign(task.action.href);\n      return;\n    }\n    if (result instanceof Promise) {\n      setRunning(task.id);\n      try {\n        await result;\n      } catch {\n        setRunning(null);\n        return;\n      }\n      setRunning(null);\n    }\n    if (task.done === undefined) setOwn((s) => new Set(s).add(task.id));\n    onTaskComplete?.(task.id);\n  };\n\n  return (\n    <section\n      aria-labelledby={`${id}-title`}\n      className={`w-full overflow-hidden rounded-[20px] border border-border bg-background ${className}`}\n      {...props}\n    >\n      <div className=\"flex items-center gap-3 px-4 py-3.5\">\n        <Ring\n          value={tasks.length ? count / tasks.length : 0}\n          complete={complete}\n          reduced={reduced}\n        />\n        <div className=\"min-w-0 flex-1\">\n          <h3\n            id={`${id}-title`}\n            className=\"text-[14px] font-medium leading-5 text-foreground\"\n          >\n            <TextMorph>{complete ? doneTitle : title}</TextMorph>\n          </h3>\n          <p className=\"flex items-baseline gap-[0.3em] text-[12px] leading-4 text-muted-foreground tabular-nums\">\n            <NumberRoll value={count} duration={700} /> of {tasks.length} done\n          </p>\n        </div>\n        <span role=\"status\" className=\"sr-only\">\n          {complete ? doneTitle : `${count} of ${tasks.length} done`}\n        </span>\n        {complete && onDismiss ? (\n          <button\n            type=\"button\"\n            onClick={onDismiss}\n            className={`cursor-pointer h-8 rounded-full px-3 text-[12.5px] font-medium text-foreground shadow-[inset_0_0_0_1px_var(--border)] transition-colors hover:bg-accent animate-[ui-fade-in_300ms_ease-out_400ms_both] motion-reduce:animate-none ${FOCUS}`}\n          >\n            Hide\n          </button>\n        ) : (\n          <button\n            type=\"button\"\n            aria-expanded={!collapsed}\n            aria-controls={`${id}-list`}\n            aria-label={collapsed ? \"Show checklist\" : \"Fold checklist\"}\n            onClick={() => setCollapsed((c) => !c)}\n            className={`cursor-pointer flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground ${FOCUS}`}\n          >\n            <svg\n              aria-hidden=\"true\"\n              viewBox=\"0 0 12 12\"\n              className=\"size-3 transition-transform duration-300 motion-reduce:transition-none\"\n              style={{\n                transform: collapsed ? \"none\" : \"rotate(180deg)\",\n                transitionTimingFunction: EASE,\n              }}\n            >\n              <path\n                d=\"m3 4.5 3 3 3-3\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                strokeWidth=\"1.4\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n              />\n            </svg>\n          </button>\n        )}\n      </div>\n\n      {/* Done: the list folds away and a line says so. */}\n      <div\n        aria-hidden={!complete || undefined}\n        className=\"grid\"\n        style={{\n          gridTemplateRows: complete ? \"1fr\" : \"0fr\",\n          opacity: complete ? 1 : 0,\n          transition: reduced\n            ? \"none\"\n            : `grid-template-rows 460ms ${EASE} 200ms, opacity 360ms ${EASE} 320ms`,\n        }}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <p className=\"px-4 pb-4 text-[13px] leading-relaxed text-muted-foreground\">\n            {doneDescription}\n          </p>\n        </div>\n      </div>\n\n      <div\n        id={`${id}-list`}\n        inert={collapsed || complete}\n        className=\"grid\"\n        style={{\n          gridTemplateRows: collapsed || complete ? \"0fr\" : \"1fr\",\n          opacity: collapsed || complete ? 0 : 1,\n          transition: reduced\n            ? \"none\"\n            : `grid-template-rows 460ms ${EASE}, opacity ${collapsed || complete ? \"180ms\" : \"360ms\"} ${EASE}`,\n        }}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <ol className=\"border-t border-border p-1.5\">\n            {tasks.map((task, i) => {\n              const done = isDone(task);\n              const open = task.id === openId;\n              const busy = running === task.id;\n              return (\n                <li\n                  key={task.id}\n                  className={`rounded-[14px] transition-colors duration-300 ${open ? \"bg-accent/60\" : \"\"}`}\n                >\n                  <button\n                    type=\"button\"\n                    aria-expanded={open}\n                    aria-controls={`${id}-t${i}`}\n                    onClick={() =>\n                      setPicked(\n                        open\n                          ? task.id === firstOpen\n                            ? \"__none__\"\n                            : null\n                          : task.id,\n                      )\n                    }\n                    className={`cursor-pointer flex w-full items-center gap-3 rounded-[14px] px-2.5 py-2.5 text-left ${FOCUS}`}\n                  >\n                    {/* An open ring that becomes a filled, drawn check. */}\n                    <span\n                      aria-hidden=\"true\"\n                      className=\"relative flex size-5 shrink-0 items-center justify-center\"\n                    >\n                      <span\n                        className=\"absolute inset-0 rounded-full shadow-[inset_0_0_0_1.5px_var(--border)]\"\n                        style={swap(!done, reduced)}\n                      />\n                      <span\n                        className=\"absolute inset-0 rounded-full bg-foreground text-background\"\n                        style={swap(done, reduced)}\n                      >\n                        <Check drawn={done} reduced={reduced} />\n                      </span>\n                    </span>\n                    <span className=\"min-w-0 flex-1 text-[13.5px]\">\n                      {/* The strike draws itself through the label once it's done. */}\n                      <span\n                        className={`bg-[linear-gradient(currentColor,currentColor)] bg-no-repeat [background-position:0_58%] transition-colors duration-300 ${done ? \"text-muted-foreground\" : \"text-foreground\"}`}\n                        style={{\n                          backgroundSize: done ? \"100% 1px\" : \"0% 1px\",\n                          transition: reduced\n                            ? \"none\"\n                            : `background-size 480ms ${EASE} 120ms, color 300ms`,\n                        }}\n                      >\n                        {task.title}\n                      </span>\n                      <span className=\"sr-only\">{done ? \", done\" : \"\"}</span>\n                    </span>\n                  </button>\n                  <div\n                    id={`${id}-t${i}`}\n                    inert={!open}\n                    className=\"grid\"\n                    style={{\n                      gridTemplateRows: open ? \"1fr\" : \"0fr\",\n                      opacity: open ? 1 : 0,\n                      transition: reduced\n                        ? \"none\"\n                        : `grid-template-rows 420ms ${EASE}, opacity ${open ? \"320ms\" : \"140ms\"} ${EASE}`,\n                    }}\n                  >\n                    <div className=\"min-h-0 overflow-hidden\">\n                      <div className=\"pb-3 pl-[42px] pr-3\">\n                        {task.description && (\n                          <p className=\"text-[12.5px] leading-relaxed text-muted-foreground\">\n                            {task.description}\n                          </p>\n                        )}\n                        {task.action && !done && (\n                          <button\n                            type=\"button\"\n                            onClick={() => run(task)}\n                            aria-busy={busy || undefined}\n                            className={`cursor-pointer mt-3 inline-flex h-8 items-center rounded-full bg-primary px-3.5 text-[12.5px] font-medium text-primary-foreground transition-[background-color,transform] duration-200 hover:bg-primary/90 active:scale-[0.97] ${FOCUS}`}\n                          >\n                            <span\n                              aria-hidden=\"true\"\n                              className=\"flex shrink-0 items-center justify-center overflow-hidden\"\n                              style={{\n                                width: busy ? 18 : 0,\n                                transition: reduced\n                                  ? \"none\"\n                                  : `width 320ms ${EASE}`,\n                              }}\n                            >\n                              <span\n                                className={`size-3 rounded-full border-[1.5px] border-primary-foreground/40 border-t-primary-foreground motion-reduce:animate-none ${busy ? \"animate-spin\" : \"\"}`}\n                              />\n                            </span>\n                            <TextMorph>\n                              {busy\n                                ? (task.action.pendingLabel ?? \"Working on it\")\n                                : task.action.label}\n                            </TextMorph>\n                          </button>\n                        )}\n                      </div>\n                    </div>\n                  </div>\n                </li>\n              );\n            })}\n          </ol>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/number-roll.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * NUMBER ROLL: numbers that change like an odometer\n *\n *   rolling   each digit is a column that rolls to its new\n *             value, in the direction the number moved: going\n *             up, a 9 rolls on to 0 instead of spinning back\n *   places    new places slide open from nothing; lost ones\n *             fold away\n *   format    anything Intl.NumberFormat does: currency,\n *             percent, compact (\"1.2K\"), decimals\n *\n * The real number is always there as text for screen readers\n * and copy and paste; the columns are only what you see.\n * ───────────────────────────────────────────────────────── */\n\nexport interface NumberRollProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  value: number;\n  /** Intl.NumberFormat options, e.g. { style: \"currency\", currency: \"USD\" }. */\n  format?: Intl.NumberFormatOptions;\n  locales?: string | string[];\n  prefix?: string;\n  suffix?: string;\n  /** Start from this value and roll to `value` once mounted, e.g. 0 for stats. */\n  from?: number;\n  /** Roll duration in ms. */\n  duration?: number;\n  /** Always roll this way, e.g. \"down\" for a countdown's seconds, which wrap from 00 to 59. Defaults to the way the number moved. */\n  direction?: \"up\" | \"down\";\n}\n\ntype Column = { key: string; char: string; digit: number | null };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst SETS = 5; // the strip repeats 0–9 five times so a roll never runs out of digits\nconst MIDDLE = 20;\n/** The strip as one text node, a digit a line: fifty lines, but one element to lay out instead of fifty. */\nconst STRIP = Array.from({ length: SETS * 10 }, (_, i) => i % 10).join(\"\\n\");\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Digits are keyed by their place counted from the right, so the units column stays the units column. */\nfunction columns(text: string): Column[] {\n  const chars = [...text];\n  const seen = new Map<string, number>();\n  let place = 0;\n  const out: Column[] = [];\n  for (let i = chars.length - 1; i >= 0; i--) {\n    const char = chars[i];\n    if (/\\d/.test(char))\n      out.push({ key: `d${place++}`, char, digit: Number(char) });\n    else {\n      // Symbols are keyed by how many of the same symbol sit to their right, so a comma that shifts is the same comma.\n      const n = seen.get(char) ?? 0;\n      seen.set(char, n + 1);\n      out.push({ key: `s${char}${n}`, char, digit: null });\n    }\n  }\n  return out.reverse();\n}\n\n// Memoised: a parent that re-renders with the same number doesn't rebuild the strips.\nconst Digit = React.memo(function Digit({\n  digit,\n  trend,\n  duration,\n  reduced,\n  rollIn,\n}: {\n  digit: number;\n  trend: number;\n  duration: number;\n  reduced: boolean;\n  rollIn: boolean;\n}) {\n  const [pos, setPos] = React.useState(MIDDLE + (rollIn ? 0 : digit));\n  const [moving, setMoving] = React.useState(false);\n  const posRef = React.useRef(pos);\n  const stripRef = React.useRef<HTMLSpanElement>(null);\n\n  React.useLayoutEffect(() => {\n    const current = posRef.current;\n    const showing = ((current % 10) + 10) % 10;\n    if (showing === digit) return;\n    if (reduced) {\n      posRef.current = MIDDLE + digit;\n      setMoving(false);\n      setPos(MIDDLE + digit);\n      return;\n    }\n    const up = trend > 0 || (trend === 0 && digit > showing);\n    let target = up\n      ? current + ((digit - showing + 10) % 10)\n      : current - ((showing - digit + 10) % 10);\n    // Values arriving faster than a roll (a progress percent) never let it re-centre, so before it runs off the strip,\n    // jump the strip back by whole sets mid-roll (it looks identical) and roll on from there.\n    if (target < 10 || target > SETS * 10 - 11) {\n      const shift = Math.round((target - MIDDLE) / 10) * 10;\n      const strip = stripRef.current;\n      if (strip?.offsetHeight) {\n        let visual = current;\n        try {\n          visual =\n            -new DOMMatrixReadOnly(getComputedStyle(strip).transform).m42 /\n            (strip.offsetHeight / (SETS * 10));\n        } catch {}\n        const transition = strip.style.transition;\n        strip.style.transition = \"none\";\n        strip.style.transform = `translateY(${(-(visual - shift) * 100) / (SETS * 10)}%)`;\n        void strip.offsetHeight;\n        strip.style.transition = transition;\n      }\n      target -= shift;\n    }\n    posRef.current = target;\n    setMoving(true);\n    setPos(target);\n  }, [digit, trend, reduced]);\n\n  // After a roll, quietly re-centre on the middle set so the next roll always has room.\n  const settle = () => {\n    const centred = MIDDLE + (((posRef.current % 10) + 10) % 10);\n    posRef.current = centred;\n    setMoving(false);\n    setPos(centred);\n  };\n\n  return (\n    <span className=\"relative inline-block [clip-path:inset(0)]\">\n      <span className=\"invisible\">{digit}</span>\n      <span\n        ref={stripRef}\n        aria-hidden=\"true\"\n        onTransitionEnd={settle}\n        className=\"absolute inset-x-0 top-0 block whitespace-pre text-center\"\n        style={{\n          transform: `translateY(${(-pos * 100) / (SETS * 10)}%)`,\n          transition: moving ? `transform ${duration}ms ${EASE}` : \"none\",\n        }}\n      >\n        {STRIP}\n      </span>\n    </span>\n  );\n});\n\n/** A place that appeared after the first paint slides open; places that were there from the start just sit. */\nfunction Place({\n  enter,\n  children,\n}: {\n  enter: boolean;\n  children: React.ReactNode;\n}) {\n  const [entering] = React.useState(enter);\n  return (\n    <span\n      className={`inline-block ${entering ? \"[clip-path:inset(0)] animate-[ui-col-in_500ms_cubic-bezier(0.16,1,0.3,1)_both]\" : \"\"}`}\n    >\n      {children}\n    </span>\n  );\n}\n\nexport function NumberRoll({\n  value,\n  format,\n  locales,\n  prefix = \"\",\n  suffix = \"\",\n  from,\n  duration = 900,\n  direction,\n  className = \"\",\n  ...props\n}: NumberRollProps) {\n  const reduced = useReducedMotion();\n  const [shown, setShown] = React.useState(from ?? value);\n  const previous = React.useRef(shown);\n  const mounted = React.useRef(false);\n\n  // Roll from `from` to the real value once on screen (a frame later, so the start is painted).\n  React.useEffect(() => {\n    const frame = requestAnimationFrame(() => setShown(value));\n    return () => cancelAnimationFrame(frame);\n  }, [value]);\n\n  React.useEffect(() => {\n    mounted.current = true;\n  }, []);\n\n  const formatter = React.useMemo(\n    () => new Intl.NumberFormat(locales, format),\n    [locales, format && JSON.stringify(format)],\n  );\n  const text = `${prefix}${formatter.format(shown)}${suffix}`;\n  const cols = React.useMemo(() => columns(text), [text]);\n  const trend =\n    direction === \"up\"\n      ? 1\n      : direction === \"down\"\n        ? -1\n        : Math.sign(shown - previous.current);\n\n  // Places that disappear fold away instead of vanishing.\n  const [leaving, setLeaving] = React.useState<Column[]>([]);\n  const lastCols = React.useRef(cols);\n  React.useLayoutEffect(() => {\n    const gone = lastCols.current.filter(\n      (c) => !cols.some((n) => n.key === c.key),\n    );\n    lastCols.current = cols;\n    previous.current = shown;\n    if (!gone.length || reduced) return;\n    setLeaving(gone);\n    const timer = window.setTimeout(() => setLeaving([]), 420);\n    return () => window.clearTimeout(timer);\n  }, [cols, shown, reduced]);\n\n  return (\n    <span className={`inline-flex tabular-nums ${className}`} {...props}>\n      <span className=\"sr-only\">{`${prefix}${formatter.format(value)}${suffix}`}</span>\n      <span\n        aria-hidden=\"true\"\n        className=\"inline-flex items-baseline whitespace-pre\"\n      >\n        {leaving.map((c) => (\n          <span\n            key={`out-${c.key}`}\n            className=\"inline-block [clip-path:inset(0)] animate-[ui-col-out_400ms_cubic-bezier(0.16,1,0.3,1)_forwards]\"\n          >\n            {c.char}\n          </span>\n        ))}\n        {cols.map((c) => (\n          <Place key={c.key} enter={mounted.current && !reduced}>\n            {c.digit === null ? (\n              c.char\n            ) : (\n              <Digit\n                digit={c.digit}\n                trend={trend}\n                duration={duration}\n                reduced={reduced}\n                rollIn={mounted.current}\n              />\n            )}\n          </Place>\n        ))}\n      </span>\n    </span>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/text-morph.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * TEXT MORPH: text that changes the way it should\n *\n *   shared   letters both texts share stay alive and slide to\n *            their new place (\"Save\" → \"Saving\" keeps \"Sav\")\n *   new      letters that weren't there rise in out of a blur,\n *            one after another\n *   gone     letters that leave lift away and blur out where\n *            they stood\n *   width    the box eases to its new width, so a button or\n *            pill holding it resizes with it\n *\n * Texts with little in common crossfade as a whole instead of\n * flinging single letters across. The real text is always\n * there for screen readers.\n * ───────────────────────────────────────────────────────── */\n\nexport interface TextMorphProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  children: string;\n  /** Morph time in ms. */\n  duration?: number;\n  /** Where new letters come from: below (\"up\") or above (\"down\"). */\n  direction?: \"up\" | \"down\";\n  /** Ease the box's width too; turn off for text that wraps. */\n  animateWidth?: boolean;\n}\n\ntype Glyph = { key: number; char: string };\ntype Leaving = Glyph & { x: number; y: number };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Keep the letters two texts share (longest common subsequence); everything else is new. */\nfunction morph(\n  previous: Glyph[],\n  text: string,\n  nextKey: () => number,\n): Glyph[] {\n  const a = previous.map((g) => g.char);\n  const b = Array.from(text);\n  const fresh = () => b.map((char) => ({ key: nextKey(), char }));\n  if (!a.length || !b.length) return fresh();\n\n  const dp = Array.from(\n    { length: a.length + 1 },\n    () => new Uint16Array(b.length + 1),\n  );\n  for (let i = a.length - 1; i >= 0; i--)\n    for (let j = b.length - 1; j >= 0; j--)\n      dp[i][j] =\n        a[i] === b[j]\n          ? dp[i + 1][j + 1] + 1\n          : Math.max(dp[i + 1][j], dp[i][j + 1]);\n\n  // Too little in common reads as two different words: crossfade them instead.\n  if (dp[0][0] < Math.min(a.length, b.length) * 0.5) return fresh();\n\n  const out: Glyph[] = [];\n  let i = 0;\n  let j = 0;\n  while (j < b.length) {\n    if (i < a.length && a[i] === b[j]) {\n      out.push(previous[i++]);\n      j++;\n    } else if (i < a.length && dp[i + 1][j] >= dp[i][j + 1]) i++;\n    else out.push({ key: nextKey(), char: b[j++] });\n  }\n  return out;\n}\n\nfunction LeavingGlyph({\n  glyph,\n  lift,\n  duration,\n  onDone,\n}: {\n  glyph: Leaving;\n  lift: number;\n  duration: number;\n  onDone: (key: number) => void;\n}) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const animation = el.animate(\n      [\n        { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n        { opacity: 0, filter: \"blur(4px)\", transform: `translateY(${lift}em)` },\n      ],\n      { duration: duration * 0.6, easing: EASE, fill: \"forwards\" },\n    );\n    animation.onfinish = () => onDone(glyph.key);\n    return () => animation.cancel();\n  }, [glyph.key, lift, duration, onDone]);\n  return (\n    <span\n      ref={ref}\n      aria-hidden=\"true\"\n      className=\"pointer-events-none absolute whitespace-pre\"\n      style={{ left: glyph.x, top: glyph.y }}\n    >\n      {glyph.char}\n    </span>\n  );\n}\n\nexport function TextMorph({\n  children: text,\n  duration = 460,\n  direction = \"up\",\n  animateWidth = true,\n  className = \"\",\n  ...props\n}: TextMorphProps) {\n  const reduced = useReducedMotion();\n  const counter = React.useRef(text.length);\n  const nextKey = React.useCallback(() => ++counter.current, []);\n  const [glyphs, setGlyphs] = React.useState<Glyph[]>(() =>\n    Array.from(text).map((char, i) => ({ key: i + 1, char })),\n  );\n  const [leaving, setLeaving] = React.useState<Leaving[]>([]);\n  const rootRef = React.useRef<HTMLSpanElement>(null);\n  const els = React.useRef(new Map<number, HTMLSpanElement>());\n  const before = React.useRef<{\n    at: Map<number, { x: number; y: number }>;\n    width: number;\n  } | null>(null);\n  const rise = direction === \"up\" ? 0.35 : -0.35;\n\n  // A preference change must also finish an in-flight morph whose target text\n  // already matches the glyphs (including the empty label in a folded receipt).\n  React.useLayoutEffect(() => {\n    if (!reduced) return;\n    before.current = null;\n    const root = rootRef.current;\n    root\n      ?.getAnimations({ subtree: true })\n      .forEach((animation) => animation.cancel());\n    if (root) root.style.whiteSpace = \"\";\n    setLeaving((previous) => (previous.length ? [] : previous));\n  }, [reduced]);\n\n  // 1. The text changed: note where every letter stands, then work out which letters stay.\n  React.useLayoutEffect(() => {\n    if (text === glyphs.map((g) => g.char).join(\"\")) return;\n    const root = rootRef.current;\n    if (!root || reduced) {\n      setLeaving([]);\n      setGlyphs(Array.from(text).map((char) => ({ key: nextKey(), char })));\n      return;\n    }\n    const box = root.getBoundingClientRect();\n    const at = new Map<number, { x: number; y: number }>();\n    els.current.forEach((el, key) => {\n      const r = el.getBoundingClientRect();\n      at.set(key, { x: r.left - box.left, y: r.top - box.top });\n    });\n    before.current = { at, width: box.width };\n    const next = morph(glyphs, text, nextKey);\n    const kept = new Set(next.map((g) => g.key));\n    setLeaving((l) => [\n      ...l,\n      ...glyphs\n        .filter((g) => !kept.has(g.key))\n        .map((g) => ({ ...g, ...(at.get(g.key) ?? { x: 0, y: 0 }) })),\n    ]);\n    setGlyphs(next);\n  }, [text, reduced]);\n\n  // 2. The new letters are in place: glide the ones that stayed, raise the new ones, ease the width.\n  React.useLayoutEffect(() => {\n    const prev = before.current;\n    const root = rootRef.current;\n    if (!prev || !root) return;\n    before.current = null;\n    const box = root.getBoundingClientRect();\n    let order = 0;\n    for (const g of glyphs) {\n      const el = els.current.get(g.key);\n      if (!el) continue;\n      const from = prev.at.get(g.key);\n      if (from) {\n        const r = el.getBoundingClientRect();\n        const dx = from.x - (r.left - box.left);\n        const dy = from.y - (r.top - box.top);\n        if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5)\n          el.animate(\n            [\n              { transform: `translate(${dx}px, ${dy}px)` },\n              { transform: \"none\" },\n            ],\n            { duration, easing: EASE },\n          );\n      } else {\n        el.animate(\n          [\n            {\n              opacity: 0,\n              filter: \"blur(4px)\",\n              transform: `translateY(${rise}em)`,\n            },\n            { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n          ],\n          {\n            duration,\n            easing: EASE,\n            delay: Math.min(order++ * 16, 160),\n            fill: \"backwards\",\n          },\n        );\n      }\n    }\n    if (animateWidth && Math.abs(prev.width - box.width) > 0.5) {\n      // Hold the words on one line while the box is narrower than them, or \"No credits left\" would wrap mid-morph.\n      root.style.whiteSpace = \"nowrap\";\n      const resize = root.animate(\n        [{ width: `${prev.width}px` }, { width: `${box.width}px` }],\n        { duration, easing: EASE },\n      );\n      resize.onfinish = resize.oncancel = () => {\n        root.style.whiteSpace = \"\";\n      };\n    }\n  }, [glyphs, duration, rise, animateWidth]);\n\n  const done = React.useCallback(\n    (key: number) => setLeaving((l) => l.filter((g) => g.key !== key)),\n    [],\n  );\n\n  // Words stay unbroken; lines may only wrap at spaces.\n  const words: Glyph[][] = [];\n  for (const g of glyphs) {\n    if (\n      g.char === \" \" ||\n      !words.length ||\n      words[words.length - 1][0]?.char === \" \"\n    )\n      words.push([g]);\n    else words[words.length - 1].push(g);\n  }\n\n  return (\n    <span\n      ref={rootRef}\n      className={`relative inline-block ${className}`}\n      {...props}\n    >\n      <span className=\"sr-only\">{text}</span>\n      {words.map((word, w) => (\n        <span\n          key={w}\n          aria-hidden=\"true\"\n          className=\"inline-block whitespace-pre\"\n        >\n          {word.map((g) => (\n            <span\n              key={g.key}\n              ref={(el) => {\n                if (el) els.current.set(g.key, el);\n                else els.current.delete(g.key);\n              }}\n              className=\"inline-block\"\n            >\n              {g.char}\n            </span>\n          ))}\n        </span>\n      ))}\n      {leaving.map((g) => (\n        <LeavingGlyph\n          key={`out-${g.key}`}\n          glyph={g}\n          lift={-rise}\n          duration={duration}\n          onDone={done}\n        />\n      ))}\n    </span>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "css": {
    "@keyframes ui-col-in": {
      "from": {
        "max-width": "0",
        "opacity": "0"
      },
      "to": {
        "max-width": "1em",
        "opacity": "1"
      }
    },
    "@keyframes ui-col-out": {
      "from": {
        "max-width": "1em",
        "opacity": "1"
      },
      "to": {
        "max-width": "0",
        "opacity": "0"
      }
    },
    "@keyframes ui-fade-in": {
      "from": {
        "opacity": "0"
      },
      "to": {
        "opacity": "1"
      }
    }
  },
  "meta": {
    "cavemio": {
      "component": "onboarding-checklist",
      "exportName": "OnboardingChecklist",
      "categories": [
        "app"
      ],
      "isNew": false,
      "usage": "import { OnboardingChecklist } from \"@/components/onboarding-checklist\";\n\n<OnboardingChecklist\n  tasks={[\n    { id: \"menu\", title: \"Add your menu\", description: \"Flavours, sizes and prices.\", action: { label: \"Import menu\", pendingLabel: \"Importing\", onClick: importMenu } },\n    { id: \"payments\", title: \"Connect payments\", action: { label: \"Connect\", href: \"/settings/payments\" } },\n  ]}\n/>",
      "accessibility": "- An ordered list of disclosure buttons, each with aria-expanded; done tasks say so to screen readers. Progress is announced politely (\"3 of 5 done\") and once more when all is done.\n- The action button stays focusable while it runs and is marked aria-busy; a rejected promise leaves the task open to try again.\n- Folded parts are inert, so the keyboard never lands inside them.\n- Installs Number roll and Text morph. With reduced motion, ticks, strikes and the finish change in place without the burst.",
      "previewNote": "Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.",
      "documentation": {
        "props": [
          {
            "name": "tasks",
            "type": "OnboardingTask[]",
            "description": "– · id, title, and any of description, done (controlled), and action { label, pendingLabel?, onClick? (return a promise to show progress), href? }."
          },
          {
            "name": "title / doneTitle / doneDescription",
            "type": "string",
            "description": "\"Get started\" / \"You’re all set\" / … · The heading before and after, and the line shown once everything’s done."
          },
          {
            "name": "onTaskComplete",
            "type": "(id) => void",
            "description": "– · Called when a task’s action resolves; mark it done here if you control done."
          },
          {
            "name": "onDismiss",
            "type": "() => void",
            "description": "– · Shows Hide once everything is done."
          },
          {
            "name": "defaultCollapsed",
            "type": "boolean",
            "description": "false · Start folded to the header."
          }
        ],
        "useCases": [
          {
            "title": "SaaS “Get started” cards",
            "description": "The first five things a new customer should do, on the dashboard."
          },
          {
            "title": "Developer platforms",
            "description": "Create an API key, install the SDK, make a first request."
          },
          {
            "title": "Seller and creator onboarding",
            "description": "Add a product, connect payouts, publish a page."
          },
          {
            "title": "Team setup",
            "description": "Invite teammates, connect integrations, finish the profile."
          }
        ],
        "features": [
          {
            "title": "The next task is open",
            "description": "It shows what the task is, why it matters and the one button that does it."
          },
          {
            "title": "Actions run in place",
            "description": "onClick can return a promise. The button shows a spinner and a pending label, and a failure leaves the task open to try again."
          },
          {
            "title": "Progress is visible",
            "description": "A ring fills a step at a time and “2 of 5” rolls."
          },
          {
            "title": "Finished tasks can be revisited",
            "description": "Click any row to open it, done or not."
          },
          {
            "title": "Progress survives a reload",
            "description": "Pass done from your database, and mark tasks done as their actions land with onTaskComplete."
          },
          {
            "title": "A finish worth seeing",
            "description": "The list folds away, the ring becomes a check with a small burst, and the title reads “You’re all set”."
          }
        ],
        "states": [
          {
            "title": "next",
            "description": "The first open task is expanded with its description and action, on a soft tint."
          },
          {
            "title": "doing",
            "description": "A spinner opens in the button and its label morphs to pendingLabel while your promise runs."
          },
          {
            "title": "ticked",
            "description": "The ring blurs into a filled circle and its check draws (380ms); a strike draws through the label (480ms); this task folds and the next opens (420ms). The ring advances and the count rolls."
          },
          {
            "title": "picked",
            "description": "Clicking any row opens it, done or not; finishing a task returns to the next open one."
          },
          {
            "title": "folded",
            "description": "The chevron folds the list to the header, which keeps the ring and count."
          },
          {
            "title": "done",
            "description": "The list folds, the ring fills and a primary disc grows over it with a check drawing itself, ten dots burst outward (700ms), the title morphs to doneTitle and Hide fades in."
          }
        ]
      }
    }
  },
  "type": "registry:component"
}