// /AIWK_COMMON/core/aiwk_module.js
// AIWK EXT4 v003
(function () {
    "use strict";

    const AIWK = window.AIWK;
    const registry = {};

    AIWK.modules = {
        registry: registry,
        register: function (name, moduleObject) {
            if (!name) {
                throw new Error("AIWK.modules.register: name is required.");
            }
            registry[name] = moduleObject || {};
            return registry[name];
        },
        get: function (name) {
            return registry[name] || null;
        },
        run: function (name, ctx) {
            const mod = AIWK.modules.get(name);
            if (!mod || typeof mod.mount !== "function") {
                throw new Error("AIWK module mount not found: " + name);
            }
            return mod.mount(ctx);
        }
    };
}());
