import{__extends}from"tslib";import{b as balBrowser}from"./browser-216e7b03.js";var Subject=function(){function t(t){this.notifyCallback=t;this.observers=[]}t.prototype.attach=function(t){var i=this.observers.includes(t);if(i){return console.log("Subject: Observer has been attached already.")}this.observers.push(t)};t.prototype.detach=function(t){var i=this.observers.indexOf(t);if(i===-1){return console.log("Subject: Nonexistent observer.")}this.observers.splice(i,1)};t.prototype.notify=function(t){for(var i=0,n=this.observers;i<n.length;i++){var e=n[i];if(typeof e==="function"){e(t)}else{if(this.notifyCallback){this.notifyCallback(e,t)}}}};return t}();var SingleSubject=function(){function t(t){this.notifyCallback=t}t.prototype.attach=function(t){this.observer=t};t.prototype.detach=function(){this.observer=undefined};t.prototype.notify=function(t){if(this.observer){if(typeof this.observer==="function"){this.observer(t)}else{if(this.notifyCallback){this.notifyCallback(this.observer,t)}}}};return t}();var ListenerAbstract=function(t){__extends(i,t);function i(){var i=t.apply(this,arguments)||this;i.el=undefined;return i}i.prototype.connect=function(t){if(t){this.el=t}else{if(balBrowser.hasWindow){this.el=window}}};i.prototype.disconnect=function(){this.el=undefined};i.prototype.add=function(i){t.prototype.attach.call(this,i)};i.prototype.remove=function(i){t.prototype.detach.call(this,i)};return i}(Subject);export{ListenerAbstract as L,Subject as S,SingleSubject as a};