import * as i0 from '@angular/core';
import { Injectable, inject, Component, ChangeDetectionStrategy, output, computed, NgModule, importProvidersFrom } from '@angular/core';
import { isSameDay, startOfDay, endOfDay, startOfWeek, endOfWeek, startOfMonth, endOfMonth, differenceInDays, isAfter, isBefore, addDays, isSameMonth } from 'date-fns';
import * as i1$1 from 'angular-calendar';
import { CalendarModule, CalendarDayModule, CalendarWeekModule, DateAdapter } from 'angular-calendar';
import { dateRangeOverlapsDateRangeFunction, isDateInDateRange, isSameDateRange, isSameDateDay, isFullDateRange, clampDateToDateRange, formatToTimeAndDurationString, sortDateRangeStartAscendingCompareFunction } from '@dereekb/date';
import { invertDecision, reduceBooleansWithAndFn } from '@dereekb/util';
import { ComponentStore } from '@ngrx/component-store';
import { distinctUntilChanged, switchMap, first, tap, map, shareReplay, combineLatest, withLatestFrom } from 'rxjs';
import * as i2$1 from '@angular/material/button-toggle';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { toSignal } from '@angular/core/rxjs-interop';
import { FlexLayoutModule } from '@ngbracket/ngx-layout';
import * as i1 from '@angular/material/button';
import { MatButtonModule } from '@angular/material/button';
import { DbxButtonSpacerDirective } from '@dereekb/dbx-web';
import * as i2 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i4 from '@ngbracket/ngx-layout/flex';
import * as i5 from '@ngbracket/ngx-layout/extended';
import { NgClass } from '@angular/common';
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';

