{
	"$schema": "https://ui.shadcn.com/schema/registry-item.json",
	"name": "LineSpiral-TS-CSS",
	"title": "LineSpiral",
	"description": "Glowing lines that spiral down an endless 3D tunnel, brighten around the cursor and send a wave of light on click.",
	"type": "registry:component",
	"files": [
		{
			"type": "registry:file",
			"path": "LineSpiral.css",
			"target": "@components/LineSpiral.css",
			"content": ".line-spiral-container {\n  position: relative;\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n}\n\n.line-spiral-canvas {\n  position: absolute;\n  inset: 0;\n  display: block;\n  width: 100%;\n  height: 100%;\n}\n"
		},
		{
			"type": "registry:component",
			"path": "LineSpiral.tsx",
			"content": "'use client';\n\nimport { useEffect, useRef, useState, type HTMLAttributes } from 'react';\n\nimport './LineSpiral.css';\n\nconst MAX_COLORS = 8;\nconst MAX_PULSES = 3;\nconst MAX_LAYERS = 4;\nconst MAX_RENDER_DIM = 2400;\nconst BLOOM_LEVELS = 4;\nconst INTRO_SECONDS = 2.4;\nconst PULSE_SECONDS = 2.2;\nconst DEFAULT_COLORS = ['#f2f5ff', '#7fb2ff', '#2f6bff'];\n\nexport type LineSpiralDirection = 'clockwise' | 'counterclockwise';\n\nexport interface LineSpiralProps extends HTMLAttributes<HTMLDivElement> {\n  colors?: string[];\n  colorSpread?: number;\n  colorSpeed?: number;\n  lines?: number;\n  layers?: number;\n  twist?: number;\n  direction?: LineSpiralDirection;\n  speed?: number;\n  spin?: number;\n  thickness?: number;\n  warp?: number;\n  streaks?: number;\n  depth?: number;\n  blur?: number;\n  glow?: number;\n  brightness?: number;\n  grain?: number;\n  fade?: number;\n  variation?: number;\n  opacity?: number;\n  intro?: boolean;\n  mouseInteraction?: boolean;\n  mouseStrength?: number;\n  clickBurst?: boolean;\n  lightMode?: boolean;\n  paused?: boolean;\n  dpr?: number;\n}\n\ntype ProgramName = 'scene' | 'down' | 'shrink' | 'blur' | 'up' | 'composite';\n\ntype Job = { program: WebGLProgram; vertex: WebGLShader; fragment: WebGLShader };\n\ntype Program = { program: WebGLProgram; uniforms: Record<string, WebGLUniformLocation | null> };\n\ntype Target = { texture: WebGLTexture | null; framebuffer: WebGLFramebuffer | null; width: number; height: number };\n\ntype Level = { a: Target; b: Target };\n\ntype Targets = { key: string; scene: Target; levels: Level[] };\n\ntype Pulse = { start: number };\n\nconst VERTEX = `#version 300 es\nvoid main() {\n  vec2 p = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));\n  gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);\n}`;\n\nconst SCENE = `#version 300 es\nprecision highp float;\nuniform vec2 uRes;\nuniform vec2 uLook;\nuniform float uFocal;\nuniform float uTravel;\nuniform float uSpin;\nuniform float uTwist;\nuniform float uLines;\nuniform float uLayers;\nuniform float uWidth;\nuniform float uWarp;\nuniform float uWave;\nuniform float uReach;\nuniform float uBlur;\nuniform float uSpread;\nuniform float uHue;\nuniform float uStreaks;\nuniform float uStreakPhase;\nuniform float uSeed;\nuniform vec3 uColors[${MAX_COLORS}];\nuniform float uColorCount;\nuniform vec4 uPulses[${MAX_PULSES}];\nuniform vec4 uCursor;\nuniform vec2 uDrag;\nuniform float uIntro;\nuniform float uIntroHead;\nout vec4 outColor;\n\nconst float TAU = 6.28318530718;\n\nvec3 tint(float t) {\n  float x = fract(t) * uColorCount;\n  float i = floor(x);\n  float f = x - i;\n  f = f * f * (3.0 - 2.0 * f);\n  int a = int(i);\n  int b = int(mod(i + 1.0, uColorCount));\n  return mix(uColors[a], uColors[b], f);\n}\n\nfloat hash(float n) {\n  return fract(sin(n * 12.9898 + uSeed * 78.233) * 43758.5453);\n}\n\nvec3 strand(float k, float d, float layer, float depth, float halfWidth, float edge, float lz) {\n  float id = mod(k, uLines) + layer * 13.0;\n  float h1 = hash(id);\n  float h2 = hash(id + 41.0);\n  halfWidth *= 0.7 + 0.6 * hash(id + 7.0);\n  float w = max(halfWidth, edge * 0.5);\n  float t = clamp((w + edge - d) / (2.0 * edge), 0.0, 1.0);\n  float body = t * t * (3.0 - 2.0 * t) * min(1.0, halfWidth / w);\n  if (body <= 0.0) return vec3(0.0);\n  body *= 1.0 - 0.35 * smoothstep(0.0, w + edge, d);\n  float world = depth + uTravel;\n  float band = pow(0.5 + 0.5 * sin(world * 1.1 + h1 * TAU + uStreakPhase), 6.0);\n  float streak = mix(1.0, 0.3 + 2.6 * band, uStreaks);\n  float strength = 0.35 + 0.65 * h2;\n  float front = uIntro - h1 * 0.4;\n  float reveal = smoothstep(front - 0.3, front, lz);\n  float head = exp(-pow((lz - front) / 0.12, 2.0)) * uIntroHead;\n  vec3 tone = tint(world * 0.06 * uSpread + uHue + h1 * 0.12);\n  return tone * body * (strength * streak * reveal + head * 2.5);\n}\n\nfloat pulses(float lz) {\n  float lift = 0.0;\n  for (int k = 0; k < ${MAX_PULSES}; k++) {\n    vec4 pulse = uPulses[k];\n    if (pulse.w <= 0.0) continue;\n    float band = lz - pulse.x;\n    lift += pulse.y * exp(-band * band / 0.05);\n  }\n  return lift;\n}\n\nvoid main() {\n  float px = 1.0 / uRes.y;\n  vec2 screen = (gl_FragCoord.xy - 0.5 * uRes) * px;\n  vec2 toCursor = screen - uCursor.xy;\n  float spot = dot(toCursor, toCursor);\n  float near = exp(-spot / 0.04);\n  vec2 uv = screen - toCursor * uCursor.w * near - uDrag * exp(-spot / 0.08) - uLook;\n  float r = max(length(uv), 1e-3);\n  float angle = atan(uv.y, uv.x);\n  float lr = log(r);\n  float wave = uWarp * (0.55 * sin(lr * 1.9 + uWave) + 0.3 * sin(lr * 3.7 - uWave * 1.37 + 2.1));\n  float slope = uWarp * (1.045 * cos(lr * 1.9 + uWave) + 1.11 * cos(lr * 3.7 - uWave * 1.37 + 2.1));\n  float cursor = 1.0 + uCursor.z * near;\n  vec3 light = vec3(0.0);\n  for (int i = 0; i < ${MAX_LAYERS}; i++) {\n    float layer = float(i);\n    if (layer >= uLayers) break;\n    float share = layer / max(uLayers - 1.0, 1.0);\n    float radius = pow(1.8, layer);\n    float depth = radius * uFocal / r;\n    float far = 1.0 - smoothstep(uReach * 0.12, uReach, depth);\n    if (far <= 0.0) continue;\n    float lz = log(depth);\n    float twist = uTwist * mix(1.0, 1.3, share);\n    float bend = slope - twist;\n    float gap = r * TAU / (uLines * sqrt(1.0 + bend * bend)) / px;\n    float dense = smoothstep(2.5, 7.0, gap);\n    float spin = uSpin * mix(1.0, 0.5, share) + hash(layer + 91.0) * TAU;\n    float phase = (angle - twist * lz - spin - wave) * uLines / TAU;\n    float nearest = floor(phase + 0.5);\n    float offset = phase - nearest;\n    float halfWidth = uWidth * r / radius / px;\n    float soft = uBlur * 0.016 * max(log(1.6 / depth), 0.0) / px;\n    float edge = sqrt(soft * soft + 0.36);\n    float lift = pulses(lz);\n    float weight = far * dense * mix(1.0, 0.55, share) * cursor;\n    vec3 lit = strand(nearest, abs(offset) * gap, layer, depth, halfWidth, edge, lz);\n    lit += strand(nearest + sign(offset), (1.0 - abs(offset)) * gap, layer, depth, halfWidth, edge, lz);\n    light += (lit * (1.0 + lift) + vec3(dot(lit, vec3(0.3333))) * lift * 0.8) * weight;\n  }\n  outColor = vec4(light, 1.0);\n}`;\n\nconst DOWN = `#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform vec2 uTexel;\nuniform float uExposure;\nout vec4 outColor;\nvec3 pick(vec2 at) {\n  vec3 c = texture(uSource, at).rgb * uExposure;\n  float peak = max(max(c.r, c.g), c.b);\n  return c * smoothstep(0.3, 1.4, peak);\n}\nvoid main() {\n  vec2 uv = gl_FragCoord.xy * 2.0 * uTexel;\n  vec3 c = pick(uv + vec2(-0.5, -0.5) * uTexel);\n  c += pick(uv + vec2(0.5, -0.5) * uTexel);\n  c += pick(uv + vec2(-0.5, 0.5) * uTexel);\n  c += pick(uv + vec2(0.5, 0.5) * uTexel);\n  outColor = vec4(c * 0.25, 1.0);\n}`;\n\nconst SHRINK = `#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform vec2 uTexel;\nout vec4 outColor;\nvoid main() {\n  vec2 uv = gl_FragCoord.xy * 2.0 * uTexel;\n  vec3 c = texture(uSource, uv + vec2(-0.5, -0.5) * uTexel).rgb;\n  c += texture(uSource, uv + vec2(0.5, -0.5) * uTexel).rgb;\n  c += texture(uSource, uv + vec2(-0.5, 0.5) * uTexel).rgb;\n  c += texture(uSource, uv + vec2(0.5, 0.5) * uTexel).rgb;\n  outColor = vec4(c * 0.25, 1.0);\n}`;\n\nconst BLUR = `#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform vec2 uStep;\nuniform vec2 uSize;\nout vec4 outColor;\nvoid main() {\n  vec2 uv = gl_FragCoord.xy / uSize;\n  vec3 c = texture(uSource, uv).rgb * 0.2270270;\n  c += texture(uSource, uv + uStep * 1.3846154).rgb * 0.3162162;\n  c += texture(uSource, uv - uStep * 1.3846154).rgb * 0.3162162;\n  c += texture(uSource, uv + uStep * 3.2307692).rgb * 0.0702703;\n  c += texture(uSource, uv - uStep * 3.2307692).rgb * 0.0702703;\n  outColor = vec4(c, 1.0);\n}`;\n\nconst UP = `#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform sampler2D uBase;\nuniform vec2 uSize;\nout vec4 outColor;\nvoid main() {\n  vec2 uv = gl_FragCoord.xy / uSize;\n  outColor = vec4(texture(uBase, uv).rgb + texture(uSource, uv).rgb, 1.0);\n}`;\n\nconst COMPOSITE = `#version 300 es\nprecision highp float;\nuniform sampler2D uScene;\nuniform sampler2D uBloom;\nuniform vec2 uRes;\nuniform float uExposure;\nuniform float uGlow;\nuniform float uGrain;\nuniform float uFade;\nuniform float uFrame;\nuniform float uLightMode;\nuniform float uOpacity;\nout vec4 outColor;\n\nfloat h31(vec3 p) {\n  p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n  p += dot(p, p.yxz + 33.33);\n  return fract((p.x + p.y) * p.z);\n}\n\nfloat feather(float x, float w) {\n  if (w <= 0.0) return 1.0;\n  float t = clamp(min(x, 1.0 - x) / w, 0.0, 1.0);\n  return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nvoid main() {\n  vec2 uv = gl_FragCoord.xy / uRes;\n  vec3 c = texture(uScene, uv).rgb * uExposure + texture(uBloom, uv).rgb * uGlow;\n  vec3 col = 1.0 - exp(-c);\n  col *= feather(uv.x, uFade * 0.34) * feather(uv.y, uFade * 0.44);\n  float top = max(max(col.r, col.g), col.b);\n  float noise = h31(vec3(floor(gl_FragCoord.xy), uFrame)) - 0.5;\n  if (uLightMode > 0.5) {\n    vec3 hue = col / max(top, 1e-3);\n    float lum = dot(hue, vec3(0.2126, 0.7152, 0.0722));\n    vec3 ink = clamp(hue * (0.42 / max(lum, 0.22)), 0.0, 1.0);\n    ink = mix(ink, vec3(0.11, 0.12, 0.16), clamp(1.0 - (top - min(min(col.r, col.g), col.b)) * 3.0, 0.0, 1.0) * 0.85);\n    float alpha = clamp(top * 1.4 - 0.05, 0.0, 1.0) * 0.95;\n    alpha = clamp(alpha + noise * uGrain * alpha, 0.0, 1.0);\n    outColor = vec4(ink * alpha, alpha) * uOpacity;\n    return;\n  }\n  col = clamp(col + noise * uGrain * (0.25 + col), 0.0, 1.0);\n  outColor = vec4(col, max(max(col.r, col.g), col.b)) * uOpacity;\n}`;\n\nconst PROGRAMS: Record<ProgramName, { source: string; uniforms: string[] }> = {\n  scene: {\n    source: SCENE,\n    uniforms: [\n      'uRes',\n      'uLook',\n      'uFocal',\n      'uTravel',\n      'uSpin',\n      'uTwist',\n      'uLines',\n      'uLayers',\n      'uWidth',\n      'uWarp',\n      'uWave',\n      'uReach',\n      'uBlur',\n      'uSpread',\n      'uHue',\n      'uStreaks',\n      'uStreakPhase',\n      'uSeed',\n      'uColors',\n      'uColorCount',\n      'uPulses',\n      'uCursor',\n      'uDrag',\n      'uIntro',\n      'uIntroHead'\n    ]\n  },\n  down: { source: DOWN, uniforms: ['uSource', 'uTexel', 'uExposure'] },\n  shrink: { source: SHRINK, uniforms: ['uSource', 'uTexel'] },\n  blur: { source: BLUR, uniforms: ['uSource', 'uStep', 'uSize'] },\n  up: { source: UP, uniforms: ['uSource', 'uBase', 'uSize'] },\n  composite: {\n    source: COMPOSITE,\n    uniforms: ['uScene', 'uBloom', 'uRes', 'uExposure', 'uGlow', 'uGrain', 'uFade', 'uFrame', 'uLightMode', 'uOpacity']\n  }\n};\n\nconst NAMES = Object.keys(PROGRAMS) as ProgramName[];\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\nconst num = (value: unknown, fallback: number) => {\n  const parsed = Number(value);\n  return Number.isFinite(parsed) ? parsed : fallback;\n};\n\nconst compileShader = (gl: WebGL2RenderingContext, 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  return shader;\n};\n\nconst startProgram = (gl: WebGL2RenderingContext, source: string): Job | null => {\n  const vertex = compileShader(gl, gl.VERTEX_SHADER, VERTEX);\n  const fragment = compileShader(gl, gl.FRAGMENT_SHADER, source);\n  const program = vertex && fragment ? gl.createProgram() : null;\n  if (!vertex || !fragment || !program) {\n    if (vertex) gl.deleteShader(vertex);\n    if (fragment) gl.deleteShader(fragment);\n    return null;\n  }\n  gl.attachShader(program, vertex);\n  gl.attachShader(program, fragment);\n  gl.linkProgram(program);\n  return { program, vertex, fragment };\n};\n\nconst finishProgram = (gl: WebGL2RenderingContext, job: Job, names: string[]): Program | null => {\n  const { program, vertex, fragment } = job;\n  const linked = gl.getProgramParameter(program, gl.LINK_STATUS);\n  if (!linked && !gl.isContextLost()) {\n    const broken = [vertex, fragment].filter(shader => !gl.getShaderParameter(shader, gl.COMPILE_STATUS));\n    if (broken.length) broken.forEach(shader => console.error(gl.getShaderInfoLog(shader)));\n    else console.error(gl.getProgramInfoLog(program));\n  }\n  gl.deleteShader(vertex);\n  gl.deleteShader(fragment);\n  if (!linked) {\n    gl.deleteProgram(program);\n    return null;\n  }\n  const uniforms: Record<string, WebGLUniformLocation | null> = {};\n  for (const name of names) uniforms[name] = gl.getUniformLocation(program, name);\n  return { program, uniforms };\n};\n\nconst LineSpiral = ({\n  colors = DEFAULT_COLORS,\n  colorSpread = 1,\n  colorSpeed = 0.15,\n  lines = 5,\n  layers = 3,\n  twist = 1,\n  direction = 'clockwise',\n  speed = 1,\n  spin = 0.2,\n  thickness = 1,\n  warp = 0.5,\n  streaks = 0.6,\n  depth = 1,\n  blur = 0.35,\n  glow = 0.6,\n  brightness = 1,\n  grain = 0,\n  fade = 0,\n  variation = 0,\n  opacity = 1,\n  intro = true,\n  mouseInteraction = true,\n  mouseStrength = 1,\n  clickBurst = true,\n  lightMode = false,\n  paused = false,\n  dpr,\n  className = '',\n  ...rest\n}: LineSpiralProps) => {\n  const containerRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const wakeRef = useRef<(() => void) | null>(null);\n  const releaseRef = useRef(0);\n  const [generation, setGeneration] = useState(0);\n  const palette = (Array.isArray(colors) && colors.length ? colors : DEFAULT_COLORS).slice(0, MAX_COLORS).map(String);\n  const settings = {\n    colors: palette,\n    colorSpread: clamp(num(colorSpread, 1), 0, 6),\n    colorSpeed: num(colorSpeed, 0.15),\n    lines: Math.round(clamp(num(lines, 5), 1, 24)),\n    layers: Math.round(clamp(num(layers, 3), 1, MAX_LAYERS)),\n    twist: clamp(num(twist, 1), -3, 3),\n    turn: direction === 'counterclockwise' ? 1 : -1,\n    speed: num(speed, 1),\n    spin: num(spin, 0.2),\n    thickness: clamp(num(thickness, 1), 0.1, 6),\n    warp: clamp(num(warp, 0.5), 0, 2),\n    streaks: clamp(num(streaks, 0.6), 0, 1),\n    depth: clamp(num(depth, 1), 0.2, 3),\n    blur: clamp(num(blur, 0.35), 0, 2),\n    glow: clamp(num(glow, 0.6), 0, 3),\n    brightness: Math.max(0, num(brightness, 1)),\n    grain: clamp(num(grain, 0), 0, 1),\n    fade: clamp(num(fade, 0), 0, 1),\n    variation: num(variation, 0),\n    opacity: clamp(num(opacity, 1), 0, 1),\n    intro,\n    mouseInteraction,\n    mouseStrength: clamp(num(mouseStrength, 1), 0, 3),\n    clickBurst,\n    lightMode,\n    paused,\n    dpr\n  };\n  const settingsRef = useRef(settings);\n  settingsRef.current = settings;\n\n  useEffect(() => {\n    wakeRef.current?.();\n  });\n\n  useEffect(() => {\n    const container = containerRef.current;\n    const canvas = canvasRef.current;\n    if (!container || !canvas) return undefined;\n    cancelAnimationFrame(releaseRef.current);\n    releaseRef.current = 0;\n    const gl = canvas.getContext('webgl2', {\n      alpha: true,\n      premultipliedAlpha: true,\n      antialias: false,\n      depth: false,\n      stencil: false,\n      powerPreference: 'default'\n    });\n    if (!gl) return undefined;\n    const parallel = gl.getExtension('KHR_parallel_shader_compile');\n    const floatTargets = Boolean(gl.getExtension('EXT_color_buffer_float'));\n    const jobs: Partial<Record<ProgramName, Job>> = {};\n    const programs: Partial<Record<ProgramName, Program>> = {};\n    let broken = false;\n    for (const name of NAMES) {\n      const job = startProgram(gl, PROGRAMS[name].source);\n      if (!job) broken = true;\n      else jobs[name] = job;\n    }\n    const finishAll = () => {\n      for (const name of NAMES) {\n        const job = jobs[name];\n        if (!job) continue;\n        delete jobs[name];\n        const done = finishProgram(gl, job, PROGRAMS[name].uniforms);\n        if (done) programs[name] = done;\n        else broken = true;\n      }\n      return !broken;\n    };\n    if (!parallel) finishAll();\n    const vao = gl.createVertexArray();\n    const probe = document.createElement('canvas');\n    probe.width = 1;\n    probe.height = 1;\n    const probeContext = probe.getContext('2d', { willReadFrequently: true });\n    const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;\n    const colorData = new Float32Array(MAX_COLORS * 3);\n    const pulseData = new Float32Array(MAX_PULSES * 4);\n    const state = {\n      travel: 2,\n      spin: 0,\n      hue: 0,\n      wave: 0,\n      streak: 0,\n      clock: 0,\n      frame: 0,\n      intro: settingsRef.current.intro && !reduce && !settingsRef.current.paused ? 0 : INTRO_SECONDS + 2,\n      width: 1,\n      height: 1,\n      paletteKey: '',\n      colorCount: 1,\n      targets: null as Targets | null,\n      pointer: { x: 0, y: 0, inside: false, placed: false },\n      look: { x: 0, y: 0, vx: 0, vy: 0 },\n      cursor: { x: 0, y: 0, glow: 0, energy: 0 },\n      trail: { x: 0, y: 0 },\n      drag: { x: 0, y: 0 },\n      surge: 0,\n      pulses: [] as Pulse[]\n    };\n    let raf = 0;\n    let last = 0;\n    let visible = true;\n    let alive = true;\n    let lost = false;\n\n    const toRgb = (value: string): number[] => {\n      if (!probeContext || !value) return [1, 1, 1];\n      const css = /^[0-9a-f]{3,8}$/i.test(value) ? `#${value}` : value;\n      probeContext.clearRect(0, 0, 1, 1);\n      probeContext.fillStyle = '#000000';\n      probeContext.fillStyle = css;\n      probeContext.fillRect(0, 0, 1, 1);\n      const [r, g, b] = probeContext.getImageData(0, 0, 1, 1).data;\n      return [r / 255, g / 255, b / 255];\n    };\n\n    const syncPalette = (s: typeof settings) => {\n      const key = s.colors.join('|');\n      if (key === state.paletteKey) return;\n      state.paletteKey = key;\n      colorData.fill(0);\n      s.colors.forEach((color, index) => colorData.set(toRgb(color), index * 3));\n      state.colorCount = s.colors.length;\n    };\n\n    const makeTarget = (width: number, height: number): Target => {\n      const texture = gl.createTexture();\n      gl.bindTexture(gl.TEXTURE_2D, texture);\n      gl.texImage2D(\n        gl.TEXTURE_2D,\n        0,\n        floatTargets ? gl.RGBA16F : gl.RGBA8,\n        width,\n        height,\n        0,\n        gl.RGBA,\n        floatTargets ? gl.HALF_FLOAT : gl.UNSIGNED_BYTE,\n        null\n      );\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n      const framebuffer = gl.createFramebuffer();\n      gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\n      gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n      gl.clearColor(0, 0, 0, 1);\n      gl.clear(gl.COLOR_BUFFER_BIT);\n      gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n      return { texture, framebuffer, width, height };\n    };\n\n    const freeTarget = (target: Target) => {\n      gl.deleteTexture(target.texture);\n      gl.deleteFramebuffer(target.framebuffer);\n    };\n\n    const freeTargets = () => {\n      if (!state.targets) return;\n      freeTarget(state.targets.scene);\n      state.targets.levels.forEach(level => {\n        freeTarget(level.a);\n        freeTarget(level.b);\n      });\n      state.targets = null;\n    };\n\n    const syncTargets = () => {\n      const w = canvas.width;\n      const h = canvas.height;\n      const key = `${w}x${h}`;\n      if (state.targets && state.targets.key === key) return;\n      freeTargets();\n      const levels: Level[] = [];\n      let lw = w;\n      let lh = h;\n      for (let i = 0; i < BLOOM_LEVELS; i++) {\n        lw = Math.max(1, Math.round(lw / 2));\n        lh = Math.max(1, Math.round(lh / 2));\n        levels.push({ a: makeTarget(lw, lh), b: makeTarget(lw, lh) });\n      }\n      state.targets = { key, scene: makeTarget(w, h), levels };\n    };\n\n    const draw = (program: Program, target: Target | null, width: number, height: number) => {\n      gl.bindFramebuffer(gl.FRAMEBUFFER, target ? target.framebuffer : null);\n      gl.viewport(0, 0, width, height);\n      gl.useProgram(program.program);\n      gl.drawArrays(gl.TRIANGLES, 0, 3);\n    };\n\n    const bind = (unit: number, texture: WebGLTexture | null) => {\n      gl.activeTexture(gl.TEXTURE0 + unit);\n      gl.bindTexture(gl.TEXTURE_2D, texture);\n    };\n\n    const render = () => {\n      const { scene, down, shrink, blur, up, composite } = programs;\n      if (!scene || !down || !shrink || !blur || !up || !composite || broken || lost) return;\n      const s = settingsRef.current;\n      syncPalette(s);\n      syncTargets();\n      if (!state.targets) return;\n      const targets = state.targets;\n      const w = canvas.width;\n      const h = canvas.height;\n      gl.disable(gl.BLEND);\n      gl.bindVertexArray(vao);\n\n      const reach = 12 * s.depth;\n      const seed = Math.abs(Math.round(s.variation));\n      const u = scene.uniforms;\n      gl.useProgram(scene.program);\n      gl.uniform2f(u.uRes, w, h);\n      gl.uniform2f(u.uLook, state.look.x, state.look.y);\n      gl.uniform1f(u.uFocal, 0.9);\n      gl.uniform1f(u.uTravel, state.travel + (seed % 37) * 1.7);\n      gl.uniform1f(u.uSpin, (state.spin + (seed % 17) * 0.37) * s.turn);\n      gl.uniform1f(u.uTwist, s.twist * 2.6 * s.turn);\n      gl.uniform1f(u.uLines, s.lines);\n      gl.uniform1f(u.uLayers, s.layers);\n      gl.uniform1f(u.uWidth, 0.0075 * s.thickness);\n      gl.uniform1f(u.uWarp, s.warp * 0.4);\n      gl.uniform1f(u.uWave, state.wave + (seed % 23) * 0.61);\n      gl.uniform1f(u.uReach, reach);\n      gl.uniform1f(u.uBlur, s.blur * (s.lightMode ? 0.3 : 1));\n      gl.uniform1f(u.uSpread, s.colorSpread);\n      gl.uniform1f(u.uHue, state.hue + (seed % 11) * 0.09);\n      gl.uniform1f(u.uStreaks, s.streaks);\n      gl.uniform1f(u.uStreakPhase, state.streak + (seed % 13) * 0.83);\n      gl.uniform1f(u.uSeed, (seed % 29) * 0.173);\n      gl.uniform3fv(u.uColors, colorData);\n      gl.uniform1f(u.uColorCount, state.colorCount);\n      pulseData.fill(0);\n      state.pulses.forEach((pulse, index) => {\n        const age = state.clock - pulse.start;\n        const life = 1 - age / PULSE_SECONDS;\n        pulseData[index * 4] = Math.log(reach) - age * 1.9;\n        pulseData[index * 4 + 1] = 6 * life * life;\n        pulseData[index * 4 + 3] = 1;\n      });\n      gl.uniform4fv(u.uPulses, pulseData);\n      const lens = state.cursor.glow * Math.min(0.3, 0.12 * s.mouseStrength);\n      const lift = state.cursor.glow * s.mouseStrength * (0.25 + 0.45 * state.cursor.energy);\n      gl.uniform4f(u.uCursor, state.cursor.x, state.cursor.y, lift, lens);\n      gl.uniform2f(u.uDrag, state.drag.x, state.drag.y);\n      const ramp = clamp(state.intro / INTRO_SECONDS, 0, 1);\n      const eased = 1 - Math.pow(1 - ramp, 3);\n      const done = ramp >= 1;\n      gl.uniform1f(u.uIntro, done ? -20 : Math.log(reach) + 0.4 - eased * (Math.log(reach) + 1.6));\n      gl.uniform1f(u.uIntroHead, done ? 0 : 1 - eased);\n      draw(scene, targets.scene, w, h);\n\n      const exposure = 2.6 * s.brightness;\n      let source = targets.scene;\n      targets.levels.forEach((level, index) => {\n        const pass = index === 0 ? down : shrink;\n        gl.useProgram(pass.program);\n        bind(0, source.texture);\n        gl.uniform1i(pass.uniforms.uSource, 0);\n        gl.uniform2f(pass.uniforms.uTexel, 1 / source.width, 1 / source.height);\n        if (index === 0) gl.uniform1f(pass.uniforms.uExposure, exposure);\n        draw(pass, level.a, level.a.width, level.a.height);\n        gl.useProgram(blur.program);\n        gl.uniform1i(blur.uniforms.uSource, 0);\n        gl.uniform2f(blur.uniforms.uSize, level.a.width, level.a.height);\n        bind(0, level.a.texture);\n        gl.uniform2f(blur.uniforms.uStep, 1 / level.a.width, 0);\n        draw(blur, level.b, level.a.width, level.a.height);\n        bind(0, level.b.texture);\n        gl.uniform2f(blur.uniforms.uStep, 0, 1 / level.a.height);\n        draw(blur, level.a, level.a.width, level.a.height);\n        source = level.a;\n      });\n      for (let i = targets.levels.length - 2; i >= 0; i--) {\n        const level = targets.levels[i];\n        gl.useProgram(up.program);\n        bind(0, targets.levels[i + 1].a.texture);\n        bind(1, level.a.texture);\n        gl.uniform1i(up.uniforms.uSource, 0);\n        gl.uniform1i(up.uniforms.uBase, 1);\n        gl.uniform2f(up.uniforms.uSize, level.b.width, level.b.height);\n        draw(up, level.b, level.b.width, level.b.height);\n        const swap = level.a;\n        level.a = level.b;\n        level.b = swap;\n      }\n\n      const cu = composite.uniforms;\n      gl.useProgram(composite.program);\n      bind(0, targets.scene.texture);\n      bind(1, targets.levels[0].a.texture);\n      gl.uniform1i(cu.uScene, 0);\n      gl.uniform1i(cu.uBloom, 1);\n      gl.uniform2f(cu.uRes, w, h);\n      gl.uniform1f(cu.uExposure, exposure);\n      gl.uniform1f(cu.uGlow, s.glow * (s.lightMode ? 0.06 : 0.6));\n      gl.uniform1f(cu.uGrain, s.grain);\n      gl.uniform1f(cu.uFade, s.fade);\n      gl.uniform1f(cu.uFrame, state.frame % 977);\n      gl.uniform1f(cu.uLightMode, s.lightMode ? 1 : 0);\n      gl.uniform1f(cu.uOpacity, s.opacity);\n      draw(composite, null, w, h);\n      gl.bindVertexArray(null);\n    };\n\n    const resize = () => {\n      const s = settingsRef.current;\n      const width = Math.max(1, container.clientWidth);\n      const height = Math.max(1, container.clientHeight);\n      const base = Math.min(s.dpr || window.devicePixelRatio || 1, 2);\n      const longest = Math.max(width, height) * base;\n      const ratio = longest > MAX_RENDER_DIM ? (base * MAX_RENDER_DIM) / longest : base;\n      const pixelWidth = Math.max(1, Math.round(width * ratio));\n      const pixelHeight = Math.max(1, Math.round(height * ratio));\n      if (canvas.width !== pixelWidth || canvas.height !== pixelHeight) {\n        canvas.width = pixelWidth;\n        canvas.height = pixelHeight;\n      }\n      state.width = width;\n      state.height = height;\n      render();\n    };\n\n    const pending = () => NAMES.filter(name => jobs[name]);\n\n    const compiling = () =>\n      NAMES.some(name => {\n        const job = jobs[name];\n        return Boolean(job && parallel && !gl.getProgramParameter(job.program, parallel.COMPLETION_STATUS_KHR));\n      });\n\n    const ready = () => {\n      if (broken) return false;\n      if (!pending().length) return true;\n      if (!parallel || compiling()) return false;\n      return finishAll();\n    };\n\n    const frame = (now: number) => {\n      raf = 0;\n      if (!alive || !visible || document.hidden || lost) return;\n      if (!ready()) {\n        if (!broken && pending().length) raf = requestAnimationFrame(frame);\n        return;\n      }\n      const s = settingsRef.current;\n      const dt = last ? Math.min(0.05, (now - last) / 1000) : 0;\n      last = now;\n      const moving = !s.paused && !reduce;\n      const { pointer, look, cursor, trail, drag } = state;\n      if (moving) {\n        state.clock += dt;\n        state.frame += 1;\n        state.intro += dt;\n        state.surge *= Math.exp(-dt / 0.5);\n        const ramp = clamp(state.intro / INTRO_SECONDS, 0, 1);\n        const pace = s.speed * (0.4 + 0.6 * ramp * ramp) * (1 + state.surge * 3);\n        state.travel += dt * pace * 1.6;\n        state.spin += dt * s.spin * (1 + state.surge * 2);\n        state.hue += dt * s.colorSpeed * 0.1;\n        state.wave += dt * (0.45 + Math.abs(s.speed) * 0.2);\n        state.streak += dt * (0.8 + state.surge * 2);\n        state.pulses = state.pulses.filter(pulse => state.clock - pulse.start < PULSE_SECONDS);\n      } else if (state.intro < INTRO_SECONDS) {\n        state.intro = INTRO_SECONDS + 2;\n      }\n      const active = s.mouseInteraction && pointer.inside && !reduce;\n      const aspect = state.width / state.height;\n      const px = (pointer.x / state.width - 0.5) * aspect;\n      const py = 0.5 - pointer.y / state.height;\n      const drift = moving ? 0.025 : 0;\n      const goalX = Math.sin(state.clock * 0.21) * drift * aspect;\n      const goalY = Math.sin(state.clock * 0.17 + 1.3) * drift;\n      const glowGoal = active ? 1 : 0;\n      if (dt > 0) {\n        look.vx += (24 * (goalX - look.x) - 9 * look.vx) * dt;\n        look.vy += (24 * (goalY - look.y) - 9 * look.vy) * dt;\n        look.x += look.vx * dt;\n        look.y += look.vy * dt;\n        if (active) {\n          const follow = 1 - Math.exp(-dt / 0.06);\n          const stepX = (px - cursor.x) * follow;\n          const stepY = (py - cursor.y) * follow;\n          cursor.x += stepX;\n          cursor.y += stepY;\n          const speed = Math.hypot(stepX, stepY) / dt;\n          cursor.energy += (Math.min(1, speed * 0.8) - cursor.energy) * (1 - Math.exp(-dt / 0.25));\n        } else {\n          cursor.energy *= Math.exp(-dt / 0.4);\n        }\n        const lag = 1 - Math.exp(-dt / 0.22);\n        trail.x += (cursor.x - trail.x) * lag;\n        trail.y += (cursor.y - trail.y) * lag;\n        const limit = 0.032 * Math.min(s.mouseStrength, 2) * cursor.glow;\n        const pullX = (cursor.x - trail.x) * 0.7;\n        const pullY = (cursor.y - trail.y) * 0.7;\n        const pull = Math.hypot(pullX, pullY);\n        const scale = pull > limit ? limit / pull : 1;\n        drag.x = pullX * scale;\n        drag.y = pullY * scale;\n        cursor.glow += (glowGoal - cursor.glow) * (1 - Math.exp(-dt / 0.3));\n      }\n      render();\n      const settling =\n        Math.hypot(look.vx, look.vy) > 0.0005 ||\n        Math.hypot(goalX - look.x, goalY - look.y) > 0.0005 ||\n        Math.hypot(cursor.x - trail.x, cursor.y - trail.y) > 0.0005 ||\n        cursor.energy > 0.002 ||\n        Math.abs(glowGoal - cursor.glow) > 0.002;\n      if (moving || settling) raf = requestAnimationFrame(frame);\n      else last = 0;\n    };\n\n    const wake = () => {\n      if (!raf && alive && visible && !document.hidden && !lost) raf = requestAnimationFrame(frame);\n    };\n\n    const locate = (event: PointerEvent) => {\n      const rect = container.getBoundingClientRect();\n      const x = event.clientX - rect.left;\n      const y = event.clientY - rect.top;\n      return { x, y, inside: x >= 0 && y >= 0 && x <= rect.width && y <= rect.height };\n    };\n\n    const onPointerMove = (event: PointerEvent) => {\n      const spot = locate(event);\n      const { pointer } = state;\n      if (spot.inside && !pointer.placed) {\n        state.cursor.x = (spot.x / Math.max(state.width, 1) - 0.5) * (state.width / Math.max(state.height, 1));\n        state.cursor.y = 0.5 - spot.y / Math.max(state.height, 1);\n        if (state.cursor.glow < 0.05) {\n          state.trail.x = state.cursor.x;\n          state.trail.y = state.cursor.y;\n        }\n      }\n      pointer.x = spot.x;\n      pointer.y = spot.y;\n      pointer.inside = spot.inside;\n      pointer.placed = spot.inside;\n      wake();\n    };\n\n    const onPointerDown = (event: PointerEvent) => {\n      const s = settingsRef.current;\n      if (!s.mouseInteraction || !s.clickBurst || event.button !== 0 || reduce || s.paused) return;\n      if (\n        event.target instanceof Element &&\n        event.target.closest('a, button, input, textarea, select, label, [role=\"button\"]')\n      )\n        return;\n      const spot = locate(event);\n      if (!spot.inside) return;\n      state.surge = Math.min(1.5, state.surge + 1);\n      state.pulses.push({ start: state.clock });\n      while (state.pulses.length > MAX_PULSES) state.pulses.shift();\n      wake();\n    };\n\n    const onPointerLeave = () => {\n      state.pointer.inside = false;\n      state.pointer.placed = false;\n      wake();\n    };\n\n    const onVisibility = () => {\n      last = 0;\n      wake();\n    };\n\n    const onLost = (event: Event) => {\n      event.preventDefault();\n      lost = true;\n      cancelAnimationFrame(raf);\n      raf = 0;\n    };\n\n    const onRestored = () => setGeneration(value => value + 1);\n\n    const resizeObserver = new ResizeObserver(resize);\n    resizeObserver.observe(container);\n    const intersection = new IntersectionObserver(entries => {\n      visible = entries.some(entry => entry.isIntersecting);\n      if (visible) {\n        last = 0;\n        wake();\n      }\n    });\n    intersection.observe(container);\n    window.addEventListener('pointermove', onPointerMove, { passive: true });\n    window.addEventListener('pointerdown', onPointerDown);\n    document.documentElement.addEventListener('pointerleave', onPointerLeave);\n    document.addEventListener('visibilitychange', onVisibility);\n    canvas.addEventListener('webglcontextlost', onLost);\n    canvas.addEventListener('webglcontextrestored', onRestored);\n    resize();\n    wake();\n    wakeRef.current = () => {\n      if (!raf) render();\n      wake();\n    };\n\n    return () => {\n      alive = false;\n      cancelAnimationFrame(raf);\n      wakeRef.current = null;\n      resizeObserver.disconnect();\n      intersection.disconnect();\n      window.removeEventListener('pointermove', onPointerMove);\n      window.removeEventListener('pointerdown', onPointerDown);\n      document.documentElement.removeEventListener('pointerleave', onPointerLeave);\n      document.removeEventListener('visibilitychange', onVisibility);\n      canvas.removeEventListener('webglcontextlost', onLost);\n      canvas.removeEventListener('webglcontextrestored', onRestored);\n      if (!gl.isContextLost()) {\n        gl.deleteVertexArray(vao);\n        freeTargets();\n        NAMES.forEach(name => {\n          const program = programs[name];\n          if (program) gl.deleteProgram(program.program);\n        });\n        const release = () => {\n          const waiting = pending();\n          if (!waiting.length || gl.isContextLost()) return;\n          if (compiling()) {\n            requestAnimationFrame(release);\n            return;\n          }\n          waiting.forEach(name => {\n            const job = jobs[name];\n            if (!job) return;\n            gl.deleteShader(job.vertex);\n            gl.deleteShader(job.fragment);\n            gl.deleteProgram(job.program);\n            delete jobs[name];\n          });\n        };\n        release();\n      }\n      const free = () => {\n        releaseRef.current = 0;\n        if (!canvas.isConnected && !gl.isContextLost()) gl.getExtension('WEBGL_lose_context')?.loseContext();\n      };\n      if (canvas.isConnected) releaseRef.current = requestAnimationFrame(free);\n      else free();\n    };\n  }, [generation]);\n\n  return (\n    <div ref={containerRef} className={`line-spiral-container${className ? ` ${className}` : ''}`} {...rest}>\n      <canvas ref={canvasRef} className=\"line-spiral-canvas\" aria-hidden=\"true\" />\n    </div>\n  );\n};\n\nexport default LineSpiral;\n"
		}
	],
	"registryDependencies": [],
	"dependencies": []
}