{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "standings-launch-demo",
  "type": "registry:block",
  "title": "Standings: Launch Day",
  "description": "Animated Leaderboard example, Launch Day: A launch board on the day, ranked by live votes, where a fast riser works its way to the top. A take on the leaderboard (ranking). Fits hero, features and stats sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "hero",
    "features",
    "stats",
    "leaderboard",
    "chart",
    "data",
    "motion"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/standings#standings-launch-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/standings.json"
  ],
  "files": [
    {
      "path": "components/standings-launch-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Standings, type StandingsEntry } from \"@/components/ui/standings\";\n\nconst TICK = 900; // ms between vote updates\nconst DAY = 30; // updates before the board starts a new day\n\ntype Product = { id: string; label: string; detail: string; from: string; to: string; votes: number; pace: [number, number]; you?: boolean };\n\n// Launch day on Dawnlist, a board for new products. Inkwell launches fourth\n// and gathers votes faster than the products above it.\nconst PRODUCTS: Product[] = [\n  { id: \"parcel\", label: \"Parcel Pigeon\", detail: \"Shipping labels in one click\", from: \"#38bdf8\", to: \"#0369a1\", votes: 412, pace: [5, 13] },\n  { id: \"quietly\", label: \"Quietly\", detail: \"Noise cancelling for calls\", from: \"#a3e635\", to: \"#4d7c0f\", votes: 388, pace: [5, 14] },\n  { id: \"moss\", label: \"Moss\", detail: \"Plant care, on a schedule\", from: \"#4ade80\", to: \"#15803d\", votes: 351, pace: [4, 12] },\n  { id: \"inkwell\", label: \"Inkwell\", detail: \"An AI editor for long documents\", from: \"#ff8a3d\", to: \"#ff3d00\", votes: 296, pace: [17, 29], you: true },\n  { id: \"tidy\", label: \"Tidy Tabs\", detail: \"Your tabs, sorted by project\", from: \"#c084fc\", to: \"#7e22ce\", votes: 240, pace: [3, 11] },\n  { id: \"brightwave\", label: \"Brightwave\", detail: \"Podcast clips for social\", from: \"#f472b6\", to: \"#be185d\", votes: 198, pace: [3, 10] },\n];\n\nconst START = Object.fromEntries(PRODUCTS.map((p) => [p.id, p.votes]));\n\n/** A small deterministic random, so every day plays out the same way. */\nfunction random(seed: number) {\n  const x = Math.sin(seed * 12.9898) * 43758.5453;\n  return x - Math.floor(x);\n}\n\nfunction Mark({ from, to, label }: { from: string; to: string; label: string }) {\n  return (\n    <span\n      className=\"grid size-full place-items-center text-[13px] font-semibold text-white\"\n      style={{ backgroundImage: `linear-gradient(150deg, ${from}, ${to})` }}\n    >\n      {label[0]}\n    </span>\n  );\n}\n\nconst clock = (tick: number) => {\n  const minutes = 9 * 60 + 12 + tick * 17;\n  return `${Math.floor(minutes / 60)}:${String(minutes % 60).padStart(2, \"0\")}`;\n};\n\nexport function StandingsLaunchDemo() {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const [tick, setTick] = React.useState(0);\n  const [votes, setVotes] = React.useState(START);\n\n  // Votes come in while the board is on screen.\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    let timer = 0;\n    let seen = false;\n    let n = 0;\n    let current = START;\n    const run = () => {\n      window.clearInterval(timer);\n      timer = window.setInterval(() => {\n        n += 1;\n        if (n > DAY) {\n          n = 0;\n          current = START;\n        } else {\n          const next: Record<string, number> = {};\n          for (const p of PRODUCTS) {\n            // Inkwell's early rush settles once it's had its morning.\n            const [lo, hi] = p.you && n > 14 ? [6, 15] : p.pace;\n            next[p.id] = current[p.id] + Math.round(lo + (hi - lo) * random(n * 31 + p.votes));\n          }\n          current = next;\n        }\n        setTick(n);\n        setVotes(current);\n      }, TICK);\n    };\n    const io = new IntersectionObserver(([entry]) => {\n      seen = entry.isIntersecting;\n      if (seen && !document.hidden) run();\n      else window.clearInterval(timer);\n    });\n    io.observe(el);\n    const onVisibility = () => (seen && !document.hidden ? run() : window.clearInterval(timer));\n    document.addEventListener(\"visibilitychange\", onVisibility);\n    return () => {\n      window.clearInterval(timer);\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVisibility);\n    };\n  }, []);\n\n  const entries = React.useMemo<StandingsEntry[]>(\n    () =>\n      PRODUCTS.map((p) => ({\n        id: p.id,\n        label: p.label,\n        detail: p.detail,\n        you: p.you,\n        value: votes[p.id],\n        icon: <Mark from={p.from} to={p.to} label={p.label} />,\n      })),\n    [votes],\n  );\n\n  return (\n    <div\n      ref={ref}\n      className=\"w-full max-w-xl rounded-2xl border border-zinc-950/[0.08] bg-white text-zinc-950 shadow-[0_1px_2px_rgb(0_0_0/0.04),0_12px_32px_-12px_rgb(0_0_0/0.12)] dark:border-white/10 dark:bg-zinc-950 dark:text-zinc-50\"\n    >\n      <div className=\"flex items-center justify-between gap-3 border-b border-zinc-950/[0.07] px-5 py-4 dark:border-white/[0.08]\">\n        <div className=\"min-w-0\">\n          <p className=\"text-[13px] font-semibold tracking-[-0.01em]\">Launching today on Dawnlist</p>\n          <p className=\"mt-0.5 text-xs text-zinc-500 dark:text-zinc-400\">Ranked by votes · resets at midnight</p>\n        </div>\n        <p className=\"flex shrink-0 items-center gap-2 rounded-full border border-zinc-950/[0.08] py-1 pr-2.5 pl-2 text-xs font-medium tabular-nums dark:border-white/10\">\n          <span className=\"size-1.5 rounded-full bg-rose-500\" aria-hidden />\n          Live · {clock(tick)}\n        </p>\n      </div>\n      <Standings\n        aria-label=\"Today's launches, ranked by votes\"\n        entries={entries}\n        className=\"px-2 pt-1 pb-2 [--standings-surface:#ffffff] dark:[--standings-surface:#09090b]\"\n      />\n    </div>\n  );\n}\n"
    }
  ]
}