const e={A:!0,BUTTON:!0,INPUT:!0,TEXTAREA:!0};let t={};const n=["MARK","STRONG","B","EM","I","U","ABBR","INS","DEL","S","SUP"];let r=["data-qidian-click"],o=[],a=!0;const c=window.TOLERANCE_TAGS||["BUTTON"],i=window.TOLERANCE_LEVEL||5;let s=!0,l=!1;function f(n){if(!n)return!1;const r=function(n){const r=(n.tagName||"").toUpperCase();return Object.assign({},e,t)[r]}(n);if(!0===r)return!0;if("object"==typeof r){let e=parseInt(r.max_level,10);isNaN(e)&&(e=1);return g(n)<=e}return!1}function u(e){if(!s||!e)return;if(!e.target)return;const{target:t}=e;let o=!1;t.tagName&&n.includes(t.tagName.toUpperCase())&&function(e){if(!e||!e.tagName||"DIV"!==e.tagName.toUpperCase())return!1;const{children:t}=e;if(!t.length)return!1;for(let e=0;e{const r=n.getAttribute(e);if(r)p[e]=r;else if(a){let r=n.parentNode,o=0;for(;r&&o{p[e]&&(N[e]=p[e])})),N}(r);s("$WebClick",l)};let d="";function g(e,t=1){if(!e.children||0===e.children.length)return t;let n=t;for(const r of e.children){const e=g(r,t+1);n=Math.max(n,e)}return n}var p={apply:function(e,n){d=n;const c=((e.getCommonParams()||[])[0]||{}).heatmap||{},i="default"===c.clickmap;function s(e){try{e.contentWindow.document.removeEventListener("click",u,!0),e.contentWindow.document.addEventListener("click",u,!0)}catch(e){console.error("无法为 iframe 添加点击事件监听器:",e)}}if(a=!c.disabledToleracnce,t=c.collect_tags,c.track_attr&&(r=c.track_attr.concat(r)),c.tag_attr&&(o=c.tag_attr.concat(o)),l=c.iframeEnable,i&&(document.removeEventListener("click",u,!0),document.addEventListener("click",u,!0),l)){const e=document.getElementsByTagName("iframe");for(const t of e)s(t);new MutationObserver((e=>{for(const t of e)for(const e of t.addedNodes)e&&e.tagName&&"IFRAME"===e.tagName.toUpperCase()&&s(e)})).observe(document.body,{childList:!0,subtree:!0})}},startIntercepting:function(){s=!0},stopIntercepting:function(){s=!1},startInterceptingIframe:function(){l=!0},stopInterceptingIframe:function(){l=!1}};export{p as default};