"""
django-notify-hub – A scalable, multi-backend Django notification package.

Quick start::

    from django_notify_hub import notify

    notify.send(
        title={"en": "Hello!", "ar": "مرحبا!"},
        body={"en": "You have a new message."},
        recipient=user,
        related_object=message_instance,
    )
"""

__version__ = "0.1.1"
default_app_config = "django_notify_hub.apps.DjangoNotifyHubConfig"


class _LazyNotificationHub:
    """
    Lazy singleton proxy for NotificationHub.

    NotificationHub (and everything it imports: services, repositories, models)
    is only instantiated on first attribute access — i.e. after Django's app
    registry is fully loaded.  Instantiating it eagerly at module level causes
    ``AppRegistryNotReady`` because Django imports this package as part of
    ``apps.populate()`` before the registry is ready.
    """

    _hub = None

    def __getattr__(self, name: str):
        if _LazyNotificationHub._hub is None:
            from django_notify_hub.hub import NotificationHub

            _LazyNotificationHub._hub = NotificationHub()
        return getattr(_LazyNotificationHub._hub, name)


# Public singleton – import and call directly:  notify.send(...)
notify = _LazyNotificationHub()

# Also export the class for users who want to subclass or type-hint it.
from django_notify_hub.hub import NotificationHub  # noqa: E402

__all__ = ["notify", "NotificationHub", "__version__"]
