import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import * as $ from 'jquery';
import { ZUILoadingTypeComponent } from './type/index.component';
import * as i0 from "@angular/core";
import * as i1 from "./index";
import * as i2 from "@angular/material/dialog";
export class ZuiLoadingService {
    constructor(dialog) {
        this.dialog = dialog;
        this.config = { disableClose: true, panelClass: 'zui-loading-content', data: { type: 'spinner' } };
        this.setConfig = (data, config = {}) => {
            this.config = Object.assign(Object.assign(Object.assign({}, this.config), config), { data });
        };
        this.start = (data) => {
            let config = Object.assign({}, this.config);
            if (data)
                config = Object.assign(Object.assign({}, config), { data });
            this.dialogRef = this.dialog.open(ZUILoadingTypeComponent, config);
            this.dialogRef.beforeClosed().subscribe(() => $('.zui-loading-content-progress-bar').css({ display: 'none' }));
        };
        /**
         * @param isClose condition to close loading, default true
         */
        this.close = (isClose = true) => {
            var _a;
            if (isClose)
                (_a = this.dialogRef) === null || _a === void 0 ? void 0 : _a.close();
        };
    }
}
ZuiLoadingService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ZuiLoadingService_Factory() { return new i1.ZuiLoadingService(i0.ɵɵinject(i2.MatDialog)); }, token: i1.ZuiLoadingService, providedIn: "root" });
ZuiLoadingService.decorators = [
    { type: Injectable, args: [{ providedIn: 'root' },] }
];
ZuiLoadingService.ctorParameters = () => [
    { type: MatDialog }
];
//# sourceMappingURL=index.service.js.map