{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "geo-timezones",
  "title": "Meeting planner",
  "description": "A meeting planner: one row of hour blocks per city, dense for working hours, with the hours every city shares lit as an accent band.",
  "registryDependencies": [
    "https://elements.lumesec.ai/r/lumesec-theme.json",
    "https://elements.lumesec.ai/r/lumesec-canvas.json",
    "https://elements.lumesec.ai/r/lumesec-color.json",
    "https://elements.lumesec.ai/r/lumesec-geo.json",
    "https://elements.lumesec.ai/r/lumesec-geo-data.json",
    "https://elements.lumesec.ai/r/lumesec-math.json",
    "https://elements.lumesec.ai/r/lumesec-motion.json",
    "https://elements.lumesec.ai/r/lumesec-roll-text.json",
    "https://elements.lumesec.ai/r/lumesec-use-controllable-state.json",
    "utils"
  ],
  "files": [
    {
      "path": "registry/components/lumesec/geo-timezones.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { snap, useCanvas, type CanvasSurface } from \"@/lib/lumesec/canvas\";\nimport { usePalette } from \"@/lib/lumesec/color\";\nimport {\n  bayer4,\n  createDotBatch,\n  GEO_TOKENS,\n  geoInk,\n  ringFront,\n  type DotBatch,\n  type GeoInk,\n  type GeoPalette,\n} from \"@/lib/lumesec/geo\";\nimport {\n  formatUtcOffset,\n  formatWeekday,\n  formatZonedTime,\n  isValidTimeZone,\n  startOfZonedDay,\n  useNow,\n  utcOffsetMinutes,\n  zonedParts,\n  type ZonedParts,\n} from \"@/lib/lumesec/geo-data\";\nimport { clamp, easeOutCubic, hash, lerp, mixRgb, rgba, stringHash } from \"@/lib/lumesec/math\";\nimport {\n  prefersReducedMotion,\n  springStep,\n  useAnimationLoop,\n  useLazyRef,\n  useReducedMotion,\n  type Spring,\n} from \"@/lib/lumesec/motion\";\nimport { RollText } from \"@/lib/lumesec/roll-text\";\nimport { useControllableState } from \"@/lib/lumesec/use-controllable-state\";\nimport { cn } from \"@/lib/utils\";\n\n/** One row of the planner: a city and the IANA time zone its local time comes from. */\nexport interface TimeZoneCity {\n  /** Unique id, used as the React key and by `reference`. Rows with a repeated id are skipped. */\n  readonly id: string;\n  /** Name shown in the row and in the slider's value text, for example `London`. */\n  readonly label: string;\n  /** IANA time zone, for example `Europe/London`. An unknown zone falls back to UTC and the row says \"(UTC)\". */\n  readonly timeZone: string;\n}\n\n/** Props of GeoTimezones. Every other `div` prop goes to the root element. */\nexport interface GeoTimezonesProps extends Omit<React.ComponentProps<\"div\">, \"defaultValue\" | \"onChange\"> {\n  /** The rows (controlled). Use with `onCitiesChange`. An empty array shows an empty state. */\n  cities?: readonly TimeZoneCity[];\n  /** The rows when uncontrolled. Default: London, Berlin, New York and São Paulo, which share two working hours all year. */\n  defaultCities?: readonly TimeZoneCity[];\n  /** Called with the remaining rows when the user removes one. */\n  onCitiesChange?: (cities: readonly TimeZoneCity[]) => void;\n  /** The cursor instant in epoch ms (controlled). Use with `onValueChange`. */\n  value?: number;\n  /** The cursor instant when uncontrolled. Default: the current time rounded to `step`, read once after mount. */\n  defaultValue?: number;\n  /** Called with the new instant in epoch ms as the cursor moves (snapped to `step`). */\n  onValueChange?: (value: number) => void;\n  /** Id of the city whose local midnight starts the window and whose hours label the axis. Default: the first city. */\n  reference?: string;\n  /** Working hours in local time, `[from, to)`. Default `[9, 17]`. A range may wrap past midnight. */\n  workHours?: readonly [number, number];\n  /** Sleeping hours in local time, `[from, to)`. Default `[23, 7]`, which wraps past midnight. */\n  sleepHours?: readonly [number, number];\n  /** Cursor step in minutes, 1 to 180. Default 15. */\n  step?: number;\n  /** Shows times on a 12-hour clock. */\n  hour12?: boolean;\n  /** Shows a remove button on every row. */\n  removable?: boolean;\n  /** BCP 47 locale for the weekday names. Default `en-US`. */\n  locale?: string;\n  /** Accessible name of the time cursor. Default \"Meeting time\". */\n  label?: string;\n}\n\n/**\n * A meeting planner: several cities on one time line, one row per city, with each local hour drawn as a block of\n * dots, dense for working hours and sparse for the night. Hours when every city is at work light up as an accent band\n * across all rows. Drag the cursor (or use the arrow keys) and every city's local time rolls with it; when the cursor\n * enters the band, a light runs down through it and bursts out at the bottom. The window is one local day of the\n * reference city, and offsets come from the time zone database, so daylight saving time and half-hour zones are exact.\n *\n * @example\n * <GeoTimezones\n *   defaultCities={[\n *     { id: \"lon\", label: \"London\", timeZone: \"Europe/London\" },\n *     { id: \"nyc\", label: \"New York\", timeZone: \"America/New_York\" },\n *   ]}\n *   onValueChange={(time) => setMeeting(new Date(time))}\n * />\n */\nexport function GeoTimezones({\n  cities,\n  defaultCities,\n  onCitiesChange,\n  value,\n  defaultValue,\n  onValueChange,\n  reference,\n  workHours = WORK_HOURS,\n  sleepHours = SLEEP_HOURS,\n  step = 15,\n  hour12 = false,\n  removable = false,\n  locale,\n  label = \"Meeting time\",\n  className,\n  ...props\n}: GeoTimezonesProps) {\n  const reducedMotion = useReducedMotion();\n  const [cityList, setCityList] = useControllableState<readonly TimeZoneCity[]>({\n    value: cities,\n    defaultValue: defaultCities ?? DEMO_CITIES,\n    onChange: onCitiesChange,\n  });\n  const rows = React.useMemo(() => resolveCities(cityList), [cityList]);\n\n  const stepMinutes = Number.isFinite(step) ? clamp(Math.round(step), 1, 180) : 15;\n  const stepMs = stepMinutes * MINUTE;\n  const [workFrom, workTo] = workHours;\n  const [sleepFrom, sleepTo] = sleepHours;\n\n  // The cursor: the controlled value, else the stored one, else the clock read once after mount (null before).\n  const clockAfterMount = useNow(0, value === undefined && defaultValue === undefined);\n  const [stored, setStored] = useControllableState<number | null>({\n    value: value === undefined ? undefined : Number.isFinite(value) ? value : null,\n    defaultValue: defaultValue !== undefined && Number.isFinite(defaultValue) ? defaultValue : null,\n    onChange: (next) => {\n      if (next !== null) onValueChange?.(next);\n    },\n  });\n  const cursor = stored ?? (clockAfterMount === null ? null : Math.round(clockAfterMount / stepMs) * stepMs);\n\n  /** Rows on screen: the cities, plus removed rows while they collapse. */\n  const [presence, setPresence] = React.useState<Presence>(() => ({\n    source: rows,\n    items: rows.map((row) => ({ row, entering: false, leaving: false })),\n  }));\n  if (presence.source !== rows) {\n    setPresence({ source: rows, items: mergePresence(presence.items, rows, reducedMotion) });\n  }\n\n  const referenceRow = rows.find((row) => row.id === reference) ?? rows[0] ?? null;\n  const referenceZone = referenceRow?.zone ?? \"UTC\";\n  const start = cursor === null || !referenceRow ? null : startOfZonedDay(referenceZone, cursor);\n  const end = start === null ? null : windowEnd(referenceZone, start);\n  const span = start !== null && end !== null ? end - start : DAY;\n  /** The last step inside the window (23:45 with 15-minute steps). */\n  const lastOffset = Math.floor((span - 1) / stepMs) * stepMs;\n  const lastTime = start === null ? null : start + lastOffset;\n\n  const models = React.useMemo(() => {\n    const map = new Map<string, RowModel>();\n    if (start === null || end === null) return map;\n    const rules: HourRules = { workFrom, workTo, sleepFrom, sleepTo };\n    for (const item of presence.items) map.set(item.row.id, buildRowModel(item.row, start, end, rules, locale));\n    return map;\n  }, [presence.items, start, end, workFrom, workTo, sleepFrom, sleepTo, locale]);\n\n  const overlap = React.useMemo(() => computeOverlap(rows, models, start, end), [rows, models, start, end]);\n  const ticks = React.useMemo(\n    () => (start === null || end === null ? genericTicks(hour12) : windowTicks(referenceZone, start, end, hour12)),\n    [referenceZone, start, end, hour12],\n  );\n\n  // Times roll in the direction the cursor moved.\n  const [roll, setRoll] = React.useState<{ cursor: number | null; direction: number }>({ cursor, direction: 1 });\n  if (roll.cursor !== cursor) {\n    setRoll({ cursor, direction: cursor !== null && roll.cursor !== null && cursor < roll.cursor ? -1 : 1 });\n  }\n\n  const contentRef = React.useRef<HTMLDivElement>(null);\n  const rowsRef = React.useRef<HTMLDivElement>(null);\n  const stripRef = React.useRef<HTMLCanvasElement>(null);\n  const effectsRef = React.useRef<HTMLCanvasElement>(null);\n  const sliderRef = React.useRef<HTMLDivElement>(null);\n  const cursorRef = React.useRef<HTMLDivElement>(null);\n  const chipRef = React.useRef<HTMLSpanElement>(null);\n  const rowRefs = React.useRef(new Map<string, HTMLDivElement>());\n  const removeRefs = React.useRef(new Map<string, HTMLButtonElement>());\n  /** The motion state, created on first use (effects, handlers and the loop), never during a render. */\n  const engineRef = useLazyRef(() => createEngine());\n\n  const loop = useAnimationLoop(contentRef, frame);\n  const palette = usePalette(contentRef, GEO_TOKENS, () => loop.kick());\n  const strip = useCanvas(stripRef, () => loop.kick(), CANVAS_OPTIONS);\n  const effects = useCanvas(effectsRef, () => loop.kick(), CANVAS_OPTIONS);\n\n  // A cursor that changes from outside (or a window that moves) springs the line to its place.\n  React.useEffect(() => {\n    if (cursor === null || start === null) return;\n    const engine = engineRef.current;\n    const fraction = clamp((cursor - start) / span, 0, 1);\n    engine.latest = cursor;\n    if (!engine.dragging) engine.cursor.target = fraction;\n    if (!engine.ready || prefersReducedMotion()) {\n      engine.cursor.position = engine.cursor.target;\n      engine.cursor.velocity = 0;\n    }\n    engine.ready = true;\n    loop.kick();\n  }, [cursor, start, span, engineRef, loop]);\n\n  // A new band fills from the top; the one it replaces drains from the top.\n  React.useEffect(() => {\n    const band = engineRef.current.band;\n    if (band.key === overlap.key) return;\n    band.previous = band.current;\n    band.previousFill = band.fill;\n    band.current = overlap.intervals;\n    band.key = overlap.key;\n    band.fill = 0;\n    band.drain = 0;\n    loop.kick();\n  }, [overlap, engineRef, loop]);\n\n  React.useEffect(() => {\n    loop.kick();\n  }, [models, reducedMotion, loop]);\n\n  const registerRow = React.useCallback((id: string, node: HTMLDivElement | null) => {\n    if (node) rowRefs.current.set(id, node);\n    else rowRefs.current.delete(id);\n  }, []);\n  const registerRemove = React.useCallback((id: string, node: HTMLButtonElement | null) => {\n    if (node) removeRefs.current.set(id, node);\n    else removeRefs.current.delete(id);\n  }, []);\n  const handleRowMotion = React.useCallback(\n    (ms: number) => {\n      const engine = engineRef.current;\n      engine.animatingUntil = Math.max(engine.animatingUntil, performance.now() + ms);\n      loop.kick();\n    },\n    [engineRef, loop],\n  );\n  const handleRowExited = React.useCallback((id: string) => {\n    setPresence((current) => ({\n      ...current,\n      items: current.items.filter((item) => !(item.leaving && item.row.id === id)),\n    }));\n  }, []);\n\n  function frame(time: number, delta: number) {\n    const engine = engineRef.current;\n    const ms = time * 1000;\n    const reduced = prefersReducedMotion();\n    const colors = palette.current;\n    if (colors && colors !== engine.palette) {\n      engine.palette = colors;\n      engine.ink = geoInk(colors);\n      const ramp = [engine.ink.land, engine.ink.landStrong, engine.ink.accent, engine.ink.glint];\n      if (engine.batch) engine.batch.setRamp(ramp);\n      else engine.batch = createDotBatch(4096, ramp, { tones: TONES, levels: 16 });\n    }\n\n    // Rows are measured every frame, so the canvas follows rows that grow in or collapse.\n    const items = presence.items;\n    engine.tops.length = 0;\n    engine.heights.length = 0;\n    for (const item of items) {\n      const element = rowRefs.current.get(item.row.id);\n      engine.tops.push(element ? element.offsetTop : 0);\n      engine.heights.push(element ? element.offsetHeight : 0);\n    }\n    engine.rowsOffset = rowsRef.current?.offsetTop ?? 0;\n\n    const cursorSpring = engine.cursor;\n    if (reduced) {\n      cursorSpring.position = cursorSpring.target;\n      cursorSpring.velocity = 0;\n    } else {\n      springStep(cursorSpring, cursorSpring.target, delta, 520, 0.72);\n    }\n    let moving = !settled(cursorSpring, cursorSpring.target);\n\n    // Each row's highlight trails the cursor on its own spring, so the lit column bends behind fast drags.\n    for (let i = 0; i < items.length; i++) {\n      const id = items[i].row.id;\n      let highlight = engine.highlights.get(id);\n      if (!highlight) {\n        highlight = { position: cursorSpring.position, velocity: 0 };\n        engine.highlights.set(id, highlight);\n      }\n      if (reduced) {\n        highlight.position = cursorSpring.position;\n        highlight.velocity = 0;\n      } else {\n        springStep(highlight, cursorSpring.position, delta, 300 + i * 40, 0.8);\n      }\n      if (!settled(highlight, cursorSpring.position)) moving = true;\n    }\n    if (engine.highlights.size > items.length) {\n      for (const id of engine.highlights.keys())\n        if (!items.some((item) => item.row.id === id)) engine.highlights.delete(id);\n    }\n\n    const glowTarget = engine.dragging ? 1 : engine.focused ? 0.7 : REST_GLOW;\n    if (reduced) {\n      engine.glow.position = glowTarget;\n      engine.glow.velocity = 0;\n    } else {\n      springStep(engine.glow, glowTarget, delta, 170, 1);\n    }\n    if (!settled(engine.glow, glowTarget)) moving = true;\n\n    const band = engine.band;\n    band.fill = reduced ? 1 : Math.min(1, band.fill + delta / FILL_SECONDS);\n    band.drain = reduced ? 1 : Math.min(1, band.drain + delta / DRAIN_SECONDS);\n\n    // The light runs down the band when the line enters it (not when the band appears around the line).\n    const inside = engine.ready && intervalsContain(band.current, cursorSpring.position);\n    if (inside && !engine.inBand && band.fill >= 1 && !reduced) {\n      engine.sweepStart = ms;\n      engine.sparksFired = false;\n      popChip(chipRef.current);\n    }\n    engine.inBand = inside;\n\n    const stripSurface = strip.current;\n    const cursorElement = cursorRef.current;\n    if (cursorElement && stripSurface) {\n      cursorElement.style.transform = `translate3d(${(cursorSpring.position * stripSurface.width).toFixed(2)}px,0,0)`;\n      cursorElement.style.opacity = engine.ready ? \"1\" : \"0\";\n    }\n\n    const ink = engine.ink;\n    const batch = engine.batch;\n    const scene: Scene = { items, models, span };\n    if (stripSurface && ink && batch) drawStrip(stripSurface, batch, ink, scene, engine, ms, reduced);\n\n    const effectsSurface = effects.current;\n    const sparksAlive =\n      effectsSurface && ink && stripSurface\n        ? drawEffects(effectsSurface, ink, engine, stripSurface.width, ms, delta)\n        : false;\n\n    const sweeping = engine.sweepStart >= 0 && ms - engine.sweepStart < SWEEP_MS + 100;\n    const ambient = !reduced && band.current.length > 0 && engine.ready;\n    return (\n      moving || band.fill < 1 || band.drain < 1 || sweeping || sparksAlive || ms < engine.animatingUntil || ambient\n    );\n  }\n\n  const fractionOf = (time: number) => (start === null ? 0 : clamp((time - start) / span, 0, 1));\n\n  function snapTime(time: number) {\n    if (start === null || lastTime === null) return time;\n    return clamp(start + Math.round((time - start) / stepMs) * stepMs, start, lastTime);\n  }\n\n  function commit(time: number) {\n    engineRef.current.latest = time;\n    setStored(time);\n  }\n\n  function dragTo(element: HTMLElement, clientX: number, release: boolean) {\n    if (start === null || lastTime === null) return;\n    const engine = engineRef.current;\n    const rect = element.getBoundingClientRect();\n    const fraction = rect.width > 0 ? clamp((clientX - rect.left) / rect.width, 0, 1) : 0;\n    const time = snapTime(start + fraction * span);\n    // the line follows the pointer while dragging and settles on the step on release\n    engine.cursor.target = release ? fractionOf(time) : Math.min(fraction, fractionOf(lastTime));\n    commit(time);\n    loop.kick();\n  }\n\n  function handlePointerDown(event: React.PointerEvent<HTMLDivElement>) {\n    if (event.button !== 0 || start === null) return;\n    event.preventDefault();\n    const element = event.currentTarget;\n    element.focus({ preventScroll: true });\n    element.setPointerCapture(event.pointerId);\n    element.setAttribute(\"data-dragging\", \"\");\n    engineRef.current.dragging = true;\n    dragTo(element, event.clientX, false);\n  }\n\n  function handlePointerMove(event: React.PointerEvent<HTMLDivElement>) {\n    if (engineRef.current.dragging) dragTo(event.currentTarget, event.clientX, false);\n  }\n\n  function handlePointerUp(event: React.PointerEvent<HTMLDivElement>) {\n    const engine = engineRef.current;\n    if (!engine.dragging) return;\n    engine.dragging = false;\n    const element = event.currentTarget;\n    element.removeAttribute(\"data-dragging\");\n    if (element.hasPointerCapture(event.pointerId)) element.releasePointerCapture(event.pointerId);\n    if (event.type === \"pointercancel\") {\n      // the page took the gesture (a vertical scroll): settle on the last committed time\n      if (engine.latest !== null) engine.cursor.target = fractionOf(engine.latest);\n      loop.kick();\n      return;\n    }\n    dragTo(element, event.clientX, true);\n  }\n\n  function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (start === null || lastTime === null) return;\n    const move = keyMove(event.key, event.shiftKey, stepMs);\n    if (move === null) return;\n    event.preventDefault();\n    const engine = engineRef.current;\n    // from the latest committed time, so presses that arrive before a re-render still add up\n    const base = engine.latest ?? cursor ?? start;\n    let time: number;\n    if (move === \"start\") time = start;\n    else if (move === \"end\") time = lastTime;\n    else {\n      // an off-grid time first moves to the grid point in the direction of the key\n      const steps = (base - start) / stepMs;\n      const aligned = start + (move > 0 ? Math.floor(steps) : Math.ceil(steps)) * stepMs;\n      time = clamp(aligned + move, start, lastTime);\n    }\n    engine.cursor.target = fractionOf(time);\n    if (prefersReducedMotion()) engine.cursor.position = engine.cursor.target;\n    commit(time);\n    loop.kick();\n  }\n\n  function removeCity(id: string) {\n    const index = rows.findIndex((row) => row.id === id);\n    const remaining = rows.filter((row) => row.id !== id);\n    // focus moves before the row turns inert: to the next row's button, else the previous one, else the cursor\n    const neighbour = remaining[index] ?? remaining[index - 1];\n    const target =\n      (neighbour && removeRefs.current.get(neighbour.id)) ?? (remaining.length > 0 ? sliderRef.current : null);\n    target?.focus({ preventScroll: true });\n    setCityList(cityList.filter((city) => city.id !== id));\n  }\n\n  const clocks = presence.items.map((item) => clockText(item.row.zone, cursor, hour12, locale));\n  const valueText =\n    cursor === null\n      ? undefined\n      : rows.map((row) => `${formatZonedTime(row.zone, cursor, { hour12 })} ${row.label}`).join(\", \");\n  const referenceLabel = referenceRow?.label ?? \"\";\n  const rangeText = overlap.ranges\n    .map(\n      (range) =>\n        `${formatZonedTime(referenceZone, range.from, { hour12 })}–${formatZonedTime(referenceZone, range.to, { hour12 })}`,\n    )\n    .join(\", \");\n  const status: OverlapStatus =\n    rows.length === 0 || start === null ? \"idle\" : rows.length === 1 ? \"single\" : overlap.minutes > 0 ? \"band\" : \"none\";\n  const announcement =\n    status === \"band\"\n      ? `Overlap ${rangeText} ${referenceLabel} time`\n      : status === \"none\"\n        ? \"No common working hours\"\n        : \"\";\n  const empty = presence.items.length === 0;\n\n  return (\n    <div\n      data-slot=\"geo-timezones\"\n      className={cn(\n        \"@container w-full max-w-[660px] rounded-[14px] border border-border bg-card p-3 text-card-foreground shadow-[0_14px_34px_-20px_rgb(0_0_0/0.4)] [-webkit-tap-highlight-color:transparent]\",\n        className,\n      )}\n      {...props}\n    >\n      <div\n        ref={contentRef}\n        className={cn(\n          \"grid gap-1.5\",\n          hour12 ? \"[--col:150px] @max-[480px]:[--col:118px]\" : \"[--col:132px] @max-[480px]:[--col:104px]\",\n        )}\n      >\n        <div aria-hidden=\"true\" className=\"flex h-7 min-w-0 items-center gap-2\">\n          {status === \"band\" ? (\n            <>\n              <OverlapChip ref={chipRef} minutes={overlap.minutes} animate={!reducedMotion} />\n              <span className=\"min-w-0 truncate text-[12.5px] leading-4 text-muted-foreground\">\n                <span className=\"font-mono tabular-nums\">{rangeText}</span> {referenceLabel} time\n              </span>\n            </>\n          ) : status === \"none\" ? (\n            <span className=\"truncate text-[12.5px] leading-4 text-muted-foreground\">No common working hours</span>\n          ) : status === \"single\" ? (\n            <span className=\"truncate text-[12.5px] leading-4 text-muted-foreground\">\n              Common hours need two or more cities\n            </span>\n          ) : null}\n        </div>\n        <span className=\"sr-only\" aria-live=\"polite\">\n          {announcement}\n        </span>\n\n        {/* the canvases stay mounted when the list is empty, so they keep their size observers */}\n        <div className=\"relative select-none\">\n          <div\n            aria-hidden=\"true\"\n            className={cn(\"grid h-[22px] grid-cols-[var(--col)_minmax(0,1fr)]\", empty && \"hidden\")}\n          >\n            <span className=\"self-end truncate pr-2 pb-1 text-[11px] leading-[14px] text-muted-foreground\">\n              {referenceLabel} time\n            </span>\n            <div className=\"relative\">\n              {ticks.map((tick, i) => (\n                <span\n                  key={tick.at}\n                  className={cn(\"absolute inset-y-0 flex items-end\", i % 2 === 1 && \"@max-[480px]:hidden\")}\n                  style={{ left: `${(tick.at * 100).toFixed(3)}%` }}\n                >\n                  <span className=\"absolute bottom-0 left-0 h-[5px] w-px bg-border\" />\n                  <span className=\"pb-1 pl-[3px] font-mono text-[10.5px] leading-3 whitespace-nowrap text-muted-foreground tabular-nums\">\n                    {tick.text}\n                  </span>\n                </span>\n              ))}\n            </div>\n          </div>\n\n          <div\n            ref={rowsRef}\n            role={empty ? undefined : \"list\"}\n            aria-label={empty ? undefined : \"Cities\"}\n            className=\"relative\"\n          >\n            <canvas\n              ref={stripRef}\n              aria-hidden=\"true\"\n              className=\"pointer-events-none absolute inset-y-0 right-0 left-[var(--col)] block h-full w-[calc(100%-var(--col))]\"\n            />\n            {presence.items.map((item, i) => (\n              <TimezoneRow\n                key={item.row.id}\n                item={item}\n                model={models.get(item.row.id)}\n                clock={clocks[i]}\n                direction={roll.direction}\n                animate={!reducedMotion}\n                hour12={hour12}\n                removable={removable}\n                onRemove={removeCity}\n                onExited={handleRowExited}\n                onMotion={handleRowMotion}\n                registerRow={registerRow}\n                registerRemove={registerRemove}\n              />\n            ))}\n          </div>\n          {empty ? (\n            <div className=\"grid h-[88px] place-items-center rounded-[10px] border border-dashed border-border text-[12.5px] text-muted-foreground\">\n              No cities to compare\n            </div>\n          ) : null}\n\n          {rows.length > 0 ? (\n            <div\n              ref={sliderRef}\n              role=\"slider\"\n              tabIndex={0}\n              aria-label={label}\n              aria-orientation=\"horizontal\"\n              aria-valuemin={0}\n              aria-valuemax={Math.round(lastOffset / MINUTE)}\n              aria-valuenow={cursor === null || start === null ? undefined : Math.round((cursor - start) / MINUTE)}\n              aria-valuetext={valueText}\n              onPointerDown={handlePointerDown}\n              onPointerMove={handlePointerMove}\n              onPointerUp={handlePointerUp}\n              onPointerCancel={handlePointerUp}\n              onKeyDown={handleKeyDown}\n              onFocus={() => {\n                engineRef.current.focused = true;\n                loop.kick();\n              }}\n              onBlur={() => {\n                engineRef.current.focused = false;\n                loop.kick();\n              }}\n              className=\"group/slider absolute inset-y-0 right-0 left-[var(--col)] z-[3] cursor-grab touch-pan-y outline-none data-[dragging]:cursor-grabbing\"\n            >\n              <div\n                ref={cursorRef}\n                aria-hidden=\"true\"\n                className=\"pointer-events-none absolute inset-y-0 left-0 w-0 opacity-0 will-change-transform\"\n              >\n                <div className=\"absolute top-[17px] bottom-0 -left-px w-0.5 bg-lumesec\" />\n                <div className=\"absolute top-[3px] -left-[7px] grid size-[14px] place-items-center rounded-[4px] bg-lumesec shadow-[0_0_0_2px_var(--card),0_1px_3px_rgb(0_0_0/0.25)] outline-lumesec group-focus-visible/slider:outline-2 group-focus-visible/slider:outline-offset-2 group-focus-visible/slider:outline-solid\">\n                  <span className=\"h-1.5 w-[3px] border-x border-lumesec-foreground/85\" />\n                </div>\n              </div>\n            </div>\n          ) : null}\n\n          <canvas\n            ref={effectsRef}\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute -top-6 -right-6 -bottom-12 left-[calc(var(--col)-24px)] z-[4] block h-[calc(100%+72px)] w-[calc(100%-var(--col)+48px)]\"\n          />\n        </div>\n      </div>\n    </div>\n  );\n}\n\n/* Rows ---------------------------------------------------------------------------------------------- */\n\ninterface TimezoneRowProps {\n  item: PresenceItem;\n  model: RowModel | undefined;\n  clock: ClockText;\n  direction: number;\n  animate: boolean;\n  hour12: boolean;\n  removable: boolean;\n  onRemove: (id: string) => void;\n  onExited: (id: string) => void;\n  onMotion: (ms: number) => void;\n  registerRow: (id: string, node: HTMLDivElement | null) => void;\n  registerRemove: (id: string, node: HTMLButtonElement | null) => void;\n}\n\n/** One city: name, local time and weekday on the left; local midnights over the dot strip on the right. */\nfunction TimezoneRow({\n  item,\n  model,\n  clock,\n  direction,\n  animate,\n  hour12,\n  removable,\n  onRemove,\n  onExited,\n  onMotion,\n  registerRow,\n  registerRemove,\n}: TimezoneRowProps) {\n  const { row, entering, leaving } = item;\n  const { id } = row;\n  const node = React.useRef<HTMLDivElement>(null);\n  const setNode = React.useCallback(\n    (element: HTMLDivElement | null) => {\n      node.current = element;\n      registerRow(id, element);\n    },\n    [id, registerRow],\n  );\n  const setRemove = React.useCallback(\n    (element: HTMLButtonElement | null) => registerRemove(id, element),\n    [id, registerRemove],\n  );\n\n  // A row added after the first render grows in; the canvas measures it every frame and follows.\n  React.useLayoutEffect(() => {\n    const element = node.current;\n    if (!entering || !element || typeof element.animate !== \"function\" || prefersReducedMotion()) return;\n    const animation = element.animate(\n      [\n        { height: \"0px\", opacity: 0 },\n        { height: `${ROW_HEIGHT}px`, opacity: 1 },\n      ],\n      { duration: 240, easing: \"cubic-bezier(.2,.8,.2,1)\" },\n    );\n    onMotion(280);\n    return () => animation.cancel();\n  }, [entering, onMotion]);\n\n  React.useLayoutEffect(() => {\n    if (!leaving) return;\n    const element = node.current;\n    if (!element || typeof element.animate !== \"function\") {\n      onExited(id);\n      return;\n    }\n    const animation = element.animate(\n      [\n        { height: `${element.offsetHeight}px`, opacity: 1 },\n        { height: \"0px\", opacity: 0 },\n      ],\n      { duration: 220, easing: \"cubic-bezier(.4,0,.2,1)\", fill: \"forwards\" },\n    );\n    onMotion(260);\n    animation.onfinish = () => onExited(id);\n    return () => {\n      animation.onfinish = null;\n      animation.cancel();\n    };\n  }, [leaving, id, onExited, onMotion]);\n\n  return (\n    <div\n      ref={setNode}\n      role={leaving ? undefined : \"listitem\"}\n      aria-hidden={leaving || undefined}\n      inert={leaving}\n      className=\"group/row grid h-11 grid-cols-[var(--col)_minmax(0,1fr)] overflow-hidden border-t border-border\"\n    >\n      <div className=\"flex min-w-0 flex-col justify-center gap-[3px] pr-2.5\">\n        <div className=\"flex h-4 min-w-0 items-center gap-1\">\n          <span title={row.label} className=\"truncate text-[13px] leading-4 font-medium text-foreground\">\n            {row.label}\n          </span>\n          {row.invalid ? <span className=\"shrink-0 text-[11px] leading-4 text-muted-foreground\">(UTC)</span> : null}\n          {removable ? (\n            <button\n              ref={setRemove}\n              type=\"button\"\n              aria-label={`Remove ${row.label}`}\n              onClick={() => onRemove(id)}\n              className=\"-my-0.5 ml-auto grid size-5 shrink-0 cursor-pointer place-items-center rounded-md border-0 bg-transparent p-0 text-muted-foreground opacity-0 transition-[opacity,background-color,color] duration-150 outline-none group-hover/row:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-lumesec focus-visible:outline-solid motion-reduce:transition-none [@media(hover:none)]:opacity-100\"\n            >\n              <svg\n                viewBox=\"0 0 12 12\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                strokeWidth={1.4}\n                strokeLinecap=\"round\"\n                aria-hidden=\"true\"\n                className=\"size-2.5\"\n              >\n                <path d=\"M3 3l6 6M9 3l-6 6\" />\n              </svg>\n            </button>\n          ) : null}\n        </div>\n        <div className=\"flex min-w-0 items-baseline gap-1.5\">\n          <span className=\"flex shrink-0 items-baseline font-mono text-[15px] leading-[18px] font-medium text-foreground tabular-nums @max-[480px]:text-[13px]\">\n            <RollText\n              text={clock.hours}\n              direction={direction}\n              animate={animate}\n              reserve={HOUR_RESERVE}\n              className=\"justify-items-end\"\n            />\n            <span>:</span>\n            <RollText text={clock.minutes} direction={direction} animate={animate} />\n            {hour12 ? (\n              <RollText\n                text={clock.period}\n                direction={direction}\n                animate={animate}\n                reserve={PERIOD_RESERVE}\n                className=\"ml-1 text-[11px] font-normal text-muted-foreground\"\n              />\n            ) : null}\n          </span>\n          <span className=\"flex min-w-0 items-baseline gap-1 text-[11px] leading-[14px] text-muted-foreground\">\n            <RollText text={clock.weekday} direction={direction} animate={animate} />\n            {clock.offset ? <span className=\"truncate @max-[480px]:hidden\">· {clock.offset}</span> : null}\n          </span>\n        </div>\n      </div>\n      <div aria-hidden=\"true\" className=\"relative\">\n        {model?.midnights.map((midnight) => (\n          <div\n            key={midnight.at}\n            className=\"pointer-events-none absolute inset-y-0 w-0\"\n            style={{ left: `${(midnight.at * 100).toFixed(3)}%` }}\n          >\n            <div className=\"absolute inset-y-0 left-0 w-px bg-border\" />\n            <span\n              className={cn(\n                \"absolute top-[2px] h-3 rounded-[3px] border border-border bg-card px-[3px] font-mono text-[9.5px] leading-[10px] whitespace-nowrap text-muted-foreground\",\n                midnight.at > 0.86 ? \"right-[3px]\" : \"left-[3px]\",\n              )}\n            >\n              {midnight.weekday}\n            </span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\n/** The accent chip with the total overlap; the duration rolls when it changes and the chip pops on the entry light. */\nfunction OverlapChip({\n  minutes,\n  animate,\n  ref,\n}: {\n  minutes: number;\n  animate: boolean;\n  ref: React.Ref<HTMLSpanElement>;\n}) {\n  const [shown, setShown] = React.useState({ minutes, direction: 1 });\n  if (shown.minutes !== minutes) setShown({ minutes, direction: minutes > shown.minutes ? 1 : -1 });\n  return (\n    <span\n      ref={ref}\n      className=\"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md border border-lumesec/30 bg-lumesec/10 px-2 text-[12px] leading-4 font-medium text-lumesec\"\n    >\n      <span className=\"size-1.5 rounded-[1px] bg-lumesec\" />\n      <RollText\n        text={formatSpan(minutes)}\n        direction={shown.direction}\n        animate={animate}\n        className=\"font-mono tabular-nums\"\n      />\n      <span>overlap</span>\n    </span>\n  );\n}\n\n/* Constants ------------------------------------------------------------------------------------------ */\n\nconst MINUTE = 60_000;\nconst HOUR = 3_600_000;\nconst DAY = 24 * HOUR;\n\nconst WORK_HOURS: readonly [number, number] = [9, 17];\nconst SLEEP_HOURS: readonly [number, number] = [23, 7];\n\n/** Built-in rows, used only while neither `cities` nor `defaultCities` is set. They share 2 working hours all year. */\nconst DEMO_CITIES: readonly TimeZoneCity[] = [\n  { id: \"london\", label: \"London\", timeZone: \"Europe/London\" },\n  { id: \"berlin\", label: \"Berlin\", timeZone: \"Europe/Berlin\" },\n  { id: \"new-york\", label: \"New York\", timeZone: \"America/New_York\" },\n  { id: \"sao-paulo\", label: \"São Paulo\", timeZone: \"America/Sao_Paulo\" },\n];\n\nconst HOUR_RESERVE = [\"00\"] as const;\nconst PERIOD_RESERVE = [\"AM\", \"PM\"] as const;\nconst CANVAS_OPTIONS = { maxDpr: 2 } as const;\n\n// Geometry in CSS pixels\nconst ROW_HEIGHT = 44;\n/** Centre of the dot lane: the top 14px of a row hold the midnight chips. */\nconst LANE_CENTER = 28.5;\nconst DOT_ROWS = 6;\nconst DOT_SIZE = 2;\n/** Room for the burst around the strip on the effects canvas (matches its negative insets). */\nconst FX_SIDE = 24;\nconst FX_TOP = 24;\n\n/** Share of lit dots per hour class (sleep, off, work), in ordered-dither order. */\nconst DENSITY = [0.18, 0.5, 1] as const;\nconst SLEEP = 0;\nconst OFF = 1;\nconst WORK = 2;\nconst WEEKEND_ALPHA = 0.6;\nconst UNLIT_ALPHA = 0.42;\nconst BAND_ALPHA = 0.85;\nconst REST_GLOW = 0.32;\n\n// Positions on the dot colour ramp: land grey, ink grey, accent, glint.\nconst TONES = 25;\nconst TONE_INK = 1 / 3;\nconst TONE_ACCENT = 2 / 3;\nconst TONE_GLINT = 1;\n\nconst FILL_SECONDS = 0.42;\nconst DRAIN_SECONDS = 0.3;\nconst SWEEP_MS = 450;\n/** The reveal threshold runs to 1 (0.82 by height + 0.18 jitter); the extra 0.07 is the soft edge. */\nconst REVEAL_END = 1.07;\nconst REVEAL_EDGE = 0.07;\n\nconst POP_KEYFRAMES: Keyframe[] = [\n  { transform: \"scale(.8)\", easing: \"cubic-bezier(.2,.8,.2,1)\" },\n  { transform: \"scale(1.08)\", easing: \"cubic-bezier(.4,0,.2,1)\", offset: 0.55 },\n  { transform: \"scale(1)\" },\n];\n\n/* Model ---------------------------------------------------------------------------------------------- */\n\n/** A city ready to draw: its zone is valid (unknown zones read as UTC). */\ninterface CityRow {\n  readonly id: string;\n  readonly label: string;\n  readonly zone: string;\n  readonly invalid: boolean;\n}\n\ninterface PresenceItem {\n  readonly row: CityRow;\n  /** Added after the first render: grows in. */\n  readonly entering: boolean;\n  /** Removed: collapses, then leaves the list. */\n  readonly leaving: boolean;\n}\n\ninterface Presence {\n  /** The resolved rows the items were merged from. */\n  readonly source: readonly CityRow[];\n  readonly items: readonly PresenceItem[];\n}\n\n/** A span of the window as fractions, 0 at the window start and 1 at its end. */\ninterface Interval {\n  readonly from: number;\n  readonly to: number;\n}\n\n/** One local hour of a row; partial at the window edges and in zones with half-hour offsets. */\ninterface Cell extends Interval {\n  readonly kind: typeof SLEEP | typeof OFF | typeof WORK;\n  readonly weekend: boolean;\n}\n\ninterface RowModel {\n  readonly cells: readonly Cell[];\n  /** Local midnights inside the window, with the weekday that starts there. */\n  readonly midnights: readonly { readonly at: number; readonly weekday: string }[];\n  /** Working hours, merged into continuous spans. */\n  readonly work: readonly Interval[];\n  /** Varies the reveal jitter between rows. */\n  readonly seed: number;\n}\n\ninterface HourRules {\n  workFrom: number;\n  workTo: number;\n  sleepFrom: number;\n  sleepTo: number;\n}\n\ninterface Overlap {\n  readonly intervals: readonly Interval[];\n  /** Absolute times of the intervals, in epoch ms. */\n  readonly ranges: readonly { readonly from: number; readonly to: number }[];\n  readonly minutes: number;\n  /** Changes when the band changes; a new key fills the band again. */\n  readonly key: string;\n}\n\ntype OverlapStatus = \"idle\" | \"single\" | \"band\" | \"none\";\n\ninterface ClockText {\n  hours: string;\n  minutes: string;\n  period: string;\n  weekday: string;\n  offset: string;\n}\n\nfunction resolveCities(list: readonly TimeZoneCity[]): CityRow[] {\n  const seen = new Set<string>();\n  const rows: CityRow[] = [];\n  for (const city of list) {\n    if (!city || typeof city.id !== \"string\" || seen.has(city.id)) continue;\n    seen.add(city.id);\n    const valid = isValidTimeZone(city.timeZone);\n    rows.push({\n      id: city.id,\n      label: String(city.label ?? city.id),\n      zone: valid ? city.timeZone : \"UTC\",\n      invalid: !valid,\n    });\n  }\n  return rows;\n}\n\n/** New rows in their order, with removed rows kept in place (collapsing) unless motion is reduced. */\nfunction mergePresence(previous: readonly PresenceItem[], next: readonly CityRow[], reduced: boolean): PresenceItem[] {\n  const before = new Map(previous.map((item) => [item.row.id, item]));\n  const nextIds = new Set(next.map((row) => row.id));\n  const items: PresenceItem[] = next.map((row) => ({\n    row,\n    entering: before.get(row.id)?.entering ?? true,\n    leaving: false,\n  }));\n  if (reduced) return items;\n  previous.forEach((item, i) => {\n    if (nextIds.has(item.row.id)) return;\n    // insert after the nearest earlier row that is still on screen\n    let anchor = -1;\n    for (let j = i - 1; j >= 0 && anchor < 0; j--)\n      anchor = items.findIndex((candidate) => candidate.row.id === previous[j].row.id);\n    items.splice(anchor + 1, 0, { row: item.row, entering: item.entering, leaving: true });\n  });\n  return items;\n}\n\n/** The next local midnight of the reference zone: the window is one local day (23 to 25 hours around DST changes). */\nfunction windowEnd(zone: string, start: number) {\n  const end = startOfZonedDay(zone, start + 26 * HOUR);\n  return end > start ? end : start + DAY;\n}\n\nfunction inHours(hour: number, from: number, to: number) {\n  if (!Number.isFinite(from) || !Number.isFinite(to) || from === to) return false;\n  return from < to ? hour >= from && hour < to : hour >= from || hour < to;\n}\n\nfunction buildRowModel(\n  row: CityRow,\n  start: number,\n  end: number,\n  rules: HourRules,\n  locale: string | undefined,\n): RowModel {\n  const span = end - start;\n  const cells: Cell[] = [];\n  const midnights: { at: number; weekday: string }[] = [];\n  const work: Interval[] = [];\n  const parts: ZonedParts = { year: 1970, month: 1, day: 1, hour: 0, minute: 0, second: 0, weekday: 4 };\n  let time = start;\n  let day = -1;\n  // a local day has at most 26 hour cells, plus the partial ones at the edges\n  for (let guard = 0; time < end && guard < 32; guard++) {\n    zonedParts(row.zone, time, parts);\n    let next = time - (parts.minute * 60 + parts.second) * 1000 + HOUR;\n    if (next <= time) next = time + HOUR;\n    if (next > end) next = end;\n    const from = (time - start) / span;\n    const to = (next - start) / span;\n    const kind = inHours(parts.hour, rules.workFrom, rules.workTo)\n      ? WORK\n      : inHours(parts.hour, rules.sleepFrom, rules.sleepTo)\n        ? SLEEP\n        : OFF;\n    cells.push({ from, to, kind, weekend: parts.weekday === 0 || parts.weekday === 6 });\n    if (day !== -1 && parts.day !== day) midnights.push({ at: from, weekday: formatWeekday(row.zone, time, locale) });\n    day = parts.day;\n    if (kind === WORK) {\n      const last = work[work.length - 1];\n      if (last && Math.abs(last.to - from) < 1e-9) work[work.length - 1] = { from: last.from, to };\n      else work.push({ from, to });\n    }\n    time = next;\n  }\n  return { cells, midnights, work, seed: stringHash(row.id) % 997 };\n}\n\nfunction intersect(a: readonly Interval[], b: readonly Interval[]): Interval[] {\n  const result: Interval[] = [];\n  let i = 0;\n  let j = 0;\n  while (i < a.length && j < b.length) {\n    const from = Math.max(a[i].from, b[j].from);\n    const to = Math.min(a[i].to, b[j].to);\n    if (to - from > 1e-9) result.push({ from, to });\n    if (a[i].to < b[j].to) i++;\n    else j++;\n  }\n  return result;\n}\n\nconst NO_OVERLAP: Overlap = { intervals: [], ranges: [], minutes: 0, key: \"\" };\n\n/** Hours when every city is at work. One city has nothing to compare, so it has no band. */\nfunction computeOverlap(\n  rows: readonly CityRow[],\n  models: ReadonlyMap<string, RowModel>,\n  start: number | null,\n  end: number | null,\n): Overlap {\n  if (start === null || end === null || rows.length < 2) return NO_OVERLAP;\n  const span = end - start;\n  let band: readonly Interval[] | null = null;\n  for (const row of rows) {\n    const model = models.get(row.id);\n    if (!model) return NO_OVERLAP;\n    band = band === null ? model.work : intersect(band, model.work);\n  }\n  const intervals = (band ?? []).filter((interval) => (interval.to - interval.from) * span >= MINUTE - 1);\n  if (!intervals.length) return { ...NO_OVERLAP, key: `none@${start}` };\n  const ranges = intervals.map((interval) => ({\n    from: Math.round((start + interval.from * span) / MINUTE) * MINUTE,\n    to: Math.round((start + interval.to * span) / MINUTE) * MINUTE,\n  }));\n  const minutes = ranges.reduce((total, range) => total + (range.to - range.from) / MINUTE, 0);\n  const key = ranges.map((range) => `${range.from}-${range.to}`).join(\",\");\n  return { intervals, ranges, minutes, key };\n}\n\nfunction intervalsContain(intervals: readonly Interval[], at: number) {\n  for (const interval of intervals) if (at >= interval.from && at < interval.to) return true;\n  return false;\n}\n\nconst pad2 = (value: number) => String(value).padStart(2, \"0\");\n\nfunction hourLabel(hour: number, hour12: boolean) {\n  if (!hour12) return pad2(hour);\n  return `${hour % 12 || 12} ${hour < 12 ? \"AM\" : \"PM\"}`;\n}\n\n/** Axis labels every 3 hours of the reference city's local time. */\nfunction windowTicks(zone: string, start: number, end: number, hour12: boolean) {\n  const span = end - start;\n  const ticks: { at: number; text: string }[] = [];\n  for (let offset = 0; offset < span - HOUR; offset += 3 * HOUR) {\n    ticks.push({ at: offset / span, text: hourLabel(zonedParts(zone, start + offset).hour, hour12) });\n  }\n  return ticks;\n}\n\n/** The same labels before the clock is read, so the axis does not shift after mount. */\nfunction genericTicks(hour12: boolean) {\n  return Array.from({ length: 8 }, (_, i) => ({ at: i / 8, text: hourLabel(i * 3, hour12) }));\n}\n\nfunction clockText(zone: string, time: number | null, hour12: boolean, locale: string | undefined): ClockText {\n  if (time === null) return { hours: \"--\", minutes: \"--\", period: \"\", weekday: \"–\", offset: \"\" };\n  const parts = zonedParts(zone, time);\n  return {\n    hours: hour12 ? String(parts.hour % 12 || 12) : pad2(parts.hour),\n    minutes: pad2(parts.minute),\n    period: parts.hour < 12 ? \"AM\" : \"PM\",\n    weekday: formatWeekday(zone, time, locale),\n    offset: formatUtcOffset(utcOffsetMinutes(zone, time)),\n  };\n}\n\n/** '2 h', '1 h 30 min', '45 min'. */\nfunction formatSpan(minutes: number) {\n  const total = Math.round(minutes);\n  const hours = Math.floor(total / 60);\n  const rest = total % 60;\n  if (!hours) return `${rest} min`;\n  return rest ? `${hours} h ${rest} min` : `${hours} h`;\n}\n\n/** The time a key moves by (ms), a window edge, or null for keys the cursor ignores. */\nfunction keyMove(key: string, shift: boolean, stepMs: number): number | \"start\" | \"end\" | null {\n  const unit = shift ? HOUR : stepMs;\n  switch (key) {\n    case \"ArrowRight\":\n    case \"ArrowUp\":\n      return unit;\n    case \"ArrowLeft\":\n    case \"ArrowDown\":\n      return -unit;\n    case \"PageUp\":\n      return 3 * HOUR;\n    case \"PageDown\":\n      return -3 * HOUR;\n    case \"Home\":\n      return \"start\";\n    case \"End\":\n      return \"end\";\n    default:\n      return null;\n  }\n}\n\nfunction popChip(element: HTMLElement | null) {\n  if (element && typeof element.animate === \"function\") element.animate(POP_KEYFRAMES, { duration: 420 });\n}\n\n/* Motion state and drawing --------------------------------------------------------------------------- */\n\ninterface BandState {\n  current: readonly Interval[];\n  previous: readonly Interval[];\n  key: string;\n  /** Fill progress of the current band, 0 to 1 over FILL_SECONDS. */\n  fill: number;\n  /** Drain progress of the previous band, 0 to 1 over DRAIN_SECONDS. */\n  drain: number;\n  /** How far the previous band had filled when it was replaced. */\n  previousFill: number;\n}\n\ninterface Spark {\n  x: number;\n  y: number;\n  vx: number;\n  vy: number;\n  age: number;\n  life: number;\n  size: number;\n  /** How far toward the glint this spark is tinted. */\n  mix: number;\n}\n\n/** Everything the animation loop mutates. Lives in a ref, never in React state. */\ninterface Engine {\n  /** False until the first cursor arrives; the line stays hidden until then. */\n  ready: boolean;\n  dragging: boolean;\n  focused: boolean;\n  /** Cursor line position as a window fraction, on a spring toward `target`. */\n  cursor: Spring & { target: number };\n  /** The latest committed cursor time, so key presses add up before React re-renders. */\n  latest: number | null;\n  highlights: Map<string, Spring>;\n  /** Strength of the lit column under the cursor. */\n  glow: Spring;\n  band: BandState;\n  inBand: boolean;\n  /** Start of the light running down the band, in ms, or -1. */\n  sweepStart: number;\n  sparksFired: boolean;\n  sparks: Spark[];\n  fxDirty: boolean;\n  /** Rows grow or collapse until this time (ms). */\n  animatingUntil: number;\n  tops: number[];\n  heights: number[];\n  /** Top of the rows below the axis, in the area's coordinates. */\n  rowsOffset: number;\n  palette: GeoPalette | null;\n  ink: GeoInk | null;\n  batch: DotBatch | null;\n}\n\nfunction createEngine(): Engine {\n  return {\n    ready: false,\n    dragging: false,\n    focused: false,\n    cursor: { position: 0, velocity: 0, target: 0 },\n    latest: null,\n    highlights: new Map(),\n    glow: { position: REST_GLOW, velocity: 0 },\n    band: { current: [], previous: [], key: \"\", fill: 1, drain: 1, previousFill: 1 },\n    inBand: false,\n    sweepStart: -1,\n    sparksFired: true,\n    sparks: [],\n    fxDirty: false,\n    animatingUntil: 0,\n    tops: [],\n    heights: [],\n    rowsOffset: 0,\n    palette: null,\n    ink: null,\n    batch: null,\n  };\n}\n\nconst settled = (spring: Spring, target: number) =>\n  Math.abs(spring.position - target) < 0.0004 && Math.abs(spring.velocity) < 0.002;\n\ninterface Scene {\n  items: readonly PresenceItem[];\n  models: ReadonlyMap<string, RowModel>;\n  span: number;\n}\n\n/** Top of the first row and the height of all rows, in the strip canvas's coordinates. */\nfunction rowsExtent(engine: Engine) {\n  const count = engine.tops.length;\n  if (!count) return { top: 0, height: 0 };\n  const top = engine.tops[0];\n  return { top, height: Math.max(1, engine.tops[count - 1] + engine.heights[count - 1] - top) };\n}\n\n/** 0 to 1: how far a dot at `threshold` is revealed by a front at `level`. */\nconst reveal = (level: number, threshold: number) => clamp((level - threshold) / REVEAL_EDGE, 0, 1);\n\n/** The dot strip: one block of dots per local hour and row, the overlap band, and the lit column under the cursor. */\nfunction drawStrip(\n  surface: CanvasSurface,\n  batch: DotBatch,\n  ink: GeoInk,\n  scene: Scene,\n  engine: Engine,\n  now: number,\n  reduced: boolean,\n) {\n  const { context, width, height, dpr } = surface;\n  context.clearRect(0, 0, width, height);\n  const { items, models, span } = scene;\n  if (!items.length || !width || !engine.ready) return;\n\n  const hourWidth = (width * HOUR) / span;\n  // narrow strips use a 3px pitch so every hour keeps at least two columns\n  const pitch = hourWidth >= 15 ? 4 : 3;\n  const blockHeight = (DOT_ROWS - 1) * pitch + DOT_SIZE;\n  const extent = rowsExtent(engine);\n  const band = engine.band;\n  const fillLevel = easeOutCubic(band.fill) * REVEAL_END;\n  const drainLevel = band.drain * REVEAL_END;\n  const previousLevel = easeOutCubic(band.previousFill) * REVEAL_END;\n  const seconds = now / 1000;\n  const sweepSince = engine.sweepStart >= 0 ? now - engine.sweepStart : -1;\n  const sweeping = sweepSince >= 0 && sweepSince < SWEEP_MS + 150;\n  const sweepFront = (sweepSince / SWEEP_MS) * (extent.height + 24) - 12;\n  const sweepFade = sweeping ? 1 - smoothFade(sweepSince, SWEEP_MS, SWEEP_MS + 150) : 0;\n  const glow = engine.glow.position;\n\n  // a faint wash and two hairlines frame the band, so it reads as one span across every row\n  const washes: [readonly Interval[], number][] = [\n    [band.current, easeOutCubic(band.fill)],\n    [band.previous, (1 - band.drain) * easeOutCubic(band.previousFill)],\n  ];\n  for (const [intervals, strength] of washes) {\n    if (strength <= 0.01) continue;\n    for (const interval of intervals) {\n      const x0 = snap(interval.from * width, dpr);\n      const x1 = snap(interval.to * width, dpr);\n      context.fillStyle = rgba(ink.accent, 0.07 * strength);\n      context.fillRect(x0, extent.top, x1 - x0, extent.height);\n      context.fillStyle = rgba(ink.accent, 0.32 * strength);\n      context.fillRect(x0, extent.top, 1, extent.height);\n      context.fillRect(x1 - 1, extent.top, 1, extent.height);\n    }\n  }\n\n  items.forEach((item, i) => {\n    const model = models.get(item.row.id);\n    const rowTop = engine.tops[i];\n    const rowHeight = engine.heights[i];\n    if (!model || !(rowHeight > 1)) return;\n    const rowBottom = rowTop + rowHeight;\n    const blockTop = snap(rowTop + LANE_CENTER - blockHeight / 2, dpr);\n    const active = !item.leaving;\n    const highlightX = (engine.highlights.get(item.row.id)?.position ?? engine.cursor.position) * width;\n\n    for (const cell of model.cells) {\n      const cellLeft = cell.from * width;\n      const cellWidth = (cell.to - cell.from) * width;\n      const columns = Math.floor((cellWidth - pitch + DOT_SIZE) / pitch);\n      if (columns < 1) continue;\n      const left = cellLeft + (cellWidth - ((columns - 1) * pitch + DOT_SIZE)) / 2;\n      const level = DENSITY[cell.kind];\n      const baseAlpha = cell.weekend ? WEEKEND_ALPHA : 1;\n\n      for (let c = 0; c < columns; c++) {\n        const x = snap(left + c * pitch, dpr);\n        const column = Math.round(x / pitch);\n        const center = (x + DOT_SIZE / 2) / width;\n        const inCurrent = active && intervalsContain(band.current, center);\n        const inPrevious = active && intervalsContain(band.previous, center);\n        const dx = (x + DOT_SIZE / 2 - highlightX) / (pitch * 1.1);\n        const highlight = glow * Math.exp(-dx * dx);\n        const shimmer = reduced ? 1 : 0.75 + 0.25 * Math.sin(seconds * 1.4 + x * 0.05);\n\n        for (let r = 0; r < DOT_ROWS; r++) {\n          const y = blockTop + r * pitch;\n          if (y + DOT_SIZE > rowBottom) break;\n          const lit = level > bayer4(r, column);\n          let tone = lit ? TONE_INK : 0;\n          let alpha = (lit ? 1 : UNLIT_ALPHA) * baseAlpha;\n\n          if (lit && (inCurrent || inPrevious)) {\n            const jitter = hash(column * 31 + r * 7 + model.seed);\n            const threshold = ((y - extent.top) / extent.height) * 0.82 + jitter * 0.18;\n            const kept = inPrevious ? Math.min(1 - reveal(drainLevel, threshold), reveal(previousLevel, threshold)) : 0;\n            const amount = inCurrent\n              ? inPrevious\n                ? Math.max(kept, reveal(fillLevel, threshold))\n                : reveal(fillLevel, threshold)\n              : kept;\n            if (amount > 0) {\n              tone = lerp(tone, TONE_ACCENT, amount);\n              alpha = lerp(alpha, BAND_ALPHA * shimmer, amount);\n              if (sweeping && inCurrent) {\n                // the entry light: an uneven front running down through the band, glint behind a short tail\n                const front = ringFront(y - extent.top, sweepFront, 9, jitter, 6);\n                const tail = y - extent.top < sweepFront ? Math.exp(-(sweepFront - (y - extent.top)) / 36) * 0.35 : 0;\n                const light = Math.min(1, front + tail) * sweepFade * amount;\n                tone = lerp(tone, TONE_GLINT, light);\n                alpha = lerp(alpha, 1, light);\n              }\n            }\n          }\n\n          if (highlight > 0.01) {\n            tone = lerp(tone, tone >= TONE_ACCENT - 0.01 ? TONE_GLINT : TONE_ACCENT, highlight * 0.85);\n            alpha = lerp(alpha, 1, highlight * (lit ? 0.8 : 0.4));\n          }\n          batch.add(x, y, DOT_SIZE, tone, alpha);\n        }\n      }\n    }\n  });\n  batch.flush(context);\n  context.globalAlpha = 1;\n}\n\n/** 0 before `from`, 1 after `to`, linear between. */\nconst smoothFade = (value: number, from: number, to: number) => clamp((value - from) / (to - from), 0, 1);\n\n/** The light bar of the entry sweep and the burst at the band's foot, on the canvas that reaches past the card. */\nfunction drawEffects(\n  surface: CanvasSurface,\n  ink: GeoInk,\n  engine: Engine,\n  stripWidth: number,\n  now: number,\n  delta: number,\n) {\n  const { context, width, height } = surface;\n  const extent = rowsExtent(engine);\n  const band = engine.band.current;\n  const sweepSince = engine.sweepStart >= 0 ? now - engine.sweepStart : -1;\n  const sweeping = sweepSince >= 0 && sweepSince < SWEEP_MS && band.length > 0;\n\n  if (sweepSince >= SWEEP_MS && !engine.sparksFired) {\n    engine.sparksFired = true;\n    const y = FX_TOP + engine.rowsOffset + extent.top + extent.height;\n    for (const interval of band) {\n      const x = FX_SIDE + ((interval.from + interval.to) / 2) * stripWidth;\n      engine.sparks.push(...footSparks(x, y, (interval.to - interval.from) * stripWidth));\n    }\n  }\n\n  if (!sweeping && !engine.sparks.length) {\n    if (engine.fxDirty) {\n      context.clearRect(0, 0, width, height);\n      engine.fxDirty = false;\n    }\n    return false;\n  }\n  engine.fxDirty = true;\n  context.clearRect(0, 0, width, height);\n\n  if (sweeping) {\n    const k = sweepSince / SWEEP_MS;\n    const y = FX_TOP + engine.rowsOffset + extent.top + k * extent.height;\n    const alpha = 0.6 * (1 - k * 0.5);\n    for (const interval of band) {\n      const x0 = FX_SIDE + interval.from * stripWidth;\n      const x1 = FX_SIDE + interval.to * stripWidth;\n      const beam = context.createLinearGradient(0, y - 18, 0, y + 6);\n      beam.addColorStop(0, rgba(ink.accent, 0));\n      beam.addColorStop(0.7, rgba(ink.accent, alpha * 0.35));\n      beam.addColorStop(0.92, rgba(ink.glint, alpha));\n      beam.addColorStop(1, rgba(ink.glint, 0));\n      context.fillStyle = beam;\n      context.fillRect(x0, y - 18, x1 - x0, 24);\n    }\n  }\n\n  const drag = Math.exp(-delta * 3.4);\n  const alive: Spark[] = [];\n  for (const spark of engine.sparks) {\n    spark.age += delta;\n    if (spark.age >= spark.life) continue;\n    spark.vx *= drag;\n    spark.vy = spark.vy * drag + 220 * delta;\n    spark.x += spark.vx * delta;\n    spark.y += spark.vy * delta;\n    const life = 1 - spark.age / spark.life;\n    const hot = Math.max(0, 1 - spark.age / 0.12);\n    const color = mixRgb(ink.accent, ink.glint, Math.min(1, spark.mix * 0.6 + hot));\n    context.globalAlpha = Math.pow(life, 1.3);\n    context.fillStyle = `rgb(${color[0] | 0},${color[1] | 0},${color[2] | 0})`;\n    context.fillRect(Math.round(spark.x * 2) / 2, Math.round(spark.y * 2) / 2, spark.size, spark.size);\n    alive.push(spark);\n  }\n  context.globalAlpha = 1;\n  engine.sparks = alive;\n  return alive.length > 0 || sweeping;\n}\n\n/** Pixel sparks thrown out of the band's foot when the entry light reaches the last row: down and out past the card. */\nfunction footSparks(x: number, y: number, spread: number): Spark[] {\n  return Array.from({ length: 24 }, () => {\n    const angle = Math.PI / 2 + (Math.random() - 0.5) * 2.4;\n    const speed = 90 + Math.random() * 230;\n    return {\n      x: x + (Math.random() - 0.5) * Math.max(4, spread * 0.8),\n      y: y - Math.random() * 4,\n      vx: Math.cos(angle) * speed,\n      vy: Math.sin(angle) * speed,\n      age: 0,\n      life: 0.4 + Math.random() * 0.55,\n      size: Math.random() < 0.3 ? 2.5 : 1.5,\n      mix: Math.random(),\n    };\n  });\n}\n",
      "type": "registry:component",
      "target": "@components/lumesec/geo-timezones.tsx"
    }
  ],
  "meta": {
    "tag": "geo-timezones",
    "collection": "location",
    "react": "GeoTimezones",
    "kind": "react",
    "data": "input"
  },
  "docs": "Meeting planner docs: https://elements.lumesec.ai/components/location/timezones",
  "categories": [
    "location",
    "inputs-time"
  ],
  "type": "registry:component"
}