'use client';
import { Search, Brain, Package, Loader2, CheckCircle2, Globe } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useState, useEffect } from 'react';
export type ProcessingStep =
| 'collecting'
| 'processing'
| 'searching'
| 'preparing'
| 'streaming';
interface ProcessingIndicatorProps {
currentStep: ProcessingStep;
progress?: number; // 0-100
sourcesCount?: number;
}
export function ProcessingIndicator({
currentStep,
progress = 0,
sourcesCount = 0,
}: ProcessingIndicatorProps) {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
// Fade-in animation
setIsVisible(true);
}, []);
const steps: Array<{
key: ProcessingStep;
label: string;
icon: React.ReactNode;
emoji: string;
}> = [
{
key: 'collecting',
label: 'Coletando Dados',
icon: ,
emoji: '🔍',
},
{
key: 'processing',
label: 'Processando...',
icon: ,
emoji: '🤖',
},
{
key: 'searching',
label: sourcesCount > 0 ? `Buscando na Web (${sourcesCount} fontes)...` : 'Buscando na Web...',
icon: ,
emoji: '🌐',
},
{
key: 'preparing',
label: 'Preparando Contexto',
icon: ,
emoji: '📦',
},
{
key: 'streaming',
label: 'Gerando Resposta...',
icon: ,
emoji: '💬',
},
];
const currentStepIndex = steps.findIndex(s => s.key === currentStep);
const currentStepData = steps[currentStepIndex] || steps[0];
return (
{/* Card de Status Atual */}
{currentStep === 'collecting' && (
)}
{currentStep === 'processing' && (
)}
{currentStep === 'searching' && (
)}
{currentStepData.emoji}
{currentStepData.label}
{progress > 0 && progress < 100 && (
)}
{/* Timeline Visual */}
{steps.slice(0, currentStepIndex + 1).map((step, idx) => {
const isActive = idx === currentStepIndex;
const isPast = idx < currentStepIndex;
return (
{isPast ? (
) : isActive ? (
) : (
step.icon
)}
{step.label.split(' ')[0]} {/* Mostrar apenas primeira palavra na timeline */}
{idx < currentStepIndex && (
)}
);
})}
{/* Timeline Vertical para Mobile */}
{steps.slice(0, currentStepIndex + 1).map((step, idx) => {
const isActive = idx === currentStepIndex;
const isPast = idx < currentStepIndex;
return (
{isPast ? (
) : isActive ? (
) : (
step.icon
)}
{step.label}
);
})}
);
}