"use client"; import { Radio, Signal } from "lucide-react"; import { useMemo } from "react"; import { GlassPanel } from "@/components/primitives"; import { SectionHeader } from "@/components/shared"; import { useStaggerReveal } from "@/hooks/use-gsap-animation"; import { downloadCsv } from "@/lib/csv"; import { formatRelativeTime } from "@/lib/format"; import type { ChannelCultureRow } from "@/lib/types"; /** * Deterministic pseudo signal-strength (0..1) derived from recency + summary * richness — purely cosmetic telemetry framing, no backend field for this. */ function deriveSignalStrength(c: ChannelCultureRow): number { let score = 0.25; if (c.culture_summary) { score += Math.min(0.45, c.culture_summary.length / 400); } if (c.last_analyzed_at) { const ageMs = Date.now() - c.last_analyzed_at; const days = ageMs / (1000 * 60 * 60 * 24); score += Math.max(0, 0.3 - days * 0.02); } return Math.max(0.08, Math.min(1, score)); } export function ChannelCultureGlossary({ cultures, }: { cultures: ChannelCultureRow[]; }) { const ranked = useMemo( () => cultures .map((c) => ({ c, signal: deriveSignalStrength(c) })) .sort((a, b) => b.signal - a.signal), [cultures], ); const hudRef = useStaggerReveal(".channel-node", { stagger: 0.045, y: 14, dependencies: [cultures], }); return ( Channel Culture Glossary } action={ cultures.length > 0 ? ( ) : null } /> {cultures.length === 0 ? (

NO CHANNEL TELEMETRY CAPTURED YET

) : (
{ranked.map(({ c, signal }) => (
#{c.channel_name ?? c.channel_id.slice(0, 8)}
{c.last_analyzed_at && ( {formatRelativeTime(c.last_analyzed_at)} )}
{c.culture_summary ? (

{c.culture_summary}

) : ( (no summary captured) )} {/* Signal strength readout bar */}
))}
)} ); }