!(function(){"use strict";var i=window.location,e=window.document.currentScript,y=e.getAttribute("data-api")||new URL(e.src).origin+"/api/event",m=e.getAttribute("data-instance")||"AhrefsAnalytics";function s(o,t){o&&console.warn("Ignoring Event: "+o),t&&t.callback&&t.callback()}function h(o,t){if(/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(i.hostname)||i.protocol==="file:")return s("localhost",t);if((window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)&&!window.__web_analytics)return s(null,t);var c=e.getAttribute("data-key"),d=e.getAttribute("data-domain");if(c==null&&d==null)return s("missing data-key",t);var u;try{u=window.navigator.languages||window.navigator.language||window.navigator.browserLanguage||window.navigator.userLanguage||window.navigator.systemLanguage}catch(p){}var n={};n.n=o,n.u=i.href,u!=null&&(n.l=u),d!=null&&(n.d=d),c!=null&&(n.k=c),n.r=window.document.referrer||null,t&&t.meta&&(n.m=JSON.stringify(t.meta)),t&&t.props&&(n.p=JSON.stringify(t.props));var v;try{v=window.screen.width}catch(p){}v!=null&&(n.sw=v);var g;try{g=window.screen.height}catch(p){}g!=null&&(n.sh=g);var f;try{f=window.devicePixelRatio}catch(p){}f!=null&&(n.sr=f);var a=new XMLHttpRequest;a.open("POST",y,!0),a.setRequestHeader("Content-Type","text/plain"),a.send(JSON.stringify(n)),a.onreadystatechange=function(){a.readyState===4&&t&&t.callback&&t.callback({status:a.status})}}window[m]={sendEvent:h};var w;function r(){w!==i.pathname&&(w=i.pathname,h("pageview"))}var l=window.history;if(l.pushState){var b=l.pushState;l.pushState=function(){b.apply(this,arguments),r()},window.addEventListener("popstate",r)}window.document.visibilityState==="prerender"?window.document.addEventListener("visibilitychange",function(){w||window.document.visibilityState!=="visible"||r()}):r()})();
