import { __awaiter } from "tslib";
import { Inject, Injectable, Optional } from '@angular/core';
import { LOGGER } from '@anglr/common';
import * as i0 from "@angular/core";
/**
 * Dynamic module items provider for css module items
 */
export class CssDynamicModuleItemsProvider {
    //######################### constructor #########################
    constructor(_logger) {
        this._logger = _logger;
    }
    //######################### public methods - implementation of DynamicItemLoaderProvider #########################
    /**
     * @inheritdoc
     */
    tryToGet(source) {
        var _a, _b;
        return __awaiter(this, void 0, void 0, function* () {
            switch (source.package) {
                case 'css-components':
                    {
                        try {
                            (_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug('CssDynamicModuleItemsProvider: trying to get item {{@item}}', { item: { name: source.name, package: source.package } });
                            const dynamicItemModule = yield import(`../../dynamicItems/${source.name}/type`);
                            return dynamicItemModule;
                        }
                        catch (e) {
                            (_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug('CssDynamicModuleItemsProvider: item {{@item}} was not found, reason: ' + e, { item: { name: source.name, package: source.package } });
                        }
                        break;
                    }
                default:
                    {
                        return null;
                    }
            }
            return null;
        });
    }
}
CssDynamicModuleItemsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CssDynamicModuleItemsProvider, deps: [{ token: LOGGER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
CssDynamicModuleItemsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CssDynamicModuleItemsProvider });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CssDynamicModuleItemsProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [LOGGER]
                }, {
                    type: Optional
                }] }] });
//# sourceMappingURL=cssDynamicModuleItemsProvider.service.js.map