"""Health routes."""

from fastapi import APIRouter

from app.core.config import settings
from app.services.ai import provider_registry as ai_provider_registry
from app.services import runtime_config

router = APIRouter(tags=["health"])


@router.get("/health")
def health() -> dict[str, object]:
    """Basic API health check with selected AI provider status."""
    ai_status = ai_provider_registry.selected_provider_health()
    return {
        "status": "ok",
        "app": settings.app_name,
        "language": runtime_config.get_default_language("es"),
        "ai_provider": {
            "selected": ai_status["selected"],
            "available": bool(ai_status["available"]),
        },
    }


@router.get("/health/ai-config")
def health_ai_config() -> dict[str, object]:
    """Resolved AI configuration health snapshot without secrets."""
    return ai_provider_registry.ai_config_health()
