(window.webpackJsonp=window.webpackJsonp||[]).push([[40],{1979:function(t,e,o){"use strict";var n=o(12),r=o(39);n({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return r(URL.prototype.toString,this)}})},1982:function(t,e,o){t.exports=function(){"use strict";var t=function(e,s){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])},t(e,s)};function e(e,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function o(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(o.prototype=s.prototype,new o)}function s(t,e,s,o){return new(s||(s=Promise))((function(i,n){function r(t){try{l(o.next(t))}catch(t){n(t)}}function a(t){try{l(o.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(r,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e){var s,o,i,n={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},r=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return r.next=a(0),r.throw=a(1),r.return=a(2),"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(l){return function(a){if(s)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(n=0)),n;)try{if(s=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(!((i=(i=n.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){n=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]i+e*(n+1)&&(n++,t(o)),s(a))}(),o},t.prototype.clearIntervalPrecision=function(t){if(this.interValPrecisionObj){var e=function(t){};try{e=e||webkitCancelAnimationFrame||mozCancelAnimationFrame||msCancelAnimationFrame}catch(t){}e(t),delete this.interValPrecisionObj["n"+t]}},t}());self.onmessage=function(e){if(e.data){var s=JSON.parse(e.data),o=s.name;"start"===o&&t.setIntervalPrecision((function(t){self.postMessage(t)}),s.timeout),"stop"===o&&t.clearIntervalPrecision(s.intervalId)}else self.postMessage(0)}}.toString();n=n.substring(n.indexOf("{")+1,n.lastIndexOf("}"));var r,l,d,h,c=new Blob([n],{type:"application/javascript"}),a=URL.createObjectURL(c),y=function(t){function s(){return null!==t&&t.apply(this,arguments)||this}return e(s,t),s.judgeTag=function(){if(this.judge()){var t=navigator.userAgent;return t.indexOf("Android")>-1||t.indexOf("Linux")>-1?"android":"iOS"}return null},s}(function(){function t(){}return t.judge=function(){for(var t=navigator.userAgent,e=["Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"],s=!1,o=0;o0){s=!0;break}return s},t}()),f=function(){function t(){this.userAgent=navigator.userAgent}return t.prototype.judge=function(){return navigator.userAgent.indexOf("UCBrowser")>-1||navigator.userAgent.indexOf("UBrowser")>-1?"UC":this.userAgent.indexOf("Edge")>-1||this.userAgent.indexOf("Edge")>-1?"Edge":this.userAgent.indexOf("Opera")>-1?"Opera":this.userAgent.indexOf("Firefox")>-1?"FF":this.userAgent.indexOf("Chrome")>-1?"Chrome":this.userAgent.indexOf("Safari")>-1?"Safari":(this.userAgent.indexOf("compatible")>-1&&this.userAgent.indexOf("MSIE")>-1&&this.userAgent.indexOf("Opera"),"IE")},t}(),u=function(t){function s(){var e=t.call(this)||this;return e.network="",e}return e(s,t),s.prototype.getType=function(){"iOS"===y.judgeTag()&&(this.network=2);var t=window.navigator.connection?window.navigator.connection.type:0,e=window.navigator.connection?window.navigator.connection.downlinkMax:0;return this.judgeBrowser()?this.network=1:this.network="wifi"===t?2:"cellular"===t?e>100?6:100===e?5:e>21?4:2:2,this.network},s}((function(){this.judgeBrowser=function(){var t=navigator.userAgent.toLowerCase(),e="ipad"==t.match(/ipad/i),s="iphone os"==t.match(/iphone os/i),o="midp"==t.match(/midp/i),i="rv:1.2.3.4"==t.match(/rv:1.2.3.4/i),n="ucweb"==t.match(/ucweb/i),r="android"==t.match(/android/i),a="windows ce"==t.match(/windows ce/i),l="windows mobile"==t.match(/windows mobile/i);return!(e||s||o||i||n||r||a||l)}})),w=function(){function t(){this.mainSelf=null,this.numberUtil=null,this.wsNodeList=[],this.confirmNodeInfoCallback=function(){}}return t.prototype.setMainSelf=function(t){this.mainSelf=t},t.prototype.setNumberUtil=function(t){this.numberUtil=t},t.prototype.setConfirmNodeInfoCallback=function(t){void 0===t&&(t=function(){}),this.confirmNodeInfoCallback=t},t.prototype.run=function(t,e){if(!t){var s=this.mainSelf;this.wsNodeList=JSON.parse(JSON.stringify(e)),this.wsNodeList.map((function(t){t.timer=null,t.wsError=!1,t.wsObj=null})),s.networkList=[s.getNetworkType()],s.pingType="websocket",s.ping="-";for(var o=0;oe?1:0})),e.length%2==0?(e[t.length/2-1]+e[e.length/2])/2:e[Math.floor(e.length/2)]},t.prototype.getIqm=function(t){if(!t.length)return null;var e=t.length,s=t.length%4,o=i([],t,!0).sort((function(t,e){return t-e}));if(!s){var n=o.slice(.25*e,.75*e);return isNaN(this.getAvg(n))?null:this.getAvg(n)}var r=this.iqmFunc(o,e);return isNaN(r)?null:r},t.prototype.iqmFunc=function(t,e){var s=t.length/4,o=t.slice(Math.floor(.25*e),Math.ceil(.75*e)),i=o.splice(0,1)[0],n=o.splice(-1)[0];return+((o.reduce((function(t,e){return t+e}),0)+(i+n)*((2*s-o.length)/2))/(2*s)).toFixed(2)},t}(),m=function(){function t(){}return t.prototype.run=function(t){return t.length?JSON.stringify(t):null},t}(),v=new u,S=new p,g=new m,C=function(t,e){var s="";try{s=Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){}for(var o=[t.defaultNode.id],i=0;ithis.splitIndex&&this.splitIndex>-1||!this.self.downloadExecutingState&&this.self.uploadExecutingState?this.upSendList=i(i([],this.upSendList,!0),[e],!1):this.downSendList=i(i([],this.downSendList,!0),[e],!1))}},t.prototype.startReceive=function(){var t=this;this.wsCase&&(this.wsCase.onmessage=function(e){if(!e.data.includes("ERROR")&&t.wsCase){var s=(new Date).getTime();t.receiveList=i(i([],t.receiveList,!0),[s],!1);var o=t.receiveList.length-1;if(t.busyDelayList=i(i([],t.busyDelayList,!0),[t.receiveList[o]-t.sendList[o]],!1),t.receiveList.length>t.splitIndex&&t.splitIndex>-1||!t.self.downloadExecutingState&&t.self.uploadExecutingState)return t.upReceiveList=i(i([],t.upReceiveList,!0),[s],!1),void(t.busyUpDelayList=i(i([],t.busyUpDelayList,!0),[t.busyDelayList.slice(-1)[0]],!1));t.downReceiveList=i(i([],t.downReceiveList,!0),[s],!1),t.busyDownDelayList=i(i([],t.busyDownDelayList,!0),[t.busyDelayList.slice(-1)[0]],!1)}else t.closeWs()})},t.prototype.closeWs=function(){this.wsCase&&(this.wsCase.close(),this.wsCase=null)},t.prototype.listenWsError=function(){var t=this;this.wsCase&&(this.wsCase.onerror=function(){t.wsError=!0,t.wsCase=null})},t.prototype.initBusy=function(){this.link="",this.wsCase=null,this.sendList=[],this.receiveList=[],this.downSendList=[],this.upSendList=[],this.downReceiveList=[],this.upReceiveList=[],this.busyDelayList=[],this.busyDownDelayList=[],this.busyUpDelayList=[],this.splitIndex=-1,this.wsError=!1},t}(),k=function(){function t(){}return t.prototype.run=function(t,e){var s=+(1.2*t).toFixed(2);if(!e.length)return isNaN(s)?null:s;var o=e.filter((function(e){return+e<=1.2*t&&+e>=t}));return o.length?+Math.max.apply(Math,o).toFixed(2):isNaN(s)?null:s},t}(),L=(r=window.WebAssembly,l=!1,"object"==typeof r&&"function"==typeof r.Memory&&("function"!=typeof r.instantiateStreaming&&"function"!=typeof r.instantiate||(l=!0)),l),x=function(){function t(){this.bytesTransferred=0,this.connectionSamples=[],this.instantsList=[],this.speedType=1,this.startTime=0,this.testLength=0,this.worker=null,this.downloadAlgorithm=+L,this.uploadAlgorithm=0,this.downloadAlgorithmType=L,this.uploadAlgorithmType=!1,this.algorithmStatus=!1,this.speedChartList=[],this.downloadFastProgress=.7,this.downloadFastIntensity=.85,this.uploadFastProgress=.7,this.uploadFastIntensity=.98,this.downloadFastType=L,this.uploadFastType=!1,this.svmFile="https://file2.speedtest.cn/wasm/1.1.3/svm.js"}return t.prototype.setDownloadAlgorithmType=function(t){this.downloadAlgorithmType=t,this.setAlgorithmType(t)},t.prototype.setUploadAlgorithmType=function(t){this.uploadAlgorithmType=t,this.setAlgorithmType(t)},t.prototype.setDownloadFastType=function(t){this.downloadFastType=t},t.prototype.setUploadFastType=function(t){this.uploadFastType=t},t.prototype.setAlgorithmType=function(t){L&&t&&!this.algorithmStatus?this.algorithmStatus=!0:this.algorithmStatus=!1},t.prototype.initSvm=function(){var t;L&&(t=this.svmFile,new Promise((function(e,s){var o=document.createElement("script");o.type="text/javascript",o.src=t,document.body.appendChild(o),o.onload=function(){e()},o.onerror=function(){s()}})))},t.prototype.setSpeedChartList=function(t){this.speedChartList=t},t.prototype.setBytesTransferred=function(t){this.bytesTransferred=t},t.prototype.setConnectionSamples=function(t){this.connectionSamples=t},t.prototype.setInstantsList=function(t){this.instantsList=t},t.prototype.setSpeedType=function(t){this.speedType=t},t.prototype.setStartTime=function(t){this.startTime=t},t.prototype.setTestLength=function(t){this.testLength=t},t.prototype.setWorker=function(t){null===t&&this.worker&&this.worker.terminate(),this.worker=t},t.prototype.setDownloadAlgorithm=function(t){this.downloadAlgorithm=t},t.prototype.setUUploadAlgorithm=function(t){this.uploadAlgorithm=t},t.prototype.getDownloadAlgorithm=function(){return this.downloadAlgorithm},t.prototype.getUploadAlgorithm=function(){return this.uploadAlgorithm},t.prototype.setDownloadFastProgress=function(t){this.downloadFastProgress=t},t.prototype.setDownloadFastIntensity=function(t){this.downloadFastIntensity=t},t.prototype.setUploadFastProgress=function(t){this.uploadFastProgress=t},t.prototype.setUploadFastIntensity=function(t){this.uploadFastIntensity=t},t.prototype.queryVelocityResult=function(){var t=this;return new Promise((function(e){if(t.instantsList.length){if(1===t.speedType){if(!L||!t.downloadAlgorithmType)return t.downloadAlgorithm=0,void e([t.oldSpeed(),!1])}else if(!L||!t.uploadAlgorithmType)return t.uploadAlgorithm=0,void e([t.oldSpeed(),!1]);try{var s=+(+Module.waper(t.speedType,t.instantsList)).toFixed(2);1===t.speedType?t.downloadAlgorithm=1:t.uploadAlgorithm=1,t.speedChartList=i(i([],t.speedChartList,!0),[s],!1),e([s,t.fastSpeed()])}catch(s){console.log("e is",s),1===t.speedType?t.downloadAlgorithm=0:t.uploadAlgorithm=0,e([t.oldSpeed(),!1])}}else e([0,!1])}))},t.prototype.oldSpeed=function(){var t=+(1e3*this.bytesTransferred/(Date.now()-this.startTime)).toFixed(2),e=0;if(this.connectionSamples.length>=4){var s=Math.ceil(.75*(this.connectionSamples.length-2));e=+(this.arraySam(this.connectionSamples.slice(2,s+2))/s).toFixed(2)}var o=Math.min((Date.now()-this.startTime)/this.testLength,1);return+((e>0&&e>t?o*e+(1-o)*t:t)/125e3).toFixed(2)},t.prototype.arraySam=function(t){return t.reduce((function(t,e){return t+e}),0)},t.prototype.fastSpeed=function(){if(!this.downloadFastType&&1===this.speedType||!this.uploadFastType&&2===this.speedType)return!1;try{return!!+Module.waper_stop(3,this.speedChartList,1===this.speedType?this.downloadFastProgress:this.uploadFastProgress,1===this.speedType?this.downloadFastIntensity:this.uploadFastIntensity)}catch(t){return!1}},t}(),D=navigator.userAgent.indexOf("UCBrowser")>-1,I=new p,R=!1;!function(t){t[t.avg=0]="avg",t[t.max=1]="max"}(d||(d={})),function(t){t[t.init=null]="init",t[t.start=0]="start",t[t.selectNode=1]="selectNode",t[t.ping=2]="ping",t[t.download=3]="download",t[t.upload=4]="upload",t[t.end=5]="end"}(h||(h={}));var P=function(){function t(){var t=this;this.ping="-",this.jitter="-",this.loss="-",this.downloadSpeed=0,this.uploadSpeed=0,this.download_chart=[],this.upload_chart=[],this.downloadInstants=[],this.uploadInstants=[],this.downloadInstantIntervals=[],this.uploadInstantIntervals=[],this.pingType="websocket",this.downloadWait=1e3,this.uploadWait=1e3,this.uploadFileSize=104857600,this.xhr=[],this.xhrRequestList=[],this.progress=null,this.connectionSamples=[],this.connectionResults=[],this.defaultNode=null,this.spareNodes=[],this.speedState=0,this.bytesTransferred=0,this.endDownload=!1,this.worker=null,this.busyWorker=null,this.uploadOnprogress=!1,this.downloadOnprogress=!1,this.unit="Mbps",this.code=0,this.pingCallback=function(){},this.speedCallback=function(){},this.finishCallback=function(){},this.nodeInfoCallback=function(){},this.errorCallback=function(){},this.storeCallback=function(){},this.busyPingCallback=function(){},this.crestCallback=function(){},this.pingResultCallback=function(){},this.getSpeedStatusCallback=function(){},this.downloadStart=0,this.downloadEnd=0,this.uploadStart=0,this.uploadEnd=0,this.pingTimeList=[],this.jitter_a=[],this.timezone_offset_seconds_a=Math.abs(60*(new Date).getTimezoneOffset()),this.app_version_a=T,this.downloadAllCount=0,this.downloadErrorCount=0,this.download_flow="0",this.upload_flow="0",this.workerCount=0,this.preTime=0,this.preBytesTransferred=0,this.instants=[],this.instantIntervals=[],this.ipv6="",this.ipv4="",this.workTime=100,this.downloadProtocol="http",this.uploadProtocol="http",this.shortTest=0,this.preNetwork=2,this.skipUpload=!1,this.normalEndSpeed=!0,this.exception=0,this.nodeFailCount={},this.startTime="",this.busyPing=new b,this.pingTest=new w,this.speedType="",this.delayList=[],this.networkList=[],this.downloadBusyDelay=null,this.uploadBusyDelay=null,this.downloadBusyBool=!1,this.speedCrest=new k,this.downloadCrest=null,this.uploadCrest=null,this.velocityResult=new x,this.progressCount=0,this.preProgressCount=0,this.maxDownloadConnect=4,this.maxUploadConnect=4,this.maxDownloadSpareConnect=1,this.maxUploadSpareConnect=1,this.downloadFastTest=1,this.uploadFastTest=1,this.spareNodeCount=2,this.velocityResult.initSvm(),this.workerIntervalId=0,this.busyWorkerIntervalId=0,this.downloadFileSize=25e6,this.uploadBlob=null,this.judgeUploadBlob=null,this.phoneVersion=y.judgeTag(),this.byteNum=1e3,this.downloadResultStatus=d.avg,this.uploadResultStatus=d.avg,this.filterNodesBool=!0,this.downloadTime=15e3,this.uploadTime=15e3,this.downloadExecutingState=!0,this.uploadExecutingState=!0,this.speedStatus=h.init,this.handleUploadBlob(),window.onbeforeunload=function(e){t.stop()},window.onerror=function(t){console.log("error is",t)}}return t.prototype.setSpeedTimer=function(t){this.downloadTime=t.downloadTime&&t.downloadTime<=15e3?t.downloadTime:15e3,this.uploadTime=t.uploadTime&&t.uploadTime<=15e3?t.uploadTime:15e3},t.prototype.setSpeedExecutingState=function(t){t.hasOwnProperty("downloadExecutingState")&&!t.downloadExecutingState&&t.hasOwnProperty("uploadExecutingState")&&!t.uploadExecutingState||(this.downloadExecutingState=!t.hasOwnProperty("downloadExecutingState")||t.downloadExecutingState,this.uploadExecutingState=!t.hasOwnProperty("uploadExecutingState")||t.uploadExecutingState)},t.prototype.setResultStatus=function(t){this.downloadResultStatus=t.downloadStatus||d.avg,this.uploadResultStatus=t.uploadStatus||d.avg},t.prototype.setMaxConnect=function(t){this.maxDownloadConnect=t.download.defaultNodeCount,this.maxDownloadSpareConnect=t.download.spareNodeCount,this.maxUploadConnect=t.upload.defaultNodeCount,this.maxUploadSpareConnect=t.upload.spareNodeCount},t.prototype.setSpareNodeCount=function(t){this.spareNodeCount=t},t.prototype.getSpeedStatus=function(t){this.getSpeedStatusCallback=t},t.prototype.setDownloadFastProgress=function(t){this.velocityResult.setDownloadFastProgress(t)},t.prototype.setDownloadFastIntensity=function(t){this.velocityResult.setDownloadFastIntensity(t)},t.prototype.setUploadFastProgress=function(t){this.velocityResult.setUploadFastProgress(t)},t.prototype.setUploadFastIntensity=function(t){this.velocityResult.setUploadFastIntensity(t)},t.prototype.setDownloadFastType=function(t){this.downloadFastTest=+t,this.velocityResult.setDownloadFastType(t)},t.prototype.setUploadFastType=function(t){this.uploadFastTest=+t,this.velocityResult.setUploadFastType(t)},t.prototype.setDownloadAlgorithmType=function(t){this.velocityResult.setDownloadAlgorithmType(t)},t.prototype.setUploadAlgorithmType=function(t){this.velocityResult.setUploadAlgorithmType(t)},t.prototype.setDownloadWait=function(t){this.downloadWait=t},t.prototype.setUploadWait=function(t){this.uploadWait=t},t.prototype.setWorkTime=function(t){this.workTime=t},t.prototype.setFilterNodesBool=function(t){this.filterNodesBool=t},t.prototype.setSpeedNode=function(t){if(0==this.speedState){this.getSpeedStatusCallback(h.selectNode);var e=t.defaultNode,s=t.spareNodes;if(e&&(this.defaultNode=e),!s||!s.length)return void(this.spareNodes=[]);var o=Array.from(new Set(s));if(Array.from(new Set(i(i([],o,!0),this.defaultNode,!0))).length!==s.length+1&&this.maxDownloadConnect+this.maxDownloadSpareConnect>6&&this.filterNodesBool)return void(this.spareNodes=o.reduce((function(t,s){return s.host!==e.host&&(t=i(i([],t,!0),[s],!1)),t}),[]));this.spareNodes=s.splice(0,this.spareNodeCount)}},t.prototype.setUnit=function(t){"Mbps"!==t&&"kB/s"!==t&&"MB/s"!==t&&(t="Mbps"),this.unit=t},t.prototype.getNetworkType=function(){return(new u).getType()},t.prototype.queryIpv6=function(){var t=this;!function(t){try{var e=new(window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection)({iceServers:[]}),s=function(){},o={},i=/([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g;function n(e){!o[e]&&e.indexOf(".")<0&&t(e),o[e]=!0}e.createDataChannel(""),e.createOffer().then((function(t){t&&(t.sdp.split("\n").forEach((function(t){t.indexOf("candidate")<0||t.match(i).forEach(n)})),e.setLocalDescription(t,s,s))})),e.onicecandidate=function(t){t&&t.candidate&&t.candidate.candidate&&t.candidate.candidate.match(i)&&t.candidate.candidate.match(i).forEach(n)}}catch(r){t("")}}((function(e){t.ipv6=e}))},t.prototype.queryIpv4=function(){var t=this;!function(t){try{var e={},s=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection;if(!s){var o=document.getElementById("iframe").contentWindow;s=o.RTCPeerConnection||o.mozRTCPeerConnection||o.webkitRTCPeerConnection}var i=new s;function n(s){var o=/([0-9]{1,3}(\.[0-9]{1,3}){3}|([a-f0-9]{1,4}((:[a-f0-9]{1,4}){7}|:+[a-f0-9]{1,4}){6}))/;if(s.match(o)){var i=s.match(o)[1];e[i]||(t(i),e[i]=!0)}}i.onicecandidate=function(t){t.candidate&&n(t.candidate.candidate)},i.createDataChannel(""),i.createOffer((function(t){i.setLocalDescription(t)}),(function(){})),setTimeout((function(){try{if(!i.localDescription||!i.localDescription.sdp)return;i.localDescription.sdp.split("\n").forEach((function(t){0===t.indexOf("a=candidate:")&&n(t)}))}catch(t){}}),1e3)}catch(r){t("")}}((function(e){t.ipv4=e}))},t.prototype.handleUploadBlob=function(){this.phoneVersion&&(this.uploadFileSize=20971520);var t=[],e=new ArrayBuffer(1048576),s=Math.pow(2,32)-1;try{e=new Uint32Array(e);for(var o=0;o("download"===this.speedType?this.downloadTime:this.uploadTime)||l){if(this.worker){try{this.worker.postMessage(JSON.stringify({name:"stop",intervalId:this.workerIntervalId}))}catch(t){}this.worker.terminate(),this.worker=null,this.workerIntervalId=0}this.clearRequests(),this.statInstants(this.bytesTransferred,!0,a),c=this.downloadExecutingState&&!this.uploadExecutingState||"upload"===this.speedType,"download"===t&&(this.busyPing.startSend(this.busyPing.getSplitContent()),this.downloadEnd=(new Date).getTime(),this.downloadSpeed=this.downloadResultStatus===d.avg?s:Math.max.apply(Math,this.download_chart),this.endDownload=!0,this.download_flow=this.countFlow(this.bytesTransferred,this.download_chart),this.downloadInstants=this.instants,this.downloadInstantIntervals=this.instantIntervals,this.downloadFastTest=+l,this.downloadCrest=this.speedCrest.run(this.downloadSpeed,this.downloadInstants),D&&"iOS"===y.judgeTag()&&(this.uploadWait=0),this.networkList=i(i([],this.networkList,!0),[this.getNetworkType()],!1),this.uploadExecutingState&&setTimeout((function(){p.endDownload=!1,p.speed("upload")}),this.uploadWait)),"upload"===t&&(this.uploadEnd=(new Date).getTime(),this.uploadSpeed=this.uploadResultStatus===d.avg?s:Math.max.apply(Math,this.upload_chart),this.upload_flow=this.countFlow(this.bytesTransferred,this.upload_chart),this.networkList=i(i([],this.networkList,!0),[this.getNetworkType()],!1),this.uploadInstants=this.instants,this.uploadInstantIntervals=this.instantIntervals,this.uploadFastTest=+l,this.uploadCrest=this.speedCrest.run(this.uploadSpeed,this.uploadInstants)),c&&(this.endDownload=!0,this.busyPing.closeWs(),this.clearRequests(),this.stopWorker(),this.loss=0,this.setPingResultCallback(),this.speedState=0),this.crestCallback(t,"download"===t?this.downloadCrest:this.uploadCrest),this.finishCallback(t,"download"===t?this.downloadSpeed:this.uploadSpeed,"download"===t?this.download_flow:this.upload_flow,l),c&&(this.getSpeedStatusCallback(h.end),C(this,this.storeCallback))}return[2]}}))}))}),this.workTime),f="download"===this.speedType?this.maxDownloadConnect:this.maxUploadConnect,w=1;w<=f;w++)this.testStream(t,w,c,p,this.defaultNode);return m=[],this.spareNodes.length&&(m=this.spareNodes.slice(0,this.spareNodeCount)),m.length&&(g="download"===this.speedType?this.maxDownloadSpareConnect:this.maxUploadSpareConnect,v=f,m.map((function(e){if(e)for(var s=1;s<=g;s++)v+=1,S.testStream(t,v,e.downloadUrl,e.uploadUrl,e)}))),this.getConnectData(e),[2]}}))}))},t.prototype.handleVelocityResult=function(){this.velocityResult.setBytesTransferred(this.bytesTransferred),this.velocityResult.setConnectionSamples(this.connectionSamples),this.velocityResult.setInstantsList(this.instants),this.velocityResult.setSpeedType("download"===this.speedType?1:2),this.velocityResult.setStartTime(this.startTime),this.velocityResult.setTestLength("download"===this.speedType?this.downloadTime:this.uploadTime)},t.prototype.countFlow=function(t,e){if(t)return(t/this.byteNum/this.byteNum).toFixed(2);var s=0;return e.map((function(t){s+=+t})),(s/15/8).toFixed(2)},t.prototype.statInstants=function(t,e,s){this.workerCount++;var o=0;s-this.preTime20&&t-this.preBytesTransferred>0&&(this.progressCount!==this.preProgressCount||!this.progressCount)&&(o=1e3*(t-this.preBytesTransferred)/(s-this.preTime)/(this.byteNum*this.byteNum/8),this.instants.push(+o.toFixed(2)),this.instantIntervals.push(s-this.preTime)),this.progressCount!==this.preProgressCount&&(this.preTime=s),this.preBytesTransferred=t,this.preProgressCount=this.progressCount},t.prototype.convertSpeed=function(t){return"MB/s"===this.unit?t=+(t/8).toFixed(2):"kB/s"===this.unit&&(t=+Math.round(t/8*this.byteNum)),t},t.prototype.testStream=function(t,e,s,o,i){var n=this;setTimeout((function(){if(!(!n.xhr||R||n.nodeFailCount[i.id]>=3||n.nodeFailCount[i.id]>=3)){var r=0;n.xhr[e]=new XMLHttpRequest,n.progress=function(e){"upload"===t?n.uploadOnprogress=!0:n.downloadOnprogress=!0,n.progressCount++,n.bytesTransferred+=Math.abs(e.loaded-r),r=e.loaded},n.xhr[e].onerror=function(){try{n.xhr[e].abort()}catch(t){}delete n.xhr[e],R||"IE"==(new f).judge()||("download"===t&&(n.downloadErrorCount=n.downloadErrorCount+1),n.nodeFailCount[i.id]++,n.nodeFailCount[i.id]>=3?n.exception=1:n.testStream(t,e,s,o,i))},n.runSpeed(t,e,s,o,i,null)}}),1)},t.prototype.runSpeed=function(t,e,s,o,n,r){var a=this;!R&&this.xhr[e]&&("download"===t&&(this.downloadAllCount=this.downloadAllCount+1,this.xhr[e].onprogress=this.progress,this.xhr[e].onload=function(){},this.xhr[e].onloadend=function(){a.clearItemRequests(e),a.testStream(t,e,s,o,n)},this.xhr[e].ontimeout=function(){a.clearItemRequests(e),a.downloadErrorCount=a.downloadErrorCount+1},this.xhr[e].open("GET","".concat(s,"?size=").concat(this.downloadFileSize,"&r=").concat(Math.random()),!0),this.xhr[e].send(),this.xhrRequestList=i(i([],this.xhrRequestList,!0),[this.xhr[e]],!1)),"upload"===t&&(this.xhr[e].upload.onprogress=this.progress,this.xhr[e].onloadend=function(){a.clearItemRequests(e),a.testStream(t,e,s,o,n)},this.xhr[e].open("POST",o+"?r="+Math.random(),!0),this.xhr[e].setRequestHeader("Content-Type","application/octet-stream"),this.xhr[e].send(this.uploadBlob),this.xhrRequestList=i(i([],this.xhrRequestList,!0),[this.xhr[e]],!1)))},t.prototype.judgeUploadProgress=function(t){var e=this;return new Promise((function(s,o){try{var i=new XMLHttpRequest,n=!1,r=setTimeout((function(){s(!n)}),500);i.upload.onprogress=function(t){n=!0,clearTimeout(r),s(!1)},i.open("POST",t+"?r="+Math.random(),!0),i.setRequestHeader("Content-Type","application/octet-stream"),i.send(e.judgeUploadBlob)}catch(t){s(!0)}}))},t.prototype.skipUploadStore=function(){this.getSpeedStatusCallback(h.end),this.skipUpload=!0,this.loss=0,this.uploadEnd=(new Date).getTime(),this.clearRequests(),this.stopWorker(),this.speedState=0,this.busyPing.closeWs(),this.setPingResultCallback(),C(this,this.storeCallback)},t.prototype.terminateSpeed=function(){this.getSpeedStatusCallback(h.end),this.loss=0,this.normalEndSpeed=!1,this.clearRequests(),this.stopWorker(),this.speedState=0,this.busyPing.closeWs(),this.setPingResultCallback(),C(this,this.storeCallback)},t.prototype.setPingResultCallback=function(){this.pingResultCallback({delayMin:I.getMin(this.delayList),delayMax:I.getMax(this.delayList),delayAvg:I.getAvg(this.delayList),delayMedian:I.getMedian(this.delayList),delayMaxDownload:I.getMax(this.busyPing.getBusyDownDelayList()),delayMaxUpload:I.getMax(this.busyPing.getBusyUpDelayList()),delayMinDownload:I.getMin(this.busyPing.getBusyDownDelayList()),delayMinUpload:I.getMin(this.busyPing.getBusyUpDelayList()),delayAvgDownload:I.getAvg(this.busyPing.getBusyDownDelayList()),delayAvgUpload:I.getAvg(this.busyPing.getBusyUpDelayList()),delayMedianDownload:I.getMedian(this.busyPing.getBusyDownDelayList()),delayMedianUpload:I.getMedian(this.busyPing.getBusyUpDelayList()),jitterDownload:I.convertJitter(this.busyPing.getBusyDownDelayList()).jitter,jitterUpload:I.convertJitter(this.busyPing.getBusyUpDelayList()).jitter})},t.prototype.getConnectData=function(t){var e=this;if(this.busyWorker){try{this.busyWorker.postMessage(JSON.stringify({name:"stop",intervalId:this.busyWorkerIntervalId}))}catch(t){}this.busyWorker.terminate(),this.busyWorker=null,this.busyWorkerIntervalId=0}this.busyWorker=this.workerTimer((function(s){e.busyWorkerIntervalId||(e.busyWorkerIntervalId=+s.data);var o=Date.now()-t;if("upload"===e.speedType&&o>e.uploadTime&&e.busyWorker){try{e.busyWorker.postMessage(JSON.stringify({name:"stop",intervalId:e.busyWorkerIntervalId}))}catch(t){}e.busyWorker.terminate(),e.busyWorker=null,e.busyWorkerIntervalId=0}if(e.connectionResults=i(i([],e.connectionResults,!0),[{time:o,bytes:e.bytesTransferred}],!1),!(e.connectionResults.length<2)){var n=e.connectionResults.length,r=e.connectionResults[n-1].bytes-e.connectionResults[n-2].bytes,a=e.connectionResults[n-1].time-e.connectionResults[n-2].time,l=+(1e3*r/a).toFixed(2);if(e.speedType){var d=e.busyPing.getSplitIndex(),u=e.busyPing.getBusyDownDelayList(),h=e.busyPing.getBusyUpDelayList();e.busyPing.getReceiveList().length>d&&d>-1||!e.downloadExecutingState&&e.uploadExecutingState?(!e.downloadBusyBool&&e.downloadExecutingState&&(e.downloadBusyDelay=I.getIqm(u),e.downloadBusyBool=!0),e.uploadBusyDelay=I.getIqm(h)):e.downloadBusyDelay=I.getIqm(u),e.busyPingCallback({download:e.downloadBusyDelay,upload:e.uploadBusyDelay})}0===r&&0!==e.connectionResults[n-1].bytes||a>=600||a<400||l<0||(e.connectionSamples=i(i([],e.connectionSamples,!0),[l],!1).sort().reverse())}}),500)},t.prototype.clearRequests=function(){if(this.xhrRequestList&&this.xhrRequestList.length){for(var t in this.progress=null,this.xhrRequestList)this.clearItemRequests(+t);this.xhrRequestList=[],this.xhr=null}},t.prototype.clearItemRequests=function(t){if(this.xhrRequestList[t]){try{this.xhrRequestList[t].onprogress=null,this.xhrRequestList[t].onload=null,this.xhrRequestList[t].onloadend=null,this.xhrRequestList[t].onerror=null,this.xhrRequestList[t].upload.onprogress=null,this.xhrRequestList[t].upload.onload=null,this.xhrRequestList[t].upload.onloadend=null,this.xhrRequestList[t].upload.onerror=null,this.xhrRequestList[t].abort()}catch(t){console.log("e ---\x3e",t)}delete this.xhrRequestList[t]}},t.prototype.stopWorker=function(){if(R=!0,this.worker){try{this.worker.postMessage(JSON.stringify({name:"stop",intervalId:this.workerIntervalId}))}catch(t){}this.worker.terminate(),this.worker=null,this.workerIntervalId=0}if(this.busyWorker){try{this.busyWorker.postMessage(JSON.stringify({name:"stop",intervalId:this.busyWorkerIntervalId}))}catch(t){}this.busyWorker.terminate(),this.busyWorker=null,this.busyWorkerIntervalId=0}this.pingTest.closeAll(),this.velocityResult.setWorker(null)},t.prototype.stop=function(){this.stopWorker(),this.clearRequests(),this.reset()},t.prototype.reset=function(){this.ping="-",this.jitter="-",this.loss="-",this.downloadSpeed=0,this.uploadSpeed=0,this.download_chart=[],this.upload_chart=[],this.downloadInstants=[],this.uploadInstants=[],this.downloadInstantIntervals=[],this.uploadInstantIntervals=[],this.pingType="websocket",this.speedState=0,this.xhr=[],this.progress=null,this.connectionSamples=[],this.connectionResults=[],this.skipUpload=!1,this.bytesTransferred=0,this.normalEndSpeed=!0,this.skipUpload=!1,this.exception=0,this.speedType="",this.busyPing.closeWs(),this.delayList=[],this.networkList=[],this.downloadBusyDelay=null,this.uploadBusyDelay=null,this.downloadBusyBool=!1,this.downloadCrest=null,this.uploadCrest=null,this.pingCallback(this.ping,this.jitter),this.busyPingCallback({download:null,upload:null}),this.pingTest.closeAll()},t.prototype.error=function(t){this.errorCallback=t},t.prototype.watchLine=function(){var t=this;window.addEventListener("offline",(function(){t.errorCallback(10010)})),window.addEventListener("online",(function(){t.errorCallback()}))},t.prototype.startRecover=function(){this.pingTimeList=[],this.downloadStart=0,this.downloadEnd=0,this.uploadStart=0,this.uploadEnd=0},t}();return P}()}}]);