import { cn } from "@/lib/utils"; import { threadLabels } from "@/lib/cite-thread.mjs"; import { clock } from "./clock"; // Where a cited second sits in its source (canvas `.cthread` / `.pthread`): a // hairline the length of the recording, a notch at the cite. Information, not // decoration -- a quote at 1:02:14 of a four-hour VOD reads differently from one // at 0:00:40 of a clip. // // On the DESK (a result line) it is one row with "at / of" on the right, and // shows on the lit line only (wrap it in `data-lit-only`); on the READER (a // pane's header) it carries 0:00, the cite and the end under the line. export function CiteThread({ at, duration, className, }: { /** The cited second. */ at: number; /** The recording's length, seconds. */ duration: number; className?: string; }) { const pct = duration > 0 ? Math.min(100, Math.max(0, (at / duration) * 100)) : 0; const label = `${clock(at)} of ${clock(duration)}`; return (
{clock(at)} / {clock(duration)}
); } /** The reader's version: start, cite and end under the line; the cite's label never on an end's (lib/cite-thread.mjs). */ export function ReaderThread({ at, duration, className }: { at: number; duration: number; className?: string }) { const pct = duration > 0 ? Math.min(100, Math.max(0, (at / duration) * 100)) : 0; const cite = clock(at); const end = clock(duration); const l = threadLabels({ pct, citeChars: cite.length, startChars: "0:00".length, endChars: end.length }); return (
{/* The ends give way when the cite's own label would sit on them. */} {l.showStart && 0:00} {cite} {l.showEnd && {end}}
); }