var CalendarDisplayType;
(function (CalendarDisplayType) {
    CalendarDisplayType["MONTH"] = "month";
    CalendarDisplayType["WEEK"] = "week";
    CalendarDisplayType["DAY"] = "day";
})(CalendarDisplayType || (CalendarDisplayType = {}));
function isCalendarViewDateRangeEqual(a, b) {
    return a.type === b.type && isSameDay(a.start, b.start) && isSameDay(a.end, b.end) && a.distance === b.distance && a.isMinDateVisible === b.isMinDateVisible && a.isMaxDateVisible === b.isMaxDateVisible;
}
function visibleDateRangeForCalendarState(calendarState) {
    const { navigationRangeLimit, type, date } = calendarState;
    let start;
    let end;
    let distance;
    switch (type) {
        case CalendarDisplayType.MONTH:
            start = startOfDay(startOfWeek(startOfMonth(date), { weekStartsOn: 0 }));
            end = endOfWeek(endOfMonth(date));
            distance = differenceInDays(end, start) + 1;
            break;
        case CalendarDisplayType.WEEK:
            start = startOfWeek(date);
            end = endOfWeek(start);
            distance = 7; // 7 days in a week.
            break;
        case CalendarDisplayType.DAY:
            start = startOfDay(date);
            end = endOfDay(date);
            distance = 1;
            break;
    }
    const isMinDateVisible = navigationRangeLimit?.start != null ? !isAfter(start, navigationRangeLimit.start) : false;
    const isMaxDateVisible = navigationRangeLimit?.end != null ? !isBefore(end, navigationRangeLimit.end) : false;
    // TODO: Consider changing min/max date visible logical utility to be fully within the current month or not,
    // not just visible, since it can change to a locked out calendar and doesn't feel as UI friendly.
    const result = {
        type,
        start,
        end,
        distance,
        isMinDateVisible,
        isMaxDateVisible
    };
    return result;
}
const distinctUntilDateOrTypeOrEventsChanged = distinctUntilChanged((a, b) => a?.date === b?.date && a?.type === b?.type && a?.events === b?.events);
class DbxCalendarStore extends ComponentStore {
    constructor() {
        super({
            type: CalendarDisplayType.MONTH,
            showTodayButton: true,
            date: new Date(),
            dateTappedTwice: false,
            events: []
        });
    }
    // MARK: Effects
    tapFirstPage = this.effect((input) => {
        return input.pipe(switchMap(() => this.minNavigationDate$.pipe(first(), tap((x) => {
            if (x) {
                this.tapDay(x);
            }
        }))));
    });
    tapNext = this.effect((input) => {
        return input.pipe(switchMap(() => this.visibleDateRange$.pipe(first(), tap(({ end, isMaxDateVisible }) => {
            if (!isMaxDateVisible) {
                this.tapDay(addDays(end, 1));
            }
        }))));
    });
    tapPrevious = this.effect((input) => {
        return input.pipe(switchMap(() => this.visibleDateRange$.pipe(first(), tap(({ start, isMinDateVisible }) => {
            if (!isMinDateVisible) {
                this.tapDay(addDays(start, -1));
            }
        }))));
    });
    tapLastPage = this.effect((input) => {
        return input.pipe(switchMap(() => this.maxNavigationDate$.pipe(first(), tap((x) => {
            if (x) {
                this.tapDay(x);
            }
        }))));
    });
    // MARK: Accessors
    showTodayButton$ = this.state$.pipe(map((x) => x.showTodayButton), distinctUntilChanged(), shareReplay(1));
    date$ = this.state$.pipe(map((x) => x.date));
    dateTappedTwice$ = this.state$.pipe(map((x) => x.dateTappedTwice));
    events$ = this.state$.pipe(map((x) => x.events), distinctUntilChanged(), shareReplay(1));
    /**
     * Returns the events that match the tapped date range state.
     */
    eventsForDateState$ = this.state$.pipe(distinctUntilDateOrTypeOrEventsChanged, map((state) => ({
        date: state.date,
        events: state.events.filter((x) => isSameDay(x.start, state.date) || (x.end && isBefore(x.start, state.date) && isAfter(x.end, state.date))),
        dateTappedTwice: state.dateTappedTwice
    })), shareReplay(1));
    eventsForDate$ = this.eventsForDateState$.pipe(map((state) => state.events));
    visibleDateRange$ = this.state$.pipe(map(visibleDateRangeForCalendarState), distinctUntilChanged(isCalendarViewDateRangeEqual), shareReplay(1));
    visibleEvents$ = combineLatest([this.events$, this.visibleDateRange$]).pipe(map(([events, dateRange]) => {
        const isEventInDateRange = dateRangeOverlapsDateRangeFunction(dateRange);
        return events.filter((x) => isEventInDateRange(x));
    }), shareReplay(1));
    isLookingAtToday$ = this.visibleDateRange$.pipe(map((x) => isDateInDateRange(new Date(), x)), distinctUntilChanged(), shareReplay(1));
    isLookingAtMinimumDate$ = this.visibleDateRange$.pipe(map((x) => x.isMinDateVisible), distinctUntilChanged(), shareReplay(1));
    isLookingAtMaximumDate$ = this.visibleDateRange$.pipe(map((x) => x.isMaxDateVisible), distinctUntilChanged(), shareReplay(1));
    hasMultiplePages$ = combineLatest([this.isLookingAtMinimumDate$, this.isLookingAtMaximumDate$]).pipe(map(invertDecision(reduceBooleansWithAndFn(true))), distinctUntilChanged(), shareReplay(1));
    displayType$ = this.state$.pipe(map((x) => x.type), distinctUntilChanged((a, b) => a === b), shareReplay(1));
    navigationRangeLimit$ = this.state$.pipe(map((x) => x.navigationRangeLimit), distinctUntilChanged(isSameDateRange), shareReplay(1));
    minNavigationDate$ = this.navigationRangeLimit$.pipe(map((x) => x?.start), distinctUntilChanged(isSameDateDay), shareReplay(1));
    maxNavigationDate$ = this.navigationRangeLimit$.pipe(map((x) => x?.end), distinctUntilChanged(isSameDateDay), shareReplay(1));
    isTodayInNavigationRangeLimit$ = this.navigationRangeLimit$.pipe(map((x) => isDateInDateRange(new Date(), x ?? {})), distinctUntilChanged(), shareReplay(1));
    canJumpToToday$ = combineLatest([this.isLookingAtToday$, this.isTodayInNavigationRangeLimit$]).pipe(map(([isLookingAtToday, isTodayInNavigationRangeLimit]) => !isLookingAtToday && isTodayInNavigationRangeLimit), distinctUntilChanged(), shareReplay(1));
    canShowPageButtons$ = this.state$.pipe(map((x) => x.showPageButtons && x.navigationRangeLimit && isFullDateRange(x.navigationRangeLimit)), distinctUntilChanged(), shareReplay(1));
    showPageButtons$ = combineLatest([this.canShowPageButtons$, this.isLookingAtMinimumDate$, this.isLookingAtMaximumDate$]).pipe(map(([canShowPageButtons, isLookingAtMinimumDate, isLookingAtMaximumDate]) => {
        return canShowPageButtons && !(isLookingAtMinimumDate && isLookingAtMaximumDate);
    }), distinctUntilChanged(), shareReplay(1));
    // MARK: State Changes
    /**
     * Tap a day.
     *
     * - If the same day is presented, dateTappedTwice is flipped.
     */
    tapDay = this.updater((state, date) => updateCalendarStateWithTappedDate(state, date));
    /**
     * Set all events on the calendar.
     */
    setEvents = this.updater((state, events) => ({ ...state, events }));
    /**
     * Set all events on the calendar.
     */
    setDisplayType = this.updater((state, type) => ({ ...state, type }));
    /**
     * Sets the navigation limit.
     */
    setNavigationRangeLimit = this.updater((state, navigationRangeLimit) => updateCalendarStateWithNavigationRangeLimit(state, navigationRangeLimit));
    setShowTodayButton = this.updater((state, showTodayButton) => ({ ...state, showTodayButton: showTodayButton != null ? showTodayButton : true }));
    setShowPageButtons = this.updater((state, showPageButtons) => ({ ...state, showPageButtons: showPageButtons != null ? showPageButtons : false }));
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
    static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarStore });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarStore, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });
