'use client'; import { motion } from 'framer-motion'; import { useLocale } from '@/lib/i18n/locale-context'; import { SectionHeader } from '@/components/ui/SectionHeader'; /** * Animated RAG pipeline: ingest → embed → retrieve → rerank → generate. * * The diagram itself is always laid out left-to-right (dir="ltr") regardless of * page locale — a data pipeline reads forward in both languages — while the * labels/descriptions come from the localized dictionary. The flowing dashes * are pure SVG (animated stroke-dashoffset), so there is no per-frame JS. */ type Accent = 'electric' | 'violet' | 'cyan' | 'magenta' | 'emerald'; const ACCENT_HEX: Record = { electric: '#38bdf8', violet: '#818cf8', cyan: '#22d3ee', magenta: '#e879f9', emerald: '#34d399', }; // Literal class maps so Tailwind's JIT scanner can see every variant. const ACCENT_TEXT: Record = { electric: 'text-electric', violet: 'text-violet', cyan: 'text-cyan', magenta: 'text-magenta', emerald: 'text-emerald', }; const ACCENT_BORDER: Record = { electric: 'border-electric/40', violet: 'border-violet/40', cyan: 'border-cyan/40', magenta: 'border-magenta/40', emerald: 'border-emerald/40', }; const ACCENT_HOVER_SHADOW: Record = { electric: 'hover:shadow-[0_0_30px_-12px_#38bdf8]', violet: 'hover:shadow-[0_0_30px_-12px_#818cf8]', cyan: 'hover:shadow-[0_0_30px_-12px_#22d3ee]', magenta: 'hover:shadow-[0_0_30px_-12px_#e879f9]', emerald: 'hover:shadow-[0_0_30px_-12px_#34d399]', }; function asAccent(value: string | undefined): Accent { return value === 'violet' || value === 'cyan' || value === 'magenta' || value === 'emerald' || value === 'electric' ? value : 'electric'; } export function DataFlow() { const { t } = useLocale(); const data = t.dataflow; const nodes = data.nodes; return (
{/* Diagram canvas — fixed LTR reading order. */}
{/* SVG connectors sit behind the cards on md+ (horizontal flow). */} {/* Static base rail */} {/* Animated travelling packets */}
    {nodes.map((node, i) => { const accent = asAccent(node.accent); return (
    {/* Step index + pulsing node dot */}
    {String(i + 1).padStart(2, '0')}

    {node.label}

    {node.desc}

    {/* Arrow connector for stacked (mobile / sm) layouts */} {i < nodes.length - 1 && ( )}
    ); })}
{data.caption && ( {data.caption} )}
); }