{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ember-eclipse",
  "title": "Ember Eclipse",
  "author": "HorizonX <https://horizonx.so>",
  "description": "Ember Sun's fire round a flat disc, like a moon covering the sun. One WebGL shader, reacts to the pointer.",
  "files": [
    {
      "path": "registry/drops/ember-eclipse/ember-eclipse.tsx",
      "content": "'use client';\n\nimport { useEffect, useRef, type CSSProperties } from 'react';\nimport { buildEmberEclipse, DEFAULT_EMBER_ECLIPSE_CONFIG, type EmberEclipseConfig, type EmberEclipseHandle } from './ember-eclipse.engine.js';\n\nexport interface EmberEclipseProps {\n  /** Radius as a share of the short side, 0.16 to 0.36. */\n  size?: number;\n  /** Flame height, 0.4 to 1.6. */\n  flames?: number;\n  /** Rising embers, 0 to 2. */\n  embers?: number;\n  /** Ripples landing on the rim, 0 to 2. */\n  ripples?: number;\n  background?: string;\n  /** Colour of the flat disc covering the sun. */\n  disc?: string;\n  /** 0.2 to 2. */\n  speed?: number;\n  paused?: boolean;\n  /** The flames lean toward the pointer and a press sends a ripple. */\n  interactive?: boolean;\n  className?: string;\n  style?: CSSProperties;\n}\n\nconst clamp = (value: number | undefined, min: number, max: number, fallback: number) =>\n  typeof value === 'number' && Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : fallback;\n\nfunction toConfig(props: EmberEclipseProps): Partial<EmberEclipseConfig> {\n  const d = DEFAULT_EMBER_ECLIPSE_CONFIG;\n  return {\n    size: clamp(props.size, 0.16, 0.36, d.size),\n    flames: clamp(props.flames, 0.4, 1.6, d.flames),\n    embers: clamp(props.embers, 0, 2, d.embers),\n    ripples: clamp(props.ripples, 0, 2, d.ripples),\n    background: props.background ?? d.background,\n    disc: props.disc ?? d.disc,\n    speed: clamp(props.speed, 0.2, 2, d.speed),\n    animate: !props.paused,\n    interactive: props.interactive ?? true\n  };\n}\n\nconst CSS = `\n.eec-viewport{position:relative;box-sizing:border-box;width:100%;height:100%;overflow:hidden;isolation:isolate;container-type:size;touch-action:manipulation}\n.eec-stage{position:absolute;inset:0}\n.eec-viewport[data-fallback] .eec-stage::before{content:\"\";position:absolute;left:50%;top:50%;width:60cqmin;height:60cqmin;transform:translate(-50%,-50%);border-radius:50%;background:var(--eec-disc,#010102);box-shadow:0 0 0 2px #ffd2a0,0 0 18px 6px #ff5a1f,0 0 90px 24px rgba(255,90,31,.35)}\n.eec-status{position:absolute;inset:0;display:grid;place-items:center;padding:24px;color:#b4b4bc;font:14px/1.5 system-ui,sans-serif;text-align:center;pointer-events:none}\n.eec-status:empty{display:none}\n`;\n\n/** A burning eclipse drawn per pixel in one WebGL shader: Ember Sun's fire round a flat disc. Fills its parent. */\nexport function EmberEclipse({ className, style, ...props }: EmberEclipseProps) {\n  const root = useRef<HTMLDivElement>(null);\n  const engine = useRef<EmberEclipseHandle | null>(null);\n  const config = toConfig(props);\n  const latest = useRef(config);\n  const key = JSON.stringify(config);\n\n  // Declared before the mount effect so a remount always starts from the newest props.\n  useEffect(() => {\n    latest.current = config;\n    engine.current?.update(config);\n  }, [key]); // eslint-disable-line react-hooks/exhaustive-deps\n\n  useEffect(() => {\n    const handle = buildEmberEclipse(root.current!, latest.current);\n    engine.current = handle;\n    return () => { handle(); engine.current = null; };\n  }, []);\n\n  return (\n    <>\n      <style href=\"hx-drops-ember-eclipse\" precedence=\"default\">{CSS}</style>\n      <div\n        ref={root}\n        className={className ? `eec-viewport ${className}` : 'eec-viewport'}\n        style={{ background: config.background, '--eec-disc': config.disc, ...style } as CSSProperties}\n      >\n        <div className=\"eec-stage\" />\n        <span className=\"eec-status\" role=\"status\" />\n      </div>\n    </>\n  );\n}\n\nexport default EmberEclipse;\n",
      "type": "registry:component"
    },
    {
      "path": "registry/drops/ember-eclipse/ember-eclipse.engine.js",
      "content": "// HorizonX Drops: this engine is copied unchanged from the HorizonX editor\n// (horizonx-frontend src/lib/tools/emberEclipse.engine.js at 00b7cec).\n// Licensed under the HorizonX Drops License in this repository's LICENSE file.\n// Do not edit here: change it in horizonx-frontend and run scripts/sync-from-horizonx.mjs.\n// --- end of HorizonX Drops banner ---\n/**\n * Ember Eclipse: a burning eclipse drawn per pixel in one WebGL fragment shader.\n * Original HorizonX code, no libraries and no assets, so the editor and the\n * HTML/React/Svelte exports run the same file.\n *\n *   1. The fire of Ember Sun, unchanged: domain-warped flame tongues burn evenly\n *      round a torn, rippling rim, with heat haze, a white-hot rim line, bloom\n *      and embers drifting up. Ripples land on the rim at random angles.\n *   2. Inside, nothing: the disc is one flat colour (near-black by default)\n *      right up to a thin molten lip on the inside of the rim, like a moon\n *      covering the sun. The pointer never lights or changes it.\n *   3. The pointer leans the flames toward it, pulls the rim out and makes it\n *      flare under it, and drops ripples as it moves; the wheel makes the fire\n *      roar.\n */\n\nexport const DEFAULT_EMBER_ECLIPSE_CONFIG = {\n  viewportWidth: 1040,\n  viewportHeight: 620,\n  size: 0.3,\n  background: '#07080a',\n  disc: '#010102',\n  flames: 1,\n  embers: 1,\n  ripples: 1,\n  speed: 1,\n  animate: true,\n  interactive: true\n};\n\n// The eclipse's radius in shader units. The fire is drawn at a fixed size in\n// these units (flames reach 0.17), so the whole eclipse scales with `size`.\nconst R_UNITS = 0.42;\n\nconst VERT = 'attribute vec2 a; void main(){ gl_Position = vec4(a, 0.0, 1.0); }';\n\nconst FRAG = `\nprecision highp float;\nuniform vec2  uRes;\nuniform vec2  uArc;      // top of the rim, canvas px (y from bottom); the centre is uRadius below\nuniform float uUnit;     // canvas px per unit\nuniform float uRadius;   // disc radius in units\nuniform float uTime;\nuniform float uFlow;     // flame/ember time; runs faster while the wheel spins or the pointer moves\nuniform float uClock;    // wall clock for pointer ripples, so they fade even while paused\nuniform vec2  uMouse;    // pointer in units, same space as p\nuniform float uMouseOn;  // 0..1 pointer influence (fades when idle)\nuniform vec2  uMouseVel; // smoothed pointer velocity, units/s\nuniform vec3  uPR[4];    // pointer ripples: xy position, z start (uClock)\nuniform float uScrollVel;// 0..1.5 smoothed wheel speed\nuniform vec3  uBg;       // background, before the tone map\nuniform vec3  uDisc;     // the disc, before the tone map\nuniform float uFlames;   // flame height multiplier\nuniform float uEmbers;   // ember density, 0..2\nuniform float uRipples;  // ripple strength, 0..2\n\nconst float PI = 3.14159265;\n\nfloat hash(vec2 p){ p = fract(p * vec2(123.34, 456.21)); p += dot(p, p + 45.32); return fract(p.x * p.y); }\nfloat noise(vec2 p){\n  vec2 i = floor(p), f = fract(p);\n  vec2 u = f * f * (3.0 - 2.0 * f);\n  return mix(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), u.y);\n}\nfloat fbm(vec2 p){\n  float v = 0.0, a = 0.5;\n  mat2 m = mat2(1.6, 1.2, -1.2, 1.6);\n  for (int i = 0; i < 5; i++) { v += a * noise(p); p = m * p; a *= 0.5; }\n  return v;\n}\nvec3 fireRamp(float x){\n  x = clamp(x, 0.0, 1.0);\n  vec3 c = mix(vec3(0.0), vec3(0.38, 0.025, 0.0), smoothstep(0.0, 0.22, x));\n  c = mix(c, vec3(0.95, 0.2, 0.02), smoothstep(0.18, 0.5, x));\n  c = mix(c, vec3(1.0, 0.52, 0.12), smoothstep(0.48, 0.78, x));\n  c = mix(c, vec3(1.0, 0.9, 0.72), smoothstep(0.82, 1.0, x));\n  return c;\n}\n\n// Torn, rippling rim at arc position s = angle * radius\nfloat rimJag(float s, float t){\n  return (fbm(vec2(s * 7.0, t * 0.35)) - 0.5) * 0.026\n       + (noise(vec2(s * 40.0, t * 1.5)) - 0.5) * 0.006;\n}\n// Flame tongues at arc position s: x = noise, yz = domain warp\nvec3 flameField(float s, float h, float lean, float fl){\n  vec2 fp = vec2(s * 3.6 - lean * max(h, 0.0) * 3.6 * 2.4, h * 2.6 - fl * 0.9);\n  vec2 warp = vec2(fbm(fp * 1.25 + vec2(0.0, fl * 0.18)), fbm(fp * 1.25 + vec2(3.7, -fl * 0.14)));\n  float n = fbm(fp * 2.2 + warp * 1.8 - vec2(0.0, fl * 0.6));\n  return vec3(n, warp);\n}\nfloat lavaField(float s, float h, vec2 warp, float t){\n  return fbm(vec2(s * 4.0, h * 5.0 + t * 0.22) + warp);\n}\n\nvoid main(){\n  vec2 p0 = (gl_FragCoord.xy - uArc) / uUnit;  // top of the rim = origin\n  vec2 p = p0;\n  float t = uTime;\n  float fl = uFlow;\n  vec2 centre = vec2(0.0, -uRadius);\n\n  // Pointer influence (broad field and a tight core)\n  vec2 dm = p0 - uMouse;\n  float md2 = dot(dm, dm);\n  float near = exp(-md2 * 9.0) * uMouseOn;\n  float core = exp(-md2 * 70.0) * uMouseOn;\n\n  /* 1. Ripple impulses dropped on the rim at seeded angles */\n  vec2 disp = vec2(0.0);\n  float rippleLight = 0.0;\n  for (int i = 0; i < 4; i++) {\n    float fi = float(i);\n    float period = 4.6 + fi * 0.9;\n    float ph = t / period + fi * 0.31;\n    float cyc = floor(ph);\n    float age = fract(ph);\n    float a = hash(vec2(cyc, fi + 1.7)) * 2.0 * PI;\n    float rr = uRadius + (hash(vec2(fi + 4.1, cyc)) - 0.35) * 0.3;\n    vec2 c = centre + rr * vec2(sin(a), cos(a));\n    vec2 dv = p - c;\n    float d = length(dv);\n    float band = d - age * 0.75;\n    float w = sin(band * 52.0) * exp(-band * band * 140.0) * (1.0 - age) * (1.0 - age) * uRipples;\n    disp += dv / (d + 1e-3) * w * 0.011;\n    rippleLight += abs(w) * (1.0 - age);\n  }\n  // Ripples dropped by the pointer as it moves\n  for (int i = 0; i < 4; i++) {\n    vec3 r = uPR[i];\n    float age = (uClock - r.z) / 1.5;\n    if (age > 0.0 && age < 1.0) {\n      vec2 dv = p0 - r.xy;\n      float d = length(dv);\n      float band = d - age * 0.55;\n      float w = sin(band * 46.0) * exp(-band * band * 150.0) * (1.0 - age) * (1.0 - age) * uRipples;\n      disp += dv / (d + 1e-3) * w * 0.017;\n      rippleLight += abs(w) * (1.0 - age) * 1.6;\n    }\n  }\n\n  float flameH = 0.17 * uFlames * (1.0 + 0.9 * near + 0.5 * min(uScrollVel, 1.0));\n\n  /* 2. Rising heat haze, only near the fire (beyond it, it would only nudge the faint glow) */\n  vec2 q = p + disp;\n  bool fire = length(q - centre) - uRadius - 0.05 * exp(-md2 * 6.0) * uMouseOn < flameH * 1.18 + 0.05;\n  if (fire) {\n    vec2 hz = vec2(fbm(p * 3.2 + vec2(0.0, -t * 0.7)),\n                   fbm(p * 3.2 + vec2(5.2, -t * 0.7 + 1.3))) - 0.5;\n    q += hz * 0.012 * (1.0 + uScrollVel * 1.4 + near * 1.6);\n  }\n\n  /* 3. The burning rim */\n  vec2 rel = q - centre;\n  float dist = length(rel);\n  float ang = atan(rel.x, rel.y);              // 0 at the top, ±PI at the bottom\n  float h = dist - uRadius;                    // > 0 outside the disc\n  h -= 0.05 * exp(-md2 * 6.0) * uMouseOn;      // rim is pulled toward the pointer\n\n  // The angle jumps from +PI to -PI at the bottom; blend both sides of that seam\n  // and restore the noise contrast the average would flatten.\n  float s = ang * uRadius;\n  float s2 = s - sign(ang) * 2.0 * PI * uRadius;\n  float seam = 0.5 * smoothstep(PI - 0.45, PI, abs(ang));\n  float keep = inversesqrt((1.0 - seam) * (1.0 - seam) + seam * seam);\n\n  if (fire) {\n    float jag = rimJag(s, t);\n    if (seam > 0.0) jag = mix(jag, rimJag(s2, t), seam) * keep;\n    h += jag;\n  }\n\n  // Flames lean toward the pointer and with its motion, along the rim; higher parts bend more.\n  // The flame noise only shows between the disc's edge (h = -0.03, the disc covers everything\n  // below) and 1.18 flame heights out, where no tongue can reach.\n  vec2 tng = vec2(cos(ang), -sin(ang));\n  float lean = clamp(dot(uMouse - p0, tng) * 2.2 * near + dot(uMouseVel, tng) * 0.45 * exp(-md2 * 3.0) * uMouseOn, -1.4, 1.4);\n  vec3 ff = vec3(0.0);\n  if (h > -0.03 && h < flameH * 1.18) {\n    ff = flameField(s, h, lean, fl);\n    if (seam > 0.0) {\n      vec3 ff2 = flameField(s2, h, lean, fl);\n      ff = vec3(0.5 + (mix(ff.x, ff2.x, seam) - 0.5) * keep, mix(ff.yz, ff2.yz, seam));\n    }\n  }\n  float n = ff.x;\n  vec2 warp = ff.yz;\n\n  float heat = 0.0;\n  if (h > 0.0) {\n    // Thresholded noise gives separate tongues instead of a uniform haze\n    float tongue = n * 1.15 - h / flameH * 0.85 - 0.12;\n    heat = smoothstep(0.0, 0.75, tongue) * 1.05;\n    heat += exp(-h * 38.0) * 0.3;                 // hot base hugging the rim\n  } else {\n    float lava = 0.0;\n    if (h > -0.03) {\n      lava = lavaField(s, h, warp, t);\n      if (seam > 0.0) lava = mix(lava, lavaField(s2, h, warp, t), seam);\n    }\n    heat = exp(h * 48.0) * 0.8 + exp(h * 7.0) * lava * 0.18;\n  }\n  heat += exp(-abs(h) * 260.0) * 0.6;              // white-hot rim line\n  heat += exp(-md2 * 26.0) * exp(-abs(h) * 9.0) * 0.45 * uMouseOn;   // rim flares under the pointer\n  heat *= 0.9;\n\n  vec3 col = uBg;\n  col += fireRamp(heat);\n\n  // Soft atmospheric bloom around the eclipse\n  if (h > 0.0) col += vec3(1.0, 0.3, 0.05) * 0.16 * exp(-h * 4.5);\n  // Warm torchlight around the pointer\n  col += vec3(1.0, 0.36, 0.07) * (core * 0.05 + near * 0.025);\n  // The disc: one flat colour right up to a thin molten lip on the inside of the torn rim, so the\n  // edge burns exactly like the sun's while nothing of the inside shows.\n  float moon = smoothstep(-0.006, -0.03, h);\n  col = mix(col, uDisc, moon);\n\n  /* 4. Embers drifting up from the rim */\n  for (int k = 0; k < 2; k++) {\n    float fk = float(k);\n    float sc = 13.0 + fk * 10.0;\n    // embers are pushed away from the pointer and rise faster while the wheel spins\n    vec2 pe = p - dm / (sqrt(md2) + 0.05) * near * 0.04;\n    vec2 sp = pe * sc + vec2(fk * 3.1, -fl * (1.2 + fk * 0.7));\n    vec2 id = floor(sp);\n    vec2 gv = fract(sp) - 0.5;\n    float rnd = hash(id + fk * 13.0);\n    vec2 off = (vec2(hash(id + 1.3), hash(id + 7.1)) - 0.5) * 0.6\n             + vec2(sin(t * 1.7 + rnd * 6.28) * 0.18, 0.0);\n    float sp2 = smoothstep(0.07 - fk * 0.02, 0.0, length(gv - off)) * step(1.0 - 0.13 * uEmbers, rnd);\n    sp2 *= 0.55 + 0.45 * sin(t * 7.0 + rnd * 40.0);\n    float mask = smoothstep(0.5 * uFlames, 0.02, h) * step(0.0, h);\n    col += vec3(1.0, 0.55, 0.18) * sp2 * mask * 1.3;\n  }\n\n  // Ripple rings catch the firelight near the rim (not on the disc)\n  col += vec3(1.0, 0.45, 0.12) * rippleLight * 0.12 * exp(-abs(h) * 6.0) * (1.0 - moon);\n\n  col += (hash(gl_FragCoord.xy + fract(t) * 100.0) - 0.5) * 0.016 * (1.0 - moon * 0.75);   // film grain, faint on the disc\n  col = max(col, 0.0);\n  col = col / (1.0 + col * 0.1);\n  gl_FragColor = vec4(col, 1.0);\n}`;\n\nconst UNIFORMS = ['uRes', 'uArc', 'uUnit', 'uRadius', 'uTime', 'uFlow', 'uClock', 'uMouse', 'uMouseOn', 'uMouseVel',\n  'uPR', 'uScrollVel', 'uBg', 'uDisc', 'uFlames', 'uEmbers', 'uRipples'];\n\nfunction hexToRgb(hex) {\n  const n = parseInt(String(hex).slice(1, 7), 16) || 0;\n  return [(n >> 16 & 255) / 255, (n >> 8 & 255) / 255, (n & 255) / 255];\n}\n\nconst ease = (cur, target, dt, rate) => cur + (target - cur) * (1 - Math.exp(-dt * rate));\n// The shader tone-maps col / (1 + 0.1 col); colours go in through the inverse so the stage and\n// the disc show exactly the chosen colour.\nconst untoned = (hex) => hexToRgb(hex).map((c) => c / (1 - 0.1 * c));\n\n/**\n * Mounts the eclipse into `root` (the element holding `.eec-stage` and\n * `.eec-status`). Returns an idempotent disposer with update(config); updates\n * keep the GPU context.\n */\nexport function buildEmberEclipse(root, config) {\n  let disposed = false;\n  let values = { ...DEFAULT_EMBER_ECLIPSE_CONFIG, ...config };\n  const stage = root.querySelector('.eec-stage');\n  const status = root.querySelector('.eec-status');\n  root.removeAttribute('data-ready');\n  root.removeAttribute('data-fallback');\n  if (status) status.textContent = '';\n\n  const canvas = document.createElement('canvas');\n  // Inline styles survive Svelte scoping.\n  Object.assign(canvas.style, { position: 'absolute', inset: '0', width: '100%', height: '100%', display: 'block' });\n  canvas.setAttribute('role', 'img');\n  canvas.setAttribute('aria-label', 'A burning eclipse: a dark disc ringed by fire.');\n  stage?.append(canvas);\n\n  let gl = null;\n  try {\n    gl = stage ? canvas.getContext('webgl', { antialias: false, alpha: false, premultipliedAlpha: false, powerPreference: 'high-performance' }) : null;\n  } catch {\n    gl = null;\n  }\n\n  let ok = false, u = null;\n  const fail = () => {\n    ok = false;\n    canvas.style.display = 'none';\n    root.removeAttribute('data-ready');\n    root.setAttribute('data-fallback', '');\n    if (status) status.textContent = 'The eclipse needs WebGL. Enable hardware acceleration and reload to see it.';\n  };\n\n  const init = () => {\n    const sh = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return s; };\n    const vs = sh(gl.VERTEX_SHADER, VERT);\n    const fs = sh(gl.FRAGMENT_SHADER, FRAG);\n    const prog = gl.createProgram();\n    gl.attachShader(prog, vs); gl.attachShader(prog, fs);\n    gl.bindAttribLocation(prog, 0, 'a');\n    gl.linkProgram(prog);\n    if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {\n      console.warn(gl.getShaderInfoLog(fs) || gl.getProgramInfoLog(prog));\n      fail();\n      return;\n    }\n    gl.useProgram(prog);\n    u = Object.fromEntries(UNIFORMS.map((n) => [n, gl.getUniformLocation(prog, n)]));\n    gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());\n    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n    gl.enableVertexAttribArray(0);\n    gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);\n    ok = true;\n    canvas.style.display = 'block';\n    root.removeAttribute('data-fallback');\n    if (status) status.textContent = '';\n  };\n  if (gl) init(); else fail();\n\n  const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)');\n  const listen = { passive: true };\n\n  /* Render resolution, in canvas px per css px. It starts at 1, climbs toward the screen's density (at most\n     1.5) while frames keep up, and steps down when they fall behind. A frame cap (a battery saver holding\n     the page at 30 fps) is told apart from real load because a smaller canvas does not speed it up, and\n     then the resolution is put back instead of blurring the fire for nothing. */\n  const MAX_SCALE = Math.min(window.devicePixelRatio || 1, 1.5), MIN_SCALE = 0.5;\n  let scale = Math.min(1, MAX_SCALE);\n  const pace = { avg: 16.7, n: 0, slow: 0, fast: 0, ceiling: MAX_SCALE, ceilingUntil: 0, probe: null, capUntil: 0, capWait: 30000 };\n  const tune = (ms, now) => {                          // true when the canvas has to be resized\n    if (++pace.n < 30) return false;                   // the first frames include the shader compile\n    pace.avg += (Math.min(ms, 100) - pace.avg) * 0.08;\n    if (pace.probe) {                                  // just stepped down: wait, then check it helped\n      if (pace.n - pace.probe.n < 45) return false;\n      const { scale: before, avg } = pace.probe;\n      pace.probe = null;\n      if (pace.avg > avg * 0.88) {                     // no faster: a frame cap, not load. Retry later, less often\n        scale = before; pace.capUntil = now + pace.capWait; pace.capWait = Math.min(pace.capWait * 2, 300000);\n        return true;\n      }\n    }\n    if (pace.avg > 25 && now > pace.capUntil) {        // under ~40 fps\n      pace.fast = 0;\n      if (++pace.slow > 20 && scale > MIN_SCALE) {\n        pace.probe = { scale, avg: pace.avg, n: pace.n };\n        pace.ceiling = scale; pace.ceilingUntil = now + 20000;\n        scale = Math.max(MIN_SCALE, scale * 0.85); pace.slow = 0;\n        return true;\n      }\n      return false;\n    }\n    pace.slow = Math.max(0, pace.slow - 1);\n    if (pace.avg < 18.5) {                             // keeping up with a 60 Hz screen, or faster\n      const up = Math.min(MAX_SCALE, scale * 1.1);\n      if (++pace.fast > 90 && up > scale + 0.01 && (now > pace.ceilingUntil || up < pace.ceiling)) {\n        scale = up; pace.fast = 0; return true;\n      }\n    } else pace.fast = 0;\n    return false;\n  };\n\n  // Geometry in css px: the radius is `size` of the stage's short side and the centre sits mid-stage.\n  const geo = { w: 1, h: 1, cx: 0, topYCss: 0, unitCss: 500, arcY: 0 };\n  const layout = () => {\n    const w = Math.max(1, root.clientWidth), h = Math.max(1, root.clientHeight);\n    canvas.width = Math.max(1, Math.round(w * scale));\n    canvas.height = Math.max(1, Math.round(h * scale));\n    const radiusCss = Math.min(w, h) * values.size;\n    const topYCss = h / 2 - radiusCss;\n    Object.assign(geo, { w, h, cx: w / 2, topYCss, unitCss: radiusCss / R_UNITS, arcY: (h - topYCss) * scale });\n  };\n\n  let colors = { bg: [0, 0, 0], disc: [0, 0, 0] };\n  const paint = () => { colors = { bg: untoned(values.background), disc: untoned(values.disc) }; };\n\n  let raf = 0, last = 0, visible = true;\n  let simTime = 8, flow = 8, clock = 0, demoClock = 0;\n\n  /* ---- Pointer: target in eclipse units, smoothed in the loop so the fire follows with fluid lag ---- */\n  const ptr = { tx: 0, ty: 0, x: 0, y: 0, on: 0, onT: 0, vx: 0, vy: 0, lastMove: -1e9, ex: 1e9, ey: 1e9, et: -1e9, ri: 0 };\n  const ripples = new Float32Array(12).fill(-100);\n  let lastRipple = -1e9, push = 0;\n  const scr = { v: 0 };\n  const live = () => ok && visible && !document.hidden && !reducedMotion.matches;\n  // Editor and gallery stages start without a cursor, so a stand-in one circles the rim until a real\n  // pointer arrives; the marker on the root retires it for good.\n  const demoing = () => (values.pointerless || values.autoDemo) && values.interactive && root.dataset.hxPointer !== 'real' && !reducedMotion.matches;\n\n  const aim = (ux, uy, tap) => {\n    ptr.tx = ux; ptr.ty = uy; ptr.onT = 1; ptr.lastMove = performance.now();\n    if (ptr.on < 0.05) { ptr.x = ux; ptr.y = uy; }             // no swoop in from the last position\n    const moved = Math.hypot(ux - ptr.ex, uy - ptr.ey);\n    if (tap || (moved > 0.07 && clock - ptr.et > 0.14)) {\n      ripples.set([ux, uy, clock], (ptr.ri++ % 4) * 3);\n      ptr.ex = ux; ptr.ey = uy; ptr.et = clock; lastRipple = clock;\n    }\n  };\n  const release = () => { ptr.onT = 0; };\n  const toUnits = (e) => {\n    const r = root.getBoundingClientRect();\n    const x = (e.clientX - r.left) * geo.w / (r.width || 1), y = (e.clientY - r.top) * geo.h / (r.height || 1);\n    return [(x - geo.cx) / geo.unitCss, (geo.topYCss - y) / geo.unitCss];\n  };\n  const onPointer = (e, tap) => {\n    if (e.isTrusted) root.dataset.hxPointer = 'real';\n    if (!values.interactive || !live()) return;\n    const [ux, uy] = toUnits(e);\n    aim(ux, uy, tap);\n    wake();\n  };\n  const onMove = (e) => onPointer(e, false);\n  const onDown = (e) => onPointer(e, true);\n  const onLeave = () => { release(); wake(); };\n  const onWheel = (e) => {\n    if (!values.interactive || !live()) return;\n    push += Math.abs(e.deltaY) * (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? window.innerHeight : 1);\n    wake();\n  };\n\n  const step = (dt) => {\n    if (demoing()) {\n      // a slow loop that rides just outside the rim, so the flames lean and flare as it passes\n      demoClock += dt;\n      const ph = demoClock * 0.55;\n      aim(R_UNITS * 1.15 * Math.sin(ph), -R_UNITS + R_UNITS * 1.15 * Math.cos(ph * 0.9 + 0.6), false);\n    }\n    if (performance.now() - ptr.lastMove > 2600) ptr.onT = 0;  // idle: hand control back to the autonomous fire\n    const px = ptr.x, py = ptr.y;\n    ptr.x = ease(ptr.x, ptr.tx, dt, 7); ptr.y = ease(ptr.y, ptr.ty, dt, 7);\n    ptr.on = ease(ptr.on, ptr.onT, dt, ptr.onT > ptr.on ? 5 : 1.6);\n    if (dt > 0) { ptr.vx = ease(ptr.vx, (ptr.x - px) / dt, dt, 6); ptr.vy = ease(ptr.vy, (ptr.y - py) / dt, dt, 6); }\n    const vel = dt > 0 ? Math.min(push / dt / (window.innerHeight || 800), 1.5) : 0;\n    push = 0;\n    scr.v = ease(scr.v, vel, dt, vel > scr.v ? 8 : 2.2);\n    if (values.animate) {\n      const sdt = dt * values.speed;\n      simTime += sdt;\n      flow += sdt * (1 + scr.v * 1.6 + Math.min(Math.hypot(ptr.vx, ptr.vy), 2) * 0.35 * ptr.on);\n    }\n    clock += dt;\n  };\n\n  const draw = () => {\n    if (!ok || gl.isContextLost()) return false;\n    gl.viewport(0, 0, canvas.width, canvas.height);\n    gl.uniform2f(u.uRes, canvas.width, canvas.height);\n    gl.uniform2f(u.uArc, canvas.width / 2, geo.arcY);\n    gl.uniform1f(u.uUnit, geo.unitCss * scale);\n    gl.uniform1f(u.uRadius, R_UNITS);\n    gl.uniform1f(u.uTime, simTime);\n    gl.uniform1f(u.uFlow, flow);\n    gl.uniform1f(u.uClock, clock);\n    gl.uniform2f(u.uMouse, ptr.x, ptr.y);\n    gl.uniform1f(u.uMouseOn, ptr.on);\n    gl.uniform2f(u.uMouseVel, ptr.vx, ptr.vy);\n    gl.uniform3fv(u.uPR, ripples);\n    gl.uniform1f(u.uScrollVel, scr.v);\n    gl.uniform3fv(u.uBg, colors.bg);\n    gl.uniform3fv(u.uDisc, colors.disc);\n    gl.uniform1f(u.uFlames, values.flames);\n    gl.uniform1f(u.uEmbers, values.embers);\n    gl.uniform1f(u.uRipples, values.ripples);\n    gl.drawArrays(gl.TRIANGLES, 0, 3);\n    root.setAttribute('data-ready', '');\n    return true;\n  };\n\n  // Keeps drawing while the fire plays, the pointer (real or stand-in) is active, or anything it set\n  // in motion is still settling; otherwise the last frame holds.\n  const busy = () => values.animate\n    || (values.interactive && (demoing() || ptr.onT > 0 || ptr.on > 0.002 || scr.v > 0.002 || clock - lastRipple < 1.5));\n\n  function frame(now) {\n    raf = 0;\n    if (disposed || !ok) return;\n    const ms = last ? now - last : 1000 / 60;\n    const run = live();\n    step(run ? Math.min(ms / 1000, 0.05) : 0);\n    // resize before drawing: resizing clears the canvas\n    if (run && tune(ms, now)) layout();\n    draw();\n    if (run && busy()) { last = now; raf = requestAnimationFrame(frame); }\n    else last = 0;\n  }\n  const wake = () => { if (!disposed && ok && !raf) raf = requestAnimationFrame(frame); };\n\n  const onLost = (e) => {\n    e.preventDefault();\n    if (raf) cancelAnimationFrame(raf);\n    raf = 0;\n    fail();\n  };\n  const onRestored = () => { if (disposed) return; init(); if (ok) { layout(); wake(); } };\n  canvas.addEventListener('webglcontextlost', onLost);\n  canvas.addEventListener('webglcontextrestored', onRestored);\n\n  root.addEventListener('pointermove', onMove, listen);\n  root.addEventListener('pointerdown', onDown, listen);\n  root.addEventListener('pointercancel', onLeave, listen);\n  root.addEventListener('pointerleave', onLeave, listen);\n  root.addEventListener('wheel', onWheel, listen);\n  reducedMotion.addEventListener?.('change', wake);\n  document.addEventListener('visibilitychange', wake);\n  // Redraw at once on resize: resizing clears the canvas.\n  const resize = typeof ResizeObserver === 'function' ? new ResizeObserver(() => { layout(); draw(); wake(); }) : null;\n  resize?.observe(root);\n  // Off-screen eclipses stop drawing.\n  const seen = typeof IntersectionObserver === 'function'\n    ? new IntersectionObserver((entries) => { visible = entries.some((e) => e.isIntersecting); wake(); })\n    : null;\n  seen?.observe(root);\n\n  paint(); layout(); wake();\n\n  const cleanup = () => {\n    if (disposed) return;\n    disposed = true;\n    if (raf) cancelAnimationFrame(raf);\n    raf = 0;\n    canvas.removeEventListener('webglcontextlost', onLost);\n    canvas.removeEventListener('webglcontextrestored', onRestored);\n    root.removeEventListener('pointermove', onMove);\n    root.removeEventListener('pointerdown', onDown);\n    root.removeEventListener('pointercancel', onLeave);\n    root.removeEventListener('pointerleave', onLeave);\n    root.removeEventListener('wheel', onWheel);\n    reducedMotion.removeEventListener?.('change', wake);\n    document.removeEventListener('visibilitychange', wake);\n    resize?.disconnect();\n    seen?.disconnect();\n    gl?.getExtension('WEBGL_lose_context')?.loseContext();\n    canvas.remove();\n    root.removeAttribute('data-ready');\n    root.removeAttribute('data-fallback');\n    if (status) status.textContent = '';\n  };\n  cleanup.update = (next) => {\n    if (disposed) return;\n    const size = values.size;\n    values = { ...values, ...next };\n    if (!values.interactive) release();\n    paint();\n    if (values.size !== size) layout();\n    wake();\n  };\n  return cleanup;\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/drops/ember-eclipse/ember-eclipse.engine.d.ts",
      "content": "// Types for ember-eclipse.engine.js (the engine itself is plain JavaScript).\nexport interface EmberEclipseConfig {\n  viewportWidth: number;\n  viewportHeight: number;\n  size: number;\n  background: string;\n  disc: string;\n  flames: number;\n  embers: number;\n  ripples: number;\n  speed: number;\n  animate: boolean;\n  interactive: boolean;\n}\n\nexport interface EmberEclipseHandle {\n  (): void;\n  update(next: Partial<EmberEclipseConfig>): void;\n}\n\nexport const DEFAULT_EMBER_ECLIPSE_CONFIG: EmberEclipseConfig;\nexport function buildEmberEclipse(root: HTMLElement, config: Partial<EmberEclipseConfig>): EmberEclipseHandle;\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "license": "HorizonX Drops License 1.0",
    "page": "https://horizonx.so/tools/ember-eclipse",
    "source": "https://horizonx.so"
  },
  "docs": "Ember Eclipse fills its parent, so give the parent a width and height. The full editor, presets and exports are at https://horizonx.so/tools/ember-eclipse",
  "categories": [
    "webgl",
    "orb"
  ],
  "type": "registry:component"
}