(function(a,b){return typeof exports!="undefined"?b(a,exports):typeof define=="function"&&define.amd?define("synapse/core",["exports"],function(c){return b(a,c)}):a.SynapseCore=b(a,{})})(this,function(a,b){var c;return c={},{toString:Object.prototype.toString,getType:function(a){return this.toString.call(a).match(/^\[object\s(.*)\]$/)[1]},isObject:function(a){return this.getType(a)==="Object"},isArray:function(a){return this.getType(a)==="Array"},isFunction:function(a){return this.getType(a)==="Function"},isString:function(a){return this.getType(a)==="String"},isBoolean:function(a){return this.getType(a)==="Boolean"}}});var __slice=Array.prototype.slice;(function(a,b){return typeof exports!="undefined"?b(a,exports,require("synapse/core")):typeof define=="function"&&define.amd?define("synapse",["synapse/core","exports"],function(c,d){return b(a,d,c)}):a.Synapse=b(a,{},a.SynapseCore)})(this,function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;return k=1,d={},l="observe notify syncWith stopObserving pauseObserving resumeObserving stopNotifying pauseNotifying resumeNotifying".split(" "),b=function(){function a(b){var e,f,g,h,i,j,m,n,o,p,q;if(b instanceof a)return b;if(e=d[b[a.expando]])return e;if(this.constructor!==a){i=new a(b),h=i.raw,j=function(a){return h[a]=function(){return i[a].apply(i,arguments),h}};for(m=0,o=l.length;marguments.length?[]:__slice.call(arguments,1),c=new a(c),e.apply(null,[c,this].concat(__slice.call(b))),this},a.prototype.notify=function(){var b,c;return c=arguments[0],b=2>arguments.length?[]:__slice.call(arguments,1),c=new a(c),e.apply(null,[this,c].concat(__slice.call(b))),this},a.prototype.syncWith=function(b){return b=new a(b),this.observe(b).notify(b),this},a.prototype.stopObserving=function(a){var b,c,e,f;if(a){if(c=this._observing[a.guid]){for(e in c.channels)b=channels[e],m(a,b.event,b.handler);delete this._observing[a.guid]}}else{for(f in this._observing){c=this._observing[f],a=d[f];for(e in c.channels)b=c.channels[e],m(a,b.event,b.handler)}this._observing={}}return this},a.prototype.pauseObserving=function(a){var b,c;if(a){if(b=this._observing[a.guid])b.open=!1}else for(c in this._observing)this._observing[c].open=!1;return this},a.prototype.resumeObserving=function(a){var b,c;if(a){if(b=this._observing[a.guid])b.open=!0}else for(c in this._observing)this._observing[c].open=!0;return this},a.prototype.stopNotifying=function(a){var b,c,e,f;if(a){if(c=this._notifying[a.guid]){for(f in c.channels)b=c.channels[f],m(this,b.event,b.handler);delete this._notifying[a.guid]}}else{for(e in this._notifying){c=this._notifying[e],a=d[e];for(f in c.channels)b=c.channels[f],m(this,b.event,b.handler)}this._notifying={}}return this},a.prototype.pauseNotifying=function(a){var b,c;if(a){if(b=this._notifying[a.guid])b.open=!1}else for(c in this._notifying)this._notifying[c].open=!1;return this},a.prototype.resumeNotifying=function(a){var b,c;if(a){if(b=this._notifying[a.guid])b.open=!0}else for(c in this._notifying)this._notifying[c].open=!0;return this},a}(),b.expando="Synapse"+(b.prototype.version+Math.random()).replace(/\D/g,""),b.hooks=[],h=function(){var a,b,c,d;b=arguments[0],a=2>arguments.length?[]:__slice.call(arguments,1);if(c=(d=b.hook).detectEvent.apply(d,[b.raw].concat(__slice.call(a))))return c;throw new Error(""+b.hook.typeName+" types do not support events")},n=function(){var a,b,c,d;b=arguments[0],a=2>arguments.length?[]:__slice.call(arguments,1);if(c=typeof (d=b.hook).onEventHandler=="function"?d.onEventHandler.apply(d,[b.raw].concat(__slice.call(a))):void 0)return b;throw new Error(""+b.hook.typeName+" types do not support events")},m=function(){var a,b,c,d;b=arguments[0],a=2>arguments.length?[]:__slice.call(arguments,1);if(c=typeof (d=b.hook).offEventHandler=="function"?d.offEventHandler.apply(d,[b.raw].concat(__slice.call(a))):void 0)return b;throw new Error(""+b.hook.typeName+" types do not support events")},o=function(){var a,b,c,d;b=arguments[0],a=2>arguments.length?[]:__slice.call(arguments,1);if(c=typeof (d=b.hook).triggerEventHandler=="function"?d.triggerEventHandler.apply(d,[b.raw].concat(__slice.call(a))):void 0)return b;throw new Error(""+b.hook.typeName+" types do not support events")},i=function(a){var b;return typeof (b=a.hook).detectInterface=="function"?b.detectInterface(a.raw):void 0},j=function(a){var b;return typeof (b=a.hook).detectOtherInterface=="function"?b.detectOtherInterface(a.raw):void 0},g={event:null,subjectInterface:null,observerInterface:null,converter:null,triggerOnBind:!0},f=function(a,b,d){var e,f,k,l,m,p,q,r,s,t,u,v,w,x;for(p in g)v=g[p],d[p]==null&&(d[p]=v);(f=d.converter)&&!c.isFunction(f)&&(f=b.object[f]);if(!(s=d.subjectInterface)&&!(s=i(a)||j(b))&&!f)throw new Error("An interface for "+a.hook.typeName+" objects could not be detected");if(!(q=d.observerInterface)&&!(q=i(b)||j(a)))throw new Error("An interface for "+b.hook.typeName+" objects could not be detected");(l=d.event)||(l=h(a,s)),c.isArray(l)||(l=[l]),u=d.triggerOnBind;for(w=0,x=l.length;warguments.length?[]:__slice.call(arguments,2),h=d,a=d[0],b=d[1];if(c.isFunction(a))h={converter:a};else if(c.isArray(a)||!c.isObject(a))h={subjectInterface:a,observerInterface:b};c.isArray(h)||(h=[h]);for(j=0,k=h.length;j