import { useState, useEffect } from "react"; /** * Enhanced loading component with visual feedback * * Features: * - Progress indicator with percentage display * - Animated loading spinner * - Progress bar visualization * - Contextual status messages * - Animated ellipsis for active feedback * * @param progress - Current progress percentage (0-100) * @param showDetails - Whether to show detailed status messages */ function Loading({ progress = 0, showDetails = false }: { progress?: number; showDetails?: boolean }) { const [dots, setDots] = useState(""); // Animated dots for the loading text (provides visual feedback even when progress is unknown) useEffect(() => { const interval = setInterval(() => { setDots(prev => (prev.length >= 3 ? "" : prev + ".")); }, 400); return () => clearInterval(interval); }, []); // Get appropriate status message based on current progress const getStatusMessage = () => { if (progress < 25) return "Analyzing request..."; if (progress < 50) return "Generating content..."; if (progress < 75) return "Processing changes..."; if (progress < 100) return "Finalizing..."; return "Complete!"; }; return (
{/* Progress circle with animated spin */} {/* Progress percentage in center - only shown when progress is known */} {progress > 0 && (
{progress}%
)}
{/* Main loading message with animated dots */}

AI is thinking{dots}

{/* Horizontal progress bar - only shown when progress is known */} {progress > 0 && (
)} {/* Optional detailed status message - shows processing stage */} {showDetails && (

{getStatusMessage()}

)}
); } export default Loading;