((d, w, data=w.internalScriptData||{})=> {
const home=data.home||location.origin;
function cap(str=''){
return str.charAt(0).toUpperCase() + str.slice(1);
}
function track(cat, name){
const label=`${name} (${location.pathname + location.search})`;
w.rybbit?.event?.(cat, {label});
}
d.addEventListener('click', e=> {
const a=e.target.closest('a[href]');
if(!a) return;
let href=a.href;
if(!href||href.startsWith('#')||href.startsWith('javascript:')) return;
let url;
try { url=new URL(href, home) } catch { return }
const isExt=url.origin!==home;
let name=href.includes('/go/')
? href.split('/').pop()
: (isExt ? href:url.pathname + url.search + url.hash);
name=cap(name.trim());
if(!name) return;
let cat='ClickFromContent';
const bc=d.body.className;
if(bc.includes('single')) cat='ClickFromPost';
else if(bc.includes('page')) cat='ClickFromPage';
track(cat, name);
}, {passive: true});
})(document, window);