var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
var NzModalSubject = (function (_super) {
    __extends(NzModalSubject, _super);
    function NzModalSubject() {
        var _this = _super.call(this) || this;
        _this.eventsQueue = {};
        _this.subscribe(function (value) {
            var eventQueue = _this.eventsQueue[value] || [];
            eventQueue.forEach(function (cb) {
                if (cb) {
                    cb();
                }
            });
        });
        return _this;
    }
    NzModalSubject.prototype.destroy = function (type) {
        if (type === void 0) { type = 'onCancel'; }
        if (!this.isStopped && !this.closed) {
            this.next(type);
        }
    };
    NzModalSubject.prototype.on = function (eventType, cb) {
        if (this.eventsQueue[eventType]) {
            this.eventsQueue[eventType].push(cb);
        }
        else {
            this.eventsQueue[eventType] = [cb];
        }
    };
    return NzModalSubject;
}(Subject));
export { NzModalSubject };
NzModalSubject.decorators = [
    { type: Injectable },
];
/** @nocollapse */
NzModalSubject.ctorParameters = function () { return []; };
