{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bg-soft-aurora",
  "type": "registry:component",
  "title": "Soft Aurora",
  "description": "Wide pastel aurora curtains that drift slowly, with a gentle bloom that follows the pointer and tiny motes floating upward.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "overlay",
    "background",
    "aurora",
    "pastel",
    "calm",
    "canvas",
    "glow"
  ],
  "docs": "https://hyperblur.dev/effects/bg-soft-aurora",
  "files": [
    {
      "path": "registry/hyperblur/bg-soft-aurora.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/bg-soft-aurora.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BgSoftAuroraProps extends React.HTMLAttributes<HTMLDivElement> {\n  colors?: string[];\n  accent?: string;\n  background?: string;\n  motes?: number;\n  intensity?: number;\n  speed?: number;\n  children?: React.ReactNode;\n}\n\nconst css = `\n.hb-qp2 { position: absolute; inset: 0; overflow: hidden; pointer-events: none; box-sizing: border-box; }\n.hb-qp2-c { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }\n.hb-qp2-in { position: relative; z-index: 1; width: 100%; height: 100%; pointer-events: auto; font-family: inherit; }\n`;\n\nconst defaultColors = [\"#9ec5ff\", \"#c8b4ff\", \"#9fe8d2\", \"#ffc6e0\"];\n\nfunction rnd(i: number) {\n  let x = Math.imul(i ^ 0x9e3779b9, 0x85ebca6b);\n  x ^= x >>> 13;\n  x = Math.imul(x, 0xc2b2ae35);\n  x ^= x >>> 16;\n  return (x >>> 0) / 4294967296;\n}\n\nexport function BgSoftAurora({\n  colors = defaultColors,\n  accent = \"#e8f0ff\",\n  background = \"#07080d\",\n  motes = 40,\n  intensity = 1,\n  speed = 1,\n  children,\n  className = \"\",\n  style,\n  ...rest\n}: BgSoftAuroraProps) {\n  const wrapRef = React.useRef<HTMLDivElement>(null);\n  const canvasRef = React.useRef<HTMLCanvasElement>(null);\n  const colorKey = (colors.length ? colors : defaultColors).join(\"|\");\n\n  React.useEffect(() => {\n    const wrap = wrapRef.current;\n    const host = wrap?.parentElement;\n    const canvas = canvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    const off = document.createElement(\"canvas\");\n    const octx = off.getContext(\"2d\");\n    if (!wrap || !host || !canvas || !ctx || !octx) return;\n\n    const motion = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const palette = colorKey.split(\"|\");\n    const curtains = palette.length;\n    const M = Math.max(0, Math.min(160, Math.round(motes)));\n    const SCALE = 6;\n\n    let w = 0;\n    let h = 0;\n    let ow = 0;\n    let oh = 0;\n    let t = 0;\n    let inside = false;\n    let tx = 0;\n    let ty = 0;\n    let px = 0;\n    let py = 0;\n    let placed = false;\n    let near = 0;\n    let visible = true;\n    let raf = 0;\n    let prev = 0;\n\n    function idleX(tt: number) {\n      return w * (0.5 + 0.32 * Math.sin(tt * 0.12 + 0.6));\n    }\n    function idleY(tt: number) {\n      return h * (0.38 + 0.12 * Math.sin(tt * 0.19 + 2));\n    }\n\n    function track(dt: number) {\n      const gx = inside ? tx : idleX(t);\n      const gy = inside ? ty : idleY(t);\n      if (!placed || dt === 0) {\n        px = gx;\n        py = gy;\n        placed = true;\n        near = inside ? 1 : 0.45;\n        return;\n      }\n      const k = 1 - Math.exp(-dt * (inside ? 2.2 : 0.9));\n      px += (gx - px) * k;\n      py += (gy - py) * k;\n      near += ((inside ? 1 : 0.45) - near) * Math.min(1, dt * 1.5);\n    }\n\n    function curtainsPass() {\n      octx!.globalCompositeOperation = \"source-over\";\n      octx!.clearRect(0, 0, ow, oh);\n      octx!.globalCompositeOperation = \"lighter\";\n      const pxs = px / SCALE;\n      const lean = (px / Math.max(1, w) - 0.5) * 0.9;\n      for (let c = 0; c < curtains; c++) {\n        const seed = c * 7 + 3;\n        const base = oh * (0.22 + (0.42 * c) / Math.max(1, curtains - 1 || 1)) + (rnd(seed) - 0.5) * oh * 0.08;\n        const amp = oh * (0.08 + 0.06 * rnd(seed + 1));\n        const freq = (0.9 + 0.8 * rnd(seed + 2)) / Math.max(1, ow);\n        const len = oh * (0.28 + 0.14 * rnd(seed + 3));\n        const drift = 0.06 + 0.05 * rnd(seed + 4);\n        const grad = octx!.createLinearGradient(0, 0, 0, len);\n        grad.addColorStop(0, \"rgba(0,0,0,0)\");\n        grad.addColorStop(0.35, palette[c]);\n        grad.addColorStop(0.6, palette[c]);\n        grad.addColorStop(1, \"rgba(0,0,0,0)\");\n        octx!.fillStyle = grad;\n        for (let x = -2; x < ow + 2; x++) {\n          const dx = (x - pxs) / Math.max(1, ow * 0.35);\n          const bend = Math.exp(-dx * dx) * near;\n          const y =\n            base +\n            Math.sin(x * freq * Math.PI * 2 + t * drift * 3 + c * 1.9) * amp +\n            Math.sin(x * freq * 5.1 + t * drift * 5.3 + c) * amp * 0.35 -\n            bend * oh * 0.07 -\n            len * 0.5;\n          const shimmer = 0.5 + 0.5 * Math.sin(x * freq * 17 + t * drift * 9 + c * 4.1);\n          octx!.globalAlpha = Math.min(1, (0.1 + 0.12 * shimmer + bend * 0.08) * intensity);\n          octx!.setTransform(1, 0, lean * 0.35, 1, x, y);\n          octx!.fillRect(0, 0, 1.4, len);\n        }\n      }\n      octx!.setTransform(1, 0, 0, 1, 0, 0);\n      octx!.globalAlpha = 1;\n    }\n\n    function draw() {\n      if (!w || !h) return;\n      curtainsPass();\n      ctx!.globalCompositeOperation = \"source-over\";\n      ctx!.globalAlpha = 1;\n      ctx!.fillStyle = background;\n      ctx!.fillRect(0, 0, w, h);\n      ctx!.imageSmoothingEnabled = true;\n      ctx!.imageSmoothingQuality = \"high\";\n      ctx!.globalCompositeOperation = \"lighter\";\n      ctx!.drawImage(off, 0, 0, ow, oh, -SCALE, -SCALE, w + SCALE * 2, h + SCALE * 2);\n      const r = Math.max(w, h) * 0.42;\n      const bloom = ctx!.createRadialGradient(px, py, 0, px, py, r);\n      bloom.addColorStop(0, accent);\n      bloom.addColorStop(1, \"rgba(0,0,0,0)\");\n      ctx!.globalAlpha = (0.05 + 0.06 * near) * intensity;\n      ctx!.fillStyle = bloom;\n      ctx!.fillRect(0, 0, w, h);\n      ctx!.fillStyle = accent;\n      for (let i = 0; i < M; i++) {\n        const sx = rnd(i * 5 + 11);\n        const sy = rnd(i * 5 + 12);\n        const sp = 0.004 + 0.01 * rnd(i * 5 + 13);\n        const yy = (((sy - t * sp) % 1) + 1) % 1;\n        const x = sx * w + Math.sin(t * 0.3 + i) * 14;\n        const y = yy * (h + 20) - 10;\n        const dx = x - px;\n        const dy = y - py;\n        const lit = Math.exp(-(dx * dx + dy * dy) / (r * r * 0.3)) * near;\n        const tw = 0.5 + 0.5 * Math.sin(t * (0.6 + rnd(i * 5 + 14)) + i * 2.7);\n        const fade = Math.min(1, yy * 4, (1 - yy) * 4);\n        ctx!.globalAlpha = Math.max(0, (0.12 + 0.4 * tw + 0.4 * lit) * fade);\n        ctx!.beginPath();\n        ctx!.arc(x, y, 0.6 + 0.9 * rnd(i * 5 + 15) + lit * 0.6, 0, Math.PI * 2);\n        ctx!.fill();\n      }\n      ctx!.globalAlpha = 1;\n      ctx!.globalCompositeOperation = \"source-over\";\n    }\n\n    function still() {\n      t = 9;\n      inside = false;\n      placed = false;\n      track(0);\n      draw();\n    }\n\n    function resize() {\n      if (!wrap || !canvas || !ctx) return;\n      const nw = wrap.clientWidth;\n      const nh = wrap.clientHeight;\n      if (!nw || !nh) return;\n      const dpr = Math.min(2, window.devicePixelRatio || 1);\n      w = nw;\n      h = nh;\n      ow = Math.max(4, Math.ceil(w / SCALE));\n      oh = Math.max(4, Math.ceil(h / SCALE));\n      off.width = ow;\n      off.height = oh;\n      canvas.width = Math.max(1, Math.round(w * dpr));\n      canvas.height = Math.max(1, Math.round(h * dpr));\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      if (motion.matches) still();\n      else {\n        track(0);\n        draw();\n      }\n    }\n\n    function frame(now: number) {\n      const dt = Math.min(0.033, (now - prev) / 1000);\n      prev = now;\n      t += dt * speed;\n      track(dt);\n      draw();\n      raf = requestAnimationFrame(frame);\n    }\n\n    function sync() {\n      const run = visible && !document.hidden && !motion.matches;\n      if (run && !raf) {\n        prev = performance.now();\n        raf = requestAnimationFrame(frame);\n      } else if (!run && raf) {\n        cancelAnimationFrame(raf);\n        raf = 0;\n      }\n      if (motion.matches) still();\n    }\n\n    function move(e: PointerEvent) {\n      if (!host || motion.matches) return;\n      const rect = host.getBoundingClientRect();\n      const sx = rect.width ? host.clientWidth / rect.width : 1;\n      const sy = rect.height ? host.clientHeight / rect.height : 1;\n      tx = (e.clientX - rect.left) * sx;\n      ty = (e.clientY - rect.top) * sy;\n      inside = true;\n    }\n\n    function leave(e: PointerEvent) {\n      if (e.type === \"pointerup\" && e.pointerType === \"mouse\") return;\n      inside = false;\n    }\n\n    const ro = new ResizeObserver(resize);\n    const io = new IntersectionObserver((entries) => {\n      visible = entries[entries.length - 1].isIntersecting;\n      sync();\n    });\n    ro.observe(wrap);\n    io.observe(wrap);\n    document.addEventListener(\"visibilitychange\", sync);\n    motion.addEventListener(\"change\", sync);\n    host.addEventListener(\"pointermove\", move, { passive: true });\n    host.addEventListener(\"pointerdown\", move, { passive: true });\n    host.addEventListener(\"pointerleave\", leave);\n    host.addEventListener(\"pointerup\", leave);\n    host.addEventListener(\"pointercancel\", leave);\n    resize();\n    sync();\n\n    return () => {\n      if (raf) cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", sync);\n      motion.removeEventListener(\"change\", sync);\n      host.removeEventListener(\"pointermove\", move);\n      host.removeEventListener(\"pointerdown\", move);\n      host.removeEventListener(\"pointerleave\", leave);\n      host.removeEventListener(\"pointerup\", leave);\n      host.removeEventListener(\"pointercancel\", leave);\n    };\n  }, [colorKey, accent, background, motes, intensity, speed]);\n\n  return (\n    <div ref={wrapRef} className={`hb-qp2 ${className}`} style={style} {...rest}>\n      <style href=\"hb-bg-soft-aurora\" precedence=\"default\">{css}</style>\n      <canvas ref={canvasRef} className=\"hb-qp2-c\" aria-hidden=\"true\" />\n      {children ? <div className=\"hb-qp2-in\">{children}</div> : null}\n    </div>\n  );\n}\n"
    }
  ]
}