import React, { useState, useEffect, useRef } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { RobotAssistant } from './RobotAssistant'; import { X, ChevronRight, CheckCircle2 } from 'lucide-react'; interface TutorialStep { targetId: string; title: string; description: string; robotMessage: string; offset: { x: number; y: number }; } const dashboardSteps: TutorialStep[] = [ { targetId: 'hero-title', title: 'Mission Control', description: 'Welcome to your central command. This is where high-level objectives are deployed.', robotMessage: "Systems ONLINE! I'm your tactical interface. Let's start the tour!", offset: { x: 50, y: 150 } }, { targetId: 'progress-bar', title: 'Neural Synchronization', description: 'Your level progress represents your synchronization with the core matrix.', robotMessage: "Keep this bar full! We need maximum sync for deep-dive missions.", offset: { x: 50, y: 100 } }, { targetId: 'missions-matrix', title: 'Mission Matrix', description: 'Select a node to begin deployment. Each card acts as a secure cover page for your mission intel.', robotMessage: "The Matrix is loaded with fresh intel! Overload these nodes to gain XP.", offset: { x: -350, y: -50 } }, { targetId: 'intel-feed', title: 'Intel Feed', description: 'Direct streams from the NLP Academy. Stay sharp with decrypted field reports.', robotMessage: "Intel is power, recruit! Check the feed before every mission.", offset: { x: 50, y: -250 } } ]; const navigatorSteps: TutorialStep[] = [ { targetId: 'matrix-grid', title: 'Navigator Matrix', description: 'Interact with the 2D grid to navigate through complex neural architectures.', robotMessage: "Check the grid! We use DQN algorithms here to find the optimal learning path.", offset: { x: 200, y: 200 } }, { targetId: 'control-center', title: 'Control Center', description: 'Analyze your progress, manage bookmarks, and run simulations.', robotMessage: "This is the brain! Run simulations to see how the agent optimizes objectives.", offset: { x: -400, y: 100 } } ]; interface DashboardTutorialProps { onComplete: () => void; page?: 'dashboard' | 'navigator'; } const DashboardTutorial: React.FC = ({ onComplete, page = 'dashboard' }) => { const [currentStep, setCurrentStep] = useState(0); const [robotPos, setRobotPos] = useState({ x: 0, y: 0 }); const [targetRect, setTargetRect] = useState(null); const steps = page === 'dashboard' ? dashboardSteps : navigatorSteps; useEffect(() => { const updatePosition = () => { const step = steps[currentStep]; if (!step) return; const element = document.getElementById(step.targetId); if (element) { // Scroll element into view first element.scrollIntoView({ behavior: 'smooth', block: 'center' }); // Small delay to allow scroll to complete before measuring setTimeout(() => { const rect = element.getBoundingClientRect(); setTargetRect(rect); // Calculate desired positions let nx = rect.left + step.offset.x; let ny = rect.top + step.offset.y; // Viewport clamping (Robot is ~100x100 scaled 2x = 200x200) const margin = 20; nx = Math.max(margin, Math.min(nx, window.innerWidth - 220)); ny = Math.max(margin, Math.min(ny, window.innerHeight - 220)); setRobotPos({ x: nx, y: ny }); }, 600); } }; updatePosition(); window.addEventListener('resize', updatePosition); return () => window.removeEventListener('resize', updatePosition); }, [currentStep, steps]); const nextStep = () => { if (currentStep < steps.length - 1) { setCurrentStep(prev => prev + 1); } else { onComplete(); } }; const step = steps[currentStep]; return (
{/* Dynamic Reveal Highlight */} {targetRect && ( )} {/* Moving Robot Assistant */} {/* Instructional Speech Bubble */}

{step?.title}

"{step?.description}"

{steps.map((_, idx) => (
))}
{/* Tail for the speech bubble */}
{/* Skip Button */}
); }; export default DashboardTutorial;