/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
var __extends=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)};define(["require","exports","../Utility/shallowCopy","../Disposable/DisposableBase","../Collections/Array/Utility","./EventDispatcherEntry","../Disposable/Utility"],function(t,e,i,r,n,s,o){"use strict";function p(){var t=this.params;t.dispatcher.removeEntry(this),t.dispatcher=null}var a="disposing",c="disposed",u=function(t){function e(){t.apply(this,arguments),this._isDisposing=!1}return __extends(e,t),e.prototype.addEventListener=function(t,e,i){void 0===i&&(i=0);var r=this._entries;r||(this._entries=r=[]),r.push(new s["default"](t,e,{priority:i||0,dispatcher:this},p))},e.prototype.removeEntry=function(t){return!!this._entries&&0!=n.remove(this._entries,t)},e.prototype.registerEventListener=function(t,e,i){void 0===i&&(i=0),this.hasEventListener(t,e)||this.addEventListener(t,e,i)},e.prototype.hasEventListener=function(t,e){var i=this._entries;return i&&i.some(function(i){return t==i.type&&(!e||e==i.listener)})},e.prototype.removeEventListener=function(t,e){o.disposeThese(this._entries.filter(function(i){return i.matches(t,e)}))},e.prototype.dispatchEvent=function(t,e){var r=this,n=this,s=n._entries;if(!s||!s.length)return!1;var o;"string"==typeof t?(o=Object.create(Event),e||(e={}),o.cancelable=!!e.cancelable,o.target=n,o.type=t):o=t;var p=o.type,a=s.filter(function(t){return t.type==p});return a.length?(a.sort(function(t,e){return e.params.priority-t.params.priority}),a.forEach(function(t){var e=Object.create(Event);i["default"](o,e),e.target=r,t.dispatch(e)}),!0):!1},Object.defineProperty(e,"DISPOSING",{get:function(){return a},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DISPOSED",{get:function(){return c},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDisposing",{get:function(){return this._isDisposing},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){var e=this;if(!e.wasDisposed&&!e._isDisposing){e._isDisposing=!0,e.dispatchEvent(a),t.prototype.dispose.call(this),e.dispatchEvent(c);var i=e._entries;i&&(this._entries=null,i.forEach(function(t){return t.dispose()}))}},e}(r["default"]);Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=u});
//# sourceMappingURL=EventDispatcherBase.js.map
