"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(t){const e=document.createElement("script");e.src=t||"https://mc.yandex.ru/metrika/tag.js",e.async=!0,document.body.appendChild(e)}function l(){window.ym=window.ym||function(...t){(window.ym.a=window.ym.a||[]).push(t)},window.ym.l=new Date().getTime()}function w(t,e){if(!window.ym)return;window.ym(t.id,"init",t.initParams);const n=document.createElement("img");n.src=`${e||"https://mc.yandex.ru/watch"}/${t.id}`,n.style.position="absolute",n.style.left="-9999px";const c=document.createElement("div");c.append(n),document.body.append(c)}function f(t,e){var i,u;if(!(e.enabled||!0)||typeof window>"u")return;y((i=e==null?void 0:e.cdn)==null?void 0:i.tag),l(),Array.isArray(e.counter)?e.counter.forEach(r=>{var a;return w(r,(a=e==null?void 0:e.cdn)==null?void 0:a.watch)}):w(e.counter,(u=e==null?void 0:e.cdn)==null?void 0:u.watch);const{router:n}=t,c=n.onAfterRouteChanged;n.onAfterRouteChanged=r=>{var m;Object.values(((m=window.Ya)==null?void 0:m._metrika.counters)||{}).forEach(d=>d==null?void 0:d.hit(r)),c==null||c(r)}}exports.yandexMetrika=f;
