|
var webVitals=function(n){"use strict";var t,e,i,a,o,r=-1,c=function(n){addEventListener("pageshow",(function(t){t.persisted&&(r=t.timeStamp,n(t))}),!0)},u=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},f=function(){var n=u();return n&&n.activationStart||0},d=function(n,t,e,i){var a=u(),o="navigate";return e?o=e:r>=0?o="back-forward-cache":a&&(o=document.prerendering||f()>0?"prerender":document.wasDiscarded?"restore":a.type.replace(/_/g,"-")),{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o,navigationId:i||1}},s=function(n){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&(null==n?void 0:n.reportSoftNavs)},v=function(n){return n&&1!==n?window.performance&&performance.getEntriesByType&&performance.getEntriesByType("soft-navigation")[n-2]:window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},g=function(n,t,e){var i=s(e);try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var a=new PerformanceObserver((function(n){Promise.resolve().then((function(){t(n.getEntries())}))}));return a.observe(Object.assign({type:n,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(n){}},l=function(n,t,e,i){var a,o;return function(r){t.value>=0&&(r||i)&&((o=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=o,t.rating=function(n,t){return n>t[1]?"poor":n>t[0]?"needs-improvement":"good"}(t.value,e),n(t))}},p=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},h=function(n){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||n(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},m=-1,I=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},T=function(n){"hidden"===document.visibilityState&&m>-1&&(m="visibilitychange"===n.type?n.timeStamp:0,E())},y=function(){addEventListener("visibilitychange",T,!0),addEventListener("prerenderingchange",T,!0)},E=function(){removeEventListener("visibilitychange",T,!0),removeEventListener("prerenderingchange",T,!0)},C=function(){return m<0&&(m=I(),y(),c((function(){setTimeout((function(){m=I(),y()}),0)}))),{get firstHiddenTime(){return m}}},b=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},w=[1800,3e3],L=function(n,t){var e=s(t=t||{});b((function(){var i,a=C(),o=d("FCP"),r=g("paint",(function(c){c.forEach((function(c){if("first-contentful-paint"===c.name){e?(c.navigationId||1)>1&&(p="soft-navigation",h=c.navigationId,o=d("FCP",0,p,h),i=l(n,o,w,t.reportAllChanges)):r.disconnect();var u=0;if(c.navigationId&&1!==c.navigationId){var s=v(c.navigationId),g=(null==s?void 0:s.startTime)||0;u=Math.max(c.startTime-g,0)}else u=Math.max(c.startTime-f(),0);(c.startTime<a.firstHiddenTime||c.navigationId&&c.navigationId>1)&&(o.value=u,o.entries.push(c),o.navigationId=c.navigationId||1,i(!0))}var p,h}))}),t);r&&(i=l(n,o,w,t.reportAllChanges),c((function(e){o=d("FCP",0,"back-forward-cache",o.navigationId),i=l(n,o,w,t.reportAllChanges),p((function(){o.value=performance.now()-e.timeStamp,i(!0)}))})))}))},S=[.1,.25],P=function(n,t){var e,i,a=s(t=t||{}),o=!1;L((e=function(){var e,i=d("CLS",0),r=0,u=[],f=function(a,c){i=d("CLS",0,a,c),e=l(n,i,S,t.reportAllChanges),r=0,o=!1},s=function(n){n.forEach((function(n){if(a&&n.navigationId&&n.navigationId>i.navigationId&&(r>i.value&&(i.value=r,i.entries=u),e(!0),f("soft-navigation",n.navigationId)),!n.hadRecentInput){var t=u[0],o=u[u.length-1];r&&n.startTime-o.startTime<1e3&&n.startTime-t.startTime<5e3?(r+=n.value,u.push(n)):(r=n.value,u=[n])}})),r>i.value&&(i.value=r,i.entries=u,e())},v=g("layout-shift",s,t);v&&(e=l(n,i,S,t.reportAllChanges),h((function(){s(v.takeRecords()),e(!0),o=!0})),c((function(){f("back-forward-cache",i.navigationId),p((function(){return e()}))})),a&&g("soft-navigation",(function(a){a.forEach((function(a){a.navigationId&&a.navigationId>i.navigationId&&(o||e(!0),f("soft-navigation",a.navigationId),e=l(n,i,S,t.reportAllChanges))}))}),t),setTimeout(e,0))},i=!1,function(n){i||(e(n),i=!0)}))},A={passive:!0,capture:!0},F=new Date,k=function(n,a){t||(t=a,e=n,i=new Date,D(removeEventListener),M())},M=function(){if(e>=0&&e<i-F){var n={entryType:"first-input",name:t.type,target:t.target,cancelable:t.cancelable,startTime:t.timeStamp,processingStart:t.timeStamp+e};a.forEach((function(t){t([n])})),a=[]}},B=function(n){if(n.cancelable){var t=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,t){var e=function(){k(n,t),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,A),removeEventListener("pointercancel",i,A)};addEventListener("pointerup",e,A),addEventListener("pointercancel",i,A)}(t,n):k(t,n)}},D=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return n(t,B,A)}))},N=[100,300],O=function(n,i){var o=s(i=i||{});b((function(){var r,u=C(),f=d("FID"),s=function(t){t.forEach((function(t){var e,a;o?(t.navigationId||1)>1&&(e="soft-navigation",a=t.navigationId,f=d("FID",0,e,a),r=l(n,f,N,i.reportAllChanges)):v.disconnect(),t.startTime<u.firstHiddenTime&&(f.value=t.processingStart-t.startTime,f.entries.push(t),f.navigationId=t.navigationId||1,r(!0))}))},v=g("first-input",s,i);r=l(n,f,N,i.reportAllChanges),v&&h((function(){s(v.takeRecords()),o||v.disconnect()})),v&&c((function(){var o;f=d("FID",0,"back-forward-cache",f.navigationId),r=l(n,f,N,i.reportAllChanges),a=[],e=-1,t=null,D(addEventListener),o=s,a.push(o),M()}))}))},x=0,R=1/0,H=0,_=1,j=!1,q=function(n){n.forEach((function(n){n.interactionId&&(j&&n.navigationId&&n.navigationId>_&&(_=n.navigationId,x=0,R=1/0,H=0),R=Math.min(R,n.interactionId),H=Math.max(H,n.interactionId),x=H?(H-R)/7+1:0)}))},V=function(){return o?x:performance.interactionCount||0},z=function(n){"interactionCount"in performance||o||(j=n||!1,o=g("event",q,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:n}))},G=[200,500],J=0,K=function(){return V()-J},Q=[],U={},W=function(n){var t=Q[Q.length-1],e=U[n.interactionId];if(e||Q.length<10||n.duration>t.latency){if(e)e.entries.push(n),e.latency=Math.max(e.latency,n.duration);else{var i={id:n.interactionId,latency:n.duration,entries:[n]};U[i.id]=i,Q.push(i)}Q.sort((function(n,t){return t.latency-n.latency})),Q.splice(10).forEach((function(n){delete U[n.id]}))}},X=function(n,t){var e=s(t=t||{}),i=!1;b((function(){z(e);var a,o=d("INP"),r=function(e,r){Q=[],J="soft-navigation"===e?0:V(),o=d("INP",0,e,r),a=l(n,o,G,t.reportAllChanges),i=!1},u=function(){var n,e,i=(e=Math.min(Q.length-1,Math.floor(K()/50)),Q[e]);i&&(i.latency!==o.value||null!==(n=t)&&void 0!==n&&n.reportAllChanges)&&(o.value=i.latency,o.entries=i.entries)},f=function(n){n.forEach((function(n){(e&&n.navigationId&&n.navigationId>o.navigationId&&(i||(u(),o.value>0&&a(!0)),r("soft-navigation",n.navigationId)),n.interactionId&&W(n),"first-input"===n.entryType)&&(!Q.some((function(t){return t.entries.some((function(t){return n.duration===t.duration&&n.startTime===t.startTime}))}))&&W(n))})),u(),a()},s=g("event",f,{durationThreshold:t.durationThreshold||40,opts:t});if(a=l(n,o,G,t.reportAllChanges),s){s.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),h((function(){f(s.takeRecords()),o.value<0&&K()>0&&(o.value=0,o.entries=[]),a(!0)})),c((function(){r("back-forward-cache",o.navigationId),p((function(){return a()}))}));e&&g("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&e.navigationId>o.navigationId&&(!i&&o.value>0&&a(!0),r("soft-navigation",e.navigationId),a=l(n,o,G,t.reportAllChanges))}))}),t)}}))},Y=[2500,4e3],Z=function(n,t){var e=!1,i=s(t=t||{});b((function(){var a,o=C(),r=d("LCP"),u=function(i,o){r=d("LCP",0,i,o),a=l(n,r,Y,t.reportAllChanges),e=!1},s=function(n){n.forEach((function(n){if(n){n.navigationId&&n.navigationId>r.navigationId&&(e||a(!0),u("soft-navigation",n.navigationId));var t,i=0;if(1!==n.navigationId&&n.navigationId)i=Math.max(n.startTime-((null===(t=v(n.navigationId))||void 0===t?void 0:t.startTime)||0),0);else i=Math.max(n.startTime-f(),0);n.startTime<o.firstHiddenTime&&(r.value=i,r.entries=[n],r.navigationId=n.navigationId||1,a())}}))},m=function(){e||(s(I.takeRecords()),i||I.disconnect(),e=!0,a(!0))},I=g("largest-contentful-paint",s,t);if(I){a=l(n,r,Y,t.reportAllChanges),["keydown","click"].forEach((function(n){addEventListener(n,m,!0)})),h(m),c((function(n){u("back-forward-cache",r.navigationId),p((function(){r.value=performance.now()-n.timeStamp,e=!0,a(!0)}))}));i&&g("soft-navigation",(function(n){n.forEach((function(n){n.navigationId&&n.navigationId>r.navigationId&&(e||a(!0),u("soft-navigation",n.navigationId))}))}),t)}}))},$=[800,1800],nn=function n(t){document.prerendering?b((function(){return n(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return n(t)}),!0):setTimeout(t,0)},tn=function(n,t){var e=s(t=t||{}),i=d("TTFB"),a=l(n,i,$,t.reportAllChanges);nn((function(){var o=u();if(o){var r=o.responseStart;if(r<=0||r>performance.now())return;i.value=Math.max(r-f(),0),i.entries=[o],a(!0),c((function(){i=d("TTFB",0,"back-forward-cache",i.navigationId),(a=l(n,i,$,t.reportAllChanges))(!0)}));e&&g("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&(i=d("TTFB",0,"soft-navigation",e.navigationId),(a=l(n,i,$,t.reportAllChanges))(!0))}))}),t)}}))};return n.CLSThresholds=S,n.FCPThresholds=w,n.FIDThresholds=N,n.INPThresholds=G,n.LCPThresholds=Y,n.TTFBThresholds=$,n.getCLS=P,n.getFCP=L,n.getFID=O,n.getINP=X,n.getLCP=Z,n.getTTFB=tn,n.onCLS=P,n.onFCP=L,n.onFID=O,n.onINP=X,n.onLCP=Z,n.onTTFB=tn,Object.defineProperty(n,"__esModule",{value:!0}),n}({}); |