"""Mixlar SDK — build plugins and device widgets for the M1X control surface.

Quick start::

    from mixlar import MixlarPlugin
    from mixlar.colors import ACCENT, CARD2, WHITE

    class MyPlugin(MixlarPlugin):
        plugin_id = "my_plugin"
        plugin_name = "My Plugin"
        def get_macro_actions(self):
            return [("hello", "Say Hello")]
        def execute_macro_step(self, step):
            print("hello from the M1X")

Then, from the plugin folder::

    mixlar-sdk validate      # lint manifest + widgets
    mixlar-sdk emulate       # run against a headless device, no hardware
    mixlar-sdk pack          # build a signed .mixplugin
    mixlar-sdk sign          # sign with your publisher key

The base class and the ``PluginRegistry`` transparently become the live app's
own classes when a plugin runs inside Mixlar Control, so what you author against
here is exactly what ships. See the module docstrings for the details.
"""
from __future__ import annotations

__version__ = "0.3.7"

# Eager foundation (no heavy/optional deps).
from .plugin import MixlarPlugin          # noqa: E402
from .registry import PluginRegistry      # noqa: E402
from . import colors                      # noqa: E402
from . import protocol                    # noqa: E402
from . import manifest                    # noqa: E402
from . import signing                     # noqa: E402

# Lazily-exposed submodules — imported on first attribute access so the package
# still imports if an optional dep (Pillow) is absent or a module is mid-build.
_LAZY = {
    "widgets", "settings_schema", "validator", "events",
    "packaging", "emulator", "imaging", "scan", "permissions", "sandbox",
    "enforce", "agreement",
}


def __getattr__(name):  # PEP 562
    if name in _LAZY:
        import importlib
        mod = importlib.import_module(f".{name}", __name__)
        globals()[name] = mod
        return mod
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


def __dir__():
    return sorted(list(globals().keys()) + list(_LAZY))


__all__ = [
    "__version__",
    "MixlarPlugin", "PluginRegistry",
    "colors", "protocol", "manifest", "signing",
    # lazy:
    "widgets", "settings_schema", "validator", "events", "packaging",
    "emulator", "imaging", "scan", "permissions", "sandbox",
    "enforce", "agreement",
]