function updateCalendarStateWithTappedDate(state, date) {
    // only update the date if it is different
    if (!isSameDateDay(state.date, date)) {
        // Only update the date if it is within the date range
        if (!state.navigationRangeLimit || isDateInDateRange(date, state.navigationRangeLimit)) {
            state = { ...state, date, dateTappedTwice: isSameDay(date, state.date) ? !state.dateTappedTwice : false };
        }
    }
    return state;
}
function updateCalendarStateWithNavigationRangeLimit(state, navigationRangeLimit) {
    const { date } = state;
    // cap the date if it doesn't fall within the range.
    if (navigationRangeLimit && !isDateInDateRange(date, navigationRangeLimit)) {
        const clampedDate = clampDateToDateRange(date, navigationRangeLimit);
        return { ...state, date: clampedDate, navigationRangeLimit };
    }
    else {
        return { ...state, navigationRangeLimit };
    }
}

function timeSubtitleForEvent(event) {
    let subtitle;
    if (event.allDay) {
        subtitle = `(All Day)`;
    }
    else {
        subtitle = formatToTimeAndDurationString(event.start, event.end ?? new Date());
    }
    return subtitle;
}
function prepareAndSortCalendarEvents(events) {
    return events
        .map((event) => {
        const subtitle = timeSubtitleForEvent(event);
        let title;
        if (event.allDay) {
            title = event.title + ' ' + subtitle;
        }
        else {
            title = `${event.title} - ${subtitle}`;
        }
        return {
            ...event,
            title
        };
    })
        .sort(sortDateRangeStartAscendingCompareFunction);
}

