/**
 * @license
 * Copyright Alibaba.com All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { CandyDate } from 'ng-zorro-antd/core';
import { PREFIX_CLASS } from './name';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "./lib/decade-header.component";
import * as i3 from "./lib/decade-table.component";
import * as i4 from "./lib/year-header.component";
import * as i5 from "./lib/year-table.component";
import * as i6 from "./lib/month-header.component";
import * as i7 from "./lib/month-table.component";
import * as i8 from "./lib/date-header.component";
import * as i9 from "./lib/date-table.component";
import * as i10 from "ng-zorro-antd/time-picker";
import * as i11 from "@angular/forms";
function InnerPopupComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    const _r1327 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "decade-header", 4);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_3_Template_decade_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1327); const ctx_r1326 = i0.ɵɵnextContext(); return ctx_r1326.activeDate = $event; })("panelModeChange", function InnerPopupComponent_ng_container_3_Template_decade_header_panelModeChange_1_listener($event) { i0.ɵɵrestoreView(_r1327); const ctx_r1328 = i0.ɵɵnextContext(); return ctx_r1328.panelModeChange.emit($event); })("valueChange", function InnerPopupComponent_ng_container_3_Template_decade_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1327); const ctx_r1329 = i0.ɵɵnextContext(); return ctx_r1329.headerChange.emit($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "div");
    i0.ɵɵelementStart(3, "decade-table", 5);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_3_Template_decade_table_valueChange_3_listener($event) { i0.ɵɵrestoreView(_r1327); const ctx_r1330 = i0.ɵɵnextContext(); return ctx_r1330.onChooseDecade($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1321 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("value", ctx_r1321.activeDate)("locale", ctx_r1321.locale)("showNextBtn", false)("showPreBtn", false);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("", ctx_r1321.prefixCls, "-body");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("showWeek", ctx_r1321.showWeek)("activeDate", ctx_r1321.activeDate)("value", ctx_r1321.value)("disabledDate", ctx_r1321.disabledDate)("cellRender", ctx_r1321.dateRender);
} }
function InnerPopupComponent_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    const _r1332 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "year-header", 4);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_4_Template_year_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1332); const ctx_r1331 = i0.ɵɵnextContext(); return ctx_r1331.activeDate = $event; })("panelModeChange", function InnerPopupComponent_ng_container_4_Template_year_header_panelModeChange_1_listener($event) { i0.ɵɵrestoreView(_r1332); const ctx_r1333 = i0.ɵɵnextContext(); return ctx_r1333.panelModeChange.emit($event); })("valueChange", function InnerPopupComponent_ng_container_4_Template_year_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1332); const ctx_r1334 = i0.ɵɵnextContext(); return ctx_r1334.headerChange.emit($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "div");
    i0.ɵɵelementStart(3, "year-table", 5);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_4_Template_year_table_valueChange_3_listener($event) { i0.ɵɵrestoreView(_r1332); const ctx_r1335 = i0.ɵɵnextContext(); return ctx_r1335.onChooseYear($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1322 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("value", ctx_r1322.activeDate)("locale", ctx_r1322.locale)("showNextBtn", false)("showPreBtn", false);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("", ctx_r1322.prefixCls, "-body");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("showWeek", ctx_r1322.showWeek)("activeDate", ctx_r1322.activeDate)("value", ctx_r1322.value)("disabledDate", ctx_r1322.disabledDate)("cellRender", ctx_r1322.dateRender);
} }
function InnerPopupComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    const _r1337 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "month-header", 4);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_5_Template_month_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1337); const ctx_r1336 = i0.ɵɵnextContext(); return ctx_r1336.activeDate = $event; })("panelModeChange", function InnerPopupComponent_ng_container_5_Template_month_header_panelModeChange_1_listener($event) { i0.ɵɵrestoreView(_r1337); const ctx_r1338 = i0.ɵɵnextContext(); return ctx_r1338.panelModeChange.emit($event); })("valueChange", function InnerPopupComponent_ng_container_5_Template_month_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1337); const ctx_r1339 = i0.ɵɵnextContext(); return ctx_r1339.headerChange.emit($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "div");
    i0.ɵɵelementStart(3, "month-table", 6);
    i0.ɵɵlistener("dayHover", function InnerPopupComponent_ng_container_5_Template_month_table_dayHover_3_listener($event) { i0.ɵɵrestoreView(_r1337); const ctx_r1340 = i0.ɵɵnextContext(); return ctx_r1340.dayHover.emit($event); })("valueChange", function InnerPopupComponent_ng_container_5_Template_month_table_valueChange_3_listener($event) { i0.ɵɵrestoreView(_r1337); const ctx_r1341 = i0.ɵɵnextContext(); return ctx_r1341.onChooseMonth($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1323 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("value", ctx_r1323.activeDate)("locale", ctx_r1323.locale)("showNextBtn", false)("showPreBtn", false);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("", ctx_r1323.prefixCls, "-body");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("showWeek", ctx_r1323.showWeek)("value", ctx_r1323.value)("activeDate", ctx_r1323.activeDate)("disabledDate", ctx_r1323.disabledDate)("cellRender", ctx_r1323.dateRender);
} }
function InnerPopupComponent_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    const _r1343 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "date-header", 7);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_6_Template_date_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1343); const ctx_r1342 = i0.ɵɵnextContext(); return ctx_r1342.activeDate = $event; })("panelModeChange", function InnerPopupComponent_ng_container_6_Template_date_header_panelModeChange_1_listener($event) { i0.ɵɵrestoreView(_r1343); const ctx_r1344 = i0.ɵɵnextContext(); return ctx_r1344.panelModeChange.emit($event); })("valueChange", function InnerPopupComponent_ng_container_6_Template_date_header_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r1343); const ctx_r1345 = i0.ɵɵnextContext(); return ctx_r1345.headerChange.emit($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(2, "div");
    i0.ɵɵelementStart(3, "date-table", 8);
    i0.ɵɵlistener("valueChange", function InnerPopupComponent_ng_container_6_Template_date_table_valueChange_3_listener($event) { i0.ɵɵrestoreView(_r1343); const ctx_r1346 = i0.ɵɵnextContext(); return ctx_r1346.onSelectDate($event); })("dayHover", function InnerPopupComponent_ng_container_6_Template_date_table_dayHover_3_listener($event) { i0.ɵɵrestoreView(_r1343); const ctx_r1347 = i0.ɵɵnextContext(); return ctx_r1347.dayHover.emit($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1324 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("value", ctx_r1324.activeDate)("locale", ctx_r1324.locale);
    i0.ɵɵadvance(1);
    i0.ɵɵclassMapInterpolate1("", ctx_r1324.prefixCls, "-body");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("locale", ctx_r1324.locale)("showWeek", ctx_r1324.showWeek)("value", ctx_r1324.value)("activeDate", ctx_r1324.activeDate)("disabledDate", ctx_r1324.disabledDate)("cellRender", ctx_r1324.dateRender)("selectedValue", ctx_r1324.selectedValue)("hoverValue", ctx_r1324.hoverValue);
} }
function InnerPopupComponent_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    const _r1349 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "nz-time-picker-panel", 9);
    i0.ɵɵlistener("ngModelChange", function InnerPopupComponent_ng_container_7_Template_nz_time_picker_panel_ngModelChange_1_listener($event) { i0.ɵɵrestoreView(_r1349); const ctx_r1348 = i0.ɵɵnextContext(); return ctx_r1348.onSelectTime($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1325 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzInDatePicker", true)("ngModel", ctx_r1325.value == null ? null : ctx_r1325.value.nativeDate)("format", ctx_r1325.timeOptions.nzFormat)("nzHourStep", ctx_r1325.timeOptions.nzHourStep)("nzMinuteStep", ctx_r1325.timeOptions.nzMinuteStep)("nzSecondStep", ctx_r1325.timeOptions.nzSecondStep)("nzDisabledHours", ctx_r1325.timeOptions.nzDisabledHours)("nzDisabledMinutes", ctx_r1325.timeOptions.nzDisabledMinutes)("nzDisabledSeconds", ctx_r1325.timeOptions.nzDisabledSeconds)("nzHideDisabledOptions", ctx_r1325.timeOptions.nzHideDisabledOptions)("nzDefaultOpenValue", ctx_r1325.timeOptions.nzDefaultOpenValue)("nzUse12Hours", ctx_r1325.timeOptions.nzUse12Hours)("nzAddOn", ctx_r1325.timeOptions.nzAddOn)("opened", true);
} }
export class InnerPopupComponent {
    constructor() {
        this.panelModeChange = new EventEmitter();
        // TODO: name is not proper
        this.headerChange = new EventEmitter(); // Emitted when user changed the header's value
        this.selectDate = new EventEmitter(); // Emitted when the date is selected by click the date panel
        this.selectTime = new EventEmitter();
        this.dayHover = new EventEmitter(); // Emitted when hover on a day by mouse enter
        this.prefixCls = PREFIX_CLASS;
    }
    onSelectTime(date) {
        this.selectTime.emit(new CandyDate(date));
    }
    // The value real changed to outside
    onSelectDate(date) {
        const value = date instanceof CandyDate ? date : new CandyDate(date);
        const timeValue = this.timeOptions && this.timeOptions.nzDefaultOpenValue;
        // Display timeValue when value is null
        if (!this.value && timeValue) {
            value.setHms(timeValue.getHours(), timeValue.getMinutes(), timeValue.getSeconds());
        }
        this.selectDate.emit(value);
    }
    onChooseMonth(value) {
        this.activeDate = this.activeDate.setMonth(value.getMonth());
        if (this.endPanelMode === 'month') {
            this.value = value;
            this.selectDate.emit(value);
        }
        else {
            this.panelModeChange.emit(this.endPanelMode);
        }
    }
    onChooseYear(value) {
        this.activeDate = this.activeDate.setYear(value.getYear());
        if (this.endPanelMode === 'year') {
            this.value = value;
            this.selectDate.emit(value);
        }
        else {
            this.panelModeChange.emit(this.endPanelMode);
        }
    }
    onChooseDecade(value) {
        this.activeDate = this.activeDate.setYear(value.getYear());
        if (this.endPanelMode === 'decade') {
            this.value = value;
            this.selectDate.emit(value);
        }
        else {
            this.panelModeChange.emit('year');
        }
    }
    ngOnChanges(changes) {
        if (changes.activeDate && !changes.activeDate.currentValue) {
            this.activeDate = new CandyDate();
        }
        // New Antd vesion has merged 'date' ant 'time' to one panel,
        // So there is not 'time' panel
        if (changes.panelMode && changes.panelMode.currentValue === 'time') {
            this.panelMode = 'date';
        }
    }
}
/** @nocollapse */ InnerPopupComponent.ɵfac = function InnerPopupComponent_Factory(t) { return new (t || InnerPopupComponent)(); };
/** @nocollapse */ InnerPopupComponent.ɵcmp = i0.ɵɵdefineComponent({ type: InnerPopupComponent, selectors: [["inner-popup"]], inputs: { activeDate: "activeDate", endPanelMode: "endPanelMode", panelMode: "panelMode", showWeek: "showWeek", locale: "locale", showTimePicker: "showTimePicker", timeOptions: "timeOptions", enablePrev: "enablePrev", enableNext: "enableNext", disabledDate: "disabledDate", dateRender: "dateRender", selectedValue: "selectedValue", hoverValue: "hoverValue", value: "value" }, outputs: { panelModeChange: "panelModeChange", headerChange: "headerChange", selectDate: "selectDate", selectTime: "selectTime", dayHover: "dayHover" }, exportAs: ["innerPopup"], features: [i0.ɵɵNgOnChangesFeature], decls: 8, vars: 11, consts: [[3, "ngSwitch"], [4, "ngSwitchCase"], [4, "ngSwitchDefault"], [4, "ngIf"], [3, "value", "locale", "showNextBtn", "showPreBtn", "valueChange", "panelModeChange"], [3, "showWeek", "activeDate", "value", "disabledDate", "cellRender", "valueChange"], [3, "showWeek", "value", "activeDate", "disabledDate", "cellRender", "dayHover", "valueChange"], [3, "value", "locale", "valueChange", "panelModeChange"], [3, "locale", "showWeek", "value", "activeDate", "disabledDate", "cellRender", "selectedValue", "hoverValue", "valueChange", "dayHover"], [3, "nzInDatePicker", "ngModel", "format", "nzHourStep", "nzMinuteStep", "nzSecondStep", "nzDisabledHours", "nzDisabledMinutes", "nzDisabledSeconds", "nzHideDisabledOptions", "nzDefaultOpenValue", "nzUse12Hours", "nzAddOn", "opened", "ngModelChange"]], template: function InnerPopupComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "div");
        i0.ɵɵelementStart(1, "div");
        i0.ɵɵelementContainerStart(2, 0);
        i0.ɵɵtemplate(3, InnerPopupComponent_ng_container_3_Template, 4, 12, "ng-container", 1);
        i0.ɵɵtemplate(4, InnerPopupComponent_ng_container_4_Template, 4, 12, "ng-container", 1);
        i0.ɵɵtemplate(5, InnerPopupComponent_ng_container_5_Template, 4, 12, "ng-container", 1);
        i0.ɵɵtemplate(6, InnerPopupComponent_ng_container_6_Template, 4, 13, "ng-container", 2);
        i0.ɵɵelementContainerEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(7, InnerPopupComponent_ng_container_7_Template, 2, 14, "ng-container", 3);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵclassProp("ant-picker-datetime-panel", ctx.showTimePicker);
        i0.ɵɵadvance(1);
        i0.ɵɵclassMapInterpolate2("", ctx.prefixCls, "-", ctx.panelMode, "-panel");
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngSwitch", ctx.panelMode);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngSwitchCase", "decade");
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngSwitchCase", "year");
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngSwitchCase", "month");
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.showTimePicker && ctx.timeOptions);
    } }, directives: [i1.NgSwitch, i1.NgSwitchCase, i1.NgSwitchDefault, i1.NgIf, i2.DecadeHeaderComponent, i3.DecadeTableComponent, i4.YearHeaderComponent, i5.YearTableComponent, i6.MonthHeaderComponent, i7.MonthTableComponent, i8.DateHeaderComponent, i9.DateTableComponent, i10.NzTimePickerPanelComponent, i11.NgControlStatus, i11.NgModel], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(InnerPopupComponent, [{
        type: Component,
        args: [{
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
                // tslint:disable-next-line:component-selector
                selector: 'inner-popup',
                exportAs: 'innerPopup',
                template: `
    <div [class.ant-picker-datetime-panel]="showTimePicker">
      <div class="{{ prefixCls }}-{{ panelMode }}-panel">
        <ng-container [ngSwitch]="panelMode">
          <ng-container *ngSwitchCase="'decade'">
            <decade-header
              [(value)]="activeDate"
              [locale]="locale"
              [showNextBtn]="false"
              [showPreBtn]="false"
              (panelModeChange)="panelModeChange.emit($event)"
              (valueChange)="headerChange.emit($event)"
            >
            </decade-header>
            <div class="{{ prefixCls }}-body">
              <decade-table
                [showWeek]="showWeek"
                [activeDate]="activeDate"
                [value]="value"
                (valueChange)="onChooseDecade($event)"
                [disabledDate]="disabledDate"
                [cellRender]="dateRender"
              ></decade-table>
            </div>
          </ng-container>
          <ng-container *ngSwitchCase="'year'">
            <year-header
              [(value)]="activeDate"
              [locale]="locale"
              [showNextBtn]="false"
              [showPreBtn]="false"
              (panelModeChange)="panelModeChange.emit($event)"
              (valueChange)="headerChange.emit($event)"
            >
            </year-header>
            <div class="{{ prefixCls }}-body">
              <year-table
                [showWeek]="showWeek"
                [activeDate]="activeDate"
                [value]="value"
                (valueChange)="onChooseYear($event)"
                [disabledDate]="disabledDate"
                [cellRender]="dateRender"
              ></year-table>
            </div>
          </ng-container>
          <ng-container *ngSwitchCase="'month'">
            <month-header
              [(value)]="activeDate"
              [locale]="locale"
              [showNextBtn]="false"
              [showPreBtn]="false"
              (panelModeChange)="panelModeChange.emit($event)"
              (valueChange)="headerChange.emit($event)"
            >
            </month-header>
            <div class="{{ prefixCls }}-body">
              <month-table
                [showWeek]="showWeek"
                [value]="value"
                [activeDate]="activeDate"
                [disabledDate]="disabledDate"
                [cellRender]="dateRender"
                (dayHover)="dayHover.emit($event)"
                (valueChange)="onChooseMonth($event)"
              ></month-table>
            </div>
          </ng-container>

          <ng-container *ngSwitchDefault>
            <date-header
              [(value)]="activeDate"
              [locale]="locale"
              (panelModeChange)="panelModeChange.emit($event)"
              (valueChange)="headerChange.emit($event)"
            >
            </date-header>
            <div class="{{ prefixCls }}-body">
              <date-table
                [locale]="locale"
                [showWeek]="showWeek"
                [value]="value"
                [activeDate]="activeDate"
                (valueChange)="onSelectDate($event)"
                [disabledDate]="disabledDate"
                [cellRender]="dateRender"
                [selectedValue]="selectedValue"
                [hoverValue]="hoverValue"
                (dayHover)="dayHover.emit($event)"
              ></date-table>
            </div>
          </ng-container>
        </ng-container>
      </div>
      <ng-container *ngIf="showTimePicker && timeOptions">
        <nz-time-picker-panel
          [nzInDatePicker]="true"
          [ngModel]="value?.nativeDate"
          (ngModelChange)="onSelectTime($event)"
          [format]="timeOptions.nzFormat"
          [nzHourStep]="timeOptions.nzHourStep"
          [nzMinuteStep]="timeOptions.nzMinuteStep"
          [nzSecondStep]="timeOptions.nzSecondStep"
          [nzDisabledHours]="timeOptions.nzDisabledHours"
          [nzDisabledMinutes]="timeOptions.nzDisabledMinutes"
          [nzDisabledSeconds]="timeOptions.nzDisabledSeconds"
          [nzHideDisabledOptions]="timeOptions.nzHideDisabledOptions"
          [nzDefaultOpenValue]="timeOptions.nzDefaultOpenValue"
          [nzUse12Hours]="timeOptions.nzUse12Hours"
          [nzAddOn]="timeOptions.nzAddOn"
          [opened]="true"
        ></nz-time-picker-panel>
        <!-- use [opened] to trigger time panel \`initPosition()\` -->
      </ng-container>
    </div>
  `
            }]
    }], null, { activeDate: [{
            type: Input
        }], endPanelMode: [{
            type: Input
        }], panelMode: [{
            type: Input
        }], showWeek: [{
            type: Input
        }], locale: [{
            type: Input
        }], showTimePicker: [{
            type: Input
        }], timeOptions: [{
            type: Input
        }], enablePrev: [{
            type: Input
        }], enableNext: [{
            type: Input
        }], disabledDate: [{
            type: Input
        }], dateRender: [{
            type: Input
        }], selectedValue: [{
            type: Input
        }], hoverValue: [{
            type: Input
        }], value: [{
            type: Input
        }], panelModeChange: [{
            type: Output
        }], headerChange: [{
            type: Output
        }], selectDate: [{
            type: Output
        }], selectTime: [{
            type: Output
        }], dayHover: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 