{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "grain",
  "title": "Grain",
  "description": "Film grain over a surface, from a tile of SVG noise, with an optional stepped jitter.",
  "registryDependencies": [
    "@corsair-ui/utils"
  ],
  "files": [
    {
      "path": "registry/default/ui/grain.tsx",
      "content": "import type { ComponentProps, CSSProperties } from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\n\n/**\n * One tile of noise as an SVG data URI. The filter id lives inside the\n * image's own document, so it never clashes with ids on the page.\n */\nfunction noiseTile(frequency: number, size: number) {\n  const svg =\n    `<svg xmlns='http://www.w3.org/2000/svg' width='${size}' height='${size}'>` +\n    `<filter id='n'><feTurbulence type='fractalNoise' baseFrequency='${frequency}' numOctaves='2' stitchTiles='stitch'/>` +\n    `<feColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/></filter>` +\n    `<rect width='100%' height='100%' filter='url(#n)'/></svg>`;\n  return `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`;\n}\n\ninterface GrainProps extends Omit<ComponentProps<\"div\">, \"children\"> {\n  /** Strength of the grain, from 0 to 1. */\n  opacity?: number;\n  /** Fineness of the noise (the filter's `baseFrequency`); higher is finer. */\n  frequency?: number;\n  /** How the grain mixes with what is under it: any CSS `mix-blend-mode`. */\n  blend?: CSSProperties[\"mixBlendMode\"];\n  /** Cover the whole viewport instead of the nearest positioned parent. */\n  fixed?: boolean;\n  /** Width and height of one noise tile, in px. */\n  size?: number;\n  /** Jitter the grain in small steps, like film running through a projector. */\n  animated?: boolean;\n}\n\n/**\n * Film grain laid over a surface: a tile of SVG noise repeated as a\n * background image, so there is nothing to download and no script to run.\n * It works as a server component and any number can share a page. It is\n * decorative, hidden from screen readers and lets every click through.\n * With `animated`, the grain jitters in steps; `prefers-reduced-motion`\n * keeps it still. Put it inside a positioned element, after the content it\n * covers, or pass `fixed` for the whole page.\n *\n * @example\n * <section className=\"relative overflow-hidden rounded-xl bg-muted p-10\">\n *   <h2>Old harbour</h2>\n *   <Grain opacity={0.2} animated />\n * </section>\n */\nfunction Grain({\n  opacity = 0.12,\n  frequency = 0.8,\n  blend = \"overlay\",\n  fixed = false,\n  size = 180,\n  animated = false,\n  className,\n  style,\n  ref,\n  ...props\n}: GrainProps) {\n  const tile = Math.max(1, Math.round(size));\n  return (\n    <div\n      ref={ref}\n      aria-hidden=\"true\"\n      data-slot=\"grain\"\n      data-animated={animated || undefined}\n      className={cn(\n        \"pointer-events-none overflow-hidden\",\n        fixed ? \"fixed inset-0 z-50\" : \"absolute inset-0\",\n        className\n      )}\n      style={{ opacity: Math.min(Math.max(opacity, 0), 1), mixBlendMode: blend, ...style }}\n      {...props}\n    >\n      <div\n        data-slot=\"grain-noise\"\n        // Twice the size of the surface, so the jitter never shows an edge.\n        className={cn(\"absolute\", animated ? \"motion-safe:animate-grain inset-[-50%]\" : \"inset-0\")}\n        style={{ backgroundImage: noiseTile(frequency, tile), backgroundSize: `${tile}px` }}\n      />\n    </div>\n  );\n}\n\nexport { Grain, type GrainProps };\n",
      "type": "registry:ui"
    }
  ],
  "tailwind": {
    "config": {
      "theme": {
        "extend": {
          "keyframes": {
            "grain": {
              "0%, 100%": {
                "transform": "translate3d(0, 0, 0)"
              },
              "10%": {
                "transform": "translate3d(-5%, -10%, 0)"
              },
              "20%": {
                "transform": "translate3d(-15%, 5%, 0)"
              },
              "30%": {
                "transform": "translate3d(7%, -15%, 0)"
              },
              "40%": {
                "transform": "translate3d(-5%, 15%, 0)"
              },
              "50%": {
                "transform": "translate3d(-15%, 10%, 0)"
              },
              "60%": {
                "transform": "translate3d(15%, 0, 0)"
              },
              "70%": {
                "transform": "translate3d(0, 10%, 0)"
              },
              "80%": {
                "transform": "translate3d(3%, 15%, 0)"
              },
              "90%": {
                "transform": "translate3d(-10%, 10%, 0)"
              }
            }
          },
          "animation": {
            "grain": "grain 0.8s steps(1) infinite"
          }
        }
      }
    }
  },
  "cssVars": {
    "theme": {
      "animate-grain": "grain 0.8s steps(1) infinite"
    }
  },
  "css": {
    "@keyframes grain": {
      "0%, 100%": {
        "transform": "translate3d(0, 0, 0)"
      },
      "10%": {
        "transform": "translate3d(-5%, -10%, 0)"
      },
      "20%": {
        "transform": "translate3d(-15%, 5%, 0)"
      },
      "30%": {
        "transform": "translate3d(7%, -15%, 0)"
      },
      "40%": {
        "transform": "translate3d(-5%, 15%, 0)"
      },
      "50%": {
        "transform": "translate3d(-15%, 10%, 0)"
      },
      "60%": {
        "transform": "translate3d(15%, 0, 0)"
      },
      "70%": {
        "transform": "translate3d(0, 10%, 0)"
      },
      "80%": {
        "transform": "translate3d(3%, 15%, 0)"
      },
      "90%": {
        "transform": "translate3d(-10%, 10%, 0)"
      }
    }
  },
  "categories": [
    "creative",
    "background"
  ],
  "type": "registry:ui"
}