"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){function e(){function e(e,t,n){this.message="Bullet:: ["+e+"] "+t+", but received: "+n;var o=new Error(this.message);void 0!==o.stack&&(this.stack=o.stack)}function t(e,t,n,o){this.message="Bullet:: ["+e+"] Expected parameter - "+t+" - to be type: "+o+", but received type: "+(void 0===n?"undefined":_typeof(n));var a=new TypeError(this.message);void 0!==a.stack&&(this.stack=a.stack)}function n(e){this.message="Bullet:: ["+e+"] Expected event name parameter to be longer than 0 characters";var t=new Error(this.message);void 0!==t.stack&&(this.stack=t.stack)}function o(e){this.message="Bullet:: ["+e+"] Expected event names array to contain one or more event names";var t=new Error(this.message);void 0!==t.stack&&(this.stack=t.stack)}function a(e,t){this.message="Bullet:: ["+e+'] Event string: "'+t+'" does not exist within the events dictionary\nPlease use the Bullet.addEventName method to add this string.';var n=new Error(this.message);void 0!==n.stack&&(this.stack=n.stack)}function r(e,t){this.message="Bullet:: ["+e+'] Event string: "'+t+'" is not mapped to any callbacks\nPlease use the Bullet.on method to map this string to a callback.';var n=new Error(this.message);void 0!==n.stack&&(this.stack=n.stack)}function i(e){e.prototype=new Error,e.prototype.name=e.name,e.prototype.constructor=e}function c(e,t){for(var n in d[e].callbacks){var o=d[e].callbacks[n];"function"==typeof o.cb&&o.cb(t),"boolean"==typeof o.once&&!0===o.once&&w.off(e,o.cb)}}function l(e){var t={};for(var n in e)t[n]={cb:e[n].cb,once:e[n].once};return t}function s(e){for(var t in d[e].callbacks){var n=d[e].callbacks[t].cb;n[v].totalEvents--,0===n[v].totalEvents?delete n[v]:delete n[v][e]}}function f(){for(var e in d)s(e)}i(e),i(t),i(n),i(o),i(a),i(r);var v="__bullet_pubsub__",w=this,d={},h=!1,u=!0;w._errors={ParamCountError:e,ParamTypeError:t,EventNameLengthError:n,EventNamesArrayLengthError:o,UndeclaredEventError:a,UnmappedEventError:r},w.events={},w._getMappings=function(){var e={};for(var t in d)e[t]={callbacks:l(d[t].callbacks),totalCallbacks:d[t].totalCallbacks};return e},w.on=function(o,r,i){if(arguments.length<2||arguments.length>3)throw new e("on","Expected between 2 and 3 parameters",arguments.length);if("string"!=typeof o)throw new t("on","event name",o,"string");if(0===o.length)throw new n("on");if(h&&void 0===w.events[o])throw new a("on",o);if("function"!=typeof r)throw new t("on","callback",r,"function");if(void 0!==i&&"boolean"!=typeof i)throw new t("on","once",i,"boolean");var c=null;void 0!==d[o]?(void 0===r[v]&&(r[v]={totalEvents:0}),void 0===r[v][o]&&(c=d[o].totalCallbacks,d[o].totalCallbacks++,d[o].callbacks[c]={cb:r,once:"boolean"==typeof i&&i},r[v][o]=c,r[v].totalEvents++),"boolean"==typeof i&&(c=r[v][o],d[o].callbacks[c].once=i)):(d[o]={callbacks:{}},c=0,d[o].callbacks[c]={cb:r,once:!!i},d[o].totalCallbacks=1,void 0===r[v]?(r[v]={},r[v].totalEvents=1):r[v].totalEvents++,r[v][o]=c)},w.once=function(o,r){if(2!==arguments.length)throw new e("once","Expected 2 parameters",arguments.length);if("string"!=typeof o)throw new t("once","event name",o,"string");if(0===o.length)throw new n("once");if(h&&void 0===w.events[o])throw new a("once",o);if("function"!=typeof r)throw new t("once","callback",r,"function");w.on(o,r,!0)},w.off=function(e,o){if(0===arguments.length)return f(),void(d={});if("string"!=typeof e)throw new t("off","event name",e,"string");if(0===e.length)throw new n("off");if(h&&void 0===w.events[e])throw new a("off",e);if(void 0!==d[e])if("function"==typeof o){var r=o[v][e];void 0!==d[e].callbacks[r]&&(delete d[e].callbacks[r],delete o[v][e],d[e].totalCallbacks--,o[v].totalEvents--,0===d[e].totalCallbacks&&delete d[e],0===o[v].totalEvents&&delete o[v])}else{if(void 0!==o)throw new t("off","callback",o,"function");s(e),delete d[e]}},w.replaceCallback=function(e,o,i,c){if("string"!=typeof e)throw new t("replaceCallback","event name",e,"string");if(0===e.length)throw new n("replaceCallback");if(void 0===d[e])throw new r("replaceCallback",e);if(h&&void 0===w.events[e])throw new a("replaceCallback",e);if("function"!=typeof o)throw new t("replaceCallback","callback",o,"function");if("function"!=typeof i)throw new t("replaceCallback","callback",i,"function");if(void 0!==c&&"boolean"!=typeof c)throw new t("replaceCallback","once",c,"boolean");w.off(e,o),w.on(e,i,c)},w.replaceAllCallbacks=function(e,o,i){if("string"!=typeof e)throw new t("replace","event name",e,"string");if(0===e.length)throw new n("replace");if(void 0===d[e])throw new r("replace",e);if(h&&void 0===w.events[e])throw new a("replace",e);if("function"!=typeof o)throw new t("replace","callback",o,"function");if(void 0!==i&&"boolean"!=typeof i)throw new t("replace","once",i,"boolean");w.off(e),w.on(e,o,i)},w.trigger=function(e,o){if("string"!=typeof e)throw new t("trigger","event name",e,"string");if(0===e.length)throw new n("trigger");if(h&&void 0===w.events[e])throw new a("trigger",e);if(void 0!==d[e])u&&"undefined"!=typeof window?window.setTimeout(function(){c(e,o)},0):c(e,o);else if(h)throw new r("trigger",e)},w.addEventName=function(e){if("string"!=typeof e)throw new t("addEventName","event name",e,"string");if(0===e.length)throw new n("addEventName");w.events[e]=e},w.addMultipleEventNames=function(e){if(!(e instanceof Array))throw new t("addMultipleEventNames","event names",e,"array");if(0===e.length)throw new o("addMultipleEventNames");var n=0,a=e.length;for(n;n