{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shader-anime-fire",
  "title": "Shader Anime Fire",
  "description": "Cel-shaded WebGL flames for landing heroes: tongues lick up from the bottom in flat bands of heat, and the fire reaches for the pointer.",
  "files": [
    {
      "path": "registry/shader-anime-fire/shader-anime-fire.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useRef, useState } from \"react\"\nimport { cn } from \"@/lib/utils\"\n\nexport type ShaderAnimeFireTheme = \"light\" | \"dark\" | \"auto\"\n\nexport type ShaderAnimeFireOptions = {\n  /**\n   * Three colors, coolest to hottest: ember, flame, core. In dark mode the\n   * densest heat still burns past the core toward white.\n   */\n  colors?: string[]\n  /** How fast the flames rise. Default `0.6`. */\n  speed?: number\n  /** Opacity of the fire and its glow, 0–1. Default `1`. */\n  intensity?: number\n  /** How far the flames climb, 0–1. Default `0.45`. */\n  height?: number\n  /** A plume of heat reaches up toward the pointer. Default `true`. */\n  interactive?: boolean\n  /** Ordered Bayer pixels instead of smooth flames. Default `false`. */\n  dither?: boolean\n  /** Dither cell size in CSS px. Default `1`. */\n  pixelSize?: number\n  /**\n   * Palette mode. Default `auto` follows shadcn / next-themes\n   * (`html.dark` class) so light and dark swap with the site theme.\n   */\n  theme?: ShaderAnimeFireTheme\n  /** Fires whenever resolved dark mode changes (CSS fallback). */\n  onThemeChange?: (dark: boolean) => void\n}\n\nexport type ShaderAnimeFireInstance = {\n  setOptions: (options: Partial<ShaderAnimeFireOptions>) => void\n  destroy: () => void\n}\n\n/** Brick, flame orange and marigold, saturated enough to hold on paper. */\nexport const LIGHT_COLORS = [\"#D8341A\", \"#F9731E\", \"#FFBA3A\"]\n/** Deep ember, flame and gold; the tonemap carries the core to white-hot. */\nexport const DARK_COLORS = [\"#B4200A\", \"#FF6512\", \"#FFC04A\"]\nconst LIGHT_BASE = \"#FCFBF9\"\nconst DARK_BASE = \"#08090C\"\n\nexport const DEFAULT_SPEED = 0.6\nexport const DEFAULT_INTENSITY = 1\nexport const DEFAULT_HEIGHT = 0.45\n\nfunction fallback(colors: string[], base: string) {\n  const [ember, flame, core] = colors\n  return {\n    backgroundColor: base,\n    backgroundImage: [\n      `radial-gradient(24% 18% at 50% 100%, ${core} 0%, transparent 70%)`,\n      `radial-gradient(36% 30% at 24% 100%, ${flame} 0%, transparent 72%)`,\n      `radial-gradient(34% 28% at 76% 100%, ${flame} 0%, transparent 72%)`,\n      `radial-gradient(90% 50% at 50% 110%, ${ember} 0%, transparent 72%)`,\n    ].join(\", \"),\n  } as const\n}\n\n/** Shown before the first frame and wherever WebGL isn't available. */\nexport const LIGHT_FALLBACK = fallback(LIGHT_COLORS, LIGHT_BASE)\nexport const DARK_FALLBACK = fallback(DARK_COLORS, DARK_BASE)\n\nconst VERT = `\nattribute vec2 a_position;\nvoid main() {\n  gl_Position = vec4(a_position, 0.0, 1.0);\n}\n`\n\nconst FRAG = `\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_intensity;\nuniform float u_height;\nuniform float u_ignite;\nuniform float u_dark;\nuniform float u_dither;\nuniform float u_pixel;\nuniform float u_pointer;\nuniform vec2 u_mouse;\n// Ember, flame, core and the paper / ink underneath, in linear light.\nuniform vec3 u_c0;\nuniform vec3 u_c1;\nuniform vec3 u_c2;\nuniform vec3 u_base;\n\n// Dave Hoskins' hash: no sin(), so it stays stable on mobile GPUs.\nfloat hash(vec2 p) {\n  vec3 p3 = fract(vec3(p.xyx) * 0.1031);\n  p3 += dot(p3, p3.yzx + 33.33);\n  return fract((p3.x + p3.y) * p3.z);\n}\n\nfloat noise(vec2 p) {\n  vec2 i = floor(p);\n  vec2 f = fract(p);\n  vec2 u = f * f * (3.0 - 2.0 * f);\n  return mix(\n    mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n    mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n    u.y\n  );\n}\n\nfloat fbm(vec2 p) {\n  float v = 0.0;\n  float a = 0.5;\n  mat2 m = mat2(1.6, 1.2, -1.2, 1.6);\n  for (int i = 0; i < 3; i++) {\n    v += a * noise(p);\n    p = m * p;\n    a *= 0.5;\n  }\n  return v / 0.875;\n}\n\n// Classic Bayer (WebGL1-safe, no bitwise ops)\nfloat bayer2(vec2 c) {\n  return mod(c.x * 2.0 + c.y * 3.0, 4.0);\n}\n\nfloat bayer4(vec2 p) {\n  vec2 c = mod(floor(p), 4.0);\n  return bayer2(mod(c, 2.0)) * 4.0 + bayer2(floor(c * 0.5));\n}\n\nfloat bayer8(vec2 p) {\n  vec2 c = mod(floor(p), 8.0);\n  return (bayer4(floor(c * 0.5)) * 4.0 + bayer2(mod(c, 2.0)) + 0.5) / 64.0;\n}\n\nfloat climbOf() {\n  return mix(0.18, 0.78, u_height) * u_ignite;\n}\n\n// Temperature: below 0 is air, around 1 is the white-hot bed of the fire.\nfloat temperature(vec2 uv, float aspect, float t, float plume) {\n  float x = uv.x * aspect;\n  float climb = max(climbOf(), 0.001);\n  float y = uv.y / climb;\n\n  // Slow swells along the bed, so the flame line is never flat.\n  y /= mix(0.6, 1.3, fbm(vec2(x * 1.1 + 3.1, t * 0.16)));\n  // Under the pointer the fire stretches up toward it.\n  y /= 1.0 + plume * max(u_mouse.y / climb - 0.4, 0.3);\n\n  // Turbulence rising through the flame: stretched tall so it reads as\n  // tongues, and swept sideways harder the higher it climbs.\n  // Few octaves on purpose: smooth, graphic tongues rather than ragged,\n  // photographic ones.\n  vec2 q = vec2(x * 4.4, uv.y * 1.5 - t * 1.1);\n  vec2 w = vec2(\n    fbm(q * vec2(0.5, 0.8) + vec2(0.0, -t * 0.3)),\n    fbm(q * 0.6 + vec2(5.2, 1.3 - t * 0.25))\n  );\n  q += (w - 0.5) * vec2(2.4, 0.8) * (0.3 + y);\n  float body = fbm(q) - 0.5;\n  // Ridged: where the finer noise crosses its midpoint it peaks sharply,\n  // which curls the bands into licks instead of flat stripes.\n  float licks = 0.2 - abs(fbm(q * vec2(1.5, 2.0) + vec2(0.0, -t * 1.6)) - 0.5) * 2.0;\n  float turb = body * 0.8 + licks * 0.45;\n\n  float T = 1.0 - y * 1.1 + turb * 2.6 * min(0.5 + y, 1.2);\n  // Nothing burns far above the tips, however the noise rolls.\n  return T - smoothstep(1.0, 1.7, y);\n}\n\n// Flat cel bands, hottest innermost. 'hot' is the core pushed toward white.\nvec3 bands(float T, vec3 hot) {\n  float w = 0.012;\n  vec3 c = mix(u_c0, u_c1, smoothstep(0.3 - w, 0.3 + w, T));\n  c = mix(c, u_c2, smoothstep(0.6 - w, 0.6 + w, T));\n  return mix(c, hot, smoothstep(1.02 - w, 1.02 + w, T));\n}\n\nvec3 linearToSrgb(vec3 c) {\n  c = clamp(c, 0.0, 1.0);\n  vec3 lo = c * 12.92;\n  vec3 hi = 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055;\n  return mix(lo, hi, step(vec3(0.0031308), c));\n}\n\nvoid main() {\n  float aspect = u_resolution.x / max(u_resolution.y, 1.0);\n  float t = u_time;\n\n  vec2 cell = floor(gl_FragCoord.xy / u_pixel);\n  vec2 uv = gl_FragCoord.xy / u_resolution;\n  if (u_dither > 0.5) uv = (cell + 0.5) * u_pixel / u_resolution;\n\n  float dx = (uv.x - u_mouse.x) * aspect;\n  float plume = exp(-dx * dx * 26.0) * u_pointer;\n\n  float T = temperature(uv, aspect, t, plume);\n  // Dither shakes the band edges by the Bayer threshold, so each boundary\n  // prints as an ordered-dot blend instead of a hard line.\n  float q = u_dither > 0.5 ? bayer8(cell) - 0.5 : 0.0;\n  T += q * 0.14;\n  float edge = u_dither > 0.5 ? 0.001 : 0.012;\n  float cover = smoothstep(0.0, edge, T) * mix(0.35, 1.0, u_intensity);\n\n  // The whole fire breathes a little, like a real one lighting a room.\n  float flicker = 0.86 + 0.14 * noise(vec2(t * 2.3, 4.7));\n  float glow = exp(-uv.y / max(climbOf() * 1.7, 0.02) * 3.4) * flicker;\n  glow += plume * exp(-length(vec2(dx, uv.y - u_mouse.y)) * 5.0) * 0.5;\n  glow *= u_intensity;\n  if (u_dither > 0.5) glow = step(0.52 + q * 0.98, glow * 2.0) * 0.5;\n\n  // On ink the core goes near white; on paper white would vanish into the\n  // page, so it stops at a pale gold.\n  vec3 hot = mix(u_c2, vec3(1.0), u_dark > 0.5 ? 0.75 : 0.4);\n  vec3 col = mix(u_base, mix(u_c0, u_c1, 0.4), glow * (u_dark > 0.5 ? 0.08 : 0.12));\n  col = mix(col, bands(T, hot), cover);\n\n  vec3 srgb = linearToSrgb(col);\n  if (u_dither < 0.5) srgb += (hash(gl_FragCoord.xy + fract(t)) - 0.5) * 0.006;\n  gl_FragColor = vec4(clamp(srgb, 0.0, 1.0), 1.0);\n}\n`\n\nfunction isDev() {\n  return (\n    typeof process !== \"undefined\" && process.env?.NODE_ENV !== \"production\"\n  )\n}\n\nfunction clamp(value: number, min: number, max: number) {\n  return Math.min(max, Math.max(min, value))\n}\n\nfunction numberOr(value: unknown, fallback: number, min: number, max: number) {\n  if (typeof value !== \"number\" || !Number.isFinite(value)) return fallback\n  return clamp(value, min, max)\n}\n\n/** Hex → linear sRGB, so the shader can add light the way light adds. */\nfunction hexToLinear(hex: string): [number, number, number] {\n  const h = hex.replace(\"#\", \"\").trim()\n  const full =\n    h.length === 3\n      ? h\n          .split(\"\")\n          .map((c) => c + c)\n          .join(\"\")\n      : h.padEnd(6, \"0\").slice(0, 6)\n  const n = Number.parseInt(full, 16)\n  const srgb = Number.isNaN(n)\n    ? [0.77, 0.38, 0.18]\n    : [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255]\n  return srgb.map((c) =>\n    c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n  ) as [number, number, number]\n}\n\n/** Resolves shadcn / next-themes dark mode (`attribute=\"class\"` → `html.dark`). */\nexport function isDarkTheme(): boolean {\n  if (typeof document === \"undefined\") return false\n  const root = document.documentElement\n  if (root.classList.contains(\"dark\")) return true\n  if (root.classList.contains(\"light\")) return false\n  const dataTheme = root.getAttribute(\"data-theme\")\n  if (dataTheme === \"dark\") return true\n  if (dataTheme === \"light\") return false\n  return window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n}\n\nexport function resolveDark(theme: ShaderAnimeFireTheme): boolean {\n  if (theme === \"dark\") return true\n  if (theme === \"light\") return false\n  return isDarkTheme()\n}\n\nfunction compile(gl: WebGLRenderingContext, type: number, source: string) {\n  const shader = gl.createShader(type)\n  if (!shader) return null\n  gl.shaderSource(shader, source)\n  gl.compileShader(shader)\n  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n    if (isDev()) {\n      console.warn(\n        \"ShaderAnimeFire: shader failed to compile\\n\",\n        gl.getShaderInfoLog(shader)\n      )\n    }\n    gl.deleteShader(shader)\n    return null\n  }\n  return shader\n}\n\n/**\n * A wall of cel-shaded fire along the bottom edge: turbulent tongues in\n * flat bands of heat over a warm, flickering glow. Theme-aware; pauses\n * off-screen and in hidden tabs; holds a still frame under\n * `prefers-reduced-motion`. Recovers from a lost WebGL context.\n */\nexport function createShaderAnimeFire(\n  canvas: HTMLCanvasElement,\n  initial: ShaderAnimeFireOptions = {}\n): ShaderAnimeFireInstance | null {\n  let options: ShaderAnimeFireOptions = {\n    interactive: true,\n    theme: \"auto\",\n    ...initial,\n  }\n\n  const mouse = { x: 0.5, y: 0.5 }\n  const target = { x: 0.5, y: 0.5 }\n  // The plume eases in and out, so leaving the hero never snaps.\n  let pull = 0\n  let pullTarget = 0\n  let dark = resolveDark(options.theme ?? \"auto\")\n  options.onThemeChange?.(dark)\n\n  const gl = canvas.getContext(\"webgl\", {\n    alpha: false,\n    antialias: false,\n    depth: false,\n    stencil: false,\n    powerPreference: \"high-performance\",\n  })\n  if (!gl) return null\n\n  // GL resources, made by initGl at startup and again when a lost context\n  // is restored.\n  type Loc = WebGLUniformLocation | null\n  let vs: WebGLShader | null = null\n  let fs: WebGLShader | null = null\n  let program: WebGLProgram | null = null\n  let buf: WebGLBuffer | null = null\n  let uResolution: Loc = null\n  let uTime: Loc = null\n  let uIntensity: Loc = null\n  let uHeight: Loc = null\n  let uIgnite: Loc = null\n  let uDark: Loc = null\n  let uDither: Loc = null\n  let uPixel: Loc = null\n  let uPointer: Loc = null\n  let uMouse: Loc = null\n  let uStops: Loc[] = []\n  let uBase: Loc = null\n\n  const initGl = () => {\n    vs = compile(gl, gl.VERTEX_SHADER, VERT)\n    fs = compile(gl, gl.FRAGMENT_SHADER, FRAG)\n    if (!vs || !fs) {\n      if (vs) gl.deleteShader(vs)\n      if (fs) gl.deleteShader(fs)\n      return false\n    }\n\n    const linked = gl.createProgram()\n    if (!linked) {\n      gl.deleteShader(vs)\n      gl.deleteShader(fs)\n      return false\n    }\n    program = linked\n    gl.attachShader(linked, vs)\n    gl.attachShader(linked, fs)\n    gl.linkProgram(linked)\n    if (!gl.getProgramParameter(linked, gl.LINK_STATUS)) {\n      if (isDev()) {\n        console.warn(\n          \"ShaderAnimeFire: program failed to link\\n\",\n          gl.getProgramInfoLog(linked)\n        )\n      }\n      gl.deleteProgram(linked)\n      gl.deleteShader(vs)\n      gl.deleteShader(fs)\n      return false\n    }\n    gl.useProgram(linked)\n\n    buf = gl.createBuffer()\n    gl.bindBuffer(gl.ARRAY_BUFFER, buf)\n    gl.bufferData(\n      gl.ARRAY_BUFFER,\n      new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]),\n      gl.STATIC_DRAW\n    )\n    const loc = gl.getAttribLocation(linked, \"a_position\")\n    gl.enableVertexAttribArray(loc)\n    gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0)\n\n    const u = (name: string) => gl.getUniformLocation(linked, name)\n    uResolution = u(\"u_resolution\")\n    uTime = u(\"u_time\")\n    uIntensity = u(\"u_intensity\")\n    uHeight = u(\"u_height\")\n    uIgnite = u(\"u_ignite\")\n    uDark = u(\"u_dark\")\n    uDither = u(\"u_dither\")\n    uPixel = u(\"u_pixel\")\n    uPointer = u(\"u_pointer\")\n    uMouse = u(\"u_mouse\")\n    uStops = [u(\"u_c0\"), u(\"u_c1\"), u(\"u_c2\")]\n    uBase = u(\"u_base\")\n    return true\n  }\n  if (!initGl()) return null\n\n  // Flame edges are crisp, so render a bit past 1x, but not a full 2x,\n  // which would quadruple the fbm work on retina screens.\n  let dpr = 1\n  /**\n   * Sizes the canvas to its parent; true when the backing store changed.\n   * Assigning the same size still clears the canvas, so it only assigns on\n   * a real change.\n   */\n  const resize = () => {\n    const parent = canvas.parentElement\n    if (!parent) return false\n    const w = parent.clientWidth\n    const h = parent.clientHeight\n    if (w <= 0 || h <= 0) return false\n    dpr = Math.min(window.devicePixelRatio || 1, 1.5)\n    const width = Math.max(1, Math.floor(w * dpr))\n    const height = Math.max(1, Math.floor(h * dpr))\n    if (canvas.width === width && canvas.height === height) return false\n    canvas.width = width\n    canvas.height = height\n    canvas.style.width = `${w}px`\n    canvas.style.height = `${h}px`\n    if (!lost) gl.viewport(0, 0, canvas.width, canvas.height)\n    wake()\n    return true\n  }\n\n  let colorsKey = \"\"\n  const syncColors = () => {\n    const source = options.colors?.length\n      ? options.colors\n      : dark\n        ? DARK_COLORS\n        : LIGHT_COLORS\n    const key = `${source.join()}|${dark}`\n    if (key === colorsKey) return\n    colorsKey = key\n    uStops.forEach((loc, i) => {\n      gl.uniform3fv(loc, hexToLinear(source[i % source.length]!))\n    })\n    gl.uniform3fv(uBase, hexToLinear(dark ? DARK_BASE : LIGHT_BASE))\n  }\n\n  const mqReduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\")\n  let onScreen = true\n  let raf = 0\n  let destroyed = false\n  // Set while the browser has taken the WebGL context away.\n  let lost = false\n  let last = 0\n  let clock = 0\n  // Seconds since the fire first caught; drives the ignite.\n  let lit = mqReduce.matches ? 10 : 0\n\n  const moving = () =>\n    onScreen && !mqReduce.matches && document.visibilityState !== \"hidden\"\n\n  function wake() {\n    // An observer callback can still arrive after destroy.\n    if (raf || destroyed || lost) return\n    last = performance.now()\n    raf = requestAnimationFrame(tick)\n  }\n\n  /** Draws in place now, without advancing; the tick carries on if live. */\n  function redraw() {\n    if (destroyed || lost) return\n    cancelAnimationFrame(raf)\n    raf = 0\n    last = performance.now()\n    tick(last)\n  }\n\n  // An arrow, not a declaration, so TypeScript keeps `gl` narrowed inside.\n  const tick = (now: number) => {\n    raf = 0\n    if (lost) return\n    const dt = Math.min(0.05, Math.max(0, (now - last) / 1000))\n    last = now\n    const live = moving()\n    if (live) {\n      clock += dt\n      lit += dt\n    } else if (mqReduce.matches) {\n      lit = 10\n    }\n\n    mouse.x += (target.x - mouse.x) * 0.08\n    mouse.y += (target.y - mouse.y) * 0.08\n    pull += (pullTarget - pull) * 0.05\n\n    syncColors()\n    const speed = numberOr(options.speed, DEFAULT_SPEED, 0, 4)\n    const ignite = 1 - (1 - Math.min(lit / 1.1, 1)) ** 3\n    const px = Math.max(1, numberOr(options.pixelSize, 1, 1, 64)) * dpr\n    gl.uniform2f(uResolution, canvas.width, canvas.height)\n    gl.uniform1f(uTime, clock * speed)\n    gl.uniform1f(\n      uIntensity,\n      numberOr(options.intensity, DEFAULT_INTENSITY, 0, 1)\n    )\n    gl.uniform1f(uHeight, numberOr(options.height, DEFAULT_HEIGHT, 0, 1))\n    gl.uniform1f(uIgnite, Math.max(ignite, 0.001))\n    gl.uniform1f(uDark, dark ? 1 : 0)\n    gl.uniform1f(uDither, options.dither ? 1 : 0)\n    gl.uniform1f(uPixel, options.dither ? px : dpr)\n    gl.uniform1f(uPointer, options.interactive === false ? 0 : pull)\n    gl.uniform2f(uMouse, mouse.x, mouse.y)\n    gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n    const settling =\n      Math.abs(pull - pullTarget) > 0.002 ||\n      Math.abs(target.x - mouse.x) > 0.001 ||\n      Math.abs(target.y - mouse.y) > 0.001\n    if (live || (settling && !mqReduce.matches)) {\n      raf = requestAnimationFrame(tick)\n    }\n  }\n\n  // Resizing cleared the canvas; draw now, or it shows blank for a frame.\n  const ro = new ResizeObserver(() => {\n    if (resize()) redraw()\n  })\n  if (canvas.parentElement) ro.observe(canvas.parentElement)\n  const io = new IntersectionObserver(([entry]) => {\n    onScreen = entry?.isIntersecting ?? true\n    wake()\n  })\n  io.observe(canvas)\n  const onVisibility = () => wake()\n  document.addEventListener(\"visibilitychange\", onVisibility)\n  const onReduce = () => wake()\n  mqReduce.addEventListener(\"change\", onReduce)\n\n  const syncTheme = () => {\n    const next = resolveDark(options.theme ?? \"auto\")\n    if (next === dark) return\n    dark = next\n    options.onThemeChange?.(dark)\n    wake()\n  }\n  const mo = new MutationObserver(syncTheme)\n  mo.observe(document.documentElement, {\n    attributes: true,\n    attributeFilter: [\"class\", \"data-theme\", \"style\"],\n  })\n  const mqDark = window.matchMedia(\"(prefers-color-scheme: dark)\")\n  mqDark.addEventListener(\"change\", syncTheme)\n\n  const onMove = (e: PointerEvent) => {\n    if (options.interactive === false) return\n    const rect = canvas.getBoundingClientRect()\n    if (rect.width <= 0 || rect.height <= 0) return\n    const x = (e.clientX - rect.left) / rect.width\n    const y = 1 - (e.clientY - rect.top) / rect.height\n    const inside = x >= 0 && x <= 1 && y >= 0 && y <= 1\n    pullTarget = inside ? 1 : 0\n    if (inside) {\n      target.x = x\n      target.y = y\n    }\n    wake()\n  }\n  window.addEventListener(\"pointermove\", onMove, { passive: true })\n\n  // GPU resets, backgrounded tabs and the live-context cap can take the\n  // context away. preventDefault asks the browser to hand it back; then\n  // rebuild everything and draw again.\n  const onLost = (e: Event) => {\n    e.preventDefault()\n    lost = true\n    cancelAnimationFrame(raf)\n    raf = 0\n  }\n  const onRestored = () => {\n    if (destroyed || !initGl()) return\n    lost = false\n    colorsKey = \"\"\n    resize()\n    wake()\n  }\n  canvas.addEventListener(\"webglcontextlost\", onLost)\n  canvas.addEventListener(\"webglcontextrestored\", onRestored)\n\n  resize()\n  wake()\n\n  return {\n    setOptions(next) {\n      options = { ...options, ...next }\n      syncTheme()\n      wake()\n    },\n    destroy() {\n      destroyed = true\n      cancelAnimationFrame(raf)\n      raf = 0\n      ro.disconnect()\n      io.disconnect()\n      mo.disconnect()\n      document.removeEventListener(\"visibilitychange\", onVisibility)\n      mqReduce.removeEventListener(\"change\", onReduce)\n      mqDark.removeEventListener(\"change\", syncTheme)\n      window.removeEventListener(\"pointermove\", onMove)\n      canvas.removeEventListener(\"webglcontextlost\", onLost)\n      canvas.removeEventListener(\"webglcontextrestored\", onRestored)\n      gl.deleteProgram(program)\n      gl.deleteShader(vs)\n      gl.deleteShader(fs)\n      gl.deleteBuffer(buf)\n      // Free the GPU context once the canvas has left the page; browsers cap\n      // live contexts at about 16. A canvas still in the page (a React\n      // Strict Mode replay) keeps it, so a new engine can reuse it.\n      const lose = gl.getExtension(\"WEBGL_lose_context\")\n      queueMicrotask(() => {\n        if (!canvas.isConnected && !gl.isContextLost()) lose?.loseContext()\n      })\n    },\n  }\n}\n\nexport type ShaderAnimeFireProps = Omit<\n  ShaderAnimeFireOptions,\n  \"onThemeChange\"\n> & {\n  className?: string\n}\n\n/**\n * Cel-shaded flames licking up from the bottom edge, over a warm flickering\n * glow. Heat reaches for the pointer. Theme-aware.\n */\nexport function ShaderAnimeFire({\n  className,\n  colors,\n  speed = DEFAULT_SPEED,\n  intensity = DEFAULT_INTENSITY,\n  height = DEFAULT_HEIGHT,\n  interactive = true,\n  dither = false,\n  pixelSize = 1,\n  theme = \"auto\",\n}: ShaderAnimeFireProps) {\n  const canvasRef = useRef<HTMLCanvasElement>(null)\n  const instanceRef = useRef<ShaderAnimeFireInstance | null>(null)\n  const [isDark, setIsDark] = useState(false)\n\n  useEffect(() => {\n    const sync = () => setIsDark(resolveDark(theme))\n    sync()\n    const mo = new MutationObserver(sync)\n    mo.observe(document.documentElement, {\n      attributes: true,\n      attributeFilter: [\"class\", \"data-theme\"],\n    })\n    const mq = window.matchMedia(\"(prefers-color-scheme: dark)\")\n    mq.addEventListener(\"change\", sync)\n    return () => {\n      mo.disconnect()\n      mq.removeEventListener(\"change\", sync)\n    }\n  }, [theme])\n\n  useEffect(() => {\n    const canvas = canvasRef.current\n    if (!canvas) return\n    instanceRef.current = createShaderAnimeFire(canvas, {\n      colors,\n      speed,\n      intensity,\n      height,\n      interactive,\n      dither,\n      pixelSize,\n      theme,\n      onThemeChange: setIsDark,\n    })\n    return () => {\n      instanceRef.current?.destroy()\n      instanceRef.current = null\n    }\n    // Engine reads live options via setOptions; mount once.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [])\n\n  useEffect(() => {\n    instanceRef.current?.setOptions({\n      colors,\n      speed,\n      intensity,\n      height,\n      interactive,\n      dither,\n      pixelSize,\n      theme,\n      onThemeChange: setIsDark,\n    })\n  }, [colors, speed, intensity, height, interactive, dither, pixelSize, theme])\n\n  const fallback = isDark ? DARK_FALLBACK : LIGHT_FALLBACK\n\n  return (\n    <div\n      data-slot=\"shader-anime-fire\"\n      aria-hidden\n      className={cn(\n        \"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit] [mask-image:linear-gradient(#000,#000)]\",\n        className\n      )}\n      style={{\n        backgroundColor: fallback.backgroundColor,\n        backgroundImage: fallback.backgroundImage,\n      }}\n    >\n      {/* Firefox can hand an opaque WebGL canvas straight to the system\n          compositor, which ignores rounded clips. The mask on the root keeps\n          it in the page's own layer, so the parent's radius holds. */}\n      <canvas\n        ref={canvasRef}\n        className=\"absolute inset-0 size-full rounded-[inherit]\"\n      />\n    </div>\n  )\n}\n",
      "type": "registry:ui",
      "target": "components/ui/shader-anime-fire.tsx"
    }
  ],
  "type": "registry:ui"
}