/* eslint-disable */ /*! * 51LA Analysis Javascript Software Development Kit * js-sdk-perf v1.7.07 * Copyright © 2016-2021 51.la All Rights Reserved */ function t(e){return t="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},t(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0&&(i=e.substring(e.indexOf("?")+1,e.length).split("&")),i.length>0)for(var a in i)r=(n=i[a].split("="))[0],o=n[1],t[r]=o}catch(e){t={}}return t},isRobot:function(){var e=["nuhk","googlebot/","googlebot-image","yammybot","openbot","slurp","msnbot","ask jeeves/teoma","ia_archiver","baiduspider","bingbot/","adsbot"];if(!navigator||"string"!=typeof navigator.userAgent)return!1;try{for(var t=navigator.userAgent.toLowerCase(),n=0;n=0)return!0}}catch(e){}return!1},getCurDomain:g,getDomainByUrl:v,checkCurDomainUrl:function(e){if(v(e)===g())return!0;var t=function(){try{var e="mh_".concat(Math.random()),t=new RegExp("(^|;)\\s*".concat(e,"=12345")),n=new Date(0),r=document.domain.split("."),o=[];for(o.unshift(r.pop());r.length;){o.unshift(r.pop());var i=o.join("."),a="".concat(e,"=",12345,";domain=.").concat(i);if(document.cookie=a,t.test(document.cookie))return document.cookie="".concat(a,";expires=").concat(n),i}}catch(e){return null}}();return!!(t&&v(e).indexOf(t)>-1)||!/http[s]{0,1}:\/\/([\w.]+\/?)\S*/.test(e)},verifyConfig:function(e){if("sample"in e){var t=e.sample,n=t;t&&/^\d+(\.\d+)?%$/.test(t)&&(n=parseInt(100/parseFloat(t))),0n&&(n=parseInt(1/n)),n>=1&&n<=100?e.sample=n:delete e.sample}return e},typeCheck:m,needReport:function(e){return Math.random()<(e||1)},filterByRule:function e(t,n){if(!t)return"";if(!n)return t;var r=m(n);return"Function"===r?function(e,t,n){if("function"!=typeof e)return n;try{return e.apply(void 0,t)}catch(e){return n}}(n,[t],t):"Array"===r?(function(e,t){var n=0,r=e.length;if(m(e,"Array"))for(;nt));n+=1);return r.removeRule(0),a},document.querySelectorAll||document.querySelector||(document.querySelectorAll=function(e){return o(e,1/0)},document.querySelector=function(e){return o(e,1)[0]||null});for(var e=document.all,t=e.length,n=0;n0?parseInt(r.substring(t+5,r.indexOf(".",t)),10):r.indexOf("Trident/")>0?(n=r.indexOf("rv:"),parseInt(r.substring(n+3,r.indexOf(".",n)),10)):(e=r.indexOf("Edge/"))>0&&parseInt(r.substring(e+5,r.indexOf(".",e)),10)},guid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})).toUpperCase()},noUint8Array:function(){return"undefined"==typeof Uint8Array||null===Uint8Array},ieVersion:function(){var e=navigator.userAgent;return!!(e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1)&&(new RegExp("MSIE (\\d+\\.\\d+);").test(e),parseFloat(RegExp.$1)<10||!("placeholder"in document.createElement("input"))||void 0)},getConnectionType:function(e){var t=e.connection||e.mozConnection||e.webkitConnection||e.oConnection;return/Android|webOS|iPhone|iPod|BlackBerry/i.test(e.userAgent)?t&&(t.effectiveType||t.type)?t.effectiveType||t.type:"wifi":t&&(t.effectiveType||t.type)?t.effectiveType||t.type:"unknown"},registerHistoryHandler:function(e){var t,n,r="";return t=window.history.pushState,n=window.history.replaceState,null!=t&&(window.history.pushState=function(){return r=window.location.toString(),t.apply(window.history,arguments),setTimeout((function(){return e()}),0)}),null!=n&&(window.history.replaceState=function(){return r=window.location.toString(),n.apply(window.history,arguments),setTimeout((function(){return e()}),0)}),null!=t&&(r=y(),"function"==typeof Object.defineProperty&&Object.defineProperty(document,"referrer",{get:function(){return r},configurable:!0}),h(window,"popstate",e)),h(window,"hashchange",e)}};function b(e,t,n,r){n=n||!1;var o,i,a=[];t=!!t&&JSON.stringify(t)||t;var c=S.detectIE()||NaN,s=[];if(S.detectIE()&&"string"==typeof t)for(var u=0;uthis.limit||this.queues.push(e)},fire:function(){this.queues&&0!==this.queues.length?(this.isStop=!1,function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(S.detectIE()||"function"!=typeof window.navigator.sendBeacon)b(e,t,n);else{window.navigator.sendBeacon("".concat(e),JSON.stringify(t))||!1||b(e,t,n)}}("//collect-v6.51.la/health/collect",this.queues),this.queues=[],this.fire()):this.isStop=!0}},R=function(){return"".concat(S.guid(),"-").concat(Math.random().toString(36).substr(-8))},x={value:R(),renew:function(){this.value=R()}},k=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function O(e){return"string"==typeof e&&k.test(e)}for(var L=[],T=0;T<256;++T)L.push((T+256).toString(16).substr(1));function A(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function U(e,t){return e<>>32-t}var C=function(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var c=0;c<16;++c)o[i+c]=a[c];return o}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(L[e[t+0]]+L[e[t+1]]+L[e[t+2]]+L[e[t+3]]+"-"+L[e[t+4]]+L[e[t+5]]+"-"+L[e[t+6]]+L[e[t+7]]+"-"+L[e[t+8]]+L[e[t+9]]+"-"+L[e[t+10]]+L[e[t+11]]+L[e[t+12]]+L[e[t+13]]+L[e[t+14]]+L[e[t+15]]).toLowerCase();if(!O(n))throw TypeError("Stringified UUID is invalid");return n}(a)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var o=0;o>>0;w=y,y=m,m=U(g,30)>>>0,g=v,v=E}n[0]=n[0]+v>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+m>>>0,n[3]=n[3]+y>>>0,n[4]=n[4]+w>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]})),I=function(e){return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[-.+*]/g,"\\$&")+"\\s*\\=s*([^;]*).*$)|^.*$"),"$1"))||null},M=function(e,t,n,r,o,i){if(!e||/^(?:expires|max-age|path|domain|secure)$/i.test(e))return!1;var a="";if(n)switch(n.constructor){case Number:a=n===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n;break;case String:a="; expires="+n;break;case Date:a="; expires="+n.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+a+(o?"; domain="+o:"")+(r?"; path="+r:"")+(i?"; secure":""),!0},j=function(e,t){var n=window.navigator,r=window.screen,o=S.now(),i=window.location.href,a=document.getElementsByTagName("title"),c=a.length?a[0].innerHTML.replace(/^\s+|\s+$/g,""):"",s=S.getRef(),u=I("__51huid__"+(t||e));return u||(u=S.ieVersion()||S.noUint8Array()?S.guid():C("\n ".concat(e,"\n ").concat(n.userAgent,"\n ").concat(o,"\n ").concat(s,"\n ").concat(r.width+"*"+r.height,"\n ").concat(S.getConnectionType(n),"\n ").concat(Math.random().toString(36).substr(-8),"\n "),S.guid())),M("__51huid__"+(t||e),u,1/0,"/"),{id:e,uid:u,tt:c,cu:i,pu:s,rt:o,bid:x.value,ct:S.getConnectionType(n)}},q=function(){function e(t){n(this,e),this.id=t.id,this.ck=t.ck,this.sample=t.sample,this.apiHelper=t.apiHelper,this.urlHelper=t.urlHelper,this.ignoreApiStatus=t.ignoreApiStatus,this.ignoreVendor=t.ignoreVendor,this.vendorList=t.vendorList,this.ignoreApiStatus=t.ignoreApiStatus}return o(e,[{key:"record",value:function(e){this.handleRecord(e),setTimeout((function(){E.isStop&&E.fire()}),200)}},{key:"handleRecord",value:function(e){try{if(!this.id&&e)return;var t=e;if(!S.needReport(this.sample)&&"perf"!==t.dt)return;if(t.cu&&this.urlHelper&&(t.cu=S.filterByRule(t.cu,this.urlHelper)),this.ignoreApiStatus.length&&"api"===t.dt){for(var n=0;n-1&&(o=!0)}if(o)return}if(t.apiUrl){for(var c=!1,s=0;s-1&&(c=!0)}if(c)return}if(t.resourceUrl){for(var f=!1,d=0;d-1&&(f=!0)}if(f)return}}E.add(S.extend(j(this.id,this.ck),t))}catch(e){}}}]),e}(),P=function(){function e(){n(this,e)}return o(e,null,[{key:"PV",get:function(){return"pv"}},{key:"JS_ERROR",get:function(){return"js"}},{key:"RESOURCE_ERROR",get:function(){return"resource"}},{key:"AJAX_ERROR",get:function(){return"api"}},{key:"PERFORMANCE",get:function(){return"perf"}},{key:"HIJACK",get:function(){return"hijack"}}]),e}(),H=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleError",value:function(){var e=arguments,t=this;window.onerror=function(n,r,o,i,a){try{return"Script error."!=n&&!r||(setTimeout((function(){var n={dt:P.JS_ERROR};if(i=i||window.event&&window.event.errorCharacter||0,n.scriptUrl=r,n.row=o,n.col=i,n.name="Unknown",a)if(a&&a.stack)n.content=a.stack.toString(),a.name&&(n.name=a.name),a.message&&(n.message=a.message);else if(e.callee){for(var c=[],s=e.callee.caller,u=3;s&&--u>0&&(c.push(s.toString()),s!==s.caller);)s=s.caller;c=c.join(","),n.content=a.stack.toString()}t.record(n)}),0),!0)}catch(a){}}}}]),r}(),N=function(e){if(window.XMLHttpRequest&&window.CustomEvent){var t=function(e){var t="function"==typeof window.CustomEvent?new CustomEvent(e,{detail:this}):function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}(e,{detail:this});window.dispatchEvent(t)},n=function(t){if(o[t]&&!0!==o[t].uploadFlag){var n=S.now(),r=o[t].event.detail.responseURL,i=o[t].event.detail.status,a=n-o[t].timeStamp;200!==i&&r&&(e({apiUrl:r,status:i,loadTime:a}),o[t].uploadFlag=!0)}},r=window.XMLHttpRequest,o=[];window.XMLHttpRequest=function(){var e=new r;return e.addEventListener("loadstart",(function(){t.call(this,"ajaxLoadStart")}),!1),e.addEventListener("loadend",(function(){t.call(this,"ajaxLoadEnd")}),!1),e},window.addEventListener("ajaxLoadStart",(function(e){var t={timeStamp:S.now(),event:e,uploadFlag:!1};o.push(t)})),window.addEventListener("ajaxLoadEnd",(function(){for(var e=0;e0&&n(e)}))}},_=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleError",value:function(){var e=this;N((function(t){var n=S.extend({dt:P.AJAX_ERROR},t);e.record(n)}))}}]),r}(),F=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleError",value:function(){var e=this;window.addEventListener("error",(function(t){try{if(!t)return;var n=t.target||t.srcElement;if(!(n instanceof HTMLScriptElement||n instanceof HTMLLinkElement||n instanceof HTMLImageElement))return;var r={};r.dt=P.RESOURCE_ERROR,r.resourceType=n.tagName.toLowerCase(),r.resourceUrl=n.src||n.href,r.resourceUrl!==window.self.location.href.replace(window.self.location.hash,"")&&e.record(r)}catch(e){}}),!0)}}]),r}(),J=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleError",value:function(){var e=this;window.addEventListener("unhandledrejection",(function(t){try{if(!t||!t.reason)return;var n={};n.dt=P.JS_ERROR,t.reason.config&&t.reason.config.url&&(n.scriptUrl=t.reason.config.url),t.reason&&t.reason.stack?(n.content=t.reason.stack.toString(),t.reason.name&&(n.name=t.reason.name),t.reason.message&&(n.message=t.reason.message)):n.content=t.reason.stack.toString(),e.record(n)}catch(e){}}),!0)}}]),r}(),D={getTiming:function(e){try{var t=window.performance||window.webkitPerformance||window.msPerformance||window.mozPerformance;if(void 0===t)return;var n=t.timing;if(n.loadEventEnd-n.navigationStart<0)return void setTimeout((function(){D.getTiming(e)}),200);var r={};for(var o in n)"Function"===S.typeCheck(n[o])||"Object"===S.typeCheck(n[o])||(r[o]=n[o]);e(n=r)}catch(e){}},getEntries:function(e){if(e=e||[],window.performance&&window.performance.getEntries){var t=[],n=window.performance.getEntries();return n&&0!=n.length?(n.forEach((function(n,r){var o={};e.indexOf(n.initiatorType)>-1&&(o.name=n.name,o.initiatorType=n.initiatorType,o.nextHopProtocol=n.nextHopProtocol,o.redirectTime=(n.redirectEnd-n.redirectStart).toFixed(2),o.dnsTime=(n.domainLookupEnd-n.domainLookupStart).toFixed(2),o.tcpTime=(n.connectEnd-n.connectStart).toFixed(2),o.ttfbTime=(n.responseStart-n.requestStart).toFixed(2),o.responseTime=(n.responseEnd-n.responseStart).toFixed(2),o.reqTotalTime=(n.responseEnd-n.requestStart).toFixed(2),t.push(o))})),t):t}}},B=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleTiming",value:function(){var e=this;D.getTiming((function(t){var n=S.extend({dt:P.PERFORMANCE},t);e.record(n)}))}},{key:"getSourceType",value:function(e){var t=[];return!1!==e.isRScript&&t.push("script"),!1!==e.isRCSS&&t.push("css"),!1!==e.isRFetch&&t.push("fetch"),!1!==e.isRXHR&&t.push("xmlhttprequest"),!1!==e.isRLink&&t.push("link"),!1!==e.isRIMG&&t.push("img"),t}}]),r}(),V=function e(t){if(t.id)return'id("'+t.id+'")';if(t===document.body)return t.tagName.toLowerCase();for(var n=0,r=t.parentNode&&t.parentNode.childNodes||[],o=0;o1&&void 0!==arguments[1]?arguments[1]:200,o=r;return function(){var r=this,i=arguments,a=+new Date;t&&a-t0&&void 0!==arguments[0]?arguments[0]:0;return e=Math.abs(e)>this.queues.length?0:e,this.queues.slice(e)},addQueues:function(e){e&&Object.keys(e).length>=1&&this.queues.push(e)},getLength:function(){return this.queues.length}},K=function(e){i(r,q);var t=u(r);function r(e){var o;return n(this,r),(o=t.call(this,e)).jankFps=e.jankFps,o.maxReport=10,o}return o(r,[{key:"handleJank",value:function(){var e=this,t=this,n=0,r=this.maxReport,o=this.jankFps||20,i=0,a=[Date.now(),Date.now()],c=a[0],s=a[1],u=[],l=[];this.sendSpaPv&&S.registerHistoryHandler((function(){u=[],l=[],r=e.maxReport}));var f=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)},d=function e(){var a=Date.now(),d=a-s,p=Math.round(1e3/d);s=a,i+=1,a>1e3+c&&((p=Math.round(1e3*i/(a-c)))&&p<=o?u.push({time:(new Date).valueOf(),fps:p}):p>o&&(u.length>=3?(r--,l=G.getQueues(-5),t.record({dt:"stuck",pageLoadTime:n,userTrack:JSON.stringify(l)}),l=[],u=[]):(u=[],l=[])),i=0,c=a),r>=1&&f(e)};D.getTiming((function(e){n=e.loadEventEnd-e.navigationStart,d()}))}},{key:"getStaticTime",value:function(){var e,t=window.performance.getEntries().filter((function(e){return"script"===e.initiatorType}));e=Math.max.apply(Math,f(t.map((function(e){return e.responseEnd}))))-Math.min.apply(Math,f(t.map((function(e){return e.startTime}))));var n=window.performance.getEntries().filter((function(e){return"css"===e.initiatorType}));return{jsTime:e,styleTime:Math.max.apply(Math,f(n.map((function(e){return e.responseEnd}))))-Math.min.apply(Math,f(n.map((function(e){return e.startTime}))))}}}]),r}(),Y=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleMonitor",value:function(){var e,t=this;(!S.detectIE()||S.detectIE()>8)&&(window.open=(e=window.open,function(n,r,o){return n&&!S.checkCurDomainUrl(n)&&t.record({dt:"outlink",outLinkUrl:n,nw:!0}),r=r||"default_window_name",e.call(window,n,r,o)})),h(document,"click",(function(e){var n=e.target||e.srcElement;if("a"===n.nodeName.toLocaleLowerCase()){var r=n.getAttribute("href"),o="_blank"===n.getAttribute("target")||!1,i=n.getAttribute("rel")&&"nofollow"===n.getAttribute("rel");r&&!S.checkCurDomainUrl(r)&&t.record({dt:"outlink",outLinkUrl:r,nw:o,nofollow:i})}}))}}]),r}(),W=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handleRouteChange",value:function(){var e=this;S.registerHistoryHandler((function(){x.renew();var t={dt:P.PV,bid:x.value};e.record(t)}))}}]),r}(),Z=function(e){i(r,q);var t=u(r);function r(e){return n(this,r),t.call(this,e)}return o(r,[{key:"handlePvReport",value:function(){var e={dt:P.PV,bid:x.value};this.record(e)}}]),r}(),ee=["cdn.bootcdn.net","lf26-cdn-tos.bytecdntp.com","lib.sinaapp.com","cdn.staticfile.org","upcdn.b0.upaiyun.com","lib.baomitu.com","ajax.aspnetcdn.com","cdn.jsdelivr.net","cdnjs.cloudflare.com","ajax.googleapis.com","g.alicdn.com",".51.la"],te=function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=[];if(n&&n.length?r?(ee.forEach((function(e){return o.push(e)})),n.forEach((function(e){o.indexOf(e)<0&&o.push(e)}))):o=n:o=ee,void 0===e||""===e)return!1;for(var i=o.length,a=0;a-1)return!0;return!1},ne=function(e){i(a,q);var r=u(a);function a(e){var t;return n(this,a),(t=r.call(this,e)).safeList=e.suspiciousSafeList.concat([/chrome-extension:\/\//]),t}return o(a,[{key:"filter",value:function(e,n){if(e===this.safeList){if(void 0===n||""===n)return!0}else if(void 0===n||""===n)return!1;for(var r=e.length,o=0;o-1)return!0}return!1}},{key:"interceptionStaticScript",value:function(){var e=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(e){var t=this,n=new e((function(e){e.forEach((function(e){for(var n=e.addedNodes,r=0;r