import { _t } from "../../../text";
import { h, Host } from "@stencil/core";
import { isAfter, isBefore, isValid, parse } from "date-fns";
import { FormInputValidation } from "../../../enums";
import { randomIdGenerator } from "../../../global/utils/randomIdGenerator";
import { CalendarDatepickerValidation } from "./calendar-datepicker-validation.enum";
import { detectClickOutside } from "../../../global/utils/detectClickOutside";
/**
 * @swedishName Datumväljare
 */
export class CalendarDatepicker {
    constructor() {
        this.futureYears = 10;
        this.screenReaderUpdateTrigger = false;
        this.showWrongFormatError = false;
        this.showDisabledDateError = false;
        this.showCalendar = false;
        this.userInput = '';
        this.afId = randomIdGenerator('digi-calendar-datepicker');
        this.afLabel = _t.calendar.datepicker.label;
        this.afLabelDescription = _t.calendar.datepicker.description;
        this.afOpenCalendarAriaLabel = _t.calendar.datepicker.openCalendarAriaLabel;
        this.afCloseCalendarAriaLabel = _t.calendar.datepicker.closeCalendarAriaLabel;
        this.afValidation = CalendarDatepickerValidation.NEUTRAL;
        this.afValidationText = undefined;
        this.afInvalid = false;
        this.afValidationMessage = _t.calendar.datepicker.validationMessage;
        this.afValidationWrongFormat = _t.calendar.datepicker.validationWrongFormat;
        this.afValidationDisabledDate = _t.calendar.datepicker.validationDisabledDate;
        this.afRequired = undefined;
        this.afDisableValidation = undefined;
        this.afRequiredText = undefined;
        this.afSelectedDates = [];
        this.value = [];
        this.afMinDate = undefined;
        this.afMaxDate = undefined;
        this.afShowWeekNumber = false;
        this.afMultipleDates = false;
        this.afCloseOnSelect = false;
    }
    valueChangeHandler(newVal) {
        if (this.afDisableValidation && this.afSelectedDates.length > 0) {
            this.afSelectedDates = [];
        }
        /**
         * Behövde lägga till den här förändringen för att angular med value accessor betedde sig märkligt vid onBlur av input-fält. Den reagerade när man lämnade fältet även fast fältet var tomt (pratar om watchern). Så behövde bygga en guard/gatekeeper som kontrollerar värdet först. Ska inte påverka manuell-, eller autovalidering.
         */
        if (Array.isArray(newVal) &&
            newVal.every((d) => d instanceof Date && !isNaN(d.getTime()))) {
            this.afSelectedDates = newVal;
            this.userInput = '';
        }
    }
    afMultipleDatesChangeHandler() {
        var _a;
        if (!this.afMultipleDates && this.afSelectedDates.length > 1) {
            this.afSelectedDates = this.afSelectedDates.slice(-1);
            this.value = (_a = this.afSelectedDates) !== null && _a !== void 0 ? _a : [];
        }
    }
    clickHandler(e) {
        const target = e.target;
        const selector = `#${this.afId}-datepicker`;
        if (detectClickOutside(target, selector)) {
            this.showCalendar = false;
        }
    }
    connectedCallback() {
        this.hostElement.addEventListener('keyup', this.keyUpHandler.bind(this));
    }
    disconnectedCallback() {
        this.hostElement.removeEventListener('keyup', this.keyUpHandler.bind(this));
    }
    componentDidLoad() {
        var _a;
        if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) {
            this.setValue(this.value);
        }
    }
    get cssModifiers() {
        return {
            'digi-calendar-datepicker__show-week-numbers': this.afShowWeekNumber,
            'digi-calendar-datepicker__show-error': this.getShowError(),
            'digi-calendar-datepicker__show-calendar': this.showCalendar
        };
    }
    keyUpHandler(e) {
        if (e.key === 'Escape' && this.showCalendar) {
            this.showCalendar = false;
            this.focusOnCalendarButton();
            e.stopPropagation();
        }
    }
    focusOnCalendarButton() {
        const calendarButton = this.hostElement.querySelector(`#${this.afId}-button`);
        calendarButton.focus();
    }
    toggleCalendar() {
        this.showCalendar = !this.showCalendar;
        if (this.showCalendar) {
            this.screenReaderUpdateTrigger = !this.screenReaderUpdateTrigger;
        }
    }
    parseInputString(value) {
        return value
            .split(/[&,]|och/g)
            .map((text) => this.parseDateString(text.trim()));
    }
    resetValueAndState() {
        this.showWrongFormatError = false;
        this.showDisabledDateError = false;
        this.setValue([]);
        this.afOnDateChange.emit(['']);
        this.afSelectedDates = [];
    }
    validateInputAndShowErrors(dates) {
        this.showWrongFormatError = !!dates.find((date) => !isValid(date));
        this.showDisabledDateError = !!dates.find((date) => !this.isDateSelectable(date));
    }
    setValue(value) {
        this.afSelectedDates = value;
        this.value = value;
    }
    /*
    
      Metoden tar både Stencil-specifika och vanliga DOM-event, extraherar texten användaren matat in, hanterar tom inmatning, par­sar till Date[], kör intern validering, uppdaterar komponentens state och slutligen emitterar alltid en string[] med exakt det användaren skrev – vilket gör det smidigare för Angular-value-accessorn att jobba vidare med.
    
    */
    parseInput(evt) {
        let newValue = '';
        if (evt.detail && typeof evt.detail.value === 'string') {
            newValue = evt.detail.value;
        }
        else if (evt.target && evt.target.value != null) {
            newValue = evt.target.value;
        }
        this.userInput = newValue;
        if (newValue === '') {
            this.resetValueAndState();
            return;
        }
        const dates = this.parseInputString(newValue);
        this.setValue(dates); // target.value
        if (!this.afDisableValidation) {
            this.validateInputAndShowErrors(dates);
            if (this.getShowError()) {
                this.afOnDateChange.emit([]);
            }
            else {
                this.afOnDateChange.emit(this.afSelectedDates);
            }
        }
        else {
            const dateStrs = newValue.split(/[&,]|och/g).map((s) => s.trim());
            this.afOnDateChange.emit([...dateStrs]); // evt.detail
        }
    }
    parseCalendar(evt) {
        if (!(evt === null || evt === void 0 ? void 0 : evt.detail))
            return;
        if (!this.afDisableValidation) {
            this.afInvalid = false;
            this.showWrongFormatError = false;
            this.showDisabledDateError = false;
        }
        this.userInput = '';
        this.setValue(evt.detail);
        if (this.afCloseOnSelect) {
            this.toggleCalendar();
            this.focusOnCalendarButton();
        }
        this.afOnDateChange.emit(this.afSelectedDates);
    }
    /*
    
      Metoden överskrider JavaScripts inbyggda "isValid"-funktion, då den tillåter att ex., "1" är rätt format medans ex., "13" är fel format vid YYYY-MM-DD krav på inmatat format.
    
    */
    parseDateString(s) {
        const raw = s.trim().replace(/[./]/g, '-');
        // 1) yyyy-MM-dd
        if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
            const d = parse(raw, 'yyyy-MM-dd', new Date());
            return isValid(d) ? d : new Date(NaN);
        }
        // 2) yyyymmdd
        if (/^\d{8}$/.test(raw)) {
            const yyyy = raw.slice(0, 4);
            const mm = raw.slice(4, 6);
            const dd = raw.slice(6, 8);
            const d = parse(`${yyyy}-${mm}-${dd}`, 'yyyy-MM-dd', new Date());
            return isValid(d) ? d : new Date(NaN);
        }
        // 3) yymmdd (map to full year using the previous futureYears logic)
        if (/^\d{6}$/.test(raw)) {
            const yy = raw.slice(0, 2);
            const mm = raw.slice(2, 4);
            const dd = raw.slice(4, 6);
            const yyyy = this.getFullYear(yy);
            const d = parse(`${yyyy}-${mm}-${dd}`, 'yyyy-MM-dd', new Date());
            return isValid(d) ? d : new Date(NaN);
        }
        // Everything else is invalid (so "1" and "25" will now be "Fel format")
        return new Date(NaN);
    }
    getFullYear(s) {
        if (s.length === 4)
            return s;
        const y = new Date().getFullYear().toString();
        return parseInt(s) > parseInt(y.slice(-2)) + this.futureYears
            ? parseInt(y.slice(0, -2)) - 1 + s
            : y.slice(0, -2) + s;
    }
    isDateSelectable(date) {
        if (this.afMinDate && this.isBefore(date, this.afMinDate))
            return false;
        if (this.afMaxDate && this.isAfter(date, this.afMaxDate))
            return false;
        return true;
    }
    isBefore(a, b) {
        return isBefore(this.dateWithoutTime(a), this.dateWithoutTime(b));
    }
    isAfter(a, b) {
        return isAfter(this.dateWithoutTime(a), this.dateWithoutTime(b));
    }
    dateWithoutTime(date) {
        return new Date(date.getFullYear(), date.getMonth(), date.getDate());
    }
    getShowError() {
        return (this.afInvalid || this.showWrongFormatError || this.showDisabledDateError);
    }
    getErrorText() {
        var _a;
        if (this.afInvalid) {
            return (_a = this.afValidationText) !== null && _a !== void 0 ? _a : this.afValidationMessage;
        }
        return this.showWrongFormatError
            ? this.afValidationWrongFormat
            : this.afValidationDisabledDate;
    }
    get inputValue() {
        if (this.userInput !== '') {
            return this.userInput;
        }
        // otherwise format your real selected dates
        const sorted = this.afSelectedDates
            .slice()
            .sort((a, b) => (this.isBefore(a, b) ? -1 : 1));
        return this.datesToInputString(sorted);
    }
    datesToInputString(dates) {
        return dates.every((date) => date instanceof Date && !isNaN(date.getTime()))
            ? dates
                .map((date) => date.toLocaleDateString('sv-SE'))
                .flatMap((date, index, all) => {
                const isLast = index == all.length - 1;
                const isFirst = index === 0;
                if (isFirst) {
                    return date;
                }
                else if (isLast) {
                    return [' och ', date];
                }
                else {
                    return [', ', date];
                }
            })
                .join('')
            : '';
    }
    get getSelectedDates() {
        if (this.afDisableValidation && this.getShowError()) {
            return this.afSelectedDates;
        }
        if (this.getShowError()) {
            return [];
        }
        return this.afSelectedDates;
    }
    render() {
        return (h(Host, { key: '8112725ba8c875e94cc556da8921a74390d9c31e' }, h("div", { key: '4c3df5468b902a4d26fea152ebaeaea0c9bf3dd9', class: Object.assign({ 'digi-calendar-datepicker': true }, this.cssModifiers), id: `${this.afId}-datepicker` }, h("div", { key: 'bcc79305b5bb0911e5f33f2ca8641ba1a3a5c588', class: "digi-calendar-datepicker__input-field" }, h("digi-form-input", { key: 'cfe6189b8a529db4bda725f483ec899fe66b87cc', class: 'digi-calendar-datepicker__input-component', afLabel: this.afLabel, afLabelDescription: this.afLabelDescription, afValue: this.inputValue, afValidation: this.getShowError()
                ? FormInputValidation.ERROR
                : FormInputValidation.NEUTRAL, afValidationText: this.getErrorText(), afId: this.afId, afAriaDescribedby: `${this.afId}--validation-message`, afRequired: this.afRequired, afRequiredText: this.afRequiredText, onAfOnChange: (evt) => {
                evt.stopImmediatePropagation();
                this.parseInput(evt);
            } }, h("button", { key: '3126acc01f2f9aef0a02990ef22acbde7c3ed3c7', id: this.afId + '-button', class: "digi-calendar-datepicker__input-button", slot: "button", "aria-label": this.showCalendar
                ? this.afCloseCalendarAriaLabel
                : this.afOpenCalendarAriaLabel, "aria-controls": "calendar-popup", "aria-expanded": this.showCalendar ? 'true' : 'false', onClick: () => this.toggleCalendar(), type: "button" }, h("digi-icon-calendar-alt", { key: 'b48fc72cea6c3a94bd9821f2ec9416a4707e13d1', class: "digi-calendar-datepicker__button-icon", slot: "icon" })))), h("div", { key: 'd7c78a170d2d855cca3c001427d1c64ebab48fb3', class: "digi-calendar-datepicker__calendar", id: "calendar-popup" }, h("p", { key: '5651e12f6e3e06bfc879bb5c2aaf9920f9faf2e7', role: "alert", class: "digi-calendar-datepicker__sr-instructions" }, this.showCalendar
            ? `${_t.calendar.screenReaderInstructions}${this.screenReaderUpdateTrigger ? '\u200B' : ''}`
            : ''), h("digi-calendar", { key: '952ce82bb05beae68436d6a1a86bb00fefa2c3cb', afActive: this.showCalendar, afShowWeekNumber: this.afShowWeekNumber, afMultipleDates: this.afMultipleDates, afSelectedDates: this.getSelectedDates, afMinDate: this.afMinDate, afMaxDate: this.afMaxDate, "aria-hidden": !this.showCalendar, onAfOnDateSelectedChange: (evt) => {
                evt.stopImmediatePropagation();
                this.parseCalendar(evt);
            }, onAfOnFocusOutside: (evt) => {
                if (this.showCalendar) {
                    const relatedTarget = evt.detail.relatedTarget;
                    if (!relatedTarget)
                        return;
                    evt.preventDefault();
                    const isDateButton = relatedTarget.classList.contains('digi-calendar__date');
                    const isToggleButton = relatedTarget.id === `${this.afId}-button`;
                    if (isDateButton) {
                        this.focusOnCalendarButton();
                    }
                    else if (isToggleButton) {
                        const focusableDateButton = this.hostElement.querySelector('.digi-calendar__date[tabindex="0"]');
                        focusableDateButton === null || focusableDateButton === void 0 ? void 0 : focusableDateButton.focus();
                    }
                }
            } })), this.afCloseOnSelect && !this.afMultipleDates && (h("div", { key: '53f3d90d7a8864b323f9e23ffaf78330babf191e', class: "digi-calendar-datepicker__selected-date-alert", role: "alert" }, this.afSelectedDates.length > 0
            ? `${_t.calendar.datepicker.selectedDate}: ${this.datesToInputString(this.afSelectedDates)}`
            : '')))));
    }
    static get is() { return "digi-calendar-datepicker"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "$": ["calendar-datepicker.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["calendar-datepicker.css"]
        };
    }
    static get properties() {
        return {
            "afId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Sets an id attribute. Standard \u00E4r slumpm\u00E4ssig str\u00E4ng."
                        }],
                    "text": "S\u00E4tter ett id attribut."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-id",
                "reflect": false,
                "defaultValue": "randomIdGenerator('digi-calendar-datepicker')"
            },
            "afLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "The label text"
                        }],
                    "text": "Texten till labelelementet"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-label",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.label"
            },
            "afLabelDescription": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Optional description text"
                        }],
                    "text": "Valfri beskrivande text"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-label-description",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.description"
            },
            "afOpenCalendarAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Aria-label for the button that opens the calendar"
                        }],
                    "text": "Aria-label till knappen som \u00F6ppnar kalendern"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-open-calendar-aria-label",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.openCalendarAriaLabel"
            },
            "afCloseCalendarAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Aria-label for the button that closes the calendar"
                        }],
                    "text": "Aria-label till knappen som st\u00E4nger kalendern"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-close-calendar-aria-label",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.closeCalendarAriaLabel"
            },
            "afValidation": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "CalendarDatepickerValidation",
                    "resolved": "CalendarDatepickerValidation.ERROR | CalendarDatepickerValidation.NEUTRAL | CalendarDatepickerValidation.SUCCESS | CalendarDatepickerValidation.WARNING",
                    "references": {
                        "CalendarDatepickerValidation": {
                            "location": "import",
                            "path": "./calendar-datepicker-validation.enum",
                            "id": "src/components/_calendar/calendar-datepicker/calendar-datepicker-validation.enum.ts::CalendarDatepickerValidation"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set input validation status"
                        }],
                    "text": "S\u00E4tter valideringsstatus. Kan vara 'success', 'error', 'warning', 'neutral' eller ingenting."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-validation",
                "reflect": false,
                "defaultValue": "CalendarDatepickerValidation.NEUTRAL"
            },
            "afValidationText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set input validation message"
                        }],
                    "text": "S\u00E4tter valideringsmeddelandet"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-validation-text",
                "reflect": false
            },
            "afInvalid": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set input validation message when using afInvalid property"
                        }],
                    "text": "S\u00E4tter valideringsmeddelandet n\u00E4r du anv\u00E4nder afInvalid"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-invalid",
                "reflect": false,
                "defaultValue": "false"
            },
            "afValidationMessage": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set input validation message when using afInvalid property"
                        }],
                    "text": "S\u00E4tter valideringsmeddelandet n\u00E4r du anv\u00E4nder afInvalid"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-validation-message",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.validationMessage"
            },
            "afValidationWrongFormat": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set input validation message"
                        }],
                    "text": "S\u00E4tter valideringsmeddelandet"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-validation-wrong-format",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.validationWrongFormat"
            },
            "afValidationDisabledDate": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set input validation message"
                        }],
                    "text": "S\u00E4tter valideringsmeddelandet"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-validation-disabled-date",
                "reflect": false,
                "defaultValue": "_t.calendar.datepicker.validationDisabledDate"
            },
            "afRequired": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Input required attribute"
                        }],
                    "text": "S\u00E4tter attributet 'required'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-required",
                "reflect": false
            },
            "afDisableValidation": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set this to true to disable internal validation."
                        }],
                    "text": "S\u00E4tt denna till true f\u00F6r att st\u00E4nga av komponentens egna validering."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-disable-validation",
                "reflect": false
            },
            "afRequiredText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set text for afRequired."
                        }],
                    "text": "S\u00E4tter text f\u00F6r afRequired."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-required-text",
                "reflect": false
            },
            "afSelectedDates": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "Array<Date>",
                    "resolved": "Date[]",
                    "references": {
                        "Array": {
                            "location": "global",
                            "id": "global::Array"
                        },
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Selected dates in calendar"
                        }],
                    "text": "Valda datum i kalendern"
                },
                "getter": false,
                "setter": false,
                "defaultValue": "[]"
            },
            "value": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "Array<Date>",
                    "resolved": "Date[]",
                    "references": {
                        "Array": {
                            "location": "global",
                            "id": "global::Array"
                        },
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Input value attribute"
                        }, {
                            "name": "ignore",
                            "text": undefined
                        }],
                    "text": "S\u00E4tter attributet 'value'"
                },
                "getter": false,
                "setter": false,
                "defaultValue": "[]"
            },
            "afMinDate": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "Date",
                    "resolved": "Date",
                    "references": {
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Earliest selectable date"
                        }],
                    "text": "Tidigaste valbara datumet"
                },
                "getter": false,
                "setter": false
            },
            "afMaxDate": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "Date",
                    "resolved": "Date",
                    "references": {
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Latest selectable date"
                        }],
                    "text": "Senaste valbara datumet"
                },
                "getter": false,
                "setter": false
            },
            "afShowWeekNumber": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Show week number in the calander. Default is false"
                        }],
                    "text": "Visa veckonummer i kalender. F\u00F6rvalt \u00E4r false"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-show-week-number",
                "reflect": false,
                "defaultValue": "false"
            },
            "afMultipleDates": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set this to true to be able to select multiple dates in the calander. Default is false"
                        }],
                    "text": "S\u00E4tt denna till true f\u00F6r att kunna markera mer en ett datum i kalendern. F\u00F6rvalt \u00E4r false"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-multiple-dates",
                "reflect": false,
                "defaultValue": "false"
            },
            "afCloseOnSelect": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set this to true if the calendar should close when a date is selected. Default is false"
                        }],
                    "text": "S\u00E4tt denna till true om kalendern ska st\u00E4ngas n\u00E4r anv\u00E4ndaren v\u00E4ljer ett datum. F\u00F6rvalt \u00E4r false"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-close-on-select",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "showWrongFormatError": {},
            "showDisabledDateError": {},
            "showCalendar": {},
            "userInput": {}
        };
    }
    static get events() {
        return [{
                "method": "afOnDateChange",
                "name": "afOnDateChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "When date is updated"
                        }],
                    "text": "Sker vid datum uppdatering"
                },
                "complexType": {
                    "original": "Date[] | string[] | []",
                    "resolved": "Date[] | [] | string[]",
                    "references": {
                        "Date": {
                            "location": "global",
                            "id": "global::Date"
                        }
                    }
                }
            }];
    }
    static get elementRef() { return "hostElement"; }
    static get watchers() {
        return [{
                "propName": "value",
                "methodName": "valueChangeHandler"
            }, {
                "propName": "afMultipleDates",
                "methodName": "afMultipleDatesChangeHandler"
            }];
    }
    static get listeners() {
        return [{
                "name": "click",
                "method": "clickHandler",
                "target": "window",
                "capture": false,
                "passive": false
            }];
    }
}
