import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Self, Optional, Input, Output, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import * as i4 from '@angular/material/button';
import { MatButtonModule } from '@angular/material/button';
import * as i5 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i3 from '@deja-js/component/time-picker';
import { DejaTimePickerModule } from '@deja-js/component/time-picker';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { Destroy, KeyCodes } from '@deja-js/component/core';
import { format } from 'date-fns';
import { Subject, fromEvent, takeUntil, mergeWith, filter, tap, debounceTime } from 'rxjs';

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
var DaysOfWeek;
(function (DaysOfWeek) {
    DaysOfWeek[DaysOfWeek["Sunday"] = 0] = "Sunday";
    DaysOfWeek[DaysOfWeek["Monday"] = 1] = "Monday";
    DaysOfWeek[DaysOfWeek["Tuesday"] = 2] = "Tuesday";
    DaysOfWeek[DaysOfWeek["Wednesday"] = 3] = "Wednesday";
    DaysOfWeek[DaysOfWeek["Thursday"] = 4] = "Thursday";
    DaysOfWeek[DaysOfWeek["Friday"] = 5] = "Friday";
    DaysOfWeek[DaysOfWeek["Saturday"] = 6] = "Saturday";
})(DaysOfWeek || (DaysOfWeek = {}));
var DateComponentLayout;
(function (DateComponentLayout) {
    DateComponentLayout[DateComponentLayout["dateonly"] = 1] = "dateonly";
    DateComponentLayout[DateComponentLayout["datetime"] = 2] = "datetime";
    DateComponentLayout[DateComponentLayout["timeonly"] = 3] = "timeonly";
})(DateComponentLayout || (DateComponentLayout = {}));
class DejaDateSelectorComponent extends Destroy {
    constructor(elementRef, changeDetectorRef, _control) {
        super();
        this.changeDetectorRef = changeDetectorRef;
        this._control = _control;
        this.startDay = DaysOfWeek.Monday;
        this.dateChange = new EventEmitter();
        this.timeChange = new EventEmitter();
        this._local = 'fr';
        this.zeroHourDate = new Date(0, 0, 0, 0, 0, 0, 0);
        this._keyboardNavigation = false;
        this._keyboardNavigation$ = new Subject();
        this._currentDate = new Date();
        this._displayedDate = new Date();
        this._days = [];
        this.onTouchedCallback = () => undefined;
        this.onChangeCallback = (_a) => undefined;
        const element = elementRef.nativeElement;
        if (this._control) {
            this._control.valueAccessor = this;
        }
        fromEvent(element, 'mousedown').pipe(takeUntil(this.destroyed$)).subscribe(event => {
            event.stopPropagation();
            event.preventDefault();
            return false;
        });
        fromEvent(element, 'click').pipe(takeUntil(this.destroyed$)).subscribe(event => {
            const target = event.target;
            if (target.hasAttribute('dateindex')) {
                const dateSelectorItem = this._currentDays[+target.getAttribute('dateindex')];
                if (!dateSelectorItem.disabled) {
                    const val = new Date(dateSelectorItem.date);
                    if (this._displayedDate) {
                        val.setHours(this._displayedDate.getHours(), this._displayedDate.getMinutes(), this._displayedDate.getSeconds(), this._displayedDate.getMilliseconds());
                    }
                    this.value = val;
                    this.dateChange.emit(this.value);
                }
            }
        });
        this._keyboardNavigation$.pipe(mergeWith(fromEvent(element, 'mouseleave'), fromEvent(element, 'click')), filter(() => this._keyboardNavigation), takeUntil(this.destroyed$)).subscribe(() => {
            this._keyboardNavigation = false;
            this.changeDetectorRef.markForCheck();
        });
        this._keyboardNavigation$.pipe(filter(value => value), tap(value => this._keyboardNavigation = value), debounceTime(2000), takeUntil(this.destroyed$)).subscribe(() => this._keyboardNavigation$.next(false));
        this.layout = DateComponentLayout.dateonly;
    }
    get keyboardNavigation() {
        return this._keyboardNavigation;
    }
    get displayedDate() {
        return this._displayedDate;
    }
    get local() {
        return this._local;
    }
    /**
     * Component Layout
     */
    set layout(value) {
        if (value) {
            if (typeof value === 'string') {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
                this.layoutId = DateComponentLayout[value];
                if (!this.layoutId) {
                    throw new Error('Invalid type for DateComponentLayout');
                }
                this.layoutClass = value;
            }
            else {
                this.layoutId = value;
                this.layoutClass = DateComponentLayout[value];
            }
        }
        this.changeDetectorRef.markForCheck();
    }
    /**
     * Time property setter. Can be string or empty so you can use it like : <deja-date-selector time></deja-date-selector>
     * Used to add time selector next to calendar
     */
    set time(value) {
        this._time = coerceBooleanProperty(value) ? true : null;
        if (this._time) {
            this.layout = DateComponentLayout.datetime;
        }
        this.changeDetectorRef.markForCheck();
    }
    /** Time property getter. */
    get time() {
        return this._time;
    }
    get days() {
        return this._days;
    }
    get emptyDays() {
        return this._emptyDays;
    }
    get currentDate() {
        return this._currentDate;
    }
    get currentDays() {
        return this._currentDays;
    }
    /** Disabled property setter. Can be string or empty so you can use it like : <deja-date-selector disabled></deja-date-selector> */
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value) ? true : null;
        // this.changeDetectorRef.markForCheck();
        this.bind();
    }
    /** Disabled property getter. */
    get disabled() {
        return this._disabled;
    }
    ngOnInit() {
        if (!this._displayedDate) {
            this._displayedDate = this._currentDate;
            this.bind();
        }
    }
    // ************* ControlValueAccessor Implementation **************
    // set accessor including call the onchange callback
    set value(v) {
        if (v !== this.selectedDate) {
            this.writeValue(v);
            this.onChangeCallback(v);
        }
    }
    // get accessor
    get value() {
        return this.selectedDate;
    }
    // From ControlValueAccessor interface
    writeValue(value) {
        if (value instanceof Date && value !== this.selectedDate) {
            const clone = new Date(value.getTime());
            if (this.selectedDate) {
                // When using a date-picker without time keep the time specified in the selectedDate when changing date
                if (this.layoutId === 1 && this.selectedDate.toLocaleDateString() !== clone.toLocaleDateString()) {
                    clone.setHours(this.selectedDate.getHours(), this.selectedDate.getMinutes(), this.selectedDate.getSeconds());
                }
            }
            this.selectedDate = clone;
            this._displayedDate = clone || this._currentDate;
        }
        else {
            this._displayedDate = this._currentDate;
        }
        this.bind();
    }
    // From ControlValueAccessor interface
    registerOnChange(fn) {
        this.onChangeCallback = fn;
    }
    // From ControlValueAccessor interface
    registerOnTouched(fn) {
        this.onTouchedCallback = fn;
    }
    setDisabledState(isDisabled) {
        this.disabled = isDisabled;
    }
    // ************* End of ControlValueAccessor Implementation **************
    /**
     * @param month (attention : Janvier = 0, Décembre = 11)
     * @param year
     * @return Jours du mois au format IDateSelectorItem
     */
    getAllDaysInMonth(month, year) {
        const days = [];
        let day = 1;
        let date = new Date(year, month, day);
        // eslint-disable-next-line no-loops/no-loops
        while (date.getDay() !== this.startDay) {
            date = new Date(year, month, --day);
            const dateSelectorItem = {
                background: true,
                date: date
            };
            days.splice(0, 0, dateSelectorItem);
        }
        let d = 0;
        // eslint-disable-next-line no-loops/no-loops
        for (d = 1; d <= this.daysInMonth(month + 1, year); d++) {
            date = new Date(year, month, d);
            const dateSelectorItem = {
                currentDate: (this._currentDate.setHours(0, 0, 0, 0) === date.setHours(0, 0, 0, 0)) ? true : null,
                date: date
            };
            days.push(dateSelectorItem);
        }
        // eslint-disable-next-line no-loops/no-loops, no-constant-condition
        while (true) {
            date = new Date(year, month, d);
            if (date.getDay() === this.startDay) {
                break;
            }
            else {
                const dateSelectorItem = {
                    background: true,
                    date: date
                };
                days.push(dateSelectorItem);
                d++;
            }
        }
        // Il nous faut 6 lignes de 7 jours pour correspondre à tous les mois. 6*7=42
        // Du coup on ajoute une ligne vide quand c'est nécessaire
        if (days.length < 42) {
            const x = 42 - days.length;
            this._emptyDays = new Array(x);
        }
        else {
            this._emptyDays = null;
        }
        return days;
    }
    daysInMonth(month, year) {
        return new Date(year, month, 0).getDate();
    }
    keyDown(event) {
        if (this.disabled) {
            return undefined;
        }
        if (!this.selectedDate) {
            this.selectedDate = new Date(this._currentDate);
        }
        this._keyboardNavigation$.next(true);
        let d;
        switch (event.code) {
            case KeyCodes.PageUp:
            case KeyCodes.PageDown:
            case KeyCodes.UpArrow:
            case KeyCodes.DownArrow:
            case KeyCodes.LeftArrow:
            case KeyCodes.RightArrow:
                event.preventDefault();
                d = new Date(this.selectedDate);
                switch (event.code) {
                    case KeyCodes.PageUp:
                        // d.setMonth(d.getMonth() - 1);
                        this.setMonthIfPossible(d, -1);
                        break;
                    case KeyCodes.PageDown:
                        // d.setMonth(d.getMonth() + 1);
                        this.setMonthIfPossible(d, 1);
                        break;
                    case KeyCodes.UpArrow:
                        // d.setDate(d.getDate() - 7);
                        this.setDateIfPossible(d, -7);
                        break;
                    case KeyCodes.DownArrow:
                        // d.setDate(d.getDate() + 7);
                        this.setDateIfPossible(d, 7);
                        break;
                    case KeyCodes.LeftArrow:
                        // d.setDate(d.getDate() - 1);
                        this.setDateIfPossible(d, -1);
                        break;
                    case KeyCodes.RightArrow:
                        // d.setDate(d.getDate() + 1);
                        this.setDateIfPossible(d, 1);
                        break;
                    default:
                        break;
                }
                // this.selectedDate = d;
                // this._displayedDate = d;
                // this.bind();
                break;
            case KeyCodes.Space:
            case KeyCodes.Enter:
                event.preventDefault();
                this.onChangeCallback(this.selectedDate);
                break;
            default:
                return true;
        }
        return undefined;
    }
    changeMonth(x) {
        this.setMonthIfPossible(this._displayedDate, x);
        return false;
    }
    changeYear(x) {
        this.setYearIfPossible(this._displayedDate, x);
        return false;
    }
    updateTime(hours) {
        let d;
        if (this.selectedDate) {
            d = new Date(this.selectedDate);
        }
        else {
            d = new Date();
            d.setHours(0, 0, 0, 0);
        }
        if (hours) {
            d.setHours(hours.getHours(), hours.getMinutes(), hours.getSeconds(), hours.getMilliseconds());
        }
        else {
            d.setHours(0, 0, 0, 0);
        }
        this.value = d;
        this.timeChange.emit(this.value);
    }
    getDisplayedDate() {
        return this.getDateLabel(this.displayedDate);
    }
    getSelectedDate() {
        return this.getDateLabel(this.selectedDate);
    }
    getDateLabel(date) {
        if (!date) {
            return '-';
        }
        const sb = new Array();
        if (!this.format) {
            if (this.layoutId < 3) {
                sb.push(date?.toLocaleDateString());
            }
            if (this.layoutId > 1) {
                const hours = `0${date.getHours()}`;
                const minutes = `0${date.getMinutes()}`;
                sb.push(`${hours.slice(-2)}:${minutes.slice(-2)}`);
            }
        }
        else {
            sb.push((date && this.format && format(date, this.format)) || date?.toLocaleDateString());
        }
        return sb.join('&nbsp;&nbsp;');
    }
    bind() {
        const month = this._displayedDate.getMonth();
        const year = this._displayedDate.getFullYear();
        this._currentDays = this.getAllDaysInMonth(month, year);
        this._currentDays.forEach((day) => day.disabled = this.isDisabledDate(day.date));
        // eslint-disable-next-line no-loops/no-loops
        for (let i = 0; i < 7; i++) {
            this._days[i] = this._currentDays[i].date.toLocaleString('fr', { weekday: 'narrow' });
        }
        if (this.selectedDate && this.selectedDate.getFullYear() === year && this.selectedDate.getMonth() === month) {
            const selectedDay = this.selectedDate.getDate();
            this._currentDays.forEach((day) => day.selected = day.date.getDate() === selectedDay && day.date.getMonth() === month);
        }
        this.changeDetectorRef.markForCheck();
    }
    /**
     * Vérifie si la date passée en param est désactivée.
     *
     * @param date
     * @return sera false si this.disableDates n'existe pas / n'est pas un tableau,
     *         si la date envoyée en param est valide,
     *         si la date est superieure a dateMax
     *         ou si la date est inférieure a dateMin
     */
    isDisabledDate(date) {
        if (this._disabled) {
            return true;
        }
        if (this.disableDates && this.disableDates instanceof Array) {
            const find = this.disableDates.find((d) => {
                if (typeof d === 'number') {
                    return d === date.getDay();
                }
                else {
                    return d.toLocaleDateString() === date.toLocaleDateString();
                }
            });
            if (typeof find !== 'undefined') {
                return true;
            }
        }
        if ((this.dateMax && date.getTime() > this.dateMax.getTime()) || (this.dateMin && date.getTime() < this.dateMin.getTime())) {
            return true;
        }
        return false;
    }
    /**
     * Fonction récursive. Si le jour séléctionné + num est invalide, la fonction
     * se rappelle pour séléctionner le jour suivant (ou précédent)
     *
     * @param date
     * @param num : nombre de jours à ajouter à date.
     */
    setDateIfPossible(date, num) {
        const d = new Date(date);
        d.setDate(d.getDate() + num);
        if ((this.dateMin && d.getTime() < this.dateMin.getTime()) || (this.dateMax && d.getTime() > this.dateMax.getTime())) {
            this._displayedDate = d;
            this.bind();
            this.dateChange.emit(this._displayedDate);
        }
        else if (this.disableDates && this.isDisabledDate(d)) {
            this.setDateIfPossible(d, num);
        }
        else {
            this._displayedDate = d;
            this.bind();
            this.dateChange.emit(this._displayedDate);
        }
    }
    /**
     * Fonction récursive. Si le mois séléctionné + num est invalide, la fonction
     * se rappelle pour séléctionner le jour suivant (ou précédent)
     *
     * @param date
     * @param num : nombre de mois à ajouter à date.
     */
    setMonthIfPossible(date, num) {
        const d = new Date(date);
        d.setMonth(d.getMonth() + num);
        if (this.disableDates && this.isDisabledDate(d)) {
            num = (num < 0) ? -1 : 1;
            this.setDateIfPossible(d, num);
        }
        else {
            this._displayedDate = d;
            this.bind();
            this.dateChange.emit(this._displayedDate);
        }
    }
    /**
     * Fonction récursive. Si l'année séléctionné + num est invalide, la fonction
     * se rappelle pour séléctionner le jour suivant (ou précédent)
     *
     * @param date
     * @param num : nombre de jours à ajouter à date.
     */
    setYearIfPossible(date, num) {
        const d = new Date(date);
        d.setFullYear(d.getFullYear() + num);
        if (this.disableDates && this.isDisabledDate(d)) {
            num = (num < 0) ? -1 : 1;
            this.setDateIfPossible(d, num);
        }
        else {
            this._displayedDate = d;
            this.bind();
            this.dateChange.emit(this._displayedDate);
        }
    }
}
DejaDateSelectorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaDateSelectorComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
DejaDateSelectorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: DejaDateSelectorComponent, selector: "deja-date-time-selector", inputs: { startDay: "startDay", disableDates: "disableDates", dateMax: "dateMax", dateMin: "dateMin", format: "format", layout: "layout", time: "time", disabled: "disabled" }, outputs: { dateChange: "dateChange", timeChange: "timeChange" }, usesInheritance: true, ngImport: i0, template: "<div id=\"date-time-selector\" [ngClass]=\"layoutClass\" tabindex=\"-1\">\n    <div id=\"date-header\">\n        <div class=\"year\" *ngIf=\"layoutId < 3\">\n            <button mat-mini-fab type=\"button\" (click)=\"changeYear(-1)\" [disabled]=\"disabled\">\n                <mat-icon>keyboard_arrow_left</mat-icon>\n            </button>\n            <div>{{displayedDate.getFullYear()}}</div>\n            <button mat-mini-fab type=\"button\" (click)=\"changeYear(1)\" [disabled]=\"disabled\">\n                <mat-icon>keyboard_arrow_right</mat-icon>\n            </button>\n        </div>\n        <div current [innerHTML]=\"getSelectedDate() || '-'\">\n        </div>\n    </div>\n    <div id=\"date-selector\" *ngIf=\"layoutId < 3\">\n        <div id=\"sub-header\">\n            <div class=\"month\">\n                <div class=\"previous\">\n                    <button mat-mini-fab type=\"button\" (click)=\"changeMonth(-1)\" [disabled]=\"disabled\">\n                        <mat-icon>keyboard_arrow_left</mat-icon>\n                    </button>\n                </div>\n                <span>{{displayedDate.toLocaleString(local, { month: 'long' })}} {{displayedDate.getFullYear()}}</span>\n                <div class=\"next\">\n                    <button mat-mini-fab type=\"button\" (click)=\"changeMonth(1)\" [disabled]=\"disabled\">\n                        <mat-icon>keyboard_arrow_right</mat-icon>\n                    </button>\n                </div>\n            </div>\n            <div class=\"days\">\n                <span *ngFor=\"let day of days\">{{day}}</span>\n            </div>\n        </div>\n        <div id=\"date-body\" (keydown)=\"keyDown($event)\" tabindex=\"0\" [attr.keynav]=\"keyboardNavigation\">\n            <div class=\"date\" *ngFor=\"let dateSelectorItem of currentDays; let index=index\">\n                <div class=\"day\" [attr.dateindex]=\"index\" [class.background]=\"dateSelectorItem.background\" [class.disabled]=\"dateSelectorItem.disabled\" [attr.current]=\"dateSelectorItem.currentDate || null\" [attr.selected]=\"dateSelectorItem.selected || null\">\n                    {{dateSelectorItem.date.getDate()}}\n                </div>\n            </div>\n            <div class=\"date\" *ngFor=\"let emptyDay of emptyDays\"></div>\n        </div>\n    </div>\n    <div id=\"time-selector\" *ngIf=\"layoutId > 1\">\n        <deja-time-picker [ngModel]=\"(displayedDate) ? displayedDate : zeroHourDate\" (ngModelChange)=\"updateTime($event)\" [disabled]=\"disabled\"></deja-time-picker>\n    </div>\n</div>\n", styles: ["deja-date-time-selector #date-time-selector{display:flex;flex-direction:column;margin:0 auto;width:310px;outline:none}deja-date-time-selector #date-time-selector.timeonly{height:15rem}deja-date-time-selector #date-time-selector #date-header{display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:2rem;height:94px;padding:0;position:relative}deja-date-time-selector #date-time-selector #date-header [current]{font-size:2rem}deja-date-time-selector #date-time-selector #date-header .year{align-items:center;display:flex;font-size:1rem;justify-content:center;width:50%}deja-date-time-selector #date-time-selector #date-header .year [fontIcon]{flex:0 0 auto;cursor:pointer}deja-date-time-selector #date-time-selector #date-header .year div{flex:1 1 auto;text-align:center}deja-date-time-selector #date-time-selector #time-selector{height:8rem;display:flex;align-items:center;justify-content:center}deja-date-time-selector #date-time-selector #date-selector{margin:0 auto;width:310px}deja-date-time-selector #date-time-selector #date-selector #sub-header .month{align-items:center;display:flex;justify-content:center;padding:1rem;text-align:center}deja-date-time-selector #date-time-selector #date-selector #sub-header .month span{flex:1 1 auto;font-size:1rem;text-transform:capitalize}deja-date-time-selector #date-time-selector #date-selector #sub-header .month button[mat-mini-fab]{flex:0 0 auto;box-shadow:none}deja-date-time-selector #date-time-selector #date-selector #sub-header .days{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin-bottom:.5rem;text-align:center}deja-date-time-selector #date-time-selector #date-selector #sub-header .days span{flex:0 0 14%;position:relative}deja-date-time-selector #date-time-selector #date-selector #date-body{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;text-align:center}deja-date-time-selector #date-time-selector #date-selector #date-body:focus{outline:none}deja-date-time-selector #date-time-selector #date-selector #date-body .date{flex:0 0 14%;position:relative}deja-date-time-selector #date-time-selector #date-selector #date-body .date:before{content:\"\";float:left;padding-top:100%}deja-date-time-selector #date-time-selector #date-selector #date-body .date .day{align-items:center;border-radius:50%;display:flex;justify-content:center;inset:0;position:absolute;transition:all .45s cubic-bezier(.23,1,.32,1) 0ms}deja-date-time-selector #date-time-selector #date-selector #date-body .date .day.disabled:hover{cursor:not-allowed}deja-date-time-selector #date-time-selector #date-selector #date-body .date .day:hover,deja-date-time-selector #date-time-selector #date-selector #date-body .date .day[selected]{cursor:pointer}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.DejaTimePickerComponent, selector: "deja-time-picker", inputs: ["mode", "dataType", "forceNullValue", "appearance", "autoFocus", "defaultPlaceholderHours", "defaultPlaceholderMinutes", "time", "step", "disabled"], outputs: ["timeChange"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button],             button[mat-fab], button[mat-mini-fab], button[mat-stroked-button],             button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaDateSelectorComponent, decorators: [{
            type: Component,
            args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: 'deja-date-time-selector', template: "<div id=\"date-time-selector\" [ngClass]=\"layoutClass\" tabindex=\"-1\">\n    <div id=\"date-header\">\n        <div class=\"year\" *ngIf=\"layoutId < 3\">\n            <button mat-mini-fab type=\"button\" (click)=\"changeYear(-1)\" [disabled]=\"disabled\">\n                <mat-icon>keyboard_arrow_left</mat-icon>\n            </button>\n            <div>{{displayedDate.getFullYear()}}</div>\n            <button mat-mini-fab type=\"button\" (click)=\"changeYear(1)\" [disabled]=\"disabled\">\n                <mat-icon>keyboard_arrow_right</mat-icon>\n            </button>\n        </div>\n        <div current [innerHTML]=\"getSelectedDate() || '-'\">\n        </div>\n    </div>\n    <div id=\"date-selector\" *ngIf=\"layoutId < 3\">\n        <div id=\"sub-header\">\n            <div class=\"month\">\n                <div class=\"previous\">\n                    <button mat-mini-fab type=\"button\" (click)=\"changeMonth(-1)\" [disabled]=\"disabled\">\n                        <mat-icon>keyboard_arrow_left</mat-icon>\n                    </button>\n                </div>\n                <span>{{displayedDate.toLocaleString(local, { month: 'long' })}} {{displayedDate.getFullYear()}}</span>\n                <div class=\"next\">\n                    <button mat-mini-fab type=\"button\" (click)=\"changeMonth(1)\" [disabled]=\"disabled\">\n                        <mat-icon>keyboard_arrow_right</mat-icon>\n                    </button>\n                </div>\n            </div>\n            <div class=\"days\">\n                <span *ngFor=\"let day of days\">{{day}}</span>\n            </div>\n        </div>\n        <div id=\"date-body\" (keydown)=\"keyDown($event)\" tabindex=\"0\" [attr.keynav]=\"keyboardNavigation\">\n            <div class=\"date\" *ngFor=\"let dateSelectorItem of currentDays; let index=index\">\n                <div class=\"day\" [attr.dateindex]=\"index\" [class.background]=\"dateSelectorItem.background\" [class.disabled]=\"dateSelectorItem.disabled\" [attr.current]=\"dateSelectorItem.currentDate || null\" [attr.selected]=\"dateSelectorItem.selected || null\">\n                    {{dateSelectorItem.date.getDate()}}\n                </div>\n            </div>\n            <div class=\"date\" *ngFor=\"let emptyDay of emptyDays\"></div>\n        </div>\n    </div>\n    <div id=\"time-selector\" *ngIf=\"layoutId > 1\">\n        <deja-time-picker [ngModel]=\"(displayedDate) ? displayedDate : zeroHourDate\" (ngModelChange)=\"updateTime($event)\" [disabled]=\"disabled\"></deja-time-picker>\n    </div>\n</div>\n", styles: ["deja-date-time-selector #date-time-selector{display:flex;flex-direction:column;margin:0 auto;width:310px;outline:none}deja-date-time-selector #date-time-selector.timeonly{height:15rem}deja-date-time-selector #date-time-selector #date-header{display:flex;flex-direction:column;justify-content:center;align-items:center;font-size:2rem;height:94px;padding:0;position:relative}deja-date-time-selector #date-time-selector #date-header [current]{font-size:2rem}deja-date-time-selector #date-time-selector #date-header .year{align-items:center;display:flex;font-size:1rem;justify-content:center;width:50%}deja-date-time-selector #date-time-selector #date-header .year [fontIcon]{flex:0 0 auto;cursor:pointer}deja-date-time-selector #date-time-selector #date-header .year div{flex:1 1 auto;text-align:center}deja-date-time-selector #date-time-selector #time-selector{height:8rem;display:flex;align-items:center;justify-content:center}deja-date-time-selector #date-time-selector #date-selector{margin:0 auto;width:310px}deja-date-time-selector #date-time-selector #date-selector #sub-header .month{align-items:center;display:flex;justify-content:center;padding:1rem;text-align:center}deja-date-time-selector #date-time-selector #date-selector #sub-header .month span{flex:1 1 auto;font-size:1rem;text-transform:capitalize}deja-date-time-selector #date-time-selector #date-selector #sub-header .month button[mat-mini-fab]{flex:0 0 auto;box-shadow:none}deja-date-time-selector #date-time-selector #date-selector #sub-header .days{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin-bottom:.5rem;text-align:center}deja-date-time-selector #date-time-selector #date-selector #sub-header .days span{flex:0 0 14%;position:relative}deja-date-time-selector #date-time-selector #date-selector #date-body{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;text-align:center}deja-date-time-selector #date-time-selector #date-selector #date-body:focus{outline:none}deja-date-time-selector #date-time-selector #date-selector #date-body .date{flex:0 0 14%;position:relative}deja-date-time-selector #date-time-selector #date-selector #date-body .date:before{content:\"\";float:left;padding-top:100%}deja-date-time-selector #date-time-selector #date-selector #date-body .date .day{align-items:center;border-radius:50%;display:flex;justify-content:center;inset:0;position:absolute;transition:all .45s cubic-bezier(.23,1,.32,1) 0ms}deja-date-time-selector #date-time-selector #date-selector #date-body .date .day.disabled:hover{cursor:not-allowed}deja-date-time-selector #date-time-selector #date-selector #date-body .date .day:hover,deja-date-time-selector #date-time-selector #date-selector #date-body .date .day[selected]{cursor:pointer}\n"] }]
        }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.NgControl, decorators: [{
                    type: Self
                }, {
                    type: Optional
                }] }]; }, propDecorators: { startDay: [{
                type: Input
            }], disableDates: [{
                type: Input
            }], dateMax: [{
                type: Input
            }], dateMin: [{
                type: Input
            }], format: [{
                type: Input
            }], dateChange: [{
                type: Output
            }], timeChange: [{
                type: Output
            }], layout: [{
                type: Input
            }], time: [{
                type: Input
            }], disabled: [{
                type: Input
            }] } });

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */

/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
class DejaDateSelectorModule {
}
DejaDateSelectorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaDateSelectorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DejaDateSelectorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: DejaDateSelectorModule, declarations: [DejaDateSelectorComponent], imports: [CommonModule,
        DejaTimePickerModule,
        FormsModule,
        MatButtonModule,
        MatIconModule], exports: [DejaDateSelectorComponent] });
DejaDateSelectorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaDateSelectorModule, imports: [CommonModule,
        DejaTimePickerModule,
        FormsModule,
        MatButtonModule,
        MatIconModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DejaDateSelectorModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [DejaDateSelectorComponent],
                    exports: [DejaDateSelectorComponent],
                    imports: [
                        CommonModule,
                        DejaTimePickerModule,
                        FormsModule,
                        MatButtonModule,
                        MatIconModule
                    ]
                }]
        }] });

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

export { DateComponentLayout, DaysOfWeek, DejaDateSelectorComponent, DejaDateSelectorModule };
//# sourceMappingURL=deja-js-component-date-selector.mjs.map
