from typing import Any, Dict

from fastapi import APIRouter, Depends, HTTPException

from modules.auth.supabase_bearer import SupabaseBearer
from modules.database.services.bootstrap_service import build_bootstrap_response

router = APIRouter()
auth_scheme = SupabaseBearer()


@router.get("/bootstrap")
async def get_me_bootstrap(credentials: Dict[str, Any] = Depends(auth_scheme)) -> Dict[str, Any]:
    """Authenticated Supabase-first session/onboarding bootstrap contract."""
    try:
        return build_bootstrap_response(credentials)
    except ValueError as exc:
        raise HTTPException(status_code=403, detail=str(exc)) from exc
