import { __decorate } from "tslib";
import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
import { LayoutComponentBase } from '@anglr/dynamic/layout';
import { LayoutEditorDesignerType, LayoutEditorMetadata } from '@anglr/dynamic/layout-editor';
import { RelationsEditorMetadata } from '@anglr/dynamic/relations-editor';
import { HostDisplayBlockStyle } from '@anglr/common';
import { nameof } from '@jscrpt/common';
import Handlebars from 'handlebars';
import { DataBlockLayoutDesignerTypeLoader, DataBlockLayoutMetadataLoader, DataBlockRelationsMetadataLoader } from './dataBlock.metadata';
import * as i0 from "@angular/core";
/**
 * Component used for displaying data block
 */
let DataBlockSAComponent = class DataBlockSAComponent extends LayoutComponentBase {
    //######################### public methods - implementation of OnChanges #########################
    /**
     * Called when input value changes
     */
    async ngOnChanges(changes) {
        await super.ngOnChanges(changes);
        if (nameof('data') in changes) {
            this.componentElement.nativeElement.innerHTML = this.compiledTemplate?.(this.data) ?? '';
        }
    }
    //######################### protected methods - overrides #########################
    /**
     * @inheritdoc
     */
    onOptionsSet() {
        if (!this.initialized) {
            return;
        }
        if (this.options?.template) {
            this.compiledTemplate = Handlebars.compile(this.options.template);
        }
        this.componentElement.nativeElement.innerHTML = this.compiledTemplate?.(this.data) ?? '';
    }
};
DataBlockSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DataBlockSAComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
DataBlockSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: DataBlockSAComponent, isStandalone: true, selector: "data-block", inputs: { data: "data" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, styles: [":host{display: block;}"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
DataBlockSAComponent = __decorate([
    LayoutEditorDesignerType(DataBlockLayoutDesignerTypeLoader),
    RelationsEditorMetadata(DataBlockRelationsMetadataLoader),
    LayoutEditorMetadata(DataBlockLayoutMetadataLoader)
], DataBlockSAComponent);
export { DataBlockSAComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DataBlockSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'data-block', template: '', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display: block;}"] }]
        }], propDecorators: { data: [{
                type: Input
            }] } });
//# sourceMappingURL=dataBlock.component.js.map