import * as i0 from '@angular/core';
import { Component, ViewEncapsulation, Input, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import { coerceBooleanProperty } from '@angular/cdk/coercion';

class UxDateTagComponent {
    constructor() {
        this.date = new Date();
        this.dateFormat = 'dd/MM/YYYY';
        this.tabindex = 0;
        this.e2eAttr = 'ux-a-date-tag';
        // TODO eUI9 : languageCode input option removed => BC
        this.stateClass = '';
        this._isHandleOverdue = false;
        this._isVerticalLayout = true;
        this._isDisplayDaysLeft = false;
        this._isMuted = false;
        this._isAgnostic = false;
    }
    get isVerticalLayout() {
        return this._isVerticalLayout;
    }
    set isVerticalLayout(value) {
        this._isVerticalLayout = coerceBooleanProperty(value);
    }
    get isHandleOverdue() {
        return this._isHandleOverdue;
    }
    set isHandleOverdue(value) {
        this._isHandleOverdue = coerceBooleanProperty(value);
    }
    get isDisplayDaysLeft() {
        return this._isDisplayDaysLeft;
    }
    set isDisplayDaysLeft(value) {
        this._isDisplayDaysLeft = coerceBooleanProperty(value);
    }
    get isMuted() {
        return this._isMuted;
    }
    set isMuted(value) {
        this._isMuted = coerceBooleanProperty(value);
    }
    get isAgnostic() {
        return this._isAgnostic;
    }
    set isAgnostic(value) {
        this._isAgnostic = coerceBooleanProperty(value);
    }
    ngAfterContentInit() {
        const prefix = 'ux-a-date-tag';
        if (this.isMuted || this.isAgnostic) {
            this.isVerticalLayout = false;
        }
        if (this.isVerticalLayout) {
            this.stateClass += prefix + '--vertical ';
            if (this.typeClass) {
                this.stateClass += prefix + '--vertical--' + this.typeClass + ' ';
            }
            else if (this.isHandleOverdue) {
                this.stateClass += prefix + '--vertical--' + this.getOverdueState();
            }
        }
        else {
            if (this.typeClass) {
                this.stateClass += `${prefix}--${this.typeClass}`;
            }
            else if (this.isHandleOverdue) {
                this.stateClass += prefix + '--' + this.getOverdueState();
            }
            this.stateClass += this.isMuted ? ` ${prefix}--muted` : '';
            this.stateClass += this.isAgnostic ? ` ${prefix}--agnostic` : '';
        }
    }
    mathAbsDays(diffDays) {
        return Math.abs(diffDays).toString();
    }
    get daysLeftValue() {
        return this.diffDays(new Date(), this.date);
    }
    diffDays(dateStart, dateEnd) {
        return Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
    }
    getOverdueState() {
        const now = new Date();
        if (this.date.toDateString() === now.toDateString()) {
            return 'warning';
        }
        else if (now > this.date) {
            return 'danger';
        }
        else {
            return 'primary';
        }
    }
}
/** @nocollapse */ UxDateTagComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: UxDateTagComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
/** @nocollapse */ UxDateTagComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: UxDateTagComponent, selector: "ux-a-date-tag", inputs: { styleClass: "styleClass", typeClass: "typeClass", date: "date", dateFormat: "dateFormat", isVerticalLayout: "isVerticalLayout", isHandleOverdue: "isHandleOverdue", isDisplayDaysLeft: "isDisplayDaysLeft", isMuted: "isMuted", isAgnostic: "isAgnostic", tabindex: "tabindex", e2eAttr: "e2eAttr" }, ngImport: i0, template: "<span\n    *ngIf=\"isVerticalLayout\"\n    class=\"ux-a-date-tag-container\"\n    [tabindex]=\"tabindex\"\n    attr.aria-label=\"{{ date | date: 'dd' }} {{ date | date: 'MMM' }} {{ date | date: 'YYYY' }} {{ daysLeftValue }}\">\n    <div class=\"ux-a-date-tag {{ stateClass }} {{ styleClass }}\" attr.data-e2e=\"{{ e2eAttr }}\">\n        <div class=\"ux-a-date-tag__d\">{{ date | date: 'dd' }}</div>\n        <div class=\"ux-a-date-tag__m\">{{ date | date: 'MMM' }}</div>\n        <div class=\"ux-a-date-tag__y\">{{ date | date: 'YYYY' }}</div>\n    </div>\n\n    <div *ngIf=\"isDisplayDaysLeft\" class=\"ux-a-date-tag__sub-label\">\n        <ng-container *ngIf=\"daysLeftValue < -1\">{{ 'eui.XDAYSAGO' | translate: { days: mathAbsDays(daysLeftValue) } }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === -1\">{{ 'eui.ONEDAYAGO' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 0\">{{ 'eui.TODAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 1\"> {{ 'eui.INONEDAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue > 1\">{{ 'eui.INXDAYS' | translate: { days: daysLeftValue } }}</ng-container>\n    </div>\n</span>\n<span\n    *ngIf=\"!isVerticalLayout\"\n    class=\"ux-a-date-tag-container\"\n    [tabindex]=\"tabindex\"\n    attr.aria-label=\"{{ date | date: dateFormat }} {{ daysLeftValue }}\">\n    <div class=\"ux-a-date-tag {{ stateClass }} {{ styleClass }}\" attr.data-e2e=\"{{ e2eAttr }}\">\n        {{ date | date: dateFormat }}\n    </div>\n\n    <div *ngIf=\"isDisplayDaysLeft\" class=\"ux-a-date-tag__sub-label\">\n        <ng-container *ngIf=\"daysLeftValue < -1\">{{ 'eui.XDAYSAGO' | translate: { days: mathAbsDays(daysLeftValue) } }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === -1\">{{ 'eui.ONEDAYAGO' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 0\">{{ 'eui.TODAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 1\"> {{ 'eui.INONEDAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue > 1\">{{ 'eui.INXDAYS' | translate: { days: daysLeftValue } }}</ng-container>\n    </div>\n</span>\n", styles: [".eui-t-compact .ux-a-date-tag-container .ux-a-date-tag{max-width:6rem}.ux-a-date-tag-container .ux-a-date-tag{background-color:var(--eui-base-color-white);justify-content:center;padding:var(--eui-base-spacing-s);text-align:center;width:7rem;box-shadow:var(--eui-base-shadow-1);font:normal normal 400 1rem/1.25rem var(--eui-base-font-family);font-weight:700}.ux-a-date-tag-container .ux-a-date-tag__sub-label{font-size:var(--eui-base-font-size-xs);font-style:italic;margin-top:var(--eui-base-spacing-xs);text-align:center}.ux-a-date-tag-container .ux-a-date-tag--vertical{background:var(--eui-base-color-grey-15);border-bottom:var(--eui-base-spacing-2xs) solid var(--eui-base-color-accent-110)}.ux-a-date-tag-container .ux-a-date-tag--vertical .ux-a-date-tag-container .ux-a-date-tag__d{font-size:var(--eui-base-font-size-l);font-weight:400}.ux-a-date-tag-container .ux-a-date-tag--vertical .ux-a-date-tag-container .ux-a-date-tag__m{font-size:var(--eui-base-font-size-s);text-transform:uppercase;font:normal normal 400 1rem/1.25rem var(--eui-base-font-family);font-weight:700}.ux-a-date-tag-container .ux-a-date-tag--vertical .ux-a-date-tag-container .ux-a-date-tag__y{font-size:var(--eui-base-font-size-s)}.ux-a-date-tag-container .ux-a-date-tag--tiny{padding:var(--eui-base-spacing-xs)}.ux-a-date-tag-container .ux-a-date-tag--big{padding:var(--eui-base-spacing-m)}.ux-a-date-tag-container .ux-a-date-tag--primary{color:var(--eui-base-color-primary-110)}.ux-a-date-tag-container .ux-a-date-tag--info{color:var(--eui-base-color-info-110)}.ux-a-date-tag-container .ux-a-date-tag--success{color:var(--eui-base-color-success-110)}.ux-a-date-tag-container .ux-a-date-tag--warning{color:var(--eui-base-color-warning-120)}.ux-a-date-tag-container .ux-a-date-tag--danger{color:var(--eui-base-color-danger-110)}.ux-a-date-tag-container .ux-a-date-tag--vertical--primary{background:var(--eui-base-color-primary-110);border-bottom-color:var(--eui-base-color-primary-140);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--info{background:var(--eui-base-color-info-110);border-bottom-color:var(--eui-base-color-info-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--success{background:var(--eui-base-color-success-110);border-bottom-color:var(--eui-base-color-success-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--warning{background:var(--eui-base-color-warning-110);border-bottom-color:var(--eui-base-color-warning-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--danger{background:var(--eui-base-color-danger-110);border-bottom-color:var(--eui-base-color-danger-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--muted{margin-bottom:0;box-shadow:var(--eui-base-shadow-0);font:normal normal 400 1rem/1.25rem var(--eui-base-font-family)}.ux-a-date-tag-container .ux-a-date-tag--agnostic{background-color:transparent!important;display:inline-block;padding:0;text-align:inherit;width:auto!important;white-space:nowrap;box-shadow:var(--eui-base-shadow-0);font:normal normal 400 1rem/1.25rem var(--eui-base-font-family)}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.DatePipe, name: "date" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: UxDateTagComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ux-a-date-tag', encapsulation: ViewEncapsulation.None, template: "<span\n    *ngIf=\"isVerticalLayout\"\n    class=\"ux-a-date-tag-container\"\n    [tabindex]=\"tabindex\"\n    attr.aria-label=\"{{ date | date: 'dd' }} {{ date | date: 'MMM' }} {{ date | date: 'YYYY' }} {{ daysLeftValue }}\">\n    <div class=\"ux-a-date-tag {{ stateClass }} {{ styleClass }}\" attr.data-e2e=\"{{ e2eAttr }}\">\n        <div class=\"ux-a-date-tag__d\">{{ date | date: 'dd' }}</div>\n        <div class=\"ux-a-date-tag__m\">{{ date | date: 'MMM' }}</div>\n        <div class=\"ux-a-date-tag__y\">{{ date | date: 'YYYY' }}</div>\n    </div>\n\n    <div *ngIf=\"isDisplayDaysLeft\" class=\"ux-a-date-tag__sub-label\">\n        <ng-container *ngIf=\"daysLeftValue < -1\">{{ 'eui.XDAYSAGO' | translate: { days: mathAbsDays(daysLeftValue) } }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === -1\">{{ 'eui.ONEDAYAGO' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 0\">{{ 'eui.TODAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 1\"> {{ 'eui.INONEDAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue > 1\">{{ 'eui.INXDAYS' | translate: { days: daysLeftValue } }}</ng-container>\n    </div>\n</span>\n<span\n    *ngIf=\"!isVerticalLayout\"\n    class=\"ux-a-date-tag-container\"\n    [tabindex]=\"tabindex\"\n    attr.aria-label=\"{{ date | date: dateFormat }} {{ daysLeftValue }}\">\n    <div class=\"ux-a-date-tag {{ stateClass }} {{ styleClass }}\" attr.data-e2e=\"{{ e2eAttr }}\">\n        {{ date | date: dateFormat }}\n    </div>\n\n    <div *ngIf=\"isDisplayDaysLeft\" class=\"ux-a-date-tag__sub-label\">\n        <ng-container *ngIf=\"daysLeftValue < -1\">{{ 'eui.XDAYSAGO' | translate: { days: mathAbsDays(daysLeftValue) } }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === -1\">{{ 'eui.ONEDAYAGO' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 0\">{{ 'eui.TODAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue === 1\"> {{ 'eui.INONEDAY' | translate }}</ng-container>\n        <ng-container *ngIf=\"daysLeftValue > 1\">{{ 'eui.INXDAYS' | translate: { days: daysLeftValue } }}</ng-container>\n    </div>\n</span>\n", styles: [".eui-t-compact .ux-a-date-tag-container .ux-a-date-tag{max-width:6rem}.ux-a-date-tag-container .ux-a-date-tag{background-color:var(--eui-base-color-white);justify-content:center;padding:var(--eui-base-spacing-s);text-align:center;width:7rem;box-shadow:var(--eui-base-shadow-1);font:normal normal 400 1rem/1.25rem var(--eui-base-font-family);font-weight:700}.ux-a-date-tag-container .ux-a-date-tag__sub-label{font-size:var(--eui-base-font-size-xs);font-style:italic;margin-top:var(--eui-base-spacing-xs);text-align:center}.ux-a-date-tag-container .ux-a-date-tag--vertical{background:var(--eui-base-color-grey-15);border-bottom:var(--eui-base-spacing-2xs) solid var(--eui-base-color-accent-110)}.ux-a-date-tag-container .ux-a-date-tag--vertical .ux-a-date-tag-container .ux-a-date-tag__d{font-size:var(--eui-base-font-size-l);font-weight:400}.ux-a-date-tag-container .ux-a-date-tag--vertical .ux-a-date-tag-container .ux-a-date-tag__m{font-size:var(--eui-base-font-size-s);text-transform:uppercase;font:normal normal 400 1rem/1.25rem var(--eui-base-font-family);font-weight:700}.ux-a-date-tag-container .ux-a-date-tag--vertical .ux-a-date-tag-container .ux-a-date-tag__y{font-size:var(--eui-base-font-size-s)}.ux-a-date-tag-container .ux-a-date-tag--tiny{padding:var(--eui-base-spacing-xs)}.ux-a-date-tag-container .ux-a-date-tag--big{padding:var(--eui-base-spacing-m)}.ux-a-date-tag-container .ux-a-date-tag--primary{color:var(--eui-base-color-primary-110)}.ux-a-date-tag-container .ux-a-date-tag--info{color:var(--eui-base-color-info-110)}.ux-a-date-tag-container .ux-a-date-tag--success{color:var(--eui-base-color-success-110)}.ux-a-date-tag-container .ux-a-date-tag--warning{color:var(--eui-base-color-warning-120)}.ux-a-date-tag-container .ux-a-date-tag--danger{color:var(--eui-base-color-danger-110)}.ux-a-date-tag-container .ux-a-date-tag--vertical--primary{background:var(--eui-base-color-primary-110);border-bottom-color:var(--eui-base-color-primary-140);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--info{background:var(--eui-base-color-info-110);border-bottom-color:var(--eui-base-color-info-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--success{background:var(--eui-base-color-success-110);border-bottom-color:var(--eui-base-color-success-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--warning{background:var(--eui-base-color-warning-110);border-bottom-color:var(--eui-base-color-warning-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--vertical--danger{background:var(--eui-base-color-danger-110);border-bottom-color:var(--eui-base-color-danger-130);color:var(--eui-base-color-white)}.ux-a-date-tag-container .ux-a-date-tag--muted{margin-bottom:0;box-shadow:var(--eui-base-shadow-0);font:normal normal 400 1rem/1.25rem var(--eui-base-font-family)}.ux-a-date-tag-container .ux-a-date-tag--agnostic{background-color:transparent!important;display:inline-block;padding:0;text-align:inherit;width:auto!important;white-space:nowrap;box-shadow:var(--eui-base-shadow-0);font:normal normal 400 1rem/1.25rem var(--eui-base-font-family)}\n"] }]
        }], propDecorators: { styleClass: [{
                type: Input
            }], typeClass: [{
                type: Input
            }], date: [{
                type: Input
            }], dateFormat: [{
                type: Input
            }], isVerticalLayout: [{
                type: Input
            }], isHandleOverdue: [{
                type: Input
            }], isDisplayDaysLeft: [{
                type: Input
            }], isMuted: [{
                type: Input
            }], isAgnostic: [{
                type: Input
            }], tabindex: [{
                type: Input
            }], e2eAttr: [{
                type: Input
            }] } });
class UxDateTagComponentModule {
}
/** @nocollapse */ UxDateTagComponentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: UxDateTagComponentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
/** @nocollapse */ UxDateTagComponentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: UxDateTagComponentModule, declarations: [UxDateTagComponent], imports: [CommonModule, TranslateModule], exports: [UxDateTagComponent] });
/** @nocollapse */ UxDateTagComponentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: UxDateTagComponentModule, imports: [CommonModule, TranslateModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: UxDateTagComponentModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule, TranslateModule],
                    exports: [UxDateTagComponent],
                    declarations: [UxDateTagComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { UxDateTagComponent, UxDateTagComponentModule };
//# sourceMappingURL=eui-deprecated-ux-a-date-tag.mjs.map
