import { ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "../../services/util/util.service";
import * as i2 from "../../services/questionnaire/validation.service";
import * as i3 from "@angular/forms";
import * as i4 from "@ionic/angular";
import * as i5 from "@angular/common";
import * as i6 from "primeng/api";
import * as i7 from "primeng/table";
import * as i8 from "@fortawesome/angular-fontawesome";
import * as i9 from "../add-wage/add-wage.component";
import * as i10 from "@ngx-translate/core";
function WageGridComponent_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 7)(1, "th", 8);
    i0.ɵɵtext(2, " Employment ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "th", 9);
    i0.ɵɵtext(4);
    i0.ɵɵpipe(5, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "th", 10);
    i0.ɵɵtext(7);
    i0.ɵɵpipe(8, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "th", 11);
    i0.ɵɵtext(10);
    i0.ɵɵpipe(11, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(12, "th", 12);
    i0.ɵɵtext(13);
    i0.ɵɵpipe(14, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(15, "th");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(5, 8, "wage.firstQuarter"), " ", ctx_r1.previousYear, " ");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(8, 10, "wage.secondQuarter"), " ", ctx_r1.previousYear, " ");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(11, 12, "wage.thirdQuarter"), " ", ctx_r1.previousYear, " ");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate2(" ", i0.ɵɵpipeBind1(14, 14, "wage.fourthQuarter"), " ", ctx_r1.previousYear, " ");
} }
const _c0 = () => ["fal", "edit"];
const _c1 = () => ["fal", "trash-alt"];
function WageGridComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 7)(1, "td", 13)(2, "span", 14);
    i0.ɵɵtext(3, "Employer");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span");
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "td", 13)(7, "span", 14);
    i0.ɵɵtext(8);
    i0.ɵɵpipe(9, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(10, "span");
    i0.ɵɵtext(11);
    i0.ɵɵpipe(12, "currency");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(13, "td", 13)(14, "span", 14);
    i0.ɵɵtext(15);
    i0.ɵɵpipe(16, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(17, "span");
    i0.ɵɵtext(18);
    i0.ɵɵpipe(19, "currency");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(20, "td", 13)(21, "span", 14);
    i0.ɵɵtext(22);
    i0.ɵɵpipe(23, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(24, "span");
    i0.ɵɵtext(25);
    i0.ɵɵpipe(26, "currency");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(27, "td", 13)(28, "span", 14);
    i0.ɵɵtext(29);
    i0.ɵɵpipe(30, "translate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(31, "span");
    i0.ɵɵtext(32);
    i0.ɵɵpipe(33, "currency");
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(34, "td", 15)(35, "ion-button", 16);
    i0.ɵɵlistener("click", function WageGridComponent_ng_template_4_Template_ion_button_click_35_listener() { const restoredCtx = i0.ɵɵrestoreView(_r9); const employerWage_r6 = restoredCtx.$implicit; const ctx_r8 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r8.editWageDetail(employerWage_r6)); });
    i0.ɵɵelement(36, "fa-icon", 17);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(37, "ion-button", 18);
    i0.ɵɵlistener("click", function WageGridComponent_ng_template_4_Template_ion_button_click_37_listener() { const restoredCtx = i0.ɵɵrestoreView(_r9); const rowIndex_r7 = restoredCtx.rowIndex; const ctx_r10 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r10.deleteWageDetail(rowIndex_r7)); });
    i0.ɵɵelement(38, "fa-icon", 17);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const employerWage_r6 = ctx.$implicit;
    const rowIndex_r7 = ctx.rowIndex;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(5);
    i0.ɵɵtextInterpolate1(" ", employerWage_r6.wageEmpNameAndAddress, "");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate2("", i0.ɵɵpipeBind1(9, 17, "wage.firstQuarter"), " ", ctx_r2.currentYear, "");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(12, 19, employerWage_r6.wageAmountQuarter1), "");
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate2("", i0.ɵɵpipeBind1(16, 21, "wage.secondQuarter"), " ", ctx_r2.currentYear, "");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(19, 23, employerWage_r6.wageAmountQuarter2), "");
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate2("", i0.ɵɵpipeBind1(23, 25, "wage.thirdQuarter"), " ", ctx_r2.currentYear, "");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(26, 27, employerWage_r6.wageAmountQuarter3), "");
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate2("", i0.ɵɵpipeBind1(30, 29, "wage.fourthQuarter"), " ", ctx_r2.currentYear, "");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(33, 31, employerWage_r6.wageAmountQuarter4), "");
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("id", "btnEditWageDetail-" + rowIndex_r7);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("icon", i0.ɵɵpureFunction0(33, _c0));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("id", "btnDeleteWageDetail-" + rowIndex_r7);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("icon", i0.ɵɵpureFunction0(34, _c1));
} }
const _c2 = () => ["fal", "plus"];
function WageGridComponent_ng_template_5_table_0_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "table")(1, "tr")(2, "td", 20)(3, "div")(4, "b");
    i0.ɵɵtext(5, "+ Add");
    i0.ɵɵelementEnd();
    i0.ɵɵtext(6, " an Employment");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(7, "td", 21)(8, "ion-button", 22);
    i0.ɵɵlistener("click", function WageGridComponent_ng_template_5_table_0_Template_ion_button_click_8_listener() { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r13.addWageDetails()); });
    i0.ɵɵelement(9, "fa-icon", 17);
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    i0.ɵɵadvance(2);
    i0.ɵɵattribute("colspan", 4);
    i0.ɵɵadvance(7);
    i0.ɵɵproperty("icon", i0.ɵɵpureFunction0(2, _c2));
} }
function WageGridComponent_ng_template_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, WageGridComponent_ng_template_5_table_0_Template, 10, 3, "table", 19);
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngIf", !ctx_r3.selected);
} }
function WageGridComponent_app_add_wage_6_Template(rf, ctx) { if (rf & 1) {
    const _r16 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "app-add-wage", 23);
    i0.ɵɵlistener("success", function WageGridComponent_app_add_wage_6_Template_app_add_wage_success_0_listener($event) { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r15.addEmployerWageDetail($event)); })("onClose", function WageGridComponent_app_add_wage_6_Template_app_add_wage_onClose_0_listener() { i0.ɵɵrestoreView(_r16); const ctx_r17 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r17.close()); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵproperty("wageToEdit", ctx_r4.selectedEmployerWage);
} }
export class WageGridComponent {
    constructor(util, vs, formBuilder) {
        this.util = util;
        this.vs = vs;
        this.formBuilder = formBuilder;
        this.selected = false;
        this.indexToEdit = null;
        this.activeIndex = null;
        this.showDuplicatePopup = false;
        this.wages = [];
        this.onChange = (value) => { };
        this.onTouch = () => { };
        this.onChangeSubs = [];
        this.isDisabled = false;
        this.modelDisplay = new EventEmitter();
        this.currentYear = new Date().getFullYear();
        this.previousYear = new Date().getFullYear() - 1;
    }
    ngOnInit() {
        //This is used for DUA FORM - Wage Table, adding employment information for prior year
        this.wages = this.vs.employerWageDetails.getValue() || [];
    }
    writeValue(value) {
        if (value) {
            this.wages = value;
            this.publishEmployerWage();
        }
    }
    registerOnChange(fn) {
        let sub = this.vs.employerWageDetails.subscribe(fn);
        this.onChangeSubs.push(sub);
    }
    registerOnTouched(onTouch) {
        this.onTouch = onTouch;
    }
    setDisabledState(isDisabled) {
        this.isDisabled = isDisabled;
    }
    ngOnDestroy() {
        for (let sub of this.onChangeSubs) {
            sub.unsubscribe();
        }
    }
    deleteWageDetail(employerWage) {
        let index = this.wages.indexOf(employerWage);
        this.wages.splice(index, 1);
        this.publishEmployerWage();
    }
    editWageDetail(employerWage) {
        this.selectedEmployerWage = employerWage;
        this.indexToEdit = this.wages.indexOf(employerWage);
        this.display = true;
        this.selected = true;
        this.activeIndex = 0;
    }
    close() {
        this.display = false;
        this.indexToEdit = null;
        this.selectedEmployerWage = null;
        this.showDuplicatePopup = false;
        this.selected = false;
        this.activeIndex = -1;
    }
    async addWageDetails() {
        this.selected = true;
        this.modelDisplay.emit(true);
    }
    addEmployerWageDetail(employerWage) {
        if (this.indexToEdit != null) {
            this.wages[this.indexToEdit] = employerWage;
        }
        else {
            this.wages.push(employerWage);
        }
        this.display = false;
        this.selectedEmployerWage = null;
        this.indexToEdit = null;
        this.publishEmployerWage();
        this.selected = false;
        this.activeIndex = -1;
    }
    publishEmployerWage() {
        this.vs.employerWageDetails.next(this.wages.length > 0 ? this.wages : null);
    }
    static { this.ɵfac = function WageGridComponent_Factory(t) { return new (t || WageGridComponent)(i0.ɵɵdirectiveInject(i1.UtilService), i0.ɵɵdirectiveInject(i2.ValidationService), i0.ɵɵdirectiveInject(i3.UntypedFormBuilder)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WageGridComponent, selectors: [["app-wage-grid"]], outputs: { modelDisplay: "modelDisplay" }, features: [i0.ɵɵProvidersFeature([{
                    provide: NG_VALUE_ACCESSOR,
                    useExisting: WageGridComponent,
                    multi: true
                }])], decls: 7, vars: 3, consts: [[2, "margin-left", "-5px"], [3, "rowHover", "value"], ["dt", ""], ["pTemplate", "header"], ["pTemplate", "body"], ["pTemplate", "summary"], [3, "wageToEdit", "success", "onClose", 4, "ngIf"], [1, "ion-padding-top", "ion-padding-bottom"], [1, "titleHeader"], [1, "firstQuarter", 2, "font-weight", "bold"], [1, "secondQuarter", 2, "font-weight", "bold"], [1, "thirdQuarter", 2, "font-weight", "bold"], [1, "fourthQuarter", 2, "font-weight", "bold"], [2, "padding-left", "15px"], [1, "p-column-title"], [2, "text-align", "center"], ["size", "small", "color", "success", "fill", "outline", "aria-label", "Edit wage details", 1, "action-button", 3, "id", "click"], [1, "action-icon", 3, "icon"], ["size", "small", "color", "success", "fill", "outline", "aria-label", "Remove wage details", 1, "action-button", 3, "id", "click"], [4, "ngIf"], [1, "ion-padding-top", 2, "width", "55%", "width", "max-content !important", "white-space", "nowrap"], [1, "ion-padding-top"], ["id", "addWageDetails", "aria-label", "Add Wage Details", "fill", "outline", "size", "small", 1, "action-button", 3, "click"], [3, "wageToEdit", "success", "onClose"]], template: function WageGridComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "p-table", 1, 2);
            i0.ɵɵtemplate(3, WageGridComponent_ng_template_3_Template, 16, 16, "ng-template", 3)(4, WageGridComponent_ng_template_4_Template, 39, 35, "ng-template", 4)(5, WageGridComponent_ng_template_5_Template, 1, 1, "ng-template", 5);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(6, WageGridComponent_app_add_wage_6_Template, 1, 1, "app-add-wage", 6);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("rowHover", true)("value", ctx.wages);
            i0.ɵɵadvance(5);
            i0.ɵɵproperty("ngIf", ctx.selected);
        } }, dependencies: [i4.IonButton, i5.NgIf, i6.PrimeTemplate, i7.Table, i8.FaIconComponent, i9.AddWageComponent, i5.CurrencyPipe, i10.TranslatePipe], styles: [".titleHeader[_ngcontent-%COMP%]{padding-left:15px;font-weight:700}@media screen and (max-width: 40rem){.header[_ngcontent-%COMP%]{padding-right:5px}.titleHeader[_ngcontent-%COMP%]{font-weight:700}.firstQuarter[_ngcontent-%COMP%], .secondQuarter[_ngcontent-%COMP%], .thirdQuarter[_ngcontent-%COMP%], .fourthQuarter[_ngcontent-%COMP%]{width:max-content!important;white-space:nowrap;padding:revert-layer}}@media (min-width: 1200px) and (max-width: 1350px){.titleHeader[_ngcontent-%COMP%]{padding-left:15px;font-weight:700;width:30%}.firstQuarter[_ngcontent-%COMP%], .secondQuarter[_ngcontent-%COMP%], .thirdQuarter[_ngcontent-%COMP%], .fourthQuarter[_ngcontent-%COMP%]{width:max-content!important;white-space:nowrap;padding:revert-layer}}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WageGridComponent, [{
        type: Component,
        args: [{ selector: 'app-wage-grid', providers: [{
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: WageGridComponent,
                        multi: true
                    }], changeDetection: ChangeDetectionStrategy.Default, template: "<div style=\"margin-left: -5px;\">\r\n    <p-table #dt [rowHover]=\"true\"  [value]=\"wages\">\r\n        <ng-template pTemplate=\"header\" let-columns>\r\n            <tr class=\"ion-padding-top ion-padding-bottom\">\r\n                <th class=\"titleHeader\">\r\n                    Employment\r\n                </th>\r\n                <th class=\"firstQuarter\" style=\"font-weight:bold\">\r\n                    {{ \"wage.firstQuarter\" | translate }} {{ previousYear }}\r\n                </th>\r\n                <th class=\"secondQuarter\" style=\"font-weight:bold\">\r\n                    {{ \"wage.secondQuarter\" | translate }} {{ previousYear }}\r\n                </th>\r\n                <th class=\"thirdQuarter\" style=\"font-weight:bold\">\r\n                    {{ \"wage.thirdQuarter\" | translate }} {{ previousYear }}\r\n                </th>\r\n                <th class=\"fourthQuarter\" style=\"font-weight:bold\">\r\n                    {{ \"wage.fourthQuarter\" | translate }} {{ previousYear }}\r\n                </th>\r\n                <th></th>\r\n            </tr>\r\n        </ng-template>\r\n\r\n        <ng-template pTemplate=\"body\" let-employerWage let-rowIndex=\"rowIndex\">\r\n            <tr class=\"ion-padding-top ion-padding-bottom\">\r\n                <td style=\"padding-left: 15px\"><span class=\"p-column-title\">Employer</span><span>\r\n                        {{employerWage.wageEmpNameAndAddress}}</span>\r\n                </td>\r\n                <td style=\"padding-left: 15px\"><span class=\"p-column-title\">{{ \"wage.firstQuarter\" | translate }} {{ currentYear }}</span><span>\r\n                        {{employerWage.wageAmountQuarter1 | currency}}</span>\r\n                </td>\r\n                <td style=\"padding-left: 15px\"><span class=\"p-column-title\">{{ \"wage.secondQuarter\" | translate }} {{ currentYear }}</span><span>\r\n                        {{employerWage.wageAmountQuarter2 | currency}}</span>\r\n                </td>\r\n                <td style=\"padding-left: 15px\"><span class=\"p-column-title\">{{ \"wage.thirdQuarter\" | translate }} {{ currentYear }}</span><span>\r\n                        {{employerWage.wageAmountQuarter3 | currency}}</span>\r\n                </td>\r\n                <td style=\"padding-left: 15px\"><span class=\"p-column-title\">{{ \"wage.fourthQuarter\" | translate }} {{ currentYear }}</span><span>\r\n                        {{employerWage.wageAmountQuarter4 | currency}}</span>\r\n                </td>\r\n\r\n            </tr>\r\n\r\n                <td style=\"text-align: center;\">\r\n                    <ion-button [id]=\"'btnEditWageDetail-' + rowIndex\" size=\"small\" color=\"success\" fill=\"outline\"\r\n                        (click)=\"editWageDetail(employerWage);\" class=\"action-button\" aria-label=\"Edit wage details\">\r\n                        <fa-icon [icon]=\"['fal', 'edit']\" class=\"action-icon\"></fa-icon>\r\n                    </ion-button>\r\n\r\n                    <ion-button [id]=\"'btnDeleteWageDetail-' + rowIndex\" size=\"small\" color=\"success\" fill=\"outline\"\r\n                        (click)=\"deleteWageDetail(rowIndex);\" class=\"action-button\" aria-label=\"Remove wage details\">\r\n                        <fa-icon [icon]=\"['fal', 'trash-alt']\" class=\"action-icon\"></fa-icon>\r\n                    </ion-button>\r\n                </td>\r\n            \r\n        </ng-template>\r\n\r\n        <ng-template pTemplate=\"summary\" let-columns>\r\n            <table *ngIf=\"!selected\">\r\n                <tr>\r\n                    <td [attr.colspan]=\"4\" style=\"width: 55%; width: max-content !important; white-space: nowrap;\" class=\"ion-padding-top\">\r\n                        <div><b>+ Add</b> an Employment</div>\r\n                    </td>\r\n                    <td class=\"ion-padding-top\">\r\n                        <ion-button id=\"addWageDetails\" aria-label=\"Add Wage Details\" (click)=\"addWageDetails()\"\r\n                            fill=\"outline\" size=\"small\" class=\"action-button\">\r\n                            <fa-icon [icon]=\"['fal', 'plus']\" class=\"action-icon\"></fa-icon>\r\n                        </ion-button>\r\n                    </td>\r\n                </tr>\r\n            </table>\r\n        </ng-template>\r\n    </p-table>\r\n    <app-add-wage (success)=\"addEmployerWageDetail($event)\" (onClose)=\"close()\" [wageToEdit]=\"selectedEmployerWage\"\r\n        *ngIf=\"selected\">\r\n    </app-add-wage>\r\n</div>", styles: [".titleHeader{padding-left:15px;font-weight:700}@media screen and (max-width: 40rem){.header{padding-right:5px}.titleHeader{font-weight:700}.firstQuarter,.secondQuarter,.thirdQuarter,.fourthQuarter{width:max-content!important;white-space:nowrap;padding:revert-layer}}@media (min-width: 1200px) and (max-width: 1350px){.titleHeader{padding-left:15px;font-weight:700;width:30%}.firstQuarter,.secondQuarter,.thirdQuarter,.fourthQuarter{width:max-content!important;white-space:nowrap;padding:revert-layer}}\n"] }]
    }], () => [{ type: i1.UtilService }, { type: i2.ValidationService }, { type: i3.UntypedFormBuilder }], { modelDisplay: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WageGridComponent, { className: "WageGridComponent", filePath: "lib\\components\\wage-grid\\wage-grid.component.ts", lineNumber: 22 }); })();
//# sourceMappingURL=data:application/json;base64, 