{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "relay-tuner",
  "title": "Relay tuner",
  "description": "Sweep the FM radio band or seek the next station and watch the carrier lock.",
  "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/readout.json",
    "https://www.cyberspec.dev/r/slider.json"
  ],
  "files": [
    {
      "path": "registry/cyber/recipes/relay-tuner.tsx",
      "content": "\"use client\"\n\nimport { useId, useState } from \"react\"\nimport { RadioTower, ScanLine } from \"lucide-react\"\nimport { Badge } from \"@/registry/cyber/ui/badge\"\nimport { Button } from \"@/registry/cyber/ui/button\"\nimport { Readout } from \"@/registry/cyber/ui/readout\"\nimport { Slider } from \"@/registry/cyber/ui/slider\"\nimport \"./recipe-layout.css\"\n\nconst stations = [\n  { frequency: 91.3, name: \"Lowtide FM\", gain: 0.72 },\n  { frequency: 98.7, name: \"Night Relay\", gain: 1 },\n  { frequency: 105.1, name: \"Glass Radio\", gain: 0.85 },\n]\nconst band = { low: 88, high: 108 }\nconst xAt = (frequency: number) => (frequency - band.low) * 20\n\n// Draw a fixed spectrum so tuning the receiver moves its cursor across the carriers.\nconst spectrum = Array.from({ length: 200 }, (_, bin) => {\n  const frequency = band.low + bin / 10\n  const peaks = stations.map(station => station.gain * Math.exp(-((frequency - station.frequency) ** 2) / 0.58))\n  const noise = Math.abs(Math.sin(bin * 4.25) * Math.cos(bin * 0.61))\n  return 4 + noise * 11 + Math.max(...peaks) * (43 + noise * 35)\n})\n\nexport default function RelayTuner() {\n  const [frequency, setFrequency] = useState(98.7)\n  const gridId = useId()\n  const station = stations.find(station => Math.abs(frequency - station.frequency) < 0.16)\n  const cursor = xAt(frequency)\n  function seek() {\n    const next = stations.find(station => station.frequency > frequency + 0.05) ?? stations[0]\n    setFrequency(next.frequency)\n  }\n\n  return (\n    <div className=\"sink-stack\">\n      <div className=\"sink-between\">\n        <Readout label=\"FM receiver\" value={frequency} precision={1} unit=\"MHz\" size=\"lg\" />\n        <Badge status tone={station ? \"signal\" : \"mute\"}>{station ? \"Locked\" : \"Scanning\"}</Badge>\n      </div>\n      <div style={{ background: \"var(--cy-void)\", border: \"1px solid var(--cy-line-deco)\", padding: \"10px 12px 6px\" }}>\n        <svg viewBox=\"0 0 400 100\" preserveAspectRatio=\"none\" aria-hidden=\"true\" style={{ display: \"block\", width: \"100%\", height: 94 }}>\n          <defs><pattern id={gridId} width=\"20\" height=\"20\" patternUnits=\"userSpaceOnUse\">\n            <path d=\"M0 20V0H20\" fill=\"none\" stroke=\"var(--cy-line-deco)\" strokeWidth=\"0.7\" />\n          </pattern></defs>\n          <rect width=\"400\" height=\"100\" fill={`url(#${gridId})`} />\n          {spectrum.map((height, index) => {\n            const tuned = Math.abs(index * 2 - cursor) < 14\n            return <rect key={index} x={index * 2} y={99 - height} width=\"1.7\" height={height}\n              fill={tuned ? \"var(--cy-signal)\" : \"var(--cy-accent)\"} opacity={tuned ? 1 : 0.75} />\n          })}\n          <path d={`M${cursor} 3V99m-4-96 4 5 4-5`} fill=\"none\" stroke=\"var(--cy-ink-hi)\" strokeWidth=\"1.4\" />\n        </svg>\n        <div aria-hidden=\"true\" style={{ display: \"flex\", justifyContent: \"space-between\", font: \"12px var(--cy-mono)\", color: \"var(--cy-ink-mute)\" }}>\n          {[88, 93, 98, 103, 108].map(mark => <span key={mark}>{mark}</span>)}\n        </div>\n      </div>\n      <Slider label=\"Tuning\" value={frequency} min={band.low} max={band.high} step={0.1} ticks={20}\n        format={value => `${value.toFixed(1)} MHz`} onValueChange={setFrequency} />\n      <div className=\"sink-between\">\n        <span className=\"sink-row\" role=\"status\"><RadioTower size={16} aria-hidden />{station?.name ?? \"Interstation noise\"}</span>\n        <Button size=\"sm\" onClick={seek}><ScanLine aria-hidden />Seek next</Button>\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/recipes/relay-tuner.tsx"
    }
  ],
  "categories": [
    "recipe",
    "instruments"
  ],
  "type": "registry:component"
}
