EVOLUTION-MANAGER
Edit File: nettest.min.js
var NetTest=function(){function x(){r={ping:{start:function(){var c=f.latency;c.settings({endpoint:"./services/networktest/?type\x3dping",measures:10,attempts:1});c.off("end").on("end",t);c.start();c.trigger("start")}},jitter:{start:function(){var c=f.latency;c.settings({endpoint:"./services/networktest/?type\x3djitter",measures:5,attempts:3});c.off("end").on("end",n);c.start();c.trigger("start")}},upload:{start:function(){var c=f.upload;c.settings({endpoint:"./services/networktest/?type\x3dupload", delay:2E3,data:{size:1048576,multiplier:2}});c.start()}},download:{start:function(){var c=f.download;c.settings({endpoint:"./services/networktest/?type\x3ddownload",delay:2E3,data:{size:1048576,multiplier:2}});c.start()}}}}function k(f,m){var d=$("\x3cspan\x3e\x3c/span\x3e").append(b["report.start"]),e=!1;"upload"===c?(d.append(b["upl.bytes"]),e=!0):"download"===c&&(d.append(b["dwn.bytes"]),e=!0);e&&d.append(g(f/1024/1024,b.mb));d.append("...");a($('\x3cspan class\x3d"delim"\x3e\x3c/span\x3e').html(d), m)}function u(c){k(c,!0)}function n(c,f){for(var m=$("\x3cspan\x3e\x3c/span\x3e").append("["),d="",e=0,v=Number.MAX_VALUE,r=0;r<f.length;++r){var w=f[r],e=Math.max(e,w),v=Math.min(v,w);m.append(d).append(g(w,b.ms));d=","}m.append("]");a(m);a($("\x3cspan\x3e\x3c/span\x3e").append(b["jitter.avg"]).append(g(c,b.ms)));a($("\x3cspan\x3e\x3c/span\x3e").append(b["jitter.min"]).append(g(v,b.ms)));a($("\x3cspan\x3e\x3c/span\x3e").append(b["jitter.max"]).append(g(e,b.ms)));a($("\x3cspan\x3e\x3c/span\x3e").append(b.jitter).append(":").append(g(e- c,b.ms)).append(";").append(g(v-c,b.ms)));p($("\x3cdiv\x3e\x3c/div\x3e").append($('\x3cdiv class\x3d"line"\x3e\x3c/div\x3e').append(b["jitter.avgAbbr"]+"\x26nbsp;").append(g(c,b.ms))).append($('\x3cdiv class\x3d"line"\x3e\x3c/div\x3e').append(b.jitter+"\x26nbsp;").append(g(e-c,b.ms))))}function t(c,m){a($("\x3cspan\x3e\x3c/span\x3e").append(b["ping.avg"]).append(g(c,b.ms)));a($("\x3cspan\x3e\x3c/span\x3e").append(b["ping.rcv"]).append(g(m.length,"")));a($("\x3cspan\x3e\x3c/span\x3e").append(b["ping.lost"]).append(g(10- m.length,"")));p(g(c,b.ms))}function l(c){k(c,!1)}function q(){return $("#test-"+c+" button.test-btn")}function p(b){var f=q();f.addClass("complete").removeClass("started");f.parent().find(".value").html(b);m=f.data("next");m?w&&(c=m,q().click()):w=!1}function h(f){f=g(f/1024/1024,b.mb+"/"+b.sec);var m=$("\x3cspan\x3e\x3c/span\x3e").append(b["upload"===c?"upl.speed":"dwn.speed"]).append(f);a(m);p(f)}function a(c,f){d.append("\x3cbr/\x3e");f&&d.append("\x3cbr/\x3e");d.append($('\x3cspan class\x3d"module"\x3e\x3c/span\x3e').text(v)).append(c); d.find("span").last()[0].scrollIntoView(!1)}function g(c,f){return $('\x3cspan class\x3d"value"\x3e\x3c/span\x3e').append(null==c?"null":c.toFixed(1)+" "+f)}var e={},d,b,f,r,c,v,m,w=!0;e.init=function(m){b=m;d=$(".nettest output");$(".nettest button").click(function(){var f=$(this);f.removeClass("complete").removeClass("not-started").addClass("started");v=f.data("lbl");c=f.data("measure");r[c].start();f.parent().find(".value").html("")});f=new Network;x();f.upload.on("start",u).on("restart",l).on("end", h);f.download.on("start",u).on("restart",l).on("end",h);f.latency.on("start",u);$('.nettest button[data-start\x3d"true"]').click()};return e}(); (function(x){"object"===typeof exports&&"undefined"!==typeof module?module.exports=x():"function"===typeof define&&define.amd?define([],x):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Network=x()})(function(){return function k(u,n,t){function l(h,a){if(!n[h]){if(!u[h]){var g="function"==typeof require&&require;if(!a&&g)return g(h,!0);if(q)return q(h,!0);a=Error("Cannot find module '"+h+"'");throw a.code="MODULE_NOT_FOUND",a;}a=n[h]={exports:{}}; u[h][0].call(a.exports,function(e){var d=u[h][1][e];return l(d?d:e)},a,a.exports,k,u,n,t)}return n[h].exports}for(var q="function"==typeof require&&require,p=0;p<t.length;p++)l(t[p]);return l}({1:[function(k,u,n){Object.defineProperty(n,"__esModule",{value:!0});var t=function(){function l(l,h,a){for(var g=0;g<h.length;g++){var e=h[g],d=e.decorators,b=e.key;delete e.key;delete e.decorators;e.enumerable=e.enumerable||!1;e.configurable=!0;if("value"in e||e.initializer)e.writable=!0;if(d){for(var f=0;f< d.length;f++){var r=d[f];if("function"===typeof r)e=r(l,b,e)||e;else throw new TypeError("The decorator for method "+e.key+" is of the invalid type "+typeof r);}if(void 0!==e.initializer){a[b]=e;continue}}Object.defineProperty(l,b,e)}}return function(k,h,a,g,e){h&&l(k.prototype,h,g);a&&l(k,a,e);return k}}(),l=k("../utils/decorators");k=function(){function k(){if(!(this instanceof k))throw new TypeError("Cannot call a class as a function");var h=n._eventCallbacks;if(h){var a={},g;for(g in h)a[g]=h[g]; a.value=a.initializer.call(this);Object.defineProperty(this,"_eventCallbacks",a)}}var n={};t(k,[{key:"on",value:function(h,a){var g=this;h=Array.isArray(h)?h:[h];h.forEach(function(e){e=g._eventCallbacks[e]=g._eventCallbacks[e]||[];~e.indexOf(a)||e.push(a)});return this}},{key:"off",value:function(h){var a=this,g=1>=arguments.length||void 0===arguments[1]?null:arguments[1];h=Array.isArray(h)?h:[h];h.forEach(function(e){var d=a._eventCallbacks[e];!g&&d?delete a._eventCallbacks[e]:(e=d?d.indexOf(g): -1,-1!=e&&d.splice(e,1))});return this}},{key:"trigger",value:function(h){for(var a=arguments.length,g=Array(1<a?a-1:0),e=1;e<a;e++)g[e-1]=arguments[e];var d=!0;(this._eventCallbacks[h]||[]).forEach(function(b){b=b.apply(void 0,g);d=d&&(!1!==b?!0:!1)});return d}},{key:"_eventCallbacks",decorators:[(0,l.enumerable)(!1)],initializer:function(){return{}},enumerable:!0}],null,n);return k}();n["default"]=k;u.exports=n["default"]},{"../utils/decorators":7}],2:[function(k,u,n){function t(b,f){if("function"!== typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);b.prototype=Object.create(f&&f.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(b,f):b.__proto__=f)}function l(b,f,d){if(d=d[f]){var c={},e;for(e in d)c[e]=d[e];c.value=c.initializer.call(b);Object.defineProperty(b,f,c)}}Object.defineProperty(n,"__esModule",{value:!0});var q=function(){function b(f,b,c){for(var d=0;d< b.length;d++){var m=b[d],e=m.decorators,g=m.key;delete m.key;delete m.decorators;m.enumerable=m.enumerable||!1;m.configurable=!0;if("value"in m||m.initializer)m.writable=!0;if(e){for(var r=0;r<e.length;r++){var a=e[r];if("function"===typeof a)m=a(f,g,m)||m;else throw new TypeError("The decorator for method "+m.key+" is of the invalid type "+typeof a);}if(void 0!==m.initializer){c[g]=m;continue}}Object.defineProperty(f,g,m)}}return function(f,d,c,e,m){d&&b(f.prototype,d,e);c&&b(f,c,m);return f}}(), p=function(b,f,d){var c=!0;for(;c;)if(null===b&&(b=Function.prototype),c=Object.getOwnPropertyDescriptor(b,f),void 0===c){b=Object.getPrototypeOf(b);if(null===b)break;c=!0}else{if("value"in c)return c.value;f=c.get;return void 0===f?void 0:f.call(d)}},h=k("./HttpModule"),h=h&&h.__esModule?h:{"default":h},a=k("../Timing"),g=a&&a.__esModule?a:{"default":a},e=k("../../utils/helpers"),d=k("../../utils/decorators");k=function(b){function f(c){var b=this,m=1>=arguments.length||void 0===arguments[1]?{}: arguments[1];if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");c=~["upload","download"].indexOf(c)?c:"download";p(Object.getPrototypeOf(f.prototype),"constructor",this).call(this,c);l(this,"_loadingType",a);l(this,"_intendedEnd",a);l(this,"_isRestarting",a);l(this,"_lastLoadedValue",a);l(this,"_speedRecords",a);l(this,"_avgSpeed",a);l(this,"_requestID",a);l(this,"_progressID",a);l(this,"_started",a);l(this,"_firstProgress",a);l(this,"_deferredProgress",a);l(this,"_timingLabels", a);this._extendDefaultSettings({data:{size:"upload"==c?2097152:10485760,multiplier:2}}).settings(m);this._loadingType=c;this.on("xhr-upload-loadstart",function(){return g["default"].mark(b._timingLabels.start)});this.on("xhr-readystatechange",function(c){b._started||c.readyState!=XMLHttpRequest.LOADING||(g["default"].mark(b._timingLabels.start),b._started=!0)});m="upload"==c?"xhr-upload":"xhr";this.on(m+"-progress",function(c,f){return b._progress(f)});this.on(m+"-timeout",function(){return b._timeout()}); this.on(m+"-loadend",function(){return b._end()})}var a={},a={};t(f,b);q(f,[{key:"_loadingType",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_intendedEnd",decorators:[(0,d.enumerable)(!1)],initializer:function(){return!1},enumerable:!0},{key:"_isRestarting",decorators:[(0,d.enumerable)(!1)],initializer:function(){return!1},enumerable:!0},{key:"_lastLoadedValue",decorators:[(0,d.enumerable)(!1)],initializer:function(){return null},enumerable:!0},{key:"_speedRecords", decorators:[(0,d.enumerable)(!1)],initializer:function(){return[]},enumerable:!0},{key:"_avgSpeed",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_requestID",decorators:[(0,d.enumerable)(!1)],initializer:function(){return 0},enumerable:!0},{key:"_progressID",decorators:[(0,d.enumerable)(!1)],initializer:function(){return 0},enumerable:!0},{key:"_started",decorators:[(0,d.enumerable)(!1)],initializer:function(){return!1},enumerable:!0},{key:"_firstProgress",decorators:[(0, d.enumerable)(!1)],initializer:function(){return!0},enumerable:!0},{key:"_deferredProgress",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_timingLabels",decorators:[(0,d.enumerable)(!1)],initializer:function(){return{start:null,progress:null,end:null,measure:null}},enumerable:!0}],null,a);q(f,[{key:"start",value:function(){var c=this._loadingType,f=this.settings().data,b=this._requestID++;this._intendedEnd=!1;this._lastLoadedValue=null;this._speedRecords=[];this._started= !1;this._firstProgress=!0;this._deferredProgress=(0,e.defer)();this._isRestarting||this.trigger("start",f.size);var d=this._timingLabels;d.start=c+"-"+b+"-start";d.progress=c+"-"+b+"-progress";d.end=c+"-"+b+"-end";d.measure=c+"-"+b+"-measure";b="upload"==c?new Blob([new ArrayBuffer(f.size)]):null;this._newRequest("download"==c?"GET":"POST",{size:f.size})._sendRequest(b);return this}},{key:"abort",value:function(){this._intendedEnd=!0;return this._abort()}},{key:"_progress",value:function(c){var f= this;if(this._firstProgress)return this._firstProgress=!1;this._deferredProgress.run();var b=this._timingLabels,d=this._progressID++,a=b.progress+"-"+d;c=c.loaded;g["default"].mark(a);var h=g["default"].measure(b.measure+"-avg-"+d,b.start,a),r=c/h*1E3;if(null===this._lastLoadedValue)var k=r;else b=g["default"].measure(b.measure+"-instant-"+d,b.progress+"-"+(d-1),a),k=(c-this._lastLoadedValue)/b*1E3;this._lastLoadedValue=c;this._deferredProgress=(0,e.defer)(function(){f._avgSpeed=r;f._speedRecords.push(k); f.trigger("progress",r,k)});return this}},{key:"_timeout",value:function(){this._intendedEnd=!0;return this}},{key:"_end",value:function(){if(this._intendedEnd)this._isRestarting=!1,this.trigger("end",this._avgSpeed,this._speedRecords);else{var c=this.settings().data,c=c.size*c.multiplier;this.settings({data:{size:c}});this.trigger("restart",c);this._isRestarting=!0;this.start()}return this}}],null,a);return f}(h["default"]);n["default"]=k;u.exports=n["default"]},{"../../utils/decorators":7,"../../utils/helpers":8, "../Timing":6,"./HttpModule":3}],3:[function(k,u,n){function t(e,d){if("function"!==typeof d&&null!==d)throw new TypeError("Super expression must either be null or a function, not "+typeof d);e.prototype=Object.create(d&&d.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}});d&&(Object.setPrototypeOf?Object.setPrototypeOf(e,d):e.__proto__=d)}function l(e,d,b){if(b=b[d]){var f={},a;for(a in b)f[a]=b[a];f.value=f.initializer.call(e);Object.defineProperty(e,d,f)}}Object.defineProperty(n, "__esModule",{value:!0});var q=function(){function e(d,b,f){for(var e=0;e<b.length;e++){var c=b[e],a=c.decorators,m=c.key;delete c.key;delete c.decorators;c.enumerable=c.enumerable||!1;c.configurable=!0;if("value"in c||c.initializer)c.writable=!0;if(a){for(var g=0;g<a.length;g++){var h=a[g];if("function"===typeof h)c=h(d,m,c)||c;else throw new TypeError("The decorator for method "+c.key+" is of the invalid type "+typeof h);}if(void 0!==c.initializer){f[m]=c;continue}}Object.defineProperty(d,m,c)}} return function(d,b,f,a,c){b&&e(d.prototype,b,a);f&&e(d,f,c);return d}}(),p=function(e,d,b){var f=!0;for(;f;)if(null===e&&(e=Function.prototype),f=Object.getOwnPropertyDescriptor(e,d),void 0===f){e=Object.getPrototypeOf(e);if(null===e)break;f=!0}else{if("value"in f)return f.value;d=f.get;return void 0===d?void 0:d.call(b)}},h=k("../EventDispatcher"),h=h&&h.__esModule?h:{"default":h},a=k("../../utils/helpers"),g=k("../../utils/decorators");k=function(e){function d(f){var e=this,c=1>=arguments.length|| void 0===arguments[1]?{}:arguments[1];if(!(this instanceof d))throw new TypeError("Cannot call a class as a function");p(Object.getPrototypeOf(d.prototype),"constructor",this).call(this);l(this,"_defaultSettings",b);l(this,"_settings",b);l(this,"_moduleName",b);l(this,"_xhr",b);l(this,"_lastURLToken",b);l(this,"_requesting",b);l(this,"_requestingOverridden",b);this._extendDefaultSettings({endpoint:"./network.php",delay:8E3});this.settings(c);this._moduleName=f;this.on(["xhr-loadstart","xhr-upload-loadstart"], function(){e._requestingOverridden||(e._requesting=!0)});this.on(["xhr-loadend","xhr-upload-loadend"],function(){e._requestingOverridden||(e._requesting=!1)})}var b={},b={};t(d,e);q(d,[{key:"_defaultSettings",decorators:[(0,g.enumerable)(!1)],initializer:function(){return null},enumerable:!0},{key:"_settings",decorators:[(0,g.enumerable)(!1)],initializer:function(){return null},enumerable:!0},{key:"_moduleName",decorators:[(0,g.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_xhr", decorators:[(0,g.enumerable)(!1)],initializer:function(){return null},enumerable:!0},{key:"_lastURLToken",decorators:[(0,g.enumerable)(!1)],initializer:function(){return null},enumerable:!0},{key:"_requesting",decorators:[(0,g.enumerable)(!1)],initializer:function(){return!1},enumerable:!0},{key:"_requestingOverridden",decorators:[(0,g.enumerable)(!1)],initializer:function(){return!1},enumerable:!0}],null,b);q(d,[{key:"settings",value:function(){var b=0>=arguments.length||void 0===arguments[0]?null: arguments[0];return(0,a.isObject)(b)?(this._settings=(0,a.assignStrict)(this._defaultSettings||{},this._settings||{},b),this):(0,a.copy)(this._settings||this._defaultSettings||{})}},{key:"isRequesting",value:function(){return this._requesting}},{key:"_extendDefaultSettings",value:function(b){this._defaultSettings=(0,a.assign)(this._defaultSettings||{},b);return this}},{key:"_newRequest",value:function(b,d){var c=this;if(!this.trigger("_newRequest")&&!this._requestingOverridden)return console.warn("To ensure accurate measures, you can only make one request at a time."), this;var f=this.settings(),e=new XMLHttpRequest;if(!~["GET","POST"].indexOf(b))return console.warn("The HTTP method must be GET or POST."),this;d=d||{};this._lastURLToken="network-"+(new Date).getTime();var a=f.endpoint,a=a+(~a.indexOf("?")?"\x26":"?"),a=a+("module\x3d"+this._moduleName);Object.keys(d).forEach(function(c){var b=encodeURIComponent(d[c]);a+="\x26"+c+"\x3d"+b});a+="\x26"+this._lastURLToken;e.open(b,a);this._xhr&&this._xhr.readyState==XMLHttpRequest.OPENED&&this._xhr.abort();this._xhr= e;"loadstart progress abort error load timeout loadend readystatechange".split(" ").forEach(function(b){e.addEventListener(b,function(){for(var f=arguments.length,d=Array(f),a=0;a<f;a++)d[a]=arguments[a];("progress"!=b||c._requesting)&&c.trigger.apply(c,["xhr-"+b,e].concat(d))});"readystatechange"!=b&&e.upload.addEventListener(b,function(){for(var f=arguments.length,d=Array(f),a=0;a<f;a++)d[a]=arguments[a];c.trigger.apply(c,["xhr-upload-"+b,e].concat(d))})});var g=function(b){setTimeout(function(){b.readyState!= XMLHttpRequest.UNSENT&&b.readyState!=XMLHttpRequest.DONE&&(c.trigger("xhr-timeout"),c.trigger("xhr-upload-timeout"),b.abort())},f.delay)};this.on("xhr-upload-loadstart",g).on("xhr-readystatechange",function(c){return function(b){c||b.readyState!=XMLHttpRequest.LOADING||(c=!0,g(b))}}(!1));return this}},{key:"_sendRequest",value:function(){var b=0>=arguments.length||void 0===arguments[0]?null:arguments[0];this._xhr&&this._xhr.readyState==XMLHttpRequest.OPENED?this._xhr.send(b):console.warn("A request must have been created before sending any data."); return this}},{key:"_abort",value:function(){this._xhr&&this._xhr.abort();return this}},{key:"_getTimingEntry",value:function(b){setTimeout(function(f){return function(){var c=performance.getEntriesByType("resource").filter(function(c){return~c.name.indexOf(f)});b(c.length?c[0]:null)}}(this._lastURLToken),0);return this}},{key:"_setRequesting",value:function(b){this._requestingOverridden=!0;this._requesting=b;return this}}],null,b);return d}(h["default"]);n["default"]=k;u.exports=n["default"]},{"../../utils/decorators":7, "../../utils/helpers":8,"../EventDispatcher":1}],4:[function(k,u,n){function t(b,f){if("function"!==typeof f&&null!==f)throw new TypeError("Super expression must either be null or a function, not "+typeof f);b.prototype=Object.create(f&&f.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});f&&(Object.setPrototypeOf?Object.setPrototypeOf(b,f):b.__proto__=f)}function l(b,f,d){if(d=d[f]){var c={},a;for(a in d)c[a]=d[a];c.value=c.initializer.call(b);Object.defineProperty(b,f, c)}}Object.defineProperty(n,"__esModule",{value:!0});var q=function(){function b(b,d,c){for(var f=0;f<d.length;f++){var a=d[f],e=a.decorators,g=a.key;delete a.key;delete a.decorators;a.enumerable=a.enumerable||!1;a.configurable=!0;if("value"in a||a.initializer)a.writable=!0;if(e){for(var h=0;h<e.length;h++){var k=e[h];if("function"===typeof k)a=k(b,g,a)||a;else throw new TypeError("The decorator for method "+a.key+" is of the invalid type "+typeof k);}if(void 0!==a.initializer){c[g]=a;continue}}Object.defineProperty(b, g,a)}}return function(a,d,c,e,g){d&&b(a.prototype,d,e);c&&b(a,c,g);return a}}(),p=function(b,a,d){var c=!0;for(;c;)if(null===b&&(b=Function.prototype),c=Object.getOwnPropertyDescriptor(b,a),void 0===c){b=Object.getPrototypeOf(b);if(null===b)break;c=!0}else{if("value"in c)return c.value;a=c.get;return void 0===a?void 0:a.call(d)}},h=k("./HttpModule"),h=h&&h.__esModule?h:{"default":h},a=k("../Timing"),g=a&&a.__esModule?a:{"default":a},e=k("../../utils/helpers"),d=k("../../utils/decorators");k=function(b){function a(){var c= 0>=arguments.length||void 0===arguments[0]?{}:arguments[0];if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");p(Object.getPrototypeOf(a.prototype),"constructor",this).call(this,"latency");l(this,"_supportsResourceTiming",h);l(this,"_requestsLeft",h);l(this,"_attemptsLeft",h);l(this,"_latencies",h);l(this,"_requestID",h);l(this,"_timingLabels",h);this._extendDefaultSettings({measures:5,attempts:3}).settings(c);this._defineResourceTimingSupport()}var h={},h={};t(a,b);q(a, [{key:"_supportsResourceTiming",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_requestsLeft",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_attemptsLeft",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_latencies",decorators:[(0,d.enumerable)(!1)],initializer:function(){},enumerable:!0},{key:"_requestID",decorators:[(0,d.enumerable)(!1)],initializer:function(){return 0},enumerable:!0},{key:"_timingLabels", decorators:[(0,d.enumerable)(!1)],initializer:function(){return{start:null,end:null,measure:null}},enumerable:!0}],null,h);q(a,[{key:"settings",value:function(){var c=0>=arguments.length||void 0===arguments[0]?null:arguments[0];return(0,e.isObject)(c)?p(Object.getPrototypeOf(a.prototype),"settings",this).call(this,(0,e.assignStrict)(c,{delay:0})):(0,e.except)(p(Object.getPrototypeOf(a.prototype),"settings",this).call(this),["delay"])}},{key:"start",value:function(){var c=this.settings(),b=c.measures, c=c.attempts;this._requestsLeft=b;this._attemptsLeft=c*b;this._supportsResourceTiming||(this._requestsLeft++,this._attemptsLeft++);this._setRequesting(!0);this._latencies=[];this._nextRequest();return this}},{key:"_defineResourceTimingSupport",value:function(c){var b=this;"boolean"!==typeof c&&(c=g["default"].supportsResourceTiming);this._supportsResourceTiming=c;this.off(["xhr-load","xhr-loadstart","xhr-readystatechange"]);if(c)this.on("xhr-load",function(){return b._measure()});else this.on("xhr-loadstart", function(){return g["default"].mark(b._timingLabels.start)}),this.on("xhr-readystatechange",function(c){return b._measure(c)})}},{key:"_nextRequest",value:function(){var b=this,a=0>=arguments.length||void 0===arguments[0]?!1:arguments[0],d=this._requestID++,e=a?this._requestsLeft:this._requestsLeft--;this._attemptsLeft--&&(e||a)?(a=this._timingLabels,a.start="latency-"+d+"-start",a.end="latency-"+d+"-end",a.measure="latency-"+d+"-measure",this._newRequest("GET")._sendRequest()):(this._setRequesting(!1), setTimeout(function(){return b._end()},0));return this}},{key:"_measure",value:function(){var b=this,a=0>=arguments.length||void 0===arguments[0]?null:arguments[0];a?this._requestsLeft<this.settings().measures?a.readyState==XMLHttpRequest.HEADERS_RECEIVED&&(a=this._timingLabels,g["default"].mark(a.end),(a=g["default"].measure(a.measure,a.start,a.end))&&this._latencies.push(a),this._abort(),this._nextRequest(!a)):this._nextRequest():this._getTimingEntry(function(a){(a=a.secureConnectionStart?a.secureConnectionStart- a.connectStart:a.connectEnd-a.connectStart)&&b._latencies.push(a);b._nextRequest(!a)});return this}},{key:"_end",value:function(){var a=this._latencies,b=a.reduce(function(a,b){return a+b},0)/(a.length||1),b=b||null;if(!a.length)return this._defineResourceTimingSupport(!1),this.start(),this;if(a.length<this.settings().measures){var d=this.settings();console.warn("\n An insufficient number of measures have been processed, this could be due to your web server using\n persistant connections or to your client settings (measures: "+ d.measures+", attempts: "+d.attempts+").\n ")}this.trigger("end",b,a);return this}}],null,h);return a}(h["default"]);n["default"]=k;u.exports=n["default"]},{"../../utils/decorators":7,"../../utils/helpers":8,"../Timing":6,"./HttpModule":3}],5:[function(k,u,n){function t(a){return a&&a.__esModule?a:{"default":a}}function l(a,b,d){b in a?Object.defineProperty(a,b,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[b]=d;return a}function q(a,b,d){if(d=d[b]){var c={},e;for(e in d)c[e]=d[e]; c.value=c.initializer.call(a);Object.defineProperty(a,b,c)}}Object.defineProperty(n,"__esModule",{value:!0});var p=function(){function a(a,b,d){for(var c=0;c<b.length;c++){var e=b[c],f=e.decorators,g=e.key;delete e.key;delete e.decorators;e.enumerable=e.enumerable||!1;e.configurable=!0;if("value"in e||e.initializer)e.writable=!0;if(f){for(var h=0;h<f.length;h++){var m=f[h];if("function"===typeof m)e=m(a,g,e)||e;else throw new TypeError("The decorator for method "+e.key+" is of the invalid type "+ typeof m);}if(void 0!==e.initializer){d[g]=e;continue}}Object.defineProperty(a,g,e)}}return function(b,c,d,e,f){c&&a(b.prototype,c,e);d&&a(b,d,f);return b}}(),h=k("./EventDispatcher"),a=t(h),h=k("./Http/HttpModule"),g=t(h),h=k("./Http/LatencyModule"),e=t(h),h=k("./Http/BandwidthModule"),d=t(h),h=k("./Timing"),b=t(h),f=k("../utils/helpers"),r=k("../utils/decorators");k=function(){function c(){var a=0>=arguments.length||void 0===arguments[0]?{}:arguments[0];if(!(this instanceof c))throw new TypeError("Cannot call a class as a function"); q(this,"_modules",h);q(this,"_modulesInitialized",h);q(this,"_pendingSettings",h);this._registerModule("latency",function(a){return new e["default"](a)})._registerModule("upload",function(a){return new d["default"]("upload",a)})._registerModule("download",function(a){return new d["default"]("download",a)});this._initModules(this.settings(a))}var h={},h={};p(c,[{key:"_modules",decorators:[(0,r.enumerable)(!1)],initializer:function(){return{}},enumerable:!0},{key:"_modulesInitialized",decorators:[(0, r.enumerable)(!1)],initializer:function(){return!1},enumerable:!0},{key:"_pendingSettings",decorators:[(0,r.enumerable)(!1)],initializer:function(){return{}},enumerable:!0}],[{key:"_exposeInternalClasses",decorators:[(0,r.enumerable)(!1)],value:function(){var c=(0,f.getGlobalObject)(),h={EventDispatcher:a["default"],HttpModule:g["default"],LatencyModule:e["default"],BandwidthModule:d["default"],Timing:b["default"]};Object.keys(h).forEach(function(a){c[a]=h[a]});return this}},{key:"supportsResourceTiming", get:function(){return b["default"].supportsResourceTiming}}],h);p(c,[{key:"settings",value:function(){var a=this,b=0>=arguments.length||void 0===arguments[0]?null:arguments[0],c=Object.keys(this._modules);if((0,f.isObject)(b)){var d=function(){var d=(0,f.except)(b,c),e=(0,f.except)(b,Object.keys(d));b=c.reduce(function(a,b){return(0,f.assign)(a,l({},b,d))},{});b=(0,f.assign)(b,e);a._modulesInitialized?Object.keys(a._modules).forEach(function(c){a._modules[c].settings(b[c])}):a._pendingSettings=b; return{v:a}}();if("object"===typeof d)return d.v}else return c.reduce(function(b,c){return(0,f.assign)(b,l({},c,a._modules[c].settings()))},{})}},{key:"isRequesting",value:function(){var a=!1,b;for(b in this._modules)this._modules.hasOwnProperty(b)&&(a=a||this._modules[b].isRequesting());return a}},{key:"_registerModule",value:function(a,b){this._modules[a]=b;return this}},{key:"_initModules",value:function(){var a=this;this._modulesInitialized||(Object.keys(this._modules).forEach(function(b){a._modules[b]= a._modules[b](a._pendingSettings[b]).on("_newRequest",function(){return!a.isRequesting()});a[b]=a._modules[b]}),this._modulesInitialized=!0);return this}}],null,h);return c}();n["default"]=k;u.exports=n["default"]},{"../utils/decorators":7,"../utils/helpers":8,"./EventDispatcher":1,"./Http/BandwidthModule":2,"./Http/HttpModule":3,"./Http/LatencyModule":4,"./Timing":6}],6:[function(k,u,n){function t(h,a,g){if(g=g[a]){var e={},d;for(d in g)e[d]=g[d];e.value=e.initializer.call(h);Object.defineProperty(h, a,e)}}Object.defineProperty(n,"__esModule",{value:!0});var l=function(){function h(a,g,e){for(var d=0;d<g.length;d++){var b=g[d],f=b.decorators,h=b.key;delete b.key;delete b.decorators;b.enumerable=b.enumerable||!1;b.configurable=!0;if("value"in b||b.initializer)b.writable=!0;if(f){for(var c=0;c<f.length;c++){var k=f[c];if("function"===typeof k)b=k(a,h,b)||b;else throw new TypeError("The decorator for method "+b.key+" is of the invalid type "+typeof k);}if(void 0!==b.initializer){e[h]=b;continue}}Object.defineProperty(a, h,b)}}return function(a,g,e,d,b){g&&h(a.prototype,g,d);e&&h(a,e,b);return a}}(),q=k("../utils/helpers"),p=k("../utils/decorators");k=function(){function h(){if(!(this instanceof h))throw new TypeError("Cannot call a class as a function");t(this,"_support",a);t(this,"_marks",a);t(this,"_measures",a);var g=(0,q.getGlobalObject)();this._support={performance:!!g.performance,userTiming:g.performance&&performance.mark,resourceTiming:g.performance&&"function"==typeof performance.getEntriesByType&&performance.timing}} var a={},a={};l(h,[{key:"supportsResourceTiming",get:function(){return!!this._support.resourceTiming}},{key:"_support",decorators:[(0,p.enumerable)(!1)],initializer:function(){return{}},enumerable:!0},{key:"_marks",decorators:[(0,p.enumerable)(!1)],initializer:function(){return{}},enumerable:!0},{key:"_measures",decorators:[(0,p.enumerable)(!1)],initializer:function(){return{}},enumerable:!0}],null,a);l(h,[{key:"mark",value:function(a){var e=this._support,d=this._marks;e.userTiming&&performance.mark(a); d[a]=e.performance?performance.now():(new Date).getTime();return this}},{key:"measure",value:function(a,e,d){var b=this._support,f=this._marks,g=this._measures;"undefined"==typeof g[a]&&(f=f[d]-f[e],b.userTiming?(performance.measure(a,e,d),e=performance.getEntriesByName(a),g[a]=e.length?e[0].duration:f):g[a]=f);return g[a]}}],null,a);return h}();n["default"]=new k;u.exports=n["default"]},{"../utils/decorators":7,"../utils/helpers":8}],7:[function(k,u,n){Object.defineProperty(n,"__esModule",{value:!0}); n.enumerable=function(k){return function(l,n,p){p.enumerable=k;return p}}},{}],8:[function(k,u,n){(function(k){function l(a){return void 0!=a&&null!=a&&"object"==typeof a.valueOf()}function q(a){return JSON.parse(JSON.stringify(a))}function p(a){for(var g=1>=arguments.length||void 0===arguments[1]?{}:arguments[1],g=q(g),e=arguments.length,d=Array(2<e?e-2:0),b=2;b<e;b++)d[b-2]=arguments[b];d.forEach(function(b){Object.keys(b).forEach(function(d){if(!a||g.hasOwnProperty(d)){var c=b[d];g[d]=l(c)?p(a, g[d],c):c}})});return g}Object.defineProperty(n,"__esModule",{value:!0});var h=function(){function a(a,e){for(var d=0;d<e.length;d++){var b=e[d];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(g,e,d){e&&a(g.prototype,e);d&&a(g,d);return g}}();n.getGlobalObject=function(){return"undefined"!==typeof self?self:"undefined"!==typeof k?k:(new Function("return this"))()};n.isObject=l;n.copy=q;n.assign=function(){for(var a=0>= arguments.length||void 0===arguments[0]?{}:arguments[0],g=arguments.length,e=Array(1<g?g-1:0),d=1;d<g;d++)e[d-1]=arguments[d];return p.apply(void 0,[!1,a].concat(e))};n.assignStrict=function(){for(var a=0>=arguments.length||void 0===arguments[0]?{}:arguments[0],g=arguments.length,e=Array(1<g?g-1:0),d=1;d<g;d++)e[d-1]=arguments[d];return p.apply(void 0,[!0,a].concat(e))};n.except=function(a,g){var e=q(a);g.forEach(function(a){return delete e[a]});return e};n.defer=function(){var a=0>=arguments.length|| void 0===arguments[0]?function(){}:arguments[0];return new (function(){function g(){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");this.func=a}h(g,[{key:"run",value:function(){this.func&&this.func();delete this.func}}]);return g}())}}).call(this,"undefined"!==typeof global?global:"undefined"!==typeof self?self:"undefined"!==typeof window?window:{})},{}]},{},[5])(5)});