/* eslint-disable @next/next/no-img-element -- External card image URLs; next/image migration is out of scope. */ import { VOCAB } from '../../lib/collection-vocabulary.js'; import Button from '../ui/Button.js'; import GlassSurface from '../ui/GlassSurface.js'; const CONDITION_OPTIONS = ['NM', 'LP', 'MP', 'HP', 'DMG']; function confidencePercent(confidence) { if (confidence == null || Number.isNaN(confidence)) return null; return confidence <= 1 ? Math.round(confidence * 100) : Math.round(confidence); } function confidenceRingColor(pct) { if (pct == null) return 'var(--border)'; if (pct < 70) return 'var(--accent-ember)'; if (pct < 85) return 'var(--color-warning)'; return 'var(--color-success)'; } function confidenceCaption(pct) { if (pct == null) return null; if (pct >= 90) return 'Excellent match.'; if (pct >= 70) return 'Good match.'; return 'Low confidence — verify before adding.'; } function formatMetadataLine(card) { return [card.set, card.rarity, card.cardNumber].filter(Boolean).join(' · '); } function EmptyStateIllustration() { return ( ); } export default function ScannerResultPanel({ focusedCard = null, queue, isIdentifying = false, commitError = null, onAddToOwned, onAddToList, onRescan, }) { if (!focusedCard) { return (

Scan Result

{isIdentifying ? (

Identifying…

) : ( <>

Point your camera at a card or upload an image to see a match.

)}
); } const card = focusedCard; const confidencePct = confidencePercent(card.confidence); const isAdding = queue?.addingCardIds?.has(card.id) ?? false; const metadataLine = formatMetadataLine(card); const handleUpdateMetadata = (patch) => { queue?.updateCardMetadata?.(card.id, patch); }; return (

Scan Result

{confidencePct != null && ( {confidencePct}% Match )}
{card.image_url ? ( {card.name} ) : (
)}

{card.name}

{metadataLine && (

{metadataLine}

)}
Foil
{confidencePct != null && (
Confidence {confidencePct}%

{confidenceCaption(confidencePct)}

)}
{commitError && (
{commitError}
)}
); }