"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DynamicApps = exports.AbstractApp = void 0;
const nestjs_modules_1 = require("@golevelup/nestjs-modules");
const app_toolkit_interface_1 = require("../app-toolkit/app-toolkit.interface");
const APP_OPTIONS = 'APP_OPTIONS';
const DYNAMIC_APP_TOOLKIT = Symbol('DYNAMIC_APP_TOOLKIT');
const DYNAMIC_PROVIDERS = [
    {
        provide: DYNAMIC_APP_TOOLKIT,
        inject: [APP_OPTIONS],
        useFactory: (options) => options.appToolkit,
    },
];
const AbstractApp = () => (0, nestjs_modules_1.createConfigurableDynamicRootModule)(APP_OPTIONS, {
    providers: DYNAMIC_PROVIDERS,
});
exports.AbstractApp = AbstractApp;
const DynamicApps = ({ apps, imports, }) => apps.map(app => app.forRootAsync(app, {
    imports,
    inject: [app_toolkit_interface_1.APP_TOOLKIT],
    useFactory: (appToolkit) => ({
        appToolkit,
    }),
}));
exports.DynamicApps = DynamicApps;
//# sourceMappingURL=app.dynamic-module.js.map