{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ridgeline",
  "title": "Ridgeline",
  "description": "Stacked ridgeline distributions per year, the latest one lit in gradient with a 2.6x stat.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/ridgeline/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: bricolage } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface RidgelineProps {\n  labels?: string[];\n  highlightLabel?: string;\n  value?: string;\n  caption?: string;\n  axisLabel?: string;\n  ticks?: string[];\n  accent?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_LABELS = [\"2020\", \"2021\", \"2022\", \"2023\", \"2024\", \"2025\"];\nconst DEFAULT_TICKS = [\"0\", \"5\", \"10\", \"15\", \"20\", \"25\", \"30\"];\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    line: \"#9A999F\",\n    axis: \"rgba(255,255,255,0.18)\",\n    // gradients.sh \"aurora\" across the hero ridge; third stop follows `accent`\n    aurora: [\"#a0f0c8\", \"#3fb5a3\", \"accent\", \"#b25c9c\"],\n    tint: 0.62,\n    grain: 0.06,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    line: \"#7D7B76\",\n    axis: \"rgba(18,18,20,0.2)\",\n    aurora: [\"#3fb5a3\", \"#2f9c8c\", \"accent\", \"#b25c9c\"],\n    tint: 0.32,\n    grain: 0.045,\n  },\n} as const;\n\nconst BASE_AT = 0;\nconst BASE_STAGGER = 3;\nconst BASE_DRAW = 22;\nconst RISE_AT = 12;\nconst RISE_STAGGER = 7;\nconst ACCENT_RISE = 58;\nconst SHIFT = [62, 100] as const;\nconst HIT = 96;\nconst SAMPLES = 180;\n\nfunction hash(n: number) {\n  const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n  return x - Math.floor(x);\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, pointerEvents: \"none\" }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={29}\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\nconst gauss = (x: number, m: number, s: number) =>\n  Math.exp(-((x - m) ** 2) / (2 * s * s));\n\ninterface Shape {\n  m: number;\n  s: number;\n  m2: number;\n  s2: number;\n  w2: number;\n}\n\nfunction shapeFor(i: number, n: number): Shape {\n  const k = n > 1 ? i / (n - 1) : 0;\n  const side = hash(i + 7.7) > 0.45 ? 1 : -1;\n  return {\n    m: 0.25 + 0.14 * k + (hash(i + 0.7) - 0.5) * 0.04,\n    s: 0.055 + 0.03 * hash(i + 3.1),\n    m2: 0.25 + 0.14 * k + side * (0.08 + 0.06 * hash(i + 5.3)),\n    s2: 0.035 + 0.025 * hash(i + 8.9),\n    w2: 0.35 + 0.5 * hash(i + 2.2),\n  };\n}\n\nfunction density(x: number, sh: Shape, shift: number) {\n  return gauss(x, sh.m + shift, sh.s) + sh.w2 * gauss(x, sh.m2 + shift, sh.s2);\n}\n\nfunction peakOf(sh: Shape) {\n  let best = 0;\n  for (let i = 0; i <= 200; i++) best = Math.max(best, density(i / 200, sh, 0));\n  return best || 1;\n}\n\nexport function Ridgeline({\n  labels = DEFAULT_LABELS,\n  highlightLabel = \"With remocn\",\n  value = \"2.6×\",\n  caption = \"more videos per team\",\n  axisLabel = \"videos per team, per month\",\n  ticks = DEFAULT_TICKS,\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: RidgelineProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const u = Math.min(W / 1280, H / 720);\n  const p = THEMES[theme];\n\n  const greys = labels.slice(0, 6);\n  const n = greys.length + 1;\n  const x0 = W * 0.19;\n  const x1 = W * 0.92;\n  const yFirst = H * 0.36;\n  const yLast = H * 0.82;\n  const gap = n > 1 ? (yLast - yFirst) / (n - 1) : 0;\n  const greyH = Math.min(gap * 2.3, H * 0.17);\n  const accentH = Math.min(gap * 4, H * 0.33);\n\n  const push = interpolate(t, [0, HIT + 30], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const camScale = 0.975 + 0.025 * push;\n  const shift = interpolate(t, SHIFT, [0, 1], { ...CLAMP, easing: EASE_IO });\n\n  const rows = Array.from({ length: n }, (_, i) => {\n    const isHl = i === n - 1;\n    const sh = isHl\n      ? { m: 0.4, s: 0.085, m2: 0.5, s2: 0.06, w2: 0.45 }\n      : shapeFor(i, n - 1);\n    const norm = peakOf(sh);\n    const baseStart = BASE_AT + i * BASE_STAGGER;\n    const draw = interpolate(t, [baseStart, baseStart + BASE_DRAW], [0, 1], {\n      ...CLAMP,\n      easing: EASE_IO,\n    });\n    const riseAt = isHl ? ACCENT_RISE : RISE_AT + i * RISE_STAGGER;\n    const rise = spring({\n      frame: t - riseAt,\n      fps,\n      config: isHl\n        ? { damping: 20, stiffness: 70, mass: 1 }\n        : { damping: 18, stiffness: 110, mass: 0.8 },\n    });\n    const amp = (isHl ? accentH : greyH * (0.86 + 0.14 * hash(i + 4.4))) * rise;\n    const off = isHl ? 0.28 * shift : 0;\n    return {\n      i,\n      isHl,\n      sh,\n      norm,\n      draw,\n      amp,\n      off,\n      label: isHl ? highlightLabel : greys[i],\n      y: yFirst + i * gap,\n      labelIn: interpolate(t, [baseStart + 4, baseStart + 18], [0, 1], {\n        ...CLAMP,\n        easing: EASE_OUT,\n      }),\n    };\n  });\n\n  const paths = rows.map((r) => {\n    const end = Math.max(0.0001, r.draw);\n    const pts: string[] = [];\n    const steps = Math.max(2, Math.ceil(SAMPLES * end));\n    for (let k = 0; k <= steps; k++) {\n      const nx = (end * k) / steps;\n      const yv = (density(nx, r.sh, r.off) / r.norm) * r.amp;\n      pts.push(\n        `${k ? \"L\" : \"M\"}${(x0 + (x1 - x0) * nx).toFixed(2)} ${(r.y - yv).toFixed(2)}`,\n      );\n    }\n    const line = pts.join(\" \");\n    const xEnd = x0 + (x1 - x0) * end;\n    const fill = `${line} L${xEnd.toFixed(2)} ${r.y.toFixed(2)} L${x0.toFixed(2)} ${r.y.toFixed(2)} Z`;\n    return { line, fill };\n  });\n\n  const hit = spring({\n    frame: t - HIT,\n    fps,\n    config: { damping: 16, stiffness: 160, mass: 0.7 },\n  });\n  const hitO = interpolate(t, [HIT, HIT + 8], [0, 1], CLAMP);\n  const capIn = interpolate(t, [HIT + 8, HIT + 26], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const axisIn = interpolate(t, [10, 30], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const quiet = interpolate(t, [ACCENT_RISE, ACCENT_RISE + 24], [1, 0.62], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n\n  const stroke = Math.max(1, u);\n  const axisY = yLast + 22 * u;\n  const valueSize = 112 * u;\n\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const hl = rows[n - 1];\n  const auroraW = (x1 - x0) * 0.2;\n  const auroraX = x0 + (x1 - x0) * (0.44 + hl.off) + auroraW * 0.15 * push;\n  const auroraStops = p.aurora.map((c) => (c === \"accent\" ? accent : c));\n\n  const ridgeEls: React.ReactNode[] = rows.map((r, idx) =>\n    r.draw <= 0.01 ? null : (\n      <g key={r.label + String(idx)}>\n        <path d={paths[idx].fill} fill={p.bg} />\n        {r.isHl && (\n          <path\n            d={paths[idx].fill}\n            fill={`url(#${uid}-aurora)`}\n            mask={`url(#${uid}-fade)`}\n          />\n        )}\n        <path\n          d={paths[idx].line}\n          fill=\"none\"\n          stroke={r.isHl ? `url(#${uid}-aurora)` : p.line}\n          strokeOpacity={r.isHl ? 1 : quiet}\n          strokeWidth={(r.isHl ? 2.6 : 1.6) * u}\n          strokeLinejoin=\"round\"\n          strokeLinecap=\"round\"\n        />\n      </g>\n    ),\n  );\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          transform: `scale(${camScale})`,\n          transformOrigin: \"50% 55%\",\n        }}\n      >\n        <svg\n          width={W}\n          height={H}\n          style={{ position: \"absolute\", inset: 0 }}\n          aria-hidden\n        >\n          <defs>\n            <linearGradient\n              id={`${uid}-aurora`}\n              gradientUnits=\"userSpaceOnUse\"\n              x1={auroraX - auroraW}\n              y1={0}\n              x2={auroraX + auroraW}\n              y2={0}\n            >\n              {auroraStops.map((c, k) => (\n                <stop\n                  key={c}\n                  offset={k / (auroraStops.length - 1)}\n                  stopColor={c}\n                />\n              ))}\n            </linearGradient>\n            <linearGradient id={`${uid}-fadeg`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n              <stop offset=\"0\" stopColor=\"#fff\" stopOpacity={p.tint} />\n              <stop offset=\"1\" stopColor=\"#fff\" stopOpacity={0.03} />\n            </linearGradient>\n            <mask\n              id={`${uid}-fade`}\n              maskUnits=\"userSpaceOnUse\"\n              x={0}\n              y={0}\n              width={W}\n              height={H}\n            >\n              <rect\n                x={0}\n                y={hl.y - accentH}\n                width={W}\n                height={accentH}\n                fill={`url(#${uid}-fadeg)`}\n              />\n            </mask>\n          </defs>\n          {ridgeEls}\n          <line\n            x1={x0}\n            x2={x0 + (x1 - x0) * axisIn}\n            y1={axisY}\n            y2={axisY}\n            stroke={p.axis}\n            strokeWidth={stroke}\n          />\n          {ticks.map((tk, k) => {\n            const x = x0 + ((x1 - x0) * k) / Math.max(1, ticks.length - 1);\n            return (\n              <line\n                key={tk}\n                x1={x}\n                x2={x}\n                y1={axisY}\n                y2={axisY + 6 * u}\n                stroke={p.axis}\n                strokeWidth={stroke}\n                opacity={axisIn}\n              />\n            );\n          })}\n        </svg>\n\n        {rows.map((r) => (\n          <div\n            key={`lab${r.i}`}\n            style={{\n              position: \"absolute\",\n              left: x0 - 18 * u - 200 * u,\n              width: 200 * u,\n              top: r.y - 22 * u,\n              textAlign: \"right\",\n              fontFamily: bricolage,\n              fontWeight: r.isHl ? 500 : 400,\n              fontSize: 17 * u,\n              lineHeight: `${22 * u}px`,\n              letterSpacing: \"-0.01em\",\n              color: r.isHl ? p.fg : p.muted,\n              fontVariantNumeric: \"tabular-nums\",\n              opacity: r.labelIn * (r.isHl ? 1 : 0.5 + 0.5 * quiet),\n              transform: `translateX(${(1 - r.labelIn) * 8 * u}px)`,\n              whiteSpace: \"nowrap\",\n            }}\n          >\n            {r.label}\n          </div>\n        ))}\n\n        {ticks.map((tk, k) => {\n          const x = x0 + ((x1 - x0) * k) / Math.max(1, ticks.length - 1);\n          return (\n            <div\n              key={`t${tk}`}\n              style={{\n                position: \"absolute\",\n                left: x - 40 * u,\n                width: 80 * u,\n                top: axisY + 12 * u,\n                textAlign: \"center\",\n                fontFamily: bricolage,\n                fontWeight: 500,\n                fontSize: 15 * u,\n                color: p.muted,\n                fontVariantNumeric: \"tabular-nums\",\n                opacity: axisIn,\n              }}\n            >\n              {tk}\n            </div>\n          );\n        })}\n        <div\n          style={{\n            position: \"absolute\",\n            right: W - x1,\n            top: axisY + 38 * u,\n            fontFamily: bricolage,\n            fontWeight: 500,\n            fontSize: 15 * u,\n            color: p.muted,\n            opacity: axisIn,\n            whiteSpace: \"nowrap\",\n          }}\n        >\n          {axisLabel}\n        </div>\n\n        {value ? (\n          <div\n            style={{\n              position: \"absolute\",\n              right: W - x1,\n              top: H * 0.09,\n              textAlign: \"right\",\n              opacity: hitO,\n              transform: `translateY(${(1 - hit) * 20 * u}px)`,\n            }}\n          >\n            <div\n              style={{\n                fontFamily: bricolage,\n                fontWeight: 400,\n                fontSize: valueSize,\n                lineHeight: 0.95,\n                letterSpacing: \"-0.02em\",\n                color: p.fg,\n                fontVariantNumeric: \"tabular-nums\",\n                whiteSpace: \"nowrap\",\n              }}\n            >\n              {value}\n            </div>\n            <div\n              style={{\n                marginTop: 8 * u,\n                fontFamily: bricolage,\n                fontWeight: 500,\n                fontSize: 20 * u,\n                letterSpacing: \"-0.01em\",\n                color: p.muted,\n                opacity: capIn,\n                transform: `translateY(${(1 - capIn) * 8 * u}px)`,\n                whiteSpace: \"nowrap\",\n              }}\n            >\n              {caption}\n            </div>\n          </div>\n        ) : null}\n      </AbsoluteFill>\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/ridgeline.tsx"
    }
  ],
  "type": "registry:component"
}
