import { MXBaseComponent } from '@acorex/cdk/common';
import '@acorex/components/decorators';
import { AXLoadingService } from '@acorex/components/loading';
import * as i0 from '@angular/core';
import { inject, EventEmitter, Input, Output, ViewChild, Injectable, Inject, NgModule } from '@angular/core';

class AXBasePageComponent extends MXBaseComponent {
    constructor() {
        super(...arguments);
        this._loadingService = inject(AXLoadingService);
        this.isLoadingChange = new EventEmitter();
        this._isLoading = false;
        this._isPopup = false;
        this.onClosed = new EventEmitter();
    }
    get isLoading() {
        return this._isLoading;
    }
    set isLoading(v) {
        this.setOption({
            name: 'isLoading',
            value: v,
            afterCallback: () => {
                if (this._loadingId && !v) {
                    this._loadingService.hide(this._loadingId);
                    this._loadingId = 0;
                }
                if (v) {
                    this._loadingId = this._loadingService.show({
                        location: this.getHostElement().closest('.ax-loading-container'),
                    });
                }
                this.cdr.markForCheck();
            },
        });
    }
    get isPopup() {
        return this._isPopup;
    }
    close(data) {
        this.onClosed.emit({
            component: this,
            data: data,
        });
    }
    onClosing(e) { }
    ngOnDestroy() {
        this.onClosed.unsubscribe();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXBasePageComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXBasePageComponent }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXBasePageComponent, decorators: [{
            type: Injectable
        }], propDecorators: { footer: [{
                type: ViewChild,
                args: ['ax-footer', { static: true }]
            }], isLoadingChange: [{
                type: Output
            }], isLoading: [{
                type: Input
            }] } });

class AXPageComponent extends MXBaseComponent {
    /** @ignore */
    constructor(_loadingService) {
        super();
        this._loadingService = _loadingService;
        /**
         * @event
         * Emits an event when the loading state changes.
         */
        this.isLoadingChange = new EventEmitter();
        /** @ignore */
        this._isLoading = false;
    }
    /**
     * Controls the loading state and visibility of the loading indicator.
     * @param {boolean} v
     */
    get isLoading() {
        return this._isLoading;
    }
    /**
     * Sets the loading state, showing or hiding the loading indicator based on the value.
     * @param {boolean} v
     */
    set isLoading(v) {
        this.setOption({
            name: 'isLoading',
            value: v,
            afterCallback: () => {
                if (this._loadingId && !v) {
                    this._loadingService.hide(this._loadingId);
                    this._loadingId = 0;
                }
                if (v) {
                    this._loadingId = this._loadingService.show(this.getHostElement());
                }
                this.cdr.markForCheck();
            },
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPageComponent, deps: [{ token: AXLoadingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPageComponent }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPageComponent, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [AXLoadingService]
                }] }], propDecorators: { isLoadingChange: [{
                type: Output
            }], isLoading: [{
                type: Input
            }] } });

// TODO: Module is empty!?
class AXPageModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: AXPageModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPageModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXPageModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [],
                    exports: [],
                    declarations: [],
                    providers: [],
                }]
        }] });

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

export { AXBasePageComponent, AXPageComponent, AXPageModule };
//# sourceMappingURL=acorex-components-page.mjs.map
