import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { AbstractFieldWriteComponent } from '../base-field/abstract-field-write.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "../utils/field-label.pipe";
import * as i4 from "../utils/first-error.pipe";
import * as i5 from "rpx-xui-translation";
const _c0 = a0 => ({ "form-group-error": a0 });
const _c1 = a0 => ({ selected: a0 });
function WriteFixedRadioListFieldComponent_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 6);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "ccdFieldLabel");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, ctx_r0.caseField));
} }
function WriteFixedRadioListFieldComponent_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 7);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "rpxTranslate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, ctx_r0.caseField.hint_text));
} }
function WriteFixedRadioListFieldComponent_span_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "ccdFirstError");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, ctx_r0.fixedRadioListControl.errors, ctx_r0.caseField.label));
} }
function WriteFixedRadioListFieldComponent_div_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵelement(1, "input", 10);
    i0.ɵɵelementStart(2, "label", 11);
    i0.ɵɵtext(3);
    i0.ɵɵpipe(4, "rpxTranslate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const radioButton_r2 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(9, _c1, ctx_r0.fixedRadioListControl.value === radioButton_r2.code));
    i0.ɵɵadvance();
    i0.ɵɵproperty("id", ctx_r0.id() + "-" + radioButton_r2.code)("name", ctx_r0.id())("formControl", ctx_r0.fixedRadioListControl)("value", radioButton_r2.code);
    i0.ɵɵadvance();
    i0.ɵɵproperty("for", ctx_r0.id() + "-" + radioButton_r2.code);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(4, 7, radioButton_r2.label));
} }
export class WriteFixedRadioListFieldComponent extends AbstractFieldWriteComponent {
    fixedRadioListControl;
    ngOnInit() {
        const notEmpty = this.caseField.value !== null && this.caseField.value !== undefined;
        this.fixedRadioListControl = this.registerControl(new FormControl(notEmpty ? this.caseField.value : null));
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵWriteFixedRadioListFieldComponent_BaseFactory; return function WriteFixedRadioListFieldComponent_Factory(__ngFactoryType__) { return (ɵWriteFixedRadioListFieldComponent_BaseFactory || (ɵWriteFixedRadioListFieldComponent_BaseFactory = i0.ɵɵgetInheritedFactory(WriteFixedRadioListFieldComponent)))(__ngFactoryType__ || WriteFixedRadioListFieldComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteFixedRadioListFieldComponent, selectors: [["ccd-write-fixed-radio-list-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 9, vars: 9, consts: [[1, "form-group", "bottom-30", 3, "ngClass", "id"], [3, "for"], ["class", "form-label", 4, "ngIf"], ["class", "form-hint", 4, "ngIf"], ["class", "error-message", 4, "ngIf"], ["class", "multiple-choice", 3, "ngClass", 4, "ngFor", "ngForOf"], [1, "form-label"], [1, "form-hint"], [1, "error-message"], [1, "multiple-choice", 3, "ngClass"], ["type", "radio", 1, "form-control", 3, "id", "name", "formControl", "value"], [1, "form-label", 3, "for"]], template: function WriteFixedRadioListFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "fieldset")(2, "legend")(3, "label", 1);
            i0.ɵɵtemplate(4, WriteFixedRadioListFieldComponent_span_4_Template, 3, 3, "span", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(5, WriteFixedRadioListFieldComponent_span_5_Template, 3, 3, "span", 3)(6, WriteFixedRadioListFieldComponent_span_6_Template, 3, 4, "span", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementContainerStart(7);
            i0.ɵɵtemplate(8, WriteFixedRadioListFieldComponent_div_8_Template, 5, 11, "div", 5);
            i0.ɵɵelementContainerEnd();
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(7, _c0, !ctx.fixedRadioListControl.valid && (ctx.fixedRadioListControl.dirty || ctx.fixedRadioListControl.touched)))("id", ctx.id());
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("for", ctx.id());
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseField.label);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseField.hint_text);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.fixedRadioListControl.errors && (ctx.fixedRadioListControl.dirty || ctx.fixedRadioListControl.touched));
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngForOf", ctx.caseField.field_type.fixed_list_items);
        } }, dependencies: [i1.NgClass, i1.NgForOf, i1.NgIf, i2.DefaultValueAccessor, i2.RadioControlValueAccessor, i2.NgControlStatus, i2.FormControlDirective, i3.FieldLabelPipe, i4.FirstErrorPipe, i5.RpxTranslatePipe], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteFixedRadioListFieldComponent, [{
        type: Component,
        args: [{ selector: 'ccd-write-fixed-radio-list-field', template: "<div class=\"form-group bottom-30\" [ngClass]=\"{'form-group-error': !fixedRadioListControl.valid && (fixedRadioListControl.dirty || fixedRadioListControl.touched)}\" [id]=\"id()\">\n  <fieldset>\n    <legend>\n      <label [for]=\"id()\">\n        <span class=\"form-label\" *ngIf=\"caseField.label\">{{(caseField | ccdFieldLabel)}}</span>\n      </label>\n      <span class=\"form-hint\" *ngIf=\"caseField.hint_text\">{{caseField.hint_text | rpxTranslate }}</span>\n      <span class=\"error-message\" *ngIf=\"fixedRadioListControl.errors && (fixedRadioListControl.dirty || fixedRadioListControl.touched)\">{{(fixedRadioListControl.errors | ccdFirstError:caseField.label)}}</span>\n    </legend>\n    <ng-container>\n      <div class=\"multiple-choice\" *ngFor=\"let radioButton of caseField.field_type.fixed_list_items\" [ngClass]=\"{selected: fixedRadioListControl.value === radioButton.code}\">\n        <input class=\"form-control\" [id]=\"id()+'-'+radioButton.code\" [name]=\"id()\" type=\"radio\" [formControl]=\"fixedRadioListControl\" [value]=\"radioButton.code\">\n        <label class=\"form-label\" [for]=\"id()+'-'+radioButton.code\">{{radioButton.label | rpxTranslate}}</label>\n      </div>\n    </ng-container>\n  </fieldset>\n</div>\n" }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WriteFixedRadioListFieldComponent, { className: "WriteFixedRadioListFieldComponent", filePath: "lib/shared/components/palette/fixed-radio-list/write-fixed-radio-list-field.component.ts", lineNumber: 9 }); })();
//# sourceMappingURL=data:application/json;base64, 