/** * DatasetTrainingConfigPanel.tsx * * Inline collapsible panel rendered inside LiveOperationsView that lets the * user: * 1. Choose one of 4 benchmark datasets (PaySim, IEEE-CIS, Elliptic, Credit Card) * 2. Toggle between "Mock Simulation" and "Real Backend" training modes * * On "Launch Training" the parent receives (profile, mode) and starts the * appropriate training path. This component carries NO training state — it is * purely presentational configuration UI. */ import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { ExternalLink, Zap, FlaskConical, ChevronRight, CheckCircle2 } from 'lucide-react'; import { DATASET_PROFILES, type DatasetProfile } from '../utils/datasetProfiles'; import { useModalA11y } from '../hooks/useModalA11y'; export type TrainingMode = 'mock' | 'real'; interface DatasetTrainingConfigPanelProps { isOpen: boolean; onClose: () => void; onLaunch: (profile: DatasetProfile, mode: TrainingMode) => void; initialDataset?: DatasetProfile['id']; initialMode?: TrainingMode; } // ── small helper: format numbers with K/M suffix ────────────────────────── function fmtCount(n: number): string { if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(2)}M`; if (n >= 1_000) return `${(n / 1_000).toFixed(0)}K`; return n.toString(); } function fmtFraud(r: number): string { if (r < 0.001) return `${(r * 100).toFixed(3)}%`; return `${(r * 100).toFixed(2)}%`; } const DATASET_ORDER: DatasetProfile['id'][] = ['paysim', 'ieee_cis', 'elliptic', 'creditcard']; export default function DatasetTrainingConfigPanel({ isOpen, onClose, onLaunch, initialDataset = 'paysim', initialMode = 'real', }: DatasetTrainingConfigPanelProps) { const [selectedId, setSelectedId] = useState(initialDataset); const [mode, setMode] = useState(initialMode); const { containerRef } = useModalA11y({ isOpen, onClose, closeOnEscape: true, trapFocus: false, // Inline expandable panel restoreFocus: true, }); const selectedProfile = DATASET_PROFILES[selectedId]; return ( {isOpen && (
{/* ── Header ──────────────────────────────────────────────────── */}

Configure Training Session

Select a benchmark dataset and training mode before launching

{/* ── Mode Toggle ─────────────────────────────────────────────── */}

Training Mode

{/* Real Backend (Default) */} {/* Offline Sandbox Demo */}
{/* ── Dataset Cards ────────────────────────────────────────────── */}

Benchmark Dataset

{DATASET_ORDER.map((dsId) => { const p = DATASET_PROFILES[dsId]; const isSelected = selectedId === dsId; return ( ); })}
{/* ── Selected dataset detail strip ────────────────────────────── */}
{selectedProfile.icon}

{selectedProfile.label}

{selectedProfile.subtitle}

{/* ── Launch button ────────────────────────────────────────────── */}
onLaunch(selectedProfile, mode)} className="flex items-center gap-2 px-6 py-2.5 rounded-xl font-bold text-sm text-white shadow-lg transition-all" style={{ background: `linear-gradient(135deg, ${selectedProfile.color}, #6366f1)`, boxShadow: `0 4px 20px ${selectedProfile.color}40`, }} > {mode === 'mock' ? : } Launch{' '} {mode === 'mock' ? 'Simulation' : 'Real Training'}
)}
); }