spy-client 2.0.7 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +119 -10
  2. package/dist/head/base.d.ts +1 -1
  3. package/dist/lib/huffman.d.ts +9 -0
  4. package/dist/lib/interface.d.ts +59 -1
  5. package/dist/lib/util.d.ts +22 -0
  6. package/dist/module/longtask.d.ts +1 -1
  7. package/dist/module/resource.d.ts +19 -9
  8. package/dist/module/tti.d.ts +1 -1
  9. package/dist/spy-client-basic.esm.js +233 -1167
  10. package/dist/spy-client-basic.iife.js +237 -1171
  11. package/dist/spy-client-basic.iife.min.js +1 -1
  12. package/dist/spy-client-basic.js +238 -1172
  13. package/dist/spy-client-basic.min.js +1 -1
  14. package/dist/spy-client-basic.mjs +82 -54
  15. package/dist/spy-client.d.ts +5 -4
  16. package/dist/spy-client.esm.js +1393 -5662
  17. package/dist/spy-client.iife.js +1401 -5670
  18. package/dist/spy-client.iife.min.js +1 -1
  19. package/dist/spy-client.js +1402 -5671
  20. package/dist/spy-client.min.js +1 -1
  21. package/dist/spy-client.mjs +704 -455
  22. package/dist/spy-head.js +330 -276
  23. package/dist/spy-head.min.js +1 -1
  24. package/dist/spy-local-cache.d.ts +18 -0
  25. package/dist/spy-local-cache.js +690 -0
  26. package/dist/spy-local-cache.min.js +1 -0
  27. package/example/index.html +8 -2
  28. package/example/local-cache.html +97 -0
  29. package/example/saveCache.js +41 -0
  30. package/karma.conf.js +111 -0
  31. package/package.json +21 -20
  32. package/src/head/error.ts +14 -15
  33. package/src/head/whitescreen.ts +8 -5
  34. package/src/lib/huffman.ts +326 -0
  35. package/src/lib/interface.ts +70 -1
  36. package/src/lib/util.ts +101 -0
  37. package/src/module/resource.ts +226 -129
  38. package/src/spy-client-basic.ts +8 -7
  39. package/src/spy-client.ts +15 -6
  40. package/src/spy-local-cache.ts +385 -0
  41. package/src/types/globals.d.ts +1 -1
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).SpyClient=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e,t){return e(t={exports:{}},t.exports),t.exports}function n(e){return e&&e.Math==Math&&e}function f(e){try{return!!e()}catch(e){return!0}}function a(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}function p(e){return c.call(e).slice(8,-1)}function h(e){if(null==e)throw TypeError("Can't call method on "+e);return e}function u(e){return w(h(e))}function v(e){return"object"==typeof e?null!==e:"function"==typeof e}function o(e,t){if(!v(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!v(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!v(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!v(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")}function k(e,t){return b.call(e,t)}function r(e){return T?L.createElement(e):{}}function S(e){if(!v(e))throw TypeError(String(e)+" is not an object");return e}function l(t,n){try{C(d,t,n)}catch(e){d[t]=n}return n}var d=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||Function("return this")(),g=!f(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,y={f:s&&!i.call({1:2},1)?function(e){var t=s(this,e);return!!t&&t.enumerable}:i},c={}.toString,m="".split,w=f(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==p(e)?m.call(e,""):Object(e)}:Object,b={}.hasOwnProperty,L=d.document,T=v(L)&&v(L.createElement),O=!g&&!f(function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}),E=Object.getOwnPropertyDescriptor,x={f:g?E:function(e,t){if(e=u(e),t=o(t,!0),O)try{return E(e,t)}catch(e){}if(k(e,t))return a(!y.f.call(e,t),e[t])}},R=Object.defineProperty,j={f:g?R:function(e,t,n){if(S(e),t=o(t,!0),S(n),O)try{return R(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},C=g?function(e,t,n){return j.f(e,t,a(1,n))}:function(e,t,n){return e[t]=n,e},I="__core-js_shared__",P=d[I]||l(I,{}),A=Function.toString;"function"!=typeof P.inspectSource&&(P.inspectSource=function(e){return A.call(e)});function B(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++H+J).toString(36)}function U(e){return V[e]||(V[e]=B(e))}var M,F,_,z=P.inspectSource,N=d.WeakMap,q="function"==typeof N&&/native code/.test(z(N)),D=t(function(e){(e.exports=function(e,t){return P[e]||(P[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.4",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})}),H=0,J=Math.random(),V=D("keys"),G={},$=d.WeakMap;if(q){var Z=new $,W=Z.get,K=Z.has,Y=Z.set;M=function(e,t){return Y.call(Z,e,t),t},F=function(e){return W.call(Z,e)||{}},_=function(e){return K.call(Z,e)}}else{var X=U("state");G[X]=!0,M=function(e,t){return C(e,X,t),t},F=function(e){return k(e,X)?e[X]:{}},_=function(e){return k(e,X)}}function Q(e){return"function"==typeof e?e:void 0}function ee(e,t){return arguments.length<2?Q(fe[e])||Q(d[e]):fe[e]&&fe[e][t]||d[e]&&d[e][t]}function te(e){return isNaN(e=+e)?0:(0<e?pe:he)(e)}function ne(e){return 0<e?ve(te(e),9007199254740991):0}function re(s){return function(e,t,n){var r,i=u(e),o=ne(i.length),a=function(e,t){var n=te(e);return n<0?de(n+t,0):ge(n,t)}(n,o);if(s&&t!=t){for(;a<o;)if((r=i[a++])!=r)return!0}else for(;a<o;a++)if((s||a in i)&&i[a]===t)return s||a||0;return!s&&-1}}function ie(e,t){var n,r=u(e),i=0,o=[];for(n in r)!k(G,n)&&k(r,n)&&o.push(n);for(;t.length>i;)k(r,n=t[i++])&&(~me(o,n)||o.push(n));return o}function oe(e,t){for(var n=Le(t),r=j.f,i=x.f,o=0;o<n.length;o++){var a=n[o];k(e,a)||r(e,a,i(t,a))}}function ae(e,t){var n=Ee[Oe(e)];return n==Re||n!=xe&&("function"==typeof t?f(t):!!t)}function se(e,t){var n,r,i,o,a,s=e.target,u=e.global,c=e.stat;if(n=u?d:c?d[s]||l(s,{}):(d[s]||{}).prototype)for(r in t){if(o=t[r],i=e.noTargetGet?(a=Ce(n,r))&&a.value:n[r],!je(u?r:s+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;oe(o,i)}(e.sham||i&&i.sham)&&C(o,"sham",!0),le(n,r,o,e)}}function ue(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}var ce={set:M,get:F,has:_,enforce:function(e){return _(e)?F(e):M(e,{})},getterFor:function(n){return function(e){var t;if(!v(e)||(t=F(e)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return t}}},le=t(function(e){var t=ce.get,s=ce.enforce,u=String(String).split("String");(e.exports=function(e,t,n,r){var i=!!r&&!!r.unsafe,o=!!r&&!!r.enumerable,a=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||k(n,"name")||C(n,"name",t),s(n).source=u.join("string"==typeof t?t:"")),e!==d?(i?!a&&e[t]&&(o=!0):delete e[t],o?e[t]=n:C(e,t,n)):o?e[t]=n:l(t,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&t(this).source||z(this)})}),fe=d,he=Math.ceil,pe=Math.floor,ve=Math.min,de=Math.max,ge=Math.min,ye={includes:re(!0),indexOf:re(!1)},me=ye.indexOf,be=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ke=be.concat("length","prototype"),Se={f:Object.getOwnPropertyNames||function(e){return ie(e,ke)}},we={f:Object.getOwnPropertySymbols},Le=ee("Reflect","ownKeys")||function(e){var t=Se.f(S(e)),n=we.f;return n?t.concat(n(e)):t},Te=/#|\.prototype\./,Oe=ae.normalize=function(e){return String(e).replace(Te,".").toLowerCase()},Ee=ae.data={},xe=ae.NATIVE="N",Re=ae.POLYFILL="P",je=ae,Ce=x.f,Ie=[].slice,Pe={},Ae=Function.bind||function(t){var n=ue(this),r=Ie.call(arguments,1),i=function(){var e=r.concat(Ie.call(arguments));return this instanceof i?function(e,t,n){if(!(t in Pe)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";Pe[t]=Function("C,a","return new C("+r.join(",")+")")}return Pe[t](e,n)}(n,e.length,e):n.apply(t,e)};return v(n.prototype)&&(i.prototype=n.prototype),i};function Be(e){return(Be="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})(e)}function Ue(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Me(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Fe(e,t,n){return t&&Me(e.prototype,t),n&&Me(e,n),e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ze(e,t){return(ze=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}se({target:"Function",proto:!0},{bind:Ae});function qe(e){return Object(h(e))}function De(e,t,n){var r=o(t);r in e?j.f(e,r,a(0,n)):e[r]=n}function He(e){return k(Ke,e)||(Ze&&k(Ye,e)?Ke[e]=Ye[e]:Ke[e]=Xe("Symbol."+e)),Ke[e]}function Je(e,t){var n;return $e(e)&&("function"!=typeof(n=e.constructor)||n!==Array&&!$e(n.prototype)?v(n)&&null===(n=n[Qe])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===t?0:t)}var Ve,Ge,$e=Array.isArray||function(e){return"Array"==p(e)},Ze=!!Object.getOwnPropertySymbols&&!f(function(){return!String(Symbol())}),We=Ze&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ke=D("wks"),Ye=d.Symbol,Xe=We?Ye:Ye&&Ye.withoutSetter||B,Qe=He("species"),et=ee("navigator","userAgent")||"",tt=d.process,nt=tt&&tt.versions,rt=nt&&nt.v8;rt?Ge=(Ve=rt.split("."))[0]+Ve[1]:et&&(!(Ve=et.match(/Edge\/(\d+)/))||74<=Ve[1])&&(Ve=et.match(/Chrome\/(\d+)/))&&(Ge=Ve[1]);function it(t){return 51<=at||!f(function(){var e=[];return(e.constructor={})[st]=function(){return{foo:1}},1!==e[t](Boolean).foo})}function ot(e){if(!v(e))return!1;var t=e[ut];return void 0!==t?!!t:$e(e)}var at=Ge&&+Ge,st=He("species"),ut=He("isConcatSpreadable"),ct=9007199254740991,lt="Maximum allowed index exceeded",ft=51<=at||!f(function(){var e=[];return e[ut]=!1,e.concat()[0]!==e}),ht=it("concat");se({target:"Array",proto:!0,forced:!ft||!ht},{concat:function(e){var t,n,r,i,o,a=qe(this),s=Je(a,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(ot(o=-1===t?a:arguments[t])){if(i=ne(o.length),ct<u+i)throw TypeError(lt);for(n=0;n<i;n++,u++)n in o&&De(s,u,o[n])}else{if(ct<=u)throw TypeError(lt);De(s,u++,o)}return s.length=u,s}});function pt(e,t){var n=[][e];return!!n&&f(function(){n.call(null,t||function(){throw 1},1)})}function vt(e){throw e}function dt(e,t){if(k(yt,e))return yt[e];var n=[][e],r=!!k(t=t||{},"ACCESSORS")&&t.ACCESSORS,i=k(t,0)?t[0]:vt,o=k(t,1)?t[1]:void 0;return yt[e]=!!n&&!f(function(){if(r&&!g)return!0;var e={length:-1};r?gt(e,1,{enumerable:!0,get:vt}):e[1]=1,n.call(e,i,o)})}var gt=Object.defineProperty,yt={},mt=ye.indexOf,bt=[].indexOf,kt=!!bt&&1/[1].indexOf(1,-0)<0,St=pt("indexOf"),wt=dt("indexOf",{ACCESSORS:!0,1:0});se({target:"Array",proto:!0,forced:kt||!St||!wt},{indexOf:function(e,t){return kt?bt.apply(this,arguments)||0:mt(this,e,1<arguments.length?t:void 0)}});var Lt=[].join,Tt=w!=Object,Ot=pt("join",",");se({target:"Array",proto:!0,forced:Tt||!Ot},{join:function(e){return Lt.call(u(this),void 0===e?",":e)}});function Et(r,i,e){if(ue(r),void 0===i)return r;switch(e){case 0:return function(){return r.call(i)};case 1:return function(e){return r.call(i,e)};case 2:return function(e,t){return r.call(i,e,t)};case 3:return function(e,t,n){return r.call(i,e,t,n)}}return function(){return r.apply(i,arguments)}}function xt(p){var v=1==p,d=2==p,g=3==p,y=4==p,m=6==p,b=5==p||m;return function(e,t,n,r){for(var i,o,a=qe(e),s=w(a),u=Et(t,n,3),c=ne(s.length),l=0,f=r||Je,h=v?f(e,c):d?f(e,0):void 0;l<c;l++)if((b||l in s)&&(o=u(i=s[l],l,a),p))if(v)h[l]=o;else if(o)switch(p){case 3:return!0;case 5:return i;case 6:return l;case 2:Rt.call(h,i)}else if(y)return!1;return m?-1:g||y?y:h}}var Rt=[].push,jt={forEach:xt(0),map:xt(1),filter:xt(2),some:xt(3),every:xt(4),find:xt(5),findIndex:xt(6)},Ct=jt.map,It=it("map"),Pt=dt("map");se({target:"Array",proto:!0,forced:!It||!Pt},{map:function(e,t){return Ct(this,e,1<arguments.length?t:void 0)}}),se({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});var At=Date.prototype,Bt="Invalid Date",Ut="toString",Mt=At[Ut],Ft=At.getTime;new Date(NaN)+""!=Bt&&le(At,Ut,function(){var e=Ft.call(this);return e==e?Mt.call(this):Bt});var _t=Object.keys||function(e){return ie(e,be)},zt=Object.assign,Nt=Object.defineProperty,qt=!zt||f(function(){if(g&&1!==zt({b:1},zt(Nt({},"a",{enumerable:!0,get:function(){Nt(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=zt({},e)[n]||_t(zt({},t)).join("")!=r})?function(e,t){for(var n=qe(e),r=arguments.length,i=1,o=we.f,a=y.f;i<r;)for(var s,u=w(arguments[i++]),c=o?_t(u).concat(o(u)):_t(u),l=c.length,f=0;f<l;)s=c[f++],g&&!a.call(u,s)||(n[s]=u[s]);return n}:zt;se({target:"Object",stat:!0,forced:Object.assign!==qt},{assign:qt});var Dt=f(function(){_t(1)});se({target:"Object",stat:!0,forced:Dt},{keys:function(e){return _t(qe(e))}});var Ht=/(iPhone|iPod|iPad)/.test(navigator.userAgent);function Jt(e){console.error("[SpyClient_log]".concat(e))}var Vt=(Fe(Gt,[{key:"send",value:function(e){if(this.check(e)){if("number"==typeof e.sample){if(Math.random()>e.sample)return}else if("number"==typeof this.option.sample&&Math.random()>this.option.sample)return;delete(e=Object.assign({pid:this.option.pid,lid:this.option.lid,ts:Date.now(),group:"common"},e)).sample;var t=this.option.logServer+function(n){return Object.keys(n).map(function(e){var t=n[e];return void 0===t?t="":"string"!=typeof t&&(t=JSON.stringify(t)),encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&")}(e);!Ht&&navigator.sendBeacon&&navigator.sendBeacon(t)||((new Image).src=t)}}},{key:"check",value:function(e){if(!this.option.check)return!0;var t=["perf","except","dist","count"];if(-1===t.indexOf(e.type))return Jt("type only is one of "+t.join(", ")),!1;if(e.group&&30<e.group.length)return Jt("group length execeeds 30"),!1;var n=/^[a-zA-Z0-9-_]{0,30}$/;if("except"===e.type){if("string"!=typeof e.info.msg||!e.info.msg.length)return Jt("info.msg field must be not empty and is String"),!1}else for(var r=0,i=Object.keys(e.info);r<i.length;r++){var o=i[r];if(!n.test(o))return Jt("info.".concat(o," is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var a=e.info[o];if("dist"===e.type){if(30<a.length)return Jt("info.".concat(o," value length execeeds 30 when type == 'dist'")),!1}else if("number"!=typeof a)return Jt("info.".concat(o," value must be number")),!1}if(e.dim)for(var s=0,u=Object.keys(e.dim);s<u.length;s++){var c=u[s];if(!n.test(c))return Jt("dim key [".concat(c,"] is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var l=e.dim[c];if(!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(l))return Jt("dim.".concat(c," value [").concat(l,"] is unexpected. ")+"Length must be not more than 30. Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese"),!1}return!0}},{key:"sendPerf",value:function(e){this.send(Object.assign({type:"perf"},e))}},{key:"sendExcept",value:function(e){this.send(Object.assign({type:"except"},e))}},{key:"sendDist",value:function(e){this.send(Object.assign({type:"dist"},e))}},{key:"sendCount",value:function(e){this.send(Object.assign({type:"count"},e))}},{key:"sendExceptForError",value:function(e,t){var n=Object.assign({},t);n.info=Object.assign({},t.info||{},{msg:e.message,stack:e.stack}),this.sendExcept(n)}},{key:"startMark",value:function(e){this.markCache[e]={start:Date.now()}}},{key:"endMark",value:function(e){return this.markCache[e]?(this.markCache[e].total=Date.now()-this.markCache[e].start,this.markCache[e].total):0}},{key:"clearMark",value:function(e){this.markCache[e]&&delete this.markCache[e]}},{key:"getAllMark",value:function(){for(var e={},t=0,n=Object.keys(this.markCache);t<n.length;t++){var r=n[t];e[r]=this.markCache[r].total}return e}},{key:"clearAllMark",value:function(){this.markCache={}}}]),Gt);function Gt(e){if(Ue(this,Gt),this.sample={},this.markCache={},!e.pid)throw new Error("pid is required");this.option={pid:e.pid,lid:e.lid,check:!1!==e.check,sample:e.sample,logServer:e.logServer||"https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?"}}var $t=window.__spyHead,Zt="first-input",Wt=(Fe(Kt,[{key:"listenFID",value:function(e){this.cb=e,this.callCB()}},{key:"callCB",value:function(){void 0!==this.finalValue&&this.cb&&this.cb({fid:this.finalValue})}},{key:"destroy",value:function(){this.observer&&this.observer.disconnect(),this.observer=null}},{key:"handle",value:function(e){var t=e.pop();t&&(this.finalValue=t.duration,this.callCB(),this.destroy())}}]),Kt);function Kt(){var t=this;if(Ue(this,Kt),this.observer=null,window.PerformanceObserver){$t&&$t.entryMap&&$t.entryMap[Zt]&&this.handle($t.entryMap[Zt]);try{this.observer=new PerformanceObserver(function(e){t.handle(e.getEntries())}),this.observer.observe({entryTypes:[Zt]})}catch(e){}}}var Yt=window.__spyHead,Xt="layout-shift",Qt=(Fe(en,[{key:"listenLayoutShift",value:function(e){this.cb=e}},{key:"leave",value:function(){this.onceLeave||(this.onceLeave=!0,this.observer&&this.observer.takeRecords&&this.observer.takeRecords(),this.finalValue=this.value,this.callCB(),this.destroy())}},{key:"callCB",value:function(){void 0!==this.finalValue&&this.cb&&this.cb({layoutShift:this.finalValue})}},{key:"destroy",value:function(){this.observer&&this.observer.disconnect(),this.observer=null}},{key:"handle",value:function(e){var t=this;e.map(function(e){e.hadRecentInput||(t.value=(t.value||0)+(e.value||0))})}}]),en);function en(){var t=this;if(Ue(this,en),this.observer=null,this.onceLeave=!1,window.PerformanceObserver){Yt&&Yt.entryMap&&Yt.entryMap[Xt]&&this.handle(Yt.entryMap[Xt]);try{this.observer=new PerformanceObserver(function(e){t.handle(e.getEntries())}),this.observer.observe({entryTypes:[Xt]})}catch(e){}}}var tn={};function nn(e){return tn[e]}var rn=window.__spyHead,on="largest-contentful-paint",an=(Fe(sn,[{key:"listenLCP",value:function(e){this.cb=e,this.callCB()}},{key:"callCB",value:function(){this.finalValue&&this.cb&&this.cb({lcp:this.finalValue})}},{key:"load",value:function(){this.observer&&this.observer.takeRecords&&this.observer.takeRecords(),this.finalValue=this.value,function(e,t){tn[e]=t}("lcp",this.value),this.callCB(),this.destroy()}},{key:"destroy",value:function(){this.observer&&this.observer.disconnect(),this.observer=null}},{key:"handle",value:function(e){var t=this;e.map(function(e){t.value=e.renderTime||e.loadTime})}}]),sn);function sn(){var t=this;if(Ue(this,sn),this.observer=null,window.PerformanceObserver){rn&&rn.entryMap&&rn.entryMap[on]&&this.handle(rn.entryMap[on]);try{this.observer=new PerformanceObserver(function(e){t.handle(e.getEntries())}),this.observer.observe({entryTypes:[on]})}catch(e){}}}function un(){}function cn(e){return"<script>"+e+"</"+vn+">"}var ln,fn=g?Object.defineProperties:function(e,t){S(e);for(var n,r=_t(t),i=r.length,o=0;o<i;)j.f(e,n=r[o++],t[n]);return e},hn=ee("document","documentElement"),pn="prototype",vn="script",dn=U("IE_PROTO"),gn=function(){try{ln=document.domain&&new ActiveXObject("htmlfile")}catch(e){}gn=ln?function(e){e.write(cn("")),e.close();var t=e.parentWindow.Object;return e=null,t}(ln):function(){var e,t=r("iframe");return t.style.display="none",hn.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(cn("document.F=Object")),e.close(),e.F}();for(var e=be.length;e--;)delete gn[pn][be[e]];return gn()};G[dn]=!0;function yn(e){var t=fe.Symbol||(fe.Symbol={});k(t,e)||jn(t,e,{value:Rn.f(e)})}function mn(e,t,n){e&&!k(e=n?e:e.prototype,In)&&Cn(e,In,{configurable:!0,value:t})}function bn(e,t){var n=Gn[e]=Ln(Nn[Un]);return Fn(n,{type:Bn,tag:e,description:t}),g||(n.description=t),n}function kn(t,e){S(t);var n=u(e),r=_t(n).concat(rr(n));return Pn(r,function(e){g&&!nr.call(n,e)||tr(t,e,n[e])}),t}function Sn(e,t){var n=u(e),r=o(t,!0);if(n!==zn||!k(Gn,r)||k($n,r)){var i=Dn(n,r);return!i||!k(Gn,r)||k(n,An)&&n[An][r]||(i.enumerable=!0),i}}function wn(e){var t=Jn(u(e)),n=[];return Pn(t,function(e){k(Gn,e)||k(G,e)||n.push(e)}),n}var Ln=Object.create||function(e,t){var n;return null!==e?(un[pn]=S(e),n=new un,un[pn]=null,n[dn]=e):n=gn(),void 0===t?n:fn(n,t)},Tn=Se.f,On={}.toString,En="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],xn={f:function(e){return En&&"[object Window]"==On.call(e)?function(e){try{return Tn(e)}catch(e){return En.slice()}}(e):Tn(u(e))}},Rn={f:He},jn=j.f,Cn=j.f,In=He("toStringTag"),Pn=jt.forEach,An=U("hidden"),Bn="Symbol",Un="prototype",Mn=He("toPrimitive"),Fn=ce.set,_n=ce.getterFor(Bn),zn=Object[Un],Nn=d.Symbol,qn=ee("JSON","stringify"),Dn=x.f,Hn=j.f,Jn=xn.f,Vn=y.f,Gn=D("symbols"),$n=D("op-symbols"),Zn=D("string-to-symbol-registry"),Wn=D("symbol-to-string-registry"),Kn=D("wks"),Yn=d.QObject,Xn=!Yn||!Yn[Un]||!Yn[Un].findChild,Qn=g&&f(function(){return 7!=Ln(Hn({},"a",{get:function(){return Hn(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=Dn(zn,t);r&&delete zn[t],Hn(e,t,n),r&&e!==zn&&Hn(zn,t,r)}:Hn,er=We?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof Nn},tr=function(e,t,n){e===zn&&tr($n,t,n),S(e);var r=o(t,!0);return S(n),k(Gn,r)?(n.enumerable?(k(e,An)&&e[An][r]&&(e[An][r]=!1),n=Ln(n,{enumerable:a(0,!1)})):(k(e,An)||Hn(e,An,a(1,{})),e[An][r]=!0),Qn(e,r,n)):Hn(e,r,n)},nr=function(e){var t=o(e,!0),n=Vn.call(this,t);return!(this===zn&&k(Gn,t)&&!k($n,t))&&(!(n||!k(this,t)||!k(Gn,t)||k(this,An)&&this[An][t])||n)},rr=function(e){var t=e===zn,n=Jn(t?$n:u(e)),r=[];return Pn(n,function(e){!k(Gn,e)||t&&!k(zn,e)||r.push(Gn[e])}),r};if(Ze||(le((Nn=function(e){if(this instanceof Nn)throw TypeError("Symbol is not a constructor");var t=arguments.length&&void 0!==e?String(e):void 0,n=B(t),r=function(e){this===zn&&r.call($n,e),k(this,An)&&k(this[An],n)&&(this[An][n]=!1),Qn(this,n,a(1,e))};return g&&Xn&&Qn(zn,n,{configurable:!0,set:r}),bn(n,t)})[Un],"toString",function(){return _n(this).tag}),le(Nn,"withoutSetter",function(e){return bn(B(e),e)}),y.f=nr,j.f=tr,x.f=Sn,Se.f=xn.f=wn,we.f=rr,Rn.f=function(e){return bn(He(e),e)},g&&(Hn(Nn[Un],"description",{configurable:!0,get:function(){return _n(this).description}}),le(zn,"propertyIsEnumerable",nr,{unsafe:!0}))),se({global:!0,wrap:!0,forced:!Ze,sham:!Ze},{Symbol:Nn}),Pn(_t(Kn),function(e){yn(e)}),se({target:Bn,stat:!0,forced:!Ze},{for:function(e){var t=String(e);if(k(Zn,t))return Zn[t];var n=Nn(t);return Zn[t]=n,Wn[n]=t,n},keyFor:function(e){if(!er(e))throw TypeError(e+" is not a symbol");if(k(Wn,e))return Wn[e]},useSetter:function(){Xn=!0},useSimple:function(){Xn=!1}}),se({target:"Object",stat:!0,forced:!Ze,sham:!g},{create:function(e,t){return void 0===t?Ln(e):kn(Ln(e),t)},defineProperty:tr,defineProperties:kn,getOwnPropertyDescriptor:Sn}),se({target:"Object",stat:!0,forced:!Ze},{getOwnPropertyNames:wn,getOwnPropertySymbols:rr}),se({target:"Object",stat:!0,forced:f(function(){we.f(1)})},{getOwnPropertySymbols:function(e){return we.f(qe(e))}}),qn){var ir=!Ze||f(function(){var e=Nn();return"[null]"!=qn([e])||"{}"!=qn({a:e})||"{}"!=qn(Object(e))});se({target:"JSON",stat:!0,forced:ir},{stringify:function(e,t,n){for(var r,i=[e],o=1;o<arguments.length;)i.push(arguments[o++]);if((v(r=t)||void 0!==e)&&!er(e))return $e(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!er(t))return t}),i[1]=t,qn.apply(null,i)}})}Nn[Un][Mn]||C(Nn[Un],Mn,Nn[Un].valueOf),mn(Nn,Bn),G[An]=!0;var or=j.f,ar=d.Symbol;if(!(!g||"function"!=typeof ar||"description"in ar.prototype&&void 0===ar().description)){var sr={},ur=function(e){var t=arguments.length<1||void 0===e?void 0:String(e),n=this instanceof ur?new ar(t):void 0===t?ar():ar(t);return""===t&&(sr[n]=!0),n};oe(ur,ar);var cr=ur.prototype=ar.prototype;cr.constructor=ur;var lr=cr.toString,fr="Symbol(test)"==String(ar("test")),hr=/^Symbol\((.*)\)[^)]+$/;or(cr,"description",{configurable:!0,get:function(){var e=v(this)?this.valueOf():this,t=lr.call(e);if(k(sr,e))return"";var n=fr?t.slice(7,-1):t.replace(hr,"$1");return""===n?void 0:n}}),se({global:!0,forced:!0},{Symbol:ur})}yn("iterator");var pr=jt.filter,vr=it("filter"),dr=dt("filter");se({target:"Array",proto:!0,forced:!vr||!dr},{filter:function(e,t){return pr(this,e,1<arguments.length?t:void 0)}});var gr=He("unscopables"),yr=Array.prototype;null==yr[gr]&&j.f(yr,gr,{configurable:!0,value:Ln(null)});function mr(e){yr[gr][e]=!0}var br,kr,Sr,wr={},Lr=!f(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Tr=U("IE_PROTO"),Or=Object.prototype,Er=Lr?Object.getPrototypeOf:function(e){return e=qe(e),k(e,Tr)?e[Tr]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?Or:null},xr=He("iterator"),Rr=!1;[].keys&&("next"in(Sr=[].keys())?(kr=Er(Er(Sr)))!==Object.prototype&&(br=kr):Rr=!0),null==br&&(br={}),k(br,xr)||C(br,xr,function(){return this});function jr(){return this}function Cr(e,t,n){var r=t+" Iterator";return e.prototype=Ln(Br,{next:a(1,n)}),mn(e,r,!1),wr[r]=jr,e}function Ir(){return this}function Pr(e,t,n,r,i,o,a){function s(e){if(e===i&&d)return d;if(!Fr&&e in p)return p[e];switch(e){case"keys":case zr:case Nr:return function(){return new n(this,e)}}return function(){return new n(this)}}Cr(n,t,r);var u,c,l,f=t+" Iterator",h=!1,p=e.prototype,v=p[_r]||p["@@iterator"]||i&&p[i],d=!Fr&&v||s(i),g="Array"==t&&p.entries||v;if(g&&(u=Er(g.call(new e)),Mr!==Object.prototype&&u.next&&(Er(u)!==Mr&&(Ur?Ur(u,Mr):"function"!=typeof u[_r]&&C(u,_r,Ir)),mn(u,f,!0))),i==zr&&v&&v.name!==zr&&(h=!0,d=function(){return v.call(this)}),p[_r]!==d&&C(p,_r,d),wr[t]=d,i)if(c={values:s(zr),keys:o?d:s("keys"),entries:s(Nr)},a)for(l in c)!Fr&&!h&&l in p||le(p,l,c[l]);else se({target:t,proto:!0,forced:Fr||h},c);return c}var Ar={IteratorPrototype:br,BUGGY_SAFARI_ITERATORS:Rr},Br=Ar.IteratorPrototype,Ur=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,e={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(e,[]),r=e instanceof Array}catch(e){}return function(e,t){return S(e),function(e){if(!v(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(t),r?n.call(e,t):e.__proto__=t,e}}():void 0),Mr=Ar.IteratorPrototype,Fr=Ar.BUGGY_SAFARI_ITERATORS,_r=He("iterator"),zr="values",Nr="entries",qr="Array Iterator",Dr=ce.set,Hr=ce.getterFor(qr),Jr=Pr(Array,"Array",function(e,t){Dr(this,{type:qr,target:u(e),index:0,kind:t})},function(){var e=Hr(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?{value:e.target=void 0,done:!0}:"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}},"values");wr.Arguments=wr.Array,mr("keys"),mr("values"),mr("entries");var Vr=j.f,Gr=Function.prototype,$r=Gr.toString,Zr=/^\s*function ([^ (]*)/;!g||"name"in Gr||Vr(Gr,"name",{configurable:!0,get:function(){try{return $r.call(this).match(Zr)[1]}catch(e){return""}}});var Wr={};Wr[He("toStringTag")]="z";var Kr="[object z]"===String(Wr),Yr=He("toStringTag"),Xr="Arguments"==p(function(){return arguments}()),Qr=Kr?p:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Yr))?n:Xr?p(t):"Object"==(r=p(t))&&"function"==typeof t.callee?"Arguments":r},ei=Kr?{}.toString:function(){return"[object "+Qr(this)+"]"};Kr||le(Object.prototype,"toString",ei,{unsafe:!0});function ti(s){return function(e,t){var n,r,i=String(h(e)),o=te(t),a=i.length;return o<0||a<=o?s?"":void 0:(n=i.charCodeAt(o))<55296||56319<n||o+1===a||(r=i.charCodeAt(o+1))<56320||57343<r?s?i.charAt(o):n:s?i.slice(o,o+2):r-56320+(n-55296<<10)+65536}}var ni={codeAt:ti(!1),charAt:ti(!0)},ri=ni.charAt,ii="String Iterator",oi=ce.set,ai=ce.getterFor(ii);Pr(String,"String",function(e){oi(this,{type:ii,string:String(e),index:0})},function(){var e,t=ai(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=ri(n,r),t.index+=e.length,{value:e,done:!1})});var si={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},ui=He("iterator"),ci=He("toStringTag"),li=Jr.values;for(var fi in si){var hi=d[fi],pi=hi&&hi.prototype;if(pi){if(pi[ui]!==li)try{C(pi,ui,li)}catch(e){pi[ui]=li}if(pi[ci]||C(pi,ci,fi),si[fi])for(var vi in Jr)if(pi[vi]!==Jr[vi])try{C(pi,vi,Jr[vi])}catch(e){pi[vi]=Jr[vi]}}}function di(i){return function(e,t){var n=2<arguments.length,r=n?gi.call(arguments,2):void 0;return i(n?function(){("function"==typeof e?e:Function(e)).apply(this,r)}:e,t)}}var gi=[].slice,yi=/MSIE .\./.test(et);function mi(e){return e.name.indexOf(".gif?")<0}se({global:!0,bind:!0,forced:yi},{setTimeout:di(d.setTimeout),setInterval:di(d.setInterval)});var bi=(Fe(ki,[{key:"check",value:function(){return window.PerformanceObserver&&performance&&performance.timing&&performance.timing.navigationStart}},{key:"listenTTI",value:function(e,t){this.check()&&(this.observeLongtask(2e4),this.cb=e,(t=t||{}).interval&&(this.interval=t.interval),t.filterRequest&&(this.filterRequest=t.filterRequest))}},{key:"load",value:function(){this.check()&&(this.ttiTimer=setInterval(this.ttiCheck,this.interval))}},{key:"ttiCheck",value:function(){if(this.cb){var e=performance.now();if(!(e-this.lastLongTask<this.interval)){var t=this.getNetworkSilenceAt();if(!1!==t&&!(e-t<this.interval)){clearTimeout(this.ttiTimer);var n=this.lastLongTask;n=n||performance.timing.domContentLoadedEventEnd-performance.timing.navigationStart,this.stopObserveLongTask(),this.cb({tti:n})}}}}},{key:"observerCallback",value:function(e){var t=e.getEntries(),n=t[t.length-1];this.lastLongTask=n.startTime+n.duration}},{key:"stopObserveLongTask",value:function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.stopLongTaskTimeoutId&&clearTimeout(this.stopLongTaskTimeoutId)}},{key:"getNetworkSilenceAt",value:function(){var e=performance.getEntriesByType("resource").filter(this.filterRequest),t=0,n=!0,r=!1,i=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done);n=!0){var s=o.value;if(!s.responseEnd)return!1;s.responseEnd>t&&(t=s.responseEnd)}}catch(e){r=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw i}}return t}},{key:"observeLongtask",value:function(e){this.stopObserveLongTask();try{this.observer=new PerformanceObserver(this.observerCallback),this.observer.observe({entryTypes:["longtask"]}),this.stopLongTaskTimeoutId=setTimeout(this.stopObserveLongTask,e)}catch(e){}}}]),ki);function ki(){Ue(this,ki),this.lastLongTask=0,this.observer=null,this.interval=5e3,this.filterRequest=mi,this.observerCallback=this.observerCallback.bind(this),this.ttiCheck=this.ttiCheck.bind(this)}var Si=jt.forEach,wi=pt("forEach"),Li=dt("forEach"),Ti=wi&&Li?[].forEach:function(e,t){return Si(this,e,1<arguments.length?t:void 0)};for(var Oi in se({target:"Array",proto:!0,forced:[].forEach!=Ti},{forEach:Ti}),si){var Ei=d[Oi],xi=Ei&&Ei.prototype;if(xi&&xi.forEach!==Ti)try{C(xi,"forEach",Ti)}catch(e){xi.forEach=Ti}}var Ri=(Fe(ji,[{key:"listenTiming",value:function(e){window.performance&&window.performance.timing&&(this.cb=e)}},{key:"load",value:function(){var e=this;setTimeout(function(){e.cb&&e.cb(e.getMetric())},500)}},{key:"getMetric",value:function(){var o={},e=window.performance.timing,t=e.navigationStart;if(o.dns=e.domainLookupEnd-e.domainLookupStart,o.tcp=e.connectEnd-e.connectStart,o.request=e.responseStart-e.requestStart,o.response=e.responseEnd-e.responseStart,o.parseHtml=e.domInteractive-e.domLoading,o.domReady=e.domContentLoadedEventEnd-t,o.loadEventHandle=e.loadEventEnd-e.loadEventStart,o.load=e.loadEventEnd-t,performance.getEntriesByType){var n=performance.getEntriesByType("paint");n&&n.length&&n.forEach(function(e){var t=e.name,n=e.duration,r=e.startTime,i=Math.ceil(n+r);"first-paint"===t&&(o.fp=i),"first-contentful-paint"===t&&(o.fcp=i)})}return e.domFirstPaint&&(o.t7FirstPaint=e.domFirstPaint-t),e.domFirstScreenPaint&&(o.t7FirstScreen=e.domFirstScreenPaint-t),o}}]),ji);function ji(){Ue(this,ji)}var Ci="".repeat||function(e){var t=String(h(this)),n="",r=te(e);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;0<r;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},Ii=1..toFixed,Pi=Math.floor,Ai=function(e,t,n){return 0===t?n:t%2==1?Ai(e,t-1,n*e):Ai(e*e,t/2,n)},Bi=Ii&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!f(function(){Ii.call({})});se({target:"Number",proto:!0,forced:Bi},{toFixed:function(e){function t(e,t){for(var n=-1,r=t;++n<6;)r+=e*l[n],l[n]=r%1e7,r=Pi(r/1e7)}function n(e){for(var t=6,n=0;0<=--t;)n+=l[t],l[t]=Pi(n/e),n=n%e*1e7}function r(){for(var e=6,t="";0<=--e;)if(""!==t||0===e||0!==l[e]){var n=String(l[e]);t=""===t?n:t+Ci.call("0",7-n.length)+n}return t}var i,o,a,s,u=function(e){if("number"!=typeof e&&"Number"!=p(e))throw TypeError("Incorrect invocation");return+e}(this),c=te(e),l=[0,0,0,0,0,0],f="",h="0";if(c<0||20<c)throw RangeError("Incorrect fraction digits");if(u!=u)return"NaN";if(u<=-1e21||1e21<=u)return String(u);if(u<0&&(f="-",u=-u),1e-21<u)if(o=(i=function(e){for(var t=0,n=e;4096<=n;)t+=12,n/=4096;for(;2<=n;)t+=1,n/=2;return t}(u*Ai(2,69,1))-69)<0?u*Ai(2,-i,1):u/Ai(2,i,1),o*=4503599627370496,0<(i=52-i)){for(t(0,o),a=c;7<=a;)t(1e7,0),a-=7;for(t(Ai(10,a,1),0),a=i-1;23<=a;)n(1<<23),a-=23;n(1<<a),t(1,1),n(2),h=r()}else t(0,o),t(1<<-i,0),h=r()+Ci.call("0",c);return h=0<c?f+((s=h.length)<=c?"0."+Ci.call("0",c-s)+h:h.slice(0,s-c)+"."+h.slice(s-c)):f+h}});function Ui(e,t){return RegExp(e,t)}var Mi,Fi,_i={UNSUPPORTED_Y:f(function(){var e=Ui("a","y");return e.lastIndex=2,null!=e.exec("abcd")}),BROKEN_CARET:f(function(){var e=Ui("^r","gy");return e.lastIndex=2,null!=e.exec("str")})},zi=RegExp.prototype.exec,Ni=String.prototype.replace,qi=zi,Di=(Mi=/a/,Fi=/b*/g,zi.call(Mi,"a"),zi.call(Fi,"a"),0!==Mi.lastIndex||0!==Fi.lastIndex),Hi=_i.UNSUPPORTED_Y||_i.BROKEN_CARET,Ji=void 0!==/()??/.exec("")[1];(Di||Ji||Hi)&&(qi=function(e){var t,n,r,i,o=this,a=Hi&&o.sticky,s=function(){var e=S(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t}.call(o),u=o.source,c=0,l=e;return a&&(-1===(s=s.replace("y","")).indexOf("g")&&(s+="g"),l=String(e).slice(o.lastIndex),0<o.lastIndex&&(!o.multiline||o.multiline&&"\n"!==e[o.lastIndex-1])&&(u="(?: "+u+")",l=" "+l,c++),n=new RegExp("^(?:"+u+")",s)),Ji&&(n=new RegExp("^"+u+"$(?!\\s)",s)),Di&&(t=o.lastIndex),r=zi.call(a?n:o,l),a?r?(r.input=r.input.slice(c),r[0]=r[0].slice(c),r.index=o.lastIndex,o.lastIndex+=r[0].length):o.lastIndex=0:Di&&r&&(o.lastIndex=o.global?r.index+r[0].length:t),Ji&&r&&1<r.length&&Ni.call(r[0],n,function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(r[i]=void 0)}),r});var Vi=qi;se({target:"RegExp",proto:!0,forced:/./.exec!==Vi},{exec:Vi});function Gi(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==p(e))throw TypeError("RegExp#exec called on incompatible receiver");return Vi.call(e,t)}var $i=He("species"),Zi=!f(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}),Wi="$0"==="a".replace(/./,"$0"),Ki=He("replace"),Yi=!!/./[Ki]&&""===/./[Ki]("a","$0"),Xi=!f(function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}),Qi=He("match"),eo=He("species"),to=ni.charAt,no=[].push,ro=Math.min,io=4294967295,oo=!f(function(){return!RegExp(io,"y")});!function(n,e,t,r){var i=He(n),o=!f(function(){var e={};return e[i]=function(){return 7},7!=""[n](e)}),a=o&&!f(function(){var e=!1,t=/a/;return"split"===n&&((t={constructor:{}}).constructor[$i]=function(){return t},t.flags="",t[i]=/./[i]),t.exec=function(){return e=!0,null},t[i](""),!e});if(!o||!a||"replace"===n&&(!Zi||!Wi||Yi)||"split"===n&&!Xi){var s=/./[i],u=t(i,""[n],function(e,t,n,r,i){return t.exec===Vi?o&&!i?{done:!0,value:s.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}},{REPLACE_KEEPS_$0:Wi,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Yi}),c=u[0],l=u[1];le(String.prototype,n,c),le(RegExp.prototype,i,2==e?function(e,t){return l.call(e,this,t)}:function(e){return l.call(e,this)})}r&&C(RegExp.prototype[i],"sham",!0)}("split",2,function(i,m,b){var k;return k="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||1<".".split(/()()/).length||"".split(/.?/).length?function(e,t){var n=String(h(this)),r=void 0===t?io:t>>>0;if(0==r)return[];if(void 0===e)return[n];if(!function(e){var t;return v(e)&&(void 0!==(t=e[Qi])?!!t:"RegExp"==p(e))}(e))return m.call(n,e,r);for(var i,o,a,s=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),c=0,l=new RegExp(e.source,u+"g");(i=Vi.call(l,n))&&!(c<(o=l.lastIndex)&&(s.push(n.slice(c,i.index)),1<i.length&&i.index<n.length&&no.apply(s,i.slice(1)),a=i[0].length,c=o,s.length>=r));)l.lastIndex===i.index&&l.lastIndex++;return c===n.length?!a&&l.test("")||s.push(""):s.push(n.slice(c)),s.length>r?s.slice(0,r):s}:"0".split(void 0,0).length?function(e,t){return void 0===e&&0===t?[]:m.call(this,e,t)}:m,[function(e,t){var n=h(this),r=null==e?void 0:e[i];return void 0!==r?r.call(e,n,t):k.call(String(n),e,t)},function(e,t){var n=b(k,e,this,t,k!==m);if(n.done)return n.value;var r=S(e),i=String(this),o=function(e,t){var n,r=S(e).constructor;return void 0===r||null==(n=S(r)[eo])?t:ue(n)}(r,RegExp),a=r.unicode,s=(r.ignoreCase?"i":"")+(r.multiline?"m":"")+(r.unicode?"u":"")+(oo?"y":"g"),u=new o(oo?r:"^(?:"+r.source+")",s),c=void 0===t?io:t>>>0;if(0==c)return[];if(0===i.length)return null===Gi(u,i)?[i]:[];for(var l,f,h=0,p=0,v=[];p<i.length;){u.lastIndex=oo?p:0;var d,g=Gi(u,oo?i:i.slice(p));if(null===g||(d=ro(ne(u.lastIndex+(oo?0:p)),i.length))===h)l=i,p=(f=p)+(a?to(l,f).length:1);else{if(v.push(i.slice(h,p)),v.length===c)return v;for(var y=1;y<=g.length-1;y++)if(v.push(g[y]),v.length===c)return v;p=h=d}}return v.push(i.slice(h)),v}]},!oo);function ao(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e}function so(t,e,n,r){try{return r?e(S(n)[0],n[1]):e(n)}catch(e){var i=t.return;throw void 0!==i&&S(i.call(t)),e}}function uo(e){if(null!=e)return e[Eo]||e["@@iterator"]||wr[Qr(e)]}function co(e,t,n){var r,i,o,a,s,u,c=qe(e),l="function"==typeof this?this:Array,f=arguments.length,h=1<f?t:void 0,p=void 0!==h,v=uo(c),d=0;if(p&&(h=Et(h,2<f?n:void 0,2)),null==v||l==Array&&function(e){return void 0!==e&&(wr.Array===e||Oo[To]===e)}(v))for(i=new l(r=ne(c.length));d<r;d++)u=p?h(c[d],d):c[d],De(i,d,u);else for(s=(a=v.call(c)).next,i=new l;!(o=s.call(a)).done;d++)u=p?so(a,h,[o.value,d],!0):o.value,De(i,d,u);return i.length=d,i}function lo(e){return e+22+75*(e<26)}function fo(e,t,n){var r=0;for(e=n?Io(e/700):e>>1,e+=Io(e/t);455<e;r+=36)e=Io(e/35);return Io(r+36*e/(e+38))}function ho(e){var t,n,r=[],i=(e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(55296<=i&&i<=56319&&n<r){var o=e.charCodeAt(n++);56320==(64512&o)?t.push(((1023&i)<<10)+(1023&o)+65536):(t.push(i),n--)}else t.push(i)}return t}(e)).length,o=128,a=0,s=72;for(t=0;t<e.length;t++)(n=e[t])<128&&r.push(Po(n));var u=r.length,c=u;for(u&&r.push("-");c<i;){var l=xo;for(t=0;t<e.length;t++)o<=(n=e[t])&&n<l&&(l=n);var f=c+1;if(l-o>Io((xo-a)/f))throw RangeError(Co);for(a+=(l-o)*f,o=l,t=0;t<e.length;t++){if((n=e[t])<o&&++a>xo)throw RangeError(Co);if(n==o){for(var h=a,p=36;;p+=36){var v=p<=s?1:s+26<=p?26:p-s;if(h<v)break;var d=h-v,g=36-v;r.push(Po(lo(v+d%g))),h=Io(d/g)}r.push(Po(lo(h))),s=fo(a,f,c==u),a=0,++c}}++a,++o}return r.join("")}function po(e){var t=uo(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return S(t.call(e))}function vo(t){try{return decodeURIComponent(t)}catch(e){return t}}function go(e){var t,n=e.replace(qo," "),r=4;try{return decodeURIComponent(n)}catch(e){for(;r;)n=n.replace((t=r--,Do[t-1]||(Do[t-1]=RegExp("((?:%[\\da-f]{2}){"+t+"})","gi"))),vo);return n}}function yo(e){return Jo[e]}function mo(e){return encodeURIComponent(e).replace(Ho,yo)}function bo(e,t){if(t)for(var n,r,i=t.split("&"),o=0;o<i.length;)(n=i[o++]).length&&(r=n.split("="),e.push({key:go(r.shift()),value:go(r.join("="))}))}function ko(e){this.entries.length=0,bo(this.entries,e)}function So(e,t){if(e<t)throw TypeError("Not enough arguments")}var wo=He("iterator"),Lo=!f(function(){var e=new URL("b?a=1&b=2&c=3","http://a"),n=e.searchParams,r="";return e.pathname="c%20d",n.forEach(function(e,t){n.delete("b"),r+=t+e}),!n.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==n.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!n[wo]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==r||"x"!==new URL("http://x",void 0).host}),To=He("iterator"),Oo=Array.prototype,Eo=He("iterator"),xo=2147483647,Ro=/[^\0-\u007E]/,jo=/[.\u3002\uFF0E\uFF61]/g,Co="Overflow: input needs wider integers to process",Io=Math.floor,Po=String.fromCharCode,Ao=ee("fetch"),Bo=ee("Headers"),Uo=He("iterator"),Mo="URLSearchParams",Fo=Mo+"Iterator",_o=ce.set,zo=ce.getterFor(Mo),No=ce.getterFor(Fo),qo=/\+/g,Do=Array(4),Ho=/[!'()~]|%20/g,Jo={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Vo=Cr(function(e,t){_o(this,{type:Fo,iterator:po(zo(e).entries),kind:t})},"Iterator",function(){var e=No(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n}),Go=function(e){ao(this,Go,Mo);var t,n,r,i,o,a,s,u,c,l=0<arguments.length?e:void 0,f=[];if(_o(this,{type:Mo,entries:f,updateURL:function(){},updateSearchParams:ko}),void 0!==l)if(v(l))if("function"==typeof(t=uo(l)))for(r=(n=t.call(l)).next;!(i=r.call(n)).done;){if((s=(a=(o=po(S(i.value))).next).call(o)).done||(u=a.call(o)).done||!a.call(o).done)throw TypeError("Expected sequence with length 2");f.push({key:s.value+"",value:u.value+""})}else for(c in l)k(l,c)&&f.push({key:c,value:l[c]+""});else bo(f,"string"==typeof l?"?"===l.charAt(0)?l.slice(1):l:l+"")},$o=Go.prototype;!function(e,t,n){for(var r in t)le(e,r,t[r],n)}($o,{append:function(e,t){So(arguments.length,2);var n=zo(this);n.entries.push({key:e+"",value:t+""}),n.updateURL()},delete:function(e){So(arguments.length,1);for(var t=zo(this),n=t.entries,r=e+"",i=0;i<n.length;)n[i].key===r?n.splice(i,1):i++;t.updateURL()},get:function(e){So(arguments.length,1);for(var t=zo(this).entries,n=e+"",r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){So(arguments.length,1);for(var t=zo(this).entries,n=e+"",r=[],i=0;i<t.length;i++)t[i].key===n&&r.push(t[i].value);return r},has:function(e){So(arguments.length,1);for(var t=zo(this).entries,n=e+"",r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){So(arguments.length,1);for(var n,r=zo(this),i=r.entries,o=!1,a=e+"",s=t+"",u=0;u<i.length;u++)(n=i[u]).key===a&&(o?i.splice(u--,1):(o=!0,n.value=s));o||i.push({key:a,value:s}),r.updateURL()},sort:function(){var e,t,n,r=zo(this),i=r.entries,o=i.slice();for(n=i.length=0;n<o.length;n++){for(e=o[n],t=0;t<n;t++)if(i[t].key>e.key){i.splice(t,0,e);break}t===n&&i.push(e)}r.updateURL()},forEach:function(e,t){for(var n,r=zo(this).entries,i=Et(e,1<arguments.length?t:void 0,3),o=0;o<r.length;)i((n=r[o++]).value,n.key,this)},keys:function(){return new Vo(this,"keys")},values:function(){return new Vo(this,"values")},entries:function(){return new Vo(this,"entries")}},{enumerable:!0}),le($o,Uo,$o.entries),le($o,"toString",function(){for(var e,t=zo(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(mo(e.key)+"="+mo(e.value));return n.join("&")},{enumerable:!0}),mn(Go,Mo),se({global:!0,forced:!Lo},{URLSearchParams:Go}),Lo||"function"!=typeof Ao||"function"!=typeof Bo||se({global:!0,enumerable:!0,forced:!0},{fetch:function(e,t){var n,r,i,o=[e];return 1<arguments.length&&(v(n=t)&&(r=n.body,Qr(r)===Mo&&((i=n.headers?new Bo(n.headers):new Bo).has("content-type")||i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),n=Ln(n,{body:a(0,String(r)),headers:a(0,i)}))),o.push(n)),Ao.apply(this,o)}});function Zo(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return ka;if(!(n=Ba(t.slice(1,-1))))return ka;e.host=n}else if(qa(e)){if(t=function(e){var t,n,r=[],i=e.toLowerCase().replace(jo,".").split(".");for(t=0;t<i.length;t++)n=i[t],r.push(Ro.test(n)?"xn--"+ho(n):n);return r.join(".")}(t),ja.test(t))return ka;if(null===(n=Aa(t)))return ka;e.host=n}else{if(Ca.test(t))return ka;for(n="",r=co(t),i=0;i<r.length;i++)n+=za(r[i],Ua);e.host=n}}function Wo(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=ya(e/256);return t.join(".")}if("object"!=typeof e)return e;for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,o=0;o<8;o++)0!==e[o]?(n<i&&(t=r,n=i),r=null,i=0):(null===r&&(r=o),++i);return n<i&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i=i&&!1,r===n?(t+=n?":":"::",i=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}function Ko(e){return""!=e.username||""!=e.password}function Yo(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme}function Xo(e,t){var n;return 2==e.length&&wa.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)}function Qo(e){var t;return 1<e.length&&Xo(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)}function ea(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&Xo(t[0],!0)||t.pop()}function ta(e,t,n,r){var i,o,a,s,u,c,l=n||Da,f=0,h="",p=!1,v=!1,d=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(Ia,"")),t=t.replace(Pa,""),i=co(t);f<=i.length;){switch(o=i[f],l){case Da:if(!o||!wa.test(o)){if(n)return ba;l=Ja;continue}h+=o.toLowerCase(),l=Ha;break;case Ha:if(o&&(La.test(o)||"+"==o||"-"==o||"."==o))h+=o.toLowerCase();else{if(":"!=o){if(n)return ba;h="",l=Ja,f=0;continue}if(n&&(qa(e)!=k(Na,h)||"file"==h&&(Ko(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=h,n)return void(qa(e)&&Na[e.scheme]==e.port&&(e.port=null));h="","file"==e.scheme?l=ts:qa(e)&&r&&r.scheme==e.scheme?l=Va:qa(e)?l=Wa:"/"==i[f+1]?(l=Ga,f++):(e.cannotBeABaseURL=!0,e.path.push(""),l=as)}break;case Ja:if(!r||r.cannotBeABaseURL&&"#"!=o)return ba;if(r.cannotBeABaseURL&&"#"==o){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,l=us;break}l="file"==r.scheme?ts:$a;continue;case Va:if("/"!=o||"/"!=i[f+1]){l=$a;continue}l=Ka,f++;break;case Ga:if("/"==o){l=Ya;break}l=os;continue;case $a:if(e.scheme=r.scheme,o==ra)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==o||"\\"==o&&qa(e))l=Za;else if("?"==o)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",l=ss;else{if("#"!=o){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),l=os;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",l=us}break;case Za:if(!qa(e)||"/"!=o&&"\\"!=o){if("/"!=o){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,l=os;continue}l=Ya}else l=Ka;break;case Wa:if(l=Ka,"/"!=o||"/"!=h.charAt(f+1))continue;f++;break;case Ka:if("/"==o||"\\"==o)break;l=Ya;continue;case Ya:if("@"==o){p&&(h="%40"+h),p=!0,a=co(h);for(var g=0;g<a.length;g++){var y=a[g];if(":"!=y||d){var m=za(y,_a);d?e.password+=m:e.username+=m}else d=!0}h=""}else if(o==ra||"/"==o||"?"==o||"#"==o||"\\"==o&&qa(e)){if(p&&""==h)return"Invalid authority";f-=co(h).length+1,h="",l=Xa}else h+=o;break;case Xa:case Qa:if(n&&"file"==e.scheme){l=rs;continue}if(":"!=o||v){if(o==ra||"/"==o||"?"==o||"#"==o||"\\"==o&&qa(e)){if(qa(e)&&""==h)return ka;if(n&&""==h&&(Ko(e)||null!==e.port))return;if(s=Zo(e,h))return s;if(h="",l=is,n)return;continue}"["==o?v=!0:"]"==o&&(v=!1),h+=o}else{if(""==h)return ka;if(s=Zo(e,h))return s;if(h="",l=es,n==Qa)return}break;case es:if(!Ta.test(o)){if(o==ra||"/"==o||"?"==o||"#"==o||"\\"==o&&qa(e)||n){if(""!=h){var b=parseInt(h,10);if(65535<b)return Sa;e.port=qa(e)&&b===Na[e.scheme]?null:b,h=""}if(n)return;l=is;continue}return Sa}h+=o;break;case ts:if(e.scheme="file","/"==o||"\\"==o)l=ns;else{if(!r||"file"!=r.scheme){l=os;continue}if(o==ra)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==o)e.host=r.host,e.path=r.path.slice(),e.query="",l=ss;else{if("#"!=o){Qo(i.slice(f).join(""))||(e.host=r.host,e.path=r.path.slice(),ea(e)),l=os;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",l=us}}break;case ns:if("/"==o||"\\"==o){l=rs;break}r&&"file"==r.scheme&&!Qo(i.slice(f).join(""))&&(Xo(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),l=os;continue;case rs:if(o==ra||"/"==o||"\\"==o||"?"==o||"#"==o){if(!n&&Xo(h))l=os;else if(""==h){if(e.host="",n)return;l=is}else{if(s=Zo(e,h))return s;if("localhost"==e.host&&(e.host=""),n)return;h="",l=is}continue}h+=o;break;case is:if(qa(e)){if(l=os,"/"!=o&&"\\"!=o)continue}else if(n||"?"!=o)if(n||"#"!=o){if(o!=ra&&(l=os,"/"!=o))continue}else e.fragment="",l=us;else e.query="",l=ss;break;case os:if(o==ra||"/"==o||"\\"==o&&qa(e)||!n&&("?"==o||"#"==o)){if(".."===(c=(c=h).toLowerCase())||"%2e."===c||".%2e"===c||"%2e%2e"===c?(ea(e),"/"==o||"\\"==o&&qa(e)||e.path.push("")):"."===(u=h)||"%2e"===u.toLowerCase()?"/"==o||"\\"==o&&qa(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&Xo(h)&&(e.host&&(e.host=""),h=h.charAt(0)+":"),e.path.push(h)),h="","file"==e.scheme&&(o==ra||"?"==o||"#"==o))for(;1<e.path.length&&""===e.path[0];)e.path.shift();"?"==o?(e.query="",l=ss):"#"==o&&(e.fragment="",l=us)}else h+=za(o,Fa);break;case as:"?"==o?(e.query="",l=ss):"#"==o?(e.fragment="",l=us):o!=ra&&(e.path[0]+=za(o,Ua));break;case ss:n||"#"!=o?o!=ra&&("'"==o&&qa(e)?e.query+="%27":e.query+="#"==o?"%23":za(o,Ua)):(e.fragment="",l=us);break;case us:o!=ra&&(e.fragment+=za(o,Ma))}f++}}function na(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}}var ra,ia,oa,aa,sa,ua,ca,la={URLSearchParams:Go,getState:zo},fa=ni.codeAt,ha=d.URL,pa=la.URLSearchParams,va=la.getState,da=ce.set,ga=ce.getterFor("URL"),ya=Math.floor,ma=Math.pow,ba="Invalid scheme",ka="Invalid host",Sa="Invalid port",wa=/[A-Za-z]/,La=/[\d+\-.A-Za-z]/,Ta=/\d/,Oa=/^(0x|0X)/,Ea=/^[0-7]+$/,xa=/^\d+$/,Ra=/^[\dA-Fa-f]+$/,ja=/[\u0000\u0009\u000A\u000D #%/:?@[\\]]/,Ca=/[\u0000\u0009\u000A\u000D #/:?@[\\]]/,Ia=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,Pa=/[\u0009\u000A\u000D]/g,Aa=function(e){var t,n,r,i,o,a,s,u=e.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),4<(t=u.length))return e;for(n=[],r=0;r<t;r++){if(""==(i=u[r]))return e;if(o=10,1<i.length&&"0"==i.charAt(0)&&(o=Oa.test(i)?16:8,i=i.slice(8==o?1:2)),""===i)a=0;else{if(!(10==o?xa:8==o?Ea:Ra).test(i))return e;a=parseInt(i,o)}n.push(a)}for(r=0;r<t;r++)if(a=n[r],r==t-1){if(a>=ma(256,5-t))return null}else if(255<a)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*ma(256,3-r);return s},Ba=function(e){function t(){return e.charAt(h)}var n,r,i,o,a,s,u,c=[0,0,0,0,0,0,0,0],l=0,f=null,h=0;if(":"==t()){if(":"!=e.charAt(1))return;h+=2,f=++l}for(;t();){if(8==l)return;if(":"!=t()){for(n=r=0;r<4&&Ra.test(t());)n=16*n+parseInt(t(),16),h++,r++;if("."==t()){if(0==r)return;if(h-=r,6<l)return;for(i=0;t();){if(o=null,0<i){if(!("."==t()&&i<4))return;h++}if(!Ta.test(t()))return;for(;Ta.test(t());){if(a=parseInt(t(),10),null===o)o=a;else{if(0==o)return;o=10*o+a}if(255<o)return;h++}c[l]=256*c[l]+o,2!=++i&&4!=i||l++}if(4!=i)return;break}if(":"==t()){if(h++,!t())return}else if(t())return;c[l++]=n}else{if(null!==f)return;h++,f=++l}}if(null!==f)for(s=l-f,l=7;0!=l&&0<s;)u=c[l],c[l--]=c[f+s-1],c[f+--s]=u;else if(8!=l)return;return c},Ua={},Ma=qt({},Ua,{" ":1,'"':1,"<":1,">":1,"`":1}),Fa=qt({},Ma,{"#":1,"?":1,"{":1,"}":1}),_a=qt({},Fa,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),za=function(e,t){var n=fa(e,0);return 32<n&&n<127&&!k(t,e)?e:encodeURIComponent(e)},Na={ftp:21,file:null,http:80,https:443,ws:80,wss:443},qa=function(e){return k(Na,e.scheme)},Da={},Ha={},Ja={},Va={},Ga={},$a={},Za={},Wa={},Ka={},Ya={},Xa={},Qa={},es={},ts={},ns={},rs={},is={},os={},as={},ss={},us={},cs=function(e,t){var n,r,i=ao(this,cs,"URL"),o=1<arguments.length?t:void 0,a=String(e),s=da(i,{type:"URL"});if(void 0!==o)if(o instanceof cs)n=ga(o);else if(r=ta(n={},String(o)))throw TypeError(r);if(r=ta(s,a,null,n))throw TypeError(r);var u=s.searchParams=new pa,c=va(u);c.updateSearchParams(s.query),c.updateURL=function(){s.query=String(u)||null},g||(i.href=fs.call(i),i.origin=hs.call(i),i.protocol=ps.call(i),i.username=vs.call(i),i.password=ds.call(i),i.host=gs.call(i),i.hostname=ys.call(i),i.port=ms.call(i),i.pathname=bs.call(i),i.search=ks.call(i),i.searchParams=Ss.call(i),i.hash=ws.call(i))},ls=cs.prototype,fs=function(){var e=ga(this),t=e.scheme,n=e.username,r=e.password,i=e.host,o=e.port,a=e.path,s=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",Ko(e)&&(c+=n+(r?":"+r:"")+"@"),c+=Wo(i),null!==o&&(c+=":"+o)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?a[0]:a.length?"/"+a.join("/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},hs=function(){var e=ga(this),t=e.scheme,n=e.port;if("blob"==t)try{return new URL(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&qa(e)?t+"://"+Wo(e.host)+(null!==n?":"+n:""):"null"},ps=function(){return ga(this).scheme+":"},vs=function(){return ga(this).username},ds=function(){return ga(this).password},gs=function(){var e=ga(this),t=e.host,n=e.port;return null===t?"":null===n?Wo(t):Wo(t)+":"+n},ys=function(){var e=ga(this).host;return null===e?"":Wo(e)},ms=function(){var e=ga(this).port;return null===e?"":String(e)},bs=function(){var e=ga(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},ks=function(){var e=ga(this).query;return e?"?"+e:""},Ss=function(){return ga(this).searchParams},ws=function(){var e=ga(this).fragment;return e?"#"+e:""};if(g&&fn(ls,{href:na(fs,function(e){var t=ga(this),n=String(e),r=ta(t,n);if(r)throw TypeError(r);va(t.searchParams).updateSearchParams(t.query)}),origin:na(hs),protocol:na(ps,function(e){var t=ga(this);ta(t,String(e)+":",Da)}),username:na(vs,function(e){var t=ga(this),n=co(String(e));if(!Yo(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=za(n[r],_a)}}),password:na(ds,function(e){var t=ga(this),n=co(String(e));if(!Yo(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=za(n[r],_a)}}),host:na(gs,function(e){var t=ga(this);t.cannotBeABaseURL||ta(t,String(e),Xa)}),hostname:na(ys,function(e){var t=ga(this);t.cannotBeABaseURL||ta(t,String(e),Qa)}),port:na(ms,function(e){var t=ga(this);Yo(t)||(""==(e=String(e))?t.port=null:ta(t,e,es))}),pathname:na(bs,function(e){var t=ga(this);t.cannotBeABaseURL||(t.path=[],ta(t,e+"",is))}),search:na(ks,function(e){var t=ga(this);""==(e=String(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",ta(t,e,ss)),va(t.searchParams).updateSearchParams(t.query)}),searchParams:na(Ss),hash:na(ws,function(e){var t=ga(this);""!=(e=String(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",ta(t,e,us)):t.fragment=null})}),le(ls,"toJSON",function(){return fs.call(this)},{enumerable:!0}),le(ls,"toString",function(){return fs.call(this)},{enumerable:!0}),ha){var Ls=ha.createObjectURL,Ts=ha.revokeObjectURL;Ls&&le(cs,"createObjectURL",function(e){return Ls.apply(ha,arguments)}),Ts&&le(cs,"revokeObjectURL",function(e){return Ts.apply(ha,arguments)})}function Os(e){if(!e)return{xpath:""};for(var t=[];e&&1===e.nodeType&&e!==e.parentNode&&(t.push(e.tagName.toLowerCase()),e!==document.body);)e=e.parentNode;return{xpath:t.join("<")}}function Es(e){return+e.toFixed(1)}mn(cs,"URL"),se({global:!0,forced:!Lo,sham:!g},{URL:cs}),(oa=ia=ia||{}).JS="js",oa.CSS="css",oa.IMG="img",oa.FONT="font",(sa=aa=aa||{})[sa.ttf=0]="ttf",sa[sa.eot=1]="eot",sa[sa.woff=2]="woff",sa[sa.woff2=3]="woff2",(ca=ua=ua||{})[ca["/mwb2.gif"]=0]="/mwb2.gif";var xs=(Fe(Rs,[{key:"check",value:function(){return performance&&performance.getEntriesByType}},{key:"listenResource",value:function(e){this.check()&&(this.cb=e)}},{key:"listenBigImg",value:function(e,t){var n=1<arguments.length&&void 0!==t?t:150;this.check()&&(this.maxImgSize=1024*n,this.bigImgCB=e)}},{key:"listenHttpResource",value:function(e){this.check()&&(this.httpResCB=e)}},{key:"load",value:function(){var s=this;this.check()&&setTimeout(function(){var e=s.getMetric();e&&s.cb&&s.cb(e),window.requestIdleCallback&&s.bigImgList.length&&s.bigImgCB&&window.requestIdleCallback(function(){var e=!0,t=!1,n=void 0;try{for(var r,i=s.bigImgList[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var o=r.value;try{var a=document.body.querySelector('img[src="'+o.name+'"]');s.bigImgCB({msg:o.name,xpath:Os(a).xpath})}catch(e){console.error(e)}}}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}}),window.requestIdleCallback&&s.httpResList.length&&s.httpResCB&&window.requestIdleCallback(function(){var e=!0,t=!1,n=void 0;try{for(var r,i=s.httpResList[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var o=r.value;try{var a=document.body.querySelector('[src="'+o.name+'"]');s.httpResCB({msg:o.name,xpath:Os(a).xpath})}catch(e){console.error(e)}}}catch(e){t=!0,n=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw n}}})},500)}},{key:"getUrlObj",value:function(e){try{var t=new URL(e),n=t.pathname.split(".");return t.ext=n[n.length-1],t}catch(e){return{}}}},{key:"collectHttpResInHttps",value:function(e){"https:"===location.protocol&&0===e.name.indexOf("http://")&&this.httpResList.push(e)}},{key:"addScript",value:function(e){"js"===this.getUrlObj(e.name).ext&&(0!==e.decodedBodySize&&this.jsList.push(e),this.collectHttpResInHttps(e))}},{key:"addCss",value:function(e){var t=this.getUrlObj(e.name).ext;t&&aa.hasOwnProperty(t)?this.fontList.push(e):this.imgList.push(e)}},{key:"addLink",value:function(e){var t=this.getUrlObj(e.name).ext;"css"===t?this.cssList.push(e):"js"===t&&this.jsList.push(e)}},{key:"addImg",value:function(e){var t=this.getUrlObj(e.name).pathname;ua.hasOwnProperty(t)||(this.imgList.push(e),-1<e.name.indexOf("fm=")&&-1<e.name.indexOf("webpstat=1")&&this.imgTnList.push(e),e.decodedBodySize>this.maxImgSize&&this.bigImgList.push(e),this.collectHttpResInHttps(e))}},{key:"handleTimings",value:function(e){for(var t=e.length,n=0;n<t;n++)switch(e[n].initiatorType){case"script":this.addScript(e[n]);break;case"css":this.addCss(e[n]);break;case"img":this.addImg(e[n]);break;case"link":this.addLink(e[n]);break;case"audio":case"video":this.collectHttpResInHttps(e[n])}}},{key:"getNumAndSize",value:function(e){var t={},n=e+"Num",r=e+"Size",i=e+"TransferSize",o=e+"CacheRate",a=e+"Duration";t[n]=0,t[r]=0;var s=t[i]=0;if(this[e+"List"].forEach(function(e){t[n]++,t[r]+=e.decodedBodySize/1024,t[i]+=e.transferSize/1024,s+=e.duration}),t[a]=Es(0<t[n]?s/t[n]:0),t[r]){var u=t[r]-t[i];t[o]=Es(0<=u?100*u/t[r]:0)}return t[r]=Es(t[r]),t[i]=Es(t[i]),t}},{key:"getMetric",value:function(){var e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("resource");if(e&&t&&t.length){this.handleTimings(t);var n=Object.assign(Object.assign(Object.assign(Object.assign({},this.getNumAndSize(ia.JS)),this.getNumAndSize(ia.CSS)),this.getNumAndSize(ia.IMG)),this.getNumAndSize(ia.FONT)),r=e;return n.docSize=Es(r.decodedBodySize/1024),n.docTransferSize=Es(r.transferSize/1024),n.headerSize=Es((r.transferSize-r.encodedBodySize||0)/1024),n.allSize=Es(n.docSize+n.jsSize+n.cssSize+n.imgSize+n.fontSize),n.allTransferSize=Es(n.docTransferSize+n.jsTransferSize+n.cssTransferSize+n.imgTransferSize+n.fontTransferSize),n}}}]),Rs);function Rs(){Ue(this,Rs),this.jsList=[],this.cssList=[],this.imgList=[],this.fontList=[],this.bigImgList=[],this.httpResList=[]}var js=null;window.performance&&window.performance.memory&&(js=window.performance.memory);var Cs=(Fe(Is,[{key:"listenMemory",value:function(e){this.cb=e}},{key:"leave",value:function(){if(!this.onceLeave&&js){this.onceLeave=!0;var e=window.performance.memory;if(e.usedJSHeapSize===js.usedJSHeapSize&&e.totalJSHeapSize===js.totalJSHeapSize)return;var t=window.performance.memory;this.cb&&this.cb({usedJSHeapSize:t.usedJSHeapSize/1024,totalJSHeapSize:t.totalJSHeapSize/1024,jsHeapSizeLimit:t.jsHeapSizeLimit/1024,usedJSHeapRate:100*t.usedJSHeapSize/t.totalJSHeapSize})}}}]),Is);function Is(){Ue(this,Is),this.onceLeave=!1}var Ps=(Fe(As,[{key:"getNavigatorInfo",value:function(){var e={},t=navigator.connection;return"object"===Be(t)&&(e={downlink:t.downlink,effectiveType:t.effectiveType,rtt:t.rtt,saveData:!!t.saveData}),navigator.deviceMemory&&(e.deviceMemory=navigator.deviceMemory),navigator.hardwareConcurrency&&(e.hardwareConcurrency=navigator.deviceMemory),e}},{key:"load",value:function(){}}]),As);function As(){Ue(this,As)}var Bs=window.__spyHead,Us="longtask",Ms=(Fe(Fs,[{key:"check",value:function(){return window.PerformanceObserver&&performance&&performance.timing&&performance.timing.navigationStart}},{key:"listenFSPLongTask",value:function(e){this.check()&&(this.fspCB=e)}},{key:"listenLCPLongTask",value:function(e){this.check()&&(this.lcpCB=e)}},{key:"listenLoadLongTask",value:function(e){this.check()&&(this.loadCB=e)}},{key:"listenPageLongTask",value:function(e){this.check()&&(this.pageCB=e)}},{key:"load",value:function(){var n=this;if(this.check()){var r=this.getStatData(Date.now());setTimeout(function(){if(n.loadCB&&n.loadCB({loadLongtaskTime:r.time,loadTBT:r.tbt,loadTotalTime:r.totalTime,loadLongtaskRate:r.rate,loadLongtaskNum:r.num}),performance.timing&&performance.timing.domFirstScreenPaint){var e=n.getStatData(performance.timing.domFirstScreenPaint);n.fspCB&&n.fspCB({fspLongtaskTime:e.time,fspTBT:e.tbt,fspTotalTime:e.totalTime,fspLongtaskRate:e.rate,fspLongtaskNum:e.num})}if(nn("lcp")){var t=n.getStatData(performance.timing.navigationStart+nn("lcp"));n.lcpCB&&n.lcpCB({lcpLongtaskTime:t.time,lcpTBT:t.tbt,lcpTotalTime:t.totalTime,lcpLongtaskRate:t.rate,lcpLongtaskNum:t.num})}},200)}}},{key:"leave",value:function(){if(!this.onceLeave){this.onceLeave=!0;var e=this.getStatData(Date.now());this.pageCB&&this.pageCB({pageLongtaskTime:e.time,pageTBT:e.tbt,pageTotalTime:e.totalTime,pageLongtaskRate:e.rate,pageLongtaskNum:e.num,pageIframeLongtaskTime:e.iframeTime,pageIframeLongtaskRate:e.iframeRate,pageIframeLongtaskNum:e.iframeNum})}}},{key:"destroy",value:function(){this.lts=[],this.observer&&this.observer.disconnect(),this.observer=null}},{key:"getStatData",value:function(e){for(var t=performance.timing.navigationStart,n=0,r=0,i=0,o=0,a=0,s={},u=0;u<this.lts.length;u++){var c=this.lts[u],l=c.duration;if(t+c.startTime+l<e&&(n+=l,r+=0<l-50?l-50:0,i++,c.attribution&&c.attribution[0])){var f=c.attribution[0].containerSrc;f&&f!==location.href&&(s[f]||(s[f]=[]),s[f].push(l),o+=l,a++)}}var h=e-t;return{num:i,time:n,tbt:r,totalTime:h,rate:100*n/h,iframeTime:o,iframeNum:a,iframeRate:100*o/h,iframeLongtasks:s}}}]),Fs);function Fs(){var t=this;Ue(this,Fs),this.lts=[],this.observer=null,this.onceLeave=!1,Bs&&Bs.entryMap&&Bs.entryMap[Us]&&(this.lts=this.lts.concat(Bs.entryMap[Us]));try{this.observer=new PerformanceObserver(function(e){t.lts=t.lts.concat(e.getEntries())}),this.observer.observe({entryTypes:[Us]})}catch(e){}}function _s(e){var t;return Ue(this,_s),(t=function(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?Ne(e):t}(this,_e(_s).call(this,e))).modules=[],t.register(new Wt),t.register(new an),t.register(new Qt),t.register(new bi),t.register(new Ri),t.register(new xs),t.register(new Cs),t.register(new Ps),t.register(new Ms),t.visibilitychangeCB=t.visibilitychangeCB.bind(Ne(t)),t.load=t.load.bind(Ne(t)),t.leave=t.leave.bind(Ne(t)),"complete"===document.readyState?t.load():window.addEventListener("load",t.load),document.addEventListener("visibilitychange",t.visibilitychangeCB),window.addEventListener("beforeunload",t.leave,!1),window.addEventListener("unload",t.leave,!1),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ze(e,t)}(_s,Vt),Fe(_s,[{key:"listenFID",value:function(e){this.invoke("listenFID",e)}},{key:"listenLayoutShift",value:function(e){this.invoke("listenLayoutShift",e)}},{key:"listenLCP",value:function(e){this.invoke("listenLCP",e)}},{key:"listenFSPLongTask",value:function(e){this.invoke("listenFSPLongTask",e)}},{key:"listenLCPLongTask",value:function(e){this.invoke("listenLCPLongTask",e)}},{key:"listenLoadLongTask",value:function(e){this.invoke("listenLoadLongTask",e)}},{key:"listenPageLongTask",value:function(e){this.invoke("listenPageLongTask",e)}},{key:"listenMemory",value:function(e){this.invoke("listenMemory",e)}},{key:"getNavigatorInfo",value:function(){return this.invoke("getNavigatorInfo")}},{key:"listenResource",value:function(e){this.invoke("listenResource",e)}},{key:"listenBigImg",value:function(e,t){this.invoke("listenBigImg",e,t)}},{key:"listenHttpResource",value:function(e){this.invoke("listenHttpResource",e)}},{key:"listenTiming",value:function(e){this.invoke("listenTiming",e)}},{key:"listenTTI",value:function(e,t){this.invoke("listenTTI",e,t)}},{key:"invoke",value:function(e,t,n){for(var r=0;r<this.modules.length;r++){var i=this.modules[r];if("function"==typeof i[e])return i[e].apply(i,[t,n])}console.error("no method",e)}},{key:"register",value:function(e){this.modules.push(e)}},{key:"load",value:function(){for(var e=0;e<this.modules.length;e++){var t=this.modules[e];t.load&&t.load()}}},{key:"leave",value:function(){for(var e=0;e<this.modules.length;e++){var t=this.modules[e];t.leave&&t.leave()}}},{key:"destroy",value:function(){for(var e=0;e<this.modules.length;e++){var t=this.modules[e];t.destroy&&t.destroy()}document.removeEventListener("visibilitychange",this.visibilitychangeCB),window.removeEventListener("load",this.load),window.removeEventListener("beforeunload",this.leave),window.removeEventListener("unload",this.destroy)}},{key:"visibilitychangeCB",value:function(){"hidden"===document.visibilityState&&this.leave()}}]),_s});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SpyClient=e()}(this,function(){"use strict";var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};var l=function(){return(l=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,t)}function r(t){var e=function(t){if(URL){t=new URL(t);if(void 0!==t.host)return{protocol:t.protocol,host:t.host,pathname:t.pathname,ext:""}}}(t);e||((i=document.createElement("a")).href=t,e={protocol:i.protocol,host:i.host||location.host,pathname:i.pathname,ext:""});var i=e.pathname.split(".");return e.ext=i[i.length-1],e}function u(t){return+t.toFixed(1)}function f(t){if(!t)return{xpath:""};for(var e=[];t&&1===t.nodeType&&t!==t.parentNode;){var i=t.tagName.toLowerCase();if(t.getAttribute("id")?i+="[#"+t.getAttribute("id")+"]":t.classList&&t.classList.length&&(i+="[."+t.classList[t.classList.length-1]+"]"),e.push(i),t===document.body)break;t=t.parentNode}return{xpath:e.join("<")}}var e=/(iPhone|iPod|iPad)/.test(navigator.userAgent);function d(t){console.error("[SpyClient_log]"+t)}var t=(n.prototype.send=function(t){if(this.check(t)){if("number"==typeof t.sample){if(Math.random()>t.sample)return}else if("number"==typeof this.option.sample&&Math.random()>this.option.sample)return;delete(t=o({pid:this.option.pid,lid:this.option.lid,ts:Date.now(),group:"common"},t)).sample;var i,t=this.option.logServer+(i=t,Object.keys(i).map(function(t){var e=i[t];return void 0===e?e="":"string"!=typeof e&&(e=JSON.stringify(e)),encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&"));!e&&navigator.sendBeacon&&navigator.sendBeacon(t)||((new Image).src=t)}},n.prototype.check=function(t){if(!this.option.check)return!0;var e=["perf","except","dist","count"];if(-1===e.indexOf(t.type))return d("type only is one of "+e.join(", ")),!1;if(t.group&&30<t.group.length)return d("group length execeeds 30"),!1;var i=/^[a-zA-Z0-9-_]{0,30}$/;if("except"===t.type){if("string"!=typeof t.info.msg||!t.info.msg.length)return d("info.msg field must be not empty and is String"),!1}else for(var o=0,n=Object.keys(t.info);o<n.length;o++){var r=n[o];if(!i.test(r))return d("info."+r+" is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var s=t.info[r];if("dist"===t.type){if(30<s.length)return d("info."+r+" value length execeeds 30 when type == 'dist'"),!1}else if("number"!=typeof s)return d("info."+r+" value must be number"),!1}if(t.dim)for(var a=0,c=Object.keys(t.dim);a<c.length;a++){var p=c[a];if(!i.test(p))return d("dim key ["+p+"] is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_"),!1;var h=t.dim[p];if(!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(h))return d("dim."+p+" value ["+h+"] is unexpected. Length must be not more than 30. Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese"),!1}return!0},n.prototype.sendPerf=function(t){this.send(o({type:"perf"},t))},n.prototype.sendExcept=function(t){this.send(o({type:"except"},t))},n.prototype.sendDist=function(t){this.send(o({type:"dist"},t))},n.prototype.sendCount=function(t){this.send(o({type:"count"},t))},n.prototype.sendExceptForError=function(t,e){var i=o({},e);i.info=o({},e.info||{},{msg:t.message,stack:t.stack}),this.sendExcept(i)},n.prototype.startMark=function(t){this.markCache[t]={start:Date.now()}},n.prototype.endMark=function(t){return this.markCache[t]?(this.markCache[t].total=Date.now()-this.markCache[t].start,this.markCache[t].total):0},n.prototype.clearMark=function(t){this.markCache[t]&&delete this.markCache[t]},n.prototype.getAllMark=function(){for(var t={},e=0,i=Object.keys(this.markCache);e<i.length;e++){var o=i[e];t[o]=this.markCache[o].total}return t},n.prototype.clearAllMark=function(){this.markCache={}},n);function n(t){if(this.sample={},this.markCache={},!t.pid)throw new Error("pid is required");this.option={pid:t.pid,lid:t.lid,check:!1!==t.check,sample:t.sample,logServer:t.logServer||"https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?"}}var s=window.__spyHead,a="first-input",c=(p.prototype.listenFID=function(t){this.cb=t,this.callCB()},p.prototype.callCB=function(){void 0!==this.finalValue&&this.cb&&this.cb({fid:this.finalValue})},p.prototype.destroy=function(){this.observer&&this.observer.disconnect(),this.observer=null},p.prototype.handle=function(t){t=t.pop();t&&(this.finalValue=t.duration,this.callCB(),this.destroy())},p);function p(){var e=this;if(this.observer=null,window.PerformanceObserver){s&&s.entryMap&&s.entryMap[a]&&this.handle(s.entryMap[a]);try{this.observer=new PerformanceObserver(function(t){e.handle(t.getEntries())}),this.observer.observe({entryTypes:[a]})}catch(t){}}}var h=window.__spyHead,m="layout-shift",g=(v.prototype.listenLayoutShift=function(t){this.cb=t},v.prototype.leave=function(){this.onceLeave||(this.onceLeave=!0,this.observer&&this.observer.takeRecords&&this.observer.takeRecords(),this.finalValue=this.value,this.callCB(),this.destroy())},v.prototype.callCB=function(){void 0!==this.finalValue&&this.cb&&this.cb({layoutShift:this.finalValue})},v.prototype.destroy=function(){this.observer&&this.observer.disconnect(),this.observer=null},v.prototype.handle=function(t){var e=this;t.map(function(t){t.hadRecentInput||(e.value=(e.value||0)+(t.value||0))})},v);function v(){var e=this;if(this.observer=null,this.onceLeave=!1,window.PerformanceObserver){h&&h.entryMap&&h.entryMap[m]&&this.handle(h.entryMap[m]);try{this.observer=new PerformanceObserver(function(t){e.handle(t.getEntries())}),this.observer.observe({entryTypes:[m]})}catch(t){}}}var y={};var b=window.__spyHead,k="largest-contentful-paint",L=(S.prototype.listenLCP=function(t){this.cb=t,this.callCB()},S.prototype.callCB=function(){this.finalValue&&this.cb&&this.cb({lcp:this.finalValue})},S.prototype.load=function(){var t,e;this.observer&&this.observer.takeRecords&&this.observer.takeRecords(),this.finalValue=this.value,t="lcp",e=this.value,y[t]=e,this.callCB(),this.destroy()},S.prototype.destroy=function(){this.observer&&this.observer.disconnect(),this.observer=null},S.prototype.handle=function(t){var e=this;t.map(function(t){e.value=t.renderTime||t.loadTime})},S);function S(){var e=this;if(this.observer=null,window.PerformanceObserver){b&&b.entryMap&&b.entryMap[k]&&this.handle(b.entryMap[k]);try{this.observer=new PerformanceObserver(function(t){e.handle(t.getEntries())}),this.observer.observe({entryTypes:[k]})}catch(t){}}}function w(t){return t.name.indexOf(".gif?")<0}var T=(C.prototype.check=function(){return window.PerformanceObserver&&performance&&performance.timing&&performance.timing.navigationStart},C.prototype.listenTTI=function(t,e){this.check()&&(this.observeLongtask(2e4),this.cb=t,(e=e||{}).interval&&(this.interval=e.interval),e.filterRequest&&(this.filterRequest=e.filterRequest))},C.prototype.load=function(){this.check()&&(this.ttiTimer=setInterval(this.ttiCheck,this.interval))},C.prototype.ttiCheck=function(){var t,e;this.cb&&((t=performance.now())-this.lastLongTask<this.interval||!1!==(e=this.getNetworkSilenceAt())&&(t-e<this.interval||(clearTimeout(this.ttiTimer),e=(e=this.lastLongTask)||performance.timing.domContentLoadedEventEnd-performance.timing.navigationStart,this.stopObserveLongTask(),this.cb({tti:e}))))},C.prototype.observerCallback=function(t){t=t.getEntries(),t=t[t.length-1];this.lastLongTask=t.startTime+t.duration},C.prototype.stopObserveLongTask=function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.stopLongTaskTimeoutId&&clearTimeout(this.stopLongTaskTimeoutId)},C.prototype.getNetworkSilenceAt=function(){for(var t=0,e=0,i=performance.getEntriesByType("resource").filter(this.filterRequest);e<i.length;e++){var o=i[e];if(!o.responseEnd)return!1;o.responseEnd>t&&(t=o.responseEnd)}return t},C.prototype.observeLongtask=function(t){this.stopObserveLongTask();try{this.observer=new PerformanceObserver(this.observerCallback),this.observer.observe({entryTypes:["longtask"]}),this.stopLongTaskTimeoutId=setTimeout(this.stopObserveLongTask,t)}catch(t){}},C);function C(){this.lastLongTask=0,this.observer=null,this.interval=5e3,this.filterRequest=w,this.observerCallback=this.observerCallback.bind(this),this.ttiCheck=this.ttiCheck.bind(this)}var O,B,R,I=(z.prototype.listenTiming=function(t){window.performance&&window.performance.timing&&(this.cb=t)},z.prototype.load=function(){var t=this;setTimeout(function(){t.cb&&t.cb(t.getMetric())},500)},z.prototype.getMetric=function(){var t,o={},e=window.performance.timing,i=e.navigationStart;return o.dns=e.domainLookupEnd-e.domainLookupStart,o.tcp=e.connectEnd-e.connectStart,o.request=e.responseStart-e.requestStart,o.response=e.responseEnd-e.responseStart,o.parseHtml=e.domInteractive-e.domLoading,o.domReady=e.domContentLoadedEventEnd-i,o.loadEventHandle=e.loadEventEnd-e.loadEventStart,o.load=e.loadEventEnd-i,!performance.getEntriesByType||(t=performance.getEntriesByType("paint"))&&t.length&&t.forEach(function(t){var e=t.name,i=t.duration,t=t.startTime,t=Math.ceil(i+t);"first-paint"===e&&(o.fp=t),"first-contentful-paint"===e&&(o.fcp=t)}),e.domFirstPaint&&(o.t7FirstPaint=e.domFirstPaint-i),e.domFirstScreenPaint&&(o.t7FirstScreen=e.domFirstScreenPaint-i),o},z);function z(){}(R=O=O||{}).JS="js",R.CSS="css",R.IMG="img",R.FONT="font",(R=B=B||{})[R.ttf=0]="ttf",R[R.eot=1]="eot",R[R.woff=2]="woff",R[R.woff2=3]="woff2";var E=["/mwb2.gif"];function P(t,e){for(var i=0,o=e;i<o.length;i++){var n=o[i];if(-1<t.indexOf(n))return 1}}function x(t){return+t.toFixed(1)}var M=(j.prototype.check=function(){return performance&&performance.getEntriesByType},j.prototype.listenResource=function(t,e){void 0===e&&(e={}),this.check()&&(this.resOption=o(this.resOption,e),this.trigger=this.resOption.trigger,this.cb=t)},j.prototype.listenBigImg=function(t,e){void 0===e&&(e={}),this.check()&&(this.bigImgOption=o(this.bigImgOption,e),this.trigger=this.bigImgOption.trigger,this.bigImgCB=t)},j.prototype.listenHttpResource=function(t,e){void 0===e&&(e={}),this.check()&&(this.httpResOption=o(this.httpResOption,e),this.trigger=this.httpResOption.trigger,this.httpResCB=t)},j.prototype.listenSlowResource=function(t,e){void 0===e&&(e={}),this.check()&&(this.slowOption=o(this.slowOption,e),this.trigger=this.slowOption.trigger,this.slowResCB=t)},j.prototype.report=function(){var t,h=this,e=this.getMetric();e&&(t=e.metric,e=e.hostMetric,this.cb&&this.cb(t,e)),this.bigImgCB&&"function"==typeof window.requestIdleCallback&&Object.keys(this.bigImgList).length&&window.requestIdleCallback(function(){for(var t=0,e=Object.keys(h.bigImgList);t<e.length;t++)for(var i=e[t],o=0,n=h.bigImgList[i];o<n.length;o++){var r=n[o],s=r.timing,r=r.type;try{var a=document.body.querySelector('img[src="'+s.name+'"]');h.bigImgCB({msg:s.name,dur:s.duration,xpath:f(a).xpath,host:i,type:r})}catch(t){console.error(t)}}}),this.httpResCB&&"function"==typeof window.requestIdleCallback&&Object.keys(this.httpResList).length&&window.requestIdleCallback(function(){for(var t=0,e=Object.keys(h.httpResList);t<e.length;t++)for(var i=e[t],o=0,n=h.httpResList[i];o<n.length;o++){var r=n[o],s=r.timing,r=r.type;try{var a=document.body.querySelector('[src="'+s.name+'"]');h.httpResCB({msg:s.name,dur:s.duration,xpath:f(a).xpath,host:i,type:r})}catch(t){console.error(t)}}}),this.slowResCB&&"function"==typeof window.requestIdleCallback&&Object.keys(this.slowList).length&&window.requestIdleCallback(function(){for(var t,e=0,i=Object.keys(h.slowList);e<i.length;e++)for(var o=i[e],n=0,r=h.slowList[o];n<r.length;n++){var s=r[n],a=s.timing,s=s.type;try{var c=document.body.querySelector('[src="'+a.name+'"]'),p={wait:u((t=a).domainLookupStart-(t.navigationStart||t.fetchStart||t.startTime)),dns:u(t.domainLookupEnd-t.domainLookupStart),connect:u(t.connectEnd-t.connectStart),req:u(t.responseStart-t.requestStart),res:u(t.responseEnd-t.responseStart)};h.slowResCB(l(l({},p),{dur:a.duration,msg:a.name,xpath:f(c).xpath,host:o,type:s}))}catch(t){console.error(t)}}})},j.prototype.load=function(){var t=this;"load"===this.trigger&&this.check()&&setTimeout(function(){t.report()},500)},j.prototype.leave=function(){"leave"===this.trigger&&this.report()},j.prototype.push=function(t,e,i,o){P(o.pathname,this.resOption.ignorePaths||[])||(e.push(i),this.pushWithHost(t,this.hostList,i,o)),P(o.pathname,this.slowOption.ignorePaths||[])||i.duration>this.slowOption.threshold&&this.pushWithHost(t,this.slowList,i,o)},j.prototype.pushWithHost=function(t,e,i,o){o=o.host;e[o]||(e[o]=[]),e[o].push({timing:i,type:t})},j.prototype.collectHttpResInHttps=function(t,e,i){"https:"!==location.protocol||0!==e.name.indexOf("http://")||P(i.pathname,this.httpResOption.ignorePaths||[])||this.pushWithHost(t,this.httpResList,e,i)},j.prototype.addScript=function(t,e){"js"===e.ext&&0!==t.decodedBodySize&&this.push("js",this.jsList,t,e)},j.prototype.addResFromCss=function(t,e){e.ext&&B.hasOwnProperty(e.ext)?this.push("font",this.fontList,t,e):this.addImg(t,e)},j.prototype.addLink=function(t,e){"css"===e.ext?this.push("css",this.cssList,t,e):"js"===e.ext&&this.push("js",this.jsList,t,e)},j.prototype.addImg=function(t,e){this.push("img",this.imgList,t,e),t.decodedBodySize>(this.bigImgOption.maxSize||0)&&!P(e.pathname,this.bigImgOption.ignorePaths||[])&&this.pushWithHost("img",this.bigImgList,t,e)},j.prototype.handleTimings=function(t){for(var e=t.length,i=0;i<e;i++){var o=t[i],n=r(o.name);if(!P(n.pathname,E))switch(t[i].initiatorType){case"script":this.addScript(o,n);break;case"css":this.addResFromCss(o,n);break;case"img":this.addImg(o,n);break;case"link":this.addLink(o,n);break;case"audio":this.collectHttpResInHttps("audio",o,n);break;case"video":this.collectHttpResInHttps("video",o,n)}}},j.prototype.getNumAndSize=function(t,e){var i={},o=t+"Num",n=t+"Size",r=t+"TransferSize",s=t+"CacheRate",t=t+"Duration";i[o]=0,i[n]=0;var a=i[r]=0;return e.forEach(function(t){i[o]++,i[n]+=t.decodedBodySize/1024,i[r]+=t.transferSize/1024,a+=t.duration}),i[t]=x(0<i[o]?a/i[o]:0),i[n]&&(t=i[n]-i[r],i[s]=x(0<=t?100*t/i[n]:0)),i[n]=x(i[n]),i[r]=x(i[r]),i},j.prototype.getMetric=function(){var t=performance.getEntriesByType("navigation")[0],e=performance.getEntriesByType("resource");if(t&&e&&e.length){this.handleTimings(e);e=l(l(l(l({},this.getNumAndSize(O.JS,this.jsList)),this.getNumAndSize(O.CSS,this.cssList)),this.getNumAndSize(O.IMG,this.imgList)),this.getNumAndSize(O.FONT,this.fontList)),t=t;e.docSize=x(t.decodedBodySize/1024),e.docTransferSize=x(t.transferSize/1024),e.headerSize=x((t.transferSize-t.encodedBodySize||0)/1024),e.allSize=x(e.docSize+e.jsSize+e.cssSize+e.imgSize+e.fontSize),e.allTransferSize=x(e.docTransferSize+e.jsTransferSize+e.cssTransferSize+e.imgTransferSize+e.fontTransferSize);for(var i={},o=0,n=Object.keys(this.hostList);o<n.length;o++){var r=n[o],s=this.hostList[r].map(function(t){return t.timing});i[r]=this.getNumAndSize("host",s)}return{metric:e,hostMetric:i}}},j);function j(){this.trigger="load",this.jsList=[],this.cssList=[],this.imgList=[],this.fontList=[],this.hostList={},this.bigImgList={},this.httpResList={},this.slowList={},this.resOption={ignorePaths:[],trigger:"load"},this.bigImgOption={ignorePaths:[],maxSize:153600,trigger:"load"},this.httpResOption={ignorePaths:[],trigger:"load"},this.slowOption={ignorePaths:[],trigger:"load",threshold:1e3}}var H=null;window.performance&&window.performance.memory&&(H=window.performance.memory);var N=(_.prototype.listenMemory=function(t){this.cb=t},_.prototype.leave=function(){var t;!this.onceLeave&&H&&(this.onceLeave=!0,(t=window.performance.memory).usedJSHeapSize===H.usedJSHeapSize&&t.totalJSHeapSize===H.totalJSHeapSize||(t=window.performance.memory,this.cb&&this.cb({usedJSHeapSize:t.usedJSHeapSize/1024,totalJSHeapSize:t.totalJSHeapSize/1024,jsHeapSizeLimit:t.jsHeapSizeLimit/1024,usedJSHeapRate:100*t.usedJSHeapSize/t.totalJSHeapSize})))},_);function _(){this.onceLeave=!1}var F=(q.prototype.getNavigatorInfo=function(){var t={},e=navigator.connection;return"object"==typeof e&&(t={downlink:e.downlink,effectiveType:e.effectiveType,rtt:e.rtt,saveData:!!e.saveData}),navigator.deviceMemory&&(t.deviceMemory=navigator.deviceMemory),navigator.hardwareConcurrency&&(t.hardwareConcurrency=navigator.deviceMemory),t},q.prototype.load=function(){},q);function q(){}var A,D,J,V=window.__spyHead,Z="longtask",W=(U.prototype.check=function(){return window.PerformanceObserver&&performance&&performance.timing&&performance.timing.navigationStart},U.prototype.listenFSPLongTask=function(t){this.check()&&(this.fspCB=t)},U.prototype.listenLCPLongTask=function(t){this.check()&&(this.lcpCB=t)},U.prototype.listenLoadLongTask=function(t){this.check()&&(this.loadCB=t)},U.prototype.listenPageLongTask=function(t){this.check()&&(this.pageCB=t)},U.prototype.load=function(){var e,i=this;this.check()&&(e=this.getStatData(Date.now()),setTimeout(function(){var t;i.loadCB&&i.loadCB({loadLongtaskTime:e.time,loadTBT:e.tbt,loadTotalTime:e.totalTime,loadLongtaskRate:e.rate,loadLongtaskNum:e.num}),performance.timing&&performance.timing.domFirstScreenPaint&&(t=i.getStatData(performance.timing.domFirstScreenPaint),i.fspCB&&i.fspCB({fspLongtaskTime:t.time,fspTBT:t.tbt,fspTotalTime:t.totalTime,fspLongtaskRate:t.rate,fspLongtaskNum:t.num})),y.lcp&&(t=i.getStatData(performance.timing.navigationStart+y.lcp),i.lcpCB&&i.lcpCB({lcpLongtaskTime:t.time,lcpTBT:t.tbt,lcpTotalTime:t.totalTime,lcpLongtaskRate:t.rate,lcpLongtaskNum:t.num}))},200))},U.prototype.leave=function(){var t;this.onceLeave||(this.onceLeave=!0,t=this.getStatData(Date.now()),this.pageCB&&this.pageCB({pageLongtaskTime:t.time,pageTBT:t.tbt,pageTotalTime:t.totalTime,pageLongtaskRate:t.rate,pageLongtaskNum:t.num,pageIframeLongtaskTime:t.iframeTime,pageIframeLongtaskRate:t.iframeRate,pageIframeLongtaskNum:t.iframeNum}))},U.prototype.destroy=function(){this.lts=[],this.observer&&this.observer.disconnect(),this.observer=null},U.prototype.getStatData=function(t){for(var e=performance.timing.navigationStart,i=0,o=0,n=0,r=0,s=0,a={},c=0;c<this.lts.length;c++){var p=this.lts[c],h=p.duration;e+p.startTime+h<t&&(i+=h,o+=0<h-50?h-50:0,n++,p.attribution&&p.attribution[0]&&((p=p.attribution[0].containerSrc)&&p!==location.href&&(a[p]||(a[p]=[]),a[p].push(h),r+=h,s++)))}var l=t-e;return{num:n,time:i,tbt:o,totalTime:l,rate:100*i/l,iframeTime:r,iframeNum:s,iframeRate:100*r/l,iframeLongtasks:a}},U);function U(){var e=this;this.lts=[],this.observer=null,this.onceLeave=!1,V&&V.entryMap&&V.entryMap[Z]&&(this.lts=this.lts.concat(V.entryMap[Z]));try{this.observer=new PerformanceObserver(function(t){e.lts=e.lts.concat(t.getEntries())}),this.observer.observe({entryTypes:[Z]})}catch(t){}}function G(){this.constructor=D}function $(t){t=A.call(this,t)||this;return t.modules=[],t.register(new c),t.register(new L),t.register(new g),t.register(new T),t.register(new I),t.register(new M),t.register(new N),t.register(new F),t.register(new W),t.visibilitychangeCB=t.visibilitychangeCB.bind(t),t.load=t.load.bind(t),t.leave=t.leave.bind(t),"complete"===document.readyState?t.load():window.addEventListener("load",t.load),document.addEventListener("visibilitychange",t.visibilitychangeCB),window.addEventListener("beforeunload",t.leave,!1),window.addEventListener("unload",t.leave,!1),t}return i(D=$,J=A=t),D.prototype=null===J?Object.create(J):(G.prototype=J.prototype,new G),$.prototype.listenFID=function(t){this.invoke("listenFID",t)},$.prototype.listenLayoutShift=function(t){this.invoke("listenLayoutShift",t)},$.prototype.listenLCP=function(t){this.invoke("listenLCP",t)},$.prototype.listenFSPLongTask=function(t){this.invoke("listenFSPLongTask",t)},$.prototype.listenLCPLongTask=function(t){this.invoke("listenLCPLongTask",t)},$.prototype.listenLoadLongTask=function(t){this.invoke("listenLoadLongTask",t)},$.prototype.listenPageLongTask=function(t){this.invoke("listenPageLongTask",t)},$.prototype.listenMemory=function(t){this.invoke("listenMemory",t)},$.prototype.getNavigatorInfo=function(){return this.invoke("getNavigatorInfo")},$.prototype.listenResource=function(t,e){this.invoke("listenResource",t,e)},$.prototype.listenBigImg=function(t,e){this.invoke("listenBigImg",t,e)},$.prototype.listenHttpResource=function(t,e){this.invoke("listenHttpResource",t,e)},$.prototype.listenSlowResource=function(t,e){this.invoke("listenSlowResource",t,e)},$.prototype.listenTiming=function(t){this.invoke("listenTiming",t)},$.prototype.listenTTI=function(t,e){this.invoke("listenTTI",t,e)},$.prototype.invoke=function(t,e,i){for(var o=0;o<this.modules.length;o++){var n=this.modules[o];if("function"==typeof n[t])return n[t].apply(n,[e,i])}console.error("no method",t)},$.prototype.register=function(t){this.modules.push(t)},$.prototype.load=function(){for(var t=0;t<this.modules.length;t++){var e=this.modules[t];e.load&&e.load()}},$.prototype.leave=function(){for(var t=0;t<this.modules.length;t++){var e=this.modules[t];e.leave&&e.leave()}},$.prototype.destroy=function(){for(var t=0;t<this.modules.length;t++){var e=this.modules[t];e.destroy&&e.destroy()}document.removeEventListener("visibilitychange",this.visibilitychangeCB),window.removeEventListener("load",this.load),window.removeEventListener("beforeunload",this.leave),window.removeEventListener("unload",this.destroy)},$.prototype.visibilitychangeCB=function(){"hidden"===document.visibilityState&&this.leave()},$});
@@ -1,16 +1,145 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise */
16
+
17
+ var extendStatics = function(d, b) {
18
+ extendStatics = Object.setPrototypeOf ||
19
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21
+ return extendStatics(d, b);
22
+ };
23
+
24
+ function __extends(d, b) {
25
+ extendStatics(d, b);
26
+ function __() { this.constructor = d; }
27
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28
+ }
29
+
30
+ var __assign = function() {
31
+ __assign = Object.assign || function __assign(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
35
+ }
36
+ return t;
37
+ };
38
+ return __assign.apply(this, arguments);
39
+ };
40
+
41
+ /**
42
+ * @file utils
43
+ * @author kaivean
44
+ */
45
+ function assign() {
46
+ var args = [];
47
+ for (var _i = 0; _i < arguments.length; _i++) {
48
+ args[_i] = arguments[_i];
49
+ }
50
+ var __assign = Object.assign || function __assign(t) {
51
+ for (var s = void 0, i = 1, n = arguments.length; i < n; i++) {
52
+ // eslint-disable-next-line prefer-rest-params
53
+ s = arguments[i];
54
+ for (var p in s) {
55
+ if (Object.prototype.hasOwnProperty.call(s, p)) {
56
+ t[p] = s[p];
57
+ }
58
+ }
59
+ }
60
+ return t;
61
+ };
62
+ return __assign.apply(this, args);
63
+ }
64
+ function getUrlInfoFromURL(url) {
65
+ if (URL) {
66
+ var obj = new URL(url);
67
+ if (obj.host !== undefined) {
68
+ return {
69
+ protocol: obj.protocol,
70
+ host: obj.host,
71
+ pathname: obj.pathname,
72
+ ext: '',
73
+ };
74
+ }
75
+ }
76
+ return;
77
+ }
78
+ function getUrlInfo(url) {
79
+ var info = getUrlInfoFromURL(url);
80
+ if (!info) {
81
+ var parser = document.createElement('a');
82
+ parser.href = url;
83
+ info = {
84
+ protocol: parser.protocol,
85
+ host: parser.host || location.host,
86
+ pathname: parser.pathname,
87
+ ext: '',
88
+ };
89
+ }
90
+ var split = info.pathname.split('.');
91
+ info.ext = split[split.length - 1];
92
+ return info;
93
+ }
94
+ function f$1(n) {
95
+ return +n.toFixed(1);
96
+ }
97
+ function getResTiming(t) {
98
+ return {
99
+ wait: f$1(t.domainLookupStart - (t.navigationStart || t.fetchStart || t.startTime)),
100
+ dns: f$1(t.domainLookupEnd - t.domainLookupStart),
101
+ connect: f$1(t.connectEnd - t.connectStart),
102
+ req: f$1(t.responseStart - t.requestStart),
103
+ res: f$1(t.responseEnd - t.responseStart),
104
+ };
105
+ }
106
+ function getxpath(el) {
107
+ if (!el) {
108
+ return { xpath: '' };
109
+ }
110
+ var xpath = [];
111
+ while (el && el.nodeType === 1 && el !== el.parentNode) {
112
+ var t = el.tagName.toLowerCase();
113
+ if (el.getAttribute('id')) {
114
+ t += '[#' + el.getAttribute('id') + ']';
115
+ }
116
+ else if (el.classList && el.classList.length) {
117
+ t += '[.' + el.classList[el.classList.length - 1] + ']';
118
+ }
119
+ xpath.push(t);
120
+ if (el === document.body) {
121
+ break;
122
+ }
123
+ el = el.parentNode; // 修复缺陷检查
124
+ }
125
+ return {
126
+ xpath: xpath.join('<'),
127
+ };
128
+ }
129
+
1
130
  /**
2
131
  * @file SpyClient
3
132
  * @author kaivean
4
133
  */
5
- const defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
6
- const isIos = /(iPhone|iPod|iPad)/.test(navigator.userAgent);
134
+ var defaultLogServer = 'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/mwb2.gif?';
135
+ var isIos = /(iPhone|iPod|iPad)/.test(navigator.userAgent);
7
136
  function err(msg) {
8
- console.error(`[SpyClient_log]${msg}`);
137
+ console.error("[SpyClient_log]" + msg);
9
138
  // throw new Error(msg);
10
139
  }
11
140
  function stringify(obj) {
12
- return Object.keys(obj).map((key) => {
13
- let value = obj[key];
141
+ return Object.keys(obj).map(function (key) {
142
+ var value = obj[key];
14
143
  if (typeof value === 'undefined') {
15
144
  value = '';
16
145
  }
@@ -20,8 +149,8 @@ function stringify(obj) {
20
149
  return encodeURIComponent(key) + '=' + encodeURIComponent(value);
21
150
  }).join('&');
22
151
  }
23
- class SpyClient {
24
- constructor(option) {
152
+ var SpyClient$1 = /** @class */ (function () {
153
+ function SpyClient(option) {
25
154
  this.sample = {};
26
155
  this.markCache = {};
27
156
  if (!option.pid) {
@@ -35,7 +164,7 @@ class SpyClient {
35
164
  logServer: option.logServer || defaultLogServer,
36
165
  };
37
166
  }
38
- send(query) {
167
+ SpyClient.prototype.send = function (query) {
39
168
  if (!this.check(query)) {
40
169
  return;
41
170
  }
@@ -48,14 +177,14 @@ class SpyClient {
48
177
  else if (typeof this.option.sample === 'number' && Math.random() > this.option.sample) { // 否则,用全局抽样
49
178
  return;
50
179
  }
51
- query = Object.assign({
180
+ query = assign({
52
181
  pid: this.option.pid,
53
182
  lid: this.option.lid,
54
183
  ts: Date.now(),
55
184
  group: 'common',
56
185
  }, query);
57
186
  delete query.sample;
58
- const url = this.option.logServer + stringify(query);
187
+ var url = this.option.logServer + stringify(query);
59
188
  // 目前服务器端支持sendBeacon的post请求,可以优先采用,该api可以降低打点丢失率
60
189
  // 但是ios有些问题:在webkit浏览内核环境下,beacon requests的请求方式存在证书验证的bug.
61
190
  // 修复说明在如下链接中:https://bugs.webkit.org/show_bug.cgi?id=193508
@@ -65,12 +194,12 @@ class SpyClient {
65
194
  && navigator.sendBeacon(url))) {
66
195
  (new Image()).src = url;
67
196
  }
68
- }
69
- check(query) {
197
+ };
198
+ SpyClient.prototype.check = function (query) {
70
199
  if (!this.option.check) {
71
200
  return true;
72
201
  }
73
- const types = ['perf', 'except', 'dist', 'count'];
202
+ var types = ['perf', 'except', 'dist', 'count'];
74
203
  if (types.indexOf(query.type) === -1) {
75
204
  err('type only is one of ' + types.join(', '));
76
205
  return false;
@@ -79,7 +208,7 @@ class SpyClient {
79
208
  err('group length execeeds 30');
80
209
  return false;
81
210
  }
82
- const simpleReg = /^[a-zA-Z0-9-_]{0,30}$/;
211
+ var simpleReg = /^[a-zA-Z0-9-_]{0,30}$/;
83
212
  if (query.type === 'except') {
84
213
  if (!(typeof query.info.msg === 'string' && query.info.msg.length)) {
85
214
  err('info.msg field must be not empty and is String');
@@ -87,37 +216,39 @@ class SpyClient {
87
216
  }
88
217
  }
89
218
  else {
90
- for (const infoKey of Object.keys(query.info)) {
219
+ for (var _i = 0, _a = Object.keys(query.info); _i < _a.length; _i++) {
220
+ var infoKey = _a[_i];
91
221
  if (!simpleReg.test(infoKey)) {
92
- err(`info.${infoKey} is unexpected. `
222
+ err("info." + infoKey + " is unexpected. "
93
223
  + 'Length must be not more than 30. '
94
224
  + 'Supported chars: a-zA-Z0-9-_');
95
225
  return false;
96
226
  }
97
- const infoVal = query.info[infoKey];
227
+ var infoVal = query.info[infoKey];
98
228
  if (query.type === 'dist') {
99
229
  if (infoVal.length > 30) {
100
- err(`info.${infoKey} value length execeeds 30 when type == 'dist'`);
230
+ err("info." + infoKey + " value length execeeds 30 when type == 'dist'");
101
231
  return false;
102
232
  }
103
233
  }
104
234
  else if (typeof infoVal !== 'number') {
105
- err(`info.${infoKey} value must be number`);
235
+ err("info." + infoKey + " value must be number");
106
236
  return false;
107
237
  }
108
238
  }
109
239
  }
110
240
  if (query.dim) {
111
- for (const dimKey of Object.keys(query.dim)) {
241
+ for (var _b = 0, _c = Object.keys(query.dim); _b < _c.length; _b++) {
242
+ var dimKey = _c[_b];
112
243
  if (!simpleReg.test(dimKey)) {
113
- err(`dim key [${dimKey}] is unexpected. `
244
+ err("dim key [" + dimKey + "] is unexpected. "
114
245
  + 'Length must be not more than 30. '
115
246
  + 'Supported chars: a-zA-Z0-9-_');
116
247
  return false;
117
248
  }
118
- const dimVal = query.dim[dimKey];
249
+ var dimVal = query.dim[dimKey];
119
250
  if (!/^[a-zA-Z0-9\-_\*\.\s\/#\+@\&\u4e00-\u9fa5]{0,30}$/.test(dimVal)) {
120
- err(`dim.${dimKey} value [${dimVal}] is unexpected. `
251
+ err("dim." + dimKey + " value [" + dimVal + "] is unexpected. "
121
252
  + 'Length must be not more than 30. '
122
253
  + 'Supported chars: a-zA-Z0-9-_*. /#+@& and Chinese');
123
254
  return false;
@@ -125,160 +256,165 @@ class SpyClient {
125
256
  }
126
257
  }
127
258
  return true;
128
- }
259
+ };
129
260
  /**
130
261
  *
131
262
  * @param option 配置
132
263
  */
133
- sendPerf(option) {
134
- this.send(Object.assign({
264
+ SpyClient.prototype.sendPerf = function (option) {
265
+ this.send(assign({
135
266
  type: 'perf',
136
267
  }, option));
137
- }
268
+ };
138
269
  /**
139
270
  *
140
271
  * @param option 错误配置项
141
272
  */
142
- sendExcept(option) {
143
- this.send(Object.assign({
273
+ SpyClient.prototype.sendExcept = function (option) {
274
+ this.send(assign({
144
275
  type: 'except',
145
276
  }, option));
146
- }
277
+ };
147
278
  /**
148
279
  *
149
280
  * @param option 配置
150
281
  */
151
- sendDist(option) {
152
- this.send(Object.assign({
282
+ SpyClient.prototype.sendDist = function (option) {
283
+ this.send(assign({
153
284
  type: 'dist',
154
285
  }, option));
155
- }
286
+ };
156
287
  /**
157
288
  *
158
289
  * @param option 配置
159
290
  */
160
- sendCount(option) {
161
- this.send(Object.assign({
291
+ SpyClient.prototype.sendCount = function (option) {
292
+ this.send(assign({
162
293
  type: 'count',
163
294
  }, option));
164
- }
295
+ };
165
296
  /**
166
297
  *
167
298
  * @param e 错误实例
168
299
  * @param option 错误配置项
169
300
  */
170
- sendExceptForError(e, option) {
171
- const newOpt = Object.assign({}, option);
172
- newOpt.info = Object.assign({}, option.info || {}, {
301
+ SpyClient.prototype.sendExceptForError = function (e, option) {
302
+ var newOpt = assign({}, option);
303
+ newOpt.info = assign({}, option.info || {}, {
173
304
  msg: e.message,
174
305
  stack: e.stack,
175
306
  });
176
307
  this.sendExcept(newOpt);
177
- }
178
- startMark(sign) {
308
+ };
309
+ SpyClient.prototype.startMark = function (sign) {
179
310
  this.markCache[sign] = {
180
311
  start: Date.now(),
181
312
  };
182
- }
183
- endMark(sign) {
313
+ };
314
+ SpyClient.prototype.endMark = function (sign) {
184
315
  if (this.markCache[sign]) {
185
316
  this.markCache[sign].total = Date.now() - this.markCache[sign].start;
186
317
  return this.markCache[sign].total;
187
318
  }
188
319
  return 0;
189
- }
190
- clearMark(sign) {
320
+ };
321
+ SpyClient.prototype.clearMark = function (sign) {
191
322
  if (this.markCache[sign]) {
192
323
  delete this.markCache[sign];
193
324
  }
194
- }
195
- getAllMark() {
196
- const ret = {};
197
- for (const sign of Object.keys(this.markCache)) {
325
+ };
326
+ SpyClient.prototype.getAllMark = function () {
327
+ var ret = {};
328
+ for (var _i = 0, _a = Object.keys(this.markCache); _i < _a.length; _i++) {
329
+ var sign = _a[_i];
198
330
  ret[sign] = this.markCache[sign].total;
199
331
  }
200
332
  return ret;
201
- }
202
- clearAllMark() {
333
+ };
334
+ SpyClient.prototype.clearAllMark = function () {
203
335
  this.markCache = {};
204
- }
205
- }
336
+ };
337
+ return SpyClient;
338
+ }());
206
339
 
207
340
  /**
208
341
  * @file FID
209
342
  * @author kaivean
210
343
  */
211
- const spyclient = window.__spyHead;
212
- const entryType = 'first-input';
213
- class FID {
214
- constructor() {
344
+ var spyclient$3 = window.__spyHead;
345
+ var entryType$3 = 'first-input';
346
+ var FID = /** @class */ (function () {
347
+ function FID() {
348
+ var _this = this;
215
349
  this.observer = null;
216
350
  if (!window.PerformanceObserver) {
217
351
  return;
218
352
  }
219
- if (spyclient && spyclient.entryMap && spyclient.entryMap[entryType]) {
220
- this.handle(spyclient.entryMap[entryType]);
353
+ if (spyclient$3 && spyclient$3.entryMap && spyclient$3.entryMap[entryType$3]) {
354
+ this.handle(spyclient$3.entryMap[entryType$3]);
221
355
  }
222
356
  try {
223
- this.observer = new PerformanceObserver(list => {
224
- this.handle(list.getEntries());
357
+ this.observer = new PerformanceObserver(function (list) {
358
+ _this.handle(list.getEntries());
225
359
  });
226
- this.observer.observe({ entryTypes: [entryType] });
360
+ this.observer.observe({ entryTypes: [entryType$3] });
227
361
  }
228
362
  catch (e) { }
229
363
  }
230
- listenFID(cb) {
364
+ FID.prototype.listenFID = function (cb) {
231
365
  this.cb = cb;
232
366
  this.callCB();
233
- }
234
- callCB() {
367
+ };
368
+ FID.prototype.callCB = function () {
235
369
  if (this.finalValue !== undefined && this.cb) {
236
370
  this.cb({ fid: this.finalValue });
237
371
  }
238
- }
239
- destroy() {
372
+ };
373
+ FID.prototype.destroy = function () {
240
374
  this.observer && this.observer.disconnect();
241
375
  this.observer = null;
242
- }
243
- handle(entries) {
244
- const lastEntry = entries.pop();
376
+ };
377
+ FID.prototype.handle = function (entries) {
378
+ var lastEntry = entries.pop();
245
379
  if (lastEntry) {
246
380
  this.finalValue = lastEntry.duration;
247
381
  this.callCB();
248
382
  this.destroy();
249
383
  }
250
- }
251
- }
384
+ };
385
+ return FID;
386
+ }());
252
387
 
253
388
  /**
254
389
  * @file LayoutShift
255
390
  * @author kaivean
256
391
  */
257
- const spyclient$1 = window.__spyHead;
258
- const entryType$1 = 'layout-shift';
259
- class LayoutShift {
260
- constructor() {
392
+ var spyclient$2 = window.__spyHead;
393
+ var entryType$2 = 'layout-shift';
394
+ var LayoutShift = /** @class */ (function () {
395
+ function LayoutShift() {
396
+ var _this = this;
261
397
  this.observer = null;
262
398
  this.onceLeave = false;
263
399
  if (!window.PerformanceObserver) {
264
400
  return;
265
401
  }
266
402
  // 先消费之前的
267
- if (spyclient$1 && spyclient$1.entryMap && spyclient$1.entryMap[entryType$1]) {
268
- this.handle(spyclient$1.entryMap[entryType$1]);
403
+ if (spyclient$2 && spyclient$2.entryMap && spyclient$2.entryMap[entryType$2]) {
404
+ this.handle(spyclient$2.entryMap[entryType$2]);
269
405
  }
270
406
  try {
271
- this.observer = new PerformanceObserver(list => {
272
- this.handle(list.getEntries());
407
+ this.observer = new PerformanceObserver(function (list) {
408
+ _this.handle(list.getEntries());
273
409
  });
274
- this.observer.observe({ entryTypes: [entryType$1] });
410
+ this.observer.observe({ entryTypes: [entryType$2] });
275
411
  }
276
412
  catch (e) { }
277
413
  }
278
- listenLayoutShift(cb) {
414
+ LayoutShift.prototype.listenLayoutShift = function (cb) {
279
415
  this.cb = cb;
280
- }
281
- leave() {
416
+ };
417
+ LayoutShift.prototype.leave = function () {
282
418
  if (!this.onceLeave) {
283
419
  this.onceLeave = true;
284
420
  this.observer && this.observer.takeRecords && this.observer.takeRecords();
@@ -286,31 +422,33 @@ class LayoutShift {
286
422
  this.callCB();
287
423
  this.destroy();
288
424
  }
289
- }
290
- callCB() {
425
+ };
426
+ LayoutShift.prototype.callCB = function () {
291
427
  if (this.finalValue !== undefined && this.cb) {
292
428
  this.cb({ layoutShift: this.finalValue });
293
429
  }
294
- }
295
- destroy() {
430
+ };
431
+ LayoutShift.prototype.destroy = function () {
296
432
  this.observer && this.observer.disconnect();
297
433
  this.observer = null;
298
- }
299
- handle(entries) {
300
- entries.map(entry => {
434
+ };
435
+ LayoutShift.prototype.handle = function (entries) {
436
+ var _this = this;
437
+ entries.map(function (entry) {
301
438
  // hadRecentInput 如果过去500毫秒内有用户输入,则返回 true, 刚进入页面内500ms,不会认为是layoutShift
302
439
  if (!entry.hadRecentInput) {
303
- this.value = (this.value || 0) + (entry.value || 0);
440
+ _this.value = (_this.value || 0) + (entry.value || 0);
304
441
  }
305
442
  });
306
- }
307
- }
443
+ };
444
+ return LayoutShift;
445
+ }());
308
446
 
309
447
  /**
310
448
  * @file 简单的公共数据模块,内部模块之间数据交换
311
449
  * @author kaivean
312
450
  */
313
- const data = {};
451
+ var data = {};
314
452
  function setData(key, value) {
315
453
  data[key] = value;
316
454
  }
@@ -322,58 +460,61 @@ function getData(key) {
322
460
  * @file LCP
323
461
  * @author kaivean
324
462
  */
325
- const spyclient$2 = window.__spyHead;
326
- const entryType$2 = 'largest-contentful-paint';
327
- class LCP {
328
- constructor() {
463
+ var spyclient$1 = window.__spyHead;
464
+ var entryType$1 = 'largest-contentful-paint';
465
+ var LCP = /** @class */ (function () {
466
+ function LCP() {
467
+ var _this = this;
329
468
  this.observer = null;
330
469
  if (!window.PerformanceObserver) {
331
470
  return;
332
471
  }
333
- if (spyclient$2 && spyclient$2.entryMap && spyclient$2.entryMap[entryType$2]) {
334
- this.handle(spyclient$2.entryMap[entryType$2]);
472
+ if (spyclient$1 && spyclient$1.entryMap && spyclient$1.entryMap[entryType$1]) {
473
+ this.handle(spyclient$1.entryMap[entryType$1]);
335
474
  }
336
475
  try {
337
476
  // 仅在 img,image,svg,video,css url, block element with text nodes
338
- this.observer = new PerformanceObserver(list => {
339
- this.handle(list.getEntries());
477
+ this.observer = new PerformanceObserver(function (list) {
478
+ _this.handle(list.getEntries());
340
479
  });
341
- this.observer.observe({ entryTypes: [entryType$2] });
480
+ this.observer.observe({ entryTypes: [entryType$1] });
342
481
  }
343
482
  catch (e) { }
344
483
  }
345
- listenLCP(cb) {
484
+ LCP.prototype.listenLCP = function (cb) {
346
485
  this.cb = cb;
347
486
  this.callCB();
348
- }
349
- callCB() {
487
+ };
488
+ LCP.prototype.callCB = function () {
350
489
  if (this.finalValue && this.cb) {
351
490
  this.cb({ lcp: this.finalValue });
352
491
  }
353
- }
354
- load() {
492
+ };
493
+ LCP.prototype.load = function () {
355
494
  this.observer && this.observer.takeRecords && this.observer.takeRecords();
356
495
  this.finalValue = this.value;
357
496
  setData('lcp', this.value);
358
497
  this.callCB();
359
498
  this.destroy();
360
- }
361
- destroy() {
499
+ };
500
+ LCP.prototype.destroy = function () {
362
501
  this.observer && this.observer.disconnect();
363
502
  this.observer = null;
364
- }
365
- handle(entries) {
366
- entries.map(entry => {
367
- this.value = entry.renderTime || entry.loadTime;
503
+ };
504
+ LCP.prototype.handle = function (entries) {
505
+ var _this = this;
506
+ entries.map(function (entry) {
507
+ _this.value = entry.renderTime || entry.loadTime;
368
508
  });
369
- }
370
- }
509
+ };
510
+ return LCP;
511
+ }());
371
512
 
372
513
  function filterExcludeLogGifs(entry) {
373
514
  return entry.name.indexOf('.gif?') < 0;
374
515
  }
375
- class TTI {
376
- constructor() {
516
+ var TTI = /** @class */ (function () {
517
+ function TTI() {
377
518
  this.lastLongTask = 0;
378
519
  this.observer = null;
379
520
  this.interval = 5000;
@@ -381,10 +522,10 @@ class TTI {
381
522
  this.observerCallback = this.observerCallback.bind(this);
382
523
  this.ttiCheck = this.ttiCheck.bind(this);
383
524
  }
384
- check() {
525
+ TTI.prototype.check = function () {
385
526
  return window.PerformanceObserver && performance && performance.timing && performance.timing.navigationStart;
386
- }
387
- listenTTI(cb, option) {
527
+ };
528
+ TTI.prototype.listenTTI = function (cb, option) {
388
529
  if (!this.check()) {
389
530
  return;
390
531
  }
@@ -398,24 +539,24 @@ class TTI {
398
539
  if (option.filterRequest) {
399
540
  this.filterRequest = option.filterRequest;
400
541
  }
401
- }
402
- load() {
542
+ };
543
+ TTI.prototype.load = function () {
403
544
  if (!this.check()) {
404
545
  return;
405
546
  }
406
547
  // 每 5 秒检查一次是否符合TTI要求
407
548
  this.ttiTimer = setInterval(this.ttiCheck, this.interval);
408
- }
409
- ttiCheck() {
549
+ };
550
+ TTI.prototype.ttiCheck = function () {
410
551
  if (!this.cb) {
411
552
  return;
412
553
  }
413
- const now = performance.now();
554
+ var now = performance.now();
414
555
  if (now - this.lastLongTask < this.interval) {
415
556
  // debug('tti 没有达成条件,上次 longTask 离现在差' + (now - this.lastLongTask) + 'ms');
416
557
  return;
417
558
  }
418
- const networkSilence = this.getNetworkSilenceAt();
559
+ var networkSilence = this.getNetworkSilenceAt();
419
560
  if (networkSilence === false) {
420
561
  // debug('tti 没有达成条件,网络没有静默');
421
562
  return;
@@ -426,7 +567,7 @@ class TTI {
426
567
  }
427
568
  // debug('tti 达成条件');
428
569
  clearTimeout(this.ttiTimer);
429
- let tti = this.lastLongTask;
570
+ var tti = this.lastLongTask;
430
571
  // 没有longtask,就用dom ready时间作为tti,默认是认为dom ready已经绑定好时间,可以交换了
431
572
  if (!tti) {
432
573
  tti = performance.timing.domContentLoadedEventEnd - performance.timing.navigationStart;
@@ -434,17 +575,17 @@ class TTI {
434
575
  // 停止 long task 获取
435
576
  this.stopObserveLongTask();
436
577
  this.cb({
437
- tti,
578
+ tti: tti,
438
579
  });
439
- }
440
- observerCallback(list) {
441
- const entries = list.getEntries();
442
- const lastEntry = entries[entries.length - 1];
580
+ };
581
+ TTI.prototype.observerCallback = function (list) {
582
+ var entries = list.getEntries();
583
+ var lastEntry = entries[entries.length - 1];
443
584
  // debug('long task (no more than ' + lastEntry.duration + 'ms) detected');
444
585
  // 最新的longTask完成时间
445
586
  this.lastLongTask = lastEntry.startTime + lastEntry.duration;
446
- }
447
- stopObserveLongTask() {
587
+ };
588
+ TTI.prototype.stopObserveLongTask = function () {
448
589
  if (this.observer) {
449
590
  this.observer.disconnect();
450
591
  this.observer = null;
@@ -452,13 +593,14 @@ class TTI {
452
593
  if (this.stopLongTaskTimeoutId) {
453
594
  clearTimeout(this.stopLongTaskTimeoutId);
454
595
  }
455
- }
456
- getNetworkSilenceAt() {
596
+ };
597
+ TTI.prototype.getNetworkSilenceAt = function () {
457
598
  // const now = performance.now();
458
- const resources = performance.getEntriesByType('resource')
599
+ var resources = performance.getEntriesByType('resource')
459
600
  .filter(this.filterRequest);
460
- let lastResourceEnd = 0;
461
- for (const item of resources) {
601
+ var lastResourceEnd = 0;
602
+ for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
603
+ var item = resources_1[_i];
462
604
  // 还没有responseEnd字段,说明网络请求还未结束
463
605
  if (!item.responseEnd) {
464
606
  return false;
@@ -469,8 +611,8 @@ class TTI {
469
611
  }
470
612
  }
471
613
  return lastResourceEnd;
472
- }
473
- observeLongtask(timeout) {
614
+ };
615
+ TTI.prototype.observeLongtask = function (timeout) {
474
616
  this.stopObserveLongTask();
475
617
  try {
476
618
  this.observer = new PerformanceObserver(this.observerCallback);
@@ -480,31 +622,35 @@ class TTI {
480
622
  this.stopLongTaskTimeoutId = setTimeout(this.stopObserveLongTask, timeout);
481
623
  }
482
624
  catch (e) { }
483
- }
484
- }
625
+ };
626
+ return TTI;
627
+ }());
485
628
 
486
629
  /**
487
630
  * @file LCP
488
631
  * @author kaivean
489
632
  */
490
- class Timing {
633
+ var Timing = /** @class */ (function () {
634
+ function Timing() {
635
+ }
491
636
  // constructor() {}
492
- listenTiming(cb) {
637
+ Timing.prototype.listenTiming = function (cb) {
493
638
  if (!window.performance || !window.performance.timing) {
494
639
  // debug('no performance.timing api');
495
640
  return;
496
641
  }
497
642
  this.cb = cb;
498
- }
499
- load() {
500
- setTimeout(() => {
501
- this.cb && this.cb(this.getMetric());
643
+ };
644
+ Timing.prototype.load = function () {
645
+ var _this = this;
646
+ setTimeout(function () {
647
+ _this.cb && _this.cb(_this.getMetric());
502
648
  }, 500);
503
- }
504
- getMetric() {
505
- const metric = {};
506
- const timing = window.performance.timing;
507
- const startTime = timing.navigationStart;
649
+ };
650
+ Timing.prototype.getMetric = function () {
651
+ var metric = {};
652
+ var timing = window.performance.timing;
653
+ var startTime = timing.navigationStart;
508
654
  // 基础信息
509
655
  metric.dns = timing.domainLookupEnd - timing.domainLookupStart;
510
656
  metric.tcp = timing.connectEnd - timing.connectStart;
@@ -522,10 +668,11 @@ class Timing {
522
668
  metric.load = timing.loadEventEnd - startTime;
523
669
  // 浏览器首次绘制与首次内容绘制, ios低版本无getEntriesByType api
524
670
  if (performance.getEntriesByType) {
525
- const paintEntries = performance.getEntriesByType('paint');
671
+ var paintEntries = performance.getEntriesByType('paint');
526
672
  if (paintEntries && paintEntries.length) {
527
- paintEntries.forEach(({ name, duration, startTime }) => {
528
- const time = Math.ceil(duration + startTime);
673
+ paintEntries.forEach(function (_a) {
674
+ var name = _a.name, duration = _a.duration, startTime = _a.startTime;
675
+ var time = Math.ceil(duration + startTime);
529
676
  if (name === 'first-paint') {
530
677
  metric.fp = time;
531
678
  }
@@ -543,8 +690,9 @@ class Timing {
543
690
  metric.t7FirstScreen = timing.domFirstScreenPaint - startTime;
544
691
  }
545
692
  return metric;
546
- }
547
- }
693
+ };
694
+ return Timing;
695
+ }());
548
696
 
549
697
  var ResType;
550
698
  (function (ResType) {
@@ -554,7 +702,6 @@ var ResType;
554
702
  ResType["FONT"] = "font";
555
703
  })(ResType || (ResType = {}));
556
704
 
557
- // import Debug from 'debug';
558
705
  // 字体
559
706
  // svg使用场景比较灵活,可能作为一种字体格式,也可能当做图片使用
560
707
  // 但因woff在所有现代浏览器中都支持,在css中使用iconfont时
@@ -568,210 +715,292 @@ var FontsTypes;
568
715
  })(FontsTypes || (FontsTypes = {}));
569
716
  // 忽略图片
570
717
  // 下述图片路径往往是用来进行日志统计,不是正常图片
571
- var IgnoreImgPath;
572
- (function (IgnoreImgPath) {
573
- IgnoreImgPath[IgnoreImgPath["/mwb2.gif"] = 0] = "/mwb2.gif";
574
- })(IgnoreImgPath || (IgnoreImgPath = {}));
575
- function getxpath(el) {
576
- if (!el) {
577
- return { xpath: '' };
578
- }
579
- const xpath = [];
580
- while (el && el.nodeType === 1 && el !== el.parentNode) {
581
- xpath.push(el.tagName.toLowerCase());
582
- if (el === document.body) {
583
- break;
718
+ var ignoreDefaultPaths = [
719
+ '/mwb2.gif',
720
+ ];
721
+ function ignorePath(url, paths) {
722
+ for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
723
+ var path = paths_1[_i];
724
+ if (url.indexOf(path) > -1) {
725
+ return true;
584
726
  }
585
- el = el.parentNode; // 修复缺陷检查
586
727
  }
587
- return {
588
- xpath: xpath.join('<'),
589
- };
728
+ return false;
590
729
  }
591
730
  function f(n) {
592
731
  return +n.toFixed(1);
593
732
  }
594
- class Resource {
595
- constructor() {
733
+ var Resource = /** @class */ (function () {
734
+ function Resource() {
735
+ this.trigger = 'load';
596
736
  this.jsList = [];
597
737
  this.cssList = [];
598
738
  this.imgList = [];
599
739
  this.fontList = [];
600
- this.bigImgList = [];
601
- this.httpResList = [];
602
- }
603
- check() {
740
+ this.hostList = {};
741
+ this.bigImgList = {};
742
+ this.httpResList = {};
743
+ this.slowList = {};
744
+ this.resOption = { ignorePaths: [], trigger: 'load' };
745
+ this.bigImgOption = { ignorePaths: [], maxSize: 150 * 1024, trigger: 'load' };
746
+ this.httpResOption = { ignorePaths: [], trigger: 'load' };
747
+ this.slowOption = { ignorePaths: [], trigger: 'load', threshold: 1000 };
748
+ }
749
+ Resource.prototype.check = function () {
604
750
  return performance && performance.getEntriesByType;
605
- }
606
- listenResource(cb) {
751
+ };
752
+ Resource.prototype.listenResource = function (cb, option) {
753
+ if (option === void 0) { option = {}; }
607
754
  if (!this.check()) {
608
755
  return;
609
756
  }
757
+ this.resOption = assign(this.resOption, option);
758
+ this.trigger = this.resOption.trigger;
610
759
  this.cb = cb;
611
- }
612
- listenBigImg(cb, maxSize = 150) {
760
+ };
761
+ Resource.prototype.listenBigImg = function (cb, option) {
762
+ if (option === void 0) { option = {}; }
613
763
  if (!this.check()) {
614
764
  return;
615
765
  }
616
- this.maxImgSize = maxSize * 1024;
766
+ this.bigImgOption = assign(this.bigImgOption, option);
767
+ this.trigger = this.bigImgOption.trigger;
617
768
  this.bigImgCB = cb;
618
- }
619
- listenHttpResource(cb) {
769
+ };
770
+ Resource.prototype.listenHttpResource = function (cb, option) {
771
+ if (option === void 0) { option = {}; }
620
772
  if (!this.check()) {
621
773
  return;
622
774
  }
775
+ this.httpResOption = assign(this.httpResOption, option);
776
+ this.trigger = this.httpResOption.trigger;
623
777
  this.httpResCB = cb;
624
- }
625
- load() {
778
+ };
779
+ Resource.prototype.listenSlowResource = function (cb, option) {
780
+ if (option === void 0) { option = {}; }
626
781
  if (!this.check()) {
627
782
  return;
628
783
  }
629
- setTimeout(() => {
630
- const metric = this.getMetric();
631
- if (metric) {
632
- this.cb && this.cb(metric);
633
- }
784
+ this.slowOption = assign(this.slowOption, option);
785
+ this.trigger = this.slowOption.trigger;
786
+ this.slowResCB = cb;
787
+ };
788
+ Resource.prototype.report = function () {
789
+ var _this = this;
790
+ var metricRes = this.getMetric();
791
+ if (metricRes) {
792
+ var metric = metricRes.metric, hostMetric = metricRes.hostMetric;
793
+ this.cb && this.cb(metric, hostMetric);
794
+ }
795
+ if (this.bigImgCB) {
634
796
  // 发送大图监控数据
635
- if (window.requestIdleCallback && this.bigImgList.length && this.bigImgCB) {
636
- window.requestIdleCallback(() => {
637
- for (const entry of this.bigImgList) {
638
- try {
639
- const img = document.body.querySelector('img[src="' + entry.name + '"]');
640
- this.bigImgCB({
641
- msg: entry.name,
642
- xpath: getxpath(img).xpath,
643
- });
644
- }
645
- catch (e) {
646
- console.error(e);
797
+ if (typeof window.requestIdleCallback === 'function' && Object.keys(this.bigImgList).length) {
798
+ window.requestIdleCallback(function () {
799
+ for (var _i = 0, _a = Object.keys(_this.bigImgList); _i < _a.length; _i++) {
800
+ var host = _a[_i];
801
+ for (var _b = 0, _c = _this.bigImgList[host]; _b < _c.length; _b++) {
802
+ var entry = _c[_b];
803
+ var timing = entry.timing;
804
+ var type = entry.type;
805
+ try {
806
+ var img = document.body.querySelector('img[src="' + timing.name + '"]');
807
+ _this.bigImgCB({
808
+ msg: timing.name,
809
+ dur: timing.duration,
810
+ xpath: getxpath(img).xpath,
811
+ host: host,
812
+ type: type,
813
+ });
814
+ }
815
+ catch (e) {
816
+ console.error(e);
817
+ }
647
818
  }
648
819
  }
649
820
  });
650
821
  }
822
+ }
823
+ if (this.httpResCB) {
651
824
  // 发送http资源监控数据
652
- if (window.requestIdleCallback && this.httpResList.length && this.httpResCB) {
653
- window.requestIdleCallback(() => {
654
- for (const entry of this.httpResList) {
655
- try {
656
- const img = document.body.querySelector('[src="' + entry.name + '"]');
657
- this.httpResCB({
658
- msg: entry.name,
659
- xpath: getxpath(img).xpath,
660
- });
825
+ if (typeof window.requestIdleCallback === 'function' && Object.keys(this.httpResList).length) {
826
+ window.requestIdleCallback(function () {
827
+ for (var _i = 0, _a = Object.keys(_this.httpResList); _i < _a.length; _i++) {
828
+ var host = _a[_i];
829
+ for (var _b = 0, _c = _this.httpResList[host]; _b < _c.length; _b++) {
830
+ var entry = _c[_b];
831
+ var timing = entry.timing;
832
+ var type = entry.type;
833
+ try {
834
+ var img = document.body.querySelector('[src="' + timing.name + '"]');
835
+ _this.httpResCB({
836
+ msg: timing.name,
837
+ dur: timing.duration,
838
+ xpath: getxpath(img).xpath,
839
+ host: host,
840
+ type: type,
841
+ });
842
+ }
843
+ catch (e) {
844
+ console.error(e);
845
+ }
661
846
  }
662
- catch (e) {
663
- console.error(e);
847
+ }
848
+ });
849
+ }
850
+ }
851
+ if (this.slowResCB) {
852
+ // 发送慢资源监控数据
853
+ if (typeof window.requestIdleCallback === 'function' && Object.keys(this.slowList).length) {
854
+ window.requestIdleCallback(function () {
855
+ for (var _i = 0, _a = Object.keys(_this.slowList); _i < _a.length; _i++) {
856
+ var host = _a[_i];
857
+ for (var _b = 0, _c = _this.slowList[host]; _b < _c.length; _b++) {
858
+ var entry = _c[_b];
859
+ var timing = entry.timing;
860
+ var type = entry.type;
861
+ try {
862
+ var img = document.body.querySelector('[src="' + timing.name + '"]');
863
+ var info = getResTiming(timing);
864
+ _this.slowResCB(__assign(__assign({}, info), { dur: timing.duration, msg: timing.name, xpath: getxpath(img).xpath, host: host, type: type }));
865
+ }
866
+ catch (e) {
867
+ console.error(e);
868
+ }
664
869
  }
665
870
  }
666
871
  });
667
872
  }
873
+ }
874
+ };
875
+ Resource.prototype.load = function () {
876
+ var _this = this;
877
+ if (this.trigger !== 'load') {
878
+ return;
879
+ }
880
+ if (!this.check()) {
881
+ return;
882
+ }
883
+ setTimeout(function () {
884
+ _this.report();
668
885
  }, 500);
669
- }
670
- getUrlObj(url) {
671
- try {
672
- const urlObj = new URL(url);
673
- const split = urlObj.pathname.split('.');
674
- urlObj.ext = split[split.length - 1];
675
- return urlObj;
886
+ };
887
+ Resource.prototype.leave = function () {
888
+ if (this.trigger !== 'leave') {
889
+ return;
676
890
  }
677
- catch (error) {
678
- return {};
891
+ this.report();
892
+ };
893
+ Resource.prototype.push = function (type, list, timing, urlInfo) {
894
+ if (!ignorePath(urlInfo.pathname, this.resOption.ignorePaths || [])) {
895
+ list.push(timing);
896
+ this.pushWithHost(type, this.hostList, timing, urlInfo);
897
+ }
898
+ if (!ignorePath(urlInfo.pathname, this.slowOption.ignorePaths || [])) {
899
+ if (timing.duration > this.slowOption.threshold) {
900
+ this.pushWithHost(type, this.slowList, timing, urlInfo);
901
+ }
679
902
  }
680
- }
681
- collectHttpResInHttps(timing) {
682
- if (location.protocol === 'https:' && timing.name.indexOf('http://') === 0) {
683
- this.httpResList.push(timing);
903
+ };
904
+ Resource.prototype.pushWithHost = function (type, list, timing, urlInfo) {
905
+ var host = urlInfo.host;
906
+ if (!list[host]) {
907
+ list[host] = [];
908
+ }
909
+ list[host].push({
910
+ timing: timing,
911
+ type: type,
912
+ });
913
+ };
914
+ Resource.prototype.collectHttpResInHttps = function (type, timing, urlInfo) {
915
+ if (location.protocol === 'https:'
916
+ && timing.name.indexOf('http://') === 0
917
+ && !ignorePath(urlInfo.pathname, this.httpResOption.ignorePaths || [])) {
918
+ this.pushWithHost(type, this.httpResList, timing, urlInfo);
684
919
  }
685
- }
920
+ };
686
921
  // 有些jsonp也属于script,这里只统计js后缀的文件
687
- addScript(timing) {
688
- const { ext } = this.getUrlObj(timing.name);
689
- if (ext === 'js') {
922
+ Resource.prototype.addScript = function (timing, urlInfo) {
923
+ if (urlInfo.ext === 'js') {
690
924
  if (timing.decodedBodySize !== 0) {
691
- this.jsList.push(timing);
925
+ this.push('js', this.jsList, timing, urlInfo);
692
926
  }
693
- this.collectHttpResInHttps(timing);
694
927
  }
695
- }
928
+ };
696
929
  // 暂时将css文件或代码块发起的请求归位三类(主要为这两类)
697
930
  // 1、加载字体
698
931
  // 2、加载背景图(图片不容易区分,有的没有明确后缀名)
699
932
  // 3、光标文件(后缀为.cur,这里也划分为图片)
700
933
  // (svg当做图片,前述已说明)
701
- addCss(timing) {
702
- const { ext } = this.getUrlObj(timing.name);
703
- if (ext && FontsTypes.hasOwnProperty(ext)) {
704
- this.fontList.push(timing);
934
+ Resource.prototype.addResFromCss = function (timing, urlInfo) {
935
+ if (urlInfo.ext && FontsTypes.hasOwnProperty(urlInfo.ext)) {
936
+ this.push('font', this.fontList, timing, urlInfo);
705
937
  }
706
938
  else {
707
- this.imgList.push(timing);
939
+ this.addImg(timing, urlInfo);
708
940
  }
709
- }
941
+ };
710
942
  // link一般加载css资源
711
943
  // 也可以通过preload可以预下载一些资源
712
944
  // 这里只统计js类型的preload
713
- addLink(timing) {
714
- const { ext } = this.getUrlObj(timing.name);
715
- if (ext === 'css') {
716
- this.cssList.push(timing);
945
+ Resource.prototype.addLink = function (timing, urlInfo) {
946
+ if (urlInfo.ext === 'css') {
947
+ this.push('css', this.cssList, timing, urlInfo);
717
948
  }
718
949
  // preload as script
719
- else if (ext === 'js') {
720
- this.jsList.push(timing);
950
+ else if (urlInfo.ext === 'js') {
951
+ this.push('js', this.jsList, timing, urlInfo);
721
952
  }
722
- }
723
- addImg(timing) {
724
- const { pathname } = this.getUrlObj(timing.name);
725
- if (!IgnoreImgPath.hasOwnProperty(pathname)) {
726
- this.imgList.push(timing);
727
- // 识别出处理webp的url
728
- if (timing.name.indexOf('fm=') > -1 && timing.name.indexOf('webpstat=1') > -1) {
729
- this.imgTnList.push(timing);
730
- }
731
- // 大于102400=100K的采集
732
- if (timing.decodedBodySize > this.maxImgSize) {
733
- this.bigImgList.push(timing);
734
- }
735
- this.collectHttpResInHttps(timing);
953
+ };
954
+ Resource.prototype.addImg = function (timing, urlInfo) {
955
+ this.push('img', this.imgList, timing, urlInfo);
956
+ // 大于指定size的图片采集
957
+ if (timing.decodedBodySize > (this.bigImgOption.maxSize || 0)
958
+ && !ignorePath(urlInfo.pathname, this.bigImgOption.ignorePaths || [])) {
959
+ this.pushWithHost('img', this.bigImgList, timing, urlInfo);
736
960
  }
737
- }
738
- handleTimings(list) {
739
- const len = list.length;
740
- for (let i = 0; i < len; i++) {
961
+ };
962
+ Resource.prototype.handleTimings = function (list) {
963
+ var len = list.length;
964
+ for (var i = 0; i < len; i++) {
965
+ var timing = list[i];
966
+ var urlInfo = getUrlInfo(timing.name);
967
+ if (ignorePath(urlInfo.pathname, ignoreDefaultPaths)) {
968
+ continue;
969
+ }
741
970
  switch (list[i].initiatorType) {
742
971
  case 'script':
743
- this.addScript(list[i]);
972
+ this.addScript(timing, urlInfo);
744
973
  break;
745
974
  case 'css':
746
- this.addCss(list[i]);
975
+ this.addResFromCss(timing, urlInfo);
747
976
  break;
748
977
  case 'img':
749
- this.addImg(list[i]);
978
+ this.addImg(timing, urlInfo);
750
979
  break;
751
980
  case 'link':
752
- this.addLink(list[i]);
981
+ this.addLink(timing, urlInfo);
753
982
  break;
754
983
  case 'audio':
755
- this.collectHttpResInHttps(list[i]);
984
+ this.collectHttpResInHttps('audio', timing, urlInfo);
756
985
  break;
757
986
  case 'video':
758
- this.collectHttpResInHttps(list[i]);
987
+ this.collectHttpResInHttps('video', timing, urlInfo);
759
988
  break;
760
989
  }
761
990
  }
762
- }
763
- getNumAndSize(type) {
764
- const obj = {};
765
- const num = type + 'Num';
766
- const size = type + 'Size';
767
- const transferSize = type + 'TransferSize';
768
- const cacheRate = type + 'CacheRate';
769
- const duration = type + 'Duration';
991
+ };
992
+ Resource.prototype.getNumAndSize = function (type, list) {
993
+ var obj = {};
994
+ var num = type + 'Num';
995
+ var size = type + 'Size';
996
+ var transferSize = type + 'TransferSize';
997
+ var cacheRate = type + 'CacheRate';
998
+ var duration = type + 'Duration';
770
999
  obj[num] = 0;
771
1000
  obj[size] = 0;
772
1001
  obj[transferSize] = 0;
773
- let totalDurationTime = 0;
774
- this[type + 'List'].forEach((timing) => {
1002
+ var totalDurationTime = 0;
1003
+ list.forEach(function (timing) {
775
1004
  obj[num]++;
776
1005
  obj[size] += (timing.decodedBodySize / 1024);
777
1006
  obj[transferSize] += (timing.transferSize / 1024);
@@ -779,22 +1008,22 @@ class Resource {
779
1008
  });
780
1009
  obj[duration] = f(obj[num] > 0 ? totalDurationTime / obj[num] : 0);
781
1010
  if (obj[size]) {
782
- const diff = obj[size] - obj[transferSize];
1011
+ var diff = obj[size] - obj[transferSize];
783
1012
  obj[cacheRate] = f(diff >= 0 ? 100 * diff / obj[size] : 0);
784
1013
  }
785
1014
  obj[size] = f(obj[size]);
786
1015
  obj[transferSize] = f(obj[transferSize]);
787
1016
  return obj;
788
- }
789
- getMetric() {
1017
+ };
1018
+ Resource.prototype.getMetric = function () {
790
1019
  // 原来代码
791
- const { 0: mainPageTiming } = performance.getEntriesByType('navigation');
792
- const resourceTimings = performance.getEntriesByType('resource');
1020
+ var mainPageTiming = performance.getEntriesByType('navigation')[0];
1021
+ var resourceTimings = performance.getEntriesByType('resource');
793
1022
  if (mainPageTiming && resourceTimings && resourceTimings.length) {
794
1023
  this.handleTimings(resourceTimings);
795
- let metric = Object.assign(Object.assign(Object.assign(Object.assign({}, this.getNumAndSize(ResType.JS)), this.getNumAndSize(ResType.CSS)), this.getNumAndSize(ResType.IMG)), this.getNumAndSize(ResType.FONT));
1024
+ var metric = __assign(__assign(__assign(__assign({}, this.getNumAndSize(ResType.JS, this.jsList)), this.getNumAndSize(ResType.CSS, this.cssList)), this.getNumAndSize(ResType.IMG, this.imgList)), this.getNumAndSize(ResType.FONT, this.fontList));
796
1025
  // 主文档大小
797
- const pageTiming = mainPageTiming;
1026
+ var pageTiming = mainPageTiming;
798
1027
  metric.docSize = f(pageTiming.decodedBodySize / 1024);
799
1028
  metric.docTransferSize = f(pageTiming.transferSize / 1024);
800
1029
  metric.headerSize = f((pageTiming.transferSize - pageTiming.encodedBodySize || 0) / 1024);
@@ -808,38 +1037,45 @@ class Resource {
808
1037
  + metric.cssTransferSize
809
1038
  + metric.imgTransferSize
810
1039
  + metric.fontTransferSize);
811
- return metric;
1040
+ var hostMetric = {};
1041
+ for (var _i = 0, _a = Object.keys(this.hostList); _i < _a.length; _i++) {
1042
+ var host = _a[_i];
1043
+ var timings = this.hostList[host].map(function (item) { return item.timing; });
1044
+ hostMetric[host] = this.getNumAndSize('host', timings);
1045
+ }
1046
+ return { metric: metric, hostMetric: hostMetric };
812
1047
  }
813
1048
  return;
814
- }
815
- }
1049
+ };
1050
+ return Resource;
1051
+ }());
816
1052
 
817
1053
  /**
818
1054
  * @file Memory
819
1055
  * @author kaivean
820
1056
  */
821
- let initMemory = null;
1057
+ var initMemory = null;
822
1058
  if (window.performance && window.performance.memory) {
823
1059
  initMemory = window.performance.memory;
824
1060
  }
825
- class Memory {
826
- constructor() {
1061
+ var Memory = /** @class */ (function () {
1062
+ function Memory() {
827
1063
  this.onceLeave = false;
828
1064
  }
829
1065
  // constructor() {}
830
- listenMemory(cb) {
1066
+ Memory.prototype.listenMemory = function (cb) {
831
1067
  this.cb = cb;
832
- }
833
- leave() {
1068
+ };
1069
+ Memory.prototype.leave = function () {
834
1070
  if (!this.onceLeave && initMemory) {
835
1071
  this.onceLeave = true;
836
- const curMemory = window.performance.memory;
1072
+ var curMemory = window.performance.memory;
837
1073
  // fix 早期浏览器的memroy api 值不更新的问题,将此情况排除
838
1074
  if (curMemory.usedJSHeapSize === initMemory.usedJSHeapSize
839
1075
  && curMemory.totalJSHeapSize === initMemory.totalJSHeapSize) {
840
1076
  return;
841
1077
  }
842
- const memory = window.performance.memory;
1078
+ var memory = window.performance.memory;
843
1079
  this.cb && this.cb({
844
1080
  usedJSHeapSize: memory.usedJSHeapSize / 1024,
845
1081
  totalJSHeapSize: memory.totalJSHeapSize / 1024,
@@ -847,25 +1083,28 @@ class Memory {
847
1083
  usedJSHeapRate: 100 * memory.usedJSHeapSize / memory.totalJSHeapSize,
848
1084
  });
849
1085
  }
850
- }
851
- }
1086
+ };
1087
+ return Memory;
1088
+ }());
852
1089
 
853
1090
  /**
854
1091
  * @file NavigatorInfo
855
1092
  * @author kaivean
856
1093
  */
857
- class NavigatorInfo {
1094
+ var NavigatorInfo = /** @class */ (function () {
1095
+ function NavigatorInfo() {
1096
+ }
858
1097
  // private cb: NavigatorInfoCB;
859
- getNavigatorInfo() {
1098
+ NavigatorInfo.prototype.getNavigatorInfo = function () {
860
1099
  // this.cb = cb;
861
- let ret = {};
862
- const dataConnection = navigator.connection;
1100
+ var ret = {};
1101
+ var dataConnection = navigator.connection;
863
1102
  if (typeof dataConnection === 'object') {
864
1103
  ret = {
865
1104
  downlink: dataConnection.downlink,
866
1105
  effectiveType: dataConnection.effectiveType,
867
1106
  rtt: dataConnection.rtt,
868
- saveData: !!dataConnection.saveData,
1107
+ saveData: !!dataConnection.saveData, // 数据节约模式
869
1108
  };
870
1109
  }
871
1110
  // 内存 G
@@ -877,68 +1116,71 @@ class NavigatorInfo {
877
1116
  ret.hardwareConcurrency = navigator.deviceMemory;
878
1117
  }
879
1118
  return ret;
880
- }
881
- load() { }
882
- }
1119
+ };
1120
+ NavigatorInfo.prototype.load = function () { };
1121
+ return NavigatorInfo;
1122
+ }());
883
1123
 
884
1124
  /**
885
1125
  * @file Longtask
886
1126
  * @author kaivean
887
1127
  */
888
- const spyclient$3 = window.__spyHead;
889
- const entryType$3 = 'longtask';
890
- class Longtask {
891
- constructor() {
1128
+ var spyclient = window.__spyHead;
1129
+ var entryType = 'longtask';
1130
+ var Longtask = /** @class */ (function () {
1131
+ function Longtask() {
1132
+ var _this = this;
892
1133
  this.lts = [];
893
1134
  this.observer = null;
894
1135
  this.onceLeave = false;
895
- if (spyclient$3 && spyclient$3.entryMap && spyclient$3.entryMap[entryType$3]) {
896
- this.lts = this.lts.concat(spyclient$3.entryMap[entryType$3]);
1136
+ if (spyclient && spyclient.entryMap && spyclient.entryMap[entryType]) {
1137
+ this.lts = this.lts.concat(spyclient.entryMap[entryType]);
897
1138
  }
898
1139
  try {
899
- this.observer = new PerformanceObserver(list => {
900
- this.lts = this.lts.concat(list.getEntries());
1140
+ this.observer = new PerformanceObserver(function (list) {
1141
+ _this.lts = _this.lts.concat(list.getEntries());
901
1142
  });
902
1143
  // buffered 兼容性太差
903
- this.observer.observe({ entryTypes: [entryType$3] });
1144
+ this.observer.observe({ entryTypes: [entryType] });
904
1145
  }
905
1146
  catch (e) { }
906
1147
  }
907
- check() {
1148
+ Longtask.prototype.check = function () {
908
1149
  return window.PerformanceObserver && performance && performance.timing && performance.timing.navigationStart;
909
- }
910
- listenFSPLongTask(cb) {
1150
+ };
1151
+ Longtask.prototype.listenFSPLongTask = function (cb) {
911
1152
  if (!this.check()) {
912
1153
  return;
913
1154
  }
914
1155
  this.fspCB = cb;
915
- }
916
- listenLCPLongTask(cb) {
1156
+ };
1157
+ Longtask.prototype.listenLCPLongTask = function (cb) {
917
1158
  if (!this.check()) {
918
1159
  return;
919
1160
  }
920
1161
  this.lcpCB = cb;
921
- }
922
- listenLoadLongTask(cb) {
1162
+ };
1163
+ Longtask.prototype.listenLoadLongTask = function (cb) {
923
1164
  if (!this.check()) {
924
1165
  return;
925
1166
  }
926
1167
  this.loadCB = cb;
927
- }
928
- listenPageLongTask(cb) {
1168
+ };
1169
+ Longtask.prototype.listenPageLongTask = function (cb) {
929
1170
  if (!this.check()) {
930
1171
  return;
931
1172
  }
932
1173
  this.pageCB = cb;
933
- }
934
- load() {
1174
+ };
1175
+ Longtask.prototype.load = function () {
1176
+ var _this = this;
935
1177
  if (!this.check()) {
936
1178
  return;
937
1179
  }
938
- const data = this.getStatData(Date.now());
1180
+ var data = this.getStatData(Date.now());
939
1181
  // lcp的值存入data模块也是在load期间,这里延迟一会再获取
940
- setTimeout(() => {
941
- this.loadCB && this.loadCB({
1182
+ setTimeout(function () {
1183
+ _this.loadCB && _this.loadCB({
942
1184
  loadLongtaskTime: data.time,
943
1185
  loadTBT: data.tbt,
944
1186
  loadTotalTime: data.totalTime,
@@ -946,31 +1188,31 @@ class Longtask {
946
1188
  loadLongtaskNum: data.num,
947
1189
  });
948
1190
  if (performance.timing && performance.timing.domFirstScreenPaint) {
949
- const data = this.getStatData(performance.timing.domFirstScreenPaint);
950
- this.fspCB && this.fspCB({
951
- fspLongtaskTime: data.time,
952
- fspTBT: data.tbt,
953
- fspTotalTime: data.totalTime,
954
- fspLongtaskRate: data.rate,
955
- fspLongtaskNum: data.num,
1191
+ var data_1 = _this.getStatData(performance.timing.domFirstScreenPaint);
1192
+ _this.fspCB && _this.fspCB({
1193
+ fspLongtaskTime: data_1.time,
1194
+ fspTBT: data_1.tbt,
1195
+ fspTotalTime: data_1.totalTime,
1196
+ fspLongtaskRate: data_1.rate,
1197
+ fspLongtaskNum: data_1.num,
956
1198
  });
957
1199
  }
958
1200
  if (getData('lcp')) {
959
- const data = this.getStatData(performance.timing.navigationStart + getData('lcp'));
960
- this.lcpCB && this.lcpCB({
961
- lcpLongtaskTime: data.time,
962
- lcpTBT: data.tbt,
963
- lcpTotalTime: data.totalTime,
964
- lcpLongtaskRate: data.rate,
965
- lcpLongtaskNum: data.num,
1201
+ var data_2 = _this.getStatData(performance.timing.navigationStart + getData('lcp'));
1202
+ _this.lcpCB && _this.lcpCB({
1203
+ lcpLongtaskTime: data_2.time,
1204
+ lcpTBT: data_2.tbt,
1205
+ lcpTotalTime: data_2.totalTime,
1206
+ lcpLongtaskRate: data_2.rate,
1207
+ lcpLongtaskNum: data_2.num,
966
1208
  });
967
1209
  }
968
1210
  }, 200);
969
- }
970
- leave() {
1211
+ };
1212
+ Longtask.prototype.leave = function () {
971
1213
  if (!this.onceLeave) {
972
1214
  this.onceLeave = true;
973
- const data = this.getStatData(Date.now());
1215
+ var data = this.getStatData(Date.now());
974
1216
  this.pageCB && this.pageCB({
975
1217
  pageLongtaskTime: data.time,
976
1218
  pageTBT: data.tbt,
@@ -982,32 +1224,32 @@ class Longtask {
982
1224
  pageIframeLongtaskNum: data.iframeNum,
983
1225
  });
984
1226
  }
985
- }
986
- destroy() {
1227
+ };
1228
+ Longtask.prototype.destroy = function () {
987
1229
  this.lts = [];
988
1230
  this.observer && this.observer.disconnect();
989
1231
  this.observer = null;
990
- }
991
- getStatData(finalTime) {
992
- const navigationStart = performance.timing.navigationStart;
993
- let time = 0;
1232
+ };
1233
+ Longtask.prototype.getStatData = function (finalTime) {
1234
+ var navigationStart = performance.timing.navigationStart;
1235
+ var time = 0;
994
1236
  // Total Blocking Time
995
- let tbt = 0;
996
- let num = 0;
997
- let iframeTime = 0;
998
- let iframeNum = 0;
999
- let iframeLongtasks = {};
1000
- for (let index = 0; index < this.lts.length; index++) {
1001
- const item = this.lts[index];
1002
- const duration = item.duration;
1003
- const end = navigationStart + item.startTime + duration;
1237
+ var tbt = 0;
1238
+ var num = 0;
1239
+ var iframeTime = 0;
1240
+ var iframeNum = 0;
1241
+ var iframeLongtasks = {};
1242
+ for (var index = 0; index < this.lts.length; index++) {
1243
+ var item = this.lts[index];
1244
+ var duration = item.duration;
1245
+ var end = navigationStart + item.startTime + duration;
1004
1246
  if (end < finalTime) {
1005
1247
  time += duration;
1006
1248
  // 多出来的时间
1007
1249
  tbt += (duration - 50 > 0 ? duration - 50 : 0);
1008
1250
  num++;
1009
1251
  if (item.attribution && item.attribution[0]) {
1010
- const containerSrc = item.attribution[0].containerSrc;
1252
+ var containerSrc = item.attribution[0].containerSrc;
1011
1253
  if (containerSrc && containerSrc !== location.href) {
1012
1254
  if (!iframeLongtasks[containerSrc]) {
1013
1255
  iframeLongtasks[containerSrc] = [];
@@ -1019,132 +1261,139 @@ class Longtask {
1019
1261
  }
1020
1262
  }
1021
1263
  }
1022
- const totalTime = finalTime - navigationStart;
1264
+ var totalTime = finalTime - navigationStart;
1023
1265
  return {
1024
- num,
1025
- time,
1026
- tbt,
1266
+ num: num,
1267
+ time: time,
1268
+ tbt: tbt,
1027
1269
  totalTime: totalTime,
1028
1270
  rate: 100 * time / totalTime,
1029
- iframeTime,
1030
- iframeNum,
1271
+ iframeTime: iframeTime,
1272
+ iframeNum: iframeNum,
1031
1273
  iframeRate: 100 * iframeTime / totalTime,
1032
- iframeLongtasks,
1274
+ iframeLongtasks: iframeLongtasks,
1033
1275
  };
1034
- }
1035
- }
1276
+ };
1277
+ return Longtask;
1278
+ }());
1036
1279
 
1037
1280
  /**
1038
1281
  * @file SpyClient
1039
1282
  * @author kaivean
1040
1283
  */
1041
- class SpyClient$1 extends SpyClient {
1042
- constructor(option) {
1043
- super(option);
1044
- this.modules = [];
1045
- this.register(new FID());
1046
- this.register(new LCP());
1047
- this.register(new LayoutShift());
1048
- this.register(new TTI());
1049
- this.register(new Timing());
1050
- this.register(new Resource());
1051
- this.register(new Memory());
1052
- this.register(new NavigatorInfo());
1053
- this.register(new Longtask());
1054
- this.visibilitychangeCB = this.visibilitychangeCB.bind(this);
1055
- this.load = this.load.bind(this);
1056
- this.leave = this.leave.bind(this);
1284
+ var SpyClient = /** @class */ (function (_super) {
1285
+ __extends(SpyClient, _super);
1286
+ function SpyClient(option) {
1287
+ var _this = _super.call(this, option) || this;
1288
+ _this.modules = [];
1289
+ _this.register(new FID());
1290
+ _this.register(new LCP());
1291
+ _this.register(new LayoutShift());
1292
+ _this.register(new TTI());
1293
+ _this.register(new Timing());
1294
+ _this.register(new Resource());
1295
+ _this.register(new Memory());
1296
+ _this.register(new NavigatorInfo());
1297
+ _this.register(new Longtask());
1298
+ _this.visibilitychangeCB = _this.visibilitychangeCB.bind(_this);
1299
+ _this.load = _this.load.bind(_this);
1300
+ _this.leave = _this.leave.bind(_this);
1057
1301
  if (document.readyState === 'complete') {
1058
- this.load();
1302
+ _this.load();
1059
1303
  }
1060
1304
  else {
1061
- window.addEventListener('load', this.load);
1305
+ window.addEventListener('load', _this.load);
1062
1306
  }
1063
- document.addEventListener('visibilitychange', this.visibilitychangeCB);
1064
- window.addEventListener('beforeunload', this.leave, false);
1065
- window.addEventListener('unload', this.leave, false);
1307
+ document.addEventListener('visibilitychange', _this.visibilitychangeCB);
1308
+ window.addEventListener('beforeunload', _this.leave, false);
1309
+ window.addEventListener('unload', _this.leave, false);
1310
+ return _this;
1066
1311
  }
1067
- listenFID(cb) {
1312
+ SpyClient.prototype.listenFID = function (cb) {
1068
1313
  this.invoke('listenFID', cb);
1069
- }
1070
- listenLayoutShift(cb) {
1314
+ };
1315
+ SpyClient.prototype.listenLayoutShift = function (cb) {
1071
1316
  this.invoke('listenLayoutShift', cb);
1072
- }
1073
- listenLCP(cb) {
1317
+ };
1318
+ SpyClient.prototype.listenLCP = function (cb) {
1074
1319
  this.invoke('listenLCP', cb);
1075
- }
1076
- listenFSPLongTask(cb) {
1320
+ };
1321
+ SpyClient.prototype.listenFSPLongTask = function (cb) {
1077
1322
  this.invoke('listenFSPLongTask', cb);
1078
- }
1079
- listenLCPLongTask(cb) {
1323
+ };
1324
+ SpyClient.prototype.listenLCPLongTask = function (cb) {
1080
1325
  this.invoke('listenLCPLongTask', cb);
1081
- }
1082
- listenLoadLongTask(cb) {
1326
+ };
1327
+ SpyClient.prototype.listenLoadLongTask = function (cb) {
1083
1328
  this.invoke('listenLoadLongTask', cb);
1084
- }
1085
- listenPageLongTask(cb) {
1329
+ };
1330
+ SpyClient.prototype.listenPageLongTask = function (cb) {
1086
1331
  this.invoke('listenPageLongTask', cb);
1087
- }
1088
- listenMemory(cb) {
1332
+ };
1333
+ SpyClient.prototype.listenMemory = function (cb) {
1089
1334
  this.invoke('listenMemory', cb);
1090
- }
1091
- getNavigatorInfo() {
1335
+ };
1336
+ SpyClient.prototype.getNavigatorInfo = function () {
1092
1337
  return this.invoke('getNavigatorInfo');
1093
- }
1094
- listenResource(cb) {
1095
- this.invoke('listenResource', cb);
1096
- }
1097
- listenBigImg(cb, maxSize) {
1098
- this.invoke('listenBigImg', cb, maxSize);
1099
- }
1100
- listenHttpResource(cb) {
1101
- this.invoke('listenHttpResource', cb);
1102
- }
1103
- listenTiming(cb) {
1338
+ };
1339
+ SpyClient.prototype.listenResource = function (cb, option) {
1340
+ this.invoke('listenResource', cb, option);
1341
+ };
1342
+ SpyClient.prototype.listenBigImg = function (cb, option) {
1343
+ this.invoke('listenBigImg', cb, option);
1344
+ };
1345
+ SpyClient.prototype.listenHttpResource = function (cb, option) {
1346
+ this.invoke('listenHttpResource', cb, option);
1347
+ };
1348
+ SpyClient.prototype.listenSlowResource = function (cb, option) {
1349
+ this.invoke('listenSlowResource', cb, option);
1350
+ };
1351
+ SpyClient.prototype.listenTiming = function (cb) {
1104
1352
  this.invoke('listenTiming', cb);
1105
- }
1106
- listenTTI(cb, option) {
1353
+ };
1354
+ SpyClient.prototype.listenTTI = function (cb, option) {
1107
1355
  this.invoke('listenTTI', cb, option);
1108
- }
1109
- invoke(name, cb, option) {
1110
- for (let index = 0; index < this.modules.length; index++) {
1111
- const mod = this.modules[index];
1356
+ };
1357
+ SpyClient.prototype.invoke = function (name, cb, option) {
1358
+ for (var index = 0; index < this.modules.length; index++) {
1359
+ var mod = this.modules[index];
1112
1360
  if (typeof mod[name] === 'function') {
1113
1361
  return mod[name].apply(mod, [cb, option]);
1114
1362
  }
1115
1363
  }
1116
1364
  console.error('no method', name);
1117
- }
1118
- register(mod) {
1365
+ };
1366
+ SpyClient.prototype.register = function (mod) {
1119
1367
  this.modules.push(mod);
1120
- }
1121
- load() {
1122
- for (let index = 0; index < this.modules.length; index++) {
1123
- const mod = this.modules[index];
1368
+ };
1369
+ SpyClient.prototype.load = function () {
1370
+ for (var index = 0; index < this.modules.length; index++) {
1371
+ var mod = this.modules[index];
1124
1372
  mod.load && mod.load();
1125
1373
  }
1126
- }
1127
- leave() {
1128
- for (let index = 0; index < this.modules.length; index++) {
1129
- const mod = this.modules[index];
1374
+ };
1375
+ SpyClient.prototype.leave = function () {
1376
+ for (var index = 0; index < this.modules.length; index++) {
1377
+ var mod = this.modules[index];
1130
1378
  mod.leave && mod.leave();
1131
1379
  }
1132
- }
1133
- destroy() {
1134
- for (let index = 0; index < this.modules.length; index++) {
1135
- const mod = this.modules[index];
1380
+ };
1381
+ SpyClient.prototype.destroy = function () {
1382
+ for (var index = 0; index < this.modules.length; index++) {
1383
+ var mod = this.modules[index];
1136
1384
  mod.destroy && mod.destroy();
1137
1385
  }
1138
1386
  document.removeEventListener('visibilitychange', this.visibilitychangeCB);
1139
1387
  window.removeEventListener('load', this.load);
1140
1388
  window.removeEventListener('beforeunload', this.leave);
1141
1389
  window.removeEventListener('unload', this.destroy);
1142
- }
1143
- visibilitychangeCB() {
1390
+ };
1391
+ SpyClient.prototype.visibilitychangeCB = function () {
1144
1392
  if (document.visibilityState === 'hidden') {
1145
1393
  this.leave();
1146
1394
  }
1147
- }
1148
- }
1395
+ };
1396
+ return SpyClient;
1397
+ }(SpyClient$1));
1149
1398
 
1150
- export default SpyClient$1;
1399
+ export { SpyClient as default };