import { Component, Inject, NgModule, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { CommonModule } from '@angular/common';
import { UxFieldsetComponentModule, UxFormGroupComponentModule, UxControlFeedbackComponentModule, } from '@eui/components';
import { UxDynResolveLabelPipeModule } from '../../../pipes/resolve-label.pipe';
import { BaseGroupComponent } from '../../../core/base-group/base-group.component';
import { DYNAMIC_COMPONENT_CONFIG } from '@eui/core';
import { UxDynFormChildContainerComponentModule } from '../../core/form-child-container/form-child-container.component';
import { UxDynNativeElementProviderDirectiveModule } from '../../../directives/native-element-provider.directive';
import { TranslateModule } from '@ngx-translate/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@eui/components";
import * as i3 from "../../../directives/native-element-provider.directive";
import * as i4 from "../../core/form-child-container/form-child-container.component";
import * as i5 from "../../../pipes/resolve-label.pipe";
import * as i6 from "@ngx-translate/core";
function FieldsetContainerComponent_ux_fieldset_0_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "span", 7);
    i0.ɵɵpipe(1, "async");
    i0.ɵɵpipe(2, "resolveLabel");
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵclassProp("ux-u-cursor-help", ctx_r2.inputs.tooltip !== "");
    i0.ɵɵpropertyInterpolate("title", i0.ɵɵpipeBind1(1, 3, i0.ɵɵpipeBind1(2, 5, ctx_r2.inputs.tooltip)));
} }
function FieldsetContainerComponent_ux_fieldset_0_span_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵtext(1, "*");
    i0.ɵɵelementEnd();
} }
function FieldsetContainerComponent_ux_fieldset_0_span_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(" * ");
} }
function FieldsetContainerComponent_ux_fieldset_0_ng_container_8_ux_control_feedback_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ux-control-feedback", 10);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("typeClass", ctx_r6.dynFormGroup.errors.uxValidationError.type ? ctx_r6.dynFormGroup.errors.uxValidationError.type : "danger");
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r6.dynFormGroup.errors.uxValidationError.message && ctx_r6.dynFormGroup.errors.uxValidationError.message.id ? i0.ɵɵpipeBind2(2, 2, ctx_r6.dynFormGroup.errors.uxValidationError.message.id, ctx_r6.dynFormGroup.errors.uxValidationError.message.params) : ctx_r6.dynFormGroup.errors.uxValidationError.message, " ");
} }
function FieldsetContainerComponent_ux_fieldset_0_ng_container_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, FieldsetContainerComponent_ux_fieldset_0_ng_container_8_ux_control_feedback_1_Template, 3, 5, "ux-control-feedback", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r5.dynFormGroup.errors && ctx_r5.dynFormGroup.errors.uxValidationError);
} }
function FieldsetContainerComponent_ux_fieldset_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ux-fieldset", 2);
    i0.ɵɵelementStart(1, "uxFieldsetLabelExtraContent");
    i0.ɵɵelement(2, "div", 3);
    i0.ɵɵpipe(3, "async");
    i0.ɵɵpipe(4, "resolveLabel");
    i0.ɵɵtemplate(5, FieldsetContainerComponent_ux_fieldset_0_span_5_Template, 3, 7, "span", 4);
    i0.ɵɵtemplate(6, FieldsetContainerComponent_ux_fieldset_0_span_6_Template, 2, 0, "span", 5);
    i0.ɵɵtemplate(7, FieldsetContainerComponent_ux_fieldset_0_span_7_Template, 2, 1, "span", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(8, FieldsetContainerComponent_ux_fieldset_0_ng_container_8_Template, 2, 1, "ng-container", 1);
    i0.ɵɵelement(9, "ux-dyn-form-child-container", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("dynFormItem", ctx_r0.dynFormGroup)("dynFormItemIsReadOnly", true);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("innerHtml", i0.ɵɵpipeBind1(3, 10, i0.ɵɵpipeBind1(4, 12, ctx_r0.inputs.label)), i0.ɵɵsanitizeHtml);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r0.inputs.tooltip);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.inputs.required && ctx_r0.inputs.tooltip);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.inputs.required && !ctx_r0.inputs.tooltip);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.dynFormGroup && ctx_r0.dynFormGroup.invalid && ctx_r0.dynFormGroup.touched);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r0.childrenConfig)("frameId", ctx_r0.frameId)("parent", ctx_r0.dynFormGroup);
} }
function FieldsetContainerComponent_ux_fieldset_1_ng_container_6_ux_control_feedback_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ux-control-feedback", 10);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(3);
    i0.ɵɵpropertyInterpolate("typeClass", ctx_r8.dynFormGroup.errors.uxValidationError.type ? ctx_r8.dynFormGroup.errors.uxValidationError.type : "danger");
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r8.dynFormGroup.errors.uxValidationError.message && ctx_r8.dynFormGroup.errors.uxValidationError.message.id ? i0.ɵɵpipeBind2(2, 2, ctx_r8.dynFormGroup.errors.uxValidationError.message.id, ctx_r8.dynFormGroup.errors.uxValidationError.message.params) : ctx_r8.dynFormGroup.errors.uxValidationError.message, " ");
} }
function FieldsetContainerComponent_ux_fieldset_1_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, FieldsetContainerComponent_ux_fieldset_1_ng_container_6_ux_control_feedback_1_Template, 3, 5, "ux-control-feedback", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r7.dynFormGroup.errors && ctx_r7.dynFormGroup.errors.uxValidationError);
} }
function FieldsetContainerComponent_ux_fieldset_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ux-fieldset");
    i0.ɵɵelementStart(1, "ux-form-group", 11);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵpipe(3, "resolveLabel");
    i0.ɵɵpipe(4, "async");
    i0.ɵɵpipe(5, "resolveLabel");
    i0.ɵɵtemplate(6, FieldsetContainerComponent_ux_fieldset_1_ng_container_6_Template, 2, 1, "ng-container", 1);
    i0.ɵɵelementEnd();
    i0.ɵɵelement(7, "ux-dyn-form-child-container", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("label", "<b>" + i0.ɵɵpipeBind1(2, 10, i0.ɵɵpipeBind1(3, 12, ctx_r1.inputs.label)) + ":</b>")("isRenderHTML", true)("infoLabel", i0.ɵɵpipeBind1(4, 14, i0.ɵɵpipeBind1(5, 16, ctx_r1.inputs.tooltip)))("isRequired", ctx_r1.inputs.required)("dynFormItem", ctx_r1.dynFormGroup)("dynFormItemIsReadOnly", true);
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("ngIf", ctx_r1.dynFormGroup && ctx_r1.dynFormGroup.invalid && ctx_r1.dynFormGroup.touched);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("config", ctx_r1.childrenConfig)("frameId", ctx_r1.frameId)("parent", ctx_r1.dynFormGroup);
} }
export class FieldsetContainerComponent extends BaseGroupComponent {
    constructor(config, cdRef) {
        super(config);
        this.cdRef = cdRef;
        this.inputs = this.context.inputs;
        this.manualHandleChangeDetection();
    }
    ngOnInit() {
    }
    ngOnDestroy() {
        if (this.statusSubs) {
            this.statusSubs.unsubscribe();
        }
        if (this.modeSubs) {
            this.modeSubs.unsubscribe();
        }
    }
    manualHandleChangeDetection() {
        var _a;
        this.statusSubs = (_a = this.dynFormGroup) === null || _a === void 0 ? void 0 : _a.statusChanges.subscribe((status) => {
            if (status === 'INVALID' || status === 'VALID') {
                this.cdRef.markForCheck();
            }
        });
        this.modeSubs = this.dynFormApi.getMode().subscribe(() => {
            this.cdRef.markForCheck();
        });
    }
}
/** @nocollapse */ FieldsetContainerComponent.ɵfac = function FieldsetContainerComponent_Factory(t) { return new (t || FieldsetContainerComponent)(i0.ɵɵdirectiveInject(DYNAMIC_COMPONENT_CONFIG), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
/** @nocollapse */ FieldsetContainerComponent.ɵcmp = i0.ɵɵdefineComponent({ type: FieldsetContainerComponent, selectors: [["ux-dyn-fieldset-container"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [["label", " ", "dynTargetedElement", "div", 3, "dynFormItem", "dynFormItemIsReadOnly", 4, "ngIf"], [4, "ngIf"], ["label", " ", "dynTargetedElement", "div", 3, "dynFormItem", "dynFormItemIsReadOnly"], [1, "ux-fieldset__header-label", 3, "innerHtml"], ["class", "ux-form-group__info-label ux-icon ux-icon-info-circle ux-u-color-info", 3, "ux-u-cursor-help", "title", 4, "ngIf"], ["class", "ux-u-color-danger", 4, "ngIf"], [3, "config", "frameId", "parent"], [1, "ux-form-group__info-label", "ux-icon", "ux-icon-info-circle", "ux-u-color-info", 3, "title"], [1, "ux-u-color-danger"], [3, "typeClass", 4, "ngIf"], [3, "typeClass"], ["labelWidthClass", "col-4", "inputWidthClass", "col-8", "iconTypeClass", "info", "dynTargetedElement", "div", 3, "label", "isRenderHTML", "infoLabel", "isRequired", "dynFormItem", "dynFormItemIsReadOnly"]], template: function FieldsetContainerComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, FieldsetContainerComponent_ux_fieldset_0_Template, 10, 14, "ux-fieldset", 0);
        i0.ɵɵtemplate(1, FieldsetContainerComponent_ux_fieldset_1_Template, 8, 18, "ux-fieldset", 1);
    } if (rf & 2) {
        i0.ɵɵproperty("ngIf", !ctx.inputs.notHeader);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.inputs.notHeader);
    } }, directives: [i1.NgIf, i2.UxFieldsetComponent, i3.NativeElementProviderDirective, i2.UxFieldsetLabelExtraContentTagDirective, i4.FormChildContainerComponent, i2.UxControlFeedbackComponent, i2.UxFormGroupComponent], pipes: [i1.AsyncPipe, i5.ResolveLabelPipe, i6.TranslatePipe], styles: [""], changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(FieldsetContainerComponent, [{
        type: Component,
        args: [{
                selector: 'ux-dyn-fieldset-container',
                templateUrl: './fieldset-container.component.html',
                styleUrls: ['./fieldset-container.component.scss'],
                changeDetection: ChangeDetectionStrategy.OnPush,
            }]
    }], function () { return [{ type: undefined, decorators: [{
                type: Inject,
                args: [DYNAMIC_COMPONENT_CONFIG]
            }] }, { type: i0.ChangeDetectorRef }]; }, null); })();
