define(["lodash"],(function(t){"use strict";var e,n=0,o=1,i=2,r={withCredentials:!1},s={};function u(t){var e=s[t];if(!e)throw"Attempted to use an EventSource that was not registered: "+t;return e}return{install:function(){if(e)throw"EventSource is already mocked.";e=window.EventSource,window.EventSource=function(e,o){return this.url=e,this.config=o||r,this.readyState=n,this.onopen=null,this.onerror=null,this.onmessage=null,this.events={},this.addEventListener=function(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)},this.removeEventListener=function(e,n){if(!this.events[e])throw"Attempted to remove an unregistered event listener: "+e;t.remove(this.events[e],n)},this.close=function(){this.readyState=i},s[e]=this,this}},emitError:function(t,e){var n=u(t);"function"==typeof n.onerror&&n.onerror(e)},emitOpen:function(t){var e=u(t);e.readyState=o,"function"==typeof e.onopen&&e.onopen()},emitMessage:function(t,e,n){var o=u(t),i={type:e,data:n};"function"==typeof o.onmessage&&o.onmessage(i),function(t,e,n){var o=t.events[e];o&&o.forEach((function(t){"function"==typeof t&&t(n)}))}(o,e,i)},uninstall:function(){if(!e)throw"EventSource is not mocked.";window.EventSource=e,e=null},get:function(t){return u(t)}}}));