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 types provider, for custom components types
 */
export class CustomComponentsDynamicModuleTypesProvider {
    //######################### constructor #########################
    constructor(_componentsRegister, _logger) {
        this._componentsRegister = _componentsRegister;
        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('CustomComponentsDynamicModuleTypesProvider: trying to get relations types {{@item}}', { item: { name: source.name, package: source.package } });
        const types = await this._componentsRegister.getRegisteredComponents();
        if (!types.length) {
            return {
                default: [
                    'placeholder',
                ]
            };
        }
        return {
            default: [
                ...types,
                'placeholder',
            ]
        };
    }
}
CustomComponentsDynamicModuleTypesProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CustomComponentsDynamicModuleTypesProvider, deps: [{ token: i1.CustomComponentsRegister }, { token: LOGGER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
CustomComponentsDynamicModuleTypesProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CustomComponentsDynamicModuleTypesProvider });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CustomComponentsDynamicModuleTypesProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1.CustomComponentsRegister }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [LOGGER]
                }, {
                    type: Optional
                }] }] });
//# sourceMappingURL=customComponentsDynamicModuleTypesProvider.service.js.map