{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"motorised-mixing-desk-fader-with-led-meter-and-engraved-decibel-scale","type":"registry:component","title":"Motorised Mixing Desk Fader with LED Meter and Engraved Decibel Scale","description":"Vertical fader on a canvas: a moulded cap rides a slot beside a segmented LED meter, with a native range input underneath. Free React and HTML to copy.","dependencies":[],"files":[{"path":"components/we-inc/motorised-mixing-desk-fader-with-led-meter-and-engraved-decibel-scale.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// The strip this fader belongs to, and the stops the motor visits while nobody is touching it.\nconst channel = { number: \"04\", name: \"Lead vocal\" };\nconst automation = [75, 44, 88, 60];\n// Engraved scale: `p` is how far up the slot the mark sits (0 bottom, 1 top), `db` the gain there.\nconst marks = [\n  { label: \"+10\", db: 10, p: 1 },\n  { label: \"+5\", db: 5, p: 0.875 },\n  { label: \"0\", db: 0, p: 0.75 },\n  { label: \"5\", db: -5, p: 0.625 },\n  { label: \"10\", db: -10, p: 0.5 },\n  { label: \"20\", db: -20, p: 0.37 },\n  { label: \"30\", db: -30, p: 0.25 },\n  { label: \"40\", db: -40, p: 0.15 },\n  { label: \"60\", db: -60, p: 0.06 },\n  { label: \"∞\", db: -96, p: 0 },\n];\nconst CAP = \"#e9e1cd\"; // the moulded cap\nconst INDEX = \"#e23d2b\"; // painted line across the cap and the unity mark\nconst LEDS = 24;\nconst W = 320, H = 580; // canvas size in CSS pixels\n\nconst dbAt = (p: number) => {\n  for (let i = 0; i < marks.length - 1; i++) {\n    const a = marks[i], b = marks[i + 1];\n    if (p <= a.p && p >= b.p) return b.db + ((p - b.p) / (a.p - b.p)) * (a.db - b.db);\n  }\n  return marks[0].db;\n};\nconst readout = (value: number) => {\n  if (value <= 0) return \"Off\";\n  const db = dbAt(value / 100);\n  return `${db > 0.05 ? \"+\" : db < -0.05 ? \"-\" : \"\"}${Math.abs(db).toFixed(1)} dB`;\n};\n\nexport default function MotorisedMixingDeskFader() {\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const hit = useRef<HTMLDivElement>(null);\n  const [value, setValue] = useState(automation[0]);\n  const api = useRef<{ set: (v: number) => void } | null>(null);\n\n  useEffect(() => {\n    const cv = canvas.current, pad = hit.current;\n    if (!cv || !pad) return;\n    const ctx = cv.getContext(\"2d\");\n    if (!ctx) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const dpr = Math.min(2, window.devicePixelRatio || 1) * 1.15;\n    cv.width = W * dpr; cv.height = H * dpr;\n    const SX = 178, LX = 104, Y0 = 478, Y1 = 104, TR = Y0 - Y1, CW = 52, CH = 82, LIFT = 8;\n    const PX = 34, PY = 8, PW = 252, PH = 564;\n\n    const rr = (c: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) => {\n      c.beginPath(); c.moveTo(x + r, y); c.arcTo(x + w, y, x + w, y + h, r); c.arcTo(x + w, y + h, x, y + h, r); c.arcTo(x, y + h, x, y, r); c.arcTo(x, y, x + w, y, r); c.closePath();\n    };\n    let seed = 11;\n    const rand = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };\n\n    // Everything that never moves is painted once: plate, grain, screws, slot, scale, unlit meter.\n    const still = document.createElement(\"canvas\");\n    still.width = cv.width; still.height = cv.height;\n    const sc = still.getContext(\"2d\");\n    if (sc) {\n      sc.scale(dpr, dpr);\n      sc.save(); sc.shadowColor = \"rgba(0,0,0,0.7)\"; sc.shadowBlur = 26; sc.shadowOffsetY = 14 * dpr;\n      rr(sc, PX, PY, PW, PH, 9); sc.fillStyle = \"#17181b\"; sc.fill(); sc.restore();\n      const body = sc.createLinearGradient(PX, 0, PX + PW, 0);\n      body.addColorStop(0, \"#2b2d31\"); body.addColorStop(0.18, \"#35373c\"); body.addColorStop(0.5, \"#2a2c30\"); body.addColorStop(0.82, \"#303236\"); body.addColorStop(1, \"#222427\");\n      rr(sc, PX, PY, PW, PH, 9); sc.fillStyle = body; sc.fill();\n      // Brushed grain runs the length of the strip.\n      sc.save(); rr(sc, PX, PY, PW, PH, 9); sc.clip();\n      for (let i = 0; i < 1500; i++) {\n        const x = PX + rand() * PW, y = PY - 40 + rand() * (PH + 40), len = 40 + rand() * 240, v = rand();\n        sc.fillStyle = v > 0.5 ? `rgba(255,255,255,${(v - 0.5) * 0.13})` : `rgba(0,0,0,${(0.5 - v) * 0.22})`;\n        sc.fillRect(x, y, 0.5, len);\n      }\n      // Brushed metal answers a lamp with broad bands across the grain.\n      for (const [y, h, a] of [[PY + 96, 150, 0.085], [PY + 372, 90, 0.045]]) {\n        const band = sc.createLinearGradient(0, y - h, 0, y + h);\n        band.addColorStop(0, \"rgba(255,255,255,0)\"); band.addColorStop(0.5, `rgba(235,240,255,${a})`); band.addColorStop(1, \"rgba(255,255,255,0)\");\n        sc.fillStyle = band; sc.fillRect(PX, y - h, PW, h * 2);\n      }\n      const fall = sc.createLinearGradient(0, PY, 0, PY + PH);\n      fall.addColorStop(0, \"rgba(255,255,255,0.07)\"); fall.addColorStop(0.3, \"rgba(255,255,255,0)\"); fall.addColorStop(1, \"rgba(0,0,0,0.3)\");\n      sc.fillStyle = fall; sc.fillRect(PX, PY, PW, PH);\n      sc.restore();\n      const lip = sc.createLinearGradient(0, PY, 0, PY + PH);\n      lip.addColorStop(0, \"rgba(255,255,255,0.5)\"); lip.addColorStop(0.06, \"rgba(255,255,255,0.12)\"); lip.addColorStop(0.9, \"rgba(0,0,0,0.3)\"); lip.addColorStop(1, \"rgba(0,0,0,0.75)\");\n      rr(sc, PX + 0.6, PY + 0.6, PW - 1.2, PH - 1.2, 8.5); sc.lineWidth = 1.2; sc.strokeStyle = lip; sc.stroke();\n\n      // Socket screws in the corners.\n      for (const [x, y] of [[PX + 17, PY + 17], [PX + PW - 17, PY + 17], [PX + 17, PY + PH - 17], [PX + PW - 17, PY + PH - 17]]) {\n        sc.beginPath(); sc.arc(x, y + 1, 7.4, 0, Math.PI * 2); sc.fillStyle = \"rgba(0,0,0,0.55)\"; sc.fill();\n        const g = sc.createLinearGradient(x - 6, y - 6, x + 6, y + 6);\n        g.addColorStop(0, \"#9a9da3\"); g.addColorStop(0.45, \"#4b4d52\"); g.addColorStop(1, \"#1c1d20\");\n        sc.beginPath(); sc.arc(x, y, 6.4, 0, Math.PI * 2); sc.fillStyle = g; sc.fill();\n        sc.beginPath(); sc.arc(x, y, 5.2, 0, Math.PI * 2); sc.strokeStyle = \"rgba(255,255,255,0.22)\"; sc.lineWidth = 0.6; sc.stroke();\n        sc.beginPath();\n        for (let k = 0; k < 6; k++) { const a = (k / 6) * Math.PI * 2 + x * 0.3; sc.lineTo(x + Math.cos(a) * 3, y + Math.sin(a) * 3); }\n        sc.closePath(); sc.fillStyle = \"#08080a\"; sc.fill(); sc.strokeStyle = \"rgba(255,255,255,0.18)\"; sc.lineWidth = 0.5; sc.stroke();\n      }\n\n      // Engraving: a dark cut with a paint fill sitting a fraction lower.\n      const engrave = (text: string, x: number, y: number, font: string, colour: string, align: CanvasTextAlign) => {\n        sc.font = font; sc.textAlign = align; sc.textBaseline = \"middle\";\n        sc.fillStyle = \"rgba(0,0,0,0.75)\"; sc.fillText(text, x, y - 0.8);\n        sc.fillStyle = colour; sc.fillText(text, x, y);\n      };\n      const mono = \"ui-monospace, SFMono-Regular, Menlo, monospace\";\n      engrave(channel.number, PX + PW / 2, PY + 24, `700 15px ${mono}`, \"rgba(240,238,232,0.9)\", \"center\");\n      engrave(channel.name.toUpperCase(), PX + PW / 2, PY + PH - 20, `600 9px ${mono}`, \"rgba(240,238,232,0.55)\", \"center\");\n      engrave(\"dB\", SX + 62, Y1 - 34, `600 8px ${mono}`, \"rgba(240,238,232,0.45)\", \"center\");\n      marks.forEach((m, i) => {\n        const y = Y0 - m.p * TR, unity = m.db === 0;\n        sc.fillStyle = \"rgba(0,0,0,0.7)\"; sc.fillRect(SX + 26, y - 1.5, unity ? 22 : 14, 1.6);\n        sc.fillStyle = unity ? INDEX : \"rgba(240,238,232,0.85)\"; sc.fillRect(SX + 26, y - 0.8, unity ? 22 : 14, 1.6);\n        engrave(m.label, SX + 76, y, `${unity ? 700 : 600} ${m.label === \"∞\" ? 15 : 11}px ${mono}`, unity ? \"#ff6a55\" : \"rgba(240,238,232,0.8)\", \"right\");\n        const next = marks[i + 1];\n        if (next) for (let k = 1; k < 4; k++) {\n          const yy = y + ((m.p - next.p) * TR * k) / 4;\n          sc.fillStyle = \"rgba(240,238,232,0.3)\"; sc.fillRect(SX + 26, yy - 0.5, 7, 1);\n        }\n      });\n\n      // The slot the cap rides in: a dark cut with a bright lower lip.\n      const slot = (x: number, y: number, w: number, h: number, r: number) => {\n        rr(sc, x - 1, y - 1, w + 2, h + 2.6, r + 1); sc.fillStyle = \"rgba(255,255,255,0.16)\"; sc.fill();\n        rr(sc, x - 1, y - 1.6, w + 2, h + 2, r + 1); sc.fillStyle = \"rgba(0,0,0,0.6)\"; sc.fill();\n        rr(sc, x, y, w, h, r); sc.fillStyle = \"#040405\"; sc.fill();\n      };\n      slot(SX - 3.5, Y1 - 50, 7, TR + 100, 3.5);\n      const dust = sc.createLinearGradient(SX - 3.5, 0, SX + 3.5, 0);\n      dust.addColorStop(0, \"rgba(255,255,255,0)\"); dust.addColorStop(0.75, \"rgba(255,255,255,0.09)\"); dust.addColorStop(1, \"rgba(255,255,255,0)\");\n      rr(sc, SX - 3.5, Y1 - 50, 7, TR + 100, 3.5); sc.fillStyle = dust; sc.fill();\n      slot(LX - 13, Y1 - 12, 26, TR + 24, 4);\n    }\n\n    const ledColour = (i: number) => (i >= LEDS - 3 ? [255, 70, 52] : i >= LEDS - 9 ? [255, 190, 40] : [52, 226, 122]);\n    const s = { p: automation[0] / 100, v: 0, target: automation[0] / 100, drag: false, grab: 0, level: 0, peak: 0, peakAt: 0, lx: -0.4 };\n\n    const draw = (t: number) => {\n      ctx.setTransform(1, 0, 0, 1, 0, 0);\n      ctx.clearRect(0, 0, cv.width, cv.height);\n      ctx.drawImage(still, 0, 0);\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      const pitch = TR / LEDS, lit = s.level * LEDS, peakI = Math.min(LEDS - 1, Math.floor(s.peak * LEDS - 0.01));\n\n      // Meter: every segment is a little tinted window; the lit ones glow and spill onto the plate.\n      for (let i = 0; i < LEDS; i++) {\n        const [r, g, b] = ledColour(i), y = Y0 - (i + 0.5) * pitch;\n        let on = Math.max(0, Math.min(1, lit - i));\n        if (i === peakI && s.peak > 0.02) on = Math.max(on, 0.9);\n        rr(ctx, LX - 9, y - 5.2, 18, 10.4, 2);\n        ctx.fillStyle = `rgb(${(r * 0.13) | 0},${(g * 0.13) | 0},${(b * 0.13) | 0})`; ctx.fill();\n        if (on > 0.01) {\n          ctx.save(); ctx.globalAlpha = on; ctx.shadowColor = `rgb(${r},${g},${b})`; ctx.shadowBlur = 14 * dpr;\n          rr(ctx, LX - 9, y - 5.2, 18, 10.4, 2); ctx.fillStyle = `rgb(${r},${g},${b})`; ctx.fill(); ctx.restore();\n          const core = ctx.createLinearGradient(0, y - 5, 0, y + 5);\n          core.addColorStop(0, `rgba(255,255,255,${0.75 * on})`); core.addColorStop(0.5, `rgba(255,255,255,${0.25 * on})`); core.addColorStop(1, \"rgba(255,255,255,0)\");\n          rr(ctx, LX - 7, y - 4, 14, 8, 1.5); ctx.fillStyle = core; ctx.fill();\n          ctx.save(); ctx.globalCompositeOperation = \"lighter\";\n          const spill = ctx.createRadialGradient(LX, y, 4, LX, y, 46);\n          spill.addColorStop(0, `rgba(${r},${g},${b},${0.11 * on})`); spill.addColorStop(1, `rgba(${r},${g},${b},0)`);\n          ctx.fillStyle = spill; ctx.fillRect(LX - 46, y - 46, 92, 92); ctx.restore();\n        }\n        ctx.fillStyle = `rgba(255,255,255,${0.1 + 0.2 * on})`; ctx.fillRect(LX - 7.5, y - 4.4, 15, 0.9);\n      }\n\n      // The cap.\n      const cy = Y0 - s.p * TR, x0 = SX - CW / 2, y0 = cy - CH / 2;\n      ctx.save(); ctx.shadowColor = \"rgba(0,0,0,0.6)\"; ctx.shadowBlur = 22 * dpr; ctx.shadowOffsetX = 9 * dpr; ctx.shadowOffsetY = 20 * dpr;\n      rr(ctx, x0 + 3, y0 + 8, CW - 6, CH - 6, 6); ctx.fillStyle = \"#000\"; ctx.fill(); ctx.restore();\n      ctx.save(); ctx.shadowColor = \"rgba(0,0,0,0.85)\"; ctx.shadowBlur = 5 * dpr; ctx.shadowOffsetX = 1.5 * dpr; ctx.shadowOffsetY = 4 * dpr;\n      rr(ctx, x0, y0 + LIFT, CW, CH, 6); ctx.fillStyle = \"#000\"; ctx.fill(); ctx.restore();\n      // The cap stands off the plate: its lower wall shows under the face.\n      const skirt = ctx.createLinearGradient(x0, 0, x0 + CW, 0);\n      skirt.addColorStop(0, \"#8d846d\"); skirt.addColorStop(0.12, \"#b4ab93\"); skirt.addColorStop(0.5, \"#9a917a\"); skirt.addColorStop(0.9, \"#756d59\"); skirt.addColorStop(1, \"#4f4939\");\n      rr(ctx, x0, y0 + LIFT, CW, CH, 6); ctx.fillStyle = skirt; ctx.fill();\n      const under = ctx.createLinearGradient(0, y0 + CH - 4, 0, y0 + CH + LIFT);\n      under.addColorStop(0, \"rgba(40,30,10,0.05)\"); under.addColorStop(1, \"rgba(30,22,8,0.5)\");\n      rr(ctx, x0, y0 + LIFT, CW, CH, 6); ctx.fillStyle = under; ctx.fill();\n\n      // A skirt, two sloped shoulders and a finger dish: light comes from above, so the upper wall of the dish is in shade.\n      const prof = ctx.createLinearGradient(0, y0, 0, y0 + CH);\n      const stops: [number, string][] = [[0, \"#fffdf6\"], [0.035, \"#f6efdd\"], [0.1, \"#e9e1cd\"], [0.24, \"#d8cfb9\"], [0.3, \"#b5ab93\"], [0.4, \"#bfb59e\"], [0.485, \"#cfc6b0\"], [0.515, \"#d6cdb8\"], [0.62, \"#efe8d6\"], [0.71, \"#fbf6e8\"], [0.78, \"#e6decb\"], [0.9, \"#cdc4ad\"], [0.965, \"#b0a68e\"], [1, \"#857c68\"]];\n      for (const [p, c] of stops) prof.addColorStop(p, c);\n      rr(ctx, x0, y0, CW, CH, 6); ctx.fillStyle = prof; ctx.fill();\n      ctx.save(); rr(ctx, x0, y0, CW, CH, 6); ctx.clip();\n      const side = ctx.createLinearGradient(x0, 0, x0 + CW, 0);\n      side.addColorStop(0, \"rgba(255,255,255,0.55)\"); side.addColorStop(0.07, \"rgba(255,255,255,0.1)\"); side.addColorStop(0.16, \"rgba(255,255,255,0)\"); side.addColorStop(0.8, \"rgba(0,0,0,0)\"); side.addColorStop(0.94, \"rgba(60,40,10,0.22)\"); side.addColorStop(1, \"rgba(40,25,5,0.5)\");\n      ctx.fillStyle = side; ctx.fillRect(x0, y0, CW, CH);\n      // Grip ribs on both shoulders.\n      for (const base of [y0 + 7, y0 + CH - 19]) for (let k = 0; k < 3; k++) {\n        const y = base + k * 4.4;\n        ctx.fillStyle = \"rgba(70,55,25,0.34)\"; ctx.fillRect(x0 + 5, y, CW - 10, 1.3);\n        ctx.fillStyle = \"rgba(255,255,255,0.7)\"; ctx.fillRect(x0 + 5, y + 1.3, CW - 10, 0.9);\n      }\n      // The painted index line sits in a groove.\n      ctx.fillStyle = \"rgba(60,20,10,0.55)\"; ctx.fillRect(x0, cy - 2.2, CW, 4.4);\n      ctx.fillStyle = INDEX; ctx.fillRect(x0, cy - 1.5, CW, 3);\n      ctx.fillStyle = \"rgba(255,255,255,0.35)\"; ctx.fillRect(x0, cy + 0.6, CW, 0.7);\n      // A soft window reflection on the lower wall of the dish. It slides as the light moves.\n      const hx = SX + s.lx * 16;\n      const spec = ctx.createRadialGradient(hx, cy + CH * 0.19, 0, hx, cy + CH * 0.19, 22);\n      spec.addColorStop(0, \"rgba(255,255,255,0.85)\"); spec.addColorStop(0.4, \"rgba(255,255,255,0.25)\"); spec.addColorStop(1, \"rgba(255,255,255,0)\");\n      ctx.save(); ctx.translate(0, cy + CH * 0.19); ctx.scale(1, 0.3); ctx.translate(0, -(cy + CH * 0.19)); ctx.fillStyle = spec; ctx.fillRect(x0, cy - 60, CW, 160); ctx.restore();\n      // The meter tints the side of the cap that faces it.\n      const near = Math.max(0, Math.min(1, (s.level - s.p) * 7 + 0.5));\n      if (near > 0.01) {\n        const [r, g, b] = ledColour(Math.min(LEDS - 1, Math.floor(s.p * LEDS)));\n        const tint = ctx.createLinearGradient(x0, 0, x0 + 20, 0);\n        tint.addColorStop(0, `rgba(${r},${g},${b},${0.5 * near})`); tint.addColorStop(1, `rgba(${r},${g},${b},0)`);\n        ctx.globalCompositeOperation = \"multiply\"; ctx.fillStyle = tint; ctx.fillRect(x0, y0, 20, CH);\n        ctx.globalCompositeOperation = \"source-over\";\n      }\n      ctx.restore();\n      rr(ctx, x0 + 0.4, y0 + 0.4, CW - 0.8, CH - 0.8, 5.6); ctx.lineWidth = 0.8; ctx.strokeStyle = \"rgba(50,40,20,0.5)\"; ctx.stroke();\n      void t;\n    };\n\n    let raf = 0, last = 0, seen = true, touched = -1e9, t0 = 0, step = 0, nextDemo = 1000;\n    const push = (p: number) => { const v = Math.round(p * 100); setValue((old) => (old === v ? old : v)); };\n    const signal = (t: number) => {\n      const beat = Math.exp(-((t * 1.9) % 1) * 5.5) * 0.3;\n      return Math.max(0, Math.min(1, 0.56 + 0.16 * Math.sin(t * 2.3) + 0.1 * Math.sin(t * 5.9 + 1) + 0.07 * Math.sin(t * 13.1) + beat));\n    };\n    const frame = (now: number) => {\n      raf = 0;\n      if (!t0) { t0 = now; last = now; }\n      const dt = Math.min(0.033, (now - last) / 1000); last = now;\n      const t = (now - t0) / 1000;\n      if (now - touched > 5000 && !s.drag) {\n        s.lx += (-0.4 + 0.5 * Math.sin(t * 0.8) - s.lx) * Math.min(1, dt * 3);\n        if (t * 1000 > nextDemo) { step = (step + 1) % automation.length; s.target = automation[step] / 100; push(s.target); nextDemo = t * 1000 + 1500; }\n      }\n      // Held, the cap tracks the finger tightly. Driven by the motor, it glides.\n      const k = s.drag ? 900 : now - touched > 5000 ? 70 : 420, c = s.drag ? 52 : now - touched > 5000 ? 15 : 34;\n      s.v += (k * (s.target - s.p) - c * s.v) * dt; s.p += s.v * dt;\n      if (s.p > 1) { s.p = 1; s.v = 0; } if (s.p < 0) { s.p = 0; s.v = 0; }\n      const want = Math.min(1, s.p * (0.5 + 0.62 * signal(t)));\n      s.level += (want - s.level) * Math.min(1, dt * (want > s.level ? 30 : 5));\n      if (s.level >= s.peak) { s.peak = s.level; s.peakAt = t; } else if (t - s.peakAt > 0.7) s.peak = Math.max(s.level, s.peak - dt * 0.7);\n      draw(t);\n      if (seen && !document.hidden) raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!raf && !reduce) { last = performance.now(); raf = requestAnimationFrame(frame); } };\n    const settle = () => { s.p = s.target; s.v = 0; s.level = s.p * 0.86; s.peak = 0; draw(0); };\n\n    api.current = { set: (v) => { touched = performance.now(); s.target = v / 100; if (reduce) settle(); else wake(); } };\n    if (reduce) settle(); else wake();\n\n    const where = (e: PointerEvent) => { const b = pad.getBoundingClientRect(); return { x: ((e.clientX - b.left) / b.width) * 2 - 1, y: Y1 - 60 + ((e.clientY - b.top) / b.height) * (TR + 120) }; };\n    const toP = (y: number) => { let p = Math.max(0, Math.min(1, (Y0 - y) / TR)); if (Math.abs(p - 0.75) < 0.014) p = 0.75; return p; }; // a small notch at unity\n    const onDown = (e: PointerEvent) => {\n      const { y } = where(e), cy = Y0 - s.p * TR;\n      s.grab = Math.abs(y - cy) < CH / 2 ? y - cy : 0;\n      s.drag = true; touched = performance.now(); s.target = toP(y - s.grab); push(s.target);\n      pad.setPointerCapture(e.pointerId); e.preventDefault();\n      if (reduce) settle(); else wake();\n    };\n    const onMove = (e: PointerEvent) => {\n      const { x, y } = where(e);\n      s.lx += (x * 0.9 - s.lx) * 0.2;\n      if (!s.drag) { touched = Math.max(touched, performance.now() - 3600); if (reduce) draw(0); return; }\n      touched = performance.now(); s.target = toP(y - s.grab); push(s.target);\n      if (reduce) settle();\n    };\n    const onUp = () => { if (s.drag) { s.drag = false; touched = performance.now(); } };\n    pad.addEventListener(\"pointerdown\", onDown);\n    pad.addEventListener(\"pointermove\", onMove);\n    pad.addEventListener(\"pointerup\", onUp);\n    pad.addEventListener(\"pointercancel\", onUp);\n    const io = new IntersectionObserver(([entry]) => { seen = entry.isIntersecting; if (seen) wake(); });\n    io.observe(cv);\n    const onVis = () => { if (!document.hidden) wake(); };\n    document.addEventListener(\"visibilitychange\", onVis);\n    return () => {\n      cancelAnimationFrame(raf); api.current = null;\n      pad.removeEventListener(\"pointerdown\", onDown); pad.removeEventListener(\"pointermove\", onMove);\n      pad.removeEventListener(\"pointerup\", onUp); pad.removeEventListener(\"pointercancel\", onUp);\n      io.disconnect(); document.removeEventListener(\"visibilitychange\", onVis);\n    };\n  }, []);\n\n  return (\n    <div className=\"flex min-h-[700px] w-full flex-col items-center justify-center bg-[#0a0b0d] bg-[radial-gradient(110%_75%_at_50%_35%,#1c1e22_0%,#0a0b0d_64%)] px-4 py-10 sm:min-h-[780px]\">\n      <div className=\"relative h-[580px] w-[320px] sm:my-8 sm:scale-110\">\n        <input\n          id=\"motorised-fader-level\"\n          type=\"range\"\n          min={0}\n          max={100}\n          step={1}\n          value={value}\n          aria-label={`Channel ${channel.number} level, ${channel.name}`}\n          aria-valuetext={readout(value)}\n          onChange={(e) => { const v = Number(e.target.value); setValue(v); api.current?.set(v); }}\n          className=\"peer absolute left-1/2 top-1/2 h-10 w-10 -translate-x-1/2 opacity-0\"\n        />\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n        <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-x-[30px] inset-y-[4px] rounded-xl ring-[#ff6a55] ring-offset-4 ring-offset-[#0a0b0d] peer-focus-visible:ring-2\" />\n        <div ref={hit} aria-hidden=\"true\" className=\"absolute left-[132px] top-[44px] h-[494px] w-[92px] cursor-grab touch-none active:cursor-grabbing\" />\n      </div>\n      <p className=\"mt-6 text-center font-mono text-[11px] uppercase leading-5 tracking-[0.16em] text-zinc-400\">\n        <span className=\"text-zinc-200\">Ch {channel.number}</span>\n        <span className=\"mx-2 text-zinc-600\">/</span>\n        {channel.name}\n        <span className=\"mx-2 text-zinc-600\">/</span>\n        <output htmlFor=\"motorised-fader-level\" className=\"inline-block min-w-[72px] text-left text-zinc-100\">{readout(value)}</output>\n      </p>\n    </div>\n  );\n}\n"}]}
