(i=>{classt{constructor(i,t,e,s,n){this.active=!0,this.params=null,this._listener=t,this._isOnce=e,this.context=s,this._signal=i,this._priority=n||0}execute(i){vart,e;returnthis.active&&this._listener&&(e=this.params?this.params.concat(i):i,t=this._listener.apply(this.context,e),this._isOnce&&this.detach()),t}detach(){returnthis.isBound()?this._signal.remove(this._listener,this.context):null}isBound(){return!!this._signal&&!!this._listener}isOnce(){returnthis._isOnce}getListener(){returnthis._listener}getSignal(){returnthis._signal}_destroy(){deletethis._signal,deletethis._listener,deletethis.context}}functione(i,t){if("function"!=typeofi)thrownewError("listener is a required param of {fn}() and should be a Function.".replace("{fn}",t))}classs{constructor(){this.memorize=!1,this.active=!0,this._bindings=[],this._prevParams=null;vari=this;this.dispatch=((...t)=>s.prototype.dispatch.apply(i,t))}_indexOfListener(i,t){for(vare,s=this._bindings.length;s--;)if((e=this._bindings[s])._listener===i&&e.context===t)returns;return-1}add(i,s,n){e(i,"add");varr,h=this._indexOfListener(i,s);if(-1!==h){if(!1!==(r=this._bindings[h]).isOnce())thrownewError("You cannot addOnce() then add() the same listener without removing the relationship first.")}else{r=newt(this,i,!1,s,n);vara=this._bindings.length;do{--a}while(this._bindings[a]&&r._priority<=this._bindings[a]._priority);this._bindings.splice(a+1,0,r)}returnthis.memorize&&this._prevParams&&r.execute(this._prevParams),r}remove(i,t){e(i,"remove");vars=this._indexOfListener(i,t);return-1!==s&&(this._bindings[s]._destroy(),this._bindings.splice(s,1)),i}removeAll(){for(vari=this._bindings.length;i--;)this._bindings[i]._destroy();this._bindings.length=0}dispatch(...i){if(this.active){vart,e=this._bindings.length;if(this.memorize&&(this._prevParams=i),e){t=this._bindings.slice();do{e--}while(t[e]&&!1!==t[e].execute(i))}}}dispose(){this.removeAll(),deletethis._bindings,deletethis._prevParams}}varn=s;n.Signal=s,i.signals=n})(this);