{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "departure-board",
  "title": "Departure board",
  "description": "Switch platforms and advance the clock to see the next trains roll onto the board.",
  "dependencies": [
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/recipe-layout.json",
    "https://www.cyberspec.dev/r/badge.json",
    "https://www.cyberspec.dev/r/button.json",
    "https://www.cyberspec.dev/r/segmented-control.json"
  ],
  "files": [
    {
      "path": "registry/cyber/recipes/departure-board.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport { Clock3 } from \"lucide-react\"\nimport { Badge } from \"@/registry/cyber/ui/badge\"\nimport { Button } from \"@/registry/cyber/ui/button\"\nimport { SegmentedControl } from \"@/registry/cyber/ui/segmented-control\"\nimport \"./recipe-layout.css\"\n\nconst services = [\n  { line: \"A\", every: 12, offset: 1, outbound: \"East Pier\", inbound: \"Union Square\" },\n  { line: \"B\", every: 15, offset: 4, outbound: \"Glassworks\", inbound: \"Northgate\" },\n  { line: \"C\", every: 20, offset: 9, outbound: \"Salt Market\", inbound: \"City Hall\" },\n]\nconst startTime = 17 * 60 + 30\nfunction clock(minutes: number) {\n  return [Math.floor(minutes / 60) % 24, minutes % 60].map(part => String(part).padStart(2, \"0\")).join(\":\")\n}\n\nexport default function DepartureBoard() {\n  const [platform, setPlatform] = useState(\"Outbound\")\n  const [elapsed, setElapsed] = useState(0)\n  const inbound = platform === \"Inbound\"\n  const upcoming = services.flatMap(service => {\n    const first = service.offset + (inbound ? 3 : 0)\n    const departure = first + Math.max(0, Math.ceil((elapsed - first) / service.every)) * service.every\n    return [departure, departure + service.every].map(minute => ({\n      line: service.line, destination: inbound ? service.inbound : service.outbound, minute,\n    }))\n  }).sort((a, b) => a.minute - b.minute).slice(0, 4)\n  return (\n    <div className=\"sink-stack\">\n      <SegmentedControl label=\"Platform\" options={[\"Outbound\", \"Inbound\"]} value={platform}\n        onValueChange={next => next && setPlatform(next)} />\n      <div className=\"sink-between\"><span className=\"sink-label\">Grand Terminal</span><strong className=\"sink-metric\">{clock(startTime + elapsed)}</strong></div>\n      <ol className=\"sink-list\" aria-label={`${platform} departures`}>\n        {upcoming.map(({ line, destination, minute }) => (\n          <li className=\"sink-item\" key={`${line}-${minute}`}>\n            <span className=\"sink-row\"><Badge tone={line === \"A\" ? \"signal\" : line === \"B\" ? \"flag\" : \"epic\"}>{line}</Badge><strong>{destination}</strong></span>\n            <span style={{ fontFamily: \"var(--cy-mono)\", color: \"var(--cy-flag)\" }}>{minute === elapsed ? \"Due\" : `${minute - elapsed} min`}</span>\n          </li>\n        ))}\n      </ol>\n      <Button size=\"sm\" onClick={() => setElapsed(current => current + 5)}><Clock3 aria-hidden />Advance 5 minutes</Button>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/recipes/departure-board.tsx"
    }
  ],
  "categories": [
    "recipe",
    "transit"
  ],
  "type": "registry:component"
}
