"""Base extractor class for domain-specific OCR extraction."""
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, Optional


@dataclass
class ExtractionResult:
    """Base result for extraction operations."""

    success: bool
    confidence: float
    raw_text: str
    processing_time_ms: int
    extracted_data: dict[str, Any] = field(default_factory=dict)
    error: Optional[str] = None


class BaseExtractor(ABC):
    """Abstract base class for domain-specific extractors."""

    @abstractmethod
    def extract(self, image_bytes: bytes, content_type: Optional[str] = None) -> ExtractionResult:
        """
        Extract domain-specific data from an image.

        Args:
            image_bytes: Raw image bytes
            content_type: MIME type of the image

        Returns:
            ExtractionResult with extracted data
        """
        pass

    @abstractmethod
    def validate(self, data: Any) -> bool:
        """
        Validate extracted data.

        Args:
            data: Extracted data to validate

        Returns:
            True if data is valid
        """
        pass
