define(["exports"],function(_exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,(EventEmitter.EventEmitter=EventEmitter).prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if("number"!=typeof n||n<0||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var handler,len,args,i,listeners,err,er;if((this._events||(this._events={}),"error"===type)&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length))throw(er=arguments[1])instanceof Error?er:((err=new Error('Uncaught, unspecified "error" event. ('+er+")")).context=er,err);if(void 0===(handler=this._events[type]))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),len=(listeners=handler.slice()).length,i=0;i<len;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.on=EventEmitter.prototype.addListener=function(type,listener){if(isFunction(listener))return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(listener=void 0!==this._maxListeners?this._maxListeners:EventEmitter.defaultMaxListeners)&&0<listener&&this._events[type].length>listener&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace)&&console.trace(),this;throw TypeError("listener must be a function")},EventEmitter.prototype.once=function(type,listener){var fired;if(isFunction(listener))return fired=!1,g.listener=listener,this.on(type,g),this;throw TypeError("listener must be a function");function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(this._events&&this._events[type])if(length=(list=this._events[type]).length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;0<i--;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(position<0)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(this._events)if(this._events.removeListener)if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);this.removeAllListeners("removeListener"),this._events={}}else{if(isFunction(listeners=this._events[type]))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);delete this._events[type]}else 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type];return this},EventEmitter.prototype.listeners=function(type){type=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[];return type},EventEmitter.prototype.listenerCount=function(type){if(this._events){type=this._events[type];if(isFunction(type))return 1;if(type)return type.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)},_exports.default=EventEmitter});