import{y as i}from"./hooks.module.BrsKpn_h.js";import"./preact.module.NIwkvMQy.js";const c=({data:e,url:n})=>{const s={method:"POST",keepalive:!0,headers:{"Content-Type":"application/json",Accept:"application/json"},body:e?JSON.stringify(e):void 0};return typeof window<"u"&&window.navigator?.sendBeacon?window.navigator.sendBeacon(n,s.body)?Promise.resolve():Promise.reject(new Error("sendBeacon failed")):fetch(n.toString(),s).then(t=>t).catch(t=>(console.error("sendRequest Error: ",t),Promise.reject(t)))};var a=(e=>(e.START="start",e))(a||{});const d=({event:e})=>({event:e,app:"search-sites",landing_domain:window.location.host});let r=[];const u=({event:e})=>{const n=d({event:e});r.push(n);const o=new URL(window.location.href).origin,t={url:new URL(`${o}/sync-metrics`).toString(),data:r};r=[],c(t).catch(()=>{setTimeout(()=>{c(t).catch(()=>{console.error(`Metrics sync failed: ${n}`)})},100)})},p=()=>{i(()=>{u({event:a.START})},[])};export{p as default};