"""Availability query handlers — Phase 10.3."""
from __future__ import annotations

from uuid import UUID

from sqlalchemy.ext.asyncio import AsyncSession

from app.services.availability import AvailabilityService, ShiftService, WorkingZoneService
from app.specifications.availability import ShiftListSpec, WorkingZoneListSpec


class AvailabilityQueries:
    def __init__(self, session: AsyncSession) -> None:
        self.availability = AvailabilityService(session)
        self.shifts = ShiftService(session)
        self.zones = WorkingZoneService(session)

    async def get_availability(self, tenant_id: UUID, driver_id: UUID):
        return await self.availability.get_for_driver(tenant_id, driver_id)

    async def get_shift(self, tenant_id: UUID, shift_id: UUID):
        return await self.shifts.get(tenant_id, shift_id)

    async def list_shifts(
        self, tenant_id: UUID, *, offset: int, limit: int, spec: ShiftListSpec | None
    ):
        return await self.shifts.list(tenant_id, offset=offset, limit=limit, spec=spec)

    async def list_shift_assignments(self, tenant_id: UUID, shift_id: UUID):
        return await self.shifts.list_assignments(tenant_id, shift_id)

    async def get_zone(self, tenant_id: UUID, zone_id: UUID):
        return await self.zones.get(tenant_id, zone_id)

    async def list_zones(
        self, tenant_id: UUID, *, offset: int, limit: int, spec: WorkingZoneListSpec | None
    ):
        return await self.zones.list(tenant_id, offset=offset, limit=limit, spec=spec)
