{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "beam-rain",
  "title": "Beam Rain",
  "author": "VenusUI",
  "description": "Beams of light fall to the floor and burst into sparks when they land.",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "registry/default/ui/beam-rain.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface BeamRainProps {\n  /** Number of beams. */\n  count?: number\n  /** Beam color, from tail to head. Any CSS colors. */\n  colors?: [string, string]\n  className?: string\n}\n\ninterface Burst {\n  id: number\n  left: number\n  sparks: { x: number; y: number; size: number }[]\n}\n\n/** Fixed, pseudo-random beams so server and browser render the same thing. */\nfunction makeBeams(count: number) {\n  return Array.from({ length: count }, (_, i) => ({\n    left: ((i + 0.5) / count) * 100 + (((i * 37) % 7) - 3),\n    length: 56 + ((i * 53) % 70),\n    duration: 5.5 + ((i * 29) % 40) / 10,\n    delay: ((i * 17) % 50) / 10,\n  }))\n}\n\n/**\n * Beams of light fall to the floor of their container and burst into sparks\n * when they land. Place inside a `relative` element. Decorative: hidden from\n * assistive technology, paused while off screen, and absent with reduced\n * motion. Requires the `animate-beam-rain-fall` theme variable and keyframes,\n * which the CLI adds.\n */\nfunction BeamRain({ count = 8, colors = [\"oklch(0.8 0.14 295)\", \"oklch(0.92 0.08 210)\"], className }: BeamRainProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const reduceMotion = useReducedMotion()\n  const [height, setHeight] = React.useState(0)\n  const [visible, setVisible] = React.useState(false)\n  const [bursts, setBursts] = React.useState<Burst[]>([])\n  const nextId = React.useRef(0)\n  const beams = React.useMemo(() => makeBeams(count), [count])\n\n  React.useEffect(() => {\n    const node = ref.current\n    if (!node) return\n    const resize = new ResizeObserver(([entry]) => entry && setHeight(entry.contentRect.height))\n    const seen = new IntersectionObserver(([entry]) => setVisible(Boolean(entry?.isIntersecting)))\n    resize.observe(node)\n    seen.observe(node)\n    return () => {\n      resize.disconnect()\n      seen.disconnect()\n    }\n  }, [])\n\n  const land = (left: number) => {\n    const burst: Burst = {\n      id: nextId.current++,\n      left,\n      sparks: Array.from({ length: 12 }, () => ({\n        x: (Math.random() - 0.5) * 120,\n        y: -(20 + Math.random() * 60),\n        size: 2 + Math.random() * 2,\n      })),\n    }\n    setBursts((all) => [...all, burst])\n    setTimeout(() => setBursts((all) => all.filter((b) => b.id !== burst.id)), 1000)\n  }\n\n  return (\n    <div\n      ref={ref}\n      aria-hidden=\"true\"\n      data-slot=\"beam-rain\"\n      className={cn(\"pointer-events-none absolute inset-0 -z-10 overflow-hidden\", className)}\n      style={{ \"--beam-a\": colors[0], \"--beam-b\": colors[1] } as React.CSSProperties}\n    >\n      {!reduceMotion && height > 0\n        ? beams.map((beam, i) => (\n            <span\n              key={i}\n              onAnimationIteration={() => land(beam.left)}\n              className=\"absolute top-0 w-px animate-beam-rain-fall rounded-full bg-linear-to-b from-transparent via-(--beam-a) to-(--beam-b) shadow-[0_0_6px_0_var(--beam-b)]\"\n              style={\n                {\n                  left: `${beam.left}%`,\n                  height: beam.length,\n                  \"--beam-rain-distance\": `${height - beam.length}px`,\n                  animationDuration: `${beam.duration}s`,\n                  animationDelay: `${beam.delay}s`,\n                  animationPlayState: visible ? \"running\" : \"paused\",\n                } as React.CSSProperties\n              }\n            />\n          ))\n        : null}\n\n      {bursts.map((burst) => (\n        <span key={burst.id} className=\"absolute bottom-0\" style={{ left: `${burst.left}%` }}>\n          <motion.span\n            className=\"absolute bottom-0 left-1/2 h-6 w-24 -translate-x-1/2 rounded-full bg-[radial-gradient(ellipse_at_bottom,var(--beam-b),transparent_70%)] blur-sm\"\n            initial={{ opacity: 0.9, scale: 0.4 }}\n            animate={{ opacity: 0, scale: 1.3 }}\n            transition={{ duration: 0.8, ease: \"easeOut\" }}\n          />\n          {burst.sparks.map((spark, i) => (\n            <motion.span\n              key={i}\n              className=\"absolute bottom-0 rounded-full bg-(--beam-b)\"\n              style={{ width: spark.size, height: spark.size }}\n              initial={{ x: 0, y: 0, opacity: 1 }}\n              animate={{ x: spark.x, y: spark.y, opacity: 0 }}\n              transition={{ duration: 0.6 + Math.abs(spark.y) / 150, ease: [0.16, 1, 0.3, 1] }}\n            />\n          ))}\n        </span>\n      ))}\n\n      <div className=\"absolute inset-x-0 bottom-0 h-px bg-linear-to-r from-transparent via-(--beam-a) to-transparent opacity-60\" />\n    </div>\n  )\n}\n\nexport { BeamRain, type BeamRainProps }\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "animate-beam-rain-fall": "beam-rain-fall 6s linear infinite backwards"
    }
  },
  "css": {
    "@keyframes beam-rain-fall": {
      "from": {
        "transform": "translateY(-140%)"
      },
      "to": {
        "transform": "translateY(var(--beam-rain-distance, 24rem))"
      }
    }
  },
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "backgrounds",
    "animations",
    "effects"
  ],
  "type": "registry:ui"
}