import{y as b,z as y,A as C,C as U,B as M,D as k}from"./bundle.js";const l=new Map,S=e=>{var t;if(!((t=e.applyToUrls)!=null&&t.length))return!0;if(l.has(e.identifier))return l.get(e.identifier);if(!e.applyToUrls)return l.set(e.identifier,!0),!0;for(const n of e.applyToUrls)if(b({value:n.value,actual:e.pathname,matchBy:n.matchBy}))return l.set(e.identifier,!0),!0;return l.set(e.identifier,!1),!1},p=e=>{const t=e.url.pathname.replace(/^\/+|\/+$/g,"");if(!S({pathname:t,applyToUrls:e.applyToUrls,identifier:e.identifier}))return;const r=e.selectors.join(",");e.callback(r)},f=async(e,t)=>{var n;await((n=window.igEvents)==null?void 0:n.push({type:"track",event:t,source:void 0,properties:{id:y(),type:e,identifier:t}}))};window.__igce=f;const T=new Map,_=new Map,L=C(e=>void f("clickEvent",e),50),j=(e,t)=>{var n;for(;e;){if((n=e.matches)!=null&&n.call(e,t))return e;e=e.parentElement}return null},B=e=>{document.addEventListener("click",t=>{const n=t.target;j(n,e.selectors)&&L(e.customEvent.identifier)},{capture:!0})},I=e=>{p({url:e.url,applyToUrls:e.customEvent.applyToUrls,identifier:e.customEvent.identifier,selectors:e.customEvent.settings.selectors,selectorCache:T,elementCache:_,callback:t=>{B({...e,selectors:t})}})},V=new Map,s=new Map;let a=null;const g=new Map;let u=null;function x(e){if(!e.target.isConnected)return d(e.target),!1;const t=window.getComputedStyle(e.target,null);return t.display!=="none"&&t.visibility!=="hidden"&&t.opacity!=="0"&&t.height!=="0px"&&t.width!=="0px"&&e.target.getBoundingClientRect().width>0&&e.target.getBoundingClientRect().height>0}function d(e){a&&a.unobserve(e),s.delete(e)}function m(e,t){return Array.from(e.querySelectorAll(t))}function D(e){for(const t of e){let n=null;for(const[r,c]of g)if(t.target.matches(r)){n=c;break}if(n)if(t.isIntersecting)x(t)&&n.selectorCallback();else{const r=s.get(t.target);r&&(r.delete(n.customEvent.identifier),r.size===0&&d(t.target))}}}function w(e,t,n=50){a||(a=new IntersectionObserver(D,{root:null,rootMargin:`${n}px`,threshold:[0,.1,.5,1]}));let r=s.get(e);r||(r=new Set,s.set(e,r)),r.add(t.identifier),a.observe(e)}function O(){u||(u=new MutationObserver(e=>{let t=!1;e.forEach(n=>{n.removedNodes.forEach(r=>{r instanceof Element&&(d(r),r.querySelectorAll("*").forEach(d))}),(n.addedNodes.length>0||n.type==="attributes"||n.type==="childList")&&(t=!0)}),t&&g.forEach(({customEvent:n},r)=>{m(document,r).filter(o=>!s.has(o)).forEach(o=>{w(o,n)})})}),u.observe(document.body,{childList:!0,subtree:!0,attributes:!0}))}const h=new Set;function $(e){h.has(e.identifier)||(f("elementViewed",e.identifier),h.add(e.identifier))}function A(e){O();const t=e.settings.selectors.join(",");g.set(t,{customEvent:e,selectorCallback:()=>$(e)}),m(document,t).forEach(n=>{w(n,e)})}const P=e=>{const{url:t,customEvent:n}=e;p({url:t,applyToUrls:n.applyToUrls,identifier:n.identifier,selectors:n.settings.selectors,selectorCache:V,elementCache:s,callback:()=>A(n)})},R=e=>{const t=`function sendEvent(){window?.__igce && window.__igce("javascriptEvent", "${e.customEvent.identifier}");}`,n=document.createElement("script");n.innerHTML=t+e.customEvent.settings.code,n.type="text/javascript",n.id=`${U.CUSTOM_JS_ID_KEY}-${e.customEvent.identifier}`,document.head.appendChild(n)};function J(e,t){const n=async()=>{const r=window.scrollY,c=window.innerHeight,o=document.documentElement.scrollHeight;(r+c)/o*100>=e&&(t(),window.removeEventListener("scroll",n))};window.addEventListener("scroll",n)}const z=window.matchMedia("(max-width: 767px)"),K=e=>{const t=()=>J(z.matches?e.customEvent.settings.mobile.percentage:e.customEvent.settings.desktop.percentage,()=>void f("scrollDepth",e.customEvent.identifier));document.readyState==="complete"?t():window.addEventListener("load",()=>{t()})},v=new URL(window.location.href);let i;function q(){if(!i){const e=window.location.pathname,t=(E._configFileCustomEvents||[]).filter(n=>{var r;return(r=n.applyToUrls)!=null&&r.length?n.applyToUrls.some(c=>M(e,{value:c.value,filter:c.matchBy})):!0});i=k(t,n=>n.type)}}const G=()=>{q();for(const e of(i==null?void 0:i.clickEvent)||[])I({url:v,customEvent:e});for(const e of(i==null?void 0:i.scrollDepth)||[])K({customEvent:e});for(const e of(i==null?void 0:i.javascriptEvent)||[])R({customEvent:e});for(const e of(i==null?void 0:i.elementViewed)||[])P({url:v,customEvent:e})},F=Object.freeze(Object.defineProperty({__proto__:null,registerCustomEventsAtPageLoad:G},Symbol.toStringTag,{value:"Module"}));let E;const Q=e=>{E=e};export{E as CustomEventConfig,F as CustomEventRegistration,Q as init}; //# sourceMappingURL=ig_standard_1749677992907.index.WJgj7USk.js.map