"""Kurier: A unified messaging abstraction layer for Python."""

from typing import TYPE_CHECKING

from .core.bus_types import BusType
from .core.station import Station
from .utilities.serializers import CloudEventSerializer, JsonSerializer, Serializer

if TYPE_CHECKING:
    from .transports import AzureLine, InMemoryLine, KafkaLine, RabbitMQLine

# Lazy loading mapping for transport classes
_LAZY_IMPORTS = {
    "InMemoryLine": "kurier.transports.inmemory.bus",
    "KafkaLine": "kurier.transports.kafka.kafkaline",
    "RabbitMQLine": "kurier.transports.rabbitmq.rabbitmqline",
    "AzureLine": "kurier.transports.azure.azureline",
}


def __getattr__(name: str):
    """Lazily import transport classes on first access."""
    if name in _LAZY_IMPORTS:
        module_path = _LAZY_IMPORTS[name]
        try:
            module = __import__(module_path, fromlist=[name])
        except ImportError as e:
            raise ImportError(f"Could not import {name}. Ensure you have the required extras installed. Error: {e}") from e
        return getattr(module, name)
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


__all__ = [
    "Station",
    "BusType",
    "InMemoryLine",
    "KafkaLine",
    "RabbitMQLine",
    "AzureLine",
    "Serializer",
    "JsonSerializer",
    "CloudEventSerializer",
]
