// ★ on the walk makes a clip a trailer candidate (UI notes 2026-10-30, #7). // // A favourite is not a verdict and not a correction: it is the walk saying // "this one is gold", which is exactly the list a trailer is cut from. The // candidates are the starred clips, in the cut's order, each as a trailer // beat over what the clip plays (report-to-video/trailer.mjs parseBeats: // `{ id, start, end }` in source seconds) -- so the list is a `--beats-json` // as it stands, and whatever lists or suggests trailer beats starts from it. // // Plain ESM: the CLI runs it under bare node. import { playedSpan } from "./citeFollow.mjs"; /** * The cut's starred clips as trailer beats, in timeline order. A clip that * would not play (incorrect, rejected) is left out. * * @param {Record} m * @returns {Array<{ id: string, start: number, end: number, label?: string, quote?: string, walkNote?: string }>} */ export function trailerCandidates(m) { const out = []; for (const e of m?.timeline ?? []) { if (e?.type !== "clip" || e.star !== true) continue; if (e.verdict === "incorrect" || e.verdict === "rejected") continue; const { from, to } = playedSpan(e); if (!Number.isFinite(from) || !Number.isFinite(to) || to <= from) continue; out.push({ id: String(e.id), start: from, end: to, ...(typeof e.quote === "string" && e.quote.trim() ? { quote: e.quote.trim() } : {}), ...(typeof e.walkNote === "string" && e.walkNote.trim() ? { walkNote: e.walkNote.trim() } : {}), }); } return out; } /** The candidates as `--beats-json` takes them: `{ id, start, end }` only. */ export const candidateBeats = (m) => trailerCandidates(m).map(({ id, start, end }) => ({ id, start, end }));