# ==============================================
# Breakpilot Drive - Unit API (barrel re-export)
# ==============================================
# This module was split into:
#   - unit_models.py      (Pydantic models)
#   - unit_helpers.py      (Auth, DB, token, validation helpers)
#   - unit_routes.py       (Definition, session, analytics routes)
#   - unit_content_routes.py (H5P, worksheet, PDF routes)
#
# The `router` object is assembled here by including all sub-routers.
# Importers that did `from units.api import router` continue to work.

from fastapi import APIRouter

from .routes import router as _routes_router
from .definition_routes import router as _definition_router
from .content_routes import router as _content_router

# Re-export models for any direct importers
from .models import (  # noqa: F401
    UnitDefinitionResponse,
    CreateSessionRequest,
    SessionResponse,
    TelemetryEvent,
    TelemetryPayload,
    TelemetryResponse,
    PostcheckAnswer,
    CompleteSessionRequest,
    SessionSummaryResponse,
    UnitListItem,
    RecommendedUnit,
    CreateUnitRequest,
    UpdateUnitRequest,
    ValidationError,
    ValidationResult,
)

# Re-export helpers for any direct importers
from .helpers import (  # noqa: F401
    get_optional_current_user,
    get_unit_database,
    create_session_token,
    verify_session_token,
    get_session_from_token,
    validate_unit_definition,
    USE_DATABASE,
    REQUIRE_AUTH,
    SECRET_KEY,
)

# Assemble the combined router.
# _routes_router and _content_router both use prefix="/api/units",
# so we create a plain router and include them without extra prefix.
router = APIRouter()
router.include_router(_routes_router)
router.include_router(_definition_router)
router.include_router(_content_router)
