{"version":3,"names":["getCleanUrl","url","window","location","href","replace","plausible","q","push","arguments","hashBasedRouting","autoCapturePageviews","lastUrl","trackPageView","currentUrl","addEventListener","originalPushState","history","pushState","args","apply","this","setTimeout","originalReplaceState","replaceState"],"sourceRoot":"theme-2/","sources":["_html/common/head_tag_2.js"],"sourcesContent":["\n  window.plausible = window.plausible || function() { \n    (window.plausible.q = window.plausible.q || []).push(arguments) \n  }\n\n  // Helper: Clean Discourse topic URLs by removing trailing post number\n  function getCleanUrl() {\n    let url = window.location.href;\n\n    // Remove everything after the last / if it's a number (e.g. /9, /42)\n    url = url.replace(/\\/\\d+$/, '');\n\n    // Optional: also remove any trailing hash (if you want to ignore #reply-123 etc.)\n    // url = url.split('#')[0];\n\n    return url;\n  }\n\n  // Disable auto-capture so we have full control\n  plausible('init', {\n    hashBasedRouting: true,           // Important for Discourse SPA navigation\n    autoCapturePageviews: false       // We will trigger manually\n  });\n\n  // Trigger the first pageview with cleaned URL\n  plausible('pageview', {\n    url: getCleanUrl()\n  });\n\n  // Listen for Discourse navigation (hash changes + pushState)\n  let lastUrl = getCleanUrl();\n\n  function trackPageView() {\n    const currentUrl = getCleanUrl();\n    if (currentUrl !== lastUrl) {\n      lastUrl = currentUrl;\n      plausible('pageview', {\n        url: currentUrl\n      });\n    }\n  }\n\n  // Track hash changes (Discourse uses these heavily)\n  window.addEventListener('hashchange', trackPageView);\n\n  // Also track History API changes (pushState / replaceState) for safety\n  const originalPushState = history.pushState;\n  history.pushState = function(...args) {\n    originalPushState.apply(this, args);\n    setTimeout(trackPageView, 10);   // small delay to let URL update\n  };\n\n  const originalReplaceState = history.replaceState;\n  history.replaceState = function(...args) {\n    originalReplaceState.apply(this, args);\n    setTimeout(trackPageView, 10);\n  };\n\n"],"mappings":"AAME,SAASA,cACP,IAAIC,EAAMC,OAAOC,SAASC;AAQ1B,OALAH,EAAMA,EAAII,QAAQ,SAAU,IAKrBJ,CACT,CAfAC,OAAOI,UAAYJ,OAAOI,WAAa,YACpCJ,OAAOI,UAAUC,EAAIL,OAAOI,UAAUC,GAAK,IAAIC,KAAKC,UACvD,EAgBAH,UAAU,OAAQ,CAChBI,kBAAkB,EAClBC,sBAAsB,IAIxBL,UAAU,WAAY,CACpBL,IAAKD;AAIP,IAAIY,QAAUZ;AAEd,SAASa,gBACP,MAAMC,EAAad;AACfc,IAAeF,UACjBA,QAAUE,EACVR,UAAU,WAAY,CACpBL,IAAKa,IAGX,CAGAZ,OAAOa,iBAAiB,aAAcF;AAGtC,MAAMG,kBAAoBC,QAAQC;AAClCD,QAAQC,UAAY,YAAYC,GAC9BH,kBAAkBI,MAAMC,KAAMF,GAC9BG,WAAWT,cAAe,GAC5B;AAEA,MAAMU,qBAAuBN,QAAQO;AACrCP,QAAQO,aAAe,YAAYL,GACjCI,qBAAqBH,MAAMC,KAAMF,GACjCG,WAAWT,cAAe,GAC5B"}