import { __read, __spread } from "tslib";
/**
 * @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 { toNumber } from 'ng-zorro-antd/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "ng-zorro-antd/select";
import * as i3 from "@angular/forms";
var _c0 = ["nz-pagination-options", ""];
function NzPaginationOptionsComponent_nz_select_0_nz_option_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-option", 4);
} if (rf & 2) {
    var option_r2685 = ctx.$implicit;
    i0.ɵɵproperty("nzLabel", option_r2685.label)("nzValue", option_r2685.value);
} }
function NzPaginationOptionsComponent_nz_select_0_Template(rf, ctx) { if (rf & 1) {
    var _r2687 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "nz-select", 2);
    i0.ɵɵlistener("ngModelChange", function NzPaginationOptionsComponent_nz_select_0_Template_nz_select_ngModelChange_0_listener($event) { i0.ɵɵrestoreView(_r2687); var ctx_r2686 = i0.ɵɵnextContext(); return ctx_r2686.onPageSizeChange($event); });
    i0.ɵɵtemplate(1, NzPaginationOptionsComponent_nz_select_0_nz_option_1_Template, 1, 2, "nz-option", 3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2682 = i0.ɵɵnextContext();
    i0.ɵɵproperty("nzDisabled", ctx_r2682.disabled)("nzSize", ctx_r2682.nzSize)("ngModel", ctx_r2682.pageSize);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2682.listOfPageSizeOption)("ngForTrackBy", ctx_r2682.trackByOption);
} }
function NzPaginationOptionsComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    var _r2689 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "input", 6);
    i0.ɵɵlistener("keydown.enter", function NzPaginationOptionsComponent_div_1_Template_input_keydown_enter_2_listener($event) { i0.ɵɵrestoreView(_r2689); var ctx_r2688 = i0.ɵɵnextContext(); return ctx_r2688.jumpToPageViaInput($event); });
    i0.ɵɵelementEnd();
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2683 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r2683.locale.jump_to, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("disabled", ctx_r2683.disabled);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r2683.locale.page, " ");
} }
var NzPaginationOptionsComponent = /** @class */ (function () {
    function NzPaginationOptionsComponent() {
        this.nzSize = 'default';
        this.disabled = false;
        this.showSizeChanger = false;
        this.showQuickJumper = false;
        this.locale = {};
        this.total = 0;
        this.pageIndex = 1;
        this.pageSize = 10;
        this.pageSizeOptions = [];
        this.pageIndexChange = new EventEmitter();
        this.pageSizeChange = new EventEmitter();
        this.listOfPageSizeOption = [];
    }
    NzPaginationOptionsComponent.prototype.onPageSizeChange = function (size) {
        if (this.pageSize !== size) {
            this.pageSizeChange.next(size);
        }
    };
    NzPaginationOptionsComponent.prototype.jumpToPageViaInput = function ($event) {
        var target = $event.target;
        var index = toNumber(target.value, this.pageIndex);
        this.pageIndexChange.next(index);
        target.value = '';
    };
    NzPaginationOptionsComponent.prototype.trackByOption = function (_, option) {
        return option.value;
    };
    NzPaginationOptionsComponent.prototype.ngOnChanges = function (changes) {
        var _this = this;
        var pageSize = changes.pageSize, pageSizeOptions = changes.pageSizeOptions, locale = changes.locale;
        if (pageSize || pageSizeOptions || locale) {
            this.listOfPageSizeOption = __spread(new Set(__spread(this.pageSizeOptions, [this.pageSize]))).map(function (item) {
                return {
                    value: item,
                    label: item + " " + _this.locale.items_per_page
                };
            });
        }
    };
    /** @nocollapse */ NzPaginationOptionsComponent.ɵfac = function NzPaginationOptionsComponent_Factory(t) { return new (t || NzPaginationOptionsComponent)(); };
    /** @nocollapse */ NzPaginationOptionsComponent.ɵcmp = i0.ɵɵdefineComponent({ type: NzPaginationOptionsComponent, selectors: [["div", "nz-pagination-options", ""]], hostVars: 2, hostBindings: function NzPaginationOptionsComponent_HostBindings(rf, ctx) { if (rf & 2) {
            i0.ɵɵclassProp("ant-pagination-options", true);
        } }, inputs: { nzSize: "nzSize", disabled: "disabled", showSizeChanger: "showSizeChanger", showQuickJumper: "showQuickJumper", locale: "locale", total: "total", pageIndex: "pageIndex", pageSize: "pageSize", pageSizeOptions: "pageSizeOptions" }, outputs: { pageIndexChange: "pageIndexChange", pageSizeChange: "pageSizeChange" }, features: [i0.ɵɵNgOnChangesFeature], attrs: _c0, decls: 2, vars: 2, consts: [["class", "ant-pagination-options-size-changer", 3, "nzDisabled", "nzSize", "ngModel", "ngModelChange", 4, "ngIf"], ["class", "ant-pagination-options-quick-jumper", 4, "ngIf"], [1, "ant-pagination-options-size-changer", 3, "nzDisabled", "nzSize", "ngModel", "ngModelChange"], [3, "nzLabel", "nzValue", 4, "ngFor", "ngForOf", "ngForTrackBy"], [3, "nzLabel", "nzValue"], [1, "ant-pagination-options-quick-jumper"], [3, "disabled", "keydown.enter"]], template: function NzPaginationOptionsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, NzPaginationOptionsComponent_nz_select_0_Template, 2, 5, "nz-select", 0);
            i0.ɵɵtemplate(1, NzPaginationOptionsComponent_div_1_Template, 4, 3, "div", 1);
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.showSizeChanger);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.showQuickJumper);
        } }, directives: [i1.NgIf, i2.NzSelectComponent, i3.NgControlStatus, i3.NgModel, i1.NgForOf, i2.NzOptionComponent], encapsulation: 2, changeDetection: 0 });
    return NzPaginationOptionsComponent;
}());
export { NzPaginationOptionsComponent };
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(NzPaginationOptionsComponent, [{
        type: Component,
        args: [{
                selector: 'div[nz-pagination-options]',
                preserveWhitespaces: false,
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
                template: "\n    <nz-select\n      class=\"ant-pagination-options-size-changer\"\n      *ngIf=\"showSizeChanger\"\n      [nzDisabled]=\"disabled\"\n      [nzSize]=\"nzSize\"\n      [ngModel]=\"pageSize\"\n      (ngModelChange)=\"onPageSizeChange($event)\"\n    >\n      <nz-option\n        *ngFor=\"let option of listOfPageSizeOption; trackBy: trackByOption\"\n        [nzLabel]=\"option.label\"\n        [nzValue]=\"option.value\"\n      ></nz-option>\n    </nz-select>\n    <div class=\"ant-pagination-options-quick-jumper\" *ngIf=\"showQuickJumper\">\n      {{ locale.jump_to }}\n      <input [disabled]=\"disabled\" (keydown.enter)=\"jumpToPageViaInput($event)\" />\n      {{ locale.page }}\n    </div>\n  ",
                host: {
                    '[class.ant-pagination-options]': 'true'
                }
            }]
    }], null, { nzSize: [{
            type: Input
        }], disabled: [{
            type: Input
        }], showSizeChanger: [{
            type: Input
        }], showQuickJumper: [{
            type: Input
        }], locale: [{
            type: Input
        }], total: [{
            type: Input
        }], pageIndex: [{
            type: Input
        }], pageSize: [{
            type: Input
        }], pageSizeOptions: [{
            type: Input
        }], pageIndexChange: [{
            type: Output
        }], pageSizeChange: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 