/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
// @dynamic
var 
// @dynamic
Loader = /** @class */ (function () {
    function Loader() {
    }
    /* SystemJS es5 library loader.

    Usage: include the following lines in your index.html:

    <script src='https://unpkg.com/systemjs'></script>
    <script src='https://unpkg.com/@ema/js-base/dist/webcomponents.js'></script>
    <link rel='stylesheet' href='https://unpkg.com/@ema/js-base/dist/css/theme.css' />

    include the following code in your javascript:

    SystemJS.config({
        baseURL: 'https://unpkg.com/@ema/core',
        packages: {
            'dist/lib': {
                defaultExtension: 'js'
            },
            'rxjs': {
                defaultExtension: 'js'
            }
        },
        paths: {
            'rxjs': [
                'https://unpkg.com/rxjs'
            ]
        }
    });

    async loadLibrary(modules){
        let loader;
        await SystemJS.import("es5/lib/loader").then((module) => {
           loader = module.Loader;
        });
        return await loader.loadModules(modules, this.settings.namespace+'_library');
    }

    // define and load the modules you want to include, set to your own requirements
    let modules = [
        "es5/lib/base/base-service",
        "es5/lib/config/config-service",
        "es5/lib/config/translate/translateService",
        "es5/lib/cms/wordpress",
        "es5/lib/util/dom-util",
        "es5/lib/util/util"
    ];
    let library = await this.loadLibrary(modules)

    // then you can call your library custom code here. Examples:

    let uuid = library.Util.getUUID();
    let translateService = library.TranslateService.instance;
    let wordpress = new library.Wordpress();

    */
    /* SystemJS es5 library loader.
    
        Usage: include the following lines in your index.html:
    
        <script src='https://unpkg.com/systemjs'></script>
        <script src='https://unpkg.com/@ema/js-base/dist/webcomponents.js'></script>
        <link rel='stylesheet' href='https://unpkg.com/@ema/js-base/dist/css/theme.css' />
    
        include the following code in your javascript:
    
        SystemJS.config({
            baseURL: 'https://unpkg.com/@ema/core',
            packages: {
                'dist/lib': {
                    defaultExtension: 'js'
                },
                'rxjs': {
                    defaultExtension: 'js'
                }
            },
            paths: {
                'rxjs': [
                    'https://unpkg.com/rxjs'
                ]
            }
        });
    
        async loadLibrary(modules){
            let loader;
            await SystemJS.import("es5/lib/loader").then((module) => {
               loader = module.Loader;
            });
            return await loader.loadModules(modules, this.settings.namespace+'_library');
        }
    
        // define and load the modules you want to include, set to your own requirements
        let modules = [
            "es5/lib/base/base-service",
            "es5/lib/config/config-service",
            "es5/lib/config/translate/translateService",
            "es5/lib/cms/wordpress",
            "es5/lib/util/dom-util",
            "es5/lib/util/util"
        ];
        let library = await this.loadLibrary(modules)
    
        // then you can call your library custom code here. Examples:
    
        let uuid = library.Util.getUUID();
        let translateService = library.TranslateService.instance;
        let wordpress = new library.Wordpress();
    
        */
    /**
     * @param {?} modules
     * @param {?=} namespace
     * @return {?}
     */
    Loader.loadModules = /* SystemJS es5 library loader.
    
        Usage: include the following lines in your index.html:
    
        <script src='https://unpkg.com/systemjs'></script>
        <script src='https://unpkg.com/@ema/js-base/dist/webcomponents.js'></script>
        <link rel='stylesheet' href='https://unpkg.com/@ema/js-base/dist/css/theme.css' />
    
        include the following code in your javascript:
    
        SystemJS.config({
            baseURL: 'https://unpkg.com/@ema/core',
            packages: {
                'dist/lib': {
                    defaultExtension: 'js'
                },
                'rxjs': {
                    defaultExtension: 'js'
                }
            },
            paths: {
                'rxjs': [
                    'https://unpkg.com/rxjs'
                ]
            }
        });
    
        async loadLibrary(modules){
            let loader;
            await SystemJS.import("es5/lib/loader").then((module) => {
               loader = module.Loader;
            });
            return await loader.loadModules(modules, this.settings.namespace+'_library');
        }
    
        // define and load the modules you want to include, set to your own requirements
        let modules = [
            "es5/lib/base/base-service",
            "es5/lib/config/config-service",
            "es5/lib/config/translate/translateService",
            "es5/lib/cms/wordpress",
            "es5/lib/util/dom-util",
            "es5/lib/util/util"
        ];
        let library = await this.loadLibrary(modules)
    
        // then you can call your library custom code here. Examples:
    
        let uuid = library.Util.getUUID();
        let translateService = library.TranslateService.instance;
        let wordpress = new library.Wordpress();
    
        */
    /**
     * @param {?} modules
     * @param {?=} namespace
     * @return {?}
     */
    function (modules, namespace) {
        if (namespace === void 0) { namespace = '_ema_core'; }
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            return tslib_1.__generator(this, function (_a) {
                return [2 /*return*/, new Promise((/**
                     * @param {?} resolve
                     * @param {?} reject
                     * @return {?}
                     */
                    function (resolve, reject) {
                        /** @type {?} */
                        var imports = [];
                        /** @type {?} */
                        var library = {};
                        /** @type {?} */
                        var global = Loader.getGlobal();
                        if (!global[namespace])
                            global[namespace] = library;
                        modules.forEach((/**
                         * @param {?} module
                         * @return {?}
                         */
                        function (module) {
                            imports.push(SystemJS.import(module));
                        }));
                        Promise.all(imports).then((/**
                         * @param {?} modules
                         * @return {?}
                         */
                        function (modules) {
                            modules.forEach((/**
                             * @param {?} module
                             * @return {?}
                             */
                            function (module) {
                                for (var C in module) {
                                    library[C] = module[C];
                                }
                            }));
                            resolve(library);
                        }));
                    }))];
            });
        });
    };
    /**
     * @return {?}
     */
    Loader.getGlobal = /**
     * @return {?}
     */
    function () {
        if (typeof self !== 'undefined') {
            return self;
        }
        if (typeof window !== 'undefined') {
            return window;
        }
        // @ts-ignore
        if (typeof global !== 'undefined') {
            return global;
        }
        throw new Error('unable to locate global object');
    };
    ;
    return Loader;
}());
// @dynamic
export { Loader };
//# sourceMappingURL=data:application/json;base64, 