class DbxCalendarBaseComponent {
    calendarStore = inject((DbxCalendarStore));
    viewDate$ = this.calendarStore.date$;
    showTodayButton$ = this.calendarStore.showTodayButton$;
    canJumpToToday$ = this.calendarStore.canJumpToToday$;
    isLookingAtMinimumDate$ = this.calendarStore.isLookingAtMinimumDate$;
    isLookingAtMaximumDate$ = this.calendarStore.isLookingAtMaximumDate$;
    hasMultiplePages$ = this.calendarStore.hasMultiplePages$;
    showPageButtons$ = this.calendarStore.showPageButtons$;
    activeDayIsOpen$ = this.calendarStore.eventsForDateState$.pipe(withLatestFrom(this.calendarStore.date$), map(([x, date]) => {
        if (x.events.length && isSameMonth(x.date, date)) {
            return !x.dateTappedTwice;
        }
        return false;
    }));
    displayType$ = this.calendarStore.displayType$;
    viewDateSignal = toSignal(this.viewDate$, { initialValue: new Date() });
    showTodayButtonSignal = toSignal(this.showTodayButton$);
    canJumpToTodaySignal = toSignal(this.canJumpToToday$);
    isLookingAtMinimumDateSignal = toSignal(this.isLookingAtMinimumDate$, { initialValue: false });
    isLookingAtMaximumDateSignal = toSignal(this.isLookingAtMaximumDate$, { initialValue: false });
    hasMultiplePagesSignal = toSignal(this.hasMultiplePages$, { initialValue: false });
    showPageButtonsSignal = toSignal(this.showPageButtons$);
    activeDayIsOpenSignal = toSignal(this.activeDayIsOpen$);
    displayTypeSignal = toSignal(this.displayType$);
    todayClicked() {
        this.calendarStore.tapDay(new Date());
    }
    firstPageButtonClicked() {
        this.calendarStore.tapFirstPage();
    }
    nextButtonClicked() {
        this.calendarStore.tapNext();
    }
    previousButtonClicked() {
        this.calendarStore.tapPrevious();
    }
    lastPageButtonClicked() {
        this.calendarStore.tapLastPage();
    }
    typeToggleChanged(event) {
        this.calendarStore.setDisplayType(event.value);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: DbxCalendarBaseComponent, isStandalone: true, selector: "dbx-calendar-base", ngImport: i0, template: "<div class=\"dbx-calendar\">\n  <h3 class=\"dbx-calendar-title\">{{ viewDateSignal() | calendarDate: displayTypeSignal() + 'ViewTitle' : 'en' }}</h3>\n  <div class=\"dbx-calendar-header\">\n    <div class=\"dbx-calendar-controls\" fxLayout=\"row\" fxLayout.xs=\"column\" ngClass.xs=\"dbx-calendar-controls-compact\">\n      <span class=\"dbx-calendar-controls-left dbx-flex-bar\" fxFlex=\"nogrow\">\n        @if (showTodayButtonSignal()) {\n          <button mat-stroked-button [disabled]=\"!canJumpToTodaySignal()\" (click)=\"todayClicked()\">Today</button>\n        }\n        <dbx-button-spacer></dbx-button-spacer>\n        @if (hasMultiplePagesSignal()) {\n          <div class=\"d-iblock\">\n            @if (showPageButtonsSignal()) {\n              <button mat-icon-button [disabled]=\"isLookingAtMinimumDateSignal()\" aria-label=\"first page button\" (click)=\"firstPageButtonClicked()\">\n                <mat-icon>first_page</mat-icon>\n              </button>\n            }\n            <button mat-icon-button [disabled]=\"isLookingAtMinimumDateSignal()\" [attr.aria-label]=\"'Previous ' + displayTypeSignal() + ' button'\" (click)=\"previousButtonClicked()\">\n              <mat-icon>navigate_before</mat-icon>\n            </button>\n            <button mat-icon-button [disabled]=\"isLookingAtMaximumDateSignal()\" [attr.aria-label]=\"'Next ' + displayTypeSignal() + ' button'\" (click)=\"nextButtonClicked()\">\n              <mat-icon>navigate_next</mat-icon>\n            </button>\n            @if (showPageButtonsSignal()) {\n              <button mat-icon-button [disabled]=\"isLookingAtMaximumDateSignal()\" aria-label=\"last page button\" (click)=\"lastPageButtonClicked()\">\n                <mat-icon>last_page</mat-icon>\n              </button>\n            }\n          </div>\n        }\n      </span>\n      <span class=\"spacer\"></span>\n      <span class=\"dbx-calendar-controls-right\" fxFlex=\"nogrow\">\n        <ng-content select=\"[controls]\"></ng-content>\n      </span>\n    </div>\n  </div>\n  <ng-content></ng-content>\n</div>\n", dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i1.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "directive", type: DbxButtonSpacerDirective, selector: "dbx-button-spacer,[dbxButtonSpacer]" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: CalendarModule }, { kind: "pipe", type: i1$1.ɵCalendarDatePipe, name: "calendarDate" }, { kind: "ngmodule", type: FlexLayoutModule }, { kind: "directive", type: i4.DefaultLayoutDirective, selector: "  [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md],  [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md],  [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm],  [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i4.DefaultFlexDirective, selector: "  [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md],  [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md],  [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm],  [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "directive", type: i5.DefaultClassDirective, selector: "  [ngClass], [ngClass.xs], [ngClass.sm], [ngClass.md], [ngClass.lg], [ngClass.xl],  [ngClass.lt-sm], [ngClass.lt-md], [ngClass.lt-lg], [ngClass.lt-xl],  [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]", inputs: ["ngClass", "ngClass.xs", "ngClass.sm", "ngClass.md", "ngClass.lg", "ngClass.xl", "ngClass.lt-sm", "ngClass.lt-md", "ngClass.lt-lg", "ngClass.lt-xl", "ngClass.gt-xs", "ngClass.gt-sm", "ngClass.gt-md", "ngClass.gt-lg"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarBaseComponent, decorators: [{
            type: Component,
            args: [{ selector: 'dbx-calendar-base', standalone: true, imports: [MatButtonModule, MatButtonToggleModule, DbxButtonSpacerDirective, MatIconModule, CalendarModule, FlexLayoutModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"dbx-calendar\">\n  <h3 class=\"dbx-calendar-title\">{{ viewDateSignal() | calendarDate: displayTypeSignal() + 'ViewTitle' : 'en' }}</h3>\n  <div class=\"dbx-calendar-header\">\n    <div class=\"dbx-calendar-controls\" fxLayout=\"row\" fxLayout.xs=\"column\" ngClass.xs=\"dbx-calendar-controls-compact\">\n      <span class=\"dbx-calendar-controls-left dbx-flex-bar\" fxFlex=\"nogrow\">\n        @if (showTodayButtonSignal()) {\n          <button mat-stroked-button [disabled]=\"!canJumpToTodaySignal()\" (click)=\"todayClicked()\">Today</button>\n        }\n        <dbx-button-spacer></dbx-button-spacer>\n        @if (hasMultiplePagesSignal()) {\n          <div class=\"d-iblock\">\n            @if (showPageButtonsSignal()) {\n              <button mat-icon-button [disabled]=\"isLookingAtMinimumDateSignal()\" aria-label=\"first page button\" (click)=\"firstPageButtonClicked()\">\n                <mat-icon>first_page</mat-icon>\n              </button>\n            }\n            <button mat-icon-button [disabled]=\"isLookingAtMinimumDateSignal()\" [attr.aria-label]=\"'Previous ' + displayTypeSignal() + ' button'\" (click)=\"previousButtonClicked()\">\n              <mat-icon>navigate_before</mat-icon>\n            </button>\n            <button mat-icon-button [disabled]=\"isLookingAtMaximumDateSignal()\" [attr.aria-label]=\"'Next ' + displayTypeSignal() + ' button'\" (click)=\"nextButtonClicked()\">\n              <mat-icon>navigate_next</mat-icon>\n            </button>\n            @if (showPageButtonsSignal()) {\n              <button mat-icon-button [disabled]=\"isLookingAtMaximumDateSignal()\" aria-label=\"last page button\" (click)=\"lastPageButtonClicked()\">\n                <mat-icon>last_page</mat-icon>\n              </button>\n            }\n          </div>\n        }\n      </span>\n      <span class=\"spacer\"></span>\n      <span class=\"dbx-calendar-controls-right\" fxFlex=\"nogrow\">\n        <ng-content select=\"[controls]\"></ng-content>\n      </span>\n    </div>\n  </div>\n  <ng-content></ng-content>\n</div>\n" }]
        }] });

class DbxCalendarComponent {
    calendarStore = inject((DbxCalendarStore));
    clickEvent = output();
    viewDate$ = this.calendarStore.date$;
    events$ = this.calendarStore.visibleEvents$.pipe(map(prepareAndSortCalendarEvents), shareReplay(1));
    activeDayIsOpen$ = this.calendarStore.eventsForDateState$.pipe(withLatestFrom(this.calendarStore.date$), map(([x, date]) => {
        if (x.events.length && isSameMonth(x.date, date)) {
            return !x.dateTappedTwice;
        }
        return false;
    }), distinctUntilChanged(), shareReplay(1));
    displayType$ = this.calendarStore.displayType$;
    viewDateSignal = toSignal(this.viewDate$, { initialValue: new Date() });
    eventsSignal = toSignal(this.events$, { initialValue: [] });
    activeDayIsOpenSignal = toSignal(this.activeDayIsOpen$, { initialValue: true });
    displayTypeSignal = toSignal(this.displayType$);
    displayTypeClassSignal = computed(() => `dbx-calendar-content-${this.displayTypeSignal()}`);
    todayClicked() {
        this.dayClicked({ date: new Date() });
    }
    nextButtonClicked() {
        this.calendarStore.tapNext();
    }
    previousButtonClicked() {
        this.calendarStore.tapPrevious();
    }
    dayClicked({ date }) {
        this.calendarStore.tapDay(date);
    }
    eventClicked(action, event) {
        this.clickEvent.emit({ action, event });
    }
    typeToggleChanged(event) {
        this.calendarStore.setDisplayType(event.value);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: DbxCalendarComponent, isStandalone: true, selector: "dbx-calendar", outputs: { clickEvent: "clickEvent" }, ngImport: i0, template: "<dbx-calendar-base>\n  <ng-container controls>\n    <mat-button-toggle-group name=\"calendarDisplayStyle\" [value]=\"displayTypeSignal()\" (change)=\"typeToggleChanged($event)\" aria-label=\"Display Style\">\n      <mat-button-toggle value=\"month\">Month</mat-button-toggle>\n      <mat-button-toggle value=\"week\">Week</mat-button-toggle>\n      <mat-button-toggle value=\"day\">Day</mat-button-toggle>\n    </mat-button-toggle-group>\n  </ng-container>\n  <div class=\"dbx-calendar-content\" [ngClass]=\"displayTypeClassSignal()\">\n    @switch (displayTypeSignal()) {\n      @case ('month') {\n        <mwl-calendar-month-view [viewDate]=\"viewDateSignal()\" [events]=\"eventsSignal()\" [activeDayIsOpen]=\"activeDayIsOpenSignal()\" (dayClicked)=\"dayClicked($event.day)\" (eventClicked)=\"eventClicked('Clicked', $event.event)\"></mwl-calendar-month-view>\n      }\n      @case ('week') {\n        <mwl-calendar-week-view [viewDate]=\"viewDateSignal()\" [events]=\"eventsSignal()\" (eventClicked)=\"eventClicked('Clicked', $event.event)\"></mwl-calendar-week-view>\n      }\n      @case ('day') {\n        <mwl-calendar-day-view [viewDate]=\"viewDateSignal()\" [events]=\"eventsSignal()\" (eventClicked)=\"eventClicked('Clicked', $event.event)\"></mwl-calendar-day-view>\n      }\n    }\n  </div>\n</dbx-calendar-base>\n", dependencies: [{ kind: "component", type: DbxCalendarBaseComponent, selector: "dbx-calendar-base" }, { kind: "ngmodule", type: CalendarModule }, { kind: "component", type: i1$1.CalendarMonthViewComponent, selector: "mwl-calendar-month-view", inputs: ["viewDate", "events", "excludeDays", "activeDayIsOpen", "activeDay", "refresh", "locale", "tooltipPlacement", "tooltipTemplate", "tooltipAppendToBody", "tooltipDelay", "weekStartsOn", "headerTemplate", "cellTemplate", "openDayEventsTemplate", "eventTitleTemplate", "eventActionsTemplate", "weekendDays"], outputs: ["beforeViewRender", "dayClicked", "eventClicked", "columnHeaderClicked", "eventTimesChanged"] }, { kind: "component", type: i1$1.CalendarWeekViewComponent, selector: "mwl-calendar-week-view", inputs: ["viewDate", "events", "excludeDays", "refresh", "locale", "tooltipPlacement", "tooltipTemplate", "tooltipAppendToBody", "tooltipDelay", "weekStartsOn", "headerTemplate", "eventTemplate", "eventTitleTemplate", "eventActionsTemplate", "precision", "weekendDays", "snapDraggedEvents", "hourSegments", "hourDuration", "hourSegmentHeight", "minimumEventHeight", "dayStartHour", "dayStartMinute", "dayEndHour", "dayEndMinute", "hourSegmentTemplate", "eventSnapSize", "allDayEventsLabelTemplate", "daysInWeek", "currentTimeMarkerTemplate", "validateEventTimesChanged", "resizeCursors"], outputs: ["dayHeaderClicked", "eventClicked", "eventTimesChanged", "beforeViewRender", "hourSegmentClicked"] }, { kind: "component", type: i1$1.CalendarDayViewComponent, selector: "mwl-calendar-day-view", inputs: ["viewDate", "events", "hourSegments", "hourSegmentHeight", "hourDuration", "minimumEventHeight", "dayStartHour", "dayStartMinute", "dayEndHour", "dayEndMinute", "refresh", "locale", "eventSnapSize", "tooltipPlacement", "tooltipTemplate", "tooltipAppendToBody", "tooltipDelay", "hourSegmentTemplate", "eventTemplate", "eventTitleTemplate", "eventActionsTemplate", "snapDraggedEvents", "allDayEventsLabelTemplate", "currentTimeMarkerTemplate", "validateEventTimesChanged", "resizeCursors"], outputs: ["eventClicked", "hourSegmentClicked", "eventTimesChanged", "beforeViewRender"] }, { kind: "ngmodule", type: CalendarDayModule }, { kind: "ngmodule", type: CalendarWeekModule }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "directive", type: i2$1.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled", "disabledInteractive", "hideSingleSelectionIndicator", "hideMultipleSelectionIndicator"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { kind: "component", type: i2$1.MatButtonToggle, selector: "mat-button-toggle", inputs: ["aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "disableRipple", "appearance", "checked", "disabled", "disabledInteractive"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'dbx-calendar', imports: [DbxCalendarBaseComponent, CalendarModule, CalendarDayModule, CalendarWeekModule, MatButtonToggleModule, NgClass], changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, template: "<dbx-calendar-base>\n  <ng-container controls>\n    <mat-button-toggle-group name=\"calendarDisplayStyle\" [value]=\"displayTypeSignal()\" (change)=\"typeToggleChanged($event)\" aria-label=\"Display Style\">\n      <mat-button-toggle value=\"month\">Month</mat-button-toggle>\n      <mat-button-toggle value=\"week\">Week</mat-button-toggle>\n      <mat-button-toggle value=\"day\">Day</mat-button-toggle>\n    </mat-button-toggle-group>\n  </ng-container>\n  <div class=\"dbx-calendar-content\" [ngClass]=\"displayTypeClassSignal()\">\n    @switch (displayTypeSignal()) {\n      @case ('month') {\n        <mwl-calendar-month-view [viewDate]=\"viewDateSignal()\" [events]=\"eventsSignal()\" [activeDayIsOpen]=\"activeDayIsOpenSignal()\" (dayClicked)=\"dayClicked($event.day)\" (eventClicked)=\"eventClicked('Clicked', $event.event)\"></mwl-calendar-month-view>\n      }\n      @case ('week') {\n        <mwl-calendar-week-view [viewDate]=\"viewDateSignal()\" [events]=\"eventsSignal()\" (eventClicked)=\"eventClicked('Clicked', $event.event)\"></mwl-calendar-week-view>\n      }\n      @case ('day') {\n        <mwl-calendar-day-view [viewDate]=\"viewDateSignal()\" [events]=\"eventsSignal()\" (eventClicked)=\"eventClicked('Clicked', $event.event)\"></mwl-calendar-day-view>\n      }\n    }\n  </div>\n</dbx-calendar-base>\n" }]
        }] });

const importsAndExports = [DbxCalendarBaseComponent, DbxCalendarComponent];
/**
 * @deprecated import DbxCalendarBaseComponent, and DbxCalendarComponent directly
 */
class DbxCalendarModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarModule, imports: [DbxCalendarBaseComponent, DbxCalendarComponent], exports: [DbxCalendarBaseComponent, DbxCalendarComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarModule, imports: [importsAndExports] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DbxCalendarModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: importsAndExports,
                    exports: importsAndExports
                }]
        }] });

/**
 * Provides default configuration for the DbxCalendarModule
 */
function provideDbxCalendar() {
    const providers = importProvidersFrom(CalendarModule.forRoot({ provide: DateAdapter, useFactory: adapterFactory }));
    return providers;
}

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

export { CalendarDisplayType, DbxCalendarBaseComponent, DbxCalendarComponent, DbxCalendarModule, DbxCalendarStore, isCalendarViewDateRangeEqual, prepareAndSortCalendarEvents, provideDbxCalendar, updateCalendarStateWithNavigationRangeLimit, updateCalendarStateWithTappedDate, visibleDateRangeForCalendarState };
//# sourceMappingURL=dereekb-dbx-web-calendar.mjs.map
