{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "exposure-scrubber",
  "title": "ExposureScrubber",
  "description": "Read any run like an animator's exposure sheet: a server-rendered X-sheet table (frame, action, timing, mark) with one marked moment, data-given causes, a detail panel and a native-range transport with even, elapsed and flipbook timing. Never autoplays; keyboard and touch AT complete.",
  "registryDependencies": [
    "https://frame12.dev/r/frame12-styles.json",
    "https://frame12.dev/r/use-tempo.json",
    "https://frame12.dev/r/use-on-twos.json",
    "https://frame12.dev/r/use-exposure.json",
    "https://frame12.dev/r/panel.json",
    "https://frame12.dev/r/segmented-control.json"
  ],
  "files": [
    {
      "path": "ui/exposure-scrubber.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { flushSync } from 'react-dom';\nimport { useResolvedMotion } from '@/hooks/use-tempo';\nimport { useChanged } from '@/hooks/use-on-twos';\nimport {\n  EXPOSURE_RATES,\n  EXPOSURE_STATUS_WORDS,\n  describeExposureFrame,\n  formatElapsed,\n  formatFrameNumber,\n  formatGap,\n  useExposure,\n  type ExposureEntry,\n  type ExposureFrame,\n  type ExposurePlayingReason,\n  type ExposureRate,\n  type ExposureStatus,\n  type ExposureTiming,\n  type ExposureValueReason,\n} from '@/hooks/use-exposure';\nimport { Panel } from './panel';\nimport { SegmentedControl } from './segmented-control';\n\nexport type {\n  ExposureFrame,\n  ExposureStatus,\n  ExposureTiming,\n  ExposureRate,\n  ExposureValueReason,\n  ExposurePlayingReason,\n};\nexport type ExposureScrubberDensity = 'comfortable' | 'compact';\nexport type ExposureScrubberVariant = 'expressive' | 'quiet';\n\nexport interface ExposureScrubberProps {\n  frames: readonly ExposureFrame[];\n  label: string;\n  renderFrame: (frame: ExposureFrame, index: number, ctx: { scrubbing: boolean; settled: boolean }) => React.ReactNode;\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (id: string, info: { index: number; reason: 'keyboard' | 'pointer' | 'row' | 'marker' | 'cause' | 'playback' | 'data' }) => void;\n  playing?: boolean;\n  onPlayingChange?: (playing: boolean, reason: 'user' | 'end' | 'scrub' | 'hidden' | 'data' | 'tempo' | 'rejected') => void;\n  timing?: 'even' | 'elapsed' | 'flipbook';\n  rate?: 0.5 | 1 | 2 | 4;\n  defaultRate?: 0.5 | 1 | 2 | 4;\n  onRateChange?: (r: 0.5 | 1 | 2 | 4) => void;\n  stepMs?: number;\n  loop?: boolean;\n  primaryMarker?: string;\n  emptyState?: React.ReactNode;\n  idPrefix?: string;\n  density?: 'comfortable' | 'compact';\n  variant?: 'expressive' | 'quiet';\n  className?: string;\n}\n\nconst TIMING_OPTIONS: ReadonlyArray<{ value: ExposureTiming; label: string; unit: string; meaning: string }> = [\n  { value: 'even', label: 'EVEN', unit: 'read', meaning: 'one readable step per frame' },\n  { value: 'elapsed', label: 'REAL', unit: 'rhythm', meaning: \"the run's real rhythm\" },\n  { value: 'flipbook', label: 'FLIP', unit: '12/s', meaning: 'flipbook, 12 poses per second' },\n];\n\nconst RATE_OPTIONS = EXPOSURE_RATES.map((r) => ({ value: r, label: `${r}×` }));\n\n/** Shows \"This frame couldn't be rendered\" instead of a consumer `renderFrame` that throws. */\nclass FrameBoundary extends React.Component<\n  { frameId: string; children: React.ReactNode },\n  { failed: boolean }\n> {\n  state = { failed: false };\n  static getDerivedStateFromError() {\n    return { failed: true };\n  }\n  render() {\n    if (this.state.failed) {\n      return (\n        <p className=\"f12-xs-error\" role=\"note\">\n          This frame couldn&apos;t be rendered <span className=\"f12-xs-mono\">({this.props.frameId})</span>\n        </p>\n      );\n    }\n    return this.props.children;\n  }\n}\n\n/** Calls `renderFrame` inside the boundary (so a throw is caught there, not in the scrubber). */\nfunction FrameSlot({\n  render,\n  frame,\n  index,\n  scrubbing,\n  settled,\n}: {\n  render: ExposureScrubberProps['renderFrame'];\n  frame: ExposureFrame;\n  index: number;\n  scrubbing: boolean;\n  settled: boolean;\n}) {\n  return <>{render(frame, index, { scrubbing, settled })}</>;\n}\n\n/** The TIMING cell: hold ticks (even) or a log-scaled screentone bar (drawn by CSS ::before). */\nfunction timingCell(entry: ExposureEntry, timing: ExposureTiming, maxGapMs: number): { style?: React.CSSProperties; text: string } {\n  if (timing === 'even') return { style: { '--xs-h': entry.hold } as React.CSSProperties, text: `×${entry.hold}` };\n  if (entry.gapMs === undefined || maxGapMs <= 0) return { text: '' };\n  const w = Math.max(4, Math.round((Math.log1p(entry.gapMs) / Math.log1p(maxGapMs)) * 100));\n  return { style: { '--xs-w': `${w}%` } as React.CSSProperties, text: formatGap(entry.gapMs) };\n}\n\n/** Status as a word; its glyph is CSS generated content with empty alt text (never color alone). */\nfunction StatusWord({ status }: { status: ExposureStatus }) {\n  return (\n    <span className=\"f12-xs-st\" data-s={status}>\n      {EXPOSURE_STATUS_WORDS[status]}\n    </span>\n  );\n}\n\ninterface RowProps {\n  entry: ExposureEntry;\n  total: number;\n  current: boolean;\n  primary: boolean;\n  timing: ExposureTiming;\n  maxGapMs: number;\n  causeLabel: string | null;\n}\n\n/** One X-sheet row. Memoized and keyed by id: a frame change re-renders two rows. */\nconst ExposureRow = React.memo(function ExposureRow({\n  entry,\n  total,\n  current,\n  primary,\n  timing,\n  maxGapMs,\n  causeLabel,\n}: RowProps) {\n  // Lean markup (≤ 400 bytes per row): cells are styled by position, not class.\n  const t = timingCell(entry, timing, maxGapMs);\n  return (\n    <tr role=\"row\" className=\"f12-xs-row\" aria-current={current ? 'step' : undefined}>\n      <td role=\"cell\" className=\"f12-xs-f\">\n        <span className=\"f12-xs-fn\">{formatFrameNumber(entry.index, total)}</span>\n        {entry.elapsedMs !== undefined && <span>{formatElapsed(entry.elapsedMs)}</span>}\n      </td>\n      <td role=\"cell\">\n        <button\n          type=\"button\"\n          className=\"f12-xs-btn\"\n          tabIndex={current ? 0 : -1}\n          aria-current={current ? 'step' : undefined}\n          data-i={entry.index}\n        >\n          {entry.label}\n        </button>\n        {entry.kind && <span className=\"f12-xs-k\">{entry.kind}</span>}\n        {entry.detail && <span className=\"f12-xs-d\">{entry.detail}</span>}\n      </td>\n      <td role=\"cell\" style={t.style}>\n        {t.text}\n      </td>\n      <td role=\"cell\">\n        {entry.status && <StatusWord status={entry.status} />}\n        {entry.marker && (\n          <span className={primary ? 'f12-xs-mk f12-xs-mk-primary' : 'f12-xs-mk'}>\n            <span aria-hidden=\"true\">{primary ? '◆ ' : '◇ '}</span>\n            {primary ? 'MARK' : 'mark'}\n          </span>\n        )}\n        {causeLabel && (\n          <span className=\"f12-xs-from\">\n            <span aria-hidden=\"true\">↖ </span>\n            <span className=\"f12-sr-only\">led here from </span>\n            {causeLabel}\n          </span>\n        )}\n      </td>\n    </tr>\n  );\n});\n\n/** Rows per memoized chunk: a frame change reconciles at most two chunks, not the whole sheet. */\nconst CHUNK = 64;\n\ninterface ChunkProps {\n  rows: readonly ExposureEntry[];\n  total: number;\n  /** The current index if it falls in this chunk, else -1 (so other chunks skip re-rendering). */\n  current: number;\n  primary: number;\n  timing: ExposureTiming;\n  maxGapMs: number;\n}\n\nconst causeLabelOf = (entry: ExposureEntry, total: number): string | null => {\n  if (entry.causes.length === 0) return null;\n  const first = formatFrameNumber(entry.causes[0], total);\n  return entry.causes.length > 1 ? `${first} +${entry.causes.length - 1}` : first;\n};\n\n/** A run of rows rendered as a fragment (no wrapper element: the table DOM is unchanged). */\nconst ExposureRowChunk = React.memo(function ExposureRowChunk({ rows, total, current, primary, timing, maxGapMs }: ChunkProps) {\n  return (\n    <>\n      {rows.map((entry) => (\n        <ExposureRow\n          key={entry.key}\n          entry={entry}\n          total={total}\n          current={entry.index === current}\n          primary={entry.index === primary}\n          timing={timing}\n          maxGapMs={maxGapMs}\n          causeLabel={causeLabelOf(entry, total)}\n        />\n      ))}\n    </>\n  );\n});\n\n/**\n * ExposureScrubber: reads a discrete history (an agent run, a CI pipeline, an incident) like an\n * animator's exposure sheet. A semantic X-sheet table (FRAME · ACTION · TIMING · MARK), a detail\n * panel for the current frame, and a native-range transport with three timing modes. Never\n * autoplays. Built on `useExposure`.\n */\nexport function ExposureScrubber({\n  frames,\n  label,\n  renderFrame,\n  value,\n  defaultValue,\n  onValueChange,\n  playing,\n  onPlayingChange,\n  timing = 'even',\n  rate,\n  defaultRate,\n  onRateChange,\n  stepMs = 1000,\n  loop = false,\n  primaryMarker,\n  emptyState,\n  idPrefix,\n  density = 'comfortable',\n  variant = 'expressive',\n  className = '',\n}: ExposureScrubberProps) {\n  const autoId = React.useId().replace(/:/g, '');\n  const prefix = idPrefix ?? `f12-xs-${autoId}`;\n  const ex = useExposure({\n    frames,\n    value,\n    defaultValue,\n    onValueChange,\n    playing,\n    onPlayingChange,\n    timing,\n    rate,\n    defaultRate,\n    onRateChange,\n    stepMs,\n    loop,\n    primaryMarker,\n    name: 'ExposureScrubber',\n  });\n  // Motion governs transitions only (row highlight, panel swap), never reading speed.\n  const motion = useResolvedMotion('stepped');\n\n  // Server render and first client render are identical (transport disabled with a note);\n  // the transport comes alive after hydration.\n  const [hydrated, setHydrated] = React.useState(false);\n  React.useEffect(() => setHydrated(true), []);\n\n  const tbodyRef = React.useRef<HTMLTableSectionElement | null>(null);\n  const scrollRef = React.useRef<HTMLDivElement | null>(null);\n  const [sheetOpen, setSheetOpen] = React.useState(true);\n\n  const { count, index, entries } = ex;\n  const chunks = React.useMemo(() => {\n    const out: ExposureEntry[][] = [];\n    for (let i = 0; i < entries.length; i += CHUNK) out.push(entries.slice(i, i + CHUNK));\n    return out;\n  }, [entries]);\n  const n = count;\n  const panelEntry = ex.panelIndex >= 0 ? entries[ex.panelIndex] : null;\n  // The panel swap animates only after the first change: nothing moves on first paint.\n  const swapped = useChanged(panelEntry?.key);\n  const ready = hydrated && n > 0;\n  const multi = ready && n > 1;\n  const frameWord = n === 1 ? 'frame' : 'frames';\n\n  // Keep the current row inside the sheet's own scroll box (never scrolls the page, never moves\n  // focus). While flipping, page by whole screens so the sheet does not crawl.\n  React.useEffect(() => {\n    const box = scrollRef.current;\n    if (!box || ex.scrubbing) return;\n    const flipping = ex.flipping;\n    // Off-screen rows use content-visibility placeholder heights; once rows near the target\n    // render, real heights shift it. Re-check for a few frames (then stop: nothing runs idle).\n    let raf = 0;\n    let tries = 0;\n    const fit = () => {\n      const row = tbodyRef.current?.rows[index];\n      if (!row) return;\n      const head = box.querySelector('thead')?.getBoundingClientRect().height ?? 0;\n      const r = row.getBoundingClientRect();\n      const top = r.top - box.getBoundingClientRect().top + box.scrollTop;\n      const bottom = top + r.height;\n      let next = box.scrollTop;\n      if (top - head < box.scrollTop) next = Math.max(0, top - head);\n      else if (bottom > box.scrollTop + box.clientHeight) next = flipping ? top - head : bottom - box.clientHeight;\n      if (Math.abs(next - box.scrollTop) >= 1) box.scrollTop = next;\n      // rAF runs before the frame renders newly relevant rows, so keep checking a few frames.\n      if (++tries < 6) raf = requestAnimationFrame(fit);\n    };\n    fit();\n    return () => cancelAnimationFrame(raf);\n  }, [index, ex.flipping, ex.scrubbing]);\n\n  // ------------------------------------------------------------------ pointer drag (FRAME column)\n  const dragRef = React.useRef<{ id: number } | null>(null);\n  const indexAtY = (y: number): number => {\n    const rows = tbodyRef.current?.rows;\n    if (!rows || rows.length === 0) return -1;\n    if (y < rows[0].getBoundingClientRect().top) return 0;\n    let lo = 0;\n    let hi = rows.length - 1;\n    while (lo < hi) {\n      const mid = (lo + hi + 1) >> 1;\n      if (rows[mid].getBoundingClientRect().top <= y) lo = mid;\n      else hi = mid - 1;\n    }\n    return lo;\n  };\n  const endDrag = () => {\n    if (!dragRef.current) return;\n    dragRef.current = null;\n    ex.endPointerScrub();\n  };\n\n  const onBodyPointerDown = (e: React.PointerEvent<HTMLTableSectionElement>) => {\n    if (!ready || e.button !== 0) return;\n    const cell = (e.target as Element).closest('.f12-xs-f');\n    if (!cell) return;\n    e.preventDefault();\n    try {\n      e.currentTarget.setPointerCapture(e.pointerId);\n    } catch {\n      /* capture is best-effort */\n    }\n    dragRef.current = { id: e.pointerId };\n    ex.beginPointerScrub();\n    const i = indexAtY(e.clientY);\n    if (i >= 0) ex.select(i, 'pointer');\n  };\n  const onBodyPointerMove = (e: React.PointerEvent<HTMLTableSectionElement>) => {\n    if (!dragRef.current || dragRef.current.id !== e.pointerId) return;\n    const i = indexAtY(e.clientY);\n    // Immediate: the frame changes in the same task as the input event.\n    if (i >= 0) flushSync(() => ex.select(i, 'pointer'));\n  };\n\n  const onBodyClick = (e: React.MouseEvent<HTMLTableSectionElement>) => {\n    const btn = (e.target as Element).closest<HTMLButtonElement>('.f12-xs-btn');\n    if (!btn || !ready) return;\n    const i = Number(btn.dataset.i);\n    // A click that follows a key (Enter/Space) is a keyboard selection.\n    ex.select(i, e.detail === 0 ? 'keyboard' : 'row');\n    ex.announceSettled();\n  };\n  const onBodyKeyDown = (e: React.KeyboardEvent<HTMLTableSectionElement>) => {\n    if (!ready || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;\n    const btn = (e.target as Element).closest<HTMLButtonElement>('.f12-xs-btn');\n    if (!btn) return;\n    // From the live current frame (j/k or playback may have moved it away from the focused row).\n    const target = ex.rowKeyTarget(e.key, index);\n    if (target === null) return;\n    e.preventDefault();\n    ex.select(target, 'keyboard');\n    ex.noteKeyScrub();\n    tbodyRef.current?.rows[target]?.querySelector<HTMLButtonElement>('.f12-xs-btn')?.focus();\n  };\n\n  // ------------------------------------------------------------------ range\n  const rangePointer = React.useRef(false);\n  const onRangeChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n    const v = Number(e.currentTarget.value) - 1;\n    if (rangePointer.current) {\n      ex.select(v, 'pointer');\n      return;\n    }\n    // Keys move relative to the live playhead (while flipping, the range shows the frozen\n    // start frame, so an absolute value would jump back to it).\n    ex.select(index + (v - displayIndex), 'keyboard');\n    ex.noteKeyScrub();\n  };\n  // Native ranges page by 10% of the range in some engines; the contract is ±10 frames.\n  const onRangeKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n    if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;\n    // Home/End are absolute (also while flipping, when the range shows the frozen start frame).\n    if (e.key === 'Home' || e.key === 'End') {\n      e.preventDefault();\n      ex.select(e.key === 'Home' ? 0 : n - 1, 'keyboard');\n      ex.noteKeyScrub();\n      return;\n    }\n    if (e.key !== 'PageUp' && e.key !== 'PageDown') return;\n    e.preventDefault();\n    ex.step(e.key === 'PageUp' ? 10 : -10, 'keyboard');\n    ex.noteKeyScrub();\n  };\n  const onRangePointerDown = (e: React.PointerEvent<HTMLInputElement>) => {\n    if (e.button !== 0) return;\n    rangePointer.current = true;\n    try {\n      e.currentTarget.setPointerCapture(e.pointerId);\n    } catch {\n      /* capture is best-effort */\n    }\n    ex.beginPointerScrub();\n  };\n  const onRangePointerEnd = () => {\n    if (!rangePointer.current) return;\n    rangePointer.current = false;\n    ex.endPointerScrub();\n  };\n\n  // ------------------------------------------------------------------ transport steps\n  // Step buttons stay focusable at the ends (aria-disabled, not disabled), so focus is never\n  // dropped to <body> when a press reaches the first or last frame.\n  const stepBy = (delta: number, e: React.MouseEvent<HTMLButtonElement>) => {\n    if (e.currentTarget.getAttribute('aria-disabled') === 'true') return;\n    const keyboard = e.detail === 0;\n    ex.step(delta, keyboard ? 'keyboard' : 'pointer');\n    if (keyboard) ex.noteKeyScrub();\n    else ex.announceSettled();\n  };\n  const contentKeys = React.useRef<WeakSet<Event>>(new WeakSet());\n  // After following a cause (or going back) the activated button unmounts; move focus to the\n  // frame title instead of losing it. A counter (not a flag) so every request is consumed in\n  // the commit it causes, even when the frame does not change, and never fires later.\n  const [focusRequest, setFocusRequest] = React.useState(0);\n  React.useEffect(() => {\n    if (focusRequest === 0) return;\n    document.getElementById(`${prefix}-title`)?.focus();\n  }, [focusRequest, prefix]);\n  const markStep = (direction: 1 | -1, e: React.MouseEvent<HTMLButtonElement>) => {\n    if (e.currentTarget.getAttribute('aria-disabled') === 'true') return;\n    ex.stepMarker(direction, e.detail === 0 ? 'keyboard' : 'pointer');\n  };\n\n  // ------------------------------------------------------------------ shortcuts (scoped)\n  const onRootKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    if (!ready || e.defaultPrevented) return;\n    // Keys from consumer content never reach the shortcuts, including content portalled out of\n    // the DOM subtree (React events still bubble through the portal to here).\n    if (contentKeys.current.has(e.nativeEvent)) return;\n    if (!(e.currentTarget as Node).contains(e.target as Node)) return;\n    if ((e.target as Element).closest('[data-exposure-content]')) return;\n    if (ex.handleShortcut(e)) e.preventDefault();\n  };\n\n  const displayIndex = ex.flipping ? ex.panelIndex : index;\n  const displayEntry = displayIndex >= 0 ? entries[displayIndex] : null;\n  const frameNo = (i: number) => formatFrameNumber(i, n);\n  const timingHeader =\n    ex.timing === 'even' ? 'hold ×1–12' : ex.hasTiming ? `log · max ${formatGap(ex.maxGapMs)}` : 'no timing data';\n\n  const transportNote = !hydrated\n    ? 'Replay needs JavaScript'\n    : n === 0\n      ? 'Nothing to replay: there are no frames.'\n      : !ex.flipbookAvailable\n        ? 'Flipbook needs motion: reduced motion or a still tempo is on.'\n        : null;\n  const noteId = `${prefix}-note`;\n\n  const rootClass = [\n    'f12-xs',\n    `f12-m-${motion}`,\n    density === 'compact' ? 'f12-xs-compact' : '',\n    variant === 'quiet' ? 'f12-xs-quiet' : '',\n    className,\n  ]\n    .filter(Boolean)\n    .join(' ');\n\n  return (\n    <div\n      className={rootClass}\n      id={prefix}\n      data-density={density}\n      data-variant={variant}\n      data-timing={ex.timing}\n      data-playing={ex.playing ? 'true' : undefined}\n      data-flipping={ex.flipping ? 'true' : undefined}\n      onKeyDown={onRootKeyDown}\n    >\n      <div className=\"f12-xs-grid\">\n        {/* 1 · Transport (first in tab order) */}\n        <fieldset className=\"f12-xs-transport\" disabled={!ready} aria-describedby={transportNote ? noteId : undefined}>\n          <legend className=\"f12-sr-only\">{`${label}: replay controls`}</legend>\n          <div className=\"f12-xs-tr-row\">\n            <button\n              type=\"button\"\n              className=\"f12-xs-tbtn\"\n              id={`${prefix}-prev`}\n              aria-disabled={!multi || index <= 0}\n              onClick={(e) => stepBy(-1, e)}\n            >\n              <span aria-hidden=\"true\">‹ </span>Prev\n            </button>\n            <button\n              type=\"button\"\n              className=\"f12-xs-tbtn f12-xs-play\"\n              id={`${prefix}-play`}\n              aria-pressed={ex.playing}\n              disabled={!multi}\n              onClick={ex.toggle}\n            >\n              <span className=\"f12-xs-play-glyph\" aria-hidden=\"true\">\n                {ex.playing ? '❚❚' : '▶'}\n              </span>\n              Play\n            </button>\n            <button\n              type=\"button\"\n              className=\"f12-xs-tbtn\"\n              id={`${prefix}-next`}\n              aria-disabled={!multi || index >= n - 1}\n              onClick={(e) => stepBy(1, e)}\n            >\n              Next<span aria-hidden=\"true\"> ›</span>\n            </button>\n            {n > 1 ? (\n              <input\n                type=\"range\"\n                className=\"f12-xs-range\"\n                id={`${prefix}-range`}\n                min={1}\n                max={n}\n                step={1}\n                value={displayIndex + 1}\n                aria-label=\"Playhead\"\n                aria-valuetext={displayEntry ? describeExposureFrame(displayEntry, n) : undefined}\n                onChange={onRangeChange}\n                onKeyDown={onRangeKeyDown}\n                onPointerDown={onRangePointerDown}\n                onPointerUp={onRangePointerEnd}\n                onPointerCancel={onRangePointerEnd}\n                onLostPointerCapture={onRangePointerEnd}\n              />\n            ) : (\n              <span className=\"f12-xs-one\">{n === 1 ? '1 frame' : '0 frames'}</span>\n            )}\n            <span className=\"f12-xs-count\" aria-hidden=\"true\">\n              {n > 0 ? `${displayIndex + 1} / ${n}` : '0 / 0'}\n            </span>\n          </div>\n          <div className=\"f12-xs-tr-row\">\n            <button\n              type=\"button\"\n              className=\"f12-xs-tbtn\"\n              id={`${prefix}-prev-mark`}\n              aria-disabled={!multi || !ex.markers.some((m) => m < index)}\n              onClick={(e) => markStep(-1, e)}\n            >\n              <span aria-hidden=\"true\">‹◆ </span>Prev mark\n            </button>\n            <button\n              type=\"button\"\n              className=\"f12-xs-tbtn\"\n              id={`${prefix}-next-mark`}\n              aria-disabled={!multi || !ex.markers.some((m) => m > index)}\n              onClick={(e) => markStep(1, e)}\n            >\n              Next mark<span aria-hidden=\"true\"> ◆›</span>\n            </button>\n            <SegmentedControl\n              options={RATE_OPTIONS}\n              value={ex.rate}\n              onChange={(r) => ex.setRate(r as ExposureRate)}\n              ariaLabel=\"Playback rate\"\n              idPrefix={`${prefix}-rate`}\n              className=\"f12-xs-rate\"\n            />\n            <fieldset className=\"f12-tempo f12-xs-timing\" disabled={!multi}>\n              <legend className=\"f12-sr-only\">Timing</legend>\n              <div className=\"f12-rng f12-tempo-rng\">\n                {TIMING_OPTIONS.map((opt) => {\n                  const id = `${prefix}-timing-${opt.value}`;\n                  const unavailable = opt.value === 'flipbook' && !ex.flipbookAvailable;\n                  return (\n                    <label key={opt.value} className=\"f12-rng-btn f12-tempo-opt\" htmlFor={id} data-unavailable={unavailable ? 'true' : undefined}>\n                      <input\n                        id={id}\n                        className=\"f12-tempo-input\"\n                        type=\"radio\"\n                        name={`${prefix}-timing`}\n                        value={opt.value}\n                        checked={ex.requestedTiming === opt.value}\n                        disabled={unavailable}\n                        aria-describedby={unavailable ? noteId : undefined}\n                        onChange={() => ex.setTiming(opt.value)}\n                      />\n                      <span className=\"f12-rng-n\" aria-hidden=\"true\">\n                        {opt.label}\n                      </span>\n                      <span className=\"f12-rng-u\" aria-hidden=\"true\">\n                        {opt.unit}\n                      </span>\n                      <span className=\"f12-sr-only\">{`${opt.label} ${opt.unit}, ${opt.meaning}`}</span>\n                    </label>\n                  );\n                })}\n              </div>\n            </fieldset>\n          </div>\n          {transportNote && (\n            <p className=\"f12-xs-note\" id={noteId}>\n              {transportNote}\n            </p>\n          )}\n        </fieldset>\n\n        {/* 2 · The exposure sheet (one roving tab stop) */}\n        {n > 0 && (\n          <details\n            className=\"f12-xs-disc\"\n            open={sheetOpen}\n            onToggle={(e) => setSheetOpen(e.currentTarget.open)}\n          >\n            <summary className=\"f12-xs-sum\">{`Exposure sheet · ${n} ${frameWord}`}</summary>\n            <div className=\"f12-xs-scroll\" ref={scrollRef}>\n              <table role=\"table\" className=\"f12-xs-sheet\">\n                <caption className=\"f12-xs-cap\">{`${label} · ${n} ${frameWord}`}</caption>\n                <thead role=\"rowgroup\">\n                  <tr role=\"row\" className=\"f12-xs-hrow\">\n                    <th role=\"columnheader\" scope=\"col\">FRAME</th>\n                    <th role=\"columnheader\" scope=\"col\">ACTION</th>\n                    <th role=\"columnheader\" scope=\"col\">\n                      TIMING <span className=\"f12-xs-sc\">{timingHeader}</span>\n                    </th>\n                    <th role=\"columnheader\" scope=\"col\">MARK</th>\n                  </tr>\n                </thead>\n                <tbody\n                  role=\"rowgroup\"\n                  ref={tbodyRef}\n                  onClick={onBodyClick}\n                  onKeyDown={onBodyKeyDown}\n                  onPointerDown={onBodyPointerDown}\n                  onPointerMove={onBodyPointerMove}\n                  onPointerUp={endDrag}\n                  onPointerCancel={endDrag}\n                  onLostPointerCapture={endDrag}\n                >\n                  {chunks.map((rows) => {\n                    const start = rows[0].index;\n                    const end = start + rows.length;\n                    return (\n                      <ExposureRowChunk\n                        key={start}\n                        rows={rows}\n                        total={n}\n                        current={index >= start && index < end ? index : -1}\n                        primary={ex.primaryMarkerIndex >= start && ex.primaryMarkerIndex < end ? ex.primaryMarkerIndex : -1}\n                        timing={ex.timing}\n                        maxGapMs={ex.maxGapMs}\n                      />\n                    );\n                  })}\n                </tbody>\n              </table>\n            </div>\n          </details>\n        )}\n\n        {/* 3 · The detail panel */}\n        <Panel\n          className=\"f12-xs-panel\"\n          label={`${label}: current frame`}\n          variant={variant}\n          cut={false}\n        >\n          <span className=\"f12-cut f12-xs-cut\" aria-hidden=\"true\">\n            {ex.flipping ? 'CURRENT CUT / FLIPPING' : panelEntry ? `CURRENT CUT / ${frameNo(panelEntry.index)}` : 'CURRENT CUT / —'}\n          </span>\n          {n === 0 ? (\n            <div className=\"f12-xs-empty\">\n              {emptyState ?? (\n                <p className=\"f12-xs-empty-msg\">\n                  <span className=\"f12-xs-mono\" aria-hidden=\"true\">[ ∅ ] </span>\n                  No frames yet. A run with steps will appear here as an exposure sheet.\n                </p>\n              )}\n            </div>\n          ) : panelEntry ? (\n            // The body and header persist across frames (a focused title survives j/k); only the\n            // consumer content is keyed per frame (fresh error boundary, swap transition).\n            <div className=\"f12-xs-body\">\n              <div className=\"f12-xs-head\">\n                <p className=\"f12-xs-pos\">\n                  <span className=\"f12-xs-pnum\">{frameNo(panelEntry.index)}</span>\n                  {panelEntry.elapsedMs !== undefined && (\n                    <span className=\"f12-xs-pel\">{formatElapsed(panelEntry.elapsedMs)}</span>\n                  )}\n                  {panelEntry.kind && <span className=\"f12-xs-k\">{panelEntry.kind}</span>}\n                </p>\n                <p className=\"f12-xs-title\" id={`${prefix}-title`} tabIndex={-1}>\n                  {panelEntry.label}\n                </p>\n                {(panelEntry.status || panelEntry.marker) && (\n                  <p className=\"f12-xs-pmeta\">\n                    {panelEntry.status && <StatusWord status={panelEntry.status} />}\n                    {panelEntry.marker && (\n                      <span className={panelEntry.index === ex.primaryMarkerIndex ? 'f12-xs-mk f12-xs-mk-primary' : 'f12-xs-mk'}>\n                        <span aria-hidden=\"true\">{panelEntry.index === ex.primaryMarkerIndex ? '◆ ' : '◇ '}</span>\n                        {panelEntry.index === ex.primaryMarkerIndex ? 'MARK' : 'mark'}\n                      </span>\n                    )}\n                  </p>\n                )}\n              </div>\n              {ex.flipping ? (\n                // While flipping the header holds the frame where the flip started and the content\n                // is a static slate: the panel does not update (and a focused title survives).\n                <div className=\"f12-xs-slate\">\n                  <p className=\"f12-xs-slate-t\">FLIPPING</p>\n                  <p className=\"f12-xs-slate-s\">\n                    12 poses per second{ex.rate !== 1 ? ` × ${ex.rate}` : ''}. Watch the sheet&apos;s rhythm; pause to read a frame.\n                  </p>\n                </div>\n              ) : (\n                <>\n                  <div\n                    className=\"f12-xs-content\"\n                    key={panelEntry.key}\n                    data-swap={swapped ? 'true' : undefined}\n                    data-exposure-content=\"\"\n                    onKeyDown={(e) => {\n                      contentKeys.current.add(e.nativeEvent);\n                    }}\n                  >\n                    <FrameBoundary frameId={panelEntry.key}>\n                      <FrameSlot\n                        render={renderFrame}\n                        frame={panelEntry.source}\n                        index={panelEntry.index}\n                        scrubbing={ex.scrubbing}\n                        settled={ex.settled}\n                      />\n                    </FrameBoundary>\n                  </div>\n                  {(panelEntry.causes.length > 0 || ex.back) && (\n                    <div className=\"f12-xs-links\">\n                      {panelEntry.causes.length > 0 && (\n                        <>\n                          <p className=\"f12-xs-links-h\" id={`${prefix}-from`}>\n                            Led here from\n                          </p>\n                          <ul className=\"f12-xs-links-l\" aria-labelledby={`${prefix}-from`}>\n                            {panelEntry.causes.map((ci) => (\n                              <li key={entries[ci].key}>\n                                <button\n                                  type=\"button\"\n                                  className=\"f12-xs-tbtn f12-xs-cause\"\n                                  disabled={!ready}\n                                  onClick={() => {\n                                    ex.followCause(ci);\n                                    setFocusRequest((r) => r + 1);\n                                  }}\n                                >\n                                  {`${frameNo(ci)} · ${entries[ci].label}`}\n                                </button>\n                              </li>\n                            ))}\n                          </ul>\n                        </>\n                      )}\n                      {ex.back && (\n                        <button type=\"button\" className=\"f12-xs-tbtn f12-xs-back\" disabled={!ready} onClick={() => {\n                            ex.goBack();\n                            setFocusRequest((r) => r + 1);\n                          }}>\n                          <span aria-hidden=\"true\">↩ </span>\n                          {`Back to ${frameNo(ex.back.index)}`}\n                        </button>\n                      )}\n                    </div>\n                  )}\n                </>\n              )}\n            </div>\n          ) : null}\n        </Panel>\n      </div>\n      <div className=\"f12-sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n        {ex.announcement}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/frame12/exposure-scrubber.tsx"
    }
  ],
  "type": "registry:ui"
}