import { Inject, Injectable, Optional } from '@angular/core';
import { LOGGER } from '@anglr/common';
import { CustomComponentsRegister } from '../customComponentsRegister/customComponentsRegister.service';
import * as i0 from "@angular/core";
import * as i1 from "../customComponentsRegister/customComponentsRegister.service";
/**
 * Dynamic module items provider for custom components module items
 */
export class CustomComponentsDynamicModuleItemsProvider {
    //######################### constructor #########################
    constructor(_customComponentRegister, _logger) {
        this._customComponentRegister = _customComponentRegister;
        this._logger = _logger;
    }
    //######################### public methods - implementation of DynamicItemLoaderProvider #########################
    /**
     * @inheritdoc
     */
    async tryToGet(source) {
        //only works with custom components
        if (source.package != 'custom-components') {
            return null;
        }
        this._logger?.debug('CustomComponentsDynamicModuleItemsProvider: trying to get node {{@item}}', { item: { name: source.name, package: source.package } });
        switch (source.name) {
            case 'placeholder':
                {
                    return await import('../../dynamicItems/placeholder/type');
                }
            case 'placeholderContainer':
                {
                    return await import('../../dynamicItems/placeholderContainer/type');
                }
            case 'componentInputs':
                {
                    return await import('../../dynamicItems/componentInputs/type');
                }
            case 'componentOutputs':
                {
                    return await import('../../dynamicItems/componentOutputs/type');
                }
            default:
                {
                    const customComponent = await import('../../dynamicItems/customComponent/type');
                    const customComponentConfiguration = this._customComponentRegister?.getConfigurationForComponent(source.name);
                    return {
                        default: customComponent.default,
                        extensions: customComponent.extensions,
                        displayName: customComponentConfiguration?.displayName,
                        description: customComponentConfiguration?.description,
                        group: customComponentConfiguration?.group,
                    };
                }
        }
    }
}
CustomComponentsDynamicModuleItemsProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CustomComponentsDynamicModuleItemsProvider, deps: [{ token: i1.CustomComponentsRegister, optional: true }, { token: LOGGER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
CustomComponentsDynamicModuleItemsProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CustomComponentsDynamicModuleItemsProvider });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CustomComponentsDynamicModuleItemsProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1.CustomComponentsRegister, decorators: [{
                    type: Optional
                }] }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [LOGGER]
                }, {
                    type: Optional
                }] }] });
//# sourceMappingURL=customComponentsDynamicModuleItemsProvider.service.js.map