{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radial-bars",
  "title": "Radial Bars",
  "description": "A radial bar dial sweeps up to a peak while 2.4M renders per hour counts in the center.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/radial-bars/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadGeistMono } from \"@remotion/google-fonts/GeistMono\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  interpolateColors,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadGeist(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadGeistMono(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\n// gradients.sh \"beam\" palette: the peak bars, its bracket and a soft ground.\nconst BEAM = [\"#f4f7ff\", \"#8fb4ff\", \"#3d5bff\", \"#1a1660\"] as const;\n\nexport interface RadialBarsProps {\n  values?: number[];\n  highlight?: number;\n  value?: string;\n  label?: string;\n  ticks?: string[];\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_GROW = Easing.bezier(0.25, 0.9, 0.3, 1.04);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\nconst TAU = Math.PI * 2;\n\nconst THEMES = {\n  dark: {\n    bg: \"#05060B\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    hair: \"rgba(255,255,255,0.16)\",\n    bar: \"#9A999F\",\n    dimBar: \"#2F3038\",\n    // Peak bars run from the ring outward: deep blue → light tips.\n    beam: [BEAM[2], BEAM[1], BEAM[0]],\n    bracket: BEAM[1],\n    glowPeak: 0.5,\n    glowDisc: 0.5,\n    glowColor: BEAM[2],\n    grain: 0.06,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    hair: \"rgba(18,18,20,0.16)\",\n    bar: \"#6F6D68\",\n    dimBar: \"#D6D4CE\",\n    beam: [BEAM[1], BEAM[2], BEAM[3]],\n    bracket: BEAM[2],\n    glowPeak: 0,\n    glowDisc: 0,\n    glowColor: BEAM[2],\n    grain: 0.045,\n  },\n} as const;\n\nfunction rgba(hex: string, a: number) {\n  const n = Number.parseInt(hex.slice(1), 16);\n  return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a.toFixed(3)})`;\n}\n\nfunction hash(n: number) {\n  const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n  return s - Math.floor(s);\n}\n\nfunction circDist(a: number, b: number, n: number) {\n  const d = Math.abs(a - b) % n;\n  return Math.min(d, n - d);\n}\n\nfunction makeDefaultValues() {\n  const n = 60;\n  return Array.from({ length: n }, (_, i) => {\n    const main = Math.exp(-((circDist(i, 41, n) / 6.5) ** 2));\n    const second = Math.exp(-((circDist(i, 18, n) / 5) ** 2));\n    return 0.16 + 0.84 * main + 0.3 * second + 0.14 * hash(i + 3);\n  });\n}\n\nconst DEFAULT_VALUES = makeDefaultValues();\nconst GROUP = 5;\n\nfunction splitNumber(s: string) {\n  const m = s.match(/^([^\\d]*)([\\d][\\d,]*(?:\\.\\d+)?)(.*)$/);\n  if (!m) return null;\n  const raw = m[2].replace(/,/g, \"\");\n  const decimals = raw.includes(\".\") ? raw.split(\".\")[1].length : 0;\n  return {\n    pre: m[1],\n    num: Number.parseFloat(raw),\n    decimals,\n    comma: m[2].includes(\",\"),\n    post: m[3],\n  };\n}\n\nfunction formatCount(s: string, k: number) {\n  const parts = splitNumber(s);\n  if (!parts) return s;\n  const v = parts.num * k;\n  const fixed = v.toFixed(parts.decimals);\n  const out = parts.comma\n    ? Number(fixed).toLocaleString(\"en-US\", {\n        minimumFractionDigits: parts.decimals,\n        maximumFractionDigits: parts.decimals,\n      })\n    : fixed;\n  return `${parts.pre}${out}${parts.post}`;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={41}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\nexport function RadialBars({\n  values = DEFAULT_VALUES,\n  highlight,\n  value = \"2.4M\",\n  label = \"renders in the peak hour\",\n  ticks = [\"00:00\", \"06:00\", \"12:00\", \"18:00\"],\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: RadialBarsProps) {\n  const t = useCurrentFrame() * speed;\n  const { width, height } = useVideoConfig();\n  const u = Math.min(width / 1280, height / 720);\n  const p = THEMES[theme];\n  const list = values.length ? values : DEFAULT_VALUES;\n  const n = list.length;\n  const maxV = Math.max(...list, 0.0001);\n\n  let center = 0;\n  if (highlight !== undefined) {\n    center = ((Math.round(highlight) % n) + n) % n;\n  } else {\n    let best = -1;\n    for (let i = 0; i < n; i++) {\n      let sum = 0;\n      for (let k = -2; k <= 2; k++) sum += list[(i + k + n) % n];\n      if (sum > best) {\n        best = sum;\n        center = i;\n      }\n    }\n  }\n  const inGroup = (i: number) => circDist(i, center, n) <= (GROUP - 1) / 2;\n\n  const cx = width / 2;\n  const cy = height / 2;\n  const R0 = height * 0.215;\n  const Lmin = 5 * u;\n  const Lmax = height * 0.155;\n  const Rmax = R0 + Lmax;\n  const bw = Math.max(2, ((TAU * R0) / n) * 0.36);\n\n  const SWEEP = 54;\n  const GROW = 22;\n  const START = 6;\n  const step = n > 1 ? SWEEP / (n - 1) : 0;\n  const HIT = START + SWEEP + GROW + 2;\n\n  const stage = interpolate(t, [0, 10], [0, 1], CLAMP);\n  const base = interpolate(t, [0, 26], [0, 1], { ...CLAMP, easing: EASE_IO });\n  const spin = interpolate(t, [0, HIT + 6], [-24, 0], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const push = interpolate(t, [0, HIT + 50], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const scale = 0.955 + 0.045 * push;\n  const focus = interpolate(t, [HIT, HIT + 16], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const bracket = interpolate(t, [HIT + 6, HIT + 24], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const land = interpolate(t, [HIT + 6, HIT + 26], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const count = interpolate(t, [HIT + 6, HIT + 32], [0.6, 1], {\n    ...CLAMP,\n    easing: Easing.bezier(0.22, 1, 0.36, 1),\n  });\n  const labIn = interpolate(t, [HIT + 14, HIT + 32], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const tickIn = interpolate(t, [10, 34], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n\n  const ang = (i: number) => (i / n) * TAU;\n  const groupA0 = ang(center - (GROUP - 1) / 2) - TAU / n / 2;\n  const groupA1 = ang(center + (GROUP - 1) / 2) + TAU / n / 2;\n  let groupMax = 0;\n  for (let i = 0; i < n; i++)\n    if (inGroup(i)) groupMax = Math.max(groupMax, list[i]);\n  const rBracket =\n    R0 + Lmin + (Lmax - Lmin) * (groupMax / maxV) ** 1.5 + 12 * u;\n  const bracketEnd = groupA0 + (groupA1 - groupA0) * bracket;\n  const pt = (r: number, a: number) => ({\n    x: cx + r * Math.sin(a),\n    y: cy - r * Math.cos(a),\n  });\n  const bs = pt(rBracket, groupA0);\n  const be = pt(rBracket, bracketEnd);\n\n  const circumference = TAU * (R0 - 10 * u);\n  const valueSize = 112 * u;\n  const gid = `rb${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n  // Soft beam ground: a wide halo under the dial that blooms toward the peak\n  // as the focus lands, drifting a few px with the frame.\n  const mid = (groupA0 + groupA1) / 2;\n  const drift = Math.sin(t / 40) * 6 * u;\n  const gp = pt(R0 + Lmax * 0.55 + drift, mid);\n  const glowA = p.glowPeak * (0.35 + 0.65 * focus) * stage;\n  const ground = [\n    `radial-gradient(${Rmax * 1.1}px ${Rmax * 0.95}px at ${gp.x}px ${gp.y}px, ${rgba(p.glowColor, 0.7 * glowA)} 0%, transparent 70%)`,\n    p.glowDisc > 0\n      ? `radial-gradient(${Rmax * 1.5}px ${Rmax * 1.5}px at ${cx}px ${cy}px, ${rgba(BEAM[3], 0.8 * p.glowDisc * stage)} 0%, transparent 72%)`\n      : \"none\",\n  ].join(\", \");\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{ transform: `scale(${scale})`, transformOrigin: \"50% 50%\" }}\n      >\n        <AbsoluteFill style={{ background: ground }} />\n        <svg\n          width={width}\n          height={height}\n          style={{ position: \"absolute\", inset: 0, opacity: stage }}\n          aria-hidden\n        >\n          <defs>\n            <radialGradient\n              id={gid}\n              gradientUnits=\"userSpaceOnUse\"\n              cx={cx}\n              cy={cy}\n              r={Rmax}\n            >\n              <stop offset={R0 / Rmax} stopColor={p.beam[0]} />\n              <stop offset={(R0 + Lmax * 0.55) / Rmax} stopColor={p.beam[1]} />\n              <stop offset={1} stopColor={p.beam[2]} />\n            </radialGradient>\n          </defs>\n          <g transform={`rotate(${spin} ${cx} ${cy})`}>\n            <circle\n              cx={cx}\n              cy={cy}\n              r={R0 - 10 * u}\n              fill=\"none\"\n              stroke={p.hair}\n              strokeWidth={Math.max(1, u)}\n              strokeDasharray={`${circumference * base} ${circumference}`}\n              transform={`rotate(-90 ${cx} ${cy})`}\n            />\n            <circle\n              cx={cx}\n              cy={cy}\n              r={Rmax + 4 * u}\n              fill=\"none\"\n              stroke={p.hair}\n              strokeWidth={Math.max(1, u)}\n              strokeDasharray={`${2 * u} ${7 * u}`}\n              opacity={0.7 * tickIn * (1 - 0.5 * focus)}\n            />\n            {list.map((v, i) => {\n              const s = START + i * step;\n              const k = interpolate(t, [s, s + GROW], [0, 1], {\n                ...CLAMP,\n                easing: EASE_GROW,\n              });\n              const vis = interpolate(t, [s - 2, s + 3], [0, 1], CLAMP);\n              if (vis <= 0) return null;\n              const hl = inGroup(i);\n              const len =\n                Lmin + (Lmax - Lmin) * (Math.max(0, v) / maxV) ** 1.5 * k;\n              const a = ang(i);\n              const p0 = pt(R0, a);\n              const p1 = pt(R0 + len, a);\n              const line = {\n                x1: p0.x,\n                y1: p0.y,\n                x2: p1.x,\n                y2: p1.y,\n                strokeWidth: bw,\n                strokeLinecap: \"round\" as const,\n              };\n              if (!hl) {\n                return (\n                  <line\n                    key={`b${i}`}\n                    {...line}\n                    stroke={interpolateColors(focus, [0, 1], [p.bar, p.dimBar])}\n                    opacity={vis}\n                  />\n                );\n              }\n              return (\n                <g key={`b${i}`} opacity={vis}>\n                  {focus < 1 ? (\n                    <line {...line} stroke={p.bar} opacity={1 - focus} />\n                  ) : null}\n                  {focus > 0 ? (\n                    <line {...line} stroke={`url(#${gid})`} opacity={focus} />\n                  ) : null}\n                </g>\n              );\n            })}\n            {bracket > 0 ? (\n              <path\n                d={`M ${bs.x} ${bs.y} A ${rBracket} ${rBracket} 0 0 1 ${be.x} ${be.y}`}\n                fill=\"none\"\n                stroke={p.bracket}\n                strokeWidth={2 * u}\n                strokeLinecap=\"round\"\n              />\n            ) : null}\n          </g>\n        </svg>\n\n        {ticks.map((tk, i) => {\n          const a = (i / ticks.length) * TAU + (spin * Math.PI) / 180;\n          const q = pt(Rmax + 24 * u, a);\n          const sx = Math.sin(a);\n          const sy = -Math.cos(a);\n          return (\n            <div\n              key={tk}\n              style={{\n                position: \"absolute\",\n                left: q.x,\n                top: q.y,\n                transform: `translate(${-50 + sx * 50}%, ${-50 + sy * 50}%)`,\n                fontFamily: mono,\n                fontWeight: 400,\n                fontSize: 14 * u,\n                letterSpacing: \"0.02em\",\n                color: p.muted,\n                fontVariantNumeric: \"tabular-nums\",\n                whiteSpace: \"nowrap\",\n                opacity: tickIn * stage * (1 - 0.35 * focus),\n              }}\n            >\n              {tk}\n            </div>\n          );\n        })}\n\n        <AbsoluteFill\n          style={{\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            flexDirection: \"column\",\n          }}\n        >\n          <div\n            style={{\n              fontFamily: sans,\n              fontWeight: 400,\n              fontSize: valueSize,\n              lineHeight: 0.9,\n              letterSpacing: \"-0.042em\",\n              color: p.fg,\n              fontVariantNumeric: \"tabular-nums\",\n              whiteSpace: \"nowrap\",\n              opacity: land,\n              filter: land < 0.99 ? `blur(${(1 - land) * 8 * u}px)` : undefined,\n              transform: `translateY(${(1 - land) * 18 * u}px) scale(${1.04 - 0.04 * land})`,\n              marginTop: 12 * u,\n            }}\n          >\n            {formatCount(value, count)}\n          </div>\n          <div\n            style={{\n              marginTop: 16 * u,\n              display: \"flex\",\n              alignItems: \"center\",\n              gap: 9 * u,\n              opacity: labIn,\n              transform: `translateY(${(1 - labIn) * 8 * u}px)`,\n            }}\n          >\n            <span\n              style={{\n                width: 9 * u,\n                height: 9 * u,\n                borderRadius: \"50%\",\n                background: accent,\n                flexShrink: 0,\n              }}\n            />\n            <span\n              style={{\n                fontFamily: sans,\n                fontWeight: 400,\n                fontSize: 19 * u,\n                letterSpacing: \"-0.01em\",\n                color: p.muted,\n                whiteSpace: \"nowrap\",\n              }}\n            >\n              {label}\n            </span>\n          </div>\n        </AbsoluteFill>\n      </AbsoluteFill>\n\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 80% 80% at 50% 50%, transparent 62%, ${p.bg} 100%)`,\n          opacity: 0.6,\n        }}\n      />\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/radial-bars.tsx"
    }
  ],
  "type": "registry:component"
}
