(()=>{"use strict";function t(t,n,e,a=null,r=!1){const o=new CustomEvent(`pwp-${n}:${e}`,{bubbles:!0,cancelable:r,detail:a});return t.dispatchEvent(o)}const n=function(n){let e={},a=[],r=!1,o=!1,c=null;function i(){let t=[];const n=new Uint32Array(6);return crypto.getRandomValues(n).forEach(function(n){t.push(n.toString(16).toUpperCase())}),t.join("-")}function s(){const{doNotTrack:t}=navigator;return!(void 0===t&&void 0===window.doNotTrack||"1"!==window.doNotTrack&&"1"!==t&&"yes"!==t)}function p(){if(s())return;const{location:n,referrer:e}=document,a=n.pathname+n.search+n.hash;let r={url:a,type:"misc",timestamp:(new Date).getTime()};pwpTrack&&pwpTrack.type&&(r.type=pwpTrack.type),pwpTrack&&pwpTrack.obj&&(r.object=pwpTrack.obj),0===e.indexOf(a.protocol+"//"+a.host)&&(r.referrer=e),pwpTrack&&pwpTrack.metadata&&(r.data=pwpTrack.metadata),r=PersonalizeWP.hooks.applyFilters("pwp-tracking-track_page",r,r.type),u(r),t(document,"tracking","trackPage",r)}function u(t){const{pwpStore:n}=PersonalizeWP.utils;a.push(t),n("tracking_queue",a,"pwp"),o||(o=setInterval(()=>async function(){const{pwpStore:t,callApi:n}=PersonalizeWP.utils;r||(r=!0,a.forEach(async a=>{if(pwpTrack.trackAnon||!1!==c){const{success:r,known:o}=await n("v1/activity",{...a,uid:e.id});e.isKnown=o,t("tracked_user",e,"pwp"),o?c=!0:o||pwpTrack.trackAnon||(c=!1)}}),a=[],r=!1,t("tracking_queue",a,"pwp"),o&&(clearInterval(o),o=!1))}(),500))}return n.init=function(){const{pwpGet:n,pwpStore:r}=PersonalizeWP.utils;if(s())return;e=n("tracked_user",!0,"pwp"),a=n("tracking_queue",!0,"pwp"),(!a||a&&"function"!=typeof a.forEach)&&(a=[]);let o=!1;const u=(new Date).getTime();e?(e.lastVisit=u,e.hasOwnProperty("isKnown")||(e.isKnown=null)):(o=!0,e={id:i(),firstVisit:u,lastVisit:u,isKnown:!1}),c=e.isKnown,pwpTrack.hasOwnProperty("userIsKnown")&&pwpTrack.userIsKnown&&(c=!0,e.isKnown=!0),r("tracked_user",e,"pwp"),o&&t(document,"tracking","userCreation",e),window.addEventListener("locationchange",function(){p()}),t(document,"tracking","ready",e),p()},n.readyInit=function(){window.PersonalizeWP&&(PersonalizeWP.module("tracking",this,!0),PersonalizeWP.tracking={trackPage:this.trackPage,trackEvent:this.trackEvent,maybeUserKnown:this.maybeUserKnown})},n.trackPage=p,n.trackEvent=function(n,e){if(s())return;if(!n||!e)return;if(!/^[a-z0-9_\-]+$/.test(n))return;const{location:a}=document;let r={url:a.pathname+a.search+a.hash,type:n,timestamp:(new Date).getTime(),data:e};r=PersonalizeWP.hooks.applyFilters("pwp-tracking-track_event",r,n),u(r),t(document,"tracking","trackEvent",r)},n.maybeUserKnown=function(){const{pwpGet:n,pwpStore:a}=PersonalizeWP.utils,r=n("tracked_user",!0,"pwp");r&&!0!==r.isKnown&&(c=null,r.isKnown=null,a("tracked_user",r,"pwp"),e=r,t(document,"tracking","maybeUserKnown",e))},n}({});var e;e=n,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{e.readyInit()},{once:!0}):e.readyInit()})();