!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).webVitals={})}(this,(function(t){"use strict";class e{t;o=0;i=[];u(t){if(t.hadRecentInput)return;const e=this.i[0],n=this.i.at(-1);this.o&&e&&n&&t.startTime-n.startTime<1e3&&t.startTime-e.startTime<5e3?(this.o+=t.value,this.i.push(t)):(this.o=t.value,this.i=[t]),this.t?.(t)}}const n=()=>{const t=performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart{if("loading"===document.readyState)return"loading";{const e=n();if(e){if(t{const e=t.nodeName;return 1===t.nodeType?e.toLowerCase():e.toUpperCase().replace(/^#/,"")},r=t=>{let e="";try{for(;9!==t?.nodeType;){const n=t,o=n.id?"#"+n.id:[i(n),...Array.from(n.classList).sort()].join(".");if(e.length+o.length>99)return e||o;if(e=e?o+">"+e:o,n.id)break;t=n.parentNode}}catch{}return e},s=new WeakMap;function a(t,e){return s.get(t)||s.set(t,new e),s.get(t)}let c=-1;const f=()=>c,u=t=>{addEventListener("pageshow",(e=>{e.persisted&&(c=e.timeStamp,t(e))}),!0)},d=(t,e,n,o)=>{let i,r;return s=>{e.value>=0&&(s||o)&&(r=e.value-(i??0),(r||void 0===i)&&(i=e.value,e.delta=r,e.rating=((t,e)=>t>e[1]?"poor":t>e[0]?"needs-improvement":"good")(e.value,n),t(e)))}},l=t=>{requestAnimationFrame((()=>requestAnimationFrame((()=>t()))))},h=()=>{const t=n();return t?.activationStart??0},p=(t,e=-1)=>{const o=n();let i="navigate";f()>=0?i="back-forward-cache":o&&(document.prerendering||h()>0?i="prerender":document.wasDiscarded?i="restore":o.type&&(i=o.type.replace(/_/g,"-")));return{name:t,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:i}},g=(t,e,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(t)){const o=new PerformanceObserver((t=>{Promise.resolve().then((()=>{e(t.getEntries())}))}));return o.observe({type:t,buffered:!0,...n}),o}}catch{}},m=t=>{let e=!1;return()=>{e||(t(),e=!0)}};let y=-1;const v=new Set,b=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,M=t=>{if("hidden"===document.visibilityState){if("visibilitychange"===t.type)for(const t of v)t();isFinite(y)||(y="visibilitychange"===t.type?t.timeStamp:0,removeEventListener("prerenderingchange",M,!0))}},T=()=>{if(y<0){const t=h(),e=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((e=>"hidden"===e.name&&e.startTime>t))[0]?.startTime;y=e??b(),addEventListener("visibilitychange",M,!0),addEventListener("prerenderingchange",M,!0),u((()=>{setTimeout((()=>{y=b()}))}))}return{get firstHiddenTime(){return y},onHidden(t){v.add(t)}}},E=t=>{document.prerendering?addEventListener("prerenderingchange",(()=>t()),!0):t()},D=[1800,3e3],L=(t,e={})=>{E((()=>{const n=T();let o,i=p("FCP");const r=g("paint",(t=>{for(const e of t)"first-contentful-paint"===e.name&&(r.disconnect(),e.startTime{i=p("FCP"),o=d(t,i,D,e.reportAllChanges),l((()=>{i.value=performance.now()-n.timeStamp,o(!0)}))})))}))},P=[.1,.25],S=t=>t.find((t=>1===t.node?.nodeType))||t[0];let w=0,_=1/0,F=0;const k=t=>{for(const e of t)e.interactionId&&(_=Math.min(_,e.interactionId),F=Math.max(F,e.interactionId),w=F?(F-_)/7+1:0)};let B;const C=()=>B?w:performance.interactionCount??0,O=()=>{"interactionCount"in performance||B||(B=g("event",k,{type:"event",buffered:!0,durationThreshold:0}))};let j=0;class I{l=[];h=new Map;p;m;v(){j=C(),this.l.length=0,this.h.clear()}M(){const t=Math.min(this.l.length-1,Math.floor((C()-j)/50));return this.l[t]}u(t){if(this.p?.(t),!t.interactionId&&"first-input"!==t.entryType)return;const e=this.l.at(-1);let n=this.h.get(t.interactionId);if(n||this.l.length<10||t.duration>e.T){if(n?t.duration>n.T?(n.entries=[t],n.T=t.duration):t.duration===n.T&&t.startTime===n.entries[0].startTime&&n.entries.push(t):(n={id:t.interactionId,entries:[t],T:t.duration},this.h.set(n.id,n),this.l.push(n)),this.l.sort(((t,e)=>e.T-t.T)),this.l.length>10){const t=this.l.splice(10);for(const e of t)this.h.delete(e.id)}this.m?.(n)}}}const A=t=>{const e=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?t():(t=m(t),addEventListener("visibilitychange",t,{once:!0,capture:!0}),e((()=>{t(),removeEventListener("visibilitychange",t,{capture:!0})})))},x=[200,500];class W{p;u(t){this.p?.(t)}}const q=[2500,4e3],N=[800,1800],H=t=>{document.prerendering?E((()=>H(t))):"complete"!==document.readyState?addEventListener("load",(()=>H(t)),!0):setTimeout(t)};t.CLSThresholds=P,t.FCPThresholds=D,t.INPThresholds=x,t.LCPThresholds=q,t.TTFBThresholds=N,t.onCLS=(t,n={})=>{const i=a(n=Object.assign({},n),e),s=new WeakMap;i.t=t=>{if(t?.sources?.length){const e=S(t.sources),o=e?.node;if(o){const t=n.generateTarget?.(o)??r(o);s.set(e,t)}}};((t,n={})=>{const o=T();L(m((()=>{let i,r=p("CLS",0);const s=a(n,e),c=t=>{for(const e of t)s.u(e);s.o>r.value&&(r.value=s.o,r.entries=s.i,i())},f=g("layout-shift",c);f&&(i=d(t,r,P,n.reportAllChanges),o.onHidden((()=>{c(f.takeRecords()),i(!0)})),u((()=>{s.o=0,r=p("CLS",0),i=d(t,r,P,n.reportAllChanges),l((()=>i()))})),setTimeout(i))})))})((e=>{const n=(t=>{let e={};if(t.entries.length){const n=t.entries.reduce(((t,e)=>t.value>e.value?t:e));if(n?.sources?.length){const t=S(n.sources);t&&(e={largestShiftTarget:s.get(t),largestShiftTime:n.startTime,largestShiftValue:n.value,largestShiftSource:t,largestShiftEntry:n,loadState:o(n.startTime)})}}return Object.assign(t,{attribution:e})})(e);t(n)}),n)},t.onFCP=(t,e={})=>{L((e=>{const i=(t=>{let e={timeToFirstByte:0,firstByteToFCP:t.value,loadState:o(f())};if(t.entries.length){const i=n(),r=t.entries.at(-1);if(i){const n=i.activationStart||0,s=Math.max(0,i.responseStart-n);e={timeToFirstByte:s,firstByteToFCP:t.value-s,loadState:o(t.entries[0].startTime),navigationEntry:i,fcpEntry:r}}}return Object.assign(t,{attribution:e})})(e);t(i)}),e)},t.onINP=(t,e={})=>{const n=a(e=Object.assign({},e),I);let i=[],s=[],c=0;const f=new WeakMap,l=new WeakMap;let h=!1;const m=()=>{h||(A(y),h=!0)},y=()=>{const t=n.l.map((t=>f.get(t.entries[0]))),e=s.length-50;s=s.filter(((n,o)=>o>=e||t.includes(n)));const o=new Set;for(const t of s){const e=v(t.startTime,t.processingEnd);for(const t of e)o.add(t)}const r=i.length-1-50;i=i.filter(((t,e)=>t.startTime>c&&e>r||o.has(t))),h=!1};n.p=t=>{const e=t.startTime+t.duration;let n;c=Math.max(c,t.processingEnd);for(let o=s.length-1;o>=0;o--){const i=s[o];if(Math.abs(e-i.renderTime)<=8){n=i,n.startTime=Math.min(t.startTime,n.startTime),n.processingStart=Math.min(t.processingStart,n.processingStart),n.processingEnd=Math.max(t.processingEnd,n.processingEnd),n.entries.push(t);break}}n||(n={startTime:t.startTime,processingStart:t.processingStart,processingEnd:t.processingEnd,renderTime:e,entries:[t]},s.push(n)),(t.interactionId||"first-input"===t.entryType)&&f.set(t,n),m()},n.m=t=>{if(!l.get(t)){const n=t.entries[0].target;if(n){const o=e.generateTarget?.(n)??r(n);l.set(t,o)}}};const v=(t,e)=>{const n=[];for(const o of i)if(!(o.startTime+o.duratione)break;n.push(o)}return n},b=t=>{const e=t.entries[0],i=f.get(e),r=e.processingStart,s=Math.max(e.startTime+e.duration,r),a=Math.min(i.processingEnd,s),c=i.entries.sort(((t,e)=>t.processingStart-e.processingStart)),u=v(e.startTime,a),d=n.h.get(e.interactionId),h={interactionTarget:l.get(d),interactionType:e.name.startsWith("key")?"keyboard":"pointer",interactionTime:e.startTime,nextPaintTime:s,processedEventEntries:c,longAnimationFrameEntries:u,inputDelay:r-e.startTime,processingDuration:a-r,presentationDelay:s-a,loadState:o(e.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};(t=>{if(!t.longAnimationFrameEntries?.length)return;const e=t.interactionTime,n=t.inputDelay,o=t.processingDuration;let i,r,s=0,a=0,c=0,f=0;for(const c of t.longAnimationFrameEntries){a=a+c.startTime+c.duration-c.styleAndLayoutStart;for(const t of c.scripts){const c=t.startTime+t.duration;if(cf&&(r=t.startTime=e+n+o?"presentation-delay":"processing-duration",i=t,f=u)}}const u=t.longAnimationFrameEntries.at(-1),d=u?u.startTime+u.duration:0;d>=e+n+o&&(c=t.nextPaintTime-d),i&&r&&(t.longestScript={entry:i,subpart:r,intersectingDuration:f}),t.totalScriptDuration=s,t.totalStyleAndLayoutDuration=a,t.totalPaintDuration=c,t.totalUnattributedDuration=t.nextPaintTime-e-s-a-c})(h);return Object.assign(t,{attribution:h})};g("long-animation-frame",(t=>{i=i.concat(t),m()})),((t,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=T();E((()=>{O();let o,i=p("INP");const r=a(e,I),s=t=>{A((()=>{for(const e of t)r.u(e);const e=r.M();e&&e.T!==i.value&&(i.value=e.T,i.entries=e.entries,o())}))},c=g("event",s,{durationThreshold:e.durationThreshold??40});o=d(t,i,x,e.reportAllChanges),c&&(c.observe({type:"first-input",buffered:!0}),n.onHidden((()=>{s(c.takeRecords()),o(!0)})),u((()=>{r.v(),i=p("INP"),o=d(t,i,x,e.reportAllChanges)})))}))})((e=>{const n=b(e);t(n)}),e)},t.onLCP=(t,e={})=>{const o=a(e=Object.assign({},e),W),i=new WeakMap;o.p=t=>{const n=t.element;if(n){const o=e.generateTarget?.(n)??r(n);i.set(t,o)}};((t,e={})=>{E((()=>{const n=T();let o,i=p("LCP");const r=a(e,W),s=t=>{e.reportAllChanges||(t=t.slice(-1));for(const e of t)r.u(e),e.startTime{s(c.takeRecords()),c.disconnect(),o(!0)})),r=t=>{t.isTrusted&&(A(n),removeEventListener(t.type,r,{capture:!0}))};for(const t of["keydown","click","visibilitychange"])addEventListener(t,r,{capture:!0});u((n=>{i=p("LCP"),o=d(t,i,q,e.reportAllChanges),l((()=>{i.value=performance.now()-n.timeStamp,o(!0)}))}))}}))})((e=>{const o=(t=>{let e={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:t.value};if(t.entries.length){const o=n();if(o){const n=o.activationStart||0,r=t.entries.at(-1),s=r.url&&performance.getEntriesByType("resource").filter((t=>t.name===r.url))[0],a=Math.max(0,o.responseStart-n),c=Math.max(a,s?(s.requestStart||s.startTime)-n:0),f=Math.min(t.value,Math.max(c,s?s.responseEnd-n:0));e={target:i.get(r),timeToFirstByte:a,resourceLoadDelay:c-a,resourceLoadDuration:f-c,elementRenderDelay:t.value-f,navigationEntry:o,lcpEntry:r},r.url&&(e.url=r.url),s&&(e.lcpResourceEntry=s)}}return Object.assign(t,{attribution:e})})(e);t(o)}),e)},t.onTTFB=(t,e={})=>{((t,e={})=>{let o=p("TTFB"),i=d(t,o,N,e.reportAllChanges);H((()=>{const r=n();r&&(o.value=Math.max(r.responseStart-h(),0),o.entries=[r],i(!0),u((()=>{o=p("TTFB",0),i=d(t,o,N,e.reportAllChanges),i(!0)})))}))})((e=>{const n=(t=>{let e={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(t.entries.length){const n=t.entries[0],o=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-o,0),r=Math.max(n.domainLookupStart-o,0),s=Math.max(n.connectStart-o,0),a=Math.max(n.connectEnd-o,0);e={waitingDuration:i,cacheDuration:r-i,dnsDuration:s-r,connectionDuration:a-s,requestDuration:t.value-a,navigationEntry:n}}return Object.assign(t,{attribution:e})})(e);t(n)}),e)}}));