var _subscription, _setType;
import { __classPrivateFieldGet } from "tslib";
import { Component, Input, TemplateRef, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ZuiB } from '@material-zui/core';
import { Subscription } from 'rxjs';
export class ZUIDialogComponent {
    constructor(dialog) {
        this.dialog = dialog;
        this.type = 'normal';
        this.width = '400px';
        this.showCloseIcon = true;
        _subscription.set(this, new Subscription());
        _setType.set(this, () => {
            switch (this.type) {
                case 'success':
                    this.status = {
                        icon: 'check_circle',
                        color: '#28a745',
                    };
                    break;
                case 'danger':
                    this.status = {
                        icon: 'dangerous',
                        color: '#dc3545',
                    };
                    break;
                case 'info':
                    this.status = {
                        icon: 'info',
                        color: '#17a2b8',
                    };
                    break;
                case 'warning':
                    this.status = {
                        icon: 'warning',
                        color: '#ffc107',
                    };
                    break;
            }
        });
        this.open = (config = {}) => {
            this.dialogRef = this.dialog.open(this.templateRef, config);
            this.data = config === null || config === void 0 ? void 0 : config.data;
        };
        this.afterClosed = (callBack) => {
            __classPrivateFieldGet(this, _subscription).add(this.dialogRef.afterClosed().subscribe(data => callBack(data)));
        };
        this.close = (dialogResult, closeAll = false) => {
            closeAll ? this.dialog.closeAll() : this.dialogRef.close(dialogResult);
        };
    }
    set hideCloseIcon(val) {
        this.showCloseIcon = ZuiB.toBoolReverse(val);
    }
    ngOnChanges() {
        __classPrivateFieldGet(this, _setType).call(this);
    }
    ngOnDestroy() {
        __classPrivateFieldGet(this, _subscription).unsubscribe();
    }
}
_subscription = new WeakMap(), _setType = new WeakMap();
ZUIDialogComponent.decorators = [
    { type: Component, args: [{
                selector: 'zui-dialog',
                template: "<ng-template #templateRef>\n  <div [ngStyle]=\"{width: width}\">\n    <div *ngIf=\"title\" class=\"d-flex align-items-center\">\n      <mat-icon *ngIf=\"status?.icon\" [ngStyle]=\"{color: status.color}\" class=\"mr-5\">{{ status.icon }}</mat-icon>\n      <h3 mat-dialog-title class=\"m-0 d-flex-1 zui-fw-500\">{{ title }}</h3>\n      <mat-icon *ngIf=\"showCloseIcon\" class=\"zui-pointer\" (click)=\"close(data)\">close</mat-icon>\n    </div>\n    <ng-content></ng-content>\n  </div>\n</ng-template>\n",
                styles: [""]
            },] }
];
ZUIDialogComponent.ctorParameters = () => [
    { type: MatDialog }
];
ZUIDialogComponent.propDecorators = {
    title: [{ type: Input }],
    type: [{ type: Input }],
    width: [{ type: Input }],
    hideCloseIcon: [{ type: Input }],
    templateRef: [{ type: ViewChild, args: ['templateRef',] }]
};
//# sourceMappingURL=index.component.js.map