{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retro-tv",
  "title": "Retro TV",
  "author": "VenusUI",
  "description": "A wood-cased CRT set: turn the channel knob through static, or switch it off to a closing line.",
  "files": [
    {
      "path": "registry/default/ui/retro-tv.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface TvChannel {\n  src: string\n  alt: string\n  name: string\n}\n\ninterface RetroTvProps extends React.ComponentProps<\"div\"> {\n  channels: TvChannel[]\n  defaultChannel?: number\n  onChannelChange?: (index: number) => void\n}\n\n/**\n * A wood-cased CRT set. Turn the channel knob (click, drag or arrow keys) and\n * the picture breaks into static before the next channel tunes in. The power\n * button collapses the picture to a line, like the real thing.\n */\nfunction RetroTv({ channels, defaultChannel = 0, onChannelChange, className, ...props }: RetroTvProps) {\n  const [channel, setChannel] = React.useState(defaultChannel)\n  const [on, setOn] = React.useState(true)\n  const [tuning, setTuning] = React.useState(false)\n  const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)\n  const id = React.useId().replace(/[^a-zA-Z0-9]/g, \"\")\n  const current = channels[channel]\n\n  React.useEffect(() => () => clearTimeout(timer.current), [])\n\n  const tune = (next: number) => {\n    const index = (next + channels.length) % channels.length\n    setChannel(index)\n    onChannelChange?.(index)\n    setTuning(true)\n    clearTimeout(timer.current)\n    timer.current = setTimeout(() => setTuning(false), 420)\n  }\n\n  return (\n    <div data-slot=\"retro-tv\" className={cn(\"w-full max-w-md\", className)} {...props}>\n      <svg aria-hidden=\"true\" className=\"absolute size-0\">\n        <filter id={`${id}-static`}>\n          <feTurbulence type=\"fractalNoise\" baseFrequency=\"0.85\" numOctaves=\"1\" seed=\"1\">\n            <animate attributeName=\"seed\" values=\"1;5;9;3;7;2;8\" dur=\"0.35s\" repeatCount=\"indefinite\" />\n          </feTurbulence>\n          <feColorMatrix type=\"saturate\" values=\"0\" />\n        </filter>\n      </svg>\n      <div className=\"flex gap-3 rounded-2xl bg-[linear-gradient(90deg,#7c4a24,#9a5f30_40%,#6b3d1c)] p-3 shadow-[0_18px_30px_-14px_rgb(0_0_0/0.65),inset_0_1px_0_rgb(255_255_255/0.2)]\">\n        {/* Screen */}\n        <div className=\"relative aspect-[4/3] min-w-0 flex-1 overflow-hidden rounded-[22%/18%] bg-neutral-950 shadow-[inset_0_0_0_6px_#262626,inset_0_0_30px_rgb(0_0_0/0.9)]\">\n          <div className={cn(\"absolute inset-2 overflow-hidden rounded-[20%/16%] transition-[transform,opacity] duration-500 motion-reduce:transition-none\", on ? \"scale-100 opacity-100\" : \"scale-x-90 scale-y-[0.005] opacity-0\")}>\n            <img src={current.src} alt={current.alt} className=\"size-full object-cover saturate-[1.15]\" />\n            {tuning ? <span aria-hidden=\"true\" className=\"absolute inset-0 bg-neutral-500\" style={{ filter: `url(#${id}-static)` }} /> : null}\n            <span aria-hidden=\"true\" className=\"absolute inset-0 bg-[repeating-linear-gradient(0deg,rgb(0_0_0/0.22)_0_1px,transparent_1px_3px)]\" />\n            <span aria-hidden=\"true\" className=\"absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_55%,rgb(0_0_0/0.55))]\" />\n            <span aria-hidden=\"true\" className=\"absolute top-[6%] left-[8%] h-1/4 w-1/3 -rotate-12 rounded-full bg-white/10 blur-md\" />\n            <span aria-live=\"polite\" className=\"absolute top-[8%] right-[10%] font-mono text-sm font-bold text-lime-300 drop-shadow-[0_0_4px_rgb(190_242_100/0.8)]\">\n              {on ? `CH ${String(channel + 1).padStart(2, \"0\")}` : \"\"}\n            </span>\n          </div>\n        </div>\n        {/* Controls */}\n        <div className=\"flex w-16 shrink-0 flex-col items-center justify-between rounded-lg bg-neutral-900/80 py-3\">\n          <button\n            type=\"button\"\n            role=\"slider\"\n            aria-label=\"Channel\"\n            aria-valuemin={1}\n            aria-valuemax={channels.length}\n            aria-valuenow={channel + 1}\n            aria-valuetext={`Channel ${channel + 1}, ${current.name}`}\n            onClick={() => tune(channel + 1)}\n            onKeyDown={(event) => {\n              const step = event.key === \"ArrowUp\" || event.key === \"ArrowRight\" ? 1 : event.key === \"ArrowDown\" || event.key === \"ArrowLeft\" ? -1 : 0\n              if (!step) return\n              event.preventDefault()\n              tune(channel + step)\n            }}\n            className=\"relative size-12 rounded-full bg-[conic-gradient(#525252,#a3a3a3,#404040,#d4d4d4,#525252)] shadow-[0_3px_6px_rgb(0_0_0/0.6)] outline-none transition-[rotate] duration-200 focus-visible:ring-3 focus-visible:ring-ring/60 motion-reduce:transition-none\"\n            style={{ rotate: `${(channel / channels.length) * 360}deg` }}\n          >\n            <span aria-hidden=\"true\" className=\"absolute top-1 left-1/2 h-3 w-1 -translate-x-1/2 rounded-full bg-neutral-100\" />\n          </button>\n          <div aria-hidden=\"true\" className=\"space-y-1\">\n            {[0, 1, 2, 3].map((i) => (\n              <span key={i} className=\"block h-0.5 w-8 rounded-full bg-neutral-700\" />\n            ))}\n          </div>\n          <button\n            type=\"button\"\n            role=\"switch\"\n            aria-checked={on}\n            aria-label=\"Power\"\n            onClick={() => setOn(!on)}\n            className={cn(\"size-5 rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/60\", on ? \"bg-red-500 shadow-[0_0_8px_2px_rgb(239_68_68/0.6)]\" : \"bg-neutral-600\")}\n          />\n        </div>\n      </div>\n      <p className=\"mt-3 text-center text-sm text-muted-foreground\">{on ? current.name : \"Off\"}</p>\n    </div>\n  )\n}\n\nexport { RetroTv }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "cards"
  ],
  "type": "registry:ui"
}