import { Component, Input, forwardRef } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
import * as i0 from "@angular/core";
import * as i1 from "../../../_helpers/utils";
import * as i2 from "@angular/common";
export class MaterialCaseSummaryComponent {
    constructor(utils) {
        this.utils = utils;
    }
    ngOnInit() {
        this.updatePrimaryWithStatus();
        this.updateLabelAndDate(this.primaryFieldsWithStatus$);
        this.updateLabelAndDate(this.secondaryFields$);
    }
    // eslint-disable-next-line sonarjs/no-identical-functions
    ngOnChanges() {
        this.updatePrimaryWithStatus();
        this.updateLabelAndDate(this.primaryFieldsWithStatus$);
        this.updateLabelAndDate(this.secondaryFields$);
    }
    updateLabelAndDate(arData) {
        for (const field of arData) {
            switch (field.type.toLowerCase()) {
                case 'caseoperator':
                    if (field.config.label.toLowerCase() == 'create operator') {
                        field.config.displayLabel = field.config.createLabel;
                    }
                    else if (field.config.label.toLowerCase() == 'update operator') {
                        field.config.displayLabel = field.config.updateLabel;
                    }
                    break;
                case 'date':
                    field.config.value = this.utils.generateDate(field.config.value, 'Date-Long');
                    break;
                case 'userreference':
                case 'decimal':
                case 'dropdown':
                    field.config.displayLabel = field.config.label;
                    break;
                case 'checkbox':
                    field.config.displayLabel = field.config.caption;
                    break;
                default:
                    break;
            }
        }
    }
    updatePrimaryWithStatus() {
        this.primaryFieldsWithStatus$ = [];
        for (const prim of this.primaryFields$) {
            this.primaryFieldsWithStatus$.push(prim);
        }
        if (this.bShowStatus$) {
            const oStatus = { type: 'status', config: { value: this.status$, label: 'Status' } };
            const count = this.primaryFieldsWithStatus$.length;
            if (count < 2) {
                this.primaryFieldsWithStatus$.push(oStatus);
            }
            else {
                this.primaryFieldsWithStatus$.splice(1, 0, oStatus);
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MaterialCaseSummaryComponent, deps: [{ token: i1.Utils }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MaterialCaseSummaryComponent, isStandalone: true, selector: "app-material-case-summary", inputs: { status$: "status$", bShowStatus$: "bShowStatus$", primaryFields$: "primaryFields$", secondaryFields$: "secondaryFields$" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"psdk-case-summary-fields\">\n  <dl class=\"psdk-case-summary-fields-primary\">\n    <div *ngFor=\"let field of primaryFieldsWithStatus$\" class=\"psdk-csf-primary-field\">\n      <dt class=\"psdk-csf-primary-field-header\">\n        {{ field.config.label }}\n      </dt>\n      <dd *ngIf=\"field.config.value === ''; else hasValue\" class=\"psdk-csf-primary-field-data\">\n        <ng-container [ngSwitch]=\"field.type.toLowerCase()\">\n          <label *ngSwitchCase=\"'caseoperator'\">operator</label>\n          <span *ngSwitchDefault class=\"psdk-csf-text-style\">---</span>\n        </ng-container>\n      </dd>\n      <ng-template #hasValue>\n        <dd class=\"psdk-csf-primary-field-data\" [ngSwitch]=\"field.type.toLowerCase()\">\n          <span *ngSwitchCase=\"'textinput'\" class=\"psdk-csf-text-style\">{{ field.config.value }}</span>\n          <span *ngSwitchCase=\"'status'\" class=\"psdk-csf-status-style\">{{ field.config.value }}</span>\n          <a *ngSwitchCase=\"'phone'\" as=\"a\" href=\"tel: {{ field.config.value }}\">{{ field.config.value }}</a>\n          <a *ngSwitchCase=\"'email'\" href=\"mailto: {{ field.config.value }}\">{{ field.config.value }}</a>\n          <span *ngSwitchCase=\"'date'\" class=\"psdk-csf-text-style\">{{ field.config.value }}</span>\n          <label *ngSwitchCase=\"'caseoperator'\">operator</label>\n          <span *ngSwitchDefault class=\"psdk-csf-text-style\">{{ field.config.value }}</span>\n        </dd>\n      </ng-template>\n    </div>\n  </dl>\n</div>\n<div class=\"psdk-case-summary-fields\">\n  <dl *ngFor=\"let field of secondaryFields$\" class=\"psdk-case-summary-fields-secondary\">\n    <div\n      *ngIf=\"\n        field.config?.label?.toLowerCase() == 'create operator' || field.config?.label?.toLowerCase() == 'update operator';\n        else hasSecondaryValue\n      \"\n    >\n      <component-mapper name=\"Operator\" [props]=\"{ pConn$: field?.kid }\"></component-mapper>\n    </div>\n    <ng-template #hasSecondaryValue>\n      <div class=\"psdk-csf-secondary-field\">\n        <dt class=\"psdk-csf-secondary-field-header\">\n          {{ field.config.displayLabel || field.config.label }}\n        </dt>\n        <dd class=\"psdk-csf-secondary-field-data\">\n          <div [ngSwitch]=\"field.type\">\n            <label *ngSwitchCase=\"'UserReference'\" class=\"psdk-secondary-value\">{{ field.config.value.userName || '---' }}</label>\n            <label *ngSwitchCase=\"'Checkbox'\" class=\"psdk-secondary-value\">{{ field.config.falseLabel || '---' }}</label>\n            <label *ngSwitchDefault class=\"psdk-secondary-value\">{{ field.config.value || '---' }}</label>\n          </div>\n        </dd>\n      </div>\n    </ng-template>\n  </dl>\n</div>\n", styles: [".psdk-case-summary{display:block;margin:.625rem}.psdk-case-summary-primary,.psdk-case-summary-secondary,.psdk-case-summary-status{text-align:left;margin-bottom:.75rem}.psdk-case-summary-status-data{display:block;background-color:var(--app-primary-lightest-color);color:var(--app-primary-color);padding:0rem .625rem;display:inline;font-size:.75rem;font-weight:700;text-transform:uppercase;line-height:1.5rem}.psdk-case-summary-primary .label{font-weight:600}.psdk-case-summary-primary .data{font-weight:600;font-size:1.625rem}.psdk-case-summary-secondary .label{font-weight:600}.psdk-case-summary-secondary .data{font-weight:600;padding-left:1.25rem}.psdk-case-summary-fields{padding:1rem;display:grid;grid-row-gap:1rem}.psdk-case-summary-fields-primary{grid-template-columns:20ch 1fr;display:grid;grid-column-gap:1rem;grid-row-gap:1rem}.psdk-csf-primary-field{display:grid;grid-template-columns:1fr;grid-column-gap:0rem}.psdk-csf-primary-field-header{word-break:break-word;grid-column-start:1;grid-row-start:1;max-width:max-content;font-size:.8125rem;font-weight:400;color:var(--app-field-header-color)}.psdk-csf-primary-field-data{word-break:break-word;grid-column-start:1;grid-row-start:2;margin-inline-start:unset}.psdk-case-summary-fields-secondary{width:100%;display:grid;grid-template-columns:1fr;grid-column-gap:1rem;grid-row-gap:.5rem}.psdk-csf-secondary-field{display:grid;grid-template-columns:auto;grid-column-gap:1rem}.psdk-csf-secondary-field-header{word-break:break-word;grid-column-start:1;grid-row-start:1;max-width:max-content;font-size:.8125rem;font-weight:400;color:var(--app-field-header-color);align-items:center;display:flex}.psdk-csf-secondary-field-data{word-break:break-word;grid-column-start:2;grid-row-start:1;margin-inline-start:unset}span.psdk-csf-text-style{font-size:1.125rem;font-weight:600}span.psdk-csf-status-style{background-color:var(--app-details-status-background);border-radius:.125rem;color:var(--app-details-status-color);display:inline-block;font-size:.75rem;font-weight:700;line-height:1.25rem;height:1.25rem;padding:0 .5rem;text-transform:uppercase}.psdk-secondary-value{font-size:1rem}\n"], dependencies: [{ kind: "ngmodule", type: i0.forwardRef(function () { return CommonModule; }) }, { kind: "directive", type: i0.forwardRef(function () { return i2.NgForOf; }), selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i0.forwardRef(function () { return i2.NgIf; }), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i0.forwardRef(function () { return i2.NgSwitch; }), selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i0.forwardRef(function () { return i2.NgSwitchCase; }), selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i0.forwardRef(function () { return i2.NgSwitchDefault; }), selector: "[ngSwitchDefault]" }, { kind: "component", type: i0.forwardRef(function () { return ComponentMapperComponent; }), selector: "component-mapper", inputs: ["name", "props", "errorMsg", "outputEvents", "parent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MaterialCaseSummaryComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-material-case-summary', standalone: true, imports: [CommonModule, forwardRef(() => ComponentMapperComponent)], template: "<div class=\"psdk-case-summary-fields\">\n  <dl class=\"psdk-case-summary-fields-primary\">\n    <div *ngFor=\"let field of primaryFieldsWithStatus$\" class=\"psdk-csf-primary-field\">\n      <dt class=\"psdk-csf-primary-field-header\">\n        {{ field.config.label }}\n      </dt>\n      <dd *ngIf=\"field.config.value === ''; else hasValue\" class=\"psdk-csf-primary-field-data\">\n        <ng-container [ngSwitch]=\"field.type.toLowerCase()\">\n          <label *ngSwitchCase=\"'caseoperator'\">operator</label>\n          <span *ngSwitchDefault class=\"psdk-csf-text-style\">---</span>\n        </ng-container>\n      </dd>\n      <ng-template #hasValue>\n        <dd class=\"psdk-csf-primary-field-data\" [ngSwitch]=\"field.type.toLowerCase()\">\n          <span *ngSwitchCase=\"'textinput'\" class=\"psdk-csf-text-style\">{{ field.config.value }}</span>\n          <span *ngSwitchCase=\"'status'\" class=\"psdk-csf-status-style\">{{ field.config.value }}</span>\n          <a *ngSwitchCase=\"'phone'\" as=\"a\" href=\"tel: {{ field.config.value }}\">{{ field.config.value }}</a>\n          <a *ngSwitchCase=\"'email'\" href=\"mailto: {{ field.config.value }}\">{{ field.config.value }}</a>\n          <span *ngSwitchCase=\"'date'\" class=\"psdk-csf-text-style\">{{ field.config.value }}</span>\n          <label *ngSwitchCase=\"'caseoperator'\">operator</label>\n          <span *ngSwitchDefault class=\"psdk-csf-text-style\">{{ field.config.value }}</span>\n        </dd>\n      </ng-template>\n    </div>\n  </dl>\n</div>\n<div class=\"psdk-case-summary-fields\">\n  <dl *ngFor=\"let field of secondaryFields$\" class=\"psdk-case-summary-fields-secondary\">\n    <div\n      *ngIf=\"\n        field.config?.label?.toLowerCase() == 'create operator' || field.config?.label?.toLowerCase() == 'update operator';\n        else hasSecondaryValue\n      \"\n    >\n      <component-mapper name=\"Operator\" [props]=\"{ pConn$: field?.kid }\"></component-mapper>\n    </div>\n    <ng-template #hasSecondaryValue>\n      <div class=\"psdk-csf-secondary-field\">\n        <dt class=\"psdk-csf-secondary-field-header\">\n          {{ field.config.displayLabel || field.config.label }}\n        </dt>\n        <dd class=\"psdk-csf-secondary-field-data\">\n          <div [ngSwitch]=\"field.type\">\n            <label *ngSwitchCase=\"'UserReference'\" class=\"psdk-secondary-value\">{{ field.config.value.userName || '---' }}</label>\n            <label *ngSwitchCase=\"'Checkbox'\" class=\"psdk-secondary-value\">{{ field.config.falseLabel || '---' }}</label>\n            <label *ngSwitchDefault class=\"psdk-secondary-value\">{{ field.config.value || '---' }}</label>\n          </div>\n        </dd>\n      </div>\n    </ng-template>\n  </dl>\n</div>\n", styles: [".psdk-case-summary{display:block;margin:.625rem}.psdk-case-summary-primary,.psdk-case-summary-secondary,.psdk-case-summary-status{text-align:left;margin-bottom:.75rem}.psdk-case-summary-status-data{display:block;background-color:var(--app-primary-lightest-color);color:var(--app-primary-color);padding:0rem .625rem;display:inline;font-size:.75rem;font-weight:700;text-transform:uppercase;line-height:1.5rem}.psdk-case-summary-primary .label{font-weight:600}.psdk-case-summary-primary .data{font-weight:600;font-size:1.625rem}.psdk-case-summary-secondary .label{font-weight:600}.psdk-case-summary-secondary .data{font-weight:600;padding-left:1.25rem}.psdk-case-summary-fields{padding:1rem;display:grid;grid-row-gap:1rem}.psdk-case-summary-fields-primary{grid-template-columns:20ch 1fr;display:grid;grid-column-gap:1rem;grid-row-gap:1rem}.psdk-csf-primary-field{display:grid;grid-template-columns:1fr;grid-column-gap:0rem}.psdk-csf-primary-field-header{word-break:break-word;grid-column-start:1;grid-row-start:1;max-width:max-content;font-size:.8125rem;font-weight:400;color:var(--app-field-header-color)}.psdk-csf-primary-field-data{word-break:break-word;grid-column-start:1;grid-row-start:2;margin-inline-start:unset}.psdk-case-summary-fields-secondary{width:100%;display:grid;grid-template-columns:1fr;grid-column-gap:1rem;grid-row-gap:.5rem}.psdk-csf-secondary-field{display:grid;grid-template-columns:auto;grid-column-gap:1rem}.psdk-csf-secondary-field-header{word-break:break-word;grid-column-start:1;grid-row-start:1;max-width:max-content;font-size:.8125rem;font-weight:400;color:var(--app-field-header-color);align-items:center;display:flex}.psdk-csf-secondary-field-data{word-break:break-word;grid-column-start:2;grid-row-start:1;margin-inline-start:unset}span.psdk-csf-text-style{font-size:1.125rem;font-weight:600}span.psdk-csf-status-style{background-color:var(--app-details-status-background);border-radius:.125rem;color:var(--app-details-status-color);display:inline-block;font-size:.75rem;font-weight:700;line-height:1.25rem;height:1.25rem;padding:0 .5rem;text-transform:uppercase}.psdk-secondary-value{font-size:1rem}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.Utils }]; }, propDecorators: { status$: [{
                type: Input
            }], bShowStatus$: [{
                type: Input
            }], primaryFields$: [{
                type: Input
            }], secondaryFields$: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 