import { ChangeDetectionStrategy, Component, HostBinding, Input } from '@angular/core';
import moment from 'moment';
import { isCalendarSelectionSingleDate } from './calendar.types';
import * as i0 from "@angular/core";
export class CalendarItemComponent {
    constructor() {
        this.view = 'day';
        this.today = false;
        this.selected = false;
        this.outsideActiveMonth = false;
    }
    ngOnChanges() {
        if (this.view !== 'day') {
            this.today = false;
            this.outsideActiveMonth = false;
        }
        else {
            this.today = moment(this.item?.date).isSame(moment(), 'day');
            this.outsideActiveMonth = !moment(this.item?.date).isSame(this.activeDate, 'month');
        }
        this.selected = this.isSelected(this.item?.date, this.selection, this.view);
    }
    isSelected(date, selection, view) {
        if (!date || !selection) {
            return false;
        }
        if (isCalendarSelectionSingleDate(this.selection)) {
            return moment(this.item?.date).isSame(this.selection, view);
        }
        else {
            // TODO ECAP-26841: determine if the item is within the range selection
            return false;
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CalendarItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CalendarItemComponent, selector: "button[ec-calendar-item]", inputs: { item: "item", activeDate: "activeDate", selection: "selection", view: "view" }, host: { properties: { "class.is-today": "this.today", "class.is-selected": "this.selected", "class.is-outside-active-month": "this.outsideActiveMonth" } }, usesOnChanges: true, ngImport: i0, template: '{{item?.label}}', isInline: true, styles: [":host{font-size:var(--ec-font-size-action);height:2rem;line-height:1.25rem;padding:.3125rem .5rem;border:0;border-radius:var(--ec-border-radius);display:flex;align-items:center;justify-content:center;cursor:pointer;background-color:transparent;line-height:1.125rem}:host .label{display:flex;align-items:center;justify-content:center;white-space:nowrap;flex:auto}:host .ec-icon{flex:none}:host .ec-icon+.label{flex:none;margin-left:.25rem}:host.has-badge{padding-right:.0625rem}:host:focus{outline:none;position:relative;z-index:1}:host:disabled{background-color:var(--ec-background-color-disabled);border:1px solid var(--ec-form-control-border-color-disabled);color:var(--ec-color-disabled-dark);opacity:var(--ec-form-control-opacity-disabled);cursor:default}:host:disabled{background-color:transparent;border-color:transparent;color:var(--ec-color-hint-dark);opacity:1;--ec-color-icon: var(--ec-color-hint-dark)}:host:hover:not(:disabled){background-color:var(--ec-background-color-hover)}:host:active:not(:disabled){background-color:var(--ec-background-color-selected);font-weight:700}:host:focus:not(:disabled){box-shadow:var(--ec-button-box-shadow-active, 0 0 0 2px var(--ec-border-color-focus))}:host.is-selected,:host.is-selected:disabled{background-color:var(--ec-background-color-selected);font-weight:700}:host.is-today{text-decoration:underline}:host.is-outside-active-month{color:var(--ec-color-hint-dark)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CalendarItemComponent, decorators: [{
            type: Component,
            args: [{ selector: 'button[ec-calendar-item]', template: '{{item?.label}}', changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{font-size:var(--ec-font-size-action);height:2rem;line-height:1.25rem;padding:.3125rem .5rem;border:0;border-radius:var(--ec-border-radius);display:flex;align-items:center;justify-content:center;cursor:pointer;background-color:transparent;line-height:1.125rem}:host .label{display:flex;align-items:center;justify-content:center;white-space:nowrap;flex:auto}:host .ec-icon{flex:none}:host .ec-icon+.label{flex:none;margin-left:.25rem}:host.has-badge{padding-right:.0625rem}:host:focus{outline:none;position:relative;z-index:1}:host:disabled{background-color:var(--ec-background-color-disabled);border:1px solid var(--ec-form-control-border-color-disabled);color:var(--ec-color-disabled-dark);opacity:var(--ec-form-control-opacity-disabled);cursor:default}:host:disabled{background-color:transparent;border-color:transparent;color:var(--ec-color-hint-dark);opacity:1;--ec-color-icon: var(--ec-color-hint-dark)}:host:hover:not(:disabled){background-color:var(--ec-background-color-hover)}:host:active:not(:disabled){background-color:var(--ec-background-color-selected);font-weight:700}:host:focus:not(:disabled){box-shadow:var(--ec-button-box-shadow-active, 0 0 0 2px var(--ec-border-color-focus))}:host.is-selected,:host.is-selected:disabled{background-color:var(--ec-background-color-selected);font-weight:700}:host.is-today{text-decoration:underline}:host.is-outside-active-month{color:var(--ec-color-hint-dark)}\n"] }]
        }], ctorParameters: () => [], propDecorators: { item: [{
                type: Input
            }], activeDate: [{
                type: Input
            }], selection: [{
                type: Input
            }], view: [{
                type: Input
            }], today: [{
                type: HostBinding,
                args: ['class.is-today']
            }], selected: [{
                type: HostBinding,
                args: ['class.is-selected']
            }], outsideActiveMonth: [{
                type: HostBinding,
                args: ['class.is-outside-active-month']
            }] } });
//# sourceMappingURL=data:application/json;base64, 