import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, inject, Input, Output, ViewChild, ViewEncapsulation, } from '@angular/core';
import { NgbDate } from './ngb-date';
import { toInteger } from '../util/util';
import { NgbDatepickerI18n } from './datepicker-i18n';
import * as i0 from "@angular/core";
const _c0 = ["month"];
const _c1 = ["year"];
function NgbDatepickerNavigationSelect_For_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 3);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const m_r2 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵproperty("value", m_r2);
    i0.ɵɵattribute("aria-label", ctx_r2.i18n.getMonthFullName(m_r2, ctx_r2.date.year));
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r2.i18n.getMonthShortName(m_r2, ctx_r2.date.year));
} }
function NgbDatepickerNavigationSelect_For_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "option", 3);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const y_r4 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵproperty("value", y_r4);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r2.i18n.getYearNumerals(y_r4));
} }
export class NgbDatepickerNavigationSelect {
    constructor() {
        this._month = -1;
        this._year = -1;
        this.i18n = inject(NgbDatepickerI18n);
        this.select = new EventEmitter();
    }
    changeMonth(month) {
        this.select.emit(new NgbDate(this.date.year, toInteger(month), 1));
    }
    changeYear(year) {
        this.select.emit(new NgbDate(toInteger(year), this.date.month, 1));
    }
    ngAfterViewChecked() {
        if (this.date) {
            if (this.date.month !== this._month) {
                this._month = this.date.month;
                this.monthSelect.nativeElement.value = `${this._month}`;
            }
            if (this.date.year !== this._year) {
                this._year = this.date.year;
                this.yearSelect.nativeElement.value = `${this._year}`;
            }
        }
    }
    static { this.ɵfac = function NgbDatepickerNavigationSelect_Factory(t) { return new (t || NgbDatepickerNavigationSelect)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NgbDatepickerNavigationSelect, selectors: [["ngb-datepicker-navigation-select"]], viewQuery: function NgbDatepickerNavigationSelect_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 7, ElementRef);
            i0.ɵɵviewQuery(_c1, 7, ElementRef);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.monthSelect = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.yearSelect = _t.first);
        } }, inputs: { date: "date", disabled: "disabled", months: "months", years: "years" }, outputs: { select: "select" }, standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 8, vars: 2, consts: () => { let i18n_0; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            /**
             * @suppress {msgDescriptions}
             */
            const MSG_EXTERNAL_ngb_datepicker_select_month$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_0 = goog.getMsg("Select month");
            i18n_0 = MSG_EXTERNAL_ngb_datepicker_select_month$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_0;
        }
        else {
            i18n_0 = $localize `:@@ngb.datepicker.select-month:Select month`;
        } let i18n_1; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            /**
             * @suppress {msgDescriptions}
             */
            const MSG_EXTERNAL_ngb_datepicker_select_month$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_1 = goog.getMsg("Select month");
            i18n_1 = MSG_EXTERNAL_ngb_datepicker_select_month$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_1;
        }
        else {
            i18n_1 = $localize `:@@ngb.datepicker.select-month:Select month`;
        } let i18n_2; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            /**
             * @suppress {msgDescriptions}
             */
            const MSG_EXTERNAL_ngb_datepicker_select_year$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_2 = goog.getMsg("Select year");
            i18n_2 = MSG_EXTERNAL_ngb_datepicker_select_year$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_2;
        }
        else {
            i18n_2 = $localize `:@@ngb.datepicker.select-year:Select year`;
        } let i18n_3; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            /**
             * @suppress {msgDescriptions}
             */
            const MSG_EXTERNAL_ngb_datepicker_select_year$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_3 = goog.getMsg("Select year");
            i18n_3 = MSG_EXTERNAL_ngb_datepicker_select_year$$DATEPICKER_DATEPICKER_NAVIGATION_SELECT_TS_3;
        }
        else {
            i18n_3 = $localize `:@@ngb.datepicker.select-year:Select year`;
        } return [["month", ""], ["year", ""], ["aria-label", i18n_0, "title", i18n_1, 1, "form-select", 3, "change", "disabled"], [3, "value"], ["aria-label", i18n_2, "title", i18n_3, 1, "form-select", 3, "change", "disabled"]]; }, template: function NgbDatepickerNavigationSelect_Template(rf, ctx) { if (rf & 1) {
            const _r1 = i0.ɵɵgetCurrentView();
            i0.ɵɵelementStart(0, "select", 2, 0);
            i0.ɵɵlistener("change", function NgbDatepickerNavigationSelect_Template_select_change_0_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.changeMonth($event.target.value)); });
            i0.ɵɵrepeaterCreate(2, NgbDatepickerNavigationSelect_For_3_Template, 2, 3, "option", 3, i0.ɵɵrepeaterTrackByIdentity);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(4, "select", 4, 1);
            i0.ɵɵlistener("change", function NgbDatepickerNavigationSelect_Template_select_change_4_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.changeYear($event.target.value)); });
            i0.ɵɵrepeaterCreate(6, NgbDatepickerNavigationSelect_For_7_Template, 2, 2, "option", 3, i0.ɵɵrepeaterTrackByIdentity);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("disabled", ctx.disabled);
            i0.ɵɵadvance(2);
            i0.ɵɵrepeater(ctx.months);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("disabled", ctx.disabled);
            i0.ɵɵadvance(2);
            i0.ɵɵrepeater(ctx.years);
        } }, styles: ["ngb-datepicker-navigation-select>.form-select{flex:1 1 auto;padding:0 .5rem;font-size:.875rem;height:1.85rem}ngb-datepicker-navigation-select>.form-select:focus{z-index:1}ngb-datepicker-navigation-select>.form-select::-ms-value{background-color:transparent!important}\n"], encapsulation: 2, changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NgbDatepickerNavigationSelect, [{
        type: Component,
        args: [{ selector: 'ngb-datepicker-navigation-select', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
		<select
			#month
			[disabled]="disabled"
			class="form-select"
			i18n-aria-label="@@ngb.datepicker.select-month"
			aria-label="Select month"
			i18n-title="@@ngb.datepicker.select-month"
			title="Select month"
			(change)="changeMonth($any($event).target.value)"
		>
			@for (m of months; track m) {
				<option [attr.aria-label]="i18n.getMonthFullName(m, date.year)" [value]="m">{{
					i18n.getMonthShortName(m, date.year)
				}}</option>
			}</select
		><select
			#year
			[disabled]="disabled"
			class="form-select"
			i18n-aria-label="@@ngb.datepicker.select-year"
			aria-label="Select year"
			i18n-title="@@ngb.datepicker.select-year"
			title="Select year"
			(change)="changeYear($any($event).target.value)"
		>
			@for (y of years; track y) {
				<option [value]="y">{{ i18n.getYearNumerals(y) }}</option>
			}
		</select>
	`, styles: ["ngb-datepicker-navigation-select>.form-select{flex:1 1 auto;padding:0 .5rem;font-size:.875rem;height:1.85rem}ngb-datepicker-navigation-select>.form-select:focus{z-index:1}ngb-datepicker-navigation-select>.form-select::-ms-value{background-color:transparent!important}\n"] }]
    }], null, { date: [{
            type: Input
        }], disabled: [{
            type: Input
        }], months: [{
            type: Input
        }], years: [{
            type: Input
        }], select: [{
            type: Output
        }], monthSelect: [{
            type: ViewChild,
            args: ['month', { static: true, read: ElementRef }]
        }], yearSelect: [{
            type: ViewChild,
            args: ['year', { static: true, read: ElementRef }]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(NgbDatepickerNavigationSelect, { className: "NgbDatepickerNavigationSelect", filePath: "datepicker\\datepicker-navigation-select.ts", lineNumber: 55 }); })();
//# sourceMappingURL=data:application/json;base64, 