{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mesh-gradient",
  "type": "registry:component",
  "title": "Mesh Gradient",
  "description": "A living mesh gradient: large blurred color fields drift on independent looping paths and blend where they meet, with optional film grain.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "overlay",
    "gradient",
    "mesh",
    "background",
    "blur",
    "grain",
    "colorful"
  ],
  "docs": "https://hyperblur.dev/effects/mesh-gradient",
  "files": [
    {
      "path": "registry/hyperblur/mesh-gradient.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/mesh-gradient.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MeshGradientProps extends React.HTMLAttributes<HTMLDivElement> {\n  colors?: string[];\n  speed?: number;\n  grain?: number;\n  blur?: number;\n  background?: string;\n  blend?: React.CSSProperties[\"mixBlendMode\"];\n}\n\nconst noise =\n  \"url(\\\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>\\\")\";\n\nconst css = `\n@keyframes hb-msh-x {\n  from { transform: translate3d(calc(var(--hb-msh-ax) * -1), 0, 0); }\n  to { transform: translate3d(var(--hb-msh-ax), 0, 0); }\n}\n@keyframes hb-msh-y {\n  from { transform: translate3d(0, calc(var(--hb-msh-ay) * -1), 0) scale(var(--hb-msh-s0)) rotate(0deg); }\n  to { transform: translate3d(0, var(--hb-msh-ay), 0) scale(var(--hb-msh-s1)) rotate(40deg); }\n}\n@keyframes hb-msh-jitter {\n  0% { transform: translate3d(0, 0, 0); }\n  20% { transform: translate3d(-3%, 2%, 0); }\n  40% { transform: translate3d(2%, -3%, 0); }\n  60% { transform: translate3d(-2%, -1%, 0); }\n  80% { transform: translate3d(3%, 3%, 0); }\n  100% { transform: translate3d(0, 0, 0); }\n}\n.hb-msh {\n  position: absolute;\n  inset: 0;\n  overflow: hidden;\n  pointer-events: none;\n  background: var(--hb-msh-bg);\n  isolation: isolate;\n}\n.hb-msh-layer {\n  position: absolute;\n  inset: -20%;\n  filter: blur(var(--hb-msh-b)) saturate(1.15);\n}\n.hb-msh-x {\n  position: absolute;\n  left: var(--hb-msh-l);\n  top: var(--hb-msh-t);\n  width: var(--hb-msh-w);\n  height: var(--hb-msh-h);\n  mix-blend-mode: var(--hb-msh-blend);\n  animation: hb-msh-x var(--hb-msh-dx) ease-in-out infinite alternate;\n  animation-delay: var(--hb-msh-lx);\n  will-change: transform;\n}\n.hb-msh-y {\n  width: 100%;\n  height: 100%;\n  border-radius: 46% 54% 58% 42% / 44% 50% 50% 56%;\n  background: radial-gradient(closest-side, var(--hb-msh-c) 0%, var(--hb-msh-c) 35%, color-mix(in srgb, var(--hb-msh-c) 0%, transparent) 100%);\n  animation: hb-msh-y var(--hb-msh-dy) ease-in-out infinite alternate;\n  animation-delay: var(--hb-msh-ly);\n  will-change: transform;\n}\n.hb-msh-grain {\n  position: absolute;\n  inset: -50%;\n  background-image: ${noise};\n  background-size: 180px 180px;\n  opacity: var(--hb-msh-g);\n  mix-blend-mode: overlay;\n  animation: hb-msh-jitter 1.2s steps(5) infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-msh-x, .hb-msh-y, .hb-msh-grain { animation: none; will-change: auto; }\n}\n`;\n\nconst spots = [\n  { l: -14, t: -22, w: 70, h: 78, ax: 20, ay: 24, dx: 17, dy: 23, s0: 1, s1: 1.2 },\n  { l: 42, t: -26, w: 66, h: 70, ax: 24, ay: 20, dx: 21, dy: 15, s0: 1.1, s1: 0.85 },\n  { l: 30, t: 38, w: 74, h: 68, ax: 26, ay: 18, dx: 19, dy: 27, s0: 0.9, s1: 1.15 },\n  { l: -20, t: 34, w: 64, h: 72, ax: 18, ay: 26, dx: 25, dy: 18, s0: 1.05, s1: 0.9 },\n  { l: 18, t: 4, w: 56, h: 56, ax: 28, ay: 26, dx: 14, dy: 20, s0: 0.85, s1: 1.25 },\n  { l: 58, t: 16, w: 58, h: 64, ax: 22, ay: 22, dx: 23, dy: 13, s0: 1, s1: 1.1 },\n];\n\nexport function MeshGradient({\n  colors = [\"#ff4d8d\", \"#7c3aed\", \"#2f7bff\", \"#19c3f5\", \"#ffb547\"],\n  speed = 1,\n  grain = 0.18,\n  blur = 60,\n  background = \"#0b0a1a\",\n  blend = \"lighten\",\n  className = \"\",\n  style,\n  ...rest\n}: MeshGradientProps) {\n  const palette = (colors.length > 0 ? colors : [\"#2f7bff\"]).slice(0, 6);\n  const count = Math.min(6, Math.max(4, palette.length));\n  const sp = Math.max(0.05, speed);\n  const g = Math.min(1, Math.max(0, grain));\n\n  const vars = {\n    \"--hb-msh-bg\": background,\n    \"--hb-msh-b\": `${Math.max(0, blur)}px`,\n    \"--hb-msh-g\": g.toFixed(3),\n    \"--hb-msh-blend\": blend,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <div className={`hb-msh ${className}`} style={vars} aria-hidden=\"true\" {...rest}>\n      <style href=\"hb-mesh-gradient\" precedence=\"default\">{css}</style>\n      <div className=\"hb-msh-layer\">\n        {spots.slice(0, count).map((s, i) => (\n          <div\n            key={i}\n            className=\"hb-msh-x\"\n            style={\n              {\n                \"--hb-msh-l\": `${s.l}%`,\n                \"--hb-msh-t\": `${s.t}%`,\n                \"--hb-msh-w\": `${s.w}%`,\n                \"--hb-msh-h\": `${s.h}%`,\n                \"--hb-msh-ax\": `${s.ax}%`,\n                \"--hb-msh-dx\": `${(s.dx / sp).toFixed(3)}s`,\n                \"--hb-msh-lx\": `${(-(s.dx * (i + 1) * 0.37) / sp).toFixed(3)}s`,\n              } as React.CSSProperties\n            }\n          >\n            <div\n              className=\"hb-msh-y\"\n              style={\n                {\n                  \"--hb-msh-c\": palette[i % palette.length],\n                  \"--hb-msh-ay\": `${s.ay}%`,\n                  \"--hb-msh-dy\": `${(s.dy / sp).toFixed(3)}s`,\n                  \"--hb-msh-ly\": `${(-(s.dy * (i + 2) * 0.29) / sp).toFixed(3)}s`,\n                  \"--hb-msh-s0\": s.s0,\n                  \"--hb-msh-s1\": s.s1,\n                } as React.CSSProperties\n              }\n            />\n          </div>\n        ))}\n      </div>\n      {g > 0 && <div className=\"hb-msh-grain\" />}\n    </div>\n  );\n}\n"
    }
  ]
}