(function(e,t){if(e.dispatch!==t)return;var n=function(e,t){return(e?e:"")+(Math.random()+"").replace(".","")+(t?t:"")},r=e.dispatch=function(e,n){var i=!1;if(typeof e=="object"){if(typeof e.name===t)return;i=!0}typeof e=="string"&&(e={name:e});var s=r.parcels[e.name];return s===t?(s=r.parcels[e.name]=new o(e.name),s.add(e,n)):i&&s.add(e,n),s.get()};r.parcels={},r.dropsite={},r.delivering=!1,r.queue=[],r.deliver=function(n,i,s){if(r.delivering&&!s){r.queue.push(arguments);return}r.delivering=!0,i.addParcel(n);if(n.exports===t)return;var o;for(o=0;o<i.sites.length;o++){var u=i.sites[o];if(n.sentTo[u.id])continue;u.target&&(u.target.apply(e,[n.exports,n.manifest]),n.sentTo[u.id]=!0)}if(r.queue.length>0){var a=r.queue.shift();r.deliver.apply(this,[a[0],a[1],!0])}else r.delivering=!1},r.to=function(e){if(e===t)return;return r.dropsite[e]||(r.dropsite[e]=new s(e))};var s=function(e){this.name=e,this.sites=[],this.parcels=[]};s.prototype.at=function(e){var t=this;if(typeof e=="function"){var i=n(this.name+"/");this.sites.push({id:i,target:e});var s;for(s=0;s<this.parcels.length;s++){var o=this.parcels[s];r.deliver(o,t)}}return this},s.prototype.addParcel=function(e){var t=!1,n;for(n=0;n<this.parcels.length;n++){var r=this.parcels[n];if(r==e){t=!0;break}}t||this.parcels.push(e)};var o=function(e){this.name=e.name,this.dropsites=[],this.parcels=[]};o.prototype.add=function(e,t){return this.parcels.push({manifest:e,exports:t,sentTo:{}})},o.prototype.get=function(){return this.indexLocked=!1,this.index=this.parcels.length-1,this},o.prototype.intendedFor=function(e){var t;for(i in this.parcels){t=this.parcels[i];if(t.manifest.recipient==e)return this.index=i,this.indexLocked=!0,this}},o.prototype.containing=function(e){if(this.indexLocked)return this;var n=this.parcels[this.index];return n.exports!==t?this.index=this.add({name:this.name},e)-1:n.exports=e,this},o.prototype.to=function(e,n){if(e===t)return this;parcel=this.parcels[this.index];if(typeof e=="string"){var i=e;parcel.manifest.recipient!==t&&(parcel.manifest.recipient=i),e=r.to(i)}return typeof e=="function"&&(e=r.to("Custom dropsite for "+parcel.manifest.name).at(e)),this.dropsites.push(e),this.dropsiteLocked?n&&r.deliver(parcel,e):this.toAll(),this},o.prototype.onlyTo=function(e){return this.dropsiteLocked=!0,this.to(e,!0),this},o.prototype.toAll=function(){this.dropsiteLocked=!1;var e=this.parcels[this.index],t=this.dropsites,n;for(n=0;n<t.length;n++){var i=t[n];r.deliver(e,i)}return this}})(window);