export class UxDynFieldsetContainerComponentModule {
}
/** @nocollapse */ UxDynFieldsetContainerComponentModule.ɵmod = i0.ɵɵdefineNgModule({ type: UxDynFieldsetContainerComponentModule });
/** @nocollapse */ UxDynFieldsetContainerComponentModule.ɵinj = i0.ɵɵdefineInjector({ factory: function UxDynFieldsetContainerComponentModule_Factory(t) { return new (t || UxDynFieldsetContainerComponentModule)(); }, imports: [[
            CommonModule,
            UxFieldsetComponentModule,
            UxDynFormChildContainerComponentModule,
            // EuiTooltipDirectiveModule,
            UxFormGroupComponentModule,
            UxDynNativeElementProviderDirectiveModule,
            UxControlFeedbackComponentModule,
            UxDynResolveLabelPipeModule,
            TranslateModule,
        ]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(UxDynFieldsetContainerComponentModule, { declarations: [FieldsetContainerComponent], imports: [CommonModule,
        UxFieldsetComponentModule,
        UxDynFormChildContainerComponentModule,
        // EuiTooltipDirectiveModule,
        UxFormGroupComponentModule,
        UxDynNativeElementProviderDirectiveModule,
        UxControlFeedbackComponentModule,
        UxDynResolveLabelPipeModule,
        TranslateModule], exports: [FieldsetContainerComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(UxDynFieldsetContainerComponentModule, [{
        type: NgModule,
        args: [{
                imports: [
                    CommonModule,
                    UxFieldsetComponentModule,
                    UxDynFormChildContainerComponentModule,
                    // EuiTooltipDirectiveModule,
                    UxFormGroupComponentModule,
                    UxDynNativeElementProviderDirectiveModule,
                    UxControlFeedbackComponentModule,
                    UxDynResolveLabelPipeModule,
                    TranslateModule,
                ],
                exports: [FieldsetContainerComponent],
                declarations: [FieldsetContainerComponent],
            }]
    }], null, null); })();
//# sourceMappingURL=data:application/json;base64, 