{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"electric-text","type":"registry:ui","title":"Electric Text","description":"Text wrapped in a crackling electric outline, driven by animated SVG turbulence displacement.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/electric-text.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useId, useRef, type CSSProperties } from \"react\";\n\nexport interface ElectricTextProps {\n  text: string;\n  /** Arc color. */\n  color?: string;\n  /** Displacement strength, in px. */\n  intensity?: number;\n  /** Crackle updates per second. */\n  speed?: number;\n  /** Soft outer glow. */\n  glow?: boolean;\n  className?: string;\n}\n\nexport function ElectricText({\n  text,\n  color = \"#7dd3fc\",\n  intensity = 6,\n  speed = 24,\n  glow = true,\n  className,\n}: ElectricTextProps) {\n  const root = useRef<HTMLSpanElement>(null);\n  const svg = useRef<SVGSVGElement>(null);\n  const id = `el${useId().replace(/[^a-zA-Z0-9]/g, \"\")}`;\n\n  useEffect(() => {\n    const el = root.current;\n    const turbs = svg.current?.querySelectorAll(\"feTurbulence\");\n    if (!el || !turbs || window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let raf = 0;\n    let last = 0;\n    let seed = 1;\n    const tick = (t: number) => {\n      raf = requestAnimationFrame(tick);\n      if (t - last < 1000 / speed) return;\n      last = t;\n      seed = (seed * 16807) % 2147483647;\n      turbs.forEach((f, i) => {\n        f.setAttribute(\"seed\", String((seed >> (i * 3)) % 1000));\n        const fx = 0.018 + 0.01 * Math.sin(t / 700 + i);\n        f.setAttribute(\"baseFrequency\", `${fx.toFixed(4)} ${(fx * 3).toFixed(4)}`);\n      });\n      el.style.setProperty(\"--el-flicker\", String(0.75 + ((seed >> 5) % 25) / 100));\n    };\n    const io = new IntersectionObserver(([e]) => {\n      cancelAnimationFrame(raf);\n      if (e.isIntersecting) raf = requestAnimationFrame(tick);\n    });\n    io.observe(el);\n    return () => {\n      io.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [speed]);\n\n  const layer: CSSProperties = {\n    position: \"absolute\",\n    inset: 0,\n    color: \"transparent\",\n    pointerEvents: \"none\",\n  };\n\n  return (\n    <span\n      ref={root}\n      className={className}\n      style={{ position: \"relative\", display: \"inline-block\", color: \"#f0f9ff\", \"--el-flicker\": 1 } as CSSProperties}\n    >\n      <svg ref={svg} aria-hidden width=\"0\" height=\"0\" style={{ position: \"absolute\" }}>\n        {[0, 1].map((i) => (\n          <filter key={i} id={`${id}-${i}`} x=\"-20%\" y=\"-40%\" width=\"140%\" height=\"180%\" colorInterpolationFilters=\"sRGB\">\n            <feTurbulence type=\"turbulence\" baseFrequency=\"0.02 0.06\" numOctaves={2} seed={i + 1} result=\"n\" />\n            <feDisplacementMap in=\"SourceGraphic\" in2=\"n\" scale={intensity * (i ? 1.6 : 1)} xChannelSelector=\"R\" yChannelSelector=\"G\" />\n          </filter>\n        ))}\n      </svg>\n      <span className=\"sr-only\">{text}</span>\n      {glow && (\n        <span\n          aria-hidden\n          style={{\n            ...layer,\n            WebkitTextStroke: `6px ${color}`,\n            filter: `url(#${id}-1) blur(10px)`,\n            opacity: \"calc(var(--el-flicker) * 0.7)\",\n          }}\n        >\n          {text}\n        </span>\n      )}\n      <span aria-hidden style={{ textShadow: `0 0 18px ${color}88`, position: \"relative\" }}>\n        {text}\n      </span>\n      <span\n        aria-hidden\n        style={{\n          ...layer,\n          WebkitTextStroke: `2px ${color}`,\n          filter: `url(#${id}-0) drop-shadow(0 0 6px ${color})`,\n          opacity: \"var(--el-flicker)\",\n        }}\n      >\n        {text}\n      </span>\n      <span\n        aria-hidden\n        style={{ ...layer, WebkitTextStroke: \"1px #ffffff\", filter: `url(#${id}-1)`, opacity: 0.8 }}\n      >\n        {text}\n      </span>\n    </span>\n  );\n}\n"}]}