"use client"; import { useMemo, type CSSProperties } from "react"; import type { CallRecord } from "@/lib/types"; const WINDOW_MS = 60 * 60 * 1000; const MAX_ITEMS = 25; function hhmm(iso: string): string { return new Date(iso).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", hour12: false }); } /** * Live radio transcripts, newest first, as a slow belt along the bottom of * the wall (mockup "Radio" ticker). Clicking an incident id drills into it. * Transcripts are machine output — the same text the call list already shows. */ export function TranscriptTicker({ calls, onSelectIncident }: { calls: CallRecord[]; onSelectIncident: (id: string) => void }) { const items = useMemo(() => { const cutoff = Date.now() - WINDOW_MS; return calls .filter((c) => !c.duplicate_of && (c.transcript_corrected || c.transcript) && new Date(c.started_at).getTime() >= cutoff) .sort((a, b) => b.started_at.localeCompare(a.started_at)) .slice(0, MAX_ITEMS); }, [calls]); const belt = (copy: number) => items.map((c) => { const text = (c.transcript_corrected || c.transcript || "").replace(/\s+/g, " ").trim(); const inc = c.incident_ids?.[0] ?? c.incident_id ?? null; return ( 0}> {hhmm(c.started_at)} {c.talkgroup_name && {c.talkgroup_name}} {inc && ( )} {text.length > 160 ? `${text.slice(0, 157)}…` : text} ); }); return (