import { Component, Input, ViewEncapsulation } from '@angular/core';
import moment from 'moment';
import { AxoUtils } from '../../../../../lib/axo-utils/axo-utils';
import { DateTime } from '../../../../forms/page/widgets/datetime';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/icon";
function DateTimeWidgetViewComponent_ng_container_1_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 9);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_container_1_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 10);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_container_1_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 11);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_container_1_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 10);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_container_1_span_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 10);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_container_1_span_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "span", 12);
    i0.ɵɵtext(3, ":");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r8.widget.prompt);
} }
function DateTimeWidgetViewComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵtemplate(2, DateTimeWidgetViewComponent_ng_container_1_span_2_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(3, DateTimeWidgetViewComponent_ng_container_1_span_3_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(4, DateTimeWidgetViewComponent_ng_container_1_span_4_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(5, DateTimeWidgetViewComponent_ng_container_1_span_5_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(6, DateTimeWidgetViewComponent_ng_container_1_span_6_Template, 2, 0, "span", 5);
    i0.ɵɵtemplate(7, DateTimeWidgetViewComponent_ng_container_1_span_7_Template, 4, 1, "span", 6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(8, "div", 7);
    i0.ɵɵtext(9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitch", ctx_r0.widget.subType);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "date");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "both");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "time");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "date_range");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r0.section.showPrompt);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r0.widgetValue, "");
} }
function DateTimeWidgetViewComponent_ng_template_2_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 9);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_template_2_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 10);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_template_2_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 11);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_template_2_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵelement(1, "mat-icon", 10);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_template_2_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵelement(1, "mat-icon", 10);
    i0.ɵɵelementEnd();
} }
function DateTimeWidgetViewComponent_ng_template_2_span_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "span", 12);
    i0.ɵɵtext(3, ":");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r14 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r14.widget.prompt);
} }
function DateTimeWidgetViewComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵtemplate(1, DateTimeWidgetViewComponent_ng_template_2_span_1_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(2, DateTimeWidgetViewComponent_ng_template_2_span_2_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(3, DateTimeWidgetViewComponent_ng_template_2_span_3_Template, 2, 0, "span", 4);
    i0.ɵɵtemplate(4, DateTimeWidgetViewComponent_ng_template_2_span_4_Template, 2, 0, "span", 13);
    i0.ɵɵtemplate(5, DateTimeWidgetViewComponent_ng_template_2_span_5_Template, 2, 0, "span", 5);
    i0.ɵɵtemplate(6, DateTimeWidgetViewComponent_ng_template_2_span_6_Template, 4, 1, "span", 6);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "span", 14);
    i0.ɵɵtext(8, "-");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngSwitch", ctx_r2.widget.subType);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "date");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "both");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "time");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "date_range");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r2.section.showPrompt);
} }
export class DateTimeWidgetViewComponent {
    constructor() { }
    ngOnInit() {
        this.widgetValue = this.widget.value;
        this.changeValueToDateRange();
    }
    changeValueToDateRange() {
        if (this.widgetValue) {
            if (this.widget.subType === 'date_range') {
                this.widgetValue = AxoUtils.formatDateToCustomDateFormat(this.widgetValue.from, 'MMMM D, YYYY') + ' to ' + AxoUtils.formatDateToCustomDateFormat(this.widgetValue.to, 'MMMM D, YYYY');
            }
            else if (this.widget.subType === 'time') {
                this.widgetValue = moment(AxoUtils.formatDateFromUTCToLocal(moment(this.widget.value.toString(), 'h:mm a').toLocaleString())).format('hh:mm A');
            }
            else if (this.widget.subType === 'date') {
                this.widgetValue = this.widget.dateFormat && this.widget.dateFormat !== '' ? moment(AxoUtils.formatDateFromUTCToLocal(moment(this.widget.value.toString()).toLocaleString())).format(AxoUtils.checkFormat(this.widget.dateFormat)) : moment(AxoUtils.formatDateFromUTCToLocal(moment(this.widget.value.toString()).toLocaleString())).format("MMMM DD YYYY");
            }
            else {
                this.widgetValue = this.widget.dateFormat && this.widget.dateFormat !== '' ? moment(AxoUtils.formatDateFromUTCToLocal(moment(this.widget.value.toString()).toLocaleString())).format(AxoUtils.checkFormat(this.widget.dateFormat)) : AxoUtils.formatDateFromUTCToLocal(moment(this.widget.value.toString()).toLocaleString());
            }
        }
    }
}
DateTimeWidgetViewComponent.ɵfac = function DateTimeWidgetViewComponent_Factory(t) { return new (t || DateTimeWidgetViewComponent)(); };
DateTimeWidgetViewComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DateTimeWidgetViewComponent, selectors: [["lib-date-time-widget-view"]], inputs: { widget: "widget" }, decls: 4, vars: 2, consts: [[1, "data-detail-info"], [4, "ngIf", "ngIfElse"], ["isWidgetValueEmpty", ""], [1, "data-detail-title", "flex", "text-sm", 3, "ngSwitch"], ["class", "date-icon", 4, "ngSwitchCase"], ["class", "date-icon", 4, "ngSwitchDefault"], ["class", "date-icon", 4, "ngIf"], [1, "data-detail-text", "text-sm"], [1, "date-icon"], ["svgIcon", "axo_date", 1, "add-text"], ["svgIcon", "axo_datetime", 1, "add-text"], ["svgIcon", "axo_time", 1, "add-text"], [1, "colon"], [4, "ngSwitchCase"], [1, "flex", "justify-start"]], template: function DateTimeWidgetViewComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵtemplate(1, DateTimeWidgetViewComponent_ng_container_1_Template, 10, 7, "ng-container", 1);
        i0.ɵɵtemplate(2, DateTimeWidgetViewComponent_ng_template_2_Template, 9, 6, "ng-template", null, 2, i0.ɵɵtemplateRefExtractor);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        const _r1 = i0.ɵɵreference(3);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.widget.value)("ngIfElse", _r1);
    } }, directives: [i1.NgIf, i1.NgSwitch, i1.NgSwitchCase, i1.NgSwitchDefault, i2.MatIcon], styles: ["lib-date-time-widget-view .date-icon{display:flex;align-items:center}\n"], encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DateTimeWidgetViewComponent, [{
        type: Component,
        args: [{ selector: 'lib-date-time-widget-view', encapsulation: ViewEncapsulation.None, template: " <div class=\"data-detail-info\">\n  <ng-container *ngIf=\"widget.value; else isWidgetValueEmpty\" >\n    <div  class=\"data-detail-title flex text-sm\" [ngSwitch]=\"widget.subType\">\n      <span *ngSwitchCase=\"'date'\" class=\"date-icon\"><mat-icon class=\"add-text\" svgIcon=\"axo_date\"></mat-icon> </span>\n      <span *ngSwitchCase=\"'both'\" class=\"date-icon\"> <mat-icon class=\"add-text\" svgIcon=\"axo_datetime\"></mat-icon></span>\n      <span *ngSwitchCase=\"'time'\" class=\"date-icon\"> <mat-icon class=\"add-text\" svgIcon=\"axo_time\"></mat-icon></span>\n      <span *ngSwitchCase=\"'date_range'\" class=\"date-icon\"><mat-icon class=\"add-text\" svgIcon=\"axo_datetime\"></mat-icon> </span>\n      <span *ngSwitchDefault class=\"date-icon\"><mat-icon class=\"add-text\" svgIcon=\"axo_datetime\"></mat-icon></span>\n      <span *ngIf=\"section.showPrompt\" class=\"date-icon\">{{widget.prompt}}<span class=\"colon\">:</span></span>\n    </div>  \n     <div class=\"data-detail-text text-sm\"> {{widgetValue}}</div>\n  </ng-container>\n  <ng-template #isWidgetValueEmpty>\n      <div class=\"data-detail-title flex text-sm\" [ngSwitch]=\"widget.subType\">\n        <span *ngSwitchCase=\"'date'\" class=\"date-icon\"><mat-icon class=\"add-text\" svgIcon=\"axo_date\"></mat-icon> </span>\n        <span *ngSwitchCase=\"'both'\" class=\"date-icon\"> <mat-icon class=\"add-text\" svgIcon=\"axo_datetime\"></mat-icon></span>\n        <span *ngSwitchCase=\"'time'\" class=\"date-icon\"> <mat-icon class=\"add-text\" svgIcon=\"axo_time\"></mat-icon></span>\n        <span *ngSwitchCase=\"'date_range'\"><mat-icon class=\"add-text\" svgIcon=\"axo_datetime\"></mat-icon> </span>\n        <span *ngSwitchDefault class=\"date-icon\"><mat-icon class=\"add-text\" svgIcon=\"axo_datetime\"></mat-icon></span>\n        <span *ngIf=\"section.showPrompt\" class=\"date-icon\">{{widget.prompt}}<span class=\"colon\">:</span></span>\n      </div>  \n      <span class=\"flex justify-start\">-</span>\n\n  </ng-template>\n</div>\n\n\n ", styles: ["lib-date-time-widget-view .date-icon{display:flex;align-items:center}\n"] }]
    }], function () { return []; }, { widget: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 