define(function(t,e,n){"use strict";var i=t("./util"),s=function(t){var e,n=!1;return function(){return n?e:(n=!0,e=t.apply(this,arguments),t=null,e)}},r={on:function(t,e,n){if(!l(this,"on",t,[e,n])||!e)return this;this._events||(this._events={});var i=this._events[t]||(this._events[t]=[]);return i.push({callback:e,context:n,ctx:n||this}),this},once:function(t,e,n){if(!l(this,"once",t,[e,n])||!e)return this;var i=this,r=s(function(){i.off(t,r),e.apply(this,arguments)});return r._callback=e,this.on(t,r,n)},off:function(t,e,n){if(!this._events||!l(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._events=void 0,this;for(var i=t?[t]:Object.keys(this._events),s=0,r=i.length;s