import * as i9 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Self, Optional, HostBinding, Output, Input, ViewChild, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import * as i8 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 i10 from '@angular/material/input';
import { MatInputModule } from '@angular/material/input';
import * as i12 from '@deja-js/component/core';
import { _MatInputMixinBase, DejaConnectionPositionPair, KeyCodes, formatWithLocale, DejaChildValidatorDirective, DejaChildValidatorModule } from '@deja-js/component/core';
import * as i7 from '@deja-js/component/date-selector';
import { DateComponentLayout, DejaDateSelectorComponent, DejaDateSelectorModule } from '@deja-js/component/date-selector';
import * as i6 from '@deja-js/component/overlay';
import { DejaOverlayModule } from '@deja-js/component/overlay';
import * as i11 from 'ngx-mask';
import { NgxMaskModule } from 'ngx-mask';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { MatFormFieldControl } from '@angular/material/form-field';
import { parse, startOfToday, isValid, add } from 'date-fns';
import { Subject, ReplaySubject, takeUntil, map, filter, delay, switchMap, fromEvent, mergeWith, combineLatestWith, tap, take, timer } from 'rxjs';
import * as i2 from '@angular/material/core';
import * as i3 from '@angular/cdk/a11y';
import * as i4 from '@angular/cdk/layout';

/*
 *  @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
 */
/**
 * List of possible format for the date-picker converted to their mask.
 *
 * Not fully implemented yet
 */
/* eslint-disable @typescript-eslint/naming-convention */
const formatToMask = {
    M: null,
    Mo: null,
    MM: 'F0',
    MMM: null,
    MMMM: null,
    Q: null,
    Qo: null,
    D: null,
    Do: null,
    DD: 'd0',
    DDD: null,
    DDDo: null,
    DDDD: null,
    d: null,
    do: null,
    dd: 'd0',
    ddd: null,
    dddd: null,
    e: null,
    E: null,
    w: null,
    wo: null,
    ww: null,
    W: null,
    Wo: null,
    WW: null,
    yy: '00',
    yyyy: 'B000',
    y: null,
    gg: null,
    gggg: null,
    GG: null,
    GGGG: null,
    A: null,
    a: null,
    H: null,
    HH: 'Hh',
    h: null,
    hh: 'Hh',
    k: null,
    kk: null,
    m: null,
    mm: 'm0',
    s: null,
    ss: 's0',
    S: null,
    SS: null,
    SSS: null,
    z: null,
    zz: null,
    Z: null,
    ZZ: null,
    X: null,
    x: null
};
const formatToPattern = {
    M: null,
    Mo: null,
    MM: new Map()
        .set('F', { pattern: new RegExp('[0|1]') })
        .set('0', { pattern: new RegExp('\\d') }),
    MMM: null,
    MMMM: null,
    Q: null,
    Qo: null,
    D: null,
    Do: null,
    DD: new Map()
        .set('d', { pattern: new RegExp('[0-3]') })
        .set('0', { pattern: new RegExp('\\d') }),
    DDD: null,
    DDDo: null,
    DDDD: null,
    d: null,
    do: null,
    dd: new Map()
        .set('d', { pattern: new RegExp('[0-3]') })
        .set('0', { pattern: new RegExp('\\d') }),
    ddd: null,
    dddd: null,
    e: null,
    E: null,
    w: null,
    wo: null,
    ww: null,
    W: null,
    Wo: null,
    WW: null,
    yy: new Map()
        .set('0', { pattern: new RegExp('\\d') })
        .set('0', { pattern: new RegExp('\\d') }),
    yyyy: new Map()
        .set('B', { pattern: new RegExp('[1|2]') })
        .set('0', { pattern: new RegExp('\\d') }),
    y: null,
    gg: null,
    gggg: null,
    GG: null,
    GGGG: null,
    A: null,
    a: null,
    H: null,
    HH: new Map()
        .set('h', { pattern: new RegExp('\\d') })
        .set('H', { pattern: new RegExp('[0-2]') }),
    h: null,
    hh: new Map()
        .set('h', { pattern: new RegExp('\\d') })
        .set('H', { pattern: new RegExp('[0-2]') }),
    k: null,
    kk: null,
    m: null,
    mm: new Map()
        .set('m', { pattern: new RegExp('[0-5]') })
        .set('0', { pattern: new RegExp('\\d') }),
    s: null,
    ss: new Map()
        .set('s', { pattern: new RegExp('[0-5]') })
        .set('0', { pattern: new RegExp('\\d') }),
    S: null,
    SS: null,
    SSS: null,
    z: null,
    zz: null,
    Z: null,
    ZZ: null,
    X: null,
    x: null
};
const formatToUnitOfTime = {
    M: null,
    Mo: null,
    MM: 'months',
    MMM: null,
    MMMM: null,
    Q: null,
    Qo: null,
    D: null,
    Do: null,
    DD: null,
    DDD: null,
    DDDo: null,
    DDDD: null,
    d: null,
    do: null,
    dd: 'days',
    ddd: null,
    dddd: null,
    e: null,
    E: null,
    w: null,
    wo: null,
    ww: null,
    W: null,
    Wo: null,
    WW: null,
    yy: 'years',
    yyyy: 'years',
    y: null,
    gg: null,
    gggg: null,
    GG: null,
    GGGG: null,
    A: null,
    a: null,
    H: null,
    HH: 'hours',
    h: null,
    hh: 'hours',
    k: null,
    kk: null,
    m: null,
    mm: 'minutes',
    s: null,
    ss: 'seconds',
    S: null,
    SS: null,
    SSS: null,
    z: null,
    zz: null,
    Z: null,
    ZZ: null,
    X: null,
    x: null
};

