"""
Translation Providers Package.

This package provides a pluggable architecture for translation providers
with a registry for easy access and fallback support.

Usage:
    from services.providers import TranslationProvider, registry
    from services.providers.schemas import TranslationRequest, TranslationResponse

    # Get a provider (Google is auto-registered)
    google_provider = registry.get("google")

    # Translate text
    request = TranslationRequest(text="Hello", target_language="fr")
    response = google_provider.translate_text(request)

    # Use fallback chain
    provider = registry.get_first_available(["google", "openai"])
"""

from .base import TranslationProvider
from .schemas import (
    TranslationRequest,
    TranslationResponse,
    BatchTranslationRequest,
    BatchTranslationResponse,
    ProviderHealthStatus,
)
from .registry import ProviderRegistry, registry, get_registry

__all__ = [
    "TranslationProvider",
    "TranslationRequest",
    "TranslationResponse",
    "BatchTranslationRequest",
    "BatchTranslationResponse",
    "ProviderHealthStatus",
    "ProviderRegistry",
    "registry",
    "get_registry",
    "translate_with_fallback",
    "translate_with_fallback_by_mode",
    "AllProvidersFailedError",
    "ALL_PROVIDERS_FAILED",
]


def _auto_register_providers() -> None:
    """Auto-register available providers on module import."""
    from .google_provider import register_google_provider
    from .config import ProvidersConfig

    if ProvidersConfig.GOOGLE_ENABLED:
        register_google_provider()

    if ProvidersConfig.OPENAI_ENABLED and ProvidersConfig.OPENAI_API_KEY:
        from .openai_provider import register_openai_provider

        register_openai_provider()

    if ProvidersConfig.DEEPSEEK_ENABLED and ProvidersConfig.DEEPSEEK_API_KEY:
        from .deepseek_provider import register_deepseek_provider

        register_deepseek_provider()

    if ProvidersConfig.MINIMAX_ENABLED and ProvidersConfig.MINIMAX_API_KEY:
        from .minimax_provider import register_minimax_provider

        register_minimax_provider()


_auto_register_providers()

# Import fallback functions for easy access
from .fallback import (
    translate_with_fallback,
    translate_with_fallback_by_mode,
    AllProvidersFailedError,
    ALL_PROVIDERS_FAILED,
)
