import { ExternalLink, Globe, Newspaper, Rss, Search } from "lucide-react"; import type { WebSourceMatch } from "@/lib/rasad-api"; const SHIELD_DOMAINS: Record = { "petra.gov.jo": "موثوق رسمي", "bbc.co.uk": "موثوق", "bbci.co.uk": "موثوق", "bbc.com": "موثوق", "aljazeera.net": "موثوق", "aljazeera.com": "موثوق", "reuters.com": "موثوق دولي", "afp.com": "موثوق دولي", "apnews.com": "موثوق دولي", "alarabiya.net": "موثوق", "skynewsarabia.com": "موثوق", "france24.com": "موثوق", "dw.com": "موثوق", "alhurra.com": "موثوق", "alghad.com": "محلي", "alrai.com": "محلي", "asharq.com": "إقليمي", "rt.com": "بحذر", "arabic.rt.com": "بحذر", "ar.wikipedia.org": "ويكيبيديا", "en.wikipedia.org": "Wikipedia", }; interface Props { matches: WebSourceMatch[]; webResults?: WebSourceMatch[]; contradictions?: WebSourceMatch[]; queries?: string[]; engines?: Record; rssCount?: number; webHitsSeen?: number; webScraped?: number; className?: string; } const formatDate = (iso?: string | null): string => { if (!iso) return ""; const date = new Date(iso); if (Number.isNaN(date.getTime())) return iso.toString().slice(0, 10); return new Intl.DateTimeFormat("ar-SA", { dateStyle: "medium", }).format(date); }; const faviconUrl = (domain: string): string => { if (!domain) return ""; return `https://www.google.com/s2/favicons?domain=${domain}&sz=32`; }; const KindIcon = ({ kind }: { kind: string }) => { const Icon = kind === "rss" ? Rss : kind === "web" ? Globe : Newspaper; return ; }; export const WebSourcesPanel = ({ matches, webResults = [], contradictions = [], queries = [], engines = {}, rssCount = 0, webHitsSeen = 0, webScraped = 0, className = "", }: Props) => { // Combine matches and webResults, deduplicating by URL, prefer matches const seen = new Set(); const all: WebSourceMatch[] = []; for (const m of matches) { if (!m.url || seen.has(m.url)) continue; seen.add(m.url); all.push(m); } for (const m of webResults) { if (!m.url || seen.has(m.url)) continue; seen.add(m.url); all.push(m); } if (all.length === 0 && contradictions.length === 0) { return (
مصادر الإنترنت

لم نجد أي مصدر يذكر هذا الادعاء بعد البحث في {webHitsSeen} نتيجة من الإنترنت و {rssCount} مقالة من خلاصات RSS.

{queries.length > 0 && (
{queries.map((q, i) => ( {q.length > 40 ? q.slice(0, 40) + "…" : q} ))}
)}
); } const activeEngines = Object.entries(engines) .filter(([, v]) => v) .map(([k]) => k); return (
مصادر الإنترنت ({all.length})
{webScraped > 0 && ( SCRAPED {webScraped} )} {webHitsSeen > 0 && ( HITS {webHitsSeen} )} {rssCount > 0 && ( RSS {rssCount} )}
{activeEngines.length > 0 && (
محركات نشطة: {activeEngines.map((e) => ( {e} ))}
)}
    {all.map((m, i) => { const domain = m.domain || m.source_name || ""; const trust = SHIELD_DOMAINS[domain] || SHIELD_DOMAINS[domain.replace(/^www\./, "")]; const simPct = Math.round((m.similarity ?? 0) * 100); return (
  • {domain ? ( { e.currentTarget.style.display = "none"; }} /> ) : ( )}
    {domain || m.source_name} {trust && ( {trust} )} {m.kind === "rss" ? "RSS" : "ويب"} {m.pub_date && {formatDate(m.pub_date)}} {simPct}% تطابق
    {m.title || m.url} {m.summary && (

    {m.summary}

    )} {m.url.length > 70 ? m.url.slice(0, 70) + "…" : m.url}
  • ); })}
{contradictions.length > 0 && (
تطابقات ضعيفة أو محتمل تناقضها ({contradictions.length})
    {contradictions.map((c, i) => (
  • {c.source_name} {" — "} {c.title} {" "} {Math.round((c.similarity ?? 0) * 100)}%
  • ))}
)}
); };