async function trackPageView(){if("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||"[::1]"===window.location.hostname)return;const e=document.currentScript,n=new URL("/api/events",e.src),t=performance.now(),o=(e.getAttribute("data-domain")??window.location.hostname).toLowerCase(),a=window.location.href,i=new URL(a).searchParams.get("ref")??document.referrer,c=window.screen.width,r=performance.now(),d={d:o,u:a,r:i,w:c,t:r};try{const e=await fetch(n,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"}});await e.text()}catch(e){}function s(){const e=Math.max(0,Math.round(performance.now()-t)),r={e:"duration",d:o,u:a,r:i,w:c,dur:e},d=JSON.stringify(r);if(navigator.sendBeacon){const e=new Blob([d],{type:"application/json"});navigator.sendBeacon(n.href,e)}else fetch(n.href,{method:"POST",body:d,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}window.addEventListener("pagehide",s,{once:!0}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&s()},{once:!0})}trackPageView();