{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tally-demo",
  "type": "registry:block",
  "title": "Tally: Failover",
  "description": "Animated Dot Chart example, Failover: Jobs by region for an inference platform. Take eu-west offline and its jobs fly to the other three regions, while retries show up as rings. A take on the chart (graph). Fits stats, app UI and about sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "stats",
    "app-ui",
    "about",
    "chart",
    "particle-effect",
    "data",
    "canvas"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/tally#tally-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/tally.json"
  ],
  "files": [
    {
      "path": "components/tally-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { Tally, type TallyItem } from \"@/components/ui/tally\";\n\n// Jobs Corvid ran in the last hour, by region. Hollow rings are jobs that had to be retried.\n// No item sets a color, so the regions take Tally's palette in order: orange, violet, green, pink.\nconst HEALTHY: TallyItem[] = [\n  { id: \"us-east\", label: \"us-east\", value: 4800, hollow: 120 },\n  { id: \"eu-west\", label: \"eu-west\", value: 3600, hollow: 80 },\n  { id: \"ap-south\", label: \"ap-south\", value: 2200, hollow: 60 },\n  { id: \"sa-east\", label: \"sa-east\", value: 1200, hollow: 40 },\n];\n\n// eu-west goes dark: its 3,600 jobs move to the other three, and retries climb while they do.\nconst OUTAGE: TallyItem[] = [\n  { id: \"us-east\", label: \"us-east\", value: 6500, hollow: 220 },\n  { id: \"eu-west\", label: \"eu-west\", value: 0 },\n  { id: \"ap-south\", label: \"ap-south\", value: 3400, hollow: 140 },\n  { id: \"sa-east\", label: \"sa-east\", value: 1900, hollow: 80 },\n];\n\n// Seconds the healthy chart holds before the outage plays on its own, if nobody has touched it.\nconst HOLD = 1.4;\n\nexport function TallyDemo() {\n  const [down, setDown] = React.useState(false);\n  const touched = React.useRef(false);\n  const played = React.useRef(false);\n  const timer = React.useRef(0);\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  // After the first settle, show the outage once, unless the visitor got there first.\n  const onSettle = React.useCallback(() => {\n    if (played.current || touched.current) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    played.current = true;\n    timer.current = window.setTimeout(() => {\n      if (!touched.current) setDown(true);\n    }, HOLD * 1000);\n  }, []);\n\n  const toggle = () => {\n    touched.current = true;\n    window.clearTimeout(timer.current);\n    setDown((d) => !d);\n  };\n\n  return (\n    <div className=\"w-full max-w-3xl overflow-hidden rounded-2xl border border-zinc-950/10 bg-white text-zinc-950 dark:border-white/10 dark:bg-zinc-950 dark:text-white\">\n      <div className=\"flex flex-wrap items-start justify-between gap-3 px-5 pt-5\">\n        <div>\n          <h3 className=\"text-[15px] font-medium tracking-tight\">Jobs by region</h3>\n          <p className=\"mt-0.5 font-mono text-[11px] tracking-wide text-zinc-500 uppercase dark:text-zinc-400\">Corvid inference · last 60 min</p>\n        </div>\n        <p\n          aria-live=\"polite\"\n          className=\"flex items-center gap-2 rounded-full border border-zinc-950/10 px-3 py-1 font-mono text-[11px] text-zinc-600 dark:border-white/10 dark:text-zinc-300\"\n        >\n          <span aria-hidden className={down ? \"size-1.5 rounded-full bg-red-500\" : \"size-1.5 rounded-full bg-emerald-500\"} />\n          {down ? \"eu-west down\" : \"All regions up\"}\n        </p>\n      </div>\n\n      <Tally\n        items={down ? OUTAGE : HEALTHY}\n        unit=\"jobs\"\n        hollowLabel=\"retried\"\n        label=\"Jobs by region in the last hour\"\n        onSettle={onSettle}\n        className=\"mx-5 mt-5 h-[25rem] sm:h-72\"\n      />\n\n      <div className=\"mt-2 flex flex-col gap-3 border-t border-zinc-950/10 px-5 py-4 sm:flex-row sm:items-center sm:justify-between dark:border-white/10\">\n        <p className=\"font-mono text-xs leading-relaxed text-zinc-600 dark:text-zinc-400\">\n          {down\n            ? \"3,600 jobs moved to the nearest healthy regions.\"\n            : \"Every job runs in the region closest to its caller.\"}\n        </p>\n        <button\n          type=\"button\"\n          onClick={toggle}\n          className=\"shrink-0 rounded-full bg-zinc-950 px-4 py-2 font-mono text-xs text-white transition-colors hover:bg-zinc-800 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#2f45e8] dark:bg-white dark:text-zinc-950 dark:hover:bg-zinc-200 dark:focus-visible:outline-[#8b98ff]\"\n        >\n          {down ? \"Bring eu-west back\" : \"Take eu-west offline\"}\n        </button>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}