{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "vhs-overlay",
  "type": "registry:component",
  "title": "VHS Overlay",
  "description": "Worn tape look: drifting tracking bands, cyan and magenta color bleed, and a tiny vertical jitter.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "overlay",
    "vhs",
    "retro",
    "tape",
    "overlay",
    "glitch"
  ],
  "docs": "https://hyperblur.dev/effects/vhs-overlay",
  "files": [
    {
      "path": "registry/hyperblur/vhs-overlay.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/vhs-overlay.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface VhsOverlayProps extends React.HTMLAttributes<HTMLDivElement> {\n  intensity?: 1 | 2 | 3;\n  bands?: number;\n  speed?: number;\n}\n\nconst css = `\n@keyframes hb-vhs-drift { from { transform: translateY(-100%); } to { transform: translateY(var(--end)); } }\n@keyframes hb-vhs-jitter {\n  0%, 100% { transform: translateY(0); }\n  18% { transform: translateY(var(--hb-j)); }\n  22% { transform: translateY(0); }\n  61% { transform: translateY(calc(var(--hb-j) * -1)); }\n  64% { transform: translateY(0); }\n  87% { transform: translateY(calc(var(--hb-j) * .5)); }\n}\n.hb-vhs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }\n.hb-vhs-in { position: absolute; inset: -4px 0; animation: hb-vhs-jitter var(--hb-jd) steps(1, end) infinite; }\n.hb-vhs-c, .hb-vhs-m { position: absolute; inset: 0; mix-blend-mode: screen; }\n.hb-vhs-c { transform: translateX(calc(var(--hb-x) * -1)); background: linear-gradient(to right, rgba(0,255,255,var(--hb-bl)) 0, rgba(0,255,255,0) 14%, rgba(0,255,255,0) 86%, rgba(0,255,255,var(--hb-bl)) 100%); }\n.hb-vhs-m { transform: translateX(var(--hb-x)); background: linear-gradient(to right, rgba(255,0,170,var(--hb-bl)) 0, rgba(255,0,170,0) 14%, rgba(255,0,170,0) 86%, rgba(255,0,170,var(--hb-bl)) 100%); }\n.hb-vhs-b { position: absolute; left: 0; right: 0; top: 0; height: var(--h); background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,var(--hb-ba)) 70%, rgba(255,255,255,0)); animation: hb-vhs-drift var(--dur) linear infinite; animation-delay: var(--delay); will-change: transform; }\n.hb-vhs-b::after { content: \"\"; position: absolute; left: 0; right: 0; bottom: 18%; height: 2px; background: rgba(255,255,255,calc(var(--hb-ba) * 2)); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-vhs-in, .hb-vhs-b { animation: none; }\n  .hb-vhs-b { transform: translateY(var(--rest)); }\n}\n`;\n\nconst LEVELS = {\n  1: { bleed: 0.14, shift: 1.5, jitter: 0.5, band: 0.06 },\n  2: { bleed: 0.24, shift: 3, jitter: 1, band: 0.1 },\n  3: { bleed: 0.38, shift: 5, jitter: 2, band: 0.16 },\n} as const;\n\nfunction rnd(i: number, salt: number) {\n  let x = ((i + 1) * 2654435761 + salt * 40503) >>> 0;\n  x = ((x >>> 16) ^ x) * 0x45d9f3b;\n  x = ((x >>> 16) ^ x) >>> 0;\n  return (x % 1000) / 1000;\n}\n\nexport function VhsOverlay({\n  intensity = 2,\n  bands = 2,\n  speed = 1,\n  className = \"\",\n  style,\n  ...rest\n}: VhsOverlayProps) {\n  const lv = LEVELS[intensity] ?? LEVELS[2];\n  const rate = Math.max(speed, 0.01);\n\n  const list = Array.from({ length: Math.max(0, Math.floor(bands)) }, (_, i) => {\n    const h = +(7 + rnd(i, 1) * 8).toFixed(2);\n    const end = +((100 / h) * 100).toFixed(1);\n    const dur = +((5 + rnd(i, 2) * 5) / rate).toFixed(2);\n    const delay = +(-rnd(i, 3) * dur).toFixed(2);\n    const rest = +(((i + 0.5) / Math.max(1, Math.floor(bands))) * end * 0.8).toFixed(1);\n    return { h, end, dur, delay, rest };\n  });\n\n  const vars = {\n    \"--hb-bl\": lv.bleed,\n    \"--hb-x\": `${lv.shift}px`,\n    \"--hb-j\": `${lv.jitter}px`,\n    \"--hb-ba\": lv.band,\n    \"--hb-jd\": `${+(1.1 / rate).toFixed(2)}s`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <div className={`hb-vhs ${className}`} style={vars} aria-hidden=\"true\" {...rest}>\n      <style href=\"hb-vhs-overlay\" precedence=\"default\">{css}</style>\n      <div className=\"hb-vhs-in\">\n        <div className=\"hb-vhs-c\" />\n        <div className=\"hb-vhs-m\" />\n        {list.map((b, i) => (\n          <div\n            key={i}\n            className=\"hb-vhs-b\"\n            style={\n              {\n                \"--h\": `${b.h}%`,\n                \"--end\": `${b.end}%`,\n                \"--dur\": `${b.dur}s`,\n                \"--delay\": `${b.delay}s`,\n                \"--rest\": `${b.rest}%`,\n              } as React.CSSProperties\n            }\n          />\n        ))}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}