import { FocusMonitor } from '@angular/cdk/a11y';
import { Directionality } from '@angular/cdk/bidi';
import { DOWN_ARROW, UP_ARROW } from '@angular/cdk/keycodes';
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { input, numberAttribute, booleanAttribute, output, inject, viewChild, ElementRef, Injector, signal, linkedSignal, contentChild, computed, DestroyRef, afterNextRender, forwardRef, Component, ChangeDetectionStrategy, ViewEncapsulation, NgModule } from '@angular/core';
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { NzFormStatusService, NzFormItemFeedbackIconComponent } from 'ng-zorro-antd/core/form';
import { isNil, getStatusClassNames } from 'ng-zorro-antd/core/util';
import * as i2 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzInputPrefixDirective, NzInputSuffixDirective, NzInputAddonBeforeDirective, NzInputAddonAfterDirective } from 'ng-zorro-antd/input';
import * as i1 from 'ng-zorro-antd/space';
import { NZ_SPACE_COMPACT_SIZE, NZ_SPACE_COMPACT_ITEM_TYPE, NzSpaceCompactItemDirective } from 'ng-zorro-antd/space';

/**
 * 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
 */
class NzInputNumberComponent {
    constructor() {
        this.nzId = input(null);
        this.nzSize = input('default');
        this.nzPlaceHolder = input(null);
        this.nzStatus = input('');
        this.nzStep = input(1, { transform: numberAttribute });
        this.nzMin = input(Number.MIN_SAFE_INTEGER, { transform: numberAttribute });
        this.nzMax = input(Number.MAX_SAFE_INTEGER, { transform: numberAttribute });
        this.nzPrecision = input(null);
        this.nzParser = input(value => {
            const parsedValue = defaultParser(value);
            const precision = this.nzPrecision();
            if (!isNil(precision)) {
                return +parsedValue.toFixed(precision);
            }
            return parsedValue;
        });
        this.nzFormatter = input(value => {
            const precision = this.nzPrecision();
            if (!isNil(precision)) {
                return value.toFixed(precision);
            }
            return value.toString();
        });
        this.nzDisabled = input(false, { transform: booleanAttribute });
        this.nzReadOnly = input(false, { transform: booleanAttribute });
        this.nzAutoFocus = input(false, { transform: booleanAttribute });
        this.nzBordered = input(true, { transform: booleanAttribute });
        this.nzKeyboard = input(true, { transform: booleanAttribute });
        this.nzControls = input(true, { transform: booleanAttribute });
        this.nzOnStep = output();
        this.onChange = () => { };
        this.onTouched = () => { };
        this.compactSize = inject(NZ_SPACE_COMPACT_SIZE, { optional: true });
        this.inputRef = viewChild.required('input');
        this.hostRef = viewChild('inputNumberHost');
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
        this.focusMonitor = inject(FocusMonitor);
        this.directionality = inject(Directionality);
        this.nzFormStatusService = inject(NzFormStatusService, { optional: true });
        this.autoStepTimer = null;
        this.value = signal(null);
        this.displayValue = signal('');
        this.dir = toSignal(this.directionality.change, { initialValue: this.directionality.value });
        this.focused = signal(false);
        this.hasFeedback = signal(false);
        this.finalStatus = linkedSignal(() => this.nzStatus());
        this.finalDisabled = linkedSignal(() => this.nzDisabled());
        this.prefix = contentChild(NzInputPrefixDirective);
        this.suffix = contentChild(NzInputSuffixDirective);
        this.addonBefore = contentChild(NzInputAddonBeforeDirective);
        this.addonAfter = contentChild(NzInputAddonAfterDirective);
        this.hasAffix = computed(() => !!this.prefix() || !!this.suffix() || this.hasFeedback());
        this.hasAddon = computed(() => !!this.addonBefore() || !!this.addonAfter());
        this.class = computed(() => {
            if (this.hasAddon()) {
                return this.groupWrapperClass();
            }
            if (this.hasAffix()) {
                return this.affixWrapperClass();
            }
            return this.inputNumberClass();
        });
        this.inputNumberClass = computed(() => {
            return {
                'ant-input-number': true,
                'ant-input-number-lg': this.finalSize() === 'large',
                'ant-input-number-sm': this.finalSize() === 'small',
                'ant-input-number-disabled': this.finalDisabled(),
                'ant-input-number-readonly': this.nzReadOnly(),
                'ant-input-number-borderless': !this.nzBordered(),
                'ant-input-number-focused': this.focused(),
                'ant-input-number-rtl': this.dir() === 'rtl',
                'ant-input-number-in-form-item': !!this.nzFormStatusService,
                'ant-input-number-out-of-range': this.value() !== null && !isInRange(this.value(), this.nzMin(), this.nzMax()),
                ...getStatusClassNames('ant-input-number', this.finalStatus(), this.hasFeedback())
            };
        });
        this.affixWrapperClass = computed(() => {
            return {
                'ant-input-number-affix-wrapper': true,
                'ant-input-number-affix-wrapper-disabled': this.finalDisabled(),
                'ant-input-number-affix-wrapper-readonly': this.nzReadOnly(),
                'ant-input-number-affix-wrapper-borderless': !this.nzBordered(),
                'ant-input-number-affix-wrapper-focused': this.focused(),
                'ant-input-number-affix-wrapper-rtl': this.dir() === 'rtl',
                ...getStatusClassNames('ant-input-number-affix-wrapper', this.finalStatus(), this.hasFeedback())
            };
        });
        this.groupWrapperClass = computed(() => {
            return {
                'ant-input-number-group-wrapper': true,
                'ant-input-number-group-wrapper-rtl': this.dir() === 'rtl',
                ...getStatusClassNames('ant-input-number-group-wrapper', this.finalStatus(), this.hasFeedback())
            };
        });
        this.finalSize = computed(() => {
            if (this.compactSize) {
                return this.compactSize();
            }
            return this.nzSize();
        });
        this.upDisabled = computed(() => {
            return !isNil(this.value()) && this.value() >= this.nzMax();
        });
        this.downDisabled = computed(() => {
            return !isNil(this.value()) && this.value() <= this.nzMin();
        });
        const destroyRef = inject(DestroyRef);
        afterNextRender(() => {
            const hostRef = this.hostRef();
            const element = hostRef ? hostRef : this.elementRef;
            this.focusMonitor
                .monitor(element, true)
                .pipe(takeUntilDestroyed(destroyRef))
                .subscribe(origin => {
                this.focused.set(!!origin);
                if (!origin) {
                    this.onTouched();
                }
            });
            destroyRef.onDestroy(() => {
                this.focusMonitor.stopMonitoring(element);
            });
        });
        this.nzFormStatusService?.formStatusChanges.pipe(takeUntilDestroyed()).subscribe(({ status, hasFeedback }) => {
            this.finalStatus.set(status);
            this.hasFeedback.set(hasFeedback);
        });
    }
    ngOnInit() {
        if (this.nzAutoFocus()) {
            afterNextRender(() => this.focus(), { injector: this.injector });
        }
    }
    writeValue(value) {
        this.setValue(value);
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    setDisabledState(disabled) {
        this.finalDisabled.set(disabled);
    }
    focus() {
        this.inputRef().nativeElement.focus();
    }
    blur() {
        this.inputRef().nativeElement.blur();
    }
    step(event, up) {
        // Ignore step since out of range
        if ((up && this.upDisabled()) || (!up && this.downDisabled())) {
            return;
        }
        // When hold the shift key, the step is 10 times
        let step = event.shiftKey ? this.nzStep() * 10 : this.nzStep();
        if (!up) {
            step = -step;
        }
        const places = getDecimalPlaces(step);
        const multiple = Math.pow(10, places);
        // Convert floating point numbers to integers to avoid floating point math errors
        this.setValue((Math.round((this.value() || 0) * multiple) + Math.round(step * multiple)) / multiple);
        this.nzOnStep.emit({
            type: up ? 'up' : 'down',
            value: this.value(),
            offset: this.nzStep()
        });
        this.focus();
    }
    setValue(value, userTyping) {
        let parsedValue = null;
        if (!isNil(value)) {
            parsedValue = this.nzParser()(value.toString());
            // If the user is typing, we need to make sure the value is in the range.
            // Instead, we allow values to be set out of range programmatically,
            // and display out-of-range values as errors.
            if (userTyping) {
                if (Number.isNaN(parsedValue)) {
                    parsedValue = null;
                }
                else {
                    parsedValue = getRangeValueWithPrecision(parsedValue, this.nzMin(), this.nzMax(), this.nzPrecision());
                }
            }
        }
        this.value.set(parsedValue);
        this.displayValue.set(parsedValue === null ? '' : this.nzFormatter()(parsedValue));
        this.onChange(parsedValue);
    }
    stopAutoStep() {
        if (this.autoStepTimer !== null) {
            clearTimeout(this.autoStepTimer);
            this.autoStepTimer = null;
        }
    }
    onStepMouseDown(event, up) {
        event.preventDefault();
        this.stopAutoStep();
        this.step(event, up);
        // Loop step for interval
        const loopStep = () => {
            this.step(event, up);
            this.autoStepTimer = setTimeout(loopStep, STEP_INTERVAL);
        };
        // First time press will wait some time to trigger loop step update
        this.autoStepTimer = setTimeout(loopStep, STEP_DELAY);
    }
    onKeyDown(event) {
        switch (event.keyCode) {
            case UP_ARROW:
                event.preventDefault();
                this.nzKeyboard() && this.step(event, true);
                break;
            case DOWN_ARROW:
                event.preventDefault();
                this.nzKeyboard() && this.step(event, false);
                break;
        }
    }
    onInputChange(value) {
        const target = value.target;
        this.setValue(target.value, true);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NzInputNumberComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: NzInputNumberComponent, isStandalone: true, selector: "nz-input-number", inputs: { nzId: { classPropertyName: "nzId", publicName: "nzId", isSignal: true, isRequired: false, transformFunction: null }, nzSize: { classPropertyName: "nzSize", publicName: "nzSize", isSignal: true, isRequired: false, transformFunction: null }, nzPlaceHolder: { classPropertyName: "nzPlaceHolder", publicName: "nzPlaceHolder", isSignal: true, isRequired: false, transformFunction: null }, nzStatus: { classPropertyName: "nzStatus", publicName: "nzStatus", isSignal: true, isRequired: false, transformFunction: null }, nzStep: { classPropertyName: "nzStep", publicName: "nzStep", isSignal: true, isRequired: false, transformFunction: null }, nzMin: { classPropertyName: "nzMin", publicName: "nzMin", isSignal: true, isRequired: false, transformFunction: null }, nzMax: { classPropertyName: "nzMax", publicName: "nzMax", isSignal: true, isRequired: false, transformFunction: null }, nzPrecision: { classPropertyName: "nzPrecision", publicName: "nzPrecision", isSignal: true, isRequired: false, transformFunction: null }, nzParser: { classPropertyName: "nzParser", publicName: "nzParser", isSignal: true, isRequired: false, transformFunction: null }, nzFormatter: { classPropertyName: "nzFormatter", publicName: "nzFormatter", isSignal: true, isRequired: false, transformFunction: null }, nzDisabled: { classPropertyName: "nzDisabled", publicName: "nzDisabled", isSignal: true, isRequired: false, transformFunction: null }, nzReadOnly: { classPropertyName: "nzReadOnly", publicName: "nzReadOnly", isSignal: true, isRequired: false, transformFunction: null }, nzAutoFocus: { classPropertyName: "nzAutoFocus", publicName: "nzAutoFocus", isSignal: true, isRequired: false, transformFunction: null }, nzBordered: { classPropertyName: "nzBordered", publicName: "nzBordered", isSignal: true, isRequired: false, transformFunction: null }, nzKeyboard: { classPropertyName: "nzKeyboard", publicName: "nzKeyboard", isSignal: true, isRequired: false, transformFunction: null }, nzControls: { classPropertyName: "nzControls", publicName: "nzControls", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nzOnStep: "nzOnStep" }, host: { listeners: { "keydown": "onKeyDown($event)" }, properties: { "class": "class()" } }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                useExisting: forwardRef(() => NzInputNumberComponent),
                multi: true
            },
            { provide: NZ_SPACE_COMPACT_ITEM_TYPE, useValue: 'input-number' }
        ], queries: [{ propertyName: "prefix", first: true, predicate: NzInputPrefixDirective, descendants: true, isSignal: true }, { propertyName: "suffix", first: true, predicate: NzInputSuffixDirective, descendants: true, isSignal: true }, { propertyName: "addonBefore", first: true, predicate: NzInputAddonBeforeDirective, descendants: true, isSignal: true }, { propertyName: "addonAfter", first: true, predicate: NzInputAddonAfterDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["input"], descendants: true, isSignal: true }, { propertyName: "hostRef", first: true, predicate: ["inputNumberHost"], descendants: true, isSignal: true }], exportAs: ["nzInputNumber"], hostDirectives: [{ directive: i1.NzSpaceCompactItemDirective }], ngImport: i0, template: `
    @if (hasAddon()) {
      <ng-template [ngTemplateOutlet]="inputNumberWithAddonInner" />
    } @else if (hasAffix()) {
      <ng-template [ngTemplateOutlet]="inputNumberWithAffixInner" />
    } @else {
      <ng-template [ngTemplateOutlet]="inputNumberInner" />
    }

    <ng-template #inputNumberWithAddonInner>
      <div class="ant-input-number-wrapper ant-input-number-group">
        @if (addonBefore()) {
          <div class="ant-input-number-group-addon">
            <ng-content select="[nzInputAddonBefore]"></ng-content>
          </div>
        }

        @if (hasAffix()) {
          <ng-template [ngTemplateOutlet]="inputNumberWithAffix" />
        } @else {
          <ng-template [ngTemplateOutlet]="inputNumber" />
        }

        @if (addonAfter()) {
          <div class="ant-input-number-group-addon">
            <ng-content select="[nzInputAddonAfter]"></ng-content>
          </div>
        }
      </div>
    </ng-template>

    <ng-template #inputNumberWithAffix>
      <div [class]="affixWrapperClass()">
        <ng-template [ngTemplateOutlet]="inputNumberWithAffixInner" />
      </div>
    </ng-template>

    <ng-template #inputNumberWithAffixInner>
      @if (prefix()) {
        <span class="ant-input-number-prefix">
          <ng-content select="[nzInputPrefix]"></ng-content>
        </span>
      }
      <ng-template [ngTemplateOutlet]="inputNumber" />
      @if (suffix() || hasFeedback()) {
        <span class="ant-input-number-suffix">
          <ng-content select="[nzInputSuffix]"></ng-content>
          @if (hasFeedback() && finalStatus()) {
            <nz-form-item-feedback-icon [status]="finalStatus()" />
          }
        </span>
      }
    </ng-template>

    <ng-template #inputNumber>
      <div #inputNumberHost [class]="inputNumberClass()">
        <ng-template [ngTemplateOutlet]="inputNumberInner" />
      </div>
    </ng-template>

    <ng-template #inputNumberInner>
      @if (nzControls()) {
        <div #handlers class="ant-input-number-handler-wrap" (mouseup)="stopAutoStep()" (mouseleave)="stopAutoStep()">
          <span
            role="button"
            unselectable="on"
            class="ant-input-number-handler ant-input-number-handler-up"
            [class.ant-input-number-handler-up-disabled]="upDisabled()"
            [attr.aria-disabled]="upDisabled()"
            (mousedown)="onStepMouseDown($event, true)"
          >
            <ng-content select="[nzInputNumberUpIcon]">
              <nz-icon nzType="up" class="ant-input-number-handler-up-inner" />
            </ng-content>
          </span>
          <span
            role="button"
            unselectable="on"
            class="ant-input-number-handler ant-input-number-handler-down"
            [class.ant-input-number-handler-down-disabled]="downDisabled()"
            [attr.aria-disabled]="downDisabled()"
            (mousedown)="onStepMouseDown($event, false)"
          >
            <ng-content select="[nzInputNumberDownIcon]">
              <nz-icon nzType="down" class="ant-input-number-handler-down-inner" />
            </ng-content>
          </span>
        </div>
      }

      <div class="ant-input-number-input-wrap">
        <input
          #input
          autocomplete="off"
          role="spinbutton"
          class="ant-input-number-input"
          [attr.aria-valuemin]="nzMin()"
          [attr.aria-valuemax]="nzMax()"
          [attr.id]="nzId()"
          [value]="displayValue()"
          [attr.step]="nzStep()"
          [placeholder]="nzPlaceHolder() ?? ''"
          [disabled]="finalDisabled()"
          [readOnly]="nzReadOnly()"
          (input)="displayValue.set(input.value)"
          (change)="onInputChange($event)"
        />
      </div>
    </ng-template>
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "component", type: NzFormItemFeedbackIconComponent, selector: "nz-form-item-feedback-icon", inputs: ["status"], exportAs: ["nzFormFeedbackIcon"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NzInputNumberComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'nz-input-number',
                    exportAs: 'nzInputNumber',
                    imports: [NzIconModule, NzFormItemFeedbackIconComponent, NgTemplateOutlet],
                    template: `
    @if (hasAddon()) {
      <ng-template [ngTemplateOutlet]="inputNumberWithAddonInner" />
    } @else if (hasAffix()) {
      <ng-template [ngTemplateOutlet]="inputNumberWithAffixInner" />
    } @else {
      <ng-template [ngTemplateOutlet]="inputNumberInner" />
    }

    <ng-template #inputNumberWithAddonInner>
      <div class="ant-input-number-wrapper ant-input-number-group">
        @if (addonBefore()) {
          <div class="ant-input-number-group-addon">
            <ng-content select="[nzInputAddonBefore]"></ng-content>
          </div>
        }

        @if (hasAffix()) {
          <ng-template [ngTemplateOutlet]="inputNumberWithAffix" />
        } @else {
          <ng-template [ngTemplateOutlet]="inputNumber" />
        }

        @if (addonAfter()) {
          <div class="ant-input-number-group-addon">
            <ng-content select="[nzInputAddonAfter]"></ng-content>
          </div>
        }
      </div>
    </ng-template>

    <ng-template #inputNumberWithAffix>
      <div [class]="affixWrapperClass()">
        <ng-template [ngTemplateOutlet]="inputNumberWithAffixInner" />
      </div>
    </ng-template>

    <ng-template #inputNumberWithAffixInner>
      @if (prefix()) {
        <span class="ant-input-number-prefix">
          <ng-content select="[nzInputPrefix]"></ng-content>
        </span>
      }
      <ng-template [ngTemplateOutlet]="inputNumber" />
      @if (suffix() || hasFeedback()) {
        <span class="ant-input-number-suffix">
          <ng-content select="[nzInputSuffix]"></ng-content>
          @if (hasFeedback() && finalStatus()) {
            <nz-form-item-feedback-icon [status]="finalStatus()" />
          }
        </span>
      }
    </ng-template>

    <ng-template #inputNumber>
      <div #inputNumberHost [class]="inputNumberClass()">
        <ng-template [ngTemplateOutlet]="inputNumberInner" />
      </div>
    </ng-template>

    <ng-template #inputNumberInner>
      @if (nzControls()) {
        <div #handlers class="ant-input-number-handler-wrap" (mouseup)="stopAutoStep()" (mouseleave)="stopAutoStep()">
          <span
            role="button"
            unselectable="on"
            class="ant-input-number-handler ant-input-number-handler-up"
            [class.ant-input-number-handler-up-disabled]="upDisabled()"
            [attr.aria-disabled]="upDisabled()"
            (mousedown)="onStepMouseDown($event, true)"
          >
            <ng-content select="[nzInputNumberUpIcon]">
              <nz-icon nzType="up" class="ant-input-number-handler-up-inner" />
            </ng-content>
          </span>
          <span
            role="button"
            unselectable="on"
            class="ant-input-number-handler ant-input-number-handler-down"
            [class.ant-input-number-handler-down-disabled]="downDisabled()"
            [attr.aria-disabled]="downDisabled()"
            (mousedown)="onStepMouseDown($event, false)"
          >
            <ng-content select="[nzInputNumberDownIcon]">
              <nz-icon nzType="down" class="ant-input-number-handler-down-inner" />
            </ng-content>
          </span>
        </div>
      }

      <div class="ant-input-number-input-wrap">
        <input
          #input
          autocomplete="off"
          role="spinbutton"
          class="ant-input-number-input"
          [attr.aria-valuemin]="nzMin()"
          [attr.aria-valuemax]="nzMax()"
          [attr.id]="nzId()"
          [value]="displayValue()"
          [attr.step]="nzStep()"
          [placeholder]="nzPlaceHolder() ?? ''"
          [disabled]="finalDisabled()"
          [readOnly]="nzReadOnly()"
          (input)="displayValue.set(input.value)"
          (change)="onInputChange($event)"
        />
      </div>
    </ng-template>
  `,
                    providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => NzInputNumberComponent),
                            multi: true
                        },
                        { provide: NZ_SPACE_COMPACT_ITEM_TYPE, useValue: 'input-number' }
                    ],
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    encapsulation: ViewEncapsulation.None,
                    host: {
                        '[class]': 'class()',
                        '(keydown)': 'onKeyDown($event)'
                    },
                    hostDirectives: [NzSpaceCompactItemDirective]
                }]
        }], ctorParameters: () => [] });
/**
 * When click and hold on a button - the speed of auto changing the value.
 */
const STEP_INTERVAL = 200;
/**
 * When click and hold on a button - the delay before auto changing the value.
 */
const STEP_DELAY = 600;
function defaultParser(value) {
    return +value.trim().replace(/。/g, '.');
    // [Legacy] We still support auto convert `$ 123,456` to `123456`
    // .replace(/[^\w.-]+/g, '');
}
function isInRange(value, min, max) {
    return value >= min && value <= max;
}
function getRangeValue(value, min, max) {
    if (value < min) {
        return min;
    }
    if (value > max) {
        return max;
    }
    return value;
}
/**
 * if max > 0, round down with precision. Example: input= 3.5, max= 3.5, precision=0; output= 3
 * if max < 0, round up with precision.   Example: input=-3.5, max=-3.5, precision=0; output=-4
 * if min > 0, round up with precision.   Example: input= 3.5, min= 3.5, precision=0; output= 4
 * if min < 0, round down with precision. Example: input=-3.5, min=-3.5, precision=0; output=-3
 */
function getRangeValueWithPrecision(value, min, max, precision) {
    if (precision === null) {
        return getRangeValue(value, min, max);
    }
    const fixedValue = +value.toFixed(precision);
    const multiple = Math.pow(10, precision);
    if (fixedValue < min) {
        return Math.ceil(min * multiple) / multiple;
    }
    if (fixedValue > max) {
        return Math.floor(max * multiple) / multiple;
    }
    return fixedValue;
}
function getDecimalPlaces(num) {
    return num.toString().split('.')[1]?.length || 0;
}

/**
 * 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
 */
class NzInputNumberModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NzInputNumberModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.1", ngImport: i0, type: NzInputNumberModule, imports: [NzInputNumberComponent,
            NzInputAddonBeforeDirective,
            NzInputAddonAfterDirective,
            NzInputPrefixDirective,
            NzInputSuffixDirective], exports: [NzInputNumberComponent,
            NzInputAddonBeforeDirective,
            NzInputAddonAfterDirective,
            NzInputPrefixDirective,
            NzInputSuffixDirective] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NzInputNumberModule, imports: [NzInputNumberComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NzInputNumberModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        NzInputNumberComponent,
                        NzInputAddonBeforeDirective,
                        NzInputAddonAfterDirective,
                        NzInputPrefixDirective,
                        NzInputSuffixDirective
                    ],
                    exports: [
                        NzInputNumberComponent,
                        NzInputAddonBeforeDirective,
                        NzInputAddonAfterDirective,
                        NzInputPrefixDirective,
                        NzInputSuffixDirective
                    ]
                }]
        }] });

/**
 * 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
 */

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

export { NzInputNumberComponent, NzInputNumberModule };
//# sourceMappingURL=ng-zorro-antd-input-number.mjs.map
