import { MXValueComponent, AXComponent, AXFocusableComponent, AXValuableComponent } from '@acorex/cdk/common';
import { AXButtonComponent } from '@acorex/components/button';
import { MXCalendarBaseComponent, AXCalendarComponent } from '@acorex/components/calendar';
import { AXDecoratorGenericComponent } from '@acorex/components/decorators';
import { AXPickerContainerComponent, AXPickerTitleComponent, AXPickerItemsComponent } from '@acorex/components/picker';
import { AXTabsComponent, AXTabItemComponent } from '@acorex/components/tabs';
import { AXFormatService, AXFormatPipe } from '@acorex/core/format';
import { AXTranslatorPipe } from '@acorex/core/translation';
import { NgTemplateOutlet, AsyncPipe } from '@angular/common';
import * as i0 from '@angular/core';
import { InjectionToken, inject, input, computed, signal, linkedSignal, effect, untracked, forwardRef, ViewChild, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
import { classes } from 'polytype';
import { AX_GLOBAL_CONFIG } from '@acorex/core/config';
import { set } from 'lodash-es';

const AX_DATETIME_PICKER_CONFIG = new InjectionToken('AX_DATETIME_PICKER_CONFIG', {
    providedIn: 'root',
    factory: () => {
        const global = inject(AX_GLOBAL_CONFIG);
        set(global, 'datetime-picker', AX_DATETIME_PICKER_CONFIG);
        return AXDateTimePickerDefaultConfig;
    },
});
const AXDateTimePickerDefaultConfig = {
    currentTimeButton: true,
};
function dateTimePickerConfig(config = {}) {
    const result = {
        ...AXDateTimePickerDefaultConfig,
        ...config,
    };
    return result;
}

/**
 * allows users to select a date and time from a calendar and time picker interface.
 *
 * @category Components
 */
class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValueComponent)) {
    constructor() {
        super(...arguments);
        this.formatService = inject(AXFormatService);
        this.weekend = input([], ...(ngDevMode ? [{ debugName: "weekend" }] : []));
        this.weekdays = input([], ...(ngDevMode ? [{ debugName: "weekdays" }] : []));
        /**
         * Day view navigation style of the embedded calendar.
         */
        this.calendarLook = input('select', ...(ngDevMode ? [{ debugName: "calendarLook" }] : []));
        /**
         * Years shown in the year selector when `calendarLook` is `select`.
         * Use a number for equal past/future ranges, or `{ past, future }` for asymmetric ranges.
         * `minValue` and `maxValue` take priority when set.
         */
        this.yearRange = input(80, ...(ngDevMode ? [{ debugName: "yearRange" }] : []));
        this.buttonText = computed(() => (this._activePart() === 'date' ? 'dateTime.today' : 'dateTime.now'), ...(ngDevMode ? [{ debugName: "buttonText" }] : []));
        this.defaultConfig = inject(AX_DATETIME_PICKER_CONFIG);
        this.pickerHoursMinValue = signal(null, ...(ngDevMode ? [{ debugName: "pickerHoursMinValue" }] : []));
        this.pickerHoursMaxValue = signal(null, ...(ngDevMode ? [{ debugName: "pickerHoursMaxValue" }] : []));
        this.pickerMinuteMinValue = signal(null, ...(ngDevMode ? [{ debugName: "pickerMinuteMinValue" }] : []));
        this.pickerMinuteMaxValue = signal(null, ...(ngDevMode ? [{ debugName: "pickerMinuteMaxValue" }] : []));
        this.pickerSecondMinValue = signal(null, ...(ngDevMode ? [{ debugName: "pickerSecondMinValue" }] : []));
        this.pickerSecondMaxValue = signal(null, ...(ngDevMode ? [{ debugName: "pickerSecondMaxValue" }] : []));
        /**
         *  @ignore
         */
        this._currentTimeButton = this.defaultConfig.currentTimeButton;
        /**
         *  @ignore
         */
        this.hours = Array(24)
            .fill(0)
            .map((m, i) => ({ id: i, text: i }));
        this.minutes = Array(60)
            .fill(0)
            .map((m, i) => ({ id: i, text: i }));
        /**
         *  @ignore
         */
        this._parts = {
            year: {
                key: 'year',
                placeholder: 'yyyy',
                placeholders: ['YY', 'yy', 'YYYY', 'yyyy'],
                enabled: false,
                default: 2023,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.year.placeholder),
            },
            month: {
                key: 'month',
                placeholder: 'MM',
                placeholders: ['MMM', 'MMMM', 'MM', 'M'],
                enabled: false,
                default: 1,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.month.placeholder),
            },
            day: {
                key: 'day',
                placeholder: 'dd',
                placeholders: ['dd', 'DD', 'd', 'E', 'dddd'],
                enabled: false,
                default: 1,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.day.placeholder),
            },
            hour: {
                key: 'hour',
                placeholder: 'HH',
                placeholders: ['HH', 'H', 'hh', 'h'],
                enabled: false,
                default: 0,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.hour.placeholder),
            },
            minute: {
                key: 'minute',
                placeholder: 'mm',
                placeholders: ['mm', 'm'],
                enabled: false,
                default: 0,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.minute.placeholder),
            },
            second: {
                key: 'second',
                placeholder: 'ss',
                placeholders: ['ss', 's'],
                enabled: false,
                default: 0,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.second.placeholder),
            },
            AMPM: {
                key: 'AMPM',
                placeholder: 'a',
                placeholders: ['a', 'A'],
                enabled: false,
                default: 0,
                typedValue: null,
                realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.AMPM.placeholder),
            },
        };
        /**
         *  @ignore
         */
        this._activePart = signal('date', ...(ngDevMode ? [{ debugName: "_activePart" }] : []));
        // /**
        //  *  @ignore
        //  */
        /**
         * @description The calendar type to use for the datetime input.
         */
        this.calendar = input(null, ...(ngDevMode ? [{ debugName: "calendar" }] : []));
        this._calendarSystem = computed(() => this.calendar() ?? this.localeService.activeProfile().calendar.system, ...(ngDevMode ? [{ debugName: "_calendarSystem" }] : []));
        this.editingDateObj = linkedSignal(() => this.calendarService.now(this._calendarSystem()), ...(ngDevMode ? [{ debugName: "editingDateObj" }] : []));
        this.picker = input('datetime', ...(ngDevMode ? [{ debugName: "picker" }] : []));
        this.#effectPicker = effect(() => {
            if (this.picker() === 'time') {
                this.checkSelectedMinValue(this.editingDateObj());
                this.checkSelectedMaxValue(this.editingDateObj());
                this._activePart.set('time');
            }
            else if (this.picker() === 'date') {
                this._activePart.set('date');
            }
        }, ...(ngDevMode ? [{ debugName: "#effectPicker" }] : []));
        this._resolvedFormat = computed(() => this.format() ?? this.localeService.activeProfile().formats[this.picker()]?.short ?? '', ...(ngDevMode ? [{ debugName: "_resolvedFormat" }] : []));
        /**
         * @deprecated use locale & mode instead
         */
        this.format = input(...(ngDevMode ? [undefined, { debugName: "format" }] : []));
        this.#effect = effect(() => {
            const system = this._calendarSystem();
            this._resolvedFormat();
            this.type = system;
            this._detectParts();
            untracked(() => {
                const current = this.editingDateObj();
                if (current) {
                    this.editingDateObj.set(this.calendarService.create(current.date, system));
                }
            });
        }, ...(ngDevMode ? [{ debugName: "#effect" }] : []));
    }
    /**
     * Determines whether a button for selecting the current time is displayed.
     */
    get currentTimeButton() {
        return this._currentTimeButton;
    }
    /**
     * Sets whether the button for selecting the current time is displayed.
     */
    set currentTimeButton(v) {
        this.setOption({
            name: 'currentTimeButton',
            value: v,
        });
    }
    /**
     *  @ignore
     */
    get _hasDatePart() {
        return ['year', 'month', 'day'].some((k) => this._parts[k].enabled);
    }
    /**
     *  @ignore
     */
    get _hasTimePart() {
        return ['hour', 'minute', 'second'].some((k) => this._parts[k].enabled);
    }
    #effectPicker;
    #effect;
    /**
     *  @ignore
     */
    async ngOnInit() {
        super.ngOnInit();
        this._detectParts();
        this.minValueChange.subscribe(() => {
            this.checkSelectedMinValue(this.editingDateObj());
        });
        this.maxValueChange.subscribe(() => {
            this.checkSelectedMaxValue(this.editingDateObj());
        });
    }
    /**
     * Handles changes to the internal value of the component.
     * @param value - The new date value. If not provided, defaults to the current date.
     */
    internalValueChanged(value) {
        try {
            if (this.calendarService.isValidDate(value)) {
                this.editingDateObj.set(this.calendarService.create(value, this._calendarSystem()));
            }
            else {
                throw new Error();
            }
        }
        catch {
            this.editingDateObj.set(this.calendarService.now(this._calendarSystem()));
        }
    }
    /**
     *  @ignore
     */
    _handleViewChanged(e) {
        this._activePart.set(e.tab.key);
    }
    /**
     *  @ignore
     */
    _handlePickerOnValueChanged(e, part) {
        if (e.isUserInteraction) {
            this.editingDateObj.set(this.editingDateObj().set(part, Number(e.value['id'])));
            if (this.minValue) {
                const minv = this.calendarService.convert(this.minValue, this._calendarSystem());
                // Only apply minute restrictions if we're on the same day and same hour
                if (this.editingDateObj().isAfter(this.minValue, 'day') || this.editingDateObj().hour > minv.hour) {
                    this.pickerMinuteMinValue.set(null);
                }
                else {
                    this.pickerMinuteMinValue.set(minv.minute);
                }
            }
            if (this.maxValue) {
                const maxv = this.calendarService.convert(this.maxValue, this._calendarSystem());
                // Only apply minute restrictions if we're on the same day and same hour
                if (this.editingDateObj().isBefore(this.maxValue, 'day') || this.editingDateObj().hour < maxv.hour) {
                    this.pickerMinuteMaxValue.set(null);
                }
                else {
                    this.pickerMinuteMaxValue.set(maxv.minute);
                }
            }
        }
    }
    /**
     *  @ignore
     */
    _handleCalendarOnNavigate(e) {
        this.onNavigate.emit(e);
    }
    /**
     *  @ignore
     */
    _handleCalendarOnValueChanged(e) {
        if (e.isUserInteraction) {
            const selectedValue = this.calendarService.create(e.value, this._calendarSystem());
            const currentValue = this.calendarService
                .create(e.value, this._calendarSystem())
                .set('day', selectedValue.dayOfMonth)
                .set('month', selectedValue.monthOfYear)
                .set('year', selectedValue.year);
            this.editingDateObj.set(currentValue);
            if (this._hasTimePart) {
                this._activePart.set('time');
                if (this.tabs && this._hasDatePart && this._hasTimePart) {
                    this.tabs.select(1);
                }
                else {
                    this.commitValue(this.editingDateObj().date, true);
                }
            }
            else {
                this.commitValue(this.editingDateObj().date, true);
            }
            this.checkSelectedMinValue(selectedValue);
            this.checkSelectedMaxValue(selectedValue);
        }
    }
    checkSelectedMinValue(selectedValue) {
        if (!this.minValue)
            return;
        if (!this.calendarService.isValidDate(this.minValue))
            return;
        if (selectedValue.isAfter(this.minValue, 'day')) {
            this.pickerHoursMinValue.set(null);
            this.pickerMinuteMinValue.set(null);
            this.pickerSecondMinValue.set(null);
        }
        else {
            const minv = this.calendarService.convert(this.minValue, this._calendarSystem());
            this.pickerHoursMinValue.set(minv.hour);
            this.pickerMinuteMinValue.set(minv.minute);
            this.pickerSecondMinValue.set(minv.second);
        }
    }
    checkSelectedMaxValue(selectedValue) {
        if (!this.maxValue)
            return;
        if (!this.calendarService.isValidDate(this.maxValue))
            return;
        if (selectedValue.isBefore(this.maxValue, 'day')) {
            this.pickerHoursMaxValue.set(null);
            this.pickerMinuteMaxValue.set(null);
            this.pickerSecondMaxValue.set(null);
        }
        else {
            const maxv = this.calendarService.convert(this.maxValue, this._calendarSystem());
            this.pickerHoursMaxValue.set(maxv.hour);
            this.pickerMinuteMaxValue.set(maxv.minute);
            this.pickerSecondMaxValue.set(maxv.second);
        }
    }
    /**
     *  @ignore
     */
    _detectParts() {
        Object.values(this._parts).forEach((e) => {
            e.enabled = false;
        });
        const formatParts = this._resolvedFormat().split(/[^a-zA-Z]+/);
        formatParts.forEach((f) => {
            const found = Object.values(this._parts).find((c) => c.placeholders.some((d) => d == f));
            if (found) {
                found.enabled = true;
                found.placeholder = f;
            }
        });
        //this.cdr.markForCheck();
    }
    /**
     *  @ignore
     */
    _handleSetClick() {
        this.commitValue(this.editingDateObj().date, true);
        this.checkSelectedMinValue(this.editingDateObj());
        this.checkSelectedMaxValue(this.editingDateObj());
    }
    /**
     *  @ignore
     */
    _handleNowClick() {
        this.editingDateObj.set(this.calendarService.now(this._calendarSystem()));
        this.commitValue(this.editingDateObj().date, true);
        this.checkSelectedMinValue(this.editingDateObj());
        this.checkSelectedMaxValue(this.editingDateObj());
    }
    /**
     *  @ignore
     */
    isDisabled(date) {
        if (Array.isArray(this.disabledDates) && this.disabledDates.length != 0) {
            return this.disabledDates.some((d) => date.equal(d, 'day'));
        }
        else if (typeof this.disabledDates == 'function') {
            return this.disabledDates(date.date);
        }
        return false;
    }
    /**
     *  @ignore
     */
    internalSetValue(value) {
        if (!value || !this.calendarService.isValidDate(value)) {
            return null;
        }
        const v = this.calendarService.convert(value, this._calendarSystem());
        this.checkSelectedMinValue(this.calendarService.convert(v, this._calendarSystem()));
        this.checkSelectedMaxValue(this.calendarService.convert(v, this._calendarSystem()));
        if (this.isDisabled(v)) {
            return null;
        }
        if (this.minValue && this.calendarService.isValidDate(this.minValue) && v.isBefore(this.minValue)) {
            return this.minValue;
        }
        if (this.maxValue && this.calendarService.isValidDate(this.maxValue) && v.isAfter(this.maxValue)) {
            return this.maxValue;
        }
        return v.date;
    }
    isTodayDisabled() {
        const disabledDates = this.disabledDates;
        if (!disabledDates || !Array.isArray(disabledDates)) {
            return false;
        }
        const today = new Date();
        today.setHours(0, 0, 0, 0);
        return disabledDates.some((disabledDate) => {
            const disabled = new Date(disabledDate);
            disabled.setHours(0, 0, 0, 0);
            return today.getTime() === disabled.getTime();
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXDateTimePickerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: AXDateTimePickerComponent, isStandalone: true, selector: "ax-datetime-picker", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: false, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: false, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: false, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: false, isRequired: false, transformFunction: null }, depth: { classPropertyName: "depth", publicName: "depth", isSignal: false, isRequired: false, transformFunction: null }, activeView: { classPropertyName: "activeView", publicName: "activeView", isSignal: false, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: false, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: false, isRequired: false, transformFunction: null }, disabledDates: { classPropertyName: "disabledDates", publicName: "disabledDates", isSignal: false, isRequired: false, transformFunction: null }, holidayDates: { classPropertyName: "holidayDates", publicName: "holidayDates", isSignal: false, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: false, isRequired: false, transformFunction: null }, cellTemplate: { classPropertyName: "cellTemplate", publicName: "cellTemplate", isSignal: false, isRequired: false, transformFunction: null }, cellClass: { classPropertyName: "cellClass", publicName: "cellClass", isSignal: false, isRequired: false, transformFunction: null }, showNavigation: { classPropertyName: "showNavigation", publicName: "showNavigation", isSignal: false, isRequired: false, transformFunction: null }, weekend: { classPropertyName: "weekend", publicName: "weekend", isSignal: true, isRequired: false, transformFunction: null }, weekdays: { classPropertyName: "weekdays", publicName: "weekdays", isSignal: true, isRequired: false, transformFunction: null }, calendarLook: { classPropertyName: "calendarLook", publicName: "calendarLook", isSignal: true, isRequired: false, transformFunction: null }, yearRange: { classPropertyName: "yearRange", publicName: "yearRange", isSignal: true, isRequired: false, transformFunction: null }, currentTimeButton: { classPropertyName: "currentTimeButton", publicName: "currentTimeButton", isSignal: false, isRequired: false, transformFunction: null }, calendar: { classPropertyName: "calendar", publicName: "calendar", isSignal: true, isRequired: false, transformFunction: null }, picker: { classPropertyName: "picker", publicName: "picker", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", stateChange: "stateChange", onValueChanged: "onValueChanged", onBlur: "onBlur", onFocus: "onFocus", onClick: "onClick", readonlyChange: "readonlyChange", disabledChange: "disabledChange", depthChange: "depthChange", typeChange: "typeChange", activeViewChange: "activeViewChange", disabledDatesChange: "disabledDatesChange", holidayDatesChange: "holidayDatesChange", onNavigate: "onNavigate", onSlotClick: "onSlotClick" }, providers: [
            { provide: AXComponent, useExisting: AXDateTimePickerComponent },
            { provide: AXFocusableComponent, useExisting: AXDateTimePickerComponent },
            { provide: AXValuableComponent, useExisting: AXDateTimePickerComponent },
            {
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef(() => AXDateTimePickerComponent),
                multi: true,
            },
        ], viewQueries: [{ propertyName: "tabs", first: true, predicate: AXTabsComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "@if (_hasDatePart && _hasTimePart) {\n  <div class=\"ax-header\">\n    <ax-tabs [look]=\"'default'\" [fitParent]=\"true\" [location]=\"'top'\" (onActiveTabChanged)=\"_handleViewChanged($event)\">\n      <ax-tab-item\n        [text]=\"'@acorex:dateTime.date' | translate | async\"\n        [key]=\"'date'\"\n        [disabled]=\"disabled\"\n      ></ax-tab-item>\n      <ax-tab-item\n        [text]=\"'@acorex:dateTime.time' | translate | async\"\n        [key]=\"'time'\"\n        [disabled]=\"disabled\"\n      ></ax-tab-item>\n    </ax-tabs>\n  </div>\n}\n<div class=\"ax-content\">\n  @if (_activePart() === 'date') {\n    <div class=\"ax-calendar-part\">\n      <ax-calendar\n        #calendar\n        id=\"calendar\"\n        [disabled]=\"disabled\"\n        [readonly]=\"readonly\"\n        [weekend]=\"weekend()\"\n        [weekdays]=\"weekdays()\"\n        [ngModel]=\"editingDateObj().date\"\n        [minValue]=\"minValue\"\n        [maxValue]=\"maxValue\"\n        [disabledDates]=\"disabledDates\"\n        [holidayDates]=\"holidayDates\"\n        [depth]=\"depth\"\n        (onNavigate)=\"_handleCalendarOnNavigate($event)\"\n        (onValueChanged)=\"_handleCalendarOnValueChanged($event)\"\n        [type]=\"_calendarSystem()\"\n        [look]=\"calendarLook()\"\n        [yearRange]=\"yearRange()\"\n      >\n      </ax-calendar>\n    </div>\n  }\n\n  @if (_activePart() === 'time') {\n    <div class=\"ax-picker-part\">\n      <div class=\"ax-header\">\n        @if (picker() === 'datetime') {\n          {{ editingDateObj() | format: 'time' : 'short' | async }}\n          {{ editingDateObj() | format: 'date' : 'short' | async }}\n        } @else {\n          {{ editingDateObj() | format: picker() : 'medium' | async }}\n        }\n      </div>\n      <div dir=\"ltr\" class=\"ax-picker-time-container\">\n        @if (_parts.hour.enabled) {\n          <ng-container [ngTemplateOutlet]=\"hourRef\"> </ng-container>\n        }\n\n        @if (_parts.minute.enabled) {\n          <ng-container [ngTemplateOutlet]=\"minuteRef\"> </ng-container>\n        }\n\n        @if (_parts.second.enabled) {\n          <ng-container [ngTemplateOutlet]=\"secondRef\"> </ng-container>\n        }\n      </div>\n    </div>\n  }\n</div>\n@if (!disabled && !readonly && (currentTimeButton || _hasTimePart)) {\n  <div class=\"ax-footer\">\n    <div>\n      @if (currentTimeButton) {\n        <ax-button\n          [text]=\"`@acorex:${buttonText()}` | translate | async\"\n          class=\"ax-sm\"\n          (onClick)=\"_handleNowClick()\"\n          [disabled]=\"isTodayDisabled()\"\n        ></ax-button>\n      }\n    </div>\n    <div>\n      @if (_hasTimePart) {\n        <ax-button\n          color=\"primary\"\n          [text]=\"'@acorex:dateTime.set' | translate | async\"\n          class=\"ax-sm\"\n          (onClick)=\"_handleSetClick()\"\n        ></ax-button>\n      }\n    </div>\n  </div>\n}\n\n<ng-template #hourRef>\n  <ax-picker-container>\n    <ax-picker-title>\n      <ax-text>{{ '@acorex:dateTime.units.hour' | translate | async }}</ax-text>\n    </ax-picker-title>\n    <ax-picker-items\n      [items]=\"hours\"\n      [ngModel]=\"editingDateObj().hour\"\n      (onValueChanged)=\"_handlePickerOnValueChanged($event, 'hour')\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [minValue]=\"pickerHoursMinValue()\"\n      [maxValue]=\"pickerHoursMaxValue()\"\n    ></ax-picker-items>\n  </ax-picker-container>\n</ng-template>\n\n<ng-template #minuteRef>\n  <ax-picker-container>\n    <ax-picker-title>\n      <ax-text>{{ '@acorex:dateTime.units.minute' | translate | async }}</ax-text>\n    </ax-picker-title>\n    <ax-picker-items\n      [items]=\"minutes\"\n      [ngModel]=\"editingDateObj().minute\"\n      (onValueChanged)=\"_handlePickerOnValueChanged($event, 'minute')\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [minValue]=\"pickerMinuteMinValue()\"\n      [maxValue]=\"pickerMinuteMaxValue()\"\n    ></ax-picker-items>\n  </ax-picker-container>\n</ng-template>\n\n<ng-template #secondRef>\n  <ax-picker-container>\n    <ax-picker-title>\n      <ax-text>{{ '@acorex:dateTime.units.second' | translate | async }}</ax-text>\n    </ax-picker-title>\n    <ax-picker-items\n      [items]=\"minutes\"\n      [ngModel]=\"editingDateObj().second\"\n      (onValueChanged)=\"_handlePickerOnValueChanged($event, 'second')\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [minValue]=\"pickerSecondMinValue()\"\n      [maxValue]=\"pickerSecondMaxValue()\"\n    ></ax-picker-items>\n  </ax-picker-container>\n</ng-template>\n", styles: ["ax-datetime-picker{display:flex;flex-direction:column}ax-datetime-picker>.ax-header{display:flex;justify-content:center;padding-top:var(--ax-comp-datetime-picker-header-padding-t, .5rem);padding-left:var(--ax-comp-datetime-picker-header-padding-x, .5rem);padding-right:var(--ax-comp-datetime-picker-header-padding-x, .5rem)}ax-datetime-picker>.ax-content{width:100%;overflow:hidden;display:flex;flex-direction:column;justify-content:center;align-items:center}@media (min-width: 768px){ax-datetime-picker>.ax-content{width:var(--ax-comp-datetime-picker-md-width, 20rem)}}ax-datetime-picker>.ax-content .ax-picker-part{width:100%;display:flex;flex-direction:column;height:var(--ax-comp-datetime-picker-picker-part-height, 376px)}ax-datetime-picker>.ax-content .ax-picker-part .ax-picker-time-container{display:flex;height:100%}ax-datetime-picker>.ax-content .ax-picker-part>.ax-header{font-weight:500;text-align:center;padding:var(--ax-comp-datetime-picker-picker-part-header-padding, .75rem);font-size:var(--ax-comp-datetime-picker-picker-part-header-font-size, 1rem);border-bottom:solid;border-bottom-width:var(--ax-comp-datetime-picker-picker-part-header-border-width, 1px);border-bottom-color:rgba(var(--ax-comp-datetime-picker-picker-part-header-border-color, var(--ax-sys-color-border-surface)))}ax-datetime-picker>.ax-content .ax-picker-part ax-picker{flex:1 1 0%}ax-datetime-picker>.ax-content .ax-calendar-part{width:100%;padding-top:var(--ax-comp-datetime-picker-calendar-part-padding, .25rem);padding-bottom:var(--ax-comp-datetime-picker-calendar-part-padding, .25rem)}ax-datetime-picker>.ax-content .ax-calendar-part ax-calendar{width:100%}ax-datetime-picker>.ax-footer{display:flex;justify-content:space-between;padding:var(--ax-comp-datetime-picker-footer-padding, .5rem);border-color:rgba(var(--ax-comp-datetime-picker-footer-border-color, var(--ax-sys-color-border-surface)));border-top-width:var(--ax-comp-datetime-picker-footer-border-top-width, 1px)}ax-datetime-picker>.ax-footer ax-button{min-width:100px}\n"], dependencies: [{ kind: "component", type: AXTabsComponent, selector: "ax-tabs", inputs: ["look", "location", "fitParent", "minWidth", "content"], outputs: ["onActiveTabChanged"] }, { kind: "component", type: AXTabItemComponent, selector: "ax-tab-item", inputs: ["disabled", "text", "key", "headerTemplate", "active"], outputs: ["disabledChange", "onClick", "onBlur", "onFocus", "activeChange"] }, { kind: "component", type: AXCalendarComponent, selector: "ax-calendar", inputs: ["rtl", "readonly", "value", "name", "disabled", "depth", "activeView", "minValue", "maxValue", "disabledDates", "holidayDates", "type", "dayCellTemplate", "monthCellTemplate", "yearCellTemplate", "cellClass", "showNavigation", "count", "id", "weekend", "weekdays", "look", "yearRange", "holidays"], outputs: ["onOptionChanged", "valueChange", "onValueChanged", "minValueChange", "maxValueChange", "onBlur", "onFocus", "depthChange", "typeChange", "activeViewChange", "disabledDatesChange", "holidayDatesChange", "onNavigate", "onSlotClick", "countChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "component", type: AXPickerContainerComponent, selector: "ax-picker-container", inputs: ["class"] }, { kind: "component", type: AXPickerTitleComponent, selector: "ax-picker-title" }, { kind: "component", type: AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "component", type: AXPickerItemsComponent, selector: "ax-picker-items", inputs: ["disabled", "readonly", "readonlyChange", "disabledChange", "items", "valueField", "textField", "slidesPerGroup", "loop", "minValue", "maxValue"], outputs: ["onValueChanged"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: AXFormatPipe, name: "format" }, { kind: "pipe", type: AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXDateTimePickerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-datetime-picker', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, inputs: [
                        'disabled',
                        'readonly',
                        'tabIndex',
                        'placeholder',
                        'value',
                        'state',
                        'name',
                        'id',
                        'depth',
                        'activeView',
                        'minValue',
                        'maxValue',
                        'disabledDates',
                        'holidayDates',
                        'type',
                        'cellTemplate',
                        'cellClass',
                        'showNavigation',
                    ], outputs: [
                        'valueChange',
                        'stateChange',
                        'onValueChanged',
                        'onBlur',
                        'onFocus',
                        'onClick',
                        'readonlyChange',
                        'disabledChange',
                        'depthChange',
                        'typeChange',
                        'activeViewChange',
                        'disabledDatesChange',
                        'holidayDatesChange',
                        'onNavigate',
                        'onSlotClick',
                    ], providers: [
                        { provide: AXComponent, useExisting: AXDateTimePickerComponent },
                        { provide: AXFocusableComponent, useExisting: AXDateTimePickerComponent },
                        { provide: AXValuableComponent, useExisting: AXDateTimePickerComponent },
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => AXDateTimePickerComponent),
                            multi: true,
                        },
                    ], imports: [
                        AXTabsComponent,
                        AXTabItemComponent,
                        AXCalendarComponent,
                        FormsModule,
                        NgTemplateOutlet,
                        AXButtonComponent,
                        AXPickerContainerComponent,
                        AXPickerTitleComponent,
                        AXDecoratorGenericComponent,
                        AXPickerItemsComponent,
                        AsyncPipe,
                        AXFormatPipe,
                        AXTranslatorPipe,
                    ], template: "@if (_hasDatePart && _hasTimePart) {\n  <div class=\"ax-header\">\n    <ax-tabs [look]=\"'default'\" [fitParent]=\"true\" [location]=\"'top'\" (onActiveTabChanged)=\"_handleViewChanged($event)\">\n      <ax-tab-item\n        [text]=\"'@acorex:dateTime.date' | translate | async\"\n        [key]=\"'date'\"\n        [disabled]=\"disabled\"\n      ></ax-tab-item>\n      <ax-tab-item\n        [text]=\"'@acorex:dateTime.time' | translate | async\"\n        [key]=\"'time'\"\n        [disabled]=\"disabled\"\n      ></ax-tab-item>\n    </ax-tabs>\n  </div>\n}\n<div class=\"ax-content\">\n  @if (_activePart() === 'date') {\n    <div class=\"ax-calendar-part\">\n      <ax-calendar\n        #calendar\n        id=\"calendar\"\n        [disabled]=\"disabled\"\n        [readonly]=\"readonly\"\n        [weekend]=\"weekend()\"\n        [weekdays]=\"weekdays()\"\n        [ngModel]=\"editingDateObj().date\"\n        [minValue]=\"minValue\"\n        [maxValue]=\"maxValue\"\n        [disabledDates]=\"disabledDates\"\n        [holidayDates]=\"holidayDates\"\n        [depth]=\"depth\"\n        (onNavigate)=\"_handleCalendarOnNavigate($event)\"\n        (onValueChanged)=\"_handleCalendarOnValueChanged($event)\"\n        [type]=\"_calendarSystem()\"\n        [look]=\"calendarLook()\"\n        [yearRange]=\"yearRange()\"\n      >\n      </ax-calendar>\n    </div>\n  }\n\n  @if (_activePart() === 'time') {\n    <div class=\"ax-picker-part\">\n      <div class=\"ax-header\">\n        @if (picker() === 'datetime') {\n          {{ editingDateObj() | format: 'time' : 'short' | async }}\n          {{ editingDateObj() | format: 'date' : 'short' | async }}\n        } @else {\n          {{ editingDateObj() | format: picker() : 'medium' | async }}\n        }\n      </div>\n      <div dir=\"ltr\" class=\"ax-picker-time-container\">\n        @if (_parts.hour.enabled) {\n          <ng-container [ngTemplateOutlet]=\"hourRef\"> </ng-container>\n        }\n\n        @if (_parts.minute.enabled) {\n          <ng-container [ngTemplateOutlet]=\"minuteRef\"> </ng-container>\n        }\n\n        @if (_parts.second.enabled) {\n          <ng-container [ngTemplateOutlet]=\"secondRef\"> </ng-container>\n        }\n      </div>\n    </div>\n  }\n</div>\n@if (!disabled && !readonly && (currentTimeButton || _hasTimePart)) {\n  <div class=\"ax-footer\">\n    <div>\n      @if (currentTimeButton) {\n        <ax-button\n          [text]=\"`@acorex:${buttonText()}` | translate | async\"\n          class=\"ax-sm\"\n          (onClick)=\"_handleNowClick()\"\n          [disabled]=\"isTodayDisabled()\"\n        ></ax-button>\n      }\n    </div>\n    <div>\n      @if (_hasTimePart) {\n        <ax-button\n          color=\"primary\"\n          [text]=\"'@acorex:dateTime.set' | translate | async\"\n          class=\"ax-sm\"\n          (onClick)=\"_handleSetClick()\"\n        ></ax-button>\n      }\n    </div>\n  </div>\n}\n\n<ng-template #hourRef>\n  <ax-picker-container>\n    <ax-picker-title>\n      <ax-text>{{ '@acorex:dateTime.units.hour' | translate | async }}</ax-text>\n    </ax-picker-title>\n    <ax-picker-items\n      [items]=\"hours\"\n      [ngModel]=\"editingDateObj().hour\"\n      (onValueChanged)=\"_handlePickerOnValueChanged($event, 'hour')\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [minValue]=\"pickerHoursMinValue()\"\n      [maxValue]=\"pickerHoursMaxValue()\"\n    ></ax-picker-items>\n  </ax-picker-container>\n</ng-template>\n\n<ng-template #minuteRef>\n  <ax-picker-container>\n    <ax-picker-title>\n      <ax-text>{{ '@acorex:dateTime.units.minute' | translate | async }}</ax-text>\n    </ax-picker-title>\n    <ax-picker-items\n      [items]=\"minutes\"\n      [ngModel]=\"editingDateObj().minute\"\n      (onValueChanged)=\"_handlePickerOnValueChanged($event, 'minute')\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [minValue]=\"pickerMinuteMinValue()\"\n      [maxValue]=\"pickerMinuteMaxValue()\"\n    ></ax-picker-items>\n  </ax-picker-container>\n</ng-template>\n\n<ng-template #secondRef>\n  <ax-picker-container>\n    <ax-picker-title>\n      <ax-text>{{ '@acorex:dateTime.units.second' | translate | async }}</ax-text>\n    </ax-picker-title>\n    <ax-picker-items\n      [items]=\"minutes\"\n      [ngModel]=\"editingDateObj().second\"\n      (onValueChanged)=\"_handlePickerOnValueChanged($event, 'second')\"\n      [disabled]=\"disabled\"\n      [readonly]=\"readonly\"\n      [minValue]=\"pickerSecondMinValue()\"\n      [maxValue]=\"pickerSecondMaxValue()\"\n    ></ax-picker-items>\n  </ax-picker-container>\n</ng-template>\n", styles: ["ax-datetime-picker{display:flex;flex-direction:column}ax-datetime-picker>.ax-header{display:flex;justify-content:center;padding-top:var(--ax-comp-datetime-picker-header-padding-t, .5rem);padding-left:var(--ax-comp-datetime-picker-header-padding-x, .5rem);padding-right:var(--ax-comp-datetime-picker-header-padding-x, .5rem)}ax-datetime-picker>.ax-content{width:100%;overflow:hidden;display:flex;flex-direction:column;justify-content:center;align-items:center}@media (min-width: 768px){ax-datetime-picker>.ax-content{width:var(--ax-comp-datetime-picker-md-width, 20rem)}}ax-datetime-picker>.ax-content .ax-picker-part{width:100%;display:flex;flex-direction:column;height:var(--ax-comp-datetime-picker-picker-part-height, 376px)}ax-datetime-picker>.ax-content .ax-picker-part .ax-picker-time-container{display:flex;height:100%}ax-datetime-picker>.ax-content .ax-picker-part>.ax-header{font-weight:500;text-align:center;padding:var(--ax-comp-datetime-picker-picker-part-header-padding, .75rem);font-size:var(--ax-comp-datetime-picker-picker-part-header-font-size, 1rem);border-bottom:solid;border-bottom-width:var(--ax-comp-datetime-picker-picker-part-header-border-width, 1px);border-bottom-color:rgba(var(--ax-comp-datetime-picker-picker-part-header-border-color, var(--ax-sys-color-border-surface)))}ax-datetime-picker>.ax-content .ax-picker-part ax-picker{flex:1 1 0%}ax-datetime-picker>.ax-content .ax-calendar-part{width:100%;padding-top:var(--ax-comp-datetime-picker-calendar-part-padding, .25rem);padding-bottom:var(--ax-comp-datetime-picker-calendar-part-padding, .25rem)}ax-datetime-picker>.ax-content .ax-calendar-part ax-calendar{width:100%}ax-datetime-picker>.ax-footer{display:flex;justify-content:space-between;padding:var(--ax-comp-datetime-picker-footer-padding, .5rem);border-color:rgba(var(--ax-comp-datetime-picker-footer-border-color, var(--ax-sys-color-border-surface)));border-top-width:var(--ax-comp-datetime-picker-footer-border-top-width, 1px)}ax-datetime-picker>.ax-footer ax-button{min-width:100px}\n"] }]
        }], propDecorators: { currentTimeButton: [{
                type: Input
            }], tabs: [{
                type: ViewChild,
                args: [AXTabsComponent]
            }] } });

class AXDateTimePickerModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXDateTimePickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: AXDateTimePickerModule, imports: [AXDateTimePickerComponent], exports: [AXDateTimePickerComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXDateTimePickerModule, imports: [AXDateTimePickerComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXDateTimePickerModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [AXDateTimePickerComponent],
                    exports: [AXDateTimePickerComponent],
                }]
        }] });

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

export { AXDateTimePickerComponent, AXDateTimePickerDefaultConfig, AXDateTimePickerModule, AX_DATETIME_PICKER_CONFIG, dateTimePickerConfig };
//# sourceMappingURL=acorex-components-datetime-picker.mjs.map
