!function(){var e={},t=null;function n(e){return this.enqueue=function(t,n,r){var o={data:t,config:n,resolver:r||function(){}};if(!r&&window.Promise)return new window.Promise((function(t){o.resolver=t,e.push([o.data,o.config,o.resolver])}));e.push([t,n,r])},this.sizeOf=function(){return e.length},this.consume=function(){return e.splice(0,e.length)},this}function r(e,t){if(!t)throw new Error("You must provide a queue to watch");var n=e,r=-1,o=null,i=t,a=!1;this.isWatching=!1,this.startWatching=function(e){o=e,this.processQueue(),window.clearInterval(r),this.isWatching=!0,r=window.setInterval(this.processQueue.bind(this),n)},this.stopWatching=function(){this.processQueue(),this.isWatching=!1,clearInterval(r)},this.processQueue=function(){if(!a){a=!0;var e=i.consume();o&&e.length>0&&o(e),a=!1}}}window.__lter=window.__lter||{q:[],trackEvent:function(){}},e._globalVar="__lter",e.LOCAL_STORAGE_NAME="browserId",e._retryMax=5;var o=function(){var e,t=[];for(let e=0;e<256;++e)t.push((e+256).toString(16).substr(1));var n=new Uint8Array(16);return function(){var r=function(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(n)}();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,n=0){return(t[e[n+0]]+t[e[n+1]]+t[e[n+2]]+t[e[n+3]]+"-"+t[e[n+4]]+t[e[n+5]]+"-"+t[e[n+6]]+t[e[n+7]]+"-"+t[e[n+8]]+t[e[n+9]]+"-"+t[e[n+10]]+t[e[n+11]]+t[e[n+12]]+t[e[n+13]]+t[e[n+14]]+t[e[n+15]]).toLowerCase()}(r)}}();e.version=1,e.sendEvent=function(t,n,r,o){o=o||function(){};var i=!1;if(n&&!r.browserId&&(1===e.version?r.browserId=n:2===e.version&&r.eventPayload&&(r.eventPayload.browserId=n)),n&&navigator&&navigator.sendBeacon&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(t,JSON.stringify(r)))return i=!0,void setTimeout((function(){o(null,{browserId:n})}),1e3);if(!i&&window.fetch&&"CREATE"!==r.eventType)try{fetch(t,{method:"POST",mode:"cors",cache:"no-cache",keepalive:!0,headers:{"Content-Type":"application/json"},redirect:"follow",body:JSON.stringify(r)}).then((function(e){if(e.ok)return e.json();throw new Error("Response from server not ok.")})).then((function(e){o(null,e?e.data:{})})).catch((function(n){e.doTraditionalXHR(t,r,o)}))}catch(n){e.doTraditionalXHR(t,r,o)}else i||e.doTraditionalXHR(t,r,o)},e.doTraditionalXHR=function(t,n,r){var o=new window.XMLHttpRequest;o.open("POST",t,!0),o.setRequestHeader("Content-Type","application/json"),o.onreadystatechange=e.xhrCallback(r),o.send(JSON.stringify(n))},e.xhrCallback=function(e){return function(){if(4===this.readyState)if(this.status>=200&&this.status<400)try{var t=JSON.parse(this.response);if(200!==t.statusCode)throw new Error("Invalid response code from server");e(null,t.data)}catch(t){e(t,null)}else e(new Error("Server responded with error"),null)}},e.getCookie=function(e){if(e){var t={browserId:void 0},n=e.split(/; */);for(var r in n){var o=n[r].split("="),i=o[0],a=decodeURIComponent(o[1]);t[i]=a}return t.browserId}},e.getBackup=function(){return window.localStorage.getItem("browserId")||null},e.getBrowserId=function(t,n){var r=e.getCookie(document.cookie)||e.getBackup()||t();if(r)return e.storeBrowserId(r),void n(null,r);throw new Error("VanillaCEP: Unable to fetch or generate browserId")},e.storeBrowserId=function(e){const{host:t}=window.location,n=t.endsWith("linktr.ee");document.cookie=`browserId=${e}; path=/; max-age=31536000; expires=Tue, 30 Mar 2099 03:14:07 GMT; samesite=strict;${n?" domain=linktr.ee;":""}`,window.localStorage.setItem("browserId",e)},e.processItems=function(n,r){for(;n.length>0;){var o=n.shift();e.sendEvent(o[1].endpoint,t,o[0],(function(){o[2]()}))}r&&r(null,!0)},e.unmungeAnalyticsUrl=function(e){if(e){var t=e.substr(0,Math.ceil(e.length/2));return[e.substr(Math.ceil(e.length/2),e.length).split("").reverse().join(""),t].join("")}},e.getDataUrlFromDocumentElement=function(){var t=document.getElementById("__ltcep");if(t&&"script"===t.tagName.toLowerCase())return e.unmungeAnalyticsUrl(t.attributes["data-url"].value)},e.getVersionIfPresent=function(){var e=document.getElementById("__ltcep");return e&&"script"===e.tagName.toLowerCase()&&e.attributes["data-version"]?parseInt(e.attributes["data-version"].value):1};var i=function(e,n,r,o,i){window.__lter&&(window.__lter.trackEvent=n.enqueue.bind(n)),o||(o=e.getDataUrlFromDocumentElement()),e.version=e.getVersionIfPresent(),1===e.version?n.enqueue({eventType:"PAGE.LOADED",context:{url:window.location.href,channel:"web",language:navigator.language,referer:document.referrer}},{endpoint:o}):2===e.version&&n.enqueue({eventType:"PageLoaded",eventPayload:{eventType:"PageLoaded",context:{url:window.location.href,language:navigator&&navigator.languages&&navigator.languages[1]?navigator.languages[1]:navigator&&navigator.language?navigator.language:"en",channel:"web",userAgent:navigator.userAgent,device:null,referrer:document.referrer}},createdAt:(new Date).toISOString()},{endpoint:o}),e.getBrowserId(i,(function(n,o){t=o,r.startWatching(e.processItems)}))};if("undefined"==typeof module||"object"!=typeof module.exports){var a=new n(window.__lter.q),s=new r(200,a);document.addEventListener("visibilitychange",(function(){"hidden"==document.visibilityState&&s.processQueue()})),window.addEventListener("pagehide",s.processQueue),window.addEventListener("unload",s.processQueue),i(e,a,s,null,o)}else module.exports={init:i,api:e,EventQueue:n,Watcher:r,uuidv4:o}}(window);