(()=>{"use strict";class t{getPerformanceMetrics(){const t={};try{window.performance&&(t.timeOrigin=performance.timeOrigin)}catch(t){console.warn("Failed to collect performance metrics:",t)}return t}}var e=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart=0?o="back-forward-cache":a&&(document.prerendering||r()>0?o="prerender":document.wasDiscarded?o="restore":a.type&&(o=a.type.replace(/_/g,"-"))),{name:t,value:void 0===i?-1:i,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o}},a=function(t,e,n,r){var i,a;return function(o){e.value>=0&&(o||r)&&((a=e.value-(i||0))||void 0===i)&&(i=e.value,e.delta=a,e.rating=function(t,e){return t>e[1]?"poor":t>e[0]?"needs-improvement":"good"}(e.value,n),t(e))}},o=[],s=new Map,c=function(t){var e=self.requestIdleCallback||self.setTimeout,n=-1;return t=function(t){var e=!1;return function(){e||(t(),e=!0)}}(t),"hidden"===document.visibilityState?t():(n=e(t),function(t){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t()}))}(t)),n},u=[],d=[],l=0,f=new WeakMap,h=new Map,m=-1,p=function(){h.size>10&&h.forEach((function(t,e){s.has(e)||h.delete(e)}));var t=o.map((function(t){return f.get(t.entries[0])})),e=d.length-50;d=d.filter((function(n,r){return r>=e||t.includes(n)}));for(var n=new Set,r=0;rl&&e>a||n.has(t)})),m=-1};[].push((function(t){t.interactionId&&t.target&&!h.has(t.interactionId)&&h.set(t.interactionId,t.target)}),(function(t){var e,n=t.startTime+t.duration;l=Math.max(l,t.processingEnd);for(var r=d.length-1;r>=0;r--){var i=d[r];if(Math.abs(n-i.renderTime)<=8){(e=i).startTime=Math.min(t.startTime,e.startTime),e.processingStart=Math.min(t.processingStart,e.processingStart),e.processingEnd=Math.max(t.processingEnd,e.processingEnd),e.entries.push(t);break}}e||(e={startTime:t.startTime,processingStart:t.processingStart,processingEnd:t.processingEnd,renderTime:n,entries:[t]},d.push(e)),(t.interactionId||"first-input"===t.entryType)&&f.set(t,e),m<0&&(m=c(p))}));var g=function(t,e){for(var n,r=[],i=0;n=u[i];i++)if(!(n.startTime+n.duratione)break;r.push(n)}return r},v=[800,1800],T=function t(e){document.prerendering?function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()}((function(){return t(e)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(e)}),!0):setTimeout(e,0)},w=function(t,o){o=o||{};var s=i("TTFB"),c=a(t,s,v,o.reportAllChanges);T((function(){var u=e();u&&(s.value=Math.max(u.responseStart-r(),0),s.entries=[u],c(!0),function(t){addEventListener("pageshow",(function(e){e.persisted&&(n=e.timeStamp,t(e))}),!0)}((function(){s=i("TTFB",0),(c=a(t,s,v,o.reportAllChanges))(!0)})))}))};new Date;class D{metrics={};constructor(e){var n;this.analyticsService=e,this.performanceService=new t,n=this.handleMetric.bind(this),w((function(t){var e=function(t){var e={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(t.entries.length){var n=t.entries[0],r=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-r,0),a=Math.max(n.domainLookupStart-r,0),o=Math.max(n.connectStart-r,0),s=Math.max(n.connectEnd-r,0);e={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:t.value-s,navigationEntry:n}}return Object.assign(t,{attribution:e})}(t);n(e)}),void 0)}parseTTFB(t){if(t)return{value:t.value,rating:t.rating,attribution:{cacheDuration:t.attribution.cacheDuration,connectionDuration:t.attribution.connectionDuration,dnsDuration:t.attribution.dnsDuration,requestDuration:t.attribution.requestDuration,waitingDuration:t.attribution.waitingDuration},navigationType:t.navigationType}}handleMetric(t){t&&("TTFB"===t.name?(this.metrics.ttfb=this.parseTTFB(t),this.analyticsService.handledMetric(t.name)):console.warn(`Unknown metric: ${t.name}`))}getMetrics(){return this.metrics.performance=this.performanceService.getPerformanceMetrics(),this.metrics}}const S=(new class{scriptSelector="script.elementor-browser-metrics[data-request-info]";requestInfoAttribute="data-request-info";getRequestData(){try{const t=document.querySelector(this.scriptSelector);if(!t)return null;const e=t.getAttribute(this.requestInfoAttribute);return e?JSON.parse(e):null}catch(t){return console.warn("Failed to parse request data:",t),null}}}).getRequestData();S?new class{sentTTFB=!1;constructor(t){this.requestData=t,this.metricsCollector=new D(this)}handledMetric(t){"TTFB"===t&&this.sendTTFB()}sendTTFB(){if(this.sentTTFB)return;const t=this.getAnalyticsData();t?.metrics?.ttfb&&(this.sentTTFB=!0,this.sendMetrics(t))}getAnalyticsData(){return{metrics:this.metricsCollector.getMetrics(),timestamp:Date.now(),url:window.location.href,traceparent:this.requestData.traceparent,version:this.requestData.version}}sendMetrics(t){if(t)try{const e=JSON.stringify(t);if(navigator.sendBeacon){const t=new Blob([e],{type:"application/json"});navigator.sendBeacon(this.requestData.endpoint,t)||console.warn("Failed to send metrics via beacon")}else fetch(this.requestData.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch((()=>{console.warn("Failed to send metrics via fetch")}))}catch(t){console.warn("Failed to send metrics:",t)}}}(S):console.warn("Request data not found")})();