!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),_=t=>null===t,f=t=>v(t)||_(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={t(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.t("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];a.t("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];a.t("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(!f(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})}function O(t){return!!t&&1===t.nodeType}function C(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function D(t){return t?s(t).split(/\s+/):[]}function j(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 D(i)}function E(t){var i="";return R(t)&&!L(t)&&t.childNodes&&t.childNodes.length&&k(t.childNodes,(function(t){var e,r;(function(t){return!!t&&3===t.nodeType})(t)&&t.textContent&&(i+=null!==(e=f(r=t.textContent)?null:s(r).split(/(\s+)/).filter((t=>I(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))&&void 0!==e?e:"")})),s(i)}var T=["a","button","form","input","select","textarea","label"];function R(t){for(var i=t;i.parentNode&&!C(i,"body");i=i.parentNode){var e=j(i);if(a(e,"ph-sensitive")||a(e,"ph-no-capture"))return!1}if(a(j(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 L(t){return!!(C(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||C(t,"select")||C(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var M="(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})",S=new RegExp("^(?:"+M+")$"),z=new RegExp(M),H="\\d{3}-?\\d{2}-?\\d{4}",P=new RegExp("^("+H+")$"),F=new RegExp("("+H+")");function I(t,i){if(void 0===i&&(i=!0),f(t))return!1;if(d(t)){if(t=s(t),(i?S:z).test((t||"").replace(/[- ]/g,"")))return!1;if((i?P:F).test(t))return!1}return!0}function N(t){var i=E(t);return I(i=(i+" "+V(t)).trim())?i:""}function V(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=E(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+V(t)).trim())}catch(t){g.error("[AutoCapture]",t)}})),i}function W(t){return t.replace(/"|\\"/g,'\\"')}function q(t){var i=t.attr__class;return i?c(i)?i:D(i):void 0}function B(t,i){return i.length>t?i.slice(0,t)+"...":i}function G(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!O(i));return i}function Y(e,n){for(var s,l,o,{e:u,maskAllElementAttributes:c,maskAllText:h,elementAttributeIgnoreList:_}=n,f=[e],b=e;b.parentNode&&!C(b,"body");)(o=b.parentNode)&&11===o.nodeType?(f.push(b.parentNode.host),b=b.parentNode.host):(f.push(b.parentNode),b=b.parentNode);var m,p,g,y,x=[],O={},M=!1,S=!1;if(k(f,(t=>{var i=R(t);"a"===t.tagName.toLowerCase()&&(M=t.getAttribute("href"),M=i&&M&&I(M)&&M),a(j(t),"ph-no-capture")&&(S=!0),x.push(function(t,i,e,r){var n=t.tagName.toLowerCase(),a={tag_name:n};T.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?B(1024,N(t)):B(1024,E(t)));var s=j(t);s.length>0&&(a.classes=s.filter((function(t){return""!==t}))),k(t.attributes,(function(e){var n;if((!L(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&I(e.value)&&(!d(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var s=e.value;"class"===e.name&&(s=D(s).join(" ")),a["attr__"+e.name]=B(1024,s)}}));for(var l=1,o=1,u=t;u=G(u);)l++,u.tagName===t.tagName&&o++;return a.nth_child=l,a.nth_of_type=o,a}(t,c,h,_));var e=function(t){if(!R(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&&I(r)&&(i[e]=r)}})),i}(t);w(O,e)})),S)return{props:{},explicitNoCapture:S};if(h||(x[0].$el_text="a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?N(e):E(e)),M){var z,H;x[0].attr__href=M;var P=null==(p=M,g=null==r?void 0:r.createElement("a"),z=v(g)?null:(g.href=p,g))?void 0:z.host,F=null==i||null==(H=i.location)?void 0:H.host;P&&F&&P!==F&&(m=M)}return{props:w({$event_type:u.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[W(i.toString())]=W(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:q(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"===u.type?{$external_click_url:m}:{},O)}}y("[AutoCapture]");var Z={};function J(t){return function(t,e){var r=Z[t];if(r)return r;var n,a=e[t];if(h(n=a)&&-1!==n.toString().indexOf("[native code]")&&!i.Zone)return Z[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)?Z[t]=a.bind(e):a}("MutationObserver",t)}function K(t,i){return b(t)&&t>=i}class Q{i(t){var i,e,r,n,a,s=this.l((null==t?void 0:t.__onCapture)||this.o.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.u=[],this.l=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.h=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);_(i)||this.v(i)||this.u.push(i),this.u.length&&v(this.m)&&(this.m=n.setTimeout((()=>{this.p()}),1e3))},this.k=()=>{var t=Date.now();t%50==0&&this.u.forEach((i=>{v(i.scrollDelayMs)&&(i.scrollDelayMs=t-i.timestamp)}))},this.A=()=>{this.$=Date.now()},this.O=()=>{"visible"===(null==r?void 0:r.visibilityState)&&(this.C=Date.now())},this.instance=t,this.D=this.i(i),this._onCapture=this.D.__onCapture}start(t){this.j(),this.T(),this.R(),this.L(),this.M(t)}M(t){if(!this.S){var i=J(n);this.S=new i((t=>{this.H(t)})),this.S.observe(t,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}}stop(){var t;null==(t=this.S)||t.disconnect(),this.S=void 0,n.removeEventListener("click",this.h),n.removeEventListener("scroll",this.k,{capture:!0}),n.removeEventListener("selectionchange",this.A),null==r||r.removeEventListener("visibilitychange",this.O)}H(t){this.P=Date.now()}j(){x(n,"click",this.h)}T(){x(n,"scroll",this.k,{capture:!0})}R(){x(n,"selectionchange",this.A)}L(){x(r,"visibilitychange",this.O)}v(t){return!(t&&(this.D.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.u.some((i=>i.node===t.node&&1e3>Math.abs(i.timestamp-t.timestamp)))&&!C(t.node,"html")&&O(t.node)&&!T.includes(t.node.tagName.toLowerCase()));var i,e}p(){if(this.u.length){clearTimeout(this.m),this.m=void 0;var t=this.u;for(var i of(this.u=[],t)){var e;i.mutationDelayMs=null!==(e=i.mutationDelayMs)&&void 0!==e?e:this.P&&this.P>=i.timestamp?this.P-i.timestamp:void 0,i.absoluteDelayMs=Date.now()-i.timestamp,i.selectionChangedDelayMs=this.$&&this.$>=i.timestamp?this.$-i.timestamp:void 0,i.visibilityChangedDelayMs=this.C?Math.abs(i.timestamp-this.C):void 0;var r=K(i.scrollDelayMs,this.D.scroll_threshold_ms),a=K(i.selectionChangedDelayMs,this.D.selection_change_threshold_ms),s=K(i.mutationDelayMs,this.D.mutation_threshold_ms),l=K(i.absoluteDelayMs,1.1*this.D.mutation_threshold_ms),o=b(i.scrollDelayMs)&&this.D.scroll_threshold_ms>i.scrollDelayMs,u=b(i.mutationDelayMs)&&this.D.mutation_threshold_ms>i.mutationDelayMs,c=b(i.selectionChangedDelayMs)&&this.D.selection_change_threshold_ms>i.selectionChangedDelayMs,h=b(i.visibilityChangedDelayMs)&&this.D.selection_change_threshold_ms>i.visibilityChangedDelayMs;if(!(o||u||c||h)){var d=K(i.visibilityChangedDelayMs,this.D.selection_change_threshold_ms);r||s||l||a||d?this._onCapture(i,{$dead_click_last_mutation_timestamp:this.P,$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.D.mutation_threshold_ms>i.absoluteDelayMs&&this.u.push(i)}}this.u.length&&v(this.m)&&(this.m=n.setTimeout((()=>{this.p()}),1e3))}}o(i,e){this.instance.capture("$dead_click",t({},e,Y(i.node,{e:i.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.D.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 Q(t,i)}(); //# sourceMappingURL=dead-clicks-autocapture.js.map