Skip to content

Instantly share code, notes, and snippets.

@petrvecera
Created January 12, 2023 12:56
Show Gist options
  • Save petrvecera/364e689f47a37bce16ad3bd741994a90 to your computer and use it in GitHub Desktop.
Save petrvecera/364e689f47a37bce16ad3bd741994a90 to your computer and use it in GitHub Desktop.
RUM-all-browsers
(()=>{var e={296:(e,t,n)=>{var i=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,a=/^0o[0-7]+$/i,c=parseInt,s="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,u="object"==typeof self&&self&&self.Object===Object&&self,f=s||u||Function("return this")(),d=Object.prototype.toString,l=Math.max,p=Math.min,h=function(){return f.Date.now()};function v(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==d.call(e)}(e))return NaN;if(v(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=v(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=o.test(e);return n||a.test(e)?c(e.slice(2),n?2:8):r.test(e)?NaN:+e}e.exports=function(e,t,n){var i,r,o,a,c,s,u=0,f=!1,d=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=i,o=r;return i=r=void 0,u=t,a=e.apply(o,n)}function _(e){return u=e,c=setTimeout(E,t),f?y(e):a}function T(e){var n=e-s;return void 0===s||n>=t||n<0||d&&e-u>=o}function E(){var e=h();if(T(e))return x(e);c=setTimeout(E,function(e){var n=t-(e-s);return d?p(n,o-(e-u)):n}(e))}function x(e){return c=void 0,g&&i?y(e):(i=r=void 0,a)}function w(){var e=h(),n=T(e);if(i=arguments,r=this,s=e,n){if(void 0===c)return _(s);if(d)return c=setTimeout(E,t),y(s)}return void 0===c&&(c=setTimeout(E,t)),a}return t=m(t)||0,v(n)&&(f=!!n.leading,o=(d="maxWait"in n)?l(m(n.maxWait)||0,t):o,g="trailing"in n?!!n.trailing:g),w.cancel=function(){void 0!==c&&clearTimeout(c),u=0,i=s=r=c=void 0},w.flush=function(){return void 0===c?a:x(h())},w}},68:(e,t,n)=>{"use strict";function i(e,t){void 0===t&&(t={});for(var n=function(e){for(var t=[],n=0;n<e.length;){var i=e[n];if("*"!==i&&"+"!==i&&"?"!==i)if("\\"!==i)if("{"!==i)if("}"!==i)if(":"!==i)if("("!==i)t.push({type:"CHAR",index:n,value:e[n++]});else{var r=1,o="";if("?"===e[c=n+1])throw new TypeError('Pattern cannot start with "?" at '.concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--r){c++;break}}else if("("===e[c]&&(r++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));o+=e[c++]}else o+=e[c++]+e[c++];if(r)throw new TypeError("Unbalanced pattern at ".concat(n));if(!o)throw new TypeError("Missing pattern at ".concat(n));t.push({type:"PATTERN",index:n,value:o}),n=c}else{for(var a="",c=n+1;c<e.length;){var s=e.charCodeAt(c);if(!(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||95===s))break;a+=e[c++]}if(!a)throw new TypeError("Missing parameter name at ".concat(n));t.push({type:"NAME",index:n,value:a}),n=c}else t.push({type:"CLOSE",index:n,value:e[n++]});else t.push({type:"OPEN",index:n,value:e[n++]});else t.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});else t.push({type:"MODIFIER",index:n,value:e[n++]})}return t.push({type:"END",index:n,value:""}),t}(e),i=t.prefixes,r=void 0===i?"./":i,o="[^".concat(s(t.delimiter||"/#?"),"]+?"),a=[],c=0,u=0,f="",d=function(e){if(u<n.length&&n[u].type===e)return n[u++].value},l=function(e){var t=d(e);if(void 0!==t)return t;var i=n[u],r=i.type,o=i.index;throw new TypeError("Unexpected ".concat(r," at ").concat(o,", expected ").concat(e))},p=function(){for(var e,t="";e=d("CHAR")||d("ESCAPED_CHAR");)t+=e;return t};u<n.length;){var h=d("CHAR"),v=d("NAME"),m=d("PATTERN");if(v||m){var g=h||"";-1===r.indexOf(g)&&(f+=g,g=""),f&&(a.push(f),f=""),a.push({name:v||c++,prefix:g,suffix:"",pattern:m||o,modifier:d("MODIFIER")||""})}else{var y=h||d("ESCAPED_CHAR");if(y)f+=y;else if(f&&(a.push(f),f=""),d("OPEN")){g=p();var _=d("NAME")||"",T=d("PATTERN")||"",E=p();l("CLOSE"),a.push({name:_||(T?c++:""),pattern:_&&!T?o:T,prefix:g,suffix:E,modifier:d("MODIFIER")||""})}else l("END")}}return a}function r(e,t){return o(i(e,t),t)}function o(e,t){void 0===t&&(t={});var n=u(t),i=t.encode,r=void 0===i?function(e){return e}:i,o=t.validate,a=void 0===o||o,c=e.map((function(e){if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),n)}));return function(t){for(var n="",i=0;i<e.length;i++){var o=e[i];if("string"!=typeof o){var s=t?t[o.name]:void 0,u="?"===o.modifier||"*"===o.modifier,f="*"===o.modifier||"+"===o.modifier;if(Array.isArray(s)){if(!f)throw new TypeError('Expected "'.concat(o.name,'" to not repeat, but got an array'));if(0===s.length){if(u)continue;throw new TypeError('Expected "'.concat(o.name,'" to not be empty'))}for(var d=0;d<s.length;d++){var l=r(s[d],o);if(a&&!c[i].test(l))throw new TypeError('Expected all "'.concat(o.name,'" to match "').concat(o.pattern,'", but got "').concat(l,'"'));n+=o.prefix+l+o.suffix}}else if("string"!=typeof s&&"number"!=typeof s){if(!u){var p=f?"an array":"a string";throw new TypeError('Expected "'.concat(o.name,'" to be ').concat(p))}}else{if(l=r(String(s),o),a&&!c[i].test(l))throw new TypeError('Expected "'.concat(o.name,'" to match "').concat(o.pattern,'", but got "').concat(l,'"'));n+=o.prefix+l+o.suffix}}else n+=o}return n}}function a(e,t){var n=[];return c(d(e,n,t),n,t)}function c(e,t,n){void 0===n&&(n={});var i=n.decode,r=void 0===i?function(e){return e}:i;return function(n){var i=e.exec(n);if(!i)return!1;for(var o=i[0],a=i.index,c=Object.create(null),s=function(e){if(void 0===i[e])return"continue";var n=t[e-1];"*"===n.modifier||"+"===n.modifier?c[n.name]=i[e].split(n.prefix+n.suffix).map((function(e){return r(e,n)})):c[n.name]=r(i[e],n)},u=1;u<i.length;u++)s(u);return{path:o,index:a,params:c}}}function s(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function u(e){return e&&e.sensitive?"":"i"}function f(e,t,n){void 0===n&&(n={});for(var i=n.strict,r=void 0!==i&&i,o=n.start,a=void 0===o||o,c=n.end,f=void 0===c||c,d=n.encode,l=void 0===d?function(e){return e}:d,p=n.delimiter,h=void 0===p?"/#?":p,v=n.endsWith,m="[".concat(s(void 0===v?"":v),"]|$"),g="[".concat(s(h),"]"),y=a?"^":"",_=0,T=e;_<T.length;_++){var E=T[_];if("string"==typeof E)y+=s(l(E));else{var x=s(l(E.prefix)),w=s(l(E.suffix));if(E.pattern)if(t&&t.push(E),x||w)if("+"===E.modifier||"*"===E.modifier){var b="*"===E.modifier?"?":"";y+="(?:".concat(x,"((?:").concat(E.pattern,")(?:").concat(w).concat(x,"(?:").concat(E.pattern,"))*)").concat(w,")").concat(b)}else y+="(?:".concat(x,"(").concat(E.pattern,")").concat(w,")").concat(E.modifier);else"+"===E.modifier||"*"===E.modifier?y+="((?:".concat(E.pattern,")").concat(E.modifier,")"):y+="(".concat(E.pattern,")").concat(E.modifier);else y+="(?:".concat(x).concat(w,")").concat(E.modifier)}}if(f)r||(y+="".concat(g,"?")),y+=n.endsWith?"(?=".concat(m,")"):"$";else{var C=e[e.length-1],A="string"==typeof C?g.indexOf(C[C.length-1])>-1:void 0===C;r||(y+="(?:".concat(g,"(?=").concat(m,"))?")),A||(y+="(?=".concat(g,"|").concat(m,")"))}return new RegExp(y,u(n))}function d(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;for(var n=/\((?:\?<(.*?)>)?(?!\?)/g,i=0,r=n.exec(e.source);r;)t.push({name:r[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),r=n.exec(e.source);return e}(e,t):Array.isArray(e)?function(e,t,n){var i=e.map((function(e){return d(e,t,n).source}));return new RegExp("(?:".concat(i.join("|"),")"),u(n))}(e,t,n):function(e,t,n){return f(i(e,n),t,n)}(e,t,n)}n.r(t),n.d(t,{parse:()=>i,compile:()=>r,tokensToFunction:()=>o,match:()=>a,regexpToFunction:()=>c,tokensToRegexp:()=>f,pathToRegexp:()=>d})},152:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(601),o=i(n(904));t.default=class{constructor(e=r.CACHE_MANIFEST_TTL){this.ttl=e>0?e:0,this.routes=[],this.load()}load(){this.isCacheFresh()?this.routes=this.getCacheRoutes():this.download()}getRoutes(){if(this.routes&&this.routes.length>0)return this.routes;let e=window.__EDGIO_CACHE_MANIFEST__||window.__LAYER0_CACHE_MANIFEST__||window.__XDN_CACHE_MANIFEST__;return e&&(this.routes=e,this.setCacheRoutes(this.routes),this.setCacheTime((new Date).getTime())),this.routes}getCacheTime(){let e=localStorage.getItem(r.CACHE_MANIFEST_TIME_KEY);return e?parseInt(e):null}setCacheTime(e){localStorage.setItem(r.CACHE_MANIFEST_TIME_KEY,e.toString())}getCacheRoutes(){var e;return JSON.parse(null!==(e=localStorage.getItem(r.CACHE_MANIFEST_DATA_KEY))&&void 0!==e?e:"[]")}setCacheRoutes(e){localStorage.setItem(r.CACHE_MANIFEST_DATA_KEY,JSON.stringify(e))}isCacheFresh(){let e=this.getCacheTime();return null!=e&&(new Date).getTime()-e<1e3*this.ttl}download(){const e=document.createElement("script");return e.setAttribute("defer","on"),(0,o.default)("edgio_environment_id_info")||(0,o.default)("edgio_eid")||(0,o.default)("edgio_bucket")?(e.setAttribute("src","/__edgio__/cache-manifest.js"),void document.head.appendChild(e)):(0,o.default)("layer0_environment_id_info")||(0,o.default)("layer0_eid")||(0,o.default)("layer0_bucket")?(e.setAttribute("src","/__layer0__/cache-manifest.js"),void document.head.appendChild(e)):(e.setAttribute("src","/__xdn__/cache-manifest.js"),void document.head.appendChild(e))}}},495:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(135),o=n(601),a=i(n(904)),c=i(n(754)),s=i(n(131)),u=i(n(296)),f=i(n(48)),d=i(n(152));let l;try{l=n(306).i8}catch(e){l="development"}const p=()=>(0,a.default)("edgio_environment_id_info")||(0,a.default)("edgio_eid")||(0,a.default)("layer0_environment_id_info")||(0,a.default)("layer0_eid")||(0,a.default)("xdn_environment_id_info")||(0,a.default)("xdn_eid");let h=class{constructor(e){}collect(){return Promise.resolve()}};"undefined"!=typeof window&&(h=class{constructor(e={}){var t;this.index=0,this.clientNavigationHasOccurred=!1,this.send=(0,u.default)((()=>{const e=this.createPayload();this.token?this.token.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)?(navigator.sendBeacon?navigator.sendBeacon(this.sendTo,e):fetch(this.sendTo,{body:e,method:"POST",keepalive:!0}),this.index++):console.warn(`[RUM] Not sending rum entry because a token "${this.token}" is not valid.`):console.warn("[RUM] Not sending rum entry because a token was not provided.")}),o.SEND_DELAY),this.originalURL=location.href,this.options=e,this.edgioEnvironmentID=p(),this.token=e.token||this.edgioEnvironmentID,this.sendTo=`${this.options.sendTo||o.DEST_URL}/${this.token}`,this.pageID=(0,s.default)(),this.metrics=this.flushMetrics(),this.splitTestVariant=this.getSplitTestVariant();try{this.connectionType=navigator.connection.effectiveType}catch(e){console.debug("could not obtain navigator.connection metrics")}null==this.edgioEnvironmentID&&"localhost"!==location.hostname||(this.manifest=new d.default(null!==(t=e.cacheManifestTTL)&&void 0!==t?t:o.CACHE_MANIFEST_TTL))}collect(){return Promise.all([this.toPromise(r.onTTFB),this.toPromise(r.onFCP),this.toPromise(r.onLCP,!0),this.toPromise(r.onFID),this.toPromise(r.onCLS,!0)]).then((()=>{}))}flushMetrics(){return{clsel:[]}}toPromise(e,...t){return new Promise((n=>{e((e=>{var t;if(0===e.delta)return n();if(this.metrics[e.name.toLowerCase()]=e.value,this.clientNavigationHasOccurred||(this.clientNavigationHasOccurred=this.originalURL!==location.href),"CLS"===e.name&&(this.clientNavigationHasOccurred&&(this.metrics.ils=e.delta),null===(t=e.entries)||void 0===t?void 0:t.length))try{const t=e.entries[e.entries.length-1].sources[0];this.metrics.clsel.push((0,f.default)(t.node).join(" > "))}catch(e){console.error(e)}this.options.debug&&console.log("[RUM]",e.name,e.value,`(pageID: ${this.pageID})`),this.send(),n()}),t)}))}createPayload(){var e;const t=(0,c.default)(),n=t.xrj;let i=this.options.pageLabel||(null===(e=this.options.router)||void 0===e?void 0:e.getPageLabel(this.originalURL));if(!i&&n)try{i=JSON.parse(n).path}catch(e){i=n}if(this.splitTestVariant||(this.splitTestVariant=this.getSplitTestVariant()),!this.connectionType)try{this.connectionType=navigator.connection.effectiveType}catch(e){console.debug("could not obtain navigator.connection metrics")}const r=Object.assign(Object.assign({},this.metrics),{i:this.index,u0:this.originalURL,cn:this.clientNavigationHasOccurred?1:0,ux:location.href,pid:this.pageID,t:this.token,ti:document.title,d:this.splitTestVariant,ua:navigator.userAgent,w:window.screen.width,h:window.screen.height,v:this.getAppVersion(t),cv:l,ht:this.isCacheHit(t),l:i,l0:i,lx:this.getCurrentPageLabel(),c:this.options.country||t.country,ct:this.connectionType,epop:t.edge_pop});return this.metrics=this.flushMetrics(),JSON.stringify(r)}getAppVersion(e){return this.options.appVersion||e["edgio-deployment-id"]||e["layer0-deployment-id"]||e["xdn-deployment-id"]}getSplitTestVariant(){return this.options.splitTestVariant||(0,a.default)("edgio_destination")||(0,a.default)("layer0_destination")||(0,a.default)("xdn_destination")}isCacheHit(e){if(null!=this.options.cacheHit)return this.options.cacheHit?1:0;const t=e["edgio-cache"]||e["layer0-cache"]||e["xdn-cache"];return(null==t?void 0:t.includes("HIT"))?1:(null==t?void 0:t.includes("MISS"))?0:null}getCurrentPageLabel(){var e,t;const n=null!==(t=null===(e=this.manifest)||void 0===e?void 0:e.getRoutes())&&void 0!==t?t:[];if(this.options.router)return this.options.router.getPageLabel(location.href);if(n){const e=n.find((e=>e.returnsResponse&&e.route&&new RegExp(e.route,"i").test(location.pathname)));return null==e?void 0:e.criteriaPath}}}),t.default=h},787:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(68);t.default=class{constructor(e,t){this.regex=(0,i.pathToRegexp)(e),this.callback=t}matches(e){return this.regex.test(e.pathname)}}},682:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(n(787));t.default=class{constructor(){this.routes=[]}match(e,t){return this.routes.push(new r.default(e,t)),this}getPageLabel(e){const t=new URL(e);let n;const i={setPageLabel:e=>n=e};for(let e of this.routes)e.matches(t)&&e.callback(i);return n}}},625:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(n(495)),o=i(n(682));if("undefined"!=typeof window){const e=window.Edgio={Metrics:r.default,Router:o.default};window.XDN=e,window.Layer0=e}},601:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CACHE_MANIFEST_TIME_KEY=t.CACHE_MANIFEST_DATA_KEY=t.CACHE_MANIFEST_TTL=t.SEND_DELAY=t.DEST_URL=void 0,t.DEST_URL="https://rum.ingress.layer0.co/ingress/rum/v1",t.SEND_DELAY=500,t.CACHE_MANIFEST_TTL=3600,t.CACHE_MANIFEST_DATA_KEY="rum_cache_manifest",t.CACHE_MANIFEST_TIME_KEY="rum_cache_manifest_time"},904:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=document.cookie.match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return t?t.pop():void 0}},48:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){if(t===document.documentElement||null==t||"function"!=typeof t.getAttribute)return[];{const n=t.getAttribute("id");if(n)return[`#${n}`];{let n=t.localName;const{classList:i}=t;return i.length&&(n+="."+Array.from(i.values()).join(".")),[...e(t.parentElement),n]}}}},754:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const e={};try{const t=performance.getEntriesByType("navigation")[0].serverTiming;for(let{name:n,description:i}of t)e[n]=decodeURIComponent(i)}catch(e){console.debug("could not obtain serverTiming metrics",e)}return e}},131:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n="undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.getRandomValues?function(){var e=new Uint16Array(8);window.crypto.getRandomValues(e);var t=function(e){for(var t=e.toString(16);t.length<4;)t="0"+t;return t};return t(e[0])+t(e[1])+"-"+t(e[2])+"-"+t(e[3])+"-"+t(e[4])+"-"+t(e[5])+t(e[6])+t(e[7])}:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))};t.default=n},135:function(e,t){!function(e){"use strict";var t,n,i,r,o,a=-1,c=function(e){addEventListener("pageshow",(function(t){t.persisted&&(a=t.timeStamp,e(t))}),!0)},s=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},u=function(){var e=s();return e&&e.activationStart||0},f=function(e,t){var n=s(),i="navigate";return a>=0?i="back-forward-cache":n&&(i=document.prerendering||u()>0?"prerender":document.wasDiscarded?"restore":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:i}},d=function(e,t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var i=new PerformanceObserver((function(e){Promise.resolve().then((function(){t(e.getEntries())}))}));return i.observe(Object.assign({type:e,buffered:!0},n||{})),i}}catch(e){}},l=function(e,t,n,i){var r,o;return function(a){t.value>=0&&(a||i)&&((o=t.value-(r||0))||void 0===r)&&(r=t.value,t.delta=o,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},p=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},h=function(e){var t=function(t){"pagehide"!==t.type&&"hidden"!==document.visibilityState||e(t)};addEventListener("visibilitychange",t,!0),addEventListener("pagehide",t,!0)},v=function(e){var t=!1;return function(n){t||(e(n),t=!0)}},m=-1,g=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},y=function(e){"hidden"===document.visibilityState&&m>-1&&(m="visibilitychange"===e.type?e.timeStamp:0,T())},_=function(){addEventListener("visibilitychange",y,!0),addEventListener("prerenderingchange",y,!0)},T=function(){removeEventListener("visibilitychange",y,!0),removeEventListener("prerenderingchange",y,!0)},E=function(){return m<0&&(m=g(),_(),c((function(){setTimeout((function(){m=g(),_()}),0)}))),{get firstHiddenTime(){return m}}},x=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},w=function(e,t){t=t||{},x((function(){var n,i=[1800,3e3],r=E(),o=f("FCP"),a=d("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(a.disconnect(),e.startTime<r.firstHiddenTime&&(o.value=Math.max(e.startTime-u(),0),o.entries.push(e),n(!0)))}))}));a&&(n=l(e,o,i,t.reportAllChanges),c((function(r){o=f("FCP"),n=l(e,o,i,t.reportAllChanges),p((function(){o.value=performance.now()-r.timeStamp,n(!0)}))})))}))},b=function(e,t){t=t||{},w(v((function(){var n,i=[.1,.25],r=f("CLS",0),o=0,a=[],s=function(e){e.forEach((function(e){if(!e.hadRecentInput){var t=a[0],n=a[a.length-1];o&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(o+=e.value,a.push(e)):(o=e.value,a=[e])}})),o>r.value&&(r.value=o,r.entries=a,n())},u=d("layout-shift",s);u&&(n=l(e,r,i,t.reportAllChanges),h((function(){s(u.takeRecords()),n(!0)})),c((function(){o=0,r=f("CLS",0),n=l(e,r,i,t.reportAllChanges),p((function(){return n()}))})),setTimeout(n,0))})))},C={passive:!0,capture:!0},A=new Date,S=function(e,r){t||(t=r,n=e,i=new Date,I(removeEventListener),M())},M=function(){if(n>=0&&n<i-A){var e={entryType:"first-input",name:t.type,target:t.target,cancelable:t.cancelable,startTime:t.timeStamp,processingStart:t.timeStamp+n};r.forEach((function(t){t(e)})),r=[]}},P=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){S(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,C),removeEventListener("pointercancel",i,C)};addEventListener("pointerup",n,C),addEventListener("pointercancel",i,C)}(t,e):S(t,e)}},I=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,P,C)}))},L=function(e,i){i=i||{},x((function(){var o,a=[100,300],s=E(),u=f("FID"),p=function(e){e.startTime<s.firstHiddenTime&&(u.value=e.processingStart-e.startTime,u.entries.push(e),o(!0))},m=function(e){e.forEach(p)},g=d("first-input",m);o=l(e,u,a,i.reportAllChanges),g&&h(v((function(){m(g.takeRecords()),g.disconnect()}))),g&&c((function(){var c;u=f("FID"),o=l(e,u,a,i.reportAllChanges),r=[],n=-1,t=null,I(addEventListener),c=p,r.push(c),M()}))}))},N=0,O=1/0,D=0,R=function(e){e.forEach((function(e){e.interactionId&&(O=Math.min(O,e.interactionId),D=Math.max(D,e.interactionId),N=D?(D-O)/7+1:0)}))},F=function(){return o?N:performance.interactionCount||0},j=function(){"interactionCount"in performance||o||(o=d("event",R,{type:"event",buffered:!0,durationThreshold:0}))},H=0,k=function(){return F()-H},U=[],$={},V=function(e){var t=U[U.length-1],n=$[e.interactionId];if(n||U.length<10||e.duration>t.latency){if(n)n.entries.push(e),n.latency=Math.max(n.latency,e.duration);else{var i={id:e.interactionId,latency:e.duration,entries:[e]};$[i.id]=i,U.push(i)}U.sort((function(e,t){return t.latency-e.latency})),U.splice(10).forEach((function(e){delete $[e.id]}))}},Y=function(e,t){t=t||{},x((function(){var n=[200,500];j();var i,r=f("INP"),o=function(e){e.forEach((function(e){e.interactionId&&V(e),"first-input"===e.entryType&&!U.some((function(t){return t.entries.some((function(t){return e.duration===t.duration&&e.startTime===t.startTime}))}))&&V(e)}));var t,n=(t=Math.min(U.length-1,Math.floor(k()/50)),U[t]);n&&n.latency!==r.value&&(r.value=n.latency,r.entries=n.entries,i())},a=d("event",o,{durationThreshold:t.durationThreshold||40});i=l(e,r,n,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),h((function(){o(a.takeRecords()),r.value<0&&k()>0&&(r.value=0,r.entries=[]),i(!0)})),c((function(){U=[],H=F(),r=f("INP"),i=l(e,r,n,t.reportAllChanges)})))}))},B={},K=function(e,t){t=t||{},x((function(){var n,i=[2500,4e3],r=E(),o=f("LCP"),a=function(e){var t=e[e.length-1];if(t){var i=Math.max(t.startTime-u(),0);i<r.firstHiddenTime&&(o.value=i,o.entries=[t],n())}},s=d("largest-contentful-paint",a);if(s){n=l(e,o,i,t.reportAllChanges);var m=v((function(){B[o.id]||(a(s.takeRecords()),s.disconnect(),B[o.id]=!0,n(!0))}));["keydown","click"].forEach((function(e){addEventListener(e,m,!0)})),h(m),c((function(r){o=f("LCP"),n=l(e,o,i,t.reportAllChanges),p((function(){o.value=performance.now()-r.timeStamp,B[o.id]=!0,n(!0)}))}))}}))},J=function e(t){document.prerendering?x((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},W=function(e,t){t=t||{};var n=[800,1800],i=f("TTFB"),r=l(e,i,n,t.reportAllChanges);J((function(){var o=s();if(o){var a=o.responseStart;if(a<=0||a>performance.now())return;i.value=Math.max(a-u(),0),i.entries=[o],r(!0),c((function(){i=f("TTFB",0),(r=l(e,i,n,t.reportAllChanges))(!0)}))}}))};e.getCLS=b,e.getFCP=w,e.getFID=L,e.getINP=Y,e.getLCP=K,e.getTTFB=W,e.onCLS=b,e.onFCP=w,e.onFID=L,e.onINP=Y,e.onLCP=K,e.onTTFB=W,Object.defineProperty(e,"__esModule",{value:!0})}(t)},306:e=>{"use strict";e.exports={i8:"6.0.0"}}},t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={exports:{}};return e[i].call(r.exports,r,r.exports,n),r.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(625)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment