{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"restaurant-pager-puck-alert-that-buzzes-across-a-black-table-with-chasing-red-lights-and-a-dot-matrix-message","type":"registry:component","title":"Restaurant Pager Puck Alert That Buzzes Across a Black Table with Chasing Red Lights and a Dot-Matrix Message","description":"Alert drawn as a restaurant pager: a black puck buzzes across a table, chases red lights round its rim and scrolls your message. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/restaurant-pager-puck-alert-that-buzzes-across-a-black-table-with-chasing-red-lights-and-a-dot-matrix-message.tsx","type":"registry:component","content":"import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** What the pager is buzzed with, in order. `lcd` scrolls across the little display (capitals and digits only). */\nconst pages = [\n  { lcd: \"TABLE 9 IS READY\", title: \"Your table is ready\", detail: \"Table nine, by the window. Bring the pager with you.\" },\n  { lcd: \"DRINKS AT THE BAR\", title: \"Your drinks are poured\", detail: \"Two spritzes and a lemonade are waiting at the bar.\" },\n  { lcd: \"TAXI IS OUTSIDE\", title: \"Your taxi has arrived\", detail: \"A silver saloon is at the side door on Marlow Street.\" },\n];\nconst NUMBER = \"27\"; // printed on the pager\nconst RING_FOR = 6400; // milliseconds it buzzes before the demo answers it by itself\nconst SOUND = false; // set to true for a low buzz while it rings (it only ever plays after the visitor has pressed the pager)\n\ntype Pt = [number, number];\ntype Mode = \"ringing\" | \"answered\" | \"waiting\";\nconst CW = 560;\nconst CH = 400;\nconst CX = 280;\nconst FOOT = 262; // screen y of the centre of the underside\nconst TILT = (40 * Math.PI) / 180;\nconst SIN = Math.sin(TILT);\nconst COS = Math.cos(TILT);\nconst R = 118;\nconst TOP_H = 35.4;\nconst LED_H = 16;\nconst LEDS = 16;\nconst LOWER: Pt[] = [[0, 0], [107, 0], [107, 0], [116, 2], [118, 6], [118, 10], [118, 10]];\nconst BAND: Pt[] = [[118, 10], [118, 10], [119.6, 12.5], [119.6, 19.5], [118, 22], [118, 22]];\nconst UPPER: Pt[] = [[118, 22], [118, 22], [118, 25], [115.5, 29], [110, 31.6], [104, 32.6], [96, 33.6], [86, 34.8], [77, 35.8], [77, 35.8], [77, 35.4], [0, 35.4]];\n\nconst FONT: Record<string, string> = {\n  A: \"0E11111F111111\", B: \"1E11111E11111E\", C: \"0E11101010110E\", D: \"1E11111111111E\", E: \"1F10101E10101F\", F: \"1F10101E101010\", G: \"0E11101711110F\", H: \"1111111F111111\", I: \"0E04040404040E\",\n  J: \"0702020202120C\", K: \"11121418141211\", L: \"1010101010101F\", M: \"111B1515111111\", N: \"11191513111111\", O: \"0E11111111110E\", P: \"1E11111E101010\", Q: \"0E11111115120D\", R: \"1E11111E141211\",\n  S: \"0F10100E01011E\", T: \"1F040404040404\", U: \"1111111111110E\", V: \"11111111110A04\", W: \"1111111515150A\", X: \"11110A040A1111\", Y: \"11110A04040404\", Z: \"1F01020408101F\",\n  \"0\": \"0E11131519110E\", \"1\": \"040C040404040E\", \"2\": \"0E11010204081F\", \"3\": \"1F02040201110E\", \"4\": \"02060A121F0202\", \"5\": \"1F101E0101110E\", \"6\": \"0608101E11110E\", \"7\": \"1F010204080808\", \"8\": \"0E11110E11110E\", \"9\": \"0E11110F01020C\",\n};\nconst COLS = 37;\n\n/** Turn a message into columns of seven dots. */\nfunction columns(text: string): number[] {\n  const out: number[] = [];\n  for (const ch of text) {\n    const g = FONT[ch];\n    for (let c = 0; c < 5; c++) {\n      let col = 0;\n      if (g) for (let r = 0; r < 7; r++) if (parseInt(g.slice(r * 2, r * 2 + 2), 16) & (16 >> c)) col |= 1 << r;\n      out.push(col);\n    }\n    out.push(0);\n  }\n  return out;\n}\n\n// fine mineral speckle for the table, as a repeating picture\nconst STONE = `url(\"data:image/svg+xml,${encodeURIComponent(\"<svg xmlns='http://www.w3.org/2000/svg' width='420' height='420'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.95  0 0 0 0 0.9  0 0 0 -2.2 1.05'/></filter><rect width='420' height='420' filter='url(#n)'/></svg>\")}\")`;\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst smooth = (a: number, b: number, v: number) => {\n  const t = clamp((v - a) / (b - a), 0, 1);\n  return t * t * (3 - 2 * t);\n};\nconst band = (v: number, a: number, b: number, s: number) => smooth(a - s, a + s, v) * (1 - smooth(b - s, b + s, v));\n\nfunction soften(pts: Pt[], rounds: number): Pt[] {\n  let out = pts;\n  for (let k = 0; k < rounds; k++) {\n    const next: Pt[] = [out[0]];\n    for (let i = 0; i < out.length - 1; i++) {\n      const [r0, h0] = out[i];\n      const [r1, h1] = out[i + 1];\n      next.push([r0 * 0.75 + r1 * 0.25, h0 * 0.75 + h1 * 0.25], [r0 * 0.25 + r1 * 0.75, h0 * 0.25 + h1 * 0.75]);\n    }\n    next.push(out[out.length - 1]);\n    out = next;\n  }\n  return out;\n}\n\n/** What the glossy plastic mirrors: a dark bar, a long window behind the table, two strip lights low at the sides. */\nfunction bar(x: number, y: number, z: number): number {\n  const el = Math.asin(clamp(y, -1, 1));\n  const az = Math.atan2(x, z);\n  let v = 0.012 + 0.02 * Math.max(0, el);\n  // the window behind the table: this is the bright shape that lies across the lid\n  const round = az < 0 ? az + Math.PI * 2 : az;\n  v += band(round, 2.5, 3.02, 0.02) * band(el, 0.47, 0.9, 0.02) * (1 - 0.92 * band(round, 2.75, 2.775, 0.008)) * (1 - 0.92 * band(el, 0.69, 0.71, 0.008)) * 4.2;\n  v += band(round, 3.5, 3.62, 0.02) * band(el, 0.5, 0.86, 0.03) * 3;\n  v += band(az, -1.5, -0.5, 0.1) * band(el, 0.05, 0.5, 0.09) * 2.6;\n  v += band(az, 0.75, 1.25, 0.08) * band(el, 0.1, 0.42, 0.08) * 1.5;\n  v += band(az, -0.25, 0.3, 0.2) * band(el, 0.2, 0.7, 0.2) * 0.25;\n  if (el < 0) v = v * (1 - smooth(0, -0.1, el)) + 0.012;\n  return v;\n}\n\n/** Spin each outline round the centre, keep the nearest surface for each pixel, then light the pixels once. */\nfunction turn(parts: { pts: Pt[]; kind: 1 | 2 | 3 }[]): HTMLCanvasElement {\n  const S = 3;\n  const W = CW * S;\n  const H = CH * S;\n  const depth = new Float32Array(W * H).fill(-1e9);\n  const nx = new Float32Array(W * H);\n  const ny = new Float32Array(W * H);\n  const nz = new Float32Array(W * H);\n  const kind = new Uint8Array(W * H);\n  for (const part of parts) {\n    const p = soften(part.pts, 3);\n    const tn: Pt[] = p.map((_, i) => {\n      const a = p[Math.max(0, i - 1)];\n      const c = p[Math.min(p.length - 1, i + 1)];\n      const l = Math.hypot(c[0] - a[0], c[1] - a[1]) || 1;\n      return [(c[1] - a[1]) / l, -(c[0] - a[0]) / l];\n    });\n    for (let i = 0; i < p.length - 1; i++) {\n      const steps = Math.max(1, Math.ceil(Math.hypot(p[i + 1][0] - p[i][0], p[i + 1][1] - p[i][1]) * S * 2));\n      for (let s = 0; s < steps; s++) {\n        const t = s / steps;\n        const r = p[i][0] + (p[i + 1][0] - p[i][0]) * t;\n        const h = p[i][1] + (p[i + 1][1] - p[i][1]) * t;\n        let nr = tn[i][0] + (tn[i + 1][0] - tn[i][0]) * t;\n        let nh = tn[i][1] + (tn[i + 1][1] - tn[i][1]) * t;\n        const nl = Math.hypot(nr, nh) || 1;\n        nr /= nl;\n        nh /= nl;\n        const count = Math.ceil(Math.PI * 2 * r * S * 2) + 8;\n        const da = (Math.PI * 2) / count;\n        const ca = Math.cos(da);\n        const sa = Math.sin(da);\n        let c = 1;\n        let sn = 0;\n        for (let k = 0; k < count; k++) {\n          if (nh * SIN + nr * sn * COS > 0) {\n            const z = r * sn;\n            const px = Math.round((CX + r * c) * S);\n            const py = Math.round((FOOT - (h * COS - z * SIN)) * S);\n            if (px >= 0 && px < W && py >= 0 && py < H) {\n              const d = z * COS + h * SIN;\n              const at = py * W + px;\n              if (d > depth[at]) {\n                depth[at] = d;\n                nx[at] = nr * c;\n                ny[at] = nh;\n                nz[at] = nr * sn;\n                kind[at] = part.kind;\n              }\n            }\n          }\n          const c2 = c * ca - sn * sa;\n          sn = sn * ca + c * sa;\n          c = c2;\n        }\n      }\n    }\n  }\n  const sheet = document.createElement(\"canvas\");\n  sheet.width = W;\n  sheet.height = H;\n  const g2 = sheet.getContext(\"2d\");\n  if (!g2) return sheet;\n  const img = g2.createImageData(W, H);\n  const px = img.data;\n  for (let i = 0; i < W * H; i++) {\n    if (!kind[i]) continue;\n    const a = nx[i];\n    const b = ny[i];\n    const c = nz[i];\n    const nv = b * SIN + c * COS;\n    const e = bar(2 * nv * a, 2 * nv * b - SIN, 2 * nv * c - COS);\n    const key = Math.max(0, a * -0.5 + b * 0.62 + c * 0.6);\n    const edge = Math.pow(1 - clamp(nv, 0, 1), 4);\n    let r: number;\n    let g: number;\n    let bl: number;\n    if (kind[i] === 1) {\n      const f = 0.05 + 0.55 * edge;\n      r = g = bl = 0.004 + e * f + 0.006 * key;\n      bl *= 1.06;\n    } else if (kind[i] === 2) {\n      // smoked red plastic with the lights behind it switched off\n      const f = 0.05 + 0.5 * edge;\n      r = 0.085 + 0.11 * key + e * f;\n      g = 0.004 + 0.006 * key + e * f;\n      bl = 0.008 + 0.01 * key + e * f;\n    } else {\n      r = g = bl = 0.006 + 0.016 * key + e * 0.02;\n    }\n    const o = i * 4;\n    px[o] = 255 * Math.pow(1 - Math.exp(-r * 1.6), 0.4545);\n    px[o + 1] = 255 * Math.pow(1 - Math.exp(-g * 1.6), 0.4545);\n    px[o + 2] = 255 * Math.pow(1 - Math.exp(-bl * 1.6), 0.4545);\n    px[o + 3] = 255;\n  }\n  g2.putImageData(img, 0, 0);\n  return sheet;\n}\n\nexport default function RestaurantPagerPuckAlert() {\n  const reduce = !!useReducedMotion();\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const [mode, setMode] = useState<Mode>(\"ringing\");\n  const [page, setPage] = useState(0);\n  const live = useRef({ mode: \"ringing\" as Mode, page: 0, since: 0, touched: false, seen: true, audio: null as AudioContext | null, hum: null as OscillatorNode | null, kick: () => {} });\n  const timers = useRef<number[]>([]);\n\n  const buzz = useCallback((on: boolean) => {\n    const s = live.current;\n    if (!SOUND || !s.touched) return;\n    try {\n      if (on && !s.hum) {\n        s.audio = s.audio || new AudioContext();\n        const gain = s.audio.createGain();\n        gain.gain.value = 0.05;\n        s.hum = s.audio.createOscillator();\n        s.hum.type = \"sawtooth\";\n        s.hum.frequency.value = 168;\n        s.hum.connect(gain).connect(s.audio.destination);\n        s.hum.start();\n      } else if (!on && s.hum) {\n        s.hum.stop();\n        s.hum = null;\n      }\n    } catch {\n      // no audio available: the pager stays silent\n    }\n  }, []);\n\n  const go = useCallback(\n    (to: Mode, nextPage?: number) => {\n      const s = live.current;\n      timers.current.forEach((t) => window.clearTimeout(t));\n      timers.current = [];\n      s.mode = to;\n      s.since = performance.now();\n      setMode(to);\n      if (nextPage !== undefined) {\n        s.page = nextPage;\n        setPage(nextPage);\n      }\n      buzz(to === \"ringing\");\n      s.kick();\n      if (reduce) return;\n      // the story the pager tells when left alone: it rings, is answered, waits, and is paged again\n      if (to === \"ringing\" && !s.touched) timers.current.push(window.setTimeout(() => go(\"answered\"), RING_FOR));\n      if (to === \"answered\") timers.current.push(window.setTimeout(() => go(\"waiting\"), 1700));\n      if (to === \"waiting\") timers.current.push(window.setTimeout(() => go(\"ringing\", (s.page + 1) % pages.length), 2600));\n    },\n    [buzz, reduce],\n  );\n\n  const press = () => {\n    const s = live.current;\n    s.touched = true;\n    if (s.mode === \"ringing\") go(\"answered\");\n    else go(\"ringing\", (s.page + 1) % pages.length);\n  };\n\n  useEffect(() => {\n    const s = live.current;\n    go(\"ringing\", 0);\n    return () => {\n      timers.current.forEach((t) => window.clearTimeout(t));\n      s.hum?.stop();\n      s.hum = null;\n    };\n  }, [go]);\n\n  useEffect(() => {\n    const canvas = canvasRef.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!canvas || !ctx) return;\n    const s = live.current;\n    const body = turn([{ pts: LOWER, kind: 3 }, { pts: BAND, kind: 2 }, { pts: UPPER, kind: 1 }]);\n    const glow = new Float32Array(LEDS);\n    const texts = pages.map((p) => columns(`${p.lcd}   `));\n    const words = { answered: columns(\"THANKS\"), waiting: columns(\"WAIT\") };\n    let raf = 0;\n    let last = 0;\n    let scale = 0;\n    let shake = 0;\n    let turnBy = 0;\n\n    const size = () => {\n      const next = clamp((canvas.clientWidth / CW) * Math.min(2, window.devicePixelRatio || 1), 1, 3);\n      if (Math.abs(next - scale) < 0.01) return;\n      scale = next;\n      canvas.width = Math.round(CW * scale);\n      canvas.height = Math.round(CH * scale);\n    };\n\n    const paint = (now: number) => {\n      raf = 0;\n      size();\n      const dt = Math.min(0.04, (now - (last || now)) / 1000);\n      last = now;\n      const t = now / 1000;\n      const age = (now - s.since) / 1000;\n      const ringing = s.mode === \"ringing\";\n      // it buzzes in bursts, and every burst walks it a little further round\n      const burst = ringing && !reduce && age % 1.5 < 0.9;\n      shake += ((burst ? 1 : 0) - shake) * Math.min(1, dt * 18);\n      if (burst) turnBy += dt;\n      const ox = shake * (Math.sin(t * 92) * 1.15 + Math.sin(t * 57) * 0.5) + Math.sin(turnBy * 0.9) * 7;\n      const oy = shake * Math.cos(t * 113) * 0.6 + Math.cos(turnBy * 0.7) * 2 - 2;\n      const phi = Math.sin(turnBy * 0.8) * 0.16;\n\n      for (let i = 0; i < LEDS; i++) {\n        let want = 0;\n        const at = i / LEDS;\n        if (ringing) {\n          if (reduce) want = 0.8;\n          else {\n            const head = (t * 1.25) % 1;\n            const d1 = (head - at + 1) % 1;\n            const d2 = (head + 0.5 - at + 1) % 1;\n            want = 0.1 + Math.max(Math.exp(-d1 * 9), Math.exp(-d2 * 9));\n          }\n        } else if (s.mode === \"waiting\") {\n          const head = reduce ? 0.25 : (t * 0.3) % 1;\n          want = 0.03 + 0.5 * Math.exp(-((head - at + 1) % 1) * 7);\n        }\n        glow[i] += (want - glow[i]) * (reduce ? 1 : Math.min(1, dt * (want > glow[i] ? 40 : 9)));\n      }\n      let total = 0;\n      for (let i = 0; i < LEDS; i++) total += glow[i];\n      total /= LEDS;\n\n      ctx.setTransform(scale, 0, 0, scale, 0, 0);\n      ctx.clearRect(0, 0, CW, CH);\n      ctx.imageSmoothingQuality = \"high\";\n      const cx = CX + ox;\n      const fy = FOOT + oy;\n\n      // its shadow on the stone\n      ctx.save();\n      ctx.translate(cx + 8, fy + 5);\n      ctx.scale(1, SIN);\n      const shade = ctx.createRadialGradient(0, 0, R * 0.7, 0, 0, R * 1.42);\n      shade.addColorStop(0, \"rgba(0,0,0,0.95)\");\n      shade.addColorStop(0.55, \"rgba(0,0,0,0.5)\");\n      shade.addColorStop(1, \"rgba(0,0,0,0)\");\n      ctx.fillStyle = shade;\n      ctx.beginPath();\n      ctx.arc(0, 0, R * 1.42, 0, Math.PI * 2);\n      ctx.fill();\n      ctx.restore();\n\n      // red light thrown across the table by each lamp, and its streak in the polish\n      ctx.globalCompositeOperation = \"lighter\";\n      const lamp = (i: number) => {\n        const a = (i / LEDS) * Math.PI * 2 + phi;\n        return { c: Math.cos(a), s: Math.sin(a) };\n      };\n      for (let i = 0; i < LEDS; i++) {\n        const v = glow[i];\n        if (v < 0.02) continue;\n        const { c, s: sn } = lamp(i);\n        ctx.save();\n        ctx.translate(cx + c * (R + 30), fy + sn * (R + 30) * SIN);\n        ctx.scale(1, SIN);\n        const pool = ctx.createRadialGradient(0, 0, 0, 0, 0, 104);\n        pool.addColorStop(0, `rgba(255,44,30,${(0.3 * v).toFixed(3)})`);\n        pool.addColorStop(0.4, `rgba(220,20,24,${(0.12 * v).toFixed(3)})`);\n        pool.addColorStop(1, \"rgba(160,0,10,0)\");\n        ctx.fillStyle = pool;\n        ctx.beginPath();\n        ctx.arc(0, 0, 104, 0, Math.PI * 2);\n        ctx.fill();\n        ctx.restore();\n        if (sn > 0.05) {\n          const lx = cx + c * R;\n          const ly = fy + sn * R * SIN + LED_H * COS * 0.9;\n          ctx.save();\n          ctx.translate(lx, ly + 3);\n          ctx.scale(1, 3.4);\n          const streak = ctx.createRadialGradient(0, 0, 0, 0, 0, 13);\n          streak.addColorStop(0, `rgba(255,90,64,${(0.42 * v * sn).toFixed(3)})`);\n          streak.addColorStop(0.5, `rgba(255,40,30,${(0.12 * v * sn).toFixed(3)})`);\n          streak.addColorStop(1, \"rgba(255,40,30,0)\");\n          ctx.fillStyle = streak;\n          ctx.beginPath();\n          ctx.arc(0, 0, 13, 0, Math.PI * 2);\n          ctx.fill();\n          ctx.restore();\n        }\n      }\n      ctx.globalCompositeOperation = \"source-over\";\n\n      ctx.drawImage(body, ox, oy, CW, CH);\n\n      // the lamps themselves, behind the red band\n      ctx.globalCompositeOperation = \"lighter\";\n      for (let i = 0; i < LEDS; i++) {\n        const v = glow[i];\n        if (v < 0.02) continue;\n        const { c, s: sn } = lamp(i);\n        const front = sn > -0.08;\n        const lx = cx + c * (R + 1);\n        const ly = fy - LED_H * COS + sn * R * SIN - (front ? 0 : 7);\n        const k = front ? v : v * 0.4;\n        const halo = ctx.createRadialGradient(lx, ly, 0, lx, ly, 34);\n        halo.addColorStop(0, `rgba(255,70,50,${(0.85 * k).toFixed(3)})`);\n        halo.addColorStop(0.3, `rgba(255,24,24,${(0.4 * k).toFixed(3)})`);\n        halo.addColorStop(1, \"rgba(200,0,10,0)\");\n        ctx.fillStyle = halo;\n        ctx.beginPath();\n        ctx.arc(lx, ly, 34, 0, Math.PI * 2);\n        ctx.fill();\n        if (front) {\n          const core = ctx.createRadialGradient(lx, ly, 0, lx, ly, 7);\n          core.addColorStop(0, `rgba(255,236,220,${Math.min(1, v * 1.2).toFixed(3)})`);\n          core.addColorStop(1, \"rgba(255,90,60,0)\");\n          ctx.fillStyle = core;\n          ctx.beginPath();\n          ctx.ellipse(lx, ly, 8, 4.6, 0, 0, Math.PI * 2);\n          ctx.fill();\n        }\n      }\n      ctx.globalCompositeOperation = \"source-over\";\n\n      // the top of the pager, drawn flat and laid back at the same angle as the body\n      ctx.save();\n      ctx.translate(cx, fy - TOP_H * COS + 0.5);\n      ctx.scale(1, SIN);\n      ctx.rotate(phi);\n      const well = ctx.createLinearGradient(0, -76, 0, 76);\n      well.addColorStop(0, \"#08080a\");\n      well.addColorStop(1, \"#1d1d21\");\n      ctx.fillStyle = well;\n      ctx.beginPath();\n      ctx.arc(0, 0, 76, 0, Math.PI * 2);\n      ctx.fill();\n      ctx.lineWidth = 1.6;\n      ctx.strokeStyle = \"rgba(0,0,0,0.9)\";\n      ctx.beginPath();\n      ctx.arc(0, 0, 76.5, Math.PI * 1.05, Math.PI * 1.95);\n      ctx.stroke();\n      ctx.strokeStyle = \"rgba(255,255,255,0.32)\";\n      ctx.beginPath();\n      ctx.arc(0, 0, 76.5, Math.PI * 0.12, Math.PI * 0.88);\n      ctx.stroke();\n      ctx.strokeStyle = `rgba(255,60,44,${(0.34 * total).toFixed(3)})`;\n      ctx.lineWidth = 2.4;\n      ctx.beginPath();\n      ctx.arc(0, 0, 114, 0, Math.PI * 2);\n      ctx.stroke();\n      // lettering round the rim\n      ctx.fillStyle = \"rgba(235,235,230,0.62)\";\n      ctx.font = \"600 6.6px ui-monospace, SFMono-Regular, Menlo, monospace\";\n      ctx.textAlign = \"center\";\n      ctx.textBaseline = \"middle\";\n      const rim = \"PLEASE BRING ME BACK TO THE HOST STAND\";\n      for (let i = 0; i < rim.length; i++) {\n        const a = Math.PI / 2 + (rim.length / 2 - i - 0.5) * 0.079;\n        ctx.save();\n        ctx.translate(Math.cos(a) * 67.5, Math.sin(a) * 67.5);\n        ctx.rotate(a - Math.PI / 2);\n        ctx.fillText(rim[i], 0, 0);\n        ctx.restore();\n      }\n      // the display\n      const dw = COLS * 3 + 7;\n      ctx.fillStyle = \"#030202\";\n      ctx.beginPath();\n      ctx.rect(-dw / 2, -45, dw, 30);\n      ctx.fill();\n      ctx.strokeStyle = \"rgba(255,255,255,0.2)\";\n      ctx.lineWidth = 1;\n      ctx.strokeRect(-dw / 2 + 0.5, -44.5, dw - 1, 29);\n      const cols = ringing ? texts[s.page] : words[s.mode as \"answered\" | \"waiting\"];\n      const shift = ringing ? (reduce ? 0 : Math.floor(Math.max(0, age - 3.2) * 13) % cols.length) : -Math.floor((COLS - cols.length) / 2);\n      for (let c = 0; c < COLS; c++) {\n        const at = ringing ? (c + shift) % cols.length : c + shift;\n        const col = at >= 0 && at < cols.length ? cols[at] : 0;\n        for (let r = 0; r < 7; r++) {\n          const on = (col >> r) & 1;\n          ctx.fillStyle = on ? \"#ffc247\" : \"rgba(120,74,14,0.26)\";\n          if (on) {\n            ctx.shadowColor = \"rgba(255,150,30,0.9)\";\n            ctx.shadowBlur = 4 * scale;\n          }\n          ctx.fillRect(-dw / 2 + 4 + c * 3, -42 + r * 3.55, 2.1, 2.6);\n          ctx.shadowBlur = 0;\n        }\n      }\n      // the number\n      ctx.fillStyle = \"#f4f3ee\";\n      ctx.font = \"800 50px ui-sans-serif, system-ui, -apple-system, Helvetica, Arial, sans-serif\";\n      ctx.fillText(NUMBER, 0, 19);\n      ctx.fillStyle = \"rgba(244,243,238,0.6)\";\n      ctx.font = \"700 7.5px ui-monospace, SFMono-Regular, Menlo, monospace\";\n      ctx.fillText(\"G U E S T\", 0, 48);\n      ctx.restore();\n\n      if (!reduce && s.seen && !document.hidden) raf = requestAnimationFrame(paint);\n      else last = 0;\n    };\n    const kick = () => {\n      if (!raf) raf = requestAnimationFrame(paint);\n    };\n    s.kick = kick;\n    kick();\n    const io = new IntersectionObserver(([e]) => {\n      s.seen = e.isIntersecting;\n      if (s.seen) kick();\n    });\n    io.observe(canvas);\n    const ro = new ResizeObserver(kick);\n    ro.observe(canvas);\n    document.addEventListener(\"visibilitychange\", kick);\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n      ro.disconnect();\n      document.removeEventListener(\"visibilitychange\", kick);\n      s.kick = () => {};\n    };\n  }, [reduce]);\n\n  const now = pages[page];\n  const line = mode === \"ringing\" ? now.title : mode === \"answered\" ? \"Answered. Thank you\" : \"Waiting for the next page\";\n  const hint = mode === \"ringing\" ? \"Press the pager to answer it\" : \"Press the pager to buzz it again\";\n\n  return (\n    <section\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" && live.current.mode === \"ringing\") {\n          live.current.touched = true;\n          go(\"answered\");\n        }\n      }}\n      className=\"relative h-[600px] overflow-hidden bg-[#0b090a] sm:h-[700px]\"\n    >\n      {/* a black stone table under one warm lamp */}\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(58% 46% at 50% 44%, #2a2224 0%, #171213 44%, #0a0809 100%)\" }} />\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 opacity-[0.13] mix-blend-screen\" style={{ backgroundImage: STONE, backgroundSize: \"420px 420px\" }} />\n\n      <div className=\"absolute left-1/2 top-[40px] h-[400px] w-[560px] -translate-x-1/2 sm:top-[-28px] sm:h-[680px] sm:w-[952px]\">\n        <canvas ref={canvasRef} aria-hidden=\"true\" className=\"h-full w-full\" />\n        <button\n          type=\"button\"\n          onClick={press}\n          aria-label={mode === \"ringing\" ? `Pager ${NUMBER} is buzzing: ${now.title}. Answer it` : `Pager ${NUMBER} is quiet. Buzz it with the next message`}\n          className=\"absolute left-[28%] top-[41%] h-[41%] w-[44%] cursor-pointer rounded-[50%] outline-none focus-visible:ring-2 focus-visible:ring-[#ffc247] focus-visible:ring-offset-4 focus-visible:ring-offset-[#0b090a]\"\n        />\n      </div>\n\n      <div className=\"absolute inset-x-5 bottom-6 sm:inset-x-8 sm:bottom-8\">\n        <p className=\"font-mono text-[11px] uppercase leading-relaxed tracking-[0.18em] text-[#c9b8b0]\">\n          <span className=\"text-white\">\n            Pager {NUMBER} / {line}\n          </span>\n          <span className=\"block\">{mode === \"ringing\" ? now.detail : hint}</span>\n          {mode === \"ringing\" && <span className=\"block text-[#ff8a70]\">{hint}, or press Escape</span>}\n        </p>\n      </div>\n      <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n        {mode === \"ringing\" ? `Pager ${NUMBER}: ${now.title}. ${now.detail}` : mode === \"answered\" ? \"Pager answered.\" : \"\"}\n      </p>\n    </section>\n  );\n}\n"}]}
