import { __esDecorate, __runInitializers } from 'tslib';
import { Directionality } from '@angular/cdk/bidi';
import { NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { inject, ChangeDetectorRef, DestroyRef, signal, booleanAttribute, numberAttribute, Input, ViewEncapsulation, Component, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { BehaviorSubject, ReplaySubject, of, Observable } from 'rxjs';
import { startWith, distinctUntilChanged, switchMap } from 'rxjs/operators';
import { WithConfig, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
const NZ_CONFIG_MODULE_NAME = 'spin';
let NzSpinComponent = (() => {
let _nzIndicator_decorators;
let _nzIndicator_initializers = [];
let _nzIndicator_extraInitializers = [];
return class NzSpinComponent {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_nzIndicator_decorators = [WithConfig()];
__esDecorate(null, null, _nzIndicator_decorators, { kind: "field", name: "nzIndicator", static: false, private: false, access: { has: obj => "nzIndicator" in obj, get: obj => obj.nzIndicator, set: (obj, value) => { obj.nzIndicator = value; } }, metadata: _metadata }, _nzIndicator_initializers, _nzIndicator_extraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
_nzModuleName = NZ_CONFIG_MODULE_NAME;
cdr = inject(ChangeDetectorRef);
directionality = inject(Directionality);
destroyRef = inject(DestroyRef);
nzIndicator = __runInitializers(this, _nzIndicator_initializers, null);
nzSize = (__runInitializers(this, _nzIndicator_extraInitializers), 'default');
nzTip = null;
nzDelay = 0;
nzSimple = false;
nzSpinning = true;
spinning$ = new BehaviorSubject(this.nzSpinning);
delay$ = new ReplaySubject(1);
isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
dir = 'ltr';
constructor() {
onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => this.cdr.markForCheck());
}
ngOnInit() {
this.delay$
.pipe(startWith(this.nzDelay), distinctUntilChanged(), switchMap(delay =>
// This construct is used to reduce RxJS dependencies.
// It previously used `debounce(() => timer())`, but consumers may not
// use these RxJS functions at all, causing them to still be bundled
// into the main bundle unnecessarily.
this.spinning$.pipe(switchMap(spinning => {
if (delay === 0 || !spinning) {
return of(spinning);
}
return new Observable(subscriber => {
const timeoutId = setTimeout(() => subscriber.next(spinning), delay);
return () => clearTimeout(timeoutId);
});
}))), takeUntilDestroyed(this.destroyRef))
.subscribe(isLoading => {
this.isLoading.set(isLoading);
});
this.directionality.change?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(direction => {
this.dir = direction;
this.cdr.detectChanges();
});
this.dir = this.directionality.value;
}
ngOnChanges(changes) {
const { nzSpinning, nzDelay } = changes;
if (nzSpinning) {
this.spinning$.next(this.nzSpinning);
}
if (nzDelay) {
this.delay$.next(this.nzDelay);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: NzSpinComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.0", type: NzSpinComponent, isStandalone: true, selector: "nz-spin", inputs: { nzIndicator: "nzIndicator", nzSize: "nzSize", nzTip: "nzTip", nzDelay: ["nzDelay", "nzDelay", numberAttribute], nzSimple: ["nzSimple", "nzSimple", booleanAttribute], nzSpinning: ["nzSpinning", "nzSpinning", booleanAttribute] }, host: { properties: { "class.ant-spin-nested-loading": "!nzSimple" } }, exportAs: ["nzSpin"], usesOnChanges: true, ngImport: i0, template: `