/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-shadow */
// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Appearanceable } from '../../../../Behaviors/Appearanceable';
import { Variantable } from '../../../../Behaviors/Variantable';
import { Attribute } from '../../../../Decorators/AttributeDecorator';
import { Component } from '../../../../Decorators/ComponentDecorator';
import { CalendarView } from '../../../../Types/CalendarView';
import { ButtonElement } from '../../../Buttons/Button/ButtonElement';
import { TextElement } from '../../../Primitives/Text/TextElement';
import { CalendarItemElement } from '../CalendarItemElement';
import { isDateEqual, isDateInDates } from '../Utils';
import { CalendarViewBaseElement } from './Abstracts/CalendarViewBase';
import { calendarMonthsViewElementTemplate } from './CalendarMonthsViewElementTemplate';
import { calendarMonthsViewElementJoyStyle } from './Themes/CalendarMonthsViewElement.Joy';
import { calendarMonthsViewElementMemphisStyle } from './Themes/CalendarMonthsViewElement.Memphis';
import { calendarMonthsViewElementCosmopolitanStyle } from './Themes/CalendarMonthsViewElement.Cosmopolitan';
import { Themeable } from '../../../../Behaviors/Themeable';
// #endregion
/**
 * Calendar Months View - A component that displays a view of months in a calendar, allowing users to select a month.
 *
 * @description
 * The Calendar Months View component presents a grid of months within a calendar format. Users can navigate through and
 * select a specific month from the displayed options. This view is typically used within a date picker or calendar
 * component to help users choose a month for date selection or scheduling purposes.
 *
 * @name CalendarMonthsView
 * @element mosaik-calendar-months-view
 * @category Calendar
 *
 * @slot header - The header slot.
 *
 * @csspart heading - The heading part.
 * @csspart month - The month part.
 * @csspart navigation - The navigation part.
 * @csspart monthView - The month view part.
 * @csspart item - The item part.
 *
 * @cssprop {String} --calendar-months-view-padding-top
 * @cssprop {String} --calendar-months-view-padding-right
 * @cssprop {String} --calendar-months-view-padding-bottom
 * @cssprop {String} --calendar-months-view-padding-left
 * @cssprop {String} --calendar-months-view-gap
 *
 * @example
 * ```html
 * <mosaik-calendar-months-view></mosaik-calendar-months-view>
 * ```
 *
 * @public
 */
let CalendarMonthsViewElement = class CalendarMonthsViewElement extends Themeable(Appearanceable(Variantable(CalendarViewBaseElement))) {
    // #region Fields
    _format;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._format = 'short';
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-calendar-months-view';
    }
    /**
     * Gets or sets the `format` property.
     *
     * @public
     * @attr
     */
    get format() {
        return this._format;
    }
    set format(value) {
        if (this._format !== value) {
            this._format = value;
            this.requestUpdate('format');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @template
     */
    selectMonth(month) {
        this.displayDate?.setMonth(month);
        this.value?.setMonth(month);
        if (this.value === undefined) {
            console.error('[CalendarMonthsViewElement] Value is not set.');
        }
        const date = this.value;
        this.onValueChanged({
            value: {
                date: date,
                isAdjacent: false, // TODO: Implement
                isBlackout: isDateInDates(date, this.blackoutDates),
                isSpecial: isDateInDates(date, this.specialDates),
                isToday: isDateEqual(date, new Date()),
                isWeekend: date.getDay() === 0 || date.getDay() === 6
            },
            values: this.values?.map((date) => ({
                date: date,
                isAdjacent: false, // TODO: Implement
                isBlackout: isDateInDates(date, this.blackoutDates),
                isSpecial: isDateInDates(date, this.specialDates),
                isToday: isDateEqual(date, new Date()),
                isWeekend: date.getDay() === 0 || date.getDay() === 6
            }))
        });
        this.setView(CalendarView.Day);
    }
    /**
     * @protected
     * @template
     */
    setView(view) {
        this.onViewChanged({ view: view });
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], CalendarMonthsViewElement.prototype, "format", null);
CalendarMonthsViewElement = __decorate([
    Component({
        selector: 'mosaik-calendar-months-view',
        template: calendarMonthsViewElementTemplate,
        themes: {
            joy: calendarMonthsViewElementJoyStyle,
            memphis: calendarMonthsViewElementMemphisStyle,
            cosmopolitan: calendarMonthsViewElementCosmopolitanStyle
        },
        imports: [
            TextElement,
            ButtonElement,
            CalendarItemElement
        ]
    }),
    __metadata("design:paramtypes", [])
], CalendarMonthsViewElement);
export { CalendarMonthsViewElement };
//# sourceMappingURL=CalendarMonthsViewElement.js.map