"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__",s=i.replace(/\*\*/g,e).replace(/\*/g,t).replace(/[.+?^${}()|[\]\\]/g,"\\$&");s=s.replace(new RegExp(`/${e}/`,"g"),"/(?:.+/)?"),s=s.replace(new RegExp(e,"g"),".*"),s=s.replace(/\//g,"\\/");let c=s.replace(new RegExp(t,"g"),"[^/]+");return new RegExp("^"+c+"$")}function T(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 U(i,e){let t=null;return(...r)=>{t&&clearTimeout(t),t=setTimeout(()=>i(...r),e)}}function F(i){try{let e=window.location.hostname,t=new URL(i).hostname;return t!==e&&t!==""}catch{return!1}}function E(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 s=i.getAttribute("data-debounce")?Math.max(0,parseInt(i.getAttribute("data-debounce"))):500,c=E(i.getAttribute("data-skip-patterns"),[]),a=E(i.getAttribute("data-mask-patterns"),[]),n=i.getAttribute("data-api-key")||void 0,o=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:s,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:o,sessionReplayBatchInterval:d,skipPatterns:c,maskPatterns:a,apiKey:n}}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)),T(t,this.config.skipPatterns))return null;let r=T(t,this.config.maskPatterns);r&&(t=r);let s=this.getDeviceInfo(),c={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,...s};return this.customUserId&&(c.user_id=this.customUserId),c}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 s=this.createBasePayload();if(!s)return;let c={...s,type:e,event_name:t,properties:e==="custom_event"||e==="outbound"?JSON.stringify(r):void 0};this.sendTrackingData(c)}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)}trackError(e,t={}){let r=window.location.origin,s=t.filename||"",c=e.stack||"";if(s)try{if(new URL(s).origin!==r)return}catch{}else if(c&&!c.includes(r))return;let a={message:e.message?.substring(0,500)||"Unknown error",stack:c.substring(0,2e3)||""};if(s&&(a.fileName=s),t.lineno){let n=typeof t.lineno=="string"?parseInt(t.lineno,10):t.lineno;n&&n!==0&&(a.lineNumber=n)}if(t.colno){let n=typeof t.colno=="string"?parseInt(t.colno,10):t.colno;n&&n!==0&&(a.columnNumber=n)}for(let n in t)!["lineno","colno"].includes(n)&&t[n]!==void 0&&(a[n]=t[n]);this.track("error",e.name||"Error",a)}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}isErrorTrackingActive(){return this.config.trackErrors??!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 n=e.match(/Chrome\/(\d+)/);n&&(t.browser_version=n[1])}else if(e.includes("Firefox")){t.browser="Firefox";let n=e.match(/Firefox\/(\d+)/);n&&(t.browser_version=n[1])}else if(e.includes("Safari")&&!e.includes("Chrome")){t.browser="Safari";let n=e.match(/Version\/(\d+)/);n&&(t.browser_version=n[1])}else if(e.includes("Edg")){t.browser="Edge";let n=e.match(/Edg\/(\d+)/);n&&(t.browser_version=n[1])}else if(e.includes("Opera")||e.includes("OPR")){t.browser="Opera";let n=e.match(/(?:Opera|OPR)\/(\d+)/);n&&(t.browser_version=n[1])}if(e.includes("Windows NT")){t.operating_system="Windows";let n=e.match(/Windows NT ([\d.]+)/);if(n){let o=n[1];o==="10.0"?t.operating_system_version="10":o==="6.3"?t.operating_system_version="8.1":o==="6.2"?t.operating_system_version="8":o==="6.1"?t.operating_system_version="7":t.operating_system_version=o}}else if(e.includes("Mac OS X")){t.operating_system="macOS";let n=e.match(/Mac OS X ([\d_]+)/);n&&(t.operating_system_version=n[1].replace(/_/g,"."))}else if(e.includes("Linux"))t.operating_system="Linux";else if(e.includes("Android")){t.operating_system="Android";let n=e.match(/Android ([\d.]+)/);n&&(t.operating_system_version=n[1])}else if(e.includes("iPhone")||e.includes("iPad")){t.operating_system="iOS";let n=e.match(/OS ([\d_]+)/);n&&(t.operating_system_version=n[1].replace(/_/g,"."))}let r=window.innerWidth,s=window.innerHeight,c=Math.max(r,s),a=Math.min(r,s);return c>1024?t.device_type="Desktop":c>768&&a>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,g=i=>{addEventListener("pageshow",e=>{e.persisted&&(Q=e.timeStamp,i(e))},!0)},u=(i,e,t,r)=>{let s,c;return a=>{e.value>=0&&(a||r)&&(c=e.value-(s??0),(c||s===void 0)&&(s=e.value,e.delta=c,e.rating=((n,o)=>n>o[1]?"poor":n>o[0]?"needs-improvement":"good")(e.value,t),i(e)))}},M=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||m()>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}},P=new WeakMap;function D(i,e){return P.get(i)||P.set(i,new e),P.get(i)}var I=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)}},f=(i,e,t={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(i)){let r=new PerformanceObserver(s=>{Promise.resolve().then(()=>{e(s.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=m();p=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>t.name==="hidden"&&t.startTime>i)[0]?.startTime)??H(),V(),g(()=>{setTimeout(()=>{p=H(),V()})})}return{get firstHiddenTime(){return p}}},R=i=>{document.prerendering?addEventListener("prerenderingchange",()=>i(),!0):i()},z=[1800,3e3],N=(i,e={})=>{R(()=>{let t=X(),r,s=h("FCP"),c=f("paint",a=>{for(let n of a)n.name==="first-contentful-paint"&&(c.disconnect(),n.startTime{s=h("FCP"),r=u(i,s,z,e.reportAllChanges),M(()=>{s.value=performance.now()-a.timeStamp,r(!0)})}))})},$=[.1,.25],Y=(i,e={})=>{N(x(()=>{let t,r=h("CLS",0),s=D(e,I),c=n=>{for(let o of n)s.h(o);s.i>r.value&&(r.value=s.i,r.entries=s.o,t())},a=f("layout-shift",c);a&&(t=u(i,r,$,e.reportAllChanges),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(c(a.takeRecords()),t(!0))}),g(()=>{s.i=0,r=h("CLS",0),t=u(i,r,$,e.reportAllChanges),M(()=>t())}),setTimeout(t))}))},Z=0,_=1/0,b=0,le=i=>{for(let e of i)e.interactionId&&(_=Math.min(_,e.interactionId),b=Math.max(b,e.interactionId),Z=b?(b-_)/7+1:0)},C,K=()=>C?Z:performance.interactionCount??0,de=()=>{"interactionCount"in performance||C||(C=f("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((s,c)=>c.T-s.T),this.u.length>10){let s=this.u.splice(10);for(let c of s)this.l.delete(c.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)}))},j=[200,500],te=(i,e={})=>{globalThis.PerformanceEventTiming&&"interactionId"in PerformanceEventTiming.prototype&&R(()=>{de();let t,r=h("INP"),s=D(e,A),c=n=>{ee(()=>{for(let d of n)s.h(d);let o=s.P();o&&o.T!==r.value&&(r.value=o.T,r.entries=o.entries,t())})},a=f("event",c,{durationThreshold:e.durationThreshold??40});t=u(i,r,j,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&(c(a.takeRecords()),t(!0))}),g(()=>{s.p(),r=h("INP"),t=u(i,r,j,e.reportAllChanges)}))})},L=class{constructor(){l(this,"m")}h(e){this.m?.(e)}},q=[2500,4e3],ie=(i,e={})=>{R(()=>{let t=X(),r,s=h("LCP"),c=D(e,L),a=o=>{e.reportAllChanges||(o=o.slice(-1));for(let d of o)c.h(d),d.startTime{a(n.takeRecords()),n.disconnect(),r(!0)});for(let d of["keydown","click","visibilitychange"])addEventListener(d,()=>ee(o),{capture:!0,once:!0});g(d=>{s=h("LCP"),r=u(i,s,q,e.reportAllChanges),M(()=>{s.value=performance.now()-d.timeStamp,r(!0)})})}})},G=[800,1800],O=i=>{document.prerendering?R(()=>O(i)):document.readyState!=="complete"?addEventListener("load",()=>O(i),!0):setTimeout(i)},re=(i,e={})=>{let t=h("TTFB"),r=u(i,t,G,e.reportAllChanges);O(()=>{let s=B();s&&(t.value=Math.max(s.responseStart-m(),0),t.entries=[s],r(!0),g(()=>{t=h("TTFB",0),r=u(i,t,G,e.reportAllChanges),r(!0)}))})};var k=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)),N(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(s=>s!==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,trackError:()=>{},startSessionReplay:()=>{},stopSessionReplay:()=>{},isSessionReplayActive:()=>!1,isErrorTrackingActive:()=>!1};return}let e=W(i);if(!e)return;let t=new y(e);e.enableWebVitals&&new k(n=>{t.trackWebVitals(n)}).initialize(),e.trackErrors&&(window.addEventListener("error",a=>{t.trackError(a.error||new Error(a.message),{filename:a.filename,lineno:a.lineno,colno:a.colno})}),window.addEventListener("unhandledrejection",a=>{let n=a.reason instanceof Error?a.reason:new Error(String(a.reason));t.trackError(n,{type:"unhandledrejection"})}));let r=()=>t.trackPageview(),s=e.debounceDuration>0?U(r,e.debounceDuration):r;function c(){if(document.addEventListener("click",function(a){let n=a.target;for(;n&&n!==document.documentElement;){if(n.hasAttribute("data-flyrank-event")){let o=n.getAttribute("data-flyrank-event");if(o){let d={};for(let S of n.attributes)if(S.name.startsWith("data-flyrank-prop-")){let ne=S.name.replace("data-flyrank-prop-","");d[ne]=S.value}t.trackEvent(o,d)}break}n=n.parentElement}if(e.trackOutbound){let o=a.target.closest("a");o?.href&&F(o.href)&&t.trackOutbound(o.href,o.innerText||o.textContent||"",o.target||"_self")}}),e.autoTrackSpa){let a=history.pushState,n=history.replaceState;history.pushState=function(...o){a.apply(this,o),s()},history.replaceState=function(...o){n.apply(this,o),s()},window.addEventListener("popstate",s),window.addEventListener("hashchange",s)}}window.flyrank={pageview:()=>t.trackPageview(),event:(a,n={})=>t.trackEvent(a,n),trackOutbound:(a,n="",o="_self")=>t.trackOutbound(a,n,o),identify:a=>t.identify(a),clearUserId:()=>t.clearUserId(),getUserId:()=>t.getUserId(),trackError:(a,n={})=>{let o=a instanceof Error?a:new Error(String(a));t.trackError(o,n)},isErrorTrackingActive:()=>t.isErrorTrackingActive(),startSessionReplay:()=>t.startSessionReplay(),stopSessionReplay:()=>t.stopSessionReplay(),isSessionReplayActive:()=>t.isSessionReplayActive()},c(),e.autoTrackPageview&&t.trackPageview()})();})();