import Link from 'next/link' import { contentPieceMediaKind, type ContentPiecePublicItem } from '@/lib/contentPieceCatalog' import { cn } from '@/lib/utils' import { ContentPieceDownloadLink, ContentPieceShareButton } from './ContentPieceActions' import { ContentPieceCardMeta, ContentPieceCardTitle } from './ContentPieceCardParts' import { ContentPieceMedia } from './ContentPieceMedia' import { CONTENT_PIECE_CARD, CONTENT_PIECE_EXACT_TAG, CONTENT_PIECE_TAG, } from './contentPieceClasses' type ContentPieceCardProps = { item: ContentPiecePublicItem playing: boolean onToggle: () => void onEnded: () => void onShare: (item: ContentPiecePublicItem) => void /** S28 — the board is in the theme mode: the badge states the provenance. */ themeMode: boolean } /** * S28 — the badge of a result. In the literal search it stays the editorial * tag; in the theme mode it states where the result came from: "✦ Tema" when an * expanded term surfaced the piece, "Termo exato" when only the query did * (never an invented theme). */ const CardTag = ({ item, themeMode }: { item: ContentPiecePublicItem; themeMode: boolean }) => { if (themeMode) { return item.themeMatch ? ( ✦ Tema ) : ( Termo exato ) } return ( {item.isLink ? item.originLabel : item.typeLabel} ) } const EVIDENCE_MARK = 'rounded-[3px] bg-[#fff09a] px-0.5 font-extrabold text-black' /** * S28 — "Por que apareceu" (artefato: cenas 05/06): the real passage that * carries the expanded term, quoted and highlighted. When the match came from * another part of the haystack the block falls back to a real passage of the * piece — no quotes, no highlight, with the origin label — and never invents a * match or a score. */ const CardThemeEvidence = ({ item }: { item: ContentPiecePublicItem }) => { const evidence = item.themeMatch?.evidence if (!evidence || evidence.parts.length === 0) return null const originLabel = evidence.source === 'description' ? 'Descrição da peça' : 'Transcrição da peça' return (
{evidence.quoted ? `“${evidence.truncatedStart ? '… ' : ''}` : null} {evidence.parts.map((part, index) => part.highlighted ? ( {part.text} ) : ( {part.text} ), )} {evidence.quoted ? `${evidence.truncatedEnd ? ' …' : ''}”` : null}