{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stats-mosaic",
  "type": "registry:component",
  "title": "Stats Mosaic",
  "description": "A by the numbers bento: counting figures in tiles that each carry a different animated mini visual, from a drawing area chart and uptime bars to a dot field, gauge, avatar marquee and star fill.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "stats",
    "stats",
    "numbers",
    "bento",
    "count up",
    "mini charts",
    "metrics"
  ],
  "docs": "https://hyperblur.dev/effects/stats-mosaic",
  "files": [
    {
      "path": "registry/hyperblur/stats-mosaic.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/stats-mosaic.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type StatsMosaicVisual = \"area\" | \"bars\" | \"dots\" | \"gauge\" | \"faces\" | \"stars\";\n\nexport interface StatsMosaicItem {\n  label: string;\n  value: number;\n  decimals?: number;\n  prefix?: string;\n  suffix?: string;\n  detail: string;\n  visual: StatsMosaicVisual;\n}\n\nexport interface StatsMosaicProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  items?: StatsMosaicItem[];\n  duration?: number;\n  accent?: string;\n}\n\nconst defaultItems: StatsMosaicItem[] = [\n  { label: \"Events processed every month\", value: 2.4, decimals: 1, suffix: \"B\", detail: \"Up 38% since January\", visual: \"area\" },\n  { label: \"Uptime, last 90 days\", value: 99.995, decimals: 3, suffix: \"%\", detail: \"One 4 minute incident\", visual: \"bars\" },\n  { label: \"Countries with active teams\", value: 184, detail: \"From Reykjavik to Wellington\", visual: \"dots\" },\n  { label: \"Median query latency\", value: 41, suffix: \"ms\", detail: \"p95 under 120ms\", visual: \"gauge\" },\n  { label: \"Teams building on Pulse\", value: 12800, detail: \"Including 61 of the Fortune 500\", visual: \"faces\" },\n  { label: \"Average review score\", value: 4.9, decimals: 1, suffix: \"/5\", detail: \"From 3,214 reviews\", visual: \"stars\" },\n];\n\nconst css = `\n.hb-yib {\n  --hb-yib-accent: #22d3ee;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-yib *, .hb-yib *::before, .hb-yib *::after { box-sizing: border-box; }\n.hb-yib-inner { max-width: 1120px; margin: 0 auto; padding: 72px 20px 80px; }\n.hb-yib-head { display: grid; gap: 14px; margin-bottom: 40px; }\n.hb-yib-eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #8f8f8f; }\n.hb-yib-eyebrow::before { content: \"\"; width: 6px; height: 6px; border-radius: 1px; background: var(--hb-yib-accent); box-shadow: 0 0 12px var(--hb-yib-accent); }\n.hb-yib-title { margin: 0; font-size: clamp(30px, 5cqi, 54px); line-height: 1.02; letter-spacing: -.045em; font-weight: 600; max-width: 16ch; }\n.hb-yib-sub { margin: 0; max-width: 440px; font-size: 15px; line-height: 1.6; color: #8f8f8f; }\n.hb-yib-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }\n.hb-yib-tile {\n  position: relative; display: flex; flex-direction: column; min-height: 230px; padding: 22px; border-radius: 20px; overflow: hidden;\n  background: linear-gradient(180deg, #131313, #0e0e0e); border: 1px solid rgba(255, 255, 255, .08);\n  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset; transition: border-color .3s, transform .3s;\n  animation: hb-yib-rise .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--hb-yib-i) * 80ms);\n}\n.hb-yib-tile:hover { border-color: rgba(255, 255, 255, .16); }\n.hb-yib-tile::before {\n  content: \"\"; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;\n  background: radial-gradient(400px circle at 50% 0%, color-mix(in srgb, var(--hb-yib-accent) 12%, transparent), transparent 60%);\n}\n.hb-yib-tile:hover::before { opacity: 1; }\n.hb-yib-num { position: relative; margin: 0; font-size: clamp(36px, 4.4cqi, 52px); line-height: 1; letter-spacing: -.045em; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-yib-num small { font-size: .5em; letter-spacing: -.02em; color: #8f8f8f; margin-left: 2px; }\n.hb-yib-label { position: relative; margin: 10px 0 0; font-size: 14px; color: #c9c9c9; }\n.hb-yib-detail { position: relative; margin: 4px 0 0; font-size: 12px; color: #6f6f6f; }\n.hb-yib-vis { position: relative; margin-top: auto; padding-top: 18px; }\n.hb-yib-area { display: block; width: 100%; height: 120px; overflow: visible; }\n.hb-yib-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hb-yib-draw 2s .3s cubic-bezier(.4, 0, .2, 1) forwards; }\n.hb-yib-fill { opacity: 0; animation: hb-yib-fade 1.2s 1.2s ease forwards; }\n.hb-yib-pulse { animation: hb-yib-blip 2s 2.2s ease-out infinite; transform-box: fill-box; transform-origin: center; opacity: 0; }\n.hb-yib-bars { display: flex; align-items: flex-end; gap: 3px; height: 54px; }\n.hb-yib-bar { flex: 1; height: 100%; border-radius: 2px; background: color-mix(in srgb, #4ade80 75%, #0a0a0a); transform-origin: bottom; animation: hb-yib-grow .5s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(300ms + var(--hb-yib-b) * 22ms); }\n.hb-yib-bar[data-bad=\"true\"] { background: #f59e0b; height: 70%; }\n.hb-yib-barlbl { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: #5f5f5f; }\n.hb-yib-dots { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; }\n.hb-yib-dot { aspect-ratio: 1; border-radius: 50%; background: #222; }\n.hb-yib-dot[data-on=\"true\"] { background: var(--hb-yib-accent); animation: hb-yib-glow 3.2s ease-in-out infinite; animation-delay: calc(var(--hb-yib-d) * 1ms); }\n.hb-yib-gauge { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto; }\n.hb-yib-arc { stroke-dasharray: 100; stroke-dashoffset: 100; animation: hb-yib-arc 1.6s .4s cubic-bezier(.2, .8, .2, 1) forwards; }\n.hb-yib-needle { transform-origin: 60px 60px; transform: rotate(-90deg); animation: hb-yib-needle 1.6s .4s cubic-bezier(.3, 1.3, .5, 1) forwards; }\n.hb-yib-faces { display: grid; gap: 8px; mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }\n.hb-yib-track { display: flex; gap: 8px; width: max-content; animation: hb-yib-slide 26s linear infinite; }\n.hb-yib-track[data-rev=\"true\"] { animation-direction: reverse; animation-duration: 32s; }\n.hb-yib-face { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: none; font-size: 12px; font-weight: 600; color: #0a0a0a; }\n.hb-yib-stars { display: flex; gap: 6px; }\n.hb-yib-star { position: relative; width: 26px; height: 26px; }\n.hb-yib-star svg { position: absolute; inset: 0; width: 100%; height: 100%; }\n.hb-yib-star span { position: absolute; inset: 0; overflow: hidden; width: 0; animation: hb-yib-fillx .5s cubic-bezier(.3, 1.2, .5, 1) forwards; animation-delay: calc(400ms + var(--hb-yib-s) * 140ms); }\n.hb-yib-star span svg { width: 26px; height: 26px; }\n.hb-yib-dist { display: grid; gap: 5px; margin-top: 14px; }\n.hb-yib-dist div { display: grid; grid-template-columns: 14px minmax(0, 1fr) 34px; align-items: center; gap: 8px; font-size: 11px; color: #6f6f6f; font-variant-numeric: tabular-nums; }\n.hb-yib-dist i { display: block; height: 5px; border-radius: 3px; background: #1f1f1f; overflow: hidden; }\n.hb-yib-dist b { display: block; height: 100%; border-radius: 3px; background: #fbbf24; transform-origin: left; animation: hb-yib-growx .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(600ms + var(--hb-yib-s) * 90ms); }\n.hb-yib-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@keyframes hb-yib-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }\n@keyframes hb-yib-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-yib-fade { to { opacity: 1; } }\n@keyframes hb-yib-blip { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(3.2); } }\n@keyframes hb-yib-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }\n@keyframes hb-yib-growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }\n@keyframes hb-yib-glow { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); box-shadow: 0 0 10px var(--hb-yib-accent); } }\n@keyframes hb-yib-arc { to { stroke-dashoffset: var(--hb-yib-arc-end); } }\n@keyframes hb-yib-needle { to { transform: rotate(var(--hb-yib-angle)); } }\n@keyframes hb-yib-slide { to { transform: translateX(-50%); } }\n@keyframes hb-yib-fillx { to { width: var(--hb-yib-w); } }\n@container (min-width: 620px) {\n  .hb-yib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n  .hb-yib-tile[data-wide=\"true\"] { grid-column: span 2; }\n}\n@container (min-width: 900px) {\n  .hb-yib-inner { padding: 104px 32px 112px; }\n  .hb-yib-head { grid-template-columns: minmax(0, 1fr) minmax(0, 440px); align-items: end; }\n  .hb-yib-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }\n  .hb-yib-tile { min-height: 250px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-yib-tile, .hb-yib-line, .hb-yib-fill, .hb-yib-pulse, .hb-yib-bar, .hb-yib-dot[data-on=\"true\"], .hb-yib-arc, .hb-yib-needle, .hb-yib-track, .hb-yib-star span, .hb-yib-dist b { animation: none; }\n  .hb-yib-line { stroke-dashoffset: 0; }\n  .hb-yib-fill { opacity: 1; }\n  .hb-yib-arc { stroke-dashoffset: var(--hb-yib-arc-end); }\n  .hb-yib-needle { transform: rotate(var(--hb-yib-angle)); }\n  .hb-yib-star span { width: var(--hb-yib-w); }\n  .hb-yib-tile, .hb-yib-tile::before { transition: none; }\n}\n`;\n\nfunction hash(n: number) {\n  let x = (n ^ 0x2c1b3c6d) >>> 0;\n  x = Math.imul(x ^ (x >>> 12), 0x297a2d39) >>> 0;\n  x = Math.imul(x ^ (x >>> 15), 0x85ebca6b) >>> 0;\n  return (x ^ (x >>> 13)) >>> 0;\n}\n\nfunction format(v: number, decimals: number) {\n  const fixed = v.toFixed(decimals);\n  const [whole, frac] = fixed.split(\".\");\n  const grouped = whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n  return frac ? `${grouped}.${frac}` : grouped;\n}\n\nfunction useProgress(duration: number) {\n  const [p, setP] = React.useState(0);\n  React.useEffect(() => {\n    let raf = 0;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let start = 0;\n    const step = (t: number) => {\n      if (reduce) {\n        setP(1);\n        return;\n      }\n      if (!start) start = t;\n      const k = Math.min(1, (t - start) / duration);\n      setP(1 - Math.pow(1 - k, 4));\n      if (k < 1) raf = requestAnimationFrame(step);\n    };\n    raf = requestAnimationFrame(step);\n    return () => cancelAnimationFrame(raf);\n  }, [duration]);\n  return p;\n}\n\nconst areaPoints = [18, 22, 20, 28, 26, 34, 31, 40, 38, 47, 44, 55, 52, 63, 61, 72, 70, 84];\n\nfunction Area({ id }: { id: string }) {\n  const w = 400;\n  const h = 120;\n  const max = 90;\n  const pts = areaPoints.map((v, i) => [(i / (areaPoints.length - 1)) * w, h - (v / max) * h] as const);\n  const d = pts.map(([x, y], i) => `${i ? \"L\" : \"M\"}${x.toFixed(1)} ${y.toFixed(1)}`).join(\" \");\n  const last = pts[pts.length - 1];\n  return (\n    <svg className=\"hb-yib-area\" viewBox={`0 0 ${w} ${h}`} preserveAspectRatio=\"none\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id={`${id}-g`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"var(--hb-yib-accent)\" stopOpacity=\".35\" />\n          <stop offset=\"1\" stopColor=\"var(--hb-yib-accent)\" stopOpacity=\"0\" />\n        </linearGradient>\n      </defs>\n      {[0.25, 0.5, 0.75].map((g) => (\n        <line key={g} x1=\"0\" x2={w} y1={(h * g).toFixed(1)} y2={(h * g).toFixed(1)} stroke=\"rgba(255,255,255,.05)\" strokeDasharray=\"3 5\" vectorEffect=\"non-scaling-stroke\" />\n      ))}\n      <path className=\"hb-yib-fill\" d={`${d} L${w} ${h} L0 ${h} Z`} fill={`url(#${id}-g)`} />\n      <path className=\"hb-yib-line\" d={d} fill=\"none\" stroke=\"var(--hb-yib-accent)\" strokeWidth=\"2.5\" strokeLinejoin=\"round\" pathLength={1} vectorEffect=\"non-scaling-stroke\" />\n      <circle className=\"hb-yib-pulse\" cx={last[0].toFixed(1)} cy={last[1].toFixed(1)} r=\"4\" fill=\"var(--hb-yib-accent)\" />\n    </svg>\n  );\n}\n\nfunction Bars() {\n  return (\n    <>\n      <div className=\"hb-yib-bars\" aria-hidden=\"true\">\n        {Array.from({ length: 36 }, (_, i) => (\n          <span key={i} className=\"hb-yib-bar\" data-bad={i === 23} style={{ \"--hb-yib-b\": i } as React.CSSProperties} />\n        ))}\n      </div>\n      <div className=\"hb-yib-barlbl\" aria-hidden=\"true\">\n        <span>90 days ago</span>\n        <span>Today</span>\n      </div>\n    </>\n  );\n}\n\nfunction Dots() {\n  return (\n    <div className=\"hb-yib-dots\" aria-hidden=\"true\">\n      {Array.from({ length: 70 }, (_, i) => {\n        const on = hash(i * 31 + 7) % 100 < 58;\n        return <span key={i} className=\"hb-yib-dot\" data-on={on} style={{ \"--hb-yib-d\": ((i % 14) * 120 + Math.floor(i / 14) * 90).toFixed(0) } as React.CSSProperties} />;\n      })}\n    </div>\n  );\n}\n\nfunction Gauge({ value }: { value: number }) {\n  const ratio = Math.max(0, Math.min(1, 1 - value / 200));\n  const end = (100 - ratio * 100).toFixed(1);\n  const angle = (-90 + ratio * 180).toFixed(1);\n  return (\n    <svg className=\"hb-yib-gauge\" viewBox=\"0 0 120 68\" aria-hidden=\"true\" style={{ \"--hb-yib-arc-end\": end, \"--hb-yib-angle\": `${angle}deg` } as React.CSSProperties}>\n      <path d=\"M10 60 A50 50 0 0 1 110 60\" fill=\"none\" stroke=\"#222\" strokeWidth=\"9\" strokeLinecap=\"round\" />\n      <path className=\"hb-yib-arc\" d=\"M10 60 A50 50 0 0 1 110 60\" fill=\"none\" stroke=\"var(--hb-yib-accent)\" strokeWidth=\"9\" strokeLinecap=\"round\" pathLength={100} />\n      <g className=\"hb-yib-needle\">\n        <line x1=\"60\" y1=\"60\" x2=\"60\" y2=\"20\" stroke=\"#ededed\" strokeWidth=\"2.5\" strokeLinecap=\"round\" />\n      </g>\n      <circle cx=\"60\" cy=\"60\" r=\"5\" fill=\"#ededed\" />\n      <text x=\"10\" y=\"68\" fill=\"#5f5f5f\" fontSize=\"7\">200ms</text>\n      <text x=\"110\" y=\"68\" fill=\"#5f5f5f\" fontSize=\"7\" textAnchor=\"end\">0ms</text>\n    </svg>\n  );\n}\n\nconst faceNames = [\"AK\", \"MR\", \"JL\", \"SO\", \"TP\", \"EV\", \"NB\", \"HC\", \"DW\", \"LF\", \"QI\", \"RY\"];\nconst faceColors = [\"#22d3ee\", \"#a78bfa\", \"#fbbf24\", \"#4ade80\", \"#f472b6\", \"#60a5fa\", \"#fb923c\"];\n\nfunction Faces() {\n  const row = (offset: number) => [...faceNames, ...faceNames].map((n, i) => ({ n, c: faceColors[(i + offset) % faceColors.length] }));\n  return (\n    <div className=\"hb-yib-faces\" aria-hidden=\"true\">\n      {[0, 3].map((o) => (\n        <div key={o} className=\"hb-yib-track\" data-rev={o > 0}>\n          {row(o).map((f, i) => (\n            <span key={i} className=\"hb-yib-face\" style={{ background: f.c }}>\n              {f.n}\n            </span>\n          ))}\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction Stars({ value }: { value: number }) {\n  const path = \"M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.4L12 17.2l-5.7 3.1 1.2-6.4-4.7-4.4 6.4-.8z\";\n  const dist = [82, 12, 4, 1, 1];\n  return (\n    <div aria-hidden=\"true\">\n      <div className=\"hb-yib-stars\">\n        {[0, 1, 2, 3, 4].map((i) => {\n          const fill = Math.max(0, Math.min(1, value - i));\n          return (\n            <span key={i} className=\"hb-yib-star\" style={{ \"--hb-yib-s\": i, \"--hb-yib-w\": `${(fill * 100).toFixed(0)}%` } as React.CSSProperties}>\n              <svg viewBox=\"0 0 24 24\" fill=\"#222\">\n                <path d={path} />\n              </svg>\n              <span>\n                <svg viewBox=\"0 0 24 24\" fill=\"#fbbf24\">\n                  <path d={path} />\n                </svg>\n              </span>\n            </span>\n          );\n        })}\n      </div>\n      <div className=\"hb-yib-dist\">\n        {dist.map((d, i) => (\n          <div key={i} style={{ \"--hb-yib-s\": i } as React.CSSProperties}>\n            <span>{5 - i}</span>\n            <i>\n              <b style={{ width: `${d}%` }} />\n            </i>\n            <span>{`${d}%`}</span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nexport function StatsMosaic({\n  eyebrow = \"By the numbers\",\n  title = \"Small team. Very large numbers.\",\n  subtitle = \"Pulse handles analytics for product teams in 184 countries. Here is what the last quarter looked like.\",\n  items = defaultItems,\n  duration = 1800,\n  accent = \"#22d3ee\",\n  className = \"\",\n  style,\n  ...rest\n}: StatsMosaicProps) {\n  const p = useProgress(duration);\n  const id = React.useId().replace(/:/g, \"\");\n  const wide = (v: StatsMosaicVisual) => v === \"area\" || v === \"faces\";\n  const vars = { \"--hb-yib-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <section className={`hb-yib ${className}`} style={vars} {...rest}>\n      <style href=\"hb-stats-mosaic\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yib-inner\">\n        <div className=\"hb-yib-head\">\n          <div>\n            {eyebrow ? <p className=\"hb-yib-eyebrow\">{eyebrow}</p> : null}\n            <h2 className=\"hb-yib-title\" style={{ marginTop: eyebrow ? 14 : 0 }}>{title}</h2>\n          </div>\n          {subtitle ? <p className=\"hb-yib-sub\">{subtitle}</p> : null}\n        </div>\n        <div className=\"hb-yib-grid\">\n          {items.map((it, i) => {\n            const decimals = it.decimals ?? 0;\n            const shown = format(it.value * p, decimals);\n            return (\n              <div key={it.label} className=\"hb-yib-tile\" data-wide={wide(it.visual)} style={{ \"--hb-yib-i\": i } as React.CSSProperties}>\n                <p className=\"hb-yib-num\">\n                  <span className=\"hb-yib-sr\">\n                    {`${it.prefix ?? \"\"}${format(it.value, decimals)}${it.suffix ?? \"\"}`}\n                  </span>\n                  <span aria-hidden=\"true\">\n                    {it.prefix}\n                    {shown}\n                    {it.suffix ? <small>{it.suffix}</small> : null}\n                  </span>\n                </p>\n                <p className=\"hb-yib-label\">{it.label}</p>\n                <p className=\"hb-yib-detail\">{it.detail}</p>\n                <div className=\"hb-yib-vis\">\n                  {it.visual === \"area\" ? <Area id={`${id}-${i}`} /> : null}\n                  {it.visual === \"bars\" ? <Bars /> : null}\n                  {it.visual === \"dots\" ? <Dots /> : null}\n                  {it.visual === \"gauge\" ? <Gauge value={it.value} /> : null}\n                  {it.visual === \"faces\" ? <Faces /> : null}\n                  {it.visual === \"stars\" ? <Stars value={it.value} /> : null}\n                </div>\n              </div>\n            );\n          })}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}