{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "milestone-roll",
  "title": "Milestone Roll",
  "description": "A counter races through milestones to a 1,000,000 poster over a gradient ground.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "registryDependencies": ["@remocn/gsh"],
  "files": [
    {
      "path": "registry/remocn/milestone-roll/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { loadFont } from \"@remotion/google-fonts/SpaceGrotesk\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst { fontFamily: grotesk } = loadFont(\"normal\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadMono(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serifItalic } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"600\"],\n  subsets: [\"latin\"],\n});\n\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: manrope.fontFamily,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <svg\n        viewBox=\"0 0 124.06 134.26\"\n        style={{ height: \"0.76em\", width: \"auto\" }}\n        aria-hidden\n      >\n        <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n      </svg>\n      <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n    </div>\n  );\n}\n\nexport interface MilestoneRollProps {\n  /** Milestones the counter races through, ascending. The last one is the poster. */\n  milestones?: number[];\n  /** What is being counted, set in the serif italic on the poster and in the top label. */\n  unit?: string;\n  /** Kept for the shared draft API; the colour comes from the halo ground. */\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  /** gradients.sh preset id for the ground. */\n  ground?: GshPresetId;\n  /** Overrides for the ground shader. */\n  groundParams?: Partial<GradientParams>;\n  speed?: number;\n}\n\nconst RUN = 15;\nconst HOLD = 14;\nconst OUT = 6;\nconst SEG = RUN + HOLD + OUT;\nconst FIRST = -2;\n\nconst RACE = Easing.bezier(0.55, 0, 1, 0.45);\nconst MOVE = Easing.bezier(0.83, 0, 0.17, 1);\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst CAMERA = Easing.bezier(0.87, 0, 0.13, 1);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst MORPH = { damping: 200 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#030306\",\n    ink: \"#F7F3EE\",\n    flash: \"#FFF6E8\",\n    flashAlpha: 0.7,\n    preset: \"iris\" as GshPresetId,\n    params: { background: \"#030306\" } as Partial<GradientParams>,\n    veil: [0.5, 0.38, 0.24, 0.12],\n    final: 0.08,\n    ring: [0.8, 1.05, 1.35, 1.7],\n    finalRing: 2.5,\n  },\n  light: {\n    stage: \"#F4F0EA\",\n    ink: \"#16121A\",\n    flash: \"#FFFFFF\",\n    flashAlpha: 0.8,\n    preset: \"iris\" as GshPresetId,\n    params: {\n      background: \"#F4F0EA\",\n      colors: [\"#FFFFFF\", \"#FFB25A\", \"#EF4F86\", \"#4058FF\"],\n    } as Partial<GradientParams>,\n    veil: [0.5, 0.4, 0.28, 0.16],\n    final: 0.1,\n    ring: [0.8, 1.05, 1.35, 1.7],\n    finalRing: 2.5,\n  },\n} as const;\n\nfunction ramp(t: number, from: number, len: number) {\n  return interpolate(t, [from, from + len], [0, 1], CLAMP);\n}\n\nfunction kick(d: number) {\n  if (d < 0) return 0;\n  if (d < 2) return d / 2;\n  const k = Math.max(0, 1 - (d - 2) / 8);\n  return k * k;\n}\n\nfunction shake(d: number, amp: number, seed: number) {\n  if (d < 0 || d > 7) return { x: 0, y: 0 };\n  const k = (1 - d / 7) ** 2;\n  return {\n    x: amp * k * Math.sin(d * 2.7 + seed),\n    y: amp * 0.7 * k * Math.cos(d * 3.3 + seed * 1.7),\n  };\n}\n\nfunction abbreviate(n: number) {\n  if (n >= 1e6) return `${+(n / 1e6).toFixed(1)}M`;\n  if (n >= 1e3) return `${+(n / 1e3).toFixed(1)}K`;\n  return `${n}`;\n}\n\nfunction withCommas(n: number) {\n  return Math.round(n)\n    .toString()\n    .replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n}\n\nexport function MilestoneRoll({\n  milestones = [1000, 10000, 100000, 1000000],\n  unit = \"renders\",\n  theme = \"dark\",\n  ground,\n  groundParams,\n  speed = 1,\n}: MilestoneRollProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const c = THEMES[theme];\n  const tall = H > W;\n  const base = tall ? W * 0.62 : H;\n  const u = Math.min(W / 1280, H / 720);\n\n  const n = milestones.length;\n  const hitAt = (i: number) => FIRST + i * SEG + RUN;\n  const finalAt = hitAt(n - 1);\n\n  let hit = -1;\n  for (let i = 0; i < n; i++) if (t >= hitAt(i)) hit = i;\n  const isFinal = hit === n - 1;\n\n  const step = (arr: readonly number[], i: number) =>\n    arr[Math.max(0, Math.min(arr.length - 1, i))];\n  let ring: number = c.ring[0];\n  let veil: number = c.veil[0];\n  for (let i = 0; i < n; i++) {\n    const k = spring({ frame: t - hitAt(i), fps, config: HEAVY });\n    const toRing = i === n - 1 ? c.finalRing : step(c.ring, i + 1);\n    const toVeil = i === n - 1 ? c.final : step(c.veil, i + 1);\n    ring += (toRing - step(c.ring, i)) * k;\n    veil += (toVeil - step(c.veil, i)) * Math.min(1, k);\n  }\n  const breathe = interpolate(t, [0, 180], [0, 1], CLAMP);\n  const flash = hit >= 0 ? Math.max(0, 1 - (t - hitAt(hit)) / 4) ** 2 : 0;\n\n  const runIdx = hit + 1;\n  const runStart = FIRST + runIdx * SEG;\n  const from = runIdx === 0 ? 0 : milestones[runIdx - 1];\n  const to = milestones[Math.min(runIdx, n - 1)];\n  const race = RACE(ramp(t, runStart, RUN));\n  const value = from + (to - from) * race;\n\n  const h = hit >= 0 && !isFinal ? hitAt(hit) : -1e9;\n  const pPunch = spring({ frame: Math.min(t - h, 60), fps, config: CARD });\n  const push = MOVE(ramp(t, h + HOLD, OUT));\n  const pushDist = 0.8 * H;\n  const inHit = hit >= 0 && !isFinal && t < h + HOLD + OUT;\n\n  let bump = 0;\n  let sx = 0;\n  let sy = 0;\n  for (let i = 0; i < n; i++) {\n    const d = t - hitAt(i) - 3;\n    bump = Math.max(bump, (i === n - 1 ? 1.3 : 0.9) * kick(d));\n    const s = shake(d, (i === n - 1 ? 9 : 6) * u, i * 1.9);\n    sx += s.x;\n    sy += s.y;\n  }\n  const camScale = 1 + 0.03 * bump;\n\n  const runFs = 0.28 * base;\n  const hugeFs = 0.56 * base;\n  const finalText = withCommas(milestones[n - 1]);\n  const digits = finalText.replace(/,/g, \"\").length;\n  const commas = finalText.length - digits;\n  const finalFs = Math.min(\n    0.3 * base,\n    (0.84 * W) / (digits * 0.6 + commas * 0.26),\n  );\n\n  const numberStyle = {\n    fontFamily: grotesk,\n    fontWeight: 300,\n    fontVariantNumeric: \"tabular-nums\",\n    lineHeight: 1,\n    whiteSpace: \"nowrap\",\n  } as const;\n\n  const pFinal = spring({ frame: t - finalAt, fps, config: CARD });\n  const pUnit = spring({ frame: t - finalAt - 6, fps, config: MORPH });\n  const pLogo = spring({ frame: t - finalAt - 12, fps, config: MORPH });\n  const creep = interpolate(t, [finalAt + 4, finalAt + 70], [1, 1.035], {\n    ...CLAMP,\n    easing: CAMERA,\n  });\n\n  const chromeOut = isFinal ? 1 - ENTER(ramp(t, finalAt, 6)) : 1;\n  const runFill = isFinal ? 1 : inHit ? 1 : race;\n  const margin = (tall ? 0.07 : 0.05) * W;\n  const labelFs = (tall ? 0.017 : 0.025) * H;\n\n  return (\n    <AbsoluteFill style={{ background: c.stage, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          transform: `scale(${ring * (1 + 0.04 * breathe)}) rotate(${-8 * breathe}deg)`,\n        }}\n      >\n        <GshGround\n          preset={ground ?? c.preset}\n          params={groundParams ?? c.params}\n          timeOffset={2}\n          timeScale={0.5}\n          style={{ width: \"100%\", height: \"100%\" }}\n        />\n      </AbsoluteFill>\n      <AbsoluteFill style={{ background: c.stage, opacity: veil }} />\n\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          transform: `translate(${sx}px, ${sy}px) scale(${camScale})`,\n          transformOrigin: \"50% 50%\",\n          color: c.ink,\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: margin,\n            right: margin,\n            top: (tall ? 0.06 : 0.07) * H,\n            display: \"flex\",\n            justifyContent: \"space-between\",\n            alignItems: \"center\",\n            fontFamily: mono,\n            fontWeight: 400,\n            fontSize: labelFs,\n            letterSpacing: \"0.06em\",\n            textTransform: \"uppercase\",\n            opacity: chromeOut * ENTER(ramp(t, 0, 10)),\n          }}\n        >\n          <div\n            style={{\n              display: \"flex\",\n              alignItems: \"center\",\n              gap: 0.5 * labelFs,\n            }}\n          >\n            <div\n              style={{\n                width: 0.4 * labelFs,\n                height: 0.4 * labelFs,\n                borderRadius: labelFs,\n                background: c.ink,\n              }}\n            />\n            {unit}\n          </div>\n          <div style={{ display: \"flex\", gap: 1.4 * labelFs }}>\n            {milestones.map((m, i) => (\n              <div\n                key={m}\n                style={{\n                  opacity: i <= hit ? 1 : 0.4,\n                  fontVariantNumeric: \"tabular-nums\",\n                }}\n              >\n                {abbreviate(m)}\n              </div>\n            ))}\n          </div>\n        </div>\n\n        <div\n          style={{\n            position: \"absolute\",\n            left: margin,\n            right: margin,\n            bottom: (tall ? 0.06 : 0.08) * H,\n            height: Math.max(2, 2 * u),\n            opacity: chromeOut * ENTER(ramp(t, 0, 10)),\n          }}\n        >\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              background: c.ink,\n              opacity: 0.2,\n            }}\n          />\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              top: 0,\n              bottom: 0,\n              width: \"100%\",\n              transform: `scaleX(${runFill})`,\n              transformOrigin: \"0% 50%\",\n              background: c.ink,\n            }}\n          />\n        </div>\n\n        {!isFinal && (!inHit || t >= h + HOLD) ? (\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              display: \"flex\",\n              alignItems: \"center\",\n              justifyContent: \"center\",\n              transform: `translateY(${inHit ? (1 - push) * pushDist : 0}px)`,\n            }}\n          >\n            <div\n              style={{\n                ...numberStyle,\n                fontSize: runFs,\n                letterSpacing: \"-0.04em\",\n              }}\n            >\n              {withCommas(inHit ? milestones[hit] : value)}\n            </div>\n          </div>\n        ) : null}\n\n        {inHit ? (\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              display: \"flex\",\n              alignItems: \"center\",\n              justifyContent: \"center\",\n              transform: `translateY(${-push * pushDist}px) scale(${1.3 - 0.3 * pPunch})`,\n              filter:\n                pPunch < 0.9\n                  ? `blur(${Math.max(0, 1 - pPunch) ** 2 * 14 * u}px)`\n                  : undefined,\n            }}\n          >\n            <div\n              style={{\n                ...numberStyle,\n                fontSize: hugeFs,\n                letterSpacing: \"-0.055em\",\n                paddingRight: 0.02 * hugeFs,\n              }}\n            >\n              {abbreviate(milestones[hit])}\n            </div>\n          </div>\n        ) : null}\n\n        {isFinal ? (\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              display: \"flex\",\n              flexDirection: \"column\",\n              alignItems: \"center\",\n              justifyContent: \"center\",\n              transform: `scale(${creep})`,\n            }}\n          >\n            <div\n              style={{\n                ...numberStyle,\n                fontSize: finalFs,\n                letterSpacing: \"-0.05em\",\n                transform: `scale(${1.25 - 0.25 * pFinal})`,\n                filter:\n                  pFinal < 0.9\n                    ? `blur(${Math.max(0, 1 - pFinal) ** 2 * 14 * u}px)`\n                    : undefined,\n                opacity: ramp(t, finalAt - 1, 2),\n              }}\n            >\n              {finalText}\n            </div>\n            <div\n              style={{\n                fontFamily: serifItalic,\n                fontStyle: \"italic\",\n                fontWeight: 400,\n                fontSize: 0.16 * base,\n                lineHeight: 1,\n                letterSpacing: \"-0.02em\",\n                marginTop: 0.005 * base,\n                opacity: ramp(t, finalAt + 6, 4),\n                transform: `translateY(${(1 - pUnit) * 0.06 * base}px)`,\n              }}\n            >\n              {unit}\n            </div>\n          </div>\n        ) : null}\n        {isFinal ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              bottom: (tall ? 0.07 : 0.075) * H,\n              display: \"flex\",\n              justifyContent: \"center\",\n              opacity: ramp(t, finalAt + 12, 5),\n              transform: `translateY(${(1 - pLogo) * 0.04 * H}px)`,\n            }}\n          >\n            <RemocnLogo fontSize={(tall ? 0.024 : 0.05) * H} color={c.ink} />\n          </div>\n        ) : null}\n      </div>\n\n      {flash > 0.01 ? (\n        <AbsoluteFill\n          style={{ background: c.flash, opacity: flash * c.flashAlpha }}\n        />\n      ) : null}\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/milestone-roll.tsx"
    }
  ],
  "type": "registry:component"
}
