!function(e){"function"==typeof define&&define.amd?define(["../global/window","../global/document"],e):"object"==typeof exports?module.exports=e(require("../global/window"),require("../global/document")):window.dependencyLib=e(window,document)}(function(e,t){function n(e){return null!=e&&e===e.window}function i(e){return e instanceof Element}function o(n){return n instanceof o?n:this instanceof o?void(void 0!==n&&null!==n&&n!==e&&(this[0]=n.nodeName?n:void 0!==n[0]&&n[0].nodeName?n[0]:t.querySelector(n),void 0!==this[0]&&null!==this[0]&&(this[0].eventRegistry=this[0].eventRegistry||{}))):new o(n)}return o.prototype={on:function(e,t){if(i(this[0]))for(var n=this[0].eventRegistry,o=this[0],r=e.split(" "),a=0;a<r.length;a++){var l=r[a].split(".");!function(e,i){o.addEventListener?o.addEventListener(e,t,!1):o.attachEvent&&o.attachEvent("on"+e,t),n[e]=n[e]||{},n[e][i]=n[e][i]||[],n[e][i].push(t)}(l[0],l[1]||"global")}return this},off:function(e,t){if(i(this[0]))for(var n=this[0].eventRegistry,o=this[0],r=e.split(" "),a=0;a<r.length;a++)for(var l=r[a].split("."),s=function(e,i){var o,r,a=[];if(e.length>0)if(void 0===t)for(o=0,r=n[e][i].length;o<r;o++)a.push({ev:e,namespace:i&&i.length>0?i:"global",handler:n[e][i][o]});else a.push({ev:e,namespace:i&&i.length>0?i:"global",handler:t});else if(i.length>0)for(var l in n)for(var s in n[l])if(s===i)if(void 0===t)for(o=0,r=n[l][s].length;o<r;o++)a.push({ev:l,namespace:s,handler:n[l][s][o]});else a.push({ev:l,namespace:s,handler:t});return a}(l[0],l[1]),f=0,c=s.length;f<c;f++)!function(e,t,i){if(e in n==1)if(o.removeEventListener?o.removeEventListener(e,i,!1):o.detachEvent&&o.detachEvent("on"+e,i),"global"===t)for(var r in n[e])n[e][r].splice(n[e][r].indexOf(i),1);else n[e][t].splice(n[e][t].indexOf(i),1)}(s[f].ev,s[f].namespace,s[f].handler);return this},trigger:function(e){if(i(this[0]))for(var n=this[0].eventRegistry,r=this[0],a="string"==typeof e?e.split(" "):[e.type],l=0;l<a.length;l++){var s=a[l].split("."),f=s[0],c=s[1]||"global";if(void 0!==t&&"global"===c){var u,v,d={bubbles:!0,cancelable:!0,detail:Array.prototype.slice.call(arguments,1)};if(t.createEvent){try{u=new CustomEvent(f,d)}catch(e){(u=t.createEvent("CustomEvent")).initCustomEvent(f,d.bubbles,d.cancelable,d.detail)}e.type&&o.extend(u,e),r.dispatchEvent(u)}else(u=t.createEventObject()).eventType=f,e.type&&o.extend(u,e),r.fireEvent("on"+u.eventType,u)}else if(void 0!==n[f])if(arguments[0]=arguments[0].type?arguments[0]:o.Event(arguments[0]),"global"===c)for(var p in n[f])for(v=0;v<n[f][p].length;v++)n[f][p][v].apply(r,arguments);else for(v=0;v<n[f][c].length;v++)n[f][c][v].apply(r,arguments)}return this}},o.isFunction=function(e){return"function"==typeof e},o.noop=function(){},o.isArray=Array.isArray,o.inArray=function(e,t,n){return null==t?-1:function(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return n;return-1}(t,e)},o.valHooks=void 0,o.isPlainObject=function(e){return!("object"!=typeof e||e.nodeType||n(e)||e.constructor&&!Object.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},o.extend=function(){var e,t,n,i,r,a,l=arguments[0]||{},s=1,f=arguments.length,c=!1;for("boolean"==typeof l&&(c=l,l=arguments[s]||{},s++),"object"==typeof l||o.isFunction(l)||(l={}),s===f&&(l=this,s--);s<f;s++)if(null!=(e=arguments[s]))for(t in e)n=l[t],l!==(i=e[t])&&(c&&i&&(o.isPlainObject(i)||(r=o.isArray(i)))?(r?(r=!1,a=n&&o.isArray(n)?n:[]):a=n&&o.isPlainObject(n)?n:{},l[t]=o.extend(c,a,i)):void 0!==i&&(l[t]=i));return l},o.each=function(e,t){var i=0;if(function(e){var t="length"in e&&e.length,i=typeof e;return"function"!==i&&!n(e)&&(!(1!==e.nodeType||!t)||"array"===i||0===t||"number"==typeof t&&t>0&&t-1 in e)}(e))for(var o=e.length;i<o&&!1!==t.call(e[i],i,e[i]);i++);else for(i in e)if(!1===t.call(e[i],i,e[i]))break;return e},o.data=function(e,t,n){if(void 0===n)return e.__data?e.__data[t]:null;e.__data=e.__data||{},e.__data[t]=n},"function"==typeof e.CustomEvent?o.Event=e.CustomEvent:(o.Event=function(e,n){n=n||{bubbles:!1,cancelable:!1,detail:void 0};var i=t.createEvent("CustomEvent");return i.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),i},o.Event.prototype=e.Event.prototype),o});
