import { inject, Optional } from '@angular/core';
import { defaultExportExtractor, DynamicItemLoader, DynamicModuleDataExtractor, MetadataHistoryManager, METADATA_STATE_MANAGER } from '@anglr/dynamic';
import { LOGGER } from '@anglr/common';
import { RELATIONS_HISTORY_MANAGER, RELATIONS_MODULE_TYPES_DATA_EXTRACTORS, RELATIONS_MODULE_TYPES_LOADER, RELATIONS_MODULE_TYPES_PROVIDERS, RELATIONS_NODES_DATA_EXTRACTORS, RELATIONS_NODES_LOADER, RELATIONS_NODES_PROVIDERS } from './tokens';
import { componentRelationsNodeExtractor, relationsNodeExtractor } from './extractors';
import { StaticComponentsRelationsNodesProvider, StaticComponentsRelationsTypesProvider, RelationsNodeManager } from '../services';
import { isRelationsModuleTypes, isRelationsNodeDef } from './utils';
/**
 * Provider for static components relations nodes provider
 */
export const STATIC_COMPONENTS_RELATIONS_NODES_PROVIDER = {
    provide: RELATIONS_NODES_PROVIDERS,
    useClass: StaticComponentsRelationsNodesProvider,
    multi: true
};
/**
 * Provider for static components relations types provider
 */
export const STATIC_COMPONENTS_RELATIONS_MODULE_TYPES_PROVIDER = {
    provide: RELATIONS_MODULE_TYPES_PROVIDERS,
    useClass: StaticComponentsRelationsTypesProvider,
    multi: true
};
/**
 * Provider for default relations nodes extractor
 */
export const DEFAULT_RELATIONS_NODES_EXTRACTOR = {
    provide: RELATIONS_NODES_DATA_EXTRACTORS,
    useFactory: (logger) => {
        return new DynamicModuleDataExtractor([
            relationsNodeExtractor,
        ], logger);
    },
    deps: [[new Optional(), LOGGER]],
    multi: true
};
/**
 * Provider for static and layout components relations nodes extractor
 */
export const COMPONENTS_RELATIONS_NODES_EXTRACTOR = {
    provide: RELATIONS_NODES_DATA_EXTRACTORS,
    useFactory: (logger) => {
        return new DynamicModuleDataExtractor([
            componentRelationsNodeExtractor,
        ], logger);
    },
    deps: [[new Optional(), LOGGER]],
    multi: true
};
/**
 * Provider for default relations module types extractor
 */
export const DEFAULT_RELATIONS_MODULE_TYPES_EXTRACTOR = {
    provide: RELATIONS_MODULE_TYPES_DATA_EXTRACTORS,
    useFactory: (logger) => {
        return new DynamicModuleDataExtractor([
            defaultExportExtractor,
        ], logger);
    },
    deps: [[new Optional(), LOGGER]],
    multi: true
};
/**
 * Provider for relations module types
 */
export const RELATIONS_MODULE_TYPES_LOADER_PROVIDER = {
    provide: RELATIONS_MODULE_TYPES_LOADER,
    useFactory: () => {
        var _a;
        return new DynamicItemLoader(inject(RELATIONS_MODULE_TYPES_PROVIDERS), inject(RELATIONS_MODULE_TYPES_DATA_EXTRACTORS), isRelationsModuleTypes, (_a = inject(LOGGER, { optional: true })) !== null && _a !== void 0 ? _a : undefined, true);
    }
};
/**
 * Provider for relations node loader
 */
export const RELATIONS_NODES_LOADER_PROVIDER = {
    provide: RELATIONS_NODES_LOADER,
    useFactory: () => {
        var _a;
        return new DynamicItemLoader(inject(RELATIONS_NODES_PROVIDERS), inject(RELATIONS_NODES_DATA_EXTRACTORS), isRelationsNodeDef, (_a = inject(LOGGER, { optional: true })) !== null && _a !== void 0 ? _a : undefined);
    }
};
/**
 * Provider for relations history manager state
 */
export const RELATIONS_HISTORY_MANAGER_STATE = {
    provide: METADATA_STATE_MANAGER,
    useExisting: RelationsNodeManager,
};
/**
 * Provider for relations history manager
 */
export const RELATIONS_HISTORY_MANAGER_PROVIDER = {
    provide: RELATIONS_HISTORY_MANAGER,
    useClass: MetadataHistoryManager
};
//# sourceMappingURL=providers.js.map