{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"banding-wheel-loader-that-throws-a-wet-terracotta-vase-up-to-a-brass-height-gauge","type":"registry:component","title":"Banding Wheel Loader That Throws a Wet Terracotta Vase up to a Brass Height Gauge","description":"Loading animation on a canvas: wet terracotta turns on a wheel and rises into a vase as the percentage climbs. The React code and HTML are free to copy.","dependencies":[],"files":[{"path":"components/we-inc/banding-wheel-loader-that-throws-a-wet-terracotta-vase-up-to-a-brass-height-gauge.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// What the loader says. The first is read while it runs, the second when it finishes.\nconst LABEL = \"Shaping your export\";\nconst DONE_LABEL = \"Export ready\";\nconst DEMO_SECONDS = 9; // length of one self-running throw\nconst DEMO_START = 0.42; // the first run opens part way up so the page never shows a bare lump\nconst STAGE = \"#e9e1d3\";\nconst CLAY: [number, number, number] = [176, 92, 58]; // wet terracotta, as red, green, blue\nconst W = 460, H = 540; // drawing size in CSS pixels\nconst TILT = 0.25; // how far the camera looks down on the wheel\nconst RISE_FROM = 52, RISE_TO = 262; // height of the clay at 0 and at 100 percent\n\nconst clamp = (v: number, a = 0, b = 1) => Math.max(a, Math.min(b, v));\nconst smooth = (a: number, b: number, v: number) => { const t = clamp((v - a) / (b - a)); return t * t * (3 - 2 * t); };\nconst bump = (t: number, at: number, wide: number) => Math.exp(-(((t - at) / wide) ** 2));\n\n// Radius of the clay at height fraction t (0 at the wheel, 1 at the lip) for progress p.\nconst profile = (t: number, p: number) => {\n  const puck = 76 - 5 * t * t;\n  const vase = 37 + 43 * bump(t, 0.34, 0.3) - 9 * bump(t, 0.83, 0.11) + 15 * smooth(0.86, 1, t) - 6 * smooth(0.12, 0, t);\n  return puck + (vase - puck) * smooth(0.04, 0.92, p);\n};\nconst heightAt = (p: number) => RISE_FROM + (RISE_TO - RISE_FROM) * (1 - (1 - p) ** 1.2);\n\nexport default function BandingWheelClayVaseLoader() {\n  const canvas = useRef<HTMLCanvasElement>(null);\n  // Write your own 0 to 1 value into this ref and delete the demo clock in the frame loop.\n  const progress = useRef(DEMO_START);\n  const restart = useRef<(() => void) | null>(null);\n  const [pct, setPct] = useState(Math.round(DEMO_START * 100));\n\n  useEffect(() => {\n    const cv = canvas.current;\n    if (!cv) 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.3;\n    cv.width = W * dpr; cv.height = H * dpr;\n    const CX = 200, FLOOR = 452, HEAD = 412, HEAD_R = 148, TAU = Math.PI * 2;\n    const hasConic = typeof ctx.createConicGradient === \"function\";\n\n    // Shading for a turned surface: across is the position round the pot, down is how far the wall leans.\n    const TW = 256, TH = 72;\n    const tex = document.createElement(\"canvas\"); tex.width = TW; tex.height = TH;\n    const tx = tex.getContext(\"2d\");\n    const img = tx ? tx.createImageData(TW, TH) : null;\n    let bakedFor = 99;\n    const bake = (lx: number) => {\n      if (!tx || !img || Math.abs(lx - bakedFor) < 0.012) return;\n      bakedFor = lx;\n      const ll = Math.hypot(lx, 0.62, 0.74), Lx = lx / ll, Ly = 0.62 / ll, Lz = 0.74 / ll;\n      const hl = Math.hypot(Lx, Ly, Lz + 1), Hx = Lx / hl, Hy = Ly / hl, Hz = (Lz + 1) / hl;\n      for (let j = 0; j < TH; j++) {\n        const up = (j / (TH - 1)) * 1.7 - 0.85, flat = Math.sqrt(1 - up * up);\n        for (let i = 0; i < TW; i++) {\n          const u = (i + 0.5) / TW * 2 - 1, nx = u * flat, nz = Math.sqrt(Math.max(0, 1 - u * u)) * flat;\n          const d = nx * Lx + up * Ly + nz * Lz, lit = clamp(d * 0.78 + 0.22);\n          const sp = Math.max(0, nx * Hx + up * Hy + nz * Hz);\n          const gloss = sp ** 70 * 0.95 + sp ** 9 * 0.2; // wet slip: one tight glint and a wide soft one\n          const rim = (1 - nz / Math.max(0.001, flat)) ** 3; // the pale table bounced into both edges\n          const back = clamp(-d) * 0.16;\n          const k = 0.2 + lit * 0.98, o = (j * TW + i) * 4;\n          img.data[o] = clamp((CLAY[0] * k + 255 * gloss + 210 * rim * 0.34 + 96 * back) / 255) * 255;\n          img.data[o + 1] = clamp((CLAY[1] * k * (0.9 + lit * 0.14) + 250 * gloss + 172 * rim * 0.3 + 52 * back) / 255) * 255;\n          img.data[o + 2] = clamp((CLAY[2] * k * (0.82 + lit * 0.2) + 244 * gloss + 140 * rim * 0.28 + 44 * back) / 255) * 255;\n          img.data[o + 3] = 255 * clamp((1 - Math.abs(u)) * TW * 0.42);\n        }\n      }\n      tx.putImageData(img, 0, 0);\n    };\n\n    // Streaks of slip that ride round with the pot, so the turning can be read.\n    let seed = 7;\n    const rand = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };\n    const streaks = Array.from({ length: 64 }, () => ({ a: rand() * TAU, t: 0.04 + rand() * 0.92, w: 5 + rand() * 16, pale: rand() > 0.45, o: 0.06 + rand() * 0.12 }));\n    const smears = Array.from({ length: 26 }, () => ({ a: rand() * TAU, r: 60 + rand() * 82, len: 0.3 + rand() * 1.5, w: 1 + rand() * 5, o: 0.1 + rand() * 0.28 }));\n    const lumps = Array.from({ length: 220 }, () => rand() - 0.5);\n\n    const s = { p: DEMO_START, pv: 0, spin: 0, w: 9, light: -0.5, lightTo: -0.5, drag: false };\n    const metal = (x0: number, x1: number, tones: number[]) => { const g = ctx.createLinearGradient(x0, 0, x1, 0); tones.forEach((v, i) => g.addColorStop(i / (tones.length - 1), `rgb(${v},${v - 3},${v - 9})`)); return g; };\n    const oval = (x: number, y: number, r: number, ry = r * TILT) => { ctx.beginPath(); ctx.ellipse(x, y, r, ry, 0, 0, TAU); };\n    const drum = (y: number, r: number, thick: number) => { ctx.beginPath(); ctx.ellipse(CX, y + thick, r, r * TILT, 0, 0, Math.PI); ctx.lineTo(CX - r, y); ctx.ellipse(CX, y, r, r * TILT, 0, Math.PI, 0, true); ctx.closePath(); };\n\n    const draw = () => {\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      ctx.clearRect(0, 0, W, H);\n      const p = clamp(s.p), lx = s.light;\n      bake(lx);\n      const tall = heightAt(p), top = HEAD - tall, wall = 30 - 23 * smooth(0, 0.8, p);\n      const live = clamp(Math.abs(s.w) / 9), wob = 2.4 * live * (1 - p * 0.72);\n      const lean = (t: number) => wob * t * Math.sin(s.spin + t * 2.1);\n      const ridge = (h: number) => 0.2 * Math.sin(h * 0.47 - s.spin) + 0.1 * Math.sin(h * 1.13 - s.spin + 1.7) + 0.16 * lumps[((h * 0.5) | 0) % 220];\n      const rad = (h: number) => profile(h / tall, p) + ridge(h);\n\n      // Floor shadow, then the cast-iron foot, the shaft and the turned aluminium head.\n      const fs = ctx.createRadialGradient(CX - lx * 30, FLOOR + 16, 10, CX - lx * 30, FLOOR + 16, 178);\n      fs.addColorStop(0, \"rgba(72,48,26,0.5)\"); fs.addColorStop(0.42, \"rgba(72,48,26,0.2)\"); fs.addColorStop(1, \"rgba(72,48,26,0)\");\n      ctx.save(); ctx.translate(0, (FLOOR + 16) * (1 - 0.3)); ctx.scale(1, 0.3); ctx.fillStyle = fs; ctx.fillRect(-60, FLOOR - 260, W + 120, 560); ctx.restore();\n      drum(FLOOR - 4, 104, 16); ctx.fillStyle = metal(CX - 104, CX + 104, [22, 58, 96, 60, 34, 24, 44, 26]); ctx.fill();\n      oval(CX, FLOOR - 4, 104); ctx.fillStyle = metal(CX - 104, CX + 104, [62, 92, 124, 96, 66, 52]); ctx.fill();\n      ctx.lineWidth = 0.8; ctx.strokeStyle = \"rgba(255,255,255,0.3)\"; oval(CX, FLOOR - 3.4, 103); ctx.stroke();\n      oval(CX, FLOOR - 4, 40); ctx.fillStyle = \"rgba(0,0,0,0.5)\"; ctx.fill();\n      drum(HEAD + 10, 25, FLOOR - HEAD - 16); ctx.fillStyle = metal(CX - 25, CX + 25, [40, 120, 214, 150, 78, 50, 96, 42]); ctx.fill();\n      const under = ctx.createLinearGradient(0, HEAD + 14, 0, HEAD + 40); under.addColorStop(0, \"rgba(20,14,8,0.85)\"); under.addColorStop(1, \"rgba(20,14,8,0)\");\n      drum(HEAD + 10, 25, 30); ctx.fillStyle = under; ctx.fill();\n      drum(HEAD, HEAD_R, 13); ctx.fillStyle = metal(CX - HEAD_R, CX + HEAD_R, [70, 150, 232, 250, 188, 120, 84, 108, 168, 96, 62]); ctx.fill();\n      ctx.lineWidth = 0.7; ctx.strokeStyle = \"rgba(30,24,18,0.4)\";\n      for (const dy of [3.4, 6.2, 9.6]) { ctx.beginPath(); ctx.ellipse(CX, HEAD + dy, HEAD_R, HEAD_R * TILT, 0, 0.04, Math.PI - 0.04); ctx.stroke(); }\n\n      ctx.save(); ctx.translate(CX, HEAD); ctx.scale(1, TILT);\n      ctx.beginPath(); ctx.arc(0, 0, HEAD_R, 0, TAU);\n      if (hasConic) {\n        const g = ctx.createConicGradient(-1.9 + lx * 0.5, 0, 0);\n        [206, 244, 214, 172, 150, 176, 222, 190, 156, 170, 228, 252, 206].forEach((v, i, all) => g.addColorStop(i / (all.length - 1), `rgb(${v},${v - 3},${v - 10})`));\n        ctx.fillStyle = g;\n      } else ctx.fillStyle = \"#cfcac0\";\n      ctx.fill(); ctx.clip();\n      for (let r = 8; r < HEAD_R; r += 2.6) { ctx.beginPath(); ctx.arc(0, 0, r, 0, TAU); ctx.lineWidth = 0.9; ctx.strokeStyle = (r * 7) % 5 < 2.4 ? \"rgba(255,255,255,0.22)\" : \"rgba(40,30,20,0.13)\"; ctx.stroke(); }\n      // Slurry thrown off the pot, dragged into arcs as the head turns.\n      ctx.rotate(s.spin); ctx.lineCap = \"round\";\n      for (const m of smears) { ctx.beginPath(); ctx.arc(0, 0, m.r, m.a, m.a + m.len); ctx.lineWidth = m.w; ctx.strokeStyle = `rgba(${CLAY[0] - 8},${CLAY[1] - 6},${CLAY[2] - 4},${m.o})`; ctx.stroke(); }\n      ctx.rotate(-s.spin);\n      const pool = ctx.createRadialGradient(0, 0, 40, 0, 0, 112);\n      pool.addColorStop(0, `rgba(${CLAY[0] - 30},${CLAY[1] - 22},${CLAY[2] - 16},0.95)`); pool.addColorStop(0.72, `rgba(${CLAY[0]},${CLAY[1]},${CLAY[2]},0.5)`); pool.addColorStop(1, `rgba(${CLAY[0]},${CLAY[1]},${CLAY[2]},0)`);\n      ctx.fillStyle = pool; ctx.fillRect(-HEAD_R, -HEAD_R, HEAD_R * 2, HEAD_R * 2);\n      const cast = ctx.createRadialGradient(-lx * 70, 46, 20, -lx * 70, 46, 150);\n      cast.addColorStop(0, \"rgba(40,18,8,0.62)\"); cast.addColorStop(1, \"rgba(40,18,8,0)\");\n      ctx.fillStyle = cast; ctx.fillRect(-HEAD_R, -HEAD_R, HEAD_R * 2, HEAD_R * 2);\n      ctx.restore();\n      ctx.lineWidth = 1; ctx.strokeStyle = \"rgba(255,255,255,0.75)\"; ctx.beginPath(); ctx.ellipse(CX, HEAD + 0.6, HEAD_R - 0.6, (HEAD_R - 0.6) * TILT, 0, 0.5, 2.5); ctx.stroke();\n\n      // Height gauge: a brass rod on a walnut block whose pointer marks where the lip must end up.\n      const GX = 392, tipX = CX + profile(1, 1) + 5, tipY = HEAD - RISE_TO + 2;\n      oval(GX - lx * 12, FLOOR + 14, 34, 7); ctx.fillStyle = \"rgba(72,48,26,0.28)\"; ctx.fill();\n      const wood = ctx.createLinearGradient(GX - 24, 0, GX + 24, 0); wood.addColorStop(0, \"#3d2415\"); wood.addColorStop(0.4, \"#7a4d2d\"); wood.addColorStop(0.62, \"#8f5d38\"); wood.addColorStop(1, \"#472a18\");\n      ctx.beginPath(); ctx.roundRect(GX - 24, FLOOR - 4, 48, 20, 3); ctx.fillStyle = wood; ctx.fill();\n      ctx.beginPath(); ctx.roundRect(GX - 24, FLOOR - 4, 48, 3, [3, 3, 0, 0]); ctx.fillStyle = \"rgba(255,226,190,0.4)\"; ctx.fill();\n      const brass = (a: number, b: number, vertical: boolean) => { const g = vertical ? ctx.createLinearGradient(0, a, 0, b) : ctx.createLinearGradient(a, 0, b, 0); g.addColorStop(0, \"#6a4a14\"); g.addColorStop(0.3, \"#e8c873\"); g.addColorStop(0.46, \"#fff3c4\"); g.addColorStop(0.7, \"#b88a33\"); g.addColorStop(1, \"#5a3d10\"); return g; };\n      ctx.fillStyle = brass(GX - 2.6, GX + 2.6, false); ctx.fillRect(GX - 2.6, tipY - 40, 5.2, FLOOR - tipY + 38);\n      oval(GX, tipY - 40, 2.6, 1.2); ctx.fillStyle = \"#fff0bd\"; ctx.fill();\n      ctx.fillStyle = brass(tipY - 2, tipY + 2, true); ctx.beginPath(); ctx.moveTo(GX + 16, tipY - 2); ctx.lineTo(tipX + 16, tipY - 2); ctx.lineTo(tipX, tipY); ctx.lineTo(tipX + 16, tipY + 2); ctx.lineTo(GX + 16, tipY + 2); ctx.closePath(); ctx.fill();\n      ctx.save(); ctx.shadowColor = \"rgba(40,24,8,0.45)\"; ctx.shadowBlur = 5 * dpr; ctx.shadowOffsetY = 2.5 * dpr;\n      ctx.beginPath(); ctx.roundRect(GX - 8, tipY - 8, 16, 16, 2.5); ctx.fillStyle = brass(GX - 8, GX + 8, false); ctx.fill(); ctx.restore();\n      oval(GX, tipY, 4.4, 4.4); ctx.fillStyle = \"#5c3f12\"; ctx.fill();\n      oval(GX - 0.6, tipY - 0.6, 3.6, 3.6); ctx.fillStyle = brass(GX - 4, GX + 4, false); ctx.fill();\n      ctx.lineWidth = 0.9; ctx.strokeStyle = \"rgba(60,38,8,0.8)\"; ctx.beginPath(); ctx.moveTo(GX - 2.6, tipY + 1.6); ctx.lineTo(GX + 1.6, tipY - 2.6); ctx.stroke();\n\n      // The clay, one thin slice at a time from the lip down to the wheel.\n      const step = 1 / dpr, rows = TH - 1;\n      const row = (y: number, r: number, off: number, up: number) => {\n        const j = Math.round(clamp((up + 0.85) / 1.7) * rows);\n        ctx.drawImage(tex, 0, j, TW, 1, CX + off - r, y, r * 2, step * 1.6);\n      };\n      for (let y = top; y < HEAD; y += step) {\n        const h = HEAD - y, r = rad(h), slope = (rad(h + 1) - rad(h - 1)) / 2;\n        row(y, r, lean(h / tall), -slope / Math.hypot(1, slope) * 0.9);\n      }\n      const foot = rad(0.5), fy = foot * TILT;\n      for (let dy = 0; dy < fy; dy += step) row(HEAD + dy, foot * Math.sqrt(1 - (dy / fy) ** 2), 0, -0.3 - 0.5 * (dy / fy));\n      for (const k of streaks) {\n        const c = Math.cos(k.a + s.spin * (0.99 + k.t * 0.02)); if (c < 0.12) continue;\n        const h = k.t * tall, r = rad(h), x = CX + lean(k.t) + r * Math.sin(k.a + s.spin);\n        ctx.beginPath(); ctx.ellipse(x, HEAD - h, k.w * c * (0.4 + live * 0.6), 0.75, 0, 0, TAU);\n        ctx.fillStyle = k.pale ? `rgba(244,196,160,${k.o * c})` : `rgba(74,30,14,${k.o * c})`; ctx.fill();\n      }\n\n      // The lip and the dark well inside it.\n      const lipR = rad(tall), ox = CX + lean(1), inR = Math.max(6, lipR - wall), lit = clamp(0.5 - lx * 0.5);\n      const lip = ctx.createLinearGradient(ox - lipR, 0, ox + lipR, 0);\n      const tone = (k: number) => `rgb(${(CLAY[0] * k) | 0},${(CLAY[1] * k) | 0},${(CLAY[2] * k) | 0})`;\n      lip.addColorStop(0, tone(0.62 + 0.5 * lit)); lip.addColorStop(clamp(0.5 - lx * 0.34), tone(1.26)); lip.addColorStop(1, tone(1.12 - 0.5 * lit));\n      oval(ox, top, lipR); ctx.fillStyle = lip; ctx.fill();\n      ctx.lineWidth = 1.5; ctx.strokeStyle = \"rgba(255,240,226,0.9)\"; ctx.beginPath(); ctx.ellipse(ox, top, lipR - 1.6, (lipR - 1.6) * TILT, 0, Math.PI * (0.52 + lx * 0.24), Math.PI * (0.8 + lx * 0.24)); ctx.stroke();\n      ctx.lineWidth = 0.8; ctx.strokeStyle = \"rgba(255,226,206,0.5)\"; ctx.beginPath(); ctx.ellipse(ox, top, lipR - 0.5, (lipR - 0.5) * TILT, 0, Math.PI * 1.08, Math.PI * 1.92); ctx.stroke();\n      ctx.save(); oval(ox, top + 0.6, inR); ctx.clip();\n      const well = ctx.createLinearGradient(0, top - inR * TILT, 0, top + inR * TILT);\n      well.addColorStop(0, tone(0.72)); well.addColorStop(0.5, tone(0.36)); well.addColorStop(1, tone(0.14));\n      ctx.fillStyle = well; ctx.fillRect(ox - inR, top - inR, inR * 2, inR * 2);\n      const far = ctx.createRadialGradient(ox - lx * inR * 0.7, top - inR * TILT * 0.9, 1, ox - lx * inR * 0.7, top - inR * TILT * 0.9, inR * 1.1);\n      far.addColorStop(0, \"rgba(255,190,150,0.5)\"); far.addColorStop(1, \"rgba(255,190,150,0)\");\n      ctx.fillStyle = far; ctx.fillRect(ox - inR, top - inR, inR * 2, inR * 2);\n      if (p < 0.5) { // while the piece is still low you can see the wet floor of the well\n        oval(ox, top + inR * TILT * 0.5, inR * 0.72, inR * TILT * 0.5); ctx.fillStyle = `rgba(${CLAY[0]},${CLAY[1]},${CLAY[2]},${0.5 * (1 - p * 2)})`; ctx.fill();\n        ctx.lineWidth = 1; ctx.strokeStyle = `rgba(255,236,220,${0.5 * (1 - p * 2)})`; ctx.beginPath(); ctx.ellipse(ox - lx * 8, top + inR * TILT * 0.5, inR * 0.42, inR * TILT * 0.24, 0, 3.5, 5.2); ctx.stroke();\n      }\n      ctx.restore();\n      ctx.lineWidth = 1; ctx.strokeStyle = \"rgba(52,20,8,0.55)\"; ctx.beginPath(); ctx.ellipse(ox, top + 0.6, inR, inR * TILT, 0, Math.PI, TAU); ctx.stroke();\n    };\n\n    let raf = 0, last = 0, seen = true, clock = DEMO_START * DEMO_SECONDS, shown = -1, lastX = 0, touched = -1e9, idle = 0;\n    const HOLD = 3;\n    const report = (p: number) => { const n = Math.round(clamp(p) * 100); if (n !== shown) { shown = n; setPct(n); } };\n    const frame = (now: number) => {\n      raf = 0;\n      if (!last) last = now;\n      const dt = Math.min(0.033, (now - last) / 1000); last = now;\n\n      // Demo clock. Delete this block when `progress.current` is fed from real work.\n      clock += dt;\n      if (clock < DEMO_SECONDS) { const t = clock / DEMO_SECONDS; progress.current = Math.min(1, t + 0.03 * Math.sin(t * Math.PI * 7) * (1 - t)); }\n      else if (clock < DEMO_SECONDS + HOLD) progress.current = 1;\n      else { clock = 0; progress.current = 0; }\n\n      const target = clamp(progress.current);\n      // The clay follows the number on a soft spring, so a reset sinks back down instead of jumping.\n      s.pv += ((target - s.p) * 60 - s.pv * 14) * dt; s.p += s.pv * dt;\n      const cruise = target >= 1 && s.p > 0.985 ? 0 : 9;\n      if (!s.drag) s.w += (cruise - s.w) * Math.min(1, dt * (cruise ? 2.4 : 1.1));\n      s.spin += s.w * dt;\n      idle += dt;\n      if (now - touched > 3500) s.lightTo = -0.5 + 0.16 * Math.sin(idle / 2.6);\n      s.light += (s.lightTo - s.light) * Math.min(1, dt * 5);\n      report(target);\n      draw();\n      if (seen && !document.hidden) raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!raf && !reduce) { last = 0; raf = requestAnimationFrame(frame); } };\n    const still = () => { progress.current = 1; s.p = 1; s.w = 0; report(1); draw(); };\n    restart.current = () => { clock = 0; progress.current = 0; if (reduce) still(); else wake(); };\n    if (reduce) still(); else wake();\n\n    const onDown = (e: PointerEvent) => { s.drag = true; lastX = e.clientX; touched = performance.now(); cv.setPointerCapture(e.pointerId); };\n    const onMove = (e: PointerEvent) => {\n      if (reduce) return;\n      const b = cv.getBoundingClientRect();\n      touched = performance.now();\n      if (!s.drag) { s.lightTo = clamp(((e.clientX - b.left) / b.width) * 2 - 1, -0.85, 0.85); return; }\n      const d = ((e.clientX - lastX) / b.width) * 5; lastX = e.clientX;\n      s.spin += d; s.w = s.w * 0.6 + (d / 0.016) * 0.4; // a push carries the wheel on after you let go\n    };\n    const onUp = () => { s.drag = false; };\n    cv.addEventListener(\"pointerdown\", onDown); cv.addEventListener(\"pointermove\", onMove);\n    cv.addEventListener(\"pointerup\", onUp); cv.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); restart.current = null;\n      cv.removeEventListener(\"pointerdown\", onDown); cv.removeEventListener(\"pointermove\", onMove);\n      cv.removeEventListener(\"pointerup\", onUp); cv.removeEventListener(\"pointercancel\", onUp);\n      io.disconnect(); document.removeEventListener(\"visibilitychange\", onVis);\n    };\n  }, []);\n\n  const done = pct >= 100;\n  return (\n    <div\n      className=\"flex min-h-[640px] w-full flex-col items-center justify-center overflow-hidden bg-[radial-gradient(90%_70%_at_50%_38%,#f6f0e4_0%,#e9e1d3_55%,#d9cfbd_100%)] px-4 py-10 sm:min-h-[760px]\"\n      style={{ backgroundColor: STAGE }}\n    >\n      <div\n        role=\"progressbar\"\n        aria-label={LABEL}\n        aria-valuemin={0}\n        aria-valuemax={100}\n        aria-valuenow={pct}\n        aria-valuetext={done ? DONE_LABEL : `${pct} percent thrown`}\n        className=\"relative h-[400px] w-[340px] sm:h-[620px] sm:w-[530px]\"\n      >\n        <canvas\n          ref={canvas}\n          aria-hidden=\"true\"\n          className=\"absolute left-1/2 top-0 h-[540px] w-[460px] max-w-none origin-top -translate-x-1/2 scale-[0.74] cursor-grab touch-pan-y active:cursor-grabbing sm:scale-[1.15]\"\n        />\n      </div>\n      <div className=\"mt-2 flex flex-col items-center gap-3\">\n        <p aria-hidden=\"true\" className=\"font-mono text-[34px] font-medium tabular-nums leading-none tracking-tight text-stone-800\">\n          {pct}\n          <span className=\"ml-1 text-[15px] text-stone-600\">%</span>\n        </p>\n        <p role=\"status\" className=\"font-mono text-[11px] uppercase tracking-[0.2em] text-stone-700\">\n          {done ? DONE_LABEL : LABEL}\n        </p>\n        <button\n          type=\"button\"\n          onClick={() => restart.current?.()}\n          className=\"flex h-10 items-center rounded-full border border-stone-500 px-5 font-mono text-[11px] uppercase tracking-[0.18em] text-stone-800 outline-none transition-colors hover:bg-stone-900/5 focus-visible:ring-2 focus-visible:ring-stone-800 motion-reduce:transition-none\"\n        >\n          Throw again\n        </button>\n      </div>\n    </div>\n  );\n}\n"}]}
