{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"round-wall-thermostat-slider-with-a-turning-copper-bezel-and-a-glass-face-that-glows-from-blue-to-amber","type":"registry:component","title":"Round Wall Thermostat Slider with a Turning Copper Bezel and a Glass Face That Glows from Blue to Amber","description":"Thermostat slider on a canvas: turn the copper bezel past a fixed arrow and the glass face glows from blue to amber. Copy the React code or the HTML free.","dependencies":[],"files":[{"path":"components/we-inc/round-wall-thermostat-slider-with-a-turning-copper-bezel-and-a-glass-face-that-glows-from-blue-to-amber.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent as ReactKeyboardEvent } from \"react\";\n\n// Everything a visitor is likely to change sits here.\nconst MIN = 10; // lowest setting, in degrees\nconst MAX = 30; // highest setting\nconst STEP = 0.5; // one click of the bezel\nconst START = 21.5; // where it opens\nconst ROOM = 19.5; // the reading shown as \"room\"\nconst ROOM_NAME = \"Hallway\";\nconst PER_DEGREE = 13.5; // how far the bezel turns for one degree, in degrees of arc\n// The face colour from coldest to warmest. Each entry is [position 0..1, red, green, blue].\nconst HEAT: [number, number, number, number][] = [[0, 47, 125, 255], [0.34, 86, 190, 255], [0.5, 255, 232, 190], [0.7, 255, 170, 60], [1, 255, 74, 40]];\n\nconst SIZE = 400; // drawing units: the canvas is scaled to whatever box it is given\nconst clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, v));\nconst snap = (v: number) => clamp(Math.round(v / STEP) * STEP, MIN, MAX);\nconst heat = (v: number, a = 1) => {\n  const t = clamp((v - MIN) / (MAX - MIN), 0, 1);\n  let i = 0;\n  while (i < HEAT.length - 2 && t > HEAT[i + 1][0]) i++;\n  const p = HEAT[i], q = HEAT[i + 1], k = clamp((t - p[0]) / (q[0] - p[0]), 0, 1);\n  return `rgba(${(p[1] + (q[1] - p[1]) * k) | 0},${(p[2] + (q[2] - p[2]) * k) | 0},${(p[3] + (q[3] - p[3]) * k) | 0},${a})`;\n};\nconst verb = (v: number) => (v > ROOM + 0.2 ? \"Heating to\" : v < ROOM - 0.2 ? \"Cooling to\" : \"Holding at\");\n\nexport default function CopperBezelThermostat() {\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const hit = useRef<HTMLDivElement>(null);\n  const [value, setValue] = useState(START);\n  const valueRef = useRef(START);\n  const api = useRef<{ go: (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 px = 580 * Math.min(2, window.devicePixelRatio || 1); // sharp at its largest shown size\n    cv.width = px; cv.height = px;\n    const k = px / SIZE;\n    const C = SIZE / 2, OUT = 136, IN = 100, GLASS = 96;\n    const hasConic = typeof ctx.createConicGradient === \"function\";\n    const sans = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", \"Helvetica Neue\", Arial, sans-serif';\n\n    // Copper is a ramp from near black through red-brown to a pale pink highlight.\n    const ramp: [number, number, number, number][] = [[0, 34, 14, 8], [70, 104, 50, 28], [130, 168, 92, 56], [185, 214, 138, 96], [228, 244, 190, 152], [255, 255, 240, 226]];\n    const copper = (v: number) => {\n      const c = clamp(v, 0, 255);\n      let i = 0;\n      while (i < ramp.length - 2 && c > ramp[i + 1][0]) i++;\n      const p = ramp[i], q = ramp[i + 1], t = (c - p[0]) / (q[0] - p[0]);\n      return `rgb(${(p[1] + (q[1] - p[1]) * t) | 0},${(p[2] + (q[2] - p[2]) * t) | 0},${(p[3] + (q[3] - p[3]) * t) | 0})`;\n    };\n    const sheen = (angle: number, lo: number, hi: number) => {\n      if (!hasConic) { const g = ctx.createLinearGradient(C - OUT, C - OUT, C + OUT, C + OUT); g.addColorStop(0, copper(hi)); g.addColorStop(0.5, copper(lo)); g.addColorStop(1, copper(hi - 30)); return g; }\n      const g = ctx.createConicGradient(angle, C, C);\n      const mid = (lo + hi) / 2;\n      const stops: [number, number][] = [[0, hi], [0.035, hi - 10], [0.09, mid + 14], [0.17, lo + 8], [0.25, lo - 12], [0.33, mid - 18], [0.41, mid + 12], [0.47, hi - 34], [0.5, hi - 12], [0.535, hi - 40], [0.6, mid - 2], [0.69, lo - 6], [0.77, lo + 12], [0.85, mid - 10], [0.93, mid + 30], [0.975, hi - 8], [1, hi]];\n      for (const [p, v] of stops) g.addColorStop(p, copper(v));\n      return g;\n    };\n\n    // Circular brushing, painted once: it looks the same at every angle, so it never has to turn.\n    const brush = document.createElement(\"canvas\");\n    brush.width = px; brush.height = px;\n    const bx = brush.getContext(\"2d\");\n    if (bx) {\n      bx.scale(k, k);\n      let seed = 11;\n      const rand = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };\n      for (let r = IN; r < OUT; r += 0.4) {\n        const v = rand();\n        bx.beginPath(); bx.arc(C, C, r, 0, Math.PI * 2);\n        bx.lineWidth = 0.4 + rand() * 0.4;\n        bx.strokeStyle = v > 0.5 ? `rgba(255,236,220,${(v - 0.5) * 0.34})` : `rgba(40,12,0,${(0.5 - v) * 0.3})`;\n        bx.stroke();\n      }\n    }\n\n    const s = { v: START, vel: 0, target: START, raw: START, drag: false, light: -2.25, lightTo: -2.25, press: 0 };\n\n    const draw = () => {\n      ctx.setTransform(k, 0, 0, k, 0, 0);\n      ctx.clearRect(0, 0, SIZE, SIZE);\n      const turn = ((s.v - (MIN + MAX) / 2) * PER_DEGREE * Math.PI) / 180;\n      const la = s.light;\n\n      // Coloured light the face spills on the wall, then two shadows under the body.\n      const halo = ctx.createRadialGradient(C, C, OUT - 10, C, C, SIZE / 2);\n      halo.addColorStop(0, heat(s.v, 0.62)); halo.addColorStop(0.4, heat(s.v, 0.24)); halo.addColorStop(1, heat(s.v, 0));\n      ctx.fillStyle = halo; ctx.fillRect(0, 0, SIZE, SIZE);\n      ctx.save(); ctx.shadowColor = \"rgba(58,40,22,0.42)\"; ctx.shadowBlur = 46 * k; ctx.shadowOffsetX = 14 * k; ctx.shadowOffsetY = 34 * k;\n      ctx.beginPath(); ctx.arc(C, C, OUT - 4, 0, Math.PI * 2); ctx.fillStyle = \"#3a2a1c\"; ctx.fill(); ctx.restore();\n      ctx.save(); ctx.shadowColor = \"rgba(40,26,14,0.6)\"; ctx.shadowBlur = 9 * k; ctx.shadowOffsetX = 3 * k; ctx.shadowOffsetY = 6 * k;\n      ctx.beginPath(); ctx.arc(C, C, OUT + 4, 0, Math.PI * 2); ctx.fillStyle = \"#2a1c10\"; ctx.fill(); ctx.restore();\n      // The ivory base that screws to the wall. Only a thin edge of it shows, lit a little by the display.\n      const base = ctx.createLinearGradient(C - OUT, C - OUT, C + OUT, C + OUT);\n      base.addColorStop(0, \"#fffdf8\"); base.addColorStop(0.55, \"#e9e2d6\"); base.addColorStop(1, \"#a99f90\");\n      ctx.beginPath(); ctx.arc(C, C, OUT + 5, 0, Math.PI * 2); ctx.fillStyle = base; ctx.fill();\n      ctx.fillStyle = heat(s.v, 0.16); ctx.fill();\n      ctx.save(); ctx.beginPath(); ctx.arc(C, C, OUT + 5, 0, Math.PI * 2); ctx.clip();\n      ctx.shadowColor = \"rgba(30,14,4,0.85)\"; ctx.shadowBlur = 5 * k; ctx.shadowOffsetX = 1.5 * k; ctx.shadowOffsetY = 3.5 * k;\n      ctx.beginPath(); ctx.arc(C, C, OUT, 0, Math.PI * 2); ctx.fillStyle = \"#1a0c04\"; ctx.fill(); ctx.restore();\n\n      // The bezel: a rounded outer shoulder, the brushed flat that carries the scale, and a polished inner lip.\n      ctx.beginPath(); ctx.arc(C, C, OUT, 0, Math.PI * 2); ctx.fillStyle = sheen(la + 0.35, 24, 255); ctx.fill();\n      ctx.lineWidth = 0.7; ctx.strokeStyle = \"rgba(24,8,0,0.55)\"; ctx.stroke();\n      ctx.beginPath(); ctx.arc(C, C, OUT - 6, 0, Math.PI * 2); ctx.fillStyle = sheen(la, 66, 255); ctx.fill();\n      ctx.save(); ctx.beginPath(); ctx.arc(C, C, OUT - 6, 0, Math.PI * 2); ctx.clip();\n      ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.drawImage(brush, 0, 0); ctx.setTransform(k, 0, 0, k, 0, 0);\n      ctx.restore();\n      // The flat is very slightly crowned: darker at both edges.\n      const crown = ctx.createRadialGradient(C, C, IN, C, C, OUT - 6);\n      crown.addColorStop(0, \"rgba(30,8,0,0.34)\"); crown.addColorStop(0.22, \"rgba(30,8,0,0)\"); crown.addColorStop(0.8, \"rgba(30,8,0,0)\"); crown.addColorStop(1, \"rgba(30,8,0,0.3)\");\n      ctx.beginPath(); ctx.arc(C, C, OUT - 6, 0, Math.PI * 2); ctx.arc(C, C, IN, 0, Math.PI * 2, true); ctx.fillStyle = crown; ctx.fill(\"evenodd\");\n\n      // Engraved scale. It is cut into the ring, so it turns with it while the reflections above stay put.\n      ctx.save(); ctx.translate(C, C); ctx.rotate(turn);\n      ctx.textAlign = \"center\"; ctx.textBaseline = \"middle\"; ctx.font = `600 10px ${sans}`; ctx.lineCap = \"butt\";\n      for (let d = MIN; d <= MAX + 0.001; d += STEP) {\n        const whole = Math.abs(d - Math.round(d)) < 0.01, even = whole && Math.round(d) % 2 === 0;\n        ctx.save(); ctx.rotate((-(d - (MIN + MAX) / 2) * PER_DEGREE * Math.PI) / 180);\n        const y0 = -(IN + 5), y1 = y0 - (whole ? 6.5 : 3.5);\n        ctx.lineWidth = whole ? 1.3 : 0.9;\n        ctx.strokeStyle = \"rgba(255,238,224,0.5)\"; ctx.beginPath(); ctx.moveTo(0.7, y0 - 0.5); ctx.lineTo(0.7, y1 - 0.5); ctx.stroke();\n        ctx.strokeStyle = whole ? \"rgba(44,16,4,0.92)\" : \"rgba(44,16,4,0.6)\"; ctx.beginPath(); ctx.moveTo(0, y0); ctx.lineTo(0, y1); ctx.stroke();\n        if (even) {\n          ctx.fillStyle = \"rgba(255,238,224,0.5)\"; ctx.fillText(String(Math.round(d)), 0.5, -(IN + 19.9));\n          ctx.fillStyle = \"rgba(44,16,4,0.94)\"; ctx.fillText(String(Math.round(d)), 0, -(IN + 20.5));\n        }\n        ctx.restore();\n      }\n      ctx.restore();\n\n      // Bright rims where the shoulder and the lip catch the lamp.\n      const rim = ctx.createLinearGradient(C - OUT, C - OUT, C + OUT, C + OUT);\n      rim.addColorStop(0, \"rgba(255,244,232,0.95)\"); rim.addColorStop(0.45, \"rgba(255,244,232,0.08)\"); rim.addColorStop(1, \"rgba(30,8,0,0.6)\");\n      ctx.lineWidth = 1.1; ctx.strokeStyle = rim; ctx.beginPath(); ctx.arc(C, C, OUT - 6, 0, Math.PI * 2); ctx.stroke();\n      ctx.beginPath(); ctx.arc(C, C, IN + 1.5, 0, Math.PI * 2); ctx.arc(C, C, GLASS, 0, Math.PI * 2, true); ctx.fillStyle = sheen(la + Math.PI, 30, 255); ctx.fill(\"evenodd\");\n      ctx.lineWidth = 0.8; ctx.strokeStyle = \"rgba(20,6,0,0.7)\"; ctx.beginPath(); ctx.arc(C, C, IN + 1.5, 0, Math.PI * 2); ctx.stroke();\n\n      // Black glass.\n      const press = s.press;\n      const glass = ctx.createRadialGradient(C, C - 26, 8, C, C, GLASS);\n      glass.addColorStop(0, \"#1b1d21\"); glass.addColorStop(0.7, \"#0b0c0e\"); glass.addColorStop(1, \"#030304\");\n      ctx.beginPath(); ctx.arc(C, C, GLASS, 0, Math.PI * 2); ctx.fillStyle = glass; ctx.fill();\n      ctx.save(); ctx.beginPath(); ctx.arc(C, C, GLASS, 0, Math.PI * 2); ctx.clip();\n      // The lit display under the glass: a band of colour round the edge and a wash rising from below.\n      const band = ctx.createRadialGradient(C, C, GLASS - 34, C, C, GLASS);\n      band.addColorStop(0, heat(s.v, 0)); band.addColorStop(0.62, heat(s.v, 0.16 + press * 0.1)); band.addColorStop(0.9, heat(s.v, 0.74)); band.addColorStop(1, heat(s.v, 0.3));\n      ctx.fillStyle = band; ctx.fillRect(C - GLASS, C - GLASS, GLASS * 2, GLASS * 2);\n      const wash = ctx.createRadialGradient(C, C + GLASS * 0.9, 4, C, C + GLASS * 0.9, GLASS * 1.5);\n      wash.addColorStop(0, heat(s.v, 0.5)); wash.addColorStop(0.5, heat(s.v, 0.13)); wash.addColorStop(1, heat(s.v, 0));\n      ctx.fillStyle = wash; ctx.fillRect(C - GLASS, C - GLASS, GLASS * 2, GLASS * 2);\n\n      // Fine marks all round. The lit run is the gap between the setting (top) and the room reading,\n      // whose white mark rides round with the engraved scale.\n      const gap = (s.v - ROOM) * PER_DEGREE, marks = 120;\n      ctx.lineCap = \"round\";\n      for (let i = 0; i < marks; i++) {\n        const deg = i * (360 / marks) > 180 ? i * (360 / marks) - 360 : i * (360 / marks);\n        const a = (deg * Math.PI) / 180, sn = Math.sin(a), cs = -Math.cos(a);\n        const inside = gap >= 0 ? clamp(Math.min(deg + 1.5, gap - deg + 1.5) / 3, 0, 1) : clamp(Math.min(-deg + 1.5, deg - gap + 1.5) / 3, 0, 1);\n        ctx.lineWidth = 1.4;\n        ctx.strokeStyle = inside > 0 ? heat(s.v - deg / PER_DEGREE, 0.25 + 0.75 * inside) : \"rgba(255,255,255,0.14)\";\n        ctx.beginPath(); ctx.moveTo(C + sn * 71, C + cs * 71); ctx.lineTo(C + sn * 78, C + cs * 78); ctx.stroke();\n      }\n      const ra = (gap * Math.PI) / 180;\n      ctx.lineWidth = 2.2; ctx.strokeStyle = \"rgba(255,255,255,0.96)\";\n      ctx.beginPath(); ctx.moveTo(C + Math.sin(ra) * 66, C - Math.cos(ra) * 66); ctx.lineTo(C + Math.sin(ra) * 80, C - Math.cos(ra) * 80); ctx.stroke();\n\n      // The reading.\n      const shown = snap(s.v), whole = Math.floor(shown + 1e-6), half = shown - whole > 0.25;\n      ctx.textBaseline = \"alphabetic\";\n      ctx.save(); ctx.shadowColor = heat(s.v, 0.75); ctx.shadowBlur = 16 * k;\n      ctx.font = `200 62px ${sans}`; ctx.textAlign = \"center\"; ctx.fillStyle = \"#ffffff\";\n      const wNum = ctx.measureText(String(whole)).width;\n      ctx.fillText(String(whole), C - 6, C + 20);\n      ctx.restore();\n      ctx.textAlign = \"left\"; ctx.fillStyle = \"rgba(255,255,255,0.92)\";\n      ctx.font = `300 19px ${sans}`; ctx.fillText(\"°\", C - 6 + wNum / 2 + 2, C - 10);\n      ctx.font = `400 17px ${sans}`; ctx.fillStyle = \"rgba(255,255,255,0.78)\"; ctx.fillText(half ? \".5\" : \".0\", C - 6 + wNum / 2 + 2, C + 20);\n      ctx.textAlign = \"center\"; ctx.font = `600 7.6px ${sans}`;\n      const label = verb(shown).replace(/ (to|at)$/, \"\").toUpperCase();\n      ctx.fillStyle = heat(s.v, 1); ctx.fillText(label.split(\"\").join(\"  \"), C, C - 38);\n      ctx.fillStyle = \"rgba(255,255,255,0.6)\"; ctx.fillText(`ROOM ${ROOM.toFixed(1)}°`.split(\"\").join(\" \"), C, C + 46);\n\n      // Reflections on the glass: one large soft window from the upper left and a thin line low on the right.\n      const sx = Math.cos(la), sy = Math.sin(la);\n      ctx.beginPath(); ctx.arc(C + sx * 92, C + sy * 92, 132, 0, Math.PI * 2);\n      const refl = ctx.createLinearGradient(C + sx * GLASS, C + sy * GLASS, C - sx * 20, C - sy * 20);\n      refl.addColorStop(0, \"rgba(255,255,255,0.2)\"); refl.addColorStop(0.6, \"rgba(255,255,255,0.05)\"); refl.addColorStop(1, \"rgba(255,255,255,0.015)\");\n      ctx.fillStyle = refl; ctx.fill();\n      ctx.lineWidth = 1.2; ctx.strokeStyle = \"rgba(255,255,255,0.2)\";\n      ctx.beginPath(); ctx.arc(C, C, GLASS - 3.5, la + Math.PI - 0.5, la + Math.PI + 0.5); ctx.stroke();\n      ctx.lineWidth = 1.6; ctx.strokeStyle = \"rgba(255,255,255,0.5)\";\n      ctx.beginPath(); ctx.arc(C, C, GLASS - 3, la - 0.42, la + 0.42); ctx.stroke();\n      ctx.restore();\n\n      // The fixed index: a small painted arrow on the glass edge that the scale turns past.\n      ctx.beginPath(); ctx.moveTo(C, C - GLASS + 3.5); ctx.lineTo(C - 4.4, C - GLASS + 11.5); ctx.lineTo(C + 4.4, C - GLASS + 11.5); ctx.closePath();\n      ctx.save(); ctx.shadowColor = heat(s.v, 1); ctx.shadowBlur = 8 * k; ctx.fillStyle = \"#ffffff\"; ctx.fill(); ctx.restore();\n    };\n\n    let raf = 0, last = 0, seen = true, touched = -1e9, t0 = 0, lastAngle = 0, step = 0;\n    const tour = [24.5, 16, START]; // what the bezel does while nobody is touching it\n    let nextDemo = 900;\n    const select = (v: number) => { if (valueRef.current !== v) { valueRef.current = v; setValue(v); } };\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;\n      if (s.drag) {\n        // While held, the bezel hangs back at each half degree and then drops into the next.\n        const n = snap(s.raw), off = s.raw - n;\n        const sticky = n + off - (Math.sin((off / STEP) * Math.PI * 2) * STEP) / (Math.PI * 2) * 0.8;\n        s.v += (sticky - s.v) * Math.min(1, dt * 28); s.vel = 0;\n        select(n);\n      } else {\n        const idle = now - touched > 5000;\n        const stiff = idle ? 22 : 150, damp = idle ? 7.4 : 20; // slow and heavy by itself, quick under a key press\n        s.vel += (stiff * (s.target - s.v) - damp * s.vel) * dt; s.v += s.vel * dt;\n        if (idle) {\n          s.lightTo = -2.25 + 0.22 * Math.sin(t / 2300);\n          if (t > nextDemo) { s.target = tour[step % tour.length]; step++; select(s.target); nextDemo = t + 2700; }\n        }\n      }\n      s.light += (s.lightTo - s.light) * Math.min(1, dt * 5);\n      s.press += ((s.drag ? 1 : 0) - s.press) * Math.min(1, dt * 10);\n      draw();\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.v = s.target; s.vel = 0; draw(); };\n\n    api.current = { go: (v) => { touched = performance.now(); s.target = v; select(v); if (reduce) settle(); else wake(); } };\n    if (reduce) settle(); else wake();\n\n    const angleAt = (e: PointerEvent) => { const b = pad.getBoundingClientRect(); return Math.atan2(e.clientX - (b.left + b.width / 2), -(e.clientY - (b.top + b.height / 2))); };\n    const onDown = (e: PointerEvent) => {\n      touched = performance.now(); s.drag = true; s.raw = s.v; lastAngle = angleAt(e);\n      pad.setPointerCapture(e.pointerId); pad.focus({ preventScroll: true }); e.preventDefault(); wake();\n    };\n    const onMove = (e: PointerEvent) => {\n      if (!s.drag) {\n        const b = pad.getBoundingClientRect();\n        touched = Math.max(touched, performance.now() - 3600);\n        s.lightTo = clamp(Math.atan2(e.clientY - (b.top + b.height / 2) - 60, e.clientX - (b.left + b.width / 2)), -2.9, -1.5);\n        if (reduce) { s.light = s.lightTo; draw(); }\n        return;\n      }\n      touched = performance.now();\n      const a = angleAt(e); let d = a - lastAngle; if (d > Math.PI) d -= Math.PI * 2; if (d < -Math.PI) d += Math.PI * 2;\n      lastAngle = a;\n      // Turning clockwise brings the warmer numbers round to the index. Past either end it stiffens.\n      const dv = (d * 180) / Math.PI / PER_DEGREE;\n      const over = s.raw + dv > MAX ? s.raw + dv - MAX : s.raw + dv < MIN ? MIN - (s.raw + dv) : 0;\n      s.raw += over > 0 ? dv * Math.max(0.06, 0.5 - over * 1.6) : dv;\n      if (reduce) { s.target = snap(s.raw); select(s.target); settle(); }\n    };\n    const onUp = () => {\n      if (!s.drag) return;\n      s.drag = false; touched = performance.now();\n      s.target = snap(s.raw); select(s.target);\n      if (reduce) settle();\n    };\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  const set = (v: number) => { const n = snap(v); valueRef.current = n; setValue(n); api.current?.go(n); };\n  const onKey = (e: ReactKeyboardEvent) => {\n    const v = valueRef.current;\n    const next = e.key === \"ArrowRight\" || e.key === \"ArrowUp\" ? v + STEP : e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" ? v - STEP : e.key === \"PageUp\" ? v + 2 : e.key === \"PageDown\" ? v - 2 : e.key === \"Home\" ? MIN : e.key === \"End\" ? MAX : null;\n    if (next === null) return;\n    e.preventDefault(); set(next);\n  };\n\n  return (\n    <div className=\"flex min-h-[640px] w-full flex-col items-center justify-center overflow-hidden bg-[#e6dfd3] bg-[radial-gradient(110%_90%_at_28%_12%,#f6f1e8_0%,#e6dfd3_52%,#d3cabb_100%)] px-0 py-12 sm:min-h-[720px]\">\n      <div className=\"relative h-[340px] w-[340px] sm:h-[580px] sm:w-[580px]\">\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"absolute inset-0 h-full w-full\" />\n        <div\n          ref={hit}\n          role=\"slider\"\n          tabIndex={0}\n          aria-label={`${ROOM_NAME} temperature`}\n          aria-valuemin={MIN}\n          aria-valuemax={MAX}\n          aria-valuenow={value}\n          aria-valuetext={`${value.toFixed(1)} degrees, ${verb(value).split(\" \")[0].toLowerCase()}`}\n          onKeyDown={onKey}\n          className=\"absolute left-1/2 top-1/2 h-[70%] w-[70%] -translate-x-1/2 -translate-y-1/2 cursor-grab touch-none rounded-full outline-none focus-visible:ring-2 focus-visible:ring-stone-900 focus-visible:ring-offset-4 focus-visible:ring-offset-[#e6dfd3] active:cursor-grabbing\"\n        />\n      </div>\n      <p className=\"mt-2 min-h-[20px] text-center font-mono text-[11px] uppercase leading-5 tracking-[0.16em] text-stone-600 sm:-mt-4\">\n        <span className=\"text-stone-900\">{ROOM_NAME}</span>\n        <span className=\"mx-2 text-stone-400\">/</span>\n        {verb(value)} {value.toFixed(1)}&deg;\n      </p>\n    </div>\n  );\n}\n"}]}
