__all__ = (
    "__version__",
    "enums",
    "exceptions",
    "fn",
    "meta",
    "num",
    "seq",
    "sets",
    "text",
)

import logging
from importlib import metadata
from typing import TYPE_CHECKING

__version__ = metadata.version(__name__)

# Prevent "No handlers could be found" warnings when the library is imported.
# Applications are responsible for configuring handlers/formatters/levels.
logging.getLogger(__name__).addHandler(logging.NullHandler())


if TYPE_CHECKING:
    from purekit import (
        enums,
        exceptions,
        fn,
        meta,
        num,
        seq,
        sets,
        text,
    )  # type: ignore


def __getattr__(name: str):
    # Lazy import of submodules on attribute access (PEP 562)
    if name in __all__:
        import importlib

        module = importlib.import_module(f"{__name__}.{name}")
        globals()[name] = module
        return module
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


def __dir__():
    # Improve interactive discoverability
    items = __all__ + tuple(globals().keys())
    exclude = {"metadata", "TYPE_CHECKING"}
    return sorted(item for item in items if item not in exclude)
