"""Localization & media-ref query handlers — Phase 11.5."""
from __future__ import annotations

from uuid import UUID

from sqlalchemy.ext.asyncio import AsyncSession

from app.services.localization import ExperienceLocalizationService
from app.specifications.localization import (
    LocalizationListSpec,
    MediaRefListSpec,
    SiteLocaleBindingListSpec,
)


class LocalizationQueries:
    def __init__(self, session: AsyncSession) -> None:
        self.service = ExperienceLocalizationService(session)

    async def get_site_locale_binding(self, tenant_id: UUID, binding_id: UUID):
        return await self.service.get_site_locale_binding(tenant_id, binding_id)

    async def list_site_locale_bindings(
        self,
        tenant_id: UUID,
        *,
        offset: int,
        limit: int,
        spec: SiteLocaleBindingListSpec | None,
    ):
        return await self.service.list_site_locale_bindings(
            tenant_id, offset=offset, limit=limit, spec=spec
        )

    async def get_localization(self, tenant_id: UUID, localization_id: UUID):
        return await self.service.get_localization(tenant_id, localization_id)

    async def list_localizations(
        self,
        tenant_id: UUID,
        *,
        offset: int,
        limit: int,
        spec: LocalizationListSpec | None,
    ):
        return await self.service.list_localizations(
            tenant_id, offset=offset, limit=limit, spec=spec
        )

    async def get_media_ref(self, tenant_id: UUID, media_ref_id: UUID):
        return await self.service.get_media_ref(tenant_id, media_ref_id)

    async def list_media_refs(
        self,
        tenant_id: UUID,
        *,
        offset: int,
        limit: int,
        spec: MediaRefListSpec | None,
    ):
        return await self.service.list_media_refs(
            tenant_id, offset=offset, limit=limit, spec=spec
        )
