import { __decorate } from "tslib";
import { Component, ChangeDetectionStrategy, inject } from '@angular/core';
import { LayoutComponentBase, LayoutComponentRendererSADirective, LAYOUT_METADATA_STORAGE } from '@anglr/dynamic/layout';
import { LayoutEditorDesignerType, LayoutEditorMetadata } from '@anglr/dynamic/layout-editor';
import { RelationsChangeDetector, RelationsComponentManager, RelationsManager, RelationsProcessor, RELATIONS_METADATA_STORAGE } from '@anglr/dynamic/relations';
import { HostDisplayBlockStyle } from '@anglr/common';
import { TemplateBlockLayoutDesignerTypeLoader, TemplateBlockLayoutMetadataLoader } from './templateBlock.metadata';
import * as i0 from "@angular/core";
/**
 * Component used for displaying template block
 */
let TemplateBlockSAComponent = class TemplateBlockSAComponent extends LayoutComponentBase {
    constructor() {
        super(...arguments);
        //######################### protected properties #########################
        /**
         * Storage for layout metadata
         */
        this.layoutMetadataStorage = inject(LAYOUT_METADATA_STORAGE);
        /**
         * Storage for relations metadata
         */
        this.relationsMetadataStorage = inject(RELATIONS_METADATA_STORAGE, { optional: true });
        /**
         * Instance of relations manager
         */
        this.relationsManager = inject(RelationsManager, { optional: true });
        //######################### protected properties - template bindings #########################
        /**
         * Instance of metadata to be displayed
         */
        this.metadata = null;
    }
    //######################### protected methods - overrides #########################
    /**
     * @inheritdoc
     */
    async onOptionsSet() {
        if (!this.initialized) {
            return;
        }
        const id = this.options?.layoutId;
        if (!id) {
            return;
        }
        this.metadata = await this.layoutMetadataStorage.getMetadata(id);
        if (this.relationsManager && this.relationsMetadataStorage) {
            const relations = await this.relationsMetadataStorage.getMetadata(id);
            this.relationsManager.setRelations(relations ?? []);
        }
    }
};
TemplateBlockSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: TemplateBlockSAComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
TemplateBlockSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: TemplateBlockSAComponent, isStandalone: true, selector: "template-block", providers: [
        RelationsComponentManager,
        RelationsManager,
        RelationsProcessor,
        RelationsChangeDetector,
    ], usesInheritance: true, ngImport: i0, template: "<ng-container [layoutComponentRenderer]=\"metadata\"></ng-container>", styles: [":host{display: block;}"], dependencies: [{ kind: "directive", type: LayoutComponentRendererSADirective, selector: "[layoutComponentRenderer]", inputs: ["layoutComponentRenderer", "layoutComponentRendererInjector", "layoutComponentRendererDisableTransformer"], outputs: ["layoutComponentRendererComponentChange", "componentElementChange"], exportAs: ["layoutComponentRenderer"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
TemplateBlockSAComponent = __decorate([
    LayoutEditorDesignerType(TemplateBlockLayoutDesignerTypeLoader),
    LayoutEditorMetadata(TemplateBlockLayoutMetadataLoader)
], TemplateBlockSAComponent);
export { TemplateBlockSAComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: TemplateBlockSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'template-block', standalone: true, imports: [
                        LayoutComponentRendererSADirective,
                    ], providers: [
                        RelationsComponentManager,
                        RelationsManager,
                        RelationsProcessor,
                        RelationsChangeDetector,
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container [layoutComponentRenderer]=\"metadata\"></ng-container>", styles: [":host{display: block;}"] }]
        }] });
//# sourceMappingURL=templateBlock.component.js.map