/**
 * Date-picker component for Angular
 */
class DejaDatePickerComponent extends _MatInputMixinBase {
    /**
     * Constructor
     * subscribe on different events needed inside this component
     */
    constructor(elementRef, changeDetectorRef, ngControl, _parentForm, _parentFormGroup, _defaultErrorStateMatcher, fm, breakpointObserver) {
        super(_defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl);
        this.elementRef = elementRef;
        this.changeDetectorRef = changeDetectorRef;
        this.ngControl = ngControl;
        this.fm = fm;
        this.breakpointObserver = breakpointObserver;
        this.id = `my-tel-input-${DejaDatePickerComponent.nextId++}`;
        this.describedBy = '';
        this.dateChange = new EventEmitter();
        this.timeChange = new EventEmitter();
        /** Offset de position horizontal de la zone de dropdown */
        this.overlayOffsetX = 0;
        /** Offset de position verticale de la zone de dropdown */
        this.overlayOffsetY = 6;
        /** matFormField implementation */
        // eslint-disable-next-line rxjs/finnish
        this.stateChanges = new Subject();
        /** Mask for input */
        this._mask = '';
        /** matFormField focus implementation */
        this.focused = false;
        /** This property indicates whether the associated NgControl is in an error state. */
        this.errorState = false;
        /** This property allows us to specify a unique string for the type of control in form field.
         * The <mat-form-field> will add an additional class based on this type that can be used to
         * easily apply special styles to a <mat-form-field> that contains a specific type of control.
         * In this example we'll use deja-date-picker as our control type which will result in the form field
         * adding the class mat-form-field-deja-date-picker.
         */
        this.controlType = 'deja-date-picker';
        this.formatChanged$ = new Subject();
        this.destroyed$ = new Subject();
        this._allowFreeEntry = false;
        this.inputElement$ = new ReplaySubject(1);
        this.focus$ = new Subject();
        this._showDropDown = false;
        this._positions = DejaConnectionPositionPair.default;
        this.dateChanged$ = new Subject();
        this.onChangeCallback = (_a) => undefined;
        this.onTouchedCallback = () => undefined;
        console.warn('@deja-js/component/date-picker is deprecated, and will be removed in a further version. Please use mat-datepicker instead. Look at the mat-datepicker demo page of @deja-js/component for implementation.');
        if (this.ngControl) {
            this.ngControl.valueAccessor = this;
        }
        this.overlayOwnerElement = this.elementRef.nativeElement;
        if (this._parentForm) {
            this._parentForm.ngSubmit.pipe(takeUntil(this.destroyed$)).subscribe(() => {
                this.changeDetectorRef.markForCheck();
            });
        }
        if (this._parentFormGroup) {
            this._parentFormGroup.ngSubmit.pipe(takeUntil(this.destroyed$)).subscribe(() => {
                this.changeDetectorRef.markForCheck();
            });
        }
        fm.monitor(this.elementRef.nativeElement, true).pipe(map(origin => {
            this.focused = !!origin;
            if (!this.focused) {
                this.onTouchedCallback();
            }
            else {
                return !this.value;
            }
            return false;
        }), filter(select => select), delay(1), takeUntil(this.destroyed$)).subscribe(() => this.inputElement.setSelectionRange(0, 0));
        const keydown$ = this.inputElement$.pipe(switchMap(element => fromEvent(element, 'keydown')));
        const cursorChanged$ = this.inputElement$.pipe(switchMap(element => fromEvent(element, 'mouseup').pipe(mergeWith(fromEvent(element, 'focus'), fromEvent(element, 'keyup')), map(() => element.selectionStart))));
        cursorChanged$.pipe(takeUntil(this.destroyed$)).subscribe(position => this.cursorPosition = position);
        keydown$.pipe(filter(event => !this.showDropDown && (event.code === KeyCodes.KeyD || event.code === KeyCodes.UpArrow || event.code === KeyCodes.DownArrow)), takeUntil(this.destroyed$)).subscribe(event => {
            switch (event.code) {
                case (KeyCodes.KeyD):
                    if (!this.allowFreeEntry) {
                        event.preventDefault();
                        this.setToCurrentDate();
                    }
                    break;
                case (KeyCodes.UpArrow):
                    event.preventDefault();
                    if (event.altKey) {
                        this.open();
                    }
                    else if (this.date) {
                        // If cursor is on number, we can update it
                        if (!isNaN(+this._inputModel[this.cursorPosition - 1])) {
                            const updatedValue = this.incrementDateBySegment(1);
                            this.updateModel(!this.dateMax || updatedValue <= this.dateMax ? updatedValue : this.value);
                        }
                    }
                    break;
                case (KeyCodes.DownArrow):
                    event.preventDefault();
                    if (event.altKey) {
                        this.open();
                    }
                    else if (this.date) {
                        // Same as arrowUp
                        if (!isNaN(+this._inputModel[this.cursorPosition - 1])) {
                            const updatedValue = this.incrementDateBySegment(-1);
                            this.updateModel(!this.dateMin || updatedValue >= this.dateMin ? updatedValue : this.value);
                        }
                    }
                    break;
                default:
                    break;
            }
        });
        const valueUpdated$ = this.formatChanged$.pipe(combineLatestWith(this.dateChanged$), tap(([dateFormat]) => {
            // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
            const array = dateFormat.match(DejaDatePickerComponent.formattingTokens);
            this._mask = array.map(val => formatToMask[val] || val).join('');
            this._pattern = array.reduce((patternBuilder, val) => {
                const patternSection = formatToPattern[val] || null;
                if (patternSection) {
                    patternSection.forEach((value, key) => {
                        patternBuilder[key] = value;
                    });
                }
                return patternBuilder;
            }, {});
        }));
        const inputElement$ = this.inputElement$.pipe(delay(1), take(1));
        valueUpdated$.pipe(tap(([dateFormat, value]) => {
            this.date = value;
            this._inputModel = (this.date && (this.date instanceof Date ? formatWithLocale(this.date, dateFormat) : this.date)) || null;
            this.changeDetectorRef.markForCheck();
        }), filter(() => this.cursorPosition && !this.allowFreeEntry), switchMap(() => inputElement$), takeUntil(this.destroyed$)).subscribe(elem => elem.setSelectionRange(this.cursorPosition, this.cursorPosition)); // si la position du curseur était stockée, on la restaure apres avoir changé la valeur
        keydown$.pipe(filter(() => this.showDropDown), takeUntil(this.destroyed$)).subscribe(event => {
            if (event.code === KeyCodes.Escape) {
                this.close();
            }
            else {
                this.dateSelectorComponent.keyDown(event);
            }
        });
        this.inputElement$.pipe(combineLatestWith(this.focus$), takeUntil(this.destroyed$)).subscribe(([element]) => element.focus());
    }
    get overlayContainerClass() {
        let oc = 'deja-datepicker-overlay-container';
        if (this.breakpointObserver.isMatched('(max-height: 900px)')) {
            oc += ' under-toolbar-position';
        }
        if (this.breakpointObserver.isMatched('(max-height: 550px)')) {
            oc += ' top-position';
        }
        return oc;
    }
    get shouldLabelFloat() {
        return this.focused || !this.empty || !!this.mask;
    }
    /** Date format. If unset, format will be 'yyyy-MM-dd' + ' HH:mm' it's a date-time selector */
    set format(dateFormat) {
        this._format = dateFormat;
        this.formatChanged$.next(dateFormat);
    }
    get format() {
        return this._format;
    }
    /** Placeholder for input */
    get placeholder() {
        return this._placeholder;
    }
    set placeholder(plh) {
        this._placeholder = plh;
        this.stateChanges.next();
    }
    /** Afficher un bouton raccourcis permettant de sélectionner la date courante */
    set showCurrentDateButton(value) {
        this._showCurrentDateButton = coerceBooleanProperty(value);
    }
    get showCurrentDateButton() {
        return this._showCurrentDateButton;
    }
    get ngModelOptions() {
        return {
            updateOn: this.updateInputOn || 'blur'
        };
    }
    /** Permettre la saisie de texte libre */
    set allowFreeEntry(value) {
        this._allowFreeEntry = coerceBooleanProperty(value) || null;
    }
    get allowFreeEntry() {
        return this._allowFreeEntry;
    }
    get mask() {
        return this._mask;
    }
    get pattern() {
        return this._pattern;
    }
    set inputElementRef(element) {
        if (element) {
            this.inputElement = element.nativeElement;
            this.overlayOwnerElement = this.inputElement || this.elementRef.nativeElement;
            this.inputElement$.next(this.inputElement);
        }
        else {
            this.overlayOwnerElement = this.elementRef.nativeElement;
        }
    }
    get inputModel() {
        return this._inputModel;
    }
    set positions(value) {
        this._positions = typeof value === 'string' ? DejaConnectionPositionPair.parse(value) : value;
    }
    get positions() {
        return this._positions;
    }
    get empty() {
        return !this.value;
    }
    /** unsubscribe to all Observable when component is destroyed */
    ngOnDestroy() {
        this.fm.stopMonitoring(this.elementRef.nativeElement);
        this.destroyed$.next();
        this.destroyed$.unsubscribe();
        this.stateChanges.complete();
    }
    /** Init mask */
    ngOnInit() {
        if (!this._format) {
            if (!this.layout || this.layout === DateComponentLayout.dateonly || this.layout === 'dateonly') {
                this.format = 'yyyy/MM/dd';
            }
            else if (this.layout === DateComponentLayout.datetime || this.layout === 'datetime') {
                this.format = 'yyyy/MM/dd HH:mm';
            }
            else if (this.layout === DateComponentLayout.timeonly || this.layout === 'timeonly') {
                this.format = 'HH:mm';
            }
            else {
                this.format = 'yyyy/MM/dd';
            }
        }
    }
    ngDoCheck() {
        if (this.ngControl) {
            // We need to re-evaluate this on every change detection cycle, because there are some
            // error triggers that we can't subscribe to (e.g. parent form submissions). This means
            // that whatever logic is in here has to be super lean or we risk destroying the performance.
            this.updateErrorState();
        }
    }
    /** This method is used by the <mat-form-field> to specify the IDs that should be used for the aria-describedby attribute of your component.
     * The method has one parameter, the list of IDs, we just need to apply the given IDs to our host element.
     */
    setDescribedByIds(ids) {
        this.describedBy = ids.join(' ');
    }
    /** This method will be called when the form field is clicked on.
     * It allows your component to hook in and handle that click however it wants.
     * The method has one parameter, the MouseEvent for the click.
     * In our case we'll just focus the first <input> if the user isn't about to click an <input> anyways.
     */
    onContainerClick(event) {
        if (event.target.tagName.toLowerCase() !== 'input') {
            this.elementRef.nativeElement.querySelector('input').focus();
        }
    }
    get showDropDown() {
        return this._showDropDown;
    }
    /** disabled property setter. Can be string or empty so you can use it like : <deja-date-picker disabled></deja-date-picker> */
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value) ? true : null;
        this.stateChanges.next();
        this.changeDetectorRef.markForCheck();
    }
    /** disabled property getter. */
    get disabled() {
        return this._disabled;
    }
    /** required property setter. Can be string or empty so you can use it like : <deja-date-picker required></deja-date-picker> */
    set required(value) {
        this._required = coerceBooleanProperty(value) || null;
        this.stateChanges.next();
    }
    /** required property getter. */
    get required() {
        return this._required;
    }
    /**
     * Component Layout
     */
    set layout(value) {
        if (value) {
            this._layout = value;
        }
        this.changeDetectorRef.markForCheck();
    }
    get layout() {
        return this._layout;
    }
    /**
     * Time property setter. Can be string or empty so you can use it like : <deja-date-picker time></deja-date-picker>
     * 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;
    }
    /** Method to close date-picker dialog */
    close() {
        this._showDropDown = false;
        this.changeDetectorRef.markForCheck();
        return false;
    }
    /** Method to open date-picker dialog */
    open() {
        this._showDropDown = true;
        this.changeDetectorRef.markForCheck();
    }
    /** set accessor including call the onchange callback */
    set value(v) {
        if (v !== this.date) {
            this.writeValue(v);
            this.onChangeCallback(v);
            this.stateChanges.next();
        }
    }
    // ************* ControlValueAccessor Implementation **************
    /** get accessor */
    get value() {
        return this.date;
    }
    /** From ControlValueAccessor interface */
    writeValue(value) {
        if (value !== this.date) {
            this.dateChanged$.next(value);
        }
    }
    /** 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 **************
    /** For reactive form. */
    ngAfterContentInit() {
        if (this.inputValidatorDirective) {
            this.inputValidatorDirective.parentControl = this.ngControl;
        }
    }
    /** Give focus to this component */
    setFocus() {
        this.focus$.next();
    }
    /**
     * Called when user click on the input of this component.
     * If click is located on icon 'calendar' who is in the matPrefix of mat-form-field-container, the picker show off.
     *
     * @param event
     */
    toggleDateSelector(event) {
        if (this.disabled) {
            return undefined;
        }
        const target = event.currentTarget;
        if (target.id !== 'calendar-button') {
            return undefined;
        }
        this.open();
        return false;
    }
    /**
     * Called when input change. If it's a string it's because user set the date manually. So we need to convert it into date with MomentJs.
     *
     * @param date new value of this model
     */
    updateModel(date) {
        if (typeof date === 'string' && !this.allowFreeEntry) { // && date.replace(/_/g, '').length === this._format.length) {
            if (date.replace(/_/g, '').length === this._format.length) { // If mask is fully filled
                const mDate = parse(date, this._format, startOfToday());
                if (mDate && isValid(mDate)) {
                    date = mDate || null;
                }
                else {
                    console.warn('[DatePicker]: Invalid Date');
                    this.ngControl.control.setErrors({ invalidMask: true });
                    this.changeDetectorRef.markForCheck();
                }
                // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
            }
            else if (!date.match(/[0-9]/)) { // if mask is empty - do nothing
                return;
            }
            else { // If mask is partially filled
                date = null;
                console.warn('[DatePicker]: Invalid Date');
                this.ngControl.control.setErrors({ invalidMask: true });
                this.changeDetectorRef.markForCheck();
            }
        }
        if (date instanceof Date) {
            if (this.value instanceof Date && this.value && this.value.getTime() === date.getTime()) {
                return;
            }
            let event;
            // now we check if it's date or time who is updated to raise correct event
            if (this.value instanceof Date && this.value && (date.getFullYear() !== this.value.getFullYear() || date.getMonth() !== this.value.getMonth() || date.getDate() !== this.value.getDate())) {
                event = this.dateChange;
            }
            else if (this.value instanceof Date && this.value && (date.getHours() !== this.value.getHours() || date.getMinutes() !== this.value.getMinutes() || date.getSeconds() !== this.value.getSeconds() || date.getMilliseconds() !== this.value.getMilliseconds())) {
                event = this.timeChange;
            }
            else {
                event = this.dateChange;
            }
            this.value = date;
            this.onTouchedCallback();
            event.emit(date);
            if (!this._layout || this._layout === DateComponentLayout.dateonly) {
                this.close();
            }
            else {
                this.changeDetectorRef.markForCheck();
            }
        }
        else if (this.allowFreeEntry) {
            this.value = date;
            this.onTouchedCallback();
            this.dateChange.emit(date);
            this.changeDetectorRef.markForCheck();
        }
    }
    /** Reset date-picker values. */
    reset() {
        // To prevent "ExpressionChangedAfterItHasBeenCheckedError"
        timer(0).pipe(takeUntil(this.destroyed$)).subscribe(() => {
            this.value = null;
            delete this._inputModel;
        });
        this.close();
    }
    setToCurrentDate() {
        this.value = new Date();
        this.selectHours();
    }
    selectHours() {
        if (this.layout === DateComponentLayout.datetime) {
            timer(0).pipe(takeUntil(this.destroyed$)).subscribe(() => {
                const hoursTemplate = formatWithLocale(this.toDate(this.date), 'HH:mm');
                const stringDate = this.inputElement.value;
                const hoursPosition = stringDate.indexOf(hoursTemplate);
                this.inputElement.setSelectionRange(hoursPosition, stringDate.length);
            });
        }
    }
    incrementDateBySegment(increment) {
        // We get an array of all sections of the date format
        // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
        const dateFormat = this._format.match(DejaDatePickerComponent.formattingTokens);
        // We check the letter of the format at cursor position
        const f = this._format[this.cursorPosition - 1];
        // With this letter we determinate the format by checking on format array
        let unitOfTime = dateFormat.find(str => str.includes(f));
        // If this format has a corresponding value inside formatToUnitOfTime object we can increment its value with moment.add() method
        unitOfTime = (unitOfTime && formatToUnitOfTime[unitOfTime]) || undefined;
        if (unitOfTime) {
            const duration = {
                [unitOfTime]: increment
            };
            const updatedValue = add(this.toDate(this.value), duration);
            return updatedValue;
        }
        return this.value;
    }
    toDate(value) {
        return typeof value === 'string' ? parse(value, this.format, startOfToday()) : value;
    }
}
// eslint-disable-next-line @typescript-eslint/naming-convention
DejaDatePickerComponent.nextId = 0;
// eslint-disable-next-line @typescript-eslint/naming-convention
DejaDatePickerComponent.formattingTokens = new RegExp('(\\[[^\\[]*\\])|(\\\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|yyyyyy|yyyyy|yyyy|yy|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)', 'g');
DejaDatePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaDatePickerComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.NgControl, optional: true, self: true }, { token: i1.NgForm, optional: true }, { token: i1.FormGroupDirective, optional: true }, { token: i2.ErrorStateMatcher }, { token: i3.FocusMonitor }, { token: i4.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component });
DejaDatePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: DejaDatePickerComponent, selector: "deja-date-picker", inputs: { dateMax: "dateMax", dateMin: "dateMin", label: "label", disableDates: "disableDates", overlayOffsetX: "overlayOffsetX", overlayOffsetY: "overlayOffsetY", updateInputOn: "updateInputOn", format: "format", placeholder: "placeholder", showCurrentDateButton: "showCurrentDateButton", allowFreeEntry: "allowFreeEntry", positions: "positions", disabled: "disabled", required: "required", layout: "layout", time: "time" }, outputs: { dateChange: "dateChange", timeChange: "timeChange" }, host: { properties: { "id": "this.id", "attr.aria-describedby": "this.describedBy", "class.floating": "this.shouldLabelFloat" } }, providers: [{ provide: MatFormFieldControl, useExisting: DejaDatePickerComponent }], viewQueries: [{ propertyName: "dateSelectorComponent", first: true, predicate: DejaDateSelectorComponent, descendants: true, static: true }, { propertyName: "inputValidatorDirective", first: true, predicate: DejaChildValidatorDirective, descendants: true }, { propertyName: "inputElementRef", first: true, predicate: ["inputelement"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<input *ngIf=\"!allowFreeEntry\"\n    deja-child-validator\n    #inputelement\n    date-selector-input\n    matInput\n    autocomplete=\"off\"\n    [disabled]=\"disabled\"\n    [required]=\"required\"\n    [ngModel]=\"inputModel\"\n    [placeholder]=\"placeholder\"\n    [mask]=\"mask\"\n    [showMaskTyped]=\"true\"\n    [patterns]=\"pattern\"\n    [dropSpecialCharacters]=\"false\"\n    (ngModelChange)=\"updateModel($event)\"\n    [ngModelOptions]=\"ngModelOptions\"\n    />\n<input *ngIf=\"allowFreeEntry\" class=\"free-txt\" deja-child-validator #inputelement date-selector-input matInput autocomplete=\"off\" [disabled]=\"disabled\" [required]=\"required\" [ngModel]=\"inputModel\" [placeholder]=\"placeholder\" (ngModelChange)=\"updateModel($event)\" [ngModelOptions]=\"ngModelOptions\">\n<div class=\"datepicker-actions\">\n    <button type=\"button\" *ngIf=\"inputModel && !disabled\" (click)=\"reset()\" id=\"clear-button\" tabindex=\"-1\">\n\t\t<mat-icon inline>clear</mat-icon>\n\t</button>\n    <button type=\"button\" *ngIf=\"showCurrentDateButton && !disabled\" (click)=\"setToCurrentDate()\" id=\"current-date-button\" tabindex=\"-1\" [disabled]=\"disabled\">\n\t\t<mat-icon inline>today</mat-icon>\n\t</button>\n    <button type=\"button\" *ngIf=\"!disabled\" (click)=\"toggleDateSelector($event)\" id=\"calendar-button\" tabindex=\"-1\">\n\t\t<mat-icon inline>date_range</mat-icon>\n\t</button>\n</div>\n\n<deja-overlay #dejaOverlay [overlayContainerClass]=\"overlayContainerClass\" [ownerElement]=\"overlayOwnerElement\" [isVisible]=\"showDropDown\" (closed)=\"close()\" [positions]=\"positions\" [overlayOffsetY]=\"overlayOffsetY\" [overlayOffsetX]=\"overlayOffsetX\">\n    <deja-date-time-selector [layout]=\"layout\" [disableDates]=\"disableDates\" [ngModel]=\"date\" (ngModelChange)=\"updateModel($event);\" class=\"inside-dropdown\" [dateMax]=\"dateMax\" [dateMin]=\"dateMin\" [layout]=\"layout\" [format]=\"format\"></deja-date-time-selector>\n    <div class=\"actions\">\n        <button mat-mini-fab type=\"button\" (click)=\"close()\">\n\t\t\t<mat-icon>close</mat-icon>\n\t\t</button>\n    </div>\n</deja-overlay>\n", styles: ["deja-date-picker{position:relative}deja-date-picker .datepicker-actions{position:absolute;right:0;top:50%;transform:translateY(-50%);z-index:2}deja-date-picker .datepicker-actions button{background:none;border:none;margin-left:.2rem;padding:0;outline:none;color:inherit;cursor:pointer;opacity:.4}deja-date-picker .datepicker-actions button:hover{opacity:.8}deja-date-picker .datepicker-actions button [fontIcon]{font-size:100%;width:1em;height:1em}.deja-datepicker-overlay-container{overflow:visible}.deja-datepicker-overlay-container.under-toolbar-position .cdk-overlay-pane{top:100px!important}.deja-datepicker-overlay-container.under-toolbar-position.top-position .cdk-overlay-pane{top:5px!important}.deja-datepicker-overlay-container .actions{position:absolute;right:.3rem;top:.3rem;height:40px}.deja-datepicker-overlay-container .actions button.mat-mini-fab{background:none;border:none;box-shadow:none}\n"], components: [{ type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i6.DejaOverlayComponent, selector: "deja-overlay", inputs: ["overlayBackdropClass", "overlayContainerClass", "overlayOffsetX", "overlayOffsetY", "isVisible", "hasBackdrop", "ownerElement", "positions", "positionsForMobile", "isMobile", "width", "widthForMobile"], outputs: ["visibleChange", "closed"] }, { type: i7.DejaDateSelectorComponent, selector: "deja-date-time-selector", inputs: ["startDay", "disableDates", "dateMax", "dateMin", "format", "layout", "time", "disabled"], outputs: ["dateChange", "timeChange"] }, { type: i8.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"] }], directives: [{ type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i11.MaskDirective, selector: "input[mask], textarea[mask]", inputs: ["mask", "specialCharacters", "patterns", "prefix", "suffix", "thousandSeparator", "decimalMarker", "dropSpecialCharacters", "hiddenInput", "showMaskTyped", "placeHolderCharacter", "shownMaskExpression", "showTemplate", "clearIfNotMatch", "validation", "separatorLimit", "allowNegativeNumbers", "leadZeroDateTime"] }, { type: i12.DejaChildValidatorDirective, selector: "[deja-child-validator]" }, { type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaDatePickerComponent, decorators: [{
            type: Component,
            args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: MatFormFieldControl, useExisting: DejaDatePickerComponent }], selector: 'deja-date-picker', template: "<input *ngIf=\"!allowFreeEntry\"\n    deja-child-validator\n    #inputelement\n    date-selector-input\n    matInput\n    autocomplete=\"off\"\n    [disabled]=\"disabled\"\n    [required]=\"required\"\n    [ngModel]=\"inputModel\"\n    [placeholder]=\"placeholder\"\n    [mask]=\"mask\"\n    [showMaskTyped]=\"true\"\n    [patterns]=\"pattern\"\n    [dropSpecialCharacters]=\"false\"\n    (ngModelChange)=\"updateModel($event)\"\n    [ngModelOptions]=\"ngModelOptions\"\n    />\n<input *ngIf=\"allowFreeEntry\" class=\"free-txt\" deja-child-validator #inputelement date-selector-input matInput autocomplete=\"off\" [disabled]=\"disabled\" [required]=\"required\" [ngModel]=\"inputModel\" [placeholder]=\"placeholder\" (ngModelChange)=\"updateModel($event)\" [ngModelOptions]=\"ngModelOptions\">\n<div class=\"datepicker-actions\">\n    <button type=\"button\" *ngIf=\"inputModel && !disabled\" (click)=\"reset()\" id=\"clear-button\" tabindex=\"-1\">\n\t\t<mat-icon inline>clear</mat-icon>\n\t</button>\n    <button type=\"button\" *ngIf=\"showCurrentDateButton && !disabled\" (click)=\"setToCurrentDate()\" id=\"current-date-button\" tabindex=\"-1\" [disabled]=\"disabled\">\n\t\t<mat-icon inline>today</mat-icon>\n\t</button>\n    <button type=\"button\" *ngIf=\"!disabled\" (click)=\"toggleDateSelector($event)\" id=\"calendar-button\" tabindex=\"-1\">\n\t\t<mat-icon inline>date_range</mat-icon>\n\t</button>\n</div>\n\n<deja-overlay #dejaOverlay [overlayContainerClass]=\"overlayContainerClass\" [ownerElement]=\"overlayOwnerElement\" [isVisible]=\"showDropDown\" (closed)=\"close()\" [positions]=\"positions\" [overlayOffsetY]=\"overlayOffsetY\" [overlayOffsetX]=\"overlayOffsetX\">\n    <deja-date-time-selector [layout]=\"layout\" [disableDates]=\"disableDates\" [ngModel]=\"date\" (ngModelChange)=\"updateModel($event);\" class=\"inside-dropdown\" [dateMax]=\"dateMax\" [dateMin]=\"dateMin\" [layout]=\"layout\" [format]=\"format\"></deja-date-time-selector>\n    <div class=\"actions\">\n        <button mat-mini-fab type=\"button\" (click)=\"close()\">\n\t\t\t<mat-icon>close</mat-icon>\n\t\t</button>\n    </div>\n</deja-overlay>\n", styles: ["deja-date-picker{position:relative}deja-date-picker .datepicker-actions{position:absolute;right:0;top:50%;transform:translateY(-50%);z-index:2}deja-date-picker .datepicker-actions button{background:none;border:none;margin-left:.2rem;padding:0;outline:none;color:inherit;cursor:pointer;opacity:.4}deja-date-picker .datepicker-actions button:hover{opacity:.8}deja-date-picker .datepicker-actions button [fontIcon]{font-size:100%;width:1em;height:1em}.deja-datepicker-overlay-container{overflow:visible}.deja-datepicker-overlay-container.under-toolbar-position .cdk-overlay-pane{top:100px!important}.deja-datepicker-overlay-container.under-toolbar-position.top-position .cdk-overlay-pane{top:5px!important}.deja-datepicker-overlay-container .actions{position:absolute;right:.3rem;top:.3rem;height:40px}.deja-datepicker-overlay-container .actions button.mat-mini-fab{background:none;border:none;box-shadow:none}\n"] }]
        }], ctorParameters: function () {
        return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.NgControl, decorators: [{
                        type: Self
                    }, {
                        type: Optional
                    }] }, { type: i1.NgForm, decorators: [{
                        type: Optional
                    }] }, { type: i1.FormGroupDirective, decorators: [{
                        type: Optional
                    }] }, { type: i2.ErrorStateMatcher }, { type: i3.FocusMonitor }, { type: i4.BreakpointObserver }];
    }, propDecorators: { id: [{
                type: HostBinding
            }], describedBy: [{
                type: HostBinding,
                args: ['attr.aria-describedby']
            }], dateChange: [{
                type: Output
            }], timeChange: [{
                type: Output
            }], dateMax: [{
                type: Input
            }], dateMin: [{
                type: Input
            }], label: [{
                type: Input
            }], disableDates: [{
                type: Input
            }], dateSelectorComponent: [{
                type: ViewChild,
                args: [DejaDateSelectorComponent, { static: true }]
            }], overlayOffsetX: [{
                type: Input
            }], overlayOffsetY: [{
                type: Input
            }], updateInputOn: [{
                type: Input
            }], inputValidatorDirective: [{
                type: ViewChild,
                args: [DejaChildValidatorDirective]
            }], shouldLabelFloat: [{
                type: HostBinding,
                args: ['class.floating']
            }], format: [{
                type: Input
            }], placeholder: [{
                type: Input
            }], showCurrentDateButton: [{
                type: Input
            }], allowFreeEntry: [{
                type: Input
            }], inputElementRef: [{
                type: ViewChild,
                args: ['inputelement']
            }], positions: [{
                type: Input
            }], disabled: [{
                type: Input
            }], required: [{
                type: Input
            }], layout: [{
                type: Input
            }], time: [{
                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
 */
class DejaDatePickerModule {
}
DejaDatePickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaDatePickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
DejaDatePickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaDatePickerModule, declarations: [DejaDatePickerComponent], imports: [CommonModule,
        DejaChildValidatorModule,
        DejaDateSelectorModule,
        DejaOverlayModule,
        FormsModule,
        MatButtonModule,
        MatIconModule,
        MatInputModule, i11.NgxMaskModule], exports: [DejaDatePickerComponent] });
DejaDatePickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaDatePickerModule, imports: [[
            CommonModule,
            DejaChildValidatorModule,
            DejaDateSelectorModule,
            DejaOverlayModule,
            FormsModule,
            MatButtonModule,
            MatIconModule,
            MatInputModule,
            NgxMaskModule.forRoot()
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: DejaDatePickerModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [DejaDatePickerComponent],
                    exports: [DejaDatePickerComponent],
                    imports: [
                        CommonModule,
                        DejaChildValidatorModule,
                        DejaDateSelectorModule,
                        DejaOverlayModule,
                        FormsModule,
                        MatButtonModule,
                        MatIconModule,
                        MatInputModule,
                        NgxMaskModule.forRoot()
                    ]
                }]
        }] });

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

export { DejaDatePickerComponent, DejaDatePickerModule, formatToMask, formatToPattern, formatToUnitOfTime };
//# sourceMappingURL=deja-js-component-date-picker.mjs.map
