'use client'; import { useState } from 'react'; import confetti from 'canvas-confetti'; import styles from './ResultCard.module.css'; import TypeBadge from './TypeBadge'; import ConfidenceBar from './ConfidenceBar'; import StatsRadar from './StatsRadar'; import TopPredictions from './TopPredictions'; import FeedbackWidget from './FeedbackWidget'; export default function ResultCard({ predictionData, pokemonDetails, originalImage, onReset, onShinyActivated, onDislikeActivated }) { const [showShiny, setShowShiny] = useState(false); if (!predictionData) return null; const { pokemon_id, name, confidence, top_5 } = predictionData; const types = pokemonDetails?.types || []; const stats = pokemonDetails?.stats || {}; const spriteUrl = showShiny ? `https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/shiny/${pokemon_id}.png` : pokemonDetails?.sprite_url; return (

{name}

#{String(pokemon_id).padStart(4, '0')}
{predictionData.status === 'UNCERTAIN_POKEMON' && (
⚠️ Uncertainty Warning Unfortunately, PokedexNet cannot guarantee this prediction. While this is our best guess, the silhouette is heavily occluded, noisy, or atypical, triggering an epistemic disagreement in our ensemble.
)}
{spriteUrl ? ( {name} ) : (
?
)}
{types.map(type => ( ))} {showShiny && ( SHINY )}

Base Stats

{ if (isCorrect) { setShowShiny(true); if (onShinyActivated) { onShinyActivated(); } const defaults = { spread: 360, ticks: 50, gravity: 0, decay: 0.94, startVelocity: 24, shapes: ['star'], colors: ['FFE400', 'FFBD00', 'E89400', 'FFCA6C', 'FDFFB8'] }; function shoot() { confetti({ ...defaults, particleCount: 30, scalar: 1.1, shapes: ['star'] }); confetti({ ...defaults, particleCount: 8, scalar: 0.6, shapes: ['circle'] }); } setTimeout(shoot, 0); setTimeout(shoot, 100); setTimeout(shoot, 200); } else { if (onDislikeActivated) { onDislikeActivated(); } } }} />
{/* Debug Mode Comparison Section */} {(predictionData.debug_mode || predictionData.debug_silhouette) && (

{predictionData.detected_source === 'birefnet' ? 'BiRefNet' : 'SAM 2'} Silhouette Preprocessing (Debug Mode)

Original Input {originalImage ? ( Original Input ) : (
No original image available
)}
{predictionData.detected_source === 'birefnet' ? 'BiRefNet' : 'SAM 2'} Silhouette {predictionData.debug_silhouette ? ( Active Silhouette ) : (
No silhouette available
)}
)}
); }