!function(){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},t.apply(null,arguments)}var i="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:i;"undefined"==typeof self&&(e.self=e),"undefined"==typeof File&&(e.File=function(){});var r=null==e?void 0:e.document;null!=e&&e.XMLHttpRequest&&new e.XMLHttpRequest;var n=null!=i?i:{};function a(t,i){return-1!==t.indexOf(i)}var s=function(t){return t.trim()},l=Object.prototype,o=l.hasOwnProperty,u=l.toString,c=Array.isArray||function(t){return"[object Array]"===u.call(t)},h=t=>"function"==typeof t,v=t=>void 0===t,d=t=>"[object String]"==u.call(t),f=t=>null===t,_=t=>v(t)||f(t),b=t=>"[object Number]"==u.call(t)&&t==t,m=t=>t instanceof FormData,p=function(t,e){var{debugEnabled:r}=void 0===e?{}:e,a={C(e){if(i&&(n.POSTHOG_DEBUG||r)&&!v(i.console)&&i.console){for(var a=("__rrweb_original__"in i.console[e]?i.console[e].__rrweb_original__:i.console[e]),s=arguments.length,l=new Array(s>1?s-1:0),o=1;s>o;o++)l[o-1]=arguments[o];a(t,...l)}},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];a.C("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];a.C("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];a.C("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){a.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>p(t+" "+i,e)};return a},g=p("[PostHog.js]"),y=g.createLogger;function k(t,i){if(!_(t))if(c(t))t.forEach(i);else if(m(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)o.call(t,e)&&i(t[e],e)}var w=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var n of e)for(var a in n)void 0!==n[a]&&(t[a]=n[a]);return t};function A(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}function x(t,i,e,r){var{capture:n=!1,passive:a=!0}=null!=r?r:{};null==t||t.addEventListener(i,e,{capture:n,passive:a})}var O=1,C=3;function D(t){return!!t&&t.nodeType===O}function j(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function E(t){return t?s(t).split(/\s+/):[]}function T(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return E(i)}function R(t){var i="";return M(t)&&!S(t)&&t.childNodes&&t.childNodes.length&&k(t.childNodes,(function(t){var e,r;(function(t){return!!t&&t.nodeType===C})(t)&&t.textContent&&(i+=null!==(e=_(r=t.textContent)?null:s(r).split(/(\s+)/).filter((t=>V(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))&&void 0!==e?e:"")})),s(i)}var L=["a","button","form","input","select","textarea","label"];function M(t){for(var i=t;i.parentNode&&!j(i,"body");i=i.parentNode){var e=T(i);if(a(e,"ph-sensitive")||a(e,"ph-no-capture"))return!1}if(a(T(t),"ph-include"))return!0;var r=t.type||"";if(d(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var n=t.name||t.id||"";return!d(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function S(t){return!!(j(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||j(t,"select")||j(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var z="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",H=new RegExp("^(?:"+z+")$"),P=new RegExp(z),F="\\d{3}-?\\d{2}-?\\d{4}",I=new RegExp("^("+F+")$"),N=new RegExp("("+F+")");function V(t,i){if(void 0===i&&(i=!0),_(t))return!1;if(d(t)){if(t=s(t),(i?H:P).test((t||"").replace(/[- ]/g,"")))return!1;if((i?I:N).test(t))return!1}return!0}function W(t){var i=R(t);return V(i=(i+" "+q(t)).trim())?i:""}function q(t){var i="";return t&&t.childNodes&&t.childNodes.length&&k(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=R(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+q(t)).trim())}catch(t){g.error("[AutoCapture]",t)}})),i}function B(t){return t.replace(/"|\\"/g,'\\"')}function G(t){var i=t.attr__class;return i?c(i)?i:E(i):void 0}function Y(t,i){return i.length>t?i.slice(0,t)+"...":i}function Z(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!D(i));return i}function J(e,n){var s,l,{e:o,maskAllElementAttributes:u,maskAllText:c,elementAttributeIgnoreList:h}=n;if(!D(e))return{props:{}};for(var f,_=[e],b=e;b.parentNode&&!j(b,"body");)if((f=b.parentNode)&&11===f.nodeType&&D(f.host))_.push(b.parentNode.host),b=b.parentNode.host;else{if(!D(b.parentNode))break;_.push(b.parentNode),b=b.parentNode}var m,p,g,y,x=[],O={},C=!1,z=!1;if(k(_,(t=>{var i=M(t);if(j(t,"a")){var e=t.getAttribute("href");C=i&&!!e&&V(e)&&e}a(T(t),"ph-no-capture")&&(z=!0),x.push(function(t,i,e,r){var n=t.tagName.toLowerCase(),a={tag_name:n};L.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Y(1024,W(t)):Y(1024,R(t)));var s=T(t);s.length>0&&(a.classes=s.filter((function(t){return""!==t}))),k(t.attributes,(function(e){var n;if((!S(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&V(e.value)&&(!d(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var s=e.value;"class"===e.name&&(s=E(s).join(" ")),a["attr__"+e.name]=Y(1024,s)}}));for(var l=1,o=1,u=t;u=Z(u);)l++,u.tagName===t.tagName&&o++;return a.nth_child=l,a.nth_of_type=o,a}(t,u,c,h));var r=function(t){if(!M(t))return{};var i={};return k(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&V(r)&&(i[e]=r)}})),i}(t);w(O,r)})),z)return{props:{},explicitNoCapture:z};if(c||(x[0].$el_text=j(e,"a")||j(e,"button")?W(e):R(e)),C){var H,P;x[0].attr__href=C;var F=null==(p=C,g=null==r?void 0:r.createElement("a"),H=v(g)?null:(g.href=p,g))?void 0:H.host,I=null==i||null==(P=i.location)?void 0:P.host;F&&I&&F!==I&&(m=C)}return{props:w({$event_type:o.type,$ce_version:1},{$elements:x},{$elements_chain:(y=x,function(i){return i.map((i=>{var e,r,n="";if(i.tag_name&&(n+=i.tag_name),i.attr_class)for(var a of(i.attr_class.sort(),i.attr_class))n+="."+a.replace(/"/g,"");var s=t({},i.text?{text:i.text}:{},{"nth-child":null!==(e=i.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=i.nth_of_type)&&void 0!==r?r:0},i.href?{href:i.href}:{},i.attr_id?{attr_id:i.attr_id}:{},i.attributes),l={};return A(s).sort(((t,i)=>{var[e]=t,[r]=i;return e.localeCompare(r)})).forEach((t=>{var[i,e]=t;return l[B(i.toString())]=B(e.toString())})),(n+=":")+A(l).map((t=>{var[i,e]=t;return i+'="'+e+'"'})).join("")})).join(";")}(function(t){return t.map((t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:G(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return A(t).filter((t=>{var[i]=t;return 0===i.indexOf("attr__")})).forEach((t=>{var[i,e]=t;return r.attributes[i]=e})),r}))}(y)))},null!=(s=x[0])&&s.$el_text?{$el_text:null==(l=x[0])?void 0:l.$el_text}:{},m&&"click"===o.type?{$external_click_url:m}:{},O)}}y("[AutoCapture]");var K={};function Q(t){return function(t,e){var r=K[t];if(r)return r;var n,a=e[t];if(h(n=a)&&-1!==n.toString().indexOf("[native code]")&&!i.Zone)return K[t]=a.bind(e);var s=e.document;if(s&&h(s.createElement))try{var l=s.createElement("iframe");l.hidden=!0,s.head.appendChild(l);var o=l.contentWindow;o&&o[t]&&(a=o[t]),s.head.removeChild(l)}catch(i){g.warn("Could not create sandbox iframe for "+t+" check, bailing to assignableWindow."+t+": ",i)}return a&&h(a)?K[t]=a.bind(e):a}("MutationObserver",t)}function U(t,i){return b(t)&&t>=i}class X{St(t){var i,e,r,n,a,s=this.kt((null==t?void 0:t.__onCapture)||this.xt.bind(this));return{element_attribute_ignorelist:null!==(i=null==t?void 0:t.element_attribute_ignorelist)&&void 0!==i?i:s.element_attribute_ignorelist,scroll_threshold_ms:null!==(e=null==t?void 0:t.scroll_threshold_ms)&&void 0!==e?e:s.scroll_threshold_ms,selection_change_threshold_ms:null!==(r=null==t?void 0:t.selection_change_threshold_ms)&&void 0!==r?r:s.selection_change_threshold_ms,mutation_threshold_ms:null!==(n=null==t?void 0:t.mutation_threshold_ms)&&void 0!==n?n:s.mutation_threshold_ms,capture_clicks_with_modifier_keys:null!==(a=null==t?void 0:t.capture_clicks_with_modifier_keys)&&void 0!==a?a:s.capture_clicks_with_modifier_keys,__onCapture:s.__onCapture}}constructor(t,i){this.At=[],this.kt=t=>({element_attribute_ignorelist:[],scroll_threshold_ms:100,selection_change_threshold_ms:100,mutation_threshold_ms:2500,capture_clicks_with_modifier_keys:!1,__onCapture:t}),this.Tt=t=>{var i=function(t){var i,e,r=v((i=t).target)?i.srcElement||null:null!=(e=i.target)&&e.shadowRoot?i.composedPath()[0]||null:i.target||null;return r?{node:r,originalEvent:t,timestamp:Date.now()}:null}(t);f(i)||this.Nt(i)||this.At.push(i),this.At.length&&v(this.Rt)&&(this.Rt=n.setTimeout((()=>{this.Mt()}),1e3))},this._t=()=>{var t=Date.now();t%50==0&&this.At.forEach((i=>{v(i.scrollDelayMs)&&(i.scrollDelayMs=t-i.timestamp)}))},this.Et=()=>{this.Ot=Date.now()},this.Ft=()=>{"visible"===(null==r?void 0:r.visibilityState)&&(this.Lt=Date.now())},this.instance=t,this.Bt=this.St(i),this._onCapture=this.Bt.__onCapture}start(t){this.Zt(),this.Dt(),this.Pt(),this.qt(),this.Vt(t)}Vt(t){if(!this.jt){var i=Q(n);this.jt=new i((t=>{this.Ht(t)})),this.jt.observe(t,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}}stop(){var t;null==(t=this.jt)||t.disconnect(),this.jt=void 0,n.removeEventListener("click",this.Tt),n.removeEventListener("scroll",this._t,{capture:!0}),n.removeEventListener("selectionchange",this.Et),null==r||r.removeEventListener("visibilitychange",this.Ft)}Ht(t){this.Yt=Date.now()}Zt(){x(n,"click",this.Tt)}Dt(){x(n,"scroll",this._t,{capture:!0})}Pt(){x(n,"selectionchange",this.Et)}qt(){x(r,"visibilitychange",this.Ft)}Nt(t){return!(t&&(this.Bt.capture_clicks_with_modifier_keys||!((i=t.originalEvent).ctrlKey||i.metaKey||i.altKey||i.shiftKey))&&!((e=t.node)instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||null!=e.closest&&e.closest(".toolbar-global-fade-container")))&&!this.At.some((i=>i.node===t.node&&1e3>Math.abs(i.timestamp-t.timestamp)))&&!j(t.node,"html")&&D(t.node)&&!L.includes(t.node.tagName.toLowerCase()));var i,e}Mt(){if(this.At.length){clearTimeout(this.Rt),this.Rt=void 0;var t=this.At;for(var i of(this.At=[],t)){var e;i.mutationDelayMs=null!==(e=i.mutationDelayMs)&&void 0!==e?e:this.Yt&&this.Yt>=i.timestamp?this.Yt-i.timestamp:void 0,i.absoluteDelayMs=Date.now()-i.timestamp,i.selectionChangedDelayMs=this.Ot&&this.Ot>=i.timestamp?this.Ot-i.timestamp:void 0,i.visibilityChangedDelayMs=this.Lt?Math.abs(i.timestamp-this.Lt):void 0;var r=U(i.scrollDelayMs,this.Bt.scroll_threshold_ms),a=U(i.selectionChangedDelayMs,this.Bt.selection_change_threshold_ms),s=U(i.mutationDelayMs,this.Bt.mutation_threshold_ms),l=U(i.absoluteDelayMs,1.1*this.Bt.mutation_threshold_ms),o=b(i.scrollDelayMs)&&this.Bt.scroll_threshold_ms>i.scrollDelayMs,u=b(i.mutationDelayMs)&&this.Bt.mutation_threshold_ms>i.mutationDelayMs,c=b(i.selectionChangedDelayMs)&&this.Bt.selection_change_threshold_ms>i.selectionChangedDelayMs,h=b(i.visibilityChangedDelayMs)&&this.Bt.selection_change_threshold_ms>i.visibilityChangedDelayMs;if(!(o||u||c||h)){var d=U(i.visibilityChangedDelayMs,this.Bt.selection_change_threshold_ms);r||s||l||a||d?this._onCapture(i,{$dead_click_last_mutation_timestamp:this.Yt,$dead_click_event_timestamp:i.timestamp,$dead_click_scroll_timeout:r,$dead_click_mutation_timeout:s,$dead_click_absolute_timeout:l,$dead_click_selection_changed_timeout:a,$dead_click_visibility_changed_timeout:d}):this.Bt.mutation_threshold_ms>i.absoluteDelayMs&&this.At.push(i)}}this.At.length&&v(this.Rt)&&(this.Rt=n.setTimeout((()=>{this.Mt()}),1e3))}}xt(i,e){this.instance.capture("$dead_click",t({},e,J(i.node,{e:i.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Bt.element_attribute_ignorelist}).props,{$dead_click_scroll_delay_ms:i.scrollDelayMs,$dead_click_mutation_delay_ms:i.mutationDelayMs,$dead_click_absolute_delay_ms:i.absoluteDelayMs,$dead_click_selection_changed_delay_ms:i.selectionChangedDelayMs,$dead_click_visibility_changed_delay_ms:i.visibilityChangedDelayMs}),{timestamp:new Date(i.timestamp)})}}n.__PosthogExtensions__=n.__PosthogExtensions__||{},n.__PosthogExtensions__.initDeadClicksAutocapture=(t,i)=>new X(t,i)}(); //# sourceMappingURL=dead-clicks-autocapture.js.map