{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-milestones",
  "type": "registry:component",
  "title": "Stats Milestones",
  "description": "A company timeline where a playhead sweeps across a cumulative growth curve and wakes each milestone as it passes, rolling its count up. Cards sit in an even row joined to their points on the curve, with a replay button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "stats",
    "stats",
    "timeline",
    "milestones",
    "growth curve",
    "count up",
    "section"
  ],
  "docs": "https://hyperblur.dev/effects/stats-milestones",
  "files": [
    {
      "path": "registry/hyperblur/stats-milestones.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/stats-milestones.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface Milestone {\n  date: string;\n  label: string;\n  value: number;\n  unit?: string;\n  at: number;\n}\n\nexport interface StatsMilestonesProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  milestones?: Milestone[];\n  axis?: string[];\n  duration?: number;\n  replayLabel?: string;\n  accent?: string;\n}\n\nconst css = `\n.hb-wb10 {\n  --hb-wb10-accent: #fb7185;\n  box-sizing: border-box;\n  position: relative;\n  width: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-wb10 *, .hb-wb10 *::before, .hb-wb10 *::after { box-sizing: border-box; }\n.hb-wb10-wrap { max-width: 1160px; margin: 0 auto; padding: 64px 24px 72px; }\n.hb-wb10-head { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: end; gap: 16px 40px; margin-bottom: 24px; }\n.hb-wb10-aside { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }\n.hb-wb10-eyebrow { margin: 0 0 12px; color: #8f8f8f; font-size: 13px; }\n.hb-wb10-eyebrow b { color: var(--hb-wb10-accent); font-weight: 600; }\n.hb-wb10-title { margin: 0; max-width: 620px; font-size: clamp(28px, 3.8cqw, 42px); font-weight: 600; line-height: 1.04; letter-spacing: -.04em; text-wrap: balance; }\n.hb-wb10-sub { margin: 0; max-width: 420px; color: #8f8f8f; font-size: 15px; line-height: 1.6; }\n.hb-wb10-replay { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 8px 14px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 999px; background: rgba(255, 255, 255, .03); color: #ededed; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .25s ease, border-color .25s ease; }\n.hb-wb10-replay:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); }\n.hb-wb10-replay:focus-visible { outline: 2px solid var(--hb-wb10-accent); outline-offset: 2px; }\n.hb-wb10-replay svg { transition: transform .5s cubic-bezier(.2, .8, .2, 1); }\n.hb-wb10-replay:hover svg { transform: rotate(-120deg); }\n.hb-wb10-stage { position: relative; height: 400px; }\n.hb-wb10-cards { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(var(--hb-wb10-n), minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }\n.hb-wb10-chart { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }\n.hb-wb10-plot { position: absolute; left: 0; right: 0; top: 150px; bottom: 34px; }\n.hb-wb10-plot svg, .hb-wb10-links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }\n.hb-wb10-grid line { stroke: rgba(255, 255, 255, .05); vector-effect: non-scaling-stroke; }\n.hb-wb10-curve { fill: none; stroke: var(--hb-wb10-accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linecap: round; }\n.hb-wb10-ghost { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 1.5; stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; }\n.hb-wb10-link { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; transition: stroke .5s ease; }\n.hb-wb10-link[data-on=\"true\"] { stroke: color-mix(in srgb, var(--hb-wb10-accent) 55%, transparent); }\n.hb-wb10-head-line { position: absolute; top: 0; bottom: 0; width: 1px; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--hb-wb10-accent) 70%, transparent) 40%, var(--hb-wb10-accent)); }\n.hb-wb10-head-line::after { content: \"\"; position: absolute; bottom: -4px; left: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--hb-wb10-accent); box-shadow: 0 0 16px var(--hb-wb10-accent); }\n.hb-wb10-axis { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; border-top: 1px solid rgba(255, 255, 255, .08); }\n.hb-wb10-axis span { position: absolute; top: 10px; color: #6f6f6f; font-size: 11.5px; font-family: var(--font-mono, ui-monospace, monospace); transform: translateX(-50%); }\n.hb-wb10-axis span:first-child { transform: none; }\n.hb-wb10-axis span:last-child { transform: translateX(-100%); }\n.hb-wb10-node { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #0a0a0a; border: 2px solid rgba(255, 255, 255, .25); transform: scale(.6); transition: transform .5s cubic-bezier(.3, 1.6, .5, 1), border-color .3s ease, box-shadow .3s ease; }\n.hb-wb10-node[data-on=\"true\"] { transform: scale(1); border-color: var(--hb-wb10-accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--hb-wb10-accent) 18%, transparent); }\n.hb-wb10-node[data-hot=\"true\"] { transform: scale(1.4); }\n.hb-wb10-ms { min-width: 0; }\n.hb-wb10-card {\n  height: 100%;\n  max-height: 112px;\n  overflow: hidden;\n  padding: 12px 14px;\n  border: 1px solid rgba(255, 255, 255, .07);\n  border-radius: 14px;\n  background: linear-gradient(180deg, #151515, #0f0f0f);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);\n  transform: translateY(8px);\n  opacity: .35;\n  outline: none;\n  transition: opacity .5s ease, transform .6s cubic-bezier(.2, .8, .2, 1), border-color .3s ease;\n}\n.hb-wb10-card:hover, .hb-wb10-card:focus-visible { border-color: color-mix(in srgb, var(--hb-wb10-accent) 45%, transparent); }\n.hb-wb10-card:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-wb10-accent) 25%, transparent); }\n.hb-wb10-ms[data-on=\"true\"] .hb-wb10-card { opacity: 1; transform: none; }\n.hb-wb10-date { display: block; color: #8f8f8f; font-size: 11px; font-family: var(--font-mono, ui-monospace, monospace); letter-spacing: .04em; }\n.hb-wb10-count { display: block; margin-top: 6px; font-size: clamp(20px, 2.4cqw, 26px); font-weight: 600; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }\n.hb-wb10-count small { margin-left: 4px; color: #8f8f8f; font-size: 12px; font-weight: 500; letter-spacing: 0; }\n.hb-wb10-label { display: -webkit-box; margin-top: 6px; color: #a1a1a1; font-size: 12px; line-height: 1.35; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }\n.hb-wb10-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@container (max-width: 760px) {\n  .hb-wb10-head { grid-template-columns: minmax(0, 1fr); }\n  .hb-wb10-card { max-height: none; }\n  .hb-wb10-label { -webkit-line-clamp: unset; }\n  .hb-wb10-stage { height: auto; padding-left: 24px; }\n  .hb-wb10-stage::before { content: \"\"; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: rgba(255, 255, 255, .1); }\n  .hb-wb10-stage::after { content: \"\"; position: absolute; left: 5px; top: 6px; width: 1px; height: calc(var(--hb-wb10-p) * (100% - 12px)); background: var(--hb-wb10-accent); }\n  .hb-wb10-chart { display: none; }\n  .hb-wb10-cards { grid-template-columns: minmax(0, 1fr); }\n  .hb-wb10-ms { position: relative; }\n  .hb-wb10-ms::before { content: \"\"; position: absolute; left: -23px; top: 16px; width: 9px; height: 9px; border-radius: 50%; background: #0a0a0a; border: 2px solid rgba(255, 255, 255, .25); }\n  .hb-wb10-ms[data-on=\"true\"]::before { border-color: var(--hb-wb10-accent); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wb10-card, .hb-wb10-node, .hb-wb10-link, .hb-wb10-replay, .hb-wb10-replay svg { transition: none; }\n}\n`;\n\nconst defaultMilestones: Milestone[] = [\n  { date: \"Mar 2021\", label: \"First paying studio signs up\", value: 1, unit: \"studio\", at: 0.03 },\n  { date: \"Jan 2022\", label: \"Public launch and the iPad app\", value: 420, unit: \"studios\", at: 0.2 },\n  { date: \"Oct 2022\", label: \"Seed round closes, team of 14\", value: 2600, unit: \"studios\", at: 0.36 },\n  { date: \"Sep 2023\", label: \"Payments and payouts go live\", value: 11800, unit: \"studios\", at: 0.55 },\n  { date: \"Jun 2025\", label: \"Expansion to 30 countries\", value: 46000, unit: \"studios\", at: 0.79 },\n  { date: \"Oct 2026\", label: \"Booking 1.2M classes a month\", value: 91500, unit: \"studios\", at: 0.97 },\n];\n\nconst STAGE = 400;\nconst PLOT_TOP = 150;\nconst CARD = 112;\n\nconst defaultAxis = [\"2021\", \"2022\", \"2023\", \"2024\", \"2025\", \"2026\"];\n\nfunction compact(v: number) {\n  if (v >= 100000) return `${Math.round(v / 1000)}k`;\n  if (v >= 10000) return `${(v / 1000).toFixed(1)}k`;\n  return Math.round(v).toLocaleString(\"en-US\");\n}\n\nfunction easeInOut(x: number) {\n  return x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;\n}\n\nfunction smooth(points: [number, number][]) {\n  if (points.length < 2) return \"\";\n  let d = `M${points[0][0].toFixed(2)} ${points[0][1].toFixed(2)}`;\n  for (let i = 0; i < points.length - 1; i += 1) {\n    const p0 = points[Math.max(0, i - 1)];\n    const p1 = points[i];\n    const p2 = points[i + 1];\n    const p3 = points[Math.min(points.length - 1, i + 2)];\n    const c1x = p1[0] + (p2[0] - p0[0]) / 6;\n    const c1y = p1[1] + (p2[1] - p0[1]) / 6;\n    const c2x = p2[0] - (p3[0] - p1[0]) / 6;\n    const c2y = p2[1] - (p3[1] - p1[1]) / 6;\n    d += ` C${c1x.toFixed(2)} ${c1y.toFixed(2)} ${c2x.toFixed(2)} ${c2y.toFixed(2)} ${p2[0].toFixed(2)} ${p2[1].toFixed(2)}`;\n  }\n  return d;\n}\n\nexport function StatsMilestones({\n  eyebrow = \"Five years of Pulsewell\",\n  title = \"From one studio to ninety thousand\",\n  subtitle = \"Every number below is a studio that runs its classes, members and payments on Pulsewell today.\",\n  milestones = defaultMilestones,\n  axis = defaultAxis,\n  duration = 3600,\n  replayLabel = \"Replay\",\n  accent = \"#fb7185\",\n  className = \"\",\n  style,\n  ...rest\n}: StatsMilestonesProps) {\n  const uid = React.useId();\n  const ref = React.useRef<HTMLDivElement>(null);\n  const raf = React.useRef(0);\n  const [t, setT] = React.useState(0);\n  const [hot, setHot] = React.useState<number | null>(null);\n\n  const play = React.useCallback(() => {\n    cancelAnimationFrame(raf.current);\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      setT(1);\n      return;\n    }\n    const start = performance.now();\n    const tick = (now: number) => {\n      const p = Math.min((now - start) / Math.max(duration, 400), 1);\n      setT(p);\n      if (p < 1) raf.current = requestAnimationFrame(tick);\n    };\n    raf.current = requestAnimationFrame(tick);\n  }, [duration]);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    if (typeof IntersectionObserver === \"undefined\") {\n      raf.current = requestAnimationFrame(() => setT(1));\n      return () => cancelAnimationFrame(raf.current);\n    }\n    const io = new IntersectionObserver(\n      (entries) => {\n        if (entries.some((e) => e.isIntersecting)) {\n          io.disconnect();\n          play();\n        }\n      },\n      { threshold: 0.3 },\n    );\n    io.observe(el);\n    return () => {\n      io.disconnect();\n      cancelAnimationFrame(raf.current);\n    };\n  }, [play]);\n\n  const head = easeInOut(t);\n  const max = Math.max(...milestones.map((m) => m.value), 1);\n  const H = 100;\n  const yOf = (v: number) => H - 6 - Math.sqrt(v / max) * (H - 14);\n  const pts: [number, number][] = [[0, H - 4], ...milestones.map((m) => [m.at * 1000, yOf(m.value)] as [number, number]), [1000, yOf(max) - 2]];\n  const curve = smooth(pts);\n  const area = `${curve} L1000 ${H} L0 ${H} Z`;\n  const gid = `${uid.replace(/[^a-zA-Z0-9]/g, \"\")}-a`;\n  const clipId = `${uid.replace(/[^a-zA-Z0-9]/g, \"\")}-c`;\n  const n = Math.max(milestones.length, 1);\n  const nodeY = (v: number) => PLOT_TOP + (yOf(v) / H) * (STAGE - PLOT_TOP - 34);\n  const vars = { \"--hb-wb10-accent\": accent, \"--hb-wb10-p\": head.toFixed(4), \"--hb-wb10-n\": n, ...style } as React.CSSProperties;\n\n  return (\n    <section className={`hb-wb10 ${className}`} style={vars} aria-labelledby={`${uid}-t`} {...rest}>\n      <style href=\"hb-stats-milestones\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wb10-wrap\">\n        <div className=\"hb-wb10-head\">\n          <div>\n            <p className=\"hb-wb10-eyebrow\"><b>{eyebrow}</b></p>\n            <h2 id={`${uid}-t`} className=\"hb-wb10-title\">{title}</h2>\n          </div>\n          <div className=\"hb-wb10-aside\">\n            {subtitle && <p className=\"hb-wb10-sub\">{subtitle}</p>}\n          <button type=\"button\" className=\"hb-wb10-replay\" onClick={play}>\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M2.5 8a5.5 5.5 0 1 0 1.7-4M2.5 2.5V5.5h3\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n            {replayLabel}\n          </button>\n          </div>\n        </div>\n        <div ref={ref} className=\"hb-wb10-stage\">\n          <div className=\"hb-wb10-chart\" aria-hidden=\"true\">\n            <div className=\"hb-wb10-plot\">\n              <svg viewBox={`0 0 1000 ${H}`} preserveAspectRatio=\"none\">\n                <defs>\n                  <linearGradient id={gid} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                    <stop offset=\"0\" stopColor={accent} stopOpacity=\".3\" />\n                    <stop offset=\"1\" stopColor={accent} stopOpacity=\"0\" />\n                  </linearGradient>\n                  <clipPath id={clipId}>\n                    <rect x=\"0\" y=\"-20\" width={(head * 1000).toFixed(2)} height={H + 40} />\n                  </clipPath>\n                </defs>\n                <g className=\"hb-wb10-grid\">\n                  {[0.25, 0.5, 0.75].map((g) => <line key={g} x1=\"0\" x2=\"1000\" y1={(H * g).toFixed(2)} y2={(H * g).toFixed(2)} />)}\n                </g>\n                <path className=\"hb-wb10-ghost\" d={curve} />\n                <g clipPath={`url(#${clipId})`}>\n                  <path d={area} fill={`url(#${gid})`} />\n                  <path className=\"hb-wb10-curve\" d={curve} />\n                </g>\n              </svg>\n              {t > 0 && t < 1 && <span className=\"hb-wb10-head-line\" style={{ left: `${(head * 100).toFixed(2)}%` }} />}\n            </div>\n            <svg className=\"hb-wb10-links\" viewBox={`0 0 1000 ${STAGE}`} preserveAspectRatio=\"none\">\n              {milestones.map((m, i) => {\n                const cx = ((i + 0.5) / n) * 1000;\n                const ax = m.at * 1000;\n                const ny = nodeY(m.value);\n                const mid = CARD + 14;\n                return (\n                  <path\n                    key={i}\n                    className=\"hb-wb10-link\"\n                    data-on={head >= m.at - 0.005}\n                    d={`M${cx.toFixed(1)} ${CARD} L${cx.toFixed(1)} ${mid} L${ax.toFixed(1)} ${(mid + 18).toFixed(1)} L${ax.toFixed(1)} ${(ny - 8).toFixed(1)}`}\n                  />\n                );\n              })}\n            </svg>\n            {milestones.map((m, i) => (\n              <span\n                key={i}\n                className=\"hb-wb10-node\"\n                data-on={head >= m.at - 0.005}\n                data-hot={hot === i}\n                style={{ left: `${(m.at * 100).toFixed(2)}%`, top: `${nodeY(m.value).toFixed(1)}px` }}\n              />\n            ))}\n            <div className=\"hb-wb10-axis\">\n              {axis.map((a, i) => (\n                <span key={a} style={{ left: `${((i / Math.max(axis.length - 1, 1)) * 100).toFixed(2)}%` }}>{a}</span>\n              ))}\n            </div>\n          </div>\n          <ol className=\"hb-wb10-cards\">\n            {milestones.map((m, i) => {\n              const on = head >= m.at - 0.005;\n              const local = on ? Math.min(1, (head - m.at) / 0.12) : 0;\n              const shown = t >= 1 ? m.value : m.value * (1 - Math.pow(1 - Math.max(local, 0), 3));\n              return (\n                <li key={`${m.date}-${i}`} className=\"hb-wb10-ms\" data-on={on}>\n                  <div\n                    className=\"hb-wb10-card\"\n                    tabIndex={0}\n                    onPointerEnter={() => setHot(i)}\n                    onPointerLeave={() => setHot(null)}\n                    onFocus={() => setHot(i)}\n                    onBlur={() => setHot(null)}\n                  >\n                    <span className=\"hb-wb10-sr\">{`${m.date}: ${m.label}, ${m.value.toLocaleString(\"en-US\")} ${m.unit ?? \"\"}`}</span>\n                    <span aria-hidden=\"true\">\n                      <span className=\"hb-wb10-date\">{m.date}</span>\n                      <span className=\"hb-wb10-count\">{compact(shown)}<small>{m.unit}</small></span>\n                      <span className=\"hb-wb10-label\">{m.label}</span>\n                    </span>\n                  </div>\n                </li>\n              );\n            })}\n          </ol>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}