import { Host, h } from "@stencil/core";
import datepicker from "js-datepicker";
export class SpwDatePicker {
    constructor() {
        /** Placeholder du champ de saisie */
        this.placeholder = 'JJ/MM/AAAA';
        /** Indique si le champ est requis */
        this.required = false;
        /** Indique si le champ est désactivé */
        this.disabled = false;
        /** Format de date à afficher */
        this.dateFormat = 'dd/MM/yyyy';
        /** Jours de la semaine désactivés (0=dimanche, 1=lundi, etc.) */
        this.disabledDays = [];
        /** Dates spécifiques désactivées (format ISO, ex: ["2026-01-01", "2026-12-25"]) */
        this.disabledDates = [];
        /** Position du datepicker */
        this.position = 'bl';
        /** Message d'erreur à afficher sous le champ */
        this.error = '';
        /** Message d'indication (hint) à afficher sous le champ */
        this.hint = '';
        /** Message de succès à afficher sous le champ */
        this.success = '';
        /** Message de warning à afficher sous le champ */
        this.warning = '';
        /** Affiche une icône d'erreur si vrai */
        this.showErrorIcon = true;
        /** Affiche une icône d'indication si vrai */
        this.showHintIcon = true;
        /** Affiche une icône de succès si vrai */
        this.showSuccessIcon = true;
        /** Affiche une icône de warning si vrai */
        this.showWarningIcon = true;
        /** Indique si le champ peut être effacé avec un bouton */
        this.isClear = false;
        /** Positionnement du tooltip */
        this.tooltipDirection = 'top';
        /** Curseur du tooltip */
        this.tooltipCursor = 'help';
        /** Si vrai, permet de définir un range de dates */
        this.range = false;
        /** Permet de définir l'input de début pour un range */
        this.isStart = false;
        /** Utilise un positionnement fixed pour le calendrier si nécessité de sortir du contexte (utile dans une modal avec overflow hidden) */
        this.fixedCalendar = false;
        this.isOpen = false;
        this.hasError = false;
        this.internalValue = '';
        this.isClearIconVisible = false;
        this.lastInputValue = '';
        this.isDeleting = false;
        this.parentScrollContainer = null;
        this.updateCalendarPosition = () => {
            var _a;
            if (!this.fixedCalendar || !((_a = this.datepickerInstance) === null || _a === void 0 ? void 0 : _a.calendarContainer) || !this.inputElement)
                return;
            const inputRect = this.inputElement.getBoundingClientRect();
            const calendarEl = this.datepickerInstance.calendarContainer;
            const calendarHeight = calendarEl.offsetHeight || 320;
            const viewportHeight = window.innerHeight;
            // Déterminer si on ouvre vers le haut ou le bas
            const spaceBelow = viewportHeight - inputRect.bottom;
            const spaceAbove = inputRect.top;
            const openAbove = spaceBelow < calendarHeight && spaceAbove > spaceBelow;
            let top;
            if (openAbove) {
                top = inputRect.top - calendarHeight - 6;
            }
            else {
                top = inputRect.bottom + 6;
            }
            // Positionner horizontalement selon la prop position
            let left;
            if (this.position === 'tr' || this.position === 'br') {
                left = inputRect.right - calendarEl.offsetWidth;
            }
            else {
                left = inputRect.left;
            }
            calendarEl.style.position = 'fixed';
            calendarEl.style.top = `${top}px`;
            calendarEl.style.left = `${left}px`;
            calendarEl.style.zIndex = '9999';
        };
        this.handleMaskedInput = (event) => {
            const target = event.target;
            const newValue = target.value;
            const cursorPosition = target.selectionStart || 0;
            this.isDeleting = newValue.length < this.lastInputValue.length;
            if (this.isDeleting) {
                this.internalValue = newValue;
                target.value = newValue;
                this.lastInputValue = newValue;
                setTimeout(() => {
                    if (this.inputElement) {
                        this.inputElement.setSelectionRange(cursorPosition, cursorPosition);
                    }
                }, 0);
            }
            else {
                const oldDigitCount = this.unmask(this.lastInputValue).length;
                const maskedValue = this.applyMaskSmart(newValue);
                const newDigitCount = this.unmask(maskedValue).length;
                this.internalValue = maskedValue;
                target.value = maskedValue;
                this.lastInputValue = maskedValue;
                setTimeout(() => {
                    if (this.inputElement) {
                        let newCursorPos = cursorPosition;
                        if (newDigitCount > oldDigitCount) {
                            if ((newDigitCount === 3 && oldDigitCount === 2) || (newDigitCount === 5 && oldDigitCount === 4)) {
                                newCursorPos = cursorPosition + 1;
                            }
                        }
                        newCursorPos = Math.min(newCursorPos, maskedValue.length);
                        this.inputElement.setSelectionRange(newCursorPos, newCursorPos);
                    }
                }, 0);
            }
            const digits = this.unmask(this.internalValue);
            if (digits.length === 8) {
                const parsedDate = this.parseDate(this.internalValue);
                if (parsedDate && !isNaN(parsedDate.getTime())) {
                    const isoString = this.toISODateString(parsedDate);
                    this.value = isoString;
                    this.internals.setFormValue(isoString);
                    this.isClearIconVisible = this.isClear && !!isoString;
                    const dateWithTime = new Date(isoString);
                    this.dateChange.emit({ value: isoString, date: dateWithTime });
                    if (this.datepickerInstance) {
                        this.datepickerInstance.setDate(parsedDate, true);
                    }
                }
            }
            else if (!this.internalValue) {
                this.value = '';
                this.internals.setFormValue(null);
                this.isClearIconVisible = false;
                this.dateChange.emit({ value: '', date: null });
                if (this.datepickerInstance) {
                    this.datepickerInstance.setDate(undefined, true);
                }
            }
        };
        this.handleInputChange = (event) => {
            this.handleMaskedInput(event);
        };
        this.handleInputFocus = () => {
            if (this.disabled)
                return;
            if (!this.datepickerInstance) {
                this.initializeDatepicker();
            }
            if (this.datepickerInstance && typeof this.datepickerInstance.show === 'function') {
                try {
                    this.datepickerInstance.show();
                }
                catch (error) {
                    console.warn("Erreur lors de l'ouverture du datepicker, réinitialisation...", error);
                    this.datepickerInstance = null;
                    this.initializeDatepicker();
                    if (this.datepickerInstance && typeof this.datepickerInstance.show === 'function') {
                        this.datepickerInstance.show();
                    }
                }
            }
        };
        this.handleClear = () => {
            this.resetInput();
        };
        this.handleCalendarIconClick = (ev) => {
            var _a, _b;
            ev.stopPropagation();
            if (this.disabled)
                return;
            if (this.isOpen) {
                (_a = this.datepickerInstance) === null || _a === void 0 ? void 0 : _a.hide();
            }
            else {
                if (!this.datepickerInstance) {
                    this.initializeDatepicker();
                }
                (_b = this.datepickerInstance) === null || _b === void 0 ? void 0 : _b.show();
            }
        };
        this.handleCalendarIconMouseDown = (ev) => {
            ev.preventDefault();
        };
        this.handleKeyDown = (ev) => {
            const target = ev.target;
            const isInputFocused = target === this.inputElement;
            const isCalendarFocused = target.closest('.qs-datepicker') !== null;
            if (isInputFocused) {
                switch (ev.key) {
                    case 'Tab':
                        if (!ev.shiftKey && this.isOpen) {
                            ev.preventDefault();
                            ev.stopPropagation();
                            setTimeout(() => {
                                var _a;
                                const calendarEl = (_a = this.datepickerInstance) === null || _a === void 0 ? void 0 : _a.calendarContainer;
                                if (calendarEl) {
                                    const focusableEls = [
                                        ...Array.from(calendarEl.querySelectorAll('.qs-arrow')),
                                        calendarEl.querySelector('.qs-month-year'),
                                        ...Array.from(calendarEl.querySelectorAll('.qs-square:not(.qs-day):not(.qs-empty)')),
                                    ].filter(Boolean);
                                    if (focusableEls[0]) {
                                        focusableEls[0].focus();
                                    }
                                }
                            }, 0);
                        }
                        break;
                    case 'Enter':
                        if (this.isOpen) {
                            ev.preventDefault();
                            this.datepickerInstance.hide();
                            this.inputElement.blur();
                        }
                        break;
                    case 'Escape':
                        if (this.isOpen) {
                            ev.preventDefault();
                            this.datepickerInstance.hide();
                            this.inputElement.focus();
                        }
                        break;
                }
            }
            else if (isCalendarFocused) {
                switch (ev.key) {
                    case 'Escape':
                        ev.preventDefault();
                        this.datepickerInstance.hide();
                        this.inputElement.focus();
                        break;
                    case 'Tab':
                        if (ev.shiftKey) {
                            ev.preventDefault();
                            this.inputElement.focus();
                        }
                        break;
                }
            }
        };
    }
    componentWillLoad() {
        this.uniqueId = `spw-date-picker-${Math.random().toString(36).substr(2, 9)}`;
        if (typeof this.disabledDays === 'string') {
            try {
                const parsed = JSON.parse(this.disabledDays);
                if (Array.isArray(parsed) && parsed.every(val => typeof val === 'number')) {
                    this.disabledDays = parsed;
                }
                else {
                    this.disabledDays = [];
                }
            }
            catch (_a) {
                this.disabledDays = [];
            }
        }
        if (typeof this.disabledDates === 'string') {
            try {
                const parsed = JSON.parse(this.disabledDates);
                if (Array.isArray(parsed) && parsed.every(val => typeof val === 'string')) {
                    this.disabledDates = parsed;
                }
                else {
                    this.disabledDates = [];
                }
            }
            catch (_b) {
                this.disabledDates = [];
            }
        }
        const start = this.value ? this.formatDate(new Date(this.value)) : '';
        this.internalValue = start;
        this.lastInputValue = this.internalValue;
        this.defaultValue = this.value;
        this.isClearIconVisible = this.isClear && !!this.value;
    }
    componentDidLoad() {
        var _a;
        this.initializeDatepicker();
        if (this.value) {
            const initialDate = new Date(this.value);
            if (!isNaN(initialDate.getTime())) {
                (_a = this.datepickerInstance) === null || _a === void 0 ? void 0 : _a.setDate(initialDate, true);
                if (this.inputElement) {
                    this.inputElement.value = this.formatDate(initialDate);
                    this.internalValue = this.formatDate(initialDate);
                }
            }
        }
        this.internals.setFormValue(this.value ? this.value : null);
    }
    connectedCallback() {
        if (!this.datepickerInstance && this.inputElement) {
            requestAnimationFrame(() => {
                this.initializeDatepicker();
            });
        }
        if (this.fixedCalendar) {
            window.addEventListener('scroll', this.updateCalendarPosition, true);
            window.addEventListener('resize', this.updateCalendarPosition);
        }
    }
    disconnectedCallback() {
        if (this.datepickerInstance && typeof this.datepickerInstance.remove === 'function') {
            setTimeout(() => {
                if (!this.el.isConnected && this.datepickerInstance) {
                    this.datepickerInstance.remove();
                    this.datepickerInstance = null;
                }
            }, 100);
        }
        if (this.fixedCalendar) {
            window.removeEventListener('scroll', this.updateCalendarPosition, true);
            window.removeEventListener('resize', this.updateCalendarPosition);
            this.cleanupParentScrollListener();
        }
    }
    findParentComponent() {
        if (!this.fixedCalendarParent)
            return null;
        let current = this.el;
        while (current) {
            if (current instanceof HTMLElement && current.tagName.toLowerCase() === this.fixedCalendarParent.toLowerCase()) {
                return current;
            }
            if (current.parentElement) {
                current = current.parentElement;
            }
            else {
                const rootNode = current.getRootNode();
                if (rootNode instanceof ShadowRoot) {
                    current = rootNode.host;
                }
                else {
                    break;
                }
            }
        }
        return null;
    }
    findScrollContainerInShadowRoot(parent) {
        const shadowRoot = parent.shadowRoot;
        if (!shadowRoot)
            return null;
        const elements = shadowRoot.querySelectorAll('*');
        let deepestScrollContainer = null;
        let maxDepth = -1;
        for (const el of Array.from(elements)) {
            const htmlEl = el;
            const style = window.getComputedStyle(htmlEl);
            const hasOverflow = style.overflow === 'auto' || style.overflow === 'scroll' || style.overflowY === 'auto' || style.overflowY === 'scroll';
            if (hasOverflow) {
                let depth = 0;
                let node = el;
                while (node && node !== shadowRoot) {
                    depth++;
                    node = node.parentNode;
                }
                if (depth > maxDepth) {
                    maxDepth = depth;
                    deepestScrollContainer = htmlEl;
                }
            }
        }
        return deepestScrollContainer;
    }
    ensureParentScrollListener() {
        if (!this.fixedCalendarParent || !this.fixedCalendar)
            return;
        if (this.parentScrollContainer)
            return;
        const parentComponent = this.findParentComponent();
        if (parentComponent) {
            this.parentScrollContainer = this.findScrollContainerInShadowRoot(parentComponent);
            if (this.parentScrollContainer) {
                this.parentScrollContainer.addEventListener('scroll', this.updateCalendarPosition);
            }
        }
    }
    cleanupParentScrollListener() {
        if (this.parentScrollContainer) {
            this.parentScrollContainer.removeEventListener('scroll', this.updateCalendarPosition);
            this.parentScrollContainer = null;
        }
    }
    watchValue(newValue) {
        if (this.datepickerInstance && newValue) {
            const date = new Date(newValue);
            if (!isNaN(date.getTime())) {
                this.datepickerInstance.setDate(date, true);
                const formattedDate = this.formatDate(date);
                this.inputElement.value = formattedDate;
                this.internalValue = formattedDate;
                this.lastInputValue = formattedDate;
            }
        }
        else if (this.datepickerInstance) {
            this.datepickerInstance.setDate(undefined, true);
            this.inputElement.value = '';
            this.internalValue = '';
            this.lastInputValue = '';
        }
        this.internals.setFormValue(newValue ? newValue : null);
        this.isClearIconVisible = this.isClear && !!newValue;
        this.updateRangeConstraints();
    }
    watchDisabled(isDisabled) {
        if (this.inputElement) {
            this.inputElement.disabled = isDisabled;
        }
    }
    watchMinDate(newMinDate) {
        if (this.datepickerInstance && newMinDate) {
            this.datepickerInstance.setMin(new Date(newMinDate));
        }
        else if (this.datepickerInstance) {
            this.datepickerInstance.setMin(undefined);
        }
    }
    watchMaxDate(newMaxDate) {
        if (this.datepickerInstance && newMaxDate) {
            this.datepickerInstance.setMax(new Date(newMaxDate));
        }
        else if (this.datepickerInstance) {
            this.datepickerInstance.setMax(undefined);
        }
    }
    /** Méthode pour ouvrir le datepicker */
    async open() {
        if (this.datepickerInstance) {
            this.datepickerInstance.show();
        }
    }
    /** Méthode pour fermer le datepicker */
    async close() {
        if (this.datepickerInstance) {
            this.datepickerInstance.hide();
        }
    }
    /** Méthode pour définir la date */
    async setDate(date) {
        if (this.datepickerInstance) {
            const dateObj = typeof date === 'string' ? new Date(date) : date;
            this.datepickerInstance.setDate(dateObj, true);
        }
    }
    /** Méthode pour récupérer la date */
    async getDate() {
        return this.datepickerInstance ? this.datepickerInstance.dateSelected : null;
    }
    /** Méthode pour récupérer le range de dates */
    async getRange() {
        if (!this.range || !this.rangeId) {
            return { start: null, end: null };
        }
        const { start, end } = this.getRangeSiblings();
        const startDate = (start === null || start === void 0 ? void 0 : start.value) ? new Date(start.value) : null;
        const endDate = (end === null || end === void 0 ? void 0 : end.value) ? new Date(end.value) : null;
        return {
            start: startDate && !isNaN(startDate.getTime()) ? startDate : null,
            end: endDate && !isNaN(endDate.getTime()) ? endDate : null,
        };
    }
    /** Méthode pour mettre à jour les contraintes min/max du datepicker */
    async updateConstraints(minDate, maxDate) {
        if (!this.datepickerInstance)
            return;
        if (minDate !== undefined) {
            if (typeof this.datepickerInstance.setMin === 'function') {
                this.datepickerInstance.setMin(minDate);
            }
            else {
                this.datepickerInstance.minDate = minDate;
            }
        }
        if (maxDate !== undefined) {
            if (typeof this.datepickerInstance.setMax === 'function') {
                this.datepickerInstance.setMax(maxDate);
            }
            else {
                this.datepickerInstance.maxDate = maxDate;
            }
        }
        if (this.isOpen && this.datepickerInstance.calendar) {
            this.datepickerInstance.hide();
            setTimeout(() => {
                this.datepickerInstance.show();
            }, 0);
        }
    }
    /** Méthode pour réinitialiser le datepicker */
    async resetInput() {
        this.value = '';
        this.internalValue = '';
        this.lastInputValue = '';
        this.internals.setFormValue(null);
        this.isClearIconVisible = false;
        if (this.inputElement) {
            this.inputElement.value = '';
        }
        if (this.datepickerInstance) {
            this.datepickerInstance.setDate(undefined, true);
        }
        this.dateChange.emit({ value: '', date: null });
        this.updateRangeConstraints();
    }
    /** Méthode pour réinitialiser les contraintes min/max du datepicker */
    async resetConstraints() {
        if (!this.datepickerInstance)
            return;
        if (typeof this.datepickerInstance.setMin === 'function') {
            this.datepickerInstance.setMin(this.minDate ? new Date(this.minDate) : undefined);
        }
        else {
            this.datepickerInstance.minDate = this.minDate ? new Date(this.minDate) : undefined;
        }
        if (typeof this.datepickerInstance.setMax === 'function') {
            this.datepickerInstance.setMax(this.maxDate ? new Date(this.maxDate) : undefined);
        }
        else {
            this.datepickerInstance.maxDate = this.maxDate ? new Date(this.maxDate) : undefined;
        }
        if (this.isOpen && this.datepickerInstance.calendar) {
            this.datepickerInstance.hide();
            setTimeout(() => {
                this.datepickerInstance.show();
            }, 0);
        }
    }
    toISODateString(date) {
        const year = date.getFullYear();
        const month = `${date.getMonth() + 1}`.padStart(2, '0');
        const day = `${date.getDate()}`.padStart(2, '0');
        if (this.range && !this.isStart) {
            return `${year}-${month}-${day}T23:59:59`;
        }
        return `${year}-${month}-${day}T00:00:00`;
    }
    getRangeSiblings() {
        if (!this.range || !this.rangeId)
            return { start: null, end: null };
        const selector = `spw-date-picker[range][range-id="${this.rangeId}"]`;
        const siblings = Array.from(document.querySelectorAll(selector));
        let start = null;
        let end = null;
        siblings.forEach(pickerEl => {
            if (pickerEl.hasAttribute('is-start')) {
                start = pickerEl;
            }
            else {
                end = pickerEl;
            }
        });
        return { start, end };
    }
    highlightRangeInCalendar() {
        var _a;
        if (!this.range || !this.rangeId || !((_a = this.datepickerInstance) === null || _a === void 0 ? void 0 : _a.calendar))
            return;
        const { start, end } = this.getRangeSiblings();
        if (!start || !end)
            return;
        const startValue = start.value;
        const endValue = end.value;
        if (!startValue || !endValue) {
            const allDates = this.datepickerInstance.calendar.querySelectorAll('.qs-square');
            allDates.forEach((dateEl) => {
                dateEl.classList.remove('spw-date-range-start', 'spw-date-range-end', 'spw-date-range-middle');
            });
            return;
        }
        const startDate = new Date(startValue);
        const endDate = new Date(endValue);
        if (isNaN(startDate.getTime()) || isNaN(endDate.getTime()))
            return;
        const allDates = this.datepickerInstance.calendar.querySelectorAll('.qs-square:not(.qs-empty)');
        allDates.forEach((dateEl) => {
            const dateNum = parseInt(dateEl.textContent || '0', 10);
            if (!dateNum)
                return;
            const currentMonth = this.datepickerInstance.currentMonth;
            const currentYear = this.datepickerInstance.currentYear;
            const cellDate = new Date(currentYear, currentMonth, dateNum);
            const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
            const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
            const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
            if (cellDateOnly >= startDateOnly && cellDateOnly <= endDateOnly) {
                if (cellDateOnly.getTime() === startDateOnly.getTime()) {
                    dateEl.classList.add('spw-date-range-start');
                    dateEl.classList.remove('spw-date-range-middle', 'spw-date-range-end');
                }
                else if (cellDateOnly.getTime() === endDateOnly.getTime()) {
                    dateEl.classList.add('spw-date-range-end');
                    dateEl.classList.remove('spw-date-range-middle', 'spw-date-range-start');
                }
                else {
                    dateEl.classList.add('spw-date-range-middle');
                    dateEl.classList.remove('spw-date-range-start', 'spw-date-range-end');
                }
            }
            else {
                dateEl.classList.remove('spw-date-range-start', 'spw-date-range-end', 'spw-date-range-middle');
            }
        });
    }
    async updateRangeConstraints() {
        var _a, _b;
        if (!this.range || !this.rangeId)
            return;
        const { start, end } = this.getRangeSiblings();
        if (this.isStart && end) {
            await ((_a = end.componentOnReady) === null || _a === void 0 ? void 0 : _a.call(end));
            const startDate = this.value ? new Date(this.value) : null;
            if (startDate && !isNaN(startDate.getTime())) {
                await end.updateConstraints(startDate, undefined);
            }
            else {
                const endMinDate = end.minDate ? new Date(end.minDate) : undefined;
                await end.updateConstraints(endMinDate, undefined);
            }
        }
        if (!this.isStart && start) {
            await ((_b = start.componentOnReady) === null || _b === void 0 ? void 0 : _b.call(start));
            const endDate = this.value ? new Date(this.value) : null;
            if (endDate && !isNaN(endDate.getTime())) {
                await start.updateConstraints(undefined, endDate);
            }
            else {
                const startMaxDate = start.maxDate ? new Date(start.maxDate) : undefined;
                await start.updateConstraints(undefined, startMaxDate);
            }
        }
    }
    unmask(value) {
        return value ? value.replace(/[^0-9]/g, '') : '';
    }
    applyMaskSmart(value) {
        if (!value)
            return '';
        const digits = this.unmask(value);
        let result = '';
        for (let i = 0; i < digits.length && i < 8; i++) {
            if (i === 2 || i === 4) {
                result += '/';
            }
            result += digits[i];
        }
        return result;
    }
    setupCalendarNavigation() {
        if (!this.datepickerInstance)
            return;
        const calendarEl = this.datepickerInstance.calendarContainer;
        if (!calendarEl)
            return;
        const focusableEls = [
            ...Array.from(calendarEl.querySelectorAll('.qs-arrow')),
            calendarEl.querySelector('.qs-month-year'),
            ...Array.from(calendarEl.querySelectorAll('.qs-square:not(.qs-day):not(.qs-empty)')),
        ].filter(Boolean);
        focusableEls.forEach((el) => {
            el.setAttribute('tabindex', '0');
            el.addEventListener('keydown', (e) => {
                this.handleCalendarKeyDown(e, el, focusableEls);
            });
            // if (el.classList.contains('qs-square')) {
            //   el.addEventListener('click', () => {
            //     setTimeout(() => this.inputElement.focus(), 100);
            //   });
            // }
        });
    }
    handleCalendarKeyDown(e, currentElement, focusableEls) {
        const currentIndex = focusableEls.indexOf(currentElement);
        let newIndex = currentIndex;
        switch (e.key) {
            case 'ArrowRight':
                e.preventDefault();
                newIndex = Math.min(currentIndex + 1, focusableEls.length - 1);
                break;
            case 'ArrowLeft':
                e.preventDefault();
                newIndex = Math.max(currentIndex - 1, 0);
                break;
            case 'ArrowDown':
                e.preventDefault();
                newIndex = currentElement.classList.contains('qs-square') ? Math.min(currentIndex + 7, focusableEls.length - 1) : Math.min(currentIndex + 1, focusableEls.length - 1);
                break;
            case 'ArrowUp':
                e.preventDefault();
                newIndex = currentElement.classList.contains('qs-square') ? Math.max(currentIndex - 7, 0) : Math.max(currentIndex - 1, 0);
                break;
            case 'Home':
                e.preventDefault();
                newIndex = 0;
                break;
            case 'End':
                e.preventDefault();
                newIndex = focusableEls.length - 1;
                break;
            case 'Enter':
            case ' ':
                e.preventDefault();
                if (currentElement.classList.contains('qs-arrow')) {
                    currentElement.click();
                    setTimeout(() => currentElement.focus(), 0);
                }
                else {
                    currentElement.click();
                }
                return;
            case 'Escape':
                e.preventDefault();
                this.datepickerInstance.hide();
                this.inputElement.focus();
                return;
        }
        if (newIndex !== currentIndex) {
            const newElement = focusableEls[newIndex];
            if (newElement && !newElement.matches('.qs-day, .qs-disabled, .qs-empty')) {
                newElement.focus();
            }
        }
    }
    initializeDatepicker() {
        var _a;
        if (!this.inputElement) {
            const shadowInput = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input[type="text"]');
            if (shadowInput) {
                this.inputElement = shadowInput;
            }
            else {
                return;
            }
        }
        const options = {
            position: this.position,
            startDay: 1,
            customDays: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
            customMonths: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
            overlayPlaceholder: 'Année',
            overlayButton: 'Valider',
            formatter: (input, date) => {
                const formattedDate = this.formatDate(date);
                input.value = formattedDate;
                this.internalValue = formattedDate;
                this.lastInputValue = formattedDate;
            },
            disabler: (date) => {
                const disabledDays = this.disabledDays;
                if (disabledDays.includes(date.getDay()))
                    return true;
                const dateStr = date.toISOString().split('T')[0];
                const disabledDates = this.disabledDates;
                return disabledDates.includes(dateStr);
            },
            onSelect: (selectedDateOrInstance) => {
                const selectedDate = selectedDateOrInstance instanceof Date ? selectedDateOrInstance : selectedDateOrInstance === null || selectedDateOrInstance === void 0 ? void 0 : selectedDateOrInstance.dateSelected;
                if (!selectedDate || isNaN(selectedDate.getTime()))
                    return;
                const isoString = this.toISODateString(selectedDate);
                this.value = isoString;
                const formattedDate = this.formatDate(selectedDate);
                this.inputElement.value = formattedDate;
                this.internalValue = formattedDate;
                this.lastInputValue = formattedDate;
                this.internals.setFormValue(isoString);
                this.isClearIconVisible = this.isClear && !!isoString;
                const dateWithTime = new Date(isoString);
                this.dateChange.emit({ value: isoString, date: dateWithTime });
                this.updateRangeConstraints();
                setTimeout(() => {
                    var _a, _b;
                    this.highlightRangeInCalendar();
                    const { start, end } = this.getRangeSiblings();
                    const sibling = this.isStart ? end : start;
                    if (sibling && sibling.isOpen) {
                        (_b = (_a = sibling).highlightRangeInCalendar) === null || _b === void 0 ? void 0 : _b.call(_a);
                    }
                }, 50);
            },
            onShow: () => {
                this.isOpen = true;
                this.datePickerOpen.emit();
                if (this.fixedCalendar) {
                    this.ensureParentScrollListener();
                    requestAnimationFrame(() => {
                        this.updateCalendarPosition();
                    });
                }
                setTimeout(() => {
                    this.setupCalendarNavigation();
                    this.highlightRangeInCalendar();
                    setTimeout(() => this.highlightRangeInCalendar(), 50);
                    setTimeout(() => this.highlightRangeInCalendar(), 150);
                }, 100);
            },
            onHide: () => {
                this.isOpen = false;
                this.datePickerClose.emit();
            },
        };
        if (this.range && this.rangeId) {
            const { start, end } = this.getRangeSiblings();
            if (this.isStart) {
                if (end && end.value) {
                    const endDate = new Date(end.value);
                    if (!isNaN(endDate.getTime())) {
                        options.maxDate = endDate;
                    }
                }
            }
            else {
                if (start && start.value) {
                    const startDate = new Date(start.value);
                    if (!isNaN(startDate.getTime())) {
                        options.minDate = startDate;
                    }
                }
            }
        }
        else {
            if (this.minDate)
                options.minDate = new Date(this.minDate);
            if (this.maxDate)
                options.maxDate = new Date(this.maxDate);
        }
        if (this.datepickerInstance) {
            if (typeof this.datepickerInstance.remove === 'function') {
                this.datepickerInstance.remove();
            }
        }
        this.datepickerInstance = datepicker(this.inputElement, options);
        if (this.value) {
            const initialDate = new Date(this.value);
            if (!isNaN(initialDate.getTime())) {
                try {
                    this.datepickerInstance.setDate(initialDate, true);
                    const formattedDate = this.formatDate(initialDate);
                    this.inputElement.value = formattedDate;
                    this.internalValue = formattedDate;
                    this.lastInputValue = formattedDate;
                }
                catch (error) { }
            }
        }
    }
    formatDate(date) {
        if (!(date instanceof Date) || isNaN(date.getTime()))
            return '';
        const day = date.getDate().toString().padStart(2, '0');
        const month = (date.getMonth() + 1).toString().padStart(2, '0');
        const year = date.getFullYear();
        return this.dateFormat.replace('dd', day).replace('MM', month).replace('yyyy', year.toString());
    }
    parseDate(dateString) {
        const parts = dateString.split('/');
        if (parts.length === 3) {
            const day = parseInt(parts[0], 10);
            const month = parseInt(parts[1], 10) - 1;
            const year = parseInt(parts[2], 10);
            if (!isNaN(day) && !isNaN(month) && !isNaN(year)) {
                return new Date(year, month, day);
            }
        }
        return null;
    }
    formResetCallback() {
        var _a;
        this.value = (_a = this.defaultValue) !== null && _a !== void 0 ? _a : '';
        this.internalValue = this.defaultValue ? this.formatDate(new Date(this.defaultValue)) : '';
        this.lastInputValue = this.internalValue;
        this.internals.setFormValue(this.defaultValue ? this.defaultValue : null);
        this.isClearIconVisible = this.isClear && !!this.defaultValue;
        if (this.inputElement) {
            this.inputElement.value = this.internalValue;
        }
        if (this.datepickerInstance) {
            if (this.defaultValue) {
                const defaultDate = new Date(this.defaultValue);
                this.datepickerInstance.setDate(defaultDate, true);
            }
            else {
                this.datepickerInstance.setDate(undefined, true);
            }
        }
        const dateToEmit = this.defaultValue ? new Date(this.defaultValue) : null;
        this.dateChange.emit({ value: this.value, date: dateToEmit });
        this.updateRangeConstraints();
    }
    render() {
        const inputClass = {
            'spw-date-picker__input': true,
            'spw-date-picker__input--error': this.hasError,
            'spw-date-picker__input--disabled': this.disabled,
            'spw-date-picker__input--open': this.isOpen,
        };
        const containerClass = {
            'spw-date-picker': true,
            'spw-date-picker--is-clear': this.isClearIconVisible,
        };
        const errorMessage = this.error || this.internalError;
        return (h(Host, { key: '532d487da5196336bc86cfa98eb2b0cf4812fdfa' }, h("div", { key: 'bd0182c0dc06cf9a5ea846513bee1960c4a6b567', class: containerClass }, this.label && (h("spw-field-label", { key: 'aa8311ff9e5d1214a8b83613b01dd0fe75981542', label: this.label, required: this.required, tooltipTitle: this.tooltipTitle, tooltipText: this.tooltipText, tooltipMaxWidth: this.tooltipMaxWidth, tooltipDirection: this.tooltipDirection, tooltipCursor: this.tooltipCursor })), this.assistiveText && (h("spw-field-message", { key: 'ddf1fee6b4ac1e18c8bc6ddf433dcb58d07bfb87', class: "spw-date-picker__field-message", variant: "hint", showIcon: false }, this.assistiveText)), h("div", { key: '8445c6f924ce87b0a630b55d15bcf439f7ae208b', class: "spw-date-picker__input-container" }, h("input", { key: '2dccede48303f05eba9fa4f37cb179f6dd8eda65', ref: el => (this.inputElement = el), id: this.uniqueId, type: "text", class: inputClass, value: this.internalValue, placeholder: this.placeholder, disabled: this.disabled, required: this.required, onFocus: this.handleInputFocus, onInput: this.handleInputChange, onKeyDown: this.handleKeyDown, "aria-label": this.accAriaLabel || this.label || this.name, "aria-describedby": this.assistiveText || errorMessage ? `${this.uniqueId}-help ${this.uniqueId}-error` : undefined, "aria-invalid": this.hasError }), h("div", { key: '0d2a94739a90dce420005bab0639cadb29444939', class: "spw-date-picker__icons" }, this.isClearIconVisible && (h("span", { key: '37b50fb2c43d2ca1be2a39b7ce9dc65e84b1b69c', class: "spw-date-picker__clear", onClick: this.handleClear }, h("spw-icon", { key: '4668571785391971ff209c46bf74f71306487f28', class: "spw-date-picker__icon spw-date-picker__icon--clear", icon: "fa-xmark" }))), h("span", { key: '14714c220f11d9b223a69354725bddbe36eed30a', class: "spw-date-picker__calendar-trigger", onMouseDown: this.handleCalendarIconMouseDown, onClick: this.handleCalendarIconClick }, h("spw-icon", { key: '67ccce624a7aed6324d48be9d3ed7c0adbf2cedf', icon: "fa-calendar", variant: "fa-regular", class: "spw-date-picker__icon spw-date-picker__icon--calendar" })))), this.error && (h("spw-field-message", { key: '7d138427f2e0a4c9863a3f041006cb0113caf038', variant: "error", showIcon: this.showErrorIcon }, this.error)), this.hint && (h("spw-field-message", { key: 'fd3265202be2901f1ad32e8343cfd2193366d201', variant: "hint", showIcon: this.showHintIcon }, this.hint)), this.success && (h("spw-field-message", { key: '085721c834bf6adfbd45ff15d3bdaaf1b4af72fb', variant: "success", showIcon: this.showSuccessIcon }, this.success)), this.warning && (h("spw-field-message", { key: '4222fb895d724619a4be4faad50d884ef571e1c9', variant: "warning", showIcon: this.showWarningIcon }, this.warning)))));
    }
    static get is() { return "spw-date-picker"; }
    static get encapsulation() { return "shadow"; }
    static get formAssociated() { return true; }
    static get originalStyleUrls() {
        return {
            "$": ["spw-date-picker.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["spw-date-picker.css"]
        };
    }
    static get properties() {
        return {
            "value": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Valeur de la date s\u00E9lectionn\u00E9e"
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "value"
            },
            "placeholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Placeholder du champ de saisie"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "placeholder",
                "defaultValue": "'JJ/MM/AAAA'"
            },
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Label du champ"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "label"
            },
            "name": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Attribut `name` utilis\u00E9 par le formulaire"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "name"
            },
            "accAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Remplit l'attribut aria-label, utilis\u00E9 \u00E0 des fins d'accessibilit\u00E9"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "acc-aria-label"
            },
            "required": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Indique si le champ est requis"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "required",
                "defaultValue": "false"
            },
            "disabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Indique si le champ est d\u00E9sactiv\u00E9"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "disabled",
                "defaultValue": "false"
            },
            "dateFormat": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Format de date \u00E0 afficher"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "date-format",
                "defaultValue": "'dd/MM/yyyy'"
            },
            "minDate": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Date minimale s\u00E9lectionnable"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "min-date"
            },
            "maxDate": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Date maximale s\u00E9lectionnable"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "max-date"
            },
            "disabledDays": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | number[]",
                    "resolved": "number[] | string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Jours de la semaine d\u00E9sactiv\u00E9s (0=dimanche, 1=lundi, etc.)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "disabled-days",
                "defaultValue": "[]"
            },
            "disabledDates": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | string[]",
                    "resolved": "string | string[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Dates sp\u00E9cifiques d\u00E9sactiv\u00E9es (format ISO, ex: [\"2026-01-01\", \"2026-12-25\"])"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "disabled-dates",
                "defaultValue": "[]"
            },
            "position": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'tr' | 'tl' | 'br' | 'bl'",
                    "resolved": "\"bl\" | \"br\" | \"tl\" | \"tr\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Position du datepicker"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "position",
                "defaultValue": "'bl'"
            },
            "error": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Message d'erreur \u00E0 afficher sous le champ"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "error",
                "defaultValue": "''"
            },
            "hint": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Message d'indication (hint) \u00E0 afficher sous le champ"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "hint",
                "defaultValue": "''"
            },
            "success": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Message de succ\u00E8s \u00E0 afficher sous le champ"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "success",
                "defaultValue": "''"
            },
            "warning": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Message de warning \u00E0 afficher sous le champ"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "warning",
                "defaultValue": "''"
            },
            "showErrorIcon": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Affiche une ic\u00F4ne d'erreur si vrai"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-error-icon",
                "defaultValue": "true"
            },
            "showHintIcon": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Affiche une ic\u00F4ne d'indication si vrai"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-hint-icon",
                "defaultValue": "true"
            },
            "showSuccessIcon": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Affiche une ic\u00F4ne de succ\u00E8s si vrai"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-success-icon",
                "defaultValue": "true"
            },
            "showWarningIcon": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Affiche une ic\u00F4ne de warning si vrai"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-warning-icon",
                "defaultValue": "true"
            },
            "assistiveText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Texte d'assistance \u00E0 afficher sous le label"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "assistive-text"
            },
            "isClear": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Indique si le champ peut \u00EAtre effac\u00E9 avec un bouton"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-clear",
                "defaultValue": "false"
            },
            "tooltipTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Titre du tooltip"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-title"
            },
            "tooltipText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Texte du tooltip"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-text"
            },
            "tooltipMaxWidth": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Largeur maximale du tooltip"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-max-width"
            },
            "tooltipDirection": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'top' | 'bottom' | 'left' | 'right'",
                    "resolved": "\"bottom\" | \"left\" | \"right\" | \"top\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Positionnement du tooltip"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-direction",
                "defaultValue": "'top'"
            },
            "tooltipCursor": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'pointer' | 'default' | 'help' | 'disabled'",
                    "resolved": "\"default\" | \"disabled\" | \"help\" | \"pointer\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Curseur du tooltip"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-cursor",
                "defaultValue": "'help'"
            },
            "range": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Si vrai, permet de d\u00E9finir un range de dates"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "range",
                "defaultValue": "false"
            },
            "rangeId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Permet de d\u00E9finir un id pour le range de date (corr\u00E9lation entre les 2 inputs)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "range-id"
            },
            "isStart": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Permet de d\u00E9finir l'input de d\u00E9but pour un range"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-start",
                "defaultValue": "false"
            },
            "fixedCalendar": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Utilise un positionnement fixed pour le calendrier si n\u00E9cessit\u00E9 de sortir du contexte (utile dans une modal avec overflow hidden)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "fixed-calendar",
                "defaultValue": "false"
            },
            "fixedCalendarParent": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Tag name du composant parent contenant le scroll (ex: 'spw-modal'). Le composant remontera les parents pour trouver ce composant et \u00E9couter son scroll interne."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "fixed-calendar-parent"
            }
        };
    }
    static get states() {
        return {
            "isOpen": {},
            "hasError": {},
            "internalError": {},
            "internalValue": {},
            "isClearIconVisible": {}
        };
    }
    static get events() {
        return [{
                "method": "dateChange",
                "name": "dateChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Evenement \u00E9mis au changement de date"
                },
                "complexType": {
                    "original": "{ value: string; date: Date }",
                    "resolved": "{ value: string; date: Date; }",
                    "references": {
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    }
                }
            }, {
                "method": "datePickerOpen",
                "name": "datePickerOpen",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Evenement \u00E9mis \u00E0 l'ouverture du datepicker"
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }, {
                "method": "datePickerClose",
                "name": "datePickerClose",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Evenement \u00E9mis \u00E0 la fermeture du datepicker"
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
    static get methods() {
        return {
            "open": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "M\u00E9thode pour ouvrir le datepicker",
                    "tags": []
                }
            },
            "close": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "M\u00E9thode pour fermer le datepicker",
                    "tags": []
                }
            },
            "setDate": {
                "complexType": {
                    "signature": "(date: Date | string) => Promise<void>",
                    "parameters": [{
                            "name": "date",
                            "type": "string | Date",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "M\u00E9thode pour d\u00E9finir la date",
                    "tags": []
                }
            },
            "getDate": {
                "complexType": {
                    "signature": "() => Promise<Date | null>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    },
                    "return": "Promise<Date>"
                },
                "docs": {
                    "text": "M\u00E9thode pour r\u00E9cup\u00E9rer la date",
                    "tags": []
                }
            },
            "getRange": {
                "complexType": {
                    "signature": "() => Promise<{ start: Date | null; end: Date | null; }>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    },
                    "return": "Promise<{ start: Date; end: Date; }>"
                },
                "docs": {
                    "text": "M\u00E9thode pour r\u00E9cup\u00E9rer le range de dates",
                    "tags": []
                }
            },
            "updateConstraints": {
                "complexType": {
                    "signature": "(minDate?: Date, maxDate?: Date) => Promise<void>",
                    "parameters": [{
                            "name": "minDate",
                            "type": "Date",
                            "docs": ""
                        }, {
                            "name": "maxDate",
                            "type": "Date",
                            "docs": ""
                        }],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "M\u00E9thode pour mettre \u00E0 jour les contraintes min/max du datepicker",
                    "tags": []
                }
            },
            "resetInput": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "M\u00E9thode pour r\u00E9initialiser le datepicker",
                    "tags": []
                }
            },
            "resetConstraints": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "M\u00E9thode pour r\u00E9initialiser les contraintes min/max du datepicker",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "value",
                "methodName": "watchValue"
            }, {
                "propName": "disabled",
                "methodName": "watchDisabled"
            }, {
                "propName": "minDate",
                "methodName": "watchMinDate"
            }, {
                "propName": "maxDate",
                "methodName": "watchMaxDate"
            }];
    }
    static get attachInternalsMemberName() { return "internals"; }
}
