import React from 'react'; import { ShieldAlert, AlertTriangle } from 'lucide-react'; import { enumLabel } from '../../../utils/i18n-enums'; import type { FindingAccent } from '../sections/FindingCard'; import { FindingCardBox, FindingIconBox, FindingBody, FindingEyebrow, FindingHeadline, FindingSourceRow, ScoresBlock, ScoreLine, ScoreLineName, ScoreLineBar, ScoreLineFill, ScoreLineNum, } from '../styles'; import { SectionDivider } from '../sections/SectionDivider'; const ACCENT_HEX: Record = { critical: '#ef4444', warning: '#f97316', info: '#3b82f6', success: '#22c55e', neutral: '#94a3b8', violet: '#7fd0d4', }; function trustAccent(trust: number): FindingAccent { if (trust >= 70) return 'success'; if (trust >= 40) return 'warning'; return 'critical'; } function barColor(score: number): string { return score >= 70 ? '#22c55e' : score >= 40 ? '#f97316' : '#ef4444'; } export function renderSourceEditorial(data: any, isRo: boolean) { if (!data) return null; const trust = data.trust_score ?? 0; const accent = trustAccent(trust); const accentHex = ACCENT_HEX[accent]; const verdictLabel = enumLabel(data.verdict || '').replace(/_/g, ' '); const riskLevel = enumLabel(data.risk_level || ''); const pub = data.publication || {}; const auth = data.author || {}; const plat = data.platform || {}; const dom = data.domain || {}; const formula = data.formula || {}; void formula; const headline = isRo ? `${verdictLabel} — încredere ${trust}/100${riskLevel ? ` · risc ${riskLevel.toLowerCase()}` : ''}` : `${verdictLabel} — trust ${trust}/100${riskLevel ? ` · ${riskLevel.toLowerCase()} risk` : ''}`; const axes = [ { name: isRo ? 'Publicație' : 'Publication', score: pub.score ?? 0, weight: Math.round((formula.publication_weight ?? 0.35) * 100), }, { name: isRo ? 'Autor' : 'Author', score: auth.score ?? 0, weight: Math.round((formula.author_weight ?? 0.25) * 100), }, { name: isRo ? 'Platformă' : 'Platform', score: plat.score ?? 0, weight: Math.round((formula.platform_weight ?? 0.15) * 100), }, { name: isRo ? 'Domeniu' : 'Domain', score: dom.score ?? 0, weight: Math.round((formula.domain_weight ?? 0.25) * 100), }, ]; const flags: string[] = []; if (!pub.confirmed) flags.push(isRo ? 'fără publicație confirmată' : 'no confirmed publication'); if (!auth.confirmed) flags.push(isRo ? 'fără autor identificat' : 'no identified author'); if (!dom.name || dom.name === 'N/A') flags.push(isRo ? 'fără domeniu' : 'no domain'); if (data.red_flags?.length) flags.push(...data.red_flags.map((f: string) => f.replace(/_/g, ' ').toLowerCase())); return ( <> {verdictLabel} {headline} {axes.map((ax, i) => ( {ax.name} {ax.score} ))} {flags.length > 0 && ( {flags.map((f, idx) => ( {idx > 0 && ·} {f} ))} )} ); } export function renderSourceDetail(data: any) { const isRo = (typeof document !== 'undefined' && document.documentElement.lang || '').toLowerCase().startsWith('ro'); return <>{renderSourceEditorial(data, isRo)}; } export function renderSourceSummary(data: any) { if (!data) return null; const trust = data.trust_score ?? 0; return ( Trust {trust}% · {enumLabel(data.verdict || '').replace(/_/g, ' ')} ); }