window.WpStatisticsUserTracker||(window.WpStatisticsUserTracker={lastUrl:window.location.href,originalPushState:history.pushState,originalReplaceState:history.replaceState,isDndActive:parseInt(navigator.msDoNotTrack||window.doNotTrack||navigator.doNotTrack,10),hasTrackerInitializedOnce:!1,hasUrlChangeTrackerInitialized:!1,hitRequestSuccessful:!0,init:function(){this.hasTrackerInitializedOnce||(this.hasTrackerInitializedOnce=!0,WP_Statistics_Tracker_Object.option.isPreview)||(void 0===WP_Statistics_Tracker_Object?console.error("WP Statistics: Variable WP_Statistics_Tracker_Object not found. Ensure /wp-content/plugins/wp-statistics/assets/js/tracker.js is either excluded from cache settings or not dequeued by any plugin. Clear your cache if necessary."):this.checkHitRequestConditions(),this.trackUrlChange())},base64Encode:function(t){t=(new TextEncoder).encode(t);return btoa(String.fromCharCode.apply(null,t))},getPathAndQueryString:function(){var t=window.location.pathname,e=window.location.search;return this.base64Encode(t+e)},getReferred:function(){return this.base64Encode(document.referrer)},checkHitRequestConditions:function(){!WP_Statistics_Tracker_Object.option.dntEnabled||1!==this.isDndActive?this.sendHitRequest():console.log("WP Statistics: Do Not Track (DNT) is enabled. Hit request not sent.")},sendHitRequest:async function(){try{var t=this.getRequestUrl(),i=new URLSearchParams({...WP_Statistics_Tracker_Object.hitParams,referred:this.getReferred(),page_uri:this.getPathAndQueryString()}).toString();let e=new XMLHttpRequest;e.open("POST",t,!0),e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(i),e.onreadystatechange=function(){var t;4===e.readyState&&(200===e.status?(t=JSON.parse(e.responseText),this.hitRequestSuccessful=!1!==t.status):(this.hitRequestSuccessful=!1,console.warn("WP Statistics: Hit request failed with status "+e.status)))}.bind(this)}catch(t){this.hitRequestSuccessful=!1,console.error("WP Statistics: Error sending hit request:",t)}},getRequestUrl:function(){let t=WP_Statistics_Tracker_Object.requestUrl+"/";return WP_Statistics_Tracker_Object.option.bypassAdBlockers?t=WP_Statistics_Tracker_Object.ajaxUrl:t+=WP_Statistics_Tracker_Object.hitParams.endpoint,t},updateTrackerObject:function(s){function r(){var t=document.getElementById("wp-statistics-tracker-js-extra");if(t)try{var e,i=t.innerHTML.match(/var\s+WP_Statistics_Tracker_Object\s*=\s*(\{[\s\S]*?\});/);i&&i[1]&&(e=JSON.parse(i[1]),!WP_Statistics_Tracker_Object.hitParams||JSON.stringify(WP_Statistics_Tracker_Object.hitParams)!==JSON.stringify(e.hitParams))?(WP_Statistics_Tracker_Object=e,!a&&s&&(a=!0,s())):++n<20?setTimeout(r,100):!a&&s&&(a=!0,s())}catch(t){console.error("WP Statistics: Error parsing WP_Statistics_Tracker_Object",t),!a&&s&&(a=!0,s())}else++n<20?setTimeout(r,100):!a&&s&&(a=!0,s())}let a=!1,n=0;setTimeout(r,50)},trackUrlChange:function(){if(!this.hasUrlChangeTrackerInitialized){this.hasUrlChangeTrackerInitialized=!0;let t=this;window.removeEventListener("popstate",t.handleUrlChange),history.pushState=function(){t.originalPushState.apply(history,arguments),t.handleUrlChange()},history.replaceState=function(){t.originalReplaceState.apply(history,arguments),t.handleUrlChange()},window.addEventListener("popstate",function(){t.handleUrlChange()})}},handleUrlChange:function(){let t=this;window.location.href!==this.lastUrl&&(this.lastUrl=window.location.href,this.updateTrackerObject(function(){t.checkHitRequestConditions()}))}});
window.WpStatisticsEventTracker||(window.WpStatisticsEventTracker={hasEventsInitializedOnce:!1,downloadTracker:!1,linkTracker:!1,init:async function(){this.hasEventsInitializedOnce||WP_Statistics_Tracker_Object.isLegacyEventLoaded||(this.hasEventsInitializedOnce=!0,"undefined"!=typeof WP_Statistics_DataPlus_Event_Object&&(this.downloadTracker=WP_Statistics_DataPlus_Event_Object.options.downloadTracker,this.linkTracker=WP_Statistics_DataPlus_Event_Object.options.linkTracker,this.downloadTracker||this.linkTracker)&&this.captureEvent(),window.wp_statistics_event=this.handleCustomEvent.bind(this),"undefined"!=typeof WP_Statistics_Marketing_Event_Object&&this.captureCustomClickEvents())},handleCustomEvent:function(t,e={}){var n=WP_Statistics_Tracker_Object.customEventAjaxUrl,t=(e.timestamp=Date.now(),e.resource_id||(e.resource_id=WP_Statistics_Tracker_Object.hitParams.source_id),{event_name:t,event_data:JSON.stringify(e)});this.sendEventData(t,n)},captureCustomClickEvents:function(){WP_Statistics_Marketing_Event_Object.events.clicks.forEach(e=>{!e.selector||null!=e.scope&&e.scope!=WP_Statistics_Tracker_Object.hitParams.source_id||document.querySelectorAll(""+e.selector).forEach(t=>{t.addEventListener("click",t=>{t={text:t.target.textContent,id:t.currentTarget.id,class:t.currentTarget.className,target:t.currentTarget.href};this.handleCustomEvent(e.name,t)})})})},captureEvent:function(){document.querySelectorAll("a").forEach(t=>{t.addEventListener("click",async t=>this.handleEvent(t)),t.addEventListener("mouseup",async t=>this.handleEvent(t))})},handleEvent:async function(t){var e;"mouseup"==t.type&&1!=t.button||(t=this.prepareEventData(t))&&(e=WP_Statistics_DataPlus_Event_Object.eventAjaxUrl,await this.sendEventData(t,e))},prepareEventData:function(t){let e={en:t.type,et:Date.now(),eid:t.currentTarget.id,ec:t.currentTarget.className,ev:"",mb:t.button,fn:"",fx:"",m:"",tu:"",pid:""};return"A"===t.currentTarget.tagName&&(e=this.extractLinkData(t,e)),"undefined"!=typeof WP_Statistics_Tracker_Object&&(e.pid=WP_Statistics_Tracker_Object.hitParams.source_id),e},extractLinkData(t,e){var n=t.target.textContent,a=t.currentTarget.href,i=WP_Statistics_DataPlus_Event_Object.fileExtensions,i=new RegExp("\\.("+i.join("|")+")$","i"),n=(n&&(e.ev=n),a&&(e.tu=a),t.currentTarget.classList.contains("woocommerce-MyAccount-downloads-file")||a.includes("download_file="));if(e.wcdl=n,(i.test(a)||n)&&(t=new URL(a).pathname,e.df=n?a.substring(a.lastIndexOf("download_file=")+14).split("&").shift():"",e.dk=n?a.substring(a.lastIndexOf("key=")+4).split("&").shift():"",e.en="file_download",e.fn=n?e.df:t.substring(t.lastIndexOf("/")+1).split(".").shift(),e.fx=n?e.df:t.split(".").pop()),"click"===e.en){if(!this.linkTracker)return!1;try{if(new URL(a).host===window.location.host)return!1}catch(t){}}return!("file_download"===e.en&&!this.downloadTracker)&&e},sendEventData:async function(t,e){var n,a=new URLSearchParams;for(n in t)a.append(n,t[n]);if(!e)throw new Error("AJAX URL is not defined.");try{(await fetch(e,{method:"POST",keepalive:!0,body:a})).ok}catch(t){console.error("Error:",t)}}});
function handleWpConsentApiIntegration(){(wp_has_consent("statistics")||wp_has_consent("statistics-anonymous"))&&(WpStatisticsUserTracker.init(),WpStatisticsEventTracker.init()),document.addEventListener("wp_listen_for_consent_change",function(t){var n,i=t.detail;for(n in i)!i.hasOwnProperty(n)||"statistics"!==n&&"statistics-anonymous"!==n||"allow"!==i[n]||(WpStatisticsUserTracker.init(),WpStatisticsEventTracker.init())})}function handleRealCookieBannerIntegration(){(window.consentApi?.consent("wp-statistics")||Promise.resolve()).then(()=>{WpStatisticsUserTracker.init(),WpStatisticsEventTracker.init()}).catch(()=>{var t=window.consentApi?.consentSync("wp-statistics-with-data-processing");null!=t.cookie&&t.cookieOptIn?(WpStatisticsUserTracker.init(),WpStatisticsEventTracker.init()):console.log("WP Statistics: Real Cookie Banner consent is not given to track visitor information.")})}document.addEventListener("DOMContentLoaded",function t(){var n;document.prerendering?document.addEventListener("prerenderingchange",t,{once:!0}):((n=WP_Statistics_Tracker_Object.option.consentIntegration.name)&&"borlabs_cookie"!==n||(WpStatisticsUserTracker.init(),WpStatisticsEventTracker.init()),"wp_consent_api"===n&&handleWpConsentApiIntegration(),"real_cookie_banner"===n&&handleRealCookieBannerIntegration())});