"""
Transport implementations for Kurier.

``InMemoryLine`` is always available. External transports (Kafka, RabbitMQ,
Azure Service Bus) are lazily imported so their heavy dependencies are only
loaded when actually accessed.
"""

from typing import TYPE_CHECKING

from .inmemory.bus import InMemoryLine

# Lazy loading mapping
_LAZY_IMPORTS = {
    "KafkaLine": "kurier.transports.kafka.kafkaline",
    "RabbitMQLine": "kurier.transports.rabbitmq.rabbitmqline",
    "AzureLine": "kurier.transports.azure.azureline",
}

if TYPE_CHECKING:
    from .azure.azureline import AzureLine
    from .kafka.kafkaline import KafkaLine
    from .rabbitmq.rabbitmqline import RabbitMQLine


def __getattr__(name: str):
    """Lazily import external 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__ = ["InMemoryLine", "KafkaLine", "RabbitMQLine", "AzureLine"]
