import { Inject, Injectable, Optional } from '@angular/core';
import { LOGGER } from '@anglr/common';
import { StaticComponentsRegister } from '../staticComponentsRegister/staticComponentsRegister.service';
import * as i0 from "@angular/core";
import * as i1 from "../staticComponentsRegister/staticComponentsRegister.service";
/**
 * Dynamic relations nodes provider for static components
 */
export class StaticComponentsRelationsNodesProvider {
    //######################### constructor #########################
    constructor(_componentsRegister, _logger) {
        this._componentsRegister = _componentsRegister;
        this._logger = _logger;
    }
    //######################### public methods - implementation of DynamicItemLoaderProvider #########################
    /**
     * @inheritdoc
     */
    tryToGet(source) {
        //only works with static components
        if (source.package != 'static-components') {
            return null;
        }
        this._logger?.debug('StaticComponentsRelationsNodesProvider: trying to get node {{@item}}', { item: { name: source.name, package: source.package } });
        const type = this._componentsRegister.getType(source.name);
        if (!type) {
            return null;
        }
        return {
            default: type
        };
    }
}
StaticComponentsRelationsNodesProvider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: StaticComponentsRelationsNodesProvider, deps: [{ token: i1.StaticComponentsRegister }, { token: LOGGER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
StaticComponentsRelationsNodesProvider.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: StaticComponentsRelationsNodesProvider });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: StaticComponentsRelationsNodesProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1.StaticComponentsRegister }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [LOGGER]
                }, {
                    type: Optional
                }] }] });
//# sourceMappingURL=staticComponentsRelationsNodesProvider.service.js.map