"use strict";(()=>{var se=Object.defineProperty;var ae=(i,e,t)=>e in i?se(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>ae(i,typeof e!="symbol"?e+"":e,t);function oe(i){let e="__DOUBLE_ASTERISK_TOKEN__",t="__SINGLE_ASTERISK_TOKEN__",n=i.replace(/\*\*/g,e).replace(/\*/g,t).replace(/[.+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(`/${e}/`,"g"),"/(?:.+/)?"),n=n.replace(new RegExp(e,"g"),".*"),n=n.replace(/\//g,"\\/");let o=n.replace(new RegExp(t,"g"),"[^/]+");return new RegExp("^"+o+"$")}function k(i,e){for(let t of e)try{if(oe(t).test(i))return t}catch(r){console.error(`Invalid pattern: ${t}`,r)}return null}function F(i,e){let t=null;return(...r)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...r),e)}}function N(i){try{let e=window.location.hostname,t=new URL(i).hostname;return t!==e&&t!==""}catch{return!1}}function P(i,e){if(!i)return e;try{let t=JSON.parse(i);return Array.isArray(e)&&!Array.isArray(t)?e:t}catch(t){return console.error("Error parsing JSON:",t),e}}function W(i){let e=i.getAttribute("src");if(!e)return console.error("Script src attribute is missing"),null;let t=e.split("/script.js")[0];if(!t)return console.error("Please provide a valid analytics host"),null;let r=i.getAttribute("data-site-id")||i.getAttribute("site-id");if(!r||isNaN(Number(r)))return console.error("Please provide a valid site ID using the data-site-id attribute"),null;let n=i.getAttribute("data-debounce")?Math.max(0,parseInt(i.getAttribute("data-debounce"))):500,o=P(i.getAttribute("data-skip-patterns"),[]),c=P(i.getAttribute("data-mask-patterns"),[]),s=i.getAttribute("data-api-key")||void 0,a=i.getAttribute("data-replay-batch-size")?Math.max(1,parseInt(i.getAttribute("data-replay-batch-size"))):25,d=i.getAttribute("data-replay-batch-interval")?Math.max(1e3,parseInt(i.getAttribute("data-replay-batch-interval"))):2e3;return{analyticsHost:t,siteId:r,debounceDuration:n,autoTrackPageview:i.getAttribute("data-auto-track-pageview")!=="false",autoTrackSpa:i.getAttribute("data-track-spa")!=="false",trackQuerystring:i.getAttribute("data-track-query")!=="false",trackOutbound:i.getAttribute("data-track-outbound")!=="false",enableWebVitals:i.getAttribute("data-web-vitals")==="true",trackErrors:i.getAttribute("data-track-errors")==="true",enableSessionReplay:i.getAttribute("data-session-replay")==="true",sessionReplayBatchSize:a,sessionReplayBatchInterval:d,skipPatterns:o,maskPatterns:c,apiKey:s}}var v=class{constructor(e,t,r){l(this,"config");l(this,"isRecording",!1);l(this,"stopRecordingFn");l(this,"userId");l(this,"eventBuffer",[]);l(this,"batchTimer");l(this,"sendBatch");this.config=e,this.userId=t,this.sendBatch=r}async initialize(){this.config.enableSessionReplay&&(window.rrweb||await this.loadRrweb(),window.rrweb&&this.startRecording())}async loadRrweb(){return new Promise((e,t)=>{let r=document.createElement("script");r.src=`${this.config.analyticsHost}/replay.js`,r.async=!1,r.onload=()=>{e()},r.onerror=()=>t(new Error("Failed to load rrweb")),document.head.appendChild(r)})}startRecording(){if(!(this.isRecording||!window.rrweb||!this.config.enableSessionReplay))try{this.stopRecordingFn=window.rrweb.record({emit:e=>{this.addEvent({type:e.type,data:e.data,timestamp:e.timestamp||Date.now()})},recordCanvas:!0,collectFonts:!0,checkoutEveryNms:3e4,checkoutEveryNth:200,maskAllInputs:!0,maskInputOptions:{password:!0,email:!0},slimDOMOptions:{script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},sampling:{mousemove:!1,mouseInteraction:!0,scroll:150,input:"last"}}),this.isRecording=!0,this.setupBatchTimer()}catch{}}stopRecording(){this.isRecording&&(this.stopRecordingFn&&this.stopRecordingFn(),this.isRecording=!1,this.clearBatchTimer(),this.eventBuffer.length>0&&this.flushEvents())}isActive(){return this.isRecording}addEvent(e){this.eventBuffer.push(e),this.eventBuffer.length>=this.config.sessionReplayBatchSize&&this.flushEvents()}setupBatchTimer(){this.clearBatchTimer(),this.batchTimer=window.setInterval(()=>{this.eventBuffer.length>0&&this.flushEvents()},this.config.sessionReplayBatchInterval)}clearBatchTimer(){this.batchTimer&&(clearInterval(this.batchTimer),this.batchTimer=void 0)}async flushEvents(){if(this.eventBuffer.length===0)return;let e=[...this.eventBuffer];this.eventBuffer=[];let t={userId:this.userId,events:e,metadata:{pageUrl:window.location.href,viewportWidth:screen.width,viewportHeight:screen.height,language:navigator.language}};try{await this.sendBatch(t)}catch{this.eventBuffer.unshift(...e)}}updateUserId(e){this.userId=e}onPageChange(){this.isRecording&&this.flushEvents()}cleanup(){this.stopRecording()}};var y=class{constructor(e){l(this,"config");l(this,"customUserId",null);l(this,"sessionReplayRecorder");this.config=e,this.loadUserId(),e.enableSessionReplay&&this.initializeSessionReplay()}loadUserId(){try{let e=localStorage.getItem("flyrank-user-id");e&&(this.customUserId=e)}catch{}}async initializeSessionReplay(){try{this.sessionReplayRecorder=new v(this.config,this.customUserId||"",e=>this.sendSessionReplayBatch(e)),await this.sessionReplayRecorder.initialize()}catch(e){console.error("Failed to initialize session replay:",e)}}async sendSessionReplayBatch(e){try{await fetch(`${this.config.analyticsHost}/session-replay/record/${this.config.siteId}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),mode:"cors",keepalive:!1})}catch(t){throw console.error("Failed to send session replay batch:",t),t}}createBasePayload(){let e=new URL(window.location.href),t=e.pathname;if(e.hash&&e.hash.startsWith("#/")&&(t=e.hash.substring(1)),k(t,this.config.skipPatterns))return null;let r=k(t,this.config.maskPatterns);r&&(t=r);let n=this.getDeviceInfo(),o={site_id:this.config.siteId,hostname:e.hostname,pathname:t,querystring:this.config.trackQuerystring?e.search:"",screenWidth:window.innerWidth,screenHeight:window.innerHeight,language:navigator.language,page_title:document.title,referrer:document.referrer,...n};return this.customUserId&&(o.user_id=this.customUserId),o}async sendTrackingData(e){try{await fetch(`${this.config.analyticsHost}/track`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),mode:"cors",keepalive:!0})}catch(t){console.error("Failed to send tracking data:",t)}}track(e,t="",r={}){if(e==="custom_event"&&(!t||typeof t!="string")){console.error("Event name is required and must be a string for custom events");return}let n=this.createBasePayload();if(!n)return;let o={...n,type:e,event_name:t,properties:e==="custom_event"||e==="outbound"?JSON.stringify(r):void 0};this.sendTrackingData(o)}trackPageview(){this.track("pageview")}trackEvent(e,t={}){this.track("custom_event",e,t)}trackOutbound(e,t="",r="_self"){this.track("outbound","",{url:e,text:t,target:r})}trackWebVitals(e){let t=this.createBasePayload();if(!t)return;let r={...t,type:"performance",event_name:"web-vitals",...e};this.sendTrackingData(r)}identify(e){if(typeof e!="string"||e.trim()===""){console.error("User ID must be a non-empty string");return}this.customUserId=e.trim();try{localStorage.setItem("flyrank-user-id",this.customUserId)}catch{console.warn("Could not persist user ID to localStorage")}this.sessionReplayRecorder&&this.sessionReplayRecorder.updateUserId(this.customUserId)}clearUserId(){this.customUserId=null;try{localStorage.removeItem("flyrank-user-id")}catch{}}getUserId(){return this.customUserId}startSessionReplay(){this.sessionReplayRecorder?this.sessionReplayRecorder.startRecording():console.warn("Session replay not initialized")}stopSessionReplay(){this.sessionReplayRecorder&&this.sessionReplayRecorder.stopRecording()}isSessionReplayActive(){return this.sessionReplayRecorder?.isActive()??!1}onPageChange(){this.sessionReplayRecorder&&this.sessionReplayRecorder.onPageChange()}cleanup(){this.sessionReplayRecorder&&this.sessionReplayRecorder.cleanup()}getDeviceInfo(){let e=navigator.userAgent,t={};if(e.includes("Chrome")&&!e.includes("Edg")){t.browser="Chrome";let s=e.match(/Chrome\/(\d+)/);s&&(t.browser_version=s[1])}else if(e.includes("Firefox")){t.browser="Firefox";let s=e.match(/Firefox\/(\d+)/);s&&(t.browser_version=s[1])}else if(e.includes("Safari")&&!e.includes("Chrome")){t.browser="Safari";let s=e.match(/Version\/(\d+)/);s&&(t.browser_version=s[1])}else if(e.includes("Edg")){t.browser="Edge";let s=e.match(/Edg\/(\d+)/);s&&(t.browser_version=s[1])}else if(e.includes("Opera")||e.includes("OPR")){t.browser="Opera";let s=e.match(/(?:Opera|OPR)\/(\d+)/);s&&(t.browser_version=s[1])}if(e.includes("Windows NT")){t.operating_system="Windows";let s=e.match(/Windows NT ([\d.]+)/);if(s){let a=s[1];a==="10.0"?t.operating_system_version="10":a==="6.3"?t.operating_system_version="8.1":a==="6.2"?t.operating_system_version="8":a==="6.1"?t.operating_system_version="7":t.operating_system_version=a}}else if(e.includes("Mac OS X")){t.operating_system="macOS";let s=e.match(/Mac OS X ([\d_]+)/);s&&(t.operating_system_version=s[1].replace(/_/g,"."))}else if(e.includes("Linux"))t.operating_system="Linux";else if(e.includes("Android")){t.operating_system="Android";let s=e.match(/Android ([\d.]+)/);s&&(t.operating_system_version=s[1])}else if(e.includes("iPhone")||e.includes("iPad")){t.operating_system="iOS";let s=e.match(/OS ([\d_]+)/);s&&(t.operating_system_version=s[1].replace(/_/g,"."))}let r=window.innerWidth,n=window.innerHeight,o=Math.max(r,n),c=Math.min(r,n);return o>1024?t.device_type="Desktop":o>768&&c>1024?t.device_type="Tablet":t.device_type="Mobile",e.includes("Mobile")||e.includes("Android")||e.includes("iPhone")?t.device_type="Mobile":(e.includes("iPad")||e.includes("Tablet"))&&(t.device_type="Tablet"),t}};var Q=-1,m=i=>{addEventListener("pageshow",e=>{e.persisted&&(Q=e.timeStamp,i(e))},!0)},u=(i,e,t,r)=>{let n,o;return c=>{e.value>=0&&(c||r)&&(o=e.value-(n??0),(o||n===void 0)&&(n=e.value,e.delta=o,e.rating=((s,a)=>s>a[1]?"poor":s>a[0]?"needs-improvement":"good")(e.value,t),i(e)))}},O=i=>{requestAnimationFrame(()=>requestAnimationFrame(()=>i()))},B=()=>{let i=performance.getEntriesByType("navigation")[0];if(i&&i.responseStart>0&&i.responseStartB()?.activationStart??0,h=(i,e=-1)=>{let t=B(),r="navigate";return Q>=0?r="back-forward-cache":t&&(document.prerendering||f()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-"))),{name:i,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},_=new WeakMap;function D(i,e){return _.get(i)||_.set(i,new e),_.get(i)}var E=class{constructor(){l(this,"t");l(this,"i",0);l(this,"o",[])}h(e){if(e.hadRecentInput)return;let t=this.o[0],r=this.o.at(-1);this.i&&t&&r&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},g=(i,e,t={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(i)){let r=new PerformanceObserver(n=>{Promise.resolve().then(()=>{e(n.getEntries())})});return r.observe({type:i,buffered:!0,...t}),r}}catch{}},x=i=>{let e=!1;return()=>{e||(i(),e=!0)}},p=-1,H=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,w=i=>{document.visibilityState==="hidden"&&p>-1&&(p=i.type==="visibilitychange"?i.timeStamp:0,ce())},V=()=>{addEventListener("visibilitychange",w,!0),addEventListener("prerenderingchange",w,!0)},ce=()=>{removeEventListener("visibilitychange",w,!0),removeEventListener("prerenderingchange",w,!0)},X=()=>{if(p<0){let i=f();p=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>t.name==="hidden"&&t.startTime>i)[0]?.startTime)??H(),V(),m(()=>{setTimeout(()=>{p=H(),V()})})}return{get firstHiddenTime(){return p}}},R=i=>{document.prerendering?addEventListener("prerenderingchange",()=>i(),!0):i()},z=[1800,3e3],U=(i,e={})=>{R(()=>{let t=X(),r,n=h("FCP"),o=g("paint",c=>{for(let s of c)s.name==="first-contentful-paint"&&(o.disconnect(),s.startTime{n=h("FCP"),r=u(i,n,z,e.reportAllChanges),O(()=>{n.value=performance.now()-c.timeStamp,r(!0)})}))})},$=[.1,.25],Y=(i,e={})=>{U(x(()=>{let t,r=h("CLS",0),n=D(e,E),o=s=>{for(let a of s)n.h(a);n.i>r.value&&(r.value=n.i,r.entries=n.o,t())},c=g("layout-shift",o);c&&(t=u(i,r,$,e.reportAllChanges),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(o(c.takeRecords()),t(!0))}),m(()=>{n.i=0,r=h("CLS",0),t=u(i,r,$,e.reportAllChanges),O(()=>t())}),setTimeout(t))}))},Z=0,I=1/0,b=0,le=i=>{for(let e of i)e.interactionId&&(I=Math.min(I,e.interactionId),b=Math.max(b,e.interactionId),Z=b?(b-I)/7+1:0)},C,K=()=>C?Z:performance.interactionCount??0,de=()=>{"interactionCount"in performance||C||(C=g("event",le,{type:"event",buffered:!0,durationThreshold:0}))},J=0,A=class{constructor(){l(this,"u",[]);l(this,"l",new Map);l(this,"m");l(this,"v")}p(){J=K(),this.u.length=0,this.l.clear()}P(){let e=Math.min(this.u.length-1,Math.floor((K()-J)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let t=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>t.T){if(r?e.duration>r.T?(r.entries=[e],r.T=e.duration):e.duration===r.T&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],T:e.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort((n,o)=>o.T-n.T),this.u.length>10){let n=this.u.splice(10);for(let o of n)this.l.delete(o.id)}this.v?.(r)}}},ee=i=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?i():(i=x(i),document.addEventListener("visibilitychange",i,{once:!0}),e(()=>{i(),document.removeEventListener("visibilitychange",i)}))},q=[200,500],te=(i,e={})=>{globalThis.PerformanceEventTiming&&"interactionId"in PerformanceEventTiming.prototype&&R(()=>{de();let t,r=h("INP"),n=D(e,A),o=s=>{ee(()=>{for(let d of s)n.h(d);let a=n.P();a&&a.T!==r.value&&(r.value=a.T,r.entries=a.entries,t())})},c=g("event",o,{durationThreshold:e.durationThreshold??40});t=u(i,r,q,e.reportAllChanges),c&&(c.observe({type:"first-input",buffered:!0}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(o(c.takeRecords()),t(!0))}),m(()=>{n.p(),r=h("INP"),t=u(i,r,q,e.reportAllChanges)}))})},L=class{constructor(){l(this,"m")}h(e){this.m?.(e)}},j=[2500,4e3],ie=(i,e={})=>{R(()=>{let t=X(),r,n=h("LCP"),o=D(e,L),c=a=>{e.reportAllChanges||(a=a.slice(-1));for(let d of a)o.h(d),d.startTime{c(s.takeRecords()),s.disconnect(),r(!0)});for(let d of["keydown","click","visibilitychange"])addEventListener(d,()=>ee(a),{capture:!0,once:!0});m(d=>{n=h("LCP"),r=u(i,n,j,e.reportAllChanges),O(()=>{n.value=performance.now()-d.timeStamp,r(!0)})})}})},G=[800,1800],M=i=>{document.prerendering?R(()=>M(i)):document.readyState!=="complete"?addEventListener("load",()=>M(i),!0):setTimeout(i)},re=(i,e={})=>{let t=h("TTFB"),r=u(i,t,G,e.reportAllChanges);M(()=>{let n=B();n&&(t.value=Math.max(n.responseStart-f(),0),t.entries=[n],r(!0),m(()=>{t=h("TTFB",0),r=u(i,t,G,e.reportAllChanges),r(!0)}))})};var S=class{constructor(e){l(this,"data",{lcp:null,cls:null,inp:null,fcp:null,ttfb:null});l(this,"sent",!1);l(this,"timeout",null);l(this,"onReadyCallback",null);this.onReadyCallback=e}initialize(){try{ie(this.collectMetric.bind(this)),Y(this.collectMetric.bind(this)),te(this.collectMetric.bind(this)),U(this.collectMetric.bind(this)),re(this.collectMetric.bind(this)),this.timeout=setTimeout(()=>{this.sent||this.sendData()},2e4),window.addEventListener("beforeunload",()=>{this.sent||this.sendData()})}catch(e){console.warn("Error initializing web vitals tracking:",e)}}collectMetric(e){if(this.sent)return;let t=e.name.toLowerCase();this.data[t]=e.value,Object.values(this.data).every(n=>n!==null)&&this.sendData()}sendData(){this.sent||(this.sent=!0,this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.onReadyCallback&&this.onReadyCallback(this.data))}getData(){return{...this.data}}};(function(){let i=document.currentScript;if(!i){console.error("Could not find current script tag");return}if(window.__FLYRANK_OPTOUT__||localStorage.getItem("disable-flyrank")!==null){window.flyrank={pageview:()=>{},event:()=>{},trackOutbound:()=>{},identify:()=>{},clearUserId:()=>{},getUserId:()=>null,startSessionReplay:()=>{},stopSessionReplay:()=>{},isSessionReplayActive:()=>!1};return}let e=W(i);if(!e)return;let t=new y(e);e.enableWebVitals&&new S(s=>{t.trackWebVitals(s)}).initialize();let r=()=>t.trackPageview(),n=e.debounceDuration>0?F(r,e.debounceDuration):r;function o(){if(document.addEventListener("click",function(c){let s=c.target;for(;s&&s!==document.documentElement;){if(s.hasAttribute("data-flyrank-event")){let a=s.getAttribute("data-flyrank-event");if(a){let d={};for(let T of s.attributes)if(T.name.startsWith("data-flyrank-prop-")){let ne=T.name.replace("data-flyrank-prop-","");d[ne]=T.value}t.trackEvent(a,d)}break}s=s.parentElement}if(e.trackOutbound){let a=c.target.closest("a");a?.href&&N(a.href)&&t.trackOutbound(a.href,a.innerText||a.textContent||"",a.target||"_self")}}),e.autoTrackSpa){let c=history.pushState,s=history.replaceState;history.pushState=function(...a){c.apply(this,a),n()},history.replaceState=function(...a){s.apply(this,a),n()},window.addEventListener("popstate",n),window.addEventListener("hashchange",n)}}window.flyrank={pageview:()=>t.trackPageview(),event:(c,s={})=>t.trackEvent(c,s),trackOutbound:(c,s="",a="_self")=>t.trackOutbound(c,s,a),identify:c=>t.identify(c),clearUserId:()=>t.clearUserId(),getUserId:()=>t.getUserId(),startSessionReplay:()=>t.startSessionReplay(),stopSessionReplay:()=>t.stopSessionReplay(),isSessionReplayActive:()=>t.isSessionReplayActive()},o(),e.autoTrackPageview&&t.trackPageview()})();})();