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 "../../../../components/form/date-input/date-input.component";
import * as i4 from "../utils/field-label.pipe";
import * as i5 from "../utils/first-error.pipe";
import * as i6 from "../utils/is-mandatory.pipe";
import * as i7 from "rpx-xui-translation";
const _c0 = a0 => ({ "form-group-error": a0 });
function WriteDateFieldComponent_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 5);
    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 WriteDateFieldComponent_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 6);
    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 WriteDateFieldComponent_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 7);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "ccdFirstError");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(2, 1, ctx_r0.dateControl.errors, ctx_r0.caseField.label), " ");
} }
export class WriteDateFieldComponent extends AbstractFieldWriteComponent {
    dateControl;
    ngOnInit() {
        this.dateControl = this.registerControl(new FormControl(this.caseField.value));
    }
    isDateTime() {
        return this.caseField.field_type.id === 'DateTime';
    }
    getId() {
        return this.caseField.getHierachicalId();
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵWriteDateFieldComponent_BaseFactory; return function WriteDateFieldComponent_Factory(__ngFactoryType__) { return (ɵWriteDateFieldComponent_BaseFactory || (ɵWriteDateFieldComponent_BaseFactory = i0.ɵɵgetInheritedFactory(WriteDateFieldComponent)))(__ngFactoryType__ || WriteDateFieldComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteDateFieldComponent, selectors: [["ccd-write-date-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 8, vars: 14, consts: [[1, "form-group", "bottom-30", 3, "id", "ngClass"], ["class", "form-label", 4, "ngIf"], ["class", "form-hint", 4, "ngIf"], ["class", "error-message", 4, "ngIf"], [3, "id", "isDateTime", "mandatory", "isInvalid", "formControl"], [1, "form-label"], [1, "form-hint"], [1, "error-message"]], template: function WriteDateFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "fieldset")(2, "legend");
            i0.ɵɵtemplate(3, WriteDateFieldComponent_span_3_Template, 3, 3, "span", 1);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(4, WriteDateFieldComponent_span_4_Template, 3, 3, "span", 2)(5, WriteDateFieldComponent_span_5_Template, 3, 4, "span", 3);
            i0.ɵɵelement(6, "cut-date-input", 4);
            i0.ɵɵpipe(7, "ccdIsMandatory");
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            i0.ɵɵproperty("id", ctx.id())("ngClass", i0.ɵɵpureFunction1(12, _c0, ctx.dateControl && !ctx.dateControl.valid && (ctx.dateControl.dirty || ctx.dateControl.touched)));
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.caseField.label);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseField.hint_text);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.dateControl && ctx.dateControl.errors && (ctx.dateControl.dirty || ctx.dateControl.touched));
            i0.ɵɵadvance();
            i0.ɵɵproperty("id", ctx.getId())("isDateTime", ctx.isDateTime())("mandatory", i0.ɵɵpipeBind1(7, 10, ctx.caseField))("isInvalid", ctx.dateControl.errors && (ctx.dateControl.dirty || ctx.dateControl.touched))("formControl", ctx.dateControl);
        } }, dependencies: [i1.NgClass, i1.NgIf, i2.NgControlStatus, i2.FormControlDirective, i3.DateInputComponent, i4.FieldLabelPipe, i5.FirstErrorPipe, i6.IsMandatoryPipe, i7.RpxTranslatePipe], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteDateFieldComponent, [{
        type: Component,
        args: [{ selector: 'ccd-write-date-field', template: "<div class=\"form-group bottom-30\" [id]=\"id()\" [ngClass]=\"{'form-group-error': dateControl && !dateControl.valid && (dateControl.dirty || dateControl.touched)}\">\n\n  <fieldset>\n    <legend>\n      <span class=\"form-label\" *ngIf=\"caseField.label\">{{(caseField | ccdFieldLabel)}}</span>\n    </legend>\n    <span class=\"form-hint\" *ngIf=\"caseField.hint_text\">{{caseField.hint_text | rpxTranslate}}</span>\n    <span class=\"error-message\" *ngIf=\"dateControl && dateControl.errors && (dateControl.dirty || dateControl.touched)\">\n      {{(dateControl.errors | ccdFirstError:caseField.label)}}\n    </span>\n    <cut-date-input [id]=\"getId()\"\n                    [isDateTime]=\"isDateTime()\"\n                    [mandatory]=\"caseField | ccdIsMandatory\"\n                    [isInvalid]=\"dateControl.errors && (dateControl.dirty || dateControl.touched)\"\n                    [formControl]=\"dateControl\"></cut-date-input>\n\n  </fieldset>\n</div>\n" }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WriteDateFieldComponent, { className: "WriteDateFieldComponent", filePath: "lib/shared/components/palette/date/write-date-field.component.ts", lineNumber: 9 }); })();
//# sourceMappingURL=data:application/json;base64, 